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