princess-python-editor 0.2.0 → 0.3.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/dist/index.es.js CHANGED
@@ -1,24 +1,24 @@
1
- var Ps = Object.defineProperty;
2
- var Os = (a, n, s) => n in a ? Ps(a, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[n] = s;
3
- var ae = (a, n, s) => Os(a, typeof n != "symbol" ? n + "" : n, s);
4
- import { h as Dn, defineComponent as Ms, ref as C, reactive as zn, computed as U, onMounted as Ns, onBeforeUnmount as Ts, watch as oe, nextTick as jn, openBlock as m, createElementBlock as g, normalizeStyle as Vn, normalizeClass as ie, createElementVNode as l, createVNode as j, unref as B, createCommentVNode as N, createBlock as Qn, withDirectives as J, vModelText as he, Fragment as A, toDisplayString as _, renderList as le, vModelSelect as St, withModifiers as Kn, withKeys as Ls, createTextVNode as Qt, onScopeDispose as $s } from "vue";
5
- import { EditorState as Yt, StateEffect as Fs, StateField as Rs, Compartment as Kt } from "@codemirror/state";
6
- import { EditorView as $e, keymap as Jn, lineNumbers as _s, highlightActiveLineGutter as Is, highlightActiveLine as Hs, drawSelection as Bs, placeholder as Us, Decoration as Xt } from "@codemirror/view";
7
- import { linter as As, forceLinting as Ds } from "@codemirror/lint";
8
- import { autocompletion as zs, closeBrackets as js, closeBracketsKeymap as Vs } from "@codemirror/autocomplete";
9
- import { history as Qs, defaultKeymap as Ks, historyKeymap as Js, indentWithTab as Zs } from "@codemirror/commands";
10
- import { syntaxHighlighting as Gs, HighlightStyle as Ws, indentUnit as Ys, bracketMatching as Xs } from "@codemirror/language";
11
- import { python as pr } from "@codemirror/lang-python";
12
- import { javascript as ea } from "@codemirror/lang-javascript";
13
- import { json as ta } from "@codemirror/lang-json";
14
- import { sql as na } from "@codemirror/lang-sql";
15
- let ra = 0;
1
+ var Na = Object.defineProperty;
2
+ var La = (s, n, a) => n in s ? Na(s, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[n] = a;
3
+ var ie = (s, n, a) => La(s, typeof n != "symbol" ? n + "" : n, a);
4
+ import { h as Kn, defineComponent as $a, ref as C, reactive as Jn, computed as U, onMounted as Fa, onBeforeUnmount as _a, watch as ee, nextTick as Zn, openBlock as m, createElementBlock as g, normalizeStyle as Gn, normalizeClass as le, createElementVNode as l, createVNode as V, unref as B, createCommentVNode as T, createBlock as Wn, withDirectives as J, vModelText as he, Fragment as A, renderList as te, toDisplayString as R, vModelSelect as Et, withModifiers as Yn, withKeys as Ra, createTextVNode as Wt, onScopeDispose as Ia } from "vue";
5
+ import { EditorState as nn, StateEffect as Ha, StateField as Ba, Compartment as qt } from "@codemirror/state";
6
+ import { EditorView as $e, keymap as Xn, lineNumbers as Ua, highlightActiveLineGutter as Aa, highlightActiveLine as Da, drawSelection as za, placeholder as ja, Decoration as rn } from "@codemirror/view";
7
+ import { linter as Va, forceLinting as Qa } from "@codemirror/lint";
8
+ import { autocompletion as Ka, closeBrackets as Ja, closeBracketsKeymap as Za } from "@codemirror/autocomplete";
9
+ import { history as Ga, defaultKeymap as Wa, historyKeymap as Ya, indentWithTab as Xa } from "@codemirror/commands";
10
+ import { syntaxHighlighting as es, HighlightStyle as ts, indentUnit as ns, bracketMatching as rs } from "@codemirror/language";
11
+ import { python as mr } from "@codemirror/lang-python";
12
+ import { javascript as as } from "@codemirror/lang-javascript";
13
+ import { json as ss } from "@codemirror/lang-json";
14
+ import { sql as os } from "@codemirror/lang-sql";
15
+ let is = 0;
16
16
  class K {
17
17
  /**
18
18
  Create a new node prop type.
19
19
  */
20
20
  constructor(n = {}) {
21
- this.id = ra++, this.perNode = !!n.perNode, this.deserialize = n.deserialize || (() => {
21
+ this.id = is++, this.perNode = !!n.perNode, this.deserialize = n.deserialize || (() => {
22
22
  throw new Error("This node type doesn't define a deserialize function");
23
23
  }), this.combine = n.combine || null;
24
24
  }
@@ -34,42 +34,42 @@ class K {
34
34
  add(n) {
35
35
  if (this.perNode)
36
36
  throw new RangeError("Can't add per-node props to node types");
37
- return typeof n != "function" && (n = ct.match(n)), (s) => {
38
- let o = n(s);
37
+ return typeof n != "function" && (n = pt.match(n)), (a) => {
38
+ let o = n(a);
39
39
  return o === void 0 ? null : [this, o];
40
40
  };
41
41
  }
42
42
  }
43
- K.closedBy = new K({ deserialize: (a) => a.split(" ") });
44
- K.openedBy = new K({ deserialize: (a) => a.split(" ") });
45
- K.group = new K({ deserialize: (a) => a.split(" ") });
46
- K.isolate = new K({ deserialize: (a) => {
47
- if (a && a != "rtl" && a != "ltr" && a != "auto")
48
- throw new RangeError("Invalid value for isolate: " + a);
49
- return a || "auto";
43
+ K.closedBy = new K({ deserialize: (s) => s.split(" ") });
44
+ K.openedBy = new K({ deserialize: (s) => s.split(" ") });
45
+ K.group = new K({ deserialize: (s) => s.split(" ") });
46
+ K.isolate = new K({ deserialize: (s) => {
47
+ if (s && s != "rtl" && s != "ltr" && s != "auto")
48
+ throw new RangeError("Invalid value for isolate: " + s);
49
+ return s || "auto";
50
50
  } });
51
51
  K.contextHash = new K({ perNode: !0 });
52
52
  K.lookAhead = new K({ perNode: !0 });
53
53
  K.mounted = new K({ perNode: !0 });
54
- const sa = /* @__PURE__ */ Object.create(null);
55
- class ct {
54
+ const ls = /* @__PURE__ */ Object.create(null);
55
+ class pt {
56
56
  /**
57
57
  @internal
58
58
  */
59
- constructor(n, s, o, i = 0) {
60
- this.name = n, this.props = s, this.id = o, this.flags = i;
59
+ constructor(n, a, o, i = 0) {
60
+ this.name = n, this.props = a, this.id = o, this.flags = i;
61
61
  }
62
62
  /**
63
63
  Define a node type.
64
64
  */
65
65
  static define(n) {
66
- let s = n.props && n.props.length ? /* @__PURE__ */ Object.create(null) : sa, o = (n.top ? 1 : 0) | (n.skipped ? 2 : 0) | (n.error ? 4 : 0) | (n.name == null ? 8 : 0), i = new ct(n.name || "", s, n.id, o);
66
+ let a = n.props && n.props.length ? /* @__PURE__ */ Object.create(null) : ls, o = (n.top ? 1 : 0) | (n.skipped ? 2 : 0) | (n.error ? 4 : 0) | (n.name == null ? 8 : 0), i = new pt(n.name || "", a, n.id, o);
67
67
  if (n.props) {
68
68
  for (let p of n.props)
69
69
  if (Array.isArray(p) || (p = p(i)), p) {
70
70
  if (p[0].perNode)
71
71
  throw new RangeError("Can't store a per-node prop on a node type");
72
- s[p[0].id] = p[1];
72
+ a[p[0].id] = p[1];
73
73
  }
74
74
  }
75
75
  return i;
@@ -114,8 +114,8 @@ class ct {
114
114
  if (typeof n == "string") {
115
115
  if (this.name == n)
116
116
  return !0;
117
- let s = this.prop(K.group);
118
- return s ? s.indexOf(n) > -1 : !1;
117
+ let a = this.prop(K.group);
118
+ return a ? a.indexOf(n) > -1 : !1;
119
119
  }
120
120
  return this.id == n;
121
121
  }
@@ -128,52 +128,52 @@ class ct {
128
128
  multiple node names to a single value.
129
129
  */
130
130
  static match(n) {
131
- let s = /* @__PURE__ */ Object.create(null);
131
+ let a = /* @__PURE__ */ Object.create(null);
132
132
  for (let o in n)
133
133
  for (let i of o.split(" "))
134
- s[i] = n[o];
134
+ a[i] = n[o];
135
135
  return (o) => {
136
136
  for (let i = o.prop(K.group), p = -1; p < (i ? i.length : 0); p++) {
137
- let b = s[p < 0 ? o.name : i[p]];
137
+ let b = a[p < 0 ? o.name : i[p]];
138
138
  if (b)
139
139
  return b;
140
140
  }
141
141
  };
142
142
  }
143
143
  }
144
- ct.none = new ct(
144
+ pt.none = new pt(
145
145
  "",
146
146
  /* @__PURE__ */ Object.create(null),
147
147
  0,
148
148
  8
149
149
  /* NodeFlag.Anonymous */
150
150
  );
151
- var Zn;
152
- (function(a) {
153
- a[a.ExcludeBuffers = 1] = "ExcludeBuffers", a[a.IncludeAnonymous = 2] = "IncludeAnonymous", a[a.IgnoreMounts = 4] = "IgnoreMounts", a[a.IgnoreOverlays = 8] = "IgnoreOverlays", a[a.EnterBracketed = 16] = "EnterBracketed";
154
- })(Zn || (Zn = {}));
151
+ var er;
152
+ (function(s) {
153
+ s[s.ExcludeBuffers = 1] = "ExcludeBuffers", s[s.IncludeAnonymous = 2] = "IncludeAnonymous", s[s.IgnoreMounts = 4] = "IgnoreMounts", s[s.IgnoreOverlays = 8] = "IgnoreOverlays", s[s.EnterBracketed = 16] = "EnterBracketed";
154
+ })(er || (er = {}));
155
155
  new K({ perNode: !0 });
156
- let aa = 0;
156
+ let us = 0;
157
157
  class ue {
158
158
  /**
159
159
  @internal
160
160
  */
161
- constructor(n, s, o, i) {
162
- this.name = n, this.set = s, this.base = o, this.modified = i, this.id = aa++;
161
+ constructor(n, a, o, i) {
162
+ this.name = n, this.set = a, this.base = o, this.modified = i, this.id = us++;
163
163
  }
164
164
  toString() {
165
165
  let { name: n } = this;
166
- for (let s of this.modified)
167
- s.name && (n = `${s.name}(${n})`);
166
+ for (let a of this.modified)
167
+ a.name && (n = `${a.name}(${n})`);
168
168
  return n;
169
169
  }
170
- static define(n, s) {
170
+ static define(n, a) {
171
171
  let o = typeof n == "string" ? n : "?";
172
- if (n instanceof ue && (s = n), s != null && s.base)
172
+ if (n instanceof ue && (a = n), a != null && a.base)
173
173
  throw new Error("Can not derive from a modified tag");
174
174
  let i = new ue(o, [], null, []);
175
- if (i.set.push(i), s)
176
- for (let p of s.set)
175
+ if (i.set.push(i), a)
176
+ for (let p of a.set)
177
177
  i.set.push(p);
178
178
  return i;
179
179
  }
@@ -190,57 +190,57 @@ class ue {
190
190
  `m1(m3(t1)`, and so on.
191
191
  */
192
192
  static defineModifier(n) {
193
- let s = new Pt(n);
194
- return (o) => o.modified.indexOf(s) > -1 ? o : Pt.get(o.base || o, o.modified.concat(s).sort((i, p) => i.id - p.id));
193
+ let a = new Nt(n);
194
+ return (o) => o.modified.indexOf(a) > -1 ? o : Nt.get(o.base || o, o.modified.concat(a).sort((i, p) => i.id - p.id));
195
195
  }
196
196
  }
197
- let oa = 0;
198
- class Pt {
197
+ let cs = 0;
198
+ class Nt {
199
199
  constructor(n) {
200
- this.name = n, this.instances = [], this.id = oa++;
200
+ this.name = n, this.instances = [], this.id = cs++;
201
201
  }
202
- static get(n, s) {
203
- if (!s.length)
202
+ static get(n, a) {
203
+ if (!a.length)
204
204
  return n;
205
- let o = s[0].instances.find((E) => E.base == n && ia(s, E.modified));
205
+ let o = a[0].instances.find((E) => E.base == n && ds(a, E.modified));
206
206
  if (o)
207
207
  return o;
208
- let i = [], p = new ue(n.name, i, n, s);
209
- for (let E of s)
208
+ let i = [], p = new ue(n.name, i, n, a);
209
+ for (let E of a)
210
210
  E.instances.push(p);
211
- let b = la(s);
211
+ let b = ps(a);
212
212
  for (let E of n.set)
213
213
  if (!E.modified.length)
214
- for (let R of b)
215
- i.push(Pt.get(E, R));
214
+ for (let _ of b)
215
+ i.push(Nt.get(E, _));
216
216
  return p;
217
217
  }
218
218
  }
219
- function ia(a, n) {
220
- return a.length == n.length && a.every((s, o) => s == n[o]);
219
+ function ds(s, n) {
220
+ return s.length == n.length && s.every((a, o) => a == n[o]);
221
221
  }
222
- function la(a) {
222
+ function ps(s) {
223
223
  let n = [[]];
224
- for (let s = 0; s < a.length; s++)
224
+ for (let a = 0; a < s.length; a++)
225
225
  for (let o = 0, i = n.length; o < i; o++)
226
- n.push(n[o].concat(a[s]));
227
- return n.sort((s, o) => o.length - s.length);
226
+ n.push(n[o].concat(s[a]));
227
+ return n.sort((a, o) => o.length - a.length);
228
228
  }
229
229
  new K({
230
- combine(a, n) {
231
- let s, o, i;
232
- for (; a || n; ) {
233
- if (!a || n && a.depth <= n.depth ? (i = n, n = n.next) : (i = a, a = a.next), s && s.mode == i.mode && !i.context && !s.context)
230
+ combine(s, n) {
231
+ let a, o, i;
232
+ for (; s || n; ) {
233
+ if (!s || n && s.depth <= n.depth ? (i = n, n = n.next) : (i = s, s = s.next), a && a.mode == i.mode && !i.context && !a.context)
234
234
  continue;
235
- let p = new en(i.tags, i.mode, i.context);
236
- s ? s.next = p : o = p, s = p;
235
+ let p = new an(i.tags, i.mode, i.context);
236
+ a ? a.next = p : o = p, a = p;
237
237
  }
238
238
  return o;
239
239
  }
240
240
  });
241
- class en {
242
- constructor(n, s, o, i) {
243
- this.tags = n, this.mode = s, this.context = o, this.next = i;
241
+ class an {
242
+ constructor(n, a, o, i) {
243
+ this.tags = n, this.mode = a, this.context = o, this.next = i;
244
244
  }
245
245
  get opaque() {
246
246
  return this.mode == 0;
@@ -255,24 +255,24 @@ class en {
255
255
  return this.context ? this.context.length : 0;
256
256
  }
257
257
  }
258
- en.empty = new en([], 2, null);
259
- function ua(a, n) {
260
- let s = /* @__PURE__ */ Object.create(null);
261
- for (let p of a)
258
+ an.empty = new an([], 2, null);
259
+ function fs(s, n) {
260
+ let a = /* @__PURE__ */ Object.create(null);
261
+ for (let p of s)
262
262
  if (!Array.isArray(p.tag))
263
- s[p.tag.id] = p.class;
263
+ a[p.tag.id] = p.class;
264
264
  else
265
265
  for (let b of p.tag)
266
- s[b.id] = p.class;
266
+ a[b.id] = p.class;
267
267
  let { scope: o, all: i = null } = {};
268
268
  return {
269
269
  style: (p) => {
270
270
  let b = i;
271
271
  for (let E of p)
272
- for (let R of E.set) {
273
- let P = s[R.id];
274
- if (P) {
275
- b = b ? b + " " + P : P;
272
+ for (let _ of E.set) {
273
+ let O = a[_.id];
274
+ if (O) {
275
+ b = b ? b + " " + O : O;
276
276
  break;
277
277
  }
278
278
  }
@@ -281,63 +281,63 @@ function ua(a, n) {
281
281
  scope: o
282
282
  };
283
283
  }
284
- const v = ue.define, xt = v(), Te = v(), Gn = v(Te), Wn = v(Te), Le = v(), Et = v(Le), Jt = v(Le), we = v(), Be = v(we), be = v(), ke = v(), tn = v(), it = v(tn), qt = v(), d = {
284
+ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt = v(Le), Yt = v(Le), we = v(), Be = v(we), be = v(), ke = v(), sn = v(), lt = v(sn), Ot = v(), d = {
285
285
  /**
286
286
  A comment.
287
287
  */
288
- comment: xt,
288
+ comment: Ct,
289
289
  /**
290
290
  A line [comment](#highlight.tags.comment).
291
291
  */
292
- lineComment: v(xt),
292
+ lineComment: v(Ct),
293
293
  /**
294
294
  A block [comment](#highlight.tags.comment).
295
295
  */
296
- blockComment: v(xt),
296
+ blockComment: v(Ct),
297
297
  /**
298
298
  A documentation [comment](#highlight.tags.comment).
299
299
  */
300
- docComment: v(xt),
300
+ docComment: v(Ct),
301
301
  /**
302
302
  Any kind of identifier.
303
303
  */
304
- name: Te,
304
+ name: Ne,
305
305
  /**
306
306
  The [name](#highlight.tags.name) of a variable.
307
307
  */
308
- variableName: v(Te),
308
+ variableName: v(Ne),
309
309
  /**
310
310
  A type [name](#highlight.tags.name).
311
311
  */
312
- typeName: Gn,
312
+ typeName: tr,
313
313
  /**
314
314
  A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
315
315
  */
316
- tagName: v(Gn),
316
+ tagName: v(tr),
317
317
  /**
318
318
  A property or field [name](#highlight.tags.name).
319
319
  */
320
- propertyName: Wn,
320
+ propertyName: nr,
321
321
  /**
322
322
  An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
323
323
  */
324
- attributeName: v(Wn),
324
+ attributeName: v(nr),
325
325
  /**
326
326
  The [name](#highlight.tags.name) of a class.
327
327
  */
328
- className: v(Te),
328
+ className: v(Ne),
329
329
  /**
330
330
  A label [name](#highlight.tags.name).
331
331
  */
332
- labelName: v(Te),
332
+ labelName: v(Ne),
333
333
  /**
334
334
  A namespace [name](#highlight.tags.name).
335
335
  */
336
- namespace: v(Te),
336
+ namespace: v(Ne),
337
337
  /**
338
338
  The [name](#highlight.tags.name) of a macro.
339
339
  */
340
- macroName: v(Te),
340
+ macroName: v(Ne),
341
341
  /**
342
342
  A literal value.
343
343
  */
@@ -345,31 +345,31 @@ const v = ue.define, xt = v(), Te = v(), Gn = v(Te), Wn = v(Te), Le = v(), Et =
345
345
  /**
346
346
  A string [literal](#highlight.tags.literal).
347
347
  */
348
- string: Et,
348
+ string: Pt,
349
349
  /**
350
350
  A documentation [string](#highlight.tags.string).
351
351
  */
352
- docString: v(Et),
352
+ docString: v(Pt),
353
353
  /**
354
354
  A character literal (subtag of [string](#highlight.tags.string)).
355
355
  */
356
- character: v(Et),
356
+ character: v(Pt),
357
357
  /**
358
358
  An attribute value (subtag of [string](#highlight.tags.string)).
359
359
  */
360
- attributeValue: v(Et),
360
+ attributeValue: v(Pt),
361
361
  /**
362
362
  A number [literal](#highlight.tags.literal).
363
363
  */
364
- number: Jt,
364
+ number: Yt,
365
365
  /**
366
366
  An integer [number](#highlight.tags.number) literal.
367
367
  */
368
- integer: v(Jt),
368
+ integer: v(Yt),
369
369
  /**
370
370
  A floating-point [number](#highlight.tags.number) literal.
371
371
  */
372
- float: v(Jt),
372
+ float: v(Yt),
373
373
  /**
374
374
  A boolean [literal](#highlight.tags.literal).
375
375
  */
@@ -476,36 +476,36 @@ const v = ue.define, xt = v(), Te = v(), Gn = v(Te), Wn = v(Te), Le = v(), Et =
476
476
  /**
477
477
  Program or markup punctuation.
478
478
  */
479
- punctuation: tn,
479
+ punctuation: sn,
480
480
  /**
481
481
  [Punctuation](#highlight.tags.punctuation) that separates
482
482
  things.
483
483
  */
484
- separator: v(tn),
484
+ separator: v(sn),
485
485
  /**
486
486
  Bracket-style [punctuation](#highlight.tags.punctuation).
487
487
  */
488
- bracket: it,
488
+ bracket: lt,
489
489
  /**
490
490
  Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
491
491
  tokens).
492
492
  */
493
- angleBracket: v(it),
493
+ angleBracket: v(lt),
494
494
  /**
495
495
  Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
496
496
  tokens).
497
497
  */
498
- squareBracket: v(it),
498
+ squareBracket: v(lt),
499
499
  /**
500
500
  Parentheses (usually `(` and `)` tokens). Subtag of
501
501
  [bracket](#highlight.tags.bracket).
502
502
  */
503
- paren: v(it),
503
+ paren: v(lt),
504
504
  /**
505
505
  Braces (usually `{` and `}` tokens). Subtag of
506
506
  [bracket](#highlight.tags.bracket).
507
507
  */
508
- brace: v(it),
508
+ brace: v(lt),
509
509
  /**
510
510
  Content, for example plain text in XML or markup documents.
511
511
  */
@@ -591,22 +591,22 @@ const v = ue.define, xt = v(), Te = v(), Gn = v(Te), Wn = v(Te), Le = v(), Et =
591
591
  /**
592
592
  Metadata or meta-instruction.
593
593
  */
594
- meta: qt,
594
+ meta: Ot,
595
595
  /**
596
596
  [Metadata](#highlight.tags.meta) that applies to the entire
597
597
  document.
598
598
  */
599
- documentMeta: v(qt),
599
+ documentMeta: v(Ot),
600
600
  /**
601
601
  [Metadata](#highlight.tags.meta) that annotates or adds
602
602
  attributes to a given syntactic element.
603
603
  */
604
- annotation: v(qt),
604
+ annotation: v(Ot),
605
605
  /**
606
606
  Processing instruction or preprocessor directive. Subtag of
607
607
  [meta](#highlight.tags.meta).
608
608
  */
609
- processingInstruction: v(qt),
609
+ processingInstruction: v(Ot),
610
610
  /**
611
611
  [Modifier](#highlight.Tag^defineModifier) that indicates that a
612
612
  given element is being defined. Expected to be used with the
@@ -647,11 +647,11 @@ const v = ue.define, xt = v(), Te = v(), Gn = v(Te), Wn = v(Te), Le = v(), Et =
647
647
  */
648
648
  special: ue.defineModifier("special")
649
649
  };
650
- for (let a in d) {
651
- let n = d[a];
652
- n instanceof ue && (n.name = a);
650
+ for (let s in d) {
651
+ let n = d[s];
652
+ n instanceof ue && (n.name = s);
653
653
  }
654
- ua([
654
+ fs([
655
655
  { tag: d.link, class: "tok-link" },
656
656
  { tag: d.heading, class: "tok-heading" },
657
657
  { tag: d.emphasis, class: "tok-emphasis" },
@@ -683,7 +683,7 @@ ua([
683
683
  { tag: d.invalid, class: "tok-invalid" },
684
684
  { tag: d.punctuation, class: "tok-punctuation" }
685
685
  ]);
686
- const ca = {
686
+ const vs = {
687
687
  "&": {
688
688
  backgroundColor: "var(--vpe-editor-bg)",
689
689
  color: "var(--vpe-text)"
@@ -738,7 +738,7 @@ const ca = {
738
738
  ".cm-panels.cm-panels-bottom": {
739
739
  borderTop: "1px solid var(--vpe-border)"
740
740
  }
741
- }, da = Ws.define([
741
+ }, ms = ts.define([
742
742
  { tag: d.comment, color: "var(--vpe-syn-comment)", fontStyle: "italic" },
743
743
  {
744
744
  tag: [
@@ -783,28 +783,28 @@ const ca = {
783
783
  { tag: d.strikethrough, textDecoration: "line-through" },
784
784
  { tag: d.invalid, color: "var(--vpe-syn-invalid)" }
785
785
  ]);
786
- function pa(a) {
787
- return [$e.theme(ca, { dark: a }), Gs(da)];
786
+ function Tt(s) {
787
+ return [$e.theme(vs, { dark: s }), es(ms)];
788
788
  }
789
- const fa = "'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace", fr = Fs.define();
790
- function va(a, n) {
791
- const s = a.filter((o) => Number.isFinite(o) && o >= 1 && o <= n.lines).sort((o, i) => o - i);
792
- return Xt.set(
793
- s.map((o) => Xt.line({ class: "vpe-error-line" }).range(n.line(o).from))
789
+ const gs = "'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace", gr = Ha.define();
790
+ function ys(s, n) {
791
+ const a = s.filter((o) => Number.isFinite(o) && o >= 1 && o <= n.lines).sort((o, i) => o - i);
792
+ return rn.set(
793
+ a.map((o) => rn.line({ class: "vpe-error-line" }).range(n.line(o).from))
794
794
  );
795
795
  }
796
- const ma = Rs.define({
797
- create: () => Xt.none,
798
- update: (a, n) => {
799
- let s = a;
796
+ const hs = Ba.define({
797
+ create: () => rn.none,
798
+ update: (s, n) => {
799
+ let a = s;
800
800
  for (const o of n.effects)
801
- o.is(fr) && (s = va(o.value, n.state.doc));
802
- return n.docChanged && (s = s.map(n.changes)), s;
801
+ o.is(gr) && (a = ys(o.value, n.state.doc));
802
+ return n.docChanged && (a = a.map(n.changes)), a;
803
803
  },
804
- provide: (a) => $e.decorations.from(a)
805
- }), ga = $e.theme({
804
+ provide: (s) => $e.decorations.from(s)
805
+ }), bs = $e.theme({
806
806
  "&": { height: "100%", fontSize: "13px" },
807
- ".cm-scroller": { fontFamily: fa, lineHeight: "1.65" },
807
+ ".cm-scroller": { fontFamily: gs, lineHeight: "1.65" },
808
808
  ".cm-content": { padding: "10px 0 14px" },
809
809
  ".cm-gutters": {
810
810
  borderRight: "none",
@@ -814,58 +814,58 @@ const ma = Rs.define({
814
814
  },
815
815
  "&.cm-focused": { outline: "none" }
816
816
  });
817
- function ya(a, n) {
818
- const s = $e.updateListener.of((p) => {
817
+ function ks(s, n) {
818
+ const a = $e.updateListener.of((p) => {
819
819
  p.docChanged && n.onDocChange(p.state.doc.toString());
820
- }), o = Jn.of([
820
+ }), o = Xn.of([
821
821
  {
822
822
  key: "Mod-Enter",
823
823
  preventDefault: !0,
824
824
  run: () => (n.onRunShortcut(), !0)
825
825
  }
826
- ]), i = Yt.create({
826
+ ]), i = nn.create({
827
827
  doc: n.value,
828
828
  extensions: [
829
- ga,
830
- _s(),
831
- Is(),
832
- Hs(),
833
- Bs(),
834
- Qs(),
835
- Ys.of(" "),
836
- n.language ?? pr(),
837
- pa(n.dark),
838
- zs(),
839
- js(),
840
- Xs(),
829
+ bs,
830
+ Ua(),
831
+ Aa(),
832
+ Da(),
833
+ za(),
834
+ Ga(),
835
+ ns.of(" "),
836
+ n.language ?? mr(),
837
+ Tt(n.dark),
838
+ Ka(),
839
+ Ja(),
840
+ rs(),
841
841
  $e.lineWrapping,
842
- Us(n.placeholderText),
843
- ma,
842
+ ja(n.placeholderText),
843
+ hs,
844
844
  o,
845
- Jn.of([...Vs, ...Ks, ...Js, Zs]),
845
+ Xn.of([...Za, ...Wa, ...Ya, Xa]),
846
846
  ...n.extensions,
847
- s
847
+ a
848
848
  ]
849
849
  });
850
- return new $e({ state: i, parent: a });
850
+ return new $e({ state: i, parent: s });
851
851
  }
852
- function ha(a, n = 600) {
853
- return As(
854
- async (s) => {
855
- const o = s.state.doc.toString();
852
+ function ws(s, n = 600) {
853
+ return Va(
854
+ async (a) => {
855
+ const o = a.state.doc.toString();
856
856
  if (!o.trim()) return [];
857
857
  let i = null;
858
858
  try {
859
- i = await a.checkSyntax(o);
859
+ i = await s.checkSyntax(o);
860
860
  } catch {
861
861
  return [];
862
862
  }
863
863
  if (!i) return [];
864
- const p = Math.min(Math.max(Math.round(i.line) || 1, 1), s.state.doc.lines), b = s.state.doc.line(p), E = Math.min(Math.max(Math.round(i.column) || 1, 1), b.length + 1), R = b.from + E - 1, P = Math.min(R + 1, b.to);
864
+ const p = Math.min(Math.max(Math.round(i.line) || 1, 1), a.state.doc.lines), b = a.state.doc.line(p), E = Math.min(Math.max(Math.round(i.column) || 1, 1), b.length + 1), _ = b.from + E - 1, O = Math.min(_ + 1, b.to);
865
865
  return [
866
866
  {
867
- from: R,
868
- to: P,
867
+ from: _,
868
+ to: O,
869
869
  severity: "error",
870
870
  message: i.message,
871
871
  source: "python-syntax"
@@ -875,7 +875,7 @@ function ha(a, n = 600) {
875
875
  { delay: n }
876
876
  );
877
877
  }
878
- const ba = [
878
+ const Ss = [
879
879
  "import ast, json",
880
880
  "def _pye_check(src):",
881
881
  " try:",
@@ -883,7 +883,7 @@ const ba = [
883
883
  " return json.dumps({'ok': True})",
884
884
  " except SyntaxError as e:",
885
885
  " return json.dumps({'ok': False, 'line': int(e.lineno or 1), 'column': int(e.offset or 1), 'message': str(e.msg or 'invalid syntax')})"
886
- ], ka = [
886
+ ], xs = [
887
887
  "import json",
888
888
  "import sqlite3",
889
889
  "",
@@ -960,13 +960,13 @@ const ba = [
960
960
  ' return json.dumps({"ok": False, "results": results, "error": error})',
961
961
  ' return json.dumps({"ok": True, "results": results})'
962
962
  ];
963
- function wa(a) {
964
- const n = a.endsWith("/") ? a : a + "/";
963
+ function Es(s) {
964
+ const n = s.endsWith("/") ? s : s + "/";
965
965
  return `
966
966
  var INDEX_URL = ${JSON.stringify(n)};
967
- var CHECK_SOURCE = ${JSON.stringify(ba.join(`
967
+ var CHECK_SOURCE = ${JSON.stringify(Ss.join(`
968
968
  `))};
969
- var SQL_SOURCE = ${JSON.stringify(ka.join(`
969
+ var SQL_SOURCE = ${JSON.stringify(xs.join(`
970
970
  `))};
971
971
  var pyodide = null;
972
972
  var checkFn = null;
@@ -1224,66 +1224,66 @@ self.onmessage = async function (ev) {
1224
1224
  };
1225
1225
  `;
1226
1226
  }
1227
- const vr = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
1228
- class Sa {
1227
+ const yr = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
1228
+ class qs {
1229
1229
  constructor(n = {}) {
1230
- ae(this, "status", "idle");
1231
- ae(this, "version", "");
1232
- ae(this, "pyodideUrl");
1233
- ae(this, "worker", null);
1234
- ae(this, "pending", /* @__PURE__ */ new Map());
1235
- ae(this, "seq", 1);
1236
- ae(this, "chain", Promise.resolve());
1230
+ ie(this, "status", "idle");
1231
+ ie(this, "version", "");
1232
+ ie(this, "pyodideUrl");
1233
+ ie(this, "worker", null);
1234
+ ie(this, "pending", /* @__PURE__ */ new Map());
1235
+ ie(this, "seq", 1);
1236
+ ie(this, "chain", Promise.resolve());
1237
1237
  /** Worker 生命周期代数:interrupt 后递增,用于废弃旧的 waitReady 等待 */
1238
- ae(this, "generation", 0);
1239
- ae(this, "statusHandlers", /* @__PURE__ */ new Set());
1240
- ae(this, "outputHandlers", /* @__PURE__ */ new Set());
1241
- ae(this, "initErrorHandlers", /* @__PURE__ */ new Set());
1242
- this.pyodideUrl = n.pyodideUrl || vr;
1238
+ ie(this, "generation", 0);
1239
+ ie(this, "statusHandlers", /* @__PURE__ */ new Set());
1240
+ ie(this, "outputHandlers", /* @__PURE__ */ new Set());
1241
+ ie(this, "initErrorHandlers", /* @__PURE__ */ new Set());
1242
+ this.pyodideUrl = n.pyodideUrl || yr;
1243
1243
  }
1244
- on(n, s) {
1244
+ on(n, a) {
1245
1245
  if (n === "status") {
1246
- const i = s;
1246
+ const i = a;
1247
1247
  return this.statusHandlers.add(i), () => this.statusHandlers.delete(i);
1248
1248
  }
1249
1249
  if (n === "output") {
1250
- const i = s;
1250
+ const i = a;
1251
1251
  return this.outputHandlers.add(i), () => this.outputHandlers.delete(i);
1252
1252
  }
1253
- const o = s;
1253
+ const o = a;
1254
1254
  return this.initErrorHandlers.add(o), () => this.initErrorHandlers.delete(o);
1255
1255
  }
1256
1256
  /** 预加载 Pyodide(返回 Promise,在就绪或失败时 settle) */
1257
1257
  waitReady(n = 18e4) {
1258
- const s = this.generation;
1258
+ const a = this.generation;
1259
1259
  return this.ensureWorker(), this.status === "ready" || this.status === "running" ? Promise.resolve() : new Promise((o, i) => {
1260
1260
  let p = () => {
1261
1261
  }, b = () => {
1262
1262
  };
1263
1263
  const E = () => {
1264
- clearTimeout(R), p(), b();
1265
- }, R = setTimeout(() => {
1264
+ clearTimeout(_), p(), b();
1265
+ }, _ = setTimeout(() => {
1266
1266
  E(), i(new Error("Pyodide 加载超时"));
1267
1267
  }, n);
1268
- p = this.on("status", (P) => {
1269
- if (this.generation !== s) {
1268
+ p = this.on("status", (O) => {
1269
+ if (this.generation !== a) {
1270
1270
  E(), i(new Error("执行已被中断"));
1271
1271
  return;
1272
1272
  }
1273
- P === "ready" && (E(), o());
1274
- }), b = this.on("initError", (P) => {
1275
- E(), i(new Error(P));
1273
+ O === "ready" && (E(), o());
1274
+ }), b = this.on("initError", (O) => {
1275
+ E(), i(new Error(O));
1276
1276
  });
1277
1277
  });
1278
1278
  }
1279
1279
  /** 执行一段 Python 代码(支持顶层 await);运行器未就绪时先等待初始化完成 */
1280
- async run(n, s) {
1280
+ async run(n, a) {
1281
1281
  await this.waitReady();
1282
1282
  const o = performance.now();
1283
1283
  this.setStatus("running");
1284
1284
  const i = await this.send(
1285
- { kind: "run", id: this.seq++, code: n, stdin: s == null ? void 0 : s.stdin },
1286
- s == null ? void 0 : s.onOutput
1285
+ { kind: "run", id: this.seq++, code: n, stdin: a == null ? void 0 : a.stdin },
1286
+ a == null ? void 0 : a.onOutput
1287
1287
  );
1288
1288
  return this.status === "running" && this.setStatus("ready"), {
1289
1289
  ok: i.ok,
@@ -1296,40 +1296,40 @@ class Sa {
1296
1296
  /** 语法检查:仅在运行器就绪时可用,否则返回 null(静默跳过) */
1297
1297
  async checkSyntax(n) {
1298
1298
  if (this.status !== "ready" || !n.trim()) return null;
1299
- const s = await this.send({ kind: "check", id: this.seq++, code: n });
1300
- return s.ok ? null : {
1301
- line: s.line ?? 1,
1302
- column: s.column ?? 1,
1303
- message: s.message ?? "语法错误"
1299
+ const a = await this.send({ kind: "check", id: this.seq++, code: n });
1300
+ return a.ok ? null : {
1301
+ line: a.line ?? 1,
1302
+ column: a.column ?? 1,
1303
+ message: a.message ?? "语法错误"
1304
1304
  };
1305
1305
  }
1306
1306
  /** 写入虚拟文件系统(UTF-8 文本),相对路径基于当前工作目录 */
1307
- async writeFile(n, s) {
1307
+ async writeFile(n, a) {
1308
1308
  await this.waitReady();
1309
- const o = await this.send({ kind: "fs-write", id: this.seq++, path: n, content: s });
1309
+ const o = await this.send({ kind: "fs-write", id: this.seq++, path: n, content: a });
1310
1310
  return { ok: o.ok, path: o.path, error: o.error };
1311
1311
  }
1312
1312
  /** 读取虚拟文件系统中的文本文件;二进制内容会返回失败 */
1313
1313
  async readFile(n) {
1314
1314
  await this.waitReady();
1315
- const s = await this.send({ kind: "fs-read", id: this.seq++, path: n });
1316
- return { ok: s.ok, path: s.path, content: s.content, error: s.error };
1315
+ const a = await this.send({ kind: "fs-read", id: this.seq++, path: n });
1316
+ return { ok: a.ok, path: a.path, content: a.content, error: a.error };
1317
1317
  }
1318
1318
  /** 列出虚拟文件系统目录(递归,跳过 __pycache__ / .cache) */
1319
1319
  async listFiles(n = ".") {
1320
1320
  await this.waitReady();
1321
- const s = await this.send({
1321
+ const a = await this.send({
1322
1322
  kind: "fs-list",
1323
1323
  id: this.seq++,
1324
1324
  path: n,
1325
1325
  recursive: !0
1326
1326
  });
1327
- return { ok: s.ok, path: s.path, entries: s.entries, error: s.error };
1327
+ return { ok: a.ok, path: a.path, entries: a.entries, error: a.error };
1328
1328
  }
1329
1329
  /** 在浏览器内的 SQLite 中执行 SQL(首次调用时自动加载 sqlite3 包) */
1330
1330
  async executeSql(n) {
1331
1331
  await this.waitReady();
1332
- const s = performance.now();
1332
+ const a = performance.now();
1333
1333
  this.setStatus("running");
1334
1334
  try {
1335
1335
  const o = await this.send({
@@ -1343,20 +1343,20 @@ class Sa {
1343
1343
  ok: o.ok,
1344
1344
  results: o.results ?? [],
1345
1345
  error: o.sqlError ?? (o.interrupted ? { type: "AbortError", message: "SQL 执行已中断" } : void 0),
1346
- durationMs: performance.now() - s
1346
+ durationMs: performance.now() - a
1347
1347
  };
1348
1348
  } finally {
1349
1349
  this.status === "running" && this.setStatus("ready");
1350
1350
  }
1351
1351
  }
1352
1352
  /** 安装第三方包:先尝试内置 wheel(loadPackage),失败后回退 micropip */
1353
- async loadPackages(n, s) {
1353
+ async loadPackages(n, a) {
1354
1354
  await this.waitReady();
1355
1355
  const o = performance.now();
1356
1356
  this.setStatus("running");
1357
1357
  const i = await this.send(
1358
1358
  { kind: "install", id: this.seq++, packages: n },
1359
- s == null ? void 0 : s.onOutput
1359
+ a == null ? void 0 : a.onOutput
1360
1360
  );
1361
1361
  return this.status === "running" && this.setStatus("ready"), { ok: i.ok, error: i.error, durationMs: performance.now() - o };
1362
1362
  }
@@ -1372,12 +1372,12 @@ class Sa {
1372
1372
  interrupted: !0,
1373
1373
  error: { type: "KeyboardInterrupt", message: "执行已被用户中断", traceback: "" }
1374
1374
  };
1375
- this.pending.forEach((s) => s.resolve(n)), this.pending.clear(), this.chain = Promise.resolve(), this.setStatus("idle");
1375
+ this.pending.forEach((a) => a.resolve(n)), this.pending.clear(), this.chain = Promise.resolve(), this.setStatus("idle");
1376
1376
  }
1377
1377
  ensureWorker() {
1378
1378
  if (this.worker) return this.worker;
1379
- const n = new Blob([wa(this.pyodideUrl)], { type: "text/javascript" }), s = new Worker(URL.createObjectURL(n));
1380
- return s.onmessage = (o) => this.handleMessage(o.data), this.worker = s, this.setStatus("loading"), s;
1379
+ const n = new Blob([Es(this.pyodideUrl)], { type: "text/javascript" }), a = new Worker(URL.createObjectURL(n));
1380
+ return a.onmessage = (o) => this.handleMessage(o.data), this.worker = a, this.setStatus("loading"), a;
1381
1381
  }
1382
1382
  handleMessage(n) {
1383
1383
  switch (n.kind) {
@@ -1385,21 +1385,21 @@ class Sa {
1385
1385
  this.version = n.version, this.setStatus("ready");
1386
1386
  break;
1387
1387
  case "init-error":
1388
- this.setStatus("idle"), this.initErrorHandlers.forEach((s) => s(n.message));
1388
+ this.setStatus("idle"), this.initErrorHandlers.forEach((a) => a(n.message));
1389
1389
  break;
1390
1390
  case "output": {
1391
- const s = n.runId ? this.pending.get(n.runId) : void 0;
1392
- s != null && s.onOutput ? s.onOutput(n.stream, n.text) : this.outputHandlers.forEach((o) => o(n.stream, n.text));
1391
+ const a = n.runId ? this.pending.get(n.runId) : void 0;
1392
+ a != null && a.onOutput ? a.onOutput(n.stream, n.text) : this.outputHandlers.forEach((o) => o(n.stream, n.text));
1393
1393
  break;
1394
1394
  }
1395
1395
  case "result": {
1396
- const s = this.pending.get(n.id);
1397
- s && (this.pending.delete(n.id), s.resolve({ ok: n.ok, value: n.value, error: n.error }));
1396
+ const a = this.pending.get(n.id);
1397
+ a && (this.pending.delete(n.id), a.resolve({ ok: n.ok, value: n.value, error: n.error }));
1398
1398
  break;
1399
1399
  }
1400
1400
  case "checked": {
1401
- const s = this.pending.get(n.id);
1402
- s && (this.pending.delete(n.id), s.resolve({
1401
+ const a = this.pending.get(n.id);
1402
+ a && (this.pending.delete(n.id), a.resolve({
1403
1403
  ok: n.ok,
1404
1404
  line: n.line,
1405
1405
  column: n.column,
@@ -1408,18 +1408,18 @@ class Sa {
1408
1408
  break;
1409
1409
  }
1410
1410
  case "installed": {
1411
- const s = this.pending.get(n.id);
1412
- s && (this.pending.delete(n.id), s.resolve({ ok: n.ok, error: n.error }));
1411
+ const a = this.pending.get(n.id);
1412
+ a && (this.pending.delete(n.id), a.resolve({ ok: n.ok, error: n.error }));
1413
1413
  break;
1414
1414
  }
1415
1415
  case "fs-written": {
1416
- const s = this.pending.get(n.id);
1417
- s && (this.pending.delete(n.id), s.resolve({ ok: n.ok, path: n.path, error: n.error }));
1416
+ const a = this.pending.get(n.id);
1417
+ a && (this.pending.delete(n.id), a.resolve({ ok: n.ok, path: n.path, error: n.error }));
1418
1418
  break;
1419
1419
  }
1420
1420
  case "fs-read": {
1421
- const s = this.pending.get(n.id);
1422
- s && (this.pending.delete(n.id), s.resolve({
1421
+ const a = this.pending.get(n.id);
1422
+ a && (this.pending.delete(n.id), a.resolve({
1423
1423
  ok: n.ok,
1424
1424
  path: n.path,
1425
1425
  content: n.content,
@@ -1428,8 +1428,8 @@ class Sa {
1428
1428
  break;
1429
1429
  }
1430
1430
  case "fs-list": {
1431
- const s = this.pending.get(n.id);
1432
- s && (this.pending.delete(n.id), s.resolve({
1431
+ const a = this.pending.get(n.id);
1432
+ a && (this.pending.delete(n.id), a.resolve({
1433
1433
  ok: n.ok,
1434
1434
  path: n.path,
1435
1435
  entries: n.entries,
@@ -1438,16 +1438,16 @@ class Sa {
1438
1438
  break;
1439
1439
  }
1440
1440
  case "sql-ran": {
1441
- const s = this.pending.get(n.id);
1442
- s && (this.pending.delete(n.id), s.resolve({ ok: n.ok, results: n.results, sqlError: n.error }));
1441
+ const a = this.pending.get(n.id);
1442
+ a && (this.pending.delete(n.id), a.resolve({ ok: n.ok, results: n.results, sqlError: n.error }));
1443
1443
  break;
1444
1444
  }
1445
1445
  }
1446
1446
  }
1447
- send(n, s) {
1447
+ send(n, a) {
1448
1448
  const o = this.ensureWorker(), i = this.chain.then(
1449
1449
  () => new Promise((p) => {
1450
- this.pending.set(n.id, { resolve: p, onOutput: s }), o.postMessage(n);
1450
+ this.pending.set(n.id, { resolve: p, onOutput: a }), o.postMessage(n);
1451
1451
  })
1452
1452
  );
1453
1453
  return this.chain = i.then(
@@ -1458,123 +1458,123 @@ class Sa {
1458
1458
  ), i;
1459
1459
  }
1460
1460
  setStatus(n) {
1461
- this.status !== n && (this.status = n, this.statusHandlers.forEach((s) => s(n, this.version)));
1461
+ this.status !== n && (this.status = n, this.statusHandlers.forEach((a) => a(n, this.version)));
1462
1462
  }
1463
1463
  }
1464
- let Zt = null;
1465
- function rn(a) {
1466
- return Zt ? a != null && a.pyodideUrl && a.pyodideUrl !== vr && console.warn(
1464
+ let Xt = null;
1465
+ function un(s) {
1466
+ return Xt ? s != null && s.pyodideUrl && s.pyodideUrl !== yr && console.warn(
1467
1467
  "[princess-python-editor] Pyodide 运行器已初始化,后续传入的 pyodideUrl 将被忽略。"
1468
- ) : Zt = new Sa(a), Zt;
1468
+ ) : Xt = new qs(s), Xt;
1469
1469
  }
1470
- const xa = 3e4;
1471
- function Ea(a) {
1472
- const n = (a ?? "").trim().replace(/\/+$/, "");
1470
+ const Cs = 3e4;
1471
+ function Ps(s) {
1472
+ const n = (s ?? "").trim().replace(/\/+$/, "");
1473
1473
  if (!n)
1474
1474
  throw new Error("未配置文件服务端点(filesEndpoint)");
1475
1475
  return n;
1476
1476
  }
1477
- async function Nt(a, n, s, o = {}) {
1478
- var R, P;
1479
- const i = Ea(a), p = new AbortController(), b = setTimeout(() => p.abort(), o.timeoutMs ?? xa), E = () => p.abort();
1477
+ async function Ft(s, n, a, o = {}) {
1478
+ var _, O;
1479
+ const i = Ps(s), p = new AbortController(), b = setTimeout(() => p.abort(), o.timeoutMs ?? Cs), E = () => p.abort();
1480
1480
  o.signal && (o.signal.aborted ? p.abort() : o.signal.addEventListener("abort", E));
1481
1481
  try {
1482
- const T = await fetch(i + n, {
1483
- ...s,
1482
+ const N = await fetch(i + n, {
1483
+ ...a,
1484
1484
  headers: {
1485
1485
  "Content-Type": "application/json",
1486
1486
  ...o.headers ?? {},
1487
- ...s.headers ?? {}
1487
+ ...a.headers ?? {}
1488
1488
  },
1489
1489
  signal: p.signal
1490
- }), x = await T.text();
1490
+ }), x = await N.text();
1491
1491
  let F = null;
1492
1492
  if (x)
1493
1493
  try {
1494
1494
  F = JSON.parse(x);
1495
1495
  } catch {
1496
- throw new Error(`文件服务返回的不是合法 JSON(HTTP ${T.status})`);
1496
+ throw new Error(`文件服务返回的不是合法 JSON(HTTP ${N.status})`);
1497
1497
  }
1498
- if (!T.ok || !F || F.ok === !1)
1499
- throw new Error(((R = F == null ? void 0 : F.error) == null ? void 0 : R.message) ?? `文件服务返回 HTTP ${T.status}`);
1498
+ if (!N.ok || !F || F.ok === !1)
1499
+ throw new Error(((_ = F == null ? void 0 : F.error) == null ? void 0 : _.message) ?? `文件服务返回 HTTP ${N.status}`);
1500
1500
  return F.data;
1501
1501
  } finally {
1502
- clearTimeout(b), (P = o.signal) == null || P.removeEventListener("abort", E);
1502
+ clearTimeout(b), (O = o.signal) == null || O.removeEventListener("abort", E);
1503
1503
  }
1504
1504
  }
1505
- function qa(a, n = {}) {
1506
- return Nt(a, "", { method: "GET" }, n);
1505
+ function Os(s, n = {}) {
1506
+ return Ft(s, "", { method: "GET" }, n);
1507
1507
  }
1508
- function Ca(a, n, s = {}) {
1509
- return Nt(
1510
- a,
1508
+ function Ms(s, n, a = {}) {
1509
+ return Ft(
1510
+ s,
1511
1511
  "",
1512
1512
  { method: "POST", body: JSON.stringify(n) },
1513
- s
1513
+ a
1514
1514
  );
1515
1515
  }
1516
- function Pa(a, n, s = {}) {
1517
- return Nt(
1518
- a,
1516
+ function Ts(s, n, a = {}) {
1517
+ return Ft(
1518
+ s,
1519
1519
  `/${encodeURIComponent(n)}`,
1520
1520
  { method: "GET" },
1521
- s
1521
+ a
1522
1522
  );
1523
1523
  }
1524
- async function Oa(a, n, s = {}) {
1525
- await Nt(a, `/${encodeURIComponent(n)}`, { method: "DELETE" }, s);
1524
+ async function Ns(s, n, a = {}) {
1525
+ await Ft(s, `/${encodeURIComponent(n)}`, { method: "DELETE" }, a);
1526
1526
  }
1527
- const Ma = 6e4;
1528
- function sn(a) {
1529
- const n = (a ?? "").trim().replace(/\/+$/, "");
1527
+ const Ls = 6e4;
1528
+ function cn(s) {
1529
+ const n = (s ?? "").trim().replace(/\/+$/, "");
1530
1530
  if (!n)
1531
1531
  throw new Error("未配置 Python 服务端点(pythonEndpoint)");
1532
1532
  return n;
1533
1533
  }
1534
- function mr(a, n) {
1535
- if (a && typeof a == "object") {
1536
- const s = a, o = Number(s.line);
1534
+ function hr(s, n) {
1535
+ if (s && typeof s == "object") {
1536
+ const a = s, o = Number(a.line);
1537
1537
  return {
1538
- type: typeof s.type == "string" && s.type ? s.type : "PythonError",
1539
- message: typeof s.message == "string" && s.message ? s.message : n,
1538
+ type: typeof a.type == "string" && a.type ? a.type : "PythonError",
1539
+ message: typeof a.message == "string" && a.message ? a.message : n,
1540
1540
  line: Number.isFinite(o) && o > 0 ? Math.trunc(o) : void 0,
1541
- traceback: typeof s.traceback == "string" && s.traceback ? s.traceback : void 0
1541
+ traceback: typeof a.traceback == "string" && a.traceback ? a.traceback : void 0
1542
1542
  };
1543
1543
  }
1544
1544
  return { type: "PythonError", message: n };
1545
1545
  }
1546
- async function Zi(a, n, s = {}) {
1547
- var R;
1548
- const o = sn(a), i = performance.now(), p = new AbortController(), b = setTimeout(() => p.abort(), s.timeoutMs ?? Ma), E = () => p.abort();
1549
- s.signal && (s.signal.aborted ? p.abort() : s.signal.addEventListener("abort", E));
1546
+ async function el(s, n, a = {}) {
1547
+ var _;
1548
+ const o = cn(s), i = performance.now(), p = new AbortController(), b = setTimeout(() => p.abort(), a.timeoutMs ?? Ls), E = () => p.abort();
1549
+ a.signal && (a.signal.aborted ? p.abort() : a.signal.addEventListener("abort", E));
1550
1550
  try {
1551
- const P = await fetch(`${o}/run`, {
1551
+ const O = await fetch(`${o}/run`, {
1552
1552
  method: "POST",
1553
1553
  headers: {
1554
1554
  "Content-Type": "application/json",
1555
- ...s.headers ?? {}
1555
+ ...a.headers ?? {}
1556
1556
  },
1557
- body: JSON.stringify({ code: n, stdin: s.stdin ?? "" }),
1557
+ body: JSON.stringify({ code: n, stdin: a.stdin ?? "" }),
1558
1558
  signal: p.signal
1559
- }), T = await P.text();
1559
+ }), N = await O.text();
1560
1560
  let x = null;
1561
- if (T)
1561
+ if (N)
1562
1562
  try {
1563
- x = JSON.parse(T);
1563
+ x = JSON.parse(N);
1564
1564
  } catch {
1565
- throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${P.status})`);
1565
+ throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${O.status})`);
1566
1566
  }
1567
1567
  const F = performance.now() - i;
1568
- if (!P.ok) {
1569
- const O = x == null ? void 0 : x.error, V = typeof (O == null ? void 0 : O.message) == "string" && O.message ? O.message : `Python 服务返回 HTTP ${P.status}`;
1568
+ if (!O.ok) {
1569
+ const M = x == null ? void 0 : x.error, Q = typeof (M == null ? void 0 : M.message) == "string" && M.message ? M.message : `Python 服务返回 HTTP ${O.status}`;
1570
1570
  return {
1571
1571
  ok: !1,
1572
1572
  stdout: "",
1573
1573
  stderr: "",
1574
1574
  durationMs: F,
1575
1575
  error: {
1576
- type: typeof (O == null ? void 0 : O.type) == "string" && O.type ? O.type : `Http${P.status}`,
1577
- message: V
1576
+ type: typeof (M == null ? void 0 : M.type) == "string" && M.type ? M.type : `Http${O.status}`,
1577
+ message: Q
1578
1578
  }
1579
1579
  };
1580
1580
  }
@@ -1586,29 +1586,29 @@ async function Zi(a, n, s = {}) {
1586
1586
  durationMs: F,
1587
1587
  error: { type: "BadResponse", message: "Python 服务返回内容为空" }
1588
1588
  };
1589
- const q = x.ok === !0, G = Number(x.durationMs), ve = Number(x.exitCode);
1589
+ const q = x.ok === !0, G = Number(x.durationMs), me = Number(x.exitCode);
1590
1590
  return {
1591
1591
  ok: q,
1592
1592
  stdout: typeof x.stdout == "string" ? x.stdout : "",
1593
1593
  stderr: typeof x.stderr == "string" ? x.stderr : "",
1594
- exitCode: Number.isFinite(ve) ? Math.trunc(ve) : void 0,
1594
+ exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
1595
1595
  durationMs: Number.isFinite(G) && G >= 0 ? G : F,
1596
- error: q ? void 0 : mr(x.error, "服务端 Python 执行失败")
1596
+ error: q ? void 0 : hr(x.error, "服务端 Python 执行失败")
1597
1597
  };
1598
1598
  } finally {
1599
- clearTimeout(b), (R = s.signal) == null || R.removeEventListener("abort", E);
1599
+ clearTimeout(b), (_ = a.signal) == null || _.removeEventListener("abort", E);
1600
1600
  }
1601
1601
  }
1602
- function Na(a) {
1603
- return a === "waiting" || a === "running" || a === "exited" ? a : "exited";
1602
+ function $s(s) {
1603
+ return s === "waiting" || s === "running" || s === "exited" ? s : "exited";
1604
1604
  }
1605
- async function an(a, n, s, o, i) {
1606
- var T;
1607
- const p = sn(a), b = performance.now(), E = new AbortController(), R = setTimeout(() => E.abort(), o.timeoutMs ?? i), P = () => E.abort();
1608
- o.signal && (o.signal.aborted ? E.abort() : o.signal.addEventListener("abort", P));
1605
+ async function dn(s, n, a, o, i) {
1606
+ var N;
1607
+ const p = cn(s), b = performance.now(), E = new AbortController(), _ = setTimeout(() => E.abort(), o.timeoutMs ?? i), O = () => E.abort();
1608
+ o.signal && (o.signal.aborted ? E.abort() : o.signal.addEventListener("abort", O));
1609
1609
  try {
1610
1610
  const x = await fetch(p + n, {
1611
- ...s,
1611
+ ...a,
1612
1612
  headers: {
1613
1613
  "Content-Type": "application/json",
1614
1614
  ...o.headers ?? {}
@@ -1624,7 +1624,7 @@ async function an(a, n, s, o, i) {
1624
1624
  }
1625
1625
  const G = performance.now() - b;
1626
1626
  if (!x.ok || !q) {
1627
- const V = q == null ? void 0 : q.error, Ue = typeof (V == null ? void 0 : V.message) == "string" && V.message ? V.message : `Python 服务返回 HTTP ${x.status}`;
1627
+ const Q = q == null ? void 0 : q.error, Ue = typeof (Q == null ? void 0 : Q.message) == "string" && Q.message ? Q.message : `Python 服务返回 HTTP ${x.status}`;
1628
1628
  return {
1629
1629
  sessionId: typeof (q == null ? void 0 : q.sessionId) == "string" ? q.sessionId : "",
1630
1630
  state: "exited",
@@ -1632,71 +1632,71 @@ async function an(a, n, s, o, i) {
1632
1632
  stderr: "",
1633
1633
  durationMs: G,
1634
1634
  error: {
1635
- type: typeof (V == null ? void 0 : V.type) == "string" && V.type ? V.type : `Http${x.status}`,
1635
+ type: typeof (Q == null ? void 0 : Q.type) == "string" && Q.type ? Q.type : `Http${x.status}`,
1636
1636
  message: Ue
1637
1637
  }
1638
1638
  };
1639
1639
  }
1640
- const ve = Number(q.exitCode), O = Number(q.durationMs);
1640
+ const me = Number(q.exitCode), M = Number(q.durationMs);
1641
1641
  return {
1642
1642
  sessionId: typeof q.sessionId == "string" ? q.sessionId : "",
1643
- state: Na(q.state),
1643
+ state: $s(q.state),
1644
1644
  stdout: typeof q.stdout == "string" ? q.stdout : "",
1645
1645
  stderr: typeof q.stderr == "string" ? q.stderr : "",
1646
- exitCode: Number.isFinite(ve) ? Math.trunc(ve) : void 0,
1647
- durationMs: Number.isFinite(O) ? O : G,
1648
- error: q.error ? mr(q.error, "服务端 Python 执行失败") : void 0
1646
+ exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
1647
+ durationMs: Number.isFinite(M) ? M : G,
1648
+ error: q.error ? hr(q.error, "服务端 Python 执行失败") : void 0
1649
1649
  };
1650
1650
  } finally {
1651
- clearTimeout(R), (T = o.signal) == null || T.removeEventListener("abort", P);
1651
+ clearTimeout(_), (N = o.signal) == null || N.removeEventListener("abort", O);
1652
1652
  }
1653
1653
  }
1654
- function Ta(a, n, s = {}) {
1655
- return an(
1656
- a,
1654
+ function Fs(s, n, a = {}) {
1655
+ return dn(
1656
+ s,
1657
1657
  "/sessions",
1658
1658
  {
1659
1659
  method: "POST",
1660
1660
  body: JSON.stringify({
1661
1661
  code: n,
1662
- stdin: s.stdin ?? "",
1663
- timeoutSeconds: s.timeoutSeconds
1662
+ stdin: a.stdin ?? "",
1663
+ timeoutSeconds: a.timeoutSeconds
1664
1664
  })
1665
1665
  },
1666
- s,
1666
+ a,
1667
1667
  2e4
1668
1668
  );
1669
1669
  }
1670
- function La(a, n, s = {}) {
1671
- return an(
1672
- a,
1670
+ function _s(s, n, a = {}) {
1671
+ return dn(
1672
+ s,
1673
1673
  `/sessions/${encodeURIComponent(n)}`,
1674
1674
  { method: "GET" },
1675
- s,
1675
+ a,
1676
1676
  5e3
1677
1677
  );
1678
1678
  }
1679
- function $a(a, n, s, o = {}) {
1680
- return an(
1681
- a,
1679
+ function Rs(s, n, a, o = {}) {
1680
+ return dn(
1681
+ s,
1682
1682
  `/sessions/${encodeURIComponent(n)}/input`,
1683
- { method: "POST", body: JSON.stringify({ text: s }) },
1683
+ { method: "POST", body: JSON.stringify({ text: a }) },
1684
1684
  o,
1685
1685
  2e4
1686
1686
  );
1687
1687
  }
1688
- async function Yn(a, n, s = {}) {
1689
- const o = sn(a);
1688
+ async function rr(s, n, a = {}) {
1689
+ const o = cn(s);
1690
1690
  try {
1691
1691
  await fetch(`${o}/sessions/${encodeURIComponent(n)}/interrupt`, {
1692
1692
  method: "POST",
1693
- headers: { ...s.headers ?? {} },
1694
- signal: s.signal
1693
+ headers: { ...a.headers ?? {} },
1694
+ signal: a.signal
1695
1695
  });
1696
1696
  } catch {
1697
1697
  }
1698
1698
  }
1699
- const ut = [
1699
+ const dt = [
1700
1700
  { value: "sqlite", label: "SQLite" },
1701
1701
  { value: "mysql", label: "MySQL", defaultPort: 3306 },
1702
1702
  { value: "postgresql", label: "PostgreSQL", defaultPort: 5432 },
@@ -1704,105 +1704,105 @@ const ut = [
1704
1704
  { value: "oracle", label: "Oracle", defaultPort: 1521 },
1705
1705
  { value: "clickhouse", label: "ClickHouse", defaultPort: 8123 },
1706
1706
  { value: "other", label: "其他" }
1707
- ], Gi = {
1707
+ ], tl = {
1708
1708
  mode: "sqlite",
1709
1709
  connection: { dialect: "sqlite", database: ":memory:" },
1710
1710
  maxRows: 200,
1711
1711
  timeoutMs: 3e4
1712
- }, gr = 200, Ot = 3e4;
1713
- function Fa(a) {
1714
- return ut.some((n) => n.value === a);
1712
+ }, br = 200, Lt = 3e4;
1713
+ function Is(s) {
1714
+ return dt.some((n) => n.value === s);
1715
1715
  }
1716
- function Xn(a, n, s, o) {
1717
- const i = typeof a == "number" ? a : Number(a);
1718
- return Number.isFinite(i) ? Math.min(Math.max(Math.trunc(i), s), o) : n;
1716
+ function ar(s, n, a, o) {
1717
+ const i = typeof s == "number" ? s : Number(s);
1718
+ return Number.isFinite(i) ? Math.min(Math.max(Math.trunc(i), a), o) : n;
1719
1719
  }
1720
- function Ra(a) {
1721
- if (a == null || a === "") return;
1722
- const n = Number(a);
1720
+ function Hs(s) {
1721
+ if (s == null || s === "") return;
1722
+ const n = Number(s);
1723
1723
  if (!(!Number.isFinite(n) || n <= 0))
1724
1724
  return Math.min(Math.trunc(n), 65535);
1725
1725
  }
1726
- function D(a = {}) {
1727
- var p, b, E, R, P, T, x;
1728
- const n = a.mode === "http" ? "http" : "sqlite", s = (p = a.connection) == null ? void 0 : p.dialect, o = Fa(s) ? s : n === "http" ? "mysql" : "sqlite", i = (b = a.connection) == null ? void 0 : b.database;
1726
+ function D(s = {}) {
1727
+ var p, b, E, _, O, N, x;
1728
+ const n = s.mode === "http" ? "http" : "sqlite", a = (p = s.connection) == null ? void 0 : p.dialect, o = Is(a) ? a : n === "http" ? "mysql" : "sqlite", i = (b = s.connection) == null ? void 0 : b.database;
1729
1729
  return {
1730
1730
  mode: n,
1731
- connectionId: a.connectionId === void 0 || a.connectionId === null ? void 0 : a.connectionId.trim() || void 0,
1731
+ connectionId: s.connectionId === void 0 || s.connectionId === null ? void 0 : s.connectionId.trim() || void 0,
1732
1732
  connection: {
1733
1733
  dialect: o,
1734
- host: ((E = a.connection) == null ? void 0 : E.host) ?? "",
1735
- port: Ra((R = a.connection) == null ? void 0 : R.port),
1736
- user: ((P = a.connection) == null ? void 0 : P.user) ?? "",
1737
- password: ((T = a.connection) == null ? void 0 : T.password) ?? "",
1734
+ host: ((E = s.connection) == null ? void 0 : E.host) ?? "",
1735
+ port: Hs((_ = s.connection) == null ? void 0 : _.port),
1736
+ user: ((O = s.connection) == null ? void 0 : O.user) ?? "",
1737
+ password: ((N = s.connection) == null ? void 0 : N.password) ?? "",
1738
1738
  database: i ?? (n === "sqlite" ? ":memory:" : ""),
1739
- options: (x = a.connection) != null && x.options ? { ...a.connection.options } : void 0
1739
+ options: (x = s.connection) != null && x.options ? { ...s.connection.options } : void 0
1740
1740
  },
1741
- endpoint: a.endpoint ?? "",
1742
- headers: a.headers ? { ...a.headers } : void 0,
1743
- maxRows: Xn(a.maxRows, gr, 1, 1e5),
1744
- timeoutMs: Xn(a.timeoutMs, Ot, 1e3, 6e5)
1741
+ endpoint: s.endpoint ?? "",
1742
+ headers: s.headers ? { ...s.headers } : void 0,
1743
+ maxRows: ar(s.maxRows, br, 1, 1e5),
1744
+ timeoutMs: ar(s.timeoutMs, Lt, 1e3, 6e5)
1745
1745
  };
1746
1746
  }
1747
- function er(a) {
1748
- if (a == null) return null;
1749
- const n = typeof a;
1747
+ function sr(s) {
1748
+ if (s == null) return null;
1749
+ const n = typeof s;
1750
1750
  if (n === "string" || n === "number" || n === "boolean")
1751
- return a;
1751
+ return s;
1752
1752
  try {
1753
- return JSON.stringify(a);
1753
+ return JSON.stringify(s);
1754
1754
  } catch {
1755
- return String(a);
1755
+ return String(s);
1756
1756
  }
1757
1757
  }
1758
- function nn(a) {
1759
- const n = a ?? {}, s = Array.isArray(n.columns) ? n.columns.map((i) => String(i)) : [], o = Array.isArray(n.rows) ? n.rows.map((i) => Array.isArray(i) ? i.map(er) : [er(i)]) : [];
1758
+ function on(s) {
1759
+ const n = s ?? {}, a = Array.isArray(n.columns) ? n.columns.map((i) => String(i)) : [], o = Array.isArray(n.rows) ? n.rows.map((i) => Array.isArray(i) ? i.map(sr) : [sr(i)]) : [];
1760
1760
  return {
1761
- columns: s,
1761
+ columns: a,
1762
1762
  rows: o,
1763
1763
  affectedRows: n.affectedRows === void 0 || n.affectedRows === null ? void 0 : Number(n.affectedRows) || 0,
1764
1764
  truncated: !!n.truncated
1765
1765
  };
1766
1766
  }
1767
- function on(a, n) {
1768
- if (a && typeof a == "object") {
1769
- const s = a;
1767
+ function pn(s, n) {
1768
+ if (s && typeof s == "object") {
1769
+ const a = s;
1770
1770
  return {
1771
- type: typeof s.type == "string" && s.type ? s.type : "SqlError",
1772
- message: typeof s.message == "string" && s.message ? s.message : typeof a == "string" ? a : n,
1773
- code: typeof s.code == "string" || typeof s.code == "number" ? s.code : void 0
1771
+ type: typeof a.type == "string" && a.type ? a.type : "SqlError",
1772
+ message: typeof a.message == "string" && a.message ? a.message : typeof s == "string" ? s : n,
1773
+ code: typeof a.code == "string" || typeof a.code == "number" ? a.code : void 0
1774
1774
  };
1775
1775
  }
1776
- return { type: "SqlError", message: typeof a == "string" && a ? a : n };
1776
+ return { type: "SqlError", message: typeof s == "string" && s ? s : n };
1777
1777
  }
1778
- function _a(a) {
1779
- return a instanceof DOMException && a.name === "AbortError" || a instanceof Error && a.name === "AbortError";
1778
+ function Bs(s) {
1779
+ return s instanceof DOMException && s.name === "AbortError" || s instanceof Error && s.name === "AbortError";
1780
1780
  }
1781
- function tr(a, n) {
1782
- if (!a || typeof a != "object")
1781
+ function or(s, n) {
1782
+ if (!s || typeof s != "object")
1783
1783
  return {
1784
1784
  ok: !1,
1785
1785
  results: [],
1786
1786
  error: { type: "BadResponse", message: "SQL 服务返回内容为空或格式不正确" },
1787
1787
  durationMs: n
1788
1788
  };
1789
- const s = a, o = s.ok !== !1, i = Number(s.durationMs), p = Number.isFinite(i) && i >= 0 ? i : n;
1789
+ const a = s, o = a.ok !== !1, i = Number(a.durationMs), p = Number.isFinite(i) && i >= 0 ? i : n;
1790
1790
  if (!o)
1791
1791
  return {
1792
1792
  ok: !1,
1793
1793
  results: [],
1794
- error: on(s.error, "SQL 服务返回执行失败"),
1794
+ error: pn(a.error, "SQL 服务返回执行失败"),
1795
1795
  durationMs: p
1796
1796
  };
1797
1797
  let b = [];
1798
- return Array.isArray(s.results) ? b = s.results : (Array.isArray(s.columns) || Array.isArray(s.rows)) && (b = [s]), {
1798
+ return Array.isArray(a.results) ? b = a.results : (Array.isArray(a.columns) || Array.isArray(a.rows)) && (b = [a]), {
1799
1799
  ok: !0,
1800
- results: b.map(nn),
1800
+ results: b.map(on),
1801
1801
  durationMs: p
1802
1802
  };
1803
1803
  }
1804
- async function Ia(a, n, s, o) {
1805
- const i = (a.endpoint ?? "").trim();
1804
+ async function Us(s, n, a, o) {
1805
+ const i = (s.endpoint ?? "").trim();
1806
1806
  if (!i)
1807
1807
  return {
1808
1808
  ok: !1,
@@ -1815,22 +1815,22 @@ async function Ia(a, n, s, o) {
1815
1815
  };
1816
1816
  const p = performance.now(), b = new AbortController();
1817
1817
  let E = !1;
1818
- const R = setTimeout(() => {
1818
+ const _ = setTimeout(() => {
1819
1819
  E = !0, b.abort();
1820
- }, a.timeoutMs ?? Ot), P = () => b.abort();
1821
- o && (o.aborted ? b.abort() : o.addEventListener("abort", P));
1820
+ }, s.timeoutMs ?? Lt), O = () => b.abort();
1821
+ o && (o.aborted ? b.abort() : o.addEventListener("abort", O));
1822
1822
  try {
1823
- const T = await fetch(i, {
1823
+ const N = await fetch(i, {
1824
1824
  method: "POST",
1825
- headers: { "Content-Type": "application/json", ...a.headers ?? {} },
1825
+ headers: { "Content-Type": "application/json", ...s.headers ?? {} },
1826
1826
  body: JSON.stringify({
1827
- connection: a.connection,
1828
- connectionId: a.connectionId,
1827
+ connection: s.connection,
1828
+ connectionId: s.connectionId,
1829
1829
  sql: n,
1830
- maxRows: s
1830
+ maxRows: a
1831
1831
  }),
1832
1832
  signal: b.signal
1833
- }), x = await T.text();
1833
+ }), x = await N.text();
1834
1834
  let F = null;
1835
1835
  if (x)
1836
1836
  try {
@@ -1841,62 +1841,62 @@ async function Ia(a, n, s, o) {
1841
1841
  results: [],
1842
1842
  error: {
1843
1843
  type: "BadResponse",
1844
- message: `SQL 服务返回的不是合法 JSON(HTTP ${T.status})`
1844
+ message: `SQL 服务返回的不是合法 JSON(HTTP ${N.status})`
1845
1845
  },
1846
1846
  durationMs: performance.now() - p
1847
1847
  };
1848
1848
  }
1849
- if (!T.ok) {
1850
- const q = F ? tr(F, performance.now() - p) : null;
1849
+ if (!N.ok) {
1850
+ const q = F ? or(F, performance.now() - p) : null;
1851
1851
  return {
1852
1852
  ok: !1,
1853
1853
  results: [],
1854
1854
  error: (q == null ? void 0 : q.error) ?? {
1855
- type: `Http${T.status}`,
1856
- message: `SQL 服务返回 HTTP ${T.status}${T.statusText ? ` ${T.statusText}` : ""}`
1855
+ type: `Http${N.status}`,
1856
+ message: `SQL 服务返回 HTTP ${N.status}${N.statusText ? ` ${N.statusText}` : ""}`
1857
1857
  },
1858
1858
  durationMs: performance.now() - p
1859
1859
  };
1860
1860
  }
1861
- return tr(F, performance.now() - p);
1862
- } catch (T) {
1861
+ return or(F, performance.now() - p);
1862
+ } catch (N) {
1863
1863
  if (E)
1864
1864
  return {
1865
1865
  ok: !1,
1866
1866
  results: [],
1867
1867
  error: {
1868
1868
  type: "Timeout",
1869
- message: `SQL 请求超时(${a.timeoutMs ?? Ot}ms)`
1869
+ message: `SQL 请求超时(${s.timeoutMs ?? Lt}ms)`
1870
1870
  },
1871
1871
  durationMs: performance.now() - p
1872
1872
  };
1873
- throw T;
1873
+ throw N;
1874
1874
  } finally {
1875
- clearTimeout(R), o == null || o.removeEventListener("abort", P);
1875
+ clearTimeout(_), o == null || o.removeEventListener("abort", O);
1876
1876
  }
1877
1877
  }
1878
- function nr(a, n) {
1879
- if (!a || typeof a != "object")
1878
+ function ir(s, n) {
1879
+ if (!s || typeof s != "object")
1880
1880
  return {
1881
1881
  ok: !1,
1882
1882
  results: [],
1883
1883
  error: { type: "SqlError", message: "SQL 执行器没有返回结果" },
1884
1884
  durationMs: n
1885
1885
  };
1886
- const s = Number.isFinite(a.durationMs) && a.durationMs >= 0 ? a.durationMs : n;
1887
- return a.ok ? {
1886
+ const a = Number.isFinite(s.durationMs) && s.durationMs >= 0 ? s.durationMs : n;
1887
+ return s.ok ? {
1888
1888
  ok: !0,
1889
- results: (a.results ?? []).map(nn),
1890
- durationMs: s
1889
+ results: (s.results ?? []).map(on),
1890
+ durationMs: a
1891
1891
  } : {
1892
1892
  ok: !1,
1893
- results: (a.results ?? []).map(nn),
1894
- error: a.error ? on(a.error, "SQL 执行失败") : { type: "SqlError", message: "SQL 执行失败" },
1895
- durationMs: s
1893
+ results: (s.results ?? []).map(on),
1894
+ error: s.error ? pn(s.error, "SQL 执行失败") : { type: "SqlError", message: "SQL 执行失败" },
1895
+ durationMs: a
1896
1896
  };
1897
1897
  }
1898
- async function yr(a, n, s = {}) {
1899
- const o = D(a), i = o.maxRows ?? gr, p = performance.now();
1898
+ async function kr(s, n, a = {}) {
1899
+ const o = D(s), i = o.maxRows ?? br, p = performance.now();
1900
1900
  if (!n.trim())
1901
1901
  return {
1902
1902
  ok: !1,
@@ -1905,23 +1905,23 @@ async function yr(a, n, s = {}) {
1905
1905
  durationMs: 0
1906
1906
  };
1907
1907
  try {
1908
- if (s.executor) {
1909
- const E = await s.executor(
1908
+ if (a.executor) {
1909
+ const E = await a.executor(
1910
1910
  { sql: n, connection: o.connection, maxRows: i },
1911
- { signal: s.signal }
1911
+ { signal: a.signal }
1912
1912
  );
1913
- return nr(E, performance.now() - p);
1913
+ return ir(E, performance.now() - p);
1914
1914
  }
1915
1915
  if (o.mode === "http")
1916
- return await Ia(o, n, i, s.signal);
1917
- const b = await rn().executeSql({
1916
+ return await Us(o, n, i, a.signal);
1917
+ const b = await un().executeSql({
1918
1918
  sql: n,
1919
1919
  database: o.connection.database || ":memory:",
1920
1920
  maxRows: i
1921
1921
  });
1922
- return nr(b, performance.now() - p);
1922
+ return ir(b, performance.now() - p);
1923
1923
  } catch (b) {
1924
- return _a(b) ? {
1924
+ return Bs(b) ? {
1925
1925
  ok: !1,
1926
1926
  results: [],
1927
1927
  error: { type: "AbortError", message: "SQL 执行已中断" },
@@ -1929,42 +1929,42 @@ async function yr(a, n, s = {}) {
1929
1929
  } : {
1930
1930
  ok: !1,
1931
1931
  results: [],
1932
- error: on(b, "SQL 执行失败"),
1932
+ error: pn(b, "SQL 执行失败"),
1933
1933
  durationMs: performance.now() - p
1934
1934
  };
1935
1935
  }
1936
1936
  }
1937
- function rr(a) {
1937
+ function lr(s) {
1938
1938
  var n;
1939
- return (n = ut.find((s) => s.value === a)) == null ? void 0 : n.defaultPort;
1939
+ return (n = dt.find((a) => a.value === s)) == null ? void 0 : n.defaultPort;
1940
1940
  }
1941
- async function Ha(a, n = {}) {
1941
+ async function As(s, n = {}) {
1942
1942
  var o;
1943
- const s = await yr(a, "SELECT 1", n);
1944
- return s.ok ? {
1943
+ const a = await kr(s, "SELECT 1", n);
1944
+ return a.ok ? {
1945
1945
  ok: !0,
1946
- message: `连接成功(${Math.max(1, Math.round(s.durationMs))}ms)`,
1947
- durationMs: s.durationMs
1946
+ message: `连接成功(${Math.max(1, Math.round(a.durationMs))}ms)`,
1947
+ durationMs: a.durationMs
1948
1948
  } : {
1949
1949
  ok: !1,
1950
- message: ((o = s.error) == null ? void 0 : o.message) ?? "连接失败",
1951
- durationMs: s.durationMs
1950
+ message: ((o = a.error) == null ? void 0 : o.message) ?? "连接失败",
1951
+ durationMs: a.durationMs
1952
1952
  };
1953
1953
  }
1954
- async function ln(a, n, s, o = {}) {
1955
- var P, T;
1956
- const i = D(a), p = (i.endpoint ?? "").trim().replace(/\/+$/, "");
1954
+ async function fn(s, n, a, o = {}) {
1955
+ var O, N;
1956
+ const i = D(s), p = (i.endpoint ?? "").trim().replace(/\/+$/, "");
1957
1957
  if (!p)
1958
1958
  throw new Error("未配置 SQL 服务端点");
1959
- const b = new AbortController(), E = setTimeout(() => b.abort(), i.timeoutMs ?? Ot), R = () => b.abort();
1960
- o.signal && (o.signal.aborted ? b.abort() : o.signal.addEventListener("abort", R));
1959
+ const b = new AbortController(), E = setTimeout(() => b.abort(), i.timeoutMs ?? Lt), _ = () => b.abort();
1960
+ o.signal && (o.signal.aborted ? b.abort() : o.signal.addEventListener("abort", _));
1961
1961
  try {
1962
1962
  const x = await fetch(p + n, {
1963
- ...s,
1963
+ ...a,
1964
1964
  headers: {
1965
1965
  "Content-Type": "application/json",
1966
1966
  ...i.headers ?? {},
1967
- ...s.headers ?? {}
1967
+ ...a.headers ?? {}
1968
1968
  },
1969
1969
  signal: b.signal
1970
1970
  }), F = await x.text();
@@ -1976,57 +1976,57 @@ async function ln(a, n, s, o = {}) {
1976
1976
  throw new Error(`SQL 服务返回的不是合法 JSON(HTTP ${x.status})`);
1977
1977
  }
1978
1978
  if (!x.ok || !q || q.ok === !1)
1979
- throw new Error(((P = q == null ? void 0 : q.error) == null ? void 0 : P.message) ?? `SQL 服务返回 HTTP ${x.status}`);
1979
+ throw new Error(((O = q == null ? void 0 : q.error) == null ? void 0 : O.message) ?? `SQL 服务返回 HTTP ${x.status}`);
1980
1980
  return q.data;
1981
1981
  } finally {
1982
- clearTimeout(E), (T = o.signal) == null || T.removeEventListener("abort", R);
1982
+ clearTimeout(E), (N = o.signal) == null || N.removeEventListener("abort", _);
1983
1983
  }
1984
1984
  }
1985
- function Ba(a, n = {}) {
1986
- return ln(a, "/connections", { method: "GET" }, n);
1985
+ function Ds(s, n = {}) {
1986
+ return fn(s, "/connections", { method: "GET" }, n);
1987
1987
  }
1988
- function Ua(a, n, s, o = {}) {
1989
- return ln(
1990
- a,
1991
- s ? `/connections/${encodeURIComponent(s)}` : "/connections",
1992
- { method: s ? "PUT" : "POST", body: JSON.stringify(n) },
1988
+ function zs(s, n, a, o = {}) {
1989
+ return fn(
1990
+ s,
1991
+ a ? `/connections/${encodeURIComponent(a)}` : "/connections",
1992
+ { method: a ? "PUT" : "POST", body: JSON.stringify(n) },
1993
1993
  o
1994
1994
  );
1995
1995
  }
1996
- async function sr(a, n, s = {}) {
1997
- await ln(
1998
- a,
1996
+ async function ur(s, n, a = {}) {
1997
+ await fn(
1998
+ s,
1999
1999
  `/connections/${encodeURIComponent(n)}`,
2000
2000
  { method: "DELETE" },
2001
- s
2001
+ a
2002
2002
  );
2003
2003
  }
2004
- const Mt = [
2004
+ const $t = [
2005
2005
  { value: "python", label: "Python", extension: "py" },
2006
2006
  { value: "sql", label: "SQL", extension: "sql" },
2007
2007
  { value: "javascript", label: "JavaScript", extension: "js" },
2008
2008
  { value: "json", label: "JSON", extension: "json" }
2009
2009
  ];
2010
- function Ct(a) {
2011
- return Mt.find((n) => n.value === a) ?? Mt[0];
2010
+ function Mt(s) {
2011
+ return $t.find((n) => n.value === s) ?? $t[0];
2012
2012
  }
2013
- function Gt(a) {
2014
- switch (a) {
2013
+ function en(s) {
2014
+ switch (s) {
2015
2015
  case "sql":
2016
- return na();
2016
+ return os();
2017
2017
  case "javascript":
2018
- return ea();
2018
+ return as();
2019
2019
  case "json":
2020
- return ta();
2020
+ return ss();
2021
2021
  case "python":
2022
2022
  default:
2023
- return pr();
2023
+ return mr();
2024
2024
  }
2025
2025
  }
2026
- function ar(a) {
2027
- const n = a.lastIndexOf(".");
2026
+ function cr(s) {
2027
+ const n = s.lastIndexOf(".");
2028
2028
  if (n < 0) return "python";
2029
- switch (a.slice(n + 1).toLowerCase()) {
2029
+ switch (s.slice(n + 1).toLowerCase()) {
2030
2030
  case "sql":
2031
2031
  return "sql";
2032
2032
  case "js":
@@ -2041,7 +2041,7 @@ function ar(a) {
2041
2041
  return "python";
2042
2042
  }
2043
2043
  }
2044
- const or = [
2044
+ const ln = [
2045
2045
  { value: "light", label: "明亮", dark: !1 },
2046
2046
  { value: "dark", label: "深色", dark: !0 },
2047
2047
  { value: "github-light", label: "GitHub 浅色", dark: !1 },
@@ -2051,15 +2051,15 @@ const or = [
2051
2051
  { value: "solarized-light", label: "Solarized 浅色", dark: !1 },
2052
2052
  { value: "monokai", label: "Monokai", dark: !0 }
2053
2053
  ];
2054
- function Aa(a) {
2055
- return or.find((n) => n.value === a) ?? or[0];
2054
+ function js(s) {
2055
+ return ln.find((n) => n.value === s) ?? ln[0];
2056
2056
  }
2057
- function ir(a) {
2058
- return Aa(a).dark;
2057
+ function ut(s) {
2058
+ return js(s).dark;
2059
2059
  }
2060
- function Z(a) {
2061
- const n = Array.isArray(a) ? a : [a];
2062
- return () => Dn(
2060
+ function Z(s) {
2061
+ const n = Array.isArray(s) ? s : [s];
2062
+ return () => Kn(
2063
2063
  "svg",
2064
2064
  {
2065
2065
  viewBox: "0 0 24 24",
@@ -2068,111 +2068,111 @@ function Z(a) {
2068
2068
  fill: "currentColor",
2069
2069
  "aria-hidden": "true"
2070
2070
  },
2071
- n.map((s) => Dn("path", { d: s }))
2071
+ n.map((a) => Kn("path", { d: a }))
2072
2072
  );
2073
2073
  }
2074
- const Da = Z(
2074
+ const Vs = Z(
2075
2075
  "M8 5.14v13.72a1 1 0 0 0 1.54.84l10.3-6.86a1 1 0 0 0 0-1.68L9.54 4.3A1 1 0 0 0 8 5.14Z"
2076
- ), za = Z("M6 6h12v12H6Z"), lr = Z(
2076
+ ), Qs = Z("M6 6h12v12H6Z"), dr = Z(
2077
2077
  "M9 3h6a1 1 0 0 1 1 1v1h4a1 1 0 1 1 0 2h-1.06l-.87 12.13A2 2 0 0 1 16.08 21H7.92a2 2 0 0 1-1.99-1.87L5.06 7H4a1 1 0 0 1 0-2h4V4a1 1 0 0 1 1-1Zm1 2h4V5h-4v0Zm-2.92 2h9.84l-.85 12.07a.5.5 0 0 1-.5.43H7.93a.5.5 0 0 1-.5-.43Z"
2078
- ), ja = Z(
2078
+ ), Ks = Z(
2079
2079
  "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"
2080
- ), Va = Z(
2080
+ ), Js = Z(
2081
2081
  "M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"
2082
- ), ur = Z(
2082
+ ), pr = Z(
2083
2083
  "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"
2084
- ), cr = Z("M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"), Qa = Z(
2084
+ ), fr = Z("M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"), Zs = Z(
2085
2085
  "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
2086
- ), Ka = Z("M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"), lt = Z(
2086
+ ), Gs = Z("M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"), ct = Z(
2087
2087
  "M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12 5.7 16.89a1 1 0 1 0 1.41 1.41L12 13.41l4.89 4.89a1 1 0 0 0 1.41-1.41L13.41 12l4.89-4.89a1 1 0 0 0 0-1.4Z"
2088
- ), Ja = Z("M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6V5z"), Za = Z([
2088
+ ), Ws = Z("M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6V5z"), Ys = Z([
2089
2089
  "M12 2C7.58 2 4 3.34 4 5v14c0 1.66 3.58 3 8 3s8-1.34 8-3V5c0-1.66-3.58-3-8-3Zm6 17c0 .35-2.03 1.4-6 1.4S6 19.35 6 19v-2.68c1.45.74 3.6 1.18 6 1.18s4.55-.44 6-1.18V19Zm0-5c0 .35-2.03 1.4-6 1.4S6 14.35 6 14v-2.68c1.45.74 3.6 1.18 6 1.18s4.55-.44 6-1.18V14Zm-6-3.6c-3.87 0-6-1.02-6-1.4V6.32C7.45 7.06 9.6 7.5 12 7.5s4.55-.44 6-1.18V9c0 .38-2.13 1.4-6 1.4Z"
2090
- ]), Ga = Z(
2090
+ ]), Xs = Z(
2091
2091
  "M17 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-4-4zm-5 16a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm3-10H5V5h10v4z"
2092
- ), Wa = Z([
2092
+ ), eo = Z([
2093
2093
  "M4 4h16a1 1 0 0 1 1 1v5H3V5a1 1 0 0 1 1-1Zm-1 8h18v5H3v-5Z",
2094
2094
  "M18 15.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"
2095
- ]), Ya = {
2095
+ ]), to = {
2096
2096
  key: 0,
2097
2097
  class: "vpe-toolbar"
2098
- }, Xa = { class: "vpe-toolbar-main" }, eo = ["title", "disabled"], to = ["disabled"], no = ["disabled"], ro = ["title", "disabled"], so = ["title", "aria-label"], ao = { key: 2 }, oo = { key: 3 }, io = ["disabled"], lo = {
2098
+ }, no = { class: "vpe-toolbar-main" }, ro = ["title", "disabled"], ao = ["disabled"], so = ["disabled"], oo = ["title", "disabled"], io = ["title", "aria-label"], lo = { key: 2 }, uo = { key: 3 }, co = ["disabled"], po = {
2099
2099
  class: "vpe-file",
2100
2100
  title: "当前文件名(下载时使用)"
2101
- }, uo = { class: "vpe-toolbar-end" }, co = ["disabled"], po = {
2101
+ }, fo = ["value"], vo = ["value"], mo = { class: "vpe-toolbar-end" }, go = ["disabled"], yo = {
2102
2102
  value: "",
2103
2103
  disabled: ""
2104
- }, fo = ["value"], vo = { class: "vpe-toolbar-chips" }, mo = ["title"], go = { class: "vpe-status-text" }, yo = ["value", "disabled"], ho = ["value"], bo = ["aria-selected", "data-file-id", "title", "onClick", "onKeydown"], ko = { class: "vpe-tab-name" }, wo = ["title", "aria-label", "disabled", "onClick"], So = ["disabled"], xo = { class: "vpe-output-head" }, Eo = { class: "vpe-output-main" }, qo = {
2104
+ }, ho = ["value"], bo = { class: "vpe-toolbar-chips" }, ko = ["title"], wo = { class: "vpe-status-text" }, So = ["value", "disabled"], xo = ["value"], Eo = ["aria-selected", "data-file-id", "title", "onClick", "onKeydown"], qo = { class: "vpe-tab-name" }, Co = ["title", "aria-label", "disabled", "onClick"], Po = ["disabled"], Oo = { class: "vpe-output-head" }, Mo = { class: "vpe-output-main" }, To = {
2105
2105
  key: 0,
2106
2106
  class: "vpe-sql-results"
2107
- }, Co = { class: "vpe-sql-result-head" }, Po = {
2107
+ }, No = { class: "vpe-sql-result-head" }, Lo = {
2108
2108
  key: 0,
2109
2109
  class: "vpe-sql-table-wrap"
2110
- }, Oo = { class: "vpe-sql-table" }, Mo = {
2110
+ }, $o = { class: "vpe-sql-table" }, Fo = {
2111
2111
  key: 0,
2112
2112
  class: "vpe-sql-empty"
2113
- }, No = {
2113
+ }, _o = {
2114
2114
  key: 1,
2115
2115
  class: "vpe-sql-affected"
2116
- }, To = {
2116
+ }, Ro = {
2117
2117
  key: 1,
2118
2118
  class: "vpe-empty"
2119
- }, Lo = {
2119
+ }, Io = {
2120
2120
  key: 0,
2121
2121
  class: "vpe-terminal-input"
2122
- }, $o = ["onKeydown"], Fo = {
2122
+ }, Ho = ["onKeydown"], Bo = {
2123
2123
  key: 4,
2124
2124
  class: "vpe-fs-panel",
2125
2125
  role: "dialog",
2126
2126
  "aria-label": "虚拟文件"
2127
- }, Ro = { class: "vpe-fs-head" }, _o = ["disabled"], Io = { class: "vpe-fs-body" }, Ho = {
2127
+ }, Uo = { class: "vpe-fs-head" }, Ao = ["disabled"], Do = { class: "vpe-fs-body" }, zo = {
2128
2128
  key: 0,
2129
2129
  class: "vpe-fs-empty"
2130
- }, Bo = {
2130
+ }, jo = {
2131
2131
  key: 0,
2132
2132
  class: "vpe-fs-empty"
2133
- }, Uo = ["title"], Ao = { class: "vpe-fs-size" }, Do = ["title", "aria-label", "onClick"], zo = {
2133
+ }, Vo = ["title"], Qo = { class: "vpe-fs-size" }, Ko = ["title", "aria-label", "onClick"], Jo = {
2134
2134
  key: 5,
2135
2135
  class: "vpe-fs-panel",
2136
2136
  role: "dialog",
2137
2137
  "aria-label": "服务端文件"
2138
- }, jo = { class: "vpe-fs-head" }, Vo = ["disabled"], Qo = { class: "vpe-fs-body" }, Ko = {
2138
+ }, Zo = { class: "vpe-fs-head" }, Go = ["disabled"], Wo = { class: "vpe-fs-body" }, Yo = {
2139
2139
  key: 0,
2140
2140
  class: "vpe-fs-empty"
2141
- }, Jo = {
2141
+ }, Xo = {
2142
2142
  key: 0,
2143
2143
  class: "vpe-fs-empty"
2144
- }, Zo = ["title"], Go = ["title"], Wo = ["title", "disabled", "onClick"], Yo = ["title", "disabled", "onClick"], Xo = {
2144
+ }, ei = ["title"], ti = ["title"], ni = ["title", "disabled", "onClick"], ri = ["title", "disabled", "onClick"], ai = {
2145
2145
  key: 1,
2146
2146
  class: "vpe-sql-hint vpe-sql-hint--error"
2147
- }, ei = {
2147
+ }, si = {
2148
2148
  key: 6,
2149
2149
  class: "vpe-sql-panel",
2150
2150
  role: "dialog",
2151
2151
  "aria-label": "SQL 连接配置"
2152
- }, ti = { class: "vpe-fs-head" }, ni = { class: "vpe-fs-title" }, ri = { class: "vpe-sql-body" }, si = { class: "vpe-sql-field" }, ai = { class: "vpe-sql-field" }, oi = { class: "vpe-sql-field" }, ii = { class: "vpe-sql-field" }, li = ["value"], ui = { class: "vpe-sql-row" }, ci = { class: "vpe-sql-field vpe-sql-field--grow" }, di = { class: "vpe-sql-field vpe-sql-field--grow" }, pi = { class: "vpe-sql-row" }, fi = { class: "vpe-sql-field vpe-sql-field--grow" }, vi = { class: "vpe-sql-field vpe-sql-field--grow" }, mi = ["placeholder"], gi = { class: "vpe-sql-field" }, yi = {
2152
+ }, oi = { class: "vpe-fs-head" }, ii = { class: "vpe-fs-title" }, li = { class: "vpe-sql-body" }, ui = { class: "vpe-sql-field" }, ci = { class: "vpe-sql-field" }, di = { class: "vpe-sql-field" }, pi = { class: "vpe-sql-field" }, fi = ["value"], vi = { class: "vpe-sql-row" }, mi = { class: "vpe-sql-field vpe-sql-field--grow" }, gi = { class: "vpe-sql-field vpe-sql-field--grow" }, yi = { class: "vpe-sql-row" }, hi = { class: "vpe-sql-field vpe-sql-field--grow" }, bi = { class: "vpe-sql-field vpe-sql-field--grow" }, ki = ["placeholder"], wi = { class: "vpe-sql-field" }, Si = {
2153
2153
  key: 0,
2154
2154
  class: "vpe-sql-field"
2155
- }, hi = {
2155
+ }, xi = {
2156
2156
  key: 1,
2157
2157
  class: "vpe-sql-hint"
2158
- }, bi = { class: "vpe-sql-actions" }, ki = ["disabled"], wi = ["disabled"], Si = ["disabled"], xi = {
2158
+ }, Ei = { class: "vpe-sql-actions" }, qi = ["disabled"], Ci = ["disabled"], Pi = ["disabled"], Oi = {
2159
2159
  key: 3,
2160
2160
  class: "vpe-sql-test vpe-sql-test--err"
2161
- }, Ei = {
2161
+ }, Mi = {
2162
2162
  key: 7,
2163
2163
  class: "vpe-sql-manager-panel",
2164
2164
  role: "dialog",
2165
2165
  "aria-label": "连接管理"
2166
- }, qi = { class: "vpe-fs-head" }, Ci = ["disabled"], Pi = { class: "vpe-sql-manager-body" }, Oi = {
2166
+ }, Ti = { class: "vpe-fs-head" }, Ni = ["disabled"], Li = { class: "vpe-sql-manager-body" }, $i = {
2167
2167
  key: 0,
2168
2168
  class: "vpe-fs-empty"
2169
- }, Mi = {
2169
+ }, Fi = {
2170
2170
  key: 0,
2171
2171
  class: "vpe-fs-empty"
2172
- }, Ni = { class: "vpe-sql-manager-main" }, Ti = ["title"], Li = { class: "vpe-sql-manager-meta" }, $i = ["onClick"], Fi = ["disabled", "onClick"], Ri = {
2172
+ }, _i = { class: "vpe-sql-manager-main" }, Ri = ["title"], Ii = { class: "vpe-sql-manager-meta" }, Hi = ["onClick"], Bi = ["disabled", "onClick"], Ui = {
2173
2173
  key: 1,
2174
2174
  class: "vpe-sql-hint vpe-sql-hint--error"
2175
- }, Wt = 1, dr = 80, _i = /* @__PURE__ */ Ms({
2175
+ }, tn = 1, vr = 80, Ai = /* @__PURE__ */ $a({
2176
2176
  __name: "PythonEditor",
2177
2177
  props: {
2178
2178
  modelValue: { default: "" },
@@ -2206,184 +2206,184 @@ const Da = Z(
2206
2206
  pythonHeaders: { default: void 0 },
2207
2207
  runtime: { default: "browser" }
2208
2208
  },
2209
- emits: ["update:modelValue", "ready", "statusChange", "runStart", "runOutput", "runError", "runFinish", "loadError", "update:fileName", "update:language", "newFile", "fileClose", "fileSwitch", "copy", "download", "fileOpen", "fsDownload", "update:sqlConfig", "update:runtime", "sqlResult", "sqlError"],
2210
- setup(a, { expose: n, emit: s }) {
2211
- const o = a, i = s, p = C(), b = C(), E = C(), R = C(), P = C(), T = C(), x = C(null), F = C(!1), q = zn(/* @__PURE__ */ new Map()), G = U(() => pe().lines), ve = U(() => pe().sqlResults), O = zn(/* @__PURE__ */ new Map()), V = U(() => O.get(w.value.id) ?? null), Ue = U(() => {
2209
+ emits: ["update:modelValue", "ready", "statusChange", "runStart", "runOutput", "runError", "runFinish", "loadError", "update:fileName", "update:language", "update:theme", "newFile", "fileClose", "fileSwitch", "copy", "download", "fileOpen", "fsDownload", "update:sqlConfig", "update:runtime", "sqlResult", "sqlError"],
2210
+ setup(s, { expose: n, emit: a }) {
2211
+ const o = s, i = a, p = C(), b = C(), E = C(), _ = C(), O = C(), N = C(), x = C(null), F = C(!1), q = Jn(/* @__PURE__ */ new Map()), G = U(() => fe().lines), me = U(() => fe().sqlResults), M = Jn(/* @__PURE__ */ new Map()), Q = U(() => M.get(w.value.id) ?? null), Ue = U(() => {
2212
2212
  var e;
2213
- return !!((e = V.value) != null && e.busy);
2213
+ return !!((e = Q.value) != null && e.busy);
2214
2214
  }), Ae = U(() => {
2215
2215
  var e;
2216
- return !!((e = V.value) != null && e.waiting);
2216
+ return !!((e = Q.value) != null && e.waiting);
2217
2217
  }), H = U({
2218
2218
  get: () => {
2219
2219
  var e;
2220
- return ((e = V.value) == null ? void 0 : e.input) ?? "";
2220
+ return ((e = Q.value) == null ? void 0 : e.input) ?? "";
2221
2221
  },
2222
2222
  set: (e) => {
2223
- const t = V.value;
2223
+ const t = Q.value;
2224
2224
  t && (t.input = e);
2225
2225
  }
2226
- }), k = C(null), I = C("idle"), Q = C(o.runtime), me = C(!1), qe = C(!1), Ye = C(!1), Xe = C([]), Se = C(!1), dt = C(!1), et = C([]), De = C(""), W = C(!1), Fe = C(!1), xe = C(!1), Re = C(!1), tt = C(""), pt = C(!1), f = C(D(o.sqlConfig)), Ce = C([]), ze = C(!1), Pe = C(""), ee = C(""), te = C(!1), ne = C(""), je = C(!1), _e = C(!1), Ve = C(""), ft = C(!1);
2227
- let Tt = !1, vt, un = !1, Lt = !1, cn = !1, M = null, hr = 0, br = 0, mt = null, gt = null, $t, ce = null, Y = null, re = null, se = null, kr = 0, nt = 0;
2228
- function Qe(e, t, r) {
2229
- return { id: ++br, name: e, language: t, code: r };
2226
+ }), k = C(null), I = C("idle"), z = C(o.theme), ce = C(o.runtime), Se = C(!1), De = C(!1), Xe = C(!1), et = C([]), xe = C(!1), ft = C(!1), tt = C([]), ze = C(""), W = C(!1), Fe = C(!1), Ee = C(!1), _e = C(!1), nt = C(""), vt = C(!1), f = C(D(o.sqlConfig)), Ce = C([]), je = C(!1), Pe = C(""), ne = C(""), re = C(!1), ae = C(""), Ve = C(!1), Re = C(!1), Qe = C(""), mt = C(!1);
2227
+ let _t = !1, gt, vn = !1, Rt = !1, mn = !1, P = null, wr = 0, Sr = 0, yt = null, ht = null, It, de = null, Y = null, se = null, oe = null, xr = 0, rt = 0;
2228
+ function Ke(e, t, r) {
2229
+ return { id: ++Sr, name: e, language: t, code: r };
2230
2230
  }
2231
- const L = C([Qe(o.fileName, o.language, o.modelValue)]), Ee = C(L.value[0].id), w = U(
2232
- () => L.value.find((e) => e.id === Ee.value) ?? L.value[0]
2231
+ const L = C([Ke(o.fileName, o.language, o.modelValue)]), qe = C(L.value[0].id), w = U(
2232
+ () => L.value.find((e) => e.id === qe.value) ?? L.value[0]
2233
2233
  ), Ie = U({
2234
2234
  get: () => w.value.name,
2235
2235
  set: (e) => {
2236
2236
  const t = w.value;
2237
2237
  t.name !== e && (t.name = e, i("update:fileName", e));
2238
2238
  }
2239
- }), dn = new Kt(), Ft = new Kt(), Rt = new Kt(), z = rn(o.pyodideUrl ? { pyodideUrl: o.pyodideUrl } : void 0), wr = U(() => ({
2239
+ }), gn = new qt(), Ht = new qt(), Bt = new qt(), Ut = new qt(), j = un(o.pyodideUrl ? { pyodideUrl: o.pyodideUrl } : void 0), Er = U(() => ({
2240
2240
  height: typeof o.height == "number" ? `${o.height}px` : o.height
2241
- })), Sr = U(() => [
2242
- `vpe-theme-${o.theme}`,
2243
- ir(o.theme) ? "vpe-dark" : ""
2241
+ })), qr = U(() => [
2242
+ `vpe-theme-${z.value}`,
2243
+ ut(z.value) ? "vpe-dark" : ""
2244
2244
  ]);
2245
- let pn = 0, _t = 0, Ke = null;
2246
- const xr = U(
2245
+ let yn = 0, At = 0, Je = null;
2246
+ const Cr = U(
2247
2247
  () => x.value !== null ? `${x.value}px` : typeof o.outputHeight == "number" ? `${o.outputHeight}px` : o.outputHeight
2248
- ), de = U(() => w.value.language === "sql"), fn = U(() => w.value.language === "python"), yt = U(() => !!(o.pythonEndpoint ?? "").trim()), Je = U(
2249
- () => fn.value && yt.value && Q.value === "server"
2250
- ), Oe = U(() => !!(o.filesEndpoint ?? "").trim()), It = U(() => Ue.value || xe.value && k.value === w.value.id ? !0 : I.value === "running" && k.value === w.value.id), vn = U(() => de.value && f.value.mode === "http" ? xe.value && k.value === w.value.id ? "查询中" : "外部服务" : Je.value ? Ue.value ? Ae.value ? "等待输入" : "执行中" : "服务端" : I.value === "running" && k.value !== w.value.id ? "就绪" : {
2248
+ ), pe = U(() => w.value.language === "sql"), hn = U(() => w.value.language === "python"), bt = U(() => !!(o.pythonEndpoint ?? "").trim()), Ze = U(
2249
+ () => hn.value && bt.value && ce.value === "server"
2250
+ ), Oe = U(() => !!(o.filesEndpoint ?? "").trim()), Dt = U(() => Ue.value || Ee.value && k.value === w.value.id ? !0 : I.value === "running" && k.value === w.value.id), bn = U(() => pe.value && f.value.mode === "http" ? Ee.value && k.value === w.value.id ? "查询中" : "外部服务" : Ze.value ? Ue.value ? Ae.value ? "等待输入" : "执行中" : "服务端" : I.value === "running" && k.value !== w.value.id ? "就绪" : {
2251
2251
  idle: "未加载",
2252
2252
  loading: "正在加载 Pyodide…",
2253
2253
  ready: "就绪",
2254
2254
  running: "运行中"
2255
- }[I.value]), Er = U(() => de.value && f.value.mode === "http" ? xe.value && k.value === w.value.id ? "running" : "ready" : Je.value ? Ue.value ? Ae.value ? "loading" : "running" : "ready" : I.value === "running" && k.value !== w.value.id ? "ready" : I.value), qr = U(() => de.value ? "执行 SQL (Ctrl+Enter)" : Je.value ? "运行(服务端 Python,Ctrl+Enter)" : w.value.language === "python" ? "运行 (Ctrl+Enter)" : "仅支持执行 Python / SQL 文件"), Cr = U(() => It.value ? !0 : Je.value || de.value ? !1 : I.value === "loading" || w.value.language !== "python"), Pr = U(() => f.value.mode === "http" ? f.value.connectionId ? "SQL 连接配置" : "新建 SQL 连接" : "SQL 连接");
2256
- function Ze(e) {
2255
+ }[I.value]), Pr = U(() => pe.value && f.value.mode === "http" ? Ee.value && k.value === w.value.id ? "running" : "ready" : Ze.value ? Ue.value ? Ae.value ? "loading" : "running" : "ready" : I.value === "running" && k.value !== w.value.id ? "ready" : I.value), Or = U(() => pe.value ? "执行 SQL (Ctrl+Enter)" : Ze.value ? "运行(服务端 Python,Ctrl+Enter)" : w.value.language === "python" ? "运行 (Ctrl+Enter)" : "仅支持执行 Python / SQL 文件"), Mr = U(() => Dt.value ? !0 : Ze.value || pe.value ? !1 : I.value === "loading" || w.value.language !== "python"), Tr = U(() => f.value.mode === "http" ? f.value.connectionId ? "SQL 连接配置" : "新建 SQL 连接" : "SQL 连接");
2256
+ function Ge(e) {
2257
2257
  return { ...e };
2258
2258
  }
2259
- function pe(e = w.value.id) {
2259
+ function fe(e = w.value.id) {
2260
2260
  let t = q.get(e);
2261
2261
  return t || (t = { lines: [], sqlResults: [] }, q.set(e, t)), t;
2262
2262
  }
2263
2263
  function ge(e, t, r) {
2264
- pe(r).lines.push({ id: ++hr, stream: e, text: t });
2264
+ fe(r).lines.push({ id: ++wr, stream: e, text: t });
2265
2265
  }
2266
2266
  function h(e, t) {
2267
2267
  ge("system", e, t);
2268
2268
  }
2269
- function Or(e) {
2270
- return Mt.some((t) => t.value === e);
2269
+ function Nr(e) {
2270
+ return $t.some((t) => t.value === e);
2271
2271
  }
2272
- function Mr() {
2272
+ function Lr() {
2273
2273
  if (!o.storageKey || typeof window > "u") return null;
2274
2274
  try {
2275
2275
  const e = window.localStorage.getItem(o.storageKey);
2276
2276
  if (!e) return null;
2277
2277
  const t = JSON.parse(e);
2278
- if (t.version !== Wt || !Array.isArray(t.files)) return null;
2278
+ if (t.version !== tn || !Array.isArray(t.files)) return null;
2279
2279
  const r = [];
2280
2280
  for (const y of t.files) {
2281
2281
  if (!y || typeof y.name != "string" || typeof y.code != "string" || !y.name.trim()) continue;
2282
- const S = Or(y.language) ? y.language : "python";
2282
+ const S = Nr(y.language) ? y.language : "python";
2283
2283
  r.push({ name: y.name, language: S, code: y.code });
2284
2284
  }
2285
2285
  if (!r.length) return null;
2286
2286
  const u = typeof t.activeIndex == "number" ? t.activeIndex : 0, c = Math.min(Math.max(Math.trunc(u) || 0, 0), r.length - 1);
2287
- return { version: Wt, files: r, activeIndex: c };
2287
+ return { version: tn, files: r, activeIndex: c };
2288
2288
  } catch {
2289
2289
  return null;
2290
2290
  }
2291
2291
  }
2292
- function Nr() {
2293
- const e = Mr();
2292
+ function $r() {
2293
+ const e = Lr();
2294
2294
  if (!e) return;
2295
- L.value = e.files.map((r) => Qe(r.name, r.language, r.code));
2295
+ L.value = e.files.map((r) => Ke(r.name, r.language, r.code));
2296
2296
  const t = L.value[e.activeIndex] ?? L.value[0];
2297
- Ee.value = t.id, h(`已恢复上次编辑内容(${L.value.length} 个文件)`), i("update:modelValue", t.code), i("update:fileName", t.name), i("update:language", t.language);
2297
+ qe.value = t.id, h(`已恢复上次编辑内容(${L.value.length} 个文件)`), i("update:modelValue", t.code), i("update:fileName", t.name), i("update:language", t.language);
2298
2298
  }
2299
- function mn() {
2300
- if (!(!Tt || Lt || !o.storageKey || typeof window > "u"))
2299
+ function kn() {
2300
+ if (!(!_t || Rt || !o.storageKey || typeof window > "u"))
2301
2301
  try {
2302
2302
  const e = {
2303
- version: Wt,
2303
+ version: tn,
2304
2304
  files: L.value.map((t) => ({
2305
2305
  name: t.name,
2306
2306
  language: t.language,
2307
2307
  code: t.code
2308
2308
  })),
2309
2309
  activeIndex: Math.max(
2310
- L.value.findIndex((t) => t.id === Ee.value),
2310
+ L.value.findIndex((t) => t.id === qe.value),
2311
2311
  0
2312
2312
  )
2313
2313
  };
2314
2314
  window.localStorage.setItem(o.storageKey, JSON.stringify(e));
2315
2315
  } catch (e) {
2316
- un || (un = !0, h(`本地草稿保存失败:${e instanceof Error ? e.message : String(e)}`));
2316
+ vn || (vn = !0, h(`本地草稿保存失败:${e instanceof Error ? e.message : String(e)}`));
2317
2317
  }
2318
2318
  }
2319
- function Tr() {
2320
- !Tt || !o.storageKey || typeof window > "u" || (Lt = !1, window.clearTimeout(vt), vt = window.setTimeout(mn, 400));
2319
+ function Fr() {
2320
+ !_t || !o.storageKey || typeof window > "u" || (Rt = !1, window.clearTimeout(gt), gt = window.setTimeout(kn, 400));
2321
2321
  }
2322
- function Lr() {
2322
+ function _r() {
2323
2323
  if (!(!o.storageKey || typeof window > "u")) {
2324
- window.clearTimeout(vt);
2324
+ window.clearTimeout(gt);
2325
2325
  try {
2326
- window.localStorage.removeItem(o.storageKey), Lt = !0, h("已清除本地草稿");
2326
+ window.localStorage.removeItem(o.storageKey), Rt = !0, h("已清除本地草稿");
2327
2327
  } catch (e) {
2328
2328
  h(`清除本地草稿失败:${e instanceof Error ? e.message : String(e)}`);
2329
2329
  }
2330
2330
  }
2331
2331
  }
2332
2332
  function Me(e) {
2333
- if (!M) return;
2333
+ if (!P) return;
2334
2334
  const t = e ? [e] : [];
2335
- M.dispatch({ effects: fr.of(t) });
2335
+ P.dispatch({ effects: gr.of(t) });
2336
2336
  }
2337
- function $r() {
2337
+ function Rr() {
2338
2338
  const e = o.modelValue;
2339
- if (M) {
2340
- e !== M.state.doc.toString() && M.dispatch({ changes: { from: 0, to: M.state.doc.length, insert: e } });
2339
+ if (P) {
2340
+ e !== P.state.doc.toString() && P.dispatch({ changes: { from: 0, to: P.state.doc.length, insert: e } });
2341
2341
  return;
2342
2342
  }
2343
2343
  const t = w.value;
2344
2344
  t.code !== e && (t.code = e);
2345
2345
  }
2346
- function Ne() {
2347
- return M ? M.state.doc.toString() : w.value.code;
2346
+ function Te() {
2347
+ return P ? P.state.doc.toString() : w.value.code;
2348
2348
  }
2349
- function ht(e) {
2350
- if (M) {
2351
- e !== M.state.doc.toString() && M.dispatch({ changes: { from: 0, to: M.state.doc.length, insert: e } });
2349
+ function kt(e) {
2350
+ if (P) {
2351
+ e !== P.state.doc.toString() && P.dispatch({ changes: { from: 0, to: P.state.doc.length, insert: e } });
2352
2352
  return;
2353
2353
  }
2354
2354
  const t = w.value;
2355
2355
  t.code = e, e !== o.modelValue && i("update:modelValue", e);
2356
2356
  }
2357
- function Ht(e) {
2358
- return o.disableLint || e !== "python" ? [] : ha(z, o.lintDelay);
2357
+ function zt(e) {
2358
+ return o.disableLint || e !== "python" ? [] : ws(j, o.lintDelay);
2359
2359
  }
2360
- function Bt(e) {
2360
+ function jt(e) {
2361
2361
  const t = w.value;
2362
2362
  if (t.language !== e) {
2363
- if (t.language = e, pe(t.id).sqlResults = [], Me(void 0), M == null || M.dispatch({
2363
+ if (t.language = e, fe(t.id).sqlResults = [], Me(void 0), P == null || P.dispatch({
2364
2364
  effects: [
2365
- Ft.reconfigure(Gt(e)),
2366
- Rt.reconfigure(Ht(e))
2365
+ Bt.reconfigure(en(e)),
2366
+ Ut.reconfigure(zt(e))
2367
2367
  ]
2368
2368
  }), /^untitled(-\d+)?\.[^.]+$/.test(t.name)) {
2369
- const u = `${t.name.slice(0, t.name.lastIndexOf("."))}.${Ct(e).extension}`;
2369
+ const u = `${t.name.slice(0, t.name.lastIndexOf("."))}.${Mt(e).extension}`;
2370
2370
  L.value.some((c) => c.id !== t.id && c.name === u) || (t.name = u, i("update:fileName", u));
2371
2371
  }
2372
2372
  i("update:language", e);
2373
2373
  }
2374
2374
  }
2375
- function Ut(e, t) {
2375
+ function Vt(e, t) {
2376
2376
  const u = e.trim().replace(/[\\/:*?"<>|]+/g, "_").replace(/\.+$/, "") || "untitled";
2377
- return /\.[^.\\/]+$/.test(u) ? u : `${u}.${Ct(t).extension}`;
2377
+ return /\.[^.\\/]+$/.test(u) ? u : `${u}.${Mt(t).extension}`;
2378
2378
  }
2379
- function gn(e) {
2380
- const t = Ct(e).extension, r = new Set(L.value.map((y) => y.name));
2379
+ function wn(e) {
2380
+ const t = Mt(e).extension, r = new Set(L.value.map((y) => y.name));
2381
2381
  let u = `untitled.${t}`, c = 2;
2382
2382
  for (; r.has(u); )
2383
2383
  u = `untitled-${c}.${t}`, c += 1;
2384
2384
  return u;
2385
2385
  }
2386
- function yn(e) {
2386
+ function Sn(e) {
2387
2387
  if (!L.value.some((S) => S.name === e)) return e;
2388
2388
  const t = e.lastIndexOf("."), r = t > 0 ? e.slice(0, t) : e, u = t > 0 ? e.slice(t) : "";
2389
2389
  let c = 2, y = `${r}-${c}${u}`;
@@ -2391,38 +2391,38 @@ const Da = Z(
2391
2391
  c += 1, y = `${r}-${c}${u}`;
2392
2392
  return y;
2393
2393
  }
2394
- let Ge = 0;
2395
- function Fr(e) {
2394
+ let We = 0;
2395
+ function Ir(e) {
2396
2396
  return !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
2397
2397
  }
2398
- async function Rr() {
2398
+ async function Hr() {
2399
2399
  var t;
2400
2400
  if (!o.syncFilesOnRun) return;
2401
2401
  const e = L.value.filter((r) => r.language === "python");
2402
2402
  for (const r of e) {
2403
- if (!Fr(r.name)) {
2403
+ if (!Ir(r.name)) {
2404
2404
  h(`跳过同步文件:${r.name}(文件名不能包含路径分隔符)`);
2405
2405
  continue;
2406
2406
  }
2407
- const u = await z.writeFile(r.name, r.code);
2407
+ const u = await j.writeFile(r.name, r.code);
2408
2408
  u.ok || h(`同步文件失败:${r.name}(${((t = u.error) == null ? void 0 : t.message) ?? "未知错误"})`);
2409
2409
  }
2410
2410
  }
2411
- function rt() {
2412
- Y == null || Y.abort(), Y = null, Re.value = !1, tt.value = "", pt.value = !1;
2411
+ function at() {
2412
+ Y == null || Y.abort(), Y = null, _e.value = !1, nt.value = "", vt.value = !1;
2413
2413
  }
2414
2414
  function ye() {
2415
- rt(), ne.value = "";
2415
+ at(), ae.value = "";
2416
2416
  const e = D(f.value);
2417
2417
  f.value = e, i("update:sqlConfig", D(e));
2418
2418
  }
2419
- function _r() {
2420
- _e.value = !1, Fe.value = !0, fe();
2419
+ function Br() {
2420
+ Re.value = !1, Fe.value = !0, ve();
2421
2421
  }
2422
- function Ir() {
2423
- f.value.mode !== "http" && (f.value = D({ ...f.value, mode: "http" }), i("update:sqlConfig", D(f.value))), Fe.value = !1, _e.value = !0, Ve.value = "", ft.value = !1, fe();
2422
+ function Ur() {
2423
+ f.value.mode !== "http" && (f.value = D({ ...f.value, mode: "http" }), i("update:sqlConfig", D(f.value))), Fe.value = !1, Re.value = !0, Qe.value = "", mt.value = !1, ve();
2424
2424
  }
2425
- function Hr() {
2425
+ function Ar() {
2426
2426
  const e = f.value.connection.dialect, t = e === "sqlite" ? "mysql" : e;
2427
2427
  f.value = D({
2428
2428
  mode: "http",
@@ -2430,43 +2430,43 @@ const Da = Z(
2430
2430
  headers: f.value.headers,
2431
2431
  maxRows: f.value.maxRows,
2432
2432
  timeoutMs: f.value.timeoutMs,
2433
- connection: { dialect: t, port: rr(t) }
2434
- }), ee.value = "", ne.value = "", Pe.value = "", rt(), i("update:sqlConfig", D(f.value)), _e.value = !1, Fe.value = !0, fe();
2433
+ connection: { dialect: t, port: lr(t) }
2434
+ }), ne.value = "", ae.value = "", Pe.value = "", at(), i("update:sqlConfig", D(f.value)), Re.value = !1, Fe.value = !0, ve();
2435
2435
  }
2436
- function hn() {
2436
+ function xn() {
2437
2437
  Fe.value = !1;
2438
2438
  }
2439
- function Br() {
2439
+ function Dr() {
2440
2440
  const e = f.value;
2441
- e.mode === "sqlite" ? (e.connectionId = void 0, e.connection.dialect = "sqlite", e.connection.database || (e.connection.database = ":memory:"), ee.value = "") : (e.connection.dialect === "sqlite" && (e.connection.dialect = "mysql", e.connection.port = rr("mysql")), e.connection.database === ":memory:" && (e.connection.database = "")), ye(), e.mode === "http" && fe();
2441
+ e.mode === "sqlite" ? (e.connectionId = void 0, e.connection.dialect = "sqlite", e.connection.database || (e.connection.database = ":memory:"), ne.value = "") : (e.connection.dialect === "sqlite" && (e.connection.dialect = "mysql", e.connection.port = lr("mysql")), e.connection.database === ":memory:" && (e.connection.database = "")), ye(), e.mode === "http" && ve();
2442
2442
  }
2443
- function Ur() {
2444
- const e = f.value.connection, t = ut.find((u) => u.value === e.dialect), r = ut.map((u) => u.defaultPort);
2443
+ function zr() {
2444
+ const e = f.value.connection, t = dt.find((u) => u.value === e.dialect), r = dt.map((u) => u.defaultPort);
2445
2445
  t != null && t.defaultPort && (!e.port || r.includes(e.port)) && (e.port = t.defaultPort), ye();
2446
2446
  }
2447
- async function fe() {
2447
+ async function ve() {
2448
2448
  const e = D(f.value);
2449
2449
  if (!e.endpoint) {
2450
2450
  Ce.value = [], Pe.value = "";
2451
2451
  return;
2452
2452
  }
2453
- re == null || re.abort();
2453
+ se == null || se.abort();
2454
2454
  const t = new AbortController();
2455
- re = t, ze.value = !0, Pe.value = "";
2455
+ se = t, je.value = !0, Pe.value = "";
2456
2456
  try {
2457
- const r = await Ba(e, { signal: t.signal });
2458
- if (re !== t) return;
2457
+ const r = await Ds(e, { signal: t.signal });
2458
+ if (se !== t) return;
2459
2459
  Ce.value = r;
2460
2460
  const u = r.find((c) => c.id === f.value.connectionId);
2461
- u ? ee.value = u.name : f.value.connectionId && (f.value.connectionId = void 0, ee.value = "");
2461
+ u ? ne.value = u.name : f.value.connectionId && (f.value.connectionId = void 0, ne.value = "");
2462
2462
  } catch (r) {
2463
- if (re !== t) return;
2463
+ if (se !== t) return;
2464
2464
  Ce.value = [], Pe.value = r instanceof Error ? r.message : String(r);
2465
2465
  } finally {
2466
- re === t && (re = null, ze.value = !1);
2466
+ se === t && (se = null, je.value = !1);
2467
2467
  }
2468
2468
  }
2469
- function bn(e) {
2469
+ function En(e) {
2470
2470
  f.value = D({
2471
2471
  mode: "http",
2472
2472
  endpoint: f.value.endpoint,
@@ -2483,25 +2483,25 @@ const Da = Z(
2483
2483
  database: e.database ?? "",
2484
2484
  options: e.options
2485
2485
  }
2486
- }), ee.value = e.name, ne.value = "", rt(), i("update:sqlConfig", D(f.value));
2486
+ }), ne.value = e.name, ae.value = "", at(), i("update:sqlConfig", D(f.value));
2487
2487
  }
2488
- function Ar() {
2489
- Fe.value = !1, _e.value = !1;
2488
+ function jr() {
2489
+ Fe.value = !1, Re.value = !1;
2490
2490
  const e = Ce.value.find((t) => t.id === f.value.connectionId);
2491
2491
  if (!e) {
2492
- f.value.connectionId = void 0, f.value.connection.password = "", ee.value = "", ye();
2492
+ f.value.connectionId = void 0, f.value.connection.password = "", ne.value = "", ye();
2493
2493
  return;
2494
2494
  }
2495
- bn(e);
2495
+ En(e);
2496
2496
  }
2497
- function Dr(e) {
2498
- bn(e), _e.value = !1, Fe.value = !0;
2497
+ function Vr(e) {
2498
+ En(e), Re.value = !1, Fe.value = !0;
2499
2499
  }
2500
- async function zr() {
2501
- if (te.value) return;
2502
- const e = ee.value.trim();
2500
+ async function Qr() {
2501
+ if (re.value) return;
2502
+ const e = ne.value.trim();
2503
2503
  if (!e) {
2504
- je.value = !1, ne.value = "请先填写连接名称";
2504
+ Ve.value = !1, ae.value = "请先填写连接名称";
2505
2505
  return;
2506
2506
  }
2507
2507
  const t = D(f.value), r = {
@@ -2514,92 +2514,92 @@ const Da = Z(
2514
2514
  database: t.connection.database,
2515
2515
  options: t.connection.options
2516
2516
  };
2517
- te.value = !0, ne.value = "";
2517
+ re.value = !0, ae.value = "";
2518
2518
  try {
2519
- const u = await Ua(t, r, t.connectionId);
2519
+ const u = await zs(t, r, t.connectionId);
2520
2520
  f.value = D({
2521
2521
  ...t,
2522
2522
  connectionId: u.id,
2523
2523
  connection: { ...t.connection, password: "" }
2524
- }), ee.value = u.name, je.value = !0, ne.value = "连接已保存", i("update:sqlConfig", D(f.value)), await fe();
2524
+ }), ne.value = u.name, Ve.value = !0, ae.value = "连接已保存", i("update:sqlConfig", D(f.value)), await ve();
2525
2525
  } catch (u) {
2526
- je.value = !1, ne.value = u instanceof Error ? u.message : String(u);
2526
+ Ve.value = !1, ae.value = u instanceof Error ? u.message : String(u);
2527
2527
  } finally {
2528
- te.value = !1;
2528
+ re.value = !1;
2529
2529
  }
2530
2530
  }
2531
- async function jr() {
2531
+ async function Kr() {
2532
2532
  const e = f.value.connectionId;
2533
- if (!(!e || te.value) && !(typeof window < "u" && !window.confirm("确定删除该连接配置?"))) {
2534
- te.value = !0, ne.value = "";
2533
+ if (!(!e || re.value) && !(typeof window < "u" && !window.confirm("确定删除该连接配置?"))) {
2534
+ re.value = !0, ae.value = "";
2535
2535
  try {
2536
- await sr(f.value, e), f.value.connectionId = void 0, ee.value = "", je.value = !0, ne.value = "连接已删除", i("update:sqlConfig", D(f.value)), await fe();
2536
+ await ur(f.value, e), f.value.connectionId = void 0, ne.value = "", Ve.value = !0, ae.value = "连接已删除", i("update:sqlConfig", D(f.value)), await ve();
2537
2537
  } catch (t) {
2538
- je.value = !1, ne.value = t instanceof Error ? t.message : String(t);
2538
+ Ve.value = !1, ae.value = t instanceof Error ? t.message : String(t);
2539
2539
  } finally {
2540
- te.value = !1;
2540
+ re.value = !1;
2541
2541
  }
2542
2542
  }
2543
2543
  }
2544
- async function Vr(e) {
2545
- if (!te.value && !(typeof window < "u" && !window.confirm(`确定删除连接“${e.name}”?`))) {
2546
- te.value = !0, Ve.value = "";
2544
+ async function Jr(e) {
2545
+ if (!re.value && !(typeof window < "u" && !window.confirm(`确定删除连接“${e.name}”?`))) {
2546
+ re.value = !0, Qe.value = "";
2547
2547
  try {
2548
- await sr(f.value, e.id), f.value.connectionId === e.id && (f.value.connectionId = void 0, f.value.connection.password = "", ee.value = "", i("update:sqlConfig", D(f.value))), ft.value = !0, Ve.value = `已删除连接“${e.name}”`, await fe();
2548
+ await ur(f.value, e.id), f.value.connectionId === e.id && (f.value.connectionId = void 0, f.value.connection.password = "", ne.value = "", i("update:sqlConfig", D(f.value))), mt.value = !0, Qe.value = `已删除连接“${e.name}”`, await ve();
2549
2549
  } catch (t) {
2550
- ft.value = !1, Ve.value = t instanceof Error ? t.message : String(t);
2550
+ mt.value = !1, Qe.value = t instanceof Error ? t.message : String(t);
2551
2551
  } finally {
2552
- te.value = !1;
2552
+ re.value = !1;
2553
2553
  }
2554
2554
  }
2555
2555
  }
2556
- async function Qr() {
2557
- if (Re.value) return;
2558
- rt(), Re.value = !0;
2556
+ async function Zr() {
2557
+ if (_e.value) return;
2558
+ at(), _e.value = !0;
2559
2559
  const e = new AbortController();
2560
2560
  Y = e;
2561
2561
  try {
2562
- const t = await Ha(D(f.value), {
2562
+ const t = await As(D(f.value), {
2563
2563
  executor: o.sqlExecutor,
2564
2564
  signal: e.signal
2565
2565
  });
2566
2566
  if (Y !== e) return;
2567
- pt.value = t.ok, tt.value = t.message;
2567
+ vt.value = t.ok, nt.value = t.message;
2568
2568
  } catch (t) {
2569
2569
  if (Y !== e) return;
2570
- pt.value = !1, tt.value = t instanceof Error ? t.message : String(t);
2570
+ vt.value = !1, nt.value = t instanceof Error ? t.message : String(t);
2571
2571
  } finally {
2572
- Y === e && (Y = null, Re.value = !1);
2572
+ Y === e && (Y = null, _e.value = !1);
2573
2573
  }
2574
2574
  }
2575
- function Kr(e) {
2575
+ function Gr(e) {
2576
2576
  return e === null ? "NULL" : String(e);
2577
2577
  }
2578
- function Jr(e) {
2578
+ function Wr(e) {
2579
2579
  return e.columns.length ? `${e.rows.length} 行${e.truncated ? "(已截断)" : ""}` : `影响 ${e.affectedRows ?? 0} 行`;
2580
2580
  }
2581
- function kn(e) {
2581
+ function qn(e) {
2582
2582
  if (e)
2583
2583
  return { type: e.type, message: e.message, traceback: "" };
2584
2584
  }
2585
- async function wn() {
2586
- if (xe.value)
2585
+ async function Cn() {
2586
+ if (Ee.value)
2587
2587
  return k.value !== w.value.id && h("另一个 SQL 正在执行,请等待或停止后再试"), null;
2588
- const e = Ne();
2588
+ const e = Te();
2589
2589
  if (!e.trim())
2590
2590
  return h("SQL 内容为空,请输入要执行的语句"), null;
2591
- const t = D(f.value), r = ++nt, u = w.value.id;
2592
- xe.value = !0, k.value = u, ce = new AbortController(), Me(void 0), o.clearOutputOnRun && (pe(u).lines = [], pe(u).sqlResults = []), h(
2591
+ const t = D(f.value), r = ++rt, u = w.value.id;
2592
+ Ee.value = !0, k.value = u, de = new AbortController(), Me(void 0), o.clearOutputOnRun && (fe(u).lines = [], fe(u).sqlResults = []), h(
2593
2593
  `开始执行 SQL(${t.mode === "sqlite" ? "浏览器内 SQLite" : "HTTP 服务"})`,
2594
2594
  u
2595
2595
  ), i("runStart");
2596
2596
  try {
2597
- const c = await yr(t, e, {
2597
+ const c = await kr(t, e, {
2598
2598
  executor: o.sqlExecutor,
2599
- signal: ce.signal
2599
+ signal: de.signal
2600
2600
  });
2601
- if (r !== nt) return null;
2602
- if (pe(u).sqlResults = c.results ?? [], c.ok) {
2601
+ if (r !== rt) return null;
2602
+ if (fe(u).sqlResults = c.results ?? [], c.ok) {
2603
2603
  const y = c.results ?? [], S = y.reduce(($, X) => $ + X.rows.length, 0);
2604
2604
  h(
2605
2605
  `SQL 执行完成:${y.length} 个结果集,共 ${S} 行,耗时 ${(c.durationMs / 1e3).toFixed(2)}s`,
@@ -2612,29 +2612,29 @@ const Da = Z(
2612
2612
  return i("sqlResult", c), i("runFinish", {
2613
2613
  ok: c.ok,
2614
2614
  durationMs: c.durationMs,
2615
- error: c.ok ? void 0 : kn(c.error)
2615
+ error: c.ok ? void 0 : qn(c.error)
2616
2616
  }), c;
2617
2617
  } catch (c) {
2618
- if (r !== nt) return null;
2618
+ if (r !== rt) return null;
2619
2619
  const y = c instanceof Error ? c.message : String(c);
2620
2620
  h(`SQL 执行失败:${y}`, u);
2621
2621
  const S = { type: "SqlError", message: y };
2622
- return i("sqlError", S), i("runFinish", { ok: !1, durationMs: 0, error: kn(S) }), null;
2622
+ return i("sqlError", S), i("runFinish", { ok: !1, durationMs: 0, error: qn(S) }), null;
2623
2623
  } finally {
2624
- r === nt && (xe.value = !1, ce = null, k.value === u && (k.value = null));
2624
+ r === rt && (Ee.value = !1, de = null, k.value === u && (k.value = null));
2625
2625
  }
2626
2626
  }
2627
- async function Zr(e) {
2628
- return e !== void 0 && (ht(e), w.value.language !== "sql" && Bt("sql")), w.value.language !== "sql" ? (h("当前文件不是 SQL,无法执行"), null) : wn();
2627
+ async function Yr(e) {
2628
+ return e !== void 0 && (kt(e), w.value.language !== "sql" && jt("sql")), w.value.language !== "sql" ? (h("当前文件不是 SQL,无法执行"), null) : Cn();
2629
2629
  }
2630
- function Gr(e) {
2630
+ function Xr(e) {
2631
2631
  const t = e.target.value === "server" ? "server" : "browser";
2632
2632
  if (t === "browser")
2633
- for (const r of [...O.keys()])
2633
+ for (const r of [...M.keys()])
2634
2634
  st(r, !1);
2635
- Q.value = t, i("update:runtime", t), h(t === "server" ? "已切换到服务端 Python 环境" : "已切换到浏览器 Python 环境");
2635
+ ce.value = t, i("update:runtime", t), h(t === "server" ? "已切换到服务端 Python 环境" : "已切换到浏览器 Python 环境");
2636
2636
  }
2637
- function Sn(e, t, r, u) {
2637
+ function Pn(e, t, r, u) {
2638
2638
  if (!u) return;
2639
2639
  const c = u.replace(/\r\n/g, `
2640
2640
  `);
@@ -2646,13 +2646,13 @@ const Da = Z(
2646
2646
  for (const X of S)
2647
2647
  ge(r, X, e), i("runOutput", { stream: r, text: X });
2648
2648
  }
2649
- function xn(e, t) {
2649
+ function On(e, t) {
2650
2650
  t.stdoutBuffer && (ge("stdout", t.stdoutBuffer, e), i("runOutput", { stream: "stdout", text: t.stdoutBuffer }), t.stdoutBuffer = ""), t.stderrBuffer && (ge("stderr", t.stderrBuffer, e), i("runOutput", { stream: "stderr", text: t.stderrBuffer }), t.stderrBuffer = "");
2651
2651
  }
2652
- function bt(e, t, r) {
2653
- window.clearTimeout(t.pollTimer), xn(e, t);
2654
- const u = O.get(e);
2655
- if (u && u.token === t.token && O.delete(e), r.error) {
2652
+ function wt(e, t, r) {
2653
+ window.clearTimeout(t.pollTimer), On(e, t);
2654
+ const u = M.get(e);
2655
+ if (u && u.token === t.token && M.delete(e), r.error) {
2656
2656
  h(`执行出错:${r.error.type}`, e), e === w.value.id && Me(r.error.line);
2657
2657
  const y = {
2658
2658
  type: r.error.type,
@@ -2666,59 +2666,59 @@ const Da = Z(
2666
2666
  const c = r.durationMs ?? 0;
2667
2667
  h(`执行完成,会话时长 ${(c / 1e3).toFixed(2)}s`, e), i("runFinish", { ok: !0, durationMs: c });
2668
2668
  }
2669
- function At(e, t, r, u) {
2670
- const c = O.get(e);
2669
+ function Qt(e, t, r, u) {
2670
+ const c = M.get(e);
2671
2671
  if (!(!c || c.token !== u)) {
2672
- if (Sn(e, t, "stdout", r.stdout), Sn(e, t, "stderr", r.stderr), r.state === "exited") {
2673
- bt(e, t, r);
2672
+ if (Pn(e, t, "stdout", r.stdout), Pn(e, t, "stderr", r.stderr), r.state === "exited") {
2673
+ wt(e, t, r);
2674
2674
  return;
2675
2675
  }
2676
- if (xn(e, t), r.state === "waiting") {
2676
+ if (On(e, t), r.state === "waiting") {
2677
2677
  t.waiting = !0;
2678
2678
  return;
2679
2679
  }
2680
- t.waiting = !1, Wr(e, t, u);
2680
+ t.waiting = !1, ea(e, t, u);
2681
2681
  }
2682
2682
  }
2683
- function Wr(e, t, r) {
2683
+ function ea(e, t, r) {
2684
2684
  window.clearTimeout(t.pollTimer), t.pollTimer = window.setTimeout(() => {
2685
- Yr(e, r);
2685
+ ta(e, r);
2686
2686
  }, 250);
2687
2687
  }
2688
- async function Yr(e, t) {
2688
+ async function ta(e, t) {
2689
2689
  var u, c;
2690
- const r = O.get(e);
2690
+ const r = M.get(e);
2691
2691
  if (!(!r || r.token !== t || !r.sessionId))
2692
2692
  try {
2693
- const y = await La(o.pythonEndpoint, r.sessionId, {
2693
+ const y = await _s(o.pythonEndpoint, r.sessionId, {
2694
2694
  headers: o.pythonHeaders,
2695
2695
  signal: (u = r.abort) == null ? void 0 : u.signal
2696
2696
  });
2697
- At(e, r, y, t);
2697
+ Qt(e, r, y, t);
2698
2698
  } catch (y) {
2699
- if (((c = O.get(e)) == null ? void 0 : c.token) !== t) return;
2699
+ if (((c = M.get(e)) == null ? void 0 : c.token) !== t) return;
2700
2700
  const S = y instanceof Error ? y.message : String(y);
2701
- h(`执行失败:${S}`, e), bt(e, r, {
2701
+ h(`执行失败:${S}`, e), wt(e, r, {
2702
2702
  sessionId: r.sessionId,
2703
2703
  durationMs: 0,
2704
2704
  error: { type: "RuntimeError", message: S }
2705
2705
  });
2706
2706
  }
2707
2707
  }
2708
- async function Xr() {
2708
+ async function na() {
2709
2709
  var y;
2710
2710
  const e = w.value.id;
2711
- if ((y = O.get(e)) != null && y.busy) return;
2712
- if (!yt.value) {
2711
+ if ((y = M.get(e)) != null && y.busy) return;
2712
+ if (!bt.value) {
2713
2713
  h("未配置 Python 服务端点(pythonEndpoint)");
2714
2714
  return;
2715
2715
  }
2716
- const t = Ne();
2716
+ const t = Te();
2717
2717
  if (!t.trim()) {
2718
2718
  h("代码为空,请输入要执行的 Python 代码");
2719
2719
  return;
2720
2720
  }
2721
- const r = ++kr, u = {
2721
+ const r = ++xr, u = {
2722
2722
  sessionId: "",
2723
2723
  busy: !0,
2724
2724
  waiting: !1,
@@ -2729,48 +2729,48 @@ const Da = Z(
2729
2729
  stdoutBuffer: "",
2730
2730
  stderrBuffer: ""
2731
2731
  };
2732
- O.set(e, u);
2733
- const c = O.get(e);
2734
- Me(void 0), o.clearOutputOnRun && (pe(e).lines = []), h("开始执行(服务端 Python)", e), i("runStart");
2732
+ M.set(e, u);
2733
+ const c = M.get(e);
2734
+ Me(void 0), o.clearOutputOnRun && (fe(e).lines = []), h("开始执行(服务端 Python)", e), i("runStart");
2735
2735
  try {
2736
- const S = await Ta(o.pythonEndpoint, t, {
2736
+ const S = await Fs(o.pythonEndpoint, t, {
2737
2737
  stdin: o.stdin,
2738
2738
  headers: o.pythonHeaders,
2739
2739
  signal: c.abort.signal
2740
- }), $ = O.get(e);
2740
+ }), $ = M.get(e);
2741
2741
  if (!$ || $.token !== r) {
2742
- S.sessionId && Yn(o.pythonEndpoint, S.sessionId, {
2742
+ S.sessionId && rr(o.pythonEndpoint, S.sessionId, {
2743
2743
  headers: o.pythonHeaders
2744
2744
  });
2745
2745
  return;
2746
2746
  }
2747
- $.sessionId = S.sessionId, At(e, $, S, r);
2747
+ $.sessionId = S.sessionId, Qt(e, $, S, r);
2748
2748
  } catch (S) {
2749
- const $ = O.get(e);
2749
+ const $ = M.get(e);
2750
2750
  if (!$ || $.token !== r) return;
2751
2751
  const X = S instanceof Error ? S.message : String(S);
2752
- h(`执行失败:${X}`, e), bt(e, $, {
2752
+ h(`执行失败:${X}`, e), wt(e, $, {
2753
2753
  durationMs: 0,
2754
2754
  error: { type: "RuntimeError", message: X }
2755
2755
  });
2756
2756
  }
2757
2757
  }
2758
- async function En() {
2758
+ async function Mn() {
2759
2759
  var u, c;
2760
- const e = w.value.id, t = O.get(e);
2760
+ const e = w.value.id, t = M.get(e);
2761
2761
  if (!t || !t.waiting || !t.sessionId) return;
2762
2762
  const r = t.input;
2763
2763
  t.input = "", t.waiting = !1, ge("stdout", r, e), i("runOutput", { stream: "stdout", text: r });
2764
2764
  try {
2765
- const y = await $a(o.pythonEndpoint, t.sessionId, r, {
2765
+ const y = await Rs(o.pythonEndpoint, t.sessionId, r, {
2766
2766
  headers: o.pythonHeaders,
2767
2767
  signal: (u = t.abort) == null ? void 0 : u.signal
2768
2768
  });
2769
- At(e, t, y, t.token);
2769
+ Qt(e, t, y, t.token);
2770
2770
  } catch (y) {
2771
- if (((c = O.get(e)) == null ? void 0 : c.token) !== t.token) return;
2771
+ if (((c = M.get(e)) == null ? void 0 : c.token) !== t.token) return;
2772
2772
  const S = y instanceof Error ? y.message : String(y);
2773
- h(`执行失败:${S}`, e), bt(e, t, {
2773
+ h(`执行失败:${S}`, e), wt(e, t, {
2774
2774
  sessionId: t.sessionId,
2775
2775
  durationMs: 0,
2776
2776
  error: { type: "RuntimeError", message: S }
@@ -2779,19 +2779,19 @@ const Da = Z(
2779
2779
  }
2780
2780
  function st(e, t = !0) {
2781
2781
  var u;
2782
- const r = O.get(e);
2783
- r && (window.clearTimeout(r.pollTimer), O.delete(e), (u = r.abort) == null || u.abort(), r.sessionId && Yn(o.pythonEndpoint, r.sessionId, {
2782
+ const r = M.get(e);
2783
+ r && (window.clearTimeout(r.pollTimer), M.delete(e), (u = r.abort) == null || u.abort(), r.sessionId && rr(o.pythonEndpoint, r.sessionId, {
2784
2784
  headers: o.pythonHeaders
2785
2785
  }), t && h("执行已中断", e));
2786
2786
  }
2787
- async function qn() {
2787
+ async function Tn() {
2788
2788
  var c, y, S;
2789
2789
  if (w.value.language === "sql") {
2790
- await wn();
2790
+ await Cn();
2791
2791
  return;
2792
2792
  }
2793
- if (Je.value) {
2794
- await Xr();
2793
+ if (Ze.value) {
2794
+ await na();
2795
2795
  return;
2796
2796
  }
2797
2797
  if (I.value === "running") {
@@ -2803,41 +2803,41 @@ const Da = Z(
2803
2803
  if (I.value === "loading") return;
2804
2804
  const e = w.value.language;
2805
2805
  if (e !== "python") {
2806
- h(`当前文件为 ${Ct(e).label},仅支持执行 Python / SQL 代码`);
2806
+ h(`当前文件为 ${Mt(e).label},仅支持执行 Python / SQL 代码`);
2807
2807
  return;
2808
2808
  }
2809
- Ge += 1;
2810
- const t = Ge, r = w.value.id;
2811
- k.value = r, Me(void 0), o.clearOutputOnRun && (pe(r).lines = []), h("开始执行", r), i("runStart");
2812
- const u = Ne();
2809
+ We += 1;
2810
+ const t = We, r = w.value.id;
2811
+ k.value = r, Me(void 0), o.clearOutputOnRun && (fe(r).lines = []), h("开始执行", r), i("runStart");
2812
+ const u = Te();
2813
2813
  try {
2814
- await Rr();
2815
- const $ = await z.run(u, {
2814
+ await Hr();
2815
+ const $ = await j.run(u, {
2816
2816
  stdin: o.stdin,
2817
- onOutput: (X, ot) => {
2818
- ge(X, ot, r), i("runOutput", { stream: X, text: ot });
2817
+ onOutput: (X, it) => {
2818
+ ge(X, it, r), i("runOutput", { stream: X, text: it });
2819
2819
  }
2820
2820
  });
2821
- if (t !== Ge) return;
2821
+ if (t !== We) return;
2822
2822
  $.interrupted ? h("执行已中断", r) : $.ok ? h(`执行完成,耗时 ${($.durationMs / 1e3).toFixed(2)}s`, r) : (h(`执行出错:${((c = $.error) == null ? void 0 : c.type) ?? "未知错误"}`, r), (y = $.error) != null && y.traceback && (ge("stderr", $.error.traceback, r), i("runOutput", { stream: "stderr", text: $.error.traceback })), w.value.id === r && Me((S = $.error) == null ? void 0 : S.line), $.error && i("runError", $.error)), i("runFinish", $);
2823
2823
  } catch ($) {
2824
- if (t !== Ge) return;
2824
+ if (t !== We) return;
2825
2825
  const X = $ instanceof Error ? $.message : String($);
2826
2826
  h(`执行失败:${X}`, r);
2827
- const ot = { type: "RuntimeError", message: X, traceback: "" };
2828
- i("runError", ot), i("runFinish", { ok: !1, durationMs: 0, error: ot });
2827
+ const it = { type: "RuntimeError", message: X, traceback: "" };
2828
+ i("runError", it), i("runFinish", { ok: !1, durationMs: 0, error: it });
2829
2829
  } finally {
2830
- t === Ge && k.value === r && (k.value = null);
2830
+ t === We && k.value === r && (k.value = null);
2831
2831
  }
2832
2832
  }
2833
- async function es() {
2833
+ async function ra() {
2834
2834
  var t;
2835
- if (cn) return;
2835
+ if (mn) return;
2836
2836
  const e = o.preloadPackages;
2837
2837
  if (e.length) {
2838
- cn = !0, h(`正在安装预置包:${e.join(", ")}`);
2838
+ mn = !0, h(`正在安装预置包:${e.join(", ")}`);
2839
2839
  try {
2840
- const r = await z.loadPackages(e, {
2840
+ const r = await j.loadPackages(e, {
2841
2841
  onOutput: (u, c) => ge(u, c)
2842
2842
  });
2843
2843
  h(
@@ -2848,28 +2848,29 @@ const Da = Z(
2848
2848
  }
2849
2849
  }
2850
2850
  }
2851
- Ns(() => {
2851
+ Fa(() => {
2852
2852
  const e = b.value;
2853
2853
  if (!e) return;
2854
- Nr(), Tt = !0;
2854
+ $r(), _t = !0;
2855
2855
  const t = [
2856
- dn.of([
2857
- Yt.readOnly.of(o.readOnly),
2856
+ gn.of([
2857
+ nn.readOnly.of(o.readOnly),
2858
2858
  $e.editable.of(!o.readOnly)
2859
2859
  ]),
2860
- Rt.of(Ht(w.value.language))
2860
+ Ut.of(zt(w.value.language)),
2861
+ Ht.of(Tt(ut(z.value)))
2861
2862
  ];
2862
2863
  try {
2863
- M = ya(e, {
2864
+ P = ks(e, {
2864
2865
  value: w.value.code,
2865
- dark: ir(o.theme),
2866
+ dark: ut(z.value),
2866
2867
  placeholderText: o.placeholder,
2867
- language: Ft.of(Gt(w.value.language)),
2868
+ language: Bt.of(en(w.value.language)),
2868
2869
  extensions: t,
2869
2870
  onDocChange: (r) => {
2870
2871
  w.value.code = r, r !== o.modelValue && i("update:modelValue", r);
2871
2872
  },
2872
- onRunShortcut: qn
2873
+ onRunShortcut: Tn
2873
2874
  });
2874
2875
  } catch (r) {
2875
2876
  const u = r instanceof Error ? r.message : String(r);
@@ -2878,202 +2879,209 @@ const Da = Z(
2878
2879
  c.className = "vpe-init-error", c.textContent = `编辑器初始化失败:${u}`, e.appendChild(c);
2879
2880
  return;
2880
2881
  }
2881
- o.autofocus && M.focus(), mt = z.on("status", (r, u) => {
2882
- I.value = r, r === "ready" && (u && h(`Pyodide ${u} 就绪`), i("ready"), M && !o.disableLint && w.value.language === "python" && Ds(M)), i("statusChange", r);
2883
- }), gt = z.on("initError", (r) => {
2882
+ o.autofocus && P.focus(), yt = j.on("status", (r, u) => {
2883
+ I.value = r, r === "ready" && (u && h(`Pyodide ${u} 就绪`), i("ready"), P && !o.disableLint && w.value.language === "python" && Qa(P)), i("statusChange", r);
2884
+ }), ht = j.on("initError", (r) => {
2884
2885
  h(`Pyodide 加载失败:${r}`), i("loadError", r);
2885
- }), I.value = z.status, de.value && fe(), typeof ResizeObserver < "u" && p.value && (Ke = new ResizeObserver(() => {
2886
- x.value !== null && Dt(x.value);
2887
- }), Ke.observe(p.value)), o.preloadPackages.length ? z.waitReady().then(() => es()).catch((r) => h(r.message)) : o.preload && z.waitReady().catch((r) => h(r.message));
2888
- }), Ts(() => {
2889
- mt == null || mt(), gt == null || gt(), at(), Ke == null || Ke.disconnect(), Ke = null, ce == null || ce.abort(), ce = null, Y == null || Y.abort(), Y = null, re == null || re.abort(), re = null, se == null || se.abort(), se = null;
2890
- for (const e of [...O.keys()])
2886
+ }), I.value = j.status, pe.value && ve(), typeof ResizeObserver < "u" && p.value && (Je = new ResizeObserver(() => {
2887
+ x.value !== null && Kt(x.value);
2888
+ }), Je.observe(p.value)), o.preloadPackages.length ? j.waitReady().then(() => ra()).catch((r) => h(r.message)) : o.preload && j.waitReady().catch((r) => h(r.message));
2889
+ }), _a(() => {
2890
+ yt == null || yt(), ht == null || ht(), ot(), Je == null || Je.disconnect(), Je = null, de == null || de.abort(), de = null, Y == null || Y.abort(), Y = null, se == null || se.abort(), se = null, oe == null || oe.abort(), oe = null;
2891
+ for (const e of [...M.keys()])
2891
2892
  st(e, !1);
2892
- window.clearTimeout($t), window.clearTimeout(vt), mn(), M == null || M.destroy(), M = null;
2893
- }), oe(
2893
+ window.clearTimeout(It), window.clearTimeout(gt), kn(), P == null || P.destroy(), P = null;
2894
+ }), ee(
2894
2895
  () => o.modelValue,
2895
- () => $r()
2896
- ), oe(
2896
+ () => Rr()
2897
+ ), ee(
2897
2898
  () => o.outputHeight,
2898
2899
  () => {
2899
2900
  x.value = null;
2900
2901
  }
2901
- ), oe(
2902
+ ), ee(
2902
2903
  () => o.fileName,
2903
2904
  (e) => {
2904
2905
  e && e !== w.value.name && (Ie.value = e);
2905
2906
  }
2906
- ), oe(
2907
+ ), ee(
2907
2908
  () => o.language,
2908
2909
  (e) => {
2909
- e !== w.value.language && Bt(e);
2910
+ e !== w.value.language && jt(e);
2911
+ }
2912
+ ), ee(
2913
+ () => o.theme,
2914
+ (e) => {
2915
+ e !== z.value && (z.value = e, P == null || P.dispatch({
2916
+ effects: Ht.reconfigure(Tt(ut(e)))
2917
+ }));
2910
2918
  }
2911
- ), oe(
2919
+ ), ee(
2912
2920
  () => o.runtime,
2913
2921
  (e) => {
2914
- e !== Q.value && (Q.value = e);
2922
+ e !== ce.value && (ce.value = e);
2915
2923
  }
2916
- ), oe(
2924
+ ), ee(
2917
2925
  () => o.pythonEndpoint,
2918
2926
  () => {
2919
- if (!yt.value) {
2920
- for (const e of [...O.keys()])
2927
+ if (!bt.value) {
2928
+ for (const e of [...M.keys()])
2921
2929
  st(e, !1);
2922
- Q.value !== "browser" && (Q.value = "browser", i("update:runtime", "browser"));
2930
+ ce.value !== "browser" && (ce.value = "browser", i("update:runtime", "browser"));
2923
2931
  }
2924
2932
  }
2925
- ), oe(
2933
+ ), ee(
2926
2934
  () => o.filesEndpoint,
2927
2935
  () => {
2928
2936
  if (!Oe.value) {
2929
- Se.value = !1, et.value = [], De.value = "";
2937
+ xe.value = !1, tt.value = [], ze.value = "";
2930
2938
  return;
2931
2939
  }
2932
- Se.value && We();
2940
+ xe.value && Ye();
2933
2941
  }
2934
- ), oe(
2942
+ ), ee(
2935
2943
  () => o.readOnly,
2936
2944
  (e) => {
2937
- M == null || M.dispatch({
2938
- effects: dn.reconfigure([Yt.readOnly.of(e), $e.editable.of(!e)])
2945
+ P == null || P.dispatch({
2946
+ effects: gn.reconfigure([nn.readOnly.of(e), $e.editable.of(!e)])
2939
2947
  });
2940
2948
  }
2941
- ), oe(
2949
+ ), ee(
2942
2950
  () => o.sqlConfig,
2943
2951
  (e) => {
2944
2952
  if (!e) return;
2945
2953
  const t = D(e);
2946
- JSON.stringify(t) !== JSON.stringify(f.value) && (f.value = t), de.value && fe();
2954
+ JSON.stringify(t) !== JSON.stringify(f.value) && (f.value = t), pe.value && ve();
2947
2955
  },
2948
2956
  { deep: !0 }
2949
- ), oe(de, (e) => {
2950
- e && fe();
2951
- }), oe(
2957
+ ), ee(pe, (e) => {
2958
+ e && ve();
2959
+ }), ee(
2952
2960
  () => G.value.length,
2953
2961
  async () => {
2954
- await jn();
2955
- const e = R.value;
2962
+ await Zn();
2963
+ const e = _.value;
2956
2964
  e && (e.scrollTop = e.scrollHeight);
2957
2965
  }
2958
- ), oe([L, Ee], () => Tr(), { deep: !0 });
2959
- function Cn() {
2960
- qn();
2966
+ ), ee([L, qe], () => Fr(), { deep: !0 });
2967
+ function Nn() {
2968
+ Tn();
2961
2969
  }
2962
- function Pn() {
2970
+ function Ln() {
2963
2971
  var t;
2964
2972
  const e = w.value.id;
2965
- if (Re.value) {
2966
- rt(), !o.sqlExecutor && f.value.mode === "sqlite" && z.interrupt(), h("已取消连接测试");
2973
+ if (_e.value) {
2974
+ at(), !o.sqlExecutor && f.value.mode === "sqlite" && j.interrupt(), h("已取消连接测试");
2967
2975
  return;
2968
2976
  }
2969
- if ((t = O.get(e)) != null && t.busy) {
2977
+ if ((t = M.get(e)) != null && t.busy) {
2970
2978
  st(e);
2971
2979
  return;
2972
2980
  }
2973
- if (xe.value && k.value === e) {
2974
- On();
2981
+ if (Ee.value && k.value === e) {
2982
+ $n();
2975
2983
  return;
2976
2984
  }
2977
- I.value === "running" && k.value === e && Mn();
2985
+ I.value === "running" && k.value === e && Fn();
2978
2986
  }
2979
- function On(e = !0) {
2987
+ function $n(e = !0) {
2980
2988
  const t = k.value;
2981
- nt += 1, xe.value = !1, k.value = null, ce == null || ce.abort(), ce = null, !o.sqlExecutor && f.value.mode === "sqlite" && z.interrupt(), e && h("执行已中断", t ?? void 0);
2989
+ rt += 1, Ee.value = !1, k.value = null, de == null || de.abort(), de = null, !o.sqlExecutor && f.value.mode === "sqlite" && j.interrupt(), e && h("执行已中断", t ?? void 0);
2982
2990
  }
2983
- function Mn(e = !0) {
2991
+ function Fn(e = !0) {
2984
2992
  const t = k.value;
2985
- Ge += 1, k.value = null, z.interrupt(), e && h("执行已中断", t ?? void 0);
2993
+ We += 1, k.value = null, j.interrupt(), e && h("执行已中断", t ?? void 0);
2986
2994
  }
2987
- function Nn() {
2988
- pe().lines = [], pe().sqlResults = [];
2995
+ function _n() {
2996
+ fe().lines = [], fe().sqlResults = [];
2989
2997
  }
2990
- function Tn() {
2998
+ function Rn() {
2991
2999
  var e;
2992
3000
  return ((e = E.value) == null ? void 0 : e.getBoundingClientRect().height) ?? 180;
2993
3001
  }
2994
- function ts() {
3002
+ function aa() {
2995
3003
  var t;
2996
3004
  const e = ((t = p.value) == null ? void 0 : t.clientHeight) ?? 0;
2997
- return Math.max(dr, e ? e - 180 : 600);
3005
+ return Math.max(vr, e ? e - 180 : 600);
2998
3006
  }
2999
- function Dt(e) {
3000
- x.value = Math.round(Math.max(dr, Math.min(e, ts())));
3007
+ function Kt(e) {
3008
+ x.value = Math.round(Math.max(vr, Math.min(e, aa())));
3001
3009
  }
3002
- function ns(e) {
3003
- e.button === 0 && (e.preventDefault(), F.value = !0, pn = e.clientY, _t = Tn(), x.value = Math.round(_t), document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", window.addEventListener("pointermove", Ln), window.addEventListener("pointerup", at), window.addEventListener("pointercancel", at));
3010
+ function sa(e) {
3011
+ e.button === 0 && (e.preventDefault(), F.value = !0, yn = e.clientY, At = Rn(), x.value = Math.round(At), document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", window.addEventListener("pointermove", In), window.addEventListener("pointerup", ot), window.addEventListener("pointercancel", ot));
3004
3012
  }
3005
- function Ln(e) {
3006
- F.value && Dt(_t + (pn - e.clientY));
3013
+ function In(e) {
3014
+ F.value && Kt(At + (yn - e.clientY));
3007
3015
  }
3008
- function at() {
3009
- F.value && (F.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove", Ln), window.removeEventListener("pointerup", at), window.removeEventListener("pointercancel", at));
3016
+ function ot() {
3017
+ F.value && (F.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove", In), window.removeEventListener("pointerup", ot), window.removeEventListener("pointercancel", ot));
3010
3018
  }
3011
- function rs() {
3019
+ function oa() {
3012
3020
  x.value = null;
3013
3021
  }
3014
- function ss(e) {
3022
+ function ia(e) {
3015
3023
  if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
3016
3024
  e.preventDefault();
3017
- const t = x.value ?? Tn();
3018
- Dt(t + (e.key === "ArrowUp" ? 16 : -16));
3025
+ const t = x.value ?? Rn();
3026
+ Kt(t + (e.key === "ArrowUp" ? 16 : -16));
3019
3027
  }
3020
- function zt() {
3028
+ function Jt() {
3021
3029
  if (o.readOnly) return;
3022
- const e = w.value.language, t = Qe(gn(e), e, "");
3023
- L.value.push(t), He(t.id), i("newFile", Ze(t));
3030
+ const e = w.value.language, t = Ke(wn(e), e, "");
3031
+ L.value.push(t), He(t.id), i("newFile", Ge(t));
3024
3032
  }
3025
3033
  function He(e) {
3026
- if (e === Ee.value) {
3027
- wt();
3034
+ if (e === qe.value) {
3035
+ xt();
3028
3036
  return;
3029
3037
  }
3030
3038
  const t = L.value.find((r) => r.id === e);
3031
- t && (Ee.value = e, jt(t));
3039
+ t && (qe.value = e, Zt(t));
3032
3040
  }
3033
- function as(e) {
3034
- st(e, !1), xe.value && k.value === e && On(!1), I.value === "running" && k.value === e && Mn(!1);
3041
+ function la(e) {
3042
+ st(e, !1), Ee.value && k.value === e && $n(!1), I.value === "running" && k.value === e && Fn(!1);
3035
3043
  }
3036
- function $n(e) {
3044
+ function Hn(e) {
3037
3045
  if (o.readOnly) return;
3038
3046
  const t = L.value.findIndex((c) => c.id === e);
3039
3047
  if (t === -1) return;
3040
- as(e);
3048
+ la(e);
3041
3049
  const r = L.value.splice(t, 1)[0];
3042
3050
  if (!r) return;
3043
- if (q.delete(e), i("fileClose", Ze(r)), !L.value.length) {
3044
- const c = Qe(gn(r.language), r.language, "");
3045
- L.value.push(c), Ee.value = c.id, jt(c), i("newFile", Ze(c));
3051
+ if (q.delete(e), i("fileClose", Ge(r)), !L.value.length) {
3052
+ const c = Ke(wn(r.language), r.language, "");
3053
+ L.value.push(c), qe.value = c.id, Zt(c), i("newFile", Ge(c));
3046
3054
  return;
3047
3055
  }
3048
- if (e !== Ee.value) return;
3056
+ if (e !== qe.value) return;
3049
3057
  const u = L.value[Math.min(t, L.value.length - 1)];
3050
- u && (Ee.value = u.id, jt(u));
3058
+ u && (qe.value = u.id, Zt(u));
3051
3059
  }
3052
- function jt(e) {
3053
- Me(void 0), ht(e.code), M == null || M.dispatch({
3060
+ function Zt(e) {
3061
+ Me(void 0), kt(e.code), P == null || P.dispatch({
3054
3062
  effects: [
3055
- Ft.reconfigure(Gt(e.language)),
3056
- Rt.reconfigure(Ht(e.language))
3063
+ Bt.reconfigure(en(e.language)),
3064
+ Ut.reconfigure(zt(e.language))
3057
3065
  ]
3058
- }), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch", Ze(e)), wt();
3066
+ }), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch", Ge(e)), xt();
3059
3067
  }
3060
- function Fn() {
3061
- o.readOnly || (Me(void 0), ht(""), wt());
3068
+ function Bn() {
3069
+ o.readOnly || (Me(void 0), kt(""), xt());
3062
3070
  }
3063
- async function Rn() {
3071
+ async function Un() {
3064
3072
  var r;
3065
- const e = Ne();
3073
+ const e = Te();
3066
3074
  let t = !1;
3067
3075
  try {
3068
3076
  (r = navigator.clipboard) != null && r.writeText && (await navigator.clipboard.writeText(e), t = !0);
3069
3077
  } catch {
3070
3078
  t = !1;
3071
3079
  }
3072
- return t || (t = os(e)), t ? (me.value = !0, window.clearTimeout($t), $t = window.setTimeout(() => {
3073
- me.value = !1;
3080
+ return t || (t = ua(e)), t ? (Se.value = !0, window.clearTimeout(It), It = window.setTimeout(() => {
3081
+ Se.value = !1;
3074
3082
  }, 1600), i("copy", e), !0) : (h("复制失败,请手动选择代码复制"), !1);
3075
3083
  }
3076
- function os(e) {
3084
+ function ua(e) {
3077
3085
  const t = document.createElement("textarea");
3078
3086
  t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.top = "0", t.style.left = "-9999px", t.style.opacity = "0", document.body.appendChild(t), t.select(), t.setSelectionRange(0, t.value.length);
3079
3087
  let r = !1;
@@ -3084,36 +3092,36 @@ const Da = Z(
3084
3092
  }
3085
3093
  return t.remove(), r;
3086
3094
  }
3087
- function _n() {
3088
- const e = w.value, t = Ut(e.name, e.language);
3095
+ function An() {
3096
+ const e = w.value, t = Vt(e.name, e.language);
3089
3097
  Ie.value = t;
3090
- const r = new Blob([Ne()], {
3098
+ const r = new Blob([Te()], {
3091
3099
  type: e.language === "python" ? "text/x-python;charset=utf-8" : "text/plain;charset=utf-8"
3092
3100
  }), u = URL.createObjectURL(r), c = document.createElement("a");
3093
3101
  return c.href = u, c.download = t, c.style.display = "none", document.body.appendChild(c), c.click(), c.remove(), window.setTimeout(() => URL.revokeObjectURL(u), 1e3), i("download", t), t;
3094
3102
  }
3095
- function is() {
3096
- qe.value = !qe.value, qe.value && (Se.value = !1, In());
3103
+ function ca() {
3104
+ De.value = !De.value, De.value && (xe.value = !1, Dn());
3097
3105
  }
3098
- async function In() {
3106
+ async function Dn() {
3099
3107
  var e;
3100
- if (!Ye.value) {
3101
- Ye.value = !0;
3108
+ if (!Xe.value) {
3109
+ Xe.value = !0;
3102
3110
  try {
3103
- const t = await z.listFiles(".");
3111
+ const t = await j.listFiles(".");
3104
3112
  if (!t.ok) {
3105
- Xe.value = [], h(`读取虚拟文件失败:${((e = t.error) == null ? void 0 : e.message) ?? "未知错误"}`);
3113
+ et.value = [], h(`读取虚拟文件失败:${((e = t.error) == null ? void 0 : e.message) ?? "未知错误"}`);
3106
3114
  return;
3107
3115
  }
3108
- Xe.value = t.entries ?? [];
3116
+ et.value = t.entries ?? [];
3109
3117
  } catch (t) {
3110
- Xe.value = [], h(`读取虚拟文件失败:${t instanceof Error ? t.message : String(t)}`);
3118
+ et.value = [], h(`读取虚拟文件失败:${t instanceof Error ? t.message : String(t)}`);
3111
3119
  } finally {
3112
- Ye.value = !1;
3120
+ Xe.value = !1;
3113
3121
  }
3114
3122
  }
3115
3123
  }
3116
- function ls(e) {
3124
+ function da(e) {
3117
3125
  switch (e.slice(e.lastIndexOf(".") + 1).toLowerCase()) {
3118
3126
  case "csv":
3119
3127
  return "text/csv";
@@ -3130,112 +3138,112 @@ const Da = Z(
3130
3138
  return "text/plain";
3131
3139
  }
3132
3140
  }
3133
- function Vt(e) {
3141
+ function Gt(e) {
3134
3142
  return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
3135
3143
  }
3136
- async function Hn(e) {
3144
+ async function zn(e) {
3137
3145
  var t;
3138
3146
  try {
3139
- const r = await z.readFile(e);
3147
+ const r = await j.readFile(e);
3140
3148
  if (!r.ok || r.content === void 0)
3141
3149
  return h(`下载失败:${e}(${((t = r.error) == null ? void 0 : t.message) ?? "未知错误"})`), null;
3142
3150
  const u = e.slice(e.lastIndexOf("/") + 1) || "download.txt", c = new Blob([r.content], {
3143
- type: `${ls(u)};charset=utf-8`
3151
+ type: `${da(u)};charset=utf-8`
3144
3152
  }), y = URL.createObjectURL(c), S = document.createElement("a");
3145
3153
  return S.href = y, S.download = u, S.style.display = "none", document.body.appendChild(S), S.click(), S.remove(), window.setTimeout(() => URL.revokeObjectURL(y), 1e3), i("fsDownload", { path: r.path ?? e, name: u }), h(`已下载虚拟文件:${u}`), u;
3146
3154
  } catch (r) {
3147
3155
  return h(`下载失败:${r instanceof Error ? r.message : String(r)}`), null;
3148
3156
  }
3149
3157
  }
3150
- function us(e, t) {
3151
- return z.writeFile(e, t);
3158
+ function pa(e, t) {
3159
+ return j.writeFile(e, t);
3152
3160
  }
3153
- function cs(e) {
3154
- return z.readFile(e);
3161
+ function fa(e) {
3162
+ return j.readFile(e);
3155
3163
  }
3156
- function ds(e = ".") {
3157
- return z.listFiles(e);
3164
+ function va(e = ".") {
3165
+ return j.listFiles(e);
3158
3166
  }
3159
- function kt(e) {
3167
+ function St(e) {
3160
3168
  return e instanceof Error ? e.message : String(e);
3161
3169
  }
3162
- function ps(e) {
3170
+ function ma(e) {
3163
3171
  if (!e) return "";
3164
3172
  const t = new Date(e);
3165
3173
  return Number.isNaN(t.getTime()) ? e : `更新时间:${t.toLocaleString()}`;
3166
3174
  }
3167
- function fs() {
3168
- Se.value = !Se.value, Se.value && (qe.value = !1, We());
3175
+ function ga() {
3176
+ xe.value = !xe.value, xe.value && (De.value = !1, Ye());
3169
3177
  }
3170
- async function We() {
3178
+ async function Ye() {
3171
3179
  if (!Oe.value) return;
3172
- se == null || se.abort();
3180
+ oe == null || oe.abort();
3173
3181
  const e = new AbortController();
3174
- se = e, dt.value = !0, De.value = "";
3182
+ oe = e, ft.value = !0, ze.value = "";
3175
3183
  try {
3176
- const t = await qa(o.filesEndpoint, {
3184
+ const t = await Os(o.filesEndpoint, {
3177
3185
  headers: o.filesHeaders,
3178
3186
  signal: e.signal
3179
3187
  });
3180
- if (se !== e) return;
3181
- et.value = t;
3188
+ if (oe !== e) return;
3189
+ tt.value = t;
3182
3190
  } catch (t) {
3183
- if (se !== e) return;
3184
- et.value = [], De.value = kt(t);
3191
+ if (oe !== e) return;
3192
+ tt.value = [], ze.value = St(t);
3185
3193
  } finally {
3186
- se === e && (se = null, dt.value = !1);
3194
+ oe === e && (oe = null, ft.value = !1);
3187
3195
  }
3188
3196
  }
3189
- async function Bn() {
3197
+ async function jn() {
3190
3198
  if (!Oe.value)
3191
3199
  return h("未配置文件服务端点(filesEndpoint)"), null;
3192
3200
  if (W.value) return null;
3193
- const e = w.value, t = Ut(e.name, e.language);
3201
+ const e = w.value, t = Vt(e.name, e.language);
3194
3202
  t !== e.name && (Ie.value = t), W.value = !0;
3195
3203
  try {
3196
- const r = await Ca(
3204
+ const r = await Ms(
3197
3205
  o.filesEndpoint,
3198
- { name: t, content: Ne() },
3206
+ { name: t, content: Te() },
3199
3207
  { headers: o.filesHeaders }
3200
3208
  );
3201
- return h(`已保存到服务端:${r.name}(${Vt(r.size)})`), Se.value && await We(), r;
3209
+ return h(`已保存到服务端:${r.name}(${Gt(r.size)})`), xe.value && await Ye(), r;
3202
3210
  } catch (r) {
3203
- return h(`保存到服务端失败:${kt(r)}`), null;
3211
+ return h(`保存到服务端失败:${St(r)}`), null;
3204
3212
  } finally {
3205
3213
  W.value = !1;
3206
3214
  }
3207
3215
  }
3208
- async function vs(e) {
3216
+ async function ya(e) {
3209
3217
  if (!Oe.value || W.value) return !1;
3210
3218
  W.value = !0;
3211
3219
  try {
3212
- const t = await Pa(o.filesEndpoint, e.id, {
3220
+ const t = await Ts(o.filesEndpoint, e.id, {
3213
3221
  headers: o.filesHeaders
3214
- }), r = ar(t.name), u = Qe(yn(t.name), r, t.content);
3222
+ }), r = cr(t.name), u = Ke(Sn(t.name), r, t.content);
3215
3223
  return L.value.push(u), He(u.id), h(`已从服务端打开文件:${t.name}`), i("fileOpen", { name: u.name, code: t.content, language: r }), !0;
3216
3224
  } catch (t) {
3217
- return h(`打开服务端文件失败:${kt(t)}`), !1;
3225
+ return h(`打开服务端文件失败:${St(t)}`), !1;
3218
3226
  } finally {
3219
3227
  W.value = !1;
3220
3228
  }
3221
3229
  }
3222
- async function ms(e) {
3230
+ async function ha(e) {
3223
3231
  if (!(!Oe.value || W.value) && !(typeof window < "u" && !window.confirm(`确定删除服务端文件“${e.name}”?`))) {
3224
3232
  W.value = !0;
3225
3233
  try {
3226
- await Oa(o.filesEndpoint, e.id, { headers: o.filesHeaders }), h(`已删除服务端文件:${e.name}`), await We();
3234
+ await Ns(o.filesEndpoint, e.id, { headers: o.filesHeaders }), h(`已删除服务端文件:${e.name}`), await Ye();
3227
3235
  } catch (t) {
3228
- h(`删除服务端文件失败:${kt(t)}`);
3236
+ h(`删除服务端文件失败:${St(t)}`);
3229
3237
  } finally {
3230
3238
  W.value = !1;
3231
3239
  }
3232
3240
  }
3233
3241
  }
3234
- function Un() {
3242
+ function Vn() {
3235
3243
  var e;
3236
- (e = T.value) == null || e.click();
3244
+ (e = N.value) == null || e.click();
3237
3245
  }
3238
- async function gs(e) {
3246
+ async function ba(e) {
3239
3247
  var u;
3240
3248
  const t = e.target, r = (u = t.files) == null ? void 0 : u[0];
3241
3249
  if (t.value = "", !!r) {
@@ -3244,7 +3252,7 @@ const Da = Z(
3244
3252
  return;
3245
3253
  }
3246
3254
  try {
3247
- const c = await r.text(), y = ar(r.name), S = Qe(yn(r.name), y, c);
3255
+ const c = await r.text(), y = cr(r.name), S = Ke(Sn(r.name), y, c);
3248
3256
  L.value.push(S), He(S.id), h(`已打开文件:${S.name}`), i("fileOpen", { name: S.name, code: c, language: y });
3249
3257
  } catch (c) {
3250
3258
  const y = c instanceof Error ? c.message : String(c);
@@ -3252,23 +3260,29 @@ const Da = Z(
3252
3260
  }
3253
3261
  }
3254
3262
  }
3255
- function ys() {
3256
- Ie.value = Ut(Ie.value, w.value.language);
3263
+ function ka() {
3264
+ Ie.value = Vt(Ie.value, w.value.language);
3257
3265
  }
3258
- function hs(e) {
3266
+ function wa(e) {
3259
3267
  e.key === "Enter" && (e.preventDefault(), e.target.blur());
3260
3268
  }
3261
- function bs(e) {
3262
- Bt(e.target.value);
3269
+ function Sa(e) {
3270
+ jt(e.target.value);
3263
3271
  }
3264
- async function An(e) {
3272
+ function xa(e) {
3273
+ const t = e.target.value;
3274
+ t !== z.value && (z.value = t, P == null || P.dispatch({
3275
+ effects: Ht.reconfigure(Tt(ut(t)))
3276
+ }), i("update:theme", t));
3277
+ }
3278
+ async function Qn(e) {
3265
3279
  var t, r;
3266
- await jn(), (r = (t = P.value) == null ? void 0 : t.querySelector(`[data-file-id="${e}"]`)) == null || r.focus();
3280
+ await Zn(), (r = (t = O.value) == null ? void 0 : t.querySelector(`[data-file-id="${e}"]`)) == null || r.focus();
3267
3281
  }
3268
- function ks(e, t) {
3282
+ function Ea(e, t) {
3269
3283
  if (e.target !== e.currentTarget) return;
3270
3284
  if (e.key === "Enter" || e.key === " ") {
3271
- e.preventDefault(), He(t.id), An(t.id);
3285
+ e.preventDefault(), He(t.id), Qn(t.id);
3272
3286
  return;
3273
3287
  }
3274
3288
  if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
@@ -3276,17 +3290,17 @@ const Da = Z(
3276
3290
  const r = L.value.findIndex((y) => y.id === t.id);
3277
3291
  if (r < 0) return;
3278
3292
  const u = e.key === "ArrowLeft" ? -1 : 1, c = L.value[(r + u + L.value.length) % L.value.length];
3279
- c && (He(c.id), An(c.id));
3293
+ c && (He(c.id), Qn(c.id));
3280
3294
  }
3281
- function wt() {
3282
- M == null || M.focus();
3295
+ function xt() {
3296
+ P == null || P.focus();
3283
3297
  }
3284
- async function ws(e) {
3298
+ async function qa(e) {
3285
3299
  var r;
3286
3300
  h(`正在安装:${e.join(", ")}`);
3287
3301
  let t;
3288
3302
  try {
3289
- t = await z.loadPackages(e, {
3303
+ t = await j.loadPackages(e, {
3290
3304
  onOutput: (u, c) => ge(u, c)
3291
3305
  });
3292
3306
  } catch (u) {
@@ -3295,79 +3309,79 @@ const Da = Z(
3295
3309
  }
3296
3310
  return h(t.ok ? "安装完成" : `安装失败:${((r = t.error) == null ? void 0 : r.message) ?? "未知错误"}`), t;
3297
3311
  }
3298
- function Ss() {
3299
- return z.checkSyntax(Ne());
3312
+ function Ca() {
3313
+ return j.checkSyntax(Te());
3300
3314
  }
3301
- function xs() {
3315
+ function Pa() {
3302
3316
  return D(f.value);
3303
3317
  }
3304
- function Es() {
3305
- return M;
3318
+ function Oa() {
3319
+ return P;
3306
3320
  }
3307
- function qs() {
3308
- return L.value.map(Ze);
3321
+ function Ma() {
3322
+ return L.value.map(Ge);
3309
3323
  }
3310
- function Cs() {
3311
- return Ze(w.value);
3324
+ function Ta() {
3325
+ return Ge(w.value);
3312
3326
  }
3313
3327
  return n({
3314
- run: Cn,
3315
- stop: Pn,
3316
- clearOutput: Nn,
3317
- clearCode: Fn,
3318
- newFile: zt,
3328
+ run: Nn,
3329
+ stop: Ln,
3330
+ clearOutput: _n,
3331
+ clearCode: Bn,
3332
+ newFile: Jt,
3319
3333
  switchFile: He,
3320
- closeFile: $n,
3321
- copyCode: Rn,
3322
- download: _n,
3323
- openFile: Un,
3324
- focus: wt,
3325
- install: ws,
3326
- checkSyntax: Ss,
3327
- executeSql: Zr,
3328
- getSqlConfig: xs,
3329
- openSqlConfig: _r,
3330
- closeSqlConfig: hn,
3331
- getEditorView: Es,
3332
- getCode: Ne,
3333
- setCode: ht,
3334
- getFiles: qs,
3335
- getActiveFile: Cs,
3336
- writeFile: us,
3337
- readFile: cs,
3338
- listFiles: ds,
3339
- downloadFile: Hn,
3340
- saveToServer: Bn,
3341
- refreshServerFiles: We,
3342
- clearPersistedState: Lr
3334
+ closeFile: Hn,
3335
+ copyCode: Un,
3336
+ download: An,
3337
+ openFile: Vn,
3338
+ focus: xt,
3339
+ install: qa,
3340
+ checkSyntax: Ca,
3341
+ executeSql: Yr,
3342
+ getSqlConfig: Pa,
3343
+ openSqlConfig: Br,
3344
+ closeSqlConfig: xn,
3345
+ getEditorView: Oa,
3346
+ getCode: Te,
3347
+ setCode: kt,
3348
+ getFiles: Ma,
3349
+ getActiveFile: Ta,
3350
+ writeFile: pa,
3351
+ readFile: fa,
3352
+ listFiles: va,
3353
+ downloadFile: zn,
3354
+ saveToServer: jn,
3355
+ refreshServerFiles: Ye,
3356
+ clearPersistedState: _r
3343
3357
  }), (e, t) => (m(), g("div", {
3344
3358
  ref_key: "rootEl",
3345
3359
  ref: p,
3346
- class: ie(["vpe-root", Sr.value]),
3347
- style: Vn(wr.value)
3360
+ class: le(["vpe-root", qr.value]),
3361
+ style: Gn(Er.value)
3348
3362
  }, [
3349
- a.showToolbar ? (m(), g("div", Ya, [
3350
- l("div", Xa, [
3351
- It.value ? (m(), g("button", {
3363
+ s.showToolbar ? (m(), g("div", to, [
3364
+ l("div", no, [
3365
+ Dt.value ? (m(), g("button", {
3352
3366
  key: 1,
3353
3367
  class: "vpe-btn vpe-btn--stop",
3354
3368
  type: "button",
3355
3369
  title: "中断执行",
3356
- onClick: Pn
3370
+ onClick: Ln
3357
3371
  }, [
3358
- j(B(za)),
3372
+ V(B(Qs)),
3359
3373
  t[19] || (t[19] = l("span", null, "停止", -1))
3360
3374
  ])) : (m(), g("button", {
3361
3375
  key: 0,
3362
3376
  class: "vpe-btn vpe-btn--primary",
3363
3377
  type: "button",
3364
- title: qr.value,
3365
- disabled: Cr.value,
3366
- onClick: Cn
3378
+ title: Or.value,
3379
+ disabled: Mr.value,
3380
+ onClick: Nn
3367
3381
  }, [
3368
- j(B(Da)),
3382
+ V(B(Vs)),
3369
3383
  t[18] || (t[18] = l("span", null, "运行", -1))
3370
- ], 8, eo)),
3384
+ ], 8, ro)),
3371
3385
  t[28] || (t[28] = l("span", {
3372
3386
  class: "vpe-divider",
3373
3387
  "aria-hidden": "true"
@@ -3377,41 +3391,41 @@ const Da = Z(
3377
3391
  type: "button",
3378
3392
  title: "新建文件",
3379
3393
  "aria-label": "新建文件",
3380
- disabled: a.readOnly,
3381
- onClick: zt
3394
+ disabled: s.readOnly,
3395
+ onClick: Jt
3382
3396
  }, [
3383
- j(B(ja)),
3397
+ V(B(Ks)),
3384
3398
  t[20] || (t[20] = l("span", null, "新建", -1))
3385
- ], 8, to),
3399
+ ], 8, ao),
3386
3400
  l("button", {
3387
3401
  class: "vpe-btn",
3388
3402
  type: "button",
3389
3403
  title: "打开本地文件",
3390
3404
  "aria-label": "打开本地文件",
3391
- disabled: a.readOnly,
3392
- onClick: Un
3405
+ disabled: s.readOnly,
3406
+ onClick: Vn
3393
3407
  }, [
3394
- j(B(Va)),
3408
+ V(B(Js)),
3395
3409
  t[21] || (t[21] = l("span", null, "本地文件", -1))
3396
- ], 8, no),
3410
+ ], 8, so),
3397
3411
  l("button", {
3398
3412
  class: "vpe-btn",
3399
3413
  type: "button",
3400
3414
  title: "下载当前文件",
3401
3415
  "aria-label": "下载当前文件",
3402
- onClick: _n
3416
+ onClick: An
3403
3417
  }, [
3404
- j(B(cr)),
3418
+ V(B(fr)),
3405
3419
  t[22] || (t[22] = l("span", null, "下载", -1))
3406
3420
  ]),
3407
3421
  l("button", {
3408
- class: "vpe-btn",
3422
+ class: "vpe-btn vpe-toolbar-secondary",
3409
3423
  type: "button",
3410
3424
  title: "虚拟文件(下载 Python 生成的文件)",
3411
3425
  "aria-label": "虚拟文件",
3412
- onClick: is
3426
+ onClick: ca
3413
3427
  }, [
3414
- j(B(ur)),
3428
+ V(B(pr)),
3415
3429
  t[23] || (t[23] = l("span", null, "虚拟文件", -1))
3416
3430
  ]),
3417
3431
  Oe.value ? (m(), g("button", {
@@ -3421,128 +3435,140 @@ const Da = Z(
3421
3435
  title: W.value ? "正在处理服务端文件…" : "保存当前文件到服务端",
3422
3436
  "aria-label": "保存到服务端",
3423
3437
  disabled: W.value,
3424
- onClick: Bn
3438
+ onClick: jn
3425
3439
  }, [
3426
- j(B(Ga)),
3440
+ V(B(Xs)),
3427
3441
  t[24] || (t[24] = l("span", null, "保存", -1))
3428
- ], 8, ro)) : N("", !0),
3442
+ ], 8, oo)) : T("", !0),
3429
3443
  Oe.value ? (m(), g("button", {
3430
3444
  key: 3,
3431
- class: "vpe-btn",
3445
+ class: "vpe-btn vpe-toolbar-secondary",
3432
3446
  type: "button",
3433
3447
  title: "查询服务端已保存文件",
3434
3448
  "aria-label": "已保存文件",
3435
- onClick: fs
3449
+ onClick: ga
3436
3450
  }, [
3437
- j(B(Wa)),
3451
+ V(B(eo)),
3438
3452
  t[25] || (t[25] = l("span", null, "已保存文件", -1))
3439
- ])) : N("", !0),
3440
- a.showSqlConfig && de.value ? (m(), g("button", {
3453
+ ])) : T("", !0),
3454
+ s.showSqlConfig && pe.value ? (m(), g("button", {
3441
3455
  key: 4,
3442
3456
  class: "vpe-btn",
3443
3457
  type: "button",
3444
3458
  title: "新建连接",
3445
3459
  "aria-label": "新建连接",
3446
- onClick: Hr
3460
+ onClick: Ar
3447
3461
  }, [
3448
- j(B(Za)),
3462
+ V(B(Ys)),
3449
3463
  t[26] || (t[26] = l("span", null, "新建连接", -1))
3450
- ])) : N("", !0),
3464
+ ])) : T("", !0),
3451
3465
  l("button", {
3452
- class: ie(["vpe-btn", { "vpe-btn--copied": me.value }]),
3466
+ class: le(["vpe-btn", { "vpe-btn--copied": Se.value }]),
3453
3467
  type: "button",
3454
- title: me.value ? "已复制" : "复制代码",
3455
- "aria-label": me.value ? "已复制" : "复制代码",
3456
- onClick: Rn
3468
+ title: Se.value ? "已复制" : "复制代码",
3469
+ "aria-label": Se.value ? "已复制" : "复制代码",
3470
+ onClick: Un
3457
3471
  }, [
3458
- me.value ? (m(), Qn(B(Ka), { key: 0 })) : (m(), Qn(B(Qa), { key: 1 })),
3459
- me.value ? (m(), g("span", ao, "已复制")) : (m(), g("span", oo, "复制"))
3460
- ], 10, so),
3472
+ Se.value ? (m(), Wn(B(Gs), { key: 0 })) : (m(), Wn(B(Zs), { key: 1 })),
3473
+ Se.value ? (m(), g("span", lo, "已复制")) : (m(), g("span", uo, "复制"))
3474
+ ], 10, io),
3461
3475
  l("button", {
3462
3476
  class: "vpe-btn",
3463
3477
  type: "button",
3464
3478
  title: "清空当前文件",
3465
3479
  "aria-label": "清空当前文件",
3466
- disabled: a.readOnly,
3467
- onClick: Fn
3480
+ disabled: s.readOnly,
3481
+ onClick: Bn
3468
3482
  }, [
3469
- j(B(lr)),
3483
+ V(B(dr)),
3470
3484
  t[27] || (t[27] = l("span", null, "清空", -1))
3471
- ], 8, io),
3485
+ ], 8, co),
3472
3486
  t[29] || (t[29] = l("span", {
3473
3487
  class: "vpe-divider",
3474
3488
  "aria-hidden": "true"
3475
3489
  }, null, -1)),
3476
- l("label", lo, [
3477
- j(B(ur)),
3490
+ l("label", po, [
3491
+ V(B(pr)),
3478
3492
  J(l("input", {
3479
3493
  "onUpdate:modelValue": t[0] || (t[0] = (r) => Ie.value = r),
3480
3494
  class: "vpe-file-input",
3481
3495
  type: "text",
3482
3496
  spellcheck: "false",
3483
3497
  "aria-label": "文件名",
3484
- onBlur: ys,
3485
- onKeydown: hs
3498
+ onBlur: ka,
3499
+ onKeydown: wa
3486
3500
  }, null, 544), [
3487
3501
  [he, Ie.value]
3488
3502
  ])
3489
- ])
3503
+ ]),
3504
+ l("select", {
3505
+ class: "vpe-toolbar-select",
3506
+ value: z.value,
3507
+ title: "编辑器主题",
3508
+ "aria-label": "编辑器主题",
3509
+ onChange: xa
3510
+ }, [
3511
+ (m(!0), g(A, null, te(B(ln), (r) => (m(), g("option", {
3512
+ key: r.value,
3513
+ value: r.value
3514
+ }, R(r.label), 9, vo))), 128))
3515
+ ], 40, fo)
3490
3516
  ]),
3491
- l("div", uo, [
3492
- a.showSqlConfig && de.value && (f.value.mode === "http" || f.value.endpoint) ? (m(), g(A, { key: 0 }, [
3517
+ l("div", mo, [
3518
+ s.showSqlConfig && pe.value && (f.value.mode === "http" || f.value.endpoint) ? (m(), g(A, { key: 0 }, [
3493
3519
  J(l("select", {
3494
3520
  "onUpdate:modelValue": t[1] || (t[1] = (r) => f.value.connectionId = r),
3495
3521
  class: "vpe-select vpe-sql-connection",
3496
3522
  title: "切换已保存连接",
3497
3523
  "aria-label": "切换已保存连接",
3498
- disabled: ze.value,
3499
- onChange: Ar
3524
+ disabled: je.value,
3525
+ onChange: jr
3500
3526
  }, [
3501
- l("option", po, _(ze.value ? "加载中…" : Ce.value.length ? "选择连接" : "暂无已保存连接"), 1),
3502
- (m(!0), g(A, null, le(Ce.value, (r) => (m(), g("option", {
3527
+ l("option", yo, R(je.value ? "加载中…" : Ce.value.length ? "选择连接" : "暂无已保存连接"), 1),
3528
+ (m(!0), g(A, null, te(Ce.value, (r) => (m(), g("option", {
3503
3529
  key: r.id,
3504
3530
  value: r.id
3505
- }, _(r.name), 9, fo))), 128))
3506
- ], 40, co), [
3507
- [St, f.value.connectionId]
3531
+ }, R(r.name), 9, ho))), 128))
3532
+ ], 40, go), [
3533
+ [Et, f.value.connectionId]
3508
3534
  ]),
3509
3535
  l("button", {
3510
3536
  class: "vpe-btn vpe-btn--sm vpe-sql-manage",
3511
3537
  type: "button",
3512
3538
  title: "管理连接配置",
3513
3539
  "aria-label": "管理连接配置",
3514
- onClick: Ir
3540
+ onClick: Ur
3515
3541
  }, " 管理 ")
3516
- ], 64)) : N("", !0),
3517
- l("div", vo, [
3542
+ ], 64)) : T("", !0),
3543
+ l("div", bo, [
3518
3544
  l("span", {
3519
- class: ie(["vpe-status", `vpe-status--${Er.value}`]),
3520
- title: vn.value
3545
+ class: le(["vpe-status", `vpe-status--${Pr.value}`]),
3546
+ title: bn.value
3521
3547
  }, [
3522
3548
  t[30] || (t[30] = l("span", {
3523
3549
  class: "vpe-status-dot",
3524
3550
  "aria-hidden": "true"
3525
3551
  }, null, -1)),
3526
- l("span", go, _(vn.value), 1)
3527
- ], 10, mo),
3528
- yt.value && fn.value ? (m(), g(A, { key: 0 }, [
3552
+ l("span", wo, R(bn.value), 1)
3553
+ ], 10, ko),
3554
+ bt.value && hn.value ? (m(), g(A, { key: 0 }, [
3529
3555
  t[32] || (t[32] = l("span", {
3530
3556
  class: "vpe-chips-divider",
3531
3557
  "aria-hidden": "true"
3532
3558
  }, null, -1)),
3533
3559
  J(l("select", {
3534
- "onUpdate:modelValue": t[2] || (t[2] = (r) => Q.value = r),
3560
+ "onUpdate:modelValue": t[2] || (t[2] = (r) => ce.value = r),
3535
3561
  class: "vpe-toolbar-select",
3536
3562
  title: "Python 运行环境",
3537
3563
  "aria-label": "Python 运行环境",
3538
- onChange: Gr
3564
+ onChange: Xr
3539
3565
  }, [...t[31] || (t[31] = [
3540
3566
  l("option", { value: "browser" }, "浏览器", -1),
3541
3567
  l("option", { value: "server" }, "服务端", -1)
3542
3568
  ])], 544), [
3543
- [St, Q.value]
3569
+ [Et, ce.value]
3544
3570
  ])
3545
- ], 64)) : N("", !0),
3571
+ ], 64)) : T("", !0),
3546
3572
  t[33] || (t[33] = l("span", {
3547
3573
  class: "vpe-chips-divider",
3548
3574
  "aria-hidden": "true"
@@ -3552,149 +3578,149 @@ const Da = Z(
3552
3578
  value: w.value.language,
3553
3579
  title: "编辑器语言",
3554
3580
  "aria-label": "编辑器语言",
3555
- disabled: a.readOnly,
3556
- onChange: bs
3581
+ disabled: s.readOnly,
3582
+ onChange: Sa
3557
3583
  }, [
3558
- (m(!0), g(A, null, le(B(Mt), (r) => (m(), g("option", {
3584
+ (m(!0), g(A, null, te(B($t), (r) => (m(), g("option", {
3559
3585
  key: r.value,
3560
3586
  value: r.value
3561
- }, _(r.label), 9, ho))), 128))
3562
- ], 40, yo)
3587
+ }, R(r.label), 9, xo))), 128))
3588
+ ], 40, So)
3563
3589
  ])
3564
3590
  ])
3565
- ])) : N("", !0),
3566
- a.showTabs ? (m(), g("div", {
3591
+ ])) : T("", !0),
3592
+ s.showTabs ? (m(), g("div", {
3567
3593
  key: 1,
3568
3594
  ref_key: "tabsEl",
3569
- ref: P,
3595
+ ref: O,
3570
3596
  class: "vpe-tabs",
3571
3597
  role: "tablist",
3572
3598
  "aria-label": "文件"
3573
3599
  }, [
3574
- (m(!0), g(A, null, le(L.value, (r) => (m(), g("div", {
3600
+ (m(!0), g(A, null, te(L.value, (r) => (m(), g("div", {
3575
3601
  key: r.id,
3576
- class: ie(["vpe-tab", { "vpe-tab--active": r.id === w.value.id }]),
3602
+ class: le(["vpe-tab", { "vpe-tab--active": r.id === w.value.id }]),
3577
3603
  role: "tab",
3578
3604
  tabindex: "0",
3579
3605
  "aria-selected": r.id === w.value.id,
3580
3606
  "data-file-id": r.id,
3581
3607
  title: r.name,
3582
3608
  onClick: (u) => He(r.id),
3583
- onKeydown: (u) => ks(u, r)
3609
+ onKeydown: (u) => Ea(u, r)
3584
3610
  }, [
3585
3611
  l("span", {
3586
- class: ie(["vpe-tab-dot", `vpe-tab-dot--${r.language}`]),
3612
+ class: le(["vpe-tab-dot", `vpe-tab-dot--${r.language}`]),
3587
3613
  "aria-hidden": "true"
3588
3614
  }, null, 2),
3589
- l("span", ko, _(r.name), 1),
3615
+ l("span", qo, R(r.name), 1),
3590
3616
  l("button", {
3591
3617
  class: "vpe-tab-close",
3592
3618
  type: "button",
3593
3619
  title: `关闭 ${r.name}`,
3594
3620
  "aria-label": `关闭 ${r.name}`,
3595
- disabled: a.readOnly,
3596
- onClick: Kn((u) => $n(r.id), ["stop"])
3621
+ disabled: s.readOnly,
3622
+ onClick: Yn((u) => Hn(r.id), ["stop"])
3597
3623
  }, [
3598
- j(B(lt))
3599
- ], 8, wo)
3600
- ], 42, bo))), 128)),
3624
+ V(B(ct))
3625
+ ], 8, Co)
3626
+ ], 42, Eo))), 128)),
3601
3627
  l("button", {
3602
3628
  class: "vpe-tabs-add",
3603
3629
  type: "button",
3604
3630
  title: "新建文件",
3605
3631
  "aria-label": "新建文件",
3606
- disabled: a.readOnly,
3607
- onClick: zt
3632
+ disabled: s.readOnly,
3633
+ onClick: Jt
3608
3634
  }, [
3609
- j(B(Ja))
3610
- ], 8, So)
3611
- ], 512)) : N("", !0),
3635
+ V(B(Ws))
3636
+ ], 8, Po)
3637
+ ], 512)) : T("", !0),
3612
3638
  l("input", {
3613
3639
  ref_key: "fileInputEl",
3614
- ref: T,
3640
+ ref: N,
3615
3641
  class: "vpe-file-hidden",
3616
3642
  type: "file",
3617
3643
  accept: ".py,.pyw,.sql,.js,.mjs,.cjs,.jsx,.ts,.json,.txt,text/x-python,text/plain,application/json",
3618
- onChange: gs
3644
+ onChange: ba
3619
3645
  }, null, 544),
3620
3646
  l("div", {
3621
3647
  ref_key: "editorEl",
3622
3648
  ref: b,
3623
3649
  class: "vpe-editor"
3624
3650
  }, null, 512),
3625
- a.showOutput ? (m(), g("div", {
3651
+ s.showOutput ? (m(), g("div", {
3626
3652
  key: 2,
3627
- class: ie(["vpe-output-resizer", { "vpe-output-resizer--active": F.value }]),
3653
+ class: le(["vpe-output-resizer", { "vpe-output-resizer--active": F.value }]),
3628
3654
  role: "separator",
3629
3655
  "aria-orientation": "horizontal",
3630
3656
  "aria-label": "调整输出面板高度",
3631
3657
  title: "拖动调整输出高度,双击复位",
3632
3658
  tabindex: "0",
3633
- onPointerdown: ns,
3634
- onDblclick: rs,
3635
- onKeydown: ss
3636
- }, null, 34)) : N("", !0),
3637
- a.showOutput ? (m(), g("div", {
3659
+ onPointerdown: sa,
3660
+ onDblclick: oa,
3661
+ onKeydown: ia
3662
+ }, null, 34)) : T("", !0),
3663
+ s.showOutput ? (m(), g("div", {
3638
3664
  key: 3,
3639
3665
  ref_key: "outputPanelEl",
3640
3666
  ref: E,
3641
3667
  class: "vpe-output",
3642
- style: Vn({ height: xr.value })
3668
+ style: Gn({ height: Cr.value })
3643
3669
  }, [
3644
- l("div", xo, [
3670
+ l("div", Oo, [
3645
3671
  t[34] || (t[34] = l("span", null, "输出", -1)),
3646
3672
  l("button", {
3647
3673
  class: "vpe-btn vpe-btn--sm",
3648
3674
  type: "button",
3649
3675
  title: "清空输出",
3650
- onClick: Nn
3676
+ onClick: _n
3651
3677
  }, [
3652
- j(B(lr))
3678
+ V(B(dr))
3653
3679
  ])
3654
3680
  ]),
3655
- l("div", Eo, [
3656
- ve.value.length ? (m(), g("div", qo, [
3657
- (m(!0), g(A, null, le(ve.value, (r, u) => (m(), g("section", {
3681
+ l("div", Mo, [
3682
+ me.value.length ? (m(), g("div", To, [
3683
+ (m(!0), g(A, null, te(me.value, (r, u) => (m(), g("section", {
3658
3684
  key: u,
3659
3685
  class: "vpe-sql-result"
3660
3686
  }, [
3661
- l("div", Co, [
3662
- l("span", null, "结果 " + _(u + 1), 1),
3663
- l("span", null, _(Jr(r)), 1)
3687
+ l("div", No, [
3688
+ l("span", null, "结果 " + R(u + 1), 1),
3689
+ l("span", null, R(Wr(r)), 1)
3664
3690
  ]),
3665
- r.columns.length ? (m(), g("div", Po, [
3666
- l("table", Oo, [
3691
+ r.columns.length ? (m(), g("div", Lo, [
3692
+ l("table", $o, [
3667
3693
  l("thead", null, [
3668
3694
  l("tr", null, [
3669
- (m(!0), g(A, null, le(r.columns, (c, y) => (m(), g("th", { key: y }, _(c), 1))), 128))
3695
+ (m(!0), g(A, null, te(r.columns, (c, y) => (m(), g("th", { key: y }, R(c), 1))), 128))
3670
3696
  ])
3671
3697
  ]),
3672
3698
  l("tbody", null, [
3673
- (m(!0), g(A, null, le(r.rows, (c, y) => (m(), g("tr", { key: y }, [
3674
- (m(!0), g(A, null, le(c, (S, $) => (m(), g("td", {
3699
+ (m(!0), g(A, null, te(r.rows, (c, y) => (m(), g("tr", { key: y }, [
3700
+ (m(!0), g(A, null, te(c, (S, $) => (m(), g("td", {
3675
3701
  key: $,
3676
- class: ie({ "vpe-sql-null": S === null })
3677
- }, _(Kr(S)), 3))), 128))
3702
+ class: le({ "vpe-sql-null": S === null })
3703
+ }, R(Gr(S)), 3))), 128))
3678
3704
  ]))), 128))
3679
3705
  ])
3680
3706
  ]),
3681
- r.rows.length ? N("", !0) : (m(), g("div", Mo, "查询无数据"))
3682
- ])) : (m(), g("div", No, "影响 " + _(r.affectedRows ?? 0) + " 行", 1))
3707
+ r.rows.length ? T("", !0) : (m(), g("div", Fo, "查询无数据"))
3708
+ ])) : (m(), g("div", _o, "影响 " + R(r.affectedRows ?? 0) + " 行", 1))
3683
3709
  ]))), 128))
3684
- ])) : N("", !0),
3710
+ ])) : T("", !0),
3685
3711
  l("pre", {
3686
3712
  ref_key: "outputEl",
3687
- ref: R,
3713
+ ref: _,
3688
3714
  class: "vpe-output-body"
3689
3715
  }, [
3690
- G.value.length ? (m(!0), g(A, { key: 0 }, le(G.value, (r) => (m(), g("span", {
3716
+ G.value.length ? (m(!0), g(A, { key: 0 }, te(G.value, (r) => (m(), g("span", {
3691
3717
  key: r.id,
3692
- class: ie(["vpe-line", `vpe-line--${r.stream}`])
3693
- }, _(r.text) + `
3694
- `, 3))), 128)) : (m(), g("span", To, "暂无输出,点击“运行”或按 Ctrl+Enter 执行代码"))
3718
+ class: le(["vpe-line", `vpe-line--${r.stream}`])
3719
+ }, R(r.text) + `
3720
+ `, 3))), 128)) : (m(), g("span", Ro, "暂无输出,点击“运行”或按 Ctrl+Enter 执行代码"))
3695
3721
  ], 512)
3696
3722
  ]),
3697
- Je.value && Ae.value && It.value ? (m(), g("div", Lo, [
3723
+ Ze.value && Ae.value && Dt.value ? (m(), g("div", Io, [
3698
3724
  t[35] || (t[35] = l("span", {
3699
3725
  class: "vpe-terminal-prompt",
3700
3726
  "aria-hidden": "true"
@@ -3706,19 +3732,19 @@ const Da = Z(
3706
3732
  spellcheck: "false",
3707
3733
  placeholder: "输入后按 Enter 发送给 input()",
3708
3734
  "aria-label": "标准输入",
3709
- onKeydown: Ls(Kn(En, ["prevent"]), ["enter"])
3710
- }, null, 40, $o), [
3735
+ onKeydown: Ra(Yn(Mn, ["prevent"]), ["enter"])
3736
+ }, null, 40, Ho), [
3711
3737
  [he, H.value]
3712
3738
  ]),
3713
3739
  l("button", {
3714
3740
  class: "vpe-btn vpe-btn--sm",
3715
3741
  type: "button",
3716
- onClick: En
3742
+ onClick: Mn
3717
3743
  }, " 发送 ")
3718
- ])) : N("", !0)
3719
- ], 4)) : N("", !0),
3720
- qe.value ? (m(), g("div", Fo, [
3721
- l("div", Ro, [
3744
+ ])) : T("", !0)
3745
+ ], 4)) : T("", !0),
3746
+ De.value ? (m(), g("div", Bo, [
3747
+ l("div", Uo, [
3722
3748
  t[36] || (t[36] = l("span", { class: "vpe-fs-title" }, "虚拟文件", -1)),
3723
3749
  t[37] || (t[37] = l("span", {
3724
3750
  class: "vpe-spacer",
@@ -3728,47 +3754,47 @@ const Da = Z(
3728
3754
  class: "vpe-btn vpe-btn--sm",
3729
3755
  type: "button",
3730
3756
  title: "刷新文件列表",
3731
- disabled: Ye.value,
3732
- onClick: In
3733
- }, " 刷新 ", 8, _o),
3757
+ disabled: Xe.value,
3758
+ onClick: Dn
3759
+ }, " 刷新 ", 8, Ao),
3734
3760
  l("button", {
3735
3761
  class: "vpe-btn vpe-btn--sm",
3736
3762
  type: "button",
3737
3763
  title: "关闭虚拟文件面板",
3738
3764
  "aria-label": "关闭虚拟文件面板",
3739
- onClick: t[4] || (t[4] = (r) => qe.value = !1)
3765
+ onClick: t[4] || (t[4] = (r) => De.value = !1)
3740
3766
  }, [
3741
- j(B(lt))
3767
+ V(B(ct))
3742
3768
  ])
3743
3769
  ]),
3744
- l("div", Io, [
3745
- Ye.value ? (m(), g("div", Ho, "正在读取虚拟文件…")) : (m(), g(A, { key: 1 }, [
3746
- Xe.value.length ? N("", !0) : (m(), g("div", Bo, " 暂无文件。运行 Python 代码创建文件后再刷新。 ")),
3747
- (m(!0), g(A, null, le(Xe.value, (r) => (m(), g("div", {
3770
+ l("div", Do, [
3771
+ Xe.value ? (m(), g("div", zo, "正在读取虚拟文件…")) : (m(), g(A, { key: 1 }, [
3772
+ et.value.length ? T("", !0) : (m(), g("div", jo, " 暂无文件。运行 Python 代码创建文件后再刷新。 ")),
3773
+ (m(!0), g(A, null, te(et.value, (r) => (m(), g("div", {
3748
3774
  key: r.path,
3749
- class: ie(["vpe-fs-item", { "vpe-fs-item--dir": r.isDirectory }])
3775
+ class: le(["vpe-fs-item", { "vpe-fs-item--dir": r.isDirectory }])
3750
3776
  }, [
3751
3777
  l("span", {
3752
3778
  class: "vpe-fs-name",
3753
3779
  title: r.path
3754
- }, _(r.path), 9, Uo),
3755
- l("span", Ao, _(r.isDirectory ? "目录" : Vt(r.size)), 1),
3756
- r.isDirectory ? N("", !0) : (m(), g("button", {
3780
+ }, R(r.path), 9, Vo),
3781
+ l("span", Qo, R(r.isDirectory ? "目录" : Gt(r.size)), 1),
3782
+ r.isDirectory ? T("", !0) : (m(), g("button", {
3757
3783
  key: 0,
3758
3784
  class: "vpe-btn vpe-btn--sm",
3759
3785
  type: "button",
3760
3786
  title: `下载 ${r.name}`,
3761
3787
  "aria-label": `下载 ${r.name}`,
3762
- onClick: (u) => Hn(r.path)
3788
+ onClick: (u) => zn(r.path)
3763
3789
  }, [
3764
- j(B(cr))
3765
- ], 8, Do))
3790
+ V(B(fr))
3791
+ ], 8, Ko))
3766
3792
  ], 2))), 128))
3767
3793
  ], 64))
3768
3794
  ])
3769
- ])) : N("", !0),
3770
- Se.value && Oe.value ? (m(), g("div", zo, [
3771
- l("div", jo, [
3795
+ ])) : T("", !0),
3796
+ xe.value && Oe.value ? (m(), g("div", Jo, [
3797
+ l("div", Zo, [
3772
3798
  t[38] || (t[38] = l("span", { class: "vpe-fs-title" }, "服务端文件", -1)),
3773
3799
  t[39] || (t[39] = l("span", {
3774
3800
  class: "vpe-spacer",
@@ -3778,56 +3804,56 @@ const Da = Z(
3778
3804
  class: "vpe-btn vpe-btn--sm",
3779
3805
  type: "button",
3780
3806
  title: "刷新文件列表",
3781
- disabled: dt.value,
3782
- onClick: t[5] || (t[5] = (r) => We())
3783
- }, " 刷新 ", 8, Vo),
3807
+ disabled: ft.value,
3808
+ onClick: t[5] || (t[5] = (r) => Ye())
3809
+ }, " 刷新 ", 8, Go),
3784
3810
  l("button", {
3785
3811
  class: "vpe-btn vpe-btn--sm",
3786
3812
  type: "button",
3787
3813
  title: "关闭服务端文件面板",
3788
3814
  "aria-label": "关闭服务端文件面板",
3789
- onClick: t[6] || (t[6] = (r) => Se.value = !1)
3815
+ onClick: t[6] || (t[6] = (r) => xe.value = !1)
3790
3816
  }, [
3791
- j(B(lt))
3817
+ V(B(ct))
3792
3818
  ])
3793
3819
  ]),
3794
- l("div", Qo, [
3795
- dt.value ? (m(), g("div", Ko, "正在读取服务端文件…")) : (m(), g(A, { key: 1 }, [
3796
- !et.value.length && !De.value ? (m(), g("div", Jo, " 暂无已保存文件。点击工具栏“保存”按钮把当前文件保存到服务端。 ")) : N("", !0),
3797
- (m(!0), g(A, null, le(et.value, (r) => (m(), g("div", {
3820
+ l("div", Wo, [
3821
+ ft.value ? (m(), g("div", Yo, "正在读取服务端文件…")) : (m(), g(A, { key: 1 }, [
3822
+ !tt.value.length && !ze.value ? (m(), g("div", Xo, " 暂无已保存文件。点击工具栏“保存”按钮把当前文件保存到服务端。 ")) : T("", !0),
3823
+ (m(!0), g(A, null, te(tt.value, (r) => (m(), g("div", {
3798
3824
  key: r.id,
3799
3825
  class: "vpe-fs-item"
3800
3826
  }, [
3801
3827
  l("span", {
3802
3828
  class: "vpe-fs-name",
3803
3829
  title: r.name
3804
- }, _(r.name), 9, Zo),
3830
+ }, R(r.name), 9, ei),
3805
3831
  l("span", {
3806
3832
  class: "vpe-fs-size",
3807
- title: ps(r.updatedAt)
3808
- }, _(Vt(r.size)), 9, Go),
3833
+ title: ma(r.updatedAt)
3834
+ }, R(Gt(r.size)), 9, ti),
3809
3835
  l("button", {
3810
3836
  class: "vpe-btn vpe-btn--sm",
3811
3837
  type: "button",
3812
3838
  title: `打开 ${r.name}`,
3813
3839
  disabled: W.value,
3814
- onClick: (u) => vs(r)
3815
- }, " 打开 ", 8, Wo),
3840
+ onClick: (u) => ya(r)
3841
+ }, " 打开 ", 8, ni),
3816
3842
  l("button", {
3817
3843
  class: "vpe-btn vpe-btn--sm",
3818
3844
  type: "button",
3819
3845
  title: `删除 ${r.name}`,
3820
3846
  disabled: W.value,
3821
- onClick: (u) => ms(r)
3822
- }, " 删除 ", 8, Yo)
3847
+ onClick: (u) => ha(r)
3848
+ }, " 删除 ", 8, ri)
3823
3849
  ]))), 128)),
3824
- De.value ? (m(), g("p", Xo, _(De.value), 1)) : N("", !0)
3850
+ ze.value ? (m(), g("p", ai, R(ze.value), 1)) : T("", !0)
3825
3851
  ], 64))
3826
3852
  ])
3827
- ])) : N("", !0),
3828
- Fe.value && de.value ? (m(), g("div", ei, [
3829
- l("div", ti, [
3830
- l("span", ni, _(Pr.value), 1),
3853
+ ])) : T("", !0),
3854
+ Fe.value && pe.value ? (m(), g("div", si, [
3855
+ l("div", oi, [
3856
+ l("span", ii, R(Tr.value), 1),
3831
3857
  t[40] || (t[40] = l("span", {
3832
3858
  class: "vpe-spacer",
3833
3859
  "aria-hidden": "true"
@@ -3837,27 +3863,27 @@ const Da = Z(
3837
3863
  type: "button",
3838
3864
  title: "关闭 SQL 连接配置",
3839
3865
  "aria-label": "关闭 SQL 连接配置",
3840
- onClick: hn
3866
+ onClick: xn
3841
3867
  }, [
3842
- j(B(lt))
3868
+ V(B(ct))
3843
3869
  ])
3844
3870
  ]),
3845
- l("div", ri, [
3846
- l("label", si, [
3871
+ l("div", li, [
3872
+ l("label", ui, [
3847
3873
  t[42] || (t[42] = l("span", { class: "vpe-sql-label" }, "执行方式", -1)),
3848
3874
  J(l("select", {
3849
3875
  "onUpdate:modelValue": t[7] || (t[7] = (r) => f.value.mode = r),
3850
3876
  class: "vpe-sql-input",
3851
- onChange: Br
3877
+ onChange: Dr
3852
3878
  }, [...t[41] || (t[41] = [
3853
3879
  l("option", { value: "sqlite" }, "浏览器内 SQLite(无需服务端)", -1),
3854
3880
  l("option", { value: "http" }, "HTTP 服务(后端网关)", -1)
3855
3881
  ])], 544), [
3856
- [St, f.value.mode]
3882
+ [Et, f.value.mode]
3857
3883
  ])
3858
3884
  ]),
3859
3885
  f.value.mode === "sqlite" ? (m(), g(A, { key: 0 }, [
3860
- l("label", ai, [
3886
+ l("label", ci, [
3861
3887
  t[43] || (t[43] = l("span", { class: "vpe-sql-label" }, "数据库文件", -1)),
3862
3888
  J(l("input", {
3863
3889
  "onUpdate:modelValue": t[8] || (t[8] = (r) => f.value.connection.database = r),
@@ -3872,35 +3898,35 @@ const Da = Z(
3872
3898
  ]),
3873
3899
  t[44] || (t[44] = l("p", { class: "vpe-sql-hint" }, " SQLite 在浏览器内运行,数据仅保存在当前页面内存;“停止”或刷新后会丢失。 ", -1))
3874
3900
  ], 64)) : (m(), g(A, { key: 1 }, [
3875
- l("label", oi, [
3901
+ l("label", di, [
3876
3902
  t[45] || (t[45] = l("span", { class: "vpe-sql-label" }, "连接名称", -1)),
3877
3903
  J(l("input", {
3878
- "onUpdate:modelValue": t[9] || (t[9] = (r) => ee.value = r),
3904
+ "onUpdate:modelValue": t[9] || (t[9] = (r) => ne.value = r),
3879
3905
  class: "vpe-sql-input",
3880
3906
  type: "text",
3881
3907
  spellcheck: "false",
3882
3908
  placeholder: "用于保存和切换连接"
3883
3909
  }, null, 512), [
3884
- [he, ee.value]
3910
+ [he, ne.value]
3885
3911
  ])
3886
3912
  ]),
3887
- l("label", ii, [
3913
+ l("label", pi, [
3888
3914
  t[46] || (t[46] = l("span", { class: "vpe-sql-label" }, "数据库类型", -1)),
3889
3915
  J(l("select", {
3890
3916
  "onUpdate:modelValue": t[10] || (t[10] = (r) => f.value.connection.dialect = r),
3891
3917
  class: "vpe-sql-input",
3892
- onChange: Ur
3918
+ onChange: zr
3893
3919
  }, [
3894
- (m(!0), g(A, null, le(B(ut), (r) => (m(), g("option", {
3920
+ (m(!0), g(A, null, te(B(dt), (r) => (m(), g("option", {
3895
3921
  key: r.value,
3896
3922
  value: r.value
3897
- }, _(r.label), 9, li))), 128))
3923
+ }, R(r.label), 9, fi))), 128))
3898
3924
  ], 544), [
3899
- [St, f.value.connection.dialect]
3925
+ [Et, f.value.connection.dialect]
3900
3926
  ])
3901
3927
  ]),
3902
- l("div", ui, [
3903
- l("label", ci, [
3928
+ l("div", vi, [
3929
+ l("label", mi, [
3904
3930
  t[47] || (t[47] = l("span", { class: "vpe-sql-label" }, "主机", -1)),
3905
3931
  J(l("input", {
3906
3932
  "onUpdate:modelValue": t[11] || (t[11] = (r) => f.value.connection.host = r),
@@ -3913,7 +3939,7 @@ const Da = Z(
3913
3939
  [he, f.value.connection.host]
3914
3940
  ])
3915
3941
  ]),
3916
- l("label", di, [
3942
+ l("label", gi, [
3917
3943
  t[48] || (t[48] = l("span", { class: "vpe-sql-label" }, "端口", -1)),
3918
3944
  J(l("input", {
3919
3945
  "onUpdate:modelValue": t[12] || (t[12] = (r) => f.value.connection.port = r),
@@ -3933,8 +3959,8 @@ const Da = Z(
3933
3959
  ])
3934
3960
  ])
3935
3961
  ]),
3936
- l("div", pi, [
3937
- l("label", fi, [
3962
+ l("div", yi, [
3963
+ l("label", hi, [
3938
3964
  t[49] || (t[49] = l("span", { class: "vpe-sql-label" }, "用户名", -1)),
3939
3965
  J(l("input", {
3940
3966
  "onUpdate:modelValue": t[13] || (t[13] = (r) => f.value.connection.user = r),
@@ -3947,7 +3973,7 @@ const Da = Z(
3947
3973
  [he, f.value.connection.user]
3948
3974
  ])
3949
3975
  ]),
3950
- l("label", vi, [
3976
+ l("label", bi, [
3951
3977
  t[50] || (t[50] = l("span", { class: "vpe-sql-label" }, "密码", -1)),
3952
3978
  J(l("input", {
3953
3979
  "onUpdate:modelValue": t[14] || (t[14] = (r) => f.value.connection.password = r),
@@ -3956,12 +3982,12 @@ const Da = Z(
3956
3982
  autocomplete: "new-password",
3957
3983
  placeholder: f.value.connectionId ? "已保存(留空不修改)" : "",
3958
3984
  onChange: ye
3959
- }, null, 40, mi), [
3985
+ }, null, 40, ki), [
3960
3986
  [he, f.value.connection.password]
3961
3987
  ])
3962
3988
  ])
3963
3989
  ]),
3964
- l("label", gi, [
3990
+ l("label", wi, [
3965
3991
  t[51] || (t[51] = l("span", { class: "vpe-sql-label" }, "数据库名", -1)),
3966
3992
  J(l("input", {
3967
3993
  "onUpdate:modelValue": t[15] || (t[15] = (r) => f.value.connection.database = r),
@@ -3974,7 +4000,7 @@ const Da = Z(
3974
4000
  [he, f.value.connection.database]
3975
4001
  ])
3976
4002
  ]),
3977
- a.sqlEndpointLocked ? N("", !0) : (m(), g("label", yi, [
4003
+ s.sqlEndpointLocked ? T("", !0) : (m(), g("label", Si, [
3978
4004
  t[52] || (t[52] = l("span", { class: "vpe-sql-label" }, "服务端点", -1)),
3979
4005
  J(l("input", {
3980
4006
  "onUpdate:modelValue": t[16] || (t[16] = (r) => f.value.endpoint = r),
@@ -3987,44 +4013,44 @@ const Da = Z(
3987
4013
  [he, f.value.endpoint]
3988
4014
  ])
3989
4015
  ])),
3990
- a.sqlEndpointLocked ? (m(), g("p", hi, "服务端点由系统预置,无需填写。")) : N("", !0),
4016
+ s.sqlEndpointLocked ? (m(), g("p", xi, "服务端点由系统预置,无需填写。")) : T("", !0),
3991
4017
  t[53] || (t[53] = l("p", { class: "vpe-sql-hint" }, " 执行时会把连接信息与 SQL POST 到该端点,由后端网关连接真实数据库。建议使用 HTTPS,并避免在前端配置高权限账号。 ", -1))
3992
4018
  ], 64)),
3993
- l("div", bi, [
4019
+ l("div", Ei, [
3994
4020
  l("button", {
3995
4021
  class: "vpe-btn vpe-btn--primary",
3996
4022
  type: "button",
3997
- disabled: Re.value,
3998
- onClick: Qr
3999
- }, _(Re.value ? "测试中…" : "测试连接"), 9, ki),
4023
+ disabled: _e.value,
4024
+ onClick: Zr
4025
+ }, R(_e.value ? "测试中…" : "测试连接"), 9, qi),
4000
4026
  f.value.mode === "http" ? (m(), g("button", {
4001
4027
  key: 0,
4002
4028
  class: "vpe-btn",
4003
4029
  type: "button",
4004
- disabled: te.value,
4005
- onClick: zr
4006
- }, " 保存 ", 8, wi)) : N("", !0),
4030
+ disabled: re.value,
4031
+ onClick: Qr
4032
+ }, " 保存 ", 8, Ci)) : T("", !0),
4007
4033
  f.value.mode === "http" && f.value.connectionId ? (m(), g("button", {
4008
4034
  key: 1,
4009
4035
  class: "vpe-btn",
4010
4036
  type: "button",
4011
- disabled: te.value,
4012
- onClick: jr
4013
- }, " 删除 ", 8, Si)) : N("", !0),
4014
- tt.value ? (m(), g("span", {
4037
+ disabled: re.value,
4038
+ onClick: Kr
4039
+ }, " 删除 ", 8, Pi)) : T("", !0),
4040
+ nt.value ? (m(), g("span", {
4015
4041
  key: 2,
4016
- class: ie(["vpe-sql-test", pt.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
4017
- }, _(tt.value), 3)) : N("", !0),
4018
- f.value.mode === "http" && Pe.value ? (m(), g("span", xi, _(Pe.value), 1)) : N("", !0),
4019
- f.value.mode === "http" && ne.value ? (m(), g("span", {
4042
+ class: le(["vpe-sql-test", vt.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
4043
+ }, R(nt.value), 3)) : T("", !0),
4044
+ f.value.mode === "http" && Pe.value ? (m(), g("span", Oi, R(Pe.value), 1)) : T("", !0),
4045
+ f.value.mode === "http" && ae.value ? (m(), g("span", {
4020
4046
  key: 4,
4021
- class: ie(["vpe-sql-test", je.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
4022
- }, _(ne.value), 3)) : N("", !0)
4047
+ class: le(["vpe-sql-test", Ve.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
4048
+ }, R(ae.value), 3)) : T("", !0)
4023
4049
  ])
4024
4050
  ])
4025
- ])) : N("", !0),
4026
- _e.value && de.value ? (m(), g("div", Ei, [
4027
- l("div", qi, [
4051
+ ])) : T("", !0),
4052
+ Re.value && pe.value ? (m(), g("div", Mi, [
4053
+ l("div", Ti, [
4028
4054
  t[54] || (t[54] = l("span", { class: "vpe-fs-title" }, "连接管理", -1)),
4029
4055
  t[55] || (t[55] = l("span", {
4030
4056
  class: "vpe-spacer",
@@ -4034,96 +4060,96 @@ const Da = Z(
4034
4060
  class: "vpe-btn vpe-btn--sm",
4035
4061
  type: "button",
4036
4062
  title: "刷新连接列表",
4037
- disabled: ze.value,
4038
- onClick: fe
4039
- }, " 刷新 ", 8, Ci),
4063
+ disabled: je.value,
4064
+ onClick: ve
4065
+ }, " 刷新 ", 8, Ni),
4040
4066
  l("button", {
4041
4067
  class: "vpe-btn vpe-btn--sm",
4042
4068
  type: "button",
4043
4069
  title: "关闭连接管理",
4044
4070
  "aria-label": "关闭连接管理",
4045
- onClick: t[17] || (t[17] = (r) => _e.value = !1)
4071
+ onClick: t[17] || (t[17] = (r) => Re.value = !1)
4046
4072
  }, [
4047
- j(B(lt))
4073
+ V(B(ct))
4048
4074
  ])
4049
4075
  ]),
4050
- l("div", Pi, [
4051
- ze.value ? (m(), g("div", Oi, "正在读取连接…")) : (m(), g(A, { key: 1 }, [
4052
- Ce.value.length ? N("", !0) : (m(), g("div", Mi, " 暂无已保存连接,点击工具栏“新建连接”创建。 ")),
4053
- (m(!0), g(A, null, le(Ce.value, (r) => (m(), g("div", {
4076
+ l("div", Li, [
4077
+ je.value ? (m(), g("div", $i, "正在读取连接…")) : (m(), g(A, { key: 1 }, [
4078
+ Ce.value.length ? T("", !0) : (m(), g("div", Fi, " 暂无已保存连接,点击工具栏“新建连接”创建。 ")),
4079
+ (m(!0), g(A, null, te(Ce.value, (r) => (m(), g("div", {
4054
4080
  key: r.id,
4055
4081
  class: "vpe-sql-manager-item"
4056
4082
  }, [
4057
- l("div", Ni, [
4083
+ l("div", _i, [
4058
4084
  l("span", {
4059
4085
  class: "vpe-sql-manager-name",
4060
4086
  title: r.name
4061
- }, _(r.name), 9, Ti),
4062
- l("span", Li, [
4063
- Qt(_(r.dialect), 1),
4087
+ }, R(r.name), 9, Ri),
4088
+ l("span", Ii, [
4089
+ Wt(R(r.dialect), 1),
4064
4090
  r.database ? (m(), g(A, { key: 0 }, [
4065
- Qt(" · " + _(r.database), 1)
4066
- ], 64)) : N("", !0),
4091
+ Wt(" · " + R(r.database), 1)
4092
+ ], 64)) : T("", !0),
4067
4093
  r.host ? (m(), g(A, { key: 1 }, [
4068
- Qt(" · " + _(r.host), 1)
4069
- ], 64)) : N("", !0)
4094
+ Wt(" · " + R(r.host), 1)
4095
+ ], 64)) : T("", !0)
4070
4096
  ])
4071
4097
  ]),
4072
4098
  l("button", {
4073
4099
  class: "vpe-btn vpe-btn--sm",
4074
4100
  type: "button",
4075
4101
  title: "编辑连接",
4076
- onClick: (u) => Dr(r)
4077
- }, " 编辑 ", 8, $i),
4102
+ onClick: (u) => Vr(r)
4103
+ }, " 编辑 ", 8, Hi),
4078
4104
  l("button", {
4079
4105
  class: "vpe-btn vpe-btn--sm",
4080
4106
  type: "button",
4081
4107
  title: "删除连接",
4082
- disabled: te.value,
4083
- onClick: (u) => Vr(r)
4084
- }, " 删除 ", 8, Fi)
4108
+ disabled: re.value,
4109
+ onClick: (u) => Jr(r)
4110
+ }, " 删除 ", 8, Bi)
4085
4111
  ]))), 128)),
4086
- Pe.value ? (m(), g("p", Ri, _(Pe.value), 1)) : N("", !0),
4087
- Ve.value ? (m(), g("p", {
4112
+ Pe.value ? (m(), g("p", Ui, R(Pe.value), 1)) : T("", !0),
4113
+ Qe.value ? (m(), g("p", {
4088
4114
  key: 2,
4089
- class: ie(["vpe-sql-hint", ft.value ? "vpe-sql-hint--ok" : "vpe-sql-hint--error"])
4090
- }, _(Ve.value), 3)) : N("", !0)
4115
+ class: le(["vpe-sql-hint", mt.value ? "vpe-sql-hint--ok" : "vpe-sql-hint--error"])
4116
+ }, R(Qe.value), 3)) : T("", !0)
4091
4117
  ], 64))
4092
4118
  ])
4093
- ])) : N("", !0)
4119
+ ])) : T("", !0)
4094
4120
  ], 6));
4095
4121
  }
4096
4122
  });
4097
- function Wi(a = {}) {
4123
+ function nl(s = {}) {
4098
4124
  var Ae;
4099
- const n = rn(a.pyodideUrl ? { pyodideUrl: a.pyodideUrl } : void 0), s = C(n.status), o = C(""), i = C([]);
4125
+ const n = un(s.pyodideUrl ? { pyodideUrl: s.pyodideUrl } : void 0), a = C(n.status), o = C(""), i = C([]);
4100
4126
  let p = 0;
4101
4127
  const b = (H, k) => {
4102
4128
  i.value.push({ id: ++p, stream: H, text: k });
4103
4129
  }, E = n.on("status", (H, k) => {
4104
- s.value = H, k && (o.value = k);
4105
- }), R = n.on("initError", (H) => {
4130
+ a.value = H, k && (o.value = k);
4131
+ }), _ = n.on("initError", (H) => {
4106
4132
  b("system", `[pyodide] 加载失败:${H}`);
4107
4133
  });
4108
- $s(() => {
4109
- E(), R();
4134
+ Ia(() => {
4135
+ E(), _();
4110
4136
  });
4111
- const P = async (H, k = {}) => {
4137
+ const O = async (H, k = {}) => {
4112
4138
  var I;
4113
4139
  try {
4114
- const Q = await n.run(H, {
4140
+ const z = await n.run(H, {
4115
4141
  stdin: k.stdin,
4116
- onOutput: (me, qe) => b(me, qe)
4142
+ onOutput: (ce, Se) => b(ce, Se)
4117
4143
  });
4118
- return !Q.ok && ((I = Q.error) != null && I.traceback) && b("stderr", Q.error.traceback), Q;
4119
- } catch (Q) {
4144
+ return !z.ok && ((I = z.error) != null && I.traceback) && b("stderr", z.error.traceback), z;
4145
+ } catch (z) {
4120
4146
  return {
4121
4147
  ok: !1,
4122
4148
  durationMs: 0,
4123
- error: { type: "RuntimeError", message: Q instanceof Error ? Q.message : String(Q), traceback: "" }
4149
+ error: { type: "RuntimeError", message: z instanceof Error ? z.message : String(z), traceback: "" }
4124
4150
  };
4125
4151
  }
4126
- }, T = async (H, k) => {
4152
+ }, N = async (H, k) => {
4127
4153
  try {
4128
4154
  return await n.writeFile(H, k);
4129
4155
  } catch (I) {
@@ -4153,10 +4179,10 @@ function Wi(a = {}) {
4153
4179
  }
4154
4180
  };
4155
4181
  let G = !1;
4156
- const ve = async () => {
4182
+ const me = async () => {
4157
4183
  var I;
4158
4184
  if (G) return;
4159
- const H = a.preloadPackages ?? [];
4185
+ const H = s.preloadPackages ?? [];
4160
4186
  if (!H.length) return;
4161
4187
  G = !0, b("system", `[pyodide] 正在安装预置包:${H.join(", ")}`);
4162
4188
  const k = await q(H);
@@ -4165,56 +4191,56 @@ function Wi(a = {}) {
4165
4191
  k.ok ? `[pyodide] 预置包安装完成(${(k.durationMs / 1e3).toFixed(1)}s)` : `[pyodide] 预置包安装失败:${((I = k.error) == null ? void 0 : I.message) ?? "未知错误"}`
4166
4192
  );
4167
4193
  };
4168
- return (a.preload || (((Ae = a.preloadPackages) == null ? void 0 : Ae.length) ?? 0) > 0) && n.waitReady().then(() => ve()).catch(() => {
4194
+ return (s.preload || (((Ae = s.preloadPackages) == null ? void 0 : Ae.length) ?? 0) > 0) && n.waitReady().then(() => me()).catch(() => {
4169
4195
  }), {
4170
- status: s,
4196
+ status: a,
4171
4197
  version: o,
4172
4198
  outputs: i,
4173
- runPython: P,
4199
+ runPython: O,
4174
4200
  install: q,
4175
4201
  checkSyntax: (H) => n.checkSyntax(H),
4176
4202
  interrupt: () => n.interrupt(),
4177
4203
  clearOutputs: () => {
4178
4204
  i.value = [];
4179
4205
  },
4180
- writeFile: T,
4206
+ writeFile: N,
4181
4207
  readFile: x,
4182
4208
  listFiles: F,
4183
4209
  /** 预加载并在就绪后 resolve */
4184
4210
  ready: () => n.waitReady()
4185
4211
  };
4186
4212
  }
4187
- const Yi = _i;
4213
+ const rl = Ai;
4188
4214
  export {
4189
- vr as DEFAULT_PYODIDE_URL,
4190
- Gi as DEFAULT_SQL_CONFIG,
4191
- or as EDITOR_THEMES,
4192
- fa as MONO_FONT_STACK,
4193
- Sa as PyodideRunner,
4194
- Yi as PythonEditor,
4195
- ut as SQL_DIALECT_OPTIONS,
4196
- ya as createEditor,
4197
- Ta as createPythonSession,
4198
- _i as default,
4199
- Oa as deleteServerFile,
4200
- sr as deleteSqlConnection,
4201
- rr as getDefaultSqlPort,
4202
- rn as getRunner,
4203
- Aa as getThemeOption,
4204
- Yn as interruptPythonSession,
4205
- ir as isDarkTheme,
4206
- qa as listServerFiles,
4207
- Ba as listSqlConnections,
4208
- ha as makePythonLinter,
4215
+ yr as DEFAULT_PYODIDE_URL,
4216
+ tl as DEFAULT_SQL_CONFIG,
4217
+ ln as EDITOR_THEMES,
4218
+ gs as MONO_FONT_STACK,
4219
+ qs as PyodideRunner,
4220
+ rl as PythonEditor,
4221
+ dt as SQL_DIALECT_OPTIONS,
4222
+ ks as createEditor,
4223
+ Fs as createPythonSession,
4224
+ Ai as default,
4225
+ Ns as deleteServerFile,
4226
+ ur as deleteSqlConnection,
4227
+ lr as getDefaultSqlPort,
4228
+ un as getRunner,
4229
+ js as getThemeOption,
4230
+ rr as interruptPythonSession,
4231
+ ut as isDarkTheme,
4232
+ Os as listServerFiles,
4233
+ Ds as listSqlConnections,
4234
+ ws as makePythonLinter,
4209
4235
  D as normalizeSqlConfig,
4210
- La as pollPythonSession,
4211
- Pa as readServerFile,
4212
- Zi as runPythonOnServer,
4213
- yr as runSql,
4214
- Ca as saveServerFile,
4215
- Ua as saveSqlConnection,
4216
- $a as sendPythonSessionInput,
4217
- fr as setErrorLines,
4218
- Ha as testSqlConnection,
4219
- Wi as usePyodide
4236
+ _s as pollPythonSession,
4237
+ Ts as readServerFile,
4238
+ el as runPythonOnServer,
4239
+ kr as runSql,
4240
+ Ms as saveServerFile,
4241
+ zs as saveSqlConnection,
4242
+ Rs as sendPythonSessionInput,
4243
+ gr as setErrorLines,
4244
+ As as testSqlConnection,
4245
+ nl as usePyodide
4220
4246
  };