lone-format 0.1.6 → 0.2.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/README.md +78 -1
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +504 -493
- package/dist/lone-format.umd.cjs +3 -3
- package/package.json +8 -4
package/dist/lone-format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as le, useCssVars as ce, ref as R, computed as T, resolveComponent as pe, createElementBlock as A, openBlock as w, createElementVNode as P, createCommentVNode as N, withDirectives as re, toDisplayString as $, withKeys as X, vModelText as ne, createTextVNode as ie, Fragment as ye, renderList as be, createVNode as ue, normalizeClass as de, nextTick as
|
|
1
|
+
import { defineComponent as le, useCssVars as ce, ref as R, computed as T, resolveComponent as pe, createElementBlock as A, openBlock as w, createElementVNode as P, createCommentVNode as N, withDirectives as re, toDisplayString as $, withKeys as X, vModelText as ne, createTextVNode as ie, Fragment as ye, renderList as be, createVNode as ue, normalizeClass as de, nextTick as Z, watch as ge } from "vue";
|
|
2
2
|
class Ee {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
@@ -18,13 +18,13 @@ class Ee {
|
|
|
18
18
|
* @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
|
-
add(e, t,
|
|
21
|
+
add(e, t, s) {
|
|
22
22
|
if (typeof arguments[0] != "string")
|
|
23
23
|
for (let n in arguments[0])
|
|
24
24
|
this.add(n, arguments[0][n], arguments[1]);
|
|
25
25
|
else
|
|
26
26
|
(Array.isArray(e) ? e : [e]).forEach(function(n) {
|
|
27
|
-
this[n] = this[n] || [], t && this[n][
|
|
27
|
+
this[n] = this[n] || [], t && this[n][s ? "unshift" : "push"](t);
|
|
28
28
|
}, this);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -37,8 +37,8 @@ class Ee {
|
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
39
|
run(e, t) {
|
|
40
|
-
this[e] = this[e] || [], this[e].forEach(function(
|
|
41
|
-
|
|
40
|
+
this[e] = this[e] || [], this[e].forEach(function(s) {
|
|
41
|
+
s.call(t && t.context ? t.context : t, t);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -60,8 +60,8 @@ class me {
|
|
|
60
60
|
* @public
|
|
61
61
|
*/
|
|
62
62
|
register() {
|
|
63
|
-
for (var e = arguments.length, t = new Array(e),
|
|
64
|
-
t[
|
|
63
|
+
for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
|
|
64
|
+
t[s] = arguments[s];
|
|
65
65
|
t.forEach((n) => {
|
|
66
66
|
if (typeof n != "object" || !n.name || !n.init)
|
|
67
67
|
throw new Error("Invalid JSEP plugin format");
|
|
@@ -69,7 +69,7 @@ class me {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class o {
|
|
73
73
|
/**
|
|
74
74
|
* @returns {string}
|
|
75
75
|
*/
|
|
@@ -80,7 +80,7 @@ class s {
|
|
|
80
80
|
* @returns {string}
|
|
81
81
|
*/
|
|
82
82
|
static toString() {
|
|
83
|
-
return "JavaScript Expression Parser (JSEP) v" +
|
|
83
|
+
return "JavaScript Expression Parser (JSEP) v" + o.version;
|
|
84
84
|
}
|
|
85
85
|
// ==================== CONFIG ================================
|
|
86
86
|
/**
|
|
@@ -89,7 +89,7 @@ class s {
|
|
|
89
89
|
* @returns {Jsep}
|
|
90
90
|
*/
|
|
91
91
|
static addUnaryOp(e) {
|
|
92
|
-
return
|
|
92
|
+
return o.max_unop_len = Math.max(e.length, o.max_unop_len), o.unary_ops[e] = 1, o;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* @method jsep.addBinaryOp
|
|
@@ -98,8 +98,8 @@ class s {
|
|
|
98
98
|
* @param {boolean} [isRightAssociative=false] whether operator is right-associative
|
|
99
99
|
* @returns {Jsep}
|
|
100
100
|
*/
|
|
101
|
-
static addBinaryOp(e, t,
|
|
102
|
-
return
|
|
101
|
+
static addBinaryOp(e, t, s) {
|
|
102
|
+
return o.max_binop_len = Math.max(e.length, o.max_binop_len), o.binary_ops[e] = t, s ? o.right_associative.add(e) : o.right_associative.delete(e), o;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* @method addIdentifierChar
|
|
@@ -107,7 +107,7 @@ class s {
|
|
|
107
107
|
* @returns {Jsep}
|
|
108
108
|
*/
|
|
109
109
|
static addIdentifierChar(e) {
|
|
110
|
-
return
|
|
110
|
+
return o.additional_identifier_chars.add(e), o;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* @method addLiteral
|
|
@@ -116,7 +116,7 @@ class s {
|
|
|
116
116
|
* @returns {Jsep}
|
|
117
117
|
*/
|
|
118
118
|
static addLiteral(e, t) {
|
|
119
|
-
return
|
|
119
|
+
return o.literals[e] = t, o;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* @method removeUnaryOp
|
|
@@ -124,14 +124,14 @@ class s {
|
|
|
124
124
|
* @returns {Jsep}
|
|
125
125
|
*/
|
|
126
126
|
static removeUnaryOp(e) {
|
|
127
|
-
return delete
|
|
127
|
+
return delete o.unary_ops[e], e.length === o.max_unop_len && (o.max_unop_len = o.getMaxKeyLen(o.unary_ops)), o;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* @method removeAllUnaryOps
|
|
131
131
|
* @returns {Jsep}
|
|
132
132
|
*/
|
|
133
133
|
static removeAllUnaryOps() {
|
|
134
|
-
return
|
|
134
|
+
return o.unary_ops = {}, o.max_unop_len = 0, o;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* @method removeIdentifierChar
|
|
@@ -139,7 +139,7 @@ class s {
|
|
|
139
139
|
* @returns {Jsep}
|
|
140
140
|
*/
|
|
141
141
|
static removeIdentifierChar(e) {
|
|
142
|
-
return
|
|
142
|
+
return o.additional_identifier_chars.delete(e), o;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @method removeBinaryOp
|
|
@@ -147,14 +147,14 @@ class s {
|
|
|
147
147
|
* @returns {Jsep}
|
|
148
148
|
*/
|
|
149
149
|
static removeBinaryOp(e) {
|
|
150
|
-
return delete
|
|
150
|
+
return delete o.binary_ops[e], e.length === o.max_binop_len && (o.max_binop_len = o.getMaxKeyLen(o.binary_ops)), o.right_associative.delete(e), o;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* @method removeAllBinaryOps
|
|
154
154
|
* @returns {Jsep}
|
|
155
155
|
*/
|
|
156
156
|
static removeAllBinaryOps() {
|
|
157
|
-
return
|
|
157
|
+
return o.binary_ops = {}, o.max_binop_len = 0, o;
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* @method removeLiteral
|
|
@@ -162,14 +162,14 @@ class s {
|
|
|
162
162
|
* @returns {Jsep}
|
|
163
163
|
*/
|
|
164
164
|
static removeLiteral(e) {
|
|
165
|
-
return delete
|
|
165
|
+
return delete o.literals[e], o;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* @method removeAllLiterals
|
|
169
169
|
* @returns {Jsep}
|
|
170
170
|
*/
|
|
171
171
|
static removeAllLiterals() {
|
|
172
|
-
return
|
|
172
|
+
return o.literals = {}, o;
|
|
173
173
|
}
|
|
174
174
|
// ==================== END CONFIG ============================
|
|
175
175
|
/**
|
|
@@ -196,7 +196,7 @@ class s {
|
|
|
196
196
|
* @returns {jsep.Expression}
|
|
197
197
|
*/
|
|
198
198
|
static parse(e) {
|
|
199
|
-
return new
|
|
199
|
+
return new o(e).parse();
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Get the longest key length of any object
|
|
@@ -220,7 +220,7 @@ class s {
|
|
|
220
220
|
* @returns {number}
|
|
221
221
|
*/
|
|
222
222
|
static binaryPrecedence(e) {
|
|
223
|
-
return
|
|
223
|
+
return o.binary_ops[e] || 0;
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* Looks for start of identifier
|
|
@@ -230,15 +230,15 @@ class s {
|
|
|
230
230
|
static isIdentifierStart(e) {
|
|
231
231
|
return e >= 65 && e <= 90 || // A...Z
|
|
232
232
|
e >= 97 && e <= 122 || // a...z
|
|
233
|
-
e >= 128 && !
|
|
234
|
-
|
|
233
|
+
e >= 128 && !o.binary_ops[String.fromCharCode(e)] || // any non-ASCII that is not an operator
|
|
234
|
+
o.additional_identifier_chars.has(String.fromCharCode(e));
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
237
|
* @param {number} ch
|
|
238
238
|
* @returns {boolean}
|
|
239
239
|
*/
|
|
240
240
|
static isIdentifierPart(e) {
|
|
241
|
-
return
|
|
241
|
+
return o.isIdentifierStart(e) || o.isDecimalDigit(e);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* throw error at index of the expression
|
|
@@ -256,12 +256,12 @@ class s {
|
|
|
256
256
|
* @returns {?jsep.Expression}
|
|
257
257
|
*/
|
|
258
258
|
runHook(e, t) {
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
259
|
+
if (o.hooks[e]) {
|
|
260
|
+
const s = {
|
|
261
261
|
context: this,
|
|
262
262
|
node: t
|
|
263
263
|
};
|
|
264
|
-
return
|
|
264
|
+
return o.hooks.run(e, s), s.node;
|
|
265
265
|
}
|
|
266
266
|
return t;
|
|
267
267
|
}
|
|
@@ -271,12 +271,12 @@ class s {
|
|
|
271
271
|
* @returns {?jsep.Expression}
|
|
272
272
|
*/
|
|
273
273
|
searchHook(e) {
|
|
274
|
-
if (
|
|
274
|
+
if (o.hooks[e]) {
|
|
275
275
|
const t = {
|
|
276
276
|
context: this
|
|
277
277
|
};
|
|
278
|
-
return
|
|
279
|
-
return
|
|
278
|
+
return o.hooks[e].find(function(s) {
|
|
279
|
+
return s.call(t.context, t), t.node;
|
|
280
280
|
}), t.node;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -285,7 +285,7 @@ class s {
|
|
|
285
285
|
*/
|
|
286
286
|
gobbleSpaces() {
|
|
287
287
|
let e = this.code;
|
|
288
|
-
for (; e ===
|
|
288
|
+
for (; e === o.SPACE_CODE || e === o.TAB_CODE || e === o.LF_CODE || e === o.CR_CODE; )
|
|
289
289
|
e = this.expr.charCodeAt(++this.index);
|
|
290
290
|
this.runHook("gobble-spaces");
|
|
291
291
|
}
|
|
@@ -296,7 +296,7 @@ class s {
|
|
|
296
296
|
parse() {
|
|
297
297
|
this.runHook("before-all");
|
|
298
298
|
const e = this.gobbleExpressions(), t = e.length === 1 ? e[0] : {
|
|
299
|
-
type:
|
|
299
|
+
type: o.COMPOUND,
|
|
300
300
|
body: e
|
|
301
301
|
};
|
|
302
302
|
return this.runHook("after-all", t);
|
|
@@ -307,14 +307,14 @@ class s {
|
|
|
307
307
|
* @returns {jsep.Expression[]}
|
|
308
308
|
*/
|
|
309
309
|
gobbleExpressions(e) {
|
|
310
|
-
let t = [],
|
|
310
|
+
let t = [], s, n;
|
|
311
311
|
for (; this.index < this.expr.length; )
|
|
312
|
-
if (
|
|
312
|
+
if (s = this.code, s === o.SEMCOL_CODE || s === o.COMMA_CODE)
|
|
313
313
|
this.index++;
|
|
314
314
|
else if (n = this.gobbleExpression())
|
|
315
315
|
t.push(n);
|
|
316
316
|
else if (this.index < this.expr.length) {
|
|
317
|
-
if (
|
|
317
|
+
if (s === e)
|
|
318
318
|
break;
|
|
319
319
|
this.throwError('Unexpected "' + this.char + '"');
|
|
320
320
|
}
|
|
@@ -337,9 +337,9 @@ class s {
|
|
|
337
337
|
*/
|
|
338
338
|
gobbleBinaryOp() {
|
|
339
339
|
this.gobbleSpaces();
|
|
340
|
-
let e = this.expr.substr(this.index,
|
|
340
|
+
let e = this.expr.substr(this.index, o.max_binop_len), t = e.length;
|
|
341
341
|
for (; t > 0; ) {
|
|
342
|
-
if (
|
|
342
|
+
if (o.binary_ops.hasOwnProperty(e) && (!o.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !o.isIdentifierPart(this.expr.charCodeAt(this.index + e.length))))
|
|
343
343
|
return this.index += t, e;
|
|
344
344
|
e = e.substr(0, --t);
|
|
345
345
|
}
|
|
@@ -351,36 +351,36 @@ class s {
|
|
|
351
351
|
* @returns {?jsep.BinaryExpression}
|
|
352
352
|
*/
|
|
353
353
|
gobbleBinaryExpression() {
|
|
354
|
-
let e, t,
|
|
355
|
-
if (
|
|
356
|
-
return
|
|
354
|
+
let e, t, s, n, a, c, f, d, h;
|
|
355
|
+
if (c = this.gobbleToken(), !c || (t = this.gobbleBinaryOp(), !t))
|
|
356
|
+
return c;
|
|
357
357
|
for (a = {
|
|
358
358
|
value: t,
|
|
359
|
-
prec:
|
|
360
|
-
right_a:
|
|
361
|
-
}, f = this.gobbleToken(), f || this.throwError("Expected expression after " + t), n = [
|
|
362
|
-
if (
|
|
359
|
+
prec: o.binaryPrecedence(t),
|
|
360
|
+
right_a: o.right_associative.has(t)
|
|
361
|
+
}, f = this.gobbleToken(), f || this.throwError("Expected expression after " + t), n = [c, a, f]; t = this.gobbleBinaryOp(); ) {
|
|
362
|
+
if (s = o.binaryPrecedence(t), s === 0) {
|
|
363
363
|
this.index -= t.length;
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
366
|
a = {
|
|
367
367
|
value: t,
|
|
368
|
-
prec:
|
|
369
|
-
right_a:
|
|
368
|
+
prec: s,
|
|
369
|
+
right_a: o.right_associative.has(t)
|
|
370
370
|
}, h = t;
|
|
371
|
-
const
|
|
372
|
-
for (; n.length > 2 &&
|
|
373
|
-
f = n.pop(), t = n.pop().value,
|
|
374
|
-
type:
|
|
371
|
+
const v = (g) => a.right_a && g.right_a ? s > g.prec : s <= g.prec;
|
|
372
|
+
for (; n.length > 2 && v(n[n.length - 2]); )
|
|
373
|
+
f = n.pop(), t = n.pop().value, c = n.pop(), e = {
|
|
374
|
+
type: o.BINARY_EXP,
|
|
375
375
|
operator: t,
|
|
376
|
-
left:
|
|
376
|
+
left: c,
|
|
377
377
|
right: f
|
|
378
378
|
}, n.push(e);
|
|
379
379
|
e = this.gobbleToken(), e || this.throwError("Expected expression after " + h), n.push(a, e);
|
|
380
380
|
}
|
|
381
381
|
for (d = n.length - 1, e = n[d]; d > 1; )
|
|
382
382
|
e = {
|
|
383
|
-
type:
|
|
383
|
+
type: o.BINARY_EXP,
|
|
384
384
|
operator: n[d - 1].value,
|
|
385
385
|
left: n[d - 2],
|
|
386
386
|
right: e
|
|
@@ -393,36 +393,36 @@ class s {
|
|
|
393
393
|
* @returns {boolean|jsep.Expression}
|
|
394
394
|
*/
|
|
395
395
|
gobbleToken() {
|
|
396
|
-
let e, t,
|
|
396
|
+
let e, t, s, n;
|
|
397
397
|
if (this.gobbleSpaces(), n = this.searchHook("gobble-token"), n)
|
|
398
398
|
return this.runHook("after-token", n);
|
|
399
|
-
if (e = this.code,
|
|
399
|
+
if (e = this.code, o.isDecimalDigit(e) || e === o.PERIOD_CODE)
|
|
400
400
|
return this.gobbleNumericLiteral();
|
|
401
|
-
if (e ===
|
|
401
|
+
if (e === o.SQUOTE_CODE || e === o.DQUOTE_CODE)
|
|
402
402
|
n = this.gobbleStringLiteral();
|
|
403
|
-
else if (e ===
|
|
403
|
+
else if (e === o.OBRACK_CODE)
|
|
404
404
|
n = this.gobbleArray();
|
|
405
405
|
else {
|
|
406
|
-
for (t = this.expr.substr(this.index,
|
|
407
|
-
if (
|
|
408
|
-
this.index +=
|
|
406
|
+
for (t = this.expr.substr(this.index, o.max_unop_len), s = t.length; s > 0; ) {
|
|
407
|
+
if (o.unary_ops.hasOwnProperty(t) && (!o.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !o.isIdentifierPart(this.expr.charCodeAt(this.index + t.length)))) {
|
|
408
|
+
this.index += s;
|
|
409
409
|
const a = this.gobbleToken();
|
|
410
410
|
return a || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
411
|
-
type:
|
|
411
|
+
type: o.UNARY_EXP,
|
|
412
412
|
operator: t,
|
|
413
413
|
argument: a,
|
|
414
414
|
prefix: !0
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
|
-
t = t.substr(0, --
|
|
417
|
+
t = t.substr(0, --s);
|
|
418
418
|
}
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
value:
|
|
419
|
+
o.isIdentifierStart(e) ? (n = this.gobbleIdentifier(), o.literals.hasOwnProperty(n.name) ? n = {
|
|
420
|
+
type: o.LITERAL,
|
|
421
|
+
value: o.literals[n.name],
|
|
422
422
|
raw: n.name
|
|
423
|
-
} : n.name ===
|
|
424
|
-
type:
|
|
425
|
-
})) : e ===
|
|
423
|
+
} : n.name === o.this_str && (n = {
|
|
424
|
+
type: o.THIS_EXP
|
|
425
|
+
})) : e === o.OPAREN_CODE && (n = this.gobbleGroup());
|
|
426
426
|
}
|
|
427
427
|
return n ? (n = this.gobbleTokenProperty(n), this.runHook("after-token", n)) : this.runHook("after-token", !1);
|
|
428
428
|
}
|
|
@@ -437,28 +437,28 @@ class s {
|
|
|
437
437
|
gobbleTokenProperty(e) {
|
|
438
438
|
this.gobbleSpaces();
|
|
439
439
|
let t = this.code;
|
|
440
|
-
for (; t ===
|
|
441
|
-
let
|
|
442
|
-
if (t ===
|
|
443
|
-
if (this.expr.charCodeAt(this.index + 1) !==
|
|
440
|
+
for (; t === o.PERIOD_CODE || t === o.OBRACK_CODE || t === o.OPAREN_CODE || t === o.QUMARK_CODE; ) {
|
|
441
|
+
let s;
|
|
442
|
+
if (t === o.QUMARK_CODE) {
|
|
443
|
+
if (this.expr.charCodeAt(this.index + 1) !== o.PERIOD_CODE)
|
|
444
444
|
break;
|
|
445
|
-
|
|
445
|
+
s = !0, this.index += 2, this.gobbleSpaces(), t = this.code;
|
|
446
446
|
}
|
|
447
|
-
this.index++, t ===
|
|
448
|
-
type:
|
|
447
|
+
this.index++, t === o.OBRACK_CODE ? (e = {
|
|
448
|
+
type: o.MEMBER_EXP,
|
|
449
449
|
computed: !0,
|
|
450
450
|
object: e,
|
|
451
451
|
property: this.gobbleExpression()
|
|
452
|
-
}, e.property || this.throwError('Unexpected "' + this.char + '"'), this.gobbleSpaces(), t = this.code, t !==
|
|
453
|
-
type:
|
|
454
|
-
arguments: this.gobbleArguments(
|
|
452
|
+
}, e.property || this.throwError('Unexpected "' + this.char + '"'), this.gobbleSpaces(), t = this.code, t !== o.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : t === o.OPAREN_CODE ? e = {
|
|
453
|
+
type: o.CALL_EXP,
|
|
454
|
+
arguments: this.gobbleArguments(o.CPAREN_CODE),
|
|
455
455
|
callee: e
|
|
456
|
-
} : (t ===
|
|
457
|
-
type:
|
|
456
|
+
} : (t === o.PERIOD_CODE || s) && (s && this.index--, this.gobbleSpaces(), e = {
|
|
457
|
+
type: o.MEMBER_EXP,
|
|
458
458
|
computed: !1,
|
|
459
459
|
object: e,
|
|
460
460
|
property: this.gobbleIdentifier()
|
|
461
|
-
}),
|
|
461
|
+
}), s && (e.optional = !0), this.gobbleSpaces(), t = this.code;
|
|
462
462
|
}
|
|
463
463
|
return e;
|
|
464
464
|
}
|
|
@@ -468,19 +468,19 @@ class s {
|
|
|
468
468
|
* @returns {jsep.Literal}
|
|
469
469
|
*/
|
|
470
470
|
gobbleNumericLiteral() {
|
|
471
|
-
let e = "", t,
|
|
472
|
-
for (;
|
|
471
|
+
let e = "", t, s;
|
|
472
|
+
for (; o.isDecimalDigit(this.code); )
|
|
473
473
|
e += this.expr.charAt(this.index++);
|
|
474
|
-
if (this.code ===
|
|
475
|
-
for (e += this.expr.charAt(this.index++);
|
|
474
|
+
if (this.code === o.PERIOD_CODE)
|
|
475
|
+
for (e += this.expr.charAt(this.index++); o.isDecimalDigit(this.code); )
|
|
476
476
|
e += this.expr.charAt(this.index++);
|
|
477
477
|
if (t = this.char, t === "e" || t === "E") {
|
|
478
|
-
for (e += this.expr.charAt(this.index++), t = this.char, (t === "+" || t === "-") && (e += this.expr.charAt(this.index++));
|
|
478
|
+
for (e += this.expr.charAt(this.index++), t = this.char, (t === "+" || t === "-") && (e += this.expr.charAt(this.index++)); o.isDecimalDigit(this.code); )
|
|
479
479
|
e += this.expr.charAt(this.index++);
|
|
480
|
-
|
|
480
|
+
o.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + e + this.char + ")");
|
|
481
481
|
}
|
|
482
|
-
return
|
|
483
|
-
type:
|
|
482
|
+
return s = this.code, o.isIdentifierStart(s) ? this.throwError("Variable names cannot start with a number (" + e + this.char + ")") : (s === o.PERIOD_CODE || e.length === 1 && e.charCodeAt(0) === o.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
483
|
+
type: o.LITERAL,
|
|
484
484
|
value: parseFloat(e),
|
|
485
485
|
raw: e
|
|
486
486
|
};
|
|
@@ -492,11 +492,11 @@ class s {
|
|
|
492
492
|
*/
|
|
493
493
|
gobbleStringLiteral() {
|
|
494
494
|
let e = "";
|
|
495
|
-
const t = this.index,
|
|
495
|
+
const t = this.index, s = this.expr.charAt(this.index++);
|
|
496
496
|
let n = !1;
|
|
497
497
|
for (; this.index < this.expr.length; ) {
|
|
498
498
|
let a = this.expr.charAt(this.index++);
|
|
499
|
-
if (a ===
|
|
499
|
+
if (a === s) {
|
|
500
500
|
n = !0;
|
|
501
501
|
break;
|
|
502
502
|
} else if (a === "\\")
|
|
@@ -527,7 +527,7 @@ class s {
|
|
|
527
527
|
e += a;
|
|
528
528
|
}
|
|
529
529
|
return n || this.throwError('Unclosed quote after "' + e + '"'), {
|
|
530
|
-
type:
|
|
530
|
+
type: o.LITERAL,
|
|
531
531
|
value: e,
|
|
532
532
|
raw: this.expr.substring(t, this.index)
|
|
533
533
|
};
|
|
@@ -541,10 +541,10 @@ class s {
|
|
|
541
541
|
*/
|
|
542
542
|
gobbleIdentifier() {
|
|
543
543
|
let e = this.code, t = this.index;
|
|
544
|
-
for (
|
|
544
|
+
for (o.isIdentifierStart(e) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (e = this.code, o.isIdentifierPart(e)); )
|
|
545
545
|
this.index++;
|
|
546
546
|
return {
|
|
547
|
-
type:
|
|
547
|
+
type: o.IDENTIFIER,
|
|
548
548
|
name: this.expr.slice(t, this.index)
|
|
549
549
|
};
|
|
550
550
|
}
|
|
@@ -559,29 +559,29 @@ class s {
|
|
|
559
559
|
*/
|
|
560
560
|
gobbleArguments(e) {
|
|
561
561
|
const t = [];
|
|
562
|
-
let
|
|
562
|
+
let s = !1, n = 0;
|
|
563
563
|
for (; this.index < this.expr.length; ) {
|
|
564
564
|
this.gobbleSpaces();
|
|
565
565
|
let a = this.code;
|
|
566
566
|
if (a === e) {
|
|
567
|
-
|
|
567
|
+
s = !0, this.index++, e === o.CPAREN_CODE && n && n >= t.length && this.throwError("Unexpected token " + String.fromCharCode(e));
|
|
568
568
|
break;
|
|
569
|
-
} else if (a ===
|
|
569
|
+
} else if (a === o.COMMA_CODE) {
|
|
570
570
|
if (this.index++, n++, n !== t.length) {
|
|
571
|
-
if (e ===
|
|
571
|
+
if (e === o.CPAREN_CODE)
|
|
572
572
|
this.throwError("Unexpected token ,");
|
|
573
|
-
else if (e ===
|
|
574
|
-
for (let
|
|
573
|
+
else if (e === o.CBRACK_CODE)
|
|
574
|
+
for (let c = t.length; c < n; c++)
|
|
575
575
|
t.push(null);
|
|
576
576
|
}
|
|
577
577
|
} else if (t.length !== n && n !== 0)
|
|
578
578
|
this.throwError("Expected comma");
|
|
579
579
|
else {
|
|
580
|
-
const
|
|
581
|
-
(!
|
|
580
|
+
const c = this.gobbleExpression();
|
|
581
|
+
(!c || c.type === o.COMPOUND) && this.throwError("Expected comma"), t.push(c);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
return
|
|
584
|
+
return s || this.throwError("Expected " + String.fromCharCode(e)), t;
|
|
585
585
|
}
|
|
586
586
|
/**
|
|
587
587
|
* Responsible for parsing a group of things within parentheses `()`
|
|
@@ -594,10 +594,10 @@ class s {
|
|
|
594
594
|
*/
|
|
595
595
|
gobbleGroup() {
|
|
596
596
|
this.index++;
|
|
597
|
-
let e = this.gobbleExpressions(
|
|
598
|
-
if (this.code ===
|
|
597
|
+
let e = this.gobbleExpressions(o.CPAREN_CODE);
|
|
598
|
+
if (this.code === o.CPAREN_CODE)
|
|
599
599
|
return this.index++, e.length === 1 ? e[0] : e.length ? {
|
|
600
|
-
type:
|
|
600
|
+
type: o.SEQUENCE_EXP,
|
|
601
601
|
expressions: e
|
|
602
602
|
} : !1;
|
|
603
603
|
this.throwError("Unclosed (");
|
|
@@ -610,15 +610,15 @@ class s {
|
|
|
610
610
|
*/
|
|
611
611
|
gobbleArray() {
|
|
612
612
|
return this.index++, {
|
|
613
|
-
type:
|
|
614
|
-
elements: this.gobbleArguments(
|
|
613
|
+
type: o.ARRAY_EXP,
|
|
614
|
+
elements: this.gobbleArguments(o.CBRACK_CODE)
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
const ve = new Ee();
|
|
619
|
-
Object.assign(
|
|
619
|
+
Object.assign(o, {
|
|
620
620
|
hooks: ve,
|
|
621
|
-
plugins: new me(
|
|
621
|
+
plugins: new me(o),
|
|
622
622
|
// Node Types
|
|
623
623
|
// ----------
|
|
624
624
|
// This is the full set of types that any JSEP node can be.
|
|
@@ -712,14 +712,14 @@ Object.assign(s, {
|
|
|
712
712
|
// Except for `this`, which is special. This could be changed to something like `'self'` as well
|
|
713
713
|
this_str: "this"
|
|
714
714
|
});
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
const L = (r) => new
|
|
715
|
+
o.max_unop_len = o.getMaxKeyLen(o.unary_ops);
|
|
716
|
+
o.max_binop_len = o.getMaxKeyLen(o.binary_ops);
|
|
717
|
+
const L = (r) => new o(r).parse(), _e = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(
|
|
720
|
-
L[r] =
|
|
719
|
+
Object.getOwnPropertyNames(o).filter((r) => !_e.includes(r) && L[r] === void 0).forEach((r) => {
|
|
720
|
+
L[r] = o[r];
|
|
721
721
|
});
|
|
722
|
-
L.Jsep =
|
|
722
|
+
L.Jsep = o;
|
|
723
723
|
const xe = "ConditionalExpression";
|
|
724
724
|
var ke = {
|
|
725
725
|
name: "ternary",
|
|
@@ -727,20 +727,20 @@ var ke = {
|
|
|
727
727
|
r.hooks.add("after-expression", function(t) {
|
|
728
728
|
if (t.node && this.code === r.QUMARK_CODE) {
|
|
729
729
|
this.index++;
|
|
730
|
-
const
|
|
730
|
+
const s = t.node, n = this.gobbleExpression();
|
|
731
731
|
if (n || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === r.COLON_CODE) {
|
|
732
732
|
this.index++;
|
|
733
733
|
const a = this.gobbleExpression();
|
|
734
734
|
if (a || this.throwError("Expected expression"), t.node = {
|
|
735
735
|
type: xe,
|
|
736
|
-
test:
|
|
736
|
+
test: s,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: a
|
|
739
|
-
},
|
|
740
|
-
let
|
|
741
|
-
for (;
|
|
742
|
-
|
|
743
|
-
t.node.test =
|
|
739
|
+
}, s.operator && r.binary_ops[s.operator] <= 0.9) {
|
|
740
|
+
let c = s;
|
|
741
|
+
for (; c.right.operator && r.binary_ops[c.right.operator] <= 0.9; )
|
|
742
|
+
c = c.right;
|
|
743
|
+
t.node.test = c.right, c.right = t.node, t.node = s;
|
|
744
744
|
}
|
|
745
745
|
} else
|
|
746
746
|
this.throwError("Expected :");
|
|
@@ -755,29 +755,29 @@ var Ce = {
|
|
|
755
755
|
init(r) {
|
|
756
756
|
r.hooks.add("gobble-token", function(t) {
|
|
757
757
|
if (this.code === ae) {
|
|
758
|
-
const
|
|
758
|
+
const s = ++this.index;
|
|
759
759
|
let n = !1;
|
|
760
760
|
for (; this.index < this.expr.length; ) {
|
|
761
761
|
if (this.code === ae && !n) {
|
|
762
|
-
const a = this.expr.slice(
|
|
763
|
-
let
|
|
762
|
+
const a = this.expr.slice(s, this.index);
|
|
763
|
+
let c = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
765
765
|
const d = this.code;
|
|
766
766
|
if (d >= 97 && d <= 122 || d >= 65 && d <= 90 || d >= 48 && d <= 57)
|
|
767
|
-
|
|
767
|
+
c += this.char;
|
|
768
768
|
else
|
|
769
769
|
break;
|
|
770
770
|
}
|
|
771
771
|
let f;
|
|
772
772
|
try {
|
|
773
|
-
f = new RegExp(a,
|
|
773
|
+
f = new RegExp(a, c);
|
|
774
774
|
} catch (d) {
|
|
775
775
|
this.throwError(d.message);
|
|
776
776
|
}
|
|
777
777
|
return t.node = {
|
|
778
778
|
type: r.LITERAL,
|
|
779
779
|
value: f,
|
|
780
|
-
raw: this.expr.slice(
|
|
780
|
+
raw: this.expr.slice(s - 1, this.index)
|
|
781
781
|
}, t.node = this.gobbleTokenProperty(t.node), t.node;
|
|
782
782
|
}
|
|
783
783
|
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code === Oe ? 2 : 1;
|
|
@@ -787,27 +787,27 @@ var Ce = {
|
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const se = 43, Ae = 45, G = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [se, Ae],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
G.assignmentOperators.forEach((
|
|
797
|
+
G.assignmentOperators.forEach((s) => r.addBinaryOp(s, G.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const a = this.code;
|
|
799
|
-
G.updateOperators.some((
|
|
799
|
+
G.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 === se ? "++" : "--",
|
|
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
|
-
G.updateOperators.some((
|
|
808
|
+
G.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 === se ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -815,8 +815,8 @@ const oe = 43, Ae = 45, G = {
|
|
|
815
815
|
}), r.hooks.add("after-expression", function(n) {
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
|
-
function t(
|
|
819
|
-
G.assignmentOperators.has(
|
|
818
|
+
function t(s) {
|
|
819
|
+
G.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
|
}
|
|
@@ -860,36 +860,36 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
860
860
|
},
|
|
861
861
|
evalBinaryExpression(r, e) {
|
|
862
862
|
return {
|
|
863
|
-
"||": (
|
|
864
|
-
"&&": (
|
|
865
|
-
"|": (
|
|
866
|
-
"^": (
|
|
867
|
-
"&": (
|
|
863
|
+
"||": (s, n) => s || n(),
|
|
864
|
+
"&&": (s, n) => s && n(),
|
|
865
|
+
"|": (s, n) => s | n(),
|
|
866
|
+
"^": (s, n) => s ^ n(),
|
|
867
|
+
"&": (s, n) => s & n(),
|
|
868
868
|
// eslint-disable-next-line eqeqeq -- API
|
|
869
|
-
"==": (
|
|
869
|
+
"==": (s, n) => s == n(),
|
|
870
870
|
// eslint-disable-next-line eqeqeq -- API
|
|
871
|
-
"!=": (
|
|
872
|
-
"===": (
|
|
873
|
-
"!==": (
|
|
874
|
-
"<": (
|
|
875
|
-
">": (
|
|
876
|
-
"<=": (
|
|
877
|
-
">=": (
|
|
878
|
-
"<<": (
|
|
879
|
-
">>": (
|
|
880
|
-
">>>": (
|
|
881
|
-
"+": (
|
|
882
|
-
"-": (
|
|
883
|
-
"*": (
|
|
884
|
-
"/": (
|
|
885
|
-
"%": (
|
|
871
|
+
"!=": (s, n) => s != n(),
|
|
872
|
+
"===": (s, n) => s === n(),
|
|
873
|
+
"!==": (s, n) => s !== n(),
|
|
874
|
+
"<": (s, n) => s < n(),
|
|
875
|
+
">": (s, n) => s > n(),
|
|
876
|
+
"<=": (s, n) => s <= n(),
|
|
877
|
+
">=": (s, n) => s >= n(),
|
|
878
|
+
"<<": (s, n) => s << n(),
|
|
879
|
+
">>": (s, n) => s >> n(),
|
|
880
|
+
">>>": (s, n) => s >>> n(),
|
|
881
|
+
"+": (s, n) => s + n(),
|
|
882
|
+
"-": (s, n) => s - n(),
|
|
883
|
+
"*": (s, n) => s * n(),
|
|
884
|
+
"/": (s, n) => s / n(),
|
|
885
|
+
"%": (s, n) => s % n()
|
|
886
886
|
}[r.operator](O.evalAst(r.left, e), () => O.evalAst(r.right, e));
|
|
887
887
|
},
|
|
888
888
|
evalCompound(r, e) {
|
|
889
889
|
let t;
|
|
890
|
-
for (let
|
|
891
|
-
r.body[
|
|
892
|
-
const n = r.body[
|
|
890
|
+
for (let s = 0; s < r.body.length; s++) {
|
|
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
|
+
const n = r.body[s];
|
|
893
893
|
t = O.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
@@ -912,22 +912,22 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
912
912
|
// i.e. `value = {toString: () => []}`
|
|
913
913
|
r.computed ? O.evalAst(r.property) : r.property.name
|
|
914
914
|
// `object.property` property is Identifier
|
|
915
|
-
),
|
|
916
|
-
if (
|
|
917
|
-
throw TypeError(`Cannot read properties of ${
|
|
918
|
-
if (!Object.hasOwn(
|
|
919
|
-
throw TypeError(`Cannot read properties of ${
|
|
920
|
-
const n =
|
|
921
|
-
return typeof n == "function" ? n.bind(
|
|
915
|
+
), s = O.evalAst(r.object, e);
|
|
916
|
+
if (s == null)
|
|
917
|
+
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
918
|
+
if (!Object.hasOwn(s, t) && we.has(t))
|
|
919
|
+
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
920
|
+
const n = s[t];
|
|
921
|
+
return typeof n == "function" ? n.bind(s) : n;
|
|
922
922
|
},
|
|
923
923
|
evalUnaryExpression(r, e) {
|
|
924
924
|
return {
|
|
925
|
-
"-": (
|
|
926
|
-
"!": (
|
|
927
|
-
"~": (
|
|
925
|
+
"-": (s) => -O.evalAst(s, e),
|
|
926
|
+
"!": (s) => !O.evalAst(s, e),
|
|
927
|
+
"~": (s) => ~O.evalAst(s, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (
|
|
930
|
-
typeof: (
|
|
929
|
+
"+": (s) => +O.evalAst(s, e),
|
|
930
|
+
typeof: (s) => typeof O.evalAst(s, e)
|
|
931
931
|
}[r.operator](r.argument);
|
|
932
932
|
},
|
|
933
933
|
evalArrayExpression(r, e) {
|
|
@@ -940,8 +940,8 @@ const we = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
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,
|
|
944
|
-
return e[t] =
|
|
943
|
+
const t = r.left.name, s = O.evalAst(r.right, e);
|
|
944
|
+
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
947
|
class Se {
|
|
@@ -964,7 +964,7 @@ class Se {
|
|
|
964
964
|
function M(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function oe(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
970
|
class Pe extends Error {
|
|
@@ -975,54 +975,54 @@ 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 x(r, e, t,
|
|
978
|
+
function x(r, e, t, s, n) {
|
|
979
979
|
if (!(this instanceof x))
|
|
980
980
|
try {
|
|
981
|
-
return new x(r, e, t,
|
|
982
|
-
} catch (
|
|
983
|
-
if (!
|
|
984
|
-
throw
|
|
985
|
-
return
|
|
981
|
+
return new x(r, e, t, s, n);
|
|
982
|
+
} catch (c) {
|
|
983
|
+
if (!c.avoidNew)
|
|
984
|
+
throw c;
|
|
985
|
+
return c.value;
|
|
986
986
|
}
|
|
987
|
-
typeof r == "string" && (n =
|
|
987
|
+
typeof r == "string" && (n = s, s = t, t = e, e = r, r = null);
|
|
988
988
|
const a = r && typeof r == "object";
|
|
989
|
-
if (r = r || {}, this.json = r.json || t, this.path = r.path || e, this.resultType = r.resultType || "value", this.flatten = r.flatten || !1, this.wrap = Object.hasOwn(r, "wrap") ? r.wrap : !0, this.sandbox = r.sandbox || {}, this.eval = r.eval === void 0 ? "safe" : r.eval, this.ignoreEvalErrors = typeof r.ignoreEvalErrors > "u" ? !1 : r.ignoreEvalErrors, this.parent = r.parent || null, this.parentProperty = r.parentProperty || null, this.callback = r.callback ||
|
|
989
|
+
if (r = r || {}, this.json = r.json || t, this.path = r.path || e, this.resultType = r.resultType || "value", this.flatten = r.flatten || !1, this.wrap = Object.hasOwn(r, "wrap") ? r.wrap : !0, this.sandbox = r.sandbox || {}, this.eval = r.eval === void 0 ? "safe" : r.eval, this.ignoreEvalErrors = typeof r.ignoreEvalErrors > "u" ? !1 : r.ignoreEvalErrors, this.parent = r.parent || null, this.parentProperty = r.parentProperty || null, this.callback = r.callback || s || null, this.otherTypeCallback = r.otherTypeCallback || n || function() {
|
|
990
990
|
throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
|
|
991
991
|
}, r.autostart !== !1) {
|
|
992
|
-
const
|
|
992
|
+
const c = {
|
|
993
993
|
path: a ? r.path : e
|
|
994
994
|
};
|
|
995
|
-
a ? "json" in r && (
|
|
996
|
-
const f = this.evaluate(
|
|
995
|
+
a ? "json" in r && (c.json = r.json) : c.json = t;
|
|
996
|
+
const f = this.evaluate(c);
|
|
997
997
|
if (!f || typeof f != "object")
|
|
998
998
|
throw new Pe(f);
|
|
999
999
|
return f;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
x.prototype.evaluate = function(r, e, t,
|
|
1002
|
+
x.prototype.evaluate = function(r, e, t, s) {
|
|
1003
1003
|
let n = this.parent, a = this.parentProperty, {
|
|
1004
|
-
flatten:
|
|
1004
|
+
flatten: c,
|
|
1005
1005
|
wrap: f
|
|
1006
1006
|
} = this;
|
|
1007
|
-
if (this.currResultType = this.resultType, this.currEval = this.eval, this.currSandbox = this.sandbox, t = t || this.callback, this.currOtherTypeCallback =
|
|
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 !== "")
|
|
1009
1009
|
throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
|
|
1010
1010
|
if (!Object.hasOwn(r, "json"))
|
|
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),
|
|
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
1016
|
if (n = n || null, a = a || null, Array.isArray(r) && (r = x.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
1018
|
const d = x.toPathArray(r);
|
|
1019
1019
|
d[0] === "$" && d.length > 1 && d.shift(), this._hasParentSelector = null;
|
|
1020
|
-
const h = this._trace(d, e, ["$"], n, a, t).filter(function(
|
|
1021
|
-
return
|
|
1020
|
+
const h = this._trace(d, e, ["$"], n, a, t).filter(function(v) {
|
|
1021
|
+
return v && !v.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
|
-
return h.length ? !f && h.length === 1 && !h[0].hasArrExpr ? this._getPreferredOutput(h[0]) : h.reduce((
|
|
1024
|
-
const k = this._getPreferredOutput(
|
|
1025
|
-
return
|
|
1023
|
+
return h.length ? !f && h.length === 1 && !h[0].hasArrExpr ? this._getPreferredOutput(h[0]) : h.reduce((v, g) => {
|
|
1024
|
+
const k = this._getPreferredOutput(g);
|
|
1025
|
+
return c && Array.isArray(k) ? v = v.concat(k) : v.push(k), v;
|
|
1026
1026
|
}, []) : f ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
1028
|
x.prototype._getPreferredOutput = function(r) {
|
|
@@ -1046,168 +1046,168 @@ x.prototype._getPreferredOutput = function(r) {
|
|
|
1046
1046
|
};
|
|
1047
1047
|
x.prototype._handleCallback = function(r, e, t) {
|
|
1048
1048
|
if (e) {
|
|
1049
|
-
const
|
|
1050
|
-
r.path = typeof r.path == "string" ? r.path : x.toPathString(r.path), e(
|
|
1049
|
+
const s = this._getPreferredOutput(r);
|
|
1050
|
+
r.path = typeof r.path == "string" ? r.path : x.toPathString(r.path), e(s, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
x.prototype._trace = function(r, e, t,
|
|
1053
|
+
x.prototype._trace = function(r, e, t, s, n, a, c, f) {
|
|
1054
1054
|
let d;
|
|
1055
1055
|
if (!r.length)
|
|
1056
1056
|
return d = {
|
|
1057
1057
|
path: t,
|
|
1058
1058
|
value: e,
|
|
1059
|
-
parent:
|
|
1059
|
+
parent: s,
|
|
1060
1060
|
parentProperty: n,
|
|
1061
|
-
hasArrExpr:
|
|
1061
|
+
hasArrExpr: c
|
|
1062
1062
|
}, this._handleCallback(d, a, "value"), d;
|
|
1063
|
-
const h = r[0],
|
|
1064
|
-
function k(
|
|
1065
|
-
Array.isArray(
|
|
1066
|
-
|
|
1067
|
-
}) :
|
|
1063
|
+
const h = r[0], v = r.slice(1), g = [];
|
|
1064
|
+
function k(m) {
|
|
1065
|
+
Array.isArray(m) ? m.forEach((S) => {
|
|
1066
|
+
g.push(S);
|
|
1067
|
+
}) : g.push(m);
|
|
1068
1068
|
}
|
|
1069
1069
|
if ((typeof h != "string" || f) && e && Object.hasOwn(e, h))
|
|
1070
|
-
k(this._trace(
|
|
1070
|
+
k(this._trace(v, e[h], M(t, h), e, h, a, c));
|
|
1071
1071
|
else if (h === "*")
|
|
1072
|
-
this._walk(e, (
|
|
1073
|
-
k(this._trace(
|
|
1072
|
+
this._walk(e, (m) => {
|
|
1073
|
+
k(this._trace(v, e[m], M(t, m), e, m, a, !0, !0));
|
|
1074
1074
|
});
|
|
1075
1075
|
else if (h === "..")
|
|
1076
|
-
k(this._trace(
|
|
1077
|
-
typeof e[
|
|
1076
|
+
k(this._trace(v, e, t, s, n, a, c)), this._walk(e, (m) => {
|
|
1077
|
+
typeof e[m] == "object" && k(this._trace(r.slice(), e[m], M(t, m), e, m, a, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
1080
|
if (h === "^")
|
|
1081
1081
|
return this._hasParentSelector = !0, {
|
|
1082
1082
|
path: t.slice(0, -1),
|
|
1083
|
-
expr:
|
|
1083
|
+
expr: v,
|
|
1084
1084
|
isParentSelector: !0
|
|
1085
1085
|
};
|
|
1086
1086
|
if (h === "~")
|
|
1087
1087
|
return d = {
|
|
1088
1088
|
path: M(t, h),
|
|
1089
1089
|
value: n,
|
|
1090
|
-
parent:
|
|
1090
|
+
parent: s,
|
|
1091
1091
|
parentProperty: null
|
|
1092
1092
|
}, this._handleCallback(d, a, "property"), d;
|
|
1093
1093
|
if (h === "$")
|
|
1094
|
-
k(this._trace(
|
|
1094
|
+
k(this._trace(v, e, t, null, null, a, c));
|
|
1095
1095
|
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(h))
|
|
1096
|
-
k(this._slice(h,
|
|
1096
|
+
k(this._slice(h, v, e, t, s, n, a));
|
|
1097
1097
|
else if (h.indexOf("?(") === 0) {
|
|
1098
1098
|
if (this.currEval === !1)
|
|
1099
1099
|
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
1100
|
-
const
|
|
1100
|
+
const m = h.replace(/^\?\((.*?)\)$/u, "$1"), S = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);
|
|
1101
1101
|
S ? this._walk(e, (C) => {
|
|
1102
1102
|
const U = [S[2]], D = S[1] ? e[C][S[1]] : e[C];
|
|
1103
|
-
this._trace(U, D, t,
|
|
1103
|
+
this._trace(U, D, t, s, n, a, !0).length > 0 && k(this._trace(v, e[C], M(t, C), e, C, a, !0));
|
|
1104
1104
|
}) : this._walk(e, (C) => {
|
|
1105
|
-
this._eval(
|
|
1105
|
+
this._eval(m, e[C], C, t, s, n) && k(this._trace(v, e[C], M(t, C), e, C, a, !0));
|
|
1106
1106
|
});
|
|
1107
1107
|
} else if (h[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
1109
1109
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1110
|
-
k(this._trace(
|
|
1110
|
+
k(this._trace(oe(this._eval(h, e, t.at(-1), t.slice(0, -1), s, n), v), e, t, s, n, a, c));
|
|
1111
1111
|
} else if (h[0] === "@") {
|
|
1112
|
-
let
|
|
1112
|
+
let m = !1;
|
|
1113
1113
|
const S = h.slice(1, -2);
|
|
1114
1114
|
switch (S) {
|
|
1115
1115
|
case "scalar":
|
|
1116
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
1116
|
+
(!e || !["object", "function"].includes(typeof e)) && (m = !0);
|
|
1117
1117
|
break;
|
|
1118
1118
|
case "boolean":
|
|
1119
1119
|
case "string":
|
|
1120
1120
|
case "undefined":
|
|
1121
1121
|
case "function":
|
|
1122
|
-
typeof e === S && (
|
|
1122
|
+
typeof e === S && (m = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
1125
|
+
Number.isFinite(e) && !(e % 1) && (m = !0);
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "number":
|
|
1128
|
-
Number.isFinite(e) && (
|
|
1128
|
+
Number.isFinite(e) && (m = !0);
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "nonFinite":
|
|
1131
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
1131
|
+
typeof e == "number" && !Number.isFinite(e) && (m = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e === S && (
|
|
1134
|
+
e && typeof e === S && (m = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
|
-
Array.isArray(e) && (
|
|
1137
|
+
Array.isArray(e) && (m = !0);
|
|
1138
1138
|
break;
|
|
1139
1139
|
case "other":
|
|
1140
|
-
|
|
1140
|
+
m = this.currOtherTypeCallback(e, t, s, n);
|
|
1141
1141
|
break;
|
|
1142
1142
|
case "null":
|
|
1143
|
-
e === null && (
|
|
1143
|
+
e === null && (m = !0);
|
|
1144
1144
|
break;
|
|
1145
1145
|
/* c8 ignore next 2 */
|
|
1146
1146
|
default:
|
|
1147
1147
|
throw new TypeError("Unknown value type " + S);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1149
|
+
if (m)
|
|
1150
1150
|
return d = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
1153
|
-
parent:
|
|
1153
|
+
parent: s,
|
|
1154
1154
|
parentProperty: n
|
|
1155
1155
|
}, this._handleCallback(d, a, "value"), d;
|
|
1156
1156
|
} else if (h[0] === "`" && e && Object.hasOwn(e, h.slice(1))) {
|
|
1157
|
-
const
|
|
1158
|
-
k(this._trace(
|
|
1157
|
+
const m = h.slice(1);
|
|
1158
|
+
k(this._trace(v, e[m], M(t, m), e, m, a, c, !0));
|
|
1159
1159
|
} else if (h.includes(",")) {
|
|
1160
|
-
const
|
|
1161
|
-
for (const S of
|
|
1162
|
-
k(this._trace(
|
|
1163
|
-
} else !f && e && Object.hasOwn(e, h) && k(this._trace(
|
|
1160
|
+
const m = h.split(",");
|
|
1161
|
+
for (const S of m)
|
|
1162
|
+
k(this._trace(oe(S, v), e, t, s, n, a, !0));
|
|
1163
|
+
} else !f && e && Object.hasOwn(e, h) && k(this._trace(v, e[h], M(t, h), e, h, a, c, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const S =
|
|
1166
|
+
for (let m = 0; m < g.length; m++) {
|
|
1167
|
+
const S = g[m];
|
|
1168
1168
|
if (S && S.isParentSelector) {
|
|
1169
|
-
const C = this._trace(S.expr, e, S.path,
|
|
1169
|
+
const C = this._trace(S.expr, e, S.path, s, n, a, c);
|
|
1170
1170
|
if (Array.isArray(C)) {
|
|
1171
|
-
|
|
1171
|
+
g[m] = C[0];
|
|
1172
1172
|
const U = C.length;
|
|
1173
1173
|
for (let D = 1; D < U; D++)
|
|
1174
|
-
|
|
1174
|
+
m++, g.splice(m, 0, C[D]);
|
|
1175
1175
|
} else
|
|
1176
|
-
|
|
1176
|
+
g[m] = C;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
return
|
|
1179
|
+
return g;
|
|
1180
1180
|
};
|
|
1181
1181
|
x.prototype._walk = function(r, e) {
|
|
1182
1182
|
if (Array.isArray(r)) {
|
|
1183
1183
|
const t = r.length;
|
|
1184
|
-
for (let
|
|
1185
|
-
e(
|
|
1184
|
+
for (let s = 0; s < t; s++)
|
|
1185
|
+
e(s);
|
|
1186
1186
|
} else r && typeof r == "object" && Object.keys(r).forEach((t) => {
|
|
1187
1187
|
e(t);
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
|
-
x.prototype._slice = function(r, e, t,
|
|
1190
|
+
x.prototype._slice = function(r, e, t, s, n, a, c) {
|
|
1191
1191
|
if (!Array.isArray(t))
|
|
1192
1192
|
return;
|
|
1193
1193
|
const f = t.length, d = r.split(":"), h = d[2] && Number.parseInt(d[2]) || 1;
|
|
1194
|
-
let
|
|
1195
|
-
|
|
1194
|
+
let v = d[0] && Number.parseInt(d[0]) || 0, g = d[1] && Number.parseInt(d[1]) || f;
|
|
1195
|
+
v = v < 0 ? Math.max(0, v + f) : Math.min(f, v), g = g < 0 ? Math.max(0, g + f) : Math.min(f, g);
|
|
1196
1196
|
const k = [];
|
|
1197
|
-
for (let
|
|
1198
|
-
this._trace(
|
|
1197
|
+
for (let m = v; m < g; m += h)
|
|
1198
|
+
this._trace(oe(m, e), t, s, n, a, c, !0).forEach((C) => {
|
|
1199
1199
|
k.push(C);
|
|
1200
1200
|
});
|
|
1201
1201
|
return k;
|
|
1202
1202
|
};
|
|
1203
|
-
x.prototype._eval = function(r, e, t,
|
|
1203
|
+
x.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
|
-
const
|
|
1206
|
-
|
|
1205
|
+
const c = r.includes("@path");
|
|
1206
|
+
c && (this.currSandbox._$_path = x.toPathString(s.concat([t])));
|
|
1207
1207
|
const f = this.currEval + "Script:" + r;
|
|
1208
1208
|
if (!x.cache[f]) {
|
|
1209
1209
|
let d = r.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
1210
|
-
if (
|
|
1210
|
+
if (c && (d = d.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
1211
1211
|
x.cache[f] = new this.safeVm.Script(d);
|
|
1212
1212
|
else if (this.currEval === "native")
|
|
1213
1213
|
x.cache[f] = new this.vm.Script(d);
|
|
@@ -1232,17 +1232,17 @@ x.prototype._eval = function(r, e, t, o, n, a) {
|
|
|
1232
1232
|
x.cache = {};
|
|
1233
1233
|
x.toPathString = function(r) {
|
|
1234
1234
|
const e = r, t = e.length;
|
|
1235
|
-
let
|
|
1235
|
+
let s = "$";
|
|
1236
1236
|
for (let n = 1; n < t; n++)
|
|
1237
|
-
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (
|
|
1238
|
-
return
|
|
1237
|
+
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (s += /^[0-9*]+$/u.test(e[n]) ? "[" + e[n] + "]" : "['" + e[n] + "']");
|
|
1238
|
+
return s;
|
|
1239
1239
|
};
|
|
1240
1240
|
x.toPointer = function(r) {
|
|
1241
1241
|
const e = r, t = e.length;
|
|
1242
|
-
let
|
|
1242
|
+
let s = "";
|
|
1243
1243
|
for (let n = 1; n < t; n++)
|
|
1244
|
-
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (
|
|
1245
|
-
return
|
|
1244
|
+
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (s += "/" + e[n].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
|
|
1245
|
+
return s;
|
|
1246
1246
|
};
|
|
1247
1247
|
x.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
@@ -1250,15 +1250,15 @@ x.toPathArray = function(r) {
|
|
|
1250
1250
|
} = x;
|
|
1251
1251
|
if (e[r])
|
|
1252
1252
|
return e[r].concat();
|
|
1253
|
-
const t = [], n = r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(a,
|
|
1254
|
-
return "[#" + (t.push(
|
|
1255
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(a,
|
|
1256
|
-
return "['" +
|
|
1257
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(a,
|
|
1258
|
-
return ";" +
|
|
1253
|
+
const t = [], n = r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(a, c) {
|
|
1254
|
+
return "[#" + (t.push(c) - 1) + "]";
|
|
1255
|
+
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(a, c) {
|
|
1256
|
+
return "['" + c.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
1257
|
+
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(a, c) {
|
|
1258
|
+
return ";" + c.split("").join(";") + ";";
|
|
1259
1259
|
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(a) {
|
|
1260
|
-
const
|
|
1261
|
-
return !
|
|
1260
|
+
const c = a.match(/#(\d+)/u);
|
|
1261
|
+
return !c || !c[1] ? a : t[c[1]];
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
@@ -1266,8 +1266,8 @@ x.prototype.safeVm = {
|
|
|
1266
1266
|
Script: Se
|
|
1267
1267
|
};
|
|
1268
1268
|
const Ne = function(r, e, t) {
|
|
1269
|
-
const
|
|
1270
|
-
for (let n = 0; n <
|
|
1269
|
+
const s = r.length;
|
|
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
|
}
|
|
@@ -1286,15 +1286,15 @@ class Te {
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
|
-
const
|
|
1290
|
-
Ne(
|
|
1291
|
-
const a =
|
|
1292
|
-
t = n.reduce((h,
|
|
1293
|
-
let
|
|
1294
|
-
return /function/u.test(
|
|
1295
|
-
}, "") + t, !/(['"])use strict\1/u.test(t) && !
|
|
1289
|
+
const s = Object.keys(e), n = [];
|
|
1290
|
+
Ne(s, n, (h) => typeof e[h] == "function");
|
|
1291
|
+
const a = s.map((h) => e[h]);
|
|
1292
|
+
t = n.reduce((h, v) => {
|
|
1293
|
+
let g = e[v].toString();
|
|
1294
|
+
return /function/u.test(g) || (g = "function " + g), "var " + v + "=" + g + ";" + h;
|
|
1295
|
+
}, "") + t, !/(['"])use strict\1/u.test(t) && !s.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;\s*$/u, "");
|
|
1296
1296
|
const f = t.lastIndexOf(";"), d = f !== -1 ? t.slice(0, f + 1) + " return " + t.slice(f + 1) : " return " + t;
|
|
1297
|
-
return new Function(...
|
|
1297
|
+
return new Function(...s, d)(...a);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
x.prototype.vm = {
|
|
@@ -1354,35 +1354,35 @@ const Be = { class: "json-node" }, De = {
|
|
|
1354
1354
|
ac53437c: u.theme.colors.background,
|
|
1355
1355
|
"15cbe7d4": u.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r,
|
|
1357
|
+
const t = r, s = e, n = R(!1), a = R(!1), c = R(""), f = R(""), d = (u) => {
|
|
1358
1358
|
if (!/^-?\d+(\.\d+)?$/.test(u)) return !1;
|
|
1359
|
-
const
|
|
1360
|
-
return !Number.isSafeInteger(
|
|
1361
|
-
}, h = T(() => t.value !== null && typeof t.value == "object"),
|
|
1359
|
+
const _ = Number(u);
|
|
1360
|
+
return !Number.isSafeInteger(_) || u.length > 15;
|
|
1361
|
+
}, h = T(() => t.value !== null && typeof t.value == "object"), v = T(() => Array.isArray(t.value)), g = T(() => t.path ? t.path : t.keyName ? t.keyName : "root"), k = T(() => t.expanded.has(g.value)), m = T(() => t.keyName), S = T(() => v.value ? "[" : "{"), C = T(() => v.value ? "]" : "}"), U = T(() => {
|
|
1362
1362
|
if (!t.value) return "";
|
|
1363
|
-
const
|
|
1364
|
-
return
|
|
1363
|
+
const _ = Object.keys(t.value).length;
|
|
1364
|
+
return v.value ? _ > 0 ? ` ${_} items ` : " " : _ > 0 ? ` ${_} keys ` : " ";
|
|
1365
1365
|
}), D = T(() => {
|
|
1366
1366
|
const u = typeof t.value;
|
|
1367
1367
|
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
|
-
}), Q = T(() => 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 = T(() => "Click to edit, double-click to copy"),
|
|
1369
|
-
const
|
|
1370
|
-
return
|
|
1368
|
+
}), Q = T(() => 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 = T(() => "Click to edit, double-click to copy"), J = (u) => t.level === 0 ? u : g.value ? `${g.value}.${u}` : u, V = (u) => {
|
|
1369
|
+
const _ = Object.keys(t.value);
|
|
1370
|
+
return _.indexOf(u) === _.length - 1;
|
|
1371
1371
|
}, Y = () => {
|
|
1372
|
-
|
|
1372
|
+
s("toggle-expand", g.value);
|
|
1373
1373
|
}, q = () => {
|
|
1374
|
-
t.level !== 0 && (n.value = !0,
|
|
1375
|
-
const u = document.querySelectorAll(".json-node__key-input"),
|
|
1376
|
-
|
|
1374
|
+
t.level !== 0 && (n.value = !0, c.value = t.keyName, Z(() => {
|
|
1375
|
+
const u = document.querySelectorAll(".json-node__key-input"), _ = u[u.length - 1];
|
|
1376
|
+
_ && (_.focus(), _.select());
|
|
1377
1377
|
}));
|
|
1378
|
-
},
|
|
1379
|
-
h.value || (a.value = !0, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value),
|
|
1380
|
-
const u = document.querySelectorAll(".json-node__value-input"),
|
|
1381
|
-
|
|
1378
|
+
}, ee = () => {
|
|
1379
|
+
h.value || (a.value = !0, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value), Z(() => {
|
|
1380
|
+
const u = document.querySelectorAll(".json-node__value-input"), _ = u[u.length - 1];
|
|
1381
|
+
_ && (_.focus(), _.select());
|
|
1382
1382
|
}));
|
|
1383
|
-
},
|
|
1383
|
+
}, F = () => {
|
|
1384
1384
|
if (t.level === 0 || !n.value) return;
|
|
1385
|
-
const u =
|
|
1385
|
+
const u = c.value.trim();
|
|
1386
1386
|
if (!u) {
|
|
1387
1387
|
W();
|
|
1388
1388
|
return;
|
|
@@ -1391,30 +1391,30 @@ const Be = { class: "json-node" }, De = {
|
|
|
1391
1391
|
n.value = !1;
|
|
1392
1392
|
return;
|
|
1393
1393
|
}
|
|
1394
|
-
n.value = !1,
|
|
1394
|
+
n.value = !1, s("update:key", g.value, u);
|
|
1395
1395
|
}, z = () => {
|
|
1396
1396
|
try {
|
|
1397
1397
|
let u;
|
|
1398
|
-
const
|
|
1399
|
-
if (
|
|
1398
|
+
const _ = f.value.trim();
|
|
1399
|
+
if (_ === "null")
|
|
1400
1400
|
u = null;
|
|
1401
|
-
else if (
|
|
1402
|
-
u =
|
|
1403
|
-
else if (!isNaN(Number(
|
|
1404
|
-
const K = Number(
|
|
1405
|
-
!Number.isSafeInteger(K) ||
|
|
1401
|
+
else if (_ === "true" || _ === "false")
|
|
1402
|
+
u = _ === "true";
|
|
1403
|
+
else if (!isNaN(Number(_)) && _ !== "") {
|
|
1404
|
+
const K = Number(_);
|
|
1405
|
+
!Number.isSafeInteger(K) || _.length > 15 ? u = _ : u = K;
|
|
1406
1406
|
} else
|
|
1407
1407
|
u = f.value;
|
|
1408
|
-
|
|
1408
|
+
s("update:value", g.value, u), a.value = !1;
|
|
1409
1409
|
} catch (u) {
|
|
1410
1410
|
console.error("Failed to parse value:", u), a.value = !1;
|
|
1411
1411
|
}
|
|
1412
1412
|
}, W = () => {
|
|
1413
|
-
n.value = !1,
|
|
1413
|
+
n.value = !1, c.value = t.keyName;
|
|
1414
1414
|
}, H = () => {
|
|
1415
1415
|
a.value = !1, typeof t.value == "string" && d(t.value) || typeof t.value == "string" ? f.value = t.value : f.value = String(t.value);
|
|
1416
1416
|
};
|
|
1417
|
-
return (u,
|
|
1417
|
+
return (u, _) => {
|
|
1418
1418
|
const K = pe("JsonNode", !0);
|
|
1419
1419
|
return w(), A("div", Be, [
|
|
1420
1420
|
h.value ? (w(), A("div", De, [
|
|
@@ -1424,18 +1424,18 @@ const Be = { class: "json-node" }, De = {
|
|
|
1424
1424
|
class: "json-node__key",
|
|
1425
1425
|
onClick: q,
|
|
1426
1426
|
title: "Click to edit key"
|
|
1427
|
-
}, ' "' + $(
|
|
1427
|
+
}, ' "' + $(m.value) + '" ', 1)) : N("", !0),
|
|
1428
1428
|
u.keyName && n.value ? re((w(), A("input", {
|
|
1429
1429
|
key: 1,
|
|
1430
|
-
"onUpdate:modelValue":
|
|
1430
|
+
"onUpdate:modelValue": _[0] || (_[0] = (i) => c.value = i),
|
|
1431
1431
|
onKeyup: [
|
|
1432
|
-
X(
|
|
1432
|
+
X(F, ["enter"]),
|
|
1433
1433
|
X(W, ["escape"])
|
|
1434
1434
|
],
|
|
1435
|
-
onBlur:
|
|
1435
|
+
onBlur: F,
|
|
1436
1436
|
class: "json-node__key-input"
|
|
1437
1437
|
}, null, 544)), [
|
|
1438
|
-
[ne,
|
|
1438
|
+
[ne, c.value]
|
|
1439
1439
|
]) : N("", !0),
|
|
1440
1440
|
u.keyName ? (w(), A("span", Ie, ": ")) : N("", !0),
|
|
1441
1441
|
P("span", {
|
|
@@ -1454,22 +1454,22 @@ const Be = { class: "json-node" }, De = {
|
|
|
1454
1454
|
]),
|
|
1455
1455
|
k.value ? (w(), A("div", Ue, [
|
|
1456
1456
|
P("div", Me, [
|
|
1457
|
-
(w(!0), A(ye, null, be(u.value, (i,
|
|
1458
|
-
key:
|
|
1457
|
+
(w(!0), A(ye, null, be(u.value, (i, l) => (w(), A("div", {
|
|
1458
|
+
key: l,
|
|
1459
1459
|
class: "json-node__child"
|
|
1460
1460
|
}, [
|
|
1461
1461
|
ue(K, {
|
|
1462
1462
|
value: i,
|
|
1463
|
-
"key-name":
|
|
1463
|
+
"key-name": v.value ? "" : String(l),
|
|
1464
1464
|
level: u.level + 1,
|
|
1465
|
-
path:
|
|
1465
|
+
path: J(String(l)),
|
|
1466
1466
|
expanded: u.expanded,
|
|
1467
1467
|
theme: u.theme,
|
|
1468
|
-
"onUpdate:value":
|
|
1469
|
-
onToggleExpand:
|
|
1470
|
-
onCopy:
|
|
1471
|
-
"onUpdate:key":
|
|
1472
|
-
"is-last":
|
|
1468
|
+
"onUpdate:value": _[1] || (_[1] = (y, p) => u.$emit("update:value", y, p)),
|
|
1469
|
+
onToggleExpand: _[2] || (_[2] = (y) => u.$emit("toggle-expand", y)),
|
|
1470
|
+
onCopy: _[3] || (_[3] = (y) => u.$emit("copy", y)),
|
|
1471
|
+
"onUpdate:key": _[4] || (_[4] = (y, p) => u.$emit("update:key", y, p)),
|
|
1472
|
+
"is-last": V(String(l))
|
|
1473
1473
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1474
1474
|
]))), 128))
|
|
1475
1475
|
]),
|
|
@@ -1484,25 +1484,25 @@ const Be = { class: "json-node" }, De = {
|
|
|
1484
1484
|
class: "json-node__key",
|
|
1485
1485
|
onClick: q,
|
|
1486
1486
|
title: "Click to edit key"
|
|
1487
|
-
}, ' "' + $(
|
|
1487
|
+
}, ' "' + $(m.value) + '" ', 1)) : N("", !0),
|
|
1488
1488
|
u.keyName && n.value ? re((w(), A("input", {
|
|
1489
1489
|
key: 1,
|
|
1490
|
-
"onUpdate:modelValue":
|
|
1490
|
+
"onUpdate:modelValue": _[5] || (_[5] = (i) => c.value = i),
|
|
1491
1491
|
onKeyup: [
|
|
1492
|
-
X(
|
|
1492
|
+
X(F, ["enter"]),
|
|
1493
1493
|
X(W, ["escape"])
|
|
1494
1494
|
],
|
|
1495
|
-
onBlur:
|
|
1495
|
+
onBlur: F,
|
|
1496
1496
|
class: "json-node__key-input"
|
|
1497
1497
|
}, null, 544)), [
|
|
1498
|
-
[ne,
|
|
1498
|
+
[ne, c.value]
|
|
1499
1499
|
]) : N("", !0),
|
|
1500
1500
|
u.keyName ? (w(), A("span", Xe, ": ")) : N("", !0),
|
|
1501
1501
|
a.value ? N("", !0) : (w(), A("span", {
|
|
1502
1502
|
key: 3,
|
|
1503
1503
|
class: de(["json-node__value", D.value]),
|
|
1504
|
-
onClick:
|
|
1505
|
-
onDblclick:
|
|
1504
|
+
onClick: ee,
|
|
1505
|
+
onDblclick: _[6] || (_[6] = (i) => u.$emit("copy", u.value)),
|
|
1506
1506
|
title: te.value
|
|
1507
1507
|
}, [
|
|
1508
1508
|
ie($(Q.value), 1),
|
|
@@ -1510,7 +1510,7 @@ const Be = { class: "json-node" }, De = {
|
|
|
1510
1510
|
], 42, Ge)),
|
|
1511
1511
|
a.value ? re((w(), A("input", {
|
|
1512
1512
|
key: 4,
|
|
1513
|
-
"onUpdate:modelValue":
|
|
1513
|
+
"onUpdate:modelValue": _[7] || (_[7] = (i) => f.value = i),
|
|
1514
1514
|
onKeyup: [
|
|
1515
1515
|
X(z, ["enter"]),
|
|
1516
1516
|
X(H, ["escape"])
|
|
@@ -1526,8 +1526,8 @@ const Be = { class: "json-node" }, De = {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
}), he = (r, e) => {
|
|
1528
1528
|
const t = r.__vccOpts || r;
|
|
1529
|
-
for (const [
|
|
1530
|
-
t[
|
|
1529
|
+
for (const [s, n] of e)
|
|
1530
|
+
t[s] = n;
|
|
1531
1531
|
return t;
|
|
1532
1532
|
}, qe = /* @__PURE__ */ he(Ye, [["__scopeId", "data-v-f3f3cbc9"]]), fe = {
|
|
1533
1533
|
name: "github-light",
|
|
@@ -1697,7 +1697,7 @@ function et(r = "github-light") {
|
|
|
1697
1697
|
const tt = {
|
|
1698
1698
|
key: 0,
|
|
1699
1699
|
class: "json-format__toolbar"
|
|
1700
|
-
}, rt = { class: "json-format__actions" }, nt = ["disabled"],
|
|
1700
|
+
}, rt = { class: "json-format__actions" }, nt = ["disabled"], st = ["disabled"], ot = ["disabled"], it = ["disabled"], at = { class: "json-format__info" }, lt = {
|
|
1701
1701
|
key: 0,
|
|
1702
1702
|
class: "json-format__status json-format__status--success"
|
|
1703
1703
|
}, ct = {
|
|
@@ -1725,36 +1725,47 @@ const tt = {
|
|
|
1725
1725
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1726
1726
|
setup(r, { expose: e, emit: t }) {
|
|
1727
1727
|
ce((i) => ({
|
|
1728
|
-
|
|
1729
|
-
"
|
|
1730
|
-
"
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
"
|
|
1735
|
-
|
|
1736
|
-
"
|
|
1737
|
-
|
|
1738
|
-
"
|
|
1739
|
-
"
|
|
1740
|
-
"
|
|
1741
|
-
|
|
1742
|
-
"
|
|
1743
|
-
"
|
|
1744
|
-
|
|
1728
|
+
dd679ea0: g.value.colors.border,
|
|
1729
|
+
"0543a09c": g.value.colors.background,
|
|
1730
|
+
"630352b1": g.value.colors.text,
|
|
1731
|
+
be141a92: g.value.colors.surfaceBackground,
|
|
1732
|
+
"4e0b2382": g.value.colors.buttonBorder,
|
|
1733
|
+
ee392cf8: g.value.colors.buttonBackground,
|
|
1734
|
+
"6224d203": g.value.colors.buttonText,
|
|
1735
|
+
c17e7bd0: g.value.colors.buttonBackgroundHover,
|
|
1736
|
+
"5c94496c": g.value.colors.buttonPrimary,
|
|
1737
|
+
a3b0d9a0: g.value.colors.buttonPrimaryHover,
|
|
1738
|
+
"1129928d": g.value.colors.successBackground,
|
|
1739
|
+
"24ed13ff": g.value.colors.success,
|
|
1740
|
+
"5bef9d5c": g.value.colors.errorBackground,
|
|
1741
|
+
"06cd15f8": g.value.colors.error,
|
|
1742
|
+
"4bc6db49": g.value.colors.scrollbarTrack,
|
|
1743
|
+
"4bc29bd4": g.value.colors.scrollbarThumb,
|
|
1744
|
+
aad6fc70: g.value.colors.scrollbarThumbHover
|
|
1745
1745
|
}));
|
|
1746
|
-
const
|
|
1746
|
+
const s = r, n = t, a = R(null), c = R(""), f = R(/* @__PURE__ */ new Set()), d = R(null), h = R(""), v = T(() => c.value === ""), g = T(() => et(s.theme)), k = T(() => h.value ? null : d.value !== null ? d.value : a.value), m = (i) => {
|
|
1747
1747
|
if (!i.trim()) {
|
|
1748
|
-
a.value = null,
|
|
1748
|
+
a.value = null, c.value = "", d.value = null, h.value = "";
|
|
1749
1749
|
return;
|
|
1750
1750
|
}
|
|
1751
1751
|
try {
|
|
1752
|
-
let
|
|
1753
|
-
|
|
1754
|
-
|
|
1752
|
+
let l = i;
|
|
1753
|
+
try {
|
|
1754
|
+
a.value = JSON.parse(l), c.value = "", d.value = null, h.value = "", Z(() => {
|
|
1755
|
+
k.value !== null && V();
|
|
1756
|
+
});
|
|
1757
|
+
return;
|
|
1758
|
+
} catch {
|
|
1759
|
+
}
|
|
1760
|
+
const y = l.split("");
|
|
1761
|
+
let p = !1, b = !1;
|
|
1762
|
+
for (let E = 0; E < y.length; E++)
|
|
1763
|
+
y[E] === "\\" && p ? b = !b : y[E] === '"' && !b ? p = !p : b = !1;
|
|
1764
|
+
p || (l = l.replace(/:\s*(\d{16,})\s*([,}\]])/g, ': "$1"$2'), l = l.replace(/:\s*(\d+\.\d*?0+)\s*([,}\]])/g, ': "$1"$2')), a.value = JSON.parse(l), c.value = "", d.value = null, h.value = "", Z(() => {
|
|
1765
|
+
k.value !== null && V();
|
|
1755
1766
|
});
|
|
1756
|
-
} catch (
|
|
1757
|
-
|
|
1767
|
+
} catch (l) {
|
|
1768
|
+
c.value = l instanceof Error ? l.message : "Unknown parsing error", a.value = null, d.value = null, h.value = "";
|
|
1758
1769
|
}
|
|
1759
1770
|
}, S = (i) => {
|
|
1760
1771
|
if (!i || !i.expression.trim()) {
|
|
@@ -1766,229 +1777,229 @@ const tt = {
|
|
|
1766
1777
|
return;
|
|
1767
1778
|
}
|
|
1768
1779
|
try {
|
|
1769
|
-
let
|
|
1780
|
+
let l;
|
|
1770
1781
|
if (i.type === "jsonpath")
|
|
1771
|
-
|
|
1782
|
+
l = x({ path: i.expression, json: a.value }), l.length === 1 && i.expression.includes("$[") === !1 && !i.expression.endsWith("[*]") ? d.value = l[0] : d.value = l;
|
|
1772
1783
|
else if (i.type === "js")
|
|
1773
|
-
|
|
1784
|
+
l = new Function("data", `
|
|
1774
1785
|
try {
|
|
1775
1786
|
return ${i.expression};
|
|
1776
1787
|
} catch (error) {
|
|
1777
1788
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1778
1789
|
}
|
|
1779
|
-
`)(a.value), d.value =
|
|
1790
|
+
`)(a.value), d.value = l;
|
|
1780
1791
|
else
|
|
1781
1792
|
throw new Error(`Unsupported filter type: ${i.type}`);
|
|
1782
|
-
h.value = "",
|
|
1783
|
-
|
|
1793
|
+
h.value = "", Z(() => {
|
|
1794
|
+
V();
|
|
1784
1795
|
});
|
|
1785
|
-
} catch (
|
|
1786
|
-
h.value =
|
|
1796
|
+
} catch (l) {
|
|
1797
|
+
h.value = l instanceof Error ? l.message : "Filter execution error", d.value = null;
|
|
1787
1798
|
}
|
|
1788
1799
|
}, C = () => {
|
|
1789
1800
|
d.value = null, h.value = "";
|
|
1790
1801
|
};
|
|
1791
|
-
ge(() =>
|
|
1792
|
-
|
|
1802
|
+
ge(() => s.modelValue, (i) => {
|
|
1803
|
+
m(i);
|
|
1793
1804
|
}, { immediate: !0 });
|
|
1794
1805
|
const U = (i) => {
|
|
1795
1806
|
if (!/^-?\d+(\.\d+)?$/.test(i)) return !1;
|
|
1796
|
-
const
|
|
1797
|
-
return !Number.isSafeInteger(
|
|
1798
|
-
}, D = (i,
|
|
1799
|
-
if (typeof
|
|
1800
|
-
return `__BIG_NUMBER__${
|
|
1801
|
-
if (typeof
|
|
1802
|
-
const
|
|
1803
|
-
if (Number.isSafeInteger(
|
|
1804
|
-
return
|
|
1805
|
-
if (!Number.isNaN(
|
|
1806
|
-
return
|
|
1807
|
-
if (!Number.isNaN(
|
|
1808
|
-
return
|
|
1807
|
+
const l = Number(i);
|
|
1808
|
+
return !Number.isSafeInteger(l) || i.length > 15;
|
|
1809
|
+
}, D = (i, l, y) => JSON.stringify(i, (p, b) => {
|
|
1810
|
+
if (typeof b == "string" && U(b))
|
|
1811
|
+
return `__BIG_NUMBER__${b}__BIG_NUMBER__`;
|
|
1812
|
+
if (typeof b == "string" && /^-?\d+(\.\d+)?$/.test(b)) {
|
|
1813
|
+
const E = Number(b);
|
|
1814
|
+
if (Number.isSafeInteger(E) && E.toString() === b)
|
|
1815
|
+
return E;
|
|
1816
|
+
if (!Number.isNaN(E) && isFinite(E) && b.includes("."))
|
|
1817
|
+
return E.toString() === b ? E : `__PRESERVE_STRING__${b}__PRESERVE_STRING__`;
|
|
1818
|
+
if (!Number.isNaN(E) && isFinite(E))
|
|
1819
|
+
return E;
|
|
1809
1820
|
}
|
|
1810
|
-
return
|
|
1811
|
-
}, y).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g, "$1").replace(/"__PRESERVE_STRING__(.+?)__PRESERVE_STRING__"/g, "$1"), Q = (i,
|
|
1812
|
-
if (!
|
|
1821
|
+
return l && typeof l == "function" ? l(p, b) : b;
|
|
1822
|
+
}, y).replace(/"__BIG_NUMBER__(.+?)__BIG_NUMBER__"/g, "$1").replace(/"__PRESERVE_STRING__(.+?)__PRESERVE_STRING__"/g, "$1"), Q = (i, l) => {
|
|
1823
|
+
if (!s.readonly)
|
|
1813
1824
|
try {
|
|
1814
|
-
const y = te(a.value, i,
|
|
1815
|
-
n("update:modelValue",
|
|
1825
|
+
const y = te(a.value, i, l), p = D(y, null, 2);
|
|
1826
|
+
n("update:modelValue", p);
|
|
1816
1827
|
} catch (y) {
|
|
1817
1828
|
console.error("Failed to update JSON:", y);
|
|
1818
1829
|
}
|
|
1819
|
-
}, te = (i,
|
|
1820
|
-
if (!
|
|
1821
|
-
const
|
|
1822
|
-
let
|
|
1823
|
-
for (let j = 0; j <
|
|
1824
|
-
const I =
|
|
1825
|
-
I !== "root" && (Array.isArray(
|
|
1830
|
+
}, te = (i, l, y) => {
|
|
1831
|
+
if (!l || l === "root") return y;
|
|
1832
|
+
const p = l.split("."), b = H(i, p.slice(0, -1));
|
|
1833
|
+
let E = b;
|
|
1834
|
+
for (let j = 0; j < p.length - 1; j++) {
|
|
1835
|
+
const I = p[j];
|
|
1836
|
+
I !== "root" && (Array.isArray(E) ? E = E[parseInt(I)] : E = E[I]);
|
|
1826
1837
|
}
|
|
1827
|
-
const B =
|
|
1828
|
-
return B === "root" ? y : (Array.isArray(
|
|
1829
|
-
},
|
|
1838
|
+
const B = p[p.length - 1];
|
|
1839
|
+
return B === "root" ? y : (Array.isArray(E) ? E[parseInt(B)] = y : E[B] = y, b);
|
|
1840
|
+
}, J = (i) => {
|
|
1830
1841
|
f.value.has(i) ? f.value.delete(i) : f.value.add(i);
|
|
1831
|
-
},
|
|
1832
|
-
const i = /* @__PURE__ */ new Set(),
|
|
1833
|
-
y !== null && typeof y == "object" && (i.add(
|
|
1834
|
-
const B =
|
|
1835
|
-
|
|
1836
|
-
}) : Object.keys(y).forEach((
|
|
1837
|
-
const
|
|
1838
|
-
|
|
1842
|
+
}, V = () => {
|
|
1843
|
+
const i = /* @__PURE__ */ new Set(), l = (y, p = "") => {
|
|
1844
|
+
y !== null && typeof y == "object" && (i.add(p || "root"), Array.isArray(y) ? y.forEach((b, E) => {
|
|
1845
|
+
const B = p ? `${p}.${E}` : `${E}`;
|
|
1846
|
+
l(b, B);
|
|
1847
|
+
}) : Object.keys(y).forEach((b) => {
|
|
1848
|
+
const E = p ? `${p}.${b}` : b;
|
|
1849
|
+
l(y[b], E);
|
|
1839
1850
|
}));
|
|
1840
1851
|
};
|
|
1841
|
-
|
|
1852
|
+
l(k.value), f.value = i, n("expand-all");
|
|
1842
1853
|
}, Y = () => {
|
|
1843
1854
|
f.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1844
1855
|
}, q = async () => {
|
|
1845
|
-
if (
|
|
1856
|
+
if (v.value)
|
|
1846
1857
|
try {
|
|
1847
|
-
const i = k.value,
|
|
1848
|
-
await navigator.clipboard.writeText(
|
|
1858
|
+
const i = k.value, l = D(i, null, 2);
|
|
1859
|
+
await navigator.clipboard.writeText(l), n("copy-success", l);
|
|
1849
1860
|
} catch (i) {
|
|
1850
1861
|
console.error("Failed to copy JSON:", i), n("copy-error", i instanceof Error ? i : new Error("Failed to copy JSON"));
|
|
1851
1862
|
}
|
|
1852
|
-
},
|
|
1853
|
-
if (
|
|
1863
|
+
}, ee = () => {
|
|
1864
|
+
if (v.value)
|
|
1854
1865
|
try {
|
|
1855
|
-
const i = k.value,
|
|
1856
|
-
n("update:modelValue",
|
|
1866
|
+
const i = k.value, l = D(i);
|
|
1867
|
+
n("update:modelValue", l), n("compress", l);
|
|
1857
1868
|
} catch (i) {
|
|
1858
1869
|
console.error("Failed to compress JSON:", i);
|
|
1859
1870
|
}
|
|
1860
|
-
},
|
|
1871
|
+
}, F = async (i) => {
|
|
1861
1872
|
try {
|
|
1862
|
-
let
|
|
1863
|
-
typeof i == "string" && U(i) ?
|
|
1864
|
-
} catch (
|
|
1865
|
-
console.error("Failed to copy value:",
|
|
1873
|
+
let l;
|
|
1874
|
+
typeof i == "string" && U(i) ? l = i : typeof i == "string" ? l = `"${i}"` : l = JSON.stringify(i), await navigator.clipboard.writeText(l);
|
|
1875
|
+
} catch (l) {
|
|
1876
|
+
console.error("Failed to copy value:", l);
|
|
1866
1877
|
}
|
|
1867
|
-
}, z = (i,
|
|
1868
|
-
if (!
|
|
1878
|
+
}, z = (i, l) => {
|
|
1879
|
+
if (!s.readonly)
|
|
1869
1880
|
try {
|
|
1870
|
-
const y = W(a.value, i,
|
|
1871
|
-
n("update:modelValue",
|
|
1881
|
+
const y = W(a.value, i, l), p = D(y, null, 2);
|
|
1882
|
+
n("update:modelValue", p), K(i, l);
|
|
1872
1883
|
} catch (y) {
|
|
1873
1884
|
console.error("Failed to rename key:", y);
|
|
1874
1885
|
}
|
|
1875
|
-
}, W = (i,
|
|
1876
|
-
if (!
|
|
1877
|
-
const
|
|
1878
|
-
if (
|
|
1879
|
-
const j =
|
|
1880
|
-
return
|
|
1886
|
+
}, W = (i, l, y) => {
|
|
1887
|
+
if (!l || l === "root") return i;
|
|
1888
|
+
const p = l.split("."), b = H(i, p.slice(0, -1));
|
|
1889
|
+
if (p.length === 1) {
|
|
1890
|
+
const j = p[0];
|
|
1891
|
+
return b && typeof b == "object" && !Array.isArray(b) ? u(b, j, y) : b;
|
|
1881
1892
|
}
|
|
1882
|
-
let
|
|
1883
|
-
for (let j = 0; j <
|
|
1884
|
-
const I =
|
|
1885
|
-
Array.isArray(
|
|
1893
|
+
let E = b;
|
|
1894
|
+
for (let j = 0; j < p.length - 1; j++) {
|
|
1895
|
+
const I = p[j];
|
|
1896
|
+
Array.isArray(E) ? E = E[parseInt(I)] : E = E[I];
|
|
1886
1897
|
}
|
|
1887
|
-
const B =
|
|
1888
|
-
if (!Array.isArray(
|
|
1889
|
-
const j = u(
|
|
1890
|
-
I.length > 0 &&
|
|
1898
|
+
const B = p[p.length - 1];
|
|
1899
|
+
if (!Array.isArray(E) && E && typeof E == "object") {
|
|
1900
|
+
const j = u(E, B, y), I = p.slice(0, -1);
|
|
1901
|
+
I.length > 0 && _(b, I, j);
|
|
1891
1902
|
}
|
|
1892
|
-
return
|
|
1893
|
-
}, H = (i,
|
|
1894
|
-
if (
|
|
1903
|
+
return b;
|
|
1904
|
+
}, H = (i, l) => {
|
|
1905
|
+
if (l.length === 0) return i;
|
|
1895
1906
|
if (Array.isArray(i)) {
|
|
1896
|
-
const y = [...i],
|
|
1897
|
-
return
|
|
1907
|
+
const y = [...i], p = l[0], b = parseInt(p);
|
|
1908
|
+
return l.length === 1 || (y[b] = H(i[b], l.slice(1))), y;
|
|
1898
1909
|
} else if (i && typeof i == "object") {
|
|
1899
|
-
const y = { ...i },
|
|
1900
|
-
return
|
|
1910
|
+
const y = { ...i }, p = l[0];
|
|
1911
|
+
return l.length === 1 || (y[p] = H(i[p], l.slice(1))), y;
|
|
1901
1912
|
}
|
|
1902
1913
|
return i;
|
|
1903
|
-
}, u = (i,
|
|
1914
|
+
}, u = (i, l, y) => {
|
|
1904
1915
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
1905
1916
|
return i;
|
|
1906
|
-
const
|
|
1907
|
-
for (const
|
|
1908
|
-
|
|
1909
|
-
return
|
|
1910
|
-
},
|
|
1911
|
-
let
|
|
1912
|
-
for (let
|
|
1913
|
-
const B =
|
|
1914
|
-
Array.isArray(
|
|
1917
|
+
const p = Object.keys(i), b = {};
|
|
1918
|
+
for (const E of p)
|
|
1919
|
+
E === l ? b[y] = i[E] : b[E] = i[E];
|
|
1920
|
+
return b;
|
|
1921
|
+
}, _ = (i, l, y) => {
|
|
1922
|
+
let p = i;
|
|
1923
|
+
for (let E = 0; E < l.length - 1; E++) {
|
|
1924
|
+
const B = l[E];
|
|
1925
|
+
Array.isArray(p) ? p = p[parseInt(B)] : p = p[B];
|
|
1915
1926
|
}
|
|
1916
|
-
const
|
|
1917
|
-
Array.isArray(
|
|
1918
|
-
}, K = (i,
|
|
1927
|
+
const b = l[l.length - 1];
|
|
1928
|
+
Array.isArray(p) ? p[parseInt(b)] = y : p[b] = y;
|
|
1929
|
+
}, K = (i, l) => {
|
|
1919
1930
|
const y = /* @__PURE__ */ new Set();
|
|
1920
|
-
f.value.forEach((
|
|
1921
|
-
if (
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
} else if (
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
const
|
|
1928
|
-
y.add(
|
|
1931
|
+
f.value.forEach((p) => {
|
|
1932
|
+
if (p === i) {
|
|
1933
|
+
const b = i.split(".");
|
|
1934
|
+
b[b.length - 1] = l, y.add(b.join("."));
|
|
1935
|
+
} else if (p.startsWith(i + ".")) {
|
|
1936
|
+
const b = i.split(".");
|
|
1937
|
+
b[b.length - 1] = l;
|
|
1938
|
+
const E = b.join("."), B = p.substring(i.length);
|
|
1939
|
+
y.add(E + B);
|
|
1929
1940
|
} else
|
|
1930
|
-
y.add(
|
|
1941
|
+
y.add(p);
|
|
1931
1942
|
}), f.value = y;
|
|
1932
1943
|
};
|
|
1933
1944
|
return e({
|
|
1934
1945
|
// 核心操作方法
|
|
1935
1946
|
copyJson: q,
|
|
1936
|
-
compressSource:
|
|
1937
|
-
expandAll:
|
|
1947
|
+
compressSource: ee,
|
|
1948
|
+
expandAll: V,
|
|
1938
1949
|
collapseAll: Y,
|
|
1939
|
-
toggleExpand:
|
|
1950
|
+
toggleExpand: J,
|
|
1940
1951
|
updateValue: Q,
|
|
1941
1952
|
updateKey: z,
|
|
1942
1953
|
// Filter 相关方法
|
|
1943
1954
|
filter: S,
|
|
1944
1955
|
clearFilter: C,
|
|
1945
1956
|
// 状态访问方法
|
|
1946
|
-
isValidJson: () =>
|
|
1957
|
+
isValidJson: () => v.value,
|
|
1947
1958
|
getParsedJson: () => a.value,
|
|
1948
1959
|
getFilteredJson: () => d.value,
|
|
1949
1960
|
getExpandedNodes: () => f.value,
|
|
1950
|
-
getParseError: () =>
|
|
1961
|
+
getParseError: () => c.value,
|
|
1951
1962
|
getFilterError: () => h.value,
|
|
1952
1963
|
// 工具方法
|
|
1953
|
-
parseJson: (i) =>
|
|
1954
|
-
copyValue: (i) =>
|
|
1955
|
-
}), (i,
|
|
1956
|
-
class: de(["json-format", `json-format--${
|
|
1964
|
+
parseJson: (i) => m(i),
|
|
1965
|
+
copyValue: (i) => F(i)
|
|
1966
|
+
}), (i, l) => (w(), A("div", {
|
|
1967
|
+
class: de(["json-format", `json-format--${g.value.name}`])
|
|
1957
1968
|
}, [
|
|
1958
1969
|
i.showToolbar ? (w(), A("div", tt, [
|
|
1959
1970
|
P("div", rt, [
|
|
1960
1971
|
P("button", {
|
|
1961
1972
|
class: "json-format__btn json-format__btn--primary",
|
|
1962
1973
|
onClick: q,
|
|
1963
|
-
disabled: !
|
|
1974
|
+
disabled: !v.value,
|
|
1964
1975
|
title: "Copy JSON"
|
|
1965
1976
|
}, " 📋 Copy ", 8, nt),
|
|
1966
1977
|
P("button", {
|
|
1967
1978
|
class: "json-format__btn json-format__btn--secondary",
|
|
1968
|
-
onClick:
|
|
1969
|
-
disabled: !
|
|
1979
|
+
onClick: V,
|
|
1980
|
+
disabled: !v.value,
|
|
1970
1981
|
title: "Expand All"
|
|
1971
|
-
}, " ⬇️ Expand All ", 8,
|
|
1982
|
+
}, " ⬇️ Expand All ", 8, st),
|
|
1972
1983
|
P("button", {
|
|
1973
1984
|
class: "json-format__btn json-format__btn--secondary",
|
|
1974
1985
|
onClick: Y,
|
|
1975
|
-
disabled: !
|
|
1986
|
+
disabled: !v.value,
|
|
1976
1987
|
title: "Collapse All"
|
|
1977
|
-
}, " ➡️ Collapse All ", 8,
|
|
1988
|
+
}, " ➡️ Collapse All ", 8, ot),
|
|
1978
1989
|
P("button", {
|
|
1979
1990
|
class: "json-format__btn json-format__btn--secondary",
|
|
1980
|
-
onClick:
|
|
1981
|
-
disabled: !
|
|
1991
|
+
onClick: ee,
|
|
1992
|
+
disabled: !v.value,
|
|
1982
1993
|
title: "Compress JSON"
|
|
1983
1994
|
}, " 📦 Compress ", 8, it)
|
|
1984
1995
|
]),
|
|
1985
1996
|
P("div", at, [
|
|
1986
|
-
|
|
1997
|
+
v.value ? (w(), A("span", lt, " ✅ Valid JSON ")) : (w(), A("span", ct, " ❌ Invalid JSON "))
|
|
1987
1998
|
])
|
|
1988
1999
|
])) : N("", !0),
|
|
1989
2000
|
P("div", ut, [
|
|
1990
|
-
|
|
1991
|
-
|
|
2001
|
+
v.value ? h.value ? (w(), A("div", ht, [
|
|
2002
|
+
l[1] || (l[1] = P("h4", null, "Filter Error:", -1)),
|
|
1992
2003
|
P("pre", null, $(h.value), 1)
|
|
1993
2004
|
])) : (w(), A("div", ft, [
|
|
1994
2005
|
ue(qe, {
|
|
@@ -1997,20 +2008,20 @@ const tt = {
|
|
|
1997
2008
|
level: 0,
|
|
1998
2009
|
expanded: f.value,
|
|
1999
2010
|
"is-last": !0,
|
|
2000
|
-
theme:
|
|
2011
|
+
theme: g.value,
|
|
2001
2012
|
"onUpdate:value": Q,
|
|
2002
|
-
onToggleExpand:
|
|
2003
|
-
onCopy:
|
|
2013
|
+
onToggleExpand: J,
|
|
2014
|
+
onCopy: F,
|
|
2004
2015
|
"onUpdate:key": z
|
|
2005
2016
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2006
2017
|
])) : (w(), A("div", dt, [
|
|
2007
|
-
|
|
2008
|
-
P("pre", null, $(
|
|
2018
|
+
l[0] || (l[0] = P("h4", null, "JSON Parse Error:", -1)),
|
|
2019
|
+
P("pre", null, $(c.value), 1)
|
|
2009
2020
|
]))
|
|
2010
2021
|
])
|
|
2011
2022
|
], 2));
|
|
2012
2023
|
}
|
|
2013
|
-
}), yt = /* @__PURE__ */ he(pt, [["__scopeId", "data-v-
|
|
2024
|
+
}), yt = /* @__PURE__ */ he(pt, [["__scopeId", "data-v-c6bbb1e1"]]), bt = [yt], gt = (r) => {
|
|
2014
2025
|
bt.forEach((e) => {
|
|
2015
2026
|
const t = e.name || e.__name || "UnknownComponent";
|
|
2016
2027
|
r.component(t, e);
|