@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.6 → 6.2.3-dev.7

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 (55) hide show
  1. package/dist/browser/assets/{entry-5_Eh4a2Z.js → entry-DSBtQnit.js} +2 -2
  2. package/dist/browser/assets/{projection-entry-5PVbP10h.js → projection-entry-Bem3exmO.js} +3 -3
  3. package/dist/browser/{connect-BtHSAuSc.js → connect-5NZDVmbb.js} +4 -4
  4. package/dist/browser/{connect-BtHSAuSc.js.map → connect-5NZDVmbb.js.map} +1 -1
  5. package/dist/browser/{dist-D69hfRZN.js → dist-1yB-AuT-.js} +3 -3
  6. package/dist/browser/{dist-D69hfRZN.js.map → dist-1yB-AuT-.js.map} +1 -1
  7. package/dist/browser/{document-drive-BEXJ-rHp.js → document-drive-CrvzV1D4.js} +79 -37
  8. package/dist/browser/{document-drive-BEXJ-rHp.js.map → document-drive-CrvzV1D4.js.map} +1 -1
  9. package/dist/browser/document-models/index.js +1 -1
  10. package/dist/browser/{editor-mNThkZOv.js → editor-6T4WF2og.js} +6 -6
  11. package/dist/browser/{editor-mNThkZOv.js.map → editor-6T4WF2og.js.map} +1 -1
  12. package/dist/browser/{editor-Cbl_EDjI.js → editor-DHysndk4.js} +5 -5
  13. package/dist/browser/{editor-Cbl_EDjI.js.map → editor-DHysndk4.js.map} +1 -1
  14. package/dist/browser/editors/document-model-editor/module.js +1 -1
  15. package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
  16. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  17. package/dist/browser/{folder-view-D8AkN1Oj.js → folder-view-DTewe8q8.js} +3 -3
  18. package/dist/browser/{folder-view-D8AkN1Oj.js.map → folder-view-DTewe8q8.js.map} +1 -1
  19. package/dist/browser/{graphql-editor-BcL3-Zha.js → graphql-editor-C2EtXqb9.js} +3 -3
  20. package/dist/browser/{graphql-editor-BcL3-Zha.js.map → graphql-editor-C2EtXqb9.js.map} +1 -1
  21. package/dist/browser/index.js +2 -2
  22. package/dist/browser/{json-editor-DHXQRIN5.js → json-editor-xI_oaxyT.js} +3 -3
  23. package/dist/browser/{json-editor-DHXQRIN5.js.map → json-editor-xI_oaxyT.js.map} +1 -1
  24. package/dist/browser/{lib-ewnRj2dJ.js → lib-CPkPeg_u.js} +2 -2
  25. package/dist/browser/lib-CPkPeg_u.js.map +1 -0
  26. package/dist/browser/{state-schemas-C4F8lReN.js → state-schemas-CpcWN_Qo.js} +3 -3
  27. package/dist/browser/{state-schemas-C4F8lReN.js.map → state-schemas-CpcWN_Qo.js.map} +1 -1
  28. package/dist/node/{connect-B6IQsY6u.mjs → connect-cjzsd2cR.mjs} +4 -4
  29. package/dist/node/{connect-B6IQsY6u.mjs.map → connect-cjzsd2cR.mjs.map} +1 -1
  30. package/dist/node/{dist-hd-KLWy7.mjs → dist-C30J_pcg.mjs} +3 -3
  31. package/dist/node/{dist-hd-KLWy7.mjs.map → dist-C30J_pcg.mjs.map} +1 -1
  32. package/dist/node/{document-drive-CkV9NvD7.mjs → document-drive-BByBwg-I.mjs} +79 -37
  33. package/dist/node/{document-drive-CkV9NvD7.mjs.map → document-drive-BByBwg-I.mjs.map} +1 -1
  34. package/dist/node/document-models/index.mjs +1 -1
  35. package/dist/node/{editor-C93fdI28.mjs → editor-B4vhYrmV.mjs} +6 -6
  36. package/dist/node/{editor-C93fdI28.mjs.map → editor-B4vhYrmV.mjs.map} +1 -1
  37. package/dist/node/{editor-DG1q4Y55.mjs → editor-DPv5LEug.mjs} +5 -5
  38. package/dist/node/{editor-DG1q4Y55.mjs.map → editor-DPv5LEug.mjs.map} +1 -1
  39. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  40. package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
  41. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  42. package/dist/node/{folder-view-BGabHV7H.mjs → folder-view-BhackcXO.mjs} +3 -3
  43. package/dist/node/{folder-view-BGabHV7H.mjs.map → folder-view-BhackcXO.mjs.map} +1 -1
  44. package/dist/node/{graphql-editor-B-XIb6az.mjs → graphql-editor-D0CHQeCL.mjs} +3 -3
  45. package/dist/node/{graphql-editor-B-XIb6az.mjs.map → graphql-editor-D0CHQeCL.mjs.map} +1 -1
  46. package/dist/node/index.mjs +2 -2
  47. package/dist/node/{json-editor-DB0vi6tV.mjs → json-editor-Ckaem6ky.mjs} +3 -3
  48. package/dist/node/{json-editor-DB0vi6tV.mjs.map → json-editor-Ckaem6ky.mjs.map} +1 -1
  49. package/dist/node/{main-B1tRsYOp.mjs → main-BhH_ajBM.mjs} +2 -2
  50. package/dist/node/main-BhH_ajBM.mjs.map +1 -0
  51. package/dist/node/{state-schemas-BGsgtEG1.mjs → state-schemas-B1SNl8Ob.mjs} +3 -3
  52. package/dist/node/{state-schemas-BGsgtEG1.mjs.map → state-schemas-B1SNl8Ob.mjs.map} +1 -1
  53. package/package.json +7 -7
  54. package/dist/browser/lib-ewnRj2dJ.js.map +0 -1
  55. package/dist/node/main-B1tRsYOp.mjs.map +0 -1
@@ -8000,22 +8000,63 @@ function escapeRegExp(string) {
8000
8000
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8001
8001
  }
8002
8002
  /**
8003
- * The node list as plain objects for read-only scans. Inside a mutative draft
8004
- * this returns the untouched base list, so a find or filter over it does not
8005
- * create a child draft per element it visits. Callers must read before they
8006
- * write: the base list does not see mutations made earlier in the same action.
8003
+ * A plain, unfrozen copy of the node list for read-only scans. Inside a
8004
+ * mutative draft the copy is taken from the untouched base list, so a find or
8005
+ * filter over it does not create a child draft per element it visits, and it is
8006
+ * a copy because the stored list is frozen and V8 scans a frozen array several
8007
+ * times slower than a normal one. Callers must read before they write: the base
8008
+ * list does not see mutations made earlier in the same action.
8007
8009
  */
8008
8010
  function readNodes(state) {
8009
- return isDraft(state) ? original(state).nodes : state.nodes;
8011
+ return [...isDraft(state) ? original(state).nodes : state.nodes];
8010
8012
  }
8011
8013
  /**
8012
- * The node list with a node added, ordered by id. The list is built and sorted
8013
- * as plain objects, so inside a mutative draft the comparator never reads an
8014
- * element through the draft proxy. Pass the list read with readNodes to get
8015
- * that benefit; passing the draft's own list is correct but slow.
8014
+ * The given array sorted by id and frozen, in place -- it takes ownership of
8015
+ * the array it is handed, which is why it is private to this module and only
8016
+ * ever given a list built at the call site. The freeze is what makes assigning
8017
+ * the list to a mutative draft cheap: assigning a draftable value to a draft
8018
+ * property queues a finalize pass that walks every element of the assigned
8019
+ * value, and the walk exits at its Object.isFrozen check instead. Elements must
8020
+ * be plain nodes -- an element that is still a draft would never be replaced by
8021
+ * its final value, because the walk that does that replacement is the one being
8022
+ * skipped.
8023
+ */
8024
+ function freezeSortedById(nodes) {
8025
+ nodes.sort((a, b) => a.id.localeCompare(b.id));
8026
+ return Object.freeze(nodes);
8027
+ }
8028
+ /**
8029
+ * A copy of the given list, sorted by id and frozen, which is the shape the
8030
+ * node reducer assigns. Read the list with readNodes, build the new list from
8031
+ * it, and pass what this returns to assignNodes. The copy is what keeps the
8032
+ * freeze off the caller's array.
8033
+ */
8034
+ function sortNodesById(nodes) {
8035
+ return freezeSortedById([...nodes]);
8036
+ }
8037
+ /**
8038
+ * The node list with a node added, ordered by id and frozen, in the same shape
8039
+ * sortNodesById returns. The list is built and sorted as plain objects, so
8040
+ * inside a mutative draft the comparator never reads an element through the
8041
+ * draft proxy. Pass the list read with readNodes: the draft's own list would
8042
+ * put child drafts in the result, which the freeze then keeps mutative from
8043
+ * resolving.
8016
8044
  */
8017
8045
  function insertNodeSorted(nodes, node) {
8018
- return [...nodes, node].sort((a, b) => a.id.localeCompare(b.id));
8046
+ return freezeSortedById([...nodes, node]);
8047
+ }
8048
+ /**
8049
+ * Installs a node list as state.nodes. Every assignment the node reducer makes
8050
+ * goes through here, and this is the one place a frozen array crosses into
8051
+ * state: the generated DocumentDriveGlobalState types nodes as a mutable
8052
+ * Node[], so the cast below is where that gap is paid rather than spread over
8053
+ * the reducer. Consumers must treat drive.state.global.nodes as read-only --
8054
+ * mutating it in place (push, sort, splice) throws in strict mode; copy it
8055
+ * first, as readNodes does. Note that LOAD_STATE replaces a whole scope and can
8056
+ * install a list this function never saw.
8057
+ */
8058
+ function assignNodes(state, nodes) {
8059
+ state.nodes = nodes;
8019
8060
  }
8020
8061
  function handleTargetNameCollisions(params) {
8021
8062
  const { nodes, targetParentFolder, srcName, srcKind } = params;
@@ -8036,13 +8077,13 @@ const nodeReducer = {
8036
8077
  srcKind: "file",
8037
8078
  targetParentFolder: action.input.parentFolder || null
8038
8079
  });
8039
- state.nodes = insertNodeSorted(nodes, {
8080
+ assignNodes(state, insertNodeSorted(nodes, {
8040
8081
  id: action.input.id,
8041
8082
  name,
8042
8083
  kind: "file",
8043
8084
  parentFolder: action.input.parentFolder ?? null,
8044
8085
  documentType: action.input.documentType
8045
- });
8086
+ }));
8046
8087
  dispatch?.({
8047
8088
  type: "CREATE_CHILD_DOCUMENT",
8048
8089
  input: {
@@ -8061,18 +8102,19 @@ const nodeReducer = {
8061
8102
  srcKind: "folder",
8062
8103
  targetParentFolder: action.input.parentFolder || null
8063
8104
  });
8064
- state.nodes = insertNodeSorted(nodes, {
8105
+ assignNodes(state, insertNodeSorted(nodes, {
8065
8106
  ...action.input,
8066
8107
  name,
8067
8108
  kind: "folder",
8068
8109
  parentFolder: action.input.parentFolder ?? null
8069
- });
8110
+ }));
8070
8111
  },
8071
8112
  deleteNodeOperation(state, action, dispatch) {
8072
- const node = state.nodes.find((node) => node.id === action.input.id);
8113
+ const nodes = readNodes(state);
8114
+ const node = nodes.find((node) => node.id === action.input.id);
8073
8115
  if (!node) throw new Error(`Node with id ${action.input.id} not found`);
8074
- const descendants = getDescendants(node, state.nodes);
8075
- state.nodes = state.nodes.filter((node) => node.id !== action.input.id && !descendants.find((descendant) => descendant.id === node.id));
8116
+ const descendants = getDescendants(node, nodes);
8117
+ assignNodes(state, sortNodesById(nodes.filter((node) => node.id !== action.input.id && !descendants.find((descendant) => descendant.id === node.id))));
8076
8118
  [node, ...descendants].filter((node) => isFileNode(node)).forEach((node) => {
8077
8119
  dispatch?.({
8078
8120
  type: "DELETE_CHILD_DOCUMENT",
@@ -8082,38 +8124,39 @@ const nodeReducer = {
8082
8124
  },
8083
8125
  updateFileOperation(state, action) {
8084
8126
  if (action.input.name && !isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
8085
- state.nodes = state.nodes.map((node) => node.id === action.input.id ? {
8127
+ const nodes = readNodes(state);
8128
+ assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
8086
8129
  ...node,
8087
8130
  name: handleTargetNameCollisions({
8088
- nodes: state.nodes.filter((n) => n.id !== action.input.id),
8131
+ nodes: nodes.filter((n) => n.id !== action.input.id),
8089
8132
  srcName: action.input.name ?? node.name,
8090
8133
  srcKind: "file",
8091
8134
  targetParentFolder: action.input.parentFolder ?? node.parentFolder
8092
8135
  }),
8093
8136
  documentType: action.input.documentType ?? node.documentType
8094
- } : node);
8095
- state.nodes.sort((a, b) => a.id.localeCompare(b.id));
8137
+ } : node)));
8096
8138
  },
8097
8139
  updateNodeOperation(state, action) {
8098
8140
  if (action.input.name && !isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
8099
- state.nodes = state.nodes.map((node) => node.id === action.input.id ? {
8141
+ const nodes = readNodes(state);
8142
+ assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
8100
8143
  ...node,
8101
8144
  name: handleTargetNameCollisions({
8102
- nodes: state.nodes.filter((n) => n.id !== action.input.id),
8145
+ nodes: nodes.filter((n) => n.id !== action.input.id),
8103
8146
  srcName: action.input.name ?? node.name,
8104
8147
  srcKind: node.kind === "file" ? "file" : "folder",
8105
8148
  targetParentFolder: action.input.parentFolder ?? node.parentFolder
8106
8149
  }),
8107
8150
  parentFolder: action.input.parentFolder === null ? null : node.parentFolder
8108
- } : node);
8109
- state.nodes.sort((a, b) => a.id.localeCompare(b.id));
8151
+ } : node)));
8110
8152
  },
8111
8153
  copyNodeOperation(state, action, dispatch) {
8112
- const node = state.nodes.find((node) => node.id === action.input.srcId);
8154
+ const nodes = readNodes(state);
8155
+ const node = nodes.find((node) => node.id === action.input.srcId);
8113
8156
  if (!node) throw new Error(`Node with id ${action.input.srcId} not found`);
8114
- if (state.nodes.find((node) => node.id === action.input.targetId)) throw new Error(`Node with id ${action.input.targetId} already exists`);
8157
+ if (nodes.find((node) => node.id === action.input.targetId)) throw new Error(`Node with id ${action.input.targetId} already exists`);
8115
8158
  const name = handleTargetNameCollisions({
8116
- nodes: state.nodes,
8159
+ nodes,
8117
8160
  srcName: action.input.targetName || node.name,
8118
8161
  srcKind: node.kind === "file" ? "file" : "folder",
8119
8162
  targetParentFolder: action.input.targetParentFolder || null
@@ -8125,8 +8168,7 @@ const nodeReducer = {
8125
8168
  name,
8126
8169
  parentFolder: action.input.targetParentFolder || null
8127
8170
  };
8128
- state.nodes.push(newNode);
8129
- state.nodes.sort((a, b) => a.id.localeCompare(b.id));
8171
+ assignNodes(state, insertNodeSorted(nodes, newNode));
8130
8172
  if (isFileNode(newNode)) dispatch?.({
8131
8173
  type: "COPY_CHILD_DOCUMENT",
8132
8174
  input: {
@@ -8137,26 +8179,26 @@ const nodeReducer = {
8137
8179
  },
8138
8180
  moveNodeOperation(state, action) {
8139
8181
  if (action.input.srcFolder === action.input.targetParentFolder) throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");
8140
- const node = state.nodes.find((node) => node.id === action.input.srcFolder);
8182
+ const nodes = readNodes(state);
8183
+ const node = nodes.find((node) => node.id === action.input.srcFolder);
8141
8184
  if (!node) throw new Error(`Node with id ${action.input.srcFolder} not found`);
8142
8185
  const name = handleTargetNameCollisions({
8143
- nodes: state.nodes,
8186
+ nodes,
8144
8187
  srcName: node.name,
8145
8188
  srcKind: node.kind === "file" ? "file" : "folder",
8146
8189
  targetParentFolder: action.input.targetParentFolder || null
8147
8190
  });
8148
8191
  if (isFolderNode(node)) {
8149
- if (getDescendants(node, state.nodes).find((descendant) => descendant.id === action.input.targetParentFolder)) throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");
8192
+ if (getDescendants(node, nodes).find((descendant) => descendant.id === action.input.targetParentFolder)) throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");
8150
8193
  }
8151
- state.nodes = state.nodes.map((node) => {
8194
+ assignNodes(state, sortNodesById(nodes.map((node) => {
8152
8195
  if (node.id === action.input.srcFolder) return {
8153
8196
  ...node,
8154
8197
  name,
8155
8198
  parentFolder: action.input.targetParentFolder || null
8156
8199
  };
8157
8200
  return node;
8158
- });
8159
- state.nodes.sort((a, b) => a.id.localeCompare(b.id));
8201
+ })));
8160
8202
  }
8161
8203
  };
8162
8204
  const driveStateReducer = (state, action, dispatch) => {
@@ -8291,4 +8333,4 @@ const driveDocumentModelModule = {
8291
8333
  //#endregion
8292
8334
  export { setModuleName as $, createPresignedHeader as A, hashDocumentStateForScope as B, baseCreateDocument as C, buildSignedAction as D, baseSaveToFileHandle as E, deleteModule as F, replayDocumentVersioned as G, normalizeDocumentModelVersion as H, deleteOperation as I, setInitialState as J, setAuthorName as K, deleteOperationError as L, createState as M, createZip as N, createAction as O, defaultBaseState as P, setModelName as Q, deserializeSignature as R, baseActions as S, baseLoadFromInputVersioned as T, redo as U, isDocumentAction as V, releaseNewVersion as W, setModelExtension as X, setModelDescription as Y, setModelId as Z, UnsupportedDocumentModelVersionError as _, getDescendants as a, setStateSchema as at, addOperationError as b, isFileNode as c, validateInitialState as ct, moveNode as d, zipEntries as dt, setName as et, updateNode as f, generateId as ft, BaseDocumentStateSchema as g, BaseDocumentHeaderSchema as h, generateNodesCopy as i, setOperationSchema as it, createReducer as j, createBaseState as k, isFolderNode as l, validateModules as lt, logger as m, copyNode as n, setOperationErrorName as nt, getNextCopyNumber as o, toTransportAction as ot, documentModelDocumentModelModule as p, setAuthorWebsite as q, driveDocumentModelModule as r, setOperationName as rt, handleTargetNameCollisions as s, undo as st, addFolder as t, setOperationDescription as tt, isValidName as u, validateStateSchemaName as ut, addModule as v, baseLoadFromInput as w, assertAuthPreservedOnDuplicate as x, addOperation as y, documentModelDocumentType as z };
8293
8335
 
8294
- //# sourceMappingURL=document-drive-CkV9NvD7.mjs.map
8336
+ //# sourceMappingURL=document-drive-BByBwg-I.mjs.map