lone-format 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +1,31 @@
1
- import { defineComponent as ue, useCssVars as ce, ref as B, computed as b, resolveComponent as ve, createElementBlock as p, openBlock as m, createElementVNode as j, createCommentVNode as w, withKeys as R, withModifiers as le, toDisplayString as $, Fragment as pe, renderList as me, createVNode as ie, normalizeClass as de, nextTick as G, watch as ge } from "vue";
2
- import { JSONPath as _e } from "jsonpath-plus";
3
- import { _ as fe } from "./_plugin-vue_export-helper-CHgC5LLL.js";
4
- const be = { class: "json-node" }, ke = {
1
+ import { defineComponent as ce, useCssVars as ie, ref as B, computed as b, resolveComponent as pe, createElementBlock as p, openBlock as m, createElementVNode as j, createCommentVNode as w, withKeys as U, withModifiers as ue, toDisplayString as T, Fragment as me, renderList as ge, createVNode as de, normalizeClass as fe, nextTick as X, watch as _e } from "vue";
2
+ import { JSONPath as be } from "jsonpath-plus";
3
+ import { _ as ve } from "./_plugin-vue_export-helper-CHgC5LLL.js";
4
+ const ke = { class: "json-node" }, he = {
5
5
  key: 0,
6
6
  class: "json-node__container"
7
- }, he = { class: "json-node__line" }, Be = ["contenteditable", "onKeydown"], xe = {
7
+ }, Be = { class: "json-node__line" }, xe = ["contenteditable", "onKeydown"], Ne = {
8
8
  key: 1,
9
9
  class: "json-node__colon"
10
- }, Ne = ["title"], je = ["title"], Se = {
10
+ }, je = ["title"], Se = ["title"], Ae = {
11
11
  key: 4,
12
12
  class: "json-node__comma"
13
- }, Ae = {
13
+ }, Ee = {
14
14
  key: 0,
15
15
  class: "json-node__children"
16
- }, Ee = { class: "json-node__children-content" }, we = { class: "json-node__line json-node__closing-bracket" }, Oe = { class: "json-node__bracket" }, Je = {
16
+ }, we = { class: "json-node__children-content" }, Oe = { class: "json-node__line json-node__closing-bracket" }, Je = { class: "json-node__bracket" }, Te = {
17
17
  key: 0,
18
18
  class: "json-node__comma"
19
- }, Te = {
19
+ }, $e = {
20
20
  key: 1,
21
21
  class: "json-node__primitive"
22
- }, $e = ["contenteditable", "onKeydown"], Ve = {
22
+ }, Ve = ["contenteditable", "onKeydown"], Pe = {
23
23
  key: 1,
24
24
  class: "json-node__colon"
25
- }, Pe = ["title"], Ce = ["contenteditable", "onKeydown"], Fe = {
25
+ }, Ce = ["title"], Fe = ["contenteditable", "onKeydown"], De = {
26
26
  key: 0,
27
27
  class: "json-node__comma"
28
- }, De = /* @__PURE__ */ ue({
28
+ }, Le = /* @__PURE__ */ ce({
29
29
  name: "JsonNode",
30
30
  __name: "JsonNode",
31
31
  props: {
@@ -38,8 +38,8 @@ const be = { class: "json-node" }, ke = {
38
38
  theme: {}
39
39
  },
40
40
  emits: ["update:value", "toggle-expand", "copy", "update:key"],
41
- setup(U, { emit: re }) {
42
- ce((n) => ({
41
+ setup(M, { emit: oe }) {
42
+ ie((n) => ({
43
43
  "2a18b018": n.level,
44
44
  "58a14b93": n.theme.colors.syntaxKey,
45
45
  "46fe1b3e": n.theme.colors.hoverBackground,
@@ -55,30 +55,30 @@ const be = { class: "json-node" }, ke = {
55
55
  "3cee3331": n.theme.colors.selectionBackground,
56
56
  "81323cee": n.theme.colors.indentLine
57
57
  }));
58
- const a = U, V = re, g = B(!1), f = B(!1), x = 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 = b(() => N(a.value) ? !1 : a.value !== null && typeof a.value == "object"), F = b(() => Array.isArray(a.value)), h = b(() => a.path ? a.path : a.keyName ? a.keyName : "root"), P = b(() => a.expanded.has(h.value)), Q = b(() => a.keyName), oe = b(() => F.value ? "[" : "{"), D = b(() => F.value ? "]" : "}"), M = b(() => {
58
+ const a = M, $ = oe, g = B(!1), f = B(!1), x = B(""), _ = B(""), v = B("string"), y = 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 = b(() => N(a.value) ? !1 : a.value !== null && typeof a.value == "object"), F = b(() => Array.isArray(a.value)), h = b(() => a.path ? a.path : a.keyName ? a.keyName : "root"), V = b(() => a.expanded.has(h.value)), Y = b(() => a.keyName), se = b(() => F.value ? "[" : "{"), D = b(() => F.value ? "]" : "}"), W = b(() => {
59
59
  if (!a.value) return "";
60
60
  const c = Object.keys(a.value).length;
61
61
  return F.value ? c > 0 ? ` ${c} items ` : " " : c > 0 ? ` ${c} keys ` : " ";
62
- }), X = b(() => {
62
+ }), ee = b(() => {
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
- }), se = b(() => 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)), ae = b(() => "Double-click to edit"), L = (n) => a.level === 0 ? n : h.value ? `${h.value}.${n}` : n, Y = (n) => {
65
+ }), ae = b(() => 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 = b(() => "Double-click to edit"), L = (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
- }, W = () => {
69
- V("toggle-expand", h.value);
70
68
  }, z = () => {
71
- a.level !== 0 && (g.value = !0, x.value = a.keyName, G(() => {
72
- if (v.value) {
73
- v.value.focus();
69
+ $("toggle-expand", h.value);
70
+ }, Z = () => {
71
+ a.level !== 0 && (g.value = !0, x.value = a.keyName, X(() => {
72
+ if (y.value) {
73
+ y.value.focus();
74
74
  const n = document.createRange();
75
- n.selectNodeContents(v.value);
75
+ n.selectNodeContents(y.value);
76
76
  const c = window.getSelection();
77
77
  c?.removeAllRanges(), c?.addRange(n);
78
78
  }
79
79
  }));
80
80
  }, H = () => {
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) ? _.value = E(a.value) : typeof a.value == "string" ? _.value = a.value : _.value = String(a.value), G(() => {
81
+ C.value || (f.value = !0, a.value === null ? v.value = "null" : N(a.value) ? v.value = "protected-number" : typeof a.value == "string" ? v.value = "string" : typeof a.value == "number" ? v.value = "number" : typeof a.value == "boolean" && (v.value = "boolean"), N(a.value) ? _.value = E(a.value) : typeof a.value == "string" ? _.value = a.value : _.value = String(a.value), X(() => {
82
82
  if (A.value) {
83
83
  A.value.focus();
84
84
  const n = document.createRange();
@@ -89,147 +89,147 @@ const be = { class: "json-node" }, ke = {
89
89
  }));
90
90
  }, K = () => {
91
91
  if (a.level === 0 || !g.value) return;
92
- const n = v.value?.innerText.trim() || "";
92
+ const n = y.value?.innerText.trim() || "";
93
93
  if (!n) {
94
- Z();
94
+ q();
95
95
  return;
96
96
  }
97
97
  if (n === a.keyName) {
98
98
  g.value = !1;
99
99
  return;
100
100
  }
101
- g.value = !1, V("update:key", h.value, n);
102
- }, ee = () => {
101
+ g.value = !1, $("update:key", h.value, n);
102
+ }, ne = () => {
103
103
  if (f.value)
104
104
  try {
105
105
  let n;
106
106
  const c = A.value?.innerText.trim() || "";
107
- if (y.value === "string")
107
+ if (v.value === "string")
108
108
  c === "null" ? n = null : c === "true" || c === "false" ? n = c === "true" : n = c;
109
- else if (y.value === "protected-number")
109
+ else if (v.value === "protected-number")
110
110
  n = { __protected_number__: c };
111
111
  else if (c === "null")
112
112
  n = null;
113
113
  else if (c === "true" || c === "false")
114
114
  n = c === "true";
115
115
  else if (!isNaN(Number(c)) && c !== "") {
116
- const O = Number(c);
117
- !Number.isSafeInteger(O) || c.length > 15 ? n = { __protected_number__: c } : n = O;
116
+ const I = Number(c);
117
+ !Number.isSafeInteger(I) || c.length > 15 ? n = { __protected_number__: c } : n = I;
118
118
  } else
119
119
  n = c;
120
- V("update:value", h.value, n), f.value = !1;
120
+ $("update:value", h.value, n), f.value = !1;
121
121
  } catch (n) {
122
122
  console.error("Failed to parse value:", n), f.value = !1;
123
123
  }
124
- }, Z = () => {
124
+ }, q = () => {
125
125
  g.value = !1, x.value = a.keyName;
126
- }, te = () => {
126
+ }, re = () => {
127
127
  f.value = !1, N(a.value) ? _.value = E(a.value) : typeof a.value == "string" ? _.value = a.value : _.value = String(a.value);
128
128
  };
129
129
  return (n, c) => {
130
- const O = ve("JsonNode", !0);
131
- return m(), p("div", be, [
132
- C.value ? (m(), p("div", ke, [
133
- j("div", he, [
130
+ const I = pe("JsonNode", !0);
131
+ return m(), p("div", ke, [
132
+ C.value ? (m(), p("div", he, [
133
+ j("div", Be, [
134
134
  n.keyName ? (m(), p("span", {
135
135
  key: 0,
136
136
  class: "json-node__key",
137
137
  contenteditable: g.value,
138
- onDblclick: z,
138
+ onDblclick: Z,
139
139
  onKeydown: [
140
- R(le(K, ["prevent"]), ["enter"]),
141
- R(Z, ["escape"])
140
+ U(ue(K, ["prevent"]), ["enter"]),
141
+ U(q, ["escape"])
142
142
  ],
143
143
  onBlur: K,
144
144
  ref_key: "keyRef",
145
- ref: v,
145
+ ref: y,
146
146
  title: "Double-click to edit key"
147
- }, $(g.value ? x.value : `"${Q.value}"`), 41, Be)) : w("", !0),
148
- n.keyName ? (m(), p("span", xe, ": ")) : w("", !0),
147
+ }, T(g.value ? x.value : `"${Y.value}"`), 41, xe)) : w("", !0),
148
+ n.keyName ? (m(), p("span", Ne, ": ")) : w("", !0),
149
149
  j("span", {
150
150
  class: "json-node__bracket json-node__bracket--clickable",
151
- onClick: W,
152
- title: P.value ? "Click to collapse" : "Click to expand"
153
- }, $(oe.value), 9, Ne),
154
- P.value ? w("", !0) : (m(), p("span", {
151
+ onClick: z,
152
+ title: V.value ? "Click to collapse" : "Click to expand"
153
+ }, T(se.value), 9, je),
154
+ V.value ? w("", !0) : (m(), p("span", {
155
155
  key: 2,
156
156
  class: "json-node__collapsed-info",
157
- onClick: W,
158
- title: `Click to expand ${M.value.trim()}`
159
- }, $(M.value), 9, je)),
160
- P.value ? w("", !0) : (m(), p("span", {
157
+ onClick: z,
158
+ title: `Click to expand ${W.value.trim()}`
159
+ }, T(W.value), 9, Se)),
160
+ V.value ? w("", !0) : (m(), p("span", {
161
161
  key: 3,
162
162
  class: "json-node__bracket json-node__bracket--clickable",
163
- onClick: W,
163
+ onClick: z,
164
164
  title: "Click to expand"
165
- }, $(D.value), 1)),
166
- !P.value && !n.isLast ? (m(), p("span", Se, ",")) : w("", !0)
165
+ }, T(D.value), 1)),
166
+ !V.value && !n.isLast ? (m(), p("span", Ae, ",")) : w("", !0)
167
167
  ]),
168
- P.value ? (m(), p("div", Ae, [
169
- j("div", Ee, [
170
- (m(!0), p(pe, null, me(n.value, (ne, I) => (m(), p("div", {
171
- key: I,
168
+ V.value ? (m(), p("div", Ee, [
169
+ j("div", we, [
170
+ (m(!0), p(me, null, ge(n.value, (R, P) => (m(), p("div", {
171
+ key: P,
172
172
  class: "json-node__child"
173
173
  }, [
174
- ie(O, {
175
- value: ne,
176
- "key-name": F.value ? "" : String(I),
174
+ de(I, {
175
+ value: R,
176
+ "key-name": F.value ? "" : String(P),
177
177
  level: n.level + 1,
178
- path: L(String(I)),
178
+ path: L(String(P)),
179
179
  expanded: n.expanded,
180
180
  theme: n.theme,
181
- "onUpdate:value": c[0] || (c[0] = (J, e) => n.$emit("update:value", J, e)),
182
- onToggleExpand: c[1] || (c[1] = (J) => n.$emit("toggle-expand", J)),
183
- onCopy: c[2] || (c[2] = (J) => n.$emit("copy", J)),
184
- "onUpdate:key": c[3] || (c[3] = (J, e) => n.$emit("update:key", J, e)),
185
- "is-last": Y(String(I))
181
+ "onUpdate:value": c[0] || (c[0] = (O, G) => n.$emit("update:value", O, G)),
182
+ onToggleExpand: c[1] || (c[1] = (O) => n.$emit("toggle-expand", O)),
183
+ onCopy: c[2] || (c[2] = (O) => n.$emit("copy", O)),
184
+ "onUpdate:key": c[3] || (c[3] = (O, G) => n.$emit("update:key", O, G)),
185
+ "is-last": te(String(P))
186
186
  }, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
187
187
  ]))), 128))
188
188
  ]),
189
- j("div", we, [
190
- j("span", Oe, $(D.value), 1),
191
- n.isLast ? w("", !0) : (m(), p("span", Je, ","))
189
+ j("div", Oe, [
190
+ j("span", Je, T(D.value), 1),
191
+ n.isLast ? w("", !0) : (m(), p("span", Te, ","))
192
192
  ])
193
193
  ])) : w("", !0)
194
- ])) : (m(), p("div", Te, [
194
+ ])) : (m(), p("div", $e, [
195
195
  n.keyName ? (m(), p("span", {
196
196
  key: 0,
197
197
  class: "json-node__key",
198
198
  contenteditable: g.value,
199
- onDblclick: z,
199
+ onDblclick: Z,
200
200
  onKeydown: [
201
- R(le(K, ["prevent"]), ["enter"]),
202
- R(Z, ["escape"])
201
+ U(ue(K, ["prevent"]), ["enter"]),
202
+ U(q, ["escape"])
203
203
  ],
204
204
  onBlur: K,
205
205
  ref_key: "keyRef",
206
- ref: v,
206
+ ref: y,
207
207
  title: "Double-click to edit key"
208
- }, $(g.value ? x.value : `"${Q.value}"`), 41, $e)) : w("", !0),
209
- n.keyName ? (m(), p("span", Ve, ": ")) : w("", !0),
208
+ }, T(g.value ? x.value : `"${Y.value}"`), 41, Ve)) : w("", !0),
209
+ n.keyName ? (m(), p("span", Pe, ": ")) : w("", !0),
210
210
  j("span", {
211
- class: de(["json-node__value-wrapper", X.value]),
211
+ class: fe(["json-node__value-wrapper", ee.value]),
212
212
  onDblclick: H,
213
- title: ae.value
213
+ title: le.value
214
214
  }, [
215
215
  j("span", {
216
216
  class: "json-node__value",
217
217
  contenteditable: f.value,
218
218
  onKeydown: [
219
- R(le(ee, ["prevent"]), ["enter"]),
220
- R(te, ["escape"])
219
+ U(ue(ne, ["prevent"]), ["enter"]),
220
+ U(re, ["escape"])
221
221
  ],
222
- onBlur: ee,
222
+ onBlur: ne,
223
223
  ref_key: "valueRef",
224
224
  ref: A
225
- }, $(f.value ? _.value : se.value), 41, Ce),
226
- n.isLast ? w("", !0) : (m(), p("span", Fe, ","))
227
- ], 42, Pe)
225
+ }, T(f.value ? _.value : ae.value), 41, Fe),
226
+ n.isLast ? w("", !0) : (m(), p("span", De, ","))
227
+ ], 42, Ce)
228
228
  ]))
229
229
  ]);
230
230
  };
231
231
  }
232
- }), Le = /* @__PURE__ */ fe(De, [["__scopeId", "data-v-1472a8af"]]), ye = {
232
+ }), He = /* @__PURE__ */ ve(Le, [["__scopeId", "data-v-1472a8af"]]), ye = {
233
233
  name: "github-light",
234
234
  colors: {
235
235
  // 背景色
@@ -270,7 +270,7 @@ const be = { class: "json-node" }, ke = {
270
270
  // 缩进线
271
271
  indentLine: "#d0d7de"
272
272
  }
273
- }, He = {
273
+ }, Ke = {
274
274
  name: "github-dark",
275
275
  colors: {
276
276
  // 背景色
@@ -311,7 +311,7 @@ const be = { class: "json-node" }, ke = {
311
311
  // 缩进线
312
312
  indentLine: "#30363d"
313
313
  }
314
- }, Ke = {
314
+ }, Ie = {
315
315
  name: "min-light",
316
316
  colors: {
317
317
  // 背景色 - 纯白简洁
@@ -352,7 +352,7 @@ const be = { class: "json-node" }, ke = {
352
352
  // 缩进线
353
353
  indentLine: "#e5e7eb"
354
354
  }
355
- }, Ie = {
355
+ }, Re = {
356
356
  name: "slack-ochin",
357
357
  colors: {
358
358
  // 背景色 - 温暖的米色调
@@ -393,25 +393,25 @@ const be = { class: "json-node" }, ke = {
393
393
  // 缩进线
394
394
  indentLine: "#e8d5b7"
395
395
  }
396
- }, Re = {
396
+ }, Ue = {
397
397
  "github-light": ye,
398
- "github-dark": He,
399
- "min-light": Ke,
400
- "slack-ochin": Ie
398
+ "github-dark": Ke,
399
+ "min-light": Ie,
400
+ "slack-ochin": Re
401
401
  };
402
- function Ue(U = "github-light") {
403
- return Re[U] || ye;
402
+ function Me(M = "github-light") {
403
+ return Ue[M] || ye;
404
404
  }
405
- const Me = { class: "json-format__content" }, We = {
405
+ const We = { class: "json-format__content" }, ze = {
406
406
  key: 0,
407
407
  class: "json-format__error"
408
- }, ze = {
408
+ }, Ze = {
409
409
  key: 1,
410
410
  class: "json-format__error"
411
- }, Ze = {
411
+ }, qe = {
412
412
  key: 2,
413
413
  class: "json-format__viewer"
414
- }, qe = /* @__PURE__ */ ue({
414
+ }, Ge = /* @__PURE__ */ ce({
415
415
  name: "JsonFormat",
416
416
  __name: "index",
417
417
  props: {
@@ -421,14 +421,14 @@ const Me = { class: "json-format__content" }, We = {
421
421
  theme: { default: "github-light" }
422
422
  },
423
423
  emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
424
- setup(U, { expose: re, emit: a }) {
425
- ce((e) => ({
426
- "1909cc0c": E.value.colors.background,
427
- "1d49ba8b": E.value.colors.text,
428
- e9bfef2c: E.value.colors.error,
429
- "16d23d38": E.value.colors.errorBackground
424
+ setup(M, { expose: oe, emit: a }) {
425
+ ie((e) => ({
426
+ "4b6ab8f6": E.value.colors.background,
427
+ "37fbe0c4": E.value.colors.text,
428
+ "729aad5e": E.value.colors.error,
429
+ "640bad42": E.value.colors.errorBackground
430
430
  }));
431
- const V = U, g = a, f = B(null), x = B(""), _ = B(/* @__PURE__ */ new Set()), y = B(null), v = B(""), A = B(!1), N = b(() => x.value === ""), E = b(() => Ue(V.theme)), C = (e) => {
431
+ const $ = M, g = a, f = B(null), x = B(""), _ = B(/* @__PURE__ */ new Set()), v = B(null), y = B(""), A = B(!1), N = b(() => x.value === ""), E = b(() => Me($.theme)), C = (e) => {
432
432
  if (e == null)
433
433
  return e;
434
434
  if (Array.isArray(e))
@@ -441,11 +441,11 @@ const Me = { class: "json-format__content" }, We = {
441
441
  }
442
442
  return e;
443
443
  }, F = b(() => {
444
- const e = y.value !== null ? y.value : f.value;
444
+ const e = v.value !== null ? v.value : f.value;
445
445
  return !e || !A.value ? e : C(e);
446
- }), h = b(() => v.value ? null : F.value), P = (e) => {
446
+ }), h = b(() => y.value ? null : F.value), V = (e) => {
447
447
  if (!e.trim()) {
448
- f.value = null, x.value = "", y.value = null, v.value = "";
448
+ f.value = null, x.value = "", v.value = null, y.value = "";
449
449
  return;
450
450
  }
451
451
  try {
@@ -453,7 +453,7 @@ const Me = { class: "json-format__content" }, We = {
453
453
  const s = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(t), o = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(t);
454
454
  if (!s && !o)
455
455
  try {
456
- f.value = JSON.parse(t), x.value = "", y.value = null, v.value = "", G(() => {
456
+ f.value = JSON.parse(t), x.value = "", v.value = null, y.value = "", X(() => {
457
457
  h.value !== null && H();
458
458
  });
459
459
  return;
@@ -462,63 +462,63 @@ const Me = { class: "json-format__content" }, We = {
462
462
  t = ((r) => {
463
463
  let l = "", i = !1, d = !1, k = 0;
464
464
  for (; k < r.length; ) {
465
- const T = r[k];
465
+ const J = r[k];
466
466
  if (i)
467
- d ? d = !1 : T === "\\" ? d = !0 : T === '"' && (i = !1), l += T, k++;
468
- else if (T === '"')
469
- i = !0, l += T, k++;
467
+ d ? d = !1 : J === "\\" ? d = !0 : J === '"' && (i = !1), l += J, k++;
468
+ else if (J === '"')
469
+ i = !0, l += J, k++;
470
470
  else {
471
- const q = r.slice(k);
472
- let S = q.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
471
+ const Q = r.slice(k);
472
+ let S = Q.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
473
473
  if (S) {
474
474
  l += S[1] + '{"__protected_number__":"' + S[2] + '"}' + S[3], k += S[0].length;
475
475
  continue;
476
476
  }
477
- if (S = q.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), S) {
477
+ if (S = Q.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), S) {
478
478
  l += S[1] + '{"__protected_number__":"' + S[2] + '"}' + S[3], k += S[0].length;
479
479
  continue;
480
480
  }
481
- l += T, k++;
481
+ l += J, k++;
482
482
  }
483
483
  }
484
484
  return l;
485
- })(t), f.value = JSON.parse(t), x.value = "", y.value = null, v.value = "", G(() => {
485
+ })(t), f.value = JSON.parse(t), x.value = "", v.value = null, y.value = "", X(() => {
486
486
  h.value !== null && H();
487
487
  });
488
488
  } catch (t) {
489
- x.value = t instanceof Error ? t.message : "Unknown parsing error", f.value = null, y.value = null, v.value = "";
489
+ x.value = t instanceof Error ? t.message : "Unknown parsing error", f.value = null, v.value = null, y.value = "";
490
490
  }
491
- }, Q = (e) => {
491
+ }, Y = (e) => {
492
492
  if (!e || !e.expression.trim()) {
493
- X();
493
+ ee();
494
494
  return;
495
495
  }
496
496
  if (!f.value) {
497
- v.value = "No valid JSON data to filter";
497
+ y.value = "No valid JSON data to filter";
498
498
  return;
499
499
  }
500
500
  try {
501
501
  let t;
502
502
  if (e.type === "jsonpath")
503
- 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;
503
+ t = be({ path: e.expression, json: f.value }), t.length === 1 && e.expression.includes("$[") === !1 && !e.expression.endsWith("[*]") ? v.value = t[0] : v.value = t;
504
504
  else if (e.type === "js") {
505
- const { proxyData: s, indexMap: o } = oe(f.value), r = new Function("$", `
505
+ const { proxyData: s, indexMap: o } = se(f.value), r = new Function("$", `
506
506
  try {
507
507
  return ${e.expression};
508
508
  } catch (error) {
509
509
  throw new Error('JavaScript expression error: ' + error.message);
510
510
  }
511
511
  `)(s);
512
- t = D(f.value, r, o), y.value = t;
512
+ t = D(f.value, r, o), v.value = t;
513
513
  } else
514
514
  throw new Error(`Unsupported filter type: ${e.type}`);
515
- v.value = "", G(() => {
515
+ y.value = "", X(() => {
516
516
  H();
517
517
  });
518
518
  } catch (t) {
519
- v.value = t instanceof Error ? t.message : "Filter execution error", y.value = null;
519
+ y.value = t instanceof Error ? t.message : "Filter execution error", v.value = null;
520
520
  }
521
- }, oe = (e, t = "root") => {
521
+ }, se = (e, t = "root") => {
522
522
  const s = /* @__PURE__ */ new Map(), o = (r, l) => {
523
523
  if (r == null)
524
524
  return r;
@@ -528,8 +528,8 @@ const Me = { class: "json-format__content" }, We = {
528
528
  }
529
529
  if (Array.isArray(r)) {
530
530
  const i = r.map((d, k) => {
531
- const T = `${l}[${k}]`, q = o(d, T);
532
- return s.set(q, T), q;
531
+ const J = `${l}[${k}]`, Q = o(d, J);
532
+ return s.set(Q, J), Q;
533
533
  });
534
534
  return s.set(i, l), i;
535
535
  }
@@ -552,7 +552,7 @@ const Me = { class: "json-format__content" }, We = {
552
552
  return t.map((r) => {
553
553
  const l = s.get(r);
554
554
  if (l) {
555
- const i = M(e, l);
555
+ const i = W(e, l);
556
556
  if (i !== void 0)
557
557
  return i;
558
558
  }
@@ -560,7 +560,7 @@ const Me = { class: "json-format__content" }, We = {
560
560
  });
561
561
  const o = s.get(t);
562
562
  if (o) {
563
- const r = M(e, o);
563
+ const r = W(e, o);
564
564
  if (r !== void 0)
565
565
  return r;
566
566
  }
@@ -568,7 +568,7 @@ const Me = { class: "json-format__content" }, We = {
568
568
  for (const r in t)
569
569
  Object.prototype.hasOwnProperty.call(t, r) && (u[r] = D(e, t[r], s));
570
570
  return u;
571
- }, M = (e, t) => {
571
+ }, W = (e, t) => {
572
572
  if (t === "root") return e;
573
573
  const s = [];
574
574
  let o = t.replace(/^root\.?/, "");
@@ -583,15 +583,15 @@ const Me = { class: "json-format__content" }, We = {
583
583
  l = l[i];
584
584
  }
585
585
  return l;
586
- }, X = () => {
587
- y.value = null, v.value = "";
588
- }, se = () => {
589
- A.value = !0;
586
+ }, ee = () => {
587
+ v.value = null, y.value = "";
590
588
  }, ae = () => {
589
+ A.value = !0;
590
+ }, le = () => {
591
591
  A.value = !1;
592
592
  };
593
- ge(() => V.modelValue, (e) => {
594
- P(e);
593
+ _e(() => $.modelValue, (e) => {
594
+ V(e);
595
595
  }, { immediate: !0 });
596
596
  const L = (e, t, s) => {
597
597
  const o = (l) => {
@@ -607,17 +607,17 @@ const Me = { class: "json-format__content" }, We = {
607
607
  return i;
608
608
  }, u = o(e);
609
609
  return JSON.stringify(u, t, s).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
610
- }, Y = (e, t) => {
611
- if (!V.readonly)
610
+ }, te = (e, t) => {
611
+ if (!$.readonly)
612
612
  try {
613
- const s = W(f.value, e, t), o = L(s, null, 2);
613
+ const s = z(f.value, e, t), o = L(s, null, 2);
614
614
  g("update:modelValue", o);
615
615
  } catch (s) {
616
616
  console.error("Failed to update JSON:", s);
617
617
  }
618
- }, W = (e, t, s) => {
618
+ }, z = (e, t, s) => {
619
619
  if (!t || t === "root") return s;
620
- const o = t.split("."), u = O(e, o.slice(0, -1));
620
+ const o = t.split("."), u = R(e, o.slice(0, -1));
621
621
  let r = u;
622
622
  for (let i = 0; i < o.length - 1; i++) {
623
623
  const d = o[i];
@@ -625,7 +625,7 @@ const Me = { class: "json-format__content" }, We = {
625
625
  }
626
626
  const l = o[o.length - 1];
627
627
  return l === "root" ? s : (Array.isArray(r) ? r[parseInt(l)] = s : r[l] = s, u);
628
- }, z = (e) => {
628
+ }, Z = (e) => {
629
629
  _.value.has(e) ? _.value.delete(e) : _.value.add(e);
630
630
  }, H = () => {
631
631
  const e = /* @__PURE__ */ new Set(), t = (s, o = "") => {
@@ -640,7 +640,7 @@ const Me = { class: "json-format__content" }, We = {
640
640
  t(h.value), _.value = e, g("expand-all");
641
641
  }, K = () => {
642
642
  _.value = /* @__PURE__ */ new Set(), g("collapse-all");
643
- }, ee = async () => {
643
+ }, ne = async () => {
644
644
  if (N.value)
645
645
  try {
646
646
  const e = h.value, t = L(e, null, 2);
@@ -648,7 +648,7 @@ const Me = { class: "json-format__content" }, We = {
648
648
  } catch (e) {
649
649
  console.error("Failed to copy JSON:", e), g("copy-error", e instanceof Error ? e : new Error("Failed to copy JSON"));
650
650
  }
651
- }, Z = () => {
651
+ }, q = () => {
652
652
  if (N.value)
653
653
  try {
654
654
  const e = h.value, t = L(e);
@@ -656,27 +656,33 @@ const Me = { class: "json-format__content" }, We = {
656
656
  } catch (e) {
657
657
  console.error("Failed to compress JSON:", e);
658
658
  }
659
- }, te = async (e) => {
659
+ }, re = (e) => {
660
+ if (typeof e == "object" && e !== null && !Array.isArray(e) && "__protected_number__" in e && Object.keys(e).length === 1)
661
+ return e.__protected_number__;
662
+ if (typeof e == "string")
663
+ return `"${e}"`;
664
+ const t = JSON.stringify(e);
665
+ return t === void 0 ? "undefined" : t;
666
+ }, n = async (e) => {
660
667
  try {
661
- let t;
662
- typeof e == "object" && e !== null && !Array.isArray(e) && "__protected_number__" in e && Object.keys(e).length === 1 ? t = e.__protected_number__ : typeof e == "string" ? t = `"${e}"` : t = JSON.stringify(e), await navigator.clipboard.writeText(t);
668
+ await navigator.clipboard.writeText(re(e));
663
669
  } catch (t) {
664
670
  console.error("Failed to copy value:", t);
665
671
  }
666
- }, n = (e, t) => {
667
- if (!V.readonly)
672
+ }, c = (e, t) => {
673
+ if (!$.readonly)
668
674
  try {
669
- const s = c(f.value, e, t), o = L(s, null, 2);
670
- g("update:modelValue", o), J(e, t);
675
+ const s = I(f.value, e, t), o = L(s, null, 2);
676
+ g("update:modelValue", o), G(e, t);
671
677
  } catch (s) {
672
678
  console.error("Failed to rename key:", s);
673
679
  }
674
- }, c = (e, t, s) => {
680
+ }, I = (e, t, s) => {
675
681
  if (!t || t === "root") return e;
676
- const o = t.split("."), u = O(e, o.slice(0, -1));
682
+ const o = t.split("."), u = R(e, o.slice(0, -1));
677
683
  if (o.length === 1) {
678
684
  const i = o[0];
679
- return u && typeof u == "object" && !Array.isArray(u) ? ne(u, i, s) : u;
685
+ return u && typeof u == "object" && !Array.isArray(u) ? P(u, i, s) : u;
680
686
  }
681
687
  let r = u;
682
688
  for (let i = 0; i < o.length - 1; i++) {
@@ -685,28 +691,28 @@ const Me = { class: "json-format__content" }, We = {
685
691
  }
686
692
  const l = o[o.length - 1];
687
693
  if (!Array.isArray(r) && r && typeof r == "object") {
688
- const i = ne(r, l, s), d = o.slice(0, -1);
689
- d.length > 0 && I(u, d, i);
694
+ const i = P(r, l, s), d = o.slice(0, -1);
695
+ d.length > 0 && O(u, d, i);
690
696
  }
691
697
  return u;
692
- }, O = (e, t) => {
698
+ }, R = (e, t) => {
693
699
  if (t.length === 0) return e;
694
700
  if (Array.isArray(e)) {
695
701
  const s = [...e], o = t[0], u = parseInt(o);
696
- return t.length === 1 || (s[u] = O(e[u], t.slice(1))), s;
702
+ return t.length === 1 || (s[u] = R(e[u], t.slice(1))), s;
697
703
  } else if (e && typeof e == "object") {
698
704
  const s = { ...e }, o = t[0];
699
- return t.length === 1 || (s[o] = O(e[o], t.slice(1))), s;
705
+ return t.length === 1 || (s[o] = R(e[o], t.slice(1))), s;
700
706
  }
701
707
  return e;
702
- }, ne = (e, t, s) => {
708
+ }, P = (e, t, s) => {
703
709
  if (!e || typeof e != "object" || Array.isArray(e))
704
710
  return e;
705
711
  const o = Object.keys(e), u = {};
706
712
  for (const r of o)
707
713
  r === t ? u[s] = e[r] : u[r] = e[r];
708
714
  return u;
709
- }, I = (e, t, s) => {
715
+ }, O = (e, t, s) => {
710
716
  let o = e;
711
717
  for (let r = 0; r < t.length - 1; r++) {
712
718
  const l = t[r];
@@ -714,7 +720,7 @@ const Me = { class: "json-format__content" }, We = {
714
720
  }
715
721
  const u = t[t.length - 1];
716
722
  Array.isArray(o) ? o[parseInt(u)] = s : o[u] = s;
717
- }, J = (e, t) => {
723
+ }, G = (e, t) => {
718
724
  const s = /* @__PURE__ */ new Set();
719
725
  _.value.forEach((o) => {
720
726
  if (o === e) {
@@ -729,60 +735,61 @@ const Me = { class: "json-format__content" }, We = {
729
735
  s.add(o);
730
736
  }), _.value = s;
731
737
  };
732
- return re({
738
+ return oe({
733
739
  // 核心操作方法
734
- copyJson: ee,
735
- compressSource: Z,
740
+ copyJson: ne,
741
+ compressSource: q,
736
742
  expandAll: H,
737
743
  collapseAll: K,
738
- toggleExpand: z,
739
- updateValue: Y,
740
- updateKey: n,
744
+ toggleExpand: Z,
745
+ updateValue: te,
746
+ updateKey: c,
741
747
  // Filter 相关方法
742
- filter: Q,
743
- clearFilter: X,
748
+ filter: Y,
749
+ clearFilter: ee,
744
750
  // Key 排序相关方法
745
- sortKeys: se,
746
- clearSortKeys: ae,
751
+ sortKeys: ae,
752
+ clearSortKeys: le,
747
753
  isSorted: () => A.value,
748
754
  // 状态访问方法
749
755
  isValidJson: () => N.value,
750
756
  getParsedJson: () => f.value,
751
- getFilteredJson: () => y.value,
757
+ getFilteredJson: () => v.value,
752
758
  getExpandedNodes: () => _.value,
753
759
  getParseError: () => x.value,
754
- getFilterError: () => v.value,
760
+ getFilterError: () => y.value,
755
761
  // 工具方法
756
- parseJson: (e) => P(e),
757
- copyValue: (e) => te(e)
762
+ parseJson: (e) => V(e),
763
+ copyValue: (e) => n(e),
764
+ getValue: (e) => re(e)
758
765
  }), (e, t) => (m(), p("div", {
759
- class: de(["json-format", `json-format--${E.value.name}`])
766
+ class: fe(["json-format", `json-format--${E.value.name}`])
760
767
  }, [
761
- j("div", Me, [
762
- N.value ? v.value ? (m(), p("div", ze, [
768
+ j("div", We, [
769
+ N.value ? y.value ? (m(), p("div", Ze, [
763
770
  t[1] || (t[1] = j("h4", null, "Filter Error:", -1)),
764
- j("pre", null, $(v.value), 1)
765
- ])) : (m(), p("div", Ze, [
766
- ie(Le, {
771
+ j("pre", null, T(y.value), 1)
772
+ ])) : (m(), p("div", qe, [
773
+ de(He, {
767
774
  value: h.value,
768
775
  "key-name": "",
769
776
  level: 0,
770
777
  expanded: _.value,
771
778
  "is-last": !0,
772
779
  theme: E.value,
773
- "onUpdate:value": Y,
774
- onToggleExpand: z,
775
- onCopy: te,
776
- "onUpdate:key": n
780
+ "onUpdate:value": te,
781
+ onToggleExpand: Z,
782
+ onCopy: n,
783
+ "onUpdate:key": c
777
784
  }, null, 8, ["value", "expanded", "theme"])
778
- ])) : (m(), p("div", We, [
785
+ ])) : (m(), p("div", ze, [
779
786
  t[0] || (t[0] = j("h4", null, "JSON Parse Error:", -1)),
780
- j("pre", null, $(x.value), 1)
787
+ j("pre", null, T(x.value), 1)
781
788
  ]))
782
789
  ])
783
790
  ], 2));
784
791
  }
785
- }), Ye = /* @__PURE__ */ fe(qe, [["__scopeId", "data-v-a802c0ac"]]);
792
+ }), et = /* @__PURE__ */ ve(Ge, [["__scopeId", "data-v-4559cb85"]]);
786
793
  export {
787
- Ye as J
794
+ et as J
788
795
  };