lone-format 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{index-DfjCsqDT.js → index-5wbkWClK.js} +350 -349
- package/dist/_chunks/{index-13rwh2MK.js → index-AlOFzpXl.js} +203 -196
- package/dist/_chunks/{index-DvNM7Tl4.js → index-BAEkF-Fh.js} +633 -632
- package/dist/components/JsonFormat/index.js +1 -1
- package/dist/components/JsonFormat/index.vue.d.ts +1 -0
- package/dist/components/JsonFormat/types.d.ts +1 -0
- package/dist/components/SqlFormat/index.js +1 -1
- package/dist/components/SqlFormat/index.vue.d.ts +1 -0
- package/dist/components/SqlFormat/types.d.ts +1 -0
- package/dist/components/XmlFormat/index.js +2 -2
- package/dist/components/XmlFormat/index.vue.d.ts +1 -0
- package/dist/components/XmlFormat/types.d.ts +1 -0
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +3 -3
- package/dist/lone-format.umd.cjs +50 -50
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { format as
|
|
3
|
-
import { _ as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as H, computed as q, resolveComponent as Q, createElementBlock as S, openBlock as N, createElementVNode as _, createCommentVNode as G, normalizeClass as $, Fragment as A, renderList as P, createBlock as W, useCssVars as z, ref as R, watch as V, toDisplayString as Y } from "vue";
|
|
2
|
+
import { format as D } from "sql-formatter";
|
|
3
|
+
import { _ as F } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
4
|
+
const X = {
|
|
5
5
|
name: "github-light",
|
|
6
6
|
colors: {
|
|
7
7
|
// 背景色
|
|
@@ -51,7 +51,7 @@ const Y = {
|
|
|
51
51
|
indentLine: "#d0d7de"
|
|
52
52
|
// 对齐线 - 灰色
|
|
53
53
|
}
|
|
54
|
-
},
|
|
54
|
+
}, Z = {
|
|
55
55
|
name: "github-dark",
|
|
56
56
|
colors: {
|
|
57
57
|
// 背景色
|
|
@@ -101,7 +101,7 @@ const Y = {
|
|
|
101
101
|
indentLine: "#30363d"
|
|
102
102
|
// 对齐线 - 灰色
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, ee = {
|
|
105
105
|
name: "min-light",
|
|
106
106
|
colors: {
|
|
107
107
|
// 背景色 - 纯白简洁
|
|
@@ -151,7 +151,7 @@ const Y = {
|
|
|
151
151
|
indentLine: "#e5e7eb"
|
|
152
152
|
// 对齐线 - 灰色
|
|
153
153
|
}
|
|
154
|
-
},
|
|
154
|
+
}, te = {
|
|
155
155
|
name: "slack-ochin",
|
|
156
156
|
colors: {
|
|
157
157
|
// 背景色
|
|
@@ -201,12 +201,12 @@ const Y = {
|
|
|
201
201
|
indentLine: "#3e4348"
|
|
202
202
|
// 对齐线 - 灰色
|
|
203
203
|
}
|
|
204
|
-
},
|
|
205
|
-
"github-light":
|
|
206
|
-
"github-dark":
|
|
207
|
-
"min-light":
|
|
208
|
-
"slack-ochin":
|
|
209
|
-
},
|
|
204
|
+
}, M = {
|
|
205
|
+
"github-light": X,
|
|
206
|
+
"github-dark": Z,
|
|
207
|
+
"min-light": ee,
|
|
208
|
+
"slack-ochin": te
|
|
209
|
+
}, se = (o) => M[o] || M["github-light"], K = [
|
|
210
210
|
"SELECT",
|
|
211
211
|
"FROM",
|
|
212
212
|
"WHERE",
|
|
@@ -254,7 +254,7 @@ const Y = {
|
|
|
254
254
|
"THEN",
|
|
255
255
|
"ELSE",
|
|
256
256
|
"END"
|
|
257
|
-
],
|
|
257
|
+
], ne = [
|
|
258
258
|
"WITH",
|
|
259
259
|
"SELECT",
|
|
260
260
|
"FROM",
|
|
@@ -281,23 +281,23 @@ const Y = {
|
|
|
281
281
|
"UNION",
|
|
282
282
|
"INTERSECT",
|
|
283
283
|
"EXCEPT"
|
|
284
|
-
],
|
|
284
|
+
], re = (o) => {
|
|
285
285
|
try {
|
|
286
286
|
if (!o || !o.trim())
|
|
287
287
|
return { valid: !1, error: "SQL string is empty" };
|
|
288
288
|
const s = o.toUpperCase().trim();
|
|
289
|
-
if (!
|
|
289
|
+
if (!K.some((t) => new RegExp(`\\b${t}\\b`).test(s)))
|
|
290
290
|
return { valid: !1, error: "No valid SQL keywords found" };
|
|
291
|
-
let
|
|
291
|
+
let d = 0, n = !1, u = "";
|
|
292
292
|
for (let t = 0; t < o.length; t++) {
|
|
293
|
-
const
|
|
294
|
-
if ((
|
|
293
|
+
const i = o[t], m = t > 0 ? o[t - 1] : "";
|
|
294
|
+
if ((i === "'" || i === '"') && m !== "\\" && (n ? i === u && (n = !1, u = "") : (n = !0, u = i)), !n && (i === "(" && d++, i === ")" && d--, d < 0))
|
|
295
295
|
return { valid: !1, error: "Mismatched parentheses: unexpected closing parenthesis" };
|
|
296
296
|
}
|
|
297
|
-
if (
|
|
298
|
-
return { valid: !1, error: `Mismatched parentheses: ${
|
|
297
|
+
if (d !== 0)
|
|
298
|
+
return { valid: !1, error: `Mismatched parentheses: ${d} unclosed opening parenthesis` };
|
|
299
299
|
try {
|
|
300
|
-
return
|
|
300
|
+
return D(o, { language: "sql" }), { valid: !0 };
|
|
301
301
|
} catch (t) {
|
|
302
302
|
return {
|
|
303
303
|
valid: !1,
|
|
@@ -310,61 +310,61 @@ const Y = {
|
|
|
310
310
|
error: s instanceof Error ? s.message : "Unknown validation error"
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
},
|
|
313
|
+
}, le = (o, s) => {
|
|
314
314
|
const e = o.match(/\bVALUES\s*/i);
|
|
315
315
|
if (!e || e.index === void 0) return o;
|
|
316
|
-
const
|
|
317
|
-
let t = 0,
|
|
318
|
-
for (;
|
|
319
|
-
const l = n[
|
|
320
|
-
if ((l === "'" || l === '"') &&
|
|
321
|
-
t > 0 && (
|
|
316
|
+
const d = o.slice(0, e.index + e[0].length), n = o.slice(e.index + e[0].length), u = [];
|
|
317
|
+
let t = 0, i = "", m = !1, r = "", f = 0;
|
|
318
|
+
for (; f < n.length; ) {
|
|
319
|
+
const l = n[f], y = f > 0 ? n[f - 1] : "";
|
|
320
|
+
if ((l === "'" || l === '"') && y !== "\\" && (m ? l === r && (m = !1) : (m = !0, r = l)), m)
|
|
321
|
+
t > 0 && (i += l);
|
|
322
322
|
else if (l === "(")
|
|
323
|
-
t === 0 ?
|
|
323
|
+
t === 0 ? i = l : i += l, t++;
|
|
324
324
|
else if (l === ")")
|
|
325
|
-
|
|
325
|
+
i += l, t--, t === 0 && i.trim() && (u.push(i.trim()), i = "");
|
|
326
326
|
else {
|
|
327
327
|
if (l === ";" && t === 0)
|
|
328
328
|
break;
|
|
329
|
-
t > 0 && (
|
|
329
|
+
t > 0 && (i += l);
|
|
330
330
|
}
|
|
331
|
-
|
|
331
|
+
f++;
|
|
332
332
|
}
|
|
333
|
-
if (
|
|
333
|
+
if (u.length === 0)
|
|
334
334
|
return o;
|
|
335
|
-
const
|
|
336
|
-
const
|
|
337
|
-
let T = "",
|
|
338
|
-
for (let
|
|
339
|
-
const
|
|
340
|
-
if ((
|
|
341
|
-
|
|
335
|
+
const g = " ".repeat(s), v = u.map((l) => {
|
|
336
|
+
const y = l.slice(1, -1), E = [];
|
|
337
|
+
let T = "", I = 0, O = !1, x = "";
|
|
338
|
+
for (let c = 0; c < y.length; c++) {
|
|
339
|
+
const b = y[c], k = c > 0 ? y[c - 1] : "";
|
|
340
|
+
if ((b === "'" || b === '"') && k !== "\\" && (O ? b === x && (O = !1) : (O = !0, x = b)), !O && (b === "(" && I++, b === ")" && I--, b === "," && I === 0)) {
|
|
341
|
+
E.push(T.trim()), T = "";
|
|
342
342
|
continue;
|
|
343
343
|
}
|
|
344
|
-
T +=
|
|
344
|
+
T += b;
|
|
345
345
|
}
|
|
346
|
-
T.trim() &&
|
|
347
|
-
const
|
|
348
|
-
const
|
|
349
|
-
return `${
|
|
346
|
+
T.trim() && E.push(T.trim());
|
|
347
|
+
const L = E.map((c, b) => {
|
|
348
|
+
const k = b < E.length - 1 ? "," : "";
|
|
349
|
+
return `${g}${g}${c}${k}`;
|
|
350
350
|
}).join(`
|
|
351
351
|
`);
|
|
352
|
-
return `${
|
|
353
|
-
${
|
|
354
|
-
${
|
|
355
|
-
}), h =
|
|
356
|
-
const
|
|
357
|
-
return l +
|
|
352
|
+
return `${g}(
|
|
353
|
+
${L}
|
|
354
|
+
${g})`;
|
|
355
|
+
}), h = v.map((l, y) => {
|
|
356
|
+
const E = y < v.length - 1 ? "," : ";";
|
|
357
|
+
return l + E;
|
|
358
358
|
}).join(`
|
|
359
359
|
`);
|
|
360
|
-
let a =
|
|
360
|
+
let a = f;
|
|
361
361
|
a < n.length && n[a] === ";" && a++;
|
|
362
|
-
const
|
|
363
|
-
return
|
|
364
|
-
` + h +
|
|
365
|
-
},
|
|
362
|
+
const p = n.slice(a);
|
|
363
|
+
return d.trimEnd() + `
|
|
364
|
+
` + h + p;
|
|
365
|
+
}, U = (o, s) => {
|
|
366
366
|
try {
|
|
367
|
-
const e = s?.dialect || "sql",
|
|
367
|
+
const e = s?.dialect || "sql", d = s?.tabWidth || 2, n = s?.keywordCase || "upper", u = s?.useTabs || !1, t = s?.linesBetweenQueries || 1, m = {
|
|
368
368
|
sql: "sql",
|
|
369
369
|
mysql: "mysql",
|
|
370
370
|
postgresql: "postgresql",
|
|
@@ -372,33 +372,33 @@ ${b})`;
|
|
|
372
372
|
plsql: "plsql",
|
|
373
373
|
tsql: "tsql"
|
|
374
374
|
}[e] || "sql";
|
|
375
|
-
let r =
|
|
375
|
+
let r = D(o, {
|
|
376
376
|
language: m,
|
|
377
|
-
tabWidth:
|
|
377
|
+
tabWidth: d,
|
|
378
378
|
keywordCase: n,
|
|
379
|
-
useTabs:
|
|
379
|
+
useTabs: u,
|
|
380
380
|
linesBetweenQueries: t,
|
|
381
381
|
// 其他默认配置
|
|
382
382
|
indentStyle: "standard"
|
|
383
383
|
});
|
|
384
|
-
return /\bINSERT\s+INTO\b/i.test(r) && /\bVALUES\b/i.test(r) && (r =
|
|
384
|
+
return /\bINSERT\s+INTO\b/i.test(r) && /\bVALUES\b/i.test(r) && (r = le(r, d)), r;
|
|
385
385
|
} catch (e) {
|
|
386
386
|
return console.error("SQL formatting error:", e), o;
|
|
387
387
|
}
|
|
388
|
-
},
|
|
388
|
+
}, oe = (o) => {
|
|
389
389
|
try {
|
|
390
390
|
const s = [];
|
|
391
|
-
let e = o.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g, (
|
|
392
|
-
return e = e.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, ""), e = e.replace(/\s+/g, " ").trim(), s.forEach((
|
|
393
|
-
e = e.replace(`__STR_${n}__`,
|
|
391
|
+
let e = o.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g, (d) => (s.push(d), `__STR_${s.length - 1}__`));
|
|
392
|
+
return e = e.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, ""), e = e.replace(/\s+/g, " ").trim(), s.forEach((d, n) => {
|
|
393
|
+
e = e.replace(`__STR_${n}__`, d);
|
|
394
394
|
}), e;
|
|
395
395
|
} catch (s) {
|
|
396
396
|
return console.error("SQL compression error:", s), o;
|
|
397
397
|
}
|
|
398
|
-
},
|
|
399
|
-
const e = [],
|
|
400
|
-
if (!
|
|
401
|
-
const n =
|
|
398
|
+
}, ae = (o, s) => {
|
|
399
|
+
const e = [], d = o.match(/^(.*?\bVALUES\b)/is);
|
|
400
|
+
if (!d) return [];
|
|
401
|
+
const n = d[1].trim();
|
|
402
402
|
e.push({
|
|
403
403
|
type: "VALUES",
|
|
404
404
|
content: n,
|
|
@@ -406,10 +406,10 @@ ${b})`;
|
|
|
406
406
|
collapsible: !1,
|
|
407
407
|
path: `clause-${s}`
|
|
408
408
|
});
|
|
409
|
-
let t = o.slice(
|
|
410
|
-
for (let
|
|
411
|
-
const h = t[
|
|
412
|
-
if ((h === "'" || h === '"') && a !== "\\" && (
|
|
409
|
+
let t = o.slice(d[1].length).trim(), i = 0, m = 0, r = "", f = !1, g = "";
|
|
410
|
+
for (let v = 0; v < t.length; v++) {
|
|
411
|
+
const h = t[v], a = v > 0 ? t[v - 1] : "";
|
|
412
|
+
if ((h === "'" || h === '"') && a !== "\\" && (f ? h === g && (f = !1) : (f = !0, g = h)), f)
|
|
413
413
|
m > 0 && (r += h);
|
|
414
414
|
else if (h === "(" && m === 0)
|
|
415
415
|
m++, r = h;
|
|
@@ -417,59 +417,59 @@ ${b})`;
|
|
|
417
417
|
m++, r += h;
|
|
418
418
|
else if (h === ")") {
|
|
419
419
|
if (r += h, m--, m === 0) {
|
|
420
|
-
let
|
|
421
|
-
for (;
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
l =
|
|
420
|
+
let p = v + 1, l = "";
|
|
421
|
+
for (; p < t.length; ) {
|
|
422
|
+
const E = t[p];
|
|
423
|
+
if (E === "," || E === ";") {
|
|
424
|
+
l = E;
|
|
425
425
|
break;
|
|
426
|
-
} else if (!/\s/.test(
|
|
426
|
+
} else if (!/\s/.test(E))
|
|
427
427
|
break;
|
|
428
|
-
|
|
428
|
+
p++;
|
|
429
429
|
}
|
|
430
|
-
const
|
|
431
|
-
|
|
430
|
+
const y = r.trim();
|
|
431
|
+
y && (e.push({
|
|
432
432
|
type: "VALUE_TUPLE",
|
|
433
|
-
content:
|
|
434
|
-
raw:
|
|
433
|
+
content: y + l,
|
|
434
|
+
raw: y + l,
|
|
435
435
|
collapsible: !0,
|
|
436
|
-
path: `clause-${s}-value-${
|
|
437
|
-
}),
|
|
436
|
+
path: `clause-${s}-value-${i}`
|
|
437
|
+
}), i++), r = "", l && (v = p);
|
|
438
438
|
}
|
|
439
439
|
} else m > 0 && (r += h);
|
|
440
440
|
}
|
|
441
441
|
return e;
|
|
442
|
-
},
|
|
442
|
+
}, ce = (o, s) => /\n\s*ON\b/i.test(s) ? s : s.replace(
|
|
443
443
|
/^(\s*)((?:INNER|LEFT|RIGHT|FULL|CROSS|OUTER)?\s*JOIN\b[^\n]*?)\s+ON\b\s*/gim,
|
|
444
444
|
`$1$2
|
|
445
445
|
$1ON `
|
|
446
|
-
),
|
|
447
|
-
let s = 0, e = !1,
|
|
446
|
+
), ie = (o) => {
|
|
447
|
+
let s = 0, e = !1, d = "";
|
|
448
448
|
for (let n = 0; n < o.length; n++) {
|
|
449
|
-
const
|
|
450
|
-
if ((
|
|
451
|
-
e ?
|
|
449
|
+
const u = o[n], t = n > 0 ? o[n - 1] : "";
|
|
450
|
+
if ((u === "'" || u === '"') && t !== "\\") {
|
|
451
|
+
e ? u === d && (e = !1, d = "") : (e = !0, d = u);
|
|
452
452
|
continue;
|
|
453
453
|
}
|
|
454
|
-
e || (
|
|
454
|
+
e || (u === "(" && s++, u === ")" && s--);
|
|
455
455
|
}
|
|
456
456
|
return s;
|
|
457
|
-
},
|
|
457
|
+
}, ue = (o) => {
|
|
458
458
|
const s = [];
|
|
459
|
-
let e = 0,
|
|
459
|
+
let e = 0, d = -1, n = !1, u = "";
|
|
460
460
|
for (let t = 0; t < o.length; t++) {
|
|
461
|
-
const
|
|
462
|
-
if ((
|
|
463
|
-
n ?
|
|
461
|
+
const i = o[t], m = t > 0 ? o[t - 1] : "";
|
|
462
|
+
if ((i === "'" || i === '"') && m !== "\\") {
|
|
463
|
+
n ? i === u && (n = !1, u = "") : (n = !0, u = i);
|
|
464
464
|
continue;
|
|
465
465
|
}
|
|
466
|
-
n || (
|
|
466
|
+
n || (i === "(" ? (e === 0 && (d = t), e++) : i === ")" && (e--, e === 0 && d >= 0 && (s.push({ open: d, close: t }), d = -1)));
|
|
467
467
|
}
|
|
468
468
|
return s;
|
|
469
|
-
},
|
|
469
|
+
}, de = (o) => {
|
|
470
470
|
const s = o.trim();
|
|
471
471
|
return s ? /^(SELECT|WITH)\b/i.test(s) ? !0 : /\n\s*(SELECT|FROM|WHERE|JOIN|UNION|INTERSECT|EXCEPT)\b/i.test(o) : !1;
|
|
472
|
-
},
|
|
472
|
+
}, fe = (o) => {
|
|
473
473
|
const s = o.content.split(`
|
|
474
474
|
`);
|
|
475
475
|
let e = -1;
|
|
@@ -479,67 +479,67 @@ $1ON `
|
|
|
479
479
|
break;
|
|
480
480
|
}
|
|
481
481
|
if (e < 0) return;
|
|
482
|
-
const
|
|
482
|
+
const d = s.slice(e + 1).join(`
|
|
483
483
|
`);
|
|
484
|
-
if (!
|
|
485
|
-
const
|
|
486
|
-
(r) =>
|
|
484
|
+
if (!d) return;
|
|
485
|
+
const u = ue(d).filter(
|
|
486
|
+
(r) => de(d.slice(r.open + 1, r.close))
|
|
487
487
|
);
|
|
488
|
-
if (
|
|
488
|
+
if (u.length === 0) return;
|
|
489
489
|
const t = [];
|
|
490
|
-
let
|
|
490
|
+
let i = 0;
|
|
491
491
|
const m = o.path || "clause";
|
|
492
|
-
|
|
493
|
-
r.open + 1 >
|
|
494
|
-
const
|
|
495
|
-
`, r.close - 1) + 1,
|
|
496
|
-
for (const l of
|
|
492
|
+
u.forEach((r, f) => {
|
|
493
|
+
r.open + 1 > i && t.push({ kind: "text", text: d.slice(i, r.open + 1) });
|
|
494
|
+
const g = d.lastIndexOf(`
|
|
495
|
+
`, r.close - 1) + 1, v = g > r.open, h = v ? g - 1 : r.close, a = d.slice(r.open + 1, h), p = j(a, `${m}-sub${f}-`);
|
|
496
|
+
for (const l of p)
|
|
497
497
|
t.push({ kind: "clause", clause: l });
|
|
498
|
-
|
|
499
|
-
}),
|
|
500
|
-
},
|
|
501
|
-
const e = [],
|
|
498
|
+
i = v ? g : r.close;
|
|
499
|
+
}), i < d.length && t.push({ kind: "text", text: d.slice(i) }), o.body = t;
|
|
500
|
+
}, j = (o, s) => {
|
|
501
|
+
const e = [], d = o.split(`
|
|
502
502
|
`);
|
|
503
|
-
let n = null,
|
|
504
|
-
const m = [...
|
|
505
|
-
if (!n ||
|
|
506
|
-
let
|
|
503
|
+
let n = null, u = [], t = [], i = 0;
|
|
504
|
+
const m = [...ne].sort((f, g) => g.length - f.length), r = () => {
|
|
505
|
+
if (!n || u.length === 0) return;
|
|
506
|
+
let f = u.join(`
|
|
507
507
|
`);
|
|
508
|
-
if (
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
const
|
|
508
|
+
if (f = ce(n.type, f), n.content = f, n.raw = f, n.type === "INSERT INTO" && /\bVALUES\b/i.test(f)) {
|
|
509
|
+
const g = f.match(/^(.*?\bINSERT\s+INTO\s+[^(]+\s*\([^)]+\))/is);
|
|
510
|
+
if (g) {
|
|
511
|
+
const v = {
|
|
512
512
|
type: "INSERT INTO",
|
|
513
|
-
content:
|
|
514
|
-
raw:
|
|
513
|
+
content: g[1].trim(),
|
|
514
|
+
raw: g[1].trim(),
|
|
515
515
|
collapsible: !0,
|
|
516
516
|
path: `${s}clause-${e.length}`
|
|
517
517
|
};
|
|
518
|
-
e.push(
|
|
519
|
-
const h =
|
|
520
|
-
for (let l = 0; l <
|
|
521
|
-
|
|
522
|
-
e.push(...
|
|
518
|
+
e.push(v);
|
|
519
|
+
const h = f.slice(g[1].length).trim(), a = e.length, p = ae(h, a);
|
|
520
|
+
for (let l = 0; l < p.length; l++)
|
|
521
|
+
p[l].path = `${s}clause-${a + l}`;
|
|
522
|
+
e.push(...p);
|
|
523
523
|
return;
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
|
|
526
|
+
fe(n), e.push(n);
|
|
527
527
|
};
|
|
528
|
-
for (const
|
|
529
|
-
const
|
|
530
|
-
if (!
|
|
531
|
-
n &&
|
|
528
|
+
for (const f of d) {
|
|
529
|
+
const g = f.trim();
|
|
530
|
+
if (!g) {
|
|
531
|
+
n && u.push(f);
|
|
532
532
|
continue;
|
|
533
533
|
}
|
|
534
|
-
if (
|
|
535
|
-
n ?
|
|
534
|
+
if (g.startsWith("--") || g.startsWith("/*")) {
|
|
535
|
+
n ? u.push(f) : t.push(f);
|
|
536
536
|
continue;
|
|
537
537
|
}
|
|
538
538
|
let h = !1, a = "UNKNOWN";
|
|
539
|
-
if (
|
|
540
|
-
for (const
|
|
541
|
-
if (new RegExp(`^${
|
|
542
|
-
h = !0, a =
|
|
539
|
+
if (i === 0) {
|
|
540
|
+
for (const p of m)
|
|
541
|
+
if (new RegExp(`^${p}\\b`, "i").test(g)) {
|
|
542
|
+
h = !0, a = p.toUpperCase();
|
|
543
543
|
break;
|
|
544
544
|
}
|
|
545
545
|
}
|
|
@@ -551,19 +551,19 @@ $1ON `
|
|
|
551
551
|
`),
|
|
552
552
|
collapsible: !1,
|
|
553
553
|
path: `${s}clause-${e.length}`
|
|
554
|
-
}), t = []),
|
|
554
|
+
}), t = []), u = [f], n = {
|
|
555
555
|
type: a,
|
|
556
556
|
content: "",
|
|
557
557
|
raw: "",
|
|
558
558
|
collapsible: !0,
|
|
559
559
|
path: `${s}clause-${e.length}`
|
|
560
|
-
}) : n ?
|
|
560
|
+
}) : n ? u.push(f) : (u = [...t, f], t = [], n = {
|
|
561
561
|
type: "UNKNOWN",
|
|
562
562
|
content: "",
|
|
563
563
|
raw: "",
|
|
564
564
|
collapsible: !1,
|
|
565
565
|
path: `${s}clause-${e.length}`
|
|
566
|
-
}),
|
|
566
|
+
}), i = Math.max(0, i + ie(f));
|
|
567
567
|
}
|
|
568
568
|
return r(), t.length > 0 && e.push({
|
|
569
569
|
type: "UNKNOWN",
|
|
@@ -574,10 +574,10 @@ $1ON `
|
|
|
574
574
|
collapsible: !1,
|
|
575
575
|
path: `${s}clause-${e.length}`
|
|
576
576
|
}), e;
|
|
577
|
-
},
|
|
577
|
+
}, pe = (o) => {
|
|
578
578
|
try {
|
|
579
|
-
const s =
|
|
580
|
-
return { clauses:
|
|
579
|
+
const s = U(o, { keywordCase: "upper" });
|
|
580
|
+
return { clauses: j(s, ""), raw: o };
|
|
581
581
|
} catch {
|
|
582
582
|
return {
|
|
583
583
|
clauses: [
|
|
@@ -592,10 +592,10 @@ $1ON `
|
|
|
592
592
|
raw: o
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
|
-
},
|
|
595
|
+
}, J = (o) => {
|
|
596
596
|
const s = [];
|
|
597
597
|
let e = o;
|
|
598
|
-
const
|
|
598
|
+
const d = [
|
|
599
599
|
"COUNT",
|
|
600
600
|
"SUM",
|
|
601
601
|
"AVG",
|
|
@@ -619,12 +619,12 @@ $1ON `
|
|
|
619
619
|
"ABS",
|
|
620
620
|
"FLOOR",
|
|
621
621
|
"CEIL"
|
|
622
|
-
], n = ["=", "!=", "<>", "<", ">", "<=", ">=", "+", "-", "*", "/", "%", "||"],
|
|
622
|
+
], n = ["=", "!=", "<>", "<", ">", "<=", ">=", "+", "-", "*", "/", "%", "||"], u = ["(", ")", ",", ";", "."];
|
|
623
623
|
for (; e.length > 0; ) {
|
|
624
624
|
let t = !1;
|
|
625
|
-
const
|
|
626
|
-
if (
|
|
627
|
-
s.push({ type: "whitespace", value:
|
|
625
|
+
const i = e.match(/^(\s+)/);
|
|
626
|
+
if (i) {
|
|
627
|
+
s.push({ type: "whitespace", value: i[1] }), e = e.slice(i[1].length);
|
|
628
628
|
continue;
|
|
629
629
|
}
|
|
630
630
|
const m = e.match(/^(--[^\n]*)/);
|
|
@@ -637,14 +637,14 @@ $1ON `
|
|
|
637
637
|
s.push({ type: "comment", value: r[1] }), e = e.slice(r[1].length);
|
|
638
638
|
continue;
|
|
639
639
|
}
|
|
640
|
-
const
|
|
641
|
-
if (
|
|
642
|
-
s.push({ type: "string", value:
|
|
640
|
+
const f = e.match(/^(["'])(?:(?=(\\?))\2.)*?\1/);
|
|
641
|
+
if (f) {
|
|
642
|
+
s.push({ type: "string", value: f[0] }), e = e.slice(f[0].length);
|
|
643
643
|
continue;
|
|
644
644
|
}
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
s.push({ type: "number", value:
|
|
645
|
+
const g = e.match(/^(\d+\.?\d*|\.\d+)/);
|
|
646
|
+
if (g) {
|
|
647
|
+
s.push({ type: "number", value: g[1] }), e = e.slice(g[1].length);
|
|
648
648
|
continue;
|
|
649
649
|
}
|
|
650
650
|
for (const h of n)
|
|
@@ -653,25 +653,25 @@ $1ON `
|
|
|
653
653
|
break;
|
|
654
654
|
}
|
|
655
655
|
if (t) continue;
|
|
656
|
-
for (const h of
|
|
656
|
+
for (const h of u)
|
|
657
657
|
if (e.startsWith(h)) {
|
|
658
658
|
s.push({ type: "punctuation", value: h }), e = e.slice(h.length), t = !0;
|
|
659
659
|
break;
|
|
660
660
|
}
|
|
661
661
|
if (t) continue;
|
|
662
|
-
const
|
|
663
|
-
if (
|
|
664
|
-
const h =
|
|
665
|
-
|
|
662
|
+
const v = e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
663
|
+
if (v) {
|
|
664
|
+
const h = v[1], a = h.toUpperCase();
|
|
665
|
+
K.includes(a) ? s.push({ type: "keyword", value: h }) : d.includes(a) ? s.push({ type: "function", value: h }) : s.push({ type: "identifier", value: h }), e = e.slice(h.length);
|
|
666
666
|
continue;
|
|
667
667
|
}
|
|
668
668
|
s.push({ type: "punctuation", value: e[0] }), e = e.slice(1);
|
|
669
669
|
}
|
|
670
670
|
return s;
|
|
671
|
-
},
|
|
671
|
+
}, he = { class: "sql-clause-node" }, me = ["title"], ge = { class: "sql-clause-node__code" }, be = ["innerHTML"], ve = {
|
|
672
672
|
key: 0,
|
|
673
673
|
class: "sql-clause-node__body"
|
|
674
|
-
},
|
|
674
|
+
}, ye = ["title"], Ee = ["innerHTML"], ke = ["title"], Te = ["innerHTML"], Ce = /* @__PURE__ */ H({
|
|
675
675
|
__name: "SqlClauseNode",
|
|
676
676
|
props: {
|
|
677
677
|
clause: {},
|
|
@@ -680,165 +680,165 @@ $1ON `
|
|
|
680
680
|
},
|
|
681
681
|
emits: ["toggle"],
|
|
682
682
|
setup(o, { emit: s }) {
|
|
683
|
-
const e = o,
|
|
683
|
+
const e = o, d = s, n = q(() => e.clause.path || ""), u = q(() => e.expandedClauses.has(n.value)), t = q(() => {
|
|
684
684
|
const a = e.clause.content.split(`
|
|
685
685
|
`);
|
|
686
|
-
for (const
|
|
687
|
-
if (
|
|
686
|
+
for (const p of a)
|
|
687
|
+
if (p.trim()) return p;
|
|
688
688
|
return "";
|
|
689
|
-
}),
|
|
689
|
+
}), i = q(() => {
|
|
690
690
|
const a = e.clause.content.split(`
|
|
691
691
|
`);
|
|
692
692
|
if (a.length <= 1) return "";
|
|
693
|
-
let
|
|
693
|
+
let p = 0;
|
|
694
694
|
for (let l = 0; l < a.length; l++)
|
|
695
695
|
if (a[l].trim()) {
|
|
696
|
-
|
|
696
|
+
p = l;
|
|
697
697
|
break;
|
|
698
698
|
}
|
|
699
|
-
return a.slice(
|
|
699
|
+
return a.slice(p + 1).join(`
|
|
700
700
|
`);
|
|
701
|
-
}), m =
|
|
702
|
-
const
|
|
703
|
-
return
|
|
704
|
-
let
|
|
705
|
-
switch (
|
|
701
|
+
}), m = q(() => e.clause.body && e.clause.body.length > 0 ? !0 : !!i.value), r = (a) => {
|
|
702
|
+
const p = J(a), l = e.theme.colors;
|
|
703
|
+
return p.map((y) => {
|
|
704
|
+
let E = l.text;
|
|
705
|
+
switch (y.type) {
|
|
706
706
|
case "keyword":
|
|
707
|
-
|
|
707
|
+
E = l.sqlKeyword;
|
|
708
708
|
break;
|
|
709
709
|
case "function":
|
|
710
|
-
|
|
710
|
+
E = l.sqlFunction;
|
|
711
711
|
break;
|
|
712
712
|
case "string":
|
|
713
|
-
|
|
713
|
+
E = l.sqlString;
|
|
714
714
|
break;
|
|
715
715
|
case "number":
|
|
716
|
-
|
|
716
|
+
E = l.sqlNumber;
|
|
717
717
|
break;
|
|
718
718
|
case "comment":
|
|
719
|
-
|
|
719
|
+
E = l.sqlComment;
|
|
720
720
|
break;
|
|
721
721
|
case "operator":
|
|
722
|
-
|
|
722
|
+
E = l.sqlOperator;
|
|
723
723
|
break;
|
|
724
724
|
case "identifier":
|
|
725
|
-
|
|
725
|
+
E = l.sqlIdentifier;
|
|
726
726
|
break;
|
|
727
727
|
case "punctuation":
|
|
728
|
-
|
|
728
|
+
E = l.sqlPunctuation;
|
|
729
729
|
break;
|
|
730
730
|
case "whitespace":
|
|
731
|
-
return
|
|
731
|
+
return y.value.replace(/ /g, " ").replace(/\n/g, `
|
|
732
732
|
`);
|
|
733
733
|
}
|
|
734
|
-
const T =
|
|
735
|
-
return `<span style="color: ${
|
|
734
|
+
const T = y.value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
735
|
+
return `<span style="color: ${E}">${T}</span>`;
|
|
736
736
|
}).join("");
|
|
737
|
-
},
|
|
737
|
+
}, f = q(() => {
|
|
738
738
|
const a = e.clause.body;
|
|
739
739
|
if (!a || a.length === 0) return null;
|
|
740
|
-
let
|
|
741
|
-
for (const
|
|
742
|
-
if (
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
|
|
740
|
+
let p = "", l = !1;
|
|
741
|
+
for (const c of a)
|
|
742
|
+
if (c.kind === "text") {
|
|
743
|
+
const b = c.text.indexOf("(");
|
|
744
|
+
if (b >= 0) {
|
|
745
|
+
p += c.text.slice(0, b), l = !0;
|
|
746
746
|
break;
|
|
747
747
|
}
|
|
748
|
-
|
|
748
|
+
p += c.text;
|
|
749
749
|
} else
|
|
750
750
|
return null;
|
|
751
751
|
if (!l) return null;
|
|
752
|
-
let
|
|
753
|
-
for (let
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
|
|
752
|
+
let y = "";
|
|
753
|
+
for (let c = a.length - 1; c >= 0; c--) {
|
|
754
|
+
const b = a[c];
|
|
755
|
+
if (b.kind === "text") {
|
|
756
|
+
const k = b.text.lastIndexOf(")");
|
|
757
|
+
if (k >= 0) {
|
|
758
|
+
y = b.text.slice(k + 1) + y;
|
|
759
759
|
break;
|
|
760
760
|
}
|
|
761
|
-
|
|
761
|
+
y = b.text + y;
|
|
762
762
|
} else
|
|
763
763
|
break;
|
|
764
764
|
}
|
|
765
|
-
const
|
|
766
|
-
return
|
|
767
|
-
}),
|
|
768
|
-
if (e.clause.collapsible && !
|
|
769
|
-
const a =
|
|
765
|
+
const E = p.replace(/\s+/g, " ").trim(), T = y.replace(/\s+/g, " ").trim(), I = t.value, O = (I.match(/^\s*/) || [""])[0], L = [I.trimStart()];
|
|
766
|
+
return E && L.push(E), L.push("(...)"), T && L.push(T), `${O}${L.join(" ")}`;
|
|
767
|
+
}), g = q(() => {
|
|
768
|
+
if (e.clause.collapsible && !u.value && m.value) {
|
|
769
|
+
const a = f.value;
|
|
770
770
|
if (a)
|
|
771
771
|
return r(a);
|
|
772
|
-
const
|
|
773
|
-
return `${
|
|
772
|
+
const p = r(t.value), l = e.theme.colors.textSecondary;
|
|
773
|
+
return `${p}<span style="color: ${l}; opacity: 0.6; font-style: italic; margin-left: 4px;"> ...</span>`;
|
|
774
774
|
}
|
|
775
775
|
return r(t.value);
|
|
776
|
-
}),
|
|
777
|
-
e.clause.collapsible &&
|
|
776
|
+
}), v = () => {
|
|
777
|
+
e.clause.collapsible && d("toggle", n.value);
|
|
778
778
|
}, h = (a) => {
|
|
779
779
|
if (!e.clause.collapsible) return;
|
|
780
|
-
const
|
|
781
|
-
if (!
|
|
782
|
-
const l = (
|
|
783
|
-
(l === "(" || l === ")") &&
|
|
780
|
+
const p = a.target;
|
|
781
|
+
if (!p) return;
|
|
782
|
+
const l = (p.textContent || "").trim();
|
|
783
|
+
(l === "(" || l === ")") && d("toggle", n.value);
|
|
784
784
|
};
|
|
785
|
-
return (a,
|
|
786
|
-
const l =
|
|
787
|
-
return N(),
|
|
788
|
-
|
|
789
|
-
class:
|
|
790
|
-
title: a.clause.collapsible ?
|
|
791
|
-
onClick:
|
|
785
|
+
return (a, p) => {
|
|
786
|
+
const l = Q("SqlClauseNode", !0);
|
|
787
|
+
return N(), S("div", he, [
|
|
788
|
+
_("div", {
|
|
789
|
+
class: $(["sql-clause-node__header", { "sql-clause-node__header--collapsible": a.clause.collapsible }]),
|
|
790
|
+
title: a.clause.collapsible ? u.value ? "Click to collapse" : "Click to expand" : "",
|
|
791
|
+
onClick: v
|
|
792
792
|
}, [
|
|
793
|
-
|
|
794
|
-
|
|
793
|
+
_("pre", ge, [
|
|
794
|
+
_("code", { innerHTML: g.value }, null, 8, be)
|
|
795
795
|
])
|
|
796
|
-
], 10,
|
|
797
|
-
|
|
798
|
-
a.clause.body && a.clause.body.length > 0 ? (N(!0),
|
|
799
|
-
|
|
796
|
+
], 10, me),
|
|
797
|
+
u.value && m.value ? (N(), S("div", ve, [
|
|
798
|
+
a.clause.body && a.clause.body.length > 0 ? (N(!0), S(A, { key: 0 }, P(a.clause.body, (y, E) => (N(), S(A, { key: E }, [
|
|
799
|
+
y.kind === "text" ? (N(), S("pre", {
|
|
800
800
|
key: 0,
|
|
801
|
-
class:
|
|
801
|
+
class: $(["sql-clause-node__code sql-clause-node__text-segment", { "sql-clause-node__text-segment--clickable": a.clause.collapsible }]),
|
|
802
802
|
title: a.clause.collapsible ? "Click ( or ) to collapse" : "",
|
|
803
|
-
onClick:
|
|
803
|
+
onClick: p[0] || (p[0] = (T) => h(T))
|
|
804
804
|
}, [
|
|
805
|
-
|
|
806
|
-
innerHTML: r(
|
|
807
|
-
}, null, 8,
|
|
808
|
-
], 10,
|
|
805
|
+
_("code", {
|
|
806
|
+
innerHTML: r(y.text)
|
|
807
|
+
}, null, 8, Ee)
|
|
808
|
+
], 10, ye)) : (N(), W(l, {
|
|
809
809
|
key: 1,
|
|
810
|
-
clause:
|
|
810
|
+
clause: y.clause,
|
|
811
811
|
"expanded-clauses": a.expandedClauses,
|
|
812
812
|
theme: a.theme,
|
|
813
|
-
onToggle:
|
|
813
|
+
onToggle: p[1] || (p[1] = (T) => a.$emit("toggle", T))
|
|
814
814
|
}, null, 8, ["clause", "expanded-clauses", "theme"]))
|
|
815
|
-
], 64))), 128)) : (N(),
|
|
815
|
+
], 64))), 128)) : (N(), S("pre", {
|
|
816
816
|
key: 1,
|
|
817
|
-
class:
|
|
817
|
+
class: $(["sql-clause-node__code sql-clause-node__rest", { "sql-clause-node__rest--clickable": a.clause.collapsible }]),
|
|
818
818
|
title: a.clause.collapsible ? "Click ( or ) to collapse" : "",
|
|
819
|
-
onClick:
|
|
819
|
+
onClick: p[2] || (p[2] = (y) => h(y))
|
|
820
820
|
}, [
|
|
821
|
-
|
|
822
|
-
innerHTML: r(
|
|
823
|
-
}, null, 8,
|
|
824
|
-
], 10,
|
|
825
|
-
])) :
|
|
821
|
+
_("code", {
|
|
822
|
+
innerHTML: r(i.value)
|
|
823
|
+
}, null, 8, Te)
|
|
824
|
+
], 10, ke))
|
|
825
|
+
])) : G("", !0)
|
|
826
826
|
]);
|
|
827
827
|
};
|
|
828
828
|
}
|
|
829
|
-
}),
|
|
829
|
+
}), Ne = /* @__PURE__ */ F(Ce, [["__scopeId", "data-v-8b9383dc"]]), Se = { class: "sql-format__content" }, qe = {
|
|
830
830
|
key: 0,
|
|
831
831
|
class: "sql-format__error"
|
|
832
|
-
},
|
|
832
|
+
}, _e = {
|
|
833
833
|
key: 1,
|
|
834
834
|
class: "sql-format__viewer"
|
|
835
|
-
},
|
|
835
|
+
}, Ie = {
|
|
836
836
|
key: 0,
|
|
837
837
|
class: "sql-format__clauses"
|
|
838
|
-
},
|
|
838
|
+
}, Oe = {
|
|
839
839
|
key: 1,
|
|
840
840
|
class: "sql-format__code"
|
|
841
|
-
},
|
|
841
|
+
}, Le = ["innerHTML"], xe = /* @__PURE__ */ H({
|
|
842
842
|
__name: "index",
|
|
843
843
|
props: {
|
|
844
844
|
modelValue: { default: "" },
|
|
@@ -849,157 +849,158 @@ $1ON `
|
|
|
849
849
|
},
|
|
850
850
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
851
851
|
setup(o, { expose: s, emit: e }) {
|
|
852
|
-
|
|
853
|
-
"
|
|
854
|
-
"
|
|
855
|
-
|
|
856
|
-
"
|
|
852
|
+
z((c) => ({
|
|
853
|
+
"45d5acb0": v.value.colors.background,
|
|
854
|
+
"4623e62f": v.value.colors.text,
|
|
855
|
+
f365b9d8: v.value.colors.errorBackground,
|
|
856
|
+
"7d8b5146": v.value.colors.error
|
|
857
857
|
}));
|
|
858
|
-
const
|
|
859
|
-
const
|
|
860
|
-
for (const C of
|
|
861
|
-
if (C.path &&
|
|
862
|
-
for (const
|
|
863
|
-
|
|
858
|
+
const d = (c) => {
|
|
859
|
+
const b = [], k = (w) => {
|
|
860
|
+
for (const C of w)
|
|
861
|
+
if (C.path && b.push(C.path), C.body)
|
|
862
|
+
for (const B of C.body)
|
|
863
|
+
B.kind === "clause" && k([B.clause]);
|
|
864
864
|
};
|
|
865
|
-
return
|
|
866
|
-
}, n = o,
|
|
867
|
-
if (!
|
|
865
|
+
return k(c), b;
|
|
866
|
+
}, n = o, u = e, t = R(""), i = R(n.dialect), m = R([]), r = R(/* @__PURE__ */ new Set()), f = R(""), g = q(() => t.value === ""), v = q(() => se(n.theme)), h = (c) => {
|
|
867
|
+
if (!c || !c.trim()) {
|
|
868
868
|
t.value = "", m.value = [], r.value.clear();
|
|
869
869
|
return;
|
|
870
870
|
}
|
|
871
871
|
try {
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
874
|
-
t.value =
|
|
872
|
+
const b = re(c);
|
|
873
|
+
if (!b.valid) {
|
|
874
|
+
t.value = b.error || "Invalid SQL", m.value = [], f.value = "";
|
|
875
875
|
return;
|
|
876
876
|
}
|
|
877
|
-
const
|
|
878
|
-
m.value =
|
|
879
|
-
dialect:
|
|
877
|
+
const k = pe(c);
|
|
878
|
+
m.value = k.clauses, f.value = U(c, {
|
|
879
|
+
dialect: i.value,
|
|
880
880
|
tabWidth: n.tabWidth
|
|
881
|
-
}), r.value = new Set(
|
|
882
|
-
} catch (
|
|
883
|
-
t.value =
|
|
881
|
+
}), r.value = new Set(d(k.clauses)), t.value = "";
|
|
882
|
+
} catch (b) {
|
|
883
|
+
t.value = b instanceof Error ? b.message : "Unknown parse error", m.value = [], f.value = "";
|
|
884
884
|
}
|
|
885
|
-
}, a = (
|
|
886
|
-
const
|
|
887
|
-
return
|
|
888
|
-
let C =
|
|
889
|
-
switch (
|
|
885
|
+
}, a = (c) => {
|
|
886
|
+
const b = J(c), k = v.value.colors;
|
|
887
|
+
return b.map((w) => {
|
|
888
|
+
let C = k.text;
|
|
889
|
+
switch (w.type) {
|
|
890
890
|
case "keyword":
|
|
891
|
-
C =
|
|
891
|
+
C = k.sqlKeyword;
|
|
892
892
|
break;
|
|
893
893
|
case "function":
|
|
894
|
-
C =
|
|
894
|
+
C = k.sqlFunction;
|
|
895
895
|
break;
|
|
896
896
|
case "string":
|
|
897
|
-
C =
|
|
897
|
+
C = k.sqlString;
|
|
898
898
|
break;
|
|
899
899
|
case "number":
|
|
900
|
-
C =
|
|
900
|
+
C = k.sqlNumber;
|
|
901
901
|
break;
|
|
902
902
|
case "comment":
|
|
903
|
-
C =
|
|
903
|
+
C = k.sqlComment;
|
|
904
904
|
break;
|
|
905
905
|
case "operator":
|
|
906
|
-
C =
|
|
906
|
+
C = k.sqlOperator;
|
|
907
907
|
break;
|
|
908
908
|
case "identifier":
|
|
909
|
-
C =
|
|
909
|
+
C = k.sqlIdentifier;
|
|
910
910
|
break;
|
|
911
911
|
case "punctuation":
|
|
912
|
-
C =
|
|
912
|
+
C = k.sqlPunctuation;
|
|
913
913
|
break;
|
|
914
914
|
case "whitespace":
|
|
915
|
-
return
|
|
915
|
+
return w.value.replace(/ /g, " ").replace(/\n/g, `
|
|
916
916
|
`);
|
|
917
917
|
}
|
|
918
|
-
const
|
|
919
|
-
return `<span style="color: ${C}">${
|
|
918
|
+
const B = w.value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
919
|
+
return `<span style="color: ${C}">${B}</span>`;
|
|
920
920
|
}).join("");
|
|
921
|
-
},
|
|
922
|
-
r.value.has(
|
|
921
|
+
}, p = (c) => {
|
|
922
|
+
r.value.has(c) ? r.value.delete(c) : r.value.add(c), r.value = new Set(r.value);
|
|
923
923
|
}, l = () => {
|
|
924
|
-
r.value = new Set(
|
|
925
|
-
},
|
|
926
|
-
r.value = /* @__PURE__ */ new Set(),
|
|
927
|
-
},
|
|
928
|
-
if (
|
|
924
|
+
r.value = new Set(d(m.value)), u("expand-all");
|
|
925
|
+
}, y = () => {
|
|
926
|
+
r.value = /* @__PURE__ */ new Set(), u("collapse-all");
|
|
927
|
+
}, E = () => f.value || n.modelValue, T = async () => {
|
|
928
|
+
if (g.value)
|
|
929
929
|
try {
|
|
930
|
-
const
|
|
931
|
-
await navigator.clipboard.writeText(
|
|
932
|
-
} catch (
|
|
933
|
-
const
|
|
934
|
-
|
|
930
|
+
const c = E();
|
|
931
|
+
await navigator.clipboard.writeText(c), u("copy-success", c);
|
|
932
|
+
} catch (c) {
|
|
933
|
+
const b = c instanceof Error ? c : new Error("Failed to copy");
|
|
934
|
+
u("copy-error", b);
|
|
935
935
|
}
|
|
936
|
-
},
|
|
937
|
-
if (
|
|
936
|
+
}, I = () => {
|
|
937
|
+
if (g.value)
|
|
938
938
|
try {
|
|
939
|
-
const
|
|
940
|
-
dialect:
|
|
939
|
+
const c = U(n.modelValue, {
|
|
940
|
+
dialect: i.value,
|
|
941
941
|
tabWidth: n.tabWidth
|
|
942
942
|
});
|
|
943
|
-
|
|
944
|
-
} catch (
|
|
945
|
-
console.error("Format error:",
|
|
943
|
+
u("update:modelValue", c), u("format", c);
|
|
944
|
+
} catch (c) {
|
|
945
|
+
console.error("Format error:", c);
|
|
946
946
|
}
|
|
947
947
|
}, O = () => {
|
|
948
|
-
if (
|
|
948
|
+
if (g.value)
|
|
949
949
|
try {
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
} catch (
|
|
953
|
-
console.error("Compress error:",
|
|
950
|
+
const c = oe(n.modelValue);
|
|
951
|
+
u("update:modelValue", c), u("compress", c);
|
|
952
|
+
} catch (c) {
|
|
953
|
+
console.error("Compress error:", c);
|
|
954
954
|
}
|
|
955
|
-
},
|
|
956
|
-
return
|
|
955
|
+
}, x = () => null, L = () => t.value;
|
|
956
|
+
return V(
|
|
957
957
|
() => n.modelValue,
|
|
958
|
-
(
|
|
959
|
-
h(
|
|
958
|
+
(c) => {
|
|
959
|
+
h(c);
|
|
960
960
|
},
|
|
961
961
|
{ immediate: !0 }
|
|
962
|
-
),
|
|
962
|
+
), V(
|
|
963
963
|
() => n.dialect,
|
|
964
|
-
(
|
|
965
|
-
|
|
964
|
+
(c) => {
|
|
965
|
+
i.value = c;
|
|
966
966
|
}
|
|
967
967
|
), s({
|
|
968
|
-
copySql:
|
|
969
|
-
formatSource:
|
|
968
|
+
copySql: T,
|
|
969
|
+
formatSource: I,
|
|
970
970
|
compressSource: O,
|
|
971
971
|
expandAll: l,
|
|
972
|
-
collapseAll:
|
|
973
|
-
toggleExpand:
|
|
974
|
-
isValidSql: () =>
|
|
975
|
-
getParsedSql:
|
|
976
|
-
getParseError:
|
|
977
|
-
|
|
978
|
-
|
|
972
|
+
collapseAll: y,
|
|
973
|
+
toggleExpand: p,
|
|
974
|
+
isValidSql: () => g.value,
|
|
975
|
+
getParsedSql: x,
|
|
976
|
+
getParseError: L,
|
|
977
|
+
getValue: E
|
|
978
|
+
}), (c, b) => (N(), S("div", {
|
|
979
|
+
class: $(["sql-format", `sql-format--${v.value.name}`])
|
|
979
980
|
}, [
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
m.value.length > 0 ? (N(),
|
|
983
|
-
(N(!0),
|
|
984
|
-
key:
|
|
985
|
-
clause:
|
|
981
|
+
_("div", Se, [
|
|
982
|
+
g.value ? (N(), S("div", _e, [
|
|
983
|
+
m.value.length > 0 ? (N(), S("div", Ie, [
|
|
984
|
+
(N(!0), S(A, null, P(m.value, (k) => (N(), W(Ne, {
|
|
985
|
+
key: k.path,
|
|
986
|
+
clause: k,
|
|
986
987
|
"expanded-clauses": r.value,
|
|
987
|
-
theme:
|
|
988
|
-
onToggle:
|
|
988
|
+
theme: v.value,
|
|
989
|
+
onToggle: p
|
|
989
990
|
}, null, 8, ["clause", "expanded-clauses", "theme"]))), 128))
|
|
990
|
-
])) : (N(),
|
|
991
|
-
|
|
991
|
+
])) : (N(), S("pre", Oe, [
|
|
992
|
+
_("code", {
|
|
992
993
|
innerHTML: a(n.modelValue)
|
|
993
|
-
}, null, 8,
|
|
994
|
+
}, null, 8, Le)
|
|
994
995
|
]))
|
|
995
|
-
])) : (N(),
|
|
996
|
-
|
|
997
|
-
|
|
996
|
+
])) : (N(), S("div", qe, [
|
|
997
|
+
b[0] || (b[0] = _("h4", null, "SQL Parse Error:", -1)),
|
|
998
|
+
_("pre", null, Y(t.value), 1)
|
|
998
999
|
]))
|
|
999
1000
|
])
|
|
1000
1001
|
], 2));
|
|
1001
1002
|
}
|
|
1002
|
-
}),
|
|
1003
|
+
}), $e = /* @__PURE__ */ F(xe, [["__scopeId", "data-v-8445135b"]]);
|
|
1003
1004
|
export {
|
|
1004
|
-
|
|
1005
|
+
$e as S
|
|
1005
1006
|
};
|