@flowgram.ai/form-materials 0.4.5 → 0.4.7

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.
Files changed (57) hide show
  1. package/dist/esm/chunk-727SU246.js +13 -0
  2. package/dist/esm/chunk-727SU246.js.map +1 -0
  3. package/dist/esm/chunk-DEZUEMUM.js +284 -0
  4. package/dist/esm/chunk-DEZUEMUM.js.map +1 -0
  5. package/dist/esm/chunk-MFDEE4HB.js +440 -0
  6. package/dist/esm/chunk-MFDEE4HB.js.map +1 -0
  7. package/dist/esm/editor-2YHACGQ2.js +282 -0
  8. package/dist/esm/editor-2YHACGQ2.js.map +1 -0
  9. package/dist/esm/editor-6UMULJYB.js +180 -0
  10. package/dist/esm/editor-6UMULJYB.js.map +1 -0
  11. package/dist/esm/editor-E2BQTPCD.js +388 -0
  12. package/dist/esm/editor-E2BQTPCD.js.map +1 -0
  13. package/dist/esm/editor-G63XGWH2.js +249 -0
  14. package/dist/esm/editor-G63XGWH2.js.map +1 -0
  15. package/dist/esm/editor-OXPGKPF5.js +167 -0
  16. package/dist/esm/editor-OXPGKPF5.js.map +1 -0
  17. package/dist/esm/index.js +607 -2300
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/index.d.mts +141 -51
  20. package/dist/index.d.ts +141 -51
  21. package/dist/index.js +3545 -2825
  22. package/dist/index.js.map +1 -1
  23. package/package.json +8 -8
  24. package/src/components/code-editor/editor.tsx +96 -0
  25. package/src/components/code-editor/index.tsx +5 -89
  26. package/src/components/code-editor-mini/index.tsx +2 -2
  27. package/src/components/condition-row/index.tsx +4 -0
  28. package/src/components/db-condition-row/hooks/use-left.tsx +66 -0
  29. package/src/components/db-condition-row/hooks/use-op.tsx +59 -0
  30. package/src/components/db-condition-row/index.tsx +93 -0
  31. package/src/components/db-condition-row/styles.tsx +43 -0
  32. package/src/components/db-condition-row/types.ts +34 -0
  33. package/src/components/display-inputs-values/index.tsx +1 -1
  34. package/src/components/dynamic-value-input/hooks.ts +1 -1
  35. package/src/components/index.ts +1 -0
  36. package/src/components/inputs-values-tree/hooks/use-child-list.tsx +1 -1
  37. package/src/components/json-editor-with-variables/editor.tsx +69 -0
  38. package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +1 -1
  39. package/src/components/json-editor-with-variables/index.tsx +5 -60
  40. package/src/components/json-schema-editor/hooks.tsx +1 -1
  41. package/src/components/prompt-editor/editor.tsx +81 -0
  42. package/src/components/prompt-editor/index.tsx +5 -69
  43. package/src/components/prompt-editor-with-inputs/editor.tsx +25 -0
  44. package/src/components/prompt-editor-with-inputs/index.tsx +5 -15
  45. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  46. package/src/components/prompt-editor-with-variables/editor.tsx +22 -0
  47. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +1 -1
  48. package/src/components/prompt-editor-with-variables/index.tsx +5 -13
  49. package/src/effects/validate-when-variable-sync/index.ts +1 -1
  50. package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
  51. package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
  52. package/src/hooks/use-object-list/index.tsx +1 -1
  53. package/src/shared/flow-value/utils.ts +1 -1
  54. package/src/shared/format-legacy-refs/index.ts +1 -1
  55. package/src/shared/index.ts +1 -0
  56. package/src/shared/lazy-suspense/index.tsx +28 -0
  57. package/src/validate/validate-flow-value/index.tsx +1 -1
@@ -0,0 +1,13 @@
1
+ import {
2
+ lazySuspense
3
+ } from "./chunk-DEZUEMUM.js";
4
+
5
+ // src/components/prompt-editor/index.tsx
6
+ var PromptEditor = lazySuspense(
7
+ () => import("./editor-6UMULJYB.js").then((module) => ({ default: module.PromptEditor }))
8
+ );
9
+
10
+ export {
11
+ PromptEditor
12
+ };
13
+ //# sourceMappingURL=chunk-727SU246.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/prompt-editor/index.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { lazySuspense } from '@/shared';\n\nexport const PromptEditor = lazySuspense(() =>\n import('./editor').then((module) => ({ default: module.PromptEditor }))\n);\n\nexport type { PromptEditorPropsType } from './editor';\n"],"mappings":";;;;;AAOO,IAAM,eAAe;AAAA,EAAa,MACvC,OAAO,sBAAU,EAAE,KAAK,CAAC,YAAY,EAAE,SAAS,OAAO,aAAa,EAAE;AACxE;","names":[]}
@@ -0,0 +1,284 @@
1
+ // src/shared/format-legacy-refs/index.ts
2
+ import { isObject } from "lodash-es";
3
+ function formatLegacyRefOnSubmit(value) {
4
+ if (isObject(value)) {
5
+ if (isLegacyFlowRefValueSchema(value)) {
6
+ return formatLegacyRefToNewRef(value);
7
+ }
8
+ return Object.fromEntries(
9
+ Object.entries(value).map(([key, value2]) => [
10
+ key,
11
+ formatLegacyRefOnSubmit(value2)
12
+ ])
13
+ );
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return value.map(formatLegacyRefOnSubmit);
17
+ }
18
+ return value;
19
+ }
20
+ function formatLegacyRefOnInit(value) {
21
+ if (isObject(value)) {
22
+ if (isNewFlowRefValueSchema(value)) {
23
+ return formatNewRefToLegacyRef(value);
24
+ }
25
+ return Object.fromEntries(
26
+ Object.entries(value).map(([key, value2]) => [
27
+ key,
28
+ formatLegacyRefOnInit(value2)
29
+ ])
30
+ );
31
+ }
32
+ if (Array.isArray(value)) {
33
+ return value.map(formatLegacyRefOnInit);
34
+ }
35
+ return value;
36
+ }
37
+ function isLegacyFlowRefValueSchema(value) {
38
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
39
+ }
40
+ function isNewFlowRefValueSchema(value) {
41
+ return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
42
+ }
43
+ function formatLegacyRefToNewRef(value) {
44
+ const keyPath = value.content.split(".");
45
+ if (keyPath[1] === "outputs") {
46
+ return {
47
+ type: "ref",
48
+ content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
49
+ };
50
+ }
51
+ return {
52
+ type: "ref",
53
+ content: keyPath
54
+ };
55
+ }
56
+ function formatNewRefToLegacyRef(value) {
57
+ return {
58
+ type: "ref",
59
+ content: value.content.join(".")
60
+ };
61
+ }
62
+
63
+ // src/shared/inject-material/index.tsx
64
+ import React from "react";
65
+ import {
66
+ FlowRendererComponentType,
67
+ FlowRendererRegistry,
68
+ usePlaygroundContainer
69
+ } from "@flowgram.ai/editor";
70
+ function createInjectMaterial(Component, params) {
71
+ const InjectComponent = (props) => {
72
+ const container = usePlaygroundContainer();
73
+ if (!container?.isBound(FlowRendererRegistry)) {
74
+ return React.createElement(Component, { ...props });
75
+ }
76
+ const rendererRegistry = container.get(FlowRendererRegistry);
77
+ const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
78
+ const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
79
+ if (renderer?.type !== FlowRendererComponentType.REACT) {
80
+ return React.createElement(Component, { ...props });
81
+ }
82
+ return React.createElement(renderer.renderer, {
83
+ ...props
84
+ });
85
+ };
86
+ return InjectComponent;
87
+ }
88
+
89
+ // src/shared/flow-value/utils.ts
90
+ import { isArray, isObject as isObject2, isPlainObject, uniq } from "lodash-es";
91
+ import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
92
+
93
+ // src/shared/flow-value/schema.ts
94
+ import z from "zod";
95
+ var extraSchema = z.object({
96
+ index: z.number().optional()
97
+ }).optional();
98
+ var constantSchema = z.object({
99
+ type: z.literal("constant"),
100
+ content: z.any().optional(),
101
+ schema: z.any().optional(),
102
+ extra: extraSchema
103
+ });
104
+ var refSchema = z.object({
105
+ type: z.literal("ref"),
106
+ content: z.array(z.string()).optional(),
107
+ extra: extraSchema
108
+ });
109
+ var expressionSchema = z.object({
110
+ type: z.literal("expression"),
111
+ content: z.string().optional(),
112
+ extra: extraSchema
113
+ });
114
+ var templateSchema = z.object({
115
+ type: z.literal("template"),
116
+ content: z.string().optional(),
117
+ extra: extraSchema
118
+ });
119
+
120
+ // src/shared/flow-value/utils.ts
121
+ var FlowValueUtils;
122
+ ((FlowValueUtils2) => {
123
+ function isConstant(value) {
124
+ return constantSchema.safeParse(value).success;
125
+ }
126
+ FlowValueUtils2.isConstant = isConstant;
127
+ function isRef(value) {
128
+ return refSchema.safeParse(value).success;
129
+ }
130
+ FlowValueUtils2.isRef = isRef;
131
+ function isExpression(value) {
132
+ return expressionSchema.safeParse(value).success;
133
+ }
134
+ FlowValueUtils2.isExpression = isExpression;
135
+ function isTemplate(value) {
136
+ return templateSchema.safeParse(value).success;
137
+ }
138
+ FlowValueUtils2.isTemplate = isTemplate;
139
+ function isConstantOrRef(value) {
140
+ return isConstant(value) || isRef(value);
141
+ }
142
+ FlowValueUtils2.isConstantOrRef = isConstantOrRef;
143
+ function isFlowValue(value) {
144
+ return isConstant(value) || isRef(value) || isExpression(value) || isTemplate(value);
145
+ }
146
+ FlowValueUtils2.isFlowValue = isFlowValue;
147
+ function* traverse(value, options) {
148
+ const { includeTypes = ["ref", "template"], path = "" } = options;
149
+ if (isPlainObject(value)) {
150
+ if (isRef(value) && includeTypes.includes("ref")) {
151
+ yield { value, path };
152
+ return;
153
+ }
154
+ if (isTemplate(value) && includeTypes.includes("template")) {
155
+ yield { value, path };
156
+ return;
157
+ }
158
+ if (isExpression(value) && includeTypes.includes("expression")) {
159
+ yield { value, path };
160
+ return;
161
+ }
162
+ if (isConstant(value) && includeTypes.includes("constant")) {
163
+ yield { value, path };
164
+ return;
165
+ }
166
+ for (const [_key, _value] of Object.entries(value)) {
167
+ yield* traverse(_value, { ...options, path: `${path}.${_key}` });
168
+ }
169
+ return;
170
+ }
171
+ if (isArray(value)) {
172
+ for (const [_idx, _value] of value.entries()) {
173
+ yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });
174
+ }
175
+ return;
176
+ }
177
+ return;
178
+ }
179
+ FlowValueUtils2.traverse = traverse;
180
+ function getTemplateKeyPaths(value) {
181
+ const keyPathReg = /\{\{([^\}\{]+)\}\}/g;
182
+ return uniq(value.content?.match(keyPathReg) || []).map(
183
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
184
+ );
185
+ }
186
+ FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths;
187
+ function inferConstantJsonSchema(value) {
188
+ if (value?.schema) {
189
+ return value.schema;
190
+ }
191
+ if (typeof value.content === "string") {
192
+ return {
193
+ type: "string"
194
+ };
195
+ }
196
+ if (typeof value.content === "number") {
197
+ return {
198
+ type: "number"
199
+ };
200
+ }
201
+ if (typeof value.content === "boolean") {
202
+ return {
203
+ type: "boolean"
204
+ };
205
+ }
206
+ if (isObject2(value.content)) {
207
+ return {
208
+ type: "object"
209
+ };
210
+ }
211
+ return void 0;
212
+ }
213
+ FlowValueUtils2.inferConstantJsonSchema = inferConstantJsonSchema;
214
+ function inferJsonSchema(values, scope) {
215
+ if (isPlainObject(values)) {
216
+ if (isConstant(values)) {
217
+ return inferConstantJsonSchema(values);
218
+ }
219
+ if (isRef(values)) {
220
+ const variable = scope.available.getByKeyPath(values?.content);
221
+ const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
222
+ return schema;
223
+ }
224
+ if (isTemplate(values)) {
225
+ return { type: "string" };
226
+ }
227
+ return {
228
+ type: "object",
229
+ properties: Object.keys(values).reduce((acc, key) => {
230
+ const schema = inferJsonSchema(values[key], scope);
231
+ if (schema) {
232
+ acc[key] = schema;
233
+ }
234
+ return acc;
235
+ }, {})
236
+ };
237
+ }
238
+ }
239
+ FlowValueUtils2.inferJsonSchema = inferJsonSchema;
240
+ })(FlowValueUtils || (FlowValueUtils = {}));
241
+
242
+ // src/shared/polyfill-create-root/index.tsx
243
+ import * as ReactDOM from "react-dom";
244
+ var unstableCreateRoot = (dom) => ({
245
+ render(children) {
246
+ ReactDOM.render(children, dom);
247
+ },
248
+ unmount() {
249
+ ReactDOM.unmountComponentAtNode(dom);
250
+ }
251
+ });
252
+ function polyfillCreateRoot(dom) {
253
+ return unstableCreateRoot(dom);
254
+ }
255
+ function unstableSetCreateRoot(createRoot) {
256
+ unstableCreateRoot = createRoot;
257
+ }
258
+
259
+ // src/shared/lazy-suspense/index.tsx
260
+ import React2, { lazy, Suspense } from "react";
261
+ import { Skeleton } from "@douyinfe/semi-ui";
262
+ function withSuspense(Component, fallback) {
263
+ const WithSuspenseComponent = (props) => /* @__PURE__ */ React2.createElement(Suspense, { fallback: fallback || /* @__PURE__ */ React2.createElement(Skeleton.Paragraph, { style: { width: "100%" }, rows: 1 }) }, /* @__PURE__ */ React2.createElement(Component, { ...props }));
264
+ return WithSuspenseComponent;
265
+ }
266
+ function lazySuspense(params, fallback) {
267
+ return withSuspense(lazy(params), fallback);
268
+ }
269
+
270
+ export {
271
+ formatLegacyRefOnSubmit,
272
+ formatLegacyRefOnInit,
273
+ isLegacyFlowRefValueSchema,
274
+ isNewFlowRefValueSchema,
275
+ formatLegacyRefToNewRef,
276
+ formatNewRefToLegacyRef,
277
+ createInjectMaterial,
278
+ FlowValueUtils,
279
+ polyfillCreateRoot,
280
+ unstableSetCreateRoot,
281
+ withSuspense,
282
+ lazySuspense
283
+ };
284
+ //# sourceMappingURL=chunk-DEZUEMUM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shared/format-legacy-refs/index.ts","../../src/shared/inject-material/index.tsx","../../src/shared/flow-value/utils.ts","../../src/shared/flow-value/schema.ts","../../src/shared/polyfill-create-root/index.tsx","../../src/shared/lazy-suspense/index.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { isObject } from 'lodash-es';\n\ninterface LegacyFlowRefValueSchema {\n type: 'ref';\n content: string;\n}\n\ninterface NewFlowRefValueSchema {\n type: 'ref';\n content: string[];\n}\n\n/**\n * In flowgram 0.2.0, for introducing Loop variable functionality,\n * the FlowRefValueSchema type definition is updated:\n *\n * interface LegacyFlowRefValueSchema {\n * type: 'ref';\n * content: string;\n * }\n *\n * interface NewFlowRefValueSchema {\n * type: 'ref';\n * content: string[];\n * }\n *\n *\n * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData\n *\n * How to use:\n *\n * 1. Call formatLegacyRefOnSubmit on the formData before submitting\n * 2. Call formatLegacyRefOnInit on the formData after submitting\n *\n * Example:\n * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';\n * formMeta: {\n * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),\n * formatOnInit: (data) => formatLegacyRefOnInit(data),\n * }\n */\nexport function formatLegacyRefOnSubmit(value: any): any {\n if (isObject(value)) {\n if (isLegacyFlowRefValueSchema(value)) {\n return formatLegacyRefToNewRef(value);\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, value]: [string, any]) => [\n key,\n formatLegacyRefOnSubmit(value),\n ])\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(formatLegacyRefOnSubmit);\n }\n\n return value;\n}\n\n/**\n * In flowgram 0.2.0, for introducing Loop variable functionality,\n * the FlowRefValueSchema type definition is updated:\n *\n * interface LegacyFlowRefValueSchema {\n * type: 'ref';\n * content: string;\n * }\n *\n * interface NewFlowRefValueSchema {\n * type: 'ref';\n * content: string[];\n * }\n *\n *\n * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData\n *\n * How to use:\n *\n * 1. Call formatLegacyRefOnSubmit on the formData before submitting\n * 2. Call formatLegacyRefOnInit on the formData after submitting\n *\n * Example:\n * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';\n *\n * formMeta: {\n * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),\n * formatOnInit: (data) => formatLegacyRefOnInit(data),\n * }\n */\nexport function formatLegacyRefOnInit(value: any): any {\n if (isObject(value)) {\n if (isNewFlowRefValueSchema(value)) {\n return formatNewRefToLegacyRef(value);\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, value]: [string, any]) => [\n key,\n formatLegacyRefOnInit(value),\n ])\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(formatLegacyRefOnInit);\n }\n\n return value;\n}\n\nexport function isLegacyFlowRefValueSchema(value: any): value is LegacyFlowRefValueSchema {\n return (\n isObject(value) &&\n Object.keys(value).length === 2 &&\n (value as any).type === 'ref' &&\n typeof (value as any).content === 'string'\n );\n}\n\nexport function isNewFlowRefValueSchema(value: any): value is NewFlowRefValueSchema {\n return (\n isObject(value) &&\n Object.keys(value).length === 2 &&\n (value as any).type === 'ref' &&\n Array.isArray((value as any).content)\n );\n}\n\nexport function formatLegacyRefToNewRef(value: LegacyFlowRefValueSchema) {\n const keyPath = value.content.split('.');\n\n if (keyPath[1] === 'outputs') {\n return {\n type: 'ref',\n content: [`${keyPath[0]}.${keyPath[1]}`, ...(keyPath.length > 2 ? keyPath.slice(2) : [])],\n };\n }\n\n return {\n type: 'ref',\n content: keyPath,\n };\n}\n\nexport function formatNewRefToLegacyRef(value: NewFlowRefValueSchema) {\n return {\n type: 'ref',\n content: value.content.join('.'),\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport {\n FlowRendererComponentType,\n FlowRendererRegistry,\n usePlaygroundContainer,\n} from '@flowgram.ai/editor';\n\n/**\n * Creates a material component wrapper with dependency injection support\n *\n * This Higher-Order Component (HOC) implements a dynamic component replacement mechanism\n * for material components. It automatically checks if a custom renderer is registered\n * in the editor context, using the injected component if available, otherwise\n * falling back to the default component.\n *\n * @example\n * ```tsx\n * // 1.Create an injectable material component\n * const InjectVariableSelector = createInjectMaterial(VariableSelector)\n *\n * // 2. Register custom components in editor\n * // Configure in use-editor-props.tsx:\n * const editorProps = {\n * materials: {\n * components: {\n * [VariableSelector.renderKey]: YourCustomVariableSelector\n * }\n * }\n * }\n * ```\n *\n * @description\n * Data flow explanation:\n * - Register components to FlowRendererRegistry in use-editor-props\n * - InjectMaterial reads renderers from FlowRendererRegistry\n * - If registered renderer exists and type is REACT, use injected component\n * - If not exists or type mismatch, fallback to default component\n *\n * @param Component - Default React component\n * @param params - Optional parameters\n * @param params.renderKey - Custom render key name, highest priority\n * @returns Wrapper component with dependency injection support\n */\nexport function createInjectMaterial<Props>(\n Component: React.FC<Props> & { renderKey?: string },\n params?: {\n renderKey?: string;\n }\n): React.FC<Props> {\n const InjectComponent: React.FC<Props> = (props) => {\n const container = usePlaygroundContainer();\n\n // Check if renderer registry is bound in container\n if (!container?.isBound(FlowRendererRegistry)) {\n // If no registry, use default component directly\n return React.createElement(Component as (props?: any) => any, { ...props });\n }\n\n // Get renderer registry instance\n const rendererRegistry = container.get(FlowRendererRegistry);\n\n // Determine render key: prioritize param specified, then component renderKey, finally component name\n const renderKey = params?.renderKey || Component.renderKey || Component.name || '';\n\n // Get corresponding renderer from registry\n const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);\n\n // Check if renderer exists and type is React component\n if (renderer?.type !== FlowRendererComponentType.REACT) {\n // If no suitable renderer found, fallback to default component\n return React.createElement(Component as (props?: any) => any, { ...props });\n }\n\n // Render using injected React component\n return React.createElement(renderer.renderer, {\n ...props,\n });\n };\n\n return InjectComponent;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { isArray, isObject, isPlainObject, uniq } from 'lodash-es';\nimport { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';\nimport { Scope } from '@flowgram.ai/editor';\n\nimport {\n IFlowConstantValue,\n IFlowRefValue,\n IFlowExpressionValue,\n IFlowTemplateValue,\n IFlowValue,\n IFlowConstantRefValue,\n FlowValueType,\n} from '@/typings';\n\nimport { constantSchema, refSchema, expressionSchema, templateSchema } from './schema';\n\nexport namespace FlowValueUtils {\n /**\n * Check if the value is a constant type\n */\n export function isConstant(value: any): value is IFlowConstantValue {\n return constantSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is a reference type\n */\n export function isRef(value: any): value is IFlowRefValue {\n return refSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is an expression type\n */\n export function isExpression(value: any): value is IFlowExpressionValue {\n return expressionSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is a template type\n */\n export function isTemplate(value: any): value is IFlowTemplateValue {\n return templateSchema.safeParse(value).success;\n }\n\n /**\n * Check if the value is either a constant or reference type\n */\n export function isConstantOrRef(value: any): value is IFlowConstantRefValue {\n return isConstant(value) || isRef(value);\n }\n\n /**\n * Check if the value is a valid flow value type\n */\n export function isFlowValue(value: any): value is IFlowValue {\n return isConstant(value) || isRef(value) || isExpression(value) || isTemplate(value);\n }\n\n /**\n * Traverse all flow values in the given value\n * @param value The value to traverse\n * @param options The options to traverse\n * @returns A generator of flow values\n */\n export function* traverse(\n value: any,\n options: {\n includeTypes?: FlowValueType[];\n path?: string;\n }\n ): Generator<{ value: IFlowValue; path: string }> {\n const { includeTypes = ['ref', 'template'], path = '' } = options;\n\n if (isPlainObject(value)) {\n if (isRef(value) && includeTypes.includes('ref')) {\n yield { value, path };\n return;\n }\n\n if (isTemplate(value) && includeTypes.includes('template')) {\n yield { value, path };\n return;\n }\n\n if (isExpression(value) && includeTypes.includes('expression')) {\n yield { value, path };\n return;\n }\n\n if (isConstant(value) && includeTypes.includes('constant')) {\n yield { value, path };\n return;\n }\n\n for (const [_key, _value] of Object.entries(value)) {\n yield* traverse(_value, { ...options, path: `${path}.${_key}` });\n }\n return;\n }\n\n if (isArray(value)) {\n for (const [_idx, _value] of value.entries()) {\n yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });\n }\n return;\n }\n\n return;\n }\n\n /**\n * Get all key paths in the template value\n * @param value The template value\n * @returns A list of key paths\n */\n export function getTemplateKeyPaths(value: IFlowTemplateValue) {\n // find all keyPath wrapped in {{}}\n const keyPathReg = /\\{\\{([^\\}\\{]+)\\}\\}/g;\n return uniq(value.content?.match(keyPathReg) || []).map((_keyPath) =>\n _keyPath.slice(2, -2).split('.')\n );\n }\n\n /**\n * Infer the schema of the constant value\n * @param value\n * @returns\n */\n export function inferConstantJsonSchema(value: IFlowConstantValue): IJsonSchema | undefined {\n if (value?.schema) {\n return value.schema;\n }\n\n if (typeof value.content === 'string') {\n return {\n type: 'string',\n };\n }\n\n if (typeof value.content === 'number') {\n return {\n type: 'number',\n };\n }\n\n if (typeof value.content === 'boolean') {\n return {\n type: 'boolean',\n };\n }\n\n if (isObject(value.content)) {\n return {\n type: 'object',\n };\n }\n return undefined;\n }\n\n /**\n * Infer the schema of the flow value\n * @param values The flow value or object contains flow value\n * @param scope\n * @returns\n */\n export function inferJsonSchema(values: any, scope: Scope): IJsonSchema | undefined {\n if (isPlainObject(values)) {\n if (isConstant(values)) {\n return inferConstantJsonSchema(values);\n }\n\n if (isRef(values)) {\n const variable = scope.available.getByKeyPath(values?.content);\n const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : undefined;\n\n return schema;\n }\n\n if (isTemplate(values)) {\n return { type: 'string' };\n }\n\n return {\n type: 'object',\n properties: Object.keys(values).reduce((acc, key) => {\n const schema = inferJsonSchema((values as any)[key], scope);\n if (schema) {\n acc[key] = schema;\n }\n return acc;\n }, {} as Record<string, IJsonSchema>),\n };\n }\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport z from 'zod';\n\n// Shared extra schema for flow value types\nexport const extraSchema = z\n .object({\n index: z.number().optional(),\n })\n .optional();\n\nexport const constantSchema = z.object({\n type: z.literal('constant'),\n content: z.any().optional(),\n schema: z.any().optional(),\n extra: extraSchema,\n});\n\nexport const refSchema = z.object({\n type: z.literal('ref'),\n content: z.array(z.string()).optional(),\n extra: extraSchema,\n});\n\nexport const expressionSchema = z.object({\n type: z.literal('expression'),\n content: z.string().optional(),\n extra: extraSchema,\n});\n\nexport const templateSchema = z.object({\n type: z.literal('template'),\n content: z.string().optional(),\n extra: extraSchema,\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport * as ReactDOM from 'react-dom';\n\nexport interface IPolyfillRoot {\n render(children: React.ReactNode): void;\n unmount(): void;\n}\n\n/**\n * React 18 polyfill\n * @param dom\n * @returns\n */\nlet unstableCreateRoot = (dom: HTMLElement): IPolyfillRoot => ({\n render(children: JSX.Element) {\n ReactDOM.render(children, dom);\n },\n unmount() {\n ReactDOM.unmountComponentAtNode(dom);\n },\n});\n\nexport function polyfillCreateRoot(dom: HTMLElement): IPolyfillRoot {\n return unstableCreateRoot(dom);\n}\n\nexport function unstableSetCreateRoot(createRoot: (dom: HTMLElement) => IPolyfillRoot) {\n unstableCreateRoot = createRoot;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { ComponentType, lazy, Suspense } from 'react';\n\nimport { Skeleton } from '@douyinfe/semi-ui';\n\nexport function withSuspense<T extends ComponentType<any>>(\n Component: T,\n fallback?: React.ReactNode\n): T {\n const WithSuspenseComponent: T = ((props: any) => (\n <Suspense fallback={fallback || <Skeleton.Paragraph style={{ width: '100%' }} rows={1} />}>\n <Component {...props} />\n </Suspense>\n )) as any;\n\n return WithSuspenseComponent;\n}\n\nexport function lazySuspense<T extends ComponentType<any>>(\n params: Parameters<typeof lazy<T>>[0],\n fallback?: React.ReactNode\n) {\n return withSuspense(lazy(params), fallback);\n}\n"],"mappings":";AAKA,SAAS,gBAAgB;AAyClB,SAAS,wBAAwB,OAAiB;AACvD,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,2BAA2B,KAAK,GAAG;AACrC,aAAO,wBAAwB,KAAK;AAAA,IACtC;AAEA,WAAO,OAAO;AAAA,MACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAqB;AAAA,QACzD;AAAA,QACA,wBAAwBA,MAAK;AAAA,MAC/B,C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