@flowgram.ai/form-materials 0.2.32 → 0.3.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/bin/index.ts +11 -5
- package/bin/materials.ts +9 -1
- package/dist/esm/index.js +1229 -1308
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +162 -125
- package/dist/index.d.ts +162 -125
- package/dist/index.js +1380 -1463
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/batch-variable-selector/config.json +6 -2
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor/theme/light.ts +1 -1
- package/src/components/code-editor-mini/config.json +7 -0
- package/src/components/code-editor-mini/index.tsx +31 -0
- package/src/components/condition-row/config.json +10 -2
- package/src/components/condition-row/constants.ts +4 -0
- package/src/components/condition-row/hooks/useRule.ts +2 -2
- package/src/components/condition-row/index.tsx +1 -1
- package/src/components/condition-row/types.ts +3 -1
- package/src/components/constant-input/config.json +6 -3
- package/src/components/constant-input/index.tsx +10 -71
- package/src/components/constant-input/types.ts +6 -10
- package/src/components/display-flow-value/config.json +8 -0
- package/src/components/display-flow-value/index.tsx +59 -0
- package/src/components/display-inputs-values/config.json +9 -0
- package/src/components/display-inputs-values/index.tsx +27 -0
- package/src/components/display-inputs-values/styles.ts +12 -0
- package/src/components/display-outputs/config.json +10 -0
- package/src/components/display-outputs/index.tsx +58 -0
- package/src/components/display-outputs/styles.ts +12 -0
- package/src/components/display-schema-tag/config.json +10 -0
- package/src/components/display-schema-tag/index.tsx +44 -0
- package/src/components/display-schema-tag/styles.ts +28 -0
- package/src/components/display-schema-tree/config.json +11 -0
- package/src/components/display-schema-tree/index.tsx +74 -0
- package/src/components/display-schema-tree/styles.tsx +90 -0
- package/src/components/dynamic-value-input/config.json +11 -2
- package/src/components/dynamic-value-input/hooks.ts +53 -0
- package/src/components/dynamic-value-input/index.tsx +30 -28
- package/src/components/index.ts +6 -0
- package/src/components/inputs-values/config.json +2 -1
- package/src/components/inputs-values/types.ts +3 -1
- package/src/components/json-schema-editor/config.json +2 -2
- package/src/components/json-schema-editor/default-value.tsx +1 -1
- package/src/components/json-schema-editor/hooks.tsx +1 -1
- package/src/components/json-schema-editor/index.tsx +1 -1
- package/src/components/json-schema-editor/types.ts +1 -1
- package/src/components/type-selector/config.json +6 -2
- package/src/components/type-selector/index.tsx +47 -11
- package/src/components/variable-selector/config.json +6 -2
- package/src/components/variable-selector/index.tsx +1 -1
- package/src/components/variable-selector/use-variable-tree.tsx +14 -20
- package/src/effects/provide-json-schema-outputs/config.json +4 -5
- package/src/effects/provide-json-schema-outputs/index.ts +1 -3
- package/src/effects/sync-variable-title/index.ts +1 -0
- package/src/form-plugins/infer-inputs-plugin/config.json +3 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +2 -2
- package/src/index.ts +2 -1
- package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
- package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
- package/src/plugins/index.ts +7 -0
- package/src/plugins/json-schema-preset/config.json +9 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
- package/src/plugins/json-schema-preset/index.tsx +39 -0
- package/src/plugins/json-schema-preset/manager.ts +18 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +23 -0
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/object.tsx +23 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
- package/src/{utils → shared}/index.ts +0 -1
- package/src/typings/flow-value/config.json +4 -4
- package/src/typings/flow-value/index.ts +1 -1
- package/src/typings/index.ts +0 -1
- package/src/components/type-selector/constants.tsx +0 -364
- package/src/typings/json-schema/index.ts +0 -36
- package/src/utils/json-schema/config.json +0 -5
- package/src/utils/json-schema/index.ts +0 -180
- /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
- /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
- /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,552 +1,567 @@
|
|
|
1
1
|
// src/components/variable-selector/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React11, { useMemo } from "react";
|
|
3
3
|
import { Popover } from "@douyinfe/semi-ui";
|
|
4
4
|
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
5
5
|
|
|
6
6
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
7
|
-
import
|
|
7
|
+
import React10, { useCallback } from "react";
|
|
8
|
+
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
8
9
|
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
9
|
-
import { Icon
|
|
10
|
+
import { Icon } from "@douyinfe/semi-ui";
|
|
10
11
|
|
|
11
|
-
// src/
|
|
12
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
13
|
+
import React9 from "react";
|
|
14
|
+
import {
|
|
15
|
+
JsonSchemaUtils,
|
|
16
|
+
useTypeManager as useOriginTypeManager,
|
|
17
|
+
TypePresetProvider as OriginTypePresetProvider
|
|
18
|
+
} from "@flowgram.ai/json-schema";
|
|
19
|
+
|
|
20
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
21
|
+
import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
22
|
+
|
|
23
|
+
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
12
24
|
import React from "react";
|
|
13
|
-
import
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
import { Input } from "@douyinfe/semi-ui";
|
|
26
|
+
var stringRegistry = {
|
|
27
|
+
type: "string",
|
|
28
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
32
|
+
import React4 from "react";
|
|
33
|
+
|
|
34
|
+
// src/components/code-editor-mini/index.tsx
|
|
35
|
+
import React3 from "react";
|
|
36
|
+
import styled from "styled-components";
|
|
37
|
+
|
|
38
|
+
// src/components/code-editor/index.tsx
|
|
39
|
+
import React2, { useEffect, useRef } from "react";
|
|
40
|
+
import {
|
|
41
|
+
ActiveLinePlaceholder,
|
|
42
|
+
createRenderer,
|
|
43
|
+
EditorProvider
|
|
44
|
+
} from "@coze-editor/editor/react";
|
|
45
|
+
import preset from "@coze-editor/editor/preset-code";
|
|
46
|
+
import { EditorView } from "@codemirror/view";
|
|
47
|
+
|
|
48
|
+
// src/components/code-editor/utils.ts
|
|
49
|
+
function getSuffixByLanguageId(languageId) {
|
|
50
|
+
if (languageId === "python") {
|
|
51
|
+
return ".py";
|
|
52
|
+
}
|
|
53
|
+
if (languageId === "typescript") {
|
|
54
|
+
return ".ts";
|
|
55
|
+
}
|
|
56
|
+
if (languageId === "shell") {
|
|
57
|
+
return ".sh";
|
|
58
|
+
}
|
|
59
|
+
if (languageId === "json") {
|
|
60
|
+
return ".json";
|
|
61
|
+
}
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/components/code-editor/language-features.ts
|
|
66
|
+
import { languages } from "@coze-editor/editor/preset-code";
|
|
67
|
+
import { typescript } from "@coze-editor/editor/language-typescript";
|
|
68
|
+
import { shell } from "@coze-editor/editor/language-shell";
|
|
69
|
+
import { python } from "@coze-editor/editor/language-python";
|
|
70
|
+
import { json } from "@coze-editor/editor/language-json";
|
|
71
|
+
import { mixLanguages } from "@coze-editor/editor";
|
|
72
|
+
languages.register("python", python);
|
|
73
|
+
languages.register("shell", shell);
|
|
74
|
+
languages.register("typescript", typescript);
|
|
75
|
+
languages.register("json", {
|
|
76
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
77
|
+
language: mixLanguages({
|
|
78
|
+
outerLanguage: json.language
|
|
79
|
+
}),
|
|
80
|
+
languageService: json.languageService
|
|
81
|
+
});
|
|
82
|
+
var tsWorkerInit = false;
|
|
83
|
+
var initTsWorker = () => {
|
|
84
|
+
if (tsWorkerInit) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
tsWorkerInit = true;
|
|
88
|
+
const tsWorker = new Worker(
|
|
89
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
|
|
90
|
+
{ type: "module" }
|
|
91
|
+
);
|
|
92
|
+
typescript.languageService.initialize(tsWorker, {
|
|
93
|
+
compilerOptions: {
|
|
94
|
+
// eliminate Promise error
|
|
95
|
+
lib: ["es2015", "dom"],
|
|
96
|
+
noImplicitAny: false
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/components/code-editor/theme/index.ts
|
|
102
|
+
import { themes } from "@coze-editor/editor/preset-code";
|
|
103
|
+
|
|
104
|
+
// src/components/code-editor/theme/light.ts
|
|
105
|
+
import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
|
|
106
|
+
var colors = {
|
|
107
|
+
background: "#F7F7FC",
|
|
108
|
+
// syntax
|
|
109
|
+
comment: "#000A298A",
|
|
110
|
+
key: "#00818C",
|
|
111
|
+
string: "#D1009D",
|
|
112
|
+
number: "#C74200",
|
|
113
|
+
boolean: "#2B57D9",
|
|
114
|
+
null: "#2B57D9",
|
|
115
|
+
separator: "#0F1529D1"
|
|
116
|
+
};
|
|
117
|
+
var lightTheme = createTheme({
|
|
118
|
+
variant: "light",
|
|
119
|
+
settings: {
|
|
120
|
+
background: "#fff",
|
|
121
|
+
foreground: "#000",
|
|
122
|
+
caret: "#000",
|
|
123
|
+
selection: "#d9d9d9",
|
|
124
|
+
gutterBackground: "#f0f0f0",
|
|
125
|
+
gutterForeground: "#666",
|
|
126
|
+
gutterBorderColor: "transparent",
|
|
127
|
+
gutterBorderWidth: 0,
|
|
128
|
+
lineHighlight: "#e1e1e180",
|
|
129
|
+
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
130
|
+
tooltip: {
|
|
131
|
+
backgroundColor: "#f0f0f0",
|
|
132
|
+
color: "#000",
|
|
133
|
+
border: "1px solid #ccc"
|
|
25
134
|
},
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
{
|
|
29
|
-
fillRule: "evenodd",
|
|
30
|
-
clipRule: "evenodd",
|
|
31
|
-
d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
|
|
32
|
-
fill: "currentColor"
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
),
|
|
36
|
-
object: /* @__PURE__ */ React.createElement(
|
|
37
|
-
"svg",
|
|
38
|
-
{
|
|
39
|
-
width: "1em",
|
|
40
|
-
height: "1em",
|
|
41
|
-
viewBox: "0 0 16 16",
|
|
42
|
-
fill: "none",
|
|
43
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
135
|
+
link: {
|
|
136
|
+
color: "#007bff"
|
|
44
137
|
},
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
{
|
|
48
|
-
d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
|
|
49
|
-
fill: "currentColor"
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
/* @__PURE__ */ React.createElement(
|
|
53
|
-
"path",
|
|
54
|
-
{
|
|
55
|
-
d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
|
|
56
|
-
fill: "currentColor"
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
),
|
|
60
|
-
boolean: /* @__PURE__ */ React.createElement(
|
|
61
|
-
"svg",
|
|
62
|
-
{
|
|
63
|
-
width: "1em",
|
|
64
|
-
height: "1em",
|
|
65
|
-
viewBox: "0 0 16 16",
|
|
66
|
-
fill: "none",
|
|
67
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
138
|
+
completionItemHover: {
|
|
139
|
+
backgroundColor: "#f0f0f0"
|
|
68
140
|
},
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
),
|
|
88
|
-
string: /* @__PURE__ */ React.createElement(
|
|
89
|
-
"svg",
|
|
141
|
+
completionItemSelected: {
|
|
142
|
+
backgroundColor: "#e0e0e0"
|
|
143
|
+
},
|
|
144
|
+
completionItemIcon: {
|
|
145
|
+
color: "#333"
|
|
146
|
+
},
|
|
147
|
+
completionItemLabel: {
|
|
148
|
+
color: "#333"
|
|
149
|
+
},
|
|
150
|
+
completionItemInfo: {
|
|
151
|
+
color: "#333"
|
|
152
|
+
},
|
|
153
|
+
completionItemDetail: {
|
|
154
|
+
color: "#666"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
styles: [
|
|
158
|
+
// JSON
|
|
90
159
|
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
viewBox: "0 0 16 16",
|
|
94
|
-
fill: "none",
|
|
95
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
160
|
+
tag: t.comment,
|
|
161
|
+
color: colors.comment
|
|
96
162
|
},
|
|
97
|
-
/* @__PURE__ */ React.createElement(
|
|
98
|
-
"path",
|
|
99
|
-
{
|
|
100
|
-
d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
|
|
101
|
-
fill: "currentColor"
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
|
-
/* @__PURE__ */ React.createElement(
|
|
105
|
-
"path",
|
|
106
|
-
{
|
|
107
|
-
d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
|
|
108
|
-
fill: "currentColor"
|
|
109
|
-
}
|
|
110
|
-
),
|
|
111
|
-
/* @__PURE__ */ React.createElement(
|
|
112
|
-
"path",
|
|
113
|
-
{
|
|
114
|
-
d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
|
|
115
|
-
fill: "currentColor"
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
/* @__PURE__ */ React.createElement(
|
|
119
|
-
"path",
|
|
120
|
-
{
|
|
121
|
-
d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
|
|
122
|
-
fill: "currentColor"
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
),
|
|
126
|
-
integer: /* @__PURE__ */ React.createElement(
|
|
127
|
-
"svg",
|
|
128
163
|
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
viewBox: "0 0 16 16",
|
|
132
|
-
fill: "none",
|
|
133
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
164
|
+
tag: [t.propertyName],
|
|
165
|
+
color: colors.key
|
|
134
166
|
},
|
|
135
|
-
/* @__PURE__ */ React.createElement(
|
|
136
|
-
"path",
|
|
137
|
-
{
|
|
138
|
-
d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
|
|
139
|
-
fill: "currentColor"
|
|
140
|
-
}
|
|
141
|
-
),
|
|
142
|
-
/* @__PURE__ */ React.createElement(
|
|
143
|
-
"path",
|
|
144
|
-
{
|
|
145
|
-
d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
|
|
146
|
-
fill: "currentColor"
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
/* @__PURE__ */ React.createElement(
|
|
150
|
-
"path",
|
|
151
|
-
{
|
|
152
|
-
d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
|
|
153
|
-
fill: "currentColor"
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
),
|
|
157
|
-
number: /* @__PURE__ */ React.createElement(
|
|
158
|
-
"svg",
|
|
159
167
|
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
viewBox: "0 0 16 16",
|
|
163
|
-
fill: "none",
|
|
164
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
168
|
+
tag: [t.string],
|
|
169
|
+
color: colors.string
|
|
165
170
|
},
|
|
166
|
-
/* @__PURE__ */ React.createElement(
|
|
167
|
-
"path",
|
|
168
|
-
{
|
|
169
|
-
d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
|
|
170
|
-
fill: "currentColor"
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
/* @__PURE__ */ React.createElement(
|
|
174
|
-
"path",
|
|
175
|
-
{
|
|
176
|
-
d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
|
|
177
|
-
fill: "currentColor"
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
/* @__PURE__ */ React.createElement(
|
|
181
|
-
"path",
|
|
182
|
-
{
|
|
183
|
-
d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
|
|
184
|
-
fill: "currentColor"
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
),
|
|
188
|
-
array: /* @__PURE__ */ React.createElement(
|
|
189
|
-
"svg",
|
|
190
171
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
viewBox: "0 0 16 16",
|
|
194
|
-
fill: "none",
|
|
195
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
172
|
+
tag: [t.number],
|
|
173
|
+
color: colors.number
|
|
196
174
|
},
|
|
197
|
-
/* @__PURE__ */ React.createElement(
|
|
198
|
-
"path",
|
|
199
|
-
{
|
|
200
|
-
d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
|
|
201
|
-
fill: "currentColor"
|
|
202
|
-
}
|
|
203
|
-
),
|
|
204
|
-
/* @__PURE__ */ React.createElement(
|
|
205
|
-
"path",
|
|
206
|
-
{
|
|
207
|
-
d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
|
|
208
|
-
fill: "currentColor"
|
|
209
|
-
}
|
|
210
|
-
)
|
|
211
|
-
),
|
|
212
|
-
stream: /* @__PURE__ */ React.createElement(
|
|
213
|
-
"svg",
|
|
214
175
|
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
218
|
-
width: "1em",
|
|
219
|
-
height: "1em"
|
|
176
|
+
tag: [t.bool],
|
|
177
|
+
color: colors.boolean
|
|
220
178
|
},
|
|
221
|
-
/* @__PURE__ */ React.createElement(
|
|
222
|
-
"path",
|
|
223
|
-
{
|
|
224
|
-
d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
|
|
225
|
-
fill: "currentColor"
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
),
|
|
229
|
-
map: /* @__PURE__ */ React.createElement(
|
|
230
|
-
"svg",
|
|
231
179
|
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
235
|
-
width: "1em",
|
|
236
|
-
height: "1em"
|
|
180
|
+
tag: [t.null],
|
|
181
|
+
color: colors.null
|
|
237
182
|
},
|
|
238
|
-
/* @__PURE__ */ React.createElement(
|
|
239
|
-
"path",
|
|
240
|
-
{
|
|
241
|
-
d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
|
|
242
|
-
fill: "currentColor"
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
/* @__PURE__ */ React.createElement(
|
|
246
|
-
"path",
|
|
247
|
-
{
|
|
248
|
-
d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
|
|
249
|
-
fill: "currentColor"
|
|
250
|
-
}
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
};
|
|
254
|
-
var ArrayIcons = {
|
|
255
|
-
object: /* @__PURE__ */ React.createElement(
|
|
256
|
-
"svg",
|
|
257
183
|
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
viewBox: "0 0 16 16",
|
|
261
|
-
fill: "none",
|
|
262
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
184
|
+
tag: [t.separator],
|
|
185
|
+
color: colors.separator
|
|
263
186
|
},
|
|
264
|
-
|
|
265
|
-
"path",
|
|
266
|
-
{
|
|
267
|
-
fillRule: "evenodd",
|
|
268
|
-
clipRule: "evenodd",
|
|
269
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
|
|
270
|
-
fill: "currentColor"
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
),
|
|
274
|
-
boolean: /* @__PURE__ */ React.createElement(
|
|
275
|
-
"svg",
|
|
187
|
+
// markdown
|
|
276
188
|
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
viewBox: "0 0 16 16",
|
|
280
|
-
fill: "none",
|
|
281
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
189
|
+
tag: [t.heading],
|
|
190
|
+
color: "#3e76ef"
|
|
282
191
|
},
|
|
283
|
-
/* @__PURE__ */ React.createElement(
|
|
284
|
-
"path",
|
|
285
|
-
{
|
|
286
|
-
fillRule: "evenodd",
|
|
287
|
-
clipRule: "evenodd",
|
|
288
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
|
|
289
|
-
fill: "currentColor"
|
|
290
|
-
}
|
|
291
|
-
)
|
|
292
|
-
),
|
|
293
|
-
string: /* @__PURE__ */ React.createElement(
|
|
294
|
-
"svg",
|
|
295
192
|
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
viewBox: "0 0 16 16",
|
|
299
|
-
fill: "none",
|
|
300
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
193
|
+
tag: [t.processingInstruction],
|
|
194
|
+
color: "#3e76ef"
|
|
301
195
|
},
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
{
|
|
305
|
-
fillRule: "evenodd",
|
|
306
|
-
clipRule: "evenodd",
|
|
307
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
|
|
308
|
-
fill: "currentColor"
|
|
309
|
-
}
|
|
310
|
-
)
|
|
311
|
-
),
|
|
312
|
-
integer: /* @__PURE__ */ React.createElement(
|
|
313
|
-
"svg",
|
|
196
|
+
// shell
|
|
197
|
+
// curl
|
|
314
198
|
{
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
viewBox: "0 0 16 16",
|
|
318
|
-
fill: "none",
|
|
319
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
199
|
+
tag: [t.standard(t.variableName)],
|
|
200
|
+
color: "#00804A"
|
|
320
201
|
},
|
|
321
|
-
|
|
322
|
-
"path",
|
|
323
|
-
{
|
|
324
|
-
fillRule: "evenodd",
|
|
325
|
-
clipRule: "evenodd",
|
|
326
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
|
|
327
|
-
fill: "currentColor"
|
|
328
|
-
}
|
|
329
|
-
)
|
|
330
|
-
),
|
|
331
|
-
number: /* @__PURE__ */ React.createElement(
|
|
332
|
-
"svg",
|
|
202
|
+
// -X
|
|
333
203
|
{
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
viewBox: "0 0 16 16",
|
|
337
|
-
fill: "none",
|
|
338
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
204
|
+
tag: [t.attributeName],
|
|
205
|
+
color: "#C74200"
|
|
339
206
|
},
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
clipRule: "evenodd",
|
|
345
|
-
d: "M3.6139 1.58154H0V14.4191H3.6139V13.1269H1.36702V2.87375H3.6139V1.58154ZM3.41656 13.3271V13.3269H1.17155V13.3271H3.41656ZM0.199219 14.2191H0.197344V1.78154H3.41656V1.78174H0.199219V14.2191ZM16 1.58154H12.3861V2.87375H14.633V13.1269H12.3861V14.4191H16V1.58154ZM12.5834 1.78154V2.67375H12.5853V1.78174H15.8027V1.78154H12.5834ZM12.5853 14.2191V13.3271H14.8322V2.67394H14.8303V13.3269H12.5834V14.2191H12.5853ZM6.86771 4.5C5.87019 4.5 5.00104 5.30767 5.00104 6.31667V9.63333C5.00104 10.6423 5.87019 11.45 6.86771 11.45C7.86523 11.45 8.73438 10.6423 8.73438 9.63333V6.31667C8.73438 5.30767 7.86523 4.5 6.86771 4.5ZM11.1177 4.5C10.1202 4.5 9.25104 5.30767 9.25104 6.31667V9.63333C9.25104 10.6423 10.1202 11.45 11.1177 11.45C12.1152 11.45 12.9844 10.6423 12.9844 9.63333V6.31667C12.9844 5.30767 12.1152 4.5 11.1177 4.5ZM6.13438 6.31667C6.13438 5.9503 6.47884 5.63333 6.86771 5.63333C7.25657 5.63333 7.60104 5.9503 7.60104 6.31667V9.63333C7.60104 9.9997 7.25657 10.3167 6.86771 10.3167C6.47884 10.3167 6.13438 9.9997 6.13438 9.63333V6.31667ZM10.3844 6.31667C10.3844 5.9503 10.7288 5.63333 11.1177 5.63333C11.5066 5.63333 11.851 5.9503 11.851 6.31667V9.63333C11.851 9.9997 11.5066 10.3167 11.1177 10.3167C10.7288 10.3167 10.3844 9.9997 10.3844 9.63333V6.31667ZM3.75938 9.85C3.33135 9.85 2.98438 10.197 2.98438 10.625C2.98438 11.053 3.33135 11.4 3.75938 11.4C4.1874 11.4 4.53438 11.053 4.53438 10.625C4.53438 10.197 4.1874 9.85 3.75938 9.85Z",
|
|
346
|
-
fill: "currentColor"
|
|
347
|
-
}
|
|
348
|
-
)
|
|
349
|
-
)
|
|
350
|
-
};
|
|
351
|
-
var getSchemaIcon = (value) => {
|
|
352
|
-
if (value?.type === "array") {
|
|
353
|
-
return ArrayIcons[value.items?.type || "object"];
|
|
354
|
-
}
|
|
355
|
-
return VariableTypeIcons[value?.type || "object"];
|
|
356
|
-
};
|
|
357
|
-
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
358
|
-
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
359
|
-
var baseOptions = [
|
|
360
|
-
{
|
|
361
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
|
|
362
|
-
value: "string"
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
|
|
366
|
-
value: "integer"
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
|
|
370
|
-
value: "number"
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
|
|
374
|
-
value: "boolean"
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
|
|
378
|
-
value: "object"
|
|
379
|
-
}
|
|
380
|
-
];
|
|
381
|
-
var options = [
|
|
382
|
-
...baseOptions,
|
|
383
|
-
{
|
|
384
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
|
|
385
|
-
value: "array",
|
|
386
|
-
children: baseOptions.map((_opt) => ({
|
|
387
|
-
..._opt,
|
|
388
|
-
value: `${_opt.value}`,
|
|
389
|
-
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
|
|
390
|
-
Icon,
|
|
391
|
-
{
|
|
392
|
-
size: "small",
|
|
393
|
-
svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
|
|
394
|
-
}
|
|
395
|
-
), firstUppercase(_opt.value))
|
|
396
|
-
}))
|
|
397
|
-
}
|
|
398
|
-
];
|
|
399
|
-
|
|
400
|
-
// src/utils/json-schema/index.ts
|
|
401
|
-
import { get } from "lodash";
|
|
402
|
-
import { ASTFactory, ASTKind, ASTMatch } from "@flowgram.ai/editor";
|
|
403
|
-
var JsonSchemaUtils;
|
|
404
|
-
((JsonSchemaUtils2) => {
|
|
405
|
-
function schemaToAST(jsonSchema) {
|
|
406
|
-
const { type, extra } = jsonSchema || {};
|
|
407
|
-
const { weak = false } = extra || {};
|
|
408
|
-
if (!type) {
|
|
409
|
-
return void 0;
|
|
207
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
208
|
+
{
|
|
209
|
+
tag: [t.special(t.string)],
|
|
210
|
+
color: "#2B57D9"
|
|
410
211
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// src/components/code-editor/theme/dark.ts
|
|
216
|
+
import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
|
|
217
|
+
var colors2 = {
|
|
218
|
+
background: "#151B27",
|
|
219
|
+
// syntax
|
|
220
|
+
comment: "#FFFFFF63",
|
|
221
|
+
key: "#39E5D7",
|
|
222
|
+
string: "#FF94D2",
|
|
223
|
+
number: "#FF9933",
|
|
224
|
+
boolean: "#78B0FF",
|
|
225
|
+
null: "#78B0FF",
|
|
226
|
+
separator: "#FFFFFFC9"
|
|
227
|
+
};
|
|
228
|
+
var darkTheme = createTheme2({
|
|
229
|
+
variant: "dark",
|
|
230
|
+
settings: {
|
|
231
|
+
background: colors2.background,
|
|
232
|
+
foreground: "#fff",
|
|
233
|
+
caret: "#AEAFAD",
|
|
234
|
+
selection: "#d9d9d942",
|
|
235
|
+
gutterBackground: colors2.background,
|
|
236
|
+
gutterForeground: "#FFFFFF63",
|
|
237
|
+
gutterBorderColor: "transparent",
|
|
238
|
+
gutterBorderWidth: 0,
|
|
239
|
+
lineHighlight: "#272e3d36",
|
|
240
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
241
|
+
tooltip: {
|
|
242
|
+
backgroundColor: "#363D4D",
|
|
243
|
+
color: "#fff",
|
|
244
|
+
border: "none"
|
|
245
|
+
},
|
|
246
|
+
link: {
|
|
247
|
+
color: "#4daafc"
|
|
248
|
+
},
|
|
249
|
+
completionItemHover: {
|
|
250
|
+
backgroundColor: "#FFFFFF0F"
|
|
251
|
+
},
|
|
252
|
+
completionItemSelected: {
|
|
253
|
+
backgroundColor: "#FFFFFF17"
|
|
254
|
+
},
|
|
255
|
+
completionItemIcon: {
|
|
256
|
+
color: "#FFFFFFC9"
|
|
257
|
+
},
|
|
258
|
+
completionItemLabel: {
|
|
259
|
+
color: "#FFFFFFC9"
|
|
260
|
+
},
|
|
261
|
+
completionItemInfo: {
|
|
262
|
+
color: "#FFFFFFC9"
|
|
263
|
+
},
|
|
264
|
+
completionItemDetail: {
|
|
265
|
+
color: "#FFFFFF63"
|
|
459
266
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
267
|
+
},
|
|
268
|
+
styles: [
|
|
269
|
+
// json
|
|
270
|
+
{
|
|
271
|
+
tag: t2.comment,
|
|
272
|
+
color: colors2.comment
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
tag: [t2.propertyName],
|
|
276
|
+
color: colors2.key
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
tag: [t2.string],
|
|
280
|
+
color: colors2.string
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
tag: [t2.number],
|
|
284
|
+
color: colors2.number
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
tag: [t2.bool],
|
|
288
|
+
color: colors2.boolean
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
tag: [t2.null],
|
|
292
|
+
color: colors2.null
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
tag: [t2.separator],
|
|
296
|
+
color: colors2.separator
|
|
297
|
+
},
|
|
298
|
+
// markdown
|
|
299
|
+
{
|
|
300
|
+
tag: [t2.heading],
|
|
301
|
+
color: "#6b6bff"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
tag: [t2.processingInstruction],
|
|
305
|
+
color: "#6b6bff"
|
|
306
|
+
},
|
|
307
|
+
// shell
|
|
308
|
+
// curl
|
|
309
|
+
{
|
|
310
|
+
tag: [t2.standard(t2.variableName)],
|
|
311
|
+
color: "#3BEB84"
|
|
312
|
+
},
|
|
313
|
+
// -X
|
|
314
|
+
{
|
|
315
|
+
tag: [t2.attributeName],
|
|
316
|
+
color: "#FF9933"
|
|
317
|
+
},
|
|
318
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
319
|
+
{
|
|
320
|
+
tag: [t2.special(t2.string)],
|
|
321
|
+
color: "#78B0FF"
|
|
464
322
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
323
|
+
]
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// src/components/code-editor/theme/index.ts
|
|
327
|
+
themes.register("dark", darkTheme);
|
|
328
|
+
themes.register("light", lightTheme);
|
|
329
|
+
|
|
330
|
+
// src/components/code-editor/index.tsx
|
|
331
|
+
var OriginCodeEditor = createRenderer(preset, [
|
|
332
|
+
EditorView.theme({
|
|
333
|
+
"&.cm-focused": {
|
|
334
|
+
outline: "none"
|
|
469
335
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
336
|
+
})
|
|
337
|
+
]);
|
|
338
|
+
function CodeEditor({
|
|
339
|
+
value,
|
|
340
|
+
onChange,
|
|
341
|
+
languageId = "python",
|
|
342
|
+
theme = "light",
|
|
343
|
+
children,
|
|
344
|
+
placeholder,
|
|
345
|
+
activeLinePlaceholder,
|
|
346
|
+
options,
|
|
347
|
+
readonly
|
|
348
|
+
}) {
|
|
349
|
+
const editorRef = useRef(null);
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
if (languageId === "typescript") {
|
|
352
|
+
initTsWorker();
|
|
474
353
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
typeAST.properties.map((property) => {
|
|
480
|
-
const schema = astToSchema(property.type);
|
|
481
|
-
if (property.meta?.title && schema) {
|
|
482
|
-
schema.title = property.meta.title;
|
|
483
|
-
}
|
|
484
|
-
if (property.meta?.description && schema) {
|
|
485
|
-
schema.description = property.meta.description;
|
|
486
|
-
}
|
|
487
|
-
return [property.key, schema];
|
|
488
|
-
})
|
|
489
|
-
) : {}
|
|
490
|
-
};
|
|
354
|
+
}, [languageId]);
|
|
355
|
+
useEffect(() => {
|
|
356
|
+
if (editorRef.current?.getValue() !== value) {
|
|
357
|
+
editorRef.current?.setValue(String(value || ""));
|
|
491
358
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
359
|
+
}, [value]);
|
|
360
|
+
return /* @__PURE__ */ React2.createElement(EditorProvider, null, /* @__PURE__ */ React2.createElement(
|
|
361
|
+
OriginCodeEditor,
|
|
362
|
+
{
|
|
363
|
+
defaultValue: value,
|
|
364
|
+
options: {
|
|
365
|
+
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
366
|
+
languageId,
|
|
367
|
+
theme,
|
|
368
|
+
placeholder,
|
|
369
|
+
readOnly: readonly,
|
|
370
|
+
editable: !readonly,
|
|
371
|
+
...options || {}
|
|
372
|
+
},
|
|
373
|
+
didMount: (editor) => {
|
|
374
|
+
editorRef.current = editor;
|
|
375
|
+
},
|
|
376
|
+
onChange: (e) => onChange?.(e.value)
|
|
377
|
+
},
|
|
378
|
+
activeLinePlaceholder && /* @__PURE__ */ React2.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
379
|
+
children
|
|
380
|
+
));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/components/code-editor-mini/index.tsx
|
|
384
|
+
var UIMini = styled.div`
|
|
385
|
+
.ͼ1 .cm-content {
|
|
386
|
+
padding: 0;
|
|
387
|
+
}
|
|
388
|
+
`;
|
|
389
|
+
function CodeEditorMini(props) {
|
|
390
|
+
return /* @__PURE__ */ React3.createElement(UIMini, null, /* @__PURE__ */ React3.createElement(
|
|
391
|
+
CodeEditor,
|
|
392
|
+
{
|
|
393
|
+
...props,
|
|
394
|
+
options: {
|
|
395
|
+
lineNumbersGutter: false,
|
|
396
|
+
foldGutter: false,
|
|
397
|
+
...props.options || {}
|
|
398
|
+
}
|
|
497
399
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
400
|
+
));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
404
|
+
var objectRegistry = {
|
|
405
|
+
type: "object",
|
|
406
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React4.createElement(
|
|
407
|
+
CodeEditorMini,
|
|
408
|
+
{
|
|
409
|
+
value: props.value,
|
|
410
|
+
onChange: (v) => props.onChange?.(v),
|
|
411
|
+
languageId: "json",
|
|
412
|
+
placeholder: "Please Input Object",
|
|
413
|
+
readonly: props.readonly
|
|
503
414
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
415
|
+
)
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
419
|
+
import React5 from "react";
|
|
420
|
+
import { InputNumber } from "@douyinfe/semi-ui";
|
|
421
|
+
var numberRegistry = {
|
|
422
|
+
type: "number",
|
|
423
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
|
|
424
|
+
InputNumber,
|
|
425
|
+
{
|
|
426
|
+
placeholder: "Please Input Number",
|
|
427
|
+
size: "small",
|
|
428
|
+
disabled: props.readonly,
|
|
429
|
+
hideButtons: true,
|
|
430
|
+
...props
|
|
431
|
+
}
|
|
432
|
+
)
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
436
|
+
import React6 from "react";
|
|
437
|
+
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
438
|
+
var integerRegistry = {
|
|
439
|
+
type: "integer",
|
|
440
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
441
|
+
InputNumber2,
|
|
442
|
+
{
|
|
443
|
+
placeholder: "Please Input Integer",
|
|
444
|
+
size: "small",
|
|
445
|
+
disabled: props.readonly,
|
|
446
|
+
precision: 0,
|
|
447
|
+
...props
|
|
508
448
|
}
|
|
509
|
-
|
|
449
|
+
)
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
453
|
+
import React7 from "react";
|
|
454
|
+
import { Select } from "@douyinfe/semi-ui";
|
|
455
|
+
var booleanRegistry = {
|
|
456
|
+
type: "boolean",
|
|
457
|
+
ConstantRenderer: (props) => {
|
|
458
|
+
const { value, onChange, ...rest } = props;
|
|
459
|
+
return /* @__PURE__ */ React7.createElement(
|
|
460
|
+
Select,
|
|
461
|
+
{
|
|
462
|
+
placeholder: "Please Select Boolean",
|
|
463
|
+
size: "small",
|
|
464
|
+
disabled: props.readonly,
|
|
465
|
+
optionList: [
|
|
466
|
+
{ label: "True", value: 1 },
|
|
467
|
+
{ label: "False", value: 0 }
|
|
468
|
+
],
|
|
469
|
+
value: value ? 1 : 0,
|
|
470
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
471
|
+
...rest
|
|
472
|
+
}
|
|
473
|
+
);
|
|
510
474
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
478
|
+
import React8 from "react";
|
|
479
|
+
var arrayRegistry = {
|
|
480
|
+
type: "array",
|
|
481
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React8.createElement(
|
|
482
|
+
CodeEditorMini,
|
|
483
|
+
{
|
|
484
|
+
value: props.value,
|
|
485
|
+
languageId: "json",
|
|
486
|
+
onChange: (v) => props.onChange?.(v),
|
|
487
|
+
placeholder: "Please Input Array",
|
|
488
|
+
readonly: props.readonly
|
|
519
489
|
}
|
|
520
|
-
|
|
490
|
+
)
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
494
|
+
var jsonSchemaTypePreset = [
|
|
495
|
+
stringRegistry,
|
|
496
|
+
objectRegistry,
|
|
497
|
+
numberRegistry,
|
|
498
|
+
integerRegistry,
|
|
499
|
+
booleanRegistry,
|
|
500
|
+
arrayRegistry
|
|
501
|
+
];
|
|
502
|
+
jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
|
|
503
|
+
|
|
504
|
+
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
505
|
+
import {
|
|
506
|
+
BaseTypeManager,
|
|
507
|
+
jsonSchemaContainerModule
|
|
508
|
+
} from "@flowgram.ai/json-schema";
|
|
509
|
+
import { definePluginCreator } from "@flowgram.ai/editor";
|
|
510
|
+
var createTypePresetPlugin = definePluginCreator({
|
|
511
|
+
onInit(ctx, opts) {
|
|
512
|
+
const typeManager = ctx.get(BaseTypeManager);
|
|
513
|
+
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
514
|
+
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
515
|
+
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
516
|
+
},
|
|
517
|
+
containerModules: [jsonSchemaContainerModule]
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
521
|
+
var useTypeManager = () => useOriginTypeManager();
|
|
522
|
+
var JsonSchemaTypePresetProvider = ({
|
|
523
|
+
types = [],
|
|
524
|
+
children
|
|
525
|
+
}) => /* @__PURE__ */ React9.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
526
|
+
|
|
527
|
+
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
528
|
+
import {
|
|
529
|
+
ASTMatch,
|
|
530
|
+
definePluginCreator as definePluginCreator2,
|
|
531
|
+
VariableEngine
|
|
532
|
+
} from "@flowgram.ai/editor";
|
|
533
|
+
var createDisableDeclarationPlugin = definePluginCreator2({
|
|
534
|
+
onInit(ctx) {
|
|
535
|
+
const variableEngine = ctx.get(VariableEngine);
|
|
536
|
+
const handleEvent = (action) => {
|
|
537
|
+
if (ASTMatch.isVariableDeclaration(action.ast)) {
|
|
538
|
+
if (!action.ast.meta?.disabled) {
|
|
539
|
+
action.ast.updateMeta({
|
|
540
|
+
...action.ast.meta || {},
|
|
541
|
+
disabled: true
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
variableEngine.onGlobalEvent("NewAST", handleEvent);
|
|
547
|
+
variableEngine.onGlobalEvent("UpdateAST", handleEvent);
|
|
521
548
|
}
|
|
522
|
-
|
|
523
|
-
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
549
|
+
});
|
|
524
550
|
|
|
525
551
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
526
552
|
function useVariableTree(params) {
|
|
527
553
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
554
|
+
const typeManager = useTypeManager();
|
|
528
555
|
const variables = useAvailableVariables();
|
|
529
556
|
const getVariableTypeIcon = useCallback((variable) => {
|
|
530
557
|
if (variable.meta?.icon) {
|
|
531
558
|
if (typeof variable.meta.icon === "string") {
|
|
532
|
-
return /* @__PURE__ */
|
|
559
|
+
return /* @__PURE__ */ React10.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
533
560
|
}
|
|
534
561
|
return variable.meta.icon;
|
|
535
562
|
}
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
return /* @__PURE__ */ React2.createElement(
|
|
539
|
-
Icon2,
|
|
540
|
-
{
|
|
541
|
-
size: "small",
|
|
542
|
-
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
543
|
-
}
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
if (ASTMatch2.isCustomType(_type)) {
|
|
547
|
-
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
548
|
-
}
|
|
549
|
-
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
563
|
+
const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
|
|
564
|
+
return /* @__PURE__ */ React10.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
550
565
|
}, []);
|
|
551
566
|
const renderVariable = (variable, parentFields = []) => {
|
|
552
567
|
let type = variable?.type;
|
|
@@ -559,10 +574,11 @@ function useVariableTree(params) {
|
|
|
559
574
|
}
|
|
560
575
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
561
576
|
const key = keyPath.join(".");
|
|
562
|
-
const isSchemaInclude = includeSchema ?
|
|
563
|
-
const isSchemaExclude = excludeSchema ?
|
|
577
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, includeSchema) : true;
|
|
578
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, excludeSchema) : false;
|
|
564
579
|
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
565
|
-
const
|
|
580
|
+
const isMetaDisabled = variable.meta?.disabled;
|
|
581
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
566
582
|
if (!isSchemaMatch && !children?.length) {
|
|
567
583
|
return null;
|
|
568
584
|
}
|
|
@@ -582,9 +598,9 @@ function useVariableTree(params) {
|
|
|
582
598
|
}
|
|
583
599
|
|
|
584
600
|
// src/components/variable-selector/styles.tsx
|
|
585
|
-
import
|
|
601
|
+
import styled2, { css } from "styled-components";
|
|
586
602
|
import { Tag, TreeSelect } from "@douyinfe/semi-ui";
|
|
587
|
-
var UIRootTitle =
|
|
603
|
+
var UIRootTitle = styled2.div`
|
|
588
604
|
margin-right: 4px;
|
|
589
605
|
min-width: 20px;
|
|
590
606
|
overflow: hidden;
|
|
@@ -592,7 +608,7 @@ var UIRootTitle = styled.div`
|
|
|
592
608
|
white-space: nowrap;
|
|
593
609
|
color: var(--semi-color-text-2);
|
|
594
610
|
`;
|
|
595
|
-
var UIVarName =
|
|
611
|
+
var UIVarName = styled2.div`
|
|
596
612
|
overflow: hidden;
|
|
597
613
|
text-overflow: ellipsis;
|
|
598
614
|
white-space: nowrap;
|
|
@@ -601,7 +617,7 @@ var UIVarName = styled.div`
|
|
|
601
617
|
min-width: 50%;
|
|
602
618
|
`}
|
|
603
619
|
`;
|
|
604
|
-
var UITag =
|
|
620
|
+
var UITag = styled2(Tag)`
|
|
605
621
|
width: 100%;
|
|
606
622
|
display: flex;
|
|
607
623
|
align-items: center;
|
|
@@ -616,7 +632,7 @@ var UITag = styled(Tag)`
|
|
|
616
632
|
height: 22px;
|
|
617
633
|
}
|
|
618
634
|
`;
|
|
619
|
-
var UITreeSelect =
|
|
635
|
+
var UITreeSelect = styled2(TreeSelect)`
|
|
620
636
|
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
621
637
|
|
|
622
638
|
& .semi-tree-select-selection {
|
|
@@ -632,7 +648,7 @@ var UITreeSelect = styled(TreeSelect)`
|
|
|
632
648
|
padding-left: 10px;
|
|
633
649
|
}
|
|
634
650
|
`;
|
|
635
|
-
var UIPopoverContent =
|
|
651
|
+
var UIPopoverContent = styled2.div`
|
|
636
652
|
padding: 10px;
|
|
637
653
|
display: inline-flex;
|
|
638
654
|
align-items: center;
|
|
@@ -665,11 +681,11 @@ var VariableSelector = ({
|
|
|
665
681
|
}, [value]);
|
|
666
682
|
const renderIcon = (icon) => {
|
|
667
683
|
if (typeof icon === "string") {
|
|
668
|
-
return /* @__PURE__ */
|
|
684
|
+
return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
669
685
|
}
|
|
670
686
|
return icon;
|
|
671
687
|
};
|
|
672
|
-
return /* @__PURE__ */
|
|
688
|
+
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(
|
|
673
689
|
UITreeSelect,
|
|
674
690
|
{
|
|
675
691
|
dropdownMatchSelectWidth: false,
|
|
@@ -686,10 +702,10 @@ var VariableSelector = ({
|
|
|
686
702
|
},
|
|
687
703
|
renderSelectedItem: (_option) => {
|
|
688
704
|
if (!_option?.keyPath) {
|
|
689
|
-
return /* @__PURE__ */
|
|
705
|
+
return /* @__PURE__ */ React11.createElement(
|
|
690
706
|
UITag,
|
|
691
707
|
{
|
|
692
|
-
prefixIcon: /* @__PURE__ */
|
|
708
|
+
prefixIcon: /* @__PURE__ */ React11.createElement(IconIssueStroked, null),
|
|
693
709
|
color: "amber",
|
|
694
710
|
closable: !readonly,
|
|
695
711
|
onClose: () => onChange(void 0)
|
|
@@ -698,13 +714,13 @@ var VariableSelector = ({
|
|
|
698
714
|
);
|
|
699
715
|
}
|
|
700
716
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
701
|
-
const rootTitle = /* @__PURE__ */
|
|
702
|
-
return /* @__PURE__ */
|
|
717
|
+
const rootTitle = /* @__PURE__ */ React11.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
718
|
+
return /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement(
|
|
703
719
|
Popover,
|
|
704
720
|
{
|
|
705
|
-
content: /* @__PURE__ */
|
|
721
|
+
content: /* @__PURE__ */ React11.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React11.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
706
722
|
},
|
|
707
|
-
/* @__PURE__ */
|
|
723
|
+
/* @__PURE__ */ React11.createElement(
|
|
708
724
|
UITag,
|
|
709
725
|
{
|
|
710
726
|
prefixIcon: rootIcon,
|
|
@@ -712,12 +728,12 @@ var VariableSelector = ({
|
|
|
712
728
|
onClose: () => onChange(void 0)
|
|
713
729
|
},
|
|
714
730
|
rootTitle,
|
|
715
|
-
!_option.isRoot && /* @__PURE__ */
|
|
731
|
+
!_option.isRoot && /* @__PURE__ */ React11.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
716
732
|
)
|
|
717
733
|
));
|
|
718
734
|
},
|
|
719
735
|
showClear: false,
|
|
720
|
-
arrowIcon: /* @__PURE__ */
|
|
736
|
+
arrowIcon: /* @__PURE__ */ React11.createElement(IconChevronDownStroked, { size: "small" }),
|
|
721
737
|
triggerRender,
|
|
722
738
|
placeholder: config?.placeholder ?? "Select Variable..."
|
|
723
739
|
}
|
|
@@ -725,8 +741,10 @@ var VariableSelector = ({
|
|
|
725
741
|
};
|
|
726
742
|
|
|
727
743
|
// src/components/type-selector/index.tsx
|
|
728
|
-
import
|
|
729
|
-
import { Cascader, IconButton } from "@douyinfe/semi-ui";
|
|
744
|
+
import React12, { useMemo as useMemo2 } from "react";
|
|
745
|
+
import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
|
|
746
|
+
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
747
|
+
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
730
748
|
var getTypeSelectValue = (value) => {
|
|
731
749
|
if (value?.type === "array" && value?.items) {
|
|
732
750
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -743,20 +761,37 @@ var parseTypeSelectValue = (value) => {
|
|
|
743
761
|
function TypeSelector(props) {
|
|
744
762
|
const { value, onChange, readonly, disabled, style } = props;
|
|
745
763
|
const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
style,
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
764
|
+
const typeManager = useTypeManager();
|
|
765
|
+
const icon = typeManager.getDisplayIcon(value || {});
|
|
766
|
+
const options = useMemo2(
|
|
767
|
+
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
768
|
+
const isArray2 = _type.type === "array";
|
|
769
|
+
return {
|
|
770
|
+
label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(Icon2, { size: "small", svg: _type.icon }), firstUppercase(_type.type)),
|
|
771
|
+
value: _type.type,
|
|
772
|
+
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
773
|
+
label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(
|
|
774
|
+
Icon2,
|
|
775
|
+
{
|
|
776
|
+
size: "small",
|
|
777
|
+
svg: typeManager.getDisplayIcon({
|
|
778
|
+
type: "array",
|
|
779
|
+
items: { type: _type2.type }
|
|
780
|
+
})
|
|
781
|
+
}
|
|
782
|
+
), firstUppercase(_type2.type)),
|
|
783
|
+
value: _type2.type
|
|
784
|
+
})) : []
|
|
785
|
+
};
|
|
786
|
+
}),
|
|
787
|
+
[]
|
|
788
|
+
);
|
|
789
|
+
return /* @__PURE__ */ React12.createElement(
|
|
790
|
+
Cascader,
|
|
791
|
+
{
|
|
792
|
+
disabled: readonly || disabled,
|
|
793
|
+
size: "small",
|
|
794
|
+
triggerRender: () => /* @__PURE__ */ React12.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
760
795
|
treeData: options,
|
|
761
796
|
value: selectValue,
|
|
762
797
|
leafOnly: true,
|
|
@@ -768,7 +803,7 @@ function TypeSelector(props) {
|
|
|
768
803
|
}
|
|
769
804
|
|
|
770
805
|
// src/components/json-schema-editor/index.tsx
|
|
771
|
-
import
|
|
806
|
+
import React17, { useMemo as useMemo5, useState as useState4 } from "react";
|
|
772
807
|
import { Button, Checkbox, IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
773
808
|
import {
|
|
774
809
|
IconExpand,
|
|
@@ -780,36 +815,36 @@ import {
|
|
|
780
815
|
} from "@douyinfe/semi-icons";
|
|
781
816
|
|
|
782
817
|
// src/components/json-schema-editor/styles.tsx
|
|
783
|
-
import
|
|
784
|
-
import
|
|
818
|
+
import React13 from "react";
|
|
819
|
+
import styled3, { css as css2 } from "styled-components";
|
|
785
820
|
import Icon3 from "@douyinfe/semi-icons";
|
|
786
|
-
var UIContainer =
|
|
821
|
+
var UIContainer = styled3.div`
|
|
787
822
|
/* & .semi-input {
|
|
788
823
|
background-color: #fff;
|
|
789
824
|
border-radius: 6px;
|
|
790
825
|
height: 24px;
|
|
791
826
|
} */
|
|
792
827
|
`;
|
|
793
|
-
var UIRow =
|
|
828
|
+
var UIRow = styled3.div`
|
|
794
829
|
display: flex;
|
|
795
830
|
align-items: center;
|
|
796
831
|
gap: 6px;
|
|
797
832
|
`;
|
|
798
|
-
var UICollapseTrigger =
|
|
833
|
+
var UICollapseTrigger = styled3.div`
|
|
799
834
|
cursor: pointer;
|
|
800
835
|
margin-right: 5px;
|
|
801
836
|
`;
|
|
802
|
-
var UIExpandDetail =
|
|
837
|
+
var UIExpandDetail = styled3.div`
|
|
803
838
|
display: flex;
|
|
804
839
|
flex-direction: column;
|
|
805
840
|
`;
|
|
806
|
-
var UILabel =
|
|
841
|
+
var UILabel = styled3.div`
|
|
807
842
|
font-size: 12px;
|
|
808
843
|
color: #999;
|
|
809
844
|
font-weight: 400;
|
|
810
845
|
margin-bottom: 2px;
|
|
811
846
|
`;
|
|
812
|
-
var UIProperties =
|
|
847
|
+
var UIProperties = styled3.div`
|
|
813
848
|
display: grid;
|
|
814
849
|
grid-template-columns: auto 1fr;
|
|
815
850
|
|
|
@@ -818,7 +853,7 @@ var UIProperties = styled2.div`
|
|
|
818
853
|
margin-top: 10px;
|
|
819
854
|
`}
|
|
820
855
|
`;
|
|
821
|
-
var UIPropertyLeft =
|
|
856
|
+
var UIPropertyLeft = styled3.div`
|
|
822
857
|
grid-column: 1;
|
|
823
858
|
position: relative;
|
|
824
859
|
width: 16px;
|
|
@@ -855,7 +890,7 @@ var UIPropertyLeft = styled2.div`
|
|
|
855
890
|
`;
|
|
856
891
|
}}
|
|
857
892
|
`;
|
|
858
|
-
var UIPropertyRight =
|
|
893
|
+
var UIPropertyRight = styled3.div`
|
|
859
894
|
grid-column: 2;
|
|
860
895
|
margin-bottom: 10px;
|
|
861
896
|
|
|
@@ -863,7 +898,7 @@ var UIPropertyRight = styled2.div`
|
|
|
863
898
|
margin-bottom: 0px;
|
|
864
899
|
}
|
|
865
900
|
`;
|
|
866
|
-
var UIPropertyMain =
|
|
901
|
+
var UIPropertyMain = styled3.div`
|
|
867
902
|
display: flex;
|
|
868
903
|
flex-direction: column;
|
|
869
904
|
gap: 10px;
|
|
@@ -893,22 +928,22 @@ var UIPropertyMain = styled2.div`
|
|
|
893
928
|
`;
|
|
894
929
|
}}
|
|
895
930
|
`;
|
|
896
|
-
var UICollapsible =
|
|
931
|
+
var UICollapsible = styled3.div`
|
|
897
932
|
display: none;
|
|
898
933
|
|
|
899
934
|
${({ $collapse }) => $collapse && css2`
|
|
900
935
|
display: block;
|
|
901
936
|
`}
|
|
902
937
|
`;
|
|
903
|
-
var UIName =
|
|
938
|
+
var UIName = styled3.div`
|
|
904
939
|
flex-grow: 1;
|
|
905
940
|
`;
|
|
906
|
-
var UIType =
|
|
907
|
-
var UIRequired =
|
|
908
|
-
var UIActions =
|
|
941
|
+
var UIType = styled3.div``;
|
|
942
|
+
var UIRequired = styled3.div``;
|
|
943
|
+
var UIActions = styled3.div`
|
|
909
944
|
white-space: nowrap;
|
|
910
945
|
`;
|
|
911
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
946
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
|
|
912
947
|
"svg",
|
|
913
948
|
{
|
|
914
949
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -918,7 +953,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
|
|
|
918
953
|
fill: "currentColor",
|
|
919
954
|
xmlns: "http://www.w3.org/2000/svg"
|
|
920
955
|
},
|
|
921
|
-
/* @__PURE__ */
|
|
956
|
+
/* @__PURE__ */ React13.createElement(
|
|
922
957
|
"path",
|
|
923
958
|
{
|
|
924
959
|
fillRule: "evenodd",
|
|
@@ -926,19 +961,19 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
|
|
|
926
961
|
d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
|
|
927
962
|
}
|
|
928
963
|
),
|
|
929
|
-
/* @__PURE__ */
|
|
964
|
+
/* @__PURE__ */ React13.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
|
|
930
965
|
);
|
|
931
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
932
|
-
var DefaultValueWrapper =
|
|
966
|
+
var IconAddChildren = () => /* @__PURE__ */ React13.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
967
|
+
var DefaultValueWrapper = styled3.div`
|
|
933
968
|
margin: 0;
|
|
934
969
|
`;
|
|
935
|
-
var JSONViewerWrapper =
|
|
970
|
+
var JSONViewerWrapper = styled3.div`
|
|
936
971
|
padding: 0 0 24px;
|
|
937
972
|
&:first-child {
|
|
938
973
|
margin-top: 0px;
|
|
939
974
|
}
|
|
940
975
|
`;
|
|
941
|
-
var JSONHeader =
|
|
976
|
+
var JSONHeader = styled3.div`
|
|
942
977
|
display: flex;
|
|
943
978
|
justify-content: space-between;
|
|
944
979
|
align-items: center;
|
|
@@ -947,17 +982,17 @@ var JSONHeader = styled2.div`
|
|
|
947
982
|
height: 36px;
|
|
948
983
|
padding: 0 8px 0 12px;
|
|
949
984
|
`;
|
|
950
|
-
var JSONHeaderLeft =
|
|
985
|
+
var JSONHeaderLeft = styled3.div`
|
|
951
986
|
display: flex;
|
|
952
987
|
align-items: center;
|
|
953
988
|
gap: 10px;
|
|
954
989
|
`;
|
|
955
|
-
var JSONHeaderRight =
|
|
990
|
+
var JSONHeaderRight = styled3.div`
|
|
956
991
|
display: flex;
|
|
957
992
|
align-items: center;
|
|
958
993
|
gap: 10px;
|
|
959
994
|
`;
|
|
960
|
-
var ConstantInputWrapper =
|
|
995
|
+
var ConstantInputWrapper = styled3.div`
|
|
961
996
|
flex-grow: 1;
|
|
962
997
|
|
|
963
998
|
& .semi-tree-select,
|
|
@@ -968,7 +1003,7 @@ var ConstantInputWrapper = styled2.div`
|
|
|
968
1003
|
`;
|
|
969
1004
|
|
|
970
1005
|
// src/components/json-schema-editor/hooks.tsx
|
|
971
|
-
import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
|
|
1006
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
|
|
972
1007
|
import { omit } from "lodash";
|
|
973
1008
|
var _id = 0;
|
|
974
1009
|
function genId() {
|
|
@@ -1002,8 +1037,8 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1002
1037
|
[isDrilldownObject]
|
|
1003
1038
|
);
|
|
1004
1039
|
const [propertyList, setPropertyList] = useState(initPropertyList);
|
|
1005
|
-
const mountRef =
|
|
1006
|
-
|
|
1040
|
+
const mountRef = useRef2(false);
|
|
1041
|
+
useEffect2(() => {
|
|
1007
1042
|
if (mountRef.current) {
|
|
1008
1043
|
setPropertyList((_list) => {
|
|
1009
1044
|
const nameMap = /* @__PURE__ */ new Map();
|
|
@@ -1071,7 +1106,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1071
1106
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1072
1107
|
);
|
|
1073
1108
|
};
|
|
1074
|
-
|
|
1109
|
+
useEffect2(() => {
|
|
1075
1110
|
if (!isDrilldownObject) {
|
|
1076
1111
|
setPropertyList([]);
|
|
1077
1112
|
}
|
|
@@ -1086,7 +1121,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1086
1121
|
}
|
|
1087
1122
|
|
|
1088
1123
|
// src/components/json-schema-editor/default-value.tsx
|
|
1089
|
-
import
|
|
1124
|
+
import React15, { useRef as useRef3, useState as useState2, useCallback as useCallback2 } from "react";
|
|
1090
1125
|
import { IconButton as IconButton2, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
|
|
1091
1126
|
import { IconBrackets } from "@douyinfe/semi-icons";
|
|
1092
1127
|
|
|
@@ -1110,100 +1145,37 @@ function getValueType(value) {
|
|
|
1110
1145
|
}
|
|
1111
1146
|
|
|
1112
1147
|
// src/components/constant-input/index.tsx
|
|
1113
|
-
import
|
|
1114
|
-
import { Input
|
|
1115
|
-
var defaultStrategies = [
|
|
1116
|
-
{
|
|
1117
|
-
hit: (schema) => schema?.type === "string",
|
|
1118
|
-
Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1119
|
-
},
|
|
1120
|
-
{
|
|
1121
|
-
hit: (schema) => schema?.type === "number",
|
|
1122
|
-
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1123
|
-
InputNumber,
|
|
1124
|
-
{
|
|
1125
|
-
placeholder: "Please Input Number",
|
|
1126
|
-
size: "small",
|
|
1127
|
-
disabled: props.readonly,
|
|
1128
|
-
hideButtons: true,
|
|
1129
|
-
...props
|
|
1130
|
-
}
|
|
1131
|
-
)
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
hit: (schema) => schema?.type === "integer",
|
|
1135
|
-
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1136
|
-
InputNumber,
|
|
1137
|
-
{
|
|
1138
|
-
placeholder: "Please Input Integer",
|
|
1139
|
-
size: "small",
|
|
1140
|
-
disabled: props.readonly,
|
|
1141
|
-
hideButtons: true,
|
|
1142
|
-
precision: 0,
|
|
1143
|
-
...props
|
|
1144
|
-
}
|
|
1145
|
-
)
|
|
1146
|
-
},
|
|
1147
|
-
{
|
|
1148
|
-
hit: (schema) => schema?.type === "boolean",
|
|
1149
|
-
Renderer: (props) => {
|
|
1150
|
-
const { value, onChange, ...rest } = props;
|
|
1151
|
-
return /* @__PURE__ */ React6.createElement(
|
|
1152
|
-
Select,
|
|
1153
|
-
{
|
|
1154
|
-
placeholder: "Please Select Boolean",
|
|
1155
|
-
size: "small",
|
|
1156
|
-
disabled: props.readonly,
|
|
1157
|
-
optionList: [
|
|
1158
|
-
{ label: "True", value: 1 },
|
|
1159
|
-
{ label: "False", value: 0 }
|
|
1160
|
-
],
|
|
1161
|
-
value: value ? 1 : 0,
|
|
1162
|
-
onChange: (value2) => onChange?.(!!value2),
|
|
1163
|
-
...rest
|
|
1164
|
-
}
|
|
1165
|
-
);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
];
|
|
1148
|
+
import React14, { useMemo as useMemo4 } from "react";
|
|
1149
|
+
import { Input as Input2 } from "@douyinfe/semi-ui";
|
|
1169
1150
|
function ConstantInput(props) {
|
|
1170
|
-
const {
|
|
1171
|
-
|
|
1172
|
-
onChange,
|
|
1173
|
-
schema,
|
|
1174
|
-
strategies: extraStrategies,
|
|
1175
|
-
fallbackRenderer,
|
|
1176
|
-
readonly,
|
|
1177
|
-
...rest
|
|
1178
|
-
} = props;
|
|
1179
|
-
const strategies = useMemo4(
|
|
1180
|
-
// user's extraStrategies first
|
|
1181
|
-
() => [...extraStrategies || [], ...defaultStrategies],
|
|
1182
|
-
[extraStrategies]
|
|
1183
|
-
);
|
|
1151
|
+
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1152
|
+
const typeManager = useTypeManager();
|
|
1184
1153
|
const Renderer2 = useMemo4(() => {
|
|
1185
|
-
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1154
|
+
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1155
|
+
if (!strategy) {
|
|
1156
|
+
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
1157
|
+
}
|
|
1186
1158
|
return strategy?.Renderer;
|
|
1187
1159
|
}, [strategies, schema]);
|
|
1188
1160
|
if (!Renderer2) {
|
|
1189
1161
|
if (fallbackRenderer) {
|
|
1190
|
-
return
|
|
1162
|
+
return React14.createElement(fallbackRenderer, {
|
|
1191
1163
|
value,
|
|
1192
1164
|
onChange,
|
|
1193
1165
|
readonly,
|
|
1194
1166
|
...rest
|
|
1195
1167
|
});
|
|
1196
1168
|
}
|
|
1197
|
-
return /* @__PURE__ */
|
|
1169
|
+
return /* @__PURE__ */ React14.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1198
1170
|
}
|
|
1199
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ React14.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1200
1172
|
}
|
|
1201
1173
|
|
|
1202
1174
|
// src/components/json-schema-editor/default-value.tsx
|
|
1203
1175
|
function DefaultValue(props) {
|
|
1204
1176
|
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1205
|
-
const wrapperRef =
|
|
1206
|
-
const JsonViewerRef =
|
|
1177
|
+
const wrapperRef = useRef3(null);
|
|
1178
|
+
const JsonViewerRef = useRef3(null);
|
|
1207
1179
|
const [internalJsonValue, setInternalJsonValue] = useState2(
|
|
1208
1180
|
getValueType(value) === "string" ? value : ""
|
|
1209
1181
|
);
|
|
@@ -1230,16 +1202,16 @@ function DefaultValue(props) {
|
|
|
1230
1202
|
console.error("Invalid JSON:", error);
|
|
1231
1203
|
}
|
|
1232
1204
|
}, [internalJsonValue, onChange]);
|
|
1233
|
-
return type === "object" ? /* @__PURE__ */
|
|
1205
|
+
return type === "object" ? /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(JSONHeader, null, /* @__PURE__ */ React15.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React15.createElement(JSONHeaderRight, null, /* @__PURE__ */ React15.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React15.createElement(
|
|
1234
1206
|
IconButton2,
|
|
1235
1207
|
{
|
|
1236
|
-
icon: /* @__PURE__ */
|
|
1208
|
+
icon: /* @__PURE__ */ React15.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1237
1209
|
size: "small",
|
|
1238
1210
|
type: "tertiary",
|
|
1239
1211
|
theme: "borderless",
|
|
1240
1212
|
onClick: handleFormatJson
|
|
1241
1213
|
}
|
|
1242
|
-
)))), /* @__PURE__ */
|
|
1214
|
+
)))), /* @__PURE__ */ React15.createElement(
|
|
1243
1215
|
JSONViewerWrapper,
|
|
1244
1216
|
{
|
|
1245
1217
|
ref: wrapperRef,
|
|
@@ -1253,7 +1225,7 @@ function DefaultValue(props) {
|
|
|
1253
1225
|
setJsonReadOnly(false);
|
|
1254
1226
|
}
|
|
1255
1227
|
},
|
|
1256
|
-
/* @__PURE__ */
|
|
1228
|
+
/* @__PURE__ */ React15.createElement(
|
|
1257
1229
|
JsonViewer,
|
|
1258
1230
|
{
|
|
1259
1231
|
ref: JsonViewerRef,
|
|
@@ -1271,7 +1243,7 @@ function DefaultValue(props) {
|
|
|
1271
1243
|
onChange: handleJsonChange
|
|
1272
1244
|
}
|
|
1273
1245
|
)
|
|
1274
|
-
)) : /* @__PURE__ */
|
|
1246
|
+
)) : /* @__PURE__ */ React15.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React15.createElement(
|
|
1275
1247
|
ConstantInput,
|
|
1276
1248
|
{
|
|
1277
1249
|
value,
|
|
@@ -1283,15 +1255,15 @@ function DefaultValue(props) {
|
|
|
1283
1255
|
}
|
|
1284
1256
|
|
|
1285
1257
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1286
|
-
import
|
|
1287
|
-
import
|
|
1258
|
+
import React16, { useEffect as useEffect3, useState as useState3 } from "react";
|
|
1259
|
+
import Input3 from "@douyinfe/semi-ui/lib/es/input";
|
|
1288
1260
|
function BlurInput(props) {
|
|
1289
1261
|
const [value, setValue] = useState3("");
|
|
1290
|
-
|
|
1262
|
+
useEffect3(() => {
|
|
1291
1263
|
setValue(props.value);
|
|
1292
1264
|
}, [props.value]);
|
|
1293
|
-
return /* @__PURE__ */
|
|
1294
|
-
|
|
1265
|
+
return /* @__PURE__ */ React16.createElement(
|
|
1266
|
+
Input3,
|
|
1295
1267
|
{
|
|
1296
1268
|
...props,
|
|
1297
1269
|
value,
|
|
@@ -1310,7 +1282,7 @@ function JsonSchemaEditor(props) {
|
|
|
1310
1282
|
value,
|
|
1311
1283
|
onChangeProps
|
|
1312
1284
|
);
|
|
1313
|
-
return /* @__PURE__ */
|
|
1285
|
+
return /* @__PURE__ */ React17.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React17.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
|
|
1314
1286
|
PropertyEdit,
|
|
1315
1287
|
{
|
|
1316
1288
|
readonly,
|
|
@@ -1325,13 +1297,13 @@ function JsonSchemaEditor(props) {
|
|
|
1325
1297
|
onRemoveProperty(_property.key);
|
|
1326
1298
|
}
|
|
1327
1299
|
}
|
|
1328
|
-
))), /* @__PURE__ */
|
|
1300
|
+
))), /* @__PURE__ */ React17.createElement(
|
|
1329
1301
|
Button,
|
|
1330
1302
|
{
|
|
1331
1303
|
disabled: readonly,
|
|
1332
1304
|
size: "small",
|
|
1333
1305
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1334
|
-
icon: /* @__PURE__ */
|
|
1306
|
+
icon: /* @__PURE__ */ React17.createElement(IconPlus, null),
|
|
1335
1307
|
onClick: onAddProperty
|
|
1336
1308
|
},
|
|
1337
1309
|
config?.addButtonText ?? "Add"
|
|
@@ -1364,7 +1336,7 @@ function PropertyEdit(props) {
|
|
|
1364
1336
|
});
|
|
1365
1337
|
};
|
|
1366
1338
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1367
|
-
return /* @__PURE__ */
|
|
1339
|
+
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(
|
|
1368
1340
|
UIPropertyLeft,
|
|
1369
1341
|
{
|
|
1370
1342
|
type,
|
|
@@ -1376,8 +1348,8 @@ function PropertyEdit(props) {
|
|
|
1376
1348
|
$parentExpand,
|
|
1377
1349
|
$parentType
|
|
1378
1350
|
},
|
|
1379
|
-
showCollapse && /* @__PURE__ */
|
|
1380
|
-
), /* @__PURE__ */
|
|
1351
|
+
showCollapse && /* @__PURE__ */ React17.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React17.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React17.createElement(IconChevronRight, { size: "small" }))
|
|
1352
|
+
), /* @__PURE__ */ React17.createElement(UIPropertyRight, null, /* @__PURE__ */ React17.createElement(
|
|
1381
1353
|
UIPropertyMain,
|
|
1382
1354
|
{
|
|
1383
1355
|
$showCollapse: showCollapse,
|
|
@@ -1385,7 +1357,7 @@ function PropertyEdit(props) {
|
|
|
1385
1357
|
$expand: expand,
|
|
1386
1358
|
type
|
|
1387
1359
|
},
|
|
1388
|
-
/* @__PURE__ */
|
|
1360
|
+
/* @__PURE__ */ React17.createElement(UIRow, null, /* @__PURE__ */ React17.createElement(UIName, null, /* @__PURE__ */ React17.createElement(
|
|
1389
1361
|
BlurInput,
|
|
1390
1362
|
{
|
|
1391
1363
|
disabled: readonly,
|
|
@@ -1394,7 +1366,7 @@ function PropertyEdit(props) {
|
|
|
1394
1366
|
value: name,
|
|
1395
1367
|
onChange: (value2) => onChange("name", value2)
|
|
1396
1368
|
}
|
|
1397
|
-
)), /* @__PURE__ */
|
|
1369
|
+
)), /* @__PURE__ */ React17.createElement(UIType, null, /* @__PURE__ */ React17.createElement(
|
|
1398
1370
|
TypeSelector,
|
|
1399
1371
|
{
|
|
1400
1372
|
value: typeSelectorValue,
|
|
@@ -1406,47 +1378,47 @@ function PropertyEdit(props) {
|
|
|
1406
1378
|
});
|
|
1407
1379
|
}
|
|
1408
1380
|
}
|
|
1409
|
-
)), /* @__PURE__ */
|
|
1381
|
+
)), /* @__PURE__ */ React17.createElement(UIRequired, null, /* @__PURE__ */ React17.createElement(
|
|
1410
1382
|
Checkbox,
|
|
1411
1383
|
{
|
|
1412
1384
|
disabled: readonly,
|
|
1413
1385
|
checked: isPropertyRequired,
|
|
1414
1386
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1415
1387
|
}
|
|
1416
|
-
)), /* @__PURE__ */
|
|
1388
|
+
)), /* @__PURE__ */ React17.createElement(UIActions, null, /* @__PURE__ */ React17.createElement(
|
|
1417
1389
|
IconButton3,
|
|
1418
1390
|
{
|
|
1419
1391
|
disabled: readonly,
|
|
1420
1392
|
size: "small",
|
|
1421
1393
|
theme: "borderless",
|
|
1422
|
-
icon: expand ? /* @__PURE__ */
|
|
1394
|
+
icon: expand ? /* @__PURE__ */ React17.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React17.createElement(IconExpand, { size: "small" }),
|
|
1423
1395
|
onClick: () => {
|
|
1424
1396
|
setExpand((_expand) => !_expand);
|
|
1425
1397
|
}
|
|
1426
1398
|
}
|
|
1427
|
-
), isDrilldownObject && /* @__PURE__ */
|
|
1399
|
+
), isDrilldownObject && /* @__PURE__ */ React17.createElement(
|
|
1428
1400
|
IconButton3,
|
|
1429
1401
|
{
|
|
1430
1402
|
disabled: readonly,
|
|
1431
1403
|
size: "small",
|
|
1432
1404
|
theme: "borderless",
|
|
1433
|
-
icon: /* @__PURE__ */
|
|
1405
|
+
icon: /* @__PURE__ */ React17.createElement(IconAddChildren, null),
|
|
1434
1406
|
onClick: () => {
|
|
1435
1407
|
onAddProperty();
|
|
1436
1408
|
setCollapse(true);
|
|
1437
1409
|
}
|
|
1438
1410
|
}
|
|
1439
|
-
), /* @__PURE__ */
|
|
1411
|
+
), /* @__PURE__ */ React17.createElement(
|
|
1440
1412
|
IconButton3,
|
|
1441
1413
|
{
|
|
1442
1414
|
disabled: readonly,
|
|
1443
1415
|
size: "small",
|
|
1444
1416
|
theme: "borderless",
|
|
1445
|
-
icon: /* @__PURE__ */
|
|
1417
|
+
icon: /* @__PURE__ */ React17.createElement(IconMinus, { size: "small" }),
|
|
1446
1418
|
onClick: onRemove
|
|
1447
1419
|
}
|
|
1448
1420
|
))),
|
|
1449
|
-
expand && /* @__PURE__ */
|
|
1421
|
+
expand && /* @__PURE__ */ React17.createElement(UIExpandDetail, null, /* @__PURE__ */ React17.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React17.createElement(
|
|
1450
1422
|
BlurInput,
|
|
1451
1423
|
{
|
|
1452
1424
|
disabled: readonly,
|
|
@@ -1455,7 +1427,7 @@ function PropertyEdit(props) {
|
|
|
1455
1427
|
onChange: (value2) => onChange("description", value2),
|
|
1456
1428
|
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1457
1429
|
}
|
|
1458
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */
|
|
1430
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React17.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React17.createElement(
|
|
1459
1431
|
DefaultValue,
|
|
1460
1432
|
{
|
|
1461
1433
|
value: defaultValue,
|
|
@@ -1466,7 +1438,7 @@ function PropertyEdit(props) {
|
|
|
1466
1438
|
onChange: (value2) => onChange("default", value2)
|
|
1467
1439
|
}
|
|
1468
1440
|
))))
|
|
1469
|
-
), showCollapse && /* @__PURE__ */
|
|
1441
|
+
), showCollapse && /* @__PURE__ */ React17.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React17.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
|
|
1470
1442
|
PropertyEdit,
|
|
1471
1443
|
{
|
|
1472
1444
|
readonly,
|
|
@@ -1491,87 +1463,25 @@ function PropertyEdit(props) {
|
|
|
1491
1463
|
}
|
|
1492
1464
|
|
|
1493
1465
|
// src/components/batch-variable-selector/index.tsx
|
|
1494
|
-
import
|
|
1466
|
+
import React18 from "react";
|
|
1495
1467
|
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1496
1468
|
var batchVariableSchema = {
|
|
1497
1469
|
type: "array",
|
|
1498
1470
|
extra: { weak: true }
|
|
1499
1471
|
};
|
|
1500
1472
|
function BatchVariableSelector(props) {
|
|
1501
|
-
return /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ React18.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React18.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1502
1474
|
}
|
|
1503
1475
|
|
|
1504
1476
|
// src/components/dynamic-value-input/index.tsx
|
|
1505
|
-
import
|
|
1506
|
-
import {
|
|
1477
|
+
import React19 from "react";
|
|
1478
|
+
import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
|
|
1507
1479
|
import { IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
1508
1480
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1509
1481
|
|
|
1510
|
-
// src/utils/format-legacy-refs/index.ts
|
|
1511
|
-
import { isObject } from "lodash";
|
|
1512
|
-
function formatLegacyRefOnSubmit(value) {
|
|
1513
|
-
if (isObject(value)) {
|
|
1514
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
1515
|
-
return formatLegacyRefToNewRef(value);
|
|
1516
|
-
}
|
|
1517
|
-
return Object.fromEntries(
|
|
1518
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1519
|
-
key,
|
|
1520
|
-
formatLegacyRefOnSubmit(value2)
|
|
1521
|
-
])
|
|
1522
|
-
);
|
|
1523
|
-
}
|
|
1524
|
-
if (Array.isArray(value)) {
|
|
1525
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
1526
|
-
}
|
|
1527
|
-
return value;
|
|
1528
|
-
}
|
|
1529
|
-
function formatLegacyRefOnInit(value) {
|
|
1530
|
-
if (isObject(value)) {
|
|
1531
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
1532
|
-
return formatNewRefToLegacyRef(value);
|
|
1533
|
-
}
|
|
1534
|
-
return Object.fromEntries(
|
|
1535
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1536
|
-
key,
|
|
1537
|
-
formatLegacyRefOnInit(value2)
|
|
1538
|
-
])
|
|
1539
|
-
);
|
|
1540
|
-
}
|
|
1541
|
-
if (Array.isArray(value)) {
|
|
1542
|
-
return value.map(formatLegacyRefOnInit);
|
|
1543
|
-
}
|
|
1544
|
-
return value;
|
|
1545
|
-
}
|
|
1546
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
1547
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1548
|
-
}
|
|
1549
|
-
function isNewFlowRefValueSchema(value) {
|
|
1550
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1551
|
-
}
|
|
1552
|
-
function formatLegacyRefToNewRef(value) {
|
|
1553
|
-
const keyPath = value.content.split(".");
|
|
1554
|
-
if (keyPath[1] === "outputs") {
|
|
1555
|
-
return {
|
|
1556
|
-
type: "ref",
|
|
1557
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
return {
|
|
1561
|
-
type: "ref",
|
|
1562
|
-
content: keyPath
|
|
1563
|
-
};
|
|
1564
|
-
}
|
|
1565
|
-
function formatNewRefToLegacyRef(value) {
|
|
1566
|
-
return {
|
|
1567
|
-
type: "ref",
|
|
1568
|
-
content: value.content.join(".")
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
1482
|
// src/components/dynamic-value-input/styles.tsx
|
|
1573
|
-
import
|
|
1574
|
-
var UIContainer2 =
|
|
1483
|
+
import styled4 from "styled-components";
|
|
1484
|
+
var UIContainer2 = styled4.div`
|
|
1575
1485
|
display: flex;
|
|
1576
1486
|
align-items: center;
|
|
1577
1487
|
border-radius: 4px;
|
|
@@ -1581,7 +1491,7 @@ var UIContainer2 = styled3.div`
|
|
|
1581
1491
|
|
|
1582
1492
|
background-color: var(--semi-color-fill-0);
|
|
1583
1493
|
`;
|
|
1584
|
-
var UIMain =
|
|
1494
|
+
var UIMain = styled4.div`
|
|
1585
1495
|
flex-grow: 1;
|
|
1586
1496
|
overflow: hidden;
|
|
1587
1497
|
min-width: 0;
|
|
@@ -1599,14 +1509,14 @@ var UIMain = styled3.div`
|
|
|
1599
1509
|
border-radius: 0;
|
|
1600
1510
|
}
|
|
1601
1511
|
`;
|
|
1602
|
-
var UIType2 =
|
|
1512
|
+
var UIType2 = styled4.div`
|
|
1603
1513
|
border-right: 1px solid #e5e5e5;
|
|
1604
1514
|
|
|
1605
1515
|
& .semi-button {
|
|
1606
1516
|
border-radius: 0;
|
|
1607
1517
|
}
|
|
1608
1518
|
`;
|
|
1609
|
-
var UITrigger =
|
|
1519
|
+
var UITrigger = styled4.div`
|
|
1610
1520
|
border-left: 1px solid #e5e5e5;
|
|
1611
1521
|
|
|
1612
1522
|
& .semi-button {
|
|
@@ -1614,6 +1524,39 @@ var UITrigger = styled3.div`
|
|
|
1614
1524
|
}
|
|
1615
1525
|
`;
|
|
1616
1526
|
|
|
1527
|
+
// src/components/dynamic-value-input/hooks.ts
|
|
1528
|
+
import { useMemo as useMemo6, useState as useState5 } from "react";
|
|
1529
|
+
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1530
|
+
function useRefVariable(value) {
|
|
1531
|
+
const available = useScopeAvailable();
|
|
1532
|
+
const refVariable = useMemo6(() => {
|
|
1533
|
+
if (value?.type === "ref") {
|
|
1534
|
+
return available.getByKeyPath(value.content);
|
|
1535
|
+
}
|
|
1536
|
+
}, [value, available]);
|
|
1537
|
+
return refVariable;
|
|
1538
|
+
}
|
|
1539
|
+
function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
1540
|
+
let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
|
|
1541
|
+
if (value?.type === "constant") {
|
|
1542
|
+
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1543
|
+
}
|
|
1544
|
+
const [selectSchema, setSelectSchema] = useState5(defaultSelectSchema);
|
|
1545
|
+
return [selectSchema, setSelectSchema];
|
|
1546
|
+
}
|
|
1547
|
+
function useIncludeSchema(schemaFromProps) {
|
|
1548
|
+
const includeSchema = useMemo6(() => {
|
|
1549
|
+
if (!schemaFromProps) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
if (schemaFromProps?.type === "number") {
|
|
1553
|
+
return [schemaFromProps, { type: "integer" }];
|
|
1554
|
+
}
|
|
1555
|
+
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1556
|
+
}, [schemaFromProps]);
|
|
1557
|
+
return includeSchema;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1617
1560
|
// src/components/dynamic-value-input/index.tsx
|
|
1618
1561
|
function DynamicValueInput({
|
|
1619
1562
|
value,
|
|
@@ -1623,44 +1566,46 @@ function DynamicValueInput({
|
|
|
1623
1566
|
schema: schemaFromProps,
|
|
1624
1567
|
constantProps
|
|
1625
1568
|
}) {
|
|
1626
|
-
const
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
return available.getByKeyPath(value.content);
|
|
1630
|
-
}
|
|
1631
|
-
}, [value, available]);
|
|
1632
|
-
const [selectSchema, setSelectSchema] = useState5(
|
|
1633
|
-
schemaFromProps || constantProps?.schema || { type: "string" }
|
|
1634
|
-
);
|
|
1569
|
+
const refVariable = useRefVariable(value);
|
|
1570
|
+
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1571
|
+
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1635
1572
|
const renderTypeSelector = () => {
|
|
1636
1573
|
if (schemaFromProps) {
|
|
1637
|
-
return /* @__PURE__ */
|
|
1574
|
+
return /* @__PURE__ */ React19.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1638
1575
|
}
|
|
1639
1576
|
if (value?.type === "ref") {
|
|
1640
|
-
const schema = refVariable?.type ?
|
|
1641
|
-
return /* @__PURE__ */
|
|
1577
|
+
const schema = refVariable?.type ? JsonSchemaUtils3.astToSchema(refVariable?.type) : void 0;
|
|
1578
|
+
return /* @__PURE__ */ React19.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1642
1579
|
}
|
|
1643
|
-
return /* @__PURE__ */
|
|
1580
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1644
1581
|
TypeSelector,
|
|
1645
1582
|
{
|
|
1646
1583
|
value: selectSchema,
|
|
1647
|
-
onChange: (_v) =>
|
|
1584
|
+
onChange: (_v) => {
|
|
1585
|
+
setSelectSchema(_v || { type: "string" });
|
|
1586
|
+
let content;
|
|
1587
|
+
if (_v?.type === "object") {
|
|
1588
|
+
content = "{}";
|
|
1589
|
+
}
|
|
1590
|
+
if (_v?.type === "array") {
|
|
1591
|
+
content = "[]";
|
|
1592
|
+
}
|
|
1593
|
+
if (_v?.type === "boolean") {
|
|
1594
|
+
content = false;
|
|
1595
|
+
}
|
|
1596
|
+
onChange({
|
|
1597
|
+
type: "constant",
|
|
1598
|
+
content,
|
|
1599
|
+
schema: _v || { type: "string" }
|
|
1600
|
+
});
|
|
1601
|
+
},
|
|
1648
1602
|
readonly
|
|
1649
1603
|
}
|
|
1650
1604
|
);
|
|
1651
1605
|
};
|
|
1652
|
-
const includeSchema = useMemo6(() => {
|
|
1653
|
-
if (!schemaFromProps) {
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
if (schemaFromProps?.type === "number") {
|
|
1657
|
-
return [schemaFromProps, { type: "integer" }];
|
|
1658
|
-
}
|
|
1659
|
-
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1660
|
-
}, [schemaFromProps]);
|
|
1661
1606
|
const renderMain = () => {
|
|
1662
1607
|
if (value?.type === "ref") {
|
|
1663
|
-
return /* @__PURE__ */
|
|
1608
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1664
1609
|
VariableSelector,
|
|
1665
1610
|
{
|
|
1666
1611
|
style: { width: "100%" },
|
|
@@ -1672,7 +1617,7 @@ function DynamicValueInput({
|
|
|
1672
1617
|
);
|
|
1673
1618
|
}
|
|
1674
1619
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1675
|
-
return /* @__PURE__ */
|
|
1620
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1676
1621
|
ConstantInput,
|
|
1677
1622
|
{
|
|
1678
1623
|
value: value?.content,
|
|
@@ -1680,7 +1625,7 @@ function DynamicValueInput({
|
|
|
1680
1625
|
schema: constantSchema || { type: "string" },
|
|
1681
1626
|
readonly,
|
|
1682
1627
|
strategies: [...constantProps?.strategies || []],
|
|
1683
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1628
|
+
fallbackRenderer: () => /* @__PURE__ */ React19.createElement(
|
|
1684
1629
|
VariableSelector,
|
|
1685
1630
|
{
|
|
1686
1631
|
style: { width: "100%" },
|
|
@@ -1693,7 +1638,7 @@ function DynamicValueInput({
|
|
|
1693
1638
|
}
|
|
1694
1639
|
);
|
|
1695
1640
|
};
|
|
1696
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1641
|
+
const renderTrigger = () => /* @__PURE__ */ React19.createElement(
|
|
1697
1642
|
VariableSelector,
|
|
1698
1643
|
{
|
|
1699
1644
|
style: { width: "100%" },
|
|
@@ -1701,31 +1646,31 @@ function DynamicValueInput({
|
|
|
1701
1646
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1702
1647
|
includeSchema,
|
|
1703
1648
|
readonly,
|
|
1704
|
-
triggerRender: () => /* @__PURE__ */
|
|
1649
|
+
triggerRender: () => /* @__PURE__ */ React19.createElement(IconButton4, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React19.createElement(IconSetting, { size: "small" }) })
|
|
1705
1650
|
}
|
|
1706
1651
|
);
|
|
1707
|
-
return /* @__PURE__ */
|
|
1652
|
+
return /* @__PURE__ */ React19.createElement(UIContainer2, { style }, /* @__PURE__ */ React19.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React19.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React19.createElement(UITrigger, null, renderTrigger()));
|
|
1708
1653
|
}
|
|
1709
1654
|
|
|
1710
1655
|
// src/components/condition-row/index.tsx
|
|
1711
|
-
import
|
|
1712
|
-
import { Input as
|
|
1656
|
+
import React21, { useMemo as useMemo9 } from "react";
|
|
1657
|
+
import { Input as Input4 } from "@douyinfe/semi-ui";
|
|
1713
1658
|
|
|
1714
1659
|
// src/components/condition-row/styles.tsx
|
|
1715
|
-
import
|
|
1716
|
-
var UIContainer3 =
|
|
1660
|
+
import styled5 from "styled-components";
|
|
1661
|
+
var UIContainer3 = styled5.div`
|
|
1717
1662
|
display: flex;
|
|
1718
1663
|
align-items: center;
|
|
1719
1664
|
gap: 4px;
|
|
1720
1665
|
`;
|
|
1721
|
-
var UIOperator =
|
|
1722
|
-
var UILeft =
|
|
1666
|
+
var UIOperator = styled5.div``;
|
|
1667
|
+
var UILeft = styled5.div`
|
|
1723
1668
|
width: 100%;
|
|
1724
1669
|
`;
|
|
1725
|
-
var UIRight =
|
|
1670
|
+
var UIRight = styled5.div`
|
|
1726
1671
|
width: 100%;
|
|
1727
1672
|
`;
|
|
1728
|
-
var UIValues =
|
|
1673
|
+
var UIValues = styled5.div`
|
|
1729
1674
|
flex-grow: 1;
|
|
1730
1675
|
display: flex;
|
|
1731
1676
|
flex-direction: column;
|
|
@@ -1735,6 +1680,7 @@ var UIValues = styled4.div`
|
|
|
1735
1680
|
|
|
1736
1681
|
// src/components/condition-row/hooks/useRule.ts
|
|
1737
1682
|
import { useMemo as useMemo7 } from "react";
|
|
1683
|
+
import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
1738
1684
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1739
1685
|
|
|
1740
1686
|
// src/components/condition-row/constants.ts
|
|
@@ -1783,7 +1729,11 @@ var rules = {
|
|
|
1783
1729
|
},
|
|
1784
1730
|
array: {
|
|
1785
1731
|
["is_empty" /* IS_EMPTY */]: null,
|
|
1786
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1732
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null,
|
|
1733
|
+
["contains" /* CONTAINS */]: "array",
|
|
1734
|
+
["not_contains" /* NOT_CONTAINS */]: "array",
|
|
1735
|
+
["eq" /* EQ */]: "array",
|
|
1736
|
+
["neq" /* NEQ */]: "array"
|
|
1787
1737
|
},
|
|
1788
1738
|
map: {
|
|
1789
1739
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -1862,18 +1812,18 @@ function useRule(left) {
|
|
|
1862
1812
|
}, [available, left]);
|
|
1863
1813
|
const rule = useMemo7(() => {
|
|
1864
1814
|
if (!variable) return void 0;
|
|
1865
|
-
const schema =
|
|
1815
|
+
const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
|
|
1866
1816
|
return rules[schema?.type];
|
|
1867
1817
|
}, [variable?.type]);
|
|
1868
1818
|
return { rule };
|
|
1869
1819
|
}
|
|
1870
1820
|
|
|
1871
1821
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1872
|
-
import
|
|
1822
|
+
import React20, { useMemo as useMemo8 } from "react";
|
|
1873
1823
|
import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1874
1824
|
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1875
1825
|
function useOp({ rule, op, onChange, readonly }) {
|
|
1876
|
-
const
|
|
1826
|
+
const options = useMemo8(
|
|
1877
1827
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1878
1828
|
...opConfigs[_op] || {},
|
|
1879
1829
|
value: _op
|
|
@@ -1881,18 +1831,18 @@ function useOp({ rule, op, onChange, readonly }) {
|
|
|
1881
1831
|
[rule]
|
|
1882
1832
|
);
|
|
1883
1833
|
const opConfig = useMemo8(() => opConfigs[op], [op]);
|
|
1884
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1834
|
+
const renderOpSelect = () => /* @__PURE__ */ React20.createElement(
|
|
1885
1835
|
Select2,
|
|
1886
1836
|
{
|
|
1887
1837
|
style: { height: 22 },
|
|
1888
1838
|
disabled: readonly,
|
|
1889
1839
|
size: "small",
|
|
1890
1840
|
value: op,
|
|
1891
|
-
optionList:
|
|
1841
|
+
optionList: options,
|
|
1892
1842
|
onChange: (v) => {
|
|
1893
1843
|
onChange(v);
|
|
1894
1844
|
},
|
|
1895
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1845
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React20.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React20.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1896
1846
|
}
|
|
1897
1847
|
);
|
|
1898
1848
|
return { renderOpSelect, opConfig };
|
|
@@ -1912,7 +1862,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1912
1862
|
const targetType = rule?.[operator] || null;
|
|
1913
1863
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1914
1864
|
}, [rule, opConfig]);
|
|
1915
|
-
return /* @__PURE__ */
|
|
1865
|
+
return /* @__PURE__ */ React21.createElement(UIContainer3, { style }, /* @__PURE__ */ React21.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React21.createElement(UIValues, null, /* @__PURE__ */ React21.createElement(UILeft, null, /* @__PURE__ */ React21.createElement(
|
|
1916
1866
|
VariableSelector,
|
|
1917
1867
|
{
|
|
1918
1868
|
readonly,
|
|
@@ -1926,7 +1876,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1926
1876
|
}
|
|
1927
1877
|
})
|
|
1928
1878
|
}
|
|
1929
|
-
)), /* @__PURE__ */
|
|
1879
|
+
)), /* @__PURE__ */ React21.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React21.createElement(
|
|
1930
1880
|
DynamicValueInput,
|
|
1931
1881
|
{
|
|
1932
1882
|
readonly: readonly || !rule,
|
|
@@ -1934,8 +1884,8 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1934
1884
|
schema: targetSchema,
|
|
1935
1885
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1936
1886
|
}
|
|
1937
|
-
) : /* @__PURE__ */
|
|
1938
|
-
|
|
1887
|
+
) : /* @__PURE__ */ React21.createElement(
|
|
1888
|
+
Input4,
|
|
1939
1889
|
{
|
|
1940
1890
|
size: "small",
|
|
1941
1891
|
disabled: true,
|
|
@@ -1946,14 +1896,14 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1946
1896
|
}
|
|
1947
1897
|
|
|
1948
1898
|
// src/components/batch-outputs/index.tsx
|
|
1949
|
-
import
|
|
1950
|
-
import { Button as Button3, Input as
|
|
1899
|
+
import React22 from "react";
|
|
1900
|
+
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1951
1901
|
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1952
1902
|
|
|
1953
1903
|
// src/hooks/use-object-list/index.tsx
|
|
1954
|
-
import { useEffect as
|
|
1904
|
+
import { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1955
1905
|
import { nanoid } from "nanoid";
|
|
1956
|
-
import { difference, get
|
|
1906
|
+
import { difference, get, isObject, set } from "lodash";
|
|
1957
1907
|
function genId2() {
|
|
1958
1908
|
return nanoid();
|
|
1959
1909
|
}
|
|
@@ -1963,9 +1913,9 @@ function useObjectList({
|
|
|
1963
1913
|
sortIndexKey
|
|
1964
1914
|
}) {
|
|
1965
1915
|
const [list, setList] = useState6([]);
|
|
1966
|
-
|
|
1916
|
+
useEffect4(() => {
|
|
1967
1917
|
setList((_prevList) => {
|
|
1968
|
-
const newKeys = Object.entries(value || {}).sort((a, b) =>
|
|
1918
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
1969
1919
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1970
1920
|
const addKeys = difference(newKeys, oldKeys);
|
|
1971
1921
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
@@ -2003,7 +1953,7 @@ function useObjectList({
|
|
|
2003
1953
|
onChange(
|
|
2004
1954
|
Object.fromEntries(
|
|
2005
1955
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2006
|
-
if (
|
|
1956
|
+
if (isObject(_res[1]) && sortIndexKey) {
|
|
2007
1957
|
set(_res[1], sortIndexKey, idx);
|
|
2008
1958
|
}
|
|
2009
1959
|
return _res;
|
|
@@ -2047,14 +1997,14 @@ function useObjectList({
|
|
|
2047
1997
|
}
|
|
2048
1998
|
|
|
2049
1999
|
// src/components/batch-outputs/styles.tsx
|
|
2050
|
-
import
|
|
2051
|
-
var UIRows =
|
|
2000
|
+
import styled6 from "styled-components";
|
|
2001
|
+
var UIRows = styled6.div`
|
|
2052
2002
|
display: flex;
|
|
2053
2003
|
flex-direction: column;
|
|
2054
2004
|
gap: 10px;
|
|
2055
2005
|
margin-bottom: 10px;
|
|
2056
2006
|
`;
|
|
2057
|
-
var UIRow2 =
|
|
2007
|
+
var UIRow2 = styled6.div`
|
|
2058
2008
|
display: flex;
|
|
2059
2009
|
align-items: center;
|
|
2060
2010
|
gap: 5px;
|
|
@@ -2064,8 +2014,8 @@ var UIRow2 = styled5.div`
|
|
|
2064
2014
|
function BatchOutputs(props) {
|
|
2065
2015
|
const { readonly, style } = props;
|
|
2066
2016
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2067
|
-
return /* @__PURE__ */
|
|
2068
|
-
|
|
2017
|
+
return /* @__PURE__ */ React22.createElement("div", null, /* @__PURE__ */ React22.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React22.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React22.createElement(
|
|
2018
|
+
Input5,
|
|
2069
2019
|
{
|
|
2070
2020
|
style: { width: 100 },
|
|
2071
2021
|
disabled: readonly,
|
|
@@ -2073,7 +2023,7 @@ function BatchOutputs(props) {
|
|
|
2073
2023
|
value: item.key,
|
|
2074
2024
|
onChange: (v) => updateKey(item.id, v)
|
|
2075
2025
|
}
|
|
2076
|
-
), /* @__PURE__ */
|
|
2026
|
+
), /* @__PURE__ */ React22.createElement(
|
|
2077
2027
|
VariableSelector,
|
|
2078
2028
|
{
|
|
2079
2029
|
style: { flexGrow: 1 },
|
|
@@ -2081,25 +2031,25 @@ function BatchOutputs(props) {
|
|
|
2081
2031
|
value: item.value?.content,
|
|
2082
2032
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2083
2033
|
}
|
|
2084
|
-
), /* @__PURE__ */
|
|
2034
|
+
), /* @__PURE__ */ React22.createElement(
|
|
2085
2035
|
Button3,
|
|
2086
2036
|
{
|
|
2087
2037
|
disabled: readonly,
|
|
2088
|
-
icon: /* @__PURE__ */
|
|
2038
|
+
icon: /* @__PURE__ */ React22.createElement(IconDelete, null),
|
|
2089
2039
|
size: "small",
|
|
2090
2040
|
onClick: () => remove(item.id)
|
|
2091
2041
|
}
|
|
2092
|
-
)))), /* @__PURE__ */
|
|
2042
|
+
)))), /* @__PURE__ */ React22.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React22.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2093
2043
|
}
|
|
2094
2044
|
|
|
2095
2045
|
// src/components/prompt-editor/index.tsx
|
|
2096
|
-
import
|
|
2097
|
-
import { Renderer, EditorProvider, ActiveLinePlaceholder } from "@coze-editor/editor/react";
|
|
2098
|
-
import
|
|
2046
|
+
import React23, { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2047
|
+
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2048
|
+
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2099
2049
|
|
|
2100
2050
|
// src/components/prompt-editor/styles.tsx
|
|
2101
|
-
import
|
|
2102
|
-
var UIContainer4 =
|
|
2051
|
+
import styled7, { css as css3 } from "styled-components";
|
|
2052
|
+
var UIContainer4 = styled7.div`
|
|
2103
2053
|
background-color: var(--semi-color-fill-0);
|
|
2104
2054
|
padding-left: 10px;
|
|
2105
2055
|
padding-right: 6px;
|
|
@@ -2113,7 +2063,7 @@ var UIContainer4 = styled6.div`
|
|
|
2113
2063
|
import { useLayoutEffect } from "react";
|
|
2114
2064
|
import { useInjector } from "@coze-editor/editor/react";
|
|
2115
2065
|
import { astDecorator } from "@coze-editor/editor";
|
|
2116
|
-
import { EditorView } from "@codemirror/view";
|
|
2066
|
+
import { EditorView as EditorView2 } from "@codemirror/view";
|
|
2117
2067
|
function MarkdownHighlight() {
|
|
2118
2068
|
const injector = useInjector();
|
|
2119
2069
|
useLayoutEffect(
|
|
@@ -2144,7 +2094,7 @@ function MarkdownHighlight() {
|
|
|
2144
2094
|
};
|
|
2145
2095
|
}
|
|
2146
2096
|
}),
|
|
2147
|
-
|
|
2097
|
+
EditorView2.theme({
|
|
2148
2098
|
".heading": {
|
|
2149
2099
|
color: "#00818C",
|
|
2150
2100
|
fontWeight: "bold"
|
|
@@ -2181,7 +2131,7 @@ var language_support_default = LanguageSupport;
|
|
|
2181
2131
|
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
2182
2132
|
import { useInjector as useInjector3 } from "@coze-editor/editor/react";
|
|
2183
2133
|
import { astDecorator as astDecorator2 } from "@coze-editor/editor";
|
|
2184
|
-
import { EditorView as
|
|
2134
|
+
import { EditorView as EditorView3 } from "@codemirror/view";
|
|
2185
2135
|
function JinjaHighlight() {
|
|
2186
2136
|
const injector = useInjector3();
|
|
2187
2137
|
useLayoutEffect3(
|
|
@@ -2206,7 +2156,7 @@ function JinjaHighlight() {
|
|
|
2206
2156
|
};
|
|
2207
2157
|
}
|
|
2208
2158
|
}),
|
|
2209
|
-
|
|
2159
|
+
EditorView3.theme({
|
|
2210
2160
|
".jinja-statement-bracket": {
|
|
2211
2161
|
color: "#D1009D"
|
|
2212
2162
|
},
|
|
@@ -2237,19 +2187,19 @@ function PromptEditor(props) {
|
|
|
2237
2187
|
children,
|
|
2238
2188
|
disableMarkdownHighlight
|
|
2239
2189
|
} = props || {};
|
|
2240
|
-
const editorRef =
|
|
2241
|
-
|
|
2190
|
+
const editorRef = useRef4(null);
|
|
2191
|
+
useEffect5(() => {
|
|
2242
2192
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2243
2193
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2244
2194
|
}
|
|
2245
2195
|
}, [value]);
|
|
2246
|
-
return /* @__PURE__ */
|
|
2196
|
+
return /* @__PURE__ */ React23.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React23.createElement(EditorProvider2, null, /* @__PURE__ */ React23.createElement(
|
|
2247
2197
|
Renderer,
|
|
2248
2198
|
{
|
|
2249
2199
|
didMount: (editor) => {
|
|
2250
2200
|
editorRef.current = editor;
|
|
2251
2201
|
},
|
|
2252
|
-
plugins:
|
|
2202
|
+
plugins: preset2,
|
|
2253
2203
|
defaultValue: String(value?.content),
|
|
2254
2204
|
options: {
|
|
2255
2205
|
readOnly: readonly,
|
|
@@ -2260,14 +2210,14 @@ function PromptEditor(props) {
|
|
|
2260
2210
|
onChange({ type: "template", content: e.value });
|
|
2261
2211
|
}
|
|
2262
2212
|
}
|
|
2263
|
-
), activeLinePlaceholder && /* @__PURE__ */
|
|
2213
|
+
), activeLinePlaceholder && /* @__PURE__ */ React23.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React23.createElement(markdown_default, null), /* @__PURE__ */ React23.createElement(language_support_default, null), /* @__PURE__ */ React23.createElement(jinja_default, null), children));
|
|
2264
2214
|
}
|
|
2265
2215
|
|
|
2266
2216
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2267
|
-
import
|
|
2217
|
+
import React26 from "react";
|
|
2268
2218
|
|
|
2269
2219
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2270
|
-
import
|
|
2220
|
+
import React24, { useEffect as useEffect6, useState as useState7 } from "react";
|
|
2271
2221
|
import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
|
|
2272
2222
|
import {
|
|
2273
2223
|
Mention,
|
|
@@ -2295,20 +2245,20 @@ function VariableTree() {
|
|
|
2295
2245
|
setPosition(e.state.selection.main.head);
|
|
2296
2246
|
setVisible(e.value);
|
|
2297
2247
|
}
|
|
2298
|
-
|
|
2248
|
+
useEffect6(() => {
|
|
2299
2249
|
if (!editor) {
|
|
2300
2250
|
return;
|
|
2301
2251
|
}
|
|
2302
2252
|
}, [editor, visible]);
|
|
2303
2253
|
const treeData = useVariableTree({});
|
|
2304
|
-
return /* @__PURE__ */
|
|
2254
|
+
return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React24.createElement(
|
|
2305
2255
|
Popover2,
|
|
2306
2256
|
{
|
|
2307
2257
|
visible,
|
|
2308
2258
|
trigger: "custom",
|
|
2309
2259
|
position: "topLeft",
|
|
2310
2260
|
rePosKey: posKey,
|
|
2311
|
-
content: /* @__PURE__ */
|
|
2261
|
+
content: /* @__PURE__ */ React24.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React24.createElement(
|
|
2312
2262
|
Tree,
|
|
2313
2263
|
{
|
|
2314
2264
|
treeData,
|
|
@@ -2318,7 +2268,7 @@ function VariableTree() {
|
|
|
2318
2268
|
}
|
|
2319
2269
|
))
|
|
2320
2270
|
},
|
|
2321
|
-
/* @__PURE__ */
|
|
2271
|
+
/* @__PURE__ */ React24.createElement(
|
|
2322
2272
|
PositionMirror,
|
|
2323
2273
|
{
|
|
2324
2274
|
position,
|
|
@@ -2330,7 +2280,7 @@ function VariableTree() {
|
|
|
2330
2280
|
|
|
2331
2281
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2332
2282
|
import ReactDOM from "react-dom";
|
|
2333
|
-
import
|
|
2283
|
+
import React25, { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2334
2284
|
import { isEqual, last } from "lodash";
|
|
2335
2285
|
import {
|
|
2336
2286
|
Disposable,
|
|
@@ -2342,16 +2292,16 @@ import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
|
|
|
2342
2292
|
import { useInjector as useInjector4 } from "@coze-editor/editor/react";
|
|
2343
2293
|
import {
|
|
2344
2294
|
Decoration,
|
|
2345
|
-
EditorView as
|
|
2295
|
+
EditorView as EditorView4,
|
|
2346
2296
|
MatchDecorator,
|
|
2347
2297
|
ViewPlugin,
|
|
2348
2298
|
WidgetType
|
|
2349
2299
|
} from "@codemirror/view";
|
|
2350
2300
|
|
|
2351
2301
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2352
|
-
import
|
|
2302
|
+
import styled8 from "styled-components";
|
|
2353
2303
|
import { Tag as Tag2 } from "@douyinfe/semi-ui";
|
|
2354
|
-
var UIRootTitle2 =
|
|
2304
|
+
var UIRootTitle2 = styled8.div`
|
|
2355
2305
|
margin-right: 4px;
|
|
2356
2306
|
min-width: 20px;
|
|
2357
2307
|
overflow: hidden;
|
|
@@ -2359,12 +2309,12 @@ var UIRootTitle2 = styled7.div`
|
|
|
2359
2309
|
white-space: nowrap;
|
|
2360
2310
|
color: var(--semi-color-text-2);
|
|
2361
2311
|
`;
|
|
2362
|
-
var UIVarName2 =
|
|
2312
|
+
var UIVarName2 = styled8.div`
|
|
2363
2313
|
overflow: hidden;
|
|
2364
2314
|
text-overflow: ellipsis;
|
|
2365
2315
|
white-space: nowrap;
|
|
2366
2316
|
`;
|
|
2367
|
-
var UITag2 =
|
|
2317
|
+
var UITag2 = styled8(Tag2)`
|
|
2368
2318
|
display: inline-flex;
|
|
2369
2319
|
align-items: center;
|
|
2370
2320
|
justify-content: flex-start;
|
|
@@ -2378,7 +2328,7 @@ var UITag2 = styled7(Tag2)`
|
|
|
2378
2328
|
margin: 0 5px;
|
|
2379
2329
|
}
|
|
2380
2330
|
`;
|
|
2381
|
-
var UIPopoverContent2 =
|
|
2331
|
+
var UIPopoverContent2 = styled8.div`
|
|
2382
2332
|
padding: 10px;
|
|
2383
2333
|
display: inline-flex;
|
|
2384
2334
|
align-items: center;
|
|
@@ -2392,7 +2342,7 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2392
2342
|
this.toDispose = new DisposableCollection();
|
|
2393
2343
|
this.renderIcon = (icon) => {
|
|
2394
2344
|
if (typeof icon === "string") {
|
|
2395
|
-
return /* @__PURE__ */
|
|
2345
|
+
return /* @__PURE__ */ React25.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2396
2346
|
}
|
|
2397
2347
|
return icon;
|
|
2398
2348
|
};
|
|
@@ -2405,21 +2355,21 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2405
2355
|
renderVariable(v) {
|
|
2406
2356
|
if (!v) {
|
|
2407
2357
|
this.renderReact(
|
|
2408
|
-
/* @__PURE__ */
|
|
2358
|
+
/* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React25.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
|
|
2409
2359
|
);
|
|
2410
2360
|
return;
|
|
2411
2361
|
}
|
|
2412
2362
|
const rootField = last(v.parentFields) || v;
|
|
2413
2363
|
const isRoot = v.parentFields.length === 0;
|
|
2414
|
-
const rootTitle = /* @__PURE__ */
|
|
2364
|
+
const rootTitle = /* @__PURE__ */ React25.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2415
2365
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2416
2366
|
this.renderReact(
|
|
2417
|
-
/* @__PURE__ */
|
|
2367
|
+
/* @__PURE__ */ React25.createElement(
|
|
2418
2368
|
Popover3,
|
|
2419
2369
|
{
|
|
2420
|
-
content: /* @__PURE__ */
|
|
2370
|
+
content: /* @__PURE__ */ React25.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2421
2371
|
},
|
|
2422
|
-
/* @__PURE__ */
|
|
2372
|
+
/* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.key))
|
|
2423
2373
|
)
|
|
2424
2374
|
);
|
|
2425
2375
|
}
|
|
@@ -2480,7 +2430,7 @@ function VariableTagInject() {
|
|
|
2480
2430
|
{
|
|
2481
2431
|
decorations: (p) => p.decorations,
|
|
2482
2432
|
provide(p) {
|
|
2483
|
-
return
|
|
2433
|
+
return EditorView4.atomicRanges.of(
|
|
2484
2434
|
(view) => view.plugin(p)?.decorations ?? Decoration.none
|
|
2485
2435
|
);
|
|
2486
2436
|
}
|
|
@@ -2493,14 +2443,14 @@ function VariableTagInject() {
|
|
|
2493
2443
|
|
|
2494
2444
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2495
2445
|
function PromptEditorWithVariables(props) {
|
|
2496
|
-
return /* @__PURE__ */
|
|
2446
|
+
return /* @__PURE__ */ React26.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React26.createElement(VariableTree, null), /* @__PURE__ */ React26.createElement(VariableTagInject, null));
|
|
2497
2447
|
}
|
|
2498
2448
|
|
|
2499
2449
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2500
|
-
import
|
|
2450
|
+
import React29 from "react";
|
|
2501
2451
|
|
|
2502
2452
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2503
|
-
import
|
|
2453
|
+
import React28, { useEffect as useEffect7, useState as useState8 } from "react";
|
|
2504
2454
|
import { Popover as Popover4 } from "@douyinfe/semi-ui";
|
|
2505
2455
|
import {
|
|
2506
2456
|
Mention as Mention2,
|
|
@@ -2510,7 +2460,7 @@ import {
|
|
|
2510
2460
|
} from "@coze-editor/editor/react";
|
|
2511
2461
|
|
|
2512
2462
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2513
|
-
import
|
|
2463
|
+
import React27, { useMemo as useMemo10 } from "react";
|
|
2514
2464
|
import { last as last2 } from "lodash";
|
|
2515
2465
|
import {
|
|
2516
2466
|
ASTMatch as ASTMatch3,
|
|
@@ -2554,434 +2504,89 @@ function InputsPicker({
|
|
|
2554
2504
|
children
|
|
2555
2505
|
};
|
|
2556
2506
|
};
|
|
2557
|
-
const treeData = useMemo10(
|
|
2558
|
-
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2559
|
-
if (value?.type === "ref") {
|
|
2560
|
-
const variable = available.getByKeyPath(value.content || []);
|
|
2561
|
-
if (variable) {
|
|
2562
|
-
return renderVariable(variable, [key]);
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
return {
|
|
2566
|
-
key,
|
|
2567
|
-
value: key,
|
|
2568
|
-
label: key
|
|
2569
|
-
};
|
|
2570
|
-
}),
|
|
2571
|
-
[]
|
|
2572
|
-
);
|
|
2573
|
-
return /* @__PURE__ */
|
|
2574
|
-
}
|
|
2575
|
-
|
|
2576
|
-
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2577
|
-
function InputsTree({ inputsValues }) {
|
|
2578
|
-
const [posKey, setPosKey] = useState8("");
|
|
2579
|
-
const [visible, setVisible] = useState8(false);
|
|
2580
|
-
const [position, setPosition] = useState8(-1);
|
|
2581
|
-
const editor = useEditor2();
|
|
2582
|
-
function insert(variablePath) {
|
|
2583
|
-
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
2584
|
-
if (!range) {
|
|
2585
|
-
return;
|
|
2586
|
-
}
|
|
2587
|
-
editor.replaceText({
|
|
2588
|
-
...range,
|
|
2589
|
-
text: "{{" + variablePath + "}}"
|
|
2590
|
-
});
|
|
2591
|
-
setVisible(false);
|
|
2592
|
-
}
|
|
2593
|
-
function handleOpenChange(e) {
|
|
2594
|
-
setPosition(e.state.selection.main.head);
|
|
2595
|
-
setVisible(e.value);
|
|
2596
|
-
}
|
|
2597
|
-
useEffect6(() => {
|
|
2598
|
-
if (!editor) {
|
|
2599
|
-
return;
|
|
2600
|
-
}
|
|
2601
|
-
}, [editor, visible]);
|
|
2602
|
-
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React20.createElement(
|
|
2603
|
-
Popover4,
|
|
2604
|
-
{
|
|
2605
|
-
visible,
|
|
2606
|
-
trigger: "custom",
|
|
2607
|
-
position: "topLeft",
|
|
2608
|
-
rePosKey: posKey,
|
|
2609
|
-
content: /* @__PURE__ */ React20.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React20.createElement(
|
|
2610
|
-
InputsPicker,
|
|
2611
|
-
{
|
|
2612
|
-
inputsValues,
|
|
2613
|
-
onSelect: (v) => {
|
|
2614
|
-
insert(v);
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
))
|
|
2618
|
-
},
|
|
2619
|
-
/* @__PURE__ */ React20.createElement(
|
|
2620
|
-
PositionMirror2,
|
|
2621
|
-
{
|
|
2622
|
-
position,
|
|
2623
|
-
onChange: () => setPosKey(String(Math.random()))
|
|
2624
|
-
}
|
|
2625
|
-
)
|
|
2626
|
-
));
|
|
2627
|
-
}
|
|
2628
|
-
|
|
2629
|
-
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2630
|
-
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2631
|
-
return /* @__PURE__ */ React21.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React21.createElement(InputsTree, { inputsValues }));
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
// src/components/code-editor/index.tsx
|
|
2635
|
-
import React22, { useEffect as useEffect7, useRef as useRef4 } from "react";
|
|
2636
|
-
import {
|
|
2637
|
-
ActiveLinePlaceholder as ActiveLinePlaceholder2,
|
|
2638
|
-
createRenderer,
|
|
2639
|
-
EditorProvider as EditorProvider2
|
|
2640
|
-
} from "@coze-editor/editor/react";
|
|
2641
|
-
import preset2 from "@coze-editor/editor/preset-code";
|
|
2642
|
-
import { EditorView as EditorView4 } from "@codemirror/view";
|
|
2643
|
-
|
|
2644
|
-
// src/components/code-editor/utils.ts
|
|
2645
|
-
function getSuffixByLanguageId(languageId) {
|
|
2646
|
-
if (languageId === "python") {
|
|
2647
|
-
return ".py";
|
|
2648
|
-
}
|
|
2649
|
-
if (languageId === "typescript") {
|
|
2650
|
-
return ".ts";
|
|
2651
|
-
}
|
|
2652
|
-
if (languageId === "shell") {
|
|
2653
|
-
return ".sh";
|
|
2654
|
-
}
|
|
2655
|
-
if (languageId === "json") {
|
|
2656
|
-
return ".json";
|
|
2657
|
-
}
|
|
2658
|
-
return "";
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
// src/components/code-editor/language-features.ts
|
|
2662
|
-
import { languages } from "@coze-editor/editor/preset-code";
|
|
2663
|
-
import { typescript } from "@coze-editor/editor/language-typescript";
|
|
2664
|
-
import { shell } from "@coze-editor/editor/language-shell";
|
|
2665
|
-
import { python } from "@coze-editor/editor/language-python";
|
|
2666
|
-
import { json } from "@coze-editor/editor/language-json";
|
|
2667
|
-
import { mixLanguages } from "@coze-editor/editor";
|
|
2668
|
-
languages.register("python", python);
|
|
2669
|
-
languages.register("shell", shell);
|
|
2670
|
-
languages.register("typescript", typescript);
|
|
2671
|
-
languages.register("json", {
|
|
2672
|
-
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2673
|
-
language: mixLanguages({
|
|
2674
|
-
outerLanguage: json.language
|
|
2675
|
-
}),
|
|
2676
|
-
languageService: json.languageService
|
|
2677
|
-
});
|
|
2678
|
-
var tsWorkerInit = false;
|
|
2679
|
-
var initTsWorker = () => {
|
|
2680
|
-
if (tsWorkerInit) {
|
|
2681
|
-
return;
|
|
2682
|
-
}
|
|
2683
|
-
tsWorkerInit = true;
|
|
2684
|
-
const tsWorker = new Worker(
|
|
2685
|
-
new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
|
|
2686
|
-
{ type: "module" }
|
|
2687
|
-
);
|
|
2688
|
-
typescript.languageService.initialize(tsWorker, {
|
|
2689
|
-
compilerOptions: {
|
|
2690
|
-
// eliminate Promise error
|
|
2691
|
-
lib: ["es2015", "dom"],
|
|
2692
|
-
noImplicitAny: false
|
|
2693
|
-
}
|
|
2694
|
-
});
|
|
2695
|
-
};
|
|
2696
|
-
|
|
2697
|
-
// src/components/code-editor/theme/index.ts
|
|
2698
|
-
import { themes } from "@coze-editor/editor/preset-code";
|
|
2699
|
-
|
|
2700
|
-
// src/components/code-editor/theme/light.ts
|
|
2701
|
-
import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
|
|
2702
|
-
var colors = {
|
|
2703
|
-
background: "#F7F7FC",
|
|
2704
|
-
// syntax
|
|
2705
|
-
comment: "#000A298A",
|
|
2706
|
-
key: "#00818C",
|
|
2707
|
-
string: "#D1009D",
|
|
2708
|
-
number: "#C74200",
|
|
2709
|
-
boolean: "#2B57D9",
|
|
2710
|
-
null: "#2B57D9",
|
|
2711
|
-
separator: "#0F1529D1"
|
|
2712
|
-
};
|
|
2713
|
-
var lightTheme = createTheme({
|
|
2714
|
-
variant: "light",
|
|
2715
|
-
settings: {
|
|
2716
|
-
background: "#fff",
|
|
2717
|
-
foreground: "#000",
|
|
2718
|
-
caret: "#000",
|
|
2719
|
-
selection: "#d9d9d9",
|
|
2720
|
-
gutterBackground: "#f0f0f0",
|
|
2721
|
-
gutterForeground: "#666",
|
|
2722
|
-
gutterBorderColor: "transparent",
|
|
2723
|
-
gutterBorderWidth: 0,
|
|
2724
|
-
lineHighlight: "#f0f0f0",
|
|
2725
|
-
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
2726
|
-
tooltip: {
|
|
2727
|
-
backgroundColor: "#f0f0f0",
|
|
2728
|
-
color: "#000",
|
|
2729
|
-
border: "1px solid #ccc"
|
|
2730
|
-
},
|
|
2731
|
-
link: {
|
|
2732
|
-
color: "#007bff"
|
|
2733
|
-
},
|
|
2734
|
-
completionItemHover: {
|
|
2735
|
-
backgroundColor: "#f0f0f0"
|
|
2736
|
-
},
|
|
2737
|
-
completionItemSelected: {
|
|
2738
|
-
backgroundColor: "#e0e0e0"
|
|
2739
|
-
},
|
|
2740
|
-
completionItemIcon: {
|
|
2741
|
-
color: "#333"
|
|
2742
|
-
},
|
|
2743
|
-
completionItemLabel: {
|
|
2744
|
-
color: "#333"
|
|
2745
|
-
},
|
|
2746
|
-
completionItemInfo: {
|
|
2747
|
-
color: "#333"
|
|
2748
|
-
},
|
|
2749
|
-
completionItemDetail: {
|
|
2750
|
-
color: "#666"
|
|
2751
|
-
}
|
|
2752
|
-
},
|
|
2753
|
-
styles: [
|
|
2754
|
-
// JSON
|
|
2755
|
-
{
|
|
2756
|
-
tag: t.comment,
|
|
2757
|
-
color: colors.comment
|
|
2758
|
-
},
|
|
2759
|
-
{
|
|
2760
|
-
tag: [t.propertyName],
|
|
2761
|
-
color: colors.key
|
|
2762
|
-
},
|
|
2763
|
-
{
|
|
2764
|
-
tag: [t.string],
|
|
2765
|
-
color: colors.string
|
|
2766
|
-
},
|
|
2767
|
-
{
|
|
2768
|
-
tag: [t.number],
|
|
2769
|
-
color: colors.number
|
|
2770
|
-
},
|
|
2771
|
-
{
|
|
2772
|
-
tag: [t.bool],
|
|
2773
|
-
color: colors.boolean
|
|
2774
|
-
},
|
|
2775
|
-
{
|
|
2776
|
-
tag: [t.null],
|
|
2777
|
-
color: colors.null
|
|
2778
|
-
},
|
|
2779
|
-
{
|
|
2780
|
-
tag: [t.separator],
|
|
2781
|
-
color: colors.separator
|
|
2782
|
-
},
|
|
2783
|
-
// markdown
|
|
2784
|
-
{
|
|
2785
|
-
tag: [t.heading],
|
|
2786
|
-
color: "#3e76ef"
|
|
2787
|
-
},
|
|
2788
|
-
{
|
|
2789
|
-
tag: [t.processingInstruction],
|
|
2790
|
-
color: "#3e76ef"
|
|
2791
|
-
},
|
|
2792
|
-
// shell
|
|
2793
|
-
// curl
|
|
2794
|
-
{
|
|
2795
|
-
tag: [t.standard(t.variableName)],
|
|
2796
|
-
color: "#00804A"
|
|
2797
|
-
},
|
|
2798
|
-
// -X
|
|
2799
|
-
{
|
|
2800
|
-
tag: [t.attributeName],
|
|
2801
|
-
color: "#C74200"
|
|
2802
|
-
},
|
|
2803
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2804
|
-
{
|
|
2805
|
-
tag: [t.special(t.string)],
|
|
2806
|
-
color: "#2B57D9"
|
|
2807
|
-
}
|
|
2808
|
-
]
|
|
2809
|
-
});
|
|
2810
|
-
|
|
2811
|
-
// src/components/code-editor/theme/dark.ts
|
|
2812
|
-
import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
|
|
2813
|
-
var colors2 = {
|
|
2814
|
-
background: "#151B27",
|
|
2815
|
-
// syntax
|
|
2816
|
-
comment: "#FFFFFF63",
|
|
2817
|
-
key: "#39E5D7",
|
|
2818
|
-
string: "#FF94D2",
|
|
2819
|
-
number: "#FF9933",
|
|
2820
|
-
boolean: "#78B0FF",
|
|
2821
|
-
null: "#78B0FF",
|
|
2822
|
-
separator: "#FFFFFFC9"
|
|
2823
|
-
};
|
|
2824
|
-
var darkTheme = createTheme2({
|
|
2825
|
-
variant: "dark",
|
|
2826
|
-
settings: {
|
|
2827
|
-
background: colors2.background,
|
|
2828
|
-
foreground: "#fff",
|
|
2829
|
-
caret: "#AEAFAD",
|
|
2830
|
-
selection: "#d9d9d942",
|
|
2831
|
-
gutterBackground: colors2.background,
|
|
2832
|
-
gutterForeground: "#FFFFFF63",
|
|
2833
|
-
gutterBorderColor: "transparent",
|
|
2834
|
-
gutterBorderWidth: 0,
|
|
2835
|
-
lineHighlight: "#272e3d36",
|
|
2836
|
-
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2837
|
-
tooltip: {
|
|
2838
|
-
backgroundColor: "#363D4D",
|
|
2839
|
-
color: "#fff",
|
|
2840
|
-
border: "none"
|
|
2841
|
-
},
|
|
2842
|
-
link: {
|
|
2843
|
-
color: "#4daafc"
|
|
2844
|
-
},
|
|
2845
|
-
completionItemHover: {
|
|
2846
|
-
backgroundColor: "#FFFFFF0F"
|
|
2847
|
-
},
|
|
2848
|
-
completionItemSelected: {
|
|
2849
|
-
backgroundColor: "#FFFFFF17"
|
|
2850
|
-
},
|
|
2851
|
-
completionItemIcon: {
|
|
2852
|
-
color: "#FFFFFFC9"
|
|
2853
|
-
},
|
|
2854
|
-
completionItemLabel: {
|
|
2855
|
-
color: "#FFFFFFC9"
|
|
2856
|
-
},
|
|
2857
|
-
completionItemInfo: {
|
|
2858
|
-
color: "#FFFFFFC9"
|
|
2859
|
-
},
|
|
2860
|
-
completionItemDetail: {
|
|
2861
|
-
color: "#FFFFFF63"
|
|
2862
|
-
}
|
|
2863
|
-
},
|
|
2864
|
-
styles: [
|
|
2865
|
-
// json
|
|
2866
|
-
{
|
|
2867
|
-
tag: t2.comment,
|
|
2868
|
-
color: colors2.comment
|
|
2869
|
-
},
|
|
2870
|
-
{
|
|
2871
|
-
tag: [t2.propertyName],
|
|
2872
|
-
color: colors2.key
|
|
2873
|
-
},
|
|
2874
|
-
{
|
|
2875
|
-
tag: [t2.string],
|
|
2876
|
-
color: colors2.string
|
|
2877
|
-
},
|
|
2878
|
-
{
|
|
2879
|
-
tag: [t2.number],
|
|
2880
|
-
color: colors2.number
|
|
2881
|
-
},
|
|
2882
|
-
{
|
|
2883
|
-
tag: [t2.bool],
|
|
2884
|
-
color: colors2.boolean
|
|
2885
|
-
},
|
|
2886
|
-
{
|
|
2887
|
-
tag: [t2.null],
|
|
2888
|
-
color: colors2.null
|
|
2889
|
-
},
|
|
2890
|
-
{
|
|
2891
|
-
tag: [t2.separator],
|
|
2892
|
-
color: colors2.separator
|
|
2893
|
-
},
|
|
2894
|
-
// markdown
|
|
2895
|
-
{
|
|
2896
|
-
tag: [t2.heading],
|
|
2897
|
-
color: "#6b6bff"
|
|
2898
|
-
},
|
|
2899
|
-
{
|
|
2900
|
-
tag: [t2.processingInstruction],
|
|
2901
|
-
color: "#6b6bff"
|
|
2902
|
-
},
|
|
2903
|
-
// shell
|
|
2904
|
-
// curl
|
|
2905
|
-
{
|
|
2906
|
-
tag: [t2.standard(t2.variableName)],
|
|
2907
|
-
color: "#3BEB84"
|
|
2908
|
-
},
|
|
2909
|
-
// -X
|
|
2910
|
-
{
|
|
2911
|
-
tag: [t2.attributeName],
|
|
2912
|
-
color: "#FF9933"
|
|
2913
|
-
},
|
|
2914
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2915
|
-
{
|
|
2916
|
-
tag: [t2.special(t2.string)],
|
|
2917
|
-
color: "#78B0FF"
|
|
2918
|
-
}
|
|
2919
|
-
]
|
|
2920
|
-
});
|
|
2921
|
-
|
|
2922
|
-
// src/components/code-editor/theme/index.ts
|
|
2923
|
-
themes.register("dark", darkTheme);
|
|
2924
|
-
themes.register("light", lightTheme);
|
|
2507
|
+
const treeData = useMemo10(
|
|
2508
|
+
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2509
|
+
if (value?.type === "ref") {
|
|
2510
|
+
const variable = available.getByKeyPath(value.content || []);
|
|
2511
|
+
if (variable) {
|
|
2512
|
+
return renderVariable(variable, [key]);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return {
|
|
2516
|
+
key,
|
|
2517
|
+
value: key,
|
|
2518
|
+
label: key
|
|
2519
|
+
};
|
|
2520
|
+
}),
|
|
2521
|
+
[]
|
|
2522
|
+
);
|
|
2523
|
+
return /* @__PURE__ */ React27.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
2524
|
+
}
|
|
2925
2525
|
|
|
2926
|
-
// src/components/
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
onChange,
|
|
2937
|
-
languageId = "python",
|
|
2938
|
-
theme = "light",
|
|
2939
|
-
children,
|
|
2940
|
-
placeholder,
|
|
2941
|
-
activeLinePlaceholder,
|
|
2942
|
-
options: options2,
|
|
2943
|
-
readonly
|
|
2944
|
-
}) {
|
|
2945
|
-
const editorRef = useRef4(null);
|
|
2946
|
-
useEffect7(() => {
|
|
2947
|
-
if (languageId === "typescript") {
|
|
2948
|
-
initTsWorker();
|
|
2526
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2527
|
+
function InputsTree({ inputsValues }) {
|
|
2528
|
+
const [posKey, setPosKey] = useState8("");
|
|
2529
|
+
const [visible, setVisible] = useState8(false);
|
|
2530
|
+
const [position, setPosition] = useState8(-1);
|
|
2531
|
+
const editor = useEditor2();
|
|
2532
|
+
function insert(variablePath) {
|
|
2533
|
+
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
2534
|
+
if (!range) {
|
|
2535
|
+
return;
|
|
2949
2536
|
}
|
|
2950
|
-
|
|
2537
|
+
editor.replaceText({
|
|
2538
|
+
...range,
|
|
2539
|
+
text: "{{" + variablePath + "}}"
|
|
2540
|
+
});
|
|
2541
|
+
setVisible(false);
|
|
2542
|
+
}
|
|
2543
|
+
function handleOpenChange(e) {
|
|
2544
|
+
setPosition(e.state.selection.main.head);
|
|
2545
|
+
setVisible(e.value);
|
|
2546
|
+
}
|
|
2951
2547
|
useEffect7(() => {
|
|
2952
|
-
if (
|
|
2953
|
-
|
|
2548
|
+
if (!editor) {
|
|
2549
|
+
return;
|
|
2954
2550
|
}
|
|
2955
|
-
}, [
|
|
2956
|
-
return /* @__PURE__ */
|
|
2957
|
-
|
|
2551
|
+
}, [editor, visible]);
|
|
2552
|
+
return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React28.createElement(
|
|
2553
|
+
Popover4,
|
|
2958
2554
|
{
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
onChange: (e) => onChange?.(e.value)
|
|
2555
|
+
visible,
|
|
2556
|
+
trigger: "custom",
|
|
2557
|
+
position: "topLeft",
|
|
2558
|
+
rePosKey: posKey,
|
|
2559
|
+
content: /* @__PURE__ */ React28.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React28.createElement(
|
|
2560
|
+
InputsPicker,
|
|
2561
|
+
{
|
|
2562
|
+
inputsValues,
|
|
2563
|
+
onSelect: (v) => {
|
|
2564
|
+
insert(v);
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
))
|
|
2973
2568
|
},
|
|
2974
|
-
|
|
2975
|
-
|
|
2569
|
+
/* @__PURE__ */ React28.createElement(
|
|
2570
|
+
PositionMirror2,
|
|
2571
|
+
{
|
|
2572
|
+
position,
|
|
2573
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2574
|
+
}
|
|
2575
|
+
)
|
|
2976
2576
|
));
|
|
2977
2577
|
}
|
|
2978
2578
|
|
|
2579
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2580
|
+
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2581
|
+
return /* @__PURE__ */ React29.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React29.createElement(InputsTree, { inputsValues }));
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2979
2584
|
// src/components/json-editor-with-variables/index.tsx
|
|
2980
|
-
import
|
|
2585
|
+
import React32 from "react";
|
|
2981
2586
|
import { transformerCreator } from "@coze-editor/editor/preset-code";
|
|
2982
2587
|
|
|
2983
2588
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2984
|
-
import
|
|
2589
|
+
import React30, { useEffect as useEffect8, useState as useState9 } from "react";
|
|
2985
2590
|
import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
|
|
2986
2591
|
import {
|
|
2987
2592
|
Mention as Mention3,
|
|
@@ -3015,14 +2620,14 @@ function VariableTree2() {
|
|
|
3015
2620
|
}
|
|
3016
2621
|
}, [editor, visible]);
|
|
3017
2622
|
const treeData = useVariableTree({});
|
|
3018
|
-
return /* @__PURE__ */
|
|
2623
|
+
return /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React30.createElement(
|
|
3019
2624
|
Popover5,
|
|
3020
2625
|
{
|
|
3021
2626
|
visible,
|
|
3022
2627
|
trigger: "custom",
|
|
3023
2628
|
position: "topLeft",
|
|
3024
2629
|
rePosKey: posKey,
|
|
3025
|
-
content: /* @__PURE__ */
|
|
2630
|
+
content: /* @__PURE__ */ React30.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React30.createElement(
|
|
3026
2631
|
Tree3,
|
|
3027
2632
|
{
|
|
3028
2633
|
treeData,
|
|
@@ -3032,7 +2637,7 @@ function VariableTree2() {
|
|
|
3032
2637
|
}
|
|
3033
2638
|
))
|
|
3034
2639
|
},
|
|
3035
|
-
/* @__PURE__ */
|
|
2640
|
+
/* @__PURE__ */ React30.createElement(
|
|
3036
2641
|
PositionMirror3,
|
|
3037
2642
|
{
|
|
3038
2643
|
position,
|
|
@@ -3043,7 +2648,7 @@ function VariableTree2() {
|
|
|
3043
2648
|
}
|
|
3044
2649
|
|
|
3045
2650
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
3046
|
-
import
|
|
2651
|
+
import React31, { useLayoutEffect as useLayoutEffect5 } from "react";
|
|
3047
2652
|
import { createRoot } from "react-dom/client";
|
|
3048
2653
|
import { isEqual as isEqual2, last as last3 } from "lodash";
|
|
3049
2654
|
import {
|
|
@@ -3063,9 +2668,9 @@ import {
|
|
|
3063
2668
|
} from "@codemirror/view";
|
|
3064
2669
|
|
|
3065
2670
|
// src/components/json-editor-with-variables/styles.tsx
|
|
3066
|
-
import
|
|
2671
|
+
import styled9 from "styled-components";
|
|
3067
2672
|
import { Tag as Tag3 } from "@douyinfe/semi-ui";
|
|
3068
|
-
var UIRootTitle3 =
|
|
2673
|
+
var UIRootTitle3 = styled9.div`
|
|
3069
2674
|
margin-right: 4px;
|
|
3070
2675
|
min-width: 20px;
|
|
3071
2676
|
overflow: hidden;
|
|
@@ -3073,12 +2678,12 @@ var UIRootTitle3 = styled8.div`
|
|
|
3073
2678
|
white-space: nowrap;
|
|
3074
2679
|
color: var(--semi-color-text-2);
|
|
3075
2680
|
`;
|
|
3076
|
-
var UIVarName3 =
|
|
2681
|
+
var UIVarName3 = styled9.div`
|
|
3077
2682
|
overflow: hidden;
|
|
3078
2683
|
text-overflow: ellipsis;
|
|
3079
2684
|
white-space: nowrap;
|
|
3080
2685
|
`;
|
|
3081
|
-
var UITag3 =
|
|
2686
|
+
var UITag3 = styled9(Tag3)`
|
|
3082
2687
|
display: inline-flex;
|
|
3083
2688
|
align-items: center;
|
|
3084
2689
|
justify-content: flex-start;
|
|
@@ -3092,7 +2697,7 @@ var UITag3 = styled8(Tag3)`
|
|
|
3092
2697
|
margin: 0 5px;
|
|
3093
2698
|
}
|
|
3094
2699
|
`;
|
|
3095
|
-
var UIPopoverContent3 =
|
|
2700
|
+
var UIPopoverContent3 = styled9.div`
|
|
3096
2701
|
padding: 10px;
|
|
3097
2702
|
display: inline-flex;
|
|
3098
2703
|
align-items: center;
|
|
@@ -3106,7 +2711,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
3106
2711
|
this.toDispose = new DisposableCollection2();
|
|
3107
2712
|
this.renderIcon = (icon) => {
|
|
3108
2713
|
if (typeof icon === "string") {
|
|
3109
|
-
return /* @__PURE__ */
|
|
2714
|
+
return /* @__PURE__ */ React31.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
3110
2715
|
}
|
|
3111
2716
|
return icon;
|
|
3112
2717
|
};
|
|
@@ -3116,20 +2721,20 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
3116
2721
|
renderVariable(v) {
|
|
3117
2722
|
if (!v) {
|
|
3118
2723
|
this.root.render(
|
|
3119
|
-
/* @__PURE__ */
|
|
2724
|
+
/* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React31.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
|
|
3120
2725
|
);
|
|
3121
2726
|
return;
|
|
3122
2727
|
}
|
|
3123
2728
|
const rootField = last3(v.parentFields);
|
|
3124
|
-
const rootTitle = /* @__PURE__ */
|
|
2729
|
+
const rootTitle = /* @__PURE__ */ React31.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
3125
2730
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
3126
2731
|
this.root.render(
|
|
3127
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ React31.createElement(
|
|
3128
2733
|
Popover6,
|
|
3129
2734
|
{
|
|
3130
|
-
content: /* @__PURE__ */
|
|
2735
|
+
content: /* @__PURE__ */ React31.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
3131
2736
|
},
|
|
3132
|
-
/* @__PURE__ */
|
|
2737
|
+
/* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.key))
|
|
3133
2738
|
)
|
|
3134
2739
|
);
|
|
3135
2740
|
}
|
|
@@ -3231,7 +2836,7 @@ var transformer = transformerCreator((text) => {
|
|
|
3231
2836
|
return text;
|
|
3232
2837
|
});
|
|
3233
2838
|
function JsonEditorWithVariables(props) {
|
|
3234
|
-
return /* @__PURE__ */
|
|
2839
|
+
return /* @__PURE__ */ React32.createElement(
|
|
3235
2840
|
CodeEditor,
|
|
3236
2841
|
{
|
|
3237
2842
|
languageId: "json",
|
|
@@ -3242,40 +2847,40 @@ function JsonEditorWithVariables(props) {
|
|
|
3242
2847
|
...props.options || {}
|
|
3243
2848
|
}
|
|
3244
2849
|
},
|
|
3245
|
-
/* @__PURE__ */
|
|
3246
|
-
/* @__PURE__ */
|
|
2850
|
+
/* @__PURE__ */ React32.createElement(VariableTree2, null),
|
|
2851
|
+
/* @__PURE__ */ React32.createElement(VariableTagInject2, null)
|
|
3247
2852
|
);
|
|
3248
2853
|
}
|
|
3249
2854
|
|
|
3250
2855
|
// src/components/inputs-values/index.tsx
|
|
3251
|
-
import
|
|
2856
|
+
import React34 from "react";
|
|
3252
2857
|
import { Button as Button4, IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3253
2858
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
3254
2859
|
|
|
3255
2860
|
// src/components/inputs-values/styles.tsx
|
|
3256
|
-
import
|
|
3257
|
-
var UIRows2 =
|
|
2861
|
+
import styled10 from "styled-components";
|
|
2862
|
+
var UIRows2 = styled10.div`
|
|
3258
2863
|
display: flex;
|
|
3259
2864
|
flex-direction: column;
|
|
3260
2865
|
gap: 10px;
|
|
3261
2866
|
margin-bottom: 10px;
|
|
3262
2867
|
`;
|
|
3263
|
-
var UIRow3 =
|
|
2868
|
+
var UIRow3 = styled10.div`
|
|
3264
2869
|
display: flex;
|
|
3265
2870
|
align-items: center;
|
|
3266
2871
|
gap: 5px;
|
|
3267
2872
|
`;
|
|
3268
2873
|
|
|
3269
2874
|
// src/components/inputs-values/components/blur-input.tsx
|
|
3270
|
-
import
|
|
3271
|
-
import
|
|
2875
|
+
import React33, { useEffect as useEffect9, useState as useState10 } from "react";
|
|
2876
|
+
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
3272
2877
|
function BlurInput2(props) {
|
|
3273
2878
|
const [value, setValue] = useState10("");
|
|
3274
2879
|
useEffect9(() => {
|
|
3275
2880
|
setValue(props.value);
|
|
3276
2881
|
}, [props.value]);
|
|
3277
|
-
return /* @__PURE__ */
|
|
3278
|
-
|
|
2882
|
+
return /* @__PURE__ */ React33.createElement(
|
|
2883
|
+
Input6,
|
|
3279
2884
|
{
|
|
3280
2885
|
...props,
|
|
3281
2886
|
value,
|
|
@@ -3302,7 +2907,7 @@ function InputsValues({
|
|
|
3302
2907
|
onChange,
|
|
3303
2908
|
sortIndexKey: "extra.index"
|
|
3304
2909
|
});
|
|
3305
|
-
return /* @__PURE__ */
|
|
2910
|
+
return /* @__PURE__ */ React34.createElement("div", null, /* @__PURE__ */ React34.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React34.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React34.createElement(
|
|
3306
2911
|
BlurInput2,
|
|
3307
2912
|
{
|
|
3308
2913
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -3312,7 +2917,7 @@ function InputsValues({
|
|
|
3312
2917
|
onChange: (v) => updateKey(item.id, v),
|
|
3313
2918
|
placeholder: "Input Key"
|
|
3314
2919
|
}
|
|
3315
|
-
), /* @__PURE__ */
|
|
2920
|
+
), /* @__PURE__ */ React34.createElement(
|
|
3316
2921
|
DynamicValueInput,
|
|
3317
2922
|
{
|
|
3318
2923
|
style: { flexGrow: 1 },
|
|
@@ -3326,46 +2931,290 @@ function InputsValues({
|
|
|
3326
2931
|
strategies: [...constantProps?.strategies || []]
|
|
3327
2932
|
}
|
|
3328
2933
|
}
|
|
3329
|
-
), /* @__PURE__ */
|
|
2934
|
+
), /* @__PURE__ */ React34.createElement(
|
|
3330
2935
|
IconButton5,
|
|
3331
2936
|
{
|
|
3332
2937
|
disabled: readonly,
|
|
3333
2938
|
theme: "borderless",
|
|
3334
|
-
icon: /* @__PURE__ */
|
|
2939
|
+
icon: /* @__PURE__ */ React34.createElement(IconDelete2, { size: "small" }),
|
|
3335
2940
|
size: "small",
|
|
3336
2941
|
onClick: () => remove(item.id)
|
|
3337
2942
|
}
|
|
3338
|
-
)))), /* @__PURE__ */
|
|
2943
|
+
)))), /* @__PURE__ */ React34.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React34.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
// src/components/display-schema-tree/index.tsx
|
|
2947
|
+
import React35 from "react";
|
|
2948
|
+
|
|
2949
|
+
// src/components/display-schema-tree/styles.tsx
|
|
2950
|
+
import styled11, { css as css4 } from "styled-components";
|
|
2951
|
+
var TreeRow = styled11.div`
|
|
2952
|
+
display: flex;
|
|
2953
|
+
align-items: center;
|
|
2954
|
+
|
|
2955
|
+
.tree-icon {
|
|
2956
|
+
margin-right: 8px;
|
|
2957
|
+
width: 14px;
|
|
2958
|
+
height: 14px;
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2961
|
+
height: 27px;
|
|
2962
|
+
white-space: nowrap;
|
|
2963
|
+
`;
|
|
2964
|
+
var HorizontalLine = styled11.div`
|
|
2965
|
+
position: relative;
|
|
2966
|
+
|
|
2967
|
+
&::before,
|
|
2968
|
+
&::after {
|
|
2969
|
+
content: '';
|
|
2970
|
+
position: absolute;
|
|
2971
|
+
background-color: var(--semi-color-text-3);
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
&::after {
|
|
2975
|
+
top: 0px;
|
|
2976
|
+
right: 6px;
|
|
2977
|
+
width: 15px;
|
|
2978
|
+
height: 1px;
|
|
2979
|
+
}
|
|
2980
|
+
`;
|
|
2981
|
+
var TreeTitle = styled11.div`
|
|
2982
|
+
// overflow: hidden;
|
|
2983
|
+
// text-overflow: ellipsis;
|
|
2984
|
+
`;
|
|
2985
|
+
var TreeLevel = styled11.div`
|
|
2986
|
+
padding-left: 30px;
|
|
2987
|
+
position: relative;
|
|
2988
|
+
|
|
2989
|
+
/* &::before {
|
|
2990
|
+
content: '';
|
|
2991
|
+
position: absolute;
|
|
2992
|
+
background-color: var(--semi-color-text-3);
|
|
2993
|
+
top: 0px;
|
|
2994
|
+
bottom: 0px;
|
|
2995
|
+
left: -22px;
|
|
2996
|
+
width: 1px;
|
|
2997
|
+
} */
|
|
2998
|
+
`;
|
|
2999
|
+
var TreeItem = styled11.div`
|
|
3000
|
+
position: relative;
|
|
3001
|
+
|
|
3002
|
+
&::before {
|
|
3003
|
+
content: '';
|
|
3004
|
+
position: absolute;
|
|
3005
|
+
background-color: var(--semi-color-text-3);
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
&:not(:last-child)::before {
|
|
3009
|
+
width: 1px;
|
|
3010
|
+
top: 0;
|
|
3011
|
+
bottom: 0;
|
|
3012
|
+
left: -22px;
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
&:last-child::before {
|
|
3016
|
+
width: 1px;
|
|
3017
|
+
top: 0;
|
|
3018
|
+
height: 14px;
|
|
3019
|
+
left: -22px;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
${(props) => props.depth === 0 && css4`
|
|
3023
|
+
&::before {
|
|
3024
|
+
width: 0px !important;
|
|
3025
|
+
}
|
|
3026
|
+
`}
|
|
3027
|
+
`;
|
|
3028
|
+
|
|
3029
|
+
// src/components/display-schema-tree/index.tsx
|
|
3030
|
+
function DisplaySchemaTree(props) {
|
|
3031
|
+
return /* @__PURE__ */ React35.createElement(SchemaTree, { ...props });
|
|
3032
|
+
}
|
|
3033
|
+
function SchemaTree(props) {
|
|
3034
|
+
const {
|
|
3035
|
+
value: schema = {},
|
|
3036
|
+
drilldown = true,
|
|
3037
|
+
depth = 0,
|
|
3038
|
+
showIcon = true,
|
|
3039
|
+
parentKey = ""
|
|
3040
|
+
} = props || {};
|
|
3041
|
+
const typeManager = useTypeManager();
|
|
3042
|
+
const config = typeManager.getTypeBySchema(schema);
|
|
3043
|
+
const title = typeManager.getComplexText(schema);
|
|
3044
|
+
const icon = typeManager?.getDisplayIcon(schema);
|
|
3045
|
+
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3046
|
+
const childEntries = Object.entries(properties || {});
|
|
3047
|
+
return /* @__PURE__ */ React35.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React35.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React35.createElement(HorizontalLine, null), showIcon && icon && React35.cloneElement(icon, {
|
|
3048
|
+
className: "tree-icon"
|
|
3049
|
+
}), /* @__PURE__ */ React35.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React35.createElement(React35.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React35.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React35.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// src/components/display-outputs/index.tsx
|
|
3053
|
+
import React37, { useEffect as useEffect10 } from "react";
|
|
3054
|
+
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
3055
|
+
import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
|
|
3056
|
+
|
|
3057
|
+
// src/components/display-schema-tag/index.tsx
|
|
3058
|
+
import React36 from "react";
|
|
3059
|
+
import { Popover as Popover7 } from "@douyinfe/semi-ui";
|
|
3060
|
+
|
|
3061
|
+
// src/components/display-schema-tag/styles.ts
|
|
3062
|
+
import styled12 from "styled-components";
|
|
3063
|
+
import { Tag as Tag4 } from "@douyinfe/semi-ui";
|
|
3064
|
+
var PopoverContent = styled12.div`
|
|
3065
|
+
padding: 10px;
|
|
3066
|
+
`;
|
|
3067
|
+
var StyledTag = styled12(Tag4)`
|
|
3068
|
+
padding: 4px;
|
|
3069
|
+
|
|
3070
|
+
.tag-icon {
|
|
3071
|
+
width: 12px;
|
|
3072
|
+
height: 12px;
|
|
3073
|
+
}
|
|
3074
|
+
`;
|
|
3075
|
+
var TitleSpan = styled12.span`
|
|
3076
|
+
display: inline-block;
|
|
3077
|
+
margin-left: 4px;
|
|
3078
|
+
margin-top: -1px;
|
|
3079
|
+
overflow: hidden;
|
|
3080
|
+
text-overflow: ellipsis;
|
|
3081
|
+
`;
|
|
3082
|
+
|
|
3083
|
+
// src/components/display-schema-tag/index.tsx
|
|
3084
|
+
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3085
|
+
const typeManager = useTypeManager();
|
|
3086
|
+
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3087
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3088
|
+
Popover7,
|
|
3089
|
+
{
|
|
3090
|
+
content: /* @__PURE__ */ React36.createElement(PopoverContent, null, /* @__PURE__ */ React36.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3091
|
+
},
|
|
3092
|
+
/* @__PURE__ */ React36.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React36.cloneElement(icon, {
|
|
3093
|
+
className: "tag-icon"
|
|
3094
|
+
}), title && /* @__PURE__ */ React36.createElement(TitleSpan, null, title))
|
|
3095
|
+
);
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
// src/components/display-outputs/styles.ts
|
|
3099
|
+
import styled13 from "styled-components";
|
|
3100
|
+
var DisplayOutputsWrapper = styled13.div`
|
|
3101
|
+
display: flex;
|
|
3102
|
+
gap: 5px;
|
|
3103
|
+
flex-wrap: wrap;
|
|
3104
|
+
`;
|
|
3105
|
+
|
|
3106
|
+
// src/components/display-outputs/index.tsx
|
|
3107
|
+
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3108
|
+
const scope = useCurrentScope3();
|
|
3109
|
+
const refresh = useRefresh();
|
|
3110
|
+
useEffect10(() => {
|
|
3111
|
+
if (!displayFromScope) {
|
|
3112
|
+
return () => null;
|
|
3113
|
+
}
|
|
3114
|
+
const disposable = scope.output.onListOrAnyVarChange(() => {
|
|
3115
|
+
refresh();
|
|
3116
|
+
});
|
|
3117
|
+
return () => {
|
|
3118
|
+
disposable.dispose();
|
|
3119
|
+
};
|
|
3120
|
+
}, [displayFromScope]);
|
|
3121
|
+
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3122
|
+
acm = {
|
|
3123
|
+
...acm,
|
|
3124
|
+
...JsonSchemaUtils5.astToSchema(curr.type)?.properties || {}
|
|
3125
|
+
};
|
|
3126
|
+
return acm;
|
|
3127
|
+
}, {}) : value?.properties || {};
|
|
3128
|
+
const childEntries = Object.entries(properties || {});
|
|
3129
|
+
return /* @__PURE__ */ React37.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React37.createElement(DisplaySchemaTag, { key, title: key, value: schema, showIconInTree })));
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
// src/components/display-flow-value/index.tsx
|
|
3133
|
+
import React38, { useMemo as useMemo11 } from "react";
|
|
3134
|
+
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3135
|
+
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3136
|
+
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3137
|
+
const available = useScopeAvailable4();
|
|
3138
|
+
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3139
|
+
const schema = useMemo11(() => {
|
|
3140
|
+
if (value?.type === "ref") {
|
|
3141
|
+
return JsonSchemaUtils6.astToSchema(variable?.type);
|
|
3142
|
+
}
|
|
3143
|
+
if (value?.type === "template") {
|
|
3144
|
+
return { type: "string" };
|
|
3145
|
+
}
|
|
3146
|
+
if (value?.type === "constant") {
|
|
3147
|
+
if (value?.schema) {
|
|
3148
|
+
return value?.schema;
|
|
3149
|
+
}
|
|
3150
|
+
if (typeof value?.content === "string") {
|
|
3151
|
+
return { type: "string" };
|
|
3152
|
+
}
|
|
3153
|
+
if (typeof value?.content === "number") {
|
|
3154
|
+
return { type: "number" };
|
|
3155
|
+
}
|
|
3156
|
+
if (typeof value?.content === "boolean") {
|
|
3157
|
+
return { type: "boolean" };
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
return { type: "unknown" };
|
|
3161
|
+
}, [value, variable?.hash]);
|
|
3162
|
+
return /* @__PURE__ */ React38.createElement(
|
|
3163
|
+
DisplaySchemaTag,
|
|
3164
|
+
{
|
|
3165
|
+
title,
|
|
3166
|
+
value: schema,
|
|
3167
|
+
showIconInTree,
|
|
3168
|
+
warning: value?.type === "ref" && !variable
|
|
3169
|
+
}
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
// src/components/display-inputs-values/index.tsx
|
|
3174
|
+
import React39 from "react";
|
|
3175
|
+
|
|
3176
|
+
// src/components/display-inputs-values/styles.ts
|
|
3177
|
+
import styled14 from "styled-components";
|
|
3178
|
+
var DisplayInputsWrapper = styled14.div`
|
|
3179
|
+
display: flex;
|
|
3180
|
+
gap: 5px;
|
|
3181
|
+
flex-wrap: wrap;
|
|
3182
|
+
`;
|
|
3183
|
+
|
|
3184
|
+
// src/components/display-inputs-values/index.tsx
|
|
3185
|
+
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3186
|
+
const childEntries = Object.entries(value || {});
|
|
3187
|
+
return /* @__PURE__ */ React39.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React39.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3339
3188
|
}
|
|
3340
3189
|
|
|
3341
3190
|
// src/effects/provide-batch-input/index.ts
|
|
3342
3191
|
import {
|
|
3343
|
-
ASTFactory
|
|
3192
|
+
ASTFactory,
|
|
3344
3193
|
createEffectFromVariableProvider,
|
|
3345
3194
|
getNodeForm
|
|
3346
3195
|
} from "@flowgram.ai/editor";
|
|
3347
3196
|
var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
3348
3197
|
private: true,
|
|
3349
3198
|
parse: (value, ctx) => [
|
|
3350
|
-
|
|
3199
|
+
ASTFactory.createVariableDeclaration({
|
|
3351
3200
|
key: `${ctx.node.id}_locals`,
|
|
3352
3201
|
meta: {
|
|
3353
3202
|
title: getNodeForm(ctx.node)?.getValueIn("title"),
|
|
3354
3203
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3355
3204
|
},
|
|
3356
|
-
type:
|
|
3205
|
+
type: ASTFactory.createObject({
|
|
3357
3206
|
properties: [
|
|
3358
|
-
|
|
3207
|
+
ASTFactory.createProperty({
|
|
3359
3208
|
key: "item",
|
|
3360
|
-
initializer:
|
|
3361
|
-
enumerateFor:
|
|
3209
|
+
initializer: ASTFactory.createEnumerateExpression({
|
|
3210
|
+
enumerateFor: ASTFactory.createKeyPathExpression({
|
|
3362
3211
|
keyPath: value.content || []
|
|
3363
3212
|
})
|
|
3364
3213
|
})
|
|
3365
3214
|
}),
|
|
3366
|
-
|
|
3215
|
+
ASTFactory.createProperty({
|
|
3367
3216
|
key: "index",
|
|
3368
|
-
type:
|
|
3217
|
+
type: ASTFactory.createNumber()
|
|
3369
3218
|
})
|
|
3370
3219
|
]
|
|
3371
3220
|
})
|
|
@@ -3374,7 +3223,7 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3374
3223
|
});
|
|
3375
3224
|
|
|
3376
3225
|
// src/effects/auto-rename-ref/index.ts
|
|
3377
|
-
import { isArray, isObject as
|
|
3226
|
+
import { isArray, isObject as isObject2, uniq } from "lodash";
|
|
3378
3227
|
import {
|
|
3379
3228
|
DataEvent,
|
|
3380
3229
|
VariableFieldKeyRenameService
|
|
@@ -3444,7 +3293,7 @@ function isTemplate(value) {
|
|
|
3444
3293
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3445
3294
|
}
|
|
3446
3295
|
function traverseRef(name, value, cb) {
|
|
3447
|
-
if (
|
|
3296
|
+
if (isObject2(value)) {
|
|
3448
3297
|
if (isRef(value)) {
|
|
3449
3298
|
cb(name, value);
|
|
3450
3299
|
return;
|
|
@@ -3468,20 +3317,21 @@ function traverseRef(name, value, cb) {
|
|
|
3468
3317
|
}
|
|
3469
3318
|
|
|
3470
3319
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3320
|
+
import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
|
|
3471
3321
|
import {
|
|
3472
|
-
ASTFactory as
|
|
3322
|
+
ASTFactory as ASTFactory2,
|
|
3473
3323
|
createEffectFromVariableProvider as createEffectFromVariableProvider2,
|
|
3474
3324
|
getNodeForm as getNodeForm2
|
|
3475
3325
|
} from "@flowgram.ai/editor";
|
|
3476
3326
|
var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
|
|
3477
3327
|
parse: (value, ctx) => [
|
|
3478
|
-
|
|
3328
|
+
ASTFactory2.createVariableDeclaration({
|
|
3479
3329
|
key: `${ctx.node.id}`,
|
|
3480
3330
|
meta: {
|
|
3481
3331
|
title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3482
3332
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3483
3333
|
},
|
|
3484
|
-
type:
|
|
3334
|
+
type: JsonSchemaUtils7.schemaToAST(value)
|
|
3485
3335
|
})
|
|
3486
3336
|
]
|
|
3487
3337
|
});
|
|
@@ -3498,6 +3348,7 @@ var syncVariableTitle = [
|
|
|
3498
3348
|
context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3499
3349
|
_scope.output.variables.forEach((_var) => {
|
|
3500
3350
|
_var.updateMeta({
|
|
3351
|
+
..._var.meta || {},
|
|
3501
3352
|
title: value || context.node.id,
|
|
3502
3353
|
icon: context.node.getNodeRegistry().info?.icon
|
|
3503
3354
|
});
|
|
@@ -3507,9 +3358,71 @@ var syncVariableTitle = [
|
|
|
3507
3358
|
}
|
|
3508
3359
|
];
|
|
3509
3360
|
|
|
3361
|
+
// src/shared/format-legacy-refs/index.ts
|
|
3362
|
+
import { isObject as isObject3 } from "lodash";
|
|
3363
|
+
function formatLegacyRefOnSubmit(value) {
|
|
3364
|
+
if (isObject3(value)) {
|
|
3365
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
3366
|
+
return formatLegacyRefToNewRef(value);
|
|
3367
|
+
}
|
|
3368
|
+
return Object.fromEntries(
|
|
3369
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3370
|
+
key,
|
|
3371
|
+
formatLegacyRefOnSubmit(value2)
|
|
3372
|
+
])
|
|
3373
|
+
);
|
|
3374
|
+
}
|
|
3375
|
+
if (Array.isArray(value)) {
|
|
3376
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
3377
|
+
}
|
|
3378
|
+
return value;
|
|
3379
|
+
}
|
|
3380
|
+
function formatLegacyRefOnInit(value) {
|
|
3381
|
+
if (isObject3(value)) {
|
|
3382
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
3383
|
+
return formatNewRefToLegacyRef(value);
|
|
3384
|
+
}
|
|
3385
|
+
return Object.fromEntries(
|
|
3386
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3387
|
+
key,
|
|
3388
|
+
formatLegacyRefOnInit(value2)
|
|
3389
|
+
])
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
if (Array.isArray(value)) {
|
|
3393
|
+
return value.map(formatLegacyRefOnInit);
|
|
3394
|
+
}
|
|
3395
|
+
return value;
|
|
3396
|
+
}
|
|
3397
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
3398
|
+
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3399
|
+
}
|
|
3400
|
+
function isNewFlowRefValueSchema(value) {
|
|
3401
|
+
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3402
|
+
}
|
|
3403
|
+
function formatLegacyRefToNewRef(value) {
|
|
3404
|
+
const keyPath = value.content.split(".");
|
|
3405
|
+
if (keyPath[1] === "outputs") {
|
|
3406
|
+
return {
|
|
3407
|
+
type: "ref",
|
|
3408
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3409
|
+
};
|
|
3410
|
+
}
|
|
3411
|
+
return {
|
|
3412
|
+
type: "ref",
|
|
3413
|
+
content: keyPath
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
function formatNewRefToLegacyRef(value) {
|
|
3417
|
+
return {
|
|
3418
|
+
type: "ref",
|
|
3419
|
+
content: value.content.join(".")
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3510
3423
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3511
3424
|
import {
|
|
3512
|
-
ASTFactory as
|
|
3425
|
+
ASTFactory as ASTFactory3,
|
|
3513
3426
|
createEffectFromVariableProvider as createEffectFromVariableProvider3,
|
|
3514
3427
|
defineFormPluginCreator,
|
|
3515
3428
|
getNodeForm as getNodeForm3,
|
|
@@ -3520,18 +3433,18 @@ import {
|
|
|
3520
3433
|
} from "@flowgram.ai/editor";
|
|
3521
3434
|
var provideBatchOutputsEffect = createEffectFromVariableProvider3({
|
|
3522
3435
|
parse: (value, ctx) => [
|
|
3523
|
-
|
|
3436
|
+
ASTFactory3.createVariableDeclaration({
|
|
3524
3437
|
key: `${ctx.node.id}`,
|
|
3525
3438
|
meta: {
|
|
3526
3439
|
title: getNodeForm3(ctx.node)?.getValueIn("title"),
|
|
3527
3440
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3528
3441
|
},
|
|
3529
|
-
type:
|
|
3442
|
+
type: ASTFactory3.createObject({
|
|
3530
3443
|
properties: Object.entries(value).map(
|
|
3531
|
-
([_key, value2]) =>
|
|
3444
|
+
([_key, value2]) => ASTFactory3.createProperty({
|
|
3532
3445
|
key: _key,
|
|
3533
|
-
initializer:
|
|
3534
|
-
wrapFor:
|
|
3446
|
+
initializer: ASTFactory3.createWrapArrayExpression({
|
|
3447
|
+
wrapFor: ASTFactory3.createKeyPathExpression({
|
|
3535
3448
|
keyPath: value2?.content || []
|
|
3536
3449
|
})
|
|
3537
3450
|
})
|
|
@@ -3583,7 +3496,8 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3583
3496
|
});
|
|
3584
3497
|
|
|
3585
3498
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3586
|
-
import { get as
|
|
3499
|
+
import { get as get2, set as set2 } from "lodash";
|
|
3500
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3587
3501
|
import {
|
|
3588
3502
|
defineFormPluginCreator as defineFormPluginCreator2,
|
|
3589
3503
|
getNodePrivateScope as getNodePrivateScope2,
|
|
@@ -3599,7 +3513,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3599
3513
|
formData,
|
|
3600
3514
|
targetKey,
|
|
3601
3515
|
infer(
|
|
3602
|
-
|
|
3516
|
+
get2(formData, sourceKey),
|
|
3603
3517
|
scope === "private" ? getNodePrivateScope2(ctx.node) : getNodeScope2(ctx.node)
|
|
3604
3518
|
)
|
|
3605
3519
|
);
|
|
@@ -3640,7 +3554,7 @@ var infer = (values, scope) => {
|
|
|
3640
3554
|
}
|
|
3641
3555
|
if (isRef2(values)) {
|
|
3642
3556
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3643
|
-
const schema = variable?.type ?
|
|
3557
|
+
const schema = variable?.type ? JsonSchemaUtils8.astToSchema(variable?.type) : void 0;
|
|
3644
3558
|
return schema;
|
|
3645
3559
|
}
|
|
3646
3560
|
if (isTemplate2(values)) {
|
|
@@ -3661,31 +3575,37 @@ var infer = (values, scope) => {
|
|
|
3661
3575
|
}
|
|
3662
3576
|
};
|
|
3663
3577
|
export {
|
|
3664
|
-
ArrayIcons,
|
|
3665
3578
|
BatchOutputs,
|
|
3666
3579
|
BatchVariableSelector,
|
|
3667
3580
|
CodeEditor,
|
|
3581
|
+
CodeEditorMini,
|
|
3668
3582
|
ConditionRow,
|
|
3669
3583
|
ConstantInput,
|
|
3584
|
+
DisplayFlowValue,
|
|
3585
|
+
DisplayInputsValues,
|
|
3586
|
+
DisplayOutputs,
|
|
3587
|
+
DisplaySchemaTag,
|
|
3588
|
+
DisplaySchemaTree,
|
|
3670
3589
|
DynamicValueInput,
|
|
3671
3590
|
InputsValues,
|
|
3672
3591
|
JsonEditorWithVariables,
|
|
3673
3592
|
JsonSchemaEditor,
|
|
3593
|
+
JsonSchemaTypePresetProvider,
|
|
3674
3594
|
JsonSchemaUtils,
|
|
3675
3595
|
PromptEditor,
|
|
3676
3596
|
PromptEditorWithInputs,
|
|
3677
3597
|
PromptEditorWithVariables,
|
|
3678
3598
|
TypeSelector,
|
|
3679
3599
|
VariableSelector,
|
|
3680
|
-
VariableTypeIcons,
|
|
3681
3600
|
autoRenameRefEffect,
|
|
3682
3601
|
createBatchOutputsFormPlugin,
|
|
3602
|
+
createDisableDeclarationPlugin,
|
|
3683
3603
|
createInferInputsPlugin,
|
|
3604
|
+
createTypePresetPlugin,
|
|
3684
3605
|
formatLegacyRefOnInit,
|
|
3685
3606
|
formatLegacyRefOnSubmit,
|
|
3686
3607
|
formatLegacyRefToNewRef,
|
|
3687
3608
|
formatNewRefToLegacyRef,
|
|
3688
|
-
getSchemaIcon,
|
|
3689
3609
|
getTypeSelectValue,
|
|
3690
3610
|
isLegacyFlowRefValueSchema,
|
|
3691
3611
|
isNewFlowRefValueSchema,
|
|
@@ -3694,6 +3614,7 @@ export {
|
|
|
3694
3614
|
provideBatchOutputsEffect,
|
|
3695
3615
|
provideJsonSchemaOutputs,
|
|
3696
3616
|
syncVariableTitle,
|
|
3617
|
+
useTypeManager,
|
|
3697
3618
|
useVariableTree
|
|
3698
3619
|
};
|
|
3699
3620
|
//# sourceMappingURL=index.js.map
|