@powerhousedao/powerhouse-vetra-packages 6.2.0-dev.3 → 6.2.0-dev.31

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.
Files changed (69) hide show
  1. package/dist/browser/assets/{entry-Bzani6_n.js → entry-BzMQu_A8.js} +2 -2
  2. package/dist/browser/assets/{projection-entry-Bpu-8SnI.js → projection-entry-CQb9a2Bz.js} +2 -2
  3. package/dist/browser/{connect-ZnLjvmRt.js → connect-CdR7HnG_.js} +104 -104
  4. package/dist/browser/connect-CdR7HnG_.js.map +1 -0
  5. package/dist/browser/{dist-DLFI75Zd.js → dist-DXM8ccKa.js} +46 -7
  6. package/dist/browser/dist-DXM8ccKa.js.map +1 -0
  7. package/dist/browser/{dist-C1nRM9t2.js → dist-HgA907mh.js} +95 -61
  8. package/dist/browser/dist-HgA907mh.js.map +1 -0
  9. package/dist/browser/{document-drive-oqv68jDU.js → document-drive-sTKoi6L4.js} +314 -9
  10. package/dist/browser/document-drive-sTKoi6L4.js.map +1 -0
  11. package/dist/browser/document-models/index.js +1 -1
  12. package/dist/browser/{editor-DC3bigBu.js → editor-Bzkc8cBh.js} +5 -5
  13. package/dist/browser/{editor-DC3bigBu.js.map → editor-Bzkc8cBh.js.map} +1 -1
  14. package/dist/browser/{editor-CoTq6fqT.js → editor-CwLkXRMi.js} +21 -21
  15. package/dist/browser/editor-CwLkXRMi.js.map +1 -0
  16. package/dist/browser/editors/document-model-editor/module.js +1 -1
  17. package/dist/browser/editors/generic-drive-explorer/index.js +5 -5
  18. package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
  19. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  20. package/dist/browser/{folder-view-DmYBf2pP.js → folder-view-SEF40UJw.js} +7 -7
  21. package/dist/browser/folder-view-SEF40UJw.js.map +1 -0
  22. package/dist/browser/{graphql-editor-CiGd_Li7.js → graphql-editor-DMG1SdS3.js} +3 -3
  23. package/dist/browser/{graphql-editor-CiGd_Li7.js.map → graphql-editor-DMG1SdS3.js.map} +1 -1
  24. package/dist/browser/index.js +2 -2
  25. package/dist/browser/{json-editor-sEqd5piI.js → json-editor-C9wagvps.js} +3 -3
  26. package/dist/browser/{json-editor-sEqd5piI.js.map → json-editor-C9wagvps.js.map} +1 -1
  27. package/dist/browser/{state-schemas-DJmzG_M8.js → state-schemas-CDE7-WSq.js} +12 -12
  28. package/dist/browser/state-schemas-CDE7-WSq.js.map +1 -0
  29. package/dist/node/{connect-BLC4PXD9.mjs → connect-C5Fwy1TV.mjs} +93 -93
  30. package/dist/node/connect-C5Fwy1TV.mjs.map +1 -0
  31. package/dist/node/{dist-Bm05eoTg.mjs → dist-BCpGdShB.mjs} +95 -61
  32. package/dist/node/dist-BCpGdShB.mjs.map +1 -0
  33. package/dist/node/{dist-Cn3iExnV.mjs → dist-C88eUERe.mjs} +46 -7
  34. package/dist/node/dist-C88eUERe.mjs.map +1 -0
  35. package/dist/node/{document-drive-sM33juXr.mjs → document-drive-DjL9iikf.mjs} +314 -9
  36. package/dist/node/document-drive-DjL9iikf.mjs.map +1 -0
  37. package/dist/node/document-models/index.mjs +1 -1
  38. package/dist/node/{editor-BrS98lEH.mjs → editor-CIR848q-.mjs} +5 -5
  39. package/dist/node/{editor-BrS98lEH.mjs.map → editor-CIR848q-.mjs.map} +1 -1
  40. package/dist/node/{editor-BFBa9nsO.mjs → editor-DmB3aE4K.mjs} +21 -21
  41. package/dist/node/editor-DmB3aE4K.mjs.map +1 -0
  42. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  43. package/dist/node/editors/generic-drive-explorer/index.mjs +5 -5
  44. package/dist/node/editors/generic-drive-explorer/index.mjs.map +1 -1
  45. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  46. package/dist/node/{folder-view-DHph3Yuu.mjs → folder-view-OzKx5KyJ.mjs} +7 -7
  47. package/dist/node/folder-view-OzKx5KyJ.mjs.map +1 -0
  48. package/dist/node/{graphql-editor-CPq7oIbf.mjs → graphql-editor-CG9Wyp7N.mjs} +3 -3
  49. package/dist/node/{graphql-editor-CPq7oIbf.mjs.map → graphql-editor-CG9Wyp7N.mjs.map} +1 -1
  50. package/dist/node/index.mjs +2 -2
  51. package/dist/node/{json-editor-L32CP7TS.mjs → json-editor-CfA5q_6F.mjs} +3 -3
  52. package/dist/node/{json-editor-L32CP7TS.mjs.map → json-editor-CfA5q_6F.mjs.map} +1 -1
  53. package/dist/node/{state-schemas-XTTjQZOe.mjs → state-schemas-DVr0xm_W.mjs} +12 -12
  54. package/dist/node/state-schemas-DVr0xm_W.mjs.map +1 -0
  55. package/package.json +6 -6
  56. package/dist/browser/connect-ZnLjvmRt.js.map +0 -1
  57. package/dist/browser/dist-C1nRM9t2.js.map +0 -1
  58. package/dist/browser/dist-DLFI75Zd.js.map +0 -1
  59. package/dist/browser/document-drive-oqv68jDU.js.map +0 -1
  60. package/dist/browser/editor-CoTq6fqT.js.map +0 -1
  61. package/dist/browser/folder-view-DmYBf2pP.js.map +0 -1
  62. package/dist/browser/state-schemas-DJmzG_M8.js.map +0 -1
  63. package/dist/node/connect-BLC4PXD9.mjs.map +0 -1
  64. package/dist/node/dist-Bm05eoTg.mjs.map +0 -1
  65. package/dist/node/dist-Cn3iExnV.mjs.map +0 -1
  66. package/dist/node/document-drive-sM33juXr.mjs.map +0 -1
  67. package/dist/node/editor-BFBa9nsO.mjs.map +0 -1
  68. package/dist/node/folder-view-DHph3Yuu.mjs.map +0 -1
  69. package/dist/node/state-schemas-XTTjQZOe.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { E as __commonJSMin, j as __toESM, t as capitalCase } from "./dist-fA4EItr0.mjs";
2
- import { A as replayDocument, J as validateStateSchemaName, K as validateInitialState, S as createZip, Y as generateId, _ as baseSaveToFileHandle, a as handleTargetNameCollisions, c as moveNode, d as logger, g as baseLoadFromInput, i as generateNodesCopy, l as updateNode, n as copyNode, o as isFileNode, q as validateModules, r as driveDocumentModelModule, s as isFolderNode, t as addFolder$1, u as documentModelDocumentModelModule, v as buildSignedAction, y as createPresignedHeader, z as setName } from "./document-drive-sM33juXr.mjs";
3
- import { a as SyncStatus, n as require_main, o as ModuleNotFoundError, s as driveCollectionId, t as reactorDriveDocumentModelModule } from "./dist-Cn3iExnV.mjs";
4
- import { Children, cloneElement, forwardRef, isValidElement, use, useEffect, useMemo, useState, useSyncExternalStore } from "react";
2
+ import { B as setName, C as createZip, J as validateModules, X as generateId, Y as validateStateSchemaName, _ as baseLoadFromInputVersioned, a as handleTargetNameCollisions, b as createPresignedHeader, c as moveNode, d as logger, g as baseLoadFromInput, i as generateNodesCopy, j as replayDocumentVersioned, l as updateNode, n as copyNode, o as isFileNode, q as validateInitialState, r as driveDocumentModelModule, s as isFolderNode, t as addFolder$1, u as documentModelDocumentModelModule, v as baseSaveToFileHandle, y as buildSignedAction } from "./document-drive-DjL9iikf.mjs";
3
+ import { a as SyncStatus, n as require_main, o as DriveCollectionId, s as ModuleNotFoundError, t as reactorDriveDocumentModelModule } from "./dist-C88eUERe.mjs";
4
+ import { Children, cloneElement, forwardRef, isValidElement, use, useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
5
5
  import "react/jsx-runtime";
6
- //#region ../reactor-browser/dist/make-ph-event-functions-DwiD1zH9.js
6
+ //#region ../reactor-browser/dist/make-ph-event-functions-BHoLPif5.js
7
7
  const isServer$1 = typeof window === "undefined";
8
8
  function makePHEventFunctions(key) {
9
9
  const setEventName = `ph:set${capitalCase(key)}`;
@@ -51,7 +51,7 @@ function makePHEventFunctions(key) {
51
51
  };
52
52
  }
53
53
  //#endregion
54
- //#region ../reactor-browser/dist/document-by-id-BrIy0iHX.js
54
+ //#region ../reactor-browser/dist/document-by-id-dLYFX-xz.js
55
55
  async function queueActions(document, actionOrActions) {
56
56
  if (!document) throw new Error("No document provided");
57
57
  if (!actionOrActions) throw new Error("No actions provided");
@@ -196,6 +196,18 @@ function useDocument(id) {
196
196
  const document = useSyncExternalStore((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : void 0);
197
197
  return document ? use(document) : void 0;
198
198
  }
199
+ /**
200
+ * Returns a function to retrieve a document from the cache.
201
+ * The returned function fetches and returns a document by ID.
202
+ * @returns A function that takes a document ID and returns a Promise of the document
203
+ */
204
+ function useGetDocument() {
205
+ const documentCache = useDocumentCache();
206
+ return useCallback((id) => {
207
+ if (!documentCache) return Promise.reject(/* @__PURE__ */ new Error("Document cache not initialized"));
208
+ return documentCache.get(id);
209
+ }, [documentCache]);
210
+ }
199
211
  function useDispatch(document) {
200
212
  /**
201
213
  * Dispatches actions to the document.
@@ -214,7 +226,7 @@ function useDocumentById(id) {
214
226
  return [document, dispatch];
215
227
  }
216
228
  //#endregion
217
- //#region ../reactor-browser/dist/client-D7hUM13i.js
229
+ //#region ../reactor-browser/dist/client-_Gh2Uf0E.js
218
230
  var import_main = require_main();
219
231
  const PhDocumentFieldsFragmentDoc = import_main.gql`
220
232
  fragment PHDocumentFields on PHDocument {
@@ -283,13 +295,6 @@ const GetDocumentWithOperationsDocument = import_main.gql`
283
295
  timestampUtcMs
284
296
  input
285
297
  scope
286
- attachments {
287
- data
288
- mimeType
289
- hash
290
- extension
291
- fileName
292
- }
293
298
  context {
294
299
  signer {
295
300
  user {
@@ -402,13 +407,6 @@ const GetDocumentOperationsDocument = import_main.gql`
402
407
  timestampUtcMs
403
408
  input
404
409
  scope
405
- attachments {
406
- data
407
- mimeType
408
- hash
409
- extension
410
- fileName
411
- }
412
410
  context {
413
411
  signer {
414
412
  user {
@@ -659,13 +657,6 @@ import_main.gql`
659
657
  timestampUtcMs
660
658
  input
661
659
  scope
662
- attachments {
663
- data
664
- mimeType
665
- hash
666
- extension
667
- fileName
668
- }
669
660
  context {
670
661
  signer {
671
662
  user {
@@ -747,7 +738,7 @@ function extractQueryParts(doc, fallbackBody) {
747
738
  extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
748
739
  extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
749
740
  //#endregion
750
- //#region ../reactor-browser/dist/renown-Dzmo1gJD.js
741
+ //#region ../reactor-browser/dist/renown-D-1c_Bvx.js
751
742
  const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
752
743
  const renownEventFunctions = makePHEventFunctions("renown");
753
744
  renownEventFunctions.addEventHandler;
@@ -2510,14 +2501,30 @@ async function exportFile(document, suggestedName) {
2510
2501
  if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
2511
2502
  }
2512
2503
  }
2504
+ /**
2505
+ * Loads a document file and replays it with version-aware reducers from the registry.
2506
+ * Falls back to single-version legacy replay when no upgrade manifest is registered for
2507
+ * the document type.
2508
+ */
2513
2509
  async function loadFile(path) {
2514
2510
  const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
2515
2511
  const reactorClient = window.ph?.reactorClient;
2516
2512
  if (!reactorClient) throw new Error("ReactorClient not initialized");
2513
+ const documentType = baseDocument.header.documentType;
2517
2514
  const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
2518
- const documentModelModule = documentModelModules.find((module) => module.documentModel.global.id === baseDocument.header.documentType);
2519
- if (!documentModelModule) throw new DocumentModelNotFoundError(baseDocument.header.documentType);
2520
- return documentModelModule.utils.loadFromInput(path);
2515
+ const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
2516
+ if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
2517
+ const reducers = {};
2518
+ for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
2519
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2520
+ let upgradeManifest;
2521
+ if (registry) try {
2522
+ upgradeManifest = registry.getUpgradeManifest(documentType);
2523
+ } catch {}
2524
+ return baseLoadFromInputVersioned(path, {
2525
+ reducers,
2526
+ upgradeManifest
2527
+ });
2521
2528
  }
2522
2529
  async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
2523
2530
  const { isAllowedToCreateDocuments } = getUserPermissions();
@@ -2639,9 +2646,28 @@ async function moveNode$1(driveId, src, target) {
2639
2646
  targetParentFolder: target?.id
2640
2647
  })]);
2641
2648
  }
2649
+ /**
2650
+ * Duplicates a document under a new id using version-aware replay.
2651
+ * Falls back gracefully when no upgrade manifest is registered for the document type.
2652
+ */
2642
2653
  async function _duplicateDocument(reactor, document, newId = generateId()) {
2643
- const documentModule = await reactor.getDocumentModelModule(document.header.documentType);
2644
- return replayDocument(document.initialState, document.operations, documentModule.reducer, createPresignedHeader(newId, document.header.documentType));
2654
+ const documentType = document.header.documentType;
2655
+ const { results: allModules } = await reactor.getDocumentModelModules();
2656
+ const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
2657
+ const reducers = {};
2658
+ for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
2659
+ if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
2660
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2661
+ let upgradeManifest;
2662
+ if (registry) try {
2663
+ upgradeManifest = registry.getUpgradeManifest(documentType);
2664
+ } catch {}
2665
+ const config = {
2666
+ reducers,
2667
+ upgradeManifest
2668
+ };
2669
+ const header = createPresignedHeader(newId, documentType);
2670
+ return replayDocumentVersioned(document.initialState, document.operations, config, header);
2645
2671
  }
2646
2672
  async function copyNode$1(driveId, src, target) {
2647
2673
  const reactor = window.ph?.reactorClient;
@@ -2681,6 +2707,29 @@ async function copyNode$1(driveId, src, target) {
2681
2707
  }
2682
2708
  return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
2683
2709
  }
2710
+ const modalEventFunctions = makePHEventFunctions("modal");
2711
+ modalEventFunctions.useValue;
2712
+ /** Sets the current modal */
2713
+ const setPHModal = modalEventFunctions.setValue;
2714
+ modalEventFunctions.addEventHandler;
2715
+ /** Shows a modal */
2716
+ function showPHModal(modal) {
2717
+ setPHModal(modal);
2718
+ }
2719
+ /** Shows the create document modal */
2720
+ function showCreateDocumentModal(documentType) {
2721
+ setPHModal({
2722
+ type: "createDocument",
2723
+ documentType
2724
+ });
2725
+ }
2726
+ /** Shows the delete node modal */
2727
+ function showDeleteNodeModal(nodeOrId) {
2728
+ setPHModal({
2729
+ type: "deleteItem",
2730
+ id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
2731
+ });
2732
+ }
2684
2733
  const baseDocumentModelsMap = {
2685
2734
  DocumentModel: documentModelDocumentModelModule,
2686
2735
  DocumentDrive: driveDocumentModelModule,
@@ -3205,29 +3254,6 @@ const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLC
3205
3254
  graphQLReactorClientEventFunctions.useValue;
3206
3255
  graphQLReactorClientEventFunctions.setValue;
3207
3256
  graphQLReactorClientEventFunctions.addEventHandler;
3208
- const modalEventFunctions = makePHEventFunctions("modal");
3209
- modalEventFunctions.useValue;
3210
- /** Sets the current modal */
3211
- const setPHModal = modalEventFunctions.setValue;
3212
- modalEventFunctions.addEventHandler;
3213
- /** Shows a modal */
3214
- function showPHModal(modal) {
3215
- setPHModal(modal);
3216
- }
3217
- /** Shows the create document modal */
3218
- function showCreateDocumentModal(documentType) {
3219
- setPHModal({
3220
- type: "createDocument",
3221
- documentType
3222
- });
3223
- }
3224
- /** Shows the delete node modal */
3225
- function showDeleteNodeModal(nodeOrId) {
3226
- setPHModal({
3227
- type: "deleteItem",
3228
- id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
3229
- });
3230
- }
3231
3257
  const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
3232
3258
  packageDiscoveryFunctions.useValue;
3233
3259
  packageDiscoveryFunctions.setValue;
@@ -3432,9 +3458,17 @@ function downloadDocument(document, handleError = defaultHandleError) {
3432
3458
  exportFile(document).catch((error) => handleError(normalizeException(error)));
3433
3459
  }
3434
3460
  function useDownloadDocument(id) {
3435
- const [document] = useDocumentById(id);
3461
+ const getDocument = useGetDocument();
3436
3462
  const toast = usePHToast();
3437
- return () => downloadDocument(document, (error) => toast?.(`Failed to export document: ${error.message}`));
3463
+ return async () => {
3464
+ if (!id) return;
3465
+ const handleError = (error) => toast?.(`Failed to export document: ${error.message}`);
3466
+ try {
3467
+ downloadDocument(await getDocument(id), handleError);
3468
+ } catch (error) {
3469
+ handleError(error);
3470
+ }
3471
+ };
3438
3472
  }
3439
3473
  function useFolderById(id) {
3440
3474
  return useFolderNodesInSelectedDrive()?.find((n) => n.id === id);
@@ -3670,12 +3704,12 @@ function useGetSwitchboardLink(document) {
3670
3704
  const remotes = useSyncList();
3671
3705
  const isRemoteDrive = useMemo(() => {
3672
3706
  if (!e$4(drive)) return false;
3673
- return remotes.some((remote) => remote.collectionId === driveCollectionId("main", drive.header.id));
3707
+ return remotes.some((remote) => remote.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
3674
3708
  }, [remotes, drive]);
3675
3709
  const remoteUrl = useMemo(() => {
3676
3710
  if (!e$4(drive)) return null;
3677
3711
  try {
3678
- const channelUrl = (remotes.find((remote) => remote.collectionId === driveCollectionId("main", drive.header.id))?.channel)?.config.url;
3712
+ const channelUrl = (remotes.find((remote) => remote.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)))?.channel)?.config.url;
3679
3713
  if (typeof channelUrl === "string") return channelUrl;
3680
3714
  return null;
3681
3715
  } catch (error) {
@@ -3766,4 +3800,4 @@ createDebouncedRefreshReactorDataClient();
3766
3800
  //#endregion
3767
3801
  export { e$4 as A, useSelectedDriveSafe as C, useTheme as D, useSetPHDocumentEditorConfig as E, t$5 as M, useDocumentById as N, useUserPermissions as O, useSelectedDriveId as S, useSetPHAppConfig as T, useNodeParentFolderById as _, setSelectedDrive as a, useSelectedDocumentOfType as b, showDeleteNodeModal as c, useDownloadDocument as d, useDragNode as f, useNodeById as g, useNodeActions as h, isFolderNodeKind as i, t$2 as j, e$1 as k, showRevisionHistory as l, useGetSwitchboardLink as m, getSyncStatusSync as n, setSelectedNode as o, useDropNode as p, isFileNodeKind as r, showCreateDocumentModal as s, addFolder as t, useDocumentModelModules as u, useNodesInSelectedDriveOrFolder as v, useSelectedNodePath as w, useSelectedDocumentSafe as x, usePHToast as y };
3768
3802
 
3769
- //# sourceMappingURL=dist-Bm05eoTg.mjs.map
3803
+ //# sourceMappingURL=dist-BCpGdShB.mjs.map