@marktiderman/genesis-native 0.11.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.
Files changed (48) hide show
  1. package/README.md +13 -3
  2. package/dist/{block-Iga-mCeC.d.ts → block-BfJT3F6B.d.ts} +3 -3
  3. package/dist/{blocks-BQY_df3j.d.ts → blocks-DoY_Z-Lh.d.ts} +69 -7
  4. package/dist/{chunk-6BT4PTGH.js → chunk-6UVWYJPZ.js} +15 -5
  5. package/dist/chunk-6UVWYJPZ.js.map +1 -0
  6. package/dist/{chunk-EWHO5WQU.js → chunk-JWIBRHDE.js} +21 -9
  7. package/dist/chunk-JWIBRHDE.js.map +1 -0
  8. package/dist/{chunk-YIF4BFQH.js → chunk-JZHDEU4Q.js} +130 -13
  9. package/dist/chunk-JZHDEU4Q.js.map +1 -0
  10. package/dist/devtools.d.ts +101 -8
  11. package/dist/devtools.js +180 -104
  12. package/dist/devtools.js.map +1 -1
  13. package/dist/index.d.ts +5 -5
  14. package/dist/index.js +4 -5
  15. package/dist/index.js.map +1 -1
  16. package/dist/observability.d.ts +14 -8
  17. package/dist/observability.js +3 -3
  18. package/dist/persist.d.ts +1 -1
  19. package/dist/push.d.ts +4 -4
  20. package/dist/push.js +1 -1
  21. package/dist/push.js.map +1 -1
  22. package/dist/{query--ihYsJWC.d.ts → query-DJFrykK_.d.ts} +38 -2
  23. package/dist/{screen-boundary-B8DlsLwb.d.ts → screen-boundary-Da3qleNz.d.ts} +5 -1
  24. package/dist/updates.d.ts +3 -3
  25. package/dist/updates.js +6 -6
  26. package/dist/updates.js.map +1 -1
  27. package/package.json +50 -8
  28. package/src/app.tsx +2 -1
  29. package/src/blocks.tsx +20 -5
  30. package/src/devtools/block.tsx +281 -152
  31. package/src/devtools/index.ts +4 -3
  32. package/src/devtools/settings.ts +50 -0
  33. package/src/devtools/slots.ts +15 -0
  34. package/src/errors.tsx +144 -13
  35. package/src/index.ts +4 -0
  36. package/src/observability/block.tsx +1 -1
  37. package/src/observability/index.ts +1 -1
  38. package/src/observability/scrub.ts +22 -4
  39. package/src/push/block.tsx +1 -1
  40. package/src/screen-boundary.tsx +13 -2
  41. package/src/updates/block.tsx +7 -5
  42. package/src/updates/index.ts +1 -1
  43. package/src/updates/signature.ts +52 -3
  44. package/dist/chunk-65P7RU4V.js +0 -49
  45. package/dist/chunk-65P7RU4V.js.map +0 -1
  46. package/dist/chunk-6BT4PTGH.js.map +0 -1
  47. package/dist/chunk-EWHO5WQU.js.map +0 -1
  48. package/dist/chunk-YIF4BFQH.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { createContext, useContext, useSyncExternalStore, Component, useMemo, useRef, useEffect } from 'react';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { View, Text, Pressable } from 'react-native';
4
- import { NativeEmptyState, NativeButton } from '@marktiderman/genesis-ui-native/components';
3
+ import { View, Text, Pressable, Linking } from 'react-native';
4
+ import { NativeEmptyState, NativeButton, Inline } from '@marktiderman/genesis-ui-native/components';
5
5
  import { classifyError, reportError } from '@marktiderman/genesis-core/errors';
6
6
 
7
7
  // src/boot.tsx
@@ -109,42 +109,158 @@ function useBoot() {
109
109
  const state = useSyncExternalStore(boot.subscribe, boot.getState, boot.getState);
110
110
  return { ...state, retry: () => void boot.retry() };
111
111
  }
112
+ function reportToBlocks(blocks, error, report) {
113
+ for (const block of blocks) {
114
+ if (!block.onError) continue;
115
+ try {
116
+ block.onError(error, report);
117
+ } catch {
118
+ }
119
+ }
120
+ }
121
+ var BlocksContext = createContext(null);
122
+ var BlocksProvider = BlocksContext.Provider;
123
+ function useOptionalBlocks() {
124
+ return useContext(BlocksContext);
125
+ }
126
+ function useBlocks() {
127
+ const blocks = useContext(BlocksContext);
128
+ if (!blocks) throw new Error("useBlocks: no blocks. Render inside <GenesisNativeApp>.");
129
+ return blocks;
130
+ }
131
+ function useBlockSettings(sections, options = {}) {
132
+ const blocks = useContext(BlocksContext);
133
+ const rows = blocks?.settings ?? [];
134
+ const subtitles = rows.map((row) => row.useSubtitle?.());
135
+ const shown = rows.map((row) => row.useShown?.() ?? true);
136
+ return mergeBlockSettings(sections, rows, subtitles, options, shown);
137
+ }
138
+ function mergeBlockSettings(sections, rows, subtitles = [], options = {}, shown = []) {
139
+ const out = sections.map((s) => ({ ...s, rows: [...s.rows] }));
140
+ rows.forEach((row, i) => {
141
+ if (shown[i] === false) return;
142
+ let section = out.find((s) => s.id === row.section);
143
+ if (!section) {
144
+ section = { id: row.section, title: options.sectionTitles?.[row.section] ?? row.section, rows: [] };
145
+ out.push(section);
146
+ }
147
+ const { navigate } = options;
148
+ const href = row.href;
149
+ section.rows.push({
150
+ id: row.id,
151
+ title: row.title,
152
+ subtitle: subtitles[i] ?? row.subtitle,
153
+ testID: row.testID,
154
+ ...href && navigate ? { showChevron: true, onPress: () => navigate(href) } : {}
155
+ });
156
+ });
157
+ return out;
158
+ }
112
159
  function errorDetails(error) {
113
160
  if (typeof __DEV__ !== "undefined" && __DEV__) return error.message;
114
161
  const classified = classifyError(error);
115
162
  return classified.kind === "unexpected" ? void 0 : classified.message;
116
163
  }
164
+ var DEFAULT_FATAL_SCREEN_LABELS = {
165
+ title: "Something went wrong",
166
+ body: "The app hit a problem. Try again, and if it keeps happening, close and reopen the app.",
167
+ screenTitle: "This screen hit a problem",
168
+ screenBody: "The rest of the app still works. Try again, or go back.",
169
+ plainBody: "Try again, and if it keeps happening, close and reopen the app.",
170
+ retry: "Try again",
171
+ contact: "Contact support",
172
+ report: "Report this"
173
+ };
174
+ function httpsPage(text) {
175
+ const t = text?.trim();
176
+ if (!t || t.length > 2048 || !/^https:\/\//i.test(t)) return null;
177
+ try {
178
+ const u = new URL(t);
179
+ return u.protocol === "https:" && u.hostname ? t : null;
180
+ } catch {
181
+ return null;
182
+ }
183
+ }
184
+ function looksLikeEmail(text) {
185
+ if (text.length > 254) return false;
186
+ let at = -1;
187
+ for (let i = 0; i < text.length; i++) {
188
+ const c = text.charCodeAt(i);
189
+ if (c <= 32 || c === 60 || c === 62 || c === 127) return false;
190
+ if (c === 64) {
191
+ if (at !== -1) return false;
192
+ at = i;
193
+ }
194
+ }
195
+ const dot = text.lastIndexOf(".");
196
+ return at > 0 && dot > at + 1 && dot < text.length - 1;
197
+ }
198
+ function contactHref(contact) {
199
+ const url = httpsPage(contact?.url);
200
+ if (url) return url;
201
+ const email = contact?.email?.trim();
202
+ if (email && looksLikeEmail(email)) return `mailto:${email.replace(/[%?#&/]/g, (c) => encodeURIComponent(c))}`;
203
+ return null;
204
+ }
205
+ var openContact = (href) => () => {
206
+ void Linking.openURL(href).catch((e) => reportError(e, "native:contact"));
207
+ };
117
208
  var runRetry = (retry, source) => () => {
118
209
  void Promise.resolve(retry()).catch((e) => reportError(e, source));
119
210
  };
120
- function FatalScreen({ error, retry, kind = "app" }) {
211
+ function FatalScreen({ error, retry, kind = "app", contact, onReport, labels: given }) {
212
+ const blocks = useOptionalBlocks();
213
+ const labels = { ...DEFAULT_FATAL_SCREEN_LABELS, ...given };
214
+ const href = contactHref(contact);
121
215
  if (kind === "plain") {
122
216
  return /* @__PURE__ */ jsxs(View, { testID: "genesis-fatal-plain", style: { flex: 1, justifyContent: "center", alignItems: "center", padding: 24, gap: 12 }, children: [
123
- /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: { fontSize: 17, fontWeight: "600" }, children: "Something went wrong" }),
124
- /* @__PURE__ */ jsx(Text, { style: { textAlign: "center" }, children: errorDetails(error) ?? "Try again, and if it keeps happening, close and reopen the app." }),
125
- /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => void retry(), testID: "genesis-fatal-plain-retry", style: { padding: 12 }, children: /* @__PURE__ */ jsx(Text, { style: { fontSize: 17 }, children: "Try again" }) })
217
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: { fontSize: 17, fontWeight: "600" }, children: labels.title }),
218
+ /* @__PURE__ */ jsx(Text, { style: { textAlign: "center" }, children: errorDetails(error) ?? labels.plainBody }),
219
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => void retry(), testID: "genesis-fatal-plain-retry", style: { padding: 12 }, children: /* @__PURE__ */ jsx(Text, { style: { fontSize: 17 }, children: labels.retry }) }),
220
+ href ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "link", onPress: openContact(href), testID: "genesis-fatal-plain-contact", style: { padding: 12 }, children: /* @__PURE__ */ jsx(Text, { style: { fontSize: 15 }, children: labels.contact }) }) : null
126
221
  ] });
127
222
  }
128
223
  const screen = kind === "screen";
224
+ const report = onReport === void 0 ? blockReporter(blocks?.blocks) : onReport;
225
+ const onReportPress = report ? () => {
226
+ if (!screen) void Promise.resolve(retry()).catch((e) => reportError(e, "native:fatal-retry"));
227
+ try {
228
+ report(error, { kind: screen ? "screen" : "app" });
229
+ } catch (e) {
230
+ reportError(e, "native:report-problem");
231
+ }
232
+ } : null;
233
+ const secondary = href || onReportPress ? /* @__PURE__ */ jsxs(Inline, { gap: "sm", wrap: true, justify: "center", children: [
234
+ onReportPress ? /* @__PURE__ */ jsx(NativeButton, { variant: "outline", onPress: onReportPress, testID: screen ? "genesis-screen-error-report" : "genesis-fatal-report", children: labels.report }) : null,
235
+ href ? /* @__PURE__ */ jsx(NativeButton, { variant: "outline", onPress: openContact(href), testID: screen ? "genesis-screen-error-contact" : "genesis-fatal-contact", children: labels.contact }) : null
236
+ ] }) : null;
129
237
  return /* @__PURE__ */ jsx(
130
238
  NativeEmptyState,
131
239
  {
132
240
  variant: "error",
133
- title: screen ? "This screen hit a problem" : "Something went wrong",
134
- body: screen ? "The rest of the app still works. Try again, or go back." : "The app hit a problem. Try again, and if it keeps happening, close and reopen the app.",
241
+ title: screen ? labels.screenTitle : labels.title,
242
+ body: screen ? labels.screenBody : labels.body,
135
243
  details: errorDetails(error),
136
244
  primaryAction: /* @__PURE__ */ jsx(
137
245
  NativeButton,
138
246
  {
139
247
  onPress: screen ? runRetry(retry, "native:screen-retry") : () => void retry(),
140
248
  testID: screen ? "genesis-screen-error-retry" : "genesis-fatal-retry",
141
- children: "Try again"
249
+ children: labels.retry
142
250
  }
143
251
  ),
252
+ ...secondary ? { secondaryAction: secondary } : {},
144
253
  testID: screen ? "genesis-screen-error" : "genesis-fatal"
145
254
  }
146
255
  );
147
256
  }
257
+ function blockReporter(blocks) {
258
+ for (const block of blocks ?? []) {
259
+ const report = block.reportProblem;
260
+ if (report) return report;
261
+ }
262
+ return null;
263
+ }
148
264
  function PlainFatalScreen(props) {
149
265
  return /* @__PURE__ */ jsx(FatalScreen, { ...props, kind: "plain" });
150
266
  }
@@ -222,7 +338,8 @@ function ScreenErrorScreen(props) {
222
338
  var ScreenFallback = (props) => /* @__PURE__ */ jsx(FatalScreen, { ...props, kind: "screen" });
223
339
  var reportThroughCore = (error, report) => reportError(error, { source: report.source, fatal: report.fatal, ...report.tags ? { tags: report.tags } : {} });
224
340
  function createScreenErrorBoundary(options = {}) {
225
- const Fallback = options.fallback ?? ScreenFallback;
341
+ const { contact, labels } = options;
342
+ const Fallback = options.fallback ?? (contact || labels ? (props) => /* @__PURE__ */ jsx(FatalScreen, { ...props, kind: "screen", contact: typeof contact === "function" ? contact() : contact ?? null, ...labels ? { labels } : {} }) : ScreenFallback);
226
343
  const onError = options.onError ?? reportThroughCore;
227
344
  function GenesisScreenErrorBoundary(props) {
228
345
  const reported = useRef(null);
@@ -249,6 +366,6 @@ function ScreenErrorBoundary({ children, fallback, onError, resetKey }) {
249
366
  return /* @__PURE__ */ jsx(GenesisErrorBoundary, { fallback: Fallback, onError: onError ?? reportThroughCore, resetKey, fatal: false, source: "screen", children });
250
367
  }
251
368
 
252
- export { BootProvider, BootTimeoutError, FatalScreen, GenesisErrorBoundary, PlainFatalScreen, ScreenErrorBoundary, ScreenErrorScreen, createBoot, createScreenErrorBoundary, defaultErrorUtils, defaultRejectionTracker, errorDetails, installGlobalErrorHandler, installRejectionTracker, useBoot };
253
- //# sourceMappingURL=chunk-YIF4BFQH.js.map
254
- //# sourceMappingURL=chunk-YIF4BFQH.js.map
369
+ export { BlocksProvider, BootProvider, BootTimeoutError, DEFAULT_FATAL_SCREEN_LABELS, FatalScreen, GenesisErrorBoundary, PlainFatalScreen, ScreenErrorBoundary, ScreenErrorScreen, contactHref, createBoot, createScreenErrorBoundary, defaultErrorUtils, defaultRejectionTracker, errorDetails, installGlobalErrorHandler, installRejectionTracker, mergeBlockSettings, reportToBlocks, useBlockSettings, useBlocks, useBoot };
370
+ //# sourceMappingURL=chunk-JZHDEU4Q.js.map
371
+ //# sourceMappingURL=chunk-JZHDEU4Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/boot.tsx","../src/blocks.tsx","../src/errors.tsx","../src/screen-boundary.tsx"],"names":["createContext","useContext","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,EAAK,MAAM,CAAA,QAAA,EAAW,EAAE,CAAA,IAAA,CAAM,CAAA;AACtD,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AACF;AAEA,IAAM,kBAAA,GAAqB,GAAA;AAEpB,SAAS,QAAQ,KAAA,EAAuB;AAC7C,EAAA,IAAI,KAAA,YAAiB,OAAO,OAAO,KAAA;AACnC,EAAA,OAAO,IAAI,KAAA,CAAM,OAAO,KAAA,KAAU,QAAA,GAAW,QAAQ,eAAA,EAAiB,EAAE,KAAA,EAAO,KAAA,EAAO,CAAA;AACxF;AAGA,SAAS,aAAA,CAAc,SAA2B,EAAA,EAA4C;AAC5F,EAAA,IAAI,KAAA;AACJ,EAAA,OAAO,QAAQ,IAAA,CAAK;AAAA,IAClB,OAAA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AAQ,MAAM,KAAA,EAAO,EAAE,OAAO,KAAA,EAAO,MAAA,EAAQ,UAAU,CAAA;AAAA,MACzD,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF,CAAA,EAAG,CAAC,KAAA,CAAM,KAAK,CAAC,CAAA;AAChB,IAAA,uBAAOA,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-JZHDEU4Q.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 * 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 * \"Report this\" on the fatal and screen error screens: the support block opens its feedback form\n * with the error attached. `app`: the app's screens were replaced by the fatal screen, and are\n * remounting (\"Try again\") as this is called.\n */\n readonly reportProblem?: (error: Error, where: { kind: \"app\" | \"screen\" }) => 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/** @internal The resolved blocks, or null outside GenesisNativeApp (an error screen must never throw for want of them). */\nexport function useOptionalBlocks(): ResolvedBlocks<NativeBlock> | null {\n return useContext(BlocksContext);\n}\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 * A row whose `useShown` hook says false is left out. Calls each row's `useSubtitle` and\n * `useShown` hooks, 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 const shown = rows.map((row) => row.useShown?.() ?? true);\n return mergeBlockSettings(sections, rows, subtitles, options, shown);\n}\n\n/** The merge `useBlockSettings` does, without hooks (subtitles and `shown` already read; a row shown false is left out). @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 shown: readonly boolean[] = [],\n): BlockSettingsSection<R | SettingsRowLike>[] {\n const out: BlockSettingsSection<R | SettingsRowLike>[] = sections.map((s) => ({ ...s, rows: [...s.rows] }));\n rows.forEach((row, i) => {\n if (shown[i] === false) return;\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","/**\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 { Linking, Pressable, Text, View } from \"react-native\";\nimport { Inline, NativeButton, NativeEmptyState } from \"@marktiderman/genesis-ui-native/components\";\nimport { classifyError, reportError } from \"@marktiderman/genesis-core/errors\";\nimport { toError } from \"./boot\";\nimport { useOptionalBlocks, type NativeBlock } from \"./blocks\";\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 * Where people can write when the app can't help (support's `contactEmail` / `contactUrl`\n * settings: `support.contact()`): a \"Contact support\" button under \"Try again\". Left out, none.\n */\n contact?: FatalScreenContact | null;\n /**\n * \"Report this\": opens the support block's feedback form with the error attached. Left out, the\n * block's (when the support block is on and feedback with it); `null` for none.\n */\n onReport?: ((error: Error, where: { kind: \"app\" | \"screen\" }) => void) | null;\n /** The screen's words, in English by default. */\n labels?: Partial<FatalScreenLabels>;\n}\n\n/** The fatal and screen error screens' words. */\nexport interface FatalScreenLabels {\n /** The app's fatal screen. */\n title: string;\n body: string;\n /** One screen failed. */\n screenTitle: string;\n screenBody: string;\n /** The plain screen's line when the error has nothing safe to say. */\n plainBody: string;\n retry: string;\n contact: string;\n report: string;\n}\n\nexport const DEFAULT_FATAL_SCREEN_LABELS: FatalScreenLabels = {\n title: \"Something went wrong\",\n body: \"The app hit a problem. Try again, and if it keeps happening, close and reopen the app.\",\n screenTitle: \"This screen hit a problem\",\n screenBody: \"The rest of the app still works. Try again, or go back.\",\n plainBody: \"Try again, and if it keeps happening, close and reopen the app.\",\n retry: \"Try again\",\n contact: \"Contact support\",\n report: \"Report this\",\n};\n\n/** A support contact for the fatal screens: an email address, a support page, or both. */\nexport interface FatalScreenContact {\n email?: string | null;\n url?: string | null;\n}\n\n/** An https page with a host (`https://acme.test/help`), else null. */\nfunction httpsPage(text: string | null | undefined): string | null {\n const t = text?.trim();\n if (!t || t.length > 2048 || !/^https:\\/\\//i.test(t)) return null;\n try {\n const u = new URL(t);\n return u.protocol === \"https:\" && u.hostname ? t : null;\n } catch {\n return null;\n }\n}\n\n/** One address, checked in one pass (no backtracking): one \"@\", no spaces or brackets, a dot in the domain, not at its ends. */\nfunction looksLikeEmail(text: string): boolean {\n if (text.length > 254) return false;\n let at = -1;\n for (let i = 0; i < text.length; i++) {\n const c = text.charCodeAt(i);\n if (c <= 0x20 || c === 0x3c || c === 0x3e || c === 0x7f) return false;\n if (c === 0x40) {\n if (at !== -1) return false;\n at = i;\n }\n }\n const dot = text.lastIndexOf(\".\");\n return at > 0 && dot > at + 1 && dot < text.length - 1;\n}\n\n/** The link a contact opens: the support page, else a mailto. Null with neither (or one that isn't safe). */\nexport function contactHref(contact: FatalScreenContact | null | undefined): string | null {\n const url = httpsPage(contact?.url);\n if (url) return url;\n const email = contact?.email?.trim();\n // RFC 6068: \"?\", \"#\", \"%\", \"&\" and \"/\" in the mailbox are encoded, so they don't start a query.\n if (email && looksLikeEmail(email)) return `mailto:${email.replace(/[%?#&/]/g, (c) => encodeURIComponent(c))}`;\n return null;\n}\n\nconst openContact = (href: string) => () => {\n void Linking.openURL(href).catch((e: unknown) => reportError(e, \"native:contact\"));\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\", contact, onReport, labels: given }: FatalScreenViewProps) {\n const blocks = useOptionalBlocks();\n const labels = { ...DEFAULT_FATAL_SCREEN_LABELS, ...given };\n const href = contactHref(contact);\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 {labels.title}\n </Text>\n <Text style={{ textAlign: \"center\" }}>{errorDetails(error) ?? labels.plainBody}</Text>\n <Pressable accessibilityRole=\"button\" onPress={() => void retry()} testID=\"genesis-fatal-plain-retry\" style={{ padding: 12 }}>\n <Text style={{ fontSize: 17 }}>{labels.retry}</Text>\n </Pressable>\n {href ? (\n <Pressable accessibilityRole=\"link\" onPress={openContact(href)} testID=\"genesis-fatal-plain-contact\" style={{ padding: 12 }}>\n <Text style={{ fontSize: 15 }}>{labels.contact}</Text>\n </Pressable>\n ) : null}\n </View>\n );\n }\n const screen = kind === \"screen\";\n const report = onReport === undefined ? blockReporter(blocks?.blocks) : onReport;\n const onReportPress = report\n ? () => {\n // The app's screens are gone behind the fatal screen: bring them back, then open the form.\n if (!screen) void Promise.resolve(retry()).catch((e: unknown) => reportError(e, \"native:fatal-retry\"));\n try {\n report(error, { kind: screen ? \"screen\" : \"app\" });\n } catch (e) {\n reportError(e, \"native:report-problem\");\n }\n }\n : null;\n const secondary =\n href || onReportPress ? (\n <Inline gap=\"sm\" wrap justify=\"center\">\n {onReportPress ? (\n <NativeButton variant=\"outline\" onPress={onReportPress} testID={screen ? \"genesis-screen-error-report\" : \"genesis-fatal-report\"}>\n {labels.report}\n </NativeButton>\n ) : null}\n {href ? (\n <NativeButton variant=\"outline\" onPress={openContact(href)} testID={screen ? \"genesis-screen-error-contact\" : \"genesis-fatal-contact\"}>\n {labels.contact}\n </NativeButton>\n ) : null}\n </Inline>\n ) : null;\n return (\n <NativeEmptyState\n variant=\"error\"\n title={screen ? labels.screenTitle : labels.title}\n body={screen ? labels.screenBody : labels.body}\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 {labels.retry}\n </NativeButton>\n }\n {...(secondary ? { secondaryAction: secondary } : {})}\n testID={screen ? \"genesis-screen-error\" : \"genesis-fatal\"}\n />\n );\n}\n\n/**\n * The first block that takes a problem report (the support block's \"Report this\"), read now: the\n * function itself is kept, so a setting that changes before the press can't leave it undefined.\n */\nfunction blockReporter(blocks: readonly NativeBlock[] | undefined): FatalScreenViewProps[\"onReport\"] {\n for (const block of blocks ?? []) {\n const report = block.reportProblem;\n if (report) return report;\n }\n return null;\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 FatalScreenContact, type FatalScreenLabels, 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 /** \"Contact support\" on the default fallback (support's `support.contact()`), read when it shows. */\n contact?: FatalScreenContact | (() => FatalScreenContact | null) | null;\n /** The default fallback's words (\"Contact support\", \"Report this\"…), in English by default. */\n labels?: Partial<FatalScreenLabels>;\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 { contact, labels } = options;\n const Fallback =\n options.fallback ??\n (contact || labels\n ? (props: ScreenErrorProps) => (\n <FatalScreen {...props} kind=\"screen\" contact={typeof contact === \"function\" ? contact() : (contact ?? null)} {...(labels ? { labels } : {})} />\n )\n : 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"]}
@@ -1,16 +1,18 @@
1
- import { N as NativeBlock, U as UpdatesBlock, V as VersionSignature } from './blocks-BQY_df3j.js';
2
- export { D as DevtoolsFeedbackProps, a as DevtoolsSlots } from './blocks-BQY_df3j.js';
3
- import { O as ObservabilityBlock, R as RecentActivity } from './block-Iga-mCeC.js';
1
+ import * as _marktiderman_genesis_config_settings from '@marktiderman/genesis-config/settings';
2
+ import { ResolvedSettings } from '@marktiderman/genesis-config/settings';
3
+ import { N as NativeBlock, U as UpdatesBlock, V as VersionSignature } from './blocks-DoY_Z-Lh.js';
4
+ export { D as DevtoolsDiagnosticsProps, a as DevtoolsFeedbackProps, b as DevtoolsSlots } from './blocks-DoY_Z-Lh.js';
5
+ import { O as ObservabilityBlock, R as RecentActivity } from './block-BfJT3F6B.js';
4
6
  import 'react';
5
7
  import '@marktiderman/genesis-core/slots';
6
- import '@marktiderman/genesis-features/blocks';
7
- import './query--ihYsJWC.js';
8
+ import '@marktiderman/genesis-config/blocks';
9
+ import './query-DJFrykK_.js';
8
10
  import '@tanstack/react-query';
9
11
  import '@marktiderman/genesis-design-system';
10
12
  import '@marktiderman/genesis-core/provider';
11
13
  import '@marktiderman/genesis-ui-native/layouts';
12
14
  import '@marktiderman/genesis-ui-native/components';
13
- import './screen-boundary-B8DlsLwb.js';
15
+ import './screen-boundary-Da3qleNz.js';
14
16
 
15
17
  /**
16
18
  * The overlay's two ways in, as plain state machines (the root feeds them
@@ -76,6 +78,32 @@ declare const DEVTOOLS_BLOCK_ID = "devtools-overlay";
76
78
  interface DevSettingsLike {
77
79
  addMenuItem(title: string, handler: () => void): void;
78
80
  }
81
+ /** One health check's result, as genesis-support's `healthChecks` gives it. */
82
+ interface DevtoolsCheckResult {
83
+ name: string;
84
+ status: "ok" | "warn" | "fail";
85
+ message: string | null;
86
+ ms: number;
87
+ }
88
+ /** A health-check registry (genesis-support's `healthChecks`): the overlay runs it and shows the results. */
89
+ interface DevtoolsChecksLike {
90
+ list(): readonly unknown[];
91
+ run(): Promise<readonly DevtoolsCheckResult[]>;
92
+ latest(): readonly DevtoolsCheckResult[];
93
+ /** Run one check again (a check's "Try again"); null when none has that name. Without it, no check has "Try again". */
94
+ runCheck?(name: string): Promise<DevtoolsCheckResult | null>;
95
+ }
96
+ /** The health checks' words: each status, and the actions. */
97
+ interface DevtoolsCheckLabels {
98
+ ok: string;
99
+ warn: string;
100
+ fail: string;
101
+ /** Run one check again. */
102
+ retry: string;
103
+ /** Run every check. */
104
+ runAll: string;
105
+ }
106
+ declare const DEFAULT_DEVTOOLS_CHECK_LABELS: DevtoolsCheckLabels;
79
107
  interface DevtoolsOptions {
80
108
  /**
81
109
  * Must be explicitly true: `__DEV__` or a fact of the binary (a `.dev` or
@@ -92,6 +120,10 @@ interface DevtoolsOptions {
92
120
  baseUrl?: string;
93
121
  /** The app's switches and flags, shown by name and value. */
94
122
  flags?: Readonly<Record<string, unknown>>;
123
+ /** The health checks to run and show (genesis-support's `healthChecks`). */
124
+ checks?: DevtoolsChecksLike;
125
+ /** The health checks' words, in English by default. */
126
+ checkLabels?: Partial<DevtoolsCheckLabels>;
95
127
  /** `Accelerometer` from expo-sensors: shake to open. Without it, the hold and the dev menu still work. */
96
128
  accelerometer?: AccelerometerLike;
97
129
  /** `DevSettings` from react-native: "Open devtools" in the dev menu (development builds). */
@@ -107,6 +139,15 @@ interface DevtoolsOptions {
107
139
  clearCache?: () => unknown;
108
140
  /** Sign out (`supabase.auth.signOut()`). Without it, the action is hidden. */
109
141
  signOut?: () => unknown;
142
+ /**
143
+ * Genesis settings (`resolveSettings`' result, or the values alone): `devtools.overlay` off
144
+ * mounts nothing (it never turns the overlay on: `enabled` does); `devtools.shakeToOpen`,
145
+ * `devtools.hold`, `devtools.flags` and `devtools.signOut` off take that part away. Without
146
+ * them, everything the options give.
147
+ */
148
+ appSettings?: Pick<ResolvedSettings, "values"> | {
149
+ readonly [key: string]: unknown;
150
+ } | null;
110
151
  }
111
152
  interface DevtoolsState {
112
153
  open: boolean;
@@ -121,7 +162,7 @@ interface DevtoolsBlock extends NativeBlock<typeof DEVTOOLS_BLOCK_ID> {
121
162
  subscribe(listener: () => void): () => void;
122
163
  }
123
164
  /** Build the overlay once, at module scope. @stability Beta */
124
- declare function createDevtools(options: DevtoolsOptions): DevtoolsBlock;
165
+ declare function createDevtools(given: DevtoolsOptions): DevtoolsBlock;
125
166
 
126
167
  /**
127
168
  * The overlay's report, as text for "Copy debug info" and the feedback slot.
@@ -142,4 +183,56 @@ interface DebugInfoInput {
142
183
  /** Several lines a person can paste into a bug report. Unknown values are written `unknown`, never left out. */
143
184
  declare function buildDebugInfo(input: DebugInfoInput): string;
144
185
 
145
- export { type AccelerometerLike, DEVTOOLS_BLOCK_ID, type DebugInfoInput, type DevSettingsLike, type DevtoolsBlock, type DevtoolsOptions, type DevtoolsState, type HoldDetector, type HoldDetectorOptions, type ShakeDetector, type ShakeDetectorOptions, buildDebugInfo, createDevtools, createHoldDetector, createShakeDetector };
186
+ /** `devtools.*`, as declared. @stability Beta */
187
+ declare const DEVTOOLS_SETTING_SPECS: {
188
+ readonly overlay: {
189
+ readonly type: "boolean";
190
+ readonly default: true;
191
+ readonly summary: "The Development overlay in development and preview builds. Off hides it; no setting turns it on in a production build.";
192
+ };
193
+ readonly shakeToOpen: {
194
+ readonly type: "boolean";
195
+ readonly default: true;
196
+ readonly requires: readonly ["devtools.overlay"];
197
+ readonly summary: "Shake to open the overlay (development and preview builds).";
198
+ };
199
+ readonly hold: {
200
+ readonly type: "boolean";
201
+ readonly default: true;
202
+ readonly requires: readonly ["devtools.overlay"];
203
+ readonly summary: "A three-finger hold opens the overlay.";
204
+ };
205
+ readonly flags: {
206
+ readonly type: "boolean";
207
+ readonly default: true;
208
+ readonly requires: readonly ["devtools.overlay"];
209
+ readonly summary: "Show the app's switches and flags in the overlay.";
210
+ };
211
+ readonly signOut: {
212
+ readonly type: "boolean";
213
+ readonly default: true;
214
+ readonly requires: readonly ["devtools.overlay"];
215
+ readonly summary: "Offer Sign out in the overlay.";
216
+ };
217
+ };
218
+ /** @stability Beta */
219
+ declare const devtoolsSettings: _marktiderman_genesis_config_settings.SettingsDeclaration<"devtools", "overlay" | "shakeToOpen" | "hold" | "flags" | "signOut">;
220
+ /** The devtools overlay's settings, typed. @stability Beta */
221
+ interface DevtoolsSettingValues {
222
+ overlay: boolean;
223
+ shakeToOpen: boolean;
224
+ hold: boolean;
225
+ flags: boolean;
226
+ signOut: boolean;
227
+ }
228
+ /**
229
+ * The overlay's settings from `resolveSettings`' result (or the values alone, by full key). A key
230
+ * that's missing, or whose value doesn't fit, takes its default (every one on).
231
+ *
232
+ * @stability Beta
233
+ */
234
+ declare function devtoolsSettingValues(input?: Pick<ResolvedSettings, "values"> | {
235
+ readonly [key: string]: unknown;
236
+ } | null): DevtoolsSettingValues;
237
+
238
+ export { type AccelerometerLike, DEFAULT_DEVTOOLS_CHECK_LABELS, DEVTOOLS_BLOCK_ID, DEVTOOLS_SETTING_SPECS, type DebugInfoInput, type DevSettingsLike, type DevtoolsBlock, type DevtoolsCheckLabels, type DevtoolsCheckResult, type DevtoolsChecksLike, type DevtoolsOptions, type DevtoolsSettingValues, type DevtoolsState, type HoldDetector, type HoldDetectorOptions, type ShakeDetector, type ShakeDetectorOptions, buildDebugInfo, createDevtools, createHoldDetector, createShakeDetector, devtoolsSettingValues, devtoolsSettings };