lone-format 0.3.4 → 0.5.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 +1572 -1490
- 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 A, 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,7 +958,7 @@ 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) {
|
|
@@ -967,7 +967,7 @@ function re(r, e) {
|
|
|
967
967
|
function ke(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(ke(this._eval(l, e, t.at(-1), t.slice(0, -1), s, n), h), e, t, s, n, o, i));
|
|
1111
1111
|
} else if (l[0] === "@") {
|
|
1112
1112
|
let m = !1;
|
|
1113
|
-
const
|
|
1114
|
-
switch (
|
|
1113
|
+
const 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(ke(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(ke(m, e), t, s, n, o, i, !0).forEach((
|
|
1199
|
-
|
|
1198
|
+
this._trace(ke(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,25 +1297,25 @@ 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" }, At = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
1321
|
}, kt = {
|
|
@@ -1324,10 +1324,10 @@ const ft = { class: "json-node" }, ht = {
|
|
|
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(), A("div", ht, [
|
|
1416
|
+
h.value ? (x(), A("div", pt, [
|
|
1417
|
+
v("div", gt, [
|
|
1418
|
+
y.keyName && !n.value ? (x(), A("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(), A("input", {
|
|
1425
1425
|
key: 1,
|
|
1426
|
-
"onUpdate:modelValue": d[0] || (d[0] = (
|
|
1426
|
+
"onUpdate:modelValue": d[0] || (d[0] = (k) => i.value = k),
|
|
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(), A("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(), A("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(), A("span", vt, ",")) : F("", !0)
|
|
1450
1450
|
]),
|
|
1451
|
-
m.value ? (x(),
|
|
1452
|
-
|
|
1453
|
-
(x(!0),
|
|
1454
|
-
key:
|
|
1451
|
+
m.value ? (x(), A("div", Et, [
|
|
1452
|
+
v("div", _t, [
|
|
1453
|
+
(x(!0), A(de, null, fe(y.value, (k, N) => (x(), A("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: k,
|
|
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(), A("span", At, ","))
|
|
1475
1475
|
])
|
|
1476
1476
|
])) : F("", !0)
|
|
1477
|
-
])) : (x(),
|
|
1478
|
-
|
|
1477
|
+
])) : (x(), A("div", kt, [
|
|
1478
|
+
y.keyName && !n.value ? (x(), A("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(), A("input", {
|
|
1485
1485
|
key: 1,
|
|
1486
|
-
"onUpdate:modelValue": d[5] || (d[5] = (
|
|
1486
|
+
"onUpdate:modelValue": d[5] || (d[5] = (k) => i.value = k),
|
|
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(), A("span", wt, ": ")) : F("", !0),
|
|
1497
|
+
o.value ? F("", !0) : (x(), A("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] = (k) => 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(), A("span", Ot, ","))
|
|
1506
|
+
], 42, Ct)),
|
|
1507
|
+
o.value ? _e((x(), A("input", {
|
|
1508
1508
|
key: 4,
|
|
1509
|
-
"onUpdate:modelValue": d[7] || (d[7] = (
|
|
1509
|
+
"onUpdate:modelValue": d[7] || (d[7] = (k) => u.value = k),
|
|
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
|
// 背景色
|
|
@@ -1555,16 +1555,12 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1555
1555
|
syntaxNull: "#656d76",
|
|
1556
1556
|
syntaxKey: "#0969da",
|
|
1557
1557
|
syntaxBracket: "#24292f",
|
|
1558
|
-
// 滚动条
|
|
1559
|
-
scrollbarTrack: "#f6f8fa",
|
|
1560
|
-
scrollbarThumb: "#d0d7de",
|
|
1561
|
-
scrollbarThumbHover: "#afb8c1",
|
|
1562
1558
|
// 悬停效果
|
|
1563
1559
|
hoverBackground: "#f6f8fa",
|
|
1564
1560
|
// 缩进线
|
|
1565
1561
|
indentLine: "#d0d7de"
|
|
1566
1562
|
}
|
|
1567
|
-
},
|
|
1563
|
+
}, $t = {
|
|
1568
1564
|
name: "github-dark",
|
|
1569
1565
|
colors: {
|
|
1570
1566
|
// 背景色
|
|
@@ -1594,10 +1590,6 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1594
1590
|
syntaxNull: "#7d8590",
|
|
1595
1591
|
syntaxKey: "#79c0ff",
|
|
1596
1592
|
syntaxBracket: "#e6edf3",
|
|
1597
|
-
// 滚动条
|
|
1598
|
-
scrollbarTrack: "#161b22",
|
|
1599
|
-
scrollbarThumb: "#30363d",
|
|
1600
|
-
scrollbarThumbHover: "#6e7681",
|
|
1601
1593
|
// 悬停效果
|
|
1602
1594
|
hoverBackground: "#161b22",
|
|
1603
1595
|
// 缩进线
|
|
@@ -1633,10 +1625,6 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1633
1625
|
syntaxNull: "#6b7280",
|
|
1634
1626
|
syntaxKey: "#1f2937",
|
|
1635
1627
|
syntaxBracket: "#374151",
|
|
1636
|
-
// 滚动条 - 极简
|
|
1637
|
-
scrollbarTrack: "#f5f5f5",
|
|
1638
|
-
scrollbarThumb: "#d1d5db",
|
|
1639
|
-
scrollbarThumbHover: "#9ca3af",
|
|
1640
1628
|
// 悬停效果
|
|
1641
1629
|
hoverBackground: "#f9f9f9",
|
|
1642
1630
|
// 缩进线
|
|
@@ -1672,43 +1660,39 @@ const ft = { class: "json-node" }, ht = {
|
|
|
1672
1660
|
syntaxNull: "#8b7355",
|
|
1673
1661
|
syntaxKey: "#4a3b2a",
|
|
1674
1662
|
syntaxBracket: "#6b5444",
|
|
1675
|
-
// 滚动条 - 暖色调
|
|
1676
|
-
scrollbarTrack: "#f4ede4",
|
|
1677
|
-
scrollbarThumb: "#e8d5b7",
|
|
1678
|
-
scrollbarThumbHover: "#d4c4a8",
|
|
1679
1663
|
// 悬停效果
|
|
1680
1664
|
hoverBackground: "#f8f2eb",
|
|
1681
1665
|
// 缩进线
|
|
1682
1666
|
indentLine: "#e8d5b7"
|
|
1683
1667
|
}
|
|
1684
|
-
},
|
|
1685
|
-
"github-light":
|
|
1686
|
-
"github-dark":
|
|
1668
|
+
}, Bt = {
|
|
1669
|
+
"github-light": Ke,
|
|
1670
|
+
"github-dark": $t,
|
|
1687
1671
|
"min-light": St,
|
|
1688
1672
|
"slack-ochin": It
|
|
1689
1673
|
};
|
|
1690
|
-
function
|
|
1691
|
-
return
|
|
1674
|
+
function Vt(r = "github-light") {
|
|
1675
|
+
return Bt[r] || Ke;
|
|
1692
1676
|
}
|
|
1693
|
-
const
|
|
1677
|
+
const Lt = {
|
|
1694
1678
|
key: 0,
|
|
1695
1679
|
class: "json-format__toolbar"
|
|
1696
|
-
},
|
|
1680
|
+
}, Rt = { class: "json-format__actions" }, jt = ["disabled"], Mt = ["disabled"], Ut = ["disabled"], Ft = ["disabled"], Xt = { class: "json-format__info" }, Ht = {
|
|
1697
1681
|
key: 0,
|
|
1698
1682
|
class: "json-format__status json-format__status--success"
|
|
1699
|
-
},
|
|
1683
|
+
}, Kt = {
|
|
1700
1684
|
key: 1,
|
|
1701
1685
|
class: "json-format__status json-format__status--error"
|
|
1702
|
-
},
|
|
1686
|
+
}, qt = { class: "json-format__content" }, Yt = {
|
|
1703
1687
|
key: 0,
|
|
1704
1688
|
class: "json-format__error"
|
|
1705
|
-
},
|
|
1689
|
+
}, Qt = {
|
|
1706
1690
|
key: 1,
|
|
1707
1691
|
class: "json-format__error"
|
|
1708
|
-
},
|
|
1692
|
+
}, Wt = {
|
|
1709
1693
|
key: 2,
|
|
1710
1694
|
class: "json-format__viewer"
|
|
1711
|
-
}, Gt = /* @__PURE__ */
|
|
1695
|
+
}, Gt = /* @__PURE__ */ ye({
|
|
1712
1696
|
name: "JsonFormat",
|
|
1713
1697
|
__name: "index",
|
|
1714
1698
|
props: {
|
|
@@ -1720,73 +1704,70 @@ const Vt = {
|
|
|
1720
1704
|
},
|
|
1721
1705
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1722
1706
|
setup(r, { expose: e, emit: t }) {
|
|
1723
|
-
|
|
1724
|
-
"
|
|
1725
|
-
"
|
|
1726
|
-
"
|
|
1727
|
-
"
|
|
1728
|
-
"
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
"
|
|
1734
|
-
"
|
|
1735
|
-
|
|
1736
|
-
"
|
|
1737
|
-
"
|
|
1738
|
-
"2c13c5fa": f.value.colors.scrollbarTrack,
|
|
1739
|
-
"2c1c44e4": f.value.colors.scrollbarThumb,
|
|
1740
|
-
"8ba97764": f.value.colors.scrollbarThumbHover
|
|
1707
|
+
Oe((d) => ({
|
|
1708
|
+
"325d5f6b": f.value.colors.border,
|
|
1709
|
+
"407388ed": f.value.colors.background,
|
|
1710
|
+
"1276f42c": f.value.colors.text,
|
|
1711
|
+
"34805dc8": f.value.colors.surfaceBackground,
|
|
1712
|
+
"212f19fd": f.value.colors.buttonBorder,
|
|
1713
|
+
b83cab02: f.value.colors.buttonBackground,
|
|
1714
|
+
b58ba984: f.value.colors.buttonText,
|
|
1715
|
+
d50a3406: f.value.colors.buttonBackgroundHover,
|
|
1716
|
+
"2421bb5e": f.value.colors.buttonPrimary,
|
|
1717
|
+
"0299816b": f.value.colors.buttonPrimaryHover,
|
|
1718
|
+
"55f370f2": f.value.colors.successBackground,
|
|
1719
|
+
b3fc86b8: f.value.colors.success,
|
|
1720
|
+
"781064f7": f.value.colors.errorBackground,
|
|
1721
|
+
"3b9a02e9": f.value.colors.error
|
|
1741
1722
|
}));
|
|
1742
|
-
const s = r, n = t, o =
|
|
1723
|
+
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
1724
|
if (!d.trim()) {
|
|
1744
1725
|
o.value = null, i.value = "", a.value = null, l.value = "";
|
|
1745
1726
|
return;
|
|
1746
1727
|
}
|
|
1747
1728
|
try {
|
|
1748
1729
|
let g = d;
|
|
1749
|
-
const
|
|
1750
|
-
if (!
|
|
1730
|
+
const k = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(g), N = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(g);
|
|
1731
|
+
if (!k && !N)
|
|
1751
1732
|
try {
|
|
1752
|
-
o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "",
|
|
1753
|
-
|
|
1733
|
+
o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", he(() => {
|
|
1734
|
+
b.value !== null && $();
|
|
1754
1735
|
});
|
|
1755
1736
|
return;
|
|
1756
1737
|
} catch {
|
|
1757
1738
|
}
|
|
1758
|
-
g = ((
|
|
1759
|
-
let
|
|
1760
|
-
for (;
|
|
1761
|
-
const
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
else if (
|
|
1765
|
-
|
|
1739
|
+
g = ((T) => {
|
|
1740
|
+
let L = "", K = !1, q = !1, J = 0;
|
|
1741
|
+
for (; J < T.length; ) {
|
|
1742
|
+
const le = T[J];
|
|
1743
|
+
if (K)
|
|
1744
|
+
q ? q = !1 : le === "\\" ? q = !0 : le === '"' && (K = !1), L += le, J++;
|
|
1745
|
+
else if (le === '"')
|
|
1746
|
+
K = !0, L += le, J++;
|
|
1766
1747
|
else {
|
|
1767
|
-
const
|
|
1768
|
-
let
|
|
1769
|
-
if (
|
|
1770
|
-
|
|
1748
|
+
const $e = T.slice(J);
|
|
1749
|
+
let D = $e.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1750
|
+
if (D) {
|
|
1751
|
+
L += D[1] + '{"__protected_number__":"' + D[2] + '"}' + D[3], J += D[0].length;
|
|
1771
1752
|
continue;
|
|
1772
1753
|
}
|
|
1773
|
-
if (
|
|
1774
|
-
|
|
1754
|
+
if (D = $e.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), D) {
|
|
1755
|
+
L += D[1] + '{"__protected_number__":"' + D[2] + '"}' + D[3], J += D[0].length;
|
|
1775
1756
|
continue;
|
|
1776
1757
|
}
|
|
1777
|
-
|
|
1758
|
+
L += le, J++;
|
|
1778
1759
|
}
|
|
1779
1760
|
}
|
|
1780
|
-
return
|
|
1781
|
-
})(g), o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "",
|
|
1782
|
-
|
|
1761
|
+
return L;
|
|
1762
|
+
})(g), o.value = JSON.parse(g), i.value = "", a.value = null, l.value = "", he(() => {
|
|
1763
|
+
b.value !== null && $();
|
|
1783
1764
|
});
|
|
1784
1765
|
} catch (g) {
|
|
1785
1766
|
i.value = g instanceof Error ? g.message : "Unknown parsing error", o.value = null, a.value = null, l.value = "";
|
|
1786
1767
|
}
|
|
1787
|
-
},
|
|
1768
|
+
}, w = (d) => {
|
|
1788
1769
|
if (!d || !d.expression.trim()) {
|
|
1789
|
-
|
|
1770
|
+
S();
|
|
1790
1771
|
return;
|
|
1791
1772
|
}
|
|
1792
1773
|
if (!o.value) {
|
|
@@ -1796,7 +1777,7 @@ const Vt = {
|
|
|
1796
1777
|
try {
|
|
1797
1778
|
let g;
|
|
1798
1779
|
if (d.type === "jsonpath")
|
|
1799
|
-
g =
|
|
1780
|
+
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
1781
|
else if (d.type === "js")
|
|
1801
1782
|
g = new Function("data", `
|
|
1802
1783
|
try {
|
|
@@ -1807,77 +1788,77 @@ const Vt = {
|
|
|
1807
1788
|
`)(o.value), a.value = g;
|
|
1808
1789
|
else
|
|
1809
1790
|
throw new Error(`Unsupported filter type: ${d.type}`);
|
|
1810
|
-
l.value = "",
|
|
1811
|
-
|
|
1791
|
+
l.value = "", he(() => {
|
|
1792
|
+
$();
|
|
1812
1793
|
});
|
|
1813
1794
|
} catch (g) {
|
|
1814
1795
|
l.value = g instanceof Error ? g.message : "Filter execution error", a.value = null;
|
|
1815
1796
|
}
|
|
1816
|
-
},
|
|
1797
|
+
}, S = () => {
|
|
1817
1798
|
a.value = null, l.value = "";
|
|
1818
1799
|
};
|
|
1819
|
-
|
|
1800
|
+
Xe(() => s.modelValue, (d) => {
|
|
1820
1801
|
m(d);
|
|
1821
1802
|
}, { 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
|
-
},
|
|
1803
|
+
const _ = (d, g, k) => {
|
|
1804
|
+
const N = (L) => {
|
|
1805
|
+
if (L === null || typeof L != "object")
|
|
1806
|
+
return L;
|
|
1807
|
+
if (!Array.isArray(L) && "__protected_number__" in L && Object.keys(L).length === 1)
|
|
1808
|
+
return `__PROTECTED_NUMBER_${L.__protected_number__}_PROTECTED_NUMBER__`;
|
|
1809
|
+
if (Array.isArray(L))
|
|
1810
|
+
return L.map((q) => N(q));
|
|
1811
|
+
const K = {};
|
|
1812
|
+
for (const [q, J] of Object.entries(L))
|
|
1813
|
+
K[q] = N(J);
|
|
1814
|
+
return K;
|
|
1815
|
+
}, C = N(d);
|
|
1816
|
+
return JSON.stringify(C, g, k).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1817
|
+
}, j = (d, g) => {
|
|
1837
1818
|
if (!s.readonly)
|
|
1838
1819
|
try {
|
|
1839
|
-
const
|
|
1840
|
-
n("update:modelValue",
|
|
1841
|
-
} catch (
|
|
1842
|
-
console.error("Failed to update JSON:",
|
|
1820
|
+
const k = H(o.value, d, g), N = _(k, null, 2);
|
|
1821
|
+
n("update:modelValue", N);
|
|
1822
|
+
} catch (k) {
|
|
1823
|
+
console.error("Failed to update JSON:", k);
|
|
1843
1824
|
}
|
|
1844
|
-
},
|
|
1845
|
-
if (!g || g === "root") return
|
|
1846
|
-
const
|
|
1847
|
-
let
|
|
1848
|
-
for (let
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1825
|
+
}, H = (d, g, k) => {
|
|
1826
|
+
if (!g || g === "root") return k;
|
|
1827
|
+
const N = g.split("."), C = Q(d, N.slice(0, -1));
|
|
1828
|
+
let T = C;
|
|
1829
|
+
for (let K = 0; K < N.length - 1; K++) {
|
|
1830
|
+
const q = N[K];
|
|
1831
|
+
q !== "root" && (Array.isArray(T) ? T = T[parseInt(q)] : T = T[q]);
|
|
1851
1832
|
}
|
|
1852
|
-
const
|
|
1853
|
-
return
|
|
1854
|
-
},
|
|
1833
|
+
const L = N[N.length - 1];
|
|
1834
|
+
return L === "root" ? k : (Array.isArray(T) ? T[parseInt(L)] = k : T[L] = k, C);
|
|
1835
|
+
}, p = (d) => {
|
|
1855
1836
|
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(
|
|
1837
|
+
}, $ = () => {
|
|
1838
|
+
const d = /* @__PURE__ */ new Set(), g = (k, N = "") => {
|
|
1839
|
+
k !== null && typeof k == "object" && (d.add(N || "root"), Array.isArray(k) ? k.forEach((C, T) => {
|
|
1840
|
+
const L = N ? `${N}.${T}` : `${T}`;
|
|
1841
|
+
g(C, L);
|
|
1842
|
+
}) : Object.keys(k).forEach((C) => {
|
|
1843
|
+
const T = N ? `${N}.${C}` : C;
|
|
1844
|
+
g(k[C], T);
|
|
1864
1845
|
}));
|
|
1865
1846
|
};
|
|
1866
|
-
g(
|
|
1867
|
-
},
|
|
1847
|
+
g(b.value), u.value = d, n("expand-all");
|
|
1848
|
+
}, E = () => {
|
|
1868
1849
|
u.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1869
|
-
},
|
|
1850
|
+
}, O = async () => {
|
|
1870
1851
|
if (h.value)
|
|
1871
1852
|
try {
|
|
1872
|
-
const d =
|
|
1853
|
+
const d = b.value, g = _(d, null, 2);
|
|
1873
1854
|
await navigator.clipboard.writeText(g), n("copy-success", g);
|
|
1874
1855
|
} catch (d) {
|
|
1875
1856
|
console.error("Failed to copy JSON:", d), n("copy-error", d instanceof Error ? d : new Error("Failed to copy JSON"));
|
|
1876
1857
|
}
|
|
1877
|
-
},
|
|
1858
|
+
}, I = () => {
|
|
1878
1859
|
if (h.value)
|
|
1879
1860
|
try {
|
|
1880
|
-
const d =
|
|
1861
|
+
const d = b.value, g = _(d);
|
|
1881
1862
|
n("update:modelValue", g), n("compress", g);
|
|
1882
1863
|
} catch (d) {
|
|
1883
1864
|
console.error("Failed to compress JSON:", d);
|
|
@@ -1892,81 +1873,81 @@ const Vt = {
|
|
|
1892
1873
|
}, Z = (d, g) => {
|
|
1893
1874
|
if (!s.readonly)
|
|
1894
1875
|
try {
|
|
1895
|
-
const
|
|
1896
|
-
n("update:modelValue",
|
|
1897
|
-
} catch (
|
|
1898
|
-
console.error("Failed to rename key:",
|
|
1876
|
+
const k = Y(o.value, d, g), N = _(k, null, 2);
|
|
1877
|
+
n("update:modelValue", N), y(d, g);
|
|
1878
|
+
} catch (k) {
|
|
1879
|
+
console.error("Failed to rename key:", k);
|
|
1899
1880
|
}
|
|
1900
|
-
},
|
|
1881
|
+
}, Y = (d, g, k) => {
|
|
1901
1882
|
if (!g || g === "root") return d;
|
|
1902
|
-
const
|
|
1903
|
-
if (
|
|
1904
|
-
const
|
|
1905
|
-
return
|
|
1883
|
+
const N = g.split("."), C = Q(d, N.slice(0, -1));
|
|
1884
|
+
if (N.length === 1) {
|
|
1885
|
+
const K = N[0];
|
|
1886
|
+
return C && typeof C == "object" && !Array.isArray(C) ? ee(C, K, k) : C;
|
|
1906
1887
|
}
|
|
1907
|
-
let
|
|
1908
|
-
for (let
|
|
1909
|
-
const
|
|
1910
|
-
Array.isArray(
|
|
1888
|
+
let T = C;
|
|
1889
|
+
for (let K = 0; K < N.length - 1; K++) {
|
|
1890
|
+
const q = N[K];
|
|
1891
|
+
Array.isArray(T) ? T = T[parseInt(q)] : T = T[q];
|
|
1911
1892
|
}
|
|
1912
|
-
const
|
|
1913
|
-
if (!Array.isArray(
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1893
|
+
const L = N[N.length - 1];
|
|
1894
|
+
if (!Array.isArray(T) && T && typeof T == "object") {
|
|
1895
|
+
const K = ee(T, L, k), q = N.slice(0, -1);
|
|
1896
|
+
q.length > 0 && ae(C, q, K);
|
|
1916
1897
|
}
|
|
1917
|
-
return
|
|
1918
|
-
},
|
|
1898
|
+
return C;
|
|
1899
|
+
}, Q = (d, g) => {
|
|
1919
1900
|
if (g.length === 0) return d;
|
|
1920
1901
|
if (Array.isArray(d)) {
|
|
1921
|
-
const
|
|
1922
|
-
return g.length === 1 || (
|
|
1902
|
+
const k = [...d], N = g[0], C = parseInt(N);
|
|
1903
|
+
return g.length === 1 || (k[C] = Q(d[C], g.slice(1))), k;
|
|
1923
1904
|
} else if (d && typeof d == "object") {
|
|
1924
|
-
const
|
|
1925
|
-
return g.length === 1 || (
|
|
1905
|
+
const k = { ...d }, N = g[0];
|
|
1906
|
+
return g.length === 1 || (k[N] = Q(d[N], g.slice(1))), k;
|
|
1926
1907
|
}
|
|
1927
1908
|
return d;
|
|
1928
|
-
},
|
|
1909
|
+
}, ee = (d, g, k) => {
|
|
1929
1910
|
if (!d || typeof d != "object" || Array.isArray(d))
|
|
1930
1911
|
return d;
|
|
1931
|
-
const
|
|
1932
|
-
for (const
|
|
1933
|
-
|
|
1934
|
-
return
|
|
1935
|
-
},
|
|
1936
|
-
let
|
|
1937
|
-
for (let
|
|
1938
|
-
const
|
|
1939
|
-
Array.isArray(
|
|
1912
|
+
const N = Object.keys(d), C = {};
|
|
1913
|
+
for (const T of N)
|
|
1914
|
+
T === g ? C[k] = d[T] : C[T] = d[T];
|
|
1915
|
+
return C;
|
|
1916
|
+
}, ae = (d, g, k) => {
|
|
1917
|
+
let N = d;
|
|
1918
|
+
for (let T = 0; T < g.length - 1; T++) {
|
|
1919
|
+
const L = g[T];
|
|
1920
|
+
Array.isArray(N) ? N = N[parseInt(L)] : N = N[L];
|
|
1940
1921
|
}
|
|
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
|
-
|
|
1922
|
+
const C = g[g.length - 1];
|
|
1923
|
+
Array.isArray(N) ? N[parseInt(C)] = k : N[C] = k;
|
|
1924
|
+
}, y = (d, g) => {
|
|
1925
|
+
const k = /* @__PURE__ */ new Set();
|
|
1926
|
+
u.value.forEach((N) => {
|
|
1927
|
+
if (N === d) {
|
|
1928
|
+
const C = d.split(".");
|
|
1929
|
+
C[C.length - 1] = g, k.add(C.join("."));
|
|
1930
|
+
} else if (N.startsWith(d + ".")) {
|
|
1931
|
+
const C = d.split(".");
|
|
1932
|
+
C[C.length - 1] = g;
|
|
1933
|
+
const T = C.join("."), L = N.substring(d.length);
|
|
1934
|
+
k.add(T + L);
|
|
1954
1935
|
} else
|
|
1955
|
-
|
|
1956
|
-
}), u.value =
|
|
1936
|
+
k.add(N);
|
|
1937
|
+
}), u.value = k;
|
|
1957
1938
|
};
|
|
1958
1939
|
return e({
|
|
1959
1940
|
// 核心操作方法
|
|
1960
|
-
copyJson:
|
|
1961
|
-
compressSource:
|
|
1962
|
-
expandAll:
|
|
1963
|
-
collapseAll:
|
|
1964
|
-
toggleExpand:
|
|
1965
|
-
updateValue:
|
|
1941
|
+
copyJson: O,
|
|
1942
|
+
compressSource: I,
|
|
1943
|
+
expandAll: $,
|
|
1944
|
+
collapseAll: E,
|
|
1945
|
+
toggleExpand: p,
|
|
1946
|
+
updateValue: j,
|
|
1966
1947
|
updateKey: Z,
|
|
1967
1948
|
// Filter 相关方法
|
|
1968
|
-
filter:
|
|
1969
|
-
clearFilter:
|
|
1949
|
+
filter: w,
|
|
1950
|
+
clearFilter: S,
|
|
1970
1951
|
// 状态访问方法
|
|
1971
1952
|
isValidJson: () => h.value,
|
|
1972
1953
|
getParsedJson: () => o.value,
|
|
@@ -1977,338 +1958,831 @@ const Vt = {
|
|
|
1977
1958
|
// 工具方法
|
|
1978
1959
|
parseJson: (d) => m(d),
|
|
1979
1960
|
copyValue: (d) => X(d)
|
|
1980
|
-
}), (d, g) => (x(),
|
|
1981
|
-
class:
|
|
1961
|
+
}), (d, g) => (x(), A("div", {
|
|
1962
|
+
class: Te(["json-format", `json-format--${f.value.name}`])
|
|
1982
1963
|
}, [
|
|
1983
|
-
d.showToolbar ? (x(),
|
|
1984
|
-
|
|
1985
|
-
|
|
1964
|
+
d.showToolbar ? (x(), A("div", Lt, [
|
|
1965
|
+
v("div", Rt, [
|
|
1966
|
+
v("button", {
|
|
1986
1967
|
class: "json-format__btn json-format__btn--primary",
|
|
1987
|
-
onClick:
|
|
1968
|
+
onClick: O,
|
|
1988
1969
|
disabled: !h.value,
|
|
1989
1970
|
title: "Copy JSON"
|
|
1990
|
-
}, " 📋 Copy ", 8,
|
|
1991
|
-
|
|
1971
|
+
}, " 📋 Copy ", 8, jt),
|
|
1972
|
+
v("button", {
|
|
1992
1973
|
class: "json-format__btn json-format__btn--secondary",
|
|
1993
|
-
onClick:
|
|
1974
|
+
onClick: $,
|
|
1994
1975
|
disabled: !h.value,
|
|
1995
1976
|
title: "Expand All"
|
|
1996
|
-
}, " ⬇️ Expand All ", 8,
|
|
1997
|
-
|
|
1977
|
+
}, " ⬇️ Expand All ", 8, Mt),
|
|
1978
|
+
v("button", {
|
|
1998
1979
|
class: "json-format__btn json-format__btn--secondary",
|
|
1999
|
-
onClick:
|
|
1980
|
+
onClick: E,
|
|
2000
1981
|
disabled: !h.value,
|
|
2001
1982
|
title: "Collapse All"
|
|
2002
|
-
}, " ➡️ Collapse All ", 8,
|
|
2003
|
-
|
|
1983
|
+
}, " ➡️ Collapse All ", 8, Ut),
|
|
1984
|
+
v("button", {
|
|
2004
1985
|
class: "json-format__btn json-format__btn--secondary",
|
|
2005
|
-
onClick:
|
|
1986
|
+
onClick: I,
|
|
2006
1987
|
disabled: !h.value,
|
|
2007
1988
|
title: "Compress JSON"
|
|
2008
|
-
}, " 📦 Compress ", 8,
|
|
1989
|
+
}, " 📦 Compress ", 8, Ft)
|
|
2009
1990
|
]),
|
|
2010
|
-
|
|
2011
|
-
h.value ? (x(),
|
|
1991
|
+
v("div", Xt, [
|
|
1992
|
+
h.value ? (x(), A("span", Ht, " ✅ Valid JSON ")) : (x(), A("span", Kt, " ❌ Invalid JSON "))
|
|
2012
1993
|
])
|
|
2013
1994
|
])) : F("", !0),
|
|
2014
|
-
|
|
2015
|
-
h.value ? l.value ? (x(),
|
|
2016
|
-
g[1] || (g[1] =
|
|
2017
|
-
|
|
2018
|
-
])) : (x(),
|
|
2019
|
-
|
|
2020
|
-
value:
|
|
1995
|
+
v("div", qt, [
|
|
1996
|
+
h.value ? l.value ? (x(), A("div", Qt, [
|
|
1997
|
+
g[1] || (g[1] = v("h4", null, "Filter Error:", -1)),
|
|
1998
|
+
v("pre", null, R(l.value), 1)
|
|
1999
|
+
])) : (x(), A("div", Wt, [
|
|
2000
|
+
Fe(Pt, {
|
|
2001
|
+
value: b.value,
|
|
2021
2002
|
"key-name": "",
|
|
2022
2003
|
level: 0,
|
|
2023
2004
|
expanded: u.value,
|
|
2024
2005
|
"is-last": !0,
|
|
2025
2006
|
theme: f.value,
|
|
2026
|
-
"onUpdate:value":
|
|
2027
|
-
onToggleExpand:
|
|
2007
|
+
"onUpdate:value": j,
|
|
2008
|
+
onToggleExpand: p,
|
|
2028
2009
|
onCopy: X,
|
|
2029
2010
|
"onUpdate:key": Z
|
|
2030
2011
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2031
|
-
])) : (x(),
|
|
2032
|
-
g[0] || (g[0] =
|
|
2033
|
-
|
|
2012
|
+
])) : (x(), A("div", Yt, [
|
|
2013
|
+
g[0] || (g[0] = v("h4", null, "JSON Parse Error:", -1)),
|
|
2014
|
+
v("pre", null, R(i.value), 1)
|
|
2034
2015
|
]))
|
|
2035
2016
|
])
|
|
2036
2017
|
], 2));
|
|
2037
2018
|
}
|
|
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
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2019
|
+
}), Zt = /* @__PURE__ */ be(Gt, [["__scopeId", "data-v-b956002c"]]), zt = {
|
|
2020
|
+
key: 0,
|
|
2021
|
+
class: "xml-node__comment"
|
|
2022
|
+
}, Dt = {
|
|
2023
|
+
key: 1,
|
|
2024
|
+
class: "xml-node__cdata"
|
|
2025
|
+
}, Jt = {
|
|
2026
|
+
key: 2,
|
|
2027
|
+
class: "xml-node__element"
|
|
2028
|
+
}, er = {
|
|
2029
|
+
key: 0,
|
|
2030
|
+
class: "xml-node__line"
|
|
2031
|
+
}, tr = {
|
|
2032
|
+
key: 1,
|
|
2033
|
+
class: "xml-node__line"
|
|
2034
|
+
}, rr = { key: 2 }, nr = { class: "xml-node__line" }, sr = ["title"], or = { key: 1 }, ir = ["title"], ar = {
|
|
2035
|
+
key: 0,
|
|
2036
|
+
class: "xml-node__children"
|
|
2037
|
+
}, lr = {
|
|
2038
|
+
key: 0,
|
|
2039
|
+
class: "xml-node__text"
|
|
2040
|
+
}, ur = {
|
|
2041
|
+
key: 1,
|
|
2042
|
+
class: "xml-node__line"
|
|
2043
|
+
}, cr = /* @__PURE__ */ ye({
|
|
2044
|
+
__name: "XmlNode",
|
|
2045
|
+
props: {
|
|
2046
|
+
node: {},
|
|
2047
|
+
index: {},
|
|
2048
|
+
level: { default: 0 },
|
|
2049
|
+
parentPath: { default: "" },
|
|
2050
|
+
expanded: {},
|
|
2051
|
+
theme: {}
|
|
2052
|
+
},
|
|
2053
|
+
emits: ["toggle-expand", "copy"],
|
|
2054
|
+
setup(r, { emit: e }) {
|
|
2055
|
+
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(() => {
|
|
2056
|
+
const p = t.node[":@"] || {}, $ = {};
|
|
2057
|
+
return Object.keys(p).forEach((E) => {
|
|
2058
|
+
E.startsWith("@_") && ($[E.substring(2)] = p[E]);
|
|
2059
|
+
}), $;
|
|
2060
|
+
}), l = V(() => {
|
|
2061
|
+
if (u.value !== "element" || !n.value) return [];
|
|
2062
|
+
const p = t.node[n.value];
|
|
2063
|
+
return Array.isArray(p) ? p : [];
|
|
2064
|
+
}), h = V(() => l.value.some((p) => p.__cdata)), f = V(() => {
|
|
2065
|
+
if (!h.value) return "";
|
|
2066
|
+
const p = l.value.find(($) => $.__cdata);
|
|
2067
|
+
if (p && Array.isArray(p.__cdata)) {
|
|
2068
|
+
const $ = p.__cdata;
|
|
2069
|
+
if ($.length > 0 && $[0]["#text"])
|
|
2070
|
+
return $[0]["#text"];
|
|
2071
|
+
}
|
|
2072
|
+
return "";
|
|
2073
|
+
}), b = V(() => {
|
|
2074
|
+
if (u.value !== "element" || !n.value || h.value) return "";
|
|
2075
|
+
const p = t.node[n.value];
|
|
2076
|
+
if (!Array.isArray(p)) return "";
|
|
2077
|
+
const $ = p.find((E) => E["#text"]);
|
|
2078
|
+
return $ ? $["#text"] : "";
|
|
2079
|
+
}), m = V(() => {
|
|
2080
|
+
if (u.value !== "comment") return "";
|
|
2081
|
+
const p = t.node["#comment"];
|
|
2082
|
+
return Array.isArray(p) && p.length > 0 && p[0]["#text"] || "";
|
|
2083
|
+
}), 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() !== ""), _ = () => {
|
|
2084
|
+
w.value && s("toggle-expand", o.value);
|
|
2085
|
+
}, j = (p, $) => `${o.value}-child-${$}`, H = () => `${o.value}.${n.value}`;
|
|
2086
|
+
return (p, $) => {
|
|
2087
|
+
const E = Ue("XmlNode", !0);
|
|
2088
|
+
return x(), A("div", {
|
|
2089
|
+
class: "xml-node",
|
|
2090
|
+
style: P({ paddingLeft: p.level > 0 ? "16px" : "0" })
|
|
2091
|
+
}, [
|
|
2092
|
+
u.value === "comment" ? (x(), A("div", zt, [
|
|
2093
|
+
v("span", {
|
|
2094
|
+
style: P({ color: p.theme.colors.xmlComment })
|
|
2095
|
+
}, " <!-- " + R(m.value) + " --> ", 5)
|
|
2096
|
+
])) : u.value === "cdata" ? (x(), A("div", Dt, [
|
|
2097
|
+
v("span", {
|
|
2098
|
+
style: P({ color: p.theme.colors.xmlCdata })
|
|
2099
|
+
}, " <![CDATA[" + R(p.node.__cdata) + "]]> ", 5)
|
|
2100
|
+
])) : u.value === "element" ? (x(), A("div", Jt, [
|
|
2101
|
+
h.value ? (x(), A("div", er, [
|
|
2102
|
+
v("span", {
|
|
2103
|
+
class: "xml-node__bracket",
|
|
2104
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2105
|
+
}, "<", 4),
|
|
2106
|
+
v("span", {
|
|
2107
|
+
class: "xml-node__tag",
|
|
2108
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2109
|
+
}, R(n.value), 5),
|
|
2110
|
+
(x(!0), A(de, null, fe(a.value, (O, I) => (x(), A("span", {
|
|
2111
|
+
key: I,
|
|
2112
|
+
class: "xml-node__attribute"
|
|
2113
|
+
}, [
|
|
2114
|
+
v("span", {
|
|
2115
|
+
class: "xml-node__attr-name",
|
|
2116
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2117
|
+
}, R(I), 5),
|
|
2118
|
+
v("span", {
|
|
2119
|
+
class: "xml-node__equals",
|
|
2120
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2121
|
+
}, "=", 4),
|
|
2122
|
+
v("span", {
|
|
2123
|
+
class: "xml-node__quote",
|
|
2124
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2125
|
+
}, '"', 4),
|
|
2126
|
+
v("span", {
|
|
2127
|
+
class: "xml-node__attr-value",
|
|
2128
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2129
|
+
}, R(O), 5),
|
|
2130
|
+
v("span", {
|
|
2131
|
+
class: "xml-node__quote",
|
|
2132
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2133
|
+
}, '"', 4)
|
|
2134
|
+
]))), 128)),
|
|
2135
|
+
v("span", {
|
|
2136
|
+
class: "xml-node__bracket",
|
|
2137
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2138
|
+
}, ">", 4),
|
|
2139
|
+
v("span", {
|
|
2140
|
+
class: "xml-node__cdata",
|
|
2141
|
+
style: P({ color: p.theme.colors.xmlCdata })
|
|
2142
|
+
}, "<![CDATA[" + R(f.value) + "]]>", 5),
|
|
2143
|
+
v("span", {
|
|
2144
|
+
class: "xml-node__bracket",
|
|
2145
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2146
|
+
}, "</", 4),
|
|
2147
|
+
v("span", {
|
|
2148
|
+
class: "xml-node__tag",
|
|
2149
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2150
|
+
}, R(n.value), 5),
|
|
2151
|
+
v("span", {
|
|
2152
|
+
class: "xml-node__bracket",
|
|
2153
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2154
|
+
}, ">", 4)
|
|
2155
|
+
])) : S.value ? (x(), A("div", tr, [
|
|
2156
|
+
v("span", {
|
|
2157
|
+
class: "xml-node__bracket",
|
|
2158
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2159
|
+
}, "<", 4),
|
|
2160
|
+
v("span", {
|
|
2161
|
+
class: "xml-node__tag",
|
|
2162
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2163
|
+
}, R(n.value), 5),
|
|
2164
|
+
(x(!0), A(de, null, fe(a.value, (O, I) => (x(), A("span", {
|
|
2165
|
+
key: I,
|
|
2166
|
+
class: "xml-node__attribute"
|
|
2167
|
+
}, [
|
|
2168
|
+
v("span", {
|
|
2169
|
+
class: "xml-node__attr-name",
|
|
2170
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2171
|
+
}, R(I), 5),
|
|
2172
|
+
v("span", {
|
|
2173
|
+
class: "xml-node__equals",
|
|
2174
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2175
|
+
}, "=", 4),
|
|
2176
|
+
v("span", {
|
|
2177
|
+
class: "xml-node__quote",
|
|
2178
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2179
|
+
}, '"', 4),
|
|
2180
|
+
v("span", {
|
|
2181
|
+
class: "xml-node__attr-value",
|
|
2182
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2183
|
+
}, R(O), 5),
|
|
2184
|
+
v("span", {
|
|
2185
|
+
class: "xml-node__quote",
|
|
2186
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2187
|
+
}, '"', 4)
|
|
2188
|
+
]))), 128)),
|
|
2189
|
+
v("span", {
|
|
2190
|
+
class: "xml-node__bracket",
|
|
2191
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2192
|
+
}, ">", 4),
|
|
2193
|
+
v("span", {
|
|
2194
|
+
class: "xml-node__text-content",
|
|
2195
|
+
style: P({ color: p.theme.colors.xmlText })
|
|
2196
|
+
}, R(b.value), 5),
|
|
2197
|
+
v("span", {
|
|
2198
|
+
class: "xml-node__bracket",
|
|
2199
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2200
|
+
}, "</", 4),
|
|
2201
|
+
v("span", {
|
|
2202
|
+
class: "xml-node__tag",
|
|
2203
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2204
|
+
}, R(n.value), 5),
|
|
2205
|
+
v("span", {
|
|
2206
|
+
class: "xml-node__bracket",
|
|
2207
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2208
|
+
}, ">", 4)
|
|
2209
|
+
])) : (x(), A("div", rr, [
|
|
2210
|
+
v("div", nr, [
|
|
2211
|
+
w.value ? (x(), A("span", {
|
|
2212
|
+
key: 0,
|
|
2213
|
+
class: "xml-node__clickable-part",
|
|
2214
|
+
onClick: $[0] || ($[0] = (O) => _()),
|
|
2215
|
+
title: i.value ? "Click to collapse" : "Click to expand"
|
|
2216
|
+
}, [
|
|
2217
|
+
v("span", {
|
|
2218
|
+
class: "xml-node__bracket",
|
|
2219
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2220
|
+
}, "<", 4),
|
|
2221
|
+
v("span", {
|
|
2222
|
+
class: "xml-node__tag",
|
|
2223
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2224
|
+
}, R(n.value), 5)
|
|
2225
|
+
], 8, sr)) : (x(), A("span", or, [
|
|
2226
|
+
v("span", {
|
|
2227
|
+
class: "xml-node__bracket",
|
|
2228
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2229
|
+
}, "<", 4),
|
|
2230
|
+
v("span", {
|
|
2231
|
+
class: "xml-node__tag",
|
|
2232
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2233
|
+
}, R(n.value), 5)
|
|
2234
|
+
])),
|
|
2235
|
+
(x(!0), A(de, null, fe(a.value, (O, I) => (x(), A("span", {
|
|
2236
|
+
key: I,
|
|
2237
|
+
class: "xml-node__attribute"
|
|
2238
|
+
}, [
|
|
2239
|
+
v("span", {
|
|
2240
|
+
class: "xml-node__attr-name",
|
|
2241
|
+
style: P({ color: p.theme.colors.xmlAttribute })
|
|
2242
|
+
}, R(I), 5),
|
|
2243
|
+
v("span", {
|
|
2244
|
+
class: "xml-node__equals",
|
|
2245
|
+
style: P({ color: p.theme.colors.xmlEquals })
|
|
2246
|
+
}, "=", 4),
|
|
2247
|
+
v("span", {
|
|
2248
|
+
class: "xml-node__quote",
|
|
2249
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2250
|
+
}, '"', 4),
|
|
2251
|
+
v("span", {
|
|
2252
|
+
class: "xml-node__attr-value",
|
|
2253
|
+
style: P({ color: p.theme.colors.xmlAttributeValue })
|
|
2254
|
+
}, R(O), 5),
|
|
2255
|
+
v("span", {
|
|
2256
|
+
class: "xml-node__quote",
|
|
2257
|
+
style: P({ color: p.theme.colors.xmlQuote })
|
|
2258
|
+
}, '"', 4)
|
|
2259
|
+
]))), 128)),
|
|
2260
|
+
w.value ? (x(), A("span", {
|
|
2261
|
+
key: 2,
|
|
2262
|
+
class: "xml-node__clickable-part",
|
|
2263
|
+
onClick: $[1] || ($[1] = (O) => _()),
|
|
2264
|
+
title: i.value ? "Click to collapse" : "Click to expand"
|
|
2265
|
+
}, [
|
|
2266
|
+
v("span", {
|
|
2267
|
+
class: "xml-node__bracket",
|
|
2268
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2269
|
+
}, ">", 4)
|
|
2270
|
+
], 8, ir)) : (x(), A("span", {
|
|
2271
|
+
key: 3,
|
|
2272
|
+
class: "xml-node__bracket",
|
|
2273
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2274
|
+
}, R(w.value ? ">" : "/>"), 5)),
|
|
2275
|
+
!i.value && w.value ? (x(), A("span", {
|
|
2276
|
+
key: 4,
|
|
2277
|
+
class: "xml-node__collapsed xml-node__collapsed--clickable",
|
|
2278
|
+
style: P({ color: p.theme.colors.textSecondary }),
|
|
2279
|
+
onClick: $[2] || ($[2] = (O) => _()),
|
|
2280
|
+
title: "Click to expand"
|
|
2281
|
+
}, "...", 4)) : F("", !0)
|
|
2282
|
+
]),
|
|
2283
|
+
i.value && w.value ? (x(), A("div", ar, [
|
|
2284
|
+
l.value.length === 0 && b.value.trim() ? (x(), A("div", lr, [
|
|
2285
|
+
v("span", {
|
|
2286
|
+
class: "xml-node__text-content",
|
|
2287
|
+
style: P({ color: p.theme.colors.xmlText })
|
|
2288
|
+
}, R(b.value), 5)
|
|
2289
|
+
])) : F("", !0),
|
|
2290
|
+
(x(!0), A(de, null, fe(l.value, (O, I) => (x(), He(E, {
|
|
2291
|
+
key: j(O, I),
|
|
2292
|
+
node: O,
|
|
2293
|
+
index: I,
|
|
2294
|
+
level: p.level + 1,
|
|
2295
|
+
"parent-path": H(),
|
|
2296
|
+
expanded: p.expanded,
|
|
2297
|
+
theme: p.theme,
|
|
2298
|
+
onToggleExpand: $[3] || ($[3] = (X) => p.$emit("toggle-expand", X)),
|
|
2299
|
+
onCopy: $[4] || ($[4] = (X) => p.$emit("copy", X))
|
|
2300
|
+
}, null, 8, ["node", "index", "level", "parent-path", "expanded", "theme"]))), 128))
|
|
2301
|
+
])) : F("", !0),
|
|
2302
|
+
i.value && w.value ? (x(), A("div", ur, [
|
|
2303
|
+
v("span", {
|
|
2304
|
+
class: "xml-node__clickable-part",
|
|
2305
|
+
onClick: $[5] || ($[5] = (O) => _()),
|
|
2306
|
+
title: "Click to collapse"
|
|
2307
|
+
}, [
|
|
2308
|
+
v("span", {
|
|
2309
|
+
class: "xml-node__bracket",
|
|
2310
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2311
|
+
}, "</", 4),
|
|
2312
|
+
v("span", {
|
|
2313
|
+
class: "xml-node__tag",
|
|
2314
|
+
style: P({ color: p.theme.colors.xmlTag })
|
|
2315
|
+
}, R(n.value), 5),
|
|
2316
|
+
v("span", {
|
|
2317
|
+
class: "xml-node__bracket",
|
|
2318
|
+
style: P({ color: p.theme.colors.xmlBracket })
|
|
2319
|
+
}, ">", 4)
|
|
2320
|
+
])
|
|
2321
|
+
])) : F("", !0)
|
|
2322
|
+
]))
|
|
2323
|
+
])) : F("", !0)
|
|
2324
|
+
], 4);
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
}), dr = /* @__PURE__ */ be(cr, [["__scopeId", "data-v-9c0c90fa"]]), fr = {
|
|
2328
|
+
name: "github-light",
|
|
2329
|
+
colors: {
|
|
2330
|
+
// 背景色
|
|
2331
|
+
background: "#ffffff",
|
|
2332
|
+
surfaceBackground: "#f6f8fa",
|
|
2333
|
+
// 边框色
|
|
2334
|
+
border: "#d0d7de",
|
|
2335
|
+
// 文本色
|
|
2336
|
+
text: "#24292f",
|
|
2337
|
+
textSecondary: "#57606a",
|
|
2338
|
+
// 按钮样式
|
|
2339
|
+
buttonBackground: "#f6f8fa",
|
|
2340
|
+
buttonBackgroundHover: "#f3f4f6",
|
|
2341
|
+
buttonBorder: "#d0d7de",
|
|
2342
|
+
buttonText: "#24292f",
|
|
2343
|
+
buttonPrimary: "#1f883d",
|
|
2344
|
+
buttonPrimaryHover: "#1a7f37",
|
|
2345
|
+
// 状态指示
|
|
2346
|
+
success: "#1f883d",
|
|
2347
|
+
successBackground: "#dafbe1",
|
|
2348
|
+
error: "#cf222e",
|
|
2349
|
+
errorBackground: "#ffebe9",
|
|
2350
|
+
// XML 语法高亮
|
|
2351
|
+
xmlTag: "#116329",
|
|
2352
|
+
// 标签名 - 绿色
|
|
2353
|
+
xmlAttribute: "#0550ae",
|
|
2354
|
+
// 属性名 - 蓝色
|
|
2355
|
+
xmlAttributeValue: "#0a3069",
|
|
2356
|
+
// 属性值 - 深蓝
|
|
2357
|
+
xmlText: "#24292f",
|
|
2358
|
+
// 文本内容 - 黑色
|
|
2359
|
+
xmlComment: "#6e7781",
|
|
2360
|
+
// 注释 - 灰色
|
|
2361
|
+
xmlCdata: "#8250df",
|
|
2362
|
+
// CDATA - 紫色
|
|
2363
|
+
xmlDeclaration: "#953800",
|
|
2364
|
+
// 声明 - 橙色
|
|
2365
|
+
xmlBracket: "#6e7781",
|
|
2366
|
+
// 括号 - 灰色
|
|
2367
|
+
xmlEquals: "#6e7781",
|
|
2368
|
+
// 等号 - 灰色
|
|
2369
|
+
xmlQuote: "#0550ae"
|
|
2370
|
+
// 引号 - 蓝色
|
|
2371
|
+
}
|
|
2372
|
+
}, hr = {
|
|
2373
|
+
name: "github-dark",
|
|
2374
|
+
colors: {
|
|
2375
|
+
// 背景色
|
|
2376
|
+
background: "#0d1117",
|
|
2377
|
+
surfaceBackground: "#161b22",
|
|
2378
|
+
// 边框色
|
|
2379
|
+
border: "#30363d",
|
|
2380
|
+
// 文本色
|
|
2381
|
+
text: "#c9d1d9",
|
|
2382
|
+
textSecondary: "#8b949e",
|
|
2383
|
+
// 按钮样式
|
|
2384
|
+
buttonBackground: "#21262d",
|
|
2385
|
+
buttonBackgroundHover: "#30363d",
|
|
2386
|
+
buttonBorder: "#30363d",
|
|
2387
|
+
buttonText: "#c9d1d9",
|
|
2388
|
+
buttonPrimary: "#238636",
|
|
2389
|
+
buttonPrimaryHover: "#2ea043",
|
|
2390
|
+
// 状态指示
|
|
2391
|
+
success: "#3fb950",
|
|
2392
|
+
successBackground: "#0f2e1c",
|
|
2393
|
+
error: "#f85149",
|
|
2394
|
+
errorBackground: "#3d1319",
|
|
2395
|
+
// XML 语法高亮
|
|
2396
|
+
xmlTag: "#7ee787",
|
|
2397
|
+
// 标签名 - 亮绿色
|
|
2398
|
+
xmlAttribute: "#79c0ff",
|
|
2399
|
+
// 属性名 - 亮蓝色
|
|
2400
|
+
xmlAttributeValue: "#a5d6ff",
|
|
2401
|
+
// 属性值 - 淡蓝色
|
|
2402
|
+
xmlText: "#c9d1d9",
|
|
2403
|
+
// 文本内容 - 白色
|
|
2404
|
+
xmlComment: "#8b949e",
|
|
2405
|
+
// 注释 - 灰色
|
|
2406
|
+
xmlCdata: "#d2a8ff",
|
|
2407
|
+
// CDATA - 紫色
|
|
2408
|
+
xmlDeclaration: "#ffa657",
|
|
2409
|
+
// 声明 - 橙色
|
|
2410
|
+
xmlBracket: "#8b949e",
|
|
2411
|
+
// 括号 - 灰色
|
|
2412
|
+
xmlEquals: "#8b949e",
|
|
2413
|
+
// 等号 - 灰色
|
|
2414
|
+
xmlQuote: "#79c0ff"
|
|
2415
|
+
// 引号 - 亮蓝色
|
|
2416
|
+
}
|
|
2417
|
+
}, pr = {
|
|
2418
|
+
name: "min-light",
|
|
2419
|
+
colors: {
|
|
2420
|
+
// 背景色
|
|
2421
|
+
background: "#ffffff",
|
|
2422
|
+
surfaceBackground: "#fafafa",
|
|
2423
|
+
// 边框色
|
|
2424
|
+
border: "#e5e5e5",
|
|
2425
|
+
// 文本色
|
|
2426
|
+
text: "#171717",
|
|
2427
|
+
textSecondary: "#737373",
|
|
2428
|
+
// 按钮样式
|
|
2429
|
+
buttonBackground: "#fafafa",
|
|
2430
|
+
buttonBackgroundHover: "#f5f5f5",
|
|
2431
|
+
buttonBorder: "#e5e5e5",
|
|
2432
|
+
buttonText: "#171717",
|
|
2433
|
+
buttonPrimary: "#22c55e",
|
|
2434
|
+
buttonPrimaryHover: "#16a34a",
|
|
2435
|
+
// 状态指示
|
|
2436
|
+
success: "#22c55e",
|
|
2437
|
+
successBackground: "#dcfce7",
|
|
2438
|
+
error: "#ef4444",
|
|
2439
|
+
errorBackground: "#fee2e2",
|
|
2440
|
+
// XML 语法高亮
|
|
2441
|
+
xmlTag: "#16a34a",
|
|
2442
|
+
// 标签名 - 绿色
|
|
2443
|
+
xmlAttribute: "#2563eb",
|
|
2444
|
+
// 属性名 - 蓝色
|
|
2445
|
+
xmlAttributeValue: "#1e40af",
|
|
2446
|
+
// 属性值 - 深蓝
|
|
2447
|
+
xmlText: "#171717",
|
|
2448
|
+
// 文本内容 - 黑色
|
|
2449
|
+
xmlComment: "#737373",
|
|
2450
|
+
// 注释 - 灰色
|
|
2451
|
+
xmlCdata: "#9333ea",
|
|
2452
|
+
// CDATA - 紫色
|
|
2453
|
+
xmlDeclaration: "#ea580c",
|
|
2454
|
+
// 声明 - 橙色
|
|
2455
|
+
xmlBracket: "#737373",
|
|
2456
|
+
// 括号 - 灰色
|
|
2457
|
+
xmlEquals: "#737373",
|
|
2458
|
+
// 等号 - 灰色
|
|
2459
|
+
xmlQuote: "#2563eb"
|
|
2460
|
+
// 引号 - 蓝色
|
|
2461
|
+
}
|
|
2462
|
+
}, gr = {
|
|
2463
|
+
name: "slack-ochin",
|
|
2464
|
+
colors: {
|
|
2465
|
+
// 背景色
|
|
2466
|
+
background: "#fef5ed",
|
|
2467
|
+
surfaceBackground: "#fef9f3",
|
|
2468
|
+
// 边框色
|
|
2469
|
+
border: "#e9dcc9",
|
|
2470
|
+
// 文本色
|
|
2471
|
+
text: "#3d3c40",
|
|
2472
|
+
textSecondary: "#616061",
|
|
2473
|
+
// 按钮样式
|
|
2474
|
+
buttonBackground: "#fef9f3",
|
|
2475
|
+
buttonBackgroundHover: "#f9f0e5",
|
|
2476
|
+
buttonBorder: "#e9dcc9",
|
|
2477
|
+
buttonText: "#3d3c40",
|
|
2478
|
+
buttonPrimary: "#007a5a",
|
|
2479
|
+
buttonPrimaryHover: "#006644",
|
|
2480
|
+
// 状态指示
|
|
2481
|
+
success: "#007a5a",
|
|
2482
|
+
successBackground: "#d1f4e0",
|
|
2483
|
+
error: "#e01e5a",
|
|
2484
|
+
errorBackground: "#ffdbea",
|
|
2485
|
+
// XML 语法高亮
|
|
2486
|
+
xmlTag: "#007a5a",
|
|
2487
|
+
// 标签名 - 绿色
|
|
2488
|
+
xmlAttribute: "#1264a3",
|
|
2489
|
+
// 属性名 - 蓝色
|
|
2490
|
+
xmlAttributeValue: "#0b4c8c",
|
|
2491
|
+
// 属性值 - 深蓝
|
|
2492
|
+
xmlText: "#3d3c40",
|
|
2493
|
+
// 文本内容 - 黑色
|
|
2494
|
+
xmlComment: "#616061",
|
|
2495
|
+
// 注释 - 灰色
|
|
2496
|
+
xmlCdata: "#8b2eff",
|
|
2497
|
+
// CDATA - 紫色
|
|
2498
|
+
xmlDeclaration: "#e8912d",
|
|
2499
|
+
// 声明 - 橙色
|
|
2500
|
+
xmlBracket: "#616061",
|
|
2501
|
+
// 括号 - 灰色
|
|
2502
|
+
xmlEquals: "#616061",
|
|
2503
|
+
// 等号 - 灰色
|
|
2504
|
+
xmlQuote: "#1264a3"
|
|
2505
|
+
// 引号 - 蓝色
|
|
2506
|
+
}
|
|
2507
|
+
}, Be = {
|
|
2508
|
+
"github-light": fr,
|
|
2509
|
+
"github-dark": hr,
|
|
2510
|
+
"min-light": pr,
|
|
2511
|
+
"slack-ochin": gr
|
|
2512
|
+
}, 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 + "$");
|
|
2513
|
+
function Ye(r, e) {
|
|
2514
|
+
const t = [];
|
|
2515
|
+
let s = e.exec(r);
|
|
2516
|
+
for (; s; ) {
|
|
2517
|
+
const n = [];
|
|
2518
|
+
n.startIndex = e.lastIndex - s[0].length;
|
|
2519
|
+
const o = s.length;
|
|
2520
|
+
for (let i = 0; i < o; i++)
|
|
2521
|
+
n.push(s[i]);
|
|
2522
|
+
t.push(n), s = e.exec(r);
|
|
2523
|
+
}
|
|
2524
|
+
return t;
|
|
2525
|
+
}
|
|
2526
|
+
const ve = function(r) {
|
|
2527
|
+
const e = vr.exec(r);
|
|
2528
|
+
return !(e === null || typeof e > "u");
|
|
2529
|
+
};
|
|
2530
|
+
function Er(r) {
|
|
2531
|
+
return typeof r < "u";
|
|
2532
|
+
}
|
|
2533
|
+
const _r = {
|
|
2534
|
+
allowBooleanAttributes: !1,
|
|
2535
|
+
//A tag can have attributes without any value
|
|
2536
|
+
unpairedTags: []
|
|
2537
|
+
};
|
|
2538
|
+
function Qe(r, e) {
|
|
2539
|
+
e = Object.assign({}, _r, e);
|
|
2540
|
+
const t = [];
|
|
2541
|
+
let s = !1, n = !1;
|
|
2542
|
+
r[0] === "\uFEFF" && (r = r.substr(1));
|
|
2543
|
+
for (let o = 0; o < r.length; o++)
|
|
2544
|
+
if (r[o] === "<" && r[o + 1] === "?") {
|
|
2545
|
+
if (o += 2, o = Le(r, o), o.err) return o;
|
|
2546
|
+
} else if (r[o] === "<") {
|
|
2547
|
+
let i = o;
|
|
2548
|
+
if (o++, r[o] === "!") {
|
|
2549
|
+
o = Re(r, o);
|
|
2550
|
+
continue;
|
|
2551
|
+
} else {
|
|
2552
|
+
let u = !1;
|
|
2553
|
+
r[o] === "/" && (u = !0, o++);
|
|
2554
|
+
let a = "";
|
|
2555
|
+
for (; o < r.length && r[o] !== ">" && r[o] !== " " && r[o] !== " " && r[o] !== `
|
|
2556
|
+
` && r[o] !== "\r"; o++)
|
|
2557
|
+
a += r[o];
|
|
2558
|
+
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !Tr(a)) {
|
|
2559
|
+
let f;
|
|
2560
|
+
return a.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + a + "' is an invalid name.", U("InvalidTag", f, W(r, o));
|
|
2561
|
+
}
|
|
2562
|
+
const l = Ar(r, o);
|
|
2563
|
+
if (l === !1)
|
|
2564
|
+
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.", W(r, o));
|
|
2565
|
+
let h = l.value;
|
|
2566
|
+
if (o = l.index, h[h.length - 1] === "/") {
|
|
2567
|
+
const f = o - h.length;
|
|
2568
|
+
h = h.substring(0, h.length - 1);
|
|
2569
|
+
const b = je(h, e);
|
|
2570
|
+
if (b === !0)
|
|
2571
|
+
s = !0;
|
|
2572
|
+
else
|
|
2573
|
+
return U(b.err.code, b.err.msg, W(r, f + b.err.line));
|
|
2574
|
+
} else if (u)
|
|
2575
|
+
if (l.tagClosed) {
|
|
2576
|
+
if (h.trim().length > 0)
|
|
2577
|
+
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", W(r, i));
|
|
2578
|
+
if (t.length === 0)
|
|
2579
|
+
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.", W(r, i));
|
|
2580
|
+
{
|
|
2581
|
+
const f = t.pop();
|
|
2582
|
+
if (a !== f.tagName) {
|
|
2583
|
+
let b = W(r, f.tagStartPos);
|
|
2584
|
+
return U(
|
|
2585
|
+
"InvalidTag",
|
|
2586
|
+
"Expected closing tag '" + f.tagName + "' (opened in line " + b.line + ", col " + b.col + ") instead of closing tag '" + a + "'.",
|
|
2587
|
+
W(r, i)
|
|
2588
|
+
);
|
|
2589
|
+
}
|
|
2590
|
+
t.length == 0 && (n = !0);
|
|
2591
|
+
}
|
|
2592
|
+
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", W(r, o));
|
|
2593
|
+
else {
|
|
2594
|
+
const f = je(h, e);
|
|
2595
|
+
if (f !== !0)
|
|
2596
|
+
return U(f.err.code, f.err.msg, W(r, o - h.length + f.err.line));
|
|
2597
|
+
if (n === !0)
|
|
2598
|
+
return U("InvalidXml", "Multiple possible root nodes found.", W(r, o));
|
|
2599
|
+
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2600
|
+
}
|
|
2601
|
+
for (o++; o < r.length; o++)
|
|
2602
|
+
if (r[o] === "<")
|
|
2603
|
+
if (r[o + 1] === "!") {
|
|
2604
|
+
o++, o = Re(r, o);
|
|
2605
|
+
continue;
|
|
2606
|
+
} else if (r[o + 1] === "?") {
|
|
2607
|
+
if (o = Le(r, ++o), o.err) return o;
|
|
2608
|
+
} else
|
|
2609
|
+
break;
|
|
2610
|
+
else if (r[o] === "&") {
|
|
2611
|
+
const f = Cr(r, o);
|
|
2612
|
+
if (f == -1)
|
|
2613
|
+
return U("InvalidChar", "char '&' is not expected.", W(r, o));
|
|
2614
|
+
o = f;
|
|
2615
|
+
} else if (n === !0 && !Ve(r[o]))
|
|
2616
|
+
return U("InvalidXml", "Extra text at the end", W(r, o));
|
|
2617
|
+
r[o] === "<" && o--;
|
|
2618
|
+
}
|
|
2619
|
+
} else {
|
|
2620
|
+
if (Ve(r[o]))
|
|
2621
|
+
continue;
|
|
2622
|
+
return U("InvalidChar", "char '" + r[o] + "' is not expected.", W(r, o));
|
|
2623
|
+
}
|
|
2624
|
+
if (s) {
|
|
2625
|
+
if (t.length == 1)
|
|
2626
|
+
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", W(r, t[0].tagStartPos));
|
|
2627
|
+
if (t.length > 0)
|
|
2628
|
+
return U("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
2629
|
+
} else return U("InvalidXml", "Start tag expected.", 1);
|
|
2630
|
+
return !0;
|
|
2631
|
+
}
|
|
2632
|
+
function Ve(r) {
|
|
2633
|
+
return r === " " || r === " " || r === `
|
|
2634
|
+
` || r === "\r";
|
|
2635
|
+
}
|
|
2636
|
+
function Le(r, e) {
|
|
2637
|
+
const t = e;
|
|
2638
|
+
for (; e < r.length; e++)
|
|
2639
|
+
if (r[e] == "?" || r[e] == " ") {
|
|
2640
|
+
const s = r.substr(t, e - t);
|
|
2641
|
+
if (e > 5 && s === "xml")
|
|
2642
|
+
return U("InvalidXml", "XML declaration allowed only at the start of the document.", W(r, e));
|
|
2643
|
+
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2644
|
+
e++;
|
|
2645
|
+
break;
|
|
2646
|
+
} else
|
|
2647
|
+
continue;
|
|
2648
|
+
}
|
|
2649
|
+
return e;
|
|
2650
|
+
}
|
|
2651
|
+
function Re(r, e) {
|
|
2652
|
+
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2653
|
+
for (e += 3; e < r.length; e++)
|
|
2654
|
+
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
2655
|
+
e += 2;
|
|
2656
|
+
break;
|
|
2657
|
+
}
|
|
2658
|
+
} 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") {
|
|
2659
|
+
let t = 1;
|
|
2660
|
+
for (e += 8; e < r.length; e++)
|
|
2661
|
+
if (r[e] === "<")
|
|
2662
|
+
t++;
|
|
2663
|
+
else if (r[e] === ">" && (t--, t === 0))
|
|
2664
|
+
break;
|
|
2665
|
+
} 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] === "[") {
|
|
2666
|
+
for (e += 8; e < r.length; e++)
|
|
2667
|
+
if (r[e] === "]" && r[e + 1] === "]" && r[e + 2] === ">") {
|
|
2668
|
+
e += 2;
|
|
2669
|
+
break;
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
return e;
|
|
2673
|
+
}
|
|
2674
|
+
const xr = '"', Nr = "'";
|
|
2675
|
+
function Ar(r, e) {
|
|
2676
|
+
let t = "", s = "", n = !1;
|
|
2677
|
+
for (; e < r.length; e++) {
|
|
2678
|
+
if (r[e] === xr || r[e] === Nr)
|
|
2679
|
+
s === "" ? s = r[e] : s !== r[e] || (s = "");
|
|
2680
|
+
else if (r[e] === ">" && s === "") {
|
|
2681
|
+
n = !0;
|
|
2682
|
+
break;
|
|
2683
|
+
}
|
|
2684
|
+
t += r[e];
|
|
2685
|
+
}
|
|
2686
|
+
return s !== "" ? !1 : {
|
|
2687
|
+
value: t,
|
|
2688
|
+
index: e,
|
|
2689
|
+
tagClosed: n
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
const kr = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
2693
|
+
function je(r, e) {
|
|
2694
|
+
const t = Ye(r, kr), s = {};
|
|
2695
|
+
for (let n = 0; n < t.length; n++) {
|
|
2696
|
+
if (t[n][1].length === 0)
|
|
2697
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' has no space in starting.", pe(t[n]));
|
|
2698
|
+
if (t[n][3] !== void 0 && t[n][4] === void 0)
|
|
2699
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' is without value.", pe(t[n]));
|
|
2700
|
+
if (t[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
2701
|
+
return U("InvalidAttr", "boolean attribute '" + t[n][2] + "' is not allowed.", pe(t[n]));
|
|
2702
|
+
const o = t[n][2];
|
|
2703
|
+
if (!Or(o))
|
|
2704
|
+
return U("InvalidAttr", "Attribute '" + o + "' is an invalid name.", pe(t[n]));
|
|
2705
|
+
if (!s.hasOwnProperty(o))
|
|
2706
|
+
s[o] = 1;
|
|
2707
|
+
else
|
|
2708
|
+
return U("InvalidAttr", "Attribute '" + o + "' is repeated.", pe(t[n]));
|
|
2709
|
+
}
|
|
2710
|
+
return !0;
|
|
2711
|
+
}
|
|
2712
|
+
function wr(r, e) {
|
|
2713
|
+
let t = /\d/;
|
|
2714
|
+
for (r[e] === "x" && (e++, t = /[\da-fA-F]/); e < r.length; e++) {
|
|
2715
|
+
if (r[e] === ";")
|
|
2716
|
+
return e;
|
|
2717
|
+
if (!r[e].match(t))
|
|
2718
|
+
break;
|
|
2719
|
+
}
|
|
2720
|
+
return -1;
|
|
2721
|
+
}
|
|
2722
|
+
function Cr(r, e) {
|
|
2723
|
+
if (e++, r[e] === ";")
|
|
2724
|
+
return -1;
|
|
2725
|
+
if (r[e] === "#")
|
|
2726
|
+
return e++, wr(r, e);
|
|
2727
|
+
let t = 0;
|
|
2728
|
+
for (; e < r.length; e++, t++)
|
|
2729
|
+
if (!(r[e].match(/\w/) && t < 20)) {
|
|
2730
|
+
if (r[e] === ";")
|
|
2731
|
+
break;
|
|
2732
|
+
return -1;
|
|
2733
|
+
}
|
|
2734
|
+
return e;
|
|
2735
|
+
}
|
|
2736
|
+
function U(r, e, t) {
|
|
2737
|
+
return {
|
|
2738
|
+
err: {
|
|
2739
|
+
code: r,
|
|
2740
|
+
msg: e,
|
|
2741
|
+
line: t.line || t,
|
|
2742
|
+
col: t.col
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
function Or(r) {
|
|
2747
|
+
return ve(r);
|
|
2748
|
+
}
|
|
2749
|
+
function Tr(r) {
|
|
2750
|
+
return ve(r);
|
|
2751
|
+
}
|
|
2752
|
+
function W(r, e) {
|
|
2753
|
+
const t = r.substring(0, e).split(/\r?\n/);
|
|
2754
|
+
return {
|
|
2755
|
+
line: t.length,
|
|
2756
|
+
// column number is last line's length + 1, because column numbering starts at 1:
|
|
2757
|
+
col: t[t.length - 1].length + 1
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
function pe(r) {
|
|
2761
|
+
return r.startIndex + r[1].length;
|
|
2762
|
+
}
|
|
2763
|
+
const Pr = {
|
|
2764
|
+
preserveOrder: !1,
|
|
2765
|
+
attributeNamePrefix: "@_",
|
|
2766
|
+
attributesGroupName: !1,
|
|
2767
|
+
textNodeName: "#text",
|
|
2768
|
+
ignoreAttributes: !0,
|
|
2769
|
+
removeNSPrefix: !1,
|
|
2770
|
+
// remove NS from tag name or attribute name if true
|
|
2771
|
+
allowBooleanAttributes: !1,
|
|
2772
|
+
//a tag can have attributes without any value
|
|
2773
|
+
//ignoreRootElement : false,
|
|
2774
|
+
parseTagValue: !0,
|
|
2775
|
+
parseAttributeValue: !1,
|
|
2776
|
+
trimValues: !0,
|
|
2777
|
+
//Trim string values of tag and attributes
|
|
2778
|
+
cdataPropName: !1,
|
|
2779
|
+
numberParseOptions: {
|
|
2780
|
+
hex: !0,
|
|
2781
|
+
leadingZeros: !0,
|
|
2782
|
+
eNotation: !0
|
|
2783
|
+
},
|
|
2784
|
+
tagValueProcessor: function(r, e) {
|
|
2785
|
+
return e;
|
|
2312
2786
|
},
|
|
2313
2787
|
attributeValueProcessor: function(r, e) {
|
|
2314
2788
|
return e;
|
|
@@ -2330,12 +2804,12 @@ const ur = {
|
|
|
2330
2804
|
},
|
|
2331
2805
|
// skipEmptyListItem: false
|
|
2332
2806
|
captureMetaData: !1
|
|
2333
|
-
},
|
|
2334
|
-
return Object.assign({},
|
|
2807
|
+
}, $r = function(r) {
|
|
2808
|
+
return Object.assign({}, Pr, r);
|
|
2335
2809
|
};
|
|
2336
|
-
let
|
|
2337
|
-
typeof Symbol != "function" ?
|
|
2338
|
-
|
|
2810
|
+
let me;
|
|
2811
|
+
typeof Symbol != "function" ? me = "@@xmlMetadata" : me = Symbol("XML Node Metadata");
|
|
2812
|
+
class oe {
|
|
2339
2813
|
constructor(e) {
|
|
2340
2814
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
2341
2815
|
}
|
|
@@ -2343,14 +2817,14 @@ let oe = class {
|
|
|
2343
2817
|
e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: t });
|
|
2344
2818
|
}
|
|
2345
2819
|
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][
|
|
2820
|
+
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
2821
|
}
|
|
2348
2822
|
/** symbol used for metadata */
|
|
2349
2823
|
static getMetaDataSymbol() {
|
|
2350
|
-
return
|
|
2824
|
+
return me;
|
|
2351
2825
|
}
|
|
2352
|
-
}
|
|
2353
|
-
class
|
|
2826
|
+
}
|
|
2827
|
+
class Sr {
|
|
2354
2828
|
constructor(e) {
|
|
2355
2829
|
this.suppressValidationErr = !e;
|
|
2356
2830
|
}
|
|
@@ -2392,11 +2866,11 @@ class dr {
|
|
|
2392
2866
|
return { entities: s, i: t };
|
|
2393
2867
|
}
|
|
2394
2868
|
readEntityExp(e, t) {
|
|
2395
|
-
t =
|
|
2869
|
+
t = G(e, t);
|
|
2396
2870
|
let s = "";
|
|
2397
2871
|
for (; t < e.length && !/\s/.test(e[t]) && e[t] !== '"' && e[t] !== "'"; )
|
|
2398
2872
|
s += e[t], t++;
|
|
2399
|
-
if (
|
|
2873
|
+
if (ge(s), t = G(e, t), !this.suppressValidationErr) {
|
|
2400
2874
|
if (e.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
2401
2875
|
throw new Error("External entities are not supported");
|
|
2402
2876
|
if (e[t] === "%")
|
|
@@ -2406,18 +2880,18 @@ class dr {
|
|
|
2406
2880
|
return [t, n] = this.readIdentifierVal(e, t, "entity"), t--, [s, n, t];
|
|
2407
2881
|
}
|
|
2408
2882
|
readNotationExp(e, t) {
|
|
2409
|
-
t =
|
|
2883
|
+
t = G(e, t);
|
|
2410
2884
|
let s = "";
|
|
2411
2885
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2412
2886
|
s += e[t], t++;
|
|
2413
|
-
!this.suppressValidationErr &&
|
|
2887
|
+
!this.suppressValidationErr && ge(s), t = G(e, t);
|
|
2414
2888
|
const n = e.substring(t, t + 6).toUpperCase();
|
|
2415
2889
|
if (!this.suppressValidationErr && n !== "SYSTEM" && n !== "PUBLIC")
|
|
2416
2890
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);
|
|
2417
|
-
t += n.length, t =
|
|
2891
|
+
t += n.length, t = G(e, t);
|
|
2418
2892
|
let o = null, i = null;
|
|
2419
2893
|
if (n === "PUBLIC")
|
|
2420
|
-
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t =
|
|
2894
|
+
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t = G(e, t), (e[t] === '"' || e[t] === "'") && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"));
|
|
2421
2895
|
else if (n === "SYSTEM" && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !i))
|
|
2422
2896
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
2423
2897
|
return { notationName: s, publicIdentifier: o, systemIdentifier: i, index: --t };
|
|
@@ -2434,13 +2908,13 @@ class dr {
|
|
|
2434
2908
|
return t++, [t, n];
|
|
2435
2909
|
}
|
|
2436
2910
|
readElementExp(e, t) {
|
|
2437
|
-
t =
|
|
2911
|
+
t = G(e, t);
|
|
2438
2912
|
let s = "";
|
|
2439
2913
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2440
2914
|
s += e[t], t++;
|
|
2441
|
-
if (!this.suppressValidationErr && !
|
|
2915
|
+
if (!this.suppressValidationErr && !ve(s))
|
|
2442
2916
|
throw new Error(`Invalid element name: "${s}"`);
|
|
2443
|
-
t =
|
|
2917
|
+
t = G(e, t);
|
|
2444
2918
|
let n = "";
|
|
2445
2919
|
if (e[t] === "E" && se(e, "MPTY", t)) t += 4;
|
|
2446
2920
|
else if (e[t] === "A" && se(e, "NY", t)) t += 2;
|
|
@@ -2458,20 +2932,20 @@ class dr {
|
|
|
2458
2932
|
};
|
|
2459
2933
|
}
|
|
2460
2934
|
readAttlistExp(e, t) {
|
|
2461
|
-
t =
|
|
2935
|
+
t = G(e, t);
|
|
2462
2936
|
let s = "";
|
|
2463
2937
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2464
2938
|
s += e[t], t++;
|
|
2465
|
-
|
|
2939
|
+
ge(s), t = G(e, t);
|
|
2466
2940
|
let n = "";
|
|
2467
2941
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2468
2942
|
n += e[t], t++;
|
|
2469
|
-
if (!
|
|
2943
|
+
if (!ge(n))
|
|
2470
2944
|
throw new Error(`Invalid attribute name: "${n}"`);
|
|
2471
|
-
t =
|
|
2945
|
+
t = G(e, t);
|
|
2472
2946
|
let o = "";
|
|
2473
2947
|
if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
|
|
2474
|
-
if (o = "NOTATION", t += 8, t =
|
|
2948
|
+
if (o = "NOTATION", t += 8, t = G(e, t), e[t] !== "(")
|
|
2475
2949
|
throw new Error(`Expected '(', found "${e[t]}"`);
|
|
2476
2950
|
t++;
|
|
2477
2951
|
let u = [];
|
|
@@ -2479,9 +2953,9 @@ class dr {
|
|
|
2479
2953
|
let a = "";
|
|
2480
2954
|
for (; t < e.length && e[t] !== "|" && e[t] !== ")"; )
|
|
2481
2955
|
a += e[t], t++;
|
|
2482
|
-
if (a = a.trim(), !
|
|
2956
|
+
if (a = a.trim(), !ge(a))
|
|
2483
2957
|
throw new Error(`Invalid notation name: "${a}"`);
|
|
2484
|
-
u.push(a), e[t] === "|" && (t++, t =
|
|
2958
|
+
u.push(a), e[t] === "|" && (t++, t = G(e, t));
|
|
2485
2959
|
}
|
|
2486
2960
|
if (e[t] !== ")")
|
|
2487
2961
|
throw new Error("Unterminated list of notations");
|
|
@@ -2493,7 +2967,7 @@ class dr {
|
|
|
2493
2967
|
if (!this.suppressValidationErr && !u.includes(o.toUpperCase()))
|
|
2494
2968
|
throw new Error(`Invalid attribute type: "${o}"`);
|
|
2495
2969
|
}
|
|
2496
|
-
t =
|
|
2970
|
+
t = G(e, t);
|
|
2497
2971
|
let i = "";
|
|
2498
2972
|
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
2973
|
elementName: s,
|
|
@@ -2504,7 +2978,7 @@ class dr {
|
|
|
2504
2978
|
};
|
|
2505
2979
|
}
|
|
2506
2980
|
}
|
|
2507
|
-
const
|
|
2981
|
+
const G = (r, e) => {
|
|
2508
2982
|
for (; e < r.length && /\s/.test(r[e]); )
|
|
2509
2983
|
e++;
|
|
2510
2984
|
return e;
|
|
@@ -2514,12 +2988,12 @@ function se(r, e, t) {
|
|
|
2514
2988
|
if (e[s] !== r[t + s + 1]) return !1;
|
|
2515
2989
|
return !0;
|
|
2516
2990
|
}
|
|
2517
|
-
function
|
|
2518
|
-
if (
|
|
2991
|
+
function ge(r) {
|
|
2992
|
+
if (ve(r))
|
|
2519
2993
|
return r;
|
|
2520
2994
|
throw new Error(`Invalid entity name ${r}`);
|
|
2521
2995
|
}
|
|
2522
|
-
const
|
|
2996
|
+
const Ir = /^[-+]?0x[a-fA-F0-9]+$/, Br = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, Vr = {
|
|
2523
2997
|
hex: !0,
|
|
2524
2998
|
// oct: false,
|
|
2525
2999
|
leadingZeros: !0,
|
|
@@ -2527,20 +3001,20 @@ const fr = /^[-+]?0x[a-fA-F0-9]+$/, hr = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, p
|
|
|
2527
3001
|
eNotation: !0
|
|
2528
3002
|
//skipLike: /regex/
|
|
2529
3003
|
};
|
|
2530
|
-
function
|
|
2531
|
-
if (e = Object.assign({},
|
|
3004
|
+
function Lr(r, e = {}) {
|
|
3005
|
+
if (e = Object.assign({}, Vr, e), !r || typeof r != "string") return r;
|
|
2532
3006
|
let t = r.trim();
|
|
2533
3007
|
if (e.skipLike !== void 0 && e.skipLike.test(t)) return r;
|
|
2534
3008
|
if (r === "0") return 0;
|
|
2535
|
-
if (e.hex &&
|
|
2536
|
-
return
|
|
3009
|
+
if (e.hex && Ir.test(t))
|
|
3010
|
+
return Ur(t, 16);
|
|
2537
3011
|
if (t.search(/.+[eE].+/) !== -1)
|
|
2538
|
-
return
|
|
3012
|
+
return jr(r, t, e);
|
|
2539
3013
|
{
|
|
2540
|
-
const s =
|
|
3014
|
+
const s = Br.exec(t);
|
|
2541
3015
|
if (s) {
|
|
2542
3016
|
const n = s[1] || "", o = s[2];
|
|
2543
|
-
let i =
|
|
3017
|
+
let i = Mr(s[3]);
|
|
2544
3018
|
const u = n ? (
|
|
2545
3019
|
// 0., -00., 000.
|
|
2546
3020
|
r[o.length + 1] === "."
|
|
@@ -2561,10 +3035,10 @@ function gr(r, e = {}) {
|
|
|
2561
3035
|
return r;
|
|
2562
3036
|
}
|
|
2563
3037
|
}
|
|
2564
|
-
const
|
|
2565
|
-
function
|
|
3038
|
+
const Rr = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
3039
|
+
function jr(r, e, t) {
|
|
2566
3040
|
if (!t.eNotation) return r;
|
|
2567
|
-
const s = e.match(
|
|
3041
|
+
const s = e.match(Rr);
|
|
2568
3042
|
if (s) {
|
|
2569
3043
|
let n = s[1] || "";
|
|
2570
3044
|
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2], u = n ? (
|
|
@@ -2575,23 +3049,23 @@ function br(r, e, t) {
|
|
|
2575
3049
|
} else
|
|
2576
3050
|
return r;
|
|
2577
3051
|
}
|
|
2578
|
-
function
|
|
3052
|
+
function Mr(r) {
|
|
2579
3053
|
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
3054
|
}
|
|
2581
|
-
function
|
|
3055
|
+
function Ur(r, e) {
|
|
2582
3056
|
if (parseInt) return parseInt(r, e);
|
|
2583
3057
|
if (Number.parseInt) return Number.parseInt(r, e);
|
|
2584
3058
|
if (window && window.parseInt) return window.parseInt(r, e);
|
|
2585
3059
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
2586
3060
|
}
|
|
2587
|
-
function
|
|
3061
|
+
function We(r) {
|
|
2588
3062
|
return typeof r == "function" ? r : Array.isArray(r) ? (e) => {
|
|
2589
3063
|
for (const t of r)
|
|
2590
3064
|
if (typeof t == "string" && e === t || t instanceof RegExp && t.test(e))
|
|
2591
3065
|
return !0;
|
|
2592
3066
|
} : () => !1;
|
|
2593
3067
|
}
|
|
2594
|
-
class
|
|
3068
|
+
class Fr {
|
|
2595
3069
|
constructor(e) {
|
|
2596
3070
|
this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
2597
3071
|
apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
@@ -2614,10 +3088,10 @@ class vr {
|
|
|
2614
3088
|
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
2615
3089
|
num_dec: { regex: /&#([0-9]{1,7});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 10)) },
|
|
2616
3090
|
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 16)) }
|
|
2617
|
-
}, this.addExternalEntities =
|
|
3091
|
+
}, 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
3092
|
}
|
|
2619
3093
|
}
|
|
2620
|
-
function
|
|
3094
|
+
function Xr(r) {
|
|
2621
3095
|
const e = Object.keys(r);
|
|
2622
3096
|
for (let t = 0; t < e.length; t++) {
|
|
2623
3097
|
const s = e[t];
|
|
@@ -2627,14 +3101,14 @@ function _r(r) {
|
|
|
2627
3101
|
};
|
|
2628
3102
|
}
|
|
2629
3103
|
}
|
|
2630
|
-
function
|
|
3104
|
+
function Hr(r, e, t, s, n, o, i) {
|
|
2631
3105
|
if (r !== void 0 && (this.options.trimValues && !s && (r = r.trim()), r.length > 0)) {
|
|
2632
3106
|
i || (r = this.replaceEntitiesValue(r));
|
|
2633
3107
|
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 ?
|
|
3108
|
+
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
3109
|
}
|
|
2636
3110
|
}
|
|
2637
|
-
function
|
|
3111
|
+
function Kr(r) {
|
|
2638
3112
|
if (this.options.removeNSPrefix) {
|
|
2639
3113
|
const e = r.split(":"), t = r.charAt(0) === "/" ? "/" : "";
|
|
2640
3114
|
if (e[0] === "xmlns")
|
|
@@ -2643,10 +3117,10 @@ function Nr(r) {
|
|
|
2643
3117
|
}
|
|
2644
3118
|
return r;
|
|
2645
3119
|
}
|
|
2646
|
-
const
|
|
2647
|
-
function
|
|
3120
|
+
const qr = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
3121
|
+
function Yr(r, e, t) {
|
|
2648
3122
|
if (this.options.ignoreAttributes !== !0 && typeof r == "string") {
|
|
2649
|
-
const s = Ye(r,
|
|
3123
|
+
const s = Ye(r, qr), n = s.length, o = {};
|
|
2650
3124
|
for (let i = 0; i < n; i++) {
|
|
2651
3125
|
const u = this.resolveNameSpace(s[i][1]);
|
|
2652
3126
|
if (this.ignoreAttributesFn(u, e))
|
|
@@ -2656,7 +3130,7 @@ function wr(r, e, t) {
|
|
|
2656
3130
|
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), a !== void 0) {
|
|
2657
3131
|
this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a);
|
|
2658
3132
|
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] =
|
|
3133
|
+
h == null ? o[l] = a : typeof h != typeof a || h !== a ? o[l] = h : o[l] = Ce(
|
|
2660
3134
|
a,
|
|
2661
3135
|
this.options.parseAttributeValue,
|
|
2662
3136
|
this.options.numberParseOptions
|
|
@@ -2672,20 +3146,20 @@ function wr(r, e, t) {
|
|
|
2672
3146
|
return o;
|
|
2673
3147
|
}
|
|
2674
3148
|
}
|
|
2675
|
-
const
|
|
3149
|
+
const Qr = function(r) {
|
|
2676
3150
|
r = r.replace(/\r\n?/g, `
|
|
2677
3151
|
`);
|
|
2678
3152
|
const e = new oe("!xml");
|
|
2679
3153
|
let t = e, s = "", n = "";
|
|
2680
|
-
const o = new
|
|
3154
|
+
const o = new Sr(this.options.processEntities);
|
|
2681
3155
|
for (let i = 0; i < r.length; i++)
|
|
2682
3156
|
if (r[i] === "<")
|
|
2683
3157
|
if (r[i + 1] === "/") {
|
|
2684
3158
|
const a = ie(r, ">", i, "Closing Tag is not closed.");
|
|
2685
3159
|
let l = r.substring(i + 2, a).trim();
|
|
2686
3160
|
if (this.options.removeNSPrefix) {
|
|
2687
|
-
const
|
|
2688
|
-
|
|
3161
|
+
const b = l.indexOf(":");
|
|
3162
|
+
b !== -1 && (l = l.substr(b + 1));
|
|
2689
3163
|
}
|
|
2690
3164
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && (s = this.saveTextToParentTag(s, t, n));
|
|
2691
3165
|
const h = n.substring(n.lastIndexOf(".") + 1);
|
|
@@ -2719,32 +3193,32 @@ const Ar = function(r) {
|
|
|
2719
3193
|
} else {
|
|
2720
3194
|
let a = we(r, i, this.options.removeNSPrefix), l = a.tagName;
|
|
2721
3195
|
const h = a.rawTagName;
|
|
2722
|
-
let f = a.tagExp,
|
|
3196
|
+
let f = a.tagExp, b = a.attrExpPresent, m = a.closeIndex;
|
|
2723
3197
|
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
|
|
3198
|
+
const w = t;
|
|
3199
|
+
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);
|
|
3200
|
+
const S = i;
|
|
2727
3201
|
if (this.isItStopNode(this.options.stopNodes, n, l)) {
|
|
2728
|
-
let
|
|
3202
|
+
let _ = "";
|
|
2729
3203
|
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1)
|
|
2730
3204
|
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
3205
|
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
2732
3206
|
i = a.closeIndex;
|
|
2733
3207
|
else {
|
|
2734
|
-
const
|
|
2735
|
-
if (!
|
|
2736
|
-
i =
|
|
3208
|
+
const H = this.readStopNodeData(r, h, m + 1);
|
|
3209
|
+
if (!H) throw new Error(`Unexpected end of ${h}`);
|
|
3210
|
+
i = H.i, _ = H.tagContent;
|
|
2737
3211
|
}
|
|
2738
|
-
const
|
|
2739
|
-
l !== f &&
|
|
3212
|
+
const j = new oe(l);
|
|
3213
|
+
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
3214
|
} else {
|
|
2741
3215
|
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1) {
|
|
2742
3216
|
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 &&
|
|
3217
|
+
const _ = new oe(l);
|
|
3218
|
+
l !== f && b && (_[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, _, n, S), n = n.substr(0, n.lastIndexOf("."));
|
|
2745
3219
|
} else {
|
|
2746
|
-
const
|
|
2747
|
-
this.tagsNodeStack.push(t), l !== f &&
|
|
3220
|
+
const _ = new oe(l);
|
|
3221
|
+
this.tagsNodeStack.push(t), l !== f && b && (_[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, _, n, S), t = _;
|
|
2748
3222
|
}
|
|
2749
3223
|
s = "", i = m;
|
|
2750
3224
|
}
|
|
@@ -2753,12 +3227,12 @@ const Ar = function(r) {
|
|
|
2753
3227
|
s += r[i];
|
|
2754
3228
|
return e.child;
|
|
2755
3229
|
};
|
|
2756
|
-
function
|
|
3230
|
+
function Wr(r, e, t, s) {
|
|
2757
3231
|
this.options.captureMetaData || (s = void 0);
|
|
2758
3232
|
const n = this.options.updateTag(e.tagname, t, e[":@"]);
|
|
2759
3233
|
n === !1 || (typeof n == "string" && (e.tagname = n), r.addChild(e, s));
|
|
2760
3234
|
}
|
|
2761
|
-
const
|
|
3235
|
+
const Gr = function(r) {
|
|
2762
3236
|
if (this.options.processEntities) {
|
|
2763
3237
|
for (let e in this.docTypeEntities) {
|
|
2764
3238
|
const t = this.docTypeEntities[e];
|
|
@@ -2777,7 +3251,7 @@ const Or = function(r) {
|
|
|
2777
3251
|
}
|
|
2778
3252
|
return r;
|
|
2779
3253
|
};
|
|
2780
|
-
function
|
|
3254
|
+
function Zr(r, e, t, s) {
|
|
2781
3255
|
return r && (s === void 0 && (s = e.child.length === 0), r = this.parseTextData(
|
|
2782
3256
|
r,
|
|
2783
3257
|
e.tagname,
|
|
@@ -2787,7 +3261,7 @@ function Tr(r, e, t, s) {
|
|
|
2787
3261
|
s
|
|
2788
3262
|
), r !== void 0 && r !== "" && e.add(this.options.textNodeName, r), r = ""), r;
|
|
2789
3263
|
}
|
|
2790
|
-
function
|
|
3264
|
+
function zr(r, e, t) {
|
|
2791
3265
|
const s = "*." + t;
|
|
2792
3266
|
for (const n in r) {
|
|
2793
3267
|
const o = r[n];
|
|
@@ -2795,7 +3269,7 @@ function Pr(r, e, t) {
|
|
|
2795
3269
|
}
|
|
2796
3270
|
return !1;
|
|
2797
3271
|
}
|
|
2798
|
-
function
|
|
3272
|
+
function Dr(r, e, t = ">") {
|
|
2799
3273
|
let s, n = "";
|
|
2800
3274
|
for (let o = e; o < r.length; o++) {
|
|
2801
3275
|
let i = r[o];
|
|
@@ -2826,7 +3300,7 @@ function ie(r, e, t, s) {
|
|
|
2826
3300
|
return n + e.length - 1;
|
|
2827
3301
|
}
|
|
2828
3302
|
function we(r, e, t, s = ">") {
|
|
2829
|
-
const n =
|
|
3303
|
+
const n = Dr(r, e + 1, s);
|
|
2830
3304
|
if (!n) return;
|
|
2831
3305
|
let o = n.data;
|
|
2832
3306
|
const i = n.index, u = o.search(/\s/);
|
|
@@ -2845,7 +3319,7 @@ function we(r, e, t, s = ">") {
|
|
|
2845
3319
|
rawTagName: h
|
|
2846
3320
|
};
|
|
2847
3321
|
}
|
|
2848
|
-
function
|
|
3322
|
+
function Jr(r, e, t) {
|
|
2849
3323
|
const s = t;
|
|
2850
3324
|
let n = 1;
|
|
2851
3325
|
for (; t < r.length; t++)
|
|
@@ -2869,22 +3343,22 @@ function Ir(r, e, t) {
|
|
|
2869
3343
|
o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && n++, t = o.closeIndex);
|
|
2870
3344
|
}
|
|
2871
3345
|
}
|
|
2872
|
-
function
|
|
3346
|
+
function Ce(r, e, t) {
|
|
2873
3347
|
if (e && typeof r == "string") {
|
|
2874
3348
|
const s = r.trim();
|
|
2875
|
-
return s === "true" ? !0 : s === "false" ? !1 :
|
|
3349
|
+
return s === "true" ? !0 : s === "false" ? !1 : Lr(r, t);
|
|
2876
3350
|
} else
|
|
2877
|
-
return
|
|
3351
|
+
return Er(r) ? r : "";
|
|
2878
3352
|
}
|
|
2879
|
-
const
|
|
2880
|
-
function
|
|
3353
|
+
const Ae = oe.getMetaDataSymbol();
|
|
3354
|
+
function en(r, e) {
|
|
2881
3355
|
return Ge(r, e);
|
|
2882
3356
|
}
|
|
2883
3357
|
function Ge(r, e, t) {
|
|
2884
3358
|
let s;
|
|
2885
3359
|
const n = {};
|
|
2886
3360
|
for (let o = 0; o < r.length; o++) {
|
|
2887
|
-
const i = r[o], u =
|
|
3361
|
+
const i = r[o], u = tn(i);
|
|
2888
3362
|
let a = "";
|
|
2889
3363
|
if (t === void 0 ? a = u : a = t + "." + u, u === e.textNodeName)
|
|
2890
3364
|
s === void 0 ? s = i[u] : s += "" + i[u];
|
|
@@ -2893,21 +3367,21 @@ function Ge(r, e, t) {
|
|
|
2893
3367
|
continue;
|
|
2894
3368
|
if (i[u]) {
|
|
2895
3369
|
let l = Ge(i[u], e, a);
|
|
2896
|
-
const h =
|
|
2897
|
-
i[
|
|
3370
|
+
const h = nn(l, e);
|
|
3371
|
+
i[Ae] !== void 0 && (l[Ae] = i[Ae]), 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
3372
|
}
|
|
2899
3373
|
}
|
|
2900
3374
|
}
|
|
2901
3375
|
return typeof s == "string" ? s.length > 0 && (n[e.textNodeName] = s) : s !== void 0 && (n[e.textNodeName] = s), n;
|
|
2902
3376
|
}
|
|
2903
|
-
function
|
|
3377
|
+
function tn(r) {
|
|
2904
3378
|
const e = Object.keys(r);
|
|
2905
3379
|
for (let t = 0; t < e.length; t++) {
|
|
2906
3380
|
const s = e[t];
|
|
2907
3381
|
if (s !== ":@") return s;
|
|
2908
3382
|
}
|
|
2909
3383
|
}
|
|
2910
|
-
function
|
|
3384
|
+
function rn(r, e, t, s) {
|
|
2911
3385
|
if (e) {
|
|
2912
3386
|
const n = Object.keys(e), o = n.length;
|
|
2913
3387
|
for (let i = 0; i < o; i++) {
|
|
@@ -2916,13 +3390,13 @@ function Vr(r, e, t, s) {
|
|
|
2916
3390
|
}
|
|
2917
3391
|
}
|
|
2918
3392
|
}
|
|
2919
|
-
function
|
|
3393
|
+
function nn(r, e) {
|
|
2920
3394
|
const { textNodeName: t } = e, s = Object.keys(r).length;
|
|
2921
3395
|
return !!(s === 0 || s === 1 && (r[t] || typeof r[t] == "boolean" || r[t] === 0));
|
|
2922
3396
|
}
|
|
2923
|
-
class
|
|
3397
|
+
class sn {
|
|
2924
3398
|
constructor(e) {
|
|
2925
|
-
this.externalEntities = {}, this.options =
|
|
3399
|
+
this.externalEntities = {}, this.options = $r(e);
|
|
2926
3400
|
}
|
|
2927
3401
|
/**
|
|
2928
3402
|
* Parse XML dats to JS object
|
|
@@ -2936,14 +3410,14 @@ class Rr {
|
|
|
2936
3410
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
2937
3411
|
if (t) {
|
|
2938
3412
|
t === !0 && (t = {});
|
|
2939
|
-
const o =
|
|
3413
|
+
const o = Qe(e, t);
|
|
2940
3414
|
if (o !== !0)
|
|
2941
3415
|
throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
|
|
2942
3416
|
}
|
|
2943
|
-
const s = new
|
|
3417
|
+
const s = new Fr(this.options);
|
|
2944
3418
|
s.addExternalEntities(this.externalEntities);
|
|
2945
3419
|
const n = s.parseXml(e);
|
|
2946
|
-
return this.options.preserveOrder || n === void 0 ? n :
|
|
3420
|
+
return this.options.preserveOrder || n === void 0 ? n : en(n, this.options);
|
|
2947
3421
|
}
|
|
2948
3422
|
/**
|
|
2949
3423
|
* Add Entity which is not by default supported by this library
|
|
@@ -2973,21 +3447,21 @@ class Rr {
|
|
|
2973
3447
|
return oe.getMetaDataSymbol();
|
|
2974
3448
|
}
|
|
2975
3449
|
}
|
|
2976
|
-
const
|
|
3450
|
+
const on = `
|
|
2977
3451
|
`;
|
|
2978
|
-
function
|
|
3452
|
+
function an(r, e) {
|
|
2979
3453
|
let t = "";
|
|
2980
|
-
return e.format && e.indentBy.length > 0 && (t =
|
|
3454
|
+
return e.format && e.indentBy.length > 0 && (t = on), Ze(r, e, "", t);
|
|
2981
3455
|
}
|
|
2982
|
-
function
|
|
3456
|
+
function Ze(r, e, t, s) {
|
|
2983
3457
|
let n = "", o = !1;
|
|
2984
3458
|
for (let i = 0; i < r.length; i++) {
|
|
2985
|
-
const u = r[i], a =
|
|
3459
|
+
const u = r[i], a = ln(u);
|
|
2986
3460
|
if (a === void 0) continue;
|
|
2987
3461
|
let l = "";
|
|
2988
3462
|
if (t.length === 0 ? l = a : l = `${t}.${a}`, a === e.textNodeName) {
|
|
2989
|
-
let
|
|
2990
|
-
|
|
3463
|
+
let w = u[a];
|
|
3464
|
+
un(l, e) || (w = e.tagValueProcessor(a, w), w = ze(w, e)), o && (n += s), n += w, o = !1;
|
|
2991
3465
|
continue;
|
|
2992
3466
|
} else if (a === e.cdataPropName) {
|
|
2993
3467
|
o && (n += s), n += `<![CDATA[${u[a][0][e.textNodeName]}]]>`, o = !1;
|
|
@@ -2996,19 +3470,19 @@ function We(r, e, t, s) {
|
|
|
2996
3470
|
n += s + `<!--${u[a][0][e.textNodeName]}-->`, o = !0;
|
|
2997
3471
|
continue;
|
|
2998
3472
|
} else if (a[0] === "?") {
|
|
2999
|
-
const
|
|
3000
|
-
let
|
|
3001
|
-
|
|
3473
|
+
const w = Me(u[":@"], e), S = a === "?xml" ? "" : s;
|
|
3474
|
+
let _ = u[a][0][e.textNodeName];
|
|
3475
|
+
_ = _.length !== 0 ? " " + _ : "", n += S + `<${a}${_}${w}?>`, o = !0;
|
|
3002
3476
|
continue;
|
|
3003
3477
|
}
|
|
3004
3478
|
let h = s;
|
|
3005
3479
|
h !== "" && (h += e.indentBy);
|
|
3006
|
-
const f =
|
|
3007
|
-
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n +=
|
|
3480
|
+
const f = Me(u[":@"], e), b = s + `<${a}${f}`, m = Ze(u[a], e, l, h);
|
|
3481
|
+
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
3482
|
}
|
|
3009
3483
|
return n;
|
|
3010
3484
|
}
|
|
3011
|
-
function
|
|
3485
|
+
function ln(r) {
|
|
3012
3486
|
const e = Object.keys(r);
|
|
3013
3487
|
for (let t = 0; t < e.length; t++) {
|
|
3014
3488
|
const s = e[t];
|
|
@@ -3016,24 +3490,24 @@ function Ur(r) {
|
|
|
3016
3490
|
return s;
|
|
3017
3491
|
}
|
|
3018
3492
|
}
|
|
3019
|
-
function
|
|
3493
|
+
function Me(r, e) {
|
|
3020
3494
|
let t = "";
|
|
3021
3495
|
if (r && !e.ignoreAttributes)
|
|
3022
3496
|
for (let s in r) {
|
|
3023
3497
|
if (!r.hasOwnProperty(s)) continue;
|
|
3024
3498
|
let n = e.attributeValueProcessor(s, r[s]);
|
|
3025
|
-
n =
|
|
3499
|
+
n = ze(n, e), n === !0 && e.suppressBooleanAttributes ? t += ` ${s.substr(e.attributeNamePrefix.length)}` : t += ` ${s.substr(e.attributeNamePrefix.length)}="${n}"`;
|
|
3026
3500
|
}
|
|
3027
3501
|
return t;
|
|
3028
3502
|
}
|
|
3029
|
-
function
|
|
3503
|
+
function un(r, e) {
|
|
3030
3504
|
r = r.substr(0, r.length - e.textNodeName.length - 1);
|
|
3031
3505
|
let t = r.substr(r.lastIndexOf(".") + 1);
|
|
3032
3506
|
for (let s in e.stopNodes)
|
|
3033
3507
|
if (e.stopNodes[s] === r || e.stopNodes[s] === "*." + t) return !0;
|
|
3034
3508
|
return !1;
|
|
3035
3509
|
}
|
|
3036
|
-
function
|
|
3510
|
+
function ze(r, e) {
|
|
3037
3511
|
if (r && r.length > 0 && e.processEntities)
|
|
3038
3512
|
for (let t = 0; t < e.entities.length; t++) {
|
|
3039
3513
|
const s = e.entities[t];
|
|
@@ -3041,7 +3515,7 @@ function Ze(r, e) {
|
|
|
3041
3515
|
}
|
|
3042
3516
|
return r;
|
|
3043
3517
|
}
|
|
3044
|
-
const
|
|
3518
|
+
const cn = {
|
|
3045
3519
|
attributeNamePrefix: "@_",
|
|
3046
3520
|
attributesGroupName: !1,
|
|
3047
3521
|
textNodeName: "#text",
|
|
@@ -3076,16 +3550,16 @@ const Xr = {
|
|
|
3076
3550
|
oneListGroup: !1
|
|
3077
3551
|
};
|
|
3078
3552
|
function ne(r) {
|
|
3079
|
-
this.options = Object.assign({},
|
|
3553
|
+
this.options = Object.assign({}, cn, r), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
3080
3554
|
return !1;
|
|
3081
|
-
} : (this.ignoreAttributesFn =
|
|
3555
|
+
} : (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
3556
|
`, this.newLine = `
|
|
3083
3557
|
`) : (this.indentate = function() {
|
|
3084
3558
|
return "";
|
|
3085
3559
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
3086
3560
|
}
|
|
3087
3561
|
ne.prototype.build = function(r) {
|
|
3088
|
-
return this.options.preserveOrder ?
|
|
3562
|
+
return this.options.preserveOrder ? an(r, this.options) : (Array.isArray(r) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (r = {
|
|
3089
3563
|
[this.options.arrayNodeName]: r
|
|
3090
3564
|
}), this.j2x(r, 0, []).val);
|
|
3091
3565
|
};
|
|
@@ -3119,13 +3593,13 @@ ne.prototype.j2x = function(r, e, t) {
|
|
|
3119
3593
|
i[0] === "?" ? n += this.indentate(e) + "<" + i + "?" + this.tagEndChar : n += this.indentate(e) + "<" + i + "/" + this.tagEndChar;
|
|
3120
3594
|
else if (typeof f == "object")
|
|
3121
3595
|
if (this.options.oneListGroup) {
|
|
3122
|
-
const
|
|
3123
|
-
a +=
|
|
3596
|
+
const b = this.j2x(f, e + 1, t.concat(i));
|
|
3597
|
+
a += b.val, this.options.attributesGroupName && f.hasOwnProperty(this.options.attributesGroupName) && (l += b.attrStr);
|
|
3124
3598
|
} else
|
|
3125
3599
|
a += this.processTextOrObjNode(f, i, e, t);
|
|
3126
3600
|
else if (this.options.oneListGroup) {
|
|
3127
|
-
let
|
|
3128
|
-
|
|
3601
|
+
let b = this.options.tagValueProcessor(i, f);
|
|
3602
|
+
b = this.replaceEntitiesValue(b), a += b;
|
|
3129
3603
|
} else
|
|
3130
3604
|
a += this.buildTextValNode(f, i, "", e);
|
|
3131
3605
|
}
|
|
@@ -3141,7 +3615,7 @@ ne.prototype.j2x = function(r, e, t) {
|
|
|
3141
3615
|
ne.prototype.buildAttrPairStr = function(r, e) {
|
|
3142
3616
|
return e = this.options.attributeValueProcessor(r, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + r : " " + r + '="' + e + '"';
|
|
3143
3617
|
};
|
|
3144
|
-
function
|
|
3618
|
+
function dn(r, e, t, s) {
|
|
3145
3619
|
const n = this.j2x(r, t + 1, s.concat(e));
|
|
3146
3620
|
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
3621
|
}
|
|
@@ -3177,15 +3651,15 @@ ne.prototype.replaceEntitiesValue = function(r) {
|
|
|
3177
3651
|
}
|
|
3178
3652
|
return r;
|
|
3179
3653
|
};
|
|
3180
|
-
function
|
|
3654
|
+
function fn(r) {
|
|
3181
3655
|
return this.options.indentBy.repeat(r);
|
|
3182
3656
|
}
|
|
3183
|
-
function
|
|
3657
|
+
function hn(r) {
|
|
3184
3658
|
return r.startsWith(this.options.attributeNamePrefix) && r !== this.options.textNodeName ? r.substr(this.attrPrefixLen) : !1;
|
|
3185
3659
|
}
|
|
3186
|
-
const
|
|
3187
|
-
validate:
|
|
3188
|
-
},
|
|
3660
|
+
const pn = {
|
|
3661
|
+
validate: Qe
|
|
3662
|
+
}, gn = {
|
|
3189
3663
|
ignoreAttributes: !1,
|
|
3190
3664
|
// 保留属性
|
|
3191
3665
|
attributeNamePrefix: "@_",
|
|
@@ -3198,540 +3672,140 @@ const qr = {
|
|
|
3198
3672
|
// 注释属性名
|
|
3199
3673
|
cdataPropName: "__cdata",
|
|
3200
3674
|
// CDATA 属性名
|
|
3201
|
-
preserveOrder: !
|
|
3202
|
-
//
|
|
3675
|
+
preserveOrder: !0,
|
|
3676
|
+
// 保留顺序(使用数组结构以保留注释位置)
|
|
3203
3677
|
parseAttributeValue: !1,
|
|
3204
3678
|
// 不解析属性值(保持字符串)
|
|
3205
3679
|
trimValues: !0,
|
|
3206
3680
|
// 去除首尾空白
|
|
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);
|
|
3681
|
+
parseTagValue: !1,
|
|
3682
|
+
// 不解析标签值(保持字符串)
|
|
3683
|
+
processEntities: !0,
|
|
3684
|
+
// 处理实体
|
|
3685
|
+
htmlEntities: !1,
|
|
3686
|
+
// 不是 HTML 实体
|
|
3687
|
+
ignoreNameSpace: !1,
|
|
3688
|
+
// 保留命名空间
|
|
3689
|
+
allowBooleanAttributes: !0,
|
|
3690
|
+
// 允许布尔属性
|
|
3691
|
+
unpairedTags: [],
|
|
3692
|
+
// 未配对的标签
|
|
3693
|
+
stopNodes: [],
|
|
3694
|
+
// 停止解析的节点
|
|
3695
|
+
alwaysCreateTextNode: !1
|
|
3696
|
+
// 仅在有文本时创建文本节点
|
|
3697
|
+
}, mn = {
|
|
3698
|
+
ignoreAttributes: !1,
|
|
3699
|
+
attributeNamePrefix: "@_",
|
|
3700
|
+
textNodeName: "#text",
|
|
3701
|
+
format: !0,
|
|
3702
|
+
// 格式化输出
|
|
3703
|
+
indentBy: " ",
|
|
3704
|
+
// 缩进 2 空格
|
|
3705
|
+
suppressEmptyNode: !1,
|
|
3706
|
+
// 不抑制空节点
|
|
3707
|
+
suppressBooleanAttributes: !1,
|
|
3708
|
+
suppressUnpairedNode: !1
|
|
3709
|
+
}, yn = (r) => {
|
|
3710
|
+
try {
|
|
3711
|
+
const e = pn.validate(r, {
|
|
3712
|
+
allowBooleanAttributes: !0
|
|
3713
|
+
});
|
|
3714
|
+
return e === !0 ? { valid: !0 } : {
|
|
3715
|
+
valid: !1,
|
|
3716
|
+
error: `Line ${e.err.line}: ${e.err.msg}`
|
|
3717
|
+
};
|
|
3718
|
+
} catch (e) {
|
|
3719
|
+
return {
|
|
3720
|
+
valid: !1,
|
|
3721
|
+
error: e instanceof Error ? e.message : "Unknown validation error"
|
|
3532
3722
|
};
|
|
3533
3723
|
}
|
|
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
|
-
// 引号 - 蓝色
|
|
3724
|
+
}, De = (r, e) => {
|
|
3725
|
+
try {
|
|
3726
|
+
return new sn({
|
|
3727
|
+
...gn,
|
|
3728
|
+
...e
|
|
3729
|
+
}).parse(r);
|
|
3730
|
+
} catch (t) {
|
|
3731
|
+
throw new Error(
|
|
3732
|
+
`XML 解析失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3733
|
+
);
|
|
3578
3734
|
}
|
|
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
|
-
// 引号 - 亮蓝色
|
|
3735
|
+
}, Pe = (r, e) => {
|
|
3736
|
+
try {
|
|
3737
|
+
let s = new ne({
|
|
3738
|
+
...mn,
|
|
3739
|
+
format: e?.format ?? !0,
|
|
3740
|
+
indentBy: e?.indentBy ?? " "
|
|
3741
|
+
}).build(r);
|
|
3742
|
+
return e?.showDeclaration !== !1 && !s.startsWith("<?xml") && (s = `<?xml version="1.0" encoding="UTF-8"?>
|
|
3743
|
+
` + s), s;
|
|
3744
|
+
} catch (t) {
|
|
3745
|
+
throw new Error(
|
|
3746
|
+
`XML 构建失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3747
|
+
);
|
|
3623
3748
|
}
|
|
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
|
-
// 引号 - 蓝色
|
|
3749
|
+
}, bn = (r) => Array.isArray(r) ? Ee(r, { format: !1 }) : Pe(r, { format: !1, showDeclaration: !1 }), vn = (r, e) => {
|
|
3750
|
+
const t = De(r);
|
|
3751
|
+
return Array.isArray(t) ? Ee(t, {
|
|
3752
|
+
indent: e?.indentBy
|
|
3753
|
+
}) : Pe(t, e);
|
|
3754
|
+
}, Ee = (r, e = {}) => {
|
|
3755
|
+
const t = e.indent !== void 0 ? e.indent : " ", s = e.level || 0, n = e.format !== !1, o = n ? t.repeat(s) : "", i = n ? `
|
|
3756
|
+
` : "";
|
|
3757
|
+
let u = "";
|
|
3758
|
+
for (const a of r) {
|
|
3759
|
+
if (a["?xml"]) {
|
|
3760
|
+
const _ = a[":@"] || {}, j = Object.entries(_).map(([H, p]) => `${H.startsWith("@_") ? H.substring(2) : H}="${p}"`).join(" ");
|
|
3761
|
+
u += `<?xml ${j}?>${i}`;
|
|
3762
|
+
continue;
|
|
3763
|
+
}
|
|
3764
|
+
if (a["#comment"]) {
|
|
3765
|
+
const _ = a["#comment"];
|
|
3766
|
+
if (Array.isArray(_) && _.length > 0) {
|
|
3767
|
+
const j = _[0]["#text"] || _[0];
|
|
3768
|
+
u += `${o}<!--${j}-->${i}`;
|
|
3769
|
+
}
|
|
3770
|
+
continue;
|
|
3771
|
+
}
|
|
3772
|
+
const l = Object.keys(a).find((_) => !_.startsWith(":") && !_.startsWith("#") && !_.startsWith("__"));
|
|
3773
|
+
if (!l) continue;
|
|
3774
|
+
const h = a[l], f = a[":@"] || {}, b = Object.entries(f).map(([_, j]) => `${_.startsWith("@_") ? _.substring(2) : _}="${j}"`).join(" "), m = b ? " " + b : "";
|
|
3775
|
+
if (!Array.isArray(h) || h.length === 0) {
|
|
3776
|
+
u += `${o}<${l}${m}/>${i}`;
|
|
3777
|
+
continue;
|
|
3778
|
+
}
|
|
3779
|
+
const w = h.length === 1 && h[0]["#text"] !== void 0;
|
|
3780
|
+
if (h.some((_) => _.__cdata)) {
|
|
3781
|
+
const _ = h.find((j) => j.__cdata);
|
|
3782
|
+
if (_) {
|
|
3783
|
+
const j = _.__cdata[0]["#text"] || "";
|
|
3784
|
+
u += `${o}<${l}${m}><![CDATA[${j}]]></${l}>${i}`;
|
|
3785
|
+
}
|
|
3786
|
+
} else if (w) {
|
|
3787
|
+
const _ = h[0]["#text"];
|
|
3788
|
+
u += `${o}<${l}${m}>${_}</${l}>${i}`;
|
|
3789
|
+
} else
|
|
3790
|
+
u += `${o}<${l}${m}>${i}`, u += Ee(h, { indent: t, level: s + 1, format: n }), u += `${o}</${l}>${i}`;
|
|
3668
3791
|
}
|
|
3792
|
+
return u;
|
|
3669
3793
|
}, 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
3794
|
key: 0,
|
|
3721
3795
|
class: "xml-format__toolbar"
|
|
3722
|
-
},
|
|
3796
|
+
}, _n = { class: "xml-format__actions" }, xn = ["disabled"], Nn = ["disabled"], An = ["disabled"], kn = ["disabled"], wn = ["disabled"], Cn = { class: "xml-format__info" }, On = {
|
|
3723
3797
|
key: 0,
|
|
3724
3798
|
class: "xml-format__status xml-format__status--success"
|
|
3725
|
-
},
|
|
3799
|
+
}, Tn = {
|
|
3726
3800
|
key: 1,
|
|
3727
3801
|
class: "xml-format__status xml-format__status--error"
|
|
3728
|
-
},
|
|
3802
|
+
}, Pn = { class: "xml-format__content" }, $n = {
|
|
3729
3803
|
key: 0,
|
|
3730
3804
|
class: "xml-format__error"
|
|
3731
|
-
},
|
|
3805
|
+
}, Sn = {
|
|
3732
3806
|
key: 1,
|
|
3733
3807
|
class: "xml-format__viewer"
|
|
3734
|
-
},
|
|
3808
|
+
}, In = /* @__PURE__ */ ye({
|
|
3735
3809
|
__name: "index",
|
|
3736
3810
|
props: {
|
|
3737
3811
|
modelValue: { default: "" },
|
|
@@ -3745,190 +3819,198 @@ const qr = {
|
|
|
3745
3819
|
},
|
|
3746
3820
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
3747
3821
|
setup(r, { expose: e, emit: t }) {
|
|
3748
|
-
|
|
3749
|
-
"
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
"
|
|
3753
|
-
|
|
3754
|
-
"
|
|
3755
|
-
"
|
|
3756
|
-
"
|
|
3757
|
-
|
|
3758
|
-
"
|
|
3759
|
-
"
|
|
3760
|
-
"
|
|
3761
|
-
"
|
|
3762
|
-
|
|
3822
|
+
Oe((E) => ({
|
|
3823
|
+
"0db40539": l.value.colors.border,
|
|
3824
|
+
bd72d08a: l.value.colors.background,
|
|
3825
|
+
"1738b57a": l.value.colors.text,
|
|
3826
|
+
"69331e8e": l.value.colors.surfaceBackground,
|
|
3827
|
+
cd0ca56a: l.value.colors.buttonBorder,
|
|
3828
|
+
"02f5e6cd": l.value.colors.buttonBackground,
|
|
3829
|
+
"060d3a0c": l.value.colors.buttonText,
|
|
3830
|
+
"6ac62a6f": l.value.colors.buttonBackgroundHover,
|
|
3831
|
+
"7ef6f8c3": l.value.colors.buttonPrimary,
|
|
3832
|
+
"24e03b8e": l.value.colors.buttonPrimaryHover,
|
|
3833
|
+
"357fd096": l.value.colors.success,
|
|
3834
|
+
"4d328338": l.value.colors.successBackground,
|
|
3835
|
+
"61df294a": l.value.colors.error,
|
|
3836
|
+
"3307322e": l.value.colors.errorBackground
|
|
3763
3837
|
}));
|
|
3764
|
-
const s = r, n = t, o =
|
|
3765
|
-
if (!o.value) return
|
|
3766
|
-
const
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
}),
|
|
3770
|
-
}),
|
|
3771
|
-
if (!
|
|
3838
|
+
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(() => {
|
|
3839
|
+
if (!o.value || !Array.isArray(o.value)) return null;
|
|
3840
|
+
const E = o.value.find((X) => X["?xml"]);
|
|
3841
|
+
if (!E || !E[":@"]) return null;
|
|
3842
|
+
const O = E[":@"], I = [];
|
|
3843
|
+
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;
|
|
3844
|
+
}), b = V(() => h.value), m = (E) => {
|
|
3845
|
+
if (!E || !E.trim()) {
|
|
3772
3846
|
i.value = "", o.value = null;
|
|
3773
3847
|
return;
|
|
3774
3848
|
}
|
|
3775
3849
|
try {
|
|
3776
|
-
const
|
|
3777
|
-
if (!
|
|
3778
|
-
i.value =
|
|
3850
|
+
const O = yn(E);
|
|
3851
|
+
if (!O.valid) {
|
|
3852
|
+
i.value = O.error || "Invalid XML", o.value = null;
|
|
3779
3853
|
return;
|
|
3780
3854
|
}
|
|
3781
|
-
o.value =
|
|
3782
|
-
|
|
3855
|
+
o.value = De(E), i.value = "", he(() => {
|
|
3856
|
+
S();
|
|
3783
3857
|
});
|
|
3784
|
-
} catch (
|
|
3785
|
-
i.value =
|
|
3858
|
+
} catch (O) {
|
|
3859
|
+
i.value = O instanceof Error ? O.message : "Unknown parse error", o.value = null;
|
|
3786
3860
|
}
|
|
3787
|
-
},
|
|
3788
|
-
u.value.has(
|
|
3789
|
-
},
|
|
3790
|
-
const
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
})
|
|
3861
|
+
}, w = (E) => {
|
|
3862
|
+
u.value.has(E) ? u.value.delete(E) : u.value.add(E);
|
|
3863
|
+
}, S = () => {
|
|
3864
|
+
const E = /* @__PURE__ */ new Set(), O = (I, X = "") => {
|
|
3865
|
+
Array.isArray(I) && I.forEach((Z, Y) => {
|
|
3866
|
+
const Q = Object.keys(Z).find((y) => !y.startsWith(":") && !y.startsWith("#"));
|
|
3867
|
+
if (!Q) return;
|
|
3868
|
+
const ee = X ? `${X}[${Y}]` : `${Q}[${Y}]`;
|
|
3869
|
+
E.add(ee);
|
|
3870
|
+
const ae = Z[Q];
|
|
3871
|
+
Array.isArray(ae) && O(ae, ee + "." + Q);
|
|
3872
|
+
});
|
|
3799
3873
|
};
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3874
|
+
h.value.forEach((I, X) => {
|
|
3875
|
+
const Z = Object.keys(I).find((Y) => !Y.startsWith(":") && !Y.startsWith("#"));
|
|
3876
|
+
if (Z) {
|
|
3877
|
+
const Y = `${Z}[${X}]`;
|
|
3878
|
+
E.add(Y);
|
|
3879
|
+
const Q = I[Z];
|
|
3880
|
+
Array.isArray(Q) && O(Q, Y + "." + Z);
|
|
3881
|
+
}
|
|
3882
|
+
}), u.value = E, n("expand-all");
|
|
3883
|
+
}, _ = () => {
|
|
3804
3884
|
u.value.clear(), n("collapse-all");
|
|
3805
|
-
},
|
|
3885
|
+
}, j = async () => {
|
|
3806
3886
|
if (!(!a.value || !o.value))
|
|
3807
3887
|
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);
|
|
3888
|
+
const E = Array.isArray(o.value) ? Ee(o.value, { indent: " " }) : Pe(o.value, { format: !0, indentBy: " " });
|
|
3889
|
+
await navigator.clipboard.writeText(E), n("copy-success", E);
|
|
3890
|
+
} catch (E) {
|
|
3891
|
+
const O = E instanceof Error ? E : new Error("Copy failed");
|
|
3892
|
+
n("copy-error", O), console.error("Failed to copy XML:", E);
|
|
3816
3893
|
}
|
|
3817
|
-
},
|
|
3894
|
+
}, H = () => {
|
|
3818
3895
|
if (!(!a.value || !o.value))
|
|
3819
3896
|
try {
|
|
3820
|
-
const
|
|
3821
|
-
n("update:modelValue",
|
|
3822
|
-
} catch (
|
|
3823
|
-
console.error("Failed to compress XML:",
|
|
3897
|
+
const E = bn(o.value);
|
|
3898
|
+
n("update:modelValue", E), n("compress", E);
|
|
3899
|
+
} catch (E) {
|
|
3900
|
+
console.error("Failed to compress XML:", E);
|
|
3824
3901
|
}
|
|
3825
|
-
},
|
|
3902
|
+
}, p = () => {
|
|
3826
3903
|
if (a.value)
|
|
3827
3904
|
try {
|
|
3828
|
-
const
|
|
3905
|
+
const E = vn(s.modelValue, {
|
|
3829
3906
|
format: !0,
|
|
3830
3907
|
indentBy: " "
|
|
3831
3908
|
});
|
|
3832
|
-
n("update:modelValue",
|
|
3833
|
-
} catch (
|
|
3834
|
-
console.error("Failed to format XML:",
|
|
3909
|
+
n("update:modelValue", E), n("format", E);
|
|
3910
|
+
} catch (E) {
|
|
3911
|
+
console.error("Failed to format XML:", E);
|
|
3835
3912
|
}
|
|
3836
|
-
},
|
|
3913
|
+
}, $ = async (E) => {
|
|
3837
3914
|
try {
|
|
3838
|
-
const
|
|
3839
|
-
await navigator.clipboard.writeText(
|
|
3840
|
-
} catch (
|
|
3841
|
-
const
|
|
3842
|
-
n("copy-error",
|
|
3915
|
+
const O = typeof E == "string" ? E : JSON.stringify(E, null, 2);
|
|
3916
|
+
await navigator.clipboard.writeText(O), n("copy-success", O);
|
|
3917
|
+
} catch (O) {
|
|
3918
|
+
const I = O instanceof Error ? O : new Error("Copy failed");
|
|
3919
|
+
n("copy-error", I), console.error("Failed to copy value:", O);
|
|
3843
3920
|
}
|
|
3844
3921
|
};
|
|
3845
|
-
return
|
|
3846
|
-
|
|
3922
|
+
return Xe(() => s.modelValue, (E) => {
|
|
3923
|
+
m(E);
|
|
3847
3924
|
}, { immediate: !0 }), e({
|
|
3848
3925
|
// 核心操作方法
|
|
3849
|
-
copyXml:
|
|
3850
|
-
compressSource:
|
|
3851
|
-
formatSource:
|
|
3852
|
-
expandAll:
|
|
3853
|
-
collapseAll:
|
|
3854
|
-
toggleExpand:
|
|
3926
|
+
copyXml: j,
|
|
3927
|
+
compressSource: H,
|
|
3928
|
+
formatSource: p,
|
|
3929
|
+
expandAll: S,
|
|
3930
|
+
collapseAll: _,
|
|
3931
|
+
toggleExpand: w,
|
|
3855
3932
|
// 状态访问方法
|
|
3856
3933
|
isValidXml: () => a.value,
|
|
3857
3934
|
getParsedXml: () => o.value,
|
|
3858
3935
|
getExpandedNodes: () => u.value,
|
|
3859
3936
|
getParseError: () => i.value,
|
|
3860
3937
|
// 工具方法
|
|
3861
|
-
parseXmlString: (
|
|
3862
|
-
copyValue: (
|
|
3863
|
-
}), (
|
|
3864
|
-
class:
|
|
3938
|
+
parseXmlString: (E) => m(E),
|
|
3939
|
+
copyValue: (E) => $(E)
|
|
3940
|
+
}), (E, O) => (x(), A("div", {
|
|
3941
|
+
class: Te(["xml-format", `xml-format--${l.value.name}`])
|
|
3865
3942
|
}, [
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3943
|
+
E.showToolbar ? (x(), A("div", En, [
|
|
3944
|
+
v("div", _n, [
|
|
3945
|
+
v("button", {
|
|
3869
3946
|
class: "xml-format__btn xml-format__btn--primary",
|
|
3870
|
-
onClick:
|
|
3947
|
+
onClick: j,
|
|
3871
3948
|
disabled: !a.value,
|
|
3872
3949
|
title: "Copy XML"
|
|
3873
|
-
}, " 📋 Copy ", 8,
|
|
3874
|
-
|
|
3950
|
+
}, " 📋 Copy ", 8, xn),
|
|
3951
|
+
v("button", {
|
|
3875
3952
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3876
|
-
onClick:
|
|
3953
|
+
onClick: S,
|
|
3877
3954
|
disabled: !a.value,
|
|
3878
3955
|
title: "Expand All"
|
|
3879
|
-
}, " ⬇️ Expand All ", 8,
|
|
3880
|
-
|
|
3956
|
+
}, " ⬇️ Expand All ", 8, Nn),
|
|
3957
|
+
v("button", {
|
|
3881
3958
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3882
|
-
onClick:
|
|
3959
|
+
onClick: _,
|
|
3883
3960
|
disabled: !a.value,
|
|
3884
3961
|
title: "Collapse All"
|
|
3885
|
-
}, " ➡️ Collapse All ", 8,
|
|
3886
|
-
|
|
3962
|
+
}, " ➡️ Collapse All ", 8, An),
|
|
3963
|
+
v("button", {
|
|
3887
3964
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3888
|
-
onClick:
|
|
3965
|
+
onClick: H,
|
|
3889
3966
|
disabled: !a.value,
|
|
3890
3967
|
title: "Compress XML"
|
|
3891
|
-
}, " 📦 Compress ", 8,
|
|
3892
|
-
|
|
3968
|
+
}, " 📦 Compress ", 8, kn),
|
|
3969
|
+
v("button", {
|
|
3893
3970
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
3894
|
-
onClick:
|
|
3971
|
+
onClick: p,
|
|
3895
3972
|
disabled: !a.value,
|
|
3896
3973
|
title: "Format XML"
|
|
3897
|
-
}, " ✨ Format ", 8,
|
|
3974
|
+
}, " ✨ Format ", 8, wn)
|
|
3898
3975
|
]),
|
|
3899
|
-
|
|
3900
|
-
a.value ? (x(),
|
|
3976
|
+
v("div", Cn, [
|
|
3977
|
+
a.value ? (x(), A("span", On, " ✅ Valid XML ")) : (x(), A("span", Tn, " ❌ Invalid XML "))
|
|
3901
3978
|
])
|
|
3902
3979
|
])) : F("", !0),
|
|
3903
|
-
|
|
3904
|
-
a.value ? (x(),
|
|
3905
|
-
|
|
3906
|
-
key:
|
|
3907
|
-
|
|
3908
|
-
|
|
3980
|
+
v("div", Pn, [
|
|
3981
|
+
a.value ? (x(), A("div", Sn, [
|
|
3982
|
+
f.value ? (x(), A("div", {
|
|
3983
|
+
key: 0,
|
|
3984
|
+
class: "xml-declaration",
|
|
3985
|
+
style: P({ color: l.value.colors.xmlDeclaration })
|
|
3986
|
+
}, R(f.value), 5)) : F("", !0),
|
|
3987
|
+
(x(!0), A(de, null, fe(b.value, (I, X) => (x(), He(dr, {
|
|
3988
|
+
key: X,
|
|
3989
|
+
node: I,
|
|
3990
|
+
index: X,
|
|
3909
3991
|
level: 0,
|
|
3910
3992
|
expanded: u.value,
|
|
3911
3993
|
theme: l.value,
|
|
3912
|
-
onToggleExpand:
|
|
3913
|
-
onCopy:
|
|
3914
|
-
}, null, 8, ["
|
|
3915
|
-
])) : (x(),
|
|
3916
|
-
|
|
3917
|
-
|
|
3994
|
+
onToggleExpand: w,
|
|
3995
|
+
onCopy: $
|
|
3996
|
+
}, null, 8, ["node", "index", "expanded", "theme"]))), 128))
|
|
3997
|
+
])) : (x(), A("div", $n, [
|
|
3998
|
+
O[0] || (O[0] = v("h4", null, "XML Parse Error:", -1)),
|
|
3999
|
+
v("pre", null, R(i.value), 1)
|
|
3918
4000
|
]))
|
|
3919
4001
|
])
|
|
3920
4002
|
], 2));
|
|
3921
4003
|
}
|
|
3922
|
-
}),
|
|
3923
|
-
|
|
4004
|
+
}), jn = /* @__PURE__ */ be(In, [["__scopeId", "data-v-f9125514"]]), Bn = [Zt], Vn = (r) => {
|
|
4005
|
+
Bn.forEach((e) => {
|
|
3924
4006
|
const t = e.name || e.__name || "UnknownComponent";
|
|
3925
4007
|
r.component(t, e);
|
|
3926
4008
|
});
|
|
3927
|
-
},
|
|
3928
|
-
install:
|
|
4009
|
+
}, Mn = {
|
|
4010
|
+
install: Vn
|
|
3929
4011
|
};
|
|
3930
4012
|
export {
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
4013
|
+
Zt as JsonFormat,
|
|
4014
|
+
jn as XmlFormat,
|
|
4015
|
+
Mn as default
|
|
3934
4016
|
};
|