@marktiderman/genesis-native 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +354 -10
  2. package/dist/block-C5-noMhB.d.ts +223 -0
  3. package/dist/blocks-a1YQ1Elf.d.ts +1540 -0
  4. package/dist/chunk-65P7RU4V.js +49 -0
  5. package/dist/chunk-65P7RU4V.js.map +1 -0
  6. package/dist/chunk-6BT4PTGH.js +37 -0
  7. package/dist/chunk-6BT4PTGH.js.map +1 -0
  8. package/dist/chunk-75YP72G6.js +374 -0
  9. package/dist/chunk-75YP72G6.js.map +1 -0
  10. package/dist/chunk-NGYNYJPL.js +90 -0
  11. package/dist/chunk-NGYNYJPL.js.map +1 -0
  12. package/dist/chunk-VKTIHNAV.js +95 -0
  13. package/dist/chunk-VKTIHNAV.js.map +1 -0
  14. package/dist/{chunk-MMTPWUWI.js → chunk-VTJDIKFC.js} +9 -6
  15. package/dist/chunk-VTJDIKFC.js.map +1 -0
  16. package/dist/chunk-XE7LC7K6.js +29 -0
  17. package/dist/chunk-XE7LC7K6.js.map +1 -0
  18. package/dist/dev-warnings.d.ts +34 -0
  19. package/dist/dev-warnings.js +15 -0
  20. package/dist/dev-warnings.js.map +1 -0
  21. package/dist/devtools.d.ts +144 -0
  22. package/dist/devtools.js +390 -0
  23. package/dist/devtools.js.map +1 -0
  24. package/dist/index.d.ts +12 -368
  25. package/dist/index.js +88 -191
  26. package/dist/index.js.map +1 -1
  27. package/dist/observability.d.ts +170 -0
  28. package/dist/observability.js +123 -0
  29. package/dist/observability.js.map +1 -0
  30. package/dist/persist.d.ts +1 -1
  31. package/dist/persist.js +1 -1
  32. package/dist/push.d.ts +169 -0
  33. package/dist/push.js +996 -0
  34. package/dist/push.js.map +1 -0
  35. package/dist/{query-DhH3lLFa.d.ts → query-DUmVAfsF.d.ts} +11 -6
  36. package/dist/updates.d.ts +8 -1
  37. package/dist/updates.js +44 -69
  38. package/dist/updates.js.map +1 -1
  39. package/package.json +222 -5
  40. package/src/app.tsx +491 -0
  41. package/src/auth.tsx +176 -0
  42. package/src/blocks.tsx +144 -0
  43. package/src/boot.tsx +188 -0
  44. package/src/dev-warnings.ts +43 -0
  45. package/src/devtools/block.tsx +488 -0
  46. package/src/devtools/gestures.ts +107 -0
  47. package/src/devtools/index.ts +22 -0
  48. package/src/devtools/info.ts +45 -0
  49. package/src/devtools/slots.ts +21 -0
  50. package/src/errors.tsx +195 -0
  51. package/src/held-link.ts +90 -0
  52. package/src/hydration-gate.ts +88 -0
  53. package/src/index.ts +83 -0
  54. package/src/links.ts +140 -0
  55. package/src/nativewind.d.ts +41 -0
  56. package/src/observability/block.tsx +300 -0
  57. package/src/observability/events.ts +89 -0
  58. package/src/observability/index.ts +44 -0
  59. package/src/observability/scrub.ts +166 -0
  60. package/src/observability/sentry.ts +222 -0
  61. package/src/observability/sink.ts +147 -0
  62. package/src/persist.ts +83 -0
  63. package/src/push/backend.ts +129 -0
  64. package/src/push/block.tsx +545 -0
  65. package/src/push/index.ts +102 -0
  66. package/src/push/modules.ts +111 -0
  67. package/src/push/permission.ts +191 -0
  68. package/src/push/preferences.ts +136 -0
  69. package/src/push/quiet-hours.ts +71 -0
  70. package/src/push/registration.ts +189 -0
  71. package/src/push/routing.ts +27 -0
  72. package/src/push/screens.tsx +46 -0
  73. package/src/push/settings.tsx +378 -0
  74. package/src/query.ts +100 -0
  75. package/src/updates/block.tsx +442 -0
  76. package/src/updates/channels.ts +131 -0
  77. package/src/updates/checker.ts +190 -0
  78. package/src/updates/index.ts +87 -0
  79. package/src/updates/modules.ts +64 -0
  80. package/src/updates/policy.ts +314 -0
  81. package/src/updates/screens.tsx +159 -0
  82. package/src/updates/signature.ts +80 -0
  83. package/src/updates/store.ts +33 -0
  84. package/src/updates/version.ts +39 -0
  85. package/src/updates/whats-new.ts +122 -0
  86. package/dist/block-Dh5ny06W.d.ts +0 -535
  87. package/dist/chunk-MMTPWUWI.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updates/store.ts","../src/updates/modules.ts","../src/updates/checker.ts","../src/updates/channels.ts","../src/updates/version.ts","../src/updates/policy.ts","../src/updates/signature.ts","../src/updates/whats-new.ts","../src/updates/screens.tsx","../src/updates/block.tsx"],"names":["jsx","jsxs","View"],"mappings":";;;;;;;;;;AAOO,SAAS,YAA8B,OAAA,EAAsB;AAClE,EAAA,IAAI,KAAA,GAAQ,OAAA;AACZ,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAgB;AACtC,EAAA,OAAO;AAAA,IACL,UAAU,MAAM,KAAA;AAAA,IAChB,SAAS,IAAA,EAAM;AACb,MAAA,MAAM,MAAA,GAAS,EAAE,GAAG,KAAA,EAAO,GAAG,IAAA,EAAK;AACnC,MAAA,IAAK,OAAO,IAAA,CAAK,MAAM,CAAA,CAAkB,KAAA,CAAM,CAAC,GAAA,KAAQ,MAAA,CAAO,EAAA,CAAG,MAAA,CAAO,GAAG,CAAA,EAAG,KAAA,CAAM,GAAG,CAAC,CAAC,CAAA,EAAG;AAC7F,MAAA,KAAA,GAAQ,MAAA;AACR,MAAA,KAAA,MAAW,QAAA,IAAY,CAAC,GAAG,SAAS,GAAG,QAAA,EAAS;AAAA,IAClD,CAAA;AAAA,IACA,UAAU,QAAA,EAAU;AAClB,MAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AACtB,MAAA,OAAO,MAAM;AACX,QAAA,SAAA,CAAU,OAAO,QAAQ,CAAA;AAAA,MAC3B,CAAA;AAAA,IACF;AAAA,GACF;AACF;AAGO,SAAS,MAAM,EAAA,EAA2B;AAC/C,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC9B,IAAA,IAAI,MAAA,CAAO,QAAA,CAAS,EAAE,CAAA,EAAG,UAAA,CAAW,SAAS,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,EAAE,CAAC,CAAA;AAAA,EAC9D,CAAC,CAAA;A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CAAW,YAAA,EAAc,OAAO,YAAA,EAAc,MAAA,EAAQ,SAAA,EAAW,YAAY,CAAA,GAAI,IAAA;AAAA,IACvG,CAAC,QAAA,IAAY,QAAA,GAAW,UAAA,CAAW,aAAA,EAAe,OAAO,QAAA,EAAU,QAAA,EAAU,SAAA,EAAW,QAAQ,CAAA,GAAI,IAAA;AAAA,IACpG,QAAA,mBACCF,GAAAA,CAACE,IAAAA,EAAA,EAAK,OAAO,IAAA,EAAM,MAAA,EAAO,0BAAA,EACvB,QAAA,EAAA,QAAA,EACH,CAAA,GACE;AAAA,GAAA,EACN,CAAA;AAEJ","file":"updates.js","sourcesContent":["/** A tiny external store for `useSyncExternalStore`: immutable state, one notify per change. */\nexport interface Store<T> {\n getState(): T;\n setState(next: Partial<T>): void;\n subscribe(listener: () => void): () => void;\n}\n\nexport function createStore<T extends object>(initial: T): Store<T> {\n let state = initial;\n const listeners = new Set<() => void>();\n return {\n getState: () => state,\n setState(next) {\n const merged = { ...state, ...next };\n if ((Object.keys(merged) as (keyof T)[]).every((key) => Object.is(merged[key], state[key]))) return;\n state = merged;\n for (const listener of [...listeners]) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** Resolves after `ms`, or never when `ms` is not finite. */\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => {\n if (Number.isFinite(ms)) setTimeout(resolve, Math.max(0, ms));\n });\n}\n","/**\n * The native modules the updates block reads, as the shapes it needs. Pass\n * the real ones (`import * as Updates from \"expo-updates\"`,\n * `import * as Application from \"expo-application\"`); tests pass fakes.\n * Both are optional peers: without `expo-updates` there is no update banner\n * and no channel switching, and without `expo-application` no force upgrade.\n */\n\n/** `expo-updates` (SDK 58): the constants and calls this block uses. */\nexport interface UpdatesModuleLike {\n /** False in development, Expo Go, or a build without updates configured. */\n readonly isEnabled: boolean;\n /** The running update's id; `null` when updates are off. */\n readonly updateId: string | null;\n /** The build's channel; `null` in development builds and Expo Go. */\n readonly channel: string | null;\n readonly runtimeVersion: string | null;\n /** True when the code that shipped in the binary is running, not a downloaded update. */\n readonly isEmbeddedLaunch: boolean;\n /** True when expo-updates fell back to the embedded update after a failed launch. */\n readonly isEmergencyLaunch?: boolean;\n readonly emergencyLaunchReason?: string | null;\n checkForUpdateAsync(): Promise<{ isAvailable: boolean; isRollBackToEmbedded?: boolean; manifest?: unknown }>;\n fetchUpdateAsync(): Promise<{ isNew: boolean; isRollBackToEmbedded?: boolean; manifest?: unknown }>;\n reloadAsync(options?: { reloadScreenOptions?: object }): Promise<void>;\n /** Overrides the `expo-channel-name` header (persists on the device); `null` removes the override. */\n setUpdateRequestHeadersOverride?(requestHeaders: Record<string, string> | null): void;\n}\n\n/** `expo-application`: the installed store version and build number. */\nexport interface ApplicationLike {\n /** `CFBundleShortVersionString` / `versionName`, e.g. `\"1.4.0\"`. */\n readonly nativeApplicationVersion: string | null;\n /** `CFBundleVersion` / `versionCode`, e.g. `\"37\"`. */\n readonly nativeBuildVersion: string | null;\n}\n\n/** AsyncStorage, MMKV's async adapter, or a stand-in. */\nexport interface UpdatesStorageLike {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem?(key: string): Promise<void>;\n}\n\n/** React Native's `AppState`. */\nexport interface UpdatesAppStateLike {\n addEventListener(type: \"change\", listener: (state: string) => void): { remove(): void };\n}\n\n/** Where a reported error came from. */\nexport type UpdatesErrorSource = \"policy\" | \"check\" | \"reload\" | \"storage\" | \"channel\";\n\nexport type UpdatesOnError = (error: Error, source: UpdatesErrorSource) => void;\n\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/** The `id` (and `runtimeVersion`) of an update manifest, when it has them. */\nexport function manifestField(manifest: unknown, field: \"id\" | \"runtimeVersion\"): string | null {\n if (!manifest || typeof manifest !== \"object\") return null;\n const value = (manifest as Record<string, unknown>)[field];\n return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n","/**\n * The update banner's engine: ask expo-updates for a newer update, download\n * it, and reload only when the person taps and nothing is mid-edit.\n *\n * - It never reloads on its own. A downloaded update also applies on the next\n * cold start, so dismissing the banner loses nothing.\n * - The reload guard says no while any `useBlockReload(true)` is mounted (a\n * form with unsaved changes) or your `canReload()` returns false (or\n * throws). The banner then asks the person to finish first.\n * - expo-updates only serves updates built for this binary's runtime\n * version; an update whose manifest names another runtime is ignored too.\n */\nimport { createStore, type Store } from \"./store\";\nimport { manifestField, toError, type UpdatesModuleLike, type UpdatesOnError } from \"./modules\";\n\nexport interface ReloadGuard {\n /** Hold reloads off until the returned function is called. */\n block(): () => void;\n /** True when nothing blocks and your `canReload` agrees. */\n canReload(): boolean;\n /** Fires when a block starts or ends. */\n subscribe(listener: () => void): () => void;\n}\n\nexport function createReloadGuard(canReload?: () => boolean): ReloadGuard {\n let blockers = 0;\n const listeners = new Set<() => void>();\n const notify = () => {\n for (const listener of [...listeners]) listener();\n };\n return {\n block() {\n blockers++;\n notify();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n blockers--;\n notify();\n };\n },\n canReload() {\n if (blockers > 0) return false;\n try {\n return canReload ? canReload() === true : true;\n } catch {\n return false; // When in doubt, don't throw away someone's work.\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\nexport type UpdateCheckStatus = \"disabled\" | \"idle\" | \"checking\" | \"downloading\" | \"ready\" | \"reloading\" | \"error\";\n\nexport interface UpdateCheckState {\n status: UpdateCheckStatus;\n /** The downloaded update's id, when the manifest has one. */\n updateId: string | null;\n /** The person closed the banner; the update still applies on the next cold start. */\n dismissed: boolean;\n /** The last tap was refused by the reload guard; cleared when the guard opens. */\n blocked: boolean;\n error: Error | null;\n}\n\nexport interface UpdateCheckerOptions {\n updates?: UpdatesModuleLike;\n guard: ReloadGuard;\n /** Passed to `reloadAsync` (a branded reload screen). */\n reloadScreenOptions?: object;\n now?: () => number;\n onError?: UpdatesOnError;\n}\n\nexport interface UpdateChecker extends Pick<Store<UpdateCheckState>, \"getState\" | \"subscribe\"> {\n /** Check and download. Never rejects; does nothing while one is in flight or an update is ready. */\n check(): Promise<void>;\n /** `check()` unless the last one started less than `minIntervalMs` ago. */\n checkIfDue(minIntervalMs: number): Promise<void>;\n /** Reload into the downloaded update. Resolves false when there is none or the guard refuses. */\n reload(): Promise<boolean>;\n dismiss(): void;\n /** Stop following the guard. */\n dispose(): void;\n}\n\nexport function createUpdateChecker(options: UpdateCheckerOptions): UpdateChecker {\n const { updates, guard, reloadScreenOptions, now = Date.now, onError } = options;\n const enabled = Boolean(updates?.isEnabled);\n const store = createStore<UpdateCheckState>({\n status: enabled ? \"idle\" : \"disabled\",\n updateId: null,\n dismissed: false,\n blocked: false,\n error: null,\n });\n let inflight: Promise<void> | null = null;\n let lastCheck: number | null = null;\n const report = (error: Error, from: \"check\" | \"reload\") => {\n try {\n onError?.(error, from);\n } catch {\n // ignore a failing reporter\n }\n };\n const stopGuard = guard.subscribe(() => {\n if (store.getState().blocked && guard.canReload()) store.setState({ blocked: false });\n });\n\n const check = (): Promise<void> => {\n if (!updates || !enabled) return Promise.resolve();\n const { status } = store.getState();\n if (inflight || status === \"ready\" || status === \"reloading\") return inflight ?? Promise.resolve();\n lastCheck = now();\n // eslint-disable-next-line prefer-const -- read in `finally`, after the assignment below\n let run!: Promise<void>;\n run = (async () => {\n // Never settle synchronously (a module that throws before its first await).\n await null;\n try {\n store.setState({ status: \"checking\", error: null });\n const result = await updates.checkForUpdateAsync();\n if (!result.isAvailable && !result.isRollBackToEmbedded) {\n store.setState({ status: \"idle\" });\n return;\n }\n const runtime = manifestField(result.manifest, \"runtimeVersion\");\n if (runtime && updates.runtimeVersion && runtime !== updates.runtimeVersion) {\n store.setState({ status: \"idle\" });\n return;\n }\n store.setState({ status: \"downloading\" });\n const fetched = await updates.fetchUpdateAsync();\n const updateId = manifestField(fetched.manifest, \"id\") ?? manifestField(result.manifest, \"id\");\n if ((fetched.isNew || fetched.isRollBackToEmbedded) && !(updateId && updateId === updates.updateId)) {\n store.setState({ status: \"ready\", updateId, dismissed: false });\n } else {\n store.setState({ status: \"idle\" });\n }\n } catch (raw) {\n const error = toError(raw);\n report(error, \"check\");\n store.setState({ status: \"error\", error });\n } finally {\n if (inflight === run) inflight = null;\n }\n })();\n inflight = run;\n return run;\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n check,\n checkIfDue(minIntervalMs) {\n const at = now();\n if (lastCheck !== null && at >= lastCheck && at - lastCheck < minIntervalMs) return Promise.resolve();\n return check();\n },\n async reload() {\n if (!updates || store.getState().status !== \"ready\") return false;\n if (!guard.canReload()) {\n store.setState({ blocked: true });\n return false;\n }\n store.setState({ status: \"reloading\", blocked: false });\n try {\n await updates.reloadAsync(reloadScreenOptions ? { reloadScreenOptions } : undefined);\n return true;\n } catch (raw) {\n const error = toError(raw);\n report(error, \"reload\");\n store.setState({ status: \"ready\", error });\n return false;\n }\n },\n dismiss() {\n store.setState({ dismissed: true, blocked: false });\n },\n dispose: stopGuard,\n };\n}\n","/**\n * Switching a test build to another update channel (EAS \"channel surfing\"):\n * override the `expo-channel-name` header, check, fetch, reload. The\n * override persists on the device until it is reset or the app is removed.\n *\n * Off unless you turn it on, and turn it on only in development and preview\n * builds (`enabled: __DEV__ || isPreviewBuild`): a store build that can be\n * pointed at any channel can be pointed at an unreviewed one. Going back\n * (`reset`) always works, for everyone, because it only removes the\n * override.\n *\n * Switching reloads, so it respects the reload guard: with unsaved changes\n * it sets the channel and says `blocked`; the channel applies on the next\n * launch.\n */\nimport { toError, type UpdatesModuleLike, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\nimport type { ReloadGuard } from \"./checker\";\n\nexport type ChannelSwitchResult =\n /** The reload was sent; JS may stop at any moment. */\n | { kind: \"reloading\" }\n /** The channel is set, but something is mid-edit: it applies on the next launch. */\n | { kind: \"blocked\" }\n /** expo-updates is off or too old here (development, Expo Go). Nothing changed. */\n | { kind: \"unavailable\"; reason: string }\n /** The channel is set but checking, fetching or reloading failed. */\n | { kind: \"error\"; error: Error };\n\nexport interface ChannelSwitcher {\n /** True when this build may switch channels (`channels.enabled`). */\n readonly enabled: boolean;\n /** Switch to `channel` and reload. Throws when switching is off. */\n switchTo(channel: string): Promise<ChannelSwitchResult>;\n /** Back to the build's own channel. Always allowed. */\n reset(): Promise<ChannelSwitchResult>;\n /** The channel picked on this device, or `null` when it follows the build. */\n requested(): Promise<string | null>;\n}\n\nexport interface ChannelSwitcherOptions {\n updates?: UpdatesModuleLike;\n /** Must be explicitly true (development and preview builds only). */\n enabled: boolean;\n guard: ReloadGuard;\n /** Remembers the picked channel, for the version signature. */\n storage?: UpdatesStorageLike;\n /** Default `\"genesis:updates:channel\"`. */\n storageKey?: string;\n reloadScreenOptions?: object;\n onError?: UpdatesOnError;\n}\n\nconst CHANNEL = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,99}$/;\n\nexport function createChannelSwitcher(options: ChannelSwitcherOptions): ChannelSwitcher {\n const { updates, enabled, guard, storage, storageKey = \"genesis:updates:channel\", reloadScreenOptions, onError } = options;\n const report = (error: Error) => {\n try {\n onError?.(error, \"channel\");\n } catch {\n // ignore a failing reporter\n }\n };\n const unavailable = (): ChannelSwitchResult | null => {\n if (!updates?.isEnabled) return { kind: \"unavailable\", reason: \"Updates are off in this build (development or Expo Go).\" };\n if (typeof updates.setUpdateRequestHeadersOverride !== \"function\") {\n return { kind: \"unavailable\", reason: \"This expo-updates can't override the channel.\" };\n }\n return null;\n };\n const save = async (channel: string | null) => {\n if (!storage) return;\n try {\n if (channel === null) await (storage.removeItem ? storage.removeItem(storageKey) : storage.setItem(storageKey, \"\"));\n else await storage.setItem(storageKey, channel);\n } catch (error) {\n report(toError(error));\n }\n };\n const apply = async (): Promise<ChannelSwitchResult> => {\n const u = updates as UpdatesModuleLike;\n try {\n const check = await u.checkForUpdateAsync();\n if (check.isAvailable || check.isRollBackToEmbedded) await u.fetchUpdateAsync();\n if (!guard.canReload()) return { kind: \"blocked\" };\n await u.reloadAsync(reloadScreenOptions ? { reloadScreenOptions } : undefined);\n return { kind: \"reloading\" };\n } catch (raw) {\n const error = toError(raw);\n report(error);\n return { kind: \"error\", error };\n }\n };\n\n return {\n enabled,\n async switchTo(channel) {\n if (enabled !== true) {\n throw new Error(\"Channel switching is off. Pass `channels: { enabled: true }` only in development and preview builds.\");\n }\n const name = channel.trim();\n if (!CHANNEL.test(name)) throw new Error(`Not a channel name: \"${channel}\"`);\n const off = unavailable();\n if (off) return off;\n updates!.setUpdateRequestHeadersOverride!({ \"expo-channel-name\": name });\n await save(name === updates!.channel ? null : name);\n return apply();\n },\n async reset() {\n const off = unavailable();\n if (off) {\n await save(null);\n return off;\n }\n // Clearing the override is the part that must happen; a failed check or reload is reported, not a reason to stay.\n updates!.setUpdateRequestHeadersOverride!(null);\n await save(null);\n return apply();\n },\n async requested() {\n if (!storage) return null;\n try {\n const value = await storage.getItem(storageKey);\n return value ? value : null;\n } catch (error) {\n report(toError(error));\n return null;\n }\n },\n };\n}\n","/**\n * Version numbers: the store version an app reports (`1.4.0`, `1.10`) and\n * the minimum a policy sets. Only plain dotted numbers count (one to four\n * parts, as App Store Connect and Play accept). Anything else (`1.2-beta`,\n * `latest`, an empty string, a number too large to compare exactly) does not\n * parse, and a comparison with it has no answer (`null`), so a malformed\n * minimum can never block anyone.\n */\n\nconst VERSION = /^\\d+(?:\\.\\d+){0,3}$/;\n\n/** `\"1.10\"` → `[1, 10, 0, 0]`; `null` when it isn't a plain dotted version. */\nexport function parseVersion(value: unknown): number[] | null {\n if (typeof value !== \"string\") return null;\n const text = value.trim();\n if (!VERSION.test(text)) return null;\n const parts = text.split(\".\").map(Number);\n if (parts.some((part) => !Number.isSafeInteger(part))) return null;\n while (parts.length < 4) parts.push(0);\n return parts;\n}\n\n/** -1, 0 or 1 as `a` is older than, the same as or newer than `b`; `null` when either doesn't parse. */\nexport function compareVersions(a: unknown, b: unknown): -1 | 0 | 1 | null {\n const left = parseVersion(a);\n const right = parseVersion(b);\n if (!left || !right) return null;\n for (let i = 0; i < 4; i++) {\n const l = left[i] ?? 0;\n const r = right[i] ?? 0;\n if (l !== r) return l < r ? -1 : 1;\n }\n return 0;\n}\n\n/** True only when both parse and `installed` is older than `minimum`. Fails open. */\nexport function isBelowMinimum(installed: unknown, minimum: unknown): boolean {\n return compareVersions(installed, minimum) === -1;\n}\n","/**\n * The release policy: the oldest store version each platform may run, a\n * maintenance switch, and release notes. It comes from an\n * `UpdatePolicySource` (a static object, Supabase, or your own), is cached on\n * the phone, and **fails open**: no answer, a timeout, a malformed value or\n * an untrusted cache never blocks anyone.\n *\n * What may block, and from where:\n * - Force upgrade: a policy fetched this session, or a cached one no older\n * than `cacheMaxAgeMs` (7 days) by the phone's clock. A cache whose time is\n * in the future (the clock moved back) is not trusted. A minimum without a\n * store link for the platform forces nothing (there would be no way out).\n * - Maintenance: only a policy fetched from the network this session. A\n * cached maintenance flag never blocks a cold start.\n */\nimport { createStore, delay, type Store } from \"./store\";\nimport { isBelowMinimum } from \"./version\";\nimport { toError, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\n\nexport type UpdatePlatform = \"ios\" | \"android\";\n\nexport interface ReleaseNote {\n /** The store version these notes describe, e.g. `\"1.4.0\"`. */\n version: string;\n title?: string;\n body: string;\n}\n\nexport interface UpdatePolicy {\n /** The oldest store version still supported, per platform. Missing or malformed: no minimum. */\n minimumVersion?: Partial<Record<UpdatePlatform, string>>;\n /** Where \"Update\" goes (`https://apps.apple.com/…`, `itms-apps://…`, `market://…`, `https://play.google.com/…`). */\n storeUrl?: Partial<Record<UpdatePlatform, string>>;\n maintenance?: { active: boolean; message: string | null };\n notes?: readonly ReleaseNote[];\n}\n\n/** Where the policy comes from. `load` throws (or rejects) when it can't answer; resolving `null` means \"no policy\". */\nexport interface UpdatePolicySource {\n load(): Promise<UpdatePolicy | null | undefined>;\n}\n\n/** A policy written in the app (or a test). */\nexport function staticPolicySource(policy: UpdatePolicy): UpdatePolicySource {\n return { load: async () => policy };\n}\n\n/** A Supabase client: anything with `from(table)` (a real `SupabaseClient` fits without a cast). */\nexport interface PolicyClientLike {\n from(table: string): unknown;\n}\n\ninterface PolicyQuery {\n select(columns: string): { eq(column: string, value: string): { maybeSingle(): PromiseLike<{ data: unknown; error: unknown }> } };\n}\n\nexport interface SupabasePolicySourceOptions {\n /** The `app_id` row to read. Default `\"default\"`. */\n appId?: string;\n /** Default `\"app_release_policy\"` (migration `0002_genesis_app_release_policy.sql` in `@marktiderman/genesis-supabase`). */\n table?: string;\n}\n\nconst COLUMNS = \"min_version_ios,min_version_android,store_url_ios,store_url_android,maintenance,maintenance_message,notes\";\n\n/**\n * Reads one row of `public.app_release_policy` (readable by anon and\n * authenticated, written only with the service role). No row is no policy.\n */\nexport function supabasePolicySource(client: PolicyClientLike, options: SupabasePolicySourceOptions = {}): UpdatePolicySource {\n const { appId = \"default\", table = \"app_release_policy\" } = options;\n return {\n async load() {\n const query = client.from(table) as PolicyQuery;\n const { data, error } = await query.select(COLUMNS).eq(\"app_id\", appId).maybeSingle();\n if (error) throw toError(error instanceof Error ? error : (error as { message?: unknown }).message ?? error);\n if (!data || typeof data !== \"object\") return {};\n const row = data as Record<string, unknown>;\n return {\n minimumVersion: pick({ ios: row.min_version_ios, android: row.min_version_android }),\n storeUrl: pick({ ios: row.store_url_ios, android: row.store_url_android }),\n maintenance: { active: row.maintenance === true, message: typeof row.maintenance_message === \"string\" ? row.maintenance_message : null },\n notes: Array.isArray(row.notes) ? (row.notes as ReleaseNote[]) : [],\n };\n },\n };\n}\n\nfunction pick(values: Record<UpdatePlatform, unknown>): Partial<Record<UpdatePlatform, string>> {\n const out: Partial<Record<UpdatePlatform, string>> = {};\n for (const platform of [\"ios\", \"android\"] as const) {\n const value = values[platform];\n if (typeof value === \"string\" && value.trim() !== \"\") out[platform] = value.trim();\n }\n return out;\n}\n\nconst STORE_URL = /^(https:\\/\\/|itms-apps:\\/\\/|market:\\/\\/)/i;\n\n/** Keeps only well-formed fields; throws when `raw` isn't an object at all (so the cache answers instead). */\nexport function sanitizePolicy(raw: unknown): UpdatePolicy {\n if (raw === null || raw === undefined) return {};\n if (typeof raw !== \"object\" || Array.isArray(raw)) throw new Error(\"The release policy is not an object\");\n const value = raw as Record<string, unknown>;\n const policy: UpdatePolicy = {};\n const minimum = value.minimumVersion && typeof value.minimumVersion === \"object\" ? (value.minimumVersion as Record<UpdatePlatform, unknown>) : null;\n if (minimum) policy.minimumVersion = pick(minimum);\n const store = value.storeUrl && typeof value.storeUrl === \"object\" ? pick(value.storeUrl as Record<UpdatePlatform, unknown>) : null;\n if (store) {\n for (const platform of [\"ios\", \"android\"] as const) if (store[platform] && !STORE_URL.test(store[platform])) delete store[platform];\n policy.storeUrl = store;\n }\n const maintenance = value.maintenance as { active?: unknown; message?: unknown } | null | undefined;\n if (maintenance && typeof maintenance === \"object\") {\n policy.maintenance = {\n active: maintenance.active === true,\n message: typeof maintenance.message === \"string\" && maintenance.message.trim() !== \"\" ? maintenance.message : null,\n };\n }\n if (Array.isArray(value.notes)) {\n policy.notes = value.notes.flatMap((note): ReleaseNote[] => {\n if (!note || typeof note !== \"object\") return [];\n const { version, title, body } = note as Record<string, unknown>;\n if (typeof version !== \"string\" || typeof body !== \"string\") return [];\n return [{ version: version.trim(), body, ...(typeof title === \"string\" ? { title } : {}) }];\n });\n }\n return policy;\n}\n\nexport type PolicyOrigin = \"network\" | \"cache\" | \"none\";\n\nexport interface PolicyState {\n /** `loading` until the first answer (or the timeout); then `ready`, with or without a policy. */\n status: \"loading\" | \"ready\";\n policy: UpdatePolicy | null;\n /** `network`: fetched this session. `cache`: read from the phone. `none`: no answer yet (fail open). */\n origin: PolicyOrigin;\n /** When it was fetched, by the phone's clock (ms). */\n fetchedAt: number | null;\n /** The last failed fetch, if the most recent one failed. */\n error: Error | null;\n /** A fetch is in flight. */\n refreshing: boolean;\n}\n\nexport interface PolicyStoreOptions {\n source: UpdatePolicySource;\n storage?: UpdatesStorageLike;\n /** Default `\"genesis:updates:policy\"`. */\n cacheKey?: string;\n /** The longest `load()` waits before carrying on without an answer. Default 3000 ms. */\n timeoutMs?: number;\n now?: () => number;\n onError?: UpdatesOnError;\n}\n\nexport interface PolicyStore extends Pick<Store<PolicyState>, \"getState\" | \"subscribe\"> {\n /** The first load: the cache and the network together, for at most `timeoutMs`. Never rejects; runs once. */\n load(): Promise<void>;\n /** Fetch again (maintenance \"Try again\", the app coming to the front). Never rejects; resolves true on an answer. */\n refresh(): Promise<boolean>;\n /** `refresh()` unless one ran less than `minIntervalMs` ago. */\n refreshIfDue(minIntervalMs: number): Promise<boolean>;\n}\n\ninterface CacheEntry {\n v: 1;\n savedAt: number;\n policy: UpdatePolicy;\n}\n\nexport function createPolicyStore(options: PolicyStoreOptions): PolicyStore {\n const { source, storage, cacheKey = \"genesis:updates:policy\", now = Date.now, onError } = options;\n const timeoutMs = validTimeout(options.timeoutMs, 3000);\n const store = createStore<PolicyState>({ status: \"loading\", policy: null, origin: \"none\", fetchedAt: null, error: null, refreshing: false });\n let inflight: Promise<boolean> | null = null;\n let firstLoad: Promise<void> | null = null;\n let lastAttempt: number | null = null;\n const report = (error: unknown, from: \"policy\" | \"storage\") => {\n try {\n onError?.(toError(error), from);\n } catch {\n // A failing reporter must not change the answer.\n }\n };\n\n const fetchNetwork = (): Promise<boolean> => {\n if (inflight) return inflight;\n lastAttempt = now();\n store.setState({ refreshing: true });\n // eslint-disable-next-line prefer-const -- read in `finally`, after the assignment below\n let run!: Promise<boolean>;\n run = (async () => {\n // Never settle synchronously: a source that throws before its first await must not leave a settled `inflight` behind.\n await null;\n try {\n const policy = sanitizePolicy(await source.load());\n const fetchedAt = now();\n store.setState({ status: \"ready\", policy, origin: \"network\", fetchedAt, error: null });\n if (storage) {\n const entry: CacheEntry = { v: 1, savedAt: fetchedAt, policy };\n Promise.resolve()\n .then(() => storage.setItem(cacheKey, JSON.stringify(entry)))\n .catch((error) => report(error, \"storage\"));\n }\n return true;\n } catch (error) {\n report(error, \"policy\");\n // A network answer from earlier this session stays; the cache (if any) was already applied.\n store.setState({ error: toError(error) });\n return false;\n } finally {\n if (inflight === run) inflight = null;\n store.setState({ refreshing: false });\n }\n })();\n inflight = run;\n return run;\n };\n\n const readCache = async () => {\n if (!storage) return;\n try {\n const entry = parseCache(await storage.getItem(cacheKey));\n if (entry && store.getState().origin !== \"network\") {\n store.setState({ policy: entry.policy, origin: \"cache\", fetchedAt: entry.savedAt });\n }\n } catch (error) {\n report(error, \"storage\");\n }\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n load() {\n firstLoad ??= (async () => {\n const cache = readCache();\n const network = fetchNetwork();\n const answered = network.then(async (ok) => {\n if (!ok) await cache;\n });\n await Promise.race([answered, delay(timeoutMs)]);\n store.setState({ status: \"ready\" });\n })();\n return firstLoad;\n },\n refresh: fetchNetwork,\n refreshIfDue(minIntervalMs) {\n const at = now();\n // A clock that moved back makes the last attempt look in the future: refresh.\n if (lastAttempt !== null && at >= lastAttempt && at - lastAttempt < minIntervalMs) return Promise.resolve(false);\n return fetchNetwork();\n },\n };\n}\n\n/** A finite, non-negative timeout, or `fallback` (a NaN or Infinity would wait forever). */\nexport function validTimeout(value: number | undefined, fallback: number): number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\nfunction parseCache(raw: string | null): CacheEntry | null {\n if (!raw) return null;\n try {\n const entry = JSON.parse(raw) as Partial<CacheEntry>;\n if (entry?.v !== 1 || typeof entry.savedAt !== \"number\" || !Number.isFinite(entry.savedAt)) return null;\n return { v: 1, savedAt: entry.savedAt, policy: sanitizePolicy(entry.policy) };\n } catch {\n return null;\n }\n}\n\n/** What the policy says this install must do. */\nexport type UpdateVerdict =\n | { kind: \"ok\" }\n | { kind: \"forceUpgrade\"; minimumVersion: string; installedVersion: string; storeUrl: string }\n | { kind: \"maintenance\"; message: string | null };\n\nexport interface EvaluatePolicyOptions {\n /** `Platform.OS`. Only `ios` and `android` can be forced to upgrade. */\n platform: string;\n /** The installed store version (`Application.nativeApplicationVersion`). `null`: never forced. */\n installedVersion: string | null;\n now: number;\n /** How old a cached policy may be and still force an upgrade. Default 7 days. */\n cacheMaxAgeMs?: number;\n}\n\n/** How far in the future a cache's time may be (clocks drift) before it isn't trusted. */\nexport const CLOCK_SKEW_MS = 5 * 60_000;\nexport const WEEK_MS = 7 * 24 * 60 * 60_000;\n\n/** Force upgrade first (the store is the way out), then maintenance, else ok. Fails open. */\nexport function evaluatePolicy(state: PolicyState, options: EvaluatePolicyOptions): UpdateVerdict {\n const { policy, origin, fetchedAt } = state;\n if (!policy) return { kind: \"ok\" };\n const { platform, installedVersion, now, cacheMaxAgeMs = WEEK_MS } = options;\n const age = fetchedAt === null ? null : now - fetchedAt;\n const trusted = origin === \"network\" || (origin === \"cache\" && age !== null && age >= -CLOCK_SKEW_MS && age <= cacheMaxAgeMs);\n if (trusted && (platform === \"ios\" || platform === \"android\")) {\n const minimum = policy.minimumVersion?.[platform];\n const storeUrl = policy.storeUrl?.[platform];\n // Without a store link there is no way out of the screen, so no store link means no force upgrade.\n if (minimum && storeUrl && installedVersion && isBelowMinimum(installedVersion, minimum)) {\n return { kind: \"forceUpgrade\", minimumVersion: minimum.trim(), installedVersion, storeUrl };\n }\n }\n if (origin === \"network\" && policy.maintenance?.active === true) {\n return { kind: \"maintenance\", message: policy.maintenance.message };\n }\n return { kind: \"ok\" };\n}\n","/**\n * The version signature: which binary and which update this is, in one\n * line for Settings \"About\" and in a few lines for a support report.\n *\n * 1.4.0 (37) · preview · 3f2a9c1b\n * 1.4.0 (37) · production · embedded\n * 1.4.0 (37) · updates off\n *\n * A value the modules can't give is printed as `unknown`, never left out.\n */\nimport type { ApplicationLike, UpdatesModuleLike } from \"./modules\";\n\nexport interface VersionSignature {\n version: string | null;\n build: string | null;\n platform: string;\n /** The build's channel (expo-updates). */\n channel: string | null;\n /** A channel picked on this device (a test build switched channels); `null` when it follows the build. */\n requestedChannel: string | null;\n runtimeVersion: string | null;\n updateId: string | null;\n /** `update`: a downloaded update runs. `embedded`: the binary's own code. `off`: updates are off (development, Expo Go). */\n launch: \"update\" | \"embedded\" | \"off\";\n /** expo-updates fell back to the embedded code after a failed launch. */\n emergency: boolean;\n /** One line, for an About row. */\n short: string;\n /** Several lines, for a support report. */\n text: string;\n}\n\nexport interface VersionSignatureInput {\n application?: ApplicationLike;\n updates?: UpdatesModuleLike;\n /** `Platform.OS`. */\n platform: string;\n requestedChannel?: string | null;\n}\n\nconst UNKNOWN = \"unknown\";\n\nexport function versionSignature({ application, updates, platform, requestedChannel = null }: VersionSignatureInput): VersionSignature {\n const version = application?.nativeApplicationVersion ?? null;\n const build = application?.nativeBuildVersion ?? null;\n const on = Boolean(updates?.isEnabled);\n const channel = on ? (updates?.channel ?? null) : null;\n const updateId = on ? (updates?.updateId ?? null) : null;\n const runtimeVersion = updates?.runtimeVersion ?? null;\n const launch: VersionSignature[\"launch\"] = !on ? \"off\" : updates?.isEmbeddedLaunch ? \"embedded\" : \"update\";\n const emergency = on && updates?.isEmergencyLaunch === true;\n const shownChannel = requestedChannel ?? channel;\n\n const head = `${version ?? UNKNOWN} (${build ?? UNKNOWN})`;\n const parts = [head];\n if (launch === \"off\") {\n parts.push(\"updates off\");\n } else {\n parts.push(shownChannel ?? \"no channel\");\n parts.push(launch === \"embedded\" ? \"embedded\" : (updateId?.slice(0, 8) ?? UNKNOWN));\n }\n if (emergency) parts.push(\"emergency launch\");\n const short = parts.join(\" · \");\n\n const lines = [\n `Version ${head}`,\n `Platform ${platform}`,\n `Channel ${channel ?? (on ? UNKNOWN : \"none\")}${requestedChannel && requestedChannel !== channel ? ` (switched to ${requestedChannel})` : \"\"}`,\n `Runtime ${runtimeVersion ?? UNKNOWN}`,\n `Update ${launch === \"off\" ? \"updates off\" : launch === \"embedded\" ? \"embedded\" : (updateId ?? UNKNOWN)}`,\n ];\n if (emergency) lines.push(`Emergency launch: ${updates?.emergencyLaunchReason ?? UNKNOWN}`);\n return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, short, text: lines.join(\"\\n\") };\n}\n","/**\n * What's new: release notes shown once per version, remembered in storage.\n *\n * - First launch after an install (nothing stored): nothing shows; the\n * version is remembered, so a new install never opens on a sheet.\n * - A newer version than the one remembered: the notes for every version\n * after it, up to this one, newest first. Closing them remembers this\n * version. With no notes for it, the version is remembered once the policy\n * has answered from the network (or there is no policy source), so notes\n * that arrive late still show.\n * - Storage that can't be read shows nothing (rather than every launch).\n */\nimport { createStore, type Store } from \"./store\";\nimport { compareVersions } from \"./version\";\nimport { toError, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\nimport type { ReleaseNote } from \"./policy\";\n\nexport interface WhatsNewState {\n status: \"loading\" | \"hidden\" | \"showing\";\n notes: readonly ReleaseNote[];\n}\n\nexport interface WhatsNewOptions {\n storage?: UpdatesStorageLike;\n /** The installed version notes are matched against. `null`: never shows. */\n version: string | null;\n /** Default `\"genesis:updates:seen-version\"`. */\n storageKey?: string;\n onError?: UpdatesOnError;\n}\n\nexport interface WhatsNewStore extends Pick<Store<WhatsNewState>, \"getState\" | \"subscribe\"> {\n /** Read the remembered version. Never rejects; runs once. */\n load(): Promise<void>;\n /** Recompute with the notes known now; `final` once no more notes can arrive. */\n update(notes: readonly ReleaseNote[], final: boolean): void;\n /** Close the notes and remember this version. */\n dismiss(): void;\n}\n\n/** The notes after `seen`, up to `version`, newest first. */\nexport function notesSince(notes: readonly ReleaseNote[], seen: string, version: string): ReleaseNote[] {\n return notes\n .filter((note) => {\n if (note.version === version) return seen !== version;\n const afterSeen = compareVersions(note.version, seen);\n const upToNow = compareVersions(note.version, version);\n return afterSeen === 1 && (upToNow === -1 || upToNow === 0);\n })\n .sort((a, b) => compareVersions(b.version, a.version) ?? 0);\n}\n\nexport function createWhatsNewStore(options: WhatsNewOptions): WhatsNewStore {\n const { storage, version, storageKey = \"genesis:updates:seen-version\", onError } = options;\n const store = createStore<WhatsNewState>({ status: \"loading\", notes: [] });\n // undefined: not read yet; null: nothing stored (a fresh install); false: unreadable.\n let seen: string | null | false | undefined;\n let loading: Promise<void> | null = null;\n let pending: { notes: readonly ReleaseNote[]; final: boolean } | null = null;\n\n const remember = () => {\n if (!storage || !version) return;\n seen = version;\n Promise.resolve()\n .then(() => storage.setItem(storageKey, version))\n .catch((error) => {\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n });\n };\n\n const compute = (notes: readonly ReleaseNote[], final: boolean) => {\n if (seen === undefined) {\n pending = { notes, final };\n return;\n }\n if (!version || seen === false) return store.setState({ status: \"hidden\", notes: [] });\n if (seen === null) {\n remember();\n return store.setState({ status: \"hidden\", notes: [] });\n }\n const due = notesSince(notes, seen, version);\n if (due.length > 0) return store.setState({ status: \"showing\", notes: due });\n if (final && seen !== version) remember();\n store.setState({ status: \"hidden\", notes: [] });\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n load() {\n loading ??= (async () => {\n if (!storage || !version) {\n seen = false;\n } else {\n try {\n seen = await storage.getItem(storageKey);\n } catch (error) {\n seen = false;\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n }\n }\n const next = pending ?? { notes: [], final: false };\n pending = null;\n compute(next.notes, next.final);\n })();\n return loading;\n },\n update: compute,\n dismiss() {\n remember();\n store.setState({ status: \"hidden\", notes: [] });\n },\n };\n}\n","/**\n * The default renderers, built from `@marktiderman/genesis-ui-native`. Each\n * is the default of one slot (`forceUpgrade`, `maintenance`, `updateBanner`,\n * `whatsNew`) and is exported on its own.\n */\nimport { View } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { NativeBanner, NativeButton, NativeEmptyState, NativeSheet, NativeText } from \"@marktiderman/genesis-ui-native/components\";\nimport type { ReleaseNote } from \"./policy\";\n\nexport interface ForceUpgradeProps {\n minimumVersion: string;\n installedVersion: string;\n /** The policy's store link for this platform (a minimum without one forces nothing). */\n storeUrl: string;\n /** Opens `storeUrl`. */\n openStore: () => void;\n /** Ask the policy again (it may have been lowered). */\n retry: () => void;\n checking: boolean;\n}\n\n/** Blocking: this version is below the minimum. \"Update\" opens the store. */\nexport function ForceUpgradeScreen({ minimumVersion, installedVersion, openStore, retry, checking }: ForceUpgradeProps) {\n return (\n <View testID=\"genesis-force-upgrade\" className=\"flex-1 justify-center bg-background\">\n <NativeEmptyState\n variant=\"first-run\"\n title=\"Update required\"\n body={`This version (${installedVersion}) is no longer supported. Update to ${minimumVersion} or later to keep going.`}\n primaryAction={\n <NativeButton onPress={openStore} testID=\"genesis-force-upgrade-store\">\n Update\n </NativeButton>\n }\n secondaryAction={\n <NativeButton variant=\"ghost\" onPress={retry} loading={checking} testID=\"genesis-force-upgrade-retry\">\n Check again\n </NativeButton>\n }\n testID=\"genesis-force-upgrade-state\"\n />\n </View>\n );\n}\n\nexport interface MaintenanceProps {\n /** The policy's message, or `null` for the default copy. */\n message: string | null;\n retry: () => void;\n retrying: boolean;\n}\n\n/** Blocking: the policy says maintenance is on. \"Try again\" asks again. */\nexport function MaintenanceScreen({ message, retry, retrying }: MaintenanceProps) {\n return (\n <View testID=\"genesis-maintenance\" className=\"flex-1 justify-center bg-background\">\n <NativeEmptyState\n variant=\"first-run\"\n title=\"Down for maintenance\"\n body={message ?? \"We're doing some work on the app. Try again in a few minutes.\"}\n primaryAction={\n <NativeButton onPress={retry} loading={retrying} testID=\"genesis-maintenance-retry\">\n Try again\n </NativeButton>\n }\n testID=\"genesis-maintenance-state\"\n />\n </View>\n );\n}\n\nexport interface UpdateBannerProps {\n /** Reload into the downloaded update (refused while `canReload` is false). */\n reload: () => void;\n /** Hide the banner; the update still applies on the next cold start. */\n dismiss: () => void;\n /** False while something is mid-edit (`useBlockReload`) or your `canReload` says no. */\n canReload: boolean;\n /** The last tap was refused because something is mid-edit. */\n blocked: boolean;\n reloading: boolean;\n}\n\n/** Non-blocking: floats over the top of the screens while an update is downloaded. */\nexport function UpdateBanner({ reload, dismiss, canReload, blocked, reloading }: UpdateBannerProps) {\n return (\n <SafeAreaView edges={[\"top\"]} pointerEvents=\"box-none\" style={{ position: \"absolute\", top: 0, left: 0, right: 0 }}>\n <View testID=\"genesis-update-banner\" className=\"mx-3 mt-2 overflow-hidden rounded-lg border border-border bg-secondary\">\n <NativeBanner\n variant=\"info\"\n title=\"An update is ready\"\n description={blocked || !canReload ? \"Finish what you're doing, then restart to use it.\" : \"Restart to use the latest version.\"}\n className=\"border-b-0\"\n testID=\"genesis-update-banner-message\"\n />\n <View className=\"flex-row justify-end gap-2 px-4 pb-3\">\n <NativeButton variant=\"ghost\" size=\"sm\" onPress={dismiss} testID=\"genesis-update-banner-later\">\n Later\n </NativeButton>\n <NativeButton size=\"sm\" onPress={reload} disabled={!canReload} loading={reloading} testID=\"genesis-update-banner-restart\">\n Restart\n </NativeButton>\n </View>\n </View>\n </SafeAreaView>\n );\n}\n\nexport interface WhatsNewProps {\n /** Newest first. */\n notes: readonly ReleaseNote[];\n /** The installed version. */\n version: string | null;\n /** Close and remember this version. */\n dismiss: () => void;\n}\n\n/** The release notes for this version, once, in a sheet. */\nexport function WhatsNewSheet({ notes, dismiss }: WhatsNewProps) {\n return (\n <NativeSheet open onOpenChange={(open) => (open ? undefined : dismiss())} testID=\"genesis-whats-new\">\n <View className=\"gap-4 p-6\">\n <NativeText preset=\"h3\" accessibilityRole=\"header\">\n What's new\n </NativeText>\n {notes.map((note) => (\n <View key={note.version} className=\"gap-1\" testID={`genesis-whats-new-${note.version}`}>\n <NativeText preset=\"label\">{note.title ?? `Version ${note.version}`}</NativeText>\n <NativeText preset=\"body-sm\" className=\"text-muted-foreground\">\n {note.body}\n </NativeText>\n </View>\n ))}\n <NativeButton onPress={dismiss} testID=\"genesis-whats-new-done\">\n Got it\n </NativeButton>\n </View>\n </NativeSheet>\n );\n}\n","/**\n * `createUpdates(options)`: the updates block. Pass the result to\n * `<GenesisNativeApp updates={updates}>` (removing that line turns the block\n * off), or render `<UpdatesRoot block={updates}>` yourself.\n *\n * UpdatesRoot\n * ├ forceUpgrade (blocking: below the policy's minimum version)\n * ├ maintenance (blocking: the policy's maintenance switch, fetched live)\n * └ your screens\n * ├ updateBanner (non-blocking: an update is downloaded; reload on tap)\n * └ whatsNew (release notes, once per version)\n *\n * Every renderer is a slot, a primitive (`ForceUpgradeScreen`, …) and a hook\n * (`useForceUpgrade`, …).\n */\nimport { createContext, useContext, useEffect, useMemo, useState, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { View } from \"react-native\";\nimport { renderSlot, type SlotPropsFor, type Slots } from \"@marktiderman/genesis-core/slots\";\nimport { createUpdateChecker, createReloadGuard, type ReloadGuard, type UpdateChecker, type UpdateCheckState } from \"./checker\";\nimport { createChannelSwitcher, type ChannelSwitcher } from \"./channels\";\nimport { delay } from \"./store\";\nimport {\n WEEK_MS,\n createPolicyStore,\n validTimeout,\n evaluatePolicy,\n type PolicyState,\n type PolicyStore,\n type ReleaseNote,\n type UpdatePolicySource,\n type UpdateVerdict,\n} from \"./policy\";\nimport { versionSignature, type VersionSignature } from \"./signature\";\nimport { createWhatsNewStore, type WhatsNewState, type WhatsNewStore } from \"./whats-new\";\nimport {\n ForceUpgradeScreen,\n MaintenanceScreen,\n UpdateBanner,\n WhatsNewSheet,\n type ForceUpgradeProps,\n type MaintenanceProps,\n type UpdateBannerProps,\n type WhatsNewProps,\n} from \"./screens\";\nimport { toError, type ApplicationLike, type UpdatesAppStateLike, type UpdatesModuleLike, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\n\n// A type, not an interface, so it fits the slots contract's Record constraint.\nexport type UpdatesSlots = {\n /** Blocking. Default `ForceUpgradeScreen`. */\n forceUpgrade: ForceUpgradeProps;\n /** Blocking. Default `MaintenanceScreen`. */\n maintenance: MaintenanceProps;\n /** Over your screens while an update is downloaded. Default `UpdateBanner`. */\n updateBanner: UpdateBannerProps;\n /** Once per version. Default `WhatsNewSheet`. */\n whatsNew: WhatsNewProps;\n};\n\nexport interface UpdatesOptions {\n /** `Platform.OS`. Force upgrade applies to `ios` and `android` only. */\n platform: string;\n /** `expo-application`: the installed version. Without it, nothing is ever forced and notes never show. */\n application?: ApplicationLike;\n /** `expo-updates`. Without it (or with updates off), no banner and no channel switching. */\n updates?: UpdatesModuleLike;\n /** Min versions, maintenance and notes. Without it, only `notes` and the banner. */\n policy?: UpdatePolicySource;\n /** AsyncStorage: the policy cache, the version whose notes were seen, the picked channel. */\n storage?: UpdatesStorageLike;\n /** `AppState`: ask again when the app comes to the front. */\n appState?: UpdatesAppStateLike;\n /** `Linking.openURL`, for the store link. */\n openURL?: (url: string) => unknown;\n /** Extra say over reloading (return false to hold it off); `useBlockReload` covers forms. */\n canReload?: () => boolean;\n /** Release notes written in the app, merged with the policy's. */\n notes?: readonly ReleaseNote[];\n /** `false` turns what's new off. */\n whatsNew?: boolean;\n /** Channel switching, for development and preview builds only: `{ enabled: __DEV__ || isPreview }`. */\n channels?: { enabled: boolean };\n /** The longest the first policy load holds the splash. Default 3000 ms. */\n policyTimeoutMs?: number;\n /** How old a cached policy may be and still force an upgrade. Default 7 days. */\n cacheMaxAgeMs?: number;\n /** Ask for the policy again on coming to the front at most this often. Default 5 minutes. */\n policyRefreshMs?: number;\n /** Check for an update on coming to the front at most this often. Default 15 minutes. */\n checkIntervalMs?: number;\n /** `reloadAsync`'s reload screen (background color, spinner). */\n reloadScreenOptions?: object;\n /** Storage key prefix. Default `\"genesis:updates\"`. */\n storageKeyPrefix?: string;\n /** Every caught error, for reporting. None of them blocks anyone. */\n onError?: UpdatesOnError;\n now?: () => number;\n}\n\nexport interface UpdatesBlock {\n readonly options: UpdatesOptions;\n readonly policy: PolicyStore;\n readonly checker: UpdateChecker;\n readonly guard: ReloadGuard;\n readonly whatsNew: WhatsNewStore;\n /** Channel switching: `switchTo` throws unless `channels.enabled` was passed; `reset` always works. */\n readonly channels: ChannelSwitcher;\n /** The signature from the modules, without the picked channel (see `useVersionSignature`). */\n readonly signature: VersionSignature;\n /** Loads the policy and the seen version behind the splash; never fails, done within `policyTimeoutMs`. */\n readonly bootStep: { id: string; run: () => Promise<void>; timeoutMs: number };\n /** Start following the app's state; returns the stop. `UpdatesRoot` calls it. */\n start(): () => void;\n /** The block's root, for `GenesisNativeApp`. */\n readonly Root: ComponentType<Omit<UpdatesRootProps, \"block\">>;\n}\n\n/** Build the block once, at module scope, next to your Supabase client. */\nexport function createUpdates(options: UpdatesOptions): UpdatesBlock {\n const {\n platform,\n application,\n updates,\n policy: source,\n storage,\n appState,\n canReload,\n channels,\n policyRefreshMs = 5 * 60_000,\n checkIntervalMs = 15 * 60_000,\n reloadScreenOptions,\n storageKeyPrefix = \"genesis:updates\",\n onError,\n now = Date.now,\n } = options;\n const policyTimeoutMs = validTimeout(options.policyTimeoutMs, 3000);\n const guard = createReloadGuard(canReload);\n const policy = createPolicyStore({\n source: source ?? { load: async () => null },\n storage: source ? storage : undefined,\n cacheKey: `${storageKeyPrefix}:policy`,\n timeoutMs: policyTimeoutMs,\n now,\n onError,\n });\n const checker = createUpdateChecker({ updates, guard, reloadScreenOptions, now, onError });\n const whatsNew = createWhatsNewStore({\n storage: options.whatsNew === false ? undefined : storage,\n version: options.whatsNew === false ? null : (application?.nativeApplicationVersion ?? null),\n storageKey: `${storageKeyPrefix}:seen-version`,\n onError,\n });\n const switcher = createChannelSwitcher({\n updates,\n enabled: channels?.enabled === true,\n guard,\n storage,\n storageKey: `${storageKeyPrefix}:channel`,\n reloadScreenOptions,\n onError,\n });\n const signature = versionSignature({ application, updates, platform });\n\n const allNotes = (): ReleaseNote[] => [...(options.notes ?? []), ...(policy.getState().policy?.notes ?? [])];\n const syncNotes = () => {\n const state = policy.getState();\n // Final once the policy has answered from the network (or there is none): no more notes can arrive.\n whatsNew.update(allNotes(), !source || state.origin === \"network\");\n };\n policy.subscribe(syncNotes);\n\n let loaded: Promise<void> | null = null;\n // Bounded and never rejects, so the boot step can't time out or fail the boot (a stalled storage read included).\n const load = () => {\n loaded ??= Promise.race([Promise.all([policy.load(), whatsNew.load()]), delay(policyTimeoutMs)])\n .then(syncNotes)\n .catch((error) => {\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n });\n return loaded;\n };\n\n const block: UpdatesBlock = {\n options,\n policy,\n checker,\n guard,\n whatsNew,\n channels: switcher,\n signature,\n bootStep: { id: \"genesis:updates\", run: load, timeoutMs: policyTimeoutMs + 5000 },\n start() {\n void load();\n void checker.check();\n const subscription = appState?.addEventListener(\"change\", (state) => {\n if (state !== \"active\") return;\n void policy.refreshIfDue(policyRefreshMs);\n void checker.checkIfDue(checkIntervalMs);\n });\n return () => subscription?.remove();\n },\n Root: function UpdatesBlockRoot(props) {\n return <UpdatesRoot block={block} {...props} />;\n },\n };\n return block;\n}\n\nconst UpdatesContext = createContext<UpdatesBlock | null>(null);\n\n/** Provides the block to the hooks, without rendering any of its parts (rung 4). */\nexport function UpdatesProvider({ block, children }: { block: UpdatesBlock; children?: ReactNode }) {\n return <UpdatesContext.Provider value={block}>{children}</UpdatesContext.Provider>;\n}\n\n/** The block from `UpdatesProvider` / `UpdatesRoot` / `GenesisNativeApp`. Throws outside one. */\nexport function useUpdates(): UpdatesBlock {\n const block = useContext(UpdatesContext);\n if (!block) throw new Error(\"useUpdates: no updates block. Pass `updates={createUpdates(…)}` to GenesisNativeApp, or wrap in <UpdatesProvider>.\");\n return block;\n}\n\n/**\n * Hold reloads off while `active` (a form with unsaved changes):\n * `useBlockReload(form.formState.isDirty)`. Does nothing without an updates\n * block, so a screen can call it whether or not the block is on.\n */\nexport function useBlockReload(active: boolean) {\n const block = useContext(UpdatesContext);\n useEffect(() => (active && block ? block.guard.block() : undefined), [active, block]);\n}\n\nexport function useUpdatePolicy(): PolicyState {\n const { policy } = useUpdates();\n return useSyncExternalStore(policy.subscribe, policy.getState, policy.getState);\n}\n\n/** What the policy says now: `ok`, `forceUpgrade` or `maintenance`. */\nexport function useUpdateVerdict(): UpdateVerdict {\n const block = useUpdates();\n const state = useUpdatePolicy();\n const { platform, application, cacheMaxAgeMs = WEEK_MS, now = Date.now } = block.options;\n return useMemo(\n () => evaluatePolicy(state, { platform, installedVersion: application?.nativeApplicationVersion ?? null, now: now(), cacheMaxAgeMs }),\n [state, platform, application, cacheMaxAgeMs, now],\n );\n}\n\n/** The force-upgrade screen's props, or `null` when this version is supported. */\nexport function useForceUpgrade(): ForceUpgradeProps | null {\n const block = useUpdates();\n const verdict = useUpdateVerdict();\n const { refreshing } = useUpdatePolicy();\n if (verdict.kind !== \"forceUpgrade\") return null;\n const { storeUrl } = verdict;\n return {\n minimumVersion: verdict.minimumVersion,\n installedVersion: verdict.installedVersion,\n storeUrl,\n checking: refreshing,\n retry: () => void block.policy.refresh(),\n openStore: () => {\n if (!block.options.openURL) return;\n Promise.resolve()\n .then(() => block.options.openURL?.(storeUrl))\n .catch((error) => block.options.onError?.(toError(error), \"policy\"));\n },\n };\n}\n\n/** The maintenance screen's props, or `null` when maintenance is off (or not known live). */\nexport function useMaintenance(): MaintenanceProps | null {\n const block = useUpdates();\n const verdict = useUpdateVerdict();\n const { refreshing } = useUpdatePolicy();\n if (verdict.kind !== \"maintenance\") return null;\n return { message: verdict.message, retrying: refreshing, retry: () => void block.policy.refresh() };\n}\n\nexport function useUpdateCheck(): UpdateCheckState {\n const { checker } = useUpdates();\n return useSyncExternalStore(checker.subscribe, checker.getState, checker.getState);\n}\n\n/** True when a reload would be allowed now. */\nexport function useCanReload(): boolean {\n const { guard } = useUpdates();\n return useSyncExternalStore(guard.subscribe, guard.canReload, guard.canReload);\n}\n\n/** The banner's props, or `null` when there is nothing to show. */\nexport function useUpdateBanner(): UpdateBannerProps | null {\n const { checker } = useUpdates();\n const state = useUpdateCheck();\n const canReload = useCanReload();\n if ((state.status !== \"ready\" && state.status !== \"reloading\") || state.dismissed) return null;\n return {\n canReload,\n blocked: state.blocked,\n reloading: state.status === \"reloading\",\n reload: () => void checker.reload(),\n dismiss: () => checker.dismiss(),\n };\n}\n\n/** The notes to show now, or `null`. */\nexport function useWhatsNew(): WhatsNewProps | null {\n const block = useUpdates();\n const state: WhatsNewState = useSyncExternalStore(block.whatsNew.subscribe, block.whatsNew.getState, block.whatsNew.getState);\n if (state.status !== \"showing\") return null;\n return { notes: state.notes, version: block.options.application?.nativeApplicationVersion ?? null, dismiss: () => block.whatsNew.dismiss() };\n}\n\n/** The version signature, with the channel picked on this device once it has been read. */\nexport function useVersionSignature(): VersionSignature {\n const block = useUpdates();\n const [requested, setRequested] = useState<string | null>(null);\n useEffect(() => {\n let alive = true;\n void block.channels.requested().then((value) => alive && setRequested(value));\n return () => {\n alive = false;\n };\n }, [block]);\n return useMemo(() => {\n if (!requested) return block.signature;\n const { application, updates, platform } = block.options;\n return versionSignature({ application, updates, platform, requestedChannel: requested });\n }, [block, requested]);\n}\n\nexport interface UpdatesRootProps {\n block: UpdatesBlock;\n slots?: Slots<UpdatesSlots>;\n slotProps?: SlotPropsFor<UpdatesSlots>;\n children?: ReactNode;\n}\n\n/** The block's parts around your screens. */\nexport function UpdatesRoot({ block, slots, slotProps, children }: UpdatesRootProps) {\n useEffect(() => block.start(), [block]);\n return (\n <UpdatesProvider block={block}>\n <UpdatesParts slots={slots} slotProps={slotProps}>\n {children}\n </UpdatesParts>\n </UpdatesProvider>\n );\n}\n\nconst FILL = { position: \"absolute\", top: 0, right: 0, bottom: 0, left: 0 } as const;\n\nfunction UpdatesParts({ slots, slotProps, children }: Omit<UpdatesRootProps, \"block\">) {\n const forceUpgrade = useForceUpgrade();\n const maintenance = useMaintenance();\n const banner = useUpdateBanner();\n const whatsNew = useWhatsNew();\n // An ejected blocking slot (`null`) falls through to the screens: a block that is turned off never blocks.\n const blocking =\n forceUpgrade && slots?.forceUpgrade !== null\n ? renderSlot(ForceUpgradeScreen, slots?.forceUpgrade, forceUpgrade, slotProps?.forceUpgrade)\n : maintenance && slots?.maintenance !== null\n ? renderSlot(MaintenanceScreen, slots?.maintenance, maintenance, slotProps?.maintenance)\n : null;\n // The screens stay mounted under a blocking screen, so a block that starts and ends\n // mid-session (maintenance on, then off) keeps a half-filled form and the navigation state.\n return (\n <View style={{ flex: 1 }}>\n <View\n style={{ flex: 1 }}\n pointerEvents={blocking ? \"none\" : \"auto\"}\n accessibilityElementsHidden={Boolean(blocking)}\n importantForAccessibility={blocking ? \"no-hide-descendants\" : \"auto\"}\n >\n {children}\n </View>\n {!blocking && banner ? renderSlot(UpdateBanner, slots?.updateBanner, banner, slotProps?.updateBanner) : null}\n {!blocking && whatsNew ? renderSlot(WhatsNewSheet, slots?.whatsNew, whatsNew, slotProps?.whatsNew) : null}\n {blocking ? (\n <View style={FILL} testID=\"genesis-updates-blocking\">\n {blocking}\n </View>\n ) : null}\n </View>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/updates/modules.ts","../src/updates/checker.ts","../src/updates/channels.ts","../src/updates/version.ts","../src/updates/policy.ts","../src/updates/whats-new.ts","../src/updates/screens.tsx","../src/updates/block.tsx"],"names":["jsx","jsxs","View"],"mappings":";;;;;;;;;;;;AAsDO,SAAS,QAAQ,KAAA,EAAuB;AAC7C,EAAA,OAAO,KAAA,YAAiB,QAAQ,KAAA,GAAQ,IAAI,MAAM,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,eAAe,CAAA;AACvG;AAGO,SAAS,aAAA,CAAc,UAAmB,KAAA,EAA+C;AAC9F,EAAA,IAAI,CAAC,QAAA,IAAY,OAAO,QAAA,KAAa,UAAU,OAAO,IAAA;AACtD,EAAA,MAAM,KAAA,GAAS,SAAqC,KAAK,CAAA;AACzD,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,GAAS,IAAI,KAAA,GAAQ,IAAA;AACjE;;;ACvCO,SAAS,kBAAkB,SAAA,EAAwC;AACxE,EAAA,IAAI,QAAA,GAAW,CAAA;AACf,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAgB;AACtC,EAAA,MAAM,SAAS,MAA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the updates block reads, as the shapes it needs. Pass\n * the real ones (`import * as Updates from \"expo-updates\"`,\n * `import * as Application from \"expo-application\"`); tests pass fakes.\n * Both are optional peers: without `expo-updates` there is no update banner\n * and no channel switching, and without `expo-application` no force upgrade.\n */\n\n/** `expo-updates` (SDK 58): the constants and calls this block uses. */\nexport interface UpdatesModuleLike {\n /** False in development, Expo Go, or a build without updates configured. */\n readonly isEnabled: boolean;\n /** The running update's id; `null` when updates are off. */\n readonly updateId: string | null;\n /** The build's channel; `null` in development builds and Expo Go. */\n readonly channel: string | null;\n readonly runtimeVersion: string | null;\n /** True when the code that shipped in the binary is running, not a downloaded update. */\n readonly isEmbeddedLaunch: boolean;\n /** True when expo-updates fell back to the embedded update after a failed launch. */\n readonly isEmergencyLaunch?: boolean;\n readonly emergencyLaunchReason?: string | null;\n checkForUpdateAsync(): Promise<{ isAvailable: boolean; isRollBackToEmbedded?: boolean; manifest?: unknown }>;\n fetchUpdateAsync(): Promise<{ isNew: boolean; isRollBackToEmbedded?: boolean; manifest?: unknown }>;\n reloadAsync(options?: { reloadScreenOptions?: object }): Promise<void>;\n /** Overrides the `expo-channel-name` header (persists on the device); `null` removes the override. */\n setUpdateRequestHeadersOverride?(requestHeaders: Record<string, string> | null): void;\n}\n\n/** `expo-application`: the installed store version and build number. */\nexport interface ApplicationLike {\n /** `CFBundleShortVersionString` / `versionName`, e.g. `\"1.4.0\"`. */\n readonly nativeApplicationVersion: string | null;\n /** `CFBundleVersion` / `versionCode`, e.g. `\"37\"`. */\n readonly nativeBuildVersion: string | null;\n}\n\n/** AsyncStorage, MMKV's async adapter, or a stand-in. */\nexport interface UpdatesStorageLike {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem?(key: string): Promise<void>;\n}\n\n/** React Native's `AppState`. */\nexport interface UpdatesAppStateLike {\n addEventListener(type: \"change\", listener: (state: string) => void): { remove(): void };\n}\n\n/** Where a reported error came from. */\nexport type UpdatesErrorSource = \"policy\" | \"check\" | \"reload\" | \"storage\" | \"channel\";\n\nexport type UpdatesOnError = (error: Error, source: UpdatesErrorSource) => void;\n\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(typeof value === \"string\" ? value : \"Unknown error\");\n}\n\n/** The `id` (and `runtimeVersion`) of an update manifest, when it has them. */\nexport function manifestField(manifest: unknown, field: \"id\" | \"runtimeVersion\"): string | null {\n if (!manifest || typeof manifest !== \"object\") return null;\n const value = (manifest as Record<string, unknown>)[field];\n return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n","/**\n * The update banner's engine: ask expo-updates for a newer update, download\n * it, and reload only when the person taps and nothing is mid-edit.\n *\n * - It never reloads on its own. A downloaded update also applies on the next\n * cold start, so dismissing the banner loses nothing.\n * - The reload guard says no while any `useBlockReload(true)` is mounted (a\n * form with unsaved changes) or your `canReload()` returns false (or\n * throws). The banner then asks the person to finish first.\n * - expo-updates only serves updates built for this binary's runtime\n * version; an update whose manifest names another runtime is ignored too.\n */\nimport { createStore, type Store } from \"./store\";\nimport { manifestField, toError, type UpdatesModuleLike, type UpdatesOnError } from \"./modules\";\n\nexport interface ReloadGuard {\n /** Hold reloads off until the returned function is called. */\n block(): () => void;\n /** True when nothing blocks and your `canReload` agrees. */\n canReload(): boolean;\n /** Fires when a block starts or ends. */\n subscribe(listener: () => void): () => void;\n}\n\nexport function createReloadGuard(canReload?: () => boolean): ReloadGuard {\n let blockers = 0;\n const listeners = new Set<() => void>();\n const notify = () => {\n for (const listener of [...listeners]) listener();\n };\n return {\n block() {\n blockers++;\n notify();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n blockers--;\n notify();\n };\n },\n canReload() {\n if (blockers > 0) return false;\n try {\n return canReload ? canReload() === true : true;\n } catch {\n return false; // When in doubt, don't throw away someone's work.\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\nexport type UpdateCheckStatus = \"disabled\" | \"idle\" | \"checking\" | \"downloading\" | \"ready\" | \"reloading\" | \"error\";\n\nexport interface UpdateCheckState {\n status: UpdateCheckStatus;\n /** The downloaded update's id, when the manifest has one. */\n updateId: string | null;\n /** The person closed the banner; the update still applies on the next cold start. */\n dismissed: boolean;\n /** The last tap was refused by the reload guard; cleared when the guard opens. */\n blocked: boolean;\n error: Error | null;\n}\n\nexport interface UpdateCheckerOptions {\n updates?: UpdatesModuleLike;\n guard: ReloadGuard;\n /** Passed to `reloadAsync` (a branded reload screen). */\n reloadScreenOptions?: object;\n now?: () => number;\n onError?: UpdatesOnError;\n}\n\nexport interface UpdateChecker extends Pick<Store<UpdateCheckState>, \"getState\" | \"subscribe\"> {\n /** Check and download. Never rejects; does nothing while one is in flight or an update is ready. */\n check(): Promise<void>;\n /** `check()` unless the last one started less than `minIntervalMs` ago. */\n checkIfDue(minIntervalMs: number): Promise<void>;\n /** Reload into the downloaded update. Resolves false when there is none or the guard refuses. */\n reload(): Promise<boolean>;\n dismiss(): void;\n /** Stop following the guard. */\n dispose(): void;\n}\n\nexport function createUpdateChecker(options: UpdateCheckerOptions): UpdateChecker {\n const { updates, guard, reloadScreenOptions, now = Date.now, onError } = options;\n const enabled = Boolean(updates?.isEnabled);\n const store = createStore<UpdateCheckState>({\n status: enabled ? \"idle\" : \"disabled\",\n updateId: null,\n dismissed: false,\n blocked: false,\n error: null,\n });\n let inflight: Promise<void> | null = null;\n let lastCheck: number | null = null;\n const report = (error: Error, from: \"check\" | \"reload\") => {\n try {\n onError?.(error, from);\n } catch {\n // ignore a failing reporter\n }\n };\n const stopGuard = guard.subscribe(() => {\n if (store.getState().blocked && guard.canReload()) store.setState({ blocked: false });\n });\n\n const check = (): Promise<void> => {\n if (!updates || !enabled) return Promise.resolve();\n const { status } = store.getState();\n if (inflight || status === \"ready\" || status === \"reloading\") return inflight ?? Promise.resolve();\n lastCheck = now();\n // eslint-disable-next-line prefer-const -- read in `finally`, after the assignment below\n let run!: Promise<void>;\n run = (async () => {\n // Never settle synchronously (a module that throws before its first await).\n await null;\n try {\n store.setState({ status: \"checking\", error: null });\n const result = await updates.checkForUpdateAsync();\n if (!result.isAvailable && !result.isRollBackToEmbedded) {\n store.setState({ status: \"idle\" });\n return;\n }\n const runtime = manifestField(result.manifest, \"runtimeVersion\");\n if (runtime && updates.runtimeVersion && runtime !== updates.runtimeVersion) {\n store.setState({ status: \"idle\" });\n return;\n }\n store.setState({ status: \"downloading\" });\n const fetched = await updates.fetchUpdateAsync();\n const updateId = manifestField(fetched.manifest, \"id\") ?? manifestField(result.manifest, \"id\");\n if ((fetched.isNew || fetched.isRollBackToEmbedded) && !(updateId && updateId === updates.updateId)) {\n store.setState({ status: \"ready\", updateId, dismissed: false });\n } else {\n store.setState({ status: \"idle\" });\n }\n } catch (raw) {\n const error = toError(raw);\n report(error, \"check\");\n store.setState({ status: \"error\", error });\n } finally {\n if (inflight === run) inflight = null;\n }\n })();\n inflight = run;\n return run;\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n check,\n checkIfDue(minIntervalMs) {\n const at = now();\n if (lastCheck !== null && at >= lastCheck && at - lastCheck < minIntervalMs) return Promise.resolve();\n return check();\n },\n async reload() {\n if (!updates || store.getState().status !== \"ready\") return false;\n if (!guard.canReload()) {\n store.setState({ blocked: true });\n return false;\n }\n store.setState({ status: \"reloading\", blocked: false });\n try {\n await updates.reloadAsync(reloadScreenOptions ? { reloadScreenOptions } : undefined);\n return true;\n } catch (raw) {\n const error = toError(raw);\n report(error, \"reload\");\n store.setState({ status: \"ready\", error });\n return false;\n }\n },\n dismiss() {\n store.setState({ dismissed: true, blocked: false });\n },\n dispose: stopGuard,\n };\n}\n","/**\n * Switching a test build to another update channel (EAS \"channel surfing\"):\n * override the `expo-channel-name` header, check, fetch, reload. The\n * override persists on the device until it is reset or the app is removed.\n *\n * Off unless you turn it on, and turn it on only in development and preview\n * builds (`enabled: __DEV__ || isPreviewBuild`): a store build that can be\n * pointed at any channel can be pointed at an unreviewed one. Going back\n * (`reset`) always works, for everyone, because it only removes the\n * override.\n *\n * Switching reloads, so it respects the reload guard: with unsaved changes\n * it sets the channel and says `blocked`; the channel applies on the next\n * launch.\n */\nimport { toError, type UpdatesModuleLike, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\nimport type { ReloadGuard } from \"./checker\";\n\nexport type ChannelSwitchResult =\n /** The reload was sent; JS may stop at any moment. */\n | { kind: \"reloading\" }\n /** The channel is set, but something is mid-edit: it applies on the next launch. */\n | { kind: \"blocked\" }\n /** expo-updates is off or too old here (development, Expo Go). Nothing changed. */\n | { kind: \"unavailable\"; reason: string }\n /** The channel is set but checking, fetching or reloading failed. */\n | { kind: \"error\"; error: Error };\n\nexport interface ChannelSwitcher {\n /** True when this build may switch channels (`channels.enabled`). */\n readonly enabled: boolean;\n /** Switch to `channel` and reload. Throws when switching is off. */\n switchTo(channel: string): Promise<ChannelSwitchResult>;\n /** Back to the build's own channel. Always allowed. */\n reset(): Promise<ChannelSwitchResult>;\n /** The channel picked on this device, or `null` when it follows the build. */\n requested(): Promise<string | null>;\n}\n\nexport interface ChannelSwitcherOptions {\n updates?: UpdatesModuleLike;\n /** Must be explicitly true (development and preview builds only). */\n enabled: boolean;\n guard: ReloadGuard;\n /** Remembers the picked channel, for the version signature. */\n storage?: UpdatesStorageLike;\n /** Default `\"genesis:updates:channel\"`. */\n storageKey?: string;\n reloadScreenOptions?: object;\n onError?: UpdatesOnError;\n}\n\nconst CHANNEL = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,99}$/;\n\nexport function createChannelSwitcher(options: ChannelSwitcherOptions): ChannelSwitcher {\n const { updates, enabled, guard, storage, storageKey = \"genesis:updates:channel\", reloadScreenOptions, onError } = options;\n const report = (error: Error) => {\n try {\n onError?.(error, \"channel\");\n } catch {\n // ignore a failing reporter\n }\n };\n const unavailable = (): ChannelSwitchResult | null => {\n if (!updates?.isEnabled) return { kind: \"unavailable\", reason: \"Updates are off in this build (development or Expo Go).\" };\n if (typeof updates.setUpdateRequestHeadersOverride !== \"function\") {\n return { kind: \"unavailable\", reason: \"This expo-updates can't override the channel.\" };\n }\n return null;\n };\n const save = async (channel: string | null) => {\n if (!storage) return;\n try {\n if (channel === null) await (storage.removeItem ? storage.removeItem(storageKey) : storage.setItem(storageKey, \"\"));\n else await storage.setItem(storageKey, channel);\n } catch (error) {\n report(toError(error));\n }\n };\n const apply = async (): Promise<ChannelSwitchResult> => {\n const u = updates as UpdatesModuleLike;\n try {\n const check = await u.checkForUpdateAsync();\n if (check.isAvailable || check.isRollBackToEmbedded) await u.fetchUpdateAsync();\n if (!guard.canReload()) return { kind: \"blocked\" };\n await u.reloadAsync(reloadScreenOptions ? { reloadScreenOptions } : undefined);\n return { kind: \"reloading\" };\n } catch (raw) {\n const error = toError(raw);\n report(error);\n return { kind: \"error\", error };\n }\n };\n\n return {\n enabled,\n async switchTo(channel) {\n if (enabled !== true) {\n throw new Error(\"Channel switching is off. Pass `channels: { enabled: true }` only in development and preview builds.\");\n }\n const name = channel.trim();\n if (!CHANNEL.test(name)) throw new Error(`Not a channel name: \"${channel}\"`);\n const off = unavailable();\n if (off) return off;\n updates!.setUpdateRequestHeadersOverride!({ \"expo-channel-name\": name });\n await save(name === updates!.channel ? null : name);\n return apply();\n },\n async reset() {\n const off = unavailable();\n if (off) {\n await save(null);\n return off;\n }\n // Clearing the override is the part that must happen; a failed check or reload is reported, not a reason to stay.\n updates!.setUpdateRequestHeadersOverride!(null);\n await save(null);\n return apply();\n },\n async requested() {\n if (!storage) return null;\n try {\n const value = await storage.getItem(storageKey);\n return value ? value : null;\n } catch (error) {\n report(toError(error));\n return null;\n }\n },\n };\n}\n","/**\n * Version numbers: the store version an app reports (`1.4.0`, `1.10`) and\n * the minimum a policy sets. Only plain dotted numbers count (one to four\n * parts, as App Store Connect and Play accept). Anything else (`1.2-beta`,\n * `latest`, an empty string, a number too large to compare exactly) does not\n * parse, and a comparison with it has no answer (`null`), so a malformed\n * minimum can never block anyone.\n */\n\nconst VERSION = /^\\d+(?:\\.\\d+){0,3}$/;\n\n/** `\"1.10\"` → `[1, 10, 0, 0]`; `null` when it isn't a plain dotted version. */\nexport function parseVersion(value: unknown): number[] | null {\n if (typeof value !== \"string\") return null;\n const text = value.trim();\n if (!VERSION.test(text)) return null;\n const parts = text.split(\".\").map(Number);\n if (parts.some((part) => !Number.isSafeInteger(part))) return null;\n while (parts.length < 4) parts.push(0);\n return parts;\n}\n\n/** -1, 0 or 1 as `a` is older than, the same as or newer than `b`; `null` when either doesn't parse. */\nexport function compareVersions(a: unknown, b: unknown): -1 | 0 | 1 | null {\n const left = parseVersion(a);\n const right = parseVersion(b);\n if (!left || !right) return null;\n for (let i = 0; i < 4; i++) {\n const l = left[i] ?? 0;\n const r = right[i] ?? 0;\n if (l !== r) return l < r ? -1 : 1;\n }\n return 0;\n}\n\n/** True only when both parse and `installed` is older than `minimum`. Fails open. */\nexport function isBelowMinimum(installed: unknown, minimum: unknown): boolean {\n return compareVersions(installed, minimum) === -1;\n}\n","/**\n * The release policy: the oldest store version each platform may run, a\n * maintenance switch, and release notes. It comes from an\n * `UpdatePolicySource` (a static object, Supabase, or your own), is cached on\n * the phone, and **fails open**: no answer, a timeout, a malformed value or\n * an untrusted cache never blocks anyone.\n *\n * What may block, and from where:\n * - Force upgrade: a policy fetched this session, or a cached one no older\n * than `cacheMaxAgeMs` (7 days) by the phone's clock. A cache whose time is\n * in the future (the clock moved back) is not trusted. A minimum without a\n * store link for the platform forces nothing (there would be no way out).\n * - Maintenance: only a policy fetched from the network this session. A\n * cached maintenance flag never blocks a cold start.\n */\nimport { createStore, delay, type Store } from \"./store\";\nimport { isBelowMinimum } from \"./version\";\nimport { toError, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\n\nexport type UpdatePlatform = \"ios\" | \"android\";\n\nexport interface ReleaseNote {\n /** The store version these notes describe, e.g. `\"1.4.0\"`. */\n version: string;\n title?: string;\n body: string;\n}\n\nexport interface UpdatePolicy {\n /** The oldest store version still supported, per platform. Missing or malformed: no minimum. */\n minimumVersion?: Partial<Record<UpdatePlatform, string>>;\n /** Where \"Update\" goes (`https://apps.apple.com/…`, `itms-apps://…`, `market://…`, `https://play.google.com/…`). */\n storeUrl?: Partial<Record<UpdatePlatform, string>>;\n maintenance?: { active: boolean; message: string | null };\n notes?: readonly ReleaseNote[];\n}\n\n/** Where the policy comes from. `load` throws (or rejects) when it can't answer; resolving `null` means \"no policy\". */\nexport interface UpdatePolicySource {\n load(): Promise<UpdatePolicy | null | undefined>;\n}\n\n/** A policy written in the app (or a test). */\nexport function staticPolicySource(policy: UpdatePolicy): UpdatePolicySource {\n return { load: async () => policy };\n}\n\n/** A Supabase client: anything with `from(table)` (a real `SupabaseClient` fits without a cast). */\nexport interface PolicyClientLike {\n from(table: string): unknown;\n}\n\ninterface PolicyQuery {\n select(columns: string): { eq(column: string, value: string): { maybeSingle(): PromiseLike<{ data: unknown; error: unknown }> } };\n}\n\nexport interface SupabasePolicySourceOptions {\n /** The `app_id` row to read. Default `\"default\"`. */\n appId?: string;\n /** Default `\"app_release_policy\"` (migration `0002_genesis_app_release_policy.sql` in `@marktiderman/genesis-supabase`). */\n table?: string;\n}\n\nconst COLUMNS = \"min_version_ios,min_version_android,store_url_ios,store_url_android,maintenance,maintenance_message,notes\";\n\n/**\n * Reads one row of `public.app_release_policy` (readable by anon and\n * authenticated, written only with the service role). No row is no policy.\n */\nexport function supabasePolicySource(client: PolicyClientLike, options: SupabasePolicySourceOptions = {}): UpdatePolicySource {\n const { appId = \"default\", table = \"app_release_policy\" } = options;\n return {\n async load() {\n const query = client.from(table) as PolicyQuery;\n const { data, error } = await query.select(COLUMNS).eq(\"app_id\", appId).maybeSingle();\n if (error) throw toError(error instanceof Error ? error : (error as { message?: unknown }).message ?? error);\n if (!data || typeof data !== \"object\") return {};\n const row = data as Record<string, unknown>;\n return {\n minimumVersion: pick({ ios: row.min_version_ios, android: row.min_version_android }),\n storeUrl: pick({ ios: row.store_url_ios, android: row.store_url_android }),\n maintenance: { active: row.maintenance === true, message: typeof row.maintenance_message === \"string\" ? row.maintenance_message : null },\n notes: Array.isArray(row.notes) ? (row.notes as ReleaseNote[]) : [],\n };\n },\n };\n}\n\nfunction pick(values: Record<UpdatePlatform, unknown>): Partial<Record<UpdatePlatform, string>> {\n const out: Partial<Record<UpdatePlatform, string>> = {};\n for (const platform of [\"ios\", \"android\"] as const) {\n const value = values[platform];\n if (typeof value === \"string\" && value.trim() !== \"\") out[platform] = value.trim();\n }\n return out;\n}\n\nconst STORE_URL = /^(https:\\/\\/|itms-apps:\\/\\/|market:\\/\\/)/i;\n\n/** Keeps only well-formed fields; throws when `raw` isn't an object at all (so the cache answers instead). */\nexport function sanitizePolicy(raw: unknown): UpdatePolicy {\n if (raw === null || raw === undefined) return {};\n if (typeof raw !== \"object\" || Array.isArray(raw)) throw new Error(\"The release policy is not an object\");\n const value = raw as Record<string, unknown>;\n const policy: UpdatePolicy = {};\n const minimum = value.minimumVersion && typeof value.minimumVersion === \"object\" ? (value.minimumVersion as Record<UpdatePlatform, unknown>) : null;\n if (minimum) policy.minimumVersion = pick(minimum);\n const store = value.storeUrl && typeof value.storeUrl === \"object\" ? pick(value.storeUrl as Record<UpdatePlatform, unknown>) : null;\n if (store) {\n for (const platform of [\"ios\", \"android\"] as const) if (store[platform] && !STORE_URL.test(store[platform])) delete store[platform];\n policy.storeUrl = store;\n }\n const maintenance = value.maintenance as { active?: unknown; message?: unknown } | null | undefined;\n if (maintenance && typeof maintenance === \"object\") {\n policy.maintenance = {\n active: maintenance.active === true,\n message: typeof maintenance.message === \"string\" && maintenance.message.trim() !== \"\" ? maintenance.message : null,\n };\n }\n if (Array.isArray(value.notes)) {\n policy.notes = value.notes.flatMap((note): ReleaseNote[] => {\n if (!note || typeof note !== \"object\") return [];\n const { version, title, body } = note as Record<string, unknown>;\n if (typeof version !== \"string\" || typeof body !== \"string\") return [];\n return [{ version: version.trim(), body, ...(typeof title === \"string\" ? { title } : {}) }];\n });\n }\n return policy;\n}\n\nexport type PolicyOrigin = \"network\" | \"cache\" | \"none\";\n\nexport interface PolicyState {\n /** `loading` until the first answer (or the timeout); then `ready`, with or without a policy. */\n status: \"loading\" | \"ready\";\n policy: UpdatePolicy | null;\n /** `network`: fetched this session. `cache`: read from the phone. `none`: no answer yet (fail open). */\n origin: PolicyOrigin;\n /** When it was fetched, by the phone's clock (ms). */\n fetchedAt: number | null;\n /** The last failed fetch, if the most recent one failed. */\n error: Error | null;\n /** A fetch is in flight. */\n refreshing: boolean;\n}\n\nexport interface PolicyStoreOptions {\n source: UpdatePolicySource;\n storage?: UpdatesStorageLike;\n /** Default `\"genesis:updates:policy\"`. */\n cacheKey?: string;\n /** The longest `load()` waits before carrying on without an answer. Default 3000 ms. */\n timeoutMs?: number;\n now?: () => number;\n onError?: UpdatesOnError;\n}\n\nexport interface PolicyStore extends Pick<Store<PolicyState>, \"getState\" | \"subscribe\"> {\n /** The first load: the cache and the network together, for at most `timeoutMs`. Never rejects; runs once. */\n load(): Promise<void>;\n /** Fetch again (maintenance \"Try again\", the app coming to the front). Never rejects; resolves true on an answer. */\n refresh(): Promise<boolean>;\n /** `refresh()` unless one ran less than `minIntervalMs` ago. */\n refreshIfDue(minIntervalMs: number): Promise<boolean>;\n}\n\ninterface CacheEntry {\n v: 1;\n savedAt: number;\n policy: UpdatePolicy;\n}\n\nexport function createPolicyStore(options: PolicyStoreOptions): PolicyStore {\n const { source, storage, cacheKey = \"genesis:updates:policy\", now = Date.now, onError } = options;\n const timeoutMs = validTimeout(options.timeoutMs, 3000);\n const store = createStore<PolicyState>({ status: \"loading\", policy: null, origin: \"none\", fetchedAt: null, error: null, refreshing: false });\n let inflight: Promise<boolean> | null = null;\n let firstLoad: Promise<void> | null = null;\n let lastAttempt: number | null = null;\n const report = (error: unknown, from: \"policy\" | \"storage\") => {\n try {\n onError?.(toError(error), from);\n } catch {\n // A failing reporter must not change the answer.\n }\n };\n\n const fetchNetwork = (): Promise<boolean> => {\n if (inflight) return inflight;\n lastAttempt = now();\n store.setState({ refreshing: true });\n // eslint-disable-next-line prefer-const -- read in `finally`, after the assignment below\n let run!: Promise<boolean>;\n run = (async () => {\n // Never settle synchronously: a source that throws before its first await must not leave a settled `inflight` behind.\n await null;\n try {\n const policy = sanitizePolicy(await source.load());\n const fetchedAt = now();\n store.setState({ status: \"ready\", policy, origin: \"network\", fetchedAt, error: null });\n if (storage) {\n const entry: CacheEntry = { v: 1, savedAt: fetchedAt, policy };\n Promise.resolve()\n .then(() => storage.setItem(cacheKey, JSON.stringify(entry)))\n .catch((error) => report(error, \"storage\"));\n }\n return true;\n } catch (error) {\n report(error, \"policy\");\n // A network answer from earlier this session stays; the cache (if any) was already applied.\n store.setState({ error: toError(error) });\n return false;\n } finally {\n if (inflight === run) inflight = null;\n store.setState({ refreshing: false });\n }\n })();\n inflight = run;\n return run;\n };\n\n const readCache = async () => {\n if (!storage) return;\n try {\n const entry = parseCache(await storage.getItem(cacheKey));\n if (entry && store.getState().origin !== \"network\") {\n store.setState({ policy: entry.policy, origin: \"cache\", fetchedAt: entry.savedAt });\n }\n } catch (error) {\n report(error, \"storage\");\n }\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n load() {\n firstLoad ??= (async () => {\n const cache = readCache();\n const network = fetchNetwork();\n const answered = network.then(async (ok) => {\n if (!ok) await cache;\n });\n await Promise.race([answered, delay(timeoutMs)]);\n store.setState({ status: \"ready\" });\n })();\n return firstLoad;\n },\n refresh: fetchNetwork,\n refreshIfDue(minIntervalMs) {\n const at = now();\n // A clock that moved back makes the last attempt look in the future: refresh.\n if (lastAttempt !== null && at >= lastAttempt && at - lastAttempt < minIntervalMs) return Promise.resolve(false);\n return fetchNetwork();\n },\n };\n}\n\n/** A finite, non-negative timeout, or `fallback` (a NaN or Infinity would wait forever). */\nexport function validTimeout(value: number | undefined, fallback: number): number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\nfunction parseCache(raw: string | null): CacheEntry | null {\n if (!raw) return null;\n try {\n const entry = JSON.parse(raw) as Partial<CacheEntry>;\n if (entry?.v !== 1 || typeof entry.savedAt !== \"number\" || !Number.isFinite(entry.savedAt)) return null;\n return { v: 1, savedAt: entry.savedAt, policy: sanitizePolicy(entry.policy) };\n } catch {\n return null;\n }\n}\n\n/** What the policy says this install must do. */\nexport type UpdateVerdict =\n | { kind: \"ok\" }\n | { kind: \"forceUpgrade\"; minimumVersion: string; installedVersion: string; storeUrl: string }\n | { kind: \"maintenance\"; message: string | null };\n\nexport interface EvaluatePolicyOptions {\n /** `Platform.OS`. Only `ios` and `android` can be forced to upgrade. */\n platform: string;\n /** The installed store version (`Application.nativeApplicationVersion`). `null`: never forced. */\n installedVersion: string | null;\n now: number;\n /** How old a cached policy may be and still force an upgrade. Default 7 days. */\n cacheMaxAgeMs?: number;\n}\n\n/** How far in the future a cache's time may be (clocks drift) before it isn't trusted. */\nexport const CLOCK_SKEW_MS = 5 * 60_000;\nexport const WEEK_MS = 7 * 24 * 60 * 60_000;\n\n/** Force upgrade first (the store is the way out), then maintenance, else ok. Fails open. */\nexport function evaluatePolicy(state: PolicyState, options: EvaluatePolicyOptions): UpdateVerdict {\n const { policy, origin, fetchedAt } = state;\n if (!policy) return { kind: \"ok\" };\n const { platform, installedVersion, now, cacheMaxAgeMs = WEEK_MS } = options;\n const age = fetchedAt === null ? null : now - fetchedAt;\n const trusted = origin === \"network\" || (origin === \"cache\" && age !== null && age >= -CLOCK_SKEW_MS && age <= cacheMaxAgeMs);\n if (trusted && (platform === \"ios\" || platform === \"android\")) {\n const minimum = policy.minimumVersion?.[platform];\n const storeUrl = policy.storeUrl?.[platform];\n // Without a store link there is no way out of the screen, so no store link means no force upgrade.\n if (minimum && storeUrl && installedVersion && isBelowMinimum(installedVersion, minimum)) {\n return { kind: \"forceUpgrade\", minimumVersion: minimum.trim(), installedVersion, storeUrl };\n }\n }\n if (origin === \"network\" && policy.maintenance?.active === true) {\n return { kind: \"maintenance\", message: policy.maintenance.message };\n }\n return { kind: \"ok\" };\n}\n","/**\n * What's new: release notes shown once per version, remembered in storage.\n *\n * - First launch after an install (nothing stored): nothing shows; the\n * version is remembered, so a new install never opens on a sheet.\n * - A newer version than the one remembered: the notes for every version\n * after it, up to this one, newest first. Closing them remembers this\n * version. With no notes for it, the version is remembered once the policy\n * has answered from the network (or there is no policy source), so notes\n * that arrive late still show.\n * - Storage that can't be read shows nothing (rather than every launch).\n */\nimport { createStore, type Store } from \"./store\";\nimport { compareVersions } from \"./version\";\nimport { toError, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\nimport type { ReleaseNote } from \"./policy\";\n\nexport interface WhatsNewState {\n status: \"loading\" | \"hidden\" | \"showing\";\n notes: readonly ReleaseNote[];\n}\n\nexport interface WhatsNewOptions {\n storage?: UpdatesStorageLike;\n /** The installed version notes are matched against. `null`: never shows. */\n version: string | null;\n /** Default `\"genesis:updates:seen-version\"`. */\n storageKey?: string;\n onError?: UpdatesOnError;\n}\n\nexport interface WhatsNewStore extends Pick<Store<WhatsNewState>, \"getState\" | \"subscribe\"> {\n /** Read the remembered version. Never rejects; runs once. */\n load(): Promise<void>;\n /** Recompute with the notes known now; `final` once no more notes can arrive. */\n update(notes: readonly ReleaseNote[], final: boolean): void;\n /** Close the notes and remember this version. */\n dismiss(): void;\n}\n\n/** The notes after `seen`, up to `version`, newest first. */\nexport function notesSince(notes: readonly ReleaseNote[], seen: string, version: string): ReleaseNote[] {\n return notes\n .filter((note) => {\n if (note.version === version) return seen !== version;\n const afterSeen = compareVersions(note.version, seen);\n const upToNow = compareVersions(note.version, version);\n return afterSeen === 1 && (upToNow === -1 || upToNow === 0);\n })\n .sort((a, b) => compareVersions(b.version, a.version) ?? 0);\n}\n\nexport function createWhatsNewStore(options: WhatsNewOptions): WhatsNewStore {\n const { storage, version, storageKey = \"genesis:updates:seen-version\", onError } = options;\n const store = createStore<WhatsNewState>({ status: \"loading\", notes: [] });\n // undefined: not read yet; null: nothing stored (a fresh install); false: unreadable.\n let seen: string | null | false | undefined;\n let loading: Promise<void> | null = null;\n let pending: { notes: readonly ReleaseNote[]; final: boolean } | null = null;\n\n const remember = () => {\n if (!storage || !version) return;\n seen = version;\n Promise.resolve()\n .then(() => storage.setItem(storageKey, version))\n .catch((error) => {\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n });\n };\n\n const compute = (notes: readonly ReleaseNote[], final: boolean) => {\n if (seen === undefined) {\n pending = { notes, final };\n return;\n }\n if (!version || seen === false) return store.setState({ status: \"hidden\", notes: [] });\n if (seen === null) {\n remember();\n return store.setState({ status: \"hidden\", notes: [] });\n }\n const due = notesSince(notes, seen, version);\n if (due.length > 0) return store.setState({ status: \"showing\", notes: due });\n if (final && seen !== version) remember();\n store.setState({ status: \"hidden\", notes: [] });\n };\n\n return {\n getState: store.getState,\n subscribe: store.subscribe,\n load() {\n loading ??= (async () => {\n if (!storage || !version) {\n seen = false;\n } else {\n try {\n seen = await storage.getItem(storageKey);\n } catch (error) {\n seen = false;\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n }\n }\n const next = pending ?? { notes: [], final: false };\n pending = null;\n compute(next.notes, next.final);\n })();\n return loading;\n },\n update: compute,\n dismiss() {\n remember();\n store.setState({ status: \"hidden\", notes: [] });\n },\n };\n}\n","/**\n * The default renderers, built from `@marktiderman/genesis-ui-native`. Each\n * is the default of one slot (`forceUpgrade`, `maintenance`, `updateBanner`,\n * `whatsNew`) and is exported on its own.\n */\nimport { View } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport {\n NativeBanner,\n NativeButton,\n NativeEmptyState,\n NativeGlassSurface,\n NativeSheet,\n NativeSheetScrollView,\n NativeText,\n useLiquidGlass,\n} from \"@marktiderman/genesis-ui-native/components\";\nimport type { ReleaseNote } from \"./policy\";\n\nexport interface ForceUpgradeProps {\n minimumVersion: string;\n installedVersion: string;\n /** The policy's store link for this platform (a minimum without one forces nothing). */\n storeUrl: string;\n /** Opens `storeUrl`. */\n openStore: () => void;\n /** Ask the policy again (it may have been lowered). */\n retry: () => void;\n checking: boolean;\n}\n\n/** Blocking: this version is below the minimum. \"Update\" opens the store. */\nexport function ForceUpgradeScreen({ minimumVersion, installedVersion, openStore, retry, checking }: ForceUpgradeProps) {\n return (\n <View testID=\"genesis-force-upgrade\" className=\"flex-1 justify-center bg-background\">\n <NativeEmptyState\n variant=\"first-run\"\n title=\"Update required\"\n body={`This version (${installedVersion}) is no longer supported. Update to ${minimumVersion} or later to keep going.`}\n primaryAction={\n <NativeButton onPress={openStore} testID=\"genesis-force-upgrade-store\">\n Update\n </NativeButton>\n }\n secondaryAction={\n <NativeButton variant=\"ghost\" onPress={retry} loading={checking} testID=\"genesis-force-upgrade-retry\">\n Check again\n </NativeButton>\n }\n testID=\"genesis-force-upgrade-state\"\n />\n </View>\n );\n}\n\nexport interface MaintenanceProps {\n /** The policy's message, or `null` for the default copy. */\n message: string | null;\n retry: () => void;\n retrying: boolean;\n}\n\n/** Blocking: the policy says maintenance is on. \"Try again\" asks again. */\nexport function MaintenanceScreen({ message, retry, retrying }: MaintenanceProps) {\n return (\n <View testID=\"genesis-maintenance\" className=\"flex-1 justify-center bg-background\">\n <NativeEmptyState\n variant=\"first-run\"\n title=\"Down for maintenance\"\n body={message ?? \"We're doing some work on the app. Try again in a few minutes.\"}\n primaryAction={\n <NativeButton onPress={retry} loading={retrying} testID=\"genesis-maintenance-retry\">\n Try again\n </NativeButton>\n }\n testID=\"genesis-maintenance-state\"\n />\n </View>\n );\n}\n\nexport interface UpdateBannerProps {\n /** Reload into the downloaded update (refused while `canReload` is false). */\n reload: () => void;\n /** Hide the banner; the update still applies on the next cold start. */\n dismiss: () => void;\n /** False while something is mid-edit (`useBlockReload`) or your `canReload` says no. */\n canReload: boolean;\n /** The last tap was refused because something is mid-edit. */\n blocked: boolean;\n reloading: boolean;\n}\n\n/**\n * Non-blocking: floats over the top of the screens while an update is\n * downloaded. Liquid Glass on iOS 26 when the app passed expo-glass-effect\n * (`modules.glass`); the solid secondary surface otherwise.\n */\nexport function UpdateBanner({ reload, dismiss, canReload, blocked, reloading }: UpdateBannerProps) {\n // On glass the message drops its own fill, or it would cover the glass.\n const onGlass = useLiquidGlass() !== null;\n return (\n <SafeAreaView edges={[\"top\"]} pointerEvents=\"box-none\" style={{ position: \"absolute\", top: 0, left: 0, right: 0 }}>\n <View className=\"mx-3 mt-2\">\n <NativeGlassSurface testID=\"genesis-update-banner\" fallbackClassName=\"overflow-hidden rounded-lg border border-border bg-secondary\">\n <NativeBanner\n variant=\"info\"\n title=\"An update is ready\"\n description={blocked || !canReload ? \"Finish what you're doing, then restart to use it.\" : \"Restart to use the latest version.\"}\n className={onGlass ? \"border-b-0 border-transparent bg-transparent\" : \"border-b-0\"}\n testID=\"genesis-update-banner-message\"\n />\n <View className=\"flex-row justify-end gap-2 px-4 pb-3\">\n <NativeButton variant=\"ghost\" size=\"sm\" onPress={dismiss} testID=\"genesis-update-banner-later\">\n Later\n </NativeButton>\n <NativeButton size=\"sm\" onPress={reload} disabled={!canReload} loading={reloading} testID=\"genesis-update-banner-restart\">\n Restart\n </NativeButton>\n </View>\n </NativeGlassSurface>\n </View>\n </SafeAreaView>\n );\n}\n\nexport interface WhatsNewProps {\n /** Newest first. */\n notes: readonly ReleaseNote[];\n /** The installed version. */\n version: string | null;\n /** Close and remember this version. */\n dismiss: () => void;\n}\n\n/** The release notes for this version, once, in a sheet. */\nexport function WhatsNewSheet({ notes, dismiss }: WhatsNewProps) {\n return (\n <NativeSheet open onOpenChange={(open) => (open ? undefined : dismiss())} testID=\"genesis-whats-new\">\n {/* The notes scroll once they pass the sheet's height. */}\n <NativeSheetScrollView contentContainerClassName=\"gap-4 p-6\">\n <NativeText preset=\"h3\" accessibilityRole=\"header\">\n What's new\n </NativeText>\n {notes.map((note) => (\n <View key={note.version} className=\"gap-1\" testID={`genesis-whats-new-${note.version}`}>\n <NativeText preset=\"label\">{note.title ?? `Version ${note.version}`}</NativeText>\n <NativeText preset=\"body-sm\" className=\"text-muted-foreground\">\n {note.body}\n </NativeText>\n </View>\n ))}\n <NativeButton onPress={dismiss} testID=\"genesis-whats-new-done\">\n Got it\n </NativeButton>\n </NativeSheetScrollView>\n </NativeSheet>\n );\n}\n","/**\n * `createUpdates(options)`: the updates block. Pass the result to\n * `<GenesisNativeApp updates={updates}>` (removing that line turns the block\n * off), or render `<UpdatesRoot block={updates}>` yourself.\n *\n * UpdatesRoot\n * ├ forceUpgrade (blocking: below the policy's minimum version)\n * ├ maintenance (blocking: the policy's maintenance switch, fetched live)\n * └ your screens\n * ├ updateBanner (non-blocking: an update is downloaded; reload on tap)\n * └ whatsNew (release notes, once per version)\n *\n * Every renderer is a slot, a primitive (`ForceUpgradeScreen`, …) and a hook\n * (`useForceUpgrade`, …).\n *\n * The block is also a `defineBlock` declaration (`id: \"app-updates\"`), so\n * `<GenesisNativeApp blocks={[updates]}>` runs it too. It contributes a\n * Settings row with the version signature (section `about`; see\n * `useBlockSettings`) and names the release-policy migration it reads.\n */\nimport { createContext, useContext, useEffect, useMemo, useState, useSyncExternalStore, type ComponentType, type ReactNode } from \"react\";\nimport { View } from \"react-native\";\nimport { renderSlot, type SlotPropsFor, type Slots } from \"@marktiderman/genesis-core/slots\";\nimport { defineBlock } from \"@marktiderman/genesis-features/blocks\";\nimport type { NativeBlock } from \"../blocks\";\nimport { createUpdateChecker, createReloadGuard, type ReloadGuard, type UpdateChecker, type UpdateCheckState } from \"./checker\";\nimport { createChannelSwitcher, type ChannelSwitcher } from \"./channels\";\nimport { delay } from \"./store\";\nimport {\n WEEK_MS,\n createPolicyStore,\n validTimeout,\n evaluatePolicy,\n type PolicyState,\n type PolicyStore,\n type ReleaseNote,\n type UpdatePolicySource,\n type UpdateVerdict,\n} from \"./policy\";\nimport { versionSignature, type VersionSignature } from \"./signature\";\nimport { createWhatsNewStore, type WhatsNewState, type WhatsNewStore } from \"./whats-new\";\nimport {\n ForceUpgradeScreen,\n MaintenanceScreen,\n UpdateBanner,\n WhatsNewSheet,\n type ForceUpgradeProps,\n type MaintenanceProps,\n type UpdateBannerProps,\n type WhatsNewProps,\n} from \"./screens\";\nimport { toError, type ApplicationLike, type UpdatesAppStateLike, type UpdatesModuleLike, type UpdatesOnError, type UpdatesStorageLike } from \"./modules\";\n\n// A type, not an interface, so it fits the slots contract's Record constraint.\nexport type UpdatesSlots = {\n /** Blocking. Default `ForceUpgradeScreen`. */\n forceUpgrade: ForceUpgradeProps;\n /** Blocking. Default `MaintenanceScreen`. */\n maintenance: MaintenanceProps;\n /** Over your screens while an update is downloaded. Default `UpdateBanner`. */\n updateBanner: UpdateBannerProps;\n /** Once per version. Default `WhatsNewSheet`. */\n whatsNew: WhatsNewProps;\n};\n\nexport interface UpdatesOptions {\n /** `Platform.OS`. Force upgrade applies to `ios` and `android` only. */\n platform: string;\n /** `expo-application`: the installed version. Without it, nothing is ever forced and notes never show. */\n application?: ApplicationLike;\n /** `expo-updates`. Without it (or with updates off), no banner and no channel switching. */\n updates?: UpdatesModuleLike;\n /** Min versions, maintenance and notes. Without it, only `notes` and the banner. */\n policy?: UpdatePolicySource;\n /** AsyncStorage: the policy cache, the version whose notes were seen, the picked channel. */\n storage?: UpdatesStorageLike;\n /** `AppState`: ask again when the app comes to the front. */\n appState?: UpdatesAppStateLike;\n /** `Linking.openURL`, for the store link. */\n openURL?: (url: string) => unknown;\n /** Extra say over reloading (return false to hold it off); `useBlockReload` covers forms. */\n canReload?: () => boolean;\n /** Release notes written in the app, merged with the policy's. */\n notes?: readonly ReleaseNote[];\n /** `false` turns what's new off. */\n whatsNew?: boolean;\n /** Channel switching, for development and preview builds only: `{ enabled: __DEV__ || isPreview }`. */\n channels?: { enabled: boolean };\n /** The longest the first policy load holds the splash. Default 3000 ms. */\n policyTimeoutMs?: number;\n /** How old a cached policy may be and still force an upgrade. Default 7 days. */\n cacheMaxAgeMs?: number;\n /** Ask for the policy again on coming to the front at most this often. Default 5 minutes. */\n policyRefreshMs?: number;\n /** Check for an update on coming to the front at most this often. Default 15 minutes. */\n checkIntervalMs?: number;\n /** `reloadAsync`'s reload screen (background color, spinner). */\n reloadScreenOptions?: object;\n /**\n * The Settings row with the version signature the block contributes\n * (`useBlockSettings`): its title and section, or `false` for none.\n * Default `{ title: \"Version\", section: \"about\" }`.\n */\n versionRow?: false | { title?: string; section?: string };\n /** Storage key prefix. Default `\"genesis:updates\"`. */\n storageKeyPrefix?: string;\n /** Every caught error, for reporting. None of them blocks anyone. */\n onError?: UpdatesOnError;\n now?: () => number;\n}\n\n/** The FeatureId of the updates block. */\nexport const UPDATES_BLOCK_ID = \"app-updates\";\n\nexport interface UpdatesBlock extends NativeBlock<typeof UPDATES_BLOCK_ID> {\n readonly options: UpdatesOptions;\n readonly policy: PolicyStore;\n readonly checker: UpdateChecker;\n readonly guard: ReloadGuard;\n readonly whatsNew: WhatsNewStore;\n /** Channel switching: `switchTo` throws unless `channels.enabled` was passed; `reset` always works. */\n readonly channels: ChannelSwitcher;\n /** The signature from the modules, without the picked channel (see `useVersionSignature`). */\n readonly signature: VersionSignature;\n /** Loads the policy and the seen version behind the splash; never fails, done within `policyTimeoutMs`. */\n readonly bootStep: { id: string; run: () => Promise<void>; timeoutMs: number };\n /** `[bootStep]`, for a shell that runs blocks. */\n readonly bootSteps: readonly { id: string; run: () => Promise<void>; timeoutMs: number }[];\n /** Start following the app's state; returns the stop. `UpdatesRoot` calls it. */\n start(): () => void;\n /** The block's root, for `GenesisNativeApp`. */\n readonly Root: ComponentType<Omit<UpdatesRootProps, \"block\">>;\n}\n\n/** Build the block once, at module scope, next to your Supabase client. */\nexport function createUpdates(options: UpdatesOptions): UpdatesBlock {\n const {\n platform,\n application,\n updates,\n policy: source,\n storage,\n appState,\n canReload,\n channels,\n policyRefreshMs = 5 * 60_000,\n checkIntervalMs = 15 * 60_000,\n reloadScreenOptions,\n storageKeyPrefix = \"genesis:updates\",\n onError,\n now = Date.now,\n } = options;\n const policyTimeoutMs = validTimeout(options.policyTimeoutMs, 3000);\n const guard = createReloadGuard(canReload);\n const policy = createPolicyStore({\n source: source ?? { load: async () => null },\n storage: source ? storage : undefined,\n cacheKey: `${storageKeyPrefix}:policy`,\n timeoutMs: policyTimeoutMs,\n now,\n onError,\n });\n const checker = createUpdateChecker({ updates, guard, reloadScreenOptions, now, onError });\n const whatsNew = createWhatsNewStore({\n storage: options.whatsNew === false ? undefined : storage,\n version: options.whatsNew === false ? null : (application?.nativeApplicationVersion ?? null),\n storageKey: `${storageKeyPrefix}:seen-version`,\n onError,\n });\n const switcher = createChannelSwitcher({\n updates,\n enabled: channels?.enabled === true,\n guard,\n storage,\n storageKey: `${storageKeyPrefix}:channel`,\n reloadScreenOptions,\n onError,\n });\n const signature = versionSignature({ application, updates, platform });\n\n const allNotes = (): ReleaseNote[] => [...(options.notes ?? []), ...(policy.getState().policy?.notes ?? [])];\n const syncNotes = () => {\n const state = policy.getState();\n // Final once the policy has answered from the network (or there is none): no more notes can arrive.\n whatsNew.update(allNotes(), !source || state.origin === \"network\");\n };\n policy.subscribe(syncNotes);\n\n let loaded: Promise<void> | null = null;\n // Bounded and never rejects, so the boot step can't time out or fail the boot (a stalled storage read included).\n const load = () => {\n loaded ??= Promise.race([Promise.all([policy.load(), whatsNew.load()]), delay(policyTimeoutMs)])\n .then(syncNotes)\n .catch((error) => {\n try {\n onError?.(toError(error), \"storage\");\n } catch {\n // ignore a failing reporter\n }\n });\n return loaded;\n };\n\n const bootStep = { id: \"genesis:updates\", run: load, timeoutMs: policyTimeoutMs + 5000 };\n const { versionRow } = options;\n const declaration = defineBlock<typeof UPDATES_BLOCK_ID, ComponentType<never>>({\n id: UPDATES_BLOCK_ID,\n platforms: [\"native\"],\n contributes: {\n settings:\n versionRow === false\n ? []\n : [\n {\n id: \"app-version\",\n section: versionRow?.section ?? \"about\",\n title: versionRow?.title ?? \"Version\",\n testID: \"genesis-app-version\",\n // Bound to this block, so it needs no provider above the Settings screen.\n useSubtitle: () => useVersionSignatureOf(block).short,\n },\n ],\n migrations: [\n {\n package: \"@marktiderman/genesis-supabase\",\n file: \"migrations/0002_genesis_app_release_policy.sql\",\n test: \"migrations/tests/0002_genesis_app_release_policy.test.sql\",\n },\n ],\n privacy: { notes: [\"Reads the installed version and update ids on the device to decide on a force upgrade; sends nothing about the person.\"] },\n },\n });\n\n const block: UpdatesBlock = {\n ...declaration,\n options,\n policy,\n checker,\n guard,\n whatsNew,\n channels: switcher,\n signature,\n bootStep,\n bootSteps: [bootStep],\n start() {\n void load();\n void checker.check();\n const subscription = appState?.addEventListener(\"change\", (state) => {\n if (state !== \"active\") return;\n void policy.refreshIfDue(policyRefreshMs);\n void checker.checkIfDue(checkIntervalMs);\n });\n return () => subscription?.remove();\n },\n Root: function UpdatesBlockRoot(props) {\n return <UpdatesRoot block={block} {...props} />;\n },\n };\n return block;\n}\n\nconst UpdatesContext = createContext<UpdatesBlock | null>(null);\n\n/** Provides the block to the hooks, without rendering any of its parts (rung 4). */\nexport function UpdatesProvider({ block, children }: { block: UpdatesBlock; children?: ReactNode }) {\n return <UpdatesContext.Provider value={block}>{children}</UpdatesContext.Provider>;\n}\n\n/** The block from `UpdatesProvider` / `UpdatesRoot` / `GenesisNativeApp`. Throws outside one. */\nexport function useUpdates(): UpdatesBlock {\n const block = useContext(UpdatesContext);\n if (!block) throw new Error(\"useUpdates: no updates block. Pass `updates={createUpdates(…)}` to GenesisNativeApp, or wrap in <UpdatesProvider>.\");\n return block;\n}\n\n/**\n * Hold reloads off while `active` (a form with unsaved changes):\n * `useBlockReload(form.formState.isDirty)`. Does nothing without an updates\n * block, so a screen can call it whether or not the block is on.\n */\nexport function useBlockReload(active: boolean) {\n const block = useContext(UpdatesContext);\n useEffect(() => (active && block ? block.guard.block() : undefined), [active, block]);\n}\n\nexport function useUpdatePolicy(): PolicyState {\n const { policy } = useUpdates();\n return useSyncExternalStore(policy.subscribe, policy.getState, policy.getState);\n}\n\n/** What the policy says now: `ok`, `forceUpgrade` or `maintenance`. */\nexport function useUpdateVerdict(): UpdateVerdict {\n const block = useUpdates();\n const state = useUpdatePolicy();\n const { platform, application, cacheMaxAgeMs = WEEK_MS, now = Date.now } = block.options;\n return useMemo(\n () => evaluatePolicy(state, { platform, installedVersion: application?.nativeApplicationVersion ?? null, now: now(), cacheMaxAgeMs }),\n [state, platform, application, cacheMaxAgeMs, now],\n );\n}\n\n/** The force-upgrade screen's props, or `null` when this version is supported. */\nexport function useForceUpgrade(): ForceUpgradeProps | null {\n const block = useUpdates();\n const verdict = useUpdateVerdict();\n const { refreshing } = useUpdatePolicy();\n if (verdict.kind !== \"forceUpgrade\") return null;\n const { storeUrl } = verdict;\n return {\n minimumVersion: verdict.minimumVersion,\n installedVersion: verdict.installedVersion,\n storeUrl,\n checking: refreshing,\n retry: () => void block.policy.refresh(),\n openStore: () => {\n if (!block.options.openURL) return;\n Promise.resolve()\n .then(() => block.options.openURL?.(storeUrl))\n .catch((error) => block.options.onError?.(toError(error), \"policy\"));\n },\n };\n}\n\n/** The maintenance screen's props, or `null` when maintenance is off (or not known live). */\nexport function useMaintenance(): MaintenanceProps | null {\n const block = useUpdates();\n const verdict = useUpdateVerdict();\n const { refreshing } = useUpdatePolicy();\n if (verdict.kind !== \"maintenance\") return null;\n return { message: verdict.message, retrying: refreshing, retry: () => void block.policy.refresh() };\n}\n\nexport function useUpdateCheck(): UpdateCheckState {\n const { checker } = useUpdates();\n return useSyncExternalStore(checker.subscribe, checker.getState, checker.getState);\n}\n\n/** True when a reload would be allowed now. */\nexport function useCanReload(): boolean {\n const { guard } = useUpdates();\n return useSyncExternalStore(guard.subscribe, guard.canReload, guard.canReload);\n}\n\n/** The banner's props, or `null` when there is nothing to show. */\nexport function useUpdateBanner(): UpdateBannerProps | null {\n const { checker } = useUpdates();\n const state = useUpdateCheck();\n const canReload = useCanReload();\n if ((state.status !== \"ready\" && state.status !== \"reloading\") || state.dismissed) return null;\n return {\n canReload,\n blocked: state.blocked,\n reloading: state.status === \"reloading\",\n reload: () => void checker.reload(),\n dismiss: () => checker.dismiss(),\n };\n}\n\n/** The notes to show now, or `null`. */\nexport function useWhatsNew(): WhatsNewProps | null {\n const block = useUpdates();\n const state: WhatsNewState = useSyncExternalStore(block.whatsNew.subscribe, block.whatsNew.getState, block.whatsNew.getState);\n if (state.status !== \"showing\") return null;\n return { notes: state.notes, version: block.options.application?.nativeApplicationVersion ?? null, dismiss: () => block.whatsNew.dismiss() };\n}\n\n/** The version signature, with the channel picked on this device once it has been read. */\nexport function useVersionSignature(): VersionSignature {\n return useVersionSignatureOf(useUpdates());\n}\n\nfunction useVersionSignatureOf(block: UpdatesBlock): VersionSignature {\n const [requested, setRequested] = useState<string | null>(null);\n useEffect(() => {\n let alive = true;\n void block.channels.requested().then((value) => alive && setRequested(value));\n return () => {\n alive = false;\n };\n }, [block]);\n return useMemo(() => {\n if (!requested) return block.signature;\n const { application, updates, platform } = block.options;\n return versionSignature({ application, updates, platform, requestedChannel: requested });\n }, [block, requested]);\n}\n\nexport interface UpdatesRootProps {\n block: UpdatesBlock;\n slots?: Slots<UpdatesSlots>;\n slotProps?: SlotPropsFor<UpdatesSlots>;\n children?: ReactNode;\n}\n\n/** The block's parts around your screens. */\nexport function UpdatesRoot({ block, slots, slotProps, children }: UpdatesRootProps) {\n useEffect(() => block.start(), [block]);\n return (\n <UpdatesProvider block={block}>\n <UpdatesParts slots={slots} slotProps={slotProps}>\n {children}\n </UpdatesParts>\n </UpdatesProvider>\n );\n}\n\nconst FILL = { position: \"absolute\", top: 0, right: 0, bottom: 0, left: 0 } as const;\n\nfunction UpdatesParts({ slots, slotProps, children }: Omit<UpdatesRootProps, \"block\">) {\n const forceUpgrade = useForceUpgrade();\n const maintenance = useMaintenance();\n const banner = useUpdateBanner();\n const whatsNew = useWhatsNew();\n // An ejected blocking slot (`null`) falls through to the screens: a block that is turned off never blocks.\n const blocking =\n forceUpgrade && slots?.forceUpgrade !== null\n ? renderSlot(ForceUpgradeScreen, slots?.forceUpgrade, forceUpgrade, slotProps?.forceUpgrade)\n : maintenance && slots?.maintenance !== null\n ? renderSlot(MaintenanceScreen, slots?.maintenance, maintenance, slotProps?.maintenance)\n : null;\n // The screens stay mounted under a blocking screen, so a block that starts and ends\n // mid-session (maintenance on, then off) keeps a half-filled form and the navigation state.\n return (\n <View style={{ flex: 1 }}>\n <View\n style={{ flex: 1 }}\n pointerEvents={blocking ? \"none\" : \"auto\"}\n accessibilityElementsHidden={Boolean(blocking)}\n importantForAccessibility={blocking ? \"no-hide-descendants\" : \"auto\"}\n >\n {children}\n </View>\n {!blocking && banner ? renderSlot(UpdateBanner, slots?.updateBanner, banner, slotProps?.updateBanner) : null}\n {!blocking && whatsNew ? renderSlot(WhatsNewSheet, slots?.whatsNew, whatsNew, slotProps?.whatsNew) : null}\n {blocking ? (\n <View style={FILL} testID=\"genesis-updates-blocking\">\n {blocking}\n </View>\n ) : null}\n </View>\n );\n}\n"]}