@huanban/rulego-editor-core 1.3.18 → 1.4.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.
- package/README.md +153 -2
- package/assets/images/discovery-dark.svg +1 -0
- package/assets/images/discovery.svg +1 -0
- package/assets/images/nacos-dark.svg +1 -0
- package/assets/images/nacos.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/discovery.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos-dark.svg +1 -0
- package/assets/theme-icons/ant-blue/nacos.svg +1 -0
- package/assets/theme-icons/apple/discovery-dark.svg +1 -0
- package/assets/theme-icons/apple/discovery.svg +1 -0
- package/assets/theme-icons/apple/nacos-dark.svg +1 -0
- package/assets/theme-icons/apple/nacos.svg +1 -0
- package/assets/theme-icons/colorful/discovery-dark.svg +1 -0
- package/assets/theme-icons/colorful/discovery.svg +1 -0
- package/assets/theme-icons/colorful/nacos-dark.svg +1 -0
- package/assets/theme-icons/colorful/nacos.svg +1 -0
- package/assets/theme-icons/dark/discovery-dark.svg +1 -0
- package/assets/theme-icons/dark/discovery.svg +1 -0
- package/assets/theme-icons/dark/nacos-dark.svg +1 -0
- package/assets/theme-icons/dark/nacos.svg +1 -0
- package/assets/theme-icons/default/discovery-dark.svg +1 -0
- package/assets/theme-icons/default/discovery.svg +1 -0
- package/assets/theme-icons/default/nacos-dark.svg +1 -0
- package/assets/theme-icons/default/nacos.svg +1 -0
- package/assets/theme-icons/elegant/discovery-dark.svg +1 -0
- package/assets/theme-icons/elegant/discovery.svg +1 -0
- package/assets/theme-icons/elegant/nacos-dark.svg +1 -0
- package/assets/theme-icons/elegant/nacos.svg +1 -0
- package/assets/theme-icons/github/discovery-dark.svg +1 -0
- package/assets/theme-icons/github/discovery.svg +1 -0
- package/assets/theme-icons/github/nacos-dark.svg +1 -0
- package/assets/theme-icons/github/nacos.svg +1 -0
- package/assets/theme-icons/icon-theme-manifest.json +30 -14
- package/assets/theme-icons/icon-theme-overview.svg +1599 -1287
- package/assets/theme-icons/material/discovery-dark.svg +1 -0
- package/assets/theme-icons/material/discovery.svg +1 -0
- package/assets/theme-icons/material/nacos-dark.svg +1 -0
- package/assets/theme-icons/material/nacos.svg +1 -0
- package/assets/theme-icons/modern/discovery-dark.svg +1 -0
- package/assets/theme-icons/modern/discovery.svg +1 -0
- package/assets/theme-icons/modern/nacos-dark.svg +1 -0
- package/assets/theme-icons/modern/nacos.svg +1 -0
- package/assets/theme-icons/nature/discovery-dark.svg +1 -0
- package/assets/theme-icons/nature/discovery.svg +1 -0
- package/assets/theme-icons/nature/nacos-dark.svg +1 -0
- package/assets/theme-icons/nature/nacos.svg +1 -0
- package/assets/theme-icons/tailwind/discovery-dark.svg +1 -0
- package/assets/theme-icons/tailwind/discovery.svg +1 -0
- package/assets/theme-icons/tailwind/nacos-dark.svg +1 -0
- package/assets/theme-icons/tailwind/nacos.svg +1 -0
- package/assets/theme-icons/tech/discovery-dark.svg +1 -0
- package/assets/theme-icons/tech/discovery.svg +1 -0
- package/assets/theme-icons/tech/nacos-dark.svg +1 -0
- package/assets/theme-icons/tech/nacos.svg +1 -0
- package/assets/theme-icons/vscode/discovery-dark.svg +1 -0
- package/assets/theme-icons/vscode/discovery.svg +1 -0
- package/assets/theme-icons/vscode/nacos-dark.svg +1 -0
- package/assets/theme-icons/vscode/nacos.svg +1 -0
- package/dist/ai/copilot-markdown.d.ts +40 -0
- package/dist/ai/copilot-transport.d.ts +39 -0
- package/dist/api/AIManager.d.ts +5 -4
- package/dist/api/ApiProvider.d.ts +17 -69
- package/dist/api/ComponentCatalogCache.d.ts +27 -0
- package/dist/api/DebugSocketClient.d.ts +18 -25
- package/dist/api/RuleChainAPI.d.ts +24 -145
- package/dist/api/StreamParser.d.ts +0 -10
- package/dist/api/index.d.ts +4 -14
- package/dist/api/response-utils.d.ts +4 -22
- package/dist/api/types.d.ts +44 -179
- package/dist/chunks/editor-core-code-editor-CRki2wA_.js +512 -0
- package/dist/chunks/editor-core-default-components-BjF65lar.js +9448 -0
- package/dist/chunks/editor-core-dialogs-CkFLaC8Q.js +17176 -0
- package/dist/chunks/editor-core-icons-BqeFofNA.js +668 -0
- package/dist/chunks/editor-core-json-diff-RHsPeX-w.js +199 -0
- package/dist/chunks/editor-core-locales-i6o28vm2.js +4159 -0
- package/dist/chunks/editor-core-node-patches-BJTT3TuX.js +8060 -0
- package/dist/chunks/editor-core-node-views-BOaPVdmN.js +1288 -0
- package/dist/chunks/editor-core-property-drawers-lLsBIoCa.js +8035 -0
- package/dist/chunks/editor-core-standalone-CHXk3ukc.js +11270 -0
- package/dist/chunks/editor-core-styles-C1TbLgCK.js +8841 -0
- package/dist/chunks/vendor-logicflow-core-runtime-Cp6IBEjB.js +217 -0
- package/dist/chunks/vendor-logicflow-shared-C7YynLDn.js +4 -0
- package/dist/chunks/xlsx-BopDBbWb.js +24176 -0
- package/dist/core/ActionRegistry.d.ts +47 -0
- package/dist/core/AutoLayout.d.ts +1 -48
- package/dist/core/ComponentDocService.d.ts +28 -0
- package/dist/core/ComponentRegistry.d.ts +1 -125
- package/dist/core/DataAdapter.d.ts +4 -89
- package/dist/core/DiagnosticService.d.ts +15 -0
- package/dist/core/EditorCore.d.ts +22 -212
- package/dist/core/EditorWorkspace.d.ts +111 -0
- package/dist/core/EventBus.d.ts +0 -86
- package/dist/core/ExplorerTreeStore.d.ts +43 -0
- package/dist/core/FieldCapabilityRegistry.d.ts +16 -0
- package/dist/core/FieldChangeRegistry.d.ts +48 -0
- package/dist/core/HistoryManager.d.ts +0 -123
- package/dist/core/I18nManager.d.ts +0 -120
- package/dist/core/Optimizations.d.ts +0 -14
- package/dist/core/OptionSourceRegistry.d.ts +38 -0
- package/dist/core/RuleChainChatManager.d.ts +0 -37
- package/dist/core/RuleChainValidator.d.ts +0 -79
- package/dist/core/StateStore.d.ts +4 -140
- package/dist/core/ThemeManager.d.ts +0 -141
- package/dist/core/ValidationEngine.d.ts +0 -103
- package/dist/core/component-palette.d.ts +20 -0
- package/dist/core/component-payload.d.ts +0 -9
- package/dist/core/connection-status.d.ts +77 -0
- package/dist/core/context-menu-position.d.ts +27 -0
- package/dist/core/cron-schedule.d.ts +85 -0
- package/dist/core/debug-panel.d.ts +6 -0
- package/dist/core/editor-capabilities.d.ts +95 -0
- package/dist/core/editor-dock.d.ts +100 -0
- package/dist/core/editor-panel.d.ts +68 -0
- package/dist/core/explorer-tree.d.ts +27 -0
- package/dist/core/field-protocol.d.ts +32 -0
- package/dist/core/foundation-tokens.d.ts +38 -0
- package/dist/core/graph-operations.d.ts +34 -0
- package/dist/core/hover-tools.d.ts +26 -0
- package/dist/core/index.d.ts +68 -16
- package/dist/core/infer-run-input.d.ts +11 -0
- package/dist/core/key-value-editor.d.ts +6 -0
- package/dist/core/overlay-layers.d.ts +28 -0
- package/dist/core/recent-components.d.ts +51 -0
- package/dist/core/run-guard.d.ts +7 -0
- package/dist/core/runtime-field-dictionary.d.ts +68 -0
- package/dist/core/runtime-limits.d.ts +0 -5
- package/dist/core/save-conflict.d.ts +4 -0
- package/dist/core/server-status.d.ts +34 -0
- package/dist/core/simple-array.d.ts +4 -0
- package/dist/core/table-protocol.d.ts +36 -0
- package/dist/core/table-spreadsheet.d.ts +3 -0
- package/dist/core/test-cases.d.ts +54 -0
- package/dist/core/toolbar-icons.d.ts +4 -0
- package/dist/core/topology-rules.d.ts +17 -0
- package/dist/core/virtual-window.d.ts +20 -0
- package/dist/core/workspace-tab-actions.d.ts +13 -0
- package/dist/defaults/components.d.ts +0 -9
- package/dist/defaults/index.d.ts +0 -15
- package/dist/defaults/locale-en-US.d.ts +0 -24
- package/dist/defaults/locale-zh-CN.d.ts +0 -39
- package/dist/defaults/official-component-fallbacks.d.ts +0 -8
- package/dist/extensions/ClipboardExtension.d.ts +0 -23
- package/dist/extensions/KeyboardExtension.d.ts +0 -17
- package/dist/extensions/MenuExtension.d.ts +0 -23
- package/dist/iconRegistry.d.ts +0 -22
- package/dist/index.cjs +11320 -0
- package/dist/index.d.ts +25 -47
- package/dist/index.esm.js +1123 -99614
- package/dist/index.umd.js +3380 -1471
- package/dist/models/BaseNodeModel.d.ts +0 -32
- package/dist/models/index.d.ts +0 -1
- package/dist/nodes/AgentOrchestrationNode.d.ts +0 -24
- package/dist/nodes/GroupNode.d.ts +0 -38
- package/dist/nodes/HeadlessHtmlNode.d.ts +0 -16
- package/dist/nodes/SwitchNode.d.ts +0 -22
- package/dist/nodes/UnknownNodeModel.d.ts +0 -19
- package/dist/standalone/HuanbanRulegoEditor.d.ts +202 -401
- package/dist/standalone/ai-model-policy.d.ts +0 -1
- package/dist/standalone/ai-providers.d.ts +0 -1
- package/dist/standalone/auth-fetch.d.ts +2 -46
- package/dist/standalone/browser-assets.d.ts +0 -8
- package/dist/standalone/canvas-view.d.ts +6 -0
- package/dist/standalone/code-editor-language-loaders.d.ts +2 -0
- package/dist/standalone/code-editor-language-loaders.legacy.d.ts +7 -0
- package/dist/standalone/code-editor.d.ts +3 -87
- package/dist/standalone/connection-status-binding.d.ts +8 -0
- package/dist/standalone/custom-nodes.d.ts +0 -26
- package/dist/standalone/drawer-unsaved-guard.d.ts +2 -9
- package/dist/standalone/edge-label-quick-editor.d.ts +2 -0
- package/dist/standalone/editor-actions.d.ts +4 -0
- package/dist/standalone/editor-chain-info.d.ts +5 -38
- package/dist/standalone/editor-context-menu.d.ts +0 -21
- package/dist/standalone/editor-debug-ws.d.ts +37 -145
- package/dist/standalone/editor-delete.d.ts +0 -1
- package/dist/standalone/editor-dialogs.d.ts +16 -66
- package/dist/standalone/editor-events.d.ts +0 -27
- package/dist/standalone/editor-overlays.d.ts +14 -0
- package/dist/standalone/editor-property-drawers.d.ts +13 -71
- package/dist/standalone/editor-route-settings.d.ts +7 -55
- package/dist/standalone/editor-sidebar.d.ts +0 -18
- package/dist/standalone/editor-styles.d.ts +0 -11
- package/dist/standalone/editor-toast.d.ts +1 -2
- package/dist/standalone/editor-toolbar.d.ts +5 -80
- package/dist/standalone/editor-tour.d.ts +7 -0
- package/dist/standalone/editor-trace-overlay.d.ts +0 -5
- package/dist/standalone/full-json-dialog.d.ts +5 -1
- package/dist/standalone/group-node.d.ts +1 -51
- package/dist/standalone/icon-utils.d.ts +0 -20
- package/dist/standalone/index.d.ts +10 -7
- package/dist/standalone/json-diff.d.ts +0 -1
- package/dist/standalone/keyboard-events.d.ts +0 -1
- package/dist/standalone/layout-scheduler.d.ts +0 -6
- package/dist/standalone/lifecycle.d.ts +0 -5
- package/dist/standalone/logger.d.ts +0 -32
- package/dist/standalone/models-dev-catalog.d.ts +0 -1
- package/dist/standalone/node-copy.d.ts +7 -4
- package/dist/standalone/node-definitions.d.ts +0 -63
- package/dist/standalone/node-identity.d.ts +0 -1
- package/dist/standalone/node-theme.d.ts +8 -0
- package/dist/standalone/node-views-data.d.ts +0 -20
- package/dist/standalone/official-node-view-patches.d.ts +1 -14
- package/dist/standalone/outline-style.d.ts +7 -0
- package/dist/standalone/run-history-format.d.ts +0 -1
- package/dist/standalone/security-utils.d.ts +1 -5
- package/dist/standalone/shared-node-manager.d.ts +31 -0
- package/dist/standalone/themes.d.ts +0 -48
- package/dist/tools/tool-editor.d.ts +0 -1
- package/dist/types/component.d.ts +105 -87
- package/dist/types/editor.d.ts +16 -169
- package/dist/types/events.d.ts +30 -107
- package/dist/types/index.d.ts +3 -10
- package/dist/types/rule-chain.d.ts +0 -90
- package/dist/utils/GraphUtils.d.ts +0 -10
- package/dist/utils/helpers.d.ts +0 -80
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/pinyin-search.d.ts +0 -57
- package/dist/utils/relation-utils.d.ts +0 -1
- package/dist/utils/textUtils.d.ts +0 -12
- package/dist/version.d.ts +2 -3
- package/dist/xlsx-qn1xoUuv.cjs +105 -0
- package/package.json +19 -5
- package/vite-chunks.d.ts +11 -0
- package/vite-chunks.mjs +120 -0
- package/dist/index.cjs.js +0 -9515
|
@@ -0,0 +1,512 @@
|
|
|
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
|
+
};
|