@huanban/rulego-editor-core 1.4.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +20 -8
  2. package/dist/ai/ai-chat-options.d.ts +12 -0
  3. package/dist/api/AIAssistantAPI.d.ts +29 -0
  4. package/dist/api/AIManager.d.ts +7 -1
  5. package/dist/api/ApiProvider.d.ts +17 -4
  6. package/dist/api/DebugSocketClient.d.ts +2 -0
  7. package/dist/api/GlobalConfigAPI.d.ts +35 -0
  8. package/dist/api/IoTPointTemplateAPI.d.ts +32 -0
  9. package/dist/api/MarketplaceAPI.d.ts +39 -0
  10. package/dist/api/RuleChainAPI.d.ts +23 -4
  11. package/dist/api/RuleChainVersionsAPI.d.ts +28 -0
  12. package/dist/api/SkillsAPI.d.ts +31 -0
  13. package/dist/api/UserAPI.d.ts +39 -0
  14. package/dist/api/extended-api-shared.d.ts +25 -0
  15. package/dist/api/index.d.ts +19 -2
  16. package/dist/api/public-api.test-d.d.ts +87 -0
  17. package/dist/api/response-utils.d.ts +1 -0
  18. package/dist/api/types.d.ts +86 -14
  19. package/dist/chunks/editor-core-api-BQiYFuIO.js +1157 -0
  20. package/dist/chunks/editor-core-canvas-nodes-BE9eN51s.js +6921 -0
  21. package/dist/chunks/editor-core-code-editor-DFm5Owtv.js +660 -0
  22. package/dist/chunks/{editor-core-default-components-BjF65lar.js → editor-core-default-components-BsNP8ma1.js} +98 -98
  23. package/dist/chunks/editor-core-dialogs-D9YHvzys.js +12009 -0
  24. package/dist/chunks/{editor-core-locales-i6o28vm2.js → editor-core-locales-CsqTh7Wh.js} +1723 -11
  25. package/dist/chunks/{editor-core-node-patches-BJTT3TuX.js → editor-core-node-patches-Dbi8XYxu.js} +633 -184
  26. package/dist/chunks/{editor-core-node-views-BOaPVdmN.js → editor-core-node-views-C8FQYC3E.js} +39 -29
  27. package/dist/chunks/editor-core-property-drawers-Bqmp9B_J.js +9562 -0
  28. package/dist/chunks/editor-core-settings-DcGCJSc7.js +4161 -0
  29. package/dist/chunks/editor-core-standalone-C7pzm8ZB.js +10013 -0
  30. package/dist/chunks/{editor-core-styles-DFhXz0vB.js → editor-core-styles-CwjFPfAo.js} +967 -510
  31. package/dist/chunks/vendor-highlight-acC2fLd8.js +5868 -0
  32. package/dist/chunks/vendor-logicflow-core-runtime-DpsWXOGl.js +4 -0
  33. package/dist/chunks/vendor-logicflow-shared-C_kIdBKO.js +4 -0
  34. package/dist/core/ActionRegistry.d.ts +4 -2
  35. package/dist/core/DataAdapter.d.ts +17 -1
  36. package/dist/core/DialogProvider.d.ts +33 -0
  37. package/dist/core/EditorCore.d.ts +16 -3
  38. package/dist/core/FieldCapabilityRegistry.d.ts +4 -1
  39. package/dist/core/FieldChangeRegistry.d.ts +3 -1
  40. package/dist/core/I18nManager.d.ts +1 -1
  41. package/dist/core/IdentityProvider.d.ts +32 -0
  42. package/dist/core/OptionSourceRegistry.d.ts +4 -1
  43. package/dist/core/PropertyControlRegistry.d.ts +29 -0
  44. package/dist/core/ThemeManager.d.ts +7 -0
  45. package/dist/core/anchored-popover.d.ts +16 -0
  46. package/dist/core/assistant-dsl.d.ts +18 -0
  47. package/dist/core/business-log-config.d.ts +18 -0
  48. package/dist/core/clean-snapshot.d.ts +14 -0
  49. package/dist/core/component-localization.d.ts +17 -0
  50. package/dist/core/component-palette.d.ts +3 -0
  51. package/dist/core/connection-status.d.ts +11 -0
  52. package/dist/core/dialog-styles.d.ts +1 -0
  53. package/dist/core/editor-capabilities.d.ts +82 -1
  54. package/dist/core/editor-edge-anchors.d.ts +16 -0
  55. package/dist/core/endpoint-protocol.d.ts +15 -0
  56. package/dist/core/expression-preview.d.ts +6 -0
  57. package/dist/core/field-protocol.d.ts +19 -4
  58. package/dist/core/global-config.d.ts +47 -0
  59. package/dist/core/global-search.d.ts +31 -0
  60. package/dist/core/group-protocol.d.ts +56 -0
  61. package/dist/core/identity-provider-default.d.ts +32 -0
  62. package/dist/core/index.d.ts +31 -5
  63. package/dist/core/keymap.d.ts +10 -0
  64. package/dist/core/payload-kv.d.ts +7 -0
  65. package/dist/core/rule-chain-versions.d.ts +143 -0
  66. package/dist/core/run-analysis.d.ts +126 -0
  67. package/dist/core/runtime-field-dictionary.d.ts +3 -0
  68. package/dist/core/save-conflict.d.ts +1 -0
  69. package/dist/core/server-status.d.ts +1 -0
  70. package/dist/core/toolbar-icons.d.ts +1 -1
  71. package/dist/core/variable-completion.d.ts +13 -0
  72. package/dist/core/websocket-auth.d.ts +2 -0
  73. package/dist/defaults/analysis-locales.d.ts +241 -0
  74. package/dist/defaults/component-locale-categories.d.ts +14 -0
  75. package/dist/defaults/component-locale-data.d.ts +4 -0
  76. package/dist/defaults/component-locale-en-US.d.ts +10 -0
  77. package/dist/defaults/component-locale-summaries.d.ts +15 -0
  78. package/dist/defaults/component-locale-zh-CN.d.ts +10 -0
  79. package/dist/defaults/editor-shell-locales.d.ts +290 -0
  80. package/dist/defaults/example-chain.d.ts +2 -0
  81. package/dist/defaults/field-interaction-locales.d.ts +19 -0
  82. package/dist/defaults/global-config-locales.d.ts +166 -0
  83. package/dist/defaults/official-component-fallbacks.d.ts +2 -1
  84. package/dist/defaults/point-template-locales.d.ts +64 -0
  85. package/dist/index.cjs +2856 -2086
  86. package/dist/index.d.ts +33 -10
  87. package/dist/index.esm.js +1182 -810
  88. package/dist/index.umd.js +2850 -2080
  89. package/dist/nodes/UnknownNodeModel.d.ts +12 -1
  90. package/dist/standalone/HuanbanRulegoEditor.d.ts +145 -13
  91. package/dist/standalone/auth-fetch.d.ts +1 -0
  92. package/dist/standalone/auth-ui-defaults.d.ts +15 -0
  93. package/dist/standalone/code-editor.d.ts +7 -5
  94. package/dist/standalone/connection-status-binding.d.ts +3 -2
  95. package/dist/standalone/custom-nodes.d.ts +13 -0
  96. package/dist/standalone/drawer-locale.d.ts +12 -0
  97. package/dist/standalone/drawer-unsaved-guard.d.ts +6 -1
  98. package/dist/standalone/dynamic-field-browse.d.ts +25 -0
  99. package/dist/standalone/edge-label-quick-editor.d.ts +2 -1
  100. package/dist/standalone/editor-actions.d.ts +1 -0
  101. package/dist/standalone/editor-canvas-anchors.d.ts +19 -0
  102. package/dist/standalone/editor-canvas-shortcuts.d.ts +1 -0
  103. package/dist/standalone/editor-chain-info.d.ts +1 -0
  104. package/dist/standalone/editor-debug-data.d.ts +18 -0
  105. package/dist/standalone/editor-debug-ws.d.ts +2 -0
  106. package/dist/standalone/editor-delete.d.ts +5 -3
  107. package/dist/standalone/editor-dialog-provider.d.ts +3 -0
  108. package/dist/standalone/editor-dialogs.d.ts +25 -2
  109. package/dist/standalone/editor-global-config.d.ts +44 -0
  110. package/dist/standalone/editor-group-interactions.d.ts +1 -0
  111. package/dist/standalone/editor-host-region-styles.d.ts +1 -0
  112. package/dist/standalone/editor-host-regions.d.ts +53 -0
  113. package/dist/standalone/editor-login.d.ts +15 -0
  114. package/dist/standalone/editor-overlays.d.ts +5 -0
  115. package/dist/standalone/editor-property-drawers.d.ts +3 -1
  116. package/dist/standalone/editor-run-analysis.d.ts +81 -0
  117. package/dist/standalone/editor-run-compare.d.ts +20 -0
  118. package/dist/standalone/editor-run-waterfall.d.ts +11 -0
  119. package/dist/standalone/editor-toast.d.ts +1 -1
  120. package/dist/standalone/editor-toolbar-presentation.d.ts +12 -0
  121. package/dist/standalone/editor-toolbar.d.ts +5 -1
  122. package/dist/standalone/editor-ui-configuration.d.ts +55 -0
  123. package/dist/standalone/editor-ui-settings.d.ts +26 -0
  124. package/dist/standalone/editor-user-menu.d.ts +8 -0
  125. package/dist/standalone/editor-version-history.d.ts +82 -0
  126. package/dist/standalone/editor-workspace-shell.d.ts +47 -0
  127. package/dist/standalone/editor-workspace-styles.d.ts +1 -0
  128. package/dist/standalone/field-expression-preview.d.ts +12 -0
  129. package/dist/standalone/group-node.d.ts +19 -3
  130. package/dist/standalone/icon-utils.d.ts +7 -0
  131. package/dist/standalone/index.d.ts +17 -5
  132. package/dist/standalone/keyboard-events.d.ts +3 -0
  133. package/dist/standalone/multi-select-popover.d.ts +16 -0
  134. package/dist/standalone/node-copy.d.ts +1 -0
  135. package/dist/standalone/node-definitions.d.ts +4 -0
  136. package/dist/standalone/node-renderer-utils.d.ts +21 -0
  137. package/dist/standalone/node-theme.d.ts +1 -1
  138. package/dist/standalone/point-template-actions.d.ts +43 -0
  139. package/dist/standalone/property-field-draft.d.ts +5 -0
  140. package/dist/standalone/question-list-editor.d.ts +35 -0
  141. package/dist/standalone/shared-node-manager.d.ts +14 -0
  142. package/dist/standalone/single-select-popover.d.ts +6 -0
  143. package/dist/standalone/theme-scope.d.ts +15 -0
  144. package/dist/standalone/themes.d.ts +4 -0
  145. package/dist/standalone/variable-completion-dropdown.d.ts +18 -0
  146. package/dist/types/component.d.ts +22 -1
  147. package/dist/types/editor.d.ts +41 -0
  148. package/dist/utils/relation-utils.d.ts +19 -1
  149. package/dist/version.d.ts +2 -2
  150. package/package.json +3 -3
  151. package/vite-chunks.mjs +66 -0
  152. package/dist/chunks/editor-core-code-editor-CRki2wA_.js +0 -512
  153. package/dist/chunks/editor-core-dialogs-BMWb0WRN.js +0 -17228
  154. package/dist/chunks/editor-core-property-drawers-BPh-jj1b.js +0 -7998
  155. package/dist/chunks/editor-core-standalone-Cls7lcgT.js +0 -11302
  156. package/dist/chunks/vendor-logicflow-core-runtime-Cp6IBEjB.js +0 -217
  157. package/dist/chunks/vendor-logicflow-shared-C7YynLDn.js +0 -4
@@ -1,512 +0,0 @@
1
- import { lineNumbers as w, highlightActiveLineGutter as H, highlightActiveLine as v, drawSelection as P, EditorView as h, keymap as U } from "@codemirror/view";
2
- import { Compartment as x, EditorState as T } from "@codemirror/state";
3
- import { javascript as W } from "@codemirror/lang-javascript";
4
- import { json as B, jsonParseLinter as k } from "@codemirror/lang-json";
5
- import { foldGutter as V, indentOnInput as $, bracketMatching as J, syntaxHighlighting as Y, defaultHighlightStyle as F, StreamLanguage as j } from "@codemirror/language";
6
- import { oneDark as X } from "@codemirror/theme-one-dark";
7
- import { closeBrackets as z, autocompletion as N } from "@codemirror/autocomplete";
8
- import { linter as A } from "@codemirror/lint";
9
- import { search as K, highlightSelectionMatches as Q } from "@codemirror/search";
10
- import { history as q, defaultKeymap as Z, historyKeymap as tt, indentWithTab as et } from "@codemirror/commands";
11
- import { parser as ot } from "@lezer/javascript";
12
- function Ot(e) {
13
- var r;
14
- if (typeof Element > "u" || !(e instanceof Element)) return !1;
15
- const t = e, o = (r = t.tagName) == null ? void 0 : r.toLowerCase();
16
- return o === "input" || o === "textarea" || o === "select" || t.isContentEditable ? !0 : !!t.closest('.cm-editor, .cm-content, [data-cm-container], [contenteditable="true"]');
17
- }
18
- function rt(e) {
19
- if (!(e.ctrlKey || e.metaKey) || e.altKey) return !1;
20
- const t = e.key.toLowerCase();
21
- return t === "c" || t === "v" || t === "x" || t === "a" || t === "z" || t === "y";
22
- }
23
- function nt() {
24
- return import("@codemirror/lang-python");
25
- }
26
- function at() {
27
- return import("@codemirror/legacy-modes/mode/lua");
28
- }
29
- function O() {
30
- return typeof DOMRect == "function" ? new DOMRect(0, 0, 0, 0) : {
31
- x: 0,
32
- y: 0,
33
- width: 0,
34
- height: 0,
35
- top: 0,
36
- right: 0,
37
- bottom: 0,
38
- left: 0,
39
- toJSON: () => ({})
40
- };
41
- }
42
- function _() {
43
- const e = [];
44
- return {
45
- length: 0,
46
- item: (t) => e[t] || null,
47
- [Symbol.iterator]: e[Symbol.iterator].bind(e)
48
- };
49
- }
50
- function it(e) {
51
- const t = e;
52
- return typeof t.getBoundingClientRect != "function" && (t.getBoundingClientRect = O), typeof t.getClientRects != "function" && (t.getClientRects = _), e;
53
- }
54
- function ct() {
55
- if (typeof Range < "u" && (typeof Range.prototype.getBoundingClientRect != "function" && (Range.prototype.getBoundingClientRect = O), typeof Range.prototype.getClientRects != "function" && (Range.prototype.getClientRects = _)), typeof document < "u" && typeof document.createRange == "function" && !document.createRange.__huanbanRangeGeometryPatched) {
56
- const e = document.createRange.bind(document), t = () => it(e());
57
- t.__huanbanRangeGeometryPatched = !0, document.createRange = t;
58
- }
59
- }
60
- function L(e) {
61
- const o = ot.parse(e).cursor();
62
- do
63
- if (o.type.isError)
64
- return {
65
- from: Math.max(0, o.from),
66
- to: Math.max(o.from + 1, o.to)
67
- };
68
- while (o.next());
69
- return null;
70
- }
71
- function I(e) {
72
- const t = L(e);
73
- if (!t) return null;
74
- const o = `function __rulego_script__(msg, metadata, msgType, dataType) {
75
- ${e}
76
- }`;
77
- return L(o) ? t : null;
78
- }
79
- function st() {
80
- return A((e) => {
81
- const t = e.state.doc.toString();
82
- if (!t.trim()) return [];
83
- const o = I(t);
84
- return o ? [{
85
- from: o.from,
86
- to: o.to,
87
- severity: "error",
88
- message: "JavaScript 语法错误"
89
- }] : [];
90
- });
91
- }
92
- function lt() {
93
- return A((e) => {
94
- const t = e.state.doc.toString();
95
- if (!t.trim()) return [];
96
- const o = [], r = (t.match(/\(/g) || []).length, n = (t.match(/\)/g) || []).length;
97
- r !== n && o.push({
98
- from: 0,
99
- to: Math.min(t.length, 50),
100
- severity: "error",
101
- message: `括号不匹配: ${r > n ? "缺少 )" : "多余 )"}`
102
- });
103
- const s = (t.match(/\b(function|if|for|while|repeat|do)\b/g) || []).length, c = (t.match(/\b(end|until)\b/g) || []).length;
104
- return s > c && o.push({
105
- from: 0,
106
- to: Math.min(t.length, 50),
107
- severity: "warning",
108
- message: `代码块不匹配: 缺少 ${s - c} 个 end`
109
- }), o;
110
- });
111
- }
112
- const ut = [
113
- "ABS",
114
- "SQRT",
115
- "ACOS",
116
- "ASIN",
117
- "ATAN",
118
- "ATAN2",
119
- "CEILING",
120
- "COS",
121
- "COSH",
122
- "EXP",
123
- "FLOOR",
124
- "LN",
125
- "LOG",
126
- "LOG10",
127
- "LOG2",
128
- "MOD",
129
- "RAND",
130
- "ROUND",
131
- "SIGN",
132
- "SIN",
133
- "SINH",
134
- "TAN",
135
- "TANH",
136
- "POWER",
137
- "CONCAT",
138
- "LENGTH",
139
- "UPPER",
140
- "LOWER",
141
- "TRIM",
142
- "FORMAT",
143
- "ENDSWITH",
144
- "STARTSWITH",
145
- "INDEXOF",
146
- "SUBSTRING",
147
- "REPLACE",
148
- "SPLIT",
149
- "LPAD",
150
- "RPAD",
151
- "LTRIM",
152
- "RTRIM",
153
- "REGEXP_MATCHES",
154
- "REGEXP_REPLACE",
155
- "REGEXP_SUBSTRING",
156
- "CAST",
157
- "HEX2DEC",
158
- "DEC2HEX",
159
- "ENCODE",
160
- "DECODE",
161
- "CONVERT_TZ",
162
- "TO_SECONDS",
163
- "CHR",
164
- "TRUNC",
165
- "URL_ENCODE",
166
- "URL_DECODE",
167
- "NOW",
168
- "CURRENT_TIME",
169
- "CURRENT_DATE",
170
- "SUM",
171
- "AVG",
172
- "MIN",
173
- "MAX",
174
- "COUNT",
175
- "STDDEV",
176
- "MEDIAN",
177
- "PERCENTILE",
178
- "COLLECT",
179
- "LAST_VALUE",
180
- "MERGE_AGG",
181
- "STDDEV_S",
182
- "DEDUPLICATE",
183
- "VAR",
184
- "VAR_S",
185
- "ROW_NUMBER",
186
- "FIRST_VALUE",
187
- "LEAD",
188
- "NTH_VALUE",
189
- "LAG",
190
- "LATEST",
191
- "CHANGED_COL",
192
- "HAD_CHANGED",
193
- "WINDOW_START",
194
- "WINDOW_END",
195
- "TO_JSON",
196
- "FROM_JSON",
197
- "JSON_EXTRACT",
198
- "JSON_VALID",
199
- "JSON_TYPE",
200
- "JSON_LENGTH",
201
- "MD5",
202
- "SHA1",
203
- "SHA256",
204
- "SHA512",
205
- "ARRAY_LENGTH",
206
- "ARRAY_CONTAINS",
207
- "ARRAY_POSITION",
208
- "ARRAY_REMOVE",
209
- "ARRAY_DISTINCT",
210
- "ARRAY_INTERSECT",
211
- "ARRAY_UNION",
212
- "ARRAY_EXCEPT",
213
- "IS_NULL",
214
- "IS_NOT_NULL",
215
- "IS_NUMERIC",
216
- "IS_STRING",
217
- "IS_BOOL",
218
- "IS_ARRAY",
219
- "IS_OBJECT",
220
- "IF_NULL",
221
- "COALESCE",
222
- "NULL_IF",
223
- "GREATEST",
224
- "LEAST",
225
- "CASE_WHEN",
226
- "UNNEST"
227
- ], ft = [
228
- "SELECT",
229
- "FROM",
230
- "WHERE",
231
- "GROUP BY",
232
- "HAVING",
233
- "ORDER BY",
234
- "LIMIT",
235
- "DISTINCT",
236
- "AS",
237
- "AND",
238
- "OR",
239
- "NOT",
240
- "NULL",
241
- "TRUE",
242
- "FALSE",
243
- "TumblingWindow",
244
- "SlidingWindow",
245
- "SessionWindow",
246
- "STREAM"
247
- ];
248
- function gt(e) {
249
- return Array.isArray(e) ? e.map((t) => {
250
- const o = String((t == null ? void 0 : t.label) || (t == null ? void 0 : t.value) || "");
251
- return o ? {
252
- label: o,
253
- detail: t == null ? void 0 : t.detail,
254
- type: (t == null ? void 0 : t.type) || "variable",
255
- apply: String((t == null ? void 0 : t.value) || o)
256
- } : null;
257
- }).filter((t) => !!t) : [];
258
- }
259
- function pt(e) {
260
- if (!Array.isArray(e)) return [];
261
- const t = [], o = /* @__PURE__ */ new Set();
262
- return e.forEach((r) => {
263
- const n = typeof r == "string" ? r : String((r == null ? void 0 : r.value) || (r == null ? void 0 : r.name) || (r == null ? void 0 : r.label) || "");
264
- !n || o.has(n) || (o.add(n), t.push(n));
265
- }), t;
266
- }
267
- function dt(e = {}) {
268
- const t = e.mode || "js", o = pt(e.globalVars), r = () => {
269
- var n;
270
- return gt(
271
- ((n = e.getSchemaCompletions) == null ? void 0 : n.call(e)) ?? e.schemaCompletions
272
- );
273
- };
274
- return (n) => {
275
- const s = n.matchBefore(/\$\{global\.[\w]*/);
276
- if (s) {
277
- const a = s.text.substring(9);
278
- return {
279
- from: s.from + 9,
280
- options: o.filter((f) => !a || f.startsWith(a)).map((f) => ({ label: f, type: "variable", detail: "全局变量" }))
281
- };
282
- }
283
- const c = n.matchBefore(/\$\{[\w]*/);
284
- if (c) {
285
- const a = c.text.substring(2);
286
- if (!a || "global".startsWith(a))
287
- return {
288
- from: c.from + 2,
289
- options: [{ label: "global.", type: "keyword", detail: "全局变量前缀", apply: "global." }]
290
- };
291
- }
292
- const l = n.matchBefore(/[\w.]*/);
293
- if (!l || l.from === l.to && !n.explicit) return null;
294
- const u = l.text;
295
- if (u.endsWith("msg.") || u === "msg.")
296
- return { from: l.to, options: r() };
297
- if (u.includes("msg.")) {
298
- const a = u.lastIndexOf(".");
299
- if (a !== -1 && u.substring(0, a + 1).endsWith("msg."))
300
- return { from: l.from + a + 1, options: r() };
301
- }
302
- const d = [];
303
- return t === "sql" && d.push(
304
- ...ut.map((a) => ({
305
- label: a,
306
- type: "function",
307
- info: `StreamSQL 函数: ${a}`,
308
- apply: `${a}()`
309
- })),
310
- ...ft.map((a) => ({
311
- label: a,
312
- type: "keyword",
313
- info: `StreamSQL 关键字: ${a}`
314
- }))
315
- ), (u === "msg" || "msg".startsWith(u)) && d.push({ label: "msg", type: "keyword", info: "Message Body" }), d.length === 0 && t !== "sql" ? null : { from: l.from, options: d };
316
- };
317
- }
318
- function mt(e) {
319
- return h.theme({
320
- "&": {
321
- fontSize: "13px",
322
- fontFamily: "'JetBrains Mono','Fira Code','Consolas','Monaco',monospace"
323
- },
324
- ".cm-content": {
325
- minHeight: `${e.minHeight}px`,
326
- caretColor: "#c9d1d9"
327
- },
328
- ".cm-scroller": {
329
- overflow: "auto",
330
- maxHeight: `${e.maxHeight}px`
331
- },
332
- ".cm-gutters": {
333
- backgroundColor: "#161b22",
334
- borderRight: "1px solid #30363d",
335
- color: "#484f58"
336
- },
337
- ".cm-activeLineGutter": {
338
- backgroundColor: "#1c2128"
339
- },
340
- ".cm-activeLine": {
341
- backgroundColor: "#161b2233"
342
- },
343
- // lint 错误标记
344
- ".cm-lintRange-error": {
345
- backgroundImage: "none",
346
- borderBottom: "2px wavy #f85149"
347
- },
348
- ".cm-lintRange-warning": {
349
- backgroundImage: "none",
350
- borderBottom: "2px wavy #d29922"
351
- },
352
- // Tooltip 样式
353
- ".cm-tooltip": {
354
- backgroundColor: "#1c2128",
355
- border: "1px solid #30363d",
356
- color: "#c9d1d9"
357
- },
358
- ".cm-tooltip-autocomplete": {
359
- backgroundColor: "#1c2128"
360
- },
361
- ".cm-tooltip-autocomplete ul li[aria-selected]": {
362
- backgroundColor: "#388bfd26"
363
- },
364
- // 折叠按钮
365
- ".cm-foldGutter .cm-gutterElement": {
366
- cursor: "pointer",
367
- color: "#484f58"
368
- },
369
- // 匹配括号
370
- ".cm-matchingBracket": {
371
- backgroundColor: "#17e5e633",
372
- outline: "1px solid #17e5e666"
373
- }
374
- });
375
- }
376
- function _t(e) {
377
- ct();
378
- const {
379
- parent: t,
380
- value: o = "",
381
- lang: r = "js",
382
- readOnly: n = !1,
383
- onChange: s,
384
- onValidate: c,
385
- minHeight: l = 200,
386
- maxHeight: u = 500,
387
- tabSize: d = 2,
388
- completionMode: a,
389
- schemaCompletions: f,
390
- getSchemaCompletions: C,
391
- globalVars: m
392
- } = e, D = !!a || !!(f != null && f.length) || !!C || !!(m != null && m.length), E = new x(), g = [
393
- // 基础功能
394
- w(),
395
- H(),
396
- v(),
397
- V(),
398
- P(),
399
- $(),
400
- J(),
401
- z(),
402
- q(),
403
- D ? N({
404
- override: [dt({
405
- mode: a || (r === "plain" ? "plain" : "js"),
406
- schemaCompletions: f,
407
- getSchemaCompletions: C,
408
- globalVars: m
409
- })]
410
- }) : N(),
411
- K(),
412
- Q(),
413
- // 按键绑定
414
- h.domEventHandlers({
415
- keydown(i) {
416
- rt(i) && i.stopPropagation();
417
- },
418
- copy(i) {
419
- i.stopPropagation();
420
- },
421
- cut(i) {
422
- i.stopPropagation();
423
- },
424
- paste(i) {
425
- i.stopPropagation();
426
- }
427
- }),
428
- U.of([
429
- ...Z,
430
- ...tt,
431
- et
432
- ]),
433
- // Tab 尺寸
434
- T.tabSize.of(d),
435
- // 语法高亮基础样式
436
- Y(F, { fallback: !0 }),
437
- // 暗色主题
438
- X,
439
- mt({ minHeight: l, maxHeight: u }),
440
- E.of([])
441
- ];
442
- r === "js" ? (g.push(W()), g.push(st())) : r === "json" ? (g.push(B()), g.push(A(k()))) : r === "lua" && g.push(lt()), n && g.push(T.readOnly.of(!0));
443
- let R;
444
- (s || c) && g.push(h.updateListener.of((i) => {
445
- i.docChanged && (clearTimeout(R), R = setTimeout(() => {
446
- const y = i.state.doc.toString();
447
- if (s && s(y), c) {
448
- const G = b(y, r);
449
- c(G);
450
- }
451
- }, 300));
452
- }));
453
- const M = T.create({
454
- doc: o,
455
- extensions: g
456
- }), p = new h({
457
- state: M,
458
- parent: t
459
- });
460
- let S = !1;
461
- return r === "python" ? nt().then(({ python: i }) => {
462
- S || p.dispatch({ effects: E.reconfigure(i()) });
463
- }).catch(() => {
464
- }) : r === "lua" && at().then(({ lua: i }) => {
465
- S || p.dispatch({ effects: E.reconfigure(j.define(i)) });
466
- }).catch(() => {
467
- }), c && o.trim() && setTimeout(() => {
468
- const i = b(o, r);
469
- c(i);
470
- }, 200), {
471
- getValue() {
472
- return p.state.doc.toString();
473
- },
474
- setValue(i) {
475
- p.dispatch({
476
- changes: {
477
- from: 0,
478
- to: p.state.doc.length,
479
- insert: i
480
- }
481
- });
482
- },
483
- destroy() {
484
- S = !0, clearTimeout(R), p.destroy();
485
- },
486
- view: p
487
- };
488
- }
489
- function b(e, t) {
490
- if (!e.trim()) return !0;
491
- try {
492
- if (t === "js") {
493
- const o = I(e);
494
- if (o) return `JavaScript 语法错误,位置 ${o.from}`;
495
- } else if (t === "json")
496
- JSON.parse(e);
497
- else if (t === "lua") {
498
- const o = (e.match(/\b(function|if|for|while|repeat|do)\b/g) || []).length, r = (e.match(/\b(end|until)\b/g) || []).length, n = (e.match(/\(/g) || []).length - (e.match(/\)/g) || []).length;
499
- if (n !== 0) return `括号不匹配: ${n > 0 ? "缺少 )" : "多余 )"}`;
500
- if (o > r) return `代码块不匹配: 缺少 ${o - r} 个 end`;
501
- } else if (t === "plain")
502
- return !0;
503
- return !0;
504
- } catch (o) {
505
- return o.message || String(o);
506
- }
507
- }
508
- export {
509
- _t as c,
510
- Ot as i,
511
- b as v
512
- };