@flowgram.ai/document 0.1.28 → 0.1.30
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 +33 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -22,8 +22,13 @@ var FlowNodeBaseType = /* @__PURE__ */ ((FlowNodeBaseType2) => {
|
|
|
22
22
|
FlowNodeBaseType2["BLOCK_ORDER_ICON"] = "blockOrderIcon";
|
|
23
23
|
FlowNodeBaseType2["GROUP"] = "group";
|
|
24
24
|
FlowNodeBaseType2["END"] = "end";
|
|
25
|
+
FlowNodeBaseType2["BREAK"] = "break";
|
|
25
26
|
FlowNodeBaseType2["CONDITION"] = "condition";
|
|
26
27
|
FlowNodeBaseType2["SUB_CANVAS"] = "subCanvas";
|
|
28
|
+
FlowNodeBaseType2["MULTI_INPUTS"] = "multiInputs";
|
|
29
|
+
FlowNodeBaseType2["MULTI_OUTPUTS"] = "multiOutputs";
|
|
30
|
+
FlowNodeBaseType2["INPUT"] = "input";
|
|
31
|
+
FlowNodeBaseType2["OUTPUT"] = "output";
|
|
27
32
|
return FlowNodeBaseType2;
|
|
28
33
|
})(FlowNodeBaseType || {});
|
|
29
34
|
var FlowNodeSplitType = /* @__PURE__ */ ((FlowNodeSplitType2) => {
|
|
@@ -1662,6 +1667,13 @@ var FlowDocument = class {
|
|
|
1662
1667
|
this.onNodeCreate = this.onNodeCreateEmitter.event;
|
|
1663
1668
|
this.onNodeDispose = this.onNodeDisposeEmitter.event;
|
|
1664
1669
|
this.onLayoutChange = this.onLayoutChangeEmitter.event;
|
|
1670
|
+
this._disposed = false;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
*
|
|
1674
|
+
*/
|
|
1675
|
+
get disposed() {
|
|
1676
|
+
return this._disposed;
|
|
1665
1677
|
}
|
|
1666
1678
|
init() {
|
|
1667
1679
|
if (!this.options) this.options = FlowDocumentOptionsDefault;
|
|
@@ -1687,6 +1699,7 @@ var FlowDocument = class {
|
|
|
1687
1699
|
* @param fireRender 是否要触发渲染,默认 true
|
|
1688
1700
|
*/
|
|
1689
1701
|
fromJSON(json, fireRender = true) {
|
|
1702
|
+
if (this._disposed) return;
|
|
1690
1703
|
this.originTree.clear();
|
|
1691
1704
|
this.renderTree.clear();
|
|
1692
1705
|
this.entityManager.changeEntityLocked = true;
|
|
@@ -1755,7 +1768,7 @@ var FlowDocument = class {
|
|
|
1755
1768
|
* @param data
|
|
1756
1769
|
* @param addedNodes
|
|
1757
1770
|
*/
|
|
1758
|
-
addNode(data, addedNodes,
|
|
1771
|
+
addNode(data, addedNodes, ignoreCreateAndUpdateEvent) {
|
|
1759
1772
|
const { id, type = "block", originParent, parent, meta, hidden, index } = data;
|
|
1760
1773
|
let node = this.getNode(id);
|
|
1761
1774
|
let isNew = false;
|
|
@@ -1776,10 +1789,10 @@ var FlowDocument = class {
|
|
|
1776
1789
|
const datas = dataRegistries ? this.nodeDataRegistries.concat(...dataRegistries) : this.nodeDataRegistries;
|
|
1777
1790
|
node.addInitializeData(datas);
|
|
1778
1791
|
node.onDispose(() => this.onNodeDisposeEmitter.fire({ node }));
|
|
1779
|
-
|
|
1780
|
-
this.options.fromNodeJSON(node, data);
|
|
1781
|
-
}
|
|
1792
|
+
this.options.fromNodeJSON?.(node, data, true);
|
|
1782
1793
|
isNew = true;
|
|
1794
|
+
} else {
|
|
1795
|
+
this.options.fromNodeJSON?.(node, data, false);
|
|
1783
1796
|
}
|
|
1784
1797
|
node.initData({
|
|
1785
1798
|
originParent,
|
|
@@ -1791,7 +1804,6 @@ var FlowDocument = class {
|
|
|
1791
1804
|
if (node.isStart) {
|
|
1792
1805
|
this.root.addChild(node);
|
|
1793
1806
|
}
|
|
1794
|
-
this.onNodeUpdateEmitter.fire({ node, data });
|
|
1795
1807
|
addedNodes?.push(node);
|
|
1796
1808
|
if (register.onCreate) {
|
|
1797
1809
|
const extendNodes = register.onCreate(node, data);
|
|
@@ -1805,11 +1817,16 @@ var FlowDocument = class {
|
|
|
1805
1817
|
this.addBlocksAsChildren(node, data.blocks, addedNodes);
|
|
1806
1818
|
}
|
|
1807
1819
|
}
|
|
1808
|
-
if (
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1820
|
+
if (!ignoreCreateAndUpdateEvent) {
|
|
1821
|
+
if (isNew) {
|
|
1822
|
+
this.onNodeCreateEmitter.fire({
|
|
1823
|
+
node,
|
|
1824
|
+
data,
|
|
1825
|
+
json: data
|
|
1826
|
+
});
|
|
1827
|
+
} else {
|
|
1828
|
+
this.onNodeUpdateEmitter.fire({ node, data, json: data });
|
|
1829
|
+
}
|
|
1813
1830
|
}
|
|
1814
1831
|
return node;
|
|
1815
1832
|
}
|
|
@@ -1948,6 +1965,7 @@ var FlowDocument = class {
|
|
|
1948
1965
|
const customDefaultRegistry = this.options.getNodeDefaultRegistry?.(type);
|
|
1949
1966
|
let register = this.registers.get(type) || { type };
|
|
1950
1967
|
const extendRegisters = [];
|
|
1968
|
+
const extendKey = register.extend;
|
|
1951
1969
|
if (register.extend && this.registers.has(register.extend)) {
|
|
1952
1970
|
register = FlowNodeRegistry.merge(
|
|
1953
1971
|
this.getNodeRegistry(register.extend),
|
|
@@ -1978,6 +1996,9 @@ var FlowDocument = class {
|
|
|
1978
1996
|
...register.meta
|
|
1979
1997
|
}
|
|
1980
1998
|
};
|
|
1999
|
+
if (extendKey) {
|
|
2000
|
+
res.extend = extendKey;
|
|
2001
|
+
}
|
|
1981
2002
|
this.nodeRegistryCache.set(typeKey, res);
|
|
1982
2003
|
return res;
|
|
1983
2004
|
}
|
|
@@ -2124,6 +2145,7 @@ var FlowDocument = class {
|
|
|
2124
2145
|
);
|
|
2125
2146
|
}
|
|
2126
2147
|
dispose() {
|
|
2148
|
+
if (this._disposed) return;
|
|
2127
2149
|
this.registers.clear();
|
|
2128
2150
|
this.nodeRegistryCache.clear();
|
|
2129
2151
|
this.originTree.dispose();
|
|
@@ -2132,6 +2154,7 @@ var FlowDocument = class {
|
|
|
2132
2154
|
this.onNodeCreateEmitter.dispose();
|
|
2133
2155
|
this.onNodeDisposeEmitter.dispose();
|
|
2134
2156
|
this.onLayoutChangeEmitter.dispose();
|
|
2157
|
+
this._disposed = true;
|
|
2135
2158
|
}
|
|
2136
2159
|
};
|
|
2137
2160
|
__decorateClass([
|