@flowgram.ai/free-layout-core 0.3.3 → 0.3.4

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 CHANGED
@@ -2221,10 +2221,13 @@ var WorkflowDocument = class extends FlowDocument {
2221
2221
  from: line.from.id,
2222
2222
  to: line.to.id
2223
2223
  }));
2224
- const startNodeId = allNode.find((node) => node.isStart).id;
2225
- const endNodeId = allNode.find((node) => node.isNodeEnd).id;
2224
+ const startNodeId = allNode.find((node) => node.isStart)?.id;
2225
+ const endNodeId = allNode.find((node) => node.isNodeEnd)?.id;
2226
2226
  const nodeInContainer = allNode.filter((node) => node.parent?.getNodeMeta().isContainer).map((node) => node.id);
2227
- const associatedCache = /* @__PURE__ */ new Set([endNodeId, ...nodeInContainer]);
2227
+ const associatedCache = new Set(nodeInContainer);
2228
+ if (endNodeId) {
2229
+ associatedCache.add(endNodeId);
2230
+ }
2228
2231
  const bfs = (nodeId) => {
2229
2232
  if (associatedCache.has(nodeId)) {
2230
2233
  return;
@@ -2238,7 +2241,9 @@ var WorkflowDocument = class extends FlowDocument {
2238
2241
  }, []);
2239
2242
  nextNodes.forEach(bfs);
2240
2243
  };
2241
- bfs(startNodeId);
2244
+ if (startNodeId) {
2245
+ bfs(startNodeId);
2246
+ }
2242
2247
  const associatedNodes = allNode.filter((node) => associatedCache.has(node.id));
2243
2248
  return associatedNodes;
2244
2249
  }
@@ -2360,6 +2365,11 @@ var WorkflowDocument = class extends FlowDocument {
2360
2365
  * 导出数据
2361
2366
  */
2362
2367
  toJSON() {
2368
+ if (this.disposed) {
2369
+ throw new Error(
2370
+ "The WorkflowDocument has been disposed and it is no longer possible to call toJSON."
2371
+ );
2372
+ }
2363
2373
  const rootJSON = this.toNodeJSON(this.root);
2364
2374
  const json = {
2365
2375
  nodes: rootJSON.blocks ?? [],