princess-python-editor 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -55
- package/dist/PythonEditor.vue.d.ts +18 -0
- package/dist/icons.d.ts +2 -0
- package/dist/index.cjs.js +6 -6
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +1150 -1115
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var La = (s, n, a) => n in s ?
|
|
1
|
+
var Fa = Object.defineProperty;
|
|
2
|
+
var La = (s, n, a) => n in s ? Fa(s, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[n] = a;
|
|
3
3
|
var ie = (s, n, a) => La(s, typeof n != "symbol" ? n + "" : n, a);
|
|
4
|
-
import { h as
|
|
5
|
-
import { EditorState as nn, StateEffect as
|
|
6
|
-
import { EditorView 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
|
|
4
|
+
import { h as Jn, defineComponent as $a, ref as C, reactive as Zn, computed as U, onMounted as Ra, onBeforeUnmount as _a, watch as ee, nextTick as Gn, openBlock as p, createElementBlock as m, normalizeStyle as Wn, normalizeClass as le, createElementVNode as l, createVNode as z, unref as H, createCommentVNode as O, createBlock as Yn, withDirectives as Z, vModelText as ge, Fragment as A, renderList as te, toDisplayString as _, vModelSelect as Et, withModifiers as Xn, withKeys as Ia, createTextVNode as Wt, onScopeDispose as Ha } from "vue";
|
|
5
|
+
import { EditorState as nn, StateEffect as Ba, StateField as Ua, Compartment as qt } from "@codemirror/state";
|
|
6
|
+
import { EditorView as Le, keymap as er, lineNumbers as Aa, highlightActiveLineGutter as Da, highlightActiveLine as za, drawSelection as ja, placeholder as Va, Decoration as rn } from "@codemirror/view";
|
|
7
|
+
import { linter as Qa, forceLinting as Ka } from "@codemirror/lint";
|
|
8
|
+
import { autocompletion as Ja, closeBrackets as Za, closeBracketsKeymap as Ga } from "@codemirror/autocomplete";
|
|
9
|
+
import { history as Wa, defaultKeymap as Ya, historyKeymap as Xa, indentWithTab as es } from "@codemirror/commands";
|
|
10
|
+
import { syntaxHighlighting as ts, HighlightStyle as ns, indentUnit as rs, bracketMatching as as } from "@codemirror/language";
|
|
11
|
+
import { python as yr } from "@codemirror/lang-python";
|
|
12
|
+
import { javascript as ss } from "@codemirror/lang-javascript";
|
|
13
|
+
import { json as os } from "@codemirror/lang-json";
|
|
14
|
+
import { sql as is } from "@codemirror/lang-sql";
|
|
15
|
+
let ls = 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 = ls++, 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
|
}
|
|
@@ -51,7 +51,7 @@ K.isolate = new K({ deserialize: (s) => {
|
|
|
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
|
|
54
|
+
const us = /* @__PURE__ */ Object.create(null);
|
|
55
55
|
class pt {
|
|
56
56
|
/**
|
|
57
57
|
@internal
|
|
@@ -63,13 +63,13 @@ class pt {
|
|
|
63
63
|
Define a node type.
|
|
64
64
|
*/
|
|
65
65
|
static define(n) {
|
|
66
|
-
let a = n.props && n.props.length ? /* @__PURE__ */ Object.create(null) :
|
|
66
|
+
let a = n.props && n.props.length ? /* @__PURE__ */ Object.create(null) : us, 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
|
-
for (let
|
|
69
|
-
if (Array.isArray(
|
|
70
|
-
if (
|
|
68
|
+
for (let f of n.props)
|
|
69
|
+
if (Array.isArray(f) || (f = f(i)), f) {
|
|
70
|
+
if (f[0].perNode)
|
|
71
71
|
throw new RangeError("Can't store a per-node prop on a node type");
|
|
72
|
-
a[
|
|
72
|
+
a[f[0].id] = f[1];
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return i;
|
|
@@ -133,8 +133,8 @@ class pt {
|
|
|
133
133
|
for (let i of o.split(" "))
|
|
134
134
|
a[i] = n[o];
|
|
135
135
|
return (o) => {
|
|
136
|
-
for (let i = o.prop(K.group),
|
|
137
|
-
let b = a[
|
|
136
|
+
for (let i = o.prop(K.group), f = -1; f < (i ? i.length : 0); f++) {
|
|
137
|
+
let b = a[f < 0 ? o.name : i[f]];
|
|
138
138
|
if (b)
|
|
139
139
|
return b;
|
|
140
140
|
}
|
|
@@ -148,18 +148,18 @@ pt.none = new pt(
|
|
|
148
148
|
8
|
|
149
149
|
/* NodeFlag.Anonymous */
|
|
150
150
|
);
|
|
151
|
-
var
|
|
151
|
+
var tr;
|
|
152
152
|
(function(s) {
|
|
153
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
|
-
})(
|
|
154
|
+
})(tr || (tr = {}));
|
|
155
155
|
new K({ perNode: !0 });
|
|
156
|
-
let
|
|
156
|
+
let cs = 0;
|
|
157
157
|
class ue {
|
|
158
158
|
/**
|
|
159
159
|
@internal
|
|
160
160
|
*/
|
|
161
161
|
constructor(n, a, o, i) {
|
|
162
|
-
this.name = n, this.set = a, this.base = o, this.modified = i, this.id =
|
|
162
|
+
this.name = n, this.set = a, this.base = o, this.modified = i, this.id = cs++;
|
|
163
163
|
}
|
|
164
164
|
toString() {
|
|
165
165
|
let { name: n } = this;
|
|
@@ -173,8 +173,8 @@ class ue {
|
|
|
173
173
|
throw new Error("Can not derive from a modified tag");
|
|
174
174
|
let i = new ue(o, [], null, []);
|
|
175
175
|
if (i.set.push(i), a)
|
|
176
|
-
for (let
|
|
177
|
-
i.set.push(
|
|
176
|
+
for (let f of a.set)
|
|
177
|
+
i.set.push(f);
|
|
178
178
|
return i;
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
@@ -190,36 +190,36 @@ class ue {
|
|
|
190
190
|
`m1(m3(t1)`, and so on.
|
|
191
191
|
*/
|
|
192
192
|
static defineModifier(n) {
|
|
193
|
-
let a = new
|
|
194
|
-
return (o) => o.modified.indexOf(a) > -1 ? o :
|
|
193
|
+
let a = new Tt(n);
|
|
194
|
+
return (o) => o.modified.indexOf(a) > -1 ? o : Tt.get(o.base || o, o.modified.concat(a).sort((i, f) => i.id - f.id));
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
let
|
|
198
|
-
class
|
|
197
|
+
let ds = 0;
|
|
198
|
+
class Tt {
|
|
199
199
|
constructor(n) {
|
|
200
|
-
this.name = n, this.instances = [], this.id =
|
|
200
|
+
this.name = n, this.instances = [], this.id = ds++;
|
|
201
201
|
}
|
|
202
202
|
static get(n, a) {
|
|
203
203
|
if (!a.length)
|
|
204
204
|
return n;
|
|
205
|
-
let o = a[0].instances.find((E) => E.base == n &&
|
|
205
|
+
let o = a[0].instances.find((E) => E.base == n && ps(a, E.modified));
|
|
206
206
|
if (o)
|
|
207
207
|
return o;
|
|
208
|
-
let i = [],
|
|
208
|
+
let i = [], f = new ue(n.name, i, n, a);
|
|
209
209
|
for (let E of a)
|
|
210
|
-
E.instances.push(
|
|
211
|
-
let b =
|
|
210
|
+
E.instances.push(f);
|
|
211
|
+
let b = fs(a);
|
|
212
212
|
for (let E of n.set)
|
|
213
213
|
if (!E.modified.length)
|
|
214
|
-
for (let
|
|
215
|
-
i.push(
|
|
216
|
-
return
|
|
214
|
+
for (let R of b)
|
|
215
|
+
i.push(Tt.get(E, R));
|
|
216
|
+
return f;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function ps(s, n) {
|
|
220
220
|
return s.length == n.length && s.every((a, o) => a == n[o]);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function fs(s) {
|
|
223
223
|
let n = [[]];
|
|
224
224
|
for (let a = 0; a < s.length; a++)
|
|
225
225
|
for (let o = 0, i = n.length; o < i; o++)
|
|
@@ -232,8 +232,8 @@ new K({
|
|
|
232
232
|
for (; s || n; ) {
|
|
233
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
|
|
236
|
-
a ? a.next =
|
|
235
|
+
let f = new an(i.tags, i.mode, i.context);
|
|
236
|
+
a ? a.next = f : o = f, a = f;
|
|
237
237
|
}
|
|
238
238
|
return o;
|
|
239
239
|
}
|
|
@@ -256,23 +256,23 @@ class an {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
an.empty = new an([], 2, null);
|
|
259
|
-
function
|
|
259
|
+
function vs(s, n) {
|
|
260
260
|
let a = /* @__PURE__ */ Object.create(null);
|
|
261
|
-
for (let
|
|
262
|
-
if (!Array.isArray(
|
|
263
|
-
a[
|
|
261
|
+
for (let f of s)
|
|
262
|
+
if (!Array.isArray(f.tag))
|
|
263
|
+
a[f.tag.id] = f.class;
|
|
264
264
|
else
|
|
265
|
-
for (let b of
|
|
266
|
-
a[b.id] =
|
|
265
|
+
for (let b of f.tag)
|
|
266
|
+
a[b.id] = f.class;
|
|
267
267
|
let { scope: o, all: i = null } = {};
|
|
268
268
|
return {
|
|
269
|
-
style: (
|
|
269
|
+
style: (f) => {
|
|
270
270
|
let b = i;
|
|
271
|
-
for (let E of
|
|
272
|
-
for (let
|
|
273
|
-
let
|
|
274
|
-
if (
|
|
275
|
-
b = b ? b + " " +
|
|
271
|
+
for (let E of f)
|
|
272
|
+
for (let R of E.set) {
|
|
273
|
+
let M = a[R.id];
|
|
274
|
+
if (M) {
|
|
275
|
+
b = b ? b + " " + M : M;
|
|
276
276
|
break;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
@@ -281,7 +281,7 @@ function fs(s, n) {
|
|
|
281
281
|
scope: o
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
const
|
|
284
|
+
const y = ue.define, Ct = y(), Te = y(), nr = y(Te), rr = y(Te), Fe = y(), Pt = y(Fe), Yt = y(Fe), we = y(), Ue = y(we), be = y(), ke = y(), sn = y(), lt = y(sn), Ot = y(), d = {
|
|
285
285
|
/**
|
|
286
286
|
A comment.
|
|
287
287
|
*/
|
|
@@ -289,59 +289,59 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
289
289
|
/**
|
|
290
290
|
A line [comment](#highlight.tags.comment).
|
|
291
291
|
*/
|
|
292
|
-
lineComment:
|
|
292
|
+
lineComment: y(Ct),
|
|
293
293
|
/**
|
|
294
294
|
A block [comment](#highlight.tags.comment).
|
|
295
295
|
*/
|
|
296
|
-
blockComment:
|
|
296
|
+
blockComment: y(Ct),
|
|
297
297
|
/**
|
|
298
298
|
A documentation [comment](#highlight.tags.comment).
|
|
299
299
|
*/
|
|
300
|
-
docComment:
|
|
300
|
+
docComment: y(Ct),
|
|
301
301
|
/**
|
|
302
302
|
Any kind of identifier.
|
|
303
303
|
*/
|
|
304
|
-
name:
|
|
304
|
+
name: Te,
|
|
305
305
|
/**
|
|
306
306
|
The [name](#highlight.tags.name) of a variable.
|
|
307
307
|
*/
|
|
308
|
-
variableName:
|
|
308
|
+
variableName: y(Te),
|
|
309
309
|
/**
|
|
310
310
|
A type [name](#highlight.tags.name).
|
|
311
311
|
*/
|
|
312
|
-
typeName:
|
|
312
|
+
typeName: nr,
|
|
313
313
|
/**
|
|
314
314
|
A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
|
315
315
|
*/
|
|
316
|
-
tagName:
|
|
316
|
+
tagName: y(nr),
|
|
317
317
|
/**
|
|
318
318
|
A property or field [name](#highlight.tags.name).
|
|
319
319
|
*/
|
|
320
|
-
propertyName:
|
|
320
|
+
propertyName: rr,
|
|
321
321
|
/**
|
|
322
322
|
An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
|
323
323
|
*/
|
|
324
|
-
attributeName:
|
|
324
|
+
attributeName: y(rr),
|
|
325
325
|
/**
|
|
326
326
|
The [name](#highlight.tags.name) of a class.
|
|
327
327
|
*/
|
|
328
|
-
className:
|
|
328
|
+
className: y(Te),
|
|
329
329
|
/**
|
|
330
330
|
A label [name](#highlight.tags.name).
|
|
331
331
|
*/
|
|
332
|
-
labelName:
|
|
332
|
+
labelName: y(Te),
|
|
333
333
|
/**
|
|
334
334
|
A namespace [name](#highlight.tags.name).
|
|
335
335
|
*/
|
|
336
|
-
namespace:
|
|
336
|
+
namespace: y(Te),
|
|
337
337
|
/**
|
|
338
338
|
The [name](#highlight.tags.name) of a macro.
|
|
339
339
|
*/
|
|
340
|
-
macroName:
|
|
340
|
+
macroName: y(Te),
|
|
341
341
|
/**
|
|
342
342
|
A literal value.
|
|
343
343
|
*/
|
|
344
|
-
literal:
|
|
344
|
+
literal: Fe,
|
|
345
345
|
/**
|
|
346
346
|
A string [literal](#highlight.tags.literal).
|
|
347
347
|
*/
|
|
@@ -349,15 +349,15 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
349
349
|
/**
|
|
350
350
|
A documentation [string](#highlight.tags.string).
|
|
351
351
|
*/
|
|
352
|
-
docString:
|
|
352
|
+
docString: y(Pt),
|
|
353
353
|
/**
|
|
354
354
|
A character literal (subtag of [string](#highlight.tags.string)).
|
|
355
355
|
*/
|
|
356
|
-
character:
|
|
356
|
+
character: y(Pt),
|
|
357
357
|
/**
|
|
358
358
|
An attribute value (subtag of [string](#highlight.tags.string)).
|
|
359
359
|
*/
|
|
360
|
-
attributeValue:
|
|
360
|
+
attributeValue: y(Pt),
|
|
361
361
|
/**
|
|
362
362
|
A number [literal](#highlight.tags.literal).
|
|
363
363
|
*/
|
|
@@ -365,32 +365,32 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
365
365
|
/**
|
|
366
366
|
An integer [number](#highlight.tags.number) literal.
|
|
367
367
|
*/
|
|
368
|
-
integer:
|
|
368
|
+
integer: y(Yt),
|
|
369
369
|
/**
|
|
370
370
|
A floating-point [number](#highlight.tags.number) literal.
|
|
371
371
|
*/
|
|
372
|
-
float:
|
|
372
|
+
float: y(Yt),
|
|
373
373
|
/**
|
|
374
374
|
A boolean [literal](#highlight.tags.literal).
|
|
375
375
|
*/
|
|
376
|
-
bool:
|
|
376
|
+
bool: y(Fe),
|
|
377
377
|
/**
|
|
378
378
|
Regular expression [literal](#highlight.tags.literal).
|
|
379
379
|
*/
|
|
380
|
-
regexp:
|
|
380
|
+
regexp: y(Fe),
|
|
381
381
|
/**
|
|
382
382
|
An escape [literal](#highlight.tags.literal), for example a
|
|
383
383
|
backslash escape in a string.
|
|
384
384
|
*/
|
|
385
|
-
escape:
|
|
385
|
+
escape: y(Fe),
|
|
386
386
|
/**
|
|
387
387
|
A color [literal](#highlight.tags.literal).
|
|
388
388
|
*/
|
|
389
|
-
color:
|
|
389
|
+
color: y(Fe),
|
|
390
390
|
/**
|
|
391
391
|
A URL [literal](#highlight.tags.literal).
|
|
392
392
|
*/
|
|
393
|
-
url:
|
|
393
|
+
url: y(Fe),
|
|
394
394
|
/**
|
|
395
395
|
A language keyword.
|
|
396
396
|
*/
|
|
@@ -399,40 +399,40 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
399
399
|
The [keyword](#highlight.tags.keyword) for the self or this
|
|
400
400
|
object.
|
|
401
401
|
*/
|
|
402
|
-
self:
|
|
402
|
+
self: y(be),
|
|
403
403
|
/**
|
|
404
404
|
The [keyword](#highlight.tags.keyword) for null.
|
|
405
405
|
*/
|
|
406
|
-
null:
|
|
406
|
+
null: y(be),
|
|
407
407
|
/**
|
|
408
408
|
A [keyword](#highlight.tags.keyword) denoting some atomic value.
|
|
409
409
|
*/
|
|
410
|
-
atom:
|
|
410
|
+
atom: y(be),
|
|
411
411
|
/**
|
|
412
412
|
A [keyword](#highlight.tags.keyword) that represents a unit.
|
|
413
413
|
*/
|
|
414
|
-
unit:
|
|
414
|
+
unit: y(be),
|
|
415
415
|
/**
|
|
416
416
|
A modifier [keyword](#highlight.tags.keyword).
|
|
417
417
|
*/
|
|
418
|
-
modifier:
|
|
418
|
+
modifier: y(be),
|
|
419
419
|
/**
|
|
420
420
|
A [keyword](#highlight.tags.keyword) that acts as an operator.
|
|
421
421
|
*/
|
|
422
|
-
operatorKeyword:
|
|
422
|
+
operatorKeyword: y(be),
|
|
423
423
|
/**
|
|
424
424
|
A control-flow related [keyword](#highlight.tags.keyword).
|
|
425
425
|
*/
|
|
426
|
-
controlKeyword:
|
|
426
|
+
controlKeyword: y(be),
|
|
427
427
|
/**
|
|
428
428
|
A [keyword](#highlight.tags.keyword) that defines something.
|
|
429
429
|
*/
|
|
430
|
-
definitionKeyword:
|
|
430
|
+
definitionKeyword: y(be),
|
|
431
431
|
/**
|
|
432
432
|
A [keyword](#highlight.tags.keyword) related to defining or
|
|
433
433
|
interfacing with modules.
|
|
434
434
|
*/
|
|
435
|
-
moduleKeyword:
|
|
435
|
+
moduleKeyword: y(be),
|
|
436
436
|
/**
|
|
437
437
|
An operator.
|
|
438
438
|
*/
|
|
@@ -440,39 +440,39 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
440
440
|
/**
|
|
441
441
|
An [operator](#highlight.tags.operator) that dereferences something.
|
|
442
442
|
*/
|
|
443
|
-
derefOperator:
|
|
443
|
+
derefOperator: y(ke),
|
|
444
444
|
/**
|
|
445
445
|
Arithmetic-related [operator](#highlight.tags.operator).
|
|
446
446
|
*/
|
|
447
|
-
arithmeticOperator:
|
|
447
|
+
arithmeticOperator: y(ke),
|
|
448
448
|
/**
|
|
449
449
|
Logical [operator](#highlight.tags.operator).
|
|
450
450
|
*/
|
|
451
|
-
logicOperator:
|
|
451
|
+
logicOperator: y(ke),
|
|
452
452
|
/**
|
|
453
453
|
Bit [operator](#highlight.tags.operator).
|
|
454
454
|
*/
|
|
455
|
-
bitwiseOperator:
|
|
455
|
+
bitwiseOperator: y(ke),
|
|
456
456
|
/**
|
|
457
457
|
Comparison [operator](#highlight.tags.operator).
|
|
458
458
|
*/
|
|
459
|
-
compareOperator:
|
|
459
|
+
compareOperator: y(ke),
|
|
460
460
|
/**
|
|
461
461
|
[Operator](#highlight.tags.operator) that updates its operand.
|
|
462
462
|
*/
|
|
463
|
-
updateOperator:
|
|
463
|
+
updateOperator: y(ke),
|
|
464
464
|
/**
|
|
465
465
|
[Operator](#highlight.tags.operator) that defines something.
|
|
466
466
|
*/
|
|
467
|
-
definitionOperator:
|
|
467
|
+
definitionOperator: y(ke),
|
|
468
468
|
/**
|
|
469
469
|
Type-related [operator](#highlight.tags.operator).
|
|
470
470
|
*/
|
|
471
|
-
typeOperator:
|
|
471
|
+
typeOperator: y(ke),
|
|
472
472
|
/**
|
|
473
473
|
Control-flow [operator](#highlight.tags.operator).
|
|
474
474
|
*/
|
|
475
|
-
controlOperator:
|
|
475
|
+
controlOperator: y(ke),
|
|
476
476
|
/**
|
|
477
477
|
Program or markup punctuation.
|
|
478
478
|
*/
|
|
@@ -481,7 +481,7 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
481
481
|
[Punctuation](#highlight.tags.punctuation) that separates
|
|
482
482
|
things.
|
|
483
483
|
*/
|
|
484
|
-
separator:
|
|
484
|
+
separator: y(sn),
|
|
485
485
|
/**
|
|
486
486
|
Bracket-style [punctuation](#highlight.tags.punctuation).
|
|
487
487
|
*/
|
|
@@ -490,22 +490,22 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
490
490
|
Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
|
491
491
|
tokens).
|
|
492
492
|
*/
|
|
493
|
-
angleBracket:
|
|
493
|
+
angleBracket: y(lt),
|
|
494
494
|
/**
|
|
495
495
|
Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
|
496
496
|
tokens).
|
|
497
497
|
*/
|
|
498
|
-
squareBracket:
|
|
498
|
+
squareBracket: y(lt),
|
|
499
499
|
/**
|
|
500
500
|
Parentheses (usually `(` and `)` tokens). Subtag of
|
|
501
501
|
[bracket](#highlight.tags.bracket).
|
|
502
502
|
*/
|
|
503
|
-
paren:
|
|
503
|
+
paren: y(lt),
|
|
504
504
|
/**
|
|
505
505
|
Braces (usually `{` and `}` tokens). Subtag of
|
|
506
506
|
[bracket](#highlight.tags.bracket).
|
|
507
507
|
*/
|
|
508
|
-
brace:
|
|
508
|
+
brace: y(lt),
|
|
509
509
|
/**
|
|
510
510
|
Content, for example plain text in XML or markup documents.
|
|
511
511
|
*/
|
|
@@ -513,81 +513,81 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
513
513
|
/**
|
|
514
514
|
[Content](#highlight.tags.content) that represents a heading.
|
|
515
515
|
*/
|
|
516
|
-
heading:
|
|
516
|
+
heading: Ue,
|
|
517
517
|
/**
|
|
518
518
|
A level 1 [heading](#highlight.tags.heading).
|
|
519
519
|
*/
|
|
520
|
-
heading1:
|
|
520
|
+
heading1: y(Ue),
|
|
521
521
|
/**
|
|
522
522
|
A level 2 [heading](#highlight.tags.heading).
|
|
523
523
|
*/
|
|
524
|
-
heading2:
|
|
524
|
+
heading2: y(Ue),
|
|
525
525
|
/**
|
|
526
526
|
A level 3 [heading](#highlight.tags.heading).
|
|
527
527
|
*/
|
|
528
|
-
heading3:
|
|
528
|
+
heading3: y(Ue),
|
|
529
529
|
/**
|
|
530
530
|
A level 4 [heading](#highlight.tags.heading).
|
|
531
531
|
*/
|
|
532
|
-
heading4:
|
|
532
|
+
heading4: y(Ue),
|
|
533
533
|
/**
|
|
534
534
|
A level 5 [heading](#highlight.tags.heading).
|
|
535
535
|
*/
|
|
536
|
-
heading5:
|
|
536
|
+
heading5: y(Ue),
|
|
537
537
|
/**
|
|
538
538
|
A level 6 [heading](#highlight.tags.heading).
|
|
539
539
|
*/
|
|
540
|
-
heading6:
|
|
540
|
+
heading6: y(Ue),
|
|
541
541
|
/**
|
|
542
542
|
A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
|
|
543
543
|
*/
|
|
544
|
-
contentSeparator:
|
|
544
|
+
contentSeparator: y(we),
|
|
545
545
|
/**
|
|
546
546
|
[Content](#highlight.tags.content) that represents a list.
|
|
547
547
|
*/
|
|
548
|
-
list:
|
|
548
|
+
list: y(we),
|
|
549
549
|
/**
|
|
550
550
|
[Content](#highlight.tags.content) that represents a quote.
|
|
551
551
|
*/
|
|
552
|
-
quote:
|
|
552
|
+
quote: y(we),
|
|
553
553
|
/**
|
|
554
554
|
[Content](#highlight.tags.content) that is emphasized.
|
|
555
555
|
*/
|
|
556
|
-
emphasis:
|
|
556
|
+
emphasis: y(we),
|
|
557
557
|
/**
|
|
558
558
|
[Content](#highlight.tags.content) that is styled strong.
|
|
559
559
|
*/
|
|
560
|
-
strong:
|
|
560
|
+
strong: y(we),
|
|
561
561
|
/**
|
|
562
562
|
[Content](#highlight.tags.content) that is part of a link.
|
|
563
563
|
*/
|
|
564
|
-
link:
|
|
564
|
+
link: y(we),
|
|
565
565
|
/**
|
|
566
566
|
[Content](#highlight.tags.content) that is styled as code or
|
|
567
567
|
monospace.
|
|
568
568
|
*/
|
|
569
|
-
monospace:
|
|
569
|
+
monospace: y(we),
|
|
570
570
|
/**
|
|
571
571
|
[Content](#highlight.tags.content) that has a strike-through
|
|
572
572
|
style.
|
|
573
573
|
*/
|
|
574
|
-
strikethrough:
|
|
574
|
+
strikethrough: y(we),
|
|
575
575
|
/**
|
|
576
576
|
Inserted text in a change-tracking format.
|
|
577
577
|
*/
|
|
578
|
-
inserted:
|
|
578
|
+
inserted: y(),
|
|
579
579
|
/**
|
|
580
580
|
Deleted text.
|
|
581
581
|
*/
|
|
582
|
-
deleted:
|
|
582
|
+
deleted: y(),
|
|
583
583
|
/**
|
|
584
584
|
Changed text.
|
|
585
585
|
*/
|
|
586
|
-
changed:
|
|
586
|
+
changed: y(),
|
|
587
587
|
/**
|
|
588
588
|
An invalid or unsyntactic element.
|
|
589
589
|
*/
|
|
590
|
-
invalid:
|
|
590
|
+
invalid: y(),
|
|
591
591
|
/**
|
|
592
592
|
Metadata or meta-instruction.
|
|
593
593
|
*/
|
|
@@ -596,17 +596,17 @@ const v = ue.define, Ct = v(), Ne = v(), tr = v(Ne), nr = v(Ne), Le = v(), Pt =
|
|
|
596
596
|
[Metadata](#highlight.tags.meta) that applies to the entire
|
|
597
597
|
document.
|
|
598
598
|
*/
|
|
599
|
-
documentMeta:
|
|
599
|
+
documentMeta: y(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:
|
|
604
|
+
annotation: y(Ot),
|
|
605
605
|
/**
|
|
606
606
|
Processing instruction or preprocessor directive. Subtag of
|
|
607
607
|
[meta](#highlight.tags.meta).
|
|
608
608
|
*/
|
|
609
|
-
processingInstruction:
|
|
609
|
+
processingInstruction: y(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
|
|
@@ -651,7 +651,7 @@ for (let s in d) {
|
|
|
651
651
|
let n = d[s];
|
|
652
652
|
n instanceof ue && (n.name = s);
|
|
653
653
|
}
|
|
654
|
-
|
|
654
|
+
vs([
|
|
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 @@ fs([
|
|
|
683
683
|
{ tag: d.invalid, class: "tok-invalid" },
|
|
684
684
|
{ tag: d.punctuation, class: "tok-punctuation" }
|
|
685
685
|
]);
|
|
686
|
-
const
|
|
686
|
+
const ms = {
|
|
687
687
|
"&": {
|
|
688
688
|
backgroundColor: "var(--vpe-editor-bg)",
|
|
689
689
|
color: "var(--vpe-text)"
|
|
@@ -738,7 +738,7 @@ const vs = {
|
|
|
738
738
|
".cm-panels.cm-panels-bottom": {
|
|
739
739
|
borderTop: "1px solid var(--vpe-border)"
|
|
740
740
|
}
|
|
741
|
-
},
|
|
741
|
+
}, ys = ns.define([
|
|
742
742
|
{ tag: d.comment, color: "var(--vpe-syn-comment)", fontStyle: "italic" },
|
|
743
743
|
{
|
|
744
744
|
tag: [
|
|
@@ -783,28 +783,28 @@ const vs = {
|
|
|
783
783
|
{ tag: d.strikethrough, textDecoration: "line-through" },
|
|
784
784
|
{ tag: d.invalid, color: "var(--vpe-syn-invalid)" }
|
|
785
785
|
]);
|
|
786
|
-
function
|
|
787
|
-
return [
|
|
786
|
+
function Nt(s) {
|
|
787
|
+
return [Le.theme(ms, { dark: s }), ts(ys)];
|
|
788
788
|
}
|
|
789
|
-
const
|
|
790
|
-
function
|
|
789
|
+
const hs = "'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace", hr = Ba.define();
|
|
790
|
+
function gs(s, n) {
|
|
791
791
|
const a = s.filter((o) => Number.isFinite(o) && o >= 1 && o <= n.lines).sort((o, i) => o - i);
|
|
792
792
|
return rn.set(
|
|
793
793
|
a.map((o) => rn.line({ class: "vpe-error-line" }).range(n.line(o).from))
|
|
794
794
|
);
|
|
795
795
|
}
|
|
796
|
-
const
|
|
796
|
+
const bs = Ua.define({
|
|
797
797
|
create: () => rn.none,
|
|
798
798
|
update: (s, n) => {
|
|
799
799
|
let a = s;
|
|
800
800
|
for (const o of n.effects)
|
|
801
|
-
o.is(
|
|
801
|
+
o.is(hr) && (a = gs(o.value, n.state.doc));
|
|
802
802
|
return n.docChanged && (a = a.map(n.changes)), a;
|
|
803
803
|
},
|
|
804
|
-
provide: (s) =>
|
|
805
|
-
}),
|
|
804
|
+
provide: (s) => Le.decorations.from(s)
|
|
805
|
+
}), ks = Le.theme({
|
|
806
806
|
"&": { height: "100%", fontSize: "13px" },
|
|
807
|
-
".cm-scroller": { fontFamily:
|
|
807
|
+
".cm-scroller": { fontFamily: hs, lineHeight: "1.65" },
|
|
808
808
|
".cm-content": { padding: "10px 0 14px" },
|
|
809
809
|
".cm-gutters": {
|
|
810
810
|
borderRight: "none",
|
|
@@ -814,10 +814,10 @@ const hs = Ba.define({
|
|
|
814
814
|
},
|
|
815
815
|
"&.cm-focused": { outline: "none" }
|
|
816
816
|
});
|
|
817
|
-
function
|
|
818
|
-
const a =
|
|
819
|
-
|
|
820
|
-
}), o =
|
|
817
|
+
function ws(s, n) {
|
|
818
|
+
const a = Le.updateListener.of((f) => {
|
|
819
|
+
f.docChanged && n.onDocChange(f.state.doc.toString());
|
|
820
|
+
}), o = er.of([
|
|
821
821
|
{
|
|
822
822
|
key: "Mod-Enter",
|
|
823
823
|
preventDefault: !0,
|
|
@@ -826,31 +826,31 @@ function ks(s, n) {
|
|
|
826
826
|
]), i = nn.create({
|
|
827
827
|
doc: n.value,
|
|
828
828
|
extensions: [
|
|
829
|
-
|
|
830
|
-
Ua(),
|
|
829
|
+
ks,
|
|
831
830
|
Aa(),
|
|
832
831
|
Da(),
|
|
833
832
|
za(),
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
833
|
+
ja(),
|
|
834
|
+
Wa(),
|
|
835
|
+
rs.of(" "),
|
|
836
|
+
n.language ?? yr(),
|
|
837
|
+
Nt(n.dark),
|
|
839
838
|
Ja(),
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
839
|
+
Za(),
|
|
840
|
+
as(),
|
|
841
|
+
Le.lineWrapping,
|
|
842
|
+
Va(n.placeholderText),
|
|
843
|
+
bs,
|
|
844
844
|
o,
|
|
845
|
-
|
|
845
|
+
er.of([...Ga, ...Ya, ...Xa, es]),
|
|
846
846
|
...n.extensions,
|
|
847
847
|
a
|
|
848
848
|
]
|
|
849
849
|
});
|
|
850
|
-
return new
|
|
850
|
+
return new Le({ state: i, parent: s });
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
return
|
|
852
|
+
function Ss(s, n = 600) {
|
|
853
|
+
return Qa(
|
|
854
854
|
async (a) => {
|
|
855
855
|
const o = a.state.doc.toString();
|
|
856
856
|
if (!o.trim()) return [];
|
|
@@ -861,11 +861,11 @@ function ws(s, n = 600) {
|
|
|
861
861
|
return [];
|
|
862
862
|
}
|
|
863
863
|
if (!i) return [];
|
|
864
|
-
const
|
|
864
|
+
const f = Math.min(Math.max(Math.round(i.line) || 1, 1), a.state.doc.lines), b = a.state.doc.line(f), E = Math.min(Math.max(Math.round(i.column) || 1, 1), b.length + 1), R = b.from + E - 1, M = Math.min(R + 1, b.to);
|
|
865
865
|
return [
|
|
866
866
|
{
|
|
867
|
-
from:
|
|
868
|
-
to:
|
|
867
|
+
from: R,
|
|
868
|
+
to: M,
|
|
869
869
|
severity: "error",
|
|
870
870
|
message: i.message,
|
|
871
871
|
source: "python-syntax"
|
|
@@ -875,7 +875,7 @@ function ws(s, n = 600) {
|
|
|
875
875
|
{ delay: n }
|
|
876
876
|
);
|
|
877
877
|
}
|
|
878
|
-
const
|
|
878
|
+
const xs = [
|
|
879
879
|
"import ast, json",
|
|
880
880
|
"def _pye_check(src):",
|
|
881
881
|
" try:",
|
|
@@ -883,7 +883,7 @@ const Ss = [
|
|
|
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
|
+
], Es = [
|
|
887
887
|
"import json",
|
|
888
888
|
"import sqlite3",
|
|
889
889
|
"",
|
|
@@ -960,13 +960,13 @@ const Ss = [
|
|
|
960
960
|
' return json.dumps({"ok": False, "results": results, "error": error})',
|
|
961
961
|
' return json.dumps({"ok": True, "results": results})'
|
|
962
962
|
];
|
|
963
|
-
function
|
|
963
|
+
function qs(s) {
|
|
964
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(xs.join(`
|
|
968
968
|
`))};
|
|
969
|
-
var SQL_SOURCE = ${JSON.stringify(
|
|
969
|
+
var SQL_SOURCE = ${JSON.stringify(Es.join(`
|
|
970
970
|
`))};
|
|
971
971
|
var pyodide = null;
|
|
972
972
|
var checkFn = null;
|
|
@@ -1224,8 +1224,8 @@ self.onmessage = async function (ev) {
|
|
|
1224
1224
|
};
|
|
1225
1225
|
`;
|
|
1226
1226
|
}
|
|
1227
|
-
const
|
|
1228
|
-
class
|
|
1227
|
+
const gr = "https://cdn.jsdelivr.net/pyodide/v0.27.2/full/";
|
|
1228
|
+
class Cs {
|
|
1229
1229
|
constructor(n = {}) {
|
|
1230
1230
|
ie(this, "status", "idle");
|
|
1231
1231
|
ie(this, "version", "");
|
|
@@ -1239,7 +1239,7 @@ class qs {
|
|
|
1239
1239
|
ie(this, "statusHandlers", /* @__PURE__ */ new Set());
|
|
1240
1240
|
ie(this, "outputHandlers", /* @__PURE__ */ new Set());
|
|
1241
1241
|
ie(this, "initErrorHandlers", /* @__PURE__ */ new Set());
|
|
1242
|
-
this.pyodideUrl = n.pyodideUrl ||
|
|
1242
|
+
this.pyodideUrl = n.pyodideUrl || gr;
|
|
1243
1243
|
}
|
|
1244
1244
|
on(n, a) {
|
|
1245
1245
|
if (n === "status") {
|
|
@@ -1257,22 +1257,22 @@ class qs {
|
|
|
1257
1257
|
waitReady(n = 18e4) {
|
|
1258
1258
|
const a = this.generation;
|
|
1259
1259
|
return this.ensureWorker(), this.status === "ready" || this.status === "running" ? Promise.resolve() : new Promise((o, i) => {
|
|
1260
|
-
let
|
|
1260
|
+
let f = () => {
|
|
1261
1261
|
}, b = () => {
|
|
1262
1262
|
};
|
|
1263
1263
|
const E = () => {
|
|
1264
|
-
clearTimeout(
|
|
1265
|
-
},
|
|
1264
|
+
clearTimeout(R), f(), b();
|
|
1265
|
+
}, R = setTimeout(() => {
|
|
1266
1266
|
E(), i(new Error("Pyodide 加载超时"));
|
|
1267
1267
|
}, n);
|
|
1268
|
-
|
|
1268
|
+
f = this.on("status", (M) => {
|
|
1269
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
|
+
M === "ready" && (E(), o());
|
|
1274
|
+
}), b = this.on("initError", (M) => {
|
|
1275
|
+
E(), i(new Error(M));
|
|
1276
1276
|
});
|
|
1277
1277
|
});
|
|
1278
1278
|
}
|
|
@@ -1376,7 +1376,7 @@ class qs {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
ensureWorker() {
|
|
1378
1378
|
if (this.worker) return this.worker;
|
|
1379
|
-
const n = new Blob([
|
|
1379
|
+
const n = new Blob([qs(this.pyodideUrl)], { type: "text/javascript" }), a = new Worker(URL.createObjectURL(n));
|
|
1380
1380
|
return a.onmessage = (o) => this.handleMessage(o.data), this.worker = a, this.setStatus("loading"), a;
|
|
1381
1381
|
}
|
|
1382
1382
|
handleMessage(n) {
|
|
@@ -1446,8 +1446,8 @@ class qs {
|
|
|
1446
1446
|
}
|
|
1447
1447
|
send(n, a) {
|
|
1448
1448
|
const o = this.ensureWorker(), i = this.chain.then(
|
|
1449
|
-
() => new Promise((
|
|
1450
|
-
this.pending.set(n.id, { resolve:
|
|
1449
|
+
() => new Promise((f) => {
|
|
1450
|
+
this.pending.set(n.id, { resolve: f, onOutput: a }), o.postMessage(n);
|
|
1451
1451
|
})
|
|
1452
1452
|
);
|
|
1453
1453
|
return this.chain = i.then(
|
|
@@ -1463,50 +1463,50 @@ class qs {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
let Xt = null;
|
|
1465
1465
|
function un(s) {
|
|
1466
|
-
return Xt ? s != null && s.pyodideUrl && s.pyodideUrl !==
|
|
1466
|
+
return Xt ? s != null && s.pyodideUrl && s.pyodideUrl !== gr && console.warn(
|
|
1467
1467
|
"[princess-python-editor] Pyodide 运行器已初始化,后续传入的 pyodideUrl 将被忽略。"
|
|
1468
|
-
) : Xt = new
|
|
1468
|
+
) : Xt = new Cs(s), Xt;
|
|
1469
1469
|
}
|
|
1470
|
-
const
|
|
1471
|
-
function
|
|
1470
|
+
const Ps = 3e4;
|
|
1471
|
+
function Os(s) {
|
|
1472
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 =
|
|
1480
|
-
o.signal && (o.signal.aborted ?
|
|
1477
|
+
async function $t(s, n, a, o = {}) {
|
|
1478
|
+
var R, M;
|
|
1479
|
+
const i = Os(s), f = new AbortController(), b = setTimeout(() => f.abort(), o.timeoutMs ?? Ps), E = () => f.abort();
|
|
1480
|
+
o.signal && (o.signal.aborted ? f.abort() : o.signal.addEventListener("abort", E));
|
|
1481
1481
|
try {
|
|
1482
|
-
const
|
|
1482
|
+
const T = await fetch(i + n, {
|
|
1483
1483
|
...a,
|
|
1484
1484
|
headers: {
|
|
1485
1485
|
"Content-Type": "application/json",
|
|
1486
1486
|
...o.headers ?? {},
|
|
1487
1487
|
...a.headers ?? {}
|
|
1488
1488
|
},
|
|
1489
|
-
signal:
|
|
1490
|
-
}), x = await
|
|
1491
|
-
let
|
|
1489
|
+
signal: f.signal
|
|
1490
|
+
}), x = await T.text();
|
|
1491
|
+
let $ = null;
|
|
1492
1492
|
if (x)
|
|
1493
1493
|
try {
|
|
1494
|
-
|
|
1494
|
+
$ = JSON.parse(x);
|
|
1495
1495
|
} catch {
|
|
1496
|
-
throw new Error(`文件服务返回的不是合法 JSON(HTTP ${
|
|
1496
|
+
throw new Error(`文件服务返回的不是合法 JSON(HTTP ${T.status})`);
|
|
1497
1497
|
}
|
|
1498
|
-
if (!
|
|
1499
|
-
throw new Error(((
|
|
1500
|
-
return
|
|
1498
|
+
if (!T.ok || !$ || $.ok === !1)
|
|
1499
|
+
throw new Error(((R = $ == null ? void 0 : $.error) == null ? void 0 : R.message) ?? `文件服务返回 HTTP ${T.status}`);
|
|
1500
|
+
return $.data;
|
|
1501
1501
|
} finally {
|
|
1502
|
-
clearTimeout(b), (
|
|
1502
|
+
clearTimeout(b), (M = o.signal) == null || M.removeEventListener("abort", E);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
function
|
|
1506
|
-
return
|
|
1505
|
+
function Ms(s, n = {}) {
|
|
1506
|
+
return $t(s, "", { method: "GET" }, n);
|
|
1507
1507
|
}
|
|
1508
|
-
function
|
|
1509
|
-
return
|
|
1508
|
+
function Ns(s, n, a = {}) {
|
|
1509
|
+
return $t(
|
|
1510
1510
|
s,
|
|
1511
1511
|
"",
|
|
1512
1512
|
{ method: "POST", body: JSON.stringify(n) },
|
|
@@ -1514,15 +1514,15 @@ function Ms(s, n, a = {}) {
|
|
|
1514
1514
|
);
|
|
1515
1515
|
}
|
|
1516
1516
|
function Ts(s, n, a = {}) {
|
|
1517
|
-
return
|
|
1517
|
+
return $t(
|
|
1518
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 Fs(s, n, a = {}) {
|
|
1525
|
+
await $t(s, `/${encodeURIComponent(n)}`, { method: "DELETE" }, a);
|
|
1526
1526
|
}
|
|
1527
1527
|
const Ls = 6e4;
|
|
1528
1528
|
function cn(s) {
|
|
@@ -1531,7 +1531,7 @@ function cn(s) {
|
|
|
1531
1531
|
throw new Error("未配置 Python 服务端点(pythonEndpoint)");
|
|
1532
1532
|
return n;
|
|
1533
1533
|
}
|
|
1534
|
-
function
|
|
1534
|
+
function br(s, n) {
|
|
1535
1535
|
if (s && typeof s == "object") {
|
|
1536
1536
|
const a = s, o = Number(a.line);
|
|
1537
1537
|
return {
|
|
@@ -1543,37 +1543,37 @@ function hr(s, n) {
|
|
|
1543
1543
|
}
|
|
1544
1544
|
return { type: "PythonError", message: n };
|
|
1545
1545
|
}
|
|
1546
|
-
async function
|
|
1547
|
-
var
|
|
1548
|
-
const o = cn(s), i = performance.now(),
|
|
1549
|
-
a.signal && (a.signal.aborted ?
|
|
1546
|
+
async function al(s, n, a = {}) {
|
|
1547
|
+
var R;
|
|
1548
|
+
const o = cn(s), i = performance.now(), f = new AbortController(), b = setTimeout(() => f.abort(), a.timeoutMs ?? Ls), E = () => f.abort();
|
|
1549
|
+
a.signal && (a.signal.aborted ? f.abort() : a.signal.addEventListener("abort", E));
|
|
1550
1550
|
try {
|
|
1551
|
-
const
|
|
1551
|
+
const M = await fetch(`${o}/run`, {
|
|
1552
1552
|
method: "POST",
|
|
1553
1553
|
headers: {
|
|
1554
1554
|
"Content-Type": "application/json",
|
|
1555
1555
|
...a.headers ?? {}
|
|
1556
1556
|
},
|
|
1557
1557
|
body: JSON.stringify({ code: n, stdin: a.stdin ?? "" }),
|
|
1558
|
-
signal:
|
|
1559
|
-
}),
|
|
1558
|
+
signal: f.signal
|
|
1559
|
+
}), T = await M.text();
|
|
1560
1560
|
let x = null;
|
|
1561
|
-
if (
|
|
1561
|
+
if (T)
|
|
1562
1562
|
try {
|
|
1563
|
-
x = JSON.parse(
|
|
1563
|
+
x = JSON.parse(T);
|
|
1564
1564
|
} catch {
|
|
1565
|
-
throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${
|
|
1565
|
+
throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${M.status})`);
|
|
1566
1566
|
}
|
|
1567
|
-
const
|
|
1568
|
-
if (!
|
|
1569
|
-
const
|
|
1567
|
+
const $ = performance.now() - i;
|
|
1568
|
+
if (!M.ok) {
|
|
1569
|
+
const N = x == null ? void 0 : x.error, Q = typeof (N == null ? void 0 : N.message) == "string" && N.message ? N.message : `Python 服务返回 HTTP ${M.status}`;
|
|
1570
1570
|
return {
|
|
1571
1571
|
ok: !1,
|
|
1572
1572
|
stdout: "",
|
|
1573
1573
|
stderr: "",
|
|
1574
|
-
durationMs:
|
|
1574
|
+
durationMs: $,
|
|
1575
1575
|
error: {
|
|
1576
|
-
type: typeof (
|
|
1576
|
+
type: typeof (N == null ? void 0 : N.type) == "string" && N.type ? N.type : `Http${M.status}`,
|
|
1577
1577
|
message: Q
|
|
1578
1578
|
}
|
|
1579
1579
|
};
|
|
@@ -1583,7 +1583,7 @@ async function el(s, n, a = {}) {
|
|
|
1583
1583
|
ok: !1,
|
|
1584
1584
|
stdout: "",
|
|
1585
1585
|
stderr: "",
|
|
1586
|
-
durationMs:
|
|
1586
|
+
durationMs: $,
|
|
1587
1587
|
error: { type: "BadResponse", message: "Python 服务返回内容为空" }
|
|
1588
1588
|
};
|
|
1589
1589
|
const q = x.ok === !0, G = Number(x.durationMs), me = Number(x.exitCode);
|
|
@@ -1592,39 +1592,39 @@ async function el(s, n, a = {}) {
|
|
|
1592
1592
|
stdout: typeof x.stdout == "string" ? x.stdout : "",
|
|
1593
1593
|
stderr: typeof x.stderr == "string" ? x.stderr : "",
|
|
1594
1594
|
exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
|
|
1595
|
-
durationMs: Number.isFinite(G) && G >= 0 ? G :
|
|
1596
|
-
error: q ? void 0 :
|
|
1595
|
+
durationMs: Number.isFinite(G) && G >= 0 ? G : $,
|
|
1596
|
+
error: q ? void 0 : br(x.error, "服务端 Python 执行失败")
|
|
1597
1597
|
};
|
|
1598
1598
|
} finally {
|
|
1599
|
-
clearTimeout(b), (
|
|
1599
|
+
clearTimeout(b), (R = a.signal) == null || R.removeEventListener("abort", E);
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
1602
|
function $s(s) {
|
|
1603
1603
|
return s === "waiting" || s === "running" || s === "exited" ? s : "exited";
|
|
1604
1604
|
}
|
|
1605
1605
|
async function dn(s, n, a, o, i) {
|
|
1606
|
-
var
|
|
1607
|
-
const
|
|
1608
|
-
o.signal && (o.signal.aborted ? E.abort() : o.signal.addEventListener("abort",
|
|
1606
|
+
var T;
|
|
1607
|
+
const f = cn(s), b = performance.now(), E = new AbortController(), R = setTimeout(() => E.abort(), o.timeoutMs ?? i), M = () => E.abort();
|
|
1608
|
+
o.signal && (o.signal.aborted ? E.abort() : o.signal.addEventListener("abort", M));
|
|
1609
1609
|
try {
|
|
1610
|
-
const x = await fetch(
|
|
1610
|
+
const x = await fetch(f + n, {
|
|
1611
1611
|
...a,
|
|
1612
1612
|
headers: {
|
|
1613
1613
|
"Content-Type": "application/json",
|
|
1614
1614
|
...o.headers ?? {}
|
|
1615
1615
|
},
|
|
1616
1616
|
signal: E.signal
|
|
1617
|
-
}),
|
|
1617
|
+
}), $ = await x.text();
|
|
1618
1618
|
let q = null;
|
|
1619
|
-
if (
|
|
1619
|
+
if ($)
|
|
1620
1620
|
try {
|
|
1621
|
-
q = JSON.parse(
|
|
1621
|
+
q = JSON.parse($);
|
|
1622
1622
|
} catch {
|
|
1623
1623
|
throw new Error(`Python 服务返回的不是合法 JSON(HTTP ${x.status})`);
|
|
1624
1624
|
}
|
|
1625
1625
|
const G = performance.now() - b;
|
|
1626
1626
|
if (!x.ok || !q) {
|
|
1627
|
-
const Q = q == null ? void 0 : q.error,
|
|
1627
|
+
const Q = q == null ? void 0 : q.error, Ae = 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",
|
|
@@ -1633,25 +1633,25 @@ async function dn(s, n, a, o, i) {
|
|
|
1633
1633
|
durationMs: G,
|
|
1634
1634
|
error: {
|
|
1635
1635
|
type: typeof (Q == null ? void 0 : Q.type) == "string" && Q.type ? Q.type : `Http${x.status}`,
|
|
1636
|
-
message:
|
|
1636
|
+
message: Ae
|
|
1637
1637
|
}
|
|
1638
1638
|
};
|
|
1639
1639
|
}
|
|
1640
|
-
const me = Number(q.exitCode),
|
|
1640
|
+
const me = Number(q.exitCode), N = Number(q.durationMs);
|
|
1641
1641
|
return {
|
|
1642
1642
|
sessionId: typeof q.sessionId == "string" ? q.sessionId : "",
|
|
1643
1643
|
state: $s(q.state),
|
|
1644
1644
|
stdout: typeof q.stdout == "string" ? q.stdout : "",
|
|
1645
1645
|
stderr: typeof q.stderr == "string" ? q.stderr : "",
|
|
1646
1646
|
exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
|
|
1647
|
-
durationMs: Number.isFinite(
|
|
1648
|
-
error: q.error ?
|
|
1647
|
+
durationMs: Number.isFinite(N) ? N : G,
|
|
1648
|
+
error: q.error ? br(q.error, "服务端 Python 执行失败") : void 0
|
|
1649
1649
|
};
|
|
1650
1650
|
} finally {
|
|
1651
|
-
clearTimeout(
|
|
1651
|
+
clearTimeout(R), (T = o.signal) == null || T.removeEventListener("abort", M);
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
|
-
function
|
|
1654
|
+
function Rs(s, n, a = {}) {
|
|
1655
1655
|
return dn(
|
|
1656
1656
|
s,
|
|
1657
1657
|
"/sessions",
|
|
@@ -1676,7 +1676,7 @@ function _s(s, n, a = {}) {
|
|
|
1676
1676
|
5e3
|
|
1677
1677
|
);
|
|
1678
1678
|
}
|
|
1679
|
-
function
|
|
1679
|
+
function Is(s, n, a, o = {}) {
|
|
1680
1680
|
return dn(
|
|
1681
1681
|
s,
|
|
1682
1682
|
`/sessions/${encodeURIComponent(n)}/input`,
|
|
@@ -1685,7 +1685,7 @@ function Rs(s, n, a, o = {}) {
|
|
|
1685
1685
|
2e4
|
|
1686
1686
|
);
|
|
1687
1687
|
}
|
|
1688
|
-
async function
|
|
1688
|
+
async function ar(s, n, a = {}) {
|
|
1689
1689
|
const o = cn(s);
|
|
1690
1690
|
try {
|
|
1691
1691
|
await fetch(`${o}/sessions/${encodeURIComponent(n)}/interrupt`, {
|
|
@@ -1704,47 +1704,47 @@ const dt = [
|
|
|
1704
1704
|
{ value: "oracle", label: "Oracle", defaultPort: 1521 },
|
|
1705
1705
|
{ value: "clickhouse", label: "ClickHouse", defaultPort: 8123 },
|
|
1706
1706
|
{ value: "other", label: "其他" }
|
|
1707
|
-
],
|
|
1707
|
+
], sl = {
|
|
1708
1708
|
mode: "sqlite",
|
|
1709
1709
|
connection: { dialect: "sqlite", database: ":memory:" },
|
|
1710
1710
|
maxRows: 200,
|
|
1711
1711
|
timeoutMs: 3e4
|
|
1712
|
-
},
|
|
1713
|
-
function
|
|
1712
|
+
}, kr = 200, Ft = 3e4;
|
|
1713
|
+
function Hs(s) {
|
|
1714
1714
|
return dt.some((n) => n.value === s);
|
|
1715
1715
|
}
|
|
1716
|
-
function
|
|
1716
|
+
function sr(s, n, a, o) {
|
|
1717
1717
|
const i = typeof s == "number" ? s : Number(s);
|
|
1718
1718
|
return Number.isFinite(i) ? Math.min(Math.max(Math.trunc(i), a), o) : n;
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function Bs(s) {
|
|
1721
1721
|
if (s == null || s === "") return;
|
|
1722
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
1726
|
function D(s = {}) {
|
|
1727
|
-
var
|
|
1728
|
-
const n = s.mode === "http" ? "http" : "sqlite", a = (
|
|
1727
|
+
var f, b, E, R, M, T, x;
|
|
1728
|
+
const n = s.mode === "http" ? "http" : "sqlite", a = (f = s.connection) == null ? void 0 : f.dialect, o = Hs(a) ? a : n === "http" ? "mysql" : "sqlite", i = (b = s.connection) == null ? void 0 : b.database;
|
|
1729
1729
|
return {
|
|
1730
1730
|
mode: n,
|
|
1731
1731
|
connectionId: s.connectionId === void 0 || s.connectionId === null ? void 0 : s.connectionId.trim() || void 0,
|
|
1732
1732
|
connection: {
|
|
1733
1733
|
dialect: o,
|
|
1734
1734
|
host: ((E = s.connection) == null ? void 0 : E.host) ?? "",
|
|
1735
|
-
port:
|
|
1736
|
-
user: ((
|
|
1737
|
-
password: ((
|
|
1735
|
+
port: Bs((R = s.connection) == null ? void 0 : R.port),
|
|
1736
|
+
user: ((M = s.connection) == null ? void 0 : M.user) ?? "",
|
|
1737
|
+
password: ((T = s.connection) == null ? void 0 : T.password) ?? "",
|
|
1738
1738
|
database: i ?? (n === "sqlite" ? ":memory:" : ""),
|
|
1739
1739
|
options: (x = s.connection) != null && x.options ? { ...s.connection.options } : void 0
|
|
1740
1740
|
},
|
|
1741
1741
|
endpoint: s.endpoint ?? "",
|
|
1742
1742
|
headers: s.headers ? { ...s.headers } : void 0,
|
|
1743
|
-
maxRows:
|
|
1744
|
-
timeoutMs:
|
|
1743
|
+
maxRows: sr(s.maxRows, kr, 1, 1e5),
|
|
1744
|
+
timeoutMs: sr(s.timeoutMs, Ft, 1e3, 6e5)
|
|
1745
1745
|
};
|
|
1746
1746
|
}
|
|
1747
|
-
function
|
|
1747
|
+
function or(s) {
|
|
1748
1748
|
if (s == null) return null;
|
|
1749
1749
|
const n = typeof s;
|
|
1750
1750
|
if (n === "string" || n === "number" || n === "boolean")
|
|
@@ -1756,7 +1756,7 @@ function sr(s) {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
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(
|
|
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(or) : [or(i)]) : [];
|
|
1760
1760
|
return {
|
|
1761
1761
|
columns: a,
|
|
1762
1762
|
rows: o,
|
|
@@ -1775,10 +1775,10 @@ function pn(s, n) {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
return { type: "SqlError", message: typeof s == "string" && s ? s : n };
|
|
1777
1777
|
}
|
|
1778
|
-
function
|
|
1778
|
+
function Us(s) {
|
|
1779
1779
|
return s instanceof DOMException && s.name === "AbortError" || s instanceof Error && s.name === "AbortError";
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1781
|
+
function ir(s, n) {
|
|
1782
1782
|
if (!s || typeof s != "object")
|
|
1783
1783
|
return {
|
|
1784
1784
|
ok: !1,
|
|
@@ -1786,22 +1786,22 @@ function or(s, n) {
|
|
|
1786
1786
|
error: { type: "BadResponse", message: "SQL 服务返回内容为空或格式不正确" },
|
|
1787
1787
|
durationMs: n
|
|
1788
1788
|
};
|
|
1789
|
-
const a = s, o = a.ok !== !1, i = Number(a.durationMs),
|
|
1789
|
+
const a = s, o = a.ok !== !1, i = Number(a.durationMs), f = Number.isFinite(i) && i >= 0 ? i : n;
|
|
1790
1790
|
if (!o)
|
|
1791
1791
|
return {
|
|
1792
1792
|
ok: !1,
|
|
1793
1793
|
results: [],
|
|
1794
1794
|
error: pn(a.error, "SQL 服务返回执行失败"),
|
|
1795
|
-
durationMs:
|
|
1795
|
+
durationMs: f
|
|
1796
1796
|
};
|
|
1797
1797
|
let b = [];
|
|
1798
1798
|
return Array.isArray(a.results) ? b = a.results : (Array.isArray(a.columns) || Array.isArray(a.rows)) && (b = [a]), {
|
|
1799
1799
|
ok: !0,
|
|
1800
1800
|
results: b.map(on),
|
|
1801
|
-
durationMs:
|
|
1801
|
+
durationMs: f
|
|
1802
1802
|
};
|
|
1803
1803
|
}
|
|
1804
|
-
async function
|
|
1804
|
+
async function As(s, n, a, o) {
|
|
1805
1805
|
const i = (s.endpoint ?? "").trim();
|
|
1806
1806
|
if (!i)
|
|
1807
1807
|
return {
|
|
@@ -1813,14 +1813,14 @@ async function Us(s, n, a, o) {
|
|
|
1813
1813
|
},
|
|
1814
1814
|
durationMs: 0
|
|
1815
1815
|
};
|
|
1816
|
-
const
|
|
1816
|
+
const f = performance.now(), b = new AbortController();
|
|
1817
1817
|
let E = !1;
|
|
1818
|
-
const
|
|
1818
|
+
const R = setTimeout(() => {
|
|
1819
1819
|
E = !0, b.abort();
|
|
1820
|
-
}, s.timeoutMs ??
|
|
1821
|
-
o && (o.aborted ? b.abort() : o.addEventListener("abort",
|
|
1820
|
+
}, s.timeoutMs ?? Ft), M = () => b.abort();
|
|
1821
|
+
o && (o.aborted ? b.abort() : o.addEventListener("abort", M));
|
|
1822
1822
|
try {
|
|
1823
|
-
const
|
|
1823
|
+
const T = await fetch(i, {
|
|
1824
1824
|
method: "POST",
|
|
1825
1825
|
headers: { "Content-Type": "application/json", ...s.headers ?? {} },
|
|
1826
1826
|
body: JSON.stringify({
|
|
@@ -1830,52 +1830,52 @@ async function Us(s, n, a, o) {
|
|
|
1830
1830
|
maxRows: a
|
|
1831
1831
|
}),
|
|
1832
1832
|
signal: b.signal
|
|
1833
|
-
}), x = await
|
|
1834
|
-
let
|
|
1833
|
+
}), x = await T.text();
|
|
1834
|
+
let $ = null;
|
|
1835
1835
|
if (x)
|
|
1836
1836
|
try {
|
|
1837
|
-
|
|
1837
|
+
$ = JSON.parse(x);
|
|
1838
1838
|
} catch {
|
|
1839
1839
|
return {
|
|
1840
1840
|
ok: !1,
|
|
1841
1841
|
results: [],
|
|
1842
1842
|
error: {
|
|
1843
1843
|
type: "BadResponse",
|
|
1844
|
-
message: `SQL 服务返回的不是合法 JSON(HTTP ${
|
|
1844
|
+
message: `SQL 服务返回的不是合法 JSON(HTTP ${T.status})`
|
|
1845
1845
|
},
|
|
1846
|
-
durationMs: performance.now() -
|
|
1846
|
+
durationMs: performance.now() - f
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
|
-
if (!
|
|
1850
|
-
const q =
|
|
1849
|
+
if (!T.ok) {
|
|
1850
|
+
const q = $ ? ir($, performance.now() - f) : 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${T.status}`,
|
|
1856
|
+
message: `SQL 服务返回 HTTP ${T.status}${T.statusText ? ` ${T.statusText}` : ""}`
|
|
1857
1857
|
},
|
|
1858
|
-
durationMs: performance.now() -
|
|
1858
|
+
durationMs: performance.now() - f
|
|
1859
1859
|
};
|
|
1860
1860
|
}
|
|
1861
|
-
return
|
|
1862
|
-
} catch (
|
|
1861
|
+
return ir($, performance.now() - f);
|
|
1862
|
+
} catch (T) {
|
|
1863
1863
|
if (E)
|
|
1864
1864
|
return {
|
|
1865
1865
|
ok: !1,
|
|
1866
1866
|
results: [],
|
|
1867
1867
|
error: {
|
|
1868
1868
|
type: "Timeout",
|
|
1869
|
-
message: `SQL 请求超时(${s.timeoutMs ??
|
|
1869
|
+
message: `SQL 请求超时(${s.timeoutMs ?? Ft}ms)`
|
|
1870
1870
|
},
|
|
1871
|
-
durationMs: performance.now() -
|
|
1871
|
+
durationMs: performance.now() - f
|
|
1872
1872
|
};
|
|
1873
|
-
throw
|
|
1873
|
+
throw T;
|
|
1874
1874
|
} finally {
|
|
1875
|
-
clearTimeout(
|
|
1875
|
+
clearTimeout(R), o == null || o.removeEventListener("abort", M);
|
|
1876
1876
|
}
|
|
1877
1877
|
}
|
|
1878
|
-
function
|
|
1878
|
+
function lr(s, n) {
|
|
1879
1879
|
if (!s || typeof s != "object")
|
|
1880
1880
|
return {
|
|
1881
1881
|
ok: !1,
|
|
@@ -1895,8 +1895,8 @@ function ir(s, n) {
|
|
|
1895
1895
|
durationMs: a
|
|
1896
1896
|
};
|
|
1897
1897
|
}
|
|
1898
|
-
async function
|
|
1899
|
-
const o = D(s), i = o.maxRows ??
|
|
1898
|
+
async function wr(s, n, a = {}) {
|
|
1899
|
+
const o = D(s), i = o.maxRows ?? kr, f = performance.now();
|
|
1900
1900
|
if (!n.trim())
|
|
1901
1901
|
return {
|
|
1902
1902
|
ok: !1,
|
|
@@ -1910,37 +1910,37 @@ async function kr(s, n, a = {}) {
|
|
|
1910
1910
|
{ sql: n, connection: o.connection, maxRows: i },
|
|
1911
1911
|
{ signal: a.signal }
|
|
1912
1912
|
);
|
|
1913
|
-
return
|
|
1913
|
+
return lr(E, performance.now() - f);
|
|
1914
1914
|
}
|
|
1915
1915
|
if (o.mode === "http")
|
|
1916
|
-
return await
|
|
1916
|
+
return await As(o, n, i, a.signal);
|
|
1917
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 lr(b, performance.now() - f);
|
|
1923
1923
|
} catch (b) {
|
|
1924
|
-
return
|
|
1924
|
+
return Us(b) ? {
|
|
1925
1925
|
ok: !1,
|
|
1926
1926
|
results: [],
|
|
1927
1927
|
error: { type: "AbortError", message: "SQL 执行已中断" },
|
|
1928
|
-
durationMs: performance.now() -
|
|
1928
|
+
durationMs: performance.now() - f
|
|
1929
1929
|
} : {
|
|
1930
1930
|
ok: !1,
|
|
1931
1931
|
results: [],
|
|
1932
1932
|
error: pn(b, "SQL 执行失败"),
|
|
1933
|
-
durationMs: performance.now() -
|
|
1933
|
+
durationMs: performance.now() - f
|
|
1934
1934
|
};
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
|
-
function
|
|
1937
|
+
function ur(s) {
|
|
1938
1938
|
var n;
|
|
1939
1939
|
return (n = dt.find((a) => a.value === s)) == null ? void 0 : n.defaultPort;
|
|
1940
1940
|
}
|
|
1941
|
-
async function
|
|
1941
|
+
async function Ds(s, n = {}) {
|
|
1942
1942
|
var o;
|
|
1943
|
-
const a = await
|
|
1943
|
+
const a = await wr(s, "SELECT 1", n);
|
|
1944
1944
|
return a.ok ? {
|
|
1945
1945
|
ok: !0,
|
|
1946
1946
|
message: `连接成功(${Math.max(1, Math.round(a.durationMs))}ms)`,
|
|
@@ -1952,14 +1952,14 @@ async function As(s, n = {}) {
|
|
|
1952
1952
|
};
|
|
1953
1953
|
}
|
|
1954
1954
|
async function fn(s, n, a, o = {}) {
|
|
1955
|
-
var
|
|
1956
|
-
const i = D(s),
|
|
1957
|
-
if (!
|
|
1955
|
+
var M, T;
|
|
1956
|
+
const i = D(s), f = (i.endpoint ?? "").trim().replace(/\/+$/, "");
|
|
1957
|
+
if (!f)
|
|
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 ?? Ft), R = () => b.abort();
|
|
1960
|
+
o.signal && (o.signal.aborted ? b.abort() : o.signal.addEventListener("abort", R));
|
|
1961
1961
|
try {
|
|
1962
|
-
const x = await fetch(
|
|
1962
|
+
const x = await fetch(f + n, {
|
|
1963
1963
|
...a,
|
|
1964
1964
|
headers: {
|
|
1965
1965
|
"Content-Type": "application/json",
|
|
@@ -1967,25 +1967,25 @@ async function fn(s, n, a, o = {}) {
|
|
|
1967
1967
|
...a.headers ?? {}
|
|
1968
1968
|
},
|
|
1969
1969
|
signal: b.signal
|
|
1970
|
-
}),
|
|
1970
|
+
}), $ = await x.text();
|
|
1971
1971
|
let q = null;
|
|
1972
|
-
if (
|
|
1972
|
+
if ($)
|
|
1973
1973
|
try {
|
|
1974
|
-
q = JSON.parse(
|
|
1974
|
+
q = JSON.parse($);
|
|
1975
1975
|
} catch {
|
|
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(((M = q == null ? void 0 : q.error) == null ? void 0 : M.message) ?? `SQL 服务返回 HTTP ${x.status}`);
|
|
1980
1980
|
return q.data;
|
|
1981
1981
|
} finally {
|
|
1982
|
-
clearTimeout(E), (
|
|
1982
|
+
clearTimeout(E), (T = o.signal) == null || T.removeEventListener("abort", R);
|
|
1983
1983
|
}
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1985
|
+
function zs(s, n = {}) {
|
|
1986
1986
|
return fn(s, "/connections", { method: "GET" }, n);
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1988
|
+
function js(s, n, a, o = {}) {
|
|
1989
1989
|
return fn(
|
|
1990
1990
|
s,
|
|
1991
1991
|
a ? `/connections/${encodeURIComponent(a)}` : "/connections",
|
|
@@ -1993,7 +1993,7 @@ function zs(s, n, a, o = {}) {
|
|
|
1993
1993
|
o
|
|
1994
1994
|
);
|
|
1995
1995
|
}
|
|
1996
|
-
async function
|
|
1996
|
+
async function cr(s, n, a = {}) {
|
|
1997
1997
|
await fn(
|
|
1998
1998
|
s,
|
|
1999
1999
|
`/connections/${encodeURIComponent(n)}`,
|
|
@@ -2001,29 +2001,29 @@ async function ur(s, n, a = {}) {
|
|
|
2001
2001
|
a
|
|
2002
2002
|
);
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
2004
|
+
const Lt = [
|
|
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
2010
|
function Mt(s) {
|
|
2011
|
-
return
|
|
2011
|
+
return Lt.find((n) => n.value === s) ?? Lt[0];
|
|
2012
2012
|
}
|
|
2013
2013
|
function en(s) {
|
|
2014
2014
|
switch (s) {
|
|
2015
2015
|
case "sql":
|
|
2016
|
-
return
|
|
2016
|
+
return is();
|
|
2017
2017
|
case "javascript":
|
|
2018
|
-
return as();
|
|
2019
|
-
case "json":
|
|
2020
2018
|
return ss();
|
|
2019
|
+
case "json":
|
|
2020
|
+
return os();
|
|
2021
2021
|
case "python":
|
|
2022
2022
|
default:
|
|
2023
|
-
return
|
|
2023
|
+
return yr();
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2026
|
+
function dr(s) {
|
|
2027
2027
|
const n = s.lastIndexOf(".");
|
|
2028
2028
|
if (n < 0) return "python";
|
|
2029
2029
|
switch (s.slice(n + 1).toLowerCase()) {
|
|
@@ -2051,15 +2051,15 @@ const ln = [
|
|
|
2051
2051
|
{ value: "solarized-light", label: "Solarized 浅色", dark: !1 },
|
|
2052
2052
|
{ value: "monokai", label: "Monokai", dark: !0 }
|
|
2053
2053
|
];
|
|
2054
|
-
function
|
|
2054
|
+
function Vs(s) {
|
|
2055
2055
|
return ln.find((n) => n.value === s) ?? ln[0];
|
|
2056
2056
|
}
|
|
2057
2057
|
function ut(s) {
|
|
2058
|
-
return
|
|
2058
|
+
return Vs(s).dark;
|
|
2059
2059
|
}
|
|
2060
|
-
function
|
|
2060
|
+
function J(s) {
|
|
2061
2061
|
const n = Array.isArray(s) ? s : [s];
|
|
2062
|
-
return () =>
|
|
2062
|
+
return () => Jn(
|
|
2063
2063
|
"svg",
|
|
2064
2064
|
{
|
|
2065
2065
|
viewBox: "0 0 24 24",
|
|
@@ -2068,111 +2068,119 @@ function Z(s) {
|
|
|
2068
2068
|
fill: "currentColor",
|
|
2069
2069
|
"aria-hidden": "true"
|
|
2070
2070
|
},
|
|
2071
|
-
n.map((a) =>
|
|
2071
|
+
n.map((a) => Jn("path", { d: a }))
|
|
2072
2072
|
);
|
|
2073
2073
|
}
|
|
2074
|
-
const
|
|
2074
|
+
const Qs = J(
|
|
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
|
+
), Ks = J("M6 6h12v12H6Z"), pr = J(
|
|
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
|
+
), Js = J(
|
|
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
|
+
), Zs = J(
|
|
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
|
+
), fr = J(
|
|
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
|
+
), vr = J("M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"), Gs = J(
|
|
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
|
+
), Ws = J("M2 3v7l15 2-15 2v7l20-9L2 3z"), Ys = J("M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"), ct = J(
|
|
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
|
+
), Xs = J("M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6V5z"), eo = J([
|
|
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
|
+
]), to = J(
|
|
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
|
+
), no = J([
|
|
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
|
+
]), ro = {
|
|
2096
2096
|
key: 0,
|
|
2097
2097
|
class: "vpe-toolbar"
|
|
2098
|
-
},
|
|
2098
|
+
}, ao = { class: "vpe-toolbar-main" }, so = ["title", "disabled"], oo = ["disabled"], io = ["disabled"], lo = ["title", "disabled"], uo = ["title", "aria-label"], co = { key: 2 }, po = { key: 3 }, fo = ["disabled"], vo = {
|
|
2099
2099
|
class: "vpe-file",
|
|
2100
2100
|
title: "当前文件名(下载时使用)"
|
|
2101
|
-
},
|
|
2101
|
+
}, mo = ["value"], yo = ["value"], ho = { class: "vpe-toolbar-end" }, go = {
|
|
2102
|
+
key: 0,
|
|
2103
|
+
class: "vpe-sql-connection-group",
|
|
2104
|
+
role: "group",
|
|
2105
|
+
"aria-label": "SQL 连接"
|
|
2106
|
+
}, bo = ["disabled"], ko = {
|
|
2102
2107
|
value: "",
|
|
2103
2108
|
disabled: ""
|
|
2104
|
-
},
|
|
2109
|
+
}, wo = ["value"], So = { class: "vpe-toolbar-chips" }, xo = ["title"], Eo = { class: "vpe-status-text" }, qo = ["value", "disabled"], Co = ["value"], Po = ["aria-selected", "data-file-id", "title", "onClick", "onKeydown"], Oo = { class: "vpe-tab-name" }, Mo = ["title", "aria-label", "disabled", "onClick"], No = ["disabled"], To = { class: "vpe-output-head" }, Fo = { class: "vpe-output-main" }, Lo = {
|
|
2105
2110
|
key: 0,
|
|
2106
2111
|
class: "vpe-sql-results"
|
|
2107
|
-
},
|
|
2112
|
+
}, $o = { class: "vpe-sql-result-head" }, Ro = {
|
|
2108
2113
|
key: 0,
|
|
2109
2114
|
class: "vpe-sql-table-wrap"
|
|
2110
|
-
},
|
|
2115
|
+
}, _o = { class: "vpe-sql-table" }, Io = {
|
|
2111
2116
|
key: 0,
|
|
2112
2117
|
class: "vpe-sql-empty"
|
|
2113
|
-
},
|
|
2118
|
+
}, Ho = {
|
|
2114
2119
|
key: 1,
|
|
2115
2120
|
class: "vpe-sql-affected"
|
|
2116
|
-
},
|
|
2121
|
+
}, Bo = {
|
|
2117
2122
|
key: 1,
|
|
2118
2123
|
class: "vpe-empty"
|
|
2119
|
-
},
|
|
2124
|
+
}, Uo = {
|
|
2120
2125
|
key: 0,
|
|
2121
2126
|
class: "vpe-terminal-input"
|
|
2122
|
-
},
|
|
2127
|
+
}, Ao = ["onKeydown"], Do = {
|
|
2123
2128
|
key: 4,
|
|
2129
|
+
class: "vpe-footer"
|
|
2130
|
+
}, zo = {
|
|
2131
|
+
key: 5,
|
|
2124
2132
|
class: "vpe-fs-panel",
|
|
2125
2133
|
role: "dialog",
|
|
2126
2134
|
"aria-label": "虚拟文件"
|
|
2127
|
-
},
|
|
2135
|
+
}, jo = { class: "vpe-fs-head" }, Vo = ["disabled"], Qo = { class: "vpe-fs-body" }, Ko = {
|
|
2128
2136
|
key: 0,
|
|
2129
2137
|
class: "vpe-fs-empty"
|
|
2130
|
-
},
|
|
2138
|
+
}, Jo = {
|
|
2131
2139
|
key: 0,
|
|
2132
2140
|
class: "vpe-fs-empty"
|
|
2133
|
-
},
|
|
2134
|
-
key:
|
|
2141
|
+
}, Zo = ["title"], Go = { class: "vpe-fs-size" }, Wo = ["title", "aria-label", "onClick"], Yo = {
|
|
2142
|
+
key: 6,
|
|
2135
2143
|
class: "vpe-fs-panel",
|
|
2136
2144
|
role: "dialog",
|
|
2137
2145
|
"aria-label": "服务端文件"
|
|
2138
|
-
},
|
|
2146
|
+
}, Xo = { class: "vpe-fs-head" }, ei = ["disabled"], ti = { class: "vpe-fs-body" }, ni = {
|
|
2139
2147
|
key: 0,
|
|
2140
2148
|
class: "vpe-fs-empty"
|
|
2141
|
-
},
|
|
2149
|
+
}, ri = {
|
|
2142
2150
|
key: 0,
|
|
2143
2151
|
class: "vpe-fs-empty"
|
|
2144
|
-
},
|
|
2152
|
+
}, ai = ["title"], si = ["title"], oi = ["title", "disabled", "onClick"], ii = ["title", "disabled", "onClick"], li = {
|
|
2145
2153
|
key: 1,
|
|
2146
2154
|
class: "vpe-sql-hint vpe-sql-hint--error"
|
|
2147
|
-
},
|
|
2148
|
-
key:
|
|
2155
|
+
}, ui = {
|
|
2156
|
+
key: 7,
|
|
2149
2157
|
class: "vpe-sql-panel",
|
|
2150
2158
|
role: "dialog",
|
|
2151
2159
|
"aria-label": "SQL 连接配置"
|
|
2152
|
-
},
|
|
2160
|
+
}, ci = { class: "vpe-fs-head" }, di = { class: "vpe-fs-title" }, pi = { class: "vpe-sql-body" }, fi = { class: "vpe-sql-field" }, vi = { class: "vpe-sql-field" }, mi = { class: "vpe-sql-field" }, yi = { class: "vpe-sql-field" }, hi = ["value"], gi = { class: "vpe-sql-row" }, bi = { class: "vpe-sql-field vpe-sql-field--grow" }, ki = { class: "vpe-sql-field vpe-sql-field--grow" }, wi = { class: "vpe-sql-row" }, Si = { class: "vpe-sql-field vpe-sql-field--grow" }, xi = { class: "vpe-sql-field vpe-sql-field--grow" }, Ei = ["placeholder"], qi = { class: "vpe-sql-field" }, Ci = {
|
|
2153
2161
|
key: 0,
|
|
2154
2162
|
class: "vpe-sql-field"
|
|
2155
|
-
},
|
|
2163
|
+
}, Pi = {
|
|
2156
2164
|
key: 1,
|
|
2157
2165
|
class: "vpe-sql-hint"
|
|
2158
|
-
},
|
|
2166
|
+
}, Oi = { class: "vpe-sql-actions" }, Mi = ["disabled"], Ni = ["disabled"], Ti = ["disabled"], Fi = {
|
|
2159
2167
|
key: 3,
|
|
2160
2168
|
class: "vpe-sql-test vpe-sql-test--err"
|
|
2161
|
-
},
|
|
2162
|
-
key:
|
|
2169
|
+
}, Li = {
|
|
2170
|
+
key: 8,
|
|
2163
2171
|
class: "vpe-sql-manager-panel",
|
|
2164
2172
|
role: "dialog",
|
|
2165
2173
|
"aria-label": "连接管理"
|
|
2166
|
-
},
|
|
2174
|
+
}, $i = { class: "vpe-fs-head" }, Ri = ["disabled"], _i = { class: "vpe-sql-manager-body" }, Ii = {
|
|
2167
2175
|
key: 0,
|
|
2168
2176
|
class: "vpe-fs-empty"
|
|
2169
|
-
},
|
|
2177
|
+
}, Hi = {
|
|
2170
2178
|
key: 0,
|
|
2171
2179
|
class: "vpe-fs-empty"
|
|
2172
|
-
},
|
|
2180
|
+
}, Bi = { class: "vpe-sql-manager-main" }, Ui = ["title"], Ai = { class: "vpe-sql-manager-meta" }, Di = ["onClick"], zi = ["disabled", "onClick"], ji = {
|
|
2173
2181
|
key: 1,
|
|
2174
2182
|
class: "vpe-sql-hint vpe-sql-hint--error"
|
|
2175
|
-
}, tn = 1,
|
|
2183
|
+
}, tn = 1, mr = 80, Vi = /* @__PURE__ */ $a({
|
|
2176
2184
|
__name: "PythonEditor",
|
|
2177
2185
|
props: {
|
|
2178
2186
|
modelValue: { default: "" },
|
|
@@ -2183,6 +2191,11 @@ const Vs = Z(
|
|
|
2183
2191
|
readOnly: { type: Boolean, default: !1 },
|
|
2184
2192
|
autofocus: { type: Boolean, default: !1 },
|
|
2185
2193
|
showToolbar: { type: Boolean, default: !0 },
|
|
2194
|
+
showSubmit: { type: Boolean, default: !1 },
|
|
2195
|
+
showNewFile: { type: Boolean, default: !0 },
|
|
2196
|
+
showOpenFile: { type: Boolean, default: !0 },
|
|
2197
|
+
showDownload: { type: Boolean, default: !0 },
|
|
2198
|
+
showVirtualFiles: { type: Boolean, default: !0 },
|
|
2186
2199
|
showTabs: { type: Boolean, default: !0 },
|
|
2187
2200
|
showOutput: { type: Boolean, default: !0 },
|
|
2188
2201
|
clearOutputOnRun: { type: Boolean, default: !0 },
|
|
@@ -2206,15 +2219,15 @@ const Vs = Z(
|
|
|
2206
2219
|
pythonHeaders: { default: void 0 },
|
|
2207
2220
|
runtime: { default: "browser" }
|
|
2208
2221
|
},
|
|
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"],
|
|
2222
|
+
emits: ["update:modelValue", "ready", "statusChange", "runStart", "runOutput", "runError", "runFinish", "loadError", "update:fileName", "update:language", "update:theme", "newFile", "fileClose", "fileSwitch", "copy", "submit", "download", "fileOpen", "fsDownload", "update:sqlConfig", "update:runtime", "sqlResult", "sqlError"],
|
|
2210
2223
|
setup(s, { expose: n, emit: a }) {
|
|
2211
|
-
const o = s, i = a,
|
|
2224
|
+
const o = s, i = a, f = C(), b = C(), E = C(), R = C(), M = C(), T = C(), x = C(null), $ = C(!1), q = Zn(/* @__PURE__ */ new Map()), G = U(() => fe().lines), me = U(() => fe().sqlResults), N = Zn(/* @__PURE__ */ new Map()), Q = U(() => N.get(w.value.id) ?? null), Ae = U(() => {
|
|
2212
2225
|
var e;
|
|
2213
2226
|
return !!((e = Q.value) != null && e.busy);
|
|
2214
|
-
}),
|
|
2227
|
+
}), De = U(() => {
|
|
2215
2228
|
var e;
|
|
2216
2229
|
return !!((e = Q.value) != null && e.waiting);
|
|
2217
|
-
}),
|
|
2230
|
+
}), B = U({
|
|
2218
2231
|
get: () => {
|
|
2219
2232
|
var e;
|
|
2220
2233
|
return ((e = Q.value) == null ? void 0 : e.input) ?? "";
|
|
@@ -2223,51 +2236,51 @@ const Vs = Z(
|
|
|
2223
2236
|
const t = Q.value;
|
|
2224
2237
|
t && (t.input = e);
|
|
2225
2238
|
}
|
|
2226
|
-
}), k = C(null), I = C("idle"),
|
|
2227
|
-
let
|
|
2228
|
-
function
|
|
2229
|
-
return { id: ++
|
|
2239
|
+
}), k = C(null), I = C("idle"), j = C(o.theme), ce = C(o.runtime), Se = C(!1), ze = C(!1), Xe = C(!1), et = C([]), xe = C(!1), ft = C(!1), tt = C([]), je = C(""), W = C(!1), $e = C(!1), Ee = C(!1), Re = C(!1), nt = C(""), vt = C(!1), v = C(D(o.sqlConfig)), Pe = C([]), Ve = C(!1), Oe = C(""), ne = C(""), re = C(!1), ae = C(""), Qe = C(!1), _e = C(!1), Ke = C(""), mt = C(!1);
|
|
2240
|
+
let Rt = !1, yt, vn = !1, _t = !1, mn = !1, P = null, Sr = 0, xr = 0, ht = null, gt = null, It, de = null, Y = null, se = null, oe = null, Er = 0, rt = 0;
|
|
2241
|
+
function Je(e, t, r) {
|
|
2242
|
+
return { id: ++xr, name: e, language: t, code: r };
|
|
2230
2243
|
}
|
|
2231
|
-
const
|
|
2232
|
-
() =>
|
|
2244
|
+
const F = C([Je(o.fileName, o.language, o.modelValue)]), qe = C(F.value[0].id), w = U(
|
|
2245
|
+
() => F.value.find((e) => e.id === qe.value) ?? F.value[0]
|
|
2233
2246
|
), Ie = U({
|
|
2234
2247
|
get: () => w.value.name,
|
|
2235
2248
|
set: (e) => {
|
|
2236
2249
|
const t = w.value;
|
|
2237
2250
|
t.name !== e && (t.name = e, i("update:fileName", e));
|
|
2238
2251
|
}
|
|
2239
|
-
}),
|
|
2252
|
+
}), yn = new qt(), Ht = new qt(), Bt = new qt(), Ut = new qt(), V = un(o.pyodideUrl ? { pyodideUrl: o.pyodideUrl } : void 0), qr = U(() => ({
|
|
2240
2253
|
height: typeof o.height == "number" ? `${o.height}px` : o.height
|
|
2241
|
-
})),
|
|
2242
|
-
`vpe-theme-${
|
|
2243
|
-
ut(
|
|
2254
|
+
})), Cr = U(() => [
|
|
2255
|
+
`vpe-theme-${j.value}`,
|
|
2256
|
+
ut(j.value) ? "vpe-dark" : ""
|
|
2244
2257
|
]);
|
|
2245
|
-
let
|
|
2246
|
-
const
|
|
2258
|
+
let hn = 0, At = 0, Ze = null;
|
|
2259
|
+
const Pr = U(
|
|
2247
2260
|
() => x.value !== null ? `${x.value}px` : typeof o.outputHeight == "number" ? `${o.outputHeight}px` : o.outputHeight
|
|
2248
|
-
), pe = U(() => w.value.language === "sql"),
|
|
2249
|
-
() =>
|
|
2250
|
-
),
|
|
2261
|
+
), pe = U(() => w.value.language === "sql"), gn = U(() => w.value.language === "python"), bt = U(() => !!(o.pythonEndpoint ?? "").trim()), Ge = U(
|
|
2262
|
+
() => gn.value && bt.value && ce.value === "server"
|
|
2263
|
+
), Me = U(() => !!(o.filesEndpoint ?? "").trim()), Dt = U(() => Ae.value || Ee.value && k.value === w.value.id ? !0 : I.value === "running" && k.value === w.value.id), bn = U(() => pe.value && v.value.mode === "http" ? Ee.value && k.value === w.value.id ? "查询中" : "外部服务" : Ge.value ? Ae.value ? De.value ? "等待输入" : "执行中" : "服务端" : I.value === "running" && k.value !== w.value.id ? "就绪" : {
|
|
2251
2264
|
idle: "未加载",
|
|
2252
2265
|
loading: "正在加载 Pyodide…",
|
|
2253
2266
|
ready: "就绪",
|
|
2254
2267
|
running: "运行中"
|
|
2255
|
-
}[I.value]),
|
|
2256
|
-
function
|
|
2268
|
+
}[I.value]), Or = U(() => pe.value && v.value.mode === "http" ? Ee.value && k.value === w.value.id ? "running" : "ready" : Ge.value ? Ae.value ? De.value ? "loading" : "running" : "ready" : I.value === "running" && k.value !== w.value.id ? "ready" : I.value), Mr = U(() => pe.value ? "执行 SQL (Ctrl+Enter)" : Ge.value ? "运行(服务端 Python,Ctrl+Enter)" : w.value.language === "python" ? "运行 (Ctrl+Enter)" : "仅支持执行 Python / SQL 文件"), Nr = U(() => Dt.value ? !0 : Ge.value || pe.value ? !1 : I.value === "loading" || w.value.language !== "python"), Tr = U(() => v.value.mode === "http" ? v.value.connectionId ? "SQL 连接配置" : "新建 SQL 连接" : "SQL 连接");
|
|
2269
|
+
function He(e) {
|
|
2257
2270
|
return { ...e };
|
|
2258
2271
|
}
|
|
2259
2272
|
function fe(e = w.value.id) {
|
|
2260
2273
|
let t = q.get(e);
|
|
2261
2274
|
return t || (t = { lines: [], sqlResults: [] }, q.set(e, t)), t;
|
|
2262
2275
|
}
|
|
2263
|
-
function
|
|
2264
|
-
fe(r).lines.push({ id: ++
|
|
2276
|
+
function ye(e, t, r) {
|
|
2277
|
+
fe(r).lines.push({ id: ++Sr, stream: e, text: t });
|
|
2265
2278
|
}
|
|
2266
|
-
function
|
|
2267
|
-
|
|
2279
|
+
function g(e, t) {
|
|
2280
|
+
ye("system", e, t);
|
|
2268
2281
|
}
|
|
2269
|
-
function
|
|
2270
|
-
return
|
|
2282
|
+
function Fr(e) {
|
|
2283
|
+
return Lt.some((t) => t.value === e);
|
|
2271
2284
|
}
|
|
2272
2285
|
function Lr() {
|
|
2273
2286
|
if (!o.storageKey || typeof window > "u") return null;
|
|
@@ -2277,10 +2290,10 @@ const Vs = Z(
|
|
|
2277
2290
|
const t = JSON.parse(e);
|
|
2278
2291
|
if (t.version !== tn || !Array.isArray(t.files)) return null;
|
|
2279
2292
|
const r = [];
|
|
2280
|
-
for (const
|
|
2281
|
-
if (!
|
|
2282
|
-
const S =
|
|
2283
|
-
r.push({ name:
|
|
2293
|
+
for (const h of t.files) {
|
|
2294
|
+
if (!h || typeof h.name != "string" || typeof h.code != "string" || !h.name.trim()) continue;
|
|
2295
|
+
const S = Fr(h.language) ? h.language : "python";
|
|
2296
|
+
r.push({ name: h.name, language: S, code: h.code });
|
|
2284
2297
|
}
|
|
2285
2298
|
if (!r.length) return null;
|
|
2286
2299
|
const u = typeof t.activeIndex == "number" ? t.activeIndex : 0, c = Math.min(Math.max(Math.trunc(u) || 0, 0), r.length - 1);
|
|
@@ -2292,49 +2305,49 @@ const Vs = Z(
|
|
|
2292
2305
|
function $r() {
|
|
2293
2306
|
const e = Lr();
|
|
2294
2307
|
if (!e) return;
|
|
2295
|
-
|
|
2296
|
-
const t =
|
|
2297
|
-
qe.value = t.id,
|
|
2308
|
+
F.value = e.files.map((r) => Je(r.name, r.language, r.code));
|
|
2309
|
+
const t = F.value[e.activeIndex] ?? F.value[0];
|
|
2310
|
+
qe.value = t.id, g(`已恢复上次编辑内容(${F.value.length} 个文件)`), i("update:modelValue", t.code), i("update:fileName", t.name), i("update:language", t.language);
|
|
2298
2311
|
}
|
|
2299
2312
|
function kn() {
|
|
2300
|
-
if (!(!
|
|
2313
|
+
if (!(!Rt || _t || !o.storageKey || typeof window > "u"))
|
|
2301
2314
|
try {
|
|
2302
2315
|
const e = {
|
|
2303
2316
|
version: tn,
|
|
2304
|
-
files:
|
|
2317
|
+
files: F.value.map((t) => ({
|
|
2305
2318
|
name: t.name,
|
|
2306
2319
|
language: t.language,
|
|
2307
2320
|
code: t.code
|
|
2308
2321
|
})),
|
|
2309
2322
|
activeIndex: Math.max(
|
|
2310
|
-
|
|
2323
|
+
F.value.findIndex((t) => t.id === qe.value),
|
|
2311
2324
|
0
|
|
2312
2325
|
)
|
|
2313
2326
|
};
|
|
2314
2327
|
window.localStorage.setItem(o.storageKey, JSON.stringify(e));
|
|
2315
2328
|
} catch (e) {
|
|
2316
|
-
vn || (vn = !0,
|
|
2329
|
+
vn || (vn = !0, g(`本地草稿保存失败:${e instanceof Error ? e.message : String(e)}`));
|
|
2317
2330
|
}
|
|
2318
2331
|
}
|
|
2319
|
-
function
|
|
2320
|
-
!
|
|
2332
|
+
function Rr() {
|
|
2333
|
+
!Rt || !o.storageKey || typeof window > "u" || (_t = !1, window.clearTimeout(yt), yt = window.setTimeout(kn, 400));
|
|
2321
2334
|
}
|
|
2322
2335
|
function _r() {
|
|
2323
2336
|
if (!(!o.storageKey || typeof window > "u")) {
|
|
2324
|
-
window.clearTimeout(
|
|
2337
|
+
window.clearTimeout(yt);
|
|
2325
2338
|
try {
|
|
2326
|
-
window.localStorage.removeItem(o.storageKey),
|
|
2339
|
+
window.localStorage.removeItem(o.storageKey), _t = !0, g("已清除本地草稿");
|
|
2327
2340
|
} catch (e) {
|
|
2328
|
-
|
|
2341
|
+
g(`清除本地草稿失败:${e instanceof Error ? e.message : String(e)}`);
|
|
2329
2342
|
}
|
|
2330
2343
|
}
|
|
2331
2344
|
}
|
|
2332
|
-
function
|
|
2345
|
+
function Ne(e) {
|
|
2333
2346
|
if (!P) return;
|
|
2334
2347
|
const t = e ? [e] : [];
|
|
2335
|
-
P.dispatch({ effects:
|
|
2348
|
+
P.dispatch({ effects: hr.of(t) });
|
|
2336
2349
|
}
|
|
2337
|
-
function
|
|
2350
|
+
function Ir() {
|
|
2338
2351
|
const e = o.modelValue;
|
|
2339
2352
|
if (P) {
|
|
2340
2353
|
e !== P.state.doc.toString() && P.dispatch({ changes: { from: 0, to: P.state.doc.length, insert: e } });
|
|
@@ -2343,7 +2356,7 @@ const Vs = Z(
|
|
|
2343
2356
|
const t = w.value;
|
|
2344
2357
|
t.code !== e && (t.code = e);
|
|
2345
2358
|
}
|
|
2346
|
-
function
|
|
2359
|
+
function Ce() {
|
|
2347
2360
|
return P ? P.state.doc.toString() : w.value.code;
|
|
2348
2361
|
}
|
|
2349
2362
|
function kt(e) {
|
|
@@ -2355,19 +2368,19 @@ const Vs = Z(
|
|
|
2355
2368
|
t.code = e, e !== o.modelValue && i("update:modelValue", e);
|
|
2356
2369
|
}
|
|
2357
2370
|
function zt(e) {
|
|
2358
|
-
return o.disableLint || e !== "python" ? [] :
|
|
2371
|
+
return o.disableLint || e !== "python" ? [] : Ss(V, o.lintDelay);
|
|
2359
2372
|
}
|
|
2360
2373
|
function jt(e) {
|
|
2361
2374
|
const t = w.value;
|
|
2362
2375
|
if (t.language !== e) {
|
|
2363
|
-
if (t.language = e, fe(t.id).sqlResults = [],
|
|
2376
|
+
if (t.language = e, fe(t.id).sqlResults = [], Ne(void 0), P == null || P.dispatch({
|
|
2364
2377
|
effects: [
|
|
2365
2378
|
Bt.reconfigure(en(e)),
|
|
2366
2379
|
Ut.reconfigure(zt(e))
|
|
2367
2380
|
]
|
|
2368
2381
|
}), /^untitled(-\d+)?\.[^.]+$/.test(t.name)) {
|
|
2369
2382
|
const u = `${t.name.slice(0, t.name.lastIndexOf("."))}.${Mt(e).extension}`;
|
|
2370
|
-
|
|
2383
|
+
F.value.some((c) => c.id !== t.id && c.name === u) || (t.name = u, i("update:fileName", u));
|
|
2371
2384
|
}
|
|
2372
2385
|
i("update:language", e);
|
|
2373
2386
|
}
|
|
@@ -2377,102 +2390,102 @@ const Vs = Z(
|
|
|
2377
2390
|
return /\.[^.\\/]+$/.test(u) ? u : `${u}.${Mt(t).extension}`;
|
|
2378
2391
|
}
|
|
2379
2392
|
function wn(e) {
|
|
2380
|
-
const t = Mt(e).extension, r = new Set(
|
|
2393
|
+
const t = Mt(e).extension, r = new Set(F.value.map((h) => h.name));
|
|
2381
2394
|
let u = `untitled.${t}`, c = 2;
|
|
2382
2395
|
for (; r.has(u); )
|
|
2383
2396
|
u = `untitled-${c}.${t}`, c += 1;
|
|
2384
2397
|
return u;
|
|
2385
2398
|
}
|
|
2386
2399
|
function Sn(e) {
|
|
2387
|
-
if (!
|
|
2400
|
+
if (!F.value.some((S) => S.name === e)) return e;
|
|
2388
2401
|
const t = e.lastIndexOf("."), r = t > 0 ? e.slice(0, t) : e, u = t > 0 ? e.slice(t) : "";
|
|
2389
|
-
let c = 2,
|
|
2390
|
-
for (;
|
|
2391
|
-
c += 1,
|
|
2392
|
-
return
|
|
2402
|
+
let c = 2, h = `${r}-${c}${u}`;
|
|
2403
|
+
for (; F.value.some((S) => S.name === h); )
|
|
2404
|
+
c += 1, h = `${r}-${c}${u}`;
|
|
2405
|
+
return h;
|
|
2393
2406
|
}
|
|
2394
2407
|
let We = 0;
|
|
2395
|
-
function
|
|
2408
|
+
function Hr(e) {
|
|
2396
2409
|
return !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
|
|
2397
2410
|
}
|
|
2398
|
-
async function
|
|
2411
|
+
async function Br() {
|
|
2399
2412
|
var t;
|
|
2400
2413
|
if (!o.syncFilesOnRun) return;
|
|
2401
|
-
const e =
|
|
2414
|
+
const e = F.value.filter((r) => r.language === "python");
|
|
2402
2415
|
for (const r of e) {
|
|
2403
|
-
if (!
|
|
2404
|
-
|
|
2416
|
+
if (!Hr(r.name)) {
|
|
2417
|
+
g(`跳过同步文件:${r.name}(文件名不能包含路径分隔符)`);
|
|
2405
2418
|
continue;
|
|
2406
2419
|
}
|
|
2407
|
-
const u = await
|
|
2408
|
-
u.ok ||
|
|
2420
|
+
const u = await V.writeFile(r.name, r.code);
|
|
2421
|
+
u.ok || g(`同步文件失败:${r.name}(${((t = u.error) == null ? void 0 : t.message) ?? "未知错误"})`);
|
|
2409
2422
|
}
|
|
2410
2423
|
}
|
|
2411
2424
|
function at() {
|
|
2412
|
-
Y == null || Y.abort(), Y = null,
|
|
2425
|
+
Y == null || Y.abort(), Y = null, Re.value = !1, nt.value = "", vt.value = !1;
|
|
2413
2426
|
}
|
|
2414
|
-
function
|
|
2427
|
+
function he() {
|
|
2415
2428
|
at(), ae.value = "";
|
|
2416
|
-
const e = D(
|
|
2417
|
-
|
|
2418
|
-
}
|
|
2419
|
-
function Br() {
|
|
2420
|
-
Re.value = !1, Fe.value = !0, ve();
|
|
2429
|
+
const e = D(v.value);
|
|
2430
|
+
v.value = e, i("update:sqlConfig", D(e));
|
|
2421
2431
|
}
|
|
2422
2432
|
function Ur() {
|
|
2423
|
-
|
|
2433
|
+
_e.value = !1, $e.value = !0, ve();
|
|
2424
2434
|
}
|
|
2425
2435
|
function Ar() {
|
|
2426
|
-
|
|
2427
|
-
|
|
2436
|
+
v.value.mode !== "http" && (v.value = D({ ...v.value, mode: "http" }), i("update:sqlConfig", D(v.value))), $e.value = !1, _e.value = !0, Ke.value = "", mt.value = !1, ve();
|
|
2437
|
+
}
|
|
2438
|
+
function Dr() {
|
|
2439
|
+
const e = v.value.connection.dialect, t = e === "sqlite" ? "mysql" : e;
|
|
2440
|
+
v.value = D({
|
|
2428
2441
|
mode: "http",
|
|
2429
|
-
endpoint:
|
|
2430
|
-
headers:
|
|
2431
|
-
maxRows:
|
|
2432
|
-
timeoutMs:
|
|
2433
|
-
connection: { dialect: t, port:
|
|
2434
|
-
}), ne.value = "", ae.value = "",
|
|
2442
|
+
endpoint: v.value.endpoint,
|
|
2443
|
+
headers: v.value.headers,
|
|
2444
|
+
maxRows: v.value.maxRows,
|
|
2445
|
+
timeoutMs: v.value.timeoutMs,
|
|
2446
|
+
connection: { dialect: t, port: ur(t) }
|
|
2447
|
+
}), ne.value = "", ae.value = "", Oe.value = "", at(), i("update:sqlConfig", D(v.value)), _e.value = !1, $e.value = !0, ve();
|
|
2435
2448
|
}
|
|
2436
2449
|
function xn() {
|
|
2437
|
-
|
|
2438
|
-
}
|
|
2439
|
-
function Dr() {
|
|
2440
|
-
const e = f.value;
|
|
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();
|
|
2450
|
+
$e.value = !1;
|
|
2442
2451
|
}
|
|
2443
2452
|
function zr() {
|
|
2444
|
-
const e =
|
|
2445
|
-
|
|
2453
|
+
const e = v.value;
|
|
2454
|
+
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 = ur("mysql")), e.connection.database === ":memory:" && (e.connection.database = "")), he(), e.mode === "http" && ve();
|
|
2455
|
+
}
|
|
2456
|
+
function jr() {
|
|
2457
|
+
const e = v.value.connection, t = dt.find((u) => u.value === e.dialect), r = dt.map((u) => u.defaultPort);
|
|
2458
|
+
t != null && t.defaultPort && (!e.port || r.includes(e.port)) && (e.port = t.defaultPort), he();
|
|
2446
2459
|
}
|
|
2447
2460
|
async function ve() {
|
|
2448
|
-
const e = D(
|
|
2461
|
+
const e = D(v.value);
|
|
2449
2462
|
if (!e.endpoint) {
|
|
2450
|
-
|
|
2463
|
+
Pe.value = [], Oe.value = "";
|
|
2451
2464
|
return;
|
|
2452
2465
|
}
|
|
2453
2466
|
se == null || se.abort();
|
|
2454
2467
|
const t = new AbortController();
|
|
2455
|
-
se = t,
|
|
2468
|
+
se = t, Ve.value = !0, Oe.value = "";
|
|
2456
2469
|
try {
|
|
2457
|
-
const r = await
|
|
2470
|
+
const r = await zs(e, { signal: t.signal });
|
|
2458
2471
|
if (se !== t) return;
|
|
2459
|
-
|
|
2460
|
-
const u = r.find((c) => c.id ===
|
|
2461
|
-
u ? ne.value = u.name :
|
|
2472
|
+
Pe.value = r;
|
|
2473
|
+
const u = r.find((c) => c.id === v.value.connectionId);
|
|
2474
|
+
u ? ne.value = u.name : v.value.connectionId && (v.value.connectionId = void 0, ne.value = "");
|
|
2462
2475
|
} catch (r) {
|
|
2463
2476
|
if (se !== t) return;
|
|
2464
|
-
|
|
2477
|
+
Pe.value = [], Oe.value = r instanceof Error ? r.message : String(r);
|
|
2465
2478
|
} finally {
|
|
2466
|
-
se === t && (se = null,
|
|
2479
|
+
se === t && (se = null, Ve.value = !1);
|
|
2467
2480
|
}
|
|
2468
2481
|
}
|
|
2469
2482
|
function En(e) {
|
|
2470
|
-
|
|
2483
|
+
v.value = D({
|
|
2471
2484
|
mode: "http",
|
|
2472
|
-
endpoint:
|
|
2473
|
-
headers:
|
|
2474
|
-
maxRows:
|
|
2475
|
-
timeoutMs:
|
|
2485
|
+
endpoint: v.value.endpoint,
|
|
2486
|
+
headers: v.value.headers,
|
|
2487
|
+
maxRows: v.value.maxRows,
|
|
2488
|
+
timeoutMs: v.value.timeoutMs,
|
|
2476
2489
|
connectionId: e.id,
|
|
2477
2490
|
connection: {
|
|
2478
2491
|
dialect: e.dialect,
|
|
@@ -2483,28 +2496,28 @@ const Vs = Z(
|
|
|
2483
2496
|
database: e.database ?? "",
|
|
2484
2497
|
options: e.options
|
|
2485
2498
|
}
|
|
2486
|
-
}), ne.value = e.name, ae.value = "", at(), i("update:sqlConfig", D(
|
|
2499
|
+
}), ne.value = e.name, ae.value = "", at(), i("update:sqlConfig", D(v.value));
|
|
2487
2500
|
}
|
|
2488
|
-
function
|
|
2489
|
-
|
|
2490
|
-
const e =
|
|
2501
|
+
function Vr() {
|
|
2502
|
+
$e.value = !1, _e.value = !1;
|
|
2503
|
+
const e = Pe.value.find((t) => t.id === v.value.connectionId);
|
|
2491
2504
|
if (!e) {
|
|
2492
|
-
|
|
2505
|
+
v.value.connectionId = void 0, v.value.connection.password = "", ne.value = "", he();
|
|
2493
2506
|
return;
|
|
2494
2507
|
}
|
|
2495
2508
|
En(e);
|
|
2496
2509
|
}
|
|
2497
|
-
function
|
|
2498
|
-
En(e),
|
|
2510
|
+
function Qr(e) {
|
|
2511
|
+
En(e), _e.value = !1, $e.value = !0;
|
|
2499
2512
|
}
|
|
2500
|
-
async function
|
|
2513
|
+
async function Kr() {
|
|
2501
2514
|
if (re.value) return;
|
|
2502
2515
|
const e = ne.value.trim();
|
|
2503
2516
|
if (!e) {
|
|
2504
|
-
|
|
2517
|
+
Qe.value = !1, ae.value = "请先填写连接名称";
|
|
2505
2518
|
return;
|
|
2506
2519
|
}
|
|
2507
|
-
const t = D(
|
|
2520
|
+
const t = D(v.value), r = {
|
|
2508
2521
|
name: e,
|
|
2509
2522
|
dialect: t.connection.dialect,
|
|
2510
2523
|
host: t.connection.host,
|
|
@@ -2516,50 +2529,50 @@ const Vs = Z(
|
|
|
2516
2529
|
};
|
|
2517
2530
|
re.value = !0, ae.value = "";
|
|
2518
2531
|
try {
|
|
2519
|
-
const u = await
|
|
2520
|
-
|
|
2532
|
+
const u = await js(t, r, t.connectionId);
|
|
2533
|
+
v.value = D({
|
|
2521
2534
|
...t,
|
|
2522
2535
|
connectionId: u.id,
|
|
2523
2536
|
connection: { ...t.connection, password: "" }
|
|
2524
|
-
}), ne.value = u.name,
|
|
2537
|
+
}), ne.value = u.name, Qe.value = !0, ae.value = "连接已保存", i("update:sqlConfig", D(v.value)), await ve();
|
|
2525
2538
|
} catch (u) {
|
|
2526
|
-
|
|
2539
|
+
Qe.value = !1, ae.value = u instanceof Error ? u.message : String(u);
|
|
2527
2540
|
} finally {
|
|
2528
2541
|
re.value = !1;
|
|
2529
2542
|
}
|
|
2530
2543
|
}
|
|
2531
|
-
async function
|
|
2532
|
-
const e =
|
|
2544
|
+
async function Jr() {
|
|
2545
|
+
const e = v.value.connectionId;
|
|
2533
2546
|
if (!(!e || re.value) && !(typeof window < "u" && !window.confirm("确定删除该连接配置?"))) {
|
|
2534
2547
|
re.value = !0, ae.value = "";
|
|
2535
2548
|
try {
|
|
2536
|
-
await
|
|
2549
|
+
await cr(v.value, e), v.value.connectionId = void 0, ne.value = "", Qe.value = !0, ae.value = "连接已删除", i("update:sqlConfig", D(v.value)), await ve();
|
|
2537
2550
|
} catch (t) {
|
|
2538
|
-
|
|
2551
|
+
Qe.value = !1, ae.value = t instanceof Error ? t.message : String(t);
|
|
2539
2552
|
} finally {
|
|
2540
2553
|
re.value = !1;
|
|
2541
2554
|
}
|
|
2542
2555
|
}
|
|
2543
2556
|
}
|
|
2544
|
-
async function
|
|
2557
|
+
async function Zr(e) {
|
|
2545
2558
|
if (!re.value && !(typeof window < "u" && !window.confirm(`确定删除连接“${e.name}”?`))) {
|
|
2546
|
-
re.value = !0,
|
|
2559
|
+
re.value = !0, Ke.value = "";
|
|
2547
2560
|
try {
|
|
2548
|
-
await
|
|
2561
|
+
await cr(v.value, e.id), v.value.connectionId === e.id && (v.value.connectionId = void 0, v.value.connection.password = "", ne.value = "", i("update:sqlConfig", D(v.value))), mt.value = !0, Ke.value = `已删除连接“${e.name}”`, await ve();
|
|
2549
2562
|
} catch (t) {
|
|
2550
|
-
mt.value = !1,
|
|
2563
|
+
mt.value = !1, Ke.value = t instanceof Error ? t.message : String(t);
|
|
2551
2564
|
} finally {
|
|
2552
2565
|
re.value = !1;
|
|
2553
2566
|
}
|
|
2554
2567
|
}
|
|
2555
2568
|
}
|
|
2556
|
-
async function
|
|
2557
|
-
if (
|
|
2558
|
-
at(),
|
|
2569
|
+
async function Gr() {
|
|
2570
|
+
if (Re.value) return;
|
|
2571
|
+
at(), Re.value = !0;
|
|
2559
2572
|
const e = new AbortController();
|
|
2560
2573
|
Y = e;
|
|
2561
2574
|
try {
|
|
2562
|
-
const t = await
|
|
2575
|
+
const t = await Ds(D(v.value), {
|
|
2563
2576
|
executor: o.sqlExecutor,
|
|
2564
2577
|
signal: e.signal
|
|
2565
2578
|
});
|
|
@@ -2569,13 +2582,13 @@ const Vs = Z(
|
|
|
2569
2582
|
if (Y !== e) return;
|
|
2570
2583
|
vt.value = !1, nt.value = t instanceof Error ? t.message : String(t);
|
|
2571
2584
|
} finally {
|
|
2572
|
-
Y === e && (Y = null,
|
|
2585
|
+
Y === e && (Y = null, Re.value = !1);
|
|
2573
2586
|
}
|
|
2574
2587
|
}
|
|
2575
|
-
function
|
|
2588
|
+
function Wr(e) {
|
|
2576
2589
|
return e === null ? "NULL" : String(e);
|
|
2577
2590
|
}
|
|
2578
|
-
function
|
|
2591
|
+
function Yr(e) {
|
|
2579
2592
|
return e.columns.length ? `${e.rows.length} 行${e.truncated ? "(已截断)" : ""}` : `影响 ${e.affectedRows ?? 0} 行`;
|
|
2580
2593
|
}
|
|
2581
2594
|
function qn(e) {
|
|
@@ -2584,30 +2597,30 @@ const Vs = Z(
|
|
|
2584
2597
|
}
|
|
2585
2598
|
async function Cn() {
|
|
2586
2599
|
if (Ee.value)
|
|
2587
|
-
return k.value !== w.value.id &&
|
|
2588
|
-
const e =
|
|
2600
|
+
return k.value !== w.value.id && g("另一个 SQL 正在执行,请等待或停止后再试"), null;
|
|
2601
|
+
const e = Ce();
|
|
2589
2602
|
if (!e.trim())
|
|
2590
|
-
return
|
|
2591
|
-
const t = D(
|
|
2592
|
-
Ee.value = !0, k.value = u, de = new AbortController(),
|
|
2603
|
+
return g("SQL 内容为空,请输入要执行的语句"), null;
|
|
2604
|
+
const t = D(v.value), r = ++rt, u = w.value.id;
|
|
2605
|
+
Ee.value = !0, k.value = u, de = new AbortController(), Ne(void 0), o.clearOutputOnRun && (fe(u).lines = [], fe(u).sqlResults = []), g(
|
|
2593
2606
|
`开始执行 SQL(${t.mode === "sqlite" ? "浏览器内 SQLite" : "HTTP 服务"})`,
|
|
2594
2607
|
u
|
|
2595
2608
|
), i("runStart");
|
|
2596
2609
|
try {
|
|
2597
|
-
const c = await
|
|
2610
|
+
const c = await wr(t, e, {
|
|
2598
2611
|
executor: o.sqlExecutor,
|
|
2599
2612
|
signal: de.signal
|
|
2600
2613
|
});
|
|
2601
2614
|
if (r !== rt) return null;
|
|
2602
2615
|
if (fe(u).sqlResults = c.results ?? [], c.ok) {
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2605
|
-
`SQL 执行完成:${
|
|
2616
|
+
const h = c.results ?? [], S = h.reduce((L, X) => L + X.rows.length, 0);
|
|
2617
|
+
g(
|
|
2618
|
+
`SQL 执行完成:${h.length} 个结果集,共 ${S} 行,耗时 ${(c.durationMs / 1e3).toFixed(2)}s`,
|
|
2606
2619
|
u
|
|
2607
2620
|
);
|
|
2608
2621
|
} else {
|
|
2609
|
-
const
|
|
2610
|
-
|
|
2622
|
+
const h = c.error ?? { type: "SqlError", message: "SQL 执行失败" };
|
|
2623
|
+
g(`SQL 执行出错:${h.type}`, u), ye("stderr", h.message, u), i("runOutput", { stream: "stderr", text: h.message }), i("sqlError", h);
|
|
2611
2624
|
}
|
|
2612
2625
|
return i("sqlResult", c), i("runFinish", {
|
|
2613
2626
|
ok: c.ok,
|
|
@@ -2616,58 +2629,58 @@ const Vs = Z(
|
|
|
2616
2629
|
}), c;
|
|
2617
2630
|
} catch (c) {
|
|
2618
2631
|
if (r !== rt) return null;
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2621
|
-
const S = { type: "SqlError", message:
|
|
2632
|
+
const h = c instanceof Error ? c.message : String(c);
|
|
2633
|
+
g(`SQL 执行失败:${h}`, u);
|
|
2634
|
+
const S = { type: "SqlError", message: h };
|
|
2622
2635
|
return i("sqlError", S), i("runFinish", { ok: !1, durationMs: 0, error: qn(S) }), null;
|
|
2623
2636
|
} finally {
|
|
2624
2637
|
r === rt && (Ee.value = !1, de = null, k.value === u && (k.value = null));
|
|
2625
2638
|
}
|
|
2626
2639
|
}
|
|
2627
|
-
async function
|
|
2628
|
-
return e !== void 0 && (kt(e), w.value.language !== "sql" && jt("sql")), w.value.language !== "sql" ? (
|
|
2640
|
+
async function Xr(e) {
|
|
2641
|
+
return e !== void 0 && (kt(e), w.value.language !== "sql" && jt("sql")), w.value.language !== "sql" ? (g("当前文件不是 SQL,无法执行"), null) : Cn();
|
|
2629
2642
|
}
|
|
2630
|
-
function
|
|
2643
|
+
function ea(e) {
|
|
2631
2644
|
const t = e.target.value === "server" ? "server" : "browser";
|
|
2632
2645
|
if (t === "browser")
|
|
2633
|
-
for (const r of [...
|
|
2646
|
+
for (const r of [...N.keys()])
|
|
2634
2647
|
st(r, !1);
|
|
2635
|
-
ce.value = t, i("update:runtime", t),
|
|
2648
|
+
ce.value = t, i("update:runtime", t), g(t === "server" ? "已切换到服务端 Python 环境" : "已切换到浏览器 Python 环境");
|
|
2636
2649
|
}
|
|
2637
2650
|
function Pn(e, t, r, u) {
|
|
2638
2651
|
if (!u) return;
|
|
2639
2652
|
const c = u.replace(/\r\n/g, `
|
|
2640
2653
|
`);
|
|
2641
|
-
let
|
|
2642
|
-
|
|
2643
|
-
const S =
|
|
2644
|
-
`),
|
|
2645
|
-
r === "stdout" ? t.stdoutBuffer =
|
|
2654
|
+
let h = r === "stdout" ? t.stdoutBuffer : t.stderrBuffer;
|
|
2655
|
+
h += c;
|
|
2656
|
+
const S = h.split(`
|
|
2657
|
+
`), L = S.pop() ?? "";
|
|
2658
|
+
r === "stdout" ? t.stdoutBuffer = L : t.stderrBuffer = L;
|
|
2646
2659
|
for (const X of S)
|
|
2647
|
-
|
|
2660
|
+
ye(r, X, e), i("runOutput", { stream: r, text: X });
|
|
2648
2661
|
}
|
|
2649
2662
|
function On(e, t) {
|
|
2650
|
-
t.stdoutBuffer && (
|
|
2663
|
+
t.stdoutBuffer && (ye("stdout", t.stdoutBuffer, e), i("runOutput", { stream: "stdout", text: t.stdoutBuffer }), t.stdoutBuffer = ""), t.stderrBuffer && (ye("stderr", t.stderrBuffer, e), i("runOutput", { stream: "stderr", text: t.stderrBuffer }), t.stderrBuffer = "");
|
|
2651
2664
|
}
|
|
2652
2665
|
function wt(e, t, r) {
|
|
2653
2666
|
window.clearTimeout(t.pollTimer), On(e, t);
|
|
2654
|
-
const u =
|
|
2655
|
-
if (u && u.token === t.token &&
|
|
2656
|
-
|
|
2657
|
-
const
|
|
2667
|
+
const u = N.get(e);
|
|
2668
|
+
if (u && u.token === t.token && N.delete(e), r.error) {
|
|
2669
|
+
g(`执行出错:${r.error.type}`, e), e === w.value.id && Ne(r.error.line);
|
|
2670
|
+
const h = {
|
|
2658
2671
|
type: r.error.type,
|
|
2659
2672
|
message: r.error.message,
|
|
2660
2673
|
line: r.error.line,
|
|
2661
2674
|
traceback: r.error.traceback ?? ""
|
|
2662
2675
|
};
|
|
2663
|
-
i("runError",
|
|
2676
|
+
i("runError", h), i("runFinish", { ok: !1, durationMs: r.durationMs ?? 0, error: h });
|
|
2664
2677
|
return;
|
|
2665
2678
|
}
|
|
2666
2679
|
const c = r.durationMs ?? 0;
|
|
2667
|
-
|
|
2680
|
+
g(`执行完成,会话时长 ${(c / 1e3).toFixed(2)}s`, e), i("runFinish", { ok: !0, durationMs: c });
|
|
2668
2681
|
}
|
|
2669
2682
|
function Qt(e, t, r, u) {
|
|
2670
|
-
const c =
|
|
2683
|
+
const c = N.get(e);
|
|
2671
2684
|
if (!(!c || c.token !== u)) {
|
|
2672
2685
|
if (Pn(e, t, "stdout", r.stdout), Pn(e, t, "stderr", r.stderr), r.state === "exited") {
|
|
2673
2686
|
wt(e, t, r);
|
|
@@ -2677,48 +2690,48 @@ const Vs = Z(
|
|
|
2677
2690
|
t.waiting = !0;
|
|
2678
2691
|
return;
|
|
2679
2692
|
}
|
|
2680
|
-
t.waiting = !1,
|
|
2693
|
+
t.waiting = !1, ta(e, t, u);
|
|
2681
2694
|
}
|
|
2682
2695
|
}
|
|
2683
|
-
function
|
|
2696
|
+
function ta(e, t, r) {
|
|
2684
2697
|
window.clearTimeout(t.pollTimer), t.pollTimer = window.setTimeout(() => {
|
|
2685
|
-
|
|
2698
|
+
na(e, r);
|
|
2686
2699
|
}, 250);
|
|
2687
2700
|
}
|
|
2688
|
-
async function
|
|
2701
|
+
async function na(e, t) {
|
|
2689
2702
|
var u, c;
|
|
2690
|
-
const r =
|
|
2703
|
+
const r = N.get(e);
|
|
2691
2704
|
if (!(!r || r.token !== t || !r.sessionId))
|
|
2692
2705
|
try {
|
|
2693
|
-
const
|
|
2706
|
+
const h = await _s(o.pythonEndpoint, r.sessionId, {
|
|
2694
2707
|
headers: o.pythonHeaders,
|
|
2695
2708
|
signal: (u = r.abort) == null ? void 0 : u.signal
|
|
2696
2709
|
});
|
|
2697
|
-
Qt(e, r,
|
|
2698
|
-
} catch (
|
|
2699
|
-
if (((c =
|
|
2700
|
-
const S =
|
|
2701
|
-
|
|
2710
|
+
Qt(e, r, h, t);
|
|
2711
|
+
} catch (h) {
|
|
2712
|
+
if (((c = N.get(e)) == null ? void 0 : c.token) !== t) return;
|
|
2713
|
+
const S = h instanceof Error ? h.message : String(h);
|
|
2714
|
+
g(`执行失败:${S}`, e), wt(e, r, {
|
|
2702
2715
|
sessionId: r.sessionId,
|
|
2703
2716
|
durationMs: 0,
|
|
2704
2717
|
error: { type: "RuntimeError", message: S }
|
|
2705
2718
|
});
|
|
2706
2719
|
}
|
|
2707
2720
|
}
|
|
2708
|
-
async function
|
|
2709
|
-
var
|
|
2721
|
+
async function ra() {
|
|
2722
|
+
var h;
|
|
2710
2723
|
const e = w.value.id;
|
|
2711
|
-
if ((
|
|
2724
|
+
if ((h = N.get(e)) != null && h.busy) return;
|
|
2712
2725
|
if (!bt.value) {
|
|
2713
|
-
|
|
2726
|
+
g("未配置 Python 服务端点(pythonEndpoint)");
|
|
2714
2727
|
return;
|
|
2715
2728
|
}
|
|
2716
|
-
const t =
|
|
2729
|
+
const t = Ce();
|
|
2717
2730
|
if (!t.trim()) {
|
|
2718
|
-
|
|
2731
|
+
g("代码为空,请输入要执行的 Python 代码");
|
|
2719
2732
|
return;
|
|
2720
2733
|
}
|
|
2721
|
-
const r = ++
|
|
2734
|
+
const r = ++Er, u = {
|
|
2722
2735
|
sessionId: "",
|
|
2723
2736
|
busy: !0,
|
|
2724
2737
|
waiting: !1,
|
|
@@ -2729,27 +2742,27 @@ const Vs = Z(
|
|
|
2729
2742
|
stdoutBuffer: "",
|
|
2730
2743
|
stderrBuffer: ""
|
|
2731
2744
|
};
|
|
2732
|
-
|
|
2733
|
-
const c =
|
|
2734
|
-
|
|
2745
|
+
N.set(e, u);
|
|
2746
|
+
const c = N.get(e);
|
|
2747
|
+
Ne(void 0), o.clearOutputOnRun && (fe(e).lines = []), g("开始执行(服务端 Python)", e), i("runStart");
|
|
2735
2748
|
try {
|
|
2736
|
-
const S = await
|
|
2749
|
+
const S = await Rs(o.pythonEndpoint, t, {
|
|
2737
2750
|
stdin: o.stdin,
|
|
2738
2751
|
headers: o.pythonHeaders,
|
|
2739
2752
|
signal: c.abort.signal
|
|
2740
|
-
}),
|
|
2741
|
-
if (
|
|
2742
|
-
S.sessionId &&
|
|
2753
|
+
}), L = N.get(e);
|
|
2754
|
+
if (!L || L.token !== r) {
|
|
2755
|
+
S.sessionId && ar(o.pythonEndpoint, S.sessionId, {
|
|
2743
2756
|
headers: o.pythonHeaders
|
|
2744
2757
|
});
|
|
2745
2758
|
return;
|
|
2746
2759
|
}
|
|
2747
|
-
|
|
2760
|
+
L.sessionId = S.sessionId, Qt(e, L, S, r);
|
|
2748
2761
|
} catch (S) {
|
|
2749
|
-
const
|
|
2750
|
-
if (
|
|
2762
|
+
const L = N.get(e);
|
|
2763
|
+
if (!L || L.token !== r) return;
|
|
2751
2764
|
const X = S instanceof Error ? S.message : String(S);
|
|
2752
|
-
|
|
2765
|
+
g(`执行失败:${X}`, e), wt(e, L, {
|
|
2753
2766
|
durationMs: 0,
|
|
2754
2767
|
error: { type: "RuntimeError", message: X }
|
|
2755
2768
|
});
|
|
@@ -2757,20 +2770,20 @@ const Vs = Z(
|
|
|
2757
2770
|
}
|
|
2758
2771
|
async function Mn() {
|
|
2759
2772
|
var u, c;
|
|
2760
|
-
const e = w.value.id, t =
|
|
2773
|
+
const e = w.value.id, t = N.get(e);
|
|
2761
2774
|
if (!t || !t.waiting || !t.sessionId) return;
|
|
2762
2775
|
const r = t.input;
|
|
2763
|
-
t.input = "", t.waiting = !1,
|
|
2776
|
+
t.input = "", t.waiting = !1, ye("stdout", r, e), i("runOutput", { stream: "stdout", text: r });
|
|
2764
2777
|
try {
|
|
2765
|
-
const
|
|
2778
|
+
const h = await Is(o.pythonEndpoint, t.sessionId, r, {
|
|
2766
2779
|
headers: o.pythonHeaders,
|
|
2767
2780
|
signal: (u = t.abort) == null ? void 0 : u.signal
|
|
2768
2781
|
});
|
|
2769
|
-
Qt(e, t,
|
|
2770
|
-
} catch (
|
|
2771
|
-
if (((c =
|
|
2772
|
-
const S =
|
|
2773
|
-
|
|
2782
|
+
Qt(e, t, h, t.token);
|
|
2783
|
+
} catch (h) {
|
|
2784
|
+
if (((c = N.get(e)) == null ? void 0 : c.token) !== t.token) return;
|
|
2785
|
+
const S = h instanceof Error ? h.message : String(h);
|
|
2786
|
+
g(`执行失败:${S}`, e), wt(e, t, {
|
|
2774
2787
|
sessionId: t.sessionId,
|
|
2775
2788
|
durationMs: 0,
|
|
2776
2789
|
error: { type: "RuntimeError", message: S }
|
|
@@ -2779,23 +2792,23 @@ const Vs = Z(
|
|
|
2779
2792
|
}
|
|
2780
2793
|
function st(e, t = !0) {
|
|
2781
2794
|
var u;
|
|
2782
|
-
const r =
|
|
2783
|
-
r && (window.clearTimeout(r.pollTimer),
|
|
2795
|
+
const r = N.get(e);
|
|
2796
|
+
r && (window.clearTimeout(r.pollTimer), N.delete(e), (u = r.abort) == null || u.abort(), r.sessionId && ar(o.pythonEndpoint, r.sessionId, {
|
|
2784
2797
|
headers: o.pythonHeaders
|
|
2785
|
-
}), t &&
|
|
2798
|
+
}), t && g("执行已中断", e));
|
|
2786
2799
|
}
|
|
2787
|
-
async function
|
|
2788
|
-
var c,
|
|
2800
|
+
async function Nn() {
|
|
2801
|
+
var c, h, S;
|
|
2789
2802
|
if (w.value.language === "sql") {
|
|
2790
2803
|
await Cn();
|
|
2791
2804
|
return;
|
|
2792
2805
|
}
|
|
2793
|
-
if (
|
|
2794
|
-
await
|
|
2806
|
+
if (Ge.value) {
|
|
2807
|
+
await ra();
|
|
2795
2808
|
return;
|
|
2796
2809
|
}
|
|
2797
2810
|
if (I.value === "running") {
|
|
2798
|
-
k.value !== w.value.id &&
|
|
2811
|
+
k.value !== w.value.id && g(
|
|
2799
2812
|
"浏览器环境共享同一个 Pyodide 实例,暂不支持同时运行多个文件;可切换到服务端环境后并行执行"
|
|
2800
2813
|
);
|
|
2801
2814
|
return;
|
|
@@ -2803,97 +2816,97 @@ const Vs = Z(
|
|
|
2803
2816
|
if (I.value === "loading") return;
|
|
2804
2817
|
const e = w.value.language;
|
|
2805
2818
|
if (e !== "python") {
|
|
2806
|
-
|
|
2819
|
+
g(`当前文件为 ${Mt(e).label},仅支持执行 Python / SQL 代码`);
|
|
2807
2820
|
return;
|
|
2808
2821
|
}
|
|
2809
2822
|
We += 1;
|
|
2810
2823
|
const t = We, r = w.value.id;
|
|
2811
|
-
k.value = r,
|
|
2812
|
-
const u =
|
|
2824
|
+
k.value = r, Ne(void 0), o.clearOutputOnRun && (fe(r).lines = []), g("开始执行", r), i("runStart");
|
|
2825
|
+
const u = Ce();
|
|
2813
2826
|
try {
|
|
2814
|
-
await
|
|
2815
|
-
const
|
|
2827
|
+
await Br();
|
|
2828
|
+
const L = await V.run(u, {
|
|
2816
2829
|
stdin: o.stdin,
|
|
2817
2830
|
onOutput: (X, it) => {
|
|
2818
|
-
|
|
2831
|
+
ye(X, it, r), i("runOutput", { stream: X, text: it });
|
|
2819
2832
|
}
|
|
2820
2833
|
});
|
|
2821
2834
|
if (t !== We) return;
|
|
2822
|
-
|
|
2823
|
-
} catch (
|
|
2835
|
+
L.interrupted ? g("执行已中断", r) : L.ok ? g(`执行完成,耗时 ${(L.durationMs / 1e3).toFixed(2)}s`, r) : (g(`执行出错:${((c = L.error) == null ? void 0 : c.type) ?? "未知错误"}`, r), (h = L.error) != null && h.traceback && (ye("stderr", L.error.traceback, r), i("runOutput", { stream: "stderr", text: L.error.traceback })), w.value.id === r && Ne((S = L.error) == null ? void 0 : S.line), L.error && i("runError", L.error)), i("runFinish", L);
|
|
2836
|
+
} catch (L) {
|
|
2824
2837
|
if (t !== We) return;
|
|
2825
|
-
const X =
|
|
2826
|
-
|
|
2838
|
+
const X = L instanceof Error ? L.message : String(L);
|
|
2839
|
+
g(`执行失败:${X}`, r);
|
|
2827
2840
|
const it = { type: "RuntimeError", message: X, traceback: "" };
|
|
2828
2841
|
i("runError", it), i("runFinish", { ok: !1, durationMs: 0, error: it });
|
|
2829
2842
|
} finally {
|
|
2830
2843
|
t === We && k.value === r && (k.value = null);
|
|
2831
2844
|
}
|
|
2832
2845
|
}
|
|
2833
|
-
async function
|
|
2846
|
+
async function aa() {
|
|
2834
2847
|
var t;
|
|
2835
2848
|
if (mn) return;
|
|
2836
2849
|
const e = o.preloadPackages;
|
|
2837
2850
|
if (e.length) {
|
|
2838
|
-
mn = !0,
|
|
2851
|
+
mn = !0, g(`正在安装预置包:${e.join(", ")}`);
|
|
2839
2852
|
try {
|
|
2840
|
-
const r = await
|
|
2841
|
-
onOutput: (u, c) =>
|
|
2853
|
+
const r = await V.loadPackages(e, {
|
|
2854
|
+
onOutput: (u, c) => ye(u, c)
|
|
2842
2855
|
});
|
|
2843
|
-
|
|
2856
|
+
g(
|
|
2844
2857
|
r.ok ? `预置包安装完成(${(r.durationMs / 1e3).toFixed(1)}s)` : `预置包安装失败:${((t = r.error) == null ? void 0 : t.message) ?? "未知错误"}`
|
|
2845
2858
|
);
|
|
2846
2859
|
} catch (r) {
|
|
2847
|
-
|
|
2860
|
+
g(`预置包安装失败:${r instanceof Error ? r.message : String(r)}`);
|
|
2848
2861
|
}
|
|
2849
2862
|
}
|
|
2850
2863
|
}
|
|
2851
|
-
|
|
2864
|
+
Ra(() => {
|
|
2852
2865
|
const e = b.value;
|
|
2853
2866
|
if (!e) return;
|
|
2854
|
-
$r(),
|
|
2867
|
+
$r(), Rt = !0;
|
|
2855
2868
|
const t = [
|
|
2856
|
-
|
|
2869
|
+
yn.of([
|
|
2857
2870
|
nn.readOnly.of(o.readOnly),
|
|
2858
|
-
|
|
2871
|
+
Le.editable.of(!o.readOnly)
|
|
2859
2872
|
]),
|
|
2860
2873
|
Ut.of(zt(w.value.language)),
|
|
2861
|
-
Ht.of(
|
|
2874
|
+
Ht.of(Nt(ut(j.value)))
|
|
2862
2875
|
];
|
|
2863
2876
|
try {
|
|
2864
|
-
P =
|
|
2877
|
+
P = ws(e, {
|
|
2865
2878
|
value: w.value.code,
|
|
2866
|
-
dark: ut(
|
|
2879
|
+
dark: ut(j.value),
|
|
2867
2880
|
placeholderText: o.placeholder,
|
|
2868
2881
|
language: Bt.of(en(w.value.language)),
|
|
2869
2882
|
extensions: t,
|
|
2870
2883
|
onDocChange: (r) => {
|
|
2871
2884
|
w.value.code = r, r !== o.modelValue && i("update:modelValue", r);
|
|
2872
2885
|
},
|
|
2873
|
-
onRunShortcut:
|
|
2886
|
+
onRunShortcut: Nn
|
|
2874
2887
|
});
|
|
2875
2888
|
} catch (r) {
|
|
2876
2889
|
const u = r instanceof Error ? r.message : String(r);
|
|
2877
|
-
console.error("[princess-python-editor] 编辑器初始化失败", r),
|
|
2890
|
+
console.error("[princess-python-editor] 编辑器初始化失败", r), g(`编辑器初始化失败:${u}`), e.innerHTML = "";
|
|
2878
2891
|
const c = document.createElement("div");
|
|
2879
2892
|
c.className = "vpe-init-error", c.textContent = `编辑器初始化失败:${u}`, e.appendChild(c);
|
|
2880
2893
|
return;
|
|
2881
2894
|
}
|
|
2882
|
-
o.autofocus && P.focus(),
|
|
2883
|
-
I.value = r, r === "ready" && (u &&
|
|
2884
|
-
}),
|
|
2885
|
-
|
|
2886
|
-
}), I.value =
|
|
2895
|
+
o.autofocus && P.focus(), ht = V.on("status", (r, u) => {
|
|
2896
|
+
I.value = r, r === "ready" && (u && g(`Pyodide ${u} 就绪`), i("ready"), P && !o.disableLint && w.value.language === "python" && Ka(P)), i("statusChange", r);
|
|
2897
|
+
}), gt = V.on("initError", (r) => {
|
|
2898
|
+
g(`Pyodide 加载失败:${r}`), i("loadError", r);
|
|
2899
|
+
}), I.value = V.status, pe.value && ve(), typeof ResizeObserver < "u" && f.value && (Ze = new ResizeObserver(() => {
|
|
2887
2900
|
x.value !== null && Kt(x.value);
|
|
2888
|
-
}),
|
|
2901
|
+
}), Ze.observe(f.value)), o.preloadPackages.length ? V.waitReady().then(() => aa()).catch((r) => g(r.message)) : o.preload && V.waitReady().catch((r) => g(r.message));
|
|
2889
2902
|
}), _a(() => {
|
|
2890
|
-
|
|
2891
|
-
for (const e of [...
|
|
2903
|
+
ht == null || ht(), gt == null || gt(), ot(), Ze == null || Ze.disconnect(), Ze = 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;
|
|
2904
|
+
for (const e of [...N.keys()])
|
|
2892
2905
|
st(e, !1);
|
|
2893
|
-
window.clearTimeout(It), window.clearTimeout(
|
|
2906
|
+
window.clearTimeout(It), window.clearTimeout(yt), kn(), P == null || P.destroy(), P = null;
|
|
2894
2907
|
}), ee(
|
|
2895
2908
|
() => o.modelValue,
|
|
2896
|
-
() =>
|
|
2909
|
+
() => Ir()
|
|
2897
2910
|
), ee(
|
|
2898
2911
|
() => o.outputHeight,
|
|
2899
2912
|
() => {
|
|
@@ -2912,8 +2925,8 @@ const Vs = Z(
|
|
|
2912
2925
|
), ee(
|
|
2913
2926
|
() => o.theme,
|
|
2914
2927
|
(e) => {
|
|
2915
|
-
e !==
|
|
2916
|
-
effects: Ht.reconfigure(
|
|
2928
|
+
e !== j.value && (j.value = e, P == null || P.dispatch({
|
|
2929
|
+
effects: Ht.reconfigure(Nt(ut(e)))
|
|
2917
2930
|
}));
|
|
2918
2931
|
}
|
|
2919
2932
|
), ee(
|
|
@@ -2925,7 +2938,7 @@ const Vs = Z(
|
|
|
2925
2938
|
() => o.pythonEndpoint,
|
|
2926
2939
|
() => {
|
|
2927
2940
|
if (!bt.value) {
|
|
2928
|
-
for (const e of [...
|
|
2941
|
+
for (const e of [...N.keys()])
|
|
2929
2942
|
st(e, !1);
|
|
2930
2943
|
ce.value !== "browser" && (ce.value = "browser", i("update:runtime", "browser"));
|
|
2931
2944
|
}
|
|
@@ -2933,8 +2946,8 @@ const Vs = Z(
|
|
|
2933
2946
|
), ee(
|
|
2934
2947
|
() => o.filesEndpoint,
|
|
2935
2948
|
() => {
|
|
2936
|
-
if (!
|
|
2937
|
-
xe.value = !1, tt.value = [],
|
|
2949
|
+
if (!Me.value) {
|
|
2950
|
+
xe.value = !1, tt.value = [], je.value = "";
|
|
2938
2951
|
return;
|
|
2939
2952
|
}
|
|
2940
2953
|
xe.value && Ye();
|
|
@@ -2943,7 +2956,7 @@ const Vs = Z(
|
|
|
2943
2956
|
() => o.readOnly,
|
|
2944
2957
|
(e) => {
|
|
2945
2958
|
P == null || P.dispatch({
|
|
2946
|
-
effects:
|
|
2959
|
+
effects: yn.reconfigure([nn.readOnly.of(e), Le.editable.of(!e)])
|
|
2947
2960
|
});
|
|
2948
2961
|
}
|
|
2949
2962
|
), ee(
|
|
@@ -2951,7 +2964,7 @@ const Vs = Z(
|
|
|
2951
2964
|
(e) => {
|
|
2952
2965
|
if (!e) return;
|
|
2953
2966
|
const t = D(e);
|
|
2954
|
-
JSON.stringify(t) !== JSON.stringify(
|
|
2967
|
+
JSON.stringify(t) !== JSON.stringify(v.value) && (v.value = t), pe.value && ve();
|
|
2955
2968
|
},
|
|
2956
2969
|
{ deep: !0 }
|
|
2957
2970
|
), ee(pe, (e) => {
|
|
@@ -2959,22 +2972,26 @@ const Vs = Z(
|
|
|
2959
2972
|
}), ee(
|
|
2960
2973
|
() => G.value.length,
|
|
2961
2974
|
async () => {
|
|
2962
|
-
await
|
|
2963
|
-
const e =
|
|
2975
|
+
await Gn();
|
|
2976
|
+
const e = R.value;
|
|
2964
2977
|
e && (e.scrollTop = e.scrollHeight);
|
|
2965
2978
|
}
|
|
2966
|
-
), ee([
|
|
2967
|
-
function
|
|
2968
|
-
|
|
2979
|
+
), ee([F, qe], () => Rr(), { deep: !0 });
|
|
2980
|
+
function Tn() {
|
|
2981
|
+
const e = Ce();
|
|
2982
|
+
i("submit", e, { ...He(w.value), code: e });
|
|
2983
|
+
}
|
|
2984
|
+
function Fn() {
|
|
2985
|
+
Nn();
|
|
2969
2986
|
}
|
|
2970
2987
|
function Ln() {
|
|
2971
2988
|
var t;
|
|
2972
2989
|
const e = w.value.id;
|
|
2973
|
-
if (
|
|
2974
|
-
at(), !o.sqlExecutor &&
|
|
2990
|
+
if (Re.value) {
|
|
2991
|
+
at(), !o.sqlExecutor && v.value.mode === "sqlite" && V.interrupt(), g("已取消连接测试");
|
|
2975
2992
|
return;
|
|
2976
2993
|
}
|
|
2977
|
-
if ((t =
|
|
2994
|
+
if ((t = N.get(e)) != null && t.busy) {
|
|
2978
2995
|
st(e);
|
|
2979
2996
|
return;
|
|
2980
2997
|
}
|
|
@@ -2982,106 +2999,106 @@ const Vs = Z(
|
|
|
2982
2999
|
$n();
|
|
2983
3000
|
return;
|
|
2984
3001
|
}
|
|
2985
|
-
I.value === "running" && k.value === e &&
|
|
3002
|
+
I.value === "running" && k.value === e && Rn();
|
|
2986
3003
|
}
|
|
2987
3004
|
function $n(e = !0) {
|
|
2988
3005
|
const t = k.value;
|
|
2989
|
-
rt += 1, Ee.value = !1, k.value = null, de == null || de.abort(), de = null, !o.sqlExecutor &&
|
|
3006
|
+
rt += 1, Ee.value = !1, k.value = null, de == null || de.abort(), de = null, !o.sqlExecutor && v.value.mode === "sqlite" && V.interrupt(), e && g("执行已中断", t ?? void 0);
|
|
2990
3007
|
}
|
|
2991
|
-
function
|
|
3008
|
+
function Rn(e = !0) {
|
|
2992
3009
|
const t = k.value;
|
|
2993
|
-
We += 1, k.value = null,
|
|
3010
|
+
We += 1, k.value = null, V.interrupt(), e && g("执行已中断", t ?? void 0);
|
|
2994
3011
|
}
|
|
2995
3012
|
function _n() {
|
|
2996
3013
|
fe().lines = [], fe().sqlResults = [];
|
|
2997
3014
|
}
|
|
2998
|
-
function
|
|
3015
|
+
function In() {
|
|
2999
3016
|
var e;
|
|
3000
3017
|
return ((e = E.value) == null ? void 0 : e.getBoundingClientRect().height) ?? 180;
|
|
3001
3018
|
}
|
|
3002
|
-
function
|
|
3019
|
+
function sa() {
|
|
3003
3020
|
var t;
|
|
3004
|
-
const e = ((t =
|
|
3005
|
-
return Math.max(
|
|
3021
|
+
const e = ((t = f.value) == null ? void 0 : t.clientHeight) ?? 0;
|
|
3022
|
+
return Math.max(mr, e ? e - 180 : 600);
|
|
3006
3023
|
}
|
|
3007
3024
|
function Kt(e) {
|
|
3008
|
-
x.value = Math.round(Math.max(
|
|
3025
|
+
x.value = Math.round(Math.max(mr, Math.min(e, sa())));
|
|
3009
3026
|
}
|
|
3010
|
-
function
|
|
3011
|
-
e.button === 0 && (e.preventDefault(),
|
|
3027
|
+
function oa(e) {
|
|
3028
|
+
e.button === 0 && (e.preventDefault(), $.value = !0, hn = e.clientY, At = In(), x.value = Math.round(At), document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", window.addEventListener("pointermove", Hn), window.addEventListener("pointerup", ot), window.addEventListener("pointercancel", ot));
|
|
3012
3029
|
}
|
|
3013
|
-
function
|
|
3014
|
-
|
|
3030
|
+
function Hn(e) {
|
|
3031
|
+
$.value && Kt(At + (hn - e.clientY));
|
|
3015
3032
|
}
|
|
3016
3033
|
function ot() {
|
|
3017
|
-
|
|
3034
|
+
$.value && ($.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove", Hn), window.removeEventListener("pointerup", ot), window.removeEventListener("pointercancel", ot));
|
|
3018
3035
|
}
|
|
3019
|
-
function
|
|
3036
|
+
function ia() {
|
|
3020
3037
|
x.value = null;
|
|
3021
3038
|
}
|
|
3022
|
-
function
|
|
3039
|
+
function la(e) {
|
|
3023
3040
|
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
3024
3041
|
e.preventDefault();
|
|
3025
|
-
const t = x.value ??
|
|
3042
|
+
const t = x.value ?? In();
|
|
3026
3043
|
Kt(t + (e.key === "ArrowUp" ? 16 : -16));
|
|
3027
3044
|
}
|
|
3028
3045
|
function Jt() {
|
|
3029
3046
|
if (o.readOnly) return;
|
|
3030
|
-
const e = w.value.language, t =
|
|
3031
|
-
|
|
3047
|
+
const e = w.value.language, t = Je(wn(e), e, "");
|
|
3048
|
+
F.value.push(t), Be(t.id), i("newFile", He(t));
|
|
3032
3049
|
}
|
|
3033
|
-
function
|
|
3050
|
+
function Be(e) {
|
|
3034
3051
|
if (e === qe.value) {
|
|
3035
3052
|
xt();
|
|
3036
3053
|
return;
|
|
3037
3054
|
}
|
|
3038
|
-
const t =
|
|
3055
|
+
const t = F.value.find((r) => r.id === e);
|
|
3039
3056
|
t && (qe.value = e, Zt(t));
|
|
3040
3057
|
}
|
|
3041
|
-
function
|
|
3042
|
-
st(e, !1), Ee.value && k.value === e && $n(!1), I.value === "running" && k.value === e &&
|
|
3058
|
+
function ua(e) {
|
|
3059
|
+
st(e, !1), Ee.value && k.value === e && $n(!1), I.value === "running" && k.value === e && Rn(!1);
|
|
3043
3060
|
}
|
|
3044
|
-
function
|
|
3061
|
+
function Bn(e) {
|
|
3045
3062
|
if (o.readOnly) return;
|
|
3046
|
-
const t =
|
|
3063
|
+
const t = F.value.findIndex((c) => c.id === e);
|
|
3047
3064
|
if (t === -1) return;
|
|
3048
|
-
|
|
3049
|
-
const r =
|
|
3065
|
+
ua(e);
|
|
3066
|
+
const r = F.value.splice(t, 1)[0];
|
|
3050
3067
|
if (!r) return;
|
|
3051
|
-
if (q.delete(e), i("fileClose",
|
|
3052
|
-
const c =
|
|
3053
|
-
|
|
3068
|
+
if (q.delete(e), i("fileClose", He(r)), !F.value.length) {
|
|
3069
|
+
const c = Je(wn(r.language), r.language, "");
|
|
3070
|
+
F.value.push(c), qe.value = c.id, Zt(c), i("newFile", He(c));
|
|
3054
3071
|
return;
|
|
3055
3072
|
}
|
|
3056
3073
|
if (e !== qe.value) return;
|
|
3057
|
-
const u =
|
|
3074
|
+
const u = F.value[Math.min(t, F.value.length - 1)];
|
|
3058
3075
|
u && (qe.value = u.id, Zt(u));
|
|
3059
3076
|
}
|
|
3060
3077
|
function Zt(e) {
|
|
3061
|
-
|
|
3078
|
+
Ne(void 0), kt(e.code), P == null || P.dispatch({
|
|
3062
3079
|
effects: [
|
|
3063
3080
|
Bt.reconfigure(en(e.language)),
|
|
3064
3081
|
Ut.reconfigure(zt(e.language))
|
|
3065
3082
|
]
|
|
3066
|
-
}), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch",
|
|
3083
|
+
}), i("update:fileName", e.name), i("update:language", e.language), i("fileSwitch", He(e)), xt();
|
|
3067
3084
|
}
|
|
3068
|
-
function
|
|
3069
|
-
o.readOnly || (
|
|
3085
|
+
function Un() {
|
|
3086
|
+
o.readOnly || (Ne(void 0), kt(""), xt());
|
|
3070
3087
|
}
|
|
3071
|
-
async function
|
|
3088
|
+
async function An() {
|
|
3072
3089
|
var r;
|
|
3073
|
-
const e =
|
|
3090
|
+
const e = Ce();
|
|
3074
3091
|
let t = !1;
|
|
3075
3092
|
try {
|
|
3076
3093
|
(r = navigator.clipboard) != null && r.writeText && (await navigator.clipboard.writeText(e), t = !0);
|
|
3077
3094
|
} catch {
|
|
3078
3095
|
t = !1;
|
|
3079
3096
|
}
|
|
3080
|
-
return t || (t =
|
|
3097
|
+
return t || (t = ca(e)), t ? (Se.value = !0, window.clearTimeout(It), It = window.setTimeout(() => {
|
|
3081
3098
|
Se.value = !1;
|
|
3082
|
-
}, 1600), i("copy", e), !0) : (
|
|
3099
|
+
}, 1600), i("copy", e), !0) : (g("复制失败,请手动选择代码复制"), !1);
|
|
3083
3100
|
}
|
|
3084
|
-
function
|
|
3101
|
+
function ca(e) {
|
|
3085
3102
|
const t = document.createElement("textarea");
|
|
3086
3103
|
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);
|
|
3087
3104
|
let r = !1;
|
|
@@ -3092,36 +3109,36 @@ const Vs = Z(
|
|
|
3092
3109
|
}
|
|
3093
3110
|
return t.remove(), r;
|
|
3094
3111
|
}
|
|
3095
|
-
function
|
|
3112
|
+
function Dn() {
|
|
3096
3113
|
const e = w.value, t = Vt(e.name, e.language);
|
|
3097
3114
|
Ie.value = t;
|
|
3098
|
-
const r = new Blob([
|
|
3115
|
+
const r = new Blob([Ce()], {
|
|
3099
3116
|
type: e.language === "python" ? "text/x-python;charset=utf-8" : "text/plain;charset=utf-8"
|
|
3100
3117
|
}), u = URL.createObjectURL(r), c = document.createElement("a");
|
|
3101
3118
|
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;
|
|
3102
3119
|
}
|
|
3103
|
-
function
|
|
3104
|
-
|
|
3120
|
+
function da() {
|
|
3121
|
+
ze.value = !ze.value, ze.value && (xe.value = !1, zn());
|
|
3105
3122
|
}
|
|
3106
|
-
async function
|
|
3123
|
+
async function zn() {
|
|
3107
3124
|
var e;
|
|
3108
3125
|
if (!Xe.value) {
|
|
3109
3126
|
Xe.value = !0;
|
|
3110
3127
|
try {
|
|
3111
|
-
const t = await
|
|
3128
|
+
const t = await V.listFiles(".");
|
|
3112
3129
|
if (!t.ok) {
|
|
3113
|
-
et.value = [],
|
|
3130
|
+
et.value = [], g(`读取虚拟文件失败:${((e = t.error) == null ? void 0 : e.message) ?? "未知错误"}`);
|
|
3114
3131
|
return;
|
|
3115
3132
|
}
|
|
3116
3133
|
et.value = t.entries ?? [];
|
|
3117
3134
|
} catch (t) {
|
|
3118
|
-
et.value = [],
|
|
3135
|
+
et.value = [], g(`读取虚拟文件失败:${t instanceof Error ? t.message : String(t)}`);
|
|
3119
3136
|
} finally {
|
|
3120
3137
|
Xe.value = !1;
|
|
3121
3138
|
}
|
|
3122
3139
|
}
|
|
3123
3140
|
}
|
|
3124
|
-
function
|
|
3141
|
+
function pa(e) {
|
|
3125
3142
|
switch (e.slice(e.lastIndexOf(".") + 1).toLowerCase()) {
|
|
3126
3143
|
case "csv":
|
|
3127
3144
|
return "text/csv";
|
|
@@ -3141,47 +3158,47 @@ const Vs = Z(
|
|
|
3141
3158
|
function Gt(e) {
|
|
3142
3159
|
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
3143
3160
|
}
|
|
3144
|
-
async function
|
|
3161
|
+
async function jn(e) {
|
|
3145
3162
|
var t;
|
|
3146
3163
|
try {
|
|
3147
|
-
const r = await
|
|
3164
|
+
const r = await V.readFile(e);
|
|
3148
3165
|
if (!r.ok || r.content === void 0)
|
|
3149
|
-
return
|
|
3166
|
+
return g(`下载失败:${e}(${((t = r.error) == null ? void 0 : t.message) ?? "未知错误"})`), null;
|
|
3150
3167
|
const u = e.slice(e.lastIndexOf("/") + 1) || "download.txt", c = new Blob([r.content], {
|
|
3151
|
-
type: `${
|
|
3152
|
-
}),
|
|
3153
|
-
return S.href =
|
|
3168
|
+
type: `${pa(u)};charset=utf-8`
|
|
3169
|
+
}), h = URL.createObjectURL(c), S = document.createElement("a");
|
|
3170
|
+
return S.href = h, S.download = u, S.style.display = "none", document.body.appendChild(S), S.click(), S.remove(), window.setTimeout(() => URL.revokeObjectURL(h), 1e3), i("fsDownload", { path: r.path ?? e, name: u }), g(`已下载虚拟文件:${u}`), u;
|
|
3154
3171
|
} catch (r) {
|
|
3155
|
-
return
|
|
3172
|
+
return g(`下载失败:${r instanceof Error ? r.message : String(r)}`), null;
|
|
3156
3173
|
}
|
|
3157
3174
|
}
|
|
3158
|
-
function
|
|
3159
|
-
return
|
|
3175
|
+
function fa(e, t) {
|
|
3176
|
+
return V.writeFile(e, t);
|
|
3160
3177
|
}
|
|
3161
|
-
function
|
|
3162
|
-
return
|
|
3178
|
+
function va(e) {
|
|
3179
|
+
return V.readFile(e);
|
|
3163
3180
|
}
|
|
3164
|
-
function
|
|
3165
|
-
return
|
|
3181
|
+
function ma(e = ".") {
|
|
3182
|
+
return V.listFiles(e);
|
|
3166
3183
|
}
|
|
3167
3184
|
function St(e) {
|
|
3168
3185
|
return e instanceof Error ? e.message : String(e);
|
|
3169
3186
|
}
|
|
3170
|
-
function
|
|
3187
|
+
function ya(e) {
|
|
3171
3188
|
if (!e) return "";
|
|
3172
3189
|
const t = new Date(e);
|
|
3173
3190
|
return Number.isNaN(t.getTime()) ? e : `更新时间:${t.toLocaleString()}`;
|
|
3174
3191
|
}
|
|
3175
|
-
function
|
|
3176
|
-
xe.value = !xe.value, xe.value && (
|
|
3192
|
+
function ha() {
|
|
3193
|
+
xe.value = !xe.value, xe.value && (ze.value = !1, Ye());
|
|
3177
3194
|
}
|
|
3178
3195
|
async function Ye() {
|
|
3179
|
-
if (!
|
|
3196
|
+
if (!Me.value) return;
|
|
3180
3197
|
oe == null || oe.abort();
|
|
3181
3198
|
const e = new AbortController();
|
|
3182
|
-
oe = e, ft.value = !0,
|
|
3199
|
+
oe = e, ft.value = !0, je.value = "";
|
|
3183
3200
|
try {
|
|
3184
|
-
const t = await
|
|
3201
|
+
const t = await Ms(o.filesEndpoint, {
|
|
3185
3202
|
headers: o.filesHeaders,
|
|
3186
3203
|
signal: e.signal
|
|
3187
3204
|
});
|
|
@@ -3189,204 +3206,206 @@ const Vs = Z(
|
|
|
3189
3206
|
tt.value = t;
|
|
3190
3207
|
} catch (t) {
|
|
3191
3208
|
if (oe !== e) return;
|
|
3192
|
-
tt.value = [],
|
|
3209
|
+
tt.value = [], je.value = St(t);
|
|
3193
3210
|
} finally {
|
|
3194
3211
|
oe === e && (oe = null, ft.value = !1);
|
|
3195
3212
|
}
|
|
3196
3213
|
}
|
|
3197
|
-
async function
|
|
3198
|
-
if (!
|
|
3199
|
-
return
|
|
3214
|
+
async function Vn() {
|
|
3215
|
+
if (!Me.value)
|
|
3216
|
+
return g("未配置文件服务端点(filesEndpoint)"), null;
|
|
3200
3217
|
if (W.value) return null;
|
|
3201
3218
|
const e = w.value, t = Vt(e.name, e.language);
|
|
3202
3219
|
t !== e.name && (Ie.value = t), W.value = !0;
|
|
3203
3220
|
try {
|
|
3204
|
-
const r = await
|
|
3221
|
+
const r = await Ns(
|
|
3205
3222
|
o.filesEndpoint,
|
|
3206
|
-
{ name: t, content:
|
|
3223
|
+
{ name: t, content: Ce() },
|
|
3207
3224
|
{ headers: o.filesHeaders }
|
|
3208
3225
|
);
|
|
3209
|
-
return
|
|
3226
|
+
return g(`已保存到服务端:${r.name}(${Gt(r.size)})`), xe.value && await Ye(), r;
|
|
3210
3227
|
} catch (r) {
|
|
3211
|
-
return
|
|
3228
|
+
return g(`保存到服务端失败:${St(r)}`), null;
|
|
3212
3229
|
} finally {
|
|
3213
3230
|
W.value = !1;
|
|
3214
3231
|
}
|
|
3215
3232
|
}
|
|
3216
|
-
async function
|
|
3217
|
-
if (!
|
|
3233
|
+
async function ga(e) {
|
|
3234
|
+
if (!Me.value || W.value) return !1;
|
|
3218
3235
|
W.value = !0;
|
|
3219
3236
|
try {
|
|
3220
3237
|
const t = await Ts(o.filesEndpoint, e.id, {
|
|
3221
3238
|
headers: o.filesHeaders
|
|
3222
|
-
}), r =
|
|
3223
|
-
return
|
|
3239
|
+
}), r = dr(t.name), u = Je(Sn(t.name), r, t.content);
|
|
3240
|
+
return F.value.push(u), Be(u.id), g(`已从服务端打开文件:${t.name}`), i("fileOpen", { name: u.name, code: t.content, language: r }), !0;
|
|
3224
3241
|
} catch (t) {
|
|
3225
|
-
return
|
|
3242
|
+
return g(`打开服务端文件失败:${St(t)}`), !1;
|
|
3226
3243
|
} finally {
|
|
3227
3244
|
W.value = !1;
|
|
3228
3245
|
}
|
|
3229
3246
|
}
|
|
3230
|
-
async function
|
|
3231
|
-
if (!(!
|
|
3247
|
+
async function ba(e) {
|
|
3248
|
+
if (!(!Me.value || W.value) && !(typeof window < "u" && !window.confirm(`确定删除服务端文件“${e.name}”?`))) {
|
|
3232
3249
|
W.value = !0;
|
|
3233
3250
|
try {
|
|
3234
|
-
await
|
|
3251
|
+
await Fs(o.filesEndpoint, e.id, { headers: o.filesHeaders }), g(`已删除服务端文件:${e.name}`), await Ye();
|
|
3235
3252
|
} catch (t) {
|
|
3236
|
-
|
|
3253
|
+
g(`删除服务端文件失败:${St(t)}`);
|
|
3237
3254
|
} finally {
|
|
3238
3255
|
W.value = !1;
|
|
3239
3256
|
}
|
|
3240
3257
|
}
|
|
3241
3258
|
}
|
|
3242
|
-
function
|
|
3259
|
+
function Qn() {
|
|
3243
3260
|
var e;
|
|
3244
|
-
(e =
|
|
3261
|
+
(e = T.value) == null || e.click();
|
|
3245
3262
|
}
|
|
3246
|
-
async function
|
|
3263
|
+
async function ka(e) {
|
|
3247
3264
|
var u;
|
|
3248
3265
|
const t = e.target, r = (u = t.files) == null ? void 0 : u[0];
|
|
3249
3266
|
if (t.value = "", !!r) {
|
|
3250
3267
|
if (r.size > 2 * 1024 * 1024) {
|
|
3251
|
-
|
|
3268
|
+
g(`文件过大:${(r.size / 1024 / 1024).toFixed(1)} MB(最多 2 MB)`);
|
|
3252
3269
|
return;
|
|
3253
3270
|
}
|
|
3254
3271
|
try {
|
|
3255
|
-
const c = await r.text(),
|
|
3256
|
-
|
|
3272
|
+
const c = await r.text(), h = dr(r.name), S = Je(Sn(r.name), h, c);
|
|
3273
|
+
F.value.push(S), Be(S.id), g(`已打开文件:${S.name}`), i("fileOpen", { name: S.name, code: c, language: h });
|
|
3257
3274
|
} catch (c) {
|
|
3258
|
-
const
|
|
3259
|
-
|
|
3275
|
+
const h = c instanceof Error ? c.message : String(c);
|
|
3276
|
+
g(`读取文件失败:${h}`);
|
|
3260
3277
|
}
|
|
3261
3278
|
}
|
|
3262
3279
|
}
|
|
3263
|
-
function
|
|
3280
|
+
function wa() {
|
|
3264
3281
|
Ie.value = Vt(Ie.value, w.value.language);
|
|
3265
3282
|
}
|
|
3266
|
-
function
|
|
3283
|
+
function Sa(e) {
|
|
3267
3284
|
e.key === "Enter" && (e.preventDefault(), e.target.blur());
|
|
3268
3285
|
}
|
|
3269
|
-
function
|
|
3286
|
+
function xa(e) {
|
|
3270
3287
|
jt(e.target.value);
|
|
3271
3288
|
}
|
|
3272
|
-
function
|
|
3289
|
+
function Ea(e) {
|
|
3273
3290
|
const t = e.target.value;
|
|
3274
|
-
t !==
|
|
3275
|
-
effects: Ht.reconfigure(
|
|
3291
|
+
t !== j.value && (j.value = t, P == null || P.dispatch({
|
|
3292
|
+
effects: Ht.reconfigure(Nt(ut(t)))
|
|
3276
3293
|
}), i("update:theme", t));
|
|
3277
3294
|
}
|
|
3278
|
-
async function
|
|
3295
|
+
async function Kn(e) {
|
|
3279
3296
|
var t, r;
|
|
3280
|
-
await
|
|
3297
|
+
await Gn(), (r = (t = M.value) == null ? void 0 : t.querySelector(`[data-file-id="${e}"]`)) == null || r.focus();
|
|
3281
3298
|
}
|
|
3282
|
-
function
|
|
3299
|
+
function qa(e, t) {
|
|
3283
3300
|
if (e.target !== e.currentTarget) return;
|
|
3284
3301
|
if (e.key === "Enter" || e.key === " ") {
|
|
3285
|
-
e.preventDefault(),
|
|
3302
|
+
e.preventDefault(), Be(t.id), Kn(t.id);
|
|
3286
3303
|
return;
|
|
3287
3304
|
}
|
|
3288
3305
|
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
3289
3306
|
e.preventDefault();
|
|
3290
|
-
const r =
|
|
3307
|
+
const r = F.value.findIndex((h) => h.id === t.id);
|
|
3291
3308
|
if (r < 0) return;
|
|
3292
|
-
const u = e.key === "ArrowLeft" ? -1 : 1, c =
|
|
3293
|
-
c && (
|
|
3309
|
+
const u = e.key === "ArrowLeft" ? -1 : 1, c = F.value[(r + u + F.value.length) % F.value.length];
|
|
3310
|
+
c && (Be(c.id), Kn(c.id));
|
|
3294
3311
|
}
|
|
3295
3312
|
function xt() {
|
|
3296
3313
|
P == null || P.focus();
|
|
3297
3314
|
}
|
|
3298
|
-
async function
|
|
3315
|
+
async function Ca(e) {
|
|
3299
3316
|
var r;
|
|
3300
|
-
|
|
3317
|
+
g(`正在安装:${e.join(", ")}`);
|
|
3301
3318
|
let t;
|
|
3302
3319
|
try {
|
|
3303
|
-
t = await
|
|
3304
|
-
onOutput: (u, c) =>
|
|
3320
|
+
t = await V.loadPackages(e, {
|
|
3321
|
+
onOutput: (u, c) => ye(u, c)
|
|
3305
3322
|
});
|
|
3306
3323
|
} catch (u) {
|
|
3307
3324
|
const c = u instanceof Error ? u.message : String(u);
|
|
3308
|
-
return
|
|
3325
|
+
return g(`安装失败:${c}`), { ok: !1, durationMs: 0, error: { type: "RuntimeError", message: c } };
|
|
3309
3326
|
}
|
|
3310
|
-
return
|
|
3311
|
-
}
|
|
3312
|
-
function Ca() {
|
|
3313
|
-
return j.checkSyntax(Te());
|
|
3327
|
+
return g(t.ok ? "安装完成" : `安装失败:${((r = t.error) == null ? void 0 : r.message) ?? "未知错误"}`), t;
|
|
3314
3328
|
}
|
|
3315
3329
|
function Pa() {
|
|
3316
|
-
return
|
|
3330
|
+
return V.checkSyntax(Ce());
|
|
3317
3331
|
}
|
|
3318
3332
|
function Oa() {
|
|
3319
|
-
return
|
|
3333
|
+
return D(v.value);
|
|
3320
3334
|
}
|
|
3321
3335
|
function Ma() {
|
|
3322
|
-
return
|
|
3336
|
+
return P;
|
|
3337
|
+
}
|
|
3338
|
+
function Na() {
|
|
3339
|
+
return F.value.map(He);
|
|
3323
3340
|
}
|
|
3324
3341
|
function Ta() {
|
|
3325
|
-
return
|
|
3342
|
+
return He(w.value);
|
|
3326
3343
|
}
|
|
3327
3344
|
return n({
|
|
3328
|
-
|
|
3345
|
+
submit: Tn,
|
|
3346
|
+
run: Fn,
|
|
3329
3347
|
stop: Ln,
|
|
3330
3348
|
clearOutput: _n,
|
|
3331
|
-
clearCode:
|
|
3349
|
+
clearCode: Un,
|
|
3332
3350
|
newFile: Jt,
|
|
3333
|
-
switchFile:
|
|
3334
|
-
closeFile:
|
|
3335
|
-
copyCode:
|
|
3336
|
-
download:
|
|
3337
|
-
openFile:
|
|
3351
|
+
switchFile: Be,
|
|
3352
|
+
closeFile: Bn,
|
|
3353
|
+
copyCode: An,
|
|
3354
|
+
download: Dn,
|
|
3355
|
+
openFile: Qn,
|
|
3338
3356
|
focus: xt,
|
|
3339
|
-
install:
|
|
3340
|
-
checkSyntax:
|
|
3341
|
-
executeSql:
|
|
3342
|
-
getSqlConfig:
|
|
3343
|
-
openSqlConfig:
|
|
3357
|
+
install: Ca,
|
|
3358
|
+
checkSyntax: Pa,
|
|
3359
|
+
executeSql: Xr,
|
|
3360
|
+
getSqlConfig: Oa,
|
|
3361
|
+
openSqlConfig: Ur,
|
|
3344
3362
|
closeSqlConfig: xn,
|
|
3345
|
-
getEditorView:
|
|
3346
|
-
getCode:
|
|
3363
|
+
getEditorView: Ma,
|
|
3364
|
+
getCode: Ce,
|
|
3347
3365
|
setCode: kt,
|
|
3348
|
-
getFiles:
|
|
3366
|
+
getFiles: Na,
|
|
3349
3367
|
getActiveFile: Ta,
|
|
3350
|
-
writeFile:
|
|
3351
|
-
readFile:
|
|
3352
|
-
listFiles:
|
|
3353
|
-
downloadFile:
|
|
3354
|
-
saveToServer:
|
|
3368
|
+
writeFile: fa,
|
|
3369
|
+
readFile: va,
|
|
3370
|
+
listFiles: ma,
|
|
3371
|
+
downloadFile: jn,
|
|
3372
|
+
saveToServer: Vn,
|
|
3355
3373
|
refreshServerFiles: Ye,
|
|
3356
3374
|
clearPersistedState: _r
|
|
3357
|
-
}), (e, t) => (
|
|
3375
|
+
}), (e, t) => (p(), m("div", {
|
|
3358
3376
|
ref_key: "rootEl",
|
|
3359
|
-
ref:
|
|
3360
|
-
class: le(["vpe-root",
|
|
3361
|
-
style:
|
|
3377
|
+
ref: f,
|
|
3378
|
+
class: le(["vpe-root", Cr.value]),
|
|
3379
|
+
style: Wn(qr.value)
|
|
3362
3380
|
}, [
|
|
3363
|
-
s.showToolbar ? (
|
|
3364
|
-
l("div",
|
|
3365
|
-
Dt.value ? (
|
|
3381
|
+
s.showToolbar ? (p(), m("div", ro, [
|
|
3382
|
+
l("div", ao, [
|
|
3383
|
+
Dt.value ? (p(), m("button", {
|
|
3366
3384
|
key: 1,
|
|
3367
3385
|
class: "vpe-btn vpe-btn--stop",
|
|
3368
3386
|
type: "button",
|
|
3369
3387
|
title: "中断执行",
|
|
3370
3388
|
onClick: Ln
|
|
3371
3389
|
}, [
|
|
3372
|
-
|
|
3390
|
+
z(H(Ks)),
|
|
3373
3391
|
t[19] || (t[19] = l("span", null, "停止", -1))
|
|
3374
|
-
])) : (
|
|
3392
|
+
])) : (p(), m("button", {
|
|
3375
3393
|
key: 0,
|
|
3376
3394
|
class: "vpe-btn vpe-btn--primary",
|
|
3377
3395
|
type: "button",
|
|
3378
|
-
title:
|
|
3379
|
-
disabled:
|
|
3380
|
-
onClick:
|
|
3396
|
+
title: Mr.value,
|
|
3397
|
+
disabled: Nr.value,
|
|
3398
|
+
onClick: Fn
|
|
3381
3399
|
}, [
|
|
3382
|
-
|
|
3400
|
+
z(H(Qs)),
|
|
3383
3401
|
t[18] || (t[18] = l("span", null, "运行", -1))
|
|
3384
|
-
], 8,
|
|
3402
|
+
], 8, so)),
|
|
3385
3403
|
t[28] || (t[28] = l("span", {
|
|
3386
3404
|
class: "vpe-divider",
|
|
3387
3405
|
"aria-hidden": "true"
|
|
3388
3406
|
}, null, -1)),
|
|
3389
|
-
|
|
3407
|
+
s.showNewFile ? (p(), m("button", {
|
|
3408
|
+
key: 2,
|
|
3390
3409
|
class: "vpe-btn",
|
|
3391
3410
|
type: "button",
|
|
3392
3411
|
title: "新建文件",
|
|
@@ -3394,181 +3413,184 @@ const Vs = Z(
|
|
|
3394
3413
|
disabled: s.readOnly,
|
|
3395
3414
|
onClick: Jt
|
|
3396
3415
|
}, [
|
|
3397
|
-
|
|
3416
|
+
z(H(Js)),
|
|
3398
3417
|
t[20] || (t[20] = l("span", null, "新建", -1))
|
|
3399
|
-
], 8,
|
|
3400
|
-
|
|
3418
|
+
], 8, oo)) : O("", !0),
|
|
3419
|
+
s.showOpenFile ? (p(), m("button", {
|
|
3420
|
+
key: 3,
|
|
3401
3421
|
class: "vpe-btn",
|
|
3402
3422
|
type: "button",
|
|
3403
3423
|
title: "打开本地文件",
|
|
3404
3424
|
"aria-label": "打开本地文件",
|
|
3405
3425
|
disabled: s.readOnly,
|
|
3406
|
-
onClick:
|
|
3426
|
+
onClick: Qn
|
|
3407
3427
|
}, [
|
|
3408
|
-
|
|
3428
|
+
z(H(Zs)),
|
|
3409
3429
|
t[21] || (t[21] = l("span", null, "本地文件", -1))
|
|
3410
|
-
], 8,
|
|
3411
|
-
|
|
3430
|
+
], 8, io)) : O("", !0),
|
|
3431
|
+
s.showDownload ? (p(), m("button", {
|
|
3432
|
+
key: 4,
|
|
3412
3433
|
class: "vpe-btn",
|
|
3413
3434
|
type: "button",
|
|
3414
3435
|
title: "下载当前文件",
|
|
3415
3436
|
"aria-label": "下载当前文件",
|
|
3416
|
-
onClick:
|
|
3437
|
+
onClick: Dn
|
|
3417
3438
|
}, [
|
|
3418
|
-
|
|
3439
|
+
z(H(vr)),
|
|
3419
3440
|
t[22] || (t[22] = l("span", null, "下载", -1))
|
|
3420
|
-
]),
|
|
3421
|
-
|
|
3441
|
+
])) : O("", !0),
|
|
3442
|
+
s.showVirtualFiles ? (p(), m("button", {
|
|
3443
|
+
key: 5,
|
|
3422
3444
|
class: "vpe-btn vpe-toolbar-secondary",
|
|
3423
3445
|
type: "button",
|
|
3424
3446
|
title: "虚拟文件(下载 Python 生成的文件)",
|
|
3425
3447
|
"aria-label": "虚拟文件",
|
|
3426
|
-
onClick:
|
|
3448
|
+
onClick: da
|
|
3427
3449
|
}, [
|
|
3428
|
-
|
|
3450
|
+
z(H(fr)),
|
|
3429
3451
|
t[23] || (t[23] = l("span", null, "虚拟文件", -1))
|
|
3430
|
-
]),
|
|
3431
|
-
|
|
3432
|
-
key:
|
|
3452
|
+
])) : O("", !0),
|
|
3453
|
+
Me.value ? (p(), m("button", {
|
|
3454
|
+
key: 6,
|
|
3433
3455
|
class: "vpe-btn",
|
|
3434
3456
|
type: "button",
|
|
3435
3457
|
title: W.value ? "正在处理服务端文件…" : "保存当前文件到服务端",
|
|
3436
3458
|
"aria-label": "保存到服务端",
|
|
3437
3459
|
disabled: W.value,
|
|
3438
|
-
onClick:
|
|
3460
|
+
onClick: Vn
|
|
3439
3461
|
}, [
|
|
3440
|
-
|
|
3462
|
+
z(H(to)),
|
|
3441
3463
|
t[24] || (t[24] = l("span", null, "保存", -1))
|
|
3442
|
-
], 8,
|
|
3443
|
-
|
|
3444
|
-
key:
|
|
3464
|
+
], 8, lo)) : O("", !0),
|
|
3465
|
+
Me.value ? (p(), m("button", {
|
|
3466
|
+
key: 7,
|
|
3445
3467
|
class: "vpe-btn vpe-toolbar-secondary",
|
|
3446
3468
|
type: "button",
|
|
3447
3469
|
title: "查询服务端已保存文件",
|
|
3448
3470
|
"aria-label": "已保存文件",
|
|
3449
|
-
onClick:
|
|
3471
|
+
onClick: ha
|
|
3450
3472
|
}, [
|
|
3451
|
-
|
|
3473
|
+
z(H(no)),
|
|
3452
3474
|
t[25] || (t[25] = l("span", null, "已保存文件", -1))
|
|
3453
|
-
])) :
|
|
3454
|
-
s.showSqlConfig && pe.value ? (
|
|
3455
|
-
key:
|
|
3475
|
+
])) : O("", !0),
|
|
3476
|
+
s.showSqlConfig && pe.value ? (p(), m("button", {
|
|
3477
|
+
key: 8,
|
|
3456
3478
|
class: "vpe-btn",
|
|
3457
3479
|
type: "button",
|
|
3458
3480
|
title: "新建连接",
|
|
3459
3481
|
"aria-label": "新建连接",
|
|
3460
|
-
onClick:
|
|
3482
|
+
onClick: Dr
|
|
3461
3483
|
}, [
|
|
3462
|
-
|
|
3484
|
+
z(H(eo)),
|
|
3463
3485
|
t[26] || (t[26] = l("span", null, "新建连接", -1))
|
|
3464
|
-
])) :
|
|
3486
|
+
])) : O("", !0),
|
|
3465
3487
|
l("button", {
|
|
3466
3488
|
class: le(["vpe-btn", { "vpe-btn--copied": Se.value }]),
|
|
3467
3489
|
type: "button",
|
|
3468
3490
|
title: Se.value ? "已复制" : "复制代码",
|
|
3469
3491
|
"aria-label": Se.value ? "已复制" : "复制代码",
|
|
3470
|
-
onClick:
|
|
3492
|
+
onClick: An
|
|
3471
3493
|
}, [
|
|
3472
|
-
Se.value ? (
|
|
3473
|
-
Se.value ? (
|
|
3474
|
-
], 10,
|
|
3494
|
+
Se.value ? (p(), Yn(H(Ys), { key: 0 })) : (p(), Yn(H(Gs), { key: 1 })),
|
|
3495
|
+
Se.value ? (p(), m("span", co, "已复制")) : (p(), m("span", po, "复制"))
|
|
3496
|
+
], 10, uo),
|
|
3475
3497
|
l("button", {
|
|
3476
3498
|
class: "vpe-btn",
|
|
3477
3499
|
type: "button",
|
|
3478
3500
|
title: "清空当前文件",
|
|
3479
3501
|
"aria-label": "清空当前文件",
|
|
3480
3502
|
disabled: s.readOnly,
|
|
3481
|
-
onClick:
|
|
3503
|
+
onClick: Un
|
|
3482
3504
|
}, [
|
|
3483
|
-
|
|
3505
|
+
z(H(pr)),
|
|
3484
3506
|
t[27] || (t[27] = l("span", null, "清空", -1))
|
|
3485
|
-
], 8,
|
|
3507
|
+
], 8, fo),
|
|
3486
3508
|
t[29] || (t[29] = l("span", {
|
|
3487
3509
|
class: "vpe-divider",
|
|
3488
3510
|
"aria-hidden": "true"
|
|
3489
3511
|
}, null, -1)),
|
|
3490
|
-
l("label",
|
|
3491
|
-
|
|
3492
|
-
|
|
3512
|
+
l("label", vo, [
|
|
3513
|
+
z(H(fr)),
|
|
3514
|
+
Z(l("input", {
|
|
3493
3515
|
"onUpdate:modelValue": t[0] || (t[0] = (r) => Ie.value = r),
|
|
3494
3516
|
class: "vpe-file-input",
|
|
3495
3517
|
type: "text",
|
|
3496
3518
|
spellcheck: "false",
|
|
3497
3519
|
"aria-label": "文件名",
|
|
3498
|
-
onBlur:
|
|
3499
|
-
onKeydown:
|
|
3520
|
+
onBlur: wa,
|
|
3521
|
+
onKeydown: Sa
|
|
3500
3522
|
}, null, 544), [
|
|
3501
|
-
[
|
|
3523
|
+
[ge, Ie.value]
|
|
3502
3524
|
])
|
|
3503
3525
|
]),
|
|
3504
3526
|
l("select", {
|
|
3505
3527
|
class: "vpe-toolbar-select",
|
|
3506
|
-
value:
|
|
3528
|
+
value: j.value,
|
|
3507
3529
|
title: "编辑器主题",
|
|
3508
3530
|
"aria-label": "编辑器主题",
|
|
3509
|
-
onChange:
|
|
3531
|
+
onChange: Ea
|
|
3510
3532
|
}, [
|
|
3511
|
-
(
|
|
3533
|
+
(p(!0), m(A, null, te(H(ln), (r) => (p(), m("option", {
|
|
3512
3534
|
key: r.value,
|
|
3513
3535
|
value: r.value
|
|
3514
|
-
},
|
|
3515
|
-
], 40,
|
|
3536
|
+
}, _(r.label), 9, yo))), 128))
|
|
3537
|
+
], 40, mo)
|
|
3516
3538
|
]),
|
|
3517
|
-
l("div",
|
|
3518
|
-
s.showSqlConfig && pe.value && (
|
|
3519
|
-
|
|
3520
|
-
"onUpdate:modelValue": t[1] || (t[1] = (r) =>
|
|
3539
|
+
l("div", ho, [
|
|
3540
|
+
s.showSqlConfig && pe.value && (v.value.mode === "http" || v.value.endpoint) ? (p(), m("div", go, [
|
|
3541
|
+
Z(l("select", {
|
|
3542
|
+
"onUpdate:modelValue": t[1] || (t[1] = (r) => v.value.connectionId = r),
|
|
3521
3543
|
class: "vpe-select vpe-sql-connection",
|
|
3522
3544
|
title: "切换已保存连接",
|
|
3523
3545
|
"aria-label": "切换已保存连接",
|
|
3524
|
-
disabled:
|
|
3525
|
-
onChange:
|
|
3546
|
+
disabled: Ve.value,
|
|
3547
|
+
onChange: Vr
|
|
3526
3548
|
}, [
|
|
3527
|
-
l("option",
|
|
3528
|
-
(
|
|
3549
|
+
l("option", ko, _(Ve.value ? "加载中…" : Pe.value.length ? "选择连接" : "暂无已保存连接"), 1),
|
|
3550
|
+
(p(!0), m(A, null, te(Pe.value, (r) => (p(), m("option", {
|
|
3529
3551
|
key: r.id,
|
|
3530
3552
|
value: r.id
|
|
3531
|
-
},
|
|
3532
|
-
], 40,
|
|
3533
|
-
[Et,
|
|
3553
|
+
}, _(r.name), 9, wo))), 128))
|
|
3554
|
+
], 40, bo), [
|
|
3555
|
+
[Et, v.value.connectionId]
|
|
3534
3556
|
]),
|
|
3535
3557
|
l("button", {
|
|
3536
3558
|
class: "vpe-btn vpe-btn--sm vpe-sql-manage",
|
|
3537
3559
|
type: "button",
|
|
3538
3560
|
title: "管理连接配置",
|
|
3539
3561
|
"aria-label": "管理连接配置",
|
|
3540
|
-
onClick:
|
|
3562
|
+
onClick: Ar
|
|
3541
3563
|
}, " 管理 ")
|
|
3542
|
-
]
|
|
3543
|
-
l("div",
|
|
3564
|
+
])) : O("", !0),
|
|
3565
|
+
l("div", So, [
|
|
3544
3566
|
l("span", {
|
|
3545
|
-
class: le(["vpe-status", `vpe-status--${
|
|
3567
|
+
class: le(["vpe-status", `vpe-status--${Or.value}`]),
|
|
3546
3568
|
title: bn.value
|
|
3547
3569
|
}, [
|
|
3548
3570
|
t[30] || (t[30] = l("span", {
|
|
3549
3571
|
class: "vpe-status-dot",
|
|
3550
3572
|
"aria-hidden": "true"
|
|
3551
3573
|
}, null, -1)),
|
|
3552
|
-
l("span",
|
|
3553
|
-
], 10,
|
|
3554
|
-
bt.value &&
|
|
3574
|
+
l("span", Eo, _(bn.value), 1)
|
|
3575
|
+
], 10, xo),
|
|
3576
|
+
bt.value && gn.value ? (p(), m(A, { key: 0 }, [
|
|
3555
3577
|
t[32] || (t[32] = l("span", {
|
|
3556
3578
|
class: "vpe-chips-divider",
|
|
3557
3579
|
"aria-hidden": "true"
|
|
3558
3580
|
}, null, -1)),
|
|
3559
|
-
|
|
3581
|
+
Z(l("select", {
|
|
3560
3582
|
"onUpdate:modelValue": t[2] || (t[2] = (r) => ce.value = r),
|
|
3561
3583
|
class: "vpe-toolbar-select",
|
|
3562
3584
|
title: "Python 运行环境",
|
|
3563
3585
|
"aria-label": "Python 运行环境",
|
|
3564
|
-
onChange:
|
|
3586
|
+
onChange: ea
|
|
3565
3587
|
}, [...t[31] || (t[31] = [
|
|
3566
3588
|
l("option", { value: "browser" }, "浏览器", -1),
|
|
3567
3589
|
l("option", { value: "server" }, "服务端", -1)
|
|
3568
3590
|
])], 544), [
|
|
3569
3591
|
[Et, ce.value]
|
|
3570
3592
|
])
|
|
3571
|
-
], 64)) :
|
|
3593
|
+
], 64)) : O("", !0),
|
|
3572
3594
|
t[33] || (t[33] = l("span", {
|
|
3573
3595
|
class: "vpe-chips-divider",
|
|
3574
3596
|
"aria-hidden": "true"
|
|
@@ -3579,25 +3601,25 @@ const Vs = Z(
|
|
|
3579
3601
|
title: "编辑器语言",
|
|
3580
3602
|
"aria-label": "编辑器语言",
|
|
3581
3603
|
disabled: s.readOnly,
|
|
3582
|
-
onChange:
|
|
3604
|
+
onChange: xa
|
|
3583
3605
|
}, [
|
|
3584
|
-
(
|
|
3606
|
+
(p(!0), m(A, null, te(H(Lt), (r) => (p(), m("option", {
|
|
3585
3607
|
key: r.value,
|
|
3586
3608
|
value: r.value
|
|
3587
|
-
},
|
|
3588
|
-
], 40,
|
|
3609
|
+
}, _(r.label), 9, Co))), 128))
|
|
3610
|
+
], 40, qo)
|
|
3589
3611
|
])
|
|
3590
3612
|
])
|
|
3591
|
-
])) :
|
|
3592
|
-
s.showTabs ? (
|
|
3613
|
+
])) : O("", !0),
|
|
3614
|
+
s.showTabs ? (p(), m("div", {
|
|
3593
3615
|
key: 1,
|
|
3594
3616
|
ref_key: "tabsEl",
|
|
3595
|
-
ref:
|
|
3617
|
+
ref: M,
|
|
3596
3618
|
class: "vpe-tabs",
|
|
3597
3619
|
role: "tablist",
|
|
3598
3620
|
"aria-label": "文件"
|
|
3599
3621
|
}, [
|
|
3600
|
-
(
|
|
3622
|
+
(p(!0), m(A, null, te(F.value, (r) => (p(), m("div", {
|
|
3601
3623
|
key: r.id,
|
|
3602
3624
|
class: le(["vpe-tab", { "vpe-tab--active": r.id === w.value.id }]),
|
|
3603
3625
|
role: "tab",
|
|
@@ -3605,26 +3627,27 @@ const Vs = Z(
|
|
|
3605
3627
|
"aria-selected": r.id === w.value.id,
|
|
3606
3628
|
"data-file-id": r.id,
|
|
3607
3629
|
title: r.name,
|
|
3608
|
-
onClick: (u) =>
|
|
3609
|
-
onKeydown: (u) =>
|
|
3630
|
+
onClick: (u) => Be(r.id),
|
|
3631
|
+
onKeydown: (u) => qa(u, r)
|
|
3610
3632
|
}, [
|
|
3611
3633
|
l("span", {
|
|
3612
3634
|
class: le(["vpe-tab-dot", `vpe-tab-dot--${r.language}`]),
|
|
3613
3635
|
"aria-hidden": "true"
|
|
3614
3636
|
}, null, 2),
|
|
3615
|
-
l("span",
|
|
3637
|
+
l("span", Oo, _(r.name), 1),
|
|
3616
3638
|
l("button", {
|
|
3617
3639
|
class: "vpe-tab-close",
|
|
3618
3640
|
type: "button",
|
|
3619
3641
|
title: `关闭 ${r.name}`,
|
|
3620
3642
|
"aria-label": `关闭 ${r.name}`,
|
|
3621
3643
|
disabled: s.readOnly,
|
|
3622
|
-
onClick:
|
|
3644
|
+
onClick: Xn((u) => Bn(r.id), ["stop"])
|
|
3623
3645
|
}, [
|
|
3624
|
-
|
|
3625
|
-
], 8,
|
|
3626
|
-
], 42,
|
|
3627
|
-
|
|
3646
|
+
z(H(ct))
|
|
3647
|
+
], 8, Mo)
|
|
3648
|
+
], 42, Po))), 128)),
|
|
3649
|
+
s.showNewFile ? (p(), m("button", {
|
|
3650
|
+
key: 0,
|
|
3628
3651
|
class: "vpe-tabs-add",
|
|
3629
3652
|
type: "button",
|
|
3630
3653
|
title: "新建文件",
|
|
@@ -3632,42 +3655,42 @@ const Vs = Z(
|
|
|
3632
3655
|
disabled: s.readOnly,
|
|
3633
3656
|
onClick: Jt
|
|
3634
3657
|
}, [
|
|
3635
|
-
|
|
3636
|
-
], 8,
|
|
3637
|
-
], 512)) :
|
|
3658
|
+
z(H(Xs))
|
|
3659
|
+
], 8, No)) : O("", !0)
|
|
3660
|
+
], 512)) : O("", !0),
|
|
3638
3661
|
l("input", {
|
|
3639
3662
|
ref_key: "fileInputEl",
|
|
3640
|
-
ref:
|
|
3663
|
+
ref: T,
|
|
3641
3664
|
class: "vpe-file-hidden",
|
|
3642
3665
|
type: "file",
|
|
3643
3666
|
accept: ".py,.pyw,.sql,.js,.mjs,.cjs,.jsx,.ts,.json,.txt,text/x-python,text/plain,application/json",
|
|
3644
|
-
onChange:
|
|
3667
|
+
onChange: ka
|
|
3645
3668
|
}, null, 544),
|
|
3646
3669
|
l("div", {
|
|
3647
3670
|
ref_key: "editorEl",
|
|
3648
3671
|
ref: b,
|
|
3649
3672
|
class: "vpe-editor"
|
|
3650
3673
|
}, null, 512),
|
|
3651
|
-
s.showOutput ? (
|
|
3674
|
+
s.showOutput ? (p(), m("div", {
|
|
3652
3675
|
key: 2,
|
|
3653
|
-
class: le(["vpe-output-resizer", { "vpe-output-resizer--active":
|
|
3676
|
+
class: le(["vpe-output-resizer", { "vpe-output-resizer--active": $.value }]),
|
|
3654
3677
|
role: "separator",
|
|
3655
3678
|
"aria-orientation": "horizontal",
|
|
3656
3679
|
"aria-label": "调整输出面板高度",
|
|
3657
3680
|
title: "拖动调整输出高度,双击复位",
|
|
3658
3681
|
tabindex: "0",
|
|
3659
|
-
onPointerdown:
|
|
3660
|
-
onDblclick:
|
|
3661
|
-
onKeydown:
|
|
3662
|
-
}, null, 34)) :
|
|
3663
|
-
s.showOutput ? (
|
|
3682
|
+
onPointerdown: oa,
|
|
3683
|
+
onDblclick: ia,
|
|
3684
|
+
onKeydown: la
|
|
3685
|
+
}, null, 34)) : O("", !0),
|
|
3686
|
+
s.showOutput ? (p(), m("div", {
|
|
3664
3687
|
key: 3,
|
|
3665
3688
|
ref_key: "outputPanelEl",
|
|
3666
3689
|
ref: E,
|
|
3667
3690
|
class: "vpe-output",
|
|
3668
|
-
style:
|
|
3691
|
+
style: Wn({ height: Pr.value })
|
|
3669
3692
|
}, [
|
|
3670
|
-
l("div",
|
|
3693
|
+
l("div", To, [
|
|
3671
3694
|
t[34] || (t[34] = l("span", null, "输出", -1)),
|
|
3672
3695
|
l("button", {
|
|
3673
3696
|
class: "vpe-btn vpe-btn--sm",
|
|
@@ -3675,78 +3698,90 @@ const Vs = Z(
|
|
|
3675
3698
|
title: "清空输出",
|
|
3676
3699
|
onClick: _n
|
|
3677
3700
|
}, [
|
|
3678
|
-
|
|
3701
|
+
z(H(pr))
|
|
3679
3702
|
])
|
|
3680
3703
|
]),
|
|
3681
|
-
l("div",
|
|
3682
|
-
me.value.length ? (
|
|
3683
|
-
(
|
|
3704
|
+
l("div", Fo, [
|
|
3705
|
+
me.value.length ? (p(), m("div", Lo, [
|
|
3706
|
+
(p(!0), m(A, null, te(me.value, (r, u) => (p(), m("section", {
|
|
3684
3707
|
key: u,
|
|
3685
3708
|
class: "vpe-sql-result"
|
|
3686
3709
|
}, [
|
|
3687
|
-
l("div",
|
|
3688
|
-
l("span", null, "结果 " +
|
|
3689
|
-
l("span", null,
|
|
3710
|
+
l("div", $o, [
|
|
3711
|
+
l("span", null, "结果 " + _(u + 1), 1),
|
|
3712
|
+
l("span", null, _(Yr(r)), 1)
|
|
3690
3713
|
]),
|
|
3691
|
-
r.columns.length ? (
|
|
3692
|
-
l("table",
|
|
3714
|
+
r.columns.length ? (p(), m("div", Ro, [
|
|
3715
|
+
l("table", _o, [
|
|
3693
3716
|
l("thead", null, [
|
|
3694
3717
|
l("tr", null, [
|
|
3695
|
-
(
|
|
3718
|
+
(p(!0), m(A, null, te(r.columns, (c, h) => (p(), m("th", { key: h }, _(c), 1))), 128))
|
|
3696
3719
|
])
|
|
3697
3720
|
]),
|
|
3698
3721
|
l("tbody", null, [
|
|
3699
|
-
(
|
|
3700
|
-
(
|
|
3701
|
-
key:
|
|
3722
|
+
(p(!0), m(A, null, te(r.rows, (c, h) => (p(), m("tr", { key: h }, [
|
|
3723
|
+
(p(!0), m(A, null, te(c, (S, L) => (p(), m("td", {
|
|
3724
|
+
key: L,
|
|
3702
3725
|
class: le({ "vpe-sql-null": S === null })
|
|
3703
|
-
},
|
|
3726
|
+
}, _(Wr(S)), 3))), 128))
|
|
3704
3727
|
]))), 128))
|
|
3705
3728
|
])
|
|
3706
3729
|
]),
|
|
3707
|
-
r.rows.length ?
|
|
3708
|
-
])) : (
|
|
3730
|
+
r.rows.length ? O("", !0) : (p(), m("div", Io, "查询无数据"))
|
|
3731
|
+
])) : (p(), m("div", Ho, "影响 " + _(r.affectedRows ?? 0) + " 行", 1))
|
|
3709
3732
|
]))), 128))
|
|
3710
|
-
])) :
|
|
3733
|
+
])) : O("", !0),
|
|
3711
3734
|
l("pre", {
|
|
3712
3735
|
ref_key: "outputEl",
|
|
3713
|
-
ref:
|
|
3736
|
+
ref: R,
|
|
3714
3737
|
class: "vpe-output-body"
|
|
3715
3738
|
}, [
|
|
3716
|
-
G.value.length ? (
|
|
3739
|
+
G.value.length ? (p(!0), m(A, { key: 0 }, te(G.value, (r) => (p(), m("span", {
|
|
3717
3740
|
key: r.id,
|
|
3718
3741
|
class: le(["vpe-line", `vpe-line--${r.stream}`])
|
|
3719
|
-
},
|
|
3720
|
-
`, 3))), 128)) : (
|
|
3742
|
+
}, _(r.text) + `
|
|
3743
|
+
`, 3))), 128)) : (p(), m("span", Bo, "暂无输出,点击“运行”或按 Ctrl+Enter 执行代码"))
|
|
3721
3744
|
], 512)
|
|
3722
3745
|
]),
|
|
3723
|
-
|
|
3746
|
+
Ge.value && De.value && Dt.value ? (p(), m("div", Uo, [
|
|
3724
3747
|
t[35] || (t[35] = l("span", {
|
|
3725
3748
|
class: "vpe-terminal-prompt",
|
|
3726
3749
|
"aria-hidden": "true"
|
|
3727
3750
|
}, "›", -1)),
|
|
3728
|
-
|
|
3729
|
-
"onUpdate:modelValue": t[3] || (t[3] = (r) =>
|
|
3751
|
+
Z(l("input", {
|
|
3752
|
+
"onUpdate:modelValue": t[3] || (t[3] = (r) => B.value = r),
|
|
3730
3753
|
class: "vpe-terminal-field",
|
|
3731
3754
|
type: "text",
|
|
3732
3755
|
spellcheck: "false",
|
|
3733
3756
|
placeholder: "输入后按 Enter 发送给 input()",
|
|
3734
3757
|
"aria-label": "标准输入",
|
|
3735
|
-
onKeydown:
|
|
3736
|
-
}, null, 40,
|
|
3737
|
-
[
|
|
3758
|
+
onKeydown: Ia(Xn(Mn, ["prevent"]), ["enter"])
|
|
3759
|
+
}, null, 40, Ao), [
|
|
3760
|
+
[ge, B.value]
|
|
3738
3761
|
]),
|
|
3739
3762
|
l("button", {
|
|
3740
3763
|
class: "vpe-btn vpe-btn--sm",
|
|
3741
3764
|
type: "button",
|
|
3742
3765
|
onClick: Mn
|
|
3743
3766
|
}, " 发送 ")
|
|
3744
|
-
])) :
|
|
3745
|
-
], 4)) :
|
|
3746
|
-
|
|
3747
|
-
l("
|
|
3748
|
-
|
|
3749
|
-
|
|
3767
|
+
])) : O("", !0)
|
|
3768
|
+
], 4)) : O("", !0),
|
|
3769
|
+
s.showSubmit ? (p(), m("div", Do, [
|
|
3770
|
+
l("button", {
|
|
3771
|
+
class: "vpe-btn vpe-btn--primary",
|
|
3772
|
+
type: "button",
|
|
3773
|
+
title: "提交当前代码",
|
|
3774
|
+
"aria-label": "提交当前代码",
|
|
3775
|
+
onClick: Tn
|
|
3776
|
+
}, [
|
|
3777
|
+
z(H(Ws)),
|
|
3778
|
+
t[36] || (t[36] = l("span", null, "提交", -1))
|
|
3779
|
+
])
|
|
3780
|
+
])) : O("", !0),
|
|
3781
|
+
ze.value ? (p(), m("div", zo, [
|
|
3782
|
+
l("div", jo, [
|
|
3783
|
+
t[37] || (t[37] = l("span", { class: "vpe-fs-title" }, "虚拟文件", -1)),
|
|
3784
|
+
t[38] || (t[38] = l("span", {
|
|
3750
3785
|
class: "vpe-spacer",
|
|
3751
3786
|
"aria-hidden": "true"
|
|
3752
3787
|
}, null, -1)),
|
|
@@ -3755,48 +3790,48 @@ const Vs = Z(
|
|
|
3755
3790
|
type: "button",
|
|
3756
3791
|
title: "刷新文件列表",
|
|
3757
3792
|
disabled: Xe.value,
|
|
3758
|
-
onClick:
|
|
3759
|
-
}, " 刷新 ", 8,
|
|
3793
|
+
onClick: zn
|
|
3794
|
+
}, " 刷新 ", 8, Vo),
|
|
3760
3795
|
l("button", {
|
|
3761
3796
|
class: "vpe-btn vpe-btn--sm",
|
|
3762
3797
|
type: "button",
|
|
3763
3798
|
title: "关闭虚拟文件面板",
|
|
3764
3799
|
"aria-label": "关闭虚拟文件面板",
|
|
3765
|
-
onClick: t[4] || (t[4] = (r) =>
|
|
3800
|
+
onClick: t[4] || (t[4] = (r) => ze.value = !1)
|
|
3766
3801
|
}, [
|
|
3767
|
-
|
|
3802
|
+
z(H(ct))
|
|
3768
3803
|
])
|
|
3769
3804
|
]),
|
|
3770
|
-
l("div",
|
|
3771
|
-
Xe.value ? (
|
|
3772
|
-
et.value.length ?
|
|
3773
|
-
(
|
|
3805
|
+
l("div", Qo, [
|
|
3806
|
+
Xe.value ? (p(), m("div", Ko, "正在读取虚拟文件…")) : (p(), m(A, { key: 1 }, [
|
|
3807
|
+
et.value.length ? O("", !0) : (p(), m("div", Jo, " 暂无文件。运行 Python 代码创建文件后再刷新。 ")),
|
|
3808
|
+
(p(!0), m(A, null, te(et.value, (r) => (p(), m("div", {
|
|
3774
3809
|
key: r.path,
|
|
3775
3810
|
class: le(["vpe-fs-item", { "vpe-fs-item--dir": r.isDirectory }])
|
|
3776
3811
|
}, [
|
|
3777
3812
|
l("span", {
|
|
3778
3813
|
class: "vpe-fs-name",
|
|
3779
3814
|
title: r.path
|
|
3780
|
-
},
|
|
3781
|
-
l("span",
|
|
3782
|
-
r.isDirectory ?
|
|
3815
|
+
}, _(r.path), 9, Zo),
|
|
3816
|
+
l("span", Go, _(r.isDirectory ? "目录" : Gt(r.size)), 1),
|
|
3817
|
+
r.isDirectory ? O("", !0) : (p(), m("button", {
|
|
3783
3818
|
key: 0,
|
|
3784
3819
|
class: "vpe-btn vpe-btn--sm",
|
|
3785
3820
|
type: "button",
|
|
3786
3821
|
title: `下载 ${r.name}`,
|
|
3787
3822
|
"aria-label": `下载 ${r.name}`,
|
|
3788
|
-
onClick: (u) =>
|
|
3823
|
+
onClick: (u) => jn(r.path)
|
|
3789
3824
|
}, [
|
|
3790
|
-
|
|
3791
|
-
], 8,
|
|
3825
|
+
z(H(vr))
|
|
3826
|
+
], 8, Wo))
|
|
3792
3827
|
], 2))), 128))
|
|
3793
3828
|
], 64))
|
|
3794
3829
|
])
|
|
3795
|
-
])) :
|
|
3796
|
-
xe.value &&
|
|
3797
|
-
l("div",
|
|
3798
|
-
t[
|
|
3799
|
-
t[
|
|
3830
|
+
])) : O("", !0),
|
|
3831
|
+
xe.value && Me.value ? (p(), m("div", Yo, [
|
|
3832
|
+
l("div", Xo, [
|
|
3833
|
+
t[39] || (t[39] = l("span", { class: "vpe-fs-title" }, "服务端文件", -1)),
|
|
3834
|
+
t[40] || (t[40] = l("span", {
|
|
3800
3835
|
class: "vpe-spacer",
|
|
3801
3836
|
"aria-hidden": "true"
|
|
3802
3837
|
}, null, -1)),
|
|
@@ -3806,7 +3841,7 @@ const Vs = Z(
|
|
|
3806
3841
|
title: "刷新文件列表",
|
|
3807
3842
|
disabled: ft.value,
|
|
3808
3843
|
onClick: t[5] || (t[5] = (r) => Ye())
|
|
3809
|
-
}, " 刷新 ", 8,
|
|
3844
|
+
}, " 刷新 ", 8, ei),
|
|
3810
3845
|
l("button", {
|
|
3811
3846
|
class: "vpe-btn vpe-btn--sm",
|
|
3812
3847
|
type: "button",
|
|
@@ -3814,47 +3849,47 @@ const Vs = Z(
|
|
|
3814
3849
|
"aria-label": "关闭服务端文件面板",
|
|
3815
3850
|
onClick: t[6] || (t[6] = (r) => xe.value = !1)
|
|
3816
3851
|
}, [
|
|
3817
|
-
|
|
3852
|
+
z(H(ct))
|
|
3818
3853
|
])
|
|
3819
3854
|
]),
|
|
3820
|
-
l("div",
|
|
3821
|
-
ft.value ? (
|
|
3822
|
-
!tt.value.length && !
|
|
3823
|
-
(
|
|
3855
|
+
l("div", ti, [
|
|
3856
|
+
ft.value ? (p(), m("div", ni, "正在读取服务端文件…")) : (p(), m(A, { key: 1 }, [
|
|
3857
|
+
!tt.value.length && !je.value ? (p(), m("div", ri, " 暂无已保存文件。点击工具栏“保存”按钮把当前文件保存到服务端。 ")) : O("", !0),
|
|
3858
|
+
(p(!0), m(A, null, te(tt.value, (r) => (p(), m("div", {
|
|
3824
3859
|
key: r.id,
|
|
3825
3860
|
class: "vpe-fs-item"
|
|
3826
3861
|
}, [
|
|
3827
3862
|
l("span", {
|
|
3828
3863
|
class: "vpe-fs-name",
|
|
3829
3864
|
title: r.name
|
|
3830
|
-
},
|
|
3865
|
+
}, _(r.name), 9, ai),
|
|
3831
3866
|
l("span", {
|
|
3832
3867
|
class: "vpe-fs-size",
|
|
3833
|
-
title:
|
|
3834
|
-
},
|
|
3868
|
+
title: ya(r.updatedAt)
|
|
3869
|
+
}, _(Gt(r.size)), 9, si),
|
|
3835
3870
|
l("button", {
|
|
3836
3871
|
class: "vpe-btn vpe-btn--sm",
|
|
3837
3872
|
type: "button",
|
|
3838
3873
|
title: `打开 ${r.name}`,
|
|
3839
3874
|
disabled: W.value,
|
|
3840
|
-
onClick: (u) =>
|
|
3841
|
-
}, " 打开 ", 8,
|
|
3875
|
+
onClick: (u) => ga(r)
|
|
3876
|
+
}, " 打开 ", 8, oi),
|
|
3842
3877
|
l("button", {
|
|
3843
3878
|
class: "vpe-btn vpe-btn--sm",
|
|
3844
3879
|
type: "button",
|
|
3845
3880
|
title: `删除 ${r.name}`,
|
|
3846
3881
|
disabled: W.value,
|
|
3847
|
-
onClick: (u) =>
|
|
3848
|
-
}, " 删除 ", 8,
|
|
3882
|
+
onClick: (u) => ba(r)
|
|
3883
|
+
}, " 删除 ", 8, ii)
|
|
3849
3884
|
]))), 128)),
|
|
3850
|
-
|
|
3885
|
+
je.value ? (p(), m("p", li, _(je.value), 1)) : O("", !0)
|
|
3851
3886
|
], 64))
|
|
3852
3887
|
])
|
|
3853
|
-
])) :
|
|
3854
|
-
|
|
3855
|
-
l("div",
|
|
3856
|
-
l("span",
|
|
3857
|
-
t[
|
|
3888
|
+
])) : O("", !0),
|
|
3889
|
+
$e.value && pe.value ? (p(), m("div", ui, [
|
|
3890
|
+
l("div", ci, [
|
|
3891
|
+
l("span", di, _(Tr.value), 1),
|
|
3892
|
+
t[41] || (t[41] = l("span", {
|
|
3858
3893
|
class: "vpe-spacer",
|
|
3859
3894
|
"aria-hidden": "true"
|
|
3860
3895
|
}, null, -1)),
|
|
@@ -3865,194 +3900,194 @@ const Vs = Z(
|
|
|
3865
3900
|
"aria-label": "关闭 SQL 连接配置",
|
|
3866
3901
|
onClick: xn
|
|
3867
3902
|
}, [
|
|
3868
|
-
|
|
3903
|
+
z(H(ct))
|
|
3869
3904
|
])
|
|
3870
3905
|
]),
|
|
3871
|
-
l("div",
|
|
3872
|
-
l("label",
|
|
3873
|
-
t[
|
|
3874
|
-
|
|
3875
|
-
"onUpdate:modelValue": t[7] || (t[7] = (r) =>
|
|
3906
|
+
l("div", pi, [
|
|
3907
|
+
l("label", fi, [
|
|
3908
|
+
t[43] || (t[43] = l("span", { class: "vpe-sql-label" }, "执行方式", -1)),
|
|
3909
|
+
Z(l("select", {
|
|
3910
|
+
"onUpdate:modelValue": t[7] || (t[7] = (r) => v.value.mode = r),
|
|
3876
3911
|
class: "vpe-sql-input",
|
|
3877
|
-
onChange:
|
|
3878
|
-
}, [...t[
|
|
3912
|
+
onChange: zr
|
|
3913
|
+
}, [...t[42] || (t[42] = [
|
|
3879
3914
|
l("option", { value: "sqlite" }, "浏览器内 SQLite(无需服务端)", -1),
|
|
3880
3915
|
l("option", { value: "http" }, "HTTP 服务(后端网关)", -1)
|
|
3881
3916
|
])], 544), [
|
|
3882
|
-
[Et,
|
|
3917
|
+
[Et, v.value.mode]
|
|
3883
3918
|
])
|
|
3884
3919
|
]),
|
|
3885
|
-
|
|
3886
|
-
l("label",
|
|
3887
|
-
t[
|
|
3888
|
-
|
|
3889
|
-
"onUpdate:modelValue": t[8] || (t[8] = (r) =>
|
|
3920
|
+
v.value.mode === "sqlite" ? (p(), m(A, { key: 0 }, [
|
|
3921
|
+
l("label", vi, [
|
|
3922
|
+
t[44] || (t[44] = l("span", { class: "vpe-sql-label" }, "数据库文件", -1)),
|
|
3923
|
+
Z(l("input", {
|
|
3924
|
+
"onUpdate:modelValue": t[8] || (t[8] = (r) => v.value.connection.database = r),
|
|
3890
3925
|
class: "vpe-sql-input",
|
|
3891
3926
|
type: "text",
|
|
3892
3927
|
spellcheck: "false",
|
|
3893
3928
|
placeholder: ":memory:",
|
|
3894
|
-
onChange:
|
|
3929
|
+
onChange: he
|
|
3895
3930
|
}, null, 544), [
|
|
3896
|
-
[
|
|
3931
|
+
[ge, v.value.connection.database]
|
|
3897
3932
|
])
|
|
3898
3933
|
]),
|
|
3899
|
-
t[
|
|
3900
|
-
], 64)) : (
|
|
3901
|
-
l("label",
|
|
3902
|
-
t[
|
|
3903
|
-
|
|
3934
|
+
t[45] || (t[45] = l("p", { class: "vpe-sql-hint" }, " SQLite 在浏览器内运行,数据仅保存在当前页面内存;“停止”或刷新后会丢失。 ", -1))
|
|
3935
|
+
], 64)) : (p(), m(A, { key: 1 }, [
|
|
3936
|
+
l("label", mi, [
|
|
3937
|
+
t[46] || (t[46] = l("span", { class: "vpe-sql-label" }, "连接名称", -1)),
|
|
3938
|
+
Z(l("input", {
|
|
3904
3939
|
"onUpdate:modelValue": t[9] || (t[9] = (r) => ne.value = r),
|
|
3905
3940
|
class: "vpe-sql-input",
|
|
3906
3941
|
type: "text",
|
|
3907
3942
|
spellcheck: "false",
|
|
3908
3943
|
placeholder: "用于保存和切换连接"
|
|
3909
3944
|
}, null, 512), [
|
|
3910
|
-
[
|
|
3945
|
+
[ge, ne.value]
|
|
3911
3946
|
])
|
|
3912
3947
|
]),
|
|
3913
|
-
l("label",
|
|
3914
|
-
t[
|
|
3915
|
-
|
|
3916
|
-
"onUpdate:modelValue": t[10] || (t[10] = (r) =>
|
|
3948
|
+
l("label", yi, [
|
|
3949
|
+
t[47] || (t[47] = l("span", { class: "vpe-sql-label" }, "数据库类型", -1)),
|
|
3950
|
+
Z(l("select", {
|
|
3951
|
+
"onUpdate:modelValue": t[10] || (t[10] = (r) => v.value.connection.dialect = r),
|
|
3917
3952
|
class: "vpe-sql-input",
|
|
3918
|
-
onChange:
|
|
3953
|
+
onChange: jr
|
|
3919
3954
|
}, [
|
|
3920
|
-
(
|
|
3955
|
+
(p(!0), m(A, null, te(H(dt), (r) => (p(), m("option", {
|
|
3921
3956
|
key: r.value,
|
|
3922
3957
|
value: r.value
|
|
3923
|
-
},
|
|
3958
|
+
}, _(r.label), 9, hi))), 128))
|
|
3924
3959
|
], 544), [
|
|
3925
|
-
[Et,
|
|
3960
|
+
[Et, v.value.connection.dialect]
|
|
3926
3961
|
])
|
|
3927
3962
|
]),
|
|
3928
|
-
l("div",
|
|
3929
|
-
l("label",
|
|
3930
|
-
t[
|
|
3931
|
-
|
|
3932
|
-
"onUpdate:modelValue": t[11] || (t[11] = (r) =>
|
|
3963
|
+
l("div", gi, [
|
|
3964
|
+
l("label", bi, [
|
|
3965
|
+
t[48] || (t[48] = l("span", { class: "vpe-sql-label" }, "主机", -1)),
|
|
3966
|
+
Z(l("input", {
|
|
3967
|
+
"onUpdate:modelValue": t[11] || (t[11] = (r) => v.value.connection.host = r),
|
|
3933
3968
|
class: "vpe-sql-input",
|
|
3934
3969
|
type: "text",
|
|
3935
3970
|
spellcheck: "false",
|
|
3936
3971
|
placeholder: "127.0.0.1",
|
|
3937
|
-
onChange:
|
|
3972
|
+
onChange: he
|
|
3938
3973
|
}, null, 544), [
|
|
3939
|
-
[
|
|
3974
|
+
[ge, v.value.connection.host]
|
|
3940
3975
|
])
|
|
3941
3976
|
]),
|
|
3942
|
-
l("label",
|
|
3943
|
-
t[
|
|
3944
|
-
|
|
3945
|
-
"onUpdate:modelValue": t[12] || (t[12] = (r) =>
|
|
3977
|
+
l("label", ki, [
|
|
3978
|
+
t[49] || (t[49] = l("span", { class: "vpe-sql-label" }, "端口", -1)),
|
|
3979
|
+
Z(l("input", {
|
|
3980
|
+
"onUpdate:modelValue": t[12] || (t[12] = (r) => v.value.connection.port = r),
|
|
3946
3981
|
class: "vpe-sql-input",
|
|
3947
3982
|
type: "number",
|
|
3948
3983
|
min: "1",
|
|
3949
3984
|
max: "65535",
|
|
3950
3985
|
placeholder: "3306",
|
|
3951
|
-
onChange:
|
|
3986
|
+
onChange: he
|
|
3952
3987
|
}, null, 544), [
|
|
3953
3988
|
[
|
|
3954
|
-
|
|
3955
|
-
|
|
3989
|
+
ge,
|
|
3990
|
+
v.value.connection.port,
|
|
3956
3991
|
void 0,
|
|
3957
3992
|
{ number: !0 }
|
|
3958
3993
|
]
|
|
3959
3994
|
])
|
|
3960
3995
|
])
|
|
3961
3996
|
]),
|
|
3962
|
-
l("div",
|
|
3963
|
-
l("label",
|
|
3964
|
-
t[
|
|
3965
|
-
|
|
3966
|
-
"onUpdate:modelValue": t[13] || (t[13] = (r) =>
|
|
3997
|
+
l("div", wi, [
|
|
3998
|
+
l("label", Si, [
|
|
3999
|
+
t[50] || (t[50] = l("span", { class: "vpe-sql-label" }, "用户名", -1)),
|
|
4000
|
+
Z(l("input", {
|
|
4001
|
+
"onUpdate:modelValue": t[13] || (t[13] = (r) => v.value.connection.user = r),
|
|
3967
4002
|
class: "vpe-sql-input",
|
|
3968
4003
|
type: "text",
|
|
3969
4004
|
autocomplete: "off",
|
|
3970
4005
|
spellcheck: "false",
|
|
3971
|
-
onChange:
|
|
4006
|
+
onChange: he
|
|
3972
4007
|
}, null, 544), [
|
|
3973
|
-
[
|
|
4008
|
+
[ge, v.value.connection.user]
|
|
3974
4009
|
])
|
|
3975
4010
|
]),
|
|
3976
|
-
l("label",
|
|
3977
|
-
t[
|
|
3978
|
-
|
|
3979
|
-
"onUpdate:modelValue": t[14] || (t[14] = (r) =>
|
|
4011
|
+
l("label", xi, [
|
|
4012
|
+
t[51] || (t[51] = l("span", { class: "vpe-sql-label" }, "密码", -1)),
|
|
4013
|
+
Z(l("input", {
|
|
4014
|
+
"onUpdate:modelValue": t[14] || (t[14] = (r) => v.value.connection.password = r),
|
|
3980
4015
|
class: "vpe-sql-input",
|
|
3981
4016
|
type: "password",
|
|
3982
4017
|
autocomplete: "new-password",
|
|
3983
|
-
placeholder:
|
|
3984
|
-
onChange:
|
|
3985
|
-
}, null, 40,
|
|
3986
|
-
[
|
|
4018
|
+
placeholder: v.value.connectionId ? "已保存(留空不修改)" : "",
|
|
4019
|
+
onChange: he
|
|
4020
|
+
}, null, 40, Ei), [
|
|
4021
|
+
[ge, v.value.connection.password]
|
|
3987
4022
|
])
|
|
3988
4023
|
])
|
|
3989
4024
|
]),
|
|
3990
|
-
l("label",
|
|
3991
|
-
t[
|
|
3992
|
-
|
|
3993
|
-
"onUpdate:modelValue": t[15] || (t[15] = (r) =>
|
|
4025
|
+
l("label", qi, [
|
|
4026
|
+
t[52] || (t[52] = l("span", { class: "vpe-sql-label" }, "数据库名", -1)),
|
|
4027
|
+
Z(l("input", {
|
|
4028
|
+
"onUpdate:modelValue": t[15] || (t[15] = (r) => v.value.connection.database = r),
|
|
3994
4029
|
class: "vpe-sql-input",
|
|
3995
4030
|
type: "text",
|
|
3996
4031
|
spellcheck: "false",
|
|
3997
4032
|
placeholder: "database",
|
|
3998
|
-
onChange:
|
|
4033
|
+
onChange: he
|
|
3999
4034
|
}, null, 544), [
|
|
4000
|
-
[
|
|
4035
|
+
[ge, v.value.connection.database]
|
|
4001
4036
|
])
|
|
4002
4037
|
]),
|
|
4003
|
-
s.sqlEndpointLocked ?
|
|
4004
|
-
t[
|
|
4005
|
-
|
|
4006
|
-
"onUpdate:modelValue": t[16] || (t[16] = (r) =>
|
|
4038
|
+
s.sqlEndpointLocked ? O("", !0) : (p(), m("label", Ci, [
|
|
4039
|
+
t[53] || (t[53] = l("span", { class: "vpe-sql-label" }, "服务端点", -1)),
|
|
4040
|
+
Z(l("input", {
|
|
4041
|
+
"onUpdate:modelValue": t[16] || (t[16] = (r) => v.value.endpoint = r),
|
|
4007
4042
|
class: "vpe-sql-input",
|
|
4008
4043
|
type: "url",
|
|
4009
4044
|
spellcheck: "false",
|
|
4010
4045
|
placeholder: "https://example.com/api/sql",
|
|
4011
|
-
onChange:
|
|
4046
|
+
onChange: he
|
|
4012
4047
|
}, null, 544), [
|
|
4013
|
-
[
|
|
4048
|
+
[ge, v.value.endpoint]
|
|
4014
4049
|
])
|
|
4015
4050
|
])),
|
|
4016
|
-
s.sqlEndpointLocked ? (
|
|
4017
|
-
t[
|
|
4051
|
+
s.sqlEndpointLocked ? (p(), m("p", Pi, "服务端点由系统预置,无需填写。")) : O("", !0),
|
|
4052
|
+
t[54] || (t[54] = l("p", { class: "vpe-sql-hint" }, " 执行时会把连接信息与 SQL POST 到该端点,由后端网关连接真实数据库。建议使用 HTTPS,并避免在前端配置高权限账号。 ", -1))
|
|
4018
4053
|
], 64)),
|
|
4019
|
-
l("div",
|
|
4054
|
+
l("div", Oi, [
|
|
4020
4055
|
l("button", {
|
|
4021
4056
|
class: "vpe-btn vpe-btn--primary",
|
|
4022
4057
|
type: "button",
|
|
4023
|
-
disabled:
|
|
4024
|
-
onClick:
|
|
4025
|
-
},
|
|
4026
|
-
|
|
4058
|
+
disabled: Re.value,
|
|
4059
|
+
onClick: Gr
|
|
4060
|
+
}, _(Re.value ? "测试中…" : "测试连接"), 9, Mi),
|
|
4061
|
+
v.value.mode === "http" ? (p(), m("button", {
|
|
4027
4062
|
key: 0,
|
|
4028
4063
|
class: "vpe-btn",
|
|
4029
4064
|
type: "button",
|
|
4030
4065
|
disabled: re.value,
|
|
4031
|
-
onClick:
|
|
4032
|
-
}, " 保存 ", 8,
|
|
4033
|
-
|
|
4066
|
+
onClick: Kr
|
|
4067
|
+
}, " 保存 ", 8, Ni)) : O("", !0),
|
|
4068
|
+
v.value.mode === "http" && v.value.connectionId ? (p(), m("button", {
|
|
4034
4069
|
key: 1,
|
|
4035
4070
|
class: "vpe-btn",
|
|
4036
4071
|
type: "button",
|
|
4037
4072
|
disabled: re.value,
|
|
4038
|
-
onClick:
|
|
4039
|
-
}, " 删除 ", 8,
|
|
4040
|
-
nt.value ? (
|
|
4073
|
+
onClick: Jr
|
|
4074
|
+
}, " 删除 ", 8, Ti)) : O("", !0),
|
|
4075
|
+
nt.value ? (p(), m("span", {
|
|
4041
4076
|
key: 2,
|
|
4042
4077
|
class: le(["vpe-sql-test", vt.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
|
|
4043
|
-
},
|
|
4044
|
-
|
|
4045
|
-
|
|
4078
|
+
}, _(nt.value), 3)) : O("", !0),
|
|
4079
|
+
v.value.mode === "http" && Oe.value ? (p(), m("span", Fi, _(Oe.value), 1)) : O("", !0),
|
|
4080
|
+
v.value.mode === "http" && ae.value ? (p(), m("span", {
|
|
4046
4081
|
key: 4,
|
|
4047
|
-
class: le(["vpe-sql-test",
|
|
4048
|
-
},
|
|
4082
|
+
class: le(["vpe-sql-test", Qe.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
|
|
4083
|
+
}, _(ae.value), 3)) : O("", !0)
|
|
4049
4084
|
])
|
|
4050
4085
|
])
|
|
4051
|
-
])) :
|
|
4052
|
-
|
|
4053
|
-
l("div",
|
|
4054
|
-
t[
|
|
4055
|
-
t[
|
|
4086
|
+
])) : O("", !0),
|
|
4087
|
+
_e.value && pe.value ? (p(), m("div", Li, [
|
|
4088
|
+
l("div", $i, [
|
|
4089
|
+
t[55] || (t[55] = l("span", { class: "vpe-fs-title" }, "连接管理", -1)),
|
|
4090
|
+
t[56] || (t[56] = l("span", {
|
|
4056
4091
|
class: "vpe-spacer",
|
|
4057
4092
|
"aria-hidden": "true"
|
|
4058
4093
|
}, null, -1)),
|
|
@@ -4060,116 +4095,116 @@ const Vs = Z(
|
|
|
4060
4095
|
class: "vpe-btn vpe-btn--sm",
|
|
4061
4096
|
type: "button",
|
|
4062
4097
|
title: "刷新连接列表",
|
|
4063
|
-
disabled:
|
|
4098
|
+
disabled: Ve.value,
|
|
4064
4099
|
onClick: ve
|
|
4065
|
-
}, " 刷新 ", 8,
|
|
4100
|
+
}, " 刷新 ", 8, Ri),
|
|
4066
4101
|
l("button", {
|
|
4067
4102
|
class: "vpe-btn vpe-btn--sm",
|
|
4068
4103
|
type: "button",
|
|
4069
4104
|
title: "关闭连接管理",
|
|
4070
4105
|
"aria-label": "关闭连接管理",
|
|
4071
|
-
onClick: t[17] || (t[17] = (r) =>
|
|
4106
|
+
onClick: t[17] || (t[17] = (r) => _e.value = !1)
|
|
4072
4107
|
}, [
|
|
4073
|
-
|
|
4108
|
+
z(H(ct))
|
|
4074
4109
|
])
|
|
4075
4110
|
]),
|
|
4076
|
-
l("div",
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
(
|
|
4111
|
+
l("div", _i, [
|
|
4112
|
+
Ve.value ? (p(), m("div", Ii, "正在读取连接…")) : (p(), m(A, { key: 1 }, [
|
|
4113
|
+
Pe.value.length ? O("", !0) : (p(), m("div", Hi, " 暂无已保存连接,点击工具栏“新建连接”创建。 ")),
|
|
4114
|
+
(p(!0), m(A, null, te(Pe.value, (r) => (p(), m("div", {
|
|
4080
4115
|
key: r.id,
|
|
4081
4116
|
class: "vpe-sql-manager-item"
|
|
4082
4117
|
}, [
|
|
4083
|
-
l("div",
|
|
4118
|
+
l("div", Bi, [
|
|
4084
4119
|
l("span", {
|
|
4085
4120
|
class: "vpe-sql-manager-name",
|
|
4086
4121
|
title: r.name
|
|
4087
|
-
},
|
|
4088
|
-
l("span",
|
|
4089
|
-
Wt(
|
|
4090
|
-
r.database ? (
|
|
4091
|
-
Wt(" · " +
|
|
4092
|
-
], 64)) :
|
|
4093
|
-
r.host ? (
|
|
4094
|
-
Wt(" · " +
|
|
4095
|
-
], 64)) :
|
|
4122
|
+
}, _(r.name), 9, Ui),
|
|
4123
|
+
l("span", Ai, [
|
|
4124
|
+
Wt(_(r.dialect), 1),
|
|
4125
|
+
r.database ? (p(), m(A, { key: 0 }, [
|
|
4126
|
+
Wt(" · " + _(r.database), 1)
|
|
4127
|
+
], 64)) : O("", !0),
|
|
4128
|
+
r.host ? (p(), m(A, { key: 1 }, [
|
|
4129
|
+
Wt(" · " + _(r.host), 1)
|
|
4130
|
+
], 64)) : O("", !0)
|
|
4096
4131
|
])
|
|
4097
4132
|
]),
|
|
4098
4133
|
l("button", {
|
|
4099
4134
|
class: "vpe-btn vpe-btn--sm",
|
|
4100
4135
|
type: "button",
|
|
4101
4136
|
title: "编辑连接",
|
|
4102
|
-
onClick: (u) =>
|
|
4103
|
-
}, " 编辑 ", 8,
|
|
4137
|
+
onClick: (u) => Qr(r)
|
|
4138
|
+
}, " 编辑 ", 8, Di),
|
|
4104
4139
|
l("button", {
|
|
4105
4140
|
class: "vpe-btn vpe-btn--sm",
|
|
4106
4141
|
type: "button",
|
|
4107
4142
|
title: "删除连接",
|
|
4108
4143
|
disabled: re.value,
|
|
4109
|
-
onClick: (u) =>
|
|
4110
|
-
}, " 删除 ", 8,
|
|
4144
|
+
onClick: (u) => Zr(r)
|
|
4145
|
+
}, " 删除 ", 8, zi)
|
|
4111
4146
|
]))), 128)),
|
|
4112
|
-
|
|
4113
|
-
|
|
4147
|
+
Oe.value ? (p(), m("p", ji, _(Oe.value), 1)) : O("", !0),
|
|
4148
|
+
Ke.value ? (p(), m("p", {
|
|
4114
4149
|
key: 2,
|
|
4115
4150
|
class: le(["vpe-sql-hint", mt.value ? "vpe-sql-hint--ok" : "vpe-sql-hint--error"])
|
|
4116
|
-
},
|
|
4151
|
+
}, _(Ke.value), 3)) : O("", !0)
|
|
4117
4152
|
], 64))
|
|
4118
4153
|
])
|
|
4119
|
-
])) :
|
|
4154
|
+
])) : O("", !0)
|
|
4120
4155
|
], 6));
|
|
4121
4156
|
}
|
|
4122
4157
|
});
|
|
4123
|
-
function
|
|
4124
|
-
var
|
|
4158
|
+
function ol(s = {}) {
|
|
4159
|
+
var De;
|
|
4125
4160
|
const n = un(s.pyodideUrl ? { pyodideUrl: s.pyodideUrl } : void 0), a = C(n.status), o = C(""), i = C([]);
|
|
4126
|
-
let
|
|
4127
|
-
const b = (
|
|
4128
|
-
i.value.push({ id: ++
|
|
4129
|
-
}, E = n.on("status", (
|
|
4130
|
-
a.value =
|
|
4131
|
-
}),
|
|
4132
|
-
b("system", `[pyodide] 加载失败:${
|
|
4161
|
+
let f = 0;
|
|
4162
|
+
const b = (B, k) => {
|
|
4163
|
+
i.value.push({ id: ++f, stream: B, text: k });
|
|
4164
|
+
}, E = n.on("status", (B, k) => {
|
|
4165
|
+
a.value = B, k && (o.value = k);
|
|
4166
|
+
}), R = n.on("initError", (B) => {
|
|
4167
|
+
b("system", `[pyodide] 加载失败:${B}`);
|
|
4133
4168
|
});
|
|
4134
|
-
|
|
4135
|
-
E(),
|
|
4169
|
+
Ha(() => {
|
|
4170
|
+
E(), R();
|
|
4136
4171
|
});
|
|
4137
|
-
const
|
|
4172
|
+
const M = async (B, k = {}) => {
|
|
4138
4173
|
var I;
|
|
4139
4174
|
try {
|
|
4140
|
-
const
|
|
4175
|
+
const j = await n.run(B, {
|
|
4141
4176
|
stdin: k.stdin,
|
|
4142
4177
|
onOutput: (ce, Se) => b(ce, Se)
|
|
4143
4178
|
});
|
|
4144
|
-
return !
|
|
4145
|
-
} catch (
|
|
4179
|
+
return !j.ok && ((I = j.error) != null && I.traceback) && b("stderr", j.error.traceback), j;
|
|
4180
|
+
} catch (j) {
|
|
4146
4181
|
return {
|
|
4147
4182
|
ok: !1,
|
|
4148
4183
|
durationMs: 0,
|
|
4149
|
-
error: { type: "RuntimeError", message:
|
|
4184
|
+
error: { type: "RuntimeError", message: j instanceof Error ? j.message : String(j), traceback: "" }
|
|
4150
4185
|
};
|
|
4151
4186
|
}
|
|
4152
|
-
},
|
|
4187
|
+
}, T = async (B, k) => {
|
|
4153
4188
|
try {
|
|
4154
|
-
return await n.writeFile(
|
|
4189
|
+
return await n.writeFile(B, k);
|
|
4155
4190
|
} catch (I) {
|
|
4156
4191
|
return { ok: !1, error: { type: "RuntimeError", message: I instanceof Error ? I.message : String(I), traceback: "" } };
|
|
4157
4192
|
}
|
|
4158
|
-
}, x = async (
|
|
4193
|
+
}, x = async (B) => {
|
|
4159
4194
|
try {
|
|
4160
|
-
return await n.readFile(
|
|
4195
|
+
return await n.readFile(B);
|
|
4161
4196
|
} catch (k) {
|
|
4162
4197
|
return { ok: !1, error: { type: "RuntimeError", message: k instanceof Error ? k.message : String(k), traceback: "" } };
|
|
4163
4198
|
}
|
|
4164
|
-
},
|
|
4199
|
+
}, $ = async (B = ".") => {
|
|
4165
4200
|
try {
|
|
4166
|
-
return await n.listFiles(
|
|
4201
|
+
return await n.listFiles(B);
|
|
4167
4202
|
} catch (k) {
|
|
4168
4203
|
return { ok: !1, error: { type: "RuntimeError", message: k instanceof Error ? k.message : String(k), traceback: "" } };
|
|
4169
4204
|
}
|
|
4170
|
-
}, q = async (
|
|
4205
|
+
}, q = async (B) => {
|
|
4171
4206
|
try {
|
|
4172
|
-
return await n.loadPackages(
|
|
4207
|
+
return await n.loadPackages(B, { onOutput: (k, I) => b(k, I) });
|
|
4173
4208
|
} catch (k) {
|
|
4174
4209
|
return {
|
|
4175
4210
|
ok: !1,
|
|
@@ -4182,65 +4217,65 @@ function nl(s = {}) {
|
|
|
4182
4217
|
const me = async () => {
|
|
4183
4218
|
var I;
|
|
4184
4219
|
if (G) return;
|
|
4185
|
-
const
|
|
4186
|
-
if (!
|
|
4187
|
-
G = !0, b("system", `[pyodide] 正在安装预置包:${
|
|
4188
|
-
const k = await q(
|
|
4220
|
+
const B = s.preloadPackages ?? [];
|
|
4221
|
+
if (!B.length) return;
|
|
4222
|
+
G = !0, b("system", `[pyodide] 正在安装预置包:${B.join(", ")}`);
|
|
4223
|
+
const k = await q(B);
|
|
4189
4224
|
b(
|
|
4190
4225
|
"system",
|
|
4191
4226
|
k.ok ? `[pyodide] 预置包安装完成(${(k.durationMs / 1e3).toFixed(1)}s)` : `[pyodide] 预置包安装失败:${((I = k.error) == null ? void 0 : I.message) ?? "未知错误"}`
|
|
4192
4227
|
);
|
|
4193
4228
|
};
|
|
4194
|
-
return (s.preload || (((
|
|
4229
|
+
return (s.preload || (((De = s.preloadPackages) == null ? void 0 : De.length) ?? 0) > 0) && n.waitReady().then(() => me()).catch(() => {
|
|
4195
4230
|
}), {
|
|
4196
4231
|
status: a,
|
|
4197
4232
|
version: o,
|
|
4198
4233
|
outputs: i,
|
|
4199
|
-
runPython:
|
|
4234
|
+
runPython: M,
|
|
4200
4235
|
install: q,
|
|
4201
|
-
checkSyntax: (
|
|
4236
|
+
checkSyntax: (B) => n.checkSyntax(B),
|
|
4202
4237
|
interrupt: () => n.interrupt(),
|
|
4203
4238
|
clearOutputs: () => {
|
|
4204
4239
|
i.value = [];
|
|
4205
4240
|
},
|
|
4206
|
-
writeFile:
|
|
4241
|
+
writeFile: T,
|
|
4207
4242
|
readFile: x,
|
|
4208
|
-
listFiles:
|
|
4243
|
+
listFiles: $,
|
|
4209
4244
|
/** 预加载并在就绪后 resolve */
|
|
4210
4245
|
ready: () => n.waitReady()
|
|
4211
4246
|
};
|
|
4212
4247
|
}
|
|
4213
|
-
const
|
|
4248
|
+
const il = Vi;
|
|
4214
4249
|
export {
|
|
4215
|
-
|
|
4216
|
-
|
|
4250
|
+
gr as DEFAULT_PYODIDE_URL,
|
|
4251
|
+
sl as DEFAULT_SQL_CONFIG,
|
|
4217
4252
|
ln as EDITOR_THEMES,
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4253
|
+
hs as MONO_FONT_STACK,
|
|
4254
|
+
Cs as PyodideRunner,
|
|
4255
|
+
il as PythonEditor,
|
|
4221
4256
|
dt as SQL_DIALECT_OPTIONS,
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4257
|
+
ws as createEditor,
|
|
4258
|
+
Rs as createPythonSession,
|
|
4259
|
+
Vi as default,
|
|
4260
|
+
Fs as deleteServerFile,
|
|
4261
|
+
cr as deleteSqlConnection,
|
|
4262
|
+
ur as getDefaultSqlPort,
|
|
4228
4263
|
un as getRunner,
|
|
4229
|
-
|
|
4230
|
-
|
|
4264
|
+
Vs as getThemeOption,
|
|
4265
|
+
ar as interruptPythonSession,
|
|
4231
4266
|
ut as isDarkTheme,
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4267
|
+
Ms as listServerFiles,
|
|
4268
|
+
zs as listSqlConnections,
|
|
4269
|
+
Ss as makePythonLinter,
|
|
4235
4270
|
D as normalizeSqlConfig,
|
|
4236
4271
|
_s as pollPythonSession,
|
|
4237
4272
|
Ts as readServerFile,
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4273
|
+
al as runPythonOnServer,
|
|
4274
|
+
wr as runSql,
|
|
4275
|
+
Ns as saveServerFile,
|
|
4276
|
+
js as saveSqlConnection,
|
|
4277
|
+
Is as sendPythonSessionInput,
|
|
4278
|
+
hr as setErrorLines,
|
|
4279
|
+
Ds as testSqlConnection,
|
|
4280
|
+
ol as usePyodide
|
|
4246
4281
|
};
|