princess-python-editor 0.1.3 → 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.cjs.js +6 -6
- package/dist/index.es.js +1408 -1375
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { h as
|
|
5
|
-
import { EditorState as
|
|
6
|
-
import { EditorView as $e, keymap as
|
|
7
|
-
import { linter as
|
|
8
|
-
import { autocompletion as
|
|
9
|
-
import { history as
|
|
10
|
-
import { syntaxHighlighting as
|
|
11
|
-
import { python as
|
|
12
|
-
import { javascript as
|
|
13
|
-
import { json as
|
|
14
|
-
import { sql as
|
|
15
|
-
let
|
|
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 =
|
|
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 =
|
|
38
|
-
let o = n(
|
|
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: (
|
|
44
|
-
K.openedBy = new K({ deserialize: (
|
|
45
|
-
K.group = new K({ deserialize: (
|
|
46
|
-
K.isolate = new K({ deserialize: (
|
|
47
|
-
if (
|
|
48
|
-
throw new RangeError("Invalid value for isolate: " +
|
|
49
|
-
return
|
|
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
|
|
55
|
-
class
|
|
54
|
+
const ls = /* @__PURE__ */ Object.create(null);
|
|
55
|
+
class pt {
|
|
56
56
|
/**
|
|
57
57
|
@internal
|
|
58
58
|
*/
|
|
59
|
-
constructor(n,
|
|
60
|
-
this.name = n, this.props =
|
|
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
|
|
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
|
-
|
|
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
|
|
118
|
-
return
|
|
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
|
|
131
|
+
let a = /* @__PURE__ */ Object.create(null);
|
|
132
132
|
for (let o in n)
|
|
133
133
|
for (let i of o.split(" "))
|
|
134
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
152
|
-
(function(
|
|
153
|
-
|
|
154
|
-
})(
|
|
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
|
|
156
|
+
let us = 0;
|
|
157
157
|
class ue {
|
|
158
158
|
/**
|
|
159
159
|
@internal
|
|
160
160
|
*/
|
|
161
|
-
constructor(n,
|
|
162
|
-
this.name = n, this.set =
|
|
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
|
|
167
|
-
|
|
166
|
+
for (let a of this.modified)
|
|
167
|
+
a.name && (n = `${a.name}(${n})`);
|
|
168
168
|
return n;
|
|
169
169
|
}
|
|
170
|
-
static define(n,
|
|
170
|
+
static define(n, a) {
|
|
171
171
|
let o = typeof n == "string" ? n : "?";
|
|
172
|
-
if (n instanceof ue && (
|
|
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),
|
|
176
|
-
for (let p of
|
|
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
|
|
194
|
-
return (o) => o.modified.indexOf(
|
|
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
|
|
198
|
-
class
|
|
197
|
+
let cs = 0;
|
|
198
|
+
class Nt {
|
|
199
199
|
constructor(n) {
|
|
200
|
-
this.name = n, this.instances = [], this.id =
|
|
200
|
+
this.name = n, this.instances = [], this.id = cs++;
|
|
201
201
|
}
|
|
202
|
-
static get(n,
|
|
203
|
-
if (!
|
|
202
|
+
static get(n, a) {
|
|
203
|
+
if (!a.length)
|
|
204
204
|
return n;
|
|
205
|
-
let o =
|
|
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,
|
|
209
|
-
for (let E of
|
|
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 =
|
|
211
|
+
let b = ps(a);
|
|
212
212
|
for (let E of n.set)
|
|
213
213
|
if (!E.modified.length)
|
|
214
|
-
for (let
|
|
215
|
-
i.push(
|
|
214
|
+
for (let _ of b)
|
|
215
|
+
i.push(Nt.get(E, _));
|
|
216
216
|
return p;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return
|
|
219
|
+
function ds(s, n) {
|
|
220
|
+
return s.length == n.length && s.every((a, o) => a == n[o]);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function ps(s) {
|
|
223
223
|
let n = [[]];
|
|
224
|
-
for (let
|
|
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
|
|
227
|
-
return n.sort((
|
|
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(
|
|
231
|
-
let
|
|
232
|
-
for (;
|
|
233
|
-
if (!
|
|
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
|
|
236
|
-
|
|
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
|
|
242
|
-
constructor(n,
|
|
243
|
-
this.tags = n, this.mode =
|
|
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
|
-
|
|
259
|
-
function
|
|
260
|
-
let
|
|
261
|
-
for (let p of
|
|
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
|
-
|
|
263
|
+
a[p.tag.id] = p.class;
|
|
264
264
|
else
|
|
265
265
|
for (let b of p.tag)
|
|
266
|
-
|
|
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
|
|
273
|
-
let
|
|
274
|
-
if (
|
|
275
|
-
b = b ? b + " " +
|
|
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,
|
|
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:
|
|
288
|
+
comment: Ct,
|
|
289
289
|
/**
|
|
290
290
|
A line [comment](#highlight.tags.comment).
|
|
291
291
|
*/
|
|
292
|
-
lineComment: v(
|
|
292
|
+
lineComment: v(Ct),
|
|
293
293
|
/**
|
|
294
294
|
A block [comment](#highlight.tags.comment).
|
|
295
295
|
*/
|
|
296
|
-
blockComment: v(
|
|
296
|
+
blockComment: v(Ct),
|
|
297
297
|
/**
|
|
298
298
|
A documentation [comment](#highlight.tags.comment).
|
|
299
299
|
*/
|
|
300
|
-
docComment: v(
|
|
300
|
+
docComment: v(Ct),
|
|
301
301
|
/**
|
|
302
302
|
Any kind of identifier.
|
|
303
303
|
*/
|
|
304
|
-
name:
|
|
304
|
+
name: Ne,
|
|
305
305
|
/**
|
|
306
306
|
The [name](#highlight.tags.name) of a variable.
|
|
307
307
|
*/
|
|
308
|
-
variableName: v(
|
|
308
|
+
variableName: v(Ne),
|
|
309
309
|
/**
|
|
310
310
|
A type [name](#highlight.tags.name).
|
|
311
311
|
*/
|
|
312
|
-
typeName:
|
|
312
|
+
typeName: tr,
|
|
313
313
|
/**
|
|
314
314
|
A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
|
315
315
|
*/
|
|
316
|
-
tagName: v(
|
|
316
|
+
tagName: v(tr),
|
|
317
317
|
/**
|
|
318
318
|
A property or field [name](#highlight.tags.name).
|
|
319
319
|
*/
|
|
320
|
-
propertyName:
|
|
320
|
+
propertyName: nr,
|
|
321
321
|
/**
|
|
322
322
|
An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
|
323
323
|
*/
|
|
324
|
-
attributeName: v(
|
|
324
|
+
attributeName: v(nr),
|
|
325
325
|
/**
|
|
326
326
|
The [name](#highlight.tags.name) of a class.
|
|
327
327
|
*/
|
|
328
|
-
className: v(
|
|
328
|
+
className: v(Ne),
|
|
329
329
|
/**
|
|
330
330
|
A label [name](#highlight.tags.name).
|
|
331
331
|
*/
|
|
332
|
-
labelName: v(
|
|
332
|
+
labelName: v(Ne),
|
|
333
333
|
/**
|
|
334
334
|
A namespace [name](#highlight.tags.name).
|
|
335
335
|
*/
|
|
336
|
-
namespace: v(
|
|
336
|
+
namespace: v(Ne),
|
|
337
337
|
/**
|
|
338
338
|
The [name](#highlight.tags.name) of a macro.
|
|
339
339
|
*/
|
|
340
|
-
macroName: v(
|
|
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(), Zn = v(Te), Gn = v(Te), Le = v(), Et =
|
|
|
345
345
|
/**
|
|
346
346
|
A string [literal](#highlight.tags.literal).
|
|
347
347
|
*/
|
|
348
|
-
string:
|
|
348
|
+
string: Pt,
|
|
349
349
|
/**
|
|
350
350
|
A documentation [string](#highlight.tags.string).
|
|
351
351
|
*/
|
|
352
|
-
docString: v(
|
|
352
|
+
docString: v(Pt),
|
|
353
353
|
/**
|
|
354
354
|
A character literal (subtag of [string](#highlight.tags.string)).
|
|
355
355
|
*/
|
|
356
|
-
character: v(
|
|
356
|
+
character: v(Pt),
|
|
357
357
|
/**
|
|
358
358
|
An attribute value (subtag of [string](#highlight.tags.string)).
|
|
359
359
|
*/
|
|
360
|
-
attributeValue: v(
|
|
360
|
+
attributeValue: v(Pt),
|
|
361
361
|
/**
|
|
362
362
|
A number [literal](#highlight.tags.literal).
|
|
363
363
|
*/
|
|
364
|
-
number:
|
|
364
|
+
number: Yt,
|
|
365
365
|
/**
|
|
366
366
|
An integer [number](#highlight.tags.number) literal.
|
|
367
367
|
*/
|
|
368
|
-
integer: v(
|
|
368
|
+
integer: v(Yt),
|
|
369
369
|
/**
|
|
370
370
|
A floating-point [number](#highlight.tags.number) literal.
|
|
371
371
|
*/
|
|
372
|
-
float: v(
|
|
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(), Zn = v(Te), Gn = v(Te), Le = v(), Et =
|
|
|
476
476
|
/**
|
|
477
477
|
Program or markup punctuation.
|
|
478
478
|
*/
|
|
479
|
-
punctuation:
|
|
479
|
+
punctuation: sn,
|
|
480
480
|
/**
|
|
481
481
|
[Punctuation](#highlight.tags.punctuation) that separates
|
|
482
482
|
things.
|
|
483
483
|
*/
|
|
484
|
-
separator: v(
|
|
484
|
+
separator: v(sn),
|
|
485
485
|
/**
|
|
486
486
|
Bracket-style [punctuation](#highlight.tags.punctuation).
|
|
487
487
|
*/
|
|
488
|
-
bracket:
|
|
488
|
+
bracket: lt,
|
|
489
489
|
/**
|
|
490
490
|
Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
|
491
491
|
tokens).
|
|
492
492
|
*/
|
|
493
|
-
angleBracket: v(
|
|
493
|
+
angleBracket: v(lt),
|
|
494
494
|
/**
|
|
495
495
|
Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
|
496
496
|
tokens).
|
|
497
497
|
*/
|
|
498
|
-
squareBracket: v(
|
|
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(
|
|
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(
|
|
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(), Zn = v(Te), Gn = v(Te), Le = v(), Et =
|
|
|
591
591
|
/**
|
|
592
592
|
Metadata or meta-instruction.
|
|
593
593
|
*/
|
|
594
|
-
meta:
|
|
594
|
+
meta: Ot,
|
|
595
595
|
/**
|
|
596
596
|
[Metadata](#highlight.tags.meta) that applies to the entire
|
|
597
597
|
document.
|
|
598
598
|
*/
|
|
599
|
-
documentMeta: v(
|
|
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(
|
|
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(
|
|
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(), Zn = v(Te), Gn = v(Te), Le = v(), Et =
|
|
|
647
647
|
*/
|
|
648
648
|
special: ue.defineModifier("special")
|
|
649
649
|
};
|
|
650
|
-
for (let
|
|
651
|
-
let n = d[
|
|
652
|
-
n instanceof ue && (n.name =
|
|
650
|
+
for (let s in d) {
|
|
651
|
+
let n = d[s];
|
|
652
|
+
n instanceof ue && (n.name = s);
|
|
653
653
|
}
|
|
654
|
-
|
|
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
|
|
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
|
-
},
|
|
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
|
|
787
|
-
return [$e.theme(
|
|
786
|
+
function Tt(s) {
|
|
787
|
+
return [$e.theme(vs, { dark: s }), es(ms)];
|
|
788
788
|
}
|
|
789
|
-
const
|
|
790
|
-
function
|
|
791
|
-
const
|
|
792
|
-
return
|
|
793
|
-
|
|
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
|
|
797
|
-
create: () =>
|
|
798
|
-
update: (
|
|
799
|
-
let
|
|
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(
|
|
802
|
-
return n.docChanged && (
|
|
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: (
|
|
805
|
-
}),
|
|
804
|
+
provide: (s) => $e.decorations.from(s)
|
|
805
|
+
}), bs = $e.theme({
|
|
806
806
|
"&": { height: "100%", fontSize: "13px" },
|
|
807
|
-
".cm-scroller": { fontFamily:
|
|
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
|
|
818
|
-
const
|
|
817
|
+
function ks(s, n) {
|
|
818
|
+
const a = $e.updateListener.of((p) => {
|
|
819
819
|
p.docChanged && n.onDocChange(p.state.doc.toString());
|
|
820
|
-
}), o =
|
|
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 =
|
|
826
|
+
]), i = nn.create({
|
|
827
827
|
doc: n.value,
|
|
828
828
|
extensions: [
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
n.language ??
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
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
|
-
|
|
843
|
-
|
|
842
|
+
ja(n.placeholderText),
|
|
843
|
+
hs,
|
|
844
844
|
o,
|
|
845
|
-
|
|
845
|
+
Xn.of([...Za, ...Wa, ...Ya, Xa]),
|
|
846
846
|
...n.extensions,
|
|
847
|
-
|
|
847
|
+
a
|
|
848
848
|
]
|
|
849
849
|
});
|
|
850
|
-
return new $e({ state: i, parent:
|
|
850
|
+
return new $e({ state: i, parent: s });
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
return
|
|
854
|
-
async (
|
|
855
|
-
const o =
|
|
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
|
|
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),
|
|
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:
|
|
868
|
-
to:
|
|
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
|
|
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
|
-
],
|
|
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
|
|
964
|
-
const n =
|
|
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(
|
|
967
|
+
var CHECK_SOURCE = ${JSON.stringify(Ss.join(`
|
|
968
968
|
`))};
|
|
969
|
-
var SQL_SOURCE = ${JSON.stringify(
|
|
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
|
|
1228
|
-
class
|
|
1227
|
+
const yr = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
|
|
1228
|
+
class qs {
|
|
1229
1229
|
constructor(n = {}) {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
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
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
this.pyodideUrl = n.pyodideUrl ||
|
|
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,
|
|
1244
|
+
on(n, a) {
|
|
1245
1245
|
if (n === "status") {
|
|
1246
|
-
const i =
|
|
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 =
|
|
1250
|
+
const i = a;
|
|
1251
1251
|
return this.outputHandlers.add(i), () => this.outputHandlers.delete(i);
|
|
1252
1252
|
}
|
|
1253
|
-
const o =
|
|
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
|
|
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(
|
|
1265
|
-
},
|
|
1264
|
+
clearTimeout(_), p(), b();
|
|
1265
|
+
}, _ = setTimeout(() => {
|
|
1266
1266
|
E(), i(new Error("Pyodide 加载超时"));
|
|
1267
1267
|
}, n);
|
|
1268
|
-
p = this.on("status", (
|
|
1269
|
-
if (this.generation !==
|
|
1268
|
+
p = this.on("status", (O) => {
|
|
1269
|
+
if (this.generation !== a) {
|
|
1270
1270
|
E(), i(new Error("执行已被中断"));
|
|
1271
1271
|
return;
|
|
1272
1272
|
}
|
|
1273
|
-
|
|
1274
|
-
}), b = this.on("initError", (
|
|
1275
|
-
E(), i(new Error(
|
|
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,
|
|
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:
|
|
1286
|
-
|
|
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
|
|
1300
|
-
return
|
|
1301
|
-
line:
|
|
1302
|
-
column:
|
|
1303
|
-
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,
|
|
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:
|
|
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
|
|
1316
|
-
return { ok:
|
|
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
|
|
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:
|
|
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
|
|
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() -
|
|
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,
|
|
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
|
-
|
|
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((
|
|
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([
|
|
1380
|
-
return
|
|
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((
|
|
1388
|
+
this.setStatus("idle"), this.initErrorHandlers.forEach((a) => a(n.message));
|
|
1389
1389
|
break;
|
|
1390
1390
|
case "output": {
|
|
1391
|
-
const
|
|
1392
|
-
|
|
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
|
|
1397
|
-
|
|
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
|
|
1402
|
-
|
|
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
|
|
1412
|
-
|
|
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
|
|
1417
|
-
|
|
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
|
|
1422
|
-
|
|
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
|
|
1432
|
-
|
|
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
|
|
1442
|
-
|
|
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,
|
|
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:
|
|
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((
|
|
1461
|
+
this.status !== n && (this.status = n, this.statusHandlers.forEach((a) => a(n, this.version)));
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
|
-
let
|
|
1465
|
-
function
|
|
1466
|
-
return
|
|
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
|
-
) :
|
|
1468
|
+
) : Xt = new qs(s), Xt;
|
|
1469
1469
|
}
|
|
1470
|
-
const
|
|
1471
|
-
function
|
|
1472
|
-
const n = (
|
|
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
|
|
1478
|
-
var
|
|
1479
|
-
const i =
|
|
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
|
|
1483
|
-
...
|
|
1482
|
+
const N = await fetch(i + n, {
|
|
1483
|
+
...a,
|
|
1484
1484
|
headers: {
|
|
1485
1485
|
"Content-Type": "application/json",
|
|
1486
1486
|
...o.headers ?? {},
|
|
1487
|
-
...
|
|
1487
|
+
...a.headers ?? {}
|
|
1488
1488
|
},
|
|
1489
1489
|
signal: p.signal
|
|
1490
|
-
}), x = await
|
|
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 ${
|
|
1496
|
+
throw new Error(`文件服务返回的不是合法 JSON(HTTP ${N.status})`);
|
|
1497
1497
|
}
|
|
1498
|
-
if (!
|
|
1499
|
-
throw new Error(((
|
|
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), (
|
|
1502
|
+
clearTimeout(b), (O = o.signal) == null || O.removeEventListener("abort", E);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
function
|
|
1506
|
-
return
|
|
1505
|
+
function Os(s, n = {}) {
|
|
1506
|
+
return Ft(s, "", { method: "GET" }, n);
|
|
1507
1507
|
}
|
|
1508
|
-
function
|
|
1509
|
-
return
|
|
1510
|
-
|
|
1508
|
+
function Ms(s, n, a = {}) {
|
|
1509
|
+
return Ft(
|
|
1510
|
+
s,
|
|
1511
1511
|
"",
|
|
1512
1512
|
{ method: "POST", body: JSON.stringify(n) },
|
|
1513
|
-
|
|
1513
|
+
a
|
|
1514
1514
|
);
|
|
1515
1515
|
}
|
|
1516
|
-
function
|
|
1517
|
-
return
|
|
1518
|
-
|
|
1516
|
+
function Ts(s, n, a = {}) {
|
|
1517
|
+
return Ft(
|
|
1518
|
+
s,
|
|
1519
1519
|
`/${encodeURIComponent(n)}`,
|
|
1520
1520
|
{ method: "GET" },
|
|
1521
|
-
|
|
1521
|
+
a
|
|
1522
1522
|
);
|
|
1523
1523
|
}
|
|
1524
|
-
async function
|
|
1525
|
-
await
|
|
1524
|
+
async function Ns(s, n, a = {}) {
|
|
1525
|
+
await Ft(s, `/${encodeURIComponent(n)}`, { method: "DELETE" }, a);
|
|
1526
1526
|
}
|
|
1527
|
-
const
|
|
1528
|
-
function
|
|
1529
|
-
const n = (
|
|
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
|
|
1535
|
-
if (
|
|
1536
|
-
const
|
|
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
|
|
1539
|
-
message: typeof
|
|
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
|
|
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
|
|
1547
|
-
var
|
|
1548
|
-
const o =
|
|
1549
|
-
|
|
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
|
|
1551
|
+
const O = await fetch(`${o}/run`, {
|
|
1552
1552
|
method: "POST",
|
|
1553
1553
|
headers: {
|
|
1554
1554
|
"Content-Type": "application/json",
|
|
1555
|
-
...
|
|
1555
|
+
...a.headers ?? {}
|
|
1556
1556
|
},
|
|
1557
|
-
body: JSON.stringify({ code: n, stdin:
|
|
1557
|
+
body: JSON.stringify({ code: n, stdin: a.stdin ?? "" }),
|
|
1558
1558
|
signal: p.signal
|
|
1559
|
-
}),
|
|
1559
|
+
}), N = await O.text();
|
|
1560
1560
|
let x = null;
|
|
1561
|
-
if (
|
|
1561
|
+
if (N)
|
|
1562
1562
|
try {
|
|
1563
|
-
x = JSON.parse(
|
|
1563
|
+
x = JSON.parse(N);
|
|
1564
1564
|
} catch {
|
|
1565
|
-
throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${
|
|
1565
|
+
throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${O.status})`);
|
|
1566
1566
|
}
|
|
1567
1567
|
const F = performance.now() - i;
|
|
1568
|
-
if (!
|
|
1569
|
-
const
|
|
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 (
|
|
1577
|
-
message:
|
|
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 Vi(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),
|
|
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(
|
|
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 :
|
|
1596
|
+
error: q ? void 0 : hr(x.error, "服务端 Python 执行失败")
|
|
1597
1597
|
};
|
|
1598
1598
|
} finally {
|
|
1599
|
-
clearTimeout(b), (
|
|
1599
|
+
clearTimeout(b), (_ = a.signal) == null || _.removeEventListener("abort", E);
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
1603
|
-
return
|
|
1602
|
+
function $s(s) {
|
|
1603
|
+
return s === "waiting" || s === "running" || s === "exited" ? s : "exited";
|
|
1604
1604
|
}
|
|
1605
|
-
async function
|
|
1606
|
-
var
|
|
1607
|
-
const p =
|
|
1608
|
-
o.signal && (o.signal.aborted ? E.abort() : o.signal.addEventListener("abort",
|
|
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
|
-
...
|
|
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
|
|
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 (
|
|
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
|
|
1640
|
+
const me = Number(q.exitCode), M = Number(q.durationMs);
|
|
1641
1641
|
return {
|
|
1642
1642
|
sessionId: typeof q.sessionId == "string" ? q.sessionId : "",
|
|
1643
|
-
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(
|
|
1647
|
-
durationMs: Number.isFinite(
|
|
1648
|
-
error: q.error ?
|
|
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(
|
|
1651
|
+
clearTimeout(_), (N = o.signal) == null || N.removeEventListener("abort", O);
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
|
-
function
|
|
1655
|
-
return
|
|
1656
|
-
|
|
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:
|
|
1663
|
-
timeoutSeconds:
|
|
1662
|
+
stdin: a.stdin ?? "",
|
|
1663
|
+
timeoutSeconds: a.timeoutSeconds
|
|
1664
1664
|
})
|
|
1665
1665
|
},
|
|
1666
|
-
|
|
1666
|
+
a,
|
|
1667
1667
|
2e4
|
|
1668
1668
|
);
|
|
1669
1669
|
}
|
|
1670
|
-
function
|
|
1671
|
-
return
|
|
1672
|
-
|
|
1670
|
+
function _s(s, n, a = {}) {
|
|
1671
|
+
return dn(
|
|
1672
|
+
s,
|
|
1673
1673
|
`/sessions/${encodeURIComponent(n)}`,
|
|
1674
1674
|
{ method: "GET" },
|
|
1675
|
-
|
|
1675
|
+
a,
|
|
1676
1676
|
5e3
|
|
1677
1677
|
);
|
|
1678
1678
|
}
|
|
1679
|
-
function
|
|
1680
|
-
return
|
|
1681
|
-
|
|
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:
|
|
1683
|
+
{ method: "POST", body: JSON.stringify({ text: a }) },
|
|
1684
1684
|
o,
|
|
1685
1685
|
2e4
|
|
1686
1686
|
);
|
|
1687
1687
|
}
|
|
1688
|
-
async function
|
|
1689
|
-
const o =
|
|
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: { ...
|
|
1694
|
-
signal:
|
|
1693
|
+
headers: { ...a.headers ?? {} },
|
|
1694
|
+
signal: a.signal
|
|
1695
1695
|
});
|
|
1696
1696
|
} catch {
|
|
1697
1697
|
}
|
|
1698
1698
|
}
|
|
1699
|
-
const
|
|
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
|
-
],
|
|
1707
|
+
], tl = {
|
|
1708
1708
|
mode: "sqlite",
|
|
1709
1709
|
connection: { dialect: "sqlite", database: ":memory:" },
|
|
1710
1710
|
maxRows: 200,
|
|
1711
1711
|
timeoutMs: 3e4
|
|
1712
|
-
},
|
|
1713
|
-
function
|
|
1714
|
-
return
|
|
1712
|
+
}, br = 200, Lt = 3e4;
|
|
1713
|
+
function Is(s) {
|
|
1714
|
+
return dt.some((n) => n.value === s);
|
|
1715
1715
|
}
|
|
1716
|
-
function
|
|
1717
|
-
const i = typeof
|
|
1718
|
-
return Number.isFinite(i) ? Math.min(Math.max(Math.trunc(i),
|
|
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
|
|
1721
|
-
if (
|
|
1722
|
-
const n = Number(
|
|
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
|
|
1727
|
-
var p, b, E,
|
|
1728
|
-
const n =
|
|
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:
|
|
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 =
|
|
1735
|
-
port:
|
|
1736
|
-
user: ((
|
|
1737
|
-
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 =
|
|
1739
|
+
options: (x = s.connection) != null && x.options ? { ...s.connection.options } : void 0
|
|
1740
1740
|
},
|
|
1741
|
-
endpoint:
|
|
1742
|
-
headers:
|
|
1743
|
-
maxRows:
|
|
1744
|
-
timeoutMs:
|
|
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
|
|
1748
|
-
if (
|
|
1749
|
-
const n = typeof
|
|
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
|
|
1751
|
+
return s;
|
|
1752
1752
|
try {
|
|
1753
|
-
return JSON.stringify(
|
|
1753
|
+
return JSON.stringify(s);
|
|
1754
1754
|
} catch {
|
|
1755
|
-
return String(
|
|
1755
|
+
return String(s);
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
|
-
function
|
|
1759
|
-
const n =
|
|
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:
|
|
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
|
|
1768
|
-
if (
|
|
1769
|
-
const
|
|
1767
|
+
function pn(s, n) {
|
|
1768
|
+
if (s && typeof s == "object") {
|
|
1769
|
+
const a = s;
|
|
1770
1770
|
return {
|
|
1771
|
-
type: typeof
|
|
1772
|
-
message: typeof
|
|
1773
|
-
code: typeof
|
|
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
|
|
1776
|
+
return { type: "SqlError", message: typeof s == "string" && s ? s : n };
|
|
1777
1777
|
}
|
|
1778
|
-
function
|
|
1779
|
-
return
|
|
1778
|
+
function Bs(s) {
|
|
1779
|
+
return s instanceof DOMException && s.name === "AbortError" || s instanceof Error && s.name === "AbortError";
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1782
|
-
if (!
|
|
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
|
|
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:
|
|
1794
|
+
error: pn(a.error, "SQL 服务返回执行失败"),
|
|
1795
1795
|
durationMs: p
|
|
1796
1796
|
};
|
|
1797
1797
|
let b = [];
|
|
1798
|
-
return Array.isArray(
|
|
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(
|
|
1800
|
+
results: b.map(on),
|
|
1801
1801
|
durationMs: p
|
|
1802
1802
|
};
|
|
1803
1803
|
}
|
|
1804
|
-
async function
|
|
1805
|
-
const i = (
|
|
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
|
|
1818
|
+
const _ = setTimeout(() => {
|
|
1819
1819
|
E = !0, b.abort();
|
|
1820
|
-
},
|
|
1821
|
-
o && (o.aborted ? b.abort() : o.addEventListener("abort",
|
|
1820
|
+
}, s.timeoutMs ?? Lt), O = () => b.abort();
|
|
1821
|
+
o && (o.aborted ? b.abort() : o.addEventListener("abort", O));
|
|
1822
1822
|
try {
|
|
1823
|
-
const
|
|
1823
|
+
const N = await fetch(i, {
|
|
1824
1824
|
method: "POST",
|
|
1825
|
-
headers: { "Content-Type": "application/json", ...
|
|
1825
|
+
headers: { "Content-Type": "application/json", ...s.headers ?? {} },
|
|
1826
1826
|
body: JSON.stringify({
|
|
1827
|
-
connection:
|
|
1828
|
-
connectionId:
|
|
1827
|
+
connection: s.connection,
|
|
1828
|
+
connectionId: s.connectionId,
|
|
1829
1829
|
sql: n,
|
|
1830
|
-
maxRows:
|
|
1830
|
+
maxRows: a
|
|
1831
1831
|
}),
|
|
1832
1832
|
signal: b.signal
|
|
1833
|
-
}), x = await
|
|
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 ${
|
|
1844
|
+
message: `SQL 服务返回的不是合法 JSON(HTTP ${N.status})`
|
|
1845
1845
|
},
|
|
1846
1846
|
durationMs: performance.now() - p
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
|
-
if (!
|
|
1850
|
-
const q = F ?
|
|
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${
|
|
1856
|
-
message: `SQL 服务返回 HTTP ${
|
|
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
|
|
1862
|
-
} catch (
|
|
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 请求超时(${
|
|
1869
|
+
message: `SQL 请求超时(${s.timeoutMs ?? Lt}ms)`
|
|
1870
1870
|
},
|
|
1871
1871
|
durationMs: performance.now() - p
|
|
1872
1872
|
};
|
|
1873
|
-
throw
|
|
1873
|
+
throw N;
|
|
1874
1874
|
} finally {
|
|
1875
|
-
clearTimeout(
|
|
1875
|
+
clearTimeout(_), o == null || o.removeEventListener("abort", O);
|
|
1876
1876
|
}
|
|
1877
1877
|
}
|
|
1878
|
-
function
|
|
1879
|
-
if (!
|
|
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
|
|
1887
|
-
return
|
|
1886
|
+
const a = Number.isFinite(s.durationMs) && s.durationMs >= 0 ? s.durationMs : n;
|
|
1887
|
+
return s.ok ? {
|
|
1888
1888
|
ok: !0,
|
|
1889
|
-
results: (
|
|
1890
|
-
durationMs:
|
|
1889
|
+
results: (s.results ?? []).map(on),
|
|
1890
|
+
durationMs: a
|
|
1891
1891
|
} : {
|
|
1892
1892
|
ok: !1,
|
|
1893
|
-
results: (
|
|
1894
|
-
error:
|
|
1895
|
-
durationMs:
|
|
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
|
|
1899
|
-
const o =
|
|
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 gr(a, n, s = {}) {
|
|
|
1905
1905
|
durationMs: 0
|
|
1906
1906
|
};
|
|
1907
1907
|
try {
|
|
1908
|
-
if (
|
|
1909
|
-
const E = await
|
|
1908
|
+
if (a.executor) {
|
|
1909
|
+
const E = await a.executor(
|
|
1910
1910
|
{ sql: n, connection: o.connection, maxRows: i },
|
|
1911
|
-
{ signal:
|
|
1911
|
+
{ signal: a.signal }
|
|
1912
1912
|
);
|
|
1913
|
-
return
|
|
1913
|
+
return ir(E, performance.now() - p);
|
|
1914
1914
|
}
|
|
1915
1915
|
if (o.mode === "http")
|
|
1916
|
-
return await
|
|
1917
|
-
const b = await
|
|
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
|
|
1922
|
+
return ir(b, performance.now() - p);
|
|
1923
1923
|
} catch (b) {
|
|
1924
|
-
return
|
|
1924
|
+
return Bs(b) ? {
|
|
1925
1925
|
ok: !1,
|
|
1926
1926
|
results: [],
|
|
1927
1927
|
error: { type: "AbortError", message: "SQL 执行已中断" },
|
|
@@ -1929,42 +1929,42 @@ async function gr(a, n, s = {}) {
|
|
|
1929
1929
|
} : {
|
|
1930
1930
|
ok: !1,
|
|
1931
1931
|
results: [],
|
|
1932
|
-
error:
|
|
1932
|
+
error: pn(b, "SQL 执行失败"),
|
|
1933
1933
|
durationMs: performance.now() - p
|
|
1934
1934
|
};
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
|
-
function
|
|
1937
|
+
function lr(s) {
|
|
1938
1938
|
var n;
|
|
1939
|
-
return (n =
|
|
1939
|
+
return (n = dt.find((a) => a.value === s)) == null ? void 0 : n.defaultPort;
|
|
1940
1940
|
}
|
|
1941
|
-
async function
|
|
1941
|
+
async function As(s, n = {}) {
|
|
1942
1942
|
var o;
|
|
1943
|
-
const
|
|
1944
|
-
return
|
|
1943
|
+
const a = await kr(s, "SELECT 1", n);
|
|
1944
|
+
return a.ok ? {
|
|
1945
1945
|
ok: !0,
|
|
1946
|
-
message: `连接成功(${Math.max(1, Math.round(
|
|
1947
|
-
durationMs:
|
|
1946
|
+
message: `连接成功(${Math.max(1, Math.round(a.durationMs))}ms)`,
|
|
1947
|
+
durationMs: a.durationMs
|
|
1948
1948
|
} : {
|
|
1949
1949
|
ok: !1,
|
|
1950
|
-
message: ((o =
|
|
1951
|
-
durationMs:
|
|
1950
|
+
message: ((o = a.error) == null ? void 0 : o.message) ?? "连接失败",
|
|
1951
|
+
durationMs: a.durationMs
|
|
1952
1952
|
};
|
|
1953
1953
|
}
|
|
1954
|
-
async function
|
|
1955
|
-
var
|
|
1956
|
-
const i =
|
|
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 ??
|
|
1960
|
-
o.signal && (o.signal.aborted ? b.abort() : o.signal.addEventListener("abort",
|
|
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
|
-
...
|
|
1963
|
+
...a,
|
|
1964
1964
|
headers: {
|
|
1965
1965
|
"Content-Type": "application/json",
|
|
1966
1966
|
...i.headers ?? {},
|
|
1967
|
-
...
|
|
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(((
|
|
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), (
|
|
1982
|
+
clearTimeout(E), (N = o.signal) == null || N.removeEventListener("abort", _);
|
|
1983
1983
|
}
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1986
|
-
return
|
|
1985
|
+
function Ds(s, n = {}) {
|
|
1986
|
+
return fn(s, "/connections", { method: "GET" }, n);
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1989
|
-
return
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
{ method:
|
|
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
|
|
1997
|
-
await
|
|
1998
|
-
|
|
1996
|
+
async function ur(s, n, a = {}) {
|
|
1997
|
+
await fn(
|
|
1998
|
+
s,
|
|
1999
1999
|
`/connections/${encodeURIComponent(n)}`,
|
|
2000
2000
|
{ method: "DELETE" },
|
|
2001
|
-
|
|
2001
|
+
a
|
|
2002
2002
|
);
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
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
|
|
2011
|
-
return
|
|
2010
|
+
function Mt(s) {
|
|
2011
|
+
return $t.find((n) => n.value === s) ?? $t[0];
|
|
2012
2012
|
}
|
|
2013
|
-
function
|
|
2014
|
-
switch (
|
|
2013
|
+
function en(s) {
|
|
2014
|
+
switch (s) {
|
|
2015
2015
|
case "sql":
|
|
2016
|
-
return
|
|
2016
|
+
return os();
|
|
2017
2017
|
case "javascript":
|
|
2018
|
-
return
|
|
2018
|
+
return as();
|
|
2019
2019
|
case "json":
|
|
2020
|
-
return
|
|
2020
|
+
return ss();
|
|
2021
2021
|
case "python":
|
|
2022
2022
|
default:
|
|
2023
|
-
return
|
|
2023
|
+
return mr();
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const n =
|
|
2026
|
+
function cr(s) {
|
|
2027
|
+
const n = s.lastIndexOf(".");
|
|
2028
2028
|
if (n < 0) return "python";
|
|
2029
|
-
switch (
|
|
2029
|
+
switch (s.slice(n + 1).toLowerCase()) {
|
|
2030
2030
|
case "sql":
|
|
2031
2031
|
return "sql";
|
|
2032
2032
|
case "js":
|
|
@@ -2041,7 +2041,7 @@ function sr(a) {
|
|
|
2041
2041
|
return "python";
|
|
2042
2042
|
}
|
|
2043
2043
|
}
|
|
2044
|
-
const
|
|
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 ar = [
|
|
|
2051
2051
|
{ value: "solarized-light", label: "Solarized 浅色", dark: !1 },
|
|
2052
2052
|
{ value: "monokai", label: "Monokai", dark: !0 }
|
|
2053
2053
|
];
|
|
2054
|
-
function
|
|
2055
|
-
return
|
|
2054
|
+
function js(s) {
|
|
2055
|
+
return ln.find((n) => n.value === s) ?? ln[0];
|
|
2056
2056
|
}
|
|
2057
|
-
function
|
|
2058
|
-
return
|
|
2057
|
+
function ut(s) {
|
|
2058
|
+
return js(s).dark;
|
|
2059
2059
|
}
|
|
2060
|
-
function Z(
|
|
2061
|
-
const n = Array.isArray(
|
|
2062
|
-
return () =>
|
|
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,114 +2068,111 @@ function Z(a) {
|
|
|
2068
2068
|
fill: "currentColor",
|
|
2069
2069
|
"aria-hidden": "true"
|
|
2070
2070
|
},
|
|
2071
|
-
n.map((
|
|
2071
|
+
n.map((a) => Kn("path", { d: a }))
|
|
2072
2072
|
);
|
|
2073
2073
|
}
|
|
2074
|
-
const
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
),
|
|
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
|
-
]),
|
|
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
|
-
),
|
|
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
|
-
]),
|
|
2095
|
+
]), to = {
|
|
2096
2096
|
key: 0,
|
|
2097
2097
|
class: "vpe-toolbar"
|
|
2098
|
-
},
|
|
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
|
-
},
|
|
2101
|
+
}, fo = ["value"], vo = ["value"], mo = { class: "vpe-toolbar-end" }, go = ["disabled"], yo = {
|
|
2102
2102
|
value: "",
|
|
2103
2103
|
disabled: ""
|
|
2104
|
-
},
|
|
2105
|
-
key: 6,
|
|
2106
|
-
class: "vpe-runtime-group"
|
|
2107
|
-
}, fo = ["value", "disabled"], vo = ["value"], mo = ["aria-selected", "data-file-id", "title", "onClick", "onKeydown"], go = { class: "vpe-tab-name" }, yo = ["title", "aria-label", "disabled", "onClick"], ho = ["disabled"], bo = { class: "vpe-output-head" }, ko = { class: "vpe-output-main" }, wo = {
|
|
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 = {
|
|
2108
2105
|
key: 0,
|
|
2109
2106
|
class: "vpe-sql-results"
|
|
2110
|
-
},
|
|
2107
|
+
}, No = { class: "vpe-sql-result-head" }, Lo = {
|
|
2111
2108
|
key: 0,
|
|
2112
2109
|
class: "vpe-sql-table-wrap"
|
|
2113
|
-
},
|
|
2110
|
+
}, $o = { class: "vpe-sql-table" }, Fo = {
|
|
2114
2111
|
key: 0,
|
|
2115
2112
|
class: "vpe-sql-empty"
|
|
2116
|
-
},
|
|
2113
|
+
}, _o = {
|
|
2117
2114
|
key: 1,
|
|
2118
2115
|
class: "vpe-sql-affected"
|
|
2119
|
-
},
|
|
2116
|
+
}, Ro = {
|
|
2120
2117
|
key: 1,
|
|
2121
2118
|
class: "vpe-empty"
|
|
2122
|
-
},
|
|
2119
|
+
}, Io = {
|
|
2123
2120
|
key: 0,
|
|
2124
2121
|
class: "vpe-terminal-input"
|
|
2125
|
-
},
|
|
2122
|
+
}, Ho = ["onKeydown"], Bo = {
|
|
2126
2123
|
key: 4,
|
|
2127
2124
|
class: "vpe-fs-panel",
|
|
2128
2125
|
role: "dialog",
|
|
2129
2126
|
"aria-label": "虚拟文件"
|
|
2130
|
-
},
|
|
2127
|
+
}, Uo = { class: "vpe-fs-head" }, Ao = ["disabled"], Do = { class: "vpe-fs-body" }, zo = {
|
|
2131
2128
|
key: 0,
|
|
2132
2129
|
class: "vpe-fs-empty"
|
|
2133
|
-
},
|
|
2130
|
+
}, jo = {
|
|
2134
2131
|
key: 0,
|
|
2135
2132
|
class: "vpe-fs-empty"
|
|
2136
|
-
},
|
|
2133
|
+
}, Vo = ["title"], Qo = { class: "vpe-fs-size" }, Ko = ["title", "aria-label", "onClick"], Jo = {
|
|
2137
2134
|
key: 5,
|
|
2138
2135
|
class: "vpe-fs-panel",
|
|
2139
2136
|
role: "dialog",
|
|
2140
2137
|
"aria-label": "服务端文件"
|
|
2141
|
-
},
|
|
2138
|
+
}, Zo = { class: "vpe-fs-head" }, Go = ["disabled"], Wo = { class: "vpe-fs-body" }, Yo = {
|
|
2142
2139
|
key: 0,
|
|
2143
2140
|
class: "vpe-fs-empty"
|
|
2144
|
-
},
|
|
2141
|
+
}, Xo = {
|
|
2145
2142
|
key: 0,
|
|
2146
2143
|
class: "vpe-fs-empty"
|
|
2147
|
-
},
|
|
2144
|
+
}, ei = ["title"], ti = ["title"], ni = ["title", "disabled", "onClick"], ri = ["title", "disabled", "onClick"], ai = {
|
|
2148
2145
|
key: 1,
|
|
2149
2146
|
class: "vpe-sql-hint vpe-sql-hint--error"
|
|
2150
|
-
},
|
|
2147
|
+
}, si = {
|
|
2151
2148
|
key: 6,
|
|
2152
2149
|
class: "vpe-sql-panel",
|
|
2153
2150
|
role: "dialog",
|
|
2154
2151
|
"aria-label": "SQL 连接配置"
|
|
2155
|
-
},
|
|
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 = {
|
|
2156
2153
|
key: 0,
|
|
2157
2154
|
class: "vpe-sql-field"
|
|
2158
|
-
},
|
|
2155
|
+
}, xi = {
|
|
2159
2156
|
key: 1,
|
|
2160
2157
|
class: "vpe-sql-hint"
|
|
2161
|
-
},
|
|
2158
|
+
}, Ei = { class: "vpe-sql-actions" }, qi = ["disabled"], Ci = ["disabled"], Pi = ["disabled"], Oi = {
|
|
2162
2159
|
key: 3,
|
|
2163
2160
|
class: "vpe-sql-test vpe-sql-test--err"
|
|
2164
|
-
},
|
|
2161
|
+
}, Mi = {
|
|
2165
2162
|
key: 7,
|
|
2166
2163
|
class: "vpe-sql-manager-panel",
|
|
2167
2164
|
role: "dialog",
|
|
2168
2165
|
"aria-label": "连接管理"
|
|
2169
|
-
},
|
|
2166
|
+
}, Ti = { class: "vpe-fs-head" }, Ni = ["disabled"], Li = { class: "vpe-sql-manager-body" }, $i = {
|
|
2170
2167
|
key: 0,
|
|
2171
2168
|
class: "vpe-fs-empty"
|
|
2172
|
-
},
|
|
2169
|
+
}, Fi = {
|
|
2173
2170
|
key: 0,
|
|
2174
2171
|
class: "vpe-fs-empty"
|
|
2175
|
-
},
|
|
2172
|
+
}, _i = { class: "vpe-sql-manager-main" }, Ri = ["title"], Ii = { class: "vpe-sql-manager-meta" }, Hi = ["onClick"], Bi = ["disabled", "onClick"], Ui = {
|
|
2176
2173
|
key: 1,
|
|
2177
2174
|
class: "vpe-sql-hint vpe-sql-hint--error"
|
|
2178
|
-
},
|
|
2175
|
+
}, tn = 1, vr = 80, Ai = /* @__PURE__ */ $a({
|
|
2179
2176
|
__name: "PythonEditor",
|
|
2180
2177
|
props: {
|
|
2181
2178
|
modelValue: { default: "" },
|
|
@@ -2209,184 +2206,184 @@ const Da = Z(
|
|
|
2209
2206
|
pythonHeaders: { default: void 0 },
|
|
2210
2207
|
runtime: { default: "browser" }
|
|
2211
2208
|
},
|
|
2212
|
-
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"],
|
|
2213
|
-
setup(
|
|
2214
|
-
const o =
|
|
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(() => {
|
|
2215
2212
|
var e;
|
|
2216
|
-
return !!((e =
|
|
2213
|
+
return !!((e = Q.value) != null && e.busy);
|
|
2217
2214
|
}), Ae = U(() => {
|
|
2218
2215
|
var e;
|
|
2219
|
-
return !!((e =
|
|
2216
|
+
return !!((e = Q.value) != null && e.waiting);
|
|
2220
2217
|
}), H = U({
|
|
2221
2218
|
get: () => {
|
|
2222
2219
|
var e;
|
|
2223
|
-
return ((e =
|
|
2220
|
+
return ((e = Q.value) == null ? void 0 : e.input) ?? "";
|
|
2224
2221
|
},
|
|
2225
2222
|
set: (e) => {
|
|
2226
|
-
const t =
|
|
2223
|
+
const t = Q.value;
|
|
2227
2224
|
t && (t.input = e);
|
|
2228
2225
|
}
|
|
2229
|
-
}), k = C(null), I = C("idle"),
|
|
2230
|
-
let
|
|
2231
|
-
function
|
|
2232
|
-
return { id: ++
|
|
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 };
|
|
2233
2230
|
}
|
|
2234
|
-
const L = C([
|
|
2235
|
-
() => L.value.find((e) => e.id ===
|
|
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]
|
|
2236
2233
|
), Ie = U({
|
|
2237
2234
|
get: () => w.value.name,
|
|
2238
2235
|
set: (e) => {
|
|
2239
2236
|
const t = w.value;
|
|
2240
2237
|
t.name !== e && (t.name = e, i("update:fileName", e));
|
|
2241
2238
|
}
|
|
2242
|
-
}),
|
|
2239
|
+
}), gn = new qt(), Ht = new qt(), Bt = new qt(), Ut = new qt(), j = un(o.pyodideUrl ? { pyodideUrl: o.pyodideUrl } : void 0), Er = U(() => ({
|
|
2243
2240
|
height: typeof o.height == "number" ? `${o.height}px` : o.height
|
|
2244
|
-
})),
|
|
2245
|
-
`vpe-theme-${
|
|
2246
|
-
|
|
2241
|
+
})), qr = U(() => [
|
|
2242
|
+
`vpe-theme-${z.value}`,
|
|
2243
|
+
ut(z.value) ? "vpe-dark" : ""
|
|
2247
2244
|
]);
|
|
2248
|
-
let
|
|
2249
|
-
const
|
|
2245
|
+
let yn = 0, At = 0, Je = null;
|
|
2246
|
+
const Cr = U(
|
|
2250
2247
|
() => x.value !== null ? `${x.value}px` : typeof o.outputHeight == "number" ? `${o.outputHeight}px` : o.outputHeight
|
|
2251
|
-
),
|
|
2252
|
-
() =>
|
|
2253
|
-
), Oe = U(() => !!(o.filesEndpoint ?? "").trim()),
|
|
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 ? "就绪" : {
|
|
2254
2251
|
idle: "未加载",
|
|
2255
2252
|
loading: "正在加载 Pyodide…",
|
|
2256
2253
|
ready: "就绪",
|
|
2257
2254
|
running: "运行中"
|
|
2258
|
-
}[I.value]),
|
|
2259
|
-
function
|
|
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) {
|
|
2260
2257
|
return { ...e };
|
|
2261
2258
|
}
|
|
2262
|
-
function
|
|
2259
|
+
function fe(e = w.value.id) {
|
|
2263
2260
|
let t = q.get(e);
|
|
2264
2261
|
return t || (t = { lines: [], sqlResults: [] }, q.set(e, t)), t;
|
|
2265
2262
|
}
|
|
2266
2263
|
function ge(e, t, r) {
|
|
2267
|
-
|
|
2264
|
+
fe(r).lines.push({ id: ++wr, stream: e, text: t });
|
|
2268
2265
|
}
|
|
2269
2266
|
function h(e, t) {
|
|
2270
2267
|
ge("system", e, t);
|
|
2271
2268
|
}
|
|
2272
|
-
function
|
|
2273
|
-
return
|
|
2269
|
+
function Nr(e) {
|
|
2270
|
+
return $t.some((t) => t.value === e);
|
|
2274
2271
|
}
|
|
2275
|
-
function
|
|
2272
|
+
function Lr() {
|
|
2276
2273
|
if (!o.storageKey || typeof window > "u") return null;
|
|
2277
2274
|
try {
|
|
2278
2275
|
const e = window.localStorage.getItem(o.storageKey);
|
|
2279
2276
|
if (!e) return null;
|
|
2280
2277
|
const t = JSON.parse(e);
|
|
2281
|
-
if (t.version !==
|
|
2278
|
+
if (t.version !== tn || !Array.isArray(t.files)) return null;
|
|
2282
2279
|
const r = [];
|
|
2283
2280
|
for (const y of t.files) {
|
|
2284
2281
|
if (!y || typeof y.name != "string" || typeof y.code != "string" || !y.name.trim()) continue;
|
|
2285
|
-
const S =
|
|
2282
|
+
const S = Nr(y.language) ? y.language : "python";
|
|
2286
2283
|
r.push({ name: y.name, language: S, code: y.code });
|
|
2287
2284
|
}
|
|
2288
2285
|
if (!r.length) return null;
|
|
2289
2286
|
const u = typeof t.activeIndex == "number" ? t.activeIndex : 0, c = Math.min(Math.max(Math.trunc(u) || 0, 0), r.length - 1);
|
|
2290
|
-
return { version:
|
|
2287
|
+
return { version: tn, files: r, activeIndex: c };
|
|
2291
2288
|
} catch {
|
|
2292
2289
|
return null;
|
|
2293
2290
|
}
|
|
2294
2291
|
}
|
|
2295
|
-
function
|
|
2296
|
-
const e =
|
|
2292
|
+
function $r() {
|
|
2293
|
+
const e = Lr();
|
|
2297
2294
|
if (!e) return;
|
|
2298
|
-
L.value = e.files.map((r) =>
|
|
2295
|
+
L.value = e.files.map((r) => Ke(r.name, r.language, r.code));
|
|
2299
2296
|
const t = L.value[e.activeIndex] ?? L.value[0];
|
|
2300
|
-
|
|
2297
|
+
qe.value = t.id, h(`已恢复上次编辑内容(${L.value.length} 个文件)`), i("update:modelValue", t.code), i("update:fileName", t.name), i("update:language", t.language);
|
|
2301
2298
|
}
|
|
2302
|
-
function
|
|
2303
|
-
if (!(!
|
|
2299
|
+
function kn() {
|
|
2300
|
+
if (!(!_t || Rt || !o.storageKey || typeof window > "u"))
|
|
2304
2301
|
try {
|
|
2305
2302
|
const e = {
|
|
2306
|
-
version:
|
|
2303
|
+
version: tn,
|
|
2307
2304
|
files: L.value.map((t) => ({
|
|
2308
2305
|
name: t.name,
|
|
2309
2306
|
language: t.language,
|
|
2310
2307
|
code: t.code
|
|
2311
2308
|
})),
|
|
2312
2309
|
activeIndex: Math.max(
|
|
2313
|
-
L.value.findIndex((t) => t.id ===
|
|
2310
|
+
L.value.findIndex((t) => t.id === qe.value),
|
|
2314
2311
|
0
|
|
2315
2312
|
)
|
|
2316
2313
|
};
|
|
2317
2314
|
window.localStorage.setItem(o.storageKey, JSON.stringify(e));
|
|
2318
2315
|
} catch (e) {
|
|
2319
|
-
|
|
2316
|
+
vn || (vn = !0, h(`本地草稿保存失败:${e instanceof Error ? e.message : String(e)}`));
|
|
2320
2317
|
}
|
|
2321
2318
|
}
|
|
2322
|
-
function
|
|
2323
|
-
!
|
|
2319
|
+
function Fr() {
|
|
2320
|
+
!_t || !o.storageKey || typeof window > "u" || (Rt = !1, window.clearTimeout(gt), gt = window.setTimeout(kn, 400));
|
|
2324
2321
|
}
|
|
2325
|
-
function
|
|
2322
|
+
function _r() {
|
|
2326
2323
|
if (!(!o.storageKey || typeof window > "u")) {
|
|
2327
|
-
window.clearTimeout(
|
|
2324
|
+
window.clearTimeout(gt);
|
|
2328
2325
|
try {
|
|
2329
|
-
window.localStorage.removeItem(o.storageKey),
|
|
2326
|
+
window.localStorage.removeItem(o.storageKey), Rt = !0, h("已清除本地草稿");
|
|
2330
2327
|
} catch (e) {
|
|
2331
2328
|
h(`清除本地草稿失败:${e instanceof Error ? e.message : String(e)}`);
|
|
2332
2329
|
}
|
|
2333
2330
|
}
|
|
2334
2331
|
}
|
|
2335
2332
|
function Me(e) {
|
|
2336
|
-
if (!
|
|
2333
|
+
if (!P) return;
|
|
2337
2334
|
const t = e ? [e] : [];
|
|
2338
|
-
|
|
2335
|
+
P.dispatch({ effects: gr.of(t) });
|
|
2339
2336
|
}
|
|
2340
|
-
function
|
|
2337
|
+
function Rr() {
|
|
2341
2338
|
const e = o.modelValue;
|
|
2342
|
-
if (
|
|
2343
|
-
e !==
|
|
2339
|
+
if (P) {
|
|
2340
|
+
e !== P.state.doc.toString() && P.dispatch({ changes: { from: 0, to: P.state.doc.length, insert: e } });
|
|
2344
2341
|
return;
|
|
2345
2342
|
}
|
|
2346
2343
|
const t = w.value;
|
|
2347
2344
|
t.code !== e && (t.code = e);
|
|
2348
2345
|
}
|
|
2349
|
-
function
|
|
2350
|
-
return
|
|
2346
|
+
function Te() {
|
|
2347
|
+
return P ? P.state.doc.toString() : w.value.code;
|
|
2351
2348
|
}
|
|
2352
|
-
function
|
|
2353
|
-
if (
|
|
2354
|
-
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 } });
|
|
2355
2352
|
return;
|
|
2356
2353
|
}
|
|
2357
2354
|
const t = w.value;
|
|
2358
2355
|
t.code = e, e !== o.modelValue && i("update:modelValue", e);
|
|
2359
2356
|
}
|
|
2360
|
-
function
|
|
2361
|
-
return o.disableLint || e !== "python" ? [] :
|
|
2357
|
+
function zt(e) {
|
|
2358
|
+
return o.disableLint || e !== "python" ? [] : ws(j, o.lintDelay);
|
|
2362
2359
|
}
|
|
2363
|
-
function
|
|
2360
|
+
function jt(e) {
|
|
2364
2361
|
const t = w.value;
|
|
2365
2362
|
if (t.language !== e) {
|
|
2366
|
-
if (t.language = e,
|
|
2363
|
+
if (t.language = e, fe(t.id).sqlResults = [], Me(void 0), P == null || P.dispatch({
|
|
2367
2364
|
effects: [
|
|
2368
|
-
|
|
2369
|
-
|
|
2365
|
+
Bt.reconfigure(en(e)),
|
|
2366
|
+
Ut.reconfigure(zt(e))
|
|
2370
2367
|
]
|
|
2371
2368
|
}), /^untitled(-\d+)?\.[^.]+$/.test(t.name)) {
|
|
2372
|
-
const u = `${t.name.slice(0, t.name.lastIndexOf("."))}.${
|
|
2369
|
+
const u = `${t.name.slice(0, t.name.lastIndexOf("."))}.${Mt(e).extension}`;
|
|
2373
2370
|
L.value.some((c) => c.id !== t.id && c.name === u) || (t.name = u, i("update:fileName", u));
|
|
2374
2371
|
}
|
|
2375
2372
|
i("update:language", e);
|
|
2376
2373
|
}
|
|
2377
2374
|
}
|
|
2378
|
-
function
|
|
2375
|
+
function Vt(e, t) {
|
|
2379
2376
|
const u = e.trim().replace(/[\\/:*?"<>|]+/g, "_").replace(/\.+$/, "") || "untitled";
|
|
2380
|
-
return /\.[^.\\/]+$/.test(u) ? u : `${u}.${
|
|
2377
|
+
return /\.[^.\\/]+$/.test(u) ? u : `${u}.${Mt(t).extension}`;
|
|
2381
2378
|
}
|
|
2382
|
-
function
|
|
2383
|
-
const t =
|
|
2379
|
+
function wn(e) {
|
|
2380
|
+
const t = Mt(e).extension, r = new Set(L.value.map((y) => y.name));
|
|
2384
2381
|
let u = `untitled.${t}`, c = 2;
|
|
2385
2382
|
for (; r.has(u); )
|
|
2386
2383
|
u = `untitled-${c}.${t}`, c += 1;
|
|
2387
2384
|
return u;
|
|
2388
2385
|
}
|
|
2389
|
-
function
|
|
2386
|
+
function Sn(e) {
|
|
2390
2387
|
if (!L.value.some((S) => S.name === e)) return e;
|
|
2391
2388
|
const t = e.lastIndexOf("."), r = t > 0 ? e.slice(0, t) : e, u = t > 0 ? e.slice(t) : "";
|
|
2392
2389
|
let c = 2, y = `${r}-${c}${u}`;
|
|
@@ -2394,83 +2391,83 @@ const Da = Z(
|
|
|
2394
2391
|
c += 1, y = `${r}-${c}${u}`;
|
|
2395
2392
|
return y;
|
|
2396
2393
|
}
|
|
2397
|
-
let
|
|
2398
|
-
function
|
|
2394
|
+
let We = 0;
|
|
2395
|
+
function Ir(e) {
|
|
2399
2396
|
return !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
|
|
2400
2397
|
}
|
|
2401
|
-
async function
|
|
2398
|
+
async function Hr() {
|
|
2402
2399
|
var t;
|
|
2403
2400
|
if (!o.syncFilesOnRun) return;
|
|
2404
2401
|
const e = L.value.filter((r) => r.language === "python");
|
|
2405
2402
|
for (const r of e) {
|
|
2406
|
-
if (!
|
|
2403
|
+
if (!Ir(r.name)) {
|
|
2407
2404
|
h(`跳过同步文件:${r.name}(文件名不能包含路径分隔符)`);
|
|
2408
2405
|
continue;
|
|
2409
2406
|
}
|
|
2410
|
-
const u = await
|
|
2407
|
+
const u = await j.writeFile(r.name, r.code);
|
|
2411
2408
|
u.ok || h(`同步文件失败:${r.name}(${((t = u.error) == null ? void 0 : t.message) ?? "未知错误"})`);
|
|
2412
2409
|
}
|
|
2413
2410
|
}
|
|
2414
|
-
function
|
|
2415
|
-
Y == null || Y.abort(), Y = null,
|
|
2411
|
+
function at() {
|
|
2412
|
+
Y == null || Y.abort(), Y = null, _e.value = !1, nt.value = "", vt.value = !1;
|
|
2416
2413
|
}
|
|
2417
2414
|
function ye() {
|
|
2418
|
-
|
|
2419
|
-
const e =
|
|
2420
|
-
f.value = e, i("update:sqlConfig",
|
|
2415
|
+
at(), ae.value = "";
|
|
2416
|
+
const e = D(f.value);
|
|
2417
|
+
f.value = e, i("update:sqlConfig", D(e));
|
|
2421
2418
|
}
|
|
2422
|
-
function
|
|
2423
|
-
|
|
2419
|
+
function Br() {
|
|
2420
|
+
Re.value = !1, Fe.value = !0, ve();
|
|
2424
2421
|
}
|
|
2425
|
-
function
|
|
2426
|
-
f.value.mode !== "http" && (f.value =
|
|
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();
|
|
2427
2424
|
}
|
|
2428
|
-
function
|
|
2425
|
+
function Ar() {
|
|
2429
2426
|
const e = f.value.connection.dialect, t = e === "sqlite" ? "mysql" : e;
|
|
2430
|
-
f.value =
|
|
2427
|
+
f.value = D({
|
|
2431
2428
|
mode: "http",
|
|
2432
2429
|
endpoint: f.value.endpoint,
|
|
2433
2430
|
headers: f.value.headers,
|
|
2434
2431
|
maxRows: f.value.maxRows,
|
|
2435
2432
|
timeoutMs: f.value.timeoutMs,
|
|
2436
|
-
connection: { dialect: t, port:
|
|
2437
|
-
}),
|
|
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();
|
|
2438
2435
|
}
|
|
2439
|
-
function
|
|
2436
|
+
function xn() {
|
|
2440
2437
|
Fe.value = !1;
|
|
2441
2438
|
}
|
|
2442
|
-
function
|
|
2439
|
+
function Dr() {
|
|
2443
2440
|
const e = f.value;
|
|
2444
|
-
e.mode === "sqlite" ? (e.connectionId = void 0, e.connection.dialect = "sqlite", e.connection.database || (e.connection.database = ":memory:"),
|
|
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();
|
|
2445
2442
|
}
|
|
2446
|
-
function
|
|
2447
|
-
const e = f.value.connection, t =
|
|
2443
|
+
function zr() {
|
|
2444
|
+
const e = f.value.connection, t = dt.find((u) => u.value === e.dialect), r = dt.map((u) => u.defaultPort);
|
|
2448
2445
|
t != null && t.defaultPort && (!e.port || r.includes(e.port)) && (e.port = t.defaultPort), ye();
|
|
2449
2446
|
}
|
|
2450
|
-
async function
|
|
2451
|
-
const e =
|
|
2447
|
+
async function ve() {
|
|
2448
|
+
const e = D(f.value);
|
|
2452
2449
|
if (!e.endpoint) {
|
|
2453
2450
|
Ce.value = [], Pe.value = "";
|
|
2454
2451
|
return;
|
|
2455
2452
|
}
|
|
2456
|
-
|
|
2453
|
+
se == null || se.abort();
|
|
2457
2454
|
const t = new AbortController();
|
|
2458
|
-
|
|
2455
|
+
se = t, je.value = !0, Pe.value = "";
|
|
2459
2456
|
try {
|
|
2460
|
-
const r = await
|
|
2461
|
-
if (
|
|
2457
|
+
const r = await Ds(e, { signal: t.signal });
|
|
2458
|
+
if (se !== t) return;
|
|
2462
2459
|
Ce.value = r;
|
|
2463
2460
|
const u = r.find((c) => c.id === f.value.connectionId);
|
|
2464
|
-
u ?
|
|
2461
|
+
u ? ne.value = u.name : f.value.connectionId && (f.value.connectionId = void 0, ne.value = "");
|
|
2465
2462
|
} catch (r) {
|
|
2466
|
-
if (
|
|
2463
|
+
if (se !== t) return;
|
|
2467
2464
|
Ce.value = [], Pe.value = r instanceof Error ? r.message : String(r);
|
|
2468
2465
|
} finally {
|
|
2469
|
-
|
|
2466
|
+
se === t && (se = null, je.value = !1);
|
|
2470
2467
|
}
|
|
2471
2468
|
}
|
|
2472
|
-
function
|
|
2473
|
-
f.value =
|
|
2469
|
+
function En(e) {
|
|
2470
|
+
f.value = D({
|
|
2474
2471
|
mode: "http",
|
|
2475
2472
|
endpoint: f.value.endpoint,
|
|
2476
2473
|
headers: f.value.headers,
|
|
@@ -2486,28 +2483,28 @@ const Da = Z(
|
|
|
2486
2483
|
database: e.database ?? "",
|
|
2487
2484
|
options: e.options
|
|
2488
2485
|
}
|
|
2489
|
-
}),
|
|
2486
|
+
}), ne.value = e.name, ae.value = "", at(), i("update:sqlConfig", D(f.value));
|
|
2490
2487
|
}
|
|
2491
|
-
function
|
|
2492
|
-
Fe.value = !1,
|
|
2488
|
+
function jr() {
|
|
2489
|
+
Fe.value = !1, Re.value = !1;
|
|
2493
2490
|
const e = Ce.value.find((t) => t.id === f.value.connectionId);
|
|
2494
2491
|
if (!e) {
|
|
2495
|
-
f.value.connectionId = void 0, f.value.connection.password = "",
|
|
2492
|
+
f.value.connectionId = void 0, f.value.connection.password = "", ne.value = "", ye();
|
|
2496
2493
|
return;
|
|
2497
2494
|
}
|
|
2498
|
-
|
|
2495
|
+
En(e);
|
|
2499
2496
|
}
|
|
2500
|
-
function
|
|
2501
|
-
|
|
2497
|
+
function Vr(e) {
|
|
2498
|
+
En(e), Re.value = !1, Fe.value = !0;
|
|
2502
2499
|
}
|
|
2503
|
-
async function
|
|
2504
|
-
if (
|
|
2505
|
-
const e =
|
|
2500
|
+
async function Qr() {
|
|
2501
|
+
if (re.value) return;
|
|
2502
|
+
const e = ne.value.trim();
|
|
2506
2503
|
if (!e) {
|
|
2507
|
-
|
|
2504
|
+
Ve.value = !1, ae.value = "请先填写连接名称";
|
|
2508
2505
|
return;
|
|
2509
2506
|
}
|
|
2510
|
-
const t =
|
|
2507
|
+
const t = D(f.value), r = {
|
|
2511
2508
|
name: e,
|
|
2512
2509
|
dialect: t.connection.dialect,
|
|
2513
2510
|
host: t.connection.host,
|
|
@@ -2517,92 +2514,92 @@ const Da = Z(
|
|
|
2517
2514
|
database: t.connection.database,
|
|
2518
2515
|
options: t.connection.options
|
|
2519
2516
|
};
|
|
2520
|
-
|
|
2517
|
+
re.value = !0, ae.value = "";
|
|
2521
2518
|
try {
|
|
2522
|
-
const u = await
|
|
2523
|
-
f.value =
|
|
2519
|
+
const u = await zs(t, r, t.connectionId);
|
|
2520
|
+
f.value = D({
|
|
2524
2521
|
...t,
|
|
2525
2522
|
connectionId: u.id,
|
|
2526
2523
|
connection: { ...t.connection, password: "" }
|
|
2527
|
-
}),
|
|
2524
|
+
}), ne.value = u.name, Ve.value = !0, ae.value = "连接已保存", i("update:sqlConfig", D(f.value)), await ve();
|
|
2528
2525
|
} catch (u) {
|
|
2529
|
-
|
|
2526
|
+
Ve.value = !1, ae.value = u instanceof Error ? u.message : String(u);
|
|
2530
2527
|
} finally {
|
|
2531
|
-
|
|
2528
|
+
re.value = !1;
|
|
2532
2529
|
}
|
|
2533
2530
|
}
|
|
2534
|
-
async function
|
|
2531
|
+
async function Kr() {
|
|
2535
2532
|
const e = f.value.connectionId;
|
|
2536
|
-
if (!(!e ||
|
|
2537
|
-
|
|
2533
|
+
if (!(!e || re.value) && !(typeof window < "u" && !window.confirm("确定删除该连接配置?"))) {
|
|
2534
|
+
re.value = !0, ae.value = "";
|
|
2538
2535
|
try {
|
|
2539
|
-
await
|
|
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();
|
|
2540
2537
|
} catch (t) {
|
|
2541
|
-
|
|
2538
|
+
Ve.value = !1, ae.value = t instanceof Error ? t.message : String(t);
|
|
2542
2539
|
} finally {
|
|
2543
|
-
|
|
2540
|
+
re.value = !1;
|
|
2544
2541
|
}
|
|
2545
2542
|
}
|
|
2546
2543
|
}
|
|
2547
|
-
async function
|
|
2548
|
-
if (!
|
|
2549
|
-
|
|
2544
|
+
async function Jr(e) {
|
|
2545
|
+
if (!re.value && !(typeof window < "u" && !window.confirm(`确定删除连接“${e.name}”?`))) {
|
|
2546
|
+
re.value = !0, Qe.value = "";
|
|
2550
2547
|
try {
|
|
2551
|
-
await
|
|
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();
|
|
2552
2549
|
} catch (t) {
|
|
2553
|
-
|
|
2550
|
+
mt.value = !1, Qe.value = t instanceof Error ? t.message : String(t);
|
|
2554
2551
|
} finally {
|
|
2555
|
-
|
|
2552
|
+
re.value = !1;
|
|
2556
2553
|
}
|
|
2557
2554
|
}
|
|
2558
2555
|
}
|
|
2559
|
-
async function
|
|
2560
|
-
if (
|
|
2561
|
-
|
|
2556
|
+
async function Zr() {
|
|
2557
|
+
if (_e.value) return;
|
|
2558
|
+
at(), _e.value = !0;
|
|
2562
2559
|
const e = new AbortController();
|
|
2563
2560
|
Y = e;
|
|
2564
2561
|
try {
|
|
2565
|
-
const t = await
|
|
2562
|
+
const t = await As(D(f.value), {
|
|
2566
2563
|
executor: o.sqlExecutor,
|
|
2567
2564
|
signal: e.signal
|
|
2568
2565
|
});
|
|
2569
2566
|
if (Y !== e) return;
|
|
2570
|
-
|
|
2567
|
+
vt.value = t.ok, nt.value = t.message;
|
|
2571
2568
|
} catch (t) {
|
|
2572
2569
|
if (Y !== e) return;
|
|
2573
|
-
|
|
2570
|
+
vt.value = !1, nt.value = t instanceof Error ? t.message : String(t);
|
|
2574
2571
|
} finally {
|
|
2575
|
-
Y === e && (Y = null,
|
|
2572
|
+
Y === e && (Y = null, _e.value = !1);
|
|
2576
2573
|
}
|
|
2577
2574
|
}
|
|
2578
|
-
function
|
|
2575
|
+
function Gr(e) {
|
|
2579
2576
|
return e === null ? "NULL" : String(e);
|
|
2580
2577
|
}
|
|
2581
|
-
function
|
|
2578
|
+
function Wr(e) {
|
|
2582
2579
|
return e.columns.length ? `${e.rows.length} 行${e.truncated ? "(已截断)" : ""}` : `影响 ${e.affectedRows ?? 0} 行`;
|
|
2583
2580
|
}
|
|
2584
|
-
function
|
|
2581
|
+
function qn(e) {
|
|
2585
2582
|
if (e)
|
|
2586
2583
|
return { type: e.type, message: e.message, traceback: "" };
|
|
2587
2584
|
}
|
|
2588
|
-
async function
|
|
2589
|
-
if (
|
|
2585
|
+
async function Cn() {
|
|
2586
|
+
if (Ee.value)
|
|
2590
2587
|
return k.value !== w.value.id && h("另一个 SQL 正在执行,请等待或停止后再试"), null;
|
|
2591
|
-
const e =
|
|
2588
|
+
const e = Te();
|
|
2592
2589
|
if (!e.trim())
|
|
2593
2590
|
return h("SQL 内容为空,请输入要执行的语句"), null;
|
|
2594
|
-
const t =
|
|
2595
|
-
|
|
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(
|
|
2596
2593
|
`开始执行 SQL(${t.mode === "sqlite" ? "浏览器内 SQLite" : "HTTP 服务"})`,
|
|
2597
2594
|
u
|
|
2598
2595
|
), i("runStart");
|
|
2599
2596
|
try {
|
|
2600
|
-
const c = await
|
|
2597
|
+
const c = await kr(t, e, {
|
|
2601
2598
|
executor: o.sqlExecutor,
|
|
2602
|
-
signal:
|
|
2599
|
+
signal: de.signal
|
|
2603
2600
|
});
|
|
2604
|
-
if (r !==
|
|
2605
|
-
if (
|
|
2601
|
+
if (r !== rt) return null;
|
|
2602
|
+
if (fe(u).sqlResults = c.results ?? [], c.ok) {
|
|
2606
2603
|
const y = c.results ?? [], S = y.reduce(($, X) => $ + X.rows.length, 0);
|
|
2607
2604
|
h(
|
|
2608
2605
|
`SQL 执行完成:${y.length} 个结果集,共 ${S} 行,耗时 ${(c.durationMs / 1e3).toFixed(2)}s`,
|
|
@@ -2615,29 +2612,29 @@ const Da = Z(
|
|
|
2615
2612
|
return i("sqlResult", c), i("runFinish", {
|
|
2616
2613
|
ok: c.ok,
|
|
2617
2614
|
durationMs: c.durationMs,
|
|
2618
|
-
error: c.ok ? void 0 :
|
|
2615
|
+
error: c.ok ? void 0 : qn(c.error)
|
|
2619
2616
|
}), c;
|
|
2620
2617
|
} catch (c) {
|
|
2621
|
-
if (r !==
|
|
2618
|
+
if (r !== rt) return null;
|
|
2622
2619
|
const y = c instanceof Error ? c.message : String(c);
|
|
2623
2620
|
h(`SQL 执行失败:${y}`, u);
|
|
2624
2621
|
const S = { type: "SqlError", message: y };
|
|
2625
|
-
return i("sqlError", S), i("runFinish", { ok: !1, durationMs: 0, error:
|
|
2622
|
+
return i("sqlError", S), i("runFinish", { ok: !1, durationMs: 0, error: qn(S) }), null;
|
|
2626
2623
|
} finally {
|
|
2627
|
-
r ===
|
|
2624
|
+
r === rt && (Ee.value = !1, de = null, k.value === u && (k.value = null));
|
|
2628
2625
|
}
|
|
2629
2626
|
}
|
|
2630
|
-
async function
|
|
2631
|
-
return e !== void 0 && (
|
|
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();
|
|
2632
2629
|
}
|
|
2633
|
-
function
|
|
2630
|
+
function Xr(e) {
|
|
2634
2631
|
const t = e.target.value === "server" ? "server" : "browser";
|
|
2635
2632
|
if (t === "browser")
|
|
2636
|
-
for (const r of [...
|
|
2633
|
+
for (const r of [...M.keys()])
|
|
2637
2634
|
st(r, !1);
|
|
2638
|
-
|
|
2635
|
+
ce.value = t, i("update:runtime", t), h(t === "server" ? "已切换到服务端 Python 环境" : "已切换到浏览器 Python 环境");
|
|
2639
2636
|
}
|
|
2640
|
-
function
|
|
2637
|
+
function Pn(e, t, r, u) {
|
|
2641
2638
|
if (!u) return;
|
|
2642
2639
|
const c = u.replace(/\r\n/g, `
|
|
2643
2640
|
`);
|
|
@@ -2649,13 +2646,13 @@ const Da = Z(
|
|
|
2649
2646
|
for (const X of S)
|
|
2650
2647
|
ge(r, X, e), i("runOutput", { stream: r, text: X });
|
|
2651
2648
|
}
|
|
2652
|
-
function
|
|
2649
|
+
function On(e, t) {
|
|
2653
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 = "");
|
|
2654
2651
|
}
|
|
2655
|
-
function
|
|
2656
|
-
window.clearTimeout(t.pollTimer),
|
|
2657
|
-
const u =
|
|
2658
|
-
if (u && u.token === t.token &&
|
|
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) {
|
|
2659
2656
|
h(`执行出错:${r.error.type}`, e), e === w.value.id && Me(r.error.line);
|
|
2660
2657
|
const y = {
|
|
2661
2658
|
type: r.error.type,
|
|
@@ -2669,59 +2666,59 @@ const Da = Z(
|
|
|
2669
2666
|
const c = r.durationMs ?? 0;
|
|
2670
2667
|
h(`执行完成,会话时长 ${(c / 1e3).toFixed(2)}s`, e), i("runFinish", { ok: !0, durationMs: c });
|
|
2671
2668
|
}
|
|
2672
|
-
function
|
|
2673
|
-
const c =
|
|
2669
|
+
function Qt(e, t, r, u) {
|
|
2670
|
+
const c = M.get(e);
|
|
2674
2671
|
if (!(!c || c.token !== u)) {
|
|
2675
|
-
if (
|
|
2676
|
-
|
|
2672
|
+
if (Pn(e, t, "stdout", r.stdout), Pn(e, t, "stderr", r.stderr), r.state === "exited") {
|
|
2673
|
+
wt(e, t, r);
|
|
2677
2674
|
return;
|
|
2678
2675
|
}
|
|
2679
|
-
if (
|
|
2676
|
+
if (On(e, t), r.state === "waiting") {
|
|
2680
2677
|
t.waiting = !0;
|
|
2681
2678
|
return;
|
|
2682
2679
|
}
|
|
2683
|
-
t.waiting = !1,
|
|
2680
|
+
t.waiting = !1, ea(e, t, u);
|
|
2684
2681
|
}
|
|
2685
2682
|
}
|
|
2686
|
-
function
|
|
2683
|
+
function ea(e, t, r) {
|
|
2687
2684
|
window.clearTimeout(t.pollTimer), t.pollTimer = window.setTimeout(() => {
|
|
2688
|
-
|
|
2685
|
+
ta(e, r);
|
|
2689
2686
|
}, 250);
|
|
2690
2687
|
}
|
|
2691
|
-
async function
|
|
2688
|
+
async function ta(e, t) {
|
|
2692
2689
|
var u, c;
|
|
2693
|
-
const r =
|
|
2690
|
+
const r = M.get(e);
|
|
2694
2691
|
if (!(!r || r.token !== t || !r.sessionId))
|
|
2695
2692
|
try {
|
|
2696
|
-
const y = await
|
|
2693
|
+
const y = await _s(o.pythonEndpoint, r.sessionId, {
|
|
2697
2694
|
headers: o.pythonHeaders,
|
|
2698
2695
|
signal: (u = r.abort) == null ? void 0 : u.signal
|
|
2699
2696
|
});
|
|
2700
|
-
|
|
2697
|
+
Qt(e, r, y, t);
|
|
2701
2698
|
} catch (y) {
|
|
2702
|
-
if (((c =
|
|
2699
|
+
if (((c = M.get(e)) == null ? void 0 : c.token) !== t) return;
|
|
2703
2700
|
const S = y instanceof Error ? y.message : String(y);
|
|
2704
|
-
h(`执行失败:${S}`, e),
|
|
2701
|
+
h(`执行失败:${S}`, e), wt(e, r, {
|
|
2705
2702
|
sessionId: r.sessionId,
|
|
2706
2703
|
durationMs: 0,
|
|
2707
2704
|
error: { type: "RuntimeError", message: S }
|
|
2708
2705
|
});
|
|
2709
2706
|
}
|
|
2710
2707
|
}
|
|
2711
|
-
async function
|
|
2708
|
+
async function na() {
|
|
2712
2709
|
var y;
|
|
2713
2710
|
const e = w.value.id;
|
|
2714
|
-
if ((y =
|
|
2715
|
-
if (!
|
|
2711
|
+
if ((y = M.get(e)) != null && y.busy) return;
|
|
2712
|
+
if (!bt.value) {
|
|
2716
2713
|
h("未配置 Python 服务端点(pythonEndpoint)");
|
|
2717
2714
|
return;
|
|
2718
2715
|
}
|
|
2719
|
-
const t =
|
|
2716
|
+
const t = Te();
|
|
2720
2717
|
if (!t.trim()) {
|
|
2721
2718
|
h("代码为空,请输入要执行的 Python 代码");
|
|
2722
2719
|
return;
|
|
2723
2720
|
}
|
|
2724
|
-
const r = ++
|
|
2721
|
+
const r = ++xr, u = {
|
|
2725
2722
|
sessionId: "",
|
|
2726
2723
|
busy: !0,
|
|
2727
2724
|
waiting: !1,
|
|
@@ -2732,48 +2729,48 @@ const Da = Z(
|
|
|
2732
2729
|
stdoutBuffer: "",
|
|
2733
2730
|
stderrBuffer: ""
|
|
2734
2731
|
};
|
|
2735
|
-
|
|
2736
|
-
const c =
|
|
2737
|
-
Me(void 0), o.clearOutputOnRun && (
|
|
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");
|
|
2738
2735
|
try {
|
|
2739
|
-
const S = await
|
|
2736
|
+
const S = await Fs(o.pythonEndpoint, t, {
|
|
2740
2737
|
stdin: o.stdin,
|
|
2741
2738
|
headers: o.pythonHeaders,
|
|
2742
2739
|
signal: c.abort.signal
|
|
2743
|
-
}), $ =
|
|
2740
|
+
}), $ = M.get(e);
|
|
2744
2741
|
if (!$ || $.token !== r) {
|
|
2745
|
-
S.sessionId &&
|
|
2742
|
+
S.sessionId && rr(o.pythonEndpoint, S.sessionId, {
|
|
2746
2743
|
headers: o.pythonHeaders
|
|
2747
2744
|
});
|
|
2748
2745
|
return;
|
|
2749
2746
|
}
|
|
2750
|
-
$.sessionId = S.sessionId,
|
|
2747
|
+
$.sessionId = S.sessionId, Qt(e, $, S, r);
|
|
2751
2748
|
} catch (S) {
|
|
2752
|
-
const $ =
|
|
2749
|
+
const $ = M.get(e);
|
|
2753
2750
|
if (!$ || $.token !== r) return;
|
|
2754
2751
|
const X = S instanceof Error ? S.message : String(S);
|
|
2755
|
-
h(`执行失败:${X}`, e),
|
|
2752
|
+
h(`执行失败:${X}`, e), wt(e, $, {
|
|
2756
2753
|
durationMs: 0,
|
|
2757
2754
|
error: { type: "RuntimeError", message: X }
|
|
2758
2755
|
});
|
|
2759
2756
|
}
|
|
2760
2757
|
}
|
|
2761
|
-
async function
|
|
2758
|
+
async function Mn() {
|
|
2762
2759
|
var u, c;
|
|
2763
|
-
const e = w.value.id, t =
|
|
2760
|
+
const e = w.value.id, t = M.get(e);
|
|
2764
2761
|
if (!t || !t.waiting || !t.sessionId) return;
|
|
2765
2762
|
const r = t.input;
|
|
2766
2763
|
t.input = "", t.waiting = !1, ge("stdout", r, e), i("runOutput", { stream: "stdout", text: r });
|
|
2767
2764
|
try {
|
|
2768
|
-
const y = await
|
|
2765
|
+
const y = await Rs(o.pythonEndpoint, t.sessionId, r, {
|
|
2769
2766
|
headers: o.pythonHeaders,
|
|
2770
2767
|
signal: (u = t.abort) == null ? void 0 : u.signal
|
|
2771
2768
|
});
|
|
2772
|
-
|
|
2769
|
+
Qt(e, t, y, t.token);
|
|
2773
2770
|
} catch (y) {
|
|
2774
|
-
if (((c =
|
|
2771
|
+
if (((c = M.get(e)) == null ? void 0 : c.token) !== t.token) return;
|
|
2775
2772
|
const S = y instanceof Error ? y.message : String(y);
|
|
2776
|
-
h(`执行失败:${S}`, e),
|
|
2773
|
+
h(`执行失败:${S}`, e), wt(e, t, {
|
|
2777
2774
|
sessionId: t.sessionId,
|
|
2778
2775
|
durationMs: 0,
|
|
2779
2776
|
error: { type: "RuntimeError", message: S }
|
|
@@ -2782,19 +2779,19 @@ const Da = Z(
|
|
|
2782
2779
|
}
|
|
2783
2780
|
function st(e, t = !0) {
|
|
2784
2781
|
var u;
|
|
2785
|
-
const r =
|
|
2786
|
-
r && (window.clearTimeout(r.pollTimer),
|
|
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, {
|
|
2787
2784
|
headers: o.pythonHeaders
|
|
2788
2785
|
}), t && h("执行已中断", e));
|
|
2789
2786
|
}
|
|
2790
|
-
async function
|
|
2787
|
+
async function Tn() {
|
|
2791
2788
|
var c, y, S;
|
|
2792
2789
|
if (w.value.language === "sql") {
|
|
2793
|
-
await
|
|
2790
|
+
await Cn();
|
|
2794
2791
|
return;
|
|
2795
2792
|
}
|
|
2796
|
-
if (
|
|
2797
|
-
await
|
|
2793
|
+
if (Ze.value) {
|
|
2794
|
+
await na();
|
|
2798
2795
|
return;
|
|
2799
2796
|
}
|
|
2800
2797
|
if (I.value === "running") {
|
|
@@ -2806,41 +2803,41 @@ const Da = Z(
|
|
|
2806
2803
|
if (I.value === "loading") return;
|
|
2807
2804
|
const e = w.value.language;
|
|
2808
2805
|
if (e !== "python") {
|
|
2809
|
-
h(`当前文件为 ${
|
|
2806
|
+
h(`当前文件为 ${Mt(e).label},仅支持执行 Python / SQL 代码`);
|
|
2810
2807
|
return;
|
|
2811
2808
|
}
|
|
2812
|
-
|
|
2813
|
-
const t =
|
|
2814
|
-
k.value = r, Me(void 0), o.clearOutputOnRun && (
|
|
2815
|
-
const u =
|
|
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();
|
|
2816
2813
|
try {
|
|
2817
|
-
await
|
|
2818
|
-
const $ = await
|
|
2814
|
+
await Hr();
|
|
2815
|
+
const $ = await j.run(u, {
|
|
2819
2816
|
stdin: o.stdin,
|
|
2820
|
-
onOutput: (X,
|
|
2821
|
-
ge(X,
|
|
2817
|
+
onOutput: (X, it) => {
|
|
2818
|
+
ge(X, it, r), i("runOutput", { stream: X, text: it });
|
|
2822
2819
|
}
|
|
2823
2820
|
});
|
|
2824
|
-
if (t !==
|
|
2821
|
+
if (t !== We) return;
|
|
2825
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", $);
|
|
2826
2823
|
} catch ($) {
|
|
2827
|
-
if (t !==
|
|
2824
|
+
if (t !== We) return;
|
|
2828
2825
|
const X = $ instanceof Error ? $.message : String($);
|
|
2829
2826
|
h(`执行失败:${X}`, r);
|
|
2830
|
-
const
|
|
2831
|
-
i("runError",
|
|
2827
|
+
const it = { type: "RuntimeError", message: X, traceback: "" };
|
|
2828
|
+
i("runError", it), i("runFinish", { ok: !1, durationMs: 0, error: it });
|
|
2832
2829
|
} finally {
|
|
2833
|
-
t ===
|
|
2830
|
+
t === We && k.value === r && (k.value = null);
|
|
2834
2831
|
}
|
|
2835
2832
|
}
|
|
2836
|
-
async function
|
|
2833
|
+
async function ra() {
|
|
2837
2834
|
var t;
|
|
2838
|
-
if (
|
|
2835
|
+
if (mn) return;
|
|
2839
2836
|
const e = o.preloadPackages;
|
|
2840
2837
|
if (e.length) {
|
|
2841
|
-
|
|
2838
|
+
mn = !0, h(`正在安装预置包:${e.join(", ")}`);
|
|
2842
2839
|
try {
|
|
2843
|
-
const r = await
|
|
2840
|
+
const r = await j.loadPackages(e, {
|
|
2844
2841
|
onOutput: (u, c) => ge(u, c)
|
|
2845
2842
|
});
|
|
2846
2843
|
h(
|
|
@@ -2851,28 +2848,29 @@ const Da = Z(
|
|
|
2851
2848
|
}
|
|
2852
2849
|
}
|
|
2853
2850
|
}
|
|
2854
|
-
|
|
2851
|
+
Fa(() => {
|
|
2855
2852
|
const e = b.value;
|
|
2856
2853
|
if (!e) return;
|
|
2857
|
-
|
|
2854
|
+
$r(), _t = !0;
|
|
2858
2855
|
const t = [
|
|
2859
|
-
|
|
2860
|
-
|
|
2856
|
+
gn.of([
|
|
2857
|
+
nn.readOnly.of(o.readOnly),
|
|
2861
2858
|
$e.editable.of(!o.readOnly)
|
|
2862
2859
|
]),
|
|
2863
|
-
|
|
2860
|
+
Ut.of(zt(w.value.language)),
|
|
2861
|
+
Ht.of(Tt(ut(z.value)))
|
|
2864
2862
|
];
|
|
2865
2863
|
try {
|
|
2866
|
-
|
|
2864
|
+
P = ks(e, {
|
|
2867
2865
|
value: w.value.code,
|
|
2868
|
-
dark:
|
|
2866
|
+
dark: ut(z.value),
|
|
2869
2867
|
placeholderText: o.placeholder,
|
|
2870
|
-
language:
|
|
2868
|
+
language: Bt.of(en(w.value.language)),
|
|
2871
2869
|
extensions: t,
|
|
2872
2870
|
onDocChange: (r) => {
|
|
2873
2871
|
w.value.code = r, r !== o.modelValue && i("update:modelValue", r);
|
|
2874
2872
|
},
|
|
2875
|
-
onRunShortcut:
|
|
2873
|
+
onRunShortcut: Tn
|
|
2876
2874
|
});
|
|
2877
2875
|
} catch (r) {
|
|
2878
2876
|
const u = r instanceof Error ? r.message : String(r);
|
|
@@ -2881,202 +2879,209 @@ const Da = Z(
|
|
|
2881
2879
|
c.className = "vpe-init-error", c.textContent = `编辑器初始化失败:${u}`, e.appendChild(c);
|
|
2882
2880
|
return;
|
|
2883
2881
|
}
|
|
2884
|
-
o.autofocus &&
|
|
2885
|
-
I.value = r, r === "ready" && (u && h(`Pyodide ${u} 就绪`), i("ready"),
|
|
2886
|
-
}),
|
|
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) => {
|
|
2887
2885
|
h(`Pyodide 加载失败:${r}`), i("loadError", r);
|
|
2888
|
-
}), I.value =
|
|
2889
|
-
x.value !== null &&
|
|
2890
|
-
}),
|
|
2891
|
-
}),
|
|
2892
|
-
|
|
2893
|
-
for (const e of [...
|
|
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()])
|
|
2894
2892
|
st(e, !1);
|
|
2895
|
-
window.clearTimeout(
|
|
2896
|
-
}),
|
|
2893
|
+
window.clearTimeout(It), window.clearTimeout(gt), kn(), P == null || P.destroy(), P = null;
|
|
2894
|
+
}), ee(
|
|
2897
2895
|
() => o.modelValue,
|
|
2898
|
-
() =>
|
|
2899
|
-
),
|
|
2896
|
+
() => Rr()
|
|
2897
|
+
), ee(
|
|
2900
2898
|
() => o.outputHeight,
|
|
2901
2899
|
() => {
|
|
2902
2900
|
x.value = null;
|
|
2903
2901
|
}
|
|
2904
|
-
),
|
|
2902
|
+
), ee(
|
|
2905
2903
|
() => o.fileName,
|
|
2906
2904
|
(e) => {
|
|
2907
2905
|
e && e !== w.value.name && (Ie.value = e);
|
|
2908
2906
|
}
|
|
2909
|
-
),
|
|
2907
|
+
), ee(
|
|
2910
2908
|
() => o.language,
|
|
2911
2909
|
(e) => {
|
|
2912
|
-
e !== w.value.language &&
|
|
2910
|
+
e !== w.value.language && jt(e);
|
|
2913
2911
|
}
|
|
2914
|
-
),
|
|
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
|
+
}));
|
|
2918
|
+
}
|
|
2919
|
+
), ee(
|
|
2915
2920
|
() => o.runtime,
|
|
2916
2921
|
(e) => {
|
|
2917
|
-
e !==
|
|
2922
|
+
e !== ce.value && (ce.value = e);
|
|
2918
2923
|
}
|
|
2919
|
-
),
|
|
2924
|
+
), ee(
|
|
2920
2925
|
() => o.pythonEndpoint,
|
|
2921
2926
|
() => {
|
|
2922
|
-
if (!
|
|
2923
|
-
for (const e of [...
|
|
2927
|
+
if (!bt.value) {
|
|
2928
|
+
for (const e of [...M.keys()])
|
|
2924
2929
|
st(e, !1);
|
|
2925
|
-
|
|
2930
|
+
ce.value !== "browser" && (ce.value = "browser", i("update:runtime", "browser"));
|
|
2926
2931
|
}
|
|
2927
2932
|
}
|
|
2928
|
-
),
|
|
2933
|
+
), ee(
|
|
2929
2934
|
() => o.filesEndpoint,
|
|
2930
2935
|
() => {
|
|
2931
2936
|
if (!Oe.value) {
|
|
2932
|
-
|
|
2937
|
+
xe.value = !1, tt.value = [], ze.value = "";
|
|
2933
2938
|
return;
|
|
2934
2939
|
}
|
|
2935
|
-
|
|
2940
|
+
xe.value && Ye();
|
|
2936
2941
|
}
|
|
2937
|
-
),
|
|
2942
|
+
), ee(
|
|
2938
2943
|
() => o.readOnly,
|
|
2939
2944
|
(e) => {
|
|
2940
|
-
|
|
2941
|
-
effects:
|
|
2945
|
+
P == null || P.dispatch({
|
|
2946
|
+
effects: gn.reconfigure([nn.readOnly.of(e), $e.editable.of(!e)])
|
|
2942
2947
|
});
|
|
2943
2948
|
}
|
|
2944
|
-
),
|
|
2949
|
+
), ee(
|
|
2945
2950
|
() => o.sqlConfig,
|
|
2946
2951
|
(e) => {
|
|
2947
2952
|
if (!e) return;
|
|
2948
|
-
const t =
|
|
2949
|
-
JSON.stringify(t) !== JSON.stringify(f.value) && (f.value = t),
|
|
2953
|
+
const t = D(e);
|
|
2954
|
+
JSON.stringify(t) !== JSON.stringify(f.value) && (f.value = t), pe.value && ve();
|
|
2950
2955
|
},
|
|
2951
2956
|
{ deep: !0 }
|
|
2952
|
-
),
|
|
2953
|
-
e &&
|
|
2954
|
-
}),
|
|
2957
|
+
), ee(pe, (e) => {
|
|
2958
|
+
e && ve();
|
|
2959
|
+
}), ee(
|
|
2955
2960
|
() => G.value.length,
|
|
2956
2961
|
async () => {
|
|
2957
|
-
await
|
|
2958
|
-
const e =
|
|
2962
|
+
await Zn();
|
|
2963
|
+
const e = _.value;
|
|
2959
2964
|
e && (e.scrollTop = e.scrollHeight);
|
|
2960
2965
|
}
|
|
2961
|
-
),
|
|
2962
|
-
function
|
|
2963
|
-
|
|
2966
|
+
), ee([L, qe], () => Fr(), { deep: !0 });
|
|
2967
|
+
function Nn() {
|
|
2968
|
+
Tn();
|
|
2964
2969
|
}
|
|
2965
|
-
function
|
|
2970
|
+
function Ln() {
|
|
2966
2971
|
var t;
|
|
2967
2972
|
const e = w.value.id;
|
|
2968
|
-
if (
|
|
2969
|
-
|
|
2973
|
+
if (_e.value) {
|
|
2974
|
+
at(), !o.sqlExecutor && f.value.mode === "sqlite" && j.interrupt(), h("已取消连接测试");
|
|
2970
2975
|
return;
|
|
2971
2976
|
}
|
|
2972
|
-
if ((t =
|
|
2977
|
+
if ((t = M.get(e)) != null && t.busy) {
|
|
2973
2978
|
st(e);
|
|
2974
2979
|
return;
|
|
2975
2980
|
}
|
|
2976
|
-
if (
|
|
2977
|
-
|
|
2981
|
+
if (Ee.value && k.value === e) {
|
|
2982
|
+
$n();
|
|
2978
2983
|
return;
|
|
2979
2984
|
}
|
|
2980
|
-
I.value === "running" && k.value === e &&
|
|
2985
|
+
I.value === "running" && k.value === e && Fn();
|
|
2981
2986
|
}
|
|
2982
|
-
function
|
|
2987
|
+
function $n(e = !0) {
|
|
2983
2988
|
const t = k.value;
|
|
2984
|
-
|
|
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);
|
|
2985
2990
|
}
|
|
2986
|
-
function
|
|
2991
|
+
function Fn(e = !0) {
|
|
2987
2992
|
const t = k.value;
|
|
2988
|
-
|
|
2993
|
+
We += 1, k.value = null, j.interrupt(), e && h("执行已中断", t ?? void 0);
|
|
2989
2994
|
}
|
|
2990
|
-
function
|
|
2991
|
-
|
|
2995
|
+
function _n() {
|
|
2996
|
+
fe().lines = [], fe().sqlResults = [];
|
|
2992
2997
|
}
|
|
2993
|
-
function
|
|
2998
|
+
function Rn() {
|
|
2994
2999
|
var e;
|
|
2995
3000
|
return ((e = E.value) == null ? void 0 : e.getBoundingClientRect().height) ?? 180;
|
|
2996
3001
|
}
|
|
2997
|
-
function
|
|
3002
|
+
function aa() {
|
|
2998
3003
|
var t;
|
|
2999
3004
|
const e = ((t = p.value) == null ? void 0 : t.clientHeight) ?? 0;
|
|
3000
|
-
return Math.max(
|
|
3005
|
+
return Math.max(vr, e ? e - 180 : 600);
|
|
3001
3006
|
}
|
|
3002
|
-
function
|
|
3003
|
-
x.value = Math.round(Math.max(
|
|
3007
|
+
function Kt(e) {
|
|
3008
|
+
x.value = Math.round(Math.max(vr, Math.min(e, aa())));
|
|
3004
3009
|
}
|
|
3005
|
-
function
|
|
3006
|
-
e.button === 0 && (e.preventDefault(), F.value = !0,
|
|
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));
|
|
3007
3012
|
}
|
|
3008
|
-
function
|
|
3009
|
-
F.value &&
|
|
3013
|
+
function In(e) {
|
|
3014
|
+
F.value && Kt(At + (yn - e.clientY));
|
|
3010
3015
|
}
|
|
3011
|
-
function
|
|
3012
|
-
F.value && (F.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove",
|
|
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));
|
|
3013
3018
|
}
|
|
3014
|
-
function
|
|
3019
|
+
function oa() {
|
|
3015
3020
|
x.value = null;
|
|
3016
3021
|
}
|
|
3017
|
-
function
|
|
3022
|
+
function ia(e) {
|
|
3018
3023
|
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
3019
3024
|
e.preventDefault();
|
|
3020
|
-
const t = x.value ??
|
|
3021
|
-
|
|
3025
|
+
const t = x.value ?? Rn();
|
|
3026
|
+
Kt(t + (e.key === "ArrowUp" ? 16 : -16));
|
|
3022
3027
|
}
|
|
3023
|
-
function
|
|
3028
|
+
function Jt() {
|
|
3024
3029
|
if (o.readOnly) return;
|
|
3025
|
-
const e = w.value.language, t =
|
|
3026
|
-
L.value.push(t), He(t.id), i("newFile",
|
|
3030
|
+
const e = w.value.language, t = Ke(wn(e), e, "");
|
|
3031
|
+
L.value.push(t), He(t.id), i("newFile", Ge(t));
|
|
3027
3032
|
}
|
|
3028
3033
|
function He(e) {
|
|
3029
|
-
if (e ===
|
|
3030
|
-
|
|
3034
|
+
if (e === qe.value) {
|
|
3035
|
+
xt();
|
|
3031
3036
|
return;
|
|
3032
3037
|
}
|
|
3033
3038
|
const t = L.value.find((r) => r.id === e);
|
|
3034
|
-
t && (
|
|
3039
|
+
t && (qe.value = e, Zt(t));
|
|
3035
3040
|
}
|
|
3036
|
-
function
|
|
3037
|
-
st(e, !1),
|
|
3041
|
+
function la(e) {
|
|
3042
|
+
st(e, !1), Ee.value && k.value === e && $n(!1), I.value === "running" && k.value === e && Fn(!1);
|
|
3038
3043
|
}
|
|
3039
|
-
function
|
|
3044
|
+
function Hn(e) {
|
|
3040
3045
|
if (o.readOnly) return;
|
|
3041
3046
|
const t = L.value.findIndex((c) => c.id === e);
|
|
3042
3047
|
if (t === -1) return;
|
|
3043
|
-
|
|
3048
|
+
la(e);
|
|
3044
3049
|
const r = L.value.splice(t, 1)[0];
|
|
3045
3050
|
if (!r) return;
|
|
3046
|
-
if (q.delete(e), i("fileClose",
|
|
3047
|
-
const c =
|
|
3048
|
-
L.value.push(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));
|
|
3049
3054
|
return;
|
|
3050
3055
|
}
|
|
3051
|
-
if (e !==
|
|
3056
|
+
if (e !== qe.value) return;
|
|
3052
3057
|
const u = L.value[Math.min(t, L.value.length - 1)];
|
|
3053
|
-
u && (
|
|
3058
|
+
u && (qe.value = u.id, Zt(u));
|
|
3054
3059
|
}
|
|
3055
|
-
function
|
|
3056
|
-
Me(void 0),
|
|
3060
|
+
function Zt(e) {
|
|
3061
|
+
Me(void 0), kt(e.code), P == null || P.dispatch({
|
|
3057
3062
|
effects: [
|
|
3058
|
-
|
|
3059
|
-
|
|
3063
|
+
Bt.reconfigure(en(e.language)),
|
|
3064
|
+
Ut.reconfigure(zt(e.language))
|
|
3060
3065
|
]
|
|
3061
|
-
}), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch",
|
|
3066
|
+
}), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch", Ge(e)), xt();
|
|
3062
3067
|
}
|
|
3063
|
-
function
|
|
3064
|
-
o.readOnly || (Me(void 0),
|
|
3068
|
+
function Bn() {
|
|
3069
|
+
o.readOnly || (Me(void 0), kt(""), xt());
|
|
3065
3070
|
}
|
|
3066
|
-
async function
|
|
3071
|
+
async function Un() {
|
|
3067
3072
|
var r;
|
|
3068
|
-
const e =
|
|
3073
|
+
const e = Te();
|
|
3069
3074
|
let t = !1;
|
|
3070
3075
|
try {
|
|
3071
3076
|
(r = navigator.clipboard) != null && r.writeText && (await navigator.clipboard.writeText(e), t = !0);
|
|
3072
3077
|
} catch {
|
|
3073
3078
|
t = !1;
|
|
3074
3079
|
}
|
|
3075
|
-
return t || (t =
|
|
3076
|
-
|
|
3080
|
+
return t || (t = ua(e)), t ? (Se.value = !0, window.clearTimeout(It), It = window.setTimeout(() => {
|
|
3081
|
+
Se.value = !1;
|
|
3077
3082
|
}, 1600), i("copy", e), !0) : (h("复制失败,请手动选择代码复制"), !1);
|
|
3078
3083
|
}
|
|
3079
|
-
function
|
|
3084
|
+
function ua(e) {
|
|
3080
3085
|
const t = document.createElement("textarea");
|
|
3081
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);
|
|
3082
3087
|
let r = !1;
|
|
@@ -3087,36 +3092,36 @@ const Da = Z(
|
|
|
3087
3092
|
}
|
|
3088
3093
|
return t.remove(), r;
|
|
3089
3094
|
}
|
|
3090
|
-
function
|
|
3091
|
-
const e = w.value, t =
|
|
3095
|
+
function An() {
|
|
3096
|
+
const e = w.value, t = Vt(e.name, e.language);
|
|
3092
3097
|
Ie.value = t;
|
|
3093
|
-
const r = new Blob([
|
|
3098
|
+
const r = new Blob([Te()], {
|
|
3094
3099
|
type: e.language === "python" ? "text/x-python;charset=utf-8" : "text/plain;charset=utf-8"
|
|
3095
3100
|
}), u = URL.createObjectURL(r), c = document.createElement("a");
|
|
3096
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;
|
|
3097
3102
|
}
|
|
3098
|
-
function
|
|
3099
|
-
|
|
3103
|
+
function ca() {
|
|
3104
|
+
De.value = !De.value, De.value && (xe.value = !1, Dn());
|
|
3100
3105
|
}
|
|
3101
|
-
async function
|
|
3106
|
+
async function Dn() {
|
|
3102
3107
|
var e;
|
|
3103
|
-
if (!
|
|
3104
|
-
|
|
3108
|
+
if (!Xe.value) {
|
|
3109
|
+
Xe.value = !0;
|
|
3105
3110
|
try {
|
|
3106
|
-
const t = await
|
|
3111
|
+
const t = await j.listFiles(".");
|
|
3107
3112
|
if (!t.ok) {
|
|
3108
|
-
|
|
3113
|
+
et.value = [], h(`读取虚拟文件失败:${((e = t.error) == null ? void 0 : e.message) ?? "未知错误"}`);
|
|
3109
3114
|
return;
|
|
3110
3115
|
}
|
|
3111
|
-
|
|
3116
|
+
et.value = t.entries ?? [];
|
|
3112
3117
|
} catch (t) {
|
|
3113
|
-
|
|
3118
|
+
et.value = [], h(`读取虚拟文件失败:${t instanceof Error ? t.message : String(t)}`);
|
|
3114
3119
|
} finally {
|
|
3115
|
-
|
|
3120
|
+
Xe.value = !1;
|
|
3116
3121
|
}
|
|
3117
3122
|
}
|
|
3118
3123
|
}
|
|
3119
|
-
function
|
|
3124
|
+
function da(e) {
|
|
3120
3125
|
switch (e.slice(e.lastIndexOf(".") + 1).toLowerCase()) {
|
|
3121
3126
|
case "csv":
|
|
3122
3127
|
return "text/csv";
|
|
@@ -3133,112 +3138,112 @@ const Da = Z(
|
|
|
3133
3138
|
return "text/plain";
|
|
3134
3139
|
}
|
|
3135
3140
|
}
|
|
3136
|
-
function
|
|
3141
|
+
function Gt(e) {
|
|
3137
3142
|
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
3138
3143
|
}
|
|
3139
|
-
async function
|
|
3144
|
+
async function zn(e) {
|
|
3140
3145
|
var t;
|
|
3141
3146
|
try {
|
|
3142
|
-
const r = await
|
|
3147
|
+
const r = await j.readFile(e);
|
|
3143
3148
|
if (!r.ok || r.content === void 0)
|
|
3144
3149
|
return h(`下载失败:${e}(${((t = r.error) == null ? void 0 : t.message) ?? "未知错误"})`), null;
|
|
3145
3150
|
const u = e.slice(e.lastIndexOf("/") + 1) || "download.txt", c = new Blob([r.content], {
|
|
3146
|
-
type: `${
|
|
3151
|
+
type: `${da(u)};charset=utf-8`
|
|
3147
3152
|
}), y = URL.createObjectURL(c), S = document.createElement("a");
|
|
3148
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;
|
|
3149
3154
|
} catch (r) {
|
|
3150
3155
|
return h(`下载失败:${r instanceof Error ? r.message : String(r)}`), null;
|
|
3151
3156
|
}
|
|
3152
3157
|
}
|
|
3153
|
-
function
|
|
3154
|
-
return
|
|
3158
|
+
function pa(e, t) {
|
|
3159
|
+
return j.writeFile(e, t);
|
|
3155
3160
|
}
|
|
3156
|
-
function
|
|
3157
|
-
return
|
|
3161
|
+
function fa(e) {
|
|
3162
|
+
return j.readFile(e);
|
|
3158
3163
|
}
|
|
3159
|
-
function
|
|
3160
|
-
return
|
|
3164
|
+
function va(e = ".") {
|
|
3165
|
+
return j.listFiles(e);
|
|
3161
3166
|
}
|
|
3162
|
-
function
|
|
3167
|
+
function St(e) {
|
|
3163
3168
|
return e instanceof Error ? e.message : String(e);
|
|
3164
3169
|
}
|
|
3165
|
-
function
|
|
3170
|
+
function ma(e) {
|
|
3166
3171
|
if (!e) return "";
|
|
3167
3172
|
const t = new Date(e);
|
|
3168
3173
|
return Number.isNaN(t.getTime()) ? e : `更新时间:${t.toLocaleString()}`;
|
|
3169
3174
|
}
|
|
3170
|
-
function
|
|
3171
|
-
|
|
3175
|
+
function ga() {
|
|
3176
|
+
xe.value = !xe.value, xe.value && (De.value = !1, Ye());
|
|
3172
3177
|
}
|
|
3173
|
-
async function
|
|
3178
|
+
async function Ye() {
|
|
3174
3179
|
if (!Oe.value) return;
|
|
3175
|
-
|
|
3180
|
+
oe == null || oe.abort();
|
|
3176
3181
|
const e = new AbortController();
|
|
3177
|
-
|
|
3182
|
+
oe = e, ft.value = !0, ze.value = "";
|
|
3178
3183
|
try {
|
|
3179
|
-
const t = await
|
|
3184
|
+
const t = await Os(o.filesEndpoint, {
|
|
3180
3185
|
headers: o.filesHeaders,
|
|
3181
3186
|
signal: e.signal
|
|
3182
3187
|
});
|
|
3183
|
-
if (
|
|
3184
|
-
|
|
3188
|
+
if (oe !== e) return;
|
|
3189
|
+
tt.value = t;
|
|
3185
3190
|
} catch (t) {
|
|
3186
|
-
if (
|
|
3187
|
-
|
|
3191
|
+
if (oe !== e) return;
|
|
3192
|
+
tt.value = [], ze.value = St(t);
|
|
3188
3193
|
} finally {
|
|
3189
|
-
|
|
3194
|
+
oe === e && (oe = null, ft.value = !1);
|
|
3190
3195
|
}
|
|
3191
3196
|
}
|
|
3192
|
-
async function
|
|
3197
|
+
async function jn() {
|
|
3193
3198
|
if (!Oe.value)
|
|
3194
3199
|
return h("未配置文件服务端点(filesEndpoint)"), null;
|
|
3195
3200
|
if (W.value) return null;
|
|
3196
|
-
const e = w.value, t =
|
|
3201
|
+
const e = w.value, t = Vt(e.name, e.language);
|
|
3197
3202
|
t !== e.name && (Ie.value = t), W.value = !0;
|
|
3198
3203
|
try {
|
|
3199
|
-
const r = await
|
|
3204
|
+
const r = await Ms(
|
|
3200
3205
|
o.filesEndpoint,
|
|
3201
|
-
{ name: t, content:
|
|
3206
|
+
{ name: t, content: Te() },
|
|
3202
3207
|
{ headers: o.filesHeaders }
|
|
3203
3208
|
);
|
|
3204
|
-
return h(`已保存到服务端:${r.name}(${
|
|
3209
|
+
return h(`已保存到服务端:${r.name}(${Gt(r.size)})`), xe.value && await Ye(), r;
|
|
3205
3210
|
} catch (r) {
|
|
3206
|
-
return h(`保存到服务端失败:${
|
|
3211
|
+
return h(`保存到服务端失败:${St(r)}`), null;
|
|
3207
3212
|
} finally {
|
|
3208
3213
|
W.value = !1;
|
|
3209
3214
|
}
|
|
3210
3215
|
}
|
|
3211
|
-
async function
|
|
3216
|
+
async function ya(e) {
|
|
3212
3217
|
if (!Oe.value || W.value) return !1;
|
|
3213
3218
|
W.value = !0;
|
|
3214
3219
|
try {
|
|
3215
|
-
const t = await
|
|
3220
|
+
const t = await Ts(o.filesEndpoint, e.id, {
|
|
3216
3221
|
headers: o.filesHeaders
|
|
3217
|
-
}), r =
|
|
3222
|
+
}), r = cr(t.name), u = Ke(Sn(t.name), r, t.content);
|
|
3218
3223
|
return L.value.push(u), He(u.id), h(`已从服务端打开文件:${t.name}`), i("fileOpen", { name: u.name, code: t.content, language: r }), !0;
|
|
3219
3224
|
} catch (t) {
|
|
3220
|
-
return h(`打开服务端文件失败:${
|
|
3225
|
+
return h(`打开服务端文件失败:${St(t)}`), !1;
|
|
3221
3226
|
} finally {
|
|
3222
3227
|
W.value = !1;
|
|
3223
3228
|
}
|
|
3224
3229
|
}
|
|
3225
|
-
async function
|
|
3230
|
+
async function ha(e) {
|
|
3226
3231
|
if (!(!Oe.value || W.value) && !(typeof window < "u" && !window.confirm(`确定删除服务端文件“${e.name}”?`))) {
|
|
3227
3232
|
W.value = !0;
|
|
3228
3233
|
try {
|
|
3229
|
-
await
|
|
3234
|
+
await Ns(o.filesEndpoint, e.id, { headers: o.filesHeaders }), h(`已删除服务端文件:${e.name}`), await Ye();
|
|
3230
3235
|
} catch (t) {
|
|
3231
|
-
h(`删除服务端文件失败:${
|
|
3236
|
+
h(`删除服务端文件失败:${St(t)}`);
|
|
3232
3237
|
} finally {
|
|
3233
3238
|
W.value = !1;
|
|
3234
3239
|
}
|
|
3235
3240
|
}
|
|
3236
3241
|
}
|
|
3237
|
-
function
|
|
3242
|
+
function Vn() {
|
|
3238
3243
|
var e;
|
|
3239
|
-
(e =
|
|
3244
|
+
(e = N.value) == null || e.click();
|
|
3240
3245
|
}
|
|
3241
|
-
async function
|
|
3246
|
+
async function ba(e) {
|
|
3242
3247
|
var u;
|
|
3243
3248
|
const t = e.target, r = (u = t.files) == null ? void 0 : u[0];
|
|
3244
3249
|
if (t.value = "", !!r) {
|
|
@@ -3247,7 +3252,7 @@ const Da = Z(
|
|
|
3247
3252
|
return;
|
|
3248
3253
|
}
|
|
3249
3254
|
try {
|
|
3250
|
-
const c = await r.text(), y =
|
|
3255
|
+
const c = await r.text(), y = cr(r.name), S = Ke(Sn(r.name), y, c);
|
|
3251
3256
|
L.value.push(S), He(S.id), h(`已打开文件:${S.name}`), i("fileOpen", { name: S.name, code: c, language: y });
|
|
3252
3257
|
} catch (c) {
|
|
3253
3258
|
const y = c instanceof Error ? c.message : String(c);
|
|
@@ -3255,23 +3260,29 @@ const Da = Z(
|
|
|
3255
3260
|
}
|
|
3256
3261
|
}
|
|
3257
3262
|
}
|
|
3258
|
-
function
|
|
3259
|
-
Ie.value =
|
|
3263
|
+
function ka() {
|
|
3264
|
+
Ie.value = Vt(Ie.value, w.value.language);
|
|
3260
3265
|
}
|
|
3261
|
-
function
|
|
3266
|
+
function wa(e) {
|
|
3262
3267
|
e.key === "Enter" && (e.preventDefault(), e.target.blur());
|
|
3263
3268
|
}
|
|
3264
|
-
function
|
|
3265
|
-
|
|
3269
|
+
function Sa(e) {
|
|
3270
|
+
jt(e.target.value);
|
|
3271
|
+
}
|
|
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));
|
|
3266
3277
|
}
|
|
3267
|
-
async function
|
|
3278
|
+
async function Qn(e) {
|
|
3268
3279
|
var t, r;
|
|
3269
|
-
await
|
|
3280
|
+
await Zn(), (r = (t = O.value) == null ? void 0 : t.querySelector(`[data-file-id="${e}"]`)) == null || r.focus();
|
|
3270
3281
|
}
|
|
3271
|
-
function
|
|
3282
|
+
function Ea(e, t) {
|
|
3272
3283
|
if (e.target !== e.currentTarget) return;
|
|
3273
3284
|
if (e.key === "Enter" || e.key === " ") {
|
|
3274
|
-
e.preventDefault(), He(t.id),
|
|
3285
|
+
e.preventDefault(), He(t.id), Qn(t.id);
|
|
3275
3286
|
return;
|
|
3276
3287
|
}
|
|
3277
3288
|
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
@@ -3279,17 +3290,17 @@ const Da = Z(
|
|
|
3279
3290
|
const r = L.value.findIndex((y) => y.id === t.id);
|
|
3280
3291
|
if (r < 0) return;
|
|
3281
3292
|
const u = e.key === "ArrowLeft" ? -1 : 1, c = L.value[(r + u + L.value.length) % L.value.length];
|
|
3282
|
-
c && (He(c.id),
|
|
3293
|
+
c && (He(c.id), Qn(c.id));
|
|
3283
3294
|
}
|
|
3284
|
-
function
|
|
3285
|
-
|
|
3295
|
+
function xt() {
|
|
3296
|
+
P == null || P.focus();
|
|
3286
3297
|
}
|
|
3287
|
-
async function
|
|
3298
|
+
async function qa(e) {
|
|
3288
3299
|
var r;
|
|
3289
3300
|
h(`正在安装:${e.join(", ")}`);
|
|
3290
3301
|
let t;
|
|
3291
3302
|
try {
|
|
3292
|
-
t = await
|
|
3303
|
+
t = await j.loadPackages(e, {
|
|
3293
3304
|
onOutput: (u, c) => ge(u, c)
|
|
3294
3305
|
});
|
|
3295
3306
|
} catch (u) {
|
|
@@ -3298,396 +3309,418 @@ const Da = Z(
|
|
|
3298
3309
|
}
|
|
3299
3310
|
return h(t.ok ? "安装完成" : `安装失败:${((r = t.error) == null ? void 0 : r.message) ?? "未知错误"}`), t;
|
|
3300
3311
|
}
|
|
3301
|
-
function
|
|
3302
|
-
return
|
|
3312
|
+
function Ca() {
|
|
3313
|
+
return j.checkSyntax(Te());
|
|
3303
3314
|
}
|
|
3304
|
-
function
|
|
3305
|
-
return
|
|
3315
|
+
function Pa() {
|
|
3316
|
+
return D(f.value);
|
|
3306
3317
|
}
|
|
3307
|
-
function
|
|
3308
|
-
return
|
|
3318
|
+
function Oa() {
|
|
3319
|
+
return P;
|
|
3309
3320
|
}
|
|
3310
|
-
function
|
|
3311
|
-
return L.value.map(
|
|
3321
|
+
function Ma() {
|
|
3322
|
+
return L.value.map(Ge);
|
|
3312
3323
|
}
|
|
3313
|
-
function
|
|
3314
|
-
return
|
|
3324
|
+
function Ta() {
|
|
3325
|
+
return Ge(w.value);
|
|
3315
3326
|
}
|
|
3316
3327
|
return n({
|
|
3317
|
-
run:
|
|
3318
|
-
stop:
|
|
3319
|
-
clearOutput:
|
|
3320
|
-
clearCode:
|
|
3321
|
-
newFile:
|
|
3328
|
+
run: Nn,
|
|
3329
|
+
stop: Ln,
|
|
3330
|
+
clearOutput: _n,
|
|
3331
|
+
clearCode: Bn,
|
|
3332
|
+
newFile: Jt,
|
|
3322
3333
|
switchFile: He,
|
|
3323
|
-
closeFile:
|
|
3324
|
-
copyCode:
|
|
3325
|
-
download:
|
|
3326
|
-
openFile:
|
|
3327
|
-
focus:
|
|
3328
|
-
install:
|
|
3329
|
-
checkSyntax:
|
|
3330
|
-
executeSql:
|
|
3331
|
-
getSqlConfig:
|
|
3332
|
-
openSqlConfig:
|
|
3333
|
-
closeSqlConfig:
|
|
3334
|
-
getEditorView:
|
|
3335
|
-
getCode:
|
|
3336
|
-
setCode:
|
|
3337
|
-
getFiles:
|
|
3338
|
-
getActiveFile:
|
|
3339
|
-
writeFile:
|
|
3340
|
-
readFile:
|
|
3341
|
-
listFiles:
|
|
3342
|
-
downloadFile:
|
|
3343
|
-
saveToServer:
|
|
3344
|
-
refreshServerFiles:
|
|
3345
|
-
clearPersistedState:
|
|
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
|
|
3346
3357
|
}), (e, t) => (m(), g("div", {
|
|
3347
3358
|
ref_key: "rootEl",
|
|
3348
3359
|
ref: p,
|
|
3349
|
-
class:
|
|
3350
|
-
style:
|
|
3360
|
+
class: le(["vpe-root", qr.value]),
|
|
3361
|
+
style: Gn(Er.value)
|
|
3351
3362
|
}, [
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
j(B(za)),
|
|
3361
|
-
t[19] || (t[19] = l("span", null, "停止", -1))
|
|
3362
|
-
])) : (m(), g("button", {
|
|
3363
|
-
key: 0,
|
|
3364
|
-
class: "vpe-btn vpe-btn--primary",
|
|
3365
|
-
type: "button",
|
|
3366
|
-
title: qr.value,
|
|
3367
|
-
disabled: Cr.value,
|
|
3368
|
-
onClick: qn
|
|
3369
|
-
}, [
|
|
3370
|
-
j(B(Da)),
|
|
3371
|
-
t[18] || (t[18] = l("span", null, "运行", -1))
|
|
3372
|
-
], 8, Xa)),
|
|
3373
|
-
t[31] || (t[31] = l("span", {
|
|
3374
|
-
class: "vpe-divider",
|
|
3375
|
-
"aria-hidden": "true"
|
|
3376
|
-
}, null, -1)),
|
|
3377
|
-
l("button", {
|
|
3378
|
-
class: "vpe-btn",
|
|
3379
|
-
type: "button",
|
|
3380
|
-
title: "新建文件",
|
|
3381
|
-
"aria-label": "新建文件",
|
|
3382
|
-
disabled: a.readOnly,
|
|
3383
|
-
onClick: zt
|
|
3384
|
-
}, [
|
|
3385
|
-
j(B(ja)),
|
|
3386
|
-
t[20] || (t[20] = l("span", null, "新建", -1))
|
|
3387
|
-
], 8, eo),
|
|
3388
|
-
l("button", {
|
|
3389
|
-
class: "vpe-btn",
|
|
3390
|
-
type: "button",
|
|
3391
|
-
title: "打开本地文件",
|
|
3392
|
-
"aria-label": "打开本地文件",
|
|
3393
|
-
disabled: a.readOnly,
|
|
3394
|
-
onClick: Bn
|
|
3395
|
-
}, [
|
|
3396
|
-
j(B(Va)),
|
|
3397
|
-
t[21] || (t[21] = l("span", null, "本地文件", -1))
|
|
3398
|
-
], 8, to),
|
|
3399
|
-
l("button", {
|
|
3400
|
-
class: "vpe-btn",
|
|
3401
|
-
type: "button",
|
|
3402
|
-
title: "下载当前文件",
|
|
3403
|
-
"aria-label": "下载当前文件",
|
|
3404
|
-
onClick: Rn
|
|
3405
|
-
}, [
|
|
3406
|
-
j(B(ur)),
|
|
3407
|
-
t[22] || (t[22] = l("span", null, "下载", -1))
|
|
3408
|
-
]),
|
|
3409
|
-
l("button", {
|
|
3410
|
-
class: "vpe-btn",
|
|
3411
|
-
type: "button",
|
|
3412
|
-
title: "虚拟文件(下载 Python 生成的文件)",
|
|
3413
|
-
"aria-label": "虚拟文件",
|
|
3414
|
-
onClick: is
|
|
3415
|
-
}, [
|
|
3416
|
-
j(B(lr)),
|
|
3417
|
-
t[23] || (t[23] = l("span", null, "虚拟文件", -1))
|
|
3418
|
-
]),
|
|
3419
|
-
Oe.value ? (m(), g("button", {
|
|
3420
|
-
key: 2,
|
|
3421
|
-
class: "vpe-btn",
|
|
3422
|
-
type: "button",
|
|
3423
|
-
title: W.value ? "正在处理服务端文件…" : "保存当前文件到服务端",
|
|
3424
|
-
"aria-label": "保存到服务端",
|
|
3425
|
-
disabled: W.value,
|
|
3426
|
-
onClick: Hn
|
|
3427
|
-
}, [
|
|
3428
|
-
j(B(Ga)),
|
|
3429
|
-
t[24] || (t[24] = l("span", null, "保存", -1))
|
|
3430
|
-
], 8, no)) : N("", !0),
|
|
3431
|
-
Oe.value ? (m(), g("button", {
|
|
3432
|
-
key: 3,
|
|
3433
|
-
class: "vpe-btn",
|
|
3434
|
-
type: "button",
|
|
3435
|
-
title: "查询服务端已保存文件",
|
|
3436
|
-
"aria-label": "已保存文件",
|
|
3437
|
-
onClick: fs
|
|
3438
|
-
}, [
|
|
3439
|
-
j(B(Wa)),
|
|
3440
|
-
t[25] || (t[25] = l("span", null, "已保存文件", -1))
|
|
3441
|
-
])) : N("", !0),
|
|
3442
|
-
a.showSqlConfig && de.value ? (m(), g("button", {
|
|
3443
|
-
key: 4,
|
|
3444
|
-
class: "vpe-btn",
|
|
3445
|
-
type: "button",
|
|
3446
|
-
title: "新建连接",
|
|
3447
|
-
"aria-label": "新建连接",
|
|
3448
|
-
onClick: Hr
|
|
3449
|
-
}, [
|
|
3450
|
-
j(B(Za)),
|
|
3451
|
-
t[26] || (t[26] = l("span", null, "新建连接", -1))
|
|
3452
|
-
])) : N("", !0),
|
|
3453
|
-
l("button", {
|
|
3454
|
-
class: ie(["vpe-btn", { "vpe-btn--copied": me.value }]),
|
|
3455
|
-
type: "button",
|
|
3456
|
-
title: me.value ? "已复制" : "复制代码",
|
|
3457
|
-
"aria-label": me.value ? "已复制" : "复制代码",
|
|
3458
|
-
onClick: Fn
|
|
3459
|
-
}, [
|
|
3460
|
-
me.value ? (m(), Vn(B(Ka), { key: 0 })) : (m(), Vn(B(Qa), { key: 1 })),
|
|
3461
|
-
me.value ? (m(), g("span", so, "已复制")) : (m(), g("span", ao, "复制"))
|
|
3462
|
-
], 10, ro),
|
|
3463
|
-
l("button", {
|
|
3464
|
-
class: "vpe-btn",
|
|
3465
|
-
type: "button",
|
|
3466
|
-
title: "清空当前文件",
|
|
3467
|
-
"aria-label": "清空当前文件",
|
|
3468
|
-
disabled: a.readOnly,
|
|
3469
|
-
onClick: $n
|
|
3470
|
-
}, [
|
|
3471
|
-
j(B(ir)),
|
|
3472
|
-
t[27] || (t[27] = l("span", null, "清空", -1))
|
|
3473
|
-
], 8, oo),
|
|
3474
|
-
t[32] || (t[32] = l("span", {
|
|
3475
|
-
class: "vpe-divider",
|
|
3476
|
-
"aria-hidden": "true"
|
|
3477
|
-
}, null, -1)),
|
|
3478
|
-
l("label", io, [
|
|
3479
|
-
j(B(lr)),
|
|
3480
|
-
J(l("input", {
|
|
3481
|
-
"onUpdate:modelValue": t[0] || (t[0] = (r) => Ie.value = r),
|
|
3482
|
-
class: "vpe-file-input",
|
|
3483
|
-
type: "text",
|
|
3484
|
-
spellcheck: "false",
|
|
3485
|
-
"aria-label": "文件名",
|
|
3486
|
-
onBlur: ys,
|
|
3487
|
-
onKeydown: hs
|
|
3488
|
-
}, null, 544), [
|
|
3489
|
-
[he, Ie.value]
|
|
3490
|
-
])
|
|
3491
|
-
]),
|
|
3492
|
-
t[33] || (t[33] = l("span", {
|
|
3493
|
-
class: "vpe-spacer",
|
|
3494
|
-
"aria-hidden": "true"
|
|
3495
|
-
}, null, -1)),
|
|
3496
|
-
a.showSqlConfig && de.value && (f.value.mode === "http" || f.value.endpoint) ? (m(), g(D, { key: 5 }, [
|
|
3497
|
-
J(l("select", {
|
|
3498
|
-
"onUpdate:modelValue": t[1] || (t[1] = (r) => f.value.connectionId = r),
|
|
3499
|
-
class: "vpe-lang vpe-sql-connection",
|
|
3500
|
-
title: "切换已保存连接",
|
|
3501
|
-
"aria-label": "切换已保存连接",
|
|
3502
|
-
disabled: ze.value,
|
|
3503
|
-
onChange: Ar
|
|
3363
|
+
s.showToolbar ? (m(), g("div", to, [
|
|
3364
|
+
l("div", no, [
|
|
3365
|
+
Dt.value ? (m(), g("button", {
|
|
3366
|
+
key: 1,
|
|
3367
|
+
class: "vpe-btn vpe-btn--stop",
|
|
3368
|
+
type: "button",
|
|
3369
|
+
title: "中断执行",
|
|
3370
|
+
onClick: Ln
|
|
3504
3371
|
}, [
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3372
|
+
V(B(Qs)),
|
|
3373
|
+
t[19] || (t[19] = l("span", null, "停止", -1))
|
|
3374
|
+
])) : (m(), g("button", {
|
|
3375
|
+
key: 0,
|
|
3376
|
+
class: "vpe-btn vpe-btn--primary",
|
|
3377
|
+
type: "button",
|
|
3378
|
+
title: Or.value,
|
|
3379
|
+
disabled: Mr.value,
|
|
3380
|
+
onClick: Nn
|
|
3381
|
+
}, [
|
|
3382
|
+
V(B(Vs)),
|
|
3383
|
+
t[18] || (t[18] = l("span", null, "运行", -1))
|
|
3384
|
+
], 8, ro)),
|
|
3385
|
+
t[28] || (t[28] = l("span", {
|
|
3386
|
+
class: "vpe-divider",
|
|
3387
|
+
"aria-hidden": "true"
|
|
3388
|
+
}, null, -1)),
|
|
3389
|
+
l("button", {
|
|
3390
|
+
class: "vpe-btn",
|
|
3391
|
+
type: "button",
|
|
3392
|
+
title: "新建文件",
|
|
3393
|
+
"aria-label": "新建文件",
|
|
3394
|
+
disabled: s.readOnly,
|
|
3395
|
+
onClick: Jt
|
|
3396
|
+
}, [
|
|
3397
|
+
V(B(Ks)),
|
|
3398
|
+
t[20] || (t[20] = l("span", null, "新建", -1))
|
|
3399
|
+
], 8, ao),
|
|
3400
|
+
l("button", {
|
|
3401
|
+
class: "vpe-btn",
|
|
3402
|
+
type: "button",
|
|
3403
|
+
title: "打开本地文件",
|
|
3404
|
+
"aria-label": "打开本地文件",
|
|
3405
|
+
disabled: s.readOnly,
|
|
3406
|
+
onClick: Vn
|
|
3407
|
+
}, [
|
|
3408
|
+
V(B(Js)),
|
|
3409
|
+
t[21] || (t[21] = l("span", null, "本地文件", -1))
|
|
3410
|
+
], 8, so),
|
|
3411
|
+
l("button", {
|
|
3412
|
+
class: "vpe-btn",
|
|
3413
|
+
type: "button",
|
|
3414
|
+
title: "下载当前文件",
|
|
3415
|
+
"aria-label": "下载当前文件",
|
|
3416
|
+
onClick: An
|
|
3417
|
+
}, [
|
|
3418
|
+
V(B(fr)),
|
|
3419
|
+
t[22] || (t[22] = l("span", null, "下载", -1))
|
|
3512
3420
|
]),
|
|
3513
3421
|
l("button", {
|
|
3514
|
-
class: "vpe-btn vpe-
|
|
3422
|
+
class: "vpe-btn vpe-toolbar-secondary",
|
|
3515
3423
|
type: "button",
|
|
3516
|
-
title: "
|
|
3517
|
-
"aria-label": "
|
|
3518
|
-
onClick:
|
|
3519
|
-
},
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
class: "vpe-
|
|
3526
|
-
|
|
3527
|
-
"
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
[
|
|
3534
|
-
])
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3424
|
+
title: "虚拟文件(下载 Python 生成的文件)",
|
|
3425
|
+
"aria-label": "虚拟文件",
|
|
3426
|
+
onClick: ca
|
|
3427
|
+
}, [
|
|
3428
|
+
V(B(pr)),
|
|
3429
|
+
t[23] || (t[23] = l("span", null, "虚拟文件", -1))
|
|
3430
|
+
]),
|
|
3431
|
+
Oe.value ? (m(), g("button", {
|
|
3432
|
+
key: 2,
|
|
3433
|
+
class: "vpe-btn",
|
|
3434
|
+
type: "button",
|
|
3435
|
+
title: W.value ? "正在处理服务端文件…" : "保存当前文件到服务端",
|
|
3436
|
+
"aria-label": "保存到服务端",
|
|
3437
|
+
disabled: W.value,
|
|
3438
|
+
onClick: jn
|
|
3439
|
+
}, [
|
|
3440
|
+
V(B(Xs)),
|
|
3441
|
+
t[24] || (t[24] = l("span", null, "保存", -1))
|
|
3442
|
+
], 8, oo)) : T("", !0),
|
|
3443
|
+
Oe.value ? (m(), g("button", {
|
|
3444
|
+
key: 3,
|
|
3445
|
+
class: "vpe-btn vpe-toolbar-secondary",
|
|
3446
|
+
type: "button",
|
|
3447
|
+
title: "查询服务端已保存文件",
|
|
3448
|
+
"aria-label": "已保存文件",
|
|
3449
|
+
onClick: ga
|
|
3450
|
+
}, [
|
|
3451
|
+
V(B(eo)),
|
|
3452
|
+
t[25] || (t[25] = l("span", null, "已保存文件", -1))
|
|
3453
|
+
])) : T("", !0),
|
|
3454
|
+
s.showSqlConfig && pe.value ? (m(), g("button", {
|
|
3455
|
+
key: 4,
|
|
3456
|
+
class: "vpe-btn",
|
|
3457
|
+
type: "button",
|
|
3458
|
+
title: "新建连接",
|
|
3459
|
+
"aria-label": "新建连接",
|
|
3460
|
+
onClick: Ar
|
|
3461
|
+
}, [
|
|
3462
|
+
V(B(Ys)),
|
|
3463
|
+
t[26] || (t[26] = l("span", null, "新建连接", -1))
|
|
3464
|
+
])) : T("", !0),
|
|
3465
|
+
l("button", {
|
|
3466
|
+
class: le(["vpe-btn", { "vpe-btn--copied": Se.value }]),
|
|
3467
|
+
type: "button",
|
|
3468
|
+
title: Se.value ? "已复制" : "复制代码",
|
|
3469
|
+
"aria-label": Se.value ? "已复制" : "复制代码",
|
|
3470
|
+
onClick: Un
|
|
3471
|
+
}, [
|
|
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),
|
|
3475
|
+
l("button", {
|
|
3476
|
+
class: "vpe-btn",
|
|
3477
|
+
type: "button",
|
|
3478
|
+
title: "清空当前文件",
|
|
3479
|
+
"aria-label": "清空当前文件",
|
|
3480
|
+
disabled: s.readOnly,
|
|
3481
|
+
onClick: Bn
|
|
3482
|
+
}, [
|
|
3483
|
+
V(B(dr)),
|
|
3484
|
+
t[27] || (t[27] = l("span", null, "清空", -1))
|
|
3485
|
+
], 8, co),
|
|
3486
|
+
t[29] || (t[29] = l("span", {
|
|
3487
|
+
class: "vpe-divider",
|
|
3541
3488
|
"aria-hidden": "true"
|
|
3542
3489
|
}, null, -1)),
|
|
3543
|
-
l("
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3490
|
+
l("label", po, [
|
|
3491
|
+
V(B(pr)),
|
|
3492
|
+
J(l("input", {
|
|
3493
|
+
"onUpdate:modelValue": t[0] || (t[0] = (r) => Ie.value = r),
|
|
3494
|
+
class: "vpe-file-input",
|
|
3495
|
+
type: "text",
|
|
3496
|
+
spellcheck: "false",
|
|
3497
|
+
"aria-label": "文件名",
|
|
3498
|
+
onBlur: ka,
|
|
3499
|
+
onKeydown: wa
|
|
3500
|
+
}, null, 544), [
|
|
3501
|
+
[he, Ie.value]
|
|
3502
|
+
])
|
|
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)
|
|
3516
|
+
]),
|
|
3517
|
+
l("div", mo, [
|
|
3518
|
+
s.showSqlConfig && pe.value && (f.value.mode === "http" || f.value.endpoint) ? (m(), g(A, { key: 0 }, [
|
|
3519
|
+
J(l("select", {
|
|
3520
|
+
"onUpdate:modelValue": t[1] || (t[1] = (r) => f.value.connectionId = r),
|
|
3521
|
+
class: "vpe-select vpe-sql-connection",
|
|
3522
|
+
title: "切换已保存连接",
|
|
3523
|
+
"aria-label": "切换已保存连接",
|
|
3524
|
+
disabled: je.value,
|
|
3525
|
+
onChange: jr
|
|
3526
|
+
}, [
|
|
3527
|
+
l("option", yo, R(je.value ? "加载中…" : Ce.value.length ? "选择连接" : "暂无已保存连接"), 1),
|
|
3528
|
+
(m(!0), g(A, null, te(Ce.value, (r) => (m(), g("option", {
|
|
3529
|
+
key: r.id,
|
|
3530
|
+
value: r.id
|
|
3531
|
+
}, R(r.name), 9, ho))), 128))
|
|
3532
|
+
], 40, go), [
|
|
3533
|
+
[Et, f.value.connectionId]
|
|
3534
|
+
]),
|
|
3535
|
+
l("button", {
|
|
3536
|
+
class: "vpe-btn vpe-btn--sm vpe-sql-manage",
|
|
3537
|
+
type: "button",
|
|
3538
|
+
title: "管理连接配置",
|
|
3539
|
+
"aria-label": "管理连接配置",
|
|
3540
|
+
onClick: Ur
|
|
3541
|
+
}, " 管理 ")
|
|
3542
|
+
], 64)) : T("", !0),
|
|
3543
|
+
l("div", bo, [
|
|
3544
|
+
l("span", {
|
|
3545
|
+
class: le(["vpe-status", `vpe-status--${Pr.value}`]),
|
|
3546
|
+
title: bn.value
|
|
3547
|
+
}, [
|
|
3548
|
+
t[30] || (t[30] = l("span", {
|
|
3549
|
+
class: "vpe-status-dot",
|
|
3550
|
+
"aria-hidden": "true"
|
|
3551
|
+
}, null, -1)),
|
|
3552
|
+
l("span", wo, R(bn.value), 1)
|
|
3553
|
+
], 10, ko),
|
|
3554
|
+
bt.value && hn.value ? (m(), g(A, { key: 0 }, [
|
|
3555
|
+
t[32] || (t[32] = l("span", {
|
|
3556
|
+
class: "vpe-chips-divider",
|
|
3557
|
+
"aria-hidden": "true"
|
|
3558
|
+
}, null, -1)),
|
|
3559
|
+
J(l("select", {
|
|
3560
|
+
"onUpdate:modelValue": t[2] || (t[2] = (r) => ce.value = r),
|
|
3561
|
+
class: "vpe-toolbar-select",
|
|
3562
|
+
title: "Python 运行环境",
|
|
3563
|
+
"aria-label": "Python 运行环境",
|
|
3564
|
+
onChange: Xr
|
|
3565
|
+
}, [...t[31] || (t[31] = [
|
|
3566
|
+
l("option", { value: "browser" }, "浏览器", -1),
|
|
3567
|
+
l("option", { value: "server" }, "服务端", -1)
|
|
3568
|
+
])], 544), [
|
|
3569
|
+
[Et, ce.value]
|
|
3570
|
+
])
|
|
3571
|
+
], 64)) : T("", !0),
|
|
3572
|
+
t[33] || (t[33] = l("span", {
|
|
3573
|
+
class: "vpe-chips-divider",
|
|
3574
|
+
"aria-hidden": "true"
|
|
3575
|
+
}, null, -1)),
|
|
3576
|
+
l("select", {
|
|
3577
|
+
class: "vpe-toolbar-select",
|
|
3578
|
+
value: w.value.language,
|
|
3579
|
+
title: "编辑器语言",
|
|
3580
|
+
"aria-label": "编辑器语言",
|
|
3581
|
+
disabled: s.readOnly,
|
|
3582
|
+
onChange: Sa
|
|
3583
|
+
}, [
|
|
3584
|
+
(m(!0), g(A, null, te(B($t), (r) => (m(), g("option", {
|
|
3585
|
+
key: r.value,
|
|
3586
|
+
value: r.value
|
|
3587
|
+
}, R(r.label), 9, xo))), 128))
|
|
3588
|
+
], 40, So)
|
|
3589
|
+
])
|
|
3590
|
+
])
|
|
3591
|
+
])) : T("", !0),
|
|
3592
|
+
s.showTabs ? (m(), g("div", {
|
|
3560
3593
|
key: 1,
|
|
3561
3594
|
ref_key: "tabsEl",
|
|
3562
|
-
ref:
|
|
3595
|
+
ref: O,
|
|
3563
3596
|
class: "vpe-tabs",
|
|
3564
3597
|
role: "tablist",
|
|
3565
3598
|
"aria-label": "文件"
|
|
3566
3599
|
}, [
|
|
3567
|
-
(m(!0), g(
|
|
3600
|
+
(m(!0), g(A, null, te(L.value, (r) => (m(), g("div", {
|
|
3568
3601
|
key: r.id,
|
|
3569
|
-
class:
|
|
3602
|
+
class: le(["vpe-tab", { "vpe-tab--active": r.id === w.value.id }]),
|
|
3570
3603
|
role: "tab",
|
|
3571
3604
|
tabindex: "0",
|
|
3572
3605
|
"aria-selected": r.id === w.value.id,
|
|
3573
3606
|
"data-file-id": r.id,
|
|
3574
3607
|
title: r.name,
|
|
3575
3608
|
onClick: (u) => He(r.id),
|
|
3576
|
-
onKeydown: (u) =>
|
|
3609
|
+
onKeydown: (u) => Ea(u, r)
|
|
3577
3610
|
}, [
|
|
3578
3611
|
l("span", {
|
|
3579
|
-
class:
|
|
3612
|
+
class: le(["vpe-tab-dot", `vpe-tab-dot--${r.language}`]),
|
|
3580
3613
|
"aria-hidden": "true"
|
|
3581
3614
|
}, null, 2),
|
|
3582
|
-
l("span",
|
|
3615
|
+
l("span", qo, R(r.name), 1),
|
|
3583
3616
|
l("button", {
|
|
3584
3617
|
class: "vpe-tab-close",
|
|
3585
3618
|
type: "button",
|
|
3586
3619
|
title: `关闭 ${r.name}`,
|
|
3587
3620
|
"aria-label": `关闭 ${r.name}`,
|
|
3588
|
-
disabled:
|
|
3589
|
-
onClick:
|
|
3621
|
+
disabled: s.readOnly,
|
|
3622
|
+
onClick: Yn((u) => Hn(r.id), ["stop"])
|
|
3590
3623
|
}, [
|
|
3591
|
-
|
|
3592
|
-
], 8,
|
|
3593
|
-
], 42,
|
|
3624
|
+
V(B(ct))
|
|
3625
|
+
], 8, Co)
|
|
3626
|
+
], 42, Eo))), 128)),
|
|
3594
3627
|
l("button", {
|
|
3595
3628
|
class: "vpe-tabs-add",
|
|
3596
3629
|
type: "button",
|
|
3597
3630
|
title: "新建文件",
|
|
3598
3631
|
"aria-label": "新建文件",
|
|
3599
|
-
disabled:
|
|
3600
|
-
onClick:
|
|
3632
|
+
disabled: s.readOnly,
|
|
3633
|
+
onClick: Jt
|
|
3601
3634
|
}, [
|
|
3602
|
-
|
|
3603
|
-
], 8,
|
|
3604
|
-
], 512)) :
|
|
3635
|
+
V(B(Ws))
|
|
3636
|
+
], 8, Po)
|
|
3637
|
+
], 512)) : T("", !0),
|
|
3605
3638
|
l("input", {
|
|
3606
3639
|
ref_key: "fileInputEl",
|
|
3607
|
-
ref:
|
|
3640
|
+
ref: N,
|
|
3608
3641
|
class: "vpe-file-hidden",
|
|
3609
3642
|
type: "file",
|
|
3610
3643
|
accept: ".py,.pyw,.sql,.js,.mjs,.cjs,.jsx,.ts,.json,.txt,text/x-python,text/plain,application/json",
|
|
3611
|
-
onChange:
|
|
3644
|
+
onChange: ba
|
|
3612
3645
|
}, null, 544),
|
|
3613
3646
|
l("div", {
|
|
3614
3647
|
ref_key: "editorEl",
|
|
3615
3648
|
ref: b,
|
|
3616
3649
|
class: "vpe-editor"
|
|
3617
3650
|
}, null, 512),
|
|
3618
|
-
|
|
3651
|
+
s.showOutput ? (m(), g("div", {
|
|
3619
3652
|
key: 2,
|
|
3620
|
-
class:
|
|
3653
|
+
class: le(["vpe-output-resizer", { "vpe-output-resizer--active": F.value }]),
|
|
3621
3654
|
role: "separator",
|
|
3622
3655
|
"aria-orientation": "horizontal",
|
|
3623
3656
|
"aria-label": "调整输出面板高度",
|
|
3624
3657
|
title: "拖动调整输出高度,双击复位",
|
|
3625
3658
|
tabindex: "0",
|
|
3626
|
-
onPointerdown:
|
|
3627
|
-
onDblclick:
|
|
3628
|
-
onKeydown:
|
|
3629
|
-
}, null, 34)) :
|
|
3630
|
-
|
|
3659
|
+
onPointerdown: sa,
|
|
3660
|
+
onDblclick: oa,
|
|
3661
|
+
onKeydown: ia
|
|
3662
|
+
}, null, 34)) : T("", !0),
|
|
3663
|
+
s.showOutput ? (m(), g("div", {
|
|
3631
3664
|
key: 3,
|
|
3632
3665
|
ref_key: "outputPanelEl",
|
|
3633
3666
|
ref: E,
|
|
3634
3667
|
class: "vpe-output",
|
|
3635
|
-
style:
|
|
3668
|
+
style: Gn({ height: Cr.value })
|
|
3636
3669
|
}, [
|
|
3637
|
-
l("div",
|
|
3670
|
+
l("div", Oo, [
|
|
3638
3671
|
t[34] || (t[34] = l("span", null, "输出", -1)),
|
|
3639
3672
|
l("button", {
|
|
3640
3673
|
class: "vpe-btn vpe-btn--sm",
|
|
3641
3674
|
type: "button",
|
|
3642
3675
|
title: "清空输出",
|
|
3643
|
-
onClick:
|
|
3676
|
+
onClick: _n
|
|
3644
3677
|
}, [
|
|
3645
|
-
|
|
3678
|
+
V(B(dr))
|
|
3646
3679
|
])
|
|
3647
3680
|
]),
|
|
3648
|
-
l("div",
|
|
3649
|
-
|
|
3650
|
-
(m(!0), g(
|
|
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", {
|
|
3651
3684
|
key: u,
|
|
3652
3685
|
class: "vpe-sql-result"
|
|
3653
3686
|
}, [
|
|
3654
|
-
l("div",
|
|
3655
|
-
l("span", null, "结果 " +
|
|
3656
|
-
l("span", null,
|
|
3687
|
+
l("div", No, [
|
|
3688
|
+
l("span", null, "结果 " + R(u + 1), 1),
|
|
3689
|
+
l("span", null, R(Wr(r)), 1)
|
|
3657
3690
|
]),
|
|
3658
|
-
r.columns.length ? (m(), g("div",
|
|
3659
|
-
l("table",
|
|
3691
|
+
r.columns.length ? (m(), g("div", Lo, [
|
|
3692
|
+
l("table", $o, [
|
|
3660
3693
|
l("thead", null, [
|
|
3661
3694
|
l("tr", null, [
|
|
3662
|
-
(m(!0), g(
|
|
3695
|
+
(m(!0), g(A, null, te(r.columns, (c, y) => (m(), g("th", { key: y }, R(c), 1))), 128))
|
|
3663
3696
|
])
|
|
3664
3697
|
]),
|
|
3665
3698
|
l("tbody", null, [
|
|
3666
|
-
(m(!0), g(
|
|
3667
|
-
(m(!0), g(
|
|
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", {
|
|
3668
3701
|
key: $,
|
|
3669
|
-
class:
|
|
3670
|
-
},
|
|
3702
|
+
class: le({ "vpe-sql-null": S === null })
|
|
3703
|
+
}, R(Gr(S)), 3))), 128))
|
|
3671
3704
|
]))), 128))
|
|
3672
3705
|
])
|
|
3673
3706
|
]),
|
|
3674
|
-
r.rows.length ?
|
|
3675
|
-
])) : (m(), g("div",
|
|
3707
|
+
r.rows.length ? T("", !0) : (m(), g("div", Fo, "查询无数据"))
|
|
3708
|
+
])) : (m(), g("div", _o, "影响 " + R(r.affectedRows ?? 0) + " 行", 1))
|
|
3676
3709
|
]))), 128))
|
|
3677
|
-
])) :
|
|
3710
|
+
])) : T("", !0),
|
|
3678
3711
|
l("pre", {
|
|
3679
3712
|
ref_key: "outputEl",
|
|
3680
|
-
ref:
|
|
3713
|
+
ref: _,
|
|
3681
3714
|
class: "vpe-output-body"
|
|
3682
3715
|
}, [
|
|
3683
|
-
G.value.length ? (m(!0), g(
|
|
3716
|
+
G.value.length ? (m(!0), g(A, { key: 0 }, te(G.value, (r) => (m(), g("span", {
|
|
3684
3717
|
key: r.id,
|
|
3685
|
-
class:
|
|
3686
|
-
},
|
|
3687
|
-
`, 3))), 128)) : (m(), g("span",
|
|
3718
|
+
class: le(["vpe-line", `vpe-line--${r.stream}`])
|
|
3719
|
+
}, R(r.text) + `
|
|
3720
|
+
`, 3))), 128)) : (m(), g("span", Ro, "暂无输出,点击“运行”或按 Ctrl+Enter 执行代码"))
|
|
3688
3721
|
], 512)
|
|
3689
3722
|
]),
|
|
3690
|
-
|
|
3723
|
+
Ze.value && Ae.value && Dt.value ? (m(), g("div", Io, [
|
|
3691
3724
|
t[35] || (t[35] = l("span", {
|
|
3692
3725
|
class: "vpe-terminal-prompt",
|
|
3693
3726
|
"aria-hidden": "true"
|
|
@@ -3699,19 +3732,19 @@ const Da = Z(
|
|
|
3699
3732
|
spellcheck: "false",
|
|
3700
3733
|
placeholder: "输入后按 Enter 发送给 input()",
|
|
3701
3734
|
"aria-label": "标准输入",
|
|
3702
|
-
onKeydown:
|
|
3703
|
-
}, null, 40,
|
|
3735
|
+
onKeydown: Ra(Yn(Mn, ["prevent"]), ["enter"])
|
|
3736
|
+
}, null, 40, Ho), [
|
|
3704
3737
|
[he, H.value]
|
|
3705
3738
|
]),
|
|
3706
3739
|
l("button", {
|
|
3707
3740
|
class: "vpe-btn vpe-btn--sm",
|
|
3708
3741
|
type: "button",
|
|
3709
|
-
onClick:
|
|
3742
|
+
onClick: Mn
|
|
3710
3743
|
}, " 发送 ")
|
|
3711
|
-
])) :
|
|
3712
|
-
], 4)) :
|
|
3713
|
-
|
|
3714
|
-
l("div",
|
|
3744
|
+
])) : T("", !0)
|
|
3745
|
+
], 4)) : T("", !0),
|
|
3746
|
+
De.value ? (m(), g("div", Bo, [
|
|
3747
|
+
l("div", Uo, [
|
|
3715
3748
|
t[36] || (t[36] = l("span", { class: "vpe-fs-title" }, "虚拟文件", -1)),
|
|
3716
3749
|
t[37] || (t[37] = l("span", {
|
|
3717
3750
|
class: "vpe-spacer",
|
|
@@ -3721,47 +3754,47 @@ const Da = Z(
|
|
|
3721
3754
|
class: "vpe-btn vpe-btn--sm",
|
|
3722
3755
|
type: "button",
|
|
3723
3756
|
title: "刷新文件列表",
|
|
3724
|
-
disabled:
|
|
3725
|
-
onClick:
|
|
3726
|
-
}, " 刷新 ", 8,
|
|
3757
|
+
disabled: Xe.value,
|
|
3758
|
+
onClick: Dn
|
|
3759
|
+
}, " 刷新 ", 8, Ao),
|
|
3727
3760
|
l("button", {
|
|
3728
3761
|
class: "vpe-btn vpe-btn--sm",
|
|
3729
3762
|
type: "button",
|
|
3730
3763
|
title: "关闭虚拟文件面板",
|
|
3731
3764
|
"aria-label": "关闭虚拟文件面板",
|
|
3732
|
-
onClick: t[4] || (t[4] = (r) =>
|
|
3765
|
+
onClick: t[4] || (t[4] = (r) => De.value = !1)
|
|
3733
3766
|
}, [
|
|
3734
|
-
|
|
3767
|
+
V(B(ct))
|
|
3735
3768
|
])
|
|
3736
3769
|
]),
|
|
3737
|
-
l("div",
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
(m(!0), g(
|
|
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", {
|
|
3741
3774
|
key: r.path,
|
|
3742
|
-
class:
|
|
3775
|
+
class: le(["vpe-fs-item", { "vpe-fs-item--dir": r.isDirectory }])
|
|
3743
3776
|
}, [
|
|
3744
3777
|
l("span", {
|
|
3745
3778
|
class: "vpe-fs-name",
|
|
3746
3779
|
title: r.path
|
|
3747
|
-
},
|
|
3748
|
-
l("span",
|
|
3749
|
-
r.isDirectory ?
|
|
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", {
|
|
3750
3783
|
key: 0,
|
|
3751
3784
|
class: "vpe-btn vpe-btn--sm",
|
|
3752
3785
|
type: "button",
|
|
3753
3786
|
title: `下载 ${r.name}`,
|
|
3754
3787
|
"aria-label": `下载 ${r.name}`,
|
|
3755
|
-
onClick: (u) =>
|
|
3788
|
+
onClick: (u) => zn(r.path)
|
|
3756
3789
|
}, [
|
|
3757
|
-
|
|
3758
|
-
], 8,
|
|
3790
|
+
V(B(fr))
|
|
3791
|
+
], 8, Ko))
|
|
3759
3792
|
], 2))), 128))
|
|
3760
3793
|
], 64))
|
|
3761
3794
|
])
|
|
3762
|
-
])) :
|
|
3763
|
-
|
|
3764
|
-
l("div",
|
|
3795
|
+
])) : T("", !0),
|
|
3796
|
+
xe.value && Oe.value ? (m(), g("div", Jo, [
|
|
3797
|
+
l("div", Zo, [
|
|
3765
3798
|
t[38] || (t[38] = l("span", { class: "vpe-fs-title" }, "服务端文件", -1)),
|
|
3766
3799
|
t[39] || (t[39] = l("span", {
|
|
3767
3800
|
class: "vpe-spacer",
|
|
@@ -3771,56 +3804,56 @@ const Da = Z(
|
|
|
3771
3804
|
class: "vpe-btn vpe-btn--sm",
|
|
3772
3805
|
type: "button",
|
|
3773
3806
|
title: "刷新文件列表",
|
|
3774
|
-
disabled:
|
|
3775
|
-
onClick: t[5] || (t[5] = (r) =>
|
|
3776
|
-
}, " 刷新 ", 8,
|
|
3807
|
+
disabled: ft.value,
|
|
3808
|
+
onClick: t[5] || (t[5] = (r) => Ye())
|
|
3809
|
+
}, " 刷新 ", 8, Go),
|
|
3777
3810
|
l("button", {
|
|
3778
3811
|
class: "vpe-btn vpe-btn--sm",
|
|
3779
3812
|
type: "button",
|
|
3780
3813
|
title: "关闭服务端文件面板",
|
|
3781
3814
|
"aria-label": "关闭服务端文件面板",
|
|
3782
|
-
onClick: t[6] || (t[6] = (r) =>
|
|
3815
|
+
onClick: t[6] || (t[6] = (r) => xe.value = !1)
|
|
3783
3816
|
}, [
|
|
3784
|
-
|
|
3817
|
+
V(B(ct))
|
|
3785
3818
|
])
|
|
3786
3819
|
]),
|
|
3787
|
-
l("div",
|
|
3788
|
-
|
|
3789
|
-
!
|
|
3790
|
-
(m(!0), g(
|
|
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", {
|
|
3791
3824
|
key: r.id,
|
|
3792
3825
|
class: "vpe-fs-item"
|
|
3793
3826
|
}, [
|
|
3794
3827
|
l("span", {
|
|
3795
3828
|
class: "vpe-fs-name",
|
|
3796
3829
|
title: r.name
|
|
3797
|
-
},
|
|
3830
|
+
}, R(r.name), 9, ei),
|
|
3798
3831
|
l("span", {
|
|
3799
3832
|
class: "vpe-fs-size",
|
|
3800
|
-
title:
|
|
3801
|
-
},
|
|
3833
|
+
title: ma(r.updatedAt)
|
|
3834
|
+
}, R(Gt(r.size)), 9, ti),
|
|
3802
3835
|
l("button", {
|
|
3803
3836
|
class: "vpe-btn vpe-btn--sm",
|
|
3804
3837
|
type: "button",
|
|
3805
3838
|
title: `打开 ${r.name}`,
|
|
3806
3839
|
disabled: W.value,
|
|
3807
|
-
onClick: (u) =>
|
|
3808
|
-
}, " 打开 ", 8,
|
|
3840
|
+
onClick: (u) => ya(r)
|
|
3841
|
+
}, " 打开 ", 8, ni),
|
|
3809
3842
|
l("button", {
|
|
3810
3843
|
class: "vpe-btn vpe-btn--sm",
|
|
3811
3844
|
type: "button",
|
|
3812
3845
|
title: `删除 ${r.name}`,
|
|
3813
3846
|
disabled: W.value,
|
|
3814
|
-
onClick: (u) =>
|
|
3815
|
-
}, " 删除 ", 8,
|
|
3847
|
+
onClick: (u) => ha(r)
|
|
3848
|
+
}, " 删除 ", 8, ri)
|
|
3816
3849
|
]))), 128)),
|
|
3817
|
-
|
|
3850
|
+
ze.value ? (m(), g("p", ai, R(ze.value), 1)) : T("", !0)
|
|
3818
3851
|
], 64))
|
|
3819
3852
|
])
|
|
3820
|
-
])) :
|
|
3821
|
-
Fe.value &&
|
|
3822
|
-
l("div",
|
|
3823
|
-
l("span",
|
|
3853
|
+
])) : T("", !0),
|
|
3854
|
+
Fe.value && pe.value ? (m(), g("div", si, [
|
|
3855
|
+
l("div", oi, [
|
|
3856
|
+
l("span", ii, R(Tr.value), 1),
|
|
3824
3857
|
t[40] || (t[40] = l("span", {
|
|
3825
3858
|
class: "vpe-spacer",
|
|
3826
3859
|
"aria-hidden": "true"
|
|
@@ -3830,27 +3863,27 @@ const Da = Z(
|
|
|
3830
3863
|
type: "button",
|
|
3831
3864
|
title: "关闭 SQL 连接配置",
|
|
3832
3865
|
"aria-label": "关闭 SQL 连接配置",
|
|
3833
|
-
onClick:
|
|
3866
|
+
onClick: xn
|
|
3834
3867
|
}, [
|
|
3835
|
-
|
|
3868
|
+
V(B(ct))
|
|
3836
3869
|
])
|
|
3837
3870
|
]),
|
|
3838
|
-
l("div",
|
|
3839
|
-
l("label",
|
|
3871
|
+
l("div", li, [
|
|
3872
|
+
l("label", ui, [
|
|
3840
3873
|
t[42] || (t[42] = l("span", { class: "vpe-sql-label" }, "执行方式", -1)),
|
|
3841
3874
|
J(l("select", {
|
|
3842
3875
|
"onUpdate:modelValue": t[7] || (t[7] = (r) => f.value.mode = r),
|
|
3843
3876
|
class: "vpe-sql-input",
|
|
3844
|
-
onChange:
|
|
3877
|
+
onChange: Dr
|
|
3845
3878
|
}, [...t[41] || (t[41] = [
|
|
3846
3879
|
l("option", { value: "sqlite" }, "浏览器内 SQLite(无需服务端)", -1),
|
|
3847
3880
|
l("option", { value: "http" }, "HTTP 服务(后端网关)", -1)
|
|
3848
3881
|
])], 544), [
|
|
3849
|
-
[
|
|
3882
|
+
[Et, f.value.mode]
|
|
3850
3883
|
])
|
|
3851
3884
|
]),
|
|
3852
|
-
f.value.mode === "sqlite" ? (m(), g(
|
|
3853
|
-
l("label",
|
|
3885
|
+
f.value.mode === "sqlite" ? (m(), g(A, { key: 0 }, [
|
|
3886
|
+
l("label", ci, [
|
|
3854
3887
|
t[43] || (t[43] = l("span", { class: "vpe-sql-label" }, "数据库文件", -1)),
|
|
3855
3888
|
J(l("input", {
|
|
3856
3889
|
"onUpdate:modelValue": t[8] || (t[8] = (r) => f.value.connection.database = r),
|
|
@@ -3864,36 +3897,36 @@ const Da = Z(
|
|
|
3864
3897
|
])
|
|
3865
3898
|
]),
|
|
3866
3899
|
t[44] || (t[44] = l("p", { class: "vpe-sql-hint" }, " SQLite 在浏览器内运行,数据仅保存在当前页面内存;“停止”或刷新后会丢失。 ", -1))
|
|
3867
|
-
], 64)) : (m(), g(
|
|
3868
|
-
l("label",
|
|
3900
|
+
], 64)) : (m(), g(A, { key: 1 }, [
|
|
3901
|
+
l("label", di, [
|
|
3869
3902
|
t[45] || (t[45] = l("span", { class: "vpe-sql-label" }, "连接名称", -1)),
|
|
3870
3903
|
J(l("input", {
|
|
3871
|
-
"onUpdate:modelValue": t[9] || (t[9] = (r) =>
|
|
3904
|
+
"onUpdate:modelValue": t[9] || (t[9] = (r) => ne.value = r),
|
|
3872
3905
|
class: "vpe-sql-input",
|
|
3873
3906
|
type: "text",
|
|
3874
3907
|
spellcheck: "false",
|
|
3875
3908
|
placeholder: "用于保存和切换连接"
|
|
3876
3909
|
}, null, 512), [
|
|
3877
|
-
[he,
|
|
3910
|
+
[he, ne.value]
|
|
3878
3911
|
])
|
|
3879
3912
|
]),
|
|
3880
|
-
l("label",
|
|
3913
|
+
l("label", pi, [
|
|
3881
3914
|
t[46] || (t[46] = l("span", { class: "vpe-sql-label" }, "数据库类型", -1)),
|
|
3882
3915
|
J(l("select", {
|
|
3883
3916
|
"onUpdate:modelValue": t[10] || (t[10] = (r) => f.value.connection.dialect = r),
|
|
3884
3917
|
class: "vpe-sql-input",
|
|
3885
|
-
onChange:
|
|
3918
|
+
onChange: zr
|
|
3886
3919
|
}, [
|
|
3887
|
-
(m(!0), g(
|
|
3920
|
+
(m(!0), g(A, null, te(B(dt), (r) => (m(), g("option", {
|
|
3888
3921
|
key: r.value,
|
|
3889
3922
|
value: r.value
|
|
3890
|
-
},
|
|
3923
|
+
}, R(r.label), 9, fi))), 128))
|
|
3891
3924
|
], 544), [
|
|
3892
|
-
[
|
|
3925
|
+
[Et, f.value.connection.dialect]
|
|
3893
3926
|
])
|
|
3894
3927
|
]),
|
|
3895
|
-
l("div",
|
|
3896
|
-
l("label",
|
|
3928
|
+
l("div", vi, [
|
|
3929
|
+
l("label", mi, [
|
|
3897
3930
|
t[47] || (t[47] = l("span", { class: "vpe-sql-label" }, "主机", -1)),
|
|
3898
3931
|
J(l("input", {
|
|
3899
3932
|
"onUpdate:modelValue": t[11] || (t[11] = (r) => f.value.connection.host = r),
|
|
@@ -3906,7 +3939,7 @@ const Da = Z(
|
|
|
3906
3939
|
[he, f.value.connection.host]
|
|
3907
3940
|
])
|
|
3908
3941
|
]),
|
|
3909
|
-
l("label",
|
|
3942
|
+
l("label", gi, [
|
|
3910
3943
|
t[48] || (t[48] = l("span", { class: "vpe-sql-label" }, "端口", -1)),
|
|
3911
3944
|
J(l("input", {
|
|
3912
3945
|
"onUpdate:modelValue": t[12] || (t[12] = (r) => f.value.connection.port = r),
|
|
@@ -3926,8 +3959,8 @@ const Da = Z(
|
|
|
3926
3959
|
])
|
|
3927
3960
|
])
|
|
3928
3961
|
]),
|
|
3929
|
-
l("div",
|
|
3930
|
-
l("label",
|
|
3962
|
+
l("div", yi, [
|
|
3963
|
+
l("label", hi, [
|
|
3931
3964
|
t[49] || (t[49] = l("span", { class: "vpe-sql-label" }, "用户名", -1)),
|
|
3932
3965
|
J(l("input", {
|
|
3933
3966
|
"onUpdate:modelValue": t[13] || (t[13] = (r) => f.value.connection.user = r),
|
|
@@ -3940,7 +3973,7 @@ const Da = Z(
|
|
|
3940
3973
|
[he, f.value.connection.user]
|
|
3941
3974
|
])
|
|
3942
3975
|
]),
|
|
3943
|
-
l("label",
|
|
3976
|
+
l("label", bi, [
|
|
3944
3977
|
t[50] || (t[50] = l("span", { class: "vpe-sql-label" }, "密码", -1)),
|
|
3945
3978
|
J(l("input", {
|
|
3946
3979
|
"onUpdate:modelValue": t[14] || (t[14] = (r) => f.value.connection.password = r),
|
|
@@ -3949,12 +3982,12 @@ const Da = Z(
|
|
|
3949
3982
|
autocomplete: "new-password",
|
|
3950
3983
|
placeholder: f.value.connectionId ? "已保存(留空不修改)" : "",
|
|
3951
3984
|
onChange: ye
|
|
3952
|
-
}, null, 40,
|
|
3985
|
+
}, null, 40, ki), [
|
|
3953
3986
|
[he, f.value.connection.password]
|
|
3954
3987
|
])
|
|
3955
3988
|
])
|
|
3956
3989
|
]),
|
|
3957
|
-
l("label",
|
|
3990
|
+
l("label", wi, [
|
|
3958
3991
|
t[51] || (t[51] = l("span", { class: "vpe-sql-label" }, "数据库名", -1)),
|
|
3959
3992
|
J(l("input", {
|
|
3960
3993
|
"onUpdate:modelValue": t[15] || (t[15] = (r) => f.value.connection.database = r),
|
|
@@ -3967,7 +4000,7 @@ const Da = Z(
|
|
|
3967
4000
|
[he, f.value.connection.database]
|
|
3968
4001
|
])
|
|
3969
4002
|
]),
|
|
3970
|
-
|
|
4003
|
+
s.sqlEndpointLocked ? T("", !0) : (m(), g("label", Si, [
|
|
3971
4004
|
t[52] || (t[52] = l("span", { class: "vpe-sql-label" }, "服务端点", -1)),
|
|
3972
4005
|
J(l("input", {
|
|
3973
4006
|
"onUpdate:modelValue": t[16] || (t[16] = (r) => f.value.endpoint = r),
|
|
@@ -3980,44 +4013,44 @@ const Da = Z(
|
|
|
3980
4013
|
[he, f.value.endpoint]
|
|
3981
4014
|
])
|
|
3982
4015
|
])),
|
|
3983
|
-
|
|
4016
|
+
s.sqlEndpointLocked ? (m(), g("p", xi, "服务端点由系统预置,无需填写。")) : T("", !0),
|
|
3984
4017
|
t[53] || (t[53] = l("p", { class: "vpe-sql-hint" }, " 执行时会把连接信息与 SQL POST 到该端点,由后端网关连接真实数据库。建议使用 HTTPS,并避免在前端配置高权限账号。 ", -1))
|
|
3985
4018
|
], 64)),
|
|
3986
|
-
l("div",
|
|
4019
|
+
l("div", Ei, [
|
|
3987
4020
|
l("button", {
|
|
3988
4021
|
class: "vpe-btn vpe-btn--primary",
|
|
3989
4022
|
type: "button",
|
|
3990
|
-
disabled:
|
|
3991
|
-
onClick:
|
|
3992
|
-
},
|
|
4023
|
+
disabled: _e.value,
|
|
4024
|
+
onClick: Zr
|
|
4025
|
+
}, R(_e.value ? "测试中…" : "测试连接"), 9, qi),
|
|
3993
4026
|
f.value.mode === "http" ? (m(), g("button", {
|
|
3994
4027
|
key: 0,
|
|
3995
4028
|
class: "vpe-btn",
|
|
3996
4029
|
type: "button",
|
|
3997
|
-
disabled:
|
|
3998
|
-
onClick:
|
|
3999
|
-
}, " 保存 ", 8,
|
|
4030
|
+
disabled: re.value,
|
|
4031
|
+
onClick: Qr
|
|
4032
|
+
}, " 保存 ", 8, Ci)) : T("", !0),
|
|
4000
4033
|
f.value.mode === "http" && f.value.connectionId ? (m(), g("button", {
|
|
4001
4034
|
key: 1,
|
|
4002
4035
|
class: "vpe-btn",
|
|
4003
4036
|
type: "button",
|
|
4004
|
-
disabled:
|
|
4005
|
-
onClick:
|
|
4006
|
-
}, " 删除 ", 8,
|
|
4007
|
-
|
|
4037
|
+
disabled: re.value,
|
|
4038
|
+
onClick: Kr
|
|
4039
|
+
}, " 删除 ", 8, Pi)) : T("", !0),
|
|
4040
|
+
nt.value ? (m(), g("span", {
|
|
4008
4041
|
key: 2,
|
|
4009
|
-
class:
|
|
4010
|
-
},
|
|
4011
|
-
f.value.mode === "http" && Pe.value ? (m(), g("span",
|
|
4012
|
-
f.value.mode === "http" &&
|
|
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", {
|
|
4013
4046
|
key: 4,
|
|
4014
|
-
class:
|
|
4015
|
-
},
|
|
4047
|
+
class: le(["vpe-sql-test", Ve.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
|
|
4048
|
+
}, R(ae.value), 3)) : T("", !0)
|
|
4016
4049
|
])
|
|
4017
4050
|
])
|
|
4018
|
-
])) :
|
|
4019
|
-
|
|
4020
|
-
l("div",
|
|
4051
|
+
])) : T("", !0),
|
|
4052
|
+
Re.value && pe.value ? (m(), g("div", Mi, [
|
|
4053
|
+
l("div", Ti, [
|
|
4021
4054
|
t[54] || (t[54] = l("span", { class: "vpe-fs-title" }, "连接管理", -1)),
|
|
4022
4055
|
t[55] || (t[55] = l("span", {
|
|
4023
4056
|
class: "vpe-spacer",
|
|
@@ -4027,96 +4060,96 @@ const Da = Z(
|
|
|
4027
4060
|
class: "vpe-btn vpe-btn--sm",
|
|
4028
4061
|
type: "button",
|
|
4029
4062
|
title: "刷新连接列表",
|
|
4030
|
-
disabled:
|
|
4031
|
-
onClick:
|
|
4032
|
-
}, " 刷新 ", 8,
|
|
4063
|
+
disabled: je.value,
|
|
4064
|
+
onClick: ve
|
|
4065
|
+
}, " 刷新 ", 8, Ni),
|
|
4033
4066
|
l("button", {
|
|
4034
4067
|
class: "vpe-btn vpe-btn--sm",
|
|
4035
4068
|
type: "button",
|
|
4036
4069
|
title: "关闭连接管理",
|
|
4037
4070
|
"aria-label": "关闭连接管理",
|
|
4038
|
-
onClick: t[17] || (t[17] = (r) =>
|
|
4071
|
+
onClick: t[17] || (t[17] = (r) => Re.value = !1)
|
|
4039
4072
|
}, [
|
|
4040
|
-
|
|
4073
|
+
V(B(ct))
|
|
4041
4074
|
])
|
|
4042
4075
|
]),
|
|
4043
|
-
l("div",
|
|
4044
|
-
|
|
4045
|
-
Ce.value.length ?
|
|
4046
|
-
(m(!0), g(
|
|
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", {
|
|
4047
4080
|
key: r.id,
|
|
4048
4081
|
class: "vpe-sql-manager-item"
|
|
4049
4082
|
}, [
|
|
4050
|
-
l("div",
|
|
4083
|
+
l("div", _i, [
|
|
4051
4084
|
l("span", {
|
|
4052
4085
|
class: "vpe-sql-manager-name",
|
|
4053
4086
|
title: r.name
|
|
4054
|
-
},
|
|
4055
|
-
l("span",
|
|
4056
|
-
|
|
4057
|
-
r.database ? (m(), g(
|
|
4058
|
-
|
|
4059
|
-
], 64)) :
|
|
4060
|
-
r.host ? (m(), g(
|
|
4061
|
-
|
|
4062
|
-
], 64)) :
|
|
4087
|
+
}, R(r.name), 9, Ri),
|
|
4088
|
+
l("span", Ii, [
|
|
4089
|
+
Wt(R(r.dialect), 1),
|
|
4090
|
+
r.database ? (m(), g(A, { key: 0 }, [
|
|
4091
|
+
Wt(" · " + R(r.database), 1)
|
|
4092
|
+
], 64)) : T("", !0),
|
|
4093
|
+
r.host ? (m(), g(A, { key: 1 }, [
|
|
4094
|
+
Wt(" · " + R(r.host), 1)
|
|
4095
|
+
], 64)) : T("", !0)
|
|
4063
4096
|
])
|
|
4064
4097
|
]),
|
|
4065
4098
|
l("button", {
|
|
4066
4099
|
class: "vpe-btn vpe-btn--sm",
|
|
4067
4100
|
type: "button",
|
|
4068
4101
|
title: "编辑连接",
|
|
4069
|
-
onClick: (u) =>
|
|
4070
|
-
}, " 编辑 ", 8,
|
|
4102
|
+
onClick: (u) => Vr(r)
|
|
4103
|
+
}, " 编辑 ", 8, Hi),
|
|
4071
4104
|
l("button", {
|
|
4072
4105
|
class: "vpe-btn vpe-btn--sm",
|
|
4073
4106
|
type: "button",
|
|
4074
4107
|
title: "删除连接",
|
|
4075
|
-
disabled:
|
|
4076
|
-
onClick: (u) =>
|
|
4077
|
-
}, " 删除 ", 8,
|
|
4108
|
+
disabled: re.value,
|
|
4109
|
+
onClick: (u) => Jr(r)
|
|
4110
|
+
}, " 删除 ", 8, Bi)
|
|
4078
4111
|
]))), 128)),
|
|
4079
|
-
Pe.value ? (m(), g("p",
|
|
4080
|
-
|
|
4112
|
+
Pe.value ? (m(), g("p", Ui, R(Pe.value), 1)) : T("", !0),
|
|
4113
|
+
Qe.value ? (m(), g("p", {
|
|
4081
4114
|
key: 2,
|
|
4082
|
-
class:
|
|
4083
|
-
},
|
|
4115
|
+
class: le(["vpe-sql-hint", mt.value ? "vpe-sql-hint--ok" : "vpe-sql-hint--error"])
|
|
4116
|
+
}, R(Qe.value), 3)) : T("", !0)
|
|
4084
4117
|
], 64))
|
|
4085
4118
|
])
|
|
4086
|
-
])) :
|
|
4119
|
+
])) : T("", !0)
|
|
4087
4120
|
], 6));
|
|
4088
4121
|
}
|
|
4089
4122
|
});
|
|
4090
|
-
function
|
|
4123
|
+
function nl(s = {}) {
|
|
4091
4124
|
var Ae;
|
|
4092
|
-
const n =
|
|
4125
|
+
const n = un(s.pyodideUrl ? { pyodideUrl: s.pyodideUrl } : void 0), a = C(n.status), o = C(""), i = C([]);
|
|
4093
4126
|
let p = 0;
|
|
4094
4127
|
const b = (H, k) => {
|
|
4095
4128
|
i.value.push({ id: ++p, stream: H, text: k });
|
|
4096
4129
|
}, E = n.on("status", (H, k) => {
|
|
4097
|
-
|
|
4098
|
-
}),
|
|
4130
|
+
a.value = H, k && (o.value = k);
|
|
4131
|
+
}), _ = n.on("initError", (H) => {
|
|
4099
4132
|
b("system", `[pyodide] 加载失败:${H}`);
|
|
4100
4133
|
});
|
|
4101
|
-
|
|
4102
|
-
E(),
|
|
4134
|
+
Ia(() => {
|
|
4135
|
+
E(), _();
|
|
4103
4136
|
});
|
|
4104
|
-
const
|
|
4137
|
+
const O = async (H, k = {}) => {
|
|
4105
4138
|
var I;
|
|
4106
4139
|
try {
|
|
4107
|
-
const
|
|
4140
|
+
const z = await n.run(H, {
|
|
4108
4141
|
stdin: k.stdin,
|
|
4109
|
-
onOutput: (
|
|
4142
|
+
onOutput: (ce, Se) => b(ce, Se)
|
|
4110
4143
|
});
|
|
4111
|
-
return !
|
|
4112
|
-
} catch (
|
|
4144
|
+
return !z.ok && ((I = z.error) != null && I.traceback) && b("stderr", z.error.traceback), z;
|
|
4145
|
+
} catch (z) {
|
|
4113
4146
|
return {
|
|
4114
4147
|
ok: !1,
|
|
4115
4148
|
durationMs: 0,
|
|
4116
|
-
error: { type: "RuntimeError", message:
|
|
4149
|
+
error: { type: "RuntimeError", message: z instanceof Error ? z.message : String(z), traceback: "" }
|
|
4117
4150
|
};
|
|
4118
4151
|
}
|
|
4119
|
-
},
|
|
4152
|
+
}, N = async (H, k) => {
|
|
4120
4153
|
try {
|
|
4121
4154
|
return await n.writeFile(H, k);
|
|
4122
4155
|
} catch (I) {
|
|
@@ -4146,10 +4179,10 @@ function Ki(a = {}) {
|
|
|
4146
4179
|
}
|
|
4147
4180
|
};
|
|
4148
4181
|
let G = !1;
|
|
4149
|
-
const
|
|
4182
|
+
const me = async () => {
|
|
4150
4183
|
var I;
|
|
4151
4184
|
if (G) return;
|
|
4152
|
-
const H =
|
|
4185
|
+
const H = s.preloadPackages ?? [];
|
|
4153
4186
|
if (!H.length) return;
|
|
4154
4187
|
G = !0, b("system", `[pyodide] 正在安装预置包:${H.join(", ")}`);
|
|
4155
4188
|
const k = await q(H);
|
|
@@ -4158,56 +4191,56 @@ function Ki(a = {}) {
|
|
|
4158
4191
|
k.ok ? `[pyodide] 预置包安装完成(${(k.durationMs / 1e3).toFixed(1)}s)` : `[pyodide] 预置包安装失败:${((I = k.error) == null ? void 0 : I.message) ?? "未知错误"}`
|
|
4159
4192
|
);
|
|
4160
4193
|
};
|
|
4161
|
-
return (
|
|
4194
|
+
return (s.preload || (((Ae = s.preloadPackages) == null ? void 0 : Ae.length) ?? 0) > 0) && n.waitReady().then(() => me()).catch(() => {
|
|
4162
4195
|
}), {
|
|
4163
|
-
status:
|
|
4196
|
+
status: a,
|
|
4164
4197
|
version: o,
|
|
4165
4198
|
outputs: i,
|
|
4166
|
-
runPython:
|
|
4199
|
+
runPython: O,
|
|
4167
4200
|
install: q,
|
|
4168
4201
|
checkSyntax: (H) => n.checkSyntax(H),
|
|
4169
4202
|
interrupt: () => n.interrupt(),
|
|
4170
4203
|
clearOutputs: () => {
|
|
4171
4204
|
i.value = [];
|
|
4172
4205
|
},
|
|
4173
|
-
writeFile:
|
|
4206
|
+
writeFile: N,
|
|
4174
4207
|
readFile: x,
|
|
4175
4208
|
listFiles: F,
|
|
4176
4209
|
/** 预加载并在就绪后 resolve */
|
|
4177
4210
|
ready: () => n.waitReady()
|
|
4178
4211
|
};
|
|
4179
4212
|
}
|
|
4180
|
-
const
|
|
4213
|
+
const rl = Ai;
|
|
4181
4214
|
export {
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
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,
|
|
4235
|
+
D as normalizeSqlConfig,
|
|
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
|
|
4213
4246
|
};
|