@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.7 → 6.2.2-dev.70
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-BBghrmE1.js} +3 -2
- package/dist/browser/assets/{projection-entry-DVec8YRh.js → projection-entry-BtmaPdIp.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-KEU-HR3o.js → connect-DmCpI0kg.js} +916 -200
- package/dist/browser/connect-DmCpI0kg.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-D5ra2aRj.js → dist-DfoAQf6g.js} +1617 -1293
- package/dist/browser/dist-DfoAQf6g.js.map +1 -0
- package/dist/browser/{document-drive-IdFV1QXL.js → document-drive-D6XhjHzr.js} +1184 -122
- package/dist/browser/document-drive-D6XhjHzr.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-C069kNOj.js +25 -0
- package/dist/browser/editor-C069kNOj.js.map +1 -0
- package/dist/browser/{editor-DiZF3ao3.js → editor-XlOiVjqp.js} +671 -236
- package/dist/browser/editor-XlOiVjqp.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-Cy-QxsDg.mjs → browser/folder-view-B4b9Ik-G.js} +73 -46
- package/dist/browser/folder-view-B4b9Ik-G.js.map +1 -0
- package/dist/browser/{graphql-editor-ZLRO_8Ce.js → graphql-editor-BDze7_wI.js} +8 -7
- package/dist/browser/{graphql-editor-ZLRO_8Ce.js.map → graphql-editor-BDze7_wI.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-DBuZ6gN7.js → json-editor-nI61gbA-.js} +4 -4
- package/dist/browser/{json-editor-DBuZ6gN7.js.map → json-editor-nI61gbA-.js.map} +1 -1
- package/dist/browser/{lib-C-f3izXz.js → lib-CE5V8jW5.js} +13 -4
- package/dist/browser/lib-CE5V8jW5.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-BjQKM498.js → state-schemas-DvpLHgMU.js} +8 -18
- package/dist/browser/state-schemas-DvpLHgMU.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-KcYZcy_Z.mjs → connect-BOwTtHRq.mjs} +916 -200
- package/dist/node/connect-BOwTtHRq.mjs.map +1 -0
- package/dist/node/{dist-DJEK2WVi.mjs → dist-CRrgpr8A.mjs} +1621 -1292
- package/dist/node/dist-CRrgpr8A.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-C8hbqQ3C.mjs → document-drive-B65n0lIk.mjs} +1184 -122
- package/dist/node/document-drive-B65n0lIk.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-B1KhoF1f.mjs → editor-BGcLm6LA.mjs} +672 -237
- package/dist/node/editor-BGcLm6LA.mjs.map +1 -0
- package/dist/node/editor-DIiXhhl2.mjs +25 -0
- package/dist/node/editor-DIiXhhl2.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-DMFqcJhc.js → node/folder-view-DyijTEeD.mjs} +73 -46
- package/dist/node/folder-view-DyijTEeD.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-C5VLRqEf.mjs → graphql-editor-5YU1uHpd.mjs} +7 -7
- package/dist/node/{graphql-editor-C5VLRqEf.mjs.map → graphql-editor-5YU1uHpd.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-iI2s9a_4.mjs → json-editor-iuJkZEgS.mjs} +4 -4
- package/dist/node/{json-editor-iI2s9a_4.mjs.map → json-editor-iuJkZEgS.mjs.map} +1 -1
- package/dist/node/{main-D82dkD7g.mjs → main-B5JSm6Hi.mjs} +15 -6
- package/dist/node/main-B5JSm6Hi.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-Bl7nA8bB.mjs → state-schemas-DHQAxfto.mjs} +10 -20
- package/dist/{browser/state-schemas-BjQKM498.js.map → node/state-schemas-DHQAxfto.mjs.map} +1 -1
- package/package.json +8 -7
- package/dist/browser/connect-KEU-HR3o.js.map +0 -1
- package/dist/browser/dist-D5ra2aRj.js.map +0 -1
- package/dist/browser/document-drive-IdFV1QXL.js.map +0 -1
- package/dist/browser/documents-D4ek7Ubv.js.map +0 -1
- package/dist/browser/editor-DiZF3ao3.js.map +0 -1
- package/dist/browser/editor-SqNULDP-.js +0 -29
- package/dist/browser/editor-SqNULDP-.js.map +0 -1
- package/dist/browser/folder-view-DMFqcJhc.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-KcYZcy_Z.mjs.map +0 -1
- package/dist/node/dist-DJEK2WVi.mjs.map +0 -1
- package/dist/node/document-drive-C8hbqQ3C.mjs.map +0 -1
- package/dist/node/editor-B1KhoF1f.mjs.map +0 -1
- package/dist/node/editor-yBGEvMGD.mjs +0 -29
- package/dist/node/editor-yBGEvMGD.mjs.map +0 -1
- package/dist/node/folder-view-Cy-QxsDg.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-Bl7nA8bB.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, C as baseSaveToFileHandle, D as createPresignedHeader, H as replayDocumentVersioned, S as baseLoadFromInputVersioned, Z as setName, a as handleTargetNameCollisions, at as validateInitialState, ct as generateId, f as logger, i as generateNodesCopy, l as moveNode, n as copyNode, o as isFileNode, ot as validateModules, s as isFolderNode, st as validateStateSchemaName, t as addFolder, u as updateNode, v as assertAuthPreservedOnDuplicate, w as buildSignedAction, x as baseLoadFromInput } from "./document-drive-D6XhjHzr.js";
|
|
3
|
+
import { a as SyncStatus, o as DriveCollectionId, s as ModuleNotFoundError, t as gql } from "./lib-CE5V8jW5.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-DB8gP4hz.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
|
|
@@ -441,6 +477,28 @@ gql`
|
|
|
441
477
|
}
|
|
442
478
|
}
|
|
443
479
|
`;
|
|
480
|
+
gql`
|
|
481
|
+
query EvaluateActions(
|
|
482
|
+
$documentIdentifier: String!
|
|
483
|
+
$branch: String
|
|
484
|
+
$candidates: [ActionCandidateInput!]!
|
|
485
|
+
) {
|
|
486
|
+
evaluateActions(
|
|
487
|
+
documentIdentifier: $documentIdentifier
|
|
488
|
+
branch: $branch
|
|
489
|
+
candidates: $candidates
|
|
490
|
+
) {
|
|
491
|
+
evaluations {
|
|
492
|
+
decision
|
|
493
|
+
reason
|
|
494
|
+
}
|
|
495
|
+
allAllowed
|
|
496
|
+
anyAllowed
|
|
497
|
+
allDenied
|
|
498
|
+
anyDenied
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
`;
|
|
444
502
|
gql`
|
|
445
503
|
mutation CreateDocument($document: JSONObject!, $parentIdentifier: String) {
|
|
446
504
|
createDocument(document: $document, parentIdentifier: $parentIdentifier) {
|
|
@@ -466,13 +524,13 @@ gql`
|
|
|
466
524
|
gql`
|
|
467
525
|
mutation MutateDocument(
|
|
468
526
|
$documentIdentifier: String!
|
|
469
|
-
$actions: [
|
|
470
|
-
$
|
|
527
|
+
$actions: [ActionInput!]!
|
|
528
|
+
$branch: String
|
|
471
529
|
) {
|
|
472
|
-
mutateDocument(
|
|
530
|
+
mutateDocument: execute(
|
|
473
531
|
documentIdentifier: $documentIdentifier
|
|
474
532
|
actions: $actions
|
|
475
|
-
|
|
533
|
+
branch: $branch
|
|
476
534
|
) {
|
|
477
535
|
...PHDocumentFields
|
|
478
536
|
}
|
|
@@ -482,14 +540,21 @@ gql`
|
|
|
482
540
|
gql`
|
|
483
541
|
mutation MutateDocumentAsync(
|
|
484
542
|
$documentIdentifier: String!
|
|
485
|
-
$actions: [
|
|
486
|
-
$
|
|
543
|
+
$actions: [ActionInput!]!
|
|
544
|
+
$branch: String
|
|
487
545
|
) {
|
|
488
|
-
mutateDocumentAsync(
|
|
546
|
+
mutateDocumentAsync: executeAsync(
|
|
489
547
|
documentIdentifier: $documentIdentifier
|
|
490
548
|
actions: $actions
|
|
491
|
-
|
|
492
|
-
)
|
|
549
|
+
branch: $branch
|
|
550
|
+
) {
|
|
551
|
+
id
|
|
552
|
+
status
|
|
553
|
+
result
|
|
554
|
+
error
|
|
555
|
+
createdAt
|
|
556
|
+
completedAt
|
|
557
|
+
}
|
|
493
558
|
}
|
|
494
559
|
`;
|
|
495
560
|
gql`
|
|
@@ -649,6 +714,7 @@ gql`
|
|
|
649
714
|
hash
|
|
650
715
|
skip
|
|
651
716
|
error
|
|
717
|
+
deniedReason
|
|
652
718
|
id
|
|
653
719
|
action {
|
|
654
720
|
id
|
|
@@ -691,6 +757,7 @@ gql`
|
|
|
691
757
|
deadLetters {
|
|
692
758
|
documentId
|
|
693
759
|
error
|
|
760
|
+
errorType
|
|
694
761
|
}
|
|
695
762
|
hasMore
|
|
696
763
|
}
|
|
@@ -737,51 +804,65 @@ function extractQueryParts(doc, fallbackBody) {
|
|
|
737
804
|
extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
|
|
738
805
|
extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
|
|
739
806
|
//#endregion
|
|
740
|
-
//#region ../reactor-browser/dist/renown-
|
|
807
|
+
//#region ../reactor-browser/dist/renown-6w_ImTvm.js
|
|
741
808
|
const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
|
|
809
|
+
const RenownInitialUserContext = createContext({ state: "unknown" });
|
|
810
|
+
/** First-render auth as a three-state value; use this to skip a spinner when anonymous. */
|
|
811
|
+
function useRenownInitialAuth() {
|
|
812
|
+
return useContext(RenownInitialUserContext);
|
|
813
|
+
}
|
|
814
|
+
function useRenownInitialUser() {
|
|
815
|
+
const initial = useRenownInitialAuth();
|
|
816
|
+
return initial.state === "authenticated" ? initial.user : void 0;
|
|
817
|
+
}
|
|
742
818
|
const renownEventFunctions = makePHEventFunctions("renown");
|
|
743
819
|
renownEventFunctions.addEventHandler;
|
|
744
820
|
/** Returns the renown instance */
|
|
745
821
|
const useRenown = renownEventFunctions.useValue;
|
|
746
822
|
renownEventFunctions.setValue;
|
|
823
|
+
function jsonEqual(a, b) {
|
|
824
|
+
if (a === b) return true;
|
|
825
|
+
if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
|
|
826
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
827
|
+
const ra = a;
|
|
828
|
+
const rb = b;
|
|
829
|
+
const keys = Object.keys(ra).filter((k) => ra[k] !== void 0);
|
|
830
|
+
if (keys.length !== Object.keys(rb).filter((k) => rb[k] !== void 0).length) return false;
|
|
831
|
+
return keys.every((k) => jsonEqual(ra[k], rb[k]));
|
|
832
|
+
}
|
|
833
|
+
function sameUser(a, b) {
|
|
834
|
+
return jsonEqual(a, b);
|
|
835
|
+
}
|
|
836
|
+
function resolveInstanceUser(instance, seed) {
|
|
837
|
+
const restored = instance.user;
|
|
838
|
+
if (restored) return sameUser(seed, restored) ? seed : restored;
|
|
839
|
+
return instance.status === "initial" ? void 0 : seed;
|
|
840
|
+
}
|
|
747
841
|
/** Returns the current user from the renown instance, subscribing to user events */
|
|
748
842
|
function useUser() {
|
|
749
843
|
const renown = useRenown();
|
|
750
|
-
const
|
|
844
|
+
const initialUser = useRenownInitialUser();
|
|
845
|
+
const instance = renown ? renown : void 0;
|
|
846
|
+
const [tracked, setTracked] = useState(() => ({
|
|
847
|
+
instance,
|
|
848
|
+
user: instance ? resolveInstanceUser(instance, initialUser) : initialUser
|
|
849
|
+
}));
|
|
850
|
+
const current = tracked.instance === instance ? tracked : {
|
|
851
|
+
instance,
|
|
852
|
+
user: instance ? resolveInstanceUser(instance, tracked.user ?? initialUser) : tracked.user
|
|
853
|
+
};
|
|
751
854
|
useEffect(() => {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
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;
|
|
855
|
+
if (current !== tracked) setTracked(current);
|
|
856
|
+
}, [current, tracked]);
|
|
857
|
+
useEffect(() => {
|
|
858
|
+
if (!instance) return;
|
|
859
|
+
return instance.on("user", (user) => setTracked((prev) => ({
|
|
860
|
+
instance,
|
|
861
|
+
user: sameUser(prev.user, user) ? prev.user : user
|
|
862
|
+
})));
|
|
863
|
+
}, [instance]);
|
|
864
|
+
return instance ? current.user : initialUser ?? current.user;
|
|
775
865
|
}
|
|
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
866
|
//#endregion
|
|
786
867
|
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
787
868
|
function e$8(e, t, n) {
|
|
@@ -906,6 +987,32 @@ function e(e) {
|
|
|
906
987
|
let t = !1, n;
|
|
907
988
|
return () => (t ||= (n = e(), !0), n);
|
|
908
989
|
}
|
|
990
|
+
var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
|
|
991
|
+
CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
|
|
992
|
+
CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
|
|
993
|
+
CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
|
|
994
|
+
CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
|
|
995
|
+
CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
|
|
996
|
+
CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
|
|
997
|
+
CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
|
|
998
|
+
CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
|
|
999
|
+
CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
|
|
1000
|
+
CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
|
|
1001
|
+
CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
|
|
1002
|
+
return CloseCode2;
|
|
1003
|
+
})(CloseCode || {});
|
|
1004
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
1005
|
+
MessageType2["ConnectionInit"] = "connection_init";
|
|
1006
|
+
MessageType2["ConnectionAck"] = "connection_ack";
|
|
1007
|
+
MessageType2["Ping"] = "ping";
|
|
1008
|
+
MessageType2["Pong"] = "pong";
|
|
1009
|
+
MessageType2["Subscribe"] = "subscribe";
|
|
1010
|
+
MessageType2["Next"] = "next";
|
|
1011
|
+
MessageType2["Error"] = "error";
|
|
1012
|
+
MessageType2["Complete"] = "complete";
|
|
1013
|
+
return MessageType2;
|
|
1014
|
+
})(MessageType || {});
|
|
1015
|
+
Error;
|
|
909
1016
|
//#endregion
|
|
910
1017
|
//#region ../../node_modules/.pnpm/slug@11.0.1/node_modules/slug/slug.js
|
|
911
1018
|
let base64;
|
|
@@ -1693,1065 +1800,513 @@ slug.setLocale = function(locale) {
|
|
|
1693
1800
|
defaultLocale = locales[locale] || {};
|
|
1694
1801
|
};
|
|
1695
1802
|
//#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;
|
|
1803
|
+
//#region ../reactor-browser/dist/document-operations-DQfMZpj8.js
|
|
1804
|
+
var DocumentModelNotFoundError = class extends Error {
|
|
1805
|
+
documentType;
|
|
1806
|
+
name = "DocumentModelNotFoundError";
|
|
1807
|
+
constructor(documentType) {
|
|
1808
|
+
super(`Document model module for type ${documentType} not found`);
|
|
1809
|
+
this.documentType = documentType;
|
|
1715
1810
|
}
|
|
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;
|
|
1811
|
+
static isError(error) {
|
|
1812
|
+
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
1766
1813
|
}
|
|
1767
1814
|
};
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
} catch {
|
|
1772
|
-
return false;
|
|
1815
|
+
var DocumentTypeMismatchError = class extends Error {
|
|
1816
|
+
constructor(documentId, expectedType, actualType) {
|
|
1817
|
+
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
1773
1818
|
}
|
|
1774
1819
|
};
|
|
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;
|
|
1820
|
+
var NoSelectedDocumentError = class extends Error {
|
|
1821
|
+
constructor() {
|
|
1822
|
+
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
1801
1823
|
}
|
|
1802
1824
|
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1825
|
+
const modalEventFunctions = makePHEventFunctions("modal");
|
|
1826
|
+
modalEventFunctions.useValue;
|
|
1827
|
+
/** Sets the current modal */
|
|
1828
|
+
const setPHModal = modalEventFunctions.setValue;
|
|
1829
|
+
modalEventFunctions.addEventHandler;
|
|
1830
|
+
/** Shows a modal */
|
|
1831
|
+
function showPHModal(modal) {
|
|
1832
|
+
setPHModal(modal);
|
|
1833
|
+
}
|
|
1834
|
+
/** Shows the delete node modal */
|
|
1835
|
+
function showDeleteNodeModal(nodeOrId) {
|
|
1836
|
+
setPHModal({
|
|
1837
|
+
type: "deleteItem",
|
|
1838
|
+
id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
function getUserPermissions() {
|
|
1842
|
+
const user = window.ph?.renown?.user;
|
|
1843
|
+
const allowList = window.ph?.allowList;
|
|
1844
|
+
if (!allowList) return {
|
|
1845
|
+
isAllowedToCreateDocuments: true,
|
|
1846
|
+
isAllowedToEditDocuments: true
|
|
1818
1847
|
};
|
|
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) => {
|
|
1848
|
+
return {
|
|
1849
|
+
isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
|
|
1850
|
+
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
1854
|
+
async function downloadFile(document, fileName) {
|
|
1845
1855
|
try {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1856
|
+
const data = await createZip(document);
|
|
1857
|
+
const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
|
|
1858
|
+
const link = window.document.createElement("a");
|
|
1859
|
+
link.style.display = "none";
|
|
1860
|
+
link.href = URL.createObjectURL(blob);
|
|
1861
|
+
link.download = fileName;
|
|
1862
|
+
window.document.body.appendChild(link);
|
|
1863
|
+
link.click();
|
|
1864
|
+
window.document.body.removeChild(link);
|
|
1865
|
+
} catch (e) {
|
|
1866
|
+
logger.error(e instanceof Error ? e.message : String(e));
|
|
1849
1867
|
}
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1868
|
+
}
|
|
1869
|
+
async function getDocumentExtension(document) {
|
|
1870
|
+
const documentType = document.header.documentType;
|
|
1871
|
+
let rawExtension;
|
|
1872
|
+
if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
|
|
1873
|
+
else {
|
|
1874
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
1875
|
+
if (reactorClient) {
|
|
1876
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
1877
|
+
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
1878
|
+
}
|
|
1856
1879
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
Object.
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1880
|
+
return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Fetches all operations for a document using cursor-based pagination.
|
|
1884
|
+
* The reactor client handles multi-scope cursors transparently via
|
|
1885
|
+
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
1886
|
+
*/
|
|
1887
|
+
async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
|
|
1888
|
+
const scopes = Object.keys(document.state);
|
|
1889
|
+
const operations = {};
|
|
1890
|
+
for (const scope of scopes) operations[scope] = [];
|
|
1891
|
+
let cursor = "";
|
|
1892
|
+
do {
|
|
1893
|
+
const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
|
|
1894
|
+
cursor,
|
|
1895
|
+
limit: pageSize
|
|
1896
|
+
});
|
|
1897
|
+
for (const op of page.results) {
|
|
1898
|
+
const scope = op.action.scope ?? "global";
|
|
1899
|
+
if (operations[scope]) operations[scope].push(op);
|
|
1900
|
+
}
|
|
1901
|
+
cursor = page.nextCursor ?? "";
|
|
1902
|
+
} while (cursor);
|
|
1903
|
+
return operations;
|
|
1904
|
+
}
|
|
1905
|
+
function extractInitialState(documentScopeOps) {
|
|
1906
|
+
const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
|
|
1907
|
+
if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
|
|
1908
|
+
const input = upgradeOp.action.input;
|
|
1909
|
+
const initialState = input.initialState ?? input.state;
|
|
1910
|
+
if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
|
|
1911
|
+
return initialState;
|
|
1912
|
+
}
|
|
1913
|
+
function filterDomainOperations(operations) {
|
|
1914
|
+
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
1915
|
+
}
|
|
1916
|
+
function countOperations(operations) {
|
|
1917
|
+
let total = 0;
|
|
1918
|
+
for (const ops of Object.values(operations)) total += ops?.length ?? 0;
|
|
1919
|
+
return total;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Split an imported document's domain operations at its mid-history upgrade
|
|
1923
|
+
* boundaries, so the caller can re-dispatch each upgrade between segments.
|
|
1924
|
+
*
|
|
1925
|
+
* The seed's CREATE_DOCUMENT and 0 -> N upgrade are replayed by the creation
|
|
1926
|
+
* path and must not be repeated. A later upgrade must be: it is where the
|
|
1927
|
+
* reducer version changes, and dropping it replays everything after it through
|
|
1928
|
+
* the module the document was created with.
|
|
1929
|
+
*/
|
|
1930
|
+
function splitAtUpgradeBoundaries(operations) {
|
|
1931
|
+
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);
|
|
1932
|
+
const domain = filterDomainOperations(operations);
|
|
1933
|
+
if (upgrades.length === 0) return [{ operations: domain }];
|
|
1934
|
+
const segments = [];
|
|
1935
|
+
const consumed = /* @__PURE__ */ new Map();
|
|
1936
|
+
const take = (until) => {
|
|
1937
|
+
const slice = {};
|
|
1938
|
+
for (const [scope, ops] of Object.entries(domain)) {
|
|
1939
|
+
if (!ops) continue;
|
|
1940
|
+
const from = consumed.get(scope) ?? 0;
|
|
1941
|
+
const stop = Math.max(from, until(scope, ops));
|
|
1942
|
+
const chunk = ops.slice(from, stop);
|
|
1943
|
+
if (chunk.length > 0) slice[scope] = chunk;
|
|
1944
|
+
consumed.set(scope, stop);
|
|
1945
|
+
}
|
|
1946
|
+
return slice;
|
|
1947
|
+
};
|
|
1948
|
+
for (const upgrade of upgrades) {
|
|
1949
|
+
const input = upgrade.action.input;
|
|
1950
|
+
const slice = take((scope, ops) => boundary(upgrade, scope, ops));
|
|
1951
|
+
segments.push({
|
|
1952
|
+
operations: slice,
|
|
1953
|
+
upgradeTo: input.toVersion
|
|
1954
|
+
});
|
|
1882
1955
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1956
|
+
const tail = take((_scope, ops) => ops.length);
|
|
1957
|
+
if (countOperations(tail) > 0) segments.push({ operations: tail });
|
|
1958
|
+
return segments;
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* How many of a scope's operations precede an upgrade. Must stay identical to
|
|
1962
|
+
* the boundary computation in `replayDocumentVersioned` — snapshots compare
|
|
1963
|
+
* against operation indices, not array positions, and the timestamp fallback
|
|
1964
|
+
* excludes the upgrade's own instant.
|
|
1965
|
+
*/
|
|
1966
|
+
function boundary(upgrade, scope, ops) {
|
|
1967
|
+
const snapshot = upgrade.action.input.revision;
|
|
1968
|
+
if (snapshot !== void 0) {
|
|
1969
|
+
const revision = snapshot[scope] ?? 0;
|
|
1970
|
+
let count = 0;
|
|
1971
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].index < revision) count = i + 1;
|
|
1972
|
+
return count;
|
|
1889
1973
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
if (
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
const assignObjectProps = (error, object) => {
|
|
1908
|
-
for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
|
|
1909
|
-
};
|
|
1910
|
-
const setNewErrorProperty = (error, propName, propValue) => {
|
|
1911
|
-
if (propValue !== void 0) setErrorProperty(error, propName, propValue);
|
|
1912
|
-
};
|
|
1913
|
-
//#endregion
|
|
1914
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
|
|
1915
|
-
const stringifyError = (value) => {
|
|
1974
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].timestampUtcMs >= upgrade.timestampUtcMs) return i;
|
|
1975
|
+
return ops.length;
|
|
1976
|
+
}
|
|
1977
|
+
async function exportFile(document, suggestedName) {
|
|
1978
|
+
const reactorClient = window.ph?.reactorClient;
|
|
1979
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1980
|
+
const operations = await fetchDocumentOperations(reactorClient, document);
|
|
1981
|
+
const initialState = extractInitialState(operations["document"] ?? []);
|
|
1982
|
+
const documentWithOps = {
|
|
1983
|
+
...document,
|
|
1984
|
+
operations,
|
|
1985
|
+
initialState
|
|
1986
|
+
};
|
|
1987
|
+
const extension = await getDocumentExtension(documentWithOps);
|
|
1988
|
+
const baseName = suggestedName || documentWithOps.header.name || "Untitled";
|
|
1989
|
+
const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
|
|
1990
|
+
if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
|
|
1916
1991
|
try {
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
return
|
|
1920
|
-
} catch (
|
|
1921
|
-
|
|
1992
|
+
const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
|
|
1993
|
+
await baseSaveToFileHandle(documentWithOps, fileHandle);
|
|
1994
|
+
return fileHandle;
|
|
1995
|
+
} catch (e) {
|
|
1996
|
+
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
1922
1997
|
}
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Loads a document file and replays it with version-aware reducers from the registry.
|
|
2001
|
+
* Falls back to single-version legacy replay when no upgrade manifest is registered for
|
|
2002
|
+
* the document type.
|
|
2003
|
+
*/
|
|
2004
|
+
async function loadFile(path) {
|
|
2005
|
+
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
2006
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2007
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2008
|
+
const documentType = baseDocument.header.documentType;
|
|
2009
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2010
|
+
const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
|
|
2011
|
+
if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
|
|
2012
|
+
const reducers = {};
|
|
2013
|
+
for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
|
|
2014
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2015
|
+
let upgradeManifest;
|
|
2016
|
+
if (registry) try {
|
|
2017
|
+
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
2018
|
+
} catch {}
|
|
2019
|
+
return baseLoadFromInputVersioned(path, {
|
|
2020
|
+
reducers,
|
|
2021
|
+
upgradeManifest
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
2025
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2026
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
2027
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2028
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2029
|
+
let documentModelModule;
|
|
2030
|
+
if (documentModelVersion !== void 0) {
|
|
2031
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2032
|
+
const module = documentModelModules.find((m) => m.documentModel.global.id === documentType && (m.version ?? 1) === documentModelVersion);
|
|
2033
|
+
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
2034
|
+
documentModelModule = module;
|
|
2035
|
+
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
2036
|
+
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
2037
|
+
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
2038
|
+
newDocument.header.name = name;
|
|
2039
|
+
if (preferredEditor) newDocument.header.meta = {
|
|
2040
|
+
...newDocument.header.meta,
|
|
2041
|
+
preferredEditor
|
|
2042
|
+
};
|
|
2043
|
+
let newDoc;
|
|
1934
2044
|
try {
|
|
1935
|
-
|
|
1936
|
-
} catch {
|
|
1937
|
-
|
|
2045
|
+
newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
|
|
2046
|
+
} catch (e) {
|
|
2047
|
+
logger.error("Error adding document: @error", e);
|
|
2048
|
+
throw new Error("There was an error adding document", { cause: e });
|
|
1938
2049
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2050
|
+
return {
|
|
2051
|
+
id: newDoc.header.id,
|
|
2052
|
+
name: newDoc.header.name,
|
|
2053
|
+
documentType,
|
|
2054
|
+
parentFolder: parentFolder ?? null,
|
|
2055
|
+
kind: "file"
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
async function addFile(file, driveId, name, parentFolder) {
|
|
2059
|
+
logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
2060
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2061
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
|
|
2062
|
+
const document = await loadFile(file);
|
|
2063
|
+
let duplicateId = false;
|
|
2064
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2065
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
1942
2066
|
try {
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2067
|
+
await reactorClient.get(document.header.id);
|
|
2068
|
+
duplicateId = true;
|
|
2069
|
+
} catch {}
|
|
2070
|
+
const documentId = duplicateId ? generateId() : document.header.id;
|
|
2071
|
+
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
2072
|
+
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
2073
|
+
header.meta = document.header.meta;
|
|
2074
|
+
header.name = name || document.header.name;
|
|
2075
|
+
const initialDocument = {
|
|
2076
|
+
...document,
|
|
2077
|
+
header,
|
|
2078
|
+
state: document.initialState,
|
|
2079
|
+
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
2080
|
+
acc[key] = [];
|
|
2081
|
+
return acc;
|
|
2082
|
+
}, {})
|
|
2083
|
+
};
|
|
2084
|
+
await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
2085
|
+
for (const segment of splitAtUpgradeBoundaries(document.operations)) {
|
|
2086
|
+
await uploadOperations(documentId, segment.operations, queueOperations);
|
|
2087
|
+
if (segment.upgradeTo !== void 0) await upgradeDocument(documentId, segment.upgradeTo);
|
|
1946
2088
|
}
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
const
|
|
1955
|
-
const
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2089
|
+
}
|
|
2090
|
+
async function addFolder$1(driveId, name, parentFolder) {
|
|
2091
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2092
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
2093
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2094
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2095
|
+
await reactorClient.get(driveId);
|
|
2096
|
+
const folderId = generateId();
|
|
2097
|
+
const node = (await reactorClient.execute(driveId, "main", [addFolder({
|
|
2098
|
+
id: folderId,
|
|
2099
|
+
name,
|
|
2100
|
+
parentFolder
|
|
2101
|
+
})])).state.global.nodes.find((node) => node.id === folderId);
|
|
2102
|
+
if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
|
|
2103
|
+
return node;
|
|
2104
|
+
}
|
|
2105
|
+
async function renameNode(driveId, nodeId, name) {
|
|
2106
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2107
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
2108
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2109
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2110
|
+
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
2111
|
+
const node = (await reactorClient.execute(driveId, "main", [updateNode({
|
|
2112
|
+
id: nodeId,
|
|
2113
|
+
name
|
|
2114
|
+
})])).state.global.nodes.find((n) => n.id === nodeId);
|
|
2115
|
+
if (!node) throw new Error("There was an error renaming node in the drive");
|
|
2116
|
+
return node;
|
|
2117
|
+
}
|
|
2118
|
+
async function renameDriveNode(driveId, nodeId, name) {
|
|
2119
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2120
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
2121
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2122
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2123
|
+
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
2124
|
+
await reactorClient.execute(driveId, "main", [updateNode({
|
|
2125
|
+
id: nodeId,
|
|
2126
|
+
name
|
|
2127
|
+
})]);
|
|
2128
|
+
return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
|
|
2129
|
+
}
|
|
2130
|
+
async function moveNodeById(args) {
|
|
2131
|
+
const { driveId, srcId, targetId } = args;
|
|
2132
|
+
if (!driveId || !srcId) return;
|
|
2133
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2134
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
2135
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2136
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2137
|
+
const targetParentFolder = t$3(targetId, [e$3(e$4), e$6(void 0)], [t(driveId), e$6(void 0)], e$6(targetId));
|
|
2138
|
+
if (t(targetParentFolder, srcId)) return;
|
|
2139
|
+
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
2140
|
+
srcFolder: srcId,
|
|
2141
|
+
targetParentFolder
|
|
2142
|
+
})]);
|
|
2143
|
+
}
|
|
2144
|
+
async function moveNode$1(driveId, src, target) {
|
|
2145
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2146
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
2147
|
+
const reactorClient = window.ph?.reactorClient;
|
|
2148
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2149
|
+
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
2150
|
+
srcFolder: src.id,
|
|
2151
|
+
targetParentFolder: target?.id
|
|
2152
|
+
})]);
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* Duplicates a document under a new id using version-aware replay.
|
|
2156
|
+
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
2157
|
+
*/
|
|
2158
|
+
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
2159
|
+
const documentType = document.header.documentType;
|
|
2160
|
+
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
2161
|
+
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
2162
|
+
const reducers = {};
|
|
2163
|
+
for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
|
|
2164
|
+
if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
|
|
2165
|
+
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2166
|
+
let upgradeManifest;
|
|
2167
|
+
if (registry) try {
|
|
2168
|
+
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
2169
|
+
} catch {}
|
|
2170
|
+
const config = {
|
|
2171
|
+
reducers,
|
|
2172
|
+
upgradeManifest
|
|
2173
|
+
};
|
|
2174
|
+
const header = createPresignedHeader(newId, documentType);
|
|
2175
|
+
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
2176
|
+
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
2177
|
+
return duplicated;
|
|
2178
|
+
}
|
|
2179
|
+
async function copyNode$1(driveId, src, target) {
|
|
2180
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
2181
|
+
if (!reactor) return;
|
|
2182
|
+
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2183
|
+
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
2184
|
+
const drive = await reactor.get(driveId);
|
|
2185
|
+
const copyNodesInput = generateNodesCopy({
|
|
2186
|
+
srcId: src.id,
|
|
2187
|
+
targetParentFolder: target?.id,
|
|
2188
|
+
targetName: src.name
|
|
2189
|
+
}, () => generateId(), drive.state.global.nodes);
|
|
2190
|
+
const resolvedNamesMap = /* @__PURE__ */ new Map();
|
|
2191
|
+
for (const copyNodeInput of copyNodesInput) {
|
|
2192
|
+
const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
|
|
2193
|
+
if (node) {
|
|
2194
|
+
const resolvedName = handleTargetNameCollisions({
|
|
2195
|
+
nodes: drive.state.global.nodes,
|
|
2196
|
+
srcName: copyNodeInput.targetName || node.name,
|
|
2197
|
+
srcKind: isFileNode(node) ? "file" : "folder",
|
|
2198
|
+
targetParentFolder: copyNodeInput.targetParentFolder || null
|
|
2199
|
+
});
|
|
2200
|
+
resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
|
|
1994
2201
|
}
|
|
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
2202
|
}
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
};
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
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);
|
|
2203
|
+
const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
|
|
2204
|
+
const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
|
|
2205
|
+
return node !== void 0 && isFileNode(node);
|
|
2206
|
+
});
|
|
2207
|
+
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
2208
|
+
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
2209
|
+
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
2210
|
+
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
2211
|
+
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
2430
2212
|
} catch (e) {
|
|
2431
|
-
logger.error(
|
|
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
|
-
}
|
|
2213
|
+
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
2444
2214
|
}
|
|
2445
|
-
return (
|
|
2215
|
+
return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
|
|
2446
2216
|
}
|
|
2447
2217
|
/**
|
|
2448
|
-
*
|
|
2449
|
-
*
|
|
2450
|
-
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
2218
|
+
* Upgrades a document to a newer document model version. Defaults to the
|
|
2219
|
+
* latest registered version for the document's type.
|
|
2451
2220
|
*/
|
|
2452
|
-
async function
|
|
2453
|
-
const
|
|
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;
|
|
2221
|
+
async function upgradeDocument(documentId, toVersion) {
|
|
2222
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2483
2223
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2484
|
-
|
|
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
|
-
}
|
|
2224
|
+
return reactorClient.upgradeDocument(documentId, toVersion);
|
|
2502
2225
|
}
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2226
|
+
gql`
|
|
2227
|
+
mutation MutateDocumentWithOperations(
|
|
2228
|
+
$documentIdentifier: String!
|
|
2229
|
+
$actions: [ActionInput!]!
|
|
2230
|
+
$sinceRevision: Int
|
|
2231
|
+
$scopes: [String!]
|
|
2232
|
+
$branch: String
|
|
2233
|
+
) {
|
|
2234
|
+
mutateDocument: execute(
|
|
2235
|
+
documentIdentifier: $documentIdentifier
|
|
2236
|
+
actions: $actions
|
|
2237
|
+
branch: $branch
|
|
2238
|
+
) {
|
|
2239
|
+
...PHDocumentFields
|
|
2240
|
+
operations(
|
|
2241
|
+
filter: {
|
|
2242
|
+
sinceRevision: $sinceRevision
|
|
2243
|
+
scopes: $scopes
|
|
2244
|
+
branch: $branch
|
|
2245
|
+
}
|
|
2246
|
+
) {
|
|
2247
|
+
items {
|
|
2248
|
+
...ReactorOperationFields
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
${PhDocumentFieldsFragmentDoc}
|
|
2254
|
+
${gql`
|
|
2255
|
+
fragment ReactorOperationFields on ReactorOperation {
|
|
2256
|
+
index
|
|
2257
|
+
timestampUtcMs
|
|
2258
|
+
hash
|
|
2259
|
+
skip
|
|
2260
|
+
error
|
|
2261
|
+
deniedReason
|
|
2262
|
+
id
|
|
2263
|
+
action {
|
|
2264
|
+
id
|
|
2265
|
+
type
|
|
2266
|
+
timestampUtcMs
|
|
2267
|
+
input
|
|
2268
|
+
scope
|
|
2269
|
+
context {
|
|
2270
|
+
signer {
|
|
2271
|
+
user {
|
|
2272
|
+
address
|
|
2273
|
+
networkId
|
|
2274
|
+
chainId
|
|
2275
|
+
}
|
|
2276
|
+
app {
|
|
2277
|
+
name
|
|
2278
|
+
key
|
|
2279
|
+
}
|
|
2280
|
+
signatures
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
`}
|
|
2286
|
+
`;
|
|
2287
|
+
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;
|
|
2288
|
+
PropagationMode.Cascade, PropagationMode.Orphan;
|
|
2289
|
+
const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
2290
|
+
/** Sets whether external controls are enabled for a given editor. */
|
|
2291
|
+
const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
2292
|
+
/** Gets whether external controls are enabled for a given editor. */
|
|
2293
|
+
const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
|
|
2294
|
+
isExternalControlsEnabledEventFunctions.addEventHandler;
|
|
2295
|
+
const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
|
|
2296
|
+
/** Sets whether drag and drop is enabled for a given app. */
|
|
2297
|
+
const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
|
|
2298
|
+
/** Gets whether drag and drop is enabled for a given app. */
|
|
2299
|
+
const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
|
|
2300
|
+
isDragAndDropEnabledEventFunctions.addEventHandler;
|
|
2301
|
+
const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
|
|
2302
|
+
/** Sets the allowed document types for a given app. */
|
|
2303
|
+
const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
|
|
2304
|
+
/** Defines the document types a drive supports.
|
|
2305
|
+
*
|
|
2306
|
+
* Defaults to all of the document types registered in the reactor.
|
|
2507
2307
|
*/
|
|
2508
|
-
|
|
2509
|
-
|
|
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
|
-
}
|
|
2584
|
-
async function addFolder(driveId, name, parentFolder) {
|
|
2585
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2586
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
2587
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2588
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2589
|
-
await reactorClient.get(driveId);
|
|
2590
|
-
const folderId = generateId();
|
|
2591
|
-
const node = (await reactorClient.execute(driveId, "main", [addFolder$1({
|
|
2592
|
-
id: folderId,
|
|
2593
|
-
name,
|
|
2594
|
-
parentFolder
|
|
2595
|
-
})])).state.global.nodes.find((node) => node.id === folderId);
|
|
2596
|
-
if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
|
|
2597
|
-
return node;
|
|
2598
|
-
}
|
|
2599
|
-
async function renameNode(driveId, nodeId, name) {
|
|
2600
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2601
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
2602
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2603
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2604
|
-
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
2605
|
-
const node = (await reactorClient.execute(driveId, "main", [updateNode({
|
|
2606
|
-
id: nodeId,
|
|
2607
|
-
name
|
|
2608
|
-
})])).state.global.nodes.find((n) => n.id === nodeId);
|
|
2609
|
-
if (!node) throw new Error("There was an error renaming node in the drive");
|
|
2610
|
-
return node;
|
|
2611
|
-
}
|
|
2612
|
-
async function renameDriveNode(driveId, nodeId, name) {
|
|
2613
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2614
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
2615
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2616
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2617
|
-
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
2618
|
-
await reactorClient.execute(driveId, "main", [updateNode({
|
|
2619
|
-
id: nodeId,
|
|
2620
|
-
name
|
|
2621
|
-
})]);
|
|
2622
|
-
return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
|
|
2623
|
-
}
|
|
2624
|
-
async function moveNodeById(args) {
|
|
2625
|
-
const { driveId, srcId, targetId } = args;
|
|
2626
|
-
if (!driveId || !srcId) return;
|
|
2627
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2628
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
2629
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2630
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2631
|
-
const targetParentFolder = t$3(targetId, [e$3(e$4), e$6(void 0)], [t(driveId), e$6(void 0)], e$6(targetId));
|
|
2632
|
-
if (t(targetParentFolder, srcId)) return;
|
|
2633
|
-
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
2634
|
-
srcFolder: srcId,
|
|
2635
|
-
targetParentFolder
|
|
2636
|
-
})]);
|
|
2637
|
-
}
|
|
2638
|
-
async function moveNode$1(driveId, src, target) {
|
|
2639
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2640
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
2641
|
-
const reactorClient = window.ph?.reactorClient;
|
|
2642
|
-
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2643
|
-
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
2644
|
-
srcFolder: src.id,
|
|
2645
|
-
targetParentFolder: target?.id
|
|
2646
|
-
})]);
|
|
2647
|
-
}
|
|
2648
|
-
/**
|
|
2649
|
-
* Duplicates a document under a new id using version-aware replay.
|
|
2650
|
-
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
2651
|
-
*/
|
|
2652
|
-
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
2653
|
-
const documentType = document.header.documentType;
|
|
2654
|
-
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
2655
|
-
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
2656
|
-
const reducers = {};
|
|
2657
|
-
for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
|
|
2658
|
-
if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
|
|
2659
|
-
const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
2660
|
-
let upgradeManifest;
|
|
2661
|
-
if (registry) try {
|
|
2662
|
-
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
2663
|
-
} catch {}
|
|
2664
|
-
const config = {
|
|
2665
|
-
reducers,
|
|
2666
|
-
upgradeManifest
|
|
2667
|
-
};
|
|
2668
|
-
const header = createPresignedHeader(newId, documentType);
|
|
2669
|
-
return replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
2670
|
-
}
|
|
2671
|
-
async function copyNode$1(driveId, src, target) {
|
|
2672
|
-
const reactor = window.ph?.reactorClient;
|
|
2673
|
-
if (!reactor) return;
|
|
2674
|
-
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2675
|
-
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
2676
|
-
const drive = await reactor.get(driveId);
|
|
2677
|
-
const copyNodesInput = generateNodesCopy({
|
|
2678
|
-
srcId: src.id,
|
|
2679
|
-
targetParentFolder: target?.id,
|
|
2680
|
-
targetName: src.name
|
|
2681
|
-
}, () => generateId(), drive.state.global.nodes);
|
|
2682
|
-
const resolvedNamesMap = /* @__PURE__ */ new Map();
|
|
2683
|
-
for (const copyNodeInput of copyNodesInput) {
|
|
2684
|
-
const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
|
|
2685
|
-
if (node) {
|
|
2686
|
-
const resolvedName = handleTargetNameCollisions({
|
|
2687
|
-
nodes: drive.state.global.nodes,
|
|
2688
|
-
srcName: copyNodeInput.targetName || node.name,
|
|
2689
|
-
srcKind: isFileNode(node) ? "file" : "folder",
|
|
2690
|
-
targetParentFolder: copyNodeInput.targetParentFolder || null
|
|
2691
|
-
});
|
|
2692
|
-
resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
|
|
2696
|
-
const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
|
|
2697
|
-
return node !== void 0 && isFileNode(node);
|
|
2698
|
-
});
|
|
2699
|
-
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
2700
|
-
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
2701
|
-
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
2702
|
-
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
2703
|
-
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
2704
|
-
} catch (e) {
|
|
2705
|
-
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
2706
|
-
}
|
|
2707
|
-
return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
|
|
2708
|
-
}
|
|
2709
|
-
const modalEventFunctions = makePHEventFunctions("modal");
|
|
2710
|
-
modalEventFunctions.useValue;
|
|
2711
|
-
/** Sets the current modal */
|
|
2712
|
-
const setPHModal = modalEventFunctions.setValue;
|
|
2713
|
-
modalEventFunctions.addEventHandler;
|
|
2714
|
-
/** Shows a modal */
|
|
2715
|
-
function showPHModal(modal) {
|
|
2716
|
-
setPHModal(modal);
|
|
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
|
-
});
|
|
2731
|
-
}
|
|
2732
|
-
/** Document types that represent a "drive": a container of nodes. */
|
|
2733
|
-
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
2734
|
-
const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
2735
|
-
/** Sets whether external controls are enabled for a given editor. */
|
|
2736
|
-
const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
2737
|
-
/** Gets whether external controls are enabled for a given editor. */
|
|
2738
|
-
const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
|
|
2739
|
-
isExternalControlsEnabledEventFunctions.addEventHandler;
|
|
2740
|
-
const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
|
|
2741
|
-
/** Sets whether drag and drop is enabled for a given app. */
|
|
2742
|
-
const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
|
|
2743
|
-
/** Gets whether drag and drop is enabled for a given app. */
|
|
2744
|
-
const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
|
|
2745
|
-
isDragAndDropEnabledEventFunctions.addEventHandler;
|
|
2746
|
-
const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
|
|
2747
|
-
/** Sets the allowed document types for a given app. */
|
|
2748
|
-
const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
|
|
2749
|
-
/** Defines the document types a drive supports.
|
|
2750
|
-
*
|
|
2751
|
-
* Defaults to all of the document types registered in the reactor.
|
|
2752
|
-
*/
|
|
2753
|
-
function useAllowedDocumentTypes() {
|
|
2754
|
-
return allowedDocumentTypesEventFunctions.useValue();
|
|
2308
|
+
function useAllowedDocumentTypes() {
|
|
2309
|
+
return allowedDocumentTypesEventFunctions.useValue();
|
|
2755
2310
|
}
|
|
2756
2311
|
allowedDocumentTypesEventFunctions.addEventHandler;
|
|
2757
2312
|
const phAppConfigSetters = {
|
|
@@ -2796,6 +2351,8 @@ const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabl
|
|
|
2796
2351
|
const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
|
|
2797
2352
|
const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
|
|
2798
2353
|
const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
|
|
2354
|
+
const { useValue: useSwitchboardUrl, setValue: setSwitchboardUrl, addEventHandler: addSwitchboardUrlEventHandler } = makePHEventFunctions("switchboardUrl");
|
|
2355
|
+
const { useValue: useRenownAdapters, setValue: setRenownAdapters, addEventHandler: addRenownAdaptersEventHandler } = makePHEventFunctions("renownAdapters");
|
|
2799
2356
|
const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
|
|
2800
2357
|
const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
|
|
2801
2358
|
const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
|
|
@@ -2893,6 +2450,8 @@ const nonUserConfigSetters = {
|
|
|
2893
2450
|
renownUrl: setRenownUrl,
|
|
2894
2451
|
renownNetworkId: setRenownNetworkId,
|
|
2895
2452
|
renownChainId: setRenownChainId,
|
|
2453
|
+
switchboardUrl: setSwitchboardUrl,
|
|
2454
|
+
renownAdapters: setRenownAdapters,
|
|
2896
2455
|
sentryRelease: setSentryRelease,
|
|
2897
2456
|
sentryDsn: setSentryDsn,
|
|
2898
2457
|
sentryEnv: setSentryEnv,
|
|
@@ -2941,6 +2500,8 @@ const nonUserConfigHooks = {
|
|
|
2941
2500
|
renownUrl: useRenownUrl,
|
|
2942
2501
|
renownNetworkId: useRenownNetworkId,
|
|
2943
2502
|
renownChainId: useRenownChainId,
|
|
2503
|
+
switchboardUrl: useSwitchboardUrl,
|
|
2504
|
+
renownAdapters: useRenownAdapters,
|
|
2944
2505
|
sentryRelease: useSentryRelease,
|
|
2945
2506
|
sentryDsn: useSentryDsn,
|
|
2946
2507
|
sentryEnv: useSentryEnv,
|
|
@@ -3121,215 +2682,931 @@ function deferDriveSelection(driveSlug) {
|
|
|
3121
2682
|
scheduleTick();
|
|
3122
2683
|
return;
|
|
3123
2684
|
}
|
|
3124
|
-
cancelPendingDriveSelection();
|
|
3125
|
-
const pathname = resolveUrlPathname("/");
|
|
3126
|
-
if (pathname === window.location.pathname) return;
|
|
3127
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
3128
|
-
}, DEFERRED_DRIVE_TICK_MS);
|
|
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
|
|
2685
|
+
cancelPendingDriveSelection();
|
|
2686
|
+
const pathname = resolveUrlPathname("/");
|
|
2687
|
+
if (pathname === window.location.pathname) return;
|
|
2688
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
2689
|
+
}, DEFERRED_DRIVE_TICK_MS);
|
|
2690
|
+
};
|
|
2691
|
+
scheduleTick();
|
|
2692
|
+
}
|
|
2693
|
+
function useDropTarget() {
|
|
2694
|
+
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
2695
|
+
const isDragAndDropEnabled = useIsDragAndDropEnabled();
|
|
2696
|
+
const targetSetter = n$1(() => setIsDropTarget(true), {
|
|
2697
|
+
triggerAt: "start",
|
|
2698
|
+
minQuietPeriodMs: 100
|
|
2699
|
+
});
|
|
2700
|
+
const targetUnsetter = n$1(() => setIsDropTarget(false), {
|
|
2701
|
+
triggerAt: "start",
|
|
2702
|
+
minQuietPeriodMs: 100
|
|
2703
|
+
});
|
|
2704
|
+
function setTarget() {
|
|
2705
|
+
if (!isDragAndDropEnabled) return;
|
|
2706
|
+
targetUnsetter.cancel();
|
|
2707
|
+
targetSetter.call();
|
|
2708
|
+
}
|
|
2709
|
+
function unsetTarget() {
|
|
2710
|
+
if (!isDragAndDropEnabled) return;
|
|
2711
|
+
targetSetter.cancel();
|
|
2712
|
+
targetUnsetter.call();
|
|
2713
|
+
}
|
|
2714
|
+
return {
|
|
2715
|
+
isDropTarget,
|
|
2716
|
+
setTarget,
|
|
2717
|
+
unsetTarget
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
|
|
2721
|
+
const useDraggingNode = draggingNodeEventFunctions.useValue;
|
|
2722
|
+
const setDraggingNode = draggingNodeEventFunctions.setValue;
|
|
2723
|
+
draggingNodeEventFunctions.addEventHandler;
|
|
2724
|
+
const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
|
|
2725
|
+
reducer: (_, newNode) => newNode,
|
|
2726
|
+
triggerAt: "start",
|
|
2727
|
+
minQuietPeriodMs: 100
|
|
2728
|
+
});
|
|
2729
|
+
const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
|
|
2730
|
+
triggerAt: "start",
|
|
2731
|
+
minQuietPeriodMs: 100
|
|
2732
|
+
});
|
|
2733
|
+
function setDragging(node) {
|
|
2734
|
+
draggingNodeUnsetter.cancel();
|
|
2735
|
+
draggingNodeSetter.call(node);
|
|
2736
|
+
}
|
|
2737
|
+
function unsetDragging() {
|
|
2738
|
+
draggingNodeSetter.cancel();
|
|
2739
|
+
draggingNodeUnsetter.call();
|
|
2740
|
+
}
|
|
2741
|
+
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));
|
|
2742
|
+
function useDragNode(args) {
|
|
2743
|
+
const { srcId, parentId } = args;
|
|
2744
|
+
const driveId = useSelectedDriveId();
|
|
2745
|
+
const draggingNodeId = useDraggingNode()?.srcId;
|
|
2746
|
+
const params = {
|
|
2747
|
+
driveId,
|
|
2748
|
+
srcId,
|
|
2749
|
+
parentId
|
|
2750
|
+
};
|
|
2751
|
+
const draggable = isNodeDrag(params);
|
|
2752
|
+
const isDragging = t$4({
|
|
2753
|
+
srcId,
|
|
2754
|
+
draggingNodeId
|
|
2755
|
+
}, [
|
|
2756
|
+
() => draggable,
|
|
2757
|
+
({ srcId }) => e$2(srcId),
|
|
2758
|
+
({ draggingNodeId }) => e$2(draggingNodeId),
|
|
2759
|
+
({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
|
|
2760
|
+
]);
|
|
2761
|
+
const onDragStart = () => {
|
|
2762
|
+
if (!draggable) return;
|
|
2763
|
+
setDragging(params);
|
|
2764
|
+
};
|
|
2765
|
+
const onDragEnd = () => {
|
|
2766
|
+
if (!draggable) return;
|
|
2767
|
+
unsetDragging();
|
|
2768
|
+
};
|
|
2769
|
+
return {
|
|
2770
|
+
isDragging,
|
|
2771
|
+
draggable,
|
|
2772
|
+
onDragStart,
|
|
2773
|
+
onDragEnd
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
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));
|
|
2777
|
+
function useDropNode(targetId) {
|
|
2778
|
+
const driveId = useSelectedDriveId();
|
|
2779
|
+
const { srcId, parentId } = useDraggingNode() ?? {};
|
|
2780
|
+
const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
|
|
2781
|
+
const params = {
|
|
2782
|
+
driveId,
|
|
2783
|
+
parentId,
|
|
2784
|
+
targetId,
|
|
2785
|
+
srcId
|
|
2786
|
+
};
|
|
2787
|
+
function handleNodeDrop(event, cb) {
|
|
2788
|
+
if (!isNodeDrop(params)) return;
|
|
2789
|
+
event.preventDefault();
|
|
2790
|
+
event.stopPropagation();
|
|
2791
|
+
cb?.();
|
|
2792
|
+
}
|
|
2793
|
+
const onDragEnter = (event) => handleNodeDrop(event);
|
|
2794
|
+
const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
|
|
2795
|
+
const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
|
|
2796
|
+
const onDrop = (event) => handleNodeDrop(event, e(() => {
|
|
2797
|
+
unsetDragging();
|
|
2798
|
+
unsetTarget();
|
|
2799
|
+
moveNodeById(params).catch(console.error);
|
|
2800
|
+
}));
|
|
2801
|
+
return {
|
|
2802
|
+
isDropTarget,
|
|
2803
|
+
onDragEnter,
|
|
2804
|
+
onDragOver,
|
|
2805
|
+
onDragLeave,
|
|
2806
|
+
onDrop
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
|
|
2810
|
+
graphQLReactorClientEventFunctions.useValue;
|
|
2811
|
+
graphQLReactorClientEventFunctions.setValue;
|
|
2812
|
+
graphQLReactorClientEventFunctions.addEventHandler;
|
|
2813
|
+
const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
|
|
2814
|
+
packageDiscoveryFunctions.useValue;
|
|
2815
|
+
packageDiscoveryFunctions.setValue;
|
|
2816
|
+
packageDiscoveryFunctions.addEventHandler;
|
|
2817
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
2818
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
2819
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
2820
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
2821
|
+
reactorClientModuleEventFunctions.setValue;
|
|
2822
|
+
reactorClientModuleEventFunctions.addEventHandler;
|
|
2823
|
+
reactorClientEventFunctions.useValue;
|
|
2824
|
+
reactorClientEventFunctions.setValue;
|
|
2825
|
+
reactorClientEventFunctions.addEventHandler;
|
|
2826
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
2827
|
+
const useSyncList = () => {
|
|
2828
|
+
return useSync()?.list() ?? [];
|
|
2829
|
+
};
|
|
2830
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
2831
|
+
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
2832
|
+
revisionHistoryEventFunctions.useValue;
|
|
2833
|
+
/** Sets revision history visibility */
|
|
2834
|
+
const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
|
|
2835
|
+
revisionHistoryEventFunctions.addEventHandler;
|
|
2836
|
+
/** Shows the revision history */
|
|
2837
|
+
function showRevisionHistory() {
|
|
2838
|
+
setRevisionHistoryVisible(true);
|
|
2839
|
+
}
|
|
2840
|
+
/** Sorts nodes by name. */
|
|
2841
|
+
function sortNodesByName(nodes) {
|
|
2842
|
+
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
2843
|
+
}
|
|
2844
|
+
/** Returns whether a node is a file. */
|
|
2845
|
+
function isFileNodeKind(node) {
|
|
2846
|
+
if (!node) return false;
|
|
2847
|
+
return node.kind.toUpperCase() === "FILE";
|
|
2848
|
+
}
|
|
2849
|
+
/** Returns whether a node is a folder. */
|
|
2850
|
+
function isFolderNodeKind(node) {
|
|
2851
|
+
if (!node) return false;
|
|
2852
|
+
return node.kind.toUpperCase() === "FOLDER";
|
|
2853
|
+
}
|
|
2854
|
+
/** Returns the nodes in the selected drive. */
|
|
2855
|
+
function useNodesInSelectedDrive() {
|
|
2856
|
+
const [selectedDrive] = useSelectedDriveSafe();
|
|
2857
|
+
return selectedDrive?.state.global.nodes;
|
|
2858
|
+
}
|
|
2859
|
+
/** Returns the folder nodes in the selected drive. */
|
|
2860
|
+
function useFolderNodesInSelectedDrive() {
|
|
2861
|
+
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
2862
|
+
}
|
|
2863
|
+
/** Returns the selected node. */
|
|
2864
|
+
function useSelectedNode() {
|
|
2865
|
+
const selectedNodeId = useSelectedNodeId();
|
|
2866
|
+
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
2867
|
+
}
|
|
2868
|
+
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
2869
|
+
selectedTimelineItemEventFunctions.useValue;
|
|
2870
|
+
selectedTimelineItemEventFunctions.setValue;
|
|
2871
|
+
selectedTimelineItemEventFunctions.addEventHandler;
|
|
2872
|
+
const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
|
|
2873
|
+
selectedTimelineRevisionEventFunctions.useValue;
|
|
2874
|
+
selectedTimelineRevisionEventFunctions.setValue;
|
|
2875
|
+
selectedTimelineRevisionEventFunctions.addEventHandler;
|
|
2876
|
+
const toastEventFunctions = makePHEventFunctions("toast");
|
|
2877
|
+
/** Returns the toast function */
|
|
2878
|
+
const usePHToast = toastEventFunctions.useValue;
|
|
2879
|
+
toastEventFunctions.setValue;
|
|
2880
|
+
toastEventFunctions.addEventHandler;
|
|
2881
|
+
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
2882
|
+
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
2883
|
+
/** Returns all of the Vetra packages loaded by the Connect instance */
|
|
2884
|
+
const useVetraPackages = () => {
|
|
2885
|
+
const packageManager = useVetraPackageManager();
|
|
2886
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
|
|
2887
|
+
};
|
|
2888
|
+
vetraPackageManagerFunctions.addEventHandler;
|
|
2889
|
+
function useDocumentModelModules() {
|
|
2890
|
+
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);
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Resolves a document model module by document type, mirroring the registry's
|
|
2894
|
+
* semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
|
|
2895
|
+
* LATEST version of the type wins (`version ?? 1` as each module's default),
|
|
2896
|
+
* with `version` given only an exact match is returned. The reactor resolves
|
|
2897
|
+
* modules the same way when a document is created, so metadata read through
|
|
2898
|
+
* this hook and the version a creation actually uses cannot disagree.
|
|
2899
|
+
*/
|
|
2900
|
+
function useDocumentModelModuleById(id, version) {
|
|
2901
|
+
const documentModelModules = useDocumentModelModules();
|
|
2902
|
+
if (!id || !documentModelModules) return void 0;
|
|
2903
|
+
let latestModule;
|
|
2904
|
+
let latestVersion = -1;
|
|
2905
|
+
for (const module of documentModelModules) {
|
|
2906
|
+
if (module.documentModel.global.id !== id) continue;
|
|
2907
|
+
const moduleVersion = module.version ?? 1;
|
|
2908
|
+
if (version !== void 0) {
|
|
2909
|
+
if (moduleVersion === version) return module;
|
|
2910
|
+
continue;
|
|
2911
|
+
}
|
|
2912
|
+
if (moduleVersion > latestVersion) {
|
|
2913
|
+
latestVersion = moduleVersion;
|
|
2914
|
+
latestModule = module;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
return latestModule;
|
|
2918
|
+
}
|
|
2919
|
+
//#endregion
|
|
2920
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
|
|
2921
|
+
const normalizeDescriptors = (error) => {
|
|
2922
|
+
CORE_ERROR_PROPS.forEach((propName) => {
|
|
2923
|
+
normalizeDescriptor(error, propName);
|
|
2924
|
+
});
|
|
2925
|
+
};
|
|
2926
|
+
const CORE_ERROR_PROPS = [
|
|
2927
|
+
"name",
|
|
2928
|
+
"message",
|
|
2929
|
+
"stack",
|
|
2930
|
+
"cause",
|
|
2931
|
+
"errors"
|
|
2932
|
+
];
|
|
2933
|
+
const normalizeDescriptor = (error, propName) => {
|
|
2934
|
+
const descriptor = getDescriptor(error, propName);
|
|
2935
|
+
if (descriptor === void 0) return;
|
|
2936
|
+
if (isReadonlyGetter(descriptor)) {
|
|
2937
|
+
setErrorProperty(error, propName, error[propName]);
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
|
|
2941
|
+
};
|
|
2942
|
+
const getDescriptor = (value, propName) => {
|
|
2943
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, propName);
|
|
2944
|
+
if (descriptor !== void 0) return descriptor;
|
|
2945
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2946
|
+
return prototype === null ? void 0 : getDescriptor(prototype, propName);
|
|
2947
|
+
};
|
|
2948
|
+
const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
|
|
2949
|
+
const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
|
|
2950
|
+
const setErrorProperty = (error, propName, value) => {
|
|
2951
|
+
setErrorDescriptor(error, propName, { value });
|
|
2952
|
+
};
|
|
2953
|
+
const setErrorDescriptor = (error, propName, descriptor) => {
|
|
2954
|
+
Object.defineProperty(error, propName, {
|
|
2955
|
+
...descriptor,
|
|
2956
|
+
..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
|
|
2957
|
+
enumerable: false,
|
|
2958
|
+
configurable: true
|
|
2959
|
+
});
|
|
2960
|
+
};
|
|
2961
|
+
//#endregion
|
|
2962
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
|
|
2963
|
+
const normalizeAggregate = (error, recurse) => {
|
|
2964
|
+
if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
|
|
2965
|
+
else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
|
|
2966
|
+
else if (error.errors !== void 0) deleteAggregateErrors(error);
|
|
2967
|
+
};
|
|
2968
|
+
const isDefined = (error) => error !== void 0;
|
|
2969
|
+
const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
|
|
2970
|
+
const deleteAggregateErrors = (error) => {
|
|
2971
|
+
delete error.errors;
|
|
2972
|
+
if (error.errors !== void 0) setErrorProperty(error, "errors", []);
|
|
2973
|
+
};
|
|
2974
|
+
//#endregion
|
|
2975
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
|
|
2976
|
+
const normalizeCause = (error, recurse) => {
|
|
2977
|
+
if (!("cause" in error)) return;
|
|
2978
|
+
const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
|
|
2979
|
+
if (cause === void 0) delete error.cause;
|
|
2980
|
+
else setErrorProperty(error, "cause", cause);
|
|
2981
|
+
};
|
|
2982
|
+
//#endregion
|
|
2983
|
+
//#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
|
|
2984
|
+
const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
|
|
2985
|
+
const isInstanceOfError = (value) => {
|
|
2986
|
+
try {
|
|
2987
|
+
return value instanceof Error;
|
|
2988
|
+
} catch {
|
|
2989
|
+
return false;
|
|
2990
|
+
}
|
|
2991
|
+
};
|
|
2992
|
+
const hasErrorTag = (value) => {
|
|
2993
|
+
try {
|
|
2994
|
+
return ERROR_TAGS.has(Object.prototype.toString.call(value));
|
|
2995
|
+
} catch {
|
|
2996
|
+
return false;
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
const ERROR_TAGS = new Set([
|
|
3000
|
+
"[object Error]",
|
|
3001
|
+
"[object DOMException]",
|
|
3002
|
+
"[object DOMError]",
|
|
3003
|
+
"[object Exception]"
|
|
3004
|
+
]);
|
|
3005
|
+
//#endregion
|
|
3006
|
+
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
3007
|
+
function isPlainObject(value) {
|
|
3008
|
+
if (typeof value !== "object" || value === null) return false;
|
|
3009
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3010
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
3011
|
+
}
|
|
3012
|
+
//#endregion
|
|
3013
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
|
|
3014
|
+
const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
|
|
3015
|
+
const isNonConfigurableProp = (error, propName) => {
|
|
3016
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, propName);
|
|
3017
|
+
return descriptor !== void 0 && !descriptor.configurable;
|
|
3018
|
+
};
|
|
3019
|
+
const isThrowingProp = (error, propName) => {
|
|
3020
|
+
try {
|
|
3021
|
+
error[propName];
|
|
3022
|
+
return false;
|
|
3023
|
+
} catch {
|
|
3024
|
+
return true;
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
|
|
3029
|
+
const setStack = (error) => {
|
|
3030
|
+
setErrorProperty(error, "stack", getStack(error.message, error.name));
|
|
3031
|
+
};
|
|
3032
|
+
const getStack = (message = "", name = "Error") => {
|
|
3033
|
+
const { stack } = new (getErrorClass(name))(message);
|
|
3034
|
+
return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
|
|
3035
|
+
};
|
|
3036
|
+
const getErrorClass = (name) => {
|
|
3037
|
+
const descriptor = {
|
|
3038
|
+
value: name,
|
|
3039
|
+
enumerable: false,
|
|
3040
|
+
writable: true,
|
|
3041
|
+
configurable: true
|
|
3042
|
+
};
|
|
3043
|
+
const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
|
|
3044
|
+
Object.defineProperty(StackError.prototype, "name", descriptor);
|
|
3045
|
+
return StackError;
|
|
3046
|
+
};
|
|
3047
|
+
//#endregion
|
|
3048
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
|
|
3049
|
+
const copyObject = (object) => {
|
|
3050
|
+
const objectCopy = {};
|
|
3051
|
+
for (const propName of getPropsToCopy(object)) try {
|
|
3052
|
+
const value = object[propName];
|
|
3053
|
+
const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
|
|
3054
|
+
Object.defineProperty(objectCopy, propName, {
|
|
3055
|
+
value,
|
|
3056
|
+
enumerable,
|
|
3057
|
+
configurable,
|
|
3058
|
+
writable
|
|
3059
|
+
});
|
|
3060
|
+
} catch {}
|
|
3061
|
+
return objectCopy;
|
|
3062
|
+
};
|
|
3063
|
+
const getPropsToCopy = (object) => {
|
|
3064
|
+
const propNames = getOwnKeys(object);
|
|
3065
|
+
for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
|
|
3066
|
+
return propNames;
|
|
3067
|
+
};
|
|
3068
|
+
const getOwnKeys = (object) => {
|
|
3069
|
+
try {
|
|
3070
|
+
return Reflect.ownKeys(object);
|
|
3071
|
+
} catch {
|
|
3072
|
+
return [];
|
|
3073
|
+
}
|
|
3074
|
+
};
|
|
3075
|
+
const isInheritedProp = (object, propName) => {
|
|
3076
|
+
try {
|
|
3077
|
+
return propName in object && !Object.hasOwn(object, propName);
|
|
3078
|
+
} catch {
|
|
3079
|
+
return false;
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
//#endregion
|
|
3083
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
|
|
3084
|
+
const objectifyError = (object) => {
|
|
3085
|
+
const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
|
|
3086
|
+
const messageA = getMessage(message, objectA);
|
|
3087
|
+
const error = newError(name, messageA);
|
|
3088
|
+
if (message === messageA) assignObjectProps(error, objectA);
|
|
3089
|
+
Object.entries({
|
|
3090
|
+
name,
|
|
3091
|
+
stack,
|
|
3092
|
+
cause,
|
|
3093
|
+
errors
|
|
3094
|
+
}).forEach(([propName, propValue]) => {
|
|
3095
|
+
setNewErrorProperty(error, propName, propValue);
|
|
3096
|
+
});
|
|
3097
|
+
if (stack === void 0) setStack(error);
|
|
3098
|
+
return error;
|
|
3099
|
+
};
|
|
3100
|
+
const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
|
|
3101
|
+
const safeJsonStringify = (object) => {
|
|
3102
|
+
try {
|
|
3103
|
+
return JSON.stringify(object);
|
|
3104
|
+
} catch {
|
|
3105
|
+
return safeStringify(object);
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
const safeStringify = (object) => {
|
|
3109
|
+
try {
|
|
3110
|
+
return String(object);
|
|
3111
|
+
} catch {
|
|
3112
|
+
return "Invalid error";
|
|
3113
|
+
}
|
|
3114
|
+
};
|
|
3115
|
+
const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
|
|
3116
|
+
const MESSAGE_MAX_SIZE = 1e3;
|
|
3117
|
+
const newError = (name, message) => {
|
|
3118
|
+
if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
|
|
3119
|
+
if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
|
|
3120
|
+
return new Error(message);
|
|
3121
|
+
};
|
|
3122
|
+
const NATIVE_ERRORS = {
|
|
3123
|
+
Error,
|
|
3124
|
+
ReferenceError,
|
|
3125
|
+
TypeError,
|
|
3126
|
+
SyntaxError,
|
|
3127
|
+
RangeError,
|
|
3128
|
+
URIError,
|
|
3129
|
+
EvalError
|
|
3130
|
+
};
|
|
3131
|
+
const assignObjectProps = (error, object) => {
|
|
3132
|
+
for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
|
|
3133
|
+
};
|
|
3134
|
+
const setNewErrorProperty = (error, propName, propValue) => {
|
|
3135
|
+
if (propValue !== void 0) setErrorProperty(error, propName, propValue);
|
|
3136
|
+
};
|
|
3137
|
+
//#endregion
|
|
3138
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
|
|
3139
|
+
const stringifyError = (value) => {
|
|
3140
|
+
try {
|
|
3141
|
+
const error = new Error(String(value));
|
|
3142
|
+
setStack(error);
|
|
3143
|
+
return error;
|
|
3144
|
+
} catch (error_) {
|
|
3145
|
+
return error_;
|
|
3146
|
+
}
|
|
3147
|
+
};
|
|
3148
|
+
//#endregion
|
|
3149
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
|
|
3150
|
+
const { toString: objectToString } = Object.prototype;
|
|
3151
|
+
const createError = (value) => {
|
|
3152
|
+
if (isErrorPlainObj(value)) return objectifyError(value);
|
|
3153
|
+
if (!isErrorInstance(value)) return stringifyError(value);
|
|
3154
|
+
if (isInvalidError(value)) return objectifyError(value);
|
|
3155
|
+
return value;
|
|
3156
|
+
};
|
|
3157
|
+
const isErrorPlainObj = (value) => {
|
|
3158
|
+
try {
|
|
3159
|
+
return isPlainObject(value);
|
|
3160
|
+
} catch {
|
|
3161
|
+
return false;
|
|
3162
|
+
}
|
|
3163
|
+
};
|
|
3164
|
+
const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
|
|
3165
|
+
const isProxy = (value) => {
|
|
3166
|
+
try {
|
|
3167
|
+
return objectToString.call(value) === "[object Object]";
|
|
3168
|
+
} catch {
|
|
3169
|
+
return true;
|
|
3170
|
+
}
|
|
3171
|
+
};
|
|
3172
|
+
const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
|
|
3173
|
+
//#endregion
|
|
3174
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
|
|
3175
|
+
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
3176
|
+
const recurseException = (error, parents, shallow) => {
|
|
3177
|
+
if (parents.includes(error)) return;
|
|
3178
|
+
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
3179
|
+
const errorA = createError(error);
|
|
3180
|
+
normalizeProps(errorA, recurse);
|
|
3181
|
+
return errorA;
|
|
3182
|
+
};
|
|
3183
|
+
const identity = (error) => error;
|
|
3184
|
+
const normalizeProps = (error, recurse) => {
|
|
3185
|
+
normalizeName(error);
|
|
3186
|
+
normalizeMessage(error);
|
|
3187
|
+
normalizeStack(error);
|
|
3188
|
+
normalizeCause(error, recurse);
|
|
3189
|
+
normalizeAggregate(error, recurse);
|
|
3190
|
+
normalizeDescriptors(error);
|
|
3191
|
+
};
|
|
3192
|
+
const normalizeName = (error) => {
|
|
3193
|
+
if (isDefinedString(error.name)) return;
|
|
3194
|
+
const prototypeName = Object.getPrototypeOf(error).name;
|
|
3195
|
+
setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
|
|
3196
|
+
};
|
|
3197
|
+
const normalizeMessage = (error) => {
|
|
3198
|
+
if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
|
|
3199
|
+
};
|
|
3200
|
+
const normalizeStack = (error) => {
|
|
3201
|
+
if (!isDefinedString(error.stack)) setStack(error);
|
|
3202
|
+
};
|
|
3203
|
+
const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
3204
|
+
//#endregion
|
|
3205
|
+
//#region ../reactor-browser/dist/index.js
|
|
3206
|
+
var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3207
|
+
var LZString = (function() {
|
|
3208
|
+
var f = String.fromCharCode;
|
|
3209
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3210
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
3211
|
+
var baseReverseDic = {};
|
|
3212
|
+
function getBaseValue(alphabet, character) {
|
|
3213
|
+
if (!baseReverseDic[alphabet]) {
|
|
3214
|
+
baseReverseDic[alphabet] = {};
|
|
3215
|
+
for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
3216
|
+
}
|
|
3217
|
+
return baseReverseDic[alphabet][character];
|
|
3218
|
+
}
|
|
3219
|
+
var LZString = {
|
|
3220
|
+
compressToBase64: function(input) {
|
|
3221
|
+
if (input == null) return "";
|
|
3222
|
+
var res = LZString._compress(input, 6, function(a) {
|
|
3223
|
+
return keyStrBase64.charAt(a);
|
|
3224
|
+
});
|
|
3225
|
+
switch (res.length % 4) {
|
|
3226
|
+
default:
|
|
3227
|
+
case 0: return res;
|
|
3228
|
+
case 1: return res + "===";
|
|
3229
|
+
case 2: return res + "==";
|
|
3230
|
+
case 3: return res + "=";
|
|
3231
|
+
}
|
|
3232
|
+
},
|
|
3233
|
+
decompressFromBase64: function(input) {
|
|
3234
|
+
if (input == null) return "";
|
|
3235
|
+
if (input == "") return null;
|
|
3236
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3237
|
+
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
3238
|
+
});
|
|
3239
|
+
},
|
|
3240
|
+
compressToUTF16: function(input) {
|
|
3241
|
+
if (input == null) return "";
|
|
3242
|
+
return LZString._compress(input, 15, function(a) {
|
|
3243
|
+
return f(a + 32);
|
|
3244
|
+
}) + " ";
|
|
3245
|
+
},
|
|
3246
|
+
decompressFromUTF16: function(compressed) {
|
|
3247
|
+
if (compressed == null) return "";
|
|
3248
|
+
if (compressed == "") return null;
|
|
3249
|
+
return LZString._decompress(compressed.length, 16384, function(index) {
|
|
3250
|
+
return compressed.charCodeAt(index) - 32;
|
|
3251
|
+
});
|
|
3252
|
+
},
|
|
3253
|
+
compressToUint8Array: function(uncompressed) {
|
|
3254
|
+
var compressed = LZString.compress(uncompressed);
|
|
3255
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
3256
|
+
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
3257
|
+
var current_value = compressed.charCodeAt(i);
|
|
3258
|
+
buf[i * 2] = current_value >>> 8;
|
|
3259
|
+
buf[i * 2 + 1] = current_value % 256;
|
|
3260
|
+
}
|
|
3261
|
+
return buf;
|
|
3262
|
+
},
|
|
3263
|
+
decompressFromUint8Array: function(compressed) {
|
|
3264
|
+
if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
|
|
3265
|
+
else {
|
|
3266
|
+
var buf = new Array(compressed.length / 2);
|
|
3267
|
+
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
3268
|
+
var result = [];
|
|
3269
|
+
buf.forEach(function(c) {
|
|
3270
|
+
result.push(f(c));
|
|
3271
|
+
});
|
|
3272
|
+
return LZString.decompress(result.join(""));
|
|
3273
|
+
}
|
|
3274
|
+
},
|
|
3275
|
+
compressToEncodedURIComponent: function(input) {
|
|
3276
|
+
if (input == null) return "";
|
|
3277
|
+
return LZString._compress(input, 6, function(a) {
|
|
3278
|
+
return keyStrUriSafe.charAt(a);
|
|
3279
|
+
});
|
|
3280
|
+
},
|
|
3281
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
3282
|
+
if (input == null) return "";
|
|
3283
|
+
if (input == "") return null;
|
|
3284
|
+
input = input.replace(/ /g, "+");
|
|
3285
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3286
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
3287
|
+
});
|
|
3288
|
+
},
|
|
3289
|
+
compress: function(uncompressed) {
|
|
3290
|
+
return LZString._compress(uncompressed, 16, function(a) {
|
|
3291
|
+
return f(a);
|
|
3292
|
+
});
|
|
3293
|
+
},
|
|
3294
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
3295
|
+
if (uncompressed == null) return "";
|
|
3296
|
+
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;
|
|
3297
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
3298
|
+
context_c = uncompressed.charAt(ii);
|
|
3299
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
3300
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
3301
|
+
context_dictionaryToCreate[context_c] = true;
|
|
3302
|
+
}
|
|
3303
|
+
context_wc = context_w + context_c;
|
|
3304
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
|
|
3305
|
+
else {
|
|
3306
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3307
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3308
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3309
|
+
context_data_val = context_data_val << 1;
|
|
3310
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3311
|
+
context_data_position = 0;
|
|
3312
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3313
|
+
context_data_val = 0;
|
|
3314
|
+
} else context_data_position++;
|
|
3315
|
+
}
|
|
3316
|
+
value = context_w.charCodeAt(0);
|
|
3317
|
+
for (i = 0; i < 8; i++) {
|
|
3318
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3319
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3320
|
+
context_data_position = 0;
|
|
3321
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3322
|
+
context_data_val = 0;
|
|
3323
|
+
} else context_data_position++;
|
|
3324
|
+
value = value >> 1;
|
|
3325
|
+
}
|
|
3326
|
+
} else {
|
|
3327
|
+
value = 1;
|
|
3328
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3329
|
+
context_data_val = context_data_val << 1 | value;
|
|
3330
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3331
|
+
context_data_position = 0;
|
|
3332
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3333
|
+
context_data_val = 0;
|
|
3334
|
+
} else context_data_position++;
|
|
3335
|
+
value = 0;
|
|
3336
|
+
}
|
|
3337
|
+
value = context_w.charCodeAt(0);
|
|
3338
|
+
for (i = 0; i < 16; i++) {
|
|
3339
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3340
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3341
|
+
context_data_position = 0;
|
|
3342
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3343
|
+
context_data_val = 0;
|
|
3344
|
+
} else context_data_position++;
|
|
3345
|
+
value = value >> 1;
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
context_enlargeIn--;
|
|
3349
|
+
if (context_enlargeIn == 0) {
|
|
3350
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3351
|
+
context_numBits++;
|
|
3352
|
+
}
|
|
3353
|
+
delete context_dictionaryToCreate[context_w];
|
|
3354
|
+
} else {
|
|
3355
|
+
value = context_dictionary[context_w];
|
|
3356
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3357
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3358
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3359
|
+
context_data_position = 0;
|
|
3360
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3361
|
+
context_data_val = 0;
|
|
3362
|
+
} else context_data_position++;
|
|
3363
|
+
value = value >> 1;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
context_enlargeIn--;
|
|
3367
|
+
if (context_enlargeIn == 0) {
|
|
3368
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3369
|
+
context_numBits++;
|
|
3370
|
+
}
|
|
3371
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
3372
|
+
context_w = String(context_c);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
if (context_w !== "") {
|
|
3376
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3377
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3378
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3379
|
+
context_data_val = context_data_val << 1;
|
|
3380
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3381
|
+
context_data_position = 0;
|
|
3382
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3383
|
+
context_data_val = 0;
|
|
3384
|
+
} else context_data_position++;
|
|
3385
|
+
}
|
|
3386
|
+
value = context_w.charCodeAt(0);
|
|
3387
|
+
for (i = 0; i < 8; i++) {
|
|
3388
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3389
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3390
|
+
context_data_position = 0;
|
|
3391
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3392
|
+
context_data_val = 0;
|
|
3393
|
+
} else context_data_position++;
|
|
3394
|
+
value = value >> 1;
|
|
3395
|
+
}
|
|
3396
|
+
} else {
|
|
3397
|
+
value = 1;
|
|
3398
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3399
|
+
context_data_val = context_data_val << 1 | value;
|
|
3400
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3401
|
+
context_data_position = 0;
|
|
3402
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3403
|
+
context_data_val = 0;
|
|
3404
|
+
} else context_data_position++;
|
|
3405
|
+
value = 0;
|
|
3406
|
+
}
|
|
3407
|
+
value = context_w.charCodeAt(0);
|
|
3408
|
+
for (i = 0; i < 16; i++) {
|
|
3409
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3410
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3411
|
+
context_data_position = 0;
|
|
3412
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3413
|
+
context_data_val = 0;
|
|
3414
|
+
} else context_data_position++;
|
|
3415
|
+
value = value >> 1;
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
context_enlargeIn--;
|
|
3419
|
+
if (context_enlargeIn == 0) {
|
|
3420
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3421
|
+
context_numBits++;
|
|
3422
|
+
}
|
|
3423
|
+
delete context_dictionaryToCreate[context_w];
|
|
3424
|
+
} else {
|
|
3425
|
+
value = context_dictionary[context_w];
|
|
3426
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3427
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3428
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3429
|
+
context_data_position = 0;
|
|
3430
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3431
|
+
context_data_val = 0;
|
|
3432
|
+
} else context_data_position++;
|
|
3433
|
+
value = value >> 1;
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
context_enlargeIn--;
|
|
3437
|
+
if (context_enlargeIn == 0) {
|
|
3438
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3439
|
+
context_numBits++;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
value = 2;
|
|
3443
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3444
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3445
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3446
|
+
context_data_position = 0;
|
|
3447
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3448
|
+
context_data_val = 0;
|
|
3449
|
+
} else context_data_position++;
|
|
3450
|
+
value = value >> 1;
|
|
3451
|
+
}
|
|
3452
|
+
while (true) {
|
|
3453
|
+
context_data_val = context_data_val << 1;
|
|
3454
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3455
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3456
|
+
break;
|
|
3457
|
+
} else context_data_position++;
|
|
3458
|
+
}
|
|
3459
|
+
return context_data.join("");
|
|
3460
|
+
},
|
|
3461
|
+
decompress: function(compressed) {
|
|
3462
|
+
if (compressed == null) return "";
|
|
3463
|
+
if (compressed == "") return null;
|
|
3464
|
+
return LZString._decompress(compressed.length, 32768, function(index) {
|
|
3465
|
+
return compressed.charCodeAt(index);
|
|
3466
|
+
});
|
|
3467
|
+
},
|
|
3468
|
+
_decompress: function(length, resetValue, getNextValue) {
|
|
3469
|
+
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
|
|
3470
|
+
val: getNextValue(0),
|
|
3471
|
+
position: resetValue,
|
|
3472
|
+
index: 1
|
|
3473
|
+
};
|
|
3474
|
+
for (i = 0; i < 3; i += 1) dictionary[i] = i;
|
|
3475
|
+
bits = 0;
|
|
3476
|
+
maxpower = Math.pow(2, 2);
|
|
3477
|
+
power = 1;
|
|
3478
|
+
while (power != maxpower) {
|
|
3479
|
+
resb = data.val & data.position;
|
|
3480
|
+
data.position >>= 1;
|
|
3481
|
+
if (data.position == 0) {
|
|
3482
|
+
data.position = resetValue;
|
|
3483
|
+
data.val = getNextValue(data.index++);
|
|
3484
|
+
}
|
|
3485
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3486
|
+
power <<= 1;
|
|
3487
|
+
}
|
|
3488
|
+
switch (bits) {
|
|
3489
|
+
case 0:
|
|
3490
|
+
bits = 0;
|
|
3491
|
+
maxpower = Math.pow(2, 8);
|
|
3492
|
+
power = 1;
|
|
3493
|
+
while (power != maxpower) {
|
|
3494
|
+
resb = data.val & data.position;
|
|
3495
|
+
data.position >>= 1;
|
|
3496
|
+
if (data.position == 0) {
|
|
3497
|
+
data.position = resetValue;
|
|
3498
|
+
data.val = getNextValue(data.index++);
|
|
3499
|
+
}
|
|
3500
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3501
|
+
power <<= 1;
|
|
3502
|
+
}
|
|
3503
|
+
c = f(bits);
|
|
3504
|
+
break;
|
|
3505
|
+
case 1:
|
|
3506
|
+
bits = 0;
|
|
3507
|
+
maxpower = Math.pow(2, 16);
|
|
3508
|
+
power = 1;
|
|
3509
|
+
while (power != maxpower) {
|
|
3510
|
+
resb = data.val & data.position;
|
|
3511
|
+
data.position >>= 1;
|
|
3512
|
+
if (data.position == 0) {
|
|
3513
|
+
data.position = resetValue;
|
|
3514
|
+
data.val = getNextValue(data.index++);
|
|
3515
|
+
}
|
|
3516
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3517
|
+
power <<= 1;
|
|
3518
|
+
}
|
|
3519
|
+
c = f(bits);
|
|
3520
|
+
break;
|
|
3521
|
+
case 2: return "";
|
|
3522
|
+
}
|
|
3523
|
+
dictionary[3] = c;
|
|
3524
|
+
w = c;
|
|
3525
|
+
result.push(c);
|
|
3526
|
+
while (true) {
|
|
3527
|
+
if (data.index > length) return "";
|
|
3528
|
+
bits = 0;
|
|
3529
|
+
maxpower = Math.pow(2, numBits);
|
|
3530
|
+
power = 1;
|
|
3531
|
+
while (power != maxpower) {
|
|
3532
|
+
resb = data.val & data.position;
|
|
3533
|
+
data.position >>= 1;
|
|
3534
|
+
if (data.position == 0) {
|
|
3535
|
+
data.position = resetValue;
|
|
3536
|
+
data.val = getNextValue(data.index++);
|
|
3537
|
+
}
|
|
3538
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3539
|
+
power <<= 1;
|
|
3540
|
+
}
|
|
3541
|
+
switch (c = bits) {
|
|
3542
|
+
case 0:
|
|
3543
|
+
bits = 0;
|
|
3544
|
+
maxpower = Math.pow(2, 8);
|
|
3545
|
+
power = 1;
|
|
3546
|
+
while (power != maxpower) {
|
|
3547
|
+
resb = data.val & data.position;
|
|
3548
|
+
data.position >>= 1;
|
|
3549
|
+
if (data.position == 0) {
|
|
3550
|
+
data.position = resetValue;
|
|
3551
|
+
data.val = getNextValue(data.index++);
|
|
3552
|
+
}
|
|
3553
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3554
|
+
power <<= 1;
|
|
3555
|
+
}
|
|
3556
|
+
dictionary[dictSize++] = f(bits);
|
|
3557
|
+
c = dictSize - 1;
|
|
3558
|
+
enlargeIn--;
|
|
3559
|
+
break;
|
|
3560
|
+
case 1:
|
|
3561
|
+
bits = 0;
|
|
3562
|
+
maxpower = Math.pow(2, 16);
|
|
3563
|
+
power = 1;
|
|
3564
|
+
while (power != maxpower) {
|
|
3565
|
+
resb = data.val & data.position;
|
|
3566
|
+
data.position >>= 1;
|
|
3567
|
+
if (data.position == 0) {
|
|
3568
|
+
data.position = resetValue;
|
|
3569
|
+
data.val = getNextValue(data.index++);
|
|
3570
|
+
}
|
|
3571
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3572
|
+
power <<= 1;
|
|
3573
|
+
}
|
|
3574
|
+
dictionary[dictSize++] = f(bits);
|
|
3575
|
+
c = dictSize - 1;
|
|
3576
|
+
enlargeIn--;
|
|
3577
|
+
break;
|
|
3578
|
+
case 2: return result.join("");
|
|
3579
|
+
}
|
|
3580
|
+
if (enlargeIn == 0) {
|
|
3581
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3582
|
+
numBits++;
|
|
3583
|
+
}
|
|
3584
|
+
if (dictionary[c]) entry = dictionary[c];
|
|
3585
|
+
else if (c === dictSize) entry = w + w.charAt(0);
|
|
3586
|
+
else return null;
|
|
3587
|
+
result.push(entry);
|
|
3588
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
3589
|
+
enlargeIn--;
|
|
3590
|
+
w = entry;
|
|
3591
|
+
if (enlargeIn == 0) {
|
|
3592
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3593
|
+
numBits++;
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
};
|
|
3598
|
+
return LZString;
|
|
3599
|
+
})();
|
|
3600
|
+
if (typeof define === "function" && define.amd) define(function() {
|
|
3601
|
+
return LZString;
|
|
3138
3602
|
});
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3603
|
+
else if (typeof module !== "undefined" && module != null) module.exports = LZString;
|
|
3604
|
+
else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
|
|
3605
|
+
return LZString;
|
|
3142
3606
|
});
|
|
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
|
-
}
|
|
3607
|
+
})))(), 1);
|
|
3608
|
+
/** Document types that represent a "drive": a container of nodes. */
|
|
3609
|
+
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
3333
3610
|
function useAllowedDocumentModelModules() {
|
|
3334
3611
|
const documentModelModules = useDocumentModelModules();
|
|
3335
3612
|
const allowedDocumentTypes = useAllowedDocumentTypes();
|
|
@@ -3405,6 +3682,50 @@ function useDocumentOfType(documentId, documentType) {
|
|
|
3405
3682
|
if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(documentId, documentType, document.header.documentType);
|
|
3406
3683
|
return [document, dispatch];
|
|
3407
3684
|
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Classifies a document's model version against the installed module
|
|
3687
|
+
* versions. Pure logic, extracted for testing.
|
|
3688
|
+
*/
|
|
3689
|
+
function getDocumentVersionStatus(documentVersion, availableVersions, hasUpgradePath) {
|
|
3690
|
+
if (availableVersions.length === 0) return;
|
|
3691
|
+
const sorted = [...availableVersions].sort((a, b) => a - b);
|
|
3692
|
+
const latestVersion = sorted[sorted.length - 1];
|
|
3693
|
+
if (documentVersion > latestVersion) return {
|
|
3694
|
+
kind: "unsupported",
|
|
3695
|
+
documentVersion,
|
|
3696
|
+
availableVersions: sorted
|
|
3697
|
+
};
|
|
3698
|
+
if (documentVersion === latestVersion) return {
|
|
3699
|
+
kind: "current",
|
|
3700
|
+
documentVersion
|
|
3701
|
+
};
|
|
3702
|
+
return {
|
|
3703
|
+
kind: "upgrade-available",
|
|
3704
|
+
documentVersion,
|
|
3705
|
+
latestVersion,
|
|
3706
|
+
canUpgrade: hasUpgradePath(documentVersion, latestVersion)
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
/**
|
|
3710
|
+
* Compares the given document's model version against the versions available
|
|
3711
|
+
* from installed Vetra packages. Returns undefined while packages load or
|
|
3712
|
+
* when the document type has no installed modules.
|
|
3713
|
+
*/
|
|
3714
|
+
function useDocumentVersionStatus(document) {
|
|
3715
|
+
const modules = useDocumentModelModules();
|
|
3716
|
+
const registry = useModelRegistry();
|
|
3717
|
+
if (!document || !modules) return;
|
|
3718
|
+
const documentType = document.header.documentType;
|
|
3719
|
+
return getDocumentVersionStatus(document.state.document.version || 1, modules.filter((m) => m.documentModel.global.id === documentType).map((m) => m.version ?? 1), (fromVersion, toVersion) => {
|
|
3720
|
+
if (!registry) return false;
|
|
3721
|
+
try {
|
|
3722
|
+
registry.computeUpgradePath(documentType, fromVersion, toVersion);
|
|
3723
|
+
return true;
|
|
3724
|
+
} catch {
|
|
3725
|
+
return false;
|
|
3726
|
+
}
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3408
3729
|
const validateDocument = (document) => {
|
|
3409
3730
|
const errors = [];
|
|
3410
3731
|
if (document.header.documentType !== "powerhouse/document-model") return errors;
|
|
@@ -3514,7 +3835,7 @@ function useNodeActions() {
|
|
|
3514
3835
|
}
|
|
3515
3836
|
async function onAddFolder(name, parent) {
|
|
3516
3837
|
if (!selectedDriveId) return;
|
|
3517
|
-
return addFolder(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
3838
|
+
return addFolder$1(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
3518
3839
|
}
|
|
3519
3840
|
async function onRenameNode(newName, node) {
|
|
3520
3841
|
if (!selectedDriveId) return;
|
|
@@ -3601,6 +3922,9 @@ function useSelectedNodePath() {
|
|
|
3601
3922
|
function useNodeParentFolderById(id) {
|
|
3602
3923
|
return useFolderById(useNodeById(id)?.parentFolder);
|
|
3603
3924
|
}
|
|
3925
|
+
function useParentFolderForSelectedNode() {
|
|
3926
|
+
return useNodeParentFolderById(useSelectedNode()?.id);
|
|
3927
|
+
}
|
|
3604
3928
|
/** Returns the selected document id */
|
|
3605
3929
|
function useSelectedDocumentId() {
|
|
3606
3930
|
const selectedNode = useSelectedNode();
|
|
@@ -3829,6 +4153,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
|
|
|
3829
4153
|
createDebouncedRefreshReactorData();
|
|
3830
4154
|
createDebouncedRefreshReactorDataClient();
|
|
3831
4155
|
//#endregion
|
|
3832
|
-
export {
|
|
4156
|
+
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
4157
|
|
|
3834
|
-
//# sourceMappingURL=dist-
|
|
4158
|
+
//# sourceMappingURL=dist-DfoAQf6g.js.map
|