@winm/vue-workbench-ui 0.0.0-stage → 0.1.2

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 (64) hide show
  1. package/README.md +55 -2
  2. package/dist/Toggle-Dcjn5G6M.js +387 -0
  3. package/dist/code-editor.css +189 -0
  4. package/dist/code-editor.d.ts +5 -0
  5. package/dist/code-editor.js +1272 -0
  6. package/dist/components/Badge.vue.d.ts +34 -0
  7. package/dist/components/BrandMark.vue.d.ts +6 -0
  8. package/dist/components/CodeEditor.vue.d.ts +32 -0
  9. package/dist/components/ConfirmationDialog.vue.d.ts +27 -0
  10. package/dist/components/ContextMenu.vue.d.ts +66 -0
  11. package/dist/components/CopyButton.vue.d.ts +35 -0
  12. package/dist/components/DataTable.vue.d.ts +87 -0
  13. package/dist/components/DatePicker.vue.d.ts +33 -0
  14. package/dist/components/DropdownMenu.vue.d.ts +88 -0
  15. package/dist/components/EmptyState.vue.d.ts +38 -0
  16. package/dist/components/ErrorBanner.vue.d.ts +30 -0
  17. package/dist/components/ExpandableCodeEditor.vue.d.ts +72 -0
  18. package/dist/components/Expander.vue.d.ts +75 -0
  19. package/dist/components/FilePicker.vue.d.ts +111 -0
  20. package/dist/components/Icon.vue.d.ts +8 -0
  21. package/dist/components/Ipv4Input.vue.d.ts +95 -0
  22. package/dist/components/KeyValueTable.vue.d.ts +96 -0
  23. package/dist/components/ModalDialog.vue.d.ts +75 -0
  24. package/dist/components/NumberInput.vue.d.ts +69 -0
  25. package/dist/components/Pagination.vue.d.ts +49 -0
  26. package/dist/components/PasswordInput.vue.d.ts +48 -0
  27. package/dist/components/PlaceholderInput.vue.d.ts +36 -0
  28. package/dist/components/PluginIcon.vue.d.ts +20 -0
  29. package/dist/components/Popover.vue.d.ts +91 -0
  30. package/dist/components/ProgressBar.vue.d.ts +46 -0
  31. package/dist/components/SearchInput.vue.d.ts +72 -0
  32. package/dist/components/SegmentedControl.vue.d.ts +45 -0
  33. package/dist/components/SliderInput.vue.d.ts +59 -0
  34. package/dist/components/StatusBadge.vue.d.ts +18 -0
  35. package/dist/components/SwitchField.vue.d.ts +38 -0
  36. package/dist/components/Tabs.vue.d.ts +51 -0
  37. package/dist/components/TextInput.vue.d.ts +120 -0
  38. package/dist/components/Toast.vue.d.ts +47 -0
  39. package/dist/components/Toggle.vue.d.ts +16 -0
  40. package/dist/components/Tooltip.vue.d.ts +32 -0
  41. package/dist/components/WorkbenchTabs.vue.d.ts +52 -0
  42. package/dist/components/flow/PanelResizer.vue.d.ts +23 -0
  43. package/dist/components/http/HttpJsonTree.vue.d.ts +6 -0
  44. package/dist/components/http/HttpJsonTreeNode.vue.d.ts +22 -0
  45. package/dist/composables/useClipboard.d.ts +23 -0
  46. package/dist/date-picker-range.d.ts +54 -0
  47. package/dist/date-picker.d.ts +31 -0
  48. package/dist/directives/tooltip.d.ts +32 -0
  49. package/dist/editors/languages.d.ts +10 -0
  50. package/dist/editors/script-completions.d.ts +23 -0
  51. package/dist/editors/script-linter.d.ts +7 -0
  52. package/dist/editors/theme.d.ts +3 -0
  53. package/dist/file-picker.d.ts +68 -0
  54. package/dist/index.d.ts +69 -0
  55. package/dist/index.js +6116 -0
  56. package/dist/media-icon.d.ts +5 -0
  57. package/dist/modal-enhancer.d.ts +28 -0
  58. package/dist/overlay-host.d.ts +2 -0
  59. package/dist/plugin.d.ts +22 -0
  60. package/dist/select-popup.d.ts +14 -0
  61. package/dist/style.css +2 -0
  62. package/dist/template-placeholders.d.ts +64 -0
  63. package/dist/ui-context.d.ts +18 -0
  64. package/package.json +71 -3
@@ -0,0 +1,1272 @@
1
+ import { a as e, f as t, l as n, n as r, o as i, t as a } from "./Toggle-Dcjn5G6M.js";
2
+ import { computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, onBeforeUnmount as m, onMounted as h, openBlock as g, ref as _, renderSlot as v, toDisplayString as ee, unref as y, watch as b, withCtx as x, withDirectives as S } from "vue";
3
+ import { Compartment as C, EditorState as w } from "@codemirror/state";
4
+ import { EditorView as T, drawSelection as E, highlightActiveLine as D, highlightActiveLineGutter as O, keymap as k, lineNumbers as A } from "@codemirror/view";
5
+ import { defaultKeymap as j, history as M, historyKeymap as N } from "@codemirror/commands";
6
+ import { HighlightStyle as P, LanguageSupport as F, StreamLanguage as I, bracketMatching as L, syntaxHighlighting as R, syntaxTree as z } from "@codemirror/language";
7
+ import { acceptCompletion as te, autocompletion as ne, closeBrackets as re, closeBracketsKeymap as ie, completionKeymap as ae, ifNotIn as oe, snippetCompletion as B } from "@codemirror/autocomplete";
8
+ import { MSSQL as se, MySQL as ce, keywordCompletionSource as le, schemaCompletionSource as ue, sql as de } from "@codemirror/lang-sql";
9
+ import { json as fe } from "@codemirror/lang-json";
10
+ import { completionPath as pe, javascriptLanguage as V, localCompletionSource as me } from "@codemirror/lang-javascript";
11
+ import { tags as H } from "@lezer/highlight";
12
+ // src/editors/script-completions.ts
13
+ var U = /^[\p{L}_$][\p{L}\p{N}_$]*$/u, W = /^[\p{L}\p{N}_$]*$/u, he = [
14
+ {
15
+ label: "input",
16
+ type: "variable",
17
+ detail: "上游数据包",
18
+ info: "包含 kind、schema、rows、value、metadata",
19
+ boost: 99
20
+ },
21
+ {
22
+ label: "return",
23
+ type: "keyword",
24
+ detail: "返回处理结果",
25
+ boost: 95
26
+ },
27
+ {
28
+ label: "const",
29
+ type: "keyword",
30
+ detail: "声明常量",
31
+ boost: 90
32
+ },
33
+ {
34
+ label: "let",
35
+ type: "keyword",
36
+ detail: "声明变量",
37
+ boost: 88
38
+ },
39
+ B("if (${condition}) {\n ${}\n}", {
40
+ label: "if",
41
+ detail: "条件分支",
42
+ type: "keyword",
43
+ boost: 85
44
+ }),
45
+ B("if (${condition}) {\n ${}\n} else {\n ${}\n}", {
46
+ label: "if...else",
47
+ detail: "条件与否则分支",
48
+ type: "keyword",
49
+ boost: 82
50
+ }),
51
+ {
52
+ label: "else",
53
+ type: "keyword",
54
+ detail: "否则分支",
55
+ boost: 75
56
+ },
57
+ B("for (const ${row} of ${input.rows}) {\n ${}\n}", {
58
+ label: "for",
59
+ detail: "遍历上游记录",
60
+ type: "keyword",
61
+ boost: 84
62
+ }),
63
+ B("try {\n ${}\n} catch (${err}) {\n ${}\n}", {
64
+ label: "try",
65
+ detail: "异常捕获",
66
+ type: "keyword",
67
+ boost: 80
68
+ }),
69
+ {
70
+ label: "while",
71
+ type: "keyword",
72
+ detail: "循环"
73
+ },
74
+ {
75
+ label: "switch",
76
+ type: "keyword",
77
+ detail: "多分支选择"
78
+ },
79
+ {
80
+ label: "case",
81
+ type: "keyword",
82
+ detail: "分支项"
83
+ },
84
+ {
85
+ label: "default",
86
+ type: "keyword",
87
+ detail: "默认分支"
88
+ },
89
+ {
90
+ label: "break",
91
+ type: "keyword",
92
+ detail: "跳出"
93
+ },
94
+ {
95
+ label: "continue",
96
+ type: "keyword",
97
+ detail: "继续下一轮"
98
+ },
99
+ {
100
+ label: "throw",
101
+ type: "keyword",
102
+ detail: "抛出错误(阻断下游)"
103
+ },
104
+ {
105
+ label: "new",
106
+ type: "keyword",
107
+ detail: "构造实例"
108
+ },
109
+ {
110
+ label: "typeof",
111
+ type: "keyword",
112
+ detail: "类型判断"
113
+ },
114
+ {
115
+ label: "true",
116
+ type: "keyword",
117
+ detail: "布尔真"
118
+ },
119
+ {
120
+ label: "false",
121
+ type: "keyword",
122
+ detail: "布尔假"
123
+ },
124
+ {
125
+ label: "null",
126
+ type: "keyword",
127
+ detail: "空值"
128
+ },
129
+ {
130
+ label: "undefined",
131
+ type: "keyword",
132
+ detail: "未定义"
133
+ },
134
+ {
135
+ label: "Array",
136
+ type: "class",
137
+ detail: "数组工具"
138
+ },
139
+ {
140
+ label: "Object",
141
+ type: "class",
142
+ detail: "对象工具"
143
+ },
144
+ {
145
+ label: "JSON",
146
+ type: "namespace",
147
+ detail: "JSON 解析与序列化"
148
+ },
149
+ {
150
+ label: "Math",
151
+ type: "namespace",
152
+ detail: "数学纯计算"
153
+ },
154
+ {
155
+ label: "String",
156
+ type: "class",
157
+ detail: "字符串"
158
+ },
159
+ {
160
+ label: "Number",
161
+ type: "class",
162
+ detail: "数值"
163
+ },
164
+ {
165
+ label: "Boolean",
166
+ type: "class",
167
+ detail: "布尔值"
168
+ },
169
+ {
170
+ label: "Date",
171
+ type: "class",
172
+ detail: "日期时间"
173
+ },
174
+ {
175
+ label: "Map",
176
+ type: "class",
177
+ detail: "键值映射"
178
+ },
179
+ {
180
+ label: "Set",
181
+ type: "class",
182
+ detail: "集合"
183
+ },
184
+ {
185
+ label: "RegExp",
186
+ type: "class",
187
+ detail: "正则表达式"
188
+ },
189
+ {
190
+ label: "Error",
191
+ type: "class",
192
+ detail: "错误对象"
193
+ },
194
+ {
195
+ label: "parseInt",
196
+ type: "function",
197
+ detail: "解析整数"
198
+ },
199
+ {
200
+ label: "parseFloat",
201
+ type: "function",
202
+ detail: "解析小数"
203
+ },
204
+ {
205
+ label: "isNaN",
206
+ type: "function",
207
+ detail: "判断是否非数字"
208
+ },
209
+ {
210
+ label: "isFinite",
211
+ type: "function",
212
+ detail: "判断是否有限数值"
213
+ }
214
+ ], ge = [
215
+ {
216
+ label: "rows",
217
+ type: "property",
218
+ detail: "表格记录数组",
219
+ info: "每项是一条包含字段值的对象",
220
+ boost: 95
221
+ },
222
+ {
223
+ label: "schema",
224
+ type: "property",
225
+ detail: "表格字段定义",
226
+ info: "包含 name、type、nullable、sensitive",
227
+ boost: 90
228
+ },
229
+ {
230
+ label: "value",
231
+ type: "property",
232
+ detail: "JSON 数据内容",
233
+ info: "当上游输出为 JSON 时为实际对象或数组",
234
+ boost: 90
235
+ },
236
+ {
237
+ label: "kind",
238
+ type: "property",
239
+ detail: "数据类型(table / json)",
240
+ boost: 85
241
+ },
242
+ {
243
+ label: "metadata",
244
+ type: "property",
245
+ detail: "运行元信息对象",
246
+ boost: 80
247
+ }
248
+ ], G = [
249
+ {
250
+ label: "map",
251
+ type: "method",
252
+ detail: "映射转换每条记录",
253
+ boost: 95
254
+ },
255
+ {
256
+ label: "filter",
257
+ type: "method",
258
+ detail: "按条件筛选记录",
259
+ boost: 94
260
+ },
261
+ {
262
+ label: "reduce",
263
+ type: "method",
264
+ detail: "汇总归约计算",
265
+ boost: 90
266
+ },
267
+ {
268
+ label: "find",
269
+ type: "method",
270
+ detail: "查找首条匹配记录",
271
+ boost: 88
272
+ },
273
+ {
274
+ label: "findIndex",
275
+ type: "method",
276
+ detail: "查找首条匹配索引"
277
+ },
278
+ {
279
+ label: "some",
280
+ type: "method",
281
+ detail: "是否存在满足条件的项"
282
+ },
283
+ {
284
+ label: "every",
285
+ type: "method",
286
+ detail: "是否全部满足条件"
287
+ },
288
+ {
289
+ label: "forEach",
290
+ type: "method",
291
+ detail: "遍历记录"
292
+ },
293
+ {
294
+ label: "sort",
295
+ type: "method",
296
+ detail: "排序"
297
+ },
298
+ {
299
+ label: "slice",
300
+ type: "method",
301
+ detail: "截取切片"
302
+ },
303
+ {
304
+ label: "concat",
305
+ type: "method",
306
+ detail: "合并数组"
307
+ },
308
+ {
309
+ label: "flatMap",
310
+ type: "method",
311
+ detail: "映射并展平"
312
+ },
313
+ {
314
+ label: "includes",
315
+ type: "method",
316
+ detail: "是否包含元素"
317
+ },
318
+ {
319
+ label: "join",
320
+ type: "method",
321
+ detail: "拼接为字符串"
322
+ },
323
+ {
324
+ label: "length",
325
+ type: "property",
326
+ detail: "记录数",
327
+ boost: 92
328
+ }
329
+ ], _e = [{
330
+ label: "totalRows",
331
+ type: "property",
332
+ detail: "记录总行数"
333
+ }, {
334
+ label: "sources",
335
+ type: "property",
336
+ detail: "来源读取证据"
337
+ }], K = [
338
+ {
339
+ label: "trim",
340
+ type: "method",
341
+ detail: "去除首尾空白",
342
+ boost: 95
343
+ },
344
+ {
345
+ label: "split",
346
+ type: "method",
347
+ detail: "按分隔符拆分为数组",
348
+ boost: 92
349
+ },
350
+ {
351
+ label: "replace",
352
+ type: "method",
353
+ detail: "替换匹配文本",
354
+ boost: 90
355
+ },
356
+ {
357
+ label: "replaceAll",
358
+ type: "method",
359
+ detail: "替换全部匹配文本",
360
+ boost: 88
361
+ },
362
+ {
363
+ label: "includes",
364
+ type: "method",
365
+ detail: "是否包含子串",
366
+ boost: 90
367
+ },
368
+ {
369
+ label: "startsWith",
370
+ type: "method",
371
+ detail: "是否以指定前缀开头",
372
+ boost: 86
373
+ },
374
+ {
375
+ label: "endsWith",
376
+ type: "method",
377
+ detail: "是否以指定后缀结尾",
378
+ boost: 86
379
+ },
380
+ {
381
+ label: "slice",
382
+ type: "method",
383
+ detail: "截取子串",
384
+ boost: 84
385
+ },
386
+ {
387
+ label: "substring",
388
+ type: "method",
389
+ detail: "按起止下标截取",
390
+ boost: 80
391
+ },
392
+ {
393
+ label: "toUpperCase",
394
+ type: "method",
395
+ detail: "转为大写",
396
+ boost: 82
397
+ },
398
+ {
399
+ label: "toLowerCase",
400
+ type: "method",
401
+ detail: "转为小写",
402
+ boost: 82
403
+ },
404
+ {
405
+ label: "padStart",
406
+ type: "method",
407
+ detail: "左侧补齐长度"
408
+ },
409
+ {
410
+ label: "padEnd",
411
+ type: "method",
412
+ detail: "右侧补齐长度"
413
+ },
414
+ {
415
+ label: "indexOf",
416
+ type: "method",
417
+ detail: "查找子串位置"
418
+ },
419
+ {
420
+ label: "match",
421
+ type: "method",
422
+ detail: "正则匹配"
423
+ },
424
+ {
425
+ label: "length",
426
+ type: "property",
427
+ detail: "字符长度",
428
+ boost: 88
429
+ }
430
+ ], ve = [
431
+ {
432
+ label: "toFixed",
433
+ type: "method",
434
+ detail: "保留指定小数位",
435
+ boost: 95
436
+ },
437
+ {
438
+ label: "toString",
439
+ type: "method",
440
+ detail: "转为字符串",
441
+ boost: 88
442
+ },
443
+ {
444
+ label: "toLocaleString",
445
+ type: "method",
446
+ detail: "格式化数字字符串",
447
+ boost: 82
448
+ },
449
+ {
450
+ label: "toPrecision",
451
+ type: "method",
452
+ detail: "保留有效数字"
453
+ }
454
+ ], ye = /(?:\.(?:filter|map|slice|concat|flatMap|sort|split|reverse)|Object\.(?:keys|values|entries)|Array\.from)\s*\([^()]*\)\s*\.$/u, be = /(?:\.(?:trim|trimStart|trimEnd|replace|replaceAll|toUpperCase|toLowerCase|substring|padStart|padEnd|join|toFixed|toString)|String|JSON\.stringify)\s*\([^()]*\)\s*\.$/u, xe = /* @__PURE__ */ new Set([
455
+ "LineComment",
456
+ "BlockComment",
457
+ "Comment",
458
+ "String",
459
+ "TemplateString",
460
+ "RegExp"
461
+ ]);
462
+ function Se(e) {
463
+ return e && /int|num|dec|float|double|real|money|bigint/i.test(e) ? ve : e && /bool|bit/i.test(e) ? [{
464
+ label: "toString",
465
+ type: "method",
466
+ detail: "转为字符串",
467
+ boost: 90
468
+ }] : K;
469
+ }
470
+ function Ce(e, t) {
471
+ return U.test(t) ? `${e}.${t}` : `${e}[${JSON.stringify(t)}]`;
472
+ }
473
+ function we(e) {
474
+ let t = z(e.state).resolveInner(e.pos, -1);
475
+ for (; t;) {
476
+ if (xe.has(t.name)) return !0;
477
+ t = t.parent;
478
+ }
479
+ return !1;
480
+ }
481
+ function Te(e) {
482
+ if (we(e)) return null;
483
+ let t = e.matchBefore(/[\)\]]\.[\p{L}\p{N}_$]*$/u);
484
+ if (!t) return null;
485
+ let n = t.text.indexOf("."), r = t.from + n + 1, i = e.state.sliceDoc(Math.max(0, t.from - 120), t.from + n + 1);
486
+ return t.text.startsWith("].") || ye.test(i) ? {
487
+ from: r,
488
+ options: [...G],
489
+ validFor: W
490
+ } : be.test(i) ? {
491
+ from: r,
492
+ options: [...K],
493
+ validFor: W
494
+ } : {
495
+ from: r,
496
+ options: [...G, ...K],
497
+ validFor: W
498
+ };
499
+ }
500
+ var q = {
501
+ Array: [
502
+ {
503
+ label: "isArray",
504
+ type: "method",
505
+ detail: "判断是否为数组"
506
+ },
507
+ {
508
+ label: "from",
509
+ type: "method",
510
+ detail: "从可迭代对象创建数组"
511
+ },
512
+ {
513
+ label: "of",
514
+ type: "method",
515
+ detail: "按参数列表创建数组"
516
+ }
517
+ ],
518
+ Object: [
519
+ {
520
+ label: "keys",
521
+ type: "method",
522
+ detail: "获取对象键数组"
523
+ },
524
+ {
525
+ label: "values",
526
+ type: "method",
527
+ detail: "获取对象值数组"
528
+ },
529
+ {
530
+ label: "entries",
531
+ type: "method",
532
+ detail: "获取键值对数组"
533
+ },
534
+ {
535
+ label: "assign",
536
+ type: "method",
537
+ detail: "浅合并对象属性"
538
+ },
539
+ {
540
+ label: "fromEntries",
541
+ type: "method",
542
+ detail: "从键值对数组构建对象"
543
+ }
544
+ ],
545
+ JSON: [{
546
+ label: "stringify",
547
+ type: "method",
548
+ detail: "序列化为 JSON 文本"
549
+ }, {
550
+ label: "parse",
551
+ type: "method",
552
+ detail: "解析 JSON 文本"
553
+ }],
554
+ Math: [
555
+ {
556
+ label: "round",
557
+ type: "method",
558
+ detail: "四舍五入"
559
+ },
560
+ {
561
+ label: "floor",
562
+ type: "method",
563
+ detail: "向下取整"
564
+ },
565
+ {
566
+ label: "ceil",
567
+ type: "method",
568
+ detail: "向上取整"
569
+ },
570
+ {
571
+ label: "abs",
572
+ type: "method",
573
+ detail: "绝对值"
574
+ },
575
+ {
576
+ label: "min",
577
+ type: "method",
578
+ detail: "最小值"
579
+ },
580
+ {
581
+ label: "max",
582
+ type: "method",
583
+ detail: "最大值"
584
+ },
585
+ {
586
+ label: "trunc",
587
+ type: "method",
588
+ detail: "截断小数部分"
589
+ }
590
+ ],
591
+ Number: [
592
+ {
593
+ label: "isFinite",
594
+ type: "method",
595
+ detail: "判断有限数值"
596
+ },
597
+ {
598
+ label: "isInteger",
599
+ type: "method",
600
+ detail: "判断整数"
601
+ },
602
+ {
603
+ label: "isNaN",
604
+ type: "method",
605
+ detail: "判断是否 NaN"
606
+ },
607
+ {
608
+ label: "parseInt",
609
+ type: "method",
610
+ detail: "解析整数"
611
+ },
612
+ {
613
+ label: "parseFloat",
614
+ type: "method",
615
+ detail: "解析浮点数"
616
+ }
617
+ ],
618
+ String: [{
619
+ label: "fromCharCode",
620
+ type: "method",
621
+ detail: "字符码转字符串"
622
+ }],
623
+ Date: [{
624
+ label: "now",
625
+ type: "method",
626
+ detail: "当前时间戳(毫秒)"
627
+ }, {
628
+ label: "parse",
629
+ type: "method",
630
+ detail: "解析日期文本"
631
+ }]
632
+ }, J = /* @__PURE__ */ new Set([
633
+ "input",
634
+ "Array",
635
+ "Object",
636
+ "JSON",
637
+ "Math",
638
+ "Number",
639
+ "String",
640
+ "Boolean",
641
+ "Date",
642
+ "Map",
643
+ "Set",
644
+ "RegExp",
645
+ "Error"
646
+ ]);
647
+ function Y(e, t, n) {
648
+ return U.test(e) ? {
649
+ label: e,
650
+ type: "property",
651
+ detail: t,
652
+ boost: n
653
+ } : {
654
+ label: e,
655
+ type: "property",
656
+ detail: t,
657
+ boost: n,
658
+ apply(t, n, r, i) {
659
+ let a = r > 0 && t.state.sliceDoc(r - 1, r) === "." ? r - 1 : r;
660
+ t.dispatch({ changes: {
661
+ from: a,
662
+ to: i,
663
+ insert: `[${JSON.stringify(e)}]`
664
+ } });
665
+ }
666
+ };
667
+ }
668
+ function X(e) {
669
+ let t = /* @__PURE__ */ new Map(), n = (e.scriptFields ?? []).filter((e) => e.name).map((e) => (t.set(e.name, e.type), Y(e.name, e.type ? `上游字段 · ${e.type}` : "上游字段", 85))), r = (e.scriptJsonKeys ?? []).filter(Boolean).map((e) => Y(e, "上游 JSON 字段", 85));
670
+ return (e) => {
671
+ let i = pe(e);
672
+ if (!i) return Te(e);
673
+ let a = e.pos - i.name.length;
674
+ if (i.path.length === 0) return {
675
+ from: a,
676
+ options: [...he],
677
+ validFor: W
678
+ };
679
+ let [o, s] = i.path;
680
+ if (i.path.length === 1 && o === "input") return {
681
+ from: a,
682
+ options: [...ge],
683
+ validFor: W
684
+ };
685
+ if (i.path.length === 2 && o === "input") {
686
+ if (s === "rows" || s === "schema") return {
687
+ from: a,
688
+ options: [...G],
689
+ validFor: W
690
+ };
691
+ if (s === "value" && r.length > 0) return {
692
+ from: a,
693
+ options: r,
694
+ validFor: W
695
+ };
696
+ if (s === "metadata") return {
697
+ from: a,
698
+ options: [..._e],
699
+ validFor: W
700
+ };
701
+ }
702
+ return i.path.length === 1 && o && Object.hasOwn(q, o) ? {
703
+ from: a,
704
+ options: [...q[o]],
705
+ validFor: W
706
+ } : i.path.length === 1 && o && !J.has(o) && n.length > 0 ? {
707
+ from: a,
708
+ options: n,
709
+ validFor: W
710
+ } : i.path.length === 2 && o && s && !J.has(o) && (t.has(s) || n.length === 0) ? {
711
+ from: a,
712
+ options: [...Se(t.get(s))],
713
+ validFor: W
714
+ } : null;
715
+ };
716
+ }
717
+ // src/editors/languages.ts
718
+ var Ee = I.define({
719
+ startState: () => ({ inBlockComment: !1 }),
720
+ token(e, t) {
721
+ return t.inBlockComment ? e.match(/.*?#>/) ? (t.inBlockComment = !1, "comment") : (e.skipToEnd(), "comment") : e.eatSpace() ? null : e.match("<#") ? (t.inBlockComment = !0, "comment") : e.match("#") ? (e.skipToEnd(), "comment") : e.match(/"(?:[^"`]|`.)*"/) || e.match(/'(?:[^']|'')*'/) ? "string" : e.match(/\$(?:ENV:)?[A-Za-z_][A-Za-z0-9_]*|\$\{[^}]+\}/i) ? "variableName" : e.match(/\b\d+(?:\.\d+)?\b/) ? "number" : e.match(/\b(?:param|begin|process|end|if|elseif|else|switch|foreach|for|while|do|function|filter|return|throw|try|catch|finally|exit|break|continue|trap)\b/i) || e.match(/\b[A-Za-z]+-[A-Za-z0-9]+\b/) ? "keyword" : e.match(/-[A-Za-z][A-Za-z0-9]*/) ? "operator" : (e.next(), null);
722
+ }
723
+ }), De = I.define({
724
+ startState: () => ({ inBlockComment: !1 }),
725
+ token(e) {
726
+ return e.eatSpace() ? null : e.sol() && e.match(/(?:@?rem\b|::).*/i) ? "comment" : e.match(/"[^"]*"/) ? "string" : e.match(/%(?:~[fdpnxsatz]*\d|[A-Za-z0-9_]+%|[*0-9])|![A-Za-z0-9_]+!/) ? "variableName" : e.match(/\b\d+\b/) ? "number" : e.match(/\b(?:echo|off|on|set|setlocal|endlocal|if|else|for|in|do|call|goto|exit|shift|chcp|cd|pushd|popd|dir|copy|move|del|mkdir|rmdir|errorlevel|exist|not|equ|neq|lss|leq|gtr|geq)\b/i) ? "keyword" : (e.next(), null);
727
+ }
728
+ }), Oe = I.define({
729
+ startState: () => ({ inBlockComment: !1 }),
730
+ token(e) {
731
+ return e.eatSpace() ? null : e.match("#") ? (e.skipToEnd(), "comment") : e.match(/"(?:[^"\\]|\\.)*"/) || e.match(/'[^']*'/) ? "string" : e.match(/\$\{[^}]+\}|\$[A-Za-z_][A-Za-z0-9_]*|\$[0-9@#*?$!-]/) ? "variableName" : e.match(/\b\d+(?:\.\d+)?\b/) ? "number" : e.match(/\b(?:if|then|elif|else|fi|for|while|until|do|done|case|esac|in|function|return|exit|export|local|readonly|declare|typeset|unset|set|shopt|setopt|source|echo|printf|test|cd|pwd|trap|true|false)\b/) ? "keyword" : (e.next(), null);
732
+ }
733
+ }), ke = I.define({
734
+ startState: () => ({
735
+ inComment: !1,
736
+ inTag: !1
737
+ }),
738
+ token(e, t) {
739
+ if (t.inComment) return e.match(/.*?-->/) ? (t.inComment = !1, "comment") : (e.skipToEnd(), "comment");
740
+ if (e.eatSpace()) return null;
741
+ if (e.match("<!--")) return t.inComment = !0, "comment";
742
+ if (e.match(/<\/?[A-Za-z_][A-Za-z0-9_:-]*/)) return t.inTag = !0, "tagName";
743
+ if (t.inTag) {
744
+ if (e.match(/\/?>/)) return t.inTag = !1, "bracket";
745
+ if (e.match(/"[^"]*"/) || e.match(/'[^']*'/)) return "string";
746
+ if (e.match(/[A-Za-z_:][A-Za-z0-9_.:-]*(?=\s*=)/)) return "attributeName";
747
+ if (e.match("=")) return "operator";
748
+ }
749
+ return e.next(), null;
750
+ }
751
+ }), Ae = I.define({
752
+ startState: () => ({}),
753
+ token(e) {
754
+ return e.skipToEnd(), null;
755
+ }
756
+ });
757
+ function Z(e, t, n) {
758
+ if (e === "json") return [fe()];
759
+ if (e === "javascript") return [new F(V, [V.data.of({ autocomplete: me }), V.data.of({ autocomplete: X(n) })])];
760
+ if (e === "powershell") return [Ee];
761
+ if (e === "cmd") return [De];
762
+ if (e === "shell") return [Oe];
763
+ if (e === "xml" || e === "html") return [ke];
764
+ if (e === "text") return [Ae];
765
+ let r = {
766
+ dialect: t === "mysql" ? ce : se,
767
+ schema: n.tables,
768
+ defaultTable: n.defaultTable,
769
+ upperCaseKeywords: !0
770
+ }, i = de(r), a = ue(r);
771
+ return [
772
+ i.language,
773
+ i.language.data.of({ autocomplete: (e) => e.matchBefore(/[@:]\w*/) ? null : a(e) }),
774
+ i.language.data.of({ autocomplete: le(r.dialect, !0) }),
775
+ i.language.data.of({ autocomplete: oe([
776
+ "String",
777
+ "Comment",
778
+ "LineComment",
779
+ "BlockComment"
780
+ ], (e) => {
781
+ let t = e.matchBefore(/[@:]\w*/);
782
+ return t ? {
783
+ from: t.from,
784
+ options: (n.parameters ?? []).map((e) => ({
785
+ label: e,
786
+ type: "variable",
787
+ detail: "查询参数"
788
+ })),
789
+ validFor: /^[@:]\w*$/
790
+ } : null;
791
+ }) })
792
+ ];
793
+ }
794
+ // src/editors/theme.ts
795
+ var je = P.define([
796
+ {
797
+ tag: H.keyword,
798
+ color: "var(--ui-accent)",
799
+ fontWeight: "600"
800
+ },
801
+ {
802
+ tag: [H.string, H.special(H.string)],
803
+ color: "var(--ui-success)"
804
+ },
805
+ {
806
+ tag: [
807
+ H.number,
808
+ H.bool,
809
+ H.null
810
+ ],
811
+ color: "var(--ui-warning)"
812
+ },
813
+ {
814
+ tag: H.comment,
815
+ color: "var(--ui-text-muted)",
816
+ fontStyle: "italic"
817
+ },
818
+ {
819
+ tag: [H.operator, H.punctuation],
820
+ color: "var(--ui-text-secondary)"
821
+ },
822
+ {
823
+ tag: [
824
+ H.variableName,
825
+ H.propertyName,
826
+ H.typeName
827
+ ],
828
+ color: "var(--ui-text)"
829
+ }
830
+ ]);
831
+ function Q(e) {
832
+ return T.theme({
833
+ "&": {
834
+ height: "100%",
835
+ backgroundColor: "var(--ui-surface-subtle)",
836
+ color: "var(--ui-text)",
837
+ fontSize: "13px"
838
+ },
839
+ ".cm-scroller": {
840
+ overflow: "auto",
841
+ fontFamily: "var(--mono)",
842
+ lineHeight: "20px"
843
+ },
844
+ ".cm-content": {
845
+ padding: "10px 0",
846
+ caretColor: "var(--ui-accent)"
847
+ },
848
+ ".cm-line": { padding: "0 12px" },
849
+ ".cm-gutters": {
850
+ backgroundColor: "var(--ui-surface-subtle)",
851
+ borderRight: "1px solid var(--ui-border)",
852
+ color: "var(--ui-text-muted)",
853
+ minWidth: "32px"
854
+ },
855
+ ".cm-activeLine": { backgroundColor: e ? "rgba(255, 255, 255, 0.06)" : "rgba(79, 70, 229, 0.07)" },
856
+ ".cm-activeLineGutter": { backgroundColor: "var(--ui-control)" },
857
+ ".cm-selectionBackground, &.cm-focused .cm-selectionBackground": { backgroundColor: e ? "rgba(99, 102, 241, 0.35) !important" : "rgba(79, 70, 229, 0.22) !important" },
858
+ "::selection": { backgroundColor: e ? "rgba(99, 102, 241, 0.35)" : "rgba(79, 70, 229, 0.22)" },
859
+ "&.cm-focused": { outline: "none" },
860
+ ".cm-cursor": { borderLeftColor: "var(--ui-accent)" },
861
+ ".cm-tooltip": {
862
+ border: "1px solid var(--ui-border)",
863
+ backgroundColor: "var(--ui-surface)",
864
+ color: "var(--ui-text)",
865
+ borderRadius: "8px",
866
+ boxShadow: "var(--shadow)",
867
+ fontSize: "12px",
868
+ zIndex: "90"
869
+ },
870
+ ".cm-tooltip-autocomplete > ul": {
871
+ fontFamily: "var(--mono)",
872
+ maxHeight: "220px",
873
+ maxWidth: "min(360px,80vw)"
874
+ },
875
+ ".cm-tooltip-autocomplete > ul > li": { padding: "4px 10px" },
876
+ ".cm-tooltip-autocomplete > ul > li[aria-selected]": {
877
+ backgroundColor: "var(--ui-accent-soft)",
878
+ color: "var(--ui-accent)"
879
+ },
880
+ ".cm-completionDetail": {
881
+ fontFamily: "var(--font)",
882
+ color: "var(--ui-text-muted)"
883
+ },
884
+ ".cm-matchingBracket": {
885
+ backgroundColor: "var(--ui-accent-soft)",
886
+ outline: "1px solid var(--ui-accent)"
887
+ }
888
+ }, { dark: e });
889
+ }
890
+ // src/components/CodeEditor.vue
891
+ var $ = /* @__PURE__ */ f({
892
+ __name: "CodeEditor",
893
+ props: {
894
+ modelValue: { default: "" },
895
+ language: { default: "sql" },
896
+ dialect: { default: "sql" },
897
+ hints: { default: () => ({}) },
898
+ readonly: {
899
+ type: Boolean,
900
+ default: !1
901
+ },
902
+ dark: {
903
+ type: Boolean,
904
+ default: !1
905
+ },
906
+ label: { default: "代码编辑器" },
907
+ wrap: {
908
+ type: Boolean,
909
+ default: !1
910
+ }
911
+ },
912
+ emits: ["update:modelValue"],
913
+ setup(e, { expose: t, emit: n }) {
914
+ let r = e, i = n, a = _(), o, s = new C(), l = new C(), u = new C(), d = new C();
915
+ h(() => {
916
+ o = new T({
917
+ parent: a.value,
918
+ state: w.create({
919
+ doc: r.modelValue,
920
+ extensions: [
921
+ A(),
922
+ O(),
923
+ M(),
924
+ E(),
925
+ L(),
926
+ re(),
927
+ D(),
928
+ ne({ icons: !1 }),
929
+ w.phrases.of({
930
+ Completions: "代码提示",
931
+ "No completions": "没有匹配的提示"
932
+ }),
933
+ k.of([
934
+ {
935
+ key: "Tab",
936
+ run: te
937
+ },
938
+ ...ie,
939
+ ...ae,
940
+ ...j,
941
+ ...N
942
+ ]),
943
+ s.of(Z(r.language, r.dialect, r.hints)),
944
+ l.of(Q(r.dark)),
945
+ R(je),
946
+ u.of([w.readOnly.of(r.readonly), T.editable.of(!r.readonly)]),
947
+ d.of(r.wrap ? T.lineWrapping : []),
948
+ T.contentAttributes.of((e) => ({
949
+ "aria-label": r.label,
950
+ "aria-multiline": "true",
951
+ "aria-readonly": String(e.state.readOnly),
952
+ tabindex: "0"
953
+ })),
954
+ T.updateListener.of((e) => {
955
+ e.docChanged && i("update:modelValue", e.state.doc.toString());
956
+ })
957
+ ]
958
+ })
959
+ });
960
+ }), b(() => r.modelValue, (e) => {
961
+ o && e !== o.state.doc.toString() && o.dispatch({ changes: {
962
+ from: 0,
963
+ to: o.state.doc.length,
964
+ insert: e
965
+ } });
966
+ }), b(() => [
967
+ r.language,
968
+ r.dialect,
969
+ r.hints
970
+ ], () => o?.dispatch({ effects: s.reconfigure(Z(r.language, r.dialect, r.hints)) }), { deep: !0 }), b(() => r.dark, (e) => o?.dispatch({ effects: l.reconfigure(Q(e)) })), b(() => r.readonly, (e) => o?.dispatch({ effects: u.reconfigure([w.readOnly.of(e), T.editable.of(!e)]) })), b(() => r.wrap, (e) => o?.dispatch({ effects: d.reconfigure(e ? T.lineWrapping : []) })), m(() => o?.destroy());
971
+ function f(e) {
972
+ if (r.readonly || !e) return;
973
+ if (!o) {
974
+ i("update:modelValue", `${r.modelValue}${e}`);
975
+ return;
976
+ }
977
+ let { from: t, to: n } = o.state.selection.main;
978
+ o.dispatch({
979
+ changes: {
980
+ from: t,
981
+ to: n,
982
+ insert: e
983
+ },
984
+ selection: { anchor: t + e.length }
985
+ }), o.focus();
986
+ }
987
+ function v(e) {
988
+ r.readonly || (o ? (o.dispatch({
989
+ changes: {
990
+ from: 0,
991
+ to: o.state.doc.length,
992
+ insert: e
993
+ },
994
+ selection: { anchor: e.length }
995
+ }), o.focus()) : i("update:modelValue", e));
996
+ }
997
+ return t({
998
+ insertText: f,
999
+ replaceText: v
1000
+ }), (t, n) => (g(), c("div", {
1001
+ ref_key: "host",
1002
+ ref: a,
1003
+ class: p(["code-editor selectable", { "is-readonly": e.readonly }])
1004
+ }, null, 2));
1005
+ }
1006
+ }), Me = { class: "code-editor-field" }, Ne = { class: "code-field-heading-actions" }, Pe = ["aria-label"], Fe = { class: "code-field-footer" }, Ie = { class: "code-wrap-toggle" }, Le = { class: "code-dialog-workspace" }, Re = {
1007
+ key: 0,
1008
+ class: "code-dialog-side"
1009
+ }, ze = { class: "code-hint" }, Be = { class: "code-dialog-footer-actions" }, Ve = { class: "code-wrap-toggle" }, He = "winm-code-editor-wrap", Ue = /* @__PURE__ */ f({
1010
+ __name: "ExpandableCodeEditor",
1011
+ props: {
1012
+ modelValue: { default: "" },
1013
+ title: {},
1014
+ language: { default: "sql" },
1015
+ dialect: { default: "sql" },
1016
+ hints: { default: () => ({}) },
1017
+ dark: {
1018
+ type: Boolean,
1019
+ default: void 0
1020
+ },
1021
+ readonly: {
1022
+ type: Boolean,
1023
+ default: !1
1024
+ },
1025
+ hideTitle: {
1026
+ type: Boolean,
1027
+ default: !1
1028
+ },
1029
+ headingClass: { default: "" },
1030
+ editorClass: { default: "" },
1031
+ editorId: { default: void 0 },
1032
+ inlineLabel: { default: void 0 },
1033
+ dialogLabel: { default: void 0 },
1034
+ dialogCodeLabel: { default: void 0 },
1035
+ expandLabel: { default: void 0 },
1036
+ closeLabel: { default: void 0 },
1037
+ dialogHint: { default: "关键字与上下文代码提示" }
1038
+ },
1039
+ emits: ["update:modelValue"],
1040
+ setup(f, { expose: m, emit: h }) {
1041
+ function C() {
1042
+ try {
1043
+ return typeof localStorage < "u" && localStorage.getItem(He) === "1";
1044
+ } catch {
1045
+ return !1;
1046
+ }
1047
+ }
1048
+ let w = f, T = h, E = _(), D = _(!1), O = _(), k = _(), A = _(C());
1049
+ b(A, (e) => {
1050
+ try {
1051
+ typeof localStorage < "u" && localStorage.setItem(He, e ? "1" : "0");
1052
+ } catch {}
1053
+ });
1054
+ let j = o({
1055
+ get: () => w.modelValue ?? "",
1056
+ set: (e) => T("update:modelValue", e)
1057
+ }), M = i(), N = o(() => e(w.dark, M?.dark, !1)), P = o(() => !!(w.readonly || e(void 0, M?.readonly, !1)));
1058
+ b(P, (e) => {
1059
+ e && I();
1060
+ });
1061
+ function F() {
1062
+ D.value = !0, E.value?.openModal();
1063
+ }
1064
+ function I() {
1065
+ D.value = !1, E.value?.closeModal();
1066
+ }
1067
+ function L() {
1068
+ return D.value ? k.value : O.value;
1069
+ }
1070
+ function R(e) {
1071
+ L()?.insertText(e);
1072
+ }
1073
+ function z(e) {
1074
+ L()?.replaceText(e);
1075
+ }
1076
+ return m({
1077
+ wordWrap: A,
1078
+ openExpanded: F,
1079
+ closeExpanded: I,
1080
+ insertText: R,
1081
+ replaceText: z
1082
+ }), (e, i) => (g(), c("div", Me, [
1083
+ l("div", { class: p(["code-field-heading", { "only-actions": f.hideTitle }]) }, [f.hideTitle ? s("", !0) : (g(), c("span", {
1084
+ key: 0,
1085
+ class: p(f.headingClass)
1086
+ }, ee(f.title), 3)), l("div", Ne, [v(e.$slots, "heading-actions"), S((g(), c("button", {
1087
+ type: "button",
1088
+ class: "icon-button",
1089
+ "aria-label": f.expandLabel ?? `展开${f.title}编辑器`,
1090
+ onClick: F
1091
+ }, [d(t, {
1092
+ name: "expand",
1093
+ size: 15
1094
+ })], 8, Pe)), [[y(n), "展开编辑"]])])], 2),
1095
+ d($, {
1096
+ ref_key: "inlineEditor",
1097
+ ref: O,
1098
+ id: f.editorId,
1099
+ class: p(f.editorClass),
1100
+ modelValue: j.value,
1101
+ "onUpdate:modelValue": i[0] ||= (e) => j.value = e,
1102
+ language: f.language,
1103
+ dialect: f.dialect,
1104
+ hints: f.hints,
1105
+ dark: N.value,
1106
+ readonly: P.value,
1107
+ wrap: A.value,
1108
+ label: f.inlineLabel ?? f.title
1109
+ }, null, 8, [
1110
+ "id",
1111
+ "class",
1112
+ "modelValue",
1113
+ "language",
1114
+ "dialect",
1115
+ "hints",
1116
+ "dark",
1117
+ "readonly",
1118
+ "wrap",
1119
+ "label"
1120
+ ]),
1121
+ l("div", Fe, [i[7] ||= l("p", { class: "code-hint" }, [
1122
+ l("kbd", { class: "ui-kbd" }, "Ctrl"),
1123
+ u(" + "),
1124
+ l("kbd", { class: "ui-kbd" }, "Space"),
1125
+ u(" 代码提示")
1126
+ ], -1), S((g(), c("label", Ie, [d(a, {
1127
+ enabled: A.value,
1128
+ label: "自动换行",
1129
+ tooltip: A.value ? "关闭自动换行" : "开启自动换行",
1130
+ onChange: i[1] ||= (e) => A.value = !A.value
1131
+ }, null, 8, ["enabled", "tooltip"]), i[6] ||= l("span", null, "自动换行", -1)])), [[y(n), A.value ? "关闭自动换行" : "开启自动换行"]])]),
1132
+ v(e.$slots, "below"),
1133
+ d(r, {
1134
+ ref_key: "expandedModal",
1135
+ ref: E,
1136
+ open: D.value,
1137
+ "onUpdate:open": i[4] ||= (e) => D.value = e,
1138
+ "modal-class": e.$slots["dialog-side"] ? "code-dialog has-side" : "code-dialog",
1139
+ "body-class": "code-dialog-body",
1140
+ title: f.title,
1141
+ "aria-label": f.dialogLabel ?? `${f.title}编辑器`,
1142
+ "close-label": f.closeLabel ?? `关闭${f.title}编辑器`,
1143
+ onClose: i[5] ||= (e) => D.value = !1
1144
+ }, {
1145
+ "before-footer": x(() => [v(e.$slots, "dialog-below")]),
1146
+ footer: x(() => [l("span", ze, ee(f.dialogHint), 1), l("div", Be, [
1147
+ S((g(), c("label", Ve, [d(a, {
1148
+ enabled: A.value,
1149
+ label: "自动换行",
1150
+ tooltip: A.value ? "关闭自动换行" : "开启自动换行",
1151
+ onChange: i[3] ||= (e) => A.value = !A.value
1152
+ }, null, 8, ["enabled", "tooltip"]), i[8] ||= l("span", null, "自动换行", -1)])), [[y(n), A.value ? "关闭自动换行" : "开启自动换行"]]),
1153
+ v(e.$slots, "dialog-actions"),
1154
+ l("button", {
1155
+ type: "button",
1156
+ class: "button primary",
1157
+ onClick: I
1158
+ }, " 完成 ")
1159
+ ])]),
1160
+ default: x(() => [l("div", Le, [d($, {
1161
+ ref_key: "dialogEditor",
1162
+ ref: k,
1163
+ modelValue: j.value,
1164
+ "onUpdate:modelValue": i[2] ||= (e) => j.value = e,
1165
+ language: f.language,
1166
+ dialect: f.dialect,
1167
+ hints: f.hints,
1168
+ dark: N.value,
1169
+ readonly: P.value,
1170
+ wrap: A.value,
1171
+ label: f.dialogCodeLabel ?? `展开的${f.title}`
1172
+ }, null, 8, [
1173
+ "modelValue",
1174
+ "language",
1175
+ "dialect",
1176
+ "hints",
1177
+ "dark",
1178
+ "readonly",
1179
+ "wrap",
1180
+ "label"
1181
+ ]), e.$slots["dialog-side"] ? (g(), c("aside", Re, [v(e.$slots, "dialog-side")])) : s("", !0)])]),
1182
+ _: 3
1183
+ }, 8, [
1184
+ "open",
1185
+ "modal-class",
1186
+ "title",
1187
+ "aria-label",
1188
+ "close-label"
1189
+ ])
1190
+ ]));
1191
+ }
1192
+ }), We = /* @__PURE__ */ new Map([
1193
+ ["fetch", "脚本运行在离线沙箱中,禁止调用 fetch 发起网络请求"],
1194
+ ["XMLHttpRequest", "脚本运行在离线沙箱中,禁止使用 XMLHttpRequest"],
1195
+ ["WebSocket", "脚本运行在离线沙箱中,禁止使用 WebSocket"],
1196
+ ["require", "脚本运行在离线沙箱中,不支持 require 动态加载模块"],
1197
+ ["console", "沙箱中 console 不会输出到任务日志,请通过 return 返回结果或 throw new Error(...) 报错"],
1198
+ ["process", "脚本运行在独立 JS 沙箱中,不存在 Node.js process 对象"],
1199
+ ["window", "脚本运行在独立 JS 沙箱中,不存在浏览器 window 对象"],
1200
+ ["document", "脚本运行在独立 JS 沙箱中,不存在浏览器 document 对象"],
1201
+ ["globalThis", "请直接使用 input 或标准内置对象,避免依赖宿主 globalThis"],
1202
+ ["setTimeout", "处理脚本仅支持同步执行,不支持 setTimeout"],
1203
+ ["setInterval", "处理脚本仅支持同步执行,不支持 setInterval"]
1204
+ ]), Ge = /* @__PURE__ */ new Set([
1205
+ "FunctionDeclaration",
1206
+ "FunctionExpression",
1207
+ "ArrowFunction",
1208
+ "MethodDeclaration"
1209
+ ]);
1210
+ function Ke(e) {
1211
+ let t = [0];
1212
+ for (let n = 0; n < e.length; n += 1) e.charCodeAt(n) === 10 && t.push(n + 1);
1213
+ return t;
1214
+ }
1215
+ function qe(e, t) {
1216
+ let n = 0, r = e.length - 1;
1217
+ for (; n <= r;) {
1218
+ let i = n + r >> 1;
1219
+ e[i] <= t ? n = i + 1 : r = i - 1;
1220
+ }
1221
+ return Math.max(1, r + 1);
1222
+ }
1223
+ function Je(e) {
1224
+ if (!e.trim()) return [];
1225
+ let t = V.parser.parse(e), n = Ke(e), r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = 0, s = !1, c = !1, l = (e) => {
1226
+ let t = `${e.level}:${e.line ?? 0}:${e.message}`;
1227
+ i.has(t) || (i.add(t), r.push(e));
1228
+ };
1229
+ return t.iterate({
1230
+ enter(t) {
1231
+ let r = qe(n, t.from);
1232
+ if (t.type.isError) c = !0, l({
1233
+ level: "error",
1234
+ line: r,
1235
+ message: `第 ${r} 行附近存在语法错误,请检查括号、引号或语句分隔`
1236
+ });
1237
+ else if (Ge.has(t.name)) o += 1;
1238
+ else if (t.name === "ReturnStatement" && o === 0) s = !0;
1239
+ else if (t.name === "VariableDefinition") a.add(e.slice(t.from, t.to));
1240
+ else if (t.name === "ImportDeclaration" || t.name === "DynamicImport" || t.name === "import") l({
1241
+ level: "error",
1242
+ line: r,
1243
+ message: `第 ${r} 行:脚本运行在离线沙箱中,不支持 import 导入模块`
1244
+ });
1245
+ else if (t.name === "ExportDeclaration") l({
1246
+ level: "error",
1247
+ line: r,
1248
+ message: `第 ${r} 行:请使用 return 返回结果,不支持 export 导出`
1249
+ });
1250
+ else if (t.name === "AwaitExpression" || t.name === "async") l({
1251
+ level: "error",
1252
+ line: r,
1253
+ message: `第 ${r} 行:处理脚本仅支持同步执行,不支持 async / await`
1254
+ });
1255
+ else if (t.name === "VariableName") {
1256
+ let n = e.slice(t.from, t.to), i = We.get(n);
1257
+ i && !a.has(n) && l({
1258
+ level: n === "console" || n === "globalThis" ? "warning" : "error",
1259
+ line: r,
1260
+ message: `第 ${r} 行:${i}`
1261
+ });
1262
+ }
1263
+ },
1264
+ leave(e) {
1265
+ Ge.has(e.name) && (o = Math.max(0, o - 1));
1266
+ }
1267
+ }), !c && !s && l({
1268
+ level: "warning",
1269
+ message: "脚本缺少顶层 return 语句,执行结果将为空"
1270
+ }), r.slice(0, 6);
1271
+ }
1272
+ export { $ as CodeEditor, Ue as ExpandableCodeEditor, Je as analyzeScript, Ce as formatFieldAccess, Z as languageExtensions, X as scriptCompletionSource };