@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.0 → 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-DqkYyEcC.js → connect-kwnl2v6o.js} +11 -5
- package/dist/browser/{connect-DqkYyEcC.js.map → connect-kwnl2v6o.js.map} +1 -1
- package/dist/browser/{dist-C1pi89al.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-Bl02Hko1.js → editor-CbJkIqg_.js} +6 -6
- package/dist/browser/{editor-Bl02Hko1.js.map → editor-CbJkIqg_.js.map} +1 -1
- package/dist/browser/{editor-CbtY05JH.js → editor-D_gIraSB.js} +5 -5
- package/dist/browser/{editor-CbtY05JH.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-BBm_YnKn.js → folder-view-CGcqEbak.js} +3 -3
- package/dist/browser/{folder-view-BBm_YnKn.js.map → folder-view-CGcqEbak.js.map} +1 -1
- package/dist/browser/{graphql-editor-LSj3LCtL.js → graphql-editor-C9wxFf0b.js} +3 -3
- package/dist/browser/{graphql-editor-LSj3LCtL.js.map → graphql-editor-C9wxFf0b.js.map} +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/{json-editor-TVSHA4PZ.js → json-editor-BIGVi54h.js} +3 -3
- package/dist/browser/{json-editor-TVSHA4PZ.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-Bsryt22c.js → state-schemas-C9Nb7S5z.js} +3 -3
- package/dist/browser/{state-schemas-Bsryt22c.js.map → state-schemas-C9Nb7S5z.js.map} +1 -1
- package/dist/node/{connect-B2yHg8VF.mjs → connect-D3-HufsW.mjs} +11 -5
- package/dist/node/{connect-B2yHg8VF.mjs.map → connect-D3-HufsW.mjs.map} +1 -1
- package/dist/node/{dist-BAXIB1_k.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-BY22Tx5_.mjs → editor-CJSAZpIG.mjs} +5 -5
- package/dist/node/{editor-BY22Tx5_.mjs.map → editor-CJSAZpIG.mjs.map} +1 -1
- package/dist/node/{editor--v67sph0.mjs → editor-D8SL0ydm.mjs} +6 -6
- package/dist/node/{editor--v67sph0.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-D_99HJFI.mjs → folder-view-ChtWc33j.mjs} +3 -3
- package/dist/node/{folder-view-D_99HJFI.mjs.map → folder-view-ChtWc33j.mjs.map} +1 -1
- package/dist/node/{graphql-editor-Bzs-PolA.mjs → graphql-editor-CnK5kIk9.mjs} +3 -3
- package/dist/node/{graphql-editor-Bzs-PolA.mjs.map → graphql-editor-CnK5kIk9.mjs.map} +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/node/{json-editor-CCsBXZ6y.mjs → json-editor-j8_JGfcP.mjs} +3 -3
- package/dist/node/{json-editor-CCsBXZ6y.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-DxJBYOC0.mjs → state-schemas-DURvYjxG.mjs} +3 -3
- package/dist/node/{state-schemas-DxJBYOC0.mjs.map → state-schemas-DURvYjxG.mjs.map} +1 -1
- package/package.json +7 -7
- package/dist/browser/dist-C1pi89al.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-BAXIB1_k.mjs.map +0 -1
- package/dist/node/document-drive-D1NMjQQc.mjs.map +0 -1
- package/dist/node/main-B1tRsYOp.mjs.map +0 -1
|
@@ -2971,6 +2971,29 @@ const makeCreator = (arg) => {
|
|
|
2971
2971
|
* ```
|
|
2972
2972
|
*/
|
|
2973
2973
|
const create = makeCreator();
|
|
2974
|
+
/**
|
|
2975
|
+
* `original(draft)` to get original state in the draft mutation function.
|
|
2976
|
+
*
|
|
2977
|
+
* ## Example
|
|
2978
|
+
*
|
|
2979
|
+
* ```ts
|
|
2980
|
+
* import { create, original } from '../index';
|
|
2981
|
+
*
|
|
2982
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
2983
|
+
* const state = create(
|
|
2984
|
+
* baseState,
|
|
2985
|
+
* (draft) => {
|
|
2986
|
+
* draft.foo.bar = 'str2';
|
|
2987
|
+
* expect(original(draft.foo)).toEqual({ bar: 'str' });
|
|
2988
|
+
* }
|
|
2989
|
+
* );
|
|
2990
|
+
* ```
|
|
2991
|
+
*/
|
|
2992
|
+
function original(target) {
|
|
2993
|
+
const proxyDraft = getProxyDraft(target);
|
|
2994
|
+
if (!proxyDraft) throw new Error(`original() is only used for a draft, parameter: ${target}`);
|
|
2995
|
+
return proxyDraft.original;
|
|
2996
|
+
}
|
|
2974
2997
|
Object.prototype.constructor.toString();
|
|
2975
2998
|
/**
|
|
2976
2999
|
* Cast a value to an Draft type value.
|
|
@@ -3756,6 +3779,7 @@ object({
|
|
|
3756
3779
|
editors: PowerhouseModulesSchema,
|
|
3757
3780
|
processors: PowerhouseModulesSchema,
|
|
3758
3781
|
subgraphs: PowerhouseModulesSchema,
|
|
3782
|
+
pieces: PowerhouseModulesSchema,
|
|
3759
3783
|
config: array(ConfigEntrySchema).optional(),
|
|
3760
3784
|
pwa: PwaConfigSchema.optional()
|
|
3761
3785
|
});
|
|
@@ -7328,36 +7352,36 @@ const logger = new class ConsoleLogger {
|
|
|
7328
7352
|
get #includeStack() {
|
|
7329
7353
|
return this.#level <= LOG_LEVELS.debug;
|
|
7330
7354
|
}
|
|
7331
|
-
verbose(message, ...replacements) {
|
|
7355
|
+
verbose = (message, ...replacements) => {
|
|
7332
7356
|
if (this.#level <= LOG_LEVELS.verbose) {
|
|
7333
7357
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7334
7358
|
console.debug(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7335
7359
|
}
|
|
7336
|
-
}
|
|
7337
|
-
debug(message, ...replacements) {
|
|
7360
|
+
};
|
|
7361
|
+
debug = (message, ...replacements) => {
|
|
7338
7362
|
if (this.#level <= LOG_LEVELS.debug) {
|
|
7339
7363
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7340
7364
|
console.debug(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7341
7365
|
}
|
|
7342
|
-
}
|
|
7343
|
-
info(message, ...replacements) {
|
|
7366
|
+
};
|
|
7367
|
+
info = (message, ...replacements) => {
|
|
7344
7368
|
if (this.#level <= LOG_LEVELS.info) {
|
|
7345
7369
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7346
7370
|
console.info(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7347
7371
|
}
|
|
7348
|
-
}
|
|
7349
|
-
warn(message, ...replacements) {
|
|
7372
|
+
};
|
|
7373
|
+
warn = (message, ...replacements) => {
|
|
7350
7374
|
if (this.#level <= LOG_LEVELS.warn) {
|
|
7351
7375
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7352
7376
|
console.warn(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7353
7377
|
}
|
|
7354
|
-
}
|
|
7355
|
-
error(message, ...replacements) {
|
|
7378
|
+
};
|
|
7379
|
+
error = (message, ...replacements) => {
|
|
7356
7380
|
if (this.#level <= LOG_LEVELS.error) {
|
|
7357
7381
|
const [formattedMessage, meta] = formatMessage(this.#tagString, message, replacements, this.#includeStack);
|
|
7358
7382
|
console.error(`[${meta["timestamp"]}] ${formattedMessage}`);
|
|
7359
7383
|
}
|
|
7360
|
-
}
|
|
7384
|
+
};
|
|
7361
7385
|
}();
|
|
7362
7386
|
//#endregion
|
|
7363
7387
|
//#region ../shared/dist/document-drive/index.js
|
|
@@ -7959,6 +7983,65 @@ function getNextCopyNumber(files, baseFilename) {
|
|
|
7959
7983
|
function escapeRegExp(string) {
|
|
7960
7984
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7961
7985
|
}
|
|
7986
|
+
/**
|
|
7987
|
+
* A plain, unfrozen copy of the node list for read-only scans. Inside a
|
|
7988
|
+
* mutative draft the copy is taken from the untouched base list, so a find or
|
|
7989
|
+
* filter over it does not create a child draft per element it visits, and it is
|
|
7990
|
+
* a copy because the stored list is frozen and V8 scans a frozen array several
|
|
7991
|
+
* times slower than a normal one. Callers must read before they write: the base
|
|
7992
|
+
* list does not see mutations made earlier in the same action.
|
|
7993
|
+
*/
|
|
7994
|
+
function readNodes(state) {
|
|
7995
|
+
return [...isDraft(state) ? original(state).nodes : state.nodes];
|
|
7996
|
+
}
|
|
7997
|
+
/**
|
|
7998
|
+
* The given array sorted by id and frozen, in place -- it takes ownership of
|
|
7999
|
+
* the array it is handed, which is why it is private to this module and only
|
|
8000
|
+
* ever given a list built at the call site. The freeze is what makes assigning
|
|
8001
|
+
* the list to a mutative draft cheap: assigning a draftable value to a draft
|
|
8002
|
+
* property queues a finalize pass that walks every element of the assigned
|
|
8003
|
+
* value, and the walk exits at its Object.isFrozen check instead. Elements must
|
|
8004
|
+
* be plain nodes -- an element that is still a draft would never be replaced by
|
|
8005
|
+
* its final value, because the walk that does that replacement is the one being
|
|
8006
|
+
* skipped.
|
|
8007
|
+
*/
|
|
8008
|
+
function freezeSortedById(nodes) {
|
|
8009
|
+
nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8010
|
+
return Object.freeze(nodes);
|
|
8011
|
+
}
|
|
8012
|
+
/**
|
|
8013
|
+
* A copy of the given list, sorted by id and frozen, which is the shape the
|
|
8014
|
+
* node reducer assigns. Read the list with readNodes, build the new list from
|
|
8015
|
+
* it, and pass what this returns to assignNodes. The copy is what keeps the
|
|
8016
|
+
* freeze off the caller's array.
|
|
8017
|
+
*/
|
|
8018
|
+
function sortNodesById(nodes) {
|
|
8019
|
+
return freezeSortedById([...nodes]);
|
|
8020
|
+
}
|
|
8021
|
+
/**
|
|
8022
|
+
* The node list with a node added, ordered by id and frozen, in the same shape
|
|
8023
|
+
* sortNodesById returns. The list is built and sorted as plain objects, so
|
|
8024
|
+
* inside a mutative draft the comparator never reads an element through the
|
|
8025
|
+
* draft proxy. Pass the list read with readNodes: the draft's own list would
|
|
8026
|
+
* put child drafts in the result, which the freeze then keeps mutative from
|
|
8027
|
+
* resolving.
|
|
8028
|
+
*/
|
|
8029
|
+
function insertNodeSorted(nodes, node) {
|
|
8030
|
+
return freezeSortedById([...nodes, node]);
|
|
8031
|
+
}
|
|
8032
|
+
/**
|
|
8033
|
+
* Installs a node list as state.nodes. Every assignment the node reducer makes
|
|
8034
|
+
* goes through here, and this is the one place a frozen array crosses into
|
|
8035
|
+
* state: the generated DocumentDriveGlobalState types nodes as a mutable
|
|
8036
|
+
* Node[], so the cast below is where that gap is paid rather than spread over
|
|
8037
|
+
* the reducer. Consumers must treat drive.state.global.nodes as read-only --
|
|
8038
|
+
* mutating it in place (push, sort, splice) throws in strict mode; copy it
|
|
8039
|
+
* first, as readNodes does. Note that LOAD_STATE replaces a whole scope and can
|
|
8040
|
+
* install a list this function never saw.
|
|
8041
|
+
*/
|
|
8042
|
+
function assignNodes(state, nodes) {
|
|
8043
|
+
state.nodes = nodes;
|
|
8044
|
+
}
|
|
7962
8045
|
function handleTargetNameCollisions(params) {
|
|
7963
8046
|
const { nodes, targetParentFolder, srcName, srcKind } = params;
|
|
7964
8047
|
const targetNodeChildrenNames = nodes.filter((node) => targetParentFolder === "" ? node.parentFolder === null : node.parentFolder === targetParentFolder).filter((node) => node.kind === srcKind).map((node) => node.name);
|
|
@@ -7969,23 +8052,22 @@ const isValidName = (name) => {
|
|
|
7969
8052
|
};
|
|
7970
8053
|
const nodeReducer = {
|
|
7971
8054
|
addFileOperation(state, action, dispatch) {
|
|
7972
|
-
|
|
8055
|
+
const nodes = readNodes(state);
|
|
8056
|
+
if (nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
7973
8057
|
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
|
|
7974
8058
|
const name = handleTargetNameCollisions({
|
|
7975
|
-
nodes
|
|
8059
|
+
nodes,
|
|
7976
8060
|
srcName: action.input.name,
|
|
7977
8061
|
srcKind: "file",
|
|
7978
8062
|
targetParentFolder: action.input.parentFolder || null
|
|
7979
8063
|
});
|
|
7980
|
-
|
|
8064
|
+
assignNodes(state, insertNodeSorted(nodes, {
|
|
7981
8065
|
id: action.input.id,
|
|
7982
8066
|
name,
|
|
7983
8067
|
kind: "file",
|
|
7984
8068
|
parentFolder: action.input.parentFolder ?? null,
|
|
7985
8069
|
documentType: action.input.documentType
|
|
7986
|
-
};
|
|
7987
|
-
state.nodes.push(fileNode);
|
|
7988
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8070
|
+
}));
|
|
7989
8071
|
dispatch?.({
|
|
7990
8072
|
type: "CREATE_CHILD_DOCUMENT",
|
|
7991
8073
|
input: {
|
|
@@ -7995,27 +8077,28 @@ const nodeReducer = {
|
|
|
7995
8077
|
});
|
|
7996
8078
|
},
|
|
7997
8079
|
addFolderOperation(state, action) {
|
|
7998
|
-
|
|
8080
|
+
const nodes = readNodes(state);
|
|
8081
|
+
if (nodes.find((node) => node.id === action.input.id)) throw new Error(`Node with id ${action.input.id} already exists!`);
|
|
7999
8082
|
if (!isValidName(action.input.name)) throw new Error(`Invalid name: '${action.input.name}'. Names must not be empty or contain control characters.`);
|
|
8000
8083
|
const name = handleTargetNameCollisions({
|
|
8001
|
-
nodes
|
|
8084
|
+
nodes,
|
|
8002
8085
|
srcName: action.input.name,
|
|
8003
8086
|
srcKind: "folder",
|
|
8004
8087
|
targetParentFolder: action.input.parentFolder || null
|
|
8005
8088
|
});
|
|
8006
|
-
state
|
|
8089
|
+
assignNodes(state, insertNodeSorted(nodes, {
|
|
8007
8090
|
...action.input,
|
|
8008
8091
|
name,
|
|
8009
8092
|
kind: "folder",
|
|
8010
8093
|
parentFolder: action.input.parentFolder ?? null
|
|
8011
|
-
});
|
|
8012
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8094
|
+
}));
|
|
8013
8095
|
},
|
|
8014
8096
|
deleteNodeOperation(state, action, dispatch) {
|
|
8015
|
-
const
|
|
8097
|
+
const nodes = readNodes(state);
|
|
8098
|
+
const node = nodes.find((node) => node.id === action.input.id);
|
|
8016
8099
|
if (!node) throw new Error(`Node with id ${action.input.id} not found`);
|
|
8017
|
-
const descendants = getDescendants(node,
|
|
8018
|
-
state
|
|
8100
|
+
const descendants = getDescendants(node, nodes);
|
|
8101
|
+
assignNodes(state, sortNodesById(nodes.filter((node) => node.id !== action.input.id && !descendants.find((descendant) => descendant.id === node.id))));
|
|
8019
8102
|
[node, ...descendants].filter((node) => isFileNode(node)).forEach((node) => {
|
|
8020
8103
|
dispatch?.({
|
|
8021
8104
|
type: "DELETE_CHILD_DOCUMENT",
|
|
@@ -8025,38 +8108,39 @@ const nodeReducer = {
|
|
|
8025
8108
|
},
|
|
8026
8109
|
updateFileOperation(state, action) {
|
|
8027
8110
|
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.`);
|
|
8028
|
-
|
|
8111
|
+
const nodes = readNodes(state);
|
|
8112
|
+
assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
|
|
8029
8113
|
...node,
|
|
8030
8114
|
name: handleTargetNameCollisions({
|
|
8031
|
-
nodes:
|
|
8115
|
+
nodes: nodes.filter((n) => n.id !== action.input.id),
|
|
8032
8116
|
srcName: action.input.name ?? node.name,
|
|
8033
8117
|
srcKind: "file",
|
|
8034
8118
|
targetParentFolder: action.input.parentFolder ?? node.parentFolder
|
|
8035
8119
|
}),
|
|
8036
8120
|
documentType: action.input.documentType ?? node.documentType
|
|
8037
|
-
} : node);
|
|
8038
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8121
|
+
} : node)));
|
|
8039
8122
|
},
|
|
8040
8123
|
updateNodeOperation(state, action) {
|
|
8041
8124
|
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.`);
|
|
8042
|
-
|
|
8125
|
+
const nodes = readNodes(state);
|
|
8126
|
+
assignNodes(state, sortNodesById(nodes.map((node) => node.id === action.input.id ? {
|
|
8043
8127
|
...node,
|
|
8044
8128
|
name: handleTargetNameCollisions({
|
|
8045
|
-
nodes:
|
|
8129
|
+
nodes: nodes.filter((n) => n.id !== action.input.id),
|
|
8046
8130
|
srcName: action.input.name ?? node.name,
|
|
8047
8131
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8048
8132
|
targetParentFolder: action.input.parentFolder ?? node.parentFolder
|
|
8049
8133
|
}),
|
|
8050
8134
|
parentFolder: action.input.parentFolder === null ? null : node.parentFolder
|
|
8051
|
-
} : node);
|
|
8052
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8135
|
+
} : node)));
|
|
8053
8136
|
},
|
|
8054
8137
|
copyNodeOperation(state, action, dispatch) {
|
|
8055
|
-
const
|
|
8138
|
+
const nodes = readNodes(state);
|
|
8139
|
+
const node = nodes.find((node) => node.id === action.input.srcId);
|
|
8056
8140
|
if (!node) throw new Error(`Node with id ${action.input.srcId} not found`);
|
|
8057
|
-
if (
|
|
8141
|
+
if (nodes.find((node) => node.id === action.input.targetId)) throw new Error(`Node with id ${action.input.targetId} already exists`);
|
|
8058
8142
|
const name = handleTargetNameCollisions({
|
|
8059
|
-
nodes
|
|
8143
|
+
nodes,
|
|
8060
8144
|
srcName: action.input.targetName || node.name,
|
|
8061
8145
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8062
8146
|
targetParentFolder: action.input.targetParentFolder || null
|
|
@@ -8068,8 +8152,7 @@ const nodeReducer = {
|
|
|
8068
8152
|
name,
|
|
8069
8153
|
parentFolder: action.input.targetParentFolder || null
|
|
8070
8154
|
};
|
|
8071
|
-
state
|
|
8072
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8155
|
+
assignNodes(state, insertNodeSorted(nodes, newNode));
|
|
8073
8156
|
if (isFileNode(newNode)) dispatch?.({
|
|
8074
8157
|
type: "COPY_CHILD_DOCUMENT",
|
|
8075
8158
|
input: {
|
|
@@ -8080,26 +8163,26 @@ const nodeReducer = {
|
|
|
8080
8163
|
},
|
|
8081
8164
|
moveNodeOperation(state, action) {
|
|
8082
8165
|
if (action.input.srcFolder === action.input.targetParentFolder) throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");
|
|
8083
|
-
const
|
|
8166
|
+
const nodes = readNodes(state);
|
|
8167
|
+
const node = nodes.find((node) => node.id === action.input.srcFolder);
|
|
8084
8168
|
if (!node) throw new Error(`Node with id ${action.input.srcFolder} not found`);
|
|
8085
8169
|
const name = handleTargetNameCollisions({
|
|
8086
|
-
nodes
|
|
8170
|
+
nodes,
|
|
8087
8171
|
srcName: node.name,
|
|
8088
8172
|
srcKind: node.kind === "file" ? "file" : "folder",
|
|
8089
8173
|
targetParentFolder: action.input.targetParentFolder || null
|
|
8090
8174
|
});
|
|
8091
8175
|
if (isFolderNode(node)) {
|
|
8092
|
-
if (getDescendants(node,
|
|
8176
|
+
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");
|
|
8093
8177
|
}
|
|
8094
|
-
state
|
|
8178
|
+
assignNodes(state, sortNodesById(nodes.map((node) => {
|
|
8095
8179
|
if (node.id === action.input.srcFolder) return {
|
|
8096
8180
|
...node,
|
|
8097
8181
|
name,
|
|
8098
8182
|
parentFolder: action.input.targetParentFolder || null
|
|
8099
8183
|
};
|
|
8100
8184
|
return node;
|
|
8101
|
-
});
|
|
8102
|
-
state.nodes.sort((a, b) => a.id.localeCompare(b.id));
|
|
8185
|
+
})));
|
|
8103
8186
|
}
|
|
8104
8187
|
};
|
|
8105
8188
|
const driveStateReducer = (state, action, dispatch) => {
|
|
@@ -8234,4 +8317,4 @@ const driveDocumentModelModule = {
|
|
|
8234
8317
|
//#endregion
|
|
8235
8318
|
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 };
|
|
8236
8319
|
|
|
8237
|
-
//# sourceMappingURL=document-drive-
|
|
8320
|
+
//# sourceMappingURL=document-drive-fcQ4o8i3.js.map
|