@flowgram.ai/variable-layout 0.5.5 → 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/esm/index.js +116 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +189 -9
- package/dist/index.d.ts +189 -9
- package/dist/index.js +116 -14
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -8,19 +8,52 @@ import { interfaces } from 'inversify';
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Enum for flow node scope types.
|
|
13
|
+
*/
|
|
11
14
|
declare enum FlowNodeScopeTypeEnum {
|
|
15
|
+
/**
|
|
16
|
+
* Public scope.
|
|
17
|
+
*/
|
|
12
18
|
public = "public",
|
|
19
|
+
/**
|
|
20
|
+
* Private scope.
|
|
21
|
+
*/
|
|
13
22
|
private = "private"
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Metadata for a flow node scope.
|
|
26
|
+
*/
|
|
15
27
|
interface FlowNodeScopeMeta {
|
|
28
|
+
/**
|
|
29
|
+
* The flow node entity associated with the scope.
|
|
30
|
+
*/
|
|
16
31
|
node?: FlowNodeEntity;
|
|
32
|
+
/**
|
|
33
|
+
* The type of the scope.
|
|
34
|
+
*/
|
|
17
35
|
type?: FlowNodeScopeTypeEnum;
|
|
18
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents a virtual node in the scope chain.
|
|
39
|
+
*/
|
|
19
40
|
interface ScopeVirtualNode {
|
|
41
|
+
/**
|
|
42
|
+
* The ID of the virtual node.
|
|
43
|
+
*/
|
|
20
44
|
id: string;
|
|
45
|
+
/**
|
|
46
|
+
* The type of the flow node.
|
|
47
|
+
*/
|
|
21
48
|
flowNodeType: 'virtualNode';
|
|
22
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a node in the scope chain, which can be either a flow node entity or a virtual node.
|
|
52
|
+
*/
|
|
23
53
|
type ScopeChainNode = FlowNodeEntity | ScopeVirtualNode;
|
|
54
|
+
/**
|
|
55
|
+
* Represents a scope associated with a flow node.
|
|
56
|
+
*/
|
|
24
57
|
interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {
|
|
25
58
|
}
|
|
26
59
|
|
|
@@ -32,6 +65,9 @@ interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {
|
|
|
32
65
|
interface Options {
|
|
33
66
|
variableEngine: VariableEngine;
|
|
34
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Manages variable data for a flow node, including public and private scopes.
|
|
70
|
+
*/
|
|
35
71
|
declare class FlowNodeVariableData extends EntityData {
|
|
36
72
|
readonly opts: Options;
|
|
37
73
|
static type: string;
|
|
@@ -42,7 +78,13 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
42
78
|
*/
|
|
43
79
|
protected _private?: FlowNodeScope;
|
|
44
80
|
protected _public: FlowNodeScope;
|
|
81
|
+
/**
|
|
82
|
+
* The private scope of the node.
|
|
83
|
+
*/
|
|
45
84
|
get private(): FlowNodeScope | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The public scope of the node.
|
|
87
|
+
*/
|
|
46
88
|
get public(): FlowNodeScope;
|
|
47
89
|
/**
|
|
48
90
|
* Sets a variable in the public AST (Abstract Syntax Tree) with the given key and JSON value.
|
|
@@ -102,9 +144,17 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
102
144
|
* @returns The updated AST node.
|
|
103
145
|
*/
|
|
104
146
|
clearPrivateVar(key?: string): void | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* An array containing all scopes (public and private) of the node.
|
|
149
|
+
*/
|
|
105
150
|
get allScopes(): FlowNodeScope[];
|
|
106
151
|
getDefaultData(): {};
|
|
107
152
|
constructor(entity: FlowNodeEntity, opts: Options);
|
|
153
|
+
/**
|
|
154
|
+
* Initializes and returns the private scope for the node.
|
|
155
|
+
* If the private scope already exists, it returns the existing one.
|
|
156
|
+
* @returns The private scope of the node.
|
|
157
|
+
*/
|
|
108
158
|
initPrivate(): FlowNodeScope;
|
|
109
159
|
/**
|
|
110
160
|
* Find a variable field by key path in the public scope by scope chain.
|
|
@@ -125,12 +175,33 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
125
175
|
* SPDX-License-Identifier: MIT
|
|
126
176
|
*/
|
|
127
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Context for scope transformers.
|
|
180
|
+
*/
|
|
128
181
|
interface TransformerContext {
|
|
182
|
+
/**
|
|
183
|
+
* The current scope
|
|
184
|
+
*/
|
|
129
185
|
scope: FlowNodeScope;
|
|
186
|
+
/**
|
|
187
|
+
* The flow document.
|
|
188
|
+
*/
|
|
130
189
|
document: FlowDocument;
|
|
190
|
+
/**
|
|
191
|
+
* The variable engine.
|
|
192
|
+
*/
|
|
131
193
|
variableEngine: VariableEngine;
|
|
132
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* A function that transforms an array of scopes.
|
|
197
|
+
* @param scopes The array of scopes to transform.
|
|
198
|
+
* @param ctx The transformer context.
|
|
199
|
+
* @returns The transformed array of scopes.
|
|
200
|
+
*/
|
|
133
201
|
type IScopeTransformer = (scopes: Scope[], ctx: TransformerContext) => Scope[];
|
|
202
|
+
/**
|
|
203
|
+
* A service for transforming scope chains.
|
|
204
|
+
*/
|
|
134
205
|
declare class ScopeChainTransformService {
|
|
135
206
|
protected configs?: VariableChainConfig | undefined;
|
|
136
207
|
protected transformerMap: Map<string, {
|
|
@@ -149,15 +220,27 @@ declare class ScopeChainTransformService {
|
|
|
149
220
|
/**
|
|
150
221
|
* register new transform function
|
|
151
222
|
* @param transformerId used to identify transformer, prevent duplicated transformer
|
|
152
|
-
* @param transformer
|
|
223
|
+
* @param transformer The transformer to register.
|
|
153
224
|
*/
|
|
154
225
|
registerTransformer(transformerId: string, transformer: {
|
|
155
226
|
transformDeps: IScopeTransformer;
|
|
156
227
|
transformCovers: IScopeTransformer;
|
|
157
228
|
}): void;
|
|
229
|
+
/**
|
|
230
|
+
* Transforms the dependency scopes.
|
|
231
|
+
* @param scopes The array of scopes to transform.
|
|
232
|
+
* @param param1 The context for the transformation.
|
|
233
|
+
* @returns The transformed array of scopes.
|
|
234
|
+
*/
|
|
158
235
|
transformDeps(scopes: Scope[], { scope }: {
|
|
159
236
|
scope: Scope;
|
|
160
237
|
}): Scope[];
|
|
238
|
+
/**
|
|
239
|
+
* Transforms the cover scopes.
|
|
240
|
+
* @param scopes The array of scopes to transform.
|
|
241
|
+
* @param param1 The context for the transformation.
|
|
242
|
+
* @returns The transformed array of scopes.
|
|
243
|
+
*/
|
|
161
244
|
transformCovers(scopes: Scope[], { scope }: {
|
|
162
245
|
scope: Scope;
|
|
163
246
|
}): Scope[];
|
|
@@ -168,6 +251,9 @@ declare class ScopeChainTransformService {
|
|
|
168
251
|
* SPDX-License-Identifier: MIT
|
|
169
252
|
*/
|
|
170
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Configuration for the variable chain.
|
|
256
|
+
*/
|
|
171
257
|
interface VariableChainConfig {
|
|
172
258
|
/**
|
|
173
259
|
* The output variables of a node's children cannot be accessed by subsequent nodes.
|
|
@@ -183,11 +269,11 @@ interface VariableChainConfig {
|
|
|
183
269
|
getNodeChildren?: (node: FlowNodeEntity) => FlowNodeEntity[];
|
|
184
270
|
getNodeParent?: (node: FlowNodeEntity) => FlowNodeEntity | undefined;
|
|
185
271
|
/**
|
|
186
|
-
* Fine-tune the dependency scope
|
|
272
|
+
* Fine-tune the dependency scope.
|
|
187
273
|
*/
|
|
188
274
|
transformDeps?: IScopeTransformer;
|
|
189
275
|
/**
|
|
190
|
-
*
|
|
276
|
+
* Fine-tune the cover scope.
|
|
191
277
|
*/
|
|
192
278
|
transformCovers?: IScopeTransformer;
|
|
193
279
|
}
|
|
@@ -199,19 +285,47 @@ declare const VariableChainConfig: unique symbol;
|
|
|
199
285
|
*/
|
|
200
286
|
|
|
201
287
|
/**
|
|
202
|
-
*
|
|
288
|
+
* Scope chain implementation for free layout.
|
|
203
289
|
*/
|
|
204
290
|
declare class FreeLayoutScopeChain extends ScopeChain {
|
|
205
291
|
entityManager: EntityManager;
|
|
206
292
|
protected flowDocument: FlowDocument;
|
|
207
293
|
protected configs?: VariableChainConfig;
|
|
208
294
|
protected transformService: ScopeChainTransformService;
|
|
295
|
+
/**
|
|
296
|
+
* The virtual tree of the flow document.
|
|
297
|
+
*/
|
|
209
298
|
get tree(): FlowVirtualTree<FlowNodeEntity>;
|
|
210
299
|
onInit(): void;
|
|
300
|
+
/**
|
|
301
|
+
* Gets all input layer nodes for a given node in the same layer, sorted by distance.
|
|
302
|
+
* @param node The node to get input layer nodes for.
|
|
303
|
+
* @returns An array of input layer nodes.
|
|
304
|
+
*/
|
|
211
305
|
protected getAllInputLayerNodes(node: FlowNodeEntity): FlowNodeEntity[];
|
|
306
|
+
/**
|
|
307
|
+
* Gets all output layer nodes for a given node in the same layer.
|
|
308
|
+
* @param curr The node to get output layer nodes for.
|
|
309
|
+
* @returns An array of output layer nodes.
|
|
310
|
+
*/
|
|
212
311
|
protected getAllOutputLayerNodes(curr: FlowNodeEntity): FlowNodeEntity[];
|
|
312
|
+
/**
|
|
313
|
+
* Gets the dependency scopes for a given scope.
|
|
314
|
+
* @param scope The scope to get dependencies for.
|
|
315
|
+
* @returns An array of dependency scopes.
|
|
316
|
+
*/
|
|
213
317
|
getDeps(scope: FlowNodeScope): FlowNodeScope[];
|
|
318
|
+
/**
|
|
319
|
+
* Gets the covering scopes for a given scope.
|
|
320
|
+
* @param scope The scope to get covering scopes for.
|
|
321
|
+
* @returns An array of covering scopes.
|
|
322
|
+
*/
|
|
214
323
|
getCovers(scope: FlowNodeScope): FlowNodeScope[];
|
|
324
|
+
/**
|
|
325
|
+
* Gets the children of a node.
|
|
326
|
+
* @param node The node to get children for.
|
|
327
|
+
* @returns An array of child nodes.
|
|
328
|
+
*/
|
|
215
329
|
getNodeChildren(node: FlowNodeEntity): FlowNodeEntity[];
|
|
216
330
|
/**
|
|
217
331
|
* Get All children of nodes
|
|
@@ -219,8 +333,22 @@ declare class FreeLayoutScopeChain extends ScopeChain {
|
|
|
219
333
|
* @returns
|
|
220
334
|
*/
|
|
221
335
|
getAllPublicChildScopes(node: FlowNodeEntity): Scope[];
|
|
336
|
+
/**
|
|
337
|
+
* Gets the parent of a node.
|
|
338
|
+
* @param node The node to get the parent for.
|
|
339
|
+
* @returns The parent node or `undefined` if not found.
|
|
340
|
+
*/
|
|
222
341
|
getNodeParent(node: FlowNodeEntity): FlowNodeEntity | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* Checks if the children of a node are private and cannot be accessed by subsequent nodes.
|
|
344
|
+
* @param node The node to check.
|
|
345
|
+
* @returns `true` if the children are private, `false` otherwise.
|
|
346
|
+
*/
|
|
223
347
|
protected isNodeChildrenPrivate(node?: FlowNodeEntity): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Sorts all scopes in the scope chain.
|
|
350
|
+
* @returns An empty array, as this method is not implemented.
|
|
351
|
+
*/
|
|
224
352
|
sortAll(): Scope[];
|
|
225
353
|
}
|
|
226
354
|
|
|
@@ -230,7 +358,7 @@ declare class FreeLayoutScopeChain extends ScopeChain {
|
|
|
230
358
|
*/
|
|
231
359
|
|
|
232
360
|
/**
|
|
233
|
-
*
|
|
361
|
+
* Scope chain implementation based on `FlowVirtualTree`.
|
|
234
362
|
*/
|
|
235
363
|
declare class FixedLayoutScopeChain extends ScopeChain {
|
|
236
364
|
protected flowDocument: FlowDocument;
|
|
@@ -238,13 +366,52 @@ declare class FixedLayoutScopeChain extends ScopeChain {
|
|
|
238
366
|
tree: FlowVirtualTree<ScopeChainNode> | undefined;
|
|
239
367
|
protected transformService: ScopeChainTransformService;
|
|
240
368
|
constructor(flowDocument: FlowDocument, configs?: VariableChainConfig | undefined);
|
|
369
|
+
/**
|
|
370
|
+
* Binds the scope chain to a `FlowVirtualTree`.
|
|
371
|
+
* @param tree The `FlowVirtualTree` to bind to.
|
|
372
|
+
*/
|
|
241
373
|
bindTree(tree: FlowVirtualTree<ScopeChainNode>): void;
|
|
374
|
+
/**
|
|
375
|
+
* Gets the dependency scopes for a given scope.
|
|
376
|
+
* @param scope The scope to get dependencies for.
|
|
377
|
+
* @returns An array of dependency scopes.
|
|
378
|
+
*/
|
|
242
379
|
getDeps(scope: FlowNodeScope): FlowNodeScope[];
|
|
380
|
+
/**
|
|
381
|
+
* Gets the covering scopes for a given scope.
|
|
382
|
+
* @param scope The scope to get covering scopes for.
|
|
383
|
+
* @returns An array of covering scopes.
|
|
384
|
+
*/
|
|
243
385
|
getCovers(scope: FlowNodeScope): FlowNodeScope[];
|
|
386
|
+
/**
|
|
387
|
+
* Sorts all scopes in the scope chain.
|
|
388
|
+
* @returns A sorted array of all scopes.
|
|
389
|
+
*/
|
|
244
390
|
sortAll(): Scope[];
|
|
391
|
+
/**
|
|
392
|
+
* Gets the `FlowNodeVariableData` for a given `ScopeChainNode`.
|
|
393
|
+
* @param node The `ScopeChainNode` to get data for.
|
|
394
|
+
* @returns The `FlowNodeVariableData` or `undefined` if not found.
|
|
395
|
+
*/
|
|
245
396
|
private getVariableData;
|
|
397
|
+
/**
|
|
398
|
+
* Checks if the children of a node are private.
|
|
399
|
+
* @param node The node to check.
|
|
400
|
+
* @returns `true` if the children are private, `false` otherwise.
|
|
401
|
+
*/
|
|
246
402
|
private isNodeChildrenPrivate;
|
|
403
|
+
/**
|
|
404
|
+
* Checks if a node has children.
|
|
405
|
+
* @param node The node to check.
|
|
406
|
+
* @returns `true` if the node has children, `false` otherwise.
|
|
407
|
+
*/
|
|
247
408
|
private hasChildren;
|
|
409
|
+
/**
|
|
410
|
+
* Gets all sorted child scopes of a node.
|
|
411
|
+
* @param node The node to get child scopes for.
|
|
412
|
+
* @param options Options for getting child scopes.
|
|
413
|
+
* @returns An array of sorted child scopes.
|
|
414
|
+
*/
|
|
248
415
|
private getAllSortedChildScope;
|
|
249
416
|
}
|
|
250
417
|
|
|
@@ -253,22 +420,35 @@ declare class FixedLayoutScopeChain extends ScopeChain {
|
|
|
253
420
|
* SPDX-License-Identifier: MIT
|
|
254
421
|
*/
|
|
255
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Global Scope stores all variables that are not scoped to any node.
|
|
425
|
+
*
|
|
426
|
+
* - Variables in Global Scope can be accessed by any node.
|
|
427
|
+
* - Any other scope's variables can not be accessed by Global Scope.
|
|
428
|
+
*/
|
|
256
429
|
declare class GlobalScope extends Scope {
|
|
257
430
|
static readonly ID: unique symbol;
|
|
431
|
+
/**
|
|
432
|
+
* Check if the scope is Global Scope.
|
|
433
|
+
* @param scope
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
258
436
|
static is(scope: Scope): boolean;
|
|
259
437
|
}
|
|
260
438
|
declare const bindGlobalScope: (bind: interfaces.Bind) => void;
|
|
261
439
|
|
|
262
440
|
/**
|
|
263
|
-
* Use `node.scope` instead
|
|
441
|
+
* Use `node.scope` instead.
|
|
264
442
|
* @deprecated
|
|
265
|
-
* @param node
|
|
443
|
+
* @param node The flow node entity.
|
|
444
|
+
* @returns The public scope of the node.
|
|
266
445
|
*/
|
|
267
446
|
declare function getNodeScope(node: FlowNodeEntity): FlowNodeScope;
|
|
268
447
|
/**
|
|
269
|
-
* Use `node.privateScope` instead
|
|
448
|
+
* Use `node.privateScope` instead.
|
|
270
449
|
* @deprecated
|
|
271
|
-
* @param node
|
|
450
|
+
* @param node The flow node entity.
|
|
451
|
+
* @returns The private scope of the node.
|
|
272
452
|
*/
|
|
273
453
|
declare function getNodePrivateScope(node: FlowNodeEntity): FlowNodeScope;
|
|
274
454
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,19 +8,52 @@ import { interfaces } from 'inversify';
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Enum for flow node scope types.
|
|
13
|
+
*/
|
|
11
14
|
declare enum FlowNodeScopeTypeEnum {
|
|
15
|
+
/**
|
|
16
|
+
* Public scope.
|
|
17
|
+
*/
|
|
12
18
|
public = "public",
|
|
19
|
+
/**
|
|
20
|
+
* Private scope.
|
|
21
|
+
*/
|
|
13
22
|
private = "private"
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Metadata for a flow node scope.
|
|
26
|
+
*/
|
|
15
27
|
interface FlowNodeScopeMeta {
|
|
28
|
+
/**
|
|
29
|
+
* The flow node entity associated with the scope.
|
|
30
|
+
*/
|
|
16
31
|
node?: FlowNodeEntity;
|
|
32
|
+
/**
|
|
33
|
+
* The type of the scope.
|
|
34
|
+
*/
|
|
17
35
|
type?: FlowNodeScopeTypeEnum;
|
|
18
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents a virtual node in the scope chain.
|
|
39
|
+
*/
|
|
19
40
|
interface ScopeVirtualNode {
|
|
41
|
+
/**
|
|
42
|
+
* The ID of the virtual node.
|
|
43
|
+
*/
|
|
20
44
|
id: string;
|
|
45
|
+
/**
|
|
46
|
+
* The type of the flow node.
|
|
47
|
+
*/
|
|
21
48
|
flowNodeType: 'virtualNode';
|
|
22
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a node in the scope chain, which can be either a flow node entity or a virtual node.
|
|
52
|
+
*/
|
|
23
53
|
type ScopeChainNode = FlowNodeEntity | ScopeVirtualNode;
|
|
54
|
+
/**
|
|
55
|
+
* Represents a scope associated with a flow node.
|
|
56
|
+
*/
|
|
24
57
|
interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {
|
|
25
58
|
}
|
|
26
59
|
|
|
@@ -32,6 +65,9 @@ interface FlowNodeScope extends Scope<FlowNodeScopeMeta> {
|
|
|
32
65
|
interface Options {
|
|
33
66
|
variableEngine: VariableEngine;
|
|
34
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Manages variable data for a flow node, including public and private scopes.
|
|
70
|
+
*/
|
|
35
71
|
declare class FlowNodeVariableData extends EntityData {
|
|
36
72
|
readonly opts: Options;
|
|
37
73
|
static type: string;
|
|
@@ -42,7 +78,13 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
42
78
|
*/
|
|
43
79
|
protected _private?: FlowNodeScope;
|
|
44
80
|
protected _public: FlowNodeScope;
|
|
81
|
+
/**
|
|
82
|
+
* The private scope of the node.
|
|
83
|
+
*/
|
|
45
84
|
get private(): FlowNodeScope | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The public scope of the node.
|
|
87
|
+
*/
|
|
46
88
|
get public(): FlowNodeScope;
|
|
47
89
|
/**
|
|
48
90
|
* Sets a variable in the public AST (Abstract Syntax Tree) with the given key and JSON value.
|
|
@@ -102,9 +144,17 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
102
144
|
* @returns The updated AST node.
|
|
103
145
|
*/
|
|
104
146
|
clearPrivateVar(key?: string): void | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* An array containing all scopes (public and private) of the node.
|
|
149
|
+
*/
|
|
105
150
|
get allScopes(): FlowNodeScope[];
|
|
106
151
|
getDefaultData(): {};
|
|
107
152
|
constructor(entity: FlowNodeEntity, opts: Options);
|
|
153
|
+
/**
|
|
154
|
+
* Initializes and returns the private scope for the node.
|
|
155
|
+
* If the private scope already exists, it returns the existing one.
|
|
156
|
+
* @returns The private scope of the node.
|
|
157
|
+
*/
|
|
108
158
|
initPrivate(): FlowNodeScope;
|
|
109
159
|
/**
|
|
110
160
|
* Find a variable field by key path in the public scope by scope chain.
|
|
@@ -125,12 +175,33 @@ declare class FlowNodeVariableData extends EntityData {
|
|
|
125
175
|
* SPDX-License-Identifier: MIT
|
|
126
176
|
*/
|
|
127
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Context for scope transformers.
|
|
180
|
+
*/
|
|
128
181
|
interface TransformerContext {
|
|
182
|
+
/**
|
|
183
|
+
* The current scope
|
|
184
|
+
*/
|
|
129
185
|
scope: FlowNodeScope;
|
|
186
|
+
/**
|
|
187
|
+
* The flow document.
|
|
188
|
+
*/
|
|
130
189
|
document: FlowDocument;
|
|
190
|
+
/**
|
|
191
|
+
* The variable engine.
|
|
192
|
+
*/
|
|
131
193
|
variableEngine: VariableEngine;
|
|
132
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* A function that transforms an array of scopes.
|
|
197
|
+
* @param scopes The array of scopes to transform.
|
|
198
|
+
* @param ctx The transformer context.
|
|
199
|
+
* @returns The transformed array of scopes.
|
|
200
|
+
*/
|
|
133
201
|
type IScopeTransformer = (scopes: Scope[], ctx: TransformerContext) => Scope[];
|
|
202
|
+
/**
|
|
203
|
+
* A service for transforming scope chains.
|
|
204
|
+
*/
|
|
134
205
|
declare class ScopeChainTransformService {
|
|
135
206
|
protected configs?: VariableChainConfig | undefined;
|
|
136
207
|
protected transformerMap: Map<string, {
|
|
@@ -149,15 +220,27 @@ declare class ScopeChainTransformService {
|
|
|
149
220
|
/**
|
|
150
221
|
* register new transform function
|
|
151
222
|
* @param transformerId used to identify transformer, prevent duplicated transformer
|
|
152
|
-
* @param transformer
|
|
223
|
+
* @param transformer The transformer to register.
|
|
153
224
|
*/
|
|
154
225
|
registerTransformer(transformerId: string, transformer: {
|
|
155
226
|
transformDeps: IScopeTransformer;
|
|
156
227
|
transformCovers: IScopeTransformer;
|
|
157
228
|
}): void;
|
|
229
|
+
/**
|
|
230
|
+
* Transforms the dependency scopes.
|
|
231
|
+
* @param scopes The array of scopes to transform.
|
|
232
|
+
* @param param1 The context for the transformation.
|
|
233
|
+
* @returns The transformed array of scopes.
|
|
234
|
+
*/
|
|
158
235
|
transformDeps(scopes: Scope[], { scope }: {
|
|
159
236
|
scope: Scope;
|
|
160
237
|
}): Scope[];
|
|
238
|
+
/**
|
|
239
|
+
* Transforms the cover scopes.
|
|
240
|
+
* @param scopes The array of scopes to transform.
|
|
241
|
+
* @param param1 The context for the transformation.
|
|
242
|
+
* @returns The transformed array of scopes.
|
|
243
|
+
*/
|
|
161
244
|
transformCovers(scopes: Scope[], { scope }: {
|
|
162
245
|
scope: Scope;
|
|
163
246
|
}): Scope[];
|
|
@@ -168,6 +251,9 @@ declare class ScopeChainTransformService {
|
|
|
168
251
|
* SPDX-License-Identifier: MIT
|
|
169
252
|
*/
|
|
170
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Configuration for the variable chain.
|
|
256
|
+
*/
|
|
171
257
|
interface VariableChainConfig {
|
|
172
258
|
/**
|
|
173
259
|
* The output variables of a node's children cannot be accessed by subsequent nodes.
|
|
@@ -183,11 +269,11 @@ interface VariableChainConfig {
|
|
|
183
269
|
getNodeChildren?: (node: FlowNodeEntity) => FlowNodeEntity[];
|
|
184
270
|
getNodeParent?: (node: FlowNodeEntity) => FlowNodeEntity | undefined;
|
|
185
271
|
/**
|
|
186
|
-
* Fine-tune the dependency scope
|
|
272
|
+
* Fine-tune the dependency scope.
|
|
187
273
|
*/
|
|
188
274
|
transformDeps?: IScopeTransformer;
|
|
189
275
|
/**
|
|
190
|
-
*
|
|
276
|
+
* Fine-tune the cover scope.
|
|
191
277
|
*/
|
|
192
278
|
transformCovers?: IScopeTransformer;
|
|
193
279
|
}
|
|
@@ -199,19 +285,47 @@ declare const VariableChainConfig: unique symbol;
|
|
|
199
285
|
*/
|
|
200
286
|
|
|
201
287
|
/**
|
|
202
|
-
*
|
|
288
|
+
* Scope chain implementation for free layout.
|
|
203
289
|
*/
|
|
204
290
|
declare class FreeLayoutScopeChain extends ScopeChain {
|
|
205
291
|
entityManager: EntityManager;
|
|
206
292
|
protected flowDocument: FlowDocument;
|
|
207
293
|
protected configs?: VariableChainConfig;
|
|
208
294
|
protected transformService: ScopeChainTransformService;
|
|
295
|
+
/**
|
|
296
|
+
* The virtual tree of the flow document.
|
|
297
|
+
*/
|
|
209
298
|
get tree(): FlowVirtualTree<FlowNodeEntity>;
|
|
210
299
|
onInit(): void;
|
|
300
|
+
/**
|
|
301
|
+
* Gets all input layer nodes for a given node in the same layer, sorted by distance.
|
|
302
|
+
* @param node The node to get input layer nodes for.
|
|
303
|
+
* @returns An array of input layer nodes.
|
|
304
|
+
*/
|
|
211
305
|
protected getAllInputLayerNodes(node: FlowNodeEntity): FlowNodeEntity[];
|
|
306
|
+
/**
|
|
307
|
+
* Gets all output layer nodes for a given node in the same layer.
|
|
308
|
+
* @param curr The node to get output layer nodes for.
|
|
309
|
+
* @returns An array of output layer nodes.
|
|
310
|
+
*/
|
|
212
311
|
protected getAllOutputLayerNodes(curr: FlowNodeEntity): FlowNodeEntity[];
|
|
312
|
+
/**
|
|
313
|
+
* Gets the dependency scopes for a given scope.
|
|
314
|
+
* @param scope The scope to get dependencies for.
|
|
315
|
+
* @returns An array of dependency scopes.
|
|
316
|
+
*/
|
|
213
317
|
getDeps(scope: FlowNodeScope): FlowNodeScope[];
|
|
318
|
+
/**
|
|
319
|
+
* Gets the covering scopes for a given scope.
|
|
320
|
+
* @param scope The scope to get covering scopes for.
|
|
321
|
+
* @returns An array of covering scopes.
|
|
322
|
+
*/
|
|
214
323
|
getCovers(scope: FlowNodeScope): FlowNodeScope[];
|
|
324
|
+
/**
|
|
325
|
+
* Gets the children of a node.
|
|
326
|
+
* @param node The node to get children for.
|
|
327
|
+
* @returns An array of child nodes.
|
|
328
|
+
*/
|
|
215
329
|
getNodeChildren(node: FlowNodeEntity): FlowNodeEntity[];
|
|
216
330
|
/**
|
|
217
331
|
* Get All children of nodes
|
|
@@ -219,8 +333,22 @@ declare class FreeLayoutScopeChain extends ScopeChain {
|
|
|
219
333
|
* @returns
|
|
220
334
|
*/
|
|
221
335
|
getAllPublicChildScopes(node: FlowNodeEntity): Scope[];
|
|
336
|
+
/**
|
|
337
|
+
* Gets the parent of a node.
|
|
338
|
+
* @param node The node to get the parent for.
|
|
339
|
+
* @returns The parent node or `undefined` if not found.
|
|
340
|
+
*/
|
|
222
341
|
getNodeParent(node: FlowNodeEntity): FlowNodeEntity | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* Checks if the children of a node are private and cannot be accessed by subsequent nodes.
|
|
344
|
+
* @param node The node to check.
|
|
345
|
+
* @returns `true` if the children are private, `false` otherwise.
|
|
346
|
+
*/
|
|
223
347
|
protected isNodeChildrenPrivate(node?: FlowNodeEntity): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Sorts all scopes in the scope chain.
|
|
350
|
+
* @returns An empty array, as this method is not implemented.
|
|
351
|
+
*/
|
|
224
352
|
sortAll(): Scope[];
|
|
225
353
|
}
|
|
226
354
|
|
|
@@ -230,7 +358,7 @@ declare class FreeLayoutScopeChain extends ScopeChain {
|
|
|
230
358
|
*/
|
|
231
359
|
|
|
232
360
|
/**
|
|
233
|
-
*
|
|
361
|
+
* Scope chain implementation based on `FlowVirtualTree`.
|
|
234
362
|
*/
|
|
235
363
|
declare class FixedLayoutScopeChain extends ScopeChain {
|
|
236
364
|
protected flowDocument: FlowDocument;
|
|
@@ -238,13 +366,52 @@ declare class FixedLayoutScopeChain extends ScopeChain {
|
|
|
238
366
|
tree: FlowVirtualTree<ScopeChainNode> | undefined;
|
|
239
367
|
protected transformService: ScopeChainTransformService;
|
|
240
368
|
constructor(flowDocument: FlowDocument, configs?: VariableChainConfig | undefined);
|
|
369
|
+
/**
|
|
370
|
+
* Binds the scope chain to a `FlowVirtualTree`.
|
|
371
|
+
* @param tree The `FlowVirtualTree` to bind to.
|
|
372
|
+
*/
|
|
241
373
|
bindTree(tree: FlowVirtualTree<ScopeChainNode>): void;
|
|
374
|
+
/**
|
|
375
|
+
* Gets the dependency scopes for a given scope.
|
|
376
|
+
* @param scope The scope to get dependencies for.
|
|
377
|
+
* @returns An array of dependency scopes.
|
|
378
|
+
*/
|
|
242
379
|
getDeps(scope: FlowNodeScope): FlowNodeScope[];
|
|
380
|
+
/**
|
|
381
|
+
* Gets the covering scopes for a given scope.
|
|
382
|
+
* @param scope The scope to get covering scopes for.
|
|
383
|
+
* @returns An array of covering scopes.
|
|
384
|
+
*/
|
|
243
385
|
getCovers(scope: FlowNodeScope): FlowNodeScope[];
|
|
386
|
+
/**
|
|
387
|
+
* Sorts all scopes in the scope chain.
|
|
388
|
+
* @returns A sorted array of all scopes.
|
|
389
|
+
*/
|
|
244
390
|
sortAll(): Scope[];
|
|
391
|
+
/**
|
|
392
|
+
* Gets the `FlowNodeVariableData` for a given `ScopeChainNode`.
|
|
393
|
+
* @param node The `ScopeChainNode` to get data for.
|
|
394
|
+
* @returns The `FlowNodeVariableData` or `undefined` if not found.
|
|
395
|
+
*/
|
|
245
396
|
private getVariableData;
|
|
397
|
+
/**
|
|
398
|
+
* Checks if the children of a node are private.
|
|
399
|
+
* @param node The node to check.
|
|
400
|
+
* @returns `true` if the children are private, `false` otherwise.
|
|
401
|
+
*/
|
|
246
402
|
private isNodeChildrenPrivate;
|
|
403
|
+
/**
|
|
404
|
+
* Checks if a node has children.
|
|
405
|
+
* @param node The node to check.
|
|
406
|
+
* @returns `true` if the node has children, `false` otherwise.
|
|
407
|
+
*/
|
|
247
408
|
private hasChildren;
|
|
409
|
+
/**
|
|
410
|
+
* Gets all sorted child scopes of a node.
|
|
411
|
+
* @param node The node to get child scopes for.
|
|
412
|
+
* @param options Options for getting child scopes.
|
|
413
|
+
* @returns An array of sorted child scopes.
|
|
414
|
+
*/
|
|
248
415
|
private getAllSortedChildScope;
|
|
249
416
|
}
|
|
250
417
|
|
|
@@ -253,22 +420,35 @@ declare class FixedLayoutScopeChain extends ScopeChain {
|
|
|
253
420
|
* SPDX-License-Identifier: MIT
|
|
254
421
|
*/
|
|
255
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Global Scope stores all variables that are not scoped to any node.
|
|
425
|
+
*
|
|
426
|
+
* - Variables in Global Scope can be accessed by any node.
|
|
427
|
+
* - Any other scope's variables can not be accessed by Global Scope.
|
|
428
|
+
*/
|
|
256
429
|
declare class GlobalScope extends Scope {
|
|
257
430
|
static readonly ID: unique symbol;
|
|
431
|
+
/**
|
|
432
|
+
* Check if the scope is Global Scope.
|
|
433
|
+
* @param scope
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
258
436
|
static is(scope: Scope): boolean;
|
|
259
437
|
}
|
|
260
438
|
declare const bindGlobalScope: (bind: interfaces.Bind) => void;
|
|
261
439
|
|
|
262
440
|
/**
|
|
263
|
-
* Use `node.scope` instead
|
|
441
|
+
* Use `node.scope` instead.
|
|
264
442
|
* @deprecated
|
|
265
|
-
* @param node
|
|
443
|
+
* @param node The flow node entity.
|
|
444
|
+
* @returns The public scope of the node.
|
|
266
445
|
*/
|
|
267
446
|
declare function getNodeScope(node: FlowNodeEntity): FlowNodeScope;
|
|
268
447
|
/**
|
|
269
|
-
* Use `node.privateScope` instead
|
|
448
|
+
* Use `node.privateScope` instead.
|
|
270
449
|
* @deprecated
|
|
271
|
-
* @param node
|
|
450
|
+
* @param node The flow node entity.
|
|
451
|
+
* @returns The private scope of the node.
|
|
272
452
|
*/
|
|
273
453
|
declare function getNodePrivateScope(node: FlowNodeEntity): FlowNodeScope;
|
|
274
454
|
|