lone-format 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +570 -524
- package/dist/lone-format.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/lone-format.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
class
|
|
1
|
+
import { defineComponent as pe, useCssVars as ye, ref as H, computed as j, resolveComponent as _e, createElementBlock as C, openBlock as A, createElementVNode as B, createCommentVNode as I, withDirectives as le, toDisplayString as F, withKeys as q, vModelText as ce, createTextVNode as he, Fragment as xe, renderList as ke, createVNode as ge, normalizeClass as be, nextTick as ee, watch as Oe } from "vue";
|
|
2
|
+
class Ce {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -42,7 +42,7 @@ class Ee {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class Ae {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -351,7 +351,7 @@ class o {
|
|
|
351
351
|
* @returns {?jsep.BinaryExpression}
|
|
352
352
|
*/
|
|
353
353
|
gobbleBinaryExpression() {
|
|
354
|
-
let e, t, s, n, a, c, f,
|
|
354
|
+
let e, t, s, n, a, c, f, h, d;
|
|
355
355
|
if (c = this.gobbleToken(), !c || (t = this.gobbleBinaryOp(), !t))
|
|
356
356
|
return c;
|
|
357
357
|
for (a = {
|
|
@@ -367,24 +367,24 @@ class o {
|
|
|
367
367
|
value: t,
|
|
368
368
|
prec: s,
|
|
369
369
|
right_a: o.right_associative.has(t)
|
|
370
|
-
},
|
|
371
|
-
const
|
|
372
|
-
for (; n.length > 2 &&
|
|
370
|
+
}, d = t;
|
|
371
|
+
const _ = (b) => a.right_a && b.right_a ? s > b.prec : s <= b.prec;
|
|
372
|
+
for (; n.length > 2 && _(n[n.length - 2]); )
|
|
373
373
|
f = n.pop(), t = n.pop().value, c = n.pop(), e = {
|
|
374
374
|
type: o.BINARY_EXP,
|
|
375
375
|
operator: t,
|
|
376
376
|
left: c,
|
|
377
377
|
right: f
|
|
378
378
|
}, n.push(e);
|
|
379
|
-
e = this.gobbleToken(), e || this.throwError("Expected expression after " +
|
|
379
|
+
e = this.gobbleToken(), e || this.throwError("Expected expression after " + d), n.push(a, e);
|
|
380
380
|
}
|
|
381
|
-
for (
|
|
381
|
+
for (h = n.length - 1, e = n[h]; h > 1; )
|
|
382
382
|
e = {
|
|
383
383
|
type: o.BINARY_EXP,
|
|
384
|
-
operator: n[
|
|
385
|
-
left: n[
|
|
384
|
+
operator: n[h - 1].value,
|
|
385
|
+
left: n[h - 2],
|
|
386
386
|
right: e
|
|
387
|
-
},
|
|
387
|
+
}, h -= 2;
|
|
388
388
|
return e;
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
@@ -615,10 +615,10 @@ class o {
|
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
618
|
+
const we = new Ce();
|
|
619
619
|
Object.assign(o, {
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
620
|
+
hooks: we,
|
|
621
|
+
plugins: new Ae(o),
|
|
622
622
|
// Node Types
|
|
623
623
|
// ----------
|
|
624
624
|
// This is the full set of types that any JSEP node can be.
|
|
@@ -714,14 +714,14 @@ Object.assign(o, {
|
|
|
714
714
|
});
|
|
715
715
|
o.max_unop_len = o.getMaxKeyLen(o.unary_ops);
|
|
716
716
|
o.max_binop_len = o.getMaxKeyLen(o.binary_ops);
|
|
717
|
-
const
|
|
717
|
+
const K = (r) => new o(r).parse(), Se = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(o).filter((r) => !
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(o).filter((r) => !Se.includes(r) && K[r] === void 0).forEach((r) => {
|
|
720
|
+
K[r] = o[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
var
|
|
722
|
+
K.Jsep = o;
|
|
723
|
+
const Pe = "ConditionalExpression";
|
|
724
|
+
var Ne = {
|
|
725
725
|
name: "ternary",
|
|
726
726
|
init(r) {
|
|
727
727
|
r.hooks.add("after-expression", function(t) {
|
|
@@ -732,7 +732,7 @@ var ke = {
|
|
|
732
732
|
this.index++;
|
|
733
733
|
const a = this.gobbleExpression();
|
|
734
734
|
if (a || this.throwError("Expected expression"), t.node = {
|
|
735
|
-
type:
|
|
735
|
+
type: Pe,
|
|
736
736
|
test: s,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: a
|
|
@@ -748,22 +748,22 @@ var ke = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
const
|
|
753
|
-
var
|
|
751
|
+
K.plugins.register(Ne);
|
|
752
|
+
const fe = 47, Te = 92;
|
|
753
|
+
var Be = {
|
|
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 === fe) {
|
|
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 === fe && !n) {
|
|
762
762
|
const a = this.expr.slice(s, this.index);
|
|
763
763
|
let c = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
765
|
+
const h = this.code;
|
|
766
|
+
if (h >= 97 && h <= 122 || h >= 65 && h <= 90 || h >= 48 && h <= 57)
|
|
767
767
|
c += this.char;
|
|
768
768
|
else
|
|
769
769
|
break;
|
|
@@ -771,8 +771,8 @@ var Ce = {
|
|
|
771
771
|
let f;
|
|
772
772
|
try {
|
|
773
773
|
f = new RegExp(a, c);
|
|
774
|
-
} catch (
|
|
775
|
-
this.throwError(
|
|
774
|
+
} catch (h) {
|
|
775
|
+
this.throwError(h.message);
|
|
776
776
|
}
|
|
777
777
|
return t.node = {
|
|
778
778
|
type: r.LITERAL,
|
|
@@ -780,34 +780,34 @@ var Ce = {
|
|
|
780
780
|
raw: this.expr.slice(s - 1, this.index)
|
|
781
781
|
}, t.node = this.gobbleTokenProperty(t.node), t.node;
|
|
782
782
|
}
|
|
783
|
-
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code ===
|
|
783
|
+
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code === Te ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const ue = 43, De = 45, z = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [ue, De],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
797
|
+
z.assignmentOperators.forEach((s) => r.addBinaryOp(s, z.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const a = this.code;
|
|
799
|
-
|
|
799
|
+
z.updateOperators.some((c) => c === a && c === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, n.node = {
|
|
800
800
|
type: "UpdateExpression",
|
|
801
|
-
operator: a ===
|
|
801
|
+
operator: a === ue ? "++" : "--",
|
|
802
802
|
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
803
803
|
prefix: !0
|
|
804
804
|
}, (!n.node.argument || !e.includes(n.node.argument.type)) && this.throwError(`Unexpected ${n.node.operator}`));
|
|
805
805
|
}), r.hooks.add("after-token", function(n) {
|
|
806
806
|
if (n.node) {
|
|
807
807
|
const a = this.code;
|
|
808
|
-
|
|
808
|
+
z.updateOperators.some((c) => c === a && c === this.expr.charCodeAt(this.index + 1)) && (e.includes(n.node.type) || this.throwError(`Unexpected ${n.node.operator}`), this.index += 2, n.node = {
|
|
809
809
|
type: "UpdateExpression",
|
|
810
|
-
operator: a ===
|
|
810
|
+
operator: a === ue ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -816,17 +816,17 @@ const se = 43, Ae = 45, G = {
|
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
818
|
function t(s) {
|
|
819
|
-
|
|
819
|
+
z.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
|
+
K.plugins.register(Be, z);
|
|
826
|
+
K.addUnaryOp("typeof");
|
|
827
|
+
K.addLiteral("null", null);
|
|
828
|
+
K.addLiteral("undefined", void 0);
|
|
829
|
+
const Ie = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), O = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -915,7 +915,7 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
915
915
|
), s = O.evalAst(r.object, e);
|
|
916
916
|
if (s == null)
|
|
917
917
|
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
918
|
-
if (!Object.hasOwn(s, t) &&
|
|
918
|
+
if (!Object.hasOwn(s, t) && Ie.has(t))
|
|
919
919
|
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
920
920
|
const n = s[t];
|
|
921
921
|
return typeof n == "function" ? n.bind(s) : n;
|
|
@@ -944,12 +944,12 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
944
944
|
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class je {
|
|
948
948
|
/**
|
|
949
949
|
* @param {string} expr Expression to evaluate
|
|
950
950
|
*/
|
|
951
951
|
constructor(e) {
|
|
952
|
-
this.code = e, this.ast =
|
|
952
|
+
this.code = e, this.ast = K(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -961,13 +961,13 @@ class Se {
|
|
|
961
961
|
return O.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function G(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function de(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class $e extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -975,10 +975,10 @@ class Pe 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 k(r, e, t, s, n) {
|
|
979
|
+
if (!(this instanceof k))
|
|
980
980
|
try {
|
|
981
|
-
return new
|
|
981
|
+
return new k(r, e, t, s, n);
|
|
982
982
|
} catch (c) {
|
|
983
983
|
if (!c.avoidNew)
|
|
984
984
|
throw c;
|
|
@@ -995,11 +995,11 @@ function x(r, e, t, s, n) {
|
|
|
995
995
|
a ? "json" in r && (c.json = r.json) : c.json = t;
|
|
996
996
|
const f = this.evaluate(c);
|
|
997
997
|
if (!f || typeof f != "object")
|
|
998
|
-
throw new
|
|
998
|
+
throw new $e(f);
|
|
999
999
|
return f;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
k.prototype.evaluate = function(r, e, t, s) {
|
|
1003
1003
|
let n = this.parent, a = this.parentProperty, {
|
|
1004
1004
|
flatten: c,
|
|
1005
1005
|
wrap: f
|
|
@@ -1013,172 +1013,172 @@ x.prototype.evaluate = function(r, e, t, s) {
|
|
|
1013
1013
|
json: e
|
|
1014
1014
|
} = r), c = Object.hasOwn(r, "flatten") ? r.flatten : c, this.currResultType = Object.hasOwn(r, "resultType") ? r.resultType : this.currResultType, this.currSandbox = Object.hasOwn(r, "sandbox") ? r.sandbox : this.currSandbox, f = Object.hasOwn(r, "wrap") ? r.wrap : f, 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, a = Object.hasOwn(r, "parentProperty") ? r.parentProperty : a, r = r.path;
|
|
1015
1015
|
}
|
|
1016
|
-
if (n = n || null, a = a || null, Array.isArray(r) && (r =
|
|
1016
|
+
if (n = n || null, a = a || null, Array.isArray(r) && (r = k.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1018
|
+
const h = k.toPathArray(r);
|
|
1019
|
+
h[0] === "$" && h.length > 1 && h.shift(), this._hasParentSelector = null;
|
|
1020
|
+
const d = this._trace(h, e, ["$"], n, a, t).filter(function(_) {
|
|
1021
|
+
return _ && !_.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
|
-
return
|
|
1024
|
-
const
|
|
1025
|
-
return c && Array.isArray(
|
|
1023
|
+
return d.length ? !f && d.length === 1 && !d[0].hasArrExpr ? this._getPreferredOutput(d[0]) : d.reduce((_, b) => {
|
|
1024
|
+
const x = this._getPreferredOutput(b);
|
|
1025
|
+
return c && Array.isArray(x) ? _ = _.concat(x) : _.push(x), _;
|
|
1026
1026
|
}, []) : f ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
|
-
|
|
1028
|
+
k.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 : k.toPathArray(r.path);
|
|
1033
|
+
return r.pointer = k.toPointer(t), r.path = typeof r.path == "string" ? r.path : k.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 k.toPathString(r[e]);
|
|
1041
1041
|
case "pointer":
|
|
1042
|
-
return
|
|
1042
|
+
return k.toPointer(r.path);
|
|
1043
1043
|
default:
|
|
1044
1044
|
throw new TypeError("Unknown result type");
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
|
-
|
|
1047
|
+
k.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 : k.toPathString(r.path), e(s, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1054
|
-
let
|
|
1053
|
+
k.prototype._trace = function(r, e, t, s, n, a, c, f) {
|
|
1054
|
+
let h;
|
|
1055
1055
|
if (!r.length)
|
|
1056
|
-
return
|
|
1056
|
+
return h = {
|
|
1057
1057
|
path: t,
|
|
1058
1058
|
value: e,
|
|
1059
1059
|
parent: s,
|
|
1060
1060
|
parentProperty: n,
|
|
1061
1061
|
hasArrExpr: c
|
|
1062
|
-
}, this._handleCallback(
|
|
1063
|
-
const
|
|
1064
|
-
function
|
|
1065
|
-
Array.isArray(
|
|
1066
|
-
|
|
1067
|
-
}) :
|
|
1068
|
-
}
|
|
1069
|
-
if ((typeof
|
|
1070
|
-
|
|
1071
|
-
else if (
|
|
1072
|
-
this._walk(e, (
|
|
1073
|
-
|
|
1062
|
+
}, this._handleCallback(h, a, "value"), h;
|
|
1063
|
+
const d = r[0], _ = r.slice(1), b = [];
|
|
1064
|
+
function x(g) {
|
|
1065
|
+
Array.isArray(g) ? g.forEach((w) => {
|
|
1066
|
+
b.push(w);
|
|
1067
|
+
}) : b.push(g);
|
|
1068
|
+
}
|
|
1069
|
+
if ((typeof d != "string" || f) && e && Object.hasOwn(e, d))
|
|
1070
|
+
x(this._trace(_, e[d], G(t, d), e, d, a, c));
|
|
1071
|
+
else if (d === "*")
|
|
1072
|
+
this._walk(e, (g) => {
|
|
1073
|
+
x(this._trace(_, e[g], G(t, g), e, g, a, !0, !0));
|
|
1074
1074
|
});
|
|
1075
|
-
else if (
|
|
1076
|
-
|
|
1077
|
-
typeof e[
|
|
1075
|
+
else if (d === "..")
|
|
1076
|
+
x(this._trace(_, e, t, s, n, a, c)), this._walk(e, (g) => {
|
|
1077
|
+
typeof e[g] == "object" && x(this._trace(r.slice(), e[g], G(t, g), e, g, a, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
|
-
if (
|
|
1080
|
+
if (d === "^")
|
|
1081
1081
|
return this._hasParentSelector = !0, {
|
|
1082
1082
|
path: t.slice(0, -1),
|
|
1083
|
-
expr:
|
|
1083
|
+
expr: _,
|
|
1084
1084
|
isParentSelector: !0
|
|
1085
1085
|
};
|
|
1086
|
-
if (
|
|
1087
|
-
return
|
|
1088
|
-
path:
|
|
1086
|
+
if (d === "~")
|
|
1087
|
+
return h = {
|
|
1088
|
+
path: G(t, d),
|
|
1089
1089
|
value: n,
|
|
1090
1090
|
parent: s,
|
|
1091
1091
|
parentProperty: null
|
|
1092
|
-
}, this._handleCallback(
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1095
|
-
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(
|
|
1096
|
-
|
|
1097
|
-
else if (
|
|
1092
|
+
}, this._handleCallback(h, a, "property"), h;
|
|
1093
|
+
if (d === "$")
|
|
1094
|
+
x(this._trace(_, e, t, null, null, a, c));
|
|
1095
|
+
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(d))
|
|
1096
|
+
x(this._slice(d, _, e, t, s, n, a));
|
|
1097
|
+
else if (d.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 g = d.replace(/^\?\((.*?)\)$/u, "$1"), w = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(g);
|
|
1101
|
+
w ? this._walk(e, (S) => {
|
|
1102
|
+
const M = [w[2]], $ = w[1] ? e[S][w[1]] : e[S];
|
|
1103
|
+
this._trace(M, $, t, s, n, a, !0).length > 0 && x(this._trace(_, e[S], G(t, S), e, S, a, !0));
|
|
1104
|
+
}) : this._walk(e, (S) => {
|
|
1105
|
+
this._eval(g, e[S], S, t, s, n) && x(this._trace(_, e[S], G(t, S), e, S, a, !0));
|
|
1106
1106
|
});
|
|
1107
|
-
} else if (
|
|
1107
|
+
} else if (d[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
1109
1109
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1110
|
-
|
|
1111
|
-
} else if (
|
|
1112
|
-
let
|
|
1113
|
-
const
|
|
1114
|
-
switch (
|
|
1110
|
+
x(this._trace(de(this._eval(d, e, t.at(-1), t.slice(0, -1), s, n), _), e, t, s, n, a, c));
|
|
1111
|
+
} else if (d[0] === "@") {
|
|
1112
|
+
let g = !1;
|
|
1113
|
+
const w = d.slice(1, -2);
|
|
1114
|
+
switch (w) {
|
|
1115
1115
|
case "scalar":
|
|
1116
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
1116
|
+
(!e || !["object", "function"].includes(typeof e)) && (g = !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 === w && (g = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
1125
|
+
Number.isFinite(e) && !(e % 1) && (g = !0);
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "number":
|
|
1128
|
-
Number.isFinite(e) && (
|
|
1128
|
+
Number.isFinite(e) && (g = !0);
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "nonFinite":
|
|
1131
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
1131
|
+
typeof e == "number" && !Number.isFinite(e) && (g = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e ===
|
|
1134
|
+
e && typeof e === w && (g = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
|
-
Array.isArray(e) && (
|
|
1137
|
+
Array.isArray(e) && (g = !0);
|
|
1138
1138
|
break;
|
|
1139
1139
|
case "other":
|
|
1140
|
-
|
|
1140
|
+
g = this.currOtherTypeCallback(e, t, s, n);
|
|
1141
1141
|
break;
|
|
1142
1142
|
case "null":
|
|
1143
|
-
e === null && (
|
|
1143
|
+
e === null && (g = !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 " + w);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1150
|
-
return
|
|
1149
|
+
if (g)
|
|
1150
|
+
return h = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
1153
1153
|
parent: s,
|
|
1154
1154
|
parentProperty: n
|
|
1155
|
-
}, this._handleCallback(
|
|
1156
|
-
} else if (
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
} else if (
|
|
1160
|
-
const
|
|
1161
|
-
for (const
|
|
1162
|
-
|
|
1163
|
-
} else !f && e && Object.hasOwn(e,
|
|
1155
|
+
}, this._handleCallback(h, a, "value"), h;
|
|
1156
|
+
} else if (d[0] === "`" && e && Object.hasOwn(e, d.slice(1))) {
|
|
1157
|
+
const g = d.slice(1);
|
|
1158
|
+
x(this._trace(_, e[g], G(t, g), e, g, a, c, !0));
|
|
1159
|
+
} else if (d.includes(",")) {
|
|
1160
|
+
const g = d.split(",");
|
|
1161
|
+
for (const w of g)
|
|
1162
|
+
x(this._trace(de(w, _), e, t, s, n, a, !0));
|
|
1163
|
+
} else !f && e && Object.hasOwn(e, d) && x(this._trace(_, e[d], G(t, d), e, d, a, c, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
const
|
|
1170
|
-
if (Array.isArray(
|
|
1171
|
-
g
|
|
1172
|
-
const
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1166
|
+
for (let g = 0; g < b.length; g++) {
|
|
1167
|
+
const w = b[g];
|
|
1168
|
+
if (w && w.isParentSelector) {
|
|
1169
|
+
const S = this._trace(w.expr, e, w.path, s, n, a, c);
|
|
1170
|
+
if (Array.isArray(S)) {
|
|
1171
|
+
b[g] = S[0];
|
|
1172
|
+
const M = S.length;
|
|
1173
|
+
for (let $ = 1; $ < M; $++)
|
|
1174
|
+
g++, b.splice(g, 0, S[$]);
|
|
1175
1175
|
} else
|
|
1176
|
-
g
|
|
1176
|
+
b[g] = S;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
return
|
|
1179
|
+
return b;
|
|
1180
1180
|
};
|
|
1181
|
-
|
|
1181
|
+
k.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 @@ x.prototype._walk = function(r, e) {
|
|
|
1187
1187
|
e(t);
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
|
-
|
|
1190
|
+
k.prototype._slice = function(r, e, t, s, n, a, c) {
|
|
1191
1191
|
if (!Array.isArray(t))
|
|
1192
1192
|
return;
|
|
1193
|
-
const f = t.length,
|
|
1194
|
-
let
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
for (let
|
|
1198
|
-
this._trace(
|
|
1199
|
-
|
|
1193
|
+
const f = t.length, h = r.split(":"), d = h[2] && Number.parseInt(h[2]) || 1;
|
|
1194
|
+
let _ = h[0] && Number.parseInt(h[0]) || 0, b = h[1] && Number.parseInt(h[1]) || f;
|
|
1195
|
+
_ = _ < 0 ? Math.max(0, _ + f) : Math.min(f, _), b = b < 0 ? Math.max(0, b + f) : Math.min(f, b);
|
|
1196
|
+
const x = [];
|
|
1197
|
+
for (let g = _; g < b; g += d)
|
|
1198
|
+
this._trace(de(g, e), t, s, n, a, c, !0).forEach((S) => {
|
|
1199
|
+
x.push(S);
|
|
1200
1200
|
});
|
|
1201
|
-
return
|
|
1201
|
+
return x;
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1203
|
+
k.prototype._eval = function(r, e, t, s, n, a) {
|
|
1204
1204
|
this.currSandbox._$_parentProperty = a, this.currSandbox._$_parent = n, this.currSandbox._$_property = t, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
|
|
1205
1205
|
const c = r.includes("@path");
|
|
1206
|
-
c && (this.currSandbox._$_path =
|
|
1206
|
+
c && (this.currSandbox._$_path = k.toPathString(s.concat([t])));
|
|
1207
1207
|
const f = this.currEval + "Script:" + r;
|
|
1208
|
-
if (!
|
|
1209
|
-
let
|
|
1210
|
-
if (c && (
|
|
1211
|
-
|
|
1208
|
+
if (!k.cache[f]) {
|
|
1209
|
+
let h = r.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
1210
|
+
if (c && (h = h.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
1211
|
+
k.cache[f] = new this.safeVm.Script(h);
|
|
1212
1212
|
else if (this.currEval === "native")
|
|
1213
|
-
|
|
1213
|
+
k.cache[f] = new this.vm.Script(h);
|
|
1214
1214
|
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1215
|
+
const d = this.currEval;
|
|
1216
|
+
k.cache[f] = new d(h);
|
|
1217
1217
|
} else if (typeof this.currEval == "function")
|
|
1218
|
-
|
|
1219
|
-
runInNewContext: (
|
|
1218
|
+
k.cache[f] = {
|
|
1219
|
+
runInNewContext: (d) => this.currEval(h, d)
|
|
1220
1220
|
};
|
|
1221
1221
|
else
|
|
1222
1222
|
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
1223
1223
|
}
|
|
1224
1224
|
try {
|
|
1225
|
-
return
|
|
1226
|
-
} catch (
|
|
1225
|
+
return k.cache[f].runInNewContext(this.currSandbox);
|
|
1226
|
+
} catch (h) {
|
|
1227
1227
|
if (this.ignoreEvalErrors)
|
|
1228
1228
|
return !1;
|
|
1229
|
-
throw new Error("jsonPath: " +
|
|
1229
|
+
throw new Error("jsonPath: " + h.message + ": " + r);
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1232
|
+
k.cache = {};
|
|
1233
|
+
k.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
|
+
k.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
|
+
k.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
1249
1249
|
cache: e
|
|
1250
|
-
} =
|
|
1250
|
+
} = k;
|
|
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(a, c) {
|
|
@@ -1262,17 +1262,17 @@ x.toPathArray = function(r) {
|
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
|
-
|
|
1266
|
-
Script:
|
|
1265
|
+
k.prototype.safeVm = {
|
|
1266
|
+
Script: je
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1268
|
+
const Re = function(r, e, t) {
|
|
1269
1269
|
const s = r.length;
|
|
1270
1270
|
for (let n = 0; n < s; n++) {
|
|
1271
1271
|
const a = r[n];
|
|
1272
1272
|
t(a) && e.push(r.splice(n--, 1)[0]);
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
|
-
class
|
|
1275
|
+
class Le {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1287,47 +1287,47 @@ class Te {
|
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
1289
|
const s = Object.keys(e), n = [];
|
|
1290
|
-
|
|
1291
|
-
const a = s.map((
|
|
1292
|
-
t = n.reduce((
|
|
1293
|
-
let
|
|
1294
|
-
return /function/u.test(
|
|
1290
|
+
Re(s, n, (d) => typeof e[d] == "function");
|
|
1291
|
+
const a = s.map((d) => e[d]);
|
|
1292
|
+
t = n.reduce((d, _) => {
|
|
1293
|
+
let b = e[_].toString();
|
|
1294
|
+
return /function/u.test(b) || (b = "function " + b), "var " + _ + "=" + b + ";" + d;
|
|
1295
1295
|
}, "") + t, !/(['"])use strict\1/u.test(t) && !s.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;\s*$/u, "");
|
|
1296
|
-
const f = t.lastIndexOf(";"),
|
|
1297
|
-
return new Function(...s,
|
|
1296
|
+
const f = t.lastIndexOf(";"), h = f !== -1 ? t.slice(0, f + 1) + " return " + t.slice(f + 1) : " return " + t;
|
|
1297
|
+
return new Function(...s, h)(...a);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
|
|
1301
|
-
Script:
|
|
1300
|
+
k.prototype.vm = {
|
|
1301
|
+
Script: Le
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const Ue = { class: "json-node" }, Me = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1306
|
+
}, Ve = { class: "json-node__line" }, Fe = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, He = ["title"], Ke = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
|
-
},
|
|
1312
|
+
}, Xe = {
|
|
1313
1313
|
key: 4,
|
|
1314
1314
|
class: "json-node__comma"
|
|
1315
|
-
},
|
|
1315
|
+
}, Ge = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__children"
|
|
1318
|
-
},
|
|
1318
|
+
}, Qe = { class: "json-node__children-content" }, Ye = { class: "json-node__line json-node__closing-bracket" }, qe = { class: "json-node__bracket" }, ze = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
|
-
},
|
|
1321
|
+
}, We = {
|
|
1322
1322
|
key: 1,
|
|
1323
1323
|
class: "json-node__primitive"
|
|
1324
|
-
},
|
|
1324
|
+
}, Ze = {
|
|
1325
1325
|
key: 2,
|
|
1326
1326
|
class: "json-node__colon"
|
|
1327
|
-
},
|
|
1327
|
+
}, Je = ["title"], et = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
},
|
|
1330
|
+
}, tt = /* @__PURE__ */ pe({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1341,195 +1341,201 @@ const Be = { class: "json-node" }, De = {
|
|
|
1341
1341
|
},
|
|
1342
1342
|
emits: ["update:value", "toggle-expand", "copy", "update:key"],
|
|
1343
1343
|
setup(r, { emit: e }) {
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
"
|
|
1347
|
-
"
|
|
1348
|
-
"
|
|
1349
|
-
"
|
|
1350
|
-
"
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
"
|
|
1354
|
-
|
|
1355
|
-
"
|
|
1344
|
+
ye((u) => ({
|
|
1345
|
+
a64439cc: u.level,
|
|
1346
|
+
"34bc012d": u.theme.colors.syntaxKey,
|
|
1347
|
+
"577f8c7b": u.theme.colors.hoverBackground,
|
|
1348
|
+
"7f7e0f14": u.theme.colors.syntaxBracket,
|
|
1349
|
+
"3cb77810": u.theme.colors.textSecondary,
|
|
1350
|
+
"5e753afa": u.theme.colors.syntaxString,
|
|
1351
|
+
"6f6e448a": u.theme.colors.syntaxNumber,
|
|
1352
|
+
88289014: u.theme.colors.syntaxBoolean,
|
|
1353
|
+
"62c5bc79": u.theme.colors.syntaxNull,
|
|
1354
|
+
"0aa554c6": u.theme.colors.background,
|
|
1355
|
+
"66a2df2f": u.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r, s = e, n =
|
|
1357
|
+
const t = r, s = e, n = H(!1), a = H(!1), c = H(""), f = H(""), h = (u) => {
|
|
1358
1358
|
if (!/^-?\d+(\.\d+)?$/.test(u)) return !1;
|
|
1359
|
-
const
|
|
1360
|
-
return !Number.isSafeInteger(
|
|
1361
|
-
},
|
|
1359
|
+
const E = Number(u);
|
|
1360
|
+
return !Number.isSafeInteger(E) || u.length > 15;
|
|
1361
|
+
}, d = (u) => {
|
|
1362
|
+
if (typeof u != "string" || !/^-?\d+(\.\d+)?$/.test(u)) return !1;
|
|
1363
|
+
if (u.includes(".") && /\.\d*0$/.test(u))
|
|
1364
|
+
return !0;
|
|
1365
|
+
const E = Number(u), i = u.startsWith("-") ? u.slice(1) : u;
|
|
1366
|
+
return !Number.isSafeInteger(E) || i.length > 15;
|
|
1367
|
+
}, _ = j(() => t.value !== null && typeof t.value == "object"), b = j(() => Array.isArray(t.value)), x = j(() => t.path ? t.path : t.keyName ? t.keyName : "root"), g = j(() => t.expanded.has(x.value)), w = j(() => t.keyName), S = j(() => b.value ? "[" : "{"), M = j(() => b.value ? "]" : "}"), $ = j(() => {
|
|
1362
1368
|
if (!t.value) return "";
|
|
1363
|
-
const
|
|
1364
|
-
return
|
|
1365
|
-
}),
|
|
1369
|
+
const E = Object.keys(t.value).length;
|
|
1370
|
+
return b.value ? E > 0 ? ` ${E} items ` : " " : E > 0 ? ` ${E} keys ` : " ";
|
|
1371
|
+
}), W = j(() => {
|
|
1366
1372
|
const u = typeof t.value;
|
|
1367
1373
|
return t.value === null ? "json-node__value--null" : u === "boolean" ? "json-node__value--boolean" : u === "number" ? "json-node__value--number" : u === "string" ? d(t.value) ? "json-node__value--number" : "json-node__value--string" : "";
|
|
1368
|
-
}),
|
|
1369
|
-
const
|
|
1370
|
-
return
|
|
1371
|
-
},
|
|
1372
|
-
s("toggle-expand",
|
|
1373
|
-
},
|
|
1374
|
-
t.level !== 0 && (n.value = !0, c.value = t.keyName,
|
|
1375
|
-
const u = document.querySelectorAll(".json-node__key-input"),
|
|
1376
|
-
|
|
1374
|
+
}), ae = j(() => a.value ? f.value : t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : typeof t.value == "string" ? d(t.value) ? t.value : `"${t.value}"` : String(t.value)), te = j(() => "Click to edit, double-click to copy"), Q = (u) => t.level === 0 ? u : x.value ? `${x.value}.${u}` : u, re = (u) => {
|
|
1375
|
+
const E = Object.keys(t.value);
|
|
1376
|
+
return E.indexOf(u) === E.length - 1;
|
|
1377
|
+
}, Z = () => {
|
|
1378
|
+
s("toggle-expand", x.value);
|
|
1379
|
+
}, J = () => {
|
|
1380
|
+
t.level !== 0 && (n.value = !0, c.value = t.keyName, ee(() => {
|
|
1381
|
+
const u = document.querySelectorAll(".json-node__key-input"), E = u[u.length - 1];
|
|
1382
|
+
E && (E.focus(), E.select());
|
|
1377
1383
|
}));
|
|
1378
|
-
},
|
|
1379
|
-
|
|
1380
|
-
const u = document.querySelectorAll(".json-node__value-input"),
|
|
1381
|
-
|
|
1384
|
+
}, ne = () => {
|
|
1385
|
+
_.value || (a.value = !0, typeof t.value == "string" && h(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value), ee(() => {
|
|
1386
|
+
const u = document.querySelectorAll(".json-node__value-input"), E = u[u.length - 1];
|
|
1387
|
+
E && (E.focus(), E.select());
|
|
1382
1388
|
}));
|
|
1383
|
-
},
|
|
1389
|
+
}, Y = () => {
|
|
1384
1390
|
if (t.level === 0 || !n.value) return;
|
|
1385
1391
|
const u = c.value.trim();
|
|
1386
1392
|
if (!u) {
|
|
1387
|
-
|
|
1393
|
+
X();
|
|
1388
1394
|
return;
|
|
1389
1395
|
}
|
|
1390
1396
|
if (u === t.keyName) {
|
|
1391
1397
|
n.value = !1;
|
|
1392
1398
|
return;
|
|
1393
1399
|
}
|
|
1394
|
-
n.value = !1, s("update:key",
|
|
1395
|
-
},
|
|
1400
|
+
n.value = !1, s("update:key", x.value, u);
|
|
1401
|
+
}, se = () => {
|
|
1396
1402
|
try {
|
|
1397
1403
|
let u;
|
|
1398
|
-
const
|
|
1399
|
-
if (
|
|
1404
|
+
const E = f.value.trim();
|
|
1405
|
+
if (E === "null")
|
|
1400
1406
|
u = null;
|
|
1401
|
-
else if (
|
|
1402
|
-
u =
|
|
1403
|
-
else if (!isNaN(Number(
|
|
1404
|
-
const
|
|
1405
|
-
!Number.isSafeInteger(
|
|
1407
|
+
else if (E === "true" || E === "false")
|
|
1408
|
+
u = E === "true";
|
|
1409
|
+
else if (!isNaN(Number(E)) && E !== "") {
|
|
1410
|
+
const i = Number(E);
|
|
1411
|
+
!Number.isSafeInteger(i) || E.length > 15 ? u = E : u = i;
|
|
1406
1412
|
} else
|
|
1407
1413
|
u = f.value;
|
|
1408
|
-
s("update:value",
|
|
1414
|
+
s("update:value", x.value, u), a.value = !1;
|
|
1409
1415
|
} catch (u) {
|
|
1410
1416
|
console.error("Failed to parse value:", u), a.value = !1;
|
|
1411
1417
|
}
|
|
1412
|
-
},
|
|
1418
|
+
}, X = () => {
|
|
1413
1419
|
n.value = !1, c.value = t.keyName;
|
|
1414
|
-
},
|
|
1415
|
-
a.value = !1, typeof t.value == "string" &&
|
|
1420
|
+
}, oe = () => {
|
|
1421
|
+
a.value = !1, typeof t.value == "string" && h(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value);
|
|
1416
1422
|
};
|
|
1417
|
-
return (u,
|
|
1418
|
-
const
|
|
1419
|
-
return
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
u.keyName && !n.value ? (
|
|
1423
|
+
return (u, E) => {
|
|
1424
|
+
const i = _e("JsonNode", !0);
|
|
1425
|
+
return A(), C("div", Ue, [
|
|
1426
|
+
_.value ? (A(), C("div", Me, [
|
|
1427
|
+
B("div", Ve, [
|
|
1428
|
+
u.keyName && !n.value ? (A(), C("span", {
|
|
1423
1429
|
key: 0,
|
|
1424
1430
|
class: "json-node__key",
|
|
1425
|
-
onClick:
|
|
1431
|
+
onClick: J,
|
|
1426
1432
|
title: "Click to edit key"
|
|
1427
|
-
}, ' "' +
|
|
1428
|
-
u.keyName && n.value ?
|
|
1433
|
+
}, ' "' + F(w.value) + '" ', 1)) : I("", !0),
|
|
1434
|
+
u.keyName && n.value ? le((A(), C("input", {
|
|
1429
1435
|
key: 1,
|
|
1430
|
-
"onUpdate:modelValue":
|
|
1436
|
+
"onUpdate:modelValue": E[0] || (E[0] = (l) => c.value = l),
|
|
1431
1437
|
onKeyup: [
|
|
1432
|
-
|
|
1433
|
-
X
|
|
1438
|
+
q(Y, ["enter"]),
|
|
1439
|
+
q(X, ["escape"])
|
|
1434
1440
|
],
|
|
1435
|
-
onBlur:
|
|
1441
|
+
onBlur: Y,
|
|
1436
1442
|
class: "json-node__key-input"
|
|
1437
1443
|
}, null, 544)), [
|
|
1438
|
-
[
|
|
1439
|
-
]) :
|
|
1440
|
-
u.keyName ? (
|
|
1441
|
-
|
|
1444
|
+
[ce, c.value]
|
|
1445
|
+
]) : I("", !0),
|
|
1446
|
+
u.keyName ? (A(), C("span", Fe, ": ")) : I("", !0),
|
|
1447
|
+
B("span", {
|
|
1442
1448
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1443
|
-
onClick:
|
|
1444
|
-
title:
|
|
1445
|
-
},
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
+
onClick: Z,
|
|
1450
|
+
title: g.value ? "Click to collapse" : "Click to expand"
|
|
1451
|
+
}, F(S.value), 9, He),
|
|
1452
|
+
g.value ? I("", !0) : (A(), C("span", Ke, [
|
|
1453
|
+
he(F($.value) + " ", 1),
|
|
1454
|
+
B("span", {
|
|
1449
1455
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1450
|
-
onClick:
|
|
1451
|
-
},
|
|
1456
|
+
onClick: Z
|
|
1457
|
+
}, F(M.value), 1)
|
|
1452
1458
|
])),
|
|
1453
|
-
!
|
|
1459
|
+
!g.value && !u.isLast ? (A(), C("span", Xe, ",")) : I("", !0)
|
|
1454
1460
|
]),
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
(
|
|
1458
|
-
key:
|
|
1461
|
+
g.value ? (A(), C("div", Ge, [
|
|
1462
|
+
B("div", Qe, [
|
|
1463
|
+
(A(!0), C(xe, null, ke(u.value, (l, m) => (A(), C("div", {
|
|
1464
|
+
key: m,
|
|
1459
1465
|
class: "json-node__child"
|
|
1460
1466
|
}, [
|
|
1461
|
-
|
|
1462
|
-
value:
|
|
1463
|
-
"key-name":
|
|
1467
|
+
ge(i, {
|
|
1468
|
+
value: l,
|
|
1469
|
+
"key-name": b.value ? "" : String(m),
|
|
1464
1470
|
level: u.level + 1,
|
|
1465
|
-
path:
|
|
1471
|
+
path: Q(String(m)),
|
|
1466
1472
|
expanded: u.expanded,
|
|
1467
1473
|
theme: u.theme,
|
|
1468
|
-
"onUpdate:value":
|
|
1469
|
-
onToggleExpand:
|
|
1470
|
-
onCopy:
|
|
1471
|
-
"onUpdate:key":
|
|
1472
|
-
"is-last":
|
|
1474
|
+
"onUpdate:value": E[1] || (E[1] = (p, y) => u.$emit("update:value", p, y)),
|
|
1475
|
+
onToggleExpand: E[2] || (E[2] = (p) => u.$emit("toggle-expand", p)),
|
|
1476
|
+
onCopy: E[3] || (E[3] = (p) => u.$emit("copy", p)),
|
|
1477
|
+
"onUpdate:key": E[4] || (E[4] = (p, y) => u.$emit("update:key", p, y)),
|
|
1478
|
+
"is-last": re(String(m))
|
|
1473
1479
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1474
1480
|
]))), 128))
|
|
1475
1481
|
]),
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
u.isLast ?
|
|
1482
|
+
B("div", Ye, [
|
|
1483
|
+
B("span", qe, F(M.value), 1),
|
|
1484
|
+
u.isLast ? I("", !0) : (A(), C("span", ze, ","))
|
|
1479
1485
|
])
|
|
1480
|
-
])) :
|
|
1481
|
-
])) : (
|
|
1482
|
-
u.keyName && !n.value ? (
|
|
1486
|
+
])) : I("", !0)
|
|
1487
|
+
])) : (A(), C("div", We, [
|
|
1488
|
+
u.keyName && !n.value ? (A(), C("span", {
|
|
1483
1489
|
key: 0,
|
|
1484
1490
|
class: "json-node__key",
|
|
1485
|
-
onClick:
|
|
1491
|
+
onClick: J,
|
|
1486
1492
|
title: "Click to edit key"
|
|
1487
|
-
}, ' "' +
|
|
1488
|
-
u.keyName && n.value ?
|
|
1493
|
+
}, ' "' + F(w.value) + '" ', 1)) : I("", !0),
|
|
1494
|
+
u.keyName && n.value ? le((A(), C("input", {
|
|
1489
1495
|
key: 1,
|
|
1490
|
-
"onUpdate:modelValue":
|
|
1496
|
+
"onUpdate:modelValue": E[5] || (E[5] = (l) => c.value = l),
|
|
1491
1497
|
onKeyup: [
|
|
1492
|
-
|
|
1493
|
-
X
|
|
1498
|
+
q(Y, ["enter"]),
|
|
1499
|
+
q(X, ["escape"])
|
|
1494
1500
|
],
|
|
1495
|
-
onBlur:
|
|
1501
|
+
onBlur: Y,
|
|
1496
1502
|
class: "json-node__key-input"
|
|
1497
1503
|
}, null, 544)), [
|
|
1498
|
-
[
|
|
1499
|
-
]) :
|
|
1500
|
-
u.keyName ? (
|
|
1501
|
-
a.value ?
|
|
1504
|
+
[ce, c.value]
|
|
1505
|
+
]) : I("", !0),
|
|
1506
|
+
u.keyName ? (A(), C("span", Ze, ": ")) : I("", !0),
|
|
1507
|
+
a.value ? I("", !0) : (A(), C("span", {
|
|
1502
1508
|
key: 3,
|
|
1503
|
-
class:
|
|
1504
|
-
onClick:
|
|
1505
|
-
onDblclick:
|
|
1509
|
+
class: be(["json-node__value", W.value]),
|
|
1510
|
+
onClick: ne,
|
|
1511
|
+
onDblclick: E[6] || (E[6] = (l) => u.$emit("copy", u.value)),
|
|
1506
1512
|
title: te.value
|
|
1507
1513
|
}, [
|
|
1508
|
-
|
|
1509
|
-
u.isLast ?
|
|
1510
|
-
], 42,
|
|
1511
|
-
a.value ?
|
|
1514
|
+
he(F(ae.value), 1),
|
|
1515
|
+
u.isLast ? I("", !0) : (A(), C("span", et, ","))
|
|
1516
|
+
], 42, Je)),
|
|
1517
|
+
a.value ? le((A(), C("input", {
|
|
1512
1518
|
key: 4,
|
|
1513
|
-
"onUpdate:modelValue":
|
|
1519
|
+
"onUpdate:modelValue": E[7] || (E[7] = (l) => f.value = l),
|
|
1514
1520
|
onKeyup: [
|
|
1515
|
-
|
|
1516
|
-
|
|
1521
|
+
q(se, ["enter"]),
|
|
1522
|
+
q(oe, ["escape"])
|
|
1517
1523
|
],
|
|
1518
|
-
onBlur:
|
|
1524
|
+
onBlur: se,
|
|
1519
1525
|
class: "json-node__value-input"
|
|
1520
1526
|
}, null, 544)), [
|
|
1521
|
-
[
|
|
1522
|
-
]) :
|
|
1527
|
+
[ce, f.value]
|
|
1528
|
+
]) : I("", !0)
|
|
1523
1529
|
]))
|
|
1524
1530
|
]);
|
|
1525
1531
|
};
|
|
1526
1532
|
}
|
|
1527
|
-
}),
|
|
1533
|
+
}), me = (r, e) => {
|
|
1528
1534
|
const t = r.__vccOpts || r;
|
|
1529
1535
|
for (const [s, n] of e)
|
|
1530
1536
|
t[s] = n;
|
|
1531
1537
|
return t;
|
|
1532
|
-
},
|
|
1538
|
+
}, rt = /* @__PURE__ */ me(tt, [["__scopeId", "data-v-c799bdec"]]), Ee = {
|
|
1533
1539
|
name: "github-light",
|
|
1534
1540
|
colors: {
|
|
1535
1541
|
// 背景色
|
|
@@ -1568,7 +1574,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1568
1574
|
// 缩进线
|
|
1569
1575
|
indentLine: "#d0d7de"
|
|
1570
1576
|
}
|
|
1571
|
-
},
|
|
1577
|
+
}, nt = {
|
|
1572
1578
|
name: "github-dark",
|
|
1573
1579
|
colors: {
|
|
1574
1580
|
// 背景色
|
|
@@ -1607,7 +1613,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1607
1613
|
// 缩进线
|
|
1608
1614
|
indentLine: "#30363d"
|
|
1609
1615
|
}
|
|
1610
|
-
},
|
|
1616
|
+
}, st = {
|
|
1611
1617
|
name: "min-light",
|
|
1612
1618
|
colors: {
|
|
1613
1619
|
// 背景色 - 纯白简洁
|
|
@@ -1646,7 +1652,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1646
1652
|
// 缩进线
|
|
1647
1653
|
indentLine: "#e5e7eb"
|
|
1648
1654
|
}
|
|
1649
|
-
},
|
|
1655
|
+
}, ot = {
|
|
1650
1656
|
name: "slack-ochin",
|
|
1651
1657
|
colors: {
|
|
1652
1658
|
// 背景色 - 温暖的米色调
|
|
@@ -1685,34 +1691,34 @@ const Be = { class: "json-node" }, De = {
|
|
|
1685
1691
|
// 缩进线
|
|
1686
1692
|
indentLine: "#e8d5b7"
|
|
1687
1693
|
}
|
|
1688
|
-
},
|
|
1689
|
-
"github-light":
|
|
1690
|
-
"github-dark":
|
|
1691
|
-
"min-light":
|
|
1692
|
-
"slack-ochin":
|
|
1694
|
+
}, it = {
|
|
1695
|
+
"github-light": Ee,
|
|
1696
|
+
"github-dark": nt,
|
|
1697
|
+
"min-light": st,
|
|
1698
|
+
"slack-ochin": ot
|
|
1693
1699
|
};
|
|
1694
|
-
function
|
|
1695
|
-
return
|
|
1700
|
+
function at(r = "github-light") {
|
|
1701
|
+
return it[r] || Ee;
|
|
1696
1702
|
}
|
|
1697
|
-
const
|
|
1703
|
+
const lt = {
|
|
1698
1704
|
key: 0,
|
|
1699
1705
|
class: "json-format__toolbar"
|
|
1700
|
-
},
|
|
1706
|
+
}, ct = { class: "json-format__actions" }, ut = ["disabled"], dt = ["disabled"], ht = ["disabled"], ft = ["disabled"], pt = { class: "json-format__info" }, yt = {
|
|
1701
1707
|
key: 0,
|
|
1702
1708
|
class: "json-format__status json-format__status--success"
|
|
1703
|
-
},
|
|
1709
|
+
}, gt = {
|
|
1704
1710
|
key: 1,
|
|
1705
1711
|
class: "json-format__status json-format__status--error"
|
|
1706
|
-
},
|
|
1712
|
+
}, bt = { class: "json-format__content" }, mt = {
|
|
1707
1713
|
key: 0,
|
|
1708
1714
|
class: "json-format__error"
|
|
1709
|
-
},
|
|
1715
|
+
}, Et = {
|
|
1710
1716
|
key: 1,
|
|
1711
1717
|
class: "json-format__error"
|
|
1712
|
-
},
|
|
1718
|
+
}, vt = {
|
|
1713
1719
|
key: 2,
|
|
1714
1720
|
class: "json-format__viewer"
|
|
1715
|
-
},
|
|
1721
|
+
}, _t = /* @__PURE__ */ pe({
|
|
1716
1722
|
name: "JsonFormat",
|
|
1717
1723
|
__name: "index",
|
|
1718
1724
|
props: {
|
|
@@ -1724,62 +1730,102 @@ const tt = {
|
|
|
1724
1730
|
},
|
|
1725
1731
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1726
1732
|
setup(r, { expose: e, emit: t }) {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
"
|
|
1730
|
-
"
|
|
1731
|
-
|
|
1732
|
-
"
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
"
|
|
1737
|
-
|
|
1738
|
-
"
|
|
1739
|
-
"
|
|
1740
|
-
|
|
1741
|
-
"
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1733
|
+
ye((i) => ({
|
|
1734
|
+
"4580f20e": b.value.colors.border,
|
|
1735
|
+
"1c771210": b.value.colors.background,
|
|
1736
|
+
"7594d38f": b.value.colors.text,
|
|
1737
|
+
"75ad6ace": b.value.colors.surfaceBackground,
|
|
1738
|
+
"0a74e660": b.value.colors.buttonBorder,
|
|
1739
|
+
ba56e53c: b.value.colors.buttonBackground,
|
|
1740
|
+
fd84973e: b.value.colors.buttonText,
|
|
1741
|
+
"486158fa": b.value.colors.buttonBackgroundHover,
|
|
1742
|
+
"2d62e24e": b.value.colors.buttonPrimary,
|
|
1743
|
+
"105f378e": b.value.colors.buttonPrimaryHover,
|
|
1744
|
+
"355cea6f": b.value.colors.successBackground,
|
|
1745
|
+
"115f033e": b.value.colors.success,
|
|
1746
|
+
acd7cc98: b.value.colors.errorBackground,
|
|
1747
|
+
"3c380fe6": b.value.colors.error,
|
|
1748
|
+
d66942b2: b.value.colors.scrollbarTrack,
|
|
1749
|
+
d671c19c: b.value.colors.scrollbarThumb,
|
|
1750
|
+
e15d2dac: b.value.colors.scrollbarThumbHover
|
|
1745
1751
|
}));
|
|
1746
|
-
const s = r, n = t, a =
|
|
1752
|
+
const s = r, n = t, a = H(null), c = H(""), f = H(/* @__PURE__ */ new Set()), h = H(null), d = H(""), _ = j(() => c.value === ""), b = j(() => at(s.theme)), x = j(() => d.value ? null : h.value !== null ? h.value : a.value), g = (i) => {
|
|
1747
1753
|
if (!i.trim()) {
|
|
1748
|
-
a.value = null, c.value = "",
|
|
1754
|
+
a.value = null, c.value = "", h.value = null, d.value = "";
|
|
1749
1755
|
return;
|
|
1750
1756
|
}
|
|
1751
1757
|
try {
|
|
1752
1758
|
let l = i;
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1759
|
+
const m = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(l), p = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(l);
|
|
1760
|
+
if (!m && !p)
|
|
1761
|
+
try {
|
|
1762
|
+
a.value = JSON.parse(l), c.value = "", h.value = null, d.value = "", ee(() => {
|
|
1763
|
+
x.value !== null && Q();
|
|
1764
|
+
});
|
|
1765
|
+
return;
|
|
1766
|
+
} catch {
|
|
1767
|
+
}
|
|
1768
|
+
const y = (P, N, D) => {
|
|
1769
|
+
let V = "", R = !1, L = !1, U = 0;
|
|
1770
|
+
for (; U < P.length; ) {
|
|
1771
|
+
const T = P[U];
|
|
1772
|
+
if (R)
|
|
1773
|
+
L ? L = !1 : T === "\\" ? L = !0 : T === '"' && (R = !1), V += T, U++;
|
|
1774
|
+
else if (T === '"')
|
|
1775
|
+
R = !0, V += T, U++;
|
|
1776
|
+
else {
|
|
1777
|
+
const ie = P.slice(U).match(N);
|
|
1778
|
+
if (ie && ie.index === 0) {
|
|
1779
|
+
const ve = ie[0].replace(N, D);
|
|
1780
|
+
V += ve, U += ie[0].length;
|
|
1781
|
+
} else
|
|
1782
|
+
V += T, U++;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return V;
|
|
1786
|
+
};
|
|
1787
|
+
l = ((P) => {
|
|
1788
|
+
let N = "", D = !1, V = !1, R = 0;
|
|
1789
|
+
for (; R < P.length; ) {
|
|
1790
|
+
const L = P[R];
|
|
1791
|
+
if (D)
|
|
1792
|
+
V ? V = !1 : L === "\\" ? V = !0 : L === '"' && (D = !1), N += L, R++;
|
|
1793
|
+
else if (L === '"')
|
|
1794
|
+
D = !0, N += L, R++;
|
|
1795
|
+
else {
|
|
1796
|
+
const U = P.slice(R);
|
|
1797
|
+
let T = U.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1798
|
+
if (T) {
|
|
1799
|
+
N += T[1] + '"' + T[2] + '"' + T[3], R += T[0].length;
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1802
|
+
if (T = U.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), T) {
|
|
1803
|
+
N += T[1] + '"' + T[2] + '"' + T[3], R += T[0].length;
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
N += L, R++;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
return N;
|
|
1810
|
+
})(l), a.value = JSON.parse(l), c.value = "", h.value = null, d.value = "", ee(() => {
|
|
1811
|
+
x.value !== null && Q();
|
|
1766
1812
|
});
|
|
1767
1813
|
} catch (l) {
|
|
1768
|
-
c.value = l instanceof Error ? l.message : "Unknown parsing error", a.value = null,
|
|
1814
|
+
c.value = l instanceof Error ? l.message : "Unknown parsing error", a.value = null, h.value = null, d.value = "";
|
|
1769
1815
|
}
|
|
1770
|
-
},
|
|
1816
|
+
}, w = (i) => {
|
|
1771
1817
|
if (!i || !i.expression.trim()) {
|
|
1772
|
-
|
|
1818
|
+
S();
|
|
1773
1819
|
return;
|
|
1774
1820
|
}
|
|
1775
1821
|
if (!a.value) {
|
|
1776
|
-
|
|
1822
|
+
d.value = "No valid JSON data to filter";
|
|
1777
1823
|
return;
|
|
1778
1824
|
}
|
|
1779
1825
|
try {
|
|
1780
1826
|
let l;
|
|
1781
1827
|
if (i.type === "jsonpath")
|
|
1782
|
-
l =
|
|
1828
|
+
l = k({ path: i.expression, json: a.value }), l.length === 1 && i.expression.includes("$[") === !1 && !i.expression.endsWith("[*]") ? h.value = l[0] : h.value = l;
|
|
1783
1829
|
else if (i.type === "js")
|
|
1784
1830
|
l = new Function("data", `
|
|
1785
1831
|
try {
|
|
@@ -1787,249 +1833,249 @@ const tt = {
|
|
|
1787
1833
|
} catch (error) {
|
|
1788
1834
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1789
1835
|
}
|
|
1790
|
-
`)(a.value),
|
|
1836
|
+
`)(a.value), h.value = l;
|
|
1791
1837
|
else
|
|
1792
1838
|
throw new Error(`Unsupported filter type: ${i.type}`);
|
|
1793
|
-
|
|
1794
|
-
|
|
1839
|
+
d.value = "", ee(() => {
|
|
1840
|
+
Q();
|
|
1795
1841
|
});
|
|
1796
1842
|
} catch (l) {
|
|
1797
|
-
|
|
1843
|
+
d.value = l instanceof Error ? l.message : "Filter execution error", h.value = null;
|
|
1798
1844
|
}
|
|
1799
|
-
},
|
|
1800
|
-
|
|
1845
|
+
}, S = () => {
|
|
1846
|
+
h.value = null, d.value = "";
|
|
1801
1847
|
};
|
|
1802
|
-
|
|
1803
|
-
|
|
1848
|
+
Oe(() => s.modelValue, (i) => {
|
|
1849
|
+
g(i);
|
|
1804
1850
|
}, { immediate: !0 });
|
|
1805
|
-
const
|
|
1851
|
+
const M = (i) => {
|
|
1806
1852
|
if (!/^-?\d+(\.\d+)?$/.test(i)) return !1;
|
|
1807
1853
|
const l = Number(i);
|
|
1808
1854
|
return !Number.isSafeInteger(l) || i.length > 15;
|
|
1809
|
-
},
|
|
1810
|
-
if (typeof
|
|
1811
|
-
return `__BIG_NUMBER__${
|
|
1812
|
-
if (typeof
|
|
1813
|
-
const
|
|
1814
|
-
if (Number.isSafeInteger(
|
|
1815
|
-
return
|
|
1816
|
-
if (!Number.isNaN(
|
|
1817
|
-
return
|
|
1818
|
-
if (!Number.isNaN(
|
|
1819
|
-
return
|
|
1855
|
+
}, $ = (i, l, m) => JSON.stringify(i, (p, y) => {
|
|
1856
|
+
if (typeof y == "string" && M(y))
|
|
1857
|
+
return `__BIG_NUMBER__${y}__BIG_NUMBER__`;
|
|
1858
|
+
if (typeof y == "string" && /^-?\d+(\.\d+)?$/.test(y)) {
|
|
1859
|
+
const v = Number(y);
|
|
1860
|
+
if (Number.isSafeInteger(v) && v.toString() === y)
|
|
1861
|
+
return v;
|
|
1862
|
+
if (!Number.isNaN(v) && isFinite(v) && y.includes("."))
|
|
1863
|
+
return v.toString() === y ? v : `__PRESERVE_STRING__${y}__PRESERVE_STRING__`;
|
|
1864
|
+
if (!Number.isNaN(v) && isFinite(v))
|
|
1865
|
+
return v;
|
|
1820
1866
|
}
|
|
1821
|
-
return l && typeof l == "function" ? l(p,
|
|
1822
|
-
},
|
|
1867
|
+
return l && typeof l == "function" ? l(p, y) : y;
|
|
1868
|
+
}, m).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g, "$1").replace(/"__PRESERVE_STRING__(.+?)__PRESERVE_STRING__"/g, "$1"), W = (i, l) => {
|
|
1823
1869
|
if (!s.readonly)
|
|
1824
1870
|
try {
|
|
1825
|
-
const
|
|
1871
|
+
const m = ae(a.value, i, l), p = $(m, null, 2);
|
|
1826
1872
|
n("update:modelValue", p);
|
|
1827
|
-
} catch (
|
|
1828
|
-
console.error("Failed to update JSON:",
|
|
1873
|
+
} catch (m) {
|
|
1874
|
+
console.error("Failed to update JSON:", m);
|
|
1829
1875
|
}
|
|
1830
|
-
},
|
|
1831
|
-
if (!l || l === "root") return
|
|
1832
|
-
const p = l.split("."),
|
|
1833
|
-
let
|
|
1834
|
-
for (let
|
|
1835
|
-
const
|
|
1836
|
-
|
|
1876
|
+
}, ae = (i, l, m) => {
|
|
1877
|
+
if (!l || l === "root") return m;
|
|
1878
|
+
const p = l.split("."), y = X(i, p.slice(0, -1));
|
|
1879
|
+
let v = y;
|
|
1880
|
+
for (let N = 0; N < p.length - 1; N++) {
|
|
1881
|
+
const D = p[N];
|
|
1882
|
+
D !== "root" && (Array.isArray(v) ? v = v[parseInt(D)] : v = v[D]);
|
|
1837
1883
|
}
|
|
1838
|
-
const
|
|
1839
|
-
return
|
|
1840
|
-
},
|
|
1884
|
+
const P = p[p.length - 1];
|
|
1885
|
+
return P === "root" ? m : (Array.isArray(v) ? v[parseInt(P)] = m : v[P] = m, y);
|
|
1886
|
+
}, te = (i) => {
|
|
1841
1887
|
f.value.has(i) ? f.value.delete(i) : f.value.add(i);
|
|
1842
|
-
},
|
|
1843
|
-
const i = /* @__PURE__ */ new Set(), l = (
|
|
1844
|
-
|
|
1845
|
-
const
|
|
1846
|
-
l(
|
|
1847
|
-
}) : Object.keys(
|
|
1848
|
-
const
|
|
1849
|
-
l(y
|
|
1888
|
+
}, Q = () => {
|
|
1889
|
+
const i = /* @__PURE__ */ new Set(), l = (m, p = "") => {
|
|
1890
|
+
m !== null && typeof m == "object" && (i.add(p || "root"), Array.isArray(m) ? m.forEach((y, v) => {
|
|
1891
|
+
const P = p ? `${p}.${v}` : `${v}`;
|
|
1892
|
+
l(y, P);
|
|
1893
|
+
}) : Object.keys(m).forEach((y) => {
|
|
1894
|
+
const v = p ? `${p}.${y}` : y;
|
|
1895
|
+
l(m[y], v);
|
|
1850
1896
|
}));
|
|
1851
1897
|
};
|
|
1852
|
-
l(
|
|
1853
|
-
},
|
|
1898
|
+
l(x.value), f.value = i, n("expand-all");
|
|
1899
|
+
}, re = () => {
|
|
1854
1900
|
f.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1855
|
-
},
|
|
1856
|
-
if (
|
|
1901
|
+
}, Z = async () => {
|
|
1902
|
+
if (_.value)
|
|
1857
1903
|
try {
|
|
1858
|
-
const i =
|
|
1904
|
+
const i = x.value, l = $(i, null, 2);
|
|
1859
1905
|
await navigator.clipboard.writeText(l), n("copy-success", l);
|
|
1860
1906
|
} catch (i) {
|
|
1861
1907
|
console.error("Failed to copy JSON:", i), n("copy-error", i instanceof Error ? i : new Error("Failed to copy JSON"));
|
|
1862
1908
|
}
|
|
1863
|
-
},
|
|
1864
|
-
if (
|
|
1909
|
+
}, J = () => {
|
|
1910
|
+
if (_.value)
|
|
1865
1911
|
try {
|
|
1866
|
-
const i =
|
|
1912
|
+
const i = x.value, l = $(i);
|
|
1867
1913
|
n("update:modelValue", l), n("compress", l);
|
|
1868
1914
|
} catch (i) {
|
|
1869
1915
|
console.error("Failed to compress JSON:", i);
|
|
1870
1916
|
}
|
|
1871
|
-
},
|
|
1917
|
+
}, ne = async (i) => {
|
|
1872
1918
|
try {
|
|
1873
1919
|
let l;
|
|
1874
|
-
typeof i == "string" &&
|
|
1920
|
+
typeof i == "string" && M(i) ? l = i : typeof i == "string" ? l = `"${i}"` : l = JSON.stringify(i), await navigator.clipboard.writeText(l);
|
|
1875
1921
|
} catch (l) {
|
|
1876
1922
|
console.error("Failed to copy value:", l);
|
|
1877
1923
|
}
|
|
1878
|
-
},
|
|
1924
|
+
}, Y = (i, l) => {
|
|
1879
1925
|
if (!s.readonly)
|
|
1880
1926
|
try {
|
|
1881
|
-
const
|
|
1882
|
-
n("update:modelValue", p),
|
|
1883
|
-
} catch (
|
|
1884
|
-
console.error("Failed to rename key:",
|
|
1927
|
+
const m = se(a.value, i, l), p = $(m, null, 2);
|
|
1928
|
+
n("update:modelValue", p), E(i, l);
|
|
1929
|
+
} catch (m) {
|
|
1930
|
+
console.error("Failed to rename key:", m);
|
|
1885
1931
|
}
|
|
1886
|
-
},
|
|
1932
|
+
}, se = (i, l, m) => {
|
|
1887
1933
|
if (!l || l === "root") return i;
|
|
1888
|
-
const p = l.split("."),
|
|
1934
|
+
const p = l.split("."), y = X(i, p.slice(0, -1));
|
|
1889
1935
|
if (p.length === 1) {
|
|
1890
|
-
const
|
|
1891
|
-
return
|
|
1936
|
+
const N = p[0];
|
|
1937
|
+
return y && typeof y == "object" && !Array.isArray(y) ? oe(y, N, m) : y;
|
|
1892
1938
|
}
|
|
1893
|
-
let
|
|
1894
|
-
for (let
|
|
1895
|
-
const
|
|
1896
|
-
Array.isArray(
|
|
1939
|
+
let v = y;
|
|
1940
|
+
for (let N = 0; N < p.length - 1; N++) {
|
|
1941
|
+
const D = p[N];
|
|
1942
|
+
Array.isArray(v) ? v = v[parseInt(D)] : v = v[D];
|
|
1897
1943
|
}
|
|
1898
|
-
const
|
|
1899
|
-
if (!Array.isArray(
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1944
|
+
const P = p[p.length - 1];
|
|
1945
|
+
if (!Array.isArray(v) && v && typeof v == "object") {
|
|
1946
|
+
const N = oe(v, P, m), D = p.slice(0, -1);
|
|
1947
|
+
D.length > 0 && u(y, D, N);
|
|
1902
1948
|
}
|
|
1903
|
-
return
|
|
1904
|
-
},
|
|
1949
|
+
return y;
|
|
1950
|
+
}, X = (i, l) => {
|
|
1905
1951
|
if (l.length === 0) return i;
|
|
1906
1952
|
if (Array.isArray(i)) {
|
|
1907
|
-
const
|
|
1908
|
-
return l.length === 1 || (y
|
|
1953
|
+
const m = [...i], p = l[0], y = parseInt(p);
|
|
1954
|
+
return l.length === 1 || (m[y] = X(i[y], l.slice(1))), m;
|
|
1909
1955
|
} else if (i && typeof i == "object") {
|
|
1910
|
-
const
|
|
1911
|
-
return l.length === 1 || (
|
|
1956
|
+
const m = { ...i }, p = l[0];
|
|
1957
|
+
return l.length === 1 || (m[p] = X(i[p], l.slice(1))), m;
|
|
1912
1958
|
}
|
|
1913
1959
|
return i;
|
|
1914
|
-
},
|
|
1960
|
+
}, oe = (i, l, m) => {
|
|
1915
1961
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
1916
1962
|
return i;
|
|
1917
|
-
const p = Object.keys(i),
|
|
1918
|
-
for (const
|
|
1919
|
-
|
|
1920
|
-
return
|
|
1921
|
-
},
|
|
1963
|
+
const p = Object.keys(i), y = {};
|
|
1964
|
+
for (const v of p)
|
|
1965
|
+
v === l ? y[m] = i[v] : y[v] = i[v];
|
|
1966
|
+
return y;
|
|
1967
|
+
}, u = (i, l, m) => {
|
|
1922
1968
|
let p = i;
|
|
1923
|
-
for (let
|
|
1924
|
-
const
|
|
1925
|
-
Array.isArray(p) ? p = p[parseInt(
|
|
1969
|
+
for (let v = 0; v < l.length - 1; v++) {
|
|
1970
|
+
const P = l[v];
|
|
1971
|
+
Array.isArray(p) ? p = p[parseInt(P)] : p = p[P];
|
|
1926
1972
|
}
|
|
1927
|
-
const
|
|
1928
|
-
Array.isArray(p) ? p[parseInt(
|
|
1929
|
-
},
|
|
1930
|
-
const
|
|
1973
|
+
const y = l[l.length - 1];
|
|
1974
|
+
Array.isArray(p) ? p[parseInt(y)] = m : p[y] = m;
|
|
1975
|
+
}, E = (i, l) => {
|
|
1976
|
+
const m = /* @__PURE__ */ new Set();
|
|
1931
1977
|
f.value.forEach((p) => {
|
|
1932
1978
|
if (p === i) {
|
|
1933
|
-
const
|
|
1934
|
-
|
|
1979
|
+
const y = i.split(".");
|
|
1980
|
+
y[y.length - 1] = l, m.add(y.join("."));
|
|
1935
1981
|
} else if (p.startsWith(i + ".")) {
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1982
|
+
const y = i.split(".");
|
|
1983
|
+
y[y.length - 1] = l;
|
|
1984
|
+
const v = y.join("."), P = p.substring(i.length);
|
|
1985
|
+
m.add(v + P);
|
|
1940
1986
|
} else
|
|
1941
|
-
|
|
1942
|
-
}), f.value =
|
|
1987
|
+
m.add(p);
|
|
1988
|
+
}), f.value = m;
|
|
1943
1989
|
};
|
|
1944
1990
|
return e({
|
|
1945
1991
|
// 核心操作方法
|
|
1946
|
-
copyJson:
|
|
1947
|
-
compressSource:
|
|
1948
|
-
expandAll:
|
|
1949
|
-
collapseAll:
|
|
1950
|
-
toggleExpand:
|
|
1951
|
-
updateValue:
|
|
1952
|
-
updateKey:
|
|
1992
|
+
copyJson: Z,
|
|
1993
|
+
compressSource: J,
|
|
1994
|
+
expandAll: Q,
|
|
1995
|
+
collapseAll: re,
|
|
1996
|
+
toggleExpand: te,
|
|
1997
|
+
updateValue: W,
|
|
1998
|
+
updateKey: Y,
|
|
1953
1999
|
// Filter 相关方法
|
|
1954
|
-
filter:
|
|
1955
|
-
clearFilter:
|
|
2000
|
+
filter: w,
|
|
2001
|
+
clearFilter: S,
|
|
1956
2002
|
// 状态访问方法
|
|
1957
|
-
isValidJson: () =>
|
|
2003
|
+
isValidJson: () => _.value,
|
|
1958
2004
|
getParsedJson: () => a.value,
|
|
1959
|
-
getFilteredJson: () =>
|
|
2005
|
+
getFilteredJson: () => h.value,
|
|
1960
2006
|
getExpandedNodes: () => f.value,
|
|
1961
2007
|
getParseError: () => c.value,
|
|
1962
|
-
getFilterError: () =>
|
|
2008
|
+
getFilterError: () => d.value,
|
|
1963
2009
|
// 工具方法
|
|
1964
|
-
parseJson: (i) =>
|
|
1965
|
-
copyValue: (i) =>
|
|
1966
|
-
}), (i, l) => (
|
|
1967
|
-
class:
|
|
2010
|
+
parseJson: (i) => g(i),
|
|
2011
|
+
copyValue: (i) => ne(i)
|
|
2012
|
+
}), (i, l) => (A(), C("div", {
|
|
2013
|
+
class: be(["json-format", `json-format--${b.value.name}`])
|
|
1968
2014
|
}, [
|
|
1969
|
-
i.showToolbar ? (
|
|
1970
|
-
|
|
1971
|
-
|
|
2015
|
+
i.showToolbar ? (A(), C("div", lt, [
|
|
2016
|
+
B("div", ct, [
|
|
2017
|
+
B("button", {
|
|
1972
2018
|
class: "json-format__btn json-format__btn--primary",
|
|
1973
|
-
onClick:
|
|
1974
|
-
disabled: !
|
|
2019
|
+
onClick: Z,
|
|
2020
|
+
disabled: !_.value,
|
|
1975
2021
|
title: "Copy JSON"
|
|
1976
|
-
}, " 📋 Copy ", 8,
|
|
1977
|
-
|
|
2022
|
+
}, " 📋 Copy ", 8, ut),
|
|
2023
|
+
B("button", {
|
|
1978
2024
|
class: "json-format__btn json-format__btn--secondary",
|
|
1979
|
-
onClick:
|
|
1980
|
-
disabled: !
|
|
2025
|
+
onClick: Q,
|
|
2026
|
+
disabled: !_.value,
|
|
1981
2027
|
title: "Expand All"
|
|
1982
|
-
}, " ⬇️ Expand All ", 8,
|
|
1983
|
-
|
|
2028
|
+
}, " ⬇️ Expand All ", 8, dt),
|
|
2029
|
+
B("button", {
|
|
1984
2030
|
class: "json-format__btn json-format__btn--secondary",
|
|
1985
|
-
onClick:
|
|
1986
|
-
disabled: !
|
|
2031
|
+
onClick: re,
|
|
2032
|
+
disabled: !_.value,
|
|
1987
2033
|
title: "Collapse All"
|
|
1988
|
-
}, " ➡️ Collapse All ", 8,
|
|
1989
|
-
|
|
2034
|
+
}, " ➡️ Collapse All ", 8, ht),
|
|
2035
|
+
B("button", {
|
|
1990
2036
|
class: "json-format__btn json-format__btn--secondary",
|
|
1991
|
-
onClick:
|
|
1992
|
-
disabled: !
|
|
2037
|
+
onClick: J,
|
|
2038
|
+
disabled: !_.value,
|
|
1993
2039
|
title: "Compress JSON"
|
|
1994
|
-
}, " 📦 Compress ", 8,
|
|
2040
|
+
}, " 📦 Compress ", 8, ft)
|
|
1995
2041
|
]),
|
|
1996
|
-
|
|
1997
|
-
|
|
2042
|
+
B("div", pt, [
|
|
2043
|
+
_.value ? (A(), C("span", yt, " ✅ Valid JSON ")) : (A(), C("span", gt, " ❌ Invalid JSON "))
|
|
1998
2044
|
])
|
|
1999
|
-
])) :
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
l[1] || (l[1] =
|
|
2003
|
-
|
|
2004
|
-
])) : (
|
|
2005
|
-
|
|
2006
|
-
value:
|
|
2045
|
+
])) : I("", !0),
|
|
2046
|
+
B("div", bt, [
|
|
2047
|
+
_.value ? d.value ? (A(), C("div", Et, [
|
|
2048
|
+
l[1] || (l[1] = B("h4", null, "Filter Error:", -1)),
|
|
2049
|
+
B("pre", null, F(d.value), 1)
|
|
2050
|
+
])) : (A(), C("div", vt, [
|
|
2051
|
+
ge(rt, {
|
|
2052
|
+
value: x.value,
|
|
2007
2053
|
"key-name": "",
|
|
2008
2054
|
level: 0,
|
|
2009
2055
|
expanded: f.value,
|
|
2010
2056
|
"is-last": !0,
|
|
2011
|
-
theme:
|
|
2012
|
-
"onUpdate:value":
|
|
2013
|
-
onToggleExpand:
|
|
2014
|
-
onCopy:
|
|
2015
|
-
"onUpdate:key":
|
|
2057
|
+
theme: b.value,
|
|
2058
|
+
"onUpdate:value": W,
|
|
2059
|
+
onToggleExpand: te,
|
|
2060
|
+
onCopy: ne,
|
|
2061
|
+
"onUpdate:key": Y
|
|
2016
2062
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2017
|
-
])) : (
|
|
2018
|
-
l[0] || (l[0] =
|
|
2019
|
-
|
|
2063
|
+
])) : (A(), C("div", mt, [
|
|
2064
|
+
l[0] || (l[0] = B("h4", null, "JSON Parse Error:", -1)),
|
|
2065
|
+
B("pre", null, F(c.value), 1)
|
|
2020
2066
|
]))
|
|
2021
2067
|
])
|
|
2022
2068
|
], 2));
|
|
2023
2069
|
}
|
|
2024
|
-
}),
|
|
2025
|
-
|
|
2070
|
+
}), xt = /* @__PURE__ */ me(_t, [["__scopeId", "data-v-632b8436"]]), kt = [xt], Ot = (r) => {
|
|
2071
|
+
kt.forEach((e) => {
|
|
2026
2072
|
const t = e.name || e.__name || "UnknownComponent";
|
|
2027
2073
|
r.component(t, e);
|
|
2028
2074
|
});
|
|
2029
|
-
},
|
|
2030
|
-
install:
|
|
2075
|
+
}, St = {
|
|
2076
|
+
install: Ot
|
|
2031
2077
|
};
|
|
2032
2078
|
export {
|
|
2033
|
-
|
|
2034
|
-
|
|
2079
|
+
xt as JsonFormat,
|
|
2080
|
+
St as default
|
|
2035
2081
|
};
|