From fbff238e5ea6a9cf8372803fbc48df95dafdbc46 Mon Sep 17 00:00:00 2001 From: VictorS67 <185000048@qq.com> Date: Mon, 1 Jul 2024 10:40:27 -0400 Subject: [PATCH] fix data does not have function getAttributes --- packages/core/src/studio/registration/nodes.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/src/studio/registration/nodes.ts b/packages/core/src/studio/registration/nodes.ts index 100bc5a..a3214da 100644 --- a/packages/core/src/studio/registration/nodes.ts +++ b/packages/core/src/studio/registration/nodes.ts @@ -1,3 +1,5 @@ +import { load } from '../../load/index.js'; +import { globalImportMap, globalSecretMap } from '../../load/registration.js'; import { type Serializable } from '../../load/serializable.js'; import { type NodeImpl } from '../nodes/base.js'; import { type SerializableNode } from '../nodes/index.js'; @@ -261,7 +263,7 @@ export class NodeRegistration< * @returns A new node implementation instance. * @throws an error if the node's type-subtype pair is unknown. */ - createImpl(node: T): NodeImpl { + async createImpl(node: T): Promise> { const key = [node.type, node.subType].join('-'); const nodeImpl = this.info[key] as { @@ -276,6 +278,9 @@ export class NodeRegistration< const { impl: Impl } = nodeImpl; + const data = await load(JSON.stringify(node.data), globalSecretMap, globalImportMap); + node.data = data; + const newNodeImpl = new Impl(node as any) as unknown as NodeImpl; if (!newNodeImpl) { @@ -340,7 +345,7 @@ export class NodeRegistration< * @throws An error if no implementation is registered for the node's type and subtype. * @returns An instance of `NodeImpl` for the given node, enabling further interaction and processing. */ - createDynamicImpl(node: SerializableNode): NodeImpl { + async createDynamicImpl(node: SerializableNode): Promise> { const { type, subType } = node; const implClass = this.dynamicImplsMap[`${type}-${subType}`]; if (!implClass) { @@ -349,6 +354,9 @@ export class NodeRegistration< ); } + const data = await load(JSON.stringify(node.data), globalSecretMap, globalImportMap); + node.data = data; + const newNodeImpl = new implClass.impl(node); if (!newNodeImpl) { throw new Error(