@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
@@ -0,0 +1,660 @@
1
+ import { lineNumbers as G, highlightActiveLineGutter as P, highlightActiveLine as H, drawSelection as B, EditorView as p, keymap as U } from "@codemirror/view";
2
+ import { Compartment as W, EditorState as E } from "@codemirror/state";
3
+ import { javascript as $ } from "@codemirror/lang-javascript";
4
+ import { json as V, jsonParseLinter as F } from "@codemirror/lang-json";
5
+ import { HighlightStyle as J, foldGutter as Y, indentOnInput as j, bracketMatching as X, syntaxHighlighting as z, StreamLanguage as K } from "@codemirror/language";
6
+ import { oneDarkHighlightStyle as Q } from "@codemirror/theme-one-dark";
7
+ import { closeBrackets as q, autocompletion as L } from "@codemirror/autocomplete";
8
+ import { linter as y } from "@codemirror/lint";
9
+ import { search as Z, highlightSelectionMatches as ee } from "@codemirror/search";
10
+ import { history as te, defaultKeymap as oe, historyKeymap as re, indentWithTab as ne } from "@codemirror/commands";
11
+ import { parser as ae } from "@lezer/javascript";
12
+ function De(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 ce(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 Ie() {
24
+ var e;
25
+ return typeof window > "u" ? !1 : !!((e = window.getSelection()) != null && e.toString());
26
+ }
27
+ function ke(e, t) {
28
+ var r;
29
+ if (!e || typeof Element > "u" || !(e instanceof Element)) return !1;
30
+ const o = (r = t == null ? void 0 : t.lf) == null ? void 0 : r.container;
31
+ return o ? o.contains(e) : !1;
32
+ }
33
+ function Me() {
34
+ var e;
35
+ typeof window > "u" || (e = window.getSelection()) == null || e.removeAllRanges();
36
+ }
37
+ function ie() {
38
+ return import("@codemirror/lang-python");
39
+ }
40
+ function le() {
41
+ return import("@codemirror/legacy-modes/mode/lua");
42
+ }
43
+ function w() {
44
+ return typeof DOMRect == "function" ? new DOMRect(0, 0, 0, 0) : {
45
+ x: 0,
46
+ y: 0,
47
+ width: 0,
48
+ height: 0,
49
+ top: 0,
50
+ right: 0,
51
+ bottom: 0,
52
+ left: 0,
53
+ toJSON: () => ({})
54
+ };
55
+ }
56
+ function _() {
57
+ const e = [];
58
+ return {
59
+ length: 0,
60
+ item: (t) => e[t] || null,
61
+ [Symbol.iterator]: e[Symbol.iterator].bind(e)
62
+ };
63
+ }
64
+ function se(e) {
65
+ const t = e;
66
+ return typeof t.getBoundingClientRect != "function" && (t.getBoundingClientRect = w), typeof t.getClientRects != "function" && (t.getClientRects = _), e;
67
+ }
68
+ function de() {
69
+ if (typeof Range < "u" && (typeof Range.prototype.getBoundingClientRect != "function" && (Range.prototype.getBoundingClientRect = w), typeof Range.prototype.getClientRects != "function" && (Range.prototype.getClientRects = _)), typeof document < "u" && typeof document.createRange == "function" && !document.createRange.__huanbanRangeGeometryPatched) {
70
+ const e = document.createRange.bind(document), t = () => se(e());
71
+ t.__huanbanRangeGeometryPatched = !0, document.createRange = t;
72
+ }
73
+ }
74
+ function x(e) {
75
+ const o = ae.parse(e).cursor();
76
+ do
77
+ if (o.type.isError)
78
+ return {
79
+ from: Math.max(0, o.from),
80
+ to: Math.max(o.from + 1, o.to)
81
+ };
82
+ while (o.next());
83
+ return null;
84
+ }
85
+ function D(e) {
86
+ const t = x(e);
87
+ if (!t) return null;
88
+ const o = `function __rulego_script__(msg, metadata, msgType, dataType) {
89
+ ${e}
90
+ }`;
91
+ return x(o) ? t : null;
92
+ }
93
+ function ue() {
94
+ return y((e) => {
95
+ const t = e.state.doc.toString();
96
+ if (!t.trim()) return [];
97
+ const o = D(t);
98
+ return o ? [{
99
+ from: o.from,
100
+ to: o.to,
101
+ severity: "error",
102
+ message: "JavaScript 语法错误"
103
+ }] : [];
104
+ });
105
+ }
106
+ function fe() {
107
+ return y((e) => {
108
+ const t = e.state.doc.toString();
109
+ if (!t.trim()) return [];
110
+ const o = [], r = (t.match(/\(/g) || []).length, n = (t.match(/\)/g) || []).length;
111
+ r !== n && o.push({
112
+ from: 0,
113
+ to: Math.min(t.length, 50),
114
+ severity: "error",
115
+ message: `括号不匹配: ${r > n ? "缺少 )" : "多余 )"}`
116
+ });
117
+ const l = (t.match(/\b(function|if|for|while|repeat|do)\b/g) || []).length, c = (t.match(/\b(end|until)\b/g) || []).length;
118
+ return l > c && o.push({
119
+ from: 0,
120
+ to: Math.min(t.length, 50),
121
+ severity: "warning",
122
+ message: `代码块不匹配: 缺少 ${l - c} 个 end`
123
+ }), o;
124
+ });
125
+ }
126
+ const he = [
127
+ "ABS",
128
+ "SQRT",
129
+ "ACOS",
130
+ "ASIN",
131
+ "ATAN",
132
+ "ATAN2",
133
+ "CEILING",
134
+ "COS",
135
+ "COSH",
136
+ "EXP",
137
+ "FLOOR",
138
+ "LN",
139
+ "LOG",
140
+ "LOG10",
141
+ "LOG2",
142
+ "MOD",
143
+ "RAND",
144
+ "ROUND",
145
+ "SIGN",
146
+ "SIN",
147
+ "SINH",
148
+ "TAN",
149
+ "TANH",
150
+ "POWER",
151
+ "CONCAT",
152
+ "LENGTH",
153
+ "UPPER",
154
+ "LOWER",
155
+ "TRIM",
156
+ "FORMAT",
157
+ "ENDSWITH",
158
+ "STARTSWITH",
159
+ "INDEXOF",
160
+ "SUBSTRING",
161
+ "REPLACE",
162
+ "SPLIT",
163
+ "LPAD",
164
+ "RPAD",
165
+ "LTRIM",
166
+ "RTRIM",
167
+ "REGEXP_MATCHES",
168
+ "REGEXP_REPLACE",
169
+ "REGEXP_SUBSTRING",
170
+ "CAST",
171
+ "HEX2DEC",
172
+ "DEC2HEX",
173
+ "ENCODE",
174
+ "DECODE",
175
+ "CONVERT_TZ",
176
+ "TO_SECONDS",
177
+ "CHR",
178
+ "TRUNC",
179
+ "URL_ENCODE",
180
+ "URL_DECODE",
181
+ "NOW",
182
+ "CURRENT_TIME",
183
+ "CURRENT_DATE",
184
+ "SUM",
185
+ "AVG",
186
+ "MIN",
187
+ "MAX",
188
+ "COUNT",
189
+ "STDDEV",
190
+ "MEDIAN",
191
+ "PERCENTILE",
192
+ "COLLECT",
193
+ "LAST_VALUE",
194
+ "MERGE_AGG",
195
+ "STDDEV_S",
196
+ "DEDUPLICATE",
197
+ "VAR",
198
+ "VAR_S",
199
+ "ROW_NUMBER",
200
+ "FIRST_VALUE",
201
+ "LEAD",
202
+ "NTH_VALUE",
203
+ "LAG",
204
+ "LATEST",
205
+ "CHANGED_COL",
206
+ "HAD_CHANGED",
207
+ "WINDOW_START",
208
+ "WINDOW_END",
209
+ "TO_JSON",
210
+ "FROM_JSON",
211
+ "JSON_EXTRACT",
212
+ "JSON_VALID",
213
+ "JSON_TYPE",
214
+ "JSON_LENGTH",
215
+ "MD5",
216
+ "SHA1",
217
+ "SHA256",
218
+ "SHA512",
219
+ "ARRAY_LENGTH",
220
+ "ARRAY_CONTAINS",
221
+ "ARRAY_POSITION",
222
+ "ARRAY_REMOVE",
223
+ "ARRAY_DISTINCT",
224
+ "ARRAY_INTERSECT",
225
+ "ARRAY_UNION",
226
+ "ARRAY_EXCEPT",
227
+ "IS_NULL",
228
+ "IS_NOT_NULL",
229
+ "IS_NUMERIC",
230
+ "IS_STRING",
231
+ "IS_BOOL",
232
+ "IS_ARRAY",
233
+ "IS_OBJECT",
234
+ "IF_NULL",
235
+ "COALESCE",
236
+ "NULL_IF",
237
+ "GREATEST",
238
+ "LEAST",
239
+ "CASE_WHEN",
240
+ "UNNEST"
241
+ ], ge = [
242
+ "SELECT",
243
+ "FROM",
244
+ "WHERE",
245
+ "GROUP BY",
246
+ "HAVING",
247
+ "ORDER BY",
248
+ "LIMIT",
249
+ "DISTINCT",
250
+ "AS",
251
+ "AND",
252
+ "OR",
253
+ "NOT",
254
+ "NULL",
255
+ "TRUE",
256
+ "FALSE",
257
+ "TumblingWindow",
258
+ "SlidingWindow",
259
+ "SessionWindow",
260
+ "STREAM"
261
+ ];
262
+ function me(e) {
263
+ return Array.isArray(e) ? e.map((t) => {
264
+ const o = String((t == null ? void 0 : t.label) || (t == null ? void 0 : t.value) || "");
265
+ return o ? {
266
+ label: o,
267
+ detail: t == null ? void 0 : t.detail,
268
+ type: (t == null ? void 0 : t.type) || "variable",
269
+ apply: String((t == null ? void 0 : t.value) || o)
270
+ } : null;
271
+ }).filter((t) => !!t) : [];
272
+ }
273
+ function be(e) {
274
+ if (!Array.isArray(e)) return [];
275
+ const t = [], o = /* @__PURE__ */ new Set();
276
+ return e.forEach((r) => {
277
+ 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) || "");
278
+ !n || o.has(n) || (o.add(n), t.push(n));
279
+ }), t;
280
+ }
281
+ function pe(e = {}) {
282
+ const t = e.mode || "js", o = () => {
283
+ var n;
284
+ return me(
285
+ ((n = e.getSchemaCompletions) == null ? void 0 : n.call(e)) ?? e.schemaCompletions
286
+ );
287
+ }, r = [
288
+ { name: "vars", detail: "链变量", prefixDetail: "链变量前缀", keys: () => {
289
+ var l;
290
+ const n = ((l = e.getChainVars) == null ? void 0 : l.call(e)) ?? e.chainVars;
291
+ return Array.isArray(n) ? [...new Set(n.filter((c) => typeof c == "string" && c.length > 0))] : [];
292
+ } },
293
+ { name: "global", detail: "全局变量", prefixDetail: "全局变量前缀", keys: () => {
294
+ var n;
295
+ return be(((n = e.getGlobalVars) == null ? void 0 : n.call(e)) ?? e.globalVars);
296
+ } }
297
+ ];
298
+ return (n) => {
299
+ for (const a of r) {
300
+ const u = n.matchBefore(new RegExp(`\\$\\{${a.name}\\.[^\\s{}]*`));
301
+ if (!u) continue;
302
+ const s = `\${${a.name}.`, b = u.text.slice(s.length);
303
+ return {
304
+ from: u.from + s.length,
305
+ options: a.keys().filter((h) => !b || h.startsWith(b)).map((h) => ({ label: h, type: "variable", detail: a.detail }))
306
+ };
307
+ }
308
+ const l = n.matchBefore(/\$\{[\w]*/);
309
+ if (l) {
310
+ const a = l.text.substring(2), u = r.filter((s) => !a || s.name.startsWith(a));
311
+ if (u.length)
312
+ return {
313
+ from: l.from + 2,
314
+ options: u.map((s) => ({ label: `${s.name}.`, type: "keyword", detail: s.prefixDetail, apply: `${s.name}.` }))
315
+ };
316
+ }
317
+ const c = n.matchBefore(/[\w.]*/);
318
+ if (!c || c.from === c.to && !n.explicit) return null;
319
+ const d = c.text;
320
+ if (d.endsWith("msg.") || d === "msg.")
321
+ return { from: c.to, options: o() };
322
+ if (d.includes("msg.")) {
323
+ const a = d.lastIndexOf(".");
324
+ if (a !== -1 && d.substring(0, a + 1).endsWith("msg."))
325
+ return { from: c.from + a + 1, options: o() };
326
+ }
327
+ const m = [];
328
+ return t === "sql" && m.push(
329
+ ...he.map((a) => ({
330
+ label: a,
331
+ type: "function",
332
+ info: `StreamSQL 函数: ${a}`,
333
+ apply: `${a}()`
334
+ })),
335
+ ...ge.map((a) => ({
336
+ label: a,
337
+ type: "keyword",
338
+ info: `StreamSQL 关键字: ${a}`
339
+ }))
340
+ ), (d === "msg" || "msg".startsWith(d)) && m.push({ label: "msg", type: "keyword", info: "Message Body" }), m.length === 0 && t !== "sql" ? null : { from: c.from, options: m };
341
+ };
342
+ }
343
+ function ve(e) {
344
+ return e === "strong" ? { fontWeight: "bold" } : e === "emphasis" ? { fontStyle: "italic" } : e === "strikethrough" ? { textDecoration: "line-through" } : e === "invalid" || e === "deleted" ? { color: "var(--hb-color-danger)" } : e === "inserted" ? { color: "var(--hb-color-success)" } : e === "link" || e === "url" ? { color: "var(--hb-code-string)", textDecoration: "underline" } : e === "heading" ? { color: "var(--hb-code-type)", fontWeight: "bold" } : { color: `var(--hb-code-${e.startsWith("function(") ? "function" : /^(keyword|operatorKeyword|modifier|self|meta|processingInstruction)$/.test(e) ? "keyword" : /string|character|regexp|escape/i.test(e) ? "string" : /^(number|integer|float|literal|atom|bool|color|changed)$/.test(e) ? "number" : /^(typeName|className|namespace|annotation)$/.test(e) ? "type" : /comment/i.test(e) ? "comment" : /operator/i.test(e) ? "operator" : /^(punctuation|separator|bracket|squareBracket|angleBracket|brace|paren)$/.test(e) ? "bracket" : /name/i.test(e) ? "variable" : "text"})` };
345
+ }
346
+ const Se = J.define(
347
+ [...new Set(Q.specs.flatMap(({ tag: e }) => [e].flat().flatMap((t) => t.set)))].map((e) => ({ tag: e, ...ve(e.toString()) }))
348
+ );
349
+ function Re(e) {
350
+ return p.theme({
351
+ "&": {
352
+ fontSize: "13px",
353
+ fontFamily: "'JetBrains Mono','Fira Code','Consolas','Monaco',monospace",
354
+ backgroundColor: "var(--hb-code-bg)",
355
+ color: "var(--hb-code-text)",
356
+ colorScheme: "inherit"
357
+ },
358
+ "&.cm-focused": {
359
+ outline: "1px solid var(--hb-color-primary)"
360
+ },
361
+ ".cm-content": {
362
+ minHeight: `${e.minHeight}px`,
363
+ caretColor: "var(--hb-code-caret)"
364
+ },
365
+ ".cm-cursor, .cm-dropCursor": {
366
+ borderLeftColor: "var(--hb-code-caret)"
367
+ },
368
+ ".cm-selectionBackground, &.cm-focused .cm-selectionBackground, & ::selection": {
369
+ backgroundColor: "var(--hb-code-selection)"
370
+ },
371
+ ".cm-scroller": {
372
+ overflow: "auto",
373
+ maxHeight: `${e.maxHeight}px`,
374
+ scrollbarColor: "var(--hb-border-strong) var(--hb-code-bg)"
375
+ },
376
+ ".cm-gutters": {
377
+ backgroundColor: "var(--hb-code-gutter-bg)",
378
+ borderRight: "1px solid var(--hb-border-color)",
379
+ color: "var(--hb-code-gutter-text)"
380
+ },
381
+ ".cm-activeLineGutter": {
382
+ backgroundColor: "var(--hb-code-active-line)",
383
+ color: "var(--hb-code-text)"
384
+ },
385
+ ".cm-activeLine": {
386
+ backgroundColor: "var(--hb-code-active-line)"
387
+ },
388
+ // lint 错误标记
389
+ ".cm-lintRange-error, .cm-lintRange-warning, .cm-lintRange-info, .cm-lintRange-hint": {
390
+ backgroundImage: "none",
391
+ textDecorationLine: "underline",
392
+ textDecorationStyle: "wavy",
393
+ textUnderlineOffset: "3px"
394
+ },
395
+ ".cm-lintRange-error": {
396
+ textDecorationColor: "var(--hb-color-danger)"
397
+ },
398
+ ".cm-lintRange-warning": {
399
+ textDecorationColor: "var(--hb-color-warning)"
400
+ },
401
+ ".cm-lintRange-info, .cm-lintRange-hint": {
402
+ textDecorationColor: "var(--hb-color-primary)"
403
+ },
404
+ ".cm-diagnostic-error": { borderLeftColor: "var(--hb-color-danger)" },
405
+ ".cm-diagnostic-warning": { borderLeftColor: "var(--hb-color-warning)" },
406
+ ".cm-diagnostic-info, .cm-diagnostic-hint": { borderLeftColor: "var(--hb-color-primary)" },
407
+ ".cm-lintPoint-error:after": { borderBottomColor: "var(--hb-color-danger)" },
408
+ ".cm-lintPoint-warning:after": { borderBottomColor: "var(--hb-color-warning)" },
409
+ ".cm-lintPoint-info:after, .cm-lintPoint-hint:after": { borderBottomColor: "var(--hb-color-primary)" },
410
+ ".cm-lintRange-active, .cm-panel.cm-panel-lint ul [aria-selected]": {
411
+ background: "var(--hb-code-selection)",
412
+ color: "var(--hb-code-text)"
413
+ },
414
+ ".cm-panel.cm-panel-lint ul:focus [aria-selected]": {
415
+ background: "var(--hb-code-selection)",
416
+ color: "var(--hb-code-text)",
417
+ outlineColor: "var(--hb-code-caret)"
418
+ },
419
+ ".cm-diagnosticSource": {
420
+ color: "var(--hb-text-muted)"
421
+ },
422
+ // Tooltip 样式
423
+ ".cm-tooltip": {
424
+ backgroundColor: "var(--hb-code-tooltip-bg)",
425
+ border: "1px solid var(--hb-border-color)",
426
+ color: "var(--hb-code-text)"
427
+ },
428
+ ".cm-tooltip-section:not(:first-child)": {
429
+ borderTopColor: "var(--hb-border-color)"
430
+ },
431
+ ".cm-tooltip.cm-tooltip-above .cm-tooltip-arrow:before": {
432
+ borderTopColor: "var(--hb-border-color)"
433
+ },
434
+ ".cm-tooltip.cm-tooltip-above .cm-tooltip-arrow:after": {
435
+ borderTopColor: "var(--hb-code-tooltip-bg)"
436
+ },
437
+ ".cm-tooltip.cm-tooltip-below .cm-tooltip-arrow:before": {
438
+ borderBottomColor: "var(--hb-border-color)"
439
+ },
440
+ ".cm-tooltip.cm-tooltip-below .cm-tooltip-arrow:after": {
441
+ borderBottomColor: "var(--hb-code-tooltip-bg)"
442
+ },
443
+ ".cm-tooltip-autocomplete": {
444
+ backgroundColor: "var(--hb-code-tooltip-bg)"
445
+ },
446
+ ".cm-tooltip-autocomplete ul li[aria-selected]": {
447
+ background: "var(--hb-code-selection)",
448
+ color: "var(--hb-code-text)"
449
+ },
450
+ ".cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
451
+ background: "var(--hb-code-active-line)",
452
+ color: "var(--hb-text-disabled)"
453
+ },
454
+ ".cm-completionDetail": { color: "var(--hb-code-comment)" },
455
+ ".cm-snippetField": { backgroundColor: "var(--hb-code-selection)" },
456
+ ".cm-snippetFieldPosition": { borderLeftColor: "var(--hb-code-caret)" },
457
+ ".cm-panels": {
458
+ backgroundColor: "var(--hb-bg-section)",
459
+ color: "var(--hb-code-text)"
460
+ },
461
+ ".cm-panels-top": { borderBottomColor: "var(--hb-border-color)" },
462
+ ".cm-panels-bottom": { borderTopColor: "var(--hb-border-color)" },
463
+ ".cm-textfield": {
464
+ background: "var(--hb-bg-input)",
465
+ border: "1px solid var(--hb-border-color)",
466
+ color: "var(--hb-code-text)"
467
+ },
468
+ ".cm-textfield:focus": {
469
+ outline: "1px solid var(--hb-color-primary)"
470
+ },
471
+ ".cm-textfield::placeholder, .cm-placeholder": { color: "var(--hb-text-muted)" },
472
+ ".cm-button, .cm-diagnosticAction": {
473
+ background: "var(--hb-bg-section)",
474
+ color: "var(--hb-text-primary)",
475
+ border: "1px solid var(--hb-border-color)"
476
+ },
477
+ ".cm-button:active, .cm-button:hover, .cm-diagnosticAction:hover": {
478
+ background: "var(--hb-bg-hover)",
479
+ color: "var(--hb-color-primary)"
480
+ },
481
+ ".cm-button:focus-visible, .cm-panel button:focus-visible": {
482
+ outline: "1px solid var(--hb-color-primary)"
483
+ },
484
+ ".cm-search input[type=checkbox]": { accentColor: "var(--hb-color-primary)" },
485
+ ".cm-panel button[name=close]": { color: "var(--hb-text-secondary)" },
486
+ ".cm-searchMatch, .cm-selectionMatch": {
487
+ backgroundColor: "color-mix(in srgb, var(--hb-color-warning) 20%, transparent)"
488
+ },
489
+ ".cm-searchMatch-selected": {
490
+ backgroundColor: "var(--hb-code-selection)",
491
+ outline: "1px solid var(--hb-code-caret)"
492
+ },
493
+ ".cm-searchMatch .cm-selectionMatch": { background: "transparent" },
494
+ ".cm-specialChar": { color: "var(--hb-color-danger)" },
495
+ ".cm-trailingSpace": { backgroundColor: "color-mix(in srgb, var(--hb-color-danger) 20%, transparent)" },
496
+ ".cm-foldPlaceholder": {
497
+ background: "var(--hb-code-active-line)",
498
+ borderColor: "var(--hb-border-color)",
499
+ color: "var(--hb-code-gutter-text)"
500
+ },
501
+ // 折叠按钮
502
+ ".cm-foldGutter .cm-gutterElement": {
503
+ cursor: "pointer",
504
+ color: "var(--hb-code-gutter-text)"
505
+ },
506
+ // 匹配括号
507
+ "&.cm-focused .cm-matchingBracket": {
508
+ backgroundColor: "var(--hb-code-selection)",
509
+ color: "var(--hb-code-bracket)",
510
+ outline: "1px solid var(--hb-code-caret)"
511
+ },
512
+ "&.cm-focused .cm-nonmatchingBracket": {
513
+ backgroundColor: "color-mix(in srgb, var(--hb-color-danger) 15%, transparent)",
514
+ color: "var(--hb-color-danger)"
515
+ }
516
+ });
517
+ }
518
+ function Ge(e) {
519
+ de();
520
+ const {
521
+ parent: t,
522
+ value: o = "",
523
+ lang: r = "js",
524
+ readOnly: n = !1,
525
+ onChange: l,
526
+ onValidate: c,
527
+ minHeight: d = 200,
528
+ maxHeight: m = 500,
529
+ tabSize: a = 2,
530
+ completionMode: u,
531
+ schemaCompletions: s,
532
+ getSchemaCompletions: b,
533
+ globalVars: h,
534
+ getGlobalVars: T,
535
+ chainVars: v,
536
+ getChainVars: A
537
+ } = e, I = !!u || !!(s != null && s.length) || !!b || !!(h != null && h.length) || !!T || !!(v != null && v.length) || !!A, S = new W(), f = [
538
+ // 基础功能
539
+ G(),
540
+ P(),
541
+ H(),
542
+ Y(),
543
+ B(),
544
+ j(),
545
+ X(),
546
+ q(),
547
+ te(),
548
+ I ? L({
549
+ override: [pe({
550
+ mode: u || (r === "plain" ? "plain" : "js"),
551
+ schemaCompletions: s,
552
+ getSchemaCompletions: b,
553
+ globalVars: h,
554
+ getGlobalVars: T,
555
+ chainVars: v,
556
+ getChainVars: A
557
+ })]
558
+ }) : L(),
559
+ Z(),
560
+ ee(),
561
+ // 按键绑定
562
+ p.domEventHandlers({
563
+ keydown(i) {
564
+ ce(i) && i.stopPropagation();
565
+ },
566
+ copy(i) {
567
+ i.stopPropagation();
568
+ },
569
+ cut(i) {
570
+ i.stopPropagation();
571
+ },
572
+ paste(i) {
573
+ i.stopPropagation();
574
+ }
575
+ }),
576
+ U.of([
577
+ ...oe,
578
+ ...re,
579
+ ne
580
+ ]),
581
+ // Tab 尺寸
582
+ E.tabSize.of(a),
583
+ z(Se),
584
+ Re({ minHeight: d, maxHeight: m }),
585
+ S.of([])
586
+ ];
587
+ r === "js" ? (f.push($()), f.push(ue())) : r === "json" ? (f.push(V()), f.push(y(F()))) : r === "lua" && f.push(fe()), n && (f.push(E.readOnly.of(!0)), f.push(p.editable.of(!1)));
588
+ let R;
589
+ (l || c) && f.push(p.updateListener.of((i) => {
590
+ i.docChanged && (clearTimeout(R), R = setTimeout(() => {
591
+ const N = i.state.doc.toString();
592
+ if (l && l(N), c) {
593
+ const M = O(N, r);
594
+ c(M);
595
+ }
596
+ }, 300));
597
+ }));
598
+ const k = E.create({
599
+ doc: o,
600
+ extensions: f
601
+ }), g = new p({
602
+ state: k,
603
+ parent: t
604
+ });
605
+ let C = !1;
606
+ return r === "python" ? ie().then(({ python: i }) => {
607
+ C || g.dispatch({ effects: S.reconfigure(i()) });
608
+ }).catch(() => {
609
+ }) : r === "lua" && le().then(({ lua: i }) => {
610
+ C || g.dispatch({ effects: S.reconfigure(K.define(i)) });
611
+ }).catch(() => {
612
+ }), c && o.trim() && setTimeout(() => {
613
+ const i = O(o, r);
614
+ c(i);
615
+ }, 200), {
616
+ getValue() {
617
+ return g.state.doc.toString();
618
+ },
619
+ setValue(i) {
620
+ g.dispatch({
621
+ changes: {
622
+ from: 0,
623
+ to: g.state.doc.length,
624
+ insert: i
625
+ }
626
+ });
627
+ },
628
+ destroy() {
629
+ C = !0, clearTimeout(R), g.destroy();
630
+ },
631
+ view: g
632
+ };
633
+ }
634
+ function O(e, t) {
635
+ if (!e.trim()) return !0;
636
+ try {
637
+ if (t === "js") {
638
+ const o = D(e);
639
+ if (o) return `JavaScript 语法错误,位置 ${o.from}`;
640
+ } else if (t === "json")
641
+ JSON.parse(e);
642
+ else if (t === "lua") {
643
+ 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;
644
+ if (n !== 0) return `括号不匹配: ${n > 0 ? "缺少 )" : "多余 )"}`;
645
+ if (o > r) return `代码块不匹配: 缺少 ${o - r} 个 end`;
646
+ } else if (t === "plain")
647
+ return !0;
648
+ return !0;
649
+ } catch (o) {
650
+ return o.message || String(o);
651
+ }
652
+ }
653
+ export {
654
+ Me as a,
655
+ ke as b,
656
+ Ge as c,
657
+ Ie as h,
658
+ De as i,
659
+ O as v
660
+ };