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