@marktiderman/genesis-native 0.8.0 → 0.10.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 (40) hide show
  1. package/README.md +22 -14
  2. package/dist/{block-q6_CV0WK.d.ts → block-CQz1pOnm.d.ts} +4 -4
  3. package/dist/{blocks-ByVBKaQW.d.ts → blocks-dppiMmy-.d.ts} +7 -4
  4. package/dist/{chunk-6L36FQBX.js → chunk-EWHO5WQU.js} +3 -3
  5. package/dist/{chunk-6L36FQBX.js.map → chunk-EWHO5WQU.js.map} +1 -1
  6. package/dist/{chunk-C54LIT4N.js → chunk-FKDZP3RJ.js} +2 -2
  7. package/dist/chunk-FKDZP3RJ.js.map +1 -0
  8. package/dist/{chunk-MFHOHSEQ.js → chunk-YIF4BFQH.js} +33 -28
  9. package/dist/chunk-YIF4BFQH.js.map +1 -0
  10. package/dist/devtools.d.ts +5 -5
  11. package/dist/devtools.js +2 -2
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +9 -8
  14. package/dist/index.js.map +1 -1
  15. package/dist/observability.d.ts +5 -5
  16. package/dist/observability.js +3 -3
  17. package/dist/offline.d.ts +40 -0
  18. package/dist/offline.js +118 -0
  19. package/dist/offline.js.map +1 -0
  20. package/dist/persist.d.ts +11 -3
  21. package/dist/persist.js +6 -3
  22. package/dist/persist.js.map +1 -1
  23. package/dist/push.d.ts +3 -3
  24. package/dist/{query-DobJyRvs.d.ts → query--ihYsJWC.d.ts} +31 -9
  25. package/dist/{screen-boundary-BlT6KBpa.d.ts → screen-boundary-B8DlsLwb.d.ts} +8 -4
  26. package/dist/updates.d.ts +2 -2
  27. package/dist/updates.js +10 -10
  28. package/dist/updates.js.map +1 -1
  29. package/package.json +15 -10
  30. package/src/app.tsx +9 -6
  31. package/src/errors.tsx +56 -22
  32. package/src/index.ts +2 -0
  33. package/src/observability/block.tsx +1 -1
  34. package/src/offline/sqlite-local-cache.ts +161 -0
  35. package/src/persist.ts +16 -4
  36. package/src/query.ts +5 -2
  37. package/src/screen-boundary.tsx +13 -21
  38. package/src/updates/screens.tsx +10 -22
  39. package/dist/chunk-C54LIT4N.js.map +0 -1
  40. package/dist/chunk-MFHOHSEQ.js.map +0 -1
@@ -0,0 +1,118 @@
1
+ export { cacheScope, persistOffline } from '@marktiderman/genesis-core/offline';
2
+
3
+ // src/offline/sqlite-local-cache.ts
4
+ var SCHEMA = `
5
+ pragma busy_timeout = 5000;
6
+ create table if not exists genesis_offline_rows (
7
+ scope text not null, resource text not null, id text not null,
8
+ row text not null, fetched_at integer not null,
9
+ primary key (scope, resource, id)
10
+ );
11
+ create table if not exists genesis_offline_queries (
12
+ scope text not null, key text not null, query_key text not null,
13
+ resource text not null, data text not null, fetched_at integer not null,
14
+ primary key (scope, key)
15
+ );`;
16
+ function assertScope(scope) {
17
+ if (!/^u:[^|]+\|/.test(scope)) {
18
+ throw new Error(`[genesis offline] "${scope}" isn't a person's cache scope: build it with cacheScope(userId, workspace).`);
19
+ }
20
+ }
21
+ var likePrefix = (prefix) => `${prefix.replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
22
+ function sqliteLocalCache({ db }) {
23
+ let ready = null;
24
+ const open = () => {
25
+ ready ??= db.execAsync(SCHEMA).catch((error) => {
26
+ ready = null;
27
+ throw error;
28
+ });
29
+ return ready;
30
+ };
31
+ return {
32
+ async readQueries(scope) {
33
+ assertScope(scope);
34
+ await open();
35
+ const rows = await db.getAllAsync(
36
+ "select key, query_key, resource, data, fetched_at from genesis_offline_queries where scope = ?",
37
+ [scope]
38
+ );
39
+ return rows.map(
40
+ (r) => ({
41
+ key: r.key,
42
+ queryKey: JSON.parse(r.query_key),
43
+ resource: r.resource,
44
+ data: JSON.parse(r.data),
45
+ fetchedAt: r.fetched_at
46
+ })
47
+ );
48
+ },
49
+ async readRows(scope, resource, ids) {
50
+ assertScope(scope);
51
+ if (ids.length === 0) return [];
52
+ await open();
53
+ const out = [];
54
+ for (let i = 0; i < ids.length; i += 500) {
55
+ const chunk = ids.slice(i, i + 500);
56
+ const rows = await db.getAllAsync(
57
+ `select id, row, fetched_at from genesis_offline_rows where scope = ? and resource = ? and id in (${chunk.map(() => "?").join(",")})`,
58
+ [scope, resource, ...chunk]
59
+ );
60
+ for (const r of rows) out.push({ resource, id: r.id, row: JSON.parse(r.row), fetchedAt: r.fetched_at });
61
+ }
62
+ return out;
63
+ },
64
+ async write(scope, ops) {
65
+ assertScope(scope);
66
+ if (ops.length === 0) return;
67
+ await open();
68
+ await db.withExclusiveTransactionAsync(async (txn) => {
69
+ for (const op of ops) {
70
+ if (op.kind === "row") {
71
+ await txn.runAsync(
72
+ `insert into genesis_offline_rows (scope, resource, id, row, fetched_at) values (?, ?, ?, ?, ?)
73
+ on conflict (scope, resource, id) do update set row = excluded.row, fetched_at = excluded.fetched_at
74
+ where excluded.fetched_at >= genesis_offline_rows.fetched_at`,
75
+ [scope, op.row.resource, op.row.id, JSON.stringify(op.row.row), op.row.fetchedAt]
76
+ );
77
+ } else if (op.kind === "query") {
78
+ await txn.runAsync(
79
+ "insert or replace into genesis_offline_queries (scope, key, query_key, resource, data, fetched_at) values (?, ?, ?, ?, ?, ?)",
80
+ [scope, op.query.key, JSON.stringify(op.query.queryKey), op.query.resource, JSON.stringify(op.query.data), op.query.fetchedAt]
81
+ );
82
+ } else if (op.kind === "forget") {
83
+ await txn.runAsync(
84
+ `delete from genesis_offline_queries where scope = ? and key = ?${op.before === void 0 ? "" : " and fetched_at < ?"}`,
85
+ op.before === void 0 ? [scope, op.key] : [scope, op.key, op.before]
86
+ );
87
+ } else if (op.kind === "drop") {
88
+ await txn.runAsync("delete from genesis_offline_rows where scope = ? and resource = ? and id = ?", [scope, op.resource, op.id]);
89
+ } else {
90
+ const ids = await txn.getAllAsync(
91
+ "select id from genesis_offline_rows where scope = ? and resource = ? and fetched_at < ?",
92
+ [scope, op.resource, op.before]
93
+ );
94
+ const keep = new Set(op.keep);
95
+ for (const { id } of ids) {
96
+ if (!keep.has(id)) await txn.runAsync("delete from genesis_offline_rows where scope = ? and resource = ? and id = ?", [scope, op.resource, id]);
97
+ }
98
+ }
99
+ }
100
+ });
101
+ },
102
+ async clear(target) {
103
+ await open();
104
+ await db.withExclusiveTransactionAsync(async (txn) => {
105
+ for (const table of ["genesis_offline_rows", "genesis_offline_queries"]) {
106
+ if (!target) await txn.runAsync(`delete from ${table}`, []);
107
+ else if ("scope" in target) await txn.runAsync(`delete from ${table} where scope = ?`, [target.scope]);
108
+ else if ("user" in target) await txn.runAsync(`delete from ${table} where scope like ? escape '\\'`, [likePrefix(`u:${target.user}|`)]);
109
+ else await txn.runAsync(`delete from ${table} where scope not like ? escape '\\'`, [likePrefix(`u:${target.except}|`)]);
110
+ }
111
+ });
112
+ }
113
+ };
114
+ }
115
+
116
+ export { sqliteLocalCache };
117
+ //# sourceMappingURL=offline.js.map
118
+ //# sourceMappingURL=offline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/offline/sqlite-local-cache.ts"],"names":[],"mappings":";;;AA6BA,IAAM,MAAA,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AAaf,SAAS,YAAY,KAAA,EAAqB;AACxC,EAAA,IAAI,CAAC,YAAA,CAAa,IAAA,CAAK,KAAK,CAAA,EAAG;AAC7B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK,CAAA,4EAAA,CAA8E,CAAA;AAAA,EAC3H;AACF;AAGA,IAAM,UAAA,GAAa,CAAC,MAAA,KAAmB,CAAA,EAAG,MAAA,CAAO,OAAA,CAAQ,SAAA,EAAW,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA;AAW7E,SAAS,gBAAA,CAAiB,EAAE,EAAA,EAAG,EAAwC;AAC5E,EAAA,IAAI,KAAA,GAA8B,IAAA;AAClC,EAAA,MAAM,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AAAA,QACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IAEA,MAAM,MAAM,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAA,EAAK;AACX,MAAA,MAAM,EAAA,CAAG,6BAAA,CAA8B,OAAO,GAAA,KAAQ;AACpD,QAAA,KAAA,MAAW,KAAA,IAAS,CAAC,sBAAA,EAAwB,yBAAyB,CAAA,EAAG;AACvE,UAAA,IAAI,CAAC,QAAQ,MAAM,GAAA,CAAI,SAAS,CAAA,YAAA,EAAe,KAAK,CAAA,CAAA,EAAI,EAAE,CAAA;AAAA,eAAA,IACjD,OAAA,IAAW,MAAA,EAAQ,MAAM,GAAA,CAAI,QAAA,CAAS,CAAA,YAAA,EAAe,KAAK,CAAA,gBAAA,CAAA,EAAoB,CAAC,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,eAAA,IAC5F,MAAA,IAAU,MAAA,EAAQ,MAAM,GAAA,CAAI,SAAS,CAAA,YAAA,EAAe,KAAK,CAAA,+BAAA,CAAA,EAAmC,CAAC,WAAW,CAAA,EAAA,EAAK,MAAA,CAAO,IAAI,CAAA,CAAA,CAAG,CAAC,CAAC,CAAA;AAAA,eACjI,MAAM,GAAA,CAAI,QAAA,CAAS,CAAA,YAAA,EAAe,KAAK,CAAA,mCAAA,CAAA,EAAuC,CAAC,UAAA,CAAW,CAAA,EAAA,EAAK,MAAA,CAAO,MAAM,CAAA,CAAA,CAAG,CAAC,CAAC,CAAA;AAAA,QACxH;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"offline.js","sourcesContent":["/**\n * `@marktiderman/genesis-native/offline`: the phone's device cache, in SQLite\n * (expo-sqlite), so lists and records open at once (ADR 0010, slice 1).\n *\n * import * as SQLite from \"expo-sqlite\";\n * import { persistOffline, sqliteLocalCache } from \"@marktiderman/genesis-native/offline\";\n *\n * const db = SQLite.openDatabaseSync(\"genesis-offline.db\");\n * <GenesisNativeApp persist={persistOffline({ cache: sqliteLocalCache({ db }), resources: [\"tasks\"], buster: version })} … />\n *\n * @stability Beta\n */\nimport type { CacheOp, LocalCache, StoredQuery, StoredRow } from \"@marktiderman/genesis-core/offline\";\n\n/** The part of expo-sqlite's `SQLiteDatabase` this uses (op-sqlite fits behind a small wrapper). */\nexport interface SQLiteDatabaseLike {\n execAsync(source: string): Promise<void>;\n runAsync(source: string, params: (string | number | null)[]): Promise<unknown>;\n getAllAsync<T>(source: string, params: (string | number | null)[]): Promise<T[]>;\n /** Runs `task` in one exclusive transaction, so a write lands whole or not at all. */\n withExclusiveTransactionAsync(task: (txn: SQLiteDatabaseLike) => Promise<void>): Promise<void>;\n}\n\n/** Options for {@link sqliteLocalCache}. */\nexport interface SqliteLocalCacheOptions {\n db: SQLiteDatabaseLike;\n}\n\n// busy_timeout: a clear at sign-out that overlaps a save waits for it instead of failing.\nconst SCHEMA = `\npragma busy_timeout = 5000;\ncreate table if not exists genesis_offline_rows (\n scope text not null, resource text not null, id text not null,\n row text not null, fetched_at integer not null,\n primary key (scope, resource, id)\n);\ncreate table if not exists genesis_offline_queries (\n scope text not null, key text not null, query_key text not null,\n resource text not null, data text not null, fetched_at integer not null,\n primary key (scope, key)\n);`;\n\nfunction assertScope(scope: string): void {\n if (!/^u:[^|]+\\|/.test(scope)) {\n throw new Error(`[genesis offline] \"${scope}\" isn't a person's cache scope: build it with cacheScope(userId, workspace).`);\n }\n}\n\n/** `LIKE` matches `_` and `%` as wildcards: escape them in a person's prefix. */\nconst likePrefix = (prefix: string) => `${prefix.replace(/[\\\\%_]/g, (c) => `\\\\${c}`)}%`;\n\n/**\n * A `LocalCache` in SQLite, for the phone. Rows and queries are separate\n * tables keyed by scope, so one row is stored once whatever lists hold it,\n * and every write runs in one exclusive transaction. Values are stored as\n * JSON, so a `Date` in a read comes back as its ISO text (rows from Supabase\n * are text already).\n *\n * @stability Beta\n */\nexport function sqliteLocalCache({ db }: SqliteLocalCacheOptions): LocalCache {\n let ready: Promise<void> | null = null;\n const open = () => {\n ready ??= db.execAsync(SCHEMA).catch((error: unknown) => {\n ready = null;\n throw error;\n });\n return ready;\n };\n\n return {\n async readQueries(scope) {\n assertScope(scope);\n await open();\n const rows = await db.getAllAsync<{ key: string; query_key: string; resource: string; data: string; fetched_at: number }>(\n \"select key, query_key, resource, data, fetched_at from genesis_offline_queries where scope = ?\",\n [scope],\n );\n return rows.map(\n (r): StoredQuery => ({\n key: r.key,\n queryKey: JSON.parse(r.query_key) as unknown[],\n resource: r.resource,\n data: JSON.parse(r.data) as unknown,\n fetchedAt: r.fetched_at,\n }),\n );\n },\n\n async readRows(scope, resource, ids) {\n assertScope(scope);\n if (ids.length === 0) return [];\n await open();\n const out: StoredRow[] = [];\n // SQLite caps bound parameters; read in chunks.\n for (let i = 0; i < ids.length; i += 500) {\n const chunk = ids.slice(i, i + 500);\n const rows = await db.getAllAsync<{ id: string; row: string; fetched_at: number }>(\n `select id, row, fetched_at from genesis_offline_rows where scope = ? and resource = ? and id in (${chunk.map(() => \"?\").join(\",\")})`,\n [scope, resource, ...chunk],\n );\n for (const r of rows) out.push({ resource, id: r.id, row: JSON.parse(r.row) as Record<string, unknown>, fetchedAt: r.fetched_at });\n }\n return out;\n },\n\n async write(scope, ops: readonly CacheOp[]) {\n assertScope(scope);\n if (ops.length === 0) return;\n await open();\n await db.withExclusiveTransactionAsync(async (txn) => {\n for (const op of ops) {\n if (op.kind === \"row\") {\n // An older read never overwrites a newer one.\n await txn.runAsync(\n `insert into genesis_offline_rows (scope, resource, id, row, fetched_at) values (?, ?, ?, ?, ?)\n on conflict (scope, resource, id) do update set row = excluded.row, fetched_at = excluded.fetched_at\n where excluded.fetched_at >= genesis_offline_rows.fetched_at`,\n [scope, op.row.resource, op.row.id, JSON.stringify(op.row.row), op.row.fetchedAt],\n );\n } else if (op.kind === \"query\") {\n await txn.runAsync(\n \"insert or replace into genesis_offline_queries (scope, key, query_key, resource, data, fetched_at) values (?, ?, ?, ?, ?, ?)\",\n [scope, op.query.key, JSON.stringify(op.query.queryKey), op.query.resource, JSON.stringify(op.query.data), op.query.fetchedAt],\n );\n } else if (op.kind === \"forget\") {\n await txn.runAsync(\n `delete from genesis_offline_queries where scope = ? and key = ?${op.before === undefined ? \"\" : \" and fetched_at < ?\"}`,\n op.before === undefined ? [scope, op.key] : [scope, op.key, op.before],\n );\n } else if (op.kind === \"drop\") {\n await txn.runAsync(\"delete from genesis_offline_rows where scope = ? and resource = ? and id = ?\", [scope, op.resource, op.id]);\n } else {\n const ids = await txn.getAllAsync<{ id: string }>(\n \"select id from genesis_offline_rows where scope = ? and resource = ? and fetched_at < ?\",\n [scope, op.resource, op.before],\n );\n const keep = new Set(op.keep);\n for (const { id } of ids) {\n if (!keep.has(id)) await txn.runAsync(\"delete from genesis_offline_rows where scope = ? and resource = ? and id = ?\", [scope, op.resource, id]);\n }\n }\n }\n });\n },\n\n async clear(target) {\n await open();\n await db.withExclusiveTransactionAsync(async (txn) => {\n for (const table of [\"genesis_offline_rows\", \"genesis_offline_queries\"]) {\n if (!target) await txn.runAsync(`delete from ${table}`, []);\n else if (\"scope\" in target) await txn.runAsync(`delete from ${table} where scope = ?`, [target.scope]);\n else if (\"user\" in target) await txn.runAsync(`delete from ${table} where scope like ? escape '\\\\'`, [likePrefix(`u:${target.user}|`)]);\n else await txn.runAsync(`delete from ${table} where scope not like ? escape '\\\\'`, [likePrefix(`u:${target.except}|`)]);\n }\n });\n },\n };\n}\n\nexport { cacheScope, persistOffline, type LocalCache, type PersistOfflineOptions, type QueryPersistence } from \"@marktiderman/genesis-core/offline\";\n"]}
package/dist/persist.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
- import { A as AsyncStorageLike, h as QueryPersistence } from './query-DobJyRvs.js';
2
+ import { A as AsyncStorageLike, j as QueryPersistence } from './query--ihYsJWC.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -37,9 +37,17 @@ interface PersistQueriesOptions {
37
37
  interface QueryPersistenceOptions extends PersistQueriesOptions {
38
38
  queryClient: QueryClient;
39
39
  }
40
- /** Save the allowlisted queries to async storage and restore them, with a max age, an app-version buster and a user scope. */
40
+ /**
41
+ * Save the allowlisted queries to async storage and restore them, with a max age, an app-version buster and a user scope.
42
+ *
43
+ * @deprecated Use `persistOffline` with `sqliteLocalCache` from `@marktiderman/genesis-native/offline`: it keeps each record once, per person and workspace. It needs expo-sqlite, a native module, so unless the app's builds already have it the switch takes a new native build and can't ship as an OTA update (https://github.com/marktiderman/genesis/blob/main/docs/MIGRATION.md). Removed in the next major.
44
+ */
41
45
  declare function createQueryPersistence({ queryClient, storage, keys, buster, maxAge, storageKey, throttleMs, }: QueryPersistenceOptions): QueryPersistence;
42
- /** `createQueryPersistence` for `GenesisNativeApp`'s `persist` prop, which supplies the client. */
46
+ /**
47
+ * `createQueryPersistence` for `GenesisNativeApp`'s `persist` prop, which supplies the client.
48
+ *
49
+ * @deprecated Use `persistOffline({ cache: sqliteLocalCache({ db }), resources, buster })` from `@marktiderman/genesis-native/offline`. It needs expo-sqlite, a native module, so unless the app's builds already have it the switch takes a new native build and can't ship as an OTA update (https://github.com/marktiderman/genesis/blob/main/docs/MIGRATION.md). Removed in the next major.
50
+ */
43
51
  declare function persistQueries(options: PersistQueriesOptions): (queryClient: QueryClient) => QueryPersistence;
44
52
 
45
53
  export { type PersistQueriesOptions, QueryPersistence, type QueryPersistenceOptions, createQueryPersistence, persistQueries };
package/dist/persist.js CHANGED
@@ -1,6 +1,6 @@
1
- import { DAY_MS } from './chunk-C54LIT4N.js';
1
+ import { DAY_MS } from './chunk-FKDZP3RJ.js';
2
2
  import { defaultShouldDehydrateQuery } from '@tanstack/react-query';
3
- import { persistQueryClientSubscribe, persistQueryClientRestore } from '@tanstack/query-persist-client-core';
3
+ import { persistQueryClientSave, persistQueryClientSubscribe, persistQueryClientRestore } from '@tanstack/query-persist-client-core';
4
4
  import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
5
5
 
6
6
  function createQueryPersistence({
@@ -27,7 +27,10 @@ function createQueryPersistence({
27
27
  } catch {
28
28
  }
29
29
  },
30
- subscribe: (scope) => persistQueryClientSubscribe({ queryClient, persister, buster: scoped(scope), dehydrateOptions }),
30
+ subscribe: (scope, options) => {
31
+ if (options?.adopt && scope) void persistQueryClientSave({ queryClient, persister, buster: scoped(scope), dehydrateOptions }).catch(() => void 0);
32
+ return persistQueryClientSubscribe({ queryClient, persister, buster: scoped(scope), dehydrateOptions });
33
+ },
31
34
  clear: async () => {
32
35
  await persister.removeClient();
33
36
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/persist.ts"],"names":[],"mappings":";;;;;AA0CO,SAAS,sBAAA,CAAuB;AAAA,EACrC,WAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA,GAAS,MAAA;AAAA,EACT,UAAA,GAAa,qBAAA;AAAA,EACb,UAAA,GAAa;AACf,CAAA,EAA8C;AAC5C,EAAA,MAAM,SAAA,GAAY,4BAA4B,EAAE,OAAA,EAAS,KAAK,UAAA,EAAY,YAAA,EAAc,YAAY,CAAA;AACpG,EAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,IAAI,CAAA;AAC5B,EAAA,MAAM,gBAAA,GAAmB;AAAA,IACvB,oBAAA,EAAsB,CAAC,KAAA,KACrB,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,QAAA,CAAS,CAAC,CAAC,CAAC,CAAA,IAAK,4BAA4B,KAAK,CAAA;AAAA;AAAA,IAE7E,yBAAyB,MAAM;AAAA,GACjC;AAGA,EAAA,MAAM,SAAS,CAAC,KAAA,KAAkB,CAAA,EAAG,MAAM,SAAS,KAAK,CAAA,CAAA;AACzD,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,OAAO,KAAA,KAAU;AACxB,MAAA,IAAI;AACF,QAAA,MAAM,yBAAA,CAA0B,EAAE,WAAA,EAAa,SAAA,EAAW,QAAQ,MAAA,CAAO,KAAK,CAAA,EAAG,MAAA,EAAQ,CAAA;AAAA,MAC3F,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF,CAAA;AAAA,IACA,SAAA,EAAW,CAAC,KAAA,KAAU,2BAAA,CAA4B,EAAE,WAAA,EAAa,SAAA,EAAW,MAAA,EAAQ,MAAA,CAAO,KAAK,CAAA,EAAG,gBAAA,EAAkB,CAAA;AAAA,IACrH,OAAO,YAAY;AACjB,MAAA,MAAM,UAAU,YAAA,EAAa;AAAA,IAC/B;AAAA,GACF;AACF;AAGO,SAAS,eAAe,OAAA,EAAgF;AAC7G,EAAA,OAAO,CAAC,WAAA,KAAgB,sBAAA,CAAuB,EAAE,GAAG,OAAA,EAAS,aAAa,CAAA;AAC5E","file":"persist.js","sourcesContent":["/**\n * `@marktiderman/genesis-native/persist`: save chosen queries to async storage\n * (AsyncStorage, MMKV, …) with TanStack's own persister, so restore,\n * throttling and max age are theirs.\n *\n * Install `@tanstack/query-persist-client-core` and\n * `@tanstack/query-async-storage-persister` at the same version as your\n * `@tanstack/react-query`: they pin `@tanstack/query-core` exactly, and two\n * copies of it would not share a cache.\n *\n * <GenesisNativeApp persist={persistQueries({ storage: AsyncStorage, keys: [\"clients\"], buster: version })} … />\n *\n * @stability Beta\n */\nimport { defaultShouldDehydrateQuery, type QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClientRestore, persistQueryClientSubscribe } from \"@tanstack/query-persist-client-core\";\nimport { createAsyncStoragePersister } from \"@tanstack/query-async-storage-persister\";\nimport { DAY_MS, type AsyncStorageLike, type QueryPersistence } from \"./query\";\n\nexport interface PersistQueriesOptions {\n storage: AsyncStorageLike;\n /**\n * The query-key roots to persist: a query is saved when its key's first\n * element is listed (`[\"clients\", id]` is saved under `\"clients\"`). Nothing\n * else is written to the phone.\n */\n keys: readonly string[];\n /** Your app's version: a different value discards the saved cache. */\n buster: string;\n /** How old a saved cache may be when restored. Default 24 hours. */\n maxAge?: number;\n /** Storage key. Default `\"genesis-query-cache\"`. */\n storageKey?: string;\n /** Write at most this often. Default 1000 ms. */\n throttleMs?: number;\n}\n\nexport interface QueryPersistenceOptions extends PersistQueriesOptions {\n queryClient: QueryClient;\n}\n\n/** Save the allowlisted queries to async storage and restore them, with a max age, an app-version buster and a user scope. */\nexport function createQueryPersistence({\n queryClient,\n storage,\n keys,\n buster,\n maxAge = DAY_MS,\n storageKey = \"genesis-query-cache\",\n throttleMs = 1000,\n}: QueryPersistenceOptions): QueryPersistence {\n const persister = createAsyncStoragePersister({ storage, key: storageKey, throttleTime: throttleMs });\n const allowed = new Set(keys);\n const dehydrateOptions = {\n shouldDehydrateQuery: (query: Parameters<typeof defaultShouldDehydrateQuery>[0]) =>\n allowed.has(String(query.queryKey[0])) && defaultShouldDehydrateQuery(query),\n // Mutations stay in memory: replaying a saved write is an outbox's job.\n shouldDehydrateMutation: () => false,\n };\n // The scope rides in the buster: TanStack discards (and deletes) a saved\n // cache whose buster differs, so another user's cache is never restored.\n const scoped = (scope: string) => `${buster}|user:${scope}`;\n return {\n restore: async (scope) => {\n try {\n await persistQueryClientRestore({ queryClient, persister, buster: scoped(scope), maxAge });\n } catch {\n // An unreadable cache has already been deleted; start without it rather than fail the boot.\n }\n },\n subscribe: (scope) => persistQueryClientSubscribe({ queryClient, persister, buster: scoped(scope), dehydrateOptions }),\n clear: async () => {\n await persister.removeClient();\n },\n };\n}\n\n/** `createQueryPersistence` for `GenesisNativeApp`'s `persist` prop, which supplies the client. */\nexport function persistQueries(options: PersistQueriesOptions): (queryClient: QueryClient) => QueryPersistence {\n return (queryClient) => createQueryPersistence({ ...options, queryClient });\n}\n\nexport type { QueryPersistence } from \"./query\";\n"]}
1
+ {"version":3,"sources":["../src/persist.ts"],"names":[],"mappings":";;;;;AA8CO,SAAS,sBAAA,CAAuB;AAAA,EACrC,WAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA,GAAS,MAAA;AAAA,EACT,UAA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YAAA,EAAa;AAAA,IAC/B;AAAA,GACF;AACF;AAOO,SAAS,eAAe,OAAA,EAAgF;AAC7G,EAAA,OAAO,CAAC,WAAA,KAAgB,sBAAA,CAAuB,EAAE,GAAG,OAAA,EAAS,aAAa,CAAA;AAC5E","file":"persist.js","sourcesContent":["/**\n * `@marktiderman/genesis-native/persist`: save chosen queries to async storage\n * (AsyncStorage, MMKV, …) with TanStack's own persister, so restore,\n * throttling and max age are theirs.\n *\n * Install `@tanstack/query-persist-client-core` and\n * `@tanstack/query-async-storage-persister` at the same version as your\n * `@tanstack/react-query`: they pin `@tanstack/query-core` exactly, and two\n * copies of it would not share a cache.\n *\n * <GenesisNativeApp persist={persistQueries({ storage: AsyncStorage, keys: [\"clients\"], buster: version })} … />\n *\n * @stability Beta\n */\nimport { defaultShouldDehydrateQuery, type QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClientRestore, persistQueryClientSave, persistQueryClientSubscribe } from \"@tanstack/query-persist-client-core\";\nimport { createAsyncStoragePersister } from \"@tanstack/query-async-storage-persister\";\nimport { DAY_MS, type AsyncStorageLike, type QueryPersistence } from \"./query\";\n\nexport interface PersistQueriesOptions {\n storage: AsyncStorageLike;\n /**\n * The query-key roots to persist: a query is saved when its key's first\n * element is listed (`[\"clients\", id]` is saved under `\"clients\"`). Nothing\n * else is written to the phone.\n */\n keys: readonly string[];\n /** Your app's version: a different value discards the saved cache. */\n buster: string;\n /** How old a saved cache may be when restored. Default 24 hours. */\n maxAge?: number;\n /** Storage key. Default `\"genesis-query-cache\"`. */\n storageKey?: string;\n /** Write at most this often. Default 1000 ms. */\n throttleMs?: number;\n}\n\nexport interface QueryPersistenceOptions extends PersistQueriesOptions {\n queryClient: QueryClient;\n}\n\n/**\n * Save the allowlisted queries to async storage and restore them, with a max age, an app-version buster and a user scope.\n *\n * @deprecated Use `persistOffline` with `sqliteLocalCache` from `@marktiderman/genesis-native/offline`: it keeps each record once, per person and workspace. It needs expo-sqlite, a native module, so unless the app's builds already have it the switch takes a new native build and can't ship as an OTA update (https://github.com/marktiderman/genesis/blob/main/docs/MIGRATION.md). Removed in the next major.\n */\nexport function createQueryPersistence({\n queryClient,\n storage,\n keys,\n buster,\n maxAge = DAY_MS,\n storageKey = \"genesis-query-cache\",\n throttleMs = 1000,\n}: QueryPersistenceOptions): QueryPersistence {\n const persister = createAsyncStoragePersister({ storage, key: storageKey, throttleTime: throttleMs });\n const allowed = new Set(keys);\n const dehydrateOptions = {\n shouldDehydrateQuery: (query: Parameters<typeof defaultShouldDehydrateQuery>[0]) =>\n allowed.has(String(query.queryKey[0])) && defaultShouldDehydrateQuery(query),\n // Mutations stay in memory: replaying a saved write is an outbox's job.\n shouldDehydrateMutation: () => false,\n };\n // The scope rides in the buster: TanStack discards (and deletes) a saved\n // cache whose buster differs, so another user's cache is never restored.\n const scoped = (scope: string) => `${buster}|user:${scope}`;\n return {\n restore: async (scope) => {\n try {\n await persistQueryClientRestore({ queryClient, persister, buster: scoped(scope), maxAge });\n } catch {\n // An unreadable cache has already been deleted; start without it rather than fail the boot.\n }\n },\n subscribe: (scope, options) => {\n // Adopting: what's already in the client is saved now, not only at its next change.\n if (options?.adopt && scope) void persistQueryClientSave({ queryClient, persister, buster: scoped(scope), dehydrateOptions }).catch(() => undefined);\n return persistQueryClientSubscribe({ queryClient, persister, buster: scoped(scope), dehydrateOptions });\n },\n clear: async () => {\n await persister.removeClient();\n },\n };\n}\n\n/**\n * `createQueryPersistence` for `GenesisNativeApp`'s `persist` prop, which supplies the client.\n *\n * @deprecated Use `persistOffline({ cache: sqliteLocalCache({ db }), resources, buster })` from `@marktiderman/genesis-native/offline`. It needs expo-sqlite, a native module, so unless the app's builds already have it the switch takes a new native build and can't ship as an OTA update (https://github.com/marktiderman/genesis/blob/main/docs/MIGRATION.md). Removed in the next major.\n */\nexport function persistQueries(options: PersistQueriesOptions): (queryClient: QueryClient) => QueryPersistence {\n return (queryClient) => createQueryPersistence({ ...options, queryClient });\n}\n\nexport type { QueryPersistence } from \"./query\";\n"]}
package/dist/push.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { X as PushPermissionStatus, Y as NotificationResponseLike, Z as NotificationLike, o as LinkOptions, _ as QuietHours } from './blocks-ByVBKaQW.js';
2
- export { $ as ChannelImportance, a0 as ChannelInputLike, a1 as DEFAULT_PREFERENCES, a2 as NotificationActionLike, a3 as NotificationBehaviorLike, a4 as NotificationCategory, a5 as NotificationPreferences, a6 as NotificationsModuleLike, a7 as PermissionRequestLike, a8 as PermissionState, a9 as PermissionStatusLike, aa as PermissionStore, ab as PreferencesState, ac as PreferencesStatus, ad as PreferencesStore, ae as PromptOptions, af as PromptState, ag as PromptStore, ah as PushAppStateLike, ai as PushBackend, aj as PushBackendError, ak as PushBlock, al as PushChannel, am as PushDeviceCategory, an as PushErrorSource, ao as PushOnError, ap as PushOptions, aq as PushPromptProps, ar as PushPromptSheet, as as PushProvider, at as PushRoot, au as PushRootProps, av as PushSlots, aw as PushStorageLike, ax as PushSupabaseLike, ay as Registration, az as RegistrationState, aA as RegistrationStatus, aB as SubscriptionLike, aC as canPush, aD as createPermissionStore, aE as createPreferencesStore, aF as createPromptStore, aG as createPush, aH as createRegistration, aI as statusOf, aJ as supabasePushBackend, aK as useBadge, aL as useNotificationPreferences, aM as useOptionalPush, aN as usePush, aO as usePushPermissionState, aP as usePushPrompt, aQ as usePushRegistration, aR as useSuppressNotifications, aS as validPreferences } from './blocks-ByVBKaQW.js';
1
+ import { X as PushPermissionStatus, Y as NotificationResponseLike, Z as NotificationLike, o as LinkOptions, _ as QuietHours } from './blocks-dppiMmy-.js';
2
+ export { $ as ChannelImportance, a0 as ChannelInputLike, a1 as DEFAULT_PREFERENCES, a2 as NotificationActionLike, a3 as NotificationBehaviorLike, a4 as NotificationCategory, a5 as NotificationPreferences, a6 as NotificationsModuleLike, a7 as PermissionRequestLike, a8 as PermissionState, a9 as PermissionStatusLike, aa as PermissionStore, ab as PreferencesState, ac as PreferencesStatus, ad as PreferencesStore, ae as PromptOptions, af as PromptState, ag as PromptStore, ah as PushAppStateLike, ai as PushBackend, aj as PushBackendError, ak as PushBlock, al as PushChannel, am as PushDeviceCategory, an as PushErrorSource, ao as PushOnError, ap as PushOptions, aq as PushPromptProps, ar as PushPromptSheet, as as PushProvider, at as PushRoot, au as PushRootProps, av as PushSlots, aw as PushStorageLike, ax as PushSupabaseLike, ay as Registration, az as RegistrationState, aA as RegistrationStatus, aB as SubscriptionLike, aC as canPush, aD as createPermissionStore, aE as createPreferencesStore, aF as createPromptStore, aG as createPush, aH as createRegistration, aI as statusOf, aJ as supabasePushBackend, aK as useBadge, aL as useNotificationPreferences, aM as useOptionalPush, aN as usePush, aO as usePushPermissionState, aP as usePushPrompt, aQ as usePushRegistration, aR as useSuppressNotifications, aS as validPreferences } from './blocks-dppiMmy-.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
  import { Slots, SlotPropsFor } from '@marktiderman/genesis-core/slots';
6
6
  import { SettingsPageProps, SettingsPageRow } from '@marktiderman/genesis-ui-native/layouts';
7
7
  export { RICH_PUSH_IMAGE_FIELDS, RichPushData, RichPushMessageLike, isRichPushUrl, richPushMessage } from './push-payload.js';
8
8
  import '@marktiderman/genesis-features/blocks';
9
- import './query-DobJyRvs.js';
9
+ import './query--ihYsJWC.js';
10
10
  import '@tanstack/react-query';
11
11
  import '@marktiderman/genesis-design-system';
12
12
  import '@marktiderman/genesis-core/provider';
@@ -14,14 +14,31 @@ interface FatalScreenProps {
14
14
  /** Clears the error and remounts the app below the shell (and re-runs a failed boot). */
15
15
  retry: () => void;
16
16
  }
17
- /** The default fatal screen: what went wrong and "Try again". */
18
- declare function FatalScreen({ error, retry }: FatalScreenProps): react.JSX.Element;
17
+ /** Which fatal screen: the app's, one screen's, or the last-resort plain one. */
18
+ type FatalScreenKind = "app" | "screen" | "plain";
19
+ interface FatalScreenViewProps {
20
+ error: Error;
21
+ /** Clears the error and renders again (a screen's retry may be async, as Expo Router's is). */
22
+ retry: () => void | Promise<void>;
23
+ /**
24
+ * `app` (default): the app hit a problem, "Try again" remounts it. `screen`: one screen failed
25
+ * and the rest of the app still works (the screen boundary's default). `plain`: React Native
26
+ * primitives only, no theme, no context, nothing that can itself fail; shown when the providers
27
+ * could not start, or when the `fatal` slot threw.
28
+ */
29
+ kind?: FatalScreenKind;
30
+ }
19
31
  /**
20
- * The last-resort fatal screen: React Native primitives only, no theme, no
21
- * context, nothing that can itself fail. Shown when the providers could not
22
- * start, or when the `fatal` slot threw.
32
+ * The fatal screen: what went wrong and "Try again", for the whole app, one screen, or (with
33
+ * `kind="plain"`) the last resort that needs nothing above it.
23
34
  */
24
- declare function PlainFatalScreen({ error, retry }: FatalScreenProps): react.JSX.Element;
35
+ declare function FatalScreen({ error, retry, kind }: FatalScreenViewProps): react.JSX.Element;
36
+ /**
37
+ * The last-resort fatal screen.
38
+ *
39
+ * @deprecated Use `<FatalScreen kind="plain" />`; this name goes at the next major.
40
+ */
41
+ declare function PlainFatalScreen(props: FatalScreenProps): react.JSX.Element;
25
42
  interface ErrorReport {
26
43
  /** True when the app could not go on (a render error, a failed boot, a fatal global error). */
27
44
  fatal: boolean;
@@ -149,8 +166,13 @@ declare function createNativeQueryClient(config?: QueryClientConfig): QueryClien
149
166
  interface QueryPersistence {
150
167
  /** Load the saved cache into the client, if it was saved for `scope`. */
151
168
  restore(scope: string): Promise<void>;
152
- /** Save on every cache change, for `scope`; returns the unsubscribe. */
153
- subscribe(scope: string): () => void;
169
+ /**
170
+ * Save on every cache change, for `scope`; returns the unsubscribe. `adopt`: the reads already
171
+ * in the client are this scope's too (the app empties the client whenever the person changes).
172
+ */
173
+ subscribe(scope: string, options?: {
174
+ adopt?: boolean;
175
+ }): () => void;
154
176
  /**
155
177
  * Delete the saved cache. Clear the QueryClient first: the subscription
156
178
  * then saves the empty cache, so a save already in flight can't leave the
@@ -205,4 +227,4 @@ declare function queryKeyName(key: readonly unknown[] | undefined): string | und
205
227
  */
206
228
  declare function reportQueryErrors(client: QueryClient, report: QueryErrorReporter, options?: ReportQueryErrorsOptions): () => void;
207
229
 
208
- export { type AsyncStorageLike as A, DAY_MS as D, type EnableRejectionTracker as E, FatalScreen as F, GenesisErrorBoundary as G, type NetInfoLike as N, type OnError as O, PlainFatalScreen as P, type QueryErrorReporter as Q, type ReportQueryErrorsOptions as R, type AppStateLike as a, type ErrorReport as b, type ErrorUtilsLike as c, type FatalScreenProps as d, type GenesisErrorBoundaryProps as e, type GlobalErrorHandlerOptions as f, type QueryLifecycleOptions as g, type QueryPersistence as h, connectQueryLifecycle as i, createNativeQueryClient as j, defaultErrorUtils as k, defaultRejectionTracker as l, errorDetails as m, installGlobalErrorHandler as n, installRejectionTracker as o, queryKeyName as q, reportQueryErrors as r };
230
+ export { type AsyncStorageLike as A, DAY_MS as D, type EnableRejectionTracker as E, FatalScreen as F, GenesisErrorBoundary as G, type NetInfoLike as N, type OnError as O, PlainFatalScreen as P, type QueryErrorReporter as Q, type ReportQueryErrorsOptions as R, type AppStateLike as a, type ErrorReport as b, type ErrorUtilsLike as c, type FatalScreenKind as d, type FatalScreenProps as e, type FatalScreenViewProps as f, type GenesisErrorBoundaryProps as g, type GlobalErrorHandlerOptions as h, type QueryLifecycleOptions as i, type QueryPersistence as j, connectQueryLifecycle as k, createNativeQueryClient as l, defaultErrorUtils as m, defaultRejectionTracker as n, errorDetails as o, installGlobalErrorHandler as p, installRejectionTracker as q, queryKeyName as r, reportQueryErrors as s };
@@ -1,16 +1,20 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- import { O as OnError } from './query-DobJyRvs.js';
3
+ import { O as OnError } from './query--ihYsJWC.js';
4
4
 
5
5
  /** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */
6
6
  interface ScreenErrorProps {
7
7
  error: Error;
8
8
  retry: () => Promise<void>;
9
9
  }
10
- /** The default screen fallback: the screen hit a problem, and "Try again". @stability Beta */
11
- declare function ScreenErrorScreen({ error, retry }: ScreenErrorProps): react.JSX.Element;
10
+ /**
11
+ * The default screen fallback: the screen hit a problem, and "Try again".
12
+ *
13
+ * @deprecated Use `<FatalScreen kind="screen" />`; this name goes at the next major.
14
+ */
15
+ declare function ScreenErrorScreen(props: ScreenErrorProps): react.JSX.Element;
12
16
  interface ScreenErrorBoundaryOptions {
13
- /** What to show. Default `ScreenErrorScreen`. */
17
+ /** What to show. Default `<FatalScreen kind="screen" />`. */
14
18
  fallback?: ComponentType<ScreenErrorProps>;
15
19
  /** Where the error goes. Default `reportError` from genesis-core (the observability block, when it is on). */
16
20
  onError?: OnError;
package/dist/updates.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { aT as ApplicationLike, aU as CLOCK_SKEW_MS, aV as ChannelSwitchResult, aW as ChannelSwitcher, aX as ChannelSwitcherOptions, aY as EvaluatePolicyOptions, aZ as ForceUpgradeProps, a_ as ForceUpgradeScreen, a$ as MaintenanceProps, b0 as MaintenanceScreen, b1 as PolicyClientLike, b2 as PolicyOrigin, b3 as PolicyState, b4 as PolicyStore, b5 as PolicyStoreOptions, b6 as ReleaseNote, b7 as ReloadGuard, b8 as SupabasePolicySourceOptions, b9 as UPDATES_BLOCK_ID, ba as UpdateBanner, bb as UpdateBannerProps, bc as UpdateCheckState, bd as UpdateCheckStatus, be as UpdateChecker, bf as UpdateCheckerOptions, bg as UpdatePlatform, bh as UpdatePolicy, bi as UpdatePolicySource, bj as UpdateVerdict, bk as UpdatesAppStateLike, U as UpdatesBlock, bl as UpdatesErrorSource, bm as UpdatesModuleLike, bn as UpdatesOnError, bo as UpdatesOptions, bp as UpdatesProvider, bq as UpdatesRoot, br as UpdatesRootProps, bs as UpdatesSlots, bt as UpdatesStorageLike, V as VersionSignature, bu as VersionSignatureInput, bv as WEEK_MS, bw as WhatsNewOptions, bx as WhatsNewProps, by as WhatsNewSheet, bz as WhatsNewState, bA as WhatsNewStore, bB as createChannelSwitcher, bC as createPolicyStore, bD as createReloadGuard, bE as createUpdateChecker, bF as createUpdates, bG as createWhatsNewStore, bH as evaluatePolicy, bI as notesSince, bJ as sanitizePolicy, bK as staticPolicySource, bL as supabasePolicySource, bM as useBlockReload, bN as useCanReload, bO as useForceUpgrade, bP as useMaintenance, bQ as useUpdateBanner, bR as useUpdateCheck, bS as useUpdatePolicy, bT as useUpdateVerdict, bU as useUpdates, bV as useVersionSignature, bW as useWhatsNew, bX as versionSignature } from './blocks-ByVBKaQW.js';
1
+ export { aT as ApplicationLike, aU as CLOCK_SKEW_MS, aV as ChannelSwitchResult, aW as ChannelSwitcher, aX as ChannelSwitcherOptions, aY as EvaluatePolicyOptions, aZ as ForceUpgradeProps, a_ as ForceUpgradeScreen, a$ as MaintenanceProps, b0 as MaintenanceScreen, b1 as PolicyClientLike, b2 as PolicyOrigin, b3 as PolicyState, b4 as PolicyStore, b5 as PolicyStoreOptions, b6 as ReleaseNote, b7 as ReloadGuard, b8 as SupabasePolicySourceOptions, b9 as UPDATES_BLOCK_ID, ba as UpdateBanner, bb as UpdateBannerProps, bc as UpdateCheckState, bd as UpdateCheckStatus, be as UpdateChecker, bf as UpdateCheckerOptions, bg as UpdatePlatform, bh as UpdatePolicy, bi as UpdatePolicySource, bj as UpdateVerdict, bk as UpdatesAppStateLike, U as UpdatesBlock, bl as UpdatesErrorSource, bm as UpdatesModuleLike, bn as UpdatesOnError, bo as UpdatesOptions, bp as UpdatesProvider, bq as UpdatesRoot, br as UpdatesRootProps, bs as UpdatesSlots, bt as UpdatesStorageLike, V as VersionSignature, bu as VersionSignatureInput, bv as WEEK_MS, bw as WhatsNewOptions, bx as WhatsNewProps, by as WhatsNewSheet, bz as WhatsNewState, bA as WhatsNewStore, bB as createChannelSwitcher, bC as createPolicyStore, bD as createReloadGuard, bE as createUpdateChecker, bF as createUpdates, bG as createWhatsNewStore, bH as evaluatePolicy, bI as notesSince, bJ as sanitizePolicy, bK as staticPolicySource, bL as supabasePolicySource, bM as useBlockReload, bN as useCanReload, bO as useForceUpgrade, bP as useMaintenance, bQ as useUpdateBanner, bR as useUpdateCheck, bS as useUpdatePolicy, bT as useUpdateVerdict, bU as useUpdates, bV as useVersionSignature, bW as useWhatsNew, bX as versionSignature } from './blocks-dppiMmy-.js';
2
2
  import 'react';
3
3
  import '@marktiderman/genesis-core/slots';
4
4
  import '@marktiderman/genesis-features/blocks';
5
- import './query-DobJyRvs.js';
5
+ import './query--ihYsJWC.js';
6
6
  import '@tanstack/react-query';
7
7
  import '@marktiderman/genesis-design-system';
8
8
  import '@marktiderman/genesis-core/provider';
package/dist/updates.js CHANGED
@@ -1,13 +1,13 @@
1
- import { createStore, delay } from './chunk-XE7LC7K6.js';
2
1
  import { versionSignature } from './chunk-6BT4PTGH.js';
3
2
  export { versionSignature } from './chunk-6BT4PTGH.js';
3
+ import { createStore, delay } from './chunk-XE7LC7K6.js';
4
4
  import { runBeforeReload } from './chunk-VIC2KXMA.js';
5
5
  import { createContext, useContext, useEffect, useSyncExternalStore, useMemo, useState } from 'react';
6
6
  import { View } from 'react-native';
7
7
  import { renderSlot } from '@marktiderman/genesis-core/slots';
8
8
  import { defineBlock } from '@marktiderman/genesis-features/blocks';
9
9
  import { SafeAreaView } from 'react-native-safe-area-context';
10
- import { NativeEmptyState, NativeButton, useLiquidGlass, NativeGlassSurface, NativeBanner, NativeSheet, NativeSheetScrollView, NativeText } from '@marktiderman/genesis-ui-native/components';
10
+ import { NativeEmptyState, NativeButton, useLiquidGlass, NativeGlassSurface, NativeBanner, NativeWhatsNewSheet } from '@marktiderman/genesis-ui-native/components';
11
11
  import { jsx, jsxs } from 'react/jsx-runtime';
12
12
 
13
13
  // src/updates/modules.ts
@@ -539,14 +539,14 @@ function UpdateBanner({ reload, dismiss, canReload, blocked, reloading }) {
539
539
  ] }) }) });
540
540
  }
541
541
  function WhatsNewSheet({ notes, dismiss }) {
542
- return /* @__PURE__ */ jsx(NativeSheet, { open: true, onOpenChange: (open) => open ? void 0 : dismiss(), testID: "genesis-whats-new", children: /* @__PURE__ */ jsxs(NativeSheetScrollView, { contentContainerClassName: "gap-4 p-6", children: [
543
- /* @__PURE__ */ jsx(NativeText, { preset: "h3", accessibilityRole: "header", children: "What's new" }),
544
- notes.map((note) => /* @__PURE__ */ jsxs(View, { className: "gap-1", testID: `genesis-whats-new-${note.version}`, children: [
545
- /* @__PURE__ */ jsx(NativeText, { preset: "label", children: note.title ?? `Version ${note.version}` }),
546
- /* @__PURE__ */ jsx(NativeText, { preset: "body-sm", className: "text-muted-foreground", children: note.body })
547
- ] }, note.version)),
548
- /* @__PURE__ */ jsx(NativeButton, { onPress: dismiss, testID: "genesis-whats-new-done", children: "Got it" })
549
- ] }) });
542
+ return /* @__PURE__ */ jsx(
543
+ NativeWhatsNewSheet,
544
+ {
545
+ notes: notes.map((note) => ({ key: note.version, title: note.title ?? `Version ${note.version}`, body: note.body })),
546
+ dismiss,
547
+ testID: "genesis-whats-new"
548
+ }
549
+ );
550
550
  }
551
551
  var UPDATES_BLOCK_ID = "app-updates";
552
552
  function createUpdates(options) {