@flowgram.ai/node-core-plugin 0.1.0-alpha.10
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 +89 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +53 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/create-node-core-plugin.ts
|
|
2
|
+
import { FormModelV2 } from "@flowgram.ai/node";
|
|
3
|
+
import {
|
|
4
|
+
createNodeContainerModules,
|
|
5
|
+
createNodeEntityDatas,
|
|
6
|
+
FlowNodeFormData,
|
|
7
|
+
FormManager as FormManager2,
|
|
8
|
+
NodeManager as NodeManager2
|
|
9
|
+
} from "@flowgram.ai/form-core";
|
|
10
|
+
import { FlowDocument } from "@flowgram.ai/document";
|
|
11
|
+
import { definePluginCreator, EntityManager } from "@flowgram.ai/core";
|
|
12
|
+
|
|
13
|
+
// src/utils.ts
|
|
14
|
+
import {
|
|
15
|
+
DecoratorAbility,
|
|
16
|
+
EffectAbility,
|
|
17
|
+
registerNodeErrorRender,
|
|
18
|
+
registerNodePlaceholderRender,
|
|
19
|
+
SetterAbility,
|
|
20
|
+
ValidationAbility
|
|
21
|
+
} from "@flowgram.ai/form-core";
|
|
22
|
+
function registerNodeMaterial({
|
|
23
|
+
nodeManager,
|
|
24
|
+
formManager,
|
|
25
|
+
material
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
setters = [],
|
|
29
|
+
decorators = [],
|
|
30
|
+
effects = [],
|
|
31
|
+
validators = [],
|
|
32
|
+
nodeErrorRender,
|
|
33
|
+
nodePlaceholderRender
|
|
34
|
+
} = material;
|
|
35
|
+
if (nodeErrorRender) {
|
|
36
|
+
registerNodeErrorRender(nodeManager, nodeErrorRender);
|
|
37
|
+
}
|
|
38
|
+
if (nodePlaceholderRender) {
|
|
39
|
+
registerNodePlaceholderRender(nodeManager, nodePlaceholderRender);
|
|
40
|
+
}
|
|
41
|
+
setters.forEach((setter) => {
|
|
42
|
+
formManager.registerAbilityExtension(SetterAbility.type, setter);
|
|
43
|
+
});
|
|
44
|
+
decorators.forEach((decorator) => {
|
|
45
|
+
formManager.registerAbilityExtension(DecoratorAbility.type, decorator);
|
|
46
|
+
});
|
|
47
|
+
effects.forEach((effect) => {
|
|
48
|
+
formManager.registerAbilityExtension(EffectAbility.type, effect);
|
|
49
|
+
});
|
|
50
|
+
validators.forEach((validator) => {
|
|
51
|
+
formManager.registerAbilityExtension(ValidationAbility.type, validator);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/create-node-core-plugin.ts
|
|
56
|
+
var createNodeCorePlugin = definePluginCreator({
|
|
57
|
+
onInit(ctx, options) {
|
|
58
|
+
ctx.get(FlowDocument).registerNodeDatas(...createNodeEntityDatas());
|
|
59
|
+
const formModelFactory = (entity) => new FormModelV2(entity);
|
|
60
|
+
const entityManager = ctx.get(EntityManager);
|
|
61
|
+
entityManager.registerEntityData(
|
|
62
|
+
FlowNodeFormData,
|
|
63
|
+
() => ({
|
|
64
|
+
formModelFactory
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
if (!options.materials) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const nodeManager = ctx.get(NodeManager2);
|
|
71
|
+
const formManager = ctx.get(FormManager2);
|
|
72
|
+
if (!nodeManager || !formManager) {
|
|
73
|
+
throw new Error("NodeCorePlugin Error: nodeManager or formManager not found");
|
|
74
|
+
}
|
|
75
|
+
registerNodeMaterial({ nodeManager, formManager, material: options.materials });
|
|
76
|
+
},
|
|
77
|
+
onDispose(ctx) {
|
|
78
|
+
ctx.get(FormManager2)?.dispose();
|
|
79
|
+
},
|
|
80
|
+
containerModules: createNodeContainerModules()
|
|
81
|
+
// onBind: ({ bind }) => {
|
|
82
|
+
// bindContributions(bind, FormNodeContribution, [NodeContribution]);
|
|
83
|
+
// },
|
|
84
|
+
});
|
|
85
|
+
export {
|
|
86
|
+
createNodeCorePlugin,
|
|
87
|
+
registerNodeMaterial
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/create-node-core-plugin.ts","../../src/utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormModelV2 } from '@flowgram.ai/node';\nimport {\n createNodeContainerModules,\n createNodeEntityDatas,\n FlowNodeFormData,\n FormManager,\n NodeManager,\n} from '@flowgram.ai/form-core';\nimport { FlowDocument, FlowNodeEntity } from '@flowgram.ai/document';\nimport { definePluginCreator, EntityManager } from '@flowgram.ai/core';\n\nimport { registerNodeMaterial } from './utils';\nimport { NodeEngineMaterialOptions } from './types';\n\nexport interface NodeCorePluginOptions {\n materials?: NodeEngineMaterialOptions;\n}\n\nexport const createNodeCorePlugin = definePluginCreator<NodeCorePluginOptions>({\n onInit(ctx, options) {\n /**\n * 注册NodeEngine 相关 EntityData 到flowDocument\n */\n ctx.get<FlowDocument>(FlowDocument).registerNodeDatas(...createNodeEntityDatas());\n\n const formModelFactory = (entity: FlowNodeEntity) => new FormModelV2(entity);\n const entityManager = ctx.get<EntityManager>(EntityManager);\n entityManager.registerEntityData(\n FlowNodeFormData,\n () =>\n ({\n formModelFactory: formModelFactory,\n } as any)\n );\n\n if (!options.materials) {\n return;\n }\n\n const nodeManager = ctx.get<NodeManager>(NodeManager);\n const formManager = ctx.get<FormManager>(FormManager);\n\n if (!nodeManager || !formManager) {\n throw new Error('NodeCorePlugin Error: nodeManager or formManager not found');\n }\n\n registerNodeMaterial({ nodeManager, formManager, material: options.materials! });\n },\n onDispose(ctx) {\n ctx.get<FormManager>(FormManager)?.dispose();\n },\n containerModules: createNodeContainerModules(),\n // onBind: ({ bind }) => {\n // bindContributions(bind, FormNodeContribution, [NodeContribution]);\n // },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n DecoratorAbility,\n DecoratorExtension,\n EffectAbility,\n EffectExtension,\n FormManager,\n NodeManager,\n registerNodeErrorRender,\n registerNodePlaceholderRender,\n SetterAbility,\n SetterExtension,\n ValidationAbility,\n ValidationExtension,\n} from '@flowgram.ai/form-core';\n\nimport { NodeEngineMaterialOptions } from './types';\n\ninterface RegisterNodeMaterialProps {\n nodeManager: NodeManager;\n formManager: FormManager;\n material: NodeEngineMaterialOptions;\n}\n\nexport function registerNodeMaterial({\n nodeManager,\n formManager,\n material,\n}: RegisterNodeMaterialProps) {\n const {\n setters = [],\n decorators = [],\n effects = [],\n validators = [],\n nodeErrorRender,\n nodePlaceholderRender,\n } = material;\n\n if (nodeErrorRender) {\n registerNodeErrorRender(nodeManager, nodeErrorRender);\n }\n if (nodePlaceholderRender) {\n registerNodePlaceholderRender(nodeManager, nodePlaceholderRender);\n }\n setters.forEach((setter: SetterExtension) => {\n formManager.registerAbilityExtension(SetterAbility.type, setter);\n });\n decorators.forEach((decorator: DecoratorExtension) => {\n formManager.registerAbilityExtension(DecoratorAbility.type, decorator);\n });\n effects.forEach((effect: EffectExtension) => {\n formManager.registerAbilityExtension(EffectAbility.type, effect);\n });\n validators.forEach((validator: ValidationExtension) => {\n formManager.registerAbilityExtension(ValidationAbility.type, validator);\n });\n}\n"],"mappings":";AAKA,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAAA;AAAA,EACA,eAAAC;AAAA,OACK;AACP,SAAS,oBAAoC;AAC7C,SAAS,qBAAqB,qBAAqB;;;ACTnD;AAAA,EACE;AAAA,EAEA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAEK;AAUA,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF,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AAK;AACb,QAAI,IAAiBA,YAAW,GAAG,QAAQ;AAAA,EAC7C;AAAA,EACA,kBAAkB,2BAA2B;AAAA;AAAA;AAAA;AAI/C,CAAC;","names":["FormManager","NodeManager","NodeManager","FormManager"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
2
|
+
import { SetterExtension, DecoratorExtension, EffectExtension, ValidationExtension, NodeErrorRender, NodePlaceholderRender, NodeManager, FormManager } from '@flowgram.ai/form-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface NodeEngineMaterialOptions {
|
|
10
|
+
/**
|
|
11
|
+
* 节点项的渲染物料
|
|
12
|
+
*/
|
|
13
|
+
setters?: SetterExtension[];
|
|
14
|
+
/**
|
|
15
|
+
* 节点项的渲染装饰器物料
|
|
16
|
+
*/
|
|
17
|
+
decorators?: DecoratorExtension[];
|
|
18
|
+
/**
|
|
19
|
+
* 副作用物料
|
|
20
|
+
*/
|
|
21
|
+
effects?: EffectExtension[];
|
|
22
|
+
/**
|
|
23
|
+
* 校验物料
|
|
24
|
+
*/
|
|
25
|
+
validators?: ValidationExtension[];
|
|
26
|
+
/**
|
|
27
|
+
* 节点内部报错的渲染组件
|
|
28
|
+
*/
|
|
29
|
+
nodeErrorRender?: NodeErrorRender;
|
|
30
|
+
/**
|
|
31
|
+
* 节点无内容时的渲染组件
|
|
32
|
+
*/
|
|
33
|
+
nodePlaceholderRender?: NodePlaceholderRender;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface NodeCorePluginOptions {
|
|
37
|
+
materials?: NodeEngineMaterialOptions;
|
|
38
|
+
}
|
|
39
|
+
declare const createNodeCorePlugin: _flowgram_ai_core.PluginCreator<NodeCorePluginOptions>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
43
|
+
* SPDX-License-Identifier: MIT
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
interface RegisterNodeMaterialProps {
|
|
47
|
+
nodeManager: NodeManager;
|
|
48
|
+
formManager: FormManager;
|
|
49
|
+
material: NodeEngineMaterialOptions;
|
|
50
|
+
}
|
|
51
|
+
declare function registerNodeMaterial({ nodeManager, formManager, material, }: RegisterNodeMaterialProps): void;
|
|
52
|
+
|
|
53
|
+
export { type NodeCorePluginOptions, type NodeEngineMaterialOptions, createNodeCorePlugin, registerNodeMaterial };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as _flowgram_ai_core from '@flowgram.ai/core';
|
|
2
|
+
import { SetterExtension, DecoratorExtension, EffectExtension, ValidationExtension, NodeErrorRender, NodePlaceholderRender, NodeManager, FormManager } from '@flowgram.ai/form-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface NodeEngineMaterialOptions {
|
|
10
|
+
/**
|
|
11
|
+
* 节点项的渲染物料
|
|
12
|
+
*/
|
|
13
|
+
setters?: SetterExtension[];
|
|
14
|
+
/**
|
|
15
|
+
* 节点项的渲染装饰器物料
|
|
16
|
+
*/
|
|
17
|
+
decorators?: DecoratorExtension[];
|
|
18
|
+
/**
|
|
19
|
+
* 副作用物料
|
|
20
|
+
*/
|
|
21
|
+
effects?: EffectExtension[];
|
|
22
|
+
/**
|
|
23
|
+
* 校验物料
|
|
24
|
+
*/
|
|
25
|
+
validators?: ValidationExtension[];
|
|
26
|
+
/**
|
|
27
|
+
* 节点内部报错的渲染组件
|
|
28
|
+
*/
|
|
29
|
+
nodeErrorRender?: NodeErrorRender;
|
|
30
|
+
/**
|
|
31
|
+
* 节点无内容时的渲染组件
|
|
32
|
+
*/
|
|
33
|
+
nodePlaceholderRender?: NodePlaceholderRender;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface NodeCorePluginOptions {
|
|
37
|
+
materials?: NodeEngineMaterialOptions;
|
|
38
|
+
}
|
|
39
|
+
declare const createNodeCorePlugin: _flowgram_ai_core.PluginCreator<NodeCorePluginOptions>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
43
|
+
* SPDX-License-Identifier: MIT
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
interface RegisterNodeMaterialProps {
|
|
47
|
+
nodeManager: NodeManager;
|
|
48
|
+
formManager: FormManager;
|
|
49
|
+
material: NodeEngineMaterialOptions;
|
|
50
|
+
}
|
|
51
|
+
declare function registerNodeMaterial({ nodeManager, formManager, material, }: RegisterNodeMaterialProps): void;
|
|
52
|
+
|
|
53
|
+
export { type NodeCorePluginOptions, type NodeEngineMaterialOptions, createNodeCorePlugin, registerNodeMaterial };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
createNodeCorePlugin: () => createNodeCorePlugin,
|
|
24
|
+
registerNodeMaterial: () => registerNodeMaterial
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/create-node-core-plugin.ts
|
|
29
|
+
var import_node = require("@flowgram.ai/node");
|
|
30
|
+
var import_form_core2 = require("@flowgram.ai/form-core");
|
|
31
|
+
var import_document = require("@flowgram.ai/document");
|
|
32
|
+
var import_core = require("@flowgram.ai/core");
|
|
33
|
+
|
|
34
|
+
// src/utils.ts
|
|
35
|
+
var import_form_core = require("@flowgram.ai/form-core");
|
|
36
|
+
function registerNodeMaterial({
|
|
37
|
+
nodeManager,
|
|
38
|
+
formManager,
|
|
39
|
+
material
|
|
40
|
+
}) {
|
|
41
|
+
const {
|
|
42
|
+
setters = [],
|
|
43
|
+
decorators = [],
|
|
44
|
+
effects = [],
|
|
45
|
+
validators = [],
|
|
46
|
+
nodeErrorRender,
|
|
47
|
+
nodePlaceholderRender
|
|
48
|
+
} = material;
|
|
49
|
+
if (nodeErrorRender) {
|
|
50
|
+
(0, import_form_core.registerNodeErrorRender)(nodeManager, nodeErrorRender);
|
|
51
|
+
}
|
|
52
|
+
if (nodePlaceholderRender) {
|
|
53
|
+
(0, import_form_core.registerNodePlaceholderRender)(nodeManager, nodePlaceholderRender);
|
|
54
|
+
}
|
|
55
|
+
setters.forEach((setter) => {
|
|
56
|
+
formManager.registerAbilityExtension(import_form_core.SetterAbility.type, setter);
|
|
57
|
+
});
|
|
58
|
+
decorators.forEach((decorator) => {
|
|
59
|
+
formManager.registerAbilityExtension(import_form_core.DecoratorAbility.type, decorator);
|
|
60
|
+
});
|
|
61
|
+
effects.forEach((effect) => {
|
|
62
|
+
formManager.registerAbilityExtension(import_form_core.EffectAbility.type, effect);
|
|
63
|
+
});
|
|
64
|
+
validators.forEach((validator) => {
|
|
65
|
+
formManager.registerAbilityExtension(import_form_core.ValidationAbility.type, validator);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/create-node-core-plugin.ts
|
|
70
|
+
var createNodeCorePlugin = (0, import_core.definePluginCreator)({
|
|
71
|
+
onInit(ctx, options) {
|
|
72
|
+
ctx.get(import_document.FlowDocument).registerNodeDatas(...(0, import_form_core2.createNodeEntityDatas)());
|
|
73
|
+
const formModelFactory = (entity) => new import_node.FormModelV2(entity);
|
|
74
|
+
const entityManager = ctx.get(import_core.EntityManager);
|
|
75
|
+
entityManager.registerEntityData(
|
|
76
|
+
import_form_core2.FlowNodeFormData,
|
|
77
|
+
() => ({
|
|
78
|
+
formModelFactory
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
if (!options.materials) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const nodeManager = ctx.get(import_form_core2.NodeManager);
|
|
85
|
+
const formManager = ctx.get(import_form_core2.FormManager);
|
|
86
|
+
if (!nodeManager || !formManager) {
|
|
87
|
+
throw new Error("NodeCorePlugin Error: nodeManager or formManager not found");
|
|
88
|
+
}
|
|
89
|
+
registerNodeMaterial({ nodeManager, formManager, material: options.materials });
|
|
90
|
+
},
|
|
91
|
+
onDispose(ctx) {
|
|
92
|
+
ctx.get(import_form_core2.FormManager)?.dispose();
|
|
93
|
+
},
|
|
94
|
+
containerModules: (0, import_form_core2.createNodeContainerModules)()
|
|
95
|
+
// onBind: ({ bind }) => {
|
|
96
|
+
// bindContributions(bind, FormNodeContribution, [NodeContribution]);
|
|
97
|
+
// },
|
|
98
|
+
});
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
createNodeCorePlugin,
|
|
102
|
+
registerNodeMaterial
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/create-node-core-plugin.ts","../src/utils.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport * from './create-node-core-plugin';\nexport * from './utils';\nexport * from './types';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { FormModelV2 } from '@flowgram.ai/node';\nimport {\n createNodeContainerModules,\n createNodeEntityDatas,\n FlowNodeFormData,\n FormManager,\n NodeManager,\n} from '@flowgram.ai/form-core';\nimport { FlowDocument, FlowNodeEntity } from '@flowgram.ai/document';\nimport { definePluginCreator, EntityManager } from '@flowgram.ai/core';\n\nimport { registerNodeMaterial } from './utils';\nimport { NodeEngineMaterialOptions } from './types';\n\nexport interface NodeCorePluginOptions {\n materials?: NodeEngineMaterialOptions;\n}\n\nexport const createNodeCorePlugin = definePluginCreator<NodeCorePluginOptions>({\n onInit(ctx, options) {\n /**\n * 注册NodeEngine 相关 EntityData 到flowDocument\n */\n ctx.get<FlowDocument>(FlowDocument).registerNodeDatas(...createNodeEntityDatas());\n\n const formModelFactory = (entity: FlowNodeEntity) => new FormModelV2(entity);\n const entityManager = ctx.get<EntityManager>(EntityManager);\n entityManager.registerEntityData(\n FlowNodeFormData,\n () =>\n ({\n formModelFactory: formModelFactory,\n } as any)\n );\n\n if (!options.materials) {\n return;\n }\n\n const nodeManager = ctx.get<NodeManager>(NodeManager);\n const formManager = ctx.get<FormManager>(FormManager);\n\n if (!nodeManager || !formManager) {\n throw new Error('NodeCorePlugin Error: nodeManager or formManager not found');\n }\n\n registerNodeMaterial({ nodeManager, formManager, material: options.materials! });\n },\n onDispose(ctx) {\n ctx.get<FormManager>(FormManager)?.dispose();\n },\n containerModules: createNodeContainerModules(),\n // onBind: ({ bind }) => {\n // bindContributions(bind, FormNodeContribution, [NodeContribution]);\n // },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport {\n DecoratorAbility,\n DecoratorExtension,\n EffectAbility,\n EffectExtension,\n FormManager,\n NodeManager,\n registerNodeErrorRender,\n registerNodePlaceholderRender,\n SetterAbility,\n SetterExtension,\n ValidationAbility,\n ValidationExtension,\n} from '@flowgram.ai/form-core';\n\nimport { NodeEngineMaterialOptions } from './types';\n\ninterface RegisterNodeMaterialProps {\n nodeManager: NodeManager;\n formManager: FormManager;\n material: NodeEngineMaterialOptions;\n}\n\nexport function registerNodeMaterial({\n nodeManager,\n formManager,\n material,\n}: RegisterNodeMaterialProps) {\n const {\n setters = [],\n decorators = [],\n effects = [],\n validators = [],\n nodeErrorRender,\n nodePlaceholderRender,\n } = material;\n\n if (nodeErrorRender) {\n registerNodeErrorRender(nodeManager, nodeErrorRender);\n }\n if (nodePlaceholderRender) {\n registerNodePlaceholderRender(nodeManager, nodePlaceholderRender);\n }\n setters.forEach((setter: SetterExtension) => {\n formManager.registerAbilityExtension(SetterAbility.type, setter);\n });\n decorators.forEach((decorator: DecoratorExtension) => {\n formManager.registerAbilityExtension(DecoratorAbility.type, decorator);\n });\n effects.forEach((effect: EffectExtension) => {\n formManager.registerAbilityExtension(EffectAbility.type, effect);\n });\n validators.forEach((validator: ValidationExtension) => {\n formManager.registerAbilityExtension(ValidationAbility.type, validator);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,kBAA4B;AAC5B,IAAAA,oBAMO;AACP,sBAA6C;AAC7C,kBAAmD;;;ACTnD,uBAaO;AAUA,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM;AAAA,IACJ,UAAU,CA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,QAAQ;AAAA,EAC7C;AAAA,EACA,sBAAkB,8CAA2B;AAAA;AAAA;AAAA;AAI/C,CAAC;","names":["import_form_core"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowgram.ai/node-core-plugin",
|
|
3
|
+
"version": "0.1.0-alpha.10",
|
|
4
|
+
"homepage": "https://flowgram.ai/",
|
|
5
|
+
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/esm/index.js",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"inversify": "^6.0.1",
|
|
20
|
+
"reflect-metadata": "~0.2.2",
|
|
21
|
+
"@flowgram.ai/core": "0.1.0-alpha.10",
|
|
22
|
+
"@flowgram.ai/document": "0.1.0-alpha.10",
|
|
23
|
+
"@flowgram.ai/form-core": "0.1.0-alpha.10",
|
|
24
|
+
"@flowgram.ai/node": "0.1.0-alpha.10",
|
|
25
|
+
"@flowgram.ai/renderer": "0.1.0-alpha.10",
|
|
26
|
+
"@flowgram.ai/utils": "0.1.0-alpha.10"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/bezier-js": "4.1.3",
|
|
30
|
+
"@types/lodash": "^4.14.137",
|
|
31
|
+
"@types/react": "^18",
|
|
32
|
+
"@types/react-dom": "^18",
|
|
33
|
+
"@types/styled-components": "^5",
|
|
34
|
+
"@vitest/coverage-v8": "^0.32.0",
|
|
35
|
+
"eslint": "^8.54.0",
|
|
36
|
+
"react": "^18",
|
|
37
|
+
"react-dom": "^18",
|
|
38
|
+
"styled-components": "^5",
|
|
39
|
+
"tsup": "^8.0.1",
|
|
40
|
+
"typescript": "^5.0.4",
|
|
41
|
+
"vitest": "^0.34.6",
|
|
42
|
+
"@flowgram.ai/ts-config": "0.1.0-alpha.10",
|
|
43
|
+
"@flowgram.ai/eslint-config": "0.1.0-alpha.10"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=16.8",
|
|
47
|
+
"react-dom": ">=16.8",
|
|
48
|
+
"styled-components": ">=4"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "npm run build:fast -- --dts-resolve",
|
|
56
|
+
"build:fast": "tsup src/index.ts --format cjs,esm --sourcemap --legacy-output",
|
|
57
|
+
"build:watch": "npm run build:fast -- --dts-resolve",
|
|
58
|
+
"clean": "rimraf dist",
|
|
59
|
+
"test": "exit 0",
|
|
60
|
+
"test:cov": "exit 0",
|
|
61
|
+
"ts-check": "tsc --noEmit",
|
|
62
|
+
"watch": "npm run build:fast -- --dts-resolve --watch --ignore-watch dist"
|
|
63
|
+
}
|
|
64
|
+
}
|