@powerhousedao/reactor-browser 6.2.3-dev.4 → 6.2.3-dev.40
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/{attachment-service-D3EhiAJ7.d.ts → attachment-service-B2UAo7sA.d.ts} +169 -59
- package/dist/attachment-service-B2UAo7sA.d.ts.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-BYd9eNbA.d.ts} +3 -3
- package/dist/client-BYd9eNbA.d.ts.map +1 -0
- package/dist/{client-D66jVnot.js → client-CSOLwWU9.js} +141 -20
- package/dist/client-CSOLwWU9.js.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-Cq5avLW5.js} +35 -22
- package/dist/client-Cq5avLW5.js.map +1 -0
- package/dist/{document-by-id-B4FIzG1w.js → dispatch-t-XkZYGh.js} +393 -54
- package/dist/dispatch-t-XkZYGh.js.map +1 -0
- package/dist/document-by-id-CQZMsJ9I.js +16 -0
- package/dist/document-by-id-CQZMsJ9I.js.map +1 -0
- package/dist/{document-model-modules-bTP87nyr.js → document-model-modules-Bfi0VEWy.js} +32 -65
- package/dist/document-model-modules-Bfi0VEWy.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-DJxHHfWq.js} +147 -120
- package/dist/document-operations-DJxHHfWq.js.map +1 -0
- package/dist/{global-OuINvEGT.d.ts → global-B0ewjXaM.d.ts} +50 -13
- package/dist/global-B0ewjXaM.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-Be363bAF.d.ts} +19 -98
- package/dist/index-Be363bAF.d.ts.map +1 -0
- package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
- package/dist/index-rtDmzViP.d.ts.map +1 -0
- package/dist/index.d.ts +383 -370
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -39
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-6h5VKAwt.d.ts → inspector-proxy-DCowaeeH.d.ts} +11 -4
- package/dist/inspector-proxy-DCowaeeH.d.ts.map +1 -0
- package/dist/{make-ph-event-functions-DBq3iWYn.js → make-ph-event-functions-FzpvQtj6.js} +1 -1
- package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-FzpvQtj6.js.map} +1 -1
- package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
- package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
- package/dist/{relational-D1RB45sA.js → relational-ChC_AWAK.js} +3 -2
- package/dist/{relational-D1RB45sA.js.map → relational-ChC_AWAK.js.map} +1 -1
- package/dist/{renown-rqK8sokh.js → renown-C9pYZRqf.js} +7 -8
- package/dist/{renown-rqK8sokh.js.map → renown-C9pYZRqf.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-Def5iO8k.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-Def5iO8k.js.map} +1 -1
- package/dist/src/ai/index.d.ts +51 -62
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +5 -8
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.d.ts +36 -44
- package/dist/src/analytics/index.d.ts.map +1 -1
- package/dist/src/analytics/index.js +2 -2
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/document-model.d.ts +3 -4
- package/dist/src/document-model.d.ts.map +1 -1
- package/dist/src/document-model.js.map +1 -1
- package/dist/src/graphql/client.d.ts +4 -3
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +5 -4
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/relational/index.d.ts +8 -9
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +3 -2
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +52 -32
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +58 -9
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
- package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
- package/dist/{switchboard-CaXQ4-5Q.js → switchboard-kKDuDWxY.js} +58 -6
- package/dist/switchboard-kKDuDWxY.js.map +1 -0
- package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
- package/dist/types-520nWrB3.d.ts.map +1 -0
- package/dist/{types-Dcv1ZLoW.d.ts → types-Cww0HJmz.d.ts} +102 -17
- package/dist/types-Cww0HJmz.d.ts.map +1 -0
- package/package.json +15 -16
- package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
- package/dist/client-BIHN_UyR.d.ts.map +0 -1
- package/dist/client-D66jVnot.js.map +0 -1
- package/dist/client-DjK30EQ-.js.map +0 -1
- package/dist/document-by-id-B4FIzG1w.js.map +0 -1
- package/dist/document-model-modules-bTP87nyr.js.map +0 -1
- package/dist/document-operations-WeE6wIDt.js.map +0 -1
- package/dist/global-OuINvEGT.d.ts.map +0 -1
- package/dist/index-B33TKEqp.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import {
|
|
3
|
-
import { t as makePHEventFunctions } from "./make-ph-event-functions-
|
|
4
|
-
import {
|
|
5
|
-
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-
|
|
1
|
+
import { C as queueOperations, S as queueActions, a as useDocumentCache, d as DocumentCache, f as IDLE_OPERATIONS_ENTRY, g as DOCUMENT_CHANGE_TYPE, m as isOperationCache, n as addDocumentCacheEventHandler, r as setDocumentCache, w as uploadOperations } from "./dispatch-t-XkZYGh.js";
|
|
2
|
+
import { B as makeAuthMiddleware, F as DocumentModelNotFoundError, R as UnsupportedDocumentTypeError, c as addSetSelectedDriveOnPopStateEventHandler, f as useSelectedDriveId, g as addSetSelectedNodeOnPopStateEventHandler, h as addSelectedNodeIdEventHandler, i as setVetraPackageManager, m as addResetSelectedNodeEventHandler, r as addVetraPackageManagerEventHandler, s as addSelectedDriveIdEventHandler, y as addDrivesEventHandler, z as ambientRenownTokenProvider } from "./document-model-modules-Bfi0VEWy.js";
|
|
3
|
+
import { t as makePHEventFunctions } from "./make-ph-event-functions-FzpvQtj6.js";
|
|
4
|
+
import { i as PhDocumentFieldsFragmentDoc, n as DocumentChangesDocument, t as createClient$1 } from "./client-CSOLwWU9.js";
|
|
5
|
+
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-Def5iO8k.js";
|
|
6
6
|
import { logger } from "document-model";
|
|
7
|
-
import { UnsupportedDocumentModelVersionError, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, deserializeSignature, documentModelDocumentType, generateId, hashDocumentStateForScope, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, toTransportAction } from "@powerhousedao/shared/document-model";
|
|
8
7
|
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
8
|
+
import { UnsupportedDocumentModelVersionError, actionSignerIdentity, actionSigningTarget, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createCopyHeader, createPresignedHeader, createZip, deserializeSignature, documentModelDocumentType, generateId, hasDerivedDocumentId, hashDocumentStateForScope, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, signaturePolicyOf, toTransportAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
9
9
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
10
|
-
import { useCallback, useEffect,
|
|
10
|
+
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
11
11
|
import { GraphQLClient } from "graphql-request";
|
|
12
12
|
import { gql } from "graphql-tag";
|
|
13
13
|
import { Kind, print } from "graphql";
|
|
@@ -39,9 +39,10 @@ function showCreateDocumentModal(documentType, documentModelVersion) {
|
|
|
39
39
|
}
|
|
40
40
|
/** Shows the delete node modal */
|
|
41
41
|
function showDeleteNodeModal(nodeOrId) {
|
|
42
|
+
const id = typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id;
|
|
42
43
|
setPHModal({
|
|
43
44
|
type: "deleteItem",
|
|
44
|
-
id
|
|
45
|
+
id
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
//#endregion
|
|
@@ -76,7 +77,7 @@ function getUserPermissions() {
|
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
78
79
|
//#region src/actions/document.ts
|
|
79
|
-
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
80
|
+
const NON_DOMAIN_SCOPES = /* @__PURE__ */ new Set(["auth", "document"]);
|
|
80
81
|
/** An unreadable drive cannot be shown to hold no duplicate, so reads throw. */
|
|
81
82
|
async function isDocumentInLocation(reactorClient, document, driveId, parentFolder) {
|
|
82
83
|
const drive = await reactorClient.get(driveId);
|
|
@@ -293,7 +294,7 @@ async function addDocument(driveId, name, documentType, parentFolder, document,
|
|
|
293
294
|
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
294
295
|
documentModelModule = module;
|
|
295
296
|
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
296
|
-
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
297
|
+
const newDocument = document ?? withSignaturePolicy(documentModelModule.utils.createDocument(), await reactorClient.getCreateSignaturePolicy());
|
|
297
298
|
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
298
299
|
newDocument.header.name = name;
|
|
299
300
|
if (preferredEditor) newDocument.header.meta = {
|
|
@@ -341,9 +342,24 @@ function isDocumentAlreadyExists(error) {
|
|
|
341
342
|
* fails leaves the drive untouched, so a retry has nothing to clean up.
|
|
342
343
|
*/
|
|
343
344
|
async function createImportedDocument(reactor, document, driveId, name, parentFolder) {
|
|
344
|
-
|
|
345
|
+
const v2Required = signaturePolicyOf(document.header) === "v2-required";
|
|
346
|
+
const keepsId = (!v2Required || hasDerivedDocumentId(document.header)) && !await reactor.isDocumentIdTaken(document.header.id);
|
|
347
|
+
let documentId = keepsId ? document.header.id : generateId();
|
|
345
348
|
for (let attempt = 1;; attempt++) {
|
|
346
|
-
|
|
349
|
+
let header;
|
|
350
|
+
if (!v2Required) header = createPresignedHeader(documentId, document.header.documentType);
|
|
351
|
+
else if (keepsId && attempt === 1) {
|
|
352
|
+
header = createPresignedHeader(documentId, document.header.documentType);
|
|
353
|
+
header.createdAtUtcIso = document.header.createdAtUtcIso;
|
|
354
|
+
header.sig = {
|
|
355
|
+
...header.sig,
|
|
356
|
+
nonce: document.header.sig.nonce
|
|
357
|
+
};
|
|
358
|
+
header.protocolVersions = { ...document.header.protocolVersions };
|
|
359
|
+
} else {
|
|
360
|
+
header = createCopyHeader(document.header);
|
|
361
|
+
documentId = header.id;
|
|
362
|
+
}
|
|
347
363
|
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
348
364
|
header.meta = document.header.meta;
|
|
349
365
|
header.name = name || document.header.name;
|
|
@@ -593,7 +609,7 @@ async function moveNode$1(driveId, src, target) {
|
|
|
593
609
|
* Duplicates a document under a new id using version-aware replay.
|
|
594
610
|
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
595
611
|
*/
|
|
596
|
-
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
612
|
+
async function _duplicateDocument(reactor, document, newId = generateId(), driveId) {
|
|
597
613
|
const documentType = document.header.documentType;
|
|
598
614
|
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
599
615
|
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
@@ -609,7 +625,14 @@ async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
609
625
|
reducers,
|
|
610
626
|
upgradeManifest
|
|
611
627
|
};
|
|
612
|
-
const
|
|
628
|
+
const selected = await reactor.getCreateProtocolVersions(driveId);
|
|
629
|
+
const header = createCopyHeader({
|
|
630
|
+
documentType: document.header.documentType,
|
|
631
|
+
protocolVersions: document.header.protocolVersions ? {
|
|
632
|
+
...selected,
|
|
633
|
+
...document.header.protocolVersions
|
|
634
|
+
} : void 0
|
|
635
|
+
}, newId, await reactor.getCreateSignaturePolicy());
|
|
613
636
|
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
614
637
|
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
615
638
|
return duplicated;
|
|
@@ -643,14 +666,16 @@ async function copyNode$1(driveId, src, target) {
|
|
|
643
666
|
return node !== void 0 && isFileNode(node);
|
|
644
667
|
});
|
|
645
668
|
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
646
|
-
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
669
|
+
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId, driveId);
|
|
647
670
|
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
648
671
|
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
672
|
+
fileNodeToCopy.targetId = duplicatedDocument.header.id;
|
|
649
673
|
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
650
674
|
} catch (e) {
|
|
651
675
|
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
652
676
|
}
|
|
653
|
-
|
|
677
|
+
const copyActions = copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput));
|
|
678
|
+
return await queueActions(drive, copyActions);
|
|
654
679
|
}
|
|
655
680
|
/**
|
|
656
681
|
* Upgrades a document to a newer document model version. Defaults to the
|
|
@@ -669,6 +694,7 @@ function screamingSnakeToCamel(s) {
|
|
|
669
694
|
}
|
|
670
695
|
/** Error thrown when a push conflict is detected with the "reject" strategy. */
|
|
671
696
|
var ConflictError = class extends Error {
|
|
697
|
+
conflict;
|
|
672
698
|
constructor(conflict) {
|
|
673
699
|
super("Push conflict: remote has new operations since last pull");
|
|
674
700
|
this.conflict = conflict;
|
|
@@ -941,43 +967,42 @@ function stampAction(action, document, revision = document.header.revision[actio
|
|
|
941
967
|
};
|
|
942
968
|
}
|
|
943
969
|
/**
|
|
944
|
-
* Signs a stamped action
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
970
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
971
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
972
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
973
|
+
* takes the signer's user and app even when the action named others.
|
|
948
974
|
*/
|
|
949
|
-
async function signStampedAction(action, signer, signal) {
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
const app = actionSigner?.app ?? signer.app;
|
|
953
|
-
if (!user || !app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
954
|
-
const signature = await signer.signAction(action, signal);
|
|
975
|
+
async function signStampedAction(action, signer, target, signal) {
|
|
976
|
+
if (!signer.user || !signer.app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
977
|
+
const signature = await signer.signAction(action, target, signal);
|
|
955
978
|
return {
|
|
956
979
|
...action,
|
|
957
980
|
context: {
|
|
958
981
|
...action.context,
|
|
959
982
|
signer: {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
signatures: [...actionSigner?.signatures ?? [], signature]
|
|
983
|
+
...actionSignerIdentity(signer),
|
|
984
|
+
signatures: [...action.context?.signer?.signatures ?? [], signature]
|
|
963
985
|
}
|
|
964
986
|
}
|
|
965
987
|
};
|
|
966
988
|
}
|
|
989
|
+
/** The log a snapshot's action is written to; the snapshot names the branch read. */
|
|
990
|
+
function snapshotTarget(action, snapshot) {
|
|
991
|
+
return actionSigningTarget(action, snapshot.header.id, snapshot.header.branch || "main");
|
|
992
|
+
}
|
|
967
993
|
/**
|
|
968
994
|
* Actions a snapshot batch cannot predict the next state for.
|
|
969
995
|
*
|
|
970
|
-
* `UNDO
|
|
971
|
-
*
|
|
996
|
+
* `UNDO` and `REDO` rewrite history the light read path never fetched (and
|
|
997
|
+
* the reducer appends no operation for them); `NOOP` is only ever produced
|
|
972
998
|
* by an undo chain; the document-scope actions run through the reactor's
|
|
973
999
|
* document-action handler rather than a document-model reducer
|
|
974
1000
|
* (`DOCUMENT_SCOPE_ACTIONS` in packages/reactor/src/executor/util.ts) and
|
|
975
1001
|
* `UPGRADE_DOCUMENT` changes which reducer applies mid-batch.
|
|
976
1002
|
*/
|
|
977
|
-
const unsupportedBatchActions = new Set([
|
|
1003
|
+
const unsupportedBatchActions = /* @__PURE__ */ new Set([
|
|
978
1004
|
"UNDO",
|
|
979
1005
|
"REDO",
|
|
980
|
-
"PRUNE",
|
|
981
1006
|
"NOOP",
|
|
982
1007
|
"CREATE_DOCUMENT",
|
|
983
1008
|
"DELETE_DOCUMENT",
|
|
@@ -1020,7 +1045,7 @@ const predictionProtocolVersion = 2;
|
|
|
1020
1045
|
*/
|
|
1021
1046
|
async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
1022
1047
|
if (actions.length === 0) return [];
|
|
1023
|
-
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, signal)];
|
|
1048
|
+
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, snapshotTarget(actions[0], snapshot), signal)];
|
|
1024
1049
|
const scope = sharedScope(actions);
|
|
1025
1050
|
assertSupportedBatch(actions);
|
|
1026
1051
|
if (!module) throw new Error(`cannot sign ${actions.length} actions: no document model module for ${snapshot.header.documentType} was supplied, so the batch state cannot be predicted`);
|
|
@@ -1035,7 +1060,8 @@ async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
|
1035
1060
|
const signed = [];
|
|
1036
1061
|
for (const [index, action] of actions.entries()) {
|
|
1037
1062
|
throwIfAborted(signal, index);
|
|
1038
|
-
const
|
|
1063
|
+
const stamped = stampAction(action, working, revision);
|
|
1064
|
+
const signedAction = await signStampedAction(stamped, signer, snapshotTarget(stamped, snapshot), signal);
|
|
1039
1065
|
signed.push(signedAction);
|
|
1040
1066
|
const before = scopeOperationCount(working, scope);
|
|
1041
1067
|
let next;
|
|
@@ -1446,7 +1472,6 @@ var GraphQLReactorClient = class {
|
|
|
1446
1472
|
results: page.items.map((item) => remoteOperationToLocal(item)),
|
|
1447
1473
|
options: effectivePaging,
|
|
1448
1474
|
nextCursor,
|
|
1449
|
-
totalCount: page.totalCount,
|
|
1450
1475
|
next: nextCursor ? () => this.getOperations(documentIdentifier, view, filter, {
|
|
1451
1476
|
cursor: nextCursor,
|
|
1452
1477
|
limit: effectivePaging.limit
|
|
@@ -1743,13 +1768,13 @@ function isGraphQLReactorClient(client) {
|
|
|
1743
1768
|
}
|
|
1744
1769
|
/** The schema's change types, mapped onto the reactor's. */
|
|
1745
1770
|
const documentChangeTypes = {
|
|
1746
|
-
[
|
|
1747
|
-
[
|
|
1748
|
-
[
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1751
|
-
[
|
|
1752
|
-
[
|
|
1771
|
+
["CREATED"]: DOCUMENT_CHANGE_TYPE.Created,
|
|
1772
|
+
["DELETED"]: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1773
|
+
["UPDATED"]: DOCUMENT_CHANGE_TYPE.Updated,
|
|
1774
|
+
["PARENT_ADDED"]: DOCUMENT_CHANGE_TYPE.ParentAdded,
|
|
1775
|
+
["PARENT_REMOVED"]: DOCUMENT_CHANGE_TYPE.ParentRemoved,
|
|
1776
|
+
["CHILD_ADDED"]: DOCUMENT_CHANGE_TYPE.ChildAdded,
|
|
1777
|
+
["CHILD_REMOVED"]: DOCUMENT_CHANGE_TYPE.ChildRemoved
|
|
1753
1778
|
};
|
|
1754
1779
|
/**
|
|
1755
1780
|
* Decides whether an event reaches a subscriber.
|
|
@@ -1804,8 +1829,8 @@ function pagingInputFromPaging(paging) {
|
|
|
1804
1829
|
* `toReactorPropagationMode`.
|
|
1805
1830
|
*/
|
|
1806
1831
|
const propagationModeInputs = {
|
|
1807
|
-
cascade:
|
|
1808
|
-
none:
|
|
1832
|
+
cascade: "CASCADE",
|
|
1833
|
+
none: "ORPHAN"
|
|
1809
1834
|
};
|
|
1810
1835
|
function propagationModeInput(propagate) {
|
|
1811
1836
|
return propagate === void 0 ? void 0 : propagationModeInputs[propagate];
|
|
@@ -2515,89 +2540,91 @@ function useSwitchboardClient() {
|
|
|
2515
2540
|
}
|
|
2516
2541
|
//#endregion
|
|
2517
2542
|
//#region src/hooks/document-operations.ts
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const
|
|
2527
|
-
const
|
|
2528
|
-
const
|
|
2529
|
-
globalOperations: [],
|
|
2530
|
-
localOperations: [],
|
|
2531
|
-
isLoading: !!documentId,
|
|
2532
|
-
error: void 0
|
|
2533
|
-
}));
|
|
2534
|
-
const fetchOperations = useCallback(async (retryCount = 0) => {
|
|
2535
|
-
const MAX_RETRIES = 5;
|
|
2536
|
-
const RETRY_DELAY_MS = 500;
|
|
2537
|
-
if (!documentId || !reactorClient) {
|
|
2538
|
-
setState({
|
|
2539
|
-
globalOperations: [],
|
|
2540
|
-
localOperations: [],
|
|
2541
|
-
isLoading: false,
|
|
2542
|
-
error: void 0
|
|
2543
|
-
});
|
|
2544
|
-
return;
|
|
2545
|
-
}
|
|
2546
|
-
setState((prev) => ({
|
|
2547
|
-
...prev,
|
|
2548
|
-
isLoading: true,
|
|
2549
|
-
error: void 0
|
|
2550
|
-
}));
|
|
2551
|
-
let globalOps = [];
|
|
2552
|
-
let localOps = [];
|
|
2553
|
-
let fetchError;
|
|
2554
|
-
try {
|
|
2555
|
-
globalOps = (await reactorClient.getOperations(documentId, { scopes: ["global"] })).results;
|
|
2556
|
-
} catch (err) {
|
|
2557
|
-
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2558
|
-
}
|
|
2559
|
-
if (!fetchError) try {
|
|
2560
|
-
localOps = (await reactorClient.getOperations(documentId, { scopes: ["local"] })).results;
|
|
2561
|
-
} catch (err) {
|
|
2562
|
-
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2563
|
-
}
|
|
2564
|
-
if (!fetchError && globalOps.length === 0 && localOps.length === 0 && retryCount < MAX_RETRIES) {
|
|
2565
|
-
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
2566
|
-
return fetchOperations(retryCount + 1);
|
|
2567
|
-
}
|
|
2568
|
-
setState({
|
|
2569
|
-
globalOperations: globalOps,
|
|
2570
|
-
localOperations: localOps,
|
|
2571
|
-
isLoading: false,
|
|
2572
|
-
error: fetchError
|
|
2573
|
-
});
|
|
2574
|
-
hasFetchedRef.current = true;
|
|
2575
|
-
}, [documentId, reactorClient]);
|
|
2543
|
+
const DEFAULT_LIMIT = 100;
|
|
2544
|
+
function toError(reason) {
|
|
2545
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
2546
|
+
}
|
|
2547
|
+
const EMPTY_OPERATIONS = [];
|
|
2548
|
+
function useScopeOperations(documentId, scope, options = {}) {
|
|
2549
|
+
const { limit = DEFAULT_LIMIT, enabled = true } = options;
|
|
2550
|
+
const documentCache = useDocumentCache();
|
|
2551
|
+
const cache = documentCache && isOperationCache(documentCache) ? documentCache : void 0;
|
|
2552
|
+
const activeId = enabled && cache && documentId ? documentId : void 0;
|
|
2553
|
+
const entry = useSyncExternalStore((onChange) => activeId && cache ? cache.subscribeOperations(activeId, onChange) : () => {}, () => activeId && cache ? cache.getOperationsState(activeId, scope) : IDLE_OPERATIONS_ENTRY);
|
|
2576
2554
|
useEffect(() => {
|
|
2577
|
-
if (
|
|
2578
|
-
else if (!documentId) {
|
|
2579
|
-
setState({
|
|
2580
|
-
globalOperations: [],
|
|
2581
|
-
localOperations: [],
|
|
2582
|
-
isLoading: false,
|
|
2583
|
-
error: void 0
|
|
2584
|
-
});
|
|
2585
|
-
hasFetchedRef.current = false;
|
|
2586
|
-
}
|
|
2555
|
+
if (activeId && cache && entry.status === "idle") cache.loadOperations(activeId, scope, limit);
|
|
2587
2556
|
}, [
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2557
|
+
activeId,
|
|
2558
|
+
cache,
|
|
2559
|
+
scope,
|
|
2560
|
+
limit,
|
|
2561
|
+
entry.status
|
|
2562
|
+
]);
|
|
2563
|
+
const fetchNextPage = useCallback(() => {
|
|
2564
|
+
if (activeId && cache) cache.loadMoreOperations(activeId, scope);
|
|
2565
|
+
}, [
|
|
2566
|
+
activeId,
|
|
2567
|
+
cache,
|
|
2568
|
+
scope
|
|
2591
2569
|
]);
|
|
2592
2570
|
const refetch = useCallback(() => {
|
|
2593
|
-
|
|
2594
|
-
}, [
|
|
2571
|
+
if (activeId && cache) cache.invalidateOperations(activeId);
|
|
2572
|
+
}, [activeId, cache]);
|
|
2573
|
+
const error = useMemo(() => entry.status === "error" ? toError(entry.error) : void 0, [entry.status, entry.error]);
|
|
2595
2574
|
return {
|
|
2596
|
-
|
|
2575
|
+
operations: entry.operations,
|
|
2576
|
+
isLoading: entry.status === "pending" || !!activeId && entry.status === "idle",
|
|
2577
|
+
error,
|
|
2578
|
+
hasNextPage: entry.hasNextPage,
|
|
2579
|
+
fetchNextPage,
|
|
2597
2580
|
refetch
|
|
2598
2581
|
};
|
|
2599
2582
|
}
|
|
2583
|
+
/** Keeps paging `result` to completion while `enabled` is true. */
|
|
2584
|
+
function useLoadAllPages(result, enabled) {
|
|
2585
|
+
useEffect(() => {
|
|
2586
|
+
if (!enabled || !result.hasNextPage || result.isLoading) return;
|
|
2587
|
+
const handle = window.setTimeout(result.fetchNextPage, 0);
|
|
2588
|
+
return () => window.clearTimeout(handle);
|
|
2589
|
+
}, [
|
|
2590
|
+
enabled,
|
|
2591
|
+
result.hasNextPage,
|
|
2592
|
+
result.isLoading,
|
|
2593
|
+
result.fetchNextPage
|
|
2594
|
+
]);
|
|
2595
|
+
}
|
|
2596
|
+
function useDocumentOperations(documentId, scope, options = {}) {
|
|
2597
|
+
const legacy = scope === void 0;
|
|
2598
|
+
const primary = useScopeOperations(documentId, legacy ? "global" : scope, legacy ? {} : options);
|
|
2599
|
+
const local = useScopeOperations(documentId, "local", { enabled: legacy });
|
|
2600
|
+
useLoadAllPages(primary, legacy);
|
|
2601
|
+
useLoadAllPages(local, legacy);
|
|
2602
|
+
const globalOperations = useMemo(() => legacy ? [...primary.operations] : EMPTY_OPERATIONS, [legacy, primary.operations]);
|
|
2603
|
+
const localOperations = useMemo(() => legacy ? [...local.operations] : EMPTY_OPERATIONS, [legacy, local.operations]);
|
|
2604
|
+
const refetch = useCallback(() => {
|
|
2605
|
+
primary.refetch();
|
|
2606
|
+
local.refetch();
|
|
2607
|
+
}, [primary.refetch, local.refetch]);
|
|
2608
|
+
const error = primary.error ?? local.error;
|
|
2609
|
+
const legacyResult = useMemo(() => ({
|
|
2610
|
+
globalOperations,
|
|
2611
|
+
localOperations,
|
|
2612
|
+
isLoading: !error && (primary.isLoading || local.isLoading || primary.hasNextPage || local.hasNextPage),
|
|
2613
|
+
error,
|
|
2614
|
+
refetch
|
|
2615
|
+
}), [
|
|
2616
|
+
globalOperations,
|
|
2617
|
+
localOperations,
|
|
2618
|
+
error,
|
|
2619
|
+
primary.isLoading,
|
|
2620
|
+
local.isLoading,
|
|
2621
|
+
primary.hasNextPage,
|
|
2622
|
+
local.hasNextPage,
|
|
2623
|
+
refetch
|
|
2624
|
+
]);
|
|
2625
|
+
return legacy ? legacyResult : primary;
|
|
2626
|
+
}
|
|
2600
2627
|
//#endregion
|
|
2601
2628
|
export { addDefaultDrivesUrlEventHandler as $, useIsAddLocalDrivesEnabled as $n, isAuthRefusalClose as $r, setEnabledEditors as $t, useReactorClientModule as A, fetchDocumentOperations as Ai, setRenownUrl as An, useSentryRelease as Ar, addRenownAdaptersEventHandler as At, useDragNode as B, addModalEventHandler as Bi, setWarnOutdatedApp as Bn, phAppConfigHooks as Br, addSwitchboardUrlEventHandler as Bt, addReactorClientModuleEventHandler as C, addDocument as Ci, setIsRelationalProcessorsEnabled as Cn, useRenownChainId as Cr, addIsExternalRelationalProcessorsEnabledEventHandler as Ct, useModelRegistry as D, deleteNode as Di, setRenownAdapters as Dn, useRouterBasename as Dr, addIsSentryTracingEnabledEventHandler as Dt, useDatabase as E, copyNode$1 as Ei, setLogLevel as En, useRequiresHardRefresh as Er, addIsRelationalProcessorsEnabledEventHandler as Et, usePackageDiscoveryService as F, renameNode as Fi, setSentryRelease as Fn, useWarnOutdatedApp as Fr, addRouterBasenameEventHandler as Ft, useFeatures as G, showPHModal as Gi, useDefaultDrivesUrl as Gn, setIsDragAndDropEnabled as Gr, phGlobalConfigSetters as Gt, useDropTarget as H, setPHModal as Hi, useAnalyticsDatabaseName as Hn, phDocumentEditorConfigHooks as Hr, addVersionEventHandler as Ht, addGraphQLReactorClientEventHandler as I, setPreferredEditorOnNode as Ii, setStudioMode as In, addAllowedDocumentTypesEventHandler as Ir, addSentryDsnEventHandler as It, useAttachmentService as J, useEnabledEditors as Jn, useIsDragAndDropEnabled as Jr, setBasePath as Jt, addAttachmentServiceEventHandler as K, usePHModal as Ki, useDisabledEditors as Kn, setIsExternalControlsEnabled as Kr, setAllowList as Kt, setGraphQLReactorClient as L, upgradeDocument as Li, setSwitchboardUrl as Ln, addIsDragAndDropEnabledEventHandler as Lr, addSentryEnvEventHandler as Lt, useSyncList as M, loadFile as Mi, setRouterBasename as Mn, useSwitchboardUrl as Mr, addRenownNetworkIdEventHandler as Mt, addPackageDiscoveryServiceEventHandler as N, moveNode$1 as Ni, setSentryDsn as Nn, useVersion as Nr, addRenownUrlEventHandler as Nt, usePGlite as O, exportFile as Oi, setRenownChainId as On, useSentryDsn as Or, addLocalDrivesEnabledEventHandler as Ot, setPackageDiscoveryService as P, renameDriveNode as Pi, setSentryEnv as Pn, useVersionCheckInterval as Pr, addRequiresHardRefreshEventHandler as Pt, addCliVersionEventHandler as Q, useIsAddDriveEnabled as Qn, viewFilterInputFromViewFilter as Qr, setDrivesPreserveStrategy as Qt, useGraphQLReactorClient as R, getUserPermissions as Ri, setVersion as Rn, addIsExternalControlsEnabledEventHandler as Rr, addSentryReleaseEventHandler as Rt, addReactorClientEventHandler as S, screamingSnakeToCamel as Si, setIsPublicDrivesEnabled as Sn, useRenownAdapters as Sr, addIsExternalProcessorsEnabledEventHandler as St, setReactorClientModule as T, addFolder$1 as Ti, setLocalDrivesEnabled as Tn, useRenownUrl as Tr, addIsPublicDrivesEnabledEventHandler as Tt, addFeaturesEventHandler as U, showCreateDocumentModal as Ui, useBasePath as Un, phDocumentEditorConfigSetters as Ur, addWarnOutdatedAppEventHandler as Ut, useDropNode as V, closePHModal as Vi, useAllowList as Vn, phAppConfigSetters as Vr, addVersionCheckIntervalEventHandler as Vt, setFeatures as W, showDeleteNodeModal as Wi, useCliVersion as Wn, setAllowedDocumentTypes as Wr, phGlobalConfigHooks as Wt, addAnalyticsDatabaseNameEventHandler as X, useGaTrackingId as Xn, GraphQLReactorClient as Xr, setDefaultDrivesUrl as Xt, addAllowListEventHandler as Y, useFileUploadOperationsChunkSize as Yn, useIsExternalControlsEnabled as Yr, setCliVersion as Yt, addBasePathEventHandler as Z, useIsAddCloudDrivesEnabled as Zn, isGraphQLReactorClient as Zr, setDisabledEditors as Zt, addRevisionHistoryVisibleEventHandler as _, ConflictError as _i, setIsEditorReadModeEnabled as _n, useIsPublicDrivesEnabled as _r, addIsDocumentModelSelectionSettingsEnabledEventHandler as _t, addPHEventHandlers as a, subgraphUrlFromGraphqlUrl as ai, setIsAddPublicDrivesEnabled as an, useIsDeleteCloudDrivesEnabled as ar, addIsAddCloudDrivesEnabledEventHandler as at, showRevisionHistory as b, extractRevisionMap as bi, setIsExternalRelationalProcessorsEnabled as bn, useLocalDrivesEnabled as br, addIsEditorReadModeEnabledEventHandler as bt, addToastEventHandler as c, resolveDocumentModelModule as ci, setIsAnalyticsExternalProcessorsEnabled as cn, useIsDiffAnalyticsEnabled as cr, addIsAddPublicDrivesEnabledEventHandler as ct, addSelectedTimelineRevisionEventHandler as d, stampAction as di, setIsDeleteLocalDrivesEnabled as dn, useIsEditorDebugModeEnabled as dr, addIsAnalyticsExternalProcessorsEnabledEventHandler as dt, makeAuthConnectionParams as ei, setFileUploadOperationsChunkSize as en, useIsAddPublicDrivesEnabled as er, addDisabledEditorsEventHandler as et, setSelectedTimelineRevision as f, MutateDocumentWithOperationsDocument as fi, setIsDeletePublicDrivesEnabled as fn, useIsEditorReadModeEnabled as fr, addIsCloudDrivesEnabledEventHandler as ft, useSelectedTimelineItem as g, revisionMapFromRevisionsList as gi, setIsEditorDebugModeEnabled as gn, useIsLocalDrivesEnabled as gr, addIsDiffAnalyticsEnabledEventHandler as gt, setSelectedTimelineItem as h, phDocumentFromMutation as hi, setIsDriveAnalyticsEnabled as hn, useIsExternalRelationalProcessorsEnabled as hr, addIsDeletePublicDrivesEnabledEventHandler as ht, useSwitchboardClient as i, describeGraphQLDocument as ii, setIsAddLocalDrivesEnabled as in, useIsCloudDrivesEnabled as ir, addGaTrackingIdEventHandler as it, useSync as j, getDocumentExtension as ji, setRequiresHardRefresh as jn, useStudioMode as jr, addRenownChainIdEventHandler as jt, useReactorClient as k, extractInitialState as ki, setRenownNetworkId as kn, useSentryEnv as kr, addLogLevelEventHandler as kt, setPHToast as l, prepareSignedActions as li, setIsCloudDrivesEnabled as ln, useIsDocumentModelSelectionSettingsEnabled as lr, addIsAnalyticsDatabaseWorkerEnabledEventHandler as lt, addSelectedTimelineItemEventHandler as m, phDocumentFromGetDocument as mi, setIsDocumentModelSelectionSettingsEnabled as mn, useIsExternalProcessorsEnabled as mr, addIsDeleteLocalDrivesEnabledEventHandler as mt, GraphQLReactorProvider as n, subscriptionsUrlFromGraphqlUrl as ni, setIsAddCloudDrivesEnabled as nn, useIsAnalyticsEnabled as nr, addEnabledEditorsEventHandler as nt, callEventHandlerRegisterFunctions as o, StaticPackageManager as oi, setIsAnalyticsDatabaseWorkerEnabled as on, useIsDeleteLocalDrivesEnabled as or, addIsAddDriveEnabledEventHandler as ot, useSelectedTimelineRevision as p, ReactorOperationFieldsFragmentDoc as pi, setIsDiffAnalyticsEnabled as pn, useIsExternalPackagesEnabled as pr, addIsDeleteCloudDrivesEnabledEventHandler as pt, setAttachmentService as q, useDrivesPreserveStrategy as qn, useAllowedDocumentTypes as qr, setAnalyticsDatabaseName as qt, ensurePHEventHandlers as r, SubgraphSdkRegistry as ri, setIsAddDriveEnabled as rn, useIsAnalyticsExternalProcessorsEnabled as rr, addFileUploadOperationsChunkSizeEventHandler as rt, commonGlobalEventHandlerFunctions as s, packageFromDocumentModels as si, setIsAnalyticsEnabled as sn, useIsDeletePublicDrivesEnabled as sr, addIsAddLocalDrivesEnabledEventHandler as st, useDocumentOperations as t, startDocumentChangesSubscription as ti, setGaTrackingId as tn, useIsAnalyticsDatabaseWorkerEnabled as tr, addDrivesPreserveStrategyEventHandler as tt, usePHToast as u, signStampedAction as ui, setIsDeleteCloudDrivesEnabled as un, useIsDriveAnalyticsEnabled as ur, addIsAnalyticsEnabledEventHandler as ut, hideRevisionHistory as v, buildPulledDocument as vi, setIsExternalPackagesEnabled as vn, useIsRelationalProcessorsEnabled as vr, addIsDriveAnalyticsEnabledEventHandler as vt, setReactorClient as w, addFileWithProgress as wi, setIsSentryTracingEnabled as wn, useRenownNetworkId as wr, addIsLocalDrivesEnabledEventHandler as wt, useRevisionHistoryVisible as x, hasRevisionConflict as xi, setIsLocalDrivesEnabled as xn, useLogLevel as xr, addIsExternalPackagesEnabledEventHandler as xt, setRevisionHistoryVisible as y, convertRemoteOperations as yi, setIsExternalProcessorsEnabled as yn, useIsSentryTracingEnabled as yr, addIsEditorDebugModeEnabledEventHandler as yt, addDraggingNodeEventHandler as z, isDocumentTypeSupported as zi, setVersionCheckInterval as zn, isExternalControlsEnabledEventFunctions as zr, addStudioModeEventHandler as zt };
|
|
2602
2629
|
|
|
2603
|
-
//# sourceMappingURL=document-operations-
|
|
2630
|
+
//# sourceMappingURL=document-operations-DJxHHfWq.js.map
|