@onerjs/code-input 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-input.cjs +16 -16
- package/dist/code-input.es.js +522 -518
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/code-input.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as Bt, ref as R, computed as q, watch as ze, nextTick as P, onMounted as Ot, onBeforeUnmount as Nt, openBlock as I, createElementBlock as H, normalizeStyle as ce, normalizeClass as le, createElementVNode as B, withModifiers as De, Fragment as je, renderList as Fe, toDisplayString as Y, createCommentVNode as K, createTextVNode as Wt } from "vue";
|
|
2
|
+
const zt = [
|
|
3
3
|
{
|
|
4
4
|
label: "Math",
|
|
5
5
|
kind: "class",
|
|
@@ -134,14 +134,14 @@ const It = [
|
|
|
134
134
|
kind: "function",
|
|
135
135
|
detail: "(id: number) => void"
|
|
136
136
|
}
|
|
137
|
-
],
|
|
138
|
-
function
|
|
137
|
+
], Dt = /[\w$]/;
|
|
138
|
+
function jt(n, s) {
|
|
139
139
|
const o = [];
|
|
140
140
|
let e = null;
|
|
141
|
-
for (let
|
|
142
|
-
const b = n[
|
|
141
|
+
for (let S = 0; S < s; S++) {
|
|
142
|
+
const b = n[S];
|
|
143
143
|
if (e) {
|
|
144
|
-
b === e && n[
|
|
144
|
+
b === e && n[S - 1] !== "\\" && (e = null);
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
147
|
if (b === "'" || b === '"' || b === "`") {
|
|
@@ -149,7 +149,7 @@ function _t(n, s) {
|
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
151
|
if (b === "(") {
|
|
152
|
-
o.push({ index:
|
|
152
|
+
o.push({ index: S, commas: 0 });
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
155
|
if (b === ")") {
|
|
@@ -162,15 +162,15 @@ function _t(n, s) {
|
|
|
162
162
|
if (!i) return null;
|
|
163
163
|
let r = i.index - 1;
|
|
164
164
|
for (; r >= 0 && /\s/.test(n[r]); ) r--;
|
|
165
|
-
const
|
|
166
|
-
for (; r >= 0 &&
|
|
167
|
-
const u = n.slice(r + 1,
|
|
165
|
+
const f = r;
|
|
166
|
+
for (; r >= 0 && Dt.test(n[r]); ) r--;
|
|
167
|
+
const u = n.slice(r + 1, f + 1);
|
|
168
168
|
if (!u) return null;
|
|
169
169
|
let a = s;
|
|
170
170
|
for (; a > 0 && /[\w$'"]/.test(n[a - 1]); ) a--;
|
|
171
|
-
const
|
|
172
|
-
let $ =
|
|
173
|
-
return
|
|
171
|
+
const d = n.slice(a, s);
|
|
172
|
+
let $ = d, z = null;
|
|
173
|
+
return d && (d[0] === "'" || d[0] === '"') && (z = d[0], $ = d.slice(1)), {
|
|
174
174
|
functionName: u,
|
|
175
175
|
paramIndex: i.commas,
|
|
176
176
|
prefix: $,
|
|
@@ -178,7 +178,7 @@ function _t(n, s) {
|
|
|
178
178
|
quote: z
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const Pe = [
|
|
182
182
|
"break",
|
|
183
183
|
"case",
|
|
184
184
|
"catch",
|
|
@@ -223,7 +223,7 @@ const ze = [
|
|
|
223
223
|
"undefined",
|
|
224
224
|
"NaN",
|
|
225
225
|
"Infinity"
|
|
226
|
-
],
|
|
226
|
+
], Ft = [
|
|
227
227
|
"abstract",
|
|
228
228
|
"any",
|
|
229
229
|
"as",
|
|
@@ -253,36 +253,36 @@ const ze = [
|
|
|
253
253
|
"type",
|
|
254
254
|
"unknown"
|
|
255
255
|
];
|
|
256
|
-
function
|
|
257
|
-
return n === "typescript" ? [...
|
|
256
|
+
function et(n) {
|
|
257
|
+
return n === "typescript" ? [...Pe, ...Ft] : Pe;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
return new Set(
|
|
259
|
+
function Ve(n) {
|
|
260
|
+
return new Set(et(n));
|
|
261
261
|
}
|
|
262
|
-
const
|
|
263
|
-
function
|
|
264
|
-
const o = n.slice(0, s), e =
|
|
262
|
+
const Pt = /((?:[A-Za-z_$][\w$]*\??\.)*)([A-Za-z_$][\w$]*)?$/, qe = /\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g, Vt = /^[A-Za-z_$]/;
|
|
263
|
+
function tt(n, s) {
|
|
264
|
+
const o = n.slice(0, s), e = Pt.exec(o);
|
|
265
265
|
if (!e) return { prefix: "", chain: [] };
|
|
266
|
-
const i = e[1] ?? "", r = e[2] ?? "",
|
|
267
|
-
return { prefix: r, chain:
|
|
266
|
+
const i = e[1] ?? "", r = e[2] ?? "", f = i.split(".").filter(Boolean).map((u) => u.replace(/\?$/, ""));
|
|
267
|
+
return { prefix: r, chain: f };
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function Ke(n, s) {
|
|
270
270
|
const o = [], e = /* @__PURE__ */ new Set();
|
|
271
271
|
let i;
|
|
272
|
-
for (
|
|
272
|
+
for (qe.lastIndex = 0; (i = qe.exec(n)) && !(i.index >= s); ) {
|
|
273
273
|
const r = i[1];
|
|
274
274
|
if (e.has(r)) continue;
|
|
275
275
|
e.add(r);
|
|
276
|
-
const
|
|
276
|
+
const f = i[0].slice(0, i[0].indexOf(r)).trim();
|
|
277
277
|
o.push({
|
|
278
278
|
label: r,
|
|
279
|
-
kind:
|
|
279
|
+
kind: f === "function" ? "function" : f === "class" ? "class" : "variable",
|
|
280
280
|
detail: "当前文件"
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
return o;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function nt(n, s) {
|
|
286
286
|
let o = s;
|
|
287
287
|
for (const e of n) {
|
|
288
288
|
if (!o) return null;
|
|
@@ -292,74 +292,74 @@ function Ge(n, s) {
|
|
|
292
292
|
}
|
|
293
293
|
return o;
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function qt(n, s) {
|
|
296
296
|
const o = n.toLowerCase(), e = s.toLowerCase(), i = o.indexOf(e);
|
|
297
297
|
if (i === 0) return 1e3 - o.length;
|
|
298
298
|
if (i > 0) return 800 - i;
|
|
299
|
-
let r = 0,
|
|
299
|
+
let r = 0, f = 0, u = -1;
|
|
300
300
|
for (let a = 0; a < o.length && r < e.length; a++)
|
|
301
|
-
o[a] === e[r] && (u >= 0 && (
|
|
302
|
-
return r !== e.length ? null : 400 -
|
|
301
|
+
o[a] === e[r] && (u >= 0 && (f += a - u - 1), u = a, r++);
|
|
302
|
+
return r !== e.length ? null : 400 - f - o.length;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function lt(n, s) {
|
|
305
305
|
if (!s) return n;
|
|
306
306
|
const o = [];
|
|
307
307
|
for (const e of n) {
|
|
308
|
-
const i =
|
|
308
|
+
const i = qt(e.label, s);
|
|
309
309
|
i !== null && o.push({ item: e, score: i });
|
|
310
310
|
}
|
|
311
311
|
return o.sort((e, i) => i.score - e.score || e.item.label.localeCompare(i.item.label)), o.map((e) => e.item);
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function Kt(n) {
|
|
314
314
|
const s = /* @__PURE__ */ new Set(), o = [];
|
|
315
315
|
for (const e of n)
|
|
316
316
|
s.has(e.label) || (s.add(e.label), o.push(e));
|
|
317
317
|
return o;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
const { prefix: e, chain: i } =
|
|
321
|
-
if (o.auto && (!e && i.length === 0 || e && !
|
|
319
|
+
function Zt(n, s, o) {
|
|
320
|
+
const { prefix: e, chain: i } = tt(n, s);
|
|
321
|
+
if (o.auto && (!e && i.length === 0 || e && !Vt.test(e)))
|
|
322
322
|
return null;
|
|
323
|
-
const r = o.declared ?? [],
|
|
323
|
+
const r = o.declared ?? [], f = [...r, ...o.completions];
|
|
324
324
|
let u;
|
|
325
325
|
if (i.length > 0) {
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
328
|
-
u =
|
|
326
|
+
const d = nt(i, f);
|
|
327
|
+
if (!d || d.length === 0) return null;
|
|
328
|
+
u = d;
|
|
329
329
|
} else
|
|
330
330
|
u = [
|
|
331
331
|
...o.completions,
|
|
332
332
|
...r,
|
|
333
|
-
...
|
|
334
|
-
label:
|
|
333
|
+
...et(o.language).map((d) => ({
|
|
334
|
+
label: d,
|
|
335
335
|
kind: "keyword"
|
|
336
336
|
}))
|
|
337
337
|
];
|
|
338
|
-
const a =
|
|
338
|
+
const a = lt(Kt(u), e);
|
|
339
339
|
return a.length === 0 ? null : {
|
|
340
340
|
items: a,
|
|
341
341
|
start: s - e.length,
|
|
342
342
|
end: s
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
|
-
const
|
|
346
|
-
function
|
|
345
|
+
const Ut = /([A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*)*)\??\.\s*$/;
|
|
346
|
+
function Yt(n, s, o, e) {
|
|
347
347
|
const i = n.slice(s, o);
|
|
348
348
|
if (!i) return null;
|
|
349
|
-
const r = [...e.declared ?? [], ...e.completions],
|
|
350
|
-
if (
|
|
351
|
-
const u =
|
|
352
|
-
if (
|
|
349
|
+
const r = [...e.declared ?? [], ...e.completions], f = Ut.exec(n.slice(0, s));
|
|
350
|
+
if (f) {
|
|
351
|
+
const u = f[1].split(".").filter(Boolean).map(($) => $.replace(/\?$/, "")), a = nt(u, r), d = a == null ? void 0 : a.find(($) => $.label === i);
|
|
352
|
+
if (d) return d;
|
|
353
353
|
}
|
|
354
354
|
return r.find((u) => u.label === i) ?? null;
|
|
355
355
|
}
|
|
356
|
-
const
|
|
357
|
-
function
|
|
356
|
+
const Z = "[A-Za-z_$][\\w$]*", Ze = "(?:readonly\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|abstract\\s+)*";
|
|
357
|
+
function Ue(n, s) {
|
|
358
358
|
let o = 0, e = !1, i = s;
|
|
359
359
|
for (let r = s; r < n.length; r++) {
|
|
360
|
-
const
|
|
361
|
-
for (let u = 0; u <
|
|
362
|
-
const a =
|
|
360
|
+
const f = n[r];
|
|
361
|
+
for (let u = 0; u < f.length; u++) {
|
|
362
|
+
const a = f[u];
|
|
363
363
|
a === "{" ? (o++, e = !0) : a === "}" && o--;
|
|
364
364
|
}
|
|
365
365
|
if (e && o <= 0) {
|
|
@@ -369,23 +369,23 @@ function Ve(n, s) {
|
|
|
369
369
|
}
|
|
370
370
|
return { end: i, body: n.slice(s + 1, i) };
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function Ye(n) {
|
|
373
373
|
return n.trim().replace(/[,;]$/, "").trim();
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function Xt(n) {
|
|
376
376
|
return /^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:interface|class|type|function|const|let|var|namespace|enum)\b/.test(
|
|
377
377
|
n
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function ie(n, s) {
|
|
381
381
|
const o = n[s];
|
|
382
382
|
let e = o.lastIndexOf("}");
|
|
383
383
|
const i = o.lastIndexOf(";");
|
|
384
384
|
if (i > e && (e = i), e === -1) return;
|
|
385
385
|
const r = o.slice(e + 1).replace(/^[\s;]+/, "").trim();
|
|
386
|
-
!r || !
|
|
386
|
+
!r || !Xt(r) || (n[s] = o.slice(0, e + 1), n.splice(s + 1, 0, r));
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function G(n) {
|
|
389
389
|
return n.length ? n.join(`
|
|
390
390
|
`).replace(/^\s*\/\*\*?/, "").replace(/\*\/\s*$/, "").split(`
|
|
391
391
|
`).map((s) => s.replace(/^\s*\*+\s?/, "").replace(/^\s*\/\/\s?/, "")).join(`
|
|
@@ -393,23 +393,23 @@ function J(n) {
|
|
|
393
393
|
|
|
394
394
|
`).trim() : "";
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Xe(n) {
|
|
397
397
|
return n.split(`
|
|
398
398
|
`).filter((s) => !/^\s*(\/\/|\/\*|\*)/.test(s)).join(`
|
|
399
399
|
`).replace(/\n{2,}/g, `
|
|
400
400
|
`).trim();
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const s = [], o = /* @__PURE__ */ new Set(), e = new RegExp(`^${
|
|
404
|
-
let r = [],
|
|
402
|
+
function Je(n) {
|
|
403
|
+
const s = [], o = /* @__PURE__ */ new Set(), e = new RegExp(`^${Ze}(${Z})(\\?)?\\s*\\((.*)\\)\\s*:\\s*(.+?);?$`), i = new RegExp(`^${Ze}(${Z})(\\?)?\\s*:\\s*(.+?);?$`);
|
|
404
|
+
let r = [], f = !1;
|
|
405
405
|
for (const u of n) {
|
|
406
406
|
const a = u.trim();
|
|
407
|
-
if (
|
|
408
|
-
r.push(a), a.includes("*/") && (
|
|
407
|
+
if (f) {
|
|
408
|
+
r.push(a), a.includes("*/") && (f = !1);
|
|
409
409
|
continue;
|
|
410
410
|
}
|
|
411
411
|
if (a.startsWith("/*")) {
|
|
412
|
-
r.push(a), a.includes("*/") || (
|
|
412
|
+
r.push(a), a.includes("*/") || (f = !0);
|
|
413
413
|
continue;
|
|
414
414
|
}
|
|
415
415
|
if (a.startsWith("//")) {
|
|
@@ -420,31 +420,31 @@ function Ze(n) {
|
|
|
420
420
|
r = [];
|
|
421
421
|
continue;
|
|
422
422
|
}
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
const z =
|
|
423
|
+
const d = e.exec(a);
|
|
424
|
+
if (d) {
|
|
425
|
+
const z = G(r);
|
|
426
426
|
r = [];
|
|
427
|
-
const
|
|
428
|
-
if (o.has(
|
|
429
|
-
o.add(
|
|
430
|
-
label:
|
|
427
|
+
const S = d[1];
|
|
428
|
+
if (o.has(S)) continue;
|
|
429
|
+
o.add(S), s.push({
|
|
430
|
+
label: S,
|
|
431
431
|
kind: "function",
|
|
432
|
-
detail: `(${
|
|
432
|
+
detail: `(${d[3].trim()}) => ${Ye(d[4])}`,
|
|
433
433
|
documentation: z || void 0
|
|
434
434
|
});
|
|
435
435
|
continue;
|
|
436
436
|
}
|
|
437
437
|
const $ = i.exec(a);
|
|
438
438
|
if ($) {
|
|
439
|
-
const z =
|
|
439
|
+
const z = G(r);
|
|
440
440
|
r = [];
|
|
441
|
-
const
|
|
442
|
-
if (o.has(
|
|
443
|
-
o.add(
|
|
444
|
-
const b =
|
|
441
|
+
const S = $[1];
|
|
442
|
+
if (o.has(S)) continue;
|
|
443
|
+
o.add(S);
|
|
444
|
+
const b = Ye($[3]), v = /^\(|=>/.test(b) ? "function" : "property";
|
|
445
445
|
s.push({
|
|
446
|
-
label:
|
|
447
|
-
kind:
|
|
446
|
+
label: S,
|
|
447
|
+
kind: v,
|
|
448
448
|
detail: b,
|
|
449
449
|
documentation: z || void 0
|
|
450
450
|
});
|
|
@@ -452,20 +452,20 @@ function Ze(n) {
|
|
|
452
452
|
}
|
|
453
453
|
return s;
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function it(n) {
|
|
456
456
|
const s = [], o = /(['"])((?:\\.|(?!\1).)*)\1/g;
|
|
457
457
|
let e;
|
|
458
458
|
for (; e = o.exec(n); )
|
|
459
459
|
s.push(e[2]);
|
|
460
460
|
return s;
|
|
461
461
|
}
|
|
462
|
-
function
|
|
462
|
+
function Jt(n, s) {
|
|
463
463
|
const o = [];
|
|
464
464
|
let e = 0, i = "", r = null;
|
|
465
|
-
for (let
|
|
466
|
-
const u = n[
|
|
465
|
+
for (let f = 0; f < n.length; f++) {
|
|
466
|
+
const u = n[f];
|
|
467
467
|
if (r) {
|
|
468
|
-
i += u, u === r && n[
|
|
468
|
+
i += u, u === r && n[f - 1] !== "\\" && (r = null);
|
|
469
469
|
continue;
|
|
470
470
|
}
|
|
471
471
|
if (u === "'" || u === '"' || u === "`") {
|
|
@@ -480,16 +480,16 @@ function Ft(n, s) {
|
|
|
480
480
|
}
|
|
481
481
|
return o.push(i), o;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
const o = n.trim(), e =
|
|
483
|
+
function Gt(n, s) {
|
|
484
|
+
const o = n.trim(), e = it(o);
|
|
485
485
|
if (e.length) return e;
|
|
486
486
|
const i = s.get(o.replace(/\[\]$/, ""));
|
|
487
487
|
return (i == null ? void 0 : i.literals) ?? [];
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function Qt(n, s) {
|
|
490
490
|
const o = n.trim();
|
|
491
|
-
return o ?
|
|
492
|
-
const i = new RegExp(`^\\s*(${
|
|
491
|
+
return o ? Jt(o, ",").map((e) => {
|
|
492
|
+
const i = new RegExp(`^\\s*(${Z})\\s*(\\?)?\\s*:\\s*(.+)$`).exec(e);
|
|
493
493
|
if (!i)
|
|
494
494
|
return { name: e.trim(), type: "", optional: !1, literals: [] };
|
|
495
495
|
const r = i[3].replace(/\s*=\s*[^=]*$/, "").trim();
|
|
@@ -497,116 +497,116 @@ function Vt(n, s) {
|
|
|
497
497
|
name: i[1],
|
|
498
498
|
optional: !!i[2],
|
|
499
499
|
type: r,
|
|
500
|
-
literals:
|
|
500
|
+
literals: Gt(r, s)
|
|
501
501
|
};
|
|
502
502
|
}) : [];
|
|
503
503
|
}
|
|
504
|
-
function
|
|
505
|
-
const s = n.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), o = new RegExp(`^(${
|
|
504
|
+
function ot(n) {
|
|
505
|
+
const s = n.replace(/\[\]/g, "").replace(/<[^>]*>/g, "").replace(/\s*\|\s*null\s*/g, "").trim(), o = new RegExp(`^(${Z})$`).exec(s);
|
|
506
506
|
return o ? o[1] : null;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function en(n) {
|
|
509
509
|
const s = n.trim();
|
|
510
510
|
if (!s || s.endsWith(";")) return !1;
|
|
511
511
|
const o = (s.match(/[(<[{]/g) ?? []).length, e = (s.match(/[)>\]}]/g) ?? []).length;
|
|
512
512
|
return /[|&,(<]\s*$/.test(s) || o > e;
|
|
513
513
|
}
|
|
514
|
-
function
|
|
514
|
+
function at(n, s, o, e = 0) {
|
|
515
515
|
return e > 6 ? n : n.map((i) => {
|
|
516
516
|
if (i.kind !== "property" || !i.detail) return i;
|
|
517
|
-
const r =
|
|
518
|
-
if (!
|
|
517
|
+
const r = ot(i.detail), f = r ? s.get(r) : void 0;
|
|
518
|
+
if (!f || o.has(f.label)) return i;
|
|
519
519
|
const u = new Set(o);
|
|
520
|
-
return u.add(
|
|
520
|
+
return u.add(f.label), {
|
|
521
521
|
...i,
|
|
522
|
-
type:
|
|
523
|
-
members:
|
|
522
|
+
type: f.type,
|
|
523
|
+
members: at(f.members, s, u, e + 1)
|
|
524
524
|
};
|
|
525
525
|
});
|
|
526
526
|
}
|
|
527
|
-
const
|
|
528
|
-
function
|
|
529
|
-
if (!n || !n.trim()) return
|
|
530
|
-
const s =
|
|
527
|
+
const tn = 50, oe = /* @__PURE__ */ new Map(), nn = { items: [], signatures: /* @__PURE__ */ new Map() };
|
|
528
|
+
function st(n) {
|
|
529
|
+
if (!n || !n.trim()) return nn;
|
|
530
|
+
const s = oe.get(n);
|
|
531
531
|
if (s) return s;
|
|
532
|
-
const o =
|
|
533
|
-
if (
|
|
534
|
-
const e =
|
|
535
|
-
e !== void 0 &&
|
|
532
|
+
const o = an(n);
|
|
533
|
+
if (oe.size >= tn) {
|
|
534
|
+
const e = oe.keys().next().value;
|
|
535
|
+
e !== void 0 && oe.delete(e);
|
|
536
536
|
}
|
|
537
|
-
return
|
|
537
|
+
return oe.set(n, o), o;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
return
|
|
539
|
+
function ln(n) {
|
|
540
|
+
return st(n).items;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return
|
|
542
|
+
function on(n) {
|
|
543
|
+
return st(n).signatures;
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function an(n) {
|
|
546
546
|
const s = n.split(`
|
|
547
|
-
`), o = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${
|
|
547
|
+
`), o = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), i = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?interface\\s+(${Z})`), r = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?(?:abstract\\s+)?class\\s+(${Z})`), f = new RegExp(`^(?:export\\s+)?(?:declare\\s+)?type\\s+(${Z})\\s*=`);
|
|
548
548
|
let u = [], a = !1;
|
|
549
549
|
for (let b = 0; b < s.length; b++) {
|
|
550
|
-
const
|
|
550
|
+
const v = s[b].trim();
|
|
551
551
|
if (a) {
|
|
552
|
-
u.push(
|
|
552
|
+
u.push(v), v.includes("*/") && (a = !1);
|
|
553
553
|
continue;
|
|
554
554
|
}
|
|
555
|
-
if (
|
|
556
|
-
u.push(
|
|
555
|
+
if (v.startsWith("/*")) {
|
|
556
|
+
u.push(v), v.includes("*/") || (a = !0);
|
|
557
557
|
continue;
|
|
558
558
|
}
|
|
559
|
-
if (
|
|
560
|
-
u.push(
|
|
559
|
+
if (v.startsWith("//")) {
|
|
560
|
+
u.push(v);
|
|
561
561
|
continue;
|
|
562
562
|
}
|
|
563
|
-
if (!
|
|
563
|
+
if (!v) {
|
|
564
564
|
u = [];
|
|
565
565
|
continue;
|
|
566
566
|
}
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
const w =
|
|
567
|
+
const W = i.exec(v);
|
|
568
|
+
if (W && v.includes("{")) {
|
|
569
|
+
const w = G(u);
|
|
570
570
|
u = [];
|
|
571
|
-
const { end: T, body:
|
|
571
|
+
const { end: T, body: L } = Ue(s, b), g = W[1];
|
|
572
572
|
o.set(g, {
|
|
573
573
|
label: g,
|
|
574
|
-
type:
|
|
574
|
+
type: Xe(
|
|
575
575
|
s.slice(b, T + 1).join(`
|
|
576
576
|
`).replace(/^\s*export\s+/, "")
|
|
577
577
|
),
|
|
578
|
-
members:
|
|
578
|
+
members: Je(L),
|
|
579
579
|
kind: "interface",
|
|
580
580
|
documentation: w || void 0
|
|
581
|
-
}),
|
|
581
|
+
}), ie(s, T), b = T;
|
|
582
582
|
continue;
|
|
583
583
|
}
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
586
|
-
const w =
|
|
584
|
+
const O = r.exec(v);
|
|
585
|
+
if (O && v.includes("{")) {
|
|
586
|
+
const w = G(u);
|
|
587
587
|
u = [];
|
|
588
|
-
const { end: T, body:
|
|
588
|
+
const { end: T, body: L } = Ue(s, b), g = O[1];
|
|
589
589
|
o.set(g, {
|
|
590
590
|
label: g,
|
|
591
|
-
type:
|
|
591
|
+
type: Xe(
|
|
592
592
|
s.slice(b, T + 1).join(`
|
|
593
593
|
`).replace(/^\s*export\s+/, "")
|
|
594
594
|
),
|
|
595
|
-
members:
|
|
595
|
+
members: Je(L),
|
|
596
596
|
kind: "class",
|
|
597
597
|
documentation: w || void 0
|
|
598
|
-
}),
|
|
598
|
+
}), ie(s, T), b = T;
|
|
599
599
|
continue;
|
|
600
600
|
}
|
|
601
|
-
const M =
|
|
601
|
+
const M = f.exec(v);
|
|
602
602
|
if (M) {
|
|
603
|
-
const w =
|
|
603
|
+
const w = G(u);
|
|
604
604
|
u = [];
|
|
605
605
|
const T = [s[b]];
|
|
606
|
-
let
|
|
607
|
-
for (;
|
|
608
|
-
`)) &&
|
|
609
|
-
|
|
606
|
+
let L = b;
|
|
607
|
+
for (; en(T.join(`
|
|
608
|
+
`)) && L + 1 < s.length; )
|
|
609
|
+
L++, T.push(s[L]);
|
|
610
610
|
const g = T.join(`
|
|
611
611
|
`).replace(/^\s*export\s+/, "").replace(/;\s*$/, "").trim();
|
|
612
612
|
o.set(M[1], {
|
|
@@ -615,74 +615,74 @@ function Jt(n) {
|
|
|
615
615
|
members: [],
|
|
616
616
|
kind: "type",
|
|
617
617
|
documentation: w || void 0,
|
|
618
|
-
literals:
|
|
619
|
-
}),
|
|
618
|
+
literals: it(g)
|
|
619
|
+
}), ie(s, L), b = L;
|
|
620
620
|
continue;
|
|
621
621
|
}
|
|
622
622
|
u = [];
|
|
623
623
|
}
|
|
624
|
-
const
|
|
625
|
-
`^(?:export\\s+)?(?:declare\\s+)?function\\s+(${
|
|
626
|
-
),
|
|
627
|
-
`^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${
|
|
624
|
+
const d = [], $ = /* @__PURE__ */ new Set(), z = new RegExp(
|
|
625
|
+
`^(?:export\\s+)?(?:declare\\s+)?function\\s+(${Z})\\s*\\(([^)]*)\\)\\s*:\\s*([^;{]+)`
|
|
626
|
+
), S = new RegExp(
|
|
627
|
+
`^(?:export\\s+)?(?:declare\\s+)?(?:const|let|var)\\s+(${Z})\\s*:\\s*([^=;]+)`
|
|
628
628
|
);
|
|
629
629
|
u = [], a = !1;
|
|
630
630
|
for (let b = 0; b < s.length; b++) {
|
|
631
|
-
const
|
|
631
|
+
const v = s[b].trim();
|
|
632
632
|
if (a) {
|
|
633
|
-
u.push(
|
|
633
|
+
u.push(v), v.includes("*/") && (a = !1);
|
|
634
634
|
continue;
|
|
635
635
|
}
|
|
636
|
-
if (
|
|
637
|
-
u.push(
|
|
636
|
+
if (v.startsWith("/*")) {
|
|
637
|
+
u.push(v), v.includes("*/") || (a = !0);
|
|
638
638
|
continue;
|
|
639
639
|
}
|
|
640
|
-
if (
|
|
641
|
-
u.push(
|
|
640
|
+
if (v.startsWith("//")) {
|
|
641
|
+
u.push(v);
|
|
642
642
|
continue;
|
|
643
643
|
}
|
|
644
|
-
if (!
|
|
644
|
+
if (!v) {
|
|
645
645
|
u = [];
|
|
646
646
|
continue;
|
|
647
647
|
}
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
650
|
-
|
|
651
|
-
const M =
|
|
648
|
+
const W = z.exec(v);
|
|
649
|
+
if (W) {
|
|
650
|
+
ie(s, b);
|
|
651
|
+
const M = G(u);
|
|
652
652
|
u = [];
|
|
653
|
-
const w =
|
|
654
|
-
$.has(w) || ($.add(w),
|
|
653
|
+
const w = W[1];
|
|
654
|
+
$.has(w) || ($.add(w), d.push({
|
|
655
655
|
label: w,
|
|
656
656
|
kind: "function",
|
|
657
|
-
detail: `(${
|
|
657
|
+
detail: `(${W[2].trim()}) => ${W[3].trim()}`,
|
|
658
658
|
documentation: M || void 0
|
|
659
|
-
})), e.set(w, { name: w, params:
|
|
659
|
+
})), e.set(w, { name: w, params: Qt(W[2], o) });
|
|
660
660
|
continue;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
const M =
|
|
662
|
+
const O = S.exec(v);
|
|
663
|
+
if (O) {
|
|
664
|
+
ie(s, b);
|
|
665
|
+
const M = G(u);
|
|
666
666
|
u = [];
|
|
667
|
-
const w =
|
|
667
|
+
const w = O[1];
|
|
668
668
|
if ($.has(w)) continue;
|
|
669
669
|
$.add(w);
|
|
670
|
-
const T =
|
|
671
|
-
|
|
670
|
+
const T = O[2].trim(), L = ot(T), g = L ? o.get(L) : void 0, ae = (g == null ? void 0 : g.kind) === "class" ? "class" : /^\(|=>/.test(T) ? "function" : "variable";
|
|
671
|
+
d.push({
|
|
672
672
|
label: w,
|
|
673
|
-
kind:
|
|
673
|
+
kind: ae,
|
|
674
674
|
detail: T,
|
|
675
675
|
type: g == null ? void 0 : g.type,
|
|
676
676
|
documentation: M || (g == null ? void 0 : g.documentation) || void 0,
|
|
677
|
-
members: g ?
|
|
677
|
+
members: g ? at(g.members, o, /* @__PURE__ */ new Set([g.label])) : void 0
|
|
678
678
|
});
|
|
679
679
|
continue;
|
|
680
680
|
}
|
|
681
681
|
u = [];
|
|
682
682
|
}
|
|
683
|
-
return { items:
|
|
683
|
+
return { items: d, signatures: e };
|
|
684
684
|
}
|
|
685
|
-
function
|
|
685
|
+
function we(n, s, o, e) {
|
|
686
686
|
if (!o || !e) return null;
|
|
687
687
|
const i = Math.max(0, s - 1), r = n.lastIndexOf(o, i);
|
|
688
688
|
if (r === -1 || n.lastIndexOf(e, i) > r) return null;
|
|
@@ -692,28 +692,28 @@ function ke(n, s, o, e) {
|
|
|
692
692
|
end: u === -1 ? n.length : u
|
|
693
693
|
};
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
695
|
+
function Hn(n, s, o, e) {
|
|
696
|
+
return we(n, s, o, e) !== null;
|
|
697
697
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
698
|
+
const Ge = /[A-Za-z_$]/, sn = /[\w$]/, Qe = /\s/;
|
|
699
|
+
function ue(n, s) {
|
|
700
700
|
const o = [], e = n.length;
|
|
701
701
|
let i = 0;
|
|
702
702
|
for (; i < e; ) {
|
|
703
|
-
const r = n[i],
|
|
704
|
-
if (
|
|
703
|
+
const r = n[i], f = n[i + 1];
|
|
704
|
+
if (Qe.test(r)) {
|
|
705
705
|
i++;
|
|
706
706
|
continue;
|
|
707
707
|
}
|
|
708
|
-
if (r === "/" &&
|
|
708
|
+
if (r === "/" && f === "/") {
|
|
709
709
|
let a = n.indexOf(`
|
|
710
710
|
`, i);
|
|
711
711
|
a === -1 && (a = e), o.push({ start: i, end: a, type: "comment" }), i = a;
|
|
712
712
|
continue;
|
|
713
713
|
}
|
|
714
|
-
if (r === "/" &&
|
|
715
|
-
const a = n.indexOf("*/", i + 2),
|
|
716
|
-
o.push({ start: i, end:
|
|
714
|
+
if (r === "/" && f === "*") {
|
|
715
|
+
const a = n.indexOf("*/", i + 2), d = a === -1 ? e : a + 2;
|
|
716
|
+
o.push({ start: i, end: d, type: "comment" }), i = d;
|
|
717
717
|
continue;
|
|
718
718
|
}
|
|
719
719
|
if (r === '"' || r === "'") {
|
|
@@ -750,93 +750,93 @@ function ce(n, s) {
|
|
|
750
750
|
o.push({ start: i, end: a, type: "template" }), i = a;
|
|
751
751
|
continue;
|
|
752
752
|
}
|
|
753
|
-
if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(
|
|
753
|
+
if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(f ?? "")) {
|
|
754
754
|
let a = i + 1;
|
|
755
755
|
for (; a < e && /[\w.]/.test(n[a]); ) a++;
|
|
756
756
|
o.push({ start: i, end: a, type: "number" }), i = a;
|
|
757
757
|
continue;
|
|
758
758
|
}
|
|
759
|
-
if (
|
|
759
|
+
if (Ge.test(r)) {
|
|
760
760
|
let a = i + 1;
|
|
761
|
-
for (; a < e &&
|
|
762
|
-
const
|
|
761
|
+
for (; a < e && sn.test(n[a]); ) a++;
|
|
762
|
+
const d = n.slice(i, a), $ = s.keywords.has(d) ? "keyword" : s.builtins.has(d) ? "builtin" : "identifier";
|
|
763
763
|
o.push({ start: i, end: a, type: $ }), i = a;
|
|
764
764
|
continue;
|
|
765
765
|
}
|
|
766
766
|
let u = i + 1;
|
|
767
767
|
for (; u < e; ) {
|
|
768
768
|
const a = n[u];
|
|
769
|
-
if (
|
|
769
|
+
if (Qe.test(a) || Ge.test(a) || /[0-9]/.test(a) || a === '"' || a === "'" || a === "`" || a === "/") break;
|
|
770
770
|
u++;
|
|
771
771
|
}
|
|
772
772
|
o.push({ start: i, end: u, type: "punctuation" }), i = u;
|
|
773
773
|
}
|
|
774
774
|
return o;
|
|
775
775
|
}
|
|
776
|
-
const
|
|
776
|
+
const rn = {
|
|
777
777
|
"&": "&",
|
|
778
778
|
"<": "<",
|
|
779
779
|
">": ">"
|
|
780
780
|
};
|
|
781
|
-
function
|
|
782
|
-
return n.replace(/[&<>]/g, (s) =>
|
|
781
|
+
function Q(n) {
|
|
782
|
+
return n.replace(/[&<>]/g, (s) => rn[s] ?? s);
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function de(n, s, o = 0) {
|
|
785
785
|
let e = "", i = 0;
|
|
786
786
|
for (const r of s) {
|
|
787
|
-
r.start > i && (e +=
|
|
788
|
-
const
|
|
789
|
-
e += `<span class="tok-${r.type}" data-start="${r.start + o}" data-end="${r.end + o}">${
|
|
787
|
+
r.start > i && (e += Q(n.slice(i, r.start)));
|
|
788
|
+
const f = Q(n.slice(r.start, r.end));
|
|
789
|
+
e += `<span class="tok-${r.type}" data-start="${r.start + o}" data-end="${r.end + o}">${f}</span>`, i = r.end;
|
|
790
790
|
}
|
|
791
|
-
return i < n.length && (e +=
|
|
791
|
+
return i < n.length && (e += Q(n.slice(i))), e;
|
|
792
792
|
}
|
|
793
|
-
function
|
|
794
|
-
if (!o || !e) return
|
|
793
|
+
function cn(n, s, o, e) {
|
|
794
|
+
if (!o || !e) return de(n, ue(n, s));
|
|
795
795
|
let i = "", r = 0;
|
|
796
796
|
for (; r < n.length; ) {
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
799
|
-
i +=
|
|
797
|
+
const f = n.indexOf(o, r);
|
|
798
|
+
if (f === -1) {
|
|
799
|
+
i += Q(n.slice(r));
|
|
800
800
|
break;
|
|
801
801
|
}
|
|
802
|
-
i +=
|
|
803
|
-
const u = n.indexOf(e,
|
|
804
|
-
i += `<span class="tok-brace">${
|
|
802
|
+
i += Q(n.slice(r, f));
|
|
803
|
+
const u = n.indexOf(e, f + o.length), a = u === -1 ? n.length : u, d = n.slice(f + o.length, a);
|
|
804
|
+
i += `<span class="tok-brace">${Q(o)}</span>`, i += de(d, ue(d, s), f + o.length), u === -1 ? r = a : (i += `<span class="tok-brace">${Q(e)}</span>`, r = u + e.length);
|
|
805
805
|
}
|
|
806
806
|
return i;
|
|
807
807
|
}
|
|
808
|
-
const
|
|
808
|
+
const un = {
|
|
809
809
|
key: 0,
|
|
810
810
|
class: "gutter",
|
|
811
811
|
"aria-hidden": "true"
|
|
812
|
-
},
|
|
812
|
+
}, dn = ["innerHTML"], fn = ["value", "readonly", "placeholder"], pn = ["onMouseenter", "onClick"], mn = { class: "popup-label" }, hn = {
|
|
813
813
|
key: 0,
|
|
814
814
|
class: "popup-detail"
|
|
815
|
-
},
|
|
815
|
+
}, gn = { class: "hover-head" }, bn = { class: "hover-name" }, vn = {
|
|
816
816
|
key: 0,
|
|
817
817
|
class: "hover-colon"
|
|
818
|
-
},
|
|
818
|
+
}, yn = {
|
|
819
819
|
key: 0,
|
|
820
820
|
class: "hover-type"
|
|
821
|
-
},
|
|
821
|
+
}, kn = {
|
|
822
822
|
key: 0,
|
|
823
823
|
class: "hover-doc"
|
|
824
|
-
},
|
|
824
|
+
}, wn = {
|
|
825
825
|
key: 1,
|
|
826
826
|
class: "hover-def"
|
|
827
|
-
},
|
|
827
|
+
}, xn = ["innerHTML"], $n = ["title", "aria-label"], Tn = {
|
|
828
828
|
key: 0,
|
|
829
829
|
viewBox: "0 0 16 16",
|
|
830
830
|
width: "14",
|
|
831
831
|
height: "14",
|
|
832
832
|
"aria-hidden": "true"
|
|
833
|
-
},
|
|
833
|
+
}, Cn = {
|
|
834
834
|
key: 1,
|
|
835
835
|
viewBox: "0 0 16 16",
|
|
836
836
|
width: "14",
|
|
837
837
|
height: "14",
|
|
838
838
|
"aria-hidden": "true"
|
|
839
|
-
},
|
|
839
|
+
}, Sn = /* @__PURE__ */ Bt({
|
|
840
840
|
__name: "CodeEditor",
|
|
841
841
|
props: {
|
|
842
842
|
modelValue: {},
|
|
@@ -871,7 +871,7 @@ const en = {
|
|
|
871
871
|
class: "对象",
|
|
872
872
|
keyword: "关键字",
|
|
873
873
|
value: "值"
|
|
874
|
-
},
|
|
874
|
+
}, f = {
|
|
875
875
|
"(": ")",
|
|
876
876
|
"[": "]",
|
|
877
877
|
"{": "}",
|
|
@@ -886,77 +886,77 @@ const en = {
|
|
|
886
886
|
"End",
|
|
887
887
|
"PageUp",
|
|
888
888
|
"PageDown"
|
|
889
|
-
]), a =
|
|
890
|
-
() => e.tsTypes ?
|
|
891
|
-
),
|
|
892
|
-
() => e.tsTypes ?
|
|
893
|
-
),
|
|
894
|
-
...
|
|
895
|
-
...
|
|
889
|
+
]), a = R(e.modelValue), d = R(), $ = R(), z = R(), S = R(), b = R(), v = R(), W = R(), O = R([]), M = R(0), w = R(!1), T = R({ start: 0, end: 0 }), L = R({}), g = R(null), ae = R({}), rt = q(
|
|
890
|
+
() => e.tsTypes ? ln(e.tsTypes) : []
|
|
891
|
+
), ct = q(
|
|
892
|
+
() => e.tsTypes ? on(e.tsTypes) : /* @__PURE__ */ new Map()
|
|
893
|
+
), xe = q(() => [
|
|
894
|
+
...zt,
|
|
895
|
+
...rt.value,
|
|
896
896
|
...e.completions
|
|
897
|
-
]),
|
|
898
|
-
() => e.mode === "template" ? [...e.templateCompletions, ...
|
|
899
|
-
),
|
|
897
|
+
]), fe = q(
|
|
898
|
+
() => e.mode === "template" ? [...e.templateCompletions, ...xe.value] : xe.value
|
|
899
|
+
), ut = q(() => {
|
|
900
900
|
const t = {
|
|
901
|
-
keywords:
|
|
902
|
-
builtins: new Set(
|
|
901
|
+
keywords: Ve(e.language),
|
|
902
|
+
builtins: new Set(fe.value.map((l) => l.label))
|
|
903
903
|
};
|
|
904
|
-
return e.mode === "template" ? `${
|
|
905
|
-
` : `${
|
|
904
|
+
return e.mode === "template" ? `${cn(a.value, t, e.templateOpen, e.templateClose)}
|
|
905
|
+
` : `${de(a.value, ue(a.value, t))}
|
|
906
906
|
`;
|
|
907
|
-
}),
|
|
908
|
-
`).length), F =
|
|
907
|
+
}), dt = q(() => a.value.split(`
|
|
908
|
+
`).length), F = R(e.defaultExpanded), pe = R(!1), me = q(() => e.collapsible && !F.value), ft = q(() => {
|
|
909
909
|
const t = {};
|
|
910
910
|
return e.collapsible && (t.height = e.collapsedHeight), t;
|
|
911
|
-
}),
|
|
911
|
+
}), pt = q(() => {
|
|
912
912
|
const t = {
|
|
913
913
|
"--ce-radius": e.borderRadius,
|
|
914
914
|
"--ce-collapsed-height": e.collapsedHeight
|
|
915
915
|
};
|
|
916
916
|
return e.background && (t["--ce-bg"] = e.background), e.borderColor && (t["--ce-border"] = e.borderColor), e.collapsible ? { ...t, height: F.value ? e.minHeight : e.collapsedHeight } : { ...t, height: e.minHeight };
|
|
917
917
|
});
|
|
918
|
-
let
|
|
919
|
-
function
|
|
918
|
+
let $e = 0;
|
|
919
|
+
function Te(t) {
|
|
920
920
|
if (F.value === t) return;
|
|
921
|
-
const l =
|
|
922
|
-
t && l && (
|
|
923
|
-
if (
|
|
921
|
+
const l = d.value;
|
|
922
|
+
t && l && ($e = l.scrollTop), F.value = t, e.collapsible && (pe.value = !0), i(t ? "expand" : "collapse"), _(), j(), P(() => {
|
|
923
|
+
if (he(), !F.value && l) {
|
|
924
924
|
const c = Math.max(0, l.scrollHeight - l.clientHeight);
|
|
925
|
-
l.scrollTop = Math.max(0, Math.min(
|
|
925
|
+
l.scrollTop = Math.max(0, Math.min($e, c)), D(!0), document.activeElement === l && X();
|
|
926
926
|
return;
|
|
927
927
|
}
|
|
928
|
-
|
|
928
|
+
D(!0), t && e.collapseOnBlur && l && document.activeElement !== l && l.focus();
|
|
929
929
|
});
|
|
930
930
|
}
|
|
931
|
-
function
|
|
932
|
-
|
|
931
|
+
function mt() {
|
|
932
|
+
pe.value = !1;
|
|
933
933
|
}
|
|
934
|
-
function
|
|
935
|
-
|
|
934
|
+
function ht() {
|
|
935
|
+
Te(!F.value);
|
|
936
936
|
}
|
|
937
|
-
|
|
937
|
+
ze(
|
|
938
938
|
() => e.modelValue,
|
|
939
939
|
(t) => {
|
|
940
|
-
t !== a.value && (a.value = t,
|
|
940
|
+
t !== a.value && (a.value = t, _());
|
|
941
941
|
}
|
|
942
|
-
),
|
|
943
|
-
|
|
942
|
+
), ze(a, () => {
|
|
943
|
+
P(() => D(!0));
|
|
944
944
|
});
|
|
945
|
-
function
|
|
945
|
+
function Ce(t) {
|
|
946
946
|
return r[t];
|
|
947
947
|
}
|
|
948
|
-
function
|
|
949
|
-
return t ?
|
|
948
|
+
function gt(t) {
|
|
949
|
+
return t ? de(
|
|
950
950
|
t,
|
|
951
|
-
|
|
951
|
+
ue(t, { keywords: Ve("typescript"), builtins: /* @__PURE__ */ new Set() })
|
|
952
952
|
) : "";
|
|
953
953
|
}
|
|
954
|
-
let
|
|
955
|
-
function
|
|
956
|
-
const t =
|
|
954
|
+
let ee = { top: 14, bottom: 14, left: 16, right: 16, lineHeight: 22 };
|
|
955
|
+
function he() {
|
|
956
|
+
const t = d.value;
|
|
957
957
|
if (!t) return;
|
|
958
958
|
const l = window.getComputedStyle(t);
|
|
959
|
-
|
|
959
|
+
ee = {
|
|
960
960
|
top: parseFloat(l.paddingTop) || 0,
|
|
961
961
|
bottom: parseFloat(l.paddingBottom) || 0,
|
|
962
962
|
left: parseFloat(l.paddingLeft) || 0,
|
|
@@ -964,66 +964,67 @@ const en = {
|
|
|
964
964
|
lineHeight: parseFloat(l.lineHeight) || 22
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
|
-
function
|
|
968
|
-
const l =
|
|
967
|
+
function D(t = !1) {
|
|
968
|
+
const l = d.value;
|
|
969
969
|
if (!l) return;
|
|
970
|
-
const c =
|
|
970
|
+
const c = S.value;
|
|
971
971
|
if (c && (c.style.transform = `translate(${-l.scrollLeft}px, ${-l.scrollTop}px)`), b.value && (b.value.style.transform = `translateY(${-l.scrollTop}px)`), t) {
|
|
972
|
-
const
|
|
973
|
-
|
|
972
|
+
const p = `${a.value}|${e.mode}|${l.clientWidth}|${l.clientHeight}`;
|
|
973
|
+
p !== Ee && (Ee = p, bt());
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
|
-
function
|
|
977
|
-
const t =
|
|
976
|
+
function X() {
|
|
977
|
+
const t = d.value;
|
|
978
978
|
if (!t) return;
|
|
979
|
-
const l =
|
|
979
|
+
const l = Re();
|
|
980
980
|
if (!l) return;
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
981
|
+
const c = t.getBoundingClientRect(), p = t.offsetWidth ? c.width / t.offsetWidth : 1, h = t.offsetHeight ? c.height / t.offsetHeight : 1;
|
|
982
|
+
let m = t.scrollTop;
|
|
983
|
+
if (me.value) {
|
|
984
|
+
const Ne = t.clientHeight * h, We = ee.top * h, It = ee.bottom * h, Ht = l.lineHeight * h, Lt = Ne - We - It, _t = l.top + t.scrollTop * h - We - Math.max(0, (Lt - Ht) / 2), At = Math.max(0, t.scrollHeight * h - Ne);
|
|
985
|
+
m = Math.max(0, Math.min(_t, At)) / h;
|
|
985
986
|
}
|
|
986
|
-
const
|
|
987
|
-
let
|
|
988
|
-
|
|
989
|
-
const
|
|
990
|
-
!
|
|
991
|
-
}
|
|
992
|
-
let
|
|
993
|
-
function
|
|
994
|
-
const t =
|
|
987
|
+
const x = t.clientWidth * p, k = ee.left * p, y = ee.right * p, C = t.scrollLeft * p, E = l.left + C, V = C + k, N = C + x - y, A = 8 * p;
|
|
988
|
+
let J = t.scrollLeft;
|
|
989
|
+
E < V + A ? J = Math.max(0, (E - k - A) / p) : E > N - A && (J = Math.max(0, (E - k - x + y + A) / p));
|
|
990
|
+
const U = Math.abs(m - t.scrollTop) > 0.5, Oe = Math.abs(J - t.scrollLeft) > 0.5;
|
|
991
|
+
!U && !Oe || (U && (t.scrollTop = m), Oe && (t.scrollLeft = J), D());
|
|
992
|
+
}
|
|
993
|
+
let Se = [], Ee = "", se = 0, ge = -1, be = -1, ve = { x: 0, y: 0 };
|
|
994
|
+
function bt() {
|
|
995
|
+
const t = d.value, l = z.value;
|
|
995
996
|
if (!t || !l) return;
|
|
996
|
-
const c = t.getBoundingClientRect(),
|
|
997
|
+
const c = t.getBoundingClientRect(), p = [];
|
|
997
998
|
l.querySelectorAll("[data-start]").forEach((h) => {
|
|
998
|
-
const
|
|
999
|
-
|
|
999
|
+
const m = h.getBoundingClientRect();
|
|
1000
|
+
p.push({
|
|
1000
1001
|
start: Number(h.dataset.start),
|
|
1001
1002
|
end: Number(h.dataset.end),
|
|
1002
|
-
left:
|
|
1003
|
-
right:
|
|
1004
|
-
top:
|
|
1005
|
-
bottom:
|
|
1003
|
+
left: m.left - c.left + t.scrollLeft,
|
|
1004
|
+
right: m.right - c.left + t.scrollLeft,
|
|
1005
|
+
top: m.top - c.top + t.scrollTop,
|
|
1006
|
+
bottom: m.bottom - c.top + t.scrollTop
|
|
1006
1007
|
});
|
|
1007
|
-
}),
|
|
1008
|
+
}), Se = p;
|
|
1008
1009
|
}
|
|
1009
|
-
function
|
|
1010
|
-
for (const c of
|
|
1010
|
+
function vt(t, l) {
|
|
1011
|
+
for (const c of Se)
|
|
1011
1012
|
if (t >= c.left - 1 && t <= c.right + 1 && l >= c.top && l <= c.bottom)
|
|
1012
1013
|
return c;
|
|
1013
1014
|
return null;
|
|
1014
1015
|
}
|
|
1015
1016
|
function j() {
|
|
1016
|
-
g.value = null,
|
|
1017
|
+
g.value = null, se = 0, ge = -1, be = -1;
|
|
1017
1018
|
}
|
|
1018
|
-
function
|
|
1019
|
-
const l =
|
|
1019
|
+
function yt(t) {
|
|
1020
|
+
const l = W.value, c = d.value;
|
|
1020
1021
|
if (!l || !c) return;
|
|
1021
|
-
const
|
|
1022
|
-
let N = h,
|
|
1023
|
-
N +
|
|
1022
|
+
const p = c.getBoundingClientRect(), h = p.left + t.left - c.scrollLeft, m = p.left + t.right - c.scrollLeft, x = p.top + t.top - c.scrollTop, k = p.top + t.bottom - c.scrollTop, y = 12, C = 8, E = l.offsetWidth, V = l.offsetHeight;
|
|
1023
|
+
let N = h, A = k + C;
|
|
1024
|
+
N + E > window.innerWidth - y && (N = m - E), A + V > window.innerHeight - y && (A = x - V - C), N = Math.max(y, Math.min(N, window.innerWidth - y - E)), A = Math.max(y, A), ae.value = { left: `${N}px`, top: `${A}px` };
|
|
1024
1025
|
}
|
|
1025
|
-
function
|
|
1026
|
-
const c =
|
|
1026
|
+
function kt(t, l) {
|
|
1027
|
+
const c = d.value;
|
|
1027
1028
|
if (!c || e.readonly || !e.hover || w.value) {
|
|
1028
1029
|
j();
|
|
1029
1030
|
return;
|
|
@@ -1032,42 +1033,42 @@ const en = {
|
|
|
1032
1033
|
j();
|
|
1033
1034
|
return;
|
|
1034
1035
|
}
|
|
1035
|
-
const
|
|
1036
|
-
if (g.value &&
|
|
1037
|
-
const k =
|
|
1036
|
+
const p = W.value;
|
|
1037
|
+
if (g.value && p) {
|
|
1038
|
+
const k = p.getBoundingClientRect();
|
|
1038
1039
|
if (t >= k.left && t <= k.right && l >= k.top && l <= k.bottom)
|
|
1039
1040
|
return;
|
|
1040
1041
|
}
|
|
1041
|
-
const h = c.getBoundingClientRect(),
|
|
1042
|
-
if (!
|
|
1042
|
+
const h = c.getBoundingClientRect(), m = vt(t - h.left + c.scrollLeft, l - h.top + c.scrollTop);
|
|
1043
|
+
if (!m) {
|
|
1043
1044
|
j();
|
|
1044
1045
|
return;
|
|
1045
1046
|
}
|
|
1046
|
-
if (g.value &&
|
|
1047
|
+
if (g.value && ge === m.start && be === m.end)
|
|
1047
1048
|
return;
|
|
1048
|
-
const x =
|
|
1049
|
-
completions:
|
|
1050
|
-
declared:
|
|
1049
|
+
const x = Yt(c.value, m.start, m.end, {
|
|
1050
|
+
completions: fe.value,
|
|
1051
|
+
declared: Ke(c.value, m.start)
|
|
1051
1052
|
});
|
|
1052
1053
|
if (!x) {
|
|
1053
1054
|
j();
|
|
1054
1055
|
return;
|
|
1055
1056
|
}
|
|
1056
|
-
g.value = x,
|
|
1057
|
+
g.value = x, ge = m.start, be = m.end, P(() => yt(m));
|
|
1057
1058
|
}
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1059
|
+
function wt(t) {
|
|
1060
|
+
ve = { x: t.clientX, y: t.clientY }, !se && (se = requestAnimationFrame(() => {
|
|
1061
|
+
se = 0, kt(ve.x, ve.y);
|
|
1061
1062
|
}));
|
|
1062
1063
|
}
|
|
1063
|
-
function
|
|
1064
|
-
const t =
|
|
1064
|
+
function Re() {
|
|
1065
|
+
const t = d.value;
|
|
1065
1066
|
if (!t) return null;
|
|
1066
|
-
const l = window.getComputedStyle(t), c = document.createElement("div"),
|
|
1067
|
+
const l = window.getComputedStyle(t), c = document.createElement("div"), p = parseFloat(l.paddingLeft) || 0, h = parseFloat(l.paddingRight) || 0, m = t.getBoundingClientRect();
|
|
1067
1068
|
Object.assign(c.style, {
|
|
1068
1069
|
position: "fixed",
|
|
1069
|
-
left: `${
|
|
1070
|
-
top: `${
|
|
1070
|
+
left: `${m.left}px`,
|
|
1071
|
+
top: `${m.top}px`,
|
|
1071
1072
|
visibility: "hidden",
|
|
1072
1073
|
pointerEvents: "none",
|
|
1073
1074
|
zIndex: "-1",
|
|
@@ -1075,7 +1076,7 @@ const en = {
|
|
|
1075
1076
|
overflowWrap: l.overflowWrap,
|
|
1076
1077
|
wordBreak: l.wordBreak,
|
|
1077
1078
|
boxSizing: "content-box",
|
|
1078
|
-
width: `${t.clientWidth -
|
|
1079
|
+
width: `${t.clientWidth - p - h}px`,
|
|
1079
1080
|
paddingTop: l.paddingTop,
|
|
1080
1081
|
paddingRight: l.paddingRight,
|
|
1081
1082
|
paddingBottom: l.paddingBottom,
|
|
@@ -1095,295 +1096,298 @@ const en = {
|
|
|
1095
1096
|
x.textContent = "", c.appendChild(x), document.body.appendChild(c);
|
|
1096
1097
|
const k = x.getBoundingClientRect();
|
|
1097
1098
|
document.body.removeChild(c);
|
|
1098
|
-
const
|
|
1099
|
+
const y = parseFloat(l.lineHeight) || 22, C = k.height, E = C > 0 && C < y ? (y - C) / 2 : 0;
|
|
1099
1100
|
return {
|
|
1100
|
-
left: k.left -
|
|
1101
|
-
top: k.top -
|
|
1102
|
-
lineHeight:
|
|
1101
|
+
left: k.left - m.left - t.scrollLeft,
|
|
1102
|
+
top: k.top - m.top - t.scrollTop - E,
|
|
1103
|
+
lineHeight: y
|
|
1103
1104
|
};
|
|
1104
1105
|
}
|
|
1105
1106
|
async function Me() {
|
|
1106
|
-
await
|
|
1107
|
-
const t = $.value, l =
|
|
1107
|
+
await P();
|
|
1108
|
+
const t = $.value, l = v.value, c = Re();
|
|
1108
1109
|
if (!t || !l || !c) return;
|
|
1109
|
-
const
|
|
1110
|
-
let
|
|
1111
|
-
k.left +
|
|
1112
|
-
left: `${
|
|
1113
|
-
top: `${
|
|
1110
|
+
const p = 4, h = 8, m = window.innerWidth, x = window.innerHeight, k = t.getBoundingClientRect(), y = l.scrollHeight, C = x - (k.top + c.top + c.lineHeight) - p - h, E = k.top + c.top - p - h, V = C >= Math.min(y, 180) || C >= E, N = Math.min(248, Math.max(V ? C : E, 96)), A = Math.min(y, N), J = l.offsetWidth || 280;
|
|
1111
|
+
let U = c.left;
|
|
1112
|
+
k.left + U + J > m - h && (U = m - h - J - k.left), U = Math.max(U, h - k.left), L.value = {
|
|
1113
|
+
left: `${U}px`,
|
|
1114
|
+
top: `${V ? c.top + c.lineHeight + p : c.top - p - A}px`,
|
|
1114
1115
|
maxHeight: `${N}px`
|
|
1115
1116
|
};
|
|
1116
1117
|
}
|
|
1117
|
-
function
|
|
1118
|
-
w.value = !1,
|
|
1118
|
+
function _() {
|
|
1119
|
+
w.value = !1, O.value = [], M.value = 0, j();
|
|
1119
1120
|
}
|
|
1120
|
-
function
|
|
1121
|
+
function ne(t = !1) {
|
|
1121
1122
|
var k;
|
|
1122
|
-
const l =
|
|
1123
|
+
const l = d.value;
|
|
1123
1124
|
if (!l || e.readonly) return;
|
|
1124
1125
|
if (l.selectionStart !== l.selectionEnd) {
|
|
1125
|
-
|
|
1126
|
+
_();
|
|
1126
1127
|
return;
|
|
1127
1128
|
}
|
|
1128
1129
|
const c = l.selectionStart;
|
|
1129
|
-
let
|
|
1130
|
-
const h =
|
|
1130
|
+
let p = !t;
|
|
1131
|
+
const h = jt(l.value, c);
|
|
1131
1132
|
if (h) {
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1134
|
-
const
|
|
1135
|
-
label: `${
|
|
1133
|
+
const y = (k = ct.value.get(h.functionName)) == null ? void 0 : k.params[h.paramIndex], C = (y == null ? void 0 : y.literals) ?? [];
|
|
1134
|
+
if (C.length) {
|
|
1135
|
+
const E = h.quote ?? "'", V = C.map((A) => ({
|
|
1136
|
+
label: `${E}${A}${E}`,
|
|
1136
1137
|
kind: "value",
|
|
1137
|
-
detail:
|
|
1138
|
-
insertText: `${
|
|
1139
|
-
})), N =
|
|
1138
|
+
detail: y == null ? void 0 : y.type,
|
|
1139
|
+
insertText: `${E}${A}${E}`
|
|
1140
|
+
})), N = lt(V, h.prefix);
|
|
1140
1141
|
if (N.length) {
|
|
1141
|
-
|
|
1142
|
+
O.value = N, T.value = { start: h.replaceStart, end: c }, M.value = 0, w.value = !0, Me();
|
|
1142
1143
|
return;
|
|
1143
1144
|
}
|
|
1144
1145
|
}
|
|
1145
1146
|
}
|
|
1146
1147
|
if (e.mode === "template") {
|
|
1147
|
-
const
|
|
1148
|
+
const y = we(
|
|
1148
1149
|
l.value,
|
|
1149
1150
|
c,
|
|
1150
1151
|
e.templateOpen,
|
|
1151
1152
|
e.templateClose
|
|
1152
1153
|
);
|
|
1153
|
-
if (!
|
|
1154
|
-
|
|
1154
|
+
if (!y) {
|
|
1155
|
+
_();
|
|
1155
1156
|
return;
|
|
1156
1157
|
}
|
|
1157
|
-
t && l.value.slice(
|
|
1158
|
+
t && l.value.slice(y.start, c).trim() === "" && (p = !0);
|
|
1158
1159
|
}
|
|
1159
|
-
const
|
|
1160
|
+
const m = Zt(l.value, c, {
|
|
1160
1161
|
language: e.language,
|
|
1161
|
-
completions:
|
|
1162
|
-
declared:
|
|
1163
|
-
auto: !
|
|
1162
|
+
completions: fe.value,
|
|
1163
|
+
declared: Ke(l.value, c),
|
|
1164
|
+
auto: !p
|
|
1164
1165
|
});
|
|
1165
|
-
if (!
|
|
1166
|
-
|
|
1166
|
+
if (!m) {
|
|
1167
|
+
_();
|
|
1167
1168
|
return;
|
|
1168
1169
|
}
|
|
1169
|
-
let x =
|
|
1170
|
+
let x = m.items;
|
|
1170
1171
|
if (e.completionFilter) {
|
|
1171
|
-
const
|
|
1172
|
+
const y = tt(l.value, c);
|
|
1172
1173
|
if (x = e.completionFilter(x, {
|
|
1173
|
-
prefix:
|
|
1174
|
-
chain:
|
|
1174
|
+
prefix: y.prefix,
|
|
1175
|
+
chain: y.chain,
|
|
1175
1176
|
text: l.value,
|
|
1176
1177
|
position: c,
|
|
1177
1178
|
mode: e.mode,
|
|
1178
1179
|
language: e.language
|
|
1179
1180
|
}), x.length === 0) {
|
|
1180
|
-
|
|
1181
|
+
_();
|
|
1181
1182
|
return;
|
|
1182
1183
|
}
|
|
1183
1184
|
}
|
|
1184
|
-
|
|
1185
|
+
O.value = x, T.value = { start: m.start, end: m.end }, M.value = 0, w.value = !0, Me();
|
|
1185
1186
|
}
|
|
1186
|
-
function
|
|
1187
|
+
function xt(t) {
|
|
1187
1188
|
a.value = t, i("update:modelValue", t), i("change", t);
|
|
1188
1189
|
}
|
|
1189
|
-
function
|
|
1190
|
-
const h =
|
|
1190
|
+
function re(t, l, c, p = t + c.length) {
|
|
1191
|
+
const h = d.value;
|
|
1191
1192
|
if (!h) return;
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
h.value =
|
|
1193
|
+
const m = h.value.slice(0, t) + c + h.value.slice(l);
|
|
1194
|
+
xt(m), _(), P(() => {
|
|
1195
|
+
h.value = m, h.setSelectionRange(p, p), h.focus(), D(!0), X();
|
|
1195
1196
|
});
|
|
1196
1197
|
}
|
|
1197
|
-
function
|
|
1198
|
+
function Ie(t = O.value[M.value]) {
|
|
1198
1199
|
if (!t) return;
|
|
1199
1200
|
const l = t.insertText ?? t.label;
|
|
1200
|
-
|
|
1201
|
+
re(T.value.start, T.value.end, l), _();
|
|
1201
1202
|
}
|
|
1202
|
-
function
|
|
1203
|
-
const l =
|
|
1204
|
-
l && (M.value = (M.value + t + l) % l,
|
|
1205
|
-
var c,
|
|
1206
|
-
(
|
|
1203
|
+
function He(t) {
|
|
1204
|
+
const l = O.value.length;
|
|
1205
|
+
l && (M.value = (M.value + t + l) % l, P(() => {
|
|
1206
|
+
var c, p;
|
|
1207
|
+
(p = (c = v.value) == null ? void 0 : c.querySelector(".is-active")) == null || p.scrollIntoView({ block: "nearest" });
|
|
1207
1208
|
}));
|
|
1208
1209
|
}
|
|
1209
|
-
function
|
|
1210
|
+
function $t(t) {
|
|
1210
1211
|
const l = t.target;
|
|
1211
|
-
a.value = l.value, i("update:modelValue", l.value), i("change", l.value), j(),
|
|
1212
|
+
a.value = l.value, i("update:modelValue", l.value), i("change", l.value), j(), D(), X(), P(X), ne(!0);
|
|
1212
1213
|
}
|
|
1213
|
-
function
|
|
1214
|
-
if (
|
|
1214
|
+
function Tt(t) {
|
|
1215
|
+
if (_(), j(), !e.collapsible || !e.collapseOnBlur || !F.value) return;
|
|
1215
1216
|
const l = t.relatedTarget;
|
|
1216
|
-
l && l.closest(".expand-toggle") ||
|
|
1217
|
+
l && l.closest(".expand-toggle") || Te(!1);
|
|
1217
1218
|
}
|
|
1218
|
-
function
|
|
1219
|
-
Le(),
|
|
1219
|
+
function Ct() {
|
|
1220
|
+
Le(), X();
|
|
1220
1221
|
}
|
|
1221
1222
|
function Le() {
|
|
1222
|
-
const t =
|
|
1223
|
+
const t = d.value;
|
|
1223
1224
|
if (!t || e.readonly) return;
|
|
1224
1225
|
if (t.selectionStart !== t.selectionEnd) {
|
|
1225
|
-
|
|
1226
|
+
_();
|
|
1226
1227
|
return;
|
|
1227
1228
|
}
|
|
1228
1229
|
const l = t.selectionStart;
|
|
1229
1230
|
if (l > 0 && t.value[l - 1] === ".") {
|
|
1230
|
-
|
|
1231
|
+
ne(!0);
|
|
1231
1232
|
return;
|
|
1232
1233
|
}
|
|
1233
1234
|
if (e.mode === "template") {
|
|
1234
|
-
const c =
|
|
1235
|
+
const c = we(
|
|
1235
1236
|
t.value,
|
|
1236
1237
|
l,
|
|
1237
1238
|
e.templateOpen,
|
|
1238
1239
|
e.templateClose
|
|
1239
1240
|
);
|
|
1240
1241
|
if (c && t.value.slice(c.start, l).trim() === "") {
|
|
1241
|
-
|
|
1242
|
+
ne(!0);
|
|
1242
1243
|
return;
|
|
1243
1244
|
}
|
|
1244
1245
|
}
|
|
1245
|
-
|
|
1246
|
+
_();
|
|
1246
1247
|
}
|
|
1247
|
-
let
|
|
1248
|
+
let ye = 0;
|
|
1248
1249
|
function _e() {
|
|
1249
|
-
window.clearTimeout(
|
|
1250
|
-
|
|
1250
|
+
window.clearTimeout(ye), ye = window.setTimeout(() => {
|
|
1251
|
+
ye = 0, Le(), X();
|
|
1251
1252
|
}, 0);
|
|
1252
1253
|
}
|
|
1253
|
-
function
|
|
1254
|
-
t.target !==
|
|
1254
|
+
function Ae(t) {
|
|
1255
|
+
t.target !== d.value && w.value && _();
|
|
1255
1256
|
}
|
|
1256
|
-
function
|
|
1257
|
-
j(),
|
|
1257
|
+
function St() {
|
|
1258
|
+
j(), D(), me.value && Et();
|
|
1258
1259
|
}
|
|
1259
|
-
let
|
|
1260
|
-
function
|
|
1261
|
-
window.clearTimeout(
|
|
1262
|
-
|
|
1260
|
+
let ke = 0;
|
|
1261
|
+
function Et() {
|
|
1262
|
+
window.clearTimeout(ke), ke = window.setTimeout(() => {
|
|
1263
|
+
ke = 0, Rt();
|
|
1263
1264
|
}, 120);
|
|
1264
1265
|
}
|
|
1265
|
-
function
|
|
1266
|
-
const t =
|
|
1266
|
+
function Rt() {
|
|
1267
|
+
const t = d.value;
|
|
1267
1268
|
if (!t) return;
|
|
1268
|
-
const l =
|
|
1269
|
-
Math.abs(
|
|
1269
|
+
const l = ee.lineHeight, c = t.scrollTop, p = Math.round(c / l) * l;
|
|
1270
|
+
Math.abs(p - c) < 0.5 || (t.scrollTop = p, D());
|
|
1270
1271
|
}
|
|
1271
|
-
function
|
|
1272
|
+
function Mt(t) {
|
|
1272
1273
|
var h;
|
|
1273
|
-
const l =
|
|
1274
|
+
const l = d.value;
|
|
1274
1275
|
if (!l) return;
|
|
1275
|
-
const c = t.metaKey || t.ctrlKey,
|
|
1276
|
+
const c = t.metaKey || t.ctrlKey, p = u.has(t.key);
|
|
1276
1277
|
if (t.key === " " && c) {
|
|
1277
|
-
t.preventDefault(),
|
|
1278
|
+
t.preventDefault(), ne(!1);
|
|
1278
1279
|
return;
|
|
1279
1280
|
}
|
|
1280
1281
|
if (w.value) {
|
|
1281
1282
|
if (t.key === "ArrowDown") {
|
|
1282
|
-
t.preventDefault(),
|
|
1283
|
+
t.preventDefault(), He(1);
|
|
1283
1284
|
return;
|
|
1284
1285
|
}
|
|
1285
1286
|
if (t.key === "ArrowUp") {
|
|
1286
|
-
t.preventDefault(),
|
|
1287
|
+
t.preventDefault(), He(-1);
|
|
1287
1288
|
return;
|
|
1288
1289
|
}
|
|
1289
1290
|
if (t.key === "Enter" || t.key === "Tab") {
|
|
1290
|
-
t.preventDefault(),
|
|
1291
|
+
t.preventDefault(), Ie();
|
|
1291
1292
|
return;
|
|
1292
1293
|
}
|
|
1293
1294
|
if (t.key === "Escape") {
|
|
1294
|
-
t.preventDefault(),
|
|
1295
|
+
t.preventDefault(), _();
|
|
1295
1296
|
return;
|
|
1296
1297
|
}
|
|
1297
|
-
if (
|
|
1298
|
-
|
|
1298
|
+
if (p || c) {
|
|
1299
|
+
_(), p && !c && _e();
|
|
1299
1300
|
return;
|
|
1300
1301
|
}
|
|
1301
1302
|
}
|
|
1302
|
-
if (
|
|
1303
|
+
if (p && !c) {
|
|
1303
1304
|
_e();
|
|
1304
1305
|
return;
|
|
1305
1306
|
}
|
|
1306
1307
|
if (t.key === "Enter" && !c && !t.shiftKey) {
|
|
1307
|
-
const
|
|
1308
|
-
if (
|
|
1308
|
+
const m = l.selectionStart;
|
|
1309
|
+
if (m !== l.selectionEnd) return;
|
|
1309
1310
|
const x = l.value.lastIndexOf(`
|
|
1310
|
-
`,
|
|
1311
|
-
t.preventDefault(),
|
|
1312
|
-
${
|
|
1311
|
+
`, m - 1) + 1, k = l.value.slice(x, m), y = ((h = k.match(/^[ \t]*/)) == null ? void 0 : h[0]) ?? "", C = /[{[(]$/.test(k.trimEnd()) ? " " : "";
|
|
1312
|
+
t.preventDefault(), re(m, m, `
|
|
1313
|
+
${y}${C}`);
|
|
1313
1314
|
return;
|
|
1314
1315
|
}
|
|
1315
1316
|
if (t.key === "Tab") {
|
|
1316
|
-
t.preventDefault(),
|
|
1317
|
+
t.preventDefault(), re(l.selectionStart, l.selectionEnd, " ");
|
|
1317
1318
|
return;
|
|
1318
1319
|
}
|
|
1319
|
-
if (t.key.length === 1 && !c && !t.altKey &&
|
|
1320
|
+
if (t.key.length === 1 && !c && !t.altKey && f[t.key]) {
|
|
1320
1321
|
if (l.selectionStart !== l.selectionEnd) return;
|
|
1321
|
-
const
|
|
1322
|
+
const m = l.selectionStart, x = l.value[m - 1], k = l.value[m];
|
|
1322
1323
|
if ((t.key === '"' || t.key === "'") && x && /[\w$]/.test(x) || k !== void 0 && !/[\s)\]},;:]/.test(k)) return;
|
|
1323
|
-
t.preventDefault(),
|
|
1324
|
+
t.preventDefault(), re(m, m, t.key + f[t.key], m + 1), e.mode === "template" && P(() => ne(!0));
|
|
1324
1325
|
}
|
|
1325
1326
|
}
|
|
1326
|
-
function
|
|
1327
|
-
w.value &&
|
|
1328
|
-
|
|
1327
|
+
function Be() {
|
|
1328
|
+
w.value && _(), j(), P(() => {
|
|
1329
|
+
he(), D(!0);
|
|
1329
1330
|
});
|
|
1330
1331
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1332
|
+
let te = null;
|
|
1333
|
+
return Ot(() => {
|
|
1334
|
+
window.addEventListener("resize", Be), window.addEventListener("scroll", Ae, !0), P(() => {
|
|
1335
|
+
he(), D(!0);
|
|
1336
|
+
}), typeof ResizeObserver < "u" && d.value && (te = new ResizeObserver(() => {
|
|
1337
|
+
D(!0), X();
|
|
1338
|
+
}), te.observe(d.value));
|
|
1339
|
+
}), Nt(() => {
|
|
1340
|
+
window.removeEventListener("resize", Be), window.removeEventListener("scroll", Ae, !0), te == null || te.disconnect(), te = null;
|
|
1337
1341
|
}), s({ focus: () => {
|
|
1338
1342
|
var t;
|
|
1339
|
-
return (t =
|
|
1340
|
-
} }), (t, l) => (I(),
|
|
1341
|
-
class:
|
|
1342
|
-
style:
|
|
1343
|
+
return (t = d.value) == null ? void 0 : t.focus();
|
|
1344
|
+
} }), (t, l) => (I(), H("div", {
|
|
1345
|
+
class: le(["code-input", { "is-collapsible": n.collapsible }]),
|
|
1346
|
+
style: ce(ft.value)
|
|
1343
1347
|
}, [
|
|
1344
|
-
|
|
1345
|
-
class:
|
|
1348
|
+
B("div", {
|
|
1349
|
+
class: le(["code-editor", {
|
|
1346
1350
|
"is-readonly": n.readonly,
|
|
1347
1351
|
"is-dark": n.theme === "dark",
|
|
1348
|
-
"is-collapsed":
|
|
1349
|
-
"is-expanding":
|
|
1352
|
+
"is-collapsed": me.value,
|
|
1353
|
+
"is-expanding": pe.value
|
|
1350
1354
|
}]),
|
|
1351
|
-
style:
|
|
1352
|
-
onAnimationend:
|
|
1355
|
+
style: ce(pt.value),
|
|
1356
|
+
onAnimationend: De(mt, ["self"])
|
|
1353
1357
|
}, [
|
|
1354
|
-
n.lineNumbers ? (I(),
|
|
1355
|
-
|
|
1358
|
+
n.lineNumbers ? (I(), H("div", un, [
|
|
1359
|
+
B("div", {
|
|
1356
1360
|
ref_key: "gutterInner",
|
|
1357
1361
|
ref: b,
|
|
1358
1362
|
class: "gutter-inner code-font"
|
|
1359
1363
|
}, [
|
|
1360
|
-
(I(!0),
|
|
1364
|
+
(I(!0), H(je, null, Fe(dt.value, (c) => (I(), H("div", {
|
|
1361
1365
|
key: c,
|
|
1362
1366
|
class: "gutter-line"
|
|
1363
1367
|
}, Y(c), 1))), 128))
|
|
1364
1368
|
], 512)
|
|
1365
|
-
])) :
|
|
1366
|
-
|
|
1369
|
+
])) : K("", !0),
|
|
1370
|
+
B("div", {
|
|
1367
1371
|
ref_key: "stage",
|
|
1368
1372
|
ref: $,
|
|
1369
1373
|
class: "stage"
|
|
1370
1374
|
}, [
|
|
1371
|
-
|
|
1375
|
+
B("div", {
|
|
1372
1376
|
ref_key: "highlightLayer",
|
|
1373
1377
|
ref: z,
|
|
1374
1378
|
class: "highlight code-font"
|
|
1375
1379
|
}, [
|
|
1376
|
-
|
|
1380
|
+
B("pre", {
|
|
1377
1381
|
ref_key: "highlightInner",
|
|
1378
|
-
ref:
|
|
1382
|
+
ref: S,
|
|
1379
1383
|
class: "code-font"
|
|
1380
1384
|
}, [
|
|
1381
|
-
|
|
1385
|
+
B("code", { innerHTML: ut.value }, null, 8, dn)
|
|
1382
1386
|
], 512)
|
|
1383
1387
|
], 512),
|
|
1384
|
-
|
|
1388
|
+
B("textarea", {
|
|
1385
1389
|
ref_key: "textarea",
|
|
1386
|
-
ref:
|
|
1390
|
+
ref: d,
|
|
1387
1391
|
class: "code-font input",
|
|
1388
1392
|
value: a.value,
|
|
1389
1393
|
readonly: n.readonly,
|
|
@@ -1393,71 +1397,71 @@ ${v}${S}`);
|
|
|
1393
1397
|
autocapitalize: "off",
|
|
1394
1398
|
autocorrect: "off",
|
|
1395
1399
|
wrap: "off",
|
|
1396
|
-
onInput:
|
|
1397
|
-
onKeydown:
|
|
1398
|
-
onScroll:
|
|
1399
|
-
onClick:
|
|
1400
|
-
onMousemove:
|
|
1400
|
+
onInput: $t,
|
|
1401
|
+
onKeydown: Mt,
|
|
1402
|
+
onScroll: St,
|
|
1403
|
+
onClick: Ct,
|
|
1404
|
+
onMousemove: wt,
|
|
1401
1405
|
onMouseleave: j,
|
|
1402
|
-
onBlur:
|
|
1403
|
-
}, null, 40,
|
|
1404
|
-
w.value ? (I(),
|
|
1406
|
+
onBlur: Tt
|
|
1407
|
+
}, null, 40, fn),
|
|
1408
|
+
w.value ? (I(), H("ul", {
|
|
1405
1409
|
key: 0,
|
|
1406
1410
|
ref_key: "popup",
|
|
1407
|
-
ref:
|
|
1411
|
+
ref: v,
|
|
1408
1412
|
class: "popup",
|
|
1409
|
-
style:
|
|
1410
|
-
onMousedown: l[0] || (l[0] =
|
|
1413
|
+
style: ce(L.value),
|
|
1414
|
+
onMousedown: l[0] || (l[0] = De(() => {
|
|
1411
1415
|
}, ["prevent"]))
|
|
1412
1416
|
}, [
|
|
1413
|
-
(I(!0),
|
|
1414
|
-
key: `${c.label}-${
|
|
1415
|
-
class:
|
|
1416
|
-
onMouseenter: (h) => M.value =
|
|
1417
|
-
onClick: (h) =>
|
|
1417
|
+
(I(!0), H(je, null, Fe(O.value, (c, p) => (I(), H("li", {
|
|
1418
|
+
key: `${c.label}-${p}`,
|
|
1419
|
+
class: le(["popup-item", { "is-active": p === M.value }]),
|
|
1420
|
+
onMouseenter: (h) => M.value = p,
|
|
1421
|
+
onClick: (h) => Ie(c)
|
|
1418
1422
|
}, [
|
|
1419
|
-
|
|
1420
|
-
class:
|
|
1421
|
-
}, Y(
|
|
1422
|
-
|
|
1423
|
-
c.detail ? (I(),
|
|
1424
|
-
], 42,
|
|
1425
|
-
], 36)) :
|
|
1426
|
-
g.value ? (I(),
|
|
1423
|
+
B("span", {
|
|
1424
|
+
class: le(["badge", `badge-${c.kind}`])
|
|
1425
|
+
}, Y(Ce(c.kind)), 3),
|
|
1426
|
+
B("span", mn, Y(c.label), 1),
|
|
1427
|
+
c.detail ? (I(), H("span", hn, Y(c.detail), 1)) : K("", !0)
|
|
1428
|
+
], 42, pn))), 128))
|
|
1429
|
+
], 36)) : K("", !0),
|
|
1430
|
+
g.value ? (I(), H("div", {
|
|
1427
1431
|
key: 1,
|
|
1428
1432
|
ref_key: "hoverCard",
|
|
1429
|
-
ref:
|
|
1433
|
+
ref: W,
|
|
1430
1434
|
class: "hover-card",
|
|
1431
|
-
style:
|
|
1435
|
+
style: ce(ae.value)
|
|
1432
1436
|
}, [
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
class:
|
|
1436
|
-
}, Y(
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
g.value.detail ? (I(),
|
|
1437
|
+
B("div", gn, [
|
|
1438
|
+
B("span", {
|
|
1439
|
+
class: le(["badge", `badge-${g.value.kind}`])
|
|
1440
|
+
}, Y(Ce(g.value.kind)), 3),
|
|
1441
|
+
B("span", bn, [
|
|
1442
|
+
Wt(Y(g.value.label), 1),
|
|
1443
|
+
g.value.detail ? (I(), H("span", vn, ":")) : K("", !0)
|
|
1440
1444
|
]),
|
|
1441
|
-
g.value.detail ? (I(),
|
|
1445
|
+
g.value.detail ? (I(), H("span", yn, Y(g.value.detail), 1)) : K("", !0)
|
|
1442
1446
|
]),
|
|
1443
|
-
g.value.documentation ? (I(),
|
|
1444
|
-
g.value.type ? (I(),
|
|
1445
|
-
|
|
1446
|
-
innerHTML:
|
|
1447
|
-
}, null, 8,
|
|
1448
|
-
])) :
|
|
1449
|
-
], 4)) :
|
|
1447
|
+
g.value.documentation ? (I(), H("p", kn, Y(g.value.documentation), 1)) : K("", !0),
|
|
1448
|
+
g.value.type ? (I(), H("pre", wn, [
|
|
1449
|
+
B("code", {
|
|
1450
|
+
innerHTML: gt(g.value.type)
|
|
1451
|
+
}, null, 8, xn)
|
|
1452
|
+
])) : K("", !0)
|
|
1453
|
+
], 4)) : K("", !0)
|
|
1450
1454
|
], 512),
|
|
1451
|
-
n.collapsible ? (I(),
|
|
1455
|
+
n.collapsible ? (I(), H("button", {
|
|
1452
1456
|
key: 1,
|
|
1453
1457
|
type: "button",
|
|
1454
1458
|
class: "expand-toggle",
|
|
1455
1459
|
title: F.value ? "收起" : "展开",
|
|
1456
1460
|
"aria-label": F.value ? "收起编辑器" : "展开编辑器",
|
|
1457
|
-
onClick:
|
|
1461
|
+
onClick: ht
|
|
1458
1462
|
}, [
|
|
1459
|
-
F.value ? (I(),
|
|
1460
|
-
|
|
1463
|
+
F.value ? (I(), H("svg", Cn, [...l[2] || (l[2] = [
|
|
1464
|
+
B("path", {
|
|
1461
1465
|
d: "M11 2 5 8 11 14",
|
|
1462
1466
|
fill: "none",
|
|
1463
1467
|
stroke: "currentColor",
|
|
@@ -1465,8 +1469,8 @@ ${v}${S}`);
|
|
|
1465
1469
|
"stroke-linecap": "round",
|
|
1466
1470
|
"stroke-linejoin": "round"
|
|
1467
1471
|
}, null, -1)
|
|
1468
|
-
])])) : (I(),
|
|
1469
|
-
|
|
1472
|
+
])])) : (I(), H("svg", Tn, [...l[1] || (l[1] = [
|
|
1473
|
+
B("path", {
|
|
1470
1474
|
d: "M6 2 12 8 6 14",
|
|
1471
1475
|
fill: "none",
|
|
1472
1476
|
stroke: "currentColor",
|
|
@@ -1475,35 +1479,35 @@ ${v}${S}`);
|
|
|
1475
1479
|
"stroke-linejoin": "round"
|
|
1476
1480
|
}, null, -1)
|
|
1477
1481
|
])]))
|
|
1478
|
-
], 8,
|
|
1482
|
+
], 8, $n)) : K("", !0)
|
|
1479
1483
|
], 38)
|
|
1480
1484
|
], 6));
|
|
1481
1485
|
}
|
|
1482
|
-
}),
|
|
1486
|
+
}), En = (n, s) => {
|
|
1483
1487
|
const o = n.__vccOpts || n;
|
|
1484
1488
|
for (const [e, i] of s)
|
|
1485
1489
|
o[e] = i;
|
|
1486
1490
|
return o;
|
|
1487
|
-
},
|
|
1491
|
+
}, Rn = /* @__PURE__ */ En(Sn, [["__scopeId", "data-v-8af715cf"]]), Ln = {
|
|
1488
1492
|
install(n) {
|
|
1489
|
-
n.component("CodeInput",
|
|
1493
|
+
n.component("CodeInput", Rn);
|
|
1490
1494
|
}
|
|
1491
1495
|
};
|
|
1492
1496
|
export {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1497
|
+
Rn as CodeEditor,
|
|
1498
|
+
Zt as collectCompletions,
|
|
1499
|
+
Ln as default,
|
|
1500
|
+
zt as defaultCompletions,
|
|
1501
|
+
jt as findArgumentContext,
|
|
1502
|
+
we as findTemplateRange,
|
|
1503
|
+
Ve as getKeywordSet,
|
|
1504
|
+
et as getKeywords,
|
|
1505
|
+
de as highlight,
|
|
1506
|
+
cn as highlightTemplate,
|
|
1507
|
+
Hn as isInsideTemplate,
|
|
1508
|
+
ln as parseTsCompletions,
|
|
1509
|
+
on as parseTsSignatures,
|
|
1510
|
+
Yt as resolveHoverItem,
|
|
1511
|
+
Ke as scanDeclarations,
|
|
1512
|
+
ue as tokenize
|
|
1509
1513
|
};
|