@flowgram.ai/variable-layout 0.5.4 → 0.5.6

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/index.js CHANGED
@@ -65,9 +65,15 @@ var FlowNodeVariableData = class extends import_core.EntityData {
65
65
  });
66
66
  this.toDispose.push(this._public);
67
67
  }
68
+ /**
69
+ * The private scope of the node.
70
+ */
68
71
  get private() {
69
72
  return this._private;
70
73
  }
74
+ /**
75
+ * The public scope of the node.
76
+ */
71
77
  get public() {
72
78
  return this._public;
73
79
  }
@@ -125,6 +131,9 @@ var FlowNodeVariableData = class extends import_core.EntityData {
125
131
  clearPrivateVar(key = "outputs") {
126
132
  return this.private?.ast.remove(key);
127
133
  }
134
+ /**
135
+ * An array containing all scopes (public and private) of the node.
136
+ */
128
137
  get allScopes() {
129
138
  const res = [];
130
139
  if (this._public) {
@@ -138,6 +147,11 @@ var FlowNodeVariableData = class extends import_core.EntityData {
138
147
  getDefaultData() {
139
148
  return {};
140
149
  }
150
+ /**
151
+ * Initializes and returns the private scope for the node.
152
+ * If the private scope already exists, it returns the existing one.
153
+ * @returns The private scope of the node.
154
+ */
141
155
  initPrivate() {
142
156
  if (!this._private) {
143
157
  this._private = this.variableEngine.createScope(`${this.entity.id}_private`, {
@@ -206,11 +220,17 @@ var ScopeChainTransformService = class {
206
220
  /**
207
221
  * register new transform function
208
222
  * @param transformerId used to identify transformer, prevent duplicated transformer
209
- * @param transformer
223
+ * @param transformer The transformer to register.
210
224
  */
211
225
  registerTransformer(transformerId, transformer) {
212
226
  this.transformerMap.set(transformerId, transformer);
213
227
  }
228
+ /**
229
+ * Transforms the dependency scopes.
230
+ * @param scopes The array of scopes to transform.
231
+ * @param param1 The context for the transformation.
232
+ * @returns The transformed array of scopes.
233
+ */
214
234
  transformDeps(scopes, { scope }) {
215
235
  return Array.from(this.transformerMap.values()).reduce((scopes2, transformer) => {
216
236
  if (!transformer.transformDeps) {
@@ -224,6 +244,12 @@ var ScopeChainTransformService = class {
224
244
  return scopes2;
225
245
  }, scopes);
226
246
  }
247
+ /**
248
+ * Transforms the cover scopes.
249
+ * @param scopes The array of scopes to transform.
250
+ * @param param1 The context for the transformation.
251
+ * @returns The transformed array of scopes.
252
+ */
227
253
  transformCovers(scopes, { scope }) {
228
254
  return Array.from(this.transformerMap.values()).reduce((scopes2, transformer) => {
229
255
  if (!transformer.transformCovers) {
@@ -254,6 +280,11 @@ ScopeChainTransformService = __decorateClass([
254
280
  var import_inversify2 = require("inversify");
255
281
  var import_variable_core2 = require("@flowgram.ai/variable-core");
256
282
  var GlobalScope = class extends import_variable_core2.Scope {
283
+ /**
284
+ * Check if the scope is Global Scope.
285
+ * @param scope
286
+ * @returns
287
+ */
257
288
  static is(scope) {
258
289
  return scope.id === GlobalScope.ID;
259
290
  }
@@ -280,24 +311,31 @@ var bindGlobalScope = (bind) => {
280
311
 
281
312
  // src/chains/free-layout-scope-chain.ts
282
313
  var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
314
+ /**
315
+ * The virtual tree of the flow document.
316
+ */
283
317
  get tree() {
284
318
  return this.flowDocument.originTree;
285
319
  }
286
320
  onInit() {
287
321
  this.toDispose.pushAll([
288
- // 线条发生变化时,会触发作用域链的更新
322
+ // When the line changes, the scope chain will be updated
289
323
  this.entityManager.onEntityDataChange(({ entityDataType }) => {
290
324
  if (entityDataType === import_free_layout_core.WorkflowNodeLinesData.type) {
291
325
  this.refreshAllChange();
292
326
  }
293
327
  }),
294
- // 树变化时候刷新作用域
328
+ // Refresh the scope when the tree changes
295
329
  this.tree.onTreeChange(() => {
296
330
  this.refreshAllChange();
297
331
  })
298
332
  ]);
299
333
  }
300
- // 获取同一层级所有输入节点, 按照由近到远的顺序
334
+ /**
335
+ * Gets all input layer nodes for a given node in the same layer, sorted by distance.
336
+ * @param node The node to get input layer nodes for.
337
+ * @returns An array of input layer nodes.
338
+ */
301
339
  getAllInputLayerNodes(node) {
302
340
  const currParent = this.getNodeParent(node);
303
341
  const result = /* @__PURE__ */ new Set();
@@ -316,13 +354,22 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
316
354
  }
317
355
  return Array.from(result).reverse();
318
356
  }
319
- // 获取同一层级所有输出节点
357
+ /**
358
+ * Gets all output layer nodes for a given node in the same layer.
359
+ * @param curr The node to get output layer nodes for.
360
+ * @returns An array of output layer nodes.
361
+ */
320
362
  getAllOutputLayerNodes(curr) {
321
363
  const currParent = this.getNodeParent(curr);
322
364
  return (curr.lines?.allOutputNodes || []).filter(
323
365
  (_node) => this.getNodeParent(_node) === currParent
324
366
  );
325
367
  }
368
+ /**
369
+ * Gets the dependency scopes for a given scope.
370
+ * @param scope The scope to get dependencies for.
371
+ * @returns An array of dependency scopes.
372
+ */
326
373
  getDeps(scope) {
327
374
  const { node } = scope.meta || {};
328
375
  if (!node) {
@@ -352,6 +399,11 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
352
399
  const uniqDeps = Array.from(new Set(deps));
353
400
  return this.transformService.transformDeps(uniqDeps, { scope });
354
401
  }
402
+ /**
403
+ * Gets the covering scopes for a given scope.
404
+ * @param scope The scope to get covering scopes for.
405
+ * @returns An array of covering scopes.
406
+ */
355
407
  getCovers(scope) {
356
408
  if (GlobalScope.is(scope)) {
357
409
  const scopes2 = this.variableEngine.getAllScopes({ sort: true }).filter((_scope) => !GlobalScope.is(_scope));
@@ -393,6 +445,11 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
393
445
  const uniqScopes = Array.from(new Set(scopes));
394
446
  return this.transformService.transformCovers(uniqScopes, { scope });
395
447
  }
448
+ /**
449
+ * Gets the children of a node.
450
+ * @param node The node to get children for.
451
+ * @returns An array of child nodes.
452
+ */
396
453
  getNodeChildren(node) {
397
454
  if (this.configs?.getNodeChildren) {
398
455
  return this.configs.getNodeChildren?.(node);
@@ -422,6 +479,11 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
422
479
  ...this.getAllPublicChildScopes(_node)
423
480
  ]).flat();
424
481
  }
482
+ /**
483
+ * Gets the parent of a node.
484
+ * @param node The node to get the parent for.
485
+ * @returns The parent node or `undefined` if not found.
486
+ */
425
487
  getNodeParent(node) {
426
488
  if (this.configs?.getNodeParent) {
427
489
  return this.configs.getNodeParent(node);
@@ -440,7 +502,11 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
440
502
  }
441
503
  return parent;
442
504
  }
443
- // Child nodes can not be accessed
505
+ /**
506
+ * Checks if the children of a node are private and cannot be accessed by subsequent nodes.
507
+ * @param node The node to check.
508
+ * @returns `true` if the children are private, `false` otherwise.
509
+ */
444
510
  isNodeChildrenPrivate(node) {
445
511
  if (this.configs?.isNodeChildrenPrivate) {
446
512
  return node ? this.configs?.isNodeChildrenPrivate(node) : false;
@@ -448,6 +514,10 @@ var FreeLayoutScopeChain = class extends import_variable_core3.ScopeChain {
448
514
  const isSystemNode = node?.id.startsWith("$");
449
515
  return !isSystemNode && node?.flowNodeType !== import_document2.FlowNodeBaseType.GROUP;
450
516
  }
517
+ /**
518
+ * Sorts all scopes in the scope chain.
519
+ * @returns An empty array, as this method is not implemented.
520
+ */
451
521
  sortAll() {
452
522
  console.warn("FreeLayoutScopeChain.sortAll is not implemented");
453
523
  return [];
@@ -481,17 +551,24 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
481
551
  this.configs = configs;
482
552
  this.bindTree(flowDocument.originTree);
483
553
  this.toDispose.push(
484
- // REFRACTOR: onTreeChange 触发时机精细化
554
+ // REFRACTOR: onTreeChange trigger timing needs to be refined
485
555
  flowDocument.originTree.onTreeChange(() => {
486
556
  this.refreshAllChange();
487
557
  })
488
558
  );
489
559
  }
490
- // 绑定树
560
+ /**
561
+ * Binds the scope chain to a `FlowVirtualTree`.
562
+ * @param tree The `FlowVirtualTree` to bind to.
563
+ */
491
564
  bindTree(tree) {
492
565
  this.tree = tree;
493
566
  }
494
- // 获取依赖作用域
567
+ /**
568
+ * Gets the dependency scopes for a given scope.
569
+ * @param scope The scope to get dependencies for.
570
+ * @returns An array of dependency scopes.
571
+ */
495
572
  getDeps(scope) {
496
573
  if (!this.tree) {
497
574
  return this.transformService.transformDeps([], { scope });
@@ -548,7 +625,11 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
548
625
  }
549
626
  return this.transformService.transformDeps(deps, { scope });
550
627
  }
551
- // 获取覆盖作用域
628
+ /**
629
+ * Gets the covering scopes for a given scope.
630
+ * @param scope The scope to get covering scopes for.
631
+ * @returns An array of covering scopes.
632
+ */
552
633
  getCovers(scope) {
553
634
  if (!this.tree) {
554
635
  return this.transformService.transformCovers([], { scope });
@@ -612,7 +693,10 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
612
693
  }
613
694
  return this.transformService.transformCovers(covers, { scope });
614
695
  }
615
- // 排序所有作用域
696
+ /**
697
+ * Sorts all scopes in the scope chain.
698
+ * @returns A sorted array of all scopes.
699
+ */
616
700
  sortAll() {
617
701
  const startNode = this.flowDocument.getAllNodes().find((_node) => _node.isStart);
618
702
  if (!startNode) {
@@ -626,7 +710,11 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
626
710
  );
627
711
  return [...deps, startPublicScope, ...covers];
628
712
  }
629
- // 获取变量 Data 数据
713
+ /**
714
+ * Gets the `FlowNodeVariableData` for a given `ScopeChainNode`.
715
+ * @param node The `ScopeChainNode` to get data for.
716
+ * @returns The `FlowNodeVariableData` or `undefined` if not found.
717
+ */
630
718
  getVariableData(node) {
631
719
  if (node.flowNodeType === "virtualNode") {
632
720
  return;
@@ -636,7 +724,11 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
636
724
  }
637
725
  return node.getData(FlowNodeVariableData);
638
726
  }
639
- // 子节点不可以被后续节点访问
727
+ /**
728
+ * Checks if the children of a node are private.
729
+ * @param node The node to check.
730
+ * @returns `true` if the children are private, `false` otherwise.
731
+ */
640
732
  isNodeChildrenPrivate(node) {
641
733
  if (this.configs?.isNodeChildrenPrivate) {
642
734
  return node ? this.configs?.isNodeChildrenPrivate(node) : false;
@@ -644,10 +736,20 @@ var FixedLayoutScopeChain = class extends import_variable_core4.ScopeChain {
644
736
  const isSystemNode = node?.id.startsWith("$");
645
737
  return !isSystemNode && this.hasChildren(node);
646
738
  }
739
+ /**
740
+ * Checks if a node has children.
741
+ * @param node The node to check.
742
+ * @returns `true` if the node has children, `false` otherwise.
743
+ */
647
744
  hasChildren(node) {
648
745
  return Boolean(this.tree && node && this.tree.getChildren(node).length > 0);
649
746
  }
650
- // 子节点按照顺序进行排序(含自身)
747
+ /**
748
+ * Gets all sorted child scopes of a node.
749
+ * @param node The node to get child scopes for.
750
+ * @param options Options for getting child scopes.
751
+ * @returns An array of sorted child scopes.
752
+ */
651
753
  getAllSortedChildScope(node, {
652
754
  ignoreNodeChildrenPrivate,
653
755
  addNodePrivateScope
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/flow-node-variable-data.ts","../src/types.ts","../src/chains/free-layout-scope-chain.ts","../src/variable-chain-config.ts","../src/services/scope-chain-transform-service.ts","../src/scopes/global-scope.ts","../src/chains/fixed-layout-scope-chain.ts","../src/utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { FlowNodeVariableData } from './flow-node-variable-data';\nexport { FreeLayoutScopeChain } from './chains/free-layout-scope-chain';\nexport { VariableChainConfig } from './variable-chain-config';\nexport { FixedLayoutScopeChain } from './chains/fixed-layout-scope-chain';\nexport {\n type FlowNodeScopeMeta,\n type FlowNodeScope,\n FlowNodeScopeTypeEnum as FlowNodeScopeType,\n} from './types';\nexport { GlobalScope, bindGlobalScope } from './scopes/global-scope';\nexport { ScopeChainTransformService } from './services/scope-chain-transform-service';\nexport { getNodeScope, getNodePrivateScope } from './utils';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { BaseVariableField, VariableEngine } from '@flowgram.ai/variable-core';\nimport { type ASTNode, ASTNodeJSON } from '@flowgram.ai/variable-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { EntityData } from '@flowgram.ai/core';\n\nimport { FlowNodeScope, FlowNodeScopeMeta, FlowNodeScopeTypeEnum } from './types';\n\ninterface Options {\n variableEngine: VariableEngine;\n}\n\nexport class FlowNodeVariableData extends EntityData {\n static type: string = 'FlowNodeVariableData';\n\n declare entity: FlowNodeEntity;\n\n readonly variableEngine: VariableEngine;\n\n /**\n * Private variables can be accessed by public ones, but not the other way around.\n */\n protected _private?: FlowNodeScope;\n\n protected _public: FlowNodeScope;\n\n get private() {\n return this._private;\n }\n\n get public() {\n return this._public;\n }\n\n /**\n * Sets a variable in the public AST (Abstract Syntax Tree) with the given key and JSON value.\n *\n * @param key - The key under which the variable will be stored.\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setVar(key: string, json: ASTNodeJSON): ASTNode;\n\n /**\n * Sets a variable in the public AST (Abstract Syntax Tree) with the default key 'outputs'.\n *\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setVar(json: ASTNodeJSON): ASTNode;\n\n public setVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.public.ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.public.ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the public AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The value of the variable, or undefined if not found.\n */\n public getVar(key: string = 'outputs') {\n return this.public.ast.get(key);\n }\n\n /**\n * Clears a variable from the public AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to clear. Defaults to 'outputs'.\n * @returns The updated AST node.\n */\n public clearVar(key: string = 'outputs') {\n return this.public.ast.remove(key);\n }\n\n /**\n * Sets a variable in the private AST (Abstract Syntax Tree) with the given key and JSON value.\n *\n * @param key - The key under which the variable will be stored.\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setPrivateVar(key: string, json: ASTNodeJSON): ASTNode;\n\n /**\n * Sets a variable in the private AST (Abstract Syntax Tree) with the default key 'outputs'.\n *\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setPrivateVar(json: ASTNodeJSON): ASTNode;\n\n public setPrivateVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.initPrivate().ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.initPrivate().ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the private AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The value of the variable, or undefined if not found.\n */\n public getPrivateVar(key: string = 'outputs') {\n return this.private?.ast.get(key);\n }\n\n /**\n * Clears a variable from the private AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to clear. Defaults to 'outputs'.\n * @returns The updated AST node.\n */\n public clearPrivateVar(key: string = 'outputs') {\n return this.private?.ast.remove(key);\n }\n\n get allScopes(): FlowNodeScope[] {\n const res = [];\n\n if (this._public) {\n res.push(this._public);\n }\n if (this._private) {\n res.push(this._private);\n }\n\n return res;\n }\n\n getDefaultData() {\n return {};\n }\n\n constructor(entity: FlowNodeEntity, readonly opts: Options) {\n super(entity);\n\n const { variableEngine } = opts || {};\n this.variableEngine = variableEngine;\n this._public = this.variableEngine.createScope(this.entity.id, {\n node: this.entity,\n type: FlowNodeScopeTypeEnum.public,\n } as FlowNodeScopeMeta);\n this.toDispose.push(this._public);\n }\n\n initPrivate(): FlowNodeScope {\n if (!this._private) {\n this._private = this.variableEngine.createScope(`${this.entity.id}_private`, {\n node: this.entity,\n type: FlowNodeScopeTypeEnum.private,\n } as FlowNodeScopeMeta);\n\n this.variableEngine.chain.refreshAllChange();\n\n this.toDispose.push(this._private);\n }\n return this._private;\n }\n\n /**\n * Find a variable field by key path in the public scope by scope chain.\n * @param keyPath - The key path of the variable field.\n * @returns The variable field, or undefined if not found.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n return this.public.available.getByKeyPath(keyPath);\n }\n\n /**\n * Find a variable field by key path in the private scope by scope chain.\n * @param keyPath - The key path of the variable field.\n * @returns The variable field, or undefined if not found.\n */\n getByKeyPathInPrivate(keyPath: string[]): BaseVariableField | undefined {\n return this.private?.available.getByKeyPath(keyPath);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Scope } from '@flowgram.ai/variable-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nexport enum FlowNodeScopeTypeEnum {\n public = 'public',\n private = 'private',\n}\n\nexport interface FlowNodeScopeMeta {\n node?: FlowNodeEntity;\n type?: FlowNodeScopeTypeEnum;\n}\n\nexport interface ScopeVirtualNode {\n id: string;\n flowNodeType: 'virtualNode';\n}\n\nexport type ScopeChainNode = FlowNodeEntity | ScopeVirtualNode;\n\n// 节点内部的作用域\nexport interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, optional, postConstruct } from 'inversify';\nimport { Scope, ScopeChain } from '@flowgram.ai/variable-core';\nimport { WorkflowNodeLinesData, WorkflowNodeMeta } from '@flowgram.ai/free-layout-core';\nimport {\n FlowNodeEntity,\n FlowDocument,\n FlowVirtualTree,\n FlowNodeBaseType,\n} from '@flowgram.ai/document';\nimport { EntityManager } from '@flowgram.ai/core';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope, FlowNodeScopeTypeEnum } from '../types';\nimport { ScopeChainTransformService } from '../services/scope-chain-transform-service';\nimport { GlobalScope } from '../scopes/global-scope';\nimport { FlowNodeVariableData } from '../flow-node-variable-data';\n\n/**\n * 自由布局作用域链实现\n */\nexport class FreeLayoutScopeChain extends ScopeChain {\n @inject(EntityManager) entityManager: EntityManager;\n\n @inject(FlowDocument)\n protected flowDocument: FlowDocument;\n\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig;\n\n @inject(ScopeChainTransformService)\n protected transformService: ScopeChainTransformService;\n\n get tree(): FlowVirtualTree<FlowNodeEntity> {\n return this.flowDocument.originTree;\n }\n\n @postConstruct()\n onInit() {\n this.toDispose.pushAll([\n // 线条发生变化时,会触发作用域链的更新\n this.entityManager.onEntityDataChange(({ entityDataType }) => {\n if (entityDataType === WorkflowNodeLinesData.type) {\n this.refreshAllChange();\n }\n }),\n // 树变化时候刷新作用域\n this.tree.onTreeChange(() => {\n this.refreshAllChange();\n }),\n ]);\n }\n\n // 获取同一层级所有输入节点, 按照由近到远的顺序\n protected getAllInputLayerNodes(node: FlowNodeEntity): FlowNodeEntity[] {\n const currParent = this.getNodeParent(node);\n\n const result = new Set<FlowNodeEntity>();\n\n // add by bfs\n const queue: FlowNodeEntity[] = [node];\n\n while (queue.length) {\n const curr = queue.shift()!;\n\n (curr.lines?.inputNodes || []).forEach((inputNode) => {\n if (this.getNodeParent(inputNode) === currParent) {\n if (result.has(inputNode)) {\n return;\n }\n queue.push(inputNode);\n result.add(inputNode);\n }\n });\n }\n\n return Array.from(result).reverse();\n }\n\n // 获取同一层级所有输出节点\n protected getAllOutputLayerNodes(curr: FlowNodeEntity): FlowNodeEntity[] {\n const currParent = this.getNodeParent(curr);\n\n return (curr.lines?.allOutputNodes || []).filter(\n (_node) => this.getNodeParent(_node) === currParent\n );\n }\n\n getDeps(scope: FlowNodeScope): FlowNodeScope[] {\n const { node } = scope.meta || {};\n if (!node) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const deps: FlowNodeScope[] = [];\n\n // 1. find dep nodes\n let curr: FlowNodeEntity | undefined = node;\n\n while (curr) {\n // 2. private scope of parent node can be access\n const currVarData: FlowNodeVariableData = curr.getData(FlowNodeVariableData);\n if (currVarData?.private && scope !== currVarData.private) {\n deps.unshift(currVarData.private);\n }\n\n // 3. all public scopes of inputNodes\n const allInputNodes: FlowNodeEntity[] = this.getAllInputLayerNodes(curr);\n deps.unshift(\n ...allInputNodes\n .map((_node) => [\n _node.getData(FlowNodeVariableData).public,\n // 4. all public children of inputNodes\n ...this.getAllPublicChildScopes(_node),\n ])\n .flat()\n .filter(Boolean)\n );\n\n curr = this.getNodeParent(curr);\n }\n\n // If scope is GlobalScope, add globalScope to deps\n const globalScope = this.variableEngine.getScopeById(GlobalScope.ID);\n if (globalScope) {\n deps.unshift(globalScope);\n }\n\n const uniqDeps = Array.from(new Set(deps));\n return this.transformService.transformDeps(uniqDeps, { scope });\n }\n\n getCovers(scope: FlowNodeScope): FlowNodeScope[] {\n // If scope is GlobalScope, return all scopes except GlobalScope\n if (GlobalScope.is(scope)) {\n const scopes = this.variableEngine\n .getAllScopes({ sort: true })\n .filter((_scope) => !GlobalScope.is(_scope));\n\n return this.transformService.transformCovers(scopes, { scope });\n }\n\n const { node } = scope.meta || {};\n if (!node) {\n return this.transformService.transformCovers([], { scope });\n }\n\n const isPrivate = scope.meta.type === FlowNodeScopeTypeEnum.private;\n\n // 1. BFS 找到所有覆盖的节点\n const queue: FlowNodeEntity[] = [];\n\n if (isPrivate) {\n // private 只能覆盖其子节点\n queue.push(...this.getNodeChildren(node));\n } else {\n // 否则覆盖其所有输出线的节点\n queue.push(...(this.getAllOutputLayerNodes(node) || []));\n\n // get all parents\n let parent = this.getNodeParent(node);\n\n while (parent) {\n // if childNodes of parent is private to next nodes, break\n if (this.isNodeChildrenPrivate(parent)) {\n break;\n }\n\n queue.push(...this.getAllOutputLayerNodes(parent));\n\n parent = this.getNodeParent(parent);\n }\n }\n\n // 2. 获取所有覆盖节点的 public、private 作用域\n const scopes: FlowNodeScope[] = [];\n\n while (queue.length) {\n const _node = queue.shift()!;\n const variableData: FlowNodeVariableData = _node.getData(FlowNodeVariableData);\n scopes.push(...variableData.allScopes);\n const children = _node && this.getNodeChildren(_node);\n\n if (children?.length) {\n queue.push(...children);\n }\n }\n\n // 3. 如果当前 scope 是 private,则当前节点的 public 也可覆盖\n const currentVariableData: FlowNodeVariableData = node.getData(FlowNodeVariableData);\n if (isPrivate && currentVariableData.public) {\n scopes.push(currentVariableData.public);\n }\n\n const uniqScopes = Array.from(new Set(scopes));\n\n return this.transformService.transformCovers(uniqScopes, { scope });\n }\n\n getNodeChildren(node: FlowNodeEntity): FlowNodeEntity[] {\n if (this.configs?.getNodeChildren) {\n return this.configs.getNodeChildren?.(node);\n }\n const nodeMeta = node.getNodeMeta<WorkflowNodeMeta>();\n const subCanvas = nodeMeta.subCanvas?.(node);\n\n if (subCanvas) {\n // 子画布本身不存在 children\n if (subCanvas.isCanvas) {\n return [];\n } else {\n return subCanvas.canvasNode.collapsedChildren;\n }\n }\n\n // 部分场景通过连线来表达父子关系,因此需要上层配置\n return this.tree.getChildren(node);\n }\n\n /**\n * Get All children of nodes\n * @param node\n * @returns\n */\n getAllPublicChildScopes(node: FlowNodeEntity): Scope[] {\n if (this.isNodeChildrenPrivate(node)) {\n return [];\n }\n\n return this.getNodeChildren(node)\n .map((_node) => [\n _node.getData(FlowNodeVariableData).public,\n ...this.getAllPublicChildScopes(_node),\n ])\n .flat();\n }\n\n getNodeParent(node: FlowNodeEntity): FlowNodeEntity | undefined {\n // 部分场景通过连线来表达父子关系,因此需要上层配置\n if (this.configs?.getNodeParent) {\n return this.configs.getNodeParent(node);\n }\n let parent = node.document.originTree.getParent(node);\n\n // If currentParent is Group, get the parent of parent\n while (parent?.flowNodeType === FlowNodeBaseType.GROUP) {\n parent = parent.parent;\n }\n\n if (!parent) {\n return parent;\n }\n\n const nodeMeta = parent.getNodeMeta<WorkflowNodeMeta>();\n const subCanvas = nodeMeta.subCanvas?.(parent);\n if (subCanvas?.isCanvas) {\n // Get real parent node by subCanvas Configuration\n return subCanvas.parentNode;\n }\n\n return parent;\n }\n\n // Child nodes can not be accessed\n protected isNodeChildrenPrivate(node?: FlowNodeEntity): boolean {\n if (this.configs?.isNodeChildrenPrivate) {\n return node ? this.configs?.isNodeChildrenPrivate(node) : false;\n }\n\n const isSystemNode = node?.id.startsWith('$');\n\n // Except system node and group node, everything else is private\n return !isSystemNode && node?.flowNodeType !== FlowNodeBaseType.GROUP;\n }\n\n sortAll(): Scope[] {\n // 暂未实现\n console.warn('FreeLayoutScopeChain.sortAll is not implemented');\n return [];\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { type ScopeChainNode } from './types';\nimport { IScopeTransformer } from './services/scope-chain-transform-service';\n\nexport interface VariableChainConfig {\n /**\n * The output variables of a node's children cannot be accessed by subsequent nodes.\n *\n * @param node\n * @returns\n */\n isNodeChildrenPrivate?: (node: ScopeChainNode) => boolean;\n\n /**\n * For fixed layout scenarios: there are a large number of useless nodes between parent and child (such as inlineBlocks, etc., which need to be configured to be skipped)\n * For free canvas scenarios: in some scenarios, the parent-child relationship between nodes is expressed through connections or other interactive forms, which needs to be configurable\n */\n getNodeChildren?: (node: FlowNodeEntity) => FlowNodeEntity[];\n getNodeParent?: (node: FlowNodeEntity) => FlowNodeEntity | undefined;\n\n /**\n * Fine-tune the dependency scope\n */\n transformDeps?: IScopeTransformer;\n\n /**\n * 对依赖作用域进行微调\n */\n transformCovers?: IScopeTransformer;\n}\n\nexport const VariableChainConfig = Symbol('VariableChainConfig');\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, injectable, optional } from 'inversify';\nimport { Scope, VariableEngine } from '@flowgram.ai/variable-core';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport { lazyInject } from '@flowgram.ai/core';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope } from '../types';\n\nexport interface TransformerContext {\n scope: FlowNodeScope;\n document: FlowDocument;\n variableEngine: VariableEngine;\n}\n\nexport type IScopeTransformer = (scopes: Scope[], ctx: TransformerContext) => Scope[];\n\nconst passthrough: IScopeTransformer = (scopes, ctx) => scopes;\n\n@injectable()\nexport class ScopeChainTransformService {\n protected transformerMap: Map<\n string,\n { transformDeps: IScopeTransformer; transformCovers: IScopeTransformer }\n > = new Map();\n\n @lazyInject(FlowDocument) document: FlowDocument;\n\n @lazyInject(VariableEngine) variableEngine: VariableEngine;\n\n constructor(\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig\n ) {\n if (this.configs?.transformDeps || this.configs?.transformCovers) {\n this.transformerMap.set('VARIABLE_LAYOUT_CONFIG', {\n transformDeps: this.configs.transformDeps || passthrough,\n transformCovers: this.configs.transformCovers || passthrough,\n });\n }\n }\n\n /**\n * check if transformer registered\n * @param transformerId used to identify transformer, prevent duplicated\n * @returns\n */\n hasTransformer(transformerId: string) {\n return this.transformerMap.has(transformerId);\n }\n\n /**\n * register new transform function\n * @param transformerId used to identify transformer, prevent duplicated transformer\n * @param transformer\n */\n registerTransformer(\n transformerId: string,\n transformer: {\n transformDeps: IScopeTransformer;\n transformCovers: IScopeTransformer;\n }\n ) {\n this.transformerMap.set(transformerId, transformer);\n }\n\n transformDeps(scopes: Scope[], { scope }: { scope: Scope }): Scope[] {\n return Array.from(this.transformerMap.values()).reduce((scopes, transformer) => {\n if (!transformer.transformDeps) {\n return scopes;\n }\n\n scopes = transformer.transformDeps(scopes, {\n scope,\n document: this.document,\n variableEngine: this.variableEngine,\n });\n return scopes;\n }, scopes);\n }\n\n transformCovers(scopes: Scope[], { scope }: { scope: Scope }): Scope[] {\n return Array.from(this.transformerMap.values()).reduce((scopes, transformer) => {\n if (!transformer.transformCovers) {\n return scopes;\n }\n\n scopes = transformer.transformCovers(scopes, {\n scope,\n document: this.document,\n variableEngine: this.variableEngine,\n });\n return scopes;\n }, scopes);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, interfaces } from 'inversify';\nimport { Scope, VariableEngine } from '@flowgram.ai/variable-core';\n\n@injectable()\nexport class GlobalScope extends Scope {\n static readonly ID = Symbol('GlobalScope');\n\n static is(scope: Scope) {\n return scope.id === GlobalScope.ID;\n }\n}\n\nexport const bindGlobalScope = (bind: interfaces.Bind) => {\n bind(GlobalScope).toDynamicValue((ctx) => {\n const variableEngine = ctx.container.get(VariableEngine);\n let scope = variableEngine.getScopeById(GlobalScope.ID) as GlobalScope;\n\n if (!scope) {\n scope = variableEngine.createScope(\n GlobalScope.ID,\n {},\n { ScopeConstructor: GlobalScope }\n ) as GlobalScope;\n variableEngine.chain.refreshAllChange();\n }\n\n return scope;\n });\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, optional } from 'inversify';\nimport { Scope, ScopeChain } from '@flowgram.ai/variable-core';\nimport { FlowDocument, type FlowVirtualTree } from '@flowgram.ai/document';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope, FlowNodeScopeTypeEnum, ScopeChainNode } from '../types';\nimport { ScopeChainTransformService } from '../services/scope-chain-transform-service';\nimport { GlobalScope } from '../scopes/global-scope';\nimport { FlowNodeVariableData } from '../flow-node-variable-data';\n\n/**\n * 基于 FlowVirtualTree 的 ScopeOrder 实现\n */\nexport class FixedLayoutScopeChain extends ScopeChain {\n // 增加 { id: string } 使得可以灵活添加自定义虚拟节点\n tree: FlowVirtualTree<ScopeChainNode> | undefined;\n\n @inject(ScopeChainTransformService)\n protected transformService: ScopeChainTransformService;\n\n constructor(\n @inject(FlowDocument)\n protected flowDocument: FlowDocument,\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig\n ) {\n super();\n\n // 绑定 flowDocument 里面的树\n this.bindTree(flowDocument.originTree);\n\n // originTree 发生变化时,触发依赖关系的变化\n this.toDispose.push(\n // REFRACTOR: onTreeChange 触发时机精细化\n flowDocument.originTree.onTreeChange(() => {\n this.refreshAllChange();\n })\n );\n }\n\n // 绑定树\n bindTree(tree: FlowVirtualTree<ScopeChainNode>): void {\n this.tree = tree;\n }\n\n // 获取依赖作用域\n getDeps(scope: FlowNodeScope): FlowNodeScope[] {\n if (!this.tree) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const node = scope.meta.node;\n if (!node) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const deps: FlowNodeScope[] = [];\n\n let curr: ScopeChainNode | undefined = node;\n\n while (curr) {\n const { parent, pre } = this.tree.getInfo(curr);\n const currData = this.getVariableData(curr);\n\n // 包含子节点,且不是私有作用域\n\n if (curr === node) {\n // public 可以依赖 private\n if (scope.meta.type === FlowNodeScopeTypeEnum.public && currData?.private) {\n deps.unshift(currData.private);\n }\n } else if (this.hasChildren(curr) && !this.isNodeChildrenPrivate(curr)) {\n // 有子元素的节点,则将子元素纳入依赖作用域\n deps.unshift(\n ...this.getAllSortedChildScope(curr, {\n ignoreNodeChildrenPrivate: true,\n })\n );\n }\n\n // 节点的 public 都可以被访问\n if (currData && curr !== node) {\n deps.unshift(currData.public);\n }\n\n // 上个节点处理\n if (pre) {\n curr = pre;\n continue;\n }\n\n // 父节点处理\n if (parent) {\n let currParent: ScopeChainNode | undefined = parent;\n let currParentPre: ScopeChainNode | undefined = this.tree.getPre(currParent);\n\n while (currParent) {\n // 父节点的 private 和 public 都能被子节点访问\n const currParentData = this.getVariableData(currParent);\n if (currParentData) {\n deps.unshift(...currParentData.allScopes);\n }\n\n // 当前 parent 有 pre 节点,则停止向上查找\n if (currParentPre) {\n break;\n }\n\n currParent = this.tree.getParent(currParent);\n currParentPre = currParent ? this.tree.getPre(currParent) : undefined;\n }\n curr = currParentPre;\n continue;\n }\n\n // next 和 parent 都没有,直接结束循环\n curr = undefined;\n }\n\n // If scope is GlobalScope, add globalScope to deps\n const globalScope = this.variableEngine.getScopeById(GlobalScope.ID);\n if (globalScope) {\n deps.unshift(globalScope);\n }\n\n return this.transformService.transformDeps(deps, { scope });\n }\n\n // 获取覆盖作用域\n getCovers(scope: FlowNodeScope): FlowNodeScope[] {\n if (!this.tree) {\n return this.transformService.transformCovers([], { scope });\n }\n\n // If scope is GlobalScope, return all scopes except GlobalScope\n if (GlobalScope.is(scope)) {\n const scopes = this.variableEngine\n .getAllScopes({ sort: true })\n .filter((_scope) => !GlobalScope.is(_scope));\n\n return this.transformService.transformCovers(scopes, { scope });\n }\n\n const node = scope.meta.node;\n if (!node) {\n return this.transformService.transformCovers([], { scope });\n }\n\n const covers: FlowNodeScope[] = [];\n\n // 如果是 private 作用域,则只能子节点访问\n if (scope.meta.type === FlowNodeScopeTypeEnum.private) {\n covers.push(\n ...this.getAllSortedChildScope(node, {\n addNodePrivateScope: true,\n }).filter((_scope) => _scope !== scope)\n );\n return this.transformService.transformCovers(covers, { scope });\n }\n\n let curr: ScopeChainNode | undefined = node;\n\n while (curr) {\n const { next, parent } = this.tree.getInfo(curr);\n const currData = this.getVariableData(curr);\n\n // 有子元素的节点,则将子元素纳入覆盖作用域\n if (curr !== node) {\n if (this.hasChildren(curr)) {\n covers.push(\n ...this.getAllSortedChildScope(curr, {\n addNodePrivateScope: true,\n })\n );\n } else if (currData) {\n covers.push(...currData.allScopes);\n }\n }\n\n // 下个节点处理\n if (next) {\n curr = next;\n continue;\n }\n\n if (parent) {\n let currParent: ScopeChainNode | undefined = parent;\n let currParentNext: ScopeChainNode | undefined = this.tree.getNext(currParent);\n\n while (currParent) {\n // 私有作用域不能被后续节点访问\n if (this.isNodeChildrenPrivate(currParent)) {\n return this.transformService.transformCovers(covers, { scope });\n }\n\n // 当前 parent 有 next 节点,则停止向上查找\n if (currParentNext) {\n break;\n }\n\n currParent = this.tree.getParent(currParent);\n currParentNext = currParent ? this.tree.getNext(currParent) : undefined;\n }\n if (!currParentNext && currParent) {\n break;\n }\n\n curr = currParentNext;\n continue;\n }\n\n // next 和 parent 都没有,直接结束循环\n curr = undefined;\n }\n\n return this.transformService.transformCovers(covers, { scope });\n }\n\n // 排序所有作用域\n sortAll(): Scope[] {\n const startNode = this.flowDocument.getAllNodes().find((_node) => _node.isStart);\n if (!startNode) {\n return [];\n }\n\n const startVariableData = startNode.getData(FlowNodeVariableData);\n const startPublicScope = startVariableData.public;\n const deps = this.getDeps(startPublicScope);\n\n const covers = this.getCovers(startPublicScope).filter(\n (_scope) => !deps.includes(_scope) && _scope !== startPublicScope\n );\n\n return [...deps, startPublicScope, ...covers];\n }\n\n // 获取变量 Data 数据\n private getVariableData(node: ScopeChainNode): FlowNodeVariableData | undefined {\n if (node.flowNodeType === 'virtualNode') {\n return;\n }\n // TODO 包含 $ 的节点不注册 variableData\n if (node.id.startsWith('$')) {\n return;\n }\n\n return (node as FlowNodeEntity).getData(FlowNodeVariableData);\n }\n\n // 子节点不可以被后续节点访问\n private isNodeChildrenPrivate(node?: ScopeChainNode): boolean {\n if (this.configs?.isNodeChildrenPrivate) {\n return node ? this.configs?.isNodeChildrenPrivate(node) : false;\n }\n\n const isSystemNode = node?.id.startsWith('$');\n // 兜底:有子节点(节点 id 没有 $ 开头)的全部为私有作用域\n return !isSystemNode && this.hasChildren(node);\n }\n\n private hasChildren(node?: ScopeChainNode): boolean {\n return Boolean(this.tree && node && this.tree.getChildren(node).length > 0);\n }\n\n // 子节点按照顺序进行排序(含自身)\n private getAllSortedChildScope(\n node: ScopeChainNode,\n {\n ignoreNodeChildrenPrivate,\n addNodePrivateScope,\n }: { ignoreNodeChildrenPrivate?: boolean; addNodePrivateScope?: boolean } = {}\n ): FlowNodeScope[] {\n const scopes: FlowNodeScope[] = [];\n\n const variableData = this.getVariableData(node);\n\n if (variableData) {\n scopes.push(variableData.public);\n }\n\n // 私有作用域,子节点的变量不对外输出\n //(父节点如果存在 public 变量则对外输出)\n if (ignoreNodeChildrenPrivate && this.isNodeChildrenPrivate(node)) {\n return scopes;\n }\n\n if (addNodePrivateScope && variableData?.private) {\n scopes.push(variableData.private);\n }\n\n const children = this.tree?.getChildren(node) || [];\n scopes.push(\n ...children\n .map((child) =>\n this.getAllSortedChildScope(child, { ignoreNodeChildrenPrivate, addNodePrivateScope })\n )\n .flat()\n );\n\n return scopes;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { FlowNodeVariableData } from './flow-node-variable-data';\n\n/**\n * Use `node.scope` instead\n * @deprecated\n * @param node\n */\nexport function getNodeScope(node: FlowNodeEntity) {\n return node.getData(FlowNodeVariableData).public;\n}\n\n/**\n * Use `node.privateScope` instead\n * @deprecated\n * @param node\n */\nexport function getNodePrivateScope(node: FlowNodeEntity) {\n return node.getData(FlowNodeVariableData).initPrivate();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,kBAA2B;;;ACApB,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;;;ADQL,IAAM,uBAAN,cAAmC,uBAAW;AAAA,EAyInD,YAAY,QAAiC,MAAe;AAC1D,UAAM,MAAM;AAD+B;AAG3C,UAAM,EAAE,eAAe,IAAI,QAAQ,CAAC;AACpC,SAAK,iBAAiB;AACtB,SAAK,UAAU,KAAK,eAAe,YAAY,KAAK,OAAO,IAAI;AAAA,MAC7D,MAAM,KAAK;AAAA,MACX;AAAA,IACF,CAAsB;AACtB,SAAK,UAAU,KAAK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C,WAAO,CAAC,gBAAgB,KAAK,YAAY,IAAI;AAAA,EAC/C;AAAA,EAEQ,YAAY,MAAgC;AAClD,WAAO,QAAQ,KAAK,QAAQ,QAAQ,KAAK,KAAK,YAAY,IAAI,EAAE,SAAS,CAAC;AAAA,EAC5E;AAAA;AAAA,EAGQ,uBACN,MACA;AAAA,IACE;AAAA,IACA;AAAA,EACF,IAA4E,CAAC,GAC5D;AACjB,UAAM,SAA0B,CAAC;AAEjC,UAAM,eAAe,KAAK,gBAAgB,IAAI;AAE9C,QAAI,cAAc;AAChB,aAAO,KAAK,aAAa,MAAM;AAAA,IACjC;AAIA,QAAI,6BAA6B,KAAK,sBAAsB,IAAI,GAAG;AACjE,aAAO;AAAA,IACT;AAEA,QAAI,uBAAuB,cAAc,SAAS;AAChD,aAAO,KAAK,aAAa,OAAO;AAAA,IAClC;AAEA,UAAM,WAAW,KAAK,MAAM,YAAY,IAAI,KAAK,CAAC;AAClD,WAAO;AAAA,MACL,GAAG,SACA;AAAA,QAAI,CAAC,UACJ,KAAK,uBAAuB,OAAO,EAAE,2BAA2B,oBAAoB,CAAC;AAAA,MACvF,EACC,KAAK;AAAA,IACV;AAEA,WAAO;AAAA,EACT;AACF;AA5RY;AAAA,MADT,0BAAO,0BAA0B;AAAA,GAJvB,sBAKD;AALC,wBAAN;AAAA,EAQF,iDAAO,6BAAY;AAAA,EAEnB,mDAAS;AAAA,EACT,iDAAO,mBAAmB;AAAA,GAXlB;;;ACLN,SAAS,aAAa,MAAsB;AACjD,SAAO,KAAK,QAAQ,oBAAoB,EAAE;AAC5C;AAOO,SAAS,oBAAoB,MAAsB;AACxD,SAAO,KAAK,QAAQ,oBAAoB,EAAE,YAAY;AACxD;","names":["FlowNodeScopeTypeEnum","import_inversify","import_variable_core","import_document","import_core","import_core","scopes","import_inversify","import_variable_core","scopes","import_inversify","import_variable_core","import_document"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/flow-node-variable-data.ts","../src/types.ts","../src/chains/free-layout-scope-chain.ts","../src/variable-chain-config.ts","../src/services/scope-chain-transform-service.ts","../src/scopes/global-scope.ts","../src/chains/fixed-layout-scope-chain.ts","../src/utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { FlowNodeVariableData } from './flow-node-variable-data';\nexport { FreeLayoutScopeChain } from './chains/free-layout-scope-chain';\nexport { VariableChainConfig } from './variable-chain-config';\nexport { FixedLayoutScopeChain } from './chains/fixed-layout-scope-chain';\nexport {\n type FlowNodeScopeMeta,\n type FlowNodeScope,\n FlowNodeScopeTypeEnum as FlowNodeScopeType,\n} from './types';\nexport { GlobalScope, bindGlobalScope } from './scopes/global-scope';\nexport { ScopeChainTransformService } from './services/scope-chain-transform-service';\nexport { getNodeScope, getNodePrivateScope } from './utils';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { BaseVariableField, VariableEngine } from '@flowgram.ai/variable-core';\nimport { type ASTNode, ASTNodeJSON } from '@flowgram.ai/variable-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\nimport { EntityData } from '@flowgram.ai/core';\n\nimport { FlowNodeScope, FlowNodeScopeMeta, FlowNodeScopeTypeEnum } from './types';\n\ninterface Options {\n variableEngine: VariableEngine;\n}\n\n/**\n * Manages variable data for a flow node, including public and private scopes.\n */\nexport class FlowNodeVariableData extends EntityData {\n static type: string = 'FlowNodeVariableData';\n\n declare entity: FlowNodeEntity;\n\n readonly variableEngine: VariableEngine;\n\n /**\n * Private variables can be accessed by public ones, but not the other way around.\n */\n protected _private?: FlowNodeScope;\n\n protected _public: FlowNodeScope;\n\n /**\n * The private scope of the node.\n */\n get private() {\n return this._private;\n }\n\n /**\n * The public scope of the node.\n */\n get public() {\n return this._public;\n }\n\n /**\n * Sets a variable in the public AST (Abstract Syntax Tree) with the given key and JSON value.\n *\n * @param key - The key under which the variable will be stored.\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setVar(key: string, json: ASTNodeJSON): ASTNode;\n\n /**\n * Sets a variable in the public AST (Abstract Syntax Tree) with the default key 'outputs'.\n *\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setVar(json: ASTNodeJSON): ASTNode;\n\n public setVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.public.ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.public.ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the public AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The value of the variable, or undefined if not found.\n */\n public getVar(key: string = 'outputs') {\n return this.public.ast.get(key);\n }\n\n /**\n * Clears a variable from the public AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to clear. Defaults to 'outputs'.\n * @returns The updated AST node.\n */\n public clearVar(key: string = 'outputs') {\n return this.public.ast.remove(key);\n }\n\n /**\n * Sets a variable in the private AST (Abstract Syntax Tree) with the given key and JSON value.\n *\n * @param key - The key under which the variable will be stored.\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setPrivateVar(key: string, json: ASTNodeJSON): ASTNode;\n\n /**\n * Sets a variable in the private AST (Abstract Syntax Tree) with the default key 'outputs'.\n *\n * @param json - The JSON value to store.\n * @returns The updated AST node.\n */\n public setPrivateVar(json: ASTNodeJSON): ASTNode;\n\n public setPrivateVar(arg1: string | ASTNodeJSON, arg2?: ASTNodeJSON): ASTNode {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.initPrivate().ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.initPrivate().ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the private AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The value of the variable, or undefined if not found.\n */\n public getPrivateVar(key: string = 'outputs') {\n return this.private?.ast.get(key);\n }\n\n /**\n * Clears a variable from the private AST (Abstract Syntax Tree) by key.\n *\n * @param key - The key of the variable to clear. Defaults to 'outputs'.\n * @returns The updated AST node.\n */\n public clearPrivateVar(key: string = 'outputs') {\n return this.private?.ast.remove(key);\n }\n\n /**\n * An array containing all scopes (public and private) of the node.\n */\n get allScopes(): FlowNodeScope[] {\n const res = [];\n\n if (this._public) {\n res.push(this._public);\n }\n if (this._private) {\n res.push(this._private);\n }\n\n return res;\n }\n\n getDefaultData() {\n return {};\n }\n\n constructor(entity: FlowNodeEntity, readonly opts: Options) {\n super(entity);\n\n const { variableEngine } = opts || {};\n this.variableEngine = variableEngine;\n this._public = this.variableEngine.createScope(this.entity.id, {\n node: this.entity,\n type: FlowNodeScopeTypeEnum.public,\n } as FlowNodeScopeMeta);\n this.toDispose.push(this._public);\n }\n\n /**\n * Initializes and returns the private scope for the node.\n * If the private scope already exists, it returns the existing one.\n * @returns The private scope of the node.\n */\n initPrivate(): FlowNodeScope {\n if (!this._private) {\n this._private = this.variableEngine.createScope(`${this.entity.id}_private`, {\n node: this.entity,\n type: FlowNodeScopeTypeEnum.private,\n } as FlowNodeScopeMeta);\n\n this.variableEngine.chain.refreshAllChange();\n\n this.toDispose.push(this._private);\n }\n return this._private;\n }\n\n /**\n * Find a variable field by key path in the public scope by scope chain.\n * @param keyPath - The key path of the variable field.\n * @returns The variable field, or undefined if not found.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n return this.public.available.getByKeyPath(keyPath);\n }\n\n /**\n * Find a variable field by key path in the private scope by scope chain.\n * @param keyPath - The key path of the variable field.\n * @returns The variable field, or undefined if not found.\n */\n getByKeyPathInPrivate(keyPath: string[]): BaseVariableField | undefined {\n return this.private?.available.getByKeyPath(keyPath);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Scope } from '@flowgram.ai/variable-core';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\n/**\n * Enum for flow node scope types.\n */\nexport enum FlowNodeScopeTypeEnum {\n /**\n * Public scope.\n */\n public = 'public',\n /**\n * Private scope.\n */\n private = 'private',\n}\n\n/**\n * Metadata for a flow node scope.\n */\nexport interface FlowNodeScopeMeta {\n /**\n * The flow node entity associated with the scope.\n */\n node?: FlowNodeEntity;\n /**\n * The type of the scope.\n */\n type?: FlowNodeScopeTypeEnum;\n}\n\n/**\n * Represents a virtual node in the scope chain.\n */\nexport interface ScopeVirtualNode {\n /**\n * The ID of the virtual node.\n */\n id: string;\n /**\n * The type of the flow node.\n */\n flowNodeType: 'virtualNode';\n}\n\n/**\n * Represents a node in the scope chain, which can be either a flow node entity or a virtual node.\n */\nexport type ScopeChainNode = FlowNodeEntity | ScopeVirtualNode;\n\n/**\n * Represents a scope associated with a flow node.\n */\nexport interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, optional, postConstruct } from 'inversify';\nimport { Scope, ScopeChain } from '@flowgram.ai/variable-core';\nimport { WorkflowNodeLinesData, WorkflowNodeMeta } from '@flowgram.ai/free-layout-core';\nimport {\n FlowNodeEntity,\n FlowDocument,\n FlowVirtualTree,\n FlowNodeBaseType,\n} from '@flowgram.ai/document';\nimport { EntityManager } from '@flowgram.ai/core';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope, FlowNodeScopeTypeEnum } from '../types';\nimport { ScopeChainTransformService } from '../services/scope-chain-transform-service';\nimport { GlobalScope } from '../scopes/global-scope';\nimport { FlowNodeVariableData } from '../flow-node-variable-data';\n\n/**\n * Scope chain implementation for free layout.\n */\nexport class FreeLayoutScopeChain extends ScopeChain {\n @inject(EntityManager) entityManager: EntityManager;\n\n @inject(FlowDocument)\n protected flowDocument: FlowDocument;\n\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig;\n\n @inject(ScopeChainTransformService)\n protected transformService: ScopeChainTransformService;\n\n /**\n * The virtual tree of the flow document.\n */\n get tree(): FlowVirtualTree<FlowNodeEntity> {\n return this.flowDocument.originTree;\n }\n\n @postConstruct()\n onInit() {\n this.toDispose.pushAll([\n // When the line changes, the scope chain will be updated\n this.entityManager.onEntityDataChange(({ entityDataType }) => {\n if (entityDataType === WorkflowNodeLinesData.type) {\n this.refreshAllChange();\n }\n }),\n // Refresh the scope when the tree changes\n this.tree.onTreeChange(() => {\n this.refreshAllChange();\n }),\n ]);\n }\n\n /**\n * Gets all input layer nodes for a given node in the same layer, sorted by distance.\n * @param node The node to get input layer nodes for.\n * @returns An array of input layer nodes.\n */\n protected getAllInputLayerNodes(node: FlowNodeEntity): FlowNodeEntity[] {\n const currParent = this.getNodeParent(node);\n\n const result = new Set<FlowNodeEntity>();\n\n // add by bfs\n const queue: FlowNodeEntity[] = [node];\n\n while (queue.length) {\n const curr = queue.shift()!;\n\n (curr.lines?.inputNodes || []).forEach((inputNode) => {\n if (this.getNodeParent(inputNode) === currParent) {\n if (result.has(inputNode)) {\n return;\n }\n queue.push(inputNode);\n result.add(inputNode);\n }\n });\n }\n\n return Array.from(result).reverse();\n }\n\n /**\n * Gets all output layer nodes for a given node in the same layer.\n * @param curr The node to get output layer nodes for.\n * @returns An array of output layer nodes.\n */\n protected getAllOutputLayerNodes(curr: FlowNodeEntity): FlowNodeEntity[] {\n const currParent = this.getNodeParent(curr);\n\n return (curr.lines?.allOutputNodes || []).filter(\n (_node) => this.getNodeParent(_node) === currParent\n );\n }\n\n /**\n * Gets the dependency scopes for a given scope.\n * @param scope The scope to get dependencies for.\n * @returns An array of dependency scopes.\n */\n getDeps(scope: FlowNodeScope): FlowNodeScope[] {\n const { node } = scope.meta || {};\n if (!node) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const deps: FlowNodeScope[] = [];\n\n // 1. find dep nodes\n let curr: FlowNodeEntity | undefined = node;\n\n while (curr) {\n // 2. private scope of parent node can be access\n const currVarData: FlowNodeVariableData = curr.getData(FlowNodeVariableData);\n if (currVarData?.private && scope !== currVarData.private) {\n deps.unshift(currVarData.private);\n }\n\n // 3. all public scopes of inputNodes\n const allInputNodes: FlowNodeEntity[] = this.getAllInputLayerNodes(curr);\n deps.unshift(\n ...allInputNodes\n .map((_node) => [\n _node.getData(FlowNodeVariableData).public,\n // 4. all public children of inputNodes\n ...this.getAllPublicChildScopes(_node),\n ])\n .flat()\n .filter(Boolean)\n );\n\n curr = this.getNodeParent(curr);\n }\n\n // If scope is GlobalScope, add globalScope to deps\n const globalScope = this.variableEngine.getScopeById(GlobalScope.ID);\n if (globalScope) {\n deps.unshift(globalScope);\n }\n\n const uniqDeps = Array.from(new Set(deps));\n return this.transformService.transformDeps(uniqDeps, { scope });\n }\n\n /**\n * Gets the covering scopes for a given scope.\n * @param scope The scope to get covering scopes for.\n * @returns An array of covering scopes.\n */\n getCovers(scope: FlowNodeScope): FlowNodeScope[] {\n // If scope is GlobalScope, return all scopes except GlobalScope\n if (GlobalScope.is(scope)) {\n const scopes = this.variableEngine\n .getAllScopes({ sort: true })\n .filter((_scope) => !GlobalScope.is(_scope));\n\n return this.transformService.transformCovers(scopes, { scope });\n }\n\n const { node } = scope.meta || {};\n if (!node) {\n return this.transformService.transformCovers([], { scope });\n }\n\n const isPrivate = scope.meta.type === FlowNodeScopeTypeEnum.private;\n\n // 1. BFS to find all covered nodes\n const queue: FlowNodeEntity[] = [];\n\n if (isPrivate) {\n // private can only cover its child nodes\n queue.push(...this.getNodeChildren(node));\n } else {\n // Otherwise, cover all nodes of its output lines\n queue.push(...(this.getAllOutputLayerNodes(node) || []));\n\n // get all parents\n let parent = this.getNodeParent(node);\n\n while (parent) {\n // if childNodes of parent is private to next nodes, break\n if (this.isNodeChildrenPrivate(parent)) {\n break;\n }\n\n queue.push(...this.getAllOutputLayerNodes(parent));\n\n parent = this.getNodeParent(parent);\n }\n }\n\n // 2. Get the public and private scopes of all covered nodes\n const scopes: FlowNodeScope[] = [];\n\n while (queue.length) {\n const _node = queue.shift()!;\n const variableData: FlowNodeVariableData = _node.getData(FlowNodeVariableData);\n scopes.push(...variableData.allScopes);\n const children = _node && this.getNodeChildren(_node);\n\n if (children?.length) {\n queue.push(...children);\n }\n }\n\n // 3. If the current scope is private, the public scope of the current node can also be covered\n const currentVariableData: FlowNodeVariableData = node.getData(FlowNodeVariableData);\n if (isPrivate && currentVariableData.public) {\n scopes.push(currentVariableData.public);\n }\n\n const uniqScopes = Array.from(new Set(scopes));\n\n return this.transformService.transformCovers(uniqScopes, { scope });\n }\n\n /**\n * Gets the children of a node.\n * @param node The node to get children for.\n * @returns An array of child nodes.\n */\n getNodeChildren(node: FlowNodeEntity): FlowNodeEntity[] {\n if (this.configs?.getNodeChildren) {\n return this.configs.getNodeChildren?.(node);\n }\n const nodeMeta = node.getNodeMeta<WorkflowNodeMeta>();\n const subCanvas = nodeMeta.subCanvas?.(node);\n\n if (subCanvas) {\n // The sub-canvas itself does not have children\n if (subCanvas.isCanvas) {\n return [];\n } else {\n return subCanvas.canvasNode.collapsedChildren;\n }\n }\n\n // In some scenarios, the parent-child relationship is expressed through connections, so it needs to be configured at the upper level\n return this.tree.getChildren(node);\n }\n\n /**\n * Get All children of nodes\n * @param node\n * @returns\n */\n getAllPublicChildScopes(node: FlowNodeEntity): Scope[] {\n if (this.isNodeChildrenPrivate(node)) {\n return [];\n }\n\n return this.getNodeChildren(node)\n .map((_node) => [\n _node.getData(FlowNodeVariableData).public,\n ...this.getAllPublicChildScopes(_node),\n ])\n .flat();\n }\n\n /**\n * Gets the parent of a node.\n * @param node The node to get the parent for.\n * @returns The parent node or `undefined` if not found.\n */\n getNodeParent(node: FlowNodeEntity): FlowNodeEntity | undefined {\n // In some scenarios, the parent-child relationship is expressed through connections, so it needs to be configured at the upper level\n if (this.configs?.getNodeParent) {\n return this.configs.getNodeParent(node);\n }\n let parent = node.document.originTree.getParent(node);\n\n // If currentParent is Group, get the parent of parent\n while (parent?.flowNodeType === FlowNodeBaseType.GROUP) {\n parent = parent.parent;\n }\n\n if (!parent) {\n return parent;\n }\n\n const nodeMeta = parent.getNodeMeta<WorkflowNodeMeta>();\n const subCanvas = nodeMeta.subCanvas?.(parent);\n if (subCanvas?.isCanvas) {\n // Get real parent node by subCanvas Configuration\n return subCanvas.parentNode;\n }\n\n return parent;\n }\n\n /**\n * Checks if the children of a node are private and cannot be accessed by subsequent nodes.\n * @param node The node to check.\n * @returns `true` if the children are private, `false` otherwise.\n */\n protected isNodeChildrenPrivate(node?: FlowNodeEntity): boolean {\n if (this.configs?.isNodeChildrenPrivate) {\n return node ? this.configs?.isNodeChildrenPrivate(node) : false;\n }\n\n const isSystemNode = node?.id.startsWith('$');\n\n // Except system node and group node, everything else is private\n return !isSystemNode && node?.flowNodeType !== FlowNodeBaseType.GROUP;\n }\n\n /**\n * Sorts all scopes in the scope chain.\n * @returns An empty array, as this method is not implemented.\n */\n sortAll(): Scope[] {\n // Not implemented yet\n console.warn('FreeLayoutScopeChain.sortAll is not implemented');\n return [];\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { type ScopeChainNode } from './types';\nimport { IScopeTransformer } from './services/scope-chain-transform-service';\n\n/**\n * Configuration for the variable chain.\n */\nexport interface VariableChainConfig {\n /**\n * The output variables of a node's children cannot be accessed by subsequent nodes.\n *\n * @param node\n * @returns\n */\n isNodeChildrenPrivate?: (node: ScopeChainNode) => boolean;\n\n /**\n * For fixed layout scenarios: there are a large number of useless nodes between parent and child (such as inlineBlocks, etc., which need to be configured to be skipped)\n * For free canvas scenarios: in some scenarios, the parent-child relationship between nodes is expressed through connections or other interactive forms, which needs to be configurable\n */\n getNodeChildren?: (node: FlowNodeEntity) => FlowNodeEntity[];\n getNodeParent?: (node: FlowNodeEntity) => FlowNodeEntity | undefined;\n\n /**\n * Fine-tune the dependency scope.\n */\n transformDeps?: IScopeTransformer;\n\n /**\n * Fine-tune the cover scope.\n */\n transformCovers?: IScopeTransformer;\n}\n\nexport const VariableChainConfig = Symbol('VariableChainConfig');\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, injectable, optional } from 'inversify';\nimport { Scope, VariableEngine } from '@flowgram.ai/variable-core';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport { lazyInject } from '@flowgram.ai/core';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope } from '../types';\n\n/**\n * Context for scope transformers.\n */\nexport interface TransformerContext {\n /**\n * The current scope\n */\n scope: FlowNodeScope;\n /**\n * The flow document.\n */\n document: FlowDocument;\n /**\n * The variable engine.\n */\n variableEngine: VariableEngine;\n}\n\n/**\n * A function that transforms an array of scopes.\n * @param scopes The array of scopes to transform.\n * @param ctx The transformer context.\n * @returns The transformed array of scopes.\n */\nexport type IScopeTransformer = (scopes: Scope[], ctx: TransformerContext) => Scope[];\n\nconst passthrough: IScopeTransformer = (scopes, ctx) => scopes;\n\n/**\n * A service for transforming scope chains.\n */\n@injectable()\nexport class ScopeChainTransformService {\n protected transformerMap: Map<\n string,\n { transformDeps: IScopeTransformer; transformCovers: IScopeTransformer }\n > = new Map();\n\n @lazyInject(FlowDocument) document: FlowDocument;\n\n @lazyInject(VariableEngine) variableEngine: VariableEngine;\n\n constructor(\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig\n ) {\n if (this.configs?.transformDeps || this.configs?.transformCovers) {\n this.transformerMap.set('VARIABLE_LAYOUT_CONFIG', {\n transformDeps: this.configs.transformDeps || passthrough,\n transformCovers: this.configs.transformCovers || passthrough,\n });\n }\n }\n\n /**\n * check if transformer registered\n * @param transformerId used to identify transformer, prevent duplicated\n * @returns\n */\n hasTransformer(transformerId: string) {\n return this.transformerMap.has(transformerId);\n }\n\n /**\n * register new transform function\n * @param transformerId used to identify transformer, prevent duplicated transformer\n * @param transformer The transformer to register.\n */\n registerTransformer(\n transformerId: string,\n transformer: {\n transformDeps: IScopeTransformer;\n transformCovers: IScopeTransformer;\n }\n ) {\n this.transformerMap.set(transformerId, transformer);\n }\n\n /**\n * Transforms the dependency scopes.\n * @param scopes The array of scopes to transform.\n * @param param1 The context for the transformation.\n * @returns The transformed array of scopes.\n */\n transformDeps(scopes: Scope[], { scope }: { scope: Scope }): Scope[] {\n return Array.from(this.transformerMap.values()).reduce((scopes, transformer) => {\n if (!transformer.transformDeps) {\n return scopes;\n }\n\n scopes = transformer.transformDeps(scopes, {\n scope,\n document: this.document,\n variableEngine: this.variableEngine,\n });\n return scopes;\n }, scopes);\n }\n\n /**\n * Transforms the cover scopes.\n * @param scopes The array of scopes to transform.\n * @param param1 The context for the transformation.\n * @returns The transformed array of scopes.\n */\n transformCovers(scopes: Scope[], { scope }: { scope: Scope }): Scope[] {\n return Array.from(this.transformerMap.values()).reduce((scopes, transformer) => {\n if (!transformer.transformCovers) {\n return scopes;\n }\n\n scopes = transformer.transformCovers(scopes, {\n scope,\n document: this.document,\n variableEngine: this.variableEngine,\n });\n return scopes;\n }, scopes);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable, interfaces } from 'inversify';\nimport { Scope, VariableEngine } from '@flowgram.ai/variable-core';\n\n/**\n * Global Scope stores all variables that are not scoped to any node.\n *\n * - Variables in Global Scope can be accessed by any node.\n * - Any other scope's variables can not be accessed by Global Scope.\n */\n@injectable()\nexport class GlobalScope extends Scope {\n static readonly ID = Symbol('GlobalScope');\n\n /**\n * Check if the scope is Global Scope.\n * @param scope\n * @returns\n */\n static is(scope: Scope) {\n return scope.id === GlobalScope.ID;\n }\n}\n\nexport const bindGlobalScope = (bind: interfaces.Bind) => {\n bind(GlobalScope).toDynamicValue((ctx) => {\n const variableEngine = ctx.container.get(VariableEngine);\n let scope = variableEngine.getScopeById(GlobalScope.ID) as GlobalScope;\n\n if (!scope) {\n scope = variableEngine.createScope(\n GlobalScope.ID,\n {},\n { ScopeConstructor: GlobalScope }\n ) as GlobalScope;\n variableEngine.chain.refreshAllChange();\n }\n\n return scope;\n });\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, optional } from 'inversify';\nimport { Scope, ScopeChain } from '@flowgram.ai/variable-core';\nimport { FlowDocument, type FlowVirtualTree } from '@flowgram.ai/document';\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { VariableChainConfig } from '../variable-chain-config';\nimport { FlowNodeScope, FlowNodeScopeTypeEnum, ScopeChainNode } from '../types';\nimport { ScopeChainTransformService } from '../services/scope-chain-transform-service';\nimport { GlobalScope } from '../scopes/global-scope';\nimport { FlowNodeVariableData } from '../flow-node-variable-data';\n\n/**\n * Scope chain implementation based on `FlowVirtualTree`.\n */\nexport class FixedLayoutScopeChain extends ScopeChain {\n // By adding { id: string }, custom virtual nodes can be flexibly added\n tree: FlowVirtualTree<ScopeChainNode> | undefined;\n\n @inject(ScopeChainTransformService)\n protected transformService: ScopeChainTransformService;\n\n constructor(\n @inject(FlowDocument)\n protected flowDocument: FlowDocument,\n @optional()\n @inject(VariableChainConfig)\n protected configs?: VariableChainConfig\n ) {\n super();\n\n // Bind the tree in flowDocument\n this.bindTree(flowDocument.originTree);\n\n // When originTree changes, trigger changes in dependencies\n this.toDispose.push(\n // REFRACTOR: onTreeChange trigger timing needs to be refined\n flowDocument.originTree.onTreeChange(() => {\n this.refreshAllChange();\n })\n );\n }\n\n /**\n * Binds the scope chain to a `FlowVirtualTree`.\n * @param tree The `FlowVirtualTree` to bind to.\n */\n bindTree(tree: FlowVirtualTree<ScopeChainNode>): void {\n this.tree = tree;\n }\n\n /**\n * Gets the dependency scopes for a given scope.\n * @param scope The scope to get dependencies for.\n * @returns An array of dependency scopes.\n */\n getDeps(scope: FlowNodeScope): FlowNodeScope[] {\n if (!this.tree) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const node = scope.meta.node;\n if (!node) {\n return this.transformService.transformDeps([], { scope });\n }\n\n const deps: FlowNodeScope[] = [];\n\n let curr: ScopeChainNode | undefined = node;\n\n while (curr) {\n const { parent, pre } = this.tree.getInfo(curr);\n const currData = this.getVariableData(curr);\n\n // Contains child nodes and is not a private scope\n\n if (curr === node) {\n // public can depend on private\n if (scope.meta.type === FlowNodeScopeTypeEnum.public && currData?.private) {\n deps.unshift(currData.private);\n }\n } else if (this.hasChildren(curr) && !this.isNodeChildrenPrivate(curr)) {\n // For nodes with child elements, include the child elements in the dependency scope\n deps.unshift(\n ...this.getAllSortedChildScope(curr, {\n ignoreNodeChildrenPrivate: true,\n })\n );\n }\n\n // The public of the node can be accessed\n if (currData && curr !== node) {\n deps.unshift(currData.public);\n }\n\n // Process the previous node\n if (pre) {\n curr = pre;\n continue;\n }\n\n // Process the parent node\n if (parent) {\n let currParent: ScopeChainNode | undefined = parent;\n let currParentPre: ScopeChainNode | undefined = this.tree.getPre(currParent);\n\n while (currParent) {\n // Both private and public of the parent node can be accessed by child nodes\n const currParentData = this.getVariableData(currParent);\n if (currParentData) {\n deps.unshift(...currParentData.allScopes);\n }\n\n // If the current parent has a pre node, stop searching upwards\n if (currParentPre) {\n break;\n }\n\n currParent = this.tree.getParent(currParent);\n currParentPre = currParent ? this.tree.getPre(currParent) : undefined;\n }\n curr = currParentPre;\n continue;\n }\n\n // If there is no next and no parent, end the loop directly\n curr = undefined;\n }\n\n // If scope is GlobalScope, add globalScope to deps\n const globalScope = this.variableEngine.getScopeById(GlobalScope.ID);\n if (globalScope) {\n deps.unshift(globalScope);\n }\n\n return this.transformService.transformDeps(deps, { scope });\n }\n\n /**\n * Gets the covering scopes for a given scope.\n * @param scope The scope to get covering scopes for.\n * @returns An array of covering scopes.\n */\n getCovers(scope: FlowNodeScope): FlowNodeScope[] {\n if (!this.tree) {\n return this.transformService.transformCovers([], { scope });\n }\n\n // If scope is GlobalScope, return all scopes except GlobalScope\n if (GlobalScope.is(scope)) {\n const scopes = this.variableEngine\n .getAllScopes({ sort: true })\n .filter((_scope) => !GlobalScope.is(_scope));\n\n return this.transformService.transformCovers(scopes, { scope });\n }\n\n const node = scope.meta.node;\n if (!node) {\n return this.transformService.transformCovers([], { scope });\n }\n\n const covers: FlowNodeScope[] = [];\n\n // If it is a private scope, only child nodes can access it\n if (scope.meta.type === FlowNodeScopeTypeEnum.private) {\n covers.push(\n ...this.getAllSortedChildScope(node, {\n addNodePrivateScope: true,\n }).filter((_scope) => _scope !== scope)\n );\n return this.transformService.transformCovers(covers, { scope });\n }\n\n let curr: ScopeChainNode | undefined = node;\n\n while (curr) {\n const { next, parent } = this.tree.getInfo(curr);\n const currData = this.getVariableData(curr);\n\n // For nodes with child elements, include the child elements in the covering scope\n if (curr !== node) {\n if (this.hasChildren(curr)) {\n covers.push(\n ...this.getAllSortedChildScope(curr, {\n addNodePrivateScope: true,\n })\n );\n } else if (currData) {\n covers.push(...currData.allScopes);\n }\n }\n\n // Process the next node\n if (next) {\n curr = next;\n continue;\n }\n\n if (parent) {\n let currParent: ScopeChainNode | undefined = parent;\n let currParentNext: ScopeChainNode | undefined = this.tree.getNext(currParent);\n\n while (currParent) {\n // Private scopes cannot be accessed by subsequent nodes\n if (this.isNodeChildrenPrivate(currParent)) {\n return this.transformService.transformCovers(covers, { scope });\n }\n\n // If the current parent has a next node, stop searching upwards\n if (currParentNext) {\n break;\n }\n\n currParent = this.tree.getParent(currParent);\n currParentNext = currParent ? this.tree.getNext(currParent) : undefined;\n }\n if (!currParentNext && currParent) {\n break;\n }\n\n curr = currParentNext;\n continue;\n }\n\n // next 和 parent 都没有,直接结束循环\n curr = undefined;\n }\n\n return this.transformService.transformCovers(covers, { scope });\n }\n\n /**\n * Sorts all scopes in the scope chain.\n * @returns A sorted array of all scopes.\n */\n sortAll(): Scope[] {\n const startNode = this.flowDocument.getAllNodes().find((_node) => _node.isStart);\n if (!startNode) {\n return [];\n }\n\n const startVariableData = startNode.getData(FlowNodeVariableData);\n const startPublicScope = startVariableData.public;\n const deps = this.getDeps(startPublicScope);\n\n const covers = this.getCovers(startPublicScope).filter(\n (_scope) => !deps.includes(_scope) && _scope !== startPublicScope\n );\n\n return [...deps, startPublicScope, ...covers];\n }\n\n /**\n * Gets the `FlowNodeVariableData` for a given `ScopeChainNode`.\n * @param node The `ScopeChainNode` to get data for.\n * @returns The `FlowNodeVariableData` or `undefined` if not found.\n */\n private getVariableData(node: ScopeChainNode): FlowNodeVariableData | undefined {\n if (node.flowNodeType === 'virtualNode') {\n return;\n }\n // TODO Nodes containing $ do not register variableData\n if (node.id.startsWith('$')) {\n return;\n }\n\n return (node as FlowNodeEntity).getData(FlowNodeVariableData);\n }\n\n /**\n * Checks if the children of a node are private.\n * @param node The node to check.\n * @returns `true` if the children are private, `false` otherwise.\n */\n private isNodeChildrenPrivate(node?: ScopeChainNode): boolean {\n if (this.configs?.isNodeChildrenPrivate) {\n return node ? this.configs?.isNodeChildrenPrivate(node) : false;\n }\n\n const isSystemNode = node?.id.startsWith('$');\n // Fallback: all nodes with children (node id does not start with $) are private scopes\n return !isSystemNode && this.hasChildren(node);\n }\n\n /**\n * Checks if a node has children.\n * @param node The node to check.\n * @returns `true` if the node has children, `false` otherwise.\n */\n private hasChildren(node?: ScopeChainNode): boolean {\n return Boolean(this.tree && node && this.tree.getChildren(node).length > 0);\n }\n\n /**\n * Gets all sorted child scopes of a node.\n * @param node The node to get child scopes for.\n * @param options Options for getting child scopes.\n * @returns An array of sorted child scopes.\n */\n private getAllSortedChildScope(\n node: ScopeChainNode,\n {\n ignoreNodeChildrenPrivate,\n addNodePrivateScope,\n }: { ignoreNodeChildrenPrivate?: boolean; addNodePrivateScope?: boolean } = {}\n ): FlowNodeScope[] {\n const scopes: FlowNodeScope[] = [];\n\n const variableData = this.getVariableData(node);\n\n if (variableData) {\n scopes.push(variableData.public);\n }\n\n // For private scopes, the variables of child nodes are not exposed externally\n // (If the parent node has public variables, they are exposed externally)\n if (ignoreNodeChildrenPrivate && this.isNodeChildrenPrivate(node)) {\n return scopes;\n }\n\n if (addNodePrivateScope && variableData?.private) {\n scopes.push(variableData.private);\n }\n\n const children = this.tree?.getChildren(node) || [];\n scopes.push(\n ...children\n .map((child) =>\n this.getAllSortedChildScope(child, { ignoreNodeChildrenPrivate, addNodePrivateScope })\n )\n .flat()\n );\n\n return scopes;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FlowNodeEntity } from '@flowgram.ai/document';\n\nimport { FlowNodeVariableData } from './flow-node-variable-data';\n\n/**\n * Use `node.scope` instead.\n * @deprecated\n * @param node The flow node entity.\n * @returns The public scope of the node.\n */\nexport function getNodeScope(node: FlowNodeEntity) {\n return node.getData(FlowNodeVariableData).public;\n}\n\n/**\n * Use `node.privateScope` instead.\n * @deprecated\n * @param node The flow node entity.\n * @returns The private scope of the node.\n */\nexport function getNodePrivateScope(node: FlowNodeEntity) {\n return node.getData(FlowNodeVariableData).initPrivate();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQA,kBAA2B;;;ACGpB,IAAK,wBAAL,kBAAKA,2BAAL;AAIL,EAAAA,uBAAA,YAAS;AAIT,EAAAA,uBAAA,aAAU;AARA,SAAAA;AAAA,GAAA;;;ADQL,IAAM,uBAAN,cAAmC,uBAAW;AAAA,EAkJnD,YAAY,QAAiC,MAAe;AAC1D,UAAM,MAAM;AAD+B;AAG3C,UAAM,EAAE,eAAe,IAAI,QAAQ,CAAC;AACpC,SAAK,iBAAiB;AACtB,SAAK,UAAU,KA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O,KAAK,aAAa,OAAO;AAAA,IAClC;AAEA,UAAM,WAAW,KAAK,MAAM,YAAY,IAAI,KAAK,CAAC;AAClD,WAAO;AAAA,MACL,GAAG,SACA;AAAA,QAAI,CAAC,UACJ,KAAK,uBAAuB,OAAO,EAAE,2BAA2B,oBAAoB,CAAC;AAAA,MACvF,EACC,KAAK;AAAA,IACV;AAEA,WAAO;AAAA,EACT;AACF;AA5TY;AAAA,MADT,0BAAO,0BAA0B;AAAA,GAJvB,sBAKD;AALC,wBAAN;AAAA,EAQF,iDAAO,6BAAY;AAAA,EAEnB,mDAAS;AAAA,EACT,iDAAO,mBAAmB;AAAA,GAXlB;;;ACJN,SAAS,aAAa,MAAsB;AACjD,SAAO,KAAK,QAAQ,oBAAoB,EAAE;AAC5C;AAQO,SAAS,oBAAoB,MAAsB;AACxD,SAAO,KAAK,QAAQ,oBAAoB,EAAE,YAAY;AACxD;","names":["FlowNodeScopeTypeEnum","import_inversify","import_variable_core","import_document","import_core","import_core","scopes","import_inversify","import_variable_core","scopes","import_inversify","import_variable_core","import_document"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/variable-layout",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -18,10 +18,10 @@
18
18
  "dependencies": {
19
19
  "inversify": "^6.0.1",
20
20
  "reflect-metadata": "~0.2.2",
21
- "@flowgram.ai/core": "0.5.4",
22
- "@flowgram.ai/document": "0.5.4",
23
- "@flowgram.ai/free-layout-core": "0.5.4",
24
- "@flowgram.ai/variable-core": "0.5.4"
21
+ "@flowgram.ai/core": "0.5.6",
22
+ "@flowgram.ai/free-layout-core": "0.5.6",
23
+ "@flowgram.ai/document": "0.5.6",
24
+ "@flowgram.ai/variable-core": "0.5.6"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@vitest/coverage-v8": "^3.2.4",
@@ -29,8 +29,8 @@
29
29
  "tsup": "^8.0.1",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@flowgram.ai/eslint-config": "0.5.4",
33
- "@flowgram.ai/ts-config": "0.5.4"
32
+ "@flowgram.ai/eslint-config": "0.5.6",
33
+ "@flowgram.ai/ts-config": "0.5.6"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public",