@flowgram.ai/variable-core 0.5.7 → 1.0.1
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 +62 -38
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +87 -52
- package/dist/index.d.ts +87 -52
- package/dist/index.js +88 -64
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/variable-container-module.ts","../src/variable-engine.ts","../src/utils/toDisposable.tsx","../src/utils/memo.ts","../src/scope/variable-table.ts","../src/scope/scope-chain.ts","../src/providers.ts","../src/scope/scope.ts","../src/ast/types.ts","../src/ast/ast-registers.ts","../src/ast/utils/inversify.ts","../src/ast/flags.ts","../src/ast/match.ts","../src/ast/utils/helpers.ts","../src/ast/ast-node.ts","../src/ast/type/base-type.ts","../src/ast/type/array.ts","../src/ast/type/string.ts","../src/ast/type/integer.ts","../src/ast/type/boolean.ts","../src/ast/type/number.ts","../src/ast/type/map.ts","../src/ast/type/object.ts","../src/ast/type/custom-type.ts","../src/ast/expression/base-expression.ts","../src/ast/utils/variable-field.ts","../src/ast/expression/enumerate-expression.ts","../src/ast/expression/keypath-expression.ts","../src/ast/utils/expression.ts","../src/ast/expression/legacy-keypath-expression.ts","../src/ast/expression/wrap-array-expression.ts","../src/ast/declaration/base-variable-field.ts","../src/ast/declaration/variable-declaration.ts","../src/ast/declaration/variable-declaration-list.ts","../src/ast/declaration/property.ts","../src/ast/common/data-node.ts","../src/ast/common/list-node.ts","../src/ast/common/map-node.ts","../src/ast/factory.ts","../src/scope/datas/scope-output-data.ts","../src/scope/datas/scope-available-data.ts","../src/scope/datas/scope-event-data.ts","../src/services/variable-field-key-rename-service.ts","../src/react/context.tsx","../src/react/hooks/use-scope-available.ts","../src/react/hooks/use-available-variables.ts","../src/react/hooks/use-output-variables.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { VariableContainerModule } from './variable-container-module';\nexport { VariableEngine } from './variable-engine';\nexport { VariableEngineProvider } from './providers';\n\nexport * from './react';\nexport * from './scope';\nexport * from './ast';\nexport * from './services';\nexport { type Observer } from 'rxjs';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ContainerModule } from 'inversify';\n\nimport { VariableEngine } from './variable-engine';\nimport { VariableFieldKeyRenameService } from './services';\nimport { ContainerProvider, VariableEngineProvider } from './providers';\nimport { ASTRegisters } from './ast';\n\n/**\n * An InversifyJS container module that binds all the necessary services for the variable engine.\n * This module sets up the dependency injection for the core components of the variable engine.\n */\nexport const VariableContainerModule = new ContainerModule((bind) => {\n bind(VariableEngine).toSelf().inSingletonScope();\n bind(ASTRegisters).toSelf().inSingletonScope();\n\n bind(VariableFieldKeyRenameService).toSelf().inSingletonScope();\n\n // Provide a dynamic provider for VariableEngine to prevent circular dependencies.\n bind(VariableEngineProvider).toDynamicValue((ctx) => () => ctx.container.get(VariableEngine));\n\n // Provide a ContainerProvider to allow AST nodes and other components to access the container.\n bind(ContainerProvider).toDynamicValue((ctx) => () => ctx.container);\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subject } from 'rxjs';\nimport { inject, injectable, interfaces, preDestroy } from 'inversify';\nimport { Disposable, DisposableCollection } from '@flowgram.ai/utils';\nimport { Emitter } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from './utils/toDisposable';\nimport { createMemo } from './utils/memo';\nimport { VariableTable } from './scope/variable-table';\nimport { ScopeChangeAction } from './scope/types';\nimport { IScopeConstructor } from './scope/scope';\nimport { Scope, ScopeChain, type IVariableTable } from './scope';\nimport { ContainerProvider } from './providers';\nimport { ASTRegisters, type GlobalEventActionType } from './ast';\n\n/**\n * The core of the variable engine system.\n * It manages scopes, variables, and events within the system.\n */\n@injectable()\nexport class VariableEngine implements Disposable {\n protected toDispose = new DisposableCollection();\n\n protected memo = createMemo();\n\n protected scopeMap = new Map<string | symbol, Scope>();\n\n /**\n * A rxjs subject that emits global events occurring within the variable engine.\n */\n globalEvent$: Subject<GlobalEventActionType> = new Subject<GlobalEventActionType>();\n\n protected onScopeChangeEmitter = new Emitter<ScopeChangeAction>();\n\n /**\n * A table containing all global variables.\n */\n public globalVariableTable: IVariableTable = new VariableTable();\n\n /**\n * An event that fires whenever a scope is added, updated, or deleted.\n */\n public onScopeChange = this.onScopeChangeEmitter.event;\n\n @inject(ContainerProvider) private readonly containerProvider: ContainerProvider;\n\n /**\n * The Inversify container instance.\n */\n get container(): interfaces.Container {\n return this.containerProvider();\n }\n\n constructor(\n /**\n * The scope chain, which manages the dependency relationships between scopes.\n */\n @inject(ScopeChain)\n public readonly chain: ScopeChain,\n /**\n * The registry for all AST node types.\n */\n @inject(ASTRegisters)\n public readonly astRegisters: ASTRegisters\n ) {\n this.toDispose.pushAll([\n chain,\n Disposable.create(() => {\n // Dispose all scopes\n this.getAllScopes().forEach((scope) => scope.dispose());\n this.globalVariableTable.dispose();\n }),\n ]);\n }\n\n /**\n * Disposes of all resources used by the variable engine.\n */\n @preDestroy()\n dispose(): void {\n this.toDispose.dispose();\n }\n\n /**\n * Retrieves a scope by its unique identifier.\n * @param scopeId The ID of the scope to retrieve.\n * @returns The scope if found, otherwise undefined.\n */\n getScopeById(scopeId: string | symbol): Scope | undefined {\n return this.scopeMap.get(scopeId);\n }\n\n /**\n * Removes a scope by its unique identifier and disposes of it.\n * @param scopeId The ID of the scope to remove.\n */\n removeScopeById(scopeId: string | symbol): void {\n this.getScopeById(scopeId)?.dispose();\n }\n\n /**\n * Creates a new scope or retrieves an existing one if the ID and type match.\n * @param id The unique identifier for the scope.\n * @param meta Optional metadata for the scope, defined by the user.\n * @param options Options for creating the scope.\n * @param options.ScopeConstructor The constructor to use for creating the scope. Defaults to `Scope`.\n * @returns The created or existing scope.\n */\n createScope(\n id: string | symbol,\n meta?: Record<string, any>,\n options: {\n ScopeConstructor?: IScopeConstructor;\n } = {}\n ): Scope {\n const { ScopeConstructor = Scope } = options;\n\n let scope = this.getScopeById(id);\n\n if (!scope) {\n scope = new ScopeConstructor({ variableEngine: this, meta, id });\n this.scopeMap.set(id, scope);\n this.onScopeChangeEmitter.fire({ type: 'add', scope: scope! });\n\n scope.toDispose.pushAll([\n scope.ast.subscribe(() => {\n this.onScopeChangeEmitter.fire({ type: 'update', scope: scope! });\n }),\n // Fires when available variables change\n scope.available.onDataChange(() => {\n this.onScopeChangeEmitter.fire({ type: 'available', scope: scope! });\n }),\n ]);\n scope.onDispose(() => {\n this.scopeMap.delete(id);\n this.onScopeChangeEmitter.fire({ type: 'delete', scope: scope! });\n });\n }\n\n return scope;\n }\n\n /**\n * Retrieves all scopes currently managed by the engine.\n * @param options Options for retrieving the scopes.\n * @param options.sort Whether to sort the scopes based on their dependency chain.\n * @returns An array of all scopes.\n */\n getAllScopes({\n sort,\n }: {\n sort?: boolean;\n } = {}): Scope[] {\n const allScopes = Array.from(this.scopeMap.values());\n\n if (sort) {\n const sortScopes = this.chain.sortAll();\n const remainScopes = new Set(allScopes);\n sortScopes.forEach((_scope) => remainScopes.delete(_scope));\n\n return [...sortScopes, ...Array.from(remainScopes)];\n }\n\n return [...allScopes];\n }\n\n /**\n * Fires a global event to be broadcast to all listeners.\n * @param event The global event to fire.\n */\n fireGlobalEvent(event: GlobalEventActionType) {\n this.globalEvent$.next(event);\n }\n\n /**\n * Subscribes to a specific type of global event.\n * @param type The type of the event to listen for.\n * @param observer A function to be called when the event is observed.\n * @returns A disposable object to unsubscribe from the event.\n */\n onGlobalEvent<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n type: ActionType['type'],\n observer: (action: ActionType) => void\n ): Disposable {\n return subsToDisposable(\n this.globalEvent$.subscribe((_action) => {\n if (_action.type === type) {\n observer(_action as ActionType);\n }\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subscription } from 'rxjs';\nimport { Disposable } from '@flowgram.ai/utils';\n\n/**\n * Convert rxjs subscription to disposable\n * @param subscription - The rxjs subscription\n * @returns The disposable\n */\nexport function subsToDisposable(subscription: Subscription): Disposable {\n return Disposable.create(() => subscription.unsubscribe());\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\ntype KeyType = string | symbol;\n\n/**\n * Create memo manager\n * @returns\n */\nexport const createMemo = (): {\n <T>(key: KeyType, fn: () => T): T;\n clear: (key?: KeyType) => void;\n} => {\n const _memoCache = new Map<KeyType, any>();\n\n const memo = <T>(key: KeyType, fn: () => T): T => {\n if (_memoCache.has(key)) {\n return _memoCache.get(key) as T;\n }\n const data = fn();\n _memoCache.set(key, data);\n return data as T;\n };\n\n const clear = (key?: KeyType) => {\n if (key) {\n _memoCache.delete(key);\n } else {\n _memoCache.clear();\n }\n };\n\n memo.clear = clear;\n\n return memo;\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Observable, Subject, merge, share, skip, switchMap } from 'rxjs';\nimport { DisposableCollection, Emitter } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from '../utils/toDisposable';\nimport { BaseVariableField } from '../ast/declaration/base-variable-field';\nimport { VariableDeclaration } from '../ast';\nimport { IVariableTable } from './types';\n\n/**\n * A class that stores and manages variables in a table-like structure.\n * It provides methods for adding, removing, and retrieving variables, as well as\n * observables for listening to changes in the variable list and individual variables.\n */\nexport class VariableTable implements IVariableTable {\n protected table: Map<string, VariableDeclaration> = new Map();\n\n toDispose = new DisposableCollection();\n\n /**\n * @deprecated\n */\n protected onDataChangeEmitter = new Emitter<void>();\n\n protected variables$: Subject<VariableDeclaration[]> = new Subject<VariableDeclaration[]>();\n\n /**\n * An observable that listens for value changes on any variable within the table.\n */\n protected anyVariableChange$: Observable<VariableDeclaration> = this.variables$.pipe(\n switchMap((_variables) =>\n merge(\n ..._variables.map((_v) =>\n _v.value$.pipe<any>(\n // Skip the initial value of the BehaviorSubject\n skip(1)\n )\n )\n )\n ),\n share()\n );\n\n /**\n * Subscribes to updates on any variable in the list.\n * @param observer A function to be called when any variable's value changes.\n * @returns A disposable object to unsubscribe from the updates.\n */\n onAnyVariableChange(observer: (changedVariable: VariableDeclaration) => void) {\n return subsToDisposable(this.anyVariableChange$.subscribe(observer));\n }\n\n /**\n * Subscribes to changes in the variable list (additions or removals).\n * @param observer A function to be called when the list of variables changes.\n * @returns A disposable object to unsubscribe from the updates.\n */\n onVariableListChange(observer: (variables: VariableDeclaration[]) => void) {\n return subsToDisposable(this.variables$.subscribe(observer));\n }\n\n /**\n * Subscribes to both variable list changes and updates to any variable in the list.\n * @param observer A function to be called when either the list or a variable in it changes.\n * @returns A disposable collection to unsubscribe from both events.\n */\n onListOrAnyVarChange(observer: () => void) {\n const disposables = new DisposableCollection();\n disposables.pushAll([this.onVariableListChange(observer), this.onAnyVariableChange(observer)]);\n return disposables;\n }\n\n /**\n * @deprecated Use onListOrAnyVarChange instead.\n */\n public onDataChange = this.onDataChangeEmitter.event;\n\n protected _version: number = 0;\n\n /**\n * Fires change events to notify listeners that the data has been updated.\n */\n fireChange() {\n this.bumpVersion();\n this.onDataChangeEmitter.fire();\n this.variables$.next(this.variables);\n this.parentTable?.fireChange();\n }\n\n /**\n * The current version of the variable table, incremented on each change.\n */\n get version(): number {\n return this._version;\n }\n\n /**\n * Increments the version number, resetting to 0 if it reaches MAX_SAFE_INTEGER.\n */\n protected bumpVersion() {\n this._version = this._version + 1;\n if (this._version === Number.MAX_SAFE_INTEGER) {\n this._version = 0;\n }\n }\n\n constructor(\n /**\n * An optional parent table. If provided, this table will contain all variables\n * from the current table.\n */\n public parentTable?: IVariableTable\n ) {\n this.toDispose.pushAll([\n this.onDataChangeEmitter,\n // Activate the share() operator\n this.onAnyVariableChange(() => {\n this.bumpVersion();\n }),\n ]);\n }\n\n /**\n * An array of all variables in the table.\n */\n get variables(): VariableDeclaration[] {\n return Array.from(this.table.values());\n }\n\n /**\n * An array of all variable keys in the table.\n */\n get variableKeys(): string[] {\n return Array.from(this.table.keys());\n }\n\n /**\n * Retrieves a variable or a nested property field by its key path.\n * @param keyPath An array of keys representing the path to the desired field.\n * @returns The found variable or property field, or undefined if not found.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n const [variableKey, ...propertyKeys] = keyPath || [];\n\n if (!variableKey) {\n return;\n }\n\n const variable = this.getVariableByKey(variableKey);\n\n return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;\n }\n\n /**\n * Retrieves a variable by its key.\n * @param key The key of the variable to retrieve.\n * @returns The variable declaration if found, otherwise undefined.\n */\n getVariableByKey(key: string) {\n return this.table.get(key);\n }\n\n /**\n * Adds a variable to the table.\n * If a parent table exists, the variable is also added to the parent.\n * @param variable The variable declaration to add.\n */\n addVariableToTable(variable: VariableDeclaration) {\n this.table.set(variable.key, variable);\n if (this.parentTable) {\n (this.parentTable as VariableTable).addVariableToTable(variable);\n }\n }\n\n /**\n * Removes a variable from the table.\n * If a parent table exists, the variable is also removed from the parent.\n * @param key The key of the variable to remove.\n */\n removeVariableFromTable(key: string) {\n this.table.delete(key);\n if (this.parentTable) {\n (this.parentTable as VariableTable).removeVariableFromTable(key);\n }\n }\n\n /**\n * Disposes of all resources used by the variable table.\n */\n dispose(): void {\n this.variableKeys.forEach((_key) =>\n (this.parentTable as VariableTable)?.removeVariableFromTable(_key)\n );\n this.parentTable?.fireChange();\n this.variables$.complete();\n this.variables$.unsubscribe();\n this.toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, injectable } from 'inversify';\nimport { DisposableCollection, type Event } from '@flowgram.ai/utils';\n\nimport { VariableEngineProvider } from '../providers';\nimport { type Scope } from './scope';\n\n/**\n * Manages the dependency relationships between scopes.\n * This is an abstract class, and specific implementations determine how the scope order is managed.\n */\n@injectable()\nexport abstract class ScopeChain {\n readonly toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(VariableEngineProvider) variableEngineProvider: VariableEngineProvider;\n\n get variableEngine() {\n return this.variableEngineProvider();\n }\n\n constructor() {}\n\n /**\n * Refreshes the dependency and coverage relationships for all scopes.\n */\n refreshAllChange(): void {\n this.variableEngine.getAllScopes().forEach((_scope) => {\n _scope.refreshCovers();\n _scope.refreshDeps();\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 abstract getDeps(scope: Scope): Scope[];\n\n /**\n * Gets the covering scopes for a given scope.\n * @param scope The scope to get covers for.\n * @returns An array of covering scopes.\n */\n abstract getCovers(scope: Scope): Scope[];\n\n /**\n * Sorts all scopes based on their dependency relationships.\n * @returns A sorted array of all scopes.\n */\n abstract sortAll(): Scope[];\n\n dispose(): void {\n this.toDispose.dispose();\n }\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n get onDispose(): Event<void> {\n return this.toDispose.onDispose;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\n\nimport { type VariableEngine } from './variable-engine';\n\n/**\n * A provider for dynamically obtaining the `VariableEngine` instance.\n * This is used to prevent circular dependencies when injecting `VariableEngine`.\n */\nexport const VariableEngineProvider = Symbol('DynamicVariableEngine');\nexport type VariableEngineProvider = () => VariableEngine;\n\n/**\n * A provider for obtaining the Inversify container instance.\n * This allows other parts of the application, like AST nodes, to access the container for dependency injection.\n */\nexport const ContainerProvider = Symbol('ContainerProvider');\nexport type ContainerProvider = () => interfaces.Container;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { DisposableCollection } from '@flowgram.ai/utils';\n\nimport { type VariableEngine } from '../variable-engine';\nimport { createMemo } from '../utils/memo';\nimport { ASTKind, type ASTNode, type ASTNodeJSON, MapNode } from '../ast';\nimport { ScopeAvailableData, ScopeEventData, ScopeOutputData } from './datas';\n\n/**\n * Interface for the Scope constructor.\n */\nexport interface IScopeConstructor {\n new (options: {\n id: string | symbol;\n variableEngine: VariableEngine;\n meta?: Record<string, any>;\n }): Scope;\n}\n\n/**\n * Represents a variable scope, which manages its own set of variables and their lifecycle.\n * - `scope.output` represents the variables declared within this scope.\n * - `scope.available` represents all variables accessible from this scope, including those from parent scopes.\n */\nexport class Scope<ScopeMeta extends Record<string, any> = Record<string, any>> {\n /**\n * A unique identifier for the scope.\n */\n readonly id: string | symbol;\n\n /**\n * The variable engine instance this scope belongs to.\n */\n readonly variableEngine: VariableEngine;\n\n /**\n * Metadata associated with the scope, which can be extended by higher-level business logic.\n */\n readonly meta: ScopeMeta;\n\n /**\n * The root AST node for this scope, which is a MapNode.\n * It stores various data related to the scope, such as `outputs`.\n */\n readonly ast: MapNode;\n\n /**\n * Manages the available variables for this scope.\n */\n readonly available: ScopeAvailableData;\n\n /**\n * Manages the output variables for this scope.\n */\n readonly output: ScopeOutputData;\n\n /**\n * Manages event dispatching and handling for this scope.\n */\n readonly event: ScopeEventData;\n\n /**\n * A memoization utility for caching computed values.\n */\n protected memo = createMemo();\n\n public toDispose: DisposableCollection = new DisposableCollection();\n\n constructor(options: { id: string | symbol; variableEngine: VariableEngine; meta?: ScopeMeta }) {\n this.id = options.id;\n this.meta = options.meta || ({} as any);\n this.variableEngine = options.variableEngine;\n\n this.event = new ScopeEventData(this);\n\n this.ast = this.variableEngine.astRegisters.createAST(\n {\n kind: ASTKind.MapNode,\n key: String(this.id),\n },\n {\n scope: this,\n }\n ) as MapNode;\n\n this.output = new ScopeOutputData(this);\n this.available = new ScopeAvailableData(this);\n }\n\n /**\n * Refreshes the covering scopes.\n */\n refreshCovers(): void {\n this.memo.clear('covers');\n }\n\n /**\n * Refreshes the dependency scopes and the available variables.\n */\n refreshDeps(): void {\n this.memo.clear('deps');\n this.available.refresh();\n }\n\n /**\n * Gets the scopes that this scope depends on.\n */\n get depScopes(): Scope[] {\n return this.memo('deps', () =>\n this.variableEngine.chain\n .getDeps(this)\n .filter((_scope) => Boolean(_scope) && !_scope?.disposed)\n );\n }\n\n /**\n * Gets the scopes that are covered by this scope.\n */\n get coverScopes(): Scope[] {\n return this.memo('covers', () =>\n this.variableEngine.chain\n .getCovers(this)\n .filter((_scope) => Boolean(_scope) && !_scope?.disposed)\n );\n }\n\n /**\n * Disposes of the scope and its resources.\n * This will also trigger updates in dependent and covering scopes.\n */\n dispose(): void {\n this.ast.dispose();\n this.toDispose.dispose();\n\n // When a scope is disposed, update its dependent and covering scopes.\n this.coverScopes.forEach((_scope) => _scope.refreshDeps());\n this.depScopes.forEach((_scope) => _scope.refreshCovers());\n }\n\n onDispose = this.toDispose.onDispose;\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n /**\n * Sets a variable in the scope with the default key 'outputs'.\n *\n * @param json The JSON representation of the AST node to set.\n * @returns The created or updated AST node.\n */\n public setVar<Node extends ASTNode = ASTNode>(json: ASTNodeJSON): Node;\n\n /**\n * Sets a variable in the scope with a specified key.\n *\n * @param key The key of the variable to set.\n * @param json The JSON representation of the AST node to set.\n * @returns The created or updated AST node.\n */\n public setVar<Node extends ASTNode = ASTNode>(key: string, json: ASTNodeJSON): Node;\n\n public setVar<Node extends ASTNode = ASTNode>(\n arg1: string | ASTNodeJSON,\n arg2?: ASTNodeJSON\n ): Node {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the scope by its key.\n *\n * @param key The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The AST node for the variable, or `undefined` if not found.\n */\n public getVar<Node extends ASTNode = ASTNode>(key: string = 'outputs') {\n return this.ast.get<Node>(key);\n }\n\n /**\n * Clears a variable from the scope by its key.\n *\n * @param key The key of the variable to clear. Defaults to 'outputs'.\n */\n public clearVar(key: string = 'outputs') {\n return this.ast.remove(key);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type Observer } from 'rxjs';\n\nimport { type Scope } from '../scope';\nimport { type ASTNode } from './ast-node';\n\nexport type ASTKindType = string;\nexport type Identifier = string;\n\n/**\n * ASTNodeJSON is the JSON representation of an ASTNode.\n */\nexport interface ASTNodeJSON {\n /**\n * Kind is the type of the AST node.\n */\n kind?: ASTKindType;\n\n /**\n * Key is the unique identifier of the node.\n * If not provided, the node will generate a default key value.\n */\n key?: Identifier;\n [key: string]: any;\n}\n\n/**\n * Core AST node types.\n */\nexport enum ASTKind {\n /**\n * # Type-related.\n * - A set of type AST nodes based on JSON types is implemented internally by default.\n */\n\n /**\n * String type.\n */\n String = 'String',\n /**\n * Number type.\n */\n Number = 'Number',\n /**\n * Integer type.\n */\n Integer = 'Integer',\n /**\n * Boolean type.\n */\n Boolean = 'Boolean',\n /**\n * Object type.\n */\n Object = 'Object',\n /**\n * Array type.\n */\n Array = 'Array',\n /**\n * Map type.\n */\n Map = 'Map',\n /**\n * Union type.\n * Commonly used for type checking, generally not exposed to the business.\n */\n Union = 'Union',\n /**\n * Any type.\n * Commonly used for business logic.\n */\n Any = 'Any',\n /**\n * Custom type.\n * For business-defined types.\n */\n CustomType = 'CustomType',\n\n /**\n * # Declaration-related.\n */\n\n /**\n * Field definition for Object drill-down.\n */\n Property = 'Property',\n /**\n * Variable declaration.\n */\n VariableDeclaration = 'VariableDeclaration',\n /**\n * Variable declaration list.\n */\n VariableDeclarationList = 'VariableDeclarationList',\n\n /**\n * # Expression-related.\n */\n\n /**\n * Access fields on variables through the path system.\n */\n KeyPathExpression = 'KeyPathExpression',\n /**\n * Iterate over specified data.\n */\n EnumerateExpression = 'EnumerateExpression',\n /**\n * Wrap with Array Type.\n */\n WrapArrayExpression = 'WrapArrayExpression',\n\n /**\n * # General-purpose AST nodes.\n */\n\n /**\n * General-purpose List<ASTNode> storage node.\n */\n ListNode = 'ListNode',\n /**\n * General-purpose data storage node.\n */\n DataNode = 'DataNode',\n /**\n * General-purpose Map<string, ASTNode> storage node.\n */\n MapNode = 'MapNode',\n}\n\nexport interface CreateASTParams {\n scope: Scope;\n key?: Identifier;\n parent?: ASTNode;\n}\n\nexport type ASTNodeJSONOrKind = string | ASTNodeJSON;\n\nexport type ObserverOrNext<T> = Partial<Observer<T>> | ((value: T) => void);\n\nexport interface SubscribeConfig<This, Data> {\n // Merge all changes within one animationFrame into a single one.\n debounceAnimation?: boolean;\n // Respond with a value by default upon subscription.\n triggerOnInit?: boolean;\n selector?: (curr: This) => Data;\n}\n\n/**\n * TypeUtils to get the JSON representation of an AST node with a specific kind.\n */\nexport type GetKindJSON<KindType extends string, JSON extends ASTNodeJSON> = {\n kind: KindType;\n key?: Identifier;\n} & JSON;\n\n/**\n * TypeUtils to get the JSON representation of an AST node with a specific kind or just the kind string.\n */\nexport type GetKindJSONOrKind<KindType extends string, JSON extends ASTNodeJSON> =\n | ({\n kind: KindType;\n key?: Identifier;\n } & JSON)\n | KindType;\n\n/**\n * Global event action type.\n * - Global event might be dispatched from `ASTNode` or `Scope`.\n */\nexport interface GlobalEventActionType<\n Type = string,\n Payload = any,\n AST extends ASTNode = ASTNode\n> {\n type: Type;\n payload?: Payload;\n ast?: AST;\n}\n\nexport type NewASTAction = GlobalEventActionType<'NewAST'>;\nexport type UpdateASTAction = GlobalEventActionType<'UpdateAST'>;\nexport type DisposeASTAction = GlobalEventActionType<'DisposeAST'>;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { omit } from 'lodash-es';\nimport { injectable } from 'inversify';\n\nimport { POST_CONSTRUCT_AST_SYMBOL } from './utils/inversify';\nimport { ASTKindType, ASTNodeJSON, CreateASTParams, NewASTAction } from './types';\nimport { ArrayType } from './type/array';\nimport {\n BooleanType,\n CustomType,\n IntegerType,\n MapType,\n NumberType,\n ObjectType,\n StringType,\n} from './type';\nimport { EnumerateExpression, KeyPathExpression, WrapArrayExpression } from './expression';\nimport { Property, VariableDeclaration, VariableDeclarationList } from './declaration';\nimport { DataNode, MapNode } from './common';\nimport { ASTNode, ASTNodeRegistry } from './ast-node';\n\ntype DataInjector = () => Record<string, any>;\n\n/**\n * Register the AST node to the engine.\n */\n@injectable()\nexport class ASTRegisters {\n protected injectors: Map<ASTKindType, DataInjector> = new Map();\n\n protected astMap: Map<ASTKindType, ASTNodeRegistry> = new Map();\n\n /**\n * Core AST node registration.\n */\n constructor() {\n this.registerAST(StringType);\n this.registerAST(NumberType);\n this.registerAST(BooleanType);\n this.registerAST(IntegerType);\n this.registerAST(ObjectType);\n this.registerAST(ArrayType);\n this.registerAST(MapType);\n this.registerAST(CustomType);\n this.registerAST(Property);\n this.registerAST(VariableDeclaration);\n this.registerAST(VariableDeclarationList);\n this.registerAST(KeyPathExpression);\n\n this.registerAST(EnumerateExpression);\n this.registerAST(WrapArrayExpression);\n this.registerAST(MapNode);\n this.registerAST(DataNode);\n }\n\n /**\n * Creates an AST node.\n * @param param Creation parameters.\n * @returns\n */\n createAST<ReturnNode extends ASTNode = ASTNode>(\n json: ASTNodeJSON,\n { parent, scope }: CreateASTParams\n ): ReturnNode {\n const Registry = this.astMap.get(json.kind!);\n\n if (!Registry) {\n throw Error(`ASTKind: ${String(json.kind)} can not find its ASTNode Registry`);\n }\n\n const injector = this.injectors.get(json.kind!);\n\n const node = new Registry(\n {\n key: json.key,\n scope,\n parent,\n },\n injector?.() || {}\n ) as ReturnNode;\n\n // Do not trigger fireChange during initial creation.\n node.changeLocked = true;\n node.fromJSON(omit(json, ['key', 'kind']));\n node.changeLocked = false;\n\n node.dispatchGlobalEvent<NewASTAction>({ type: 'NewAST' });\n\n if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {\n const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);\n (node[postConstructKey] as () => void)?.();\n }\n\n return node;\n }\n\n /**\n * Gets the node Registry by AST node type.\n * @param kind\n * @returns\n */\n getASTRegistryByKind(kind: ASTKindType) {\n return this.astMap.get(kind);\n }\n\n /**\n * Registers an AST node.\n * @param ASTNode\n * @param injector\n */\n registerAST(ASTNode: ASTNodeRegistry, injector?: DataInjector) {\n this.astMap.set(ASTNode.kind, ASTNode);\n if (injector) {\n this.injectors.set(ASTNode.kind, injector);\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\n\nimport { type ASTNode } from '../ast-node';\n\nexport const injectToAST = (serviceIdentifier: interfaces.ServiceIdentifier) =>\n function (target: any, propertyKey: string) {\n if (!serviceIdentifier) {\n throw new Error(\n `ServiceIdentifier ${serviceIdentifier} in @lazyInject is Empty, it might be caused by file circular dependency, please check it.`\n );\n }\n\n const descriptor = {\n get() {\n const container = (this as ASTNode).scope.variableEngine.container;\n return container.get(serviceIdentifier);\n },\n set() {},\n configurable: true,\n enumerable: true,\n } as any;\n\n // Object.defineProperty(target, propertyKey, descriptor);\n\n return descriptor;\n };\n\nexport const POST_CONSTRUCT_AST_SYMBOL = Symbol('post_construct_ast');\n\nexport const postConstructAST = () => (target: any, propertyKey: string) => {\n // Only run once.\n if (!Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, target)) {\n Reflect.defineMetadata(POST_CONSTRUCT_AST_SYMBOL, propertyKey, target);\n } else {\n throw Error('Duplication Post Construct AST');\n }\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * ASTNode flags. Stored in the `flags` property of the `ASTNode`.\n */\nexport enum ASTNodeFlags {\n /**\n * None.\n */\n None = 0,\n\n /**\n * Variable Field.\n */\n VariableField = 1 << 0,\n\n /**\n * Expression.\n */\n Expression = 1 << 2,\n\n /**\n * # Variable Type Flags\n */\n\n /**\n * Basic type.\n */\n BasicType = 1 << 3,\n /**\n * Drillable variable type.\n */\n DrilldownType = 1 << 4,\n /**\n * Enumerable variable type.\n */\n EnumerateType = 1 << 5,\n /**\n * Composite type, currently not in use.\n */\n UnionType = 1 << 6,\n\n /**\n * Variable type.\n */\n VariableType = BasicType | DrilldownType | EnumerateType | UnionType,\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from './types';\nimport {\n type StringType,\n type NumberType,\n type BooleanType,\n type IntegerType,\n type ObjectType,\n type ArrayType,\n type MapType,\n type CustomType,\n} from './type';\nimport { ASTNodeFlags } from './flags';\nimport {\n type WrapArrayExpression,\n type EnumerateExpression,\n type KeyPathExpression,\n} from './expression';\nimport {\n type BaseVariableField,\n type Property,\n type VariableDeclaration,\n type VariableDeclarationList,\n} from './declaration';\nimport { type ASTNode } from './ast-node';\n\n/**\n * Variable-core ASTNode matchers.\n *\n * - Typescript code inside if statement will be type guarded.\n */\nexport namespace ASTMatch {\n /**\n * # Type-related matchers.\n */\n\n /**\n * Check if the node is a `StringType`.\n */\n export const isString = (node?: ASTNode): node is StringType => node?.kind === ASTKind.String;\n\n /**\n * Check if the node is a `NumberType`.\n */\n export const isNumber = (node?: ASTNode): node is NumberType => node?.kind === ASTKind.Number;\n\n /**\n * Check if the node is a `BooleanType`.\n */\n export const isBoolean = (node?: ASTNode): node is BooleanType => node?.kind === ASTKind.Boolean;\n\n /**\n * Check if the node is a `IntegerType`.\n */\n export const isInteger = (node?: ASTNode): node is IntegerType => node?.kind === ASTKind.Integer;\n\n /**\n * Check if the node is a `ObjectType`.\n */\n export const isObject = (node?: ASTNode): node is ObjectType => node?.kind === ASTKind.Object;\n\n /**\n * Check if the node is a `ArrayType`.\n */\n export const isArray = (node?: ASTNode): node is ArrayType => node?.kind === ASTKind.Array;\n\n /**\n * Check if the node is a `MapType`.\n */\n export const isMap = (node?: ASTNode): node is MapType => node?.kind === ASTKind.Map;\n\n /**\n * Check if the node is a `CustomType`.\n */\n export const isCustomType = (node?: ASTNode): node is CustomType =>\n node?.kind === ASTKind.CustomType;\n\n /**\n * # Declaration-related matchers.\n */\n\n /**\n * Check if the node is a `VariableDeclaration`.\n */\n export const isVariableDeclaration = <VariableMeta = any>(\n node?: ASTNode\n ): node is VariableDeclaration<VariableMeta> => node?.kind === ASTKind.VariableDeclaration;\n\n /**\n * Check if the node is a `Property`.\n */\n export const isProperty = <VariableMeta = any>(node?: ASTNode): node is Property<VariableMeta> =>\n node?.kind === ASTKind.Property;\n\n /**\n * Check if the node is a `BaseVariableField`.\n */\n export const isBaseVariableField = (node?: ASTNode): node is BaseVariableField =>\n !!(node?.flags || 0 & ASTNodeFlags.VariableField);\n\n /**\n * Check if the node is a `VariableDeclarationList`.\n */\n export const isVariableDeclarationList = (node?: ASTNode): node is VariableDeclarationList =>\n node?.kind === ASTKind.VariableDeclarationList;\n\n /**\n * # Expression-related matchers.\n */\n\n /**\n * Check if the node is a `EnumerateExpression`.\n */\n export const isEnumerateExpression = (node?: ASTNode): node is EnumerateExpression =>\n node?.kind === ASTKind.EnumerateExpression;\n\n /**\n * Check if the node is a `WrapArrayExpression`.\n */\n export const isWrapArrayExpression = (node?: ASTNode): node is WrapArrayExpression =>\n node?.kind === ASTKind.WrapArrayExpression;\n\n /**\n * Check if the node is a `KeyPathExpression`.\n */\n export const isKeyPathExpression = (node?: ASTNode): node is KeyPathExpression =>\n node?.kind === ASTKind.KeyPathExpression;\n\n /**\n * Check ASTNode Match by ASTClass\n *\n * @param node ASTNode to be checked.\n * @param targetType Target ASTNode class.\n * @returns Whether the node is of the target type.\n */\n export function is<TargetASTNode extends ASTNode>(\n node?: ASTNode,\n targetType?: { kind: string; new (...args: any[]): TargetASTNode }\n ): node is TargetASTNode {\n return node?.kind === targetType?.kind;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTMatch } from '../match';\nimport { ASTNode } from '../ast-node';\n\nexport function updateChildNodeHelper(\n this: ASTNode,\n {\n getChildNode,\n updateChildNode,\n removeChildNode,\n nextJSON,\n }: {\n getChildNode: () => ASTNode | undefined;\n updateChildNode: (nextNode: ASTNode) => void;\n removeChildNode: () => void;\n nextJSON?: ASTNodeJSON;\n }\n): ASTNode | undefined {\n const currNode: ASTNode | undefined = getChildNode();\n\n const isNewKind = currNode?.kind !== nextJSON?.kind;\n // If `nextJSON` does not pass a key value, the key value remains unchanged by default.\n const isNewKey = nextJSON?.key && nextJSON?.key !== currNode?.key;\n\n if (isNewKind || isNewKey) {\n // The previous node needs to be destroyed.\n if (currNode) {\n currNode.dispose();\n removeChildNode();\n }\n\n if (nextJSON) {\n const newNode = this.createChildNode(nextJSON);\n updateChildNode(newNode);\n this.fireChange();\n return newNode;\n } else {\n // Also trigger an update when deleting a child node directly.\n this.fireChange();\n }\n } else if (nextJSON) {\n currNode?.fromJSON(nextJSON);\n }\n\n return currNode;\n}\n\nexport function parseTypeJsonOrKind(typeJSONOrKind?: ASTNodeJSONOrKind): ASTNodeJSON | undefined {\n return typeof typeJSONOrKind === 'string' ? { kind: typeJSONOrKind } : typeJSONOrKind;\n}\n\n// Get all children.\nexport function getAllChildren(ast: ASTNode): ASTNode[] {\n return [...ast.children, ...ast.children.map((_child) => getAllChildren(_child)).flat()];\n}\n\n/**\n * isMatchAST is same as ASTMatch.is\n * @param node\n * @param targetType\n * @returns\n */\nexport function isMatchAST<TargetASTNode extends ASTNode>(\n node?: ASTNode,\n targetType?: { kind: string; new (...args: any[]): TargetASTNode }\n): node is TargetASTNode {\n return ASTMatch.is(node, targetType);\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n BehaviorSubject,\n animationFrameScheduler,\n debounceTime,\n distinctUntilChanged,\n map,\n skip,\n tap,\n} from 'rxjs';\nimport { nanoid } from 'nanoid';\nimport { shallowEqual } from 'fast-equals';\nimport { Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from '../utils/toDisposable';\nimport { updateChildNodeHelper } from './utils/helpers';\nimport { type Scope } from '../scope';\nimport {\n type ASTNodeJSON,\n type ObserverOrNext,\n type ASTKindType,\n type CreateASTParams,\n type Identifier,\n SubscribeConfig,\n GlobalEventActionType,\n DisposeASTAction,\n UpdateASTAction,\n} from './types';\nimport { ASTNodeFlags } from './flags';\n\nexport interface ASTNodeRegistry<JSON extends ASTNodeJSON = any, InjectOpts = any> {\n kind: string;\n new (params: CreateASTParams, injectOpts: InjectOpts): ASTNode<JSON>;\n}\n\n/**\n * An `ASTNode` represents a fundamental unit of variable information within the system's Abstract Syntax Tree.\n * It can model various constructs, for example:\n * - **Declarations**: `const a = 1`\n * - **Expressions**: `a.b.c`\n * - **Types**: `number`, `string`, `boolean`\n *\n * Here is some characteristic of ASTNode:\n * - **Tree-like Structure**: ASTNodes can be nested to form a tree, representing complex variable structures.\n * - **Extendable**: New features can be added by extending the base ASTNode class.\n * - **Reactive**: Changes in an ASTNode's value trigger events, enabling reactive programming patterns.\n * - **Serializable**: ASTNodes can be converted to and from a JSON format (ASTNodeJSON) for storage or transmission.\n */\nexport abstract class ASTNode<JSON extends ASTNodeJSON = any, InjectOpts = any>\n implements Disposable\n{\n /**\n * @deprecated\n * Get the injected options for the ASTNode.\n *\n * Please use `@injectToAst(XXXService) declare xxxService: XXXService` to achieve external dependency injection.\n */\n public readonly opts?: InjectOpts;\n\n /**\n * The unique identifier of the ASTNode, which is **immutable**.\n * - Immutable: Once assigned, the key cannot be changed.\n * - Automatically generated if not specified, and cannot be changed as well.\n * - If a new key needs to be generated, the current ASTNode should be destroyed and a new ASTNode should be generated.\n */\n public readonly key: Identifier;\n\n /**\n * The kind of the ASTNode.\n */\n static readonly kind: ASTKindType;\n\n /**\n * Node flags, used to record some flag information.\n */\n public readonly flags: number = ASTNodeFlags.None;\n\n /**\n * The scope in which the ASTNode is located.\n */\n public readonly scope: Scope;\n\n /**\n * The parent ASTNode.\n */\n public readonly parent: ASTNode | undefined;\n\n /**\n * The version number of the ASTNode, which increments by 1 each time `fireChange` is called.\n */\n protected _version: number = 0;\n\n /**\n * Update lock.\n * - When set to `true`, `fireChange` will not trigger any events.\n * - This is useful when multiple updates are needed, and you want to avoid multiple triggers.\n */\n public changeLocked = false;\n\n /**\n * Parameters related to batch updates.\n */\n private _batch: {\n batching: boolean;\n hasChangesInBatch: boolean;\n } = {\n batching: false,\n hasChangesInBatch: false,\n };\n\n /**\n * AST node change Observable events, implemented based on RxJS.\n * - Emits the current ASTNode value upon subscription.\n * - Emits a new value whenever `fireChange` is called.\n */\n public readonly value$: BehaviorSubject<ASTNode> = new BehaviorSubject<ASTNode>(this as ASTNode);\n\n /**\n * Child ASTNodes.\n */\n protected _children = new Set<ASTNode>();\n\n /**\n * List of disposal handlers for the ASTNode.\n */\n public readonly toDispose: DisposableCollection = new DisposableCollection(\n Disposable.create(() => {\n // When a child element is deleted, the parent element triggers an update.\n this.parent?.fireChange();\n this.children.forEach((child) => child.dispose());\n })\n );\n\n /**\n * Callback triggered upon disposal.\n */\n onDispose = this.toDispose.onDispose;\n\n /**\n * Constructor.\n * @param createParams Necessary parameters for creating an ASTNode.\n * @param injectOptions Dependency injection for various modules.\n */\n constructor({ key, parent, scope }: CreateASTParams, opts?: InjectOpts) {\n this.scope = scope;\n this.parent = parent;\n this.opts = opts;\n\n // Initialize the key value. If a key is passed in, use it; otherwise, generate a random one using nanoid.\n this.key = key || nanoid();\n\n // All `fireChange` calls within the subsequent `fromJSON` will be merged into one.\n this.fromJSON = this.withBatchUpdate(this.fromJSON.bind(this));\n }\n\n /**\n * The type of the ASTNode.\n */\n get kind(): string {\n if (!(this.constructor as any).kind) {\n throw new Error(`ASTNode Registry need a kind: ${this.constructor.name}`);\n }\n return (this.constructor as any).kind;\n }\n\n /**\n * Parses AST JSON data.\n * @param json AST JSON data.\n */\n abstract fromJSON(json: JSON): void;\n\n /**\n * Gets all child ASTNodes of the current ASTNode.\n */\n get children(): ASTNode[] {\n return Array.from(this._children);\n }\n\n /**\n * Serializes the current ASTNode to ASTNodeJSON.\n * @returns\n */\n toJSON(): ASTNodeJSON {\n // Prompt the user to implement the toJSON method for the ASTNode themselves, instead of using the fallback implementation.\n console.warn('[VariableEngine] Please Implement toJSON method for ' + this.kind);\n\n return {\n kind: this.kind,\n };\n }\n\n /**\n * Creates a child ASTNode.\n * @param json The AST JSON of the child ASTNode.\n * @returns\n */\n protected createChildNode<ChildNode extends ASTNode = ASTNode>(json: ASTNodeJSON): ChildNode {\n const astRegisters = this.scope.variableEngine.astRegisters;\n\n const child = astRegisters.createAST(json, {\n parent: this,\n scope: this.scope,\n }) as ChildNode;\n\n // Add to the _children set.\n this._children.add(child);\n child.toDispose.push(\n Disposable.create(() => {\n this._children.delete(child);\n })\n );\n\n return child;\n }\n\n /**\n * Updates a child ASTNode, quickly implementing the consumption logic for child ASTNode updates.\n * @param keyInThis The specified key on the current object.\n */\n protected updateChildNodeByKey(keyInThis: keyof this, nextJSON?: ASTNodeJSON) {\n this.withBatchUpdate(updateChildNodeHelper).call(this, {\n getChildNode: () => this[keyInThis] as ASTNode,\n updateChildNode: (_node) => ((this as any)[keyInThis] = _node),\n removeChildNode: () => ((this as any)[keyInThis] = undefined),\n nextJSON,\n });\n }\n\n /**\n * Batch updates the ASTNode, merging all `fireChange` calls within the batch function into one.\n * @param updater The batch function.\n * @returns\n */\n protected withBatchUpdate<ParamTypes extends any[], ReturnType>(\n updater: (...args: ParamTypes) => ReturnType\n ) {\n return (...args: ParamTypes) => {\n // Nested batchUpdate can only take effect once.\n if (this._batch.batching) {\n return updater.call(this, ...args);\n }\n\n this._batch.hasChangesInBatch = false;\n\n this._batch.batching = true;\n const res = updater.call(this, ...args);\n this._batch.batching = false;\n\n if (this._batch.hasChangesInBatch) {\n this.fireChange();\n }\n this._batch.hasChangesInBatch = false;\n\n return res;\n };\n }\n\n /**\n * Triggers an update for the current node.\n */\n fireChange(): void {\n if (this.changeLocked || this.disposed) {\n return;\n }\n\n if (this._batch.batching) {\n this._batch.hasChangesInBatch = true;\n return;\n }\n\n this._version++;\n this.value$.next(this);\n this.dispatchGlobalEvent<UpdateASTAction>({ type: 'UpdateAST' });\n this.parent?.fireChange();\n }\n\n /**\n * The version value of the ASTNode.\n * - You can used to check whether ASTNode are updated.\n */\n get version(): number {\n return this._version;\n }\n\n /**\n * The unique hash value of the ASTNode.\n * - It will update when the ASTNode is updated.\n * - You can used to check two ASTNode are equal.\n */\n get hash(): string {\n return `${this._version}${this.kind}${this.key}`;\n }\n\n /**\n * Listens for changes to the ASTNode.\n * @param observer The listener callback.\n * @param selector Listens for specified data.\n * @returns\n */\n subscribe<Data = this>(\n observer: ObserverOrNext<Data>,\n { selector, debounceAnimation, triggerOnInit }: SubscribeConfig<this, Data> = {}\n ): Disposable {\n return subsToDisposable(\n this.value$\n .pipe(\n map(() => (selector ? selector(this) : (this as any))),\n distinctUntilChanged(\n (a, b) => shallowEqual(a, b),\n (value) => {\n if (value instanceof ASTNode) {\n // If the value is an ASTNode, compare its hash.\n return value.hash;\n }\n return value;\n }\n ),\n // By default, skip the first trigger of BehaviorSubject.\n triggerOnInit ? tap(() => null) : skip(1),\n // All updates within each animationFrame are merged into one.\n debounceAnimation ? debounceTime(0, animationFrameScheduler) : tap(() => null)\n )\n .subscribe(observer)\n );\n }\n\n /**\n * Dispatches a global event for the current ASTNode.\n * @param event The global event.\n */\n dispatchGlobalEvent<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n event: Omit<ActionType, 'ast'>\n ) {\n this.scope.event.dispatch({\n ...event,\n ast: this,\n });\n }\n\n /**\n * Disposes the ASTNode.\n */\n dispose(): void {\n // Prevent multiple disposals.\n if (this.toDispose.disposed) {\n return;\n }\n\n this.toDispose.dispose();\n this.dispatchGlobalEvent<DisposeASTAction>({ type: 'DisposeAST' });\n\n // When the complete event is emitted, ensure that the current ASTNode is in a disposed state.\n this.value$.complete();\n this.value$.unsubscribe();\n }\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n /**\n * Extended information of the ASTNode.\n */\n [key: string]: unknown;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\nimport { UnionJSON } from './union';\n\n/**\n * Base class for all types.\n *\n * All other types should extend this class.\n */\nexport abstract class BaseType<JSON extends ASTNodeJSON = any, InjectOpts = any> extends ASTNode<\n JSON,\n InjectOpts\n> {\n public flags: number = ASTNodeFlags.BasicType;\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n\n // If it is a Union type, it is sufficient for one of the subtypes to be equal.\n if (targetTypeJSON?.kind === ASTKind.Union) {\n return ((targetTypeJSON as UnionJSON)?.types || [])?.some((_subType) =>\n this.isTypeEqual(_subType)\n );\n }\n\n return this.kind === targetTypeJSON?.kind;\n }\n\n /**\n * Get a variable field by key path.\n *\n * This method should be implemented by drillable types.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[] = []): BaseVariableField | undefined {\n throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);\n }\n\n /**\n * Serialize the node to a JSON object.\n * @returns The JSON representation of the node.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: this.kind,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `ArrayType`\n */\nexport interface ArrayJSON {\n /**\n * The type of the items in the array.\n */\n items?: ASTNodeJSONOrKind;\n}\n\n/**\n * Represents an array type.\n */\nexport class ArrayType extends BaseType<ArrayJSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType | ASTNodeFlags.EnumerateType;\n\n static kind: string = ASTKind.Array;\n\n /**\n * The type of the items in the array.\n */\n items: BaseType;\n\n /**\n * Deserializes the `ArrayJSON` to the `ArrayType`.\n * @param json The `ArrayJSON` to deserialize.\n */\n fromJSON({ items }: ArrayJSON): void {\n this.updateChildNodeByKey('items', parseTypeJsonOrKind(items));\n }\n\n /**\n * Whether the items type can be drilled down.\n */\n get canDrilldownItems(): boolean {\n return !!(this.items?.flags & ASTNodeFlags.DrilldownType);\n }\n\n /**\n * Get a variable field by key path.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n const [curr, ...rest] = keyPath || [];\n\n if (curr === '0' && this.canDrilldownItems) {\n // The first item of the array.\n return this.items.getByKeyPath(rest);\n }\n\n return undefined;\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Array strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n if (!this.items) {\n return !(targetTypeJSON as ArrayJSON)?.items;\n }\n return this.items?.isTypeEqual((targetTypeJSON as ArrayJSON).items);\n }\n\n /**\n * Serialize the `ArrayType` to `ArrayJSON`\n * @returns The JSON representation of `ArrayType`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.Array,\n items: this.items?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of the `StringType`.\n */\nexport interface StringJSON {\n /**\n * see https://json-schema.org/understanding-json-schema/reference/type#format\n */\n format?: string;\n}\n\nexport class StringType extends BaseType {\n public flags: ASTNodeFlags = ASTNodeFlags.BasicType;\n\n static kind: string = ASTKind.String;\n\n protected _format?: string;\n\n /**\n * see https://json-schema.org/understanding-json-schema/reference/string#format\n */\n get format() {\n return this._format;\n }\n\n /**\n * Deserialize the `StringJSON` to the `StringType`.\n *\n * @param json StringJSON representation of the `StringType`.\n */\n fromJSON(json?: StringJSON): void {\n if (json?.format !== this._format) {\n this._format = json?.format;\n this.fireChange();\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseType } from './base-type';\n\n/**\n * Represents an integer type.\n */\nexport class IntegerType extends BaseType {\n public flags: ASTNodeFlags = ASTNodeFlags.BasicType;\n\n static kind: string = ASTKind.Integer;\n\n /**\n * Deserializes the `IntegerJSON` to the `IntegerType`.\n * @param json The `IntegerJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * Represents a boolean type.\n */\nexport class BooleanType extends BaseType {\n static kind: string = ASTKind.Boolean;\n\n /**\n * Deserializes the `BooleanJSON` to the `BooleanType`.\n * @param json The `BooleanJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * Represents a number type.\n */\nexport class NumberType extends BaseType {\n static kind: string = ASTKind.Number;\n\n /**\n * Deserializes the `NumberJSON` to the `NumberType`.\n * @param json The `NumberJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `MapType`\n */\nexport interface MapJSON {\n /**\n * The type of the keys in the map.\n */\n keyType?: ASTNodeJSONOrKind;\n /**\n * The type of the values in the map.\n */\n valueType?: ASTNodeJSONOrKind;\n}\n\n/**\n * Represents a map type.\n */\nexport class MapType extends BaseType<MapJSON> {\n static kind: string = ASTKind.Map;\n\n /**\n * The type of the keys in the map.\n */\n keyType: BaseType;\n\n /**\n * The type of the values in the map.\n */\n valueType: BaseType;\n\n /**\n * Deserializes the `MapJSON` to the `MapType`.\n * @param json The `MapJSON` to deserialize.\n */\n fromJSON({ keyType = ASTKind.String, valueType }: MapJSON): void {\n // Key defaults to String.\n this.updateChildNodeByKey('keyType', parseTypeJsonOrKind(keyType));\n this.updateChildNodeByKey('valueType', parseTypeJsonOrKind(valueType));\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Map strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n const { keyType = ASTKind.String, valueType } = targetTypeJSON as MapJSON;\n\n const isValueTypeEqual =\n (!valueType && !this.valueType) || this.valueType?.isTypeEqual(valueType);\n\n return isValueTypeEqual && this.keyType?.isTypeEqual(keyType);\n }\n\n /**\n * Serialize the node to a JSON object.\n * @returns The JSON representation of the node.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.Map,\n keyType: this.keyType?.toJSON(),\n valueType: this.valueType?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { xor } from 'lodash-es';\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTNodeJSON, ASTKind, ASTNodeJSONOrKind, type GlobalEventActionType } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { Property, type PropertyJSON } from '../declaration/property';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `ObjectType`\n */\nexport interface ObjectJSON<VariableMeta = any> {\n /**\n * The properties of the object.\n *\n * The `properties` of an Object must be of type `Property`, so the business can omit the `kind` field.\n */\n properties?: PropertyJSON<VariableMeta>[];\n}\n\n/**\n * Action type for object properties change.\n */\nexport type ObjectPropertiesChangeAction = GlobalEventActionType<\n 'ObjectPropertiesChange',\n {\n prev: Property[];\n next: Property[];\n },\n ObjectType\n>;\n\n/**\n * Represents an object type.\n */\nexport class ObjectType extends BaseType<ObjectJSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType;\n\n static kind: string = ASTKind.Object;\n\n /**\n * A map of property keys to `Property` instances.\n */\n propertyTable: Map<string, Property> = new Map();\n\n /**\n * An array of `Property` instances.\n */\n properties: Property[];\n\n /**\n * Deserializes the `ObjectJSON` to the `ObjectType`.\n * @param json The `ObjectJSON` to deserialize.\n */\n fromJSON({ properties }: ObjectJSON): void {\n const removedKeys = new Set(this.propertyTable.keys());\n const prev = [...(this.properties || [])];\n\n // Iterate over the new properties.\n this.properties = (properties || []).map((property: PropertyJSON) => {\n const existProperty = this.propertyTable.get(property.key);\n removedKeys.delete(property.key);\n\n if (existProperty) {\n existProperty.fromJSON(property as PropertyJSON);\n\n return existProperty;\n } else {\n const newProperty = this.createChildNode({\n ...property,\n kind: ASTKind.Property,\n }) as Property;\n\n this.fireChange();\n\n this.propertyTable.set(property.key, newProperty);\n // TODO: When a child node is actively destroyed, delete the information in the table.\n\n return newProperty;\n }\n });\n\n // Delete properties that no longer exist.\n removedKeys.forEach((key) => {\n const property = this.propertyTable.get(key);\n property?.dispose();\n this.propertyTable.delete(key);\n this.fireChange();\n });\n\n this.dispatchGlobalEvent<ObjectPropertiesChangeAction>({\n type: 'ObjectPropertiesChange',\n payload: {\n prev,\n next: [...this.properties],\n },\n });\n }\n\n /**\n * Serialize the `ObjectType` to `ObjectJSON`.\n * @returns The JSON representation of `ObjectType`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.Object,\n properties: this.properties.map((_property) => _property.toJSON()),\n };\n }\n\n /**\n * Get a variable field by key path.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[]): Property | undefined {\n const [curr, ...restKeyPath] = keyPath;\n\n const property = this.propertyTable.get(curr);\n\n // Found the end of the path.\n if (!restKeyPath.length) {\n return property;\n }\n\n // Otherwise, continue searching downwards.\n if (property?.type && property?.type?.flags & ASTNodeFlags.DrilldownType) {\n return property.type.getByKeyPath(restKeyPath) as Property | undefined;\n }\n\n return undefined;\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Object type strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n const targetProperties = (targetTypeJSON as ObjectJSON).properties || [];\n\n const sourcePropertyKeys = Array.from(this.propertyTable.keys());\n const targetPropertyKeys = targetProperties.map((_target) => _target.key);\n\n const isKeyStrongEqual = !xor(sourcePropertyKeys, targetPropertyKeys).length;\n\n return (\n isKeyStrongEqual &&\n targetProperties.every((targetProperty) => {\n const sourceProperty = this.propertyTable.get(targetProperty.key);\n\n return (\n sourceProperty &&\n sourceProperty.key === targetProperty.key &&\n sourceProperty.type?.isTypeEqual(targetProperty?.type)\n );\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSONOrKind } from '../types';\nimport { type UnionJSON } from './union';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `CustomType`\n */\nexport interface CustomTypeJSON {\n /**\n * The name of the custom type.\n */\n typeName: string;\n}\n\n/**\n * Represents a custom type.\n */\nexport class CustomType extends BaseType<CustomTypeJSON> {\n static kind: string = ASTKind.CustomType;\n\n protected _typeName: string;\n\n /**\n * The name of the custom type.\n */\n get typeName(): string {\n return this._typeName;\n }\n\n /**\n * Deserializes the `CustomTypeJSON` to the `CustomType`.\n * @param json The `CustomTypeJSON` to deserialize.\n */\n fromJSON(json: CustomTypeJSON): void {\n if (this._typeName !== json.typeName) {\n this._typeName = json.typeName;\n this.fireChange();\n }\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n\n // If it is a Union type, it is sufficient for one of the subtypes to be equal.\n if (targetTypeJSON?.kind === ASTKind.Union) {\n return ((targetTypeJSON as UnionJSON)?.types || [])?.some((_subType) =>\n this.isTypeEqual(_subType)\n );\n }\n\n return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n type Observable,\n distinctUntilChanged,\n map,\n switchMap,\n combineLatest,\n of,\n Subject,\n share,\n} from 'rxjs';\nimport { shallowEqual } from 'fast-equals';\n\nimport { getParentFields } from '../utils/variable-field';\nimport { ASTNodeJSON, type CreateASTParams } from '../types';\nimport { type BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { IVariableTable } from '../../scope/types';\n\ntype ExpressionRefs = (BaseVariableField | undefined)[];\n\n/**\n * Base class for all expressions.\n *\n * All other expressions should extend this class.\n */\nexport abstract class BaseExpression<\n JSON extends ASTNodeJSON = any,\n InjectOpts = any\n> extends ASTNode<JSON, InjectOpts> {\n public flags: ASTNodeFlags = ASTNodeFlags.Expression;\n\n /**\n * Get the global variable table, which is used to access referenced variables.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n /**\n * Parent variable fields, sorted from closest to farthest.\n */\n get parentFields(): BaseVariableField[] {\n return getParentFields(this);\n }\n\n /**\n * Get the variable fields referenced by the expression.\n *\n * This method should be implemented by subclasses.\n * @returns An array of referenced variable fields.\n */\n abstract getRefFields(): ExpressionRefs;\n\n /**\n * The return type of the expression.\n */\n abstract returnType: BaseType | undefined;\n\n /**\n * The variable fields referenced by the expression.\n */\n protected _refs: ExpressionRefs = [];\n\n /**\n * The variable fields referenced by the expression.\n */\n get refs(): ExpressionRefs {\n return this._refs;\n }\n\n protected refreshRefs$: Subject<void> = new Subject();\n\n /**\n * Refresh the variable references.\n */\n refreshRefs() {\n this.refreshRefs$.next();\n }\n\n /**\n * An observable that emits the referenced variable fields when they change.\n */\n refs$: Observable<ExpressionRefs> = this.refreshRefs$.pipe(\n map(() => this.getRefFields()),\n distinctUntilChanged<ExpressionRefs>(shallowEqual),\n switchMap((refs) =>\n !refs?.length\n ? of([])\n : combineLatest(\n refs.map((ref) =>\n ref\n ? (ref.value$ as unknown as Observable<BaseVariableField | undefined>)\n : of(undefined)\n )\n )\n ),\n share()\n );\n\n constructor(params: CreateASTParams, opts?: InjectOpts) {\n super(params, opts);\n\n this.toDispose.push(\n subsToDisposable(\n this.refs$.subscribe((_refs: ExpressionRefs) => {\n this._refs = _refs;\n this.fireChange();\n })\n )\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTNodeFlags } from '../flags';\nimport { BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\n\n/**\n * Parent variable fields, sorted from nearest to farthest.\n */\nexport function getParentFields(ast: ASTNode): BaseVariableField[] {\n let curr = ast.parent;\n const res: BaseVariableField[] = [];\n\n while (curr) {\n if (curr.flags & ASTNodeFlags.VariableField) {\n res.push(curr as BaseVariableField);\n }\n curr = curr.parent;\n }\n\n return res;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ArrayType } from '../type/array';\nimport { BaseType } from '../type';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `EnumerateExpression`\n */\nexport interface EnumerateExpressionJSON {\n /**\n * The expression to be enumerated.\n */\n enumerateFor: ASTNodeJSON;\n}\n\n/**\n * Represents an enumeration expression, which iterates over a list and returns the type of the enumerated variable.\n */\nexport class EnumerateExpression extends BaseExpression<EnumerateExpressionJSON> {\n static kind: string = ASTKind.EnumerateExpression;\n\n protected _enumerateFor: BaseExpression | undefined;\n\n /**\n * The expression to be enumerated.\n */\n get enumerateFor() {\n return this._enumerateFor;\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n // The return value of the enumerated expression.\n const childReturnType = this.enumerateFor?.returnType;\n\n if (childReturnType?.kind === ASTKind.Array) {\n // Get the item type of the array.\n return (childReturnType as ArrayType).items;\n }\n\n return undefined;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An empty array, as this expression does not reference any variables.\n */\n getRefFields(): [] {\n return [];\n }\n\n /**\n * Deserializes the `EnumerateExpressionJSON` to the `EnumerateExpression`.\n * @param json The `EnumerateExpressionJSON` to deserialize.\n */\n fromJSON({ enumerateFor: expression }: EnumerateExpressionJSON): void {\n this.updateChildNodeByKey('_enumerateFor', expression);\n }\n\n /**\n * Serialize the `EnumerateExpression` to `EnumerateExpressionJSON`.\n * @returns The JSON representation of `EnumerateExpression`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.EnumerateExpression,\n enumerateFor: this.enumerateFor?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { checkRefCycle } from '../utils/expression';\nimport { ASTNodeJSON, ASTKind, CreateASTParams } from '../types';\nimport { BaseType } from '../type';\nimport { type BaseVariableField } from '../declaration';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `KeyPathExpression`\n */\nexport interface KeyPathExpressionJSON {\n /**\n * The key path of the variable.\n */\n keyPath: string[];\n}\n\n/**\n * Represents a key path expression, which is used to reference a variable by its key path.\n *\n * This is the V2 of `KeyPathExpression`, with the following improvements:\n * - `returnType` is copied to a new instance to avoid reference issues.\n * - Circular reference detection is introduced.\n */\nexport class KeyPathExpression<\n CustomPathJSON extends ASTNodeJSON = KeyPathExpressionJSON\n> extends BaseExpression<CustomPathJSON> {\n static kind: string = ASTKind.KeyPathExpression;\n\n protected _keyPath: string[] = [];\n\n /**\n * The key path of the variable.\n */\n get keyPath(): string[] {\n return this._keyPath;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An array of referenced variable fields.\n */\n getRefFields(): BaseVariableField[] {\n const ref = this.scope.available.getByKeyPath(this._keyPath);\n\n // When refreshing references, check for circular references. If a circular reference exists, do not reference the variable.\n if (checkRefCycle(this, [ref])) {\n // Prompt that a circular reference exists.\n console.warn(\n '[CustomKeyPathExpression] checkRefCycle: Reference Cycle Existed',\n this.parentFields.map((_field) => _field.key).reverse()\n );\n return [];\n }\n\n return ref ? [ref] : [];\n }\n\n /**\n * The return type of the expression.\n *\n * A new `returnType` node is generated directly, instead of reusing the existing one, to ensure that different key paths do not point to the same field.\n */\n _returnType: BaseType;\n\n /**\n * The return type of the expression.\n */\n get returnType() {\n return this._returnType;\n }\n\n /**\n * Parse the business-defined path expression into a key path.\n *\n * Businesses can quickly customize their own path expressions by modifying this method.\n * @param json The path expression defined by the business.\n * @returns The key path.\n */\n protected parseToKeyPath(json: CustomPathJSON): string[] {\n // The default JSON is in KeyPathExpressionJSON format.\n return (json as unknown as KeyPathExpressionJSON).keyPath;\n }\n\n /**\n * Deserializes the `KeyPathExpressionJSON` to the `KeyPathExpression`.\n * @param json The `KeyPathExpressionJSON` to deserialize.\n */\n fromJSON(json: CustomPathJSON): void {\n const keyPath = this.parseToKeyPath(json);\n\n if (!shallowEqual(keyPath, this._keyPath)) {\n this._keyPath = keyPath;\n\n // After the keyPath is updated, the referenced variables need to be refreshed.\n this.refreshRefs();\n }\n }\n\n /**\n * Get the return type JSON by reference.\n * @param _ref The referenced variable field.\n * @returns The JSON representation of the return type.\n */\n getReturnTypeJSONByRef(_ref: BaseVariableField | undefined): ASTNodeJSON | undefined {\n return _ref?.type?.toJSON();\n }\n\n protected prevRefTypeHash: string | undefined;\n\n constructor(params: CreateASTParams, opts: any) {\n super(params, opts);\n\n this.toDispose.pushAll([\n // Can be used when the variable list changes (when there are additions or deletions).\n this.scope.available.onVariableListChange(() => {\n this.refreshRefs();\n }),\n // When the referable variable pointed to by this._keyPath changes, refresh the reference data.\n this.scope.available.onAnyVariableChange((_v) => {\n if (_v.key === this._keyPath[0]) {\n this.refreshRefs();\n }\n }),\n subsToDisposable(\n this.refs$.subscribe((_type) => {\n const [ref] = this._refs;\n\n if (this.prevRefTypeHash !== ref?.type?.hash) {\n this.prevRefTypeHash = ref?.type?.hash;\n this.updateChildNodeByKey('_returnType', this.getReturnTypeJSONByRef(ref));\n }\n })\n ),\n ]);\n }\n\n /**\n * Serialize the `KeyPathExpression` to `KeyPathExpressionJSON`.\n * @returns The JSON representation of `KeyPathExpression`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.KeyPathExpression,\n keyPath: this._keyPath,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { intersection } from 'lodash-es';\n\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseExpression } from '../expression';\nimport { type BaseVariableField } from '../declaration';\nimport { type ASTNode } from '../ast-node';\nimport { getParentFields } from './variable-field';\nimport { getAllChildren } from './helpers';\n\n/**\n * Get all variables referenced by child ASTs.\n * @param ast The ASTNode to traverse.\n * @returns All variables referenced by child ASTs.\n */\nexport function getAllRefs(ast: ASTNode): BaseVariableField[] {\n return getAllChildren(ast)\n .filter((_child) => _child.flags & ASTNodeFlags.Expression)\n .map((_child) => (_child as BaseExpression).refs)\n .flat()\n .filter(Boolean) as BaseVariableField[];\n}\n\n/**\n * Checks for circular references.\n * @param curr The current expression.\n * @param refNode The referenced variable node.\n * @returns Whether a circular reference exists.\n */\nexport function checkRefCycle(\n curr: BaseExpression,\n refNodes: (BaseVariableField | undefined)[]\n): boolean {\n // If there are no circular references in the scope, then it is impossible to have a circular reference.\n if (\n intersection(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean))\n .length === 0\n ) {\n return false;\n }\n\n // BFS traversal.\n const visited = new Set<BaseVariableField>();\n const queue = [...refNodes];\n\n while (queue.length) {\n const currNode = queue.shift()!;\n visited.add(currNode);\n\n for (const ref of getAllRefs(currNode).filter((_ref) => !visited.has(_ref))) {\n queue.push(ref);\n }\n }\n\n // If the referenced variables include the parent variable of the expression, then there is a circular reference.\n return intersection(Array.from(visited), getParentFields(curr)).length > 0;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { ASTNodeJSON, ASTKind, CreateASTParams } from '../types';\nimport { BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `KeyPathExpression`\n */\nexport interface KeyPathExpressionJSON {\n /**\n * The key path of the variable.\n */\n keyPath: string[];\n}\n\n/**\n * @deprecated Use `KeyPathExpression` instead.\n * Represents a key path expression, which is used to reference a variable by its key path.\n */\nexport class LegacyKeyPathExpression<\n CustomPathJSON extends ASTNodeJSON = KeyPathExpressionJSON\n> extends BaseExpression<CustomPathJSON> {\n static kind: string = ASTKind.KeyPathExpression;\n\n protected _keyPath: string[] = [];\n\n /**\n * The key path of the variable.\n */\n get keyPath(): string[] {\n return this._keyPath;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An array of referenced variable fields.\n */\n getRefFields(): BaseVariableField[] {\n const ref = this.scope.available.getByKeyPath(this._keyPath);\n return ref ? [ref] : [];\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n const [refNode] = this._refs || [];\n\n // Get the type of the referenced variable.\n if (refNode && refNode.flags & ASTNodeFlags.VariableField) {\n return refNode.type;\n }\n\n return;\n }\n\n /**\n * Parse the business-defined path expression into a key path.\n *\n * Businesses can quickly customize their own path expressions by modifying this method.\n * @param json The path expression defined by the business.\n * @returns The key path.\n */\n protected parseToKeyPath(json: CustomPathJSON): string[] {\n // The default JSON is in KeyPathExpressionJSON format.\n return (json as unknown as KeyPathExpressionJSON).keyPath;\n }\n\n /**\n * Deserializes the `KeyPathExpressionJSON` to the `KeyPathExpression`.\n * @param json The `KeyPathExpressionJSON` to deserialize.\n */\n fromJSON(json: CustomPathJSON): void {\n const keyPath = this.parseToKeyPath(json);\n\n if (!shallowEqual(keyPath, this._keyPath)) {\n this._keyPath = keyPath;\n\n // After the keyPath is updated, the referenced variables need to be refreshed.\n this.refreshRefs();\n }\n }\n\n constructor(params: CreateASTParams, opts: any) {\n super(params, opts);\n\n this.toDispose.pushAll([\n // Can be used when the variable list changes (when there are additions or deletions).\n this.scope.available.onVariableListChange(() => {\n this.refreshRefs();\n }),\n // When the referable variable pointed to by this._keyPath changes, refresh the reference data.\n this.scope.available.onAnyVariableChange((_v) => {\n if (_v.key === this._keyPath[0]) {\n this.refreshRefs();\n }\n }),\n ]);\n }\n\n /**\n * Serialize the `KeyPathExpression` to `KeyPathExpressionJSON`.\n * @returns The JSON representation of `KeyPathExpression`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.KeyPathExpression,\n keyPath: this._keyPath,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { postConstructAST } from '../utils/inversify';\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { BaseType } from '../type';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `WrapArrayExpression`\n */\nexport interface WrapArrayExpressionJSON {\n /**\n * The expression to be wrapped.\n */\n wrapFor: ASTNodeJSON;\n}\n\n/**\n * Represents a wrap expression, which wraps an expression with an array.\n */\nexport class WrapArrayExpression extends BaseExpression<WrapArrayExpressionJSON> {\n static kind: string = ASTKind.WrapArrayExpression;\n\n protected _wrapFor: BaseExpression | undefined;\n\n protected _returnType: BaseType | undefined;\n\n /**\n * The expression to be wrapped.\n */\n get wrapFor() {\n return this._wrapFor;\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n return this._returnType;\n }\n\n /**\n * Refresh the return type of the expression.\n */\n refreshReturnType() {\n // The return value of the wrapped expression.\n const childReturnTypeJSON = this.wrapFor?.returnType?.toJSON();\n\n this.updateChildNodeByKey('_returnType', {\n kind: ASTKind.Array,\n items: childReturnTypeJSON,\n });\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An empty array, as this expression does not reference any variables.\n */\n getRefFields(): [] {\n return [];\n }\n\n /**\n * Deserializes the `WrapArrayExpressionJSON` to the `WrapArrayExpression`.\n * @param json The `WrapArrayExpressionJSON` to deserialize.\n */\n fromJSON({ wrapFor: expression }: WrapArrayExpressionJSON): void {\n this.updateChildNodeByKey('_wrapFor', expression);\n }\n\n /**\n * Serialize the `WrapArrayExpression` to `WrapArrayExpressionJSON`.\n * @returns The JSON representation of `WrapArrayExpression`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.WrapArrayExpression,\n wrapFor: this.wrapFor?.toJSON(),\n };\n }\n\n @postConstructAST()\n protected init() {\n this.refreshReturnType = this.refreshReturnType.bind(this);\n\n this.toDispose.push(\n this.subscribe(this.refreshReturnType, {\n selector: (curr) => curr.wrapFor?.returnType,\n triggerOnInit: true,\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { getParentFields } from '../utils/variable-field';\nimport { ASTNodeJSON, ASTNodeJSONOrKind, Identifier } from '../types';\nimport { type BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseExpression } from '../expression';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `BaseVariableField`\n */\nexport type BaseVariableFieldJSON<VariableMeta = any> = {\n /**\n * key of the variable field\n * - For `VariableDeclaration`, the key should be global unique.\n * - For `Property`, the key is the property name.\n */\n key?: Identifier;\n /**\n * type of the variable field, similar to js code:\n * `const v: string`\n */\n type?: ASTNodeJSONOrKind;\n /**\n * initializer of the variable field, similar to js code:\n * `const v = 'hello'`\n *\n * with initializer, the type of field will be inferred from the initializer.\n */\n initializer?: ASTNodeJSON;\n /**\n * meta data of the variable field, you cans store information like `title`, `icon`, etc.\n */\n meta?: VariableMeta;\n};\n\n/**\n * Variable Field abstract class, which is the base class for `VariableDeclaration` and `Property`\n *\n * - `VariableDeclaration` is used to declare a variable in a block scope.\n * - `Property` is used to declare a property in an object.\n */\nexport abstract class BaseVariableField<VariableMeta = any> extends ASTNode<\n BaseVariableFieldJSON<VariableMeta>\n> {\n public flags: ASTNodeFlags = ASTNodeFlags.VariableField;\n\n protected _type?: BaseType;\n\n protected _meta: VariableMeta = {} as any;\n\n protected _initializer?: BaseExpression;\n\n /**\n * Parent variable fields, sorted from closest to farthest\n */\n get parentFields(): BaseVariableField[] {\n return getParentFields(this);\n }\n\n /**\n * KeyPath of the variable field, sorted from farthest to closest\n */\n get keyPath(): string[] {\n return [...this.parentFields.reverse().map((_field) => _field.key), this.key];\n }\n\n /**\n * Metadata of the variable field, you cans store information like `title`, `icon`, etc.\n */\n get meta(): VariableMeta {\n return this._meta;\n }\n\n /**\n * Type of the variable field, similar to js code:\n * `const v: string`\n */\n get type(): BaseType {\n return (this._initializer?.returnType || this._type)!;\n }\n\n /**\n * Initializer of the variable field, similar to js code:\n * `const v = 'hello'`\n *\n * with initializer, the type of field will be inferred from the initializer.\n */\n get initializer(): BaseExpression | undefined {\n return this._initializer;\n }\n\n /**\n * The global unique hash of the field, and will be changed when the field is updated.\n */\n get hash(): string {\n return `[${this._version}]${this.keyPath.join('.')}`;\n }\n\n /**\n * Deserialize the `BaseVariableFieldJSON` to the `BaseVariableField`.\n * @param json ASTJSON representation of `BaseVariableField`\n */\n fromJSON({ type, initializer, meta }: BaseVariableFieldJSON<VariableMeta>): void {\n // 类型变化\n this.updateType(type);\n\n // 表达式更新\n this.updateInitializer(initializer);\n\n // Extra 更新\n this.updateMeta(meta!);\n }\n\n /**\n * Update the type of the variable field\n * @param type type ASTJSON representation of Type\n */\n updateType(type: BaseVariableFieldJSON['type']) {\n const nextTypeJson = typeof type === 'string' ? { kind: type } : type;\n this.updateChildNodeByKey('_type', nextTypeJson);\n }\n\n /**\n * Update the initializer of the variable field\n * @param nextInitializer initializer ASTJSON representation of Expression\n */\n updateInitializer(nextInitializer?: BaseVariableFieldJSON['initializer']) {\n this.updateChildNodeByKey('_initializer', nextInitializer);\n }\n\n /**\n * Update the meta data of the variable field\n * @param nextMeta meta data of the variable field\n */\n updateMeta(nextMeta: VariableMeta) {\n if (!shallowEqual(nextMeta, this._meta)) {\n this._meta = nextMeta;\n this.fireChange();\n }\n }\n\n /**\n * Get the variable field by keyPath, similar to js code:\n * `v.a.b`\n * @param keyPath\n * @returns\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n if (this.type?.flags & ASTNodeFlags.DrilldownType) {\n return this.type.getByKeyPath(keyPath) as BaseVariableField | undefined;\n }\n\n return undefined;\n }\n\n /**\n * Subscribe to type change of the variable field\n * @param observer\n * @returns\n */\n onTypeChange(observer: (type: ASTNode | undefined) => void) {\n return this.subscribe(observer, { selector: (curr) => curr.type });\n }\n\n /**\n * Serialize the variable field to JSON\n * @returns ASTNodeJSON representation of `BaseVariableField`\n */\n toJSON(): BaseVariableFieldJSON<VariableMeta> & { kind: string } {\n return {\n kind: this.kind,\n key: this.key,\n type: this.type?.toJSON(),\n initializer: this.initializer?.toJSON(),\n meta: this._meta,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, GlobalEventActionType, type CreateASTParams } from '../types';\nimport { BaseVariableField, BaseVariableFieldJSON } from './base-variable-field';\n\n/**\n * ASTNodeJSON representation of the `VariableDeclaration`.\n */\nexport type VariableDeclarationJSON<VariableMeta = any> = BaseVariableFieldJSON<VariableMeta> & {\n /**\n * Variable sorting order, which is used to sort variables in `scope.outputs.variables`\n */\n order?: number;\n};\n\n/**\n * Action type for re-sorting variable declarations.\n */\nexport type ReSortVariableDeclarationsAction = GlobalEventActionType<'ReSortVariableDeclarations'>;\n\n/**\n * `VariableDeclaration` is a variable field that represents a variable declaration.\n */\nexport class VariableDeclaration<VariableMeta = any> extends BaseVariableField<VariableMeta> {\n static kind: string = ASTKind.VariableDeclaration;\n\n protected _order: number = 0;\n\n /**\n * Variable sorting order, which is used to sort variables in `scope.outputs.variables`\n */\n get order(): number {\n return this._order;\n }\n\n constructor(params: CreateASTParams) {\n super(params);\n }\n\n /**\n * Deserialize the `VariableDeclarationJSON` to the `VariableDeclaration`.\n */\n fromJSON({ order, ...rest }: VariableDeclarationJSON<VariableMeta>): void {\n // Update order.\n this.updateOrder(order);\n\n // Update other information.\n super.fromJSON(rest as BaseVariableFieldJSON<VariableMeta>);\n }\n\n /**\n * Update the sorting order of the variable declaration.\n * @param order Variable sorting order. Default is 0.\n */\n updateOrder(order: number = 0): void {\n if (order !== this._order) {\n this._order = order;\n this.dispatchGlobalEvent<ReSortVariableDeclarationsAction>({\n type: 'ReSortVariableDeclarations',\n });\n this.fireChange();\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { GlobalEventActionType } from '../types';\nimport { ASTNode } from '../ast-node';\nimport { type VariableDeclarationJSON, VariableDeclaration } from './variable-declaration';\n\nexport interface VariableDeclarationListJSON<VariableMeta = any> {\n /**\n * `declarations` must be of type `VariableDeclaration`, so the business can omit the `kind` field.\n */\n declarations?: VariableDeclarationJSON<VariableMeta>[];\n /**\n * The starting order number for variables.\n */\n startOrder?: number;\n}\n\nexport type VariableDeclarationListChangeAction = GlobalEventActionType<\n 'VariableListChange',\n {\n prev: VariableDeclaration[];\n next: VariableDeclaration[];\n },\n VariableDeclarationList\n>;\n\nexport class VariableDeclarationList extends ASTNode<VariableDeclarationListJSON> {\n static kind: string = ASTKind.VariableDeclarationList;\n\n /**\n * Map of variable declarations, keyed by variable name.\n */\n declarationTable: Map<string, VariableDeclaration> = new Map();\n\n /**\n * Variable declarations, sorted by `order`.\n */\n declarations: VariableDeclaration[];\n\n /**\n * Deserialize the `VariableDeclarationListJSON` to the `VariableDeclarationList`.\n * - VariableDeclarationListChangeAction will be dispatched after deserialization.\n *\n * @param declarations Variable declarations.\n * @param startOrder The starting order number for variables. Default is 0.\n */\n fromJSON({ declarations, startOrder }: VariableDeclarationListJSON): void {\n const removedKeys = new Set(this.declarationTable.keys());\n const prev = [...(this.declarations || [])];\n\n // Iterate over the new properties.\n this.declarations = (declarations || []).map(\n (declaration: VariableDeclarationJSON, idx: number) => {\n const order = (startOrder || 0) + idx;\n\n // If the key is not set, reuse the previous key.\n const declarationKey = declaration.key || this.declarations?.[idx]?.key;\n const existDeclaration = this.declarationTable.get(declarationKey);\n if (declarationKey) {\n removedKeys.delete(declarationKey);\n }\n\n if (existDeclaration) {\n existDeclaration.fromJSON({ order, ...declaration });\n\n return existDeclaration;\n } else {\n const newDeclaration = this.createChildNode({\n order,\n ...declaration,\n kind: ASTKind.VariableDeclaration,\n }) as VariableDeclaration;\n this.fireChange();\n\n this.declarationTable.set(newDeclaration.key, newDeclaration);\n\n return newDeclaration;\n }\n }\n );\n\n // Delete variables that no longer exist.\n removedKeys.forEach((key) => {\n const declaration = this.declarationTable.get(key);\n declaration?.dispose();\n this.declarationTable.delete(key);\n });\n\n this.dispatchGlobalEvent<VariableDeclarationListChangeAction>({\n type: 'VariableListChange',\n payload: {\n prev,\n next: [...this.declarations],\n },\n });\n }\n\n /**\n * Serialize the `VariableDeclarationList` to the `VariableDeclarationListJSON`.\n * @returns ASTJSON representation of `VariableDeclarationList`\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.VariableDeclarationList,\n declarations: this.declarations.map((_declaration) => _declaration.toJSON()),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseVariableField, BaseVariableFieldJSON } from './base-variable-field';\n\n/**\n * ASTNodeJSON representation of the `Property`.\n */\nexport type PropertyJSON<VariableMeta = any> = BaseVariableFieldJSON<VariableMeta> & {\n // Key is a required field.\n key: string;\n};\n\n/**\n * `Property` is a variable field that represents a property of a `ObjectType`.\n */\nexport class Property<VariableMeta = any> extends BaseVariableField<VariableMeta> {\n static kind: string = ASTKind.Property;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * Represents a general data node with no child nodes.\n */\nexport class DataNode<Data = any> extends ASTNode {\n static kind: string = ASTKind.DataNode;\n\n protected _data: Data;\n\n /**\n * The data of the node.\n */\n get data(): Data {\n return this._data;\n }\n\n /**\n * Deserializes the `DataNodeJSON` to the `DataNode`.\n * @param json The `DataNodeJSON` to deserialize.\n */\n fromJSON(json: Data): void {\n const { kind, ...restData } = json as ASTNodeJSON;\n\n if (!shallowEqual(restData, this._data)) {\n this._data = restData as unknown as Data;\n this.fireChange();\n }\n }\n\n /**\n * Serialize the `DataNode` to `DataNodeJSON`.\n * @returns The JSON representation of `DataNode`.\n */\n toJSON() {\n return {\n kind: ASTKind.DataNode,\n ...this._data,\n };\n }\n\n /**\n * Partially update the data of the node.\n * @param nextData The data to be updated.\n */\n partialUpdate(nextData: Data) {\n if (!shallowEqual(nextData, this._data)) {\n this._data = {\n ...this._data,\n ...nextData,\n };\n this.fireChange();\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `ListNode`\n */\nexport interface ListNodeJSON {\n /**\n * The list of nodes.\n */\n list: ASTNodeJSON[];\n}\n\n/**\n * Represents a list of nodes.\n */\nexport class ListNode extends ASTNode<ListNodeJSON> {\n static kind: string = ASTKind.ListNode;\n\n protected _list: ASTNode[];\n\n /**\n * The list of nodes.\n */\n get list(): ASTNode[] {\n return this._list;\n }\n\n /**\n * Deserializes the `ListNodeJSON` to the `ListNode`.\n * @param json The `ListNodeJSON` to deserialize.\n */\n fromJSON({ list }: ListNodeJSON): void {\n // Children that exceed the length need to be destroyed.\n this._list.slice(list.length).forEach((_item) => {\n _item.dispose();\n this.fireChange();\n });\n\n // Processing of remaining children.\n this._list = list.map((_item, idx) => {\n const prevItem = this._list[idx];\n\n if (prevItem.kind !== _item.kind) {\n prevItem.dispose();\n this.fireChange();\n return this.createChildNode(_item);\n }\n\n prevItem.fromJSON(_item);\n return prevItem;\n });\n }\n\n /**\n * Serialize the `ListNode` to `ListNodeJSON`.\n * @returns The JSON representation of `ListNode`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.ListNode,\n list: this._list.map((item) => item.toJSON()),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { updateChildNodeHelper } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `MapNode`\n */\nexport interface MapNodeJSON {\n /**\n * The map of nodes.\n */\n map: [string, ASTNodeJSON][];\n}\n\n/**\n * Represents a map of nodes.\n */\nexport class MapNode extends ASTNode<MapNodeJSON> {\n static kind: string = ASTKind.MapNode;\n\n protected map: Map<string, ASTNode> = new Map<string, ASTNode>();\n\n /**\n * Deserializes the `MapNodeJSON` to the `MapNode`.\n * @param json The `MapNodeJSON` to deserialize.\n */\n fromJSON({ map }: MapNodeJSON): void {\n const removedKeys = new Set(this.map.keys());\n\n for (const [key, item] of map || []) {\n removedKeys.delete(key);\n this.set(key, item);\n }\n\n for (const removeKey of Array.from(removedKeys)) {\n this.remove(removeKey);\n }\n }\n\n /**\n * Serialize the `MapNode` to `MapNodeJSON`.\n * @returns The JSON representation of `MapNode`.\n */\n toJSON(): ASTNodeJSON {\n return {\n kind: ASTKind.MapNode,\n map: Array.from(this.map.entries()),\n };\n }\n\n /**\n * Set a node in the map.\n * @param key The key of the node.\n * @param nextJSON The JSON representation of the node.\n * @returns The node instance.\n */\n set<Node extends ASTNode = ASTNode>(key: string, nextJSON: ASTNodeJSON): Node {\n return this.withBatchUpdate(updateChildNodeHelper).call(this, {\n getChildNode: () => this.get(key),\n removeChildNode: () => this.map.delete(key),\n updateChildNode: (nextNode) => this.map.set(key, nextNode),\n nextJSON,\n }) as Node;\n }\n\n /**\n * Remove a node from the map.\n * @param key The key of the node.\n */\n remove(key: string) {\n this.get(key)?.dispose();\n this.map.delete(key);\n this.fireChange();\n }\n\n /**\n * Get a node from the map.\n * @param key The key of the node.\n * @returns The node instance if found, otherwise `undefined`.\n */\n get<Node extends ASTNode = ASTNode>(key: string): Node | undefined {\n return this.map.get(key) as Node | undefined;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from './types';\nimport { StringJSON } from './type/string';\nimport { MapJSON } from './type/map';\nimport { ArrayJSON } from './type/array';\nimport { CustomTypeJSON, ObjectJSON, UnionJSON } from './type';\nimport {\n EnumerateExpressionJSON,\n KeyPathExpressionJSON,\n WrapArrayExpressionJSON,\n} from './expression';\nimport { PropertyJSON, VariableDeclarationJSON, VariableDeclarationListJSON } from './declaration';\nimport { ASTNode } from './ast-node';\n\n/**\n * Variable-core ASTNode factories.\n */\nexport namespace ASTFactory {\n /**\n * Type-related factories.\n */\n\n /**\n * Creates a `String` type node.\n */\n export const createString = (json?: StringJSON) => ({\n kind: ASTKind.String,\n ...(json || {}),\n });\n\n /**\n * Creates a `Number` type node.\n */\n export const createNumber = () => ({ kind: ASTKind.Number });\n\n /**\n * Creates a `Boolean` type node.\n */\n export const createBoolean = () => ({ kind: ASTKind.Boolean });\n\n /**\n * Creates an `Integer` type node.\n */\n export const createInteger = () => ({ kind: ASTKind.Integer });\n\n /**\n * Creates an `Object` type node.\n */\n export const createObject = (json: ObjectJSON) => ({\n kind: ASTKind.Object,\n ...json,\n });\n\n /**\n * Creates an `Array` type node.\n */\n export const createArray = (json: ArrayJSON) => ({\n kind: ASTKind.Array,\n ...json,\n });\n\n /**\n * Creates a `Map` type node.\n */\n export const createMap = (json: MapJSON) => ({\n kind: ASTKind.Map,\n ...json,\n });\n\n /**\n * Creates a `Union` type node.\n */\n export const createUnion = (json: UnionJSON) => ({\n kind: ASTKind.Union,\n ...json,\n });\n\n /**\n * Creates a `CustomType` node.\n */\n export const createCustomType = (json: CustomTypeJSON) => ({\n kind: ASTKind.CustomType,\n ...json,\n });\n\n /**\n * Declaration-related factories.\n */\n\n /**\n * Creates a `VariableDeclaration` node.\n */\n export const createVariableDeclaration = <VariableMeta = any>(\n json: VariableDeclarationJSON<VariableMeta>\n ) => ({\n kind: ASTKind.VariableDeclaration,\n ...json,\n });\n\n /**\n * Creates a `Property` node.\n */\n export const createProperty = <VariableMeta = any>(json: PropertyJSON<VariableMeta>) => ({\n kind: ASTKind.Property,\n ...json,\n });\n\n /**\n * Creates a `VariableDeclarationList` node.\n */\n export const createVariableDeclarationList = (json: VariableDeclarationListJSON) => ({\n kind: ASTKind.VariableDeclarationList,\n ...json,\n });\n\n /**\n * Expression-related factories.\n */\n\n /**\n * Creates an `EnumerateExpression` node.\n */\n export const createEnumerateExpression = (json: EnumerateExpressionJSON) => ({\n kind: ASTKind.EnumerateExpression,\n ...json,\n });\n\n /**\n * Creates a `KeyPathExpression` node.\n */\n export const createKeyPathExpression = (json: KeyPathExpressionJSON) => ({\n kind: ASTKind.KeyPathExpression,\n ...json,\n });\n\n /**\n * Creates a `WrapArrayExpression` node.\n */\n export const createWrapArrayExpression = (json: WrapArrayExpressionJSON) => ({\n kind: ASTKind.WrapArrayExpression,\n ...json,\n });\n\n /**\n * Create by AST Class.\n */\n\n /**\n * Creates Type-Safe ASTNodeJSON object based on the provided AST class.\n *\n * @param targetType Target ASTNode class.\n * @param json The JSON data for the node.\n * @returns The ASTNode JSON object.\n */\n export const create = <JSON extends ASTNodeJSON>(\n targetType: { kind: string; new (...args: any[]): ASTNode<JSON> },\n json: JSON\n ) => ({ kind: targetType.kind, ...json });\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { VariableTable } from '../variable-table';\nimport { IVariableTable } from '../types';\nimport { type Scope } from '../scope';\nimport { type VariableEngine } from '../../variable-engine';\nimport { createMemo } from '../../utils/memo';\nimport { NewASTAction } from '../../ast/types';\nimport { DisposeASTAction } from '../../ast/types';\nimport { ReSortVariableDeclarationsAction } from '../../ast/declaration/variable-declaration';\nimport { ASTKind, type VariableDeclaration } from '../../ast';\n\n/**\n * Manages the output variables of a scope.\n */\nexport class ScopeOutputData {\n protected variableTable: IVariableTable;\n\n protected memo = createMemo();\n\n /**\n * The variable engine instance.\n */\n get variableEngine(): VariableEngine {\n return this.scope.variableEngine;\n }\n\n /**\n * The global variable table from the variable engine.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n /**\n * The current version of the output data, which increments on each change.\n */\n get version() {\n return this.variableTable.version;\n }\n\n /**\n * @deprecated use onListOrAnyVarChange instead\n */\n get onDataChange() {\n return this.variableTable.onDataChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when the list of output variables changes.\n */\n get onVariableListChange() {\n return this.variableTable.onVariableListChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when any output variable's value changes.\n */\n get onAnyVariableChange() {\n return this.variableTable.onAnyVariableChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when the output variable list changes or any variable's value is updated.\n */\n get onListOrAnyVarChange() {\n return this.variableTable.onListOrAnyVarChange.bind(this.variableTable);\n }\n\n protected _hasChanges = false;\n\n constructor(public readonly scope: Scope) {\n // Setup scope variable table based on globalVariableTable\n this.variableTable = new VariableTable(scope.variableEngine.globalVariableTable);\n\n this.scope.toDispose.pushAll([\n // When the root AST node is updated, check if there are any changes.\n this.scope.ast.subscribe(() => {\n if (this._hasChanges) {\n this.memo.clear();\n this.notifyCoversChange();\n this.variableTable.fireChange();\n this._hasChanges = false;\n }\n }),\n this.scope.event.on<DisposeASTAction>('DisposeAST', (_action) => {\n if (_action.ast?.kind === ASTKind.VariableDeclaration) {\n this.removeVariableFromTable(_action.ast.key);\n }\n }),\n this.scope.event.on<NewASTAction>('NewAST', (_action) => {\n if (_action.ast?.kind === ASTKind.VariableDeclaration) {\n this.addVariableToTable(_action.ast as VariableDeclaration);\n }\n }),\n this.scope.event.on<ReSortVariableDeclarationsAction>('ReSortVariableDeclarations', () => {\n this._hasChanges = true;\n }),\n this.variableTable,\n ]);\n }\n\n /**\n * The output variable declarations of the scope, sorted by order.\n */\n get variables(): VariableDeclaration[] {\n return this.memo('variables', () =>\n this.variableTable.variables.sort((a, b) => a.order - b.order)\n );\n }\n\n /**\n * The keys of the output variables.\n */\n get variableKeys(): string[] {\n return this.memo('variableKeys', () => this.variableTable.variableKeys);\n }\n\n protected addVariableToTable(variable: VariableDeclaration) {\n if (variable.scope !== this.scope) {\n throw Error('VariableDeclaration must be a ast node in scope');\n }\n\n (this.variableTable as VariableTable).addVariableToTable(variable);\n this._hasChanges = true;\n }\n\n protected removeVariableFromTable(key: string) {\n (this.variableTable as VariableTable).removeVariableFromTable(key);\n this._hasChanges = true;\n }\n\n /**\n * Retrieves a variable declaration by its key.\n * @param key The key of the variable.\n * @returns The `VariableDeclaration` or `undefined` if not found.\n */\n getVariableByKey(key: string) {\n return this.variableTable.getVariableByKey(key);\n }\n\n /**\n * Notifies the covering scopes that the available variables have changed.\n */\n notifyCoversChange(): void {\n this.scope.coverScopes.forEach((scope) => scope.available.refresh());\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n debounceTime,\n distinctUntilChanged,\n map,\n merge,\n share,\n skip,\n startWith,\n switchMap,\n tap,\n} from 'rxjs';\nimport { flatten } from 'lodash-es';\nimport { shallowEqual } from 'fast-equals';\nimport { Disposable } from '@flowgram.ai/utils';\nimport { Emitter } from '@flowgram.ai/utils';\n\nimport { IVariableTable } from '../types';\nimport { type Scope } from '../scope';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { createMemo } from '../../utils/memo';\nimport { SubscribeConfig } from '../../ast/types';\nimport { ASTNode, BaseVariableField, VariableDeclaration } from '../../ast';\n\n/**\n * Manages the available variables within a scope.\n */\nexport class ScopeAvailableData {\n protected memo = createMemo();\n\n /**\n * The global variable table from the variable engine.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n protected _version: number = 0;\n\n protected refresh$: Subject<void> = new Subject();\n\n protected _variables: VariableDeclaration[] = [];\n\n /**\n * The current version of the available data, which increments on each change.\n */\n get version() {\n return this._version;\n }\n\n protected bumpVersion() {\n this._version = this._version + 1;\n if (this._version === Number.MAX_SAFE_INTEGER) {\n this._version = 0;\n }\n }\n\n /**\n * Refreshes the list of available variables.\n * This should be called when the dependencies of the scope change.\n */\n refresh(): void {\n // Do not trigger refresh for a disposed scope.\n if (this.scope.disposed) {\n return;\n }\n this.refresh$.next();\n }\n\n /**\n * An observable that emits when the list of available variables changes.\n */\n protected variables$: Observable<VariableDeclaration[]> = this.refresh$.pipe(\n // Map to the flattened list of variables from all dependency scopes.\n map(() => flatten(this.depScopes.map((scope) => scope.output.variables || []))),\n // Use shallow equality to check if the variable list has changed.\n distinctUntilChanged<VariableDeclaration[]>(shallowEqual),\n share()\n );\n\n /**\n * An observable that emits when any variable in the available list changes its value.\n */\n protected anyVariableChange$: Observable<VariableDeclaration> = this.variables$.pipe(\n switchMap((_variables) =>\n merge(\n ..._variables.map((_v) =>\n _v.value$.pipe<any>(\n // Skip the initial value of the BehaviorSubject.\n skip(1)\n )\n )\n )\n ),\n share()\n );\n\n /**\n * Subscribes to changes in any variable's value in the available list.\n * @param observer A function to be called with the changed variable.\n * @returns A disposable to unsubscribe from the changes.\n */\n onAnyVariableChange(observer: (changedVariable: VariableDeclaration) => void) {\n return subsToDisposable(this.anyVariableChange$.subscribe(observer));\n }\n\n /**\n * Subscribes to changes in the list of available variables.\n * @param observer A function to be called with the new list of variables.\n * @returns A disposable to unsubscribe from the changes.\n */\n onVariableListChange(observer: (variables: VariableDeclaration[]) => void) {\n return subsToDisposable(this.variables$.subscribe(observer));\n }\n\n /**\n * @deprecated\n */\n protected onDataChangeEmitter = new Emitter<VariableDeclaration[]>();\n\n protected onListOrAnyVarChangeEmitter = new Emitter<VariableDeclaration[]>();\n\n /**\n * @deprecated use available.onListOrAnyVarChange instead\n */\n public onDataChange = this.onDataChangeEmitter.event;\n\n /**\n * An event that fires when the variable list changes or any variable's value is updated.\n */\n public onListOrAnyVarChange = this.onListOrAnyVarChangeEmitter.event;\n\n constructor(public readonly scope: Scope) {\n this.scope.toDispose.pushAll([\n this.onVariableListChange((_variables) => {\n this._variables = _variables;\n this.memo.clear();\n this.onDataChangeEmitter.fire(this._variables);\n this.bumpVersion();\n this.onListOrAnyVarChangeEmitter.fire(this._variables);\n }),\n this.onAnyVariableChange(() => {\n this.onDataChangeEmitter.fire(this._variables);\n this.bumpVersion();\n this.onListOrAnyVarChangeEmitter.fire(this._variables);\n }),\n Disposable.create(() => {\n this.refresh$.complete();\n this.refresh$.unsubscribe();\n }),\n ]);\n }\n\n /**\n * Gets the list of available variables.\n */\n get variables(): VariableDeclaration[] {\n return this._variables;\n }\n\n /**\n * Gets the keys of the available variables.\n */\n get variableKeys(): string[] {\n return this.memo('availableKeys', () => this._variables.map((_v) => _v.key));\n }\n\n /**\n * Gets the dependency scopes.\n */\n get depScopes(): Scope[] {\n return this.scope.depScopes;\n }\n\n /**\n * Retrieves a variable field by its key path from the available variables.\n * @param keyPath The key path to the variable field.\n * @returns The found `BaseVariableField` or `undefined`.\n */\n getByKeyPath(keyPath: string[] = []): BaseVariableField | undefined {\n // Check if the variable is accessible in the current scope.\n if (!this.variableKeys.includes(keyPath[0])) {\n return;\n }\n return this.globalVariableTable.getByKeyPath(keyPath);\n }\n\n /**\n * Tracks changes to a variable field by its key path.\n * This includes changes to its type, value, or any nested properties.\n * @param keyPath The key path to the variable field to track.\n * @param cb The callback to execute when the variable changes.\n * @param opts Configuration options for the subscription.\n * @returns A disposable to unsubscribe from the tracking.\n */\n trackByKeyPath<Data = BaseVariableField | undefined>(\n keyPath: string[] = [],\n cb: (variable?: Data) => void,\n opts?: SubscribeConfig<BaseVariableField | undefined, Data>\n ): Disposable {\n const { triggerOnInit = true, debounceAnimation, selector } = opts || {};\n\n return subsToDisposable(\n merge(this.anyVariableChange$, this.variables$)\n .pipe(\n triggerOnInit ? startWith() : tap(() => null),\n map(() => {\n const v = this.getByKeyPath(keyPath);\n return selector ? selector(v) : (v as any);\n }),\n distinctUntilChanged(\n (a, b) => shallowEqual(a, b),\n (value) => {\n if (value instanceof ASTNode) {\n // If the value is an ASTNode, compare its hash for changes.\n return value.hash;\n }\n return value;\n }\n ),\n // Debounce updates to a single emission per animation frame.\n debounceAnimation ? debounceTime(0, animationFrameScheduler) : tap(() => null)\n )\n .subscribe(cb)\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subject, filter } from 'rxjs';\nimport { Disposable } from '@flowgram.ai/utils';\n\nimport { type Scope } from '../scope';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { type GlobalEventActionType } from '../../ast';\n\ntype Observer<ActionType extends GlobalEventActionType = GlobalEventActionType> = (\n action: ActionType\n) => void;\n\n/**\n * Manages global events within a scope.\n */\nexport class ScopeEventData {\n event$: Subject<GlobalEventActionType> = new Subject<GlobalEventActionType>();\n\n /**\n * Dispatches a global event.\n * @param action The event action to dispatch.\n */\n dispatch<ActionType extends GlobalEventActionType = GlobalEventActionType>(action: ActionType) {\n if (this.scope.disposed) {\n return;\n }\n this.event$.next(action);\n }\n\n /**\n * Subscribes to all global events.\n * @param observer The observer function to call with the event action.\n * @returns A disposable to unsubscribe from the events.\n */\n subscribe<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n observer: Observer<ActionType>\n ): Disposable {\n return subsToDisposable(this.event$.subscribe(observer as Observer));\n }\n\n /**\n * Subscribes to a specific type of global event.\n * @param type The type of the event to subscribe to.\n * @param observer The observer function to call with the event action.\n * @returns A disposable to unsubscribe from the event.\n */\n on<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n type: ActionType['type'],\n observer: Observer<ActionType>\n ): Disposable {\n return subsToDisposable(\n this.event$.pipe(filter((_action) => _action.type === type)).subscribe(observer as Observer)\n );\n }\n\n constructor(public readonly scope: Scope) {\n scope.toDispose.pushAll([\n this.subscribe((_action) => {\n scope.variableEngine.fireGlobalEvent(_action);\n }),\n ]);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { difference } from 'lodash-es';\nimport { inject, injectable, postConstruct, preDestroy } from 'inversify';\nimport { DisposableCollection, Emitter } from '@flowgram.ai/utils';\n\nimport { VariableEngine } from '../variable-engine';\nimport {\n ASTNode,\n BaseVariableField,\n ObjectPropertiesChangeAction,\n VariableDeclarationListChangeAction,\n} from '../ast';\n\ninterface RenameInfo {\n before: BaseVariableField;\n after: BaseVariableField;\n}\n\n/**\n * This service is responsible for detecting when a variable field's key is renamed.\n * It listens for changes in variable declaration lists and object properties, and\n * determines if a change constitutes a rename operation.\n */\n@injectable()\nexport class VariableFieldKeyRenameService {\n @inject(VariableEngine) variableEngine: VariableEngine;\n\n toDispose = new DisposableCollection();\n\n renameEmitter = new Emitter<RenameInfo>();\n\n /**\n * Emits events for fields that are disposed of during a list change, but not renamed.\n * This helps distinguish between a field that was truly removed and one that was renamed.\n */\n disposeInListEmitter = new Emitter<BaseVariableField>();\n\n /**\n * An event that fires when a variable field key is successfully renamed.\n */\n onRename = this.renameEmitter.event;\n\n /**\n * An event that fires when a field is removed from a list (and not part of a rename).\n */\n onDisposeInList = this.disposeInListEmitter.event;\n\n /**\n * Handles changes in a list of fields to detect rename operations.\n * @param ast The AST node where the change occurred.\n * @param prev The list of fields before the change.\n * @param next The list of fields after the change.\n */\n handleFieldListChange(ast?: ASTNode, prev?: BaseVariableField[], next?: BaseVariableField[]) {\n // 1. Check if a rename is possible.\n if (!ast || !prev?.length || !next?.length) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n // 2. The lengths of the lists must be the same for a rename.\n if (prev.length !== next.length) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n let renameNodeInfo: RenameInfo | null = null;\n let existFieldChanged = false;\n\n for (const [index, prevField] of prev.entries()) {\n const nextField = next[index];\n\n if (prevField.key !== nextField.key) {\n // Only one rename is allowed at a time.\n if (existFieldChanged) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n existFieldChanged = true;\n\n if (prevField.type?.kind === nextField.type?.kind) {\n renameNodeInfo = { before: prevField, after: nextField };\n }\n }\n }\n\n if (!renameNodeInfo) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n this.renameEmitter.fire(renameNodeInfo);\n }\n\n /**\n * Notifies listeners about fields that were removed from a list.\n * @param prev The list of fields before the change.\n * @param next The list of fields after the change.\n */\n notifyFieldsDispose(prev?: BaseVariableField[], next?: BaseVariableField[]) {\n const removedFields = difference(prev || [], next || []);\n removedFields.forEach((_field) => this.disposeInListEmitter.fire(_field));\n }\n\n @postConstruct()\n init() {\n this.toDispose.pushAll([\n this.variableEngine.onGlobalEvent<VariableDeclarationListChangeAction>(\n 'VariableListChange',\n (_action) => {\n this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);\n }\n ),\n this.variableEngine.onGlobalEvent<ObjectPropertiesChangeAction>(\n 'ObjectPropertiesChange',\n (_action) => {\n this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);\n }\n ),\n ]);\n }\n\n @preDestroy()\n dispose() {\n this.toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\n\nimport React, { createContext, useContext } from 'react';\n\nimport { Scope } from '../scope';\n\ninterface ScopeContextProps {\n scope: Scope;\n}\n\nconst ScopeContext = createContext<ScopeContextProps>(null!);\n\n/**\n * ScopeProvider provides the scope to its children via context.\n */\nexport const ScopeProvider = (\n props: React.PropsWithChildren<{\n /**\n * scope used in the context\n */\n scope?: Scope;\n /**\n * @deprecated use scope prop instead, this is kept for backward compatibility\n */\n value?: ScopeContextProps;\n }>\n) => {\n const { scope, value, children } = props;\n\n const scopeToUse = scope || value?.scope;\n\n if (!scopeToUse) {\n throw new Error('[ScopeProvider] scope is required');\n }\n\n return <ScopeContext.Provider value={{ scope: scopeToUse }}>{children}</ScopeContext.Provider>;\n};\n\n/**\n * useCurrentScope returns the scope provided by ScopeProvider.\n * @returns\n */\nexport const useCurrentScope = <Strict extends boolean = false>(params?: {\n /**\n * whether to throw error when no scope in ScopeProvider is found\n */\n strict: Strict;\n}): Strict extends true ? Scope : Scope | undefined => {\n const { strict = false } = params || {};\n\n const context = useContext(ScopeContext);\n\n if (!context) {\n if (strict) {\n throw new Error('useCurrentScope must be used within a <ScopeProvider scope={scope}>');\n }\n console.warn('useCurrentScope should be used within a <ScopeProvider scope={scope}>');\n }\n\n return context?.scope;\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { ScopeAvailableData } from '../../scope/datas';\n\n/**\n * Get the available variables in the current scope.\n * 获取作用域的可访问变量\n *\n * @returns the available variables in the current scope\n */\nexport function useScopeAvailable(params?: { autoRefresh?: boolean }): ScopeAvailableData {\n const { autoRefresh = true } = params || {};\n\n const scope = useCurrentScope({ strict: true });\n const refresh = useRefresh();\n\n useEffect(() => {\n if (!autoRefresh) {\n return () => null;\n }\n\n const disposable = scope.available.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, [autoRefresh]);\n\n return scope.available;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh, useService } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { VariableEngine } from '../../variable-engine';\nimport { VariableDeclaration } from '../../ast';\n\n/**\n * Get available variable list in the current scope.\n *\n * - If no scope, return global variable list.\n * - The hook is reactive to variable list or any variables change.\n */\nexport function useAvailableVariables(): VariableDeclaration[] {\n const scope = useCurrentScope();\n const variableEngine: VariableEngine = useService(VariableEngine);\n\n const refresh = useRefresh();\n\n useEffect(() => {\n // 没有作用域时,监听全局变量表\n if (!scope) {\n const disposable = variableEngine.globalVariableTable.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }\n\n const disposable = scope.available.onDataChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, []);\n\n // 没有作用域时,使用全局变量表\n return scope ? scope.available.variables : variableEngine.globalVariableTable.variables;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { VariableDeclaration } from '../../ast';\n\n/**\n * Get output variable list in the current scope.\n *\n * - The hook is reactive to variable list or any variables change.\n */\nexport function useOutputVariables(): VariableDeclaration[] {\n const scope = useCurrentScope();\n\n const refresh = useRefresh();\n\n useEffect(() => {\n if (!scope) {\n throw new Error(\n '[useOutputVariables]: No scope found, useOutputVariables must be used in <ScopeProvider>'\n );\n }\n\n const disposable = scope.output.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, []);\n\n return scope?.output.variables || [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;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1B,IAAAC,eAA2B;AAUpB,SAAS,qBAA4C;AAC1D,QAAM,QAAQ,gBAAgB;AAE9B,QAAM,cAAU,yBAAW;AAE3B,+BAAU,MAAM;AACd,QAAI,CAAC,OAAO;AACV,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,aAAa,MAAM,OAAO,qBAAqB,MAAM;AACzD,cAAQ;AAAA,IACV,CAAC;AAED,WAAO,MAAM,WAAW,QAAQ;AAAA,EAClC,GAAG,CAAC,CAAC;AAEL,SAAO,OAAO,OAAO,aAAa,CAAC;AACrC;","names":["import_inversify","import_rxjs","import_inversify","import_utils","import_utils","import_utils","import_utils","ASTKind","import_lodash_es","import_inversify","ASTNodeFlags","ASTMatch","import_rxjs","import_utils","import_rxjs","import_fast_equals","import_fast_equals","import_lodash_es","import_fast_equals","import_fast_equals","import_fast_equals","map","ASTNode","ASTFactory","import_rxjs","import_lodash_es","import_fast_equals","import_utils","import_rxjs","import_lodash_es","import_inversify","import_utils","React","import_react","import_react","import_core","disposable","import_react","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/variable-container-module.ts","../src/variable-engine.ts","../src/utils/toDisposable.tsx","../src/utils/memo.ts","../src/scope/variable-table.ts","../src/scope/scope-chain.ts","../src/providers.ts","../src/scope/scope.ts","../src/ast/types.ts","../src/ast/ast-registers.ts","../src/ast/utils/inversify.ts","../src/ast/flags.ts","../src/ast/match.ts","../src/ast/utils/helpers.ts","../src/ast/ast-node.ts","../src/ast/type/base-type.ts","../src/ast/type/array.ts","../src/ast/type/string.ts","../src/ast/type/integer.ts","../src/ast/type/boolean.ts","../src/ast/type/number.ts","../src/ast/type/map.ts","../src/ast/type/object.ts","../src/ast/type/custom-type.ts","../src/ast/expression/base-expression.ts","../src/ast/utils/variable-field.ts","../src/ast/expression/enumerate-expression.ts","../src/ast/expression/keypath-expression.ts","../src/ast/utils/expression.ts","../src/ast/expression/legacy-keypath-expression.ts","../src/ast/expression/wrap-array-expression.ts","../src/ast/declaration/base-variable-field.ts","../src/ast/declaration/variable-declaration.ts","../src/ast/declaration/variable-declaration-list.ts","../src/ast/declaration/property.ts","../src/ast/common/data-node.ts","../src/ast/common/list-node.ts","../src/ast/common/map-node.ts","../src/ast/factory.ts","../src/scope/datas/scope-output-data.ts","../src/scope/datas/scope-available-data.ts","../src/scope/datas/scope-event-data.ts","../src/services/variable-field-key-rename-service.ts","../src/react/context.tsx","../src/react/hooks/use-scope-available.ts","../src/react/hooks/use-available-variables.ts","../src/react/hooks/use-output-variables.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { VariableContainerModule } from './variable-container-module';\nexport { VariableEngine } from './variable-engine';\nexport { VariableEngineProvider } from './providers';\n\nexport * from './react';\nexport * from './scope';\nexport * from './ast';\nexport * from './services';\nexport { type Observer } from 'rxjs';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ContainerModule } from 'inversify';\n\nimport { VariableEngine } from './variable-engine';\nimport { VariableFieldKeyRenameService } from './services';\nimport { ContainerProvider, VariableEngineProvider } from './providers';\nimport { ASTRegisters } from './ast';\n\n/**\n * An InversifyJS container module that binds all the necessary services for the variable engine.\n * This module sets up the dependency injection for the core components of the variable engine.\n */\nexport const VariableContainerModule = new ContainerModule((bind) => {\n bind(VariableEngine).toSelf().inSingletonScope();\n bind(ASTRegisters).toSelf().inSingletonScope();\n\n bind(VariableFieldKeyRenameService).toSelf().inSingletonScope();\n\n // Provide a dynamic provider for VariableEngine to prevent circular dependencies.\n bind(VariableEngineProvider).toDynamicValue((ctx) => () => ctx.container.get(VariableEngine));\n\n // Provide a ContainerProvider to allow AST nodes and other components to access the container.\n bind(ContainerProvider).toDynamicValue((ctx) => () => ctx.container);\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subject } from 'rxjs';\nimport { inject, injectable, interfaces, preDestroy } from 'inversify';\nimport { Disposable, DisposableCollection } from '@flowgram.ai/utils';\nimport { Emitter } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from './utils/toDisposable';\nimport { createMemo } from './utils/memo';\nimport { VariableTable } from './scope/variable-table';\nimport { ScopeChangeAction } from './scope/types';\nimport { IScopeConstructor } from './scope/scope';\nimport { Scope, ScopeChain, type IVariableTable } from './scope';\nimport { ContainerProvider } from './providers';\nimport { ASTRegisters, type GlobalEventActionType } from './ast';\n\n/**\n * The core of the variable engine system.\n * It manages scopes, variables, and events within the system.\n */\n@injectable()\nexport class VariableEngine implements Disposable {\n protected toDispose = new DisposableCollection();\n\n protected memo = createMemo();\n\n protected scopeMap = new Map<string | symbol, Scope>();\n\n /**\n * A rxjs subject that emits global events occurring within the variable engine.\n */\n globalEvent$: Subject<GlobalEventActionType> = new Subject<GlobalEventActionType>();\n\n protected onScopeChangeEmitter = new Emitter<ScopeChangeAction>();\n\n /**\n * A table containing all global variables.\n */\n public globalVariableTable: IVariableTable = new VariableTable();\n\n /**\n * An event that fires whenever a scope is added, updated, or deleted.\n */\n public onScopeChange = this.onScopeChangeEmitter.event;\n\n @inject(ContainerProvider) private readonly containerProvider: ContainerProvider;\n\n /**\n * The Inversify container instance.\n */\n get container(): interfaces.Container {\n return this.containerProvider();\n }\n\n constructor(\n /**\n * The scope chain, which manages the dependency relationships between scopes.\n */\n @inject(ScopeChain)\n public readonly chain: ScopeChain,\n /**\n * The registry for all AST node types.\n */\n @inject(ASTRegisters)\n public readonly astRegisters: ASTRegisters\n ) {\n this.toDispose.pushAll([\n chain,\n Disposable.create(() => {\n // Dispose all scopes\n this.getAllScopes().forEach((scope) => scope.dispose());\n this.globalVariableTable.dispose();\n }),\n ]);\n }\n\n /**\n * Disposes of all resources used by the variable engine.\n */\n @preDestroy()\n dispose(): void {\n this.toDispose.dispose();\n }\n\n /**\n * Retrieves a scope by its unique identifier.\n * @param scopeId The ID of the scope to retrieve.\n * @returns The scope if found, otherwise undefined.\n */\n getScopeById(scopeId: string | symbol): Scope | undefined {\n return this.scopeMap.get(scopeId);\n }\n\n /**\n * Removes a scope by its unique identifier and disposes of it.\n * @param scopeId The ID of the scope to remove.\n */\n removeScopeById(scopeId: string | symbol): void {\n this.getScopeById(scopeId)?.dispose();\n }\n\n /**\n * Creates a new scope or retrieves an existing one if the ID and type match.\n * @param id The unique identifier for the scope.\n * @param meta Optional metadata for the scope, defined by the user.\n * @param options Options for creating the scope.\n * @param options.ScopeConstructor The constructor to use for creating the scope. Defaults to `Scope`.\n * @returns The created or existing scope.\n */\n createScope(\n id: string | symbol,\n meta?: Record<string, any>,\n options: {\n ScopeConstructor?: IScopeConstructor;\n } = {}\n ): Scope {\n const { ScopeConstructor = Scope } = options;\n\n let scope = this.getScopeById(id);\n\n if (!scope) {\n scope = new ScopeConstructor({ variableEngine: this, meta, id });\n this.scopeMap.set(id, scope);\n this.onScopeChangeEmitter.fire({ type: 'add', scope: scope! });\n\n scope.toDispose.pushAll([\n scope.ast.subscribe(() => {\n this.onScopeChangeEmitter.fire({ type: 'update', scope: scope! });\n }),\n // Fires when available variables change\n scope.available.onDataChange(() => {\n this.onScopeChangeEmitter.fire({ type: 'available', scope: scope! });\n }),\n ]);\n scope.onDispose(() => {\n this.scopeMap.delete(id);\n this.onScopeChangeEmitter.fire({ type: 'delete', scope: scope! });\n });\n }\n\n return scope;\n }\n\n /**\n * Retrieves all scopes currently managed by the engine.\n * @param options Options for retrieving the scopes.\n * @param options.sort Whether to sort the scopes based on their dependency chain.\n * @returns An array of all scopes.\n */\n getAllScopes({\n sort,\n }: {\n sort?: boolean;\n } = {}): Scope[] {\n const allScopes = Array.from(this.scopeMap.values());\n\n if (sort) {\n const sortScopes = this.chain.sortAll();\n const remainScopes = new Set(allScopes);\n sortScopes.forEach((_scope) => remainScopes.delete(_scope));\n\n return [...sortScopes, ...Array.from(remainScopes)];\n }\n\n return [...allScopes];\n }\n\n /**\n * Fires a global event to be broadcast to all listeners.\n * @param event The global event to fire.\n */\n fireGlobalEvent(event: GlobalEventActionType) {\n this.globalEvent$.next(event);\n }\n\n /**\n * Subscribes to a specific type of global event.\n * @param type The type of the event to listen for.\n * @param observer A function to be called when the event is observed.\n * @returns A disposable object to unsubscribe from the event.\n */\n onGlobalEvent<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n type: ActionType['type'],\n observer: (action: ActionType) => void\n ): Disposable {\n return subsToDisposable(\n this.globalEvent$.subscribe((_action) => {\n if (_action.type === type) {\n observer(_action as ActionType);\n }\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subscription } from 'rxjs';\nimport { Disposable } from '@flowgram.ai/utils';\n\n/**\n * Convert rxjs subscription to disposable\n * @param subscription - The rxjs subscription\n * @returns The disposable\n */\nexport function subsToDisposable(subscription: Subscription): Disposable {\n return Disposable.create(() => subscription.unsubscribe());\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\ntype KeyType = string | symbol;\n\n/**\n * Create memo manager\n * @returns\n */\nexport const createMemo = (): {\n <T>(key: KeyType, fn: () => T): T;\n clear: (key?: KeyType) => void;\n} => {\n const _memoCache = new Map<KeyType, any>();\n\n const memo = <T>(key: KeyType, fn: () => T): T => {\n if (_memoCache.has(key)) {\n return _memoCache.get(key) as T;\n }\n const data = fn();\n _memoCache.set(key, data);\n return data as T;\n };\n\n const clear = (key?: KeyType) => {\n if (key) {\n _memoCache.delete(key);\n } else {\n _memoCache.clear();\n }\n };\n\n memo.clear = clear;\n\n return memo;\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Observable, Subject, merge, share, skip, switchMap } from 'rxjs';\nimport { DisposableCollection, Emitter } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from '../utils/toDisposable';\nimport { BaseVariableField } from '../ast/declaration/base-variable-field';\nimport { VariableDeclaration } from '../ast';\nimport { IVariableTable } from './types';\n\n/**\n * A class that stores and manages variables in a table-like structure.\n * It provides methods for adding, removing, and retrieving variables, as well as\n * observables for listening to changes in the variable list and individual variables.\n */\nexport class VariableTable implements IVariableTable {\n protected table: Map<string, VariableDeclaration> = new Map();\n\n toDispose = new DisposableCollection();\n\n /**\n * @deprecated\n */\n protected onDataChangeEmitter = new Emitter<void>();\n\n protected variables$: Subject<VariableDeclaration[]> = new Subject<VariableDeclaration[]>();\n\n /**\n * An observable that listens for value changes on any variable within the table.\n */\n protected anyVariableChange$: Observable<VariableDeclaration> = this.variables$.pipe(\n switchMap((_variables) =>\n merge(\n ..._variables.map((_v) =>\n _v.value$.pipe<any>(\n // Skip the initial value of the BehaviorSubject\n skip(1)\n )\n )\n )\n ),\n share()\n );\n\n /**\n * Subscribes to updates on any variable in the list.\n * @param observer A function to be called when any variable's value changes.\n * @returns A disposable object to unsubscribe from the updates.\n */\n onAnyVariableChange(observer: (changedVariable: VariableDeclaration) => void) {\n return subsToDisposable(this.anyVariableChange$.subscribe(observer));\n }\n\n /**\n * Subscribes to changes in the variable list (additions or removals).\n * @param observer A function to be called when the list of variables changes.\n * @returns A disposable object to unsubscribe from the updates.\n */\n onVariableListChange(observer: (variables: VariableDeclaration[]) => void) {\n return subsToDisposable(this.variables$.subscribe(observer));\n }\n\n /**\n * Subscribes to both variable list changes and updates to any variable in the list.\n * @param observer A function to be called when either the list or a variable in it changes.\n * @returns A disposable collection to unsubscribe from both events.\n */\n onListOrAnyVarChange(observer: () => void) {\n const disposables = new DisposableCollection();\n disposables.pushAll([this.onVariableListChange(observer), this.onAnyVariableChange(observer)]);\n return disposables;\n }\n\n /**\n * @deprecated Use onListOrAnyVarChange instead.\n */\n public onDataChange = this.onDataChangeEmitter.event;\n\n protected _version: number = 0;\n\n /**\n * Fires change events to notify listeners that the data has been updated.\n */\n fireChange() {\n this.bumpVersion();\n this.onDataChangeEmitter.fire();\n this.variables$.next(this.variables);\n this.parentTable?.fireChange();\n }\n\n /**\n * The current version of the variable table, incremented on each change.\n */\n get version(): number {\n return this._version;\n }\n\n /**\n * Increments the version number, resetting to 0 if it reaches MAX_SAFE_INTEGER.\n */\n protected bumpVersion() {\n this._version = this._version + 1;\n if (this._version === Number.MAX_SAFE_INTEGER) {\n this._version = 0;\n }\n }\n\n constructor(\n /**\n * An optional parent table. If provided, this table will contain all variables\n * from the current table.\n */\n public parentTable?: IVariableTable\n ) {\n this.toDispose.pushAll([\n this.onDataChangeEmitter,\n // Activate the share() operator\n this.onAnyVariableChange(() => {\n this.bumpVersion();\n }),\n ]);\n }\n\n /**\n * An array of all variables in the table.\n */\n get variables(): VariableDeclaration[] {\n return Array.from(this.table.values());\n }\n\n /**\n * An array of all variable keys in the table.\n */\n get variableKeys(): string[] {\n return Array.from(this.table.keys());\n }\n\n /**\n * Retrieves a variable or a nested property field by its key path.\n * @param keyPath An array of keys representing the path to the desired field.\n * @returns The found variable or property field, or undefined if not found.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n const [variableKey, ...propertyKeys] = keyPath || [];\n\n if (!variableKey) {\n return;\n }\n\n const variable = this.getVariableByKey(variableKey);\n\n return propertyKeys.length ? variable?.getByKeyPath(propertyKeys) : variable;\n }\n\n /**\n * Retrieves a variable by its key.\n * @param key The key of the variable to retrieve.\n * @returns The variable declaration if found, otherwise undefined.\n */\n getVariableByKey(key: string) {\n return this.table.get(key);\n }\n\n /**\n * Adds a variable to the table.\n * If a parent table exists, the variable is also added to the parent.\n * @param variable The variable declaration to add.\n */\n addVariableToTable(variable: VariableDeclaration) {\n this.table.set(variable.key, variable);\n if (this.parentTable) {\n (this.parentTable as VariableTable).addVariableToTable(variable);\n }\n }\n\n /**\n * Removes a variable from the table.\n * If a parent table exists, the variable is also removed from the parent.\n * @param key The key of the variable to remove.\n */\n removeVariableFromTable(key: string) {\n this.table.delete(key);\n if (this.parentTable) {\n (this.parentTable as VariableTable).removeVariableFromTable(key);\n }\n }\n\n /**\n * Disposes of all resources used by the variable table.\n */\n dispose(): void {\n this.variableKeys.forEach((_key) =>\n (this.parentTable as VariableTable)?.removeVariableFromTable(_key)\n );\n this.parentTable?.fireChange();\n this.variables$.complete();\n this.variables$.unsubscribe();\n this.toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { inject, injectable } from 'inversify';\nimport { DisposableCollection, type Event } from '@flowgram.ai/utils';\n\nimport { VariableEngineProvider } from '../providers';\nimport { type Scope } from './scope';\n\n/**\n * Manages the dependency relationships between scopes.\n * This is an abstract class, and specific implementations determine how the scope order is managed.\n */\n@injectable()\nexport abstract class ScopeChain {\n readonly toDispose: DisposableCollection = new DisposableCollection();\n\n @inject(VariableEngineProvider) variableEngineProvider: VariableEngineProvider;\n\n get variableEngine() {\n return this.variableEngineProvider();\n }\n\n constructor() {}\n\n /**\n * Refreshes the dependency and coverage relationships for all scopes.\n */\n refreshAllChange(): void {\n this.variableEngine.getAllScopes().forEach((_scope) => {\n _scope.refreshCovers();\n _scope.refreshDeps();\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 abstract getDeps(scope: Scope): Scope[];\n\n /**\n * Gets the covering scopes for a given scope.\n * @param scope The scope to get covers for.\n * @returns An array of covering scopes.\n */\n abstract getCovers(scope: Scope): Scope[];\n\n /**\n * Sorts all scopes based on their dependency relationships.\n * @returns A sorted array of all scopes.\n */\n abstract sortAll(): Scope[];\n\n dispose(): void {\n this.toDispose.dispose();\n }\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n get onDispose(): Event<void> {\n return this.toDispose.onDispose;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\n\nimport { type VariableEngine } from './variable-engine';\n\n/**\n * A provider for dynamically obtaining the `VariableEngine` instance.\n * This is used to prevent circular dependencies when injecting `VariableEngine`.\n */\nexport const VariableEngineProvider = Symbol('DynamicVariableEngine');\nexport type VariableEngineProvider = () => VariableEngine;\n\n/**\n * A provider for obtaining the Inversify container instance.\n * This allows other parts of the application, like AST nodes, to access the container for dependency injection.\n */\nexport const ContainerProvider = Symbol('ContainerProvider');\nexport type ContainerProvider = () => interfaces.Container;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { DisposableCollection } from '@flowgram.ai/utils';\n\nimport { type VariableEngine } from '../variable-engine';\nimport { createMemo } from '../utils/memo';\nimport { ASTKind, type ASTNode, type ASTNodeJSON, MapNode } from '../ast';\nimport { ScopeAvailableData, ScopeEventData, ScopeOutputData } from './datas';\n\n/**\n * Interface for the Scope constructor.\n */\nexport interface IScopeConstructor {\n new (options: {\n id: string | symbol;\n variableEngine: VariableEngine;\n meta?: Record<string, any>;\n }): Scope;\n}\n\n/**\n * Represents a variable scope, which manages its own set of variables and their lifecycle.\n * - `scope.output` represents the variables declared within this scope.\n * - `scope.available` represents all variables accessible from this scope, including those from parent scopes.\n */\nexport class Scope<ScopeMeta extends Record<string, any> = Record<string, any>> {\n /**\n * A unique identifier for the scope.\n */\n readonly id: string | symbol;\n\n /**\n * The variable engine instance this scope belongs to.\n */\n readonly variableEngine: VariableEngine;\n\n /**\n * Metadata associated with the scope, which can be extended by higher-level business logic.\n */\n readonly meta: ScopeMeta;\n\n /**\n * The root AST node for this scope, which is a MapNode.\n * It stores various data related to the scope, such as `outputs`.\n */\n readonly ast: MapNode;\n\n /**\n * Manages the available variables for this scope.\n */\n readonly available: ScopeAvailableData;\n\n /**\n * Manages the output variables for this scope.\n */\n readonly output: ScopeOutputData;\n\n /**\n * Manages event dispatching and handling for this scope.\n */\n readonly event: ScopeEventData;\n\n /**\n * A memoization utility for caching computed values.\n */\n protected memo = createMemo();\n\n public toDispose: DisposableCollection = new DisposableCollection();\n\n constructor(options: { id: string | symbol; variableEngine: VariableEngine; meta?: ScopeMeta }) {\n this.id = options.id;\n this.meta = options.meta || ({} as any);\n this.variableEngine = options.variableEngine;\n\n this.event = new ScopeEventData(this);\n\n this.ast = this.variableEngine.astRegisters.createAST(\n {\n kind: ASTKind.MapNode,\n key: String(this.id),\n },\n {\n scope: this,\n }\n ) as MapNode;\n\n this.output = new ScopeOutputData(this);\n this.available = new ScopeAvailableData(this);\n }\n\n /**\n * Refreshes the covering scopes.\n */\n refreshCovers(): void {\n this.memo.clear('covers');\n }\n\n /**\n * Refreshes the dependency scopes and the available variables.\n */\n refreshDeps(): void {\n this.memo.clear('deps');\n this.available.refresh();\n }\n\n /**\n * Gets the scopes that this scope depends on.\n */\n get depScopes(): Scope[] {\n return this.memo('deps', () =>\n this.variableEngine.chain\n .getDeps(this)\n .filter((_scope) => Boolean(_scope) && !_scope?.disposed)\n );\n }\n\n /**\n * Gets the scopes that are covered by this scope.\n */\n get coverScopes(): Scope[] {\n return this.memo('covers', () =>\n this.variableEngine.chain\n .getCovers(this)\n .filter((_scope) => Boolean(_scope) && !_scope?.disposed)\n );\n }\n\n /**\n * Disposes of the scope and its resources.\n * This will also trigger updates in dependent and covering scopes.\n */\n dispose(): void {\n this.ast.dispose();\n this.toDispose.dispose();\n\n // When a scope is disposed, update its dependent and covering scopes.\n this.coverScopes.forEach((_scope) => _scope.refreshDeps());\n this.depScopes.forEach((_scope) => _scope.refreshCovers());\n }\n\n onDispose = this.toDispose.onDispose;\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n /**\n * Sets a variable in the scope with the default key 'outputs'.\n *\n * @param json The JSON representation of the AST node to set.\n * @returns The created or updated AST node.\n */\n public setVar<Node extends ASTNode = ASTNode>(json: ASTNodeJSON): Node;\n\n /**\n * Sets a variable in the scope with a specified key.\n *\n * @param key The key of the variable to set.\n * @param json The JSON representation of the AST node to set.\n * @returns The created or updated AST node.\n */\n public setVar<Node extends ASTNode = ASTNode>(key: string, json: ASTNodeJSON): Node;\n\n public setVar<Node extends ASTNode = ASTNode>(\n arg1: string | ASTNodeJSON,\n arg2?: ASTNodeJSON\n ): Node {\n if (typeof arg1 === 'string' && arg2 !== undefined) {\n return this.ast.set(arg1, arg2);\n }\n\n if (typeof arg1 === 'object' && arg2 === undefined) {\n return this.ast.set('outputs', arg1);\n }\n\n throw new Error('Invalid arguments');\n }\n\n /**\n * Retrieves a variable from the scope by its key.\n *\n * @param key The key of the variable to retrieve. Defaults to 'outputs'.\n * @returns The AST node for the variable, or `undefined` if not found.\n */\n public getVar<Node extends ASTNode = ASTNode>(key: string = 'outputs') {\n return this.ast.get<Node>(key);\n }\n\n /**\n * Clears a variable from the scope by its key.\n *\n * @param key The key of the variable to clear. Defaults to 'outputs'.\n */\n public clearVar(key: string = 'outputs') {\n return this.ast.remove(key);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type Observer } from 'rxjs';\n\nimport { type Scope } from '../scope';\nimport { type ASTNode } from './ast-node';\n\nexport type ASTKindType = string;\nexport type Identifier = string;\n\n/**\n * ASTNodeJSON is the JSON representation of an ASTNode.\n */\nexport interface ASTNodeJSON {\n /**\n * Kind is the type of the AST node.\n */\n kind?: ASTKindType;\n\n /**\n * Key is the unique identifier of the node.\n * If not provided, the node will generate a default key value.\n */\n key?: Identifier;\n [key: string]: any;\n}\n\n/**\n * Core AST node types.\n */\nexport enum ASTKind {\n /**\n * # Type-related.\n * - A set of type AST nodes based on JSON types is implemented internally by default.\n */\n\n /**\n * String type.\n */\n String = 'String',\n /**\n * Number type.\n */\n Number = 'Number',\n /**\n * Integer type.\n */\n Integer = 'Integer',\n /**\n * Boolean type.\n */\n Boolean = 'Boolean',\n /**\n * Object type.\n */\n Object = 'Object',\n /**\n * Array type.\n */\n Array = 'Array',\n /**\n * Map type.\n */\n Map = 'Map',\n /**\n * Union type.\n * Commonly used for type checking, generally not exposed to the business.\n */\n Union = 'Union',\n /**\n * Any type.\n * Commonly used for business logic.\n */\n Any = 'Any',\n /**\n * Custom type.\n * For business-defined types.\n */\n CustomType = 'CustomType',\n\n /**\n * # Declaration-related.\n */\n\n /**\n * Field definition for Object drill-down.\n */\n Property = 'Property',\n /**\n * Variable declaration.\n */\n VariableDeclaration = 'VariableDeclaration',\n /**\n * Variable declaration list.\n */\n VariableDeclarationList = 'VariableDeclarationList',\n\n /**\n * # Expression-related.\n */\n\n /**\n * Access fields on variables through the path system.\n */\n KeyPathExpression = 'KeyPathExpression',\n /**\n * Iterate over specified data.\n */\n EnumerateExpression = 'EnumerateExpression',\n /**\n * Wrap with Array Type.\n */\n WrapArrayExpression = 'WrapArrayExpression',\n\n /**\n * # General-purpose AST nodes.\n */\n\n /**\n * General-purpose List<ASTNode> storage node.\n */\n ListNode = 'ListNode',\n /**\n * General-purpose data storage node.\n */\n DataNode = 'DataNode',\n /**\n * General-purpose Map<string, ASTNode> storage node.\n */\n MapNode = 'MapNode',\n}\n\nexport interface CreateASTParams {\n scope: Scope;\n key?: Identifier;\n parent?: ASTNode;\n}\n\nexport type ASTNodeJSONOrKind = string | ASTNodeJSON;\n\nexport type ObserverOrNext<T> = Partial<Observer<T>> | ((value: T) => void);\n\nexport interface SubscribeConfig<This, Data> {\n // Merge all changes within one animationFrame into a single one.\n debounceAnimation?: boolean;\n // Respond with a value by default upon subscription.\n triggerOnInit?: boolean;\n selector?: (curr: This) => Data;\n}\n\n/**\n * TypeUtils to get the JSON representation of an AST node with a specific kind.\n */\nexport type GetKindJSON<KindType extends string, JSON extends ASTNodeJSON> = {\n kind: KindType;\n key?: Identifier;\n} & JSON;\n\n/**\n * TypeUtils to get the JSON representation of an AST node with a specific kind or just the kind string.\n */\nexport type GetKindJSONOrKind<KindType extends string, JSON extends ASTNodeJSON> =\n | ({\n kind: KindType;\n key?: Identifier;\n } & JSON)\n | KindType;\n\n/**\n * Global event action type.\n * - Global event might be dispatched from `ASTNode` or `Scope`.\n */\nexport interface GlobalEventActionType<\n Type = string,\n Payload = any,\n AST extends ASTNode = ASTNode\n> {\n type: Type;\n payload?: Payload;\n ast?: AST;\n}\n\nexport type NewASTAction = GlobalEventActionType<'NewAST'>;\nexport type UpdateASTAction = GlobalEventActionType<'UpdateAST'>;\nexport type DisposeASTAction = GlobalEventActionType<'DisposeAST'>;\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { omit } from 'lodash-es';\nimport { injectable } from 'inversify';\n\nimport { POST_CONSTRUCT_AST_SYMBOL } from './utils/inversify';\nimport { ASTKindType, ASTNodeJSON, CreateASTParams, NewASTAction } from './types';\nimport { ArrayType } from './type/array';\nimport {\n BooleanType,\n CustomType,\n IntegerType,\n MapType,\n NumberType,\n ObjectType,\n StringType,\n} from './type';\nimport { EnumerateExpression, KeyPathExpression, WrapArrayExpression } from './expression';\nimport { Property, VariableDeclaration, VariableDeclarationList } from './declaration';\nimport { DataNode, MapNode } from './common';\nimport { ASTNode, ASTNodeRegistry } from './ast-node';\n\ntype DataInjector = () => Record<string, any>;\n\n/**\n * Register the AST node to the engine.\n */\n@injectable()\nexport class ASTRegisters {\n /**\n * @deprecated Please use `@injectToAst(XXXService) declare xxxService: XXXService` to achieve external dependency injection.\n */\n protected injectors: Map<ASTKindType, DataInjector> = new Map();\n\n protected astMap: Map<ASTKindType, ASTNodeRegistry> = new Map();\n\n /**\n * Core AST node registration.\n */\n constructor() {\n this.registerAST(StringType);\n this.registerAST(NumberType);\n this.registerAST(BooleanType);\n this.registerAST(IntegerType);\n this.registerAST(ObjectType);\n this.registerAST(ArrayType);\n this.registerAST(MapType);\n this.registerAST(CustomType);\n this.registerAST(Property);\n this.registerAST(VariableDeclaration);\n this.registerAST(VariableDeclarationList);\n this.registerAST(KeyPathExpression);\n\n this.registerAST(EnumerateExpression);\n this.registerAST(WrapArrayExpression);\n this.registerAST(MapNode);\n this.registerAST(DataNode);\n }\n\n /**\n * Creates an AST node.\n * @param param Creation parameters.\n * @returns\n */\n createAST<ReturnNode extends ASTNode = ASTNode>(\n json: ASTNodeJSON,\n { parent, scope }: CreateASTParams\n ): ReturnNode {\n const Registry = this.astMap.get(json.kind!);\n\n if (!Registry) {\n throw Error(`ASTKind: ${String(json.kind)} can not find its ASTNode Registry`);\n }\n\n const injector = this.injectors.get(json.kind!);\n\n const node = new Registry(\n {\n key: json.key,\n scope,\n parent,\n },\n injector?.() || {}\n ) as ReturnNode;\n\n // Do not trigger fireChange during initial creation.\n node.changeLocked = true;\n node.fromJSON(omit(json, ['key', 'kind']));\n node.changeLocked = false;\n\n node.dispatchGlobalEvent<NewASTAction>({ type: 'NewAST' });\n\n if (Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, node)) {\n const postConstructKey = Reflect.getMetadata(POST_CONSTRUCT_AST_SYMBOL, node);\n (node[postConstructKey] as () => void)?.();\n }\n\n return node;\n }\n\n /**\n * Gets the node Registry by AST node type.\n * @param kind\n * @returns\n */\n getASTRegistryByKind(kind: ASTKindType) {\n return this.astMap.get(kind);\n }\n\n /**\n * Registers an AST node.\n * @param ASTNode\n */\n registerAST(\n ASTNode: ASTNodeRegistry,\n /**\n * @deprecated Please use `@injectToAst(XXXService) declare xxxService: XXXService` to achieve external dependency injection.\n */\n injector?: DataInjector\n ) {\n this.astMap.set(ASTNode.kind, ASTNode);\n if (injector) {\n this.injectors.set(ASTNode.kind, injector);\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { interfaces } from 'inversify';\n\nimport { type ASTNode } from '../ast-node';\n\nexport const injectToAST = (serviceIdentifier: interfaces.ServiceIdentifier) =>\n function (target: any, propertyKey: string) {\n if (!serviceIdentifier) {\n throw new Error(\n `ServiceIdentifier ${serviceIdentifier} in @lazyInject is Empty, it might be caused by file circular dependency, please check it.`\n );\n }\n\n const descriptor = {\n get() {\n const container = (this as ASTNode).scope.variableEngine.container;\n return container.get(serviceIdentifier);\n },\n set() {},\n configurable: true,\n enumerable: true,\n } as any;\n\n // Object.defineProperty(target, propertyKey, descriptor);\n\n return descriptor;\n };\n\nexport const POST_CONSTRUCT_AST_SYMBOL = Symbol('post_construct_ast');\n\nexport const postConstructAST = () => (target: any, propertyKey: string) => {\n // Only run once.\n if (!Reflect.hasMetadata(POST_CONSTRUCT_AST_SYMBOL, target)) {\n Reflect.defineMetadata(POST_CONSTRUCT_AST_SYMBOL, propertyKey, target);\n } else {\n throw Error('Duplication Post Construct AST');\n }\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * ASTNode flags. Stored in the `flags` property of the `ASTNode`.\n */\nexport enum ASTNodeFlags {\n /**\n * None.\n */\n None = 0,\n\n /**\n * Variable Field.\n */\n VariableField = 1 << 0,\n\n /**\n * Expression.\n */\n Expression = 1 << 2,\n\n /**\n * # Variable Type Flags\n */\n\n /**\n * Basic type.\n */\n BasicType = 1 << 3,\n /**\n * Drillable variable type.\n */\n DrilldownType = 1 << 4,\n /**\n * Enumerable variable type.\n */\n EnumerateType = 1 << 5,\n /**\n * Composite type, currently not in use.\n */\n UnionType = 1 << 6,\n\n /**\n * Variable type.\n */\n VariableType = BasicType | DrilldownType | EnumerateType | UnionType,\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from './types';\nimport {\n type StringType,\n type NumberType,\n type BooleanType,\n type IntegerType,\n type ObjectType,\n type ArrayType,\n type MapType,\n type CustomType,\n} from './type';\nimport { ASTNodeFlags } from './flags';\nimport {\n type WrapArrayExpression,\n type EnumerateExpression,\n type KeyPathExpression,\n} from './expression';\nimport {\n type BaseVariableField,\n type Property,\n type VariableDeclaration,\n type VariableDeclarationList,\n} from './declaration';\nimport { type ASTNode } from './ast-node';\n\n/**\n * Variable-core ASTNode matchers.\n *\n * - Typescript code inside if statement will be type guarded.\n */\nexport namespace ASTMatch {\n /**\n * # Type-related matchers.\n */\n\n /**\n * Check if the node is a `StringType`.\n */\n export const isString = (node?: ASTNode): node is StringType => node?.kind === ASTKind.String;\n\n /**\n * Check if the node is a `NumberType`.\n */\n export const isNumber = (node?: ASTNode): node is NumberType => node?.kind === ASTKind.Number;\n\n /**\n * Check if the node is a `BooleanType`.\n */\n export const isBoolean = (node?: ASTNode): node is BooleanType => node?.kind === ASTKind.Boolean;\n\n /**\n * Check if the node is a `IntegerType`.\n */\n export const isInteger = (node?: ASTNode): node is IntegerType => node?.kind === ASTKind.Integer;\n\n /**\n * Check if the node is a `ObjectType`.\n */\n export const isObject = (node?: ASTNode): node is ObjectType => node?.kind === ASTKind.Object;\n\n /**\n * Check if the node is a `ArrayType`.\n */\n export const isArray = (node?: ASTNode): node is ArrayType => node?.kind === ASTKind.Array;\n\n /**\n * Check if the node is a `MapType`.\n */\n export const isMap = (node?: ASTNode): node is MapType => node?.kind === ASTKind.Map;\n\n /**\n * Check if the node is a `CustomType`.\n */\n export const isCustomType = (node?: ASTNode): node is CustomType =>\n node?.kind === ASTKind.CustomType;\n\n /**\n * # Declaration-related matchers.\n */\n\n /**\n * Check if the node is a `VariableDeclaration`.\n */\n export const isVariableDeclaration = <VariableMeta = any>(\n node?: ASTNode\n ): node is VariableDeclaration<VariableMeta> => node?.kind === ASTKind.VariableDeclaration;\n\n /**\n * Check if the node is a `Property`.\n */\n export const isProperty = <VariableMeta = any>(node?: ASTNode): node is Property<VariableMeta> =>\n node?.kind === ASTKind.Property;\n\n /**\n * Check if the node is a `BaseVariableField`.\n */\n export const isBaseVariableField = (node?: ASTNode): node is BaseVariableField =>\n !!(node?.flags || 0 & ASTNodeFlags.VariableField);\n\n /**\n * Check if the node is a `VariableDeclarationList`.\n */\n export const isVariableDeclarationList = (node?: ASTNode): node is VariableDeclarationList =>\n node?.kind === ASTKind.VariableDeclarationList;\n\n /**\n * # Expression-related matchers.\n */\n\n /**\n * Check if the node is a `EnumerateExpression`.\n */\n export const isEnumerateExpression = (node?: ASTNode): node is EnumerateExpression =>\n node?.kind === ASTKind.EnumerateExpression;\n\n /**\n * Check if the node is a `WrapArrayExpression`.\n */\n export const isWrapArrayExpression = (node?: ASTNode): node is WrapArrayExpression =>\n node?.kind === ASTKind.WrapArrayExpression;\n\n /**\n * Check if the node is a `KeyPathExpression`.\n */\n export const isKeyPathExpression = (node?: ASTNode): node is KeyPathExpression =>\n node?.kind === ASTKind.KeyPathExpression;\n\n /**\n * Check ASTNode Match by ASTClass\n *\n * @param node ASTNode to be checked.\n * @param targetType Target ASTNode class.\n * @returns Whether the node is of the target type.\n */\n export function is<TargetASTNode extends ASTNode>(\n node?: ASTNode,\n targetType?: { kind: string; new (...args: any[]): TargetASTNode }\n ): node is TargetASTNode {\n return node?.kind === targetType?.kind;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTMatch } from '../match';\nimport { ASTNode } from '../ast-node';\n\nexport function updateChildNodeHelper(\n this: ASTNode,\n {\n getChildNode,\n updateChildNode,\n removeChildNode,\n nextJSON,\n }: {\n getChildNode: () => ASTNode | undefined;\n updateChildNode: (nextNode: ASTNode) => void;\n removeChildNode: () => void;\n nextJSON?: ASTNodeJSON;\n }\n): ASTNode | undefined {\n const currNode: ASTNode | undefined = getChildNode();\n\n const isNewKind = currNode?.kind !== nextJSON?.kind;\n // If `nextJSON` does not pass a key value, the key value remains unchanged by default.\n const isNewKey = nextJSON?.key && nextJSON?.key !== currNode?.key;\n\n if (isNewKind || isNewKey) {\n // The previous node needs to be destroyed.\n if (currNode) {\n currNode.dispose();\n removeChildNode();\n }\n\n if (nextJSON) {\n const newNode = this.createChildNode(nextJSON);\n updateChildNode(newNode);\n this.fireChange();\n return newNode;\n } else {\n // Also trigger an update when deleting a child node directly.\n this.fireChange();\n }\n } else if (nextJSON) {\n currNode?.fromJSON(nextJSON);\n }\n\n return currNode;\n}\n\nexport function parseTypeJsonOrKind(typeJSONOrKind?: ASTNodeJSONOrKind): ASTNodeJSON | undefined {\n return typeof typeJSONOrKind === 'string' ? { kind: typeJSONOrKind } : typeJSONOrKind;\n}\n\n// Get all children.\nexport function getAllChildren(ast: ASTNode): ASTNode[] {\n return [...ast.children, ...ast.children.map((_child) => getAllChildren(_child)).flat()];\n}\n\n/**\n * isMatchAST is same as ASTMatch.is\n * @param node\n * @param targetType\n * @returns\n */\nexport function isMatchAST<TargetASTNode extends ASTNode>(\n node?: ASTNode,\n targetType?: { kind: string; new (...args: any[]): TargetASTNode }\n): node is TargetASTNode {\n return ASTMatch.is(node, targetType);\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n BehaviorSubject,\n animationFrameScheduler,\n debounceTime,\n distinctUntilChanged,\n map,\n skip,\n tap,\n} from 'rxjs';\nimport { nanoid } from 'nanoid';\nimport { isNil, omitBy } from 'lodash-es';\nimport { shallowEqual } from 'fast-equals';\nimport { Disposable, DisposableCollection } from '@flowgram.ai/utils';\n\nimport { subsToDisposable } from '../utils/toDisposable';\nimport { updateChildNodeHelper } from './utils/helpers';\nimport { type Scope } from '../scope';\nimport {\n type ASTNodeJSON,\n type ObserverOrNext,\n type ASTKindType,\n type CreateASTParams,\n type Identifier,\n SubscribeConfig,\n GlobalEventActionType,\n DisposeASTAction,\n UpdateASTAction,\n} from './types';\nimport { ASTNodeFlags } from './flags';\n\nexport interface ASTNodeRegistry<JSON extends ASTNodeJSON = any> {\n kind: string;\n new (params: CreateASTParams, injectOpts: any): ASTNode<JSON>;\n}\n\n/**\n * An `ASTNode` represents a fundamental unit of variable information within the system's Abstract Syntax Tree.\n * It can model various constructs, for example:\n * - **Declarations**: `const a = 1`\n * - **Expressions**: `a.b.c`\n * - **Types**: `number`, `string`, `boolean`\n *\n * Here is some characteristic of ASTNode:\n * - **Tree-like Structure**: ASTNodes can be nested to form a tree, representing complex variable structures.\n * - **Extendable**: New features can be added by extending the base ASTNode class.\n * - **Reactive**: Changes in an ASTNode's value trigger events, enabling reactive programming patterns.\n * - **Serializable**: ASTNodes can be converted to and from a JSON format (ASTNodeJSON) for storage or transmission.\n */\nexport abstract class ASTNode<JSON extends ASTNodeJSON = any> implements Disposable {\n /**\n * @deprecated\n * Get the injected options for the ASTNode.\n *\n * Please use `@injectToAst(XXXService) declare xxxService: XXXService` to achieve external dependency injection.\n */\n public readonly opts?: any;\n\n /**\n * The unique identifier of the ASTNode, which is **immutable**.\n * - Immutable: Once assigned, the key cannot be changed.\n * - Automatically generated if not specified, and cannot be changed as well.\n * - If a new key needs to be generated, the current ASTNode should be destroyed and a new ASTNode should be generated.\n */\n public readonly key: Identifier;\n\n /**\n * The kind of the ASTNode.\n */\n static readonly kind: ASTKindType;\n\n /**\n * Node flags, used to record some flag information.\n */\n public readonly flags: number = ASTNodeFlags.None;\n\n /**\n * The scope in which the ASTNode is located.\n */\n public readonly scope: Scope;\n\n /**\n * The parent ASTNode.\n */\n public readonly parent: ASTNode | undefined;\n\n /**\n * The version number of the ASTNode, which increments by 1 each time `fireChange` is called.\n */\n protected _version: number = 0;\n\n /**\n * Update lock.\n * - When set to `true`, `fireChange` will not trigger any events.\n * - This is useful when multiple updates are needed, and you want to avoid multiple triggers.\n */\n public changeLocked = false;\n\n /**\n * Parameters related to batch updates.\n */\n private _batch: {\n batching: boolean;\n hasChangesInBatch: boolean;\n } = {\n batching: false,\n hasChangesInBatch: false,\n };\n\n /**\n * AST node change Observable events, implemented based on RxJS.\n * - Emits the current ASTNode value upon subscription.\n * - Emits a new value whenever `fireChange` is called.\n */\n public readonly value$: BehaviorSubject<ASTNode> = new BehaviorSubject<ASTNode>(this as ASTNode);\n\n /**\n * Child ASTNodes.\n */\n protected _children = new Set<ASTNode>();\n\n /**\n * List of disposal handlers for the ASTNode.\n */\n public readonly toDispose: DisposableCollection = new DisposableCollection(\n Disposable.create(() => {\n // When a child element is deleted, the parent element triggers an update.\n this.parent?.fireChange();\n this.children.forEach((child) => child.dispose());\n })\n );\n\n /**\n * Callback triggered upon disposal.\n */\n onDispose = this.toDispose.onDispose;\n\n /**\n * Constructor.\n * @param createParams Necessary parameters for creating an ASTNode.\n * @param injectOptions Dependency injection for various modules.\n */\n constructor({ key, parent, scope }: CreateASTParams, opts?: any) {\n this.scope = scope;\n this.parent = parent;\n this.opts = opts;\n\n // Initialize the key value. If a key is passed in, use it; otherwise, generate a random one using nanoid.\n this.key = key || nanoid();\n\n // All `fireChange` calls within the subsequent `fromJSON` will be merged into one.\n this.fromJSON = this.withBatchUpdate(this.fromJSON.bind(this));\n\n // Add the kind field to the JSON output.\n const rawToJSON = this.toJSON?.bind(this);\n this.toJSON = () =>\n omitBy(\n {\n // always include kind\n kind: this.kind,\n ...(rawToJSON?.() || {}),\n },\n // remove undefined fields\n isNil\n ) as JSON;\n }\n\n /**\n * The type of the ASTNode.\n */\n get kind(): string {\n if (!(this.constructor as any).kind) {\n throw new Error(`ASTNode Registry need a kind: ${this.constructor.name}`);\n }\n return (this.constructor as any).kind;\n }\n\n /**\n * Parses AST JSON data.\n * @param json AST JSON data.\n */\n abstract fromJSON(json: JSON): void;\n\n /**\n * Gets all child ASTNodes of the current ASTNode.\n */\n get children(): ASTNode[] {\n return Array.from(this._children);\n }\n\n /**\n * Serializes the current ASTNode to ASTNodeJSON.\n * @returns\n */\n abstract toJSON(): JSON;\n\n /**\n * Creates a child ASTNode.\n * @param json The AST JSON of the child ASTNode.\n * @returns\n */\n protected createChildNode<ChildNode extends ASTNode = ASTNode>(json: ASTNodeJSON): ChildNode {\n const astRegisters = this.scope.variableEngine.astRegisters;\n\n const child = astRegisters.createAST(json, {\n parent: this,\n scope: this.scope,\n }) as ChildNode;\n\n // Add to the _children set.\n this._children.add(child);\n child.toDispose.push(\n Disposable.create(() => {\n this._children.delete(child);\n })\n );\n\n return child;\n }\n\n /**\n * Updates a child ASTNode, quickly implementing the consumption logic for child ASTNode updates.\n * @param keyInThis The specified key on the current object.\n */\n protected updateChildNodeByKey(keyInThis: keyof this, nextJSON?: ASTNodeJSON) {\n this.withBatchUpdate(updateChildNodeHelper).call(this, {\n getChildNode: () => this[keyInThis] as ASTNode,\n updateChildNode: (_node) => ((this as any)[keyInThis] = _node),\n removeChildNode: () => ((this as any)[keyInThis] = undefined),\n nextJSON,\n });\n }\n\n /**\n * Batch updates the ASTNode, merging all `fireChange` calls within the batch function into one.\n * @param updater The batch function.\n * @returns\n */\n protected withBatchUpdate<ParamTypes extends any[], ReturnType>(\n updater: (...args: ParamTypes) => ReturnType\n ) {\n return (...args: ParamTypes) => {\n // Nested batchUpdate can only take effect once.\n if (this._batch.batching) {\n return updater.call(this, ...args);\n }\n\n this._batch.hasChangesInBatch = false;\n\n this._batch.batching = true;\n const res = updater.call(this, ...args);\n this._batch.batching = false;\n\n if (this._batch.hasChangesInBatch) {\n this.fireChange();\n }\n this._batch.hasChangesInBatch = false;\n\n return res;\n };\n }\n\n /**\n * Triggers an update for the current node.\n */\n fireChange(): void {\n if (this.changeLocked || this.disposed) {\n return;\n }\n\n if (this._batch.batching) {\n this._batch.hasChangesInBatch = true;\n return;\n }\n\n this._version++;\n this.value$.next(this);\n this.dispatchGlobalEvent<UpdateASTAction>({ type: 'UpdateAST' });\n this.parent?.fireChange();\n }\n\n /**\n * The version value of the ASTNode.\n * - You can used to check whether ASTNode are updated.\n */\n get version(): number {\n return this._version;\n }\n\n /**\n * The unique hash value of the ASTNode.\n * - It will update when the ASTNode is updated.\n * - You can used to check two ASTNode are equal.\n */\n get hash(): string {\n return `${this._version}${this.kind}${this.key}`;\n }\n\n /**\n * Listens for changes to the ASTNode.\n * @param observer The listener callback.\n * @param selector Listens for specified data.\n * @returns\n */\n subscribe<Data = this>(\n observer: ObserverOrNext<Data>,\n { selector, debounceAnimation, triggerOnInit }: SubscribeConfig<this, Data> = {}\n ): Disposable {\n return subsToDisposable(\n this.value$\n .pipe(\n map(() => (selector ? selector(this) : (this as any))),\n distinctUntilChanged(\n (a, b) => shallowEqual(a, b),\n (value) => {\n if (value instanceof ASTNode) {\n // If the value is an ASTNode, compare its hash.\n return value.hash;\n }\n return value;\n }\n ),\n // By default, skip the first trigger of BehaviorSubject.\n triggerOnInit ? tap(() => null) : skip(1),\n // All updates within each animationFrame are merged into one.\n debounceAnimation ? debounceTime(0, animationFrameScheduler) : tap(() => null)\n )\n .subscribe(observer)\n );\n }\n\n /**\n * Dispatches a global event for the current ASTNode.\n * @param event The global event.\n */\n dispatchGlobalEvent<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n event: Omit<ActionType, 'ast'>\n ) {\n this.scope.event.dispatch({\n ...event,\n ast: this,\n });\n }\n\n /**\n * Disposes the ASTNode.\n */\n dispose(): void {\n // Prevent multiple disposals.\n if (this.toDispose.disposed) {\n return;\n }\n\n this.toDispose.dispose();\n this.dispatchGlobalEvent<DisposeASTAction>({ type: 'DisposeAST' });\n\n // When the complete event is emitted, ensure that the current ASTNode is in a disposed state.\n this.value$.complete();\n this.value$.unsubscribe();\n }\n\n get disposed(): boolean {\n return this.toDispose.disposed;\n }\n\n /**\n * Extended information of the ASTNode.\n */\n [key: string]: unknown;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\nimport { UnionJSON } from './union';\n\n/**\n * Base class for all types.\n *\n * All other types should extend this class.\n */\nexport abstract class BaseType<JSON extends ASTNodeJSON = any> extends ASTNode<JSON> {\n public flags: number = ASTNodeFlags.BasicType;\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n\n // If it is a Union type, it is sufficient for one of the subtypes to be equal.\n if (targetTypeJSON?.kind === ASTKind.Union) {\n return ((targetTypeJSON as UnionJSON)?.types || [])?.some((_subType) =>\n this.isTypeEqual(_subType)\n );\n }\n\n return this.kind === targetTypeJSON?.kind;\n }\n\n /**\n * Get a variable field by key path.\n *\n * This method should be implemented by drillable types.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[] = []): BaseVariableField | undefined {\n throw new Error(`Get By Key Path is not implemented for Type: ${this.kind}`);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `ArrayType`\n */\nexport interface ArrayJSON {\n /**\n * The type of the items in the array.\n */\n items?: ASTNodeJSONOrKind;\n}\n\n/**\n * Represents an array type.\n */\nexport class ArrayType extends BaseType<ArrayJSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType | ASTNodeFlags.EnumerateType;\n\n static kind: string = ASTKind.Array;\n\n /**\n * The type of the items in the array.\n */\n items: BaseType;\n\n /**\n * Deserializes the `ArrayJSON` to the `ArrayType`.\n * @param json The `ArrayJSON` to deserialize.\n */\n fromJSON({ items }: ArrayJSON): void {\n this.updateChildNodeByKey('items', parseTypeJsonOrKind(items));\n }\n\n /**\n * Whether the items type can be drilled down.\n */\n get canDrilldownItems(): boolean {\n return !!(this.items?.flags & ASTNodeFlags.DrilldownType);\n }\n\n /**\n * Get a variable field by key path.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n const [curr, ...rest] = keyPath || [];\n\n if (curr === '0' && this.canDrilldownItems) {\n // The first item of the array.\n return this.items.getByKeyPath(rest);\n }\n\n return undefined;\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Array strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n if (!this.items) {\n return !(targetTypeJSON as ArrayJSON)?.items;\n }\n return this.items?.isTypeEqual((targetTypeJSON as ArrayJSON).items);\n }\n\n /**\n * Serialize the `ArrayType` to `ArrayJSON`\n * @returns The JSON representation of `ArrayType`.\n */\n toJSON() {\n return {\n kind: ASTKind.Array,\n items: this.items?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of the `StringType`.\n */\nexport interface StringJSON {\n /**\n * see https://json-schema.org/understanding-json-schema/reference/type#format\n */\n format?: string;\n}\n\nexport class StringType extends BaseType<StringJSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.BasicType;\n\n static kind: string = ASTKind.String;\n\n protected _format?: string;\n\n /**\n * see https://json-schema.org/understanding-json-schema/reference/string#format\n */\n get format() {\n return this._format;\n }\n\n /**\n * Deserialize the `StringJSON` to the `StringType`.\n *\n * @param json StringJSON representation of the `StringType`.\n */\n fromJSON(json?: StringJSON): void {\n if (json?.format !== this._format) {\n this._format = json?.format;\n this.fireChange();\n }\n }\n\n /**\n * Serialize the `StringType` to `StringJSON`.\n * @returns The JSON representation of `StringType`.\n */\n toJSON() {\n return {\n format: this._format,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { BaseType } from './base-type';\n\n/**\n * Represents an integer type.\n */\nexport class IntegerType extends BaseType {\n public flags: ASTNodeFlags = ASTNodeFlags.BasicType;\n\n static kind: string = ASTKind.Integer;\n\n /**\n * Deserializes the `IntegerJSON` to the `IntegerType`.\n * @param json The `IntegerJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n\n toJSON() {\n return {};\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * Represents a boolean type.\n */\nexport class BooleanType extends BaseType {\n static kind: string = ASTKind.Boolean;\n\n /**\n * Deserializes the `BooleanJSON` to the `BooleanType`.\n * @param json The `BooleanJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n\n toJSON() {\n return {};\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * Represents a number type.\n */\nexport class NumberType extends BaseType {\n static kind: string = ASTKind.Number;\n\n /**\n * Deserializes the `NumberJSON` to the `NumberType`.\n * @param json The `NumberJSON` to deserialize.\n */\n fromJSON(): void {\n // noop\n }\n\n toJSON() {\n return {};\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON, ASTNodeJSONOrKind } from '../types';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `MapType`\n */\nexport interface MapJSON {\n /**\n * The type of the keys in the map.\n */\n keyType?: ASTNodeJSONOrKind;\n /**\n * The type of the values in the map.\n */\n valueType?: ASTNodeJSONOrKind;\n}\n\n/**\n * Represents a map type.\n */\nexport class MapType extends BaseType<MapJSON> {\n static kind: string = ASTKind.Map;\n\n /**\n * The type of the keys in the map.\n */\n keyType: BaseType;\n\n /**\n * The type of the values in the map.\n */\n valueType: BaseType;\n\n /**\n * Deserializes the `MapJSON` to the `MapType`.\n * @param json The `MapJSON` to deserialize.\n */\n fromJSON({ keyType = ASTKind.String, valueType }: MapJSON): void {\n // Key defaults to String.\n this.updateChildNodeByKey('keyType', parseTypeJsonOrKind(keyType));\n this.updateChildNodeByKey('valueType', parseTypeJsonOrKind(valueType));\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Map strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n const { keyType = ASTKind.String, valueType } = targetTypeJSON as MapJSON;\n\n const isValueTypeEqual =\n (!valueType && !this.valueType) || this.valueType?.isTypeEqual(valueType);\n\n return isValueTypeEqual && this.keyType?.isTypeEqual(keyType);\n }\n\n /**\n * Serialize the node to a JSON object.\n * @returns The JSON representation of the node.\n */\n toJSON() {\n return {\n kind: ASTKind.Map,\n keyType: this.keyType?.toJSON(),\n valueType: this.valueType?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { xor } from 'lodash-es';\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTNodeJSON, ASTKind, ASTNodeJSONOrKind, type GlobalEventActionType } from '../types';\nimport { ASTNodeFlags } from '../flags';\nimport { Property, type PropertyJSON } from '../declaration/property';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `ObjectType`\n */\nexport interface ObjectJSON<VariableMeta = any> {\n /**\n * The properties of the object.\n *\n * The `properties` of an Object must be of type `Property`, so the business can omit the `kind` field.\n */\n properties?: PropertyJSON<VariableMeta>[];\n}\n\n/**\n * Action type for object properties change.\n */\nexport type ObjectPropertiesChangeAction = GlobalEventActionType<\n 'ObjectPropertiesChange',\n {\n prev: Property[];\n next: Property[];\n },\n ObjectType\n>;\n\n/**\n * Represents an object type.\n */\nexport class ObjectType extends BaseType<ObjectJSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.DrilldownType;\n\n static kind: string = ASTKind.Object;\n\n /**\n * A map of property keys to `Property` instances.\n */\n propertyTable: Map<string, Property> = new Map();\n\n /**\n * An array of `Property` instances.\n */\n properties: Property[];\n\n /**\n * Deserializes the `ObjectJSON` to the `ObjectType`.\n * @param json The `ObjectJSON` to deserialize.\n */\n fromJSON({ properties }: ObjectJSON): void {\n const removedKeys = new Set(this.propertyTable.keys());\n const prev = [...(this.properties || [])];\n\n // Iterate over the new properties.\n this.properties = (properties || []).map((property: PropertyJSON) => {\n const existProperty = this.propertyTable.get(property.key);\n removedKeys.delete(property.key);\n\n if (existProperty) {\n existProperty.fromJSON(property as PropertyJSON);\n\n return existProperty;\n } else {\n const newProperty = this.createChildNode({\n ...property,\n kind: ASTKind.Property,\n }) as Property;\n\n this.fireChange();\n\n this.propertyTable.set(property.key, newProperty);\n // TODO: When a child node is actively destroyed, delete the information in the table.\n\n return newProperty;\n }\n });\n\n // Delete properties that no longer exist.\n removedKeys.forEach((key) => {\n const property = this.propertyTable.get(key);\n property?.dispose();\n this.propertyTable.delete(key);\n this.fireChange();\n });\n\n this.dispatchGlobalEvent<ObjectPropertiesChangeAction>({\n type: 'ObjectPropertiesChange',\n payload: {\n prev,\n next: [...this.properties],\n },\n });\n }\n\n /**\n * Serialize the `ObjectType` to `ObjectJSON`.\n * @returns The JSON representation of `ObjectType`.\n */\n toJSON() {\n return {\n properties: this.properties.map((_property) => _property.toJSON()),\n };\n }\n\n /**\n * Get a variable field by key path.\n * @param keyPath The key path to search for.\n * @returns The variable field if found, otherwise `undefined`.\n */\n getByKeyPath(keyPath: string[]): Property | undefined {\n const [curr, ...restKeyPath] = keyPath;\n\n const property = this.propertyTable.get(curr);\n\n // Found the end of the path.\n if (!restKeyPath.length) {\n return property;\n }\n\n // Otherwise, continue searching downwards.\n if (property?.type && property?.type?.flags & ASTNodeFlags.DrilldownType) {\n return property.type.getByKeyPath(restKeyPath) as Property | undefined;\n }\n\n return undefined;\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n const isSuperEqual = super.isTypeEqual(targetTypeJSONOrKind);\n\n if (targetTypeJSON?.weak || targetTypeJSON?.kind === ASTKind.Union) {\n return isSuperEqual;\n }\n\n return (\n targetTypeJSON &&\n isSuperEqual &&\n // Weak comparison, only need to compare the Kind.\n (targetTypeJSON?.weak || this.customStrongEqual(targetTypeJSON))\n );\n }\n\n /**\n * Object type strong comparison.\n * @param targetTypeJSON The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n protected customStrongEqual(targetTypeJSON: ASTNodeJSON): boolean {\n const targetProperties = (targetTypeJSON as ObjectJSON).properties || [];\n\n const sourcePropertyKeys = Array.from(this.propertyTable.keys());\n const targetPropertyKeys = targetProperties.map((_target) => _target.key);\n\n const isKeyStrongEqual = !xor(sourcePropertyKeys, targetPropertyKeys).length;\n\n return (\n isKeyStrongEqual &&\n targetProperties.every((targetProperty) => {\n const sourceProperty = this.propertyTable.get(targetProperty.key);\n\n return (\n sourceProperty &&\n sourceProperty.key === targetProperty.key &&\n sourceProperty.type?.isTypeEqual(targetProperty?.type)\n );\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { parseTypeJsonOrKind } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSONOrKind } from '../types';\nimport { type UnionJSON } from './union';\nimport { BaseType } from './base-type';\n\n/**\n * ASTNodeJSON representation of `CustomType`\n */\nexport interface CustomTypeJSON {\n /**\n * The name of the custom type.\n */\n typeName: string;\n}\n\n/**\n * Represents a custom type.\n */\nexport class CustomType extends BaseType<CustomTypeJSON> {\n static kind: string = ASTKind.CustomType;\n\n protected _typeName: string;\n\n /**\n * The name of the custom type.\n */\n get typeName(): string {\n return this._typeName;\n }\n\n /**\n * Deserializes the `CustomTypeJSON` to the `CustomType`.\n * @param json The `CustomTypeJSON` to deserialize.\n */\n fromJSON(json: CustomTypeJSON): void {\n if (this._typeName !== json.typeName) {\n this._typeName = json.typeName;\n this.fireChange();\n }\n }\n\n /**\n * Check if the current type is equal to the target type.\n * @param targetTypeJSONOrKind The type to compare with.\n * @returns `true` if the types are equal, `false` otherwise.\n */\n public isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean {\n const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);\n\n // If it is a Union type, it is sufficient for one of the subtypes to be equal.\n if (targetTypeJSON?.kind === ASTKind.Union) {\n return ((targetTypeJSON as UnionJSON)?.types || [])?.some((_subType) =>\n this.isTypeEqual(_subType)\n );\n }\n\n return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;\n }\n\n toJSON() {\n return {\n typeName: this.typeName,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n type Observable,\n distinctUntilChanged,\n map,\n switchMap,\n combineLatest,\n of,\n Subject,\n share,\n} from 'rxjs';\nimport { shallowEqual } from 'fast-equals';\n\nimport { getParentFields } from '../utils/variable-field';\nimport { ASTNodeJSON, type CreateASTParams } from '../types';\nimport { type BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { IVariableTable } from '../../scope/types';\n\ntype ExpressionRefs = (BaseVariableField | undefined)[];\n\n/**\n * Base class for all expressions.\n *\n * All other expressions should extend this class.\n */\nexport abstract class BaseExpression<JSON extends ASTNodeJSON = any> extends ASTNode<JSON> {\n public flags: ASTNodeFlags = ASTNodeFlags.Expression;\n\n /**\n * Get the global variable table, which is used to access referenced variables.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n /**\n * Parent variable fields, sorted from closest to farthest.\n */\n get parentFields(): BaseVariableField[] {\n return getParentFields(this);\n }\n\n /**\n * Get the variable fields referenced by the expression.\n *\n * This method should be implemented by subclasses.\n * @returns An array of referenced variable fields.\n */\n abstract getRefFields(): ExpressionRefs;\n\n /**\n * The return type of the expression.\n */\n abstract returnType: BaseType | undefined;\n\n /**\n * The variable fields referenced by the expression.\n */\n protected _refs: ExpressionRefs = [];\n\n /**\n * The variable fields referenced by the expression.\n */\n get refs(): ExpressionRefs {\n return this._refs;\n }\n\n protected refreshRefs$: Subject<void> = new Subject();\n\n /**\n * Refresh the variable references.\n */\n refreshRefs() {\n this.refreshRefs$.next();\n }\n\n /**\n * An observable that emits the referenced variable fields when they change.\n */\n refs$: Observable<ExpressionRefs> = this.refreshRefs$.pipe(\n map(() => this.getRefFields()),\n distinctUntilChanged<ExpressionRefs>(shallowEqual),\n switchMap((refs) =>\n !refs?.length\n ? of([])\n : combineLatest(\n refs.map((ref) =>\n ref\n ? (ref.value$ as unknown as Observable<BaseVariableField | undefined>)\n : of(undefined)\n )\n )\n ),\n share()\n );\n\n constructor(params: CreateASTParams, opts?: any) {\n super(params, opts);\n\n this.toDispose.push(\n subsToDisposable(\n this.refs$.subscribe((_refs: ExpressionRefs) => {\n this._refs = _refs;\n this.fireChange();\n })\n )\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTNodeFlags } from '../flags';\nimport { BaseVariableField } from '../declaration';\nimport { ASTNode } from '../ast-node';\n\n/**\n * Parent variable fields, sorted from nearest to farthest.\n */\nexport function getParentFields(ast: ASTNode): BaseVariableField[] {\n let curr = ast.parent;\n const res: BaseVariableField[] = [];\n\n while (curr) {\n if (curr.flags & ASTNodeFlags.VariableField) {\n res.push(curr as BaseVariableField);\n }\n curr = curr.parent;\n }\n\n return res;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ArrayType } from '../type/array';\nimport { BaseType } from '../type';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `EnumerateExpression`\n */\nexport interface EnumerateExpressionJSON {\n /**\n * The expression to be enumerated.\n */\n enumerateFor: ASTNodeJSON;\n}\n\n/**\n * Represents an enumeration expression, which iterates over a list and returns the type of the enumerated variable.\n */\nexport class EnumerateExpression extends BaseExpression<EnumerateExpressionJSON> {\n static kind: string = ASTKind.EnumerateExpression;\n\n protected _enumerateFor: BaseExpression | undefined;\n\n /**\n * The expression to be enumerated.\n */\n get enumerateFor() {\n return this._enumerateFor;\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n // The return value of the enumerated expression.\n const childReturnType = this.enumerateFor?.returnType;\n\n if (childReturnType?.kind === ASTKind.Array) {\n // Get the item type of the array.\n return (childReturnType as ArrayType).items;\n }\n\n return undefined;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An empty array, as this expression does not reference any variables.\n */\n getRefFields(): [] {\n return [];\n }\n\n /**\n * Deserializes the `EnumerateExpressionJSON` to the `EnumerateExpression`.\n * @param json The `EnumerateExpressionJSON` to deserialize.\n */\n fromJSON({ enumerateFor: expression }: EnumerateExpressionJSON): void {\n this.updateChildNodeByKey('_enumerateFor', expression);\n }\n\n /**\n * Serialize the `EnumerateExpression` to `EnumerateExpressionJSON`.\n * @returns The JSON representation of `EnumerateExpression`.\n */\n toJSON() {\n return {\n kind: ASTKind.EnumerateExpression,\n enumerateFor: this.enumerateFor?.toJSON(),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { distinctUntilChanged } from 'rxjs';\nimport { shallowEqual } from 'fast-equals';\n\nimport { checkRefCycle } from '../utils/expression';\nimport { ASTNodeJSON, ASTKind, CreateASTParams } from '../types';\nimport { BaseType } from '../type';\nimport { type BaseVariableField } from '../declaration';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `KeyPathExpression`\n */\nexport interface KeyPathExpressionJSON {\n /**\n * The key path of the variable.\n */\n keyPath: string[];\n}\n\n/**\n * Represents a key path expression, which is used to reference a variable by its key path.\n *\n * This is the V2 of `KeyPathExpression`, with the following improvements:\n * - `returnType` is copied to a new instance to avoid reference issues.\n * - Circular reference detection is introduced.\n */\nexport class KeyPathExpression<\n CustomPathJSON extends ASTNodeJSON = KeyPathExpressionJSON\n> extends BaseExpression<CustomPathJSON> {\n static kind: string = ASTKind.KeyPathExpression;\n\n protected _keyPath: string[] = [];\n\n protected _rawPathJson: CustomPathJSON;\n\n /**\n * The key path of the variable.\n */\n get keyPath(): string[] {\n return this._keyPath;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An array of referenced variable fields.\n */\n getRefFields(): BaseVariableField[] {\n const ref = this.scope.available.getByKeyPath(this._keyPath);\n\n // When refreshing references, check for circular references. If a circular reference exists, do not reference the variable.\n if (checkRefCycle(this, [ref])) {\n // Prompt that a circular reference exists.\n console.warn(\n '[CustomKeyPathExpression] checkRefCycle: Reference Cycle Existed',\n this.parentFields.map((_field) => _field.key).reverse()\n );\n return [];\n }\n\n return ref ? [ref] : [];\n }\n\n /**\n * The return type of the expression.\n *\n * A new `returnType` node is generated directly, instead of reusing the existing one, to ensure that different key paths do not point to the same field.\n */\n _returnType: BaseType;\n\n /**\n * The return type of the expression.\n */\n get returnType() {\n return this._returnType;\n }\n\n /**\n * Parse the business-defined path expression into a key path.\n *\n * Businesses can quickly customize their own path expressions by modifying this method.\n * @param json The path expression defined by the business.\n * @returns The key path.\n */\n protected parseToKeyPath(json: CustomPathJSON): string[] {\n // The default JSON is in KeyPathExpressionJSON format.\n return (json as unknown as KeyPathExpressionJSON).keyPath;\n }\n\n /**\n * Deserializes the `KeyPathExpressionJSON` to the `KeyPathExpression`.\n * @param json The `KeyPathExpressionJSON` to deserialize.\n */\n fromJSON(json: CustomPathJSON): void {\n const keyPath = this.parseToKeyPath(json);\n\n if (!shallowEqual(keyPath, this._keyPath)) {\n this._keyPath = keyPath;\n this._rawPathJson = json;\n\n // After the keyPath is updated, the referenced variables need to be refreshed.\n this.refreshRefs();\n }\n }\n\n /**\n * Get the return type JSON by reference.\n * @param _ref The referenced variable field.\n * @returns The JSON representation of the return type.\n */\n getReturnTypeJSONByRef(_ref: BaseVariableField | undefined): ASTNodeJSON | undefined {\n return _ref?.type?.toJSON();\n }\n\n constructor(params: CreateASTParams, opts: any) {\n super(params, opts);\n\n this.toDispose.pushAll([\n // Can be used when the variable list changes (when there are additions or deletions).\n this.scope.available.onVariableListChange(() => {\n this.refreshRefs();\n }),\n // When the referable variable pointed to by this._keyPath changes, refresh the reference data.\n this.scope.available.onAnyVariableChange((_v) => {\n if (_v.key === this._keyPath[0]) {\n this.refreshRefs();\n }\n }),\n subsToDisposable(\n this.refs$\n .pipe(\n distinctUntilChanged(\n (prev, next) => prev === next,\n (_refs) => _refs?.[0]?.type?.hash\n )\n )\n .subscribe((_type) => {\n const [ref] = this._refs;\n this.updateChildNodeByKey('_returnType', this.getReturnTypeJSONByRef(ref));\n })\n ),\n ]);\n }\n\n /**\n * Serialize the `KeyPathExpression` to `KeyPathExpressionJSON`.\n * @returns The JSON representation of `KeyPathExpression`.\n */\n toJSON() {\n return this._rawPathJson;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { intersection } from 'lodash-es';\n\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseExpression } from '../expression';\nimport { type BaseVariableField } from '../declaration';\nimport { type ASTNode } from '../ast-node';\nimport { getParentFields } from './variable-field';\nimport { getAllChildren } from './helpers';\n\n/**\n * Get all variables referenced by child ASTs.\n * @param ast The ASTNode to traverse.\n * @returns All variables referenced by child ASTs.\n */\nexport function getAllRefs(ast: ASTNode): BaseVariableField[] {\n return getAllChildren(ast)\n .filter((_child) => _child.flags & ASTNodeFlags.Expression)\n .map((_child) => (_child as BaseExpression).refs)\n .flat()\n .filter(Boolean) as BaseVariableField[];\n}\n\n/**\n * Checks for circular references.\n * @param curr The current expression.\n * @param refNode The referenced variable node.\n * @returns Whether a circular reference exists.\n */\nexport function checkRefCycle(\n curr: BaseExpression,\n refNodes: (BaseVariableField | undefined)[]\n): boolean {\n // If there are no circular references in the scope, then it is impossible to have a circular reference.\n if (\n intersection(curr.scope.coverScopes, refNodes.map((_ref) => _ref?.scope).filter(Boolean))\n .length === 0\n ) {\n return false;\n }\n\n // BFS traversal.\n const visited = new Set<BaseVariableField>();\n const queue = [...refNodes];\n\n while (queue.length) {\n const currNode = queue.shift()!;\n visited.add(currNode);\n\n for (const ref of getAllRefs(currNode).filter((_ref) => !visited.has(_ref))) {\n queue.push(ref);\n }\n }\n\n // If the referenced variables include the parent variable of the expression, then there is a circular reference.\n return intersection(Array.from(visited), getParentFields(curr)).length > 0;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { ASTNodeJSON, ASTKind, CreateASTParams } from '../types';\nimport { BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseVariableField } from '../declaration';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `KeyPathExpression`\n */\nexport interface KeyPathExpressionJSON {\n /**\n * The key path of the variable.\n */\n keyPath: string[];\n}\n\n/**\n * @deprecated Use `KeyPathExpression` instead.\n * Represents a key path expression, which is used to reference a variable by its key path.\n */\nexport class LegacyKeyPathExpression<\n CustomPathJSON extends ASTNodeJSON = KeyPathExpressionJSON\n> extends BaseExpression<CustomPathJSON> {\n static kind: string = ASTKind.KeyPathExpression;\n\n protected _keyPath: string[] = [];\n\n protected _rawPathJson: CustomPathJSON;\n\n /**\n * The key path of the variable.\n */\n get keyPath(): string[] {\n return this._keyPath;\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An array of referenced variable fields.\n */\n getRefFields(): BaseVariableField[] {\n const ref = this.scope.available.getByKeyPath(this._keyPath);\n return ref ? [ref] : [];\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n const [refNode] = this._refs || [];\n\n // Get the type of the referenced variable.\n if (refNode && refNode.flags & ASTNodeFlags.VariableField) {\n return refNode.type;\n }\n\n return;\n }\n\n /**\n * Parse the business-defined path expression into a key path.\n *\n * Businesses can quickly customize their own path expressions by modifying this method.\n * @param json The path expression defined by the business.\n * @returns The key path.\n */\n protected parseToKeyPath(json: CustomPathJSON): string[] {\n // The default JSON is in KeyPathExpressionJSON format.\n return (json as unknown as KeyPathExpressionJSON).keyPath;\n }\n\n /**\n * Deserializes the `KeyPathExpressionJSON` to the `KeyPathExpression`.\n * @param json The `KeyPathExpressionJSON` to deserialize.\n */\n fromJSON(json: CustomPathJSON): void {\n const keyPath = this.parseToKeyPath(json);\n\n if (!shallowEqual(keyPath, this._keyPath)) {\n this._keyPath = keyPath;\n this._rawPathJson = json;\n\n // After the keyPath is updated, the referenced variables need to be refreshed.\n this.refreshRefs();\n }\n }\n\n constructor(params: CreateASTParams, opts: any) {\n super(params, opts);\n\n this.toDispose.pushAll([\n // Can be used when the variable list changes (when there are additions or deletions).\n this.scope.available.onVariableListChange(() => {\n this.refreshRefs();\n }),\n // When the referable variable pointed to by this._keyPath changes, refresh the reference data.\n this.scope.available.onAnyVariableChange((_v) => {\n if (_v.key === this._keyPath[0]) {\n this.refreshRefs();\n }\n }),\n ]);\n }\n\n /**\n * Serialize the `KeyPathExpression` to `KeyPathExpressionJSON`.\n * @returns The JSON representation of `KeyPathExpression`.\n */\n toJSON() {\n return this._rawPathJson;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { postConstructAST } from '../utils/inversify';\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { BaseType } from '../type';\nimport { BaseExpression } from './base-expression';\n\n/**\n * ASTNodeJSON representation of `WrapArrayExpression`\n */\nexport interface WrapArrayExpressionJSON {\n /**\n * The expression to be wrapped.\n */\n wrapFor: ASTNodeJSON;\n}\n\n/**\n * Represents a wrap expression, which wraps an expression with an array.\n */\nexport class WrapArrayExpression extends BaseExpression<WrapArrayExpressionJSON> {\n static kind: string = ASTKind.WrapArrayExpression;\n\n protected _wrapFor: BaseExpression | undefined;\n\n protected _returnType: BaseType | undefined;\n\n /**\n * The expression to be wrapped.\n */\n get wrapFor() {\n return this._wrapFor;\n }\n\n /**\n * The return type of the expression.\n */\n get returnType(): BaseType | undefined {\n return this._returnType;\n }\n\n /**\n * Refresh the return type of the expression.\n */\n refreshReturnType() {\n // The return value of the wrapped expression.\n const childReturnTypeJSON = this.wrapFor?.returnType?.toJSON();\n\n this.updateChildNodeByKey('_returnType', {\n kind: ASTKind.Array,\n items: childReturnTypeJSON,\n });\n }\n\n /**\n * Get the variable fields referenced by the expression.\n * @returns An empty array, as this expression does not reference any variables.\n */\n getRefFields(): [] {\n return [];\n }\n\n /**\n * Deserializes the `WrapArrayExpressionJSON` to the `WrapArrayExpression`.\n * @param json The `WrapArrayExpressionJSON` to deserialize.\n */\n fromJSON({ wrapFor: expression }: WrapArrayExpressionJSON): void {\n this.updateChildNodeByKey('_wrapFor', expression);\n }\n\n /**\n * Serialize the `WrapArrayExpression` to `WrapArrayExpressionJSON`.\n * @returns The JSON representation of `WrapArrayExpression`.\n */\n toJSON() {\n return {\n kind: ASTKind.WrapArrayExpression,\n wrapFor: this.wrapFor?.toJSON(),\n };\n }\n\n @postConstructAST()\n protected init() {\n this.refreshReturnType = this.refreshReturnType.bind(this);\n\n this.toDispose.push(\n this.subscribe(this.refreshReturnType, {\n selector: (curr) => curr.wrapFor?.returnType,\n triggerOnInit: true,\n })\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { getParentFields } from '../utils/variable-field';\nimport { ASTNodeJSON, ASTNodeJSONOrKind, Identifier } from '../types';\nimport { type BaseType } from '../type';\nimport { ASTNodeFlags } from '../flags';\nimport { type BaseExpression } from '../expression';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `BaseVariableField`\n */\nexport interface BaseVariableFieldJSON<VariableMeta = any> extends ASTNodeJSON {\n /**\n * key of the variable field\n * - For `VariableDeclaration`, the key should be global unique.\n * - For `Property`, the key is the property name.\n */\n key: Identifier;\n /**\n * type of the variable field, similar to js code:\n * `const v: string`\n */\n type?: ASTNodeJSONOrKind;\n /**\n * initializer of the variable field, similar to js code:\n * `const v = 'hello'`\n *\n * with initializer, the type of field will be inferred from the initializer.\n */\n initializer?: ASTNodeJSON;\n /**\n * meta data of the variable field, you cans store information like `title`, `icon`, etc.\n */\n meta?: VariableMeta;\n}\n\n/**\n * Variable Field abstract class, which is the base class for `VariableDeclaration` and `Property`\n *\n * - `VariableDeclaration` is used to declare a variable in a block scope.\n * - `Property` is used to declare a property in an object.\n */\nexport abstract class BaseVariableField<VariableMeta = any> extends ASTNode<\n BaseVariableFieldJSON<VariableMeta>\n> {\n public flags: ASTNodeFlags = ASTNodeFlags.VariableField;\n\n protected _type?: BaseType;\n\n protected _meta: VariableMeta = {} as any;\n\n protected _initializer?: BaseExpression;\n\n /**\n * Parent variable fields, sorted from closest to farthest\n */\n get parentFields(): BaseVariableField[] {\n return getParentFields(this);\n }\n\n /**\n * KeyPath of the variable field, sorted from farthest to closest\n */\n get keyPath(): string[] {\n return [...this.parentFields.reverse().map((_field) => _field.key), this.key];\n }\n\n /**\n * Metadata of the variable field, you cans store information like `title`, `icon`, etc.\n */\n get meta(): VariableMeta {\n return this._meta;\n }\n\n /**\n * Type of the variable field, similar to js code:\n * `const v: string`\n */\n get type(): BaseType {\n return (this._initializer?.returnType || this._type)!;\n }\n\n /**\n * Initializer of the variable field, similar to js code:\n * `const v = 'hello'`\n *\n * with initializer, the type of field will be inferred from the initializer.\n */\n get initializer(): BaseExpression | undefined {\n return this._initializer;\n }\n\n /**\n * The global unique hash of the field, and will be changed when the field is updated.\n */\n get hash(): string {\n return `[${this._version}]${this.keyPath.join('.')}`;\n }\n\n /**\n * Deserialize the `BaseVariableFieldJSON` to the `BaseVariableField`.\n * @param json ASTJSON representation of `BaseVariableField`\n */\n fromJSON({ type, initializer, meta }: Omit<BaseVariableFieldJSON<VariableMeta>, 'key'>): void {\n // 类型变化\n this.updateType(type);\n\n // 表达式更新\n this.updateInitializer(initializer);\n\n // Extra 更新\n this.updateMeta(meta!);\n }\n\n /**\n * Update the type of the variable field\n * @param type type ASTJSON representation of Type\n */\n updateType(type: BaseVariableFieldJSON['type']) {\n const nextTypeJson = typeof type === 'string' ? { kind: type } : type;\n this.updateChildNodeByKey('_type', nextTypeJson);\n }\n\n /**\n * Update the initializer of the variable field\n * @param nextInitializer initializer ASTJSON representation of Expression\n */\n updateInitializer(nextInitializer?: BaseVariableFieldJSON['initializer']) {\n this.updateChildNodeByKey('_initializer', nextInitializer);\n }\n\n /**\n * Update the meta data of the variable field\n * @param nextMeta meta data of the variable field\n */\n updateMeta(nextMeta: VariableMeta) {\n if (!shallowEqual(nextMeta, this._meta)) {\n this._meta = nextMeta;\n this.fireChange();\n }\n }\n\n /**\n * Get the variable field by keyPath, similar to js code:\n * `v.a.b`\n * @param keyPath\n * @returns\n */\n getByKeyPath(keyPath: string[]): BaseVariableField | undefined {\n if (this.type?.flags & ASTNodeFlags.DrilldownType) {\n return this.type.getByKeyPath(keyPath) as BaseVariableField | undefined;\n }\n\n return undefined;\n }\n\n /**\n * Subscribe to type change of the variable field\n * @param observer\n * @returns\n */\n onTypeChange(observer: (type: ASTNode | undefined) => void) {\n return this.subscribe(observer, { selector: (curr) => curr.type });\n }\n\n /**\n * Serialize the variable field to JSON\n * @returns ASTNodeJSON representation of `BaseVariableField`\n */\n toJSON(): BaseVariableFieldJSON<VariableMeta> {\n return {\n key: this.key,\n type: this.type?.toJSON(),\n initializer: this.initializer?.toJSON(),\n meta: this._meta,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, GlobalEventActionType, type CreateASTParams } from '../types';\nimport { BaseVariableField, BaseVariableFieldJSON } from './base-variable-field';\n\n/**\n * ASTNodeJSON representation of the `VariableDeclaration`.\n */\nexport type VariableDeclarationJSON<VariableMeta = any> = BaseVariableFieldJSON<VariableMeta> & {\n /**\n * Variable sorting order, which is used to sort variables in `scope.outputs.variables`\n */\n order?: number;\n};\n\n/**\n * Action type for re-sorting variable declarations.\n */\nexport type ReSortVariableDeclarationsAction = GlobalEventActionType<'ReSortVariableDeclarations'>;\n\n/**\n * `VariableDeclaration` is a variable field that represents a variable declaration.\n */\nexport class VariableDeclaration<VariableMeta = any> extends BaseVariableField<VariableMeta> {\n static kind: string = ASTKind.VariableDeclaration;\n\n protected _order: number = 0;\n\n /**\n * Variable sorting order, which is used to sort variables in `scope.outputs.variables`\n */\n get order(): number {\n return this._order;\n }\n\n constructor(params: CreateASTParams) {\n super(params);\n }\n\n /**\n * Deserialize the `VariableDeclarationJSON` to the `VariableDeclaration`.\n */\n fromJSON({ order, ...rest }: Omit<VariableDeclarationJSON<VariableMeta>, 'key'>): void {\n // Update order.\n this.updateOrder(order);\n\n // Update other information.\n super.fromJSON(rest as BaseVariableFieldJSON<VariableMeta>);\n }\n\n /**\n * Update the sorting order of the variable declaration.\n * @param order Variable sorting order. Default is 0.\n */\n updateOrder(order: number = 0): void {\n if (order !== this._order) {\n this._order = order;\n this.dispatchGlobalEvent<ReSortVariableDeclarationsAction>({\n type: 'ReSortVariableDeclarations',\n });\n this.fireChange();\n }\n }\n\n /**\n * Serialize the `VariableDeclaration` to `VariableDeclarationJSON`.\n * @returns The JSON representation of `VariableDeclaration`.\n */\n toJSON(): VariableDeclarationJSON<VariableMeta> {\n return {\n ...super.toJSON(),\n order: this.order,\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { GlobalEventActionType } from '../types';\nimport { ASTNode } from '../ast-node';\nimport { type VariableDeclarationJSON, VariableDeclaration } from './variable-declaration';\n\nexport interface VariableDeclarationListJSON<VariableMeta = any> {\n /**\n * `declarations` must be of type `VariableDeclaration`, so the business can omit the `kind` field.\n */\n declarations?: VariableDeclarationJSON<VariableMeta>[];\n /**\n * The starting order number for variables.\n */\n startOrder?: number;\n}\n\nexport type VariableDeclarationListChangeAction = GlobalEventActionType<\n 'VariableListChange',\n {\n prev: VariableDeclaration[];\n next: VariableDeclaration[];\n },\n VariableDeclarationList\n>;\n\nexport class VariableDeclarationList extends ASTNode<VariableDeclarationListJSON> {\n static kind: string = ASTKind.VariableDeclarationList;\n\n /**\n * Map of variable declarations, keyed by variable name.\n */\n declarationTable: Map<string, VariableDeclaration> = new Map();\n\n /**\n * Variable declarations, sorted by `order`.\n */\n declarations: VariableDeclaration[];\n\n /**\n * Deserialize the `VariableDeclarationListJSON` to the `VariableDeclarationList`.\n * - VariableDeclarationListChangeAction will be dispatched after deserialization.\n *\n * @param declarations Variable declarations.\n * @param startOrder The starting order number for variables. Default is 0.\n */\n fromJSON({ declarations, startOrder }: VariableDeclarationListJSON): void {\n const removedKeys = new Set(this.declarationTable.keys());\n const prev = [...(this.declarations || [])];\n\n // Iterate over the new properties.\n this.declarations = (declarations || []).map(\n (declaration: VariableDeclarationJSON, idx: number) => {\n const order = (startOrder || 0) + idx;\n\n // If the key is not set, reuse the previous key.\n const declarationKey = declaration.key || this.declarations?.[idx]?.key;\n const existDeclaration = this.declarationTable.get(declarationKey);\n if (declarationKey) {\n removedKeys.delete(declarationKey);\n }\n\n if (existDeclaration) {\n existDeclaration.fromJSON({ order, ...declaration });\n\n return existDeclaration;\n } else {\n const newDeclaration = this.createChildNode({\n order,\n ...declaration,\n kind: ASTKind.VariableDeclaration,\n }) as VariableDeclaration;\n this.fireChange();\n\n this.declarationTable.set(newDeclaration.key, newDeclaration);\n\n return newDeclaration;\n }\n }\n );\n\n // Delete variables that no longer exist.\n removedKeys.forEach((key) => {\n const declaration = this.declarationTable.get(key);\n declaration?.dispose();\n this.declarationTable.delete(key);\n });\n\n this.dispatchGlobalEvent<VariableDeclarationListChangeAction>({\n type: 'VariableListChange',\n payload: {\n prev,\n next: [...this.declarations],\n },\n });\n }\n\n /**\n * Serialize the `VariableDeclarationList` to the `VariableDeclarationListJSON`.\n * @returns ASTJSON representation of `VariableDeclarationList`\n */\n toJSON() {\n return {\n kind: ASTKind.VariableDeclarationList,\n declarations: this.declarations.map((_declaration) => _declaration.toJSON()),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind } from '../types';\nimport { BaseVariableField, BaseVariableFieldJSON } from './base-variable-field';\n\n/**\n * ASTNodeJSON representation of the `Property`.\n */\nexport type PropertyJSON<VariableMeta = any> = BaseVariableFieldJSON<VariableMeta>;\n\n/**\n * `Property` is a variable field that represents a property of a `ObjectType`.\n */\nexport class Property<VariableMeta = any> extends BaseVariableField<VariableMeta> {\n static kind: string = ASTKind.Property;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { shallowEqual } from 'fast-equals';\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * Represents a general data node with no child nodes.\n */\nexport class DataNode<Data = any> extends ASTNode {\n static kind: string = ASTKind.DataNode;\n\n protected _data: Data;\n\n /**\n * The data of the node.\n */\n get data(): Data {\n return this._data;\n }\n\n /**\n * Deserializes the `DataNodeJSON` to the `DataNode`.\n * @param json The `DataNodeJSON` to deserialize.\n */\n fromJSON(json: Data): void {\n const { kind, ...restData } = json as ASTNodeJSON;\n\n if (!shallowEqual(restData, this._data)) {\n this._data = restData as unknown as Data;\n this.fireChange();\n }\n }\n\n /**\n * Serialize the `DataNode` to `DataNodeJSON`.\n * @returns The JSON representation of `DataNode`.\n */\n toJSON() {\n return {\n kind: ASTKind.DataNode,\n ...this._data,\n };\n }\n\n /**\n * Partially update the data of the node.\n * @param nextData The data to be updated.\n */\n partialUpdate(nextData: Data) {\n if (!shallowEqual(nextData, this._data)) {\n this._data = {\n ...this._data,\n ...nextData,\n };\n this.fireChange();\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `ListNode`\n */\nexport interface ListNodeJSON {\n /**\n * The list of nodes.\n */\n list: ASTNodeJSON[];\n}\n\n/**\n * Represents a list of nodes.\n */\nexport class ListNode extends ASTNode<ListNodeJSON> {\n static kind: string = ASTKind.ListNode;\n\n protected _list: ASTNode[];\n\n /**\n * The list of nodes.\n */\n get list(): ASTNode[] {\n return this._list;\n }\n\n /**\n * Deserializes the `ListNodeJSON` to the `ListNode`.\n * @param json The `ListNodeJSON` to deserialize.\n */\n fromJSON({ list }: ListNodeJSON): void {\n // Children that exceed the length need to be destroyed.\n this._list.slice(list.length).forEach((_item) => {\n _item.dispose();\n this.fireChange();\n });\n\n // Processing of remaining children.\n this._list = list.map((_item, idx) => {\n const prevItem = this._list[idx];\n\n if (prevItem.kind !== _item.kind) {\n prevItem.dispose();\n this.fireChange();\n return this.createChildNode(_item);\n }\n\n prevItem.fromJSON(_item);\n return prevItem;\n });\n }\n\n /**\n * Serialize the `ListNode` to `ListNodeJSON`.\n * @returns The JSON representation of `ListNode`.\n */\n toJSON() {\n return {\n kind: ASTKind.ListNode,\n list: this._list.map((item) => item.toJSON()),\n };\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { updateChildNodeHelper } from '../utils/helpers';\nimport { ASTKind, ASTNodeJSON } from '../types';\nimport { ASTNode } from '../ast-node';\n\n/**\n * ASTNodeJSON representation of `MapNode`\n */\nexport interface MapNodeJSON {\n /**\n * The map of nodes.\n */\n map: [string, ASTNodeJSON][];\n}\n\n/**\n * Represents a map of nodes.\n */\nexport class MapNode extends ASTNode<MapNodeJSON> {\n static kind: string = ASTKind.MapNode;\n\n protected map: Map<string, ASTNode> = new Map<string, ASTNode>();\n\n /**\n * Deserializes the `MapNodeJSON` to the `MapNode`.\n * @param json The `MapNodeJSON` to deserialize.\n */\n fromJSON({ map }: MapNodeJSON): void {\n const removedKeys = new Set(this.map.keys());\n\n for (const [key, item] of map || []) {\n removedKeys.delete(key);\n this.set(key, item);\n }\n\n for (const removeKey of Array.from(removedKeys)) {\n this.remove(removeKey);\n }\n }\n\n /**\n * Serialize the `MapNode` to `MapNodeJSON`.\n * @returns The JSON representation of `MapNode`.\n */\n toJSON() {\n return {\n kind: ASTKind.MapNode,\n map: Array.from(this.map.entries()),\n };\n }\n\n /**\n * Set a node in the map.\n * @param key The key of the node.\n * @param nextJSON The JSON representation of the node.\n * @returns The node instance.\n */\n set<Node extends ASTNode = ASTNode>(key: string, nextJSON: ASTNodeJSON): Node {\n return this.withBatchUpdate(updateChildNodeHelper).call(this, {\n getChildNode: () => this.get(key),\n removeChildNode: () => this.map.delete(key),\n updateChildNode: (nextNode) => this.map.set(key, nextNode),\n nextJSON,\n }) as Node;\n }\n\n /**\n * Remove a node from the map.\n * @param key The key of the node.\n */\n remove(key: string) {\n this.get(key)?.dispose();\n this.map.delete(key);\n this.fireChange();\n }\n\n /**\n * Get a node from the map.\n * @param key The key of the node.\n * @returns The node instance if found, otherwise `undefined`.\n */\n get<Node extends ASTNode = ASTNode>(key: string): Node | undefined {\n return this.map.get(key) as Node | undefined;\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { ASTKind, ASTNodeJSON } from './types';\nimport { StringJSON } from './type/string';\nimport { MapJSON } from './type/map';\nimport { ArrayJSON } from './type/array';\nimport { CustomTypeJSON, ObjectJSON, UnionJSON } from './type';\nimport {\n EnumerateExpressionJSON,\n KeyPathExpressionJSON,\n WrapArrayExpressionJSON,\n} from './expression';\nimport { PropertyJSON, VariableDeclarationJSON, VariableDeclarationListJSON } from './declaration';\nimport { ASTNode } from './ast-node';\n\n/**\n * Variable-core ASTNode factories.\n */\nexport namespace ASTFactory {\n /**\n * Type-related factories.\n */\n\n /**\n * Creates a `String` type node.\n */\n export const createString = (json?: StringJSON) => ({\n kind: ASTKind.String,\n ...(json || {}),\n });\n\n /**\n * Creates a `Number` type node.\n */\n export const createNumber = () => ({ kind: ASTKind.Number });\n\n /**\n * Creates a `Boolean` type node.\n */\n export const createBoolean = () => ({ kind: ASTKind.Boolean });\n\n /**\n * Creates an `Integer` type node.\n */\n export const createInteger = () => ({ kind: ASTKind.Integer });\n\n /**\n * Creates an `Object` type node.\n */\n export const createObject = (json: ObjectJSON) => ({\n kind: ASTKind.Object,\n ...json,\n });\n\n /**\n * Creates an `Array` type node.\n */\n export const createArray = (json: ArrayJSON) => ({\n kind: ASTKind.Array,\n ...json,\n });\n\n /**\n * Creates a `Map` type node.\n */\n export const createMap = (json: MapJSON) => ({\n kind: ASTKind.Map,\n ...json,\n });\n\n /**\n * Creates a `Union` type node.\n */\n export const createUnion = (json: UnionJSON) => ({\n kind: ASTKind.Union,\n ...json,\n });\n\n /**\n * Creates a `CustomType` node.\n */\n export const createCustomType = (json: CustomTypeJSON) => ({\n kind: ASTKind.CustomType,\n ...json,\n });\n\n /**\n * Declaration-related factories.\n */\n\n /**\n * Creates a `VariableDeclaration` node.\n */\n export const createVariableDeclaration = <VariableMeta = any>(\n json: VariableDeclarationJSON<VariableMeta>\n ) => ({\n kind: ASTKind.VariableDeclaration,\n ...json,\n });\n\n /**\n * Creates a `Property` node.\n */\n export const createProperty = <VariableMeta = any>(json: PropertyJSON<VariableMeta>) => ({\n kind: ASTKind.Property,\n ...json,\n });\n\n /**\n * Creates a `VariableDeclarationList` node.\n */\n export const createVariableDeclarationList = (json: VariableDeclarationListJSON) => ({\n kind: ASTKind.VariableDeclarationList,\n ...json,\n });\n\n /**\n * Expression-related factories.\n */\n\n /**\n * Creates an `EnumerateExpression` node.\n */\n export const createEnumerateExpression = (json: EnumerateExpressionJSON) => ({\n kind: ASTKind.EnumerateExpression,\n ...json,\n });\n\n /**\n * Creates a `KeyPathExpression` node.\n */\n export const createKeyPathExpression = (json: KeyPathExpressionJSON) => ({\n kind: ASTKind.KeyPathExpression,\n ...json,\n });\n\n /**\n * Creates a `WrapArrayExpression` node.\n */\n export const createWrapArrayExpression = (json: WrapArrayExpressionJSON) => ({\n kind: ASTKind.WrapArrayExpression,\n ...json,\n });\n\n /**\n * Create by AST Class.\n */\n\n /**\n * Creates Type-Safe ASTNodeJSON object based on the provided AST class.\n *\n * @param targetType Target ASTNode class.\n * @param json The JSON data for the node.\n * @returns The ASTNode JSON object.\n */\n export const create = <JSON extends ASTNodeJSON>(\n targetType: { kind: string; new (...args: any[]): ASTNode<JSON> },\n json: JSON\n ) => ({ kind: targetType.kind, ...json });\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { VariableTable } from '../variable-table';\nimport { IVariableTable } from '../types';\nimport { type Scope } from '../scope';\nimport { type VariableEngine } from '../../variable-engine';\nimport { createMemo } from '../../utils/memo';\nimport { NewASTAction } from '../../ast/types';\nimport { DisposeASTAction } from '../../ast/types';\nimport { ReSortVariableDeclarationsAction } from '../../ast/declaration/variable-declaration';\nimport { ASTKind, type VariableDeclaration } from '../../ast';\n\n/**\n * Manages the output variables of a scope.\n */\nexport class ScopeOutputData {\n protected variableTable: IVariableTable;\n\n protected memo = createMemo();\n\n /**\n * The variable engine instance.\n */\n get variableEngine(): VariableEngine {\n return this.scope.variableEngine;\n }\n\n /**\n * The global variable table from the variable engine.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n /**\n * The current version of the output data, which increments on each change.\n */\n get version() {\n return this.variableTable.version;\n }\n\n /**\n * @deprecated use onListOrAnyVarChange instead\n */\n get onDataChange() {\n return this.variableTable.onDataChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when the list of output variables changes.\n */\n get onVariableListChange() {\n return this.variableTable.onVariableListChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when any output variable's value changes.\n */\n get onAnyVariableChange() {\n return this.variableTable.onAnyVariableChange.bind(this.variableTable);\n }\n\n /**\n * An event that fires when the output variable list changes or any variable's value is updated.\n */\n get onListOrAnyVarChange() {\n return this.variableTable.onListOrAnyVarChange.bind(this.variableTable);\n }\n\n protected _hasChanges = false;\n\n constructor(public readonly scope: Scope) {\n // Setup scope variable table based on globalVariableTable\n this.variableTable = new VariableTable(scope.variableEngine.globalVariableTable);\n\n this.scope.toDispose.pushAll([\n // When the root AST node is updated, check if there are any changes.\n this.scope.ast.subscribe(() => {\n if (this._hasChanges) {\n this.memo.clear();\n this.notifyCoversChange();\n this.variableTable.fireChange();\n this._hasChanges = false;\n }\n }),\n this.scope.event.on<DisposeASTAction>('DisposeAST', (_action) => {\n if (_action.ast?.kind === ASTKind.VariableDeclaration) {\n this.removeVariableFromTable(_action.ast.key);\n }\n }),\n this.scope.event.on<NewASTAction>('NewAST', (_action) => {\n if (_action.ast?.kind === ASTKind.VariableDeclaration) {\n this.addVariableToTable(_action.ast as VariableDeclaration);\n }\n }),\n this.scope.event.on<ReSortVariableDeclarationsAction>('ReSortVariableDeclarations', () => {\n this._hasChanges = true;\n }),\n this.variableTable,\n ]);\n }\n\n /**\n * The output variable declarations of the scope, sorted by order.\n */\n get variables(): VariableDeclaration[] {\n return this.memo('variables', () =>\n this.variableTable.variables.sort((a, b) => a.order - b.order)\n );\n }\n\n /**\n * The keys of the output variables.\n */\n get variableKeys(): string[] {\n return this.memo('variableKeys', () => this.variableTable.variableKeys);\n }\n\n protected addVariableToTable(variable: VariableDeclaration) {\n if (variable.scope !== this.scope) {\n throw Error('VariableDeclaration must be a ast node in scope');\n }\n\n (this.variableTable as VariableTable).addVariableToTable(variable);\n this._hasChanges = true;\n }\n\n protected removeVariableFromTable(key: string) {\n (this.variableTable as VariableTable).removeVariableFromTable(key);\n this._hasChanges = true;\n }\n\n /**\n * Retrieves a variable declaration by its key.\n * @param key The key of the variable.\n * @returns The `VariableDeclaration` or `undefined` if not found.\n */\n getVariableByKey(key: string) {\n return this.variableTable.getVariableByKey(key);\n }\n\n /**\n * Notifies the covering scopes that the available variables have changed.\n */\n notifyCoversChange(): void {\n this.scope.coverScopes.forEach((scope) => scope.available.refresh());\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n Observable,\n Subject,\n animationFrameScheduler,\n debounceTime,\n distinctUntilChanged,\n map,\n merge,\n share,\n skip,\n startWith,\n switchMap,\n tap,\n} from 'rxjs';\nimport { flatten } from 'lodash-es';\nimport { shallowEqual } from 'fast-equals';\nimport { Disposable } from '@flowgram.ai/utils';\nimport { Emitter } from '@flowgram.ai/utils';\n\nimport { IVariableTable } from '../types';\nimport { type Scope } from '../scope';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { createMemo } from '../../utils/memo';\nimport { SubscribeConfig } from '../../ast/types';\nimport { ASTNode, BaseVariableField, VariableDeclaration } from '../../ast';\n\n/**\n * Manages the available variables within a scope.\n */\nexport class ScopeAvailableData {\n protected memo = createMemo();\n\n /**\n * The global variable table from the variable engine.\n */\n get globalVariableTable(): IVariableTable {\n return this.scope.variableEngine.globalVariableTable;\n }\n\n protected _version: number = 0;\n\n protected refresh$: Subject<void> = new Subject();\n\n protected _variables: VariableDeclaration[] = [];\n\n /**\n * The current version of the available data, which increments on each change.\n */\n get version() {\n return this._version;\n }\n\n protected bumpVersion() {\n this._version = this._version + 1;\n if (this._version === Number.MAX_SAFE_INTEGER) {\n this._version = 0;\n }\n }\n\n /**\n * Refreshes the list of available variables.\n * This should be called when the dependencies of the scope change.\n */\n refresh(): void {\n // Do not trigger refresh for a disposed scope.\n if (this.scope.disposed) {\n return;\n }\n this.refresh$.next();\n }\n\n /**\n * An observable that emits when the list of available variables changes.\n */\n protected variables$: Observable<VariableDeclaration[]> = this.refresh$.pipe(\n // Map to the flattened list of variables from all dependency scopes.\n map(() => flatten(this.depScopes.map((scope) => scope.output.variables || []))),\n // Use shallow equality to check if the variable list has changed.\n distinctUntilChanged<VariableDeclaration[]>(shallowEqual),\n share()\n );\n\n /**\n * An observable that emits when any variable in the available list changes its value.\n */\n protected anyVariableChange$: Observable<VariableDeclaration> = this.variables$.pipe(\n switchMap((_variables) =>\n merge(\n ..._variables.map((_v) =>\n _v.value$.pipe<any>(\n // Skip the initial value of the BehaviorSubject.\n skip(1)\n )\n )\n )\n ),\n share()\n );\n\n /**\n * Subscribes to changes in any variable's value in the available list.\n * @param observer A function to be called with the changed variable.\n * @returns A disposable to unsubscribe from the changes.\n */\n onAnyVariableChange(observer: (changedVariable: VariableDeclaration) => void) {\n return subsToDisposable(this.anyVariableChange$.subscribe(observer));\n }\n\n /**\n * Subscribes to changes in the list of available variables.\n * @param observer A function to be called with the new list of variables.\n * @returns A disposable to unsubscribe from the changes.\n */\n onVariableListChange(observer: (variables: VariableDeclaration[]) => void) {\n return subsToDisposable(this.variables$.subscribe(observer));\n }\n\n /**\n * @deprecated\n */\n protected onDataChangeEmitter = new Emitter<VariableDeclaration[]>();\n\n protected onListOrAnyVarChangeEmitter = new Emitter<VariableDeclaration[]>();\n\n /**\n * @deprecated use available.onListOrAnyVarChange instead\n */\n public onDataChange = this.onDataChangeEmitter.event;\n\n /**\n * An event that fires when the variable list changes or any variable's value is updated.\n */\n public onListOrAnyVarChange = this.onListOrAnyVarChangeEmitter.event;\n\n constructor(public readonly scope: Scope) {\n this.scope.toDispose.pushAll([\n this.onVariableListChange((_variables) => {\n this._variables = _variables;\n this.memo.clear();\n this.onDataChangeEmitter.fire(this._variables);\n this.bumpVersion();\n this.onListOrAnyVarChangeEmitter.fire(this._variables);\n }),\n this.onAnyVariableChange(() => {\n this.onDataChangeEmitter.fire(this._variables);\n this.bumpVersion();\n this.onListOrAnyVarChangeEmitter.fire(this._variables);\n }),\n Disposable.create(() => {\n this.refresh$.complete();\n this.refresh$.unsubscribe();\n }),\n ]);\n }\n\n /**\n * Gets the list of available variables.\n */\n get variables(): VariableDeclaration[] {\n return this._variables;\n }\n\n /**\n * Gets the keys of the available variables.\n */\n get variableKeys(): string[] {\n return this.memo('availableKeys', () => this._variables.map((_v) => _v.key));\n }\n\n /**\n * Gets the dependency scopes.\n */\n get depScopes(): Scope[] {\n return this.scope.depScopes;\n }\n\n /**\n * Retrieves a variable field by its key path from the available variables.\n * @param keyPath The key path to the variable field.\n * @returns The found `BaseVariableField` or `undefined`.\n */\n getByKeyPath(keyPath: string[] = []): BaseVariableField | undefined {\n // Check if the variable is accessible in the current scope.\n if (!this.variableKeys.includes(keyPath[0])) {\n return;\n }\n return this.globalVariableTable.getByKeyPath(keyPath);\n }\n\n /**\n * Tracks changes to a variable field by its key path.\n * This includes changes to its type, value, or any nested properties.\n * @param keyPath The key path to the variable field to track.\n * @param cb The callback to execute when the variable changes.\n * @param opts Configuration options for the subscription.\n * @returns A disposable to unsubscribe from the tracking.\n */\n trackByKeyPath<Data = BaseVariableField | undefined>(\n keyPath: string[] = [],\n cb: (variable?: Data) => void,\n opts?: SubscribeConfig<BaseVariableField | undefined, Data>\n ): Disposable {\n const { triggerOnInit = true, debounceAnimation, selector } = opts || {};\n\n return subsToDisposable(\n merge(this.anyVariableChange$, this.variables$)\n .pipe(\n triggerOnInit ? startWith() : tap(() => null),\n map(() => {\n const v = this.getByKeyPath(keyPath);\n return selector ? selector(v) : (v as any);\n }),\n distinctUntilChanged(\n (a, b) => shallowEqual(a, b),\n (value) => {\n if (value instanceof ASTNode) {\n // If the value is an ASTNode, compare its hash for changes.\n return value.hash;\n }\n return value;\n }\n ),\n // Debounce updates to a single emission per animation frame.\n debounceAnimation ? debounceTime(0, animationFrameScheduler) : tap(() => null)\n )\n .subscribe(cb)\n );\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { Subject, filter } from 'rxjs';\nimport { Disposable } from '@flowgram.ai/utils';\n\nimport { type Scope } from '../scope';\nimport { subsToDisposable } from '../../utils/toDisposable';\nimport { type GlobalEventActionType } from '../../ast';\n\ntype Observer<ActionType extends GlobalEventActionType = GlobalEventActionType> = (\n action: ActionType\n) => void;\n\n/**\n * Manages global events within a scope.\n */\nexport class ScopeEventData {\n event$: Subject<GlobalEventActionType> = new Subject<GlobalEventActionType>();\n\n /**\n * Dispatches a global event.\n * @param action The event action to dispatch.\n */\n dispatch<ActionType extends GlobalEventActionType = GlobalEventActionType>(action: ActionType) {\n if (this.scope.disposed) {\n return;\n }\n this.event$.next(action);\n }\n\n /**\n * Subscribes to all global events.\n * @param observer The observer function to call with the event action.\n * @returns A disposable to unsubscribe from the events.\n */\n subscribe<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n observer: Observer<ActionType>\n ): Disposable {\n return subsToDisposable(this.event$.subscribe(observer as Observer));\n }\n\n /**\n * Subscribes to a specific type of global event.\n * @param type The type of the event to subscribe to.\n * @param observer The observer function to call with the event action.\n * @returns A disposable to unsubscribe from the event.\n */\n on<ActionType extends GlobalEventActionType = GlobalEventActionType>(\n type: ActionType['type'],\n observer: Observer<ActionType>\n ): Disposable {\n return subsToDisposable(\n this.event$.pipe(filter((_action) => _action.type === type)).subscribe(observer as Observer)\n );\n }\n\n constructor(public readonly scope: Scope) {\n scope.toDispose.pushAll([\n this.subscribe((_action) => {\n scope.variableEngine.fireGlobalEvent(_action);\n }),\n ]);\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { difference } from 'lodash-es';\nimport { inject, injectable, postConstruct, preDestroy } from 'inversify';\nimport { DisposableCollection, Emitter } from '@flowgram.ai/utils';\n\nimport { VariableEngine } from '../variable-engine';\nimport {\n ASTNode,\n BaseVariableField,\n ObjectPropertiesChangeAction,\n VariableDeclarationListChangeAction,\n} from '../ast';\n\ninterface RenameInfo {\n before: BaseVariableField;\n after: BaseVariableField;\n}\n\n/**\n * This service is responsible for detecting when a variable field's key is renamed.\n * It listens for changes in variable declaration lists and object properties, and\n * determines if a change constitutes a rename operation.\n */\n@injectable()\nexport class VariableFieldKeyRenameService {\n @inject(VariableEngine) variableEngine: VariableEngine;\n\n toDispose = new DisposableCollection();\n\n renameEmitter = new Emitter<RenameInfo>();\n\n /**\n * Emits events for fields that are disposed of during a list change, but not renamed.\n * This helps distinguish between a field that was truly removed and one that was renamed.\n */\n disposeInListEmitter = new Emitter<BaseVariableField>();\n\n /**\n * An event that fires when a variable field key is successfully renamed.\n */\n onRename = this.renameEmitter.event;\n\n /**\n * An event that fires when a field is removed from a list (and not part of a rename).\n */\n onDisposeInList = this.disposeInListEmitter.event;\n\n /**\n * Handles changes in a list of fields to detect rename operations.\n * @param ast The AST node where the change occurred.\n * @param prev The list of fields before the change.\n * @param next The list of fields after the change.\n */\n handleFieldListChange(ast?: ASTNode, prev?: BaseVariableField[], next?: BaseVariableField[]) {\n // 1. Check if a rename is possible.\n if (!ast || !prev?.length || !next?.length) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n // 2. The lengths of the lists must be the same for a rename.\n if (prev.length !== next.length) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n let renameNodeInfo: RenameInfo | null = null;\n let existFieldChanged = false;\n\n for (const [index, prevField] of prev.entries()) {\n const nextField = next[index];\n\n if (prevField.key !== nextField.key) {\n // Only one rename is allowed at a time.\n if (existFieldChanged) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n existFieldChanged = true;\n\n if (prevField.type?.kind === nextField.type?.kind) {\n renameNodeInfo = { before: prevField, after: nextField };\n }\n }\n }\n\n if (!renameNodeInfo) {\n this.notifyFieldsDispose(prev, next);\n return;\n }\n\n this.renameEmitter.fire(renameNodeInfo);\n }\n\n /**\n * Notifies listeners about fields that were removed from a list.\n * @param prev The list of fields before the change.\n * @param next The list of fields after the change.\n */\n notifyFieldsDispose(prev?: BaseVariableField[], next?: BaseVariableField[]) {\n const removedFields = difference(prev || [], next || []);\n removedFields.forEach((_field) => this.disposeInListEmitter.fire(_field));\n }\n\n @postConstruct()\n init() {\n this.toDispose.pushAll([\n this.variableEngine.onGlobalEvent<VariableDeclarationListChangeAction>(\n 'VariableListChange',\n (_action) => {\n this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);\n }\n ),\n this.variableEngine.onGlobalEvent<ObjectPropertiesChangeAction>(\n 'ObjectPropertiesChange',\n (_action) => {\n this.handleFieldListChange(_action.ast, _action.payload?.prev, _action.payload?.next);\n }\n ),\n ]);\n }\n\n @preDestroy()\n dispose() {\n this.toDispose.dispose();\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable react/prop-types */\n\nimport React, { createContext, useContext } from 'react';\n\nimport { Scope } from '../scope';\n\ninterface ScopeContextProps {\n scope: Scope;\n}\n\nconst ScopeContext = createContext<ScopeContextProps>(null!);\n\n/**\n * ScopeProvider provides the scope to its children via context.\n */\nexport const ScopeProvider = (\n props: React.PropsWithChildren<{\n /**\n * scope used in the context\n */\n scope?: Scope;\n /**\n * @deprecated use scope prop instead, this is kept for backward compatibility\n */\n value?: ScopeContextProps;\n }>\n) => {\n const { scope, value, children } = props;\n\n const scopeToUse = scope || value?.scope;\n\n if (!scopeToUse) {\n throw new Error('[ScopeProvider] scope is required');\n }\n\n return <ScopeContext.Provider value={{ scope: scopeToUse }}>{children}</ScopeContext.Provider>;\n};\n\n/**\n * useCurrentScope returns the scope provided by ScopeProvider.\n * @returns\n */\nexport const useCurrentScope = <Strict extends boolean = false>(params?: {\n /**\n * whether to throw error when no scope in ScopeProvider is found\n */\n strict: Strict;\n}): Strict extends true ? Scope : Scope | undefined => {\n const { strict = false } = params || {};\n\n const context = useContext(ScopeContext);\n\n if (!context) {\n if (strict) {\n throw new Error('useCurrentScope must be used within a <ScopeProvider scope={scope}>');\n }\n console.warn('useCurrentScope should be used within a <ScopeProvider scope={scope}>');\n }\n\n return context?.scope;\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { ScopeAvailableData } from '../../scope/datas';\n\n/**\n * Get the available variables in the current scope.\n * 获取作用域的可访问变量\n *\n * @returns the available variables in the current scope\n */\nexport function useScopeAvailable(params?: { autoRefresh?: boolean }): ScopeAvailableData {\n const { autoRefresh = true } = params || {};\n\n const scope = useCurrentScope({ strict: true });\n const refresh = useRefresh();\n\n useEffect(() => {\n if (!autoRefresh) {\n return () => null;\n }\n\n const disposable = scope.available.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, [autoRefresh]);\n\n return scope.available;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh, useService } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { VariableEngine } from '../../variable-engine';\nimport { VariableDeclaration } from '../../ast';\n\n/**\n * Get available variable list in the current scope.\n *\n * - If no scope, return global variable list.\n * - The hook is reactive to variable list or any variables change.\n */\nexport function useAvailableVariables(): VariableDeclaration[] {\n const scope = useCurrentScope();\n const variableEngine: VariableEngine = useService(VariableEngine);\n\n const refresh = useRefresh();\n\n useEffect(() => {\n // 没有作用域时,监听全局变量表\n if (!scope) {\n const disposable = variableEngine.globalVariableTable.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }\n\n const disposable = scope.available.onDataChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, []);\n\n // 没有作用域时,使用全局变量表\n return scope ? scope.available.variables : variableEngine.globalVariableTable.variables;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect } from 'react';\n\nimport { useRefresh } from '@flowgram.ai/core';\n\nimport { useCurrentScope } from '../context';\nimport { VariableDeclaration } from '../../ast';\n\n/**\n * Get output variable list in the current scope.\n *\n * - The hook is reactive to variable list or any variables change.\n */\nexport function useOutputVariables(): VariableDeclaration[] {\n const scope = useCurrentScope();\n\n const refresh = useRefresh();\n\n useEffect(() => {\n if (!scope) {\n throw new Error(\n '[useOutputVariables]: No scope found, useOutputVariables must be used in <ScopeProvider>'\n );\n }\n\n const disposable = scope.output.onListOrAnyVarChange(() => {\n refresh();\n });\n\n return () => disposable.dispose();\n }, []);\n\n return scope?.output.variables || [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAAA,oBAAgC;;;ACAhC,IAAAC,eAAwB;AACxB,IAAAC,oBAA2D;AAC3D,IAAAC,gBAAiD;AACjD,IAAAA,gBAAwB;;;ACFxB,mBAA2B;AAOpB,SAAS,iBAAiB,cAAwC;AACvE,SAAO,wBAAW,OAAO,MAAM,aAAa,YAAY,CAAC;AAC3D;;;ACJO,IAAM,aAAa,MAGrB;AACH,QAAM,aAAa,oBAAI,IAAkB;AAEzC,QAAM,OAAO,CAAI,KAAc,OAAmB;AAChD,QAAI,WAAW,IAAI,GAAG,GAAG;AACvB,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A,EAClC,GAAG,CAAC,CAAC;AAEL,SAAO,OAAO,OAAO,aAAa,CAAC;AACrC;","names":["import_inversify","import_rxjs","import_inversify","import_utils","import_utils","import_utils","import_utils","ASTKind","import_lodash_es","import_inversify","ASTNodeFlags","ASTMatch","import_rxjs","import_utils","import_lodash_es","import_rxjs","import_fast_equals","import_rxjs","import_fast_equals","import_lodash_es","import_fast_equals","import_fast_equals","import_fast_equals","map","ASTNode","ASTFactory","import_rxjs","import_lodash_es","import_fast_equals","import_utils","import_rxjs","import_lodash_es","import_inversify","import_utils","React","import_react","import_react","import_core","disposable","import_react","import_core"]}
|