@marktiderman/genesis-native 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/{block-DlGnjjps.d.ts → block-BfJT3F6B.d.ts} +3 -3
- package/dist/{blocks-CF0agqxk.d.ts → blocks-DoY_Z-Lh.d.ts} +21 -4
- package/dist/{chunk-5STOXRTS.js → chunk-6UVWYJPZ.js} +7 -4
- package/dist/chunk-6UVWYJPZ.js.map +1 -0
- package/dist/{chunk-ZQVRCW5J.js → chunk-JWIBRHDE.js} +3 -3
- package/dist/{chunk-ZQVRCW5J.js.map → chunk-JWIBRHDE.js.map} +1 -1
- package/dist/{chunk-YIF4BFQH.js → chunk-JZHDEU4Q.js} +130 -13
- package/dist/chunk-JZHDEU4Q.js.map +1 -0
- package/dist/devtools.d.ts +36 -6
- package/dist/devtools.js +138 -98
- package/dist/devtools.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +5 -5
- package/dist/observability.js +3 -3
- package/dist/persist.d.ts +1 -1
- package/dist/push.d.ts +3 -3
- package/dist/{query--ihYsJWC.d.ts → query-DJFrykK_.d.ts} +38 -2
- package/dist/{screen-boundary-B8DlsLwb.d.ts → screen-boundary-Da3qleNz.d.ts} +5 -1
- package/dist/updates.d.ts +2 -2
- package/dist/updates.js +2 -2
- package/package.json +4 -4
- package/src/blocks.tsx +18 -3
- package/src/devtools/block.tsx +244 -144
- package/src/devtools/index.ts +1 -1
- package/src/errors.tsx +144 -13
- package/src/index.ts +4 -0
- package/src/screen-boundary.tsx +13 -2
- package/src/updates/signature.ts +13 -2
- package/dist/chunk-5STOXRTS.js.map +0 -1
- package/dist/chunk-M7S7F6L5.js +0 -49
- package/dist/chunk-M7S7F6L5.js.map +0 -1
- package/dist/chunk-YIF4BFQH.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -34,6 +34,10 @@ export {
|
|
|
34
34
|
FatalScreen,
|
|
35
35
|
type FatalScreenKind,
|
|
36
36
|
type FatalScreenViewProps,
|
|
37
|
+
type FatalScreenContact,
|
|
38
|
+
type FatalScreenLabels,
|
|
39
|
+
DEFAULT_FATAL_SCREEN_LABELS,
|
|
40
|
+
contactHref,
|
|
37
41
|
PlainFatalScreen,
|
|
38
42
|
GenesisErrorBoundary,
|
|
39
43
|
installGlobalErrorHandler,
|
package/src/screen-boundary.tsx
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { useEffect, useMemo, useRef, type ComponentType, type ReactNode } from "react";
|
|
21
21
|
import { reportError } from "@marktiderman/genesis-core/errors";
|
|
22
|
-
import { FatalScreen, GenesisErrorBoundary, type ErrorReport, type FatalScreenProps, type OnError } from "./errors";
|
|
22
|
+
import { FatalScreen, GenesisErrorBoundary, type ErrorReport, type FatalScreenContact, type FatalScreenLabels, type FatalScreenProps, type OnError } from "./errors";
|
|
23
23
|
|
|
24
24
|
/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */
|
|
25
25
|
export interface ScreenErrorProps {
|
|
@@ -48,6 +48,10 @@ export interface ScreenErrorBoundaryOptions {
|
|
|
48
48
|
onError?: OnError;
|
|
49
49
|
/** Wrappers around the route boundary, innermost first (Sentry's `wrapExpoRouterErrorBoundary`). */
|
|
50
50
|
wrap?: readonly ((boundary: ComponentType<ScreenErrorProps>) => ComponentType<ScreenErrorProps>)[];
|
|
51
|
+
/** "Contact support" on the default fallback (support's `support.contact()`), read when it shows. */
|
|
52
|
+
contact?: FatalScreenContact | (() => FatalScreenContact | null) | null;
|
|
53
|
+
/** The default fallback's words ("Contact support", "Report this"…), in English by default. */
|
|
54
|
+
labels?: Partial<FatalScreenLabels>;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -57,7 +61,14 @@ export interface ScreenErrorBoundaryOptions {
|
|
|
57
61
|
* @stability Beta
|
|
58
62
|
*/
|
|
59
63
|
export function createScreenErrorBoundary(options: ScreenErrorBoundaryOptions = {}): ComponentType<ScreenErrorProps> {
|
|
60
|
-
const
|
|
64
|
+
const { contact, labels } = options;
|
|
65
|
+
const Fallback =
|
|
66
|
+
options.fallback ??
|
|
67
|
+
(contact || labels
|
|
68
|
+
? (props: ScreenErrorProps) => (
|
|
69
|
+
<FatalScreen {...props} kind="screen" contact={typeof contact === "function" ? contact() : (contact ?? null)} {...(labels ? { labels } : {})} />
|
|
70
|
+
)
|
|
71
|
+
: ScreenFallback);
|
|
61
72
|
const onError = options.onError ?? reportThroughCore;
|
|
62
73
|
function GenesisScreenErrorBoundary(props: ScreenErrorProps) {
|
|
63
74
|
const reported = useRef<Error | null>(null);
|
package/src/updates/signature.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface VersionSignature {
|
|
|
38
38
|
otaNumber?: string | null;
|
|
39
39
|
/** The release's name (`buildMetadata`), or null. */
|
|
40
40
|
release?: string | null;
|
|
41
|
+
/** When it was built (`buildMetadata`), ISO, or null. */
|
|
42
|
+
builtAt?: string | null;
|
|
41
43
|
/** One line, for an About row. */
|
|
42
44
|
short: string;
|
|
43
45
|
/** Several lines, for a support report. */
|
|
@@ -49,6 +51,12 @@ export interface VersionSignature {
|
|
|
49
51
|
* every field optional.
|
|
50
52
|
*/
|
|
51
53
|
export interface BuildMetadata {
|
|
54
|
+
/** The app's version at build time (`genesis build-stamp`). */
|
|
55
|
+
version?: string | null;
|
|
56
|
+
/** The channel it was built or published for. */
|
|
57
|
+
channel?: string | null;
|
|
58
|
+
/** When it was built, ISO. */
|
|
59
|
+
builtAt?: string | null;
|
|
52
60
|
/** The commit the bundle was built from, full or short. */
|
|
53
61
|
commit?: string | null;
|
|
54
62
|
commitMessage?: string | null;
|
|
@@ -79,7 +87,7 @@ const given = (value: string | null | undefined): string | null => (typeof value
|
|
|
79
87
|
const metaText = (value: string | number | null | undefined): string | null => (typeof value === "number" && Number.isFinite(value) ? String(value) : given(typeof value === "string" ? value : null));
|
|
80
88
|
|
|
81
89
|
export function versionSignature({ application, updates, platform, requestedChannel = null, buildMetadata = null }: VersionSignatureInput): VersionSignature {
|
|
82
|
-
const version = given(application?.nativeApplicationVersion);
|
|
90
|
+
const version = given(application?.nativeApplicationVersion) ?? metaText(buildMetadata?.version);
|
|
83
91
|
const build = given(application?.nativeBuildVersion);
|
|
84
92
|
const on = Boolean(updates?.isEnabled);
|
|
85
93
|
const channel = on ? given(updates?.channel) : null;
|
|
@@ -114,5 +122,8 @@ export function versionSignature({ application, updates, platform, requestedChan
|
|
|
114
122
|
if (commit) lines.push(`Commit ${commit}`);
|
|
115
123
|
if (otaNumber) lines.push(`OTA ${otaNumber}`);
|
|
116
124
|
if (release) lines.push(`Release ${release}`);
|
|
117
|
-
|
|
125
|
+
const builtAt = metaText(buildMetadata?.builtAt);
|
|
126
|
+
const builtFor = metaText(buildMetadata?.channel);
|
|
127
|
+
if (builtAt || builtFor) lines.push(`Built ${builtAt ?? UNKNOWN}${builtFor ? ` for ${builtFor}` : ""}`);
|
|
128
|
+
return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, commit, otaNumber, release, builtAt, short, text: lines.join("\n") };
|
|
118
129
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updates/signature.ts"],"names":[],"mappings":";AAyEA,IAAM,OAAA,GAAU,SAAA;AAGhB,IAAM,KAAA,GAAQ,CAAC,KAAA,KAAqD,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,IAAA,EAAK,KAAM,EAAA,GAAK,KAAA,GAAQ,IAAA;AAE/H,IAAM,WAAW,CAAC,KAAA,KAA8D,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,QAAA,CAAS,KAAK,CAAA,GAAI,MAAA,CAAO,KAAK,CAAA,GAAI,KAAA,CAAM,OAAO,KAAA,KAAU,QAAA,GAAW,QAAQ,IAAI,CAAA;AAE7L,SAAS,gBAAA,CA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AAA,CAAE,CAAA;AAC5C,EAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,UAAU,OAAA,EAAS,gBAAA,EAAkB,gBAAgB,QAAA,EAAU,MAAA,EAAQ,SAAA,EAAW,MAAA,EAAQ,WAAW,OAAA,EAAS,KAAA,EAAO,MAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA,EAAE;AACvK","file":"chunk-5STOXRTS.js","sourcesContent":["/**\n * The version signature: which binary and which update this is, in one\n * line for Settings \"About\" and in a few lines for a support report.\n *\n * 1.4.0 (37) · preview · 3f2a9c1b\n * 1.4.0 (37) · production · embedded\n * 1.4.0 (37) · updates off\n *\n * A value the modules can't give is printed as `unknown`, never left out\n * (an empty string counts as not given: expo-updates gives `\"\"` for the\n * runtime version in a development build); one that doesn't apply, with\n * updates off, as `none`.\n *\n * With `buildMetadata` (a module the app writes at publish time: the commit,\n * the OTA number, the release), the signature also carries `commit`,\n * `otaNumber` and `release`, and the text names them. Without it they are\n * null and the text is as before.\n */\nimport type { ApplicationLike, UpdatesModuleLike } from \"./modules\";\n\nexport interface VersionSignature {\n version: string | null;\n build: string | null;\n platform: string;\n /** The build's channel (expo-updates). */\n channel: string | null;\n /** A channel picked on this device (a test build switched channels); `null` when it follows the build. */\n requestedChannel: string | null;\n runtimeVersion: string | null;\n updateId: string | null;\n /** `update`: a downloaded update runs. `embedded`: the binary's own code. `off`: updates are off (development, Expo Go). */\n launch: \"update\" | \"embedded\" | \"off\";\n /** expo-updates fell back to the embedded code after a failed launch. */\n emergency: boolean;\n /** The commit the bundle was built from (`buildMetadata`), or null. Optional for signatures made by hand. */\n commit?: string | null;\n /** The OTA number (`buildMetadata`), or null. */\n otaNumber?: string | null;\n /** The release's name (`buildMetadata`), or null. */\n release?: string | null;\n /** One line, for an About row. */\n short: string;\n /** Several lines, for a support report. */\n text: string;\n}\n\n/**\n * What the app stamps into its bundle when it publishes (a generated `build-metadata.ts` or JSON):\n * every field optional.\n */\nexport interface BuildMetadata {\n /** The commit the bundle was built from, full or short. */\n commit?: string | null;\n commitMessage?: string | null;\n branch?: string | null;\n /** The over-the-air update's number on its channel. */\n otaNumber?: string | number | null;\n /** The release's name (a tag, a date, a version). */\n release?: string | null;\n /** When the release or update was published, ISO. */\n publishedAt?: string | null;\n}\n\nexport interface VersionSignatureInput {\n application?: ApplicationLike;\n updates?: UpdatesModuleLike;\n /** `Platform.OS`. */\n platform: string;\n requestedChannel?: string | null;\n /** The commit, OTA number and release the app stamped at publish time. */\n buildMetadata?: BuildMetadata | null;\n}\n\nconst UNKNOWN = \"unknown\";\n\n/** A module's value, or null when it gave none (undefined, null or an empty string). */\nconst given = (value: string | null | undefined): string | null => (typeof value === \"string\" && value.trim() !== \"\" ? value : null);\n\nconst metaText = (value: string | number | null | undefined): string | null => (typeof value === \"number\" && Number.isFinite(value) ? String(value) : given(typeof value === \"string\" ? value : null));\n\nexport function versionSignature({ application, updates, platform, requestedChannel = null, buildMetadata = null }: VersionSignatureInput): VersionSignature {\n const version = given(application?.nativeApplicationVersion);\n const build = given(application?.nativeBuildVersion);\n const on = Boolean(updates?.isEnabled);\n const channel = on ? given(updates?.channel) : null;\n const updateId = on ? given(updates?.updateId) : null;\n const runtimeVersion = given(updates?.runtimeVersion);\n const launch: VersionSignature[\"launch\"] = !on ? \"off\" : updates?.isEmbeddedLaunch ? \"embedded\" : \"update\";\n const emergency = on && updates?.isEmergencyLaunch === true;\n const shownChannel = requestedChannel ?? channel;\n\n const head = `${version ?? UNKNOWN} (${build ?? UNKNOWN})`;\n const parts = [head];\n if (launch === \"off\") {\n parts.push(\"updates off\");\n } else {\n parts.push(shownChannel ?? \"no channel\");\n parts.push(launch === \"embedded\" ? \"embedded\" : (updateId?.slice(0, 8) ?? UNKNOWN));\n }\n if (emergency) parts.push(\"emergency launch\");\n const short = parts.join(\" · \");\n\n const lines = [\n `Version ${head}`,\n `Platform ${platform}`,\n `Channel ${channel ?? (on ? UNKNOWN : \"none\")}${requestedChannel && requestedChannel !== channel ? ` (switched to ${requestedChannel})` : \"\"}`,\n `Runtime ${runtimeVersion ?? (on ? UNKNOWN : \"none\")}`,\n `Update ${launch === \"off\" ? \"updates off\" : launch === \"embedded\" ? \"embedded\" : (updateId ?? UNKNOWN)}`,\n ];\n if (emergency) lines.push(`Emergency launch: ${updates?.emergencyLaunchReason ?? UNKNOWN}`);\n const commit = metaText(buildMetadata?.commit);\n const otaNumber = metaText(buildMetadata?.otaNumber);\n const release = metaText(buildMetadata?.release);\n if (commit) lines.push(`Commit ${commit}`);\n if (otaNumber) lines.push(`OTA ${otaNumber}`);\n if (release) lines.push(`Release ${release}`);\n return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, commit, otaNumber, release, short, text: lines.join(\"\\n\") };\n}\n"]}
|
package/dist/chunk-M7S7F6L5.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// src/blocks.tsx
|
|
4
|
-
function reportToBlocks(blocks, error, report) {
|
|
5
|
-
for (const block of blocks) {
|
|
6
|
-
if (!block.onError) continue;
|
|
7
|
-
try {
|
|
8
|
-
block.onError(error, report);
|
|
9
|
-
} catch {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
var BlocksContext = createContext(null);
|
|
14
|
-
var BlocksProvider = BlocksContext.Provider;
|
|
15
|
-
function useBlocks() {
|
|
16
|
-
const blocks = useContext(BlocksContext);
|
|
17
|
-
if (!blocks) throw new Error("useBlocks: no blocks. Render inside <GenesisNativeApp>.");
|
|
18
|
-
return blocks;
|
|
19
|
-
}
|
|
20
|
-
function useBlockSettings(sections, options = {}) {
|
|
21
|
-
const blocks = useContext(BlocksContext);
|
|
22
|
-
const rows = blocks?.settings ?? [];
|
|
23
|
-
const subtitles = rows.map((row) => row.useSubtitle?.());
|
|
24
|
-
return mergeBlockSettings(sections, rows, subtitles, options);
|
|
25
|
-
}
|
|
26
|
-
function mergeBlockSettings(sections, rows, subtitles = [], options = {}) {
|
|
27
|
-
const out = sections.map((s) => ({ ...s, rows: [...s.rows] }));
|
|
28
|
-
rows.forEach((row, i) => {
|
|
29
|
-
let section = out.find((s) => s.id === row.section);
|
|
30
|
-
if (!section) {
|
|
31
|
-
section = { id: row.section, title: options.sectionTitles?.[row.section] ?? row.section, rows: [] };
|
|
32
|
-
out.push(section);
|
|
33
|
-
}
|
|
34
|
-
const { navigate } = options;
|
|
35
|
-
const href = row.href;
|
|
36
|
-
section.rows.push({
|
|
37
|
-
id: row.id,
|
|
38
|
-
title: row.title,
|
|
39
|
-
subtitle: subtitles[i] ?? row.subtitle,
|
|
40
|
-
testID: row.testID,
|
|
41
|
-
...href && navigate ? { showChevron: true, onPress: () => navigate(href) } : {}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { BlocksProvider, mergeBlockSettings, reportToBlocks, useBlockSettings, useBlocks };
|
|
48
|
-
//# sourceMappingURL=chunk-M7S7F6L5.js.map
|
|
49
|
-
//# sourceMappingURL=chunk-M7S7F6L5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blocks.tsx"],"names":[],"mappings":";;;AA0CO,SAAS,cAAA,CAAe,MAAA,EAAgC,KAAA,EAAc,MAAA,EAA2B;AACtG,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,CAAC,MAAM,OAAA,EAAS;AACpB,IAAA,IAAI;AACF,MAAA,KAAA,CAAM,OAAA,CAAQ,OAAO,MAAM,CAAA;AAAA,IAC7B,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF;AAEA,IAAM,aAAA,GAAgB,cAAkD,IAAI,CAAA;AAGrE,IAAM,iBAAiB,aAAA,CAAc;AAQrC,SAAS,SAAA,GAAyC;AACvD,EAAA,MAAM,MAAA,GAAS,WAAW,aAAa,CAAA;AACvC,EAAA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IAAA,CAAK;AAAA,MAChB,IAAI,GAAA,CAAI,EAAA;AAAA,MACR,OAAO,GAAA,CAAI,KAAA;AAAA,MACX,QAAA,EAAU,SAAA,CAAU,CAAC,CAAA,IAAK,GAAA,CAAI,QAAA;AAAA,MAC9B,QAAQ,GAAA,CAAI,MAAA;AAAA,MACZ,GAAI,IAAA,IAAQ,QAAA,GAAW,EAAE,WAAA,EAAa,IAAA,EAAM,OAAA,EAAS,MAAM,QAAA,CAAS,IAAI,CAAA,EAAE,GAAI;AAAC,KAChF,CAAA;AAAA,EACH,CAAC,CAAA;AACD,EAAA,OAAO,GAAA;AACT","file":"chunk-M7S7F6L5.js","sourcesContent":["/**\n * Blocks on native: `defineBlock` declarations (from\n * `@marktiderman/genesis-config/blocks`) with the two things only a native\n * shell can run, boot steps behind the splash and a root around the screens.\n * `<GenesisNativeApp blocks={[…]}>` resolves them once, runs their steps,\n * mounts their roots, puts their slot fills under the app's own `slots`, and\n * hands their Settings rows to `useBlockSettings`.\n */\nimport { createContext, useContext, type ComponentType, type ReactNode } from \"react\";\nimport type { SlotPropsFor, Slots } from \"@marktiderman/genesis-core/slots\";\nimport type { BlockDef, BlockSettingsRow, Contributed, ResolvedBlocks } from \"@marktiderman/genesis-config/blocks\";\nimport type { BootStep } from \"./boot\";\nimport type { ErrorReport } from \"./errors\";\nimport type { NativeAppSlots } from \"./app\";\n\n/** What a block's `Root` is given: the app's slots, with every block's fills merged under them. @stability Beta */\nexport interface NativeBlockRootProps {\n slots?: Slots<NativeAppSlots>;\n slotProps?: SlotPropsFor<NativeAppSlots>;\n children?: ReactNode;\n}\n\n/**\n * A block a native shell can run. `contributes.slots` fills `GenesisNativeApp`\n * slots by name (the app's own `slots` win).\n *\n * @stability Beta\n */\nexport interface NativeBlock<Id extends string = string> extends BlockDef<Id, ComponentType<never>> {\n /** Run behind the splash after the app's own `steps`, before the session. A step that fails fails the boot, so keep them bounded. */\n readonly bootSteps?: readonly BootStep[];\n /** Mounted around the screens, inside the shell's error boundary. The first block's root is the outermost. */\n readonly Root?: ComponentType<NativeBlockRootProps>;\n /**\n * Every error the shell catches (render, global, boot, rejection), before\n * the app's own `onError`. The observability block reports them here. A\n * throw is ignored.\n */\n readonly onError?: (error: Error, report: ErrorReport) => void;\n}\n\n/** @internal Hand an error to each block's `onError`; one that throws never stops the rest. */\nexport function reportToBlocks(blocks: readonly NativeBlock[], error: Error, report: ErrorReport): void {\n for (const block of blocks) {\n if (!block.onError) continue;\n try {\n block.onError(error, report);\n } catch {\n // A failing reporter must not take the error path down with it.\n }\n }\n}\n\nconst BlocksContext = createContext<ResolvedBlocks<NativeBlock> | null>(null);\n\n/** @internal Provided by GenesisNativeApp. */\nexport const BlocksProvider = BlocksContext.Provider;\n\n/**\n * The resolved blocks: their ids, nav entries, Settings rows, routes and the\n * rest, each tagged with its FeatureId. Throws outside `GenesisNativeApp`.\n *\n * @stability Beta\n */\nexport function useBlocks(): ResolvedBlocks<NativeBlock> {\n const blocks = useContext(BlocksContext);\n if (!blocks) throw new Error(\"useBlocks: no blocks. Render inside <GenesisNativeApp>.\");\n return blocks;\n}\n\n/** A Settings section as `SettingsPage` from `@marktiderman/genesis-ui-native` takes it. @stability Beta */\nexport interface BlockSettingsSection<R extends { id: string; title: string } = SettingsRowLike> {\n id: string;\n title?: string;\n footnote?: string;\n rows: R[];\n}\n\n/** The row fields a block can fill. @stability Beta */\nexport interface SettingsRowLike {\n id: string;\n title: string;\n subtitle?: string;\n showChevron?: boolean;\n onPress?: () => void;\n testID?: string;\n}\n\n/** @stability Beta */\nexport interface UseBlockSettingsOptions {\n /** Open a row's `href` (expo-router's `router.push`). Without it, rows with an `href` aren't pressable. */\n navigate?: (href: string) => void;\n /** Titles for sections a block names that `sections` doesn't have. Default the section id. */\n sectionTitles?: Readonly<Record<string, string>>;\n}\n\n/**\n * The app's Settings sections with every block's rows added: each row goes\n * at the end of the section its `section` names (by `order`, then block\n * order), and a section no one has yet is added after the rest.\n *\n * Calls each row's `useSubtitle` hook, so call it unconditionally at the top\n * of the Settings screen. The blocks are fixed for the life of the app, so\n * the hooks run in the same order on every render.\n *\n * @stability Beta\n */\nexport function useBlockSettings<R extends SettingsRowLike>(\n sections: readonly BlockSettingsSection<R>[],\n options: UseBlockSettingsOptions = {},\n): BlockSettingsSection<R | SettingsRowLike>[] {\n const blocks = useContext(BlocksContext);\n const rows = blocks?.settings ?? [];\n // The same hooks in the same order every render: `rows` never changes once the shell has resolved it.\n const subtitles = rows.map((row) => row.useSubtitle?.());\n return mergeBlockSettings(sections, rows, subtitles, options);\n}\n\n/** The merge `useBlockSettings` does, without hooks (subtitles already read). @stability Beta */\nexport function mergeBlockSettings<R extends SettingsRowLike>(\n sections: readonly BlockSettingsSection<R>[],\n rows: readonly Contributed<BlockSettingsRow>[],\n subtitles: readonly (string | null | undefined)[] = [],\n options: UseBlockSettingsOptions = {},\n): BlockSettingsSection<R | SettingsRowLike>[] {\n const out: BlockSettingsSection<R | SettingsRowLike>[] = sections.map((s) => ({ ...s, rows: [...s.rows] }));\n rows.forEach((row, i) => {\n let section = out.find((s) => s.id === row.section);\n if (!section) {\n section = { id: row.section, title: options.sectionTitles?.[row.section] ?? row.section, rows: [] };\n out.push(section);\n }\n const { navigate } = options;\n const href = row.href;\n section.rows.push({\n id: row.id,\n title: row.title,\n subtitle: subtitles[i] ?? row.subtitle,\n testID: row.testID,\n ...(href && navigate ? { showChevron: true, onPress: () => navigate(href) } : {}),\n });\n });\n return out;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/boot.tsx","../src/errors.tsx","../src/screen-boundary.tsx"],"names":["jsx","reportError","ScreenFallback"],"mappings":";;;;;;;AA6DO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjC,IAAA;AAAA,EACT,WAAA,CAAY,IAAA,EAAc,EAAA,EAAY,MAAA,GAAS,gBAAA,EAAkB;AAC/D,IAAA,KAAA,CAAM,cAAc,IAAI,CAAA,EAAA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;AAAA,MAER;AAAA,IACF,CAAA,EAAG,CAAC,KAAA,CAAM,KAAK,CAAC,CAAA;AAChB,IAAA,uBAAOD,GAAAA,CAAC,QAAA,EAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAAA,EAC9B;AACA,EAAA,OAAA,CAAQ,OAAA,CAAQ,IAAA,IAAQ,EAAC,EAAG,MAAA,CAAwC,CAAC,KAAA,EAAO,IAAA,KAAS,IAAA,CAAK,KAAK,CAAA,EAAG,0BAA0B,CAAA;AAC9H;AAiBO,SAAS,oBAAoB,EAAE,QAAA,EAAU,QAAA,EAAU,OAAA,EAAS,UAAS,EAA6B;AACvG,EAAA,MAAM,SAAS,QAAA,IAAY,cAAA;AAE3B,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACf,MACE,SAASE,eAAAA,CAAe,EAAE,KAAA,EAAO,OAAM,EAAqB;AAC1D,MAAA,uBAAOF,GAAAA,CAAC,MAAA,EAAA,EAAO,OAAc,KAAA,EAAO,YAAY,OAAM,EAAG,CAAA;AAAA,IAC3D,CAAA;AAAA,IACF,CAAC,MAAM;AAAA,GACT;AACA,EAAA,uBACEA,GAAAA,CAAC,oBAAA,EAAA,EAAqB,QAAA,EAAU,QAAA,EAAU,OAAA,EAAS,OAAA,IAAW,iBAAA,EAAmB,QAAA,EAAoB,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO,UACvH,QAAA,EACH,CAAA;AAEJ","file":"chunk-YIF4BFQH.js","sourcesContent":["/**\n * Boot: the async work an app must finish before its first screen (wipe a\n * session left by a reinstall, hydrate stores, load fonts, restore the query\n * cache, read the session).\n *\n * Steps run once each, in order. A step that finished is never run again, so\n * \"try again\" after a failure resumes at the step that failed. Each step has a\n * timeout (10 seconds by default), so a hung step ends in the fatal screen with\n * retry instead of trapping the splash. A minimum keeps a fast boot from\n * flashing the splash.\n *\n * `createBoot` is the controller (no React); `BootProvider` + `useBoot()` read\n * it from components.\n */\nimport { createContext, useContext, useSyncExternalStore, type ReactNode } from \"react\";\n\nexport interface BootStepContext {\n /**\n * Aborted when the step times out. Stop work when it fires: a retry waits\n * for a timed-out run to settle before running the step again.\n */\n signal: AbortSignal;\n}\n\nexport interface BootStep {\n /** Unique within the list; names the step in errors. */\n id: string;\n run: (context: BootStepContext) => Promise<unknown> | unknown;\n /** Overrides the boot's `timeoutMs` for this step. */\n timeoutMs?: number;\n}\n\nexport type BootStatus = \"idle\" | \"booting\" | \"ready\" | \"failed\";\n\nexport interface BootState {\n status: BootStatus;\n /** Set when `status` is `\"failed\"`. */\n error: Error | null;\n /** The id of the step that failed. */\n failedStep: string | null;\n /** Ids of the steps that have finished, in order. */\n completed: readonly string[];\n}\n\nexport interface BootOptions {\n /** Shortest time the boot takes, so the splash doesn't flash. Default 0. */\n minimumMs?: number;\n /** Longest time one step may take. Default 10 000. */\n timeoutMs?: number;\n}\n\nexport interface BootController {\n getState(): BootState;\n subscribe(listener: () => void): () => void;\n /** Run the steps not yet finished. Calling it while a run is in flight returns that run. */\n start(): Promise<void>;\n /** After a failure: run again from the step that failed. */\n retry(): Promise<void>;\n}\n\n/** Thrown when a step takes longer than its timeout. */\nexport class BootTimeoutError extends Error {\n readonly step: string;\n constructor(step: string, ms: number, reason = \"did not finish\") {\n super(`Boot step \"${step}\" ${reason} within ${ms} ms.`);\n this.name = \"BootTimeoutError\";\n this.step = step;\n }\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nexport function toError(value: unknown): Error {\n if (value instanceof Error) return value;\n return new Error(typeof value === \"string\" ? value : \"Unknown error\", { cause: value });\n}\n\n/** Resolves \"settled\" when `promise` settles, \"pending\" after `ms`. */\nfunction settledWithin(promise: Promise<unknown>, ms: number): Promise<\"settled\" | \"pending\"> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n return Promise.race([\n promise.then(\n () => \"settled\" as const,\n () => \"settled\" as const,\n ),\n new Promise<\"pending\">((resolve) => {\n timer = setTimeout(() => resolve(\"pending\"), ms);\n }),\n ]).finally(() => clearTimeout(timer));\n}\n\n/** The boot controller: runs `steps` once each, in order, with a timeout per step. */\nexport function createBoot(steps: readonly BootStep[], options: BootOptions = {}): BootController {\n const seen = new Set<string>();\n for (const step of steps) {\n if (seen.has(step.id)) throw new Error(`Boot step \"${step.id}\" is listed twice.`);\n seen.add(step.id);\n }\n const { minimumMs = 0, timeoutMs = DEFAULT_TIMEOUT_MS } = options;\n const listeners = new Set<() => void>();\n let state: BootState = { status: \"idle\", error: null, failedStep: null, completed: [] };\n let inFlight: Promise<void> | null = null;\n // A step that timed out keeps running (JavaScript can't stop it; `signal`\n // asks it to). A retry waits for it rather than running it twice at once.\n const abandoned = new Map<string, Promise<\"ok\" | \"failed\">>();\n\n const runStep = async (step: BootStep, ms: number): Promise<void> => {\n const previous = abandoned.get(step.id);\n if (previous) {\n if ((await settledWithin(previous, ms)) === \"pending\") {\n throw new BootTimeoutError(step.id, ms, \"is still running from the last attempt\");\n }\n abandoned.delete(step.id);\n // The abandoned run finished after all: it counts.\n if ((await previous) === \"ok\") return;\n }\n const controller = new AbortController();\n const running = Promise.resolve().then(() => step.run({ signal: controller.signal }));\n if ((await settledWithin(running, ms)) === \"pending\") {\n controller.abort();\n abandoned.set(step.id, running.then(() => \"ok\" as const, () => \"failed\" as const));\n throw new BootTimeoutError(step.id, ms);\n }\n await running;\n };\n\n const set = (next: Partial<BootState>) => {\n state = { ...state, ...next };\n for (const listener of listeners) listener();\n };\n\n const run = async () => {\n const started = Date.now();\n set({ status: \"booting\", error: null, failedStep: null });\n for (const step of steps) {\n if (state.completed.includes(step.id)) continue;\n try {\n await runStep(step, step.timeoutMs ?? timeoutMs);\n } catch (error) {\n set({ status: \"failed\", error: toError(error), failedStep: step.id });\n return;\n }\n set({ completed: [...state.completed, step.id] });\n }\n const wait = minimumMs - (Date.now() - started);\n if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait));\n set({ status: \"ready\" });\n };\n\n const start = () => {\n if (state.status === \"ready\") return Promise.resolve();\n if (!inFlight) {\n inFlight = run().finally(() => {\n inFlight = null;\n });\n }\n return inFlight;\n };\n\n return {\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n start,\n retry: start,\n };\n}\n\nconst BootContext = createContext<BootController | null>(null);\n\n/** Makes a boot readable with `useBoot()`. */\nexport function BootProvider({ boot, children }: { boot: BootController; children: ReactNode }) {\n return <BootContext.Provider value={boot}>{children}</BootContext.Provider>;\n}\n\nexport interface UseBootReturn extends BootState {\n retry: () => void;\n}\n\n/** The boot's status, and `retry` after a failure. Inside `GenesisNativeApp` or a `BootProvider`. */\nexport function useBoot(): UseBootReturn {\n const boot = useContext(BootContext);\n if (!boot) throw new Error(\"useBoot must be used inside <GenesisNativeApp> or <BootProvider>.\");\n const state = useSyncExternalStore(boot.subscribe, boot.getState, boot.getState);\n return { ...state, retry: () => void boot.retry() };\n}\n","/**\n * Errors: a boundary per screen tree, and handlers for errors React never sees\n * (a fatal global error from `ErrorUtils`, an unhandled promise rejection).\n * All of them report through one `onError` (wire Sentry there) and show the\n * fatal screen instead of letting the app die; its \"Try again\" remounts the\n * tree with fresh state.\n */\nimport { Component, type ComponentType, type ErrorInfo, type ReactNode } from \"react\";\nimport { Pressable, Text, View } from \"react-native\";\nimport { NativeButton, NativeEmptyState } from \"@marktiderman/genesis-ui-native/components\";\nimport { classifyError, reportError } from \"@marktiderman/genesis-core/errors\";\nimport { toError } from \"./boot\";\n\ndeclare const __DEV__: boolean | undefined;\n\n/**\n * What a fatal or screen error says under its title: the safe sentence for\n * its kind (offline, signed out…), or nothing for a plain bug. The error's\n * own text can hold an email, an id or a store's internals, so it is shown\n * only in development builds.\n */\nexport function errorDetails(error: Error): string | undefined {\n if (typeof __DEV__ !== \"undefined\" && __DEV__) return error.message;\n const classified = classifyError(error);\n return classified.kind === \"unexpected\" ? undefined : classified.message;\n}\n\nexport interface FatalScreenProps {\n error: Error;\n /** Clears the error and remounts the app below the shell (and re-runs a failed boot). */\n retry: () => void;\n}\n\n/** Which fatal screen: the app's, one screen's, or the last-resort plain one. */\nexport type FatalScreenKind = \"app\" | \"screen\" | \"plain\";\n\nexport interface FatalScreenViewProps {\n error: Error;\n /** Clears the error and renders again (a screen's retry may be async, as Expo Router's is). */\n retry: () => void | Promise<void>;\n /**\n * `app` (default): the app hit a problem, \"Try again\" remounts it. `screen`: one screen failed\n * and the rest of the app still works (the screen boundary's default). `plain`: React Native\n * primitives only, no theme, no context, nothing that can itself fail; shown when the providers\n * could not start, or when the `fatal` slot threw.\n */\n kind?: FatalScreenKind;\n}\n\nconst runRetry = (retry: FatalScreenViewProps[\"retry\"], source: string) => () => {\n void Promise.resolve(retry()).catch((e: unknown) => reportError(e, source));\n};\n\n/**\n * The fatal screen: what went wrong and \"Try again\", for the whole app, one screen, or (with\n * `kind=\"plain\"`) the last resort that needs nothing above it.\n */\nexport function FatalScreen({ error, retry, kind = \"app\" }: FatalScreenViewProps) {\n if (kind === \"plain\") {\n return (\n <View testID=\"genesis-fatal-plain\" style={{ flex: 1, justifyContent: \"center\", alignItems: \"center\", padding: 24, gap: 12 }}>\n <Text accessibilityRole=\"header\" style={{ fontSize: 17, fontWeight: \"600\" }}>\n Something went wrong\n </Text>\n <Text style={{ textAlign: \"center\" }}>{errorDetails(error) ?? \"Try again, and if it keeps happening, close and reopen the app.\"}</Text>\n <Pressable accessibilityRole=\"button\" onPress={() => void retry()} testID=\"genesis-fatal-plain-retry\" style={{ padding: 12 }}>\n <Text style={{ fontSize: 17 }}>Try again</Text>\n </Pressable>\n </View>\n );\n }\n const screen = kind === \"screen\";\n return (\n <NativeEmptyState\n variant=\"error\"\n title={screen ? \"This screen hit a problem\" : \"Something went wrong\"}\n body={\n screen\n ? \"The rest of the app still works. Try again, or go back.\"\n : \"The app hit a problem. Try again, and if it keeps happening, close and reopen the app.\"\n }\n details={errorDetails(error)}\n primaryAction={\n <NativeButton\n onPress={screen ? runRetry(retry, \"native:screen-retry\") : () => void retry()}\n testID={screen ? \"genesis-screen-error-retry\" : \"genesis-fatal-retry\"}\n >\n Try again\n </NativeButton>\n }\n testID={screen ? \"genesis-screen-error\" : \"genesis-fatal\"}\n />\n );\n}\n\n/**\n * The last-resort fatal screen.\n *\n * @deprecated Use `<FatalScreen kind=\"plain\" />`; this name goes at the next major.\n */\nexport function PlainFatalScreen(props: FatalScreenProps) {\n return <FatalScreen {...props} kind=\"plain\" />;\n}\n\nexport interface ErrorReport {\n /** True when the app could not go on (a render error, a failed boot, a fatal global error). */\n fatal: boolean;\n /**\n * `boundary` (the shell's), `screen` (a screen boundary), `global`, `boot`,\n * `rejection`, `query` and `mutation` (a failed query or mutation the\n * shell's query client saw).\n */\n source: \"boundary\" | \"screen\" | \"global\" | \"boot\" | \"rejection\" | \"query\" | \"mutation\";\n componentStack?: string;\n /** False when nothing caught it (an unhandled promise rejection). Default: handled unless fatal. */\n handled?: boolean;\n /** Low-cardinality labels (`query.key`), never ids. */\n tags?: Readonly<Record<string, string>>;\n}\n\nexport type OnError = (error: Error, report: ErrorReport) => void;\n\nexport interface GenesisErrorBoundaryProps {\n children?: ReactNode;\n /** What to render instead of the tree that threw. */\n fallback: ComponentType<FatalScreenProps>;\n onError?: OnError;\n /** Change it to clear a caught error (the tree remounts). */\n resetKey?: unknown;\n /** Called by the fallback's retry, after the error is cleared. */\n onRetry?: () => void;\n /** Reported as fatal (the app could not go on). Default true; a screen boundary reports false. */\n fatal?: boolean;\n /** The report's source. Default `boundary`. */\n source?: ErrorReport[\"source\"];\n}\n\ninterface BoundaryState {\n error: Error | null;\n}\n\n/** An error boundary whose fallback gets `{ error, retry }`. */\nexport class GenesisErrorBoundary extends Component<GenesisErrorBoundaryProps, BoundaryState> {\n override state: BoundaryState = { error: null };\n\n static getDerivedStateFromError(error: unknown): BoundaryState {\n return { error: toError(error) };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo) {\n try {\n this.props.onError?.(toError(error), {\n fatal: this.props.fatal ?? true,\n source: this.props.source ?? \"boundary\",\n componentStack: info.componentStack ?? undefined,\n });\n } catch {\n // A failing reporter must not stop the fallback.\n }\n }\n\n override componentDidUpdate(previous: GenesisErrorBoundaryProps) {\n if (this.state.error && previous.resetKey !== this.props.resetKey) this.setState({ error: null });\n }\n\n retry = () => {\n this.setState({ error: null });\n this.props.onRetry?.();\n };\n\n override render() {\n const { error } = this.state;\n if (!error) return this.props.children ?? null;\n const Fallback = this.props.fallback;\n return <Fallback error={error} retry={this.retry} />;\n }\n}\n\n/** React Native's `ErrorUtils` (a global in every RN app), or a stand-in. */\nexport interface ErrorUtilsLike {\n getGlobalHandler(): ((error: unknown, isFatal?: boolean) => void) | undefined;\n setGlobalHandler(handler: (error: unknown, isFatal?: boolean) => void): void;\n}\n\nexport interface GlobalErrorHandlerOptions {\n errorUtils: ErrorUtilsLike;\n onError?: OnError;\n /** A fatal error: show the fatal screen. The previous handler (which would end the app) is not called. */\n onFatal: (error: Error) => void;\n /**\n * True while a fatal screen is already up. Another fatal error then goes to\n * the previous handler, which ends the app (it restarts clean) rather than\n * leaving it stuck behind a screen that may itself be broken.\n */\n alreadyFatal?: () => boolean;\n}\n\n/**\n * Route global errors to `onError`. A fatal one goes to `onFatal` instead of\n * React Native's default handler, which would close the app; a non-fatal one\n * still reaches the previous handler (LogBox in development). Returns a\n * function that puts the previous handler back.\n */\nexport function installGlobalErrorHandler({ errorUtils, onError, onFatal, alreadyFatal }: GlobalErrorHandlerOptions): () => void {\n const previous = errorUtils.getGlobalHandler();\n errorUtils.setGlobalHandler((raw, isFatal) => {\n const error = toError(raw);\n try {\n onError?.(error, { fatal: Boolean(isFatal), source: \"global\" });\n } catch {\n // A failing reporter must not take the handler down with it.\n }\n if (isFatal && !alreadyFatal?.()) onFatal(error);\n else previous?.(raw, isFatal);\n });\n return () => {\n // With no previous handler, leave one that only logs, never ours (it would call an unmounted app).\n // genesis-allow-console: the last handler left once the shell is gone; nothing else is listening.\n errorUtils.setGlobalHandler(previous ?? ((error) => console.error(error)));\n };\n}\n\n/** `globalThis.ErrorUtils` in a React Native runtime, undefined elsewhere. */\nexport function defaultErrorUtils(): ErrorUtilsLike | undefined {\n const candidate = (globalThis as { ErrorUtils?: ErrorUtilsLike }).ErrorUtils;\n return candidate && typeof candidate.setGlobalHandler === \"function\" ? candidate : undefined;\n}\n\n/** Hermes's `HermesInternal.enablePromiseRejectionTracker`, or a stand-in. */\nexport type EnableRejectionTracker = (options: {\n allRejections: boolean;\n onUnhandled: (id: number, rejection: unknown) => void;\n onHandled: (id: number) => void;\n}) => void;\n\n/**\n * Hermes's rejection tracker, when the app runs on Hermes. React Native sends\n * unhandled rejections to `ExceptionsManager` (LogBox in development), never\n * to `ErrorUtils`' global handler, so without this they never reach `onError`.\n */\nexport function defaultRejectionTracker(): EnableRejectionTracker | undefined {\n const hermes = (globalThis as { HermesInternal?: { enablePromiseRejectionTracker?: EnableRejectionTracker } }).HermesInternal;\n const enable = hermes?.enablePromiseRejectionTracker;\n return typeof enable === \"function\" ? enable.bind(hermes) : undefined;\n}\n\n/**\n * Report unhandled promise rejections to `onError`: non-fatal, and unhandled\n * (`handled: false`), so release health counts them. This replaces React\n * Native's own tracker, so each rejection is also written with\n * `console.warn`, which LogBox shows in development as before.\n */\nexport function installRejectionTracker({ enable, onError }: { enable: EnableRejectionTracker; onError: OnError }): void {\n enable({\n allRejections: true,\n onUnhandled: (id, rejection) => {\n const error = toError(rejection);\n // genesis-allow-console: React Native's own tracker writes this warning; replacing it must too (LogBox).\n console.warn(`Uncaught (in promise, id: ${id}): ${error.message}`);\n try {\n onError(error, { fatal: false, handled: false, source: \"rejection\" });\n } catch {\n // A failing reporter must not throw inside the promise machinery.\n }\n },\n onHandled: () => {},\n });\n}\n","/**\n * Screen errors: one screen fails, the rest of the app (the tab bar, the\n * other tabs) keeps working. The error is reported non-fatal, and \"Try\n * again\" renders the screen again.\n *\n * With Expo Router, export the boundary from a route or layout file; it\n * catches errors in that route and the routes below it:\n *\n * // src/lib/observability.ts\n * export const ScreenErrorBoundary = observability.screenBoundary();\n * // src/app/(app)/messages/_layout.tsx\n * export { ScreenErrorBoundary as ErrorBoundary } from \"@/lib/observability\";\n *\n * `observability.screenBoundary()` reports through the block and wraps the\n * boundary with each sink's route wrapper (Sentry's\n * `wrapExpoRouterErrorBoundary`). Without the block,\n * `createScreenErrorBoundary()` reports through `reportError` from\n * genesis-core. Outside Expo Router, wrap a subtree in `<ScreenErrorBoundary>`.\n */\nimport { useEffect, useMemo, useRef, type ComponentType, type ReactNode } from \"react\";\nimport { reportError } from \"@marktiderman/genesis-core/errors\";\nimport { FatalScreen, GenesisErrorBoundary, type ErrorReport, type FatalScreenProps, type OnError } from \"./errors\";\n\n/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */\nexport interface ScreenErrorProps {\n error: Error;\n retry: () => Promise<void>;\n}\n\n/**\n * The default screen fallback: the screen hit a problem, and \"Try again\".\n *\n * @deprecated Use `<FatalScreen kind=\"screen\" />`; this name goes at the next major.\n */\nexport function ScreenErrorScreen(props: ScreenErrorProps) {\n return <FatalScreen {...props} kind=\"screen\" />;\n}\n\nconst ScreenFallback = (props: ScreenErrorProps) => <FatalScreen {...props} kind=\"screen\" />;\n\nconst reportThroughCore = (error: Error, report: ErrorReport) =>\n reportError(error, { source: report.source, fatal: report.fatal, ...(report.tags ? { tags: report.tags } : {}) });\n\nexport interface ScreenErrorBoundaryOptions {\n /** What to show. Default `<FatalScreen kind=\"screen\" />`. */\n fallback?: ComponentType<ScreenErrorProps>;\n /** Where the error goes. Default `reportError` from genesis-core (the observability block, when it is on). */\n onError?: OnError;\n /** Wrappers around the route boundary, innermost first (Sentry's `wrapExpoRouterErrorBoundary`). */\n wrap?: readonly ((boundary: ComponentType<ScreenErrorProps>) => ComponentType<ScreenErrorProps>)[];\n}\n\n/**\n * An Expo Router `ErrorBoundary`: reports each error once (non-fatal, source\n * `screen`) and shows `fallback`. Build it once, at module scope.\n *\n * @stability Beta\n */\nexport function createScreenErrorBoundary(options: ScreenErrorBoundaryOptions = {}): ComponentType<ScreenErrorProps> {\n const Fallback = options.fallback ?? ScreenFallback;\n const onError = options.onError ?? reportThroughCore;\n function GenesisScreenErrorBoundary(props: ScreenErrorProps) {\n const reported = useRef<Error | null>(null);\n useEffect(() => {\n if (reported.current === props.error) return;\n reported.current = props.error;\n try {\n onError(props.error, { fatal: false, source: \"screen\" });\n } catch {\n // A failing reporter must not take the fallback down with it.\n }\n }, [props.error]);\n return <Fallback {...props} />;\n }\n return (options.wrap ?? []).reduce<ComponentType<ScreenErrorProps>>((inner, wrap) => wrap(inner), GenesisScreenErrorBoundary);\n}\n\nexport interface ScreenErrorBoundaryProps {\n children?: ReactNode;\n fallback?: ComponentType<ScreenErrorProps>;\n /** Default `reportError` from genesis-core. */\n onError?: OnError;\n /** Change it to clear a caught error. */\n resetKey?: unknown;\n}\n\n/**\n * A boundary around part of a screen tree, for apps without Expo Router's\n * per-route boundaries: non-fatal, reported, with \"Try again\".\n *\n * @stability Beta\n */\nexport function ScreenErrorBoundary({ children, fallback, onError, resetKey }: ScreenErrorBoundaryProps) {\n const Screen = fallback ?? ScreenFallback;\n // The boundary's retry is synchronous; the screen's (Expo Router's shape) returns a promise.\n const Fallback = useMemo(\n () =>\n function ScreenFallback({ error, retry }: FatalScreenProps) {\n return <Screen error={error} retry={async () => retry()} />;\n },\n [Screen],\n );\n return (\n <GenesisErrorBoundary fallback={Fallback} onError={onError ?? reportThroughCore} resetKey={resetKey} fatal={false} source=\"screen\">\n {children}\n </GenesisErrorBoundary>\n );\n}\n"]}
|