@inditextech/weave-sdk 0.40.0 → 0.40.1
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/sdk.cjs +137 -134
- package/dist/sdk.js +137 -134
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -15548,7 +15548,6 @@ var WeaveStore = class {
|
|
|
15548
15548
|
this.getState().weave
|
|
15549
15549
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15550
15550
|
);
|
|
15551
|
-
console.log(`User: ${this.config.getUser().id}`);
|
|
15552
15551
|
if (weaveStateValues) {
|
|
15553
15552
|
this.undoManager = new yjs.UndoManager([weaveStateValues], {
|
|
15554
15553
|
captureTimeout: 250,
|
|
@@ -15578,6 +15577,7 @@ var WeaveStore = class {
|
|
|
15578
15577
|
}
|
|
15579
15578
|
(0, __syncedstore_core.observeDeep)(this.getState(), () => {
|
|
15580
15579
|
const newState = JSON.parse(JSON.stringify(this.getState()));
|
|
15580
|
+
this.logger.info({ newState }, "State changed");
|
|
15581
15581
|
this.instance.emitEvent("onStateChange", newState);
|
|
15582
15582
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
15583
15583
|
if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
|
|
@@ -18419,156 +18419,159 @@ var WeaveStateManager = class {
|
|
|
18419
18419
|
return this.findNodeById(state, nodeKey);
|
|
18420
18420
|
}
|
|
18421
18421
|
addNode(node, parentId = "mainLayer", index = void 0) {
|
|
18422
|
-
const
|
|
18423
|
-
this.
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18434
|
-
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18459
|
-
...actNode.props,
|
|
18460
|
-
zIndex: index$1
|
|
18461
|
-
}
|
|
18462
|
-
};
|
|
18463
|
-
});
|
|
18464
|
-
parent.props.children = parentChildren;
|
|
18465
|
-
} else {
|
|
18466
|
-
const childrenAmount = parent.props.children.length;
|
|
18467
|
-
const finalNode = {
|
|
18468
|
-
...node,
|
|
18422
|
+
const state = this.instance.getStore().getState();
|
|
18423
|
+
this.logger.info({ state: JSON.parse(JSON.stringify(state)) }, "State before addNode");
|
|
18424
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18425
|
+
const msg = `State is empty, cannot add the node`;
|
|
18426
|
+
this.logger.warn({
|
|
18427
|
+
node,
|
|
18428
|
+
parentId
|
|
18429
|
+
}, msg);
|
|
18430
|
+
return;
|
|
18431
|
+
}
|
|
18432
|
+
const { node: nodeState } = this.findNodeById(state.weave, node.key);
|
|
18433
|
+
if (nodeState) {
|
|
18434
|
+
const msg = `Node with key [${node.key}] already exists, cannot add it`;
|
|
18435
|
+
this.logger.warn({
|
|
18436
|
+
node,
|
|
18437
|
+
parentId
|
|
18438
|
+
}, msg);
|
|
18439
|
+
return;
|
|
18440
|
+
}
|
|
18441
|
+
const { node: parent } = this.findNodeById(state.weave, parentId);
|
|
18442
|
+
if (!parent) {
|
|
18443
|
+
const msg = `Parent container with key [${node.key}] doesn't exists, cannot add it`;
|
|
18444
|
+
this.logger.warn({
|
|
18445
|
+
node,
|
|
18446
|
+
parentId
|
|
18447
|
+
}, msg);
|
|
18448
|
+
return;
|
|
18449
|
+
}
|
|
18450
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before init");
|
|
18451
|
+
let parentChildren = [];
|
|
18452
|
+
if (parent.props.children) parentChildren = JSON.parse(JSON.stringify(parent.props.children));
|
|
18453
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before add");
|
|
18454
|
+
if (index && parentChildren) {
|
|
18455
|
+
parentChildren.splice(index, 0, node);
|
|
18456
|
+
parentChildren = parentChildren.map((actNode, index$1) => {
|
|
18457
|
+
return {
|
|
18458
|
+
...actNode,
|
|
18469
18459
|
props: {
|
|
18470
|
-
...
|
|
18471
|
-
zIndex:
|
|
18460
|
+
...actNode.props,
|
|
18461
|
+
zIndex: index$1
|
|
18472
18462
|
}
|
|
18473
18463
|
};
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18464
|
+
});
|
|
18465
|
+
}
|
|
18466
|
+
if (!index && parent.props.children) {
|
|
18467
|
+
const childrenAmount = parent.props.children.length;
|
|
18468
|
+
let finalNode = JSON.parse(JSON.stringify(node));
|
|
18469
|
+
finalNode = {
|
|
18470
|
+
...finalNode,
|
|
18471
|
+
props: {
|
|
18472
|
+
...finalNode.props,
|
|
18473
|
+
zIndex: childrenAmount
|
|
18474
|
+
}
|
|
18475
|
+
};
|
|
18476
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(finalNode)) }, "addNode: node to add");
|
|
18477
|
+
parentChildren.push(finalNode);
|
|
18478
|
+
}
|
|
18479
|
+
parent.props.children = parentChildren;
|
|
18480
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent after add");
|
|
18481
|
+
this.instance.emitEvent("onNodeAdded", node);
|
|
18478
18482
|
}
|
|
18479
18483
|
updateNode(node) {
|
|
18480
|
-
const
|
|
18481
|
-
this.
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18484
|
+
const state = this.instance.getStore().getState();
|
|
18485
|
+
this.logger.info({ state: JSON.parse(JSON.stringify(state)) }, "State before updateNode");
|
|
18486
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18487
|
+
const msg = `State is empty, cannot update the node`;
|
|
18488
|
+
this.logger.warn({ node }, msg);
|
|
18489
|
+
return;
|
|
18490
|
+
}
|
|
18491
|
+
const { node: nodeState } = this.findNodeById(state.weave, node.key);
|
|
18492
|
+
if (!nodeState) {
|
|
18493
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
|
|
18494
|
+
this.logger.warn({ node }, msg);
|
|
18495
|
+
return;
|
|
18496
|
+
}
|
|
18497
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: before update");
|
|
18498
|
+
const nodeNew = JSON.parse(JSON.stringify({
|
|
18499
|
+
...nodeState.props,
|
|
18500
|
+
...node.props
|
|
18501
|
+
}));
|
|
18502
|
+
nodeState.props = { ...nodeNew };
|
|
18503
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: after update");
|
|
18504
|
+
this.instance.emitEvent("onNodeUpdated", node);
|
|
18501
18505
|
}
|
|
18502
18506
|
removeNode(node) {
|
|
18503
|
-
const
|
|
18504
|
-
this.
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18518
|
-
|
|
18519
|
-
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
this.
|
|
18523
|
-
}
|
|
18507
|
+
const state = this.instance.getStore().getState();
|
|
18508
|
+
this.logger.info({ stage: JSON.parse(JSON.stringify(state)) }, "State before removeNode");
|
|
18509
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18510
|
+
const msg = `State is empty, cannot update the node`;
|
|
18511
|
+
this.logger.warn({ node }, msg);
|
|
18512
|
+
return;
|
|
18513
|
+
}
|
|
18514
|
+
const { node: nodeState, parent: parentState } = this.findNodeById(state.weave, node.key);
|
|
18515
|
+
if (!nodeState) {
|
|
18516
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot remove it`;
|
|
18517
|
+
this.logger.warn({ node }, msg);
|
|
18518
|
+
return;
|
|
18519
|
+
}
|
|
18520
|
+
this.logger.info({ key: node.key }, "removeNode: node to remove");
|
|
18521
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent before remove");
|
|
18522
|
+
if (parentState && parentState.props.children) {
|
|
18523
|
+
const newChildren = JSON.parse(JSON.stringify(parentState.props.children));
|
|
18524
|
+
const filteredChildren = newChildren.filter((actNode) => actNode.key !== node.key);
|
|
18525
|
+
parentState.props.children = filteredChildren;
|
|
18526
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent after remove");
|
|
18527
|
+
}
|
|
18528
|
+
this.instance.emitEvent("onNodeRemoved", node);
|
|
18524
18529
|
}
|
|
18525
18530
|
removeNodes(nodes) {
|
|
18526
18531
|
for (const node of nodes) this.removeNode(node);
|
|
18527
18532
|
}
|
|
18528
18533
|
moveNode(node, position) {
|
|
18529
|
-
const
|
|
18530
|
-
|
|
18531
|
-
const
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
const
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
...actNode,
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
|
|
18563
|
-
nodeParent.props.children = nodeParentNewChildren;
|
|
18564
|
-
}
|
|
18565
|
-
}, userId);
|
|
18534
|
+
const state = this.instance.getStore().getState();
|
|
18535
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18536
|
+
const msg = `State is empty, cannot update the node`;
|
|
18537
|
+
this.logger.warn({ node }, msg);
|
|
18538
|
+
return;
|
|
18539
|
+
}
|
|
18540
|
+
const { node: nodeState, parent: nodeParent } = this.findNodeById(state.weave, node.key);
|
|
18541
|
+
if (!nodeState) {
|
|
18542
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
|
|
18543
|
+
this.logger.warn({ node }, msg);
|
|
18544
|
+
return;
|
|
18545
|
+
}
|
|
18546
|
+
if (nodeParent && nodeParent.props.children) {
|
|
18547
|
+
let nodeParentNewChildren = JSON.parse(JSON.stringify([...nodeParent.props.children ?? []]));
|
|
18548
|
+
const nodeNew = JSON.parse(JSON.stringify({ ...node }));
|
|
18549
|
+
const childrenAmount = nodeParentNewChildren.length;
|
|
18550
|
+
const nodeIndex = nodeParentNewChildren.findIndex((n) => n.key === nodeNew.key);
|
|
18551
|
+
nodeParentNewChildren.splice(nodeIndex, 1);
|
|
18552
|
+
if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.UP) nodeParentNewChildren.splice(nodeIndex + 1, 0, nodeNew);
|
|
18553
|
+
if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN) nodeParentNewChildren.splice(nodeIndex - 1, 0, nodeNew);
|
|
18554
|
+
if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT) nodeParentNewChildren.splice(childrenAmount - 1, 0, nodeNew);
|
|
18555
|
+
if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.BACK) nodeParentNewChildren.splice(0, 0, nodeNew);
|
|
18556
|
+
nodeParentNewChildren = nodeParentNewChildren.map((actNode, index) => {
|
|
18557
|
+
return {
|
|
18558
|
+
...actNode,
|
|
18559
|
+
props: {
|
|
18560
|
+
...actNode.props,
|
|
18561
|
+
zIndex: index
|
|
18562
|
+
}
|
|
18563
|
+
};
|
|
18564
|
+
});
|
|
18565
|
+
if (!nodeParent.props.children) nodeParent.props.children = [];
|
|
18566
|
+
nodeParent.props.children = nodeParentNewChildren;
|
|
18567
|
+
}
|
|
18566
18568
|
}
|
|
18567
18569
|
getElementsTree() {
|
|
18568
18570
|
const state = this.instance.getStore().getState().weave;
|
|
18569
18571
|
const jsonState = JSON.parse(JSON.stringify(state, null, 2));
|
|
18570
18572
|
const mainLayer = jsonState.props?.children.find((node) => node.key === "mainLayer");
|
|
18571
18573
|
if (!mainLayer) return [];
|
|
18574
|
+
if (!mainLayer.props?.children) return [];
|
|
18572
18575
|
return mainLayer.props.children;
|
|
18573
18576
|
}
|
|
18574
18577
|
};
|
|
@@ -18646,7 +18649,7 @@ var WeaveRegisterManager = class {
|
|
|
18646
18649
|
|
|
18647
18650
|
//#endregion
|
|
18648
18651
|
//#region package.json
|
|
18649
|
-
var version = "0.40.
|
|
18652
|
+
var version = "0.40.1";
|
|
18650
18653
|
|
|
18651
18654
|
//#endregion
|
|
18652
18655
|
//#region src/managers/setup.ts
|
package/dist/sdk.js
CHANGED
|
@@ -15548,7 +15548,6 @@ var WeaveStore = class {
|
|
|
15548
15548
|
this.getState().weave
|
|
15549
15549
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15550
15550
|
);
|
|
15551
|
-
console.log(`User: ${this.config.getUser().id}`);
|
|
15552
15551
|
if (weaveStateValues) {
|
|
15553
15552
|
this.undoManager = new UndoManager([weaveStateValues], {
|
|
15554
15553
|
captureTimeout: 250,
|
|
@@ -15578,6 +15577,7 @@ var WeaveStore = class {
|
|
|
15578
15577
|
}
|
|
15579
15578
|
observeDeep(this.getState(), () => {
|
|
15580
15579
|
const newState = JSON.parse(JSON.stringify(this.getState()));
|
|
15580
|
+
this.logger.info({ newState }, "State changed");
|
|
15581
15581
|
this.instance.emitEvent("onStateChange", newState);
|
|
15582
15582
|
const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
15583
15583
|
if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
|
|
@@ -18419,156 +18419,159 @@ var WeaveStateManager = class {
|
|
|
18419
18419
|
return this.findNodeById(state, nodeKey);
|
|
18420
18420
|
}
|
|
18421
18421
|
addNode(node, parentId = "mainLayer", index = void 0) {
|
|
18422
|
-
const
|
|
18423
|
-
this.
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18434
|
-
|
|
18435
|
-
|
|
18436
|
-
|
|
18437
|
-
|
|
18438
|
-
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18459
|
-
...actNode.props,
|
|
18460
|
-
zIndex: index$1
|
|
18461
|
-
}
|
|
18462
|
-
};
|
|
18463
|
-
});
|
|
18464
|
-
parent.props.children = parentChildren;
|
|
18465
|
-
} else {
|
|
18466
|
-
const childrenAmount = parent.props.children.length;
|
|
18467
|
-
const finalNode = {
|
|
18468
|
-
...node,
|
|
18422
|
+
const state = this.instance.getStore().getState();
|
|
18423
|
+
this.logger.info({ state: JSON.parse(JSON.stringify(state)) }, "State before addNode");
|
|
18424
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18425
|
+
const msg = `State is empty, cannot add the node`;
|
|
18426
|
+
this.logger.warn({
|
|
18427
|
+
node,
|
|
18428
|
+
parentId
|
|
18429
|
+
}, msg);
|
|
18430
|
+
return;
|
|
18431
|
+
}
|
|
18432
|
+
const { node: nodeState } = this.findNodeById(state.weave, node.key);
|
|
18433
|
+
if (nodeState) {
|
|
18434
|
+
const msg = `Node with key [${node.key}] already exists, cannot add it`;
|
|
18435
|
+
this.logger.warn({
|
|
18436
|
+
node,
|
|
18437
|
+
parentId
|
|
18438
|
+
}, msg);
|
|
18439
|
+
return;
|
|
18440
|
+
}
|
|
18441
|
+
const { node: parent } = this.findNodeById(state.weave, parentId);
|
|
18442
|
+
if (!parent) {
|
|
18443
|
+
const msg = `Parent container with key [${node.key}] doesn't exists, cannot add it`;
|
|
18444
|
+
this.logger.warn({
|
|
18445
|
+
node,
|
|
18446
|
+
parentId
|
|
18447
|
+
}, msg);
|
|
18448
|
+
return;
|
|
18449
|
+
}
|
|
18450
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before init");
|
|
18451
|
+
let parentChildren = [];
|
|
18452
|
+
if (parent.props.children) parentChildren = JSON.parse(JSON.stringify(parent.props.children));
|
|
18453
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before add");
|
|
18454
|
+
if (index && parentChildren) {
|
|
18455
|
+
parentChildren.splice(index, 0, node);
|
|
18456
|
+
parentChildren = parentChildren.map((actNode, index$1) => {
|
|
18457
|
+
return {
|
|
18458
|
+
...actNode,
|
|
18469
18459
|
props: {
|
|
18470
|
-
...
|
|
18471
|
-
zIndex:
|
|
18460
|
+
...actNode.props,
|
|
18461
|
+
zIndex: index$1
|
|
18472
18462
|
}
|
|
18473
18463
|
};
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18464
|
+
});
|
|
18465
|
+
}
|
|
18466
|
+
if (!index && parent.props.children) {
|
|
18467
|
+
const childrenAmount = parent.props.children.length;
|
|
18468
|
+
let finalNode = JSON.parse(JSON.stringify(node));
|
|
18469
|
+
finalNode = {
|
|
18470
|
+
...finalNode,
|
|
18471
|
+
props: {
|
|
18472
|
+
...finalNode.props,
|
|
18473
|
+
zIndex: childrenAmount
|
|
18474
|
+
}
|
|
18475
|
+
};
|
|
18476
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(finalNode)) }, "addNode: node to add");
|
|
18477
|
+
parentChildren.push(finalNode);
|
|
18478
|
+
}
|
|
18479
|
+
parent.props.children = parentChildren;
|
|
18480
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent after add");
|
|
18481
|
+
this.instance.emitEvent("onNodeAdded", node);
|
|
18478
18482
|
}
|
|
18479
18483
|
updateNode(node) {
|
|
18480
|
-
const
|
|
18481
|
-
this.
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18494
|
-
|
|
18495
|
-
|
|
18496
|
-
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18484
|
+
const state = this.instance.getStore().getState();
|
|
18485
|
+
this.logger.info({ state: JSON.parse(JSON.stringify(state)) }, "State before updateNode");
|
|
18486
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18487
|
+
const msg = `State is empty, cannot update the node`;
|
|
18488
|
+
this.logger.warn({ node }, msg);
|
|
18489
|
+
return;
|
|
18490
|
+
}
|
|
18491
|
+
const { node: nodeState } = this.findNodeById(state.weave, node.key);
|
|
18492
|
+
if (!nodeState) {
|
|
18493
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
|
|
18494
|
+
this.logger.warn({ node }, msg);
|
|
18495
|
+
return;
|
|
18496
|
+
}
|
|
18497
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: before update");
|
|
18498
|
+
const nodeNew = JSON.parse(JSON.stringify({
|
|
18499
|
+
...nodeState.props,
|
|
18500
|
+
...node.props
|
|
18501
|
+
}));
|
|
18502
|
+
nodeState.props = { ...nodeNew };
|
|
18503
|
+
this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: after update");
|
|
18504
|
+
this.instance.emitEvent("onNodeUpdated", node);
|
|
18501
18505
|
}
|
|
18502
18506
|
removeNode(node) {
|
|
18503
|
-
const
|
|
18504
|
-
this.
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
18515
|
-
|
|
18516
|
-
|
|
18517
|
-
|
|
18518
|
-
|
|
18519
|
-
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
this.
|
|
18523
|
-
}
|
|
18507
|
+
const state = this.instance.getStore().getState();
|
|
18508
|
+
this.logger.info({ stage: JSON.parse(JSON.stringify(state)) }, "State before removeNode");
|
|
18509
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18510
|
+
const msg = `State is empty, cannot update the node`;
|
|
18511
|
+
this.logger.warn({ node }, msg);
|
|
18512
|
+
return;
|
|
18513
|
+
}
|
|
18514
|
+
const { node: nodeState, parent: parentState } = this.findNodeById(state.weave, node.key);
|
|
18515
|
+
if (!nodeState) {
|
|
18516
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot remove it`;
|
|
18517
|
+
this.logger.warn({ node }, msg);
|
|
18518
|
+
return;
|
|
18519
|
+
}
|
|
18520
|
+
this.logger.info({ key: node.key }, "removeNode: node to remove");
|
|
18521
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent before remove");
|
|
18522
|
+
if (parentState && parentState.props.children) {
|
|
18523
|
+
const newChildren = JSON.parse(JSON.stringify(parentState.props.children));
|
|
18524
|
+
const filteredChildren = newChildren.filter((actNode) => actNode.key !== node.key);
|
|
18525
|
+
parentState.props.children = filteredChildren;
|
|
18526
|
+
this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent after remove");
|
|
18527
|
+
}
|
|
18528
|
+
this.instance.emitEvent("onNodeRemoved", node);
|
|
18524
18529
|
}
|
|
18525
18530
|
removeNodes(nodes) {
|
|
18526
18531
|
for (const node of nodes) this.removeNode(node);
|
|
18527
18532
|
}
|
|
18528
18533
|
moveNode(node, position) {
|
|
18529
|
-
const
|
|
18530
|
-
|
|
18531
|
-
const
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
const
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18543
|
-
|
|
18544
|
-
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
...actNode,
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
|
|
18563
|
-
nodeParent.props.children = nodeParentNewChildren;
|
|
18564
|
-
}
|
|
18565
|
-
}, userId);
|
|
18534
|
+
const state = this.instance.getStore().getState();
|
|
18535
|
+
if ((0, import_lodash.isEmpty)(state.weave)) {
|
|
18536
|
+
const msg = `State is empty, cannot update the node`;
|
|
18537
|
+
this.logger.warn({ node }, msg);
|
|
18538
|
+
return;
|
|
18539
|
+
}
|
|
18540
|
+
const { node: nodeState, parent: nodeParent } = this.findNodeById(state.weave, node.key);
|
|
18541
|
+
if (!nodeState) {
|
|
18542
|
+
const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
|
|
18543
|
+
this.logger.warn({ node }, msg);
|
|
18544
|
+
return;
|
|
18545
|
+
}
|
|
18546
|
+
if (nodeParent && nodeParent.props.children) {
|
|
18547
|
+
let nodeParentNewChildren = JSON.parse(JSON.stringify([...nodeParent.props.children ?? []]));
|
|
18548
|
+
const nodeNew = JSON.parse(JSON.stringify({ ...node }));
|
|
18549
|
+
const childrenAmount = nodeParentNewChildren.length;
|
|
18550
|
+
const nodeIndex = nodeParentNewChildren.findIndex((n) => n.key === nodeNew.key);
|
|
18551
|
+
nodeParentNewChildren.splice(nodeIndex, 1);
|
|
18552
|
+
if (position === WEAVE_NODE_POSITION.UP) nodeParentNewChildren.splice(nodeIndex + 1, 0, nodeNew);
|
|
18553
|
+
if (position === WEAVE_NODE_POSITION.DOWN) nodeParentNewChildren.splice(nodeIndex - 1, 0, nodeNew);
|
|
18554
|
+
if (position === WEAVE_NODE_POSITION.FRONT) nodeParentNewChildren.splice(childrenAmount - 1, 0, nodeNew);
|
|
18555
|
+
if (position === WEAVE_NODE_POSITION.BACK) nodeParentNewChildren.splice(0, 0, nodeNew);
|
|
18556
|
+
nodeParentNewChildren = nodeParentNewChildren.map((actNode, index) => {
|
|
18557
|
+
return {
|
|
18558
|
+
...actNode,
|
|
18559
|
+
props: {
|
|
18560
|
+
...actNode.props,
|
|
18561
|
+
zIndex: index
|
|
18562
|
+
}
|
|
18563
|
+
};
|
|
18564
|
+
});
|
|
18565
|
+
if (!nodeParent.props.children) nodeParent.props.children = [];
|
|
18566
|
+
nodeParent.props.children = nodeParentNewChildren;
|
|
18567
|
+
}
|
|
18566
18568
|
}
|
|
18567
18569
|
getElementsTree() {
|
|
18568
18570
|
const state = this.instance.getStore().getState().weave;
|
|
18569
18571
|
const jsonState = JSON.parse(JSON.stringify(state, null, 2));
|
|
18570
18572
|
const mainLayer = jsonState.props?.children.find((node) => node.key === "mainLayer");
|
|
18571
18573
|
if (!mainLayer) return [];
|
|
18574
|
+
if (!mainLayer.props?.children) return [];
|
|
18572
18575
|
return mainLayer.props.children;
|
|
18573
18576
|
}
|
|
18574
18577
|
};
|
|
@@ -18646,7 +18649,7 @@ var WeaveRegisterManager = class {
|
|
|
18646
18649
|
|
|
18647
18650
|
//#endregion
|
|
18648
18651
|
//#region package.json
|
|
18649
|
-
var version = "0.40.
|
|
18652
|
+
var version = "0.40.1";
|
|
18650
18653
|
|
|
18651
18654
|
//#endregion
|
|
18652
18655
|
//#region src/managers/setup.ts
|