@arbidocs/react 0.5.143 → 0.5.144
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.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/offline.js +2 -1
- package/dist/offline.js.map +2 -2
- package/package.json +3 -3
package/dist/offline.js
CHANGED
|
@@ -41,7 +41,8 @@ function isOfflineReadableArbiQuery(queryKey) {
|
|
|
41
41
|
}
|
|
42
42
|
function isRestorableArbiQueryOnline(queryKey, data) {
|
|
43
43
|
if (queryKey[0] !== "arbi") return true;
|
|
44
|
-
if (queryKey[1] === "documents" || queryKey[1] === "entitlements"
|
|
44
|
+
if (queryKey[1] === "documents" || queryKey[1] === "entitlements" || queryKey[1] === "userSettings")
|
|
45
|
+
return false;
|
|
45
46
|
if (!DOCUMENT_FAMILIES.includes(queryKey[1])) return true;
|
|
46
47
|
const docs = Array.isArray(data) ? data : [data];
|
|
47
48
|
return !docs.some((doc) => {
|
package/dist/offline.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/offline.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Offline writes that survive a reload \u2014 opt in. A mutation made while offline pauses and is sent on\n * reconnect; a host that also persists its query cache (`@tanstack/react-query-persist-client`)\n * keeps the paused write across a reload, but the restored mutation has lost its function. Call\n * {@link registerArbiMutationDefaults} once on the query client, before the persisted cache is\n * restored and `resumePausedMutations()` runs: it gives each replayable package write its request\n * back (on a bare client: the hook's `Arbi` may not exist yet) and what its success does to the\n * cache. {@link isReplayableArbiMutation} says which writes those are, for a host's\n * `shouldDehydrateMutation` and its pending-changes list.\n *\n * Replayable: creating a tag (`useCreateTag`), editing documents' fields (`useUpdateDocuments`),\n * and applying, removing or re-noting a tag on documents (`useAssignDocTags`, `useRemoveDocTags`,\n * `useUpdateDocTag`). Each keeps the workspace it was made in and is replayed there\n * (`queued-writes.ts`), whichever workspace is open after the reload.\n */\n\nimport type { MutationKey, QueryClient, QueryKey } from '@tanstack/react-query'\nimport { partialMatchKey } from '@tanstack/react-query'\nimport type { ArbiClient } from '@arbidocs/client'\nimport { replayableTagMutations } from './tags'\nimport { replayableDocumentMutations } from './documents/documents-writes'\nimport { FINISHED_DOCUMENT_STATUSES } from './documents/documents-data'\nimport { QUEUED_WRITE_RETRY } from './queued-writes'\n\ninterface ReplayableMutation {\n mutationKey: MutationKey\n // Each entry types its own variables and result; the registry only passes them through.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n run: (client: ArbiClient, variables: any) => Promise<unknown>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n settle: (qc: QueryClient, data: any, variables: any) => unknown\n}\n\nconst REPLAYABLE: readonly ReplayableMutation[] = [\n ...replayableTagMutations,\n ...replayableDocumentMutations,\n]\n\n/** Whether a mutation is a package write that can be queued offline and replayed after a reload. */\nexport function isReplayableArbiMutation(mutationKey: MutationKey | undefined): boolean {\n return !!mutationKey && REPLAYABLE.some((m) => partialMatchKey(mutationKey, m.mutationKey))\n}\n\n/**\n * Re-supply the replayable package writes on `queryClient` (see the module comment). `client` is\n * the host's API client, read when a restored write is sent.\n */\nexport function registerArbiMutationDefaults(\n queryClient: QueryClient,\n client: () => ArbiClient\n): void {\n for (const m of REPLAYABLE) {\n queryClient.setMutationDefaults(m.mutationKey, {\n // Each write is sent in the workspace it was made in (kept in its variables), never in the\n // one open when it is replayed; one whose workspace can't be opened is tried again, then\n // kept as not sent.\n mutationFn: (variables: unknown) => m.run(client(), variables),\n onSuccess: (data: unknown, variables: unknown) => m.settle(queryClient, data, variables),\n ...QUEUED_WRITE_RETRY,\n })\n }\n}\n\n/** The package query families holding document metadata (never content). */\nconst DOCUMENT_FAMILIES = [\n 'documents',\n 'document',\n 'documentsById',\n 'documentVersions',\n 'similarDocuments',\n]\n\n/**\n * The package query families a host may persist for an offline start. The entitlements too: the\n * paid pages (Mail, Calendar) open only once they are known, so without them a reopened tab offline\n * showed an empty page instead of the mailbox and Outbox kept on this device.\n */\nconst OFFLINE_READABLE = [\n ...DOCUMENT_FAMILIES,\n 'workspaces',\n 'userSettings',\n 'projects',\n 'entitlements',\n]\n\n/**\n * Whether a package query is worth persisting for an offline start (a host's\n * `shouldDehydrateQuery`): the documents lists, documents, their versions and near-duplicate\n * pairs (metadata, never a document's content), the workspace list (its keys stay wrapped), the\n * user settings, the projects and the entitlements.\n */\nexport function isOfflineReadableArbiQuery(queryKey: QueryKey): boolean {\n return queryKey[0] === 'arbi' && OFFLINE_READABLE.includes(queryKey[1] as string)\n}\n\n/**\n * Whether a persisted package query may be restored when the app starts online. Not a documents\n * list (it is never re-read on its own, so a stale copy would be trusted all session: it loads\n * fresh instead), nor a document saved while still processing (its saved freshness would keep it\n * \"processing\" with no re-read), nor the entitlements (kept for an offline start only: online they
|
|
5
|
-
"mappings": "AAiBA,SAAS,uBAAuB;AAEhC,SAAS,8BAA8B;AACvC,SAAS,mCAAmC;AAC5C,SAAS,kCAAkC;AAC3C,SAAS,0BAA0B;AAWnC,MAAM,aAA4C;AAAA,EAChD,GAAG;AAAA,EACH,GAAG;AACL;AAGO,SAAS,yBAAyB,aAA+C;AACtF,SAAO,CAAC,CAAC,eAAe,WAAW,KAAK,CAAC,MAAM,gBAAgB,aAAa,EAAE,WAAW,CAAC;AAC5F;AAMO,SAAS,6BACd,aACA,QACM;AACN,aAAW,KAAK,YAAY;AAC1B,gBAAY,oBAAoB,EAAE,aAAa;AAAA;AAAA;AAAA;AAAA,MAI7C,YAAY,CAAC,cAAuB,EAAE,IAAI,OAAO,GAAG,SAAS;AAAA,MAC7D,WAAW,CAAC,MAAe,cAAuB,EAAE,OAAO,aAAa,MAAM,SAAS;AAAA,MACvF,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAGA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOA,MAAM,mBAAmB;AAAA,EACvB,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,2BAA2B,UAA6B;AACtE,SAAO,SAAS,CAAC,MAAM,UAAU,iBAAiB,SAAS,SAAS,CAAC,CAAW;AAClF;
|
|
4
|
+
"sourcesContent": ["/**\n * Offline writes that survive a reload \u2014 opt in. A mutation made while offline pauses and is sent on\n * reconnect; a host that also persists its query cache (`@tanstack/react-query-persist-client`)\n * keeps the paused write across a reload, but the restored mutation has lost its function. Call\n * {@link registerArbiMutationDefaults} once on the query client, before the persisted cache is\n * restored and `resumePausedMutations()` runs: it gives each replayable package write its request\n * back (on a bare client: the hook's `Arbi` may not exist yet) and what its success does to the\n * cache. {@link isReplayableArbiMutation} says which writes those are, for a host's\n * `shouldDehydrateMutation` and its pending-changes list.\n *\n * Replayable: creating a tag (`useCreateTag`), editing documents' fields (`useUpdateDocuments`),\n * and applying, removing or re-noting a tag on documents (`useAssignDocTags`, `useRemoveDocTags`,\n * `useUpdateDocTag`). Each keeps the workspace it was made in and is replayed there\n * (`queued-writes.ts`), whichever workspace is open after the reload.\n */\n\nimport type { MutationKey, QueryClient, QueryKey } from '@tanstack/react-query'\nimport { partialMatchKey } from '@tanstack/react-query'\nimport type { ArbiClient } from '@arbidocs/client'\nimport { replayableTagMutations } from './tags'\nimport { replayableDocumentMutations } from './documents/documents-writes'\nimport { FINISHED_DOCUMENT_STATUSES } from './documents/documents-data'\nimport { QUEUED_WRITE_RETRY } from './queued-writes'\n\ninterface ReplayableMutation {\n mutationKey: MutationKey\n // Each entry types its own variables and result; the registry only passes them through.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n run: (client: ArbiClient, variables: any) => Promise<unknown>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n settle: (qc: QueryClient, data: any, variables: any) => unknown\n}\n\nconst REPLAYABLE: readonly ReplayableMutation[] = [\n ...replayableTagMutations,\n ...replayableDocumentMutations,\n]\n\n/** Whether a mutation is a package write that can be queued offline and replayed after a reload. */\nexport function isReplayableArbiMutation(mutationKey: MutationKey | undefined): boolean {\n return !!mutationKey && REPLAYABLE.some((m) => partialMatchKey(mutationKey, m.mutationKey))\n}\n\n/**\n * Re-supply the replayable package writes on `queryClient` (see the module comment). `client` is\n * the host's API client, read when a restored write is sent.\n */\nexport function registerArbiMutationDefaults(\n queryClient: QueryClient,\n client: () => ArbiClient\n): void {\n for (const m of REPLAYABLE) {\n queryClient.setMutationDefaults(m.mutationKey, {\n // Each write is sent in the workspace it was made in (kept in its variables), never in the\n // one open when it is replayed; one whose workspace can't be opened is tried again, then\n // kept as not sent.\n mutationFn: (variables: unknown) => m.run(client(), variables),\n onSuccess: (data: unknown, variables: unknown) => m.settle(queryClient, data, variables),\n ...QUEUED_WRITE_RETRY,\n })\n }\n}\n\n/** The package query families holding document metadata (never content). */\nconst DOCUMENT_FAMILIES = [\n 'documents',\n 'document',\n 'documentsById',\n 'documentVersions',\n 'similarDocuments',\n]\n\n/**\n * The package query families a host may persist for an offline start. The entitlements too: the\n * paid pages (Mail, Calendar) open only once they are known, so without them a reopened tab offline\n * showed an empty page instead of the mailbox and Outbox kept on this device.\n */\nconst OFFLINE_READABLE = [\n ...DOCUMENT_FAMILIES,\n 'workspaces',\n 'userSettings',\n 'projects',\n 'entitlements',\n]\n\n/**\n * Whether a package query is worth persisting for an offline start (a host's\n * `shouldDehydrateQuery`): the documents lists, documents, their versions and near-duplicate\n * pairs (metadata, never a document's content), the workspace list (its keys stay wrapped), the\n * user settings, the projects and the entitlements.\n */\nexport function isOfflineReadableArbiQuery(queryKey: QueryKey): boolean {\n return queryKey[0] === 'arbi' && OFFLINE_READABLE.includes(queryKey[1] as string)\n}\n\n/**\n * Whether a persisted package query may be restored when the app starts online. Not a documents\n * list (it is never re-read on its own, so a stale copy would be trusted all session: it loads\n * fresh instead), nor a document saved while still processing (its saved freshness would keep it\n * \"processing\" with no re-read), nor the entitlements or the user settings (kept for an offline start\n * only: online they are read fresh, so a plan bought since shows at once, and a setting written just\n * before a reload, whose persisted copy may predate it, is not lost for the settings' half-hour\n * staleness). The other families (the workspace list, the projects) always. Offline, everything\n * persisted is restored.\n */\nexport function isRestorableArbiQueryOnline(queryKey: QueryKey, data: unknown): boolean {\n if (queryKey[0] !== 'arbi') return true\n if (\n queryKey[1] === 'documents' ||\n queryKey[1] === 'entitlements' ||\n queryKey[1] === 'userSettings'\n )\n return false\n if (!DOCUMENT_FAMILIES.includes(queryKey[1] as string)) return true\n const docs = Array.isArray(data) ? data : [data]\n return !docs.some((doc) => {\n const status = (doc as { status?: string | null } | null)?.status\n return !!status && !FINISHED_DOCUMENT_STATUSES.has(status)\n })\n}\n"],
|
|
5
|
+
"mappings": "AAiBA,SAAS,uBAAuB;AAEhC,SAAS,8BAA8B;AACvC,SAAS,mCAAmC;AAC5C,SAAS,kCAAkC;AAC3C,SAAS,0BAA0B;AAWnC,MAAM,aAA4C;AAAA,EAChD,GAAG;AAAA,EACH,GAAG;AACL;AAGO,SAAS,yBAAyB,aAA+C;AACtF,SAAO,CAAC,CAAC,eAAe,WAAW,KAAK,CAAC,MAAM,gBAAgB,aAAa,EAAE,WAAW,CAAC;AAC5F;AAMO,SAAS,6BACd,aACA,QACM;AACN,aAAW,KAAK,YAAY;AAC1B,gBAAY,oBAAoB,EAAE,aAAa;AAAA;AAAA;AAAA;AAAA,MAI7C,YAAY,CAAC,cAAuB,EAAE,IAAI,OAAO,GAAG,SAAS;AAAA,MAC7D,WAAW,CAAC,MAAe,cAAuB,EAAE,OAAO,aAAa,MAAM,SAAS;AAAA,MACvF,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;AAGA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOA,MAAM,mBAAmB;AAAA,EACvB,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,2BAA2B,UAA6B;AACtE,SAAO,SAAS,CAAC,MAAM,UAAU,iBAAiB,SAAS,SAAS,CAAC,CAAW;AAClF;AAYO,SAAS,4BAA4B,UAAoB,MAAwB;AACtF,MAAI,SAAS,CAAC,MAAM,OAAQ,QAAO;AACnC,MACE,SAAS,CAAC,MAAM,eAChB,SAAS,CAAC,MAAM,kBAChB,SAAS,CAAC,MAAM;AAEhB,WAAO;AACT,MAAI,CAAC,kBAAkB,SAAS,SAAS,CAAC,CAAW,EAAG,QAAO;AAC/D,QAAM,OAAO,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAC/C,SAAO,CAAC,KAAK,KAAK,CAAC,QAAQ;AACzB,UAAM,SAAU,KAA2C;AAC3D,WAAO,CAAC,CAAC,UAAU,CAAC,2BAA2B,IAAI,MAAM;AAAA,EAC3D,CAAC;AACH;",
|
|
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.144",
|
|
4
4
|
"description": "React hooks and provider for the ARBI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
"build-storybook": "storybook build"
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@arbidocs/client": "0.5.
|
|
121
|
-
"@arbidocs/sdk": "0.5.
|
|
120
|
+
"@arbidocs/client": "0.5.144",
|
|
121
|
+
"@arbidocs/sdk": "0.5.144",
|
|
122
122
|
"@didit-protocol/sdk-web": "0.4.0",
|
|
123
123
|
"@livekit/components-react": "2.9.24",
|
|
124
124
|
"@radix-ui/react-avatar": "^1.2.0",
|