lone-format 0.2.0 → 0.2.2
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/lone-format.css +1 -1
- package/dist/lone-format.js +342 -317
- package/dist/lone-format.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/lone-format.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
class
|
|
1
|
+
import { defineComponent as fe, useCssVars as pe, ref as R, computed as D, resolveComponent as ve, createElementBlock as A, openBlock as w, createElementVNode as P, createCommentVNode as B, withDirectives as ae, toDisplayString as $, withKeys as Q, vModelText as le, createTextVNode as de, Fragment as _e, renderList as xe, createVNode as ye, normalizeClass as ge, nextTick as ee, watch as ke } from "vue";
|
|
2
|
+
class Oe {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -42,7 +42,7 @@ class Ee {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class Ce {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -615,10 +615,10 @@ class o {
|
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
618
|
+
const Ae = new Oe();
|
|
619
619
|
Object.assign(o, {
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
620
|
+
hooks: Ae,
|
|
621
|
+
plugins: new Ce(o),
|
|
622
622
|
// Node Types
|
|
623
623
|
// ----------
|
|
624
624
|
// This is the full set of types that any JSEP node can be.
|
|
@@ -714,14 +714,14 @@ Object.assign(o, {
|
|
|
714
714
|
});
|
|
715
715
|
o.max_unop_len = o.getMaxKeyLen(o.unary_ops);
|
|
716
716
|
o.max_binop_len = o.getMaxKeyLen(o.binary_ops);
|
|
717
|
-
const L = (r) => new o(r).parse(),
|
|
717
|
+
const L = (r) => new o(r).parse(), we = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(o).filter((r) => !
|
|
719
|
+
Object.getOwnPropertyNames(o).filter((r) => !we.includes(r) && L[r] === void 0).forEach((r) => {
|
|
720
720
|
L[r] = o[r];
|
|
721
721
|
});
|
|
722
722
|
L.Jsep = o;
|
|
723
|
-
const
|
|
724
|
-
var
|
|
723
|
+
const Se = "ConditionalExpression";
|
|
724
|
+
var Pe = {
|
|
725
725
|
name: "ternary",
|
|
726
726
|
init(r) {
|
|
727
727
|
r.hooks.add("after-expression", function(t) {
|
|
@@ -732,7 +732,7 @@ var ke = {
|
|
|
732
732
|
this.index++;
|
|
733
733
|
const a = this.gobbleExpression();
|
|
734
734
|
if (a || this.throwError("Expected expression"), t.node = {
|
|
735
|
-
type:
|
|
735
|
+
type: Se,
|
|
736
736
|
test: s,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: a
|
|
@@ -748,17 +748,17 @@ var ke = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
L.plugins.register(
|
|
752
|
-
const
|
|
753
|
-
var
|
|
751
|
+
L.plugins.register(Pe);
|
|
752
|
+
const he = 47, Ne = 92;
|
|
753
|
+
var Te = {
|
|
754
754
|
name: "regex",
|
|
755
755
|
init(r) {
|
|
756
756
|
r.hooks.add("gobble-token", function(t) {
|
|
757
|
-
if (this.code ===
|
|
757
|
+
if (this.code === he) {
|
|
758
758
|
const s = ++this.index;
|
|
759
759
|
let n = !1;
|
|
760
760
|
for (; this.index < this.expr.length; ) {
|
|
761
|
-
if (this.code ===
|
|
761
|
+
if (this.code === he && !n) {
|
|
762
762
|
const a = this.expr.slice(s, this.index);
|
|
763
763
|
let c = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
@@ -780,34 +780,34 @@ var Ce = {
|
|
|
780
780
|
raw: this.expr.slice(s - 1, this.index)
|
|
781
781
|
}, t.node = this.gobbleTokenProperty(t.node), t.node;
|
|
782
782
|
}
|
|
783
|
-
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code ===
|
|
783
|
+
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code === Ne ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const ce = 43, Be = 45, Y = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [ce, Be],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
797
|
+
Y.assignmentOperators.forEach((s) => r.addBinaryOp(s, Y.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const a = this.code;
|
|
799
|
-
|
|
799
|
+
Y.updateOperators.some((c) => c === a && c === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, n.node = {
|
|
800
800
|
type: "UpdateExpression",
|
|
801
|
-
operator: a ===
|
|
801
|
+
operator: a === ce ? "++" : "--",
|
|
802
802
|
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
803
803
|
prefix: !0
|
|
804
804
|
}, (!n.node.argument || !e.includes(n.node.argument.type)) && this.throwError(`Unexpected ${n.node.operator}`));
|
|
805
805
|
}), r.hooks.add("after-token", function(n) {
|
|
806
806
|
if (n.node) {
|
|
807
807
|
const a = this.code;
|
|
808
|
-
|
|
808
|
+
Y.updateOperators.some((c) => c === a && c === this.expr.charCodeAt(this.index + 1)) && (e.includes(n.node.type) || this.throwError(`Unexpected ${n.node.operator}`), this.index += 2, n.node = {
|
|
809
809
|
type: "UpdateExpression",
|
|
810
|
-
operator: a ===
|
|
810
|
+
operator: a === ce ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -816,17 +816,17 @@ const se = 43, Ae = 45, G = {
|
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
818
|
function t(s) {
|
|
819
|
-
|
|
819
|
+
Y.assignmentOperators.has(s.operator) ? (s.type = "AssignmentExpression", t(s.left), t(s.right)) : s.operator || Object.values(s).forEach((n) => {
|
|
820
820
|
n && typeof n == "object" && t(n);
|
|
821
821
|
});
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
|
-
L.plugins.register(
|
|
825
|
+
L.plugins.register(Te, Y);
|
|
826
826
|
L.addUnaryOp("typeof");
|
|
827
827
|
L.addLiteral("null", null);
|
|
828
828
|
L.addLiteral("undefined", void 0);
|
|
829
|
-
const
|
|
829
|
+
const De = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), O = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -915,7 +915,7 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
915
915
|
), s = O.evalAst(r.object, e);
|
|
916
916
|
if (s == null)
|
|
917
917
|
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
918
|
-
if (!Object.hasOwn(s, t) &&
|
|
918
|
+
if (!Object.hasOwn(s, t) && De.has(t))
|
|
919
919
|
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
920
920
|
const n = s[t];
|
|
921
921
|
return typeof n == "function" ? n.bind(s) : n;
|
|
@@ -944,7 +944,7 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
944
944
|
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class je {
|
|
948
948
|
/**
|
|
949
949
|
* @param {string} expr Expression to evaluate
|
|
950
950
|
*/
|
|
@@ -964,10 +964,10 @@ class Se {
|
|
|
964
964
|
function M(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function ue(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class Ie extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -995,7 +995,7 @@ function x(r, e, t, s, n) {
|
|
|
995
995
|
a ? "json" in r && (c.json = r.json) : c.json = t;
|
|
996
996
|
const f = this.evaluate(c);
|
|
997
997
|
if (!f || typeof f != "object")
|
|
998
|
-
throw new
|
|
998
|
+
throw new Ie(f);
|
|
999
999
|
return f;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
@@ -1061,20 +1061,20 @@ x.prototype._trace = function(r, e, t, s, n, a, c, f) {
|
|
|
1061
1061
|
hasArrExpr: c
|
|
1062
1062
|
}, this._handleCallback(d, a, "value"), d;
|
|
1063
1063
|
const h = r[0], v = r.slice(1), g = [];
|
|
1064
|
-
function k(
|
|
1065
|
-
Array.isArray(
|
|
1064
|
+
function k(E) {
|
|
1065
|
+
Array.isArray(E) ? E.forEach((S) => {
|
|
1066
1066
|
g.push(S);
|
|
1067
|
-
}) : g.push(
|
|
1067
|
+
}) : g.push(E);
|
|
1068
1068
|
}
|
|
1069
1069
|
if ((typeof h != "string" || f) && e && Object.hasOwn(e, h))
|
|
1070
1070
|
k(this._trace(v, e[h], M(t, h), e, h, a, c));
|
|
1071
1071
|
else if (h === "*")
|
|
1072
|
-
this._walk(e, (
|
|
1073
|
-
k(this._trace(v, e[
|
|
1072
|
+
this._walk(e, (E) => {
|
|
1073
|
+
k(this._trace(v, e[E], M(t, E), e, E, a, !0, !0));
|
|
1074
1074
|
});
|
|
1075
1075
|
else if (h === "..")
|
|
1076
|
-
k(this._trace(v, e, t, s, n, a, c)), this._walk(e, (
|
|
1077
|
-
typeof e[
|
|
1076
|
+
k(this._trace(v, e, t, s, n, a, c)), this._walk(e, (E) => {
|
|
1077
|
+
typeof e[E] == "object" && k(this._trace(r.slice(), e[E], M(t, E), e, E, a, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
1080
|
if (h === "^")
|
|
@@ -1097,56 +1097,56 @@ x.prototype._trace = function(r, e, t, s, n, a, c, f) {
|
|
|
1097
1097
|
else if (h.indexOf("?(") === 0) {
|
|
1098
1098
|
if (this.currEval === !1)
|
|
1099
1099
|
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
1100
|
-
const
|
|
1100
|
+
const E = h.replace(/^\?\((.*?)\)$/u, "$1"), S = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(E);
|
|
1101
1101
|
S ? this._walk(e, (C) => {
|
|
1102
|
-
const U = [S[2]],
|
|
1103
|
-
this._trace(U,
|
|
1102
|
+
const U = [S[2]], I = S[1] ? e[C][S[1]] : e[C];
|
|
1103
|
+
this._trace(U, I, t, s, n, a, !0).length > 0 && k(this._trace(v, e[C], M(t, C), e, C, a, !0));
|
|
1104
1104
|
}) : this._walk(e, (C) => {
|
|
1105
|
-
this._eval(
|
|
1105
|
+
this._eval(E, e[C], C, t, s, n) && k(this._trace(v, e[C], M(t, C), e, C, a, !0));
|
|
1106
1106
|
});
|
|
1107
1107
|
} else if (h[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
1109
1109
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1110
|
-
k(this._trace(
|
|
1110
|
+
k(this._trace(ue(this._eval(h, e, t.at(-1), t.slice(0, -1), s, n), v), e, t, s, n, a, c));
|
|
1111
1111
|
} else if (h[0] === "@") {
|
|
1112
|
-
let
|
|
1112
|
+
let E = !1;
|
|
1113
1113
|
const S = h.slice(1, -2);
|
|
1114
1114
|
switch (S) {
|
|
1115
1115
|
case "scalar":
|
|
1116
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
1116
|
+
(!e || !["object", "function"].includes(typeof e)) && (E = !0);
|
|
1117
1117
|
break;
|
|
1118
1118
|
case "boolean":
|
|
1119
1119
|
case "string":
|
|
1120
1120
|
case "undefined":
|
|
1121
1121
|
case "function":
|
|
1122
|
-
typeof e === S && (
|
|
1122
|
+
typeof e === S && (E = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
1125
|
+
Number.isFinite(e) && !(e % 1) && (E = !0);
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "number":
|
|
1128
|
-
Number.isFinite(e) && (
|
|
1128
|
+
Number.isFinite(e) && (E = !0);
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "nonFinite":
|
|
1131
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
1131
|
+
typeof e == "number" && !Number.isFinite(e) && (E = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e === S && (
|
|
1134
|
+
e && typeof e === S && (E = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
|
-
Array.isArray(e) && (
|
|
1137
|
+
Array.isArray(e) && (E = !0);
|
|
1138
1138
|
break;
|
|
1139
1139
|
case "other":
|
|
1140
|
-
|
|
1140
|
+
E = this.currOtherTypeCallback(e, t, s, n);
|
|
1141
1141
|
break;
|
|
1142
1142
|
case "null":
|
|
1143
|
-
e === null && (
|
|
1143
|
+
e === null && (E = !0);
|
|
1144
1144
|
break;
|
|
1145
1145
|
/* c8 ignore next 2 */
|
|
1146
1146
|
default:
|
|
1147
1147
|
throw new TypeError("Unknown value type " + S);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1149
|
+
if (E)
|
|
1150
1150
|
return d = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
@@ -1154,26 +1154,26 @@ x.prototype._trace = function(r, e, t, s, n, a, c, f) {
|
|
|
1154
1154
|
parentProperty: n
|
|
1155
1155
|
}, this._handleCallback(d, a, "value"), d;
|
|
1156
1156
|
} else if (h[0] === "`" && e && Object.hasOwn(e, h.slice(1))) {
|
|
1157
|
-
const
|
|
1158
|
-
k(this._trace(v, e[
|
|
1157
|
+
const E = h.slice(1);
|
|
1158
|
+
k(this._trace(v, e[E], M(t, E), e, E, a, c, !0));
|
|
1159
1159
|
} else if (h.includes(",")) {
|
|
1160
|
-
const
|
|
1161
|
-
for (const S of
|
|
1162
|
-
k(this._trace(
|
|
1160
|
+
const E = h.split(",");
|
|
1161
|
+
for (const S of E)
|
|
1162
|
+
k(this._trace(ue(S, v), e, t, s, n, a, !0));
|
|
1163
1163
|
} else !f && e && Object.hasOwn(e, h) && k(this._trace(v, e[h], M(t, h), e, h, a, c, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const S = g[
|
|
1166
|
+
for (let E = 0; E < g.length; E++) {
|
|
1167
|
+
const S = g[E];
|
|
1168
1168
|
if (S && S.isParentSelector) {
|
|
1169
1169
|
const C = this._trace(S.expr, e, S.path, s, n, a, c);
|
|
1170
1170
|
if (Array.isArray(C)) {
|
|
1171
|
-
g[
|
|
1171
|
+
g[E] = C[0];
|
|
1172
1172
|
const U = C.length;
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1173
|
+
for (let I = 1; I < U; I++)
|
|
1174
|
+
E++, g.splice(E, 0, C[I]);
|
|
1175
1175
|
} else
|
|
1176
|
-
g[
|
|
1176
|
+
g[E] = C;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
1179
|
return g;
|
|
@@ -1194,8 +1194,8 @@ x.prototype._slice = function(r, e, t, s, n, a, c) {
|
|
|
1194
1194
|
let v = d[0] && Number.parseInt(d[0]) || 0, g = d[1] && Number.parseInt(d[1]) || f;
|
|
1195
1195
|
v = v < 0 ? Math.max(0, v + f) : Math.min(f, v), g = g < 0 ? Math.max(0, g + f) : Math.min(f, g);
|
|
1196
1196
|
const k = [];
|
|
1197
|
-
for (let
|
|
1198
|
-
this._trace(
|
|
1197
|
+
for (let E = v; E < g; E += h)
|
|
1198
|
+
this._trace(ue(E, e), t, s, n, a, c, !0).forEach((C) => {
|
|
1199
1199
|
k.push(C);
|
|
1200
1200
|
});
|
|
1201
1201
|
return k;
|
|
@@ -1263,16 +1263,16 @@ x.toPathArray = function(r) {
|
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
1265
|
x.prototype.safeVm = {
|
|
1266
|
-
Script:
|
|
1266
|
+
Script: je
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1268
|
+
const $e = function(r, e, t) {
|
|
1269
1269
|
const s = r.length;
|
|
1270
1270
|
for (let n = 0; n < s; n++) {
|
|
1271
1271
|
const a = r[n];
|
|
1272
1272
|
t(a) && e.push(r.splice(n--, 1)[0]);
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
|
-
class
|
|
1275
|
+
class Re {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1287,7 +1287,7 @@ class Te {
|
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
1289
|
const s = Object.keys(e), n = [];
|
|
1290
|
-
|
|
1290
|
+
$e(s, n, (h) => typeof e[h] == "function");
|
|
1291
1291
|
const a = s.map((h) => e[h]);
|
|
1292
1292
|
t = n.reduce((h, v) => {
|
|
1293
1293
|
let g = e[v].toString();
|
|
@@ -1298,36 +1298,36 @@ class Te {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
x.prototype.vm = {
|
|
1301
|
-
Script:
|
|
1301
|
+
Script: Re
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const Le = { class: "json-node" }, Ue = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1306
|
+
}, Me = { class: "json-node__line" }, Ve = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, Fe = ["title"], He = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
|
-
},
|
|
1312
|
+
}, Ke = {
|
|
1313
1313
|
key: 4,
|
|
1314
1314
|
class: "json-node__comma"
|
|
1315
|
-
},
|
|
1315
|
+
}, Xe = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__children"
|
|
1318
|
-
},
|
|
1318
|
+
}, Ge = { class: "json-node__children-content" }, Qe = { class: "json-node__line json-node__closing-bracket" }, Ye = { class: "json-node__bracket" }, qe = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
|
-
},
|
|
1321
|
+
}, ze = {
|
|
1322
1322
|
key: 1,
|
|
1323
1323
|
class: "json-node__primitive"
|
|
1324
|
-
},
|
|
1324
|
+
}, We = {
|
|
1325
1325
|
key: 2,
|
|
1326
1326
|
class: "json-node__colon"
|
|
1327
|
-
},
|
|
1327
|
+
}, Ze = ["title"], Je = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
},
|
|
1330
|
+
}, et = /* @__PURE__ */ fe({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1341,7 +1341,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1341
1341
|
},
|
|
1342
1342
|
emits: ["update:value", "toggle-expand", "copy", "update:key"],
|
|
1343
1343
|
setup(r, { emit: e }) {
|
|
1344
|
-
|
|
1344
|
+
pe((u) => ({
|
|
1345
1345
|
"41b58a02": u.level,
|
|
1346
1346
|
"63accfe8": u.theme.colors.syntaxKey,
|
|
1347
1347
|
"7a4b22f6": u.theme.colors.hoverBackground,
|
|
@@ -1358,25 +1358,25 @@ const Be = { class: "json-node" }, De = {
|
|
|
1358
1358
|
if (!/^-?\d+(\.\d+)?$/.test(u)) return !1;
|
|
1359
1359
|
const _ = Number(u);
|
|
1360
1360
|
return !Number.isSafeInteger(_) || u.length > 15;
|
|
1361
|
-
}, h =
|
|
1361
|
+
}, h = D(() => t.value !== null && typeof t.value == "object"), v = D(() => Array.isArray(t.value)), g = D(() => t.path ? t.path : t.keyName ? t.keyName : "root"), k = D(() => t.expanded.has(g.value)), E = D(() => t.keyName), S = D(() => v.value ? "[" : "{"), C = D(() => v.value ? "]" : "}"), U = D(() => {
|
|
1362
1362
|
if (!t.value) return "";
|
|
1363
1363
|
const _ = Object.keys(t.value).length;
|
|
1364
1364
|
return v.value ? _ > 0 ? ` ${_} items ` : " " : _ > 0 ? ` ${_} keys ` : " ";
|
|
1365
|
-
}),
|
|
1365
|
+
}), I = D(() => {
|
|
1366
1366
|
const u = typeof t.value;
|
|
1367
1367
|
return t.value === null ? "json-node__value--null" : u === "boolean" ? "json-node__value--boolean" : u === "number" ? "json-node__value--number" : u === "string" ? d(t.value) ? "json-node__value--number" : "json-node__value--string" : "";
|
|
1368
|
-
}),
|
|
1368
|
+
}), q = D(() => a.value ? f.value : t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : typeof t.value == "string" ? d(t.value) ? t.value : `"${t.value}"` : String(t.value)), se = D(() => "Click to edit, double-click to copy"), te = (u) => t.level === 0 ? u : g.value ? `${g.value}.${u}` : u, V = (u) => {
|
|
1369
1369
|
const _ = Object.keys(t.value);
|
|
1370
1370
|
return _.indexOf(u) === _.length - 1;
|
|
1371
|
-
},
|
|
1371
|
+
}, z = () => {
|
|
1372
1372
|
s("toggle-expand", g.value);
|
|
1373
|
-
},
|
|
1374
|
-
t.level !== 0 && (n.value = !0, c.value = t.keyName,
|
|
1373
|
+
}, W = () => {
|
|
1374
|
+
t.level !== 0 && (n.value = !0, c.value = t.keyName, ee(() => {
|
|
1375
1375
|
const u = document.querySelectorAll(".json-node__key-input"), _ = u[u.length - 1];
|
|
1376
1376
|
_ && (_.focus(), _.select());
|
|
1377
1377
|
}));
|
|
1378
|
-
},
|
|
1379
|
-
h.value || (a.value = !0, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value),
|
|
1378
|
+
}, re = () => {
|
|
1379
|
+
h.value || (a.value = !0, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value), ee(() => {
|
|
1380
1380
|
const u = document.querySelectorAll(".json-node__value-input"), _ = u[u.length - 1];
|
|
1381
1381
|
_ && (_.focus(), _.select());
|
|
1382
1382
|
}));
|
|
@@ -1384,7 +1384,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1384
1384
|
if (t.level === 0 || !n.value) return;
|
|
1385
1385
|
const u = c.value.trim();
|
|
1386
1386
|
if (!u) {
|
|
1387
|
-
|
|
1387
|
+
J();
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
1390
|
if (u === t.keyName) {
|
|
@@ -1392,7 +1392,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1392
1392
|
return;
|
|
1393
1393
|
}
|
|
1394
1394
|
n.value = !1, s("update:key", g.value, u);
|
|
1395
|
-
},
|
|
1395
|
+
}, Z = () => {
|
|
1396
1396
|
try {
|
|
1397
1397
|
let u;
|
|
1398
1398
|
const _ = f.value.trim();
|
|
@@ -1401,135 +1401,135 @@ const Be = { class: "json-node" }, De = {
|
|
|
1401
1401
|
else if (_ === "true" || _ === "false")
|
|
1402
1402
|
u = _ === "true";
|
|
1403
1403
|
else if (!isNaN(Number(_)) && _ !== "") {
|
|
1404
|
-
const
|
|
1405
|
-
!Number.isSafeInteger(
|
|
1404
|
+
const X = Number(_);
|
|
1405
|
+
!Number.isSafeInteger(X) || _.length > 15 ? u = _ : u = X;
|
|
1406
1406
|
} else
|
|
1407
1407
|
u = f.value;
|
|
1408
1408
|
s("update:value", g.value, u), a.value = !1;
|
|
1409
1409
|
} catch (u) {
|
|
1410
1410
|
console.error("Failed to parse value:", u), a.value = !1;
|
|
1411
1411
|
}
|
|
1412
|
-
},
|
|
1412
|
+
}, J = () => {
|
|
1413
1413
|
n.value = !1, c.value = t.keyName;
|
|
1414
|
-
},
|
|
1414
|
+
}, K = () => {
|
|
1415
1415
|
a.value = !1, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value);
|
|
1416
1416
|
};
|
|
1417
1417
|
return (u, _) => {
|
|
1418
|
-
const
|
|
1419
|
-
return w(), A("div",
|
|
1420
|
-
h.value ? (w(), A("div",
|
|
1421
|
-
P("div",
|
|
1418
|
+
const X = ve("JsonNode", !0);
|
|
1419
|
+
return w(), A("div", Le, [
|
|
1420
|
+
h.value ? (w(), A("div", Ue, [
|
|
1421
|
+
P("div", Me, [
|
|
1422
1422
|
u.keyName && !n.value ? (w(), A("span", {
|
|
1423
1423
|
key: 0,
|
|
1424
1424
|
class: "json-node__key",
|
|
1425
|
-
onClick:
|
|
1425
|
+
onClick: W,
|
|
1426
1426
|
title: "Click to edit key"
|
|
1427
|
-
}, ' "' + $(
|
|
1428
|
-
u.keyName && n.value ?
|
|
1427
|
+
}, ' "' + $(E.value) + '" ', 1)) : B("", !0),
|
|
1428
|
+
u.keyName && n.value ? ae((w(), A("input", {
|
|
1429
1429
|
key: 1,
|
|
1430
1430
|
"onUpdate:modelValue": _[0] || (_[0] = (i) => c.value = i),
|
|
1431
1431
|
onKeyup: [
|
|
1432
|
-
|
|
1433
|
-
|
|
1432
|
+
Q(F, ["enter"]),
|
|
1433
|
+
Q(J, ["escape"])
|
|
1434
1434
|
],
|
|
1435
1435
|
onBlur: F,
|
|
1436
1436
|
class: "json-node__key-input"
|
|
1437
1437
|
}, null, 544)), [
|
|
1438
|
-
[
|
|
1439
|
-
]) :
|
|
1440
|
-
u.keyName ? (w(), A("span",
|
|
1438
|
+
[le, c.value]
|
|
1439
|
+
]) : B("", !0),
|
|
1440
|
+
u.keyName ? (w(), A("span", Ve, ": ")) : B("", !0),
|
|
1441
1441
|
P("span", {
|
|
1442
1442
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1443
|
-
onClick:
|
|
1443
|
+
onClick: z,
|
|
1444
1444
|
title: k.value ? "Click to collapse" : "Click to expand"
|
|
1445
|
-
}, $(S.value), 9,
|
|
1446
|
-
k.value ?
|
|
1447
|
-
|
|
1445
|
+
}, $(S.value), 9, Fe),
|
|
1446
|
+
k.value ? B("", !0) : (w(), A("span", He, [
|
|
1447
|
+
de($(U.value) + " ", 1),
|
|
1448
1448
|
P("span", {
|
|
1449
1449
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1450
|
-
onClick:
|
|
1450
|
+
onClick: z
|
|
1451
1451
|
}, $(C.value), 1)
|
|
1452
1452
|
])),
|
|
1453
|
-
!k.value && !u.isLast ? (w(), A("span",
|
|
1453
|
+
!k.value && !u.isLast ? (w(), A("span", Ke, ",")) : B("", !0)
|
|
1454
1454
|
]),
|
|
1455
|
-
k.value ? (w(), A("div",
|
|
1456
|
-
P("div",
|
|
1457
|
-
(w(!0), A(
|
|
1455
|
+
k.value ? (w(), A("div", Xe, [
|
|
1456
|
+
P("div", Ge, [
|
|
1457
|
+
(w(!0), A(_e, null, xe(u.value, (i, l) => (w(), A("div", {
|
|
1458
1458
|
key: l,
|
|
1459
1459
|
class: "json-node__child"
|
|
1460
1460
|
}, [
|
|
1461
|
-
|
|
1461
|
+
ye(X, {
|
|
1462
1462
|
value: i,
|
|
1463
1463
|
"key-name": v.value ? "" : String(l),
|
|
1464
1464
|
level: u.level + 1,
|
|
1465
|
-
path:
|
|
1465
|
+
path: te(String(l)),
|
|
1466
1466
|
expanded: u.expanded,
|
|
1467
1467
|
theme: u.theme,
|
|
1468
|
-
"onUpdate:value": _[1] || (_[1] = (
|
|
1469
|
-
onToggleExpand: _[2] || (_[2] = (
|
|
1470
|
-
onCopy: _[3] || (_[3] = (
|
|
1471
|
-
"onUpdate:key": _[4] || (_[4] = (
|
|
1468
|
+
"onUpdate:value": _[1] || (_[1] = (p, y) => u.$emit("update:value", p, y)),
|
|
1469
|
+
onToggleExpand: _[2] || (_[2] = (p) => u.$emit("toggle-expand", p)),
|
|
1470
|
+
onCopy: _[3] || (_[3] = (p) => u.$emit("copy", p)),
|
|
1471
|
+
"onUpdate:key": _[4] || (_[4] = (p, y) => u.$emit("update:key", p, y)),
|
|
1472
1472
|
"is-last": V(String(l))
|
|
1473
1473
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1474
1474
|
]))), 128))
|
|
1475
1475
|
]),
|
|
1476
|
-
P("div",
|
|
1477
|
-
P("span",
|
|
1478
|
-
u.isLast ?
|
|
1476
|
+
P("div", Qe, [
|
|
1477
|
+
P("span", Ye, $(C.value), 1),
|
|
1478
|
+
u.isLast ? B("", !0) : (w(), A("span", qe, ","))
|
|
1479
1479
|
])
|
|
1480
|
-
])) :
|
|
1481
|
-
])) : (w(), A("div",
|
|
1480
|
+
])) : B("", !0)
|
|
1481
|
+
])) : (w(), A("div", ze, [
|
|
1482
1482
|
u.keyName && !n.value ? (w(), A("span", {
|
|
1483
1483
|
key: 0,
|
|
1484
1484
|
class: "json-node__key",
|
|
1485
|
-
onClick:
|
|
1485
|
+
onClick: W,
|
|
1486
1486
|
title: "Click to edit key"
|
|
1487
|
-
}, ' "' + $(
|
|
1488
|
-
u.keyName && n.value ?
|
|
1487
|
+
}, ' "' + $(E.value) + '" ', 1)) : B("", !0),
|
|
1488
|
+
u.keyName && n.value ? ae((w(), A("input", {
|
|
1489
1489
|
key: 1,
|
|
1490
1490
|
"onUpdate:modelValue": _[5] || (_[5] = (i) => c.value = i),
|
|
1491
1491
|
onKeyup: [
|
|
1492
|
-
|
|
1493
|
-
|
|
1492
|
+
Q(F, ["enter"]),
|
|
1493
|
+
Q(J, ["escape"])
|
|
1494
1494
|
],
|
|
1495
1495
|
onBlur: F,
|
|
1496
1496
|
class: "json-node__key-input"
|
|
1497
1497
|
}, null, 544)), [
|
|
1498
|
-
[
|
|
1499
|
-
]) :
|
|
1500
|
-
u.keyName ? (w(), A("span",
|
|
1501
|
-
a.value ?
|
|
1498
|
+
[le, c.value]
|
|
1499
|
+
]) : B("", !0),
|
|
1500
|
+
u.keyName ? (w(), A("span", We, ": ")) : B("", !0),
|
|
1501
|
+
a.value ? B("", !0) : (w(), A("span", {
|
|
1502
1502
|
key: 3,
|
|
1503
|
-
class:
|
|
1504
|
-
onClick:
|
|
1503
|
+
class: ge(["json-node__value", I.value]),
|
|
1504
|
+
onClick: re,
|
|
1505
1505
|
onDblclick: _[6] || (_[6] = (i) => u.$emit("copy", u.value)),
|
|
1506
|
-
title:
|
|
1506
|
+
title: se.value
|
|
1507
1507
|
}, [
|
|
1508
|
-
|
|
1509
|
-
u.isLast ?
|
|
1510
|
-
], 42,
|
|
1511
|
-
a.value ?
|
|
1508
|
+
de($(q.value), 1),
|
|
1509
|
+
u.isLast ? B("", !0) : (w(), A("span", Je, ","))
|
|
1510
|
+
], 42, Ze)),
|
|
1511
|
+
a.value ? ae((w(), A("input", {
|
|
1512
1512
|
key: 4,
|
|
1513
1513
|
"onUpdate:modelValue": _[7] || (_[7] = (i) => f.value = i),
|
|
1514
1514
|
onKeyup: [
|
|
1515
|
-
|
|
1516
|
-
|
|
1515
|
+
Q(Z, ["enter"]),
|
|
1516
|
+
Q(K, ["escape"])
|
|
1517
1517
|
],
|
|
1518
|
-
onBlur:
|
|
1518
|
+
onBlur: Z,
|
|
1519
1519
|
class: "json-node__value-input"
|
|
1520
1520
|
}, null, 544)), [
|
|
1521
|
-
[
|
|
1522
|
-
]) :
|
|
1521
|
+
[le, f.value]
|
|
1522
|
+
]) : B("", !0)
|
|
1523
1523
|
]))
|
|
1524
1524
|
]);
|
|
1525
1525
|
};
|
|
1526
1526
|
}
|
|
1527
|
-
}),
|
|
1527
|
+
}), be = (r, e) => {
|
|
1528
1528
|
const t = r.__vccOpts || r;
|
|
1529
1529
|
for (const [s, n] of e)
|
|
1530
1530
|
t[s] = n;
|
|
1531
1531
|
return t;
|
|
1532
|
-
},
|
|
1532
|
+
}, tt = /* @__PURE__ */ be(et, [["__scopeId", "data-v-f3f3cbc9"]]), Ee = {
|
|
1533
1533
|
name: "github-light",
|
|
1534
1534
|
colors: {
|
|
1535
1535
|
// 背景色
|
|
@@ -1568,7 +1568,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1568
1568
|
// 缩进线
|
|
1569
1569
|
indentLine: "#d0d7de"
|
|
1570
1570
|
}
|
|
1571
|
-
},
|
|
1571
|
+
}, rt = {
|
|
1572
1572
|
name: "github-dark",
|
|
1573
1573
|
colors: {
|
|
1574
1574
|
// 背景色
|
|
@@ -1607,7 +1607,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1607
1607
|
// 缩进线
|
|
1608
1608
|
indentLine: "#30363d"
|
|
1609
1609
|
}
|
|
1610
|
-
},
|
|
1610
|
+
}, nt = {
|
|
1611
1611
|
name: "min-light",
|
|
1612
1612
|
colors: {
|
|
1613
1613
|
// 背景色 - 纯白简洁
|
|
@@ -1646,7 +1646,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1646
1646
|
// 缩进线
|
|
1647
1647
|
indentLine: "#e5e7eb"
|
|
1648
1648
|
}
|
|
1649
|
-
},
|
|
1649
|
+
}, st = {
|
|
1650
1650
|
name: "slack-ochin",
|
|
1651
1651
|
colors: {
|
|
1652
1652
|
// 背景色 - 温暖的米色调
|
|
@@ -1685,34 +1685,34 @@ const Be = { class: "json-node" }, De = {
|
|
|
1685
1685
|
// 缩进线
|
|
1686
1686
|
indentLine: "#e8d5b7"
|
|
1687
1687
|
}
|
|
1688
|
-
},
|
|
1689
|
-
"github-light":
|
|
1690
|
-
"github-dark":
|
|
1691
|
-
"min-light":
|
|
1692
|
-
"slack-ochin":
|
|
1688
|
+
}, ot = {
|
|
1689
|
+
"github-light": Ee,
|
|
1690
|
+
"github-dark": rt,
|
|
1691
|
+
"min-light": nt,
|
|
1692
|
+
"slack-ochin": st
|
|
1693
1693
|
};
|
|
1694
|
-
function
|
|
1695
|
-
return
|
|
1694
|
+
function it(r = "github-light") {
|
|
1695
|
+
return ot[r] || Ee;
|
|
1696
1696
|
}
|
|
1697
|
-
const
|
|
1697
|
+
const at = {
|
|
1698
1698
|
key: 0,
|
|
1699
1699
|
class: "json-format__toolbar"
|
|
1700
|
-
},
|
|
1700
|
+
}, lt = { class: "json-format__actions" }, ct = ["disabled"], ut = ["disabled"], dt = ["disabled"], ht = ["disabled"], ft = { class: "json-format__info" }, pt = {
|
|
1701
1701
|
key: 0,
|
|
1702
1702
|
class: "json-format__status json-format__status--success"
|
|
1703
|
-
},
|
|
1703
|
+
}, yt = {
|
|
1704
1704
|
key: 1,
|
|
1705
1705
|
class: "json-format__status json-format__status--error"
|
|
1706
|
-
},
|
|
1706
|
+
}, gt = { class: "json-format__content" }, bt = {
|
|
1707
1707
|
key: 0,
|
|
1708
1708
|
class: "json-format__error"
|
|
1709
|
-
},
|
|
1709
|
+
}, Et = {
|
|
1710
1710
|
key: 1,
|
|
1711
1711
|
class: "json-format__error"
|
|
1712
|
-
},
|
|
1712
|
+
}, mt = {
|
|
1713
1713
|
key: 2,
|
|
1714
1714
|
class: "json-format__viewer"
|
|
1715
|
-
},
|
|
1715
|
+
}, vt = /* @__PURE__ */ fe({
|
|
1716
1716
|
name: "JsonFormat",
|
|
1717
1717
|
__name: "index",
|
|
1718
1718
|
props: {
|
|
@@ -1724,44 +1724,69 @@ const tt = {
|
|
|
1724
1724
|
},
|
|
1725
1725
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1726
1726
|
setup(r, { expose: e, emit: t }) {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
"
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
"
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
"
|
|
1739
|
-
"
|
|
1740
|
-
|
|
1741
|
-
"
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1727
|
+
pe((i) => ({
|
|
1728
|
+
ef037492: g.value.colors.border,
|
|
1729
|
+
"33e06939": g.value.colors.background,
|
|
1730
|
+
60160510: g.value.colors.text,
|
|
1731
|
+
"5ef04350": g.value.colors.surfaceBackground,
|
|
1732
|
+
"2635d16e": g.value.colors.buttonBorder,
|
|
1733
|
+
"7e8021cb": g.value.colors.buttonBackground,
|
|
1734
|
+
ceb1e8ec: g.value.colors.buttonText,
|
|
1735
|
+
"3fff1e31": g.value.colors.buttonBackgroundHover,
|
|
1736
|
+
ce0e62f6: g.value.colors.buttonPrimary,
|
|
1737
|
+
a1115492: g.value.colors.buttonPrimaryHover,
|
|
1738
|
+
"61b839b4": g.value.colors.successBackground,
|
|
1739
|
+
"13fd9fd8": g.value.colors.success,
|
|
1740
|
+
f14057aa: g.value.colors.errorBackground,
|
|
1741
|
+
"2ddd231d": g.value.colors.error,
|
|
1742
|
+
c81a0d60: g.value.colors.scrollbarTrack,
|
|
1743
|
+
c8228c4a: g.value.colors.scrollbarThumb,
|
|
1744
|
+
"5985dfbe": g.value.colors.scrollbarThumbHover
|
|
1745
1745
|
}));
|
|
1746
|
-
const s = r, n = t, a = R(null), c = R(""), f = R(/* @__PURE__ */ new Set()), d = R(null), h = R(""), v =
|
|
1746
|
+
const s = r, n = t, a = R(null), c = R(""), f = R(/* @__PURE__ */ new Set()), d = R(null), h = R(""), v = D(() => c.value === ""), g = D(() => it(s.theme)), k = D(() => h.value ? null : d.value !== null ? d.value : a.value), E = (i) => {
|
|
1747
1747
|
if (!i.trim()) {
|
|
1748
1748
|
a.value = null, c.value = "", d.value = null, h.value = "";
|
|
1749
1749
|
return;
|
|
1750
1750
|
}
|
|
1751
1751
|
try {
|
|
1752
1752
|
let l = i;
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1753
|
+
const p = /:\s*\d{16,}/.test(l), y = /:\s*\d+\.\d*0+\s*[,}\]]/.test(l);
|
|
1754
|
+
if (!p && !y)
|
|
1755
|
+
try {
|
|
1756
|
+
a.value = JSON.parse(l), c.value = "", d.value = null, h.value = "", ee(() => {
|
|
1757
|
+
k.value !== null && V();
|
|
1758
|
+
});
|
|
1759
|
+
return;
|
|
1760
|
+
} catch {
|
|
1761
|
+
}
|
|
1762
|
+
const b = (m, N, j) => {
|
|
1763
|
+
let T = "", oe = !1, ie = !1, H = 0;
|
|
1764
|
+
for (; H < m.length; ) {
|
|
1765
|
+
const G = m[H];
|
|
1766
|
+
if (oe)
|
|
1767
|
+
ie ? ie = !1 : G === "\\" ? ie = !0 : G === '"' && (oe = !1), T += G, H++;
|
|
1768
|
+
else if (G === '"')
|
|
1769
|
+
oe = !0, T += G, H++;
|
|
1770
|
+
else {
|
|
1771
|
+
const ne = m.slice(H).match(N);
|
|
1772
|
+
if (ne && ne.index === 0) {
|
|
1773
|
+
const me = ne[0].replace(N, j);
|
|
1774
|
+
T += me, H += ne[0].length;
|
|
1775
|
+
} else
|
|
1776
|
+
T += G, H++;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
return T;
|
|
1780
|
+
};
|
|
1781
|
+
l = b(
|
|
1782
|
+
l,
|
|
1783
|
+
/:\s*(\d{16,})(\s*[,}\]\n\r])/,
|
|
1784
|
+
': "$1"$2'
|
|
1785
|
+
), l = b(
|
|
1786
|
+
l,
|
|
1787
|
+
/:\s*(\d+\.\d*?0+)(\s*[,}\]\n\r])/,
|
|
1788
|
+
': "$1"$2'
|
|
1789
|
+
), a.value = JSON.parse(l), c.value = "", d.value = null, h.value = "", ee(() => {
|
|
1765
1790
|
k.value !== null && V();
|
|
1766
1791
|
});
|
|
1767
1792
|
} catch (l) {
|
|
@@ -1790,7 +1815,7 @@ const tt = {
|
|
|
1790
1815
|
`)(a.value), d.value = l;
|
|
1791
1816
|
else
|
|
1792
1817
|
throw new Error(`Unsupported filter type: ${i.type}`);
|
|
1793
|
-
h.value = "",
|
|
1818
|
+
h.value = "", ee(() => {
|
|
1794
1819
|
V();
|
|
1795
1820
|
});
|
|
1796
1821
|
} catch (l) {
|
|
@@ -1799,71 +1824,71 @@ const tt = {
|
|
|
1799
1824
|
}, C = () => {
|
|
1800
1825
|
d.value = null, h.value = "";
|
|
1801
1826
|
};
|
|
1802
|
-
|
|
1803
|
-
|
|
1827
|
+
ke(() => s.modelValue, (i) => {
|
|
1828
|
+
E(i);
|
|
1804
1829
|
}, { immediate: !0 });
|
|
1805
1830
|
const U = (i) => {
|
|
1806
1831
|
if (!/^-?\d+(\.\d+)?$/.test(i)) return !1;
|
|
1807
1832
|
const l = Number(i);
|
|
1808
1833
|
return !Number.isSafeInteger(l) || i.length > 15;
|
|
1809
|
-
},
|
|
1834
|
+
}, I = (i, l, p) => JSON.stringify(i, (y, b) => {
|
|
1810
1835
|
if (typeof b == "string" && U(b))
|
|
1811
1836
|
return `__BIG_NUMBER__${b}__BIG_NUMBER__`;
|
|
1812
1837
|
if (typeof b == "string" && /^-?\d+(\.\d+)?$/.test(b)) {
|
|
1813
|
-
const
|
|
1814
|
-
if (Number.isSafeInteger(
|
|
1815
|
-
return
|
|
1816
|
-
if (!Number.isNaN(
|
|
1817
|
-
return
|
|
1818
|
-
if (!Number.isNaN(
|
|
1819
|
-
return
|
|
1838
|
+
const m = Number(b);
|
|
1839
|
+
if (Number.isSafeInteger(m) && m.toString() === b)
|
|
1840
|
+
return m;
|
|
1841
|
+
if (!Number.isNaN(m) && isFinite(m) && b.includes("."))
|
|
1842
|
+
return m.toString() === b ? m : `__PRESERVE_STRING__${b}__PRESERVE_STRING__`;
|
|
1843
|
+
if (!Number.isNaN(m) && isFinite(m))
|
|
1844
|
+
return m;
|
|
1820
1845
|
}
|
|
1821
|
-
return l && typeof l == "function" ? l(
|
|
1822
|
-
},
|
|
1846
|
+
return l && typeof l == "function" ? l(y, b) : b;
|
|
1847
|
+
}, p).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g, "$1").replace(/"__PRESERVE_STRING__(.+?)__PRESERVE_STRING__"/g, "$1"), q = (i, l) => {
|
|
1823
1848
|
if (!s.readonly)
|
|
1824
1849
|
try {
|
|
1825
|
-
const
|
|
1826
|
-
n("update:modelValue",
|
|
1827
|
-
} catch (
|
|
1828
|
-
console.error("Failed to update JSON:",
|
|
1850
|
+
const p = se(a.value, i, l), y = I(p, null, 2);
|
|
1851
|
+
n("update:modelValue", y);
|
|
1852
|
+
} catch (p) {
|
|
1853
|
+
console.error("Failed to update JSON:", p);
|
|
1829
1854
|
}
|
|
1830
|
-
},
|
|
1831
|
-
if (!l || l === "root") return
|
|
1832
|
-
const
|
|
1833
|
-
let
|
|
1834
|
-
for (let j = 0; j <
|
|
1835
|
-
const
|
|
1836
|
-
|
|
1855
|
+
}, se = (i, l, p) => {
|
|
1856
|
+
if (!l || l === "root") return p;
|
|
1857
|
+
const y = l.split("."), b = K(i, y.slice(0, -1));
|
|
1858
|
+
let m = b;
|
|
1859
|
+
for (let j = 0; j < y.length - 1; j++) {
|
|
1860
|
+
const T = y[j];
|
|
1861
|
+
T !== "root" && (Array.isArray(m) ? m = m[parseInt(T)] : m = m[T]);
|
|
1837
1862
|
}
|
|
1838
|
-
const
|
|
1839
|
-
return
|
|
1840
|
-
},
|
|
1863
|
+
const N = y[y.length - 1];
|
|
1864
|
+
return N === "root" ? p : (Array.isArray(m) ? m[parseInt(N)] = p : m[N] = p, b);
|
|
1865
|
+
}, te = (i) => {
|
|
1841
1866
|
f.value.has(i) ? f.value.delete(i) : f.value.add(i);
|
|
1842
1867
|
}, V = () => {
|
|
1843
|
-
const i = /* @__PURE__ */ new Set(), l = (
|
|
1844
|
-
|
|
1845
|
-
const
|
|
1846
|
-
l(b,
|
|
1847
|
-
}) : Object.keys(
|
|
1848
|
-
const
|
|
1849
|
-
l(
|
|
1868
|
+
const i = /* @__PURE__ */ new Set(), l = (p, y = "") => {
|
|
1869
|
+
p !== null && typeof p == "object" && (i.add(y || "root"), Array.isArray(p) ? p.forEach((b, m) => {
|
|
1870
|
+
const N = y ? `${y}.${m}` : `${m}`;
|
|
1871
|
+
l(b, N);
|
|
1872
|
+
}) : Object.keys(p).forEach((b) => {
|
|
1873
|
+
const m = y ? `${y}.${b}` : b;
|
|
1874
|
+
l(p[b], m);
|
|
1850
1875
|
}));
|
|
1851
1876
|
};
|
|
1852
1877
|
l(k.value), f.value = i, n("expand-all");
|
|
1853
|
-
},
|
|
1878
|
+
}, z = () => {
|
|
1854
1879
|
f.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1855
|
-
},
|
|
1880
|
+
}, W = async () => {
|
|
1856
1881
|
if (v.value)
|
|
1857
1882
|
try {
|
|
1858
|
-
const i = k.value, l =
|
|
1883
|
+
const i = k.value, l = I(i, null, 2);
|
|
1859
1884
|
await navigator.clipboard.writeText(l), n("copy-success", l);
|
|
1860
1885
|
} catch (i) {
|
|
1861
1886
|
console.error("Failed to copy JSON:", i), n("copy-error", i instanceof Error ? i : new Error("Failed to copy JSON"));
|
|
1862
1887
|
}
|
|
1863
|
-
},
|
|
1888
|
+
}, re = () => {
|
|
1864
1889
|
if (v.value)
|
|
1865
1890
|
try {
|
|
1866
|
-
const i = k.value, l =
|
|
1891
|
+
const i = k.value, l = I(i);
|
|
1867
1892
|
n("update:modelValue", l), n("compress", l);
|
|
1868
1893
|
} catch (i) {
|
|
1869
1894
|
console.error("Failed to compress JSON:", i);
|
|
@@ -1875,81 +1900,81 @@ const tt = {
|
|
|
1875
1900
|
} catch (l) {
|
|
1876
1901
|
console.error("Failed to copy value:", l);
|
|
1877
1902
|
}
|
|
1878
|
-
},
|
|
1903
|
+
}, Z = (i, l) => {
|
|
1879
1904
|
if (!s.readonly)
|
|
1880
1905
|
try {
|
|
1881
|
-
const
|
|
1882
|
-
n("update:modelValue",
|
|
1883
|
-
} catch (
|
|
1884
|
-
console.error("Failed to rename key:",
|
|
1906
|
+
const p = J(a.value, i, l), y = I(p, null, 2);
|
|
1907
|
+
n("update:modelValue", y), X(i, l);
|
|
1908
|
+
} catch (p) {
|
|
1909
|
+
console.error("Failed to rename key:", p);
|
|
1885
1910
|
}
|
|
1886
|
-
},
|
|
1911
|
+
}, J = (i, l, p) => {
|
|
1887
1912
|
if (!l || l === "root") return i;
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
1890
|
-
const j =
|
|
1891
|
-
return b && typeof b == "object" && !Array.isArray(b) ? u(b, j,
|
|
1913
|
+
const y = l.split("."), b = K(i, y.slice(0, -1));
|
|
1914
|
+
if (y.length === 1) {
|
|
1915
|
+
const j = y[0];
|
|
1916
|
+
return b && typeof b == "object" && !Array.isArray(b) ? u(b, j, p) : b;
|
|
1892
1917
|
}
|
|
1893
|
-
let
|
|
1894
|
-
for (let j = 0; j <
|
|
1895
|
-
const
|
|
1896
|
-
Array.isArray(
|
|
1918
|
+
let m = b;
|
|
1919
|
+
for (let j = 0; j < y.length - 1; j++) {
|
|
1920
|
+
const T = y[j];
|
|
1921
|
+
Array.isArray(m) ? m = m[parseInt(T)] : m = m[T];
|
|
1897
1922
|
}
|
|
1898
|
-
const
|
|
1899
|
-
if (!Array.isArray(
|
|
1900
|
-
const j = u(
|
|
1901
|
-
|
|
1923
|
+
const N = y[y.length - 1];
|
|
1924
|
+
if (!Array.isArray(m) && m && typeof m == "object") {
|
|
1925
|
+
const j = u(m, N, p), T = y.slice(0, -1);
|
|
1926
|
+
T.length > 0 && _(b, T, j);
|
|
1902
1927
|
}
|
|
1903
1928
|
return b;
|
|
1904
|
-
},
|
|
1929
|
+
}, K = (i, l) => {
|
|
1905
1930
|
if (l.length === 0) return i;
|
|
1906
1931
|
if (Array.isArray(i)) {
|
|
1907
|
-
const
|
|
1908
|
-
return l.length === 1 || (
|
|
1932
|
+
const p = [...i], y = l[0], b = parseInt(y);
|
|
1933
|
+
return l.length === 1 || (p[b] = K(i[b], l.slice(1))), p;
|
|
1909
1934
|
} else if (i && typeof i == "object") {
|
|
1910
|
-
const
|
|
1911
|
-
return l.length === 1 || (y
|
|
1935
|
+
const p = { ...i }, y = l[0];
|
|
1936
|
+
return l.length === 1 || (p[y] = K(i[y], l.slice(1))), p;
|
|
1912
1937
|
}
|
|
1913
1938
|
return i;
|
|
1914
|
-
}, u = (i, l,
|
|
1939
|
+
}, u = (i, l, p) => {
|
|
1915
1940
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
1916
1941
|
return i;
|
|
1917
|
-
const
|
|
1918
|
-
for (const
|
|
1919
|
-
|
|
1942
|
+
const y = Object.keys(i), b = {};
|
|
1943
|
+
for (const m of y)
|
|
1944
|
+
m === l ? b[p] = i[m] : b[m] = i[m];
|
|
1920
1945
|
return b;
|
|
1921
|
-
}, _ = (i, l,
|
|
1922
|
-
let
|
|
1923
|
-
for (let
|
|
1924
|
-
const
|
|
1925
|
-
Array.isArray(
|
|
1946
|
+
}, _ = (i, l, p) => {
|
|
1947
|
+
let y = i;
|
|
1948
|
+
for (let m = 0; m < l.length - 1; m++) {
|
|
1949
|
+
const N = l[m];
|
|
1950
|
+
Array.isArray(y) ? y = y[parseInt(N)] : y = y[N];
|
|
1926
1951
|
}
|
|
1927
1952
|
const b = l[l.length - 1];
|
|
1928
|
-
Array.isArray(
|
|
1929
|
-
},
|
|
1930
|
-
const
|
|
1931
|
-
f.value.forEach((
|
|
1932
|
-
if (
|
|
1953
|
+
Array.isArray(y) ? y[parseInt(b)] = p : y[b] = p;
|
|
1954
|
+
}, X = (i, l) => {
|
|
1955
|
+
const p = /* @__PURE__ */ new Set();
|
|
1956
|
+
f.value.forEach((y) => {
|
|
1957
|
+
if (y === i) {
|
|
1933
1958
|
const b = i.split(".");
|
|
1934
|
-
b[b.length - 1] = l,
|
|
1935
|
-
} else if (
|
|
1959
|
+
b[b.length - 1] = l, p.add(b.join("."));
|
|
1960
|
+
} else if (y.startsWith(i + ".")) {
|
|
1936
1961
|
const b = i.split(".");
|
|
1937
1962
|
b[b.length - 1] = l;
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1963
|
+
const m = b.join("."), N = y.substring(i.length);
|
|
1964
|
+
p.add(m + N);
|
|
1940
1965
|
} else
|
|
1941
|
-
|
|
1942
|
-
}), f.value =
|
|
1966
|
+
p.add(y);
|
|
1967
|
+
}), f.value = p;
|
|
1943
1968
|
};
|
|
1944
1969
|
return e({
|
|
1945
1970
|
// 核心操作方法
|
|
1946
|
-
copyJson:
|
|
1947
|
-
compressSource:
|
|
1971
|
+
copyJson: W,
|
|
1972
|
+
compressSource: re,
|
|
1948
1973
|
expandAll: V,
|
|
1949
|
-
collapseAll:
|
|
1950
|
-
toggleExpand:
|
|
1951
|
-
updateValue:
|
|
1952
|
-
updateKey:
|
|
1974
|
+
collapseAll: z,
|
|
1975
|
+
toggleExpand: te,
|
|
1976
|
+
updateValue: q,
|
|
1977
|
+
updateKey: Z,
|
|
1953
1978
|
// Filter 相关方法
|
|
1954
1979
|
filter: S,
|
|
1955
1980
|
clearFilter: C,
|
|
@@ -1961,75 +1986,75 @@ const tt = {
|
|
|
1961
1986
|
getParseError: () => c.value,
|
|
1962
1987
|
getFilterError: () => h.value,
|
|
1963
1988
|
// 工具方法
|
|
1964
|
-
parseJson: (i) =>
|
|
1989
|
+
parseJson: (i) => E(i),
|
|
1965
1990
|
copyValue: (i) => F(i)
|
|
1966
1991
|
}), (i, l) => (w(), A("div", {
|
|
1967
|
-
class:
|
|
1992
|
+
class: ge(["json-format", `json-format--${g.value.name}`])
|
|
1968
1993
|
}, [
|
|
1969
|
-
i.showToolbar ? (w(), A("div",
|
|
1970
|
-
P("div",
|
|
1994
|
+
i.showToolbar ? (w(), A("div", at, [
|
|
1995
|
+
P("div", lt, [
|
|
1971
1996
|
P("button", {
|
|
1972
1997
|
class: "json-format__btn json-format__btn--primary",
|
|
1973
|
-
onClick:
|
|
1998
|
+
onClick: W,
|
|
1974
1999
|
disabled: !v.value,
|
|
1975
2000
|
title: "Copy JSON"
|
|
1976
|
-
}, " 📋 Copy ", 8,
|
|
2001
|
+
}, " 📋 Copy ", 8, ct),
|
|
1977
2002
|
P("button", {
|
|
1978
2003
|
class: "json-format__btn json-format__btn--secondary",
|
|
1979
2004
|
onClick: V,
|
|
1980
2005
|
disabled: !v.value,
|
|
1981
2006
|
title: "Expand All"
|
|
1982
|
-
}, " ⬇️ Expand All ", 8,
|
|
2007
|
+
}, " ⬇️ Expand All ", 8, ut),
|
|
1983
2008
|
P("button", {
|
|
1984
2009
|
class: "json-format__btn json-format__btn--secondary",
|
|
1985
|
-
onClick:
|
|
2010
|
+
onClick: z,
|
|
1986
2011
|
disabled: !v.value,
|
|
1987
2012
|
title: "Collapse All"
|
|
1988
|
-
}, " ➡️ Collapse All ", 8,
|
|
2013
|
+
}, " ➡️ Collapse All ", 8, dt),
|
|
1989
2014
|
P("button", {
|
|
1990
2015
|
class: "json-format__btn json-format__btn--secondary",
|
|
1991
|
-
onClick:
|
|
2016
|
+
onClick: re,
|
|
1992
2017
|
disabled: !v.value,
|
|
1993
2018
|
title: "Compress JSON"
|
|
1994
|
-
}, " 📦 Compress ", 8,
|
|
2019
|
+
}, " 📦 Compress ", 8, ht)
|
|
1995
2020
|
]),
|
|
1996
|
-
P("div",
|
|
1997
|
-
v.value ? (w(), A("span",
|
|
2021
|
+
P("div", ft, [
|
|
2022
|
+
v.value ? (w(), A("span", pt, " ✅ Valid JSON ")) : (w(), A("span", yt, " ❌ Invalid JSON "))
|
|
1998
2023
|
])
|
|
1999
|
-
])) :
|
|
2000
|
-
P("div",
|
|
2001
|
-
v.value ? h.value ? (w(), A("div",
|
|
2024
|
+
])) : B("", !0),
|
|
2025
|
+
P("div", gt, [
|
|
2026
|
+
v.value ? h.value ? (w(), A("div", Et, [
|
|
2002
2027
|
l[1] || (l[1] = P("h4", null, "Filter Error:", -1)),
|
|
2003
2028
|
P("pre", null, $(h.value), 1)
|
|
2004
|
-
])) : (w(), A("div",
|
|
2005
|
-
|
|
2029
|
+
])) : (w(), A("div", mt, [
|
|
2030
|
+
ye(tt, {
|
|
2006
2031
|
value: k.value,
|
|
2007
2032
|
"key-name": "",
|
|
2008
2033
|
level: 0,
|
|
2009
2034
|
expanded: f.value,
|
|
2010
2035
|
"is-last": !0,
|
|
2011
2036
|
theme: g.value,
|
|
2012
|
-
"onUpdate:value":
|
|
2013
|
-
onToggleExpand:
|
|
2037
|
+
"onUpdate:value": q,
|
|
2038
|
+
onToggleExpand: te,
|
|
2014
2039
|
onCopy: F,
|
|
2015
|
-
"onUpdate:key":
|
|
2040
|
+
"onUpdate:key": Z
|
|
2016
2041
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2017
|
-
])) : (w(), A("div",
|
|
2042
|
+
])) : (w(), A("div", bt, [
|
|
2018
2043
|
l[0] || (l[0] = P("h4", null, "JSON Parse Error:", -1)),
|
|
2019
2044
|
P("pre", null, $(c.value), 1)
|
|
2020
2045
|
]))
|
|
2021
2046
|
])
|
|
2022
2047
|
], 2));
|
|
2023
2048
|
}
|
|
2024
|
-
}),
|
|
2025
|
-
|
|
2049
|
+
}), _t = /* @__PURE__ */ be(vt, [["__scopeId", "data-v-ad4d00ac"]]), xt = [_t], kt = (r) => {
|
|
2050
|
+
xt.forEach((e) => {
|
|
2026
2051
|
const t = e.name || e.__name || "UnknownComponent";
|
|
2027
2052
|
r.component(t, e);
|
|
2028
2053
|
});
|
|
2029
|
-
},
|
|
2030
|
-
install:
|
|
2054
|
+
}, wt = {
|
|
2055
|
+
install: kt
|
|
2031
2056
|
};
|
|
2032
2057
|
export {
|
|
2033
|
-
|
|
2034
|
-
|
|
2058
|
+
_t as JsonFormat,
|
|
2059
|
+
wt as default
|
|
2035
2060
|
};
|