lone-format 0.5.1 → 0.6.1
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 +1585 -1216
- package/dist/lone-format.umd.cjs +11 -11
- 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 Oe, useCssVars as Le, ref as W, computed as K, resolveComponent as Qe, createElementBlock as P, openBlock as O, createElementVNode as y, createCommentVNode as te, withKeys as U, withModifiers as Z, toDisplayString as M, Fragment as pe, renderList as _e, createVNode as Ye, normalizeClass as je, nextTick as ue, watch as Ge, normalizeStyle as $, createBlock as Ze } from "vue";
|
|
2
|
+
class it {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -42,7 +42,7 @@ class Je {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class at {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -351,14 +351,14 @@ class d {
|
|
|
351
351
|
* @returns {?jsep.BinaryExpression}
|
|
352
352
|
*/
|
|
353
353
|
gobbleBinaryExpression() {
|
|
354
|
-
let e, t, s, n, o, i,
|
|
354
|
+
let e, t, s, n, o, i, c, a, l;
|
|
355
355
|
if (i = this.gobbleToken(), !i || (t = this.gobbleBinaryOp(), !t))
|
|
356
356
|
return i;
|
|
357
357
|
for (o = {
|
|
358
358
|
value: t,
|
|
359
359
|
prec: d.binaryPrecedence(t),
|
|
360
360
|
right_a: d.right_associative.has(t)
|
|
361
|
-
},
|
|
361
|
+
}, c = this.gobbleToken(), c || this.throwError("Expected expression after " + t), n = [i, o, c]; t = this.gobbleBinaryOp(); ) {
|
|
362
362
|
if (s = d.binaryPrecedence(t), s === 0) {
|
|
363
363
|
this.index -= t.length;
|
|
364
364
|
break;
|
|
@@ -368,13 +368,13 @@ class d {
|
|
|
368
368
|
prec: s,
|
|
369
369
|
right_a: d.right_associative.has(t)
|
|
370
370
|
}, l = t;
|
|
371
|
-
const
|
|
372
|
-
for (; n.length > 2 &&
|
|
373
|
-
|
|
371
|
+
const g = (h) => o.right_a && h.right_a ? s > h.prec : s <= h.prec;
|
|
372
|
+
for (; n.length > 2 && g(n[n.length - 2]); )
|
|
373
|
+
c = n.pop(), t = n.pop().value, i = n.pop(), e = {
|
|
374
374
|
type: d.BINARY_EXP,
|
|
375
375
|
operator: t,
|
|
376
376
|
left: i,
|
|
377
|
-
right:
|
|
377
|
+
right: c
|
|
378
378
|
}, n.push(e);
|
|
379
379
|
e = this.gobbleToken(), e || this.throwError("Expected expression after " + l), n.push(o, e);
|
|
380
380
|
}
|
|
@@ -615,10 +615,10 @@ class d {
|
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
618
|
+
const lt = new it();
|
|
619
619
|
Object.assign(d, {
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
620
|
+
hooks: lt,
|
|
621
|
+
plugins: new at(d),
|
|
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(d, {
|
|
|
714
714
|
});
|
|
715
715
|
d.max_unop_len = d.getMaxKeyLen(d.unary_ops);
|
|
716
716
|
d.max_binop_len = d.getMaxKeyLen(d.binary_ops);
|
|
717
|
-
const
|
|
717
|
+
const de = (r) => new d(r).parse(), ct = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(d).filter((r) => !
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(d).filter((r) => !ct.includes(r) && de[r] === void 0).forEach((r) => {
|
|
720
|
+
de[r] = d[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
var
|
|
722
|
+
de.Jsep = d;
|
|
723
|
+
const ut = "ConditionalExpression";
|
|
724
|
+
var dt = {
|
|
725
725
|
name: "ternary",
|
|
726
726
|
init(r) {
|
|
727
727
|
r.hooks.add("after-expression", function(t) {
|
|
@@ -732,7 +732,7 @@ var st = {
|
|
|
732
732
|
this.index++;
|
|
733
733
|
const o = this.gobbleExpression();
|
|
734
734
|
if (o || this.throwError("Expected expression"), t.node = {
|
|
735
|
-
type:
|
|
735
|
+
type: ut,
|
|
736
736
|
test: s,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: o
|
|
@@ -748,17 +748,17 @@ var st = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
const
|
|
753
|
-
var
|
|
751
|
+
de.plugins.register(dt);
|
|
752
|
+
const Me = 47, ft = 92;
|
|
753
|
+
var ht = {
|
|
754
754
|
name: "regex",
|
|
755
755
|
init(r) {
|
|
756
756
|
r.hooks.add("gobble-token", function(t) {
|
|
757
|
-
if (this.code ===
|
|
757
|
+
if (this.code === Me) {
|
|
758
758
|
const s = ++this.index;
|
|
759
759
|
let n = !1;
|
|
760
760
|
for (; this.index < this.expr.length; ) {
|
|
761
|
-
if (this.code ===
|
|
761
|
+
if (this.code === Me && !n) {
|
|
762
762
|
const o = this.expr.slice(s, this.index);
|
|
763
763
|
let i = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
@@ -768,46 +768,46 @@ var it = {
|
|
|
768
768
|
else
|
|
769
769
|
break;
|
|
770
770
|
}
|
|
771
|
-
let
|
|
771
|
+
let c;
|
|
772
772
|
try {
|
|
773
|
-
|
|
773
|
+
c = new RegExp(o, i);
|
|
774
774
|
} catch (a) {
|
|
775
775
|
this.throwError(a.message);
|
|
776
776
|
}
|
|
777
777
|
return t.node = {
|
|
778
778
|
type: r.LITERAL,
|
|
779
|
-
value:
|
|
779
|
+
value: c,
|
|
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 === ft ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const Be = 43, pt = 45, ke = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [Be, pt],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
797
|
+
ke.assignmentOperators.forEach((s) => r.addBinaryOp(s, ke.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const o = this.code;
|
|
799
|
-
|
|
799
|
+
ke.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 === Be ? "++" : "--",
|
|
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
|
+
ke.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 === Be ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -816,17 +816,17 @@ const ke = 43, at = 45, fe = {
|
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
818
|
function t(s) {
|
|
819
|
-
|
|
819
|
+
ke.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
|
+
de.plugins.register(ht, ke);
|
|
826
|
+
de.addUnaryOp("typeof");
|
|
827
|
+
de.addLiteral("null", null);
|
|
828
|
+
de.addLiteral("undefined", void 0);
|
|
829
|
+
const gt = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), q = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -835,25 +835,25 @@ const lt = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
835
835
|
switch (r.type) {
|
|
836
836
|
case "BinaryExpression":
|
|
837
837
|
case "LogicalExpression":
|
|
838
|
-
return
|
|
838
|
+
return q.evalBinaryExpression(r, e);
|
|
839
839
|
case "Compound":
|
|
840
|
-
return
|
|
840
|
+
return q.evalCompound(r, e);
|
|
841
841
|
case "ConditionalExpression":
|
|
842
|
-
return
|
|
842
|
+
return q.evalConditionalExpression(r, e);
|
|
843
843
|
case "Identifier":
|
|
844
|
-
return
|
|
844
|
+
return q.evalIdentifier(r, e);
|
|
845
845
|
case "Literal":
|
|
846
|
-
return
|
|
846
|
+
return q.evalLiteral(r, e);
|
|
847
847
|
case "MemberExpression":
|
|
848
|
-
return
|
|
848
|
+
return q.evalMemberExpression(r, e);
|
|
849
849
|
case "UnaryExpression":
|
|
850
|
-
return
|
|
850
|
+
return q.evalUnaryExpression(r, e);
|
|
851
851
|
case "ArrayExpression":
|
|
852
|
-
return
|
|
852
|
+
return q.evalArrayExpression(r, e);
|
|
853
853
|
case "CallExpression":
|
|
854
|
-
return
|
|
854
|
+
return q.evalCallExpression(r, e);
|
|
855
855
|
case "AssignmentExpression":
|
|
856
|
-
return
|
|
856
|
+
return q.evalAssignmentExpression(r, e);
|
|
857
857
|
default:
|
|
858
858
|
throw SyntaxError("Unexpected expression", r);
|
|
859
859
|
}
|
|
@@ -883,19 +883,19 @@ const lt = /* @__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](q.evalAst(r.left, e), () => q.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 = q.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
896
896
|
},
|
|
897
897
|
evalConditionalExpression(r, e) {
|
|
898
|
-
return
|
|
898
|
+
return q.evalAst(r.test, e) ? q.evalAst(r.consequent, e) : q.evalAst(r.alternate, e);
|
|
899
899
|
},
|
|
900
900
|
evalIdentifier(r, e) {
|
|
901
901
|
if (Object.hasOwn(e, r.name))
|
|
@@ -910,46 +910,46 @@ const lt = /* @__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 ? q.evalAst(r.property) : r.property.name
|
|
914
914
|
// `object.property` property is Identifier
|
|
915
|
-
), s =
|
|
915
|
+
), s = q.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) && gt.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) => -q.evalAst(s, e),
|
|
926
|
+
"!": (s) => !q.evalAst(s, e),
|
|
927
|
+
"~": (s) => ~q.evalAst(s, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (s) => +
|
|
930
|
-
typeof: (s) => typeof
|
|
929
|
+
"+": (s) => +q.evalAst(s, e),
|
|
930
|
+
typeof: (s) => typeof q.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) => q.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) => q.evalAst(n, e));
|
|
938
|
+
return q.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 = q.evalAst(r.right, e);
|
|
944
944
|
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class mt {
|
|
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 = de(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -958,16 +958,16 @@ class ut {
|
|
|
958
958
|
*/
|
|
959
959
|
runInNewContext(e) {
|
|
960
960
|
const t = Object.assign(/* @__PURE__ */ Object.create(null), e);
|
|
961
|
-
return
|
|
961
|
+
return q.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function he(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function Ie(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class bt extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -975,10 +975,10 @@ class ct 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 X(r, e, t, s, n) {
|
|
979
|
+
if (!(this instanceof X))
|
|
980
980
|
try {
|
|
981
|
-
return new
|
|
981
|
+
return new X(r, e, t, s, n);
|
|
982
982
|
} catch (i) {
|
|
983
983
|
if (!i.avoidNew)
|
|
984
984
|
throw i;
|
|
@@ -993,16 +993,16 @@ function L(r, e, t, s, n) {
|
|
|
993
993
|
path: o ? r.path : e
|
|
994
994
|
};
|
|
995
995
|
o ? "json" in r && (i.json = r.json) : i.json = t;
|
|
996
|
-
const
|
|
997
|
-
if (!
|
|
998
|
-
throw new
|
|
999
|
-
return
|
|
996
|
+
const c = this.evaluate(i);
|
|
997
|
+
if (!c || typeof c != "object")
|
|
998
|
+
throw new bt(c);
|
|
999
|
+
return c;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
X.prototype.evaluate = function(r, e, t, s) {
|
|
1003
1003
|
let n = this.parent, o = this.parentProperty, {
|
|
1004
1004
|
flatten: i,
|
|
1005
|
-
wrap:
|
|
1005
|
+
wrap: c
|
|
1006
1006
|
} = this;
|
|
1007
1007
|
if (this.currResultType = this.resultType, this.currEval = this.eval, this.currSandbox = this.sandbox, t = t || this.callback, this.currOtherTypeCallback = s || this.otherTypeCallback, e = e || this.json, r = r || this.path, r && typeof r == "object" && !Array.isArray(r)) {
|
|
1008
1008
|
if (!r.path && r.path !== "")
|
|
@@ -1011,46 +1011,46 @@ L.prototype.evaluate = function(r, e, t, s) {
|
|
|
1011
1011
|
throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
|
|
1012
1012
|
({
|
|
1013
1013
|
json: e
|
|
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,
|
|
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, c = Object.hasOwn(r, "wrap") ? r.wrap : c, 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 = X.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
|
-
const a =
|
|
1018
|
+
const a = X.toPathArray(r);
|
|
1019
1019
|
a[0] === "$" && a.length > 1 && a.shift(), this._hasParentSelector = null;
|
|
1020
|
-
const l = this._trace(a, e, ["$"], n, o, t).filter(function(
|
|
1021
|
-
return
|
|
1020
|
+
const l = this._trace(a, e, ["$"], n, o, t).filter(function(g) {
|
|
1021
|
+
return g && !g.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
|
-
return l.length ? !
|
|
1024
|
-
const
|
|
1025
|
-
return i && Array.isArray(
|
|
1026
|
-
}, []) :
|
|
1023
|
+
return l.length ? !c && l.length === 1 && !l[0].hasArrExpr ? this._getPreferredOutput(l[0]) : l.reduce((g, h) => {
|
|
1024
|
+
const x = this._getPreferredOutput(h);
|
|
1025
|
+
return i && Array.isArray(x) ? g = g.concat(x) : g.push(x), g;
|
|
1026
|
+
}, []) : c ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
|
-
|
|
1028
|
+
X.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 : X.toPathArray(r.path);
|
|
1033
|
+
return r.pointer = X.toPointer(t), r.path = typeof r.path == "string" ? r.path : X.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 X.toPathString(r[e]);
|
|
1041
1041
|
case "pointer":
|
|
1042
|
-
return
|
|
1042
|
+
return X.toPointer(r.path);
|
|
1043
1043
|
default:
|
|
1044
1044
|
throw new TypeError("Unknown result type");
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
|
-
|
|
1047
|
+
X.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 : X.toPathString(r.path), e(s, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1053
|
+
X.prototype._trace = function(r, e, t, s, n, o, i, c) {
|
|
1054
1054
|
let a;
|
|
1055
1055
|
if (!r.length)
|
|
1056
1056
|
return a = {
|
|
@@ -1060,93 +1060,93 @@ L.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1060
1060
|
parentProperty: n,
|
|
1061
1061
|
hasArrExpr: i
|
|
1062
1062
|
}, this._handleCallback(a, o, "value"), a;
|
|
1063
|
-
const l = r[0],
|
|
1064
|
-
function v
|
|
1065
|
-
Array.isArray(
|
|
1066
|
-
h.push(
|
|
1067
|
-
}) : h.push(
|
|
1063
|
+
const l = r[0], g = r.slice(1), h = [];
|
|
1064
|
+
function x(v) {
|
|
1065
|
+
Array.isArray(v) ? v.forEach((B) => {
|
|
1066
|
+
h.push(B);
|
|
1067
|
+
}) : h.push(v);
|
|
1068
1068
|
}
|
|
1069
|
-
if ((typeof l != "string" ||
|
|
1070
|
-
|
|
1069
|
+
if ((typeof l != "string" || c) && e && Object.hasOwn(e, l))
|
|
1070
|
+
x(this._trace(g, e[l], he(t, l), e, l, o, i));
|
|
1071
1071
|
else if (l === "*")
|
|
1072
|
-
this._walk(e, (
|
|
1073
|
-
|
|
1072
|
+
this._walk(e, (v) => {
|
|
1073
|
+
x(this._trace(g, e[v], he(t, v), e, v, o, !0, !0));
|
|
1074
1074
|
});
|
|
1075
1075
|
else if (l === "..")
|
|
1076
|
-
|
|
1077
|
-
typeof e[
|
|
1076
|
+
x(this._trace(g, e, t, s, n, o, i)), this._walk(e, (v) => {
|
|
1077
|
+
typeof e[v] == "object" && x(this._trace(r.slice(), e[v], he(t, v), e, v, o, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
1080
|
if (l === "^")
|
|
1081
1081
|
return this._hasParentSelector = !0, {
|
|
1082
1082
|
path: t.slice(0, -1),
|
|
1083
|
-
expr:
|
|
1083
|
+
expr: g,
|
|
1084
1084
|
isParentSelector: !0
|
|
1085
1085
|
};
|
|
1086
1086
|
if (l === "~")
|
|
1087
1087
|
return a = {
|
|
1088
|
-
path:
|
|
1088
|
+
path: he(t, l),
|
|
1089
1089
|
value: n,
|
|
1090
1090
|
parent: s,
|
|
1091
1091
|
parentProperty: null
|
|
1092
1092
|
}, this._handleCallback(a, o, "property"), a;
|
|
1093
1093
|
if (l === "$")
|
|
1094
|
-
|
|
1094
|
+
x(this._trace(g, e, t, null, null, o, i));
|
|
1095
1095
|
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))
|
|
1096
|
-
|
|
1096
|
+
x(this._slice(l, g, 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
|
|
1101
|
-
|
|
1102
|
-
const
|
|
1103
|
-
this._trace(
|
|
1104
|
-
}) : this._walk(e, (
|
|
1105
|
-
this._eval(
|
|
1100
|
+
const v = l.replace(/^\?\((.*?)\)$/u, "$1"), B = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(v);
|
|
1101
|
+
B ? this._walk(e, (S) => {
|
|
1102
|
+
const _ = [B[2]], j = B[1] ? e[S][B[1]] : e[S];
|
|
1103
|
+
this._trace(_, j, t, s, n, o, !0).length > 0 && x(this._trace(g, e[S], he(t, S), e, S, o, !0));
|
|
1104
|
+
}) : this._walk(e, (S) => {
|
|
1105
|
+
this._eval(v, e[S], S, t, s, n) && x(this._trace(g, e[S], he(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
|
+
x(this._trace(Ie(this._eval(l, e, t.at(-1), t.slice(0, -1), s, n), g), e, t, s, n, o, i));
|
|
1111
1111
|
} else if (l[0] === "@") {
|
|
1112
|
-
let
|
|
1113
|
-
const
|
|
1114
|
-
switch (
|
|
1112
|
+
let v = !1;
|
|
1113
|
+
const B = l.slice(1, -2);
|
|
1114
|
+
switch (B) {
|
|
1115
1115
|
case "scalar":
|
|
1116
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
1116
|
+
(!e || !["object", "function"].includes(typeof e)) && (v = !0);
|
|
1117
1117
|
break;
|
|
1118
1118
|
case "boolean":
|
|
1119
1119
|
case "string":
|
|
1120
1120
|
case "undefined":
|
|
1121
1121
|
case "function":
|
|
1122
|
-
typeof e ===
|
|
1122
|
+
typeof e === B && (v = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
1125
|
+
Number.isFinite(e) && !(e % 1) && (v = !0);
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "number":
|
|
1128
|
-
Number.isFinite(e) && (
|
|
1128
|
+
Number.isFinite(e) && (v = !0);
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "nonFinite":
|
|
1131
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
1131
|
+
typeof e == "number" && !Number.isFinite(e) && (v = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e ===
|
|
1134
|
+
e && typeof e === B && (v = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
|
-
Array.isArray(e) && (
|
|
1137
|
+
Array.isArray(e) && (v = !0);
|
|
1138
1138
|
break;
|
|
1139
1139
|
case "other":
|
|
1140
|
-
|
|
1140
|
+
v = this.currOtherTypeCallback(e, t, s, n);
|
|
1141
1141
|
break;
|
|
1142
1142
|
case "null":
|
|
1143
|
-
e === null && (
|
|
1143
|
+
e === null && (v = !0);
|
|
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 " + B);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1149
|
+
if (v)
|
|
1150
1150
|
return a = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
@@ -1154,31 +1154,31 @@ L.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
|
1154
1154
|
parentProperty: n
|
|
1155
1155
|
}, this._handleCallback(a, o, "value"), a;
|
|
1156
1156
|
} else if (l[0] === "`" && e && Object.hasOwn(e, l.slice(1))) {
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1157
|
+
const v = l.slice(1);
|
|
1158
|
+
x(this._trace(g, e[v], he(t, v), e, v, o, i, !0));
|
|
1159
1159
|
} else if (l.includes(",")) {
|
|
1160
|
-
const
|
|
1161
|
-
for (const
|
|
1162
|
-
|
|
1163
|
-
} else !
|
|
1160
|
+
const v = l.split(",");
|
|
1161
|
+
for (const B of v)
|
|
1162
|
+
x(this._trace(Ie(B, g), e, t, s, n, o, !0));
|
|
1163
|
+
} else !c && e && Object.hasOwn(e, l) && x(this._trace(g, e[l], he(t, l), e, l, o, i, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
const
|
|
1170
|
-
if (Array.isArray(
|
|
1171
|
-
h[
|
|
1172
|
-
const
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1166
|
+
for (let v = 0; v < h.length; v++) {
|
|
1167
|
+
const B = h[v];
|
|
1168
|
+
if (B && B.isParentSelector) {
|
|
1169
|
+
const S = this._trace(B.expr, e, B.path, s, n, o, i);
|
|
1170
|
+
if (Array.isArray(S)) {
|
|
1171
|
+
h[v] = S[0];
|
|
1172
|
+
const _ = S.length;
|
|
1173
|
+
for (let j = 1; j < _; j++)
|
|
1174
|
+
v++, h.splice(v, 0, S[j]);
|
|
1175
1175
|
} else
|
|
1176
|
-
h[
|
|
1176
|
+
h[v] = S;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
1179
|
return h;
|
|
1180
1180
|
};
|
|
1181
|
-
|
|
1181
|
+
X.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 @@ L.prototype._walk = function(r, e) {
|
|
|
1187
1187
|
e(t);
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
|
-
|
|
1190
|
+
X.prototype._slice = function(r, e, t, s, n, o, i) {
|
|
1191
1191
|
if (!Array.isArray(t))
|
|
1192
1192
|
return;
|
|
1193
|
-
const
|
|
1194
|
-
let
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
for (let
|
|
1198
|
-
this._trace(
|
|
1199
|
-
|
|
1193
|
+
const c = t.length, a = r.split(":"), l = a[2] && Number.parseInt(a[2]) || 1;
|
|
1194
|
+
let g = a[0] && Number.parseInt(a[0]) || 0, h = a[1] && Number.parseInt(a[1]) || c;
|
|
1195
|
+
g = g < 0 ? Math.max(0, g + c) : Math.min(c, g), h = h < 0 ? Math.max(0, h + c) : Math.min(c, h);
|
|
1196
|
+
const x = [];
|
|
1197
|
+
for (let v = g; v < h; v += l)
|
|
1198
|
+
this._trace(Ie(v, e), t, s, n, o, i, !0).forEach((S) => {
|
|
1199
|
+
x.push(S);
|
|
1200
1200
|
});
|
|
1201
|
-
return
|
|
1201
|
+
return x;
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1203
|
+
X.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 =
|
|
1207
|
-
const
|
|
1208
|
-
if (!
|
|
1206
|
+
i && (this.currSandbox._$_path = X.toPathString(s.concat([t])));
|
|
1207
|
+
const c = this.currEval + "Script:" + r;
|
|
1208
|
+
if (!X.cache[c]) {
|
|
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
|
+
X.cache[c] = new this.safeVm.Script(a);
|
|
1212
1212
|
else if (this.currEval === "native")
|
|
1213
|
-
|
|
1213
|
+
X.cache[c] = 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
|
+
X.cache[c] = new l(a);
|
|
1217
1217
|
} else if (typeof this.currEval == "function")
|
|
1218
|
-
|
|
1218
|
+
X.cache[c] = {
|
|
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 X.cache[c].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
|
+
X.cache = {};
|
|
1233
|
+
X.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
|
+
X.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
|
+
X.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
1249
1249
|
cache: e
|
|
1250
|
-
} =
|
|
1250
|
+
} = X;
|
|
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 @@ L.toPathArray = function(r) {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
|
-
|
|
1266
|
-
Script:
|
|
1265
|
+
X.prototype.safeVm = {
|
|
1266
|
+
Script: mt
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1268
|
+
const yt = 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 vt {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1287,44 +1287,44 @@ class ft {
|
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
1289
|
const s = Object.keys(e), n = [];
|
|
1290
|
-
|
|
1290
|
+
yt(s, n, (l) => typeof e[l] == "function");
|
|
1291
1291
|
const o = s.map((l) => e[l]);
|
|
1292
|
-
t = n.reduce((l,
|
|
1293
|
-
let h = e[
|
|
1294
|
-
return /function/u.test(h) || (h = "function " + h), "var " +
|
|
1292
|
+
t = n.reduce((l, g) => {
|
|
1293
|
+
let h = e[g].toString();
|
|
1294
|
+
return /function/u.test(h) || (h = "function " + h), "var " + g + "=" + h + ";" + l;
|
|
1295
1295
|
}, "") + t, !/(['"])use strict\1/u.test(t) && !s.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;\s*$/u, "");
|
|
1296
|
-
const
|
|
1296
|
+
const c = t.lastIndexOf(";"), a = c !== -1 ? t.slice(0, c + 1) + " return " + t.slice(c + 1) : " return " + t;
|
|
1297
1297
|
return new Function(...s, a)(...o);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
|
|
1301
|
-
Script:
|
|
1300
|
+
X.prototype.vm = {
|
|
1301
|
+
Script: vt
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const _t = { class: "json-node" }, xt = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1307
|
-
key:
|
|
1306
|
+
}, Et = { class: "json-node__line" }, kt = ["contenteditable", "onKeydown"], At = {
|
|
1307
|
+
key: 1,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1310
|
-
key:
|
|
1309
|
+
}, wt = ["title"], Nt = ["title"], Ct = {
|
|
1310
|
+
key: 4,
|
|
1311
1311
|
class: "json-node__comma"
|
|
1312
|
-
},
|
|
1312
|
+
}, Tt = {
|
|
1313
1313
|
key: 0,
|
|
1314
1314
|
class: "json-node__children"
|
|
1315
|
-
},
|
|
1315
|
+
}, Ot = { class: "json-node__children-content" }, $t = { class: "json-node__line json-node__closing-bracket" }, Pt = { class: "json-node__bracket" }, Bt = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__comma"
|
|
1318
|
-
},
|
|
1318
|
+
}, St = {
|
|
1319
1319
|
key: 1,
|
|
1320
1320
|
class: "json-node__primitive"
|
|
1321
|
-
},
|
|
1322
|
-
key:
|
|
1321
|
+
}, It = ["contenteditable", "onKeydown"], Vt = {
|
|
1322
|
+
key: 1,
|
|
1323
1323
|
class: "json-node__colon"
|
|
1324
|
-
},
|
|
1324
|
+
}, Rt = ["title"], Lt = ["contenteditable", "onKeydown"], jt = {
|
|
1325
1325
|
key: 0,
|
|
1326
1326
|
class: "json-node__comma"
|
|
1327
|
-
},
|
|
1327
|
+
}, Ut = /* @__PURE__ */ Oe({
|
|
1328
1328
|
name: "JsonNode",
|
|
1329
1329
|
__name: "JsonNode",
|
|
1330
1330
|
props: {
|
|
@@ -1338,202 +1338,202 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1338
1338
|
},
|
|
1339
1339
|
emits: ["update:value", "toggle-expand", "copy", "update:key"],
|
|
1340
1340
|
setup(r, { emit: e }) {
|
|
1341
|
-
|
|
1342
|
-
"
|
|
1343
|
-
"
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
"
|
|
1347
|
-
"
|
|
1348
|
-
|
|
1349
|
-
"
|
|
1350
|
-
"
|
|
1351
|
-
|
|
1352
|
-
"
|
|
1353
|
-
"
|
|
1354
|
-
"
|
|
1341
|
+
Le((u) => ({
|
|
1342
|
+
"2a18b018": u.level,
|
|
1343
|
+
"58a14b93": u.theme.colors.syntaxKey,
|
|
1344
|
+
"46fe1b3e": u.theme.colors.hoverBackground,
|
|
1345
|
+
fbe2c048: u.theme.colors.syntaxBracket,
|
|
1346
|
+
"4bd524bb": u.theme.colors.collapsedText,
|
|
1347
|
+
"3308d23c": u.theme.colors.collapsedBackground,
|
|
1348
|
+
"36380c60": u.theme.colors.collapsedBackgroundHover,
|
|
1349
|
+
"0892365d": u.theme.colors.syntaxString,
|
|
1350
|
+
"0015b195": u.theme.colors.syntaxNumber,
|
|
1351
|
+
"7db95f5c": u.theme.colors.syntaxBoolean,
|
|
1352
|
+
"88ec825a": u.theme.colors.syntaxNull,
|
|
1353
|
+
"537157f7": u.theme.colors.background,
|
|
1354
|
+
"3cee3331": u.theme.colors.selectionBackground,
|
|
1355
|
+
"81323cee": u.theme.colors.indentLine
|
|
1355
1356
|
}));
|
|
1356
|
-
const t = r, s = e, n =
|
|
1357
|
+
const t = r, s = e, n = W(!1), o = W(!1), i = W(""), c = W(""), a = W("string"), l = W(null), g = W(null), h = (u) => u !== null && typeof u == "object" && !Array.isArray(u) && "__protected_number__" in u && Object.keys(u).length === 1, x = (u) => h(u) ? u.__protected_number__ : "", v = K(() => h(t.value) ? !1 : t.value !== null && typeof t.value == "object"), B = K(() => Array.isArray(t.value)), S = K(() => t.path ? t.path : t.keyName ? t.keyName : "root"), _ = K(() => t.expanded.has(S.value)), j = K(() => t.keyName), Y = K(() => B.value ? "[" : "{"), J = K(() => B.value ? "]" : "}"), z = K(() => {
|
|
1357
1358
|
if (!t.value) return "";
|
|
1358
|
-
const
|
|
1359
|
-
return
|
|
1360
|
-
}),
|
|
1361
|
-
const
|
|
1362
|
-
return t.value === null ? "json-node__value--null" :
|
|
1363
|
-
}),
|
|
1364
|
-
const
|
|
1365
|
-
return
|
|
1366
|
-
},
|
|
1367
|
-
s("toggle-expand",
|
|
1368
|
-
},
|
|
1369
|
-
t.level !== 0 && (n.value = !0, i.value = t.keyName,
|
|
1370
|
-
|
|
1371
|
-
|
|
1359
|
+
const m = Object.keys(t.value).length;
|
|
1360
|
+
return B.value ? m > 0 ? ` ${m} items ` : " " : m > 0 ? ` ${m} keys ` : " ";
|
|
1361
|
+
}), ae = K(() => {
|
|
1362
|
+
const u = typeof t.value;
|
|
1363
|
+
return t.value === null ? "json-node__value--null" : u === "boolean" ? "json-node__value--boolean" : u === "number" || h(t.value) ? "json-node__value--number" : u === "string" ? "json-node__value--string" : "";
|
|
1364
|
+
}), ce = K(() => t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : h(t.value) ? x(t.value) : typeof t.value == "string" ? `"${t.value}"` : String(t.value)), fe = K(() => "Double-click to edit"), se = (u) => t.level === 0 ? u : S.value ? `${S.value}.${u}` : u, k = (u) => {
|
|
1365
|
+
const m = Object.keys(t.value);
|
|
1366
|
+
return m.indexOf(u) === m.length - 1;
|
|
1367
|
+
}, C = () => {
|
|
1368
|
+
s("toggle-expand", S.value);
|
|
1369
|
+
}, R = () => {
|
|
1370
|
+
t.level !== 0 && (n.value = !0, i.value = t.keyName, ue(() => {
|
|
1371
|
+
if (l.value) {
|
|
1372
|
+
l.value.focus();
|
|
1373
|
+
const u = document.createRange();
|
|
1374
|
+
u.selectNodeContents(l.value);
|
|
1375
|
+
const m = window.getSelection();
|
|
1376
|
+
m?.removeAllRanges(), m?.addRange(u);
|
|
1377
|
+
}
|
|
1372
1378
|
}));
|
|
1373
|
-
},
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1379
|
+
}, V = () => {
|
|
1380
|
+
v.value || (o.value = !0, t.value === null ? a.value = "null" : h(t.value) ? a.value = "protected-number" : typeof t.value == "string" ? a.value = "string" : typeof t.value == "number" ? a.value = "number" : typeof t.value == "boolean" && (a.value = "boolean"), h(t.value) ? c.value = x(t.value) : typeof t.value == "string" ? c.value = t.value : c.value = String(t.value), ue(() => {
|
|
1381
|
+
if (g.value) {
|
|
1382
|
+
g.value.focus();
|
|
1383
|
+
const u = document.createRange();
|
|
1384
|
+
u.selectNodeContents(g.value);
|
|
1385
|
+
const m = window.getSelection();
|
|
1386
|
+
m?.removeAllRanges(), m?.addRange(u);
|
|
1387
|
+
}
|
|
1377
1388
|
}));
|
|
1378
|
-
},
|
|
1389
|
+
}, T = () => {
|
|
1379
1390
|
if (t.level === 0 || !n.value) return;
|
|
1380
|
-
const
|
|
1381
|
-
if (!
|
|
1382
|
-
|
|
1391
|
+
const u = l.value?.innerText.trim() || "";
|
|
1392
|
+
if (!u) {
|
|
1393
|
+
f();
|
|
1383
1394
|
return;
|
|
1384
1395
|
}
|
|
1385
|
-
if (
|
|
1396
|
+
if (u === t.keyName) {
|
|
1386
1397
|
n.value = !1;
|
|
1387
1398
|
return;
|
|
1388
1399
|
}
|
|
1389
|
-
n.value = !1, s("update:key",
|
|
1390
|
-
},
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1400
|
+
n.value = !1, s("update:key", S.value, u);
|
|
1401
|
+
}, Q = () => {
|
|
1402
|
+
if (o.value)
|
|
1403
|
+
try {
|
|
1404
|
+
let u;
|
|
1405
|
+
const m = g.value?.innerText.trim() || "";
|
|
1406
|
+
if (a.value === "string")
|
|
1407
|
+
m === "null" ? u = null : m === "true" || m === "false" ? u = m === "true" : u = m;
|
|
1408
|
+
else if (a.value === "protected-number")
|
|
1409
|
+
u = { __protected_number__: m };
|
|
1410
|
+
else if (m === "null")
|
|
1411
|
+
u = null;
|
|
1412
|
+
else if (m === "true" || m === "false")
|
|
1413
|
+
u = m === "true";
|
|
1414
|
+
else if (!isNaN(Number(m)) && m !== "") {
|
|
1415
|
+
const E = Number(m);
|
|
1416
|
+
!Number.isSafeInteger(E) || m.length > 15 ? u = { __protected_number__: m } : u = E;
|
|
1417
|
+
} else
|
|
1418
|
+
u = m;
|
|
1419
|
+
s("update:value", S.value, u), o.value = !1;
|
|
1420
|
+
} catch (u) {
|
|
1421
|
+
console.error("Failed to parse value:", u), o.value = !1;
|
|
1422
|
+
}
|
|
1423
|
+
}, f = () => {
|
|
1412
1424
|
n.value = !1, i.value = t.keyName;
|
|
1413
|
-
},
|
|
1414
|
-
o.value = !1,
|
|
1425
|
+
}, b = () => {
|
|
1426
|
+
o.value = !1, h(t.value) ? c.value = x(t.value) : typeof t.value == "string" ? c.value = t.value : c.value = String(t.value);
|
|
1415
1427
|
};
|
|
1416
|
-
return (
|
|
1417
|
-
const
|
|
1418
|
-
return
|
|
1419
|
-
|
|
1420
|
-
y("div",
|
|
1421
|
-
|
|
1428
|
+
return (u, m) => {
|
|
1429
|
+
const E = Qe("JsonNode", !0);
|
|
1430
|
+
return O(), P("div", _t, [
|
|
1431
|
+
v.value ? (O(), P("div", xt, [
|
|
1432
|
+
y("div", Et, [
|
|
1433
|
+
u.keyName ? (O(), P("span", {
|
|
1422
1434
|
key: 0,
|
|
1423
1435
|
class: "json-node__key",
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
"onUpdate:modelValue": f[0] || (f[0] = (E) => i.value = E),
|
|
1430
|
-
onKeyup: [
|
|
1431
|
-
de(K, ["enter"]),
|
|
1432
|
-
de(te, ["escape"])
|
|
1436
|
+
contenteditable: n.value,
|
|
1437
|
+
onDblclick: R,
|
|
1438
|
+
onKeydown: [
|
|
1439
|
+
U(Z(T, ["prevent"]), ["enter"]),
|
|
1440
|
+
U(f, ["escape"])
|
|
1433
1441
|
],
|
|
1434
|
-
onBlur:
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1442
|
+
onBlur: T,
|
|
1443
|
+
ref_key: "keyRef",
|
|
1444
|
+
ref: l,
|
|
1445
|
+
title: "Double-click to edit key"
|
|
1446
|
+
}, M(n.value ? i.value : `"${j.value}"`), 41, kt)) : te("", !0),
|
|
1447
|
+
u.keyName ? (O(), P("span", At, ": ")) : te("", !0),
|
|
1440
1448
|
y("span", {
|
|
1441
1449
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1442
|
-
onClick:
|
|
1443
|
-
title:
|
|
1444
|
-
},
|
|
1445
|
-
|
|
1446
|
-
key:
|
|
1450
|
+
onClick: C,
|
|
1451
|
+
title: _.value ? "Click to collapse" : "Click to expand"
|
|
1452
|
+
}, M(Y.value), 9, wt),
|
|
1453
|
+
_.value ? te("", !0) : (O(), P("span", {
|
|
1454
|
+
key: 2,
|
|
1447
1455
|
class: "json-node__collapsed-info",
|
|
1448
|
-
onClick:
|
|
1449
|
-
title: `Click to expand ${
|
|
1450
|
-
},
|
|
1451
|
-
|
|
1452
|
-
key:
|
|
1456
|
+
onClick: C,
|
|
1457
|
+
title: `Click to expand ${z.value.trim()}`
|
|
1458
|
+
}, M(z.value), 9, Nt)),
|
|
1459
|
+
_.value ? te("", !0) : (O(), P("span", {
|
|
1460
|
+
key: 3,
|
|
1453
1461
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1454
|
-
onClick:
|
|
1462
|
+
onClick: C,
|
|
1455
1463
|
title: "Click to expand"
|
|
1456
|
-
},
|
|
1457
|
-
!
|
|
1464
|
+
}, M(J.value), 1)),
|
|
1465
|
+
!_.value && !u.isLast ? (O(), P("span", Ct, ",")) : te("", !0)
|
|
1458
1466
|
]),
|
|
1459
|
-
|
|
1460
|
-
y("div",
|
|
1461
|
-
(
|
|
1462
|
-
key:
|
|
1467
|
+
_.value ? (O(), P("div", Tt, [
|
|
1468
|
+
y("div", Ot, [
|
|
1469
|
+
(O(!0), P(pe, null, _e(u.value, (A, w) => (O(), P("div", {
|
|
1470
|
+
key: w,
|
|
1463
1471
|
class: "json-node__child"
|
|
1464
1472
|
}, [
|
|
1465
|
-
|
|
1466
|
-
value:
|
|
1467
|
-
"key-name":
|
|
1468
|
-
level:
|
|
1469
|
-
path:
|
|
1470
|
-
expanded:
|
|
1471
|
-
theme:
|
|
1472
|
-
"onUpdate:value":
|
|
1473
|
-
onToggleExpand:
|
|
1474
|
-
onCopy:
|
|
1475
|
-
"onUpdate:key":
|
|
1476
|
-
"is-last":
|
|
1473
|
+
Ye(E, {
|
|
1474
|
+
value: A,
|
|
1475
|
+
"key-name": B.value ? "" : String(w),
|
|
1476
|
+
level: u.level + 1,
|
|
1477
|
+
path: se(String(w)),
|
|
1478
|
+
expanded: u.expanded,
|
|
1479
|
+
theme: u.theme,
|
|
1480
|
+
"onUpdate:value": m[0] || (m[0] = (L, H) => u.$emit("update:value", L, H)),
|
|
1481
|
+
onToggleExpand: m[1] || (m[1] = (L) => u.$emit("toggle-expand", L)),
|
|
1482
|
+
onCopy: m[2] || (m[2] = (L) => u.$emit("copy", L)),
|
|
1483
|
+
"onUpdate:key": m[3] || (m[3] = (L, H) => u.$emit("update:key", L, H)),
|
|
1484
|
+
"is-last": k(String(w))
|
|
1477
1485
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1478
1486
|
]))), 128))
|
|
1479
1487
|
]),
|
|
1480
|
-
y("div",
|
|
1481
|
-
y("span",
|
|
1482
|
-
|
|
1488
|
+
y("div", $t, [
|
|
1489
|
+
y("span", Pt, M(J.value), 1),
|
|
1490
|
+
u.isLast ? te("", !0) : (O(), P("span", Bt, ","))
|
|
1483
1491
|
])
|
|
1484
|
-
])) :
|
|
1485
|
-
])) : (
|
|
1486
|
-
|
|
1492
|
+
])) : te("", !0)
|
|
1493
|
+
])) : (O(), P("div", St, [
|
|
1494
|
+
u.keyName ? (O(), P("span", {
|
|
1487
1495
|
key: 0,
|
|
1488
1496
|
class: "json-node__key",
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
"onUpdate:modelValue": f[5] || (f[5] = (E) => i.value = E),
|
|
1495
|
-
onKeyup: [
|
|
1496
|
-
de(K, ["enter"]),
|
|
1497
|
-
de(te, ["escape"])
|
|
1497
|
+
contenteditable: n.value,
|
|
1498
|
+
onDblclick: R,
|
|
1499
|
+
onKeydown: [
|
|
1500
|
+
U(Z(T, ["prevent"]), ["enter"]),
|
|
1501
|
+
U(f, ["escape"])
|
|
1498
1502
|
],
|
|
1499
|
-
onBlur:
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
onDblclick: f[6] || (f[6] = (E) => c.$emit("copy", c.value)),
|
|
1510
|
-
title: m.value
|
|
1503
|
+
onBlur: T,
|
|
1504
|
+
ref_key: "keyRef",
|
|
1505
|
+
ref: l,
|
|
1506
|
+
title: "Double-click to edit key"
|
|
1507
|
+
}, M(n.value ? i.value : `"${j.value}"`), 41, It)) : te("", !0),
|
|
1508
|
+
u.keyName ? (O(), P("span", Vt, ": ")) : te("", !0),
|
|
1509
|
+
y("span", {
|
|
1510
|
+
class: je(["json-node__value-wrapper", ae.value]),
|
|
1511
|
+
onDblclick: V,
|
|
1512
|
+
title: fe.value
|
|
1511
1513
|
}, [
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
[xe, u.value]
|
|
1526
|
-
]) : U("", !0)
|
|
1514
|
+
y("span", {
|
|
1515
|
+
class: "json-node__value",
|
|
1516
|
+
contenteditable: o.value,
|
|
1517
|
+
onKeydown: [
|
|
1518
|
+
U(Z(Q, ["prevent"]), ["enter"]),
|
|
1519
|
+
U(b, ["escape"])
|
|
1520
|
+
],
|
|
1521
|
+
onBlur: Q,
|
|
1522
|
+
ref_key: "valueRef",
|
|
1523
|
+
ref: g
|
|
1524
|
+
}, M(o.value ? c.value : ce.value), 41, Lt),
|
|
1525
|
+
u.isLast ? te("", !0) : (O(), P("span", jt, ","))
|
|
1526
|
+
], 42, Rt)
|
|
1527
1527
|
]))
|
|
1528
1528
|
]);
|
|
1529
1529
|
};
|
|
1530
1530
|
}
|
|
1531
|
-
}),
|
|
1531
|
+
}), $e = (r, e) => {
|
|
1532
1532
|
const t = r.__vccOpts || r;
|
|
1533
1533
|
for (const [s, n] of e)
|
|
1534
1534
|
t[s] = n;
|
|
1535
1535
|
return t;
|
|
1536
|
-
},
|
|
1536
|
+
}, Mt = /* @__PURE__ */ $e(Ut, [["__scopeId", "data-v-1472a8af"]]), ze = {
|
|
1537
1537
|
name: "github-light",
|
|
1538
1538
|
colors: {
|
|
1539
1539
|
// 背景色
|
|
@@ -1565,6 +1565,8 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1565
1565
|
syntaxBracket: "#24292f",
|
|
1566
1566
|
// 悬停效果
|
|
1567
1567
|
hoverBackground: "#f6f8fa",
|
|
1568
|
+
// 选中背景色
|
|
1569
|
+
selectionBackground: "rgba(9, 105, 218, 0.2)",
|
|
1568
1570
|
// 折叠信息样式
|
|
1569
1571
|
collapsedBackground: "#ddf4ff",
|
|
1570
1572
|
collapsedBackgroundHover: "#b6e3ff",
|
|
@@ -1572,7 +1574,7 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1572
1574
|
// 缩进线
|
|
1573
1575
|
indentLine: "#d0d7de"
|
|
1574
1576
|
}
|
|
1575
|
-
},
|
|
1577
|
+
}, Ft = {
|
|
1576
1578
|
name: "github-dark",
|
|
1577
1579
|
colors: {
|
|
1578
1580
|
// 背景色
|
|
@@ -1604,6 +1606,8 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1604
1606
|
syntaxBracket: "#e6edf3",
|
|
1605
1607
|
// 悬停效果
|
|
1606
1608
|
hoverBackground: "#161b22",
|
|
1609
|
+
// 选中背景色
|
|
1610
|
+
selectionBackground: "rgba(121, 192, 255, 0.2)",
|
|
1607
1611
|
// 折叠信息样式
|
|
1608
1612
|
collapsedBackground: "#1c2128",
|
|
1609
1613
|
collapsedBackgroundHover: "#2d333b",
|
|
@@ -1611,7 +1615,7 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1611
1615
|
// 缩进线
|
|
1612
1616
|
indentLine: "#30363d"
|
|
1613
1617
|
}
|
|
1614
|
-
},
|
|
1618
|
+
}, Kt = {
|
|
1615
1619
|
name: "min-light",
|
|
1616
1620
|
colors: {
|
|
1617
1621
|
// 背景色 - 纯白简洁
|
|
@@ -1643,6 +1647,8 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1643
1647
|
syntaxBracket: "#374151",
|
|
1644
1648
|
// 悬停效果
|
|
1645
1649
|
hoverBackground: "#f9f9f9",
|
|
1650
|
+
// 选中背景色
|
|
1651
|
+
selectionBackground: "rgba(59, 130, 246, 0.2)",
|
|
1646
1652
|
// 折叠信息样式
|
|
1647
1653
|
collapsedBackground: "#e0f2fe",
|
|
1648
1654
|
collapsedBackgroundHover: "#bae6fd",
|
|
@@ -1650,7 +1656,7 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1650
1656
|
// 缩进线
|
|
1651
1657
|
indentLine: "#e5e7eb"
|
|
1652
1658
|
}
|
|
1653
|
-
},
|
|
1659
|
+
}, Xt = {
|
|
1654
1660
|
name: "slack-ochin",
|
|
1655
1661
|
colors: {
|
|
1656
1662
|
// 背景色 - 温暖的米色调
|
|
@@ -1682,6 +1688,8 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1682
1688
|
syntaxBracket: "#6b5444",
|
|
1683
1689
|
// 悬停效果
|
|
1684
1690
|
hoverBackground: "#f8f2eb",
|
|
1691
|
+
// 选中背景色
|
|
1692
|
+
selectionBackground: "rgba(255, 107, 53, 0.2)",
|
|
1685
1693
|
// 折叠信息样式
|
|
1686
1694
|
collapsedBackground: "#ffe8d6",
|
|
1687
1695
|
collapsedBackgroundHover: "#ffd4b0",
|
|
@@ -1689,34 +1697,34 @@ const ht = { class: "json-node" }, pt = {
|
|
|
1689
1697
|
// 缩进线
|
|
1690
1698
|
indentLine: "#e8d5b7"
|
|
1691
1699
|
}
|
|
1692
|
-
},
|
|
1693
|
-
"github-light":
|
|
1694
|
-
"github-dark":
|
|
1695
|
-
"min-light":
|
|
1696
|
-
"slack-ochin":
|
|
1700
|
+
}, Ht = {
|
|
1701
|
+
"github-light": ze,
|
|
1702
|
+
"github-dark": Ft,
|
|
1703
|
+
"min-light": Kt,
|
|
1704
|
+
"slack-ochin": Xt
|
|
1697
1705
|
};
|
|
1698
|
-
function
|
|
1699
|
-
return
|
|
1706
|
+
function qt(r = "github-light") {
|
|
1707
|
+
return Ht[r] || ze;
|
|
1700
1708
|
}
|
|
1701
|
-
const
|
|
1709
|
+
const Wt = {
|
|
1702
1710
|
key: 0,
|
|
1703
1711
|
class: "json-format__toolbar"
|
|
1704
|
-
},
|
|
1712
|
+
}, Qt = { class: "json-format__actions" }, Yt = ["disabled"], Gt = ["disabled"], Zt = ["disabled"], zt = ["disabled"], Dt = { class: "json-format__info" }, Jt = {
|
|
1705
1713
|
key: 0,
|
|
1706
1714
|
class: "json-format__status json-format__status--success"
|
|
1707
|
-
},
|
|
1715
|
+
}, er = {
|
|
1708
1716
|
key: 1,
|
|
1709
1717
|
class: "json-format__status json-format__status--error"
|
|
1710
|
-
},
|
|
1718
|
+
}, tr = { class: "json-format__content" }, rr = {
|
|
1711
1719
|
key: 0,
|
|
1712
1720
|
class: "json-format__error"
|
|
1713
|
-
},
|
|
1721
|
+
}, nr = {
|
|
1714
1722
|
key: 1,
|
|
1715
1723
|
class: "json-format__error"
|
|
1716
|
-
},
|
|
1724
|
+
}, sr = {
|
|
1717
1725
|
key: 2,
|
|
1718
1726
|
class: "json-format__viewer"
|
|
1719
|
-
},
|
|
1727
|
+
}, or = /* @__PURE__ */ Oe({
|
|
1720
1728
|
name: "JsonFormat",
|
|
1721
1729
|
__name: "index",
|
|
1722
1730
|
props: {
|
|
@@ -1728,7 +1736,7 @@ const Lt = {
|
|
|
1728
1736
|
},
|
|
1729
1737
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1730
1738
|
setup(r, { expose: e, emit: t }) {
|
|
1731
|
-
|
|
1739
|
+
Le((f) => ({
|
|
1732
1740
|
"325d5f6b": h.value.colors.border,
|
|
1733
1741
|
"407388ed": h.value.colors.background,
|
|
1734
1742
|
"1276f42c": h.value.colors.text,
|
|
@@ -1744,54 +1752,54 @@ const Lt = {
|
|
|
1744
1752
|
"781064f7": h.value.colors.errorBackground,
|
|
1745
1753
|
"3b9a02e9": h.value.colors.error
|
|
1746
1754
|
}));
|
|
1747
|
-
const s = r, n = t, o =
|
|
1748
|
-
if (!
|
|
1755
|
+
const s = r, n = t, o = W(null), i = W(""), c = W(/* @__PURE__ */ new Set()), a = W(null), l = W(""), g = K(() => i.value === ""), h = K(() => qt(s.theme)), x = K(() => l.value ? null : a.value !== null ? a.value : o.value), v = (f) => {
|
|
1756
|
+
if (!f.trim()) {
|
|
1749
1757
|
o.value = null, i.value = "", a.value = null, l.value = "";
|
|
1750
1758
|
return;
|
|
1751
1759
|
}
|
|
1752
1760
|
try {
|
|
1753
|
-
let
|
|
1754
|
-
const
|
|
1755
|
-
if (!
|
|
1761
|
+
let b = f;
|
|
1762
|
+
const u = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(b), m = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(b);
|
|
1763
|
+
if (!u && !m)
|
|
1756
1764
|
try {
|
|
1757
|
-
o.value = JSON.parse(
|
|
1758
|
-
|
|
1765
|
+
o.value = JSON.parse(b), i.value = "", a.value = null, l.value = "", ue(() => {
|
|
1766
|
+
x.value !== null && z();
|
|
1759
1767
|
});
|
|
1760
1768
|
return;
|
|
1761
1769
|
} catch {
|
|
1762
1770
|
}
|
|
1763
|
-
|
|
1764
|
-
let
|
|
1765
|
-
for (;
|
|
1766
|
-
const
|
|
1767
|
-
if (
|
|
1768
|
-
|
|
1769
|
-
else if (
|
|
1770
|
-
|
|
1771
|
+
b = ((A) => {
|
|
1772
|
+
let w = "", L = !1, H = !1, re = 0;
|
|
1773
|
+
for (; re < A.length; ) {
|
|
1774
|
+
const le = A[re];
|
|
1775
|
+
if (L)
|
|
1776
|
+
H ? H = !1 : le === "\\" ? H = !0 : le === '"' && (L = !1), w += le, re++;
|
|
1777
|
+
else if (le === '"')
|
|
1778
|
+
L = !0, w += le, re++;
|
|
1771
1779
|
else {
|
|
1772
|
-
const
|
|
1773
|
-
let
|
|
1774
|
-
if (
|
|
1775
|
-
|
|
1780
|
+
const be = A.slice(re);
|
|
1781
|
+
let oe = be.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1782
|
+
if (oe) {
|
|
1783
|
+
w += oe[1] + '{"__protected_number__":"' + oe[2] + '"}' + oe[3], re += oe[0].length;
|
|
1776
1784
|
continue;
|
|
1777
1785
|
}
|
|
1778
|
-
if (
|
|
1779
|
-
|
|
1786
|
+
if (oe = be.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), oe) {
|
|
1787
|
+
w += oe[1] + '{"__protected_number__":"' + oe[2] + '"}' + oe[3], re += oe[0].length;
|
|
1780
1788
|
continue;
|
|
1781
1789
|
}
|
|
1782
|
-
|
|
1790
|
+
w += le, re++;
|
|
1783
1791
|
}
|
|
1784
1792
|
}
|
|
1785
|
-
return
|
|
1786
|
-
})(
|
|
1787
|
-
|
|
1793
|
+
return w;
|
|
1794
|
+
})(b), o.value = JSON.parse(b), i.value = "", a.value = null, l.value = "", ue(() => {
|
|
1795
|
+
x.value !== null && z();
|
|
1788
1796
|
});
|
|
1789
|
-
} catch (
|
|
1790
|
-
i.value =
|
|
1797
|
+
} catch (b) {
|
|
1798
|
+
i.value = b instanceof Error ? b.message : "Unknown parsing error", o.value = null, a.value = null, l.value = "";
|
|
1791
1799
|
}
|
|
1792
|
-
},
|
|
1793
|
-
if (!
|
|
1794
|
-
|
|
1800
|
+
}, B = (f) => {
|
|
1801
|
+
if (!f || !f.expression.trim()) {
|
|
1802
|
+
S();
|
|
1795
1803
|
return;
|
|
1796
1804
|
}
|
|
1797
1805
|
if (!o.value) {
|
|
@@ -1799,275 +1807,275 @@ const Lt = {
|
|
|
1799
1807
|
return;
|
|
1800
1808
|
}
|
|
1801
1809
|
try {
|
|
1802
|
-
let
|
|
1803
|
-
if (
|
|
1804
|
-
|
|
1805
|
-
else if (
|
|
1806
|
-
|
|
1810
|
+
let b;
|
|
1811
|
+
if (f.type === "jsonpath")
|
|
1812
|
+
b = X({ path: f.expression, json: o.value }), b.length === 1 && f.expression.includes("$[") === !1 && !f.expression.endsWith("[*]") ? a.value = b[0] : a.value = b;
|
|
1813
|
+
else if (f.type === "js")
|
|
1814
|
+
b = new Function("data", `
|
|
1807
1815
|
try {
|
|
1808
|
-
return ${
|
|
1816
|
+
return ${f.expression};
|
|
1809
1817
|
} catch (error) {
|
|
1810
1818
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1811
1819
|
}
|
|
1812
|
-
`)(o.value), a.value =
|
|
1820
|
+
`)(o.value), a.value = b;
|
|
1813
1821
|
else
|
|
1814
|
-
throw new Error(`Unsupported filter type: ${
|
|
1815
|
-
l.value = "",
|
|
1816
|
-
|
|
1822
|
+
throw new Error(`Unsupported filter type: ${f.type}`);
|
|
1823
|
+
l.value = "", ue(() => {
|
|
1824
|
+
z();
|
|
1817
1825
|
});
|
|
1818
|
-
} catch (
|
|
1819
|
-
l.value =
|
|
1826
|
+
} catch (b) {
|
|
1827
|
+
l.value = b instanceof Error ? b.message : "Filter execution error", a.value = null;
|
|
1820
1828
|
}
|
|
1821
|
-
},
|
|
1829
|
+
}, S = () => {
|
|
1822
1830
|
a.value = null, l.value = "";
|
|
1823
1831
|
};
|
|
1824
|
-
|
|
1825
|
-
|
|
1832
|
+
Ge(() => s.modelValue, (f) => {
|
|
1833
|
+
v(f);
|
|
1826
1834
|
}, { immediate: !0 });
|
|
1827
|
-
const
|
|
1828
|
-
const
|
|
1829
|
-
if (
|
|
1830
|
-
return
|
|
1831
|
-
if (!Array.isArray(
|
|
1832
|
-
return `__PROTECTED_NUMBER_${
|
|
1833
|
-
if (Array.isArray(
|
|
1834
|
-
return
|
|
1835
|
-
const
|
|
1836
|
-
for (const [
|
|
1837
|
-
|
|
1838
|
-
return
|
|
1839
|
-
},
|
|
1840
|
-
return JSON.stringify(
|
|
1841
|
-
},
|
|
1835
|
+
const _ = (f, b, u) => {
|
|
1836
|
+
const m = (w) => {
|
|
1837
|
+
if (w === null || typeof w != "object")
|
|
1838
|
+
return w;
|
|
1839
|
+
if (!Array.isArray(w) && "__protected_number__" in w && Object.keys(w).length === 1)
|
|
1840
|
+
return `__PROTECTED_NUMBER_${w.__protected_number__}_PROTECTED_NUMBER__`;
|
|
1841
|
+
if (Array.isArray(w))
|
|
1842
|
+
return w.map((H) => m(H));
|
|
1843
|
+
const L = {};
|
|
1844
|
+
for (const [H, re] of Object.entries(w))
|
|
1845
|
+
L[H] = m(re);
|
|
1846
|
+
return L;
|
|
1847
|
+
}, E = m(f);
|
|
1848
|
+
return JSON.stringify(E, b, u).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1849
|
+
}, j = (f, b) => {
|
|
1842
1850
|
if (!s.readonly)
|
|
1843
1851
|
try {
|
|
1844
|
-
const
|
|
1845
|
-
n("update:modelValue",
|
|
1846
|
-
} catch (
|
|
1847
|
-
console.error("Failed to update JSON:",
|
|
1852
|
+
const u = Y(o.value, f, b), m = _(u, null, 2);
|
|
1853
|
+
n("update:modelValue", m);
|
|
1854
|
+
} catch (u) {
|
|
1855
|
+
console.error("Failed to update JSON:", u);
|
|
1848
1856
|
}
|
|
1849
|
-
},
|
|
1850
|
-
if (!
|
|
1851
|
-
const
|
|
1852
|
-
let
|
|
1853
|
-
for (let
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1857
|
+
}, Y = (f, b, u) => {
|
|
1858
|
+
if (!b || b === "root") return u;
|
|
1859
|
+
const m = b.split("."), E = R(f, m.slice(0, -1));
|
|
1860
|
+
let A = E;
|
|
1861
|
+
for (let L = 0; L < m.length - 1; L++) {
|
|
1862
|
+
const H = m[L];
|
|
1863
|
+
H !== "root" && (Array.isArray(A) ? A = A[parseInt(H)] : A = A[H]);
|
|
1856
1864
|
}
|
|
1857
|
-
const
|
|
1858
|
-
return
|
|
1859
|
-
},
|
|
1860
|
-
|
|
1861
|
-
},
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1866
|
-
}) : Object.keys(
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1865
|
+
const w = m[m.length - 1];
|
|
1866
|
+
return w === "root" ? u : (Array.isArray(A) ? A[parseInt(w)] = u : A[w] = u, E);
|
|
1867
|
+
}, J = (f) => {
|
|
1868
|
+
c.value.has(f) ? c.value.delete(f) : c.value.add(f);
|
|
1869
|
+
}, z = () => {
|
|
1870
|
+
const f = /* @__PURE__ */ new Set(), b = (u, m = "") => {
|
|
1871
|
+
u !== null && typeof u == "object" && (f.add(m || "root"), Array.isArray(u) ? u.forEach((E, A) => {
|
|
1872
|
+
const w = m ? `${m}.${A}` : `${A}`;
|
|
1873
|
+
b(E, w);
|
|
1874
|
+
}) : Object.keys(u).forEach((E) => {
|
|
1875
|
+
const A = m ? `${m}.${E}` : E;
|
|
1876
|
+
b(u[E], A);
|
|
1869
1877
|
}));
|
|
1870
1878
|
};
|
|
1871
|
-
|
|
1872
|
-
},
|
|
1873
|
-
|
|
1874
|
-
},
|
|
1875
|
-
if (
|
|
1879
|
+
b(x.value), c.value = f, n("expand-all");
|
|
1880
|
+
}, ae = () => {
|
|
1881
|
+
c.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1882
|
+
}, ce = async () => {
|
|
1883
|
+
if (g.value)
|
|
1876
1884
|
try {
|
|
1877
|
-
const
|
|
1878
|
-
await navigator.clipboard.writeText(
|
|
1879
|
-
} catch (
|
|
1880
|
-
console.error("Failed to copy JSON:",
|
|
1885
|
+
const f = x.value, b = _(f, null, 2);
|
|
1886
|
+
await navigator.clipboard.writeText(b), n("copy-success", b);
|
|
1887
|
+
} catch (f) {
|
|
1888
|
+
console.error("Failed to copy JSON:", f), n("copy-error", f instanceof Error ? f : new Error("Failed to copy JSON"));
|
|
1881
1889
|
}
|
|
1882
|
-
},
|
|
1883
|
-
if (
|
|
1890
|
+
}, fe = () => {
|
|
1891
|
+
if (g.value)
|
|
1884
1892
|
try {
|
|
1885
|
-
const
|
|
1886
|
-
n("update:modelValue",
|
|
1887
|
-
} catch (
|
|
1888
|
-
console.error("Failed to compress JSON:",
|
|
1893
|
+
const f = x.value, b = _(f);
|
|
1894
|
+
n("update:modelValue", b), n("compress", b);
|
|
1895
|
+
} catch (f) {
|
|
1896
|
+
console.error("Failed to compress JSON:", f);
|
|
1889
1897
|
}
|
|
1890
|
-
},
|
|
1898
|
+
}, se = async (f) => {
|
|
1891
1899
|
try {
|
|
1892
|
-
let
|
|
1893
|
-
typeof
|
|
1894
|
-
} catch (
|
|
1895
|
-
console.error("Failed to copy value:",
|
|
1900
|
+
let b;
|
|
1901
|
+
typeof f == "object" && f !== null && !Array.isArray(f) && "__protected_number__" in f && Object.keys(f).length === 1 ? b = f.__protected_number__ : typeof f == "string" ? b = `"${f}"` : b = JSON.stringify(f), await navigator.clipboard.writeText(b);
|
|
1902
|
+
} catch (b) {
|
|
1903
|
+
console.error("Failed to copy value:", b);
|
|
1896
1904
|
}
|
|
1897
|
-
},
|
|
1905
|
+
}, k = (f, b) => {
|
|
1898
1906
|
if (!s.readonly)
|
|
1899
1907
|
try {
|
|
1900
|
-
const
|
|
1901
|
-
n("update:modelValue",
|
|
1902
|
-
} catch (
|
|
1903
|
-
console.error("Failed to rename key:",
|
|
1908
|
+
const u = C(o.value, f, b), m = _(u, null, 2);
|
|
1909
|
+
n("update:modelValue", m), Q(f, b);
|
|
1910
|
+
} catch (u) {
|
|
1911
|
+
console.error("Failed to rename key:", u);
|
|
1904
1912
|
}
|
|
1905
|
-
},
|
|
1906
|
-
if (!
|
|
1907
|
-
const
|
|
1908
|
-
if (
|
|
1909
|
-
const
|
|
1910
|
-
return
|
|
1913
|
+
}, C = (f, b, u) => {
|
|
1914
|
+
if (!b || b === "root") return f;
|
|
1915
|
+
const m = b.split("."), E = R(f, m.slice(0, -1));
|
|
1916
|
+
if (m.length === 1) {
|
|
1917
|
+
const L = m[0];
|
|
1918
|
+
return E && typeof E == "object" && !Array.isArray(E) ? V(E, L, u) : E;
|
|
1911
1919
|
}
|
|
1912
|
-
let
|
|
1913
|
-
for (let
|
|
1914
|
-
const
|
|
1915
|
-
Array.isArray(
|
|
1920
|
+
let A = E;
|
|
1921
|
+
for (let L = 0; L < m.length - 1; L++) {
|
|
1922
|
+
const H = m[L];
|
|
1923
|
+
Array.isArray(A) ? A = A[parseInt(H)] : A = A[H];
|
|
1916
1924
|
}
|
|
1917
|
-
const
|
|
1918
|
-
if (!Array.isArray(
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1925
|
+
const w = m[m.length - 1];
|
|
1926
|
+
if (!Array.isArray(A) && A && typeof A == "object") {
|
|
1927
|
+
const L = V(A, w, u), H = m.slice(0, -1);
|
|
1928
|
+
H.length > 0 && T(E, H, L);
|
|
1921
1929
|
}
|
|
1922
|
-
return
|
|
1923
|
-
},
|
|
1924
|
-
if (
|
|
1925
|
-
if (Array.isArray(
|
|
1926
|
-
const
|
|
1927
|
-
return
|
|
1928
|
-
} else if (
|
|
1929
|
-
const
|
|
1930
|
-
return
|
|
1930
|
+
return E;
|
|
1931
|
+
}, R = (f, b) => {
|
|
1932
|
+
if (b.length === 0) return f;
|
|
1933
|
+
if (Array.isArray(f)) {
|
|
1934
|
+
const u = [...f], m = b[0], E = parseInt(m);
|
|
1935
|
+
return b.length === 1 || (u[E] = R(f[E], b.slice(1))), u;
|
|
1936
|
+
} else if (f && typeof f == "object") {
|
|
1937
|
+
const u = { ...f }, m = b[0];
|
|
1938
|
+
return b.length === 1 || (u[m] = R(f[m], b.slice(1))), u;
|
|
1931
1939
|
}
|
|
1932
|
-
return
|
|
1933
|
-
},
|
|
1934
|
-
if (!
|
|
1935
|
-
return
|
|
1936
|
-
const
|
|
1937
|
-
for (const
|
|
1938
|
-
|
|
1939
|
-
return
|
|
1940
|
-
},
|
|
1941
|
-
let
|
|
1942
|
-
for (let
|
|
1943
|
-
const
|
|
1944
|
-
Array.isArray(
|
|
1940
|
+
return f;
|
|
1941
|
+
}, V = (f, b, u) => {
|
|
1942
|
+
if (!f || typeof f != "object" || Array.isArray(f))
|
|
1943
|
+
return f;
|
|
1944
|
+
const m = Object.keys(f), E = {};
|
|
1945
|
+
for (const A of m)
|
|
1946
|
+
A === b ? E[u] = f[A] : E[A] = f[A];
|
|
1947
|
+
return E;
|
|
1948
|
+
}, T = (f, b, u) => {
|
|
1949
|
+
let m = f;
|
|
1950
|
+
for (let A = 0; A < b.length - 1; A++) {
|
|
1951
|
+
const w = b[A];
|
|
1952
|
+
Array.isArray(m) ? m = m[parseInt(w)] : m = m[w];
|
|
1945
1953
|
}
|
|
1946
|
-
const
|
|
1947
|
-
Array.isArray(
|
|
1948
|
-
},
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
if (
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
} else if (
|
|
1955
|
-
const
|
|
1956
|
-
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1954
|
+
const E = b[b.length - 1];
|
|
1955
|
+
Array.isArray(m) ? m[parseInt(E)] = u : m[E] = u;
|
|
1956
|
+
}, Q = (f, b) => {
|
|
1957
|
+
const u = /* @__PURE__ */ new Set();
|
|
1958
|
+
c.value.forEach((m) => {
|
|
1959
|
+
if (m === f) {
|
|
1960
|
+
const E = f.split(".");
|
|
1961
|
+
E[E.length - 1] = b, u.add(E.join("."));
|
|
1962
|
+
} else if (m.startsWith(f + ".")) {
|
|
1963
|
+
const E = f.split(".");
|
|
1964
|
+
E[E.length - 1] = b;
|
|
1965
|
+
const A = E.join("."), w = m.substring(f.length);
|
|
1966
|
+
u.add(A + w);
|
|
1959
1967
|
} else
|
|
1960
|
-
|
|
1961
|
-
}),
|
|
1968
|
+
u.add(m);
|
|
1969
|
+
}), c.value = u;
|
|
1962
1970
|
};
|
|
1963
1971
|
return e({
|
|
1964
1972
|
// 核心操作方法
|
|
1965
|
-
copyJson:
|
|
1966
|
-
compressSource:
|
|
1967
|
-
expandAll:
|
|
1968
|
-
collapseAll:
|
|
1969
|
-
toggleExpand:
|
|
1970
|
-
updateValue:
|
|
1971
|
-
updateKey:
|
|
1973
|
+
copyJson: ce,
|
|
1974
|
+
compressSource: fe,
|
|
1975
|
+
expandAll: z,
|
|
1976
|
+
collapseAll: ae,
|
|
1977
|
+
toggleExpand: J,
|
|
1978
|
+
updateValue: j,
|
|
1979
|
+
updateKey: k,
|
|
1972
1980
|
// Filter 相关方法
|
|
1973
|
-
filter:
|
|
1974
|
-
clearFilter:
|
|
1981
|
+
filter: B,
|
|
1982
|
+
clearFilter: S,
|
|
1975
1983
|
// 状态访问方法
|
|
1976
|
-
isValidJson: () =>
|
|
1984
|
+
isValidJson: () => g.value,
|
|
1977
1985
|
getParsedJson: () => o.value,
|
|
1978
1986
|
getFilteredJson: () => a.value,
|
|
1979
|
-
getExpandedNodes: () =>
|
|
1987
|
+
getExpandedNodes: () => c.value,
|
|
1980
1988
|
getParseError: () => i.value,
|
|
1981
1989
|
getFilterError: () => l.value,
|
|
1982
1990
|
// 工具方法
|
|
1983
|
-
parseJson: (
|
|
1984
|
-
copyValue: (
|
|
1985
|
-
}), (
|
|
1986
|
-
class:
|
|
1991
|
+
parseJson: (f) => v(f),
|
|
1992
|
+
copyValue: (f) => se(f)
|
|
1993
|
+
}), (f, b) => (O(), P("div", {
|
|
1994
|
+
class: je(["json-format", `json-format--${h.value.name}`])
|
|
1987
1995
|
}, [
|
|
1988
|
-
|
|
1989
|
-
y("div",
|
|
1996
|
+
f.showToolbar ? (O(), P("div", Wt, [
|
|
1997
|
+
y("div", Qt, [
|
|
1990
1998
|
y("button", {
|
|
1991
1999
|
class: "json-format__btn json-format__btn--primary",
|
|
1992
|
-
onClick:
|
|
1993
|
-
disabled: !
|
|
2000
|
+
onClick: ce,
|
|
2001
|
+
disabled: !g.value,
|
|
1994
2002
|
title: "Copy JSON"
|
|
1995
|
-
}, " 📋 Copy ", 8,
|
|
2003
|
+
}, " 📋 Copy ", 8, Yt),
|
|
1996
2004
|
y("button", {
|
|
1997
2005
|
class: "json-format__btn json-format__btn--secondary",
|
|
1998
|
-
onClick:
|
|
1999
|
-
disabled: !
|
|
2006
|
+
onClick: z,
|
|
2007
|
+
disabled: !g.value,
|
|
2000
2008
|
title: "Expand All"
|
|
2001
|
-
}, " ⬇️ Expand All ", 8,
|
|
2009
|
+
}, " ⬇️ Expand All ", 8, Gt),
|
|
2002
2010
|
y("button", {
|
|
2003
2011
|
class: "json-format__btn json-format__btn--secondary",
|
|
2004
|
-
onClick:
|
|
2005
|
-
disabled: !
|
|
2012
|
+
onClick: ae,
|
|
2013
|
+
disabled: !g.value,
|
|
2006
2014
|
title: "Collapse All"
|
|
2007
|
-
}, " ➡️ Collapse All ", 8,
|
|
2015
|
+
}, " ➡️ Collapse All ", 8, Zt),
|
|
2008
2016
|
y("button", {
|
|
2009
2017
|
class: "json-format__btn json-format__btn--secondary",
|
|
2010
|
-
onClick:
|
|
2011
|
-
disabled: !
|
|
2018
|
+
onClick: fe,
|
|
2019
|
+
disabled: !g.value,
|
|
2012
2020
|
title: "Compress JSON"
|
|
2013
|
-
}, " 📦 Compress ", 8,
|
|
2021
|
+
}, " 📦 Compress ", 8, zt)
|
|
2014
2022
|
]),
|
|
2015
|
-
y("div",
|
|
2016
|
-
|
|
2023
|
+
y("div", Dt, [
|
|
2024
|
+
g.value ? (O(), P("span", Jt, " ✅ Valid JSON ")) : (O(), P("span", er, " ❌ Invalid JSON "))
|
|
2017
2025
|
])
|
|
2018
|
-
])) :
|
|
2019
|
-
y("div",
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
y("pre", null,
|
|
2023
|
-
])) : (
|
|
2024
|
-
|
|
2025
|
-
value:
|
|
2026
|
+
])) : te("", !0),
|
|
2027
|
+
y("div", tr, [
|
|
2028
|
+
g.value ? l.value ? (O(), P("div", nr, [
|
|
2029
|
+
b[1] || (b[1] = y("h4", null, "Filter Error:", -1)),
|
|
2030
|
+
y("pre", null, M(l.value), 1)
|
|
2031
|
+
])) : (O(), P("div", sr, [
|
|
2032
|
+
Ye(Mt, {
|
|
2033
|
+
value: x.value,
|
|
2026
2034
|
"key-name": "",
|
|
2027
2035
|
level: 0,
|
|
2028
|
-
expanded:
|
|
2036
|
+
expanded: c.value,
|
|
2029
2037
|
"is-last": !0,
|
|
2030
2038
|
theme: h.value,
|
|
2031
|
-
"onUpdate:value":
|
|
2032
|
-
onToggleExpand:
|
|
2033
|
-
onCopy:
|
|
2034
|
-
"onUpdate:key":
|
|
2039
|
+
"onUpdate:value": j,
|
|
2040
|
+
onToggleExpand: J,
|
|
2041
|
+
onCopy: se,
|
|
2042
|
+
"onUpdate:key": k
|
|
2035
2043
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2036
|
-
])) : (
|
|
2037
|
-
|
|
2038
|
-
y("pre", null,
|
|
2044
|
+
])) : (O(), P("div", rr, [
|
|
2045
|
+
b[0] || (b[0] = y("h4", null, "JSON Parse Error:", -1)),
|
|
2046
|
+
y("pre", null, M(i.value), 1)
|
|
2039
2047
|
]))
|
|
2040
2048
|
])
|
|
2041
2049
|
], 2));
|
|
2042
2050
|
}
|
|
2043
|
-
}),
|
|
2051
|
+
}), ir = /* @__PURE__ */ $e(or, [["__scopeId", "data-v-b956002c"]]), ar = {
|
|
2044
2052
|
key: 0,
|
|
2045
2053
|
class: "xml-node__comment"
|
|
2046
|
-
},
|
|
2054
|
+
}, lr = {
|
|
2047
2055
|
key: 1,
|
|
2048
2056
|
class: "xml-node__cdata"
|
|
2049
|
-
},
|
|
2057
|
+
}, cr = {
|
|
2050
2058
|
key: 2,
|
|
2051
2059
|
class: "xml-node__element"
|
|
2052
|
-
},
|
|
2060
|
+
}, ur = {
|
|
2053
2061
|
key: 0,
|
|
2054
2062
|
class: "xml-node__line"
|
|
2055
|
-
},
|
|
2063
|
+
}, dr = ["contenteditable", "onKeydown"], fr = ["contenteditable", "onDblclick", "onKeydown"], hr = ["contenteditable", "onDblclick", "onKeydown"], pr = {
|
|
2056
2064
|
key: 1,
|
|
2057
2065
|
class: "xml-node__line"
|
|
2058
|
-
},
|
|
2066
|
+
}, gr = ["contenteditable", "onKeydown"], mr = ["contenteditable", "onDblclick", "onKeydown"], br = ["contenteditable", "onDblclick", "onKeydown"], yr = ["contenteditable", "onKeydown"], vr = { key: 2 }, _r = {
|
|
2059
2067
|
key: 0,
|
|
2060
2068
|
class: "xml-node__line"
|
|
2061
|
-
},
|
|
2069
|
+
}, xr = ["contenteditable", "onKeydown"], Er = ["contenteditable", "onDblclick", "onKeydown"], kr = ["contenteditable", "onDblclick", "onKeydown"], Ar = ["title"], wr = { class: "xml-node__line" }, Nr = ["title"], Cr = ["contenteditable", "onKeydown"], Tr = { key: 1 }, Or = ["contenteditable", "onKeydown"], $r = ["contenteditable", "onDblclick", "onKeydown"], Pr = ["contenteditable", "onDblclick", "onKeydown"], Br = ["title"], Sr = {
|
|
2062
2070
|
key: 0,
|
|
2063
2071
|
class: "xml-node__children"
|
|
2064
|
-
},
|
|
2072
|
+
}, Ir = {
|
|
2065
2073
|
key: 0,
|
|
2066
2074
|
class: "xml-node__text"
|
|
2067
|
-
},
|
|
2075
|
+
}, Vr = ["contenteditable", "onKeydown"], Rr = {
|
|
2068
2076
|
key: 1,
|
|
2069
2077
|
class: "xml-node__line"
|
|
2070
|
-
},
|
|
2078
|
+
}, Lr = /* @__PURE__ */ Oe({
|
|
2071
2079
|
__name: "XmlNode",
|
|
2072
2080
|
props: {
|
|
2073
2081
|
node: {},
|
|
@@ -2077,353 +2085,605 @@ const Lt = {
|
|
|
2077
2085
|
expanded: {},
|
|
2078
2086
|
theme: {}
|
|
2079
2087
|
},
|
|
2080
|
-
emits: ["toggle-expand", "copy"],
|
|
2088
|
+
emits: ["toggle-expand", "copy", "update:tagName", "update:attributeName", "update:attributeValue", "update:textContent"],
|
|
2081
2089
|
setup(r, { emit: e }) {
|
|
2082
|
-
const t = r, s = e, n =
|
|
2083
|
-
const
|
|
2084
|
-
return Object.keys(
|
|
2085
|
-
|
|
2086
|
-
}),
|
|
2087
|
-
}),
|
|
2088
|
-
if (
|
|
2089
|
-
const
|
|
2090
|
-
return Array.isArray(
|
|
2091
|
-
}),
|
|
2092
|
-
if (!
|
|
2093
|
-
const
|
|
2094
|
-
if (
|
|
2095
|
-
const
|
|
2096
|
-
if (
|
|
2097
|
-
return
|
|
2090
|
+
const t = r, s = e, n = W(!1), o = W(null), i = W(null), c = W(!1), a = W(""), l = W(""), g = W(""), h = W(""), x = W(null), v = W(null), B = W(null), S = W(null), _ = K(() => Object.keys(t.node).find((N) => !N.startsWith(":") && !N.startsWith("#")) || ""), j = K(() => _.value ? t.parentPath ? `${t.parentPath}.${_.value}[${t.index}]` : `${_.value}[${t.index}]` : ""), Y = K(() => t.expanded.has(j.value)), J = K(() => t.node["#comment"] ? "comment" : t.node.__cdata ? "cdata" : _.value ? "element" : "unknown"), z = K(() => {
|
|
2091
|
+
const p = t.node[":@"] || {}, N = {};
|
|
2092
|
+
return Object.keys(p).forEach((D) => {
|
|
2093
|
+
D.startsWith("@_") && (N[D.substring(2)] = p[D]);
|
|
2094
|
+
}), N;
|
|
2095
|
+
}), ae = K(() => {
|
|
2096
|
+
if (J.value !== "element" || !_.value) return [];
|
|
2097
|
+
const p = t.node[_.value];
|
|
2098
|
+
return Array.isArray(p) ? p : [];
|
|
2099
|
+
}), ce = K(() => ae.value.some((p) => p.__cdata)), fe = K(() => {
|
|
2100
|
+
if (!ce.value) return "";
|
|
2101
|
+
const p = ae.value.find((N) => N.__cdata);
|
|
2102
|
+
if (p && Array.isArray(p.__cdata)) {
|
|
2103
|
+
const N = p.__cdata;
|
|
2104
|
+
if (N.length > 0 && N[0]["#text"])
|
|
2105
|
+
return N[0]["#text"];
|
|
2098
2106
|
}
|
|
2099
2107
|
return "";
|
|
2100
|
-
}),
|
|
2101
|
-
if (
|
|
2102
|
-
const
|
|
2103
|
-
if (!Array.isArray(
|
|
2104
|
-
const
|
|
2105
|
-
return
|
|
2106
|
-
}),
|
|
2107
|
-
if (
|
|
2108
|
-
const
|
|
2109
|
-
return Array.isArray(
|
|
2110
|
-
}),
|
|
2111
|
-
|
|
2112
|
-
},
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2108
|
+
}), se = K(() => {
|
|
2109
|
+
if (J.value !== "element" || !_.value || ce.value) return "";
|
|
2110
|
+
const p = t.node[_.value];
|
|
2111
|
+
if (!Array.isArray(p)) return "";
|
|
2112
|
+
const N = p.find((D) => D["#text"]);
|
|
2113
|
+
return N ? N["#text"] : "";
|
|
2114
|
+
}), k = K(() => {
|
|
2115
|
+
if (J.value !== "comment") return "";
|
|
2116
|
+
const p = t.node["#comment"];
|
|
2117
|
+
return Array.isArray(p) && p.length > 0 && p[0]["#text"] || "";
|
|
2118
|
+
}), C = K(() => ae.value.some((p) => Object.keys(p).some((D) => !D.startsWith("#") && !D.startsWith(":")))), R = K(() => C.value ? ae.value.filter((p) => Object.keys(p).some((D) => !D.startsWith("#") && !D.startsWith(":"))).length : 0), V = K(() => J.value === "element" && !C.value && se.value.trim() !== ""), T = () => {
|
|
2119
|
+
C.value && s("toggle-expand", j.value);
|
|
2120
|
+
}, Q = (p, N) => `${j.value}-child-${N}`, f = () => `${j.value}.${_.value}`, b = () => {
|
|
2121
|
+
n.value = !0, a.value = _.value, ue(() => {
|
|
2122
|
+
if (x.value) {
|
|
2123
|
+
x.value.focus();
|
|
2124
|
+
const p = document.createRange();
|
|
2125
|
+
p.selectNodeContents(x.value);
|
|
2126
|
+
const N = window.getSelection();
|
|
2127
|
+
N?.removeAllRanges(), N?.addRange(p);
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
}, u = (p) => {
|
|
2131
|
+
o.value = p, l.value = p, ue(() => {
|
|
2132
|
+
if (v.value) {
|
|
2133
|
+
v.value.focus();
|
|
2134
|
+
const N = document.createRange();
|
|
2135
|
+
N.selectNodeContents(v.value);
|
|
2136
|
+
const D = window.getSelection();
|
|
2137
|
+
D?.removeAllRanges(), D?.addRange(N);
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
}, m = (p) => {
|
|
2141
|
+
i.value = p, g.value = z.value[p] || "", ue(() => {
|
|
2142
|
+
if (B.value) {
|
|
2143
|
+
B.value.focus();
|
|
2144
|
+
const N = document.createRange();
|
|
2145
|
+
N.selectNodeContents(B.value);
|
|
2146
|
+
const D = window.getSelection();
|
|
2147
|
+
D?.removeAllRanges(), D?.addRange(N);
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
}, E = () => {
|
|
2151
|
+
c.value = !0, h.value = se.value, ue(() => {
|
|
2152
|
+
if (S.value) {
|
|
2153
|
+
S.value.focus();
|
|
2154
|
+
const p = document.createRange();
|
|
2155
|
+
p.selectNodeContents(S.value);
|
|
2156
|
+
const N = window.getSelection();
|
|
2157
|
+
N?.removeAllRanges(), N?.addRange(p);
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
}, A = () => {
|
|
2161
|
+
if (!n.value) return;
|
|
2162
|
+
const p = x.value?.innerText.trim() || "";
|
|
2163
|
+
if (!p || p === _.value) {
|
|
2164
|
+
n.value = !1;
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
n.value = !1, s("update:tagName", j.value, _.value, p);
|
|
2168
|
+
}, w = () => {
|
|
2169
|
+
if (!o.value) return;
|
|
2170
|
+
const p = o.value, N = v.value?.innerText.trim() || "";
|
|
2171
|
+
if (!N || N === p) {
|
|
2172
|
+
o.value = null;
|
|
2173
|
+
return;
|
|
2174
|
+
}
|
|
2175
|
+
o.value = null, s("update:attributeName", j.value, p, N);
|
|
2176
|
+
}, L = () => {
|
|
2177
|
+
if (!i.value) return;
|
|
2178
|
+
const p = i.value, N = B.value?.innerText.trim() || "";
|
|
2179
|
+
i.value = null, s("update:attributeValue", j.value, p, N);
|
|
2180
|
+
}, H = () => {
|
|
2181
|
+
if (!c.value) return;
|
|
2182
|
+
const p = S.value?.innerText || "";
|
|
2183
|
+
if (p === se.value) {
|
|
2184
|
+
c.value = !1;
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
c.value = !1, s("update:textContent", j.value, p);
|
|
2188
|
+
}, re = () => {
|
|
2189
|
+
n.value = !1, a.value = _.value;
|
|
2190
|
+
}, le = () => {
|
|
2191
|
+
o.value && (l.value = o.value, o.value = null);
|
|
2192
|
+
}, be = () => {
|
|
2193
|
+
i.value && (g.value = z.value[i.value] || "", i.value = null);
|
|
2194
|
+
}, oe = () => {
|
|
2195
|
+
c.value = !1, h.value = se.value;
|
|
2196
|
+
}, Ce = (p) => {
|
|
2197
|
+
C.value && (p.preventDefault(), b());
|
|
2198
|
+
};
|
|
2199
|
+
return (p, N) => {
|
|
2200
|
+
const D = Qe("XmlNode", !0);
|
|
2201
|
+
return O(), P("div", {
|
|
2116
2202
|
class: "xml-node",
|
|
2117
|
-
style:
|
|
2203
|
+
style: $({ paddingLeft: p.level > 0 ? "16px" : "0" })
|
|
2118
2204
|
}, [
|
|
2119
|
-
|
|
2205
|
+
J.value === "comment" ? (O(), P("div", ar, [
|
|
2120
2206
|
y("span", {
|
|
2121
|
-
style:
|
|
2122
|
-
}, " <!-- " +
|
|
2123
|
-
])) :
|
|
2207
|
+
style: $({ color: p.theme.colors.xmlComment })
|
|
2208
|
+
}, " <!-- " + M(k.value) + " --> ", 5)
|
|
2209
|
+
])) : J.value === "cdata" ? (O(), P("div", lr, [
|
|
2124
2210
|
y("span", {
|
|
2125
|
-
style:
|
|
2126
|
-
}, " <![CDATA[" +
|
|
2127
|
-
])) :
|
|
2128
|
-
|
|
2211
|
+
style: $({ color: p.theme.colors.xmlCdata })
|
|
2212
|
+
}, " <![CDATA[" + M(p.node.__cdata) + "]]> ", 5)
|
|
2213
|
+
])) : J.value === "element" ? (O(), P("div", cr, [
|
|
2214
|
+
ce.value ? (O(), P("div", ur, [
|
|
2129
2215
|
y("span", {
|
|
2130
2216
|
class: "xml-node__bracket",
|
|
2131
|
-
style:
|
|
2217
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2132
2218
|
}, "<", 4),
|
|
2133
2219
|
y("span", {
|
|
2134
|
-
class: "xml-node__tag",
|
|
2135
|
-
style:
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2220
|
+
class: "xml-node__tag xml-node__tag--editable",
|
|
2221
|
+
style: $({ color: p.theme.colors.xmlTag }),
|
|
2222
|
+
contenteditable: n.value,
|
|
2223
|
+
onDblclick: b,
|
|
2224
|
+
onContextmenu: Ce,
|
|
2225
|
+
onKeydown: [
|
|
2226
|
+
U(Z(A, ["prevent"]), ["enter"]),
|
|
2227
|
+
U(re, ["escape"])
|
|
2228
|
+
],
|
|
2229
|
+
onBlur: A,
|
|
2230
|
+
ref_key: "tagNameRef",
|
|
2231
|
+
ref: x,
|
|
2232
|
+
title: "Double-click to edit tag name"
|
|
2233
|
+
}, M(n.value ? a.value : _.value), 45, dr),
|
|
2234
|
+
(O(!0), P(pe, null, _e(z.value, (ee, I) => (O(), P("span", {
|
|
2235
|
+
key: I,
|
|
2139
2236
|
class: "xml-node__attribute"
|
|
2140
2237
|
}, [
|
|
2141
2238
|
y("span", {
|
|
2142
|
-
class: "xml-node__attr-name",
|
|
2143
|
-
style:
|
|
2144
|
-
|
|
2239
|
+
class: "xml-node__attr-name xml-node__attr-name--editable",
|
|
2240
|
+
style: $({ color: p.theme.colors.xmlAttribute }),
|
|
2241
|
+
contenteditable: o.value === I,
|
|
2242
|
+
onDblclick: (F) => u(I),
|
|
2243
|
+
onKeydown: [
|
|
2244
|
+
U(Z(w, ["prevent"]), ["enter"]),
|
|
2245
|
+
U(le, ["escape"])
|
|
2246
|
+
],
|
|
2247
|
+
onBlur: w,
|
|
2248
|
+
ref_for: !0,
|
|
2249
|
+
ref: (F) => {
|
|
2250
|
+
o.value === I && (v.value = F);
|
|
2251
|
+
},
|
|
2252
|
+
title: "Double-click to edit attribute name"
|
|
2253
|
+
}, M(o.value === I ? l.value : I), 45, fr),
|
|
2145
2254
|
y("span", {
|
|
2146
2255
|
class: "xml-node__equals",
|
|
2147
|
-
style:
|
|
2256
|
+
style: $({ color: p.theme.colors.xmlEquals })
|
|
2148
2257
|
}, "=", 4),
|
|
2149
2258
|
y("span", {
|
|
2150
2259
|
class: "xml-node__quote",
|
|
2151
|
-
style:
|
|
2260
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2152
2261
|
}, '"', 4),
|
|
2153
2262
|
y("span", {
|
|
2154
|
-
class: "xml-node__attr-value",
|
|
2155
|
-
style:
|
|
2156
|
-
|
|
2263
|
+
class: "xml-node__attr-value xml-node__attr-value--editable",
|
|
2264
|
+
style: $({ color: p.theme.colors.xmlAttributeValue }),
|
|
2265
|
+
contenteditable: i.value === I,
|
|
2266
|
+
onDblclick: (F) => m(I),
|
|
2267
|
+
onKeydown: [
|
|
2268
|
+
U(Z(L, ["prevent"]), ["enter"]),
|
|
2269
|
+
U(be, ["escape"])
|
|
2270
|
+
],
|
|
2271
|
+
onBlur: L,
|
|
2272
|
+
ref_for: !0,
|
|
2273
|
+
ref: (F) => {
|
|
2274
|
+
i.value === I && (B.value = F);
|
|
2275
|
+
},
|
|
2276
|
+
title: "Double-click to edit attribute value"
|
|
2277
|
+
}, M(i.value === I ? g.value : ee), 45, hr),
|
|
2157
2278
|
y("span", {
|
|
2158
2279
|
class: "xml-node__quote",
|
|
2159
|
-
style:
|
|
2280
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2160
2281
|
}, '"', 4)
|
|
2161
2282
|
]))), 128)),
|
|
2162
2283
|
y("span", {
|
|
2163
2284
|
class: "xml-node__bracket",
|
|
2164
|
-
style:
|
|
2285
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2165
2286
|
}, ">", 4),
|
|
2166
2287
|
y("span", {
|
|
2167
2288
|
class: "xml-node__cdata",
|
|
2168
|
-
style:
|
|
2169
|
-
}, "<![CDATA[" +
|
|
2289
|
+
style: $({ color: p.theme.colors.xmlCdata })
|
|
2290
|
+
}, "<![CDATA[" + M(fe.value) + "]]>", 5),
|
|
2170
2291
|
y("span", {
|
|
2171
2292
|
class: "xml-node__bracket",
|
|
2172
|
-
style:
|
|
2293
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2173
2294
|
}, "</", 4),
|
|
2174
2295
|
y("span", {
|
|
2175
2296
|
class: "xml-node__tag",
|
|
2176
|
-
style:
|
|
2177
|
-
},
|
|
2297
|
+
style: $({ color: p.theme.colors.xmlTag })
|
|
2298
|
+
}, M(n.value ? a.value : _.value), 5),
|
|
2178
2299
|
y("span", {
|
|
2179
2300
|
class: "xml-node__bracket",
|
|
2180
|
-
style:
|
|
2301
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2181
2302
|
}, ">", 4)
|
|
2182
|
-
])) :
|
|
2303
|
+
])) : V.value ? (O(), P("div", pr, [
|
|
2183
2304
|
y("span", {
|
|
2184
2305
|
class: "xml-node__bracket",
|
|
2185
|
-
style:
|
|
2306
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2186
2307
|
}, "<", 4),
|
|
2187
2308
|
y("span", {
|
|
2188
|
-
class: "xml-node__tag",
|
|
2189
|
-
style:
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2309
|
+
class: "xml-node__tag xml-node__tag--editable",
|
|
2310
|
+
style: $({ color: p.theme.colors.xmlTag }),
|
|
2311
|
+
contenteditable: n.value,
|
|
2312
|
+
onDblclick: b,
|
|
2313
|
+
onContextmenu: Ce,
|
|
2314
|
+
onKeydown: [
|
|
2315
|
+
U(Z(A, ["prevent"]), ["enter"]),
|
|
2316
|
+
U(re, ["escape"])
|
|
2317
|
+
],
|
|
2318
|
+
onBlur: A,
|
|
2319
|
+
ref_key: "tagNameRef",
|
|
2320
|
+
ref: x,
|
|
2321
|
+
title: "Double-click to edit tag name"
|
|
2322
|
+
}, M(n.value ? a.value : _.value), 45, gr),
|
|
2323
|
+
(O(!0), P(pe, null, _e(z.value, (ee, I) => (O(), P("span", {
|
|
2324
|
+
key: I,
|
|
2193
2325
|
class: "xml-node__attribute"
|
|
2194
2326
|
}, [
|
|
2195
2327
|
y("span", {
|
|
2196
|
-
class: "xml-node__attr-name",
|
|
2197
|
-
style:
|
|
2198
|
-
|
|
2328
|
+
class: "xml-node__attr-name xml-node__attr-name--editable",
|
|
2329
|
+
style: $({ color: p.theme.colors.xmlAttribute }),
|
|
2330
|
+
contenteditable: o.value === I,
|
|
2331
|
+
onDblclick: (F) => u(I),
|
|
2332
|
+
onKeydown: [
|
|
2333
|
+
U(Z(w, ["prevent"]), ["enter"]),
|
|
2334
|
+
U(le, ["escape"])
|
|
2335
|
+
],
|
|
2336
|
+
onBlur: w,
|
|
2337
|
+
ref_for: !0,
|
|
2338
|
+
ref: (F) => {
|
|
2339
|
+
o.value === I && (v.value = F);
|
|
2340
|
+
},
|
|
2341
|
+
title: "Double-click to edit attribute name"
|
|
2342
|
+
}, M(o.value === I ? l.value : I), 45, mr),
|
|
2199
2343
|
y("span", {
|
|
2200
2344
|
class: "xml-node__equals",
|
|
2201
|
-
style:
|
|
2345
|
+
style: $({ color: p.theme.colors.xmlEquals })
|
|
2202
2346
|
}, "=", 4),
|
|
2203
2347
|
y("span", {
|
|
2204
2348
|
class: "xml-node__quote",
|
|
2205
|
-
style:
|
|
2349
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2206
2350
|
}, '"', 4),
|
|
2207
2351
|
y("span", {
|
|
2208
|
-
class: "xml-node__attr-value",
|
|
2209
|
-
style:
|
|
2210
|
-
|
|
2352
|
+
class: "xml-node__attr-value xml-node__attr-value--editable",
|
|
2353
|
+
style: $({ color: p.theme.colors.xmlAttributeValue }),
|
|
2354
|
+
contenteditable: i.value === I,
|
|
2355
|
+
onDblclick: (F) => m(I),
|
|
2356
|
+
onKeydown: [
|
|
2357
|
+
U(Z(L, ["prevent"]), ["enter"]),
|
|
2358
|
+
U(be, ["escape"])
|
|
2359
|
+
],
|
|
2360
|
+
onBlur: L,
|
|
2361
|
+
ref_for: !0,
|
|
2362
|
+
ref: (F) => {
|
|
2363
|
+
i.value === I && (B.value = F);
|
|
2364
|
+
},
|
|
2365
|
+
title: "Double-click to edit attribute value"
|
|
2366
|
+
}, M(i.value === I ? g.value : ee), 45, br),
|
|
2211
2367
|
y("span", {
|
|
2212
2368
|
class: "xml-node__quote",
|
|
2213
|
-
style:
|
|
2369
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2214
2370
|
}, '"', 4)
|
|
2215
2371
|
]))), 128)),
|
|
2216
2372
|
y("span", {
|
|
2217
2373
|
class: "xml-node__bracket",
|
|
2218
|
-
style:
|
|
2374
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2219
2375
|
}, ">", 4),
|
|
2220
2376
|
y("span", {
|
|
2221
|
-
class: "xml-node__text-content",
|
|
2222
|
-
style:
|
|
2223
|
-
|
|
2377
|
+
class: "xml-node__text-content xml-node__text-content--editable",
|
|
2378
|
+
style: $({ color: p.theme.colors.xmlText }),
|
|
2379
|
+
contenteditable: c.value,
|
|
2380
|
+
onDblclick: E,
|
|
2381
|
+
onKeydown: [
|
|
2382
|
+
U(Z(H, ["prevent"]), ["enter"]),
|
|
2383
|
+
U(oe, ["escape"])
|
|
2384
|
+
],
|
|
2385
|
+
onBlur: H,
|
|
2386
|
+
ref_key: "textContentRef",
|
|
2387
|
+
ref: S,
|
|
2388
|
+
title: "Double-click to edit text content"
|
|
2389
|
+
}, M(c.value ? h.value : se.value), 45, yr),
|
|
2224
2390
|
y("span", {
|
|
2225
2391
|
class: "xml-node__bracket",
|
|
2226
|
-
style:
|
|
2392
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2227
2393
|
}, "</", 4),
|
|
2228
2394
|
y("span", {
|
|
2229
2395
|
class: "xml-node__tag",
|
|
2230
|
-
style:
|
|
2231
|
-
},
|
|
2396
|
+
style: $({ color: p.theme.colors.xmlTag })
|
|
2397
|
+
}, M(n.value ? a.value : _.value), 5),
|
|
2232
2398
|
y("span", {
|
|
2233
2399
|
class: "xml-node__bracket",
|
|
2234
|
-
style:
|
|
2400
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2235
2401
|
}, ">", 4)
|
|
2236
|
-
])) : (
|
|
2237
|
-
!
|
|
2402
|
+
])) : (O(), P("div", vr, [
|
|
2403
|
+
!Y.value && C.value ? (O(), P("div", _r, [
|
|
2238
2404
|
y("span", {
|
|
2239
2405
|
class: "xml-node__clickable-part",
|
|
2240
|
-
onClick:
|
|
2406
|
+
onClick: N[0] || (N[0] = (ee) => T()),
|
|
2241
2407
|
title: "Click to expand"
|
|
2242
2408
|
}, [
|
|
2243
2409
|
y("span", {
|
|
2244
2410
|
class: "xml-node__bracket",
|
|
2245
|
-
style:
|
|
2411
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2246
2412
|
}, "<", 4),
|
|
2247
2413
|
y("span", {
|
|
2248
|
-
class: "xml-node__tag",
|
|
2249
|
-
style:
|
|
2250
|
-
|
|
2414
|
+
class: "xml-node__tag xml-node__tag--editable",
|
|
2415
|
+
style: $({ color: p.theme.colors.xmlTag }),
|
|
2416
|
+
contenteditable: n.value,
|
|
2417
|
+
onDblclick: Z(b, ["stop"]),
|
|
2418
|
+
onContextmenu: Ce,
|
|
2419
|
+
onKeydown: [
|
|
2420
|
+
U(Z(A, ["prevent"]), ["enter"]),
|
|
2421
|
+
U(re, ["escape"])
|
|
2422
|
+
],
|
|
2423
|
+
onBlur: A,
|
|
2424
|
+
ref_key: "tagNameRef",
|
|
2425
|
+
ref: x,
|
|
2426
|
+
title: "Double-click or right-click to edit tag name"
|
|
2427
|
+
}, M(n.value ? a.value : _.value), 45, xr)
|
|
2251
2428
|
]),
|
|
2252
|
-
(
|
|
2253
|
-
key:
|
|
2429
|
+
(O(!0), P(pe, null, _e(z.value, (ee, I) => (O(), P("span", {
|
|
2430
|
+
key: I,
|
|
2254
2431
|
class: "xml-node__attribute"
|
|
2255
2432
|
}, [
|
|
2256
2433
|
y("span", {
|
|
2257
|
-
class: "xml-node__attr-name",
|
|
2258
|
-
style:
|
|
2259
|
-
|
|
2434
|
+
class: "xml-node__attr-name xml-node__attr-name--editable",
|
|
2435
|
+
style: $({ color: p.theme.colors.xmlAttribute }),
|
|
2436
|
+
contenteditable: o.value === I,
|
|
2437
|
+
onDblclick: (F) => u(I),
|
|
2438
|
+
onKeydown: [
|
|
2439
|
+
U(Z(w, ["prevent"]), ["enter"]),
|
|
2440
|
+
U(le, ["escape"])
|
|
2441
|
+
],
|
|
2442
|
+
onBlur: w,
|
|
2443
|
+
ref_for: !0,
|
|
2444
|
+
ref: (F) => {
|
|
2445
|
+
o.value === I && (v.value = F);
|
|
2446
|
+
},
|
|
2447
|
+
title: "Double-click to edit attribute name"
|
|
2448
|
+
}, M(o.value === I ? l.value : I), 45, Er),
|
|
2260
2449
|
y("span", {
|
|
2261
2450
|
class: "xml-node__equals",
|
|
2262
|
-
style:
|
|
2451
|
+
style: $({ color: p.theme.colors.xmlEquals })
|
|
2263
2452
|
}, "=", 4),
|
|
2264
2453
|
y("span", {
|
|
2265
2454
|
class: "xml-node__quote",
|
|
2266
|
-
style:
|
|
2455
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2267
2456
|
}, '"', 4),
|
|
2268
2457
|
y("span", {
|
|
2269
|
-
class: "xml-node__attr-value",
|
|
2270
|
-
style:
|
|
2271
|
-
|
|
2458
|
+
class: "xml-node__attr-value xml-node__attr-value--editable",
|
|
2459
|
+
style: $({ color: p.theme.colors.xmlAttributeValue }),
|
|
2460
|
+
contenteditable: i.value === I,
|
|
2461
|
+
onDblclick: (F) => m(I),
|
|
2462
|
+
onKeydown: [
|
|
2463
|
+
U(Z(L, ["prevent"]), ["enter"]),
|
|
2464
|
+
U(be, ["escape"])
|
|
2465
|
+
],
|
|
2466
|
+
onBlur: L,
|
|
2467
|
+
ref_for: !0,
|
|
2468
|
+
ref: (F) => {
|
|
2469
|
+
i.value === I && (B.value = F);
|
|
2470
|
+
},
|
|
2471
|
+
title: "Double-click to edit attribute value"
|
|
2472
|
+
}, M(i.value === I ? g.value : ee), 45, kr),
|
|
2272
2473
|
y("span", {
|
|
2273
2474
|
class: "xml-node__quote",
|
|
2274
|
-
style:
|
|
2475
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2275
2476
|
}, '"', 4)
|
|
2276
2477
|
]))), 128)),
|
|
2277
2478
|
y("span", {
|
|
2278
2479
|
class: "xml-node__clickable-part",
|
|
2279
|
-
onClick:
|
|
2480
|
+
onClick: N[1] || (N[1] = (ee) => T()),
|
|
2280
2481
|
title: "Click to expand"
|
|
2281
2482
|
}, [
|
|
2282
2483
|
y("span", {
|
|
2283
2484
|
class: "xml-node__bracket",
|
|
2284
|
-
style:
|
|
2485
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2285
2486
|
}, ">", 4)
|
|
2286
2487
|
]),
|
|
2287
2488
|
y("span", {
|
|
2288
2489
|
class: "xml-node__collapsed-badge",
|
|
2289
|
-
style:
|
|
2290
|
-
backgroundColor:
|
|
2291
|
-
color:
|
|
2490
|
+
style: $({
|
|
2491
|
+
backgroundColor: p.theme.colors.collapsedBackground,
|
|
2492
|
+
color: p.theme.colors.collapsedText
|
|
2292
2493
|
}),
|
|
2293
|
-
onClick:
|
|
2294
|
-
title: `Click to expand ${
|
|
2295
|
-
},
|
|
2494
|
+
onClick: N[2] || (N[2] = (ee) => T()),
|
|
2495
|
+
title: `Click to expand ${R.value} child element${R.value > 1 ? "s" : ""}`
|
|
2496
|
+
}, M(R.value) + " child" + M(R.value > 1 ? "ren" : ""), 13, Ar),
|
|
2296
2497
|
y("span", {
|
|
2297
2498
|
class: "xml-node__clickable-part",
|
|
2298
|
-
onClick:
|
|
2499
|
+
onClick: N[3] || (N[3] = (ee) => T()),
|
|
2299
2500
|
title: "Click to expand"
|
|
2300
2501
|
}, [
|
|
2301
2502
|
y("span", {
|
|
2302
2503
|
class: "xml-node__bracket",
|
|
2303
|
-
style:
|
|
2504
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2304
2505
|
}, "</", 4),
|
|
2305
2506
|
y("span", {
|
|
2306
2507
|
class: "xml-node__tag",
|
|
2307
|
-
style:
|
|
2308
|
-
},
|
|
2508
|
+
style: $({ color: p.theme.colors.xmlTag })
|
|
2509
|
+
}, M(n.value ? a.value : _.value), 5),
|
|
2309
2510
|
y("span", {
|
|
2310
2511
|
class: "xml-node__bracket",
|
|
2311
|
-
style:
|
|
2512
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2312
2513
|
}, ">", 4)
|
|
2313
2514
|
])
|
|
2314
|
-
])) : (
|
|
2315
|
-
y("div",
|
|
2316
|
-
|
|
2515
|
+
])) : (O(), P(pe, { key: 1 }, [
|
|
2516
|
+
y("div", wr, [
|
|
2517
|
+
C.value ? (O(), P("span", {
|
|
2317
2518
|
key: 0,
|
|
2318
2519
|
class: "xml-node__clickable-part",
|
|
2319
|
-
onClick:
|
|
2320
|
-
title:
|
|
2520
|
+
onClick: N[4] || (N[4] = (ee) => T()),
|
|
2521
|
+
title: Y.value ? "Click to collapse" : "Click to expand"
|
|
2321
2522
|
}, [
|
|
2322
2523
|
y("span", {
|
|
2323
2524
|
class: "xml-node__bracket",
|
|
2324
|
-
style:
|
|
2525
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2325
2526
|
}, "<", 4),
|
|
2326
2527
|
y("span", {
|
|
2327
|
-
class: "xml-node__tag",
|
|
2328
|
-
style:
|
|
2329
|
-
|
|
2330
|
-
|
|
2528
|
+
class: "xml-node__tag xml-node__tag--editable",
|
|
2529
|
+
style: $({ color: p.theme.colors.xmlTag }),
|
|
2530
|
+
contenteditable: n.value,
|
|
2531
|
+
onDblclick: Z(b, ["stop"]),
|
|
2532
|
+
onContextmenu: Ce,
|
|
2533
|
+
onKeydown: [
|
|
2534
|
+
U(Z(A, ["prevent"]), ["enter"]),
|
|
2535
|
+
U(re, ["escape"])
|
|
2536
|
+
],
|
|
2537
|
+
onBlur: A,
|
|
2538
|
+
ref_key: "tagNameRef",
|
|
2539
|
+
ref: x,
|
|
2540
|
+
title: "Double-click or right-click to edit tag name"
|
|
2541
|
+
}, M(n.value ? a.value : _.value), 45, Cr)
|
|
2542
|
+
], 8, Nr)) : (O(), P("span", Tr, [
|
|
2331
2543
|
y("span", {
|
|
2332
2544
|
class: "xml-node__bracket",
|
|
2333
|
-
style:
|
|
2545
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2334
2546
|
}, "<", 4),
|
|
2335
2547
|
y("span", {
|
|
2336
|
-
class: "xml-node__tag",
|
|
2337
|
-
style:
|
|
2338
|
-
|
|
2548
|
+
class: "xml-node__tag xml-node__tag--editable",
|
|
2549
|
+
style: $({ color: p.theme.colors.xmlTag }),
|
|
2550
|
+
contenteditable: n.value,
|
|
2551
|
+
onDblclick: b,
|
|
2552
|
+
onKeydown: [
|
|
2553
|
+
U(Z(A, ["prevent"]), ["enter"]),
|
|
2554
|
+
U(re, ["escape"])
|
|
2555
|
+
],
|
|
2556
|
+
onBlur: A,
|
|
2557
|
+
ref_key: "tagNameRef",
|
|
2558
|
+
ref: x,
|
|
2559
|
+
title: "Double-click to edit tag name"
|
|
2560
|
+
}, M(n.value ? a.value : _.value), 45, Or)
|
|
2339
2561
|
])),
|
|
2340
|
-
(
|
|
2341
|
-
key:
|
|
2562
|
+
(O(!0), P(pe, null, _e(z.value, (ee, I) => (O(), P("span", {
|
|
2563
|
+
key: I,
|
|
2342
2564
|
class: "xml-node__attribute"
|
|
2343
2565
|
}, [
|
|
2344
2566
|
y("span", {
|
|
2345
|
-
class: "xml-node__attr-name",
|
|
2346
|
-
style:
|
|
2347
|
-
|
|
2567
|
+
class: "xml-node__attr-name xml-node__attr-name--editable",
|
|
2568
|
+
style: $({ color: p.theme.colors.xmlAttribute }),
|
|
2569
|
+
contenteditable: o.value === I,
|
|
2570
|
+
onDblclick: (F) => u(I),
|
|
2571
|
+
onKeydown: [
|
|
2572
|
+
U(Z(w, ["prevent"]), ["enter"]),
|
|
2573
|
+
U(le, ["escape"])
|
|
2574
|
+
],
|
|
2575
|
+
onBlur: w,
|
|
2576
|
+
ref_for: !0,
|
|
2577
|
+
ref: (F) => {
|
|
2578
|
+
o.value === I && (v.value = F);
|
|
2579
|
+
},
|
|
2580
|
+
title: "Double-click to edit attribute name"
|
|
2581
|
+
}, M(o.value === I ? l.value : I), 45, $r),
|
|
2348
2582
|
y("span", {
|
|
2349
2583
|
class: "xml-node__equals",
|
|
2350
|
-
style:
|
|
2584
|
+
style: $({ color: p.theme.colors.xmlEquals })
|
|
2351
2585
|
}, "=", 4),
|
|
2352
2586
|
y("span", {
|
|
2353
2587
|
class: "xml-node__quote",
|
|
2354
|
-
style:
|
|
2588
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2355
2589
|
}, '"', 4),
|
|
2356
2590
|
y("span", {
|
|
2357
|
-
class: "xml-node__attr-value",
|
|
2358
|
-
style:
|
|
2359
|
-
|
|
2591
|
+
class: "xml-node__attr-value xml-node__attr-value--editable",
|
|
2592
|
+
style: $({ color: p.theme.colors.xmlAttributeValue }),
|
|
2593
|
+
contenteditable: i.value === I,
|
|
2594
|
+
onDblclick: (F) => m(I),
|
|
2595
|
+
onKeydown: [
|
|
2596
|
+
U(Z(L, ["prevent"]), ["enter"]),
|
|
2597
|
+
U(be, ["escape"])
|
|
2598
|
+
],
|
|
2599
|
+
onBlur: L,
|
|
2600
|
+
ref_for: !0,
|
|
2601
|
+
ref: (F) => {
|
|
2602
|
+
i.value === I && (B.value = F);
|
|
2603
|
+
},
|
|
2604
|
+
title: "Double-click to edit attribute value"
|
|
2605
|
+
}, M(i.value === I ? g.value : ee), 45, Pr),
|
|
2360
2606
|
y("span", {
|
|
2361
2607
|
class: "xml-node__quote",
|
|
2362
|
-
style:
|
|
2608
|
+
style: $({ color: p.theme.colors.xmlQuote })
|
|
2363
2609
|
}, '"', 4)
|
|
2364
2610
|
]))), 128)),
|
|
2365
|
-
|
|
2611
|
+
C.value ? (O(), P("span", {
|
|
2366
2612
|
key: 2,
|
|
2367
2613
|
class: "xml-node__clickable-part",
|
|
2368
|
-
onClick:
|
|
2369
|
-
title:
|
|
2614
|
+
onClick: N[5] || (N[5] = (ee) => T()),
|
|
2615
|
+
title: Y.value ? "Click to collapse" : "Click to expand"
|
|
2370
2616
|
}, [
|
|
2371
2617
|
y("span", {
|
|
2372
2618
|
class: "xml-node__bracket",
|
|
2373
|
-
style:
|
|
2619
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2374
2620
|
}, ">", 4)
|
|
2375
|
-
], 8,
|
|
2621
|
+
], 8, Br)) : (O(), P("span", {
|
|
2376
2622
|
key: 3,
|
|
2377
2623
|
class: "xml-node__bracket",
|
|
2378
|
-
style:
|
|
2379
|
-
},
|
|
2624
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2625
|
+
}, M(C.value ? ">" : "/>"), 5))
|
|
2380
2626
|
]),
|
|
2381
|
-
|
|
2382
|
-
|
|
2627
|
+
Y.value && C.value ? (O(), P("div", Sr, [
|
|
2628
|
+
ae.value.length === 0 && se.value.trim() ? (O(), P("div", Ir, [
|
|
2383
2629
|
y("span", {
|
|
2384
|
-
class: "xml-node__text-content",
|
|
2385
|
-
style:
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2630
|
+
class: "xml-node__text-content xml-node__text-content--editable",
|
|
2631
|
+
style: $({ color: p.theme.colors.xmlText }),
|
|
2632
|
+
contenteditable: c.value,
|
|
2633
|
+
onDblclick: E,
|
|
2634
|
+
onKeydown: [
|
|
2635
|
+
U(Z(H, ["prevent"]), ["enter"]),
|
|
2636
|
+
U(oe, ["escape"])
|
|
2637
|
+
],
|
|
2638
|
+
onBlur: H,
|
|
2639
|
+
ref_key: "textContentRef",
|
|
2640
|
+
ref: S,
|
|
2641
|
+
title: "Double-click to edit text content"
|
|
2642
|
+
}, M(c.value ? h.value : se.value), 45, Vr)
|
|
2643
|
+
])) : te("", !0),
|
|
2644
|
+
(O(!0), P(pe, null, _e(ae.value, (ee, I) => (O(), Ze(D, {
|
|
2645
|
+
key: Q(ee, I),
|
|
2646
|
+
node: ee,
|
|
2647
|
+
index: I,
|
|
2648
|
+
level: p.level + 1,
|
|
2649
|
+
"parent-path": f(),
|
|
2650
|
+
expanded: p.expanded,
|
|
2651
|
+
theme: p.theme,
|
|
2652
|
+
onToggleExpand: N[6] || (N[6] = (F) => p.$emit("toggle-expand", F)),
|
|
2653
|
+
onCopy: N[7] || (N[7] = (F) => p.$emit("copy", F)),
|
|
2654
|
+
"onUpdate:tagName": N[8] || (N[8] = (F, ye, Ae) => p.$emit("update:tagName", F, ye, Ae)),
|
|
2655
|
+
"onUpdate:attributeName": N[9] || (N[9] = (F, ye, Ae) => p.$emit("update:attributeName", F, ye, Ae)),
|
|
2656
|
+
"onUpdate:attributeValue": N[10] || (N[10] = (F, ye, Ae) => p.$emit("update:attributeValue", F, ye, Ae)),
|
|
2657
|
+
"onUpdate:textContent": N[11] || (N[11] = (F, ye) => p.$emit("update:textContent", F, ye))
|
|
2398
2658
|
}, null, 8, ["node", "index", "level", "parent-path", "expanded", "theme"]))), 128))
|
|
2399
|
-
])) :
|
|
2400
|
-
|
|
2659
|
+
])) : te("", !0),
|
|
2660
|
+
Y.value && C.value ? (O(), P("div", Rr, [
|
|
2401
2661
|
y("span", {
|
|
2402
2662
|
class: "xml-node__clickable-part",
|
|
2403
|
-
onClick:
|
|
2663
|
+
onClick: N[12] || (N[12] = (ee) => T()),
|
|
2404
2664
|
title: "Click to collapse"
|
|
2405
2665
|
}, [
|
|
2406
2666
|
y("span", {
|
|
2407
2667
|
class: "xml-node__bracket",
|
|
2408
|
-
style:
|
|
2668
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2409
2669
|
}, "</", 4),
|
|
2410
2670
|
y("span", {
|
|
2411
2671
|
class: "xml-node__tag",
|
|
2412
|
-
style:
|
|
2413
|
-
},
|
|
2672
|
+
style: $({ color: p.theme.colors.xmlTag })
|
|
2673
|
+
}, M(n.value ? a.value : _.value), 5),
|
|
2414
2674
|
y("span", {
|
|
2415
2675
|
class: "xml-node__bracket",
|
|
2416
|
-
style:
|
|
2676
|
+
style: $({ color: p.theme.colors.xmlBracket })
|
|
2417
2677
|
}, ">", 4)
|
|
2418
2678
|
])
|
|
2419
|
-
])) :
|
|
2679
|
+
])) : te("", !0)
|
|
2420
2680
|
], 64))
|
|
2421
2681
|
]))
|
|
2422
|
-
])) :
|
|
2682
|
+
])) : te("", !0)
|
|
2423
2683
|
], 4);
|
|
2424
2684
|
};
|
|
2425
2685
|
}
|
|
2426
|
-
}),
|
|
2686
|
+
}), jr = /* @__PURE__ */ $e(Lr, [["__scopeId", "data-v-9bd6cb1a"]]), Ur = {
|
|
2427
2687
|
name: "github-light",
|
|
2428
2688
|
colors: {
|
|
2429
2689
|
// 背景色
|
|
@@ -2473,7 +2733,7 @@ const Lt = {
|
|
|
2473
2733
|
collapsedText: "#0969da"
|
|
2474
2734
|
// 折叠信息文本色 - 蓝色
|
|
2475
2735
|
}
|
|
2476
|
-
},
|
|
2736
|
+
}, Mr = {
|
|
2477
2737
|
name: "github-dark",
|
|
2478
2738
|
colors: {
|
|
2479
2739
|
// 背景色
|
|
@@ -2523,7 +2783,7 @@ const Lt = {
|
|
|
2523
2783
|
collapsedText: "#58a6ff"
|
|
2524
2784
|
// 折叠信息文本色 - 亮蓝
|
|
2525
2785
|
}
|
|
2526
|
-
},
|
|
2786
|
+
}, Fr = {
|
|
2527
2787
|
name: "min-light",
|
|
2528
2788
|
colors: {
|
|
2529
2789
|
// 背景色
|
|
@@ -2573,7 +2833,7 @@ const Lt = {
|
|
|
2573
2833
|
collapsedText: "#1d4ed8"
|
|
2574
2834
|
// 折叠信息文本色 - 蓝色
|
|
2575
2835
|
}
|
|
2576
|
-
},
|
|
2836
|
+
}, Kr = {
|
|
2577
2837
|
name: "slack-ochin",
|
|
2578
2838
|
colors: {
|
|
2579
2839
|
// 背景色
|
|
@@ -2623,13 +2883,13 @@ const Lt = {
|
|
|
2623
2883
|
collapsedText: "#0b4c8c"
|
|
2624
2884
|
// 折叠信息文本色 - 深蓝
|
|
2625
2885
|
}
|
|
2626
|
-
},
|
|
2627
|
-
"github-light":
|
|
2628
|
-
"github-dark":
|
|
2629
|
-
"min-light":
|
|
2630
|
-
"slack-ochin":
|
|
2631
|
-
},
|
|
2632
|
-
function
|
|
2886
|
+
}, Fe = {
|
|
2887
|
+
"github-light": Ur,
|
|
2888
|
+
"github-dark": Mr,
|
|
2889
|
+
"min-light": Fr,
|
|
2890
|
+
"slack-ochin": Kr
|
|
2891
|
+
}, Xr = (r) => Fe[r] || Fe["github-light"], De = ":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", Hr = De + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", qr = "[" + De + "][" + Hr + "]*", Wr = new RegExp("^" + qr + "$");
|
|
2892
|
+
function Je(r, e) {
|
|
2633
2893
|
const t = [];
|
|
2634
2894
|
let s = e.exec(r);
|
|
2635
2895
|
for (; s; ) {
|
|
@@ -2642,123 +2902,123 @@ function qe(r, e) {
|
|
|
2642
2902
|
}
|
|
2643
2903
|
return t;
|
|
2644
2904
|
}
|
|
2645
|
-
const
|
|
2646
|
-
const e =
|
|
2905
|
+
const Pe = function(r) {
|
|
2906
|
+
const e = Wr.exec(r);
|
|
2647
2907
|
return !(e === null || typeof e > "u");
|
|
2648
2908
|
};
|
|
2649
|
-
function
|
|
2909
|
+
function Qr(r) {
|
|
2650
2910
|
return typeof r < "u";
|
|
2651
2911
|
}
|
|
2652
|
-
const
|
|
2912
|
+
const Yr = {
|
|
2653
2913
|
allowBooleanAttributes: !1,
|
|
2654
2914
|
//A tag can have attributes without any value
|
|
2655
2915
|
unpairedTags: []
|
|
2656
2916
|
};
|
|
2657
|
-
function
|
|
2658
|
-
e = Object.assign({},
|
|
2917
|
+
function et(r, e) {
|
|
2918
|
+
e = Object.assign({}, Yr, e);
|
|
2659
2919
|
const t = [];
|
|
2660
2920
|
let s = !1, n = !1;
|
|
2661
2921
|
r[0] === "\uFEFF" && (r = r.substr(1));
|
|
2662
2922
|
for (let o = 0; o < r.length; o++)
|
|
2663
2923
|
if (r[o] === "<" && r[o + 1] === "?") {
|
|
2664
|
-
if (o += 2, o =
|
|
2924
|
+
if (o += 2, o = Xe(r, o), o.err) return o;
|
|
2665
2925
|
} else if (r[o] === "<") {
|
|
2666
2926
|
let i = o;
|
|
2667
2927
|
if (o++, r[o] === "!") {
|
|
2668
|
-
o =
|
|
2928
|
+
o = He(r, o);
|
|
2669
2929
|
continue;
|
|
2670
2930
|
} else {
|
|
2671
|
-
let
|
|
2672
|
-
r[o] === "/" && (
|
|
2931
|
+
let c = !1;
|
|
2932
|
+
r[o] === "/" && (c = !0, o++);
|
|
2673
2933
|
let a = "";
|
|
2674
2934
|
for (; o < r.length && r[o] !== ">" && r[o] !== " " && r[o] !== " " && r[o] !== `
|
|
2675
2935
|
` && r[o] !== "\r"; o++)
|
|
2676
2936
|
a += r[o];
|
|
2677
|
-
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--),
|
|
2937
|
+
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !rn(a)) {
|
|
2678
2938
|
let h;
|
|
2679
|
-
return a.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + a + "' is an invalid name.",
|
|
2939
|
+
return a.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + a + "' is an invalid name.", G("InvalidTag", h, ne(r, o));
|
|
2680
2940
|
}
|
|
2681
|
-
const l =
|
|
2941
|
+
const l = zr(r, o);
|
|
2682
2942
|
if (l === !1)
|
|
2683
|
-
return
|
|
2684
|
-
let
|
|
2685
|
-
if (o = l.index,
|
|
2686
|
-
const h = o -
|
|
2687
|
-
|
|
2688
|
-
const
|
|
2689
|
-
if (
|
|
2943
|
+
return G("InvalidAttr", "Attributes for '" + a + "' have open quote.", ne(r, o));
|
|
2944
|
+
let g = l.value;
|
|
2945
|
+
if (o = l.index, g[g.length - 1] === "/") {
|
|
2946
|
+
const h = o - g.length;
|
|
2947
|
+
g = g.substring(0, g.length - 1);
|
|
2948
|
+
const x = qe(g, e);
|
|
2949
|
+
if (x === !0)
|
|
2690
2950
|
s = !0;
|
|
2691
2951
|
else
|
|
2692
|
-
return
|
|
2693
|
-
} else if (
|
|
2952
|
+
return G(x.err.code, x.err.msg, ne(r, h + x.err.line));
|
|
2953
|
+
} else if (c)
|
|
2694
2954
|
if (l.tagClosed) {
|
|
2695
|
-
if (
|
|
2696
|
-
return
|
|
2955
|
+
if (g.trim().length > 0)
|
|
2956
|
+
return G("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", ne(r, i));
|
|
2697
2957
|
if (t.length === 0)
|
|
2698
|
-
return
|
|
2958
|
+
return G("InvalidTag", "Closing tag '" + a + "' has not been opened.", ne(r, i));
|
|
2699
2959
|
{
|
|
2700
2960
|
const h = t.pop();
|
|
2701
2961
|
if (a !== h.tagName) {
|
|
2702
|
-
let
|
|
2703
|
-
return
|
|
2962
|
+
let x = ne(r, h.tagStartPos);
|
|
2963
|
+
return G(
|
|
2704
2964
|
"InvalidTag",
|
|
2705
|
-
"Expected closing tag '" + h.tagName + "' (opened in line " +
|
|
2706
|
-
|
|
2965
|
+
"Expected closing tag '" + h.tagName + "' (opened in line " + x.line + ", col " + x.col + ") instead of closing tag '" + a + "'.",
|
|
2966
|
+
ne(r, i)
|
|
2707
2967
|
);
|
|
2708
2968
|
}
|
|
2709
2969
|
t.length == 0 && (n = !0);
|
|
2710
2970
|
}
|
|
2711
|
-
} else return
|
|
2971
|
+
} else return G("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", ne(r, o));
|
|
2712
2972
|
else {
|
|
2713
|
-
const h =
|
|
2973
|
+
const h = qe(g, e);
|
|
2714
2974
|
if (h !== !0)
|
|
2715
|
-
return
|
|
2975
|
+
return G(h.err.code, h.err.msg, ne(r, o - g.length + h.err.line));
|
|
2716
2976
|
if (n === !0)
|
|
2717
|
-
return
|
|
2977
|
+
return G("InvalidXml", "Multiple possible root nodes found.", ne(r, o));
|
|
2718
2978
|
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2719
2979
|
}
|
|
2720
2980
|
for (o++; o < r.length; o++)
|
|
2721
2981
|
if (r[o] === "<")
|
|
2722
2982
|
if (r[o + 1] === "!") {
|
|
2723
|
-
o++, o =
|
|
2983
|
+
o++, o = He(r, o);
|
|
2724
2984
|
continue;
|
|
2725
2985
|
} else if (r[o + 1] === "?") {
|
|
2726
|
-
if (o =
|
|
2986
|
+
if (o = Xe(r, ++o), o.err) return o;
|
|
2727
2987
|
} else
|
|
2728
2988
|
break;
|
|
2729
2989
|
else if (r[o] === "&") {
|
|
2730
|
-
const h =
|
|
2990
|
+
const h = en(r, o);
|
|
2731
2991
|
if (h == -1)
|
|
2732
|
-
return
|
|
2992
|
+
return G("InvalidChar", "char '&' is not expected.", ne(r, o));
|
|
2733
2993
|
o = h;
|
|
2734
|
-
} else if (n === !0 && !
|
|
2735
|
-
return
|
|
2994
|
+
} else if (n === !0 && !Ke(r[o]))
|
|
2995
|
+
return G("InvalidXml", "Extra text at the end", ne(r, o));
|
|
2736
2996
|
r[o] === "<" && o--;
|
|
2737
2997
|
}
|
|
2738
2998
|
} else {
|
|
2739
|
-
if (
|
|
2999
|
+
if (Ke(r[o]))
|
|
2740
3000
|
continue;
|
|
2741
|
-
return
|
|
3001
|
+
return G("InvalidChar", "char '" + r[o] + "' is not expected.", ne(r, o));
|
|
2742
3002
|
}
|
|
2743
3003
|
if (s) {
|
|
2744
3004
|
if (t.length == 1)
|
|
2745
|
-
return
|
|
3005
|
+
return G("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", ne(r, t[0].tagStartPos));
|
|
2746
3006
|
if (t.length > 0)
|
|
2747
|
-
return
|
|
2748
|
-
} else return
|
|
3007
|
+
return G("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
3008
|
+
} else return G("InvalidXml", "Start tag expected.", 1);
|
|
2749
3009
|
return !0;
|
|
2750
3010
|
}
|
|
2751
|
-
function
|
|
3011
|
+
function Ke(r) {
|
|
2752
3012
|
return r === " " || r === " " || r === `
|
|
2753
3013
|
` || r === "\r";
|
|
2754
3014
|
}
|
|
2755
|
-
function
|
|
3015
|
+
function Xe(r, e) {
|
|
2756
3016
|
const t = e;
|
|
2757
3017
|
for (; e < r.length; e++)
|
|
2758
3018
|
if (r[e] == "?" || r[e] == " ") {
|
|
2759
3019
|
const s = r.substr(t, e - t);
|
|
2760
3020
|
if (e > 5 && s === "xml")
|
|
2761
|
-
return
|
|
3021
|
+
return G("InvalidXml", "XML declaration allowed only at the start of the document.", ne(r, e));
|
|
2762
3022
|
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2763
3023
|
e++;
|
|
2764
3024
|
break;
|
|
@@ -2767,7 +3027,7 @@ function Ve(r, e) {
|
|
|
2767
3027
|
}
|
|
2768
3028
|
return e;
|
|
2769
3029
|
}
|
|
2770
|
-
function
|
|
3030
|
+
function He(r, e) {
|
|
2771
3031
|
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2772
3032
|
for (e += 3; e < r.length; e++)
|
|
2773
3033
|
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
@@ -2790,11 +3050,11 @@ function Le(r, e) {
|
|
|
2790
3050
|
}
|
|
2791
3051
|
return e;
|
|
2792
3052
|
}
|
|
2793
|
-
const
|
|
2794
|
-
function
|
|
3053
|
+
const Gr = '"', Zr = "'";
|
|
3054
|
+
function zr(r, e) {
|
|
2795
3055
|
let t = "", s = "", n = !1;
|
|
2796
3056
|
for (; e < r.length; e++) {
|
|
2797
|
-
if (r[e] ===
|
|
3057
|
+
if (r[e] === Gr || r[e] === Zr)
|
|
2798
3058
|
s === "" ? s = r[e] : s !== r[e] || (s = "");
|
|
2799
3059
|
else if (r[e] === ">" && s === "") {
|
|
2800
3060
|
n = !0;
|
|
@@ -2808,27 +3068,27 @@ function wr(r, e) {
|
|
|
2808
3068
|
tagClosed: n
|
|
2809
3069
|
};
|
|
2810
3070
|
}
|
|
2811
|
-
const
|
|
2812
|
-
function
|
|
2813
|
-
const t =
|
|
3071
|
+
const Dr = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
3072
|
+
function qe(r, e) {
|
|
3073
|
+
const t = Je(r, Dr), s = {};
|
|
2814
3074
|
for (let n = 0; n < t.length; n++) {
|
|
2815
3075
|
if (t[n][1].length === 0)
|
|
2816
|
-
return
|
|
3076
|
+
return G("InvalidAttr", "Attribute '" + t[n][2] + "' has no space in starting.", we(t[n]));
|
|
2817
3077
|
if (t[n][3] !== void 0 && t[n][4] === void 0)
|
|
2818
|
-
return
|
|
3078
|
+
return G("InvalidAttr", "Attribute '" + t[n][2] + "' is without value.", we(t[n]));
|
|
2819
3079
|
if (t[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
2820
|
-
return
|
|
3080
|
+
return G("InvalidAttr", "boolean attribute '" + t[n][2] + "' is not allowed.", we(t[n]));
|
|
2821
3081
|
const o = t[n][2];
|
|
2822
|
-
if (!
|
|
2823
|
-
return
|
|
3082
|
+
if (!tn(o))
|
|
3083
|
+
return G("InvalidAttr", "Attribute '" + o + "' is an invalid name.", we(t[n]));
|
|
2824
3084
|
if (!s.hasOwnProperty(o))
|
|
2825
3085
|
s[o] = 1;
|
|
2826
3086
|
else
|
|
2827
|
-
return
|
|
3087
|
+
return G("InvalidAttr", "Attribute '" + o + "' is repeated.", we(t[n]));
|
|
2828
3088
|
}
|
|
2829
3089
|
return !0;
|
|
2830
3090
|
}
|
|
2831
|
-
function
|
|
3091
|
+
function Jr(r, e) {
|
|
2832
3092
|
let t = /\d/;
|
|
2833
3093
|
for (r[e] === "x" && (e++, t = /[\da-fA-F]/); e < r.length; e++) {
|
|
2834
3094
|
if (r[e] === ";")
|
|
@@ -2838,11 +3098,11 @@ function Or(r, e) {
|
|
|
2838
3098
|
}
|
|
2839
3099
|
return -1;
|
|
2840
3100
|
}
|
|
2841
|
-
function
|
|
3101
|
+
function en(r, e) {
|
|
2842
3102
|
if (e++, r[e] === ";")
|
|
2843
3103
|
return -1;
|
|
2844
3104
|
if (r[e] === "#")
|
|
2845
|
-
return e++,
|
|
3105
|
+
return e++, Jr(r, e);
|
|
2846
3106
|
let t = 0;
|
|
2847
3107
|
for (; e < r.length; e++, t++)
|
|
2848
3108
|
if (!(r[e].match(/\w/) && t < 20)) {
|
|
@@ -2852,7 +3112,7 @@ function Tr(r, e) {
|
|
|
2852
3112
|
}
|
|
2853
3113
|
return e;
|
|
2854
3114
|
}
|
|
2855
|
-
function
|
|
3115
|
+
function G(r, e, t) {
|
|
2856
3116
|
return {
|
|
2857
3117
|
err: {
|
|
2858
3118
|
code: r,
|
|
@@ -2862,13 +3122,13 @@ function M(r, e, t) {
|
|
|
2862
3122
|
}
|
|
2863
3123
|
};
|
|
2864
3124
|
}
|
|
2865
|
-
function
|
|
2866
|
-
return
|
|
3125
|
+
function tn(r) {
|
|
3126
|
+
return Pe(r);
|
|
2867
3127
|
}
|
|
2868
|
-
function
|
|
2869
|
-
return
|
|
3128
|
+
function rn(r) {
|
|
3129
|
+
return Pe(r);
|
|
2870
3130
|
}
|
|
2871
|
-
function
|
|
3131
|
+
function ne(r, e) {
|
|
2872
3132
|
const t = r.substring(0, e).split(/\r?\n/);
|
|
2873
3133
|
return {
|
|
2874
3134
|
line: t.length,
|
|
@@ -2876,10 +3136,10 @@ function Q(r, e) {
|
|
|
2876
3136
|
col: t[t.length - 1].length + 1
|
|
2877
3137
|
};
|
|
2878
3138
|
}
|
|
2879
|
-
function
|
|
3139
|
+
function we(r) {
|
|
2880
3140
|
return r.startIndex + r[1].length;
|
|
2881
3141
|
}
|
|
2882
|
-
const
|
|
3142
|
+
const nn = {
|
|
2883
3143
|
preserveOrder: !1,
|
|
2884
3144
|
attributeNamePrefix: "@_",
|
|
2885
3145
|
attributesGroupName: !1,
|
|
@@ -2923,12 +3183,12 @@ const Sr = {
|
|
|
2923
3183
|
},
|
|
2924
3184
|
// skipEmptyListItem: false
|
|
2925
3185
|
captureMetaData: !1
|
|
2926
|
-
},
|
|
2927
|
-
return Object.assign({},
|
|
3186
|
+
}, sn = function(r) {
|
|
3187
|
+
return Object.assign({}, nn, r);
|
|
2928
3188
|
};
|
|
2929
|
-
let
|
|
2930
|
-
typeof Symbol != "function" ?
|
|
2931
|
-
class
|
|
3189
|
+
let Te;
|
|
3190
|
+
typeof Symbol != "function" ? Te = "@@xmlMetadata" : Te = Symbol("XML Node Metadata");
|
|
3191
|
+
class xe {
|
|
2932
3192
|
constructor(e) {
|
|
2933
3193
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
2934
3194
|
}
|
|
@@ -2936,14 +3196,14 @@ class ae {
|
|
|
2936
3196
|
e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: t });
|
|
2937
3197
|
}
|
|
2938
3198
|
addChild(e, t) {
|
|
2939
|
-
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][
|
|
3199
|
+
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][Te] = { startIndex: t });
|
|
2940
3200
|
}
|
|
2941
3201
|
/** symbol used for metadata */
|
|
2942
3202
|
static getMetaDataSymbol() {
|
|
2943
|
-
return
|
|
3203
|
+
return Te;
|
|
2944
3204
|
}
|
|
2945
3205
|
}
|
|
2946
|
-
class
|
|
3206
|
+
class on {
|
|
2947
3207
|
constructor(e) {
|
|
2948
3208
|
this.suppressValidationErr = !e;
|
|
2949
3209
|
}
|
|
@@ -2951,33 +3211,33 @@ class Ir {
|
|
|
2951
3211
|
const s = {};
|
|
2952
3212
|
if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
|
|
2953
3213
|
t = t + 9;
|
|
2954
|
-
let n = 1, o = !1, i = !1,
|
|
3214
|
+
let n = 1, o = !1, i = !1, c = "";
|
|
2955
3215
|
for (; t < e.length; t++)
|
|
2956
3216
|
if (e[t] === "<" && !i) {
|
|
2957
|
-
if (o &&
|
|
3217
|
+
if (o && ve(e, "!ENTITY", t)) {
|
|
2958
3218
|
t += 7;
|
|
2959
3219
|
let a, l;
|
|
2960
3220
|
[a, l, t] = this.readEntityExp(e, t + 1, this.suppressValidationErr), l.indexOf("&") === -1 && (s[a] = {
|
|
2961
3221
|
regx: RegExp(`&${a};`, "g"),
|
|
2962
3222
|
val: l
|
|
2963
3223
|
});
|
|
2964
|
-
} else if (o &&
|
|
3224
|
+
} else if (o && ve(e, "!ELEMENT", t)) {
|
|
2965
3225
|
t += 8;
|
|
2966
3226
|
const { index: a } = this.readElementExp(e, t + 1);
|
|
2967
3227
|
t = a;
|
|
2968
|
-
} else if (o &&
|
|
3228
|
+
} else if (o && ve(e, "!ATTLIST", t))
|
|
2969
3229
|
t += 8;
|
|
2970
|
-
else if (o &&
|
|
3230
|
+
else if (o && ve(e, "!NOTATION", t)) {
|
|
2971
3231
|
t += 9;
|
|
2972
3232
|
const { index: a } = this.readNotationExp(e, t + 1, this.suppressValidationErr);
|
|
2973
3233
|
t = a;
|
|
2974
|
-
} else if (
|
|
3234
|
+
} else if (ve(e, "!--", t)) i = !0;
|
|
2975
3235
|
else throw new Error("Invalid DOCTYPE");
|
|
2976
|
-
n++,
|
|
3236
|
+
n++, c = "";
|
|
2977
3237
|
} else if (e[t] === ">") {
|
|
2978
3238
|
if (i ? e[t - 1] === "-" && e[t - 2] === "-" && (i = !1, n--) : n--, n === 0)
|
|
2979
3239
|
break;
|
|
2980
|
-
} else e[t] === "[" ? o = !0 :
|
|
3240
|
+
} else e[t] === "[" ? o = !0 : c += e[t];
|
|
2981
3241
|
if (n !== 0)
|
|
2982
3242
|
throw new Error("Unclosed DOCTYPE");
|
|
2983
3243
|
} else
|
|
@@ -2985,11 +3245,11 @@ class Ir {
|
|
|
2985
3245
|
return { entities: s, i: t };
|
|
2986
3246
|
}
|
|
2987
3247
|
readEntityExp(e, t) {
|
|
2988
|
-
t =
|
|
3248
|
+
t = ie(e, t);
|
|
2989
3249
|
let s = "";
|
|
2990
3250
|
for (; t < e.length && !/\s/.test(e[t]) && e[t] !== '"' && e[t] !== "'"; )
|
|
2991
3251
|
s += e[t], t++;
|
|
2992
|
-
if (
|
|
3252
|
+
if (Ne(s), t = ie(e, t), !this.suppressValidationErr) {
|
|
2993
3253
|
if (e.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
2994
3254
|
throw new Error("External entities are not supported");
|
|
2995
3255
|
if (e[t] === "%")
|
|
@@ -2999,18 +3259,18 @@ class Ir {
|
|
|
2999
3259
|
return [t, n] = this.readIdentifierVal(e, t, "entity"), t--, [s, n, t];
|
|
3000
3260
|
}
|
|
3001
3261
|
readNotationExp(e, t) {
|
|
3002
|
-
t =
|
|
3262
|
+
t = ie(e, t);
|
|
3003
3263
|
let s = "";
|
|
3004
3264
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
3005
3265
|
s += e[t], t++;
|
|
3006
|
-
!this.suppressValidationErr &&
|
|
3266
|
+
!this.suppressValidationErr && Ne(s), t = ie(e, t);
|
|
3007
3267
|
const n = e.substring(t, t + 6).toUpperCase();
|
|
3008
3268
|
if (!this.suppressValidationErr && n !== "SYSTEM" && n !== "PUBLIC")
|
|
3009
3269
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);
|
|
3010
|
-
t += n.length, t =
|
|
3270
|
+
t += n.length, t = ie(e, t);
|
|
3011
3271
|
let o = null, i = null;
|
|
3012
3272
|
if (n === "PUBLIC")
|
|
3013
|
-
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t =
|
|
3273
|
+
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t = ie(e, t), (e[t] === '"' || e[t] === "'") && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"));
|
|
3014
3274
|
else if (n === "SYSTEM" && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !i))
|
|
3015
3275
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
3016
3276
|
return { notationName: s, publicIdentifier: o, systemIdentifier: i, index: --t };
|
|
@@ -3027,16 +3287,16 @@ class Ir {
|
|
|
3027
3287
|
return t++, [t, n];
|
|
3028
3288
|
}
|
|
3029
3289
|
readElementExp(e, t) {
|
|
3030
|
-
t =
|
|
3290
|
+
t = ie(e, t);
|
|
3031
3291
|
let s = "";
|
|
3032
3292
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
3033
3293
|
s += e[t], t++;
|
|
3034
|
-
if (!this.suppressValidationErr && !
|
|
3294
|
+
if (!this.suppressValidationErr && !Pe(s))
|
|
3035
3295
|
throw new Error(`Invalid element name: "${s}"`);
|
|
3036
|
-
t =
|
|
3296
|
+
t = ie(e, t);
|
|
3037
3297
|
let n = "";
|
|
3038
|
-
if (e[t] === "E" &&
|
|
3039
|
-
else if (e[t] === "A" &&
|
|
3298
|
+
if (e[t] === "E" && ve(e, "MPTY", t)) t += 4;
|
|
3299
|
+
else if (e[t] === "A" && ve(e, "NY", t)) t += 2;
|
|
3040
3300
|
else if (e[t] === "(") {
|
|
3041
3301
|
for (t++; t < e.length && e[t] !== ")"; )
|
|
3042
3302
|
n += e[t], t++;
|
|
@@ -3051,42 +3311,42 @@ class Ir {
|
|
|
3051
3311
|
};
|
|
3052
3312
|
}
|
|
3053
3313
|
readAttlistExp(e, t) {
|
|
3054
|
-
t =
|
|
3314
|
+
t = ie(e, t);
|
|
3055
3315
|
let s = "";
|
|
3056
3316
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
3057
3317
|
s += e[t], t++;
|
|
3058
|
-
|
|
3318
|
+
Ne(s), t = ie(e, t);
|
|
3059
3319
|
let n = "";
|
|
3060
3320
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
3061
3321
|
n += e[t], t++;
|
|
3062
|
-
if (!
|
|
3322
|
+
if (!Ne(n))
|
|
3063
3323
|
throw new Error(`Invalid attribute name: "${n}"`);
|
|
3064
|
-
t =
|
|
3324
|
+
t = ie(e, t);
|
|
3065
3325
|
let o = "";
|
|
3066
3326
|
if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
|
|
3067
|
-
if (o = "NOTATION", t += 8, t =
|
|
3327
|
+
if (o = "NOTATION", t += 8, t = ie(e, t), e[t] !== "(")
|
|
3068
3328
|
throw new Error(`Expected '(', found "${e[t]}"`);
|
|
3069
3329
|
t++;
|
|
3070
|
-
let
|
|
3330
|
+
let c = [];
|
|
3071
3331
|
for (; t < e.length && e[t] !== ")"; ) {
|
|
3072
3332
|
let a = "";
|
|
3073
3333
|
for (; t < e.length && e[t] !== "|" && e[t] !== ")"; )
|
|
3074
3334
|
a += e[t], t++;
|
|
3075
|
-
if (a = a.trim(), !
|
|
3335
|
+
if (a = a.trim(), !Ne(a))
|
|
3076
3336
|
throw new Error(`Invalid notation name: "${a}"`);
|
|
3077
|
-
|
|
3337
|
+
c.push(a), e[t] === "|" && (t++, t = ie(e, t));
|
|
3078
3338
|
}
|
|
3079
3339
|
if (e[t] !== ")")
|
|
3080
3340
|
throw new Error("Unterminated list of notations");
|
|
3081
|
-
t++, o += " (" +
|
|
3341
|
+
t++, o += " (" + c.join("|") + ")";
|
|
3082
3342
|
} else {
|
|
3083
3343
|
for (; t < e.length && !/\s/.test(e[t]); )
|
|
3084
3344
|
o += e[t], t++;
|
|
3085
|
-
const
|
|
3086
|
-
if (!this.suppressValidationErr && !
|
|
3345
|
+
const c = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
3346
|
+
if (!this.suppressValidationErr && !c.includes(o.toUpperCase()))
|
|
3087
3347
|
throw new Error(`Invalid attribute type: "${o}"`);
|
|
3088
3348
|
}
|
|
3089
|
-
t =
|
|
3349
|
+
t = ie(e, t);
|
|
3090
3350
|
let i = "";
|
|
3091
3351
|
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"), {
|
|
3092
3352
|
elementName: s,
|
|
@@ -3097,22 +3357,22 @@ class Ir {
|
|
|
3097
3357
|
};
|
|
3098
3358
|
}
|
|
3099
3359
|
}
|
|
3100
|
-
const
|
|
3360
|
+
const ie = (r, e) => {
|
|
3101
3361
|
for (; e < r.length && /\s/.test(r[e]); )
|
|
3102
3362
|
e++;
|
|
3103
3363
|
return e;
|
|
3104
3364
|
};
|
|
3105
|
-
function
|
|
3365
|
+
function ve(r, e, t) {
|
|
3106
3366
|
for (let s = 0; s < e.length; s++)
|
|
3107
3367
|
if (e[s] !== r[t + s + 1]) return !1;
|
|
3108
3368
|
return !0;
|
|
3109
3369
|
}
|
|
3110
|
-
function
|
|
3111
|
-
if (
|
|
3370
|
+
function Ne(r) {
|
|
3371
|
+
if (Pe(r))
|
|
3112
3372
|
return r;
|
|
3113
3373
|
throw new Error(`Invalid entity name ${r}`);
|
|
3114
3374
|
}
|
|
3115
|
-
const
|
|
3375
|
+
const an = /^[-+]?0x[a-fA-F0-9]+$/, ln = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, cn = {
|
|
3116
3376
|
hex: !0,
|
|
3117
3377
|
// oct: false,
|
|
3118
3378
|
leadingZeros: !0,
|
|
@@ -3120,25 +3380,25 @@ const Vr = /^[-+]?0x[a-fA-F0-9]+$/, Lr = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, j
|
|
|
3120
3380
|
eNotation: !0
|
|
3121
3381
|
//skipLike: /regex/
|
|
3122
3382
|
};
|
|
3123
|
-
function
|
|
3124
|
-
if (e = Object.assign({},
|
|
3383
|
+
function un(r, e = {}) {
|
|
3384
|
+
if (e = Object.assign({}, cn, e), !r || typeof r != "string") return r;
|
|
3125
3385
|
let t = r.trim();
|
|
3126
3386
|
if (e.skipLike !== void 0 && e.skipLike.test(t)) return r;
|
|
3127
3387
|
if (r === "0") return 0;
|
|
3128
|
-
if (e.hex &&
|
|
3129
|
-
return
|
|
3388
|
+
if (e.hex && an.test(t))
|
|
3389
|
+
return pn(t, 16);
|
|
3130
3390
|
if (t.search(/.+[eE].+/) !== -1)
|
|
3131
|
-
return
|
|
3391
|
+
return fn(r, t, e);
|
|
3132
3392
|
{
|
|
3133
|
-
const s =
|
|
3393
|
+
const s = ln.exec(t);
|
|
3134
3394
|
if (s) {
|
|
3135
3395
|
const n = s[1] || "", o = s[2];
|
|
3136
|
-
let i =
|
|
3137
|
-
const
|
|
3396
|
+
let i = hn(s[3]);
|
|
3397
|
+
const c = n ? (
|
|
3138
3398
|
// 0., -00., 000.
|
|
3139
3399
|
r[o.length + 1] === "."
|
|
3140
3400
|
) : r[o.length] === ".";
|
|
3141
|
-
if (!e.leadingZeros && (o.length > 1 || o.length === 1 && !
|
|
3401
|
+
if (!e.leadingZeros && (o.length > 1 || o.length === 1 && !c))
|
|
3142
3402
|
return r;
|
|
3143
3403
|
{
|
|
3144
3404
|
const a = Number(t), l = String(a);
|
|
@@ -3147,44 +3407,44 @@ function Rr(r, e = {}) {
|
|
|
3147
3407
|
return e.eNotation ? a : r;
|
|
3148
3408
|
if (t.indexOf(".") !== -1)
|
|
3149
3409
|
return l === "0" || l === i || l === `${n}${i}` ? a : r;
|
|
3150
|
-
let
|
|
3151
|
-
return o ?
|
|
3410
|
+
let g = o ? i : t;
|
|
3411
|
+
return o ? g === l || n + g === l ? a : r : g === l || g === n + l ? a : r;
|
|
3152
3412
|
}
|
|
3153
3413
|
} else
|
|
3154
3414
|
return r;
|
|
3155
3415
|
}
|
|
3156
3416
|
}
|
|
3157
|
-
const
|
|
3158
|
-
function
|
|
3417
|
+
const dn = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
3418
|
+
function fn(r, e, t) {
|
|
3159
3419
|
if (!t.eNotation) return r;
|
|
3160
|
-
const s = e.match(
|
|
3420
|
+
const s = e.match(dn);
|
|
3161
3421
|
if (s) {
|
|
3162
3422
|
let n = s[1] || "";
|
|
3163
|
-
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2],
|
|
3423
|
+
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2], c = n ? (
|
|
3164
3424
|
// 0E.
|
|
3165
3425
|
r[i.length + 1] === o
|
|
3166
3426
|
) : r[i.length] === o;
|
|
3167
|
-
return i.length > 1 &&
|
|
3427
|
+
return i.length > 1 && c ? r : i.length === 1 && (s[3].startsWith(`.${o}`) || s[3][0] === o) ? Number(e) : t.leadingZeros && !c ? (e = (s[1] || "") + s[3], Number(e)) : r;
|
|
3168
3428
|
} else
|
|
3169
3429
|
return r;
|
|
3170
3430
|
}
|
|
3171
|
-
function
|
|
3431
|
+
function hn(r) {
|
|
3172
3432
|
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;
|
|
3173
3433
|
}
|
|
3174
|
-
function
|
|
3434
|
+
function pn(r, e) {
|
|
3175
3435
|
if (parseInt) return parseInt(r, e);
|
|
3176
3436
|
if (Number.parseInt) return Number.parseInt(r, e);
|
|
3177
3437
|
if (window && window.parseInt) return window.parseInt(r, e);
|
|
3178
3438
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
3179
3439
|
}
|
|
3180
|
-
function
|
|
3440
|
+
function tt(r) {
|
|
3181
3441
|
return typeof r == "function" ? r : Array.isArray(r) ? (e) => {
|
|
3182
3442
|
for (const t of r)
|
|
3183
3443
|
if (typeof t == "string" && e === t || t instanceof RegExp && t.test(e))
|
|
3184
3444
|
return !0;
|
|
3185
3445
|
} : () => !1;
|
|
3186
3446
|
}
|
|
3187
|
-
class
|
|
3447
|
+
class gn {
|
|
3188
3448
|
constructor(e) {
|
|
3189
3449
|
this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
3190
3450
|
apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
@@ -3207,10 +3467,10 @@ class Hr {
|
|
|
3207
3467
|
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
3208
3468
|
num_dec: { regex: /&#([0-9]{1,7});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 10)) },
|
|
3209
3469
|
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 16)) }
|
|
3210
|
-
}, this.addExternalEntities =
|
|
3470
|
+
}, this.addExternalEntities = mn, this.parseXml = xn, this.parseTextData = bn, this.resolveNameSpace = yn, this.buildAttributesMap = _n, this.isItStopNode = wn, this.replaceEntitiesValue = kn, this.readStopNodeData = Cn, this.saveTextToParentTag = An, this.addChild = En, this.ignoreAttributesFn = tt(this.options.ignoreAttributes);
|
|
3211
3471
|
}
|
|
3212
3472
|
}
|
|
3213
|
-
function
|
|
3473
|
+
function mn(r) {
|
|
3214
3474
|
const e = Object.keys(r);
|
|
3215
3475
|
for (let t = 0; t < e.length; t++) {
|
|
3216
3476
|
const s = e[t];
|
|
@@ -3220,14 +3480,14 @@ function Kr(r) {
|
|
|
3220
3480
|
};
|
|
3221
3481
|
}
|
|
3222
3482
|
}
|
|
3223
|
-
function
|
|
3483
|
+
function bn(r, e, t, s, n, o, i) {
|
|
3224
3484
|
if (r !== void 0 && (this.options.trimValues && !s && (r = r.trim()), r.length > 0)) {
|
|
3225
3485
|
i || (r = this.replaceEntitiesValue(r));
|
|
3226
|
-
const
|
|
3227
|
-
return
|
|
3486
|
+
const c = this.options.tagValueProcessor(e, r, t, n, o);
|
|
3487
|
+
return c == null ? r : typeof c != typeof r || c !== r ? c : this.options.trimValues ? Re(r, this.options.parseTagValue, this.options.numberParseOptions) : r.trim() === r ? Re(r, this.options.parseTagValue, this.options.numberParseOptions) : r;
|
|
3228
3488
|
}
|
|
3229
3489
|
}
|
|
3230
|
-
function
|
|
3490
|
+
function yn(r) {
|
|
3231
3491
|
if (this.options.removeNSPrefix) {
|
|
3232
3492
|
const e = r.split(":"), t = r.charAt(0) === "/" ? "/" : "";
|
|
3233
3493
|
if (e[0] === "xmlns")
|
|
@@ -3236,20 +3496,20 @@ function Qr(r) {
|
|
|
3236
3496
|
}
|
|
3237
3497
|
return r;
|
|
3238
3498
|
}
|
|
3239
|
-
const
|
|
3240
|
-
function
|
|
3499
|
+
const vn = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
3500
|
+
function _n(r, e, t) {
|
|
3241
3501
|
if (this.options.ignoreAttributes !== !0 && typeof r == "string") {
|
|
3242
|
-
const s =
|
|
3502
|
+
const s = Je(r, vn), n = s.length, o = {};
|
|
3243
3503
|
for (let i = 0; i < n; i++) {
|
|
3244
|
-
const
|
|
3245
|
-
if (this.ignoreAttributesFn(
|
|
3504
|
+
const c = this.resolveNameSpace(s[i][1]);
|
|
3505
|
+
if (this.ignoreAttributesFn(c, e))
|
|
3246
3506
|
continue;
|
|
3247
|
-
let a = s[i][4], l = this.options.attributeNamePrefix +
|
|
3248
|
-
if (
|
|
3507
|
+
let a = s[i][4], l = this.options.attributeNamePrefix + c;
|
|
3508
|
+
if (c.length)
|
|
3249
3509
|
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), a !== void 0) {
|
|
3250
3510
|
this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a);
|
|
3251
|
-
const
|
|
3252
|
-
|
|
3511
|
+
const g = this.options.attributeValueProcessor(c, a, e);
|
|
3512
|
+
g == null ? o[l] = a : typeof g != typeof a || g !== a ? o[l] = g : o[l] = Re(
|
|
3253
3513
|
a,
|
|
3254
3514
|
this.options.parseAttributeValue,
|
|
3255
3515
|
this.options.numberParseOptions
|
|
@@ -3265,37 +3525,37 @@ function Yr(r, e, t) {
|
|
|
3265
3525
|
return o;
|
|
3266
3526
|
}
|
|
3267
3527
|
}
|
|
3268
|
-
const
|
|
3528
|
+
const xn = function(r) {
|
|
3269
3529
|
r = r.replace(/\r\n?/g, `
|
|
3270
3530
|
`);
|
|
3271
|
-
const e = new
|
|
3531
|
+
const e = new xe("!xml");
|
|
3272
3532
|
let t = e, s = "", n = "";
|
|
3273
|
-
const o = new
|
|
3533
|
+
const o = new on(this.options.processEntities);
|
|
3274
3534
|
for (let i = 0; i < r.length; i++)
|
|
3275
3535
|
if (r[i] === "<")
|
|
3276
3536
|
if (r[i + 1] === "/") {
|
|
3277
|
-
const a =
|
|
3537
|
+
const a = Ee(r, ">", i, "Closing Tag is not closed.");
|
|
3278
3538
|
let l = r.substring(i + 2, a).trim();
|
|
3279
3539
|
if (this.options.removeNSPrefix) {
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3540
|
+
const x = l.indexOf(":");
|
|
3541
|
+
x !== -1 && (l = l.substr(x + 1));
|
|
3282
3542
|
}
|
|
3283
3543
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && (s = this.saveTextToParentTag(s, t, n));
|
|
3284
|
-
const
|
|
3544
|
+
const g = n.substring(n.lastIndexOf(".") + 1);
|
|
3285
3545
|
if (l && this.options.unpairedTags.indexOf(l) !== -1)
|
|
3286
3546
|
throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);
|
|
3287
3547
|
let h = 0;
|
|
3288
|
-
|
|
3548
|
+
g && this.options.unpairedTags.indexOf(g) !== -1 ? (h = n.lastIndexOf(".", n.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : h = n.lastIndexOf("."), n = n.substring(0, h), t = this.tagsNodeStack.pop(), s = "", i = a;
|
|
3289
3549
|
} else if (r[i + 1] === "?") {
|
|
3290
|
-
let a =
|
|
3550
|
+
let a = Ve(r, i, !1, "?>");
|
|
3291
3551
|
if (!a) throw new Error("Pi Tag is not closed.");
|
|
3292
3552
|
if (s = this.saveTextToParentTag(s, t, n), !(this.options.ignoreDeclaration && a.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
3293
|
-
const l = new
|
|
3553
|
+
const l = new xe(a.tagName);
|
|
3294
3554
|
l.add(this.options.textNodeName, ""), a.tagName !== a.tagExp && a.attrExpPresent && (l[":@"] = this.buildAttributesMap(a.tagExp, n, a.tagName)), this.addChild(t, l, n, i);
|
|
3295
3555
|
}
|
|
3296
3556
|
i = a.closeIndex + 1;
|
|
3297
3557
|
} else if (r.substr(i + 1, 3) === "!--") {
|
|
3298
|
-
const a =
|
|
3558
|
+
const a = Ee(r, "-->", i + 4, "Comment is not closed.");
|
|
3299
3559
|
if (this.options.commentPropName) {
|
|
3300
3560
|
const l = r.substring(i + 4, a - 2);
|
|
3301
3561
|
s = this.saveTextToParentTag(s, t, n), t.add(this.options.commentPropName, [{ [this.options.textNodeName]: l }]);
|
|
@@ -3305,53 +3565,53 @@ const Gr = function(r) {
|
|
|
3305
3565
|
const a = o.readDocType(r, i);
|
|
3306
3566
|
this.docTypeEntities = a.entities, i = a.i;
|
|
3307
3567
|
} else if (r.substr(i + 1, 2) === "![") {
|
|
3308
|
-
const a =
|
|
3568
|
+
const a = Ee(r, "]]>", i, "CDATA is not closed.") - 2, l = r.substring(i + 9, a);
|
|
3309
3569
|
s = this.saveTextToParentTag(s, t, n);
|
|
3310
|
-
let
|
|
3311
|
-
|
|
3570
|
+
let g = this.parseTextData(l, t.tagname, n, !0, !1, !0, !0);
|
|
3571
|
+
g == null && (g = ""), this.options.cdataPropName ? t.add(this.options.cdataPropName, [{ [this.options.textNodeName]: l }]) : t.add(this.options.textNodeName, g), i = a + 2;
|
|
3312
3572
|
} else {
|
|
3313
|
-
let a =
|
|
3314
|
-
const
|
|
3315
|
-
let h = a.tagExp,
|
|
3573
|
+
let a = Ve(r, i, this.options.removeNSPrefix), l = a.tagName;
|
|
3574
|
+
const g = a.rawTagName;
|
|
3575
|
+
let h = a.tagExp, x = a.attrExpPresent, v = a.closeIndex;
|
|
3316
3576
|
this.options.transformTagName && (l = this.options.transformTagName(l)), t && s && t.tagname !== "!xml" && (s = this.saveTextToParentTag(s, t, n, !1));
|
|
3317
|
-
const
|
|
3318
|
-
|
|
3319
|
-
const
|
|
3577
|
+
const B = t;
|
|
3578
|
+
B && this.options.unpairedTags.indexOf(B.tagname) !== -1 && (t = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), l !== e.tagname && (n += n ? "." + l : l);
|
|
3579
|
+
const S = i;
|
|
3320
3580
|
if (this.isItStopNode(this.options.stopNodes, n, l)) {
|
|
3321
|
-
let
|
|
3581
|
+
let _ = "";
|
|
3322
3582
|
if (h.length > 0 && h.lastIndexOf("/") === h.length - 1)
|
|
3323
3583
|
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), n = n.substr(0, n.length - 1), h = l) : h = h.substr(0, h.length - 1), i = a.closeIndex;
|
|
3324
3584
|
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
3325
3585
|
i = a.closeIndex;
|
|
3326
3586
|
else {
|
|
3327
|
-
const
|
|
3328
|
-
if (!
|
|
3329
|
-
i =
|
|
3587
|
+
const Y = this.readStopNodeData(r, g, v + 1);
|
|
3588
|
+
if (!Y) throw new Error(`Unexpected end of ${g}`);
|
|
3589
|
+
i = Y.i, _ = Y.tagContent;
|
|
3330
3590
|
}
|
|
3331
|
-
const
|
|
3332
|
-
l !== h &&
|
|
3591
|
+
const j = new xe(l);
|
|
3592
|
+
l !== h && x && (j[":@"] = this.buildAttributesMap(h, n, l)), _ && (_ = this.parseTextData(_, l, n, !0, x, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), j.add(this.options.textNodeName, _), this.addChild(t, j, n, S);
|
|
3333
3593
|
} else {
|
|
3334
3594
|
if (h.length > 0 && h.lastIndexOf("/") === h.length - 1) {
|
|
3335
3595
|
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), n = n.substr(0, n.length - 1), h = l) : h = h.substr(0, h.length - 1), this.options.transformTagName && (l = this.options.transformTagName(l));
|
|
3336
|
-
const
|
|
3337
|
-
l !== h &&
|
|
3596
|
+
const _ = new xe(l);
|
|
3597
|
+
l !== h && x && (_[":@"] = this.buildAttributesMap(h, n, l)), this.addChild(t, _, n, S), n = n.substr(0, n.lastIndexOf("."));
|
|
3338
3598
|
} else {
|
|
3339
|
-
const
|
|
3340
|
-
this.tagsNodeStack.push(t), l !== h &&
|
|
3599
|
+
const _ = new xe(l);
|
|
3600
|
+
this.tagsNodeStack.push(t), l !== h && x && (_[":@"] = this.buildAttributesMap(h, n, l)), this.addChild(t, _, n, S), t = _;
|
|
3341
3601
|
}
|
|
3342
|
-
s = "", i =
|
|
3602
|
+
s = "", i = v;
|
|
3343
3603
|
}
|
|
3344
3604
|
}
|
|
3345
3605
|
else
|
|
3346
3606
|
s += r[i];
|
|
3347
3607
|
return e.child;
|
|
3348
3608
|
};
|
|
3349
|
-
function
|
|
3609
|
+
function En(r, e, t, s) {
|
|
3350
3610
|
this.options.captureMetaData || (s = void 0);
|
|
3351
3611
|
const n = this.options.updateTag(e.tagname, t, e[":@"]);
|
|
3352
3612
|
n === !1 || (typeof n == "string" && (e.tagname = n), r.addChild(e, s));
|
|
3353
3613
|
}
|
|
3354
|
-
const
|
|
3614
|
+
const kn = function(r) {
|
|
3355
3615
|
if (this.options.processEntities) {
|
|
3356
3616
|
for (let e in this.docTypeEntities) {
|
|
3357
3617
|
const t = this.docTypeEntities[e];
|
|
@@ -3370,7 +3630,7 @@ const zr = function(r) {
|
|
|
3370
3630
|
}
|
|
3371
3631
|
return r;
|
|
3372
3632
|
};
|
|
3373
|
-
function
|
|
3633
|
+
function An(r, e, t, s) {
|
|
3374
3634
|
return r && (s === void 0 && (s = e.child.length === 0), r = this.parseTextData(
|
|
3375
3635
|
r,
|
|
3376
3636
|
e.tagname,
|
|
@@ -3380,7 +3640,7 @@ function Dr(r, e, t, s) {
|
|
|
3380
3640
|
s
|
|
3381
3641
|
), r !== void 0 && r !== "" && e.add(this.options.textNodeName, r), r = ""), r;
|
|
3382
3642
|
}
|
|
3383
|
-
function
|
|
3643
|
+
function wn(r, e, t) {
|
|
3384
3644
|
const s = "*." + t;
|
|
3385
3645
|
for (const n in r) {
|
|
3386
3646
|
const o = r[n];
|
|
@@ -3388,7 +3648,7 @@ function Jr(r, e, t) {
|
|
|
3388
3648
|
}
|
|
3389
3649
|
return !1;
|
|
3390
3650
|
}
|
|
3391
|
-
function
|
|
3651
|
+
function Nn(r, e, t = ">") {
|
|
3392
3652
|
let s, n = "";
|
|
3393
3653
|
for (let o = e; o < r.length; o++) {
|
|
3394
3654
|
let i = r[o];
|
|
@@ -3412,20 +3672,20 @@ function en(r, e, t = ">") {
|
|
|
3412
3672
|
n += i;
|
|
3413
3673
|
}
|
|
3414
3674
|
}
|
|
3415
|
-
function
|
|
3675
|
+
function Ee(r, e, t, s) {
|
|
3416
3676
|
const n = r.indexOf(e, t);
|
|
3417
3677
|
if (n === -1)
|
|
3418
3678
|
throw new Error(s);
|
|
3419
3679
|
return n + e.length - 1;
|
|
3420
3680
|
}
|
|
3421
|
-
function
|
|
3422
|
-
const n =
|
|
3681
|
+
function Ve(r, e, t, s = ">") {
|
|
3682
|
+
const n = Nn(r, e + 1, s);
|
|
3423
3683
|
if (!n) return;
|
|
3424
3684
|
let o = n.data;
|
|
3425
|
-
const i = n.index,
|
|
3685
|
+
const i = n.index, c = o.search(/\s/);
|
|
3426
3686
|
let a = o, l = !0;
|
|
3427
|
-
|
|
3428
|
-
const
|
|
3687
|
+
c !== -1 && (a = o.substring(0, c), o = o.substring(c + 1).trimStart());
|
|
3688
|
+
const g = a;
|
|
3429
3689
|
if (t) {
|
|
3430
3690
|
const h = a.indexOf(":");
|
|
3431
3691
|
h !== -1 && (a = a.substr(h + 1), l = a !== n.data.substr(h + 1));
|
|
@@ -3435,16 +3695,16 @@ function we(r, e, t, s = ">") {
|
|
|
3435
3695
|
tagExp: o,
|
|
3436
3696
|
closeIndex: i,
|
|
3437
3697
|
attrExpPresent: l,
|
|
3438
|
-
rawTagName:
|
|
3698
|
+
rawTagName: g
|
|
3439
3699
|
};
|
|
3440
3700
|
}
|
|
3441
|
-
function
|
|
3701
|
+
function Cn(r, e, t) {
|
|
3442
3702
|
const s = t;
|
|
3443
3703
|
let n = 1;
|
|
3444
3704
|
for (; t < r.length; t++)
|
|
3445
3705
|
if (r[t] === "<")
|
|
3446
3706
|
if (r[t + 1] === "/") {
|
|
3447
|
-
const o =
|
|
3707
|
+
const o = Ee(r, ">", t, `${e} is not closed`);
|
|
3448
3708
|
if (r.substring(t + 2, o).trim() === e && (n--, n === 0))
|
|
3449
3709
|
return {
|
|
3450
3710
|
tagContent: r.substring(s, t),
|
|
@@ -3452,70 +3712,70 @@ function tn(r, e, t) {
|
|
|
3452
3712
|
};
|
|
3453
3713
|
t = o;
|
|
3454
3714
|
} else if (r[t + 1] === "?")
|
|
3455
|
-
t =
|
|
3715
|
+
t = Ee(r, "?>", t + 1, "StopNode is not closed.");
|
|
3456
3716
|
else if (r.substr(t + 1, 3) === "!--")
|
|
3457
|
-
t =
|
|
3717
|
+
t = Ee(r, "-->", t + 3, "StopNode is not closed.");
|
|
3458
3718
|
else if (r.substr(t + 1, 2) === "![")
|
|
3459
|
-
t =
|
|
3719
|
+
t = Ee(r, "]]>", t, "StopNode is not closed.") - 2;
|
|
3460
3720
|
else {
|
|
3461
|
-
const o =
|
|
3721
|
+
const o = Ve(r, t, ">");
|
|
3462
3722
|
o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && n++, t = o.closeIndex);
|
|
3463
3723
|
}
|
|
3464
3724
|
}
|
|
3465
|
-
function
|
|
3725
|
+
function Re(r, e, t) {
|
|
3466
3726
|
if (e && typeof r == "string") {
|
|
3467
3727
|
const s = r.trim();
|
|
3468
|
-
return s === "true" ? !0 : s === "false" ? !1 :
|
|
3728
|
+
return s === "true" ? !0 : s === "false" ? !1 : un(r, t);
|
|
3469
3729
|
} else
|
|
3470
|
-
return
|
|
3730
|
+
return Qr(r) ? r : "";
|
|
3471
3731
|
}
|
|
3472
|
-
const
|
|
3473
|
-
function
|
|
3474
|
-
return
|
|
3732
|
+
const Se = xe.getMetaDataSymbol();
|
|
3733
|
+
function Tn(r, e) {
|
|
3734
|
+
return rt(r, e);
|
|
3475
3735
|
}
|
|
3476
|
-
function
|
|
3736
|
+
function rt(r, e, t) {
|
|
3477
3737
|
let s;
|
|
3478
3738
|
const n = {};
|
|
3479
3739
|
for (let o = 0; o < r.length; o++) {
|
|
3480
|
-
const i = r[o],
|
|
3740
|
+
const i = r[o], c = On(i);
|
|
3481
3741
|
let a = "";
|
|
3482
|
-
if (t === void 0 ? a =
|
|
3483
|
-
s === void 0 ? s = i[
|
|
3742
|
+
if (t === void 0 ? a = c : a = t + "." + c, c === e.textNodeName)
|
|
3743
|
+
s === void 0 ? s = i[c] : s += "" + i[c];
|
|
3484
3744
|
else {
|
|
3485
|
-
if (
|
|
3745
|
+
if (c === void 0)
|
|
3486
3746
|
continue;
|
|
3487
|
-
if (i[
|
|
3488
|
-
let l =
|
|
3489
|
-
const
|
|
3490
|
-
i[
|
|
3747
|
+
if (i[c]) {
|
|
3748
|
+
let l = rt(i[c], e, a);
|
|
3749
|
+
const g = Pn(l, e);
|
|
3750
|
+
i[Se] !== void 0 && (l[Se] = i[Se]), i[":@"] ? $n(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[c] !== void 0 && n.hasOwnProperty(c) ? (Array.isArray(n[c]) || (n[c] = [n[c]]), n[c].push(l)) : e.isArray(c, a, g) ? n[c] = [l] : n[c] = l;
|
|
3491
3751
|
}
|
|
3492
3752
|
}
|
|
3493
3753
|
}
|
|
3494
3754
|
return typeof s == "string" ? s.length > 0 && (n[e.textNodeName] = s) : s !== void 0 && (n[e.textNodeName] = s), n;
|
|
3495
3755
|
}
|
|
3496
|
-
function
|
|
3756
|
+
function On(r) {
|
|
3497
3757
|
const e = Object.keys(r);
|
|
3498
3758
|
for (let t = 0; t < e.length; t++) {
|
|
3499
3759
|
const s = e[t];
|
|
3500
3760
|
if (s !== ":@") return s;
|
|
3501
3761
|
}
|
|
3502
3762
|
}
|
|
3503
|
-
function
|
|
3763
|
+
function $n(r, e, t, s) {
|
|
3504
3764
|
if (e) {
|
|
3505
3765
|
const n = Object.keys(e), o = n.length;
|
|
3506
3766
|
for (let i = 0; i < o; i++) {
|
|
3507
|
-
const
|
|
3508
|
-
s.isArray(
|
|
3767
|
+
const c = n[i];
|
|
3768
|
+
s.isArray(c, t + "." + c, !0, !0) ? r[c] = [e[c]] : r[c] = e[c];
|
|
3509
3769
|
}
|
|
3510
3770
|
}
|
|
3511
3771
|
}
|
|
3512
|
-
function
|
|
3772
|
+
function Pn(r, e) {
|
|
3513
3773
|
const { textNodeName: t } = e, s = Object.keys(r).length;
|
|
3514
3774
|
return !!(s === 0 || s === 1 && (r[t] || typeof r[t] == "boolean" || r[t] === 0));
|
|
3515
3775
|
}
|
|
3516
|
-
class
|
|
3776
|
+
class Bn {
|
|
3517
3777
|
constructor(e) {
|
|
3518
|
-
this.externalEntities = {}, this.options =
|
|
3778
|
+
this.externalEntities = {}, this.options = sn(e);
|
|
3519
3779
|
}
|
|
3520
3780
|
/**
|
|
3521
3781
|
* Parse XML dats to JS object
|
|
@@ -3529,14 +3789,14 @@ class an {
|
|
|
3529
3789
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
3530
3790
|
if (t) {
|
|
3531
3791
|
t === !0 && (t = {});
|
|
3532
|
-
const o =
|
|
3792
|
+
const o = et(e, t);
|
|
3533
3793
|
if (o !== !0)
|
|
3534
3794
|
throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
|
|
3535
3795
|
}
|
|
3536
|
-
const s = new
|
|
3796
|
+
const s = new gn(this.options);
|
|
3537
3797
|
s.addExternalEntities(this.externalEntities);
|
|
3538
3798
|
const n = s.parseXml(e);
|
|
3539
|
-
return this.options.preserveOrder || n === void 0 ? n :
|
|
3799
|
+
return this.options.preserveOrder || n === void 0 ? n : Tn(n, this.options);
|
|
3540
3800
|
}
|
|
3541
3801
|
/**
|
|
3542
3802
|
* Add Entity which is not by default supported by this library
|
|
@@ -3563,45 +3823,45 @@ class an {
|
|
|
3563
3823
|
* is true in the options.
|
|
3564
3824
|
*/
|
|
3565
3825
|
static getMetaDataSymbol() {
|
|
3566
|
-
return
|
|
3826
|
+
return xe.getMetaDataSymbol();
|
|
3567
3827
|
}
|
|
3568
3828
|
}
|
|
3569
|
-
const
|
|
3829
|
+
const Sn = `
|
|
3570
3830
|
`;
|
|
3571
|
-
function
|
|
3831
|
+
function In(r, e) {
|
|
3572
3832
|
let t = "";
|
|
3573
|
-
return e.format && e.indentBy.length > 0 && (t =
|
|
3833
|
+
return e.format && e.indentBy.length > 0 && (t = Sn), nt(r, e, "", t);
|
|
3574
3834
|
}
|
|
3575
|
-
function
|
|
3835
|
+
function nt(r, e, t, s) {
|
|
3576
3836
|
let n = "", o = !1;
|
|
3577
3837
|
for (let i = 0; i < r.length; i++) {
|
|
3578
|
-
const
|
|
3838
|
+
const c = r[i], a = Vn(c);
|
|
3579
3839
|
if (a === void 0) continue;
|
|
3580
3840
|
let l = "";
|
|
3581
3841
|
if (t.length === 0 ? l = a : l = `${t}.${a}`, a === e.textNodeName) {
|
|
3582
|
-
let
|
|
3583
|
-
|
|
3842
|
+
let B = c[a];
|
|
3843
|
+
Rn(l, e) || (B = e.tagValueProcessor(a, B), B = st(B, e)), o && (n += s), n += B, o = !1;
|
|
3584
3844
|
continue;
|
|
3585
3845
|
} else if (a === e.cdataPropName) {
|
|
3586
|
-
o && (n += s), n += `<![CDATA[${
|
|
3846
|
+
o && (n += s), n += `<![CDATA[${c[a][0][e.textNodeName]}]]>`, o = !1;
|
|
3587
3847
|
continue;
|
|
3588
3848
|
} else if (a === e.commentPropName) {
|
|
3589
|
-
n += s + `<!--${
|
|
3849
|
+
n += s + `<!--${c[a][0][e.textNodeName]}-->`, o = !0;
|
|
3590
3850
|
continue;
|
|
3591
3851
|
} else if (a[0] === "?") {
|
|
3592
|
-
const
|
|
3593
|
-
let
|
|
3594
|
-
|
|
3852
|
+
const B = We(c[":@"], e), S = a === "?xml" ? "" : s;
|
|
3853
|
+
let _ = c[a][0][e.textNodeName];
|
|
3854
|
+
_ = _.length !== 0 ? " " + _ : "", n += S + `<${a}${_}${B}?>`, o = !0;
|
|
3595
3855
|
continue;
|
|
3596
3856
|
}
|
|
3597
|
-
let
|
|
3598
|
-
|
|
3599
|
-
const h =
|
|
3600
|
-
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n +=
|
|
3857
|
+
let g = s;
|
|
3858
|
+
g !== "" && (g += e.indentBy);
|
|
3859
|
+
const h = We(c[":@"], e), x = s + `<${a}${h}`, v = nt(c[a], e, l, g);
|
|
3860
|
+
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n += x + ">" : n += x + "/>" : (!v || v.length === 0) && e.suppressEmptyNode ? n += x + "/>" : v && v.endsWith(">") ? n += x + `>${v}${s}</${a}>` : (n += x + ">", v && s !== "" && (v.includes("/>") || v.includes("</")) ? n += s + e.indentBy + v + s : n += v, n += `</${a}>`), o = !0;
|
|
3601
3861
|
}
|
|
3602
3862
|
return n;
|
|
3603
3863
|
}
|
|
3604
|
-
function
|
|
3864
|
+
function Vn(r) {
|
|
3605
3865
|
const e = Object.keys(r);
|
|
3606
3866
|
for (let t = 0; t < e.length; t++) {
|
|
3607
3867
|
const s = e[t];
|
|
@@ -3609,24 +3869,24 @@ function cn(r) {
|
|
|
3609
3869
|
return s;
|
|
3610
3870
|
}
|
|
3611
3871
|
}
|
|
3612
|
-
function
|
|
3872
|
+
function We(r, e) {
|
|
3613
3873
|
let t = "";
|
|
3614
3874
|
if (r && !e.ignoreAttributes)
|
|
3615
3875
|
for (let s in r) {
|
|
3616
3876
|
if (!r.hasOwnProperty(s)) continue;
|
|
3617
3877
|
let n = e.attributeValueProcessor(s, r[s]);
|
|
3618
|
-
n =
|
|
3878
|
+
n = st(n, e), n === !0 && e.suppressBooleanAttributes ? t += ` ${s.substr(e.attributeNamePrefix.length)}` : t += ` ${s.substr(e.attributeNamePrefix.length)}="${n}"`;
|
|
3619
3879
|
}
|
|
3620
3880
|
return t;
|
|
3621
3881
|
}
|
|
3622
|
-
function
|
|
3882
|
+
function Rn(r, e) {
|
|
3623
3883
|
r = r.substr(0, r.length - e.textNodeName.length - 1);
|
|
3624
3884
|
let t = r.substr(r.lastIndexOf(".") + 1);
|
|
3625
3885
|
for (let s in e.stopNodes)
|
|
3626
3886
|
if (e.stopNodes[s] === r || e.stopNodes[s] === "*." + t) return !0;
|
|
3627
3887
|
return !1;
|
|
3628
3888
|
}
|
|
3629
|
-
function
|
|
3889
|
+
function st(r, e) {
|
|
3630
3890
|
if (r && r.length > 0 && e.processEntities)
|
|
3631
3891
|
for (let t = 0; t < e.entities.length; t++) {
|
|
3632
3892
|
const s = e.entities[t];
|
|
@@ -3634,7 +3894,7 @@ function Ze(r, e) {
|
|
|
3634
3894
|
}
|
|
3635
3895
|
return r;
|
|
3636
3896
|
}
|
|
3637
|
-
const
|
|
3897
|
+
const Ln = {
|
|
3638
3898
|
attributeNamePrefix: "@_",
|
|
3639
3899
|
attributesGroupName: !1,
|
|
3640
3900
|
textNodeName: "#text",
|
|
@@ -3668,21 +3928,21 @@ const fn = {
|
|
|
3668
3928
|
// transformAttributeName: false,
|
|
3669
3929
|
oneListGroup: !1
|
|
3670
3930
|
};
|
|
3671
|
-
function
|
|
3672
|
-
this.options = Object.assign({},
|
|
3931
|
+
function me(r) {
|
|
3932
|
+
this.options = Object.assign({}, Ln, r), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
3673
3933
|
return !1;
|
|
3674
|
-
} : (this.ignoreAttributesFn =
|
|
3934
|
+
} : (this.ignoreAttributesFn = tt(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Mn), this.processTextOrObjNode = jn, this.options.format ? (this.indentate = Un, this.tagEndChar = `>
|
|
3675
3935
|
`, this.newLine = `
|
|
3676
3936
|
`) : (this.indentate = function() {
|
|
3677
3937
|
return "";
|
|
3678
3938
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
3679
3939
|
}
|
|
3680
|
-
|
|
3681
|
-
return this.options.preserveOrder ?
|
|
3940
|
+
me.prototype.build = function(r) {
|
|
3941
|
+
return this.options.preserveOrder ? In(r, this.options) : (Array.isArray(r) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (r = {
|
|
3682
3942
|
[this.options.arrayNodeName]: r
|
|
3683
3943
|
}), this.j2x(r, 0, []).val);
|
|
3684
3944
|
};
|
|
3685
|
-
|
|
3945
|
+
me.prototype.j2x = function(r, e, t) {
|
|
3686
3946
|
let s = "", n = "";
|
|
3687
3947
|
const o = t.join(".");
|
|
3688
3948
|
for (let i in r)
|
|
@@ -3694,51 +3954,51 @@ se.prototype.j2x = function(r, e, t) {
|
|
|
3694
3954
|
else if (r[i] instanceof Date)
|
|
3695
3955
|
n += this.buildTextValNode(r[i], i, "", e);
|
|
3696
3956
|
else if (typeof r[i] != "object") {
|
|
3697
|
-
const
|
|
3698
|
-
if (
|
|
3699
|
-
s += this.buildAttrPairStr(
|
|
3700
|
-
else if (!
|
|
3957
|
+
const c = this.isAttribute(i);
|
|
3958
|
+
if (c && !this.ignoreAttributesFn(c, o))
|
|
3959
|
+
s += this.buildAttrPairStr(c, "" + r[i]);
|
|
3960
|
+
else if (!c)
|
|
3701
3961
|
if (i === this.options.textNodeName) {
|
|
3702
3962
|
let a = this.options.tagValueProcessor(i, "" + r[i]);
|
|
3703
3963
|
n += this.replaceEntitiesValue(a);
|
|
3704
3964
|
} else
|
|
3705
3965
|
n += this.buildTextValNode(r[i], i, "", e);
|
|
3706
3966
|
} else if (Array.isArray(r[i])) {
|
|
3707
|
-
const
|
|
3967
|
+
const c = r[i].length;
|
|
3708
3968
|
let a = "", l = "";
|
|
3709
|
-
for (let
|
|
3710
|
-
const h = r[i][
|
|
3969
|
+
for (let g = 0; g < c; g++) {
|
|
3970
|
+
const h = r[i][g];
|
|
3711
3971
|
if (!(typeof h > "u")) if (h === null)
|
|
3712
3972
|
i[0] === "?" ? n += this.indentate(e) + "<" + i + "?" + this.tagEndChar : n += this.indentate(e) + "<" + i + "/" + this.tagEndChar;
|
|
3713
3973
|
else if (typeof h == "object")
|
|
3714
3974
|
if (this.options.oneListGroup) {
|
|
3715
|
-
const
|
|
3716
|
-
a +=
|
|
3975
|
+
const x = this.j2x(h, e + 1, t.concat(i));
|
|
3976
|
+
a += x.val, this.options.attributesGroupName && h.hasOwnProperty(this.options.attributesGroupName) && (l += x.attrStr);
|
|
3717
3977
|
} else
|
|
3718
3978
|
a += this.processTextOrObjNode(h, i, e, t);
|
|
3719
3979
|
else if (this.options.oneListGroup) {
|
|
3720
|
-
let
|
|
3721
|
-
|
|
3980
|
+
let x = this.options.tagValueProcessor(i, h);
|
|
3981
|
+
x = this.replaceEntitiesValue(x), a += x;
|
|
3722
3982
|
} else
|
|
3723
3983
|
a += this.buildTextValNode(h, i, "", e);
|
|
3724
3984
|
}
|
|
3725
3985
|
this.options.oneListGroup && (a = this.buildObjectNode(a, i, l, e)), n += a;
|
|
3726
3986
|
} else if (this.options.attributesGroupName && i === this.options.attributesGroupName) {
|
|
3727
|
-
const
|
|
3987
|
+
const c = Object.keys(r[i]), a = c.length;
|
|
3728
3988
|
for (let l = 0; l < a; l++)
|
|
3729
|
-
s += this.buildAttrPairStr(
|
|
3989
|
+
s += this.buildAttrPairStr(c[l], "" + r[i][c[l]]);
|
|
3730
3990
|
} else
|
|
3731
3991
|
n += this.processTextOrObjNode(r[i], i, e, t);
|
|
3732
3992
|
return { attrStr: s, val: n };
|
|
3733
3993
|
};
|
|
3734
|
-
|
|
3994
|
+
me.prototype.buildAttrPairStr = function(r, e) {
|
|
3735
3995
|
return e = this.options.attributeValueProcessor(r, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + r : " " + r + '="' + e + '"';
|
|
3736
3996
|
};
|
|
3737
|
-
function
|
|
3997
|
+
function jn(r, e, t, s) {
|
|
3738
3998
|
const n = this.j2x(r, t + 1, s.concat(e));
|
|
3739
3999
|
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);
|
|
3740
4000
|
}
|
|
3741
|
-
|
|
4001
|
+
me.prototype.buildObjectNode = function(r, e, t, s) {
|
|
3742
4002
|
if (r === "")
|
|
3743
4003
|
return e[0] === "?" ? this.indentate(s) + "<" + e + t + "?" + this.tagEndChar : this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar;
|
|
3744
4004
|
{
|
|
@@ -3746,11 +4006,11 @@ se.prototype.buildObjectNode = function(r, e, t, s) {
|
|
|
3746
4006
|
return e[0] === "?" && (o = "?", n = ""), (t || t === "") && r.indexOf("<") === -1 ? this.indentate(s) + "<" + e + t + o + ">" + r + n : this.options.commentPropName !== !1 && e === this.options.commentPropName && o.length === 0 ? this.indentate(s) + `<!--${r}-->` + this.newLine : this.indentate(s) + "<" + e + t + o + this.tagEndChar + r + this.indentate(s) + n;
|
|
3747
4007
|
}
|
|
3748
4008
|
};
|
|
3749
|
-
|
|
4009
|
+
me.prototype.closeTag = function(r) {
|
|
3750
4010
|
let e = "";
|
|
3751
4011
|
return this.options.unpairedTags.indexOf(r) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${r}`, e;
|
|
3752
4012
|
};
|
|
3753
|
-
|
|
4013
|
+
me.prototype.buildTextValNode = function(r, e, t, s) {
|
|
3754
4014
|
if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
|
|
3755
4015
|
return this.indentate(s) + `<![CDATA[${r}]]>` + this.newLine;
|
|
3756
4016
|
if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
|
|
@@ -3762,7 +4022,7 @@ se.prototype.buildTextValNode = function(r, e, t, s) {
|
|
|
3762
4022
|
return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar : this.indentate(s) + "<" + e + t + ">" + n + "</" + e + this.tagEndChar;
|
|
3763
4023
|
}
|
|
3764
4024
|
};
|
|
3765
|
-
|
|
4025
|
+
me.prototype.replaceEntitiesValue = function(r) {
|
|
3766
4026
|
if (r && r.length > 0 && this.options.processEntities)
|
|
3767
4027
|
for (let e = 0; e < this.options.entities.length; e++) {
|
|
3768
4028
|
const t = this.options.entities[e];
|
|
@@ -3770,15 +4030,15 @@ se.prototype.replaceEntitiesValue = function(r) {
|
|
|
3770
4030
|
}
|
|
3771
4031
|
return r;
|
|
3772
4032
|
};
|
|
3773
|
-
function
|
|
4033
|
+
function Un(r) {
|
|
3774
4034
|
return this.options.indentBy.repeat(r);
|
|
3775
4035
|
}
|
|
3776
|
-
function
|
|
4036
|
+
function Mn(r) {
|
|
3777
4037
|
return r.startsWith(this.options.attributeNamePrefix) && r !== this.options.textNodeName ? r.substr(this.attrPrefixLen) : !1;
|
|
3778
4038
|
}
|
|
3779
|
-
const
|
|
3780
|
-
validate:
|
|
3781
|
-
},
|
|
4039
|
+
const Fn = {
|
|
4040
|
+
validate: et
|
|
4041
|
+
}, Kn = {
|
|
3782
4042
|
ignoreAttributes: !1,
|
|
3783
4043
|
// 保留属性
|
|
3784
4044
|
attributeNamePrefix: "@_",
|
|
@@ -3813,7 +4073,7 @@ const mn = {
|
|
|
3813
4073
|
// 停止解析的节点
|
|
3814
4074
|
alwaysCreateTextNode: !1
|
|
3815
4075
|
// 仅在有文本时创建文本节点
|
|
3816
|
-
},
|
|
4076
|
+
}, Xn = {
|
|
3817
4077
|
ignoreAttributes: !1,
|
|
3818
4078
|
attributeNamePrefix: "@_",
|
|
3819
4079
|
textNodeName: "#text",
|
|
@@ -3825,9 +4085,9 @@ const mn = {
|
|
|
3825
4085
|
// 不抑制空节点
|
|
3826
4086
|
suppressBooleanAttributes: !1,
|
|
3827
4087
|
suppressUnpairedNode: !1
|
|
3828
|
-
},
|
|
4088
|
+
}, Hn = (r) => {
|
|
3829
4089
|
try {
|
|
3830
|
-
const e =
|
|
4090
|
+
const e = Fn.validate(r, {
|
|
3831
4091
|
allowBooleanAttributes: !0
|
|
3832
4092
|
});
|
|
3833
4093
|
return e === !0 ? { valid: !0 } : {
|
|
@@ -3840,10 +4100,10 @@ const mn = {
|
|
|
3840
4100
|
error: e instanceof Error ? e.message : "Unknown validation error"
|
|
3841
4101
|
};
|
|
3842
4102
|
}
|
|
3843
|
-
},
|
|
4103
|
+
}, ot = (r, e) => {
|
|
3844
4104
|
try {
|
|
3845
|
-
return new
|
|
3846
|
-
...
|
|
4105
|
+
return new Bn({
|
|
4106
|
+
...Kn,
|
|
3847
4107
|
...e
|
|
3848
4108
|
}).parse(r);
|
|
3849
4109
|
} catch (t) {
|
|
@@ -3851,10 +4111,10 @@ const mn = {
|
|
|
3851
4111
|
`XML 解析失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3852
4112
|
);
|
|
3853
4113
|
}
|
|
3854
|
-
},
|
|
4114
|
+
}, Ue = (r, e) => {
|
|
3855
4115
|
try {
|
|
3856
|
-
let s = new
|
|
3857
|
-
...
|
|
4116
|
+
let s = new me({
|
|
4117
|
+
...Xn,
|
|
3858
4118
|
format: e?.format ?? !0,
|
|
3859
4119
|
indentBy: e?.indentBy ?? " "
|
|
3860
4120
|
}).build(r);
|
|
@@ -3865,66 +4125,66 @@ const mn = {
|
|
|
3865
4125
|
`XML 构建失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3866
4126
|
);
|
|
3867
4127
|
}
|
|
3868
|
-
},
|
|
3869
|
-
const t =
|
|
3870
|
-
return Array.isArray(t) ?
|
|
4128
|
+
}, qn = (r) => Array.isArray(r) ? ge(r, { format: !1 }) : Ue(r, { format: !1, showDeclaration: !1 }), Wn = (r, e) => {
|
|
4129
|
+
const t = ot(r);
|
|
4130
|
+
return Array.isArray(t) ? ge(t, {
|
|
3871
4131
|
indent: e?.indentBy
|
|
3872
|
-
}) :
|
|
3873
|
-
},
|
|
4132
|
+
}) : Ue(t, e);
|
|
4133
|
+
}, ge = (r, e = {}) => {
|
|
3874
4134
|
const t = e.indent !== void 0 ? e.indent : " ", s = e.level || 0, n = e.format !== !1, o = n ? t.repeat(s) : "", i = n ? `
|
|
3875
4135
|
` : "";
|
|
3876
|
-
let
|
|
4136
|
+
let c = "";
|
|
3877
4137
|
for (const a of r) {
|
|
3878
4138
|
if (a["?xml"]) {
|
|
3879
|
-
const
|
|
3880
|
-
|
|
4139
|
+
const _ = a[":@"] || {}, j = Object.entries(_).map(([Y, J]) => `${Y.startsWith("@_") ? Y.substring(2) : Y}="${J}"`).join(" ");
|
|
4140
|
+
c += `<?xml ${j}?>${i}`;
|
|
3881
4141
|
continue;
|
|
3882
4142
|
}
|
|
3883
4143
|
if (a["#comment"]) {
|
|
3884
|
-
const
|
|
3885
|
-
if (Array.isArray(
|
|
3886
|
-
const
|
|
3887
|
-
|
|
4144
|
+
const _ = a["#comment"];
|
|
4145
|
+
if (Array.isArray(_) && _.length > 0) {
|
|
4146
|
+
const j = _[0]["#text"] || _[0];
|
|
4147
|
+
c += `${o}<!--${j}-->${i}`;
|
|
3888
4148
|
}
|
|
3889
4149
|
continue;
|
|
3890
4150
|
}
|
|
3891
|
-
const l = Object.keys(a).find((
|
|
4151
|
+
const l = Object.keys(a).find((_) => !_.startsWith(":") && !_.startsWith("#") && !_.startsWith("__"));
|
|
3892
4152
|
if (!l) continue;
|
|
3893
|
-
const
|
|
3894
|
-
if (!Array.isArray(
|
|
3895
|
-
|
|
4153
|
+
const g = a[l], h = a[":@"] || {}, x = Object.entries(h).map(([_, j]) => `${_.startsWith("@_") ? _.substring(2) : _}="${j}"`).join(" "), v = x ? " " + x : "";
|
|
4154
|
+
if (!Array.isArray(g) || g.length === 0) {
|
|
4155
|
+
c += `${o}<${l}${v}/>${i}`;
|
|
3896
4156
|
continue;
|
|
3897
4157
|
}
|
|
3898
|
-
const
|
|
3899
|
-
if (
|
|
3900
|
-
const
|
|
3901
|
-
if (
|
|
3902
|
-
const
|
|
3903
|
-
|
|
4158
|
+
const B = g.length === 1 && g[0]["#text"] !== void 0;
|
|
4159
|
+
if (g.some((_) => _.__cdata)) {
|
|
4160
|
+
const _ = g.find((j) => j.__cdata);
|
|
4161
|
+
if (_) {
|
|
4162
|
+
const j = _.__cdata[0]["#text"] || "";
|
|
4163
|
+
c += `${o}<${l}${v}><![CDATA[${j}]]></${l}>${i}`;
|
|
3904
4164
|
}
|
|
3905
|
-
} else if (
|
|
3906
|
-
const
|
|
3907
|
-
|
|
4165
|
+
} else if (B) {
|
|
4166
|
+
const _ = g[0]["#text"];
|
|
4167
|
+
c += `${o}<${l}${v}>${_}</${l}>${i}`;
|
|
3908
4168
|
} else
|
|
3909
|
-
|
|
4169
|
+
c += `${o}<${l}${v}>${i}`, c += ge(g, { indent: t, level: s + 1, format: n }), c += `${o}</${l}>${i}`;
|
|
3910
4170
|
}
|
|
3911
|
-
return
|
|
3912
|
-
},
|
|
4171
|
+
return c;
|
|
4172
|
+
}, Qn = {
|
|
3913
4173
|
key: 0,
|
|
3914
4174
|
class: "xml-format__toolbar"
|
|
3915
|
-
},
|
|
4175
|
+
}, Yn = { class: "xml-format__actions" }, Gn = ["disabled"], Zn = ["disabled"], zn = ["disabled"], Dn = ["disabled"], Jn = ["disabled"], es = { class: "xml-format__info" }, ts = {
|
|
3916
4176
|
key: 0,
|
|
3917
4177
|
class: "xml-format__status xml-format__status--success"
|
|
3918
|
-
},
|
|
4178
|
+
}, rs = {
|
|
3919
4179
|
key: 1,
|
|
3920
4180
|
class: "xml-format__status xml-format__status--error"
|
|
3921
|
-
},
|
|
4181
|
+
}, ns = { class: "xml-format__content" }, ss = {
|
|
3922
4182
|
key: 0,
|
|
3923
4183
|
class: "xml-format__error"
|
|
3924
|
-
},
|
|
4184
|
+
}, os = {
|
|
3925
4185
|
key: 1,
|
|
3926
4186
|
class: "xml-format__viewer"
|
|
3927
|
-
},
|
|
4187
|
+
}, is = /* @__PURE__ */ Oe({
|
|
3928
4188
|
__name: "index",
|
|
3929
4189
|
props: {
|
|
3930
4190
|
modelValue: { default: "" },
|
|
@@ -3938,198 +4198,307 @@ const mn = {
|
|
|
3938
4198
|
},
|
|
3939
4199
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
3940
4200
|
setup(r, { expose: e, emit: t }) {
|
|
3941
|
-
|
|
3942
|
-
"
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
"
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
"
|
|
3950
|
-
"
|
|
3951
|
-
"
|
|
3952
|
-
|
|
3953
|
-
"
|
|
3954
|
-
"
|
|
3955
|
-
|
|
4201
|
+
Le((k) => ({
|
|
4202
|
+
"1078f5f2": l.value.colors.border,
|
|
4203
|
+
"3b7af818": l.value.colors.background,
|
|
4204
|
+
e476ff1a: l.value.colors.text,
|
|
4205
|
+
"434e9f96": l.value.colors.surfaceBackground,
|
|
4206
|
+
e9a92178: l.value.colors.buttonBorder,
|
|
4207
|
+
61940446: l.value.colors.buttonBackground,
|
|
4208
|
+
47092645: l.value.colors.buttonText,
|
|
4209
|
+
"6c26ded4": l.value.colors.buttonBackgroundHover,
|
|
4210
|
+
"7905142c": l.value.colors.buttonPrimary,
|
|
4211
|
+
"1d1c8572": l.value.colors.buttonPrimaryHover,
|
|
4212
|
+
e94e1206: l.value.colors.success,
|
|
4213
|
+
"4e8c500b": l.value.colors.successBackground,
|
|
4214
|
+
"29fdff82": l.value.colors.error,
|
|
4215
|
+
23583650: l.value.colors.errorBackground
|
|
3956
4216
|
}));
|
|
3957
|
-
const s = r, n = t, o =
|
|
4217
|
+
const s = r, n = t, o = W(null), i = W(""), c = W(/* @__PURE__ */ new Set()), a = K(() => i.value === ""), l = K(() => Xr(s.theme)), g = K(() => !o.value || !Array.isArray(o.value) ? [] : o.value.map((k, C) => ({ node: k, originalIndex: C })).filter((k) => !k.node["?xml"])), h = K(() => {
|
|
3958
4218
|
if (!o.value || !Array.isArray(o.value)) return null;
|
|
3959
|
-
const
|
|
3960
|
-
if (!
|
|
3961
|
-
const
|
|
3962
|
-
return
|
|
3963
|
-
}),
|
|
3964
|
-
if (!
|
|
4219
|
+
const k = o.value.find((V) => V["?xml"]);
|
|
4220
|
+
if (!k || !k[":@"]) return null;
|
|
4221
|
+
const C = k[":@"], R = [];
|
|
4222
|
+
return C["@_version"] && R.push(`version="${C["@_version"]}"`), C["@_encoding"] && R.push(`encoding="${C["@_encoding"]}"`), C["@_standalone"] && R.push(`standalone="${C["@_standalone"]}"`), R.length > 0 ? `<?xml ${R.join(" ")}?>` : null;
|
|
4223
|
+
}), x = K(() => g.value), v = (k) => {
|
|
4224
|
+
if (!k || !k.trim()) {
|
|
3965
4225
|
i.value = "", o.value = null;
|
|
3966
4226
|
return;
|
|
3967
4227
|
}
|
|
3968
4228
|
try {
|
|
3969
|
-
const
|
|
3970
|
-
if (!
|
|
3971
|
-
i.value =
|
|
4229
|
+
const C = Hn(k);
|
|
4230
|
+
if (!C.valid) {
|
|
4231
|
+
i.value = C.error || "Invalid XML", o.value = null;
|
|
3972
4232
|
return;
|
|
3973
4233
|
}
|
|
3974
|
-
o.value =
|
|
3975
|
-
|
|
4234
|
+
o.value = ot(k), i.value = "", ue(() => {
|
|
4235
|
+
S();
|
|
3976
4236
|
});
|
|
3977
|
-
} catch (
|
|
3978
|
-
i.value =
|
|
4237
|
+
} catch (C) {
|
|
4238
|
+
i.value = C instanceof Error ? C.message : "Unknown parse error", o.value = null;
|
|
3979
4239
|
}
|
|
3980
|
-
},
|
|
3981
|
-
|
|
3982
|
-
},
|
|
3983
|
-
const
|
|
3984
|
-
Array.isArray(
|
|
3985
|
-
const
|
|
3986
|
-
if (!
|
|
3987
|
-
const
|
|
3988
|
-
|
|
3989
|
-
const
|
|
3990
|
-
Array.isArray(
|
|
4240
|
+
}, B = (k) => {
|
|
4241
|
+
c.value.has(k) ? c.value.delete(k) : c.value.add(k);
|
|
4242
|
+
}, S = () => {
|
|
4243
|
+
const k = /* @__PURE__ */ new Set(), C = (R, V = "") => {
|
|
4244
|
+
Array.isArray(R) && R.forEach((T, Q) => {
|
|
4245
|
+
const f = Object.keys(T).find((m) => !m.startsWith(":") && !m.startsWith("#"));
|
|
4246
|
+
if (!f) return;
|
|
4247
|
+
const b = V ? `${V}.${f}[${Q}]` : `${f}[${Q}]`;
|
|
4248
|
+
k.add(b);
|
|
4249
|
+
const u = T[f];
|
|
4250
|
+
Array.isArray(u) && C(u, b + "." + f);
|
|
3991
4251
|
});
|
|
3992
4252
|
};
|
|
3993
|
-
|
|
3994
|
-
const
|
|
3995
|
-
if (
|
|
3996
|
-
const
|
|
3997
|
-
|
|
3998
|
-
const
|
|
3999
|
-
Array.isArray(
|
|
4253
|
+
g.value.forEach(({ node: R, originalIndex: V }) => {
|
|
4254
|
+
const T = Object.keys(R).find((Q) => !Q.startsWith(":") && !Q.startsWith("#"));
|
|
4255
|
+
if (T) {
|
|
4256
|
+
const Q = `${T}[${V}]`;
|
|
4257
|
+
k.add(Q);
|
|
4258
|
+
const f = R[T];
|
|
4259
|
+
Array.isArray(f) && C(f, Q + "." + T);
|
|
4000
4260
|
}
|
|
4001
|
-
}),
|
|
4002
|
-
},
|
|
4003
|
-
|
|
4004
|
-
},
|
|
4261
|
+
}), c.value = k, n("expand-all");
|
|
4262
|
+
}, _ = () => {
|
|
4263
|
+
c.value.clear(), n("collapse-all");
|
|
4264
|
+
}, j = async () => {
|
|
4005
4265
|
if (!(!a.value || !o.value))
|
|
4006
4266
|
try {
|
|
4007
|
-
const
|
|
4008
|
-
await navigator.clipboard.writeText(
|
|
4009
|
-
} catch (
|
|
4010
|
-
const
|
|
4011
|
-
n("copy-error",
|
|
4267
|
+
const k = Array.isArray(o.value) ? ge(o.value, { indent: " " }) : Ue(o.value, { format: !0, indentBy: " " });
|
|
4268
|
+
await navigator.clipboard.writeText(k), n("copy-success", k);
|
|
4269
|
+
} catch (k) {
|
|
4270
|
+
const C = k instanceof Error ? k : new Error("Copy failed");
|
|
4271
|
+
n("copy-error", C), console.error("Failed to copy XML:", k);
|
|
4012
4272
|
}
|
|
4013
|
-
},
|
|
4273
|
+
}, Y = () => {
|
|
4014
4274
|
if (!(!a.value || !o.value))
|
|
4015
4275
|
try {
|
|
4016
|
-
const
|
|
4017
|
-
n("update:modelValue",
|
|
4018
|
-
} catch (
|
|
4019
|
-
console.error("Failed to compress XML:",
|
|
4276
|
+
const k = qn(o.value);
|
|
4277
|
+
n("update:modelValue", k), n("compress", k);
|
|
4278
|
+
} catch (k) {
|
|
4279
|
+
console.error("Failed to compress XML:", k);
|
|
4020
4280
|
}
|
|
4021
|
-
},
|
|
4281
|
+
}, J = () => {
|
|
4022
4282
|
if (a.value)
|
|
4023
4283
|
try {
|
|
4024
|
-
const
|
|
4284
|
+
const k = Wn(s.modelValue, {
|
|
4025
4285
|
format: !0,
|
|
4026
4286
|
indentBy: " "
|
|
4027
4287
|
});
|
|
4028
|
-
n("update:modelValue",
|
|
4029
|
-
} catch (
|
|
4030
|
-
console.error("Failed to format XML:",
|
|
4288
|
+
n("update:modelValue", k), n("format", k);
|
|
4289
|
+
} catch (k) {
|
|
4290
|
+
console.error("Failed to format XML:", k);
|
|
4031
4291
|
}
|
|
4032
|
-
},
|
|
4292
|
+
}, z = async (k) => {
|
|
4033
4293
|
try {
|
|
4034
|
-
const
|
|
4035
|
-
await navigator.clipboard.writeText(
|
|
4036
|
-
} catch (
|
|
4037
|
-
const
|
|
4038
|
-
n("copy-error",
|
|
4294
|
+
const C = typeof k == "string" ? k : JSON.stringify(k, null, 2);
|
|
4295
|
+
await navigator.clipboard.writeText(C), n("copy-success", C);
|
|
4296
|
+
} catch (C) {
|
|
4297
|
+
const R = C instanceof Error ? C : new Error("Copy failed");
|
|
4298
|
+
n("copy-error", R), console.error("Failed to copy value:", C);
|
|
4039
4299
|
}
|
|
4300
|
+
}, ae = (k, C, R) => {
|
|
4301
|
+
if (!(!o.value || !Array.isArray(o.value)))
|
|
4302
|
+
try {
|
|
4303
|
+
const V = k.split(/\./).filter(Boolean);
|
|
4304
|
+
let T = o.value;
|
|
4305
|
+
for (let f = 0; f < V.length; f++) {
|
|
4306
|
+
const b = V[f], u = b.match(/^(.+?)\[(\d+)\]$/);
|
|
4307
|
+
if (u) {
|
|
4308
|
+
const m = u[1], E = parseInt(u[2]);
|
|
4309
|
+
if (f === V.length - 1) {
|
|
4310
|
+
if (Array.isArray(T) && T[E]) {
|
|
4311
|
+
const A = T[E];
|
|
4312
|
+
if (A[C]) {
|
|
4313
|
+
const w = A[C];
|
|
4314
|
+
delete A[C], A[R] = w;
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
} else
|
|
4318
|
+
Array.isArray(T) && T[E] && (T = T[E]);
|
|
4319
|
+
} else
|
|
4320
|
+
T[b] && (T = T[b]);
|
|
4321
|
+
}
|
|
4322
|
+
const Q = ge(o.value, { indent: " " });
|
|
4323
|
+
n("update:modelValue", Q);
|
|
4324
|
+
} catch (V) {
|
|
4325
|
+
console.error("Failed to update tag name:", V);
|
|
4326
|
+
}
|
|
4327
|
+
}, ce = (k, C, R) => {
|
|
4328
|
+
if (!(!o.value || !Array.isArray(o.value)))
|
|
4329
|
+
try {
|
|
4330
|
+
const V = k.split(/\./).filter(Boolean);
|
|
4331
|
+
let T = o.value;
|
|
4332
|
+
for (let f = 0; f < V.length; f++) {
|
|
4333
|
+
const b = V[f], u = b.match(/^(.+?)\[(\d+)\]$/);
|
|
4334
|
+
if (u) {
|
|
4335
|
+
const m = u[1], E = parseInt(u[2]);
|
|
4336
|
+
if (f === V.length - 1) {
|
|
4337
|
+
if (Array.isArray(T) && T[E]) {
|
|
4338
|
+
const w = T[E][":@"];
|
|
4339
|
+
if (w && w[`@_${C}`] !== void 0) {
|
|
4340
|
+
const L = w[`@_${C}`];
|
|
4341
|
+
delete w[`@_${C}`], w[`@_${R}`] = L;
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
} else
|
|
4345
|
+
Array.isArray(T) && T[E] && (T = T[E]);
|
|
4346
|
+
} else
|
|
4347
|
+
T[b] && (T = T[b]);
|
|
4348
|
+
}
|
|
4349
|
+
const Q = ge(o.value, { indent: " " });
|
|
4350
|
+
n("update:modelValue", Q);
|
|
4351
|
+
} catch (V) {
|
|
4352
|
+
console.error("Failed to update attribute name:", V);
|
|
4353
|
+
}
|
|
4354
|
+
}, fe = (k, C, R) => {
|
|
4355
|
+
if (!(!o.value || !Array.isArray(o.value)))
|
|
4356
|
+
try {
|
|
4357
|
+
const V = k.split(/\./).filter(Boolean);
|
|
4358
|
+
let T = o.value;
|
|
4359
|
+
for (let f = 0; f < V.length; f++) {
|
|
4360
|
+
const b = V[f], u = b.match(/^(.+?)\[(\d+)\]$/);
|
|
4361
|
+
if (u) {
|
|
4362
|
+
const m = u[1], E = parseInt(u[2]);
|
|
4363
|
+
if (f === V.length - 1) {
|
|
4364
|
+
if (Array.isArray(T) && T[E]) {
|
|
4365
|
+
const w = T[E][":@"];
|
|
4366
|
+
w && w[`@_${C}`] !== void 0 && (w[`@_${C}`] = R);
|
|
4367
|
+
}
|
|
4368
|
+
} else
|
|
4369
|
+
Array.isArray(T) && T[E] && (T = T[E]);
|
|
4370
|
+
} else
|
|
4371
|
+
T[b] && (T = T[b]);
|
|
4372
|
+
}
|
|
4373
|
+
const Q = ge(o.value, { indent: " " });
|
|
4374
|
+
n("update:modelValue", Q);
|
|
4375
|
+
} catch (V) {
|
|
4376
|
+
console.error("Failed to update attribute value:", V);
|
|
4377
|
+
}
|
|
4378
|
+
}, se = (k, C) => {
|
|
4379
|
+
if (!(!o.value || !Array.isArray(o.value)))
|
|
4380
|
+
try {
|
|
4381
|
+
const R = k.split(/\./).filter(Boolean);
|
|
4382
|
+
let V = o.value, T = "";
|
|
4383
|
+
for (let f = 0; f < R.length; f++) {
|
|
4384
|
+
const b = R[f], u = b.match(/^(.+?)\[(\d+)\]$/);
|
|
4385
|
+
if (u) {
|
|
4386
|
+
const m = u[1], E = parseInt(u[2]);
|
|
4387
|
+
if (f === R.length - 1) {
|
|
4388
|
+
if (Array.isArray(V) && V[E]) {
|
|
4389
|
+
const A = V[E];
|
|
4390
|
+
if (T = Object.keys(A).find((w) => !w.startsWith(":") && !w.startsWith("#")) || "", T && Array.isArray(A[T])) {
|
|
4391
|
+
const w = A[T], L = w.findIndex((H) => H["#text"] !== void 0);
|
|
4392
|
+
L !== -1 ? w[L]["#text"] = C : w.push({ "#text": C });
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
} else
|
|
4396
|
+
Array.isArray(V) && V[E] && (V = V[E]);
|
|
4397
|
+
} else
|
|
4398
|
+
V[b] && (V = V[b]);
|
|
4399
|
+
}
|
|
4400
|
+
const Q = ge(o.value, { indent: " " });
|
|
4401
|
+
n("update:modelValue", Q);
|
|
4402
|
+
} catch (R) {
|
|
4403
|
+
console.error("Failed to update text content:", R);
|
|
4404
|
+
}
|
|
4040
4405
|
};
|
|
4041
|
-
return
|
|
4042
|
-
|
|
4406
|
+
return Ge(() => s.modelValue, (k) => {
|
|
4407
|
+
v(k);
|
|
4043
4408
|
}, { immediate: !0 }), e({
|
|
4044
4409
|
// 核心操作方法
|
|
4045
|
-
copyXml:
|
|
4046
|
-
compressSource:
|
|
4047
|
-
formatSource:
|
|
4048
|
-
expandAll:
|
|
4049
|
-
collapseAll:
|
|
4050
|
-
toggleExpand:
|
|
4410
|
+
copyXml: j,
|
|
4411
|
+
compressSource: Y,
|
|
4412
|
+
formatSource: J,
|
|
4413
|
+
expandAll: S,
|
|
4414
|
+
collapseAll: _,
|
|
4415
|
+
toggleExpand: B,
|
|
4051
4416
|
// 状态访问方法
|
|
4052
4417
|
isValidXml: () => a.value,
|
|
4053
4418
|
getParsedXml: () => o.value,
|
|
4054
|
-
getExpandedNodes: () =>
|
|
4419
|
+
getExpandedNodes: () => c.value,
|
|
4055
4420
|
getParseError: () => i.value,
|
|
4056
4421
|
// 工具方法
|
|
4057
|
-
parseXmlString: (
|
|
4058
|
-
copyValue: (
|
|
4059
|
-
}), (
|
|
4060
|
-
class:
|
|
4422
|
+
parseXmlString: (k) => v(k),
|
|
4423
|
+
copyValue: (k) => z(k)
|
|
4424
|
+
}), (k, C) => (O(), P("div", {
|
|
4425
|
+
class: je(["xml-format", `xml-format--${l.value.name}`])
|
|
4061
4426
|
}, [
|
|
4062
|
-
|
|
4063
|
-
y("div",
|
|
4427
|
+
k.showToolbar ? (O(), P("div", Qn, [
|
|
4428
|
+
y("div", Yn, [
|
|
4064
4429
|
y("button", {
|
|
4065
4430
|
class: "xml-format__btn xml-format__btn--primary",
|
|
4066
|
-
onClick:
|
|
4431
|
+
onClick: j,
|
|
4067
4432
|
disabled: !a.value,
|
|
4068
4433
|
title: "Copy XML"
|
|
4069
|
-
}, " 📋 Copy ", 8,
|
|
4434
|
+
}, " 📋 Copy ", 8, Gn),
|
|
4070
4435
|
y("button", {
|
|
4071
4436
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
4072
|
-
onClick:
|
|
4437
|
+
onClick: S,
|
|
4073
4438
|
disabled: !a.value,
|
|
4074
4439
|
title: "Expand All"
|
|
4075
|
-
}, " ⬇️ Expand All ", 8,
|
|
4440
|
+
}, " ⬇️ Expand All ", 8, Zn),
|
|
4076
4441
|
y("button", {
|
|
4077
4442
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
4078
|
-
onClick:
|
|
4443
|
+
onClick: _,
|
|
4079
4444
|
disabled: !a.value,
|
|
4080
4445
|
title: "Collapse All"
|
|
4081
|
-
}, " ➡️ Collapse All ", 8,
|
|
4446
|
+
}, " ➡️ Collapse All ", 8, zn),
|
|
4082
4447
|
y("button", {
|
|
4083
4448
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
4084
|
-
onClick:
|
|
4449
|
+
onClick: Y,
|
|
4085
4450
|
disabled: !a.value,
|
|
4086
4451
|
title: "Compress XML"
|
|
4087
|
-
}, " 📦 Compress ", 8,
|
|
4452
|
+
}, " 📦 Compress ", 8, Dn),
|
|
4088
4453
|
y("button", {
|
|
4089
4454
|
class: "xml-format__btn xml-format__btn--secondary",
|
|
4090
|
-
onClick:
|
|
4455
|
+
onClick: J,
|
|
4091
4456
|
disabled: !a.value,
|
|
4092
4457
|
title: "Format XML"
|
|
4093
|
-
}, " ✨ Format ", 8,
|
|
4458
|
+
}, " ✨ Format ", 8, Jn)
|
|
4094
4459
|
]),
|
|
4095
|
-
y("div",
|
|
4096
|
-
a.value ? (
|
|
4460
|
+
y("div", es, [
|
|
4461
|
+
a.value ? (O(), P("span", ts, " ✅ Valid XML ")) : (O(), P("span", rs, " ❌ Invalid XML "))
|
|
4097
4462
|
])
|
|
4098
|
-
])) :
|
|
4099
|
-
y("div",
|
|
4100
|
-
a.value ? (
|
|
4101
|
-
h.value ? (
|
|
4463
|
+
])) : te("", !0),
|
|
4464
|
+
y("div", ns, [
|
|
4465
|
+
a.value ? (O(), P("div", os, [
|
|
4466
|
+
h.value ? (O(), P("div", {
|
|
4102
4467
|
key: 0,
|
|
4103
4468
|
class: "xml-declaration",
|
|
4104
|
-
style:
|
|
4105
|
-
},
|
|
4106
|
-
(
|
|
4107
|
-
key:
|
|
4108
|
-
node:
|
|
4109
|
-
index:
|
|
4469
|
+
style: $({ color: l.value.colors.xmlDeclaration })
|
|
4470
|
+
}, M(h.value), 5)) : te("", !0),
|
|
4471
|
+
(O(!0), P(pe, null, _e(x.value, (R, V) => (O(), Ze(jr, {
|
|
4472
|
+
key: V,
|
|
4473
|
+
node: R.node,
|
|
4474
|
+
index: R.originalIndex,
|
|
4110
4475
|
level: 0,
|
|
4111
|
-
expanded:
|
|
4476
|
+
expanded: c.value,
|
|
4112
4477
|
theme: l.value,
|
|
4113
|
-
onToggleExpand:
|
|
4114
|
-
onCopy:
|
|
4478
|
+
onToggleExpand: B,
|
|
4479
|
+
onCopy: z,
|
|
4480
|
+
"onUpdate:tagName": ae,
|
|
4481
|
+
"onUpdate:attributeName": ce,
|
|
4482
|
+
"onUpdate:attributeValue": fe,
|
|
4483
|
+
"onUpdate:textContent": se
|
|
4115
4484
|
}, null, 8, ["node", "index", "expanded", "theme"]))), 128))
|
|
4116
|
-
])) : (
|
|
4117
|
-
|
|
4118
|
-
y("pre", null,
|
|
4485
|
+
])) : (O(), P("div", ss, [
|
|
4486
|
+
C[0] || (C[0] = y("h4", null, "XML Parse Error:", -1)),
|
|
4487
|
+
y("pre", null, M(i.value), 1)
|
|
4119
4488
|
]))
|
|
4120
4489
|
])
|
|
4121
4490
|
], 2));
|
|
4122
4491
|
}
|
|
4123
|
-
}),
|
|
4124
|
-
|
|
4492
|
+
}), ds = /* @__PURE__ */ $e(is, [["__scopeId", "data-v-28f02178"]]), as = [ir], ls = (r) => {
|
|
4493
|
+
as.forEach((e) => {
|
|
4125
4494
|
const t = e.name || e.__name || "UnknownComponent";
|
|
4126
4495
|
r.component(t, e);
|
|
4127
4496
|
});
|
|
4128
|
-
},
|
|
4129
|
-
install:
|
|
4497
|
+
}, fs = {
|
|
4498
|
+
install: ls
|
|
4130
4499
|
};
|
|
4131
4500
|
export {
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4501
|
+
ir as JsonFormat,
|
|
4502
|
+
ds as XmlFormat,
|
|
4503
|
+
fs as default
|
|
4135
4504
|
};
|