@marktiderman/genesis-native 0.4.4 → 0.5.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 +98 -6
- package/dist/{block-Onqx7NiK.d.ts → block-DFnC8j5U.d.ts} +53 -3
- package/dist/{blocks-C2RDpvaN.d.ts → blocks-CyXjSGwV.d.ts} +12 -93
- package/dist/{chunk-75YP72G6.js → chunk-6L36FQBX.js} +95 -7
- package/dist/chunk-6L36FQBX.js.map +1 -0
- package/dist/chunk-C54LIT4N.js +73 -0
- package/dist/chunk-C54LIT4N.js.map +1 -0
- package/dist/chunk-MFHOHSEQ.js +249 -0
- package/dist/chunk-MFHOHSEQ.js.map +1 -0
- package/dist/chunk-VIC2KXMA.js +35 -0
- package/dist/chunk-VIC2KXMA.js.map +1 -0
- package/dist/devtools.d.ts +5 -4
- package/dist/devtools.js +3 -1
- package/dist/devtools.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +13 -192
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +33 -7
- package/dist/observability.js +20 -7
- package/dist/observability.js.map +1 -1
- package/dist/persist.d.ts +2 -1
- package/dist/persist.js +1 -1
- package/dist/push.d.ts +3 -3
- package/dist/query-DobJyRvs.d.ts +208 -0
- package/dist/screen-boundary-BlT6KBpa.d.ts +43 -0
- package/dist/updates.d.ts +2 -2
- package/dist/updates.js +3 -0
- package/dist/updates.js.map +1 -1
- package/dist/web-handoff.d.ts +88 -0
- package/dist/web-handoff.js +78 -0
- package/dist/web-handoff.js.map +1 -0
- package/package.json +9 -4
- package/src/app.tsx +16 -2
- package/src/errors.tsx +46 -7
- package/src/index.ts +24 -0
- package/src/observability/block.tsx +132 -5
- package/src/observability/index.ts +2 -0
- package/src/observability/sentry.ts +41 -6
- package/src/observability/sink.ts +30 -1
- package/src/query.ts +67 -1
- package/src/reload.ts +56 -0
- package/src/screen-boundary.tsx +116 -0
- package/src/updates/channels.ts +3 -0
- package/src/updates/checker.ts +3 -0
- package/src/web-handoff.ts +165 -0
- package/dist/chunk-75YP72G6.js.map +0 -1
- package/dist/chunk-VTJDIKFC.js +0 -39
- package/dist/chunk-VTJDIKFC.js.map +0 -1
- package/dist/query-DUmVAfsF.d.ts +0 -70
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/observability/events.ts","../src/observability/scrub.ts","../src/observability/sink.ts","../src/observability/block.tsx"],"names":[],"mappings":";;;;;;;;;AAkCA,IAAM,UAAA,GAAa,yCAAA;AACnB,IAAM,SAAA,GAAY,mBAAA;AAClB,IAAM,SAAA,GAAY,EAAA;AAClB,IAAM,WAAA,GAAc,EAAA;AASb,SAAS,aAA0C,MAAA,EAAc;AACtE,EAAA,MAAM,WAAqB,EAAC;AAC5B,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAClD,IAAA,IAAI,CAAC,WAAW,IAAA,CAAK,IAAI,GAAG,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,EAAI,IAAI,CAAA,mEAAA,CAAqE,CAAA;AACvH,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AAC9B,IAAA,IAAI,IAAA,CAAK,SAAS,SAAA,EAAW,QAAA,CAAS,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,WAAA,EAAc,SAAS,CAAA,MAAA,CAAQ,CAAA;AAClF,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,MAAM,IAAA,GAAO,MAAM,GAAG,CAAA;AACtB,MAAA,IAAI,CAAC,SAAA,CAAU,IAAA,CAAK,GAAG,CAAA,EAAG,QAAA,CAAS,IAAA,CAAK,CAAA,CAAA,EAAI,IAAI,CAAA,EAAA,EAAK,GAAG,CAAA,mDAAA,CAAqD,CAAA;AAC7G,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA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A,OAAO,qBAAqB,KAAA,CAAM,SAAA,EAAW,KAAA,CAAM,QAAA,EAAU,MAAM,QAAQ,CAAA;AAC7E;AAEA,IAAM,QAAwB,EAAE,WAAA,EAAa,EAAC,EAAG,MAAA,EAAQ,EAAC,EAAE;AAC5D,IAAM,cAA2B,EAAE,QAAA,EAAU,MAAM,KAAA,EAAO,SAAA,EAAW,MAAM,MAAM;AAAC,CAAmB,CAAA","file":"chunk-6L36FQBX.js","sourcesContent":["/**\n * Typed analytics events: the app lists every event and the props each may\n * carry once, and `track(name, props)` accepts nothing else. A prop is a\n * closed list of strings, a number or a boolean, never free text, so an\n * event can't carry a name, an email or a message someone typed.\n *\n * ```ts\n * export const events = defineEvents({\n * \"auth.signed_in\": { method: [\"email\", \"apple\"] },\n * \"settings.opened\": {},\n * \"checkin.saved\": { mood: \"number\", first: \"boolean\" },\n * });\n * ```\n *\n * At run time an unknown event, an unknown prop or a value outside its list\n * is dropped and reported (a `console.warn` in development, `onInvalid`\n * always), so a bad call is loud and still sends nothing.\n */\n\n/** A closed list of strings, `\"number\"` (finite) or `\"boolean\"`. */\nexport type EventPropSpec = readonly string[] | \"number\" | \"boolean\";\n\n/** Every event, by name, with the props it may carry. */\nexport type EventSchema = Readonly<Record<string, Readonly<Record<string, EventPropSpec>>>>;\n\ntype PropValue<S> = S extends readonly (infer L)[] ? L : S extends \"number\" ? number : S extends \"boolean\" ? boolean : never;\n\n/** The props of one event: every prop optional, each its spec's type. */\nexport type EventProps<S extends Readonly<Record<string, EventPropSpec>>> = { readonly [K in keyof S]?: PropValue<S[K]> };\n\n/** What a sink receives: the checked props. */\nexport type EventValues = Readonly<Record<string, string | number | boolean>>;\n\n// Lower-case words joined by `.` or `_`: `auth.signed_in`, `checkin.saved`.\nconst EVENT_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\nconst PROP_NAME = /^[a-z][a-z0-9_]*$/;\nconst MAX_PROPS = 25;\nconst MAX_LITERAL = 64;\n\n/**\n * Declare the app's events. Checks names (lower-case, dot-separated), prop\n * names, and that each list has at least one short value, and throws listing\n * every problem, so a bad schema fails where it is written.\n *\n * @stability Beta\n */\nexport function defineEvents<const E extends EventSchema>(schema: E): E {\n const problems: string[] = [];\n for (const [name, props] of Object.entries(schema)) {\n if (!EVENT_NAME.test(name)) problems.push(`\"${name}\": an event name is lower-case words joined by \".\" (auth.signed_in)`);\n const keys = Object.keys(props);\n if (keys.length > MAX_PROPS) problems.push(`\"${name}\": at most ${MAX_PROPS} props`);\n for (const key of keys) {\n const spec = props[key];\n if (!PROP_NAME.test(key)) problems.push(`\"${name}\".${key}: a prop name is lower-case letters, digits and \"_\"`);\n if (Array.isArray(spec)) {\n if (spec.length === 0) problems.push(`\"${name}\".${key}: an empty list allows nothing`);\n for (const v of spec) if (typeof v !== \"string\" || v.length === 0 || v.length > MAX_LITERAL) problems.push(`\"${name}\".${key}: \"${String(v)}\" must be 1-${MAX_LITERAL} characters`);\n } else if (spec !== \"number\" && spec !== \"boolean\") {\n problems.push(`\"${name}\".${key}: a prop is a list of strings, \"number\" or \"boolean\" (free text is not allowed)`);\n }\n }\n }\n if (problems.length) throw new Error(`Invalid events:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n return Object.freeze(schema);\n}\n\nexport type EventCheck = { ok: true; props: EventValues } | { ok: false; problem: string };\n\n/** Check one call against the schema: the props to send, or why nothing is sent. */\nexport function checkEvent(schema: EventSchema, name: string, props: Readonly<Record<string, unknown>> | undefined): EventCheck {\n if (!Object.prototype.hasOwnProperty.call(schema, name)) return { ok: false, problem: `\"${name}\" is not in the event schema` };\n const specs = schema[name] ?? {};\n const out: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(props ?? {})) {\n if (value === undefined) continue;\n if (!Object.prototype.hasOwnProperty.call(specs, key)) return { ok: false, problem: `\"${name}\" has no prop \"${key}\"` };\n const spec = specs[key];\n const fits =\n spec === \"number\"\n ? typeof value === \"number\" && Number.isFinite(value)\n : spec === \"boolean\"\n ? typeof value === \"boolean\"\n : typeof value === \"string\" && (spec as readonly string[]).includes(value);\n if (!fits) return { ok: false, problem: `\"${name}\".${key}: ${JSON.stringify(value)} is not allowed` };\n out[key] = value as string | number | boolean;\n }\n return { ok: true, props: out };\n}\n","/**\n * The PII scrubber every sink's input goes through by default: text is\n * rewritten by pattern (an email, a phone number, a JWT, a Supabase key, a\n * bearer token, a token in a query string, row values in a database error),\n * values under a key that names a secret or a contact detail are replaced\n * whole, and URLs lose their query and fragment (PostgREST filters carry\n * record ids, auth callbacks carry codes). Strings are cut at 4 KB first, so\n * a huge log line can't stall the JS thread.\n *\n * What it can't know: a person's name in free text. Keep names out of error\n * messages and breadcrumbs; touch breadcrumbs lose their labels in\n * `sentrySink` for this reason.\n *\n * Pattern-based on values, not an allowlist of keys: a key allowlist misses\n * `refresh failed: eyJhbGciOi…`, which is the shape that actually occurs.\n *\n * Fail closed: `scrubEvent` and `scrubRecord` return `null` (drop it) when\n * scrubbing itself throws, never the unscrubbed input.\n */\n\n/** What replaces a value under a secret-looking key. */\nexport const FILTERED = \"[Filtered]\";\n\n// Keys whose value is a secret (or a contact detail) whatever it looks like.\n// Matched case-insensitively with `-`, `_`, `.` and spaces removed: exactly\n// for the short, ambiguous ones, as a part of the key for the rest\n// (`x-supabase-api-key`, `user.email`, `refresh_token_hash`).\nconst SECRET_KEY_EXACT = /^(session|sessionid|dsn|otp|code|verifier|codeverifier|privatekey|refresh|pwd|key)$/;\nconst SECRET_KEY_PART = /(authoriz|cookie|passw|secret|token|apikey|credential|jwt|email|phone|servicerole)/;\n\n/** True when a value under `key` is a secret (or contact detail) whatever it looks like. */\nexport function isSecretKey(key: string): boolean {\n const k = key.replace(/[-_.\\s]/g, \"\").toLowerCase();\n return SECRET_KEY_EXACT.test(k) || SECRET_KEY_PART.test(k);\n}\n\n// Sentry's own ids and envelope fields: 32-hex values the hex rule would break, never PII.\nconst ID_KEY = /^(event_id|trace_id|span_id|parent_span_id|profile_id|replay_id|debug_id|code_id|public_key|segment_id|sampled|release|dist|environment)$/;\n\n// Fields dropped whole: query strings travel as their own fields too (Sentry's http breadcrumbs,\n// spans and requests), and bodies and PostgREST `details` carry row values.\nconst DROPPED_KEY = /^(query_string|http\\.query|http\\.fragment|url\\.query|url\\.fragment|request_body|response_body|body|cookies|details)$/i;\n\n/** Longest string scrubbed in full; the rest is cut off (the patterns stay fast on huge logs). */\nexport const MAX_STRING = 4096;\n\nconst PATTERNS: readonly [RegExp, string][] = [\n // The query string and fragment of a URL with a scheme anywhere in text (a span's\n // \"GET https://…?id=eq.42\", a deep link \"myapp://reset?token_hash=…\").\n [/\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/[^\\s?#\"'<>]{0,2048})[?#][^\\s\"'<>]*/gi, \"$1\"],\n // …and of a path (\"POST /rest/v1/rpc/find?email=eq.…\").\n [/(^|[\\s\"'(=])(\\/[^\\s?#\"'<>]{0,2048})\\?[^\\s\"'<>]*/g, \"$1$2\"],\n // JWTs: Supabase access tokens and the legacy anon / service_role keys.\n [/\\beyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*/g, \"[jwt]\"],\n // Supabase's API keys (sb_secret_…, sb_publishable_…).\n [/\\bsb_(?:secret|publishable)_[A-Za-z0-9_-]{8,}/g, \"[supabase-key]\"],\n // `Authorization: Bearer …` copied into a message.\n [/\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]+/gi, \"$1 [token]\"],\n // Tokens in a query string or a fragment left without a scheme.\n [\n /([?&#](?:access_token|refresh_token|id_token|provider_token|provider_refresh_token|token|token_hash|code|apikey|api_key|key|password|secret|email|phone)=)[^&#\\s\"']+/gi,\n \"$1[Filtered]\",\n ],\n // Row values in PostgreSQL errors: `Failing row contains (…)`, `Key (email)=(…)`.\n [/(Failing row contains )\\([^)]*\\)/g, \"$1(…)\"],\n [/(Key \\([^)]{0,256}\\)=)\\([^)]*\\)/g, \"$1(…)\"],\n // Email addresses, also percent-encoded (`a%40b.co`). Bounded, so a long run of letters can't backtrack.\n [/[A-Za-z0-9._%+-]{1,64}(?:@|%40)(?:[A-Za-z0-9-]{1,63}\\.){1,8}[A-Za-z]{2,24}/g, \"[email]\"],\n // Phone numbers: international (`+1 555 555 0101`) and North American (`555-555-0101`).\n [/\\+\\d[\\d\\s().-]{6,18}\\d/g, \"[phone]\"],\n [/\\b\\(?\\d{3}\\)?[-.\\s]\\d{3}[-.\\s]\\d{4}\\b/g, \"[phone]\"],\n // Long opaque hex runs: API keys, refresh tokens, DSN secrets. Linear: a run starts only after a non-hex character.\n [/(^|[^A-Fa-f0-9])[A-Fa-f0-9]{32,}(?![A-Fa-f0-9])/g, \"$1[hex]\"],\n];\n\n/** A string with every URL query, email, phone number, JWT, Supabase key, bearer token and query-string token replaced. */\nexport function scrubString(value: string): string {\n let out = value.length > MAX_STRING ? `${value.slice(0, MAX_STRING)}…[truncated]` : value;\n for (const [pattern, replacement] of PATTERNS) out = out.replace(pattern, replacement);\n return out;\n}\n\n/** A URL without its query string and fragment, then scrubbed (an email in a path). */\nexport function scrubUrl(value: string): string {\n const cut = value.search(/[?#]/);\n return scrubString(cut === -1 ? value : value.slice(0, cut));\n}\n\n// Keys whose string value is cut at `?` when it is a URL.\nconst URL_KEY = /^(url|href|from|to|uri|description|http\\.url|url\\.full)$/i;\nconst MAX_DEPTH = 8;\n\n/**\n * A deep copy of `value` with every string scrubbed and every value under a\n * secret key replaced. Cycles become `\"[Circular]\"`; past 8 levels,\n * `\"[Truncated]\"`. Errors become `{ name, message }`. Header lists\n * (`[[\"authorization\", \"…\"]]`) are treated like objects.\n */\nexport function scrubValue(value: unknown, key = \"\", depth = 0, seen: WeakSet<object> = new WeakSet()): unknown {\n if (key && isSecretKey(key)) return value === undefined || value === null || value === \"\" ? value : FILTERED;\n if (typeof value === \"string\") {\n if (key && ID_KEY.test(key)) return value;\n return URL_KEY.test(key) ? scrubUrl(value) : scrubString(value);\n }\n if (value === null || typeof value !== \"object\") return value;\n if (seen.has(value)) return \"[Circular]\";\n if (depth >= MAX_DEPTH) return \"[Truncated]\";\n seen.add(value);\n if (value instanceof Error) return { name: value.name, message: scrubString(value.message) };\n if (Array.isArray(value)) {\n // A `[name, value]` pair (fetch's header lists): the name decides, as for an object key.\n if (value.length === 2 && typeof value[0] === \"string\" && isSecretKey(value[0])) return [value[0], FILTERED];\n return value.map((item) => scrubValue(item, \"\", depth + 1, seen));\n }\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (DROPPED_KEY.test(k)) continue;\n out[k] = scrubValue(v, k, depth + 1, seen);\n }\n return out;\n}\n\n/** The fields of a Sentry-shaped event `scrubEvent` treats specially. Anything else is scrubbed by value. */\nexport interface ScrubbableEvent {\n user?: { id?: unknown; [key: string]: unknown } | null;\n request?: { url?: unknown; method?: unknown; headers?: unknown; [key: string]: unknown };\n [key: string]: unknown;\n}\n\n/**\n * The event with the user reduced to its id, the request reduced to its\n * method, URL (cut at `?`) and scrubbed headers, and every other value\n * scrubbed. `null` when scrubbing threw: fail closed, send nothing rather\n * than PII.\n */\nexport function scrubEvent<E extends ScrubbableEvent>(event: E): E | null {\n try {\n // Sentry's processing metadata (scopes, the sampling context its envelope header is built\n // from) is never sent as part of the event: pass it through, or the envelope breaks.\n const { user, request, sdkProcessingMetadata, ...rest } = event;\n const out = scrubValue(rest) as E;\n if (sdkProcessingMetadata !== undefined) (out as ScrubbableEvent).sdkProcessingMetadata = sdkProcessingMetadata;\n if (user !== undefined) {\n (out as ScrubbableEvent).user = user && user.id !== undefined && user.id !== null ? { id: scrubString(String(user.id)) } : null;\n }\n if (request && typeof request === \"object\") {\n const safe: Record<string, unknown> = {};\n if (typeof request.url === \"string\") safe.url = scrubUrl(request.url);\n if (typeof request.method === \"string\") safe.method = request.method;\n if (request.headers && typeof request.headers === \"object\") safe.headers = scrubValue(request.headers);\n (out as ScrubbableEvent).request = safe;\n }\n return out;\n } catch {\n return null;\n }\n}\n\n/** A breadcrumb, span or any record, scrubbed by value. `null` when scrubbing threw (fail closed). */\nexport function scrubRecord<R extends object>(record: R): R | null {\n try {\n return scrubValue(record) as R;\n } catch {\n return null;\n }\n}\n","/**\n * The vendor-neutral seam: a sink is where errors, breadcrumbs, the user id,\n * analytics events and timings go. `createObservability` fans every call out\n * to its sinks, scrubbed first; a sink that throws is reported to\n * `onSinkError` and never takes the others (or the app) down with it.\n *\n * Shipped sinks: `sentrySink` (Sentry), `observeSink` (EAS Observe) and\n * `consoleSink` (development). A vendor adapter (PostHog, Datadog…) is one\n * object with the methods it supports.\n */\nimport type { ComponentType } from \"react\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport type { EventValues } from \"./events\";\n\n/** Where a caught error came from and whether the app could go on. */\nexport interface ErrorContext {\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`, `global`, `boot`, `rejection`, `screen`, `query`, `mutation`\n * (the shell's), a package's (`chat:attachment-action`, through\n * `reportError` from genesis-core) or the app's own (`updates:policy`, `sync`).\n */\n source: string;\n componentStack?: string;\n /** The route pattern on screen (`/(app)/settings`), when known. */\n route?: string | null;\n /**\n * False when nothing caught it (an unhandled promise rejection): release\n * health counts it. Default: handled unless `fatal`.\n */\n handled?: boolean;\n /** Low-cardinality labels (`query.key: \"tasks\"`), scrubbed like everything else. */\n tags?: Readonly<Record<string, string>>;\n}\n\nexport type BreadcrumbLevel = \"debug\" | \"info\" | \"warning\" | \"error\";\n\n/** One step that led up to an error: a navigation, a tap, a request. */\nexport interface Breadcrumb {\n /** `navigation`, `ui`, `http`, `event`, or the app's own. */\n category: string;\n message?: string;\n level?: BreadcrumbLevel;\n data?: Readonly<Record<string, unknown>>;\n /** Milliseconds since the epoch. Default now. */\n timestamp?: number;\n}\n\n/** Low-cardinality labels on a timing (`route`, `step`), never ids or text someone typed. */\nexport type TimingTags = Readonly<Record<string, string>>;\n\n/**\n * One destination. Every method is optional: a sink takes what its vendor\n * supports. Errors arrive as an `Error` whose message is already scrubbed,\n * unless the sink sets `scrubsErrors` (it scrubs the whole event itself and\n * needs the original object, as Sentry does to deduplicate).\n *\n * @stability Beta\n */\nexport interface ObservabilitySink {\n readonly name: string;\n /** The sink scrubs error events itself; give it the original `Error`. */\n readonly scrubsErrors?: boolean;\n captureError?(error: Error, context: ErrorContext): void;\n breadcrumb?(crumb: Breadcrumb): void;\n /** The signed-in login's id, or `null` when signed out. Never an email or a name. */\n setUser?(id: string | null): void;\n /** An analytics event, its props checked against the schema. */\n event?(name: string, props: EventValues): void;\n timing?(name: string, ms: number, tags?: TimingTags): void;\n /** Wraps the root layout (Sentry's `wrap`, EAS Observe's `ObserveRoot.wrap`). */\n wrap?<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /**\n * Wraps an Expo Router per-route `ErrorBoundary` (Sentry's\n * `wrapExpoRouterErrorBoundary`). A sink that wraps reports the route's\n * error itself, so the block's screen boundary doesn't send it to that sink again.\n */\n wrapRouteErrorBoundary?(boundary: ComponentType<RouteErrorBoundaryProps>): ComponentType<RouteErrorBoundaryProps>;\n /** Send what is queued, within `timeoutMs`; resolves false when it didn't finish. Called before an update reloads the app. */\n flush?(timeoutMs: number): PromiseLike<boolean> | boolean | void;\n /** The id of the last error event this sink sent, for a support request or feedback. */\n lastEventId?(): string | undefined;\n /** The current session replay's id, when replay is on. */\n replayId?(): string | undefined;\n}\n\n/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */\nexport interface RouteErrorBoundaryProps {\n error: Error;\n retry: () => Promise<void>;\n}\n\n/** A copy of `error` whose message and stack have been scrubbed (for sinks that don't scrub themselves). */\nexport function scrubbedError(error: Error): Error {\n const copy = new Error(scrubString(error.message));\n copy.name = error.name;\n if (error.stack) copy.stack = scrubString(error.stack);\n return copy;\n}\n\nexport interface ConsoleSinkOptions {\n /** Default `console`. */\n console?: Pick<Console, \"log\" | \"warn\" | \"error\">;\n /** Also log breadcrumbs (noisy). Default false. */\n breadcrumbs?: boolean;\n}\n\n/**\n * Logs what would be sent, for development: fatal errors with `console.error`, others with `console.warn`,\n * events and timings with `console.log`. Already scrubbed, so what you read\n * is what a vendor sink would get.\n *\n * @stability Beta\n */\nexport function consoleSink(options: ConsoleSinkOptions = {}): ObservabilitySink {\n const out = options.console ?? console;\n return {\n name: \"console\",\n // `warn` for what the app survives: `console.error` would raise a LogBox error for every one in development.\n captureError: (error, context) => {\n const line = `[observability] ${context.fatal ? \"fatal \" : \"\"}${context.source}: ${error.message}`;\n if (context.fatal) out.error(line);\n else out.warn(line);\n },\n breadcrumb: options.breadcrumbs ? (crumb) => out.log(`[observability] · ${crumb.category} ${crumb.message ?? \"\"}`) : undefined,\n setUser: (id) => out.log(`[observability] user ${id ?? \"(signed out)\"}`),\n event: (name, props) => out.log(`[observability] event ${name}`, props),\n timing: (name, ms, tags) => out.log(`[observability] timing ${name} ${Math.round(ms)}ms`, tags ?? {}),\n };\n}\n\n/**\n * `expo-observe`'s `Observe` (SDK 56+), or a stand-in: the calls `observeSink`\n * uses. Pass `import { Observe } from \"expo-observe\"`.\n */\nexport interface ObserveLike {\n logEvent(name: string, options?: { severity?: \"debug\" | \"info\" | \"warn\" | \"error\"; body?: string; attributes?: Record<string, unknown> }): void;\n /** Error reporting, in preview on SDK 57+. */\n reportError?(error: unknown): void;\n}\n\nexport interface ObserveSinkOptions {\n /** Report caught errors with `Observe.reportError` (in preview). Default false: Sentry is the error tracker. */\n errors?: boolean;\n}\n\n/**\n * EAS Observe. It measures launch (cold, warm, bundle load, first render),\n * time to interactive and, with its Expo Router integration, per-route\n * render times on its own; it has no API for a custom timing metric, so\n * `timing` is logged as an event (`timing.<name>` with `duration_ms`) and\n * shows on the Events page, not as a metric. Analytics events go to\n * `Observe.logEvent` as they are.\n *\n * @stability Beta\n */\nexport function observeSink(observe: ObserveLike, options: ObserveSinkOptions = {}): ObservabilitySink {\n return {\n name: \"eas-observe\",\n event: (name, props) => observe.logEvent(name, { attributes: { ...props } }),\n timing: (name, ms, tags) => observe.logEvent(`timing.${name}`, { severity: \"info\", attributes: { duration_ms: Math.round(ms), ...(tags ?? {}) } }),\n captureError: options.errors && observe.reportError ? (error) => observe.reportError?.(error) : undefined,\n };\n}\n\n/** Breadcrumb data scrubbed and made plain (for sinks and the devtools overlay). */\nexport function scrubBreadcrumb(crumb: Breadcrumb): Breadcrumb {\n return {\n category: scrubString(crumb.category),\n level: crumb.level,\n timestamp: crumb.timestamp,\n ...(crumb.message !== undefined ? { message: scrubString(crumb.message) } : {}),\n ...(crumb.data ? { data: scrubValue(crumb.data) as Record<string, unknown> } : {}),\n };\n}\n","/**\n * `createObservability(options)`: the observability block. Build it once at\n * module scope (it starts the sinks, Sentry's `init` included), then:\n *\n * <GenesisNativeApp blocks={[observability]}> every error the shell catches → captureError\n * export default observability.wrap(RootLayout) Sentry's `wrap` (touch and profiler boundaries)\n * observability.track(\"auth.signed_in\", { method: \"email\" })\n *\n * Its root (inside the shell) sets the user to the signed-in login's id and,\n * with `useSegments` from expo-router, leaves a breadcrumb per route change\n * and a `route.time_on_screen` timing for the route left. Route patterns\n * (`/(app)/clients/[id]`) are used, never the values in them.\n *\n * Creating it also:\n * - registers it as genesis-core's error reporter (`setErrorReporter`), so a\n * package's `reportError(e, \"chat:…\")` reaches the sinks as a non-fatal error;\n * - registers a before-reload hook (`onBeforeReload`) that flushes the sinks\n * before an update reloads the app.\n *\n * `observability.screenBoundary()` is an Expo Router `ErrorBoundary` for a\n * route (reported non-fatal, wrapped by Sentry's route wrapper), and\n * `lastEventId()` / `replayId()` let a support or feedback screen point at\n * the event.\n *\n * Everything a sink receives has been scrubbed (see `scrub.ts`), and the\n * last breadcrumbs and errors are kept, scrubbed, for the devtools overlay\n * (`recent`).\n */\nimport { createContext, useContext, useEffect, useRef, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { defineBlock } from \"@marktiderman/genesis-features/blocks\";\nimport { setErrorReporter } from \"@marktiderman/genesis-core/errors\";\nimport { useSession } from \"../auth\";\nimport { onBeforeReload } from \"../reload\";\nimport { createScreenErrorBoundary, type ScreenErrorProps } from \"../screen-boundary\";\nimport type { NativeBlock, NativeBlockRootProps } from \"../blocks\";\nimport type { ErrorReport } from \"../errors\";\nimport { checkEvent, type EventProps, type EventSchema } from \"./events\";\nimport { scrubString, scrubValue } from \"./scrub\";\nimport { scrubBreadcrumb, scrubbedError, type Breadcrumb, type ErrorContext, type ObservabilitySink, type TimingTags } from \"./sink\";\n\n/** The FeatureId of the observability block. */\nexport const OBSERVABILITY_BLOCK_ID = \"observability\";\n\n/** A caught error as the devtools overlay shows it (scrubbed). */\nexport interface RecentError {\n at: number;\n name: string;\n message: string;\n source: string;\n fatal: boolean;\n}\n\nexport interface RecentActivity {\n /** Oldest first. Navigation, events and the app's breadcrumbs. */\n breadcrumbs: readonly Breadcrumb[];\n /** Oldest first. */\n errors: readonly RecentError[];\n}\n\nexport interface RecentStore {\n getState(): RecentActivity;\n subscribe(listener: () => void): () => void;\n clear(): void;\n}\n\nexport interface ObservabilityOptions<E extends EventSchema = EventSchema> {\n /** Where everything goes: `sentrySink(Sentry, …)`, `consoleSink()` in development, `observeSink(Observe)`. */\n sinks: readonly (ObservabilitySink | null | undefined | false)[];\n /** The app's analytics events (`defineEvents`). Without it, `track` accepts nothing. */\n events?: E;\n /** `useSegments` from expo-router: route breadcrumbs and `route.time_on_screen` timings. */\n useSegments?: () => readonly string[];\n /** How many breadcrumbs and errors `recent` keeps. Default 50 and 20. */\n recent?: { breadcrumbs?: number; errors?: number };\n /** A sink threw, or `track` was called with something the schema doesn't allow. Default `console.warn` in development. */\n onProblem?: (problem: string, error?: unknown) => void;\n /**\n * Become genesis-core's error reporter, so packages' `reportError` calls\n * reach the sinks. Default true; the last block created wins.\n */\n reportErrors?: boolean;\n /** Flush the sinks before an update reloads the app, within this many milliseconds. Default 2000; 0 turns it off. */\n flushBeforeReloadMs?: number;\n now?: () => number;\n}\n\nexport interface ObservabilityBlock<E extends EventSchema = EventSchema> extends NativeBlock<typeof OBSERVABILITY_BLOCK_ID> {\n readonly sinks: readonly ObservabilitySink[];\n readonly events: E | undefined;\n /** Report an error. The shell calls it for every error it catches. */\n captureError(error: unknown, context?: Partial<ErrorContext>): void;\n breadcrumb(crumb: Breadcrumb): void;\n /** The login's id only. The block's root sets it from the session. */\n setUser(id: string | null): void;\n /** An analytics event from the schema. Anything else is dropped and reported. */\n track<N extends keyof E & string>(name: N, props?: EventProps<E[N]>): void;\n timing(name: string, ms: number, tags?: TimingTags): void;\n /** The root layout wrapped by each sink that wraps (Sentry's `wrap`). Use once: `export default observability.wrap(RootLayout)`. */\n wrap<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;\n /** The last breadcrumbs and errors, scrubbed, for the devtools overlay. */\n readonly recent: RecentStore;\n /** Send what every sink has queued; resolves false when one didn't finish within `timeoutMs` (default 2000). */\n flush(timeoutMs?: number): Promise<boolean>;\n /** The id of the last error event a sink sent (Sentry's), for a support request or feedback. */\n lastEventId(): string | undefined;\n /** The current session replay's id, when a sink records replays. */\n replayId(): string | undefined;\n /**\n * An Expo Router `ErrorBoundary` for a route: reports the error non-fatal\n * (source `screen`), shows `fallback` (default `ScreenErrorScreen`) with\n * \"Try again\", and is wrapped by each sink's route wrapper (Sentry's\n * `wrapExpoRouterErrorBoundary`). Build it once, at module scope.\n */\n screenBoundary(fallback?: ComponentType<ScreenErrorProps>): ComponentType<ScreenErrorProps>;\n /** For the shell: every error it catches. */\n readonly onError: (error: Error, report: ErrorReport) => void;\n readonly Root: ComponentType<NativeBlockRootProps>;\n}\n\ndeclare const __DEV__: boolean | undefined;\n\nlet releaseReloadHook: (() => void) | undefined;\n\nconst TIMING_NAME = /^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*$/;\n\nfunction createRecentStore(maxCrumbs: number, maxErrors: number): RecentStore & { addCrumb(c: Breadcrumb): void; addError(e: RecentError): void } {\n let state: RecentActivity = { breadcrumbs: [], errors: [] };\n const listeners = new Set<() => void>();\n const emit = () => listeners.forEach((l) => l());\n const push = <T,>(list: readonly T[], item: T, max: number) => (list.length >= max ? [...list.slice(list.length - max + 1), item] : [...list, item]);\n return {\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n clear() {\n state = { breadcrumbs: [], errors: [] };\n emit();\n },\n addCrumb(crumb) {\n state = { ...state, breadcrumbs: push(state.breadcrumbs, crumb, maxCrumbs) };\n emit();\n },\n addError(error) {\n state = { ...state, errors: push(state.errors, error, maxErrors) };\n emit();\n },\n };\n}\n\nfunction toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/** Build the block once, at module scope, before the root layout renders. @stability Beta */\nexport function createObservability<const E extends EventSchema = EventSchema>(options: ObservabilityOptions<E>): ObservabilityBlock<E> {\n const sinks = options.sinks.filter((s): s is ObservabilitySink => Boolean(s));\n const now = options.now ?? Date.now;\n const problem =\n options.onProblem ??\n ((message: string, error?: unknown) => {\n // genesis-allow-console: the block's own development warning; it can't report to itself.\n if (typeof __DEV__ !== \"undefined\" && __DEV__) console.warn(`[observability] ${message}`, error ?? \"\");\n });\n const recent = createRecentStore(options.recent?.breadcrumbs ?? 50, options.recent?.errors ?? 20);\n let route: string | null = null;\n let user: string | null | undefined;\n\n // One sink failing never stops the others, and never throws into the caller (an error handler, a render).\n const each = (method: string, call: (sink: ObservabilitySink) => void) => {\n for (const sink of sinks) {\n try {\n call(sink);\n } catch (error) {\n try {\n problem(`${sink.name}.${method} threw`, error);\n } catch {\n // ignore a failing reporter\n }\n }\n }\n };\n\n // Never throws into the caller (an effect, a handler): a record that can't be scrubbed is dropped.\n const breadcrumb = (input: Breadcrumb) => {\n let crumb: Breadcrumb;\n try {\n crumb = scrubBreadcrumb({ ...input, timestamp: input.timestamp ?? now() });\n } catch (error) {\n problem(\"breadcrumb dropped: it could not be scrubbed\", error);\n return;\n }\n recent.addCrumb(crumb);\n each(\"breadcrumb\", (s) => s.breadcrumb?.(crumb));\n };\n\n const captureError = (value: unknown, context: Partial<ErrorContext> = {}, skip?: ReadonlySet<ObservabilitySink>) => {\n const error = toError(value);\n const full: ErrorContext = {\n fatal: context.fatal ?? false,\n source: context.source ?? \"app\",\n route: context.route ?? route,\n componentStack: context.componentStack,\n ...(context.handled !== undefined ? { handled: context.handled } : {}),\n ...(context.tags ? { tags: context.tags } : {}),\n };\n let safe: Error | undefined;\n const scrubbed = () => (safe ??= scrubbedError(error));\n try {\n recent.addError({ at: now(), name: error.name, message: scrubString(error.message), source: full.source, fatal: full.fatal });\n } catch {\n // never let the overlay's list stop a report\n }\n let forSinks: ErrorContext = full;\n try {\n forSinks = {\n ...full,\n ...(full.componentStack ? { componentStack: scrubString(full.componentStack) } : {}),\n ...(full.tags ? { tags: scrubValue(full.tags) as Record<string, string> } : {}),\n };\n } catch {\n // Tags that can't be scrubbed are dropped, never sent raw.\n forSinks = { ...full, componentStack: undefined, tags: undefined };\n }\n each(\"captureError\", (s) => {\n if (skip?.has(s)) return;\n s.captureError?.(s.scrubsErrors ? error : scrubbed(), s.scrubsErrors ? full : forSinks);\n });\n };\n\n const flush = async (timeoutMs = 2000): Promise<boolean> => {\n const results = sinks.map(async (sink) => {\n if (!sink.flush) return true;\n try {\n return (await sink.flush(timeoutMs)) !== false;\n } catch (error) {\n problem(`${sink.name}.flush threw`, error);\n return false;\n }\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs);\n });\n try {\n return await Promise.race([Promise.all(results).then((all) => all.every(Boolean)), deadline]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n };\n\n const firstOf = (read: (sink: ObservabilitySink) => string | undefined): string | undefined => {\n for (const sink of sinks) {\n try {\n const value = read(sink);\n if (value) return value;\n } catch (error) {\n problem(`${sink.name} threw reading an id`, error);\n }\n }\n return undefined;\n };\n\n const setUser = (id: string | null) => {\n if (id === user) return;\n user = id;\n each(\"setUser\", (s) => s.setUser?.(id));\n };\n\n const track = (name: string, props?: Readonly<Record<string, unknown>>) => {\n const check = options.events ? checkEvent(options.events, name, props) : ({ ok: false, problem: \"no event schema: pass `events: defineEvents({…})`\" } as const);\n if (!check.ok) {\n problem(`track dropped: ${check.problem}`);\n return;\n }\n recent.addCrumb({ category: \"event\", message: name, level: \"info\", data: check.props, timestamp: now() });\n each(\"event\", (s) => s.event?.(name, check.props));\n };\n\n const timing = (name: string, ms: number, tags?: TimingTags) => {\n if (!Number.isFinite(ms) || ms < 0) return;\n // A name like an event's (`route.time_on_screen`), never text with values in it.\n if (!TIMING_NAME.test(name)) {\n problem(`timing dropped: \"${scrubString(name)}\" is not lower-case words joined by \".\"`);\n return;\n }\n let safeTags: TimingTags | undefined;\n try {\n safeTags = tags ? (scrubValue(tags) as TimingTags) : undefined;\n } catch (error) {\n problem(\"timing dropped: its tags could not be scrubbed\", error);\n return;\n }\n each(\"timing\", (s) => s.timing?.(name, ms, safeTags));\n };\n\n const declaration = defineBlock<typeof OBSERVABILITY_BLOCK_ID, ComponentType<never>>({\n id: OBSERVABILITY_BLOCK_ID,\n platforms: [\"native\"],\n contributes: {\n privacy: {\n collects: [\n // genesis-cli's PRIVACY_BLOCKS.observability mirrors this (with events) for the iOS\n // privacy manifest; observability/block.test.tsx keeps the two the same.\n { type: \"crash data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"performance data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n // Sentry's device and OS details, breadcrumbs and sessions.\n { type: \"other diagnostic data\", purposes: [\"app functionality\"], linked: true, tracking: false },\n { type: \"user id\", purposes: options.events ? [\"app functionality\", \"analytics\"] : [\"app functionality\"], linked: true, tracking: false },\n ...(options.events ? [{ type: \"product interaction\", purposes: [\"analytics\"], linked: true, tracking: false }] : []),\n ],\n notes: [\n \"Crash reports, timings and analytics events carry the login's id only; emails, tokens, keys and query strings are removed on the device before anything is sent.\",\n ],\n },\n },\n });\n\n const useSegments = options.useSegments;\n function RouteTracker() {\n const segments = (useSegments as () => readonly string[])();\n const path = `/${segments.join(\"/\")}`;\n const last = useRef<{ path: string; at: number } | null>(null);\n useEffect(() => {\n const at = now();\n const previous = last.current;\n if (previous?.path === path) return;\n route = path;\n breadcrumb({ category: \"navigation\", message: path, data: previous ? { from: previous.path } : undefined, timestamp: at });\n if (previous) timing(\"route.time_on_screen\", at - previous.at, { route: previous.path });\n last.current = { path, at };\n }, [path]);\n return null;\n }\n\n function UserTracker() {\n const { userId } = useSession();\n useEffect(() => setUser(userId ?? null), [userId]);\n return null;\n }\n\n const block: ObservabilityBlock<E> = {\n ...declaration,\n sinks,\n events: options.events,\n captureError,\n breadcrumb,\n setUser,\n track: track as ObservabilityBlock<E>[\"track\"],\n timing,\n recent,\n wrap(root) {\n return sinks.reduce((wrapped, sink) => (sink.wrap ? sink.wrap(wrapped) : wrapped), root);\n },\n onError: (error, report) =>\n captureError(error, {\n fatal: report.fatal,\n source: report.source,\n componentStack: report.componentStack,\n ...(report.handled !== undefined ? { handled: report.handled } : {}),\n ...(report.tags ? { tags: report.tags } : {}),\n }),\n flush,\n lastEventId: () => firstOf((s) => s.lastEventId?.()),\n replayId: () => firstOf((s) => s.replayId?.()),\n screenBoundary(fallback) {\n const wrapping = sinks.filter((s) => s.wrapRouteErrorBoundary);\n // A sink whose wrapper reports the route's error (Sentry's) isn't sent it a second time.\n const skip = new Set(wrapping);\n return createScreenErrorBoundary({\n fallback,\n onError: (error, report) => captureError(error, { fatal: report.fatal, source: report.source }, skip),\n wrap: wrapping.map((sink) => (boundary: ComponentType<ScreenErrorProps>) => {\n try {\n return sink.wrapRouteErrorBoundary!(boundary);\n } catch (error) {\n problem(`${sink.name}.wrapRouteErrorBoundary threw`, error);\n skip.delete(sink);\n return boundary;\n }\n }),\n });\n },\n Root: function ObservabilityRoot({ children }: NativeBlockRootProps) {\n return (\n <ObservabilityContext.Provider value={block as ObservabilityBlock}>\n <UserTracker />\n {useSegments ? <RouteTracker /> : null}\n {children}\n </ObservabilityContext.Provider>\n );\n },\n };\n if (options.reportErrors !== false) {\n setErrorReporter((value, context) =>\n captureError(value, { fatal: context.fatal ?? false, source: context.source, ...(context.tags ? { tags: context.tags } : {}) }),\n );\n }\n const flushMs = options.flushBeforeReloadMs ?? 2000;\n // The newest block replaces the last one's hook (Fast Refresh builds the block again).\n releaseReloadHook?.();\n releaseReloadHook = flushMs > 0 && sinks.some((s) => s.flush) ? onBeforeReload(() => flush(flushMs)) : undefined;\n return block;\n}\n\nconst ObservabilityContext = createContext<ObservabilityBlock | null>(null);\n\n/** Provides a block to the hooks without its root (rung 4). @stability Beta */\nexport function ObservabilityProvider({ block, children }: { block: ObservabilityBlock; children?: ReactNode }) {\n return <ObservabilityContext.Provider value={block}>{children}</ObservabilityContext.Provider>;\n}\n\n/** The block, or `null` when it is off (so a screen can call it whether or not the block is on). @stability Beta */\nexport function useObservability(): ObservabilityBlock | null {\n return useContext(ObservabilityContext);\n}\n\n/** The last breadcrumbs and errors, scrubbed; empty when the block is off. @stability Beta */\nexport function useRecentActivity(block?: ObservabilityBlock | null): RecentActivity {\n const fromContext = useObservability();\n const store = (block ?? fromContext)?.recent ?? EMPTY_STORE;\n return useSyncExternalStore(store.subscribe, store.getState, store.getState);\n}\n\nconst EMPTY: RecentActivity = { breadcrumbs: [], errors: [] };\nconst EMPTY_STORE: RecentStore = { getState: () => EMPTY, subscribe: () => () => {}, clear: () => {} };\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { QueryClient, focusManager, onlineManager, isCancelledError } from '@tanstack/react-query';
|
|
2
|
+
import { classifyError } from '@marktiderman/genesis-core/errors';
|
|
3
|
+
|
|
4
|
+
// src/query.ts
|
|
5
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
6
|
+
function createNativeQueryClient(config = {}) {
|
|
7
|
+
const { queries, mutations, ...rest } = config.defaultOptions ?? {};
|
|
8
|
+
return new QueryClient({
|
|
9
|
+
...config,
|
|
10
|
+
defaultOptions: {
|
|
11
|
+
...rest,
|
|
12
|
+
queries: { networkMode: "offlineFirst", gcTime: DAY_MS, staleTime: 6e4, ...queries },
|
|
13
|
+
mutations: { networkMode: "offlineFirst", ...mutations }
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function connectQueryLifecycle({ appState, netInfo }) {
|
|
18
|
+
if (appState) {
|
|
19
|
+
focusManager.setEventListener((setFocused) => {
|
|
20
|
+
const subscription = appState.addEventListener("change", (state) => setFocused(state === "active"));
|
|
21
|
+
return () => subscription.remove();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (netInfo) {
|
|
25
|
+
onlineManager.setEventListener((setOnline) => netInfo.addEventListener((state) => setOnline(state.isConnected !== false)));
|
|
26
|
+
}
|
|
27
|
+
return () => {
|
|
28
|
+
if (appState) focusManager.setEventListener(() => () => {
|
|
29
|
+
});
|
|
30
|
+
if (netInfo) {
|
|
31
|
+
onlineManager.setEventListener(() => () => {
|
|
32
|
+
});
|
|
33
|
+
onlineManager.setOnline(true);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var KEY_NAME = /^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;
|
|
38
|
+
var LOOKS_LIKE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-|^\d+$|[0-9a-f]{20,}/i;
|
|
39
|
+
function queryKeyName(key) {
|
|
40
|
+
const first = key?.[0];
|
|
41
|
+
return typeof first === "string" && KEY_NAME.test(first) && !LOOKS_LIKE_ID.test(first) ? first : void 0;
|
|
42
|
+
}
|
|
43
|
+
function toError(value) {
|
|
44
|
+
return value instanceof Error ? value : new Error(typeof value === "string" ? value : "Unknown error");
|
|
45
|
+
}
|
|
46
|
+
function reportQueryErrors(client, report, options = {}) {
|
|
47
|
+
const isOffline = options.isOffline ?? (() => !onlineManager.isOnline());
|
|
48
|
+
const send = (raw, source, key, meta) => {
|
|
49
|
+
if (meta?.reportErrors === false || isCancelledError(raw)) return;
|
|
50
|
+
if (!classifyError(raw, { isOffline }).report) return;
|
|
51
|
+
const name = queryKeyName(key);
|
|
52
|
+
try {
|
|
53
|
+
report(toError(raw), { fatal: false, source, ...name ? { tags: { [`${source}.key`]: name } } : {} });
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const offQueries = client.getQueryCache().subscribe((event) => {
|
|
58
|
+
if (event.type !== "updated" || event.action.type !== "error") return;
|
|
59
|
+
send(event.action.error, "query", event.query.queryKey, event.query.meta);
|
|
60
|
+
});
|
|
61
|
+
const offMutations = client.getMutationCache().subscribe((event) => {
|
|
62
|
+
if (event.type !== "updated" || event.action.type !== "error") return;
|
|
63
|
+
send(event.action.error, "mutation", event.mutation.options.mutationKey, event.mutation.meta);
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
offQueries();
|
|
67
|
+
offMutations();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { DAY_MS, connectQueryLifecycle, createNativeQueryClient, queryKeyName, reportQueryErrors };
|
|
72
|
+
//# sourceMappingURL=chunk-C54LIT4N.js.map
|
|
73
|
+
//# sourceMappingURL=chunk-C54LIT4N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/query.ts"],"names":[],"mappings":";;;;AAkBO,IAAM,MAAA,GAAS,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK;AAc9B,SAAS,uBAAA,CAAwB,MAAA,GAA4B,EAAC,EAAgB;AACnF,EAAA,MAAM,EAAE,SAAS,SAAA,EAAW,GAAG,MAAK,GAAI,MAAA,CAAO,kBAAkB,EAAC;AAClE,EAAA,OAAO,IAAI,WAAA,CAAY;AAAA,IACrB,GAAG,MAAA;AAAA,IACH,cAAA,EAAgB;AAAA,MACd,GAAG,IAAA;AAAA,MACH,OAAA,EAAS,EAAE,WAAA,EAAa,cAAA,E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CAAM,OAAO,KAAA,EAAO,OAAA,EAAS,MAAM,KAAA,CAAM,QAAA,EAAU,KAAA,CAAM,KAAA,CAAM,IAAI,CAAA;AAAA,EAC1E,CAAC,CAAA;AACD,EAAA,MAAM,eAAe,MAAA,CAAO,gBAAA,EAAiB,CAAE,SAAA,CAAU,CAAC,KAAA,KAAU;AAClE,IAAA,IAAI,MAAM,IAAA,KAAS,SAAA,IAAa,KAAA,CAAM,MAAA,CAAO,SAAS,OAAA,EAAS;AAC/D,IAAA,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,KAAA,EAAO,UAAA,EAAY,KAAA,CAAM,SAAS,OAAA,CAAQ,WAAA,EAAa,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AAAA,EAC9F,CAAC,CAAA;AACD,EAAA,OAAO,MAAM;AACX,IAAA,UAAA,EAAW;AACX,IAAA,YAAA,EAAa;AAAA,EACf,CAAA;AACF","file":"chunk-C54LIT4N.js","sourcesContent":["/**\n * Query: a TanStack Query client with offline-safe defaults, and the contract\n * for saving it to the phone. The persister itself is in\n * `@marktiderman/genesis-native/persist`, so an app that saves nothing doesn't\n * install TanStack's persister packages.\n */\nimport { QueryClient, focusManager, isCancelledError, onlineManager, type QueryClientConfig } from \"@tanstack/react-query\";\nimport { classifyError } from \"@marktiderman/genesis-core/errors\";\nimport type { ErrorReport } from \"./errors\";\n\n/** The part of AsyncStorage (or any async key-value store) Genesis uses. */\nexport interface AsyncStorageLike {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\n/** One day in milliseconds: the default max age of the saved query cache. */\nexport const DAY_MS = 24 * 60 * 60 * 1000;\n\n/**\n * A QueryClient for a phone. `networkMode: \"offlineFirst\"` runs a query or\n * mutation once whatever the network says, then pauses its retries while the\n * device is offline (`onlineManager`, which `connectQueryLifecycle` feeds from\n * NetInfo), continues them when it is back, and refetches stale queries on\n * reconnect. So offline, a query with saved data keeps showing it\n * (`fetchStatus: \"paused\"`); one with nothing saved stays `pending` and paused\n * until the network returns (check `isPaused`, not only `isPending`, before\n * showing a spinner); and a mutation, which TanStack doesn't retry by default,\n * fails at once instead of waiting. `gcTime` matches the persisted max age, or\n * restored queries would be collected before they are used. Your `config` wins.\n */\nexport function createNativeQueryClient(config: QueryClientConfig = {}): QueryClient {\n const { queries, mutations, ...rest } = config.defaultOptions ?? {};\n return new QueryClient({\n ...config,\n defaultOptions: {\n ...rest,\n queries: { networkMode: \"offlineFirst\", gcTime: DAY_MS, staleTime: 60_000, ...queries },\n mutations: { networkMode: \"offlineFirst\", ...mutations },\n },\n });\n}\n\n/**\n * The saved query cache. A `scope` (the signed-in user's id, `\"\"` for nobody)\n * is part of what is saved: a cache saved for one user is discarded, on disk\n * too, when another scope restores it.\n */\nexport interface QueryPersistence {\n /** Load the saved cache into the client, if it was saved for `scope`. */\n restore(scope: string): Promise<void>;\n /** Save on every cache change, for `scope`; returns the unsubscribe. */\n subscribe(scope: string): () => void;\n /**\n * Delete the saved cache. Clear the QueryClient first: the subscription\n * then saves the empty cache, so a save already in flight can't leave the\n * old queries on disk.\n */\n clear(): Promise<void>;\n}\n\n/** React Native's `AppState`, or a stand-in. */\nexport interface AppStateLike {\n addEventListener(type: \"change\", listener: (state: string) => void): { remove(): void };\n}\n\n/** `@react-native-community/netinfo`'s default export, or a stand-in. */\nexport interface NetInfoLike {\n addEventListener(listener: (state: { isConnected: boolean | null }) => void): () => void;\n}\n\nexport interface QueryLifecycleOptions {\n appState?: AppStateLike;\n netInfo?: NetInfoLike;\n}\n\n/**\n * Tell TanStack Query when the app comes to the front (refetch stale\n * queries) and when the network comes and goes. Returns the cleanup.\n */\nexport function connectQueryLifecycle({ appState, netInfo }: QueryLifecycleOptions): () => void {\n if (appState) {\n focusManager.setEventListener((setFocused) => {\n const subscription = appState.addEventListener(\"change\", (state) => setFocused(state === \"active\"));\n return () => subscription.remove();\n });\n }\n if (netInfo) {\n onlineManager.setEventListener((setOnline) => netInfo.addEventListener((state) => setOnline(state.isConnected !== false)));\n }\n return () => {\n // Replacing the listener runs the cleanup of the one set above.\n if (appState) focusManager.setEventListener(() => () => {});\n if (netInfo) {\n onlineManager.setEventListener(() => () => {});\n // Nothing reports the network any more: don't leave paused queries waiting on the last\n // \"offline\" NetInfo said (offlineFirst pauses retries while offline).\n onlineManager.setOnline(true);\n }\n };\n}\n\n/** A failed query or mutation, as `reportQueryErrors` hands it on. */\nexport type QueryErrorReporter = (error: Error, report: ErrorReport) => void;\n\nexport interface ReportQueryErrorsOptions {\n /** True when the device is offline. Default TanStack's `onlineManager`. */\n isOffline?: () => boolean;\n}\n\n// A key segment that is a name (`tasks`, `chat.messages`), not an id or text.\nconst KEY_NAME = /^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;\nconst LOOKS_LIKE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-|^\\d+$|[0-9a-f]{20,}/i;\n\n/** The first segment of a query or mutation key, when it is a name; never the ids after it. */\nexport function queryKeyName(key: readonly unknown[] | undefined): string | undefined {\n const first = key?.[0];\n return typeof first === \"string\" && KEY_NAME.test(first) && !LOOKS_LIKE_ID.test(first) ? first : undefined;\n}\n\nfunction toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/**\n * Hand every query and mutation that failed for good (after its retries) to\n * `report`, as a non-fatal `query` or `mutation` error tagged with the key's\n * first segment (`query.key: \"tasks\"`), never the ids after it.\n *\n * Only errors worth a report (`classifyError(e).report`): being offline,\n * signed out, a record that's gone and the server's expected refusals\n * (forbidden, conflict, a rejected value) are the screen's to show, not\n * bugs. A cancelled query is never reported. One query or mutation opts out\n * with `meta: { reportErrors: false }`.\n *\n * Works on any client (it subscribes to the caches), so it covers a client\n * the app passed in too. Returns the unsubscribe.\n *\n * @stability Beta\n */\nexport function reportQueryErrors(client: QueryClient, report: QueryErrorReporter, options: ReportQueryErrorsOptions = {}): () => void {\n const isOffline = options.isOffline ?? (() => !onlineManager.isOnline());\n const send = (raw: unknown, source: \"query\" | \"mutation\", key: readonly unknown[] | undefined, meta: Record<string, unknown> | undefined) => {\n if (meta?.reportErrors === false || isCancelledError(raw)) return;\n if (!classifyError(raw, { isOffline }).report) return;\n const name = queryKeyName(key);\n try {\n report(toError(raw), { fatal: false, source, ...(name ? { tags: { [`${source}.key`]: name } } : {}) });\n } catch {\n // A failing reporter must not break the cache's listeners.\n }\n };\n const offQueries = client.getQueryCache().subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n send(event.action.error, \"query\", event.query.queryKey, event.query.meta);\n });\n const offMutations = client.getMutationCache().subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n send(event.action.error, \"mutation\", event.mutation.options.mutationKey, event.mutation.meta);\n });\n return () => {\n offQueries();\n offMutations();\n };\n}\n"]}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { createContext, useContext, useSyncExternalStore, Component, useMemo, useRef, useEffect } from 'react';
|
|
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';
|
|
5
|
+
import { classifyError, reportError } from '@marktiderman/genesis-core/errors';
|
|
6
|
+
|
|
7
|
+
// src/boot.tsx
|
|
8
|
+
var BootTimeoutError = class extends Error {
|
|
9
|
+
step;
|
|
10
|
+
constructor(step, ms, reason = "did not finish") {
|
|
11
|
+
super(`Boot step "${step}" ${reason} within ${ms} ms.`);
|
|
12
|
+
this.name = "BootTimeoutError";
|
|
13
|
+
this.step = step;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
17
|
+
function toError(value) {
|
|
18
|
+
if (value instanceof Error) return value;
|
|
19
|
+
return new Error(typeof value === "string" ? value : "Unknown error", { cause: value });
|
|
20
|
+
}
|
|
21
|
+
function settledWithin(promise, ms) {
|
|
22
|
+
let timer;
|
|
23
|
+
return Promise.race([
|
|
24
|
+
promise.then(
|
|
25
|
+
() => "settled",
|
|
26
|
+
() => "settled"
|
|
27
|
+
),
|
|
28
|
+
new Promise((resolve) => {
|
|
29
|
+
timer = setTimeout(() => resolve("pending"), ms);
|
|
30
|
+
})
|
|
31
|
+
]).finally(() => clearTimeout(timer));
|
|
32
|
+
}
|
|
33
|
+
function createBoot(steps, options = {}) {
|
|
34
|
+
const seen = /* @__PURE__ */ new Set();
|
|
35
|
+
for (const step of steps) {
|
|
36
|
+
if (seen.has(step.id)) throw new Error(`Boot step "${step.id}" is listed twice.`);
|
|
37
|
+
seen.add(step.id);
|
|
38
|
+
}
|
|
39
|
+
const { minimumMs = 0, timeoutMs = DEFAULT_TIMEOUT_MS } = options;
|
|
40
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
41
|
+
let state = { status: "idle", error: null, failedStep: null, completed: [] };
|
|
42
|
+
let inFlight = null;
|
|
43
|
+
const abandoned = /* @__PURE__ */ new Map();
|
|
44
|
+
const runStep = async (step, ms) => {
|
|
45
|
+
const previous = abandoned.get(step.id);
|
|
46
|
+
if (previous) {
|
|
47
|
+
if (await settledWithin(previous, ms) === "pending") {
|
|
48
|
+
throw new BootTimeoutError(step.id, ms, "is still running from the last attempt");
|
|
49
|
+
}
|
|
50
|
+
abandoned.delete(step.id);
|
|
51
|
+
if (await previous === "ok") return;
|
|
52
|
+
}
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const running = Promise.resolve().then(() => step.run({ signal: controller.signal }));
|
|
55
|
+
if (await settledWithin(running, ms) === "pending") {
|
|
56
|
+
controller.abort();
|
|
57
|
+
abandoned.set(step.id, running.then(() => "ok", () => "failed"));
|
|
58
|
+
throw new BootTimeoutError(step.id, ms);
|
|
59
|
+
}
|
|
60
|
+
await running;
|
|
61
|
+
};
|
|
62
|
+
const set = (next) => {
|
|
63
|
+
state = { ...state, ...next };
|
|
64
|
+
for (const listener of listeners) listener();
|
|
65
|
+
};
|
|
66
|
+
const run = async () => {
|
|
67
|
+
const started = Date.now();
|
|
68
|
+
set({ status: "booting", error: null, failedStep: null });
|
|
69
|
+
for (const step of steps) {
|
|
70
|
+
if (state.completed.includes(step.id)) continue;
|
|
71
|
+
try {
|
|
72
|
+
await runStep(step, step.timeoutMs ?? timeoutMs);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
set({ status: "failed", error: toError(error), failedStep: step.id });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
set({ completed: [...state.completed, step.id] });
|
|
78
|
+
}
|
|
79
|
+
const wait = minimumMs - (Date.now() - started);
|
|
80
|
+
if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait));
|
|
81
|
+
set({ status: "ready" });
|
|
82
|
+
};
|
|
83
|
+
const start = () => {
|
|
84
|
+
if (state.status === "ready") return Promise.resolve();
|
|
85
|
+
if (!inFlight) {
|
|
86
|
+
inFlight = run().finally(() => {
|
|
87
|
+
inFlight = null;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return inFlight;
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
getState: () => state,
|
|
94
|
+
subscribe(listener) {
|
|
95
|
+
listeners.add(listener);
|
|
96
|
+
return () => listeners.delete(listener);
|
|
97
|
+
},
|
|
98
|
+
start,
|
|
99
|
+
retry: start
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
var BootContext = createContext(null);
|
|
103
|
+
function BootProvider({ boot, children }) {
|
|
104
|
+
return /* @__PURE__ */ jsx(BootContext.Provider, { value: boot, children });
|
|
105
|
+
}
|
|
106
|
+
function useBoot() {
|
|
107
|
+
const boot = useContext(BootContext);
|
|
108
|
+
if (!boot) throw new Error("useBoot must be used inside <GenesisNativeApp> or <BootProvider>.");
|
|
109
|
+
const state = useSyncExternalStore(boot.subscribe, boot.getState, boot.getState);
|
|
110
|
+
return { ...state, retry: () => void boot.retry() };
|
|
111
|
+
}
|
|
112
|
+
function errorDetails(error) {
|
|
113
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) return error.message;
|
|
114
|
+
const classified = classifyError(error);
|
|
115
|
+
return classified.kind === "unexpected" ? void 0 : classified.message;
|
|
116
|
+
}
|
|
117
|
+
function FatalScreen({ error, retry }) {
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
NativeEmptyState,
|
|
120
|
+
{
|
|
121
|
+
variant: "error",
|
|
122
|
+
title: "Something went wrong",
|
|
123
|
+
body: "The app hit a problem. Try again, and if it keeps happening, close and reopen the app.",
|
|
124
|
+
details: errorDetails(error),
|
|
125
|
+
primaryAction: /* @__PURE__ */ jsx(NativeButton, { onPress: retry, testID: "genesis-fatal-retry", children: "Try again" }),
|
|
126
|
+
testID: "genesis-fatal"
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function PlainFatalScreen({ error, retry }) {
|
|
131
|
+
return /* @__PURE__ */ jsxs(View, { testID: "genesis-fatal-plain", style: { flex: 1, justifyContent: "center", alignItems: "center", padding: 24, gap: 12 }, children: [
|
|
132
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: { fontSize: 17, fontWeight: "600" }, children: "Something went wrong" }),
|
|
133
|
+
/* @__PURE__ */ jsx(Text, { style: { textAlign: "center" }, children: errorDetails(error) ?? "Try again, and if it keeps happening, close and reopen the app." }),
|
|
134
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: retry, testID: "genesis-fatal-plain-retry", style: { padding: 12 }, children: /* @__PURE__ */ jsx(Text, { style: { fontSize: 17 }, children: "Try again" }) })
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
var GenesisErrorBoundary = class extends Component {
|
|
138
|
+
state = { error: null };
|
|
139
|
+
static getDerivedStateFromError(error) {
|
|
140
|
+
return { error: toError(error) };
|
|
141
|
+
}
|
|
142
|
+
componentDidCatch(error, info) {
|
|
143
|
+
try {
|
|
144
|
+
this.props.onError?.(toError(error), {
|
|
145
|
+
fatal: this.props.fatal ?? true,
|
|
146
|
+
source: this.props.source ?? "boundary",
|
|
147
|
+
componentStack: info.componentStack ?? void 0
|
|
148
|
+
});
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
componentDidUpdate(previous) {
|
|
153
|
+
if (this.state.error && previous.resetKey !== this.props.resetKey) this.setState({ error: null });
|
|
154
|
+
}
|
|
155
|
+
retry = () => {
|
|
156
|
+
this.setState({ error: null });
|
|
157
|
+
this.props.onRetry?.();
|
|
158
|
+
};
|
|
159
|
+
render() {
|
|
160
|
+
const { error } = this.state;
|
|
161
|
+
if (!error) return this.props.children ?? null;
|
|
162
|
+
const Fallback = this.props.fallback;
|
|
163
|
+
return /* @__PURE__ */ jsx(Fallback, { error, retry: this.retry });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
function installGlobalErrorHandler({ errorUtils, onError, onFatal, alreadyFatal }) {
|
|
167
|
+
const previous = errorUtils.getGlobalHandler();
|
|
168
|
+
errorUtils.setGlobalHandler((raw, isFatal) => {
|
|
169
|
+
const error = toError(raw);
|
|
170
|
+
try {
|
|
171
|
+
onError?.(error, { fatal: Boolean(isFatal), source: "global" });
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
if (isFatal && !alreadyFatal?.()) onFatal(error);
|
|
175
|
+
else previous?.(raw, isFatal);
|
|
176
|
+
});
|
|
177
|
+
return () => {
|
|
178
|
+
errorUtils.setGlobalHandler(previous ?? ((error) => console.error(error)));
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function defaultErrorUtils() {
|
|
182
|
+
const candidate = globalThis.ErrorUtils;
|
|
183
|
+
return candidate && typeof candidate.setGlobalHandler === "function" ? candidate : void 0;
|
|
184
|
+
}
|
|
185
|
+
function defaultRejectionTracker() {
|
|
186
|
+
const hermes = globalThis.HermesInternal;
|
|
187
|
+
const enable = hermes?.enablePromiseRejectionTracker;
|
|
188
|
+
return typeof enable === "function" ? enable.bind(hermes) : void 0;
|
|
189
|
+
}
|
|
190
|
+
function installRejectionTracker({ enable, onError }) {
|
|
191
|
+
enable({
|
|
192
|
+
allRejections: true,
|
|
193
|
+
onUnhandled: (id, rejection) => {
|
|
194
|
+
const error = toError(rejection);
|
|
195
|
+
console.warn(`Uncaught (in promise, id: ${id}): ${error.message}`);
|
|
196
|
+
try {
|
|
197
|
+
onError(error, { fatal: false, handled: false, source: "rejection" });
|
|
198
|
+
} catch {
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
onHandled: () => {
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function ScreenErrorScreen({ error, retry }) {
|
|
206
|
+
return /* @__PURE__ */ jsx(
|
|
207
|
+
NativeEmptyState,
|
|
208
|
+
{
|
|
209
|
+
variant: "error",
|
|
210
|
+
title: "This screen hit a problem",
|
|
211
|
+
body: "The rest of the app still works. Try again, or go back.",
|
|
212
|
+
details: errorDetails(error),
|
|
213
|
+
primaryAction: /* @__PURE__ */ jsx(NativeButton, { onPress: () => void Promise.resolve(retry()).catch((e) => reportError(e, "native:screen-retry")), testID: "genesis-screen-error-retry", children: "Try again" }),
|
|
214
|
+
testID: "genesis-screen-error"
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
var reportThroughCore = (error, report) => reportError(error, { source: report.source, fatal: report.fatal, ...report.tags ? { tags: report.tags } : {} });
|
|
219
|
+
function createScreenErrorBoundary(options = {}) {
|
|
220
|
+
const Fallback = options.fallback ?? ScreenErrorScreen;
|
|
221
|
+
const onError = options.onError ?? reportThroughCore;
|
|
222
|
+
function GenesisScreenErrorBoundary(props) {
|
|
223
|
+
const reported = useRef(null);
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
if (reported.current === props.error) return;
|
|
226
|
+
reported.current = props.error;
|
|
227
|
+
try {
|
|
228
|
+
onError(props.error, { fatal: false, source: "screen" });
|
|
229
|
+
} catch {
|
|
230
|
+
}
|
|
231
|
+
}, [props.error]);
|
|
232
|
+
return /* @__PURE__ */ jsx(Fallback, { ...props });
|
|
233
|
+
}
|
|
234
|
+
return (options.wrap ?? []).reduce((inner, wrap) => wrap(inner), GenesisScreenErrorBoundary);
|
|
235
|
+
}
|
|
236
|
+
function ScreenErrorBoundary({ children, fallback, onError, resetKey }) {
|
|
237
|
+
const Screen = fallback ?? ScreenErrorScreen;
|
|
238
|
+
const Fallback = useMemo(
|
|
239
|
+
() => function ScreenFallback({ error, retry }) {
|
|
240
|
+
return /* @__PURE__ */ jsx(Screen, { error, retry: async () => retry() });
|
|
241
|
+
},
|
|
242
|
+
[Screen]
|
|
243
|
+
);
|
|
244
|
+
return /* @__PURE__ */ jsx(GenesisErrorBoundary, { fallback: Fallback, onError: onError ?? reportThroughCore, resetKey, fatal: false, source: "screen", children });
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { BootProvider, BootTimeoutError, FatalScreen, GenesisErrorBoundary, PlainFatalScreen, ScreenErrorBoundary, ScreenErrorScreen, createBoot, createScreenErrorBoundary, defaultErrorUtils, defaultRejectionTracker, errorDetails, installGlobalErrorHandler, installRejectionTracker, useBoot };
|
|
248
|
+
//# sourceMappingURL=chunk-MFHOHSEQ.js.map
|
|
249
|
+
//# sourceMappingURL=chunk-MFHOHSEQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/boot.tsx","../src/errors.tsx","../src/screen-boundary.tsx"],"names":["jsx","NativeEmptyState","NativeButton"],"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,IAA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A,EAAU,OAAA,EAAS,UAAS,EAA6B;AACvG,EAAA,MAAM,SAAS,QAAA,IAAY,iBAAA;AAE3B,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACf,MACE,SAAS,cAAA,CAAe,EAAE,KAAA,EAAO,OAAM,EAAqB;AAC1D,MAAA,uBAAOA,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-MFHOHSEQ.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 } 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/** The default fatal screen: what went wrong and \"Try again\". */\nexport function FatalScreen({ error, retry }: FatalScreenProps) {\n return (\n <NativeEmptyState\n variant=\"error\"\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 details={errorDetails(error)}\n primaryAction={\n <NativeButton onPress={retry} testID=\"genesis-fatal-retry\">\n Try again\n </NativeButton>\n }\n testID=\"genesis-fatal\"\n />\n );\n}\n\n/**\n * The last-resort fatal screen: React Native primitives only, no theme, no\n * context, nothing that can itself fail. Shown when the providers could not\n * start, or when the `fatal` slot threw.\n */\nexport function PlainFatalScreen({ error, retry }: FatalScreenProps) {\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={retry} testID=\"genesis-fatal-plain-retry\" style={{ padding: 12 }}>\n <Text style={{ fontSize: 17 }}>Try again</Text>\n </Pressable>\n </View>\n );\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 { NativeButton, NativeEmptyState } from \"@marktiderman/genesis-ui-native/components\";\nimport { reportError } from \"@marktiderman/genesis-core/errors\";\nimport { errorDetails, 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/** The default screen fallback: the screen hit a problem, and \"Try again\". @stability Beta */\nexport function ScreenErrorScreen({ error, retry }: ScreenErrorProps) {\n return (\n <NativeEmptyState\n variant=\"error\"\n title=\"This screen hit a problem\"\n body=\"The rest of the app still works. Try again, or go back.\"\n details={errorDetails(error)}\n primaryAction={\n <NativeButton onPress={() => void Promise.resolve(retry()).catch((e: unknown) => reportError(e, \"native:screen-retry\"))} testID=\"genesis-screen-error-retry\">\n Try again\n </NativeButton>\n }\n testID=\"genesis-screen-error\"\n />\n );\n}\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 `ScreenErrorScreen`. */\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 ?? ScreenErrorScreen;\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 ?? ScreenErrorScreen;\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"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/reload.ts
|
|
2
|
+
var KEY = /* @__PURE__ */ Symbol.for("genesis.beforeReload");
|
|
3
|
+
function hooks() {
|
|
4
|
+
const holder = globalThis;
|
|
5
|
+
return holder[KEY] ??= /* @__PURE__ */ new Set();
|
|
6
|
+
}
|
|
7
|
+
function onBeforeReload(hook) {
|
|
8
|
+
hooks().add(hook);
|
|
9
|
+
return () => {
|
|
10
|
+
hooks().delete(hook);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var BEFORE_RELOAD_TIMEOUT_MS = 2e3;
|
|
14
|
+
async function runBeforeReload(timeoutMs = BEFORE_RELOAD_TIMEOUT_MS) {
|
|
15
|
+
const list = [...hooks()];
|
|
16
|
+
if (list.length === 0) return;
|
|
17
|
+
const settled = Promise.allSettled(
|
|
18
|
+
list.map(async (hook) => {
|
|
19
|
+
await hook(timeoutMs);
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
let timer;
|
|
23
|
+
const deadline = new Promise((resolve) => {
|
|
24
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
await Promise.race([settled, deadline]);
|
|
28
|
+
} finally {
|
|
29
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { BEFORE_RELOAD_TIMEOUT_MS, onBeforeReload, runBeforeReload };
|
|
34
|
+
//# sourceMappingURL=chunk-VIC2KXMA.js.map
|
|
35
|
+
//# sourceMappingURL=chunk-VIC2KXMA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/reload.ts"],"names":[],"mappings":";AAaA,IAAM,GAAA,mBAAM,MAAA,CAAO,GAAA,CAAI,sBAAsB,CAAA;AAG7C,SAAS,KAAA,GAA+B;AACtC,EAAA,MAAM,MAAA,GAAS,UAAA;AACf,EAAA,OAAQ,MAAA,CAAO,GAAG,CAAA,qBAAM,IAAI,GAAA,EAAI;AAClC;AAGO,SAAS,eAAe,IAAA,EAAoC;AACjE,EAAA,KAAA,EAAM,CAAE,IAAI,IAAI,CAAA;AAChB,EAAA,OAAO,MAAM;AACX,IAAA,KAAA,EAAM,CAAE,OAAO,IAAI,CAAA;AAAA,EACrB,CAAA;AACF;AAGO,IAAM,wBAAA,GAA2B;AAQxC,eAAsB,eAAA,CAAgB,YAAoB,wBAAA,EAAyC;AACjG,EAAA,MAAM,IAAA,GAAO,CAAC,GAAG,KAAA,EAAO,CAAA;AACxB,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAM,UAAU,OAAA,CAAQ,UAAA;AAAA,IACtB,IAAA,CAAK,GAAA,CAAI,OAAO,IAAA,KAAS;AACvB,MAAA,MAAM,KAAK,SAAS,CAAA;AAAA,IACtB,CAAC;AAAA,GACH;AACA,EAAA,IAAI,KAAA;AACJ,EAAA,MAAM,QAAA,GAAW,IAAI,OAAA,CAAc,CAAC,OAAA,KAAY;AAC9C,IAAA,KAAA,GAAQ,UAAA,CAAW,SAAS,SAAS,CAAA;AAAA,EACvC,CAAC,CAAA;AACD,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,OAAA,EAAS,QAAQ,CAAC,CAAA;AAAA,EACxC,CAAA,SAAE;AACA,IAAA,IAAI,KAAA,KAAU,MAAA,EAAW,YAAA,CAAa,KAAK,CAAA;AAAA,EAC7C;AACF","file":"chunk-VIC2KXMA.js","sourcesContent":["/**\n * Before the app reloads itself (an over-the-air update applied now, a\n * channel switch), the JavaScript runtime is thrown away with whatever it\n * had queued. `onBeforeReload` registers work that must happen first (the\n * observability block flushes its sinks there); the updates block awaits\n * `runBeforeReload()` before `reloadAsync`. Each hook gets a share of a short\n * deadline, and a slow or failing hook never stops the reload.\n */\n\n/** Work to finish before a reload; gets the milliseconds it has. */\nexport type BeforeReloadHook = (timeoutMs: number) => unknown;\n\n// On globalThis, so the `/updates` and `/observability` entries share one list even when bundled apart.\nconst KEY = Symbol.for(\"genesis.beforeReload\");\ntype Holder = { [KEY]?: Set<BeforeReloadHook> };\n\nfunction hooks(): Set<BeforeReloadHook> {\n const holder = globalThis as Holder;\n return (holder[KEY] ??= new Set());\n}\n\n/** Run `hook` before every reload the updates block starts. Returns the unregister. @stability Beta */\nexport function onBeforeReload(hook: BeforeReloadHook): () => void {\n hooks().add(hook);\n return () => {\n hooks().delete(hook);\n };\n}\n\n/** The default deadline for every hook together. */\nexport const BEFORE_RELOAD_TIMEOUT_MS = 2000;\n\n/**\n * Run every registered hook, in parallel, and resolve when they have all\n * settled or `timeoutMs` has passed, whichever is first. Never rejects.\n *\n * @stability Beta\n */\nexport async function runBeforeReload(timeoutMs: number = BEFORE_RELOAD_TIMEOUT_MS): Promise<void> {\n const list = [...hooks()];\n if (list.length === 0) return;\n const settled = Promise.allSettled(\n list.map(async (hook) => {\n await hook(timeoutMs);\n }),\n );\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<void>((resolve) => {\n timer = setTimeout(resolve, timeoutMs);\n });\n try {\n await Promise.race([settled, deadline]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n"]}
|