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