@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.1 → 6.2.3-dev.10
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-5_Eh4a2Z.js → entry-DvpdFGdw.js} +2 -2
- package/dist/browser/assets/{projection-entry-5PVbP10h.js → projection-entry-QU4xTPM_.js} +3 -3
- package/dist/browser/{connect-BqgnsniX.js → connect-kwnl2v6o.js} +11 -5
- package/dist/browser/{connect-BqgnsniX.js.map → connect-kwnl2v6o.js.map} +1 -1
- package/dist/browser/{dist-C-xkNfyD.js → dist-D0tSbK8B.js} +90 -10
- package/dist/browser/dist-D0tSbK8B.js.map +1 -0
- package/dist/browser/{document-drive-ZQzPQfEL.js → document-drive-fcQ4o8i3.js} +127 -44
- package/dist/browser/document-drive-fcQ4o8i3.js.map +1 -0
- package/dist/browser/document-models/index.js +1 -1
- package/dist/browser/{editor-BNgF9-uX.js → editor-CbJkIqg_.js} +6 -6
- package/dist/browser/{editor-BNgF9-uX.js.map → editor-CbJkIqg_.js.map} +1 -1
- package/dist/browser/{editor-DZP1WlYy.js → editor-D_gIraSB.js} +5 -5
- package/dist/browser/{editor-DZP1WlYy.js.map → editor-D_gIraSB.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/{folder-view-tx0A96ZI.js → folder-view-CGcqEbak.js} +3 -3
- package/dist/browser/{folder-view-tx0A96ZI.js.map → folder-view-CGcqEbak.js.map} +1 -1
- package/dist/browser/{graphql-editor-Cbkb5KRZ.js → graphql-editor-C9wxFf0b.js} +3 -3
- package/dist/browser/{graphql-editor-Cbkb5KRZ.js.map → graphql-editor-C9wxFf0b.js.map} +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/{json-editor-CN6kPtl1.js → json-editor-BIGVi54h.js} +3 -3
- package/dist/browser/{json-editor-CN6kPtl1.js.map → json-editor-BIGVi54h.js.map} +1 -1
- package/dist/browser/{lib-ewnRj2dJ.js → lib-BWPfFpyy.js} +2 -2
- package/dist/browser/lib-BWPfFpyy.js.map +1 -0
- package/dist/browser/{state-schemas-CKh98ehP.js → state-schemas-C9Nb7S5z.js} +3 -3
- package/dist/browser/{state-schemas-CKh98ehP.js.map → state-schemas-C9Nb7S5z.js.map} +1 -1
- package/dist/node/{connect-CeLh6yfj.mjs → connect-D3-HufsW.mjs} +11 -5
- package/dist/node/{connect-CeLh6yfj.mjs.map → connect-D3-HufsW.mjs.map} +1 -1
- package/dist/node/{dist-CUFTZwfc.mjs → dist-D5Xp9PwJ.mjs} +90 -10
- package/dist/node/dist-D5Xp9PwJ.mjs.map +1 -0
- package/dist/node/{document-drive-D1NMjQQc.mjs → document-drive-DuGBBYw5.mjs} +127 -44
- package/dist/node/document-drive-DuGBBYw5.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +1 -1
- package/dist/node/{editor-Dg2OZEJu.mjs → editor-CJSAZpIG.mjs} +5 -5
- package/dist/node/{editor-Dg2OZEJu.mjs.map → editor-CJSAZpIG.mjs.map} +1 -1
- package/dist/node/{editor-CXQOsbup.mjs → editor-D8SL0ydm.mjs} +6 -6
- package/dist/node/{editor-CXQOsbup.mjs.map → editor-D8SL0ydm.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/node/{folder-view-DZ0o2-Ef.mjs → folder-view-ChtWc33j.mjs} +3 -3
- package/dist/node/{folder-view-DZ0o2-Ef.mjs.map → folder-view-ChtWc33j.mjs.map} +1 -1
- package/dist/node/{graphql-editor-DNxebuTn.mjs → graphql-editor-CnK5kIk9.mjs} +3 -3
- package/dist/node/{graphql-editor-DNxebuTn.mjs.map → graphql-editor-CnK5kIk9.mjs.map} +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/node/{json-editor-BpnEn9AS.mjs → json-editor-j8_JGfcP.mjs} +3 -3
- package/dist/node/{json-editor-BpnEn9AS.mjs.map → json-editor-j8_JGfcP.mjs.map} +1 -1
- package/dist/node/{main-B1tRsYOp.mjs → main-7sul-YJl.mjs} +2 -2
- package/dist/node/main-7sul-YJl.mjs.map +1 -0
- package/dist/node/{state-schemas-CuSHxrn6.mjs → state-schemas-DURvYjxG.mjs} +3 -3
- package/dist/node/{state-schemas-CuSHxrn6.mjs.map → state-schemas-DURvYjxG.mjs.map} +1 -1
- package/package.json +7 -7
- package/dist/browser/dist-C-xkNfyD.js.map +0 -1
- package/dist/browser/document-drive-ZQzPQfEL.js.map +0 -1
- package/dist/browser/lib-ewnRj2dJ.js.map +0 -1
- package/dist/node/dist-CUFTZwfc.mjs.map +0 -1
- package/dist/node/document-drive-D1NMjQQc.mjs.map +0 -1
- package/dist/node/main-B1tRsYOp.mjs.map +0 -1
|
@@ -2988,6 +2988,29 @@ const makeCreator = (arg) => {
|
|
|
2988
2988
|
* ```
|
|
2989
2989
|
*/
|
|
2990
2990
|
const create = makeCreator();
|
|
2991
|
+
/**
|
|
2992
|
+
* `original(draft)` to get original state in the draft mutation function.
|
|
2993
|
+
*
|
|
2994
|
+
* ## Example
|
|
2995
|
+
*
|
|
2996
|
+
* ```ts
|
|
2997
|
+
* import { create, original } from '../index';
|
|
2998
|
+
*
|
|
2999
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
3000
|
+
* const state = create(
|
|
3001
|
+
* baseState,
|
|
3002
|
+
* (draft) => {
|
|
3003
|
+
* draft.foo.bar = 'str2';
|
|
3004
|
+
* expect(original(draft.foo)).toEqual({ bar: 'str' });
|
|
3005
|
+
* }
|
|
3006
|
+
* );
|
|
3007
|
+
* ```
|
|
3008
|
+
*/
|
|
3009
|
+
function original(target) {
|
|
3010
|
+
const proxyDraft = getProxyDraft(target);
|
|
3011
|
+
if (!proxyDraft) throw new Error(`original() is only used for a draft, parameter: ${target}`);
|
|
3012
|
+
return proxyDraft.original;
|
|
3013
|
+
}
|
|
2991
3014
|
Object.prototype.constructor.toString();
|
|
2992
3015
|
/**
|
|
2993
3016
|
* Cast a value to an Draft type value.
|
|
@@ -3773,6 +3796,7 @@ object({
|
|
|
3773
3796
|
editors: PowerhouseModulesSchema,
|
|
3774
3797
|
processors: PowerhouseModulesSchema,
|
|
3775
3798
|
subgraphs: PowerhouseModulesSchema,
|
|
3799
|
+
pieces: PowerhouseModulesSchema,
|
|
3776
3800
|
config: array(ConfigEntrySchema).optional(),
|
|
3777
3801
|
pwa: PwaConfigSchema.optional()
|
|
3778
3802
|
});
|
|
@@ -7345,36 +7369,36 @@ const logger = new class ConsoleLogger {
|
|
|
7345
7369
|
get #includeStack() {
|
|
7346
7370
|
return this.#level <= LOG_LEVELS.debug;
|
|
7347
7371
|
}
|
|
7348
|
-
verbose(message, ...replacements) {
|
|
7372
|
+
verbose = (message, ...replacements) => {
|
|
7349
7373
|
if (this.#level <= LOG_LEVELS.verbose) {
|
|
7350
7374
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7351
7375
|
console.debug(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7352
7376
|
}
|
|
7353
|
-
}
|
|
7354
|
-
debug(message, ...replacements) {
|
|
7377
|
+
};
|
|
7378
|
+
debug = (message, ...replacements) => {
|
|
7355
7379
|
if (this.#level <= LOG_LEVELS.debug) {
|
|
7356
7380
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7357
7381
|
console.debug(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7358
7382
|
}
|
|
7359
|
-
}
|
|
7360
|
-
info(message, ...replacements) {
|
|
7383
|
+
};
|
|
7384
|
+
info = (message, ...replacements) => {
|
|
7361
7385
|
if (this.#level <= LOG_LEVELS.info) {
|
|
7362
7386
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7363
7387
|
console.info(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7364
7388
|
}
|
|
7365
|
-
}
|
|
7366
|
-
warn(message, ...replacements) {
|
|
7389
|
+
};
|
|
7390
|
+
warn = (message, ...replacements) => {
|
|
7367
7391
|
if (this.#level <= LOG_LEVELS.warn) {
|
|
7368
7392
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7369
7393
|
console.warn(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7370
7394
|
}
|
|
7371
|
-
}
|
|
7372
|
-
error(message, ...replacements) {
|
|
7395
|
+
};
|
|
7396
|
+
error = (message, ...replacements) => {
|
|
7373
7397
|
if (this.#level <= LOG_LEVELS.error) {
|
|
7374
7398
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7375
7399
|
console.error(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7376
7400
|
}
|
|
7377
|
-
}
|
|
7401
|
+
};
|
|
7378
7402
|
}();
|
|
7379
7403
|
//#endregion
|
|
7380
7404
|
//#region ../shared/dist/document-drive/index.js
|
|
@@ -7976,6 +8000,65 @@ function getNextCopyNumber(files, baseFilename) {
|
|
|
7976
8000
|
function escapeRegExp(string) {
|
|
7977
8001
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7978
8002
|
}
|
|
8003
|
+
/**
|
|
8004
|
+
* A plain, unfrozen copy of the node list for read-only scans. Inside a
|
|
8005
|
+
* mutative draft the copy is taken from the untouched base list, so a find or
|
|
8006
|
+
* filter over it does not create a child draft per element it visits, and it is
|
|
8007
|
+
* a copy because the stored list is frozen and V8 scans a frozen array several
|
|
8008
|
+
* times slower than a normal one. Callers must read before they write: the base
|
|
8009
|
+
* list does not see mutations made earlier in the same action.
|
|
8010
|
+
*/
|
|
8011
|
+
function readNodes(state) {
|
|
8012
|
+
return [...isDraft(state) ? original(state).nodes : state.nodes];
|
|
8013
|
+
}
|
|
8014
|
+
/**
|
|
8015
|
+
* The given array sorted by id and frozen, in place -- it takes ownership of
|
|
8016
|
+
* the array it is handed, which is why it is private to this module and only
|
|
8017
|
+
* ever given a list built at the call site. The freeze is what makes assigning
|
|
8018
|
+
* the list to a mutative draft cheap: assigning a draftable value to a draft
|
|
8019
|
+
* property queues a finalize pass that walks every element of the assigned
|
|
8020
|
+
* value, and the walk exits at its Object.isFrozen check instead. Elements must
|
|
8021
|
+
* be plain nodes -- an element that is still a draft would never be replaced by
|
|
8022
|
+
* its final value, because the walk that does that replacement is the one being
|
|
8023
|
+
* skipped.
|
|
8024
|
+
*/
|
|
8025
|
+
function freezeSortedById(nodes) {
|
|
8026
|
+
nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8027
|
+
return Object.freeze(nodes);
|
|
8028
|
+
}
|
|
8029
|
+
/**
|
|
8030
|
+
* A copy of the given list, sorted by id and frozen, which is the shape the
|
|
8031
|
+
* node reducer assigns. Read the list with readNodes, build the new list from
|
|
8032
|
+
* it, and pass what this returns to assignNodes. The copy is what keeps the
|
|
8033
|
+
* freeze off the caller's array.
|
|
8034
|
+
*/
|
|
8035
|
+
function sortNodesById(nodes) {
|
|
8036
|
+
return freezeSortedById([...nodes]);
|
|
8037
|
+
}
|
|
8038
|
+
/**
|
|
8039
|
+
* The node list with a node added, ordered by id and frozen, in the same shape
|
|
8040
|
+
* sortNodesById returns. The list is built and sorted as plain objects, so
|
|
8041
|
+
* inside a mutative draft the comparator never reads an element through the
|
|
8042
|
+
* draft proxy. Pass the list read with readNodes: the draft's own list would
|
|
8043
|
+
* put child drafts in the result, which the freeze then keeps mutative from
|
|
8044
|
+
* resolving.
|
|
8045
|
+
*/
|
|
8046
|
+
function insertNodeSorted(nodes, node) {
|
|
8047
|
+
return freezeSortedById([...nodes, node]);
|
|
8048
|
+
}
|
|
8049
|
+
/**
|
|
8050
|
+
* Installs a node list as state.nodes. Every assignment the node reducer makes
|
|
8051
|
+
* goes through here, and this is the one place a frozen array crosses into
|
|
8052
|
+
* state: the generated DocumentDriveGlobalState types nodes as a mutable
|
|
8053
|
+
* Node[], so the cast below is where that gap is paid rather than spread over
|
|
8054
|
+
* the reducer. Consumers must treat drive.state.global.nodes as read-only --
|
|
8055
|
+
* mutating it in place (push, sort, splice) throws in strict mode; copy it
|
|
8056
|
+
* first, as readNodes does. Note that LOAD_STATE replaces a whole scope and can
|
|
8057
|
+
* install a list this function never saw.
|
|
8058
|
+
*/
|
|
8059
|
+
function assignNodes(state, nodes) {
|
|
8060
|
+
state.nodes = nodes;
|
|
8061
|
+
}
|
|
7979
8062
|
function handleTargetNameCollisions(params) {
|
|
7980
8063
|
const { nodes, targetParentFolder, srcName, srcKind } = params;
|
|
7981
8064
|
const targetNodeChildrenNames = nodes.filter((node) => targetParentFolder === "" ? node.parentFolder === null : node.parentFolder === targetParentFolder).filter((node) => node.kind === srcKind).map((node) => node.name);
|
|
@@ -7986,23 +8069,22 @@ const isValidName = (name) => {
|
|
|
7986
8069
|
};
|
|
7987
8070
|
const nodeReducer = {
|
|
7988
8071
|
addFileOperation(state, action, dispatch) {
|
|
7989
|
-
|
|
8072
|
+
const nodes = readNodes(state);
|
|
8073
|
+
if (nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
7990
8074
|
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
|
|
7991
8075
|
const name = handleTargetNameCollisions({
|
|
7992
|
-
nodes
|
|
8076
|
+
nodes,
|
|
7993
8077
|
srcName: action.input.name,
|
|
7994
8078
|
srcKind: "file",
|
|
7995
8079
|
targetParentFolder: action.input.parentFolder || null
|
|
7996
8080
|
});
|
|
7997
|
-
|
|
8081
|
+
assignNodes(state, insertNodeSorted(nodes, {
|
|
7998
8082
|
id: action.input.id,
|
|
7999
8083
|
name,
|
|
8000
8084
|
kind: "file",
|
|
8001
8085
|
parentFolder: action.input.parentFolder ?? null,
|
|
8002
8086
|
documentType: action.input.documentType
|
|
8003
|
-
};
|
|
8004
|
-
state.nodes.push(fileNode);
|
|
8005
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8087
|
+
}));
|
|
8006
8088
|
dispatch?.({
|
|
8007
8089
|
type: "CREATE_CHILD_DOCUMENT",
|
|
8008
8090
|
input: {
|
|
@@ -8012,27 +8094,28 @@ const nodeReducer = {
|
|
|
8012
8094
|
});
|
|
8013
8095
|
},
|
|
8014
8096
|
addFolderOperation(state, action) {
|
|
8015
|
-
|
|
8097
|
+
const nodes = readNodes(state);
|
|
8098
|
+
if (nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
8016
8099
|
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
|
|
8017
8100
|
const name = handleTargetNameCollisions({
|
|
8018
|
-
nodes
|
|
8101
|
+
nodes,
|
|
8019
8102
|
srcName: action.input.name,
|
|
8020
8103
|
srcKind: "folder",
|
|
8021
8104
|
targetParentFolder: action.input.parentFolder || null
|
|
8022
8105
|
});
|
|
8023
|
-
state
|
|
8106
|
+
assignNodes(state, insertNodeSorted(nodes, {
|
|
8024
8107
|
...action.input,
|
|
8025
8108
|
name,
|
|
8026
8109
|
kind: "folder",
|
|
8027
8110
|
parentFolder: action.input.parentFolder ?? null
|
|
8028
|
-
});
|
|
8029
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8111
|
+
}));
|
|
8030
8112
|
},
|
|
8031
8113
|
deleteNodeOperation(state, action, dispatch) {
|
|
8032
|
-
const
|
|
8114
|
+
const nodes = readNodes(state);
|
|
8115
|
+
const node = nodes.find((node) => node.id === action.input.id);
|
|
8033
8116
|
if (!node) throw new Error(`Node with id ${action.input.id} not found`);
|
|
8034
|
-
const descendants = getDescendants(node,
|
|
8035
|
-
state
|
|
8117
|
+
const descendants = getDescendants(node, nodes);
|
|
8118
|
+
assignNodes(state, sortNodesById(nodes.filter((node) => node.id !== action.input.id && !descendants.find((descendant) => descendant.id === node.id))));
|
|
8036
8119
|
[node, ...descendants].filter((node) => isFileNode(node)).forEach((node) => {
|
|
8037
8120
|
dispatch?.({
|
|
8038
8121
|
type: "DELETE_CHILD_DOCUMENT",
|
|
@@ -8042,38 +8125,39 @@ const nodeReducer = {
|
|
|
8042
8125
|
},
|
|
8043
8126
|
updateFileOperation(state, action) {
|
|
8044
8127
|
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.`);
|
|
8045
|
-
|
|
8128
|
+
const nodes = readNodes(state);
|
|
8129
|
+
assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
|
|
8046
8130
|
...node,
|
|
8047
8131
|
name: handleTargetNameCollisions({
|
|
8048
|
-
nodes:
|
|
8132
|
+
nodes: nodes.filter((n) => n.id !== action.input.id),
|
|
8049
8133
|
srcName: action.input.name ?? node.name,
|
|
8050
8134
|
srcKind: "file",
|
|
8051
8135
|
targetParentFolder: action.input.parentFolder ?? node.parentFolder
|
|
8052
8136
|
}),
|
|
8053
8137
|
documentType: action.input.documentType ?? node.documentType
|
|
8054
|
-
} : node);
|
|
8055
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8138
|
+
} : node)));
|
|
8056
8139
|
},
|
|
8057
8140
|
updateNodeOperation(state, action) {
|
|
8058
8141
|
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.`);
|
|
8059
|
-
|
|
8142
|
+
const nodes = readNodes(state);
|
|
8143
|
+
assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
|
|
8060
8144
|
...node,
|
|
8061
8145
|
name: handleTargetNameCollisions({
|
|
8062
|
-
nodes:
|
|
8146
|
+
nodes: nodes.filter((n) => n.id !== action.input.id),
|
|
8063
8147
|
srcName: action.input.name ?? node.name,
|
|
8064
8148
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8065
8149
|
targetParentFolder: action.input.parentFolder ?? node.parentFolder
|
|
8066
8150
|
}),
|
|
8067
8151
|
parentFolder: action.input.parentFolder === null ? null : node.parentFolder
|
|
8068
|
-
} : node);
|
|
8069
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8152
|
+
} : node)));
|
|
8070
8153
|
},
|
|
8071
8154
|
copyNodeOperation(state, action, dispatch) {
|
|
8072
|
-
const
|
|
8155
|
+
const nodes = readNodes(state);
|
|
8156
|
+
const node = nodes.find((node) => node.id === action.input.srcId);
|
|
8073
8157
|
if (!node) throw new Error(`Node with id ${action.input.srcId} not found`);
|
|
8074
|
-
if (
|
|
8158
|
+
if (nodes.find((node) => node.id === action.input.targetId)) throw new Error(`Node with id ${action.input.targetId} already exists`);
|
|
8075
8159
|
const name = handleTargetNameCollisions({
|
|
8076
|
-
nodes
|
|
8160
|
+
nodes,
|
|
8077
8161
|
srcName: action.input.targetName || node.name,
|
|
8078
8162
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8079
8163
|
targetParentFolder: action.input.targetParentFolder || null
|
|
@@ -8085,8 +8169,7 @@ const nodeReducer = {
|
|
|
8085
8169
|
name,
|
|
8086
8170
|
parentFolder: action.input.targetParentFolder || null
|
|
8087
8171
|
};
|
|
8088
|
-
state
|
|
8089
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8172
|
+
assignNodes(state, insertNodeSorted(nodes, newNode));
|
|
8090
8173
|
if (isFileNode(newNode)) dispatch?.({
|
|
8091
8174
|
type: "COPY_CHILD_DOCUMENT",
|
|
8092
8175
|
input: {
|
|
@@ -8097,26 +8180,26 @@ const nodeReducer = {
|
|
|
8097
8180
|
},
|
|
8098
8181
|
moveNodeOperation(state, action) {
|
|
8099
8182
|
if (action.input.srcFolder === action.input.targetParentFolder) throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");
|
|
8100
|
-
const
|
|
8183
|
+
const nodes = readNodes(state);
|
|
8184
|
+
const node = nodes.find((node) => node.id === action.input.srcFolder);
|
|
8101
8185
|
if (!node) throw new Error(`Node with id ${action.input.srcFolder} not found`);
|
|
8102
8186
|
const name = handleTargetNameCollisions({
|
|
8103
|
-
nodes
|
|
8187
|
+
nodes,
|
|
8104
8188
|
srcName: node.name,
|
|
8105
8189
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8106
8190
|
targetParentFolder: action.input.targetParentFolder || null
|
|
8107
8191
|
});
|
|
8108
8192
|
if (isFolderNode(node)) {
|
|
8109
|
-
if (getDescendants(node,
|
|
8193
|
+
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");
|
|
8110
8194
|
}
|
|
8111
|
-
state
|
|
8195
|
+
assignNodes(state, sortNodesById(nodes.map((node) => {
|
|
8112
8196
|
if (node.id === action.input.srcFolder) return {
|
|
8113
8197
|
...node,
|
|
8114
8198
|
name,
|
|
8115
8199
|
parentFolder: action.input.targetParentFolder || null
|
|
8116
8200
|
};
|
|
8117
8201
|
return node;
|
|
8118
|
-
});
|
|
8119
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8202
|
+
})));
|
|
8120
8203
|
}
|
|
8121
8204
|
};
|
|
8122
8205
|
const driveStateReducer = (state, action, dispatch) => {
|
|
@@ -8251,4 +8334,4 @@ const driveDocumentModelModule = {
|
|
|
8251
8334
|
//#endregion
|
|
8252
8335
|
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 };
|
|
8253
8336
|
|
|
8254
|
-
//# sourceMappingURL=document-drive-
|
|
8337
|
+
//# sourceMappingURL=document-drive-DuGBBYw5.mjs.map
|