lone-format 0.14.0 → 0.16.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-Bc-10qZH.js +1035 -0
- package/dist/_chunks/{index-AlOFzpXl.js → index-BqjA0ynE.js} +152 -110
- package/dist/_chunks/{index-BAEkF-Fh.js → index-Du4VL__q.js} +527 -470
- package/dist/components/JsonFormat/index.js +1 -1
- package/dist/components/JsonFormat/themes.d.ts +4 -0
- package/dist/components/JsonFormat/types.d.ts +1 -1
- package/dist/components/SqlFormat/index.js +1 -1
- package/dist/components/SqlFormat/parser.d.ts +3 -3
- package/dist/components/SqlFormat/themes.d.ts +5 -1
- package/dist/components/SqlFormat/types.d.ts +3 -5
- package/dist/components/XmlFormat/index.js +17 -16
- package/dist/components/XmlFormat/themes.d.ts +5 -1
- package/dist/components/XmlFormat/types.d.ts +1 -1
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +3 -3
- package/dist/lone-format.umd.cjs +47 -47
- package/package.json +1 -1
- package/dist/_chunks/index-5wbkWClK.js +0 -1006
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { defineComponent as ce, useCssVars as ie, ref as B, computed as
|
|
2
|
-
import { JSONPath as
|
|
3
|
-
import { _ as
|
|
1
|
+
import { defineComponent as ce, useCssVars as ie, ref as B, computed as _, resolveComponent as pe, createElementBlock as p, openBlock as m, createElementVNode as S, createCommentVNode as w, withKeys as U, withModifiers as ue, toDisplayString as J, Fragment as me, renderList as ge, createVNode as de, normalizeClass as fe, nextTick as X, watch as be } from "vue";
|
|
2
|
+
import { JSONPath as _e } from "jsonpath-plus";
|
|
3
|
+
import { _ as ye } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
4
4
|
const ke = { class: "json-node" }, he = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "json-node__container"
|
|
7
7
|
}, Be = { class: "json-node__line" }, xe = ["contenteditable", "onKeydown"], Ne = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "json-node__colon"
|
|
10
|
-
},
|
|
10
|
+
}, Se = ["title"], je = ["title"], Ae = {
|
|
11
11
|
key: 4,
|
|
12
12
|
class: "json-node__comma"
|
|
13
13
|
}, Ee = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "json-node__children"
|
|
16
|
-
}, we = { class: "json-node__children-content" }, Oe = { class: "json-node__line json-node__closing-bracket" },
|
|
16
|
+
}, we = { class: "json-node__children-content" }, Oe = { class: "json-node__line json-node__closing-bracket" }, Te = { class: "json-node__bracket" }, Je = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "json-node__comma"
|
|
19
19
|
}, $e = {
|
|
@@ -22,10 +22,10 @@ const ke = { class: "json-node" }, he = {
|
|
|
22
22
|
}, Ve = ["contenteditable", "onKeydown"], Pe = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "json-node__colon"
|
|
25
|
-
}, Ce = ["title"],
|
|
25
|
+
}, Ce = ["title"], De = ["contenteditable", "onKeydown"], Fe = {
|
|
26
26
|
key: 0,
|
|
27
27
|
class: "json-node__comma"
|
|
28
|
-
},
|
|
28
|
+
}, He = /* @__PURE__ */ ce({
|
|
29
29
|
name: "JsonNode",
|
|
30
30
|
__name: "JsonNode",
|
|
31
31
|
props: {
|
|
@@ -55,30 +55,30 @@ const ke = { class: "json-node" }, he = {
|
|
|
55
55
|
"3cee3331": n.theme.colors.selectionBackground,
|
|
56
56
|
"81323cee": n.theme.colors.indentLine
|
|
57
57
|
}));
|
|
58
|
-
const a = M, $ = oe, g = B(!1), f = B(!1), x = B(""),
|
|
58
|
+
const a = M, $ = oe, g = B(!1), f = B(!1), x = B(""), b = B(""), y = B("string"), v = B(null), A = B(null), N = (n) => n !== null && typeof n == "object" && !Array.isArray(n) && "__protected_number__" in n && Object.keys(n).length === 1, E = (n) => N(n) ? n.__protected_number__ : "", C = _(() => N(a.value) ? !1 : a.value !== null && typeof a.value == "object"), D = _(() => Array.isArray(a.value)), h = _(() => a.path ? a.path : a.keyName ? a.keyName : "root"), V = _(() => a.expanded.has(h.value)), Y = _(() => a.keyName), se = _(() => D.value ? "[" : "{"), F = _(() => D.value ? "]" : "}"), W = _(() => {
|
|
59
59
|
if (!a.value) return "";
|
|
60
60
|
const c = Object.keys(a.value).length;
|
|
61
|
-
return
|
|
62
|
-
}), ee =
|
|
61
|
+
return D.value ? c > 0 ? ` ${c} items ` : " " : c > 0 ? ` ${c} keys ` : " ";
|
|
62
|
+
}), ee = _(() => {
|
|
63
63
|
const n = typeof a.value;
|
|
64
64
|
return a.value === null ? "json-node__value--null" : n === "boolean" ? "json-node__value--boolean" : n === "number" || N(a.value) ? "json-node__value--number" : n === "string" ? "json-node__value--string" : "";
|
|
65
|
-
}), ae =
|
|
65
|
+
}), ae = _(() => a.value === null ? "null" : typeof a.value == "boolean" || typeof a.value == "number" ? String(a.value) : N(a.value) ? E(a.value) : typeof a.value == "string" ? `"${a.value}"` : String(a.value)), le = _(() => "Double-click to edit"), H = (n) => a.level === 0 ? n : h.value ? `${h.value}.${n}` : n, te = (n) => {
|
|
66
66
|
const c = Object.keys(a.value);
|
|
67
67
|
return c.indexOf(n) === c.length - 1;
|
|
68
68
|
}, z = () => {
|
|
69
69
|
$("toggle-expand", h.value);
|
|
70
70
|
}, Z = () => {
|
|
71
71
|
a.level !== 0 && (g.value = !0, x.value = a.keyName, X(() => {
|
|
72
|
-
if (
|
|
73
|
-
|
|
72
|
+
if (v.value) {
|
|
73
|
+
v.value.focus();
|
|
74
74
|
const n = document.createRange();
|
|
75
|
-
n.selectNodeContents(
|
|
75
|
+
n.selectNodeContents(v.value);
|
|
76
76
|
const c = window.getSelection();
|
|
77
77
|
c?.removeAllRanges(), c?.addRange(n);
|
|
78
78
|
}
|
|
79
79
|
}));
|
|
80
|
-
},
|
|
81
|
-
C.value || (f.value = !0, a.value === null ?
|
|
80
|
+
}, L = () => {
|
|
81
|
+
C.value || (f.value = !0, a.value === null ? y.value = "null" : N(a.value) ? y.value = "protected-number" : typeof a.value == "string" ? y.value = "string" : typeof a.value == "number" ? y.value = "number" : typeof a.value == "boolean" && (y.value = "boolean"), N(a.value) ? b.value = E(a.value) : typeof a.value == "string" ? b.value = a.value : b.value = String(a.value), X(() => {
|
|
82
82
|
if (A.value) {
|
|
83
83
|
A.value.focus();
|
|
84
84
|
const n = document.createRange();
|
|
@@ -89,7 +89,7 @@ const ke = { class: "json-node" }, he = {
|
|
|
89
89
|
}));
|
|
90
90
|
}, K = () => {
|
|
91
91
|
if (a.level === 0 || !g.value) return;
|
|
92
|
-
const n =
|
|
92
|
+
const n = v.value?.innerText.trim() || "";
|
|
93
93
|
if (!n) {
|
|
94
94
|
q();
|
|
95
95
|
return;
|
|
@@ -104,9 +104,9 @@ const ke = { class: "json-node" }, he = {
|
|
|
104
104
|
try {
|
|
105
105
|
let n;
|
|
106
106
|
const c = A.value?.innerText.trim() || "";
|
|
107
|
-
if (
|
|
107
|
+
if (y.value === "string")
|
|
108
108
|
c === "null" ? n = null : c === "true" || c === "false" ? n = c === "true" : n = c;
|
|
109
|
-
else if (
|
|
109
|
+
else if (y.value === "protected-number")
|
|
110
110
|
n = { __protected_number__: c };
|
|
111
111
|
else if (c === "null")
|
|
112
112
|
n = null;
|
|
@@ -124,13 +124,13 @@ const ke = { class: "json-node" }, he = {
|
|
|
124
124
|
}, q = () => {
|
|
125
125
|
g.value = !1, x.value = a.keyName;
|
|
126
126
|
}, re = () => {
|
|
127
|
-
f.value = !1, N(a.value) ?
|
|
127
|
+
f.value = !1, N(a.value) ? b.value = E(a.value) : typeof a.value == "string" ? b.value = a.value : b.value = String(a.value);
|
|
128
128
|
};
|
|
129
129
|
return (n, c) => {
|
|
130
130
|
const I = pe("JsonNode", !0);
|
|
131
131
|
return m(), p("div", ke, [
|
|
132
132
|
C.value ? (m(), p("div", he, [
|
|
133
|
-
|
|
133
|
+
S("div", Be, [
|
|
134
134
|
n.keyName ? (m(), p("span", {
|
|
135
135
|
key: 0,
|
|
136
136
|
class: "json-node__key",
|
|
@@ -142,40 +142,40 @@ const ke = { class: "json-node" }, he = {
|
|
|
142
142
|
],
|
|
143
143
|
onBlur: K,
|
|
144
144
|
ref_key: "keyRef",
|
|
145
|
-
ref:
|
|
145
|
+
ref: v,
|
|
146
146
|
title: "Double-click to edit key"
|
|
147
|
-
},
|
|
147
|
+
}, J(g.value ? x.value : `"${Y.value}"`), 41, xe)) : w("", !0),
|
|
148
148
|
n.keyName ? (m(), p("span", Ne, ": ")) : w("", !0),
|
|
149
|
-
|
|
149
|
+
S("span", {
|
|
150
150
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
151
151
|
onClick: z,
|
|
152
152
|
title: V.value ? "Click to collapse" : "Click to expand"
|
|
153
|
-
},
|
|
153
|
+
}, J(se.value), 9, Se),
|
|
154
154
|
V.value ? w("", !0) : (m(), p("span", {
|
|
155
155
|
key: 2,
|
|
156
156
|
class: "json-node__collapsed-info",
|
|
157
157
|
onClick: z,
|
|
158
158
|
title: `Click to expand ${W.value.trim()}`
|
|
159
|
-
},
|
|
159
|
+
}, J(W.value), 9, je)),
|
|
160
160
|
V.value ? w("", !0) : (m(), p("span", {
|
|
161
161
|
key: 3,
|
|
162
162
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
163
163
|
onClick: z,
|
|
164
164
|
title: "Click to expand"
|
|
165
|
-
},
|
|
165
|
+
}, J(F.value), 1)),
|
|
166
166
|
!V.value && !n.isLast ? (m(), p("span", Ae, ",")) : w("", !0)
|
|
167
167
|
]),
|
|
168
168
|
V.value ? (m(), p("div", Ee, [
|
|
169
|
-
|
|
169
|
+
S("div", we, [
|
|
170
170
|
(m(!0), p(me, null, ge(n.value, (R, P) => (m(), p("div", {
|
|
171
171
|
key: P,
|
|
172
172
|
class: "json-node__child"
|
|
173
173
|
}, [
|
|
174
174
|
de(I, {
|
|
175
175
|
value: R,
|
|
176
|
-
"key-name":
|
|
176
|
+
"key-name": D.value ? "" : String(P),
|
|
177
177
|
level: n.level + 1,
|
|
178
|
-
path:
|
|
178
|
+
path: H(String(P)),
|
|
179
179
|
expanded: n.expanded,
|
|
180
180
|
theme: n.theme,
|
|
181
181
|
"onUpdate:value": c[0] || (c[0] = (O, G) => n.$emit("update:value", O, G)),
|
|
@@ -186,9 +186,9 @@ const ke = { class: "json-node" }, he = {
|
|
|
186
186
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
187
187
|
]))), 128))
|
|
188
188
|
]),
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
n.isLast ? w("", !0) : (m(), p("span",
|
|
189
|
+
S("div", Oe, [
|
|
190
|
+
S("span", Te, J(F.value), 1),
|
|
191
|
+
n.isLast ? w("", !0) : (m(), p("span", Je, ","))
|
|
192
192
|
])
|
|
193
193
|
])) : w("", !0)
|
|
194
194
|
])) : (m(), p("div", $e, [
|
|
@@ -203,16 +203,16 @@ const ke = { class: "json-node" }, he = {
|
|
|
203
203
|
],
|
|
204
204
|
onBlur: K,
|
|
205
205
|
ref_key: "keyRef",
|
|
206
|
-
ref:
|
|
206
|
+
ref: v,
|
|
207
207
|
title: "Double-click to edit key"
|
|
208
|
-
},
|
|
208
|
+
}, J(g.value ? x.value : `"${Y.value}"`), 41, Ve)) : w("", !0),
|
|
209
209
|
n.keyName ? (m(), p("span", Pe, ": ")) : w("", !0),
|
|
210
|
-
|
|
210
|
+
S("span", {
|
|
211
211
|
class: fe(["json-node__value-wrapper", ee.value]),
|
|
212
|
-
onDblclick:
|
|
212
|
+
onDblclick: L,
|
|
213
213
|
title: le.value
|
|
214
214
|
}, [
|
|
215
|
-
|
|
215
|
+
S("span", {
|
|
216
216
|
class: "json-node__value",
|
|
217
217
|
contenteditable: f.value,
|
|
218
218
|
onKeydown: [
|
|
@@ -222,14 +222,14 @@ const ke = { class: "json-node" }, he = {
|
|
|
222
222
|
onBlur: ne,
|
|
223
223
|
ref_key: "valueRef",
|
|
224
224
|
ref: A
|
|
225
|
-
},
|
|
226
|
-
n.isLast ? w("", !0) : (m(), p("span",
|
|
225
|
+
}, J(f.value ? b.value : ae.value), 41, De),
|
|
226
|
+
n.isLast ? w("", !0) : (m(), p("span", Fe, ","))
|
|
227
227
|
], 42, Ce)
|
|
228
228
|
]))
|
|
229
229
|
]);
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
-
}),
|
|
232
|
+
}), Le = /* @__PURE__ */ ye(He, [["__scopeId", "data-v-1472a8af"]]), ve = {
|
|
233
233
|
name: "github-light",
|
|
234
234
|
colors: {
|
|
235
235
|
// 背景色
|
|
@@ -353,6 +353,47 @@ const ke = { class: "json-node" }, he = {
|
|
|
353
353
|
indentLine: "#e5e7eb"
|
|
354
354
|
}
|
|
355
355
|
}, Re = {
|
|
356
|
+
name: "min-dark",
|
|
357
|
+
colors: {
|
|
358
|
+
// 背景色 - 低对比暗色
|
|
359
|
+
background: "#111111",
|
|
360
|
+
surfaceBackground: "#1a1a1a",
|
|
361
|
+
// 边框色 - 柔和深灰
|
|
362
|
+
border: "#2a2a2a",
|
|
363
|
+
// 文本色 - 柔和浅灰
|
|
364
|
+
text: "#e5e5e5",
|
|
365
|
+
textSecondary: "#a3a3a3",
|
|
366
|
+
// 按钮样式 - 简约暗色
|
|
367
|
+
buttonBackground: "#1f1f1f",
|
|
368
|
+
buttonBackgroundHover: "#2a2a2a",
|
|
369
|
+
buttonBorder: "#333333",
|
|
370
|
+
buttonText: "#e5e5e5",
|
|
371
|
+
buttonPrimary: "#3b82f6",
|
|
372
|
+
buttonPrimaryHover: "#2563eb",
|
|
373
|
+
// 状态指示 - 暗色可读性
|
|
374
|
+
success: "#22c55e",
|
|
375
|
+
successBackground: "#052e16",
|
|
376
|
+
error: "#f87171",
|
|
377
|
+
errorBackground: "#450a0a",
|
|
378
|
+
// JSON 语法高亮 - 极简暗色配色
|
|
379
|
+
syntaxString: "#4ade80",
|
|
380
|
+
syntaxNumber: "#60a5fa",
|
|
381
|
+
syntaxBoolean: "#c084fc",
|
|
382
|
+
syntaxNull: "#9ca3af",
|
|
383
|
+
syntaxKey: "#f3f4f6",
|
|
384
|
+
syntaxBracket: "#d1d5db",
|
|
385
|
+
// 悬停效果
|
|
386
|
+
hoverBackground: "#1f1f1f",
|
|
387
|
+
// 选中背景色
|
|
388
|
+
selectionBackground: "rgba(96, 165, 250, 0.25)",
|
|
389
|
+
// 折叠信息样式
|
|
390
|
+
collapsedBackground: "#1e293b",
|
|
391
|
+
collapsedBackgroundHover: "#334155",
|
|
392
|
+
collapsedText: "#60a5fa",
|
|
393
|
+
// 缩进线
|
|
394
|
+
indentLine: "#374151"
|
|
395
|
+
}
|
|
396
|
+
}, Ue = {
|
|
356
397
|
name: "slack-ochin",
|
|
357
398
|
colors: {
|
|
358
399
|
// 背景色 - 温暖的米色调
|
|
@@ -393,25 +434,26 @@ const ke = { class: "json-node" }, he = {
|
|
|
393
434
|
// 缩进线
|
|
394
435
|
indentLine: "#e8d5b7"
|
|
395
436
|
}
|
|
396
|
-
},
|
|
397
|
-
"github-light":
|
|
437
|
+
}, Me = {
|
|
438
|
+
"github-light": ve,
|
|
398
439
|
"github-dark": Ke,
|
|
399
440
|
"min-light": Ie,
|
|
400
|
-
"
|
|
441
|
+
"min-dark": Re,
|
|
442
|
+
"slack-ochin": Ue
|
|
401
443
|
};
|
|
402
|
-
function
|
|
403
|
-
return
|
|
444
|
+
function We(M = "github-light") {
|
|
445
|
+
return Me[M] || ve;
|
|
404
446
|
}
|
|
405
|
-
const
|
|
447
|
+
const ze = { class: "json-format__content" }, Ze = {
|
|
406
448
|
key: 0,
|
|
407
449
|
class: "json-format__error"
|
|
408
|
-
},
|
|
450
|
+
}, qe = {
|
|
409
451
|
key: 1,
|
|
410
452
|
class: "json-format__error"
|
|
411
|
-
},
|
|
453
|
+
}, Ge = {
|
|
412
454
|
key: 2,
|
|
413
455
|
class: "json-format__viewer"
|
|
414
|
-
},
|
|
456
|
+
}, Qe = /* @__PURE__ */ ce({
|
|
415
457
|
name: "JsonFormat",
|
|
416
458
|
__name: "index",
|
|
417
459
|
props: {
|
|
@@ -428,7 +470,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
428
470
|
"729aad5e": E.value.colors.error,
|
|
429
471
|
"640bad42": E.value.colors.errorBackground
|
|
430
472
|
}));
|
|
431
|
-
const $ = M, g = a, f = B(null), x = B(""),
|
|
473
|
+
const $ = M, g = a, f = B(null), x = B(""), b = B(/* @__PURE__ */ new Set()), y = B(null), v = B(""), A = B(!1), N = _(() => x.value === ""), E = _(() => We($.theme)), C = (e) => {
|
|
432
474
|
if (e == null)
|
|
433
475
|
return e;
|
|
434
476
|
if (Array.isArray(e))
|
|
@@ -440,12 +482,12 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
440
482
|
return t;
|
|
441
483
|
}
|
|
442
484
|
return e;
|
|
443
|
-
},
|
|
444
|
-
const e =
|
|
485
|
+
}, D = _(() => {
|
|
486
|
+
const e = y.value !== null ? y.value : f.value;
|
|
445
487
|
return !e || !A.value ? e : C(e);
|
|
446
|
-
}), h =
|
|
488
|
+
}), h = _(() => v.value ? null : D.value), V = (e) => {
|
|
447
489
|
if (!e.trim()) {
|
|
448
|
-
f.value = null, x.value = "",
|
|
490
|
+
f.value = null, x.value = "", y.value = null, v.value = "";
|
|
449
491
|
return;
|
|
450
492
|
}
|
|
451
493
|
try {
|
|
@@ -453,8 +495,8 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
453
495
|
const s = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(t), o = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(t);
|
|
454
496
|
if (!s && !o)
|
|
455
497
|
try {
|
|
456
|
-
f.value = JSON.parse(t), x.value = "",
|
|
457
|
-
h.value !== null &&
|
|
498
|
+
f.value = JSON.parse(t), x.value = "", y.value = null, v.value = "", X(() => {
|
|
499
|
+
h.value !== null && L();
|
|
458
500
|
});
|
|
459
501
|
return;
|
|
460
502
|
} catch {
|
|
@@ -462,31 +504,31 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
462
504
|
t = ((r) => {
|
|
463
505
|
let l = "", i = !1, d = !1, k = 0;
|
|
464
506
|
for (; k < r.length; ) {
|
|
465
|
-
const
|
|
507
|
+
const T = r[k];
|
|
466
508
|
if (i)
|
|
467
|
-
d ? d = !1 :
|
|
468
|
-
else if (
|
|
469
|
-
i = !0, l +=
|
|
509
|
+
d ? d = !1 : T === "\\" ? d = !0 : T === '"' && (i = !1), l += T, k++;
|
|
510
|
+
else if (T === '"')
|
|
511
|
+
i = !0, l += T, k++;
|
|
470
512
|
else {
|
|
471
513
|
const Q = r.slice(k);
|
|
472
|
-
let
|
|
473
|
-
if (
|
|
474
|
-
l +=
|
|
514
|
+
let j = Q.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
515
|
+
if (j) {
|
|
516
|
+
l += j[1] + '{"__protected_number__":"' + j[2] + '"}' + j[3], k += j[0].length;
|
|
475
517
|
continue;
|
|
476
518
|
}
|
|
477
|
-
if (
|
|
478
|
-
l +=
|
|
519
|
+
if (j = Q.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), j) {
|
|
520
|
+
l += j[1] + '{"__protected_number__":"' + j[2] + '"}' + j[3], k += j[0].length;
|
|
479
521
|
continue;
|
|
480
522
|
}
|
|
481
|
-
l +=
|
|
523
|
+
l += T, k++;
|
|
482
524
|
}
|
|
483
525
|
}
|
|
484
526
|
return l;
|
|
485
|
-
})(t), f.value = JSON.parse(t), x.value = "",
|
|
486
|
-
h.value !== null &&
|
|
527
|
+
})(t), f.value = JSON.parse(t), x.value = "", y.value = null, v.value = "", X(() => {
|
|
528
|
+
h.value !== null && L();
|
|
487
529
|
});
|
|
488
530
|
} catch (t) {
|
|
489
|
-
x.value = t instanceof Error ? t.message : "Unknown parsing error", f.value = null,
|
|
531
|
+
x.value = t instanceof Error ? t.message : "Unknown parsing error", f.value = null, y.value = null, v.value = "";
|
|
490
532
|
}
|
|
491
533
|
}, Y = (e) => {
|
|
492
534
|
if (!e || !e.expression.trim()) {
|
|
@@ -494,13 +536,13 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
494
536
|
return;
|
|
495
537
|
}
|
|
496
538
|
if (!f.value) {
|
|
497
|
-
|
|
539
|
+
v.value = "No valid JSON data to filter";
|
|
498
540
|
return;
|
|
499
541
|
}
|
|
500
542
|
try {
|
|
501
543
|
let t;
|
|
502
544
|
if (e.type === "jsonpath")
|
|
503
|
-
t =
|
|
545
|
+
t = _e({ path: e.expression, json: f.value }), t.length === 1 && e.expression.includes("$[") === !1 && !e.expression.endsWith("[*]") ? y.value = t[0] : y.value = t;
|
|
504
546
|
else if (e.type === "js") {
|
|
505
547
|
const { proxyData: s, indexMap: o } = se(f.value), r = new Function("$", `
|
|
506
548
|
try {
|
|
@@ -509,14 +551,14 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
509
551
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
510
552
|
}
|
|
511
553
|
`)(s);
|
|
512
|
-
t =
|
|
554
|
+
t = F(f.value, r, o), y.value = t;
|
|
513
555
|
} else
|
|
514
556
|
throw new Error(`Unsupported filter type: ${e.type}`);
|
|
515
|
-
|
|
516
|
-
|
|
557
|
+
v.value = "", X(() => {
|
|
558
|
+
L();
|
|
517
559
|
});
|
|
518
560
|
} catch (t) {
|
|
519
|
-
|
|
561
|
+
v.value = t instanceof Error ? t.message : "Filter execution error", y.value = null;
|
|
520
562
|
}
|
|
521
563
|
}, se = (e, t = "root") => {
|
|
522
564
|
const s = /* @__PURE__ */ new Map(), o = (r, l) => {
|
|
@@ -528,8 +570,8 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
528
570
|
}
|
|
529
571
|
if (Array.isArray(r)) {
|
|
530
572
|
const i = r.map((d, k) => {
|
|
531
|
-
const
|
|
532
|
-
return s.set(Q,
|
|
573
|
+
const T = `${l}[${k}]`, Q = o(d, T);
|
|
574
|
+
return s.set(Q, T), Q;
|
|
533
575
|
});
|
|
534
576
|
return s.set(i, l), i;
|
|
535
577
|
}
|
|
@@ -545,7 +587,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
545
587
|
return r;
|
|
546
588
|
};
|
|
547
589
|
return { proxyData: o(e, t), indexMap: s };
|
|
548
|
-
},
|
|
590
|
+
}, F = (e, t, s) => {
|
|
549
591
|
if (t === null || typeof t != "object")
|
|
550
592
|
return t;
|
|
551
593
|
if (Array.isArray(t))
|
|
@@ -556,7 +598,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
556
598
|
if (i !== void 0)
|
|
557
599
|
return i;
|
|
558
600
|
}
|
|
559
|
-
return
|
|
601
|
+
return F(e, r, s);
|
|
560
602
|
});
|
|
561
603
|
const o = s.get(t);
|
|
562
604
|
if (o) {
|
|
@@ -566,7 +608,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
566
608
|
}
|
|
567
609
|
const u = {};
|
|
568
610
|
for (const r in t)
|
|
569
|
-
Object.prototype.hasOwnProperty.call(t, r) && (u[r] =
|
|
611
|
+
Object.prototype.hasOwnProperty.call(t, r) && (u[r] = F(e, t[r], s));
|
|
570
612
|
return u;
|
|
571
613
|
}, W = (e, t) => {
|
|
572
614
|
if (t === "root") return e;
|
|
@@ -584,16 +626,16 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
584
626
|
}
|
|
585
627
|
return l;
|
|
586
628
|
}, ee = () => {
|
|
587
|
-
|
|
629
|
+
y.value = null, v.value = "";
|
|
588
630
|
}, ae = () => {
|
|
589
631
|
A.value = !0;
|
|
590
632
|
}, le = () => {
|
|
591
633
|
A.value = !1;
|
|
592
634
|
};
|
|
593
|
-
|
|
635
|
+
be(() => $.modelValue, (e) => {
|
|
594
636
|
V(e);
|
|
595
637
|
}, { immediate: !0 });
|
|
596
|
-
const
|
|
638
|
+
const H = (e, t, s) => {
|
|
597
639
|
const o = (l) => {
|
|
598
640
|
if (l === null || typeof l != "object")
|
|
599
641
|
return l;
|
|
@@ -610,7 +652,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
610
652
|
}, te = (e, t) => {
|
|
611
653
|
if (!$.readonly)
|
|
612
654
|
try {
|
|
613
|
-
const s = z(f.value, e, t), o =
|
|
655
|
+
const s = z(f.value, e, t), o = H(s, null, 2);
|
|
614
656
|
g("update:modelValue", o);
|
|
615
657
|
} catch (s) {
|
|
616
658
|
console.error("Failed to update JSON:", s);
|
|
@@ -626,8 +668,8 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
626
668
|
const l = o[o.length - 1];
|
|
627
669
|
return l === "root" ? s : (Array.isArray(r) ? r[parseInt(l)] = s : r[l] = s, u);
|
|
628
670
|
}, Z = (e) => {
|
|
629
|
-
|
|
630
|
-
},
|
|
671
|
+
b.value.has(e) ? b.value.delete(e) : b.value.add(e);
|
|
672
|
+
}, L = () => {
|
|
631
673
|
const e = /* @__PURE__ */ new Set(), t = (s, o = "") => {
|
|
632
674
|
s !== null && typeof s == "object" && (e.add(o || "root"), Array.isArray(s) ? s.forEach((u, r) => {
|
|
633
675
|
const l = o ? `${o}.${r}` : `${r}`;
|
|
@@ -637,13 +679,13 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
637
679
|
t(s[u], r);
|
|
638
680
|
}));
|
|
639
681
|
};
|
|
640
|
-
t(h.value),
|
|
682
|
+
t(h.value), b.value = e, g("expand-all");
|
|
641
683
|
}, K = () => {
|
|
642
|
-
|
|
684
|
+
b.value = /* @__PURE__ */ new Set(), g("collapse-all");
|
|
643
685
|
}, ne = async () => {
|
|
644
686
|
if (N.value)
|
|
645
687
|
try {
|
|
646
|
-
const e = h.value, t =
|
|
688
|
+
const e = h.value, t = H(e, null, 2);
|
|
647
689
|
await navigator.clipboard.writeText(t), g("copy-success", t);
|
|
648
690
|
} catch (e) {
|
|
649
691
|
console.error("Failed to copy JSON:", e), g("copy-error", e instanceof Error ? e : new Error("Failed to copy JSON"));
|
|
@@ -651,7 +693,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
651
693
|
}, q = () => {
|
|
652
694
|
if (N.value)
|
|
653
695
|
try {
|
|
654
|
-
const e = h.value, t =
|
|
696
|
+
const e = h.value, t = H(e);
|
|
655
697
|
g("update:modelValue", t), g("compress", t);
|
|
656
698
|
} catch (e) {
|
|
657
699
|
console.error("Failed to compress JSON:", e);
|
|
@@ -672,7 +714,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
672
714
|
}, c = (e, t) => {
|
|
673
715
|
if (!$.readonly)
|
|
674
716
|
try {
|
|
675
|
-
const s = I(f.value, e, t), o =
|
|
717
|
+
const s = I(f.value, e, t), o = H(s, null, 2);
|
|
676
718
|
g("update:modelValue", o), G(e, t);
|
|
677
719
|
} catch (s) {
|
|
678
720
|
console.error("Failed to rename key:", s);
|
|
@@ -722,7 +764,7 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
722
764
|
Array.isArray(o) ? o[parseInt(u)] = s : o[u] = s;
|
|
723
765
|
}, G = (e, t) => {
|
|
724
766
|
const s = /* @__PURE__ */ new Set();
|
|
725
|
-
|
|
767
|
+
b.value.forEach((o) => {
|
|
726
768
|
if (o === e) {
|
|
727
769
|
const u = e.split(".");
|
|
728
770
|
u[u.length - 1] = t, s.add(u.join("."));
|
|
@@ -733,13 +775,13 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
733
775
|
s.add(r + l);
|
|
734
776
|
} else
|
|
735
777
|
s.add(o);
|
|
736
|
-
}),
|
|
778
|
+
}), b.value = s;
|
|
737
779
|
};
|
|
738
780
|
return oe({
|
|
739
781
|
// 核心操作方法
|
|
740
782
|
copyJson: ne,
|
|
741
783
|
compressSource: q,
|
|
742
|
-
expandAll:
|
|
784
|
+
expandAll: L,
|
|
743
785
|
collapseAll: K,
|
|
744
786
|
toggleExpand: Z,
|
|
745
787
|
updateValue: te,
|
|
@@ -754,10 +796,10 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
754
796
|
// 状态访问方法
|
|
755
797
|
isValidJson: () => N.value,
|
|
756
798
|
getParsedJson: () => f.value,
|
|
757
|
-
getFilteredJson: () =>
|
|
758
|
-
getExpandedNodes: () =>
|
|
799
|
+
getFilteredJson: () => y.value,
|
|
800
|
+
getExpandedNodes: () => b.value,
|
|
759
801
|
getParseError: () => x.value,
|
|
760
|
-
getFilterError: () =>
|
|
802
|
+
getFilterError: () => v.value,
|
|
761
803
|
// 工具方法
|
|
762
804
|
parseJson: (e) => V(e),
|
|
763
805
|
copyValue: (e) => n(e),
|
|
@@ -765,16 +807,16 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
765
807
|
}), (e, t) => (m(), p("div", {
|
|
766
808
|
class: fe(["json-format", `json-format--${E.value.name}`])
|
|
767
809
|
}, [
|
|
768
|
-
|
|
769
|
-
N.value ?
|
|
770
|
-
t[1] || (t[1] =
|
|
771
|
-
|
|
772
|
-
])) : (m(), p("div",
|
|
773
|
-
de(
|
|
810
|
+
S("div", ze, [
|
|
811
|
+
N.value ? v.value ? (m(), p("div", qe, [
|
|
812
|
+
t[1] || (t[1] = S("h4", null, "Filter Error:", -1)),
|
|
813
|
+
S("pre", null, J(v.value), 1)
|
|
814
|
+
])) : (m(), p("div", Ge, [
|
|
815
|
+
de(Le, {
|
|
774
816
|
value: h.value,
|
|
775
817
|
"key-name": "",
|
|
776
818
|
level: 0,
|
|
777
|
-
expanded:
|
|
819
|
+
expanded: b.value,
|
|
778
820
|
"is-last": !0,
|
|
779
821
|
theme: E.value,
|
|
780
822
|
"onUpdate:value": te,
|
|
@@ -782,14 +824,14 @@ const We = { class: "json-format__content" }, ze = {
|
|
|
782
824
|
onCopy: n,
|
|
783
825
|
"onUpdate:key": c
|
|
784
826
|
}, null, 8, ["value", "expanded", "theme"])
|
|
785
|
-
])) : (m(), p("div",
|
|
786
|
-
t[0] || (t[0] =
|
|
787
|
-
|
|
827
|
+
])) : (m(), p("div", Ze, [
|
|
828
|
+
t[0] || (t[0] = S("h4", null, "JSON Parse Error:", -1)),
|
|
829
|
+
S("pre", null, J(x.value), 1)
|
|
788
830
|
]))
|
|
789
831
|
])
|
|
790
832
|
], 2));
|
|
791
833
|
}
|
|
792
|
-
}),
|
|
834
|
+
}), tt = /* @__PURE__ */ ye(Qe, [["__scopeId", "data-v-4559cb85"]]);
|
|
793
835
|
export {
|
|
794
|
-
|
|
836
|
+
tt as J
|
|
795
837
|
};
|