@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.9 → 6.2.2
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-5_Eh4a2Z.js} +3 -2
- package/dist/browser/assets/{projection-entry-DVec8YRh.js → projection-entry-DgFDnTMt.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-DqkYyEcC.js} +927 -202
- package/dist/browser/connect-DqkYyEcC.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-C1pi89al.js} +2640 -1833
- package/dist/browser/dist-C1pi89al.js.map +1 -0
- package/dist/browser/{document-drive-IdFV1QXL.js → document-drive-ZQzPQfEL.js} +998 -127
- package/dist/browser/document-drive-ZQzPQfEL.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-DiZF3ao3.js → editor-Bl02Hko1.js} +671 -236
- package/dist/browser/editor-Bl02Hko1.js.map +1 -0
- package/dist/browser/editor-CbtY05JH.js +25 -0
- package/dist/browser/editor-CbtY05JH.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-BBm_YnKn.js} +73 -46
- package/dist/browser/folder-view-BBm_YnKn.js.map +1 -0
- package/dist/browser/{graphql-editor-ZLRO_8Ce.js → graphql-editor-LSj3LCtL.js} +8 -7
- package/dist/browser/{graphql-editor-ZLRO_8Ce.js.map → graphql-editor-LSj3LCtL.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-TVSHA4PZ.js} +4 -4
- package/dist/browser/{json-editor-DBuZ6gN7.js.map → json-editor-TVSHA4PZ.js.map} +1 -1
- package/dist/browser/{lib-C-f3izXz.js → lib-ewnRj2dJ.js} +13 -4
- package/dist/browser/lib-ewnRj2dJ.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-Bsryt22c.js} +8 -18
- package/dist/browser/state-schemas-Bsryt22c.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-B2yHg8VF.mjs} +927 -202
- package/dist/node/connect-B2yHg8VF.mjs.map +1 -0
- package/dist/node/{dist-DJEK2WVi.mjs → dist-BAXIB1_k.mjs} +2647 -1833
- package/dist/node/dist-BAXIB1_k.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-D1NMjQQc.mjs} +998 -127
- package/dist/node/document-drive-D1NMjQQc.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--v67sph0.mjs} +672 -237
- package/dist/node/editor--v67sph0.mjs.map +1 -0
- package/dist/node/editor-BY22Tx5_.mjs +25 -0
- package/dist/node/editor-BY22Tx5_.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-D_99HJFI.mjs} +73 -46
- package/dist/node/folder-view-D_99HJFI.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-Bzs-PolA.mjs} +7 -7
- package/dist/node/{graphql-editor-C5VLRqEf.mjs.map → graphql-editor-Bzs-PolA.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-CCsBXZ6y.mjs} +4 -4
- package/dist/node/{json-editor-iI2s9a_4.mjs.map → json-editor-CCsBXZ6y.mjs.map} +1 -1
- package/dist/node/{main-D82dkD7g.mjs → main-B1tRsYOp.mjs} +15 -6
- package/dist/node/main-B1tRsYOp.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-DxJBYOC0.mjs} +10 -20
- package/dist/{browser/state-schemas-BjQKM498.js.map → node/state-schemas-DxJBYOC0.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, r as pascalCase, t as capitalCase } from "./dist-B4FWbuEM.js";
|
|
2
|
+
import { A as createPresignedHeader, D as buildSignedAction, E as baseSaveToFileHandle, G as replayDocumentVersioned, N as createZip, T as baseLoadFromInputVersioned, _ as UnsupportedDocumentModelVersionError, a as getDescendants, c as isFileNode, ct as validateInitialState, d as moveNode, dt as zipEntries, et as setName, f as updateNode, ft as generateId, i as generateNodesCopy, l as isFolderNode, lt as validateModules, m as logger, n as copyNode, o as getNextCopyNumber, s as handleTargetNameCollisions, t as addFolder, ut as validateStateSchemaName, w as baseLoadFromInput, x as assertAuthPreservedOnDuplicate } from "./document-drive-ZQzPQfEL.js";
|
|
3
|
+
import { a as SyncStatus, o as DriveCollectionId, s as ModuleNotFoundError, t as gql } from "./lib-ewnRj2dJ.js";
|
|
4
|
+
import { c as Kind, t as parse } from "./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;
|
|
@@ -226,710 +243,29 @@ function useDocumentById(id) {
|
|
|
226
243
|
return [document, dispatch];
|
|
227
244
|
}
|
|
228
245
|
//#endregion
|
|
229
|
-
//#region
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
version
|
|
253
|
-
specification
|
|
254
|
-
}
|
|
255
|
-
totalCount
|
|
256
|
-
hasNextPage
|
|
257
|
-
hasPreviousPage
|
|
258
|
-
cursor
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
`;
|
|
262
|
-
const GetDocumentDocument = gql`
|
|
263
|
-
query GetDocument($identifier: String!, $view: ViewFilterInput) {
|
|
264
|
-
document(identifier: $identifier, view: $view) {
|
|
265
|
-
document {
|
|
266
|
-
...PHDocumentFields
|
|
267
|
-
}
|
|
268
|
-
childIds
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
${PhDocumentFieldsFragmentDoc}
|
|
272
|
-
`;
|
|
273
|
-
const GetDocumentWithOperationsDocument = gql`
|
|
274
|
-
query GetDocumentWithOperations(
|
|
275
|
-
$identifier: String!
|
|
276
|
-
$view: ViewFilterInput
|
|
277
|
-
$operationsFilter: DocumentOperationsFilterInput
|
|
278
|
-
$operationsPaging: PagingInput
|
|
279
|
-
) {
|
|
280
|
-
document(identifier: $identifier, view: $view) {
|
|
281
|
-
document {
|
|
282
|
-
...PHDocumentFields
|
|
283
|
-
operations(filter: $operationsFilter, paging: $operationsPaging) {
|
|
284
|
-
items {
|
|
285
|
-
index
|
|
286
|
-
timestampUtcMs
|
|
287
|
-
hash
|
|
288
|
-
skip
|
|
289
|
-
error
|
|
290
|
-
id
|
|
291
|
-
action {
|
|
292
|
-
id
|
|
293
|
-
type
|
|
294
|
-
timestampUtcMs
|
|
295
|
-
input
|
|
296
|
-
scope
|
|
297
|
-
context {
|
|
298
|
-
signer {
|
|
299
|
-
user {
|
|
300
|
-
address
|
|
301
|
-
networkId
|
|
302
|
-
chainId
|
|
303
|
-
}
|
|
304
|
-
app {
|
|
305
|
-
name
|
|
306
|
-
key
|
|
307
|
-
}
|
|
308
|
-
signatures
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
totalCount
|
|
314
|
-
hasNextPage
|
|
315
|
-
hasPreviousPage
|
|
316
|
-
cursor
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
childIds
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
${PhDocumentFieldsFragmentDoc}
|
|
323
|
-
`;
|
|
324
|
-
gql`
|
|
325
|
-
query GetDocumentOutgoingRelationships(
|
|
326
|
-
$sourceIdentifier: String!
|
|
327
|
-
$relationshipType: String!
|
|
328
|
-
$view: ViewFilterInput
|
|
329
|
-
$paging: PagingInput
|
|
330
|
-
) {
|
|
331
|
-
documentOutgoingRelationships(
|
|
332
|
-
sourceIdentifier: $sourceIdentifier
|
|
333
|
-
relationshipType: $relationshipType
|
|
334
|
-
view: $view
|
|
335
|
-
paging: $paging
|
|
336
|
-
) {
|
|
337
|
-
items {
|
|
338
|
-
...PHDocumentFields
|
|
339
|
-
}
|
|
340
|
-
totalCount
|
|
341
|
-
hasNextPage
|
|
342
|
-
hasPreviousPage
|
|
343
|
-
cursor
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
${PhDocumentFieldsFragmentDoc}
|
|
347
|
-
`;
|
|
348
|
-
gql`
|
|
349
|
-
query GetDocumentIncomingRelationships(
|
|
350
|
-
$targetIdentifier: String!
|
|
351
|
-
$relationshipType: String!
|
|
352
|
-
$view: ViewFilterInput
|
|
353
|
-
$paging: PagingInput
|
|
354
|
-
) {
|
|
355
|
-
documentIncomingRelationships(
|
|
356
|
-
targetIdentifier: $targetIdentifier
|
|
357
|
-
relationshipType: $relationshipType
|
|
358
|
-
view: $view
|
|
359
|
-
paging: $paging
|
|
360
|
-
) {
|
|
361
|
-
items {
|
|
362
|
-
...PHDocumentFields
|
|
363
|
-
}
|
|
364
|
-
totalCount
|
|
365
|
-
hasNextPage
|
|
366
|
-
hasPreviousPage
|
|
367
|
-
cursor
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
${PhDocumentFieldsFragmentDoc}
|
|
371
|
-
`;
|
|
372
|
-
gql`
|
|
373
|
-
query FindDocuments(
|
|
374
|
-
$search: SearchFilterInput
|
|
375
|
-
$view: ViewFilterInput
|
|
376
|
-
$paging: PagingInput
|
|
377
|
-
) {
|
|
378
|
-
findDocuments(search: $search, view: $view, paging: $paging) {
|
|
379
|
-
items {
|
|
380
|
-
...PHDocumentFields
|
|
381
|
-
}
|
|
382
|
-
totalCount
|
|
383
|
-
hasNextPage
|
|
384
|
-
hasPreviousPage
|
|
385
|
-
cursor
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
${PhDocumentFieldsFragmentDoc}
|
|
389
|
-
`;
|
|
390
|
-
const GetDocumentOperationsDocument = gql`
|
|
391
|
-
query GetDocumentOperations(
|
|
392
|
-
$filter: OperationsFilterInput!
|
|
393
|
-
$paging: PagingInput
|
|
394
|
-
) {
|
|
395
|
-
documentOperations(filter: $filter, paging: $paging) {
|
|
396
|
-
items {
|
|
397
|
-
index
|
|
398
|
-
timestampUtcMs
|
|
399
|
-
hash
|
|
400
|
-
skip
|
|
401
|
-
error
|
|
402
|
-
id
|
|
403
|
-
action {
|
|
404
|
-
id
|
|
405
|
-
type
|
|
406
|
-
timestampUtcMs
|
|
407
|
-
input
|
|
408
|
-
scope
|
|
409
|
-
context {
|
|
410
|
-
signer {
|
|
411
|
-
user {
|
|
412
|
-
address
|
|
413
|
-
networkId
|
|
414
|
-
chainId
|
|
415
|
-
}
|
|
416
|
-
app {
|
|
417
|
-
name
|
|
418
|
-
key
|
|
419
|
-
}
|
|
420
|
-
signatures
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
totalCount
|
|
426
|
-
hasNextPage
|
|
427
|
-
hasPreviousPage
|
|
428
|
-
cursor
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
`;
|
|
432
|
-
gql`
|
|
433
|
-
query GetJobStatus($jobId: String!) {
|
|
434
|
-
jobStatus(jobId: $jobId) {
|
|
435
|
-
id
|
|
436
|
-
status
|
|
437
|
-
result
|
|
438
|
-
error
|
|
439
|
-
createdAt
|
|
440
|
-
completedAt
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
`;
|
|
444
|
-
gql`
|
|
445
|
-
mutation CreateDocument($document: JSONObject!, $parentIdentifier: String) {
|
|
446
|
-
createDocument(document: $document, parentIdentifier: $parentIdentifier) {
|
|
447
|
-
...PHDocumentFields
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
${PhDocumentFieldsFragmentDoc}
|
|
451
|
-
`;
|
|
452
|
-
gql`
|
|
453
|
-
mutation CreateEmptyDocument(
|
|
454
|
-
$documentType: String!
|
|
455
|
-
$parentIdentifier: String
|
|
456
|
-
) {
|
|
457
|
-
createEmptyDocument(
|
|
458
|
-
documentType: $documentType
|
|
459
|
-
parentIdentifier: $parentIdentifier
|
|
460
|
-
) {
|
|
461
|
-
...PHDocumentFields
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
${PhDocumentFieldsFragmentDoc}
|
|
465
|
-
`;
|
|
466
|
-
gql`
|
|
467
|
-
mutation MutateDocument(
|
|
468
|
-
$documentIdentifier: String!
|
|
469
|
-
$actions: [JSONObject!]!
|
|
470
|
-
$view: ViewFilterInput
|
|
471
|
-
) {
|
|
472
|
-
mutateDocument(
|
|
473
|
-
documentIdentifier: $documentIdentifier
|
|
474
|
-
actions: $actions
|
|
475
|
-
view: $view
|
|
476
|
-
) {
|
|
477
|
-
...PHDocumentFields
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
${PhDocumentFieldsFragmentDoc}
|
|
481
|
-
`;
|
|
482
|
-
gql`
|
|
483
|
-
mutation MutateDocumentAsync(
|
|
484
|
-
$documentIdentifier: String!
|
|
485
|
-
$actions: [JSONObject!]!
|
|
486
|
-
$view: ViewFilterInput
|
|
487
|
-
) {
|
|
488
|
-
mutateDocumentAsync(
|
|
489
|
-
documentIdentifier: $documentIdentifier
|
|
490
|
-
actions: $actions
|
|
491
|
-
view: $view
|
|
492
|
-
)
|
|
493
|
-
}
|
|
494
|
-
`;
|
|
495
|
-
gql`
|
|
496
|
-
mutation RenameDocument(
|
|
497
|
-
$documentIdentifier: String!
|
|
498
|
-
$name: String!
|
|
499
|
-
$branch: String
|
|
500
|
-
) {
|
|
501
|
-
renameDocument(
|
|
502
|
-
documentIdentifier: $documentIdentifier
|
|
503
|
-
name: $name
|
|
504
|
-
branch: $branch
|
|
505
|
-
) {
|
|
506
|
-
...PHDocumentFields
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
${PhDocumentFieldsFragmentDoc}
|
|
510
|
-
`;
|
|
511
|
-
gql`
|
|
512
|
-
mutation SetPreferredEditor(
|
|
513
|
-
$documentIdentifier: String!
|
|
514
|
-
$preferredEditor: String
|
|
515
|
-
$branch: String
|
|
516
|
-
) {
|
|
517
|
-
setPreferredEditor(
|
|
518
|
-
documentIdentifier: $documentIdentifier
|
|
519
|
-
preferredEditor: $preferredEditor
|
|
520
|
-
branch: $branch
|
|
521
|
-
) {
|
|
522
|
-
...PHDocumentFields
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
${PhDocumentFieldsFragmentDoc}
|
|
526
|
-
`;
|
|
527
|
-
gql`
|
|
528
|
-
mutation AddRelationship(
|
|
529
|
-
$sourceIdentifier: String!
|
|
530
|
-
$targetIdentifier: String!
|
|
531
|
-
$relationshipType: String!
|
|
532
|
-
$branch: String
|
|
533
|
-
) {
|
|
534
|
-
addRelationship(
|
|
535
|
-
sourceIdentifier: $sourceIdentifier
|
|
536
|
-
targetIdentifier: $targetIdentifier
|
|
537
|
-
relationshipType: $relationshipType
|
|
538
|
-
branch: $branch
|
|
539
|
-
) {
|
|
540
|
-
...PHDocumentFields
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
${PhDocumentFieldsFragmentDoc}
|
|
544
|
-
`;
|
|
545
|
-
gql`
|
|
546
|
-
mutation RemoveRelationship(
|
|
547
|
-
$sourceIdentifier: String!
|
|
548
|
-
$targetIdentifier: String!
|
|
549
|
-
$relationshipType: String!
|
|
550
|
-
$branch: String
|
|
551
|
-
) {
|
|
552
|
-
removeRelationship(
|
|
553
|
-
sourceIdentifier: $sourceIdentifier
|
|
554
|
-
targetIdentifier: $targetIdentifier
|
|
555
|
-
relationshipType: $relationshipType
|
|
556
|
-
branch: $branch
|
|
557
|
-
) {
|
|
558
|
-
...PHDocumentFields
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
${PhDocumentFieldsFragmentDoc}
|
|
562
|
-
`;
|
|
563
|
-
gql`
|
|
564
|
-
mutation MoveRelationship(
|
|
565
|
-
$sourceParentIdentifier: String!
|
|
566
|
-
$targetParentIdentifier: String!
|
|
567
|
-
$targetIdentifier: String!
|
|
568
|
-
$relationshipType: String!
|
|
569
|
-
$branch: String
|
|
570
|
-
) {
|
|
571
|
-
moveRelationship(
|
|
572
|
-
sourceParentIdentifier: $sourceParentIdentifier
|
|
573
|
-
targetParentIdentifier: $targetParentIdentifier
|
|
574
|
-
targetIdentifier: $targetIdentifier
|
|
575
|
-
relationshipType: $relationshipType
|
|
576
|
-
branch: $branch
|
|
577
|
-
) {
|
|
578
|
-
source {
|
|
579
|
-
...PHDocumentFields
|
|
580
|
-
}
|
|
581
|
-
target {
|
|
582
|
-
...PHDocumentFields
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
${PhDocumentFieldsFragmentDoc}
|
|
587
|
-
`;
|
|
588
|
-
gql`
|
|
589
|
-
mutation DeleteDocument($identifier: String!, $propagate: PropagationMode) {
|
|
590
|
-
deleteDocument(identifier: $identifier, propagate: $propagate)
|
|
591
|
-
}
|
|
592
|
-
`;
|
|
593
|
-
gql`
|
|
594
|
-
mutation DeleteDocuments(
|
|
595
|
-
$identifiers: [String!]!
|
|
596
|
-
$propagate: PropagationMode
|
|
597
|
-
) {
|
|
598
|
-
deleteDocuments(identifiers: $identifiers, propagate: $propagate)
|
|
599
|
-
}
|
|
600
|
-
`;
|
|
601
|
-
gql`
|
|
602
|
-
subscription DocumentChanges(
|
|
603
|
-
$search: SearchFilterInput
|
|
604
|
-
$view: ViewFilterInput
|
|
605
|
-
) {
|
|
606
|
-
documentChanges(search: $search, view: $view) {
|
|
607
|
-
type
|
|
608
|
-
documents {
|
|
609
|
-
...PHDocumentFields
|
|
610
|
-
}
|
|
611
|
-
context {
|
|
612
|
-
parentId
|
|
613
|
-
childId
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
${PhDocumentFieldsFragmentDoc}
|
|
618
|
-
`;
|
|
619
|
-
gql`
|
|
620
|
-
subscription JobChanges($jobId: String!) {
|
|
621
|
-
jobChanges(jobId: $jobId) {
|
|
622
|
-
jobId
|
|
623
|
-
status
|
|
624
|
-
result
|
|
625
|
-
error
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
`;
|
|
629
|
-
gql`
|
|
630
|
-
query PollSyncEnvelopes(
|
|
631
|
-
$channelId: String!
|
|
632
|
-
$outboxAck: Int!
|
|
633
|
-
$outboxLatest: Int!
|
|
634
|
-
) {
|
|
635
|
-
pollSyncEnvelopes(
|
|
636
|
-
channelId: $channelId
|
|
637
|
-
outboxAck: $outboxAck
|
|
638
|
-
outboxLatest: $outboxLatest
|
|
639
|
-
) {
|
|
640
|
-
envelopes {
|
|
641
|
-
type
|
|
642
|
-
channelMeta {
|
|
643
|
-
id
|
|
644
|
-
}
|
|
645
|
-
operations {
|
|
646
|
-
operation {
|
|
647
|
-
index
|
|
648
|
-
timestampUtcMs
|
|
649
|
-
hash
|
|
650
|
-
skip
|
|
651
|
-
error
|
|
652
|
-
id
|
|
653
|
-
action {
|
|
654
|
-
id
|
|
655
|
-
type
|
|
656
|
-
timestampUtcMs
|
|
657
|
-
input
|
|
658
|
-
scope
|
|
659
|
-
context {
|
|
660
|
-
signer {
|
|
661
|
-
user {
|
|
662
|
-
address
|
|
663
|
-
networkId
|
|
664
|
-
chainId
|
|
665
|
-
}
|
|
666
|
-
app {
|
|
667
|
-
name
|
|
668
|
-
key
|
|
669
|
-
}
|
|
670
|
-
signatures
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
context {
|
|
676
|
-
documentId
|
|
677
|
-
documentType
|
|
678
|
-
scope
|
|
679
|
-
branch
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
cursor {
|
|
683
|
-
remoteName
|
|
684
|
-
cursorOrdinal
|
|
685
|
-
lastSyncedAtUtcMs
|
|
686
|
-
}
|
|
687
|
-
key
|
|
688
|
-
dependsOn
|
|
689
|
-
}
|
|
690
|
-
ackOrdinal
|
|
691
|
-
deadLetters {
|
|
692
|
-
documentId
|
|
693
|
-
error
|
|
694
|
-
}
|
|
695
|
-
hasMore
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
`;
|
|
699
|
-
gql`
|
|
700
|
-
mutation TouchChannel($input: TouchChannelInput!) {
|
|
701
|
-
touchChannel(input: $input) {
|
|
702
|
-
success
|
|
703
|
-
ackOrdinal
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
`;
|
|
707
|
-
gql`
|
|
708
|
-
mutation PushSyncEnvelopes($envelopes: [SyncEnvelopeInput!]!) {
|
|
709
|
-
pushSyncEnvelopes(envelopes: $envelopes)
|
|
710
|
-
}
|
|
711
|
-
`;
|
|
712
|
-
/** Get the source string from a GraphQL document (string or DocumentNode). */
|
|
713
|
-
function getDocumentSource(doc) {
|
|
714
|
-
return typeof doc === "string" ? doc : doc.loc?.source.body ?? "";
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Extract the inner selection set of a named field from a GraphQL document source.
|
|
718
|
-
* Returns the `{ ... }` block including braces.
|
|
719
|
-
*/
|
|
720
|
-
function extractSelectionSet(doc, fieldName, fallback) {
|
|
721
|
-
const source = getDocumentSource(doc);
|
|
722
|
-
return new RegExp(`${fieldName}\\([^)]*\\)\\s*(\\{[\\s\\S]*\\})\\s*\\}`).exec(source)?.[1] ?? fallback;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Extract the query body and any fragment definitions from a GraphQL document.
|
|
726
|
-
* Returns { body, fragments } where body is the content inside the query `{ ... }`
|
|
727
|
-
* and fragments are any trailing fragment definitions.
|
|
728
|
-
*/
|
|
729
|
-
function extractQueryParts(doc, fallbackBody) {
|
|
730
|
-
const source = getDocumentSource(doc);
|
|
731
|
-
const queryMatch = /^[^{]*\{([\s\S]*?)\}\s*(fragment[\s\S]*)?$/.exec(source);
|
|
732
|
-
return {
|
|
733
|
-
body: queryMatch?.[1]?.trim() ?? fallbackBody,
|
|
734
|
-
fragments: queryMatch?.[2]?.trim() ?? ""
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
|
|
738
|
-
extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
|
|
739
|
-
//#endregion
|
|
740
|
-
//#region ../reactor-browser/dist/renown-D-1c_Bvx.js
|
|
741
|
-
const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
|
|
742
|
-
const renownEventFunctions = makePHEventFunctions("renown");
|
|
743
|
-
renownEventFunctions.addEventHandler;
|
|
744
|
-
/** Returns the renown instance */
|
|
745
|
-
const useRenown = renownEventFunctions.useValue;
|
|
746
|
-
renownEventFunctions.setValue;
|
|
747
|
-
/** Returns the current user from the renown instance, subscribing to user events */
|
|
748
|
-
function useUser() {
|
|
749
|
-
const renown = useRenown();
|
|
750
|
-
const [user, setUser] = useState(renown?.user);
|
|
751
|
-
useEffect(() => {
|
|
752
|
-
setUser(renown?.user);
|
|
753
|
-
if (!renown) return;
|
|
754
|
-
return renown.on("user", setUser);
|
|
755
|
-
}, [renown]);
|
|
756
|
-
return user;
|
|
757
|
-
}
|
|
758
|
-
function mergeProps(parentProps, childProps) {
|
|
759
|
-
const merged = { ...parentProps };
|
|
760
|
-
for (const key of Object.keys(childProps)) {
|
|
761
|
-
const parentValue = parentProps[key];
|
|
762
|
-
const childValue = childProps[key];
|
|
763
|
-
if (key === "style") merged[key] = {
|
|
764
|
-
...parentValue,
|
|
765
|
-
...childValue
|
|
766
|
-
};
|
|
767
|
-
else if (key === "className") merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
|
|
768
|
-
else if (typeof parentValue === "function" && typeof childValue === "function") merged[key] = (...args) => {
|
|
769
|
-
childValue(...args);
|
|
770
|
-
parentValue(...args);
|
|
771
|
-
};
|
|
772
|
-
else if (childValue !== void 0) merged[key] = childValue;
|
|
773
|
-
}
|
|
774
|
-
return merged;
|
|
775
|
-
}
|
|
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
|
-
//#endregion
|
|
786
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
787
|
-
function e$8(e, t, n) {
|
|
788
|
-
let r = (n) => e(n, ...t);
|
|
789
|
-
return n === void 0 ? r : Object.assign(r, {
|
|
790
|
-
lazy: n,
|
|
791
|
-
lazyArgs: t
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
//#endregion
|
|
795
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/purry.js
|
|
796
|
-
function t$5(t, n, r) {
|
|
797
|
-
let i = t.length - n.length;
|
|
798
|
-
if (i === 0) return t(...n);
|
|
799
|
-
if (i === 1) return e$8(t, n, r);
|
|
800
|
-
throw Error(`Wrong number of arguments`);
|
|
801
|
-
}
|
|
802
|
-
//#endregion
|
|
803
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/allPass.js
|
|
804
|
-
function t$4(...t) {
|
|
805
|
-
return t$5(n$4, t);
|
|
806
|
-
}
|
|
807
|
-
const n$4 = (e, t) => t.every((t) => t(e));
|
|
808
|
-
//#endregion
|
|
809
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/conditional-CTEJD5TX.js
|
|
810
|
-
function e$7(e, t, n) {
|
|
811
|
-
return e(n[0]) ? (e) => t(e, ...n) : t(...n);
|
|
812
|
-
}
|
|
813
|
-
function t$3(...t) {
|
|
814
|
-
return e$7(r, n$3, t);
|
|
815
|
-
}
|
|
816
|
-
function n$3(e, ...t) {
|
|
817
|
-
for (let n of t) {
|
|
818
|
-
if (typeof n == `function`) return n(e);
|
|
819
|
-
let [t, r] = n;
|
|
820
|
-
if (t(e)) return r(e);
|
|
821
|
-
}
|
|
822
|
-
throw Error(`conditional: data failed for all cases`);
|
|
823
|
-
}
|
|
824
|
-
function r(e) {
|
|
825
|
-
if (!Array.isArray(e)) return !1;
|
|
826
|
-
let [t, n, ...r] = e;
|
|
827
|
-
return typeof t == `function` && t.length <= 1 && typeof n == `function` && n.length <= 1 && r.length === 0;
|
|
828
|
-
}
|
|
829
|
-
//#endregion
|
|
830
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/constant.js
|
|
831
|
-
function e$6(e) {
|
|
832
|
-
return () => e;
|
|
833
|
-
}
|
|
834
|
-
//#endregion
|
|
835
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/hasAtLeast.js
|
|
836
|
-
function t$2(...t) {
|
|
837
|
-
return t$5(n$2, t);
|
|
838
|
-
}
|
|
839
|
-
const n$2 = (e, t) => e.length >= t;
|
|
840
|
-
//#endregion
|
|
841
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/funnel.js
|
|
842
|
-
const e$5 = Symbol(`funnel/voidReducer`), t$1 = () => e$5;
|
|
843
|
-
function n$1(n, { triggerAt: r = `end`, minQuietPeriodMs: i, maxBurstDurationMs: a, minGapMs: o, reducer: s = t$1 }) {
|
|
844
|
-
let c, l, u, d, f = () => {
|
|
845
|
-
let t = u;
|
|
846
|
-
t !== void 0 && (u = void 0, t === e$5 ? n() : n(t), o !== void 0 && (l = setTimeout(p, o)));
|
|
847
|
-
}, p = () => {
|
|
848
|
-
clearTimeout(l), l = void 0, c === void 0 && f();
|
|
849
|
-
}, m = () => {
|
|
850
|
-
clearTimeout(c), c = void 0, d = void 0, l === void 0 && f();
|
|
851
|
-
};
|
|
852
|
-
return {
|
|
853
|
-
call: (...e) => {
|
|
854
|
-
let t = c === void 0 && l === void 0;
|
|
855
|
-
if ((r !== `start` || t) && (u = s(u, ...e)), !(c === void 0 && !t)) {
|
|
856
|
-
if (i !== void 0 || a !== void 0 || o === void 0) {
|
|
857
|
-
clearTimeout(c);
|
|
858
|
-
let e = Date.now();
|
|
859
|
-
d ??= e;
|
|
860
|
-
let t = a === void 0 ? i ?? 0 : Math.min(i ?? a, Math.max(0, a - (e - d)));
|
|
861
|
-
c = setTimeout(m, t);
|
|
862
|
-
}
|
|
863
|
-
r !== `end` && t && f();
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
cancel: () => {
|
|
867
|
-
clearTimeout(c), c = void 0, d = void 0, clearTimeout(l), l = void 0, u = void 0;
|
|
868
|
-
},
|
|
869
|
-
flush: () => {
|
|
870
|
-
m(), p();
|
|
871
|
-
},
|
|
872
|
-
get isIdle() {
|
|
873
|
-
return c === void 0 && l === void 0;
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isDefined.js
|
|
879
|
-
function e$4(e) {
|
|
880
|
-
return e !== void 0;
|
|
881
|
-
}
|
|
882
|
-
//#endregion
|
|
883
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isNot.js
|
|
884
|
-
function e$3(e) {
|
|
885
|
-
return (t) => !e(t);
|
|
886
|
-
}
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isStrictEqual.js
|
|
889
|
-
function t(...t) {
|
|
890
|
-
return t$5(n, t);
|
|
891
|
-
}
|
|
892
|
-
const n = (e, t) => e === t || Object.is(e, t);
|
|
893
|
-
//#endregion
|
|
894
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isString.js
|
|
895
|
-
function e$2(e) {
|
|
896
|
-
return typeof e == `string`;
|
|
897
|
-
}
|
|
898
|
-
//#endregion
|
|
899
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isTruthy.js
|
|
900
|
-
function e$1(e) {
|
|
901
|
-
return !!e;
|
|
902
|
-
}
|
|
903
|
-
//#endregion
|
|
904
|
-
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/once.js
|
|
905
|
-
function e(e) {
|
|
906
|
-
let t = !1, n;
|
|
907
|
-
return () => (t ||= (n = e(), !0), n);
|
|
908
|
-
}
|
|
909
|
-
//#endregion
|
|
910
|
-
//#region ../../node_modules/.pnpm/slug@11.0.1/node_modules/slug/slug.js
|
|
911
|
-
let base64;
|
|
912
|
-
if (typeof window !== "undefined") if (window.btoa) base64 = function(input) {
|
|
913
|
-
return btoa(unescape(encodeURIComponent(input)));
|
|
914
|
-
};
|
|
915
|
-
else base64 = function(input) {
|
|
916
|
-
const str = unescape(encodeURIComponent(input + ""));
|
|
917
|
-
let output = "";
|
|
918
|
-
for (let block, charCode, idx = 0, map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; str.charAt(idx | 0) || (map = "=", idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
|
|
919
|
-
charCode = str.charCodeAt(idx += 3 / 4);
|
|
920
|
-
/* c8 ignore next 3 */
|
|
921
|
-
if (charCode > 255) throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
|
922
|
-
block = block << 8 | charCode;
|
|
923
|
-
}
|
|
924
|
-
return output;
|
|
925
|
-
};
|
|
926
|
-
else base64 = function(input) {
|
|
927
|
-
return Buffer.from(input).toString("base64");
|
|
928
|
-
};
|
|
929
|
-
function slug(string, opts) {
|
|
930
|
-
let result = slugify(string, opts);
|
|
931
|
-
if ((opts && opts.fallback !== void 0 ? opts.fallback : slug.defaults.fallback) === true && result === "") result = slugify(base64(string), opts);
|
|
932
|
-
return result;
|
|
246
|
+
//#region ../../node_modules/.pnpm/slug@11.0.1/node_modules/slug/slug.js
|
|
247
|
+
let base64;
|
|
248
|
+
if (typeof window !== "undefined") if (window.btoa) base64 = function(input) {
|
|
249
|
+
return btoa(unescape(encodeURIComponent(input)));
|
|
250
|
+
};
|
|
251
|
+
else base64 = function(input) {
|
|
252
|
+
const str = unescape(encodeURIComponent(input + ""));
|
|
253
|
+
let output = "";
|
|
254
|
+
for (let block, charCode, idx = 0, map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; str.charAt(idx | 0) || (map = "=", idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
|
|
255
|
+
charCode = str.charCodeAt(idx += 3 / 4);
|
|
256
|
+
/* c8 ignore next 3 */
|
|
257
|
+
if (charCode > 255) throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
|
258
|
+
block = block << 8 | charCode;
|
|
259
|
+
}
|
|
260
|
+
return output;
|
|
261
|
+
};
|
|
262
|
+
else base64 = function(input) {
|
|
263
|
+
return Buffer.from(input).toString("base64");
|
|
264
|
+
};
|
|
265
|
+
function slug(string, opts) {
|
|
266
|
+
let result = slugify(string, opts);
|
|
267
|
+
if ((opts && opts.fallback !== void 0 ? opts.fallback : slug.defaults.fallback) === true && result === "") result = slugify(base64(string), opts);
|
|
268
|
+
return result;
|
|
933
269
|
}
|
|
934
270
|
const locales = {
|
|
935
271
|
bg: {
|
|
@@ -1693,715 +1029,1073 @@ slug.setLocale = function(locale) {
|
|
|
1693
1029
|
defaultLocale = locales[locale] || {};
|
|
1694
1030
|
};
|
|
1695
1031
|
//#endregion
|
|
1696
|
-
//#region
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
|
|
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;
|
|
1032
|
+
//#region ../reactor-browser/dist/document-model-modules-DfQBNGc-.js
|
|
1033
|
+
var UnsupportedDocumentTypeError = class extends Error {
|
|
1034
|
+
constructor(documentType) {
|
|
1035
|
+
super(`Document type ${documentType} is not supported`);
|
|
1036
|
+
this.name = "UnsupportedDocumentTypeError";
|
|
1037
|
+
}
|
|
1038
|
+
static isError(error) {
|
|
1039
|
+
return Error.isError(error) && error.name === "UnsupportedDocumentTypeError";
|
|
1715
1040
|
}
|
|
1716
|
-
if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
|
|
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
1041
|
};
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1042
|
+
var DocumentModelNotFoundError = class extends Error {
|
|
1043
|
+
documentType;
|
|
1044
|
+
name = "DocumentModelNotFoundError";
|
|
1045
|
+
constructor(documentType) {
|
|
1046
|
+
super(`Document model module for type ${documentType} not found`);
|
|
1047
|
+
this.documentType = documentType;
|
|
1048
|
+
}
|
|
1049
|
+
static isError(error) {
|
|
1050
|
+
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
1051
|
+
}
|
|
1736
1052
|
};
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
|
|
1742
|
-
else if (error.errors !== void 0) deleteAggregateErrors(error);
|
|
1053
|
+
var DocumentTypeMismatchError = class extends Error {
|
|
1054
|
+
constructor(documentId, expectedType, actualType) {
|
|
1055
|
+
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
1056
|
+
}
|
|
1743
1057
|
};
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
if (error.errors !== void 0) setErrorProperty(error, "errors", []);
|
|
1058
|
+
var NoSelectedDocumentError = class extends Error {
|
|
1059
|
+
constructor() {
|
|
1060
|
+
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
1061
|
+
}
|
|
1749
1062
|
};
|
|
1750
|
-
|
|
1751
|
-
|
|
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;
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
const hasErrorTag = (value) => {
|
|
1769
|
-
try {
|
|
1770
|
-
return ERROR_TAGS.has(Object.prototype.toString.call(value));
|
|
1771
|
-
} catch {
|
|
1772
|
-
return false;
|
|
1773
|
-
}
|
|
1774
|
-
};
|
|
1775
|
-
const ERROR_TAGS = new Set([
|
|
1776
|
-
"[object Error]",
|
|
1777
|
-
"[object DOMException]",
|
|
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);
|
|
1063
|
+
function resolveUrlPathname(path) {
|
|
1064
|
+
return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
|
|
1787
1065
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
const
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1066
|
+
/** Returns the current path without the base path */
|
|
1067
|
+
function getPathWithoutBase(path) {
|
|
1068
|
+
const basePath = window.ph?.basePath ?? "/";
|
|
1069
|
+
return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
|
|
1070
|
+
}
|
|
1071
|
+
/** Makes a URL component for a node. */
|
|
1072
|
+
function makeNodeSlug(node) {
|
|
1073
|
+
if (!node) return "";
|
|
1074
|
+
const nodeName = node.name;
|
|
1075
|
+
if (!nodeName) return slug(node.id);
|
|
1076
|
+
return slug(`${nodeName}-${node.id}`);
|
|
1077
|
+
}
|
|
1078
|
+
/** Extracts the node slug from a path.
|
|
1079
|
+
*
|
|
1080
|
+
* The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
|
|
1081
|
+
*/
|
|
1082
|
+
function extractNodeSlugFromPath(path) {
|
|
1083
|
+
const currentPath = getPathWithoutBase(path);
|
|
1084
|
+
return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
|
|
1085
|
+
}
|
|
1086
|
+
/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
|
|
1087
|
+
function findUuid(input) {
|
|
1088
|
+
if (!input) return void 0;
|
|
1089
|
+
return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
|
|
1090
|
+
}
|
|
1091
|
+
function extractNodeIdFromSlug(nodeSlug) {
|
|
1092
|
+
return findUuid(nodeSlug);
|
|
1093
|
+
}
|
|
1094
|
+
/** Extracts the drive slug from a path.
|
|
1095
|
+
* Used for extracting drive ids from drive slugs in the URL.
|
|
1096
|
+
* Expects the path to be in the format `/d/<drive-slug>`.
|
|
1097
|
+
*/
|
|
1098
|
+
function extractDriveSlugFromPath(path) {
|
|
1099
|
+
const currentPath = getPathWithoutBase(path);
|
|
1100
|
+
return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Creates a URL string with the given pathname while preserving existing query parameters.
|
|
1104
|
+
*/
|
|
1105
|
+
function createUrlWithPreservedParams(pathname) {
|
|
1106
|
+
const search = window.location.search;
|
|
1107
|
+
return search ? `${pathname}${search}` : pathname;
|
|
1108
|
+
}
|
|
1109
|
+
const drivesEventFunctions = makePHEventFunctions("drives");
|
|
1110
|
+
/** Returns all of the drives in the reactor */
|
|
1111
|
+
const useDrives = drivesEventFunctions.useValue;
|
|
1112
|
+
/** Sets the drives in the reactor */
|
|
1113
|
+
const setDrives = drivesEventFunctions.setValue;
|
|
1114
|
+
drivesEventFunctions.addEventHandler;
|
|
1115
|
+
const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
|
|
1116
|
+
const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
|
|
1117
|
+
const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
|
|
1118
|
+
selectedNodeIdEventFunctions.addEventHandler;
|
|
1119
|
+
/** Sets the selected node (file or folder). */
|
|
1120
|
+
function setSelectedNode(nodeOrNodeSlug) {
|
|
1121
|
+
const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
|
|
1122
|
+
setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
|
|
1123
|
+
const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
|
|
1124
|
+
if (!driveSlugFromPath) return;
|
|
1125
|
+
if (!nodeSlug) {
|
|
1126
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
|
|
1127
|
+
if (pathname === window.location.pathname) return;
|
|
1128
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1129
|
+
return;
|
|
1801
1130
|
}
|
|
1802
|
-
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
const
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
const value = object[propName];
|
|
1829
|
-
const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
|
|
1830
|
-
Object.defineProperty(objectCopy, propName, {
|
|
1831
|
-
value,
|
|
1832
|
-
enumerable,
|
|
1833
|
-
configurable,
|
|
1834
|
-
writable
|
|
1835
|
-
});
|
|
1836
|
-
} catch {}
|
|
1837
|
-
return objectCopy;
|
|
1838
|
-
};
|
|
1839
|
-
const getPropsToCopy = (object) => {
|
|
1840
|
-
const propNames = getOwnKeys(object);
|
|
1841
|
-
for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
|
|
1842
|
-
return propNames;
|
|
1843
|
-
};
|
|
1844
|
-
const getOwnKeys = (object) => {
|
|
1845
|
-
try {
|
|
1846
|
-
return Reflect.ownKeys(object);
|
|
1847
|
-
} catch {
|
|
1848
|
-
return [];
|
|
1131
|
+
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
|
|
1132
|
+
if (pathname === window.location.pathname) return;
|
|
1133
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1134
|
+
}
|
|
1135
|
+
const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
|
|
1136
|
+
/** Returns the selected drive id */
|
|
1137
|
+
const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
|
|
1138
|
+
/** Sets the selected drive id */
|
|
1139
|
+
const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
|
|
1140
|
+
selectedDriveIdEventFunctions.addEventHandler;
|
|
1141
|
+
/** Returns the selected drive, or undefined if no drive is selected */
|
|
1142
|
+
function useSelectedDriveSafe() {
|
|
1143
|
+
const selectedDriveId = useSelectedDriveId();
|
|
1144
|
+
const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
|
|
1145
|
+
const [drive, dispatch] = useDispatch(selectedDrive);
|
|
1146
|
+
if (!selectedDrive) return [void 0, void 0];
|
|
1147
|
+
return [drive, dispatch];
|
|
1148
|
+
}
|
|
1149
|
+
function setSelectedDrive(driveOrDriveSlug) {
|
|
1150
|
+
const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
|
|
1151
|
+
const drives = window.ph?.drives;
|
|
1152
|
+
const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
|
|
1153
|
+
if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
|
|
1154
|
+
if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
|
|
1155
|
+
deferDriveSelection(driveSlug);
|
|
1156
|
+
return;
|
|
1849
1157
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1158
|
+
cancelPendingDriveSelection();
|
|
1159
|
+
setSelectedDriveId(driveId);
|
|
1160
|
+
if (!driveId) {
|
|
1161
|
+
const pathname = resolveUrlPathname("/");
|
|
1162
|
+
if (pathname === window.location.pathname) return;
|
|
1163
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1164
|
+
return;
|
|
1856
1165
|
}
|
|
1857
|
-
};
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1166
|
+
const pathname = resolveUrlPathname(`/d/${driveSlug}`);
|
|
1167
|
+
if (pathname === window.location.pathname) return;
|
|
1168
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1169
|
+
}
|
|
1170
|
+
const DEFERRED_DRIVE_TICK_MS = 2e3;
|
|
1171
|
+
const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
|
|
1172
|
+
function isInitialSyncInFlight() {
|
|
1173
|
+
const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
|
|
1174
|
+
if (!remotes?.length) return false;
|
|
1175
|
+
return remotes.some((remote) => {
|
|
1176
|
+
try {
|
|
1177
|
+
const snapshot = remote.channel.getConnectionState();
|
|
1178
|
+
return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
|
|
1179
|
+
} catch {
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1872
1182
|
});
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
} catch {
|
|
1881
|
-
return safeStringify(object);
|
|
1183
|
+
}
|
|
1184
|
+
let pendingHandler;
|
|
1185
|
+
let pendingTimeout;
|
|
1186
|
+
function cancelPendingDriveSelection() {
|
|
1187
|
+
if (pendingHandler) {
|
|
1188
|
+
window.removeEventListener("ph:drivesUpdated", pendingHandler);
|
|
1189
|
+
pendingHandler = void 0;
|
|
1882
1190
|
}
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
return String(object);
|
|
1887
|
-
} catch {
|
|
1888
|
-
return "Invalid error";
|
|
1889
|
-
}
|
|
1890
|
-
};
|
|
1891
|
-
const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
|
|
1892
|
-
const MESSAGE_MAX_SIZE = 1e3;
|
|
1893
|
-
const newError = (name, message) => {
|
|
1894
|
-
if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
|
|
1895
|
-
if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
|
|
1896
|
-
return new Error(message);
|
|
1897
|
-
};
|
|
1898
|
-
const NATIVE_ERRORS = {
|
|
1899
|
-
Error,
|
|
1900
|
-
ReferenceError,
|
|
1901
|
-
TypeError,
|
|
1902
|
-
SyntaxError,
|
|
1903
|
-
RangeError,
|
|
1904
|
-
URIError,
|
|
1905
|
-
EvalError
|
|
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) => {
|
|
1916
|
-
try {
|
|
1917
|
-
const error = new Error(String(value));
|
|
1918
|
-
setStack(error);
|
|
1919
|
-
return error;
|
|
1920
|
-
} catch (error_) {
|
|
1921
|
-
return error_;
|
|
1922
|
-
}
|
|
1923
|
-
};
|
|
1924
|
-
//#endregion
|
|
1925
|
-
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
|
|
1926
|
-
const { toString: objectToString } = Object.prototype;
|
|
1927
|
-
const createError = (value) => {
|
|
1928
|
-
if (isErrorPlainObj(value)) return objectifyError(value);
|
|
1929
|
-
if (!isErrorInstance(value)) return stringifyError(value);
|
|
1930
|
-
if (isInvalidError(value)) return objectifyError(value);
|
|
1931
|
-
return value;
|
|
1932
|
-
};
|
|
1933
|
-
const isErrorPlainObj = (value) => {
|
|
1934
|
-
try {
|
|
1935
|
-
return isPlainObject(value);
|
|
1936
|
-
} catch {
|
|
1937
|
-
return false;
|
|
1191
|
+
if (pendingTimeout) {
|
|
1192
|
+
clearTimeout(pendingTimeout);
|
|
1193
|
+
pendingTimeout = void 0;
|
|
1938
1194
|
}
|
|
1195
|
+
}
|
|
1196
|
+
function deferDriveSelection(driveSlug) {
|
|
1197
|
+
cancelPendingDriveSelection();
|
|
1198
|
+
const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
|
|
1199
|
+
const handler = () => {
|
|
1200
|
+
if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
|
|
1201
|
+
cancelPendingDriveSelection();
|
|
1202
|
+
setSelectedDrive(driveSlug);
|
|
1203
|
+
setSelectedNode(nodeSlug);
|
|
1204
|
+
};
|
|
1205
|
+
pendingHandler = handler;
|
|
1206
|
+
window.addEventListener("ph:drivesUpdated", handler);
|
|
1207
|
+
const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
|
|
1208
|
+
const scheduleTick = () => {
|
|
1209
|
+
pendingTimeout = setTimeout(() => {
|
|
1210
|
+
if (Date.now() < deadline && isInitialSyncInFlight()) {
|
|
1211
|
+
scheduleTick();
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
cancelPendingDriveSelection();
|
|
1215
|
+
const pathname = resolveUrlPathname("/");
|
|
1216
|
+
if (pathname === window.location.pathname) return;
|
|
1217
|
+
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
1218
|
+
}, DEFERRED_DRIVE_TICK_MS);
|
|
1219
|
+
};
|
|
1220
|
+
scheduleTick();
|
|
1221
|
+
}
|
|
1222
|
+
/** Sorts nodes by name. */
|
|
1223
|
+
function sortNodesByName(nodes) {
|
|
1224
|
+
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
1225
|
+
}
|
|
1226
|
+
/** Returns whether a node is a file. */
|
|
1227
|
+
function isFileNodeKind(node) {
|
|
1228
|
+
if (!node) return false;
|
|
1229
|
+
return node.kind.toUpperCase() === "FILE";
|
|
1230
|
+
}
|
|
1231
|
+
/** Returns whether a node is a folder. */
|
|
1232
|
+
function isFolderNodeKind(node) {
|
|
1233
|
+
if (!node) return false;
|
|
1234
|
+
return node.kind.toUpperCase() === "FOLDER";
|
|
1235
|
+
}
|
|
1236
|
+
/** Returns the nodes in the selected drive. */
|
|
1237
|
+
function useNodesInSelectedDrive() {
|
|
1238
|
+
const [selectedDrive] = useSelectedDriveSafe();
|
|
1239
|
+
return selectedDrive?.state.global.nodes;
|
|
1240
|
+
}
|
|
1241
|
+
/** Returns the folder nodes in the selected drive. */
|
|
1242
|
+
function useFolderNodesInSelectedDrive() {
|
|
1243
|
+
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
1244
|
+
}
|
|
1245
|
+
/** Returns the selected node. */
|
|
1246
|
+
function useSelectedNode() {
|
|
1247
|
+
const selectedNodeId = useSelectedNodeId();
|
|
1248
|
+
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
1249
|
+
}
|
|
1250
|
+
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
1251
|
+
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
1252
|
+
const EMPTY_VETRA_PACKAGES = [];
|
|
1253
|
+
const noPackageManagerUnsubscribe = () => {};
|
|
1254
|
+
/**
|
|
1255
|
+
* Returns all of the Vetra packages loaded by the Connect instance.
|
|
1256
|
+
*
|
|
1257
|
+
* The snapshot and subscription must keep stable identity while no package
|
|
1258
|
+
* manager is registered: `useSyncExternalStore` loops when the snapshot
|
|
1259
|
+
* changes on every read, which a fresh `[]` does.
|
|
1260
|
+
*/
|
|
1261
|
+
const useVetraPackages = () => {
|
|
1262
|
+
const packageManager = useVetraPackageManager();
|
|
1263
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : noPackageManagerUnsubscribe, () => packageManager?.packages ?? EMPTY_VETRA_PACKAGES);
|
|
1939
1264
|
};
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1265
|
+
vetraPackageManagerFunctions.addEventHandler;
|
|
1266
|
+
function useDocumentModelModules() {
|
|
1267
|
+
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);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Resolves a document model module by document type, mirroring the registry's
|
|
1271
|
+
* semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
|
|
1272
|
+
* LATEST version of the type wins (`version ?? 1` as each module's default),
|
|
1273
|
+
* with `version` given only an exact match is returned. The reactor resolves
|
|
1274
|
+
* modules the same way when a document is created, so metadata read through
|
|
1275
|
+
* this hook and the version a creation actually uses cannot disagree.
|
|
1276
|
+
*/
|
|
1277
|
+
function useDocumentModelModuleById(id, version) {
|
|
1278
|
+
const documentModelModules = useDocumentModelModules();
|
|
1279
|
+
if (!id || !documentModelModules) return void 0;
|
|
1280
|
+
let latestModule;
|
|
1281
|
+
let latestVersion = -1;
|
|
1282
|
+
for (const module of documentModelModules) {
|
|
1283
|
+
if (module.documentModel.global.id !== id) continue;
|
|
1284
|
+
const moduleVersion = module.version ?? 1;
|
|
1285
|
+
if (version !== void 0) {
|
|
1286
|
+
if (moduleVersion === version) return module;
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
1289
|
+
if (moduleVersion > latestVersion) {
|
|
1290
|
+
latestVersion = moduleVersion;
|
|
1291
|
+
latestModule = module;
|
|
1292
|
+
}
|
|
1946
1293
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
1952
|
-
const recurseException = (error, parents, shallow) => {
|
|
1953
|
-
if (parents.includes(error)) return;
|
|
1954
|
-
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
1955
|
-
const errorA = createError(error);
|
|
1956
|
-
normalizeProps(errorA, recurse);
|
|
1957
|
-
return errorA;
|
|
1958
|
-
};
|
|
1959
|
-
const identity = (error) => error;
|
|
1960
|
-
const normalizeProps = (error, recurse) => {
|
|
1961
|
-
normalizeName(error);
|
|
1962
|
-
normalizeMessage(error);
|
|
1963
|
-
normalizeStack(error);
|
|
1964
|
-
normalizeCause(error, recurse);
|
|
1965
|
-
normalizeAggregate(error, recurse);
|
|
1966
|
-
normalizeDescriptors(error);
|
|
1967
|
-
};
|
|
1968
|
-
const normalizeName = (error) => {
|
|
1969
|
-
if (isDefinedString(error.name)) return;
|
|
1970
|
-
const prototypeName = Object.getPrototypeOf(error).name;
|
|
1971
|
-
setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
|
|
1972
|
-
};
|
|
1973
|
-
const normalizeMessage = (error) => {
|
|
1974
|
-
if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
|
|
1975
|
-
};
|
|
1976
|
-
const normalizeStack = (error) => {
|
|
1977
|
-
if (!isDefinedString(error.stack)) setStack(error);
|
|
1978
|
-
};
|
|
1979
|
-
const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
1294
|
+
return latestModule;
|
|
1295
|
+
}
|
|
1296
|
+
Error;
|
|
1297
|
+
JSON;
|
|
1980
1298
|
//#endregion
|
|
1981
|
-
//#region ../reactor-browser/dist/
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
1299
|
+
//#region ../reactor-browser/dist/client-D66jVnot.js
|
|
1300
|
+
let DocumentChangeType = /* @__PURE__ */ function(DocumentChangeType) {
|
|
1301
|
+
DocumentChangeType["ChildAdded"] = "CHILD_ADDED";
|
|
1302
|
+
DocumentChangeType["ChildRemoved"] = "CHILD_REMOVED";
|
|
1303
|
+
DocumentChangeType["Created"] = "CREATED";
|
|
1304
|
+
DocumentChangeType["Deleted"] = "DELETED";
|
|
1305
|
+
DocumentChangeType["ParentAdded"] = "PARENT_ADDED";
|
|
1306
|
+
DocumentChangeType["ParentRemoved"] = "PARENT_REMOVED";
|
|
1307
|
+
DocumentChangeType["Updated"] = "UPDATED";
|
|
1308
|
+
return DocumentChangeType;
|
|
1309
|
+
}({});
|
|
1310
|
+
let PropagationMode = /* @__PURE__ */ function(PropagationMode) {
|
|
1311
|
+
PropagationMode["Cascade"] = "CASCADE";
|
|
1312
|
+
PropagationMode["Orphan"] = "ORPHAN";
|
|
1313
|
+
return PropagationMode;
|
|
1314
|
+
}({});
|
|
1315
|
+
const PhDocumentFieldsFragmentDoc = gql`
|
|
1316
|
+
fragment PHDocumentFields on PHDocument {
|
|
1317
|
+
id
|
|
1318
|
+
slug
|
|
1319
|
+
name
|
|
1320
|
+
documentType
|
|
1321
|
+
state
|
|
1322
|
+
revisionsList {
|
|
1323
|
+
scope
|
|
1324
|
+
revision
|
|
1325
|
+
}
|
|
1326
|
+
createdAtUtcIso
|
|
1327
|
+
lastModifiedAtUtcIso
|
|
1328
|
+
}
|
|
1329
|
+
`;
|
|
1330
|
+
gql`
|
|
1331
|
+
query GetDocumentModels($namespace: String, $paging: PagingInput) {
|
|
1332
|
+
documentModels(namespace: $namespace, paging: $paging) {
|
|
1333
|
+
items {
|
|
1334
|
+
id
|
|
1335
|
+
name
|
|
1336
|
+
namespace
|
|
1337
|
+
version
|
|
1338
|
+
specification
|
|
1339
|
+
}
|
|
1340
|
+
totalCount
|
|
1341
|
+
hasNextPage
|
|
1342
|
+
hasPreviousPage
|
|
1343
|
+
cursor
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
`;
|
|
1347
|
+
const GetDocumentDocument = gql`
|
|
1348
|
+
query GetDocument($identifier: String!, $view: ViewFilterInput) {
|
|
1349
|
+
document(identifier: $identifier, view: $view) {
|
|
1350
|
+
document {
|
|
1351
|
+
...PHDocumentFields
|
|
1352
|
+
}
|
|
1353
|
+
childIds
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1357
|
+
`;
|
|
1358
|
+
const GetDocumentWithOperationsDocument = gql`
|
|
1359
|
+
query GetDocumentWithOperations(
|
|
1360
|
+
$identifier: String!
|
|
1361
|
+
$view: ViewFilterInput
|
|
1362
|
+
$operationsFilter: DocumentOperationsFilterInput
|
|
1363
|
+
$operationsPaging: PagingInput
|
|
1364
|
+
) {
|
|
1365
|
+
document(identifier: $identifier, view: $view) {
|
|
1366
|
+
document {
|
|
1367
|
+
...PHDocumentFields
|
|
1368
|
+
operations(filter: $operationsFilter, paging: $operationsPaging) {
|
|
1369
|
+
items {
|
|
1370
|
+
index
|
|
1371
|
+
timestampUtcMs
|
|
1372
|
+
hash
|
|
1373
|
+
skip
|
|
1374
|
+
error
|
|
1375
|
+
deniedReason
|
|
1376
|
+
id
|
|
1377
|
+
action {
|
|
1378
|
+
id
|
|
1379
|
+
type
|
|
1380
|
+
timestampUtcMs
|
|
1381
|
+
input
|
|
1382
|
+
scope
|
|
1383
|
+
context {
|
|
1384
|
+
signer {
|
|
1385
|
+
user {
|
|
1386
|
+
address
|
|
1387
|
+
networkId
|
|
1388
|
+
chainId
|
|
1389
|
+
}
|
|
1390
|
+
app {
|
|
1391
|
+
name
|
|
1392
|
+
key
|
|
1393
|
+
}
|
|
1394
|
+
signatures
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
totalCount
|
|
1400
|
+
hasNextPage
|
|
1401
|
+
hasPreviousPage
|
|
1402
|
+
cursor
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
childIds
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1409
|
+
`;
|
|
1410
|
+
gql`
|
|
1411
|
+
query GetDocumentOutgoingRelationships(
|
|
1412
|
+
$sourceIdentifier: String!
|
|
1413
|
+
$relationshipType: String!
|
|
1414
|
+
$view: ViewFilterInput
|
|
1415
|
+
$paging: PagingInput
|
|
1416
|
+
) {
|
|
1417
|
+
documentOutgoingRelationships(
|
|
1418
|
+
sourceIdentifier: $sourceIdentifier
|
|
1419
|
+
relationshipType: $relationshipType
|
|
1420
|
+
view: $view
|
|
1421
|
+
paging: $paging
|
|
1422
|
+
) {
|
|
1423
|
+
items {
|
|
1424
|
+
...PHDocumentFields
|
|
1425
|
+
}
|
|
1426
|
+
totalCount
|
|
1427
|
+
hasNextPage
|
|
1428
|
+
hasPreviousPage
|
|
1429
|
+
cursor
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1433
|
+
`;
|
|
1434
|
+
gql`
|
|
1435
|
+
query GetDocumentIncomingRelationships(
|
|
1436
|
+
$targetIdentifier: String!
|
|
1437
|
+
$relationshipType: String!
|
|
1438
|
+
$view: ViewFilterInput
|
|
1439
|
+
$paging: PagingInput
|
|
1440
|
+
) {
|
|
1441
|
+
documentIncomingRelationships(
|
|
1442
|
+
targetIdentifier: $targetIdentifier
|
|
1443
|
+
relationshipType: $relationshipType
|
|
1444
|
+
view: $view
|
|
1445
|
+
paging: $paging
|
|
1446
|
+
) {
|
|
1447
|
+
items {
|
|
1448
|
+
...PHDocumentFields
|
|
1449
|
+
}
|
|
1450
|
+
totalCount
|
|
1451
|
+
hasNextPage
|
|
1452
|
+
hasPreviousPage
|
|
1453
|
+
cursor
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1457
|
+
`;
|
|
1458
|
+
gql`
|
|
1459
|
+
query FindDocuments(
|
|
1460
|
+
$search: SearchFilterInput
|
|
1461
|
+
$view: ViewFilterInput
|
|
1462
|
+
$paging: PagingInput
|
|
1463
|
+
) {
|
|
1464
|
+
findDocuments(search: $search, view: $view, paging: $paging) {
|
|
1465
|
+
items {
|
|
1466
|
+
...PHDocumentFields
|
|
1467
|
+
}
|
|
1468
|
+
totalCount
|
|
1469
|
+
hasNextPage
|
|
1470
|
+
hasPreviousPage
|
|
1471
|
+
cursor
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1475
|
+
`;
|
|
1476
|
+
const GetDocumentOperationsDocument = gql`
|
|
1477
|
+
query GetDocumentOperations(
|
|
1478
|
+
$filter: OperationsFilterInput!
|
|
1479
|
+
$paging: PagingInput
|
|
1480
|
+
) {
|
|
1481
|
+
documentOperations(filter: $filter, paging: $paging) {
|
|
1482
|
+
items {
|
|
1483
|
+
index
|
|
1484
|
+
timestampUtcMs
|
|
1485
|
+
hash
|
|
1486
|
+
skip
|
|
1487
|
+
error
|
|
1488
|
+
deniedReason
|
|
1489
|
+
id
|
|
1490
|
+
action {
|
|
1491
|
+
id
|
|
1492
|
+
type
|
|
1493
|
+
timestampUtcMs
|
|
1494
|
+
input
|
|
1495
|
+
scope
|
|
1496
|
+
context {
|
|
1497
|
+
signer {
|
|
1498
|
+
user {
|
|
1499
|
+
address
|
|
1500
|
+
networkId
|
|
1501
|
+
chainId
|
|
1502
|
+
}
|
|
1503
|
+
app {
|
|
1504
|
+
name
|
|
1505
|
+
key
|
|
1506
|
+
}
|
|
1507
|
+
signatures
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
totalCount
|
|
1513
|
+
hasNextPage
|
|
1514
|
+
hasPreviousPage
|
|
1515
|
+
cursor
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
`;
|
|
1519
|
+
gql`
|
|
1520
|
+
query GetJobStatus($jobId: String!) {
|
|
1521
|
+
jobStatus(jobId: $jobId) {
|
|
1522
|
+
id
|
|
1523
|
+
status
|
|
1524
|
+
result
|
|
1525
|
+
error
|
|
1526
|
+
createdAt
|
|
1527
|
+
completedAt
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
`;
|
|
1531
|
+
gql`
|
|
1532
|
+
query EvaluateActions(
|
|
1533
|
+
$documentIdentifier: String!
|
|
1534
|
+
$branch: String
|
|
1535
|
+
$candidates: [ActionCandidateInput!]!
|
|
1536
|
+
) {
|
|
1537
|
+
evaluateActions(
|
|
1538
|
+
documentIdentifier: $documentIdentifier
|
|
1539
|
+
branch: $branch
|
|
1540
|
+
candidates: $candidates
|
|
1541
|
+
) {
|
|
1542
|
+
evaluations {
|
|
1543
|
+
decision
|
|
1544
|
+
reason
|
|
1545
|
+
}
|
|
1546
|
+
allAllowed
|
|
1547
|
+
anyAllowed
|
|
1548
|
+
allDenied
|
|
1549
|
+
anyDenied
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
`;
|
|
1553
|
+
gql`
|
|
1554
|
+
mutation CreateDocument($document: JSONObject!, $parentIdentifier: String) {
|
|
1555
|
+
createDocument(document: $document, parentIdentifier: $parentIdentifier) {
|
|
1556
|
+
...PHDocumentFields
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1560
|
+
`;
|
|
1561
|
+
gql`
|
|
1562
|
+
mutation CreateEmptyDocument(
|
|
1563
|
+
$documentType: String!
|
|
1564
|
+
$parentIdentifier: String
|
|
1565
|
+
) {
|
|
1566
|
+
createEmptyDocument(
|
|
1567
|
+
documentType: $documentType
|
|
1568
|
+
parentIdentifier: $parentIdentifier
|
|
1569
|
+
) {
|
|
1570
|
+
...PHDocumentFields
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1574
|
+
`;
|
|
1575
|
+
gql`
|
|
1576
|
+
mutation MutateDocument(
|
|
1577
|
+
$documentIdentifier: String!
|
|
1578
|
+
$actions: [ActionInput!]!
|
|
1579
|
+
$branch: String
|
|
1580
|
+
) {
|
|
1581
|
+
mutateDocument: execute(
|
|
1582
|
+
documentIdentifier: $documentIdentifier
|
|
1583
|
+
actions: $actions
|
|
1584
|
+
branch: $branch
|
|
1585
|
+
) {
|
|
1586
|
+
...PHDocumentFields
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1590
|
+
`;
|
|
1591
|
+
gql`
|
|
1592
|
+
mutation MutateDocumentAsync(
|
|
1593
|
+
$documentIdentifier: String!
|
|
1594
|
+
$actions: [ActionInput!]!
|
|
1595
|
+
$branch: String
|
|
1596
|
+
) {
|
|
1597
|
+
mutateDocumentAsync: executeAsync(
|
|
1598
|
+
documentIdentifier: $documentIdentifier
|
|
1599
|
+
actions: $actions
|
|
1600
|
+
branch: $branch
|
|
1601
|
+
) {
|
|
1602
|
+
id
|
|
1603
|
+
status
|
|
1604
|
+
result
|
|
1605
|
+
error
|
|
1606
|
+
createdAt
|
|
1607
|
+
completedAt
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
`;
|
|
1611
|
+
gql`
|
|
1612
|
+
mutation RenameDocument(
|
|
1613
|
+
$documentIdentifier: String!
|
|
1614
|
+
$name: String!
|
|
1615
|
+
$branch: String
|
|
1616
|
+
) {
|
|
1617
|
+
renameDocument(
|
|
1618
|
+
documentIdentifier: $documentIdentifier
|
|
1619
|
+
name: $name
|
|
1620
|
+
branch: $branch
|
|
1621
|
+
) {
|
|
1622
|
+
...PHDocumentFields
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1626
|
+
`;
|
|
1627
|
+
gql`
|
|
1628
|
+
mutation SetPreferredEditor(
|
|
1629
|
+
$documentIdentifier: String!
|
|
1630
|
+
$preferredEditor: String
|
|
1631
|
+
$branch: String
|
|
1632
|
+
) {
|
|
1633
|
+
setPreferredEditor(
|
|
1634
|
+
documentIdentifier: $documentIdentifier
|
|
1635
|
+
preferredEditor: $preferredEditor
|
|
1636
|
+
branch: $branch
|
|
1637
|
+
) {
|
|
1638
|
+
...PHDocumentFields
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1642
|
+
`;
|
|
1643
|
+
gql`
|
|
1644
|
+
mutation AddRelationship(
|
|
1645
|
+
$sourceIdentifier: String!
|
|
1646
|
+
$targetIdentifier: String!
|
|
1647
|
+
$relationshipType: String!
|
|
1648
|
+
$branch: String
|
|
1649
|
+
) {
|
|
1650
|
+
addRelationship(
|
|
1651
|
+
sourceIdentifier: $sourceIdentifier
|
|
1652
|
+
targetIdentifier: $targetIdentifier
|
|
1653
|
+
relationshipType: $relationshipType
|
|
1654
|
+
branch: $branch
|
|
1655
|
+
) {
|
|
1656
|
+
...PHDocumentFields
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1660
|
+
`;
|
|
1661
|
+
gql`
|
|
1662
|
+
mutation RemoveRelationship(
|
|
1663
|
+
$sourceIdentifier: String!
|
|
1664
|
+
$targetIdentifier: String!
|
|
1665
|
+
$relationshipType: String!
|
|
1666
|
+
$branch: String
|
|
1667
|
+
) {
|
|
1668
|
+
removeRelationship(
|
|
1669
|
+
sourceIdentifier: $sourceIdentifier
|
|
1670
|
+
targetIdentifier: $targetIdentifier
|
|
1671
|
+
relationshipType: $relationshipType
|
|
1672
|
+
branch: $branch
|
|
1673
|
+
) {
|
|
1674
|
+
...PHDocumentFields
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1678
|
+
`;
|
|
1679
|
+
gql`
|
|
1680
|
+
mutation MoveRelationship(
|
|
1681
|
+
$sourceParentIdentifier: String!
|
|
1682
|
+
$targetParentIdentifier: String!
|
|
1683
|
+
$targetIdentifier: String!
|
|
1684
|
+
$relationshipType: String!
|
|
1685
|
+
$branch: String
|
|
1686
|
+
) {
|
|
1687
|
+
moveRelationship(
|
|
1688
|
+
sourceParentIdentifier: $sourceParentIdentifier
|
|
1689
|
+
targetParentIdentifier: $targetParentIdentifier
|
|
1690
|
+
targetIdentifier: $targetIdentifier
|
|
1691
|
+
relationshipType: $relationshipType
|
|
1692
|
+
branch: $branch
|
|
1693
|
+
) {
|
|
1694
|
+
source {
|
|
1695
|
+
...PHDocumentFields
|
|
1696
|
+
}
|
|
1697
|
+
target {
|
|
1698
|
+
...PHDocumentFields
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1703
|
+
`;
|
|
1704
|
+
gql`
|
|
1705
|
+
mutation DeleteDocument($identifier: String!, $propagate: PropagationMode) {
|
|
1706
|
+
deleteDocument(identifier: $identifier, propagate: $propagate)
|
|
1707
|
+
}
|
|
1708
|
+
`;
|
|
1709
|
+
gql`
|
|
1710
|
+
mutation DeleteDocuments(
|
|
1711
|
+
$identifiers: [String!]!
|
|
1712
|
+
$propagate: PropagationMode
|
|
1713
|
+
) {
|
|
1714
|
+
deleteDocuments(identifiers: $identifiers, propagate: $propagate)
|
|
1715
|
+
}
|
|
1716
|
+
`;
|
|
1717
|
+
gql`
|
|
1718
|
+
subscription DocumentChanges(
|
|
1719
|
+
$search: SearchFilterInput
|
|
1720
|
+
$view: ViewFilterInput
|
|
1721
|
+
) {
|
|
1722
|
+
documentChanges(search: $search, view: $view) {
|
|
1723
|
+
type
|
|
1724
|
+
documents {
|
|
1725
|
+
...PHDocumentFields
|
|
1726
|
+
}
|
|
1727
|
+
context {
|
|
1728
|
+
parentId
|
|
1729
|
+
childId
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
${PhDocumentFieldsFragmentDoc}
|
|
1734
|
+
`;
|
|
1735
|
+
gql`
|
|
1736
|
+
subscription JobChanges($jobId: String!) {
|
|
1737
|
+
jobChanges(jobId: $jobId) {
|
|
1738
|
+
jobId
|
|
1739
|
+
status
|
|
1740
|
+
result
|
|
1741
|
+
error
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
`;
|
|
1745
|
+
gql`
|
|
1746
|
+
query PollSyncEnvelopes(
|
|
1747
|
+
$channelId: String!
|
|
1748
|
+
$outboxAck: Int!
|
|
1749
|
+
$outboxLatest: Int!
|
|
1750
|
+
) {
|
|
1751
|
+
pollSyncEnvelopes(
|
|
1752
|
+
channelId: $channelId
|
|
1753
|
+
outboxAck: $outboxAck
|
|
1754
|
+
outboxLatest: $outboxLatest
|
|
1755
|
+
) {
|
|
1756
|
+
envelopes {
|
|
1757
|
+
type
|
|
1758
|
+
channelMeta {
|
|
1759
|
+
id
|
|
1760
|
+
}
|
|
1761
|
+
operations {
|
|
1762
|
+
operation {
|
|
1763
|
+
index
|
|
1764
|
+
timestampUtcMs
|
|
1765
|
+
hash
|
|
1766
|
+
skip
|
|
1767
|
+
error
|
|
1768
|
+
deniedReason
|
|
1769
|
+
id
|
|
1770
|
+
action {
|
|
1771
|
+
id
|
|
1772
|
+
type
|
|
1773
|
+
timestampUtcMs
|
|
1774
|
+
input
|
|
1775
|
+
scope
|
|
1776
|
+
context {
|
|
1777
|
+
signer {
|
|
1778
|
+
user {
|
|
1779
|
+
address
|
|
1780
|
+
networkId
|
|
1781
|
+
chainId
|
|
1782
|
+
}
|
|
1783
|
+
app {
|
|
1784
|
+
name
|
|
1785
|
+
key
|
|
1786
|
+
}
|
|
1787
|
+
signatures
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
context {
|
|
1793
|
+
documentId
|
|
1794
|
+
documentType
|
|
1795
|
+
scope
|
|
1796
|
+
branch
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
cursor {
|
|
1800
|
+
remoteName
|
|
1801
|
+
cursorOrdinal
|
|
1802
|
+
lastSyncedAtUtcMs
|
|
1803
|
+
}
|
|
1804
|
+
key
|
|
1805
|
+
dependsOn
|
|
1806
|
+
}
|
|
1807
|
+
ackOrdinal
|
|
1808
|
+
deadLetters {
|
|
1809
|
+
documentId
|
|
1810
|
+
error
|
|
1811
|
+
errorType
|
|
1812
|
+
}
|
|
1813
|
+
hasMore
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
`;
|
|
1817
|
+
gql`
|
|
1818
|
+
mutation TouchChannel($input: TouchChannelInput!) {
|
|
1819
|
+
touchChannel(input: $input) {
|
|
1820
|
+
success
|
|
1821
|
+
ackOrdinal
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
`;
|
|
1825
|
+
gql`
|
|
1826
|
+
mutation PushSyncEnvelopes($envelopes: [SyncEnvelopeInput!]!) {
|
|
1827
|
+
pushSyncEnvelopes(envelopes: $envelopes)
|
|
1828
|
+
}
|
|
1829
|
+
`;
|
|
1830
|
+
/** Get the source string from a GraphQL document (string or DocumentNode). */
|
|
1831
|
+
function getDocumentSource(doc) {
|
|
1832
|
+
return typeof doc === "string" ? doc : doc.loc?.source.body ?? "";
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Extract the inner selection set of a named field from a GraphQL document source.
|
|
1836
|
+
* Returns the `{ ... }` block including braces.
|
|
1837
|
+
*/
|
|
1838
|
+
function extractSelectionSet(doc, fieldName, fallback) {
|
|
1839
|
+
const source = getDocumentSource(doc);
|
|
1840
|
+
return new RegExp(`${fieldName}\\([^)]*\\)\\s*(\\{[\\s\\S]*\\})\\s*\\}`).exec(source)?.[1] ?? fallback;
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Extract the query body and any fragment definitions from a GraphQL document.
|
|
1844
|
+
* Returns { body, fragments } where body is the content inside the query `{ ... }`
|
|
1845
|
+
* and fragments are any trailing fragment definitions.
|
|
1846
|
+
*/
|
|
1847
|
+
function extractQueryParts(doc, fallbackBody) {
|
|
1848
|
+
const source = getDocumentSource(doc);
|
|
1849
|
+
const queryMatch = /^[^{]*\{([\s\S]*?)\}\s*(fragment[\s\S]*)?$/.exec(source);
|
|
1850
|
+
return {
|
|
1851
|
+
body: queryMatch?.[1]?.trim() ?? fallbackBody,
|
|
1852
|
+
fragments: queryMatch?.[2]?.trim() ?? ""
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
|
|
1856
|
+
extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region ../reactor-browser/dist/renown-BHxwP7xU.js
|
|
1859
|
+
const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
|
|
1860
|
+
const RenownInitialUserContext = createContext({ state: "unknown" });
|
|
1861
|
+
/** First-render auth as a three-state value; use this to skip a spinner when anonymous. */
|
|
1862
|
+
function useRenownInitialAuth() {
|
|
1863
|
+
return useContext(RenownInitialUserContext);
|
|
1864
|
+
}
|
|
1865
|
+
function useRenownInitialUser() {
|
|
1866
|
+
const initial = useRenownInitialAuth();
|
|
1867
|
+
return initial.state === "authenticated" ? initial.user : void 0;
|
|
1868
|
+
}
|
|
1869
|
+
const renownEventFunctions = makePHEventFunctions("renown");
|
|
1870
|
+
renownEventFunctions.addEventHandler;
|
|
1871
|
+
/** Returns the renown instance */
|
|
1872
|
+
const useRenown = renownEventFunctions.useValue;
|
|
1873
|
+
renownEventFunctions.setValue;
|
|
1874
|
+
function jsonEqual(a, b) {
|
|
1875
|
+
if (a === b) return true;
|
|
1876
|
+
if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
|
|
1877
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
1878
|
+
const ra = a;
|
|
1879
|
+
const rb = b;
|
|
1880
|
+
const keys = Object.keys(ra).filter((k) => ra[k] !== void 0);
|
|
1881
|
+
if (keys.length !== Object.keys(rb).filter((k) => rb[k] !== void 0).length) return false;
|
|
1882
|
+
return keys.every((k) => jsonEqual(ra[k], rb[k]));
|
|
1883
|
+
}
|
|
1884
|
+
function sameUser(a, b) {
|
|
1885
|
+
return jsonEqual(a, b);
|
|
1886
|
+
}
|
|
1887
|
+
function resolveInstanceUser(instance, seed) {
|
|
1888
|
+
const restored = instance.user;
|
|
1889
|
+
if (restored) return sameUser(seed, restored) ? seed : restored;
|
|
1890
|
+
return instance.status === "initial" ? void 0 : seed;
|
|
1891
|
+
}
|
|
1892
|
+
/** Returns the current user from the renown instance, subscribing to user events */
|
|
1893
|
+
function useUser() {
|
|
1894
|
+
const renown = useRenown();
|
|
1895
|
+
const initialUser = useRenownInitialUser();
|
|
1896
|
+
const instance = renown ? renown : void 0;
|
|
1897
|
+
const [tracked, setTracked] = useState(() => ({
|
|
1898
|
+
instance,
|
|
1899
|
+
user: instance ? resolveInstanceUser(instance, initialUser) : initialUser
|
|
1900
|
+
}));
|
|
1901
|
+
const current = tracked.instance === instance ? tracked : {
|
|
1902
|
+
instance,
|
|
1903
|
+
user: instance ? resolveInstanceUser(instance, tracked.user ?? initialUser) : tracked.user
|
|
1904
|
+
};
|
|
1905
|
+
useEffect(() => {
|
|
1906
|
+
if (current !== tracked) setTracked(current);
|
|
1907
|
+
}, [current, tracked]);
|
|
1908
|
+
useEffect(() => {
|
|
1909
|
+
if (!instance) return;
|
|
1910
|
+
return instance.on("user", (user) => setTracked((prev) => ({
|
|
1911
|
+
instance,
|
|
1912
|
+
user: sameUser(prev.user, user) ? prev.user : user
|
|
1913
|
+
})));
|
|
1914
|
+
}, [instance]);
|
|
1915
|
+
return instance ? current.user : initialUser ?? current.user;
|
|
1916
|
+
}
|
|
1917
|
+
//#endregion
|
|
1918
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
|
|
1919
|
+
function e$8(e, t, n) {
|
|
1920
|
+
let r = (n) => e(n, ...t);
|
|
1921
|
+
return n === void 0 ? r : Object.assign(r, {
|
|
1922
|
+
lazy: n,
|
|
1923
|
+
lazyArgs: t
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
//#endregion
|
|
1927
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/purry.js
|
|
1928
|
+
function t$5(t, n, r) {
|
|
1929
|
+
let i = t.length - n.length;
|
|
1930
|
+
if (i === 0) return t(...n);
|
|
1931
|
+
if (i === 1) return e$8(t, n, r);
|
|
1932
|
+
throw Error(`Wrong number of arguments`);
|
|
1933
|
+
}
|
|
1934
|
+
//#endregion
|
|
1935
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/allPass.js
|
|
1936
|
+
function t$4(...t) {
|
|
1937
|
+
return t$5(n$4, t);
|
|
1938
|
+
}
|
|
1939
|
+
const n$4 = (e, t) => t.every((t) => t(e));
|
|
1940
|
+
//#endregion
|
|
1941
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/conditional-CTEJD5TX.js
|
|
1942
|
+
function e$7(e, t, n) {
|
|
1943
|
+
return e(n[0]) ? (e) => t(e, ...n) : t(...n);
|
|
1944
|
+
}
|
|
1945
|
+
function t$3(...t) {
|
|
1946
|
+
return e$7(r, n$3, t);
|
|
1947
|
+
}
|
|
1948
|
+
function n$3(e, ...t) {
|
|
1949
|
+
for (let n of t) {
|
|
1950
|
+
if (typeof n == `function`) return n(e);
|
|
1951
|
+
let [t, r] = n;
|
|
1952
|
+
if (t(e)) return r(e);
|
|
1953
|
+
}
|
|
1954
|
+
throw Error(`conditional: data failed for all cases`);
|
|
1955
|
+
}
|
|
1956
|
+
function r(e) {
|
|
1957
|
+
if (!Array.isArray(e)) return !1;
|
|
1958
|
+
let [t, n, ...r] = e;
|
|
1959
|
+
return typeof t == `function` && t.length <= 1 && typeof n == `function` && n.length <= 1 && r.length === 0;
|
|
1960
|
+
}
|
|
1961
|
+
//#endregion
|
|
1962
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/constant.js
|
|
1963
|
+
function e$6(e) {
|
|
1964
|
+
return () => e;
|
|
1965
|
+
}
|
|
1966
|
+
//#endregion
|
|
1967
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/hasAtLeast.js
|
|
1968
|
+
function t$2(...t) {
|
|
1969
|
+
return t$5(n$2, t);
|
|
1970
|
+
}
|
|
1971
|
+
const n$2 = (e, t) => e.length >= t;
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/funnel.js
|
|
1974
|
+
const e$5 = Symbol(`funnel/voidReducer`), t$1 = () => e$5;
|
|
1975
|
+
function n$1(n, { triggerAt: r = `end`, minQuietPeriodMs: i, maxBurstDurationMs: a, minGapMs: o, reducer: s = t$1 }) {
|
|
1976
|
+
let c, l, u, d, f = () => {
|
|
1977
|
+
let t = u;
|
|
1978
|
+
t !== void 0 && (u = void 0, t === e$5 ? n() : n(t), o !== void 0 && (l = setTimeout(p, o)));
|
|
1979
|
+
}, p = () => {
|
|
1980
|
+
clearTimeout(l), l = void 0, c === void 0 && f();
|
|
1981
|
+
}, m = () => {
|
|
1982
|
+
clearTimeout(c), c = void 0, d = void 0, l === void 0 && f();
|
|
1983
|
+
};
|
|
1984
|
+
return {
|
|
1985
|
+
call: (...e) => {
|
|
1986
|
+
let t = c === void 0 && l === void 0;
|
|
1987
|
+
if ((r !== `start` || t) && (u = s(u, ...e)), !(c === void 0 && !t)) {
|
|
1988
|
+
if (i !== void 0 || a !== void 0 || o === void 0) {
|
|
1989
|
+
clearTimeout(c);
|
|
1990
|
+
let e = Date.now();
|
|
1991
|
+
d ??= e;
|
|
1992
|
+
let t = a === void 0 ? i ?? 0 : Math.min(i ?? a, Math.max(0, a - (e - d)));
|
|
1993
|
+
c = setTimeout(m, t);
|
|
2371
1994
|
}
|
|
1995
|
+
r !== `end` && t && f();
|
|
2372
1996
|
}
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
1997
|
+
},
|
|
1998
|
+
cancel: () => {
|
|
1999
|
+
clearTimeout(c), c = void 0, d = void 0, clearTimeout(l), l = void 0, u = void 0;
|
|
2000
|
+
},
|
|
2001
|
+
flush: () => {
|
|
2002
|
+
m(), p();
|
|
2003
|
+
},
|
|
2004
|
+
get isIdle() {
|
|
2005
|
+
return c === void 0 && l === void 0;
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
//#endregion
|
|
2010
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isDefined.js
|
|
2011
|
+
function e$4(e) {
|
|
2012
|
+
return e !== void 0;
|
|
2013
|
+
}
|
|
2014
|
+
//#endregion
|
|
2015
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isNot.js
|
|
2016
|
+
function e$3(e) {
|
|
2017
|
+
return (t) => !e(t);
|
|
2018
|
+
}
|
|
2019
|
+
//#endregion
|
|
2020
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isStrictEqual.js
|
|
2021
|
+
function t(...t) {
|
|
2022
|
+
return t$5(n, t);
|
|
2023
|
+
}
|
|
2024
|
+
const n = (e, t) => e === t || Object.is(e, t);
|
|
2025
|
+
//#endregion
|
|
2026
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isString.js
|
|
2027
|
+
function e$2(e) {
|
|
2028
|
+
return typeof e == `string`;
|
|
2029
|
+
}
|
|
2030
|
+
//#endregion
|
|
2031
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/isTruthy.js
|
|
2032
|
+
function e$1(e) {
|
|
2033
|
+
return !!e;
|
|
2034
|
+
}
|
|
2035
|
+
//#endregion
|
|
2036
|
+
//#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/once.js
|
|
2037
|
+
function e(e) {
|
|
2038
|
+
let t = !1, n;
|
|
2039
|
+
return () => (t ||= (n = e(), !0), n);
|
|
2040
|
+
}
|
|
2041
|
+
var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
|
|
2042
|
+
CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
|
|
2043
|
+
CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
|
|
2044
|
+
CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
|
|
2045
|
+
CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
|
|
2046
|
+
CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
|
|
2047
|
+
CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
|
|
2048
|
+
CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
|
|
2049
|
+
CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
|
|
2050
|
+
CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
|
|
2051
|
+
CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
|
|
2052
|
+
CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
|
|
2053
|
+
return CloseCode2;
|
|
2054
|
+
})(CloseCode || {});
|
|
2055
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
2056
|
+
MessageType2["ConnectionInit"] = "connection_init";
|
|
2057
|
+
MessageType2["ConnectionAck"] = "connection_ack";
|
|
2058
|
+
MessageType2["Ping"] = "ping";
|
|
2059
|
+
MessageType2["Pong"] = "pong";
|
|
2060
|
+
MessageType2["Subscribe"] = "subscribe";
|
|
2061
|
+
MessageType2["Next"] = "next";
|
|
2062
|
+
MessageType2["Error"] = "error";
|
|
2063
|
+
MessageType2["Complete"] = "complete";
|
|
2064
|
+
return MessageType2;
|
|
2065
|
+
})(MessageType || {});
|
|
2066
|
+
Error;
|
|
2067
|
+
//#endregion
|
|
2068
|
+
//#region ../reactor-browser/dist/document-operations-CBExT76y.js
|
|
2069
|
+
const modalEventFunctions = makePHEventFunctions("modal");
|
|
2070
|
+
modalEventFunctions.useValue;
|
|
2071
|
+
/** Sets the current modal */
|
|
2072
|
+
const setPHModal = modalEventFunctions.setValue;
|
|
2073
|
+
modalEventFunctions.addEventHandler;
|
|
2074
|
+
/** Shows a modal */
|
|
2075
|
+
function showPHModal(modal) {
|
|
2076
|
+
setPHModal(modal);
|
|
2077
|
+
}
|
|
2078
|
+
/** Shows the delete node modal */
|
|
2079
|
+
function showDeleteNodeModal(nodeOrId) {
|
|
2080
|
+
setPHModal({
|
|
2081
|
+
type: "deleteItem",
|
|
2082
|
+
id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
|
|
2378
2083
|
});
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2084
|
+
}
|
|
2085
|
+
function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
2086
|
+
if (!supportedDocuments?.length) return true;
|
|
2087
|
+
return supportedDocuments.some((pattern) => {
|
|
2088
|
+
if (pattern.endsWith("/*")) {
|
|
2089
|
+
const prefix = pattern.slice(0, -2);
|
|
2090
|
+
return documentType.startsWith(prefix + "/");
|
|
2091
|
+
}
|
|
2092
|
+
if (pattern.endsWith("*") && !pattern.endsWith("/*")) {
|
|
2093
|
+
const prefix = pattern.slice(0, -1);
|
|
2094
|
+
return documentType.startsWith(prefix);
|
|
2095
|
+
}
|
|
2096
|
+
return pattern === documentType;
|
|
2382
2097
|
});
|
|
2383
|
-
}
|
|
2384
|
-
var DocumentModelNotFoundError = class extends Error {
|
|
2385
|
-
documentType;
|
|
2386
|
-
name = "DocumentModelNotFoundError";
|
|
2387
|
-
constructor(documentType) {
|
|
2388
|
-
super(`Document model module for type ${documentType} not found`);
|
|
2389
|
-
this.documentType = documentType;
|
|
2390
|
-
}
|
|
2391
|
-
static isError(error) {
|
|
2392
|
-
return Error.isError(error) && error.name === "DocumentModelNotFoundError";
|
|
2393
|
-
}
|
|
2394
|
-
};
|
|
2395
|
-
var DocumentTypeMismatchError = class extends Error {
|
|
2396
|
-
constructor(documentId, expectedType, actualType) {
|
|
2397
|
-
super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
|
|
2398
|
-
}
|
|
2399
|
-
};
|
|
2400
|
-
var NoSelectedDocumentError = class extends Error {
|
|
2401
|
-
constructor() {
|
|
2402
|
-
super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
|
|
2403
|
-
}
|
|
2404
|
-
};
|
|
2098
|
+
}
|
|
2405
2099
|
function getUserPermissions() {
|
|
2406
2100
|
const user = window.ph?.renown?.user;
|
|
2407
2101
|
const allowList = window.ph?.allowList;
|
|
@@ -2414,8 +2108,41 @@ function getUserPermissions() {
|
|
|
2414
2108
|
isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
|
|
2415
2109
|
};
|
|
2416
2110
|
}
|
|
2417
|
-
const BASE_STATE_KEYS = new Set(["auth"]);
|
|
2418
2111
|
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
2112
|
+
/** An unreadable drive cannot be shown to hold no duplicate, so reads throw. */
|
|
2113
|
+
async function isDocumentInLocation(reactorClient, document, driveId, parentFolder) {
|
|
2114
|
+
const drive = await reactorClient.get(driveId);
|
|
2115
|
+
const nodeById = drive.state.global.nodes.find((node) => node.id === document.header.id);
|
|
2116
|
+
if (nodeById && nodeById.parentFolder === (parentFolder ?? null)) return {
|
|
2117
|
+
isDuplicate: true,
|
|
2118
|
+
duplicateType: "id",
|
|
2119
|
+
nodeId: nodeById.id
|
|
2120
|
+
};
|
|
2121
|
+
const nodeByNameAndType = drive.state.global.nodes.find((node) => isFileNode(node) && node.name === document.header.name && node.documentType === document.header.documentType && node.parentFolder === (parentFolder ?? null));
|
|
2122
|
+
if (nodeByNameAndType) return {
|
|
2123
|
+
isDuplicate: true,
|
|
2124
|
+
duplicateType: "name",
|
|
2125
|
+
nodeId: nodeByNameAndType.id
|
|
2126
|
+
};
|
|
2127
|
+
return { isDuplicate: false };
|
|
2128
|
+
}
|
|
2129
|
+
function getDocumentTypeIcon(document) {
|
|
2130
|
+
switch (document.header.documentType) {
|
|
2131
|
+
case "powerhouse/document-model": return "document-model";
|
|
2132
|
+
case "powerhouse/app": return "app";
|
|
2133
|
+
case "powerhouse/document-editor": return "editor";
|
|
2134
|
+
case "powerhouse/subgraph": return "subgraph";
|
|
2135
|
+
case "powerhouse/package": return "package";
|
|
2136
|
+
case "powerhouse/processor": {
|
|
2137
|
+
const processorType = document.state.global?.type;
|
|
2138
|
+
if (processorType === "analytics") return "analytics-processor";
|
|
2139
|
+
if (processorType === "relational") return "relational-processor";
|
|
2140
|
+
if (processorType === "codegen") return "codegen-processor";
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
default: return;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2419
2146
|
async function downloadFile(document, fileName) {
|
|
2420
2147
|
try {
|
|
2421
2148
|
const data = await createZip(document);
|
|
@@ -2436,7 +2163,7 @@ async function getDocumentExtension(document) {
|
|
|
2436
2163
|
let rawExtension;
|
|
2437
2164
|
if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
|
|
2438
2165
|
else {
|
|
2439
|
-
const reactorClient = window.ph?.
|
|
2166
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2440
2167
|
if (reactorClient) {
|
|
2441
2168
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2442
2169
|
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
@@ -2450,7 +2177,7 @@ async function getDocumentExtension(document) {
|
|
|
2450
2177
|
* composite cursors, so all scopes are fetched in a single paginated stream.
|
|
2451
2178
|
*/
|
|
2452
2179
|
async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
|
|
2453
|
-
const scopes = Object.keys(document.state)
|
|
2180
|
+
const scopes = Object.keys(document.state);
|
|
2454
2181
|
const operations = {};
|
|
2455
2182
|
for (const scope of scopes) operations[scope] = [];
|
|
2456
2183
|
let cursor = "";
|
|
@@ -2478,6 +2205,67 @@ function extractInitialState(documentScopeOps) {
|
|
|
2478
2205
|
function filterDomainOperations(operations) {
|
|
2479
2206
|
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
2480
2207
|
}
|
|
2208
|
+
function countOperations(operations) {
|
|
2209
|
+
let total = 0;
|
|
2210
|
+
for (const ops of Object.values(operations)) total += ops?.length ?? 0;
|
|
2211
|
+
return total;
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Split an imported document's domain operations at its mid-history upgrade
|
|
2215
|
+
* boundaries, so the caller can re-dispatch each upgrade between segments.
|
|
2216
|
+
*
|
|
2217
|
+
* The seed's CREATE_DOCUMENT and 0 -> N upgrade are replayed by the creation
|
|
2218
|
+
* path and must not be repeated. A later upgrade must be: it is where the
|
|
2219
|
+
* reducer version changes, and dropping it replays everything after it through
|
|
2220
|
+
* the module the document was created with.
|
|
2221
|
+
*/
|
|
2222
|
+
function splitAtUpgradeBoundaries(operations) {
|
|
2223
|
+
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);
|
|
2224
|
+
const domain = filterDomainOperations(operations);
|
|
2225
|
+
if (upgrades.length === 0) return [{ operations: domain }];
|
|
2226
|
+
const segments = [];
|
|
2227
|
+
const consumed = /* @__PURE__ */ new Map();
|
|
2228
|
+
const take = (until) => {
|
|
2229
|
+
const slice = {};
|
|
2230
|
+
for (const [scope, ops] of Object.entries(domain)) {
|
|
2231
|
+
if (!ops) continue;
|
|
2232
|
+
const from = consumed.get(scope) ?? 0;
|
|
2233
|
+
const stop = Math.max(from, until(scope, ops));
|
|
2234
|
+
const chunk = ops.slice(from, stop);
|
|
2235
|
+
if (chunk.length > 0) slice[scope] = chunk;
|
|
2236
|
+
consumed.set(scope, stop);
|
|
2237
|
+
}
|
|
2238
|
+
return slice;
|
|
2239
|
+
};
|
|
2240
|
+
for (const upgrade of upgrades) {
|
|
2241
|
+
const input = upgrade.action.input;
|
|
2242
|
+
const slice = take((scope, ops) => boundary(upgrade, scope, ops));
|
|
2243
|
+
segments.push({
|
|
2244
|
+
operations: slice,
|
|
2245
|
+
upgradeTo: input.toVersion
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
const tail = take((_scope, ops) => ops.length);
|
|
2249
|
+
if (countOperations(tail) > 0) segments.push({ operations: tail });
|
|
2250
|
+
return segments;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* How many of a scope's operations precede an upgrade. Must stay identical to
|
|
2254
|
+
* the boundary computation in `replayDocumentVersioned` — snapshots compare
|
|
2255
|
+
* against operation indices, not array positions, and the timestamp fallback
|
|
2256
|
+
* excludes the upgrade's own instant.
|
|
2257
|
+
*/
|
|
2258
|
+
function boundary(upgrade, scope, ops) {
|
|
2259
|
+
const snapshot = upgrade.action.input.revision;
|
|
2260
|
+
if (snapshot !== void 0) {
|
|
2261
|
+
const revision = snapshot[scope] ?? 0;
|
|
2262
|
+
let count = 0;
|
|
2263
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].index < revision) count = i + 1;
|
|
2264
|
+
return count;
|
|
2265
|
+
}
|
|
2266
|
+
for (let i = 0; i < ops.length; i++) if (ops[i].timestampUtcMs >= upgrade.timestampUtcMs) return i;
|
|
2267
|
+
return ops.length;
|
|
2268
|
+
}
|
|
2481
2269
|
async function exportFile(document, suggestedName) {
|
|
2482
2270
|
const reactorClient = window.ph?.reactorClient;
|
|
2483
2271
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
@@ -2507,7 +2295,7 @@ async function exportFile(document, suggestedName) {
|
|
|
2507
2295
|
*/
|
|
2508
2296
|
async function loadFile(path) {
|
|
2509
2297
|
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
2510
|
-
const reactorClient = window.ph?.
|
|
2298
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2511
2299
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2512
2300
|
const documentType = baseDocument.header.documentType;
|
|
2513
2301
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
@@ -2525,13 +2313,20 @@ async function loadFile(path) {
|
|
|
2525
2313
|
upgradeManifest
|
|
2526
2314
|
});
|
|
2527
2315
|
}
|
|
2528
|
-
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
|
|
2316
|
+
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
2529
2317
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2530
2318
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
2531
|
-
const reactorClient = window.ph?.
|
|
2319
|
+
const reactorClient = window.ph?.reactorClientModule?.client;
|
|
2532
2320
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2533
|
-
|
|
2321
|
+
let documentModelModule;
|
|
2322
|
+
if (documentModelVersion !== void 0) {
|
|
2323
|
+
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
2324
|
+
const module = documentModelModules.find((m) => m.documentModel.global.id === documentType && (m.version ?? 1) === documentModelVersion);
|
|
2325
|
+
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
2326
|
+
documentModelModule = module;
|
|
2327
|
+
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
2534
2328
|
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
2329
|
+
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
2535
2330
|
newDocument.header.name = name;
|
|
2536
2331
|
if (preferredEditor) newDocument.header.meta = {
|
|
2537
2332
|
...newDocument.header.meta,
|
|
@@ -2552,43 +2347,210 @@ async function addDocument(driveId, name, documentType, parentFolder, document,
|
|
|
2552
2347
|
kind: "file"
|
|
2553
2348
|
};
|
|
2554
2349
|
}
|
|
2555
|
-
|
|
2556
|
-
|
|
2350
|
+
/**
|
|
2351
|
+
* How many ids an import will try before giving up. The check before the create
|
|
2352
|
+
* catches an id that is already taken; this bound covers the window between the
|
|
2353
|
+
* two, where a create can still lose to a claim made in the meantime.
|
|
2354
|
+
*/
|
|
2355
|
+
const IMPORT_ID_ATTEMPTS = 3;
|
|
2356
|
+
/** True when this error, or anything it wraps, is a taken document id. */
|
|
2357
|
+
function isDocumentAlreadyExists(error) {
|
|
2358
|
+
let current = error;
|
|
2359
|
+
while (current instanceof Error) {
|
|
2360
|
+
if (current.name === "DocumentAlreadyExistsError") return true;
|
|
2361
|
+
current = current.cause;
|
|
2362
|
+
}
|
|
2363
|
+
return false;
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Creates the imported document under an id that is free, retrying on a
|
|
2367
|
+
* collision.
|
|
2368
|
+
*
|
|
2369
|
+
* The check cannot stand on its own: it answers for the moment it ran, and the
|
|
2370
|
+
* create that follows can still land on an id claimed in between. The store
|
|
2371
|
+
* rejects that create as DocumentAlreadyExistsError, which is not retryable
|
|
2372
|
+
* under the same id and is resolved by minting another one. A create that
|
|
2373
|
+
* fails leaves the drive untouched, so a retry has nothing to clean up.
|
|
2374
|
+
*/
|
|
2375
|
+
async function createImportedDocument(reactor, document, driveId, name, parentFolder) {
|
|
2376
|
+
let documentId = await reactor.isDocumentIdTaken(document.header.id) ? generateId() : document.header.id;
|
|
2377
|
+
for (let attempt = 1;; attempt++) {
|
|
2378
|
+
const header = createPresignedHeader(documentId, document.header.documentType);
|
|
2379
|
+
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
2380
|
+
header.meta = document.header.meta;
|
|
2381
|
+
header.name = name || document.header.name;
|
|
2382
|
+
const initialDocument = {
|
|
2383
|
+
...document,
|
|
2384
|
+
header,
|
|
2385
|
+
state: document.initialState,
|
|
2386
|
+
operations: Object.keys(document.operations).reduce((acc, key) => {
|
|
2387
|
+
acc[key] = [];
|
|
2388
|
+
return acc;
|
|
2389
|
+
}, {})
|
|
2390
|
+
};
|
|
2391
|
+
try {
|
|
2392
|
+
const fileNode = await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
|
|
2393
|
+
if (!fileNode) throw new Error("There was an error adding file");
|
|
2394
|
+
return {
|
|
2395
|
+
documentId,
|
|
2396
|
+
fileNode
|
|
2397
|
+
};
|
|
2398
|
+
} catch (error) {
|
|
2399
|
+
if (!isDocumentAlreadyExists(error) || attempt === IMPORT_ID_ATTEMPTS) throw error;
|
|
2400
|
+
logger.warn(`Document id ${documentId} was taken between the check and the create; importing under a new id`);
|
|
2401
|
+
documentId = generateId();
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
2406
|
+
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
2407
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
2408
|
+
if (!reactor) {
|
|
2409
|
+
onProgress?.({
|
|
2410
|
+
stage: "failed",
|
|
2411
|
+
progress: 100,
|
|
2412
|
+
error: "ReactorClient not initialized"
|
|
2413
|
+
});
|
|
2414
|
+
throw new Error("ReactorClient not initialized");
|
|
2415
|
+
}
|
|
2557
2416
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2558
2417
|
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
2418
|
try {
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2419
|
+
onProgress?.({
|
|
2420
|
+
stage: "loading",
|
|
2421
|
+
progress: 0
|
|
2422
|
+
});
|
|
2423
|
+
let document;
|
|
2424
|
+
try {
|
|
2425
|
+
document = await loadFile(file);
|
|
2426
|
+
} catch (loadError) {
|
|
2427
|
+
if (UnsupportedDocumentModelVersionError.isError(loadError)) {
|
|
2428
|
+
showPHModal({
|
|
2429
|
+
type: "documentVersionUnsupported",
|
|
2430
|
+
documentType: loadError.documentType,
|
|
2431
|
+
requiredVersion: loadError.requiredVersion,
|
|
2432
|
+
availableVersions: loadError.availableVersions
|
|
2433
|
+
});
|
|
2434
|
+
onProgress?.({
|
|
2435
|
+
stage: "failed",
|
|
2436
|
+
progress: 100,
|
|
2437
|
+
error: loadError.message
|
|
2438
|
+
});
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
const discoveryService = window.ph?.packageDiscoveryService;
|
|
2442
|
+
if (discoveryService && DocumentModelNotFoundError.isError(loadError)) {
|
|
2443
|
+
retryAfterDiscovery(discoveryService, loadError.documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict).catch((retryError) => {
|
|
2444
|
+
logger.error("Import retry after discovery failed: @error", retryError);
|
|
2445
|
+
onProgress?.({
|
|
2446
|
+
stage: "failed",
|
|
2447
|
+
progress: 100,
|
|
2448
|
+
error: retryError instanceof Error ? retryError.message : String(retryError)
|
|
2449
|
+
});
|
|
2450
|
+
});
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
throw loadError;
|
|
2454
|
+
}
|
|
2455
|
+
const duplicateCheck = await isDocumentInLocation(reactor, document, driveId, parentFolder);
|
|
2456
|
+
if (duplicateCheck.isDuplicate && !resolveConflict) {
|
|
2457
|
+
onProgress?.({
|
|
2458
|
+
stage: "conflict",
|
|
2459
|
+
progress: 0,
|
|
2460
|
+
duplicateType: duplicateCheck.duplicateType
|
|
2461
|
+
});
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
const documentType = getDocumentTypeIcon(document);
|
|
2465
|
+
if (documentType) onProgress?.({
|
|
2466
|
+
stage: "loading",
|
|
2467
|
+
progress: 10,
|
|
2468
|
+
documentType
|
|
2469
|
+
});
|
|
2470
|
+
else onProgress?.({
|
|
2471
|
+
stage: "loading",
|
|
2472
|
+
progress: 10
|
|
2473
|
+
});
|
|
2474
|
+
if (!isDocumentTypeSupported(document.header.documentType, documentTypes)) {
|
|
2475
|
+
onProgress?.({
|
|
2476
|
+
stage: "unsupported-document-type",
|
|
2477
|
+
progress: 100,
|
|
2478
|
+
error: `Document type ${document.header.documentType} is not supported`
|
|
2479
|
+
});
|
|
2480
|
+
throw new UnsupportedDocumentTypeError(document.header.documentType);
|
|
2481
|
+
}
|
|
2482
|
+
await reactor.getDocumentModelModule(document.header.documentType);
|
|
2483
|
+
onProgress?.({
|
|
2484
|
+
stage: "initializing",
|
|
2485
|
+
progress: 10
|
|
2486
|
+
});
|
|
2487
|
+
const created = await createImportedDocument(reactor, document, driveId, name, parentFolder);
|
|
2488
|
+
const documentId = created.documentId;
|
|
2489
|
+
const fileNode = created.fileNode;
|
|
2490
|
+
onProgress?.({
|
|
2491
|
+
stage: "initializing",
|
|
2492
|
+
progress: 20
|
|
2493
|
+
});
|
|
2494
|
+
await reactor.get(documentId);
|
|
2495
|
+
console.log("Document created, starting upload of operations");
|
|
2496
|
+
const segments = splitAtUpgradeBoundaries(document.operations);
|
|
2497
|
+
const totalOperations = segments.reduce((total, segment) => total + countOperations(segment.operations), 0);
|
|
2498
|
+
let uploadedBefore = 0;
|
|
2499
|
+
for (const segment of segments) {
|
|
2500
|
+
await uploadOperations(documentId, segment.operations, queueOperations, { onProgress: (uploadProgress) => {
|
|
2501
|
+
if (uploadProgress.uploadedOperations === void 0) return;
|
|
2502
|
+
const uploaded = uploadedBefore + uploadProgress.uploadedOperations;
|
|
2503
|
+
const uploadPercent = totalOperations > 0 ? uploaded / totalOperations : 0;
|
|
2504
|
+
onProgress?.({
|
|
2505
|
+
stage: "uploading",
|
|
2506
|
+
progress: 20 + Math.round(uploadPercent * 80),
|
|
2507
|
+
totalOperations,
|
|
2508
|
+
uploadedOperations: uploaded
|
|
2509
|
+
});
|
|
2510
|
+
} });
|
|
2511
|
+
uploadedBefore += countOperations(segment.operations);
|
|
2512
|
+
if (segment.upgradeTo !== void 0) await reactor.upgradeDocument(documentId, segment.upgradeTo);
|
|
2513
|
+
}
|
|
2514
|
+
onProgress?.({
|
|
2515
|
+
stage: "complete",
|
|
2516
|
+
progress: 100,
|
|
2517
|
+
fileNode
|
|
2518
|
+
});
|
|
2519
|
+
return fileNode;
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
if (!UnsupportedDocumentTypeError.isError(error)) {
|
|
2522
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
2523
|
+
onProgress?.({
|
|
2524
|
+
stage: "failed",
|
|
2525
|
+
progress: 100,
|
|
2526
|
+
error: errorMessage
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
throw error;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
async function retryAfterDiscovery(discoveryService, documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
2533
|
+
if (!discoveryService) return;
|
|
2534
|
+
try {
|
|
2535
|
+
await discoveryService.load(documentType);
|
|
2536
|
+
} catch {
|
|
2537
|
+
onProgress?.({
|
|
2538
|
+
stage: "unsupported-document-type",
|
|
2539
|
+
progress: 100,
|
|
2540
|
+
error: `Document type ${documentType} is not supported`
|
|
2541
|
+
});
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
await addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict);
|
|
2583
2545
|
}
|
|
2584
|
-
async function addFolder(driveId, name, parentFolder) {
|
|
2546
|
+
async function addFolder$1(driveId, name, parentFolder) {
|
|
2585
2547
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2586
2548
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
2587
2549
|
const reactorClient = window.ph?.reactorClient;
|
|
2588
2550
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
2589
2551
|
await reactorClient.get(driveId);
|
|
2590
2552
|
const folderId = generateId();
|
|
2591
|
-
const node = (await reactorClient.execute(driveId, "main", [addFolder
|
|
2553
|
+
const node = (await reactorClient.execute(driveId, "main", [addFolder({
|
|
2592
2554
|
id: folderId,
|
|
2593
2555
|
name,
|
|
2594
2556
|
parentFolder
|
|
@@ -2666,10 +2628,12 @@ async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
2666
2628
|
upgradeManifest
|
|
2667
2629
|
};
|
|
2668
2630
|
const header = createPresignedHeader(newId, documentType);
|
|
2669
|
-
|
|
2631
|
+
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
2632
|
+
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
2633
|
+
return duplicated;
|
|
2670
2634
|
}
|
|
2671
2635
|
async function copyNode$1(driveId, src, target) {
|
|
2672
|
-
const reactor = window.ph?.
|
|
2636
|
+
const reactor = window.ph?.reactorClientModule?.client;
|
|
2673
2637
|
if (!reactor) return;
|
|
2674
2638
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
2675
2639
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
@@ -2706,31 +2670,69 @@ async function copyNode$1(driveId, src, target) {
|
|
|
2706
2670
|
}
|
|
2707
2671
|
return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
|
|
2708
2672
|
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2673
|
+
gql`
|
|
2674
|
+
mutation MutateDocumentWithOperations(
|
|
2675
|
+
$documentIdentifier: String!
|
|
2676
|
+
$actions: [ActionInput!]!
|
|
2677
|
+
$sinceRevision: Int
|
|
2678
|
+
$scopes: [String!]
|
|
2679
|
+
$branch: String
|
|
2680
|
+
) {
|
|
2681
|
+
mutateDocument: execute(
|
|
2682
|
+
documentIdentifier: $documentIdentifier
|
|
2683
|
+
actions: $actions
|
|
2684
|
+
branch: $branch
|
|
2685
|
+
) {
|
|
2686
|
+
...PHDocumentFields
|
|
2687
|
+
operations(
|
|
2688
|
+
filter: {
|
|
2689
|
+
sinceRevision: $sinceRevision
|
|
2690
|
+
scopes: $scopes
|
|
2691
|
+
branch: $branch
|
|
2692
|
+
}
|
|
2693
|
+
) {
|
|
2694
|
+
items {
|
|
2695
|
+
...ReactorOperationFields
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
${PhDocumentFieldsFragmentDoc}
|
|
2701
|
+
${gql`
|
|
2702
|
+
fragment ReactorOperationFields on ReactorOperation {
|
|
2703
|
+
index
|
|
2704
|
+
timestampUtcMs
|
|
2705
|
+
hash
|
|
2706
|
+
skip
|
|
2707
|
+
error
|
|
2708
|
+
deniedReason
|
|
2709
|
+
id
|
|
2710
|
+
action {
|
|
2711
|
+
id
|
|
2712
|
+
type
|
|
2713
|
+
timestampUtcMs
|
|
2714
|
+
input
|
|
2715
|
+
scope
|
|
2716
|
+
context {
|
|
2717
|
+
signer {
|
|
2718
|
+
user {
|
|
2719
|
+
address
|
|
2720
|
+
networkId
|
|
2721
|
+
chainId
|
|
2722
|
+
}
|
|
2723
|
+
app {
|
|
2724
|
+
name
|
|
2725
|
+
key
|
|
2726
|
+
}
|
|
2727
|
+
signatures
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
`}
|
|
2733
|
+
`;
|
|
2734
|
+
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;
|
|
2735
|
+
PropagationMode.Cascade, PropagationMode.Orphan;
|
|
2734
2736
|
const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
|
|
2735
2737
|
/** Sets whether external controls are enabled for a given editor. */
|
|
2736
2738
|
const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
|
|
@@ -2796,6 +2798,8 @@ const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabl
|
|
|
2796
2798
|
const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
|
|
2797
2799
|
const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
|
|
2798
2800
|
const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
|
|
2801
|
+
const { useValue: useSwitchboardUrl, setValue: setSwitchboardUrl, addEventHandler: addSwitchboardUrlEventHandler } = makePHEventFunctions("switchboardUrl");
|
|
2802
|
+
const { useValue: useRenownAdapters, setValue: setRenownAdapters, addEventHandler: addRenownAdaptersEventHandler } = makePHEventFunctions("renownAdapters");
|
|
2799
2803
|
const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
|
|
2800
2804
|
const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
|
|
2801
2805
|
const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
|
|
@@ -2893,6 +2897,8 @@ const nonUserConfigSetters = {
|
|
|
2893
2897
|
renownUrl: setRenownUrl,
|
|
2894
2898
|
renownNetworkId: setRenownNetworkId,
|
|
2895
2899
|
renownChainId: setRenownChainId,
|
|
2900
|
+
switchboardUrl: setSwitchboardUrl,
|
|
2901
|
+
renownAdapters: setRenownAdapters,
|
|
2896
2902
|
sentryRelease: setSentryRelease,
|
|
2897
2903
|
sentryDsn: setSentryDsn,
|
|
2898
2904
|
sentryEnv: setSentryEnv,
|
|
@@ -2941,6 +2947,8 @@ const nonUserConfigHooks = {
|
|
|
2941
2947
|
renownUrl: useRenownUrl,
|
|
2942
2948
|
renownNetworkId: useRenownNetworkId,
|
|
2943
2949
|
renownChainId: useRenownChainId,
|
|
2950
|
+
switchboardUrl: useSwitchboardUrl,
|
|
2951
|
+
renownAdapters: useRenownAdapters,
|
|
2944
2952
|
sentryRelease: useSentryRelease,
|
|
2945
2953
|
sentryDsn: useSentryDsn,
|
|
2946
2954
|
sentryEnv: useSentryEnv,
|
|
@@ -2970,366 +2978,995 @@ const featuresEventFunctions = makePHEventFunctions("features");
|
|
|
2970
2978
|
featuresEventFunctions.useValue;
|
|
2971
2979
|
featuresEventFunctions.setValue;
|
|
2972
2980
|
featuresEventFunctions.addEventHandler;
|
|
2973
|
-
function
|
|
2974
|
-
|
|
2981
|
+
function useDropTarget() {
|
|
2982
|
+
const [isDropTarget, setIsDropTarget] = useState(false);
|
|
2983
|
+
const isDragAndDropEnabled = useIsDragAndDropEnabled();
|
|
2984
|
+
const targetSetter = n$1(() => setIsDropTarget(true), {
|
|
2985
|
+
triggerAt: "start",
|
|
2986
|
+
minQuietPeriodMs: 100
|
|
2987
|
+
});
|
|
2988
|
+
const targetUnsetter = n$1(() => setIsDropTarget(false), {
|
|
2989
|
+
triggerAt: "start",
|
|
2990
|
+
minQuietPeriodMs: 100
|
|
2991
|
+
});
|
|
2992
|
+
function setTarget() {
|
|
2993
|
+
if (!isDragAndDropEnabled) return;
|
|
2994
|
+
targetUnsetter.cancel();
|
|
2995
|
+
targetSetter.call();
|
|
2996
|
+
}
|
|
2997
|
+
function unsetTarget() {
|
|
2998
|
+
if (!isDragAndDropEnabled) return;
|
|
2999
|
+
targetSetter.cancel();
|
|
3000
|
+
targetUnsetter.call();
|
|
3001
|
+
}
|
|
3002
|
+
return {
|
|
3003
|
+
isDropTarget,
|
|
3004
|
+
setTarget,
|
|
3005
|
+
unsetTarget
|
|
3006
|
+
};
|
|
2975
3007
|
}
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3008
|
+
const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
|
|
3009
|
+
const useDraggingNode = draggingNodeEventFunctions.useValue;
|
|
3010
|
+
const setDraggingNode = draggingNodeEventFunctions.setValue;
|
|
3011
|
+
draggingNodeEventFunctions.addEventHandler;
|
|
3012
|
+
const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
|
|
3013
|
+
reducer: (_, newNode) => newNode,
|
|
3014
|
+
triggerAt: "start",
|
|
3015
|
+
minQuietPeriodMs: 100
|
|
3016
|
+
});
|
|
3017
|
+
const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
|
|
3018
|
+
triggerAt: "start",
|
|
3019
|
+
minQuietPeriodMs: 100
|
|
3020
|
+
});
|
|
3021
|
+
function setDragging(node) {
|
|
3022
|
+
draggingNodeUnsetter.cancel();
|
|
3023
|
+
draggingNodeSetter.call(node);
|
|
2980
3024
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
const nodeName = node.name;
|
|
2985
|
-
if (!nodeName) return slug(node.id);
|
|
2986
|
-
return slug(`${nodeName}-${node.id}`);
|
|
3025
|
+
function unsetDragging() {
|
|
3026
|
+
draggingNodeSetter.cancel();
|
|
3027
|
+
draggingNodeUnsetter.call();
|
|
2987
3028
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
const
|
|
2994
|
-
|
|
3029
|
+
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));
|
|
3030
|
+
function useDragNode(args) {
|
|
3031
|
+
const { srcId, parentId } = args;
|
|
3032
|
+
const driveId = useSelectedDriveId();
|
|
3033
|
+
const draggingNodeId = useDraggingNode()?.srcId;
|
|
3034
|
+
const params = {
|
|
3035
|
+
driveId,
|
|
3036
|
+
srcId,
|
|
3037
|
+
parentId
|
|
3038
|
+
};
|
|
3039
|
+
const draggable = isNodeDrag(params);
|
|
3040
|
+
const isDragging = t$4({
|
|
3041
|
+
srcId,
|
|
3042
|
+
draggingNodeId
|
|
3043
|
+
}, [
|
|
3044
|
+
() => draggable,
|
|
3045
|
+
({ srcId }) => e$2(srcId),
|
|
3046
|
+
({ draggingNodeId }) => e$2(draggingNodeId),
|
|
3047
|
+
({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
|
|
3048
|
+
]);
|
|
3049
|
+
const onDragStart = () => {
|
|
3050
|
+
if (!draggable) return;
|
|
3051
|
+
setDragging(params);
|
|
3052
|
+
};
|
|
3053
|
+
const onDragEnd = () => {
|
|
3054
|
+
if (!draggable) return;
|
|
3055
|
+
unsetDragging();
|
|
3056
|
+
};
|
|
3057
|
+
return {
|
|
3058
|
+
isDragging,
|
|
3059
|
+
draggable,
|
|
3060
|
+
onDragStart,
|
|
3061
|
+
onDragEnd
|
|
3062
|
+
};
|
|
2995
3063
|
}
|
|
2996
|
-
|
|
2997
|
-
function
|
|
2998
|
-
|
|
2999
|
-
|
|
3064
|
+
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));
|
|
3065
|
+
function useDropNode(targetId) {
|
|
3066
|
+
const driveId = useSelectedDriveId();
|
|
3067
|
+
const { srcId, parentId } = useDraggingNode() ?? {};
|
|
3068
|
+
const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
|
|
3069
|
+
const params = {
|
|
3070
|
+
driveId,
|
|
3071
|
+
parentId,
|
|
3072
|
+
targetId,
|
|
3073
|
+
srcId
|
|
3074
|
+
};
|
|
3075
|
+
function handleNodeDrop(event, cb) {
|
|
3076
|
+
if (!isNodeDrop(params)) return;
|
|
3077
|
+
event.preventDefault();
|
|
3078
|
+
event.stopPropagation();
|
|
3079
|
+
cb?.();
|
|
3080
|
+
}
|
|
3081
|
+
const onDragEnter = (event) => handleNodeDrop(event);
|
|
3082
|
+
const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
|
|
3083
|
+
const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
|
|
3084
|
+
const onDrop = (event) => handleNodeDrop(event, e(() => {
|
|
3085
|
+
unsetDragging();
|
|
3086
|
+
unsetTarget();
|
|
3087
|
+
moveNodeById(params).catch(console.error);
|
|
3088
|
+
}));
|
|
3089
|
+
return {
|
|
3090
|
+
isDropTarget,
|
|
3091
|
+
onDragEnter,
|
|
3092
|
+
onDragOver,
|
|
3093
|
+
onDragLeave,
|
|
3094
|
+
onDrop
|
|
3095
|
+
};
|
|
3000
3096
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3097
|
+
const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
|
|
3098
|
+
graphQLReactorClientEventFunctions.useValue;
|
|
3099
|
+
graphQLReactorClientEventFunctions.setValue;
|
|
3100
|
+
graphQLReactorClientEventFunctions.addEventHandler;
|
|
3101
|
+
const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
|
|
3102
|
+
packageDiscoveryFunctions.useValue;
|
|
3103
|
+
packageDiscoveryFunctions.setValue;
|
|
3104
|
+
packageDiscoveryFunctions.addEventHandler;
|
|
3105
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
3106
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
3107
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
3108
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
3109
|
+
reactorClientModuleEventFunctions.setValue;
|
|
3110
|
+
reactorClientModuleEventFunctions.addEventHandler;
|
|
3111
|
+
reactorClientEventFunctions.useValue;
|
|
3112
|
+
reactorClientEventFunctions.setValue;
|
|
3113
|
+
reactorClientEventFunctions.addEventHandler;
|
|
3114
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
3115
|
+
const useSyncList = () => {
|
|
3116
|
+
return useSync()?.list() ?? [];
|
|
3117
|
+
};
|
|
3118
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
3119
|
+
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
3120
|
+
revisionHistoryEventFunctions.useValue;
|
|
3121
|
+
/** Sets revision history visibility */
|
|
3122
|
+
const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
|
|
3123
|
+
revisionHistoryEventFunctions.addEventHandler;
|
|
3124
|
+
/** Shows the revision history */
|
|
3125
|
+
function showRevisionHistory() {
|
|
3126
|
+
setRevisionHistoryVisible(true);
|
|
3003
3127
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3128
|
+
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
3129
|
+
selectedTimelineItemEventFunctions.useValue;
|
|
3130
|
+
selectedTimelineItemEventFunctions.setValue;
|
|
3131
|
+
selectedTimelineItemEventFunctions.addEventHandler;
|
|
3132
|
+
const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
|
|
3133
|
+
selectedTimelineRevisionEventFunctions.useValue;
|
|
3134
|
+
selectedTimelineRevisionEventFunctions.setValue;
|
|
3135
|
+
selectedTimelineRevisionEventFunctions.addEventHandler;
|
|
3136
|
+
const toastEventFunctions = makePHEventFunctions("toast");
|
|
3137
|
+
/** Returns the toast function */
|
|
3138
|
+
const usePHToast = toastEventFunctions.useValue;
|
|
3139
|
+
toastEventFunctions.setValue;
|
|
3140
|
+
toastEventFunctions.addEventHandler;
|
|
3141
|
+
//#endregion
|
|
3142
|
+
//#region ../reactor-browser/dist/switchboard-D4-_jwk-.js
|
|
3143
|
+
/** Returns a document of a specific type, throws an error if the found document has a different type */
|
|
3144
|
+
function useDocumentOfType(documentId, documentType) {
|
|
3145
|
+
const [document, dispatch] = useDocumentById(documentId);
|
|
3146
|
+
const documentModelModule = useDocumentModelModuleById(documentType);
|
|
3147
|
+
if (!documentId || !documentType) return [];
|
|
3148
|
+
if (!document) throw new Error(`Document not found: ${documentId}`);
|
|
3149
|
+
if (!documentModelModule) throw new ModuleNotFoundError(documentType);
|
|
3150
|
+
if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(documentId, documentType, document.header.documentType);
|
|
3151
|
+
return [document, dispatch];
|
|
3011
3152
|
}
|
|
3012
|
-
/**
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
const search = window.location.search;
|
|
3017
|
-
return search ? `${pathname}${search}` : pathname;
|
|
3153
|
+
/** Returns the selected document id */
|
|
3154
|
+
function useSelectedDocumentId() {
|
|
3155
|
+
const selectedNode = useSelectedNode();
|
|
3156
|
+
return selectedNode && isFileNode(selectedNode) ? selectedNode.id : void 0;
|
|
3018
3157
|
}
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
/** Sets the drives in the reactor */
|
|
3023
|
-
const setDrives = drivesEventFunctions.setValue;
|
|
3024
|
-
drivesEventFunctions.addEventHandler;
|
|
3025
|
-
const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
|
|
3026
|
-
const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
|
|
3027
|
-
const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
|
|
3028
|
-
selectedNodeIdEventFunctions.addEventHandler;
|
|
3029
|
-
/** Sets the selected node (file or folder). */
|
|
3030
|
-
function setSelectedNode(nodeOrNodeSlug) {
|
|
3031
|
-
const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
|
|
3032
|
-
setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
|
|
3033
|
-
const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
|
|
3034
|
-
if (!driveSlugFromPath) return;
|
|
3035
|
-
if (!nodeSlug) {
|
|
3036
|
-
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
|
|
3037
|
-
if (pathname === window.location.pathname) return;
|
|
3038
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
3039
|
-
return;
|
|
3040
|
-
}
|
|
3041
|
-
const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
|
|
3042
|
-
if (pathname === window.location.pathname) return;
|
|
3043
|
-
window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
|
|
3158
|
+
/** Returns the selected document. */
|
|
3159
|
+
function useSelectedDocumentSafe() {
|
|
3160
|
+
return useDocumentById(useSelectedDocumentId());
|
|
3044
3161
|
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
selectedDriveIdEventFunctions.addEventHandler;
|
|
3051
|
-
/** Returns the selected drive, or undefined if no drive is selected */
|
|
3052
|
-
function useSelectedDriveSafe() {
|
|
3053
|
-
const selectedDriveId = useSelectedDriveId();
|
|
3054
|
-
const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
|
|
3055
|
-
const [drive, dispatch] = useDispatch(selectedDrive);
|
|
3056
|
-
if (!selectedDrive) return [void 0, void 0];
|
|
3057
|
-
return [drive, dispatch];
|
|
3162
|
+
function useSelectedDocumentOfType(documentType) {
|
|
3163
|
+
const documentId = useSelectedDocumentId();
|
|
3164
|
+
if (!documentType) return [];
|
|
3165
|
+
if (!documentId) throw new NoSelectedDocumentError();
|
|
3166
|
+
return useDocumentOfType(documentId, documentType);
|
|
3058
3167
|
}
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3168
|
+
//#endregion
|
|
3169
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
|
|
3170
|
+
const normalizeDescriptors = (error) => {
|
|
3171
|
+
CORE_ERROR_PROPS.forEach((propName) => {
|
|
3172
|
+
normalizeDescriptor(error, propName);
|
|
3173
|
+
});
|
|
3174
|
+
};
|
|
3175
|
+
const CORE_ERROR_PROPS = [
|
|
3176
|
+
"name",
|
|
3177
|
+
"message",
|
|
3178
|
+
"stack",
|
|
3179
|
+
"cause",
|
|
3180
|
+
"errors"
|
|
3181
|
+
];
|
|
3182
|
+
const normalizeDescriptor = (error, propName) => {
|
|
3183
|
+
const descriptor = getDescriptor(error, propName);
|
|
3184
|
+
if (descriptor === void 0) return;
|
|
3185
|
+
if (isReadonlyGetter(descriptor)) {
|
|
3186
|
+
setErrorProperty(error, propName, error[propName]);
|
|
3066
3187
|
return;
|
|
3067
3188
|
}
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3189
|
+
if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
|
|
3190
|
+
};
|
|
3191
|
+
const getDescriptor = (value, propName) => {
|
|
3192
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, propName);
|
|
3193
|
+
if (descriptor !== void 0) return descriptor;
|
|
3194
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3195
|
+
return prototype === null ? void 0 : getDescriptor(prototype, propName);
|
|
3196
|
+
};
|
|
3197
|
+
const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
|
|
3198
|
+
const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
|
|
3199
|
+
const setErrorProperty = (error, propName, value) => {
|
|
3200
|
+
setErrorDescriptor(error, propName, { value });
|
|
3201
|
+
};
|
|
3202
|
+
const setErrorDescriptor = (error, propName, descriptor) => {
|
|
3203
|
+
Object.defineProperty(error, propName, {
|
|
3204
|
+
...descriptor,
|
|
3205
|
+
..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
|
|
3206
|
+
enumerable: false,
|
|
3207
|
+
configurable: true
|
|
3208
|
+
});
|
|
3209
|
+
};
|
|
3210
|
+
//#endregion
|
|
3211
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
|
|
3212
|
+
const normalizeAggregate = (error, recurse) => {
|
|
3213
|
+
if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
|
|
3214
|
+
else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
|
|
3215
|
+
else if (error.errors !== void 0) deleteAggregateErrors(error);
|
|
3216
|
+
};
|
|
3217
|
+
const isDefined = (error) => error !== void 0;
|
|
3218
|
+
const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
|
|
3219
|
+
const deleteAggregateErrors = (error) => {
|
|
3220
|
+
delete error.errors;
|
|
3221
|
+
if (error.errors !== void 0) setErrorProperty(error, "errors", []);
|
|
3222
|
+
};
|
|
3223
|
+
//#endregion
|
|
3224
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
|
|
3225
|
+
const normalizeCause = (error, recurse) => {
|
|
3226
|
+
if (!("cause" in error)) return;
|
|
3227
|
+
const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
|
|
3228
|
+
if (cause === void 0) delete error.cause;
|
|
3229
|
+
else setErrorProperty(error, "cause", cause);
|
|
3230
|
+
};
|
|
3231
|
+
//#endregion
|
|
3232
|
+
//#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
|
|
3233
|
+
const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
|
|
3234
|
+
const isInstanceOfError = (value) => {
|
|
3235
|
+
try {
|
|
3236
|
+
return value instanceof Error;
|
|
3237
|
+
} catch {
|
|
3238
|
+
return false;
|
|
3075
3239
|
}
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3240
|
+
};
|
|
3241
|
+
const hasErrorTag = (value) => {
|
|
3242
|
+
try {
|
|
3243
|
+
return ERROR_TAGS.has(Object.prototype.toString.call(value));
|
|
3244
|
+
} catch {
|
|
3245
|
+
return false;
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
const ERROR_TAGS = new Set([
|
|
3249
|
+
"[object Error]",
|
|
3250
|
+
"[object DOMException]",
|
|
3251
|
+
"[object DOMError]",
|
|
3252
|
+
"[object Exception]"
|
|
3253
|
+
]);
|
|
3254
|
+
//#endregion
|
|
3255
|
+
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
3256
|
+
function isPlainObject(value) {
|
|
3257
|
+
if (typeof value !== "object" || value === null) return false;
|
|
3258
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3259
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
3079
3260
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
return
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3261
|
+
//#endregion
|
|
3262
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
|
|
3263
|
+
const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
|
|
3264
|
+
const isNonConfigurableProp = (error, propName) => {
|
|
3265
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, propName);
|
|
3266
|
+
return descriptor !== void 0 && !descriptor.configurable;
|
|
3267
|
+
};
|
|
3268
|
+
const isThrowingProp = (error, propName) => {
|
|
3269
|
+
try {
|
|
3270
|
+
error[propName];
|
|
3271
|
+
return false;
|
|
3272
|
+
} catch {
|
|
3273
|
+
return true;
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
//#endregion
|
|
3277
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
|
|
3278
|
+
const setStack = (error) => {
|
|
3279
|
+
setErrorProperty(error, "stack", getStack(error.message, error.name));
|
|
3280
|
+
};
|
|
3281
|
+
const getStack = (message = "", name = "Error") => {
|
|
3282
|
+
const { stack } = new (getErrorClass(name))(message);
|
|
3283
|
+
return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
|
|
3284
|
+
};
|
|
3285
|
+
const getErrorClass = (name) => {
|
|
3286
|
+
const descriptor = {
|
|
3287
|
+
value: name,
|
|
3288
|
+
enumerable: false,
|
|
3289
|
+
writable: true,
|
|
3290
|
+
configurable: true
|
|
3291
|
+
};
|
|
3292
|
+
const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
|
|
3293
|
+
Object.defineProperty(StackError.prototype, "name", descriptor);
|
|
3294
|
+
return StackError;
|
|
3295
|
+
};
|
|
3296
|
+
//#endregion
|
|
3297
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
|
|
3298
|
+
const copyObject = (object) => {
|
|
3299
|
+
const objectCopy = {};
|
|
3300
|
+
for (const propName of getPropsToCopy(object)) try {
|
|
3301
|
+
const value = object[propName];
|
|
3302
|
+
const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
|
|
3303
|
+
Object.defineProperty(objectCopy, propName, {
|
|
3304
|
+
value,
|
|
3305
|
+
enumerable,
|
|
3306
|
+
configurable,
|
|
3307
|
+
writable
|
|
3308
|
+
});
|
|
3309
|
+
} catch {}
|
|
3310
|
+
return objectCopy;
|
|
3311
|
+
};
|
|
3312
|
+
const getPropsToCopy = (object) => {
|
|
3313
|
+
const propNames = getOwnKeys(object);
|
|
3314
|
+
for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
|
|
3315
|
+
return propNames;
|
|
3316
|
+
};
|
|
3317
|
+
const getOwnKeys = (object) => {
|
|
3318
|
+
try {
|
|
3319
|
+
return Reflect.ownKeys(object);
|
|
3320
|
+
} catch {
|
|
3321
|
+
return [];
|
|
3322
|
+
}
|
|
3323
|
+
};
|
|
3324
|
+
const isInheritedProp = (object, propName) => {
|
|
3325
|
+
try {
|
|
3326
|
+
return propName in object && !Object.hasOwn(object, propName);
|
|
3327
|
+
} catch {
|
|
3328
|
+
return false;
|
|
3329
|
+
}
|
|
3330
|
+
};
|
|
3331
|
+
//#endregion
|
|
3332
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
|
|
3333
|
+
const objectifyError = (object) => {
|
|
3334
|
+
const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
|
|
3335
|
+
const messageA = getMessage(message, objectA);
|
|
3336
|
+
const error = newError(name, messageA);
|
|
3337
|
+
if (message === messageA) assignObjectProps(error, objectA);
|
|
3338
|
+
Object.entries({
|
|
3339
|
+
name,
|
|
3340
|
+
stack,
|
|
3341
|
+
cause,
|
|
3342
|
+
errors
|
|
3343
|
+
}).forEach(([propName, propValue]) => {
|
|
3344
|
+
setNewErrorProperty(error, propName, propValue);
|
|
3092
3345
|
});
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3346
|
+
if (stack === void 0) setStack(error);
|
|
3347
|
+
return error;
|
|
3348
|
+
};
|
|
3349
|
+
const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
|
|
3350
|
+
const safeJsonStringify = (object) => {
|
|
3351
|
+
try {
|
|
3352
|
+
return JSON.stringify(object);
|
|
3353
|
+
} catch {
|
|
3354
|
+
return safeStringify(object);
|
|
3355
|
+
}
|
|
3356
|
+
};
|
|
3357
|
+
const safeStringify = (object) => {
|
|
3358
|
+
try {
|
|
3359
|
+
return String(object);
|
|
3360
|
+
} catch {
|
|
3361
|
+
return "Invalid error";
|
|
3362
|
+
}
|
|
3363
|
+
};
|
|
3364
|
+
const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
|
|
3365
|
+
const MESSAGE_MAX_SIZE = 1e3;
|
|
3366
|
+
const newError = (name, message) => {
|
|
3367
|
+
if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
|
|
3368
|
+
if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
|
|
3369
|
+
return new Error(message);
|
|
3370
|
+
};
|
|
3371
|
+
const NATIVE_ERRORS = {
|
|
3372
|
+
Error,
|
|
3373
|
+
ReferenceError,
|
|
3374
|
+
TypeError,
|
|
3375
|
+
SyntaxError,
|
|
3376
|
+
RangeError,
|
|
3377
|
+
URIError,
|
|
3378
|
+
EvalError
|
|
3379
|
+
};
|
|
3380
|
+
const assignObjectProps = (error, object) => {
|
|
3381
|
+
for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
|
|
3382
|
+
};
|
|
3383
|
+
const setNewErrorProperty = (error, propName, propValue) => {
|
|
3384
|
+
if (propValue !== void 0) setErrorProperty(error, propName, propValue);
|
|
3385
|
+
};
|
|
3386
|
+
//#endregion
|
|
3387
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
|
|
3388
|
+
const stringifyError = (value) => {
|
|
3389
|
+
try {
|
|
3390
|
+
const error = new Error(String(value));
|
|
3391
|
+
setStack(error);
|
|
3392
|
+
return error;
|
|
3393
|
+
} catch (error_) {
|
|
3394
|
+
return error_;
|
|
3395
|
+
}
|
|
3396
|
+
};
|
|
3397
|
+
//#endregion
|
|
3398
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
|
|
3399
|
+
const { toString: objectToString } = Object.prototype;
|
|
3400
|
+
const createError = (value) => {
|
|
3401
|
+
if (isErrorPlainObj(value)) return objectifyError(value);
|
|
3402
|
+
if (!isErrorInstance(value)) return stringifyError(value);
|
|
3403
|
+
if (isInvalidError(value)) return objectifyError(value);
|
|
3404
|
+
return value;
|
|
3405
|
+
};
|
|
3406
|
+
const isErrorPlainObj = (value) => {
|
|
3407
|
+
try {
|
|
3408
|
+
return isPlainObject(value);
|
|
3409
|
+
} catch {
|
|
3410
|
+
return false;
|
|
3100
3411
|
}
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3412
|
+
};
|
|
3413
|
+
const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
|
|
3414
|
+
const isProxy = (value) => {
|
|
3415
|
+
try {
|
|
3416
|
+
return objectToString.call(value) === "[object Object]";
|
|
3417
|
+
} catch {
|
|
3418
|
+
return true;
|
|
3104
3419
|
}
|
|
3105
|
-
}
|
|
3106
|
-
function
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3420
|
+
};
|
|
3421
|
+
const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
|
|
3422
|
+
//#endregion
|
|
3423
|
+
//#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
|
|
3424
|
+
const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
|
|
3425
|
+
const recurseException = (error, parents, shallow) => {
|
|
3426
|
+
if (parents.includes(error)) return;
|
|
3427
|
+
const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
|
|
3428
|
+
const errorA = createError(error);
|
|
3429
|
+
normalizeProps(errorA, recurse);
|
|
3430
|
+
return errorA;
|
|
3431
|
+
};
|
|
3432
|
+
const identity = (error) => error;
|
|
3433
|
+
const normalizeProps = (error, recurse) => {
|
|
3434
|
+
normalizeName(error);
|
|
3435
|
+
normalizeMessage(error);
|
|
3436
|
+
normalizeStack(error);
|
|
3437
|
+
normalizeCause(error, recurse);
|
|
3438
|
+
normalizeAggregate(error, recurse);
|
|
3439
|
+
normalizeDescriptors(error);
|
|
3440
|
+
};
|
|
3441
|
+
const normalizeName = (error) => {
|
|
3442
|
+
if (isDefinedString(error.name)) return;
|
|
3443
|
+
const prototypeName = Object.getPrototypeOf(error).name;
|
|
3444
|
+
setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
|
|
3445
|
+
};
|
|
3446
|
+
const normalizeMessage = (error) => {
|
|
3447
|
+
if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
|
|
3448
|
+
};
|
|
3449
|
+
const normalizeStack = (error) => {
|
|
3450
|
+
if (!isDefinedString(error.stack)) setStack(error);
|
|
3451
|
+
};
|
|
3452
|
+
const isDefinedString = (value) => typeof value === "string" && value !== "";
|
|
3453
|
+
//#endregion
|
|
3454
|
+
//#region ../reactor-browser/dist/index.js
|
|
3455
|
+
var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3456
|
+
var LZString = (function() {
|
|
3457
|
+
var f = String.fromCharCode;
|
|
3458
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3459
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
3460
|
+
var baseReverseDic = {};
|
|
3461
|
+
function getBaseValue(alphabet, character) {
|
|
3462
|
+
if (!baseReverseDic[alphabet]) {
|
|
3463
|
+
baseReverseDic[alphabet] = {};
|
|
3464
|
+
for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
3123
3465
|
}
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
}
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
function
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3466
|
+
return baseReverseDic[alphabet][character];
|
|
3467
|
+
}
|
|
3468
|
+
var LZString = {
|
|
3469
|
+
compressToBase64: function(input) {
|
|
3470
|
+
if (input == null) return "";
|
|
3471
|
+
var res = LZString._compress(input, 6, function(a) {
|
|
3472
|
+
return keyStrBase64.charAt(a);
|
|
3473
|
+
});
|
|
3474
|
+
switch (res.length % 4) {
|
|
3475
|
+
default:
|
|
3476
|
+
case 0: return res;
|
|
3477
|
+
case 1: return res + "===";
|
|
3478
|
+
case 2: return res + "==";
|
|
3479
|
+
case 3: return res + "=";
|
|
3480
|
+
}
|
|
3481
|
+
},
|
|
3482
|
+
decompressFromBase64: function(input) {
|
|
3483
|
+
if (input == null) return "";
|
|
3484
|
+
if (input == "") return null;
|
|
3485
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3486
|
+
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
3487
|
+
});
|
|
3488
|
+
},
|
|
3489
|
+
compressToUTF16: function(input) {
|
|
3490
|
+
if (input == null) return "";
|
|
3491
|
+
return LZString._compress(input, 15, function(a) {
|
|
3492
|
+
return f(a + 32);
|
|
3493
|
+
}) + " ";
|
|
3494
|
+
},
|
|
3495
|
+
decompressFromUTF16: function(compressed) {
|
|
3496
|
+
if (compressed == null) return "";
|
|
3497
|
+
if (compressed == "") return null;
|
|
3498
|
+
return LZString._decompress(compressed.length, 16384, function(index) {
|
|
3499
|
+
return compressed.charCodeAt(index) - 32;
|
|
3500
|
+
});
|
|
3501
|
+
},
|
|
3502
|
+
compressToUint8Array: function(uncompressed) {
|
|
3503
|
+
var compressed = LZString.compress(uncompressed);
|
|
3504
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
3505
|
+
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
3506
|
+
var current_value = compressed.charCodeAt(i);
|
|
3507
|
+
buf[i * 2] = current_value >>> 8;
|
|
3508
|
+
buf[i * 2 + 1] = current_value % 256;
|
|
3509
|
+
}
|
|
3510
|
+
return buf;
|
|
3511
|
+
},
|
|
3512
|
+
decompressFromUint8Array: function(compressed) {
|
|
3513
|
+
if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
|
|
3514
|
+
else {
|
|
3515
|
+
var buf = new Array(compressed.length / 2);
|
|
3516
|
+
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
3517
|
+
var result = [];
|
|
3518
|
+
buf.forEach(function(c) {
|
|
3519
|
+
result.push(f(c));
|
|
3520
|
+
});
|
|
3521
|
+
return LZString.decompress(result.join(""));
|
|
3522
|
+
}
|
|
3523
|
+
},
|
|
3524
|
+
compressToEncodedURIComponent: function(input) {
|
|
3525
|
+
if (input == null) return "";
|
|
3526
|
+
return LZString._compress(input, 6, function(a) {
|
|
3527
|
+
return keyStrUriSafe.charAt(a);
|
|
3528
|
+
});
|
|
3529
|
+
},
|
|
3530
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
3531
|
+
if (input == null) return "";
|
|
3532
|
+
if (input == "") return null;
|
|
3533
|
+
input = input.replace(/ /g, "+");
|
|
3534
|
+
return LZString._decompress(input.length, 32, function(index) {
|
|
3535
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
3536
|
+
});
|
|
3537
|
+
},
|
|
3538
|
+
compress: function(uncompressed) {
|
|
3539
|
+
return LZString._compress(uncompressed, 16, function(a) {
|
|
3540
|
+
return f(a);
|
|
3541
|
+
});
|
|
3542
|
+
},
|
|
3543
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
3544
|
+
if (uncompressed == null) return "";
|
|
3545
|
+
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;
|
|
3546
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
3547
|
+
context_c = uncompressed.charAt(ii);
|
|
3548
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
3549
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
3550
|
+
context_dictionaryToCreate[context_c] = true;
|
|
3551
|
+
}
|
|
3552
|
+
context_wc = context_w + context_c;
|
|
3553
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
|
|
3554
|
+
else {
|
|
3555
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3556
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3557
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3558
|
+
context_data_val = context_data_val << 1;
|
|
3559
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3560
|
+
context_data_position = 0;
|
|
3561
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3562
|
+
context_data_val = 0;
|
|
3563
|
+
} else context_data_position++;
|
|
3564
|
+
}
|
|
3565
|
+
value = context_w.charCodeAt(0);
|
|
3566
|
+
for (i = 0; i < 8; i++) {
|
|
3567
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3568
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3569
|
+
context_data_position = 0;
|
|
3570
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3571
|
+
context_data_val = 0;
|
|
3572
|
+
} else context_data_position++;
|
|
3573
|
+
value = value >> 1;
|
|
3574
|
+
}
|
|
3575
|
+
} else {
|
|
3576
|
+
value = 1;
|
|
3577
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3578
|
+
context_data_val = context_data_val << 1 | value;
|
|
3579
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3580
|
+
context_data_position = 0;
|
|
3581
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3582
|
+
context_data_val = 0;
|
|
3583
|
+
} else context_data_position++;
|
|
3584
|
+
value = 0;
|
|
3585
|
+
}
|
|
3586
|
+
value = context_w.charCodeAt(0);
|
|
3587
|
+
for (i = 0; i < 16; i++) {
|
|
3588
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3589
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3590
|
+
context_data_position = 0;
|
|
3591
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3592
|
+
context_data_val = 0;
|
|
3593
|
+
} else context_data_position++;
|
|
3594
|
+
value = value >> 1;
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
context_enlargeIn--;
|
|
3598
|
+
if (context_enlargeIn == 0) {
|
|
3599
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3600
|
+
context_numBits++;
|
|
3601
|
+
}
|
|
3602
|
+
delete context_dictionaryToCreate[context_w];
|
|
3603
|
+
} else {
|
|
3604
|
+
value = context_dictionary[context_w];
|
|
3605
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3606
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3607
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3608
|
+
context_data_position = 0;
|
|
3609
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3610
|
+
context_data_val = 0;
|
|
3611
|
+
} else context_data_position++;
|
|
3612
|
+
value = value >> 1;
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
context_enlargeIn--;
|
|
3616
|
+
if (context_enlargeIn == 0) {
|
|
3617
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3618
|
+
context_numBits++;
|
|
3619
|
+
}
|
|
3620
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
3621
|
+
context_w = String(context_c);
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
if (context_w !== "") {
|
|
3625
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
3626
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
3627
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3628
|
+
context_data_val = context_data_val << 1;
|
|
3629
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3630
|
+
context_data_position = 0;
|
|
3631
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3632
|
+
context_data_val = 0;
|
|
3633
|
+
} else context_data_position++;
|
|
3634
|
+
}
|
|
3635
|
+
value = context_w.charCodeAt(0);
|
|
3636
|
+
for (i = 0; i < 8; i++) {
|
|
3637
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3638
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3639
|
+
context_data_position = 0;
|
|
3640
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3641
|
+
context_data_val = 0;
|
|
3642
|
+
} else context_data_position++;
|
|
3643
|
+
value = value >> 1;
|
|
3644
|
+
}
|
|
3645
|
+
} else {
|
|
3646
|
+
value = 1;
|
|
3647
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3648
|
+
context_data_val = context_data_val << 1 | value;
|
|
3649
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3650
|
+
context_data_position = 0;
|
|
3651
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3652
|
+
context_data_val = 0;
|
|
3653
|
+
} else context_data_position++;
|
|
3654
|
+
value = 0;
|
|
3655
|
+
}
|
|
3656
|
+
value = context_w.charCodeAt(0);
|
|
3657
|
+
for (i = 0; i < 16; i++) {
|
|
3658
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3659
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3660
|
+
context_data_position = 0;
|
|
3661
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3662
|
+
context_data_val = 0;
|
|
3663
|
+
} else context_data_position++;
|
|
3664
|
+
value = value >> 1;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
context_enlargeIn--;
|
|
3668
|
+
if (context_enlargeIn == 0) {
|
|
3669
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3670
|
+
context_numBits++;
|
|
3671
|
+
}
|
|
3672
|
+
delete context_dictionaryToCreate[context_w];
|
|
3673
|
+
} else {
|
|
3674
|
+
value = context_dictionary[context_w];
|
|
3675
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3676
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3677
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3678
|
+
context_data_position = 0;
|
|
3679
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3680
|
+
context_data_val = 0;
|
|
3681
|
+
} else context_data_position++;
|
|
3682
|
+
value = value >> 1;
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
context_enlargeIn--;
|
|
3686
|
+
if (context_enlargeIn == 0) {
|
|
3687
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
3688
|
+
context_numBits++;
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
value = 2;
|
|
3692
|
+
for (i = 0; i < context_numBits; i++) {
|
|
3693
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
3694
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3695
|
+
context_data_position = 0;
|
|
3696
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3697
|
+
context_data_val = 0;
|
|
3698
|
+
} else context_data_position++;
|
|
3699
|
+
value = value >> 1;
|
|
3700
|
+
}
|
|
3701
|
+
while (true) {
|
|
3702
|
+
context_data_val = context_data_val << 1;
|
|
3703
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
3704
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
3705
|
+
break;
|
|
3706
|
+
} else context_data_position++;
|
|
3707
|
+
}
|
|
3708
|
+
return context_data.join("");
|
|
3709
|
+
},
|
|
3710
|
+
decompress: function(compressed) {
|
|
3711
|
+
if (compressed == null) return "";
|
|
3712
|
+
if (compressed == "") return null;
|
|
3713
|
+
return LZString._decompress(compressed.length, 32768, function(index) {
|
|
3714
|
+
return compressed.charCodeAt(index);
|
|
3715
|
+
});
|
|
3716
|
+
},
|
|
3717
|
+
_decompress: function(length, resetValue, getNextValue) {
|
|
3718
|
+
var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
|
|
3719
|
+
val: getNextValue(0),
|
|
3720
|
+
position: resetValue,
|
|
3721
|
+
index: 1
|
|
3722
|
+
};
|
|
3723
|
+
for (i = 0; i < 3; i += 1) dictionary[i] = i;
|
|
3724
|
+
bits = 0;
|
|
3725
|
+
maxpower = Math.pow(2, 2);
|
|
3726
|
+
power = 1;
|
|
3727
|
+
while (power != maxpower) {
|
|
3728
|
+
resb = data.val & data.position;
|
|
3729
|
+
data.position >>= 1;
|
|
3730
|
+
if (data.position == 0) {
|
|
3731
|
+
data.position = resetValue;
|
|
3732
|
+
data.val = getNextValue(data.index++);
|
|
3733
|
+
}
|
|
3734
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3735
|
+
power <<= 1;
|
|
3736
|
+
}
|
|
3737
|
+
switch (bits) {
|
|
3738
|
+
case 0:
|
|
3739
|
+
bits = 0;
|
|
3740
|
+
maxpower = Math.pow(2, 8);
|
|
3741
|
+
power = 1;
|
|
3742
|
+
while (power != maxpower) {
|
|
3743
|
+
resb = data.val & data.position;
|
|
3744
|
+
data.position >>= 1;
|
|
3745
|
+
if (data.position == 0) {
|
|
3746
|
+
data.position = resetValue;
|
|
3747
|
+
data.val = getNextValue(data.index++);
|
|
3748
|
+
}
|
|
3749
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3750
|
+
power <<= 1;
|
|
3751
|
+
}
|
|
3752
|
+
c = f(bits);
|
|
3753
|
+
break;
|
|
3754
|
+
case 1:
|
|
3755
|
+
bits = 0;
|
|
3756
|
+
maxpower = Math.pow(2, 16);
|
|
3757
|
+
power = 1;
|
|
3758
|
+
while (power != maxpower) {
|
|
3759
|
+
resb = data.val & data.position;
|
|
3760
|
+
data.position >>= 1;
|
|
3761
|
+
if (data.position == 0) {
|
|
3762
|
+
data.position = resetValue;
|
|
3763
|
+
data.val = getNextValue(data.index++);
|
|
3764
|
+
}
|
|
3765
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3766
|
+
power <<= 1;
|
|
3767
|
+
}
|
|
3768
|
+
c = f(bits);
|
|
3769
|
+
break;
|
|
3770
|
+
case 2: return "";
|
|
3771
|
+
}
|
|
3772
|
+
dictionary[3] = c;
|
|
3773
|
+
w = c;
|
|
3774
|
+
result.push(c);
|
|
3775
|
+
while (true) {
|
|
3776
|
+
if (data.index > length) return "";
|
|
3777
|
+
bits = 0;
|
|
3778
|
+
maxpower = Math.pow(2, numBits);
|
|
3779
|
+
power = 1;
|
|
3780
|
+
while (power != maxpower) {
|
|
3781
|
+
resb = data.val & data.position;
|
|
3782
|
+
data.position >>= 1;
|
|
3783
|
+
if (data.position == 0) {
|
|
3784
|
+
data.position = resetValue;
|
|
3785
|
+
data.val = getNextValue(data.index++);
|
|
3786
|
+
}
|
|
3787
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3788
|
+
power <<= 1;
|
|
3789
|
+
}
|
|
3790
|
+
switch (c = bits) {
|
|
3791
|
+
case 0:
|
|
3792
|
+
bits = 0;
|
|
3793
|
+
maxpower = Math.pow(2, 8);
|
|
3794
|
+
power = 1;
|
|
3795
|
+
while (power != maxpower) {
|
|
3796
|
+
resb = data.val & data.position;
|
|
3797
|
+
data.position >>= 1;
|
|
3798
|
+
if (data.position == 0) {
|
|
3799
|
+
data.position = resetValue;
|
|
3800
|
+
data.val = getNextValue(data.index++);
|
|
3801
|
+
}
|
|
3802
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3803
|
+
power <<= 1;
|
|
3804
|
+
}
|
|
3805
|
+
dictionary[dictSize++] = f(bits);
|
|
3806
|
+
c = dictSize - 1;
|
|
3807
|
+
enlargeIn--;
|
|
3808
|
+
break;
|
|
3809
|
+
case 1:
|
|
3810
|
+
bits = 0;
|
|
3811
|
+
maxpower = Math.pow(2, 16);
|
|
3812
|
+
power = 1;
|
|
3813
|
+
while (power != maxpower) {
|
|
3814
|
+
resb = data.val & data.position;
|
|
3815
|
+
data.position >>= 1;
|
|
3816
|
+
if (data.position == 0) {
|
|
3817
|
+
data.position = resetValue;
|
|
3818
|
+
data.val = getNextValue(data.index++);
|
|
3819
|
+
}
|
|
3820
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
3821
|
+
power <<= 1;
|
|
3822
|
+
}
|
|
3823
|
+
dictionary[dictSize++] = f(bits);
|
|
3824
|
+
c = dictSize - 1;
|
|
3825
|
+
enlargeIn--;
|
|
3826
|
+
break;
|
|
3827
|
+
case 2: return result.join("");
|
|
3828
|
+
}
|
|
3829
|
+
if (enlargeIn == 0) {
|
|
3830
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3831
|
+
numBits++;
|
|
3832
|
+
}
|
|
3833
|
+
if (dictionary[c]) entry = dictionary[c];
|
|
3834
|
+
else if (c === dictSize) entry = w + w.charAt(0);
|
|
3835
|
+
else return null;
|
|
3836
|
+
result.push(entry);
|
|
3837
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
3838
|
+
enlargeIn--;
|
|
3839
|
+
w = entry;
|
|
3840
|
+
if (enlargeIn == 0) {
|
|
3841
|
+
enlargeIn = Math.pow(2, numBits);
|
|
3842
|
+
numBits++;
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
};
|
|
3847
|
+
return LZString;
|
|
3848
|
+
})();
|
|
3849
|
+
if (typeof define === "function" && define.amd) define(function() {
|
|
3850
|
+
return LZString;
|
|
3851
|
+
});
|
|
3852
|
+
else if (typeof module !== "undefined" && module != null) module.exports = LZString;
|
|
3853
|
+
else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
|
|
3854
|
+
return LZString;
|
|
3855
|
+
});
|
|
3856
|
+
})))(), 1);
|
|
3857
|
+
const sanitize = (segment) => segment.replace(/\//g, "-");
|
|
3858
|
+
/**
|
|
3859
|
+
* Name segments from the exported folder (exclusive) down to `node`
|
|
3860
|
+
* (inclusive), in top-down order. `root === undefined` means the drive root:
|
|
3861
|
+
* all ancestors. A node that IS the exported folder yields no segments.
|
|
3862
|
+
*/
|
|
3863
|
+
function segmentsBelow(root, node, allNodes) {
|
|
3864
|
+
const segments = [];
|
|
3865
|
+
let current = node;
|
|
3866
|
+
while (current && current.id !== root?.id) {
|
|
3867
|
+
segments.push(sanitize(current.name));
|
|
3868
|
+
const parentId = current.parentFolder;
|
|
3869
|
+
current = parentId ? allNodes.find((n) => n.id === parentId) : void 0;
|
|
3870
|
+
}
|
|
3871
|
+
return segments.reverse();
|
|
3214
3872
|
}
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3873
|
+
/**
|
|
3874
|
+
* Assemble the archive zip for a folder (or the whole drive when
|
|
3875
|
+
* `folderNode` is undefined). Every folder in the subtree becomes a
|
|
3876
|
+
* directory entry (empty folders survive); every file becomes a standard
|
|
3877
|
+
* single-document zip named after the node (drive naming convention:
|
|
3878
|
+
* `${name}.${extension}.phd`, ` (copy) N` on a same-folder collision).
|
|
3879
|
+
*
|
|
3880
|
+
* `fetchDocument` must return the document WITH its full operations and
|
|
3881
|
+
* initialState (see downloadFolderZip).
|
|
3882
|
+
*/
|
|
3883
|
+
async function buildFolderZip(drive, folderNode, fetchDocument, onProgress) {
|
|
3884
|
+
const allNodes = drive.state.global.nodes;
|
|
3885
|
+
const topName = sanitize(folderNode?.name ?? (drive.state.global.name || drive.header.name));
|
|
3886
|
+
const subtree = folderNode ? [folderNode, ...getDescendants(folderNode, allNodes)] : allNodes;
|
|
3887
|
+
const entries = { [topName + "/"]: new Uint8Array(0) };
|
|
3888
|
+
for (const node of subtree) {
|
|
3889
|
+
if (!isFolderNode(node)) continue;
|
|
3890
|
+
const dir = [topName, ...segmentsBelow(folderNode, node, allNodes)].join("/");
|
|
3891
|
+
entries[dir + "/"] = new Uint8Array(0);
|
|
3892
|
+
}
|
|
3893
|
+
const files = subtree.filter(isFileNode);
|
|
3894
|
+
const failed = [];
|
|
3895
|
+
const usedNamesByDir = /* @__PURE__ */ new Map();
|
|
3896
|
+
let done = 0;
|
|
3897
|
+
for (const node of files) try {
|
|
3898
|
+
const doc = await fetchDocument(node.id);
|
|
3899
|
+
const extension = await getDocumentExtension(doc);
|
|
3900
|
+
const parent = node.parentFolder ? allNodes.find((n) => n.id === node.parentFolder) : void 0;
|
|
3901
|
+
const dir = [topName, ...parent ? segmentsBelow(folderNode, parent, allNodes) : []].join("/");
|
|
3902
|
+
let usedNames = usedNamesByDir.get(dir);
|
|
3903
|
+
if (!usedNames) {
|
|
3904
|
+
usedNames = /* @__PURE__ */ new Set();
|
|
3905
|
+
usedNamesByDir.set(dir, usedNames);
|
|
3906
|
+
}
|
|
3907
|
+
const base = sanitize(node.name);
|
|
3908
|
+
let candidate = base;
|
|
3909
|
+
let count = getNextCopyNumber([...usedNames], base);
|
|
3910
|
+
while (usedNames.has(candidate)) {
|
|
3911
|
+
candidate = `${base} (copy) ${count}`;
|
|
3912
|
+
count += 1;
|
|
3913
|
+
}
|
|
3914
|
+
usedNames.add(candidate);
|
|
3915
|
+
const leaf = extension ? `${candidate}.${extension}.phd` : `${candidate}.phd`;
|
|
3916
|
+
entries[`${dir}/${leaf}`] = await createZip(doc);
|
|
3917
|
+
} catch {
|
|
3918
|
+
failed.push(node.name);
|
|
3919
|
+
} finally {
|
|
3920
|
+
done += 1;
|
|
3921
|
+
onProgress?.(done, files.length);
|
|
3231
3922
|
}
|
|
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
3923
|
return {
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
onDrop
|
|
3924
|
+
zip: await zipEntries(entries),
|
|
3925
|
+
archiveName: `${topName}.zip`,
|
|
3926
|
+
entryCount: files.length - failed.length,
|
|
3927
|
+
failed
|
|
3246
3928
|
};
|
|
3247
3929
|
}
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
const
|
|
3257
|
-
const
|
|
3258
|
-
|
|
3259
|
-
const
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
}
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
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);
|
|
3930
|
+
/**
|
|
3931
|
+
* Export a folder (or whole drive) to disk: fetches every document with its
|
|
3932
|
+
* full operation history, builds the archive, and saves it via
|
|
3933
|
+
* showSaveFilePicker (fallback: blob download), mirroring exportFile.
|
|
3934
|
+
*/
|
|
3935
|
+
async function downloadFolderZip(drive, folderNode, onProgress) {
|
|
3936
|
+
const reactorClient = window.ph?.reactorClient;
|
|
3937
|
+
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
3938
|
+
const result = await buildFolderZip(drive, folderNode, async (id) => {
|
|
3939
|
+
const doc = await reactorClient.get(id);
|
|
3940
|
+
const operations = await fetchDocumentOperations(reactorClient, doc);
|
|
3941
|
+
const initialState = extractInitialState(operations["document"] ?? []);
|
|
3942
|
+
return {
|
|
3943
|
+
...doc,
|
|
3944
|
+
operations,
|
|
3945
|
+
initialState
|
|
3946
|
+
};
|
|
3947
|
+
}, onProgress);
|
|
3948
|
+
if (!window.showSaveFilePicker) {
|
|
3949
|
+
const blob = new Blob([new Uint8Array(result.zip)], { type: "application/zip" });
|
|
3950
|
+
const link = window.document.createElement("a");
|
|
3951
|
+
link.style.display = "none";
|
|
3952
|
+
link.href = URL.createObjectURL(blob);
|
|
3953
|
+
link.download = result.archiveName;
|
|
3954
|
+
window.document.body.appendChild(link);
|
|
3955
|
+
link.click();
|
|
3956
|
+
window.document.body.removeChild(link);
|
|
3957
|
+
return result;
|
|
3958
|
+
}
|
|
3959
|
+
try {
|
|
3960
|
+
const writable = await (await window.showSaveFilePicker({ suggestedName: result.archiveName })).createWritable();
|
|
3961
|
+
await writable.write(new Uint8Array(result.zip));
|
|
3962
|
+
await writable.close();
|
|
3963
|
+
} catch (e) {
|
|
3964
|
+
if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
|
|
3965
|
+
}
|
|
3966
|
+
return result;
|
|
3332
3967
|
}
|
|
3968
|
+
/** Document types that represent a "drive": a container of nodes. */
|
|
3969
|
+
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
3333
3970
|
function useAllowedDocumentModelModules() {
|
|
3334
3971
|
const documentModelModules = useDocumentModelModules();
|
|
3335
3972
|
const allowedDocumentTypes = useAllowedDocumentTypes();
|
|
@@ -3395,15 +4032,49 @@ function useSetPHDocumentEditorConfig(config) {
|
|
|
3395
4032
|
setIsInitialized(true);
|
|
3396
4033
|
}, [config, isInitialized]);
|
|
3397
4034
|
}
|
|
3398
|
-
/**
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
if (
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
return
|
|
4035
|
+
/**
|
|
4036
|
+
* Classifies a document's model version against the installed module
|
|
4037
|
+
* versions. Pure logic, extracted for testing.
|
|
4038
|
+
*/
|
|
4039
|
+
function getDocumentVersionStatus(documentVersion, availableVersions, hasUpgradePath) {
|
|
4040
|
+
if (availableVersions.length === 0) return;
|
|
4041
|
+
const sorted = [...availableVersions].sort((a, b) => a - b);
|
|
4042
|
+
const latestVersion = sorted[sorted.length - 1];
|
|
4043
|
+
if (documentVersion > latestVersion) return {
|
|
4044
|
+
kind: "unsupported",
|
|
4045
|
+
documentVersion,
|
|
4046
|
+
availableVersions: sorted
|
|
4047
|
+
};
|
|
4048
|
+
if (documentVersion === latestVersion) return {
|
|
4049
|
+
kind: "current",
|
|
4050
|
+
documentVersion
|
|
4051
|
+
};
|
|
4052
|
+
return {
|
|
4053
|
+
kind: "upgrade-available",
|
|
4054
|
+
documentVersion,
|
|
4055
|
+
latestVersion,
|
|
4056
|
+
canUpgrade: hasUpgradePath(documentVersion, latestVersion)
|
|
4057
|
+
};
|
|
4058
|
+
}
|
|
4059
|
+
/**
|
|
4060
|
+
* Compares the given document's model version against the versions available
|
|
4061
|
+
* from installed Vetra packages. Returns undefined while packages load or
|
|
4062
|
+
* when the document type has no installed modules.
|
|
4063
|
+
*/
|
|
4064
|
+
function useDocumentVersionStatus(document) {
|
|
4065
|
+
const modules = useDocumentModelModules();
|
|
4066
|
+
const registry = useModelRegistry();
|
|
4067
|
+
if (!document || !modules) return;
|
|
4068
|
+
const documentType = document.header.documentType;
|
|
4069
|
+
return getDocumentVersionStatus(document.state.document.version || 1, modules.filter((m) => m.documentModel.global.id === documentType).map((m) => m.version ?? 1), (fromVersion, toVersion) => {
|
|
4070
|
+
if (!registry) return false;
|
|
4071
|
+
try {
|
|
4072
|
+
registry.computeUpgradePath(documentType, fromVersion, toVersion);
|
|
4073
|
+
return true;
|
|
4074
|
+
} catch {
|
|
4075
|
+
return false;
|
|
4076
|
+
}
|
|
4077
|
+
});
|
|
3407
4078
|
}
|
|
3408
4079
|
const validateDocument = (document) => {
|
|
3409
4080
|
const errors = [];
|
|
@@ -3471,6 +4142,25 @@ function useDownloadDocument(id) {
|
|
|
3471
4142
|
}
|
|
3472
4143
|
};
|
|
3473
4144
|
}
|
|
4145
|
+
/**
|
|
4146
|
+
* Downloads the selected drive's folder (or the whole drive when no folder
|
|
4147
|
+
* is given) as a single zip archive mirroring the folder tree.
|
|
4148
|
+
*/
|
|
4149
|
+
function useDownloadFolder(folderNode) {
|
|
4150
|
+
const [selectedDrive] = useSelectedDriveSafe();
|
|
4151
|
+
const toast = usePHToast();
|
|
4152
|
+
return async () => {
|
|
4153
|
+
if (!selectedDrive) return;
|
|
4154
|
+
const name = folderNode?.name ?? selectedDrive.header.name;
|
|
4155
|
+
toast?.(`Downloading "${name}"…`);
|
|
4156
|
+
try {
|
|
4157
|
+
const { entryCount, failed } = await downloadFolderZip(selectedDrive, folderNode);
|
|
4158
|
+
toast?.(failed.length ? `Downloaded ${entryCount} files (${failed.length} failed)` : `Downloaded ${entryCount} files`);
|
|
4159
|
+
} catch (error) {
|
|
4160
|
+
toast?.(`Failed to download "${name}": ${error.message}`);
|
|
4161
|
+
}
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
3474
4164
|
/** An editor is a drive "app" if it targets any supported drive document type. */
|
|
3475
4165
|
function isDriveEditor(module) {
|
|
3476
4166
|
const driveTypes = DRIVE_DOCUMENT_TYPES;
|
|
@@ -3510,11 +4200,11 @@ function useNodeActions() {
|
|
|
3510
4200
|
const drives = useDrives();
|
|
3511
4201
|
async function onAddFile(file, parent) {
|
|
3512
4202
|
if (!selectedDriveId) return;
|
|
3513
|
-
return
|
|
4203
|
+
return addFileWithProgress(file, selectedDriveId, file.name.replace(/\..+/gim, ""), resolveNode(selectedDriveId, parent)?.id, void 0, void 0, "duplicate");
|
|
3514
4204
|
}
|
|
3515
4205
|
async function onAddFolder(name, parent) {
|
|
3516
4206
|
if (!selectedDriveId) return;
|
|
3517
|
-
return addFolder(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
4207
|
+
return addFolder$1(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
|
|
3518
4208
|
}
|
|
3519
4209
|
async function onRenameNode(newName, node) {
|
|
3520
4210
|
if (!selectedDriveId) return;
|
|
@@ -3601,20 +4291,8 @@ function useSelectedNodePath() {
|
|
|
3601
4291
|
function useNodeParentFolderById(id) {
|
|
3602
4292
|
return useFolderById(useNodeById(id)?.parentFolder);
|
|
3603
4293
|
}
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
const selectedNode = useSelectedNode();
|
|
3607
|
-
return selectedNode && isFileNode(selectedNode) ? selectedNode.id : void 0;
|
|
3608
|
-
}
|
|
3609
|
-
/** Returns the selected document. */
|
|
3610
|
-
function useSelectedDocumentSafe() {
|
|
3611
|
-
return useDocumentById(useSelectedDocumentId());
|
|
3612
|
-
}
|
|
3613
|
-
function useSelectedDocumentOfType(documentType) {
|
|
3614
|
-
const documentId = useSelectedDocumentId();
|
|
3615
|
-
if (!documentType) return [];
|
|
3616
|
-
if (!documentId) throw new NoSelectedDocumentError();
|
|
3617
|
-
return useDocumentOfType(documentId, documentType);
|
|
4294
|
+
function useParentFolderForSelectedNode() {
|
|
4295
|
+
return useNodeParentFolderById(useSelectedNode()?.id);
|
|
3618
4296
|
}
|
|
3619
4297
|
const STORED_THEME_KEY = "ph:theme";
|
|
3620
4298
|
const UPDATE_STORED_THEME = "ph:updateStoredTheme";
|
|
@@ -3705,8 +4383,134 @@ function getDocumentGraphqlQuery() {
|
|
|
3705
4383
|
if (!loc) throw new Error("GetDocumentWithOperationsDocument is misconfigured, loc is missing.");
|
|
3706
4384
|
return loc.source.body;
|
|
3707
4385
|
}
|
|
3708
|
-
|
|
3709
|
-
|
|
4386
|
+
/**
|
|
4387
|
+
* The base URL of the switchboard that serves a drive's GraphQL channel.
|
|
4388
|
+
*
|
|
4389
|
+
* The channel URL is `<origin>[<proxy-prefix>]/graphql/r`, so stripping the
|
|
4390
|
+
* suffix preserves any proxy prefix (e.g. `/api/reactor`). A URL that does
|
|
4391
|
+
* not end with the suffix is unexpected — fall back to its origin.
|
|
4392
|
+
*/
|
|
4393
|
+
function getSwitchboardBaseFromChannelUrl(channelUrl) {
|
|
4394
|
+
if (channelUrl.endsWith("/graphql/r")) return channelUrl.slice(0, -10);
|
|
4395
|
+
return new URL(channelUrl).origin;
|
|
4396
|
+
}
|
|
4397
|
+
/**
|
|
4398
|
+
* The GraphQL name the switchboard exposes a document model under. Mirrors
|
|
4399
|
+
* `getDocumentModelSchemaName` on the server (`create-schema.ts`): the root
|
|
4400
|
+
* query field and the state type names are all derived from the model's
|
|
4401
|
+
* `global.name`.
|
|
4402
|
+
*/
|
|
4403
|
+
function getDocumentModelSchemaName(model) {
|
|
4404
|
+
return pascalCase(model.documentModel.global.name.replaceAll("/", " "));
|
|
4405
|
+
}
|
|
4406
|
+
function buildStateTypeMap(definitions) {
|
|
4407
|
+
const typeMap = /* @__PURE__ */ new Map();
|
|
4408
|
+
for (const def of definitions) if (def.kind === Kind.OBJECT_TYPE_DEFINITION) typeMap.set(def.name.value, def);
|
|
4409
|
+
return typeMap;
|
|
4410
|
+
}
|
|
4411
|
+
/**
|
|
4412
|
+
* Recursively expands the fields of a state object type into a GraphQL
|
|
4413
|
+
* selection. Objects expand their sub-selection (lists expand their item
|
|
4414
|
+
* type); enums, scalars, and built-ins are leaves.
|
|
4415
|
+
*/
|
|
4416
|
+
function expandStateFields(typeDef, typeMap) {
|
|
4417
|
+
return (typeDef.fields ?? []).map((field) => {
|
|
4418
|
+
const fieldName = field.name.value;
|
|
4419
|
+
let typeNode = field.type;
|
|
4420
|
+
if (typeNode.kind === Kind.NON_NULL_TYPE) typeNode = typeNode.type;
|
|
4421
|
+
if (typeNode.kind === Kind.LIST_TYPE) {
|
|
4422
|
+
let itemType = typeNode.type;
|
|
4423
|
+
if (itemType.kind === Kind.NON_NULL_TYPE) itemType = itemType.type;
|
|
4424
|
+
if (itemType.kind === Kind.LIST_TYPE) throw new Error(`Nested lists are not supported in state selections: ${fieldName}`);
|
|
4425
|
+
if (itemType.kind !== Kind.NAMED_TYPE) return fieldName;
|
|
4426
|
+
const itemTypeDef = typeMap.get(itemType.name.value);
|
|
4427
|
+
if (!itemTypeDef) return fieldName;
|
|
4428
|
+
return `${fieldName} { ${expandStateFields(itemTypeDef, typeMap)} }`;
|
|
4429
|
+
}
|
|
4430
|
+
if (typeNode.kind !== Kind.NAMED_TYPE) return fieldName;
|
|
4431
|
+
const typeDef = typeMap.get(typeNode.name.value);
|
|
4432
|
+
if (!typeDef) return fieldName;
|
|
4433
|
+
return `${fieldName} { ${expandStateFields(typeDef, typeMap)} }`;
|
|
4434
|
+
}).join(" ");
|
|
4435
|
+
}
|
|
4436
|
+
/**
|
|
4437
|
+
* Finds the root state object type in a state SDL. Root state types follow
|
|
4438
|
+
* the `<Name>State` / `<Name>GlobalState` conventions, and are defined last
|
|
4439
|
+
* by convention — the same resolution order the server uses
|
|
4440
|
+
* (`extractRootTypeName` in `create-schema.ts`).
|
|
4441
|
+
*/
|
|
4442
|
+
function findRootStateType(definitions, candidates) {
|
|
4443
|
+
let lastObjectType = null;
|
|
4444
|
+
for (const def of definitions) {
|
|
4445
|
+
if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
|
|
4446
|
+
if (candidates.includes(def.name.value)) return def;
|
|
4447
|
+
lastObjectType = def;
|
|
4448
|
+
}
|
|
4449
|
+
if (!lastObjectType) throw new Error("No root state type found in the document model schema");
|
|
4450
|
+
return lastObjectType;
|
|
4451
|
+
}
|
|
4452
|
+
/**
|
|
4453
|
+
* Derives the subselection for the document's `global` state scope from the
|
|
4454
|
+
* model's state SDL (e.g. `name total`), expanding object fields
|
|
4455
|
+
* recursively. Throws when the schema is missing, unparseable, or has no
|
|
4456
|
+
* root object type — the caller falls back to the generic document query.
|
|
4457
|
+
*/
|
|
4458
|
+
function getDocumentStateSelection(model) {
|
|
4459
|
+
const schema = model.documentModel.global.specifications.at(-1)?.state.global.schema;
|
|
4460
|
+
if (!schema || !schema.trim()) throw new Error("Document model has no global state schema");
|
|
4461
|
+
const ast = parse(schema);
|
|
4462
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4463
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4464
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}State`, `${documentName}GlobalState`]), typeMap);
|
|
4465
|
+
}
|
|
4466
|
+
function getLocalStateSelection(localSchema, documentName) {
|
|
4467
|
+
const ast = parse(localSchema);
|
|
4468
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4469
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}LocalState`]), typeMap);
|
|
4470
|
+
}
|
|
4471
|
+
/**
|
|
4472
|
+
* Builds a query scoped to a document type's own subgraph root field,
|
|
4473
|
+
* selecting the document and its full typed state. The shape mirrors what
|
|
4474
|
+
* the switchboard generates per model (`generateNewApiSchema` in
|
|
4475
|
+
* `create-schema.ts`): `<Name> { document(identifier:) { document { ...
|
|
4476
|
+
* state { auth document global local } } } childIds }`.
|
|
4477
|
+
*/
|
|
4478
|
+
function buildModelScopedQuery(model) {
|
|
4479
|
+
const globalState = model.documentModel.global;
|
|
4480
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4481
|
+
const globalSelection = getDocumentStateSelection(model);
|
|
4482
|
+
const localSchema = globalState.specifications.at(-1)?.state.local.schema ?? "";
|
|
4483
|
+
const localSelection = localSchema.includes(`type ${documentName}LocalState`) ? getLocalStateSelection(localSchema, documentName) : null;
|
|
4484
|
+
return [
|
|
4485
|
+
"query GetDocument($identifier: String!) {",
|
|
4486
|
+
` ${documentName} {`,
|
|
4487
|
+
" document(identifier: $identifier) {",
|
|
4488
|
+
" document {",
|
|
4489
|
+
" id",
|
|
4490
|
+
" name",
|
|
4491
|
+
" documentType",
|
|
4492
|
+
" state {",
|
|
4493
|
+
" auth",
|
|
4494
|
+
" document { version hash { algorithm encoding } isDeleted deletedAtUtcIso deletedBy deletionReason }",
|
|
4495
|
+
` global { ${globalSelection} }`,
|
|
4496
|
+
` ${localSelection ? `local { ${localSelection} }` : "local"}`,
|
|
4497
|
+
" }",
|
|
4498
|
+
" }",
|
|
4499
|
+
" childIds",
|
|
4500
|
+
" }",
|
|
4501
|
+
" }",
|
|
4502
|
+
"}"
|
|
4503
|
+
].join("\n");
|
|
4504
|
+
}
|
|
4505
|
+
function buildDocumentSubgraphQuery(documentType, identifier, model, authToken) {
|
|
4506
|
+
let query;
|
|
4507
|
+
if (model && model.documentModel.global.id === documentType) try {
|
|
4508
|
+
query = buildModelScopedQuery(model);
|
|
4509
|
+
} catch (error) {
|
|
4510
|
+
console.warn("Could not derive a document-scoped query from the document model, falling back to the generic document query:", error);
|
|
4511
|
+
query = getDocumentGraphqlQuery();
|
|
4512
|
+
}
|
|
4513
|
+
else query = getDocumentGraphqlQuery();
|
|
3710
4514
|
const variables = { identifier };
|
|
3711
4515
|
const headers = authToken ? { Authorization: `Bearer ${authToken}` } : void 0;
|
|
3712
4516
|
const payload = {
|
|
@@ -3714,10 +4518,11 @@ function buildDocumentSubgraphQuery(identifier, authToken) {
|
|
|
3714
4518
|
variables: JSON.stringify(variables, null, 2)
|
|
3715
4519
|
};
|
|
3716
4520
|
if (headers) payload.headers = JSON.stringify(headers);
|
|
3717
|
-
return import_lz_string.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
4521
|
+
return import_lz_string.default.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
3718
4522
|
}
|
|
3719
|
-
function buildDocumentSubgraphUrl(
|
|
3720
|
-
|
|
4523
|
+
function buildDocumentSubgraphUrl(channelUrl, documentType, identifier, model, authToken) {
|
|
4524
|
+
const encodedQuery = buildDocumentSubgraphQuery(documentType, identifier, model, authToken);
|
|
4525
|
+
return `${getSwitchboardBaseFromChannelUrl(channelUrl)}/explorer?explorerURLState=${encodedQuery}`;
|
|
3721
4526
|
}
|
|
3722
4527
|
/**
|
|
3723
4528
|
* Hook that returns a function to generate a document's switchboard URL.
|
|
@@ -3733,6 +4538,7 @@ function buildDocumentSubgraphUrl(driveUrl, identifier, authToken) {
|
|
|
3733
4538
|
function useGetSwitchboardLink(document) {
|
|
3734
4539
|
const [drive] = useSelectedDriveSafe();
|
|
3735
4540
|
const remotes = useSyncList();
|
|
4541
|
+
const documentModelModule = useDocumentModelModuleById(document?.header.documentType);
|
|
3736
4542
|
const isRemoteDrive = useMemo(() => {
|
|
3737
4543
|
if (!e$4(drive)) return false;
|
|
3738
4544
|
return remotes.some((remote) => remote.meta.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
|
|
@@ -3757,12 +4563,13 @@ function useGetSwitchboardLink(document) {
|
|
|
3757
4563
|
expiresIn: 600,
|
|
3758
4564
|
aud: remoteUrl
|
|
3759
4565
|
}) : void 0;
|
|
3760
|
-
return buildDocumentSubgraphUrl(remoteUrl, document.header.id, token);
|
|
4566
|
+
return buildDocumentSubgraphUrl(remoteUrl, document.header.documentType, document.header.id, documentModelModule, token);
|
|
3761
4567
|
};
|
|
3762
4568
|
}, [
|
|
3763
4569
|
isRemoteDrive,
|
|
3764
4570
|
remoteUrl,
|
|
3765
4571
|
document,
|
|
4572
|
+
documentModelModule,
|
|
3766
4573
|
user,
|
|
3767
4574
|
renown
|
|
3768
4575
|
]);
|
|
@@ -3829,6 +4636,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
|
|
|
3829
4636
|
createDebouncedRefreshReactorData();
|
|
3830
4637
|
createDebouncedRefreshReactorDataClient();
|
|
3831
4638
|
//#endregion
|
|
3832
|
-
export {
|
|
4639
|
+
export { useDropNode as A, setSelectedNode as B, addDocument as C, showRevisionHistory as D, showPHModal as E, t$2 as F, useSelectedDriveSafe as H, t$5 as I, isFileNodeKind as L, useStudioMode as M, e$1 as N, useDisabledEditors as O, e$4 as P, isFolderNodeKind as R, useSelectedDocumentSafe as S, showDeleteNodeModal as T, useDocumentById as U, useSelectedDriveId as V, useSetPHAppConfig as _, useDownloadDocument as a, useUserPermissions as b, useEditorModulesForDocumentType as c, useNodeById as d, useNodeParentFolderById as f, useSelectedNodePath as g, useSelectedFolder as h, useDocumentVersionStatus as i, usePHToast as j, useDragNode as k, useGetSwitchboardLink as l, useParentFolderForSelectedNode as m, preloadEditorModule as n, useDownloadFolder as o, useNodesInSelectedDriveOrFolder as p, useAllowedDocumentModelModules as r, useEditorModules as s, getSyncStatusSync as t, useNodeActions as u, useSetPHDocumentEditorConfig as v, addFolder$1 as w, useSelectedDocumentOfType as x, useTheme as y, setSelectedDrive as z };
|
|
3833
4640
|
|
|
3834
|
-
//# sourceMappingURL=dist-
|
|
4641
|
+
//# sourceMappingURL=dist-C1pi89al.js.map
|