lone-format 0.3.2 → 0.3.4
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 +486 -467
- package/dist/lone-format.umd.cjs +9 -9
- package/package.json +1 -1
package/dist/lone-format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as me, useCssVars as Ce, ref as G, computed as V, resolveComponent as Me, createElementBlock as N, openBlock as x, createElementVNode as E, createCommentVNode as F, withDirectives as ve, toDisplayString as R, withKeys as le, vModelText as _e, createTextVNode as Se, Fragment as he, renderList as pe, createVNode as Ue, normalizeClass as Oe, nextTick as ce, watch as Fe, normalizeStyle as I, createBlock as Xe } from "vue";
|
|
2
2
|
class De {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
@@ -714,12 +714,12 @@ Object.assign(c, {
|
|
|
714
714
|
});
|
|
715
715
|
c.max_unop_len = c.getMaxKeyLen(c.unary_ops);
|
|
716
716
|
c.max_binop_len = c.getMaxKeyLen(c.binary_ops);
|
|
717
|
-
const
|
|
717
|
+
const J = (r) => new c(r).parse(), tt = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(c).filter((r) => !tt.includes(r) &&
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(c).filter((r) => !tt.includes(r) && J[r] === void 0).forEach((r) => {
|
|
720
|
+
J[r] = c[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
722
|
+
J.Jsep = c;
|
|
723
723
|
const rt = "ConditionalExpression";
|
|
724
724
|
var nt = {
|
|
725
725
|
name: "ternary",
|
|
@@ -748,7 +748,7 @@ var nt = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
751
|
+
J.plugins.register(nt);
|
|
752
752
|
const Ie = 47, st = 92;
|
|
753
753
|
var ot = {
|
|
754
754
|
name: "regex",
|
|
@@ -822,11 +822,11 @@ const xe = 43, it = 45, ue = {
|
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]),
|
|
825
|
+
J.plugins.register(ot, ue);
|
|
826
|
+
J.addUnaryOp("typeof");
|
|
827
|
+
J.addLiteral("null", null);
|
|
828
|
+
J.addLiteral("undefined", void 0);
|
|
829
|
+
const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), L = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -835,25 +835,25 @@ const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
835
835
|
switch (r.type) {
|
|
836
836
|
case "BinaryExpression":
|
|
837
837
|
case "LogicalExpression":
|
|
838
|
-
return
|
|
838
|
+
return L.evalBinaryExpression(r, e);
|
|
839
839
|
case "Compound":
|
|
840
|
-
return
|
|
840
|
+
return L.evalCompound(r, e);
|
|
841
841
|
case "ConditionalExpression":
|
|
842
|
-
return
|
|
842
|
+
return L.evalConditionalExpression(r, e);
|
|
843
843
|
case "Identifier":
|
|
844
|
-
return
|
|
844
|
+
return L.evalIdentifier(r, e);
|
|
845
845
|
case "Literal":
|
|
846
|
-
return
|
|
846
|
+
return L.evalLiteral(r, e);
|
|
847
847
|
case "MemberExpression":
|
|
848
|
-
return
|
|
848
|
+
return L.evalMemberExpression(r, e);
|
|
849
849
|
case "UnaryExpression":
|
|
850
|
-
return
|
|
850
|
+
return L.evalUnaryExpression(r, e);
|
|
851
851
|
case "ArrayExpression":
|
|
852
|
-
return
|
|
852
|
+
return L.evalArrayExpression(r, e);
|
|
853
853
|
case "CallExpression":
|
|
854
|
-
return
|
|
854
|
+
return L.evalCallExpression(r, e);
|
|
855
855
|
case "AssignmentExpression":
|
|
856
|
-
return
|
|
856
|
+
return L.evalAssignmentExpression(r, e);
|
|
857
857
|
default:
|
|
858
858
|
throw SyntaxError("Unexpected expression", r);
|
|
859
859
|
}
|
|
@@ -883,19 +883,19 @@ const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
883
883
|
"*": (s, n) => s * n(),
|
|
884
884
|
"/": (s, n) => s / n(),
|
|
885
885
|
"%": (s, n) => s % n()
|
|
886
|
-
}[r.operator](
|
|
886
|
+
}[r.operator](L.evalAst(r.left, e), () => L.evalAst(r.right, e));
|
|
887
887
|
},
|
|
888
888
|
evalCompound(r, e) {
|
|
889
889
|
let t;
|
|
890
890
|
for (let s = 0; s < r.body.length; s++) {
|
|
891
891
|
r.body[s].type === "Identifier" && ["var", "let", "const"].includes(r.body[s].name) && r.body[s + 1] && r.body[s + 1].type === "AssignmentExpression" && (s += 1);
|
|
892
892
|
const n = r.body[s];
|
|
893
|
-
t =
|
|
893
|
+
t = L.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
896
896
|
},
|
|
897
897
|
evalConditionalExpression(r, e) {
|
|
898
|
-
return
|
|
898
|
+
return L.evalAst(r.test, e) ? L.evalAst(r.consequent, e) : L.evalAst(r.alternate, e);
|
|
899
899
|
},
|
|
900
900
|
evalIdentifier(r, e) {
|
|
901
901
|
if (Object.hasOwn(e, r.name))
|
|
@@ -910,9 +910,9 @@ const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
910
910
|
// NOTE: `String(value)` throws error when
|
|
911
911
|
// value has overwritten the toString method to return non-string
|
|
912
912
|
// i.e. `value = {toString: () => []}`
|
|
913
|
-
r.computed ?
|
|
913
|
+
r.computed ? L.evalAst(r.property) : r.property.name
|
|
914
914
|
// `object.property` property is Identifier
|
|
915
|
-
), s =
|
|
915
|
+
), s = L.evalAst(r.object, e);
|
|
916
916
|
if (s == null)
|
|
917
917
|
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
918
918
|
if (!Object.hasOwn(s, t) && at.has(t))
|
|
@@ -922,25 +922,25 @@ const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
922
922
|
},
|
|
923
923
|
evalUnaryExpression(r, e) {
|
|
924
924
|
return {
|
|
925
|
-
"-": (s) => -
|
|
926
|
-
"!": (s) => !
|
|
927
|
-
"~": (s) => ~
|
|
925
|
+
"-": (s) => -L.evalAst(s, e),
|
|
926
|
+
"!": (s) => !L.evalAst(s, e),
|
|
927
|
+
"~": (s) => ~L.evalAst(s, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (s) => +
|
|
930
|
-
typeof: (s) => typeof
|
|
929
|
+
"+": (s) => +L.evalAst(s, e),
|
|
930
|
+
typeof: (s) => typeof L.evalAst(s, e)
|
|
931
931
|
}[r.operator](r.argument);
|
|
932
932
|
},
|
|
933
933
|
evalArrayExpression(r, e) {
|
|
934
|
-
return r.elements.map((t) =>
|
|
934
|
+
return r.elements.map((t) => L.evalAst(t, e));
|
|
935
935
|
},
|
|
936
936
|
evalCallExpression(r, e) {
|
|
937
|
-
const t = r.arguments.map((n) =>
|
|
938
|
-
return
|
|
937
|
+
const t = r.arguments.map((n) => L.evalAst(n, e));
|
|
938
|
+
return L.evalAst(r.callee, e)(...t);
|
|
939
939
|
},
|
|
940
940
|
evalAssignmentExpression(r, e) {
|
|
941
941
|
if (r.left.type !== "Identifier")
|
|
942
942
|
throw SyntaxError("Invalid left-hand side in assignment");
|
|
943
|
-
const t = r.left.name, s =
|
|
943
|
+
const t = r.left.name, s = L.evalAst(r.right, e);
|
|
944
944
|
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
@@ -949,7 +949,7 @@ class lt {
|
|
|
949
949
|
* @param {string} expr Expression to evaluate
|
|
950
950
|
*/
|
|
951
951
|
constructor(e) {
|
|
952
|
-
this.code = e, this.ast =
|
|
952
|
+
this.code = e, this.ast = J(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -958,10 +958,10 @@ class lt {
|
|
|
958
958
|
*/
|
|
959
959
|
runInNewContext(e) {
|
|
960
960
|
const t = Object.assign(/* @__PURE__ */ Object.create(null), e);
|
|
961
|
-
return
|
|
961
|
+
return L.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function re(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
967
|
function ke(r, e) {
|
|
@@ -1062,19 +1062,19 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1062
1062
|
}, this._handleCallback(a, o, "value"), a;
|
|
1063
1063
|
const l = r[0], h = r.slice(1), f = [];
|
|
1064
1064
|
function y(m) {
|
|
1065
|
-
Array.isArray(m) ? m.forEach((
|
|
1066
|
-
f.push(
|
|
1065
|
+
Array.isArray(m) ? m.forEach((A) => {
|
|
1066
|
+
f.push(A);
|
|
1067
1067
|
}) : f.push(m);
|
|
1068
1068
|
}
|
|
1069
1069
|
if ((typeof l != "string" || u) && e && Object.hasOwn(e, l))
|
|
1070
|
-
y(this._trace(h, e[l],
|
|
1070
|
+
y(this._trace(h, e[l], re(t, l), e, l, o, i));
|
|
1071
1071
|
else if (l === "*")
|
|
1072
1072
|
this._walk(e, (m) => {
|
|
1073
|
-
y(this._trace(h, e[m],
|
|
1073
|
+
y(this._trace(h, e[m], re(t, m), e, m, o, !0, !0));
|
|
1074
1074
|
});
|
|
1075
1075
|
else if (l === "..")
|
|
1076
1076
|
y(this._trace(h, e, t, s, n, o, i)), this._walk(e, (m) => {
|
|
1077
|
-
typeof e[m] == "object" && y(this._trace(r.slice(), e[m],
|
|
1077
|
+
typeof e[m] == "object" && y(this._trace(r.slice(), e[m], re(t, m), e, m, o, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
1080
|
if (l === "^")
|
|
@@ -1085,7 +1085,7 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1085
1085
|
};
|
|
1086
1086
|
if (l === "~")
|
|
1087
1087
|
return a = {
|
|
1088
|
-
path:
|
|
1088
|
+
path: re(t, l),
|
|
1089
1089
|
value: n,
|
|
1090
1090
|
parent: s,
|
|
1091
1091
|
parentProperty: null
|
|
@@ -1097,12 +1097,12 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1097
1097
|
else if (l.indexOf("?(") === 0) {
|
|
1098
1098
|
if (this.currEval === !1)
|
|
1099
1099
|
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
1100
|
-
const m = l.replace(/^\?\((.*?)\)$/u, "$1"),
|
|
1101
|
-
|
|
1102
|
-
const P = [
|
|
1103
|
-
this._trace(P, M, t, s, n, o, !0).length > 0 && y(this._trace(h, e[O],
|
|
1100
|
+
const m = l.replace(/^\?\((.*?)\)$/u, "$1"), A = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);
|
|
1101
|
+
A ? this._walk(e, (O) => {
|
|
1102
|
+
const P = [A[2]], M = A[1] ? e[O][A[1]] : e[O];
|
|
1103
|
+
this._trace(P, M, t, s, n, o, !0).length > 0 && y(this._trace(h, e[O], re(t, O), e, O, o, !0));
|
|
1104
1104
|
}) : this._walk(e, (O) => {
|
|
1105
|
-
this._eval(m, e[O], O, t, s, n) && y(this._trace(h, e[O],
|
|
1105
|
+
this._eval(m, e[O], O, t, s, n) && y(this._trace(h, e[O], re(t, O), e, O, o, !0));
|
|
1106
1106
|
});
|
|
1107
1107
|
} else if (l[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
@@ -1110,8 +1110,8 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1110
1110
|
y(this._trace(ke(this._eval(l, e, t.at(-1), t.slice(0, -1), s, n), h), e, t, s, n, o, i));
|
|
1111
1111
|
} else if (l[0] === "@") {
|
|
1112
1112
|
let m = !1;
|
|
1113
|
-
const
|
|
1114
|
-
switch (
|
|
1113
|
+
const A = l.slice(1, -2);
|
|
1114
|
+
switch (A) {
|
|
1115
1115
|
case "scalar":
|
|
1116
1116
|
(!e || !["object", "function"].includes(typeof e)) && (m = !0);
|
|
1117
1117
|
break;
|
|
@@ -1119,7 +1119,7 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1119
1119
|
case "string":
|
|
1120
1120
|
case "undefined":
|
|
1121
1121
|
case "function":
|
|
1122
|
-
typeof e ===
|
|
1122
|
+
typeof e === A && (m = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
1125
|
Number.isFinite(e) && !(e % 1) && (m = !0);
|
|
@@ -1131,7 +1131,7 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1131
1131
|
typeof e == "number" && !Number.isFinite(e) && (m = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e ===
|
|
1134
|
+
e && typeof e === A && (m = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
1137
|
Array.isArray(e) && (m = !0);
|
|
@@ -1144,7 +1144,7 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1144
1144
|
break;
|
|
1145
1145
|
/* c8 ignore next 2 */
|
|
1146
1146
|
default:
|
|
1147
|
-
throw new TypeError("Unknown value type " +
|
|
1147
|
+
throw new TypeError("Unknown value type " + A);
|
|
1148
1148
|
}
|
|
1149
1149
|
if (m)
|
|
1150
1150
|
return a = {
|
|
@@ -1155,18 +1155,18 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1155
1155
|
}, this._handleCallback(a, o, "value"), a;
|
|
1156
1156
|
} else if (l[0] === "`" && e && Object.hasOwn(e, l.slice(1))) {
|
|
1157
1157
|
const m = l.slice(1);
|
|
1158
|
-
y(this._trace(h, e[m],
|
|
1158
|
+
y(this._trace(h, e[m], re(t, m), e, m, o, i, !0));
|
|
1159
1159
|
} else if (l.includes(",")) {
|
|
1160
1160
|
const m = l.split(",");
|
|
1161
|
-
for (const
|
|
1162
|
-
y(this._trace(ke(
|
|
1163
|
-
} else !u && e && Object.hasOwn(e, l) && y(this._trace(h, e[l],
|
|
1161
|
+
for (const A of m)
|
|
1162
|
+
y(this._trace(ke(A, h), e, t, s, n, o, !0));
|
|
1163
|
+
} else !u && e && Object.hasOwn(e, l) && y(this._trace(h, e[l], re(t, l), e, l, o, i, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
1166
|
for (let m = 0; m < f.length; m++) {
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
const O = this._trace(
|
|
1167
|
+
const A = f[m];
|
|
1168
|
+
if (A && A.isParentSelector) {
|
|
1169
|
+
const O = this._trace(A.expr, e, A.path, s, n, o, i);
|
|
1170
1170
|
if (Array.isArray(O)) {
|
|
1171
1171
|
f[m] = O[0];
|
|
1172
1172
|
const P = O.length;
|
|
@@ -1306,7 +1306,7 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1306
1306
|
}, pt = { class: "json-node__line" }, gt = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, mt = ["title"], bt = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
1312
|
}, yt = {
|
|
@@ -1327,7 +1327,7 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1327
1327
|
}, At = ["title"], Ct = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
}, Ot = /* @__PURE__ */
|
|
1330
|
+
}, Ot = /* @__PURE__ */ me({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1354,19 +1354,19 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1354
1354
|
"231c0282": b.theme.colors.background,
|
|
1355
1355
|
e1dce7d8: b.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r, s = e, n = G(!1), o = G(!1), i = G(""), u = G(""), a = (b) => b !== null && typeof b == "object" && !Array.isArray(b) && "__protected_number__" in b && Object.keys(b).length === 1, l = (b) => a(b) ? b.__protected_number__ : "", h =
|
|
1357
|
+
const t = r, s = e, n = G(!1), o = G(!1), i = G(""), u = G(""), a = (b) => b !== null && typeof b == "object" && !Array.isArray(b) && "__protected_number__" in b && Object.keys(b).length === 1, l = (b) => a(b) ? b.__protected_number__ : "", h = V(() => a(t.value) ? !1 : t.value !== null && typeof t.value == "object"), f = V(() => Array.isArray(t.value)), y = V(() => t.path ? t.path : t.keyName ? t.keyName : "root"), m = V(() => t.expanded.has(y.value)), A = V(() => t.keyName), O = V(() => f.value ? "[" : "{"), P = V(() => f.value ? "]" : "}"), M = V(() => {
|
|
1358
1358
|
if (!t.value) return "";
|
|
1359
1359
|
const d = Object.keys(t.value).length;
|
|
1360
1360
|
return f.value ? d > 0 ? ` ${d} items ` : " " : d > 0 ? ` ${d} keys ` : " ";
|
|
1361
|
-
}),
|
|
1361
|
+
}), Q = V(() => {
|
|
1362
1362
|
const b = typeof t.value;
|
|
1363
1363
|
return t.value === null ? "json-node__value--null" : b === "boolean" ? "json-node__value--boolean" : b === "number" || a(t.value) ? "json-node__value--number" : b === "string" ? "json-node__value--string" : "";
|
|
1364
|
-
}),
|
|
1364
|
+
}), k = V(() => o.value ? u.value : t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : a(t.value) ? l(t.value) : typeof t.value == "string" ? `"${t.value}"` : String(t.value)), p = V(() => "Click to edit, double-click to copy"), T = (b) => t.level === 0 ? b : y.value ? `${y.value}.${b}` : b, j = (b) => {
|
|
1365
1365
|
const d = Object.keys(t.value);
|
|
1366
1366
|
return d.indexOf(b) === d.length - 1;
|
|
1367
|
-
},
|
|
1367
|
+
}, S = () => {
|
|
1368
1368
|
s("toggle-expand", y.value);
|
|
1369
|
-
},
|
|
1369
|
+
}, X = () => {
|
|
1370
1370
|
t.level !== 0 && (n.value = !0, i.value = t.keyName, ce(() => {
|
|
1371
1371
|
const b = document.querySelectorAll(".json-node__key-input"), d = b[b.length - 1];
|
|
1372
1372
|
d && (d.focus(), d.select());
|
|
@@ -1376,11 +1376,11 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1376
1376
|
const b = document.querySelectorAll(".json-node__value-input"), d = b[b.length - 1];
|
|
1377
1377
|
d && (d.focus(), d.select());
|
|
1378
1378
|
}));
|
|
1379
|
-
},
|
|
1379
|
+
}, ee = () => {
|
|
1380
1380
|
if (t.level === 0 || !n.value) return;
|
|
1381
1381
|
const b = i.value.trim();
|
|
1382
1382
|
if (!b) {
|
|
1383
|
-
|
|
1383
|
+
te();
|
|
1384
1384
|
return;
|
|
1385
1385
|
}
|
|
1386
1386
|
if (b === t.keyName) {
|
|
@@ -1388,7 +1388,7 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
1390
|
n.value = !1, s("update:key", y.value, b);
|
|
1391
|
-
},
|
|
1391
|
+
}, z = () => {
|
|
1392
1392
|
try {
|
|
1393
1393
|
let b;
|
|
1394
1394
|
const d = u.value.trim();
|
|
@@ -1397,38 +1397,38 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1397
1397
|
else if (d === "true" || d === "false")
|
|
1398
1398
|
b = d === "true";
|
|
1399
1399
|
else if (!isNaN(Number(d)) && d !== "") {
|
|
1400
|
-
const
|
|
1401
|
-
!Number.isSafeInteger(
|
|
1400
|
+
const g = Number(d);
|
|
1401
|
+
!Number.isSafeInteger(g) || d.length > 15 ? b = { __protected_number__: d } : b = g;
|
|
1402
1402
|
} else
|
|
1403
1403
|
b = u.value;
|
|
1404
1404
|
s("update:value", y.value, b), o.value = !1;
|
|
1405
1405
|
} catch (b) {
|
|
1406
1406
|
console.error("Failed to parse value:", b), o.value = !1;
|
|
1407
1407
|
}
|
|
1408
|
-
},
|
|
1408
|
+
}, te = () => {
|
|
1409
1409
|
n.value = !1, i.value = t.keyName;
|
|
1410
1410
|
}, Ee = () => {
|
|
1411
1411
|
o.value = !1, a(t.value) ? u.value = l(t.value) : typeof t.value == "string" ? u.value = t.value : u.value = String(t.value);
|
|
1412
1412
|
};
|
|
1413
1413
|
return (b, d) => {
|
|
1414
|
-
const
|
|
1414
|
+
const g = Me("JsonNode", !0);
|
|
1415
1415
|
return x(), N("div", ft, [
|
|
1416
1416
|
h.value ? (x(), N("div", ht, [
|
|
1417
1417
|
E("div", pt, [
|
|
1418
1418
|
b.keyName && !n.value ? (x(), N("span", {
|
|
1419
1419
|
key: 0,
|
|
1420
1420
|
class: "json-node__key",
|
|
1421
|
-
onClick:
|
|
1421
|
+
onClick: X,
|
|
1422
1422
|
title: "Click to edit key"
|
|
1423
|
-
}, ' "' + R(
|
|
1423
|
+
}, ' "' + R(A.value) + '" ', 1)) : F("", !0),
|
|
1424
1424
|
b.keyName && n.value ? ve((x(), N("input", {
|
|
1425
1425
|
key: 1,
|
|
1426
1426
|
"onUpdate:modelValue": d[0] || (d[0] = (_) => i.value = _),
|
|
1427
1427
|
onKeyup: [
|
|
1428
|
-
le(
|
|
1429
|
-
le(
|
|
1428
|
+
le(ee, ["enter"]),
|
|
1429
|
+
le(te, ["escape"])
|
|
1430
1430
|
],
|
|
1431
|
-
onBlur:
|
|
1431
|
+
onBlur: ee,
|
|
1432
1432
|
class: "json-node__key-input"
|
|
1433
1433
|
}, null, 544)), [
|
|
1434
1434
|
[_e, i.value]
|
|
@@ -1436,14 +1436,14 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1436
1436
|
b.keyName ? (x(), N("span", gt, ": ")) : F("", !0),
|
|
1437
1437
|
E("span", {
|
|
1438
1438
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1439
|
-
onClick:
|
|
1439
|
+
onClick: S,
|
|
1440
1440
|
title: m.value ? "Click to collapse" : "Click to expand"
|
|
1441
|
-
}, R(O.value), 9,
|
|
1442
|
-
m.value ? F("", !0) : (x(), N("span",
|
|
1441
|
+
}, R(O.value), 9, mt),
|
|
1442
|
+
m.value ? F("", !0) : (x(), N("span", bt, [
|
|
1443
1443
|
Se(R(M.value) + " ", 1),
|
|
1444
1444
|
E("span", {
|
|
1445
1445
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1446
|
-
onClick:
|
|
1446
|
+
onClick: S
|
|
1447
1447
|
}, R(P.value), 1)
|
|
1448
1448
|
])),
|
|
1449
1449
|
!m.value && !b.isLast ? (x(), N("span", yt, ",")) : F("", !0)
|
|
@@ -1454,18 +1454,18 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1454
1454
|
key: v,
|
|
1455
1455
|
class: "json-node__child"
|
|
1456
1456
|
}, [
|
|
1457
|
-
Ue(
|
|
1457
|
+
Ue(g, {
|
|
1458
1458
|
value: _,
|
|
1459
1459
|
"key-name": f.value ? "" : String(v),
|
|
1460
1460
|
level: b.level + 1,
|
|
1461
1461
|
path: T(String(v)),
|
|
1462
1462
|
expanded: b.expanded,
|
|
1463
1463
|
theme: b.theme,
|
|
1464
|
-
"onUpdate:value": d[1] || (d[1] = (w,
|
|
1464
|
+
"onUpdate:value": d[1] || (d[1] = (w, C) => b.$emit("update:value", w, C)),
|
|
1465
1465
|
onToggleExpand: d[2] || (d[2] = (w) => b.$emit("toggle-expand", w)),
|
|
1466
1466
|
onCopy: d[3] || (d[3] = (w) => b.$emit("copy", w)),
|
|
1467
|
-
"onUpdate:key": d[4] || (d[4] = (w,
|
|
1468
|
-
"is-last":
|
|
1467
|
+
"onUpdate:key": d[4] || (d[4] = (w, C) => b.$emit("update:key", w, C)),
|
|
1468
|
+
"is-last": j(String(v))
|
|
1469
1469
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1470
1470
|
]))), 128))
|
|
1471
1471
|
]),
|
|
@@ -1478,17 +1478,17 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1478
1478
|
b.keyName && !n.value ? (x(), N("span", {
|
|
1479
1479
|
key: 0,
|
|
1480
1480
|
class: "json-node__key",
|
|
1481
|
-
onClick:
|
|
1481
|
+
onClick: X,
|
|
1482
1482
|
title: "Click to edit key"
|
|
1483
|
-
}, ' "' + R(
|
|
1483
|
+
}, ' "' + R(A.value) + '" ', 1)) : F("", !0),
|
|
1484
1484
|
b.keyName && n.value ? ve((x(), N("input", {
|
|
1485
1485
|
key: 1,
|
|
1486
1486
|
"onUpdate:modelValue": d[5] || (d[5] = (_) => i.value = _),
|
|
1487
1487
|
onKeyup: [
|
|
1488
|
-
le(
|
|
1489
|
-
le(
|
|
1488
|
+
le(ee, ["enter"]),
|
|
1489
|
+
le(te, ["escape"])
|
|
1490
1490
|
],
|
|
1491
|
-
onBlur:
|
|
1491
|
+
onBlur: ee,
|
|
1492
1492
|
class: "json-node__key-input"
|
|
1493
1493
|
}, null, 544)), [
|
|
1494
1494
|
[_e, i.value]
|
|
@@ -1496,22 +1496,22 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1496
1496
|
b.keyName ? (x(), N("span", wt, ": ")) : F("", !0),
|
|
1497
1497
|
o.value ? F("", !0) : (x(), N("span", {
|
|
1498
1498
|
key: 3,
|
|
1499
|
-
class: Oe(["json-node__value",
|
|
1499
|
+
class: Oe(["json-node__value", Q.value]),
|
|
1500
1500
|
onClick: Z,
|
|
1501
1501
|
onDblclick: d[6] || (d[6] = (_) => b.$emit("copy", b.value)),
|
|
1502
|
-
title:
|
|
1502
|
+
title: p.value
|
|
1503
1503
|
}, [
|
|
1504
|
-
Se(R(
|
|
1504
|
+
Se(R(k.value), 1),
|
|
1505
1505
|
b.isLast ? F("", !0) : (x(), N("span", Ct, ","))
|
|
1506
1506
|
], 42, At)),
|
|
1507
1507
|
o.value ? ve((x(), N("input", {
|
|
1508
1508
|
key: 4,
|
|
1509
1509
|
"onUpdate:modelValue": d[7] || (d[7] = (_) => u.value = _),
|
|
1510
1510
|
onKeyup: [
|
|
1511
|
-
le(
|
|
1511
|
+
le(z, ["enter"]),
|
|
1512
1512
|
le(Ee, ["escape"])
|
|
1513
1513
|
],
|
|
1514
|
-
onBlur:
|
|
1514
|
+
onBlur: z,
|
|
1515
1515
|
class: "json-node__value-input"
|
|
1516
1516
|
}, null, 544)), [
|
|
1517
1517
|
[_e, u.value]
|
|
@@ -1520,12 +1520,12 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1520
1520
|
]);
|
|
1521
1521
|
};
|
|
1522
1522
|
}
|
|
1523
|
-
}),
|
|
1523
|
+
}), be = (r, e) => {
|
|
1524
1524
|
const t = r.__vccOpts || r;
|
|
1525
1525
|
for (const [s, n] of e)
|
|
1526
1526
|
t[s] = n;
|
|
1527
1527
|
return t;
|
|
1528
|
-
}, Tt = /* @__PURE__ */
|
|
1528
|
+
}, Tt = /* @__PURE__ */ be(Ot, [["__scopeId", "data-v-860beb35"]]), He = {
|
|
1529
1529
|
name: "github-light",
|
|
1530
1530
|
colors: {
|
|
1531
1531
|
// 背景色
|
|
@@ -1690,10 +1690,10 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1690
1690
|
function Bt(r = "github-light") {
|
|
1691
1691
|
return $t[r] || He;
|
|
1692
1692
|
}
|
|
1693
|
-
const
|
|
1693
|
+
const Vt = {
|
|
1694
1694
|
key: 0,
|
|
1695
1695
|
class: "json-format__toolbar"
|
|
1696
|
-
},
|
|
1696
|
+
}, Lt = { class: "json-format__actions" }, Rt = ["disabled"], jt = ["disabled"], Mt = ["disabled"], Ut = ["disabled"], Ft = { class: "json-format__info" }, Xt = {
|
|
1697
1697
|
key: 0,
|
|
1698
1698
|
class: "json-format__status json-format__status--success"
|
|
1699
1699
|
}, Ht = {
|
|
@@ -1708,7 +1708,7 @@ const Lt = {
|
|
|
1708
1708
|
}, Qt = {
|
|
1709
1709
|
key: 2,
|
|
1710
1710
|
class: "json-format__viewer"
|
|
1711
|
-
}, Gt = /* @__PURE__ */
|
|
1711
|
+
}, Gt = /* @__PURE__ */ me({
|
|
1712
1712
|
name: "JsonFormat",
|
|
1713
1713
|
__name: "index",
|
|
1714
1714
|
props: {
|
|
@@ -1739,52 +1739,52 @@ const Lt = {
|
|
|
1739
1739
|
"2c1c44e4": f.value.colors.scrollbarThumb,
|
|
1740
1740
|
"8ba97764": f.value.colors.scrollbarThumbHover
|
|
1741
1741
|
}));
|
|
1742
|
-
const s = r, n = t, o = G(null), i = G(""), u = G(/* @__PURE__ */ new Set()), a = G(null), l = G(""), h =
|
|
1742
|
+
const s = r, n = t, o = G(null), i = G(""), u = G(/* @__PURE__ */ new Set()), a = G(null), l = G(""), h = V(() => i.value === ""), f = V(() => Bt(s.theme)), y = V(() => l.value ? null : a.value !== null ? a.value : o.value), m = (d) => {
|
|
1743
1743
|
if (!d.trim()) {
|
|
1744
1744
|
o.value = null, i.value = "", a.value = null, l.value = "";
|
|
1745
1745
|
return;
|
|
1746
1746
|
}
|
|
1747
1747
|
try {
|
|
1748
|
-
let
|
|
1749
|
-
const _ = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(
|
|
1748
|
+
let g = d;
|
|
1749
|
+
const _ = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(g), v = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(g);
|
|
1750
1750
|
if (!_ && !v)
|
|
1751
1751
|
try {
|
|
1752
|
-
o.value = JSON.parse(
|
|
1753
|
-
y.value !== null &&
|
|
1752
|
+
o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", ce(() => {
|
|
1753
|
+
y.value !== null && p();
|
|
1754
1754
|
});
|
|
1755
1755
|
return;
|
|
1756
1756
|
} catch {
|
|
1757
1757
|
}
|
|
1758
|
-
|
|
1759
|
-
let B = "", H = !1, K = !1,
|
|
1760
|
-
for (;
|
|
1761
|
-
const ae =
|
|
1758
|
+
g = ((C) => {
|
|
1759
|
+
let B = "", H = !1, K = !1, D = 0;
|
|
1760
|
+
for (; D < C.length; ) {
|
|
1761
|
+
const ae = C[D];
|
|
1762
1762
|
if (H)
|
|
1763
|
-
K ? K = !1 : ae === "\\" ? K = !0 : ae === '"' && (H = !1), B += ae,
|
|
1763
|
+
K ? K = !1 : ae === "\\" ? K = !0 : ae === '"' && (H = !1), B += ae, D++;
|
|
1764
1764
|
else if (ae === '"')
|
|
1765
|
-
H = !0, B += ae,
|
|
1765
|
+
H = !0, B += ae, D++;
|
|
1766
1766
|
else {
|
|
1767
|
-
const Pe =
|
|
1767
|
+
const Pe = C.slice(D);
|
|
1768
1768
|
let W = Pe.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1769
1769
|
if (W) {
|
|
1770
|
-
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3],
|
|
1770
|
+
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3], D += W[0].length;
|
|
1771
1771
|
continue;
|
|
1772
1772
|
}
|
|
1773
1773
|
if (W = Pe.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), W) {
|
|
1774
|
-
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3],
|
|
1774
|
+
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3], D += W[0].length;
|
|
1775
1775
|
continue;
|
|
1776
1776
|
}
|
|
1777
|
-
B += ae,
|
|
1777
|
+
B += ae, D++;
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
1780
|
return B;
|
|
1781
|
-
})(
|
|
1782
|
-
y.value !== null &&
|
|
1781
|
+
})(g), o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", ce(() => {
|
|
1782
|
+
y.value !== null && p();
|
|
1783
1783
|
});
|
|
1784
|
-
} catch (
|
|
1785
|
-
i.value =
|
|
1784
|
+
} catch (g) {
|
|
1785
|
+
i.value = g instanceof Error ? g.message : "Unknown parsing error", o.value = null, a.value = null, l.value = "";
|
|
1786
1786
|
}
|
|
1787
|
-
},
|
|
1787
|
+
}, A = (d) => {
|
|
1788
1788
|
if (!d || !d.expression.trim()) {
|
|
1789
1789
|
O();
|
|
1790
1790
|
return;
|
|
@@ -1794,24 +1794,24 @@ const Lt = {
|
|
|
1794
1794
|
return;
|
|
1795
1795
|
}
|
|
1796
1796
|
try {
|
|
1797
|
-
let
|
|
1797
|
+
let g;
|
|
1798
1798
|
if (d.type === "jsonpath")
|
|
1799
|
-
|
|
1799
|
+
g = $({ path: d.expression, json: o.value }), g.length === 1 && d.expression.includes("$[") === !1 && !d.expression.endsWith("[*]") ? a.value = g[0] : a.value = g;
|
|
1800
1800
|
else if (d.type === "js")
|
|
1801
|
-
|
|
1801
|
+
g = new Function("data", `
|
|
1802
1802
|
try {
|
|
1803
1803
|
return ${d.expression};
|
|
1804
1804
|
} catch (error) {
|
|
1805
1805
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1806
1806
|
}
|
|
1807
|
-
`)(o.value), a.value =
|
|
1807
|
+
`)(o.value), a.value = g;
|
|
1808
1808
|
else
|
|
1809
1809
|
throw new Error(`Unsupported filter type: ${d.type}`);
|
|
1810
1810
|
l.value = "", ce(() => {
|
|
1811
|
-
|
|
1811
|
+
p();
|
|
1812
1812
|
});
|
|
1813
|
-
} catch (
|
|
1814
|
-
l.value =
|
|
1813
|
+
} catch (g) {
|
|
1814
|
+
l.value = g instanceof Error ? g.message : "Filter execution error", a.value = null;
|
|
1815
1815
|
}
|
|
1816
1816
|
}, O = () => {
|
|
1817
1817
|
a.value = null, l.value = "";
|
|
@@ -1819,7 +1819,7 @@ const Lt = {
|
|
|
1819
1819
|
Fe(() => s.modelValue, (d) => {
|
|
1820
1820
|
m(d);
|
|
1821
1821
|
}, { immediate: !0 });
|
|
1822
|
-
const P = (d,
|
|
1822
|
+
const P = (d, g, _) => {
|
|
1823
1823
|
const v = (B) => {
|
|
1824
1824
|
if (B === null || typeof B != "object")
|
|
1825
1825
|
return B;
|
|
@@ -1828,144 +1828,144 @@ const Lt = {
|
|
|
1828
1828
|
if (Array.isArray(B))
|
|
1829
1829
|
return B.map((K) => v(K));
|
|
1830
1830
|
const H = {};
|
|
1831
|
-
for (const [K,
|
|
1832
|
-
H[K] = v(
|
|
1831
|
+
for (const [K, D] of Object.entries(B))
|
|
1832
|
+
H[K] = v(D);
|
|
1833
1833
|
return H;
|
|
1834
1834
|
}, w = v(d);
|
|
1835
|
-
return JSON.stringify(w,
|
|
1836
|
-
}, M = (d,
|
|
1835
|
+
return JSON.stringify(w, g, _).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1836
|
+
}, M = (d, g) => {
|
|
1837
1837
|
if (!s.readonly)
|
|
1838
1838
|
try {
|
|
1839
|
-
const _ =
|
|
1839
|
+
const _ = Q(o.value, d, g), v = P(_, null, 2);
|
|
1840
1840
|
n("update:modelValue", v);
|
|
1841
1841
|
} catch (_) {
|
|
1842
1842
|
console.error("Failed to update JSON:", _);
|
|
1843
1843
|
}
|
|
1844
|
-
},
|
|
1845
|
-
if (!
|
|
1846
|
-
const v =
|
|
1847
|
-
let
|
|
1844
|
+
}, Q = (d, g, _) => {
|
|
1845
|
+
if (!g || g === "root") return _;
|
|
1846
|
+
const v = g.split("."), w = z(d, v.slice(0, -1));
|
|
1847
|
+
let C = w;
|
|
1848
1848
|
for (let H = 0; H < v.length - 1; H++) {
|
|
1849
1849
|
const K = v[H];
|
|
1850
|
-
K !== "root" && (Array.isArray(
|
|
1850
|
+
K !== "root" && (Array.isArray(C) ? C = C[parseInt(K)] : C = C[K]);
|
|
1851
1851
|
}
|
|
1852
1852
|
const B = v[v.length - 1];
|
|
1853
|
-
return B === "root" ? _ : (Array.isArray(
|
|
1854
|
-
},
|
|
1853
|
+
return B === "root" ? _ : (Array.isArray(C) ? C[parseInt(B)] = _ : C[B] = _, w);
|
|
1854
|
+
}, k = (d) => {
|
|
1855
1855
|
u.value.has(d) ? u.value.delete(d) : u.value.add(d);
|
|
1856
|
-
},
|
|
1857
|
-
const d = /* @__PURE__ */ new Set(),
|
|
1858
|
-
_ !== null && typeof _ == "object" && (d.add(v || "root"), Array.isArray(_) ? _.forEach((w,
|
|
1859
|
-
const B = v ? `${v}.${
|
|
1860
|
-
|
|
1856
|
+
}, p = () => {
|
|
1857
|
+
const d = /* @__PURE__ */ new Set(), g = (_, v = "") => {
|
|
1858
|
+
_ !== null && typeof _ == "object" && (d.add(v || "root"), Array.isArray(_) ? _.forEach((w, C) => {
|
|
1859
|
+
const B = v ? `${v}.${C}` : `${C}`;
|
|
1860
|
+
g(w, B);
|
|
1861
1861
|
}) : Object.keys(_).forEach((w) => {
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1862
|
+
const C = v ? `${v}.${w}` : w;
|
|
1863
|
+
g(_[w], C);
|
|
1864
1864
|
}));
|
|
1865
1865
|
};
|
|
1866
|
-
|
|
1866
|
+
g(y.value), u.value = d, n("expand-all");
|
|
1867
1867
|
}, T = () => {
|
|
1868
1868
|
u.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1869
|
-
},
|
|
1869
|
+
}, j = async () => {
|
|
1870
1870
|
if (h.value)
|
|
1871
1871
|
try {
|
|
1872
|
-
const d = y.value,
|
|
1873
|
-
await navigator.clipboard.writeText(
|
|
1872
|
+
const d = y.value, g = P(d, null, 2);
|
|
1873
|
+
await navigator.clipboard.writeText(g), n("copy-success", g);
|
|
1874
1874
|
} catch (d) {
|
|
1875
1875
|
console.error("Failed to copy JSON:", d), n("copy-error", d instanceof Error ? d : new Error("Failed to copy JSON"));
|
|
1876
1876
|
}
|
|
1877
|
-
},
|
|
1877
|
+
}, S = () => {
|
|
1878
1878
|
if (h.value)
|
|
1879
1879
|
try {
|
|
1880
|
-
const d = y.value,
|
|
1881
|
-
n("update:modelValue",
|
|
1880
|
+
const d = y.value, g = P(d);
|
|
1881
|
+
n("update:modelValue", g), n("compress", g);
|
|
1882
1882
|
} catch (d) {
|
|
1883
1883
|
console.error("Failed to compress JSON:", d);
|
|
1884
1884
|
}
|
|
1885
|
-
},
|
|
1885
|
+
}, X = async (d) => {
|
|
1886
1886
|
try {
|
|
1887
|
-
let
|
|
1888
|
-
typeof d == "object" && d !== null && !Array.isArray(d) && "__protected_number__" in d && Object.keys(d).length === 1 ?
|
|
1889
|
-
} catch (
|
|
1890
|
-
console.error("Failed to copy value:",
|
|
1887
|
+
let g;
|
|
1888
|
+
typeof d == "object" && d !== null && !Array.isArray(d) && "__protected_number__" in d && Object.keys(d).length === 1 ? g = d.__protected_number__ : typeof d == "string" ? g = `"${d}"` : g = JSON.stringify(d), await navigator.clipboard.writeText(g);
|
|
1889
|
+
} catch (g) {
|
|
1890
|
+
console.error("Failed to copy value:", g);
|
|
1891
1891
|
}
|
|
1892
|
-
}, Z = (d,
|
|
1892
|
+
}, Z = (d, g) => {
|
|
1893
1893
|
if (!s.readonly)
|
|
1894
1894
|
try {
|
|
1895
|
-
const _ =
|
|
1896
|
-
n("update:modelValue", v), b(d,
|
|
1895
|
+
const _ = ee(o.value, d, g), v = P(_, null, 2);
|
|
1896
|
+
n("update:modelValue", v), b(d, g);
|
|
1897
1897
|
} catch (_) {
|
|
1898
1898
|
console.error("Failed to rename key:", _);
|
|
1899
1899
|
}
|
|
1900
|
-
},
|
|
1901
|
-
if (!
|
|
1902
|
-
const v =
|
|
1900
|
+
}, ee = (d, g, _) => {
|
|
1901
|
+
if (!g || g === "root") return d;
|
|
1902
|
+
const v = g.split("."), w = z(d, v.slice(0, -1));
|
|
1903
1903
|
if (v.length === 1) {
|
|
1904
1904
|
const H = v[0];
|
|
1905
|
-
return w && typeof w == "object" && !Array.isArray(w) ?
|
|
1905
|
+
return w && typeof w == "object" && !Array.isArray(w) ? te(w, H, _) : w;
|
|
1906
1906
|
}
|
|
1907
|
-
let
|
|
1907
|
+
let C = w;
|
|
1908
1908
|
for (let H = 0; H < v.length - 1; H++) {
|
|
1909
1909
|
const K = v[H];
|
|
1910
|
-
Array.isArray(
|
|
1910
|
+
Array.isArray(C) ? C = C[parseInt(K)] : C = C[K];
|
|
1911
1911
|
}
|
|
1912
1912
|
const B = v[v.length - 1];
|
|
1913
|
-
if (!Array.isArray(
|
|
1914
|
-
const H =
|
|
1913
|
+
if (!Array.isArray(C) && C && typeof C == "object") {
|
|
1914
|
+
const H = te(C, B, _), K = v.slice(0, -1);
|
|
1915
1915
|
K.length > 0 && Ee(w, K, H);
|
|
1916
1916
|
}
|
|
1917
1917
|
return w;
|
|
1918
|
-
},
|
|
1919
|
-
if (
|
|
1918
|
+
}, z = (d, g) => {
|
|
1919
|
+
if (g.length === 0) return d;
|
|
1920
1920
|
if (Array.isArray(d)) {
|
|
1921
|
-
const _ = [...d], v =
|
|
1922
|
-
return
|
|
1921
|
+
const _ = [...d], v = g[0], w = parseInt(v);
|
|
1922
|
+
return g.length === 1 || (_[w] = z(d[w], g.slice(1))), _;
|
|
1923
1923
|
} else if (d && typeof d == "object") {
|
|
1924
|
-
const _ = { ...d }, v =
|
|
1925
|
-
return
|
|
1924
|
+
const _ = { ...d }, v = g[0];
|
|
1925
|
+
return g.length === 1 || (_[v] = z(d[v], g.slice(1))), _;
|
|
1926
1926
|
}
|
|
1927
1927
|
return d;
|
|
1928
|
-
},
|
|
1928
|
+
}, te = (d, g, _) => {
|
|
1929
1929
|
if (!d || typeof d != "object" || Array.isArray(d))
|
|
1930
1930
|
return d;
|
|
1931
1931
|
const v = Object.keys(d), w = {};
|
|
1932
|
-
for (const
|
|
1933
|
-
|
|
1932
|
+
for (const C of v)
|
|
1933
|
+
C === g ? w[_] = d[C] : w[C] = d[C];
|
|
1934
1934
|
return w;
|
|
1935
|
-
}, Ee = (d,
|
|
1935
|
+
}, Ee = (d, g, _) => {
|
|
1936
1936
|
let v = d;
|
|
1937
|
-
for (let
|
|
1938
|
-
const B =
|
|
1937
|
+
for (let C = 0; C < g.length - 1; C++) {
|
|
1938
|
+
const B = g[C];
|
|
1939
1939
|
Array.isArray(v) ? v = v[parseInt(B)] : v = v[B];
|
|
1940
1940
|
}
|
|
1941
|
-
const w =
|
|
1941
|
+
const w = g[g.length - 1];
|
|
1942
1942
|
Array.isArray(v) ? v[parseInt(w)] = _ : v[w] = _;
|
|
1943
|
-
}, b = (d,
|
|
1943
|
+
}, b = (d, g) => {
|
|
1944
1944
|
const _ = /* @__PURE__ */ new Set();
|
|
1945
1945
|
u.value.forEach((v) => {
|
|
1946
1946
|
if (v === d) {
|
|
1947
1947
|
const w = d.split(".");
|
|
1948
|
-
w[w.length - 1] =
|
|
1948
|
+
w[w.length - 1] = g, _.add(w.join("."));
|
|
1949
1949
|
} else if (v.startsWith(d + ".")) {
|
|
1950
1950
|
const w = d.split(".");
|
|
1951
|
-
w[w.length - 1] =
|
|
1952
|
-
const
|
|
1953
|
-
_.add(
|
|
1951
|
+
w[w.length - 1] = g;
|
|
1952
|
+
const C = w.join("."), B = v.substring(d.length);
|
|
1953
|
+
_.add(C + B);
|
|
1954
1954
|
} else
|
|
1955
1955
|
_.add(v);
|
|
1956
1956
|
}), u.value = _;
|
|
1957
1957
|
};
|
|
1958
1958
|
return e({
|
|
1959
1959
|
// 核心操作方法
|
|
1960
|
-
copyJson:
|
|
1961
|
-
compressSource:
|
|
1962
|
-
expandAll:
|
|
1960
|
+
copyJson: j,
|
|
1961
|
+
compressSource: S,
|
|
1962
|
+
expandAll: p,
|
|
1963
1963
|
collapseAll: T,
|
|
1964
|
-
toggleExpand:
|
|
1964
|
+
toggleExpand: k,
|
|
1965
1965
|
updateValue: M,
|
|
1966
1966
|
updateKey: Z,
|
|
1967
1967
|
// Filter 相关方法
|
|
1968
|
-
filter:
|
|
1968
|
+
filter: A,
|
|
1969
1969
|
clearFilter: O,
|
|
1970
1970
|
// 状态访问方法
|
|
1971
1971
|
isValidJson: () => h.value,
|
|
@@ -1976,21 +1976,21 @@ const Lt = {
|
|
|
1976
1976
|
getFilterError: () => l.value,
|
|
1977
1977
|
// 工具方法
|
|
1978
1978
|
parseJson: (d) => m(d),
|
|
1979
|
-
copyValue: (d) =>
|
|
1980
|
-
}), (d,
|
|
1979
|
+
copyValue: (d) => X(d)
|
|
1980
|
+
}), (d, g) => (x(), N("div", {
|
|
1981
1981
|
class: Oe(["json-format", `json-format--${f.value.name}`])
|
|
1982
1982
|
}, [
|
|
1983
|
-
d.showToolbar ? (x(), N("div",
|
|
1984
|
-
E("div",
|
|
1983
|
+
d.showToolbar ? (x(), N("div", Vt, [
|
|
1984
|
+
E("div", Lt, [
|
|
1985
1985
|
E("button", {
|
|
1986
1986
|
class: "json-format__btn json-format__btn--primary",
|
|
1987
|
-
onClick:
|
|
1987
|
+
onClick: j,
|
|
1988
1988
|
disabled: !h.value,
|
|
1989
1989
|
title: "Copy JSON"
|
|
1990
1990
|
}, " 📋 Copy ", 8, Rt),
|
|
1991
1991
|
E("button", {
|
|
1992
1992
|
class: "json-format__btn json-format__btn--secondary",
|
|
1993
|
-
onClick:
|
|
1993
|
+
onClick: p,
|
|
1994
1994
|
disabled: !h.value,
|
|
1995
1995
|
title: "Expand All"
|
|
1996
1996
|
}, " ⬇️ Expand All ", 8, jt),
|
|
@@ -2002,7 +2002,7 @@ const Lt = {
|
|
|
2002
2002
|
}, " ➡️ Collapse All ", 8, Mt),
|
|
2003
2003
|
E("button", {
|
|
2004
2004
|
class: "json-format__btn json-format__btn--secondary",
|
|
2005
|
-
onClick:
|
|
2005
|
+
onClick: S,
|
|
2006
2006
|
disabled: !h.value,
|
|
2007
2007
|
title: "Compress JSON"
|
|
2008
2008
|
}, " 📦 Compress ", 8, Ut)
|
|
@@ -2013,7 +2013,7 @@ const Lt = {
|
|
|
2013
2013
|
])) : F("", !0),
|
|
2014
2014
|
E("div", Kt, [
|
|
2015
2015
|
h.value ? l.value ? (x(), N("div", qt, [
|
|
2016
|
-
|
|
2016
|
+
g[1] || (g[1] = E("h4", null, "Filter Error:", -1)),
|
|
2017
2017
|
E("pre", null, R(l.value), 1)
|
|
2018
2018
|
])) : (x(), N("div", Qt, [
|
|
2019
2019
|
Ue(Tt, {
|
|
@@ -2024,18 +2024,18 @@ const Lt = {
|
|
|
2024
2024
|
"is-last": !0,
|
|
2025
2025
|
theme: f.value,
|
|
2026
2026
|
"onUpdate:value": M,
|
|
2027
|
-
onToggleExpand:
|
|
2028
|
-
onCopy:
|
|
2027
|
+
onToggleExpand: k,
|
|
2028
|
+
onCopy: X,
|
|
2029
2029
|
"onUpdate:key": Z
|
|
2030
2030
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2031
2031
|
])) : (x(), N("div", Yt, [
|
|
2032
|
-
|
|
2032
|
+
g[0] || (g[0] = E("h4", null, "JSON Parse Error:", -1)),
|
|
2033
2033
|
E("pre", null, R(i.value), 1)
|
|
2034
2034
|
]))
|
|
2035
2035
|
])
|
|
2036
2036
|
], 2));
|
|
2037
2037
|
}
|
|
2038
|
-
}), Wt = /* @__PURE__ */
|
|
2038
|
+
}), Wt = /* @__PURE__ */ be(Gt, [["__scopeId", "data-v-7a477244"]]), Ke = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", Zt = Ke + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", zt = "[" + Ke + "][" + Zt + "]*", Dt = new RegExp("^" + zt + "$");
|
|
2039
2039
|
function Ye(r, e) {
|
|
2040
2040
|
const t = [];
|
|
2041
2041
|
let s = e.exec(r);
|
|
@@ -2072,7 +2072,7 @@ function qe(r, e) {
|
|
|
2072
2072
|
} else if (r[o] === "<") {
|
|
2073
2073
|
let i = o;
|
|
2074
2074
|
if (o++, r[o] === "!") {
|
|
2075
|
-
o =
|
|
2075
|
+
o = Ve(r, o);
|
|
2076
2076
|
continue;
|
|
2077
2077
|
} else {
|
|
2078
2078
|
let u = !1;
|
|
@@ -2083,51 +2083,51 @@ function qe(r, e) {
|
|
|
2083
2083
|
a += r[o];
|
|
2084
2084
|
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !lr(a)) {
|
|
2085
2085
|
let f;
|
|
2086
|
-
return a.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + a + "' is an invalid name.", U("InvalidTag", f,
|
|
2086
|
+
return a.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + a + "' is an invalid name.", U("InvalidTag", f, Y(r, o));
|
|
2087
2087
|
}
|
|
2088
2088
|
const l = nr(r, o);
|
|
2089
2089
|
if (l === !1)
|
|
2090
|
-
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.",
|
|
2090
|
+
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.", Y(r, o));
|
|
2091
2091
|
let h = l.value;
|
|
2092
2092
|
if (o = l.index, h[h.length - 1] === "/") {
|
|
2093
2093
|
const f = o - h.length;
|
|
2094
2094
|
h = h.substring(0, h.length - 1);
|
|
2095
|
-
const y =
|
|
2095
|
+
const y = Le(h, e);
|
|
2096
2096
|
if (y === !0)
|
|
2097
2097
|
s = !0;
|
|
2098
2098
|
else
|
|
2099
|
-
return U(y.err.code, y.err.msg,
|
|
2099
|
+
return U(y.err.code, y.err.msg, Y(r, f + y.err.line));
|
|
2100
2100
|
} else if (u)
|
|
2101
2101
|
if (l.tagClosed) {
|
|
2102
2102
|
if (h.trim().length > 0)
|
|
2103
|
-
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.",
|
|
2103
|
+
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", Y(r, i));
|
|
2104
2104
|
if (t.length === 0)
|
|
2105
|
-
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.",
|
|
2105
|
+
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.", Y(r, i));
|
|
2106
2106
|
{
|
|
2107
2107
|
const f = t.pop();
|
|
2108
2108
|
if (a !== f.tagName) {
|
|
2109
|
-
let y =
|
|
2109
|
+
let y = Y(r, f.tagStartPos);
|
|
2110
2110
|
return U(
|
|
2111
2111
|
"InvalidTag",
|
|
2112
2112
|
"Expected closing tag '" + f.tagName + "' (opened in line " + y.line + ", col " + y.col + ") instead of closing tag '" + a + "'.",
|
|
2113
|
-
|
|
2113
|
+
Y(r, i)
|
|
2114
2114
|
);
|
|
2115
2115
|
}
|
|
2116
2116
|
t.length == 0 && (n = !0);
|
|
2117
2117
|
}
|
|
2118
|
-
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.",
|
|
2118
|
+
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", Y(r, o));
|
|
2119
2119
|
else {
|
|
2120
|
-
const f =
|
|
2120
|
+
const f = Le(h, e);
|
|
2121
2121
|
if (f !== !0)
|
|
2122
|
-
return U(f.err.code, f.err.msg,
|
|
2122
|
+
return U(f.err.code, f.err.msg, Y(r, o - h.length + f.err.line));
|
|
2123
2123
|
if (n === !0)
|
|
2124
|
-
return U("InvalidXml", "Multiple possible root nodes found.",
|
|
2124
|
+
return U("InvalidXml", "Multiple possible root nodes found.", Y(r, o));
|
|
2125
2125
|
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2126
2126
|
}
|
|
2127
2127
|
for (o++; o < r.length; o++)
|
|
2128
2128
|
if (r[o] === "<")
|
|
2129
2129
|
if (r[o + 1] === "!") {
|
|
2130
|
-
o++, o =
|
|
2130
|
+
o++, o = Ve(r, o);
|
|
2131
2131
|
continue;
|
|
2132
2132
|
} else if (r[o + 1] === "?") {
|
|
2133
2133
|
if (o = Be(r, ++o), o.err) return o;
|
|
@@ -2136,20 +2136,20 @@ function qe(r, e) {
|
|
|
2136
2136
|
else if (r[o] === "&") {
|
|
2137
2137
|
const f = ir(r, o);
|
|
2138
2138
|
if (f == -1)
|
|
2139
|
-
return U("InvalidChar", "char '&' is not expected.",
|
|
2139
|
+
return U("InvalidChar", "char '&' is not expected.", Y(r, o));
|
|
2140
2140
|
o = f;
|
|
2141
2141
|
} else if (n === !0 && !$e(r[o]))
|
|
2142
|
-
return U("InvalidXml", "Extra text at the end",
|
|
2142
|
+
return U("InvalidXml", "Extra text at the end", Y(r, o));
|
|
2143
2143
|
r[o] === "<" && o--;
|
|
2144
2144
|
}
|
|
2145
2145
|
} else {
|
|
2146
2146
|
if ($e(r[o]))
|
|
2147
2147
|
continue;
|
|
2148
|
-
return U("InvalidChar", "char '" + r[o] + "' is not expected.",
|
|
2148
|
+
return U("InvalidChar", "char '" + r[o] + "' is not expected.", Y(r, o));
|
|
2149
2149
|
}
|
|
2150
2150
|
if (s) {
|
|
2151
2151
|
if (t.length == 1)
|
|
2152
|
-
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.",
|
|
2152
|
+
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", Y(r, t[0].tagStartPos));
|
|
2153
2153
|
if (t.length > 0)
|
|
2154
2154
|
return U("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
2155
2155
|
} else return U("InvalidXml", "Start tag expected.", 1);
|
|
@@ -2165,7 +2165,7 @@ function Be(r, e) {
|
|
|
2165
2165
|
if (r[e] == "?" || r[e] == " ") {
|
|
2166
2166
|
const s = r.substr(t, e - t);
|
|
2167
2167
|
if (e > 5 && s === "xml")
|
|
2168
|
-
return U("InvalidXml", "XML declaration allowed only at the start of the document.",
|
|
2168
|
+
return U("InvalidXml", "XML declaration allowed only at the start of the document.", Y(r, e));
|
|
2169
2169
|
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2170
2170
|
e++;
|
|
2171
2171
|
break;
|
|
@@ -2174,7 +2174,7 @@ function Be(r, e) {
|
|
|
2174
2174
|
}
|
|
2175
2175
|
return e;
|
|
2176
2176
|
}
|
|
2177
|
-
function
|
|
2177
|
+
function Ve(r, e) {
|
|
2178
2178
|
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2179
2179
|
for (e += 3; e < r.length; e++)
|
|
2180
2180
|
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
@@ -2216,7 +2216,7 @@ function nr(r, e) {
|
|
|
2216
2216
|
};
|
|
2217
2217
|
}
|
|
2218
2218
|
const sr = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
2219
|
-
function
|
|
2219
|
+
function Le(r, e) {
|
|
2220
2220
|
const t = Ye(r, sr), s = {};
|
|
2221
2221
|
for (let n = 0; n < t.length; n++) {
|
|
2222
2222
|
if (t[n][1].length === 0)
|
|
@@ -2275,7 +2275,7 @@ function ar(r) {
|
|
|
2275
2275
|
function lr(r) {
|
|
2276
2276
|
return ye(r);
|
|
2277
2277
|
}
|
|
2278
|
-
function
|
|
2278
|
+
function Y(r, e) {
|
|
2279
2279
|
const t = r.substring(0, e).split(/\r?\n/);
|
|
2280
2280
|
return {
|
|
2281
2281
|
line: t.length,
|
|
@@ -2335,7 +2335,7 @@ const ur = {
|
|
|
2335
2335
|
};
|
|
2336
2336
|
let ge;
|
|
2337
2337
|
typeof Symbol != "function" ? ge = "@@xmlMetadata" : ge = Symbol("XML Node Metadata");
|
|
2338
|
-
let
|
|
2338
|
+
let oe = class {
|
|
2339
2339
|
constructor(e) {
|
|
2340
2340
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
2341
2341
|
}
|
|
@@ -2361,24 +2361,24 @@ class dr {
|
|
|
2361
2361
|
let n = 1, o = !1, i = !1, u = "";
|
|
2362
2362
|
for (; t < e.length; t++)
|
|
2363
2363
|
if (e[t] === "<" && !i) {
|
|
2364
|
-
if (o &&
|
|
2364
|
+
if (o && se(e, "!ENTITY", t)) {
|
|
2365
2365
|
t += 7;
|
|
2366
2366
|
let a, l;
|
|
2367
2367
|
[a, l, t] = this.readEntityExp(e, t + 1, this.suppressValidationErr), l.indexOf("&") === -1 && (s[a] = {
|
|
2368
2368
|
regx: RegExp(`&${a};`, "g"),
|
|
2369
2369
|
val: l
|
|
2370
2370
|
});
|
|
2371
|
-
} else if (o &&
|
|
2371
|
+
} else if (o && se(e, "!ELEMENT", t)) {
|
|
2372
2372
|
t += 8;
|
|
2373
2373
|
const { index: a } = this.readElementExp(e, t + 1);
|
|
2374
2374
|
t = a;
|
|
2375
|
-
} else if (o &&
|
|
2375
|
+
} else if (o && se(e, "!ATTLIST", t))
|
|
2376
2376
|
t += 8;
|
|
2377
|
-
else if (o &&
|
|
2377
|
+
else if (o && se(e, "!NOTATION", t)) {
|
|
2378
2378
|
t += 9;
|
|
2379
2379
|
const { index: a } = this.readNotationExp(e, t + 1, this.suppressValidationErr);
|
|
2380
2380
|
t = a;
|
|
2381
|
-
} else if (
|
|
2381
|
+
} else if (se(e, "!--", t)) i = !0;
|
|
2382
2382
|
else throw new Error("Invalid DOCTYPE");
|
|
2383
2383
|
n++, u = "";
|
|
2384
2384
|
} else if (e[t] === ">") {
|
|
@@ -2392,11 +2392,11 @@ class dr {
|
|
|
2392
2392
|
return { entities: s, i: t };
|
|
2393
2393
|
}
|
|
2394
2394
|
readEntityExp(e, t) {
|
|
2395
|
-
t =
|
|
2395
|
+
t = q(e, t);
|
|
2396
2396
|
let s = "";
|
|
2397
2397
|
for (; t < e.length && !/\s/.test(e[t]) && e[t] !== '"' && e[t] !== "'"; )
|
|
2398
2398
|
s += e[t], t++;
|
|
2399
|
-
if (fe(s), t =
|
|
2399
|
+
if (fe(s), t = q(e, t), !this.suppressValidationErr) {
|
|
2400
2400
|
if (e.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
2401
2401
|
throw new Error("External entities are not supported");
|
|
2402
2402
|
if (e[t] === "%")
|
|
@@ -2406,18 +2406,18 @@ class dr {
|
|
|
2406
2406
|
return [t, n] = this.readIdentifierVal(e, t, "entity"), t--, [s, n, t];
|
|
2407
2407
|
}
|
|
2408
2408
|
readNotationExp(e, t) {
|
|
2409
|
-
t =
|
|
2409
|
+
t = q(e, t);
|
|
2410
2410
|
let s = "";
|
|
2411
2411
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2412
2412
|
s += e[t], t++;
|
|
2413
|
-
!this.suppressValidationErr && fe(s), t =
|
|
2413
|
+
!this.suppressValidationErr && fe(s), t = q(e, t);
|
|
2414
2414
|
const n = e.substring(t, t + 6).toUpperCase();
|
|
2415
2415
|
if (!this.suppressValidationErr && n !== "SYSTEM" && n !== "PUBLIC")
|
|
2416
2416
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);
|
|
2417
|
-
t += n.length, t =
|
|
2417
|
+
t += n.length, t = q(e, t);
|
|
2418
2418
|
let o = null, i = null;
|
|
2419
2419
|
if (n === "PUBLIC")
|
|
2420
|
-
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t =
|
|
2420
|
+
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t = q(e, t), (e[t] === '"' || e[t] === "'") && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"));
|
|
2421
2421
|
else if (n === "SYSTEM" && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !i))
|
|
2422
2422
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
2423
2423
|
return { notationName: s, publicIdentifier: o, systemIdentifier: i, index: --t };
|
|
@@ -2434,16 +2434,16 @@ class dr {
|
|
|
2434
2434
|
return t++, [t, n];
|
|
2435
2435
|
}
|
|
2436
2436
|
readElementExp(e, t) {
|
|
2437
|
-
t =
|
|
2437
|
+
t = q(e, t);
|
|
2438
2438
|
let s = "";
|
|
2439
2439
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2440
2440
|
s += e[t], t++;
|
|
2441
2441
|
if (!this.suppressValidationErr && !ye(s))
|
|
2442
2442
|
throw new Error(`Invalid element name: "${s}"`);
|
|
2443
|
-
t =
|
|
2443
|
+
t = q(e, t);
|
|
2444
2444
|
let n = "";
|
|
2445
|
-
if (e[t] === "E" &&
|
|
2446
|
-
else if (e[t] === "A" &&
|
|
2445
|
+
if (e[t] === "E" && se(e, "MPTY", t)) t += 4;
|
|
2446
|
+
else if (e[t] === "A" && se(e, "NY", t)) t += 2;
|
|
2447
2447
|
else if (e[t] === "(") {
|
|
2448
2448
|
for (t++; t < e.length && e[t] !== ")"; )
|
|
2449
2449
|
n += e[t], t++;
|
|
@@ -2458,20 +2458,20 @@ class dr {
|
|
|
2458
2458
|
};
|
|
2459
2459
|
}
|
|
2460
2460
|
readAttlistExp(e, t) {
|
|
2461
|
-
t =
|
|
2461
|
+
t = q(e, t);
|
|
2462
2462
|
let s = "";
|
|
2463
2463
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2464
2464
|
s += e[t], t++;
|
|
2465
|
-
fe(s), t =
|
|
2465
|
+
fe(s), t = q(e, t);
|
|
2466
2466
|
let n = "";
|
|
2467
2467
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2468
2468
|
n += e[t], t++;
|
|
2469
2469
|
if (!fe(n))
|
|
2470
2470
|
throw new Error(`Invalid attribute name: "${n}"`);
|
|
2471
|
-
t =
|
|
2471
|
+
t = q(e, t);
|
|
2472
2472
|
let o = "";
|
|
2473
2473
|
if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
|
|
2474
|
-
if (o = "NOTATION", t += 8, t =
|
|
2474
|
+
if (o = "NOTATION", t += 8, t = q(e, t), e[t] !== "(")
|
|
2475
2475
|
throw new Error(`Expected '(', found "${e[t]}"`);
|
|
2476
2476
|
t++;
|
|
2477
2477
|
let u = [];
|
|
@@ -2481,7 +2481,7 @@ class dr {
|
|
|
2481
2481
|
a += e[t], t++;
|
|
2482
2482
|
if (a = a.trim(), !fe(a))
|
|
2483
2483
|
throw new Error(`Invalid notation name: "${a}"`);
|
|
2484
|
-
u.push(a), e[t] === "|" && (t++, t =
|
|
2484
|
+
u.push(a), e[t] === "|" && (t++, t = q(e, t));
|
|
2485
2485
|
}
|
|
2486
2486
|
if (e[t] !== ")")
|
|
2487
2487
|
throw new Error("Unterminated list of notations");
|
|
@@ -2493,7 +2493,7 @@ class dr {
|
|
|
2493
2493
|
if (!this.suppressValidationErr && !u.includes(o.toUpperCase()))
|
|
2494
2494
|
throw new Error(`Invalid attribute type: "${o}"`);
|
|
2495
2495
|
}
|
|
2496
|
-
t =
|
|
2496
|
+
t = q(e, t);
|
|
2497
2497
|
let i = "";
|
|
2498
2498
|
return e.substring(t, t + 8).toUpperCase() === "#REQUIRED" ? (i = "#REQUIRED", t += 8) : e.substring(t, t + 7).toUpperCase() === "#IMPLIED" ? (i = "#IMPLIED", t += 7) : [t, i] = this.readIdentifierVal(e, t, "ATTLIST"), {
|
|
2499
2499
|
elementName: s,
|
|
@@ -2504,12 +2504,12 @@ class dr {
|
|
|
2504
2504
|
};
|
|
2505
2505
|
}
|
|
2506
2506
|
}
|
|
2507
|
-
const
|
|
2507
|
+
const q = (r, e) => {
|
|
2508
2508
|
for (; e < r.length && /\s/.test(r[e]); )
|
|
2509
2509
|
e++;
|
|
2510
2510
|
return e;
|
|
2511
2511
|
};
|
|
2512
|
-
function
|
|
2512
|
+
function se(r, e, t) {
|
|
2513
2513
|
for (let s = 0; s < e.length; s++)
|
|
2514
2514
|
if (e[s] !== r[t + s + 1]) return !1;
|
|
2515
2515
|
return !0;
|
|
@@ -2535,7 +2535,7 @@ function gr(r, e = {}) {
|
|
|
2535
2535
|
if (e.hex && fr.test(t))
|
|
2536
2536
|
return Er(t, 16);
|
|
2537
2537
|
if (t.search(/.+[eE].+/) !== -1)
|
|
2538
|
-
return
|
|
2538
|
+
return br(r, t, e);
|
|
2539
2539
|
{
|
|
2540
2540
|
const s = hr.exec(t);
|
|
2541
2541
|
if (s) {
|
|
@@ -2561,10 +2561,10 @@ function gr(r, e = {}) {
|
|
|
2561
2561
|
return r;
|
|
2562
2562
|
}
|
|
2563
2563
|
}
|
|
2564
|
-
const
|
|
2565
|
-
function
|
|
2564
|
+
const mr = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
2565
|
+
function br(r, e, t) {
|
|
2566
2566
|
if (!t.eNotation) return r;
|
|
2567
|
-
const s = e.match(
|
|
2567
|
+
const s = e.match(mr);
|
|
2568
2568
|
if (s) {
|
|
2569
2569
|
let n = s[1] || "";
|
|
2570
2570
|
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2], u = n ? (
|
|
@@ -2675,13 +2675,13 @@ function wr(r, e, t) {
|
|
|
2675
2675
|
const Ar = function(r) {
|
|
2676
2676
|
r = r.replace(/\r\n?/g, `
|
|
2677
2677
|
`);
|
|
2678
|
-
const e = new
|
|
2678
|
+
const e = new oe("!xml");
|
|
2679
2679
|
let t = e, s = "", n = "";
|
|
2680
2680
|
const o = new dr(this.options.processEntities);
|
|
2681
2681
|
for (let i = 0; i < r.length; i++)
|
|
2682
2682
|
if (r[i] === "<")
|
|
2683
2683
|
if (r[i + 1] === "/") {
|
|
2684
|
-
const a =
|
|
2684
|
+
const a = ie(r, ">", i, "Closing Tag is not closed.");
|
|
2685
2685
|
let l = r.substring(i + 2, a).trim();
|
|
2686
2686
|
if (this.options.removeNSPrefix) {
|
|
2687
2687
|
const y = l.indexOf(":");
|
|
@@ -2697,12 +2697,12 @@ const Ar = function(r) {
|
|
|
2697
2697
|
let a = we(r, i, !1, "?>");
|
|
2698
2698
|
if (!a) throw new Error("Pi Tag is not closed.");
|
|
2699
2699
|
if (s = this.saveTextToParentTag(s, t, n), !(this.options.ignoreDeclaration && a.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
2700
|
-
const l = new
|
|
2700
|
+
const l = new oe(a.tagName);
|
|
2701
2701
|
l.add(this.options.textNodeName, ""), a.tagName !== a.tagExp && a.attrExpPresent && (l[":@"] = this.buildAttributesMap(a.tagExp, n, a.tagName)), this.addChild(t, l, n, i);
|
|
2702
2702
|
}
|
|
2703
2703
|
i = a.closeIndex + 1;
|
|
2704
2704
|
} else if (r.substr(i + 1, 3) === "!--") {
|
|
2705
|
-
const a =
|
|
2705
|
+
const a = ie(r, "-->", i + 4, "Comment is not closed.");
|
|
2706
2706
|
if (this.options.commentPropName) {
|
|
2707
2707
|
const l = r.substring(i + 4, a - 2);
|
|
2708
2708
|
s = this.saveTextToParentTag(s, t, n), t.add(this.options.commentPropName, [{ [this.options.textNodeName]: l }]);
|
|
@@ -2712,7 +2712,7 @@ const Ar = function(r) {
|
|
|
2712
2712
|
const a = o.readDocType(r, i);
|
|
2713
2713
|
this.docTypeEntities = a.entities, i = a.i;
|
|
2714
2714
|
} else if (r.substr(i + 1, 2) === "![") {
|
|
2715
|
-
const a =
|
|
2715
|
+
const a = ie(r, "]]>", i, "CDATA is not closed.") - 2, l = r.substring(i + 9, a);
|
|
2716
2716
|
s = this.saveTextToParentTag(s, t, n);
|
|
2717
2717
|
let h = this.parseTextData(l, t.tagname, n, !0, !1, !0, !0);
|
|
2718
2718
|
h == null && (h = ""), this.options.cdataPropName ? t.add(this.options.cdataPropName, [{ [this.options.textNodeName]: l }]) : t.add(this.options.textNodeName, h), i = a + 2;
|
|
@@ -2721,8 +2721,8 @@ const Ar = function(r) {
|
|
|
2721
2721
|
const h = a.rawTagName;
|
|
2722
2722
|
let f = a.tagExp, y = a.attrExpPresent, m = a.closeIndex;
|
|
2723
2723
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && s && t.tagname !== "!xml" && (s = this.saveTextToParentTag(s, t, n, !1));
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2724
|
+
const A = t;
|
|
2725
|
+
A && this.options.unpairedTags.indexOf(A.tagname) !== -1 && (t = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), l !== e.tagname && (n += n ? "." + l : l);
|
|
2726
2726
|
const O = i;
|
|
2727
2727
|
if (this.isItStopNode(this.options.stopNodes, n, l)) {
|
|
2728
2728
|
let P = "";
|
|
@@ -2731,19 +2731,19 @@ const Ar = function(r) {
|
|
|
2731
2731
|
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
2732
2732
|
i = a.closeIndex;
|
|
2733
2733
|
else {
|
|
2734
|
-
const
|
|
2735
|
-
if (!
|
|
2736
|
-
i =
|
|
2734
|
+
const Q = this.readStopNodeData(r, h, m + 1);
|
|
2735
|
+
if (!Q) throw new Error(`Unexpected end of ${h}`);
|
|
2736
|
+
i = Q.i, P = Q.tagContent;
|
|
2737
2737
|
}
|
|
2738
|
-
const M = new
|
|
2738
|
+
const M = new oe(l);
|
|
2739
2739
|
l !== f && y && (M[":@"] = this.buildAttributesMap(f, n, l)), P && (P = this.parseTextData(P, l, n, !0, y, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), M.add(this.options.textNodeName, P), this.addChild(t, M, n, O);
|
|
2740
2740
|
} else {
|
|
2741
2741
|
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1) {
|
|
2742
2742
|
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), n = n.substr(0, n.length - 1), f = l) : f = f.substr(0, f.length - 1), this.options.transformTagName && (l = this.options.transformTagName(l));
|
|
2743
|
-
const P = new
|
|
2743
|
+
const P = new oe(l);
|
|
2744
2744
|
l !== f && y && (P[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, P, n, O), n = n.substr(0, n.lastIndexOf("."));
|
|
2745
2745
|
} else {
|
|
2746
|
-
const P = new
|
|
2746
|
+
const P = new oe(l);
|
|
2747
2747
|
this.tagsNodeStack.push(t), l !== f && y && (P[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, P, n, O), t = P;
|
|
2748
2748
|
}
|
|
2749
2749
|
s = "", i = m;
|
|
@@ -2819,7 +2819,7 @@ function Sr(r, e, t = ">") {
|
|
|
2819
2819
|
n += i;
|
|
2820
2820
|
}
|
|
2821
2821
|
}
|
|
2822
|
-
function
|
|
2822
|
+
function ie(r, e, t, s) {
|
|
2823
2823
|
const n = r.indexOf(e, t);
|
|
2824
2824
|
if (n === -1)
|
|
2825
2825
|
throw new Error(s);
|
|
@@ -2851,7 +2851,7 @@ function Ir(r, e, t) {
|
|
|
2851
2851
|
for (; t < r.length; t++)
|
|
2852
2852
|
if (r[t] === "<")
|
|
2853
2853
|
if (r[t + 1] === "/") {
|
|
2854
|
-
const o =
|
|
2854
|
+
const o = ie(r, ">", t, `${e} is not closed`);
|
|
2855
2855
|
if (r.substring(t + 2, o).trim() === e && (n--, n === 0))
|
|
2856
2856
|
return {
|
|
2857
2857
|
tagContent: r.substring(s, t),
|
|
@@ -2859,11 +2859,11 @@ function Ir(r, e, t) {
|
|
|
2859
2859
|
};
|
|
2860
2860
|
t = o;
|
|
2861
2861
|
} else if (r[t + 1] === "?")
|
|
2862
|
-
t =
|
|
2862
|
+
t = ie(r, "?>", t + 1, "StopNode is not closed.");
|
|
2863
2863
|
else if (r.substr(t + 1, 3) === "!--")
|
|
2864
|
-
t =
|
|
2864
|
+
t = ie(r, "-->", t + 3, "StopNode is not closed.");
|
|
2865
2865
|
else if (r.substr(t + 1, 2) === "![")
|
|
2866
|
-
t =
|
|
2866
|
+
t = ie(r, "]]>", t, "StopNode is not closed.") - 2;
|
|
2867
2867
|
else {
|
|
2868
2868
|
const o = we(r, t, ">");
|
|
2869
2869
|
o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && n++, t = o.closeIndex);
|
|
@@ -2876,7 +2876,7 @@ function Ae(r, e, t) {
|
|
|
2876
2876
|
} else
|
|
2877
2877
|
return Jt(r) ? r : "";
|
|
2878
2878
|
}
|
|
2879
|
-
const Ne =
|
|
2879
|
+
const Ne = oe.getMetaDataSymbol();
|
|
2880
2880
|
function $r(r, e) {
|
|
2881
2881
|
return Ge(r, e);
|
|
2882
2882
|
}
|
|
@@ -2893,8 +2893,8 @@ function Ge(r, e, t) {
|
|
|
2893
2893
|
continue;
|
|
2894
2894
|
if (i[u]) {
|
|
2895
2895
|
let l = Ge(i[u], e, a);
|
|
2896
|
-
const h =
|
|
2897
|
-
i[Ne] !== void 0 && (l[Ne] = i[Ne]), i[":@"] ?
|
|
2896
|
+
const h = Lr(l, e);
|
|
2897
|
+
i[Ne] !== void 0 && (l[Ne] = i[Ne]), i[":@"] ? Vr(l, i[":@"], a, e) : Object.keys(l).length === 1 && l[e.textNodeName] !== void 0 && !e.alwaysCreateTextNode ? l = l[e.textNodeName] : Object.keys(l).length === 0 && (e.alwaysCreateTextNode ? l[e.textNodeName] = "" : l = ""), n[u] !== void 0 && n.hasOwnProperty(u) ? (Array.isArray(n[u]) || (n[u] = [n[u]]), n[u].push(l)) : e.isArray(u, a, h) ? n[u] = [l] : n[u] = l;
|
|
2898
2898
|
}
|
|
2899
2899
|
}
|
|
2900
2900
|
}
|
|
@@ -2907,7 +2907,7 @@ function Br(r) {
|
|
|
2907
2907
|
if (s !== ":@") return s;
|
|
2908
2908
|
}
|
|
2909
2909
|
}
|
|
2910
|
-
function
|
|
2910
|
+
function Vr(r, e, t, s) {
|
|
2911
2911
|
if (e) {
|
|
2912
2912
|
const n = Object.keys(e), o = n.length;
|
|
2913
2913
|
for (let i = 0; i < o; i++) {
|
|
@@ -2916,7 +2916,7 @@ function Lr(r, e, t, s) {
|
|
|
2916
2916
|
}
|
|
2917
2917
|
}
|
|
2918
2918
|
}
|
|
2919
|
-
function
|
|
2919
|
+
function Lr(r, e) {
|
|
2920
2920
|
const { textNodeName: t } = e, s = Object.keys(r).length;
|
|
2921
2921
|
return !!(s === 0 || s === 1 && (r[t] || typeof r[t] == "boolean" || r[t] === 0));
|
|
2922
2922
|
}
|
|
@@ -2970,7 +2970,7 @@ class Rr {
|
|
|
2970
2970
|
* is true in the options.
|
|
2971
2971
|
*/
|
|
2972
2972
|
static getMetaDataSymbol() {
|
|
2973
|
-
return
|
|
2973
|
+
return oe.getMetaDataSymbol();
|
|
2974
2974
|
}
|
|
2975
2975
|
}
|
|
2976
2976
|
const jr = `
|
|
@@ -2986,8 +2986,8 @@ function We(r, e, t, s) {
|
|
|
2986
2986
|
if (a === void 0) continue;
|
|
2987
2987
|
let l = "";
|
|
2988
2988
|
if (t.length === 0 ? l = a : l = `${t}.${a}`, a === e.textNodeName) {
|
|
2989
|
-
let
|
|
2990
|
-
Fr(l, e) || (
|
|
2989
|
+
let A = u[a];
|
|
2990
|
+
Fr(l, e) || (A = e.tagValueProcessor(a, A), A = Ze(A, e)), o && (n += s), n += A, o = !1;
|
|
2991
2991
|
continue;
|
|
2992
2992
|
} else if (a === e.cdataPropName) {
|
|
2993
2993
|
o && (n += s), n += `<![CDATA[${u[a][0][e.textNodeName]}]]>`, o = !1;
|
|
@@ -2996,9 +2996,9 @@ function We(r, e, t, s) {
|
|
|
2996
2996
|
n += s + `<!--${u[a][0][e.textNodeName]}-->`, o = !0;
|
|
2997
2997
|
continue;
|
|
2998
2998
|
} else if (a[0] === "?") {
|
|
2999
|
-
const
|
|
2999
|
+
const A = Re(u[":@"], e), O = a === "?xml" ? "" : s;
|
|
3000
3000
|
let P = u[a][0][e.textNodeName];
|
|
3001
|
-
P = P.length !== 0 ? " " + P : "", n += O + `<${a}${P}${
|
|
3001
|
+
P = P.length !== 0 ? " " + P : "", n += O + `<${a}${P}${A}?>`, o = !0;
|
|
3002
3002
|
continue;
|
|
3003
3003
|
}
|
|
3004
3004
|
let h = s;
|
|
@@ -3075,7 +3075,7 @@ const Xr = {
|
|
|
3075
3075
|
// transformAttributeName: false,
|
|
3076
3076
|
oneListGroup: !1
|
|
3077
3077
|
};
|
|
3078
|
-
function
|
|
3078
|
+
function ne(r) {
|
|
3079
3079
|
this.options = Object.assign({}, Xr, r), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
3080
3080
|
return !1;
|
|
3081
3081
|
} : (this.ignoreAttributesFn = Qe(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Yr), this.processTextOrObjNode = Hr, this.options.format ? (this.indentate = Kr, this.tagEndChar = `>
|
|
@@ -3084,12 +3084,12 @@ function re(r) {
|
|
|
3084
3084
|
return "";
|
|
3085
3085
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
3086
3086
|
}
|
|
3087
|
-
|
|
3087
|
+
ne.prototype.build = function(r) {
|
|
3088
3088
|
return this.options.preserveOrder ? Mr(r, this.options) : (Array.isArray(r) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (r = {
|
|
3089
3089
|
[this.options.arrayNodeName]: r
|
|
3090
3090
|
}), this.j2x(r, 0, []).val);
|
|
3091
3091
|
};
|
|
3092
|
-
|
|
3092
|
+
ne.prototype.j2x = function(r, e, t) {
|
|
3093
3093
|
let s = "", n = "";
|
|
3094
3094
|
const o = t.join(".");
|
|
3095
3095
|
for (let i in r)
|
|
@@ -3138,14 +3138,14 @@ re.prototype.j2x = function(r, e, t) {
|
|
|
3138
3138
|
n += this.processTextOrObjNode(r[i], i, e, t);
|
|
3139
3139
|
return { attrStr: s, val: n };
|
|
3140
3140
|
};
|
|
3141
|
-
|
|
3141
|
+
ne.prototype.buildAttrPairStr = function(r, e) {
|
|
3142
3142
|
return e = this.options.attributeValueProcessor(r, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + r : " " + r + '="' + e + '"';
|
|
3143
3143
|
};
|
|
3144
3144
|
function Hr(r, e, t, s) {
|
|
3145
3145
|
const n = this.j2x(r, t + 1, s.concat(e));
|
|
3146
3146
|
return r[this.options.textNodeName] !== void 0 && Object.keys(r).length === 1 ? this.buildTextValNode(r[this.options.textNodeName], e, n.attrStr, t) : this.buildObjectNode(n.val, e, n.attrStr, t);
|
|
3147
3147
|
}
|
|
3148
|
-
|
|
3148
|
+
ne.prototype.buildObjectNode = function(r, e, t, s) {
|
|
3149
3149
|
if (r === "")
|
|
3150
3150
|
return e[0] === "?" ? this.indentate(s) + "<" + e + t + "?" + this.tagEndChar : this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar;
|
|
3151
3151
|
{
|
|
@@ -3153,11 +3153,11 @@ re.prototype.buildObjectNode = function(r, e, t, s) {
|
|
|
3153
3153
|
return e[0] === "?" && (o = "?", n = ""), (t || t === "") && r.indexOf("<") === -1 ? this.indentate(s) + "<" + e + t + o + ">" + r + n : this.options.commentPropName !== !1 && e === this.options.commentPropName && o.length === 0 ? this.indentate(s) + `<!--${r}-->` + this.newLine : this.indentate(s) + "<" + e + t + o + this.tagEndChar + r + this.indentate(s) + n;
|
|
3154
3154
|
}
|
|
3155
3155
|
};
|
|
3156
|
-
|
|
3156
|
+
ne.prototype.closeTag = function(r) {
|
|
3157
3157
|
let e = "";
|
|
3158
3158
|
return this.options.unpairedTags.indexOf(r) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${r}`, e;
|
|
3159
3159
|
};
|
|
3160
|
-
|
|
3160
|
+
ne.prototype.buildTextValNode = function(r, e, t, s) {
|
|
3161
3161
|
if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
|
|
3162
3162
|
return this.indentate(s) + `<![CDATA[${r}]]>` + this.newLine;
|
|
3163
3163
|
if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
|
|
@@ -3169,7 +3169,7 @@ re.prototype.buildTextValNode = function(r, e, t, s) {
|
|
|
3169
3169
|
return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar : this.indentate(s) + "<" + e + t + ">" + n + "</" + e + this.tagEndChar;
|
|
3170
3170
|
}
|
|
3171
3171
|
};
|
|
3172
|
-
|
|
3172
|
+
ne.prototype.replaceEntitiesValue = function(r) {
|
|
3173
3173
|
if (r && r.length > 0 && this.options.processEntities)
|
|
3174
3174
|
for (let e = 0; e < this.options.entities.length; e++) {
|
|
3175
3175
|
const t = this.options.entities[e];
|
|
@@ -3260,7 +3260,7 @@ const qr = {
|
|
|
3260
3260
|
}
|
|
3261
3261
|
}, Te = (r, e) => {
|
|
3262
3262
|
try {
|
|
3263
|
-
let s = new
|
|
3263
|
+
let s = new ne({
|
|
3264
3264
|
...Gr,
|
|
3265
3265
|
format: e?.format ?? !0,
|
|
3266
3266
|
indentBy: e?.indentBy ?? " "
|
|
@@ -3308,7 +3308,7 @@ const qr = {
|
|
|
3308
3308
|
}, hn = {
|
|
3309
3309
|
key: 3,
|
|
3310
3310
|
class: "xml-node__cdata"
|
|
3311
|
-
}, pn = /* @__PURE__ */
|
|
3311
|
+
}, pn = /* @__PURE__ */ me({
|
|
3312
3312
|
__name: "XmlNode",
|
|
3313
3313
|
props: {
|
|
3314
3314
|
value: {},
|
|
@@ -3320,191 +3320,196 @@ const qr = {
|
|
|
3320
3320
|
},
|
|
3321
3321
|
emits: ["toggle-expand", "copy"],
|
|
3322
3322
|
setup(r, { emit: e }) {
|
|
3323
|
-
const t = r, s = e, n =
|
|
3323
|
+
const t = r, s = e, n = V(() => t.path || t.tagName), o = V(() => t.expanded.has(n.value)), i = V(() => t.tagName && !t.tagName.startsWith("#") && t.tagName !== "__cdata" ? !0 : t.value !== null && typeof t.value == "object"), u = V(() => !t.tagName && typeof t.value == "string"), a = V(() => t.tagName === "#comment"), l = V(() => t.tagName === "__cdata"), h = V(() => i.value ? Dr(t.value) : {}), f = V(() => typeof t.value == "string" ? t.value : i.value ? Jr(t.value) || "" : t.value || ""), y = V(() => t.value || ""), m = V(() => t.value || ""), A = V(() => {
|
|
3324
3324
|
if (typeof t.value != "object" || t.value === null)
|
|
3325
3325
|
return [];
|
|
3326
|
-
const
|
|
3326
|
+
const p = [];
|
|
3327
3327
|
return Object.keys(t.value).forEach((T) => {
|
|
3328
3328
|
if (T.startsWith("@_") || T === "#text") return;
|
|
3329
|
-
const
|
|
3330
|
-
Array.isArray(
|
|
3331
|
-
|
|
3332
|
-
}) :
|
|
3333
|
-
}),
|
|
3334
|
-
}), O =
|
|
3329
|
+
const j = t.value[T];
|
|
3330
|
+
Array.isArray(j) ? j.forEach((S) => {
|
|
3331
|
+
p.push({ tagName: T, value: S });
|
|
3332
|
+
}) : p.push({ tagName: T, value: j });
|
|
3333
|
+
}), p;
|
|
3334
|
+
}), O = V(() => A.value.length > 0 ? !0 : f.value.trim() !== ""), P = V(() => i.value && A.value.length === 0 && f.value.trim() !== ""), M = () => {
|
|
3335
3335
|
O.value && s("toggle-expand", n.value);
|
|
3336
|
-
},
|
|
3337
|
-
|
|
3338
|
-
|
|
3336
|
+
}, Q = (p, T) => {
|
|
3337
|
+
let j = 0;
|
|
3338
|
+
for (let S = 0; S < T; S++)
|
|
3339
|
+
A.value[S].tagName === p && j++;
|
|
3340
|
+
return `${n.value}.${p}[${j}]`;
|
|
3341
|
+
}, k = (p, T) => `${p.tagName}-${T}`;
|
|
3342
|
+
return (p, T) => {
|
|
3343
|
+
const j = Me("XmlNode", !0);
|
|
3339
3344
|
return x(), N("div", {
|
|
3340
3345
|
class: "xml-node",
|
|
3341
|
-
style: I({ paddingLeft:
|
|
3346
|
+
style: I({ paddingLeft: p.level > 0 ? "16px" : "0" })
|
|
3342
3347
|
}, [
|
|
3343
3348
|
i.value ? (x(), N("div", en, [
|
|
3344
3349
|
P.value ? (x(), N("div", tn, [
|
|
3345
3350
|
E("span", {
|
|
3346
3351
|
class: "xml-node__bracket",
|
|
3347
|
-
style: I({ color:
|
|
3352
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3348
3353
|
}, "<", 4),
|
|
3349
3354
|
E("span", {
|
|
3350
3355
|
class: "xml-node__tag",
|
|
3351
|
-
style: I({ color:
|
|
3352
|
-
}, R(
|
|
3353
|
-
(x(!0), N(he, null, pe(h.value, (
|
|
3354
|
-
key:
|
|
3356
|
+
style: I({ color: p.theme.colors.xmlTag })
|
|
3357
|
+
}, R(p.tagName), 5),
|
|
3358
|
+
(x(!0), N(he, null, pe(h.value, (S, X) => (x(), N("span", {
|
|
3359
|
+
key: X,
|
|
3355
3360
|
class: "xml-node__attribute"
|
|
3356
3361
|
}, [
|
|
3357
3362
|
E("span", {
|
|
3358
3363
|
class: "xml-node__attr-name",
|
|
3359
|
-
style: I({ color:
|
|
3360
|
-
}, R(
|
|
3364
|
+
style: I({ color: p.theme.colors.xmlAttribute })
|
|
3365
|
+
}, R(X), 5),
|
|
3361
3366
|
E("span", {
|
|
3362
3367
|
class: "xml-node__equals",
|
|
3363
|
-
style: I({ color:
|
|
3368
|
+
style: I({ color: p.theme.colors.xmlEquals })
|
|
3364
3369
|
}, "=", 4),
|
|
3365
3370
|
E("span", {
|
|
3366
3371
|
class: "xml-node__quote",
|
|
3367
|
-
style: I({ color:
|
|
3372
|
+
style: I({ color: p.theme.colors.xmlQuote })
|
|
3368
3373
|
}, '"', 4),
|
|
3369
3374
|
E("span", {
|
|
3370
3375
|
class: "xml-node__attr-value",
|
|
3371
|
-
style: I({ color:
|
|
3372
|
-
}, R(
|
|
3376
|
+
style: I({ color: p.theme.colors.xmlAttributeValue })
|
|
3377
|
+
}, R(S), 5),
|
|
3373
3378
|
E("span", {
|
|
3374
3379
|
class: "xml-node__quote",
|
|
3375
|
-
style: I({ color:
|
|
3380
|
+
style: I({ color: p.theme.colors.xmlQuote })
|
|
3376
3381
|
}, '"', 4)
|
|
3377
3382
|
]))), 128)),
|
|
3378
3383
|
E("span", {
|
|
3379
3384
|
class: "xml-node__bracket",
|
|
3380
|
-
style: I({ color:
|
|
3385
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3381
3386
|
}, ">", 4),
|
|
3382
3387
|
E("span", {
|
|
3383
3388
|
class: "xml-node__text-content",
|
|
3384
|
-
style: I({ color:
|
|
3389
|
+
style: I({ color: p.theme.colors.xmlText })
|
|
3385
3390
|
}, R(f.value), 5),
|
|
3386
3391
|
E("span", {
|
|
3387
3392
|
class: "xml-node__bracket",
|
|
3388
|
-
style: I({ color:
|
|
3393
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3389
3394
|
}, "</", 4),
|
|
3390
3395
|
E("span", {
|
|
3391
3396
|
class: "xml-node__tag",
|
|
3392
|
-
style: I({ color:
|
|
3393
|
-
}, R(
|
|
3397
|
+
style: I({ color: p.theme.colors.xmlTag })
|
|
3398
|
+
}, R(p.tagName), 5),
|
|
3394
3399
|
E("span", {
|
|
3395
3400
|
class: "xml-node__bracket",
|
|
3396
|
-
style: I({ color:
|
|
3401
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3397
3402
|
}, ">", 4)
|
|
3398
3403
|
])) : (x(), N("div", rn, [
|
|
3399
3404
|
E("div", nn, [
|
|
3400
3405
|
O.value ? (x(), N("span", {
|
|
3401
3406
|
key: 0,
|
|
3402
3407
|
class: "xml-node__clickable-part",
|
|
3403
|
-
onClick: T[0] || (T[0] = (
|
|
3408
|
+
onClick: T[0] || (T[0] = (S) => M()),
|
|
3404
3409
|
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3405
3410
|
}, [
|
|
3406
3411
|
E("span", {
|
|
3407
3412
|
class: "xml-node__bracket",
|
|
3408
|
-
style: I({ color:
|
|
3413
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3409
3414
|
}, "<", 4),
|
|
3410
3415
|
E("span", {
|
|
3411
3416
|
class: "xml-node__tag",
|
|
3412
|
-
style: I({ color:
|
|
3413
|
-
}, R(
|
|
3417
|
+
style: I({ color: p.theme.colors.xmlTag })
|
|
3418
|
+
}, R(p.tagName), 5)
|
|
3414
3419
|
], 8, sn)) : (x(), N("span", on, [
|
|
3415
3420
|
E("span", {
|
|
3416
3421
|
class: "xml-node__bracket",
|
|
3417
|
-
style: I({ color:
|
|
3422
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3418
3423
|
}, "<", 4),
|
|
3419
3424
|
E("span", {
|
|
3420
3425
|
class: "xml-node__tag",
|
|
3421
|
-
style: I({ color:
|
|
3422
|
-
}, R(
|
|
3426
|
+
style: I({ color: p.theme.colors.xmlTag })
|
|
3427
|
+
}, R(p.tagName), 5)
|
|
3423
3428
|
])),
|
|
3424
|
-
(x(!0), N(he, null, pe(h.value, (
|
|
3425
|
-
key:
|
|
3429
|
+
(x(!0), N(he, null, pe(h.value, (S, X) => (x(), N("span", {
|
|
3430
|
+
key: X,
|
|
3426
3431
|
class: "xml-node__attribute"
|
|
3427
3432
|
}, [
|
|
3428
3433
|
E("span", {
|
|
3429
3434
|
class: "xml-node__attr-name",
|
|
3430
|
-
style: I({ color:
|
|
3431
|
-
}, R(
|
|
3435
|
+
style: I({ color: p.theme.colors.xmlAttribute })
|
|
3436
|
+
}, R(X), 5),
|
|
3432
3437
|
E("span", {
|
|
3433
3438
|
class: "xml-node__equals",
|
|
3434
|
-
style: I({ color:
|
|
3439
|
+
style: I({ color: p.theme.colors.xmlEquals })
|
|
3435
3440
|
}, "=", 4),
|
|
3436
3441
|
E("span", {
|
|
3437
3442
|
class: "xml-node__quote",
|
|
3438
|
-
style: I({ color:
|
|
3443
|
+
style: I({ color: p.theme.colors.xmlQuote })
|
|
3439
3444
|
}, '"', 4),
|
|
3440
3445
|
E("span", {
|
|
3441
3446
|
class: "xml-node__attr-value",
|
|
3442
|
-
style: I({ color:
|
|
3443
|
-
}, R(
|
|
3447
|
+
style: I({ color: p.theme.colors.xmlAttributeValue })
|
|
3448
|
+
}, R(S), 5),
|
|
3444
3449
|
E("span", {
|
|
3445
3450
|
class: "xml-node__quote",
|
|
3446
|
-
style: I({ color:
|
|
3451
|
+
style: I({ color: p.theme.colors.xmlQuote })
|
|
3447
3452
|
}, '"', 4)
|
|
3448
3453
|
]))), 128)),
|
|
3449
3454
|
O.value ? (x(), N("span", {
|
|
3450
3455
|
key: 2,
|
|
3451
3456
|
class: "xml-node__clickable-part",
|
|
3452
|
-
onClick: T[1] || (T[1] = (
|
|
3457
|
+
onClick: T[1] || (T[1] = (S) => M()),
|
|
3453
3458
|
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3454
3459
|
}, [
|
|
3455
3460
|
E("span", {
|
|
3456
3461
|
class: "xml-node__bracket",
|
|
3457
|
-
style: I({ color:
|
|
3462
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3458
3463
|
}, ">", 4)
|
|
3459
3464
|
], 8, an)) : (x(), N("span", {
|
|
3460
3465
|
key: 3,
|
|
3461
3466
|
class: "xml-node__bracket",
|
|
3462
|
-
style: I({ color:
|
|
3467
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3463
3468
|
}, R(O.value ? ">" : "/>"), 5)),
|
|
3464
3469
|
!o.value && O.value ? (x(), N("span", {
|
|
3465
3470
|
key: 4,
|
|
3466
3471
|
class: "xml-node__collapsed xml-node__collapsed--clickable",
|
|
3467
|
-
style: I({ color:
|
|
3468
|
-
onClick: T[2] || (T[2] = (
|
|
3472
|
+
style: I({ color: p.theme.colors.textSecondary }),
|
|
3473
|
+
onClick: T[2] || (T[2] = (S) => M()),
|
|
3469
3474
|
title: "Click to expand"
|
|
3470
3475
|
}, "...", 4)) : F("", !0)
|
|
3471
3476
|
]),
|
|
3472
3477
|
o.value && O.value ? (x(), N("div", ln, [
|
|
3473
|
-
|
|
3478
|
+
A.value.length === 0 && f.value.trim() ? (x(), N("div", un, [
|
|
3474
3479
|
E("span", {
|
|
3475
3480
|
class: "xml-node__text-content",
|
|
3476
|
-
style: I({ color:
|
|
3481
|
+
style: I({ color: p.theme.colors.xmlText })
|
|
3477
3482
|
}, R(f.value), 5)
|
|
3478
3483
|
])) : F("", !0),
|
|
3479
|
-
(x(!0), N(he, null, pe(
|
|
3480
|
-
key: S
|
|
3481
|
-
value:
|
|
3482
|
-
"tag-name":
|
|
3483
|
-
level:
|
|
3484
|
-
path:
|
|
3485
|
-
expanded:
|
|
3486
|
-
theme:
|
|
3487
|
-
onToggleExpand: T[3] || (T[3] = (Z) =>
|
|
3488
|
-
onCopy: T[4] || (T[4] = (Z) =>
|
|
3484
|
+
(x(!0), N(he, null, pe(A.value, (S, X) => (x(), Xe(j, {
|
|
3485
|
+
key: k(S, X),
|
|
3486
|
+
value: S.value,
|
|
3487
|
+
"tag-name": S.tagName,
|
|
3488
|
+
level: p.level + 1,
|
|
3489
|
+
path: Q(S.tagName, X),
|
|
3490
|
+
expanded: p.expanded,
|
|
3491
|
+
theme: p.theme,
|
|
3492
|
+
onToggleExpand: T[3] || (T[3] = (Z) => p.$emit("toggle-expand", Z)),
|
|
3493
|
+
onCopy: T[4] || (T[4] = (Z) => p.$emit("copy", Z))
|
|
3489
3494
|
}, null, 8, ["value", "tag-name", "level", "path", "expanded", "theme"]))), 128))
|
|
3490
3495
|
])) : F("", !0),
|
|
3491
3496
|
o.value && O.value ? (x(), N("div", cn, [
|
|
3492
3497
|
E("span", {
|
|
3493
3498
|
class: "xml-node__clickable-part",
|
|
3494
|
-
onClick: T[5] || (T[5] = (
|
|
3499
|
+
onClick: T[5] || (T[5] = (S) => M()),
|
|
3495
3500
|
title: "Click to collapse"
|
|
3496
3501
|
}, [
|
|
3497
3502
|
E("span", {
|
|
3498
3503
|
class: "xml-node__bracket",
|
|
3499
|
-
style: I({ color:
|
|
3504
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3500
3505
|
}, "</", 4),
|
|
3501
3506
|
E("span", {
|
|
3502
3507
|
class: "xml-node__tag",
|
|
3503
|
-
style: I({ color:
|
|
3504
|
-
}, R(
|
|
3508
|
+
style: I({ color: p.theme.colors.xmlTag })
|
|
3509
|
+
}, R(p.tagName), 5),
|
|
3505
3510
|
E("span", {
|
|
3506
3511
|
class: "xml-node__bracket",
|
|
3507
|
-
style: I({ color:
|
|
3512
|
+
style: I({ color: p.theme.colors.xmlBracket })
|
|
3508
3513
|
}, ">", 4)
|
|
3509
3514
|
])
|
|
3510
3515
|
])) : F("", !0)
|
|
@@ -3512,21 +3517,21 @@ const qr = {
|
|
|
3512
3517
|
])) : u.value ? (x(), N("div", dn, [
|
|
3513
3518
|
E("span", {
|
|
3514
3519
|
class: "xml-node__text-content",
|
|
3515
|
-
style: I({ color:
|
|
3520
|
+
style: I({ color: p.theme.colors.xmlText })
|
|
3516
3521
|
}, R(f.value), 5)
|
|
3517
3522
|
])) : a.value ? (x(), N("div", fn, [
|
|
3518
3523
|
E("span", {
|
|
3519
|
-
style: I({ color:
|
|
3524
|
+
style: I({ color: p.theme.colors.xmlComment })
|
|
3520
3525
|
}, " <!-- " + R(y.value) + " --> ", 5)
|
|
3521
3526
|
])) : l.value ? (x(), N("div", hn, [
|
|
3522
3527
|
E("span", {
|
|
3523
|
-
style: I({ color:
|
|
3528
|
+
style: I({ color: p.theme.colors.xmlCdata })
|
|
3524
3529
|
}, " <![CDATA[" + R(m.value) + "]]> ", 5)
|
|
3525
3530
|
])) : F("", !0)
|
|
3526
3531
|
], 4);
|
|
3527
3532
|
};
|
|
3528
3533
|
}
|
|
3529
|
-
}), gn = /* @__PURE__ */
|
|
3534
|
+
}), gn = /* @__PURE__ */ be(pn, [["__scopeId", "data-v-c8f9132d"]]), mn = {
|
|
3530
3535
|
name: "github-light",
|
|
3531
3536
|
colors: {
|
|
3532
3537
|
// 背景色
|
|
@@ -3571,7 +3576,7 @@ const qr = {
|
|
|
3571
3576
|
xmlQuote: "#0550ae"
|
|
3572
3577
|
// 引号 - 蓝色
|
|
3573
3578
|
}
|
|
3574
|
-
},
|
|
3579
|
+
}, bn = {
|
|
3575
3580
|
name: "github-dark",
|
|
3576
3581
|
colors: {
|
|
3577
3582
|
// 背景色
|
|
@@ -3707,8 +3712,8 @@ const qr = {
|
|
|
3707
3712
|
// 引号 - 蓝色
|
|
3708
3713
|
}
|
|
3709
3714
|
}, je = {
|
|
3710
|
-
"github-light":
|
|
3711
|
-
"github-dark":
|
|
3715
|
+
"github-light": mn,
|
|
3716
|
+
"github-dark": bn,
|
|
3712
3717
|
"min-light": yn,
|
|
3713
3718
|
"slack-ochin": En
|
|
3714
3719
|
}, vn = (r) => je[r] || je["github-light"], _n = {
|
|
@@ -3726,7 +3731,7 @@ const qr = {
|
|
|
3726
3731
|
}, $n = {
|
|
3727
3732
|
key: 1,
|
|
3728
3733
|
class: "xml-format__viewer"
|
|
3729
|
-
}, Bn = /* @__PURE__ */
|
|
3734
|
+
}, Bn = /* @__PURE__ */ me({
|
|
3730
3735
|
__name: "index",
|
|
3731
3736
|
props: {
|
|
3732
3737
|
modelValue: { default: "" },
|
|
@@ -3739,174 +3744,188 @@ const qr = {
|
|
|
3739
3744
|
preserveWhitespace: { type: Boolean, default: !1 }
|
|
3740
3745
|
},
|
|
3741
3746
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
3742
|
-
setup(r, {
|
|
3747
|
+
setup(r, { expose: e, emit: t }) {
|
|
3743
3748
|
Ce((k) => ({
|
|
3744
|
-
"
|
|
3745
|
-
"
|
|
3746
|
-
|
|
3747
|
-
"
|
|
3748
|
-
"
|
|
3749
|
-
"
|
|
3750
|
-
"
|
|
3751
|
-
"
|
|
3752
|
-
|
|
3753
|
-
"
|
|
3754
|
-
"
|
|
3755
|
-
"
|
|
3756
|
-
"
|
|
3757
|
-
|
|
3749
|
+
"1b3a8c40": l.value.colors.border,
|
|
3750
|
+
"2ad7797c": l.value.colors.background,
|
|
3751
|
+
a00485b2: l.value.colors.surfaceBackground,
|
|
3752
|
+
"73ead9dc": l.value.colors.buttonBorder,
|
|
3753
|
+
"0d809114": l.value.colors.buttonBackground,
|
|
3754
|
+
"4f5ae593": l.value.colors.buttonText,
|
|
3755
|
+
"110456f0": l.value.colors.buttonBackgroundHover,
|
|
3756
|
+
"36fa6848": l.value.colors.buttonPrimary,
|
|
3757
|
+
ffcdd280: l.value.colors.buttonPrimaryHover,
|
|
3758
|
+
"4e6bab22": l.value.colors.success,
|
|
3759
|
+
"20315cfd": l.value.colors.successBackground,
|
|
3760
|
+
"74a96774": l.value.colors.error,
|
|
3761
|
+
"185fd7c2": l.value.colors.errorBackground,
|
|
3762
|
+
ae195b7e: l.value.colors.text
|
|
3758
3763
|
}));
|
|
3759
|
-
const
|
|
3760
|
-
if (!
|
|
3764
|
+
const s = r, n = t, o = G(null), i = G(""), u = G(/* @__PURE__ */ new Set()), a = V(() => i.value === ""), l = V(() => vn(s.theme)), h = V(() => {
|
|
3765
|
+
if (!o.value) return {};
|
|
3761
3766
|
const k = {};
|
|
3762
|
-
return Object.keys(
|
|
3763
|
-
!
|
|
3767
|
+
return Object.keys(o.value).forEach((p) => {
|
|
3768
|
+
!p.startsWith("?") && !p.startsWith("#") && (k[p] = o.value[p]);
|
|
3764
3769
|
}), k;
|
|
3765
|
-
}),
|
|
3770
|
+
}), f = (k) => {
|
|
3766
3771
|
if (!k || !k.trim()) {
|
|
3767
|
-
|
|
3772
|
+
i.value = "", o.value = null;
|
|
3768
3773
|
return;
|
|
3769
3774
|
}
|
|
3770
3775
|
try {
|
|
3771
|
-
const
|
|
3772
|
-
if (!
|
|
3773
|
-
|
|
3776
|
+
const p = Wr(k);
|
|
3777
|
+
if (!p.valid) {
|
|
3778
|
+
i.value = p.error || "Invalid XML", o.value = null;
|
|
3774
3779
|
return;
|
|
3775
3780
|
}
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
i.value.add(g);
|
|
3779
|
-
});
|
|
3781
|
+
o.value = ze(k), i.value = "", ce(() => {
|
|
3782
|
+
m();
|
|
3780
3783
|
});
|
|
3781
|
-
} catch (
|
|
3782
|
-
|
|
3784
|
+
} catch (p) {
|
|
3785
|
+
i.value = p instanceof Error ? p.message : "Unknown parse error", o.value = null;
|
|
3783
3786
|
}
|
|
3784
|
-
},
|
|
3785
|
-
|
|
3786
|
-
},
|
|
3787
|
-
const k = /* @__PURE__ */ new Set(),
|
|
3788
|
-
|
|
3789
|
-
if (
|
|
3790
|
-
const
|
|
3791
|
-
Array.isArray(
|
|
3792
|
-
const
|
|
3793
|
-
|
|
3794
|
-
}) :
|
|
3787
|
+
}, y = (k) => {
|
|
3788
|
+
u.value.has(k) ? u.value.delete(k) : u.value.add(k);
|
|
3789
|
+
}, m = () => {
|
|
3790
|
+
const k = /* @__PURE__ */ new Set(), p = (T, j = "") => {
|
|
3791
|
+
T !== null && typeof T == "object" && (j && k.add(j), Object.keys(T).forEach((S) => {
|
|
3792
|
+
if (S.startsWith("@_") || S === "#text") return;
|
|
3793
|
+
const X = T[S], Z = j ? `${j}.${S}[0]` : S;
|
|
3794
|
+
Array.isArray(X) ? X.forEach((ee, z) => {
|
|
3795
|
+
const te = j ? `${j}.${S}[${z}]` : `${S}[${z}]`;
|
|
3796
|
+
p(ee, te);
|
|
3797
|
+
}) : p(X, Z);
|
|
3795
3798
|
}));
|
|
3796
3799
|
};
|
|
3797
|
-
Object.keys(
|
|
3798
|
-
|
|
3799
|
-
}),
|
|
3800
|
-
},
|
|
3801
|
-
|
|
3802
|
-
},
|
|
3803
|
-
if (!(!
|
|
3800
|
+
Object.keys(h.value).forEach((T) => {
|
|
3801
|
+
p(h.value[T], T);
|
|
3802
|
+
}), u.value = k, n("expand-all");
|
|
3803
|
+
}, A = () => {
|
|
3804
|
+
u.value.clear(), n("collapse-all");
|
|
3805
|
+
}, O = async () => {
|
|
3806
|
+
if (!(!a.value || !o.value))
|
|
3804
3807
|
try {
|
|
3805
|
-
const k = Te(
|
|
3808
|
+
const k = Te(o.value, {
|
|
3806
3809
|
format: !0,
|
|
3807
3810
|
indentBy: " "
|
|
3808
3811
|
});
|
|
3809
|
-
await navigator.clipboard.writeText(k),
|
|
3812
|
+
await navigator.clipboard.writeText(k), n("copy-success", k);
|
|
3810
3813
|
} catch (k) {
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3814
|
+
const p = k instanceof Error ? k : new Error("Copy failed");
|
|
3815
|
+
n("copy-error", p), console.error("Failed to copy XML:", k);
|
|
3813
3816
|
}
|
|
3814
|
-
},
|
|
3815
|
-
if (!(!
|
|
3817
|
+
}, P = () => {
|
|
3818
|
+
if (!(!a.value || !o.value))
|
|
3816
3819
|
try {
|
|
3817
|
-
const k = Zr(
|
|
3818
|
-
|
|
3820
|
+
const k = Zr(o.value);
|
|
3821
|
+
n("update:modelValue", k), n("compress", k);
|
|
3819
3822
|
} catch (k) {
|
|
3820
3823
|
console.error("Failed to compress XML:", k);
|
|
3821
3824
|
}
|
|
3822
|
-
},
|
|
3823
|
-
if (
|
|
3825
|
+
}, M = () => {
|
|
3826
|
+
if (a.value)
|
|
3824
3827
|
try {
|
|
3825
|
-
const k = zr(
|
|
3828
|
+
const k = zr(s.modelValue, {
|
|
3826
3829
|
format: !0,
|
|
3827
3830
|
indentBy: " "
|
|
3828
3831
|
});
|
|
3829
|
-
|
|
3832
|
+
n("update:modelValue", k), n("format", k);
|
|
3830
3833
|
} catch (k) {
|
|
3831
3834
|
console.error("Failed to format XML:", k);
|
|
3832
3835
|
}
|
|
3833
|
-
},
|
|
3836
|
+
}, Q = async (k) => {
|
|
3834
3837
|
try {
|
|
3835
|
-
const
|
|
3836
|
-
await navigator.clipboard.writeText(
|
|
3837
|
-
} catch (
|
|
3838
|
-
const
|
|
3839
|
-
|
|
3838
|
+
const p = typeof k == "string" ? k : JSON.stringify(k, null, 2);
|
|
3839
|
+
await navigator.clipboard.writeText(p), n("copy-success", p);
|
|
3840
|
+
} catch (p) {
|
|
3841
|
+
const T = p instanceof Error ? p : new Error("Copy failed");
|
|
3842
|
+
n("copy-error", T), console.error("Failed to copy value:", p);
|
|
3840
3843
|
}
|
|
3841
3844
|
};
|
|
3842
|
-
return Fe(() =>
|
|
3843
|
-
|
|
3844
|
-
}, { immediate: !0 }), (
|
|
3845
|
-
|
|
3845
|
+
return Fe(() => s.modelValue, (k) => {
|
|
3846
|
+
f(k);
|
|
3847
|
+
}, { immediate: !0 }), e({
|
|
3848
|
+
// 核心操作方法
|
|
3849
|
+
copyXml: O,
|
|
3850
|
+
compressSource: P,
|
|
3851
|
+
formatSource: M,
|
|
3852
|
+
expandAll: m,
|
|
3853
|
+
collapseAll: A,
|
|
3854
|
+
toggleExpand: y,
|
|
3855
|
+
// 状态访问方法
|
|
3856
|
+
isValidXml: () => a.value,
|
|
3857
|
+
getParsedXml: () => o.value,
|
|
3858
|
+
getExpandedNodes: () => u.value,
|
|
3859
|
+
getParseError: () => i.value,
|
|
3860
|
+
// 工具方法
|
|
3861
|
+
parseXmlString: (k) => f(k),
|
|
3862
|
+
copyValue: (k) => Q(k)
|
|
3863
|
+
}), (k, p) => (x(), N("div", {
|
|
3864
|
+
class: Oe(["xml-format", `xml-format--${l.value.name}`])
|
|
3846
3865
|
}, [
|
|
3847
3866
|
k.showToolbar ? (x(), N("div", _n, [
|
|
3848
3867
|
E("div", xn, [
|
|
3849
3868
|
E("button", {
|
|
3850
3869
|
class: "xml-format__btn xml-format__btn--primary",
|
|
3851
|
-
onClick:
|
|
3852
|
-
disabled: !
|
|
3870
|
+
onClick: O,
|
|
3871
|
+
disabled: !a.value,
|
|
3853
3872
|
title: "Copy XML"
|
|
3854
3873
|
}, " 📋 Copy ", 8, Nn),
|
|
3855
3874
|
E("button", {
|
|
3856
3875
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3857
|
-
onClick:
|
|
3858
|
-
disabled: !
|
|
3876
|
+
onClick: m,
|
|
3877
|
+
disabled: !a.value,
|
|
3859
3878
|
title: "Expand All"
|
|
3860
3879
|
}, " ⬇️ Expand All ", 8, kn),
|
|
3861
3880
|
E("button", {
|
|
3862
3881
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3863
|
-
onClick:
|
|
3864
|
-
disabled: !
|
|
3882
|
+
onClick: A,
|
|
3883
|
+
disabled: !a.value,
|
|
3865
3884
|
title: "Collapse All"
|
|
3866
3885
|
}, " ➡️ Collapse All ", 8, wn),
|
|
3867
3886
|
E("button", {
|
|
3868
3887
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3869
|
-
onClick:
|
|
3870
|
-
disabled: !
|
|
3888
|
+
onClick: P,
|
|
3889
|
+
disabled: !a.value,
|
|
3871
3890
|
title: "Compress XML"
|
|
3872
3891
|
}, " 📦 Compress ", 8, An),
|
|
3873
3892
|
E("button", {
|
|
3874
3893
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3875
|
-
onClick:
|
|
3876
|
-
disabled: !
|
|
3894
|
+
onClick: M,
|
|
3895
|
+
disabled: !a.value,
|
|
3877
3896
|
title: "Format XML"
|
|
3878
3897
|
}, " ✨ Format ", 8, Cn)
|
|
3879
3898
|
]),
|
|
3880
3899
|
E("div", On, [
|
|
3881
|
-
|
|
3900
|
+
a.value ? (x(), N("span", Tn, " ✅ Valid XML ")) : (x(), N("span", Pn, " ❌ Invalid XML "))
|
|
3882
3901
|
])
|
|
3883
3902
|
])) : F("", !0),
|
|
3884
3903
|
E("div", Sn, [
|
|
3885
|
-
|
|
3886
|
-
(x(!0), N(he, null, pe(
|
|
3887
|
-
key: String(
|
|
3888
|
-
value:
|
|
3889
|
-
"tag-name": String(
|
|
3904
|
+
a.value ? (x(), N("div", $n, [
|
|
3905
|
+
(x(!0), N(he, null, pe(h.value, (T, j) => (x(), Xe(gn, {
|
|
3906
|
+
key: String(j),
|
|
3907
|
+
value: T,
|
|
3908
|
+
"tag-name": String(j),
|
|
3890
3909
|
level: 0,
|
|
3891
|
-
expanded:
|
|
3892
|
-
theme:
|
|
3893
|
-
onToggleExpand:
|
|
3894
|
-
onCopy:
|
|
3910
|
+
expanded: u.value,
|
|
3911
|
+
theme: l.value,
|
|
3912
|
+
onToggleExpand: y,
|
|
3913
|
+
onCopy: Q
|
|
3895
3914
|
}, null, 8, ["value", "tag-name", "expanded", "theme"]))), 128))
|
|
3896
3915
|
])) : (x(), N("div", In, [
|
|
3897
|
-
|
|
3898
|
-
E("pre", null, R(
|
|
3916
|
+
p[0] || (p[0] = E("h4", null, "XML Parse Error:", -1)),
|
|
3917
|
+
E("pre", null, R(i.value), 1)
|
|
3899
3918
|
]))
|
|
3900
3919
|
])
|
|
3901
3920
|
], 2));
|
|
3902
3921
|
}
|
|
3903
|
-
}), Un = /* @__PURE__ */
|
|
3904
|
-
|
|
3922
|
+
}), Un = /* @__PURE__ */ be(Bn, [["__scopeId", "data-v-c1cb61a7"]]), Vn = [Wt], Ln = (r) => {
|
|
3923
|
+
Vn.forEach((e) => {
|
|
3905
3924
|
const t = e.name || e.__name || "UnknownComponent";
|
|
3906
3925
|
r.component(t, e);
|
|
3907
3926
|
});
|
|
3908
3927
|
}, Fn = {
|
|
3909
|
-
install:
|
|
3928
|
+
install: Ln
|
|
3910
3929
|
};
|
|
3911
3930
|
export {
|
|
3912
3931
|
Wt as JsonFormat,
|