lone-format 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +1564 -1463
- package/dist/lone-format.umd.cjs +10 -9
- 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 ye, useCssVars as Oe, ref as z, computed as V, resolveComponent as Ue, createElementBlock as k, openBlock as x, createElementVNode as v, createCommentVNode as F, withDirectives as _e, toDisplayString as R, withKeys as ue, vModelText as xe, createTextVNode as Se, Fragment as de, renderList as fe, createVNode as Fe, normalizeClass as Te, nextTick as he, watch as Xe, normalizeStyle as P, createBlock as He } from "vue";
|
|
2
|
+
class Je {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -42,7 +42,7 @@ class De {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class et {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -615,10 +615,10 @@ class c {
|
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
618
|
+
const tt = new Je();
|
|
619
619
|
Object.assign(c, {
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
620
|
+
hooks: tt,
|
|
621
|
+
plugins: new et(c),
|
|
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(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 te = (r) => new c(r).parse(), rt = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(c).filter((r) => !
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(c).filter((r) => !rt.includes(r) && te[r] === void 0).forEach((r) => {
|
|
720
|
+
te[r] = c[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
var
|
|
722
|
+
te.Jsep = c;
|
|
723
|
+
const nt = "ConditionalExpression";
|
|
724
|
+
var st = {
|
|
725
725
|
name: "ternary",
|
|
726
726
|
init(r) {
|
|
727
727
|
r.hooks.add("after-expression", function(t) {
|
|
@@ -732,7 +732,7 @@ var nt = {
|
|
|
732
732
|
this.index++;
|
|
733
733
|
const o = this.gobbleExpression();
|
|
734
734
|
if (o || this.throwError("Expected expression"), t.node = {
|
|
735
|
-
type:
|
|
735
|
+
type: nt,
|
|
736
736
|
test: s,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: o
|
|
@@ -748,9 +748,9 @@ var nt = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
const Ie = 47,
|
|
753
|
-
var
|
|
751
|
+
te.plugins.register(st);
|
|
752
|
+
const Ie = 47, ot = 92;
|
|
753
|
+
var it = {
|
|
754
754
|
name: "regex",
|
|
755
755
|
init(r) {
|
|
756
756
|
r.hooks.add("gobble-token", function(t) {
|
|
@@ -780,34 +780,34 @@ var ot = {
|
|
|
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 === ot ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const Ne = 43, at = 45, ce = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [Ne, at],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
797
|
+
ce.assignmentOperators.forEach((s) => r.addBinaryOp(s, ce.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const o = this.code;
|
|
799
|
-
|
|
799
|
+
ce.updateOperators.some((i) => i === o && i === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, n.node = {
|
|
800
800
|
type: "UpdateExpression",
|
|
801
|
-
operator: o ===
|
|
801
|
+
operator: o === Ne ? "++" : "--",
|
|
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 o = this.code;
|
|
808
|
-
|
|
808
|
+
ce.updateOperators.some((i) => i === o && i === 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: o ===
|
|
810
|
+
operator: o === Ne ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -816,17 +816,17 @@ const xe = 43, it = 45, ue = {
|
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
818
|
function t(s) {
|
|
819
|
-
|
|
819
|
+
ce.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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const
|
|
825
|
+
te.plugins.register(it, ce);
|
|
826
|
+
te.addUnaryOp("typeof");
|
|
827
|
+
te.addLiteral("null", null);
|
|
828
|
+
te.addLiteral("undefined", void 0);
|
|
829
|
+
const lt = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), M = {
|
|
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 M.evalBinaryExpression(r, e);
|
|
839
839
|
case "Compound":
|
|
840
|
-
return
|
|
840
|
+
return M.evalCompound(r, e);
|
|
841
841
|
case "ConditionalExpression":
|
|
842
|
-
return
|
|
842
|
+
return M.evalConditionalExpression(r, e);
|
|
843
843
|
case "Identifier":
|
|
844
|
-
return
|
|
844
|
+
return M.evalIdentifier(r, e);
|
|
845
845
|
case "Literal":
|
|
846
|
-
return
|
|
846
|
+
return M.evalLiteral(r, e);
|
|
847
847
|
case "MemberExpression":
|
|
848
|
-
return
|
|
848
|
+
return M.evalMemberExpression(r, e);
|
|
849
849
|
case "UnaryExpression":
|
|
850
|
-
return
|
|
850
|
+
return M.evalUnaryExpression(r, e);
|
|
851
851
|
case "ArrayExpression":
|
|
852
|
-
return
|
|
852
|
+
return M.evalArrayExpression(r, e);
|
|
853
853
|
case "CallExpression":
|
|
854
|
-
return
|
|
854
|
+
return M.evalCallExpression(r, e);
|
|
855
855
|
case "AssignmentExpression":
|
|
856
|
-
return
|
|
856
|
+
return M.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](M.evalAst(r.left, e), () => M.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 = M.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
896
896
|
},
|
|
897
897
|
evalConditionalExpression(r, e) {
|
|
898
|
-
return
|
|
898
|
+
return M.evalAst(r.test, e) ? M.evalAst(r.consequent, e) : M.evalAst(r.alternate, e);
|
|
899
899
|
},
|
|
900
900
|
evalIdentifier(r, e) {
|
|
901
901
|
if (Object.hasOwn(e, r.name))
|
|
@@ -910,46 +910,46 @@ 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 ? M.evalAst(r.property) : r.property.name
|
|
914
914
|
// `object.property` property is Identifier
|
|
915
|
-
), s =
|
|
915
|
+
), s = M.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) && lt.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;
|
|
922
922
|
},
|
|
923
923
|
evalUnaryExpression(r, e) {
|
|
924
924
|
return {
|
|
925
|
-
"-": (s) => -
|
|
926
|
-
"!": (s) => !
|
|
927
|
-
"~": (s) => ~
|
|
925
|
+
"-": (s) => -M.evalAst(s, e),
|
|
926
|
+
"!": (s) => !M.evalAst(s, e),
|
|
927
|
+
"~": (s) => ~M.evalAst(s, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (s) => +
|
|
930
|
-
typeof: (s) => typeof
|
|
929
|
+
"+": (s) => +M.evalAst(s, e),
|
|
930
|
+
typeof: (s) => typeof M.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) => M.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) => M.evalAst(n, e));
|
|
938
|
+
return M.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 = M.evalAst(r.right, e);
|
|
944
944
|
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class ut {
|
|
948
948
|
/**
|
|
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 = te(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -958,16 +958,16 @@ class lt {
|
|
|
958
958
|
*/
|
|
959
959
|
runInNewContext(e) {
|
|
960
960
|
const t = Object.assign(/* @__PURE__ */ Object.create(null), e);
|
|
961
|
-
return
|
|
961
|
+
return M.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
964
|
function re(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function Ae(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class ct extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -975,10 +975,10 @@ class ut extends Error {
|
|
|
975
975
|
super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'), this.avoidNew = !0, this.value = e, this.name = "NewError";
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
|
-
function
|
|
979
|
-
if (!(this instanceof
|
|
978
|
+
function B(r, e, t, s, n) {
|
|
979
|
+
if (!(this instanceof B))
|
|
980
980
|
try {
|
|
981
|
-
return new
|
|
981
|
+
return new B(r, e, t, s, n);
|
|
982
982
|
} catch (i) {
|
|
983
983
|
if (!i.avoidNew)
|
|
984
984
|
throw i;
|
|
@@ -995,11 +995,11 @@ function $(r, e, t, s, n) {
|
|
|
995
995
|
o ? "json" in r && (i.json = r.json) : i.json = t;
|
|
996
996
|
const u = this.evaluate(i);
|
|
997
997
|
if (!u || typeof u != "object")
|
|
998
|
-
throw new
|
|
998
|
+
throw new ct(u);
|
|
999
999
|
return u;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
B.prototype.evaluate = function(r, e, t, s) {
|
|
1003
1003
|
let n = this.parent, o = this.parentProperty, {
|
|
1004
1004
|
flatten: i,
|
|
1005
1005
|
wrap: u
|
|
@@ -1013,44 +1013,44 @@ $.prototype.evaluate = function(r, e, t, s) {
|
|
|
1013
1013
|
json: e
|
|
1014
1014
|
} = r), i = Object.hasOwn(r, "flatten") ? r.flatten : i, this.currResultType = Object.hasOwn(r, "resultType") ? r.resultType : this.currResultType, this.currSandbox = Object.hasOwn(r, "sandbox") ? r.sandbox : this.currSandbox, u = Object.hasOwn(r, "wrap") ? r.wrap : u, this.currEval = Object.hasOwn(r, "eval") ? r.eval : this.currEval, t = Object.hasOwn(r, "callback") ? r.callback : t, this.currOtherTypeCallback = Object.hasOwn(r, "otherTypeCallback") ? r.otherTypeCallback : this.currOtherTypeCallback, n = Object.hasOwn(r, "parent") ? r.parent : n, o = Object.hasOwn(r, "parentProperty") ? r.parentProperty : o, r = r.path;
|
|
1015
1015
|
}
|
|
1016
|
-
if (n = n || null, o = o || null, Array.isArray(r) && (r =
|
|
1016
|
+
if (n = n || null, o = o || null, Array.isArray(r) && (r = B.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
|
-
const a =
|
|
1018
|
+
const a = B.toPathArray(r);
|
|
1019
1019
|
a[0] === "$" && a.length > 1 && a.shift(), this._hasParentSelector = null;
|
|
1020
1020
|
const l = this._trace(a, e, ["$"], n, o, t).filter(function(h) {
|
|
1021
1021
|
return h && !h.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
1023
|
return l.length ? !u && l.length === 1 && !l[0].hasArrExpr ? this._getPreferredOutput(l[0]) : l.reduce((h, f) => {
|
|
1024
|
-
const
|
|
1025
|
-
return i && Array.isArray(
|
|
1024
|
+
const b = this._getPreferredOutput(f);
|
|
1025
|
+
return i && Array.isArray(b) ? h = h.concat(b) : h.push(b), h;
|
|
1026
1026
|
}, []) : u ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
|
-
|
|
1028
|
+
B.prototype._getPreferredOutput = function(r) {
|
|
1029
1029
|
const e = this.currResultType;
|
|
1030
1030
|
switch (e) {
|
|
1031
1031
|
case "all": {
|
|
1032
|
-
const t = Array.isArray(r.path) ? r.path :
|
|
1033
|
-
return r.pointer =
|
|
1032
|
+
const t = Array.isArray(r.path) ? r.path : B.toPathArray(r.path);
|
|
1033
|
+
return r.pointer = B.toPointer(t), r.path = typeof r.path == "string" ? r.path : B.toPathString(r.path), r;
|
|
1034
1034
|
}
|
|
1035
1035
|
case "value":
|
|
1036
1036
|
case "parent":
|
|
1037
1037
|
case "parentProperty":
|
|
1038
1038
|
return r[e];
|
|
1039
1039
|
case "path":
|
|
1040
|
-
return
|
|
1040
|
+
return B.toPathString(r[e]);
|
|
1041
1041
|
case "pointer":
|
|
1042
|
-
return
|
|
1042
|
+
return B.toPointer(r.path);
|
|
1043
1043
|
default:
|
|
1044
1044
|
throw new TypeError("Unknown result type");
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
|
-
|
|
1047
|
+
B.prototype._handleCallback = function(r, e, t) {
|
|
1048
1048
|
if (e) {
|
|
1049
1049
|
const s = this._getPreferredOutput(r);
|
|
1050
|
-
r.path = typeof r.path == "string" ? r.path :
|
|
1050
|
+
r.path = typeof r.path == "string" ? r.path : B.toPathString(r.path), e(s, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1053
|
+
B.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
1054
1054
|
let a;
|
|
1055
1055
|
if (!r.length)
|
|
1056
1056
|
return a = {
|
|
@@ -1061,20 +1061,20 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1061
1061
|
hasArrExpr: i
|
|
1062
1062
|
}, this._handleCallback(a, o, "value"), a;
|
|
1063
1063
|
const l = r[0], h = r.slice(1), f = [];
|
|
1064
|
-
function
|
|
1065
|
-
Array.isArray(m) ? m.forEach((
|
|
1066
|
-
f.push(
|
|
1064
|
+
function b(m) {
|
|
1065
|
+
Array.isArray(m) ? m.forEach((w) => {
|
|
1066
|
+
f.push(w);
|
|
1067
1067
|
}) : f.push(m);
|
|
1068
1068
|
}
|
|
1069
1069
|
if ((typeof l != "string" || u) && e && Object.hasOwn(e, l))
|
|
1070
|
-
|
|
1070
|
+
b(this._trace(h, e[l], re(t, l), e, l, o, i));
|
|
1071
1071
|
else if (l === "*")
|
|
1072
1072
|
this._walk(e, (m) => {
|
|
1073
|
-
|
|
1073
|
+
b(this._trace(h, e[m], re(t, m), e, m, o, !0, !0));
|
|
1074
1074
|
});
|
|
1075
1075
|
else if (l === "..")
|
|
1076
|
-
|
|
1077
|
-
typeof e[m] == "object" &&
|
|
1076
|
+
b(this._trace(h, e, t, s, n, o, i)), this._walk(e, (m) => {
|
|
1077
|
+
typeof e[m] == "object" && b(this._trace(r.slice(), e[m], re(t, m), e, m, o, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
1080
|
if (l === "^")
|
|
@@ -1091,27 +1091,27 @@ $.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1091
1091
|
parentProperty: null
|
|
1092
1092
|
}, this._handleCallback(a, o, "property"), a;
|
|
1093
1093
|
if (l === "$")
|
|
1094
|
-
|
|
1094
|
+
b(this._trace(h, e, t, null, null, o, i));
|
|
1095
1095
|
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))
|
|
1096
|
-
|
|
1096
|
+
b(this._slice(l, h, e, t, s, n, o));
|
|
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
|
|
1103
|
-
this._trace(
|
|
1104
|
-
}) : this._walk(e, (
|
|
1105
|
-
this._eval(m, e[
|
|
1100
|
+
const m = l.replace(/^\?\((.*?)\)$/u, "$1"), w = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);
|
|
1101
|
+
w ? this._walk(e, (S) => {
|
|
1102
|
+
const _ = [w[2]], j = w[1] ? e[S][w[1]] : e[S];
|
|
1103
|
+
this._trace(_, j, t, s, n, o, !0).length > 0 && b(this._trace(h, e[S], re(t, S), e, S, o, !0));
|
|
1104
|
+
}) : this._walk(e, (S) => {
|
|
1105
|
+
this._eval(m, e[S], S, t, s, n) && b(this._trace(h, e[S], re(t, S), e, S, o, !0));
|
|
1106
1106
|
});
|
|
1107
1107
|
} else if (l[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
1109
1109
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1110
|
-
|
|
1110
|
+
b(this._trace(Ae(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 w = l.slice(1, -2);
|
|
1114
|
+
switch (w) {
|
|
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 === w && (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 === w && (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 " + w);
|
|
1148
1148
|
}
|
|
1149
1149
|
if (m)
|
|
1150
1150
|
return a = {
|
|
@@ -1155,30 +1155,30 @@ $.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
|
-
|
|
1158
|
+
b(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
|
-
|
|
1163
|
-
} else !u && e && Object.hasOwn(e, l) &&
|
|
1161
|
+
for (const w of m)
|
|
1162
|
+
b(this._trace(Ae(w, h), e, t, s, n, o, !0));
|
|
1163
|
+
} else !u && e && Object.hasOwn(e, l) && b(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
|
|
1170
|
-
if (Array.isArray(
|
|
1171
|
-
f[m] =
|
|
1172
|
-
const
|
|
1173
|
-
for (let
|
|
1174
|
-
m++, f.splice(m, 0,
|
|
1167
|
+
const w = f[m];
|
|
1168
|
+
if (w && w.isParentSelector) {
|
|
1169
|
+
const S = this._trace(w.expr, e, w.path, s, n, o, i);
|
|
1170
|
+
if (Array.isArray(S)) {
|
|
1171
|
+
f[m] = S[0];
|
|
1172
|
+
const _ = S.length;
|
|
1173
|
+
for (let j = 1; j < _; j++)
|
|
1174
|
+
m++, f.splice(m, 0, S[j]);
|
|
1175
1175
|
} else
|
|
1176
|
-
f[m] =
|
|
1176
|
+
f[m] = S;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
1179
|
return f;
|
|
1180
1180
|
};
|
|
1181
|
-
|
|
1181
|
+
B.prototype._walk = function(r, e) {
|
|
1182
1182
|
if (Array.isArray(r)) {
|
|
1183
1183
|
const t = r.length;
|
|
1184
1184
|
for (let s = 0; s < t; s++)
|
|
@@ -1187,67 +1187,67 @@ $.prototype._walk = function(r, e) {
|
|
|
1187
1187
|
e(t);
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
|
-
|
|
1190
|
+
B.prototype._slice = function(r, e, t, s, n, o, i) {
|
|
1191
1191
|
if (!Array.isArray(t))
|
|
1192
1192
|
return;
|
|
1193
1193
|
const u = t.length, a = r.split(":"), l = a[2] && Number.parseInt(a[2]) || 1;
|
|
1194
1194
|
let h = a[0] && Number.parseInt(a[0]) || 0, f = a[1] && Number.parseInt(a[1]) || u;
|
|
1195
1195
|
h = h < 0 ? Math.max(0, h + u) : Math.min(u, h), f = f < 0 ? Math.max(0, f + u) : Math.min(u, f);
|
|
1196
|
-
const
|
|
1196
|
+
const b = [];
|
|
1197
1197
|
for (let m = h; m < f; m += l)
|
|
1198
|
-
this._trace(
|
|
1199
|
-
|
|
1198
|
+
this._trace(Ae(m, e), t, s, n, o, i, !0).forEach((S) => {
|
|
1199
|
+
b.push(S);
|
|
1200
1200
|
});
|
|
1201
|
-
return
|
|
1201
|
+
return b;
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1203
|
+
B.prototype._eval = function(r, e, t, s, n, o) {
|
|
1204
1204
|
this.currSandbox._$_parentProperty = o, this.currSandbox._$_parent = n, this.currSandbox._$_property = t, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
|
|
1205
1205
|
const i = r.includes("@path");
|
|
1206
|
-
i && (this.currSandbox._$_path =
|
|
1206
|
+
i && (this.currSandbox._$_path = B.toPathString(s.concat([t])));
|
|
1207
1207
|
const u = this.currEval + "Script:" + r;
|
|
1208
|
-
if (
|
|
1208
|
+
if (!B.cache[u]) {
|
|
1209
1209
|
let a = r.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
1210
1210
|
if (i && (a = a.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
1211
|
-
|
|
1211
|
+
B.cache[u] = new this.safeVm.Script(a);
|
|
1212
1212
|
else if (this.currEval === "native")
|
|
1213
|
-
|
|
1213
|
+
B.cache[u] = new this.vm.Script(a);
|
|
1214
1214
|
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
1215
1215
|
const l = this.currEval;
|
|
1216
|
-
|
|
1216
|
+
B.cache[u] = new l(a);
|
|
1217
1217
|
} else if (typeof this.currEval == "function")
|
|
1218
|
-
|
|
1218
|
+
B.cache[u] = {
|
|
1219
1219
|
runInNewContext: (l) => this.currEval(a, l)
|
|
1220
1220
|
};
|
|
1221
1221
|
else
|
|
1222
1222
|
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
1223
1223
|
}
|
|
1224
1224
|
try {
|
|
1225
|
-
return
|
|
1225
|
+
return B.cache[u].runInNewContext(this.currSandbox);
|
|
1226
1226
|
} catch (a) {
|
|
1227
1227
|
if (this.ignoreEvalErrors)
|
|
1228
1228
|
return !1;
|
|
1229
1229
|
throw new Error("jsonPath: " + a.message + ": " + r);
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1232
|
+
B.cache = {};
|
|
1233
|
+
B.toPathString = function(r) {
|
|
1234
1234
|
const e = r, t = e.length;
|
|
1235
1235
|
let s = "$";
|
|
1236
1236
|
for (let n = 1; n < t; n++)
|
|
1237
1237
|
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (s += /^[0-9*]+$/u.test(e[n]) ? "[" + e[n] + "]" : "['" + e[n] + "']");
|
|
1238
1238
|
return s;
|
|
1239
1239
|
};
|
|
1240
|
-
|
|
1240
|
+
B.toPointer = function(r) {
|
|
1241
1241
|
const e = r, t = e.length;
|
|
1242
1242
|
let s = "";
|
|
1243
1243
|
for (let n = 1; n < t; n++)
|
|
1244
1244
|
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (s += "/" + e[n].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
|
|
1245
1245
|
return s;
|
|
1246
1246
|
};
|
|
1247
|
-
|
|
1247
|
+
B.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
1249
1249
|
cache: e
|
|
1250
|
-
} =
|
|
1250
|
+
} = B;
|
|
1251
1251
|
if (e[r])
|
|
1252
1252
|
return e[r].concat();
|
|
1253
1253
|
const t = [], n = r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(o, i) {
|
|
@@ -1262,17 +1262,17 @@ $.toPathArray = function(r) {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
|
-
|
|
1266
|
-
Script:
|
|
1265
|
+
B.prototype.safeVm = {
|
|
1266
|
+
Script: ut
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1268
|
+
const dt = function(r, e, t) {
|
|
1269
1269
|
const s = r.length;
|
|
1270
1270
|
for (let n = 0; n < s; n++) {
|
|
1271
1271
|
const o = r[n];
|
|
1272
1272
|
t(o) && e.push(r.splice(n--, 1)[0]);
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
|
-
class
|
|
1275
|
+
class ft {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1287,7 +1287,7 @@ class dt {
|
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
1289
|
const s = Object.keys(e), n = [];
|
|
1290
|
-
|
|
1290
|
+
dt(s, n, (l) => typeof e[l] == "function");
|
|
1291
1291
|
const o = s.map((l) => e[l]);
|
|
1292
1292
|
t = n.reduce((l, h) => {
|
|
1293
1293
|
let f = e[h].toString();
|
|
@@ -1297,37 +1297,37 @@ class dt {
|
|
|
1297
1297
|
return new Function(...s, a)(...o);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
|
|
1301
|
-
Script:
|
|
1300
|
+
B.prototype.vm = {
|
|
1301
|
+
Script: ft
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const ht = { class: "json-node" }, pt = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1306
|
+
}, gt = { class: "json-node__line" }, mt = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, yt = ["title"], bt = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
|
-
},
|
|
1312
|
+
}, vt = {
|
|
1313
1313
|
key: 4,
|
|
1314
1314
|
class: "json-node__comma"
|
|
1315
1315
|
}, Et = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__children"
|
|
1318
|
-
},
|
|
1318
|
+
}, _t = { class: "json-node__children-content" }, xt = { class: "json-node__line json-node__closing-bracket" }, Nt = { class: "json-node__bracket" }, kt = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
|
-
},
|
|
1321
|
+
}, At = {
|
|
1322
1322
|
key: 1,
|
|
1323
1323
|
class: "json-node__primitive"
|
|
1324
1324
|
}, wt = {
|
|
1325
1325
|
key: 2,
|
|
1326
1326
|
class: "json-node__colon"
|
|
1327
|
-
},
|
|
1327
|
+
}, Ct = ["title"], Ot = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
},
|
|
1330
|
+
}, Tt = /* @__PURE__ */ ye({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1341,180 +1341,180 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1341
1341
|
},
|
|
1342
1342
|
emits: ["update:value", "toggle-expand", "copy", "update:key"],
|
|
1343
1343
|
setup(r, { emit: e }) {
|
|
1344
|
-
|
|
1345
|
-
"7b112182":
|
|
1346
|
-
"1501a3a8":
|
|
1347
|
-
"4c2226b6":
|
|
1348
|
-
"30aa351e":
|
|
1349
|
-
"090e30f3":
|
|
1350
|
-
cf872bb0:
|
|
1351
|
-
e0803540:
|
|
1352
|
-
"3954b61e":
|
|
1353
|
-
e9972d44:
|
|
1354
|
-
"231c0282":
|
|
1355
|
-
e1dce7d8:
|
|
1344
|
+
Oe((y) => ({
|
|
1345
|
+
"7b112182": y.level,
|
|
1346
|
+
"1501a3a8": y.theme.colors.syntaxKey,
|
|
1347
|
+
"4c2226b6": y.theme.colors.hoverBackground,
|
|
1348
|
+
"30aa351e": y.theme.colors.syntaxBracket,
|
|
1349
|
+
"090e30f3": y.theme.colors.textSecondary,
|
|
1350
|
+
cf872bb0: y.theme.colors.syntaxString,
|
|
1351
|
+
e0803540: y.theme.colors.syntaxNumber,
|
|
1352
|
+
"3954b61e": y.theme.colors.syntaxBoolean,
|
|
1353
|
+
e9972d44: y.theme.colors.syntaxNull,
|
|
1354
|
+
"231c0282": y.theme.colors.background,
|
|
1355
|
+
e1dce7d8: y.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r, s = e, n =
|
|
1357
|
+
const t = r, s = e, n = z(!1), o = z(!1), i = z(""), u = z(""), a = (y) => y !== null && typeof y == "object" && !Array.isArray(y) && "__protected_number__" in y && Object.keys(y).length === 1, l = (y) => a(y) ? y.__protected_number__ : "", h = V(() => a(t.value) ? !1 : t.value !== null && typeof t.value == "object"), f = V(() => Array.isArray(t.value)), b = V(() => t.path ? t.path : t.keyName ? t.keyName : "root"), m = V(() => t.expanded.has(b.value)), w = V(() => t.keyName), S = V(() => f.value ? "[" : "{"), _ = V(() => f.value ? "]" : "}"), j = 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
|
-
}),
|
|
1362
|
-
const
|
|
1363
|
-
return t.value === null ? "json-node__value--null" :
|
|
1364
|
-
}),
|
|
1361
|
+
}), H = V(() => {
|
|
1362
|
+
const y = typeof t.value;
|
|
1363
|
+
return t.value === null ? "json-node__value--null" : y === "boolean" ? "json-node__value--boolean" : y === "number" || a(t.value) ? "json-node__value--number" : y === "string" ? "json-node__value--string" : "";
|
|
1364
|
+
}), p = 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)), $ = V(() => "Click to edit, double-click to copy"), E = (y) => t.level === 0 ? y : b.value ? `${b.value}.${y}` : y, O = (y) => {
|
|
1365
1365
|
const d = Object.keys(t.value);
|
|
1366
|
-
return d.indexOf(
|
|
1367
|
-
},
|
|
1368
|
-
s("toggle-expand",
|
|
1366
|
+
return d.indexOf(y) === d.length - 1;
|
|
1367
|
+
}, I = () => {
|
|
1368
|
+
s("toggle-expand", b.value);
|
|
1369
1369
|
}, X = () => {
|
|
1370
|
-
t.level !== 0 && (n.value = !0, i.value = t.keyName,
|
|
1371
|
-
const
|
|
1370
|
+
t.level !== 0 && (n.value = !0, i.value = t.keyName, he(() => {
|
|
1371
|
+
const y = document.querySelectorAll(".json-node__key-input"), d = y[y.length - 1];
|
|
1372
1372
|
d && (d.focus(), d.select());
|
|
1373
1373
|
}));
|
|
1374
1374
|
}, Z = () => {
|
|
1375
|
-
h.value || (o.value = !0, a(t.value) ? u.value = l(t.value) : typeof t.value == "string" ? u.value = t.value : u.value = String(t.value),
|
|
1376
|
-
const
|
|
1375
|
+
h.value || (o.value = !0, a(t.value) ? u.value = l(t.value) : typeof t.value == "string" ? u.value = t.value : u.value = String(t.value), he(() => {
|
|
1376
|
+
const y = document.querySelectorAll(".json-node__value-input"), d = y[y.length - 1];
|
|
1377
1377
|
d && (d.focus(), d.select());
|
|
1378
1378
|
}));
|
|
1379
|
-
},
|
|
1379
|
+
}, Y = () => {
|
|
1380
1380
|
if (t.level === 0 || !n.value) return;
|
|
1381
|
-
const
|
|
1382
|
-
if (!
|
|
1383
|
-
|
|
1381
|
+
const y = i.value.trim();
|
|
1382
|
+
if (!y) {
|
|
1383
|
+
ee();
|
|
1384
1384
|
return;
|
|
1385
1385
|
}
|
|
1386
|
-
if (
|
|
1386
|
+
if (y === t.keyName) {
|
|
1387
1387
|
n.value = !1;
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
|
-
n.value = !1, s("update:key",
|
|
1391
|
-
},
|
|
1390
|
+
n.value = !1, s("update:key", b.value, y);
|
|
1391
|
+
}, Q = () => {
|
|
1392
1392
|
try {
|
|
1393
|
-
let
|
|
1393
|
+
let y;
|
|
1394
1394
|
const d = u.value.trim();
|
|
1395
1395
|
if (d === "null")
|
|
1396
|
-
|
|
1396
|
+
y = null;
|
|
1397
1397
|
else if (d === "true" || d === "false")
|
|
1398
|
-
|
|
1398
|
+
y = d === "true";
|
|
1399
1399
|
else if (!isNaN(Number(d)) && d !== "") {
|
|
1400
1400
|
const g = Number(d);
|
|
1401
|
-
!Number.isSafeInteger(g) || d.length > 15 ?
|
|
1401
|
+
!Number.isSafeInteger(g) || d.length > 15 ? y = { __protected_number__: d } : y = g;
|
|
1402
1402
|
} else
|
|
1403
|
-
|
|
1404
|
-
s("update:value",
|
|
1405
|
-
} catch (
|
|
1406
|
-
console.error("Failed to parse value:",
|
|
1403
|
+
y = u.value;
|
|
1404
|
+
s("update:value", b.value, y), o.value = !1;
|
|
1405
|
+
} catch (y) {
|
|
1406
|
+
console.error("Failed to parse value:", y), o.value = !1;
|
|
1407
1407
|
}
|
|
1408
|
-
},
|
|
1408
|
+
}, ee = () => {
|
|
1409
1409
|
n.value = !1, i.value = t.keyName;
|
|
1410
|
-
},
|
|
1410
|
+
}, ae = () => {
|
|
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
|
-
return (
|
|
1414
|
-
const g =
|
|
1415
|
-
return x(),
|
|
1416
|
-
h.value ? (x(),
|
|
1417
|
-
|
|
1418
|
-
|
|
1413
|
+
return (y, d) => {
|
|
1414
|
+
const g = Ue("JsonNode", !0);
|
|
1415
|
+
return x(), k("div", ht, [
|
|
1416
|
+
h.value ? (x(), k("div", pt, [
|
|
1417
|
+
v("div", gt, [
|
|
1418
|
+
y.keyName && !n.value ? (x(), k("span", {
|
|
1419
1419
|
key: 0,
|
|
1420
1420
|
class: "json-node__key",
|
|
1421
1421
|
onClick: X,
|
|
1422
1422
|
title: "Click to edit key"
|
|
1423
|
-
}, ' "' + R(
|
|
1424
|
-
|
|
1423
|
+
}, ' "' + R(w.value) + '" ', 1)) : F("", !0),
|
|
1424
|
+
y.keyName && n.value ? _e((x(), k("input", {
|
|
1425
1425
|
key: 1,
|
|
1426
|
-
"onUpdate:modelValue": d[0] || (d[0] = (
|
|
1426
|
+
"onUpdate:modelValue": d[0] || (d[0] = (A) => i.value = A),
|
|
1427
1427
|
onKeyup: [
|
|
1428
|
-
|
|
1429
|
-
|
|
1428
|
+
ue(Y, ["enter"]),
|
|
1429
|
+
ue(ee, ["escape"])
|
|
1430
1430
|
],
|
|
1431
|
-
onBlur:
|
|
1431
|
+
onBlur: Y,
|
|
1432
1432
|
class: "json-node__key-input"
|
|
1433
1433
|
}, null, 544)), [
|
|
1434
|
-
[
|
|
1434
|
+
[xe, i.value]
|
|
1435
1435
|
]) : F("", !0),
|
|
1436
|
-
|
|
1437
|
-
|
|
1436
|
+
y.keyName ? (x(), k("span", mt, ": ")) : F("", !0),
|
|
1437
|
+
v("span", {
|
|
1438
1438
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1439
|
-
onClick:
|
|
1439
|
+
onClick: I,
|
|
1440
1440
|
title: m.value ? "Click to collapse" : "Click to expand"
|
|
1441
|
-
}, R(
|
|
1442
|
-
m.value ? F("", !0) : (x(),
|
|
1443
|
-
Se(R(
|
|
1444
|
-
|
|
1441
|
+
}, R(S.value), 9, yt),
|
|
1442
|
+
m.value ? F("", !0) : (x(), k("span", bt, [
|
|
1443
|
+
Se(R(j.value) + " ", 1),
|
|
1444
|
+
v("span", {
|
|
1445
1445
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1446
|
-
onClick:
|
|
1447
|
-
}, R(
|
|
1446
|
+
onClick: I
|
|
1447
|
+
}, R(_.value), 1)
|
|
1448
1448
|
])),
|
|
1449
|
-
!m.value && !
|
|
1449
|
+
!m.value && !y.isLast ? (x(), k("span", vt, ",")) : F("", !0)
|
|
1450
1450
|
]),
|
|
1451
|
-
m.value ? (x(),
|
|
1452
|
-
|
|
1453
|
-
(x(!0),
|
|
1454
|
-
key:
|
|
1451
|
+
m.value ? (x(), k("div", Et, [
|
|
1452
|
+
v("div", _t, [
|
|
1453
|
+
(x(!0), k(de, null, fe(y.value, (A, N) => (x(), k("div", {
|
|
1454
|
+
key: N,
|
|
1455
1455
|
class: "json-node__child"
|
|
1456
1456
|
}, [
|
|
1457
|
-
|
|
1458
|
-
value:
|
|
1459
|
-
"key-name": f.value ? "" : String(
|
|
1460
|
-
level:
|
|
1461
|
-
path:
|
|
1462
|
-
expanded:
|
|
1463
|
-
theme:
|
|
1464
|
-
"onUpdate:value": d[1] || (d[1] = (
|
|
1465
|
-
onToggleExpand: d[2] || (d[2] = (
|
|
1466
|
-
onCopy: d[3] || (d[3] = (
|
|
1467
|
-
"onUpdate:key": d[4] || (d[4] = (
|
|
1468
|
-
"is-last":
|
|
1457
|
+
Fe(g, {
|
|
1458
|
+
value: A,
|
|
1459
|
+
"key-name": f.value ? "" : String(N),
|
|
1460
|
+
level: y.level + 1,
|
|
1461
|
+
path: E(String(N)),
|
|
1462
|
+
expanded: y.expanded,
|
|
1463
|
+
theme: y.theme,
|
|
1464
|
+
"onUpdate:value": d[1] || (d[1] = (C, T) => y.$emit("update:value", C, T)),
|
|
1465
|
+
onToggleExpand: d[2] || (d[2] = (C) => y.$emit("toggle-expand", C)),
|
|
1466
|
+
onCopy: d[3] || (d[3] = (C) => y.$emit("copy", C)),
|
|
1467
|
+
"onUpdate:key": d[4] || (d[4] = (C, T) => y.$emit("update:key", C, T)),
|
|
1468
|
+
"is-last": O(String(N))
|
|
1469
1469
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1470
1470
|
]))), 128))
|
|
1471
1471
|
]),
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1472
|
+
v("div", xt, [
|
|
1473
|
+
v("span", Nt, R(_.value), 1),
|
|
1474
|
+
y.isLast ? F("", !0) : (x(), k("span", kt, ","))
|
|
1475
1475
|
])
|
|
1476
1476
|
])) : F("", !0)
|
|
1477
|
-
])) : (x(),
|
|
1478
|
-
|
|
1477
|
+
])) : (x(), k("div", At, [
|
|
1478
|
+
y.keyName && !n.value ? (x(), k("span", {
|
|
1479
1479
|
key: 0,
|
|
1480
1480
|
class: "json-node__key",
|
|
1481
1481
|
onClick: X,
|
|
1482
1482
|
title: "Click to edit key"
|
|
1483
|
-
}, ' "' + R(
|
|
1484
|
-
|
|
1483
|
+
}, ' "' + R(w.value) + '" ', 1)) : F("", !0),
|
|
1484
|
+
y.keyName && n.value ? _e((x(), k("input", {
|
|
1485
1485
|
key: 1,
|
|
1486
|
-
"onUpdate:modelValue": d[5] || (d[5] = (
|
|
1486
|
+
"onUpdate:modelValue": d[5] || (d[5] = (A) => i.value = A),
|
|
1487
1487
|
onKeyup: [
|
|
1488
|
-
|
|
1489
|
-
|
|
1488
|
+
ue(Y, ["enter"]),
|
|
1489
|
+
ue(ee, ["escape"])
|
|
1490
1490
|
],
|
|
1491
|
-
onBlur:
|
|
1491
|
+
onBlur: Y,
|
|
1492
1492
|
class: "json-node__key-input"
|
|
1493
1493
|
}, null, 544)), [
|
|
1494
|
-
[
|
|
1494
|
+
[xe, i.value]
|
|
1495
1495
|
]) : F("", !0),
|
|
1496
|
-
|
|
1497
|
-
o.value ? F("", !0) : (x(),
|
|
1496
|
+
y.keyName ? (x(), k("span", wt, ": ")) : F("", !0),
|
|
1497
|
+
o.value ? F("", !0) : (x(), k("span", {
|
|
1498
1498
|
key: 3,
|
|
1499
|
-
class:
|
|
1499
|
+
class: Te(["json-node__value", H.value]),
|
|
1500
1500
|
onClick: Z,
|
|
1501
|
-
onDblclick: d[6] || (d[6] = (
|
|
1502
|
-
title:
|
|
1501
|
+
onDblclick: d[6] || (d[6] = (A) => y.$emit("copy", y.value)),
|
|
1502
|
+
title: $.value
|
|
1503
1503
|
}, [
|
|
1504
|
-
Se(R(
|
|
1505
|
-
|
|
1506
|
-
], 42,
|
|
1507
|
-
o.value ?
|
|
1504
|
+
Se(R(p.value), 1),
|
|
1505
|
+
y.isLast ? F("", !0) : (x(), k("span", Ot, ","))
|
|
1506
|
+
], 42, Ct)),
|
|
1507
|
+
o.value ? _e((x(), k("input", {
|
|
1508
1508
|
key: 4,
|
|
1509
|
-
"onUpdate:modelValue": d[7] || (d[7] = (
|
|
1509
|
+
"onUpdate:modelValue": d[7] || (d[7] = (A) => u.value = A),
|
|
1510
1510
|
onKeyup: [
|
|
1511
|
-
|
|
1512
|
-
|
|
1511
|
+
ue(Q, ["enter"]),
|
|
1512
|
+
ue(ae, ["escape"])
|
|
1513
1513
|
],
|
|
1514
|
-
onBlur:
|
|
1514
|
+
onBlur: Q,
|
|
1515
1515
|
class: "json-node__value-input"
|
|
1516
1516
|
}, null, 544)), [
|
|
1517
|
-
[
|
|
1517
|
+
[xe, u.value]
|
|
1518
1518
|
]) : F("", !0)
|
|
1519
1519
|
]))
|
|
1520
1520
|
]);
|
|
@@ -1525,7 +1525,7 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1525
1525
|
for (const [s, n] of e)
|
|
1526
1526
|
t[s] = n;
|
|
1527
1527
|
return t;
|
|
1528
|
-
},
|
|
1528
|
+
}, Pt = /* @__PURE__ */ be(Tt, [["__scopeId", "data-v-860beb35"]]), Ke = {
|
|
1529
1529
|
name: "github-light",
|
|
1530
1530
|
colors: {
|
|
1531
1531
|
// 背景色
|
|
@@ -1564,7 +1564,7 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1564
1564
|
// 缩进线
|
|
1565
1565
|
indentLine: "#d0d7de"
|
|
1566
1566
|
}
|
|
1567
|
-
},
|
|
1567
|
+
}, $t = {
|
|
1568
1568
|
name: "github-dark",
|
|
1569
1569
|
colors: {
|
|
1570
1570
|
// 背景色
|
|
@@ -1681,34 +1681,34 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1681
1681
|
// 缩进线
|
|
1682
1682
|
indentLine: "#e8d5b7"
|
|
1683
1683
|
}
|
|
1684
|
-
},
|
|
1685
|
-
"github-light":
|
|
1686
|
-
"github-dark":
|
|
1684
|
+
}, Bt = {
|
|
1685
|
+
"github-light": Ke,
|
|
1686
|
+
"github-dark": $t,
|
|
1687
1687
|
"min-light": St,
|
|
1688
1688
|
"slack-ochin": It
|
|
1689
1689
|
};
|
|
1690
|
-
function
|
|
1691
|
-
return
|
|
1690
|
+
function Vt(r = "github-light") {
|
|
1691
|
+
return Bt[r] || Ke;
|
|
1692
1692
|
}
|
|
1693
|
-
const
|
|
1693
|
+
const Lt = {
|
|
1694
1694
|
key: 0,
|
|
1695
1695
|
class: "json-format__toolbar"
|
|
1696
|
-
},
|
|
1696
|
+
}, Rt = { class: "json-format__actions" }, jt = ["disabled"], Mt = ["disabled"], Ut = ["disabled"], Ft = ["disabled"], Xt = { class: "json-format__info" }, Ht = {
|
|
1697
1697
|
key: 0,
|
|
1698
1698
|
class: "json-format__status json-format__status--success"
|
|
1699
|
-
},
|
|
1699
|
+
}, Kt = {
|
|
1700
1700
|
key: 1,
|
|
1701
1701
|
class: "json-format__status json-format__status--error"
|
|
1702
|
-
},
|
|
1702
|
+
}, qt = { class: "json-format__content" }, Yt = {
|
|
1703
1703
|
key: 0,
|
|
1704
1704
|
class: "json-format__error"
|
|
1705
|
-
},
|
|
1705
|
+
}, Qt = {
|
|
1706
1706
|
key: 1,
|
|
1707
1707
|
class: "json-format__error"
|
|
1708
|
-
},
|
|
1708
|
+
}, Wt = {
|
|
1709
1709
|
key: 2,
|
|
1710
1710
|
class: "json-format__viewer"
|
|
1711
|
-
}, Gt = /* @__PURE__ */
|
|
1711
|
+
}, Gt = /* @__PURE__ */ ye({
|
|
1712
1712
|
name: "JsonFormat",
|
|
1713
1713
|
__name: "index",
|
|
1714
1714
|
props: {
|
|
@@ -1720,7 +1720,7 @@ const Vt = {
|
|
|
1720
1720
|
},
|
|
1721
1721
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1722
1722
|
setup(r, { expose: e, emit: t }) {
|
|
1723
|
-
|
|
1723
|
+
Oe((d) => ({
|
|
1724
1724
|
"50e4672c": f.value.colors.border,
|
|
1725
1725
|
"64d14328": f.value.colors.background,
|
|
1726
1726
|
"668c94eb": f.value.colors.text,
|
|
@@ -1739,54 +1739,54 @@ const Vt = {
|
|
|
1739
1739
|
"2c1c44e4": f.value.colors.scrollbarThumb,
|
|
1740
1740
|
"8ba97764": f.value.colors.scrollbarThumbHover
|
|
1741
1741
|
}));
|
|
1742
|
-
const s = r, n = t, o =
|
|
1742
|
+
const s = r, n = t, o = z(null), i = z(""), u = z(/* @__PURE__ */ new Set()), a = z(null), l = z(""), h = V(() => i.value === ""), f = V(() => Vt(s.theme)), b = 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
1748
|
let g = d;
|
|
1749
|
-
const
|
|
1750
|
-
if (!
|
|
1749
|
+
const A = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(g), N = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(g);
|
|
1750
|
+
if (!A && !N)
|
|
1751
1751
|
try {
|
|
1752
|
-
o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "",
|
|
1753
|
-
|
|
1752
|
+
o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", he(() => {
|
|
1753
|
+
b.value !== null && $();
|
|
1754
1754
|
});
|
|
1755
1755
|
return;
|
|
1756
1756
|
} catch {
|
|
1757
1757
|
}
|
|
1758
|
-
g = ((
|
|
1759
|
-
let
|
|
1760
|
-
for (;
|
|
1761
|
-
const
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
else if (
|
|
1765
|
-
|
|
1758
|
+
g = ((T) => {
|
|
1759
|
+
let L = "", K = !1, q = !1, J = 0;
|
|
1760
|
+
for (; J < T.length; ) {
|
|
1761
|
+
const le = T[J];
|
|
1762
|
+
if (K)
|
|
1763
|
+
q ? q = !1 : le === "\\" ? q = !0 : le === '"' && (K = !1), L += le, J++;
|
|
1764
|
+
else if (le === '"')
|
|
1765
|
+
K = !0, L += le, J++;
|
|
1766
1766
|
else {
|
|
1767
|
-
const
|
|
1768
|
-
let
|
|
1769
|
-
if (
|
|
1770
|
-
|
|
1767
|
+
const $e = T.slice(J);
|
|
1768
|
+
let D = $e.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1769
|
+
if (D) {
|
|
1770
|
+
L += D[1] + '{"__protected_number__":"' + D[2] + '"}' + D[3], J += D[0].length;
|
|
1771
1771
|
continue;
|
|
1772
1772
|
}
|
|
1773
|
-
if (
|
|
1774
|
-
|
|
1773
|
+
if (D = $e.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), D) {
|
|
1774
|
+
L += D[1] + '{"__protected_number__":"' + D[2] + '"}' + D[3], J += D[0].length;
|
|
1775
1775
|
continue;
|
|
1776
1776
|
}
|
|
1777
|
-
|
|
1777
|
+
L += le, J++;
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
|
-
return
|
|
1781
|
-
})(g), o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "",
|
|
1782
|
-
|
|
1780
|
+
return L;
|
|
1781
|
+
})(g), o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", he(() => {
|
|
1782
|
+
b.value !== null && $();
|
|
1783
1783
|
});
|
|
1784
1784
|
} catch (g) {
|
|
1785
1785
|
i.value = g instanceof Error ? g.message : "Unknown parsing error", o.value = null, a.value = null, l.value = "";
|
|
1786
1786
|
}
|
|
1787
|
-
},
|
|
1787
|
+
}, w = (d) => {
|
|
1788
1788
|
if (!d || !d.expression.trim()) {
|
|
1789
|
-
|
|
1789
|
+
S();
|
|
1790
1790
|
return;
|
|
1791
1791
|
}
|
|
1792
1792
|
if (!o.value) {
|
|
@@ -1796,7 +1796,7 @@ const Vt = {
|
|
|
1796
1796
|
try {
|
|
1797
1797
|
let g;
|
|
1798
1798
|
if (d.type === "jsonpath")
|
|
1799
|
-
g =
|
|
1799
|
+
g = B({ 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 {
|
|
@@ -1807,77 +1807,77 @@ const Vt = {
|
|
|
1807
1807
|
`)(o.value), a.value = g;
|
|
1808
1808
|
else
|
|
1809
1809
|
throw new Error(`Unsupported filter type: ${d.type}`);
|
|
1810
|
-
l.value = "",
|
|
1811
|
-
|
|
1810
|
+
l.value = "", he(() => {
|
|
1811
|
+
$();
|
|
1812
1812
|
});
|
|
1813
1813
|
} catch (g) {
|
|
1814
1814
|
l.value = g instanceof Error ? g.message : "Filter execution error", a.value = null;
|
|
1815
1815
|
}
|
|
1816
|
-
},
|
|
1816
|
+
}, S = () => {
|
|
1817
1817
|
a.value = null, l.value = "";
|
|
1818
1818
|
};
|
|
1819
|
-
|
|
1819
|
+
Xe(() => s.modelValue, (d) => {
|
|
1820
1820
|
m(d);
|
|
1821
1821
|
}, { immediate: !0 });
|
|
1822
|
-
const
|
|
1823
|
-
const
|
|
1824
|
-
if (
|
|
1825
|
-
return
|
|
1826
|
-
if (!Array.isArray(
|
|
1827
|
-
return `__PROTECTED_NUMBER_${
|
|
1828
|
-
if (Array.isArray(
|
|
1829
|
-
return
|
|
1830
|
-
const
|
|
1831
|
-
for (const [
|
|
1832
|
-
|
|
1833
|
-
return
|
|
1834
|
-
},
|
|
1835
|
-
return JSON.stringify(
|
|
1836
|
-
},
|
|
1822
|
+
const _ = (d, g, A) => {
|
|
1823
|
+
const N = (L) => {
|
|
1824
|
+
if (L === null || typeof L != "object")
|
|
1825
|
+
return L;
|
|
1826
|
+
if (!Array.isArray(L) && "__protected_number__" in L && Object.keys(L).length === 1)
|
|
1827
|
+
return `__PROTECTED_NUMBER_${L.__protected_number__}_PROTECTED_NUMBER__`;
|
|
1828
|
+
if (Array.isArray(L))
|
|
1829
|
+
return L.map((q) => N(q));
|
|
1830
|
+
const K = {};
|
|
1831
|
+
for (const [q, J] of Object.entries(L))
|
|
1832
|
+
K[q] = N(J);
|
|
1833
|
+
return K;
|
|
1834
|
+
}, C = N(d);
|
|
1835
|
+
return JSON.stringify(C, g, A).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1836
|
+
}, j = (d, g) => {
|
|
1837
1837
|
if (!s.readonly)
|
|
1838
1838
|
try {
|
|
1839
|
-
const
|
|
1840
|
-
n("update:modelValue",
|
|
1841
|
-
} catch (
|
|
1842
|
-
console.error("Failed to update JSON:",
|
|
1839
|
+
const A = H(o.value, d, g), N = _(A, null, 2);
|
|
1840
|
+
n("update:modelValue", N);
|
|
1841
|
+
} catch (A) {
|
|
1842
|
+
console.error("Failed to update JSON:", A);
|
|
1843
1843
|
}
|
|
1844
|
-
},
|
|
1845
|
-
if (!g || g === "root") return
|
|
1846
|
-
const
|
|
1847
|
-
let
|
|
1848
|
-
for (let
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1844
|
+
}, H = (d, g, A) => {
|
|
1845
|
+
if (!g || g === "root") return A;
|
|
1846
|
+
const N = g.split("."), C = Q(d, N.slice(0, -1));
|
|
1847
|
+
let T = C;
|
|
1848
|
+
for (let K = 0; K < N.length - 1; K++) {
|
|
1849
|
+
const q = N[K];
|
|
1850
|
+
q !== "root" && (Array.isArray(T) ? T = T[parseInt(q)] : T = T[q]);
|
|
1851
1851
|
}
|
|
1852
|
-
const
|
|
1853
|
-
return
|
|
1854
|
-
},
|
|
1852
|
+
const L = N[N.length - 1];
|
|
1853
|
+
return L === "root" ? A : (Array.isArray(T) ? T[parseInt(L)] = A : T[L] = A, C);
|
|
1854
|
+
}, p = (d) => {
|
|
1855
1855
|
u.value.has(d) ? u.value.delete(d) : u.value.add(d);
|
|
1856
|
-
},
|
|
1857
|
-
const d = /* @__PURE__ */ new Set(), g = (
|
|
1858
|
-
|
|
1859
|
-
const
|
|
1860
|
-
g(
|
|
1861
|
-
}) : Object.keys(
|
|
1862
|
-
const
|
|
1863
|
-
g(
|
|
1856
|
+
}, $ = () => {
|
|
1857
|
+
const d = /* @__PURE__ */ new Set(), g = (A, N = "") => {
|
|
1858
|
+
A !== null && typeof A == "object" && (d.add(N || "root"), Array.isArray(A) ? A.forEach((C, T) => {
|
|
1859
|
+
const L = N ? `${N}.${T}` : `${T}`;
|
|
1860
|
+
g(C, L);
|
|
1861
|
+
}) : Object.keys(A).forEach((C) => {
|
|
1862
|
+
const T = N ? `${N}.${C}` : C;
|
|
1863
|
+
g(A[C], T);
|
|
1864
1864
|
}));
|
|
1865
1865
|
};
|
|
1866
|
-
g(
|
|
1867
|
-
},
|
|
1866
|
+
g(b.value), u.value = d, n("expand-all");
|
|
1867
|
+
}, E = () => {
|
|
1868
1868
|
u.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1869
|
-
},
|
|
1869
|
+
}, O = async () => {
|
|
1870
1870
|
if (h.value)
|
|
1871
1871
|
try {
|
|
1872
|
-
const d =
|
|
1872
|
+
const d = b.value, g = _(d, null, 2);
|
|
1873
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
|
+
}, I = () => {
|
|
1878
1878
|
if (h.value)
|
|
1879
1879
|
try {
|
|
1880
|
-
const d =
|
|
1880
|
+
const d = b.value, g = _(d);
|
|
1881
1881
|
n("update:modelValue", g), n("compress", g);
|
|
1882
1882
|
} catch (d) {
|
|
1883
1883
|
console.error("Failed to compress JSON:", d);
|
|
@@ -1892,81 +1892,81 @@ const Vt = {
|
|
|
1892
1892
|
}, Z = (d, g) => {
|
|
1893
1893
|
if (!s.readonly)
|
|
1894
1894
|
try {
|
|
1895
|
-
const
|
|
1896
|
-
n("update:modelValue",
|
|
1897
|
-
} catch (
|
|
1898
|
-
console.error("Failed to rename key:",
|
|
1895
|
+
const A = Y(o.value, d, g), N = _(A, null, 2);
|
|
1896
|
+
n("update:modelValue", N), y(d, g);
|
|
1897
|
+
} catch (A) {
|
|
1898
|
+
console.error("Failed to rename key:", A);
|
|
1899
1899
|
}
|
|
1900
|
-
},
|
|
1900
|
+
}, Y = (d, g, A) => {
|
|
1901
1901
|
if (!g || g === "root") return d;
|
|
1902
|
-
const
|
|
1903
|
-
if (
|
|
1904
|
-
const
|
|
1905
|
-
return
|
|
1902
|
+
const N = g.split("."), C = Q(d, N.slice(0, -1));
|
|
1903
|
+
if (N.length === 1) {
|
|
1904
|
+
const K = N[0];
|
|
1905
|
+
return C && typeof C == "object" && !Array.isArray(C) ? ee(C, K, A) : C;
|
|
1906
1906
|
}
|
|
1907
|
-
let
|
|
1908
|
-
for (let
|
|
1909
|
-
const
|
|
1910
|
-
Array.isArray(
|
|
1907
|
+
let T = C;
|
|
1908
|
+
for (let K = 0; K < N.length - 1; K++) {
|
|
1909
|
+
const q = N[K];
|
|
1910
|
+
Array.isArray(T) ? T = T[parseInt(q)] : T = T[q];
|
|
1911
1911
|
}
|
|
1912
|
-
const
|
|
1913
|
-
if (!Array.isArray(
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1912
|
+
const L = N[N.length - 1];
|
|
1913
|
+
if (!Array.isArray(T) && T && typeof T == "object") {
|
|
1914
|
+
const K = ee(T, L, A), q = N.slice(0, -1);
|
|
1915
|
+
q.length > 0 && ae(C, q, K);
|
|
1916
1916
|
}
|
|
1917
|
-
return
|
|
1918
|
-
},
|
|
1917
|
+
return C;
|
|
1918
|
+
}, Q = (d, g) => {
|
|
1919
1919
|
if (g.length === 0) return d;
|
|
1920
1920
|
if (Array.isArray(d)) {
|
|
1921
|
-
const
|
|
1922
|
-
return g.length === 1 || (
|
|
1921
|
+
const A = [...d], N = g[0], C = parseInt(N);
|
|
1922
|
+
return g.length === 1 || (A[C] = Q(d[C], g.slice(1))), A;
|
|
1923
1923
|
} else if (d && typeof d == "object") {
|
|
1924
|
-
const
|
|
1925
|
-
return g.length === 1 || (
|
|
1924
|
+
const A = { ...d }, N = g[0];
|
|
1925
|
+
return g.length === 1 || (A[N] = Q(d[N], g.slice(1))), A;
|
|
1926
1926
|
}
|
|
1927
1927
|
return d;
|
|
1928
|
-
},
|
|
1928
|
+
}, ee = (d, g, A) => {
|
|
1929
1929
|
if (!d || typeof d != "object" || Array.isArray(d))
|
|
1930
1930
|
return d;
|
|
1931
|
-
const
|
|
1932
|
-
for (const
|
|
1933
|
-
|
|
1934
|
-
return
|
|
1935
|
-
},
|
|
1936
|
-
let
|
|
1937
|
-
for (let
|
|
1938
|
-
const
|
|
1939
|
-
Array.isArray(
|
|
1931
|
+
const N = Object.keys(d), C = {};
|
|
1932
|
+
for (const T of N)
|
|
1933
|
+
T === g ? C[A] = d[T] : C[T] = d[T];
|
|
1934
|
+
return C;
|
|
1935
|
+
}, ae = (d, g, A) => {
|
|
1936
|
+
let N = d;
|
|
1937
|
+
for (let T = 0; T < g.length - 1; T++) {
|
|
1938
|
+
const L = g[T];
|
|
1939
|
+
Array.isArray(N) ? N = N[parseInt(L)] : N = N[L];
|
|
1940
1940
|
}
|
|
1941
|
-
const
|
|
1942
|
-
Array.isArray(
|
|
1943
|
-
},
|
|
1944
|
-
const
|
|
1945
|
-
u.value.forEach((
|
|
1946
|
-
if (
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
} else if (
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1941
|
+
const C = g[g.length - 1];
|
|
1942
|
+
Array.isArray(N) ? N[parseInt(C)] = A : N[C] = A;
|
|
1943
|
+
}, y = (d, g) => {
|
|
1944
|
+
const A = /* @__PURE__ */ new Set();
|
|
1945
|
+
u.value.forEach((N) => {
|
|
1946
|
+
if (N === d) {
|
|
1947
|
+
const C = d.split(".");
|
|
1948
|
+
C[C.length - 1] = g, A.add(C.join("."));
|
|
1949
|
+
} else if (N.startsWith(d + ".")) {
|
|
1950
|
+
const C = d.split(".");
|
|
1951
|
+
C[C.length - 1] = g;
|
|
1952
|
+
const T = C.join("."), L = N.substring(d.length);
|
|
1953
|
+
A.add(T + L);
|
|
1954
1954
|
} else
|
|
1955
|
-
|
|
1956
|
-
}), u.value =
|
|
1955
|
+
A.add(N);
|
|
1956
|
+
}), u.value = A;
|
|
1957
1957
|
};
|
|
1958
1958
|
return e({
|
|
1959
1959
|
// 核心操作方法
|
|
1960
|
-
copyJson:
|
|
1961
|
-
compressSource:
|
|
1962
|
-
expandAll:
|
|
1963
|
-
collapseAll:
|
|
1964
|
-
toggleExpand:
|
|
1965
|
-
updateValue:
|
|
1960
|
+
copyJson: O,
|
|
1961
|
+
compressSource: I,
|
|
1962
|
+
expandAll: $,
|
|
1963
|
+
collapseAll: E,
|
|
1964
|
+
toggleExpand: p,
|
|
1965
|
+
updateValue: j,
|
|
1966
1966
|
updateKey: Z,
|
|
1967
1967
|
// Filter 相关方法
|
|
1968
|
-
filter:
|
|
1969
|
-
clearFilter:
|
|
1968
|
+
filter: w,
|
|
1969
|
+
clearFilter: S,
|
|
1970
1970
|
// 状态访问方法
|
|
1971
1971
|
isValidJson: () => h.value,
|
|
1972
1972
|
getParsedJson: () => o.value,
|
|
@@ -1977,341 +1977,834 @@ const Vt = {
|
|
|
1977
1977
|
// 工具方法
|
|
1978
1978
|
parseJson: (d) => m(d),
|
|
1979
1979
|
copyValue: (d) => X(d)
|
|
1980
|
-
}), (d, g) => (x(),
|
|
1981
|
-
class:
|
|
1980
|
+
}), (d, g) => (x(), k("div", {
|
|
1981
|
+
class: Te(["json-format", `json-format--${f.value.name}`])
|
|
1982
1982
|
}, [
|
|
1983
|
-
d.showToolbar ? (x(),
|
|
1984
|
-
|
|
1985
|
-
|
|
1983
|
+
d.showToolbar ? (x(), k("div", Lt, [
|
|
1984
|
+
v("div", Rt, [
|
|
1985
|
+
v("button", {
|
|
1986
1986
|
class: "json-format__btn json-format__btn--primary",
|
|
1987
|
-
onClick:
|
|
1987
|
+
onClick: O,
|
|
1988
1988
|
disabled: !h.value,
|
|
1989
1989
|
title: "Copy JSON"
|
|
1990
|
-
}, " 📋 Copy ", 8,
|
|
1991
|
-
|
|
1990
|
+
}, " 📋 Copy ", 8, jt),
|
|
1991
|
+
v("button", {
|
|
1992
1992
|
class: "json-format__btn json-format__btn--secondary",
|
|
1993
|
-
onClick:
|
|
1993
|
+
onClick: $,
|
|
1994
1994
|
disabled: !h.value,
|
|
1995
1995
|
title: "Expand All"
|
|
1996
|
-
}, " ⬇️ Expand All ", 8,
|
|
1997
|
-
|
|
1996
|
+
}, " ⬇️ Expand All ", 8, Mt),
|
|
1997
|
+
v("button", {
|
|
1998
1998
|
class: "json-format__btn json-format__btn--secondary",
|
|
1999
|
-
onClick:
|
|
1999
|
+
onClick: E,
|
|
2000
2000
|
disabled: !h.value,
|
|
2001
2001
|
title: "Collapse All"
|
|
2002
|
-
}, " ➡️ Collapse All ", 8,
|
|
2003
|
-
|
|
2002
|
+
}, " ➡️ Collapse All ", 8, Ut),
|
|
2003
|
+
v("button", {
|
|
2004
2004
|
class: "json-format__btn json-format__btn--secondary",
|
|
2005
|
-
onClick:
|
|
2005
|
+
onClick: I,
|
|
2006
2006
|
disabled: !h.value,
|
|
2007
2007
|
title: "Compress JSON"
|
|
2008
|
-
}, " 📦 Compress ", 8,
|
|
2008
|
+
}, " 📦 Compress ", 8, Ft)
|
|
2009
2009
|
]),
|
|
2010
|
-
|
|
2011
|
-
h.value ? (x(),
|
|
2010
|
+
v("div", Xt, [
|
|
2011
|
+
h.value ? (x(), k("span", Ht, " ✅ Valid JSON ")) : (x(), k("span", Kt, " ❌ Invalid JSON "))
|
|
2012
2012
|
])
|
|
2013
2013
|
])) : F("", !0),
|
|
2014
|
-
|
|
2015
|
-
h.value ? l.value ? (x(),
|
|
2016
|
-
g[1] || (g[1] =
|
|
2017
|
-
|
|
2018
|
-
])) : (x(),
|
|
2019
|
-
|
|
2020
|
-
value:
|
|
2014
|
+
v("div", qt, [
|
|
2015
|
+
h.value ? l.value ? (x(), k("div", Qt, [
|
|
2016
|
+
g[1] || (g[1] = v("h4", null, "Filter Error:", -1)),
|
|
2017
|
+
v("pre", null, R(l.value), 1)
|
|
2018
|
+
])) : (x(), k("div", Wt, [
|
|
2019
|
+
Fe(Pt, {
|
|
2020
|
+
value: b.value,
|
|
2021
2021
|
"key-name": "",
|
|
2022
2022
|
level: 0,
|
|
2023
2023
|
expanded: u.value,
|
|
2024
2024
|
"is-last": !0,
|
|
2025
2025
|
theme: f.value,
|
|
2026
|
-
"onUpdate:value":
|
|
2027
|
-
onToggleExpand:
|
|
2026
|
+
"onUpdate:value": j,
|
|
2027
|
+
onToggleExpand: p,
|
|
2028
2028
|
onCopy: X,
|
|
2029
2029
|
"onUpdate:key": Z
|
|
2030
2030
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2031
|
-
])) : (x(),
|
|
2032
|
-
g[0] || (g[0] =
|
|
2033
|
-
|
|
2031
|
+
])) : (x(), k("div", Yt, [
|
|
2032
|
+
g[0] || (g[0] = v("h4", null, "JSON Parse Error:", -1)),
|
|
2033
|
+
v("pre", null, R(i.value), 1)
|
|
2034
2034
|
]))
|
|
2035
2035
|
])
|
|
2036
2036
|
], 2));
|
|
2037
2037
|
}
|
|
2038
|
-
}),
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
if (o += 2, o = Be(r, o), o.err) return o;
|
|
2072
|
-
} else if (r[o] === "<") {
|
|
2073
|
-
let i = o;
|
|
2074
|
-
if (o++, r[o] === "!") {
|
|
2075
|
-
o = Ve(r, o);
|
|
2076
|
-
continue;
|
|
2077
|
-
} else {
|
|
2078
|
-
let u = !1;
|
|
2079
|
-
r[o] === "/" && (u = !0, o++);
|
|
2080
|
-
let a = "";
|
|
2081
|
-
for (; o < r.length && r[o] !== ">" && r[o] !== " " && r[o] !== " " && r[o] !== `
|
|
2082
|
-
` && r[o] !== "\r"; o++)
|
|
2083
|
-
a += r[o];
|
|
2084
|
-
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !lr(a)) {
|
|
2085
|
-
let 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
|
-
}
|
|
2088
|
-
const l = nr(r, o);
|
|
2089
|
-
if (l === !1)
|
|
2090
|
-
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.", Y(r, o));
|
|
2091
|
-
let h = l.value;
|
|
2092
|
-
if (o = l.index, h[h.length - 1] === "/") {
|
|
2093
|
-
const f = o - h.length;
|
|
2094
|
-
h = h.substring(0, h.length - 1);
|
|
2095
|
-
const y = Le(h, e);
|
|
2096
|
-
if (y === !0)
|
|
2097
|
-
s = !0;
|
|
2098
|
-
else
|
|
2099
|
-
return U(y.err.code, y.err.msg, Y(r, f + y.err.line));
|
|
2100
|
-
} else if (u)
|
|
2101
|
-
if (l.tagClosed) {
|
|
2102
|
-
if (h.trim().length > 0)
|
|
2103
|
-
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", Y(r, i));
|
|
2104
|
-
if (t.length === 0)
|
|
2105
|
-
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.", Y(r, i));
|
|
2106
|
-
{
|
|
2107
|
-
const f = t.pop();
|
|
2108
|
-
if (a !== f.tagName) {
|
|
2109
|
-
let y = Y(r, f.tagStartPos);
|
|
2110
|
-
return U(
|
|
2111
|
-
"InvalidTag",
|
|
2112
|
-
"Expected closing tag '" + f.tagName + "' (opened in line " + y.line + ", col " + y.col + ") instead of closing tag '" + a + "'.",
|
|
2113
|
-
Y(r, i)
|
|
2114
|
-
);
|
|
2115
|
-
}
|
|
2116
|
-
t.length == 0 && (n = !0);
|
|
2117
|
-
}
|
|
2118
|
-
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", Y(r, o));
|
|
2119
|
-
else {
|
|
2120
|
-
const f = Le(h, e);
|
|
2121
|
-
if (f !== !0)
|
|
2122
|
-
return U(f.err.code, f.err.msg, Y(r, o - h.length + f.err.line));
|
|
2123
|
-
if (n === !0)
|
|
2124
|
-
return U("InvalidXml", "Multiple possible root nodes found.", Y(r, o));
|
|
2125
|
-
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2126
|
-
}
|
|
2127
|
-
for (o++; o < r.length; o++)
|
|
2128
|
-
if (r[o] === "<")
|
|
2129
|
-
if (r[o + 1] === "!") {
|
|
2130
|
-
o++, o = Ve(r, o);
|
|
2131
|
-
continue;
|
|
2132
|
-
} else if (r[o + 1] === "?") {
|
|
2133
|
-
if (o = Be(r, ++o), o.err) return o;
|
|
2134
|
-
} else
|
|
2135
|
-
break;
|
|
2136
|
-
else if (r[o] === "&") {
|
|
2137
|
-
const f = ir(r, o);
|
|
2138
|
-
if (f == -1)
|
|
2139
|
-
return U("InvalidChar", "char '&' is not expected.", Y(r, o));
|
|
2140
|
-
o = f;
|
|
2141
|
-
} else if (n === !0 && !$e(r[o]))
|
|
2142
|
-
return U("InvalidXml", "Extra text at the end", Y(r, o));
|
|
2143
|
-
r[o] === "<" && o--;
|
|
2144
|
-
}
|
|
2145
|
-
} else {
|
|
2146
|
-
if ($e(r[o]))
|
|
2147
|
-
continue;
|
|
2148
|
-
return U("InvalidChar", "char '" + r[o] + "' is not expected.", Y(r, o));
|
|
2149
|
-
}
|
|
2150
|
-
if (s) {
|
|
2151
|
-
if (t.length == 1)
|
|
2152
|
-
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", Y(r, t[0].tagStartPos));
|
|
2153
|
-
if (t.length > 0)
|
|
2154
|
-
return U("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
2155
|
-
} else return U("InvalidXml", "Start tag expected.", 1);
|
|
2156
|
-
return !0;
|
|
2157
|
-
}
|
|
2158
|
-
function $e(r) {
|
|
2159
|
-
return r === " " || r === " " || r === `
|
|
2160
|
-
` || r === "\r";
|
|
2161
|
-
}
|
|
2162
|
-
function Be(r, e) {
|
|
2163
|
-
const t = e;
|
|
2164
|
-
for (; e < r.length; e++)
|
|
2165
|
-
if (r[e] == "?" || r[e] == " ") {
|
|
2166
|
-
const s = r.substr(t, e - t);
|
|
2167
|
-
if (e > 5 && s === "xml")
|
|
2168
|
-
return U("InvalidXml", "XML declaration allowed only at the start of the document.", Y(r, e));
|
|
2169
|
-
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2170
|
-
e++;
|
|
2171
|
-
break;
|
|
2172
|
-
} else
|
|
2173
|
-
continue;
|
|
2174
|
-
}
|
|
2175
|
-
return e;
|
|
2176
|
-
}
|
|
2177
|
-
function Ve(r, e) {
|
|
2178
|
-
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2179
|
-
for (e += 3; e < r.length; e++)
|
|
2180
|
-
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
2181
|
-
e += 2;
|
|
2182
|
-
break;
|
|
2183
|
-
}
|
|
2184
|
-
} else if (r.length > e + 8 && r[e + 1] === "D" && r[e + 2] === "O" && r[e + 3] === "C" && r[e + 4] === "T" && r[e + 5] === "Y" && r[e + 6] === "P" && r[e + 7] === "E") {
|
|
2185
|
-
let t = 1;
|
|
2186
|
-
for (e += 8; e < r.length; e++)
|
|
2187
|
-
if (r[e] === "<")
|
|
2188
|
-
t++;
|
|
2189
|
-
else if (r[e] === ">" && (t--, t === 0))
|
|
2190
|
-
break;
|
|
2191
|
-
} else if (r.length > e + 9 && r[e + 1] === "[" && r[e + 2] === "C" && r[e + 3] === "D" && r[e + 4] === "A" && r[e + 5] === "T" && r[e + 6] === "A" && r[e + 7] === "[") {
|
|
2192
|
-
for (e += 8; e < r.length; e++)
|
|
2193
|
-
if (r[e] === "]" && r[e + 1] === "]" && r[e + 2] === ">") {
|
|
2194
|
-
e += 2;
|
|
2195
|
-
break;
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
return e;
|
|
2199
|
-
}
|
|
2200
|
-
const tr = '"', rr = "'";
|
|
2201
|
-
function nr(r, e) {
|
|
2202
|
-
let t = "", s = "", n = !1;
|
|
2203
|
-
for (; e < r.length; e++) {
|
|
2204
|
-
if (r[e] === tr || r[e] === rr)
|
|
2205
|
-
s === "" ? s = r[e] : s !== r[e] || (s = "");
|
|
2206
|
-
else if (r[e] === ">" && s === "") {
|
|
2207
|
-
n = !0;
|
|
2208
|
-
break;
|
|
2209
|
-
}
|
|
2210
|
-
t += r[e];
|
|
2211
|
-
}
|
|
2212
|
-
return s !== "" ? !1 : {
|
|
2213
|
-
value: t,
|
|
2214
|
-
index: e,
|
|
2215
|
-
tagClosed: n
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
|
-
const sr = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
2219
|
-
function Le(r, e) {
|
|
2220
|
-
const t = Ye(r, sr), s = {};
|
|
2221
|
-
for (let n = 0; n < t.length; n++) {
|
|
2222
|
-
if (t[n][1].length === 0)
|
|
2223
|
-
return U("InvalidAttr", "Attribute '" + t[n][2] + "' has no space in starting.", de(t[n]));
|
|
2224
|
-
if (t[n][3] !== void 0 && t[n][4] === void 0)
|
|
2225
|
-
return U("InvalidAttr", "Attribute '" + t[n][2] + "' is without value.", de(t[n]));
|
|
2226
|
-
if (t[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
2227
|
-
return U("InvalidAttr", "boolean attribute '" + t[n][2] + "' is not allowed.", de(t[n]));
|
|
2228
|
-
const o = t[n][2];
|
|
2229
|
-
if (!ar(o))
|
|
2230
|
-
return U("InvalidAttr", "Attribute '" + o + "' is an invalid name.", de(t[n]));
|
|
2231
|
-
if (!s.hasOwnProperty(o))
|
|
2232
|
-
s[o] = 1;
|
|
2233
|
-
else
|
|
2234
|
-
return U("InvalidAttr", "Attribute '" + o + "' is repeated.", de(t[n]));
|
|
2235
|
-
}
|
|
2236
|
-
return !0;
|
|
2237
|
-
}
|
|
2238
|
-
function or(r, e) {
|
|
2239
|
-
let t = /\d/;
|
|
2240
|
-
for (r[e] === "x" && (e++, t = /[\da-fA-F]/); e < r.length; e++) {
|
|
2241
|
-
if (r[e] === ";")
|
|
2242
|
-
return e;
|
|
2243
|
-
if (!r[e].match(t))
|
|
2244
|
-
break;
|
|
2245
|
-
}
|
|
2246
|
-
return -1;
|
|
2247
|
-
}
|
|
2248
|
-
function ir(r, e) {
|
|
2249
|
-
if (e++, r[e] === ";")
|
|
2250
|
-
return -1;
|
|
2251
|
-
if (r[e] === "#")
|
|
2252
|
-
return e++, or(r, e);
|
|
2253
|
-
let t = 0;
|
|
2254
|
-
for (; e < r.length; e++, t++)
|
|
2255
|
-
if (!(r[e].match(/\w/) && t < 20)) {
|
|
2256
|
-
if (r[e] === ";")
|
|
2257
|
-
break;
|
|
2258
|
-
return -1;
|
|
2259
|
-
}
|
|
2260
|
-
return e;
|
|
2261
|
-
}
|
|
2262
|
-
function U(r, e, t) {
|
|
2263
|
-
return {
|
|
2264
|
-
err: {
|
|
2265
|
-
code: r,
|
|
2266
|
-
msg: e,
|
|
2267
|
-
line: t.line || t,
|
|
2268
|
-
col: t.col
|
|
2269
|
-
}
|
|
2270
|
-
};
|
|
2271
|
-
}
|
|
2272
|
-
function ar(r) {
|
|
2273
|
-
return ye(r);
|
|
2274
|
-
}
|
|
2275
|
-
function lr(r) {
|
|
2276
|
-
return ye(r);
|
|
2277
|
-
}
|
|
2278
|
-
function Y(r, e) {
|
|
2279
|
-
const t = r.substring(0, e).split(/\r?\n/);
|
|
2280
|
-
return {
|
|
2281
|
-
line: t.length,
|
|
2282
|
-
// column number is last line's length + 1, because column numbering starts at 1:
|
|
2283
|
-
col: t[t.length - 1].length + 1
|
|
2284
|
-
};
|
|
2285
|
-
}
|
|
2286
|
-
function de(r) {
|
|
2287
|
-
return r.startIndex + r[1].length;
|
|
2288
|
-
}
|
|
2289
|
-
const ur = {
|
|
2290
|
-
preserveOrder: !1,
|
|
2291
|
-
attributeNamePrefix: "@_",
|
|
2292
|
-
attributesGroupName: !1,
|
|
2293
|
-
textNodeName: "#text",
|
|
2294
|
-
ignoreAttributes: !0,
|
|
2295
|
-
removeNSPrefix: !1,
|
|
2296
|
-
// remove NS from tag name or attribute name if true
|
|
2297
|
-
allowBooleanAttributes: !1,
|
|
2298
|
-
//a tag can have attributes without any value
|
|
2299
|
-
//ignoreRootElement : false,
|
|
2300
|
-
parseTagValue: !0,
|
|
2301
|
-
parseAttributeValue: !1,
|
|
2302
|
-
trimValues: !0,
|
|
2303
|
-
//Trim string values of tag and attributes
|
|
2304
|
-
cdataPropName: !1,
|
|
2305
|
-
numberParseOptions: {
|
|
2306
|
-
hex: !0,
|
|
2307
|
-
leadingZeros: !0,
|
|
2308
|
-
eNotation: !0
|
|
2309
|
-
},
|
|
2310
|
-
tagValueProcessor: function(r, e) {
|
|
2311
|
-
return e;
|
|
2038
|
+
}), Zt = /* @__PURE__ */ be(Gt, [["__scopeId", "data-v-7a477244"]]), zt = {
|
|
2039
|
+
key: 0,
|
|
2040
|
+
class: "xml-node__comment"
|
|
2041
|
+
}, Dt = {
|
|
2042
|
+
key: 1,
|
|
2043
|
+
class: "xml-node__cdata"
|
|
2044
|
+
}, Jt = {
|
|
2045
|
+
key: 2,
|
|
2046
|
+
class: "xml-node__element"
|
|
2047
|
+
}, er = {
|
|
2048
|
+
key: 0,
|
|
2049
|
+
class: "xml-node__line"
|
|
2050
|
+
}, tr = {
|
|
2051
|
+
key: 1,
|
|
2052
|
+
class: "xml-node__line"
|
|
2053
|
+
}, rr = { key: 2 }, nr = { class: "xml-node__line" }, sr = ["title"], or = { key: 1 }, ir = ["title"], ar = {
|
|
2054
|
+
key: 0,
|
|
2055
|
+
class: "xml-node__children"
|
|
2056
|
+
}, lr = {
|
|
2057
|
+
key: 0,
|
|
2058
|
+
class: "xml-node__text"
|
|
2059
|
+
}, ur = {
|
|
2060
|
+
key: 1,
|
|
2061
|
+
class: "xml-node__line"
|
|
2062
|
+
}, cr = /* @__PURE__ */ ye({
|
|
2063
|
+
__name: "XmlNode",
|
|
2064
|
+
props: {
|
|
2065
|
+
node: {},
|
|
2066
|
+
index: {},
|
|
2067
|
+
level: { default: 0 },
|
|
2068
|
+
parentPath: { default: "" },
|
|
2069
|
+
expanded: {},
|
|
2070
|
+
theme: {}
|
|
2312
2071
|
},
|
|
2313
|
-
|
|
2314
|
-
|
|
2072
|
+
emits: ["toggle-expand", "copy"],
|
|
2073
|
+
setup(r, { emit: e }) {
|
|
2074
|
+
const t = r, s = e, n = V(() => Object.keys(t.node).find(($) => !$.startsWith(":") && !$.startsWith("#")) || ""), o = V(() => n.value ? t.parentPath ? `${t.parentPath}[${t.index}]` : `${n.value}[${t.index}]` : ""), i = V(() => t.expanded.has(o.value)), u = V(() => t.node["#comment"] ? "comment" : t.node.__cdata ? "cdata" : n.value ? "element" : "unknown"), a = V(() => {
|
|
2075
|
+
const p = t.node[":@"] || {}, $ = {};
|
|
2076
|
+
return Object.keys(p).forEach((E) => {
|
|
2077
|
+
E.startsWith("@_") && ($[E.substring(2)] = p[E]);
|
|
2078
|
+
}), $;
|
|
2079
|
+
}), l = V(() => {
|
|
2080
|
+
if (u.value !== "element" || !n.value) return [];
|
|
2081
|
+
const p = t.node[n.value];
|
|
2082
|
+
return Array.isArray(p) ? p : [];
|
|
2083
|
+
}), h = V(() => l.value.some((p) => p.__cdata)), f = V(() => {
|
|
2084
|
+
if (!h.value) return "";
|
|
2085
|
+
const p = l.value.find(($) => $.__cdata);
|
|
2086
|
+
if (p && Array.isArray(p.__cdata)) {
|
|
2087
|
+
const $ = p.__cdata;
|
|
2088
|
+
if ($.length > 0 && $[0]["#text"])
|
|
2089
|
+
return $[0]["#text"];
|
|
2090
|
+
}
|
|
2091
|
+
return "";
|
|
2092
|
+
}), b = V(() => {
|
|
2093
|
+
if (u.value !== "element" || !n.value || h.value) return "";
|
|
2094
|
+
const p = t.node[n.value];
|
|
2095
|
+
if (!Array.isArray(p)) return "";
|
|
2096
|
+
const $ = p.find((E) => E["#text"]);
|
|
2097
|
+
return $ ? $["#text"] : "";
|
|
2098
|
+
}), m = V(() => {
|
|
2099
|
+
if (u.value !== "comment") return "";
|
|
2100
|
+
const p = t.node["#comment"];
|
|
2101
|
+
return Array.isArray(p) && p.length > 0 && p[0]["#text"] || "";
|
|
2102
|
+
}), w = V(() => l.value.some((p) => Object.keys(p).some((E) => !E.startsWith("#") && !E.startsWith(":")))), S = V(() => u.value === "element" && !w.value && b.value.trim() !== ""), _ = () => {
|
|
2103
|
+
w.value && s("toggle-expand", o.value);
|
|
2104
|
+
}, j = (p, $) => `${o.value}-child-${$}`, H = () => `${o.value}.${n.value}`;
|
|
2105
|
+
return (p, $) => {
|
|
2106
|
+
const E = Ue("XmlNode", !0);
|
|
2107
|
+
return x(), k("div", {
|
|
2108
|
+
class: "xml-node",
|
|
2109
|
+
style: P({ paddingLeft: p.level > 0 ? "16px" : "0" })
|
|
2110
|
+
}, [
|
|
2111
|
+
u.value === "comment" ? (x(), k("div", zt, [
|
|
2112
|
+
v("span", {
|
|
2113
|
+
style: P({ color: p.theme.colors.xmlComment })
|
|
2114
|
+
}, " <!-- " + R(m.value) + " --> ", 5)
|
|
2115
|
+
])) : u.value === "cdata" ? (x(), k("div", Dt, [
|
|
2116
|
+
v("span", {
|
|
2117
|
+
style: P({ color: p.theme.colors.xmlCdata })
|
|
2118
|
+
}, " <![CDATA[" + R(p.node.__cdata) + "]]> ", 5)
|
|
2119
|
+
])) : u.value === "element" ? (x(), k("div", Jt, [
|
|
2120
|
+
h.value ? (x(), k("div", er, [
|
|
2121
|
+
v("span", {
|
|
2122
|
+
class: "xml-node__bracket",
|
|
2123
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2124
|
+
}, "<", 4),
|
|
2125
|
+
v("span", {
|
|
2126
|
+
class: "xml-node__tag",
|
|
2127
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2128
|
+
}, R(n.value), 5),
|
|
2129
|
+
(x(!0), k(de, null, fe(a.value, (O, I) => (x(), k("span", {
|
|
2130
|
+
key: I,
|
|
2131
|
+
class: "xml-node__attribute"
|
|
2132
|
+
}, [
|
|
2133
|
+
v("span", {
|
|
2134
|
+
class: "xml-node__attr-name",
|
|
2135
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2136
|
+
}, R(I), 5),
|
|
2137
|
+
v("span", {
|
|
2138
|
+
class: "xml-node__equals",
|
|
2139
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2140
|
+
}, "=", 4),
|
|
2141
|
+
v("span", {
|
|
2142
|
+
class: "xml-node__quote",
|
|
2143
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2144
|
+
}, '"', 4),
|
|
2145
|
+
v("span", {
|
|
2146
|
+
class: "xml-node__attr-value",
|
|
2147
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2148
|
+
}, R(O), 5),
|
|
2149
|
+
v("span", {
|
|
2150
|
+
class: "xml-node__quote",
|
|
2151
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2152
|
+
}, '"', 4)
|
|
2153
|
+
]))), 128)),
|
|
2154
|
+
v("span", {
|
|
2155
|
+
class: "xml-node__bracket",
|
|
2156
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2157
|
+
}, ">", 4),
|
|
2158
|
+
v("span", {
|
|
2159
|
+
class: "xml-node__cdata",
|
|
2160
|
+
style: P({ color: p.theme.colors.xmlCdata })
|
|
2161
|
+
}, "<![CDATA[" + R(f.value) + "]]>", 5),
|
|
2162
|
+
v("span", {
|
|
2163
|
+
class: "xml-node__bracket",
|
|
2164
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2165
|
+
}, "</", 4),
|
|
2166
|
+
v("span", {
|
|
2167
|
+
class: "xml-node__tag",
|
|
2168
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2169
|
+
}, R(n.value), 5),
|
|
2170
|
+
v("span", {
|
|
2171
|
+
class: "xml-node__bracket",
|
|
2172
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2173
|
+
}, ">", 4)
|
|
2174
|
+
])) : S.value ? (x(), k("div", tr, [
|
|
2175
|
+
v("span", {
|
|
2176
|
+
class: "xml-node__bracket",
|
|
2177
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2178
|
+
}, "<", 4),
|
|
2179
|
+
v("span", {
|
|
2180
|
+
class: "xml-node__tag",
|
|
2181
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2182
|
+
}, R(n.value), 5),
|
|
2183
|
+
(x(!0), k(de, null, fe(a.value, (O, I) => (x(), k("span", {
|
|
2184
|
+
key: I,
|
|
2185
|
+
class: "xml-node__attribute"
|
|
2186
|
+
}, [
|
|
2187
|
+
v("span", {
|
|
2188
|
+
class: "xml-node__attr-name",
|
|
2189
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2190
|
+
}, R(I), 5),
|
|
2191
|
+
v("span", {
|
|
2192
|
+
class: "xml-node__equals",
|
|
2193
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2194
|
+
}, "=", 4),
|
|
2195
|
+
v("span", {
|
|
2196
|
+
class: "xml-node__quote",
|
|
2197
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2198
|
+
}, '"', 4),
|
|
2199
|
+
v("span", {
|
|
2200
|
+
class: "xml-node__attr-value",
|
|
2201
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2202
|
+
}, R(O), 5),
|
|
2203
|
+
v("span", {
|
|
2204
|
+
class: "xml-node__quote",
|
|
2205
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2206
|
+
}, '"', 4)
|
|
2207
|
+
]))), 128)),
|
|
2208
|
+
v("span", {
|
|
2209
|
+
class: "xml-node__bracket",
|
|
2210
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2211
|
+
}, ">", 4),
|
|
2212
|
+
v("span", {
|
|
2213
|
+
class: "xml-node__text-content",
|
|
2214
|
+
style: P({ color: p.theme.colors.xmlText })
|
|
2215
|
+
}, R(b.value), 5),
|
|
2216
|
+
v("span", {
|
|
2217
|
+
class: "xml-node__bracket",
|
|
2218
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2219
|
+
}, "</", 4),
|
|
2220
|
+
v("span", {
|
|
2221
|
+
class: "xml-node__tag",
|
|
2222
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2223
|
+
}, R(n.value), 5),
|
|
2224
|
+
v("span", {
|
|
2225
|
+
class: "xml-node__bracket",
|
|
2226
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2227
|
+
}, ">", 4)
|
|
2228
|
+
])) : (x(), k("div", rr, [
|
|
2229
|
+
v("div", nr, [
|
|
2230
|
+
w.value ? (x(), k("span", {
|
|
2231
|
+
key: 0,
|
|
2232
|
+
class: "xml-node__clickable-part",
|
|
2233
|
+
onClick: $[0] || ($[0] = (O) => _()),
|
|
2234
|
+
title: i.value ? "Click to collapse" : "Click to expand"
|
|
2235
|
+
}, [
|
|
2236
|
+
v("span", {
|
|
2237
|
+
class: "xml-node__bracket",
|
|
2238
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2239
|
+
}, "<", 4),
|
|
2240
|
+
v("span", {
|
|
2241
|
+
class: "xml-node__tag",
|
|
2242
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2243
|
+
}, R(n.value), 5)
|
|
2244
|
+
], 8, sr)) : (x(), k("span", or, [
|
|
2245
|
+
v("span", {
|
|
2246
|
+
class: "xml-node__bracket",
|
|
2247
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2248
|
+
}, "<", 4),
|
|
2249
|
+
v("span", {
|
|
2250
|
+
class: "xml-node__tag",
|
|
2251
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2252
|
+
}, R(n.value), 5)
|
|
2253
|
+
])),
|
|
2254
|
+
(x(!0), k(de, null, fe(a.value, (O, I) => (x(), k("span", {
|
|
2255
|
+
key: I,
|
|
2256
|
+
class: "xml-node__attribute"
|
|
2257
|
+
}, [
|
|
2258
|
+
v("span", {
|
|
2259
|
+
class: "xml-node__attr-name",
|
|
2260
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2261
|
+
}, R(I), 5),
|
|
2262
|
+
v("span", {
|
|
2263
|
+
class: "xml-node__equals",
|
|
2264
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2265
|
+
}, "=", 4),
|
|
2266
|
+
v("span", {
|
|
2267
|
+
class: "xml-node__quote",
|
|
2268
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2269
|
+
}, '"', 4),
|
|
2270
|
+
v("span", {
|
|
2271
|
+
class: "xml-node__attr-value",
|
|
2272
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2273
|
+
}, R(O), 5),
|
|
2274
|
+
v("span", {
|
|
2275
|
+
class: "xml-node__quote",
|
|
2276
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2277
|
+
}, '"', 4)
|
|
2278
|
+
]))), 128)),
|
|
2279
|
+
w.value ? (x(), k("span", {
|
|
2280
|
+
key: 2,
|
|
2281
|
+
class: "xml-node__clickable-part",
|
|
2282
|
+
onClick: $[1] || ($[1] = (O) => _()),
|
|
2283
|
+
title: i.value ? "Click to collapse" : "Click to expand"
|
|
2284
|
+
}, [
|
|
2285
|
+
v("span", {
|
|
2286
|
+
class: "xml-node__bracket",
|
|
2287
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2288
|
+
}, ">", 4)
|
|
2289
|
+
], 8, ir)) : (x(), k("span", {
|
|
2290
|
+
key: 3,
|
|
2291
|
+
class: "xml-node__bracket",
|
|
2292
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2293
|
+
}, R(w.value ? ">" : "/>"), 5)),
|
|
2294
|
+
!i.value && w.value ? (x(), k("span", {
|
|
2295
|
+
key: 4,
|
|
2296
|
+
class: "xml-node__collapsed xml-node__collapsed--clickable",
|
|
2297
|
+
style: P({ color: p.theme.colors.textSecondary }),
|
|
2298
|
+
onClick: $[2] || ($[2] = (O) => _()),
|
|
2299
|
+
title: "Click to expand"
|
|
2300
|
+
}, "...", 4)) : F("", !0)
|
|
2301
|
+
]),
|
|
2302
|
+
i.value && w.value ? (x(), k("div", ar, [
|
|
2303
|
+
l.value.length === 0 && b.value.trim() ? (x(), k("div", lr, [
|
|
2304
|
+
v("span", {
|
|
2305
|
+
class: "xml-node__text-content",
|
|
2306
|
+
style: P({ color: p.theme.colors.xmlText })
|
|
2307
|
+
}, R(b.value), 5)
|
|
2308
|
+
])) : F("", !0),
|
|
2309
|
+
(x(!0), k(de, null, fe(l.value, (O, I) => (x(), He(E, {
|
|
2310
|
+
key: j(O, I),
|
|
2311
|
+
node: O,
|
|
2312
|
+
index: I,
|
|
2313
|
+
level: p.level + 1,
|
|
2314
|
+
"parent-path": H(),
|
|
2315
|
+
expanded: p.expanded,
|
|
2316
|
+
theme: p.theme,
|
|
2317
|
+
onToggleExpand: $[3] || ($[3] = (X) => p.$emit("toggle-expand", X)),
|
|
2318
|
+
onCopy: $[4] || ($[4] = (X) => p.$emit("copy", X))
|
|
2319
|
+
}, null, 8, ["node", "index", "level", "parent-path", "expanded", "theme"]))), 128))
|
|
2320
|
+
])) : F("", !0),
|
|
2321
|
+
i.value && w.value ? (x(), k("div", ur, [
|
|
2322
|
+
v("span", {
|
|
2323
|
+
class: "xml-node__clickable-part",
|
|
2324
|
+
onClick: $[5] || ($[5] = (O) => _()),
|
|
2325
|
+
title: "Click to collapse"
|
|
2326
|
+
}, [
|
|
2327
|
+
v("span", {
|
|
2328
|
+
class: "xml-node__bracket",
|
|
2329
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2330
|
+
}, "</", 4),
|
|
2331
|
+
v("span", {
|
|
2332
|
+
class: "xml-node__tag",
|
|
2333
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2334
|
+
}, R(n.value), 5),
|
|
2335
|
+
v("span", {
|
|
2336
|
+
class: "xml-node__bracket",
|
|
2337
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2338
|
+
}, ">", 4)
|
|
2339
|
+
])
|
|
2340
|
+
])) : F("", !0)
|
|
2341
|
+
]))
|
|
2342
|
+
])) : F("", !0)
|
|
2343
|
+
], 4);
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
}), dr = /* @__PURE__ */ be(cr, [["__scopeId", "data-v-9c0c90fa"]]), fr = {
|
|
2347
|
+
name: "github-light",
|
|
2348
|
+
colors: {
|
|
2349
|
+
// 背景色
|
|
2350
|
+
background: "#ffffff",
|
|
2351
|
+
surfaceBackground: "#f6f8fa",
|
|
2352
|
+
// 边框色
|
|
2353
|
+
border: "#d0d7de",
|
|
2354
|
+
// 文本色
|
|
2355
|
+
text: "#24292f",
|
|
2356
|
+
textSecondary: "#57606a",
|
|
2357
|
+
// 按钮样式
|
|
2358
|
+
buttonBackground: "#f6f8fa",
|
|
2359
|
+
buttonBackgroundHover: "#f3f4f6",
|
|
2360
|
+
buttonBorder: "#d0d7de",
|
|
2361
|
+
buttonText: "#24292f",
|
|
2362
|
+
buttonPrimary: "#1f883d",
|
|
2363
|
+
buttonPrimaryHover: "#1a7f37",
|
|
2364
|
+
// 状态指示
|
|
2365
|
+
success: "#1f883d",
|
|
2366
|
+
successBackground: "#dafbe1",
|
|
2367
|
+
error: "#cf222e",
|
|
2368
|
+
errorBackground: "#ffebe9",
|
|
2369
|
+
// XML 语法高亮
|
|
2370
|
+
xmlTag: "#116329",
|
|
2371
|
+
// 标签名 - 绿色
|
|
2372
|
+
xmlAttribute: "#0550ae",
|
|
2373
|
+
// 属性名 - 蓝色
|
|
2374
|
+
xmlAttributeValue: "#0a3069",
|
|
2375
|
+
// 属性值 - 深蓝
|
|
2376
|
+
xmlText: "#24292f",
|
|
2377
|
+
// 文本内容 - 黑色
|
|
2378
|
+
xmlComment: "#6e7781",
|
|
2379
|
+
// 注释 - 灰色
|
|
2380
|
+
xmlCdata: "#8250df",
|
|
2381
|
+
// CDATA - 紫色
|
|
2382
|
+
xmlDeclaration: "#953800",
|
|
2383
|
+
// 声明 - 橙色
|
|
2384
|
+
xmlBracket: "#6e7781",
|
|
2385
|
+
// 括号 - 灰色
|
|
2386
|
+
xmlEquals: "#6e7781",
|
|
2387
|
+
// 等号 - 灰色
|
|
2388
|
+
xmlQuote: "#0550ae"
|
|
2389
|
+
// 引号 - 蓝色
|
|
2390
|
+
}
|
|
2391
|
+
}, hr = {
|
|
2392
|
+
name: "github-dark",
|
|
2393
|
+
colors: {
|
|
2394
|
+
// 背景色
|
|
2395
|
+
background: "#0d1117",
|
|
2396
|
+
surfaceBackground: "#161b22",
|
|
2397
|
+
// 边框色
|
|
2398
|
+
border: "#30363d",
|
|
2399
|
+
// 文本色
|
|
2400
|
+
text: "#c9d1d9",
|
|
2401
|
+
textSecondary: "#8b949e",
|
|
2402
|
+
// 按钮样式
|
|
2403
|
+
buttonBackground: "#21262d",
|
|
2404
|
+
buttonBackgroundHover: "#30363d",
|
|
2405
|
+
buttonBorder: "#30363d",
|
|
2406
|
+
buttonText: "#c9d1d9",
|
|
2407
|
+
buttonPrimary: "#238636",
|
|
2408
|
+
buttonPrimaryHover: "#2ea043",
|
|
2409
|
+
// 状态指示
|
|
2410
|
+
success: "#3fb950",
|
|
2411
|
+
successBackground: "#0f2e1c",
|
|
2412
|
+
error: "#f85149",
|
|
2413
|
+
errorBackground: "#3d1319",
|
|
2414
|
+
// XML 语法高亮
|
|
2415
|
+
xmlTag: "#7ee787",
|
|
2416
|
+
// 标签名 - 亮绿色
|
|
2417
|
+
xmlAttribute: "#79c0ff",
|
|
2418
|
+
// 属性名 - 亮蓝色
|
|
2419
|
+
xmlAttributeValue: "#a5d6ff",
|
|
2420
|
+
// 属性值 - 淡蓝色
|
|
2421
|
+
xmlText: "#c9d1d9",
|
|
2422
|
+
// 文本内容 - 白色
|
|
2423
|
+
xmlComment: "#8b949e",
|
|
2424
|
+
// 注释 - 灰色
|
|
2425
|
+
xmlCdata: "#d2a8ff",
|
|
2426
|
+
// CDATA - 紫色
|
|
2427
|
+
xmlDeclaration: "#ffa657",
|
|
2428
|
+
// 声明 - 橙色
|
|
2429
|
+
xmlBracket: "#8b949e",
|
|
2430
|
+
// 括号 - 灰色
|
|
2431
|
+
xmlEquals: "#8b949e",
|
|
2432
|
+
// 等号 - 灰色
|
|
2433
|
+
xmlQuote: "#79c0ff"
|
|
2434
|
+
// 引号 - 亮蓝色
|
|
2435
|
+
}
|
|
2436
|
+
}, pr = {
|
|
2437
|
+
name: "min-light",
|
|
2438
|
+
colors: {
|
|
2439
|
+
// 背景色
|
|
2440
|
+
background: "#ffffff",
|
|
2441
|
+
surfaceBackground: "#fafafa",
|
|
2442
|
+
// 边框色
|
|
2443
|
+
border: "#e5e5e5",
|
|
2444
|
+
// 文本色
|
|
2445
|
+
text: "#171717",
|
|
2446
|
+
textSecondary: "#737373",
|
|
2447
|
+
// 按钮样式
|
|
2448
|
+
buttonBackground: "#fafafa",
|
|
2449
|
+
buttonBackgroundHover: "#f5f5f5",
|
|
2450
|
+
buttonBorder: "#e5e5e5",
|
|
2451
|
+
buttonText: "#171717",
|
|
2452
|
+
buttonPrimary: "#22c55e",
|
|
2453
|
+
buttonPrimaryHover: "#16a34a",
|
|
2454
|
+
// 状态指示
|
|
2455
|
+
success: "#22c55e",
|
|
2456
|
+
successBackground: "#dcfce7",
|
|
2457
|
+
error: "#ef4444",
|
|
2458
|
+
errorBackground: "#fee2e2",
|
|
2459
|
+
// XML 语法高亮
|
|
2460
|
+
xmlTag: "#16a34a",
|
|
2461
|
+
// 标签名 - 绿色
|
|
2462
|
+
xmlAttribute: "#2563eb",
|
|
2463
|
+
// 属性名 - 蓝色
|
|
2464
|
+
xmlAttributeValue: "#1e40af",
|
|
2465
|
+
// 属性值 - 深蓝
|
|
2466
|
+
xmlText: "#171717",
|
|
2467
|
+
// 文本内容 - 黑色
|
|
2468
|
+
xmlComment: "#737373",
|
|
2469
|
+
// 注释 - 灰色
|
|
2470
|
+
xmlCdata: "#9333ea",
|
|
2471
|
+
// CDATA - 紫色
|
|
2472
|
+
xmlDeclaration: "#ea580c",
|
|
2473
|
+
// 声明 - 橙色
|
|
2474
|
+
xmlBracket: "#737373",
|
|
2475
|
+
// 括号 - 灰色
|
|
2476
|
+
xmlEquals: "#737373",
|
|
2477
|
+
// 等号 - 灰色
|
|
2478
|
+
xmlQuote: "#2563eb"
|
|
2479
|
+
// 引号 - 蓝色
|
|
2480
|
+
}
|
|
2481
|
+
}, gr = {
|
|
2482
|
+
name: "slack-ochin",
|
|
2483
|
+
colors: {
|
|
2484
|
+
// 背景色
|
|
2485
|
+
background: "#fef5ed",
|
|
2486
|
+
surfaceBackground: "#fef9f3",
|
|
2487
|
+
// 边框色
|
|
2488
|
+
border: "#e9dcc9",
|
|
2489
|
+
// 文本色
|
|
2490
|
+
text: "#3d3c40",
|
|
2491
|
+
textSecondary: "#616061",
|
|
2492
|
+
// 按钮样式
|
|
2493
|
+
buttonBackground: "#fef9f3",
|
|
2494
|
+
buttonBackgroundHover: "#f9f0e5",
|
|
2495
|
+
buttonBorder: "#e9dcc9",
|
|
2496
|
+
buttonText: "#3d3c40",
|
|
2497
|
+
buttonPrimary: "#007a5a",
|
|
2498
|
+
buttonPrimaryHover: "#006644",
|
|
2499
|
+
// 状态指示
|
|
2500
|
+
success: "#007a5a",
|
|
2501
|
+
successBackground: "#d1f4e0",
|
|
2502
|
+
error: "#e01e5a",
|
|
2503
|
+
errorBackground: "#ffdbea",
|
|
2504
|
+
// XML 语法高亮
|
|
2505
|
+
xmlTag: "#007a5a",
|
|
2506
|
+
// 标签名 - 绿色
|
|
2507
|
+
xmlAttribute: "#1264a3",
|
|
2508
|
+
// 属性名 - 蓝色
|
|
2509
|
+
xmlAttributeValue: "#0b4c8c",
|
|
2510
|
+
// 属性值 - 深蓝
|
|
2511
|
+
xmlText: "#3d3c40",
|
|
2512
|
+
// 文本内容 - 黑色
|
|
2513
|
+
xmlComment: "#616061",
|
|
2514
|
+
// 注释 - 灰色
|
|
2515
|
+
xmlCdata: "#8b2eff",
|
|
2516
|
+
// CDATA - 紫色
|
|
2517
|
+
xmlDeclaration: "#e8912d",
|
|
2518
|
+
// 声明 - 橙色
|
|
2519
|
+
xmlBracket: "#616061",
|
|
2520
|
+
// 括号 - 灰色
|
|
2521
|
+
xmlEquals: "#616061",
|
|
2522
|
+
// 等号 - 灰色
|
|
2523
|
+
xmlQuote: "#1264a3"
|
|
2524
|
+
// 引号 - 蓝色
|
|
2525
|
+
}
|
|
2526
|
+
}, Be = {
|
|
2527
|
+
"github-light": fr,
|
|
2528
|
+
"github-dark": hr,
|
|
2529
|
+
"min-light": pr,
|
|
2530
|
+
"slack-ochin": gr
|
|
2531
|
+
}, mr = (r) => Be[r] || Be["github-light"], qe = ":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", yr = qe + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", br = "[" + qe + "][" + yr + "]*", vr = new RegExp("^" + br + "$");
|
|
2532
|
+
function Ye(r, e) {
|
|
2533
|
+
const t = [];
|
|
2534
|
+
let s = e.exec(r);
|
|
2535
|
+
for (; s; ) {
|
|
2536
|
+
const n = [];
|
|
2537
|
+
n.startIndex = e.lastIndex - s[0].length;
|
|
2538
|
+
const o = s.length;
|
|
2539
|
+
for (let i = 0; i < o; i++)
|
|
2540
|
+
n.push(s[i]);
|
|
2541
|
+
t.push(n), s = e.exec(r);
|
|
2542
|
+
}
|
|
2543
|
+
return t;
|
|
2544
|
+
}
|
|
2545
|
+
const ve = function(r) {
|
|
2546
|
+
const e = vr.exec(r);
|
|
2547
|
+
return !(e === null || typeof e > "u");
|
|
2548
|
+
};
|
|
2549
|
+
function Er(r) {
|
|
2550
|
+
return typeof r < "u";
|
|
2551
|
+
}
|
|
2552
|
+
const _r = {
|
|
2553
|
+
allowBooleanAttributes: !1,
|
|
2554
|
+
//A tag can have attributes without any value
|
|
2555
|
+
unpairedTags: []
|
|
2556
|
+
};
|
|
2557
|
+
function Qe(r, e) {
|
|
2558
|
+
e = Object.assign({}, _r, e);
|
|
2559
|
+
const t = [];
|
|
2560
|
+
let s = !1, n = !1;
|
|
2561
|
+
r[0] === "\uFEFF" && (r = r.substr(1));
|
|
2562
|
+
for (let o = 0; o < r.length; o++)
|
|
2563
|
+
if (r[o] === "<" && r[o + 1] === "?") {
|
|
2564
|
+
if (o += 2, o = Le(r, o), o.err) return o;
|
|
2565
|
+
} else if (r[o] === "<") {
|
|
2566
|
+
let i = o;
|
|
2567
|
+
if (o++, r[o] === "!") {
|
|
2568
|
+
o = Re(r, o);
|
|
2569
|
+
continue;
|
|
2570
|
+
} else {
|
|
2571
|
+
let u = !1;
|
|
2572
|
+
r[o] === "/" && (u = !0, o++);
|
|
2573
|
+
let a = "";
|
|
2574
|
+
for (; o < r.length && r[o] !== ">" && r[o] !== " " && r[o] !== " " && r[o] !== `
|
|
2575
|
+
` && r[o] !== "\r"; o++)
|
|
2576
|
+
a += r[o];
|
|
2577
|
+
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !Tr(a)) {
|
|
2578
|
+
let f;
|
|
2579
|
+
return a.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + a + "' is an invalid name.", U("InvalidTag", f, W(r, o));
|
|
2580
|
+
}
|
|
2581
|
+
const l = kr(r, o);
|
|
2582
|
+
if (l === !1)
|
|
2583
|
+
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.", W(r, o));
|
|
2584
|
+
let h = l.value;
|
|
2585
|
+
if (o = l.index, h[h.length - 1] === "/") {
|
|
2586
|
+
const f = o - h.length;
|
|
2587
|
+
h = h.substring(0, h.length - 1);
|
|
2588
|
+
const b = je(h, e);
|
|
2589
|
+
if (b === !0)
|
|
2590
|
+
s = !0;
|
|
2591
|
+
else
|
|
2592
|
+
return U(b.err.code, b.err.msg, W(r, f + b.err.line));
|
|
2593
|
+
} else if (u)
|
|
2594
|
+
if (l.tagClosed) {
|
|
2595
|
+
if (h.trim().length > 0)
|
|
2596
|
+
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", W(r, i));
|
|
2597
|
+
if (t.length === 0)
|
|
2598
|
+
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.", W(r, i));
|
|
2599
|
+
{
|
|
2600
|
+
const f = t.pop();
|
|
2601
|
+
if (a !== f.tagName) {
|
|
2602
|
+
let b = W(r, f.tagStartPos);
|
|
2603
|
+
return U(
|
|
2604
|
+
"InvalidTag",
|
|
2605
|
+
"Expected closing tag '" + f.tagName + "' (opened in line " + b.line + ", col " + b.col + ") instead of closing tag '" + a + "'.",
|
|
2606
|
+
W(r, i)
|
|
2607
|
+
);
|
|
2608
|
+
}
|
|
2609
|
+
t.length == 0 && (n = !0);
|
|
2610
|
+
}
|
|
2611
|
+
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", W(r, o));
|
|
2612
|
+
else {
|
|
2613
|
+
const f = je(h, e);
|
|
2614
|
+
if (f !== !0)
|
|
2615
|
+
return U(f.err.code, f.err.msg, W(r, o - h.length + f.err.line));
|
|
2616
|
+
if (n === !0)
|
|
2617
|
+
return U("InvalidXml", "Multiple possible root nodes found.", W(r, o));
|
|
2618
|
+
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2619
|
+
}
|
|
2620
|
+
for (o++; o < r.length; o++)
|
|
2621
|
+
if (r[o] === "<")
|
|
2622
|
+
if (r[o + 1] === "!") {
|
|
2623
|
+
o++, o = Re(r, o);
|
|
2624
|
+
continue;
|
|
2625
|
+
} else if (r[o + 1] === "?") {
|
|
2626
|
+
if (o = Le(r, ++o), o.err) return o;
|
|
2627
|
+
} else
|
|
2628
|
+
break;
|
|
2629
|
+
else if (r[o] === "&") {
|
|
2630
|
+
const f = Cr(r, o);
|
|
2631
|
+
if (f == -1)
|
|
2632
|
+
return U("InvalidChar", "char '&' is not expected.", W(r, o));
|
|
2633
|
+
o = f;
|
|
2634
|
+
} else if (n === !0 && !Ve(r[o]))
|
|
2635
|
+
return U("InvalidXml", "Extra text at the end", W(r, o));
|
|
2636
|
+
r[o] === "<" && o--;
|
|
2637
|
+
}
|
|
2638
|
+
} else {
|
|
2639
|
+
if (Ve(r[o]))
|
|
2640
|
+
continue;
|
|
2641
|
+
return U("InvalidChar", "char '" + r[o] + "' is not expected.", W(r, o));
|
|
2642
|
+
}
|
|
2643
|
+
if (s) {
|
|
2644
|
+
if (t.length == 1)
|
|
2645
|
+
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", W(r, t[0].tagStartPos));
|
|
2646
|
+
if (t.length > 0)
|
|
2647
|
+
return U("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
2648
|
+
} else return U("InvalidXml", "Start tag expected.", 1);
|
|
2649
|
+
return !0;
|
|
2650
|
+
}
|
|
2651
|
+
function Ve(r) {
|
|
2652
|
+
return r === " " || r === " " || r === `
|
|
2653
|
+
` || r === "\r";
|
|
2654
|
+
}
|
|
2655
|
+
function Le(r, e) {
|
|
2656
|
+
const t = e;
|
|
2657
|
+
for (; e < r.length; e++)
|
|
2658
|
+
if (r[e] == "?" || r[e] == " ") {
|
|
2659
|
+
const s = r.substr(t, e - t);
|
|
2660
|
+
if (e > 5 && s === "xml")
|
|
2661
|
+
return U("InvalidXml", "XML declaration allowed only at the start of the document.", W(r, e));
|
|
2662
|
+
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2663
|
+
e++;
|
|
2664
|
+
break;
|
|
2665
|
+
} else
|
|
2666
|
+
continue;
|
|
2667
|
+
}
|
|
2668
|
+
return e;
|
|
2669
|
+
}
|
|
2670
|
+
function Re(r, e) {
|
|
2671
|
+
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2672
|
+
for (e += 3; e < r.length; e++)
|
|
2673
|
+
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
2674
|
+
e += 2;
|
|
2675
|
+
break;
|
|
2676
|
+
}
|
|
2677
|
+
} else if (r.length > e + 8 && r[e + 1] === "D" && r[e + 2] === "O" && r[e + 3] === "C" && r[e + 4] === "T" && r[e + 5] === "Y" && r[e + 6] === "P" && r[e + 7] === "E") {
|
|
2678
|
+
let t = 1;
|
|
2679
|
+
for (e += 8; e < r.length; e++)
|
|
2680
|
+
if (r[e] === "<")
|
|
2681
|
+
t++;
|
|
2682
|
+
else if (r[e] === ">" && (t--, t === 0))
|
|
2683
|
+
break;
|
|
2684
|
+
} else if (r.length > e + 9 && r[e + 1] === "[" && r[e + 2] === "C" && r[e + 3] === "D" && r[e + 4] === "A" && r[e + 5] === "T" && r[e + 6] === "A" && r[e + 7] === "[") {
|
|
2685
|
+
for (e += 8; e < r.length; e++)
|
|
2686
|
+
if (r[e] === "]" && r[e + 1] === "]" && r[e + 2] === ">") {
|
|
2687
|
+
e += 2;
|
|
2688
|
+
break;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
return e;
|
|
2692
|
+
}
|
|
2693
|
+
const xr = '"', Nr = "'";
|
|
2694
|
+
function kr(r, e) {
|
|
2695
|
+
let t = "", s = "", n = !1;
|
|
2696
|
+
for (; e < r.length; e++) {
|
|
2697
|
+
if (r[e] === xr || r[e] === Nr)
|
|
2698
|
+
s === "" ? s = r[e] : s !== r[e] || (s = "");
|
|
2699
|
+
else if (r[e] === ">" && s === "") {
|
|
2700
|
+
n = !0;
|
|
2701
|
+
break;
|
|
2702
|
+
}
|
|
2703
|
+
t += r[e];
|
|
2704
|
+
}
|
|
2705
|
+
return s !== "" ? !1 : {
|
|
2706
|
+
value: t,
|
|
2707
|
+
index: e,
|
|
2708
|
+
tagClosed: n
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
const Ar = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
2712
|
+
function je(r, e) {
|
|
2713
|
+
const t = Ye(r, Ar), s = {};
|
|
2714
|
+
for (let n = 0; n < t.length; n++) {
|
|
2715
|
+
if (t[n][1].length === 0)
|
|
2716
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' has no space in starting.", pe(t[n]));
|
|
2717
|
+
if (t[n][3] !== void 0 && t[n][4] === void 0)
|
|
2718
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' is without value.", pe(t[n]));
|
|
2719
|
+
if (t[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
2720
|
+
return U("InvalidAttr", "boolean attribute '" + t[n][2] + "' is not allowed.", pe(t[n]));
|
|
2721
|
+
const o = t[n][2];
|
|
2722
|
+
if (!Or(o))
|
|
2723
|
+
return U("InvalidAttr", "Attribute '" + o + "' is an invalid name.", pe(t[n]));
|
|
2724
|
+
if (!s.hasOwnProperty(o))
|
|
2725
|
+
s[o] = 1;
|
|
2726
|
+
else
|
|
2727
|
+
return U("InvalidAttr", "Attribute '" + o + "' is repeated.", pe(t[n]));
|
|
2728
|
+
}
|
|
2729
|
+
return !0;
|
|
2730
|
+
}
|
|
2731
|
+
function wr(r, e) {
|
|
2732
|
+
let t = /\d/;
|
|
2733
|
+
for (r[e] === "x" && (e++, t = /[\da-fA-F]/); e < r.length; e++) {
|
|
2734
|
+
if (r[e] === ";")
|
|
2735
|
+
return e;
|
|
2736
|
+
if (!r[e].match(t))
|
|
2737
|
+
break;
|
|
2738
|
+
}
|
|
2739
|
+
return -1;
|
|
2740
|
+
}
|
|
2741
|
+
function Cr(r, e) {
|
|
2742
|
+
if (e++, r[e] === ";")
|
|
2743
|
+
return -1;
|
|
2744
|
+
if (r[e] === "#")
|
|
2745
|
+
return e++, wr(r, e);
|
|
2746
|
+
let t = 0;
|
|
2747
|
+
for (; e < r.length; e++, t++)
|
|
2748
|
+
if (!(r[e].match(/\w/) && t < 20)) {
|
|
2749
|
+
if (r[e] === ";")
|
|
2750
|
+
break;
|
|
2751
|
+
return -1;
|
|
2752
|
+
}
|
|
2753
|
+
return e;
|
|
2754
|
+
}
|
|
2755
|
+
function U(r, e, t) {
|
|
2756
|
+
return {
|
|
2757
|
+
err: {
|
|
2758
|
+
code: r,
|
|
2759
|
+
msg: e,
|
|
2760
|
+
line: t.line || t,
|
|
2761
|
+
col: t.col
|
|
2762
|
+
}
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
function Or(r) {
|
|
2766
|
+
return ve(r);
|
|
2767
|
+
}
|
|
2768
|
+
function Tr(r) {
|
|
2769
|
+
return ve(r);
|
|
2770
|
+
}
|
|
2771
|
+
function W(r, e) {
|
|
2772
|
+
const t = r.substring(0, e).split(/\r?\n/);
|
|
2773
|
+
return {
|
|
2774
|
+
line: t.length,
|
|
2775
|
+
// column number is last line's length + 1, because column numbering starts at 1:
|
|
2776
|
+
col: t[t.length - 1].length + 1
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
function pe(r) {
|
|
2780
|
+
return r.startIndex + r[1].length;
|
|
2781
|
+
}
|
|
2782
|
+
const Pr = {
|
|
2783
|
+
preserveOrder: !1,
|
|
2784
|
+
attributeNamePrefix: "@_",
|
|
2785
|
+
attributesGroupName: !1,
|
|
2786
|
+
textNodeName: "#text",
|
|
2787
|
+
ignoreAttributes: !0,
|
|
2788
|
+
removeNSPrefix: !1,
|
|
2789
|
+
// remove NS from tag name or attribute name if true
|
|
2790
|
+
allowBooleanAttributes: !1,
|
|
2791
|
+
//a tag can have attributes without any value
|
|
2792
|
+
//ignoreRootElement : false,
|
|
2793
|
+
parseTagValue: !0,
|
|
2794
|
+
parseAttributeValue: !1,
|
|
2795
|
+
trimValues: !0,
|
|
2796
|
+
//Trim string values of tag and attributes
|
|
2797
|
+
cdataPropName: !1,
|
|
2798
|
+
numberParseOptions: {
|
|
2799
|
+
hex: !0,
|
|
2800
|
+
leadingZeros: !0,
|
|
2801
|
+
eNotation: !0
|
|
2802
|
+
},
|
|
2803
|
+
tagValueProcessor: function(r, e) {
|
|
2804
|
+
return e;
|
|
2805
|
+
},
|
|
2806
|
+
attributeValueProcessor: function(r, e) {
|
|
2807
|
+
return e;
|
|
2315
2808
|
},
|
|
2316
2809
|
stopNodes: [],
|
|
2317
2810
|
//nested tags will not be parsed even for errors
|
|
@@ -2330,12 +2823,12 @@ const ur = {
|
|
|
2330
2823
|
},
|
|
2331
2824
|
// skipEmptyListItem: false
|
|
2332
2825
|
captureMetaData: !1
|
|
2333
|
-
},
|
|
2334
|
-
return Object.assign({},
|
|
2826
|
+
}, $r = function(r) {
|
|
2827
|
+
return Object.assign({}, Pr, r);
|
|
2335
2828
|
};
|
|
2336
|
-
let
|
|
2337
|
-
typeof Symbol != "function" ?
|
|
2338
|
-
|
|
2829
|
+
let me;
|
|
2830
|
+
typeof Symbol != "function" ? me = "@@xmlMetadata" : me = Symbol("XML Node Metadata");
|
|
2831
|
+
class oe {
|
|
2339
2832
|
constructor(e) {
|
|
2340
2833
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
2341
2834
|
}
|
|
@@ -2343,14 +2836,14 @@ let oe = class {
|
|
|
2343
2836
|
e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: t });
|
|
2344
2837
|
}
|
|
2345
2838
|
addChild(e, t) {
|
|
2346
|
-
e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({ [e.tagname]: e.child, ":@": e[":@"] }) : this.child.push({ [e.tagname]: e.child }), t !== void 0 && (this.child[this.child.length - 1][
|
|
2839
|
+
e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({ [e.tagname]: e.child, ":@": e[":@"] }) : this.child.push({ [e.tagname]: e.child }), t !== void 0 && (this.child[this.child.length - 1][me] = { startIndex: t });
|
|
2347
2840
|
}
|
|
2348
2841
|
/** symbol used for metadata */
|
|
2349
2842
|
static getMetaDataSymbol() {
|
|
2350
|
-
return
|
|
2843
|
+
return me;
|
|
2351
2844
|
}
|
|
2352
|
-
}
|
|
2353
|
-
class
|
|
2845
|
+
}
|
|
2846
|
+
class Sr {
|
|
2354
2847
|
constructor(e) {
|
|
2355
2848
|
this.suppressValidationErr = !e;
|
|
2356
2849
|
}
|
|
@@ -2392,11 +2885,11 @@ class dr {
|
|
|
2392
2885
|
return { entities: s, i: t };
|
|
2393
2886
|
}
|
|
2394
2887
|
readEntityExp(e, t) {
|
|
2395
|
-
t =
|
|
2888
|
+
t = G(e, t);
|
|
2396
2889
|
let s = "";
|
|
2397
2890
|
for (; t < e.length && !/\s/.test(e[t]) && e[t] !== '"' && e[t] !== "'"; )
|
|
2398
2891
|
s += e[t], t++;
|
|
2399
|
-
if (
|
|
2892
|
+
if (ge(s), t = G(e, t), !this.suppressValidationErr) {
|
|
2400
2893
|
if (e.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
2401
2894
|
throw new Error("External entities are not supported");
|
|
2402
2895
|
if (e[t] === "%")
|
|
@@ -2406,18 +2899,18 @@ class dr {
|
|
|
2406
2899
|
return [t, n] = this.readIdentifierVal(e, t, "entity"), t--, [s, n, t];
|
|
2407
2900
|
}
|
|
2408
2901
|
readNotationExp(e, t) {
|
|
2409
|
-
t =
|
|
2902
|
+
t = G(e, t);
|
|
2410
2903
|
let s = "";
|
|
2411
2904
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2412
2905
|
s += e[t], t++;
|
|
2413
|
-
!this.suppressValidationErr &&
|
|
2906
|
+
!this.suppressValidationErr && ge(s), t = G(e, t);
|
|
2414
2907
|
const n = e.substring(t, t + 6).toUpperCase();
|
|
2415
2908
|
if (!this.suppressValidationErr && n !== "SYSTEM" && n !== "PUBLIC")
|
|
2416
2909
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);
|
|
2417
|
-
t += n.length, t =
|
|
2910
|
+
t += n.length, t = G(e, t);
|
|
2418
2911
|
let o = null, i = null;
|
|
2419
2912
|
if (n === "PUBLIC")
|
|
2420
|
-
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t =
|
|
2913
|
+
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t = G(e, t), (e[t] === '"' || e[t] === "'") && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"));
|
|
2421
2914
|
else if (n === "SYSTEM" && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !i))
|
|
2422
2915
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
2423
2916
|
return { notationName: s, publicIdentifier: o, systemIdentifier: i, index: --t };
|
|
@@ -2434,13 +2927,13 @@ class dr {
|
|
|
2434
2927
|
return t++, [t, n];
|
|
2435
2928
|
}
|
|
2436
2929
|
readElementExp(e, t) {
|
|
2437
|
-
t =
|
|
2930
|
+
t = G(e, t);
|
|
2438
2931
|
let s = "";
|
|
2439
2932
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2440
2933
|
s += e[t], t++;
|
|
2441
|
-
if (!this.suppressValidationErr && !
|
|
2934
|
+
if (!this.suppressValidationErr && !ve(s))
|
|
2442
2935
|
throw new Error(`Invalid element name: "${s}"`);
|
|
2443
|
-
t =
|
|
2936
|
+
t = G(e, t);
|
|
2444
2937
|
let n = "";
|
|
2445
2938
|
if (e[t] === "E" && se(e, "MPTY", t)) t += 4;
|
|
2446
2939
|
else if (e[t] === "A" && se(e, "NY", t)) t += 2;
|
|
@@ -2458,20 +2951,20 @@ class dr {
|
|
|
2458
2951
|
};
|
|
2459
2952
|
}
|
|
2460
2953
|
readAttlistExp(e, t) {
|
|
2461
|
-
t =
|
|
2954
|
+
t = G(e, t);
|
|
2462
2955
|
let s = "";
|
|
2463
2956
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2464
2957
|
s += e[t], t++;
|
|
2465
|
-
|
|
2958
|
+
ge(s), t = G(e, t);
|
|
2466
2959
|
let n = "";
|
|
2467
2960
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2468
2961
|
n += e[t], t++;
|
|
2469
|
-
if (!
|
|
2962
|
+
if (!ge(n))
|
|
2470
2963
|
throw new Error(`Invalid attribute name: "${n}"`);
|
|
2471
|
-
t =
|
|
2964
|
+
t = G(e, t);
|
|
2472
2965
|
let o = "";
|
|
2473
2966
|
if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
|
|
2474
|
-
if (o = "NOTATION", t += 8, t =
|
|
2967
|
+
if (o = "NOTATION", t += 8, t = G(e, t), e[t] !== "(")
|
|
2475
2968
|
throw new Error(`Expected '(', found "${e[t]}"`);
|
|
2476
2969
|
t++;
|
|
2477
2970
|
let u = [];
|
|
@@ -2479,9 +2972,9 @@ class dr {
|
|
|
2479
2972
|
let a = "";
|
|
2480
2973
|
for (; t < e.length && e[t] !== "|" && e[t] !== ")"; )
|
|
2481
2974
|
a += e[t], t++;
|
|
2482
|
-
if (a = a.trim(), !
|
|
2975
|
+
if (a = a.trim(), !ge(a))
|
|
2483
2976
|
throw new Error(`Invalid notation name: "${a}"`);
|
|
2484
|
-
u.push(a), e[t] === "|" && (t++, t =
|
|
2977
|
+
u.push(a), e[t] === "|" && (t++, t = G(e, t));
|
|
2485
2978
|
}
|
|
2486
2979
|
if (e[t] !== ")")
|
|
2487
2980
|
throw new Error("Unterminated list of notations");
|
|
@@ -2493,7 +2986,7 @@ class dr {
|
|
|
2493
2986
|
if (!this.suppressValidationErr && !u.includes(o.toUpperCase()))
|
|
2494
2987
|
throw new Error(`Invalid attribute type: "${o}"`);
|
|
2495
2988
|
}
|
|
2496
|
-
t =
|
|
2989
|
+
t = G(e, t);
|
|
2497
2990
|
let i = "";
|
|
2498
2991
|
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
2992
|
elementName: s,
|
|
@@ -2504,7 +2997,7 @@ class dr {
|
|
|
2504
2997
|
};
|
|
2505
2998
|
}
|
|
2506
2999
|
}
|
|
2507
|
-
const
|
|
3000
|
+
const G = (r, e) => {
|
|
2508
3001
|
for (; e < r.length && /\s/.test(r[e]); )
|
|
2509
3002
|
e++;
|
|
2510
3003
|
return e;
|
|
@@ -2514,12 +3007,12 @@ function se(r, e, t) {
|
|
|
2514
3007
|
if (e[s] !== r[t + s + 1]) return !1;
|
|
2515
3008
|
return !0;
|
|
2516
3009
|
}
|
|
2517
|
-
function
|
|
2518
|
-
if (
|
|
3010
|
+
function ge(r) {
|
|
3011
|
+
if (ve(r))
|
|
2519
3012
|
return r;
|
|
2520
3013
|
throw new Error(`Invalid entity name ${r}`);
|
|
2521
3014
|
}
|
|
2522
|
-
const
|
|
3015
|
+
const Ir = /^[-+]?0x[a-fA-F0-9]+$/, Br = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, Vr = {
|
|
2523
3016
|
hex: !0,
|
|
2524
3017
|
// oct: false,
|
|
2525
3018
|
leadingZeros: !0,
|
|
@@ -2527,20 +3020,20 @@ const fr = /^[-+]?0x[a-fA-F0-9]+$/, hr = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, p
|
|
|
2527
3020
|
eNotation: !0
|
|
2528
3021
|
//skipLike: /regex/
|
|
2529
3022
|
};
|
|
2530
|
-
function
|
|
2531
|
-
if (e = Object.assign({},
|
|
3023
|
+
function Lr(r, e = {}) {
|
|
3024
|
+
if (e = Object.assign({}, Vr, e), !r || typeof r != "string") return r;
|
|
2532
3025
|
let t = r.trim();
|
|
2533
3026
|
if (e.skipLike !== void 0 && e.skipLike.test(t)) return r;
|
|
2534
3027
|
if (r === "0") return 0;
|
|
2535
|
-
if (e.hex &&
|
|
2536
|
-
return
|
|
3028
|
+
if (e.hex && Ir.test(t))
|
|
3029
|
+
return Ur(t, 16);
|
|
2537
3030
|
if (t.search(/.+[eE].+/) !== -1)
|
|
2538
|
-
return
|
|
3031
|
+
return jr(r, t, e);
|
|
2539
3032
|
{
|
|
2540
|
-
const s =
|
|
3033
|
+
const s = Br.exec(t);
|
|
2541
3034
|
if (s) {
|
|
2542
3035
|
const n = s[1] || "", o = s[2];
|
|
2543
|
-
let i =
|
|
3036
|
+
let i = Mr(s[3]);
|
|
2544
3037
|
const u = n ? (
|
|
2545
3038
|
// 0., -00., 000.
|
|
2546
3039
|
r[o.length + 1] === "."
|
|
@@ -2561,10 +3054,10 @@ function gr(r, e = {}) {
|
|
|
2561
3054
|
return r;
|
|
2562
3055
|
}
|
|
2563
3056
|
}
|
|
2564
|
-
const
|
|
2565
|
-
function
|
|
3057
|
+
const Rr = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
3058
|
+
function jr(r, e, t) {
|
|
2566
3059
|
if (!t.eNotation) return r;
|
|
2567
|
-
const s = e.match(
|
|
3060
|
+
const s = e.match(Rr);
|
|
2568
3061
|
if (s) {
|
|
2569
3062
|
let n = s[1] || "";
|
|
2570
3063
|
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2], u = n ? (
|
|
@@ -2575,23 +3068,23 @@ function br(r, e, t) {
|
|
|
2575
3068
|
} else
|
|
2576
3069
|
return r;
|
|
2577
3070
|
}
|
|
2578
|
-
function
|
|
3071
|
+
function Mr(r) {
|
|
2579
3072
|
return r && r.indexOf(".") !== -1 && (r = r.replace(/0+$/, ""), r === "." ? r = "0" : r[0] === "." ? r = "0" + r : r[r.length - 1] === "." && (r = r.substring(0, r.length - 1))), r;
|
|
2580
3073
|
}
|
|
2581
|
-
function
|
|
3074
|
+
function Ur(r, e) {
|
|
2582
3075
|
if (parseInt) return parseInt(r, e);
|
|
2583
3076
|
if (Number.parseInt) return Number.parseInt(r, e);
|
|
2584
3077
|
if (window && window.parseInt) return window.parseInt(r, e);
|
|
2585
3078
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
2586
3079
|
}
|
|
2587
|
-
function
|
|
3080
|
+
function We(r) {
|
|
2588
3081
|
return typeof r == "function" ? r : Array.isArray(r) ? (e) => {
|
|
2589
3082
|
for (const t of r)
|
|
2590
3083
|
if (typeof t == "string" && e === t || t instanceof RegExp && t.test(e))
|
|
2591
3084
|
return !0;
|
|
2592
3085
|
} : () => !1;
|
|
2593
3086
|
}
|
|
2594
|
-
class
|
|
3087
|
+
class Fr {
|
|
2595
3088
|
constructor(e) {
|
|
2596
3089
|
this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
2597
3090
|
apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
@@ -2614,10 +3107,10 @@ class vr {
|
|
|
2614
3107
|
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
2615
3108
|
num_dec: { regex: /&#([0-9]{1,7});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 10)) },
|
|
2616
3109
|
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 16)) }
|
|
2617
|
-
}, this.addExternalEntities =
|
|
3110
|
+
}, this.addExternalEntities = Xr, this.parseXml = Qr, this.parseTextData = Hr, this.resolveNameSpace = Kr, this.buildAttributesMap = Yr, this.isItStopNode = zr, this.replaceEntitiesValue = Gr, this.readStopNodeData = Jr, this.saveTextToParentTag = Zr, this.addChild = Wr, this.ignoreAttributesFn = We(this.options.ignoreAttributes);
|
|
2618
3111
|
}
|
|
2619
3112
|
}
|
|
2620
|
-
function
|
|
3113
|
+
function Xr(r) {
|
|
2621
3114
|
const e = Object.keys(r);
|
|
2622
3115
|
for (let t = 0; t < e.length; t++) {
|
|
2623
3116
|
const s = e[t];
|
|
@@ -2627,14 +3120,14 @@ function _r(r) {
|
|
|
2627
3120
|
};
|
|
2628
3121
|
}
|
|
2629
3122
|
}
|
|
2630
|
-
function
|
|
3123
|
+
function Hr(r, e, t, s, n, o, i) {
|
|
2631
3124
|
if (r !== void 0 && (this.options.trimValues && !s && (r = r.trim()), r.length > 0)) {
|
|
2632
3125
|
i || (r = this.replaceEntitiesValue(r));
|
|
2633
3126
|
const u = this.options.tagValueProcessor(e, r, t, n, o);
|
|
2634
|
-
return u == null ? r : typeof u != typeof r || u !== r ? u : this.options.trimValues ?
|
|
3127
|
+
return u == null ? r : typeof u != typeof r || u !== r ? u : this.options.trimValues ? Ce(r, this.options.parseTagValue, this.options.numberParseOptions) : r.trim() === r ? Ce(r, this.options.parseTagValue, this.options.numberParseOptions) : r;
|
|
2635
3128
|
}
|
|
2636
3129
|
}
|
|
2637
|
-
function
|
|
3130
|
+
function Kr(r) {
|
|
2638
3131
|
if (this.options.removeNSPrefix) {
|
|
2639
3132
|
const e = r.split(":"), t = r.charAt(0) === "/" ? "/" : "";
|
|
2640
3133
|
if (e[0] === "xmlns")
|
|
@@ -2643,10 +3136,10 @@ function Nr(r) {
|
|
|
2643
3136
|
}
|
|
2644
3137
|
return r;
|
|
2645
3138
|
}
|
|
2646
|
-
const
|
|
2647
|
-
function
|
|
3139
|
+
const qr = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
3140
|
+
function Yr(r, e, t) {
|
|
2648
3141
|
if (this.options.ignoreAttributes !== !0 && typeof r == "string") {
|
|
2649
|
-
const s = Ye(r,
|
|
3142
|
+
const s = Ye(r, qr), n = s.length, o = {};
|
|
2650
3143
|
for (let i = 0; i < n; i++) {
|
|
2651
3144
|
const u = this.resolveNameSpace(s[i][1]);
|
|
2652
3145
|
if (this.ignoreAttributesFn(u, e))
|
|
@@ -2656,7 +3149,7 @@ function wr(r, e, t) {
|
|
|
2656
3149
|
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), a !== void 0) {
|
|
2657
3150
|
this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a);
|
|
2658
3151
|
const h = this.options.attributeValueProcessor(u, a, e);
|
|
2659
|
-
h == null ? o[l] = a : typeof h != typeof a || h !== a ? o[l] = h : o[l] =
|
|
3152
|
+
h == null ? o[l] = a : typeof h != typeof a || h !== a ? o[l] = h : o[l] = Ce(
|
|
2660
3153
|
a,
|
|
2661
3154
|
this.options.parseAttributeValue,
|
|
2662
3155
|
this.options.numberParseOptions
|
|
@@ -2672,20 +3165,20 @@ function wr(r, e, t) {
|
|
|
2672
3165
|
return o;
|
|
2673
3166
|
}
|
|
2674
3167
|
}
|
|
2675
|
-
const
|
|
3168
|
+
const Qr = function(r) {
|
|
2676
3169
|
r = r.replace(/\r\n?/g, `
|
|
2677
3170
|
`);
|
|
2678
3171
|
const e = new oe("!xml");
|
|
2679
3172
|
let t = e, s = "", n = "";
|
|
2680
|
-
const o = new
|
|
3173
|
+
const o = new Sr(this.options.processEntities);
|
|
2681
3174
|
for (let i = 0; i < r.length; i++)
|
|
2682
3175
|
if (r[i] === "<")
|
|
2683
3176
|
if (r[i + 1] === "/") {
|
|
2684
3177
|
const a = ie(r, ">", i, "Closing Tag is not closed.");
|
|
2685
3178
|
let l = r.substring(i + 2, a).trim();
|
|
2686
3179
|
if (this.options.removeNSPrefix) {
|
|
2687
|
-
const
|
|
2688
|
-
|
|
3180
|
+
const b = l.indexOf(":");
|
|
3181
|
+
b !== -1 && (l = l.substr(b + 1));
|
|
2689
3182
|
}
|
|
2690
3183
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && (s = this.saveTextToParentTag(s, t, n));
|
|
2691
3184
|
const h = n.substring(n.lastIndexOf(".") + 1);
|
|
@@ -2719,32 +3212,32 @@ const Ar = function(r) {
|
|
|
2719
3212
|
} else {
|
|
2720
3213
|
let a = we(r, i, this.options.removeNSPrefix), l = a.tagName;
|
|
2721
3214
|
const h = a.rawTagName;
|
|
2722
|
-
let f = a.tagExp,
|
|
3215
|
+
let f = a.tagExp, b = a.attrExpPresent, m = a.closeIndex;
|
|
2723
3216
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && s && t.tagname !== "!xml" && (s = this.saveTextToParentTag(s, t, n, !1));
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2726
|
-
const
|
|
3217
|
+
const w = t;
|
|
3218
|
+
w && this.options.unpairedTags.indexOf(w.tagname) !== -1 && (t = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), l !== e.tagname && (n += n ? "." + l : l);
|
|
3219
|
+
const S = i;
|
|
2727
3220
|
if (this.isItStopNode(this.options.stopNodes, n, l)) {
|
|
2728
|
-
let
|
|
3221
|
+
let _ = "";
|
|
2729
3222
|
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1)
|
|
2730
3223
|
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), i = a.closeIndex;
|
|
2731
3224
|
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
2732
3225
|
i = a.closeIndex;
|
|
2733
3226
|
else {
|
|
2734
|
-
const
|
|
2735
|
-
if (!
|
|
2736
|
-
i =
|
|
3227
|
+
const H = this.readStopNodeData(r, h, m + 1);
|
|
3228
|
+
if (!H) throw new Error(`Unexpected end of ${h}`);
|
|
3229
|
+
i = H.i, _ = H.tagContent;
|
|
2737
3230
|
}
|
|
2738
|
-
const
|
|
2739
|
-
l !== f &&
|
|
3231
|
+
const j = new oe(l);
|
|
3232
|
+
l !== f && b && (j[":@"] = this.buildAttributesMap(f, n, l)), _ && (_ = this.parseTextData(_, l, n, !0, b, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), j.add(this.options.textNodeName, _), this.addChild(t, j, n, S);
|
|
2740
3233
|
} else {
|
|
2741
3234
|
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1) {
|
|
2742
3235
|
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
|
|
2744
|
-
l !== f &&
|
|
3236
|
+
const _ = new oe(l);
|
|
3237
|
+
l !== f && b && (_[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, _, n, S), n = n.substr(0, n.lastIndexOf("."));
|
|
2745
3238
|
} else {
|
|
2746
|
-
const
|
|
2747
|
-
this.tagsNodeStack.push(t), l !== f &&
|
|
3239
|
+
const _ = new oe(l);
|
|
3240
|
+
this.tagsNodeStack.push(t), l !== f && b && (_[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, _, n, S), t = _;
|
|
2748
3241
|
}
|
|
2749
3242
|
s = "", i = m;
|
|
2750
3243
|
}
|
|
@@ -2753,12 +3246,12 @@ const Ar = function(r) {
|
|
|
2753
3246
|
s += r[i];
|
|
2754
3247
|
return e.child;
|
|
2755
3248
|
};
|
|
2756
|
-
function
|
|
3249
|
+
function Wr(r, e, t, s) {
|
|
2757
3250
|
this.options.captureMetaData || (s = void 0);
|
|
2758
3251
|
const n = this.options.updateTag(e.tagname, t, e[":@"]);
|
|
2759
3252
|
n === !1 || (typeof n == "string" && (e.tagname = n), r.addChild(e, s));
|
|
2760
3253
|
}
|
|
2761
|
-
const
|
|
3254
|
+
const Gr = function(r) {
|
|
2762
3255
|
if (this.options.processEntities) {
|
|
2763
3256
|
for (let e in this.docTypeEntities) {
|
|
2764
3257
|
const t = this.docTypeEntities[e];
|
|
@@ -2777,7 +3270,7 @@ const Or = function(r) {
|
|
|
2777
3270
|
}
|
|
2778
3271
|
return r;
|
|
2779
3272
|
};
|
|
2780
|
-
function
|
|
3273
|
+
function Zr(r, e, t, s) {
|
|
2781
3274
|
return r && (s === void 0 && (s = e.child.length === 0), r = this.parseTextData(
|
|
2782
3275
|
r,
|
|
2783
3276
|
e.tagname,
|
|
@@ -2787,7 +3280,7 @@ function Tr(r, e, t, s) {
|
|
|
2787
3280
|
s
|
|
2788
3281
|
), r !== void 0 && r !== "" && e.add(this.options.textNodeName, r), r = ""), r;
|
|
2789
3282
|
}
|
|
2790
|
-
function
|
|
3283
|
+
function zr(r, e, t) {
|
|
2791
3284
|
const s = "*." + t;
|
|
2792
3285
|
for (const n in r) {
|
|
2793
3286
|
const o = r[n];
|
|
@@ -2795,7 +3288,7 @@ function Pr(r, e, t) {
|
|
|
2795
3288
|
}
|
|
2796
3289
|
return !1;
|
|
2797
3290
|
}
|
|
2798
|
-
function
|
|
3291
|
+
function Dr(r, e, t = ">") {
|
|
2799
3292
|
let s, n = "";
|
|
2800
3293
|
for (let o = e; o < r.length; o++) {
|
|
2801
3294
|
let i = r[o];
|
|
@@ -2826,7 +3319,7 @@ function ie(r, e, t, s) {
|
|
|
2826
3319
|
return n + e.length - 1;
|
|
2827
3320
|
}
|
|
2828
3321
|
function we(r, e, t, s = ">") {
|
|
2829
|
-
const n =
|
|
3322
|
+
const n = Dr(r, e + 1, s);
|
|
2830
3323
|
if (!n) return;
|
|
2831
3324
|
let o = n.data;
|
|
2832
3325
|
const i = n.index, u = o.search(/\s/);
|
|
@@ -2845,7 +3338,7 @@ function we(r, e, t, s = ">") {
|
|
|
2845
3338
|
rawTagName: h
|
|
2846
3339
|
};
|
|
2847
3340
|
}
|
|
2848
|
-
function
|
|
3341
|
+
function Jr(r, e, t) {
|
|
2849
3342
|
const s = t;
|
|
2850
3343
|
let n = 1;
|
|
2851
3344
|
for (; t < r.length; t++)
|
|
@@ -2869,22 +3362,22 @@ function Ir(r, e, t) {
|
|
|
2869
3362
|
o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && n++, t = o.closeIndex);
|
|
2870
3363
|
}
|
|
2871
3364
|
}
|
|
2872
|
-
function
|
|
3365
|
+
function Ce(r, e, t) {
|
|
2873
3366
|
if (e && typeof r == "string") {
|
|
2874
3367
|
const s = r.trim();
|
|
2875
|
-
return s === "true" ? !0 : s === "false" ? !1 :
|
|
3368
|
+
return s === "true" ? !0 : s === "false" ? !1 : Lr(r, t);
|
|
2876
3369
|
} else
|
|
2877
|
-
return
|
|
3370
|
+
return Er(r) ? r : "";
|
|
2878
3371
|
}
|
|
2879
|
-
const
|
|
2880
|
-
function
|
|
3372
|
+
const ke = oe.getMetaDataSymbol();
|
|
3373
|
+
function en(r, e) {
|
|
2881
3374
|
return Ge(r, e);
|
|
2882
3375
|
}
|
|
2883
3376
|
function Ge(r, e, t) {
|
|
2884
3377
|
let s;
|
|
2885
3378
|
const n = {};
|
|
2886
3379
|
for (let o = 0; o < r.length; o++) {
|
|
2887
|
-
const i = r[o], u =
|
|
3380
|
+
const i = r[o], u = tn(i);
|
|
2888
3381
|
let a = "";
|
|
2889
3382
|
if (t === void 0 ? a = u : a = t + "." + u, u === e.textNodeName)
|
|
2890
3383
|
s === void 0 ? s = i[u] : s += "" + i[u];
|
|
@@ -2893,21 +3386,21 @@ function Ge(r, e, t) {
|
|
|
2893
3386
|
continue;
|
|
2894
3387
|
if (i[u]) {
|
|
2895
3388
|
let l = Ge(i[u], e, a);
|
|
2896
|
-
const h =
|
|
2897
|
-
i[
|
|
3389
|
+
const h = nn(l, e);
|
|
3390
|
+
i[ke] !== void 0 && (l[ke] = i[ke]), i[":@"] ? rn(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
3391
|
}
|
|
2899
3392
|
}
|
|
2900
3393
|
}
|
|
2901
3394
|
return typeof s == "string" ? s.length > 0 && (n[e.textNodeName] = s) : s !== void 0 && (n[e.textNodeName] = s), n;
|
|
2902
3395
|
}
|
|
2903
|
-
function
|
|
3396
|
+
function tn(r) {
|
|
2904
3397
|
const e = Object.keys(r);
|
|
2905
3398
|
for (let t = 0; t < e.length; t++) {
|
|
2906
3399
|
const s = e[t];
|
|
2907
3400
|
if (s !== ":@") return s;
|
|
2908
3401
|
}
|
|
2909
3402
|
}
|
|
2910
|
-
function
|
|
3403
|
+
function rn(r, e, t, s) {
|
|
2911
3404
|
if (e) {
|
|
2912
3405
|
const n = Object.keys(e), o = n.length;
|
|
2913
3406
|
for (let i = 0; i < o; i++) {
|
|
@@ -2916,13 +3409,13 @@ function Vr(r, e, t, s) {
|
|
|
2916
3409
|
}
|
|
2917
3410
|
}
|
|
2918
3411
|
}
|
|
2919
|
-
function
|
|
3412
|
+
function nn(r, e) {
|
|
2920
3413
|
const { textNodeName: t } = e, s = Object.keys(r).length;
|
|
2921
3414
|
return !!(s === 0 || s === 1 && (r[t] || typeof r[t] == "boolean" || r[t] === 0));
|
|
2922
3415
|
}
|
|
2923
|
-
class
|
|
3416
|
+
class sn {
|
|
2924
3417
|
constructor(e) {
|
|
2925
|
-
this.externalEntities = {}, this.options =
|
|
3418
|
+
this.externalEntities = {}, this.options = $r(e);
|
|
2926
3419
|
}
|
|
2927
3420
|
/**
|
|
2928
3421
|
* Parse XML dats to JS object
|
|
@@ -2936,14 +3429,14 @@ class Rr {
|
|
|
2936
3429
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
2937
3430
|
if (t) {
|
|
2938
3431
|
t === !0 && (t = {});
|
|
2939
|
-
const o =
|
|
3432
|
+
const o = Qe(e, t);
|
|
2940
3433
|
if (o !== !0)
|
|
2941
3434
|
throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
|
|
2942
3435
|
}
|
|
2943
|
-
const s = new
|
|
3436
|
+
const s = new Fr(this.options);
|
|
2944
3437
|
s.addExternalEntities(this.externalEntities);
|
|
2945
3438
|
const n = s.parseXml(e);
|
|
2946
|
-
return this.options.preserveOrder || n === void 0 ? n :
|
|
3439
|
+
return this.options.preserveOrder || n === void 0 ? n : en(n, this.options);
|
|
2947
3440
|
}
|
|
2948
3441
|
/**
|
|
2949
3442
|
* Add Entity which is not by default supported by this library
|
|
@@ -2973,21 +3466,21 @@ class Rr {
|
|
|
2973
3466
|
return oe.getMetaDataSymbol();
|
|
2974
3467
|
}
|
|
2975
3468
|
}
|
|
2976
|
-
const
|
|
3469
|
+
const on = `
|
|
2977
3470
|
`;
|
|
2978
|
-
function
|
|
3471
|
+
function an(r, e) {
|
|
2979
3472
|
let t = "";
|
|
2980
|
-
return e.format && e.indentBy.length > 0 && (t =
|
|
3473
|
+
return e.format && e.indentBy.length > 0 && (t = on), Ze(r, e, "", t);
|
|
2981
3474
|
}
|
|
2982
|
-
function
|
|
3475
|
+
function Ze(r, e, t, s) {
|
|
2983
3476
|
let n = "", o = !1;
|
|
2984
3477
|
for (let i = 0; i < r.length; i++) {
|
|
2985
|
-
const u = r[i], a =
|
|
3478
|
+
const u = r[i], a = ln(u);
|
|
2986
3479
|
if (a === void 0) continue;
|
|
2987
3480
|
let l = "";
|
|
2988
3481
|
if (t.length === 0 ? l = a : l = `${t}.${a}`, a === e.textNodeName) {
|
|
2989
|
-
let
|
|
2990
|
-
|
|
3482
|
+
let w = u[a];
|
|
3483
|
+
un(l, e) || (w = e.tagValueProcessor(a, w), w = ze(w, e)), o && (n += s), n += w, o = !1;
|
|
2991
3484
|
continue;
|
|
2992
3485
|
} else if (a === e.cdataPropName) {
|
|
2993
3486
|
o && (n += s), n += `<![CDATA[${u[a][0][e.textNodeName]}]]>`, o = !1;
|
|
@@ -2996,19 +3489,19 @@ function We(r, e, t, s) {
|
|
|
2996
3489
|
n += s + `<!--${u[a][0][e.textNodeName]}-->`, o = !0;
|
|
2997
3490
|
continue;
|
|
2998
3491
|
} else if (a[0] === "?") {
|
|
2999
|
-
const
|
|
3000
|
-
let
|
|
3001
|
-
|
|
3492
|
+
const w = Me(u[":@"], e), S = a === "?xml" ? "" : s;
|
|
3493
|
+
let _ = u[a][0][e.textNodeName];
|
|
3494
|
+
_ = _.length !== 0 ? " " + _ : "", n += S + `<${a}${_}${w}?>`, o = !0;
|
|
3002
3495
|
continue;
|
|
3003
3496
|
}
|
|
3004
3497
|
let h = s;
|
|
3005
3498
|
h !== "" && (h += e.indentBy);
|
|
3006
|
-
const f =
|
|
3007
|
-
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n +=
|
|
3499
|
+
const f = Me(u[":@"], e), b = s + `<${a}${f}`, m = Ze(u[a], e, l, h);
|
|
3500
|
+
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n += b + ">" : n += b + "/>" : (!m || m.length === 0) && e.suppressEmptyNode ? n += b + "/>" : m && m.endsWith(">") ? n += b + `>${m}${s}</${a}>` : (n += b + ">", m && s !== "" && (m.includes("/>") || m.includes("</")) ? n += s + e.indentBy + m + s : n += m, n += `</${a}>`), o = !0;
|
|
3008
3501
|
}
|
|
3009
3502
|
return n;
|
|
3010
3503
|
}
|
|
3011
|
-
function
|
|
3504
|
+
function ln(r) {
|
|
3012
3505
|
const e = Object.keys(r);
|
|
3013
3506
|
for (let t = 0; t < e.length; t++) {
|
|
3014
3507
|
const s = e[t];
|
|
@@ -3016,24 +3509,24 @@ function Ur(r) {
|
|
|
3016
3509
|
return s;
|
|
3017
3510
|
}
|
|
3018
3511
|
}
|
|
3019
|
-
function
|
|
3512
|
+
function Me(r, e) {
|
|
3020
3513
|
let t = "";
|
|
3021
3514
|
if (r && !e.ignoreAttributes)
|
|
3022
3515
|
for (let s in r) {
|
|
3023
3516
|
if (!r.hasOwnProperty(s)) continue;
|
|
3024
3517
|
let n = e.attributeValueProcessor(s, r[s]);
|
|
3025
|
-
n =
|
|
3518
|
+
n = ze(n, e), n === !0 && e.suppressBooleanAttributes ? t += ` ${s.substr(e.attributeNamePrefix.length)}` : t += ` ${s.substr(e.attributeNamePrefix.length)}="${n}"`;
|
|
3026
3519
|
}
|
|
3027
3520
|
return t;
|
|
3028
3521
|
}
|
|
3029
|
-
function
|
|
3522
|
+
function un(r, e) {
|
|
3030
3523
|
r = r.substr(0, r.length - e.textNodeName.length - 1);
|
|
3031
3524
|
let t = r.substr(r.lastIndexOf(".") + 1);
|
|
3032
3525
|
for (let s in e.stopNodes)
|
|
3033
3526
|
if (e.stopNodes[s] === r || e.stopNodes[s] === "*." + t) return !0;
|
|
3034
3527
|
return !1;
|
|
3035
3528
|
}
|
|
3036
|
-
function
|
|
3529
|
+
function ze(r, e) {
|
|
3037
3530
|
if (r && r.length > 0 && e.processEntities)
|
|
3038
3531
|
for (let t = 0; t < e.entities.length; t++) {
|
|
3039
3532
|
const s = e.entities[t];
|
|
@@ -3041,7 +3534,7 @@ function Ze(r, e) {
|
|
|
3041
3534
|
}
|
|
3042
3535
|
return r;
|
|
3043
3536
|
}
|
|
3044
|
-
const
|
|
3537
|
+
const cn = {
|
|
3045
3538
|
attributeNamePrefix: "@_",
|
|
3046
3539
|
attributesGroupName: !1,
|
|
3047
3540
|
textNodeName: "#text",
|
|
@@ -3076,16 +3569,16 @@ const Xr = {
|
|
|
3076
3569
|
oneListGroup: !1
|
|
3077
3570
|
};
|
|
3078
3571
|
function ne(r) {
|
|
3079
|
-
this.options = Object.assign({},
|
|
3572
|
+
this.options = Object.assign({}, cn, r), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
3080
3573
|
return !1;
|
|
3081
|
-
} : (this.ignoreAttributesFn =
|
|
3574
|
+
} : (this.ignoreAttributesFn = We(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = hn), this.processTextOrObjNode = dn, this.options.format ? (this.indentate = fn, this.tagEndChar = `>
|
|
3082
3575
|
`, this.newLine = `
|
|
3083
3576
|
`) : (this.indentate = function() {
|
|
3084
3577
|
return "";
|
|
3085
3578
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
3086
3579
|
}
|
|
3087
3580
|
ne.prototype.build = function(r) {
|
|
3088
|
-
return this.options.preserveOrder ?
|
|
3581
|
+
return this.options.preserveOrder ? an(r, this.options) : (Array.isArray(r) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (r = {
|
|
3089
3582
|
[this.options.arrayNodeName]: r
|
|
3090
3583
|
}), this.j2x(r, 0, []).val);
|
|
3091
3584
|
};
|
|
@@ -3119,13 +3612,13 @@ ne.prototype.j2x = function(r, e, t) {
|
|
|
3119
3612
|
i[0] === "?" ? n += this.indentate(e) + "<" + i + "?" + this.tagEndChar : n += this.indentate(e) + "<" + i + "/" + this.tagEndChar;
|
|
3120
3613
|
else if (typeof f == "object")
|
|
3121
3614
|
if (this.options.oneListGroup) {
|
|
3122
|
-
const
|
|
3123
|
-
a +=
|
|
3615
|
+
const b = this.j2x(f, e + 1, t.concat(i));
|
|
3616
|
+
a += b.val, this.options.attributesGroupName && f.hasOwnProperty(this.options.attributesGroupName) && (l += b.attrStr);
|
|
3124
3617
|
} else
|
|
3125
3618
|
a += this.processTextOrObjNode(f, i, e, t);
|
|
3126
3619
|
else if (this.options.oneListGroup) {
|
|
3127
|
-
let
|
|
3128
|
-
|
|
3620
|
+
let b = this.options.tagValueProcessor(i, f);
|
|
3621
|
+
b = this.replaceEntitiesValue(b), a += b;
|
|
3129
3622
|
} else
|
|
3130
3623
|
a += this.buildTextValNode(f, i, "", e);
|
|
3131
3624
|
}
|
|
@@ -3141,7 +3634,7 @@ ne.prototype.j2x = function(r, e, t) {
|
|
|
3141
3634
|
ne.prototype.buildAttrPairStr = function(r, e) {
|
|
3142
3635
|
return e = this.options.attributeValueProcessor(r, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + r : " " + r + '="' + e + '"';
|
|
3143
3636
|
};
|
|
3144
|
-
function
|
|
3637
|
+
function dn(r, e, t, s) {
|
|
3145
3638
|
const n = this.j2x(r, t + 1, s.concat(e));
|
|
3146
3639
|
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
3640
|
}
|
|
@@ -3177,15 +3670,15 @@ ne.prototype.replaceEntitiesValue = function(r) {
|
|
|
3177
3670
|
}
|
|
3178
3671
|
return r;
|
|
3179
3672
|
};
|
|
3180
|
-
function
|
|
3673
|
+
function fn(r) {
|
|
3181
3674
|
return this.options.indentBy.repeat(r);
|
|
3182
3675
|
}
|
|
3183
|
-
function
|
|
3676
|
+
function hn(r) {
|
|
3184
3677
|
return r.startsWith(this.options.attributeNamePrefix) && r !== this.options.textNodeName ? r.substr(this.attrPrefixLen) : !1;
|
|
3185
3678
|
}
|
|
3186
|
-
const
|
|
3187
|
-
validate:
|
|
3188
|
-
},
|
|
3679
|
+
const pn = {
|
|
3680
|
+
validate: Qe
|
|
3681
|
+
}, gn = {
|
|
3189
3682
|
ignoreAttributes: !1,
|
|
3190
3683
|
// 保留属性
|
|
3191
3684
|
attributeNamePrefix: "@_",
|
|
@@ -3198,540 +3691,140 @@ const qr = {
|
|
|
3198
3691
|
// 注释属性名
|
|
3199
3692
|
cdataPropName: "__cdata",
|
|
3200
3693
|
// CDATA 属性名
|
|
3201
|
-
preserveOrder: !
|
|
3202
|
-
//
|
|
3694
|
+
preserveOrder: !0,
|
|
3695
|
+
// 保留顺序(使用数组结构以保留注释位置)
|
|
3203
3696
|
parseAttributeValue: !1,
|
|
3204
|
-
// 不解析属性值(保持字符串)
|
|
3205
|
-
trimValues: !0,
|
|
3206
|
-
// 去除首尾空白
|
|
3207
|
-
parseTagValue: !1,
|
|
3208
|
-
// 不解析标签值(保持字符串)
|
|
3209
|
-
processEntities: !0,
|
|
3210
|
-
// 处理实体
|
|
3211
|
-
htmlEntities: !1,
|
|
3212
|
-
// 不是 HTML 实体
|
|
3213
|
-
ignoreNameSpace: !1,
|
|
3214
|
-
// 保留命名空间
|
|
3215
|
-
allowBooleanAttributes: !0,
|
|
3216
|
-
// 允许布尔属性
|
|
3217
|
-
unpairedTags: [],
|
|
3218
|
-
// 未配对的标签
|
|
3219
|
-
stopNodes: [],
|
|
3220
|
-
// 停止解析的节点
|
|
3221
|
-
alwaysCreateTextNode: !1
|
|
3222
|
-
// 仅在有文本时创建文本节点
|
|
3223
|
-
},
|
|
3224
|
-
ignoreAttributes: !1,
|
|
3225
|
-
attributeNamePrefix: "@_",
|
|
3226
|
-
textNodeName: "#text",
|
|
3227
|
-
format: !0,
|
|
3228
|
-
// 格式化输出
|
|
3229
|
-
indentBy: " ",
|
|
3230
|
-
// 缩进 2 空格
|
|
3231
|
-
suppressEmptyNode: !1,
|
|
3232
|
-
// 不抑制空节点
|
|
3233
|
-
suppressBooleanAttributes: !1,
|
|
3234
|
-
suppressUnpairedNode: !1
|
|
3235
|
-
},
|
|
3236
|
-
try {
|
|
3237
|
-
const e =
|
|
3238
|
-
allowBooleanAttributes: !0
|
|
3239
|
-
});
|
|
3240
|
-
return e === !0 ? { valid: !0 } : {
|
|
3241
|
-
valid: !1,
|
|
3242
|
-
error: `Line ${e.err.line}: ${e.err.msg}`
|
|
3243
|
-
};
|
|
3244
|
-
} catch (e) {
|
|
3245
|
-
return {
|
|
3246
|
-
valid: !1,
|
|
3247
|
-
error: e instanceof Error ? e.message : "Unknown validation error"
|
|
3248
|
-
};
|
|
3249
|
-
}
|
|
3250
|
-
}, ze = (r, e) => {
|
|
3251
|
-
try {
|
|
3252
|
-
return new Rr({
|
|
3253
|
-
...Qr,
|
|
3254
|
-
...e
|
|
3255
|
-
}).parse(r);
|
|
3256
|
-
} catch (t) {
|
|
3257
|
-
throw new Error(
|
|
3258
|
-
`XML 解析失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3259
|
-
);
|
|
3260
|
-
}
|
|
3261
|
-
}, Te = (r, e) => {
|
|
3262
|
-
try {
|
|
3263
|
-
let s = new ne({
|
|
3264
|
-
...Gr,
|
|
3265
|
-
format: e?.format ?? !0,
|
|
3266
|
-
indentBy: e?.indentBy ?? " "
|
|
3267
|
-
}).build(r);
|
|
3268
|
-
return e?.showDeclaration !== !1 && !s.startsWith("<?xml") && (s = `<?xml version="1.0" encoding="UTF-8"?>
|
|
3269
|
-
` + s), s;
|
|
3270
|
-
} catch (t) {
|
|
3271
|
-
throw new Error(
|
|
3272
|
-
`XML 构建失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3273
|
-
);
|
|
3274
|
-
}
|
|
3275
|
-
}, Zr = (r) => Te(r, { format: !1, showDeclaration: !1 }), zr = (r, e) => {
|
|
3276
|
-
const t = ze(r);
|
|
3277
|
-
return Te(t, e);
|
|
3278
|
-
}, Dr = (r) => {
|
|
3279
|
-
if (!r || typeof r != "object") return {};
|
|
3280
|
-
const e = {};
|
|
3281
|
-
return Object.keys(r).forEach((t) => {
|
|
3282
|
-
if (t.startsWith("@_")) {
|
|
3283
|
-
const s = t.substring(2);
|
|
3284
|
-
e[s] = r[t];
|
|
3285
|
-
}
|
|
3286
|
-
}), e;
|
|
3287
|
-
}, Jr = (r) => !r || typeof r != "object" ? typeof r == "string" ? r : null : r["#text"] || null, en = {
|
|
3288
|
-
key: 0,
|
|
3289
|
-
class: "xml-node__element"
|
|
3290
|
-
}, tn = {
|
|
3291
|
-
key: 0,
|
|
3292
|
-
class: "xml-node__line"
|
|
3293
|
-
}, rn = { key: 1 }, nn = { class: "xml-node__line" }, sn = ["title"], on = { key: 1 }, an = ["title"], ln = {
|
|
3294
|
-
key: 0,
|
|
3295
|
-
class: "xml-node__children"
|
|
3296
|
-
}, un = {
|
|
3297
|
-
key: 0,
|
|
3298
|
-
class: "xml-node__text"
|
|
3299
|
-
}, cn = {
|
|
3300
|
-
key: 1,
|
|
3301
|
-
class: "xml-node__line"
|
|
3302
|
-
}, dn = {
|
|
3303
|
-
key: 1,
|
|
3304
|
-
class: "xml-node__text"
|
|
3305
|
-
}, fn = {
|
|
3306
|
-
key: 2,
|
|
3307
|
-
class: "xml-node__comment"
|
|
3308
|
-
}, hn = {
|
|
3309
|
-
key: 3,
|
|
3310
|
-
class: "xml-node__cdata"
|
|
3311
|
-
}, pn = /* @__PURE__ */ me({
|
|
3312
|
-
__name: "XmlNode",
|
|
3313
|
-
props: {
|
|
3314
|
-
value: {},
|
|
3315
|
-
tagName: {},
|
|
3316
|
-
level: { default: 0 },
|
|
3317
|
-
path: { default: "" },
|
|
3318
|
-
expanded: {},
|
|
3319
|
-
theme: {}
|
|
3320
|
-
},
|
|
3321
|
-
emits: ["toggle-expand", "copy"],
|
|
3322
|
-
setup(r, { emit: e }) {
|
|
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
|
-
if (typeof t.value != "object" || t.value === null)
|
|
3325
|
-
return [];
|
|
3326
|
-
const p = [];
|
|
3327
|
-
return Object.keys(t.value).forEach((T) => {
|
|
3328
|
-
if (T.startsWith("@_") || T === "#text") return;
|
|
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
|
-
O.value && s("toggle-expand", n.value);
|
|
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);
|
|
3344
|
-
return x(), N("div", {
|
|
3345
|
-
class: "xml-node",
|
|
3346
|
-
style: I({ paddingLeft: p.level > 0 ? "16px" : "0" })
|
|
3347
|
-
}, [
|
|
3348
|
-
i.value ? (x(), N("div", en, [
|
|
3349
|
-
P.value ? (x(), N("div", tn, [
|
|
3350
|
-
E("span", {
|
|
3351
|
-
class: "xml-node__bracket",
|
|
3352
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3353
|
-
}, "<", 4),
|
|
3354
|
-
E("span", {
|
|
3355
|
-
class: "xml-node__tag",
|
|
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,
|
|
3360
|
-
class: "xml-node__attribute"
|
|
3361
|
-
}, [
|
|
3362
|
-
E("span", {
|
|
3363
|
-
class: "xml-node__attr-name",
|
|
3364
|
-
style: I({ color: p.theme.colors.xmlAttribute })
|
|
3365
|
-
}, R(X), 5),
|
|
3366
|
-
E("span", {
|
|
3367
|
-
class: "xml-node__equals",
|
|
3368
|
-
style: I({ color: p.theme.colors.xmlEquals })
|
|
3369
|
-
}, "=", 4),
|
|
3370
|
-
E("span", {
|
|
3371
|
-
class: "xml-node__quote",
|
|
3372
|
-
style: I({ color: p.theme.colors.xmlQuote })
|
|
3373
|
-
}, '"', 4),
|
|
3374
|
-
E("span", {
|
|
3375
|
-
class: "xml-node__attr-value",
|
|
3376
|
-
style: I({ color: p.theme.colors.xmlAttributeValue })
|
|
3377
|
-
}, R(S), 5),
|
|
3378
|
-
E("span", {
|
|
3379
|
-
class: "xml-node__quote",
|
|
3380
|
-
style: I({ color: p.theme.colors.xmlQuote })
|
|
3381
|
-
}, '"', 4)
|
|
3382
|
-
]))), 128)),
|
|
3383
|
-
E("span", {
|
|
3384
|
-
class: "xml-node__bracket",
|
|
3385
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3386
|
-
}, ">", 4),
|
|
3387
|
-
E("span", {
|
|
3388
|
-
class: "xml-node__text-content",
|
|
3389
|
-
style: I({ color: p.theme.colors.xmlText })
|
|
3390
|
-
}, R(f.value), 5),
|
|
3391
|
-
E("span", {
|
|
3392
|
-
class: "xml-node__bracket",
|
|
3393
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3394
|
-
}, "</", 4),
|
|
3395
|
-
E("span", {
|
|
3396
|
-
class: "xml-node__tag",
|
|
3397
|
-
style: I({ color: p.theme.colors.xmlTag })
|
|
3398
|
-
}, R(p.tagName), 5),
|
|
3399
|
-
E("span", {
|
|
3400
|
-
class: "xml-node__bracket",
|
|
3401
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3402
|
-
}, ">", 4)
|
|
3403
|
-
])) : (x(), N("div", rn, [
|
|
3404
|
-
E("div", nn, [
|
|
3405
|
-
O.value ? (x(), N("span", {
|
|
3406
|
-
key: 0,
|
|
3407
|
-
class: "xml-node__clickable-part",
|
|
3408
|
-
onClick: T[0] || (T[0] = (S) => M()),
|
|
3409
|
-
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3410
|
-
}, [
|
|
3411
|
-
E("span", {
|
|
3412
|
-
class: "xml-node__bracket",
|
|
3413
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3414
|
-
}, "<", 4),
|
|
3415
|
-
E("span", {
|
|
3416
|
-
class: "xml-node__tag",
|
|
3417
|
-
style: I({ color: p.theme.colors.xmlTag })
|
|
3418
|
-
}, R(p.tagName), 5)
|
|
3419
|
-
], 8, sn)) : (x(), N("span", on, [
|
|
3420
|
-
E("span", {
|
|
3421
|
-
class: "xml-node__bracket",
|
|
3422
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3423
|
-
}, "<", 4),
|
|
3424
|
-
E("span", {
|
|
3425
|
-
class: "xml-node__tag",
|
|
3426
|
-
style: I({ color: p.theme.colors.xmlTag })
|
|
3427
|
-
}, R(p.tagName), 5)
|
|
3428
|
-
])),
|
|
3429
|
-
(x(!0), N(he, null, pe(h.value, (S, X) => (x(), N("span", {
|
|
3430
|
-
key: X,
|
|
3431
|
-
class: "xml-node__attribute"
|
|
3432
|
-
}, [
|
|
3433
|
-
E("span", {
|
|
3434
|
-
class: "xml-node__attr-name",
|
|
3435
|
-
style: I({ color: p.theme.colors.xmlAttribute })
|
|
3436
|
-
}, R(X), 5),
|
|
3437
|
-
E("span", {
|
|
3438
|
-
class: "xml-node__equals",
|
|
3439
|
-
style: I({ color: p.theme.colors.xmlEquals })
|
|
3440
|
-
}, "=", 4),
|
|
3441
|
-
E("span", {
|
|
3442
|
-
class: "xml-node__quote",
|
|
3443
|
-
style: I({ color: p.theme.colors.xmlQuote })
|
|
3444
|
-
}, '"', 4),
|
|
3445
|
-
E("span", {
|
|
3446
|
-
class: "xml-node__attr-value",
|
|
3447
|
-
style: I({ color: p.theme.colors.xmlAttributeValue })
|
|
3448
|
-
}, R(S), 5),
|
|
3449
|
-
E("span", {
|
|
3450
|
-
class: "xml-node__quote",
|
|
3451
|
-
style: I({ color: p.theme.colors.xmlQuote })
|
|
3452
|
-
}, '"', 4)
|
|
3453
|
-
]))), 128)),
|
|
3454
|
-
O.value ? (x(), N("span", {
|
|
3455
|
-
key: 2,
|
|
3456
|
-
class: "xml-node__clickable-part",
|
|
3457
|
-
onClick: T[1] || (T[1] = (S) => M()),
|
|
3458
|
-
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3459
|
-
}, [
|
|
3460
|
-
E("span", {
|
|
3461
|
-
class: "xml-node__bracket",
|
|
3462
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3463
|
-
}, ">", 4)
|
|
3464
|
-
], 8, an)) : (x(), N("span", {
|
|
3465
|
-
key: 3,
|
|
3466
|
-
class: "xml-node__bracket",
|
|
3467
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3468
|
-
}, R(O.value ? ">" : "/>"), 5)),
|
|
3469
|
-
!o.value && O.value ? (x(), N("span", {
|
|
3470
|
-
key: 4,
|
|
3471
|
-
class: "xml-node__collapsed xml-node__collapsed--clickable",
|
|
3472
|
-
style: I({ color: p.theme.colors.textSecondary }),
|
|
3473
|
-
onClick: T[2] || (T[2] = (S) => M()),
|
|
3474
|
-
title: "Click to expand"
|
|
3475
|
-
}, "...", 4)) : F("", !0)
|
|
3476
|
-
]),
|
|
3477
|
-
o.value && O.value ? (x(), N("div", ln, [
|
|
3478
|
-
A.value.length === 0 && f.value.trim() ? (x(), N("div", un, [
|
|
3479
|
-
E("span", {
|
|
3480
|
-
class: "xml-node__text-content",
|
|
3481
|
-
style: I({ color: p.theme.colors.xmlText })
|
|
3482
|
-
}, R(f.value), 5)
|
|
3483
|
-
])) : F("", !0),
|
|
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))
|
|
3494
|
-
}, null, 8, ["value", "tag-name", "level", "path", "expanded", "theme"]))), 128))
|
|
3495
|
-
])) : F("", !0),
|
|
3496
|
-
o.value && O.value ? (x(), N("div", cn, [
|
|
3497
|
-
E("span", {
|
|
3498
|
-
class: "xml-node__clickable-part",
|
|
3499
|
-
onClick: T[5] || (T[5] = (S) => M()),
|
|
3500
|
-
title: "Click to collapse"
|
|
3501
|
-
}, [
|
|
3502
|
-
E("span", {
|
|
3503
|
-
class: "xml-node__bracket",
|
|
3504
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3505
|
-
}, "</", 4),
|
|
3506
|
-
E("span", {
|
|
3507
|
-
class: "xml-node__tag",
|
|
3508
|
-
style: I({ color: p.theme.colors.xmlTag })
|
|
3509
|
-
}, R(p.tagName), 5),
|
|
3510
|
-
E("span", {
|
|
3511
|
-
class: "xml-node__bracket",
|
|
3512
|
-
style: I({ color: p.theme.colors.xmlBracket })
|
|
3513
|
-
}, ">", 4)
|
|
3514
|
-
])
|
|
3515
|
-
])) : F("", !0)
|
|
3516
|
-
]))
|
|
3517
|
-
])) : u.value ? (x(), N("div", dn, [
|
|
3518
|
-
E("span", {
|
|
3519
|
-
class: "xml-node__text-content",
|
|
3520
|
-
style: I({ color: p.theme.colors.xmlText })
|
|
3521
|
-
}, R(f.value), 5)
|
|
3522
|
-
])) : a.value ? (x(), N("div", fn, [
|
|
3523
|
-
E("span", {
|
|
3524
|
-
style: I({ color: p.theme.colors.xmlComment })
|
|
3525
|
-
}, " <!-- " + R(y.value) + " --> ", 5)
|
|
3526
|
-
])) : l.value ? (x(), N("div", hn, [
|
|
3527
|
-
E("span", {
|
|
3528
|
-
style: I({ color: p.theme.colors.xmlCdata })
|
|
3529
|
-
}, " <![CDATA[" + R(m.value) + "]]> ", 5)
|
|
3530
|
-
])) : F("", !0)
|
|
3531
|
-
], 4);
|
|
3697
|
+
// 不解析属性值(保持字符串)
|
|
3698
|
+
trimValues: !0,
|
|
3699
|
+
// 去除首尾空白
|
|
3700
|
+
parseTagValue: !1,
|
|
3701
|
+
// 不解析标签值(保持字符串)
|
|
3702
|
+
processEntities: !0,
|
|
3703
|
+
// 处理实体
|
|
3704
|
+
htmlEntities: !1,
|
|
3705
|
+
// 不是 HTML 实体
|
|
3706
|
+
ignoreNameSpace: !1,
|
|
3707
|
+
// 保留命名空间
|
|
3708
|
+
allowBooleanAttributes: !0,
|
|
3709
|
+
// 允许布尔属性
|
|
3710
|
+
unpairedTags: [],
|
|
3711
|
+
// 未配对的标签
|
|
3712
|
+
stopNodes: [],
|
|
3713
|
+
// 停止解析的节点
|
|
3714
|
+
alwaysCreateTextNode: !1
|
|
3715
|
+
// 仅在有文本时创建文本节点
|
|
3716
|
+
}, mn = {
|
|
3717
|
+
ignoreAttributes: !1,
|
|
3718
|
+
attributeNamePrefix: "@_",
|
|
3719
|
+
textNodeName: "#text",
|
|
3720
|
+
format: !0,
|
|
3721
|
+
// 格式化输出
|
|
3722
|
+
indentBy: " ",
|
|
3723
|
+
// 缩进 2 空格
|
|
3724
|
+
suppressEmptyNode: !1,
|
|
3725
|
+
// 不抑制空节点
|
|
3726
|
+
suppressBooleanAttributes: !1,
|
|
3727
|
+
suppressUnpairedNode: !1
|
|
3728
|
+
}, yn = (r) => {
|
|
3729
|
+
try {
|
|
3730
|
+
const e = pn.validate(r, {
|
|
3731
|
+
allowBooleanAttributes: !0
|
|
3732
|
+
});
|
|
3733
|
+
return e === !0 ? { valid: !0 } : {
|
|
3734
|
+
valid: !1,
|
|
3735
|
+
error: `Line ${e.err.line}: ${e.err.msg}`
|
|
3736
|
+
};
|
|
3737
|
+
} catch (e) {
|
|
3738
|
+
return {
|
|
3739
|
+
valid: !1,
|
|
3740
|
+
error: e instanceof Error ? e.message : "Unknown validation error"
|
|
3532
3741
|
};
|
|
3533
3742
|
}
|
|
3534
|
-
}
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
textSecondary: "#57606a",
|
|
3545
|
-
// 按钮样式
|
|
3546
|
-
buttonBackground: "#f6f8fa",
|
|
3547
|
-
buttonBackgroundHover: "#f3f4f6",
|
|
3548
|
-
buttonBorder: "#d0d7de",
|
|
3549
|
-
buttonText: "#24292f",
|
|
3550
|
-
buttonPrimary: "#1f883d",
|
|
3551
|
-
buttonPrimaryHover: "#1a7f37",
|
|
3552
|
-
// 状态指示
|
|
3553
|
-
success: "#1f883d",
|
|
3554
|
-
successBackground: "#dafbe1",
|
|
3555
|
-
error: "#cf222e",
|
|
3556
|
-
errorBackground: "#ffebe9",
|
|
3557
|
-
// XML 语法高亮
|
|
3558
|
-
xmlTag: "#116329",
|
|
3559
|
-
// 标签名 - 绿色
|
|
3560
|
-
xmlAttribute: "#0550ae",
|
|
3561
|
-
// 属性名 - 蓝色
|
|
3562
|
-
xmlAttributeValue: "#0a3069",
|
|
3563
|
-
// 属性值 - 深蓝
|
|
3564
|
-
xmlText: "#24292f",
|
|
3565
|
-
// 文本内容 - 黑色
|
|
3566
|
-
xmlComment: "#6e7781",
|
|
3567
|
-
// 注释 - 灰色
|
|
3568
|
-
xmlCdata: "#8250df",
|
|
3569
|
-
// CDATA - 紫色
|
|
3570
|
-
xmlDeclaration: "#953800",
|
|
3571
|
-
// 声明 - 橙色
|
|
3572
|
-
xmlBracket: "#6e7781",
|
|
3573
|
-
// 括号 - 灰色
|
|
3574
|
-
xmlEquals: "#6e7781",
|
|
3575
|
-
// 等号 - 灰色
|
|
3576
|
-
xmlQuote: "#0550ae"
|
|
3577
|
-
// 引号 - 蓝色
|
|
3743
|
+
}, De = (r, e) => {
|
|
3744
|
+
try {
|
|
3745
|
+
return new sn({
|
|
3746
|
+
...gn,
|
|
3747
|
+
...e
|
|
3748
|
+
}).parse(r);
|
|
3749
|
+
} catch (t) {
|
|
3750
|
+
throw new Error(
|
|
3751
|
+
`XML 解析失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3752
|
+
);
|
|
3578
3753
|
}
|
|
3579
|
-
},
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
buttonBackgroundHover: "#30363d",
|
|
3593
|
-
buttonBorder: "#30363d",
|
|
3594
|
-
buttonText: "#c9d1d9",
|
|
3595
|
-
buttonPrimary: "#238636",
|
|
3596
|
-
buttonPrimaryHover: "#2ea043",
|
|
3597
|
-
// 状态指示
|
|
3598
|
-
success: "#3fb950",
|
|
3599
|
-
successBackground: "#0f2e1c",
|
|
3600
|
-
error: "#f85149",
|
|
3601
|
-
errorBackground: "#3d1319",
|
|
3602
|
-
// XML 语法高亮
|
|
3603
|
-
xmlTag: "#7ee787",
|
|
3604
|
-
// 标签名 - 亮绿色
|
|
3605
|
-
xmlAttribute: "#79c0ff",
|
|
3606
|
-
// 属性名 - 亮蓝色
|
|
3607
|
-
xmlAttributeValue: "#a5d6ff",
|
|
3608
|
-
// 属性值 - 淡蓝色
|
|
3609
|
-
xmlText: "#c9d1d9",
|
|
3610
|
-
// 文本内容 - 白色
|
|
3611
|
-
xmlComment: "#8b949e",
|
|
3612
|
-
// 注释 - 灰色
|
|
3613
|
-
xmlCdata: "#d2a8ff",
|
|
3614
|
-
// CDATA - 紫色
|
|
3615
|
-
xmlDeclaration: "#ffa657",
|
|
3616
|
-
// 声明 - 橙色
|
|
3617
|
-
xmlBracket: "#8b949e",
|
|
3618
|
-
// 括号 - 灰色
|
|
3619
|
-
xmlEquals: "#8b949e",
|
|
3620
|
-
// 等号 - 灰色
|
|
3621
|
-
xmlQuote: "#79c0ff"
|
|
3622
|
-
// 引号 - 亮蓝色
|
|
3754
|
+
}, Pe = (r, e) => {
|
|
3755
|
+
try {
|
|
3756
|
+
let s = new ne({
|
|
3757
|
+
...mn,
|
|
3758
|
+
format: e?.format ?? !0,
|
|
3759
|
+
indentBy: e?.indentBy ?? " "
|
|
3760
|
+
}).build(r);
|
|
3761
|
+
return e?.showDeclaration !== !1 && !s.startsWith("<?xml") && (s = `<?xml version="1.0" encoding="UTF-8"?>
|
|
3762
|
+
` + s), s;
|
|
3763
|
+
} catch (t) {
|
|
3764
|
+
throw new Error(
|
|
3765
|
+
`XML 构建失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3766
|
+
);
|
|
3623
3767
|
}
|
|
3624
|
-
},
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
xmlQuote: "#2563eb"
|
|
3667
|
-
// 引号 - 蓝色
|
|
3768
|
+
}, bn = (r) => Array.isArray(r) ? Ee(r, { format: !1 }) : Pe(r, { format: !1, showDeclaration: !1 }), vn = (r, e) => {
|
|
3769
|
+
const t = De(r);
|
|
3770
|
+
return Array.isArray(t) ? Ee(t, {
|
|
3771
|
+
indent: e?.indentBy
|
|
3772
|
+
}) : Pe(t, e);
|
|
3773
|
+
}, Ee = (r, e = {}) => {
|
|
3774
|
+
const t = e.indent !== void 0 ? e.indent : " ", s = e.level || 0, n = e.format !== !1, o = n ? t.repeat(s) : "", i = n ? `
|
|
3775
|
+
` : "";
|
|
3776
|
+
let u = "";
|
|
3777
|
+
for (const a of r) {
|
|
3778
|
+
if (a["?xml"]) {
|
|
3779
|
+
const _ = a[":@"] || {}, j = Object.entries(_).map(([H, p]) => `${H.startsWith("@_") ? H.substring(2) : H}="${p}"`).join(" ");
|
|
3780
|
+
u += `<?xml ${j}?>${i}`;
|
|
3781
|
+
continue;
|
|
3782
|
+
}
|
|
3783
|
+
if (a["#comment"]) {
|
|
3784
|
+
const _ = a["#comment"];
|
|
3785
|
+
if (Array.isArray(_) && _.length > 0) {
|
|
3786
|
+
const j = _[0]["#text"] || _[0];
|
|
3787
|
+
u += `${o}<!--${j}-->${i}`;
|
|
3788
|
+
}
|
|
3789
|
+
continue;
|
|
3790
|
+
}
|
|
3791
|
+
const l = Object.keys(a).find((_) => !_.startsWith(":") && !_.startsWith("#") && !_.startsWith("__"));
|
|
3792
|
+
if (!l) continue;
|
|
3793
|
+
const h = a[l], f = a[":@"] || {}, b = Object.entries(f).map(([_, j]) => `${_.startsWith("@_") ? _.substring(2) : _}="${j}"`).join(" "), m = b ? " " + b : "";
|
|
3794
|
+
if (!Array.isArray(h) || h.length === 0) {
|
|
3795
|
+
u += `${o}<${l}${m}/>${i}`;
|
|
3796
|
+
continue;
|
|
3797
|
+
}
|
|
3798
|
+
const w = h.length === 1 && h[0]["#text"] !== void 0;
|
|
3799
|
+
if (h.some((_) => _.__cdata)) {
|
|
3800
|
+
const _ = h.find((j) => j.__cdata);
|
|
3801
|
+
if (_) {
|
|
3802
|
+
const j = _.__cdata[0]["#text"] || "";
|
|
3803
|
+
u += `${o}<${l}${m}><![CDATA[${j}]]></${l}>${i}`;
|
|
3804
|
+
}
|
|
3805
|
+
} else if (w) {
|
|
3806
|
+
const _ = h[0]["#text"];
|
|
3807
|
+
u += `${o}<${l}${m}>${_}</${l}>${i}`;
|
|
3808
|
+
} else
|
|
3809
|
+
u += `${o}<${l}${m}>${i}`, u += Ee(h, { indent: t, level: s + 1, format: n }), u += `${o}</${l}>${i}`;
|
|
3668
3810
|
}
|
|
3811
|
+
return u;
|
|
3669
3812
|
}, En = {
|
|
3670
|
-
name: "slack-ochin",
|
|
3671
|
-
colors: {
|
|
3672
|
-
// 背景色
|
|
3673
|
-
background: "#fef5ed",
|
|
3674
|
-
surfaceBackground: "#fef9f3",
|
|
3675
|
-
// 边框色
|
|
3676
|
-
border: "#e9dcc9",
|
|
3677
|
-
// 文本色
|
|
3678
|
-
text: "#3d3c40",
|
|
3679
|
-
textSecondary: "#616061",
|
|
3680
|
-
// 按钮样式
|
|
3681
|
-
buttonBackground: "#fef9f3",
|
|
3682
|
-
buttonBackgroundHover: "#f9f0e5",
|
|
3683
|
-
buttonBorder: "#e9dcc9",
|
|
3684
|
-
buttonText: "#3d3c40",
|
|
3685
|
-
buttonPrimary: "#007a5a",
|
|
3686
|
-
buttonPrimaryHover: "#006644",
|
|
3687
|
-
// 状态指示
|
|
3688
|
-
success: "#007a5a",
|
|
3689
|
-
successBackground: "#d1f4e0",
|
|
3690
|
-
error: "#e01e5a",
|
|
3691
|
-
errorBackground: "#ffdbea",
|
|
3692
|
-
// XML 语法高亮
|
|
3693
|
-
xmlTag: "#007a5a",
|
|
3694
|
-
// 标签名 - 绿色
|
|
3695
|
-
xmlAttribute: "#1264a3",
|
|
3696
|
-
// 属性名 - 蓝色
|
|
3697
|
-
xmlAttributeValue: "#0b4c8c",
|
|
3698
|
-
// 属性值 - 深蓝
|
|
3699
|
-
xmlText: "#3d3c40",
|
|
3700
|
-
// 文本内容 - 黑色
|
|
3701
|
-
xmlComment: "#616061",
|
|
3702
|
-
// 注释 - 灰色
|
|
3703
|
-
xmlCdata: "#8b2eff",
|
|
3704
|
-
// CDATA - 紫色
|
|
3705
|
-
xmlDeclaration: "#e8912d",
|
|
3706
|
-
// 声明 - 橙色
|
|
3707
|
-
xmlBracket: "#616061",
|
|
3708
|
-
// 括号 - 灰色
|
|
3709
|
-
xmlEquals: "#616061",
|
|
3710
|
-
// 等号 - 灰色
|
|
3711
|
-
xmlQuote: "#1264a3"
|
|
3712
|
-
// 引号 - 蓝色
|
|
3713
|
-
}
|
|
3714
|
-
}, je = {
|
|
3715
|
-
"github-light": mn,
|
|
3716
|
-
"github-dark": bn,
|
|
3717
|
-
"min-light": yn,
|
|
3718
|
-
"slack-ochin": En
|
|
3719
|
-
}, vn = (r) => je[r] || je["github-light"], _n = {
|
|
3720
3813
|
key: 0,
|
|
3721
3814
|
class: "xml-format__toolbar"
|
|
3722
|
-
},
|
|
3815
|
+
}, _n = { class: "xml-format__actions" }, xn = ["disabled"], Nn = ["disabled"], kn = ["disabled"], An = ["disabled"], wn = ["disabled"], Cn = { class: "xml-format__info" }, On = {
|
|
3723
3816
|
key: 0,
|
|
3724
3817
|
class: "xml-format__status xml-format__status--success"
|
|
3725
|
-
},
|
|
3818
|
+
}, Tn = {
|
|
3726
3819
|
key: 1,
|
|
3727
3820
|
class: "xml-format__status xml-format__status--error"
|
|
3728
|
-
},
|
|
3821
|
+
}, Pn = { class: "xml-format__content" }, $n = {
|
|
3729
3822
|
key: 0,
|
|
3730
3823
|
class: "xml-format__error"
|
|
3731
|
-
},
|
|
3824
|
+
}, Sn = {
|
|
3732
3825
|
key: 1,
|
|
3733
3826
|
class: "xml-format__viewer"
|
|
3734
|
-
},
|
|
3827
|
+
}, In = /* @__PURE__ */ ye({
|
|
3735
3828
|
__name: "index",
|
|
3736
3829
|
props: {
|
|
3737
3830
|
modelValue: { default: "" },
|
|
@@ -3745,190 +3838,198 @@ const qr = {
|
|
|
3745
3838
|
},
|
|
3746
3839
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
3747
3840
|
setup(r, { expose: e, emit: t }) {
|
|
3748
|
-
|
|
3749
|
-
"
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
"
|
|
3753
|
-
|
|
3754
|
-
"
|
|
3755
|
-
"
|
|
3756
|
-
"
|
|
3757
|
-
|
|
3758
|
-
"
|
|
3759
|
-
"
|
|
3760
|
-
"
|
|
3761
|
-
"
|
|
3762
|
-
|
|
3841
|
+
Oe((E) => ({
|
|
3842
|
+
"0db40539": l.value.colors.border,
|
|
3843
|
+
bd72d08a: l.value.colors.background,
|
|
3844
|
+
"1738b57a": l.value.colors.text,
|
|
3845
|
+
"69331e8e": l.value.colors.surfaceBackground,
|
|
3846
|
+
cd0ca56a: l.value.colors.buttonBorder,
|
|
3847
|
+
"02f5e6cd": l.value.colors.buttonBackground,
|
|
3848
|
+
"060d3a0c": l.value.colors.buttonText,
|
|
3849
|
+
"6ac62a6f": l.value.colors.buttonBackgroundHover,
|
|
3850
|
+
"7ef6f8c3": l.value.colors.buttonPrimary,
|
|
3851
|
+
"24e03b8e": l.value.colors.buttonPrimaryHover,
|
|
3852
|
+
"357fd096": l.value.colors.success,
|
|
3853
|
+
"4d328338": l.value.colors.successBackground,
|
|
3854
|
+
"61df294a": l.value.colors.error,
|
|
3855
|
+
"3307322e": l.value.colors.errorBackground
|
|
3763
3856
|
}));
|
|
3764
|
-
const s = r, n = t, o =
|
|
3765
|
-
if (!o.value) return
|
|
3766
|
-
const
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
}),
|
|
3770
|
-
}),
|
|
3771
|
-
if (!
|
|
3857
|
+
const s = r, n = t, o = z(null), i = z(""), u = z(/* @__PURE__ */ new Set()), a = V(() => i.value === ""), l = V(() => mr(s.theme)), h = V(() => !o.value || !Array.isArray(o.value) ? [] : o.value.filter((E) => !E["?xml"])), f = V(() => {
|
|
3858
|
+
if (!o.value || !Array.isArray(o.value)) return null;
|
|
3859
|
+
const E = o.value.find((X) => X["?xml"]);
|
|
3860
|
+
if (!E || !E[":@"]) return null;
|
|
3861
|
+
const O = E[":@"], I = [];
|
|
3862
|
+
return O["@_version"] && I.push(`version="${O["@_version"]}"`), O["@_encoding"] && I.push(`encoding="${O["@_encoding"]}"`), O["@_standalone"] && I.push(`standalone="${O["@_standalone"]}"`), I.length > 0 ? `<?xml ${I.join(" ")}?>` : null;
|
|
3863
|
+
}), b = V(() => h.value), m = (E) => {
|
|
3864
|
+
if (!E || !E.trim()) {
|
|
3772
3865
|
i.value = "", o.value = null;
|
|
3773
3866
|
return;
|
|
3774
3867
|
}
|
|
3775
3868
|
try {
|
|
3776
|
-
const
|
|
3777
|
-
if (!
|
|
3778
|
-
i.value =
|
|
3869
|
+
const O = yn(E);
|
|
3870
|
+
if (!O.valid) {
|
|
3871
|
+
i.value = O.error || "Invalid XML", o.value = null;
|
|
3779
3872
|
return;
|
|
3780
3873
|
}
|
|
3781
|
-
o.value =
|
|
3782
|
-
|
|
3874
|
+
o.value = De(E), i.value = "", he(() => {
|
|
3875
|
+
S();
|
|
3783
3876
|
});
|
|
3784
|
-
} catch (
|
|
3785
|
-
i.value =
|
|
3877
|
+
} catch (O) {
|
|
3878
|
+
i.value = O instanceof Error ? O.message : "Unknown parse error", o.value = null;
|
|
3786
3879
|
}
|
|
3787
|
-
},
|
|
3788
|
-
u.value.has(
|
|
3789
|
-
},
|
|
3790
|
-
const
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
})
|
|
3880
|
+
}, w = (E) => {
|
|
3881
|
+
u.value.has(E) ? u.value.delete(E) : u.value.add(E);
|
|
3882
|
+
}, S = () => {
|
|
3883
|
+
const E = /* @__PURE__ */ new Set(), O = (I, X = "") => {
|
|
3884
|
+
Array.isArray(I) && I.forEach((Z, Y) => {
|
|
3885
|
+
const Q = Object.keys(Z).find((y) => !y.startsWith(":") && !y.startsWith("#"));
|
|
3886
|
+
if (!Q) return;
|
|
3887
|
+
const ee = X ? `${X}[${Y}]` : `${Q}[${Y}]`;
|
|
3888
|
+
E.add(ee);
|
|
3889
|
+
const ae = Z[Q];
|
|
3890
|
+
Array.isArray(ae) && O(ae, ee + "." + Q);
|
|
3891
|
+
});
|
|
3799
3892
|
};
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3893
|
+
h.value.forEach((I, X) => {
|
|
3894
|
+
const Z = Object.keys(I).find((Y) => !Y.startsWith(":") && !Y.startsWith("#"));
|
|
3895
|
+
if (Z) {
|
|
3896
|
+
const Y = `${Z}[${X}]`;
|
|
3897
|
+
E.add(Y);
|
|
3898
|
+
const Q = I[Z];
|
|
3899
|
+
Array.isArray(Q) && O(Q, Y + "." + Z);
|
|
3900
|
+
}
|
|
3901
|
+
}), u.value = E, n("expand-all");
|
|
3902
|
+
}, _ = () => {
|
|
3804
3903
|
u.value.clear(), n("collapse-all");
|
|
3805
|
-
},
|
|
3904
|
+
}, j = async () => {
|
|
3806
3905
|
if (!(!a.value || !o.value))
|
|
3807
3906
|
try {
|
|
3808
|
-
const
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
} catch (k) {
|
|
3814
|
-
const p = k instanceof Error ? k : new Error("Copy failed");
|
|
3815
|
-
n("copy-error", p), console.error("Failed to copy XML:", k);
|
|
3907
|
+
const E = Array.isArray(o.value) ? Ee(o.value, { indent: " " }) : Pe(o.value, { format: !0, indentBy: " " });
|
|
3908
|
+
await navigator.clipboard.writeText(E), n("copy-success", E);
|
|
3909
|
+
} catch (E) {
|
|
3910
|
+
const O = E instanceof Error ? E : new Error("Copy failed");
|
|
3911
|
+
n("copy-error", O), console.error("Failed to copy XML:", E);
|
|
3816
3912
|
}
|
|
3817
|
-
},
|
|
3913
|
+
}, H = () => {
|
|
3818
3914
|
if (!(!a.value || !o.value))
|
|
3819
3915
|
try {
|
|
3820
|
-
const
|
|
3821
|
-
n("update:modelValue",
|
|
3822
|
-
} catch (
|
|
3823
|
-
console.error("Failed to compress XML:",
|
|
3916
|
+
const E = bn(o.value);
|
|
3917
|
+
n("update:modelValue", E), n("compress", E);
|
|
3918
|
+
} catch (E) {
|
|
3919
|
+
console.error("Failed to compress XML:", E);
|
|
3824
3920
|
}
|
|
3825
|
-
},
|
|
3921
|
+
}, p = () => {
|
|
3826
3922
|
if (a.value)
|
|
3827
3923
|
try {
|
|
3828
|
-
const
|
|
3924
|
+
const E = vn(s.modelValue, {
|
|
3829
3925
|
format: !0,
|
|
3830
3926
|
indentBy: " "
|
|
3831
3927
|
});
|
|
3832
|
-
n("update:modelValue",
|
|
3833
|
-
} catch (
|
|
3834
|
-
console.error("Failed to format XML:",
|
|
3928
|
+
n("update:modelValue", E), n("format", E);
|
|
3929
|
+
} catch (E) {
|
|
3930
|
+
console.error("Failed to format XML:", E);
|
|
3835
3931
|
}
|
|
3836
|
-
},
|
|
3932
|
+
}, $ = async (E) => {
|
|
3837
3933
|
try {
|
|
3838
|
-
const
|
|
3839
|
-
await navigator.clipboard.writeText(
|
|
3840
|
-
} catch (
|
|
3841
|
-
const
|
|
3842
|
-
n("copy-error",
|
|
3934
|
+
const O = typeof E == "string" ? E : JSON.stringify(E, null, 2);
|
|
3935
|
+
await navigator.clipboard.writeText(O), n("copy-success", O);
|
|
3936
|
+
} catch (O) {
|
|
3937
|
+
const I = O instanceof Error ? O : new Error("Copy failed");
|
|
3938
|
+
n("copy-error", I), console.error("Failed to copy value:", O);
|
|
3843
3939
|
}
|
|
3844
3940
|
};
|
|
3845
|
-
return
|
|
3846
|
-
|
|
3941
|
+
return Xe(() => s.modelValue, (E) => {
|
|
3942
|
+
m(E);
|
|
3847
3943
|
}, { immediate: !0 }), e({
|
|
3848
3944
|
// 核心操作方法
|
|
3849
|
-
copyXml:
|
|
3850
|
-
compressSource:
|
|
3851
|
-
formatSource:
|
|
3852
|
-
expandAll:
|
|
3853
|
-
collapseAll:
|
|
3854
|
-
toggleExpand:
|
|
3945
|
+
copyXml: j,
|
|
3946
|
+
compressSource: H,
|
|
3947
|
+
formatSource: p,
|
|
3948
|
+
expandAll: S,
|
|
3949
|
+
collapseAll: _,
|
|
3950
|
+
toggleExpand: w,
|
|
3855
3951
|
// 状态访问方法
|
|
3856
3952
|
isValidXml: () => a.value,
|
|
3857
3953
|
getParsedXml: () => o.value,
|
|
3858
3954
|
getExpandedNodes: () => u.value,
|
|
3859
3955
|
getParseError: () => i.value,
|
|
3860
3956
|
// 工具方法
|
|
3861
|
-
parseXmlString: (
|
|
3862
|
-
copyValue: (
|
|
3863
|
-
}), (
|
|
3864
|
-
class:
|
|
3957
|
+
parseXmlString: (E) => m(E),
|
|
3958
|
+
copyValue: (E) => $(E)
|
|
3959
|
+
}), (E, O) => (x(), k("div", {
|
|
3960
|
+
class: Te(["xml-format", `xml-format--${l.value.name}`])
|
|
3865
3961
|
}, [
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3962
|
+
E.showToolbar ? (x(), k("div", En, [
|
|
3963
|
+
v("div", _n, [
|
|
3964
|
+
v("button", {
|
|
3869
3965
|
class: "xml-format__btn xml-format__btn--primary",
|
|
3870
|
-
onClick:
|
|
3966
|
+
onClick: j,
|
|
3871
3967
|
disabled: !a.value,
|
|
3872
3968
|
title: "Copy XML"
|
|
3873
|
-
}, " 📋 Copy ", 8,
|
|
3874
|
-
|
|
3969
|
+
}, " 📋 Copy ", 8, xn),
|
|
3970
|
+
v("button", {
|
|
3875
3971
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3876
|
-
onClick:
|
|
3972
|
+
onClick: S,
|
|
3877
3973
|
disabled: !a.value,
|
|
3878
3974
|
title: "Expand All"
|
|
3879
|
-
}, " ⬇️ Expand All ", 8,
|
|
3880
|
-
|
|
3975
|
+
}, " ⬇️ Expand All ", 8, Nn),
|
|
3976
|
+
v("button", {
|
|
3881
3977
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3882
|
-
onClick:
|
|
3978
|
+
onClick: _,
|
|
3883
3979
|
disabled: !a.value,
|
|
3884
3980
|
title: "Collapse All"
|
|
3885
|
-
}, " ➡️ Collapse All ", 8,
|
|
3886
|
-
|
|
3981
|
+
}, " ➡️ Collapse All ", 8, kn),
|
|
3982
|
+
v("button", {
|
|
3887
3983
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3888
|
-
onClick:
|
|
3984
|
+
onClick: H,
|
|
3889
3985
|
disabled: !a.value,
|
|
3890
3986
|
title: "Compress XML"
|
|
3891
3987
|
}, " 📦 Compress ", 8, An),
|
|
3892
|
-
|
|
3988
|
+
v("button", {
|
|
3893
3989
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3894
|
-
onClick:
|
|
3990
|
+
onClick: p,
|
|
3895
3991
|
disabled: !a.value,
|
|
3896
3992
|
title: "Format XML"
|
|
3897
|
-
}, " ✨ Format ", 8,
|
|
3993
|
+
}, " ✨ Format ", 8, wn)
|
|
3898
3994
|
]),
|
|
3899
|
-
|
|
3900
|
-
a.value ? (x(),
|
|
3995
|
+
v("div", Cn, [
|
|
3996
|
+
a.value ? (x(), k("span", On, " ✅ Valid XML ")) : (x(), k("span", Tn, " ❌ Invalid XML "))
|
|
3901
3997
|
])
|
|
3902
3998
|
])) : F("", !0),
|
|
3903
|
-
|
|
3904
|
-
a.value ? (x(),
|
|
3905
|
-
|
|
3906
|
-
key:
|
|
3907
|
-
|
|
3908
|
-
|
|
3999
|
+
v("div", Pn, [
|
|
4000
|
+
a.value ? (x(), k("div", Sn, [
|
|
4001
|
+
f.value ? (x(), k("div", {
|
|
4002
|
+
key: 0,
|
|
4003
|
+
class: "xml-declaration",
|
|
4004
|
+
style: P({ color: l.value.colors.xmlDeclaration })
|
|
4005
|
+
}, R(f.value), 5)) : F("", !0),
|
|
4006
|
+
(x(!0), k(de, null, fe(b.value, (I, X) => (x(), He(dr, {
|
|
4007
|
+
key: X,
|
|
4008
|
+
node: I,
|
|
4009
|
+
index: X,
|
|
3909
4010
|
level: 0,
|
|
3910
4011
|
expanded: u.value,
|
|
3911
4012
|
theme: l.value,
|
|
3912
|
-
onToggleExpand:
|
|
3913
|
-
onCopy:
|
|
3914
|
-
}, null, 8, ["
|
|
3915
|
-
])) : (x(),
|
|
3916
|
-
|
|
3917
|
-
|
|
4013
|
+
onToggleExpand: w,
|
|
4014
|
+
onCopy: $
|
|
4015
|
+
}, null, 8, ["node", "index", "expanded", "theme"]))), 128))
|
|
4016
|
+
])) : (x(), k("div", $n, [
|
|
4017
|
+
O[0] || (O[0] = v("h4", null, "XML Parse Error:", -1)),
|
|
4018
|
+
v("pre", null, R(i.value), 1)
|
|
3918
4019
|
]))
|
|
3919
4020
|
])
|
|
3920
4021
|
], 2));
|
|
3921
4022
|
}
|
|
3922
|
-
}),
|
|
3923
|
-
|
|
4023
|
+
}), jn = /* @__PURE__ */ be(In, [["__scopeId", "data-v-f9125514"]]), Bn = [Zt], Vn = (r) => {
|
|
4024
|
+
Bn.forEach((e) => {
|
|
3924
4025
|
const t = e.name || e.__name || "UnknownComponent";
|
|
3925
4026
|
r.component(t, e);
|
|
3926
4027
|
});
|
|
3927
|
-
},
|
|
3928
|
-
install:
|
|
4028
|
+
}, Mn = {
|
|
4029
|
+
install: Vn
|
|
3929
4030
|
};
|
|
3930
4031
|
export {
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
4032
|
+
Zt as JsonFormat,
|
|
4033
|
+
jn as XmlFormat,
|
|
4034
|
+
Mn as default
|
|
3934
4035
|
};
|