lone-format 0.13.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-13rwh2MK.js → index-AlOFzpXl.js} +203 -196
- package/dist/_chunks/{index-DvNM7Tl4.js → index-BAEkF-Fh.js} +633 -632
- package/dist/_chunks/index-Deb34Mk7.js +984 -0
- 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/parser.d.ts +3 -3
- package/dist/components/SqlFormat/types.d.ts +3 -4
- 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
- package/dist/_chunks/index-DfjCsqDT.js +0 -1005
|
@@ -1,1005 +0,0 @@
|
|
|
1
|
-
import { defineComponent as M, computed as _, resolveComponent as J, createElementBlock as q, openBlock as N, createElementVNode as I, createCommentVNode as Q, normalizeClass as B, Fragment as $, renderList as H, createBlock as P, useCssVars as G, ref as w, watch as U, toDisplayString as z } from "vue";
|
|
2
|
-
import { format as W } from "sql-formatter";
|
|
3
|
-
import { _ as D } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
4
|
-
const Y = {
|
|
5
|
-
name: "github-light",
|
|
6
|
-
colors: {
|
|
7
|
-
// 背景色
|
|
8
|
-
background: "#ffffff",
|
|
9
|
-
surfaceBackground: "#f6f8fa",
|
|
10
|
-
hoverBackground: "#f3f4f6",
|
|
11
|
-
// 边框色
|
|
12
|
-
border: "#d0d7de",
|
|
13
|
-
// 文本色
|
|
14
|
-
text: "#24292f",
|
|
15
|
-
textSecondary: "#57606a",
|
|
16
|
-
// 按钮样式
|
|
17
|
-
buttonBackground: "#f6f8fa",
|
|
18
|
-
buttonBackgroundHover: "#f3f4f6",
|
|
19
|
-
buttonBorder: "#d0d7de",
|
|
20
|
-
buttonText: "#24292f",
|
|
21
|
-
buttonPrimary: "#1f883d",
|
|
22
|
-
buttonPrimaryHover: "#1a7f37",
|
|
23
|
-
// 状态指示
|
|
24
|
-
success: "#1f883d",
|
|
25
|
-
successBackground: "#dafbe1",
|
|
26
|
-
error: "#cf222e",
|
|
27
|
-
errorBackground: "#ffebe9",
|
|
28
|
-
// SQL 语法高亮
|
|
29
|
-
sqlKeyword: "#cf222e",
|
|
30
|
-
// 关键字 - 红色
|
|
31
|
-
sqlFunction: "#8250df",
|
|
32
|
-
// 函数 - 紫色
|
|
33
|
-
sqlString: "#0a3069",
|
|
34
|
-
// 字符串 - 深蓝
|
|
35
|
-
sqlNumber: "#0550ae",
|
|
36
|
-
// 数字 - 蓝色
|
|
37
|
-
sqlComment: "#6e7781",
|
|
38
|
-
// 注释 - 灰色
|
|
39
|
-
sqlOperator: "#cf222e",
|
|
40
|
-
// 操作符 - 红色
|
|
41
|
-
sqlIdentifier: "#24292f",
|
|
42
|
-
// 标识符 - 黑色
|
|
43
|
-
sqlPunctuation: "#24292f",
|
|
44
|
-
// 标点 - 黑色
|
|
45
|
-
// 折叠效果
|
|
46
|
-
collapsedBackground: "#ddf4ff",
|
|
47
|
-
// 折叠信息背景色 - 浅蓝
|
|
48
|
-
collapsedText: "#0969da",
|
|
49
|
-
// 折叠信息文本色 - 蓝色
|
|
50
|
-
// 缩进指示线
|
|
51
|
-
indentLine: "#d0d7de"
|
|
52
|
-
// 对齐线 - 灰色
|
|
53
|
-
}
|
|
54
|
-
}, X = {
|
|
55
|
-
name: "github-dark",
|
|
56
|
-
colors: {
|
|
57
|
-
// 背景色
|
|
58
|
-
background: "#0d1117",
|
|
59
|
-
surfaceBackground: "#161b22",
|
|
60
|
-
hoverBackground: "#30363d",
|
|
61
|
-
// 边框色
|
|
62
|
-
border: "#30363d",
|
|
63
|
-
// 文本色
|
|
64
|
-
text: "#c9d1d9",
|
|
65
|
-
textSecondary: "#8b949e",
|
|
66
|
-
// 按钮样式
|
|
67
|
-
buttonBackground: "#21262d",
|
|
68
|
-
buttonBackgroundHover: "#30363d",
|
|
69
|
-
buttonBorder: "#30363d",
|
|
70
|
-
buttonText: "#c9d1d9",
|
|
71
|
-
buttonPrimary: "#238636",
|
|
72
|
-
buttonPrimaryHover: "#2ea043",
|
|
73
|
-
// 状态指示
|
|
74
|
-
success: "#3fb950",
|
|
75
|
-
successBackground: "#0f2e1c",
|
|
76
|
-
error: "#f85149",
|
|
77
|
-
errorBackground: "#3d1319",
|
|
78
|
-
// SQL 语法高亮
|
|
79
|
-
sqlKeyword: "#ff7b72",
|
|
80
|
-
// 关键字 - 红色
|
|
81
|
-
sqlFunction: "#d2a8ff",
|
|
82
|
-
// 函数 - 紫色
|
|
83
|
-
sqlString: "#a5d6ff",
|
|
84
|
-
// 字符串 - 淡蓝色
|
|
85
|
-
sqlNumber: "#79c0ff",
|
|
86
|
-
// 数字 - 亮蓝色
|
|
87
|
-
sqlComment: "#8b949e",
|
|
88
|
-
// 注释 - 灰色
|
|
89
|
-
sqlOperator: "#ff7b72",
|
|
90
|
-
// 操作符 - 红色
|
|
91
|
-
sqlIdentifier: "#c9d1d9",
|
|
92
|
-
// 标识符 - 白色
|
|
93
|
-
sqlPunctuation: "#c9d1d9",
|
|
94
|
-
// 标点 - 白色
|
|
95
|
-
// 折叠效果
|
|
96
|
-
collapsedBackground: "#1c2d41",
|
|
97
|
-
// 折叠信息背景色 - 深蓝
|
|
98
|
-
collapsedText: "#58a6ff",
|
|
99
|
-
// 折叠信息文本色 - 蓝色
|
|
100
|
-
// 缩进指示线
|
|
101
|
-
indentLine: "#30363d"
|
|
102
|
-
// 对齐线 - 灰色
|
|
103
|
-
}
|
|
104
|
-
}, Z = {
|
|
105
|
-
name: "min-light",
|
|
106
|
-
colors: {
|
|
107
|
-
// 背景色 - 纯白简洁
|
|
108
|
-
background: "#ffffff",
|
|
109
|
-
surfaceBackground: "#fafafa",
|
|
110
|
-
hoverBackground: "#f9f9f9",
|
|
111
|
-
// 边框色 - 极浅灰
|
|
112
|
-
border: "#e5e5e5",
|
|
113
|
-
// 文本色 - 深灰而非纯黑
|
|
114
|
-
text: "#333333",
|
|
115
|
-
textSecondary: "#888888",
|
|
116
|
-
// 按钮样式 - 简约设计
|
|
117
|
-
buttonBackground: "#f8f8f8",
|
|
118
|
-
buttonBackgroundHover: "#eeeeee",
|
|
119
|
-
buttonBorder: "#e0e0e0",
|
|
120
|
-
buttonText: "#333333",
|
|
121
|
-
buttonPrimary: "#007acc",
|
|
122
|
-
buttonPrimaryHover: "#005a9e",
|
|
123
|
-
// 状态指示 - 柔和色彩
|
|
124
|
-
success: "#22c55e",
|
|
125
|
-
successBackground: "#f0fdf4",
|
|
126
|
-
error: "#ef4444",
|
|
127
|
-
errorBackground: "#fef2f2",
|
|
128
|
-
// SQL 语法高亮 - 简约配色(与 JSON 对应)
|
|
129
|
-
sqlKeyword: "#22c55e",
|
|
130
|
-
// 关键字 - 对应 Boolean 红色系
|
|
131
|
-
sqlFunction: "#8b5cf6",
|
|
132
|
-
// 函数 - 对应 Boolean 紫色
|
|
133
|
-
sqlString: "#ef4444",
|
|
134
|
-
// 字符串 - 对应 String 绿色
|
|
135
|
-
sqlNumber: "#3b82f6",
|
|
136
|
-
// 数字 - 对应 Number 蓝色
|
|
137
|
-
sqlComment: "#6b7280",
|
|
138
|
-
// 注释 - 对应 Null 灰色
|
|
139
|
-
sqlOperator: "#ef4444",
|
|
140
|
-
// 操作符 - 红色
|
|
141
|
-
sqlIdentifier: "#1f2937",
|
|
142
|
-
// 标识符 - 对应 Key 深灰
|
|
143
|
-
sqlPunctuation: "#374151",
|
|
144
|
-
// 标点 - 对应 Bracket 灰色
|
|
145
|
-
// 折叠效果
|
|
146
|
-
collapsedBackground: "#e0f2fe",
|
|
147
|
-
// 折叠信息背景色 - 浅蓝
|
|
148
|
-
collapsedText: "#0284c7",
|
|
149
|
-
// 折叠信息文本色 - 蓝色
|
|
150
|
-
// 缩进指示线
|
|
151
|
-
indentLine: "#e5e7eb"
|
|
152
|
-
// 对齐线 - 灰色
|
|
153
|
-
}
|
|
154
|
-
}, ee = {
|
|
155
|
-
name: "slack-ochin",
|
|
156
|
-
colors: {
|
|
157
|
-
// 背景色
|
|
158
|
-
background: "#fef5ed",
|
|
159
|
-
surfaceBackground: "#fef9f3",
|
|
160
|
-
hoverBackground: "#f9f0e5",
|
|
161
|
-
// 边框色
|
|
162
|
-
border: "#e9dcc9",
|
|
163
|
-
// 文本色
|
|
164
|
-
text: "#3d3c40",
|
|
165
|
-
textSecondary: "#616061",
|
|
166
|
-
// 按钮样式
|
|
167
|
-
buttonBackground: "#fef9f3",
|
|
168
|
-
buttonBackgroundHover: "#f9f0e5",
|
|
169
|
-
buttonBorder: "#e9dcc9",
|
|
170
|
-
buttonText: "#3d3c40",
|
|
171
|
-
buttonPrimary: "#007a5a",
|
|
172
|
-
buttonPrimaryHover: "#006644",
|
|
173
|
-
// 状态指示
|
|
174
|
-
success: "#007a5a",
|
|
175
|
-
successBackground: "#d1f4e0",
|
|
176
|
-
error: "#e01e5a",
|
|
177
|
-
errorBackground: "#ffdbea",
|
|
178
|
-
// SQL 语法高亮
|
|
179
|
-
sqlKeyword: "#e01e5a",
|
|
180
|
-
// 关键字 - 红色
|
|
181
|
-
sqlFunction: "#8b2eff",
|
|
182
|
-
// 函数 - 紫色
|
|
183
|
-
sqlString: "#0b4c8c",
|
|
184
|
-
// 字符串 - 深蓝
|
|
185
|
-
sqlNumber: "#1264a3",
|
|
186
|
-
// 数字 - 蓝色
|
|
187
|
-
sqlComment: "#616061",
|
|
188
|
-
// 注释 - 灰色
|
|
189
|
-
sqlOperator: "#e01e5a",
|
|
190
|
-
// 操作符 - 红色
|
|
191
|
-
sqlIdentifier: "#3d3c40",
|
|
192
|
-
// 标识符 - 深色
|
|
193
|
-
sqlPunctuation: "#3d3c40",
|
|
194
|
-
// 标点 - 深色
|
|
195
|
-
// 折叠效果
|
|
196
|
-
collapsedBackground: "#d8eaf5",
|
|
197
|
-
// 折叠信息背景色 - 浅蓝
|
|
198
|
-
collapsedText: "#0b4c8c",
|
|
199
|
-
// 折叠信息文本色 - 深蓝
|
|
200
|
-
// 缩进指示线
|
|
201
|
-
indentLine: "#3e4348"
|
|
202
|
-
// 对齐线 - 灰色
|
|
203
|
-
}
|
|
204
|
-
}, V = {
|
|
205
|
-
"github-light": Y,
|
|
206
|
-
"github-dark": X,
|
|
207
|
-
"min-light": Z,
|
|
208
|
-
"slack-ochin": ee
|
|
209
|
-
}, te = (o) => V[o] || V["github-light"], F = [
|
|
210
|
-
"SELECT",
|
|
211
|
-
"FROM",
|
|
212
|
-
"WHERE",
|
|
213
|
-
"JOIN",
|
|
214
|
-
"INNER",
|
|
215
|
-
"LEFT",
|
|
216
|
-
"RIGHT",
|
|
217
|
-
"FULL",
|
|
218
|
-
"OUTER",
|
|
219
|
-
"ON",
|
|
220
|
-
"GROUP",
|
|
221
|
-
"BY",
|
|
222
|
-
"HAVING",
|
|
223
|
-
"ORDER",
|
|
224
|
-
"LIMIT",
|
|
225
|
-
"OFFSET",
|
|
226
|
-
"INSERT",
|
|
227
|
-
"INTO",
|
|
228
|
-
"VALUES",
|
|
229
|
-
"UPDATE",
|
|
230
|
-
"SET",
|
|
231
|
-
"DELETE",
|
|
232
|
-
"CREATE",
|
|
233
|
-
"ALTER",
|
|
234
|
-
"DROP",
|
|
235
|
-
"TABLE",
|
|
236
|
-
"DATABASE",
|
|
237
|
-
"INDEX",
|
|
238
|
-
"VIEW",
|
|
239
|
-
"AND",
|
|
240
|
-
"OR",
|
|
241
|
-
"NOT",
|
|
242
|
-
"IN",
|
|
243
|
-
"BETWEEN",
|
|
244
|
-
"LIKE",
|
|
245
|
-
"IS",
|
|
246
|
-
"NULL",
|
|
247
|
-
"AS",
|
|
248
|
-
"DISTINCT",
|
|
249
|
-
"UNION",
|
|
250
|
-
"ALL",
|
|
251
|
-
"EXISTS",
|
|
252
|
-
"CASE",
|
|
253
|
-
"WHEN",
|
|
254
|
-
"THEN",
|
|
255
|
-
"ELSE",
|
|
256
|
-
"END"
|
|
257
|
-
], se = [
|
|
258
|
-
"WITH",
|
|
259
|
-
"SELECT",
|
|
260
|
-
"FROM",
|
|
261
|
-
"WHERE",
|
|
262
|
-
"GROUP BY",
|
|
263
|
-
"HAVING",
|
|
264
|
-
"ORDER BY",
|
|
265
|
-
"LIMIT",
|
|
266
|
-
"INSERT INTO",
|
|
267
|
-
"UPDATE",
|
|
268
|
-
"SET",
|
|
269
|
-
"DELETE FROM",
|
|
270
|
-
"CREATE",
|
|
271
|
-
"ALTER",
|
|
272
|
-
"DROP",
|
|
273
|
-
"INNER JOIN",
|
|
274
|
-
"LEFT JOIN",
|
|
275
|
-
"RIGHT JOIN",
|
|
276
|
-
"FULL JOIN",
|
|
277
|
-
"CROSS JOIN",
|
|
278
|
-
"OUTER JOIN",
|
|
279
|
-
"JOIN",
|
|
280
|
-
"UNION ALL",
|
|
281
|
-
"UNION",
|
|
282
|
-
"INTERSECT",
|
|
283
|
-
"EXCEPT"
|
|
284
|
-
], ne = (o) => {
|
|
285
|
-
try {
|
|
286
|
-
if (!o || !o.trim())
|
|
287
|
-
return { valid: !1, error: "SQL string is empty" };
|
|
288
|
-
const s = o.toUpperCase().trim();
|
|
289
|
-
if (!F.some((t) => new RegExp(`\\b${t}\\b`).test(s)))
|
|
290
|
-
return { valid: !1, error: "No valid SQL keywords found" };
|
|
291
|
-
let u = 0, n = !1, i = "";
|
|
292
|
-
for (let t = 0; t < o.length; t++) {
|
|
293
|
-
const c = o[t], m = t > 0 ? o[t - 1] : "";
|
|
294
|
-
if ((c === "'" || c === '"') && m !== "\\" && (n ? c === i && (n = !1, i = "") : (n = !0, i = c)), !n && (c === "(" && u++, c === ")" && u--, u < 0))
|
|
295
|
-
return { valid: !1, error: "Mismatched parentheses: unexpected closing parenthesis" };
|
|
296
|
-
}
|
|
297
|
-
if (u !== 0)
|
|
298
|
-
return { valid: !1, error: `Mismatched parentheses: ${u} unclosed opening parenthesis` };
|
|
299
|
-
try {
|
|
300
|
-
return W(o, { language: "sql" }), { valid: !0 };
|
|
301
|
-
} catch (t) {
|
|
302
|
-
return {
|
|
303
|
-
valid: !1,
|
|
304
|
-
error: t instanceof Error ? t.message : "SQL syntax error"
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
} catch (s) {
|
|
308
|
-
return {
|
|
309
|
-
valid: !1,
|
|
310
|
-
error: s instanceof Error ? s.message : "Unknown validation error"
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
}, re = (o, s) => {
|
|
314
|
-
const e = o.match(/\bVALUES\s*/i);
|
|
315
|
-
if (!e || e.index === void 0) return o;
|
|
316
|
-
const u = o.slice(0, e.index + e[0].length), n = o.slice(e.index + e[0].length), i = [];
|
|
317
|
-
let t = 0, c = "", m = !1, r = "", d = 0;
|
|
318
|
-
for (; d < n.length; ) {
|
|
319
|
-
const l = n[d], E = d > 0 ? n[d - 1] : "";
|
|
320
|
-
if ((l === "'" || l === '"') && E !== "\\" && (m ? l === r && (m = !1) : (m = !0, r = l)), m)
|
|
321
|
-
t > 0 && (c += l);
|
|
322
|
-
else if (l === "(")
|
|
323
|
-
t === 0 ? c = l : c += l, t++;
|
|
324
|
-
else if (l === ")")
|
|
325
|
-
c += l, t--, t === 0 && c.trim() && (i.push(c.trim()), c = "");
|
|
326
|
-
else {
|
|
327
|
-
if (l === ";" && t === 0)
|
|
328
|
-
break;
|
|
329
|
-
t > 0 && (c += l);
|
|
330
|
-
}
|
|
331
|
-
d++;
|
|
332
|
-
}
|
|
333
|
-
if (i.length === 0)
|
|
334
|
-
return o;
|
|
335
|
-
const b = " ".repeat(s), y = i.map((l) => {
|
|
336
|
-
const E = l.slice(1, -1), k = [];
|
|
337
|
-
let T = "", O = 0, L = !1, x = "";
|
|
338
|
-
for (let v = 0; v < E.length; v++) {
|
|
339
|
-
const g = E[v], S = v > 0 ? E[v - 1] : "";
|
|
340
|
-
if ((g === "'" || g === '"') && S !== "\\" && (L ? g === x && (L = !1) : (L = !0, x = g)), !L && (g === "(" && O++, g === ")" && O--, g === "," && O === 0)) {
|
|
341
|
-
k.push(T.trim()), T = "";
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
T += g;
|
|
345
|
-
}
|
|
346
|
-
T.trim() && k.push(T.trim());
|
|
347
|
-
const p = k.map((v, g) => {
|
|
348
|
-
const S = g < k.length - 1 ? "," : "";
|
|
349
|
-
return `${b}${b}${v}${S}`;
|
|
350
|
-
}).join(`
|
|
351
|
-
`);
|
|
352
|
-
return `${b}(
|
|
353
|
-
${p}
|
|
354
|
-
${b})`;
|
|
355
|
-
}), h = y.map((l, E) => {
|
|
356
|
-
const k = E < y.length - 1 ? "," : ";";
|
|
357
|
-
return l + k;
|
|
358
|
-
}).join(`
|
|
359
|
-
`);
|
|
360
|
-
let a = d;
|
|
361
|
-
a < n.length && n[a] === ";" && a++;
|
|
362
|
-
const f = n.slice(a);
|
|
363
|
-
return u.trimEnd() + `
|
|
364
|
-
` + h + f;
|
|
365
|
-
}, A = (o, s) => {
|
|
366
|
-
try {
|
|
367
|
-
const e = s?.dialect || "sql", u = s?.tabWidth || 2, n = s?.keywordCase || "upper", i = s?.useTabs || !1, t = s?.linesBetweenQueries || 1, m = {
|
|
368
|
-
sql: "sql",
|
|
369
|
-
mysql: "mysql",
|
|
370
|
-
postgresql: "postgresql",
|
|
371
|
-
sqlite: "sqlite",
|
|
372
|
-
plsql: "plsql",
|
|
373
|
-
tsql: "tsql"
|
|
374
|
-
}[e] || "sql";
|
|
375
|
-
let r = W(o, {
|
|
376
|
-
language: m,
|
|
377
|
-
tabWidth: u,
|
|
378
|
-
keywordCase: n,
|
|
379
|
-
useTabs: i,
|
|
380
|
-
linesBetweenQueries: t,
|
|
381
|
-
// 其他默认配置
|
|
382
|
-
indentStyle: "standard"
|
|
383
|
-
});
|
|
384
|
-
return /\bINSERT\s+INTO\b/i.test(r) && /\bVALUES\b/i.test(r) && (r = re(r, u)), r;
|
|
385
|
-
} catch (e) {
|
|
386
|
-
return console.error("SQL formatting error:", e), o;
|
|
387
|
-
}
|
|
388
|
-
}, le = (o) => {
|
|
389
|
-
try {
|
|
390
|
-
const s = [];
|
|
391
|
-
let e = o.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g, (u) => (s.push(u), `__STR_${s.length - 1}__`));
|
|
392
|
-
return e = e.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, ""), e = e.replace(/\s+/g, " ").trim(), s.forEach((u, n) => {
|
|
393
|
-
e = e.replace(`__STR_${n}__`, u);
|
|
394
|
-
}), e;
|
|
395
|
-
} catch (s) {
|
|
396
|
-
return console.error("SQL compression error:", s), o;
|
|
397
|
-
}
|
|
398
|
-
}, oe = (o, s) => {
|
|
399
|
-
const e = [], u = o.match(/^(.*?\bVALUES\b)/is);
|
|
400
|
-
if (!u) return [];
|
|
401
|
-
const n = u[1].trim();
|
|
402
|
-
e.push({
|
|
403
|
-
type: "VALUES",
|
|
404
|
-
content: n,
|
|
405
|
-
raw: n,
|
|
406
|
-
collapsible: !1,
|
|
407
|
-
path: `clause-${s}`
|
|
408
|
-
});
|
|
409
|
-
let t = o.slice(u[1].length).trim(), c = 0, m = 0, r = "", d = !1, b = "";
|
|
410
|
-
for (let y = 0; y < t.length; y++) {
|
|
411
|
-
const h = t[y], a = y > 0 ? t[y - 1] : "";
|
|
412
|
-
if ((h === "'" || h === '"') && a !== "\\" && (d ? h === b && (d = !1) : (d = !0, b = h)), d)
|
|
413
|
-
m > 0 && (r += h);
|
|
414
|
-
else if (h === "(" && m === 0)
|
|
415
|
-
m++, r = h;
|
|
416
|
-
else if (h === "(")
|
|
417
|
-
m++, r += h;
|
|
418
|
-
else if (h === ")") {
|
|
419
|
-
if (r += h, m--, m === 0) {
|
|
420
|
-
let f = y + 1, l = "";
|
|
421
|
-
for (; f < t.length; ) {
|
|
422
|
-
const k = t[f];
|
|
423
|
-
if (k === "," || k === ";") {
|
|
424
|
-
l = k;
|
|
425
|
-
break;
|
|
426
|
-
} else if (!/\s/.test(k))
|
|
427
|
-
break;
|
|
428
|
-
f++;
|
|
429
|
-
}
|
|
430
|
-
const E = r.trim();
|
|
431
|
-
E && (e.push({
|
|
432
|
-
type: "VALUE_TUPLE",
|
|
433
|
-
content: E + l,
|
|
434
|
-
raw: E + l,
|
|
435
|
-
collapsible: !0,
|
|
436
|
-
path: `clause-${s}-value-${c}`
|
|
437
|
-
}), c++), r = "", l && (y = f);
|
|
438
|
-
}
|
|
439
|
-
} else m > 0 && (r += h);
|
|
440
|
-
}
|
|
441
|
-
return e;
|
|
442
|
-
}, ae = (o, s) => /\n\s*ON\b/i.test(s) ? s : s.replace(
|
|
443
|
-
/^(\s*)((?:INNER|LEFT|RIGHT|FULL|CROSS|OUTER)?\s*JOIN\b[^\n]*?)\s+ON\b\s*/gim,
|
|
444
|
-
`$1$2
|
|
445
|
-
$1ON `
|
|
446
|
-
), ce = (o) => {
|
|
447
|
-
let s = 0, e = !1, u = "";
|
|
448
|
-
for (let n = 0; n < o.length; n++) {
|
|
449
|
-
const i = o[n], t = n > 0 ? o[n - 1] : "";
|
|
450
|
-
if ((i === "'" || i === '"') && t !== "\\") {
|
|
451
|
-
e ? i === u && (e = !1, u = "") : (e = !0, u = i);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
e || (i === "(" && s++, i === ")" && s--);
|
|
455
|
-
}
|
|
456
|
-
return s;
|
|
457
|
-
}, ie = (o) => {
|
|
458
|
-
const s = [];
|
|
459
|
-
let e = 0, u = -1, n = !1, i = "";
|
|
460
|
-
for (let t = 0; t < o.length; t++) {
|
|
461
|
-
const c = o[t], m = t > 0 ? o[t - 1] : "";
|
|
462
|
-
if ((c === "'" || c === '"') && m !== "\\") {
|
|
463
|
-
n ? c === i && (n = !1, i = "") : (n = !0, i = c);
|
|
464
|
-
continue;
|
|
465
|
-
}
|
|
466
|
-
n || (c === "(" ? (e === 0 && (u = t), e++) : c === ")" && (e--, e === 0 && u >= 0 && (s.push({ open: u, close: t }), u = -1)));
|
|
467
|
-
}
|
|
468
|
-
return s;
|
|
469
|
-
}, ue = (o) => {
|
|
470
|
-
const s = o.trim();
|
|
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
|
-
}, de = (o) => {
|
|
473
|
-
const s = o.content.split(`
|
|
474
|
-
`);
|
|
475
|
-
let e = -1;
|
|
476
|
-
for (let r = 0; r < s.length; r++)
|
|
477
|
-
if (s[r].trim()) {
|
|
478
|
-
e = r;
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
if (e < 0) return;
|
|
482
|
-
const u = s.slice(e + 1).join(`
|
|
483
|
-
`);
|
|
484
|
-
if (!u) return;
|
|
485
|
-
const i = ie(u).filter(
|
|
486
|
-
(r) => ue(u.slice(r.open + 1, r.close))
|
|
487
|
-
);
|
|
488
|
-
if (i.length === 0) return;
|
|
489
|
-
const t = [];
|
|
490
|
-
let c = 0;
|
|
491
|
-
const m = o.path || "clause";
|
|
492
|
-
i.forEach((r, d) => {
|
|
493
|
-
r.open + 1 > c && t.push({ kind: "text", text: u.slice(c, r.open + 1) });
|
|
494
|
-
const b = u.lastIndexOf(`
|
|
495
|
-
`, r.close - 1) + 1, y = b > r.open, h = y ? b - 1 : r.close, a = u.slice(r.open + 1, h), f = K(a, `${m}-sub${d}-`);
|
|
496
|
-
for (const l of f)
|
|
497
|
-
t.push({ kind: "clause", clause: l });
|
|
498
|
-
c = y ? b : r.close;
|
|
499
|
-
}), c < u.length && t.push({ kind: "text", text: u.slice(c) }), o.body = t;
|
|
500
|
-
}, K = (o, s) => {
|
|
501
|
-
const e = [], u = o.split(`
|
|
502
|
-
`);
|
|
503
|
-
let n = null, i = [], t = [], c = 0;
|
|
504
|
-
const m = [...se].sort((d, b) => b.length - d.length), r = () => {
|
|
505
|
-
if (!n || i.length === 0) return;
|
|
506
|
-
let d = i.join(`
|
|
507
|
-
`);
|
|
508
|
-
if (d = ae(n.type, d), n.content = d, n.raw = d, n.type === "INSERT INTO" && /\bVALUES\b/i.test(d)) {
|
|
509
|
-
const b = d.match(/^(.*?\bINSERT\s+INTO\s+[^(]+\s*\([^)]+\))/is);
|
|
510
|
-
if (b) {
|
|
511
|
-
const y = {
|
|
512
|
-
type: "INSERT INTO",
|
|
513
|
-
content: b[1].trim(),
|
|
514
|
-
raw: b[1].trim(),
|
|
515
|
-
collapsible: !0,
|
|
516
|
-
path: `${s}clause-${e.length}`
|
|
517
|
-
};
|
|
518
|
-
e.push(y);
|
|
519
|
-
const h = d.slice(b[1].length).trim(), a = e.length, f = oe(h, a);
|
|
520
|
-
for (let l = 0; l < f.length; l++)
|
|
521
|
-
f[l].path = `${s}clause-${a + l}`;
|
|
522
|
-
e.push(...f);
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
de(n), e.push(n);
|
|
527
|
-
};
|
|
528
|
-
for (const d of u) {
|
|
529
|
-
const b = d.trim();
|
|
530
|
-
if (!b) {
|
|
531
|
-
n && i.push(d);
|
|
532
|
-
continue;
|
|
533
|
-
}
|
|
534
|
-
if (b.startsWith("--") || b.startsWith("/*")) {
|
|
535
|
-
n ? i.push(d) : t.push(d);
|
|
536
|
-
continue;
|
|
537
|
-
}
|
|
538
|
-
let h = !1, a = "UNKNOWN";
|
|
539
|
-
if (c === 0) {
|
|
540
|
-
for (const f of m)
|
|
541
|
-
if (new RegExp(`^${f}\\b`, "i").test(b)) {
|
|
542
|
-
h = !0, a = f.toUpperCase();
|
|
543
|
-
break;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
h ? (r(), t.length > 0 && (e.push({
|
|
547
|
-
type: "UNKNOWN",
|
|
548
|
-
content: t.join(`
|
|
549
|
-
`),
|
|
550
|
-
raw: t.join(`
|
|
551
|
-
`),
|
|
552
|
-
collapsible: !1,
|
|
553
|
-
path: `${s}clause-${e.length}`
|
|
554
|
-
}), t = []), i = [d], n = {
|
|
555
|
-
type: a,
|
|
556
|
-
content: "",
|
|
557
|
-
raw: "",
|
|
558
|
-
collapsible: !0,
|
|
559
|
-
path: `${s}clause-${e.length}`
|
|
560
|
-
}) : n ? i.push(d) : (i = [...t, d], t = [], n = {
|
|
561
|
-
type: "UNKNOWN",
|
|
562
|
-
content: "",
|
|
563
|
-
raw: "",
|
|
564
|
-
collapsible: !1,
|
|
565
|
-
path: `${s}clause-${e.length}`
|
|
566
|
-
}), c = Math.max(0, c + ce(d));
|
|
567
|
-
}
|
|
568
|
-
return r(), t.length > 0 && e.push({
|
|
569
|
-
type: "UNKNOWN",
|
|
570
|
-
content: t.join(`
|
|
571
|
-
`),
|
|
572
|
-
raw: t.join(`
|
|
573
|
-
`),
|
|
574
|
-
collapsible: !1,
|
|
575
|
-
path: `${s}clause-${e.length}`
|
|
576
|
-
}), e;
|
|
577
|
-
}, fe = (o) => {
|
|
578
|
-
try {
|
|
579
|
-
const s = A(o, { keywordCase: "upper" });
|
|
580
|
-
return { clauses: K(s, ""), raw: o };
|
|
581
|
-
} catch {
|
|
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 = [];
|
|
597
|
-
let e = o;
|
|
598
|
-
const u = [
|
|
599
|
-
"COUNT",
|
|
600
|
-
"SUM",
|
|
601
|
-
"AVG",
|
|
602
|
-
"MAX",
|
|
603
|
-
"MIN",
|
|
604
|
-
"UPPER",
|
|
605
|
-
"LOWER",
|
|
606
|
-
"SUBSTRING",
|
|
607
|
-
"CONCAT",
|
|
608
|
-
"LENGTH",
|
|
609
|
-
"TRIM",
|
|
610
|
-
"NOW",
|
|
611
|
-
"DATE",
|
|
612
|
-
"YEAR",
|
|
613
|
-
"MONTH",
|
|
614
|
-
"DAY",
|
|
615
|
-
"COALESCE",
|
|
616
|
-
"CAST",
|
|
617
|
-
"CONVERT",
|
|
618
|
-
"ROUND",
|
|
619
|
-
"ABS",
|
|
620
|
-
"FLOOR",
|
|
621
|
-
"CEIL"
|
|
622
|
-
], n = ["=", "!=", "<>", "<", ">", "<=", ">=", "+", "-", "*", "/", "%", "||"], i = ["(", ")", ",", ";", "."];
|
|
623
|
-
for (; e.length > 0; ) {
|
|
624
|
-
let t = !1;
|
|
625
|
-
const c = e.match(/^(\s+)/);
|
|
626
|
-
if (c) {
|
|
627
|
-
s.push({ type: "whitespace", value: c[1] }), e = e.slice(c[1].length);
|
|
628
|
-
continue;
|
|
629
|
-
}
|
|
630
|
-
const m = e.match(/^(--[^\n]*)/);
|
|
631
|
-
if (m) {
|
|
632
|
-
s.push({ type: "comment", value: m[1] }), e = e.slice(m[1].length);
|
|
633
|
-
continue;
|
|
634
|
-
}
|
|
635
|
-
const r = e.match(/^(\/\*[\s\S]*?\*\/)/);
|
|
636
|
-
if (r) {
|
|
637
|
-
s.push({ type: "comment", value: r[1] }), e = e.slice(r[1].length);
|
|
638
|
-
continue;
|
|
639
|
-
}
|
|
640
|
-
const d = e.match(/^(["'])(?:(?=(\\?))\2.)*?\1/);
|
|
641
|
-
if (d) {
|
|
642
|
-
s.push({ type: "string", value: d[0] }), e = e.slice(d[0].length);
|
|
643
|
-
continue;
|
|
644
|
-
}
|
|
645
|
-
const b = e.match(/^(\d+\.?\d*|\.\d+)/);
|
|
646
|
-
if (b) {
|
|
647
|
-
s.push({ type: "number", value: b[1] }), e = e.slice(b[1].length);
|
|
648
|
-
continue;
|
|
649
|
-
}
|
|
650
|
-
for (const h of n)
|
|
651
|
-
if (e.startsWith(h)) {
|
|
652
|
-
s.push({ type: "operator", value: h }), e = e.slice(h.length), t = !0;
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
if (t) continue;
|
|
656
|
-
for (const h of i)
|
|
657
|
-
if (e.startsWith(h)) {
|
|
658
|
-
s.push({ type: "punctuation", value: h }), e = e.slice(h.length), t = !0;
|
|
659
|
-
break;
|
|
660
|
-
}
|
|
661
|
-
if (t) continue;
|
|
662
|
-
const y = e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
663
|
-
if (y) {
|
|
664
|
-
const h = y[1], a = h.toUpperCase();
|
|
665
|
-
F.includes(a) ? s.push({ type: "keyword", value: h }) : u.includes(a) ? s.push({ type: "function", value: h }) : s.push({ type: "identifier", value: h }), e = e.slice(h.length);
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
s.push({ type: "punctuation", value: e[0] }), e = e.slice(1);
|
|
669
|
-
}
|
|
670
|
-
return s;
|
|
671
|
-
}, pe = { class: "sql-clause-node" }, he = ["title"], me = { class: "sql-clause-node__code" }, ge = ["innerHTML"], be = {
|
|
672
|
-
key: 0,
|
|
673
|
-
class: "sql-clause-node__body"
|
|
674
|
-
}, ve = ["title"], ye = ["innerHTML"], Ee = ["title"], ke = ["innerHTML"], Te = /* @__PURE__ */ M({
|
|
675
|
-
__name: "SqlClauseNode",
|
|
676
|
-
props: {
|
|
677
|
-
clause: {},
|
|
678
|
-
expandedClauses: {},
|
|
679
|
-
theme: {}
|
|
680
|
-
},
|
|
681
|
-
emits: ["toggle"],
|
|
682
|
-
setup(o, { emit: s }) {
|
|
683
|
-
const e = o, u = s, n = _(() => e.clause.path || ""), i = _(() => e.expandedClauses.has(n.value)), t = _(() => {
|
|
684
|
-
const a = e.clause.content.split(`
|
|
685
|
-
`);
|
|
686
|
-
for (const f of a)
|
|
687
|
-
if (f.trim()) return f;
|
|
688
|
-
return "";
|
|
689
|
-
}), c = _(() => {
|
|
690
|
-
const a = e.clause.content.split(`
|
|
691
|
-
`);
|
|
692
|
-
if (a.length <= 1) return "";
|
|
693
|
-
let f = 0;
|
|
694
|
-
for (let l = 0; l < a.length; l++)
|
|
695
|
-
if (a[l].trim()) {
|
|
696
|
-
f = l;
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
return a.slice(f + 1).join(`
|
|
700
|
-
`);
|
|
701
|
-
}), m = _(() => e.clause.body && e.clause.body.length > 0 ? !0 : !!c.value), r = (a) => {
|
|
702
|
-
const f = j(a), l = e.theme.colors;
|
|
703
|
-
return f.map((E) => {
|
|
704
|
-
let k = l.text;
|
|
705
|
-
switch (E.type) {
|
|
706
|
-
case "keyword":
|
|
707
|
-
k = l.sqlKeyword;
|
|
708
|
-
break;
|
|
709
|
-
case "function":
|
|
710
|
-
k = l.sqlFunction;
|
|
711
|
-
break;
|
|
712
|
-
case "string":
|
|
713
|
-
k = l.sqlString;
|
|
714
|
-
break;
|
|
715
|
-
case "number":
|
|
716
|
-
k = l.sqlNumber;
|
|
717
|
-
break;
|
|
718
|
-
case "comment":
|
|
719
|
-
k = l.sqlComment;
|
|
720
|
-
break;
|
|
721
|
-
case "operator":
|
|
722
|
-
k = l.sqlOperator;
|
|
723
|
-
break;
|
|
724
|
-
case "identifier":
|
|
725
|
-
k = l.sqlIdentifier;
|
|
726
|
-
break;
|
|
727
|
-
case "punctuation":
|
|
728
|
-
k = l.sqlPunctuation;
|
|
729
|
-
break;
|
|
730
|
-
case "whitespace":
|
|
731
|
-
return E.value.replace(/ /g, " ").replace(/\n/g, `
|
|
732
|
-
`);
|
|
733
|
-
}
|
|
734
|
-
const T = E.value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
735
|
-
return `<span style="color: ${k}">${T}</span>`;
|
|
736
|
-
}).join("");
|
|
737
|
-
}, d = _(() => {
|
|
738
|
-
const a = e.clause.body;
|
|
739
|
-
if (!a || a.length === 0) return null;
|
|
740
|
-
let f = "", l = !1;
|
|
741
|
-
for (const v of a)
|
|
742
|
-
if (v.kind === "text") {
|
|
743
|
-
const g = v.text.indexOf("(");
|
|
744
|
-
if (g >= 0) {
|
|
745
|
-
f += v.text.slice(0, g), l = !0;
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
f += v.text;
|
|
749
|
-
} else
|
|
750
|
-
return null;
|
|
751
|
-
if (!l) return null;
|
|
752
|
-
let E = "";
|
|
753
|
-
for (let v = a.length - 1; v >= 0; v--) {
|
|
754
|
-
const g = a[v];
|
|
755
|
-
if (g.kind === "text") {
|
|
756
|
-
const S = g.text.lastIndexOf(")");
|
|
757
|
-
if (S >= 0) {
|
|
758
|
-
E = g.text.slice(S + 1) + E;
|
|
759
|
-
break;
|
|
760
|
-
}
|
|
761
|
-
E = g.text + E;
|
|
762
|
-
} else
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
const k = f.replace(/\s+/g, " ").trim(), T = E.replace(/\s+/g, " ").trim(), O = t.value, L = (O.match(/^\s*/) || [""])[0], p = [O.trimStart()];
|
|
766
|
-
return k && p.push(k), p.push("(...)"), T && p.push(T), `${L}${p.join(" ")}`;
|
|
767
|
-
}), b = _(() => {
|
|
768
|
-
if (e.clause.collapsible && !i.value && m.value) {
|
|
769
|
-
const a = d.value;
|
|
770
|
-
if (a)
|
|
771
|
-
return r(a);
|
|
772
|
-
const f = r(t.value), l = e.theme.colors.textSecondary;
|
|
773
|
-
return `${f}<span style="color: ${l}; opacity: 0.6; font-style: italic; margin-left: 4px;"> ...</span>`;
|
|
774
|
-
}
|
|
775
|
-
return r(t.value);
|
|
776
|
-
}), y = () => {
|
|
777
|
-
e.clause.collapsible && u("toggle", n.value);
|
|
778
|
-
}, h = (a) => {
|
|
779
|
-
if (!e.clause.collapsible) return;
|
|
780
|
-
const f = a.target;
|
|
781
|
-
if (!f) return;
|
|
782
|
-
const l = (f.textContent || "").trim();
|
|
783
|
-
(l === "(" || l === ")") && u("toggle", n.value);
|
|
784
|
-
};
|
|
785
|
-
return (a, f) => {
|
|
786
|
-
const l = J("SqlClauseNode", !0);
|
|
787
|
-
return N(), q("div", pe, [
|
|
788
|
-
I("div", {
|
|
789
|
-
class: B(["sql-clause-node__header", { "sql-clause-node__header--collapsible": a.clause.collapsible }]),
|
|
790
|
-
title: a.clause.collapsible ? i.value ? "Click to collapse" : "Click to expand" : "",
|
|
791
|
-
onClick: y
|
|
792
|
-
}, [
|
|
793
|
-
I("pre", me, [
|
|
794
|
-
I("code", { innerHTML: b.value }, null, 8, ge)
|
|
795
|
-
])
|
|
796
|
-
], 10, he),
|
|
797
|
-
i.value && m.value ? (N(), q("div", be, [
|
|
798
|
-
a.clause.body && a.clause.body.length > 0 ? (N(!0), q($, { key: 0 }, H(a.clause.body, (E, k) => (N(), q($, { key: k }, [
|
|
799
|
-
E.kind === "text" ? (N(), q("pre", {
|
|
800
|
-
key: 0,
|
|
801
|
-
class: B(["sql-clause-node__code sql-clause-node__text-segment", { "sql-clause-node__text-segment--clickable": a.clause.collapsible }]),
|
|
802
|
-
title: a.clause.collapsible ? "Click ( or ) to collapse" : "",
|
|
803
|
-
onClick: f[0] || (f[0] = (T) => h(T))
|
|
804
|
-
}, [
|
|
805
|
-
I("code", {
|
|
806
|
-
innerHTML: r(E.text)
|
|
807
|
-
}, null, 8, ye)
|
|
808
|
-
], 10, ve)) : (N(), P(l, {
|
|
809
|
-
key: 1,
|
|
810
|
-
clause: E.clause,
|
|
811
|
-
"expanded-clauses": a.expandedClauses,
|
|
812
|
-
theme: a.theme,
|
|
813
|
-
onToggle: f[1] || (f[1] = (T) => a.$emit("toggle", T))
|
|
814
|
-
}, null, 8, ["clause", "expanded-clauses", "theme"]))
|
|
815
|
-
], 64))), 128)) : (N(), q("pre", {
|
|
816
|
-
key: 1,
|
|
817
|
-
class: B(["sql-clause-node__code sql-clause-node__rest", { "sql-clause-node__rest--clickable": a.clause.collapsible }]),
|
|
818
|
-
title: a.clause.collapsible ? "Click ( or ) to collapse" : "",
|
|
819
|
-
onClick: f[2] || (f[2] = (E) => h(E))
|
|
820
|
-
}, [
|
|
821
|
-
I("code", {
|
|
822
|
-
innerHTML: r(c.value)
|
|
823
|
-
}, null, 8, ke)
|
|
824
|
-
], 10, Ee))
|
|
825
|
-
])) : Q("", !0)
|
|
826
|
-
]);
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
}), Ce = /* @__PURE__ */ D(Te, [["__scopeId", "data-v-8b9383dc"]]), Ne = { class: "sql-format__content" }, Se = {
|
|
830
|
-
key: 0,
|
|
831
|
-
class: "sql-format__error"
|
|
832
|
-
}, qe = {
|
|
833
|
-
key: 1,
|
|
834
|
-
class: "sql-format__viewer"
|
|
835
|
-
}, _e = {
|
|
836
|
-
key: 0,
|
|
837
|
-
class: "sql-format__clauses"
|
|
838
|
-
}, Ie = {
|
|
839
|
-
key: 1,
|
|
840
|
-
class: "sql-format__code"
|
|
841
|
-
}, Oe = ["innerHTML"], Le = /* @__PURE__ */ M({
|
|
842
|
-
__name: "index",
|
|
843
|
-
props: {
|
|
844
|
-
modelValue: { default: "" },
|
|
845
|
-
readonly: { type: Boolean, default: !1 },
|
|
846
|
-
theme: { default: "github-light" },
|
|
847
|
-
dialect: { default: "sql" },
|
|
848
|
-
tabWidth: { default: 2 }
|
|
849
|
-
},
|
|
850
|
-
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
851
|
-
setup(o, { expose: s, emit: e }) {
|
|
852
|
-
G((p) => ({
|
|
853
|
-
"175be318": y.value.colors.background,
|
|
854
|
-
"6c8d0a97": y.value.colors.text,
|
|
855
|
-
e09ea4a8: y.value.colors.errorBackground,
|
|
856
|
-
"2446b9de": y.value.colors.error
|
|
857
|
-
}));
|
|
858
|
-
const u = (p) => {
|
|
859
|
-
const v = [], g = (S) => {
|
|
860
|
-
for (const C of S)
|
|
861
|
-
if (C.path && v.push(C.path), C.body)
|
|
862
|
-
for (const R of C.body)
|
|
863
|
-
R.kind === "clause" && g([R.clause]);
|
|
864
|
-
};
|
|
865
|
-
return g(p), v;
|
|
866
|
-
}, n = o, i = e, t = w(""), c = w(n.dialect), m = w([]), r = w(/* @__PURE__ */ new Set()), d = w(""), b = _(() => t.value === ""), y = _(() => te(n.theme)), h = (p) => {
|
|
867
|
-
if (!p || !p.trim()) {
|
|
868
|
-
t.value = "", m.value = [], r.value.clear();
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
try {
|
|
872
|
-
const v = ne(p);
|
|
873
|
-
if (!v.valid) {
|
|
874
|
-
t.value = v.error || "Invalid SQL", m.value = [], d.value = "";
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
const g = fe(p);
|
|
878
|
-
m.value = g.clauses, d.value = A(p, {
|
|
879
|
-
dialect: c.value,
|
|
880
|
-
tabWidth: n.tabWidth
|
|
881
|
-
}), r.value = new Set(u(g.clauses)), t.value = "";
|
|
882
|
-
} catch (v) {
|
|
883
|
-
t.value = v instanceof Error ? v.message : "Unknown parse error", m.value = [], d.value = "";
|
|
884
|
-
}
|
|
885
|
-
}, a = (p) => {
|
|
886
|
-
const v = j(p), g = y.value.colors;
|
|
887
|
-
return v.map((S) => {
|
|
888
|
-
let C = g.text;
|
|
889
|
-
switch (S.type) {
|
|
890
|
-
case "keyword":
|
|
891
|
-
C = g.sqlKeyword;
|
|
892
|
-
break;
|
|
893
|
-
case "function":
|
|
894
|
-
C = g.sqlFunction;
|
|
895
|
-
break;
|
|
896
|
-
case "string":
|
|
897
|
-
C = g.sqlString;
|
|
898
|
-
break;
|
|
899
|
-
case "number":
|
|
900
|
-
C = g.sqlNumber;
|
|
901
|
-
break;
|
|
902
|
-
case "comment":
|
|
903
|
-
C = g.sqlComment;
|
|
904
|
-
break;
|
|
905
|
-
case "operator":
|
|
906
|
-
C = g.sqlOperator;
|
|
907
|
-
break;
|
|
908
|
-
case "identifier":
|
|
909
|
-
C = g.sqlIdentifier;
|
|
910
|
-
break;
|
|
911
|
-
case "punctuation":
|
|
912
|
-
C = g.sqlPunctuation;
|
|
913
|
-
break;
|
|
914
|
-
case "whitespace":
|
|
915
|
-
return S.value.replace(/ /g, " ").replace(/\n/g, `
|
|
916
|
-
`);
|
|
917
|
-
}
|
|
918
|
-
const R = S.value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
919
|
-
return `<span style="color: ${C}">${R}</span>`;
|
|
920
|
-
}).join("");
|
|
921
|
-
}, f = (p) => {
|
|
922
|
-
r.value.has(p) ? r.value.delete(p) : r.value.add(p), r.value = new Set(r.value);
|
|
923
|
-
}, l = () => {
|
|
924
|
-
r.value = new Set(u(m.value)), i("expand-all");
|
|
925
|
-
}, E = () => {
|
|
926
|
-
r.value = /* @__PURE__ */ new Set(), i("collapse-all");
|
|
927
|
-
}, k = async () => {
|
|
928
|
-
if (b.value)
|
|
929
|
-
try {
|
|
930
|
-
const p = d.value || n.modelValue;
|
|
931
|
-
await navigator.clipboard.writeText(p), i("copy-success", p);
|
|
932
|
-
} catch (p) {
|
|
933
|
-
const v = p instanceof Error ? p : new Error("Failed to copy");
|
|
934
|
-
i("copy-error", v);
|
|
935
|
-
}
|
|
936
|
-
}, T = () => {
|
|
937
|
-
if (b.value)
|
|
938
|
-
try {
|
|
939
|
-
const p = A(n.modelValue, {
|
|
940
|
-
dialect: c.value,
|
|
941
|
-
tabWidth: n.tabWidth
|
|
942
|
-
});
|
|
943
|
-
i("update:modelValue", p), i("format", p);
|
|
944
|
-
} catch (p) {
|
|
945
|
-
console.error("Format error:", p);
|
|
946
|
-
}
|
|
947
|
-
}, O = () => {
|
|
948
|
-
if (b.value)
|
|
949
|
-
try {
|
|
950
|
-
const p = le(n.modelValue);
|
|
951
|
-
i("update:modelValue", p), i("compress", p);
|
|
952
|
-
} catch (p) {
|
|
953
|
-
console.error("Compress error:", p);
|
|
954
|
-
}
|
|
955
|
-
}, L = () => null, x = () => t.value;
|
|
956
|
-
return U(
|
|
957
|
-
() => n.modelValue,
|
|
958
|
-
(p) => {
|
|
959
|
-
h(p);
|
|
960
|
-
},
|
|
961
|
-
{ immediate: !0 }
|
|
962
|
-
), U(
|
|
963
|
-
() => n.dialect,
|
|
964
|
-
(p) => {
|
|
965
|
-
c.value = p;
|
|
966
|
-
}
|
|
967
|
-
), s({
|
|
968
|
-
copySql: k,
|
|
969
|
-
formatSource: T,
|
|
970
|
-
compressSource: O,
|
|
971
|
-
expandAll: l,
|
|
972
|
-
collapseAll: E,
|
|
973
|
-
toggleExpand: f,
|
|
974
|
-
isValidSql: () => b.value,
|
|
975
|
-
getParsedSql: L,
|
|
976
|
-
getParseError: x
|
|
977
|
-
}), (p, v) => (N(), q("div", {
|
|
978
|
-
class: B(["sql-format", `sql-format--${y.value.name}`])
|
|
979
|
-
}, [
|
|
980
|
-
I("div", Ne, [
|
|
981
|
-
b.value ? (N(), q("div", qe, [
|
|
982
|
-
m.value.length > 0 ? (N(), q("div", _e, [
|
|
983
|
-
(N(!0), q($, null, H(m.value, (g) => (N(), P(Ce, {
|
|
984
|
-
key: g.path,
|
|
985
|
-
clause: g,
|
|
986
|
-
"expanded-clauses": r.value,
|
|
987
|
-
theme: y.value,
|
|
988
|
-
onToggle: f
|
|
989
|
-
}, null, 8, ["clause", "expanded-clauses", "theme"]))), 128))
|
|
990
|
-
])) : (N(), q("pre", Ie, [
|
|
991
|
-
I("code", {
|
|
992
|
-
innerHTML: a(n.modelValue)
|
|
993
|
-
}, null, 8, Oe)
|
|
994
|
-
]))
|
|
995
|
-
])) : (N(), q("div", Se, [
|
|
996
|
-
v[0] || (v[0] = I("h4", null, "SQL Parse Error:", -1)),
|
|
997
|
-
I("pre", null, z(t.value), 1)
|
|
998
|
-
]))
|
|
999
|
-
])
|
|
1000
|
-
], 2));
|
|
1001
|
-
}
|
|
1002
|
-
}), Be = /* @__PURE__ */ D(Le, [["__scopeId", "data-v-36f32aa6"]]);
|
|
1003
|
-
export {
|
|
1004
|
-
Be as S
|
|
1005
|
-
};
|