@oxy.so/services 9.0.0 → 9.1.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 (42) hide show
  1. package/lib/commonjs/ui/components/OxyProvider.js +2 -2
  2. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  3. package/lib/commonjs/ui/context/OxyContext.js +4 -0
  4. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  5. package/lib/commonjs/ui/hooks/accountQueryPersistence.js +110 -80
  6. package/lib/commonjs/ui/hooks/accountQueryPersistence.js.map +1 -1
  7. package/lib/commonjs/ui/hooks/persistedQueryCache.js +101 -0
  8. package/lib/commonjs/ui/hooks/persistedQueryCache.js.map +1 -0
  9. package/lib/commonjs/ui/hooks/queryClient.js +43 -80
  10. package/lib/commonjs/ui/hooks/queryClient.js.map +1 -1
  11. package/lib/module/ui/components/OxyProvider.js +2 -2
  12. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  13. package/lib/module/ui/context/OxyContext.js +4 -0
  14. package/lib/module/ui/context/OxyContext.js.map +1 -1
  15. package/lib/module/ui/hooks/accountQueryPersistence.js +109 -80
  16. package/lib/module/ui/hooks/accountQueryPersistence.js.map +1 -1
  17. package/lib/module/ui/hooks/persistedQueryCache.js +94 -0
  18. package/lib/module/ui/hooks/persistedQueryCache.js.map +1 -0
  19. package/lib/module/ui/hooks/queryClient.js +44 -81
  20. package/lib/module/ui/hooks/queryClient.js.map +1 -1
  21. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/ui/hooks/accountQueryPersistence.d.ts +31 -13
  23. package/lib/typescript/commonjs/ui/hooks/accountQueryPersistence.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/ui/hooks/persistedQueryCache.d.ts +44 -0
  25. package/lib/typescript/commonjs/ui/hooks/persistedQueryCache.d.ts.map +1 -0
  26. package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts +15 -20
  27. package/lib/typescript/commonjs/ui/hooks/queryClient.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  29. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  30. package/lib/typescript/module/ui/hooks/accountQueryPersistence.d.ts +31 -13
  31. package/lib/typescript/module/ui/hooks/accountQueryPersistence.d.ts.map +1 -1
  32. package/lib/typescript/module/ui/hooks/persistedQueryCache.d.ts +44 -0
  33. package/lib/typescript/module/ui/hooks/persistedQueryCache.d.ts.map +1 -0
  34. package/lib/typescript/module/ui/hooks/queryClient.d.ts +15 -20
  35. package/lib/typescript/module/ui/hooks/queryClient.d.ts.map +1 -1
  36. package/lib/typescript/module/ui/icons/MaterialCommunityIcons.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/ui/components/OxyProvider.tsx +2 -2
  39. package/src/ui/context/OxyContext.tsx +4 -0
  40. package/src/ui/hooks/accountQueryPersistence.ts +138 -91
  41. package/src/ui/hooks/persistedQueryCache.ts +126 -0
  42. package/src/ui/hooks/queryClient.ts +55 -98
@@ -10,23 +10,54 @@
10
10
  *
11
11
  * - Storage is keyed by the account (`oxy_account_queries:<accountId>`), so a
12
12
  * restore can only ever hydrate the account that is signed in.
13
- * - The buster is the build (`getOxyBuildId`), so no cache written by an older
14
- * bundle, in an older shape, is ever served.
15
- * - On a subject change the declared roots, memory-only ones included, and the
16
- * account's paused mutations are dropped
17
- * from memory synchronously, before anyone is woken, and the new account's
18
- * blob is restored. `isReady()` is false until that restore settles, and
13
+ * - Queries written by another build are dropped on restore; queued (paused)
14
+ * mutations are kept (`persistedQueryCache.ts`).
15
+ * - On a subject change the account's queries, memory-only ones included, and
16
+ * its paused mutations are dropped from memory synchronously, before anyone
17
+ * is woken. The leaving account's latest state is written first, a sign-out
18
+ * then deletes it, and only then is the next account's blob read.
19
+ * - `isReady()` is false until the signed-in account's blob is restored, and
19
20
  * `RequireOxyAuth` waits on it, so another account's rows never render.
20
- * - On sign-out the signed-out account's blob is deleted.
21
+ *
22
+ * Every storage operation runs through one queue, in order, and a restore
23
+ * checks that its account is still the active one in the same tick it hydrates.
21
24
  */
22
25
 
23
26
  import { hashKey } from '@tanstack/react-query';
24
- import { persistQueryClient } from '@tanstack/react-query-persist-client';
25
- import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
26
- import { getOxyBuildId } from "../utils/buildId.js";
27
+ import { PERSISTED_QUERY_PREFIXES, SDK_MEMORY_ONLY_ROOTS, hydrateSnapshot, rootOf, snapshot, subscribeSnapshots } from "./persistedQueryCache.js";
27
28
 
28
29
  /** An app's declaration of which data is private to the signed-in account. */
29
30
 
31
+ /** Which queries and mutations an `AccountQueriesConfig` makes the account's. */
32
+
33
+ /** SDK roots that hold device-level data, the same whoever is signed in. */
34
+ const DEVICE_ROOTS = new Set(['accounts', 'sessions', 'devices']);
35
+ export function accountQueryOwnership(config) {
36
+ const memoryOnly = new Set([...(config.memoryOnlyRoots ?? []), ...SDK_MEMORY_ONLY_ROOTS]);
37
+ const sdkRoots = new Set(PERSISTED_QUERY_PREFIXES);
38
+ const declared = config.roots === 'all' ? null : new Set(config.roots);
39
+ const mutationHashes = new Set((config.mutationKeys ?? []).map(key => hashKey(key)));
40
+ const ownsQuery = query => {
41
+ const root = rootOf(query);
42
+ if (root !== null && memoryOnly.has(root)) return true;
43
+ if (declared === null) return root === null || !DEVICE_ROOTS.has(root);
44
+ return root !== null && declared.has(root);
45
+ };
46
+ return {
47
+ ownsQuery,
48
+ persistsQuery: query => {
49
+ if (!ownsQuery(query)) return false;
50
+ const root = rootOf(query);
51
+ if (root === null) return true;
52
+ // The SDK's own roots stay with the SDK persister.
53
+ return !memoryOnly.has(root) && (declared !== null || !sdkRoots.has(root));
54
+ },
55
+ ownsMutation: mutation => {
56
+ const key = mutation.options.mutationKey;
57
+ return key !== undefined && mutationHashes.has(hashKey(key));
58
+ }
59
+ };
60
+ }
30
61
  export const ACCOUNT_QUERY_CACHE_KEY = 'oxy_account_queries';
31
62
  const ACCOUNT_QUERY_CACHE_MAX_AGE = 7 * 24 * 60 * 60 * 1000; // 7 days
32
63
  const ACCOUNT_QUERY_PERSIST_THROTTLE_MS = 1_000;
@@ -34,31 +65,34 @@ function storageKeyFor(accountId) {
34
65
  return `${ACCOUNT_QUERY_CACHE_KEY}:${encodeURIComponent(accountId)}`;
35
66
  }
36
67
  export function createAccountQueryPersistence(queryClient, config) {
37
- const persistedRoots = new Set(config.roots);
38
- const accountRoots = new Set([...config.roots, ...(config.memoryOnlyRoots ?? [])]);
39
- const mutationHashes = new Set((config.mutationKeys ?? []).map(key => hashKey(key)));
68
+ const {
69
+ ownsQuery,
70
+ persistsQuery,
71
+ ownsMutation
72
+ } = accountQueryOwnership(config);
73
+ const filters = {
74
+ shouldDehydrateQuery: query => query.state.status === 'success' && persistsQuery(query),
75
+ shouldDehydrateMutation: mutation => mutation.state.isPaused && ownsMutation(mutation)
76
+ };
40
77
  const listeners = new Set();
41
- let storage = null;
78
+ let resolveStorage = () => undefined;
79
+ const storageReady = new Promise(resolve => {
80
+ resolveStorage = resolve;
81
+ });
82
+ let hasStorage = false;
83
+ // Every read, write and delete runs here, in order, once storage exists.
84
+ let io = storageReady;
85
+ const enqueue = operation => {
86
+ io = io.then(() => storageReady).then(operation).catch(() => undefined);
87
+ };
88
+ let attached = false;
42
89
  let accountId = null;
43
90
  let restoredFor = null;
44
91
  let generation = 0;
45
- let unsubscribePersist = null;
46
- // The in-flight restore. A new account waits for it, so a late restore can
47
- // never hydrate the previous account's rows after the switch.
48
- let restoring = Promise.resolve();
92
+ let writer = null;
49
93
  const notify = () => {
50
94
  for (const listener of listeners) listener();
51
95
  };
52
- const rootOf = query => {
53
- const head = query.queryKey[0];
54
- return typeof head === 'string' ? head : null;
55
- };
56
- const ownsQuery = query => accountRoots.has(rootOf(query) ?? '');
57
- const persistsQuery = query => persistedRoots.has(rootOf(query) ?? '');
58
- const ownsMutation = mutation => {
59
- const key = mutation.options.mutationKey;
60
- return key !== undefined && mutationHashes.has(hashKey(key));
61
- };
62
96
  const dropScopedData = () => {
63
97
  queryClient.removeQueries({
64
98
  predicate: ownsQuery
@@ -68,70 +102,71 @@ export function createAccountQueryPersistence(queryClient, config) {
68
102
  if (ownsMutation(mutation)) mutations.remove(mutation);
69
103
  }
70
104
  };
71
- const persisterFor = (id, target) => createAsyncStoragePersister({
72
- storage: {
73
- getItem: key => target.getItem(key),
74
- setItem: (key, value) => target.setItem(key, value),
75
- removeItem: key => target.removeItem(key)
76
- },
77
- key: storageKeyFor(id),
78
- throttleTime: ACCOUNT_QUERY_PERSIST_THROTTLE_MS
79
- });
80
- const start = () => {
105
+ const stopWriting = () => {
106
+ writer?.unsubscribe();
107
+ writer = null;
108
+ };
109
+ const restore = () => {
81
110
  const id = accountId;
82
- const target = storage;
83
- if (!id || !target || unsubscribePersist) return;
111
+ if (!attached || id === null) return;
84
112
  const current = generation;
85
- const [unsubscribe, restored] = persistQueryClient({
86
- queryClient,
87
- persister: persisterFor(id, target),
88
- maxAge: ACCOUNT_QUERY_CACHE_MAX_AGE,
89
- buster: getOxyBuildId(),
90
- dehydrateOptions: {
91
- shouldDehydrateQuery: query => query.state.status === 'success' && persistsQuery(query),
92
- shouldDehydrateMutation: mutation => mutation.state.isPaused && ownsMutation(mutation)
93
- }
94
- });
95
- unsubscribePersist = unsubscribe;
96
- restoring = restored.catch(() => undefined).then(() => {
113
+ const key = storageKeyFor(id);
114
+ enqueue(async storage => {
115
+ const raw = await storage.getItem(key);
116
+ // Same tick as the hydrate: a switch in between cannot be missed.
97
117
  if (current !== generation) return;
118
+ if (!hydrateSnapshot(queryClient, raw, ACCOUNT_QUERY_CACHE_MAX_AGE) && raw) {
119
+ await storage.removeItem(key);
120
+ if (current !== generation) return;
121
+ }
98
122
  restoredFor = id;
123
+ writer = subscribeSnapshots(queryClient, filters, ACCOUNT_QUERY_PERSIST_THROTTLE_MS, serialized => {
124
+ if (current !== generation) return;
125
+ enqueue(target => target.setItem(key, serialized));
126
+ });
99
127
  notify();
100
128
  });
101
129
  };
102
- const stop = () => {
103
- unsubscribePersist?.();
104
- unsubscribePersist = null;
105
- };
106
130
  return {
107
131
  setStorage(next) {
108
- if (storage) return;
109
- storage = next;
110
- const current = generation;
111
- void restoring.then(() => {
112
- if (current === generation) start();
113
- });
132
+ if (hasStorage) return;
133
+ hasStorage = true;
134
+ resolveStorage(next);
114
135
  },
115
136
  activate(next) {
116
137
  if (next === accountId) return;
117
138
  const previous = accountId;
139
+ // Keep the leaving account's latest state, but only once its own blob was
140
+ // restored: before that, the cache holds none of it to write.
141
+ if (previous !== null && restoredFor === previous) {
142
+ const serialized = snapshot(queryClient, filters);
143
+ const key = storageKeyFor(previous);
144
+ enqueue(storage => storage.setItem(key, serialized));
145
+ }
118
146
  generation += 1;
119
- const current = generation;
120
- stop();
147
+ stopWriting();
121
148
  dropScopedData();
122
149
  accountId = next;
123
150
  restoredFor = null;
124
- notify();
125
- if (next === null && previous !== null && storage) {
126
- void persisterFor(previous, storage).removeClient();
151
+ if (next === null && previous !== null) {
152
+ const key = storageKeyFor(previous);
153
+ enqueue(storage => storage.removeItem(key));
127
154
  }
128
- void restoring.then(() => {
129
- if (current !== generation) return;
130
- // A restore that was already in flight may have hydrated the previous
131
- // account's rows; drop them again before this account's restore.
132
- dropScopedData();
133
- start();
134
- });
155
+ notify();
156
+ restore();
157
+ },
158
+ attach() {
159
+ if (attached) return;
160
+ attached = true;
161
+ restore();
162
+ },
163
+ detach() {
164
+ if (!attached) return;
165
+ attached = false;
166
+ writer?.flush();
167
+ generation += 1;
168
+ stopWriting();
169
+ restoredFor = null;
135
170
  },
136
171
  isReady() {
137
172
  return accountId === null || restoredFor === accountId;
@@ -141,12 +176,6 @@ export function createAccountQueryPersistence(queryClient, config) {
141
176
  return () => {
142
177
  listeners.delete(listener);
143
178
  };
144
- },
145
- ownsMutation,
146
- dispose() {
147
- generation += 1;
148
- stop();
149
- listeners.clear();
150
179
  }
151
180
  };
152
181
  }
@@ -1 +1 @@
1
- {"version":3,"names":["hashKey","persistQueryClient","createAsyncStoragePersister","getOxyBuildId","ACCOUNT_QUERY_CACHE_KEY","ACCOUNT_QUERY_CACHE_MAX_AGE","ACCOUNT_QUERY_PERSIST_THROTTLE_MS","storageKeyFor","accountId","encodeURIComponent","createAccountQueryPersistence","queryClient","config","persistedRoots","Set","roots","accountRoots","memoryOnlyRoots","mutationHashes","mutationKeys","map","key","listeners","storage","restoredFor","generation","unsubscribePersist","restoring","Promise","resolve","notify","listener","rootOf","query","head","queryKey","ownsQuery","has","persistsQuery","ownsMutation","mutation","options","mutationKey","undefined","dropScopedData","removeQueries","predicate","mutations","getMutationCache","getAll","remove","persisterFor","id","target","getItem","setItem","value","removeItem","throttleTime","start","current","unsubscribe","restored","persister","maxAge","buster","dehydrateOptions","shouldDehydrateQuery","state","status","shouldDehydrateMutation","isPaused","catch","then","stop","setStorage","next","activate","previous","removeClient","isReady","subscribe","add","delete","dispose","clear"],"sourceRoot":"../../../../src","sources":["ui/hooks/accountQueryPersistence.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAoE,uBAAuB;AAC3G,SAASC,kBAAkB,QAAQ,sCAAsC;AACzE,SAASC,2BAA2B,QAAQ,yCAAyC;AAErF,SAASC,aAAa,QAAQ,qBAAkB;;AAEhD;;AAmBA,OAAO,MAAMC,uBAAuB,GAAG,qBAAqB;AAC5D,MAAMC,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAC7D,MAAMC,iCAAiC,GAAG,KAAK;AAe/C,SAASC,aAAaA,CAACC,SAAiB,EAAU;EAChD,OAAO,GAAGJ,uBAAuB,IAAIK,kBAAkB,CAACD,SAAS,CAAC,EAAE;AACtE;AAEA,OAAO,SAASE,6BAA6BA,CAC3CC,WA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cAAc,CAAC,CAAC;MAChBpC,SAAS,GAAGoE,IAAI;MAChBpD,WAAW,GAAG,IAAI;MAClBM,MAAM,CAAC,CAAC;MAER,IAAI8C,IAAI,KAAK,IAAI,IAAIE,QAAQ,KAAK,IAAI,IAAIvD,OAAO,EAAE;QACjD,KAAK4B,YAAY,CAAC2B,QAAQ,EAAEvD,OAAO,CAAC,CAACwD,YAAY,CAAC,CAAC;MACrD;MAEA,KAAKpD,SAAS,CAAC8C,IAAI,CAAC,MAAM;QACxB,IAAIb,OAAO,KAAKnC,UAAU,EAAE;QAC5B;QACA;QACAmB,cAAc,CAAC,CAAC;QAChBe,KAAK,CAAC,CAAC;MACT,CAAC,CAAC;IACJ,CAAC;IAEDqB,OAAOA,CAAA,EAAG;MACR,OAAOxE,SAAS,KAAK,IAAI,IAAIgB,WAAW,KAAKhB,SAAS;IACxD,CAAC;IAEDyE,SAASA,CAAClD,QAAQ,EAAE;MAClBT,SAAS,CAAC4D,GAAG,CAACnD,QAAQ,CAAC;MACvB,OAAO,MAAM;QACXT,SAAS,CAAC6D,MAAM,CAACpD,QAAQ,CAAC;MAC5B,CAAC;IACH,CAAC;IAEDQ,YAAY;IAEZ6C,OAAOA,CAAA,EAAG;MACR3D,UAAU,IAAI,CAAC;MACfiD,IAAI,CAAC,CAAC;MACNpD,SAAS,CAAC+D,KAAK,CAAC,CAAC;IACnB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["hashKey","PERSISTED_QUERY_PREFIXES","SDK_MEMORY_ONLY_ROOTS","hydrateSnapshot","rootOf","snapshot","subscribeSnapshots","DEVICE_ROOTS","Set","accountQueryOwnership","config","memoryOnly","memoryOnlyRoots","sdkRoots","declared","roots","mutationHashes","mutationKeys","map","key","ownsQuery","query","root","has","persistsQuery","ownsMutation","mutation","options","mutationKey","undefined","ACCOUNT_QUERY_CACHE_KEY","ACCOUNT_QUERY_CACHE_MAX_AGE","ACCOUNT_QUERY_PERSIST_THROTTLE_MS","storageKeyFor","accountId","encodeURIComponent","createAccountQueryPersistence","queryClient","filters","shouldDehydrateQuery","state","status","shouldDehydrateMutation","isPaused","listeners","resolveStorage","storageReady","Promise","resolve","hasStorage","io","enqueue","operation","then","catch","attached","restoredFor","generation","writer","notify","listener","dropScopedData","removeQueries","predicate","mutations","getMutationCache","getAll","remove","stopWriting","unsubscribe","restore","id","current","storage","raw","getItem","removeItem","serialized","target","setItem","setStorage","next","activate","previous","attach","detach","flush","isReady","subscribe","add","delete"],"sourceRoot":"../../../../src","sources":["ui/hooks/accountQueryPersistence.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAoE,uBAAuB;AAE3G,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,eAAe,EACfC,MAAM,EACNC,QAAQ,EACRC,kBAAkB,QAEb,0BAAuB;;AAE9B;;AAwBA;;AASA;AACA,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAEjE,OAAO,SAASC,qBAAqBA,CAACC,MAA4B,EAAyB;EACzF,MAAMC,UAAU,GAAG,IAAIH,GAAG,CAAC,CAAC,IAAIE,MAAM,CAACE,eAAe,IAAI,EAAE,CAAC,EAAE,GAAGV,qBAAqB,CAAC,CAAC;EACzF,MAAMW,QAAQ,GAAG,IAAIL,GAAG,CAACP,wBAAwB,CAAC;EAClD,MAAMa,QAAQ,GAAGJ,MAAM,CAACK,KAAK,KAAK,KAAK,GAAG,IAAI,GAAG,IAAIP,GAAG,CAACE,MAAM,CAACK,KAAK,CAAC;EACtE,MAAMC,cAAc,GAAG,IAAIR,GAAG,CAAC,CAACE,MAAM,CAACO,YAAY,IAAI,EAAE,EAAEC,GAAG,CAAEC,GAAG,IAAKnB,OAAO,CAACmB,GAAG,CAAC,CAAC,CAAC;EA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AAM,EAAE4B,KAAK,CAAC,CAAC;MACf7B,UAAU,IAAI,CAAC;MACfW,WAAW,CAAC,CAAC;MACbZ,WAAW,GAAG,IAAI;IACpB,CAAC;IAED+B,OAAOA,CAAA,EAAG;MACR,OAAOrD,SAAS,KAAK,IAAI,IAAIsB,WAAW,KAAKtB,SAAS;IACxD,CAAC;IAEDsD,SAASA,CAAC5B,QAAQ,EAAE;MAClBhB,SAAS,CAAC6C,GAAG,CAAC7B,QAAQ,CAAC;MACvB,OAAO,MAAM;QACXhB,SAAS,CAAC8C,MAAM,CAAC9B,QAAQ,CAAC;MAC5B,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The storage format and restore rules shared by the SDK's two query caches:
5
+ * the account-agnostic one (`attachQueryPersistence`) and the per-account one
6
+ * (`createAccountQueryPersistence`).
7
+ *
8
+ * A blob is `{ buster, timestamp, clientState }`, TanStack's persisted-client
9
+ * shape. Restoring it treats its two halves differently:
10
+ *
11
+ * - Queries are served before any refetch, so a query written by another
12
+ * build, in whatever shape that build used, is dropped (`getOxyBuildId`).
13
+ * - Paused mutations are the user's queued actions (a star, a send made
14
+ * offline). A deploy must not lose them, so they are restored whatever build
15
+ * wrote them; the current build's `setMutationDefaults` replays them.
16
+ */
17
+
18
+ import { dehydrate, hydrate } from '@tanstack/react-query';
19
+ import { getOxyBuildId } from "../utils/buildId.js";
20
+
21
+ /** The SDK's own account-agnostic query roots, persisted by `attachQueryPersistence`. */
22
+ export const PERSISTED_QUERY_PREFIXES = ['accounts', 'users', 'sessions', 'devices', 'privacy'];
23
+
24
+ /**
25
+ * SDK queries whose data (or key) carries a signed, expiring URL. Never
26
+ * written to disk: a restored one would serve an expired URL.
27
+ */
28
+ export const SDK_MEMORY_ONLY_ROOTS = ['assetDownloadUrls', 'avatarCropSource', 'avatarCropMeasure', 'justifiedPhotoDimensions'];
29
+ export function rootOf(query) {
30
+ const head = query.queryKey[0];
31
+ return typeof head === 'string' ? head : null;
32
+ }
33
+
34
+ /** Serialize what the filters select, stamped with this build. */
35
+ export function snapshot(queryClient, filters) {
36
+ const blob = {
37
+ buster: getOxyBuildId(),
38
+ timestamp: Date.now(),
39
+ clientState: dehydrate(queryClient, filters)
40
+ };
41
+ return JSON.stringify(blob);
42
+ }
43
+
44
+ /**
45
+ * Hydrate a stored blob into the client, synchronously, so a caller can check
46
+ * it is still wanted immediately before. Returns false when there was nothing
47
+ * usable (absent, unreadable or expired), in which case the caller removes it.
48
+ */
49
+ export function hydrateSnapshot(queryClient, raw, maxAge) {
50
+ if (!raw) return false;
51
+ let blob;
52
+ try {
53
+ blob = JSON.parse(raw);
54
+ } catch {
55
+ return false;
56
+ }
57
+ if (!blob?.clientState || typeof blob.timestamp !== 'number' || Date.now() - blob.timestamp > maxAge) {
58
+ return false;
59
+ }
60
+ const sameBuild = blob.buster === getOxyBuildId();
61
+ hydrate(queryClient, {
62
+ queries: sameBuild ? blob.clientState.queries : [],
63
+ mutations: blob.clientState.mutations ?? []
64
+ });
65
+ return true;
66
+ }
67
+
68
+ /**
69
+ * Write the filtered cache on every change, at most once per `throttleMs`.
70
+ * `write` receives the serialized snapshot; `flush()` writes now.
71
+ */
72
+ export function subscribeSnapshots(queryClient, filters, throttleMs, write) {
73
+ let timer = null;
74
+ const flush = () => {
75
+ if (timer) clearTimeout(timer);
76
+ timer = null;
77
+ write(snapshot(queryClient, filters));
78
+ };
79
+ const schedule = () => {
80
+ if (!timer) timer = setTimeout(flush, throttleMs);
81
+ };
82
+ const offQueries = queryClient.getQueryCache().subscribe(schedule);
83
+ const offMutations = queryClient.getMutationCache().subscribe(schedule);
84
+ return {
85
+ flush,
86
+ unsubscribe: () => {
87
+ if (timer) clearTimeout(timer);
88
+ timer = null;
89
+ offQueries();
90
+ offMutations();
91
+ }
92
+ };
93
+ }
94
+ //# sourceMappingURL=persistedQueryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["dehydrate","hydrate","getOxyBuildId","PERSISTED_QUERY_PREFIXES","SDK_MEMORY_ONLY_ROOTS","rootOf","query","head","queryKey","snapshot","queryClient","filters","blob","buster","timestamp","Date","now","clientState","JSON","stringify","hydrateSnapshot","raw","maxAge","parse","sameBuild","queries","mutations","subscribeSnapshots","throttleMs","write","timer","flush","clearTimeout","schedule","setTimeout","offQueries","getQueryCache","subscribe","offMutations","getMutationCache","unsubscribe"],"sourceRoot":"../../../../src","sources":["ui/hooks/persistedQueryCache.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,SAAS,EACTC,OAAO,QAKF,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,qBAAkB;;AAEhD;AACA,OAAO,MAAMC,wBAA+C,GAAG,CAC7D,UAAU,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,CACV;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAA4C,GAAG,CAC1D,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,CAC3B;AAaD,OAAO,SAASC,MAAMA,CAACC,KAAY,EAAiB;EAClD,MAAMC,IAAI,GAAGD,KAAK,CAACE,QAAQ,CAAC,CAAC,CAAC;EAC9B,OAAO,OAAOD,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAG,IAAI;AAC/C;;AAEA;AACA,OAAO,SAASE,QAAQA,CAACC,WAAwB,EAAEC,OAAuB,EAAU;EAClF,MAAMC,IAAmB,GAAG;IAC1BC,MAAM,EAAEX,aAAa,CAAC,CAAC;IACvBY,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;IACrBC,WAAW,EAAEjB,SAAS,CAACU,WAAW,EAAEC,OAAO;EAC7C,CAAC;EACD,OAAOO,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,eAAeA,CA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AAQ,CAAC;EAClE,MAAMK,YAAY,GAAG5B,WAAW,CAAC6B,gBAAgB,CAAC,CAAC,CAACF,SAAS,CAACJ,QAAQ,CAAC;EACvE,OAAO;IACLF,KAAK;IACLS,WAAW,EAAEA,CAAA,KAAM;MACjB,IAAIV,KAAK,EAAEE,YAAY,CAACF,KAAK,CAAC;MAC9BA,KAAK,GAAG,IAAI;MACZK,UAAU,CAAC,CAAC;MACZG,YAAY,CAAC,CAAC;IAChB;EACF,CAAC;AACH","ignoreList":[]}
@@ -7,30 +7,26 @@
7
7
  * - TanStack Query with `networkMode: 'offlineFirst'` for queries and mutations
8
8
  * so cached data is served immediately and mutations are queued (paused) while
9
9
  * the browser/device reports offline.
10
- * - `persistQueryClient(...)` from `@tanstack/react-query-persist-client` so that
11
- * query results AND paused mutations survive a cold restart (kill-and-relaunch).
10
+ * - `attachQueryPersistence(...)` so that query results AND paused mutations
11
+ * survive a cold restart (kill-and-relaunch); see `persistedQueryCache.ts`.
12
12
  * - `onlineManager` resume hook so paused mutations replay the moment the
13
13
  * network is reported back, even if the host app swapped in a custom
14
14
  * onlineManager implementation.
15
15
  *
16
- * Storage layer:
17
- * - React Native -> AsyncStorage via `createAsyncStoragePersister`.
18
- * - Web -> localStorage via `createSyncStoragePersister` (wrapped in the
19
- * async persister API for a single call site).
20
- * - Both adapters are content-shape compatible with our `StorageInterface`.
16
+ * Storage layer: the platform `StorageInterface` (AsyncStorage on native,
17
+ * localStorage on web).
21
18
  *
22
19
  * Whitelist policy:
23
20
  * - Persist every account/user/session/privacy query and every queued mutation.
24
21
  * - DO NOT persist large list queries (e.g. activity feeds) — they go stale
25
22
  * fast and would balloon storage. Add new keys to `PERSISTED_QUERY_PREFIXES`
26
- * when introducing reads that should survive restart.
23
+ * (`persistedQueryCache.ts`) when introducing reads that should survive restart.
27
24
  */
28
25
 
29
- import { QueryClient, hashKey, onlineManager } from '@tanstack/react-query';
30
- import { persistQueryClient } from '@tanstack/react-query-persist-client';
31
- import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
26
+ import { QueryClient, onlineManager } from '@tanstack/react-query';
32
27
  import { isDev } from '@oxy.so/core';
33
- import { getOxyBuildId } from "../utils/buildId.js";
28
+ import { accountQueryOwnership } from "./accountQueryPersistence.js";
29
+ import { PERSISTED_QUERY_PREFIXES, hydrateSnapshot, subscribeSnapshots } from "./persistedQueryCache.js";
34
30
  const QUERY_CACHE_KEY = 'oxy_query_cache_v3';
35
31
  const QUERY_CACHE_MAX_AGE = 30 * 24 * 60 * 60 * 1000; // 30 days
36
32
  const QUERY_PERSIST_THROTTLE_MS = 1_000;
@@ -50,46 +46,16 @@ export function shouldRetryQuery(failureCount, error) {
50
46
  }
51
47
 
52
48
  /**
53
- * Query-key prefixes that should survive cold restart. Anything not listed
54
- * is dropped during dehydration so the persisted blob stays small.
55
- *
56
- * Mutations are persisted independently (always) so the offline write queue
57
- * works regardless of the read whitelist.
49
+ * Whether a query belongs in the account-agnostic cache: successful (a
50
+ * `pending`/`error` state is not worth keeping, and an error would leak
51
+ * failure objects across restarts) and under one of the SDK's own prefixes.
58
52
  */
59
- const PERSISTED_QUERY_PREFIXES = ['accounts', 'users', 'sessions', 'devices', 'privacy'];
60
-
61
- /**
62
- * Adapt our `StorageInterface` (which always returns `null` for missing keys)
63
- * to TanStack's `AsyncStorage` shape. The two are structurally identical
64
- * apart from naming; this also gives us a single place to add error
65
- * suppression if a host platform's storage throws.
66
- */
67
- function adaptStorage(storage) {
68
- return {
69
- getItem: key => storage.getItem(key),
70
- setItem: (key, value) => storage.setItem(key, value),
71
- removeItem: key => storage.removeItem(key)
72
- };
73
- }
74
-
75
- /**
76
- * Decide whether a given query should be written to persistent storage.
77
- *
78
- * Two gates:
79
- * 1. The query must be in our prefix whitelist.
80
- * 2. The query must have completed successfully at least once — there's no
81
- * point persisting a `pending`/`error` state, and persisting `error` would
82
- * leak failure objects across restarts.
83
- */
84
- function shouldDehydrateQuery(query) {
53
+ function isSharedQuery(query) {
85
54
  if (query.state.status !== 'success') {
86
55
  return false;
87
56
  }
88
57
  const head = query.queryKey[0];
89
- if (typeof head !== 'string') {
90
- return false;
91
- }
92
- return PERSISTED_QUERY_PREFIXES.includes(head);
58
+ return typeof head === 'string' && PERSISTED_QUERY_PREFIXES.includes(head);
93
59
  }
94
60
 
95
61
  /**
@@ -148,58 +114,55 @@ export const createQueryClient = () => {
148
114
  return client;
149
115
  };
150
116
  /**
151
- * Wire `persistQueryClient` to the supplied storage adapter.
117
+ * Restore, then keep writing, the account-agnostic cache.
152
118
  *
153
- * Returns once the in-flight restore promise is available so callers can
154
- * `await result.restored` before rendering UI that depends on cached data.
119
+ * Queries written by another build are dropped; queued mutations are kept
120
+ * (`persistedQueryCache.ts`). Whatever the app declared account-scoped
121
+ * (`accountQueries`) is left to `createAccountQueryPersistence`, even under
122
+ * one of the SDK's prefixes, so private rows never land in the shared blob and
123
+ * a paused mutation cannot replay twice or under another account.
155
124
  *
156
125
  * Safe to no-op if `storage` is null/undefined (e.g. server-side render
157
126
  * with no host storage).
158
127
  */
159
- export const attachQueryPersistence = (queryClient, storage,
160
- /**
161
- * Mutation keys the app declared account-scoped (`accountQueries`). Those are
162
- * persisted per account by `createAccountQueryPersistence`, never here, so a
163
- * paused mutation cannot replay twice or under another account.
164
- */
165
- accountMutationKeys = []) => {
128
+ export const attachQueryPersistence = (queryClient, storage, accountQueries) => {
166
129
  if (!storage) {
167
130
  return {
168
131
  restored: Promise.resolve(),
169
132
  unsubscribe: () => {}
170
133
  };
171
134
  }
172
- const persister = createAsyncStoragePersister({
173
- storage: adaptStorage(storage),
174
- key: QUERY_CACHE_KEY,
175
- throttleTime: QUERY_PERSIST_THROTTLE_MS
176
- });
177
-
178
- // Persist every other mutation regardless of status: paused mutations are
179
- // exactly the ones that must survive restart to replay when online.
180
- const accountScoped = new Set(accountMutationKeys.map(key => hashKey(key)));
181
- const shouldDehydrateMutation = mutation => {
182
- const key = mutation.options.mutationKey;
183
- return key === undefined || !accountScoped.has(hashKey(key));
135
+ const account = accountQueries ? accountQueryOwnership(accountQueries) : null;
136
+ const filters = {
137
+ shouldDehydrateQuery: query => isSharedQuery(query) && !(account?.ownsQuery(query) ?? false),
138
+ // Every other mutation, whatever its status: paused ones are exactly the
139
+ // ones that must survive a restart to replay when online.
140
+ shouldDehydrateMutation: mutation => !(account?.ownsMutation(mutation) ?? false)
184
141
  };
185
- const [unsubscribe, restored] = persistQueryClient({
186
- queryClient,
187
- persister,
188
- maxAge: QUERY_CACHE_MAX_AGE,
189
- buster: getOxyBuildId(),
190
- dehydrateOptions: {
191
- shouldDehydrateQuery,
192
- shouldDehydrateMutation
142
+ let stopped = false;
143
+ let writer = null;
144
+ const restored = (async () => {
145
+ const raw = await storage.getItem(QUERY_CACHE_KEY);
146
+ if (stopped) return;
147
+ if (!hydrateSnapshot(queryClient, raw, QUERY_CACHE_MAX_AGE) && raw) {
148
+ await storage.removeItem(QUERY_CACHE_KEY);
193
149
  }
194
- });
195
- restored.catch(error => {
150
+ })().catch(error => {
196
151
  if (isDev()) {
197
152
  console.warn('[QueryClient] Failed to restore persisted cache', error);
198
153
  }
154
+ }).then(() => {
155
+ if (stopped) return;
156
+ writer = subscribeSnapshots(queryClient, filters, QUERY_PERSIST_THROTTLE_MS, serialized => {
157
+ void Promise.resolve(storage.setItem(QUERY_CACHE_KEY, serialized)).catch(() => undefined);
158
+ });
199
159
  });
200
160
  return {
201
- unsubscribe,
202
- restored
161
+ restored,
162
+ unsubscribe: () => {
163
+ stopped = true;
164
+ writer?.unsubscribe();
165
+ }
203
166
  };
204
167
  };
205
168
 
@@ -1 +1 @@
1
- {"version":3,"names":["QueryClient","hashKey","onlineManager","persistQueryClient","createAsyncStoragePersister","isDev","getOxyBuildId","QUERY_CACHE_KEY","QUERY_CACHE_MAX_AGE","QUERY_PERSIST_THROTTLE_MS","MAX_QUERY_RETRIES","statusOf","error","value","status","response","shouldRetryQuery","failureCount","PERSISTED_QUERY_PREFIXES","adaptStorage","storage","getItem","key","setItem","removeItem","shouldDehydrateQuery","query","state","head","queryKey","includes","createQueryClient","client","defaultOptions","queries","staleTime","gcTime","retry","retryDelay","attemptIndex","Math","min","refetchOnReconnect","refetchOnWindowFocus","networkMode","mutations","unsubscribe","subscribe","isOnline","getMutationCache","resumePausedMutations","Object","defineProperty","enumerable","configurable","writable","attachQueryPersistence","queryClient","accountMutationKeys","restored","Promise","resolve","persister","throttleTime","accountScoped","Set","map","shouldDehydrateMutation","mutation","options","mutationKey","undefined","has","maxAge","buster","dehydrateOptions","catch","console","warn","clearQueryCache"],"sourceRoot":"../../../../src","sources":["ui/hooks/queryClient.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,OAAO,EAAEC,aAAa,QAAkD,uBAAuB;AACrH,SACEC,kBAAkB,QAEb,sCAAsC;AAC7C,SAASC,2BAA2B,QAAQ,yCAAyC;AACrF,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,aAAa,QAAQ,qBAAkB;AAEhD,MAAMC,eAAe,GAAG,oBAAoB;AAC5C,MAAMC,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACtD,MAAMC,yBAAyB,GAAG,KAAK;AACvC,MAAMC,iBAAiB,GAAG,CAAC;AAE3B,SAASC,QAAQA,CAACC,KAAc,EAAiB;EAC/C,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,IAAI;EACpD,MAAMC,KAAK,GAAID,KAAK,CAA2DE,MAAM,IAC/EF,KAAK,CAAyCG,QAAQ,EAAED,MAAM;EACpE,OAAO,OAAOD,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,IAAI;AACjD;;AAEA;AACA,OAAO,SAASG,gBAAgBA,CAACC,YA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O,CAACC,IAAI,CAAC,qDAAqD,EAAElE,KAAK,CAAC;IAC5E;EACF;AACF,CAAC;;AAED;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["QueryClient","onlineManager","isDev","accountQueryOwnership","PERSISTED_QUERY_PREFIXES","hydrateSnapshot","subscribeSnapshots","QUERY_CACHE_KEY","QUERY_CACHE_MAX_AGE","QUERY_PERSIST_THROTTLE_MS","MAX_QUERY_RETRIES","statusOf","error","value","status","response","shouldRetryQuery","failureCount","isSharedQuery","query","state","head","queryKey","includes","createQueryClient","client","defaultOptions","queries","staleTime","gcTime","retry","retryDelay","attemptIndex","Math","min","refetchOnReconnect","refetchOnWindowFocus","networkMode","mutations","unsubscribe","subscribe","isOnline","getMutationCache","resumePausedMutations","Object","defineProperty","enumerable","configurable","writable","attachQueryPersistence","queryClient","storage","accountQueries","restored","Promise","resolve","account","filters","shouldDehydrateQuery","ownsQuery","shouldDehydrateMutation","mutation","ownsMutation","stopped","writer","raw","getItem","removeItem","catch","console","warn","then","serialized","setItem","undefined","clearQueryCache"],"sourceRoot":"../../../../src","sources":["ui/hooks/queryClient.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,EAAEC,aAAa,QAAmC,uBAAuB;AAE7F,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,qBAAqB,QAAmC,8BAA2B;AAC5F,SAASC,wBAAwB,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,0BAAuB;AAErG,MAAMC,eAAe,GAAG,oBAAoB;AAC5C,MAAMC,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACtD,MAAMC,yBAAyB,GAAG,KAAK;AACvC,MAAMC,iBAAiB,GAAG,CAAC;AAE3B,SAASC,QAAQA,CAACC,KAAc,EAAi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AMA,OAAO,CAACgB,UAAU,CAAC5D,eAAe,CAAC;EAC3C,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd,IAAIV,KAAK,CAAC,CAAC,EAAE;MACXmE,OAAO,CAACC,IAAI,CAAC,qDAAqD,EAAE1D,KAAK,CAAC;IAC5E;EACF;AACF,CAAC;;AAED;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgF/B,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EAExB,MAAM,mBAAmB,CAAC;AAU3B,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAMhG,KAAK,0BAA0B,GAAG,IAAI,CACpC,eAAe,EACb,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,CACtB,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAixChE,CAAC;AAMF,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,0BAA0B;;CAMxC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,QAAO,eAMzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,eAAe,GAAG,IAAqC,CAAC;AAE1F,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAO,0BAMpC,CAAC"}
1
+ {"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgF/B,OA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