@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.5 → 6.2.2-dev.51
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/browser/assets/{entry-Cvoo4_c9.js → entry-CHj7_KqV.js} +3 -2
- package/dist/browser/assets/{projection-entry-DVec8YRh.js → projection-entry-Deqa5Gd1.js} +4 -4
- package/dist/browser/{linting-Dn6pXRkK.js → button-CuO8Gh3v.js} +20 -6
- package/dist/browser/button-CuO8Gh3v.js.map +1 -0
- package/dist/browser/{connect-CV-z3DqA.js → connect-MB8tpoQw.js} +916 -200
- package/dist/browser/connect-MB8tpoQw.js.map +1 -0
- package/dist/browser/{dist-CXoKspdx.js → dist-B4FWbuEM.js} +10 -2
- package/dist/browser/{dist-CXoKspdx.js.map → dist-B4FWbuEM.js.map} +1 -1
- package/dist/{node/dist-BeZaEP6S.mjs → browser/dist-BAJ5nRDl.js} +21 -2
- package/dist/browser/{dist-D8H48e8N.js.map → dist-BAJ5nRDl.js.map} +1 -1
- package/dist/browser/{dist-BEs8jMgM.js → dist-BesM2uPE.js} +1559 -1292
- package/dist/browser/dist-BesM2uPE.js.map +1 -0
- package/dist/browser/{document-drive-sTKoi6L4.js → document-drive-CJz0STcj.js} +1077 -122
- package/dist/browser/document-drive-CJz0STcj.js.map +1 -0
- package/dist/browser/document-models/index.js +1 -1
- package/dist/browser/{documents-D4ek7Ubv.js → documents-J_l59mSV.js} +5 -604
- package/dist/browser/documents-J_l59mSV.js.map +1 -0
- package/dist/browser/{editor-Cw38euRs.js → editor-BDpW8vq8.js} +671 -236
- package/dist/browser/editor-BDpW8vq8.js.map +1 -0
- package/dist/browser/editor-DQ49fg9m.js +25 -0
- package/dist/browser/editor-DQ49fg9m.js.map +1 -0
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +5 -5
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/{node/folder-view-DjKO1mAh.mjs → browser/folder-view-BG4n0zgH.js} +73 -46
- package/dist/browser/folder-view-BG4n0zgH.js.map +1 -0
- package/dist/browser/{graphql-editor-B-dNI5hD.js → graphql-editor-gWZAjvBa.js} +8 -7
- package/dist/browser/{graphql-editor-B-dNI5hD.js.map → graphql-editor-gWZAjvBa.js.map} +1 -1
- package/dist/browser/{hooks-CORHBNHb.js → hooks-KKcNp2X0.js} +2 -2
- package/dist/browser/{hooks-CORHBNHb.js.map → hooks-KKcNp2X0.js.map} +1 -1
- package/dist/browser/index.js +378 -9
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{json-editor-v_MnzQVs.js → json-editor-DCA4V_DS.js} +4 -4
- package/dist/browser/{json-editor-v_MnzQVs.js.map → json-editor-DCA4V_DS.js.map} +1 -1
- package/dist/browser/{lib-C-f3izXz.js → lib-V-A4Y98b.js} +12 -2
- package/dist/browser/lib-V-A4Y98b.js.map +1 -0
- package/dist/browser/printer-CEYr4JOg.js +604 -0
- package/dist/browser/printer-CEYr4JOg.js.map +1 -0
- package/dist/browser/{schema-context-DY-GEGnY.js → schema-context-ZyeclQwy.js} +2 -2
- package/dist/browser/{schema-context-DY-GEGnY.js.map → schema-context-ZyeclQwy.js.map} +1 -1
- package/dist/browser/{state-schemas-65Tp0ZuG.js → state-schemas-oLJnYfWV.js} +8 -18
- package/dist/browser/state-schemas-oLJnYfWV.js.map +1 -0
- package/dist/node/{linting-Dx50GuLN.mjs → button-Da7CxMn7.mjs} +20 -7
- package/dist/node/button-Da7CxMn7.mjs.map +1 -0
- package/dist/node/{connect-Bbi5wHyR.mjs → connect-Cdie59_O.mjs} +916 -200
- package/dist/node/connect-Cdie59_O.mjs.map +1 -0
- package/dist/node/{dist-8nCvrie2.mjs → dist-BIdl6Tbq.mjs} +1564 -1292
- package/dist/node/dist-BIdl6Tbq.mjs.map +1 -0
- package/dist/{browser/dist-D8H48e8N.js → node/dist-CzYOpeXN.mjs} +21 -2
- package/dist/node/{dist-BeZaEP6S.mjs.map → dist-CzYOpeXN.mjs.map} +1 -1
- package/dist/node/{dist-fA4EItr0.mjs → dist-DT7jI9ol.mjs} +10 -2
- package/dist/node/{dist-fA4EItr0.mjs.map → dist-DT7jI9ol.mjs.map} +1 -1
- package/dist/node/{document-drive-DjL9iikf.mjs → document-drive-BgHPyTwW.mjs} +1077 -122
- package/dist/node/document-drive-BgHPyTwW.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +1 -1
- package/dist/node/{documents-BFBPmyw1.mjs → documents-DCf53bzO.mjs} +3 -3
- package/dist/node/{documents-BFBPmyw1.mjs.map → documents-DCf53bzO.mjs.map} +1 -1
- package/dist/node/editor-C_RkuhbJ.mjs +25 -0
- package/dist/node/editor-C_RkuhbJ.mjs.map +1 -0
- package/dist/node/{editor-DkT0krRE.mjs → editor-CyRFyoHM.mjs} +672 -237
- package/dist/node/editor-CyRFyoHM.mjs.map +1 -0
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +5 -5
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/{browser/folder-view-BQWrt8wh.js → node/folder-view-jO8_grQ6.mjs} +73 -46
- package/dist/node/folder-view-jO8_grQ6.mjs.map +1 -0
- package/dist/node/{graphql-DskHmkMe.mjs → graphql-BfAoPeWM.mjs} +2 -2
- package/dist/node/{graphql-DskHmkMe.mjs.map → graphql-BfAoPeWM.mjs.map} +1 -1
- package/dist/node/{graphql-editor-x-d_DoqN.mjs → graphql-editor-DyuSPAfc.mjs} +7 -7
- package/dist/node/{graphql-editor-x-d_DoqN.mjs.map → graphql-editor-DyuSPAfc.mjs.map} +1 -1
- package/dist/node/{hooks-DJrjfVaS.mjs → hooks-D0DcS3MV.mjs} +2 -2
- package/dist/node/{hooks-DJrjfVaS.mjs.map → hooks-D0DcS3MV.mjs.map} +1 -1
- package/dist/node/index.mjs +378 -9
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{json-editor-D8QbP3jl.mjs → json-editor-DtNAniwW.mjs} +4 -4
- package/dist/node/{json-editor-D8QbP3jl.mjs.map → json-editor-DtNAniwW.mjs.map} +1 -1
- package/dist/node/{main-D82dkD7g.mjs → main-C2GlZ2Rh.mjs} +14 -4
- package/dist/node/main-C2GlZ2Rh.mjs.map +1 -0
- package/dist/node/{schema-context-CX5ml_9t.mjs → schema-context-DL8jhi_d.mjs} +3 -3
- package/dist/node/{schema-context-CX5ml_9t.mjs.map → schema-context-DL8jhi_d.mjs.map} +1 -1
- package/dist/node/{state-schemas-BwvZVEhR.mjs → state-schemas-CeAvAzja.mjs} +10 -20
- package/dist/{browser/state-schemas-65Tp0ZuG.js.map → node/state-schemas-CeAvAzja.mjs.map} +1 -1
- package/package.json +7 -6
- package/dist/browser/connect-CV-z3DqA.js.map +0 -1
- package/dist/browser/dist-BEs8jMgM.js.map +0 -1
- package/dist/browser/document-drive-sTKoi6L4.js.map +0 -1
- package/dist/browser/documents-D4ek7Ubv.js.map +0 -1
- package/dist/browser/editor-Cw38euRs.js.map +0 -1
- package/dist/browser/editor-DY3JsQJ3.js +0 -29
- package/dist/browser/editor-DY3JsQJ3.js.map +0 -1
- package/dist/browser/folder-view-BQWrt8wh.js.map +0 -1
- package/dist/browser/lib-C-f3izXz.js.map +0 -1
- package/dist/browser/linting-Dn6pXRkK.js.map +0 -1
- package/dist/node/connect-Bbi5wHyR.mjs.map +0 -1
- package/dist/node/dist-8nCvrie2.mjs.map +0 -1
- package/dist/node/document-drive-DjL9iikf.mjs.map +0 -1
- package/dist/node/editor-BH2gCDjt.mjs +0 -29
- package/dist/node/editor-BH2gCDjt.mjs.map +0 -1
- package/dist/node/editor-DkT0krRE.mjs.map +0 -1
- package/dist/node/folder-view-DjKO1mAh.mjs.map +0 -1
- package/dist/node/linting-Dx50GuLN.mjs.map +0 -1
- package/dist/node/main-D82dkD7g.mjs.map +0 -1
- package/dist/node/state-schemas-BwvZVEhR.mjs.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as DriveCollectionId, i as SyncStatus, o as ModuleNotFoundError, t as require_main } from "./main-
|
|
4
|
-
import {
|
|
1
|
+
import { D as __commonJSMin, M as __toESM, t as capitalCase } from "./dist-DT7jI9ol.mjs";
|
|
2
|
+
import { A as createZip, B as replayDocumentVersioned, C as baseSaveToFileHandle, D as createPresignedHeader, S as baseLoadFromInputVersioned, Y as setName, a as handleTargetNameCollisions, at as generateId, f as logger, i as generateNodesCopy, it as validateStateSchemaName, l as moveNode, n as copyNode, nt as validateInitialState, o as isFileNode, rt as validateModules, s as isFolderNode, t as addFolder, u as updateNode, v as assertAuthPreservedOnDuplicate, w as buildSignedAction, x as baseLoadFromInput } from "./document-drive-BgHPyTwW.mjs";
|
|
3
|
+
import { a as DriveCollectionId, i as SyncStatus, o as ModuleNotFoundError, t as require_main } from "./main-C2GlZ2Rh.mjs";
|
|
4
|
+
import { t as require_graphql } from "./graphql-BfAoPeWM.mjs";
|
|
5
|
+
import { createContext, use, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
5
6
|
import "react/jsx-runtime";
|
|
6
|
-
//#region ../reactor-browser/dist/make-ph-event-functions-
|
|
7
|
+
//#region ../reactor-browser/dist/make-ph-event-functions-DBq3iWYn.js
|
|
7
8
|
const isServer$1 = typeof window === "undefined";
|
|
8
9
|
function makePHEventFunctions(key) {
|
|
9
10
|
const setEventName = `ph:set${capitalCase(key)}`;
|
|
@@ -51,7 +52,7 @@ function makePHEventFunctions(key) {
|
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
//#endregion
|
|
54
|
-
//#region ../reactor-browser/dist/document-by-id-
|
|
55
|
+
//#region ../reactor-browser/dist/document-by-id-BSZqTN66.js
|
|
55
56
|
async function queueActions(document, actionOrActions) {
|
|
56
57
|
if (!document) throw new Error("No document provided");
|
|
57
58
|
if (!actionOrActions) throw new Error("No actions provided");
|
|
@@ -97,12 +98,12 @@ async function uploadOperations(documentId, allOperations, pushOperations, optio
|
|
|
97
98
|
logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${documentId}): END`);
|
|
98
99
|
}
|
|
99
100
|
async function signAction(action, document) {
|
|
100
|
-
const reactor = window.ph?.reactorClient;
|
|
101
|
-
if (!reactor) return action;
|
|
102
|
-
const reducer = (await reactor.getDocumentModelModule(document.header.documentType)).reducer;
|
|
103
101
|
const renown = window.ph?.renown;
|
|
104
102
|
if (!renown?.user) return action;
|
|
105
103
|
if (!action.context?.signer) return action;
|
|
104
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
105
|
+
if (!reactorClient) return action;
|
|
106
|
+
const reducer = (await reactorClient.getDocumentModelModuleForDocument(document)).reducer;
|
|
106
107
|
const actionSigner = action.context.signer;
|
|
107
108
|
return await buildSignedAction(action, reducer, document, actionSigner, renown.crypto.sign);
|
|
108
109
|
}
|
|
@@ -180,6 +181,21 @@ async function dispatchActions(actionOrActions, documentOrDocumentId, onErrors,
|
|
|
180
181
|
if (onSuccess && result) onSuccess(result);
|
|
181
182
|
return result;
|
|
182
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* The reactor's `DocumentChangeType` members, typed as the enum so they can be
|
|
186
|
+
* assigned to `DocumentChangeEvent.type`. The assertion is unavoidable - a
|
|
187
|
+
* TypeScript string enum is nominal, so no string literal is assignable to it
|
|
188
|
+
* without one - and the two checks above are what make it safe.
|
|
189
|
+
*/
|
|
190
|
+
const DOCUMENT_CHANGE_TYPE = {
|
|
191
|
+
Created: "created",
|
|
192
|
+
Deleted: "deleted",
|
|
193
|
+
Updated: "updated",
|
|
194
|
+
ParentAdded: "parent_added",
|
|
195
|
+
ParentRemoved: "parent_removed",
|
|
196
|
+
ChildAdded: "child_added",
|
|
197
|
+
ChildRemoved: "child_removed"
|
|
198
|
+
};
|
|
183
199
|
const documentEventFunctions = makePHEventFunctions("documentCache");
|
|
184
200
|
/** Returns all documents in the reactor. */
|
|
185
201
|
const useDocumentCache = documentEventFunctions.useValue;
|
|
@@ -225,9 +241,27 @@ function useDocumentById(id) {
|
|
|
225
241
|
const [, dispatch] = useDispatch(document);
|
|
226
242
|
return [document, dispatch];
|
|
227
243
|
}
|
|
244
|
+
Error;
|
|
245
|
+
require_graphql();
|
|
246
|
+
JSON;
|
|
228
247
|
//#endregion
|
|
229
|
-
//#region ../reactor-browser/dist/client-
|
|
248
|
+
//#region ../reactor-browser/dist/client-s_ISz_Zs.js
|
|
230
249
|
var import_main = require_main();
|
|
250
|
+
let DocumentChangeType = /* @__PURE__ */ function(DocumentChangeType) {
|
|
251
|
+
DocumentChangeType["ChildAdded"] = "CHILD_ADDED";
|
|
252
|
+
DocumentChangeType["ChildRemoved"] = "CHILD_REMOVED";
|
|
253
|
+
DocumentChangeType["Created"] = "CREATED";
|
|
254
|
+
DocumentChangeType["Deleted"] = "DELETED";
|
|
255
|
+
DocumentChangeType["ParentAdded"] = "PARENT_ADDED";
|
|
256
|
+
DocumentChangeType["ParentRemoved"] = "PARENT_REMOVED";
|
|
257
|
+
DocumentChangeType["Updated"] = "UPDATED";
|
|
258
|
+
return DocumentChangeType;
|
|
259
|
+
}({});
|
|
260
|
+
let PropagationMode = /* @__PURE__ */ function(PropagationMode) {
|
|
261
|
+
PropagationMode["Cascade"] = "CASCADE";
|
|
262
|
+
PropagationMode["Orphan"] = "ORPHAN";
|
|
263
|
+
return PropagationMode;
|
|
264
|
+
}({});
|
|
231
265
|
const PhDocumentFieldsFragmentDoc = import_main.gql`
|
|
232
266
|
fragment PHDocumentFields on PHDocument {
|
|
233
267
|
id
|
|
@@ -288,6 +322,7 @@ const GetDocumentWithOperationsDocument = import_main.gql`
|
|
|
288
322
|
hash
|
|
289
323
|
skip
|
|
290
324
|
error
|
|
325
|
+
deniedReason
|
|
291
326
|
id
|
|
292
327
|
action {
|
|
293
328
|
id
|
|
@@ -400,6 +435,7 @@ const GetDocumentOperationsDocument = import_main.gql`
|
|
|
400
435
|
hash
|
|
401
436
|
skip
|
|
402
437
|
error
|
|
438
|
+
deniedReason
|
|
403
439
|
id
|
|
404
440
|
action {
|
|
405
441
|
id
|
|
@@ -650,6 +686,7 @@ import_main.gql`
|
|
|
650
686
|
hash
|
|
651
687
|
skip
|
|
652
688
|
error
|
|
689
|
+
deniedReason
|
|
653
690
|
id
|
|
654
691
|
action {
|
|
655
692
|
id
|
|
@@ -692,6 +729,7 @@ import_main.gql`
|
|
|
692
729
|
deadLetters {
|
|
693
730
|
documentId
|
|
694
731
|
error
|
|
732
|
+
errorType
|
|
695
733
|
}
|
|
696
734
|
hasMore
|
|
697
735
|
}
|
|
@@ -738,8 +776,17 @@ function extractQueryParts(doc, fallbackBody) {
|
|
|
738
776
|
extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
|
|
739
777
|
extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
|
|
740
778
|
//#endregion
|
|
741
|
-
//#region ../reactor-browser/dist/renown-
|
|
779
|
+
//#region ../reactor-browser/dist/renown-BZabzj4l.js
|
|
742
780
|
const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
|
|
781
|
+
const RenownInitialUserContext = createContext({ state: "unknown" });
|
|
782
|
+
/** First-render auth as a three-state value; use this to skip a spinner when anonymous. */
|
|
783
|
+
function useRenownInitialAuth() {
|
|
784
|
+
return useContext(RenownInitialUserContext);
|
|
785
|
+
}
|
|
786
|
+
function useRenownInitialUser() {
|
|
787
|
+
const initial = useRenownInitialAuth();
|
|
788
|
+
return initial.state === "authenticated" ? initial.user : void 0;
|
|
789
|
+
}
|
|
743
790
|
const renownEventFunctions = makePHEventFunctions("renown");
|
|
744
791
|
renownEventFunctions.addEventHandler;
|
|
745
792
|
/** Returns the renown instance */
|
|
@@ -748,41 +795,17 @@ renownEventFunctions.setValue;
|
|
|
748
795
|
/** Returns the current user from the renown instance, subscribing to user events */
|
|
749
796
|
function useUser() {
|
|
750
797
|
const renown = useRenown();
|
|
751
|
-
const
|
|
798
|
+
const initialUser = useRenownInitialUser();
|
|
799
|
+
const instance = renown ? renown : void 0;
|
|
800
|
+
const [user, setUser] = useState(instance ? instance.user : initialUser);
|
|
752
801
|
useEffect(() => {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
function mergeProps(parentProps, childProps) {
|
|
760
|
-
const merged = { ...parentProps };
|
|
761
|
-
for (const key of Object.keys(childProps)) {
|
|
762
|
-
const parentValue = parentProps[key];
|
|
763
|
-
const childValue = childProps[key];
|
|
764
|
-
if (key === "style") merged[key] = {
|
|
765
|
-
...parentValue,
|
|
766
|
-
...childValue
|
|
767
|
-
};
|
|
768
|
-
else if (key === "className") merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
|
|
769
|
-
else if (typeof parentValue === "function" && typeof childValue === "function") merged[key] = (...args) => {
|
|
770
|
-
childValue(...args);
|
|
771
|
-
parentValue(...args);
|
|
772
|
-
};
|
|
773
|
-
else if (childValue !== void 0) merged[key] = childValue;
|
|
774
|
-
}
|
|
775
|
-
return merged;
|
|
802
|
+
if (instance) {
|
|
803
|
+
setUser(instance.user);
|
|
804
|
+
return instance.on("user", setUser);
|
|
805
|
+
}
|
|
806
|
+
}, [instance]);
|
|
807
|
+
return instance ? user : initialUser ?? user;
|
|
776
808
|
}
|
|
777
|
-
const Slot = forwardRef(({ children, ...props }, ref) => {
|
|
778
|
-
const child = Children.only(children);
|
|
779
|
-
if (!isValidElement(child)) return null;
|
|
780
|
-
const childElement = child;
|
|
781
|
-
const mergedProps = mergeProps(props, childElement.props);
|
|
782
|
-
if (ref) mergedProps.ref = ref;
|
|
783
|
-
return cloneElement(childElement, mergedProps);
|
|
784
|
-
});
|
|
785
|
-
Slot.displayName = "Slot";
|
|
786
809
|
//#endregion
|
|
787
810
|
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
788
811
|
function e$8(e, t, n) {
|
|
@@ -907,6 +930,32 @@ function e(e) {
|
|
|
907
930
|
let t = !1, n;
|
|
908
931
|
return () => (t ||= (n = e(), !0), n);
|
|
909
932
|
}
|
|
933
|
+
var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
|
|
934
|
+
CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
|
|
935
|
+
CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
|
|
936
|
+
CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
|
|
937
|
+
CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
|
|
938
|
+
CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
|
|
939
|
+
CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
|
|
940
|
+
CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
|
|
941
|
+
CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
|
|
942
|
+
CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
|
|
943
|
+
CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
|
|
944
|
+
CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
|
|
945
|
+
return CloseCode2;
|
|
946
|
+
})(CloseCode || {});
|
|
947
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
948
|
+
MessageType2["ConnectionInit"] = "connection_init";
|
|
949
|
+
MessageType2["ConnectionAck"] = "connection_ack";
|
|
950
|
+
MessageType2["Ping"] = "ping";
|
|
951
|
+
MessageType2["Pong"] = "pong";
|
|
952
|
+
MessageType2["Subscribe"] = "subscribe";
|
|
953
|
+
MessageType2["Next"] = "next";
|
|
954
|
+
MessageType2["Error"] = "error";
|
|
955
|
+
MessageType2["Complete"] = "complete";
|
|
956
|
+
return MessageType2;
|
|
957
|
+
})(MessageType || {});
|
|
958
|
+
Error;
|
|
910
959
|
//#endregion
|
|
911
960
|
//#region ../../node_modules/.pnpm/slug@11.0.1/node_modules/slug/slug.js
|
|
912
961
|
let base64;
|
|
@@ -1694,902 +1743,301 @@ slug.setLocale = function(locale) {
|
|
|
1694
1743
|
defaultLocale = locales[locale] || {};
|
|
1695
1744
|
};
|
|
1696
1745
|
//#endregion
|
|
1697
|
-
//#region
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
"name",
|
|
1705
|
-
"message",
|
|
1706
|
-
"stack",
|
|
1707
|
-
"cause",
|
|
1708
|
-
"errors"
|
|
1709
|
-
];
|
|
1710
|
-
const normalizeDescriptor = (error, propName) => {
|
|
1711
|
-
const descriptor = getDescriptor(error, propName);
|
|
1712
|
-
if (descriptor === void 0) return;
|
|
1713
|
-
if (isReadonlyGetter(descriptor)) {
|
|
1714
|
-
setErrorProperty(error, propName, error[propName]);
|
|
1715
|
-
return;
|
|
1746
|
+
//#region ../reactor-browser/dist/document-operations-ZLuPOV3H.js
|
|
1747
|
+
var DocumentModelNotFoundError = class extends Error {
|
|
1748
|
+
documentType;
|
|
1749
|
+
name = "DocumentModelNotFoundError";
|
|
1750
|
+
constructor(documentType) {
|
|
1751
|
+
super(`Document model module for type ${documentType} not found`);
|
|
1752
|
+
this.documentType = documentType;
|
|
1716
1753
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
const getDescriptor = (value, propName) => {
|
|
1720
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, propName);
|
|
1721
|
-
if (descriptor !== void 0) return descriptor;
|
|
1722
|
-
const prototype = Object.getPrototypeOf(value);
|
|
1723
|
-
return prototype === null ? void 0 : getDescriptor(prototype, propName);
|
|
1724
|
-
};
|
|
1725
|
-
const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
|
|
1726
|
-
const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
|
|
1727
|
-
const setErrorProperty = (error, propName, value) => {
|
|
1728
|
-
setErrorDescriptor(error, propName, { value });
|
|
1729
|
-
};
|
|
1730
|
-
const setErrorDescriptor = (error, propName, descriptor) => {
|
|
1731
|
-
Object.defineProperty(error, propName, {
|
|
1732
|
-
...descriptor,
|
|
1733
|
-
..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
|
|
1734
|
-
enumerable: false,
|
|
1735
|
-
configurable: true
|
|
1736
|
-
});
|
|
1737
|
-
};
|
|
1738
|
-
//#endregion
|
|
1739
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
|
|
1740
|
-
const normalizeAggregate = (error, recurse) => {
|
|
1741
|
-
if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
|
|
1742
|
-
else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
|
|
1743
|
-
else if (error.errors !== void 0) deleteAggregateErrors(error);
|
|
1744
|
-
};
|
|
1745
|
-
const isDefined = (error) => error !== void 0;
|
|
1746
|
-
const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
|
|
1747
|
-
const deleteAggregateErrors = (error) => {
|
|
1748
|
-
delete error.errors;
|
|
1749
|
-
if (error.errors !== void 0) setErrorProperty(error, "errors", []);
|
|
1750
|
-
};
|
|
1751
|
-
//#endregion
|
|
1752
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
|
|
1753
|
-
const normalizeCause = (error, recurse) => {
|
|
1754
|
-
if (!("cause" in error)) return;
|
|
1755
|
-
const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
|
|
1756
|
-
if (cause === void 0) delete error.cause;
|
|
1757
|
-
else setErrorProperty(error, "cause", cause);
|
|
1758
|
-
};
|
|
1759
|
-
//#endregion
|
|
1760
|
-
//#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
|
|
1761
|
-
const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
|
|
1762
|
-
const isInstanceOfError = (value) => {
|
|
1763
|
-
try {
|
|
1764
|
-
return value instanceof Error;
|
|
1765
|
-
} catch {
|
|
1766
|
-
return false;
|
|
1754
|
+
static isError(error) {
|
|
1755
|
+
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
1767
1756
|
}
|
|
1768
1757
|
};
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
} catch {
|
|
1773
|
-
return false;
|
|
1758
|
+
var DocumentTypeMismatchError = class extends Error {
|
|
1759
|
+
constructor(documentId, expectedType, actualType) {
|
|
1760
|
+
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
1774
1761
|
}
|
|
1775
1762
|
};
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
"[object DOMError]",
|
|
1780
|
-
"[object Exception]"
|
|
1781
|
-
]);
|
|
1782
|
-
//#endregion
|
|
1783
|
-
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
1784
|
-
function isPlainObject(value) {
|
|
1785
|
-
if (typeof value !== "object" || value === null) return false;
|
|
1786
|
-
const prototype = Object.getPrototypeOf(value);
|
|
1787
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
1788
|
-
}
|
|
1789
|
-
//#endregion
|
|
1790
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
|
|
1791
|
-
const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
|
|
1792
|
-
const isNonConfigurableProp = (error, propName) => {
|
|
1793
|
-
const descriptor = Object.getOwnPropertyDescriptor(error, propName);
|
|
1794
|
-
return descriptor !== void 0 && !descriptor.configurable;
|
|
1795
|
-
};
|
|
1796
|
-
const isThrowingProp = (error, propName) => {
|
|
1797
|
-
try {
|
|
1798
|
-
error[propName];
|
|
1799
|
-
return false;
|
|
1800
|
-
} catch {
|
|
1801
|
-
return true;
|
|
1763
|
+
var NoSelectedDocumentError = class extends Error {
|
|
1764
|
+
constructor() {
|
|
1765
|
+
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
1802
1766
|
}
|
|
1803
1767
|
};
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1768
|
+
const modalEventFunctions = makePHEventFunctions("modal");
|
|
1769
|
+
modalEventFunctions.useValue;
|
|
1770
|
+
/** Sets the current modal */
|
|
1771
|
+
const setPHModal = modalEventFunctions.setValue;
|
|
1772
|
+
modalEventFunctions.addEventHandler;
|
|
1773
|
+
/** Shows a modal */
|
|
1774
|
+
function showPHModal(modal) {
|
|
1775
|
+
setPHModal(modal);
|
|
1776
|
+
}
|
|
1777
|
+
/** Shows the delete node modal */
|
|
1778
|
+
function showDeleteNodeModal(nodeOrId) {
|
|
1779
|
+
setPHModal({
|
|
1780
|
+
type: "deleteItem",
|
|
1781
|
+
id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
function getUserPermissions() {
|
|
1785
|
+
const user = window.ph?.renown?.user;
|
|
1786
|
+
const allowList = window.ph?.allowList;
|
|
1787
|
+
if (!allowList) return {
|
|
1788
|
+
isAllowedToCreateDocuments: true,
|
|
1789
|
+
isAllowedToEditDocuments: true
|
|
1819
1790
|
};
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
};
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
const objectCopy = {};
|
|
1828
|
-
for (const propName of getPropsToCopy(object)) try {
|
|
1829
|
-
const value = object[propName];
|
|
1830
|
-
const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
|
|
1831
|
-
Object.defineProperty(objectCopy, propName, {
|
|
1832
|
-
value,
|
|
1833
|
-
enumerable,
|
|
1834
|
-
configurable,
|
|
1835
|
-
writable
|
|
1836
|
-
});
|
|
1837
|
-
} catch {}
|
|
1838
|
-
return objectCopy;
|
|
1839
|
-
};
|
|
1840
|
-
const getPropsToCopy = (object) => {
|
|
1841
|
-
const propNames = getOwnKeys(object);
|
|
1842
|
-
for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
|
|
1843
|
-
return propNames;
|
|
1844
|
-
};
|
|
1845
|
-
const getOwnKeys = (object) => {
|
|
1846
|
-
try {
|
|
1847
|
-
return Reflect.ownKeys(object);
|
|
1848
|
-
} catch {
|
|
1849
|
-
return [];
|
|
1850
|
-
}
|
|
1851
|
-
};
|
|
1852
|
-
const isInheritedProp = (object, propName) => {
|
|
1791
|
+
return {
|
|
1792
|
+
isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
|
|
1793
|
+
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
1797
|
+
async function downloadFile(document, fileName) {
|
|
1853
1798
|
try {
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1799
|
+
const data = await createZip(document);
|
|
1800
|
+
const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
|
|
1801
|
+
const link = window.document.createElement("a");
|
|
1802
|
+
link.style.display = "none";
|
|
1803
|
+
link.href = URL.createObjectURL(blob);
|
|
1804
|
+
link.download = fileName;
|
|
1805
|
+
window.document.body.appendChild(link);
|
|
1806
|
+
link.click();
|
|
1807
|
+
window.document.body.removeChild(link);
|
|
1808
|
+
} catch (e) {
|
|
1809
|
+
logger.error(e instanceof Error ? e.message : String(e));
|
|
1857
1810
|
}
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
cause,
|
|
1870
|
-
errors
|
|
1871
|
-
}).forEach(([propName, propValue]) => {
|
|
1872
|
-
setNewErrorProperty(error, propName, propValue);
|
|
1873
|
-
});
|
|
1874
|
-
if (stack === void 0) setStack(error);
|
|
1875
|
-
return error;
|
|
1876
|
-
};
|
|
1877
|
-
const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
|
|
1878
|
-
const safeJsonStringify = (object) => {
|
|
1879
|
-
try {
|
|
1880
|
-
return JSON.stringify(object);
|
|
1881
|
-
} catch {
|
|
1882
|
-
return safeStringify(object);
|
|
1811
|
+
}
|
|
1812
|
+
async function getDocumentExtension(document) {
|
|
1813
|
+
const documentType = document.header.documentType;
|
|
1814
|
+
let rawExtension;
|
|
1815
|
+
if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
|
|
1816
|
+
else {
|
|
1817
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
1818
|
+
if (reactorClient) {
|
|
1819
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
1820
|
+
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
1821
|
+
}
|
|
1883
1822
|
}
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1823
|
+
return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Fetches all operations for a document using cursor-based pagination.
|
|
1827
|
+
* The reactor client handles multi-scope cursors transparently via
|
|
1828
|
+
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
1829
|
+
*/
|
|
1830
|
+
async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
|
|
1831
|
+
const scopes = Object.keys(document.state);
|
|
1832
|
+
const operations = {};
|
|
1833
|
+
for (const scope of scopes) operations[scope] = [];
|
|
1834
|
+
let cursor = "";
|
|
1835
|
+
do {
|
|
1836
|
+
const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
|
|
1837
|
+
cursor,
|
|
1838
|
+
limit: pageSize
|
|
1839
|
+
});
|
|
1840
|
+
for (const op of page.results) {
|
|
1841
|
+
const scope = op.action.scope ?? "global";
|
|
1842
|
+
if (operations[scope]) operations[scope].push(op);
|
|
1843
|
+
}
|
|
1844
|
+
cursor = page.nextCursor ?? "";
|
|
1845
|
+
} while (cursor);
|
|
1846
|
+
return operations;
|
|
1847
|
+
}
|
|
1848
|
+
function extractInitialState(documentScopeOps) {
|
|
1849
|
+
const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
|
|
1850
|
+
if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
|
|
1851
|
+
const input = upgradeOp.action.input;
|
|
1852
|
+
const initialState = input.initialState ?? input.state;
|
|
1853
|
+
if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
|
|
1854
|
+
return initialState;
|
|
1855
|
+
}
|
|
1856
|
+
function filterDomainOperations(operations) {
|
|
1857
|
+
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
1858
|
+
}
|
|
1859
|
+
function countOperations(operations) {
|
|
1860
|
+
let total = 0;
|
|
1861
|
+
for (const ops of Object.values(operations)) total += ops?.length ?? 0;
|
|
1862
|
+
return total;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Split an imported document's domain operations at its mid-history upgrade
|
|
1866
|
+
* boundaries, so the caller can re-dispatch each upgrade between segments.
|
|
1867
|
+
*
|
|
1868
|
+
* The seed's CREATE_DOCUMENT and 0 -> N upgrade are replayed by the creation
|
|
1869
|
+
* path and must not be repeated. A later upgrade must be: it is where the
|
|
1870
|
+
* reducer version changes, and dropping it replays everything after it through
|
|
1871
|
+
* the module the document was created with.
|
|
1872
|
+
*/
|
|
1873
|
+
function splitAtUpgradeBoundaries(operations) {
|
|
1874
|
+
const upgrades = (operations.document ?? []).filter((op) => op.action.type === "UPGRADE_DOCUMENT").filter((op) => op.action.input.fromVersion > 0).sort((a, b) => a.index - b.index);
|
|
1875
|
+
const domain = filterDomainOperations(operations);
|
|
1876
|
+
if (upgrades.length === 0) return [{ operations: domain }];
|
|
1877
|
+
const segments = [];
|
|
1878
|
+
const consumed = /* @__PURE__ */ new Map();
|
|
1879
|
+
const take = (until) => {
|
|
1880
|
+
const slice = {};
|
|
1881
|
+
for (const [scope, ops] of Object.entries(domain)) {
|
|
1882
|
+
if (!ops) continue;
|
|
1883
|
+
const from = consumed.get(scope) ?? 0;
|
|
1884
|
+
const stop = Math.max(from, until(scope, ops));
|
|
1885
|
+
const chunk = ops.slice(from, stop);
|
|
1886
|
+
if (chunk.length > 0) slice[scope] = chunk;
|
|
1887
|
+
consumed.set(scope, stop);
|
|
1888
|
+
}
|
|
1889
|
+
return slice;
|
|
1890
|
+
};
|
|
1891
|
+
for (const upgrade of upgrades) {
|
|
1892
|
+
const input = upgrade.action.input;
|
|
1893
|
+
const slice = take((scope, ops) => boundary(upgrade, scope, ops));
|
|
1894
|
+
segments.push({
|
|
1895
|
+
operations: slice,
|
|
1896
|
+
upgradeTo: input.toVersion
|
|
1897
|
+
});
|
|
1890
1898
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
for (
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
const
|
|
1899
|
+
const tail = take((_scope, ops) => ops.length);
|
|
1900
|
+
if (countOperations(tail) > 0) segments.push({ operations: tail });
|
|
1901
|
+
return segments;
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* How many of a scope's operations precede an upgrade. Must stay identical to
|
|
1905
|
+
* the boundary computation in `replayDocumentVersioned` — snapshots compare
|
|
1906
|
+
* against operation indices, not array positions, and the timestamp fallback
|
|
1907
|
+
* excludes the upgrade's own instant.
|
|
1908
|
+
*/
|
|
1909
|
+
function boundary(upgrade, scope, ops) {
|
|
1910
|
+
const snapshot = upgrade.action.input.revision;
|
|
1911
|
+
if (snapshot !== void 0) {
|
|
1912
|
+
const revision = snapshot[scope] ?? 0;
|
|
1913
|
+
let count = 0;
|
|
1914
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].index < revision) count = i + 1;
|
|
1915
|
+
return count;
|
|
1916
|
+
}
|
|
1917
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].timestampUtcMs >= upgrade.timestampUtcMs) return i;
|
|
1918
|
+
return ops.length;
|
|
1919
|
+
}
|
|
1920
|
+
async function exportFile(document, suggestedName) {
|
|
1921
|
+
const reactorClient = window.ph?.reactorClient;
|
|
1922
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1923
|
+
const operations = await fetchDocumentOperations(reactorClient, document);
|
|
1924
|
+
const initialState = extractInitialState(operations["document"] ?? []);
|
|
1925
|
+
const documentWithOps = {
|
|
1926
|
+
...document,
|
|
1927
|
+
operations,
|
|
1928
|
+
initialState
|
|
1929
|
+
};
|
|
1930
|
+
const extension = await getDocumentExtension(documentWithOps);
|
|
1931
|
+
const baseName = suggestedName || documentWithOps.header.name || "Untitled";
|
|
1932
|
+
const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
|
|
1933
|
+
if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
|
|
1917
1934
|
try {
|
|
1918
|
-
const
|
|
1919
|
-
|
|
1920
|
-
return
|
|
1921
|
-
} catch (
|
|
1922
|
-
|
|
1935
|
+
const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
|
|
1936
|
+
await baseSaveToFileHandle(documentWithOps, fileHandle);
|
|
1937
|
+
return fileHandle;
|
|
1938
|
+
} catch (e) {
|
|
1939
|
+
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
1923
1940
|
}
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
const
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Loads a document file and replays it with version-aware reducers from the registry.
|
|
1944
|
+
* Falls back to single-version legacy replay when no upgrade manifest is registered for
|
|
1945
|
+
* the document type.
|
|
1946
|
+
*/
|
|
1947
|
+
async function loadFile(path) {
|
|
1948
|
+
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
1949
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
1950
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1951
|
+
const documentType = baseDocument.header.documentType;
|
|
1952
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
1953
|
+
const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
|
|
1954
|
+
if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
|
|
1955
|
+
const reducers = {};
|
|
1956
|
+
for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
|
|
1957
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
1958
|
+
let upgradeManifest;
|
|
1959
|
+
if (registry) try {
|
|
1960
|
+
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
1961
|
+
} catch {}
|
|
1962
|
+
return baseLoadFromInputVersioned(path, {
|
|
1963
|
+
reducers,
|
|
1964
|
+
upgradeManifest
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
1968
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
1969
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
1970
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
1971
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1972
|
+
let documentModelModule;
|
|
1973
|
+
if (documentModelVersion !== void 0) {
|
|
1974
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
1975
|
+
const module = documentModelModules.find((m) => m.documentModel.global.id === documentType && (m.version ?? 1) === documentModelVersion);
|
|
1976
|
+
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
1977
|
+
documentModelModule = module;
|
|
1978
|
+
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
1979
|
+
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
1980
|
+
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
1981
|
+
newDocument.header.name = name;
|
|
1982
|
+
if (preferredEditor) newDocument.header.meta = {
|
|
1983
|
+
...newDocument.header.meta,
|
|
1984
|
+
preferredEditor
|
|
1985
|
+
};
|
|
1986
|
+
let newDoc;
|
|
1935
1987
|
try {
|
|
1936
|
-
|
|
1937
|
-
} catch {
|
|
1938
|
-
|
|
1988
|
+
newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
|
|
1989
|
+
} catch (e) {
|
|
1990
|
+
logger.error("Error adding document: @error", e);
|
|
1991
|
+
throw new Error("There was an error adding document", { cause: e });
|
|
1939
1992
|
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1993
|
+
return {
|
|
1994
|
+
id: newDoc.header.id,
|
|
1995
|
+
name: newDoc.header.name,
|
|
1996
|
+
documentType,
|
|
1997
|
+
parentFolder: parentFolder ?? null,
|
|
1998
|
+
kind: "file"
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
async function addFile(file, driveId, name, parentFolder) {
|
|
2002
|
+
logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
2003
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2004
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
|
|
2005
|
+
const document = await loadFile(file);
|
|
2006
|
+
let duplicateId = false;
|
|
2007
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2008
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1943
2009
|
try {
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2010
|
+
await reactorClient.get(document.header.id);
|
|
2011
|
+
duplicateId = true;
|
|
2012
|
+
} catch {}
|
|
2013
|
+
const documentId = duplicateId ? generateId() : document.header.id;
|
|
2014
|
+
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
2015
|
+
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
2016
|
+
header.meta = document.header.meta;
|
|
2017
|
+
header.name = name || document.header.name;
|
|
2018
|
+
const initialDocument = {
|
|
2019
|
+
...document,
|
|
2020
|
+
header,
|
|
2021
|
+
state: document.initialState,
|
|
2022
|
+
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
2023
|
+
acc[key] = [];
|
|
2024
|
+
return acc;
|
|
2025
|
+
}, {})
|
|
2026
|
+
};
|
|
2027
|
+
await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
2028
|
+
for (const segment of splitAtUpgradeBoundaries(document.operations)) {
|
|
2029
|
+
await uploadOperations(documentId, segment.operations, queueOperations);
|
|
2030
|
+
if (segment.upgradeTo !== void 0) await upgradeDocument(documentId, segment.upgradeTo);
|
|
1947
2031
|
}
|
|
1948
|
-
};
|
|
1949
|
-
const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
|
|
1950
|
-
//#endregion
|
|
1951
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
|
|
1952
|
-
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
1953
|
-
const recurseException = (error, parents, shallow) => {
|
|
1954
|
-
if (parents.includes(error)) return;
|
|
1955
|
-
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
1956
|
-
const errorA = createError(error);
|
|
1957
|
-
normalizeProps(errorA, recurse);
|
|
1958
|
-
return errorA;
|
|
1959
|
-
};
|
|
1960
|
-
const identity = (error) => error;
|
|
1961
|
-
const normalizeProps = (error, recurse) => {
|
|
1962
|
-
normalizeName(error);
|
|
1963
|
-
normalizeMessage(error);
|
|
1964
|
-
normalizeStack(error);
|
|
1965
|
-
normalizeCause(error, recurse);
|
|
1966
|
-
normalizeAggregate(error, recurse);
|
|
1967
|
-
normalizeDescriptors(error);
|
|
1968
|
-
};
|
|
1969
|
-
const normalizeName = (error) => {
|
|
1970
|
-
if (isDefinedString(error.name)) return;
|
|
1971
|
-
const prototypeName = Object.getPrototypeOf(error).name;
|
|
1972
|
-
setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
|
|
1973
|
-
};
|
|
1974
|
-
const normalizeMessage = (error) => {
|
|
1975
|
-
if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
|
|
1976
|
-
};
|
|
1977
|
-
const normalizeStack = (error) => {
|
|
1978
|
-
if (!isDefinedString(error.stack)) setStack(error);
|
|
1979
|
-
};
|
|
1980
|
-
const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
1981
|
-
//#endregion
|
|
1982
|
-
//#region ../reactor-browser/dist/index.js
|
|
1983
|
-
var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1984
|
-
var LZString = (function() {
|
|
1985
|
-
var f = String.fromCharCode;
|
|
1986
|
-
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
1987
|
-
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
1988
|
-
var baseReverseDic = {};
|
|
1989
|
-
function getBaseValue(alphabet, character) {
|
|
1990
|
-
if (!baseReverseDic[alphabet]) {
|
|
1991
|
-
baseReverseDic[alphabet] = {};
|
|
1992
|
-
for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
1993
|
-
}
|
|
1994
|
-
return baseReverseDic[alphabet][character];
|
|
1995
|
-
}
|
|
1996
|
-
var LZString = {
|
|
1997
|
-
compressToBase64: function(input) {
|
|
1998
|
-
if (input == null) return "";
|
|
1999
|
-
var res = LZString._compress(input, 6, function(a) {
|
|
2000
|
-
return keyStrBase64.charAt(a);
|
|
2001
|
-
});
|
|
2002
|
-
switch (res.length % 4) {
|
|
2003
|
-
default:
|
|
2004
|
-
case 0: return res;
|
|
2005
|
-
case 1: return res + "===";
|
|
2006
|
-
case 2: return res + "==";
|
|
2007
|
-
case 3: return res + "=";
|
|
2008
|
-
}
|
|
2009
|
-
},
|
|
2010
|
-
decompressFromBase64: function(input) {
|
|
2011
|
-
if (input == null) return "";
|
|
2012
|
-
if (input == "") return null;
|
|
2013
|
-
return LZString._decompress(input.length, 32, function(index) {
|
|
2014
|
-
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
2015
|
-
});
|
|
2016
|
-
},
|
|
2017
|
-
compressToUTF16: function(input) {
|
|
2018
|
-
if (input == null) return "";
|
|
2019
|
-
return LZString._compress(input, 15, function(a) {
|
|
2020
|
-
return f(a + 32);
|
|
2021
|
-
}) + " ";
|
|
2022
|
-
},
|
|
2023
|
-
decompressFromUTF16: function(compressed) {
|
|
2024
|
-
if (compressed == null) return "";
|
|
2025
|
-
if (compressed == "") return null;
|
|
2026
|
-
return LZString._decompress(compressed.length, 16384, function(index) {
|
|
2027
|
-
return compressed.charCodeAt(index) - 32;
|
|
2028
|
-
});
|
|
2029
|
-
},
|
|
2030
|
-
compressToUint8Array: function(uncompressed) {
|
|
2031
|
-
var compressed = LZString.compress(uncompressed);
|
|
2032
|
-
var buf = new Uint8Array(compressed.length * 2);
|
|
2033
|
-
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
2034
|
-
var current_value = compressed.charCodeAt(i);
|
|
2035
|
-
buf[i * 2] = current_value >>> 8;
|
|
2036
|
-
buf[i * 2 + 1] = current_value % 256;
|
|
2037
|
-
}
|
|
2038
|
-
return buf;
|
|
2039
|
-
},
|
|
2040
|
-
decompressFromUint8Array: function(compressed) {
|
|
2041
|
-
if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
|
|
2042
|
-
else {
|
|
2043
|
-
var buf = new Array(compressed.length / 2);
|
|
2044
|
-
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
2045
|
-
var result = [];
|
|
2046
|
-
buf.forEach(function(c) {
|
|
2047
|
-
result.push(f(c));
|
|
2048
|
-
});
|
|
2049
|
-
return LZString.decompress(result.join(""));
|
|
2050
|
-
}
|
|
2051
|
-
},
|
|
2052
|
-
compressToEncodedURIComponent: function(input) {
|
|
2053
|
-
if (input == null) return "";
|
|
2054
|
-
return LZString._compress(input, 6, function(a) {
|
|
2055
|
-
return keyStrUriSafe.charAt(a);
|
|
2056
|
-
});
|
|
2057
|
-
},
|
|
2058
|
-
decompressFromEncodedURIComponent: function(input) {
|
|
2059
|
-
if (input == null) return "";
|
|
2060
|
-
if (input == "") return null;
|
|
2061
|
-
input = input.replace(/ /g, "+");
|
|
2062
|
-
return LZString._decompress(input.length, 32, function(index) {
|
|
2063
|
-
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
2064
|
-
});
|
|
2065
|
-
},
|
|
2066
|
-
compress: function(uncompressed) {
|
|
2067
|
-
return LZString._compress(uncompressed, 16, function(a) {
|
|
2068
|
-
return f(a);
|
|
2069
|
-
});
|
|
2070
|
-
},
|
|
2071
|
-
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
2072
|
-
if (uncompressed == null) return "";
|
|
2073
|
-
var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
2074
|
-
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
2075
|
-
context_c = uncompressed.charAt(ii);
|
|
2076
|
-
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
2077
|
-
context_dictionary[context_c] = context_dictSize++;
|
|
2078
|
-
context_dictionaryToCreate[context_c] = true;
|
|
2079
|
-
}
|
|
2080
|
-
context_wc = context_w + context_c;
|
|
2081
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
|
|
2082
|
-
else {
|
|
2083
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
2084
|
-
if (context_w.charCodeAt(0) < 256) {
|
|
2085
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2086
|
-
context_data_val = context_data_val << 1;
|
|
2087
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2088
|
-
context_data_position = 0;
|
|
2089
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2090
|
-
context_data_val = 0;
|
|
2091
|
-
} else context_data_position++;
|
|
2092
|
-
}
|
|
2093
|
-
value = context_w.charCodeAt(0);
|
|
2094
|
-
for (i = 0; i < 8; i++) {
|
|
2095
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2096
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2097
|
-
context_data_position = 0;
|
|
2098
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2099
|
-
context_data_val = 0;
|
|
2100
|
-
} else context_data_position++;
|
|
2101
|
-
value = value >> 1;
|
|
2102
|
-
}
|
|
2103
|
-
} else {
|
|
2104
|
-
value = 1;
|
|
2105
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2106
|
-
context_data_val = context_data_val << 1 | value;
|
|
2107
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2108
|
-
context_data_position = 0;
|
|
2109
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2110
|
-
context_data_val = 0;
|
|
2111
|
-
} else context_data_position++;
|
|
2112
|
-
value = 0;
|
|
2113
|
-
}
|
|
2114
|
-
value = context_w.charCodeAt(0);
|
|
2115
|
-
for (i = 0; i < 16; i++) {
|
|
2116
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2117
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2118
|
-
context_data_position = 0;
|
|
2119
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2120
|
-
context_data_val = 0;
|
|
2121
|
-
} else context_data_position++;
|
|
2122
|
-
value = value >> 1;
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
context_enlargeIn--;
|
|
2126
|
-
if (context_enlargeIn == 0) {
|
|
2127
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
2128
|
-
context_numBits++;
|
|
2129
|
-
}
|
|
2130
|
-
delete context_dictionaryToCreate[context_w];
|
|
2131
|
-
} else {
|
|
2132
|
-
value = context_dictionary[context_w];
|
|
2133
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2134
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2135
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2136
|
-
context_data_position = 0;
|
|
2137
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2138
|
-
context_data_val = 0;
|
|
2139
|
-
} else context_data_position++;
|
|
2140
|
-
value = value >> 1;
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
context_enlargeIn--;
|
|
2144
|
-
if (context_enlargeIn == 0) {
|
|
2145
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
2146
|
-
context_numBits++;
|
|
2147
|
-
}
|
|
2148
|
-
context_dictionary[context_wc] = context_dictSize++;
|
|
2149
|
-
context_w = String(context_c);
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
if (context_w !== "") {
|
|
2153
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
2154
|
-
if (context_w.charCodeAt(0) < 256) {
|
|
2155
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2156
|
-
context_data_val = context_data_val << 1;
|
|
2157
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2158
|
-
context_data_position = 0;
|
|
2159
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2160
|
-
context_data_val = 0;
|
|
2161
|
-
} else context_data_position++;
|
|
2162
|
-
}
|
|
2163
|
-
value = context_w.charCodeAt(0);
|
|
2164
|
-
for (i = 0; i < 8; i++) {
|
|
2165
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2166
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2167
|
-
context_data_position = 0;
|
|
2168
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2169
|
-
context_data_val = 0;
|
|
2170
|
-
} else context_data_position++;
|
|
2171
|
-
value = value >> 1;
|
|
2172
|
-
}
|
|
2173
|
-
} else {
|
|
2174
|
-
value = 1;
|
|
2175
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2176
|
-
context_data_val = context_data_val << 1 | value;
|
|
2177
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2178
|
-
context_data_position = 0;
|
|
2179
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2180
|
-
context_data_val = 0;
|
|
2181
|
-
} else context_data_position++;
|
|
2182
|
-
value = 0;
|
|
2183
|
-
}
|
|
2184
|
-
value = context_w.charCodeAt(0);
|
|
2185
|
-
for (i = 0; i < 16; i++) {
|
|
2186
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2187
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2188
|
-
context_data_position = 0;
|
|
2189
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2190
|
-
context_data_val = 0;
|
|
2191
|
-
} else context_data_position++;
|
|
2192
|
-
value = value >> 1;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
context_enlargeIn--;
|
|
2196
|
-
if (context_enlargeIn == 0) {
|
|
2197
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
2198
|
-
context_numBits++;
|
|
2199
|
-
}
|
|
2200
|
-
delete context_dictionaryToCreate[context_w];
|
|
2201
|
-
} else {
|
|
2202
|
-
value = context_dictionary[context_w];
|
|
2203
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2204
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2205
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2206
|
-
context_data_position = 0;
|
|
2207
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2208
|
-
context_data_val = 0;
|
|
2209
|
-
} else context_data_position++;
|
|
2210
|
-
value = value >> 1;
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
context_enlargeIn--;
|
|
2214
|
-
if (context_enlargeIn == 0) {
|
|
2215
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
2216
|
-
context_numBits++;
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
value = 2;
|
|
2220
|
-
for (i = 0; i < context_numBits; i++) {
|
|
2221
|
-
context_data_val = context_data_val << 1 | value & 1;
|
|
2222
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2223
|
-
context_data_position = 0;
|
|
2224
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2225
|
-
context_data_val = 0;
|
|
2226
|
-
} else context_data_position++;
|
|
2227
|
-
value = value >> 1;
|
|
2228
|
-
}
|
|
2229
|
-
while (true) {
|
|
2230
|
-
context_data_val = context_data_val << 1;
|
|
2231
|
-
if (context_data_position == bitsPerChar - 1) {
|
|
2232
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
2233
|
-
break;
|
|
2234
|
-
} else context_data_position++;
|
|
2235
|
-
}
|
|
2236
|
-
return context_data.join("");
|
|
2237
|
-
},
|
|
2238
|
-
decompress: function(compressed) {
|
|
2239
|
-
if (compressed == null) return "";
|
|
2240
|
-
if (compressed == "") return null;
|
|
2241
|
-
return LZString._decompress(compressed.length, 32768, function(index) {
|
|
2242
|
-
return compressed.charCodeAt(index);
|
|
2243
|
-
});
|
|
2244
|
-
},
|
|
2245
|
-
_decompress: function(length, resetValue, getNextValue) {
|
|
2246
|
-
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
|
|
2247
|
-
val: getNextValue(0),
|
|
2248
|
-
position: resetValue,
|
|
2249
|
-
index: 1
|
|
2250
|
-
};
|
|
2251
|
-
for (i = 0; i < 3; i += 1) dictionary[i] = i;
|
|
2252
|
-
bits = 0;
|
|
2253
|
-
maxpower = Math.pow(2, 2);
|
|
2254
|
-
power = 1;
|
|
2255
|
-
while (power != maxpower) {
|
|
2256
|
-
resb = data.val & data.position;
|
|
2257
|
-
data.position >>= 1;
|
|
2258
|
-
if (data.position == 0) {
|
|
2259
|
-
data.position = resetValue;
|
|
2260
|
-
data.val = getNextValue(data.index++);
|
|
2261
|
-
}
|
|
2262
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2263
|
-
power <<= 1;
|
|
2264
|
-
}
|
|
2265
|
-
switch (bits) {
|
|
2266
|
-
case 0:
|
|
2267
|
-
bits = 0;
|
|
2268
|
-
maxpower = Math.pow(2, 8);
|
|
2269
|
-
power = 1;
|
|
2270
|
-
while (power != maxpower) {
|
|
2271
|
-
resb = data.val & data.position;
|
|
2272
|
-
data.position >>= 1;
|
|
2273
|
-
if (data.position == 0) {
|
|
2274
|
-
data.position = resetValue;
|
|
2275
|
-
data.val = getNextValue(data.index++);
|
|
2276
|
-
}
|
|
2277
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2278
|
-
power <<= 1;
|
|
2279
|
-
}
|
|
2280
|
-
c = f(bits);
|
|
2281
|
-
break;
|
|
2282
|
-
case 1:
|
|
2283
|
-
bits = 0;
|
|
2284
|
-
maxpower = Math.pow(2, 16);
|
|
2285
|
-
power = 1;
|
|
2286
|
-
while (power != maxpower) {
|
|
2287
|
-
resb = data.val & data.position;
|
|
2288
|
-
data.position >>= 1;
|
|
2289
|
-
if (data.position == 0) {
|
|
2290
|
-
data.position = resetValue;
|
|
2291
|
-
data.val = getNextValue(data.index++);
|
|
2292
|
-
}
|
|
2293
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2294
|
-
power <<= 1;
|
|
2295
|
-
}
|
|
2296
|
-
c = f(bits);
|
|
2297
|
-
break;
|
|
2298
|
-
case 2: return "";
|
|
2299
|
-
}
|
|
2300
|
-
dictionary[3] = c;
|
|
2301
|
-
w = c;
|
|
2302
|
-
result.push(c);
|
|
2303
|
-
while (true) {
|
|
2304
|
-
if (data.index > length) return "";
|
|
2305
|
-
bits = 0;
|
|
2306
|
-
maxpower = Math.pow(2, numBits);
|
|
2307
|
-
power = 1;
|
|
2308
|
-
while (power != maxpower) {
|
|
2309
|
-
resb = data.val & data.position;
|
|
2310
|
-
data.position >>= 1;
|
|
2311
|
-
if (data.position == 0) {
|
|
2312
|
-
data.position = resetValue;
|
|
2313
|
-
data.val = getNextValue(data.index++);
|
|
2314
|
-
}
|
|
2315
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2316
|
-
power <<= 1;
|
|
2317
|
-
}
|
|
2318
|
-
switch (c = bits) {
|
|
2319
|
-
case 0:
|
|
2320
|
-
bits = 0;
|
|
2321
|
-
maxpower = Math.pow(2, 8);
|
|
2322
|
-
power = 1;
|
|
2323
|
-
while (power != maxpower) {
|
|
2324
|
-
resb = data.val & data.position;
|
|
2325
|
-
data.position >>= 1;
|
|
2326
|
-
if (data.position == 0) {
|
|
2327
|
-
data.position = resetValue;
|
|
2328
|
-
data.val = getNextValue(data.index++);
|
|
2329
|
-
}
|
|
2330
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2331
|
-
power <<= 1;
|
|
2332
|
-
}
|
|
2333
|
-
dictionary[dictSize++] = f(bits);
|
|
2334
|
-
c = dictSize - 1;
|
|
2335
|
-
enlargeIn--;
|
|
2336
|
-
break;
|
|
2337
|
-
case 1:
|
|
2338
|
-
bits = 0;
|
|
2339
|
-
maxpower = Math.pow(2, 16);
|
|
2340
|
-
power = 1;
|
|
2341
|
-
while (power != maxpower) {
|
|
2342
|
-
resb = data.val & data.position;
|
|
2343
|
-
data.position >>= 1;
|
|
2344
|
-
if (data.position == 0) {
|
|
2345
|
-
data.position = resetValue;
|
|
2346
|
-
data.val = getNextValue(data.index++);
|
|
2347
|
-
}
|
|
2348
|
-
bits |= (resb > 0 ? 1 : 0) * power;
|
|
2349
|
-
power <<= 1;
|
|
2350
|
-
}
|
|
2351
|
-
dictionary[dictSize++] = f(bits);
|
|
2352
|
-
c = dictSize - 1;
|
|
2353
|
-
enlargeIn--;
|
|
2354
|
-
break;
|
|
2355
|
-
case 2: return result.join("");
|
|
2356
|
-
}
|
|
2357
|
-
if (enlargeIn == 0) {
|
|
2358
|
-
enlargeIn = Math.pow(2, numBits);
|
|
2359
|
-
numBits++;
|
|
2360
|
-
}
|
|
2361
|
-
if (dictionary[c]) entry = dictionary[c];
|
|
2362
|
-
else if (c === dictSize) entry = w + w.charAt(0);
|
|
2363
|
-
else return null;
|
|
2364
|
-
result.push(entry);
|
|
2365
|
-
dictionary[dictSize++] = w + entry.charAt(0);
|
|
2366
|
-
enlargeIn--;
|
|
2367
|
-
w = entry;
|
|
2368
|
-
if (enlargeIn == 0) {
|
|
2369
|
-
enlargeIn = Math.pow(2, numBits);
|
|
2370
|
-
numBits++;
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
};
|
|
2375
|
-
return LZString;
|
|
2376
|
-
})();
|
|
2377
|
-
if (typeof define === "function" && define.amd) define(function() {
|
|
2378
|
-
return LZString;
|
|
2379
|
-
});
|
|
2380
|
-
else if (typeof module !== "undefined" && module != null) module.exports = LZString;
|
|
2381
|
-
else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
|
|
2382
|
-
return LZString;
|
|
2383
|
-
});
|
|
2384
|
-
})))(), 1);
|
|
2385
|
-
var DocumentModelNotFoundError = class extends Error {
|
|
2386
|
-
documentType;
|
|
2387
|
-
name = "DocumentModelNotFoundError";
|
|
2388
|
-
constructor(documentType) {
|
|
2389
|
-
super(`Document model module for type ${documentType} not found`);
|
|
2390
|
-
this.documentType = documentType;
|
|
2391
|
-
}
|
|
2392
|
-
static isError(error) {
|
|
2393
|
-
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
var DocumentTypeMismatchError = class extends Error {
|
|
2397
|
-
constructor(documentId, expectedType, actualType) {
|
|
2398
|
-
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
2399
|
-
}
|
|
2400
|
-
};
|
|
2401
|
-
var NoSelectedDocumentError = class extends Error {
|
|
2402
|
-
constructor() {
|
|
2403
|
-
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
function getUserPermissions() {
|
|
2407
|
-
const user = window.ph?.renown?.user;
|
|
2408
|
-
const allowList = window.ph?.allowList;
|
|
2409
|
-
if (!allowList) return {
|
|
2410
|
-
isAllowedToCreateDocuments: true,
|
|
2411
|
-
isAllowedToEditDocuments: true
|
|
2412
|
-
};
|
|
2413
|
-
return {
|
|
2414
|
-
isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
|
|
2415
|
-
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
2416
|
-
};
|
|
2417
|
-
}
|
|
2418
|
-
const BASE_STATE_KEYS = new Set(["auth"]);
|
|
2419
|
-
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
2420
|
-
async function downloadFile(document, fileName) {
|
|
2421
|
-
try {
|
|
2422
|
-
const data = await createZip(document);
|
|
2423
|
-
const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
|
|
2424
|
-
const link = window.document.createElement("a");
|
|
2425
|
-
link.style.display = "none";
|
|
2426
|
-
link.href = URL.createObjectURL(blob);
|
|
2427
|
-
link.download = fileName;
|
|
2428
|
-
window.document.body.appendChild(link);
|
|
2429
|
-
link.click();
|
|
2430
|
-
window.document.body.removeChild(link);
|
|
2431
|
-
} catch (e) {
|
|
2432
|
-
logger.error(e instanceof Error ? e.message : String(e));
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
async function getDocumentExtension(document) {
|
|
2436
|
-
const documentType = document.header.documentType;
|
|
2437
|
-
let rawExtension;
|
|
2438
|
-
if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
|
|
2439
|
-
else {
|
|
2440
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2441
|
-
if (reactorClient) {
|
|
2442
|
-
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2443
|
-
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
|
|
2447
|
-
}
|
|
2448
|
-
/**
|
|
2449
|
-
* Fetches all operations for a document using cursor-based pagination.
|
|
2450
|
-
* The reactor client handles multi-scope cursors transparently via
|
|
2451
|
-
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
2452
|
-
*/
|
|
2453
|
-
async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
|
|
2454
|
-
const scopes = Object.keys(document.state).filter((k) => !BASE_STATE_KEYS.has(k));
|
|
2455
|
-
const operations = {};
|
|
2456
|
-
for (const scope of scopes) operations[scope] = [];
|
|
2457
|
-
let cursor = "";
|
|
2458
|
-
do {
|
|
2459
|
-
const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
|
|
2460
|
-
cursor,
|
|
2461
|
-
limit: pageSize
|
|
2462
|
-
});
|
|
2463
|
-
for (const op of page.results) {
|
|
2464
|
-
const scope = op.action.scope ?? "global";
|
|
2465
|
-
if (operations[scope]) operations[scope].push(op);
|
|
2466
|
-
}
|
|
2467
|
-
cursor = page.nextCursor ?? "";
|
|
2468
|
-
} while (cursor);
|
|
2469
|
-
return operations;
|
|
2470
|
-
}
|
|
2471
|
-
function extractInitialState(documentScopeOps) {
|
|
2472
|
-
const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
|
|
2473
|
-
if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
|
|
2474
|
-
const input = upgradeOp.action.input;
|
|
2475
|
-
const initialState = input.initialState ?? input.state;
|
|
2476
|
-
if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
|
|
2477
|
-
return initialState;
|
|
2478
|
-
}
|
|
2479
|
-
function filterDomainOperations(operations) {
|
|
2480
|
-
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
2481
|
-
}
|
|
2482
|
-
async function exportFile(document, suggestedName) {
|
|
2483
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2484
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2485
|
-
const operations = await fetchDocumentOperations(reactorClient, document);
|
|
2486
|
-
const initialState = extractInitialState(operations["document"] ?? []);
|
|
2487
|
-
const documentWithOps = {
|
|
2488
|
-
...document,
|
|
2489
|
-
operations,
|
|
2490
|
-
initialState
|
|
2491
|
-
};
|
|
2492
|
-
const extension = await getDocumentExtension(documentWithOps);
|
|
2493
|
-
const baseName = suggestedName || documentWithOps.header.name || "Untitled";
|
|
2494
|
-
const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
|
|
2495
|
-
if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
|
|
2496
|
-
try {
|
|
2497
|
-
const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
|
|
2498
|
-
await baseSaveToFileHandle(documentWithOps, fileHandle);
|
|
2499
|
-
return fileHandle;
|
|
2500
|
-
} catch (e) {
|
|
2501
|
-
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
/**
|
|
2505
|
-
* Loads a document file and replays it with version-aware reducers from the registry.
|
|
2506
|
-
* Falls back to single-version legacy replay when no upgrade manifest is registered for
|
|
2507
|
-
* the document type.
|
|
2508
|
-
*/
|
|
2509
|
-
async function loadFile(path) {
|
|
2510
|
-
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
2511
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2512
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2513
|
-
const documentType = baseDocument.header.documentType;
|
|
2514
|
-
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2515
|
-
const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
|
|
2516
|
-
if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
|
|
2517
|
-
const reducers = {};
|
|
2518
|
-
for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
|
|
2519
|
-
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2520
|
-
let upgradeManifest;
|
|
2521
|
-
if (registry) try {
|
|
2522
|
-
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
2523
|
-
} catch {}
|
|
2524
|
-
return baseLoadFromInputVersioned(path, {
|
|
2525
|
-
reducers,
|
|
2526
|
-
upgradeManifest
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
|
|
2530
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2531
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
2532
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2533
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2534
|
-
const documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
2535
|
-
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
2536
|
-
newDocument.header.name = name;
|
|
2537
|
-
if (preferredEditor) newDocument.header.meta = {
|
|
2538
|
-
...newDocument.header.meta,
|
|
2539
|
-
preferredEditor
|
|
2540
|
-
};
|
|
2541
|
-
let newDoc;
|
|
2542
|
-
try {
|
|
2543
|
-
newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
|
|
2544
|
-
} catch (e) {
|
|
2545
|
-
logger.error("Error adding document: @error", e);
|
|
2546
|
-
throw new Error("There was an error adding document", { cause: e });
|
|
2547
|
-
}
|
|
2548
|
-
return {
|
|
2549
|
-
id: newDoc.header.id,
|
|
2550
|
-
name: newDoc.header.name,
|
|
2551
|
-
documentType,
|
|
2552
|
-
parentFolder: parentFolder ?? null,
|
|
2553
|
-
kind: "file"
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
async function addFile(file, driveId, name, parentFolder) {
|
|
2557
|
-
logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
2558
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2559
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
|
|
2560
|
-
const document = await loadFile(file);
|
|
2561
|
-
let duplicateId = false;
|
|
2562
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2563
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2564
|
-
try {
|
|
2565
|
-
await reactorClient.get(document.header.id);
|
|
2566
|
-
duplicateId = true;
|
|
2567
|
-
} catch {}
|
|
2568
|
-
const documentId = duplicateId ? generateId() : document.header.id;
|
|
2569
|
-
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
2570
|
-
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
2571
|
-
header.meta = document.header.meta;
|
|
2572
|
-
header.name = name || document.header.name;
|
|
2573
|
-
const initialDocument = {
|
|
2574
|
-
...document,
|
|
2575
|
-
header,
|
|
2576
|
-
state: document.initialState,
|
|
2577
|
-
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
2578
|
-
acc[key] = [];
|
|
2579
|
-
return acc;
|
|
2580
|
-
}, {})
|
|
2581
|
-
};
|
|
2582
|
-
await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
2583
|
-
await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations);
|
|
2584
2032
|
}
|
|
2585
|
-
async function addFolder(driveId, name, parentFolder) {
|
|
2033
|
+
async function addFolder$1(driveId, name, parentFolder) {
|
|
2586
2034
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2587
2035
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
2588
2036
|
const reactorClient = window.ph?.reactorClient;
|
|
2589
2037
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2590
2038
|
await reactorClient.get(driveId);
|
|
2591
2039
|
const folderId = generateId();
|
|
2592
|
-
const node = (await reactorClient.execute(driveId, "main", [addFolder
|
|
2040
|
+
const node = (await reactorClient.execute(driveId, "main", [addFolder({
|
|
2593
2041
|
id: folderId,
|
|
2594
2042
|
name,
|
|
2595
2043
|
parentFolder
|
|
@@ -2667,10 +2115,12 @@ async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
2667
2115
|
upgradeManifest
|
|
2668
2116
|
};
|
|
2669
2117
|
const header = createPresignedHeader(newId, documentType);
|
|
2670
|
-
|
|
2118
|
+
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
2119
|
+
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
2120
|
+
return duplicated;
|
|
2671
2121
|
}
|
|
2672
2122
|
async function copyNode$1(driveId, src, target) {
|
|
2673
|
-
const reactor = window.ph?.
|
|
2123
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
2674
2124
|
if (!reactor) return;
|
|
2675
2125
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2676
2126
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
@@ -2707,31 +2157,84 @@ async function copyNode$1(driveId, src, target) {
|
|
|
2707
2157
|
}
|
|
2708
2158
|
return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
|
|
2709
2159
|
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
}
|
|
2719
|
-
/** Shows the create document modal */
|
|
2720
|
-
function showCreateDocumentModal(documentType) {
|
|
2721
|
-
setPHModal({
|
|
2722
|
-
type: "createDocument",
|
|
2723
|
-
documentType
|
|
2724
|
-
});
|
|
2725
|
-
}
|
|
2726
|
-
/** Shows the delete node modal */
|
|
2727
|
-
function showDeleteNodeModal(nodeOrId) {
|
|
2728
|
-
setPHModal({
|
|
2729
|
-
type: "deleteItem",
|
|
2730
|
-
id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
|
|
2731
|
-
});
|
|
2160
|
+
/**
|
|
2161
|
+
* Upgrades a document to a newer document model version. Defaults to the
|
|
2162
|
+
* latest registered version for the document's type.
|
|
2163
|
+
*/
|
|
2164
|
+
async function upgradeDocument(documentId, toVersion) {
|
|
2165
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2166
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2167
|
+
return reactorClient.upgradeDocument(documentId, toVersion);
|
|
2732
2168
|
}
|
|
2733
|
-
/**
|
|
2734
|
-
|
|
2169
|
+
/**
|
|
2170
|
+
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
2171
|
+
* the write path can reuse `remoteOperationToLocal` on the items it selects.
|
|
2172
|
+
*/
|
|
2173
|
+
const ReactorOperationFieldsFragmentDoc = import_main.gql`
|
|
2174
|
+
fragment ReactorOperationFields on ReactorOperation {
|
|
2175
|
+
index
|
|
2176
|
+
timestampUtcMs
|
|
2177
|
+
hash
|
|
2178
|
+
skip
|
|
2179
|
+
error
|
|
2180
|
+
deniedReason
|
|
2181
|
+
id
|
|
2182
|
+
action {
|
|
2183
|
+
id
|
|
2184
|
+
type
|
|
2185
|
+
timestampUtcMs
|
|
2186
|
+
input
|
|
2187
|
+
scope
|
|
2188
|
+
context {
|
|
2189
|
+
signer {
|
|
2190
|
+
user {
|
|
2191
|
+
address
|
|
2192
|
+
networkId
|
|
2193
|
+
chainId
|
|
2194
|
+
}
|
|
2195
|
+
app {
|
|
2196
|
+
name
|
|
2197
|
+
key
|
|
2198
|
+
}
|
|
2199
|
+
signatures
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
`;
|
|
2205
|
+
import_main.gql`
|
|
2206
|
+
mutation MutateDocumentWithOperations(
|
|
2207
|
+
$documentIdentifier: String!
|
|
2208
|
+
$actions: [JSONObject!]!
|
|
2209
|
+
$view: ViewFilterInput
|
|
2210
|
+
$sinceRevision: Int
|
|
2211
|
+
$scopes: [String!]
|
|
2212
|
+
$branch: String
|
|
2213
|
+
) {
|
|
2214
|
+
mutateDocument(
|
|
2215
|
+
documentIdentifier: $documentIdentifier
|
|
2216
|
+
actions: $actions
|
|
2217
|
+
view: $view
|
|
2218
|
+
) {
|
|
2219
|
+
...PHDocumentFields
|
|
2220
|
+
operations(
|
|
2221
|
+
filter: {
|
|
2222
|
+
sinceRevision: $sinceRevision
|
|
2223
|
+
scopes: $scopes
|
|
2224
|
+
branch: $branch
|
|
2225
|
+
}
|
|
2226
|
+
) {
|
|
2227
|
+
items {
|
|
2228
|
+
...ReactorOperationFields
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
${PhDocumentFieldsFragmentDoc}
|
|
2234
|
+
${ReactorOperationFieldsFragmentDoc}
|
|
2235
|
+
`;
|
|
2236
|
+
DocumentChangeType.Created, DOCUMENT_CHANGE_TYPE.Created, DocumentChangeType.Deleted, DOCUMENT_CHANGE_TYPE.Deleted, DocumentChangeType.Updated, DOCUMENT_CHANGE_TYPE.Updated, DocumentChangeType.ParentAdded, DOCUMENT_CHANGE_TYPE.ParentAdded, DocumentChangeType.ParentRemoved, DOCUMENT_CHANGE_TYPE.ParentRemoved, DocumentChangeType.ChildAdded, DOCUMENT_CHANGE_TYPE.ChildAdded, DocumentChangeType.ChildRemoved, DOCUMENT_CHANGE_TYPE.ChildRemoved;
|
|
2237
|
+
PropagationMode.Cascade, PropagationMode.Orphan;
|
|
2735
2238
|
const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
2736
2239
|
/** Sets whether external controls are enabled for a given editor. */
|
|
2737
2240
|
const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
@@ -2797,6 +2300,8 @@ const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabl
|
|
|
2797
2300
|
const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
|
|
2798
2301
|
const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
|
|
2799
2302
|
const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
|
|
2303
|
+
const { useValue: useSwitchboardUrl, setValue: setSwitchboardUrl, addEventHandler: addSwitchboardUrlEventHandler } = makePHEventFunctions("switchboardUrl");
|
|
2304
|
+
const { useValue: useRenownAdapters, setValue: setRenownAdapters, addEventHandler: addRenownAdaptersEventHandler } = makePHEventFunctions("renownAdapters");
|
|
2800
2305
|
const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
|
|
2801
2306
|
const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
|
|
2802
2307
|
const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
|
|
@@ -2894,6 +2399,8 @@ const nonUserConfigSetters = {
|
|
|
2894
2399
|
renownUrl: setRenownUrl,
|
|
2895
2400
|
renownNetworkId: setRenownNetworkId,
|
|
2896
2401
|
renownChainId: setRenownChainId,
|
|
2402
|
+
switchboardUrl: setSwitchboardUrl,
|
|
2403
|
+
renownAdapters: setRenownAdapters,
|
|
2897
2404
|
sentryRelease: setSentryRelease,
|
|
2898
2405
|
sentryDsn: setSentryDsn,
|
|
2899
2406
|
sentryEnv: setSentryEnv,
|
|
@@ -2942,6 +2449,8 @@ const nonUserConfigHooks = {
|
|
|
2942
2449
|
renownUrl: useRenownUrl,
|
|
2943
2450
|
renownNetworkId: useRenownNetworkId,
|
|
2944
2451
|
renownChainId: useRenownChainId,
|
|
2452
|
+
switchboardUrl: useSwitchboardUrl,
|
|
2453
|
+
renownAdapters: useRenownAdapters,
|
|
2945
2454
|
sentryRelease: useSentryRelease,
|
|
2946
2455
|
sentryDsn: useSentryDsn,
|
|
2947
2456
|
sentryEnv: useSentryEnv,
|
|
@@ -2963,374 +2472,1090 @@ const nonUserConfigHooks = {
|
|
|
2963
2472
|
...phDocumentEditorConfigHooks,
|
|
2964
2473
|
...nonUserConfigHooks
|
|
2965
2474
|
});
|
|
2966
|
-
const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
|
|
2967
|
-
attachmentServiceEventFunctions.useValue;
|
|
2968
|
-
attachmentServiceEventFunctions.setValue;
|
|
2969
|
-
attachmentServiceEventFunctions.addEventHandler;
|
|
2970
|
-
const featuresEventFunctions = makePHEventFunctions("features");
|
|
2971
|
-
featuresEventFunctions.useValue;
|
|
2972
|
-
featuresEventFunctions.setValue;
|
|
2973
|
-
featuresEventFunctions.addEventHandler;
|
|
2974
|
-
function resolveUrlPathname(path) {
|
|
2975
|
-
return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
|
|
2475
|
+
const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
|
|
2476
|
+
attachmentServiceEventFunctions.useValue;
|
|
2477
|
+
attachmentServiceEventFunctions.setValue;
|
|
2478
|
+
attachmentServiceEventFunctions.addEventHandler;
|
|
2479
|
+
const featuresEventFunctions = makePHEventFunctions("features");
|
|
2480
|
+
featuresEventFunctions.useValue;
|
|
2481
|
+
featuresEventFunctions.setValue;
|
|
2482
|
+
featuresEventFunctions.addEventHandler;
|
|
2483
|
+
function resolveUrlPathname(path) {
|
|
2484
|
+
return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
|
|
2485
|
+
}
|
|
2486
|
+
/** Returns the current path without the base path */
|
|
2487
|
+
function getPathWithoutBase(path) {
|
|
2488
|
+
const basePath = window.ph?.basePath ?? "/";
|
|
2489
|
+
return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
|
|
2490
|
+
}
|
|
2491
|
+
/** Makes a URL component for a node. */
|
|
2492
|
+
function makeNodeSlug(node) {
|
|
2493
|
+
if (!node) return "";
|
|
2494
|
+
const nodeName = node.name;
|
|
2495
|
+
if (!nodeName) return slug(node.id);
|
|
2496
|
+
return slug(`${nodeName}-${node.id}`);
|
|
2497
|
+
}
|
|
2498
|
+
/** Extracts the node slug from a path.
|
|
2499
|
+
*
|
|
2500
|
+
* The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
|
|
2501
|
+
*/
|
|
2502
|
+
function extractNodeSlugFromPath(path) {
|
|
2503
|
+
const currentPath = getPathWithoutBase(path);
|
|
2504
|
+
return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
|
|
2505
|
+
}
|
|
2506
|
+
/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
|
|
2507
|
+
function findUuid(input) {
|
|
2508
|
+
if (!input) return void 0;
|
|
2509
|
+
return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
|
|
2510
|
+
}
|
|
2511
|
+
function extractNodeIdFromSlug(nodeSlug) {
|
|
2512
|
+
return findUuid(nodeSlug);
|
|
2513
|
+
}
|
|
2514
|
+
/** Extracts the drive slug from a path.
|
|
2515
|
+
* Used for extracting drive ids from drive slugs in the URL.
|
|
2516
|
+
* Expects the path to be in the format `/d/<drive-slug>`.
|
|
2517
|
+
*/
|
|
2518
|
+
function extractDriveSlugFromPath(path) {
|
|
2519
|
+
const currentPath = getPathWithoutBase(path);
|
|
2520
|
+
return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Creates a URL string with the given pathname while preserving existing query parameters.
|
|
2524
|
+
*/
|
|
2525
|
+
function createUrlWithPreservedParams(pathname) {
|
|
2526
|
+
const search = window.location.search;
|
|
2527
|
+
return search ? `${pathname}${search}` : pathname;
|
|
2528
|
+
}
|
|
2529
|
+
const drivesEventFunctions = makePHEventFunctions("drives");
|
|
2530
|
+
/** Returns all of the drives in the reactor */
|
|
2531
|
+
const useDrives = drivesEventFunctions.useValue;
|
|
2532
|
+
/** Sets the drives in the reactor */
|
|
2533
|
+
const setDrives = drivesEventFunctions.setValue;
|
|
2534
|
+
drivesEventFunctions.addEventHandler;
|
|
2535
|
+
const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
|
|
2536
|
+
const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
|
|
2537
|
+
const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
|
|
2538
|
+
selectedNodeIdEventFunctions.addEventHandler;
|
|
2539
|
+
/** Sets the selected node (file or folder). */
|
|
2540
|
+
function setSelectedNode(nodeOrNodeSlug) {
|
|
2541
|
+
const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
|
|
2542
|
+
setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
|
|
2543
|
+
const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
|
|
2544
|
+
if (!driveSlugFromPath) return;
|
|
2545
|
+
if (!nodeSlug) {
|
|
2546
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
|
|
2547
|
+
if (pathname === window.location.pathname) return;
|
|
2548
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
|
|
2552
|
+
if (pathname === window.location.pathname) return;
|
|
2553
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2554
|
+
}
|
|
2555
|
+
const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
|
|
2556
|
+
/** Returns the selected drive id */
|
|
2557
|
+
const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
|
|
2558
|
+
/** Sets the selected drive id */
|
|
2559
|
+
const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
|
|
2560
|
+
selectedDriveIdEventFunctions.addEventHandler;
|
|
2561
|
+
/** Returns the selected drive, or undefined if no drive is selected */
|
|
2562
|
+
function useSelectedDriveSafe() {
|
|
2563
|
+
const selectedDriveId = useSelectedDriveId();
|
|
2564
|
+
const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
|
|
2565
|
+
const [drive, dispatch] = useDispatch(selectedDrive);
|
|
2566
|
+
if (!selectedDrive) return [void 0, void 0];
|
|
2567
|
+
return [drive, dispatch];
|
|
2568
|
+
}
|
|
2569
|
+
function setSelectedDrive(driveOrDriveSlug) {
|
|
2570
|
+
const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
|
|
2571
|
+
const drives = window.ph?.drives;
|
|
2572
|
+
const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
|
|
2573
|
+
if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
|
|
2574
|
+
if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
|
|
2575
|
+
deferDriveSelection(driveSlug);
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
cancelPendingDriveSelection();
|
|
2579
|
+
setSelectedDriveId(driveId);
|
|
2580
|
+
if (!driveId) {
|
|
2581
|
+
const pathname = resolveUrlPathname("/");
|
|
2582
|
+
if (pathname === window.location.pathname) return;
|
|
2583
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
const pathname = resolveUrlPathname(`/d/${driveSlug}`);
|
|
2587
|
+
if (pathname === window.location.pathname) return;
|
|
2588
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2589
|
+
}
|
|
2590
|
+
const DEFERRED_DRIVE_TICK_MS = 2e3;
|
|
2591
|
+
const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
|
|
2592
|
+
function isInitialSyncInFlight() {
|
|
2593
|
+
const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
|
|
2594
|
+
if (!remotes?.length) return false;
|
|
2595
|
+
return remotes.some((remote) => {
|
|
2596
|
+
try {
|
|
2597
|
+
const snapshot = remote.channel.getConnectionState();
|
|
2598
|
+
return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
|
|
2599
|
+
} catch {
|
|
2600
|
+
return false;
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
let pendingHandler;
|
|
2605
|
+
let pendingTimeout;
|
|
2606
|
+
function cancelPendingDriveSelection() {
|
|
2607
|
+
if (pendingHandler) {
|
|
2608
|
+
window.removeEventListener("ph:drivesUpdated", pendingHandler);
|
|
2609
|
+
pendingHandler = void 0;
|
|
2610
|
+
}
|
|
2611
|
+
if (pendingTimeout) {
|
|
2612
|
+
clearTimeout(pendingTimeout);
|
|
2613
|
+
pendingTimeout = void 0;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
function deferDriveSelection(driveSlug) {
|
|
2617
|
+
cancelPendingDriveSelection();
|
|
2618
|
+
const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
|
|
2619
|
+
const handler = () => {
|
|
2620
|
+
if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
|
|
2621
|
+
cancelPendingDriveSelection();
|
|
2622
|
+
setSelectedDrive(driveSlug);
|
|
2623
|
+
setSelectedNode(nodeSlug);
|
|
2624
|
+
};
|
|
2625
|
+
pendingHandler = handler;
|
|
2626
|
+
window.addEventListener("ph:drivesUpdated", handler);
|
|
2627
|
+
const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
|
|
2628
|
+
const scheduleTick = () => {
|
|
2629
|
+
pendingTimeout = setTimeout(() => {
|
|
2630
|
+
if (Date.now() < deadline && isInitialSyncInFlight()) {
|
|
2631
|
+
scheduleTick();
|
|
2632
|
+
return;
|
|
2633
|
+
}
|
|
2634
|
+
cancelPendingDriveSelection();
|
|
2635
|
+
const pathname = resolveUrlPathname("/");
|
|
2636
|
+
if (pathname === window.location.pathname) return;
|
|
2637
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2638
|
+
}, DEFERRED_DRIVE_TICK_MS);
|
|
2639
|
+
};
|
|
2640
|
+
scheduleTick();
|
|
2641
|
+
}
|
|
2642
|
+
function useDropTarget() {
|
|
2643
|
+
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
2644
|
+
const isDragAndDropEnabled = useIsDragAndDropEnabled();
|
|
2645
|
+
const targetSetter = n$1(() => setIsDropTarget(true), {
|
|
2646
|
+
triggerAt: "start",
|
|
2647
|
+
minQuietPeriodMs: 100
|
|
2648
|
+
});
|
|
2649
|
+
const targetUnsetter = n$1(() => setIsDropTarget(false), {
|
|
2650
|
+
triggerAt: "start",
|
|
2651
|
+
minQuietPeriodMs: 100
|
|
2652
|
+
});
|
|
2653
|
+
function setTarget() {
|
|
2654
|
+
if (!isDragAndDropEnabled) return;
|
|
2655
|
+
targetUnsetter.cancel();
|
|
2656
|
+
targetSetter.call();
|
|
2657
|
+
}
|
|
2658
|
+
function unsetTarget() {
|
|
2659
|
+
if (!isDragAndDropEnabled) return;
|
|
2660
|
+
targetSetter.cancel();
|
|
2661
|
+
targetUnsetter.call();
|
|
2662
|
+
}
|
|
2663
|
+
return {
|
|
2664
|
+
isDropTarget,
|
|
2665
|
+
setTarget,
|
|
2666
|
+
unsetTarget
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
|
|
2670
|
+
const useDraggingNode = draggingNodeEventFunctions.useValue;
|
|
2671
|
+
const setDraggingNode = draggingNodeEventFunctions.setValue;
|
|
2672
|
+
draggingNodeEventFunctions.addEventHandler;
|
|
2673
|
+
const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
|
|
2674
|
+
reducer: (_, newNode) => newNode,
|
|
2675
|
+
triggerAt: "start",
|
|
2676
|
+
minQuietPeriodMs: 100
|
|
2677
|
+
});
|
|
2678
|
+
const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
|
|
2679
|
+
triggerAt: "start",
|
|
2680
|
+
minQuietPeriodMs: 100
|
|
2681
|
+
});
|
|
2682
|
+
function setDragging(node) {
|
|
2683
|
+
draggingNodeUnsetter.cancel();
|
|
2684
|
+
draggingNodeSetter.call(node);
|
|
2976
2685
|
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
|
|
2686
|
+
function unsetDragging() {
|
|
2687
|
+
draggingNodeSetter.cancel();
|
|
2688
|
+
draggingNodeUnsetter.call();
|
|
2981
2689
|
}
|
|
2982
|
-
|
|
2983
|
-
function
|
|
2984
|
-
|
|
2985
|
-
const
|
|
2986
|
-
|
|
2987
|
-
|
|
2690
|
+
const isNodeDrag = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$1)(driveId), e$6(false)], [({ driveId, srcId }) => t(driveId, srcId), e$6(false)], e$6(true));
|
|
2691
|
+
function useDragNode(args) {
|
|
2692
|
+
const { srcId, parentId } = args;
|
|
2693
|
+
const driveId = useSelectedDriveId();
|
|
2694
|
+
const draggingNodeId = useDraggingNode()?.srcId;
|
|
2695
|
+
const params = {
|
|
2696
|
+
driveId,
|
|
2697
|
+
srcId,
|
|
2698
|
+
parentId
|
|
2699
|
+
};
|
|
2700
|
+
const draggable = isNodeDrag(params);
|
|
2701
|
+
const isDragging = t$4({
|
|
2702
|
+
srcId,
|
|
2703
|
+
draggingNodeId
|
|
2704
|
+
}, [
|
|
2705
|
+
() => draggable,
|
|
2706
|
+
({ srcId }) => e$2(srcId),
|
|
2707
|
+
({ draggingNodeId }) => e$2(draggingNodeId),
|
|
2708
|
+
({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
|
|
2709
|
+
]);
|
|
2710
|
+
const onDragStart = () => {
|
|
2711
|
+
if (!draggable) return;
|
|
2712
|
+
setDragging(params);
|
|
2713
|
+
};
|
|
2714
|
+
const onDragEnd = () => {
|
|
2715
|
+
if (!draggable) return;
|
|
2716
|
+
unsetDragging();
|
|
2717
|
+
};
|
|
2718
|
+
return {
|
|
2719
|
+
isDragging,
|
|
2720
|
+
draggable,
|
|
2721
|
+
onDragStart,
|
|
2722
|
+
onDragEnd
|
|
2723
|
+
};
|
|
2988
2724
|
}
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
const
|
|
2995
|
-
|
|
2725
|
+
const isNodeDrop = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$4)(driveId), e$6(false)], [({ srcId, targetId }) => t(srcId, targetId), e$6(false)], [({ driveId, parentId, targetId }) => e$3(e$1)(parentId) && t(targetId, driveId), e$6(false)], [({ targetId, parentId }) => t(targetId, parentId), e$6(false)], e$6(true));
|
|
2726
|
+
function useDropNode(targetId) {
|
|
2727
|
+
const driveId = useSelectedDriveId();
|
|
2728
|
+
const { srcId, parentId } = useDraggingNode() ?? {};
|
|
2729
|
+
const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
|
|
2730
|
+
const params = {
|
|
2731
|
+
driveId,
|
|
2732
|
+
parentId,
|
|
2733
|
+
targetId,
|
|
2734
|
+
srcId
|
|
2735
|
+
};
|
|
2736
|
+
function handleNodeDrop(event, cb) {
|
|
2737
|
+
if (!isNodeDrop(params)) return;
|
|
2738
|
+
event.preventDefault();
|
|
2739
|
+
event.stopPropagation();
|
|
2740
|
+
cb?.();
|
|
2741
|
+
}
|
|
2742
|
+
const onDragEnter = (event) => handleNodeDrop(event);
|
|
2743
|
+
const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
|
|
2744
|
+
const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
|
|
2745
|
+
const onDrop = (event) => handleNodeDrop(event, e(() => {
|
|
2746
|
+
unsetDragging();
|
|
2747
|
+
unsetTarget();
|
|
2748
|
+
moveNodeById(params).catch(console.error);
|
|
2749
|
+
}));
|
|
2750
|
+
return {
|
|
2751
|
+
isDropTarget,
|
|
2752
|
+
onDragEnter,
|
|
2753
|
+
onDragOver,
|
|
2754
|
+
onDragLeave,
|
|
2755
|
+
onDrop
|
|
2756
|
+
};
|
|
2996
2757
|
}
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2758
|
+
const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
|
|
2759
|
+
graphQLReactorClientEventFunctions.useValue;
|
|
2760
|
+
graphQLReactorClientEventFunctions.setValue;
|
|
2761
|
+
graphQLReactorClientEventFunctions.addEventHandler;
|
|
2762
|
+
const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
|
|
2763
|
+
packageDiscoveryFunctions.useValue;
|
|
2764
|
+
packageDiscoveryFunctions.setValue;
|
|
2765
|
+
packageDiscoveryFunctions.addEventHandler;
|
|
2766
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
2767
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
2768
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
2769
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
2770
|
+
reactorClientModuleEventFunctions.setValue;
|
|
2771
|
+
reactorClientModuleEventFunctions.addEventHandler;
|
|
2772
|
+
reactorClientEventFunctions.useValue;
|
|
2773
|
+
reactorClientEventFunctions.setValue;
|
|
2774
|
+
reactorClientEventFunctions.addEventHandler;
|
|
2775
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
2776
|
+
const useSyncList = () => {
|
|
2777
|
+
return useSync()?.list() ?? [];
|
|
2778
|
+
};
|
|
2779
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
2780
|
+
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
2781
|
+
revisionHistoryEventFunctions.useValue;
|
|
2782
|
+
/** Sets revision history visibility */
|
|
2783
|
+
const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
|
|
2784
|
+
revisionHistoryEventFunctions.addEventHandler;
|
|
2785
|
+
/** Shows the revision history */
|
|
2786
|
+
function showRevisionHistory() {
|
|
2787
|
+
setRevisionHistoryVisible(true);
|
|
3001
2788
|
}
|
|
3002
|
-
|
|
3003
|
-
|
|
2789
|
+
/** Sorts nodes by name. */
|
|
2790
|
+
function sortNodesByName(nodes) {
|
|
2791
|
+
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
3004
2792
|
}
|
|
3005
|
-
/**
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
2793
|
+
/** Returns whether a node is a file. */
|
|
2794
|
+
function isFileNodeKind(node) {
|
|
2795
|
+
if (!node) return false;
|
|
2796
|
+
return node.kind.toUpperCase() === "FILE";
|
|
2797
|
+
}
|
|
2798
|
+
/** Returns whether a node is a folder. */
|
|
2799
|
+
function isFolderNodeKind(node) {
|
|
2800
|
+
if (!node) return false;
|
|
2801
|
+
return node.kind.toUpperCase() === "FOLDER";
|
|
2802
|
+
}
|
|
2803
|
+
/** Returns the nodes in the selected drive. */
|
|
2804
|
+
function useNodesInSelectedDrive() {
|
|
2805
|
+
const [selectedDrive] = useSelectedDriveSafe();
|
|
2806
|
+
return selectedDrive?.state.global.nodes;
|
|
2807
|
+
}
|
|
2808
|
+
/** Returns the folder nodes in the selected drive. */
|
|
2809
|
+
function useFolderNodesInSelectedDrive() {
|
|
2810
|
+
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
2811
|
+
}
|
|
2812
|
+
/** Returns the selected node. */
|
|
2813
|
+
function useSelectedNode() {
|
|
2814
|
+
const selectedNodeId = useSelectedNodeId();
|
|
2815
|
+
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
2816
|
+
}
|
|
2817
|
+
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
2818
|
+
selectedTimelineItemEventFunctions.useValue;
|
|
2819
|
+
selectedTimelineItemEventFunctions.setValue;
|
|
2820
|
+
selectedTimelineItemEventFunctions.addEventHandler;
|
|
2821
|
+
const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
|
|
2822
|
+
selectedTimelineRevisionEventFunctions.useValue;
|
|
2823
|
+
selectedTimelineRevisionEventFunctions.setValue;
|
|
2824
|
+
selectedTimelineRevisionEventFunctions.addEventHandler;
|
|
2825
|
+
const toastEventFunctions = makePHEventFunctions("toast");
|
|
2826
|
+
/** Returns the toast function */
|
|
2827
|
+
const usePHToast = toastEventFunctions.useValue;
|
|
2828
|
+
toastEventFunctions.setValue;
|
|
2829
|
+
toastEventFunctions.addEventHandler;
|
|
2830
|
+
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
2831
|
+
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
2832
|
+
/** Returns all of the Vetra packages loaded by the Connect instance */
|
|
2833
|
+
const useVetraPackages = () => {
|
|
2834
|
+
const packageManager = useVetraPackageManager();
|
|
2835
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
2836
|
+
};
|
|
2837
|
+
vetraPackageManagerFunctions.addEventHandler;
|
|
2838
|
+
function useDocumentModelModules() {
|
|
2839
|
+
return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
|
|
3012
2840
|
}
|
|
3013
2841
|
/**
|
|
3014
|
-
*
|
|
2842
|
+
* Resolves a document model module by document type, mirroring the registry's
|
|
2843
|
+
* semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
|
|
2844
|
+
* LATEST version of the type wins (`version ?? 1` as each module's default),
|
|
2845
|
+
* with `version` given only an exact match is returned. The reactor resolves
|
|
2846
|
+
* modules the same way when a document is created, so metadata read through
|
|
2847
|
+
* this hook and the version a creation actually uses cannot disagree.
|
|
3015
2848
|
*/
|
|
3016
|
-
function
|
|
3017
|
-
const
|
|
3018
|
-
|
|
2849
|
+
function useDocumentModelModuleById(id, version) {
|
|
2850
|
+
const documentModelModules = useDocumentModelModules();
|
|
2851
|
+
if (!id || !documentModelModules) return void 0;
|
|
2852
|
+
let latestModule;
|
|
2853
|
+
let latestVersion = -1;
|
|
2854
|
+
for (const module of documentModelModules) {
|
|
2855
|
+
if (module.documentModel.global.id !== id) continue;
|
|
2856
|
+
const moduleVersion = module.version ?? 1;
|
|
2857
|
+
if (version !== void 0) {
|
|
2858
|
+
if (moduleVersion === version) return module;
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
if (moduleVersion > latestVersion) {
|
|
2862
|
+
latestVersion = moduleVersion;
|
|
2863
|
+
latestModule = module;
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
return latestModule;
|
|
3019
2867
|
}
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
const
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
const
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
if (
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2868
|
+
//#endregion
|
|
2869
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
|
|
2870
|
+
const normalizeDescriptors = (error) => {
|
|
2871
|
+
CORE_ERROR_PROPS.forEach((propName) => {
|
|
2872
|
+
normalizeDescriptor(error, propName);
|
|
2873
|
+
});
|
|
2874
|
+
};
|
|
2875
|
+
const CORE_ERROR_PROPS = [
|
|
2876
|
+
"name",
|
|
2877
|
+
"message",
|
|
2878
|
+
"stack",
|
|
2879
|
+
"cause",
|
|
2880
|
+
"errors"
|
|
2881
|
+
];
|
|
2882
|
+
const normalizeDescriptor = (error, propName) => {
|
|
2883
|
+
const descriptor = getDescriptor(error, propName);
|
|
2884
|
+
if (descriptor === void 0) return;
|
|
2885
|
+
if (isReadonlyGetter(descriptor)) {
|
|
2886
|
+
setErrorProperty(error, propName, error[propName]);
|
|
3040
2887
|
return;
|
|
3041
2888
|
}
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
const
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
2889
|
+
if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
|
|
2890
|
+
};
|
|
2891
|
+
const getDescriptor = (value, propName) => {
|
|
2892
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, propName);
|
|
2893
|
+
if (descriptor !== void 0) return descriptor;
|
|
2894
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2895
|
+
return prototype === null ? void 0 : getDescriptor(prototype, propName);
|
|
2896
|
+
};
|
|
2897
|
+
const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
|
|
2898
|
+
const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
|
|
2899
|
+
const setErrorProperty = (error, propName, value) => {
|
|
2900
|
+
setErrorDescriptor(error, propName, { value });
|
|
2901
|
+
};
|
|
2902
|
+
const setErrorDescriptor = (error, propName, descriptor) => {
|
|
2903
|
+
Object.defineProperty(error, propName, {
|
|
2904
|
+
...descriptor,
|
|
2905
|
+
..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
|
|
2906
|
+
enumerable: false,
|
|
2907
|
+
configurable: true
|
|
2908
|
+
});
|
|
2909
|
+
};
|
|
2910
|
+
//#endregion
|
|
2911
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
|
|
2912
|
+
const normalizeAggregate = (error, recurse) => {
|
|
2913
|
+
if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
|
|
2914
|
+
else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
|
|
2915
|
+
else if (error.errors !== void 0) deleteAggregateErrors(error);
|
|
2916
|
+
};
|
|
2917
|
+
const isDefined = (error) => error !== void 0;
|
|
2918
|
+
const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
|
|
2919
|
+
const deleteAggregateErrors = (error) => {
|
|
2920
|
+
delete error.errors;
|
|
2921
|
+
if (error.errors !== void 0) setErrorProperty(error, "errors", []);
|
|
2922
|
+
};
|
|
2923
|
+
//#endregion
|
|
2924
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
|
|
2925
|
+
const normalizeCause = (error, recurse) => {
|
|
2926
|
+
if (!("cause" in error)) return;
|
|
2927
|
+
const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
|
|
2928
|
+
if (cause === void 0) delete error.cause;
|
|
2929
|
+
else setErrorProperty(error, "cause", cause);
|
|
2930
|
+
};
|
|
2931
|
+
//#endregion
|
|
2932
|
+
//#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
|
|
2933
|
+
const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
|
|
2934
|
+
const isInstanceOfError = (value) => {
|
|
2935
|
+
try {
|
|
2936
|
+
return value instanceof Error;
|
|
2937
|
+
} catch {
|
|
2938
|
+
return false;
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
const hasErrorTag = (value) => {
|
|
2942
|
+
try {
|
|
2943
|
+
return ERROR_TAGS.has(Object.prototype.toString.call(value));
|
|
2944
|
+
} catch {
|
|
2945
|
+
return false;
|
|
2946
|
+
}
|
|
2947
|
+
};
|
|
2948
|
+
const ERROR_TAGS = new Set([
|
|
2949
|
+
"[object Error]",
|
|
2950
|
+
"[object DOMException]",
|
|
2951
|
+
"[object DOMError]",
|
|
2952
|
+
"[object Exception]"
|
|
2953
|
+
]);
|
|
2954
|
+
//#endregion
|
|
2955
|
+
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
2956
|
+
function isPlainObject(value) {
|
|
2957
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2958
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2959
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
3059
2960
|
}
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
2961
|
+
//#endregion
|
|
2962
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
|
|
2963
|
+
const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
|
|
2964
|
+
const isNonConfigurableProp = (error, propName) => {
|
|
2965
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, propName);
|
|
2966
|
+
return descriptor !== void 0 && !descriptor.configurable;
|
|
2967
|
+
};
|
|
2968
|
+
const isThrowingProp = (error, propName) => {
|
|
2969
|
+
try {
|
|
2970
|
+
error[propName];
|
|
2971
|
+
return false;
|
|
2972
|
+
} catch {
|
|
2973
|
+
return true;
|
|
2974
|
+
}
|
|
2975
|
+
};
|
|
2976
|
+
//#endregion
|
|
2977
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
|
|
2978
|
+
const setStack = (error) => {
|
|
2979
|
+
setErrorProperty(error, "stack", getStack(error.message, error.name));
|
|
2980
|
+
};
|
|
2981
|
+
const getStack = (message = "", name = "Error") => {
|
|
2982
|
+
const { stack } = new (getErrorClass(name))(message);
|
|
2983
|
+
return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
|
|
2984
|
+
};
|
|
2985
|
+
const getErrorClass = (name) => {
|
|
2986
|
+
const descriptor = {
|
|
2987
|
+
value: name,
|
|
2988
|
+
enumerable: false,
|
|
2989
|
+
writable: true,
|
|
2990
|
+
configurable: true
|
|
2991
|
+
};
|
|
2992
|
+
const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
|
|
2993
|
+
Object.defineProperty(StackError.prototype, "name", descriptor);
|
|
2994
|
+
return StackError;
|
|
2995
|
+
};
|
|
2996
|
+
//#endregion
|
|
2997
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
|
|
2998
|
+
const copyObject = (object) => {
|
|
2999
|
+
const objectCopy = {};
|
|
3000
|
+
for (const propName of getPropsToCopy(object)) try {
|
|
3001
|
+
const value = object[propName];
|
|
3002
|
+
const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
|
|
3003
|
+
Object.defineProperty(objectCopy, propName, {
|
|
3004
|
+
value,
|
|
3005
|
+
enumerable,
|
|
3006
|
+
configurable,
|
|
3007
|
+
writable
|
|
3008
|
+
});
|
|
3009
|
+
} catch {}
|
|
3010
|
+
return objectCopy;
|
|
3011
|
+
};
|
|
3012
|
+
const getPropsToCopy = (object) => {
|
|
3013
|
+
const propNames = getOwnKeys(object);
|
|
3014
|
+
for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
|
|
3015
|
+
return propNames;
|
|
3016
|
+
};
|
|
3017
|
+
const getOwnKeys = (object) => {
|
|
3018
|
+
try {
|
|
3019
|
+
return Reflect.ownKeys(object);
|
|
3020
|
+
} catch {
|
|
3021
|
+
return [];
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
const isInheritedProp = (object, propName) => {
|
|
3025
|
+
try {
|
|
3026
|
+
return propName in object && !Object.hasOwn(object, propName);
|
|
3027
|
+
} catch {
|
|
3028
|
+
return false;
|
|
3029
|
+
}
|
|
3030
|
+
};
|
|
3031
|
+
//#endregion
|
|
3032
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
|
|
3033
|
+
const objectifyError = (object) => {
|
|
3034
|
+
const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
|
|
3035
|
+
const messageA = getMessage(message, objectA);
|
|
3036
|
+
const error = newError(name, messageA);
|
|
3037
|
+
if (message === messageA) assignObjectProps(error, objectA);
|
|
3038
|
+
Object.entries({
|
|
3039
|
+
name,
|
|
3040
|
+
stack,
|
|
3041
|
+
cause,
|
|
3042
|
+
errors
|
|
3043
|
+
}).forEach(([propName, propValue]) => {
|
|
3044
|
+
setNewErrorProperty(error, propName, propValue);
|
|
3045
|
+
});
|
|
3046
|
+
if (stack === void 0) setStack(error);
|
|
3047
|
+
return error;
|
|
3048
|
+
};
|
|
3049
|
+
const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
|
|
3050
|
+
const safeJsonStringify = (object) => {
|
|
3051
|
+
try {
|
|
3052
|
+
return JSON.stringify(object);
|
|
3053
|
+
} catch {
|
|
3054
|
+
return safeStringify(object);
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
const safeStringify = (object) => {
|
|
3058
|
+
try {
|
|
3059
|
+
return String(object);
|
|
3060
|
+
} catch {
|
|
3061
|
+
return "Invalid error";
|
|
3068
3062
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3063
|
+
};
|
|
3064
|
+
const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
|
|
3065
|
+
const MESSAGE_MAX_SIZE = 1e3;
|
|
3066
|
+
const newError = (name, message) => {
|
|
3067
|
+
if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
|
|
3068
|
+
if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
|
|
3069
|
+
return new Error(message);
|
|
3070
|
+
};
|
|
3071
|
+
const NATIVE_ERRORS = {
|
|
3072
|
+
Error,
|
|
3073
|
+
ReferenceError,
|
|
3074
|
+
TypeError,
|
|
3075
|
+
SyntaxError,
|
|
3076
|
+
RangeError,
|
|
3077
|
+
URIError,
|
|
3078
|
+
EvalError
|
|
3079
|
+
};
|
|
3080
|
+
const assignObjectProps = (error, object) => {
|
|
3081
|
+
for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
|
|
3082
|
+
};
|
|
3083
|
+
const setNewErrorProperty = (error, propName, propValue) => {
|
|
3084
|
+
if (propValue !== void 0) setErrorProperty(error, propName, propValue);
|
|
3085
|
+
};
|
|
3086
|
+
//#endregion
|
|
3087
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
|
|
3088
|
+
const stringifyError = (value) => {
|
|
3089
|
+
try {
|
|
3090
|
+
const error = new Error(String(value));
|
|
3091
|
+
setStack(error);
|
|
3092
|
+
return error;
|
|
3093
|
+
} catch (error_) {
|
|
3094
|
+
return error_;
|
|
3076
3095
|
}
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
}
|
|
3081
|
-
const
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
}
|
|
3093
|
-
});
|
|
3094
|
-
}
|
|
3095
|
-
let pendingHandler;
|
|
3096
|
-
let pendingTimeout;
|
|
3097
|
-
function cancelPendingDriveSelection() {
|
|
3098
|
-
if (pendingHandler) {
|
|
3099
|
-
window.removeEventListener("ph:drivesUpdated", pendingHandler);
|
|
3100
|
-
pendingHandler = void 0;
|
|
3096
|
+
};
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
|
|
3099
|
+
const { toString: objectToString } = Object.prototype;
|
|
3100
|
+
const createError = (value) => {
|
|
3101
|
+
if (isErrorPlainObj(value)) return objectifyError(value);
|
|
3102
|
+
if (!isErrorInstance(value)) return stringifyError(value);
|
|
3103
|
+
if (isInvalidError(value)) return objectifyError(value);
|
|
3104
|
+
return value;
|
|
3105
|
+
};
|
|
3106
|
+
const isErrorPlainObj = (value) => {
|
|
3107
|
+
try {
|
|
3108
|
+
return isPlainObject(value);
|
|
3109
|
+
} catch {
|
|
3110
|
+
return false;
|
|
3101
3111
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3112
|
+
};
|
|
3113
|
+
const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
|
|
3114
|
+
const isProxy = (value) => {
|
|
3115
|
+
try {
|
|
3116
|
+
return objectToString.call(value) === "[object Object]";
|
|
3117
|
+
} catch {
|
|
3118
|
+
return true;
|
|
3105
3119
|
}
|
|
3106
|
-
}
|
|
3107
|
-
function
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3120
|
+
};
|
|
3121
|
+
const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
|
|
3122
|
+
//#endregion
|
|
3123
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
|
|
3124
|
+
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
3125
|
+
const recurseException = (error, parents, shallow) => {
|
|
3126
|
+
if (parents.includes(error)) return;
|
|
3127
|
+
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
3128
|
+
const errorA = createError(error);
|
|
3129
|
+
normalizeProps(errorA, recurse);
|
|
3130
|
+
return errorA;
|
|
3131
|
+
};
|
|
3132
|
+
const identity = (error) => error;
|
|
3133
|
+
const normalizeProps = (error, recurse) => {
|
|
3134
|
+
normalizeName(error);
|
|
3135
|
+
normalizeMessage(error);
|
|
3136
|
+
normalizeStack(error);
|
|
3137
|
+
normalizeCause(error, recurse);
|
|
3138
|
+
normalizeAggregate(error, recurse);
|
|
3139
|
+
normalizeDescriptors(error);
|
|
3140
|
+
};
|
|
3141
|
+
const normalizeName = (error) => {
|
|
3142
|
+
if (isDefinedString(error.name)) return;
|
|
3143
|
+
const prototypeName = Object.getPrototypeOf(error).name;
|
|
3144
|
+
setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
|
|
3145
|
+
};
|
|
3146
|
+
const normalizeMessage = (error) => {
|
|
3147
|
+
if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
|
|
3148
|
+
};
|
|
3149
|
+
const normalizeStack = (error) => {
|
|
3150
|
+
if (!isDefinedString(error.stack)) setStack(error);
|
|
3151
|
+
};
|
|
3152
|
+
const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
3153
|
+
//#endregion
|
|
3154
|
+
//#region ../reactor-browser/dist/index.js
|
|
3155
|
+
var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3156
|
+
var LZString = (function() {
|
|
3157
|
+
var f = String.fromCharCode;
|
|
3158
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3159
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
3160
|
+
var baseReverseDic = {};
|
|
3161
|
+
function getBaseValue(alphabet, character) {
|
|
3162
|
+
if (!baseReverseDic[alphabet]) {
|
|
3163
|
+
baseReverseDic[alphabet] = {};
|
|
3164
|
+
for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
3165
|
+
}
|
|
3166
|
+
return baseReverseDic[alphabet][character];
|
|
3167
|
+
}
|
|
3168
|
+
var LZString = {
|
|
3169
|
+
compressToBase64: function(input) {
|
|
3170
|
+
if (input == null) return "";
|
|
3171
|
+
var res = LZString._compress(input, 6, function(a) {
|
|
3172
|
+
return keyStrBase64.charAt(a);
|
|
3173
|
+
});
|
|
3174
|
+
switch (res.length % 4) {
|
|
3175
|
+
default:
|
|
3176
|
+
case 0: return res;
|
|
3177
|
+
case 1: return res + "===";
|
|
3178
|
+
case 2: return res + "==";
|
|
3179
|
+
case 3: return res + "=";
|
|
3180
|
+
}
|
|
3181
|
+
},
|
|
3182
|
+
decompressFromBase64: function(input) {
|
|
3183
|
+
if (input == null) return "";
|
|
3184
|
+
if (input == "") return null;
|
|
3185
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3186
|
+
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
3187
|
+
});
|
|
3188
|
+
},
|
|
3189
|
+
compressToUTF16: function(input) {
|
|
3190
|
+
if (input == null) return "";
|
|
3191
|
+
return LZString._compress(input, 15, function(a) {
|
|
3192
|
+
return f(a + 32);
|
|
3193
|
+
}) + " ";
|
|
3194
|
+
},
|
|
3195
|
+
decompressFromUTF16: function(compressed) {
|
|
3196
|
+
if (compressed == null) return "";
|
|
3197
|
+
if (compressed == "") return null;
|
|
3198
|
+
return LZString._decompress(compressed.length, 16384, function(index) {
|
|
3199
|
+
return compressed.charCodeAt(index) - 32;
|
|
3200
|
+
});
|
|
3201
|
+
},
|
|
3202
|
+
compressToUint8Array: function(uncompressed) {
|
|
3203
|
+
var compressed = LZString.compress(uncompressed);
|
|
3204
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
3205
|
+
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
3206
|
+
var current_value = compressed.charCodeAt(i);
|
|
3207
|
+
buf[i * 2] = current_value >>> 8;
|
|
3208
|
+
buf[i * 2 + 1] = current_value % 256;
|
|
3209
|
+
}
|
|
3210
|
+
return buf;
|
|
3211
|
+
},
|
|
3212
|
+
decompressFromUint8Array: function(compressed) {
|
|
3213
|
+
if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
|
|
3214
|
+
else {
|
|
3215
|
+
var buf = new Array(compressed.length / 2);
|
|
3216
|
+
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
3217
|
+
var result = [];
|
|
3218
|
+
buf.forEach(function(c) {
|
|
3219
|
+
result.push(f(c));
|
|
3220
|
+
});
|
|
3221
|
+
return LZString.decompress(result.join(""));
|
|
3222
|
+
}
|
|
3223
|
+
},
|
|
3224
|
+
compressToEncodedURIComponent: function(input) {
|
|
3225
|
+
if (input == null) return "";
|
|
3226
|
+
return LZString._compress(input, 6, function(a) {
|
|
3227
|
+
return keyStrUriSafe.charAt(a);
|
|
3228
|
+
});
|
|
3229
|
+
},
|
|
3230
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
3231
|
+
if (input == null) return "";
|
|
3232
|
+
if (input == "") return null;
|
|
3233
|
+
input = input.replace(/ /g, "+");
|
|
3234
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3235
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
3236
|
+
});
|
|
3237
|
+
},
|
|
3238
|
+
compress: function(uncompressed) {
|
|
3239
|
+
return LZString._compress(uncompressed, 16, function(a) {
|
|
3240
|
+
return f(a);
|
|
3241
|
+
});
|
|
3242
|
+
},
|
|
3243
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
3244
|
+
if (uncompressed == null) return "";
|
|
3245
|
+
var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
3246
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
3247
|
+
context_c = uncompressed.charAt(ii);
|
|
3248
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
3249
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
3250
|
+
context_dictionaryToCreate[context_c] = true;
|
|
3251
|
+
}
|
|
3252
|
+
context_wc = context_w + context_c;
|
|
3253
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
|
|
3254
|
+
else {
|
|
3255
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3256
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3257
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3258
|
+
context_data_val = context_data_val << 1;
|
|
3259
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3260
|
+
context_data_position = 0;
|
|
3261
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3262
|
+
context_data_val = 0;
|
|
3263
|
+
} else context_data_position++;
|
|
3264
|
+
}
|
|
3265
|
+
value = context_w.charCodeAt(0);
|
|
3266
|
+
for (i = 0; i < 8; i++) {
|
|
3267
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3268
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3269
|
+
context_data_position = 0;
|
|
3270
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3271
|
+
context_data_val = 0;
|
|
3272
|
+
} else context_data_position++;
|
|
3273
|
+
value = value >> 1;
|
|
3274
|
+
}
|
|
3275
|
+
} else {
|
|
3276
|
+
value = 1;
|
|
3277
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3278
|
+
context_data_val = context_data_val << 1 | value;
|
|
3279
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3280
|
+
context_data_position = 0;
|
|
3281
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3282
|
+
context_data_val = 0;
|
|
3283
|
+
} else context_data_position++;
|
|
3284
|
+
value = 0;
|
|
3285
|
+
}
|
|
3286
|
+
value = context_w.charCodeAt(0);
|
|
3287
|
+
for (i = 0; i < 16; i++) {
|
|
3288
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3289
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3290
|
+
context_data_position = 0;
|
|
3291
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3292
|
+
context_data_val = 0;
|
|
3293
|
+
} else context_data_position++;
|
|
3294
|
+
value = value >> 1;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
context_enlargeIn--;
|
|
3298
|
+
if (context_enlargeIn == 0) {
|
|
3299
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3300
|
+
context_numBits++;
|
|
3301
|
+
}
|
|
3302
|
+
delete context_dictionaryToCreate[context_w];
|
|
3303
|
+
} else {
|
|
3304
|
+
value = context_dictionary[context_w];
|
|
3305
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3306
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3307
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3308
|
+
context_data_position = 0;
|
|
3309
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3310
|
+
context_data_val = 0;
|
|
3311
|
+
} else context_data_position++;
|
|
3312
|
+
value = value >> 1;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
context_enlargeIn--;
|
|
3316
|
+
if (context_enlargeIn == 0) {
|
|
3317
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3318
|
+
context_numBits++;
|
|
3319
|
+
}
|
|
3320
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
3321
|
+
context_w = String(context_c);
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
if (context_w !== "") {
|
|
3325
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3326
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3327
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3328
|
+
context_data_val = context_data_val << 1;
|
|
3329
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3330
|
+
context_data_position = 0;
|
|
3331
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3332
|
+
context_data_val = 0;
|
|
3333
|
+
} else context_data_position++;
|
|
3334
|
+
}
|
|
3335
|
+
value = context_w.charCodeAt(0);
|
|
3336
|
+
for (i = 0; i < 8; i++) {
|
|
3337
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3338
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3339
|
+
context_data_position = 0;
|
|
3340
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3341
|
+
context_data_val = 0;
|
|
3342
|
+
} else context_data_position++;
|
|
3343
|
+
value = value >> 1;
|
|
3344
|
+
}
|
|
3345
|
+
} else {
|
|
3346
|
+
value = 1;
|
|
3347
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3348
|
+
context_data_val = context_data_val << 1 | value;
|
|
3349
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3350
|
+
context_data_position = 0;
|
|
3351
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3352
|
+
context_data_val = 0;
|
|
3353
|
+
} else context_data_position++;
|
|
3354
|
+
value = 0;
|
|
3355
|
+
}
|
|
3356
|
+
value = context_w.charCodeAt(0);
|
|
3357
|
+
for (i = 0; i < 16; i++) {
|
|
3358
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3359
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3360
|
+
context_data_position = 0;
|
|
3361
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3362
|
+
context_data_val = 0;
|
|
3363
|
+
} else context_data_position++;
|
|
3364
|
+
value = value >> 1;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
context_enlargeIn--;
|
|
3368
|
+
if (context_enlargeIn == 0) {
|
|
3369
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3370
|
+
context_numBits++;
|
|
3371
|
+
}
|
|
3372
|
+
delete context_dictionaryToCreate[context_w];
|
|
3373
|
+
} else {
|
|
3374
|
+
value = context_dictionary[context_w];
|
|
3375
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3376
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3377
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3378
|
+
context_data_position = 0;
|
|
3379
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3380
|
+
context_data_val = 0;
|
|
3381
|
+
} else context_data_position++;
|
|
3382
|
+
value = value >> 1;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
context_enlargeIn--;
|
|
3386
|
+
if (context_enlargeIn == 0) {
|
|
3387
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3388
|
+
context_numBits++;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
value = 2;
|
|
3392
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3393
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3394
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3395
|
+
context_data_position = 0;
|
|
3396
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3397
|
+
context_data_val = 0;
|
|
3398
|
+
} else context_data_position++;
|
|
3399
|
+
value = value >> 1;
|
|
3400
|
+
}
|
|
3401
|
+
while (true) {
|
|
3402
|
+
context_data_val = context_data_val << 1;
|
|
3403
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3404
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3405
|
+
break;
|
|
3406
|
+
} else context_data_position++;
|
|
3407
|
+
}
|
|
3408
|
+
return context_data.join("");
|
|
3409
|
+
},
|
|
3410
|
+
decompress: function(compressed) {
|
|
3411
|
+
if (compressed == null) return "";
|
|
3412
|
+
if (compressed == "") return null;
|
|
3413
|
+
return LZString._decompress(compressed.length, 32768, function(index) {
|
|
3414
|
+
return compressed.charCodeAt(index);
|
|
3415
|
+
});
|
|
3416
|
+
},
|
|
3417
|
+
_decompress: function(length, resetValue, getNextValue) {
|
|
3418
|
+
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
|
|
3419
|
+
val: getNextValue(0),
|
|
3420
|
+
position: resetValue,
|
|
3421
|
+
index: 1
|
|
3422
|
+
};
|
|
3423
|
+
for (i = 0; i < 3; i += 1) dictionary[i] = i;
|
|
3424
|
+
bits = 0;
|
|
3425
|
+
maxpower = Math.pow(2, 2);
|
|
3426
|
+
power = 1;
|
|
3427
|
+
while (power != maxpower) {
|
|
3428
|
+
resb = data.val & data.position;
|
|
3429
|
+
data.position >>= 1;
|
|
3430
|
+
if (data.position == 0) {
|
|
3431
|
+
data.position = resetValue;
|
|
3432
|
+
data.val = getNextValue(data.index++);
|
|
3433
|
+
}
|
|
3434
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3435
|
+
power <<= 1;
|
|
3436
|
+
}
|
|
3437
|
+
switch (bits) {
|
|
3438
|
+
case 0:
|
|
3439
|
+
bits = 0;
|
|
3440
|
+
maxpower = Math.pow(2, 8);
|
|
3441
|
+
power = 1;
|
|
3442
|
+
while (power != maxpower) {
|
|
3443
|
+
resb = data.val & data.position;
|
|
3444
|
+
data.position >>= 1;
|
|
3445
|
+
if (data.position == 0) {
|
|
3446
|
+
data.position = resetValue;
|
|
3447
|
+
data.val = getNextValue(data.index++);
|
|
3448
|
+
}
|
|
3449
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3450
|
+
power <<= 1;
|
|
3451
|
+
}
|
|
3452
|
+
c = f(bits);
|
|
3453
|
+
break;
|
|
3454
|
+
case 1:
|
|
3455
|
+
bits = 0;
|
|
3456
|
+
maxpower = Math.pow(2, 16);
|
|
3457
|
+
power = 1;
|
|
3458
|
+
while (power != maxpower) {
|
|
3459
|
+
resb = data.val & data.position;
|
|
3460
|
+
data.position >>= 1;
|
|
3461
|
+
if (data.position == 0) {
|
|
3462
|
+
data.position = resetValue;
|
|
3463
|
+
data.val = getNextValue(data.index++);
|
|
3464
|
+
}
|
|
3465
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3466
|
+
power <<= 1;
|
|
3467
|
+
}
|
|
3468
|
+
c = f(bits);
|
|
3469
|
+
break;
|
|
3470
|
+
case 2: return "";
|
|
3471
|
+
}
|
|
3472
|
+
dictionary[3] = c;
|
|
3473
|
+
w = c;
|
|
3474
|
+
result.push(c);
|
|
3475
|
+
while (true) {
|
|
3476
|
+
if (data.index > length) return "";
|
|
3477
|
+
bits = 0;
|
|
3478
|
+
maxpower = Math.pow(2, numBits);
|
|
3479
|
+
power = 1;
|
|
3480
|
+
while (power != maxpower) {
|
|
3481
|
+
resb = data.val & data.position;
|
|
3482
|
+
data.position >>= 1;
|
|
3483
|
+
if (data.position == 0) {
|
|
3484
|
+
data.position = resetValue;
|
|
3485
|
+
data.val = getNextValue(data.index++);
|
|
3486
|
+
}
|
|
3487
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3488
|
+
power <<= 1;
|
|
3489
|
+
}
|
|
3490
|
+
switch (c = bits) {
|
|
3491
|
+
case 0:
|
|
3492
|
+
bits = 0;
|
|
3493
|
+
maxpower = Math.pow(2, 8);
|
|
3494
|
+
power = 1;
|
|
3495
|
+
while (power != maxpower) {
|
|
3496
|
+
resb = data.val & data.position;
|
|
3497
|
+
data.position >>= 1;
|
|
3498
|
+
if (data.position == 0) {
|
|
3499
|
+
data.position = resetValue;
|
|
3500
|
+
data.val = getNextValue(data.index++);
|
|
3501
|
+
}
|
|
3502
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3503
|
+
power <<= 1;
|
|
3504
|
+
}
|
|
3505
|
+
dictionary[dictSize++] = f(bits);
|
|
3506
|
+
c = dictSize - 1;
|
|
3507
|
+
enlargeIn--;
|
|
3508
|
+
break;
|
|
3509
|
+
case 1:
|
|
3510
|
+
bits = 0;
|
|
3511
|
+
maxpower = Math.pow(2, 16);
|
|
3512
|
+
power = 1;
|
|
3513
|
+
while (power != maxpower) {
|
|
3514
|
+
resb = data.val & data.position;
|
|
3515
|
+
data.position >>= 1;
|
|
3516
|
+
if (data.position == 0) {
|
|
3517
|
+
data.position = resetValue;
|
|
3518
|
+
data.val = getNextValue(data.index++);
|
|
3519
|
+
}
|
|
3520
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3521
|
+
power <<= 1;
|
|
3522
|
+
}
|
|
3523
|
+
dictionary[dictSize++] = f(bits);
|
|
3524
|
+
c = dictSize - 1;
|
|
3525
|
+
enlargeIn--;
|
|
3526
|
+
break;
|
|
3527
|
+
case 2: return result.join("");
|
|
3528
|
+
}
|
|
3529
|
+
if (enlargeIn == 0) {
|
|
3530
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3531
|
+
numBits++;
|
|
3532
|
+
}
|
|
3533
|
+
if (dictionary[c]) entry = dictionary[c];
|
|
3534
|
+
else if (c === dictSize) entry = w + w.charAt(0);
|
|
3535
|
+
else return null;
|
|
3536
|
+
result.push(entry);
|
|
3537
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
3538
|
+
enlargeIn--;
|
|
3539
|
+
w = entry;
|
|
3540
|
+
if (enlargeIn == 0) {
|
|
3541
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3542
|
+
numBits++;
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3124
3545
|
}
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
};
|
|
3131
|
-
scheduleTick();
|
|
3132
|
-
}
|
|
3133
|
-
function useDropTarget() {
|
|
3134
|
-
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
3135
|
-
const isDragAndDropEnabled = useIsDragAndDropEnabled();
|
|
3136
|
-
const targetSetter = n$1(() => setIsDropTarget(true), {
|
|
3137
|
-
triggerAt: "start",
|
|
3138
|
-
minQuietPeriodMs: 100
|
|
3546
|
+
};
|
|
3547
|
+
return LZString;
|
|
3548
|
+
})();
|
|
3549
|
+
if (typeof define === "function" && define.amd) define(function() {
|
|
3550
|
+
return LZString;
|
|
3139
3551
|
});
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3552
|
+
else if (typeof module !== "undefined" && module != null) module.exports = LZString;
|
|
3553
|
+
else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
|
|
3554
|
+
return LZString;
|
|
3143
3555
|
});
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
targetSetter.call();
|
|
3148
|
-
}
|
|
3149
|
-
function unsetTarget() {
|
|
3150
|
-
if (!isDragAndDropEnabled) return;
|
|
3151
|
-
targetSetter.cancel();
|
|
3152
|
-
targetUnsetter.call();
|
|
3153
|
-
}
|
|
3154
|
-
return {
|
|
3155
|
-
isDropTarget,
|
|
3156
|
-
setTarget,
|
|
3157
|
-
unsetTarget
|
|
3158
|
-
};
|
|
3159
|
-
}
|
|
3160
|
-
const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
|
|
3161
|
-
const useDraggingNode = draggingNodeEventFunctions.useValue;
|
|
3162
|
-
const setDraggingNode = draggingNodeEventFunctions.setValue;
|
|
3163
|
-
draggingNodeEventFunctions.addEventHandler;
|
|
3164
|
-
const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
|
|
3165
|
-
reducer: (_, newNode) => newNode,
|
|
3166
|
-
triggerAt: "start",
|
|
3167
|
-
minQuietPeriodMs: 100
|
|
3168
|
-
});
|
|
3169
|
-
const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
|
|
3170
|
-
triggerAt: "start",
|
|
3171
|
-
minQuietPeriodMs: 100
|
|
3172
|
-
});
|
|
3173
|
-
function setDragging(node) {
|
|
3174
|
-
draggingNodeUnsetter.cancel();
|
|
3175
|
-
draggingNodeSetter.call(node);
|
|
3176
|
-
}
|
|
3177
|
-
function unsetDragging() {
|
|
3178
|
-
draggingNodeSetter.cancel();
|
|
3179
|
-
draggingNodeUnsetter.call();
|
|
3180
|
-
}
|
|
3181
|
-
const isNodeDrag = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$1)(driveId), e$6(false)], [({ driveId, srcId }) => t(driveId, srcId), e$6(false)], e$6(true));
|
|
3182
|
-
function useDragNode(args) {
|
|
3183
|
-
const { srcId, parentId } = args;
|
|
3184
|
-
const driveId = useSelectedDriveId();
|
|
3185
|
-
const draggingNodeId = useDraggingNode()?.srcId;
|
|
3186
|
-
const params = {
|
|
3187
|
-
driveId,
|
|
3188
|
-
srcId,
|
|
3189
|
-
parentId
|
|
3190
|
-
};
|
|
3191
|
-
const draggable = isNodeDrag(params);
|
|
3192
|
-
const isDragging = t$4({
|
|
3193
|
-
srcId,
|
|
3194
|
-
draggingNodeId
|
|
3195
|
-
}, [
|
|
3196
|
-
() => draggable,
|
|
3197
|
-
({ srcId }) => e$2(srcId),
|
|
3198
|
-
({ draggingNodeId }) => e$2(draggingNodeId),
|
|
3199
|
-
({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
|
|
3200
|
-
]);
|
|
3201
|
-
const onDragStart = () => {
|
|
3202
|
-
if (!draggable) return;
|
|
3203
|
-
setDragging(params);
|
|
3204
|
-
};
|
|
3205
|
-
const onDragEnd = () => {
|
|
3206
|
-
if (!draggable) return;
|
|
3207
|
-
unsetDragging();
|
|
3208
|
-
};
|
|
3209
|
-
return {
|
|
3210
|
-
isDragging,
|
|
3211
|
-
draggable,
|
|
3212
|
-
onDragStart,
|
|
3213
|
-
onDragEnd
|
|
3214
|
-
};
|
|
3215
|
-
}
|
|
3216
|
-
const isNodeDrop = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$4)(driveId), e$6(false)], [({ srcId, targetId }) => t(srcId, targetId), e$6(false)], [({ driveId, parentId, targetId }) => e$3(e$1)(parentId) && t(targetId, driveId), e$6(false)], [({ targetId, parentId }) => t(targetId, parentId), e$6(false)], e$6(true));
|
|
3217
|
-
function useDropNode(targetId) {
|
|
3218
|
-
const driveId = useSelectedDriveId();
|
|
3219
|
-
const { srcId, parentId } = useDraggingNode() ?? {};
|
|
3220
|
-
const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
|
|
3221
|
-
const params = {
|
|
3222
|
-
driveId,
|
|
3223
|
-
parentId,
|
|
3224
|
-
targetId,
|
|
3225
|
-
srcId
|
|
3226
|
-
};
|
|
3227
|
-
function handleNodeDrop(event, cb) {
|
|
3228
|
-
if (!isNodeDrop(params)) return;
|
|
3229
|
-
event.preventDefault();
|
|
3230
|
-
event.stopPropagation();
|
|
3231
|
-
cb?.();
|
|
3232
|
-
}
|
|
3233
|
-
const onDragEnter = (event) => handleNodeDrop(event);
|
|
3234
|
-
const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
|
|
3235
|
-
const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
|
|
3236
|
-
const onDrop = (event) => handleNodeDrop(event, e(() => {
|
|
3237
|
-
unsetDragging();
|
|
3238
|
-
unsetTarget();
|
|
3239
|
-
moveNodeById(params).catch(console.error);
|
|
3240
|
-
}));
|
|
3241
|
-
return {
|
|
3242
|
-
isDropTarget,
|
|
3243
|
-
onDragEnter,
|
|
3244
|
-
onDragOver,
|
|
3245
|
-
onDragLeave,
|
|
3246
|
-
onDrop
|
|
3247
|
-
};
|
|
3248
|
-
}
|
|
3249
|
-
const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
|
|
3250
|
-
graphQLReactorClientEventFunctions.useValue;
|
|
3251
|
-
graphQLReactorClientEventFunctions.setValue;
|
|
3252
|
-
graphQLReactorClientEventFunctions.addEventHandler;
|
|
3253
|
-
const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
|
|
3254
|
-
packageDiscoveryFunctions.useValue;
|
|
3255
|
-
packageDiscoveryFunctions.setValue;
|
|
3256
|
-
packageDiscoveryFunctions.addEventHandler;
|
|
3257
|
-
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
3258
|
-
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
3259
|
-
/** Returns the reactor client module (in-process or worker-backed) */
|
|
3260
|
-
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
3261
|
-
reactorClientModuleEventFunctions.setValue;
|
|
3262
|
-
reactorClientModuleEventFunctions.addEventHandler;
|
|
3263
|
-
reactorClientEventFunctions.useValue;
|
|
3264
|
-
reactorClientEventFunctions.setValue;
|
|
3265
|
-
reactorClientEventFunctions.addEventHandler;
|
|
3266
|
-
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
3267
|
-
const useSyncList = () => {
|
|
3268
|
-
return useSync()?.list() ?? [];
|
|
3269
|
-
};
|
|
3270
|
-
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
3271
|
-
revisionHistoryEventFunctions.useValue;
|
|
3272
|
-
/** Sets revision history visibility */
|
|
3273
|
-
const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
|
|
3274
|
-
revisionHistoryEventFunctions.addEventHandler;
|
|
3275
|
-
/** Shows the revision history */
|
|
3276
|
-
function showRevisionHistory() {
|
|
3277
|
-
setRevisionHistoryVisible(true);
|
|
3278
|
-
}
|
|
3279
|
-
/** Sorts nodes by name. */
|
|
3280
|
-
function sortNodesByName(nodes) {
|
|
3281
|
-
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
3282
|
-
}
|
|
3283
|
-
/** Returns whether a node is a file. */
|
|
3284
|
-
function isFileNodeKind(node) {
|
|
3285
|
-
if (!node) return false;
|
|
3286
|
-
return node.kind.toUpperCase() === "FILE";
|
|
3287
|
-
}
|
|
3288
|
-
/** Returns whether a node is a folder. */
|
|
3289
|
-
function isFolderNodeKind(node) {
|
|
3290
|
-
if (!node) return false;
|
|
3291
|
-
return node.kind.toUpperCase() === "FOLDER";
|
|
3292
|
-
}
|
|
3293
|
-
/** Returns the nodes in the selected drive. */
|
|
3294
|
-
function useNodesInSelectedDrive() {
|
|
3295
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
3296
|
-
return selectedDrive?.state.global.nodes;
|
|
3297
|
-
}
|
|
3298
|
-
/** Returns the folder nodes in the selected drive. */
|
|
3299
|
-
function useFolderNodesInSelectedDrive() {
|
|
3300
|
-
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
3301
|
-
}
|
|
3302
|
-
/** Returns the selected node. */
|
|
3303
|
-
function useSelectedNode() {
|
|
3304
|
-
const selectedNodeId = useSelectedNodeId();
|
|
3305
|
-
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
3306
|
-
}
|
|
3307
|
-
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
3308
|
-
selectedTimelineItemEventFunctions.useValue;
|
|
3309
|
-
selectedTimelineItemEventFunctions.setValue;
|
|
3310
|
-
selectedTimelineItemEventFunctions.addEventHandler;
|
|
3311
|
-
const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
|
|
3312
|
-
selectedTimelineRevisionEventFunctions.useValue;
|
|
3313
|
-
selectedTimelineRevisionEventFunctions.setValue;
|
|
3314
|
-
selectedTimelineRevisionEventFunctions.addEventHandler;
|
|
3315
|
-
const toastEventFunctions = makePHEventFunctions("toast");
|
|
3316
|
-
/** Returns the toast function */
|
|
3317
|
-
const usePHToast = toastEventFunctions.useValue;
|
|
3318
|
-
toastEventFunctions.setValue;
|
|
3319
|
-
toastEventFunctions.addEventHandler;
|
|
3320
|
-
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
3321
|
-
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
3322
|
-
/** Returns all of the Vetra packages loaded by the Connect instance */
|
|
3323
|
-
const useVetraPackages = () => {
|
|
3324
|
-
const packageManager = useVetraPackageManager();
|
|
3325
|
-
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
3326
|
-
};
|
|
3327
|
-
vetraPackageManagerFunctions.addEventHandler;
|
|
3328
|
-
function useDocumentModelModules() {
|
|
3329
|
-
return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
|
|
3330
|
-
}
|
|
3331
|
-
function useDocumentModelModuleById(id) {
|
|
3332
|
-
return useDocumentModelModules()?.find((module) => module.documentModel.global.id === id);
|
|
3333
|
-
}
|
|
3556
|
+
})))(), 1);
|
|
3557
|
+
/** Document types that represent a "drive": a container of nodes. */
|
|
3558
|
+
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
3334
3559
|
function useAllowedDocumentModelModules() {
|
|
3335
3560
|
const documentModelModules = useDocumentModelModules();
|
|
3336
3561
|
const allowedDocumentTypes = useAllowedDocumentTypes();
|
|
@@ -3406,6 +3631,50 @@ function useDocumentOfType(documentId, documentType) {
|
|
|
3406
3631
|
if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(documentId, documentType, document.header.documentType);
|
|
3407
3632
|
return [document, dispatch];
|
|
3408
3633
|
}
|
|
3634
|
+
/**
|
|
3635
|
+
* Classifies a document's model version against the installed module
|
|
3636
|
+
* versions. Pure logic, extracted for testing.
|
|
3637
|
+
*/
|
|
3638
|
+
function getDocumentVersionStatus(documentVersion, availableVersions, hasUpgradePath) {
|
|
3639
|
+
if (availableVersions.length === 0) return;
|
|
3640
|
+
const sorted = [...availableVersions].sort((a, b) => a - b);
|
|
3641
|
+
const latestVersion = sorted[sorted.length - 1];
|
|
3642
|
+
if (documentVersion > latestVersion) return {
|
|
3643
|
+
kind: "unsupported",
|
|
3644
|
+
documentVersion,
|
|
3645
|
+
availableVersions: sorted
|
|
3646
|
+
};
|
|
3647
|
+
if (documentVersion === latestVersion) return {
|
|
3648
|
+
kind: "current",
|
|
3649
|
+
documentVersion
|
|
3650
|
+
};
|
|
3651
|
+
return {
|
|
3652
|
+
kind: "upgrade-available",
|
|
3653
|
+
documentVersion,
|
|
3654
|
+
latestVersion,
|
|
3655
|
+
canUpgrade: hasUpgradePath(documentVersion, latestVersion)
|
|
3656
|
+
};
|
|
3657
|
+
}
|
|
3658
|
+
/**
|
|
3659
|
+
* Compares the given document's model version against the versions available
|
|
3660
|
+
* from installed Vetra packages. Returns undefined while packages load or
|
|
3661
|
+
* when the document type has no installed modules.
|
|
3662
|
+
*/
|
|
3663
|
+
function useDocumentVersionStatus(document) {
|
|
3664
|
+
const modules = useDocumentModelModules();
|
|
3665
|
+
const registry = useModelRegistry();
|
|
3666
|
+
if (!document || !modules) return;
|
|
3667
|
+
const documentType = document.header.documentType;
|
|
3668
|
+
return getDocumentVersionStatus(document.state.document.version || 1, modules.filter((m) => m.documentModel.global.id === documentType).map((m) => m.version ?? 1), (fromVersion, toVersion) => {
|
|
3669
|
+
if (!registry) return false;
|
|
3670
|
+
try {
|
|
3671
|
+
registry.computeUpgradePath(documentType, fromVersion, toVersion);
|
|
3672
|
+
return true;
|
|
3673
|
+
} catch {
|
|
3674
|
+
return false;
|
|
3675
|
+
}
|
|
3676
|
+
});
|
|
3677
|
+
}
|
|
3409
3678
|
const validateDocument = (document) => {
|
|
3410
3679
|
const errors = [];
|
|
3411
3680
|
if (document.header.documentType !== "powerhouse/document-model") return errors;
|
|
@@ -3515,7 +3784,7 @@ function useNodeActions() {
|
|
|
3515
3784
|
}
|
|
3516
3785
|
async function onAddFolder(name, parent) {
|
|
3517
3786
|
if (!selectedDriveId) return;
|
|
3518
|
-
return addFolder(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
3787
|
+
return addFolder$1(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
3519
3788
|
}
|
|
3520
3789
|
async function onRenameNode(newName, node) {
|
|
3521
3790
|
if (!selectedDriveId) return;
|
|
@@ -3602,6 +3871,9 @@ function useSelectedNodePath() {
|
|
|
3602
3871
|
function useNodeParentFolderById(id) {
|
|
3603
3872
|
return useFolderById(useNodeById(id)?.parentFolder);
|
|
3604
3873
|
}
|
|
3874
|
+
function useParentFolderForSelectedNode() {
|
|
3875
|
+
return useNodeParentFolderById(useSelectedNode()?.id);
|
|
3876
|
+
}
|
|
3605
3877
|
/** Returns the selected document id */
|
|
3606
3878
|
function useSelectedDocumentId() {
|
|
3607
3879
|
const selectedNode = useSelectedNode();
|
|
@@ -3830,6 +4102,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
|
|
|
3830
4102
|
createDebouncedRefreshReactorData();
|
|
3831
4103
|
createDebouncedRefreshReactorDataClient();
|
|
3832
4104
|
//#endregion
|
|
3833
|
-
export {
|
|
4105
|
+
export { showRevisionHistory as A, t$2 as B, addFolder$1 as C, setSelectedNode as D, setSelectedDrive as E, useSelectedDriveId as F, useDocumentById as H, useSelectedDriveSafe as I, useStudioMode as L, useDragNode as M, useDropNode as N, showDeleteNodeModal as O, usePHToast as P, e$1 as R, addDocument as S, isFolderNodeKind as T, t$5 as V, useSelectedNodePath as _, useDownloadDocument as a, useTheme as b, useGetSwitchboardLink as c, useNodeParentFolderById as d, useNodesInSelectedDriveOrFolder as f, useSelectedFolder as g, useSelectedDocumentSafe as h, useDocumentVersionStatus as i, useDisabledEditors as j, showPHModal as k, useNodeActions as l, useSelectedDocumentOfType as m, preloadEditorModule as n, useEditorModules as o, useParentFolderForSelectedNode as p, useAllowedDocumentModelModules as r, useEditorModulesForDocumentType as s, getSyncStatusSync as t, useNodeById as u, useSetPHAppConfig as v, isFileNodeKind as w, useUserPermissions as x, useSetPHDocumentEditorConfig as y, e$4 as z };
|
|
3834
4106
|
|
|
3835
|
-
//# sourceMappingURL=dist-
|
|
4107
|
+
//# sourceMappingURL=dist-BIdl6Tbq.mjs.map
|