@powerhousedao/powerhouse-vetra-packages 6.2.0-dev.2 → 6.2.0-dev.21

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-Bo3FDnsW.js} +45 -45
  4. package/dist/browser/connect-Bo3FDnsW.js.map +1 -0
  5. package/dist/browser/{dist-C1nRM9t2.js → dist-8DwGBjee.js} +72 -58
  6. package/dist/browser/dist-8DwGBjee.js.map +1 -0
  7. package/dist/browser/{dist-DLFI75Zd.js → dist-DXM8ccKa.js} +46 -7
  8. package/dist/browser/dist-DXM8ccKa.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-CoTq6fqT.js → editor-B4oNCwiL.js} +21 -21
  13. package/dist/browser/editor-B4oNCwiL.js.map +1 -0
  14. package/dist/browser/{editor-DC3bigBu.js → editor-IU5iuNBj.js} +5 -5
  15. package/dist/browser/{editor-DC3bigBu.js.map → editor-IU5iuNBj.js.map} +1 -1
  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-BhY9Mjgv.js} +7 -7
  21. package/dist/browser/folder-view-BhY9Mjgv.js.map +1 -0
  22. package/dist/browser/{graphql-editor-CiGd_Li7.js → graphql-editor-Cz-MK2uE.js} +3 -3
  23. package/dist/browser/{graphql-editor-CiGd_Li7.js.map → graphql-editor-Cz-MK2uE.js.map} +1 -1
  24. package/dist/browser/index.js +2 -2
  25. package/dist/browser/{json-editor-sEqd5piI.js → json-editor-BoQLblBv.js} +3 -3
  26. package/dist/browser/{json-editor-sEqd5piI.js.map → json-editor-BoQLblBv.js.map} +1 -1
  27. package/dist/browser/{state-schemas-DJmzG_M8.js → state-schemas-C5GjGnKu.js} +12 -12
  28. package/dist/browser/state-schemas-C5GjGnKu.js.map +1 -0
  29. package/dist/node/{connect-BLC4PXD9.mjs → connect-CTnyQiGd.mjs} +45 -45
  30. package/dist/node/connect-CTnyQiGd.mjs.map +1 -0
  31. package/dist/node/{dist-Cn3iExnV.mjs → dist-C88eUERe.mjs} +46 -7
  32. package/dist/node/dist-C88eUERe.mjs.map +1 -0
  33. package/dist/node/{dist-Bm05eoTg.mjs → dist-DUNKfQX4.mjs} +72 -58
  34. package/dist/node/dist-DUNKfQX4.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-BFBa9nsO.mjs → editor-BckQifh7.mjs} +21 -21
  39. package/dist/node/editor-BckQifh7.mjs.map +1 -0
  40. package/dist/node/{editor-BrS98lEH.mjs → editor-m0rY3A7P.mjs} +5 -5
  41. package/dist/node/{editor-BrS98lEH.mjs.map → editor-m0rY3A7P.mjs.map} +1 -1
  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-ClopFdxe.mjs} +7 -7
  47. package/dist/node/folder-view-ClopFdxe.mjs.map +1 -0
  48. package/dist/node/{graphql-editor-CPq7oIbf.mjs → graphql-editor-DXkhnv8j.mjs} +3 -3
  49. package/dist/node/{graphql-editor-CPq7oIbf.mjs.map → graphql-editor-DXkhnv8j.mjs.map} +1 -1
  50. package/dist/node/index.mjs +2 -2
  51. package/dist/node/{json-editor-L32CP7TS.mjs → json-editor-Dr57NX3w.mjs} +3 -3
  52. package/dist/node/{json-editor-L32CP7TS.mjs.map → json-editor-Dr57NX3w.mjs.map} +1 -1
  53. package/dist/node/{state-schemas-XTTjQZOe.mjs → state-schemas-D6aPAH4x.mjs} +12 -12
  54. package/dist/node/state-schemas-D6aPAH4x.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, k as __toESM, t as capitalCase } from "./dist-CXoKspdx.js";
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-oqv68jDU.js";
3
- import { c as driveCollectionId, n as gql, o as SyncStatus, s as ModuleNotFoundError, t as reactorDriveDocumentModelModule } from "./dist-DLFI75Zd.js";
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-sTKoi6L4.js";
3
+ import { c as ModuleNotFoundError, n as gql, o as SyncStatus, s as DriveCollectionId, t as reactorDriveDocumentModelModule } from "./dist-DXM8ccKa.js";
4
4
  import { Children, cloneElement, forwardRef, isValidElement, use, 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");
@@ -214,7 +214,7 @@ function useDocumentById(id) {
214
214
  return [document, dispatch];
215
215
  }
216
216
  //#endregion
217
- //#region ../reactor-browser/dist/client-D7hUM13i.js
217
+ //#region ../reactor-browser/dist/client-_Gh2Uf0E.js
218
218
  const PhDocumentFieldsFragmentDoc = gql`
219
219
  fragment PHDocumentFields on PHDocument {
220
220
  id
@@ -282,13 +282,6 @@ const GetDocumentWithOperationsDocument = gql`
282
282
  timestampUtcMs
283
283
  input
284
284
  scope
285
- attachments {
286
- data
287
- mimeType
288
- hash
289
- extension
290
- fileName
291
- }
292
285
  context {
293
286
  signer {
294
287
  user {
@@ -401,13 +394,6 @@ const GetDocumentOperationsDocument = gql`
401
394
  timestampUtcMs
402
395
  input
403
396
  scope
404
- attachments {
405
- data
406
- mimeType
407
- hash
408
- extension
409
- fileName
410
- }
411
397
  context {
412
398
  signer {
413
399
  user {
@@ -658,13 +644,6 @@ gql`
658
644
  timestampUtcMs
659
645
  input
660
646
  scope
661
- attachments {
662
- data
663
- mimeType
664
- hash
665
- extension
666
- fileName
667
- }
668
647
  context {
669
648
  signer {
670
649
  user {
@@ -746,7 +725,7 @@ function extractQueryParts(doc, fallbackBody) {
746
725
  extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
747
726
  extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
748
727
  //#endregion
749
- //#region ../reactor-browser/dist/renown-Dzmo1gJD.js
728
+ //#region ../reactor-browser/dist/renown-D-1c_Bvx.js
750
729
  const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
751
730
  const renownEventFunctions = makePHEventFunctions("renown");
752
731
  renownEventFunctions.addEventHandler;
@@ -2509,14 +2488,30 @@ async function exportFile(document, suggestedName) {
2509
2488
  if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
2510
2489
  }
2511
2490
  }
2491
+ /**
2492
+ * Loads a document file and replays it with version-aware reducers from the registry.
2493
+ * Falls back to single-version legacy replay when no upgrade manifest is registered for
2494
+ * the document type.
2495
+ */
2512
2496
  async function loadFile(path) {
2513
2497
  const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
2514
2498
  const reactorClient = window.ph?.reactorClient;
2515
2499
  if (!reactorClient) throw new Error("ReactorClient not initialized");
2500
+ const documentType = baseDocument.header.documentType;
2516
2501
  const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
2517
- const documentModelModule = documentModelModules.find((module) => module.documentModel.global.id === baseDocument.header.documentType);
2518
- if (!documentModelModule) throw new DocumentModelNotFoundError(baseDocument.header.documentType);
2519
- return documentModelModule.utils.loadFromInput(path);
2502
+ const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
2503
+ if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
2504
+ const reducers = {};
2505
+ for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
2506
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2507
+ let upgradeManifest;
2508
+ if (registry) try {
2509
+ upgradeManifest = registry.getUpgradeManifest(documentType);
2510
+ } catch {}
2511
+ return baseLoadFromInputVersioned(path, {
2512
+ reducers,
2513
+ upgradeManifest
2514
+ });
2520
2515
  }
2521
2516
  async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
2522
2517
  const { isAllowedToCreateDocuments } = getUserPermissions();
@@ -2638,9 +2633,28 @@ async function moveNode$1(driveId, src, target) {
2638
2633
  targetParentFolder: target?.id
2639
2634
  })]);
2640
2635
  }
2636
+ /**
2637
+ * Duplicates a document under a new id using version-aware replay.
2638
+ * Falls back gracefully when no upgrade manifest is registered for the document type.
2639
+ */
2641
2640
  async function _duplicateDocument(reactor, document, newId = generateId()) {
2642
- const documentModule = await reactor.getDocumentModelModule(document.header.documentType);
2643
- return replayDocument(document.initialState, document.operations, documentModule.reducer, createPresignedHeader(newId, document.header.documentType));
2641
+ const documentType = document.header.documentType;
2642
+ const { results: allModules } = await reactor.getDocumentModelModules();
2643
+ const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
2644
+ const reducers = {};
2645
+ for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
2646
+ if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
2647
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2648
+ let upgradeManifest;
2649
+ if (registry) try {
2650
+ upgradeManifest = registry.getUpgradeManifest(documentType);
2651
+ } catch {}
2652
+ const config = {
2653
+ reducers,
2654
+ upgradeManifest
2655
+ };
2656
+ const header = createPresignedHeader(newId, documentType);
2657
+ return replayDocumentVersioned(document.initialState, document.operations, config, header);
2644
2658
  }
2645
2659
  async function copyNode$1(driveId, src, target) {
2646
2660
  const reactor = window.ph?.reactorClient;
@@ -2680,6 +2694,29 @@ async function copyNode$1(driveId, src, target) {
2680
2694
  }
2681
2695
  return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
2682
2696
  }
2697
+ const modalEventFunctions = makePHEventFunctions("modal");
2698
+ modalEventFunctions.useValue;
2699
+ /** Sets the current modal */
2700
+ const setPHModal = modalEventFunctions.setValue;
2701
+ modalEventFunctions.addEventHandler;
2702
+ /** Shows a modal */
2703
+ function showPHModal(modal) {
2704
+ setPHModal(modal);
2705
+ }
2706
+ /** Shows the create document modal */
2707
+ function showCreateDocumentModal(documentType) {
2708
+ setPHModal({
2709
+ type: "createDocument",
2710
+ documentType
2711
+ });
2712
+ }
2713
+ /** Shows the delete node modal */
2714
+ function showDeleteNodeModal(nodeOrId) {
2715
+ setPHModal({
2716
+ type: "deleteItem",
2717
+ id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
2718
+ });
2719
+ }
2683
2720
  const baseDocumentModelsMap = {
2684
2721
  DocumentModel: documentModelDocumentModelModule,
2685
2722
  DocumentDrive: driveDocumentModelModule,
@@ -3204,29 +3241,6 @@ const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLC
3204
3241
  graphQLReactorClientEventFunctions.useValue;
3205
3242
  graphQLReactorClientEventFunctions.setValue;
3206
3243
  graphQLReactorClientEventFunctions.addEventHandler;
3207
- const modalEventFunctions = makePHEventFunctions("modal");
3208
- modalEventFunctions.useValue;
3209
- /** Sets the current modal */
3210
- const setPHModal = modalEventFunctions.setValue;
3211
- modalEventFunctions.addEventHandler;
3212
- /** Shows a modal */
3213
- function showPHModal(modal) {
3214
- setPHModal(modal);
3215
- }
3216
- /** Shows the create document modal */
3217
- function showCreateDocumentModal(documentType) {
3218
- setPHModal({
3219
- type: "createDocument",
3220
- documentType
3221
- });
3222
- }
3223
- /** Shows the delete node modal */
3224
- function showDeleteNodeModal(nodeOrId) {
3225
- setPHModal({
3226
- type: "deleteItem",
3227
- id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
3228
- });
3229
- }
3230
3244
  const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
3231
3245
  packageDiscoveryFunctions.useValue;
3232
3246
  packageDiscoveryFunctions.setValue;
@@ -3669,12 +3683,12 @@ function useGetSwitchboardLink(document) {
3669
3683
  const remotes = useSyncList();
3670
3684
  const isRemoteDrive = useMemo(() => {
3671
3685
  if (!e$4(drive)) return false;
3672
- return remotes.some((remote) => remote.collectionId === driveCollectionId("main", drive.header.id));
3686
+ return remotes.some((remote) => remote.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
3673
3687
  }, [remotes, drive]);
3674
3688
  const remoteUrl = useMemo(() => {
3675
3689
  if (!e$4(drive)) return null;
3676
3690
  try {
3677
- const channelUrl = (remotes.find((remote) => remote.collectionId === driveCollectionId("main", drive.header.id))?.channel)?.config.url;
3691
+ const channelUrl = (remotes.find((remote) => remote.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)))?.channel)?.config.url;
3678
3692
  if (typeof channelUrl === "string") return channelUrl;
3679
3693
  return null;
3680
3694
  } catch (error) {
@@ -3765,4 +3779,4 @@ createDebouncedRefreshReactorDataClient();
3765
3779
  //#endregion
3766
3780
  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 };
3767
3781
 
3768
- //# sourceMappingURL=dist-C1nRM9t2.js.map
3782
+ //# sourceMappingURL=dist-8DwGBjee.js.map