princess-python-editor 0.3.1 → 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 +0 -54
- package/dist/PythonEditor.vue.d.ts +6 -0
- package/dist/icons.d.ts +2 -0
- package/dist/index.cjs.js +6 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +703 -677
- 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
|
|
3
|
-
var ie = (s, n, a) =>
|
|
4
|
-
import { h as
|
|
5
|
-
import { EditorState as nn, StateEffect as
|
|
6
|
-
import { EditorView as Le, keymap as
|
|
7
|
-
import { linter as
|
|
8
|
-
import { autocompletion as
|
|
9
|
-
import { history as
|
|
10
|
-
import { syntaxHighlighting as
|
|
11
|
-
import { python as
|
|
12
|
-
import { javascript as
|
|
13
|
-
import { json as
|
|
14
|
-
import { sql as
|
|
15
|
-
let
|
|
1
|
+
var 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
|
+
var ie = (s, n, a) => La(s, typeof n != "symbol" ? n + "" : n, a);
|
|
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,7 +63,7 @@ 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
68
|
for (let f of n.props)
|
|
69
69
|
if (Array.isArray(f) || (f = f(i)), f) {
|
|
@@ -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;
|
|
@@ -194,21 +194,21 @@ class ue {
|
|
|
194
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
|
|
197
|
+
let ds = 0;
|
|
198
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
208
|
let i = [], f = new ue(n.name, i, n, a);
|
|
209
209
|
for (let E of a)
|
|
210
210
|
E.instances.push(f);
|
|
211
|
-
let b =
|
|
211
|
+
let b = fs(a);
|
|
212
212
|
for (let E of n.set)
|
|
213
213
|
if (!E.modified.length)
|
|
214
214
|
for (let R of b)
|
|
@@ -216,10 +216,10 @@ class Tt {
|
|
|
216
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++)
|
|
@@ -256,7 +256,7 @@ 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
261
|
for (let f of s)
|
|
262
262
|
if (!Array.isArray(f.tag))
|
|
@@ -281,7 +281,7 @@ function fs(s, n) {
|
|
|
281
281
|
scope: o
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
const y = ue.define, Ct = y(), Te = y(),
|
|
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
|
*/
|
|
@@ -309,19 +309,19 @@ const y = ue.define, Ct = y(), Te = y(), tr = y(Te), nr = y(Te), Fe = y(), Pt =
|
|
|
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: y(
|
|
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: y(
|
|
324
|
+
attributeName: y(rr),
|
|
325
325
|
/**
|
|
326
326
|
The [name](#highlight.tags.name) of a class.
|
|
327
327
|
*/
|
|
@@ -513,31 +513,31 @@ const y = ue.define, Ct = y(), Te = y(), tr = y(Te), nr = y(Te), Fe = y(), 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: y(
|
|
520
|
+
heading1: y(Ue),
|
|
521
521
|
/**
|
|
522
522
|
A level 2 [heading](#highlight.tags.heading).
|
|
523
523
|
*/
|
|
524
|
-
heading2: y(
|
|
524
|
+
heading2: y(Ue),
|
|
525
525
|
/**
|
|
526
526
|
A level 3 [heading](#highlight.tags.heading).
|
|
527
527
|
*/
|
|
528
|
-
heading3: y(
|
|
528
|
+
heading3: y(Ue),
|
|
529
529
|
/**
|
|
530
530
|
A level 4 [heading](#highlight.tags.heading).
|
|
531
531
|
*/
|
|
532
|
-
heading4: y(
|
|
532
|
+
heading4: y(Ue),
|
|
533
533
|
/**
|
|
534
534
|
A level 5 [heading](#highlight.tags.heading).
|
|
535
535
|
*/
|
|
536
|
-
heading5: y(
|
|
536
|
+
heading5: y(Ue),
|
|
537
537
|
/**
|
|
538
538
|
A level 6 [heading](#highlight.tags.heading).
|
|
539
539
|
*/
|
|
540
|
-
heading6: y(
|
|
540
|
+
heading6: y(Ue),
|
|
541
541
|
/**
|
|
542
542
|
A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
|
|
543
543
|
*/
|
|
@@ -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: [
|
|
@@ -784,27 +784,27 @@ const vs = {
|
|
|
784
784
|
{ tag: d.invalid, color: "var(--vpe-syn-invalid)" }
|
|
785
785
|
]);
|
|
786
786
|
function Nt(s) {
|
|
787
|
-
return [Le.theme(
|
|
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
804
|
provide: (s) => Le.decorations.from(s)
|
|
805
|
-
}),
|
|
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 gs = Ba.define({
|
|
|
814
814
|
},
|
|
815
815
|
"&.cm-focused": { outline: "none" }
|
|
816
816
|
});
|
|
817
|
-
function
|
|
817
|
+
function ws(s, n) {
|
|
818
818
|
const a = Le.updateListener.of((f) => {
|
|
819
819
|
f.docChanged && n.onDocChange(f.state.doc.toString());
|
|
820
|
-
}), o =
|
|
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
|
-
|
|
833
|
+
ja(),
|
|
834
|
+
Wa(),
|
|
835
|
+
rs.of(" "),
|
|
836
|
+
n.language ?? yr(),
|
|
837
837
|
Nt(n.dark),
|
|
838
|
-
Ka(),
|
|
839
838
|
Ja(),
|
|
840
|
-
|
|
839
|
+
Za(),
|
|
840
|
+
as(),
|
|
841
841
|
Le.lineWrapping,
|
|
842
|
-
|
|
843
|
-
|
|
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
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 [];
|
|
@@ -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") {
|
|
@@ -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) {
|
|
@@ -1463,12 +1463,12 @@ 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)");
|
|
@@ -1476,7 +1476,7 @@ function Ps(s) {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
async function $t(s, n, a, o = {}) {
|
|
1478
1478
|
var R, M;
|
|
1479
|
-
const i =
|
|
1479
|
+
const i = Os(s), f = new AbortController(), b = setTimeout(() => f.abort(), o.timeoutMs ?? Ps), E = () => f.abort();
|
|
1480
1480
|
o.signal && (o.signal.aborted ? f.abort() : o.signal.addEventListener("abort", E));
|
|
1481
1481
|
try {
|
|
1482
1482
|
const T = await fetch(i + n, {
|
|
@@ -1502,10 +1502,10 @@ async function $t(s, n, a, o = {}) {
|
|
|
1502
1502
|
clearTimeout(b), (M = o.signal) == null || M.removeEventListener("abort", E);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
function
|
|
1505
|
+
function Ms(s, n = {}) {
|
|
1506
1506
|
return $t(s, "", { method: "GET" }, n);
|
|
1507
1507
|
}
|
|
1508
|
-
function
|
|
1508
|
+
function Ns(s, n, a = {}) {
|
|
1509
1509
|
return $t(
|
|
1510
1510
|
s,
|
|
1511
1511
|
"",
|
|
@@ -1513,7 +1513,7 @@ function Ms(s, n, a = {}) {
|
|
|
1513
1513
|
a
|
|
1514
1514
|
);
|
|
1515
1515
|
}
|
|
1516
|
-
function
|
|
1516
|
+
function Ts(s, n, a = {}) {
|
|
1517
1517
|
return $t(
|
|
1518
1518
|
s,
|
|
1519
1519
|
`/${encodeURIComponent(n)}`,
|
|
@@ -1521,17 +1521,17 @@ function Ns(s, n, a = {}) {
|
|
|
1521
1521
|
a
|
|
1522
1522
|
);
|
|
1523
1523
|
}
|
|
1524
|
-
async function
|
|
1524
|
+
async function Fs(s, n, a = {}) {
|
|
1525
1525
|
await $t(s, `/${encodeURIComponent(n)}`, { method: "DELETE" }, a);
|
|
1526
1526
|
}
|
|
1527
|
-
const
|
|
1527
|
+
const Ls = 6e4;
|
|
1528
1528
|
function cn(s) {
|
|
1529
1529
|
const n = (s ?? "").trim().replace(/\/+$/, "");
|
|
1530
1530
|
if (!n)
|
|
1531
1531
|
throw new Error("未配置 Python 服务端点(pythonEndpoint)");
|
|
1532
1532
|
return n;
|
|
1533
1533
|
}
|
|
1534
|
-
function
|
|
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,9 +1543,9 @@ function gr(s, n) {
|
|
|
1543
1543
|
}
|
|
1544
1544
|
return { type: "PythonError", message: n };
|
|
1545
1545
|
}
|
|
1546
|
-
async function
|
|
1546
|
+
async function al(s, n, a = {}) {
|
|
1547
1547
|
var R;
|
|
1548
|
-
const o = cn(s), i = performance.now(), f = new AbortController(), b = setTimeout(() => f.abort(), a.timeoutMs ??
|
|
1548
|
+
const o = cn(s), i = performance.now(), f = new AbortController(), b = setTimeout(() => f.abort(), a.timeoutMs ?? Ls), E = () => f.abort();
|
|
1549
1549
|
a.signal && (a.signal.aborted ? f.abort() : a.signal.addEventListener("abort", E));
|
|
1550
1550
|
try {
|
|
1551
1551
|
const M = await fetch(`${o}/run`, {
|
|
@@ -1593,13 +1593,13 @@ async function el(s, n, a = {}) {
|
|
|
1593
1593
|
stderr: typeof x.stderr == "string" ? x.stderr : "",
|
|
1594
1594
|
exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
|
|
1595
1595
|
durationMs: Number.isFinite(G) && G >= 0 ? G : $,
|
|
1596
|
-
error: q ? void 0 :
|
|
1596
|
+
error: q ? void 0 : br(x.error, "服务端 Python 执行失败")
|
|
1597
1597
|
};
|
|
1598
1598
|
} finally {
|
|
1599
1599
|
clearTimeout(b), (R = a.signal) == null || R.removeEventListener("abort", E);
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
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) {
|
|
@@ -1624,7 +1624,7 @@ async function dn(s, n, a, o, i) {
|
|
|
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
1640
|
const me = Number(q.exitCode), N = Number(q.durationMs);
|
|
1641
1641
|
return {
|
|
1642
1642
|
sessionId: typeof q.sessionId == "string" ? q.sessionId : "",
|
|
1643
|
-
state:
|
|
1643
|
+
state: $s(q.state),
|
|
1644
1644
|
stdout: typeof q.stdout == "string" ? q.stdout : "",
|
|
1645
1645
|
stderr: typeof q.stderr == "string" ? q.stderr : "",
|
|
1646
1646
|
exitCode: Number.isFinite(me) ? Math.trunc(me) : void 0,
|
|
1647
1647
|
durationMs: Number.isFinite(N) ? N : G,
|
|
1648
|
-
error: q.error ?
|
|
1648
|
+
error: q.error ? br(q.error, "服务端 Python 执行失败") : void 0
|
|
1649
1649
|
};
|
|
1650
1650
|
} finally {
|
|
1651
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",
|
|
@@ -1667,7 +1667,7 @@ function $s(s, n, a = {}) {
|
|
|
1667
1667
|
2e4
|
|
1668
1668
|
);
|
|
1669
1669
|
}
|
|
1670
|
-
function
|
|
1670
|
+
function _s(s, n, a = {}) {
|
|
1671
1671
|
return dn(
|
|
1672
1672
|
s,
|
|
1673
1673
|
`/sessions/${encodeURIComponent(n)}`,
|
|
@@ -1676,7 +1676,7 @@ function Rs(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 _s(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,20 +1704,20 @@ 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))
|
|
@@ -1725,14 +1725,14 @@ function Hs(s) {
|
|
|
1725
1725
|
}
|
|
1726
1726
|
function D(s = {}) {
|
|
1727
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 =
|
|
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:
|
|
1735
|
+
port: Bs((R = s.connection) == null ? void 0 : R.port),
|
|
1736
1736
|
user: ((M = s.connection) == null ? void 0 : M.user) ?? "",
|
|
1737
1737
|
password: ((T = s.connection) == null ? void 0 : T.password) ?? "",
|
|
1738
1738
|
database: i ?? (n === "sqlite" ? ":memory:" : ""),
|
|
@@ -1740,11 +1740,11 @@ function D(s = {}) {
|
|
|
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,
|
|
@@ -1801,7 +1801,7 @@ function or(s, n) {
|
|
|
1801
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 {
|
|
@@ -1847,7 +1847,7 @@ async function Us(s, n, a, o) {
|
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
1849
|
if (!T.ok) {
|
|
1850
|
-
const q = $ ?
|
|
1850
|
+
const q = $ ? ir($, performance.now() - f) : null;
|
|
1851
1851
|
return {
|
|
1852
1852
|
ok: !1,
|
|
1853
1853
|
results: [],
|
|
@@ -1858,7 +1858,7 @@ async function Us(s, n, a, o) {
|
|
|
1858
1858
|
durationMs: performance.now() - f
|
|
1859
1859
|
};
|
|
1860
1860
|
}
|
|
1861
|
-
return
|
|
1861
|
+
return ir($, performance.now() - f);
|
|
1862
1862
|
} catch (T) {
|
|
1863
1863
|
if (E)
|
|
1864
1864
|
return {
|
|
@@ -1875,7 +1875,7 @@ async function Us(s, n, a, o) {
|
|
|
1875
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,18 +1910,18 @@ 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 执行已中断" },
|
|
@@ -1934,13 +1934,13 @@ async function kr(s, n, a = {}) {
|
|
|
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)`,
|
|
@@ -1982,10 +1982,10 @@ async function fn(s, n, a, o = {}) {
|
|
|
1982
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)}`,
|
|
@@ -2013,17 +2013,17 @@ function Mt(s) {
|
|
|
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,7 @@ 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 },
|
|
2186
2195
|
showNewFile: { type: Boolean, default: !0 },
|
|
2187
2196
|
showOpenFile: { type: Boolean, default: !0 },
|
|
2188
2197
|
showDownload: { type: Boolean, default: !0 },
|
|
@@ -2210,15 +2219,15 @@ const Vs = Z(
|
|
|
2210
2219
|
pythonHeaders: { default: void 0 },
|
|
2211
2220
|
runtime: { default: "browser" }
|
|
2212
2221
|
},
|
|
2213
|
-
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"],
|
|
2214
2223
|
setup(s, { expose: n, emit: a }) {
|
|
2215
|
-
const o = s, i = a, f = C(), b = C(), E = C(), R = C(), M = C(), T = C(), x = C(null), $ = C(!1), q =
|
|
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(() => {
|
|
2216
2225
|
var e;
|
|
2217
2226
|
return !!((e = Q.value) != null && e.busy);
|
|
2218
|
-
}),
|
|
2227
|
+
}), De = U(() => {
|
|
2219
2228
|
var e;
|
|
2220
2229
|
return !!((e = Q.value) != null && e.waiting);
|
|
2221
|
-
}),
|
|
2230
|
+
}), B = U({
|
|
2222
2231
|
get: () => {
|
|
2223
2232
|
var e;
|
|
2224
2233
|
return ((e = Q.value) == null ? void 0 : e.input) ?? "";
|
|
@@ -2227,12 +2236,12 @@ const Vs = Z(
|
|
|
2227
2236
|
const t = Q.value;
|
|
2228
2237
|
t && (t.input = e);
|
|
2229
2238
|
}
|
|
2230
|
-
}), k = C(null), I = C("idle"),
|
|
2231
|
-
let Rt = !1, yt, vn = !1, _t = !1, mn = !1, P = null,
|
|
2232
|
-
function
|
|
2233
|
-
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 };
|
|
2234
2243
|
}
|
|
2235
|
-
const F = C([
|
|
2244
|
+
const F = C([Je(o.fileName, o.language, o.modelValue)]), qe = C(F.value[0].id), w = U(
|
|
2236
2245
|
() => F.value.find((e) => e.id === qe.value) ?? F.value[0]
|
|
2237
2246
|
), Ie = U({
|
|
2238
2247
|
get: () => w.value.name,
|
|
@@ -2240,24 +2249,24 @@ const Vs = Z(
|
|
|
2240
2249
|
const t = w.value;
|
|
2241
2250
|
t.name !== e && (t.name = e, i("update:fileName", e));
|
|
2242
2251
|
}
|
|
2243
|
-
}), yn = new qt(), Ht = new qt(), Bt = new qt(), Ut = new qt(),
|
|
2252
|
+
}), yn = new qt(), Ht = new qt(), Bt = new qt(), Ut = new qt(), V = un(o.pyodideUrl ? { pyodideUrl: o.pyodideUrl } : void 0), qr = U(() => ({
|
|
2244
2253
|
height: typeof o.height == "number" ? `${o.height}px` : o.height
|
|
2245
|
-
})),
|
|
2246
|
-
`vpe-theme-${
|
|
2247
|
-
ut(
|
|
2254
|
+
})), Cr = U(() => [
|
|
2255
|
+
`vpe-theme-${j.value}`,
|
|
2256
|
+
ut(j.value) ? "vpe-dark" : ""
|
|
2248
2257
|
]);
|
|
2249
|
-
let hn = 0, At = 0,
|
|
2250
|
-
const
|
|
2258
|
+
let hn = 0, At = 0, Ze = null;
|
|
2259
|
+
const Pr = U(
|
|
2251
2260
|
() => x.value !== null ? `${x.value}px` : typeof o.outputHeight == "number" ? `${o.outputHeight}px` : o.outputHeight
|
|
2252
|
-
), pe = U(() => w.value.language === "sql"), gn = U(() => w.value.language === "python"), bt = U(() => !!(o.pythonEndpoint ?? "").trim()),
|
|
2261
|
+
), pe = U(() => w.value.language === "sql"), gn = U(() => w.value.language === "python"), bt = U(() => !!(o.pythonEndpoint ?? "").trim()), Ge = U(
|
|
2253
2262
|
() => gn.value && bt.value && ce.value === "server"
|
|
2254
|
-
),
|
|
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 ? "就绪" : {
|
|
2255
2264
|
idle: "未加载",
|
|
2256
2265
|
loading: "正在加载 Pyodide…",
|
|
2257
2266
|
ready: "就绪",
|
|
2258
2267
|
running: "运行中"
|
|
2259
|
-
}[I.value]),
|
|
2260
|
-
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) {
|
|
2261
2270
|
return { ...e };
|
|
2262
2271
|
}
|
|
2263
2272
|
function fe(e = w.value.id) {
|
|
@@ -2265,15 +2274,15 @@ const Vs = Z(
|
|
|
2265
2274
|
return t || (t = { lines: [], sqlResults: [] }, q.set(e, t)), t;
|
|
2266
2275
|
}
|
|
2267
2276
|
function ye(e, t, r) {
|
|
2268
|
-
fe(r).lines.push({ id: ++
|
|
2277
|
+
fe(r).lines.push({ id: ++Sr, stream: e, text: t });
|
|
2269
2278
|
}
|
|
2270
2279
|
function g(e, t) {
|
|
2271
2280
|
ye("system", e, t);
|
|
2272
2281
|
}
|
|
2273
|
-
function
|
|
2282
|
+
function Fr(e) {
|
|
2274
2283
|
return Lt.some((t) => t.value === e);
|
|
2275
2284
|
}
|
|
2276
|
-
function
|
|
2285
|
+
function Lr() {
|
|
2277
2286
|
if (!o.storageKey || typeof window > "u") return null;
|
|
2278
2287
|
try {
|
|
2279
2288
|
const e = window.localStorage.getItem(o.storageKey);
|
|
@@ -2283,7 +2292,7 @@ const Vs = Z(
|
|
|
2283
2292
|
const r = [];
|
|
2284
2293
|
for (const h of t.files) {
|
|
2285
2294
|
if (!h || typeof h.name != "string" || typeof h.code != "string" || !h.name.trim()) continue;
|
|
2286
|
-
const S =
|
|
2295
|
+
const S = Fr(h.language) ? h.language : "python";
|
|
2287
2296
|
r.push({ name: h.name, language: S, code: h.code });
|
|
2288
2297
|
}
|
|
2289
2298
|
if (!r.length) return null;
|
|
@@ -2293,10 +2302,10 @@ const Vs = Z(
|
|
|
2293
2302
|
return null;
|
|
2294
2303
|
}
|
|
2295
2304
|
}
|
|
2296
|
-
function
|
|
2297
|
-
const e =
|
|
2305
|
+
function $r() {
|
|
2306
|
+
const e = Lr();
|
|
2298
2307
|
if (!e) return;
|
|
2299
|
-
F.value = e.files.map((r) =>
|
|
2308
|
+
F.value = e.files.map((r) => Je(r.name, r.language, r.code));
|
|
2300
2309
|
const t = F.value[e.activeIndex] ?? F.value[0];
|
|
2301
2310
|
qe.value = t.id, g(`已恢复上次编辑内容(${F.value.length} 个文件)`), i("update:modelValue", t.code), i("update:fileName", t.name), i("update:language", t.language);
|
|
2302
2311
|
}
|
|
@@ -2320,10 +2329,10 @@ const Vs = Z(
|
|
|
2320
2329
|
vn || (vn = !0, g(`本地草稿保存失败:${e instanceof Error ? e.message : String(e)}`));
|
|
2321
2330
|
}
|
|
2322
2331
|
}
|
|
2323
|
-
function
|
|
2332
|
+
function Rr() {
|
|
2324
2333
|
!Rt || !o.storageKey || typeof window > "u" || (_t = !1, window.clearTimeout(yt), yt = window.setTimeout(kn, 400));
|
|
2325
2334
|
}
|
|
2326
|
-
function
|
|
2335
|
+
function _r() {
|
|
2327
2336
|
if (!(!o.storageKey || typeof window > "u")) {
|
|
2328
2337
|
window.clearTimeout(yt);
|
|
2329
2338
|
try {
|
|
@@ -2333,12 +2342,12 @@ const Vs = Z(
|
|
|
2333
2342
|
}
|
|
2334
2343
|
}
|
|
2335
2344
|
}
|
|
2336
|
-
function
|
|
2345
|
+
function Ne(e) {
|
|
2337
2346
|
if (!P) return;
|
|
2338
2347
|
const t = e ? [e] : [];
|
|
2339
|
-
P.dispatch({ effects:
|
|
2348
|
+
P.dispatch({ effects: hr.of(t) });
|
|
2340
2349
|
}
|
|
2341
|
-
function
|
|
2350
|
+
function Ir() {
|
|
2342
2351
|
const e = o.modelValue;
|
|
2343
2352
|
if (P) {
|
|
2344
2353
|
e !== P.state.doc.toString() && P.dispatch({ changes: { from: 0, to: P.state.doc.length, insert: e } });
|
|
@@ -2347,7 +2356,7 @@ const Vs = Z(
|
|
|
2347
2356
|
const t = w.value;
|
|
2348
2357
|
t.code !== e && (t.code = e);
|
|
2349
2358
|
}
|
|
2350
|
-
function
|
|
2359
|
+
function Ce() {
|
|
2351
2360
|
return P ? P.state.doc.toString() : w.value.code;
|
|
2352
2361
|
}
|
|
2353
2362
|
function kt(e) {
|
|
@@ -2359,12 +2368,12 @@ const Vs = Z(
|
|
|
2359
2368
|
t.code = e, e !== o.modelValue && i("update:modelValue", e);
|
|
2360
2369
|
}
|
|
2361
2370
|
function zt(e) {
|
|
2362
|
-
return o.disableLint || e !== "python" ? [] :
|
|
2371
|
+
return o.disableLint || e !== "python" ? [] : Ss(V, o.lintDelay);
|
|
2363
2372
|
}
|
|
2364
2373
|
function jt(e) {
|
|
2365
2374
|
const t = w.value;
|
|
2366
2375
|
if (t.language !== e) {
|
|
2367
|
-
if (t.language = e, fe(t.id).sqlResults = [],
|
|
2376
|
+
if (t.language = e, fe(t.id).sqlResults = [], Ne(void 0), P == null || P.dispatch({
|
|
2368
2377
|
effects: [
|
|
2369
2378
|
Bt.reconfigure(en(e)),
|
|
2370
2379
|
Ut.reconfigure(zt(e))
|
|
@@ -2396,19 +2405,19 @@ const Vs = Z(
|
|
|
2396
2405
|
return h;
|
|
2397
2406
|
}
|
|
2398
2407
|
let We = 0;
|
|
2399
|
-
function
|
|
2408
|
+
function Hr(e) {
|
|
2400
2409
|
return !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
|
|
2401
2410
|
}
|
|
2402
|
-
async function
|
|
2411
|
+
async function Br() {
|
|
2403
2412
|
var t;
|
|
2404
2413
|
if (!o.syncFilesOnRun) return;
|
|
2405
2414
|
const e = F.value.filter((r) => r.language === "python");
|
|
2406
2415
|
for (const r of e) {
|
|
2407
|
-
if (!
|
|
2416
|
+
if (!Hr(r.name)) {
|
|
2408
2417
|
g(`跳过同步文件:${r.name}(文件名不能包含路径分隔符)`);
|
|
2409
2418
|
continue;
|
|
2410
2419
|
}
|
|
2411
|
-
const u = await
|
|
2420
|
+
const u = await V.writeFile(r.name, r.code);
|
|
2412
2421
|
u.ok || g(`同步文件失败:${r.name}(${((t = u.error) == null ? void 0 : t.message) ?? "未知错误"})`);
|
|
2413
2422
|
}
|
|
2414
2423
|
}
|
|
@@ -2420,13 +2429,13 @@ const Vs = Z(
|
|
|
2420
2429
|
const e = D(v.value);
|
|
2421
2430
|
v.value = e, i("update:sqlConfig", D(e));
|
|
2422
2431
|
}
|
|
2423
|
-
function Br() {
|
|
2424
|
-
_e.value = !1, $e.value = !0, ve();
|
|
2425
|
-
}
|
|
2426
2432
|
function Ur() {
|
|
2427
|
-
|
|
2433
|
+
_e.value = !1, $e.value = !0, ve();
|
|
2428
2434
|
}
|
|
2429
2435
|
function Ar() {
|
|
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() {
|
|
2430
2439
|
const e = v.value.connection.dialect, t = e === "sqlite" ? "mysql" : e;
|
|
2431
2440
|
v.value = D({
|
|
2432
2441
|
mode: "http",
|
|
@@ -2434,40 +2443,40 @@ const Vs = Z(
|
|
|
2434
2443
|
headers: v.value.headers,
|
|
2435
2444
|
maxRows: v.value.maxRows,
|
|
2436
2445
|
timeoutMs: v.value.timeoutMs,
|
|
2437
|
-
connection: { dialect: t, port:
|
|
2438
|
-
}), ne.value = "", ae.value = "",
|
|
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();
|
|
2439
2448
|
}
|
|
2440
2449
|
function xn() {
|
|
2441
2450
|
$e.value = !1;
|
|
2442
2451
|
}
|
|
2443
|
-
function
|
|
2452
|
+
function zr() {
|
|
2444
2453
|
const e = v.value;
|
|
2445
|
-
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 =
|
|
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();
|
|
2446
2455
|
}
|
|
2447
|
-
function
|
|
2456
|
+
function jr() {
|
|
2448
2457
|
const e = v.value.connection, t = dt.find((u) => u.value === e.dialect), r = dt.map((u) => u.defaultPort);
|
|
2449
2458
|
t != null && t.defaultPort && (!e.port || r.includes(e.port)) && (e.port = t.defaultPort), he();
|
|
2450
2459
|
}
|
|
2451
2460
|
async function ve() {
|
|
2452
2461
|
const e = D(v.value);
|
|
2453
2462
|
if (!e.endpoint) {
|
|
2454
|
-
|
|
2463
|
+
Pe.value = [], Oe.value = "";
|
|
2455
2464
|
return;
|
|
2456
2465
|
}
|
|
2457
2466
|
se == null || se.abort();
|
|
2458
2467
|
const t = new AbortController();
|
|
2459
|
-
se = t,
|
|
2468
|
+
se = t, Ve.value = !0, Oe.value = "";
|
|
2460
2469
|
try {
|
|
2461
|
-
const r = await
|
|
2470
|
+
const r = await zs(e, { signal: t.signal });
|
|
2462
2471
|
if (se !== t) return;
|
|
2463
|
-
|
|
2472
|
+
Pe.value = r;
|
|
2464
2473
|
const u = r.find((c) => c.id === v.value.connectionId);
|
|
2465
2474
|
u ? ne.value = u.name : v.value.connectionId && (v.value.connectionId = void 0, ne.value = "");
|
|
2466
2475
|
} catch (r) {
|
|
2467
2476
|
if (se !== t) return;
|
|
2468
|
-
|
|
2477
|
+
Pe.value = [], Oe.value = r instanceof Error ? r.message : String(r);
|
|
2469
2478
|
} finally {
|
|
2470
|
-
se === t && (se = null,
|
|
2479
|
+
se === t && (se = null, Ve.value = !1);
|
|
2471
2480
|
}
|
|
2472
2481
|
}
|
|
2473
2482
|
function En(e) {
|
|
@@ -2489,23 +2498,23 @@ const Vs = Z(
|
|
|
2489
2498
|
}
|
|
2490
2499
|
}), ne.value = e.name, ae.value = "", at(), i("update:sqlConfig", D(v.value));
|
|
2491
2500
|
}
|
|
2492
|
-
function
|
|
2501
|
+
function Vr() {
|
|
2493
2502
|
$e.value = !1, _e.value = !1;
|
|
2494
|
-
const e =
|
|
2503
|
+
const e = Pe.value.find((t) => t.id === v.value.connectionId);
|
|
2495
2504
|
if (!e) {
|
|
2496
2505
|
v.value.connectionId = void 0, v.value.connection.password = "", ne.value = "", he();
|
|
2497
2506
|
return;
|
|
2498
2507
|
}
|
|
2499
2508
|
En(e);
|
|
2500
2509
|
}
|
|
2501
|
-
function
|
|
2510
|
+
function Qr(e) {
|
|
2502
2511
|
En(e), _e.value = !1, $e.value = !0;
|
|
2503
2512
|
}
|
|
2504
|
-
async function
|
|
2513
|
+
async function Kr() {
|
|
2505
2514
|
if (re.value) return;
|
|
2506
2515
|
const e = ne.value.trim();
|
|
2507
2516
|
if (!e) {
|
|
2508
|
-
|
|
2517
|
+
Qe.value = !1, ae.value = "请先填写连接名称";
|
|
2509
2518
|
return;
|
|
2510
2519
|
}
|
|
2511
2520
|
const t = D(v.value), r = {
|
|
@@ -2520,50 +2529,50 @@ const Vs = Z(
|
|
|
2520
2529
|
};
|
|
2521
2530
|
re.value = !0, ae.value = "";
|
|
2522
2531
|
try {
|
|
2523
|
-
const u = await
|
|
2532
|
+
const u = await js(t, r, t.connectionId);
|
|
2524
2533
|
v.value = D({
|
|
2525
2534
|
...t,
|
|
2526
2535
|
connectionId: u.id,
|
|
2527
2536
|
connection: { ...t.connection, password: "" }
|
|
2528
|
-
}), ne.value = u.name,
|
|
2537
|
+
}), ne.value = u.name, Qe.value = !0, ae.value = "连接已保存", i("update:sqlConfig", D(v.value)), await ve();
|
|
2529
2538
|
} catch (u) {
|
|
2530
|
-
|
|
2539
|
+
Qe.value = !1, ae.value = u instanceof Error ? u.message : String(u);
|
|
2531
2540
|
} finally {
|
|
2532
2541
|
re.value = !1;
|
|
2533
2542
|
}
|
|
2534
2543
|
}
|
|
2535
|
-
async function
|
|
2544
|
+
async function Jr() {
|
|
2536
2545
|
const e = v.value.connectionId;
|
|
2537
2546
|
if (!(!e || re.value) && !(typeof window < "u" && !window.confirm("确定删除该连接配置?"))) {
|
|
2538
2547
|
re.value = !0, ae.value = "";
|
|
2539
2548
|
try {
|
|
2540
|
-
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();
|
|
2541
2550
|
} catch (t) {
|
|
2542
|
-
|
|
2551
|
+
Qe.value = !1, ae.value = t instanceof Error ? t.message : String(t);
|
|
2543
2552
|
} finally {
|
|
2544
2553
|
re.value = !1;
|
|
2545
2554
|
}
|
|
2546
2555
|
}
|
|
2547
2556
|
}
|
|
2548
|
-
async function
|
|
2557
|
+
async function Zr(e) {
|
|
2549
2558
|
if (!re.value && !(typeof window < "u" && !window.confirm(`确定删除连接“${e.name}”?`))) {
|
|
2550
|
-
re.value = !0,
|
|
2559
|
+
re.value = !0, Ke.value = "";
|
|
2551
2560
|
try {
|
|
2552
|
-
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();
|
|
2553
2562
|
} catch (t) {
|
|
2554
|
-
mt.value = !1,
|
|
2563
|
+
mt.value = !1, Ke.value = t instanceof Error ? t.message : String(t);
|
|
2555
2564
|
} finally {
|
|
2556
2565
|
re.value = !1;
|
|
2557
2566
|
}
|
|
2558
2567
|
}
|
|
2559
2568
|
}
|
|
2560
|
-
async function
|
|
2569
|
+
async function Gr() {
|
|
2561
2570
|
if (Re.value) return;
|
|
2562
2571
|
at(), Re.value = !0;
|
|
2563
2572
|
const e = new AbortController();
|
|
2564
2573
|
Y = e;
|
|
2565
2574
|
try {
|
|
2566
|
-
const t = await
|
|
2575
|
+
const t = await Ds(D(v.value), {
|
|
2567
2576
|
executor: o.sqlExecutor,
|
|
2568
2577
|
signal: e.signal
|
|
2569
2578
|
});
|
|
@@ -2576,10 +2585,10 @@ const Vs = Z(
|
|
|
2576
2585
|
Y === e && (Y = null, Re.value = !1);
|
|
2577
2586
|
}
|
|
2578
2587
|
}
|
|
2579
|
-
function
|
|
2588
|
+
function Wr(e) {
|
|
2580
2589
|
return e === null ? "NULL" : String(e);
|
|
2581
2590
|
}
|
|
2582
|
-
function
|
|
2591
|
+
function Yr(e) {
|
|
2583
2592
|
return e.columns.length ? `${e.rows.length} 行${e.truncated ? "(已截断)" : ""}` : `影响 ${e.affectedRows ?? 0} 行`;
|
|
2584
2593
|
}
|
|
2585
2594
|
function qn(e) {
|
|
@@ -2589,16 +2598,16 @@ const Vs = Z(
|
|
|
2589
2598
|
async function Cn() {
|
|
2590
2599
|
if (Ee.value)
|
|
2591
2600
|
return k.value !== w.value.id && g("另一个 SQL 正在执行,请等待或停止后再试"), null;
|
|
2592
|
-
const e =
|
|
2601
|
+
const e = Ce();
|
|
2593
2602
|
if (!e.trim())
|
|
2594
2603
|
return g("SQL 内容为空,请输入要执行的语句"), null;
|
|
2595
2604
|
const t = D(v.value), r = ++rt, u = w.value.id;
|
|
2596
|
-
Ee.value = !0, k.value = u, de = new AbortController(),
|
|
2605
|
+
Ee.value = !0, k.value = u, de = new AbortController(), Ne(void 0), o.clearOutputOnRun && (fe(u).lines = [], fe(u).sqlResults = []), g(
|
|
2597
2606
|
`开始执行 SQL(${t.mode === "sqlite" ? "浏览器内 SQLite" : "HTTP 服务"})`,
|
|
2598
2607
|
u
|
|
2599
2608
|
), i("runStart");
|
|
2600
2609
|
try {
|
|
2601
|
-
const c = await
|
|
2610
|
+
const c = await wr(t, e, {
|
|
2602
2611
|
executor: o.sqlExecutor,
|
|
2603
2612
|
signal: de.signal
|
|
2604
2613
|
});
|
|
@@ -2628,10 +2637,10 @@ const Vs = Z(
|
|
|
2628
2637
|
r === rt && (Ee.value = !1, de = null, k.value === u && (k.value = null));
|
|
2629
2638
|
}
|
|
2630
2639
|
}
|
|
2631
|
-
async function
|
|
2640
|
+
async function Xr(e) {
|
|
2632
2641
|
return e !== void 0 && (kt(e), w.value.language !== "sql" && jt("sql")), w.value.language !== "sql" ? (g("当前文件不是 SQL,无法执行"), null) : Cn();
|
|
2633
2642
|
}
|
|
2634
|
-
function
|
|
2643
|
+
function ea(e) {
|
|
2635
2644
|
const t = e.target.value === "server" ? "server" : "browser";
|
|
2636
2645
|
if (t === "browser")
|
|
2637
2646
|
for (const r of [...N.keys()])
|
|
@@ -2657,7 +2666,7 @@ const Vs = Z(
|
|
|
2657
2666
|
window.clearTimeout(t.pollTimer), On(e, t);
|
|
2658
2667
|
const u = N.get(e);
|
|
2659
2668
|
if (u && u.token === t.token && N.delete(e), r.error) {
|
|
2660
|
-
g(`执行出错:${r.error.type}`, e), e === w.value.id &&
|
|
2669
|
+
g(`执行出错:${r.error.type}`, e), e === w.value.id && Ne(r.error.line);
|
|
2661
2670
|
const h = {
|
|
2662
2671
|
type: r.error.type,
|
|
2663
2672
|
message: r.error.message,
|
|
@@ -2681,20 +2690,20 @@ const Vs = Z(
|
|
|
2681
2690
|
t.waiting = !0;
|
|
2682
2691
|
return;
|
|
2683
2692
|
}
|
|
2684
|
-
t.waiting = !1,
|
|
2693
|
+
t.waiting = !1, ta(e, t, u);
|
|
2685
2694
|
}
|
|
2686
2695
|
}
|
|
2687
|
-
function
|
|
2696
|
+
function ta(e, t, r) {
|
|
2688
2697
|
window.clearTimeout(t.pollTimer), t.pollTimer = window.setTimeout(() => {
|
|
2689
|
-
|
|
2698
|
+
na(e, r);
|
|
2690
2699
|
}, 250);
|
|
2691
2700
|
}
|
|
2692
|
-
async function
|
|
2701
|
+
async function na(e, t) {
|
|
2693
2702
|
var u, c;
|
|
2694
2703
|
const r = N.get(e);
|
|
2695
2704
|
if (!(!r || r.token !== t || !r.sessionId))
|
|
2696
2705
|
try {
|
|
2697
|
-
const h = await
|
|
2706
|
+
const h = await _s(o.pythonEndpoint, r.sessionId, {
|
|
2698
2707
|
headers: o.pythonHeaders,
|
|
2699
2708
|
signal: (u = r.abort) == null ? void 0 : u.signal
|
|
2700
2709
|
});
|
|
@@ -2709,7 +2718,7 @@ const Vs = Z(
|
|
|
2709
2718
|
});
|
|
2710
2719
|
}
|
|
2711
2720
|
}
|
|
2712
|
-
async function
|
|
2721
|
+
async function ra() {
|
|
2713
2722
|
var h;
|
|
2714
2723
|
const e = w.value.id;
|
|
2715
2724
|
if ((h = N.get(e)) != null && h.busy) return;
|
|
@@ -2717,12 +2726,12 @@ const Vs = Z(
|
|
|
2717
2726
|
g("未配置 Python 服务端点(pythonEndpoint)");
|
|
2718
2727
|
return;
|
|
2719
2728
|
}
|
|
2720
|
-
const t =
|
|
2729
|
+
const t = Ce();
|
|
2721
2730
|
if (!t.trim()) {
|
|
2722
2731
|
g("代码为空,请输入要执行的 Python 代码");
|
|
2723
2732
|
return;
|
|
2724
2733
|
}
|
|
2725
|
-
const r = ++
|
|
2734
|
+
const r = ++Er, u = {
|
|
2726
2735
|
sessionId: "",
|
|
2727
2736
|
busy: !0,
|
|
2728
2737
|
waiting: !1,
|
|
@@ -2735,15 +2744,15 @@ const Vs = Z(
|
|
|
2735
2744
|
};
|
|
2736
2745
|
N.set(e, u);
|
|
2737
2746
|
const c = N.get(e);
|
|
2738
|
-
|
|
2747
|
+
Ne(void 0), o.clearOutputOnRun && (fe(e).lines = []), g("开始执行(服务端 Python)", e), i("runStart");
|
|
2739
2748
|
try {
|
|
2740
|
-
const S = await
|
|
2749
|
+
const S = await Rs(o.pythonEndpoint, t, {
|
|
2741
2750
|
stdin: o.stdin,
|
|
2742
2751
|
headers: o.pythonHeaders,
|
|
2743
2752
|
signal: c.abort.signal
|
|
2744
2753
|
}), L = N.get(e);
|
|
2745
2754
|
if (!L || L.token !== r) {
|
|
2746
|
-
S.sessionId &&
|
|
2755
|
+
S.sessionId && ar(o.pythonEndpoint, S.sessionId, {
|
|
2747
2756
|
headers: o.pythonHeaders
|
|
2748
2757
|
});
|
|
2749
2758
|
return;
|
|
@@ -2766,7 +2775,7 @@ const Vs = Z(
|
|
|
2766
2775
|
const r = t.input;
|
|
2767
2776
|
t.input = "", t.waiting = !1, ye("stdout", r, e), i("runOutput", { stream: "stdout", text: r });
|
|
2768
2777
|
try {
|
|
2769
|
-
const h = await
|
|
2778
|
+
const h = await Is(o.pythonEndpoint, t.sessionId, r, {
|
|
2770
2779
|
headers: o.pythonHeaders,
|
|
2771
2780
|
signal: (u = t.abort) == null ? void 0 : u.signal
|
|
2772
2781
|
});
|
|
@@ -2784,7 +2793,7 @@ const Vs = Z(
|
|
|
2784
2793
|
function st(e, t = !0) {
|
|
2785
2794
|
var u;
|
|
2786
2795
|
const r = N.get(e);
|
|
2787
|
-
r && (window.clearTimeout(r.pollTimer), N.delete(e), (u = r.abort) == null || u.abort(), r.sessionId &&
|
|
2796
|
+
r && (window.clearTimeout(r.pollTimer), N.delete(e), (u = r.abort) == null || u.abort(), r.sessionId && ar(o.pythonEndpoint, r.sessionId, {
|
|
2788
2797
|
headers: o.pythonHeaders
|
|
2789
2798
|
}), t && g("执行已中断", e));
|
|
2790
2799
|
}
|
|
@@ -2794,8 +2803,8 @@ const Vs = Z(
|
|
|
2794
2803
|
await Cn();
|
|
2795
2804
|
return;
|
|
2796
2805
|
}
|
|
2797
|
-
if (
|
|
2798
|
-
await
|
|
2806
|
+
if (Ge.value) {
|
|
2807
|
+
await ra();
|
|
2799
2808
|
return;
|
|
2800
2809
|
}
|
|
2801
2810
|
if (I.value === "running") {
|
|
@@ -2812,18 +2821,18 @@ const Vs = Z(
|
|
|
2812
2821
|
}
|
|
2813
2822
|
We += 1;
|
|
2814
2823
|
const t = We, r = w.value.id;
|
|
2815
|
-
k.value = r,
|
|
2816
|
-
const u =
|
|
2824
|
+
k.value = r, Ne(void 0), o.clearOutputOnRun && (fe(r).lines = []), g("开始执行", r), i("runStart");
|
|
2825
|
+
const u = Ce();
|
|
2817
2826
|
try {
|
|
2818
|
-
await
|
|
2819
|
-
const L = await
|
|
2827
|
+
await Br();
|
|
2828
|
+
const L = await V.run(u, {
|
|
2820
2829
|
stdin: o.stdin,
|
|
2821
2830
|
onOutput: (X, it) => {
|
|
2822
2831
|
ye(X, it, r), i("runOutput", { stream: X, text: it });
|
|
2823
2832
|
}
|
|
2824
2833
|
});
|
|
2825
2834
|
if (t !== We) return;
|
|
2826
|
-
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 &&
|
|
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);
|
|
2827
2836
|
} catch (L) {
|
|
2828
2837
|
if (t !== We) return;
|
|
2829
2838
|
const X = L instanceof Error ? L.message : String(L);
|
|
@@ -2834,14 +2843,14 @@ const Vs = Z(
|
|
|
2834
2843
|
t === We && k.value === r && (k.value = null);
|
|
2835
2844
|
}
|
|
2836
2845
|
}
|
|
2837
|
-
async function
|
|
2846
|
+
async function aa() {
|
|
2838
2847
|
var t;
|
|
2839
2848
|
if (mn) return;
|
|
2840
2849
|
const e = o.preloadPackages;
|
|
2841
2850
|
if (e.length) {
|
|
2842
2851
|
mn = !0, g(`正在安装预置包:${e.join(", ")}`);
|
|
2843
2852
|
try {
|
|
2844
|
-
const r = await
|
|
2853
|
+
const r = await V.loadPackages(e, {
|
|
2845
2854
|
onOutput: (u, c) => ye(u, c)
|
|
2846
2855
|
});
|
|
2847
2856
|
g(
|
|
@@ -2852,22 +2861,22 @@ const Vs = Z(
|
|
|
2852
2861
|
}
|
|
2853
2862
|
}
|
|
2854
2863
|
}
|
|
2855
|
-
|
|
2864
|
+
Ra(() => {
|
|
2856
2865
|
const e = b.value;
|
|
2857
2866
|
if (!e) return;
|
|
2858
|
-
|
|
2867
|
+
$r(), Rt = !0;
|
|
2859
2868
|
const t = [
|
|
2860
2869
|
yn.of([
|
|
2861
2870
|
nn.readOnly.of(o.readOnly),
|
|
2862
2871
|
Le.editable.of(!o.readOnly)
|
|
2863
2872
|
]),
|
|
2864
2873
|
Ut.of(zt(w.value.language)),
|
|
2865
|
-
Ht.of(Nt(ut(
|
|
2874
|
+
Ht.of(Nt(ut(j.value)))
|
|
2866
2875
|
];
|
|
2867
2876
|
try {
|
|
2868
|
-
P =
|
|
2877
|
+
P = ws(e, {
|
|
2869
2878
|
value: w.value.code,
|
|
2870
|
-
dark: ut(
|
|
2879
|
+
dark: ut(j.value),
|
|
2871
2880
|
placeholderText: o.placeholder,
|
|
2872
2881
|
language: Bt.of(en(w.value.language)),
|
|
2873
2882
|
extensions: t,
|
|
@@ -2883,21 +2892,21 @@ const Vs = Z(
|
|
|
2883
2892
|
c.className = "vpe-init-error", c.textContent = `编辑器初始化失败:${u}`, e.appendChild(c);
|
|
2884
2893
|
return;
|
|
2885
2894
|
}
|
|
2886
|
-
o.autofocus && P.focus(), ht =
|
|
2887
|
-
I.value = r, r === "ready" && (u && g(`Pyodide ${u} 就绪`), i("ready"), P && !o.disableLint && w.value.language === "python" &&
|
|
2888
|
-
}), gt =
|
|
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) => {
|
|
2889
2898
|
g(`Pyodide 加载失败:${r}`), i("loadError", r);
|
|
2890
|
-
}), I.value =
|
|
2899
|
+
}), I.value = V.status, pe.value && ve(), typeof ResizeObserver < "u" && f.value && (Ze = new ResizeObserver(() => {
|
|
2891
2900
|
x.value !== null && Kt(x.value);
|
|
2892
|
-
}),
|
|
2893
|
-
}),
|
|
2894
|
-
ht == null || ht(), gt == null || gt(), ot(),
|
|
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));
|
|
2902
|
+
}), _a(() => {
|
|
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;
|
|
2895
2904
|
for (const e of [...N.keys()])
|
|
2896
2905
|
st(e, !1);
|
|
2897
2906
|
window.clearTimeout(It), window.clearTimeout(yt), kn(), P == null || P.destroy(), P = null;
|
|
2898
2907
|
}), ee(
|
|
2899
2908
|
() => o.modelValue,
|
|
2900
|
-
() =>
|
|
2909
|
+
() => Ir()
|
|
2901
2910
|
), ee(
|
|
2902
2911
|
() => o.outputHeight,
|
|
2903
2912
|
() => {
|
|
@@ -2916,7 +2925,7 @@ const Vs = Z(
|
|
|
2916
2925
|
), ee(
|
|
2917
2926
|
() => o.theme,
|
|
2918
2927
|
(e) => {
|
|
2919
|
-
e !==
|
|
2928
|
+
e !== j.value && (j.value = e, P == null || P.dispatch({
|
|
2920
2929
|
effects: Ht.reconfigure(Nt(ut(e)))
|
|
2921
2930
|
}));
|
|
2922
2931
|
}
|
|
@@ -2937,8 +2946,8 @@ const Vs = Z(
|
|
|
2937
2946
|
), ee(
|
|
2938
2947
|
() => o.filesEndpoint,
|
|
2939
2948
|
() => {
|
|
2940
|
-
if (!
|
|
2941
|
-
xe.value = !1, tt.value = [],
|
|
2949
|
+
if (!Me.value) {
|
|
2950
|
+
xe.value = !1, tt.value = [], je.value = "";
|
|
2942
2951
|
return;
|
|
2943
2952
|
}
|
|
2944
2953
|
xe.value && Ye();
|
|
@@ -2963,19 +2972,23 @@ const Vs = Z(
|
|
|
2963
2972
|
}), ee(
|
|
2964
2973
|
() => G.value.length,
|
|
2965
2974
|
async () => {
|
|
2966
|
-
await
|
|
2975
|
+
await Gn();
|
|
2967
2976
|
const e = R.value;
|
|
2968
2977
|
e && (e.scrollTop = e.scrollHeight);
|
|
2969
2978
|
}
|
|
2970
|
-
), ee([F, qe], () =>
|
|
2979
|
+
), ee([F, qe], () => Rr(), { deep: !0 });
|
|
2971
2980
|
function Tn() {
|
|
2972
|
-
|
|
2981
|
+
const e = Ce();
|
|
2982
|
+
i("submit", e, { ...He(w.value), code: e });
|
|
2973
2983
|
}
|
|
2974
2984
|
function Fn() {
|
|
2985
|
+
Nn();
|
|
2986
|
+
}
|
|
2987
|
+
function Ln() {
|
|
2975
2988
|
var t;
|
|
2976
2989
|
const e = w.value.id;
|
|
2977
2990
|
if (Re.value) {
|
|
2978
|
-
at(), !o.sqlExecutor && v.value.mode === "sqlite" &&
|
|
2991
|
+
at(), !o.sqlExecutor && v.value.mode === "sqlite" && V.interrupt(), g("已取消连接测试");
|
|
2979
2992
|
return;
|
|
2980
2993
|
}
|
|
2981
2994
|
if ((t = N.get(e)) != null && t.busy) {
|
|
@@ -2983,58 +2996,58 @@ const Vs = Z(
|
|
|
2983
2996
|
return;
|
|
2984
2997
|
}
|
|
2985
2998
|
if (Ee.value && k.value === e) {
|
|
2986
|
-
|
|
2999
|
+
$n();
|
|
2987
3000
|
return;
|
|
2988
3001
|
}
|
|
2989
|
-
I.value === "running" && k.value === e &&
|
|
3002
|
+
I.value === "running" && k.value === e && Rn();
|
|
2990
3003
|
}
|
|
2991
|
-
function
|
|
3004
|
+
function $n(e = !0) {
|
|
2992
3005
|
const t = k.value;
|
|
2993
|
-
rt += 1, Ee.value = !1, k.value = null, de == null || de.abort(), de = null, !o.sqlExecutor && v.value.mode === "sqlite" &&
|
|
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);
|
|
2994
3007
|
}
|
|
2995
|
-
function
|
|
3008
|
+
function Rn(e = !0) {
|
|
2996
3009
|
const t = k.value;
|
|
2997
|
-
We += 1, k.value = null,
|
|
3010
|
+
We += 1, k.value = null, V.interrupt(), e && g("执行已中断", t ?? void 0);
|
|
2998
3011
|
}
|
|
2999
|
-
function
|
|
3012
|
+
function _n() {
|
|
3000
3013
|
fe().lines = [], fe().sqlResults = [];
|
|
3001
3014
|
}
|
|
3002
|
-
function
|
|
3015
|
+
function In() {
|
|
3003
3016
|
var e;
|
|
3004
3017
|
return ((e = E.value) == null ? void 0 : e.getBoundingClientRect().height) ?? 180;
|
|
3005
3018
|
}
|
|
3006
|
-
function
|
|
3019
|
+
function sa() {
|
|
3007
3020
|
var t;
|
|
3008
3021
|
const e = ((t = f.value) == null ? void 0 : t.clientHeight) ?? 0;
|
|
3009
|
-
return Math.max(
|
|
3022
|
+
return Math.max(mr, e ? e - 180 : 600);
|
|
3010
3023
|
}
|
|
3011
3024
|
function Kt(e) {
|
|
3012
|
-
x.value = Math.round(Math.max(
|
|
3025
|
+
x.value = Math.round(Math.max(mr, Math.min(e, sa())));
|
|
3013
3026
|
}
|
|
3014
|
-
function
|
|
3015
|
-
e.button === 0 && (e.preventDefault(), $.value = !0, hn = e.clientY, At =
|
|
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));
|
|
3016
3029
|
}
|
|
3017
|
-
function
|
|
3030
|
+
function Hn(e) {
|
|
3018
3031
|
$.value && Kt(At + (hn - e.clientY));
|
|
3019
3032
|
}
|
|
3020
3033
|
function ot() {
|
|
3021
|
-
$.value && ($.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove",
|
|
3034
|
+
$.value && ($.value = !1, document.body.style.cursor = "", document.body.style.userSelect = "", window.removeEventListener("pointermove", Hn), window.removeEventListener("pointerup", ot), window.removeEventListener("pointercancel", ot));
|
|
3022
3035
|
}
|
|
3023
|
-
function
|
|
3036
|
+
function ia() {
|
|
3024
3037
|
x.value = null;
|
|
3025
3038
|
}
|
|
3026
|
-
function
|
|
3039
|
+
function la(e) {
|
|
3027
3040
|
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
3028
3041
|
e.preventDefault();
|
|
3029
|
-
const t = x.value ??
|
|
3042
|
+
const t = x.value ?? In();
|
|
3030
3043
|
Kt(t + (e.key === "ArrowUp" ? 16 : -16));
|
|
3031
3044
|
}
|
|
3032
3045
|
function Jt() {
|
|
3033
3046
|
if (o.readOnly) return;
|
|
3034
|
-
const e = w.value.language, t =
|
|
3035
|
-
F.value.push(t),
|
|
3047
|
+
const e = w.value.language, t = Je(wn(e), e, "");
|
|
3048
|
+
F.value.push(t), Be(t.id), i("newFile", He(t));
|
|
3036
3049
|
}
|
|
3037
|
-
function
|
|
3050
|
+
function Be(e) {
|
|
3038
3051
|
if (e === qe.value) {
|
|
3039
3052
|
xt();
|
|
3040
3053
|
return;
|
|
@@ -3042,19 +3055,19 @@ const Vs = Z(
|
|
|
3042
3055
|
const t = F.value.find((r) => r.id === e);
|
|
3043
3056
|
t && (qe.value = e, Zt(t));
|
|
3044
3057
|
}
|
|
3045
|
-
function
|
|
3046
|
-
st(e, !1), Ee.value && 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);
|
|
3047
3060
|
}
|
|
3048
|
-
function
|
|
3061
|
+
function Bn(e) {
|
|
3049
3062
|
if (o.readOnly) return;
|
|
3050
3063
|
const t = F.value.findIndex((c) => c.id === e);
|
|
3051
3064
|
if (t === -1) return;
|
|
3052
|
-
|
|
3065
|
+
ua(e);
|
|
3053
3066
|
const r = F.value.splice(t, 1)[0];
|
|
3054
3067
|
if (!r) return;
|
|
3055
|
-
if (q.delete(e), i("fileClose",
|
|
3056
|
-
const c =
|
|
3057
|
-
F.value.push(c), qe.value = c.id, Zt(c), i("newFile",
|
|
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));
|
|
3058
3071
|
return;
|
|
3059
3072
|
}
|
|
3060
3073
|
if (e !== qe.value) return;
|
|
@@ -3062,30 +3075,30 @@ const Vs = Z(
|
|
|
3062
3075
|
u && (qe.value = u.id, Zt(u));
|
|
3063
3076
|
}
|
|
3064
3077
|
function Zt(e) {
|
|
3065
|
-
|
|
3078
|
+
Ne(void 0), kt(e.code), P == null || P.dispatch({
|
|
3066
3079
|
effects: [
|
|
3067
3080
|
Bt.reconfigure(en(e.language)),
|
|
3068
3081
|
Ut.reconfigure(zt(e.language))
|
|
3069
3082
|
]
|
|
3070
|
-
}), 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();
|
|
3071
3084
|
}
|
|
3072
|
-
function
|
|
3073
|
-
o.readOnly || (
|
|
3085
|
+
function Un() {
|
|
3086
|
+
o.readOnly || (Ne(void 0), kt(""), xt());
|
|
3074
3087
|
}
|
|
3075
|
-
async function
|
|
3088
|
+
async function An() {
|
|
3076
3089
|
var r;
|
|
3077
|
-
const e =
|
|
3090
|
+
const e = Ce();
|
|
3078
3091
|
let t = !1;
|
|
3079
3092
|
try {
|
|
3080
3093
|
(r = navigator.clipboard) != null && r.writeText && (await navigator.clipboard.writeText(e), t = !0);
|
|
3081
3094
|
} catch {
|
|
3082
3095
|
t = !1;
|
|
3083
3096
|
}
|
|
3084
|
-
return t || (t =
|
|
3097
|
+
return t || (t = ca(e)), t ? (Se.value = !0, window.clearTimeout(It), It = window.setTimeout(() => {
|
|
3085
3098
|
Se.value = !1;
|
|
3086
3099
|
}, 1600), i("copy", e), !0) : (g("复制失败,请手动选择代码复制"), !1);
|
|
3087
3100
|
}
|
|
3088
|
-
function
|
|
3101
|
+
function ca(e) {
|
|
3089
3102
|
const t = document.createElement("textarea");
|
|
3090
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);
|
|
3091
3104
|
let r = !1;
|
|
@@ -3096,23 +3109,23 @@ const Vs = Z(
|
|
|
3096
3109
|
}
|
|
3097
3110
|
return t.remove(), r;
|
|
3098
3111
|
}
|
|
3099
|
-
function
|
|
3112
|
+
function Dn() {
|
|
3100
3113
|
const e = w.value, t = Vt(e.name, e.language);
|
|
3101
3114
|
Ie.value = t;
|
|
3102
|
-
const r = new Blob([
|
|
3115
|
+
const r = new Blob([Ce()], {
|
|
3103
3116
|
type: e.language === "python" ? "text/x-python;charset=utf-8" : "text/plain;charset=utf-8"
|
|
3104
3117
|
}), u = URL.createObjectURL(r), c = document.createElement("a");
|
|
3105
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;
|
|
3106
3119
|
}
|
|
3107
|
-
function
|
|
3108
|
-
|
|
3120
|
+
function da() {
|
|
3121
|
+
ze.value = !ze.value, ze.value && (xe.value = !1, zn());
|
|
3109
3122
|
}
|
|
3110
|
-
async function
|
|
3123
|
+
async function zn() {
|
|
3111
3124
|
var e;
|
|
3112
3125
|
if (!Xe.value) {
|
|
3113
3126
|
Xe.value = !0;
|
|
3114
3127
|
try {
|
|
3115
|
-
const t = await
|
|
3128
|
+
const t = await V.listFiles(".");
|
|
3116
3129
|
if (!t.ok) {
|
|
3117
3130
|
et.value = [], g(`读取虚拟文件失败:${((e = t.error) == null ? void 0 : e.message) ?? "未知错误"}`);
|
|
3118
3131
|
return;
|
|
@@ -3125,7 +3138,7 @@ const Vs = Z(
|
|
|
3125
3138
|
}
|
|
3126
3139
|
}
|
|
3127
3140
|
}
|
|
3128
|
-
function
|
|
3141
|
+
function pa(e) {
|
|
3129
3142
|
switch (e.slice(e.lastIndexOf(".") + 1).toLowerCase()) {
|
|
3130
3143
|
case "csv":
|
|
3131
3144
|
return "text/csv";
|
|
@@ -3145,47 +3158,47 @@ const Vs = Z(
|
|
|
3145
3158
|
function Gt(e) {
|
|
3146
3159
|
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
3147
3160
|
}
|
|
3148
|
-
async function
|
|
3161
|
+
async function jn(e) {
|
|
3149
3162
|
var t;
|
|
3150
3163
|
try {
|
|
3151
|
-
const r = await
|
|
3164
|
+
const r = await V.readFile(e);
|
|
3152
3165
|
if (!r.ok || r.content === void 0)
|
|
3153
3166
|
return g(`下载失败:${e}(${((t = r.error) == null ? void 0 : t.message) ?? "未知错误"})`), null;
|
|
3154
3167
|
const u = e.slice(e.lastIndexOf("/") + 1) || "download.txt", c = new Blob([r.content], {
|
|
3155
|
-
type: `${
|
|
3168
|
+
type: `${pa(u)};charset=utf-8`
|
|
3156
3169
|
}), h = URL.createObjectURL(c), S = document.createElement("a");
|
|
3157
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;
|
|
3158
3171
|
} catch (r) {
|
|
3159
3172
|
return g(`下载失败:${r instanceof Error ? r.message : String(r)}`), null;
|
|
3160
3173
|
}
|
|
3161
3174
|
}
|
|
3162
|
-
function
|
|
3163
|
-
return
|
|
3175
|
+
function fa(e, t) {
|
|
3176
|
+
return V.writeFile(e, t);
|
|
3164
3177
|
}
|
|
3165
|
-
function
|
|
3166
|
-
return
|
|
3178
|
+
function va(e) {
|
|
3179
|
+
return V.readFile(e);
|
|
3167
3180
|
}
|
|
3168
|
-
function
|
|
3169
|
-
return
|
|
3181
|
+
function ma(e = ".") {
|
|
3182
|
+
return V.listFiles(e);
|
|
3170
3183
|
}
|
|
3171
3184
|
function St(e) {
|
|
3172
3185
|
return e instanceof Error ? e.message : String(e);
|
|
3173
3186
|
}
|
|
3174
|
-
function
|
|
3187
|
+
function ya(e) {
|
|
3175
3188
|
if (!e) return "";
|
|
3176
3189
|
const t = new Date(e);
|
|
3177
3190
|
return Number.isNaN(t.getTime()) ? e : `更新时间:${t.toLocaleString()}`;
|
|
3178
3191
|
}
|
|
3179
|
-
function
|
|
3180
|
-
xe.value = !xe.value, xe.value && (
|
|
3192
|
+
function ha() {
|
|
3193
|
+
xe.value = !xe.value, xe.value && (ze.value = !1, Ye());
|
|
3181
3194
|
}
|
|
3182
3195
|
async function Ye() {
|
|
3183
|
-
if (!
|
|
3196
|
+
if (!Me.value) return;
|
|
3184
3197
|
oe == null || oe.abort();
|
|
3185
3198
|
const e = new AbortController();
|
|
3186
|
-
oe = e, ft.value = !0,
|
|
3199
|
+
oe = e, ft.value = !0, je.value = "";
|
|
3187
3200
|
try {
|
|
3188
|
-
const t = await
|
|
3201
|
+
const t = await Ms(o.filesEndpoint, {
|
|
3189
3202
|
headers: o.filesHeaders,
|
|
3190
3203
|
signal: e.signal
|
|
3191
3204
|
});
|
|
@@ -3193,21 +3206,21 @@ const Vs = Z(
|
|
|
3193
3206
|
tt.value = t;
|
|
3194
3207
|
} catch (t) {
|
|
3195
3208
|
if (oe !== e) return;
|
|
3196
|
-
tt.value = [],
|
|
3209
|
+
tt.value = [], je.value = St(t);
|
|
3197
3210
|
} finally {
|
|
3198
3211
|
oe === e && (oe = null, ft.value = !1);
|
|
3199
3212
|
}
|
|
3200
3213
|
}
|
|
3201
|
-
async function
|
|
3202
|
-
if (!
|
|
3214
|
+
async function Vn() {
|
|
3215
|
+
if (!Me.value)
|
|
3203
3216
|
return g("未配置文件服务端点(filesEndpoint)"), null;
|
|
3204
3217
|
if (W.value) return null;
|
|
3205
3218
|
const e = w.value, t = Vt(e.name, e.language);
|
|
3206
3219
|
t !== e.name && (Ie.value = t), W.value = !0;
|
|
3207
3220
|
try {
|
|
3208
|
-
const r = await
|
|
3221
|
+
const r = await Ns(
|
|
3209
3222
|
o.filesEndpoint,
|
|
3210
|
-
{ name: t, content:
|
|
3223
|
+
{ name: t, content: Ce() },
|
|
3211
3224
|
{ headers: o.filesHeaders }
|
|
3212
3225
|
);
|
|
3213
3226
|
return g(`已保存到服务端:${r.name}(${Gt(r.size)})`), xe.value && await Ye(), r;
|
|
@@ -3217,25 +3230,25 @@ const Vs = Z(
|
|
|
3217
3230
|
W.value = !1;
|
|
3218
3231
|
}
|
|
3219
3232
|
}
|
|
3220
|
-
async function
|
|
3221
|
-
if (!
|
|
3233
|
+
async function ga(e) {
|
|
3234
|
+
if (!Me.value || W.value) return !1;
|
|
3222
3235
|
W.value = !0;
|
|
3223
3236
|
try {
|
|
3224
|
-
const t = await
|
|
3237
|
+
const t = await Ts(o.filesEndpoint, e.id, {
|
|
3225
3238
|
headers: o.filesHeaders
|
|
3226
|
-
}), r =
|
|
3227
|
-
return F.value.push(u),
|
|
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;
|
|
3228
3241
|
} catch (t) {
|
|
3229
3242
|
return g(`打开服务端文件失败:${St(t)}`), !1;
|
|
3230
3243
|
} finally {
|
|
3231
3244
|
W.value = !1;
|
|
3232
3245
|
}
|
|
3233
3246
|
}
|
|
3234
|
-
async function
|
|
3235
|
-
if (!(!
|
|
3247
|
+
async function ba(e) {
|
|
3248
|
+
if (!(!Me.value || W.value) && !(typeof window < "u" && !window.confirm(`确定删除服务端文件“${e.name}”?`))) {
|
|
3236
3249
|
W.value = !0;
|
|
3237
3250
|
try {
|
|
3238
|
-
await
|
|
3251
|
+
await Fs(o.filesEndpoint, e.id, { headers: o.filesHeaders }), g(`已删除服务端文件:${e.name}`), await Ye();
|
|
3239
3252
|
} catch (t) {
|
|
3240
3253
|
g(`删除服务端文件失败:${St(t)}`);
|
|
3241
3254
|
} finally {
|
|
@@ -3243,11 +3256,11 @@ const Vs = Z(
|
|
|
3243
3256
|
}
|
|
3244
3257
|
}
|
|
3245
3258
|
}
|
|
3246
|
-
function
|
|
3259
|
+
function Qn() {
|
|
3247
3260
|
var e;
|
|
3248
3261
|
(e = T.value) == null || e.click();
|
|
3249
3262
|
}
|
|
3250
|
-
async function
|
|
3263
|
+
async function ka(e) {
|
|
3251
3264
|
var u;
|
|
3252
3265
|
const t = e.target, r = (u = t.files) == null ? void 0 : u[0];
|
|
3253
3266
|
if (t.value = "", !!r) {
|
|
@@ -3256,37 +3269,37 @@ const Vs = Z(
|
|
|
3256
3269
|
return;
|
|
3257
3270
|
}
|
|
3258
3271
|
try {
|
|
3259
|
-
const c = await r.text(), h =
|
|
3260
|
-
F.value.push(S),
|
|
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 });
|
|
3261
3274
|
} catch (c) {
|
|
3262
3275
|
const h = c instanceof Error ? c.message : String(c);
|
|
3263
3276
|
g(`读取文件失败:${h}`);
|
|
3264
3277
|
}
|
|
3265
3278
|
}
|
|
3266
3279
|
}
|
|
3267
|
-
function
|
|
3280
|
+
function wa() {
|
|
3268
3281
|
Ie.value = Vt(Ie.value, w.value.language);
|
|
3269
3282
|
}
|
|
3270
|
-
function
|
|
3283
|
+
function Sa(e) {
|
|
3271
3284
|
e.key === "Enter" && (e.preventDefault(), e.target.blur());
|
|
3272
3285
|
}
|
|
3273
|
-
function
|
|
3286
|
+
function xa(e) {
|
|
3274
3287
|
jt(e.target.value);
|
|
3275
3288
|
}
|
|
3276
|
-
function
|
|
3289
|
+
function Ea(e) {
|
|
3277
3290
|
const t = e.target.value;
|
|
3278
|
-
t !==
|
|
3291
|
+
t !== j.value && (j.value = t, P == null || P.dispatch({
|
|
3279
3292
|
effects: Ht.reconfigure(Nt(ut(t)))
|
|
3280
3293
|
}), i("update:theme", t));
|
|
3281
3294
|
}
|
|
3282
|
-
async function
|
|
3295
|
+
async function Kn(e) {
|
|
3283
3296
|
var t, r;
|
|
3284
|
-
await
|
|
3297
|
+
await Gn(), (r = (t = M.value) == null ? void 0 : t.querySelector(`[data-file-id="${e}"]`)) == null || r.focus();
|
|
3285
3298
|
}
|
|
3286
|
-
function
|
|
3299
|
+
function qa(e, t) {
|
|
3287
3300
|
if (e.target !== e.currentTarget) return;
|
|
3288
3301
|
if (e.key === "Enter" || e.key === " ") {
|
|
3289
|
-
e.preventDefault(),
|
|
3302
|
+
e.preventDefault(), Be(t.id), Kn(t.id);
|
|
3290
3303
|
return;
|
|
3291
3304
|
}
|
|
3292
3305
|
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
@@ -3294,17 +3307,17 @@ const Vs = Z(
|
|
|
3294
3307
|
const r = F.value.findIndex((h) => h.id === t.id);
|
|
3295
3308
|
if (r < 0) return;
|
|
3296
3309
|
const u = e.key === "ArrowLeft" ? -1 : 1, c = F.value[(r + u + F.value.length) % F.value.length];
|
|
3297
|
-
c && (
|
|
3310
|
+
c && (Be(c.id), Kn(c.id));
|
|
3298
3311
|
}
|
|
3299
3312
|
function xt() {
|
|
3300
3313
|
P == null || P.focus();
|
|
3301
3314
|
}
|
|
3302
|
-
async function
|
|
3315
|
+
async function Ca(e) {
|
|
3303
3316
|
var r;
|
|
3304
3317
|
g(`正在安装:${e.join(", ")}`);
|
|
3305
3318
|
let t;
|
|
3306
3319
|
try {
|
|
3307
|
-
t = await
|
|
3320
|
+
t = await V.loadPackages(e, {
|
|
3308
3321
|
onOutput: (u, c) => ye(u, c)
|
|
3309
3322
|
});
|
|
3310
3323
|
} catch (u) {
|
|
@@ -3313,79 +3326,80 @@ const Vs = Z(
|
|
|
3313
3326
|
}
|
|
3314
3327
|
return g(t.ok ? "安装完成" : `安装失败:${((r = t.error) == null ? void 0 : r.message) ?? "未知错误"}`), t;
|
|
3315
3328
|
}
|
|
3316
|
-
function Ca() {
|
|
3317
|
-
return j.checkSyntax(Ne());
|
|
3318
|
-
}
|
|
3319
3329
|
function Pa() {
|
|
3320
|
-
return
|
|
3330
|
+
return V.checkSyntax(Ce());
|
|
3321
3331
|
}
|
|
3322
3332
|
function Oa() {
|
|
3323
|
-
return
|
|
3333
|
+
return D(v.value);
|
|
3324
3334
|
}
|
|
3325
3335
|
function Ma() {
|
|
3326
|
-
return
|
|
3336
|
+
return P;
|
|
3327
3337
|
}
|
|
3328
3338
|
function Na() {
|
|
3329
|
-
return
|
|
3339
|
+
return F.value.map(He);
|
|
3340
|
+
}
|
|
3341
|
+
function Ta() {
|
|
3342
|
+
return He(w.value);
|
|
3330
3343
|
}
|
|
3331
3344
|
return n({
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3345
|
+
submit: Tn,
|
|
3346
|
+
run: Fn,
|
|
3347
|
+
stop: Ln,
|
|
3348
|
+
clearOutput: _n,
|
|
3349
|
+
clearCode: Un,
|
|
3336
3350
|
newFile: Jt,
|
|
3337
|
-
switchFile:
|
|
3338
|
-
closeFile:
|
|
3339
|
-
copyCode:
|
|
3340
|
-
download:
|
|
3341
|
-
openFile:
|
|
3351
|
+
switchFile: Be,
|
|
3352
|
+
closeFile: Bn,
|
|
3353
|
+
copyCode: An,
|
|
3354
|
+
download: Dn,
|
|
3355
|
+
openFile: Qn,
|
|
3342
3356
|
focus: xt,
|
|
3343
|
-
install:
|
|
3344
|
-
checkSyntax:
|
|
3345
|
-
executeSql:
|
|
3346
|
-
getSqlConfig:
|
|
3347
|
-
openSqlConfig:
|
|
3357
|
+
install: Ca,
|
|
3358
|
+
checkSyntax: Pa,
|
|
3359
|
+
executeSql: Xr,
|
|
3360
|
+
getSqlConfig: Oa,
|
|
3361
|
+
openSqlConfig: Ur,
|
|
3348
3362
|
closeSqlConfig: xn,
|
|
3349
|
-
getEditorView:
|
|
3350
|
-
getCode:
|
|
3363
|
+
getEditorView: Ma,
|
|
3364
|
+
getCode: Ce,
|
|
3351
3365
|
setCode: kt,
|
|
3352
|
-
getFiles:
|
|
3353
|
-
getActiveFile:
|
|
3354
|
-
writeFile:
|
|
3355
|
-
readFile:
|
|
3356
|
-
listFiles:
|
|
3357
|
-
downloadFile:
|
|
3358
|
-
saveToServer:
|
|
3366
|
+
getFiles: Na,
|
|
3367
|
+
getActiveFile: Ta,
|
|
3368
|
+
writeFile: fa,
|
|
3369
|
+
readFile: va,
|
|
3370
|
+
listFiles: ma,
|
|
3371
|
+
downloadFile: jn,
|
|
3372
|
+
saveToServer: Vn,
|
|
3359
3373
|
refreshServerFiles: Ye,
|
|
3360
|
-
clearPersistedState:
|
|
3374
|
+
clearPersistedState: _r
|
|
3361
3375
|
}), (e, t) => (p(), m("div", {
|
|
3362
3376
|
ref_key: "rootEl",
|
|
3363
3377
|
ref: f,
|
|
3364
|
-
class: le(["vpe-root",
|
|
3365
|
-
style:
|
|
3378
|
+
class: le(["vpe-root", Cr.value]),
|
|
3379
|
+
style: Wn(qr.value)
|
|
3366
3380
|
}, [
|
|
3367
|
-
s.showToolbar ? (p(), m("div",
|
|
3368
|
-
l("div",
|
|
3381
|
+
s.showToolbar ? (p(), m("div", ro, [
|
|
3382
|
+
l("div", ao, [
|
|
3369
3383
|
Dt.value ? (p(), m("button", {
|
|
3370
3384
|
key: 1,
|
|
3371
3385
|
class: "vpe-btn vpe-btn--stop",
|
|
3372
3386
|
type: "button",
|
|
3373
3387
|
title: "中断执行",
|
|
3374
|
-
onClick:
|
|
3388
|
+
onClick: Ln
|
|
3375
3389
|
}, [
|
|
3376
|
-
|
|
3390
|
+
z(H(Ks)),
|
|
3377
3391
|
t[19] || (t[19] = l("span", null, "停止", -1))
|
|
3378
3392
|
])) : (p(), m("button", {
|
|
3379
3393
|
key: 0,
|
|
3380
3394
|
class: "vpe-btn vpe-btn--primary",
|
|
3381
3395
|
type: "button",
|
|
3382
|
-
title:
|
|
3383
|
-
disabled:
|
|
3384
|
-
onClick:
|
|
3396
|
+
title: Mr.value,
|
|
3397
|
+
disabled: Nr.value,
|
|
3398
|
+
onClick: Fn
|
|
3385
3399
|
}, [
|
|
3386
|
-
|
|
3400
|
+
z(H(Qs)),
|
|
3387
3401
|
t[18] || (t[18] = l("span", null, "运行", -1))
|
|
3388
|
-
], 8,
|
|
3402
|
+
], 8, so)),
|
|
3389
3403
|
t[28] || (t[28] = l("span", {
|
|
3390
3404
|
class: "vpe-divider",
|
|
3391
3405
|
"aria-hidden": "true"
|
|
@@ -3399,9 +3413,9 @@ const Vs = Z(
|
|
|
3399
3413
|
disabled: s.readOnly,
|
|
3400
3414
|
onClick: Jt
|
|
3401
3415
|
}, [
|
|
3402
|
-
|
|
3416
|
+
z(H(Js)),
|
|
3403
3417
|
t[20] || (t[20] = l("span", null, "新建", -1))
|
|
3404
|
-
], 8,
|
|
3418
|
+
], 8, oo)) : O("", !0),
|
|
3405
3419
|
s.showOpenFile ? (p(), m("button", {
|
|
3406
3420
|
key: 3,
|
|
3407
3421
|
class: "vpe-btn",
|
|
@@ -3409,20 +3423,20 @@ const Vs = Z(
|
|
|
3409
3423
|
title: "打开本地文件",
|
|
3410
3424
|
"aria-label": "打开本地文件",
|
|
3411
3425
|
disabled: s.readOnly,
|
|
3412
|
-
onClick:
|
|
3426
|
+
onClick: Qn
|
|
3413
3427
|
}, [
|
|
3414
|
-
|
|
3428
|
+
z(H(Zs)),
|
|
3415
3429
|
t[21] || (t[21] = l("span", null, "本地文件", -1))
|
|
3416
|
-
], 8,
|
|
3430
|
+
], 8, io)) : O("", !0),
|
|
3417
3431
|
s.showDownload ? (p(), m("button", {
|
|
3418
3432
|
key: 4,
|
|
3419
3433
|
class: "vpe-btn",
|
|
3420
3434
|
type: "button",
|
|
3421
3435
|
title: "下载当前文件",
|
|
3422
3436
|
"aria-label": "下载当前文件",
|
|
3423
|
-
onClick:
|
|
3437
|
+
onClick: Dn
|
|
3424
3438
|
}, [
|
|
3425
|
-
|
|
3439
|
+
z(H(vr)),
|
|
3426
3440
|
t[22] || (t[22] = l("span", null, "下载", -1))
|
|
3427
3441
|
])) : O("", !0),
|
|
3428
3442
|
s.showVirtualFiles ? (p(), m("button", {
|
|
@@ -3431,32 +3445,32 @@ const Vs = Z(
|
|
|
3431
3445
|
type: "button",
|
|
3432
3446
|
title: "虚拟文件(下载 Python 生成的文件)",
|
|
3433
3447
|
"aria-label": "虚拟文件",
|
|
3434
|
-
onClick:
|
|
3448
|
+
onClick: da
|
|
3435
3449
|
}, [
|
|
3436
|
-
|
|
3450
|
+
z(H(fr)),
|
|
3437
3451
|
t[23] || (t[23] = l("span", null, "虚拟文件", -1))
|
|
3438
3452
|
])) : O("", !0),
|
|
3439
|
-
|
|
3453
|
+
Me.value ? (p(), m("button", {
|
|
3440
3454
|
key: 6,
|
|
3441
3455
|
class: "vpe-btn",
|
|
3442
3456
|
type: "button",
|
|
3443
3457
|
title: W.value ? "正在处理服务端文件…" : "保存当前文件到服务端",
|
|
3444
3458
|
"aria-label": "保存到服务端",
|
|
3445
3459
|
disabled: W.value,
|
|
3446
|
-
onClick:
|
|
3460
|
+
onClick: Vn
|
|
3447
3461
|
}, [
|
|
3448
|
-
|
|
3462
|
+
z(H(to)),
|
|
3449
3463
|
t[24] || (t[24] = l("span", null, "保存", -1))
|
|
3450
|
-
], 8,
|
|
3451
|
-
|
|
3464
|
+
], 8, lo)) : O("", !0),
|
|
3465
|
+
Me.value ? (p(), m("button", {
|
|
3452
3466
|
key: 7,
|
|
3453
3467
|
class: "vpe-btn vpe-toolbar-secondary",
|
|
3454
3468
|
type: "button",
|
|
3455
3469
|
title: "查询服务端已保存文件",
|
|
3456
3470
|
"aria-label": "已保存文件",
|
|
3457
|
-
onClick:
|
|
3471
|
+
onClick: ha
|
|
3458
3472
|
}, [
|
|
3459
|
-
|
|
3473
|
+
z(H(no)),
|
|
3460
3474
|
t[25] || (t[25] = l("span", null, "已保存文件", -1))
|
|
3461
3475
|
])) : O("", !0),
|
|
3462
3476
|
s.showSqlConfig && pe.value ? (p(), m("button", {
|
|
@@ -3465,9 +3479,9 @@ const Vs = Z(
|
|
|
3465
3479
|
type: "button",
|
|
3466
3480
|
title: "新建连接",
|
|
3467
3481
|
"aria-label": "新建连接",
|
|
3468
|
-
onClick:
|
|
3482
|
+
onClick: Dr
|
|
3469
3483
|
}, [
|
|
3470
|
-
|
|
3484
|
+
z(H(eo)),
|
|
3471
3485
|
t[26] || (t[26] = l("span", null, "新建连接", -1))
|
|
3472
3486
|
])) : O("", !0),
|
|
3473
3487
|
l("button", {
|
|
@@ -3475,69 +3489,69 @@ const Vs = Z(
|
|
|
3475
3489
|
type: "button",
|
|
3476
3490
|
title: Se.value ? "已复制" : "复制代码",
|
|
3477
3491
|
"aria-label": Se.value ? "已复制" : "复制代码",
|
|
3478
|
-
onClick:
|
|
3492
|
+
onClick: An
|
|
3479
3493
|
}, [
|
|
3480
|
-
Se.value ? (p(),
|
|
3481
|
-
Se.value ? (p(), m("span",
|
|
3482
|
-
], 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),
|
|
3483
3497
|
l("button", {
|
|
3484
3498
|
class: "vpe-btn",
|
|
3485
3499
|
type: "button",
|
|
3486
3500
|
title: "清空当前文件",
|
|
3487
3501
|
"aria-label": "清空当前文件",
|
|
3488
3502
|
disabled: s.readOnly,
|
|
3489
|
-
onClick:
|
|
3503
|
+
onClick: Un
|
|
3490
3504
|
}, [
|
|
3491
|
-
|
|
3505
|
+
z(H(pr)),
|
|
3492
3506
|
t[27] || (t[27] = l("span", null, "清空", -1))
|
|
3493
|
-
], 8,
|
|
3507
|
+
], 8, fo),
|
|
3494
3508
|
t[29] || (t[29] = l("span", {
|
|
3495
3509
|
class: "vpe-divider",
|
|
3496
3510
|
"aria-hidden": "true"
|
|
3497
3511
|
}, null, -1)),
|
|
3498
|
-
l("label",
|
|
3499
|
-
|
|
3500
|
-
|
|
3512
|
+
l("label", vo, [
|
|
3513
|
+
z(H(fr)),
|
|
3514
|
+
Z(l("input", {
|
|
3501
3515
|
"onUpdate:modelValue": t[0] || (t[0] = (r) => Ie.value = r),
|
|
3502
3516
|
class: "vpe-file-input",
|
|
3503
3517
|
type: "text",
|
|
3504
3518
|
spellcheck: "false",
|
|
3505
3519
|
"aria-label": "文件名",
|
|
3506
|
-
onBlur:
|
|
3507
|
-
onKeydown:
|
|
3520
|
+
onBlur: wa,
|
|
3521
|
+
onKeydown: Sa
|
|
3508
3522
|
}, null, 544), [
|
|
3509
3523
|
[ge, Ie.value]
|
|
3510
3524
|
])
|
|
3511
3525
|
]),
|
|
3512
3526
|
l("select", {
|
|
3513
3527
|
class: "vpe-toolbar-select",
|
|
3514
|
-
value:
|
|
3528
|
+
value: j.value,
|
|
3515
3529
|
title: "编辑器主题",
|
|
3516
3530
|
"aria-label": "编辑器主题",
|
|
3517
|
-
onChange:
|
|
3531
|
+
onChange: Ea
|
|
3518
3532
|
}, [
|
|
3519
|
-
(p(!0), m(A, null, te(
|
|
3533
|
+
(p(!0), m(A, null, te(H(ln), (r) => (p(), m("option", {
|
|
3520
3534
|
key: r.value,
|
|
3521
3535
|
value: r.value
|
|
3522
|
-
}, _(r.label), 9,
|
|
3523
|
-
], 40,
|
|
3536
|
+
}, _(r.label), 9, yo))), 128))
|
|
3537
|
+
], 40, mo)
|
|
3524
3538
|
]),
|
|
3525
|
-
l("div",
|
|
3526
|
-
s.showSqlConfig && pe.value && (v.value.mode === "http" || v.value.endpoint) ? (p(), m(
|
|
3527
|
-
|
|
3539
|
+
l("div", ho, [
|
|
3540
|
+
s.showSqlConfig && pe.value && (v.value.mode === "http" || v.value.endpoint) ? (p(), m("div", go, [
|
|
3541
|
+
Z(l("select", {
|
|
3528
3542
|
"onUpdate:modelValue": t[1] || (t[1] = (r) => v.value.connectionId = r),
|
|
3529
3543
|
class: "vpe-select vpe-sql-connection",
|
|
3530
3544
|
title: "切换已保存连接",
|
|
3531
3545
|
"aria-label": "切换已保存连接",
|
|
3532
|
-
disabled:
|
|
3533
|
-
onChange:
|
|
3546
|
+
disabled: Ve.value,
|
|
3547
|
+
onChange: Vr
|
|
3534
3548
|
}, [
|
|
3535
|
-
l("option",
|
|
3536
|
-
(p(!0), m(A, null, te(
|
|
3549
|
+
l("option", ko, _(Ve.value ? "加载中…" : Pe.value.length ? "选择连接" : "暂无已保存连接"), 1),
|
|
3550
|
+
(p(!0), m(A, null, te(Pe.value, (r) => (p(), m("option", {
|
|
3537
3551
|
key: r.id,
|
|
3538
3552
|
value: r.id
|
|
3539
|
-
}, _(r.name), 9,
|
|
3540
|
-
], 40,
|
|
3553
|
+
}, _(r.name), 9, wo))), 128))
|
|
3554
|
+
], 40, bo), [
|
|
3541
3555
|
[Et, v.value.connectionId]
|
|
3542
3556
|
]),
|
|
3543
3557
|
l("button", {
|
|
@@ -3545,31 +3559,31 @@ const Vs = Z(
|
|
|
3545
3559
|
type: "button",
|
|
3546
3560
|
title: "管理连接配置",
|
|
3547
3561
|
"aria-label": "管理连接配置",
|
|
3548
|
-
onClick:
|
|
3562
|
+
onClick: Ar
|
|
3549
3563
|
}, " 管理 ")
|
|
3550
|
-
]
|
|
3551
|
-
l("div",
|
|
3564
|
+
])) : O("", !0),
|
|
3565
|
+
l("div", So, [
|
|
3552
3566
|
l("span", {
|
|
3553
|
-
class: le(["vpe-status", `vpe-status--${
|
|
3567
|
+
class: le(["vpe-status", `vpe-status--${Or.value}`]),
|
|
3554
3568
|
title: bn.value
|
|
3555
3569
|
}, [
|
|
3556
3570
|
t[30] || (t[30] = l("span", {
|
|
3557
3571
|
class: "vpe-status-dot",
|
|
3558
3572
|
"aria-hidden": "true"
|
|
3559
3573
|
}, null, -1)),
|
|
3560
|
-
l("span",
|
|
3561
|
-
], 10,
|
|
3574
|
+
l("span", Eo, _(bn.value), 1)
|
|
3575
|
+
], 10, xo),
|
|
3562
3576
|
bt.value && gn.value ? (p(), m(A, { key: 0 }, [
|
|
3563
3577
|
t[32] || (t[32] = l("span", {
|
|
3564
3578
|
class: "vpe-chips-divider",
|
|
3565
3579
|
"aria-hidden": "true"
|
|
3566
3580
|
}, null, -1)),
|
|
3567
|
-
|
|
3581
|
+
Z(l("select", {
|
|
3568
3582
|
"onUpdate:modelValue": t[2] || (t[2] = (r) => ce.value = r),
|
|
3569
3583
|
class: "vpe-toolbar-select",
|
|
3570
3584
|
title: "Python 运行环境",
|
|
3571
3585
|
"aria-label": "Python 运行环境",
|
|
3572
|
-
onChange:
|
|
3586
|
+
onChange: ea
|
|
3573
3587
|
}, [...t[31] || (t[31] = [
|
|
3574
3588
|
l("option", { value: "browser" }, "浏览器", -1),
|
|
3575
3589
|
l("option", { value: "server" }, "服务端", -1)
|
|
@@ -3587,13 +3601,13 @@ const Vs = Z(
|
|
|
3587
3601
|
title: "编辑器语言",
|
|
3588
3602
|
"aria-label": "编辑器语言",
|
|
3589
3603
|
disabled: s.readOnly,
|
|
3590
|
-
onChange:
|
|
3604
|
+
onChange: xa
|
|
3591
3605
|
}, [
|
|
3592
|
-
(p(!0), m(A, null, te(
|
|
3606
|
+
(p(!0), m(A, null, te(H(Lt), (r) => (p(), m("option", {
|
|
3593
3607
|
key: r.value,
|
|
3594
3608
|
value: r.value
|
|
3595
|
-
}, _(r.label), 9,
|
|
3596
|
-
], 40,
|
|
3609
|
+
}, _(r.label), 9, Co))), 128))
|
|
3610
|
+
], 40, qo)
|
|
3597
3611
|
])
|
|
3598
3612
|
])
|
|
3599
3613
|
])) : O("", !0),
|
|
@@ -3613,25 +3627,25 @@ const Vs = Z(
|
|
|
3613
3627
|
"aria-selected": r.id === w.value.id,
|
|
3614
3628
|
"data-file-id": r.id,
|
|
3615
3629
|
title: r.name,
|
|
3616
|
-
onClick: (u) =>
|
|
3617
|
-
onKeydown: (u) =>
|
|
3630
|
+
onClick: (u) => Be(r.id),
|
|
3631
|
+
onKeydown: (u) => qa(u, r)
|
|
3618
3632
|
}, [
|
|
3619
3633
|
l("span", {
|
|
3620
3634
|
class: le(["vpe-tab-dot", `vpe-tab-dot--${r.language}`]),
|
|
3621
3635
|
"aria-hidden": "true"
|
|
3622
3636
|
}, null, 2),
|
|
3623
|
-
l("span",
|
|
3637
|
+
l("span", Oo, _(r.name), 1),
|
|
3624
3638
|
l("button", {
|
|
3625
3639
|
class: "vpe-tab-close",
|
|
3626
3640
|
type: "button",
|
|
3627
3641
|
title: `关闭 ${r.name}`,
|
|
3628
3642
|
"aria-label": `关闭 ${r.name}`,
|
|
3629
3643
|
disabled: s.readOnly,
|
|
3630
|
-
onClick:
|
|
3644
|
+
onClick: Xn((u) => Bn(r.id), ["stop"])
|
|
3631
3645
|
}, [
|
|
3632
|
-
|
|
3633
|
-
], 8,
|
|
3634
|
-
], 42,
|
|
3646
|
+
z(H(ct))
|
|
3647
|
+
], 8, Mo)
|
|
3648
|
+
], 42, Po))), 128)),
|
|
3635
3649
|
s.showNewFile ? (p(), m("button", {
|
|
3636
3650
|
key: 0,
|
|
3637
3651
|
class: "vpe-tabs-add",
|
|
@@ -3641,8 +3655,8 @@ const Vs = Z(
|
|
|
3641
3655
|
disabled: s.readOnly,
|
|
3642
3656
|
onClick: Jt
|
|
3643
3657
|
}, [
|
|
3644
|
-
|
|
3645
|
-
], 8,
|
|
3658
|
+
z(H(Xs))
|
|
3659
|
+
], 8, No)) : O("", !0)
|
|
3646
3660
|
], 512)) : O("", !0),
|
|
3647
3661
|
l("input", {
|
|
3648
3662
|
ref_key: "fileInputEl",
|
|
@@ -3650,7 +3664,7 @@ const Vs = Z(
|
|
|
3650
3664
|
class: "vpe-file-hidden",
|
|
3651
3665
|
type: "file",
|
|
3652
3666
|
accept: ".py,.pyw,.sql,.js,.mjs,.cjs,.jsx,.ts,.json,.txt,text/x-python,text/plain,application/json",
|
|
3653
|
-
onChange:
|
|
3667
|
+
onChange: ka
|
|
3654
3668
|
}, null, 544),
|
|
3655
3669
|
l("div", {
|
|
3656
3670
|
ref_key: "editorEl",
|
|
@@ -3665,40 +3679,40 @@ const Vs = Z(
|
|
|
3665
3679
|
"aria-label": "调整输出面板高度",
|
|
3666
3680
|
title: "拖动调整输出高度,双击复位",
|
|
3667
3681
|
tabindex: "0",
|
|
3668
|
-
onPointerdown:
|
|
3669
|
-
onDblclick:
|
|
3670
|
-
onKeydown:
|
|
3682
|
+
onPointerdown: oa,
|
|
3683
|
+
onDblclick: ia,
|
|
3684
|
+
onKeydown: la
|
|
3671
3685
|
}, null, 34)) : O("", !0),
|
|
3672
3686
|
s.showOutput ? (p(), m("div", {
|
|
3673
3687
|
key: 3,
|
|
3674
3688
|
ref_key: "outputPanelEl",
|
|
3675
3689
|
ref: E,
|
|
3676
3690
|
class: "vpe-output",
|
|
3677
|
-
style:
|
|
3691
|
+
style: Wn({ height: Pr.value })
|
|
3678
3692
|
}, [
|
|
3679
|
-
l("div",
|
|
3693
|
+
l("div", To, [
|
|
3680
3694
|
t[34] || (t[34] = l("span", null, "输出", -1)),
|
|
3681
3695
|
l("button", {
|
|
3682
3696
|
class: "vpe-btn vpe-btn--sm",
|
|
3683
3697
|
type: "button",
|
|
3684
3698
|
title: "清空输出",
|
|
3685
|
-
onClick:
|
|
3699
|
+
onClick: _n
|
|
3686
3700
|
}, [
|
|
3687
|
-
|
|
3701
|
+
z(H(pr))
|
|
3688
3702
|
])
|
|
3689
3703
|
]),
|
|
3690
|
-
l("div",
|
|
3691
|
-
me.value.length ? (p(), m("div",
|
|
3704
|
+
l("div", Fo, [
|
|
3705
|
+
me.value.length ? (p(), m("div", Lo, [
|
|
3692
3706
|
(p(!0), m(A, null, te(me.value, (r, u) => (p(), m("section", {
|
|
3693
3707
|
key: u,
|
|
3694
3708
|
class: "vpe-sql-result"
|
|
3695
3709
|
}, [
|
|
3696
|
-
l("div",
|
|
3710
|
+
l("div", $o, [
|
|
3697
3711
|
l("span", null, "结果 " + _(u + 1), 1),
|
|
3698
|
-
l("span", null, _(
|
|
3712
|
+
l("span", null, _(Yr(r)), 1)
|
|
3699
3713
|
]),
|
|
3700
|
-
r.columns.length ? (p(), m("div",
|
|
3701
|
-
l("table",
|
|
3714
|
+
r.columns.length ? (p(), m("div", Ro, [
|
|
3715
|
+
l("table", _o, [
|
|
3702
3716
|
l("thead", null, [
|
|
3703
3717
|
l("tr", null, [
|
|
3704
3718
|
(p(!0), m(A, null, te(r.columns, (c, h) => (p(), m("th", { key: h }, _(c), 1))), 128))
|
|
@@ -3709,12 +3723,12 @@ const Vs = Z(
|
|
|
3709
3723
|
(p(!0), m(A, null, te(c, (S, L) => (p(), m("td", {
|
|
3710
3724
|
key: L,
|
|
3711
3725
|
class: le({ "vpe-sql-null": S === null })
|
|
3712
|
-
}, _(
|
|
3726
|
+
}, _(Wr(S)), 3))), 128))
|
|
3713
3727
|
]))), 128))
|
|
3714
3728
|
])
|
|
3715
3729
|
]),
|
|
3716
|
-
r.rows.length ? O("", !0) : (p(), m("div",
|
|
3717
|
-
])) : (p(), m("div",
|
|
3730
|
+
r.rows.length ? O("", !0) : (p(), m("div", Io, "查询无数据"))
|
|
3731
|
+
])) : (p(), m("div", Ho, "影响 " + _(r.affectedRows ?? 0) + " 行", 1))
|
|
3718
3732
|
]))), 128))
|
|
3719
3733
|
])) : O("", !0),
|
|
3720
3734
|
l("pre", {
|
|
@@ -3726,24 +3740,24 @@ const Vs = Z(
|
|
|
3726
3740
|
key: r.id,
|
|
3727
3741
|
class: le(["vpe-line", `vpe-line--${r.stream}`])
|
|
3728
3742
|
}, _(r.text) + `
|
|
3729
|
-
`, 3))), 128)) : (p(), m("span",
|
|
3743
|
+
`, 3))), 128)) : (p(), m("span", Bo, "暂无输出,点击“运行”或按 Ctrl+Enter 执行代码"))
|
|
3730
3744
|
], 512)
|
|
3731
3745
|
]),
|
|
3732
|
-
|
|
3746
|
+
Ge.value && De.value && Dt.value ? (p(), m("div", Uo, [
|
|
3733
3747
|
t[35] || (t[35] = l("span", {
|
|
3734
3748
|
class: "vpe-terminal-prompt",
|
|
3735
3749
|
"aria-hidden": "true"
|
|
3736
3750
|
}, "›", -1)),
|
|
3737
|
-
|
|
3738
|
-
"onUpdate:modelValue": t[3] || (t[3] = (r) =>
|
|
3751
|
+
Z(l("input", {
|
|
3752
|
+
"onUpdate:modelValue": t[3] || (t[3] = (r) => B.value = r),
|
|
3739
3753
|
class: "vpe-terminal-field",
|
|
3740
3754
|
type: "text",
|
|
3741
3755
|
spellcheck: "false",
|
|
3742
3756
|
placeholder: "输入后按 Enter 发送给 input()",
|
|
3743
3757
|
"aria-label": "标准输入",
|
|
3744
|
-
onKeydown:
|
|
3745
|
-
}, null, 40,
|
|
3746
|
-
[ge,
|
|
3758
|
+
onKeydown: Ia(Xn(Mn, ["prevent"]), ["enter"])
|
|
3759
|
+
}, null, 40, Ao), [
|
|
3760
|
+
[ge, B.value]
|
|
3747
3761
|
]),
|
|
3748
3762
|
l("button", {
|
|
3749
3763
|
class: "vpe-btn vpe-btn--sm",
|
|
@@ -3752,10 +3766,22 @@ const Vs = Z(
|
|
|
3752
3766
|
}, " 发送 ")
|
|
3753
3767
|
])) : O("", !0)
|
|
3754
3768
|
], 4)) : O("", !0),
|
|
3755
|
-
|
|
3756
|
-
l("
|
|
3757
|
-
|
|
3758
|
-
|
|
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", {
|
|
3759
3785
|
class: "vpe-spacer",
|
|
3760
3786
|
"aria-hidden": "true"
|
|
3761
3787
|
}, null, -1)),
|
|
@@ -3764,21 +3790,21 @@ const Vs = Z(
|
|
|
3764
3790
|
type: "button",
|
|
3765
3791
|
title: "刷新文件列表",
|
|
3766
3792
|
disabled: Xe.value,
|
|
3767
|
-
onClick:
|
|
3768
|
-
}, " 刷新 ", 8,
|
|
3793
|
+
onClick: zn
|
|
3794
|
+
}, " 刷新 ", 8, Vo),
|
|
3769
3795
|
l("button", {
|
|
3770
3796
|
class: "vpe-btn vpe-btn--sm",
|
|
3771
3797
|
type: "button",
|
|
3772
3798
|
title: "关闭虚拟文件面板",
|
|
3773
3799
|
"aria-label": "关闭虚拟文件面板",
|
|
3774
|
-
onClick: t[4] || (t[4] = (r) =>
|
|
3800
|
+
onClick: t[4] || (t[4] = (r) => ze.value = !1)
|
|
3775
3801
|
}, [
|
|
3776
|
-
|
|
3802
|
+
z(H(ct))
|
|
3777
3803
|
])
|
|
3778
3804
|
]),
|
|
3779
|
-
l("div",
|
|
3780
|
-
Xe.value ? (p(), m("div",
|
|
3781
|
-
et.value.length ? O("", !0) : (p(), m("div",
|
|
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 代码创建文件后再刷新。 ")),
|
|
3782
3808
|
(p(!0), m(A, null, te(et.value, (r) => (p(), m("div", {
|
|
3783
3809
|
key: r.path,
|
|
3784
3810
|
class: le(["vpe-fs-item", { "vpe-fs-item--dir": r.isDirectory }])
|
|
@@ -3786,26 +3812,26 @@ const Vs = Z(
|
|
|
3786
3812
|
l("span", {
|
|
3787
3813
|
class: "vpe-fs-name",
|
|
3788
3814
|
title: r.path
|
|
3789
|
-
}, _(r.path), 9,
|
|
3790
|
-
l("span",
|
|
3815
|
+
}, _(r.path), 9, Zo),
|
|
3816
|
+
l("span", Go, _(r.isDirectory ? "目录" : Gt(r.size)), 1),
|
|
3791
3817
|
r.isDirectory ? O("", !0) : (p(), m("button", {
|
|
3792
3818
|
key: 0,
|
|
3793
3819
|
class: "vpe-btn vpe-btn--sm",
|
|
3794
3820
|
type: "button",
|
|
3795
3821
|
title: `下载 ${r.name}`,
|
|
3796
3822
|
"aria-label": `下载 ${r.name}`,
|
|
3797
|
-
onClick: (u) =>
|
|
3823
|
+
onClick: (u) => jn(r.path)
|
|
3798
3824
|
}, [
|
|
3799
|
-
|
|
3800
|
-
], 8,
|
|
3825
|
+
z(H(vr))
|
|
3826
|
+
], 8, Wo))
|
|
3801
3827
|
], 2))), 128))
|
|
3802
3828
|
], 64))
|
|
3803
3829
|
])
|
|
3804
3830
|
])) : O("", !0),
|
|
3805
|
-
xe.value &&
|
|
3806
|
-
l("div",
|
|
3807
|
-
t[
|
|
3808
|
-
t[
|
|
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", {
|
|
3809
3835
|
class: "vpe-spacer",
|
|
3810
3836
|
"aria-hidden": "true"
|
|
3811
3837
|
}, null, -1)),
|
|
@@ -3815,7 +3841,7 @@ const Vs = Z(
|
|
|
3815
3841
|
title: "刷新文件列表",
|
|
3816
3842
|
disabled: ft.value,
|
|
3817
3843
|
onClick: t[5] || (t[5] = (r) => Ye())
|
|
3818
|
-
}, " 刷新 ", 8,
|
|
3844
|
+
}, " 刷新 ", 8, ei),
|
|
3819
3845
|
l("button", {
|
|
3820
3846
|
class: "vpe-btn vpe-btn--sm",
|
|
3821
3847
|
type: "button",
|
|
@@ -3823,12 +3849,12 @@ const Vs = Z(
|
|
|
3823
3849
|
"aria-label": "关闭服务端文件面板",
|
|
3824
3850
|
onClick: t[6] || (t[6] = (r) => xe.value = !1)
|
|
3825
3851
|
}, [
|
|
3826
|
-
|
|
3852
|
+
z(H(ct))
|
|
3827
3853
|
])
|
|
3828
3854
|
]),
|
|
3829
|
-
l("div",
|
|
3830
|
-
ft.value ? (p(), m("div",
|
|
3831
|
-
!tt.value.length && !
|
|
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),
|
|
3832
3858
|
(p(!0), m(A, null, te(tt.value, (r) => (p(), m("div", {
|
|
3833
3859
|
key: r.id,
|
|
3834
3860
|
class: "vpe-fs-item"
|
|
@@ -3836,34 +3862,34 @@ const Vs = Z(
|
|
|
3836
3862
|
l("span", {
|
|
3837
3863
|
class: "vpe-fs-name",
|
|
3838
3864
|
title: r.name
|
|
3839
|
-
}, _(r.name), 9,
|
|
3865
|
+
}, _(r.name), 9, ai),
|
|
3840
3866
|
l("span", {
|
|
3841
3867
|
class: "vpe-fs-size",
|
|
3842
|
-
title:
|
|
3843
|
-
}, _(Gt(r.size)), 9,
|
|
3868
|
+
title: ya(r.updatedAt)
|
|
3869
|
+
}, _(Gt(r.size)), 9, si),
|
|
3844
3870
|
l("button", {
|
|
3845
3871
|
class: "vpe-btn vpe-btn--sm",
|
|
3846
3872
|
type: "button",
|
|
3847
3873
|
title: `打开 ${r.name}`,
|
|
3848
3874
|
disabled: W.value,
|
|
3849
|
-
onClick: (u) =>
|
|
3850
|
-
}, " 打开 ", 8,
|
|
3875
|
+
onClick: (u) => ga(r)
|
|
3876
|
+
}, " 打开 ", 8, oi),
|
|
3851
3877
|
l("button", {
|
|
3852
3878
|
class: "vpe-btn vpe-btn--sm",
|
|
3853
3879
|
type: "button",
|
|
3854
3880
|
title: `删除 ${r.name}`,
|
|
3855
3881
|
disabled: W.value,
|
|
3856
|
-
onClick: (u) =>
|
|
3857
|
-
}, " 删除 ", 8,
|
|
3882
|
+
onClick: (u) => ba(r)
|
|
3883
|
+
}, " 删除 ", 8, ii)
|
|
3858
3884
|
]))), 128)),
|
|
3859
|
-
|
|
3885
|
+
je.value ? (p(), m("p", li, _(je.value), 1)) : O("", !0)
|
|
3860
3886
|
], 64))
|
|
3861
3887
|
])
|
|
3862
3888
|
])) : O("", !0),
|
|
3863
|
-
$e.value && pe.value ? (p(), m("div",
|
|
3864
|
-
l("div",
|
|
3865
|
-
l("span",
|
|
3866
|
-
t[
|
|
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", {
|
|
3867
3893
|
class: "vpe-spacer",
|
|
3868
3894
|
"aria-hidden": "true"
|
|
3869
3895
|
}, null, -1)),
|
|
@@ -3874,17 +3900,17 @@ const Vs = Z(
|
|
|
3874
3900
|
"aria-label": "关闭 SQL 连接配置",
|
|
3875
3901
|
onClick: xn
|
|
3876
3902
|
}, [
|
|
3877
|
-
|
|
3903
|
+
z(H(ct))
|
|
3878
3904
|
])
|
|
3879
3905
|
]),
|
|
3880
|
-
l("div",
|
|
3881
|
-
l("label",
|
|
3882
|
-
t[
|
|
3883
|
-
|
|
3906
|
+
l("div", pi, [
|
|
3907
|
+
l("label", fi, [
|
|
3908
|
+
t[43] || (t[43] = l("span", { class: "vpe-sql-label" }, "执行方式", -1)),
|
|
3909
|
+
Z(l("select", {
|
|
3884
3910
|
"onUpdate:modelValue": t[7] || (t[7] = (r) => v.value.mode = r),
|
|
3885
3911
|
class: "vpe-sql-input",
|
|
3886
|
-
onChange:
|
|
3887
|
-
}, [...t[
|
|
3912
|
+
onChange: zr
|
|
3913
|
+
}, [...t[42] || (t[42] = [
|
|
3888
3914
|
l("option", { value: "sqlite" }, "浏览器内 SQLite(无需服务端)", -1),
|
|
3889
3915
|
l("option", { value: "http" }, "HTTP 服务(后端网关)", -1)
|
|
3890
3916
|
])], 544), [
|
|
@@ -3892,9 +3918,9 @@ const Vs = Z(
|
|
|
3892
3918
|
])
|
|
3893
3919
|
]),
|
|
3894
3920
|
v.value.mode === "sqlite" ? (p(), m(A, { key: 0 }, [
|
|
3895
|
-
l("label",
|
|
3896
|
-
t[
|
|
3897
|
-
|
|
3921
|
+
l("label", vi, [
|
|
3922
|
+
t[44] || (t[44] = l("span", { class: "vpe-sql-label" }, "数据库文件", -1)),
|
|
3923
|
+
Z(l("input", {
|
|
3898
3924
|
"onUpdate:modelValue": t[8] || (t[8] = (r) => v.value.connection.database = r),
|
|
3899
3925
|
class: "vpe-sql-input",
|
|
3900
3926
|
type: "text",
|
|
@@ -3905,11 +3931,11 @@ const Vs = Z(
|
|
|
3905
3931
|
[ge, v.value.connection.database]
|
|
3906
3932
|
])
|
|
3907
3933
|
]),
|
|
3908
|
-
t[
|
|
3934
|
+
t[45] || (t[45] = l("p", { class: "vpe-sql-hint" }, " SQLite 在浏览器内运行,数据仅保存在当前页面内存;“停止”或刷新后会丢失。 ", -1))
|
|
3909
3935
|
], 64)) : (p(), m(A, { key: 1 }, [
|
|
3910
|
-
l("label",
|
|
3911
|
-
t[
|
|
3912
|
-
|
|
3936
|
+
l("label", mi, [
|
|
3937
|
+
t[46] || (t[46] = l("span", { class: "vpe-sql-label" }, "连接名称", -1)),
|
|
3938
|
+
Z(l("input", {
|
|
3913
3939
|
"onUpdate:modelValue": t[9] || (t[9] = (r) => ne.value = r),
|
|
3914
3940
|
class: "vpe-sql-input",
|
|
3915
3941
|
type: "text",
|
|
@@ -3919,25 +3945,25 @@ const Vs = Z(
|
|
|
3919
3945
|
[ge, ne.value]
|
|
3920
3946
|
])
|
|
3921
3947
|
]),
|
|
3922
|
-
l("label",
|
|
3923
|
-
t[
|
|
3924
|
-
|
|
3948
|
+
l("label", yi, [
|
|
3949
|
+
t[47] || (t[47] = l("span", { class: "vpe-sql-label" }, "数据库类型", -1)),
|
|
3950
|
+
Z(l("select", {
|
|
3925
3951
|
"onUpdate:modelValue": t[10] || (t[10] = (r) => v.value.connection.dialect = r),
|
|
3926
3952
|
class: "vpe-sql-input",
|
|
3927
|
-
onChange:
|
|
3953
|
+
onChange: jr
|
|
3928
3954
|
}, [
|
|
3929
|
-
(p(!0), m(A, null, te(
|
|
3955
|
+
(p(!0), m(A, null, te(H(dt), (r) => (p(), m("option", {
|
|
3930
3956
|
key: r.value,
|
|
3931
3957
|
value: r.value
|
|
3932
|
-
}, _(r.label), 9,
|
|
3958
|
+
}, _(r.label), 9, hi))), 128))
|
|
3933
3959
|
], 544), [
|
|
3934
3960
|
[Et, v.value.connection.dialect]
|
|
3935
3961
|
])
|
|
3936
3962
|
]),
|
|
3937
|
-
l("div",
|
|
3938
|
-
l("label",
|
|
3939
|
-
t[
|
|
3940
|
-
|
|
3963
|
+
l("div", gi, [
|
|
3964
|
+
l("label", bi, [
|
|
3965
|
+
t[48] || (t[48] = l("span", { class: "vpe-sql-label" }, "主机", -1)),
|
|
3966
|
+
Z(l("input", {
|
|
3941
3967
|
"onUpdate:modelValue": t[11] || (t[11] = (r) => v.value.connection.host = r),
|
|
3942
3968
|
class: "vpe-sql-input",
|
|
3943
3969
|
type: "text",
|
|
@@ -3948,9 +3974,9 @@ const Vs = Z(
|
|
|
3948
3974
|
[ge, v.value.connection.host]
|
|
3949
3975
|
])
|
|
3950
3976
|
]),
|
|
3951
|
-
l("label",
|
|
3952
|
-
t[
|
|
3953
|
-
|
|
3977
|
+
l("label", ki, [
|
|
3978
|
+
t[49] || (t[49] = l("span", { class: "vpe-sql-label" }, "端口", -1)),
|
|
3979
|
+
Z(l("input", {
|
|
3954
3980
|
"onUpdate:modelValue": t[12] || (t[12] = (r) => v.value.connection.port = r),
|
|
3955
3981
|
class: "vpe-sql-input",
|
|
3956
3982
|
type: "number",
|
|
@@ -3968,10 +3994,10 @@ const Vs = Z(
|
|
|
3968
3994
|
])
|
|
3969
3995
|
])
|
|
3970
3996
|
]),
|
|
3971
|
-
l("div",
|
|
3972
|
-
l("label",
|
|
3973
|
-
t[
|
|
3974
|
-
|
|
3997
|
+
l("div", wi, [
|
|
3998
|
+
l("label", Si, [
|
|
3999
|
+
t[50] || (t[50] = l("span", { class: "vpe-sql-label" }, "用户名", -1)),
|
|
4000
|
+
Z(l("input", {
|
|
3975
4001
|
"onUpdate:modelValue": t[13] || (t[13] = (r) => v.value.connection.user = r),
|
|
3976
4002
|
class: "vpe-sql-input",
|
|
3977
4003
|
type: "text",
|
|
@@ -3982,23 +4008,23 @@ const Vs = Z(
|
|
|
3982
4008
|
[ge, v.value.connection.user]
|
|
3983
4009
|
])
|
|
3984
4010
|
]),
|
|
3985
|
-
l("label",
|
|
3986
|
-
t[
|
|
3987
|
-
|
|
4011
|
+
l("label", xi, [
|
|
4012
|
+
t[51] || (t[51] = l("span", { class: "vpe-sql-label" }, "密码", -1)),
|
|
4013
|
+
Z(l("input", {
|
|
3988
4014
|
"onUpdate:modelValue": t[14] || (t[14] = (r) => v.value.connection.password = r),
|
|
3989
4015
|
class: "vpe-sql-input",
|
|
3990
4016
|
type: "password",
|
|
3991
4017
|
autocomplete: "new-password",
|
|
3992
4018
|
placeholder: v.value.connectionId ? "已保存(留空不修改)" : "",
|
|
3993
4019
|
onChange: he
|
|
3994
|
-
}, null, 40,
|
|
4020
|
+
}, null, 40, Ei), [
|
|
3995
4021
|
[ge, v.value.connection.password]
|
|
3996
4022
|
])
|
|
3997
4023
|
])
|
|
3998
4024
|
]),
|
|
3999
|
-
l("label",
|
|
4000
|
-
t[
|
|
4001
|
-
|
|
4025
|
+
l("label", qi, [
|
|
4026
|
+
t[52] || (t[52] = l("span", { class: "vpe-sql-label" }, "数据库名", -1)),
|
|
4027
|
+
Z(l("input", {
|
|
4002
4028
|
"onUpdate:modelValue": t[15] || (t[15] = (r) => v.value.connection.database = r),
|
|
4003
4029
|
class: "vpe-sql-input",
|
|
4004
4030
|
type: "text",
|
|
@@ -4009,9 +4035,9 @@ const Vs = Z(
|
|
|
4009
4035
|
[ge, v.value.connection.database]
|
|
4010
4036
|
])
|
|
4011
4037
|
]),
|
|
4012
|
-
s.sqlEndpointLocked ? O("", !0) : (p(), m("label",
|
|
4013
|
-
t[
|
|
4014
|
-
|
|
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", {
|
|
4015
4041
|
"onUpdate:modelValue": t[16] || (t[16] = (r) => v.value.endpoint = r),
|
|
4016
4042
|
class: "vpe-sql-input",
|
|
4017
4043
|
type: "url",
|
|
@@ -4022,46 +4048,46 @@ const Vs = Z(
|
|
|
4022
4048
|
[ge, v.value.endpoint]
|
|
4023
4049
|
])
|
|
4024
4050
|
])),
|
|
4025
|
-
s.sqlEndpointLocked ? (p(), m("p",
|
|
4026
|
-
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))
|
|
4027
4053
|
], 64)),
|
|
4028
|
-
l("div",
|
|
4054
|
+
l("div", Oi, [
|
|
4029
4055
|
l("button", {
|
|
4030
4056
|
class: "vpe-btn vpe-btn--primary",
|
|
4031
4057
|
type: "button",
|
|
4032
4058
|
disabled: Re.value,
|
|
4033
|
-
onClick:
|
|
4034
|
-
}, _(Re.value ? "测试中…" : "测试连接"), 9,
|
|
4059
|
+
onClick: Gr
|
|
4060
|
+
}, _(Re.value ? "测试中…" : "测试连接"), 9, Mi),
|
|
4035
4061
|
v.value.mode === "http" ? (p(), m("button", {
|
|
4036
4062
|
key: 0,
|
|
4037
4063
|
class: "vpe-btn",
|
|
4038
4064
|
type: "button",
|
|
4039
4065
|
disabled: re.value,
|
|
4040
|
-
onClick:
|
|
4041
|
-
}, " 保存 ", 8,
|
|
4066
|
+
onClick: Kr
|
|
4067
|
+
}, " 保存 ", 8, Ni)) : O("", !0),
|
|
4042
4068
|
v.value.mode === "http" && v.value.connectionId ? (p(), m("button", {
|
|
4043
4069
|
key: 1,
|
|
4044
4070
|
class: "vpe-btn",
|
|
4045
4071
|
type: "button",
|
|
4046
4072
|
disabled: re.value,
|
|
4047
|
-
onClick:
|
|
4048
|
-
}, " 删除 ", 8,
|
|
4073
|
+
onClick: Jr
|
|
4074
|
+
}, " 删除 ", 8, Ti)) : O("", !0),
|
|
4049
4075
|
nt.value ? (p(), m("span", {
|
|
4050
4076
|
key: 2,
|
|
4051
4077
|
class: le(["vpe-sql-test", vt.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
|
|
4052
4078
|
}, _(nt.value), 3)) : O("", !0),
|
|
4053
|
-
v.value.mode === "http" &&
|
|
4079
|
+
v.value.mode === "http" && Oe.value ? (p(), m("span", Fi, _(Oe.value), 1)) : O("", !0),
|
|
4054
4080
|
v.value.mode === "http" && ae.value ? (p(), m("span", {
|
|
4055
4081
|
key: 4,
|
|
4056
|
-
class: le(["vpe-sql-test",
|
|
4082
|
+
class: le(["vpe-sql-test", Qe.value ? "vpe-sql-test--ok" : "vpe-sql-test--err"])
|
|
4057
4083
|
}, _(ae.value), 3)) : O("", !0)
|
|
4058
4084
|
])
|
|
4059
4085
|
])
|
|
4060
4086
|
])) : O("", !0),
|
|
4061
|
-
_e.value && pe.value ? (p(), m("div",
|
|
4062
|
-
l("div",
|
|
4063
|
-
t[
|
|
4064
|
-
t[
|
|
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", {
|
|
4065
4091
|
class: "vpe-spacer",
|
|
4066
4092
|
"aria-hidden": "true"
|
|
4067
4093
|
}, null, -1)),
|
|
@@ -4069,9 +4095,9 @@ const Vs = Z(
|
|
|
4069
4095
|
class: "vpe-btn vpe-btn--sm",
|
|
4070
4096
|
type: "button",
|
|
4071
4097
|
title: "刷新连接列表",
|
|
4072
|
-
disabled:
|
|
4098
|
+
disabled: Ve.value,
|
|
4073
4099
|
onClick: ve
|
|
4074
|
-
}, " 刷新 ", 8,
|
|
4100
|
+
}, " 刷新 ", 8, Ri),
|
|
4075
4101
|
l("button", {
|
|
4076
4102
|
class: "vpe-btn vpe-btn--sm",
|
|
4077
4103
|
type: "button",
|
|
@@ -4079,22 +4105,22 @@ const Vs = Z(
|
|
|
4079
4105
|
"aria-label": "关闭连接管理",
|
|
4080
4106
|
onClick: t[17] || (t[17] = (r) => _e.value = !1)
|
|
4081
4107
|
}, [
|
|
4082
|
-
|
|
4108
|
+
z(H(ct))
|
|
4083
4109
|
])
|
|
4084
4110
|
]),
|
|
4085
|
-
l("div",
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
(p(!0), m(A, null, te(
|
|
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", {
|
|
4089
4115
|
key: r.id,
|
|
4090
4116
|
class: "vpe-sql-manager-item"
|
|
4091
4117
|
}, [
|
|
4092
|
-
l("div",
|
|
4118
|
+
l("div", Bi, [
|
|
4093
4119
|
l("span", {
|
|
4094
4120
|
class: "vpe-sql-manager-name",
|
|
4095
4121
|
title: r.name
|
|
4096
|
-
}, _(r.name), 9,
|
|
4097
|
-
l("span",
|
|
4122
|
+
}, _(r.name), 9, Ui),
|
|
4123
|
+
l("span", Ai, [
|
|
4098
4124
|
Wt(_(r.dialect), 1),
|
|
4099
4125
|
r.database ? (p(), m(A, { key: 0 }, [
|
|
4100
4126
|
Wt(" · " + _(r.database), 1)
|
|
@@ -4108,77 +4134,77 @@ const Vs = Z(
|
|
|
4108
4134
|
class: "vpe-btn vpe-btn--sm",
|
|
4109
4135
|
type: "button",
|
|
4110
4136
|
title: "编辑连接",
|
|
4111
|
-
onClick: (u) =>
|
|
4112
|
-
}, " 编辑 ", 8,
|
|
4137
|
+
onClick: (u) => Qr(r)
|
|
4138
|
+
}, " 编辑 ", 8, Di),
|
|
4113
4139
|
l("button", {
|
|
4114
4140
|
class: "vpe-btn vpe-btn--sm",
|
|
4115
4141
|
type: "button",
|
|
4116
4142
|
title: "删除连接",
|
|
4117
4143
|
disabled: re.value,
|
|
4118
|
-
onClick: (u) =>
|
|
4119
|
-
}, " 删除 ", 8,
|
|
4144
|
+
onClick: (u) => Zr(r)
|
|
4145
|
+
}, " 删除 ", 8, zi)
|
|
4120
4146
|
]))), 128)),
|
|
4121
|
-
|
|
4122
|
-
|
|
4147
|
+
Oe.value ? (p(), m("p", ji, _(Oe.value), 1)) : O("", !0),
|
|
4148
|
+
Ke.value ? (p(), m("p", {
|
|
4123
4149
|
key: 2,
|
|
4124
4150
|
class: le(["vpe-sql-hint", mt.value ? "vpe-sql-hint--ok" : "vpe-sql-hint--error"])
|
|
4125
|
-
}, _(
|
|
4151
|
+
}, _(Ke.value), 3)) : O("", !0)
|
|
4126
4152
|
], 64))
|
|
4127
4153
|
])
|
|
4128
4154
|
])) : O("", !0)
|
|
4129
4155
|
], 6));
|
|
4130
4156
|
}
|
|
4131
4157
|
});
|
|
4132
|
-
function
|
|
4133
|
-
var
|
|
4158
|
+
function ol(s = {}) {
|
|
4159
|
+
var De;
|
|
4134
4160
|
const n = un(s.pyodideUrl ? { pyodideUrl: s.pyodideUrl } : void 0), a = C(n.status), o = C(""), i = C([]);
|
|
4135
4161
|
let f = 0;
|
|
4136
|
-
const b = (
|
|
4137
|
-
i.value.push({ id: ++f, stream:
|
|
4138
|
-
}, E = n.on("status", (
|
|
4139
|
-
a.value =
|
|
4140
|
-
}), R = n.on("initError", (
|
|
4141
|
-
b("system", `[pyodide] 加载失败:${
|
|
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}`);
|
|
4142
4168
|
});
|
|
4143
|
-
|
|
4169
|
+
Ha(() => {
|
|
4144
4170
|
E(), R();
|
|
4145
4171
|
});
|
|
4146
|
-
const M = async (
|
|
4172
|
+
const M = async (B, k = {}) => {
|
|
4147
4173
|
var I;
|
|
4148
4174
|
try {
|
|
4149
|
-
const
|
|
4175
|
+
const j = await n.run(B, {
|
|
4150
4176
|
stdin: k.stdin,
|
|
4151
4177
|
onOutput: (ce, Se) => b(ce, Se)
|
|
4152
4178
|
});
|
|
4153
|
-
return !
|
|
4154
|
-
} catch (
|
|
4179
|
+
return !j.ok && ((I = j.error) != null && I.traceback) && b("stderr", j.error.traceback), j;
|
|
4180
|
+
} catch (j) {
|
|
4155
4181
|
return {
|
|
4156
4182
|
ok: !1,
|
|
4157
4183
|
durationMs: 0,
|
|
4158
|
-
error: { type: "RuntimeError", message:
|
|
4184
|
+
error: { type: "RuntimeError", message: j instanceof Error ? j.message : String(j), traceback: "" }
|
|
4159
4185
|
};
|
|
4160
4186
|
}
|
|
4161
|
-
}, T = async (
|
|
4187
|
+
}, T = async (B, k) => {
|
|
4162
4188
|
try {
|
|
4163
|
-
return await n.writeFile(
|
|
4189
|
+
return await n.writeFile(B, k);
|
|
4164
4190
|
} catch (I) {
|
|
4165
4191
|
return { ok: !1, error: { type: "RuntimeError", message: I instanceof Error ? I.message : String(I), traceback: "" } };
|
|
4166
4192
|
}
|
|
4167
|
-
}, x = async (
|
|
4193
|
+
}, x = async (B) => {
|
|
4168
4194
|
try {
|
|
4169
|
-
return await n.readFile(
|
|
4195
|
+
return await n.readFile(B);
|
|
4170
4196
|
} catch (k) {
|
|
4171
4197
|
return { ok: !1, error: { type: "RuntimeError", message: k instanceof Error ? k.message : String(k), traceback: "" } };
|
|
4172
4198
|
}
|
|
4173
|
-
}, $ = async (
|
|
4199
|
+
}, $ = async (B = ".") => {
|
|
4174
4200
|
try {
|
|
4175
|
-
return await n.listFiles(
|
|
4201
|
+
return await n.listFiles(B);
|
|
4176
4202
|
} catch (k) {
|
|
4177
4203
|
return { ok: !1, error: { type: "RuntimeError", message: k instanceof Error ? k.message : String(k), traceback: "" } };
|
|
4178
4204
|
}
|
|
4179
|
-
}, q = async (
|
|
4205
|
+
}, q = async (B) => {
|
|
4180
4206
|
try {
|
|
4181
|
-
return await n.loadPackages(
|
|
4207
|
+
return await n.loadPackages(B, { onOutput: (k, I) => b(k, I) });
|
|
4182
4208
|
} catch (k) {
|
|
4183
4209
|
return {
|
|
4184
4210
|
ok: !1,
|
|
@@ -4191,23 +4217,23 @@ function nl(s = {}) {
|
|
|
4191
4217
|
const me = async () => {
|
|
4192
4218
|
var I;
|
|
4193
4219
|
if (G) return;
|
|
4194
|
-
const
|
|
4195
|
-
if (!
|
|
4196
|
-
G = !0, b("system", `[pyodide] 正在安装预置包:${
|
|
4197
|
-
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);
|
|
4198
4224
|
b(
|
|
4199
4225
|
"system",
|
|
4200
4226
|
k.ok ? `[pyodide] 预置包安装完成(${(k.durationMs / 1e3).toFixed(1)}s)` : `[pyodide] 预置包安装失败:${((I = k.error) == null ? void 0 : I.message) ?? "未知错误"}`
|
|
4201
4227
|
);
|
|
4202
4228
|
};
|
|
4203
|
-
return (s.preload || (((
|
|
4229
|
+
return (s.preload || (((De = s.preloadPackages) == null ? void 0 : De.length) ?? 0) > 0) && n.waitReady().then(() => me()).catch(() => {
|
|
4204
4230
|
}), {
|
|
4205
4231
|
status: a,
|
|
4206
4232
|
version: o,
|
|
4207
4233
|
outputs: i,
|
|
4208
4234
|
runPython: M,
|
|
4209
4235
|
install: q,
|
|
4210
|
-
checkSyntax: (
|
|
4236
|
+
checkSyntax: (B) => n.checkSyntax(B),
|
|
4211
4237
|
interrupt: () => n.interrupt(),
|
|
4212
4238
|
clearOutputs: () => {
|
|
4213
4239
|
i.value = [];
|
|
@@ -4219,37 +4245,37 @@ function nl(s = {}) {
|
|
|
4219
4245
|
ready: () => n.waitReady()
|
|
4220
4246
|
};
|
|
4221
4247
|
}
|
|
4222
|
-
const
|
|
4248
|
+
const il = Vi;
|
|
4223
4249
|
export {
|
|
4224
|
-
|
|
4225
|
-
|
|
4250
|
+
gr as DEFAULT_PYODIDE_URL,
|
|
4251
|
+
sl as DEFAULT_SQL_CONFIG,
|
|
4226
4252
|
ln as EDITOR_THEMES,
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4253
|
+
hs as MONO_FONT_STACK,
|
|
4254
|
+
Cs as PyodideRunner,
|
|
4255
|
+
il as PythonEditor,
|
|
4230
4256
|
dt as SQL_DIALECT_OPTIONS,
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4257
|
+
ws as createEditor,
|
|
4258
|
+
Rs as createPythonSession,
|
|
4259
|
+
Vi as default,
|
|
4260
|
+
Fs as deleteServerFile,
|
|
4261
|
+
cr as deleteSqlConnection,
|
|
4262
|
+
ur as getDefaultSqlPort,
|
|
4237
4263
|
un as getRunner,
|
|
4238
|
-
|
|
4239
|
-
|
|
4264
|
+
Vs as getThemeOption,
|
|
4265
|
+
ar as interruptPythonSession,
|
|
4240
4266
|
ut as isDarkTheme,
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4267
|
+
Ms as listServerFiles,
|
|
4268
|
+
zs as listSqlConnections,
|
|
4269
|
+
Ss as makePythonLinter,
|
|
4244
4270
|
D as normalizeSqlConfig,
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4271
|
+
_s as pollPythonSession,
|
|
4272
|
+
Ts as readServerFile,
|
|
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
|
|
4255
4281
|
};
|