@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.82 → 6.2.2-dev.84

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 (51) hide show
  1. package/dist/browser/{connect-Bpm1qc2o.js → connect-CZxjNDFs.js} +14 -5
  2. package/dist/browser/{connect-Bpm1qc2o.js.map → connect-CZxjNDFs.js.map} +1 -1
  3. package/dist/browser/{dist-DzuQgnp9.js → dist-CnNpgEVe.js} +134 -4
  4. package/dist/browser/dist-CnNpgEVe.js.map +1 -0
  5. package/dist/browser/{document-drive-BVYCdu_5.js → document-drive-ZQzPQfEL.js} +12 -5
  6. package/dist/browser/{document-drive-BVYCdu_5.js.map → document-drive-ZQzPQfEL.js.map} +1 -1
  7. package/dist/browser/document-models/index.js +1 -1
  8. package/dist/browser/{editor-BhVC9JGB.js → editor-Dg_2AIoc.js} +5 -5
  9. package/dist/browser/{editor-BhVC9JGB.js.map → editor-Dg_2AIoc.js.map} +1 -1
  10. package/dist/browser/{editor-Cr2SUFnl.js → editor-TmNqs_3q.js} +6 -6
  11. package/dist/browser/{editor-Cr2SUFnl.js.map → editor-TmNqs_3q.js.map} +1 -1
  12. package/dist/browser/editors/document-model-editor/module.js +1 -1
  13. package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
  14. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  15. package/dist/browser/{folder-view-EDdZl1fJ.js → folder-view-B7P3uF6d.js} +3 -3
  16. package/dist/browser/{folder-view-EDdZl1fJ.js.map → folder-view-B7P3uF6d.js.map} +1 -1
  17. package/dist/browser/{graphql-editor-BjkthIT9.js → graphql-editor-tFWpwJhB.js} +3 -3
  18. package/dist/browser/{graphql-editor-BjkthIT9.js.map → graphql-editor-tFWpwJhB.js.map} +1 -1
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/{json-editor-nLgiw_aY.js → json-editor-DczBqrwD.js} +3 -3
  21. package/dist/browser/{json-editor-nLgiw_aY.js.map → json-editor-DczBqrwD.js.map} +1 -1
  22. package/dist/browser/lib-ewnRj2dJ.js.map +1 -1
  23. package/dist/browser/{state-schemas-IiwC01DT.js → state-schemas-inzuDitu.js} +3 -3
  24. package/dist/browser/{state-schemas-IiwC01DT.js.map → state-schemas-inzuDitu.js.map} +1 -1
  25. package/dist/node/{connect-DzMvrvtH.mjs → connect-Bfdoq4eL.mjs} +14 -5
  26. package/dist/node/{connect-DzMvrvtH.mjs.map → connect-Bfdoq4eL.mjs.map} +1 -1
  27. package/dist/node/{dist-CWqCyPep.mjs → dist-BDq_3xzc.mjs} +134 -4
  28. package/dist/node/dist-BDq_3xzc.mjs.map +1 -0
  29. package/dist/node/{document-drive-lf_0SP-H.mjs → document-drive-D1NMjQQc.mjs} +12 -5
  30. package/dist/node/{document-drive-lf_0SP-H.mjs.map → document-drive-D1NMjQQc.mjs.map} +1 -1
  31. package/dist/node/document-models/index.mjs +1 -1
  32. package/dist/node/{editor-DSlBxXEG.mjs → editor-DQvgS2LK.mjs} +5 -5
  33. package/dist/node/{editor-DSlBxXEG.mjs.map → editor-DQvgS2LK.mjs.map} +1 -1
  34. package/dist/node/{editor-BHFgv5Sn.mjs → editor-tTT_T9Fq.mjs} +6 -6
  35. package/dist/node/{editor-BHFgv5Sn.mjs.map → editor-tTT_T9Fq.mjs.map} +1 -1
  36. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  37. package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
  38. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  39. package/dist/node/{folder-view-BU4jkZT4.mjs → folder-view-Bjnpy_l9.mjs} +3 -3
  40. package/dist/node/{folder-view-BU4jkZT4.mjs.map → folder-view-Bjnpy_l9.mjs.map} +1 -1
  41. package/dist/node/{graphql-editor-CScEOmFM.mjs → graphql-editor-DK16Va7B.mjs} +3 -3
  42. package/dist/node/{graphql-editor-CScEOmFM.mjs.map → graphql-editor-DK16Va7B.mjs.map} +1 -1
  43. package/dist/node/index.mjs +1 -1
  44. package/dist/node/{json-editor-BkdBLGDx.mjs → json-editor-CUxDXYvs.mjs} +3 -3
  45. package/dist/node/{json-editor-BkdBLGDx.mjs.map → json-editor-CUxDXYvs.mjs.map} +1 -1
  46. package/dist/node/main-B1tRsYOp.mjs.map +1 -1
  47. package/dist/node/{state-schemas-BCTGWiNB.mjs → state-schemas-CbnYhOyM.mjs} +3 -3
  48. package/dist/node/{state-schemas-BCTGWiNB.mjs.map → state-schemas-CbnYhOyM.mjs.map} +1 -1
  49. package/package.json +7 -7
  50. package/dist/browser/dist-DzuQgnp9.js.map +0 -1
  51. package/dist/node/dist-CWqCyPep.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { A as __toESM, D as __commonJSMin, t as capitalCase } from "./dist-B4FWbuEM.js";
2
- import { C as baseLoadFromInputVersioned, O as createPresignedHeader, Q as setName, S as baseLoadFromInput, T as buildSignedAction, U as replayDocumentVersioned, a as handleTargetNameCollisions, ct as validateStateSchemaName, f as logger, h as UnsupportedDocumentModelVersionError, i as generateNodesCopy, j as createZip, l as moveNode, lt as generateId, n as copyNode, o as isFileNode, ot as validateInitialState, s as isFolderNode, st as validateModules, t as addFolder, u as updateNode, w as baseSaveToFileHandle, y as assertAuthPreservedOnDuplicate } from "./document-drive-BVYCdu_5.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
3
  import { a as SyncStatus, o as DriveCollectionId, s as ModuleNotFoundError, t as gql } from "./lib-ewnRj2dJ.js";
4
4
  import "./parser-CkF6Qt8V.js";
5
5
  import "./printer-CEYr4JOg.js";
@@ -2057,7 +2057,7 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
2057
2057
  })(MessageType || {});
2058
2058
  Error;
2059
2059
  //#endregion
2060
- //#region ../reactor-browser/dist/document-operations-BO-SlTDw.js
2060
+ //#region ../reactor-browser/dist/document-operations-Bo1dPDgq.js
2061
2061
  const modalEventFunctions = makePHEventFunctions("modal");
2062
2062
  modalEventFunctions.useValue;
2063
2063
  /** Sets the current modal */
@@ -3846,6 +3846,117 @@ var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((
3846
3846
  return LZString;
3847
3847
  });
3848
3848
  })))(), 1);
3849
+ const sanitize = (segment) => segment.replace(/\//g, "-");
3850
+ /**
3851
+ * Name segments from the exported folder (exclusive) down to `node`
3852
+ * (inclusive), in top-down order. `root === undefined` means the drive root:
3853
+ * all ancestors. A node that IS the exported folder yields no segments.
3854
+ */
3855
+ function segmentsBelow(root, node, allNodes) {
3856
+ const segments = [];
3857
+ let current = node;
3858
+ while (current && current.id !== root?.id) {
3859
+ segments.push(sanitize(current.name));
3860
+ const parentId = current.parentFolder;
3861
+ current = parentId ? allNodes.find((n) => n.id === parentId) : void 0;
3862
+ }
3863
+ return segments.reverse();
3864
+ }
3865
+ /**
3866
+ * Assemble the archive zip for a folder (or the whole drive when
3867
+ * `folderNode` is undefined). Every folder in the subtree becomes a
3868
+ * directory entry (empty folders survive); every file becomes a standard
3869
+ * single-document zip named after the node (drive naming convention:
3870
+ * `${name}.${extension}.phd`, ` (copy) N` on a same-folder collision).
3871
+ *
3872
+ * `fetchDocument` must return the document WITH its full operations and
3873
+ * initialState (see downloadFolderZip).
3874
+ */
3875
+ async function buildFolderZip(drive, folderNode, fetchDocument, onProgress) {
3876
+ const allNodes = drive.state.global.nodes;
3877
+ const topName = sanitize(folderNode?.name ?? (drive.state.global.name || drive.header.name));
3878
+ const subtree = folderNode ? [folderNode, ...getDescendants(folderNode, allNodes)] : allNodes;
3879
+ const entries = { [topName + "/"]: new Uint8Array(0) };
3880
+ for (const node of subtree) {
3881
+ if (!isFolderNode(node)) continue;
3882
+ const dir = [topName, ...segmentsBelow(folderNode, node, allNodes)].join("/");
3883
+ entries[dir + "/"] = new Uint8Array(0);
3884
+ }
3885
+ const files = subtree.filter(isFileNode);
3886
+ const failed = [];
3887
+ const usedNamesByDir = /* @__PURE__ */ new Map();
3888
+ let done = 0;
3889
+ for (const node of files) try {
3890
+ const doc = await fetchDocument(node.id);
3891
+ const extension = await getDocumentExtension(doc);
3892
+ const parent = node.parentFolder ? allNodes.find((n) => n.id === node.parentFolder) : void 0;
3893
+ const dir = [topName, ...parent ? segmentsBelow(folderNode, parent, allNodes) : []].join("/");
3894
+ let usedNames = usedNamesByDir.get(dir);
3895
+ if (!usedNames) {
3896
+ usedNames = /* @__PURE__ */ new Set();
3897
+ usedNamesByDir.set(dir, usedNames);
3898
+ }
3899
+ const base = sanitize(node.name);
3900
+ let candidate = base;
3901
+ let count = getNextCopyNumber([...usedNames], base);
3902
+ while (usedNames.has(candidate)) {
3903
+ candidate = `${base} (copy) ${count}`;
3904
+ count += 1;
3905
+ }
3906
+ usedNames.add(candidate);
3907
+ const leaf = extension ? `${candidate}.${extension}.phd` : `${candidate}.phd`;
3908
+ entries[`${dir}/${leaf}`] = await createZip(doc);
3909
+ } catch {
3910
+ failed.push(node.name);
3911
+ } finally {
3912
+ done += 1;
3913
+ onProgress?.(done, files.length);
3914
+ }
3915
+ return {
3916
+ zip: await zipEntries(entries),
3917
+ archiveName: `${topName}.zip`,
3918
+ entryCount: files.length - failed.length,
3919
+ failed
3920
+ };
3921
+ }
3922
+ /**
3923
+ * Export a folder (or whole drive) to disk: fetches every document with its
3924
+ * full operation history, builds the archive, and saves it via
3925
+ * showSaveFilePicker (fallback: blob download), mirroring exportFile.
3926
+ */
3927
+ async function downloadFolderZip(drive, folderNode, onProgress) {
3928
+ const reactorClient = window.ph?.reactorClient;
3929
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
3930
+ const result = await buildFolderZip(drive, folderNode, async (id) => {
3931
+ const doc = await reactorClient.get(id);
3932
+ const operations = await fetchDocumentOperations(reactorClient, doc);
3933
+ const initialState = extractInitialState(operations["document"] ?? []);
3934
+ return {
3935
+ ...doc,
3936
+ operations,
3937
+ initialState
3938
+ };
3939
+ }, onProgress);
3940
+ if (!window.showSaveFilePicker) {
3941
+ const blob = new Blob([new Uint8Array(result.zip)], { type: "application/zip" });
3942
+ const link = window.document.createElement("a");
3943
+ link.style.display = "none";
3944
+ link.href = URL.createObjectURL(blob);
3945
+ link.download = result.archiveName;
3946
+ window.document.body.appendChild(link);
3947
+ link.click();
3948
+ window.document.body.removeChild(link);
3949
+ return result;
3950
+ }
3951
+ try {
3952
+ const writable = await (await window.showSaveFilePicker({ suggestedName: result.archiveName })).createWritable();
3953
+ await writable.write(new Uint8Array(result.zip));
3954
+ await writable.close();
3955
+ } catch (e) {
3956
+ if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
3957
+ }
3958
+ return result;
3959
+ }
3849
3960
  /** Document types that represent a "drive": a container of nodes. */
3850
3961
  const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
3851
3962
  function useAllowedDocumentModelModules() {
@@ -4023,6 +4134,25 @@ function useDownloadDocument(id) {
4023
4134
  }
4024
4135
  };
4025
4136
  }
4137
+ /**
4138
+ * Downloads the selected drive's folder (or the whole drive when no folder
4139
+ * is given) as a single zip archive mirroring the folder tree.
4140
+ */
4141
+ function useDownloadFolder(folderNode) {
4142
+ const [selectedDrive] = useSelectedDriveSafe();
4143
+ const toast = usePHToast();
4144
+ return async () => {
4145
+ if (!selectedDrive) return;
4146
+ const name = folderNode?.name ?? selectedDrive.header.name;
4147
+ toast?.(`Downloading "${name}"…`);
4148
+ try {
4149
+ const { entryCount, failed } = await downloadFolderZip(selectedDrive, folderNode);
4150
+ toast?.(failed.length ? `Downloaded ${entryCount} files (${failed.length} failed)` : `Downloaded ${entryCount} files`);
4151
+ } catch (error) {
4152
+ toast?.(`Failed to download "${name}": ${error.message}`);
4153
+ }
4154
+ };
4155
+ }
4026
4156
  /** An editor is a drive "app" if it targets any supported drive document type. */
4027
4157
  function isDriveEditor(module) {
4028
4158
  const driveTypes = DRIVE_DOCUMENT_TYPES;
@@ -4369,6 +4499,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
4369
4499
  createDebouncedRefreshReactorData();
4370
4500
  createDebouncedRefreshReactorDataClient();
4371
4501
  //#endregion
4372
- export { usePHToast as A, useSelectedDriveId as B, addFolder$1 as C, useDisabledEditors as D, showRevisionHistory as E, t$5 as F, useDocumentById as H, isFileNodeKind as I, isFolderNodeKind as L, e$1 as M, e$4 as N, useDragNode as O, t$2 as P, setSelectedDrive as R, addDocument as S, showPHModal as T, useSelectedDriveSafe as V, useSetPHDocumentEditorConfig as _, useDownloadDocument as a, useSelectedDocumentOfType as b, useGetSwitchboardLink as c, useNodeParentFolderById as d, useNodesInSelectedDriveOrFolder as f, useSetPHAppConfig as g, useSelectedNodePath as h, useDocumentVersionStatus as i, useStudioMode as j, useDropNode as k, useNodeActions as l, useSelectedFolder as m, preloadEditorModule as n, useEditorModules as o, useParentFolderForSelectedNode as p, useAllowedDocumentModelModules as r, useEditorModulesForDocumentType as s, getSyncStatusSync as t, useNodeById as u, useTheme as v, showDeleteNodeModal as w, useSelectedDocumentSafe as x, useUserPermissions as y, setSelectedNode as z };
4502
+ 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 };
4373
4503
 
4374
- //# sourceMappingURL=dist-DzuQgnp9.js.map
4504
+ //# sourceMappingURL=dist-CnNpgEVe.js.map