@flowgram.ai/document 0.1.27 → 0.1.29
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/esm/index.js +25 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var FlowNodeBaseType = /* @__PURE__ */ ((FlowNodeBaseType2) => {
|
|
|
27
27
|
return FlowNodeBaseType2;
|
|
28
28
|
})(FlowNodeBaseType || {});
|
|
29
29
|
var FlowNodeSplitType = /* @__PURE__ */ ((FlowNodeSplitType2) => {
|
|
30
|
+
FlowNodeSplitType2["SIMPLE_SPLIT"] = "simpleSplit";
|
|
30
31
|
FlowNodeSplitType2["DYNAMIC_SPLIT"] = "dynamicSplit";
|
|
31
32
|
FlowNodeSplitType2["STATIC_SPLIT"] = "staticSplit";
|
|
32
33
|
return FlowNodeSplitType2;
|
|
@@ -1661,6 +1662,13 @@ var FlowDocument = class {
|
|
|
1661
1662
|
this.onNodeCreate = this.onNodeCreateEmitter.event;
|
|
1662
1663
|
this.onNodeDispose = this.onNodeDisposeEmitter.event;
|
|
1663
1664
|
this.onLayoutChange = this.onLayoutChangeEmitter.event;
|
|
1665
|
+
this._disposed = false;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
*
|
|
1669
|
+
*/
|
|
1670
|
+
get disposed() {
|
|
1671
|
+
return this._disposed;
|
|
1664
1672
|
}
|
|
1665
1673
|
init() {
|
|
1666
1674
|
if (!this.options) this.options = FlowDocumentOptionsDefault;
|
|
@@ -1686,6 +1694,7 @@ var FlowDocument = class {
|
|
|
1686
1694
|
* @param fireRender 是否要触发渲染,默认 true
|
|
1687
1695
|
*/
|
|
1688
1696
|
fromJSON(json, fireRender = true) {
|
|
1697
|
+
if (this._disposed) return;
|
|
1689
1698
|
this.originTree.clear();
|
|
1690
1699
|
this.renderTree.clear();
|
|
1691
1700
|
this.entityManager.changeEntityLocked = true;
|
|
@@ -1754,7 +1763,7 @@ var FlowDocument = class {
|
|
|
1754
1763
|
* @param data
|
|
1755
1764
|
* @param addedNodes
|
|
1756
1765
|
*/
|
|
1757
|
-
addNode(data, addedNodes,
|
|
1766
|
+
addNode(data, addedNodes, ignoreCreateAndUpdateEvent) {
|
|
1758
1767
|
const { id, type = "block", originParent, parent, meta, hidden, index } = data;
|
|
1759
1768
|
let node = this.getNode(id);
|
|
1760
1769
|
let isNew = false;
|
|
@@ -1775,10 +1784,10 @@ var FlowDocument = class {
|
|
|
1775
1784
|
const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
|
|
1776
1785
|
node.addInitializeData(datas);
|
|
1777
1786
|
node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
|
|
1778
|
-
|
|
1779
|
-
this.options.fromNodeJSON(node, data);
|
|
1780
|
-
}
|
|
1787
|
+
this.options.fromNodeJSON?.(node, data, true);
|
|
1781
1788
|
isNew = true;
|
|
1789
|
+
} else {
|
|
1790
|
+
this.options.fromNodeJSON?.(node, data, false);
|
|
1782
1791
|
}
|
|
1783
1792
|
node.initData({
|
|
1784
1793
|
originParent,
|
|
@@ -1790,7 +1799,6 @@ var FlowDocument = class {
|
|
|
1790
1799
|
if (node.isStart) {
|
|
1791
1800
|
this.root.addChild(node);
|
|
1792
1801
|
}
|
|
1793
|
-
this.onNodeUpdateEmitter.fire({ node, data });
|
|
1794
1802
|
addedNodes?.push(node);
|
|
1795
1803
|
if (register.onCreate) {
|
|
1796
1804
|
const extendNodes = register.onCreate(node, data);
|
|
@@ -1804,11 +1812,16 @@ var FlowDocument = class {
|
|
|
1804
1812
|
this.addBlocksAsChildren(node, data.blocks, addedNodes);
|
|
1805
1813
|
}
|
|
1806
1814
|
}
|
|
1807
|
-
if (
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1815
|
+
if (!ignoreCreateAndUpdateEvent) {
|
|
1816
|
+
if (isNew) {
|
|
1817
|
+
this.onNodeCreateEmitter.fire({
|
|
1818
|
+
node,
|
|
1819
|
+
data,
|
|
1820
|
+
json: data
|
|
1821
|
+
});
|
|
1822
|
+
} else {
|
|
1823
|
+
this.onNodeUpdateEmitter.fire({ node, data, json: data });
|
|
1824
|
+
}
|
|
1812
1825
|
}
|
|
1813
1826
|
return node;
|
|
1814
1827
|
}
|
|
@@ -2123,6 +2136,7 @@ var FlowDocument = class {
|
|
|
2123
2136
|
);
|
|
2124
2137
|
}
|
|
2125
2138
|
dispose() {
|
|
2139
|
+
if (this._disposed) return;
|
|
2126
2140
|
this.registers.clear();
|
|
2127
2141
|
this.nodeRegistryCache.clear();
|
|
2128
2142
|
this.originTree.dispose();
|
|
@@ -2131,6 +2145,7 @@ var FlowDocument = class {
|
|
|
2131
2145
|
this.onNodeCreateEmitter.dispose();
|
|
2132
2146
|
this.onNodeDisposeEmitter.dispose();
|
|
2133
2147
|
this.onLayoutChangeEmitter.dispose();
|
|
2148
|
+
this._disposed = true;
|
|
2134
2149
|
}
|
|
2135
2150
|
};
|
|
2136
2151
|
__decorateClass([
|