@arbidocs/react 0.5.170 → 0.5.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -14933,7 +14933,7 @@ interface DmAvatarProps {
|
|
|
14933
14933
|
declare function DmAvatar({ user, className, size }: DmAvatarProps): React$1.JSX.Element;
|
|
14934
14934
|
|
|
14935
14935
|
/** Observe an existing Home run without changing the selected workspace. */
|
|
14936
|
-
declare function useAgentDmProgress(responseId: string | null | undefined): _tanstack_react_query.UseQueryResult<NoInfer<{
|
|
14936
|
+
declare function useAgentDmProgress(responseId: string | null | undefined, workspaceId?: string | null): _tanstack_react_query.UseQueryResult<NoInfer<{
|
|
14937
14937
|
id: string;
|
|
14938
14938
|
object: "response";
|
|
14939
14939
|
status: "completed" | "in_progress" | "queued" | "cancelled" | "failed" | "incomplete";
|
package/dist/query-persist.js
CHANGED
|
@@ -46,9 +46,7 @@ function createIDBPersister() {
|
|
|
46
46
|
if (!persisted) return persisted;
|
|
47
47
|
const isOffline = typeof navigator !== "undefined" && navigator.onLine === false;
|
|
48
48
|
if (isOffline) return persisted;
|
|
49
|
-
persisted.clientState.queries = persisted.clientState.queries.filter(
|
|
50
|
-
(q) => isRestorableArbiQueryOnline(q.queryKey, q.state.data)
|
|
51
|
-
);
|
|
49
|
+
persisted.clientState.queries = persisted.clientState.queries.filter((q) => isRestorableArbiQueryOnline(q.queryKey, q.state.data)).map((q) => ({ ...q, state: { ...q.state, dataUpdatedAt: 0 } }));
|
|
52
50
|
return persisted;
|
|
53
51
|
},
|
|
54
52
|
removeClient: () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/query-persist.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The query cache kept for an offline start (`createArbiQueryClient({ persist: true })`).\n *\n * Persists a *metadata-only* slice of the query cache to IndexedDB so an already signed-in user\n * can cold-start offline and still see their workspaces and documents list (and open a pinned\n * document). Deliberately conservative about what is written to disk: only the families\n * {@link isOfflineReadableArbiQuery} names; NEVER conversations, messages or document bytes (the\n * pinned bytes live separately, encrypted: `offline-documents.ts`).\n *\n * An async IndexedDB persister (idb-keyval, structured clone) rather than the JSON sync persister:\n * the robust choice for binary-capable storage.\n */\n\nimport { get, set, del } from 'idb-keyval'\nimport type {\n PersistedClient,\n Persister,\n PersistQueryClientOptions,\n} from '@tanstack/react-query-persist-client'\nimport { throttle } from './lib/throttle'\nimport {\n isOfflineReadableArbiQuery,\n isReplayableArbiMutation,\n isRestorableArbiQueryOnline,\n} from './offline'\n\nlet storageFailed = false\n\n// Optional offline persistence must never prevent an online sign-in. Once storage fails,\n// keep it disabled for this page, including restoration, so another account's queue cannot replay.\nasync function withStorage<T>(operation: () => Promise<T>): Promise<T | undefined> {\n if (storageFailed) return undefined\n try {\n return await operation()\n } catch {\n storageFailed = true\n console.warn('[offline] Browser storage unavailable; offline persistence is disabled.')\n return undefined\n }\n}\n\nconst IDB_KEY = 'arbi-react-query-cache'\n\n// Which account the persisted offline queue belongs to. The queue is one record\n// per browser, so it is only valid for the account that wrote it.\nconst OWNER_KEY = 'arbi-react-query-cache-owner'\n\n// Bump to invalidate everyone's persisted cache after an incompatible change.\n// v2: documents and their writes moved to the `@arbidocs/react` keys.\nconst CACHE_BUSTER = 'arbi-rq-v2'\n\nconst MAX_AGE = 1000 * 60 * 60 * 24 * 7 // 7 days\n\n/**\n * At most this often the cache is written. The persist subscription hands over the whole dehydrated\n * cache on every cache event (a processing burst is hundreds a second) and leaves throttling to the\n * persister, so writing each one would clone and store the documents lists on every event.\n */\nexport const PERSIST_THROTTLE_MS = 1000\n\n/** What `<PersistQueryClientProvider persistOptions>` takes for the package's offline cache. */\nexport type ArbiQueryPersistOptions = Omit<PersistQueryClientOptions, 'queryClient'>\n\nfunction createIDBPersister(): Persister {\n const write = throttle((client: PersistedClient) => {\n void withStorage(() => set(IDB_KEY, client))\n }, PERSIST_THROTTLE_MS)\n // A page going away writes what is pending.\n if (typeof window !== 'undefined') window.addEventListener('pagehide', () => write.flush())\n return {\n persistClient: async (client: PersistedClient) => {\n write(client)\n },\n // The offline persister must be INERT when online. Because the documents\n // list never auto-refetches, a rehydrated copy would be trusted\n // indefinitely and surface stale statuses across a reload \u2014 e.g. a document\n // that finished processing while the tab was closed (its one-shot\n // completion WS event is long gone) still renders as \"queued\". So when\n // online we strip that query from the restored cache; it then loads\n // fresh from the server exactly as it did before offline support existed.\n // A document caught mid-processing is stripped for the same reason, and the\n // entitlements are read fresh (isRestorableArbiQueryOnline).\n // Queued offline mutations and all other queries restore normally. When\n // offline we keep everything so the pages still have something to show.\n restoreClient: async () => {\n const persisted = await withStorage(() => get<PersistedClient>(IDB_KEY))\n if (!persisted) return persisted\n const isOffline = typeof navigator !== 'undefined' && navigator.onLine === false\n if (isOffline) return persisted\n persisted.clientState.queries = persisted.clientState.queries.filter((q)
|
|
5
|
-
"mappings": "AAaA,SAAS,KAAK,KAAK,WAAW;AAM9B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAI,gBAAgB;AAIpB,eAAe,YAAe,WAAqD;AACjF,MAAI,cAAe,QAAO;AAC1B,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,QAAQ;AACN,oBAAgB;AAChB,YAAQ,KAAK,yEAAyE;AACtF,WAAO;AAAA,EACT;AACF;AAEA,MAAM,UAAU;AAIhB,MAAM,YAAY;AAIlB,MAAM,eAAe;AAErB,MAAM,UAAU,MAAO,KAAK,KAAK,KAAK;AAO/B,MAAM,sBAAsB;AAKnC,SAAS,qBAAgC;AACvC,QAAM,QAAQ,SAAS,CAAC,WAA4B;AAClD,SAAK,YAAY,MAAM,IAAI,SAAS,MAAM,CAAC;AAAA,EAC7C,GAAG,mBAAmB;AAEtB,MAAI,OAAO,WAAW,YAAa,QAAO,iBAAiB,YAAY,MAAM,MAAM,MAAM,CAAC;AAC1F,SAAO;AAAA,IACL,eAAe,OAAO,WAA4B;AAChD,YAAM,MAAM;AAAA,IACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYA,eAAe,YAAY;AACzB,YAAM,YAAY,MAAM,YAAY,MAAM,IAAqB,OAAO,CAAC;AACvE,UAAI,CAAC,UAAW,QAAO;AACvB,YAAM,YAAY,OAAO,cAAc,eAAe,UAAU,WAAW;AAC3E,UAAI,UAAW,QAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * The query cache kept for an offline start (`createArbiQueryClient({ persist: true })`).\n *\n * Persists a *metadata-only* slice of the query cache to IndexedDB so an already signed-in user\n * can cold-start offline and still see their workspaces and documents list (and open a pinned\n * document). Deliberately conservative about what is written to disk: only the families\n * {@link isOfflineReadableArbiQuery} names; NEVER conversations, messages or document bytes (the\n * pinned bytes live separately, encrypted: `offline-documents.ts`).\n *\n * An async IndexedDB persister (idb-keyval, structured clone) rather than the JSON sync persister:\n * the robust choice for binary-capable storage.\n */\n\nimport { get, set, del } from 'idb-keyval'\nimport type {\n PersistedClient,\n Persister,\n PersistQueryClientOptions,\n} from '@tanstack/react-query-persist-client'\nimport { throttle } from './lib/throttle'\nimport {\n isOfflineReadableArbiQuery,\n isReplayableArbiMutation,\n isRestorableArbiQueryOnline,\n} from './offline'\n\nlet storageFailed = false\n\n// Optional offline persistence must never prevent an online sign-in. Once storage fails,\n// keep it disabled for this page, including restoration, so another account's queue cannot replay.\nasync function withStorage<T>(operation: () => Promise<T>): Promise<T | undefined> {\n if (storageFailed) return undefined\n try {\n return await operation()\n } catch {\n storageFailed = true\n console.warn('[offline] Browser storage unavailable; offline persistence is disabled.')\n return undefined\n }\n}\n\nconst IDB_KEY = 'arbi-react-query-cache'\n\n// Which account the persisted offline queue belongs to. The queue is one record\n// per browser, so it is only valid for the account that wrote it.\nconst OWNER_KEY = 'arbi-react-query-cache-owner'\n\n// Bump to invalidate everyone's persisted cache after an incompatible change.\n// v2: documents and their writes moved to the `@arbidocs/react` keys.\nconst CACHE_BUSTER = 'arbi-rq-v2'\n\nconst MAX_AGE = 1000 * 60 * 60 * 24 * 7 // 7 days\n\n/**\n * At most this often the cache is written. The persist subscription hands over the whole dehydrated\n * cache on every cache event (a processing burst is hundreds a second) and leaves throttling to the\n * persister, so writing each one would clone and store the documents lists on every event.\n */\nexport const PERSIST_THROTTLE_MS = 1000\n\n/** What `<PersistQueryClientProvider persistOptions>` takes for the package's offline cache. */\nexport type ArbiQueryPersistOptions = Omit<PersistQueryClientOptions, 'queryClient'>\n\nfunction createIDBPersister(): Persister {\n const write = throttle((client: PersistedClient) => {\n void withStorage(() => set(IDB_KEY, client))\n }, PERSIST_THROTTLE_MS)\n // A page going away writes what is pending.\n if (typeof window !== 'undefined') window.addEventListener('pagehide', () => write.flush())\n return {\n persistClient: async (client: PersistedClient) => {\n write(client)\n },\n // The offline persister must be INERT when online. Because the documents\n // list never auto-refetches, a rehydrated copy would be trusted\n // indefinitely and surface stale statuses across a reload \u2014 e.g. a document\n // that finished processing while the tab was closed (its one-shot\n // completion WS event is long gone) still renders as \"queued\". So when\n // online we strip that query from the restored cache; it then loads\n // fresh from the server exactly as it did before offline support existed.\n // A document caught mid-processing is stripped for the same reason, and the\n // entitlements are read fresh (isRestorableArbiQueryOnline).\n // Queued offline mutations and all other queries restore normally. When\n // offline we keep everything so the pages still have something to show.\n restoreClient: async () => {\n const persisted = await withStorage(() => get<PersistedClient>(IDB_KEY))\n if (!persisted) return persisted\n const isOffline = typeof navigator !== 'undefined' && navigator.onLine === false\n if (isOffline) return persisted\n // What stays is a seed shown while it reloads: marked stale, so the server's answer replaces it\n // (a workspace deleted just before the reload must not linger for the staleTime).\n persisted.clientState.queries = persisted.clientState.queries\n .filter((q) => isRestorableArbiQueryOnline(q.queryKey, q.state.data))\n .map((q) => ({ ...q, state: { ...q.state, dataUpdatedAt: 0 } }))\n return persisted\n },\n removeClient: () => {\n write.cancel()\n return withStorage(() => del(IDB_KEY))\n },\n }\n}\n\n/**\n * Hand the offline write queue to the account that is signing in. Queued edits\n * are replayed under whoever is logged in on reload, so a queue left by a\n * different account (or one whose owner was never recorded) must be discarded\n * here \u2014 otherwise another person's edit syncs, and fails, as this user.\n * The same account keeps its queue across logins.\n */\nexport async function claimOfflineQueue(userExtId: string): Promise<void> {\n await withStorage(async () => {\n const owner = await get<string>(OWNER_KEY)\n if (owner !== userExtId) await del(IDB_KEY)\n await set(OWNER_KEY, userExtId)\n })\n}\n\n/** The persistence of the offline cache (see the module comment). */\nexport function createArbiQueryPersistOptions(): ArbiQueryPersistOptions {\n return {\n persister: createIDBPersister(),\n maxAge: MAX_AGE,\n buster: CACHE_BUSTER,\n dehydrateOptions: {\n // Persist mutations that were paused offline so a queued write (apply tag,\n // edit field) survives a reload and replays on reconnect. Resuming them\n // after a reload requires the registered mutation defaults\n // (registerArbiMutationDefaults). Scope to real offline EDITS: an incidental\n // paused mutation (e.g. workspace-open) isn't a user change to queue/replay.\n shouldDehydrateMutation: (mutation) =>\n mutation.state.isPaused && isReplayableArbiMutation(mutation.options.mutationKey),\n shouldDehydrateQuery: (query) => {\n if (query.state.status !== 'success') return false\n // Every query key comes from the package factory: its offline families are the whole\n // list (document metadata, the workspace list, the settings, the projects, the\n // entitlements; never a document's content or bytes).\n return isOfflineReadableArbiQuery(query.queryKey)\n },\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAaA,SAAS,KAAK,KAAK,WAAW;AAM9B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,IAAI,gBAAgB;AAIpB,eAAe,YAAe,WAAqD;AACjF,MAAI,cAAe,QAAO;AAC1B,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,QAAQ;AACN,oBAAgB;AAChB,YAAQ,KAAK,yEAAyE;AACtF,WAAO;AAAA,EACT;AACF;AAEA,MAAM,UAAU;AAIhB,MAAM,YAA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AQ;AAAA,IACR,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMhB,yBAAyB,CAAC,aACxB,SAAS,MAAM,YAAY,yBAAyB,SAAS,QAAQ,WAAW;AAAA,MAClF,sBAAsB,CAAC,UAAU;AAC/B,YAAI,MAAM,MAAM,WAAW,UAAW,QAAO;AAI7C,eAAO,2BAA2B,MAAM,QAAQ;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/react",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.172",
|
|
4
4
|
"description": "React hooks and provider for the ARBI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
"build-storybook": "storybook build"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"@arbidocs/client": "0.5.
|
|
126
|
-
"@arbidocs/sdk": "0.5.
|
|
125
|
+
"@arbidocs/client": "0.5.172",
|
|
126
|
+
"@arbidocs/sdk": "0.5.172",
|
|
127
127
|
"@didit-protocol/sdk-web": "0.4.0",
|
|
128
128
|
"@livekit/components-react": "2.9.24",
|
|
129
129
|
"@radix-ui/react-avatar": "^1.2.0",
|