lone-format 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lone-format.css +1 -1
- package/dist/lone-format.js +736 -768
- 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 de, useCssVars as he, ref as U, computed as D, resolveComponent as ge, createElementBlock as A, openBlock as C, createElementVNode as N, createCommentVNode as j, withDirectives as oe, toDisplayString as L, withKeys as Y, vModelText as se, createTextVNode as ce, Fragment as ve, renderList as me, createVNode as fe, normalizeClass as pe, nextTick as W, watch as Ee } from "vue";
|
|
2
|
+
class _e {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -18,13 +18,13 @@ class Ce {
|
|
|
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, o) {
|
|
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][o ? "unshift" : "push"](t);
|
|
28
28
|
}, this);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -37,12 +37,12 @@ class Ce {
|
|
|
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(o) {
|
|
41
|
+
o.call(t && t.context ? t.context : t, t);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class xe {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -60,8 +60,8 @@ class Ae {
|
|
|
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), o = 0; o < e; o++)
|
|
64
|
+
t[o] = arguments[o];
|
|
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 Ae {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class s {
|
|
73
73
|
/**
|
|
74
74
|
* @returns {string}
|
|
75
75
|
*/
|
|
@@ -80,7 +80,7 @@ class o {
|
|
|
80
80
|
* @returns {string}
|
|
81
81
|
*/
|
|
82
82
|
static toString() {
|
|
83
|
-
return "JavaScript Expression Parser (JSEP) v" +
|
|
83
|
+
return "JavaScript Expression Parser (JSEP) v" + s.version;
|
|
84
84
|
}
|
|
85
85
|
// ==================== CONFIG ================================
|
|
86
86
|
/**
|
|
@@ -89,7 +89,7 @@ class o {
|
|
|
89
89
|
* @returns {Jsep}
|
|
90
90
|
*/
|
|
91
91
|
static addUnaryOp(e) {
|
|
92
|
-
return
|
|
92
|
+
return s.max_unop_len = Math.max(e.length, s.max_unop_len), s.unary_ops[e] = 1, s;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* @method jsep.addBinaryOp
|
|
@@ -98,8 +98,8 @@ class o {
|
|
|
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, o) {
|
|
102
|
+
return s.max_binop_len = Math.max(e.length, s.max_binop_len), s.binary_ops[e] = t, o ? s.right_associative.add(e) : s.right_associative.delete(e), s;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* @method addIdentifierChar
|
|
@@ -107,7 +107,7 @@ class o {
|
|
|
107
107
|
* @returns {Jsep}
|
|
108
108
|
*/
|
|
109
109
|
static addIdentifierChar(e) {
|
|
110
|
-
return
|
|
110
|
+
return s.additional_identifier_chars.add(e), s;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* @method addLiteral
|
|
@@ -116,7 +116,7 @@ class o {
|
|
|
116
116
|
* @returns {Jsep}
|
|
117
117
|
*/
|
|
118
118
|
static addLiteral(e, t) {
|
|
119
|
-
return
|
|
119
|
+
return s.literals[e] = t, s;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* @method removeUnaryOp
|
|
@@ -124,14 +124,14 @@ class o {
|
|
|
124
124
|
* @returns {Jsep}
|
|
125
125
|
*/
|
|
126
126
|
static removeUnaryOp(e) {
|
|
127
|
-
return delete
|
|
127
|
+
return delete s.unary_ops[e], e.length === s.max_unop_len && (s.max_unop_len = s.getMaxKeyLen(s.unary_ops)), s;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* @method removeAllUnaryOps
|
|
131
131
|
* @returns {Jsep}
|
|
132
132
|
*/
|
|
133
133
|
static removeAllUnaryOps() {
|
|
134
|
-
return
|
|
134
|
+
return s.unary_ops = {}, s.max_unop_len = 0, s;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* @method removeIdentifierChar
|
|
@@ -139,7 +139,7 @@ class o {
|
|
|
139
139
|
* @returns {Jsep}
|
|
140
140
|
*/
|
|
141
141
|
static removeIdentifierChar(e) {
|
|
142
|
-
return
|
|
142
|
+
return s.additional_identifier_chars.delete(e), s;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* @method removeBinaryOp
|
|
@@ -147,14 +147,14 @@ class o {
|
|
|
147
147
|
* @returns {Jsep}
|
|
148
148
|
*/
|
|
149
149
|
static removeBinaryOp(e) {
|
|
150
|
-
return delete
|
|
150
|
+
return delete s.binary_ops[e], e.length === s.max_binop_len && (s.max_binop_len = s.getMaxKeyLen(s.binary_ops)), s.right_associative.delete(e), s;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* @method removeAllBinaryOps
|
|
154
154
|
* @returns {Jsep}
|
|
155
155
|
*/
|
|
156
156
|
static removeAllBinaryOps() {
|
|
157
|
-
return
|
|
157
|
+
return s.binary_ops = {}, s.max_binop_len = 0, s;
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* @method removeLiteral
|
|
@@ -162,14 +162,14 @@ class o {
|
|
|
162
162
|
* @returns {Jsep}
|
|
163
163
|
*/
|
|
164
164
|
static removeLiteral(e) {
|
|
165
|
-
return delete
|
|
165
|
+
return delete s.literals[e], s;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* @method removeAllLiterals
|
|
169
169
|
* @returns {Jsep}
|
|
170
170
|
*/
|
|
171
171
|
static removeAllLiterals() {
|
|
172
|
-
return
|
|
172
|
+
return s.literals = {}, s;
|
|
173
173
|
}
|
|
174
174
|
// ==================== END CONFIG ============================
|
|
175
175
|
/**
|
|
@@ -196,7 +196,7 @@ class o {
|
|
|
196
196
|
* @returns {jsep.Expression}
|
|
197
197
|
*/
|
|
198
198
|
static parse(e) {
|
|
199
|
-
return new
|
|
199
|
+
return new s(e).parse();
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Get the longest key length of any object
|
|
@@ -220,7 +220,7 @@ class o {
|
|
|
220
220
|
* @returns {number}
|
|
221
221
|
*/
|
|
222
222
|
static binaryPrecedence(e) {
|
|
223
|
-
return
|
|
223
|
+
return s.binary_ops[e] || 0;
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* Looks for start of identifier
|
|
@@ -230,15 +230,15 @@ class o {
|
|
|
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 && !s.binary_ops[String.fromCharCode(e)] || // any non-ASCII that is not an operator
|
|
234
|
+
s.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 s.isIdentifierStart(e) || s.isDecimalDigit(e);
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* throw error at index of the expression
|
|
@@ -256,12 +256,12 @@ class o {
|
|
|
256
256
|
* @returns {?jsep.Expression}
|
|
257
257
|
*/
|
|
258
258
|
runHook(e, t) {
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
259
|
+
if (s.hooks[e]) {
|
|
260
|
+
const o = {
|
|
261
261
|
context: this,
|
|
262
262
|
node: t
|
|
263
263
|
};
|
|
264
|
-
return
|
|
264
|
+
return s.hooks.run(e, o), o.node;
|
|
265
265
|
}
|
|
266
266
|
return t;
|
|
267
267
|
}
|
|
@@ -271,12 +271,12 @@ class o {
|
|
|
271
271
|
* @returns {?jsep.Expression}
|
|
272
272
|
*/
|
|
273
273
|
searchHook(e) {
|
|
274
|
-
if (
|
|
274
|
+
if (s.hooks[e]) {
|
|
275
275
|
const t = {
|
|
276
276
|
context: this
|
|
277
277
|
};
|
|
278
|
-
return
|
|
279
|
-
return
|
|
278
|
+
return s.hooks[e].find(function(o) {
|
|
279
|
+
return o.call(t.context, t), t.node;
|
|
280
280
|
}), t.node;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -285,7 +285,7 @@ class o {
|
|
|
285
285
|
*/
|
|
286
286
|
gobbleSpaces() {
|
|
287
287
|
let e = this.code;
|
|
288
|
-
for (; e ===
|
|
288
|
+
for (; e === s.SPACE_CODE || e === s.TAB_CODE || e === s.LF_CODE || e === s.CR_CODE; )
|
|
289
289
|
e = this.expr.charCodeAt(++this.index);
|
|
290
290
|
this.runHook("gobble-spaces");
|
|
291
291
|
}
|
|
@@ -296,7 +296,7 @@ class o {
|
|
|
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: s.COMPOUND,
|
|
300
300
|
body: e
|
|
301
301
|
};
|
|
302
302
|
return this.runHook("after-all", t);
|
|
@@ -307,14 +307,14 @@ class o {
|
|
|
307
307
|
* @returns {jsep.Expression[]}
|
|
308
308
|
*/
|
|
309
309
|
gobbleExpressions(e) {
|
|
310
|
-
let t = [],
|
|
310
|
+
let t = [], o, n;
|
|
311
311
|
for (; this.index < this.expr.length; )
|
|
312
|
-
if (
|
|
312
|
+
if (o = this.code, o === s.SEMCOL_CODE || o === s.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 (o === e)
|
|
318
318
|
break;
|
|
319
319
|
this.throwError('Unexpected "' + this.char + '"');
|
|
320
320
|
}
|
|
@@ -337,9 +337,9 @@ class o {
|
|
|
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, s.max_binop_len), t = e.length;
|
|
341
341
|
for (; t > 0; ) {
|
|
342
|
-
if (
|
|
342
|
+
if (s.binary_ops.hasOwnProperty(e) && (!s.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !s.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,40 +351,40 @@ class o {
|
|
|
351
351
|
* @returns {?jsep.BinaryExpression}
|
|
352
352
|
*/
|
|
353
353
|
gobbleBinaryExpression() {
|
|
354
|
-
let e, t,
|
|
355
|
-
if (
|
|
356
|
-
return
|
|
354
|
+
let e, t, o, n, a, l, f, d, h;
|
|
355
|
+
if (l = this.gobbleToken(), !l || (t = this.gobbleBinaryOp(), !t))
|
|
356
|
+
return l;
|
|
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: s.binaryPrecedence(t),
|
|
360
|
+
right_a: s.right_associative.has(t)
|
|
361
|
+
}, f = this.gobbleToken(), f || this.throwError("Expected expression after " + t), n = [l, a, f]; t = this.gobbleBinaryOp(); ) {
|
|
362
|
+
if (o = s.binaryPrecedence(t), o === 0) {
|
|
363
363
|
this.index -= t.length;
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
366
|
a = {
|
|
367
367
|
value: t,
|
|
368
|
-
prec:
|
|
369
|
-
right_a:
|
|
370
|
-
},
|
|
371
|
-
const
|
|
372
|
-
for (; n.length > 2 &&
|
|
373
|
-
f = n.pop(), t = n.pop().value,
|
|
374
|
-
type:
|
|
368
|
+
prec: o,
|
|
369
|
+
right_a: s.right_associative.has(t)
|
|
370
|
+
}, h = t;
|
|
371
|
+
const m = (g) => a.right_a && g.right_a ? o > g.prec : o <= g.prec;
|
|
372
|
+
for (; n.length > 2 && m(n[n.length - 2]); )
|
|
373
|
+
f = n.pop(), t = n.pop().value, l = n.pop(), e = {
|
|
374
|
+
type: s.BINARY_EXP,
|
|
375
375
|
operator: t,
|
|
376
|
-
left:
|
|
376
|
+
left: l,
|
|
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 " + h), n.push(a, e);
|
|
380
380
|
}
|
|
381
|
-
for (
|
|
381
|
+
for (d = n.length - 1, e = n[d]; d > 1; )
|
|
382
382
|
e = {
|
|
383
|
-
type:
|
|
384
|
-
operator: n[
|
|
385
|
-
left: n[
|
|
383
|
+
type: s.BINARY_EXP,
|
|
384
|
+
operator: n[d - 1].value,
|
|
385
|
+
left: n[d - 2],
|
|
386
386
|
right: e
|
|
387
|
-
},
|
|
387
|
+
}, d -= 2;
|
|
388
388
|
return e;
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
@@ -393,36 +393,36 @@ class o {
|
|
|
393
393
|
* @returns {boolean|jsep.Expression}
|
|
394
394
|
*/
|
|
395
395
|
gobbleToken() {
|
|
396
|
-
let e, t,
|
|
396
|
+
let e, t, o, 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, s.isDecimalDigit(e) || e === s.PERIOD_CODE)
|
|
400
400
|
return this.gobbleNumericLiteral();
|
|
401
|
-
if (e ===
|
|
401
|
+
if (e === s.SQUOTE_CODE || e === s.DQUOTE_CODE)
|
|
402
402
|
n = this.gobbleStringLiteral();
|
|
403
|
-
else if (e ===
|
|
403
|
+
else if (e === s.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, s.max_unop_len), o = t.length; o > 0; ) {
|
|
407
|
+
if (s.unary_ops.hasOwnProperty(t) && (!s.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !s.isIdentifierPart(this.expr.charCodeAt(this.index + t.length)))) {
|
|
408
|
+
this.index += o;
|
|
409
409
|
const a = this.gobbleToken();
|
|
410
410
|
return a || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
411
|
-
type:
|
|
411
|
+
type: s.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, --o);
|
|
418
418
|
}
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
value:
|
|
419
|
+
s.isIdentifierStart(e) ? (n = this.gobbleIdentifier(), s.literals.hasOwnProperty(n.name) ? n = {
|
|
420
|
+
type: s.LITERAL,
|
|
421
|
+
value: s.literals[n.name],
|
|
422
422
|
raw: n.name
|
|
423
|
-
} : n.name ===
|
|
424
|
-
type:
|
|
425
|
-
})) : e ===
|
|
423
|
+
} : n.name === s.this_str && (n = {
|
|
424
|
+
type: s.THIS_EXP
|
|
425
|
+
})) : e === s.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 o {
|
|
|
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 === s.PERIOD_CODE || t === s.OBRACK_CODE || t === s.OPAREN_CODE || t === s.QUMARK_CODE; ) {
|
|
441
|
+
let o;
|
|
442
|
+
if (t === s.QUMARK_CODE) {
|
|
443
|
+
if (this.expr.charCodeAt(this.index + 1) !== s.PERIOD_CODE)
|
|
444
444
|
break;
|
|
445
|
-
|
|
445
|
+
o = !0, this.index += 2, this.gobbleSpaces(), t = this.code;
|
|
446
446
|
}
|
|
447
|
-
this.index++, t ===
|
|
448
|
-
type:
|
|
447
|
+
this.index++, t === s.OBRACK_CODE ? (e = {
|
|
448
|
+
type: s.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 !== s.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : t === s.OPAREN_CODE ? e = {
|
|
453
|
+
type: s.CALL_EXP,
|
|
454
|
+
arguments: this.gobbleArguments(s.CPAREN_CODE),
|
|
455
455
|
callee: e
|
|
456
|
-
} : (t ===
|
|
457
|
-
type:
|
|
456
|
+
} : (t === s.PERIOD_CODE || o) && (o && this.index--, this.gobbleSpaces(), e = {
|
|
457
|
+
type: s.MEMBER_EXP,
|
|
458
458
|
computed: !1,
|
|
459
459
|
object: e,
|
|
460
460
|
property: this.gobbleIdentifier()
|
|
461
|
-
}),
|
|
461
|
+
}), o && (e.optional = !0), this.gobbleSpaces(), t = this.code;
|
|
462
462
|
}
|
|
463
463
|
return e;
|
|
464
464
|
}
|
|
@@ -468,19 +468,19 @@ class o {
|
|
|
468
468
|
* @returns {jsep.Literal}
|
|
469
469
|
*/
|
|
470
470
|
gobbleNumericLiteral() {
|
|
471
|
-
let e = "", t,
|
|
472
|
-
for (;
|
|
471
|
+
let e = "", t, o;
|
|
472
|
+
for (; s.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 === s.PERIOD_CODE)
|
|
475
|
+
for (e += this.expr.charAt(this.index++); s.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++)); s.isDecimalDigit(this.code); )
|
|
479
479
|
e += this.expr.charAt(this.index++);
|
|
480
|
-
|
|
480
|
+
s.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + e + this.char + ")");
|
|
481
481
|
}
|
|
482
|
-
return
|
|
483
|
-
type:
|
|
482
|
+
return o = this.code, s.isIdentifierStart(o) ? this.throwError("Variable names cannot start with a number (" + e + this.char + ")") : (o === s.PERIOD_CODE || e.length === 1 && e.charCodeAt(0) === s.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
483
|
+
type: s.LITERAL,
|
|
484
484
|
value: parseFloat(e),
|
|
485
485
|
raw: e
|
|
486
486
|
};
|
|
@@ -492,11 +492,11 @@ class o {
|
|
|
492
492
|
*/
|
|
493
493
|
gobbleStringLiteral() {
|
|
494
494
|
let e = "";
|
|
495
|
-
const t = this.index,
|
|
495
|
+
const t = this.index, o = 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 === o) {
|
|
500
500
|
n = !0;
|
|
501
501
|
break;
|
|
502
502
|
} else if (a === "\\")
|
|
@@ -527,7 +527,7 @@ class o {
|
|
|
527
527
|
e += a;
|
|
528
528
|
}
|
|
529
529
|
return n || this.throwError('Unclosed quote after "' + e + '"'), {
|
|
530
|
-
type:
|
|
530
|
+
type: s.LITERAL,
|
|
531
531
|
value: e,
|
|
532
532
|
raw: this.expr.substring(t, this.index)
|
|
533
533
|
};
|
|
@@ -541,10 +541,10 @@ class o {
|
|
|
541
541
|
*/
|
|
542
542
|
gobbleIdentifier() {
|
|
543
543
|
let e = this.code, t = this.index;
|
|
544
|
-
for (
|
|
544
|
+
for (s.isIdentifierStart(e) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (e = this.code, s.isIdentifierPart(e)); )
|
|
545
545
|
this.index++;
|
|
546
546
|
return {
|
|
547
|
-
type:
|
|
547
|
+
type: s.IDENTIFIER,
|
|
548
548
|
name: this.expr.slice(t, this.index)
|
|
549
549
|
};
|
|
550
550
|
}
|
|
@@ -559,29 +559,29 @@ class o {
|
|
|
559
559
|
*/
|
|
560
560
|
gobbleArguments(e) {
|
|
561
561
|
const t = [];
|
|
562
|
-
let
|
|
562
|
+
let o = !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
|
+
o = !0, this.index++, e === s.CPAREN_CODE && n && n >= t.length && this.throwError("Unexpected token " + String.fromCharCode(e));
|
|
568
568
|
break;
|
|
569
|
-
} else if (a ===
|
|
569
|
+
} else if (a === s.COMMA_CODE) {
|
|
570
570
|
if (this.index++, n++, n !== t.length) {
|
|
571
|
-
if (e ===
|
|
571
|
+
if (e === s.CPAREN_CODE)
|
|
572
572
|
this.throwError("Unexpected token ,");
|
|
573
|
-
else if (e ===
|
|
574
|
-
for (let
|
|
573
|
+
else if (e === s.CBRACK_CODE)
|
|
574
|
+
for (let l = t.length; l < n; l++)
|
|
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 l = this.gobbleExpression();
|
|
581
|
+
(!l || l.type === s.COMPOUND) && this.throwError("Expected comma"), t.push(l);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
return
|
|
584
|
+
return o || 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 o {
|
|
|
594
594
|
*/
|
|
595
595
|
gobbleGroup() {
|
|
596
596
|
this.index++;
|
|
597
|
-
let e = this.gobbleExpressions(
|
|
598
|
-
if (this.code ===
|
|
597
|
+
let e = this.gobbleExpressions(s.CPAREN_CODE);
|
|
598
|
+
if (this.code === s.CPAREN_CODE)
|
|
599
599
|
return this.index++, e.length === 1 ? e[0] : e.length ? {
|
|
600
|
-
type:
|
|
600
|
+
type: s.SEQUENCE_EXP,
|
|
601
601
|
expressions: e
|
|
602
602
|
} : !1;
|
|
603
603
|
this.throwError("Unclosed (");
|
|
@@ -610,15 +610,15 @@ class o {
|
|
|
610
610
|
*/
|
|
611
611
|
gobbleArray() {
|
|
612
612
|
return this.index++, {
|
|
613
|
-
type:
|
|
614
|
-
elements: this.gobbleArguments(
|
|
613
|
+
type: s.ARRAY_EXP,
|
|
614
|
+
elements: this.gobbleArguments(s.CBRACK_CODE)
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
619
|
-
Object.assign(
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
618
|
+
const ke = new _e();
|
|
619
|
+
Object.assign(s, {
|
|
620
|
+
hooks: ke,
|
|
621
|
+
plugins: new xe(s),
|
|
622
622
|
// Node Types
|
|
623
623
|
// ----------
|
|
624
624
|
// This is the full set of types that any JSEP node can be.
|
|
@@ -712,35 +712,35 @@ Object.assign(o, {
|
|
|
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
|
|
715
|
+
s.max_unop_len = s.getMaxKeyLen(s.unary_ops);
|
|
716
|
+
s.max_binop_len = s.getMaxKeyLen(s.binary_ops);
|
|
717
|
+
const M = (r) => new s(r).parse(), Oe = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(s).filter((r) => !Oe.includes(r) && M[r] === void 0).forEach((r) => {
|
|
720
|
+
M[r] = s[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
var
|
|
722
|
+
M.Jsep = s;
|
|
723
|
+
const Ae = "ConditionalExpression";
|
|
724
|
+
var Ce = {
|
|
725
725
|
name: "ternary",
|
|
726
726
|
init(r) {
|
|
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 o = 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
|
-
type:
|
|
736
|
-
test:
|
|
735
|
+
type: Ae,
|
|
736
|
+
test: o,
|
|
737
737
|
consequent: n,
|
|
738
738
|
alternate: a
|
|
739
|
-
},
|
|
740
|
-
let
|
|
741
|
-
for (;
|
|
742
|
-
|
|
743
|
-
t.node.test =
|
|
739
|
+
}, o.operator && r.binary_ops[o.operator] <= 0.9) {
|
|
740
|
+
let l = o;
|
|
741
|
+
for (; l.right.operator && r.binary_ops[l.right.operator] <= 0.9; )
|
|
742
|
+
l = l.right;
|
|
743
|
+
t.node.test = l.right, l.right = t.node, t.node = o;
|
|
744
744
|
}
|
|
745
745
|
} else
|
|
746
746
|
this.throwError("Expected :");
|
|
@@ -748,66 +748,66 @@ var Ne = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
const
|
|
753
|
-
var
|
|
751
|
+
M.plugins.register(Ce);
|
|
752
|
+
const ue = 47, we = 92;
|
|
753
|
+
var Se = {
|
|
754
754
|
name: "regex",
|
|
755
755
|
init(r) {
|
|
756
756
|
r.hooks.add("gobble-token", function(t) {
|
|
757
|
-
if (this.code ===
|
|
758
|
-
const
|
|
757
|
+
if (this.code === ue) {
|
|
758
|
+
const o = ++this.index;
|
|
759
759
|
let n = !1;
|
|
760
760
|
for (; this.index < this.expr.length; ) {
|
|
761
|
-
if (this.code ===
|
|
762
|
-
const a = this.expr.slice(
|
|
763
|
-
let
|
|
761
|
+
if (this.code === ue && !n) {
|
|
762
|
+
const a = this.expr.slice(o, this.index);
|
|
763
|
+
let l = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
|
|
765
|
+
const d = this.code;
|
|
766
|
+
if (d >= 97 && d <= 122 || d >= 65 && d <= 90 || d >= 48 && d <= 57)
|
|
767
|
+
l += this.char;
|
|
768
768
|
else
|
|
769
769
|
break;
|
|
770
770
|
}
|
|
771
771
|
let f;
|
|
772
772
|
try {
|
|
773
|
-
f = new RegExp(a,
|
|
774
|
-
} catch (
|
|
775
|
-
this.throwError(
|
|
773
|
+
f = new RegExp(a, l);
|
|
774
|
+
} catch (d) {
|
|
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(o - 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 === we ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const ie = 43, Pe = 45, q = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [ie, Pe],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
797
|
+
q.assignmentOperators.forEach((o) => r.addBinaryOp(o, q.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
798
|
const a = this.code;
|
|
799
|
-
|
|
799
|
+
q.updateOperators.some((l) => l === a && l === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, n.node = {
|
|
800
800
|
type: "UpdateExpression",
|
|
801
|
-
operator: a ===
|
|
801
|
+
operator: a === ie ? "++" : "--",
|
|
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
|
+
q.updateOperators.some((l) => l === a && l === 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 === ie ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -815,18 +815,18 @@ const ue = 43, De = 45, z = {
|
|
|
815
815
|
}), r.hooks.add("after-expression", function(n) {
|
|
816
816
|
n.node && t(n.node);
|
|
817
817
|
});
|
|
818
|
-
function t(
|
|
819
|
-
|
|
818
|
+
function t(o) {
|
|
819
|
+
q.assignmentOperators.has(o.operator) ? (o.type = "AssignmentExpression", t(o.left), t(o.right)) : o.operator || Object.values(o).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
|
+
M.plugins.register(Se, q);
|
|
826
|
+
M.addUnaryOp("typeof");
|
|
827
|
+
M.addLiteral("null", null);
|
|
828
|
+
M.addLiteral("undefined", void 0);
|
|
829
|
+
const Te = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), O = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -860,36 +860,36 @@ const Ie = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
860
860
|
},
|
|
861
861
|
evalBinaryExpression(r, e) {
|
|
862
862
|
return {
|
|
863
|
-
"||": (
|
|
864
|
-
"&&": (
|
|
865
|
-
"|": (
|
|
866
|
-
"^": (
|
|
867
|
-
"&": (
|
|
863
|
+
"||": (o, n) => o || n(),
|
|
864
|
+
"&&": (o, n) => o && n(),
|
|
865
|
+
"|": (o, n) => o | n(),
|
|
866
|
+
"^": (o, n) => o ^ n(),
|
|
867
|
+
"&": (o, n) => o & n(),
|
|
868
868
|
// eslint-disable-next-line eqeqeq -- API
|
|
869
|
-
"==": (
|
|
869
|
+
"==": (o, n) => o == 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
|
+
"!=": (o, n) => o != n(),
|
|
872
|
+
"===": (o, n) => o === n(),
|
|
873
|
+
"!==": (o, n) => o !== n(),
|
|
874
|
+
"<": (o, n) => o < n(),
|
|
875
|
+
">": (o, n) => o > n(),
|
|
876
|
+
"<=": (o, n) => o <= n(),
|
|
877
|
+
">=": (o, n) => o >= n(),
|
|
878
|
+
"<<": (o, n) => o << n(),
|
|
879
|
+
">>": (o, n) => o >> n(),
|
|
880
|
+
">>>": (o, n) => o >>> n(),
|
|
881
|
+
"+": (o, n) => o + n(),
|
|
882
|
+
"-": (o, n) => o - n(),
|
|
883
|
+
"*": (o, n) => o * n(),
|
|
884
|
+
"/": (o, n) => o / n(),
|
|
885
|
+
"%": (o, n) => o % 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 o = 0; o < r.body.length; o++) {
|
|
891
|
+
r.body[o].type === "Identifier" && ["var", "let", "const"].includes(r.body[o].name) && r.body[o + 1] && r.body[o + 1].type === "AssignmentExpression" && (o += 1);
|
|
892
|
+
const n = r.body[o];
|
|
893
893
|
t = O.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
@@ -912,22 +912,22 @@ const Ie = /* @__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
|
+
), o = O.evalAst(r.object, e);
|
|
916
|
+
if (o == null)
|
|
917
|
+
throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);
|
|
918
|
+
if (!Object.hasOwn(o, t) && Te.has(t))
|
|
919
|
+
throw TypeError(`Cannot read properties of ${o} (reading '${t}')`);
|
|
920
|
+
const n = o[t];
|
|
921
|
+
return typeof n == "function" ? n.bind(o) : n;
|
|
922
922
|
},
|
|
923
923
|
evalUnaryExpression(r, e) {
|
|
924
924
|
return {
|
|
925
|
-
"-": (
|
|
926
|
-
"!": (
|
|
927
|
-
"~": (
|
|
925
|
+
"-": (o) => -O.evalAst(o, e),
|
|
926
|
+
"!": (o) => !O.evalAst(o, e),
|
|
927
|
+
"~": (o) => ~O.evalAst(o, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (
|
|
930
|
-
typeof: (
|
|
929
|
+
"+": (o) => +O.evalAst(o, e),
|
|
930
|
+
typeof: (o) => typeof O.evalAst(o, e)
|
|
931
931
|
}[r.operator](r.argument);
|
|
932
932
|
},
|
|
933
933
|
evalArrayExpression(r, e) {
|
|
@@ -940,16 +940,16 @@ const Ie = /* @__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, o = O.evalAst(r.right, e);
|
|
944
|
+
return e[t] = o, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class Ne {
|
|
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 = M(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -961,13 +961,13 @@ class je {
|
|
|
961
961
|
return O.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function V(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function ae(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class je extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -975,304 +975,304 @@ class $e extends Error {
|
|
|
975
975
|
super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'), this.avoidNew = !0, this.value = e, this.name = "NewError";
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
|
-
function
|
|
979
|
-
if (!(this instanceof
|
|
978
|
+
function x(r, e, t, o, n) {
|
|
979
|
+
if (!(this instanceof x))
|
|
980
980
|
try {
|
|
981
|
-
return new
|
|
982
|
-
} catch (
|
|
983
|
-
if (!
|
|
984
|
-
throw
|
|
985
|
-
return
|
|
981
|
+
return new x(r, e, t, o, n);
|
|
982
|
+
} catch (l) {
|
|
983
|
+
if (!l.avoidNew)
|
|
984
|
+
throw l;
|
|
985
|
+
return l.value;
|
|
986
986
|
}
|
|
987
|
-
typeof r == "string" && (n =
|
|
987
|
+
typeof r == "string" && (n = o, o = 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 || o || 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 l = {
|
|
993
993
|
path: a ? r.path : e
|
|
994
994
|
};
|
|
995
|
-
a ? "json" in r && (
|
|
996
|
-
const f = this.evaluate(
|
|
995
|
+
a ? "json" in r && (l.json = r.json) : l.json = t;
|
|
996
|
+
const f = this.evaluate(l);
|
|
997
997
|
if (!f || typeof f != "object")
|
|
998
|
-
throw new
|
|
998
|
+
throw new je(f);
|
|
999
999
|
return f;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
x.prototype.evaluate = function(r, e, t, o) {
|
|
1003
1003
|
let n = this.parent, a = this.parentProperty, {
|
|
1004
|
-
flatten:
|
|
1004
|
+
flatten: l,
|
|
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 = o || 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), l = Object.hasOwn(r, "flatten") ? r.flatten : l, 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 = x.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1018
|
+
const d = x.toPathArray(r);
|
|
1019
|
+
d[0] === "$" && d.length > 1 && d.shift(), this._hasParentSelector = null;
|
|
1020
|
+
const h = this._trace(d, e, ["$"], n, a, t).filter(function(m) {
|
|
1021
|
+
return m && !m.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
|
-
return
|
|
1024
|
-
const
|
|
1025
|
-
return
|
|
1023
|
+
return h.length ? !f && h.length === 1 && !h[0].hasArrExpr ? this._getPreferredOutput(h[0]) : h.reduce((m, g) => {
|
|
1024
|
+
const _ = this._getPreferredOutput(g);
|
|
1025
|
+
return l && Array.isArray(_) ? m = m.concat(_) : m.push(_), m;
|
|
1026
1026
|
}, []) : f ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
|
-
|
|
1028
|
+
x.prototype._getPreferredOutput = function(r) {
|
|
1029
1029
|
const e = this.currResultType;
|
|
1030
1030
|
switch (e) {
|
|
1031
1031
|
case "all": {
|
|
1032
|
-
const t = Array.isArray(r.path) ? r.path :
|
|
1033
|
-
return r.pointer =
|
|
1032
|
+
const t = Array.isArray(r.path) ? r.path : x.toPathArray(r.path);
|
|
1033
|
+
return r.pointer = x.toPointer(t), r.path = typeof r.path == "string" ? r.path : x.toPathString(r.path), r;
|
|
1034
1034
|
}
|
|
1035
1035
|
case "value":
|
|
1036
1036
|
case "parent":
|
|
1037
1037
|
case "parentProperty":
|
|
1038
1038
|
return r[e];
|
|
1039
1039
|
case "path":
|
|
1040
|
-
return
|
|
1040
|
+
return x.toPathString(r[e]);
|
|
1041
1041
|
case "pointer":
|
|
1042
|
-
return
|
|
1042
|
+
return x.toPointer(r.path);
|
|
1043
1043
|
default:
|
|
1044
1044
|
throw new TypeError("Unknown result type");
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
|
-
|
|
1047
|
+
x.prototype._handleCallback = function(r, e, t) {
|
|
1048
1048
|
if (e) {
|
|
1049
|
-
const
|
|
1050
|
-
r.path = typeof r.path == "string" ? r.path :
|
|
1049
|
+
const o = this._getPreferredOutput(r);
|
|
1050
|
+
r.path = typeof r.path == "string" ? r.path : x.toPathString(r.path), e(o, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1054
|
-
let
|
|
1053
|
+
x.prototype._trace = function(r, e, t, o, n, a, l, f) {
|
|
1054
|
+
let d;
|
|
1055
1055
|
if (!r.length)
|
|
1056
|
-
return
|
|
1056
|
+
return d = {
|
|
1057
1057
|
path: t,
|
|
1058
1058
|
value: e,
|
|
1059
|
-
parent:
|
|
1059
|
+
parent: o,
|
|
1060
1060
|
parentProperty: n,
|
|
1061
|
-
hasArrExpr:
|
|
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
|
-
|
|
1061
|
+
hasArrExpr: l
|
|
1062
|
+
}, this._handleCallback(d, a, "value"), d;
|
|
1063
|
+
const h = r[0], m = r.slice(1), g = [];
|
|
1064
|
+
function _(b) {
|
|
1065
|
+
Array.isArray(b) ? b.forEach((w) => {
|
|
1066
|
+
g.push(w);
|
|
1067
|
+
}) : g.push(b);
|
|
1068
|
+
}
|
|
1069
|
+
if ((typeof h != "string" || f) && e && Object.hasOwn(e, h))
|
|
1070
|
+
_(this._trace(m, e[h], V(t, h), e, h, a, l));
|
|
1071
|
+
else if (h === "*")
|
|
1072
|
+
this._walk(e, (b) => {
|
|
1073
|
+
_(this._trace(m, e[b], V(t, b), e, b, a, !0, !0));
|
|
1074
1074
|
});
|
|
1075
|
-
else if (
|
|
1076
|
-
|
|
1077
|
-
typeof e[
|
|
1075
|
+
else if (h === "..")
|
|
1076
|
+
_(this._trace(m, e, t, o, n, a, l)), this._walk(e, (b) => {
|
|
1077
|
+
typeof e[b] == "object" && _(this._trace(r.slice(), e[b], V(t, b), e, b, a, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
|
-
if (
|
|
1080
|
+
if (h === "^")
|
|
1081
1081
|
return this._hasParentSelector = !0, {
|
|
1082
1082
|
path: t.slice(0, -1),
|
|
1083
|
-
expr:
|
|
1083
|
+
expr: m,
|
|
1084
1084
|
isParentSelector: !0
|
|
1085
1085
|
};
|
|
1086
|
-
if (
|
|
1087
|
-
return
|
|
1088
|
-
path:
|
|
1086
|
+
if (h === "~")
|
|
1087
|
+
return d = {
|
|
1088
|
+
path: V(t, h),
|
|
1089
1089
|
value: n,
|
|
1090
|
-
parent:
|
|
1090
|
+
parent: o,
|
|
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(d, a, "property"), d;
|
|
1093
|
+
if (h === "$")
|
|
1094
|
+
_(this._trace(m, e, t, null, null, a, l));
|
|
1095
|
+
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(h))
|
|
1096
|
+
_(this._slice(h, m, e, t, o, n, a));
|
|
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 b = h.replace(/^\?\((.*?)\)$/u, "$1"), w = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(b);
|
|
1101
1101
|
w ? this._walk(e, (S) => {
|
|
1102
|
-
const
|
|
1103
|
-
this._trace(
|
|
1102
|
+
const B = [w[2]], I = w[1] ? e[S][w[1]] : e[S];
|
|
1103
|
+
this._trace(B, I, t, o, n, a, !0).length > 0 && _(this._trace(m, e[S], V(t, S), e, S, a, !0));
|
|
1104
1104
|
}) : this._walk(e, (S) => {
|
|
1105
|
-
this._eval(
|
|
1105
|
+
this._eval(b, e[S], S, t, o, n) && _(this._trace(m, e[S], V(t, S), e, S, a, !0));
|
|
1106
1106
|
});
|
|
1107
|
-
} else if (
|
|
1107
|
+
} else if (h[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 w =
|
|
1110
|
+
_(this._trace(ae(this._eval(h, e, t.at(-1), t.slice(0, -1), o, n), m), e, t, o, n, a, l));
|
|
1111
|
+
} else if (h[0] === "@") {
|
|
1112
|
+
let b = !1;
|
|
1113
|
+
const w = h.slice(1, -2);
|
|
1114
1114
|
switch (w) {
|
|
1115
1115
|
case "scalar":
|
|
1116
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
1116
|
+
(!e || !["object", "function"].includes(typeof e)) && (b = !0);
|
|
1117
1117
|
break;
|
|
1118
1118
|
case "boolean":
|
|
1119
1119
|
case "string":
|
|
1120
1120
|
case "undefined":
|
|
1121
1121
|
case "function":
|
|
1122
|
-
typeof e === w && (
|
|
1122
|
+
typeof e === w && (b = !0);
|
|
1123
1123
|
break;
|
|
1124
1124
|
case "integer":
|
|
1125
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
1125
|
+
Number.isFinite(e) && !(e % 1) && (b = !0);
|
|
1126
1126
|
break;
|
|
1127
1127
|
case "number":
|
|
1128
|
-
Number.isFinite(e) && (
|
|
1128
|
+
Number.isFinite(e) && (b = !0);
|
|
1129
1129
|
break;
|
|
1130
1130
|
case "nonFinite":
|
|
1131
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
1131
|
+
typeof e == "number" && !Number.isFinite(e) && (b = !0);
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "object":
|
|
1134
|
-
e && typeof e === w && (
|
|
1134
|
+
e && typeof e === w && (b = !0);
|
|
1135
1135
|
break;
|
|
1136
1136
|
case "array":
|
|
1137
|
-
Array.isArray(e) && (
|
|
1137
|
+
Array.isArray(e) && (b = !0);
|
|
1138
1138
|
break;
|
|
1139
1139
|
case "other":
|
|
1140
|
-
|
|
1140
|
+
b = this.currOtherTypeCallback(e, t, o, n);
|
|
1141
1141
|
break;
|
|
1142
1142
|
case "null":
|
|
1143
|
-
e === null && (
|
|
1143
|
+
e === null && (b = !0);
|
|
1144
1144
|
break;
|
|
1145
1145
|
/* c8 ignore next 2 */
|
|
1146
1146
|
default:
|
|
1147
1147
|
throw new TypeError("Unknown value type " + w);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1150
|
-
return
|
|
1149
|
+
if (b)
|
|
1150
|
+
return d = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
1153
|
-
parent:
|
|
1153
|
+
parent: o,
|
|
1154
1154
|
parentProperty: n
|
|
1155
|
-
}, this._handleCallback(
|
|
1156
|
-
} else if (
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
} else if (
|
|
1160
|
-
const
|
|
1161
|
-
for (const w of
|
|
1162
|
-
|
|
1163
|
-
} else !f && e && Object.hasOwn(e,
|
|
1155
|
+
}, this._handleCallback(d, a, "value"), d;
|
|
1156
|
+
} else if (h[0] === "`" && e && Object.hasOwn(e, h.slice(1))) {
|
|
1157
|
+
const b = h.slice(1);
|
|
1158
|
+
_(this._trace(m, e[b], V(t, b), e, b, a, l, !0));
|
|
1159
|
+
} else if (h.includes(",")) {
|
|
1160
|
+
const b = h.split(",");
|
|
1161
|
+
for (const w of b)
|
|
1162
|
+
_(this._trace(ae(w, m), e, t, o, n, a, !0));
|
|
1163
|
+
} else !f && e && Object.hasOwn(e, h) && _(this._trace(m, e[h], V(t, h), e, h, a, l, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const w = b
|
|
1166
|
+
for (let b = 0; b < g.length; b++) {
|
|
1167
|
+
const w = g[b];
|
|
1168
1168
|
if (w && w.isParentSelector) {
|
|
1169
|
-
const S = this._trace(w.expr, e, w.path,
|
|
1169
|
+
const S = this._trace(w.expr, e, w.path, o, n, a, l);
|
|
1170
1170
|
if (Array.isArray(S)) {
|
|
1171
|
-
b
|
|
1172
|
-
const
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1171
|
+
g[b] = S[0];
|
|
1172
|
+
const B = S.length;
|
|
1173
|
+
for (let I = 1; I < B; I++)
|
|
1174
|
+
b++, g.splice(b, 0, S[I]);
|
|
1175
1175
|
} else
|
|
1176
|
-
b
|
|
1176
|
+
g[b] = S;
|
|
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 o = 0; o < t; o++)
|
|
1185
|
+
e(o);
|
|
1186
1186
|
} else r && typeof r == "object" && Object.keys(r).forEach((t) => {
|
|
1187
1187
|
e(t);
|
|
1188
1188
|
});
|
|
1189
1189
|
};
|
|
1190
|
-
|
|
1190
|
+
x.prototype._slice = function(r, e, t, o, n, a, l) {
|
|
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, d = r.split(":"), h = d[2] && Number.parseInt(d[2]) || 1;
|
|
1194
|
+
let m = d[0] && Number.parseInt(d[0]) || 0, g = d[1] && Number.parseInt(d[1]) || f;
|
|
1195
|
+
m = m < 0 ? Math.max(0, m + f) : Math.min(f, m), g = g < 0 ? Math.max(0, g + f) : Math.min(f, g);
|
|
1196
|
+
const _ = [];
|
|
1197
|
+
for (let b = m; b < g; b += h)
|
|
1198
|
+
this._trace(ae(b, e), t, o, n, a, l, !0).forEach((S) => {
|
|
1199
|
+
_.push(S);
|
|
1200
1200
|
});
|
|
1201
|
-
return
|
|
1201
|
+
return _;
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1203
|
+
x.prototype._eval = function(r, e, t, o, 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 l = r.includes("@path");
|
|
1206
|
+
l && (this.currSandbox._$_path = x.toPathString(o.concat([t])));
|
|
1207
1207
|
const f = this.currEval + "Script:" + r;
|
|
1208
|
-
if (!
|
|
1209
|
-
let
|
|
1210
|
-
if (
|
|
1211
|
-
|
|
1208
|
+
if (!x.cache[f]) {
|
|
1209
|
+
let d = r.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
1210
|
+
if (l && (d = d.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
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);
|
|
1214
1214
|
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1215
|
+
const h = this.currEval;
|
|
1216
|
+
x.cache[f] = new h(d);
|
|
1217
1217
|
} else if (typeof this.currEval == "function")
|
|
1218
|
-
|
|
1219
|
-
runInNewContext: (
|
|
1218
|
+
x.cache[f] = {
|
|
1219
|
+
runInNewContext: (h) => this.currEval(d, h)
|
|
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 x.cache[f].runInNewContext(this.currSandbox);
|
|
1226
|
+
} catch (d) {
|
|
1227
1227
|
if (this.ignoreEvalErrors)
|
|
1228
1228
|
return !1;
|
|
1229
|
-
throw new Error("jsonPath: " +
|
|
1229
|
+
throw new Error("jsonPath: " + d.message + ": " + r);
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1232
|
+
x.cache = {};
|
|
1233
|
+
x.toPathString = function(r) {
|
|
1234
1234
|
const e = r, t = e.length;
|
|
1235
|
-
let
|
|
1235
|
+
let o = "$";
|
|
1236
1236
|
for (let n = 1; n < t; n++)
|
|
1237
|
-
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (
|
|
1238
|
-
return
|
|
1237
|
+
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (o += /^[0-9*]+$/u.test(e[n]) ? "[" + e[n] + "]" : "['" + e[n] + "']");
|
|
1238
|
+
return o;
|
|
1239
1239
|
};
|
|
1240
|
-
|
|
1240
|
+
x.toPointer = function(r) {
|
|
1241
1241
|
const e = r, t = e.length;
|
|
1242
|
-
let
|
|
1242
|
+
let o = "";
|
|
1243
1243
|
for (let n = 1; n < t; n++)
|
|
1244
|
-
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (
|
|
1245
|
-
return
|
|
1244
|
+
/^(~|\^|@.*?\(\))$/u.test(e[n]) || (o += "/" + e[n].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
|
|
1245
|
+
return o;
|
|
1246
1246
|
};
|
|
1247
|
-
|
|
1247
|
+
x.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
1249
1249
|
cache: e
|
|
1250
|
-
} =
|
|
1250
|
+
} = x;
|
|
1251
1251
|
if (e[r])
|
|
1252
1252
|
return e[r].concat();
|
|
1253
|
-
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, l) {
|
|
1254
|
+
return "[#" + (t.push(l) - 1) + "]";
|
|
1255
|
+
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(a, l) {
|
|
1256
|
+
return "['" + l.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
1257
|
+
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(a, l) {
|
|
1258
|
+
return ";" + l.split("").join(";") + ";";
|
|
1259
1259
|
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(a) {
|
|
1260
|
-
const
|
|
1261
|
-
return !
|
|
1260
|
+
const l = a.match(/#(\d+)/u);
|
|
1261
|
+
return !l || !l[1] ? a : t[l[1]];
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
|
-
|
|
1266
|
-
Script:
|
|
1265
|
+
x.prototype.safeVm = {
|
|
1266
|
+
Script: Ne
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1269
|
-
const
|
|
1270
|
-
for (let n = 0; n <
|
|
1268
|
+
const De = function(r, e, t) {
|
|
1269
|
+
const o = r.length;
|
|
1270
|
+
for (let n = 0; n < o; 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 Be {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1286,48 +1286,48 @@ class Le {
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
const a =
|
|
1292
|
-
t = n.reduce((
|
|
1293
|
-
let
|
|
1294
|
-
return /function/u.test(
|
|
1295
|
-
}, "") + t, !/(['"])use strict\1/u.test(t) && !
|
|
1296
|
-
const f = t.lastIndexOf(";"),
|
|
1297
|
-
return new Function(...
|
|
1289
|
+
const o = Object.keys(e), n = [];
|
|
1290
|
+
De(o, n, (h) => typeof e[h] == "function");
|
|
1291
|
+
const a = o.map((h) => e[h]);
|
|
1292
|
+
t = n.reduce((h, m) => {
|
|
1293
|
+
let g = e[m].toString();
|
|
1294
|
+
return /function/u.test(g) || (g = "function " + g), "var " + m + "=" + g + ";" + h;
|
|
1295
|
+
}, "") + t, !/(['"])use strict\1/u.test(t) && !o.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;\s*$/u, "");
|
|
1296
|
+
const f = t.lastIndexOf(";"), d = f !== -1 ? t.slice(0, f + 1) + " return " + t.slice(f + 1) : " return " + t;
|
|
1297
|
+
return new Function(...o, d)(...a);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
|
|
1301
|
-
Script:
|
|
1300
|
+
x.prototype.vm = {
|
|
1301
|
+
Script: Be
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const $e = { class: "json-node" }, Ie = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1306
|
+
}, Re = { class: "json-node__line" }, Le = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, Ue = ["title"], Me = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
|
-
},
|
|
1312
|
+
}, Ve = {
|
|
1313
1313
|
key: 4,
|
|
1314
1314
|
class: "json-node__comma"
|
|
1315
|
-
},
|
|
1315
|
+
}, He = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__children"
|
|
1318
|
-
},
|
|
1318
|
+
}, Fe = { class: "json-node__children-content" }, Ke = { class: "json-node__line json-node__closing-bracket" }, Xe = { class: "json-node__bracket" }, Qe = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
|
-
},
|
|
1321
|
+
}, Ye = {
|
|
1322
1322
|
key: 1,
|
|
1323
1323
|
class: "json-node__primitive"
|
|
1324
|
-
},
|
|
1324
|
+
}, qe = {
|
|
1325
1325
|
key: 2,
|
|
1326
1326
|
class: "json-node__colon"
|
|
1327
|
-
},
|
|
1327
|
+
}, ze = ["title"], Ge = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
},
|
|
1330
|
+
}, We = /* @__PURE__ */ de({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1341,54 +1341,44 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
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
|
+
he((u) => ({
|
|
1345
|
+
"7b112182": u.level,
|
|
1346
|
+
"1501a3a8": u.theme.colors.syntaxKey,
|
|
1347
|
+
"4c2226b6": u.theme.colors.hoverBackground,
|
|
1348
|
+
"30aa351e": u.theme.colors.syntaxBracket,
|
|
1349
|
+
"090e30f3": u.theme.colors.textSecondary,
|
|
1350
|
+
cf872bb0: u.theme.colors.syntaxString,
|
|
1351
|
+
e0803540: u.theme.colors.syntaxNumber,
|
|
1352
|
+
"3954b61e": u.theme.colors.syntaxBoolean,
|
|
1353
|
+
e9972d44: u.theme.colors.syntaxNull,
|
|
1354
|
+
"231c0282": u.theme.colors.background,
|
|
1355
|
+
e1dce7d8: u.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r,
|
|
1358
|
-
if (!/^-?\d+(\.\d+)?$/.test(u)) return !1;
|
|
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(() => {
|
|
1357
|
+
const t = r, o = e, n = U(!1), a = U(!1), l = U(""), f = U(""), d = (u) => u !== null && typeof u == "object" && !Array.isArray(u) && "__protected_number__" in u && Object.keys(u).length === 1, h = (u) => d(u) ? u.__protected_number__ : "", m = D(() => d(t.value) ? !1 : t.value !== null && typeof t.value == "object"), g = D(() => Array.isArray(t.value)), _ = D(() => t.path ? t.path : t.keyName ? t.keyName : "root"), b = D(() => t.expanded.has(_.value)), w = D(() => t.keyName), S = D(() => g.value ? "[" : "{"), B = D(() => g.value ? "]" : "}"), I = D(() => {
|
|
1368
1358
|
if (!t.value) return "";
|
|
1369
|
-
const
|
|
1370
|
-
return
|
|
1371
|
-
}),
|
|
1359
|
+
const i = Object.keys(t.value).length;
|
|
1360
|
+
return g.value ? i > 0 ? ` ${i} items ` : " " : i > 0 ? ` ${i} keys ` : " ";
|
|
1361
|
+
}), Z = D(() => {
|
|
1372
1362
|
const u = typeof t.value;
|
|
1373
|
-
return t.value === null ? "json-node__value--null" : u === "boolean" ? "json-node__value--boolean" : u === "number" ? "json-node__value--number" : u === "string" ?
|
|
1374
|
-
}),
|
|
1375
|
-
const
|
|
1376
|
-
return
|
|
1377
|
-
},
|
|
1378
|
-
|
|
1379
|
-
},
|
|
1380
|
-
t.level !== 0 && (n.value = !0,
|
|
1381
|
-
const u = document.querySelectorAll(".json-node__key-input"),
|
|
1382
|
-
|
|
1363
|
+
return t.value === null ? "json-node__value--null" : u === "boolean" ? "json-node__value--boolean" : u === "number" || d(t.value) ? "json-node__value--number" : u === "string" ? "json-node__value--string" : "";
|
|
1364
|
+
}), J = D(() => a.value ? f.value : t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : d(t.value) ? h(t.value) : typeof t.value == "string" ? `"${t.value}"` : String(t.value)), H = D(() => "Click to edit, double-click to copy"), ee = (u) => t.level === 0 ? u : _.value ? `${_.value}.${u}` : u, te = (u) => {
|
|
1365
|
+
const i = Object.keys(t.value);
|
|
1366
|
+
return i.indexOf(u) === i.length - 1;
|
|
1367
|
+
}, z = () => {
|
|
1368
|
+
o("toggle-expand", _.value);
|
|
1369
|
+
}, G = () => {
|
|
1370
|
+
t.level !== 0 && (n.value = !0, l.value = t.keyName, W(() => {
|
|
1371
|
+
const u = document.querySelectorAll(".json-node__key-input"), i = u[u.length - 1];
|
|
1372
|
+
i && (i.focus(), i.select());
|
|
1383
1373
|
}));
|
|
1384
|
-
},
|
|
1385
|
-
|
|
1386
|
-
const u = document.querySelectorAll(".json-node__value-input"),
|
|
1387
|
-
|
|
1374
|
+
}, re = () => {
|
|
1375
|
+
m.value || (a.value = !0, d(t.value) ? f.value = h(t.value) : typeof t.value == "string" ? f.value = t.value : f.value = String(t.value), W(() => {
|
|
1376
|
+
const u = document.querySelectorAll(".json-node__value-input"), i = u[u.length - 1];
|
|
1377
|
+
i && (i.focus(), i.select());
|
|
1388
1378
|
}));
|
|
1389
|
-
},
|
|
1379
|
+
}, K = () => {
|
|
1390
1380
|
if (t.level === 0 || !n.value) return;
|
|
1391
|
-
const u =
|
|
1381
|
+
const u = l.value.trim();
|
|
1392
1382
|
if (!u) {
|
|
1393
1383
|
X();
|
|
1394
1384
|
return;
|
|
@@ -1397,145 +1387,145 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
1397
1387
|
n.value = !1;
|
|
1398
1388
|
return;
|
|
1399
1389
|
}
|
|
1400
|
-
n.value = !1,
|
|
1401
|
-
},
|
|
1390
|
+
n.value = !1, o("update:key", _.value, u);
|
|
1391
|
+
}, F = () => {
|
|
1402
1392
|
try {
|
|
1403
1393
|
let u;
|
|
1404
|
-
const
|
|
1405
|
-
if (
|
|
1394
|
+
const i = f.value.trim();
|
|
1395
|
+
if (i === "null")
|
|
1406
1396
|
u = null;
|
|
1407
|
-
else if (
|
|
1408
|
-
u =
|
|
1409
|
-
else if (!isNaN(Number(
|
|
1410
|
-
const
|
|
1411
|
-
!Number.isSafeInteger(
|
|
1397
|
+
else if (i === "true" || i === "false")
|
|
1398
|
+
u = i === "true";
|
|
1399
|
+
else if (!isNaN(Number(i)) && i !== "") {
|
|
1400
|
+
const c = Number(i);
|
|
1401
|
+
!Number.isSafeInteger(c) || i.length > 15 ? u = { __protected_number__: i } : u = c;
|
|
1412
1402
|
} else
|
|
1413
1403
|
u = f.value;
|
|
1414
|
-
|
|
1404
|
+
o("update:value", _.value, u), a.value = !1;
|
|
1415
1405
|
} catch (u) {
|
|
1416
1406
|
console.error("Failed to parse value:", u), a.value = !1;
|
|
1417
1407
|
}
|
|
1418
1408
|
}, X = () => {
|
|
1419
|
-
n.value = !1,
|
|
1420
|
-
},
|
|
1421
|
-
a.value = !1,
|
|
1409
|
+
n.value = !1, l.value = t.keyName;
|
|
1410
|
+
}, ne = () => {
|
|
1411
|
+
a.value = !1, d(t.value) ? f.value = h(t.value) : typeof t.value == "string" ? f.value = t.value : f.value = String(t.value);
|
|
1422
1412
|
};
|
|
1423
|
-
return (u,
|
|
1424
|
-
const
|
|
1425
|
-
return
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
u.keyName && !n.value ? (
|
|
1413
|
+
return (u, i) => {
|
|
1414
|
+
const c = ge("JsonNode", !0);
|
|
1415
|
+
return C(), A("div", $e, [
|
|
1416
|
+
m.value ? (C(), A("div", Ie, [
|
|
1417
|
+
N("div", Re, [
|
|
1418
|
+
u.keyName && !n.value ? (C(), A("span", {
|
|
1429
1419
|
key: 0,
|
|
1430
1420
|
class: "json-node__key",
|
|
1431
|
-
onClick:
|
|
1421
|
+
onClick: G,
|
|
1432
1422
|
title: "Click to edit key"
|
|
1433
|
-
}, ' "' +
|
|
1434
|
-
u.keyName && n.value ?
|
|
1423
|
+
}, ' "' + L(w.value) + '" ', 1)) : j("", !0),
|
|
1424
|
+
u.keyName && n.value ? oe((C(), A("input", {
|
|
1435
1425
|
key: 1,
|
|
1436
|
-
"onUpdate:modelValue":
|
|
1426
|
+
"onUpdate:modelValue": i[0] || (i[0] = (y) => l.value = y),
|
|
1437
1427
|
onKeyup: [
|
|
1438
|
-
|
|
1439
|
-
|
|
1428
|
+
Y(K, ["enter"]),
|
|
1429
|
+
Y(X, ["escape"])
|
|
1440
1430
|
],
|
|
1441
|
-
onBlur:
|
|
1431
|
+
onBlur: K,
|
|
1442
1432
|
class: "json-node__key-input"
|
|
1443
1433
|
}, null, 544)), [
|
|
1444
|
-
[
|
|
1445
|
-
]) :
|
|
1446
|
-
u.keyName ? (
|
|
1447
|
-
|
|
1434
|
+
[se, l.value]
|
|
1435
|
+
]) : j("", !0),
|
|
1436
|
+
u.keyName ? (C(), A("span", Le, ": ")) : j("", !0),
|
|
1437
|
+
N("span", {
|
|
1448
1438
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1449
|
-
onClick:
|
|
1450
|
-
title:
|
|
1451
|
-
},
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1439
|
+
onClick: z,
|
|
1440
|
+
title: b.value ? "Click to collapse" : "Click to expand"
|
|
1441
|
+
}, L(S.value), 9, Ue),
|
|
1442
|
+
b.value ? j("", !0) : (C(), A("span", Me, [
|
|
1443
|
+
ce(L(I.value) + " ", 1),
|
|
1444
|
+
N("span", {
|
|
1455
1445
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1456
|
-
onClick:
|
|
1457
|
-
},
|
|
1446
|
+
onClick: z
|
|
1447
|
+
}, L(B.value), 1)
|
|
1458
1448
|
])),
|
|
1459
|
-
!
|
|
1449
|
+
!b.value && !u.isLast ? (C(), A("span", Ve, ",")) : j("", !0)
|
|
1460
1450
|
]),
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
(
|
|
1464
|
-
key:
|
|
1451
|
+
b.value ? (C(), A("div", He, [
|
|
1452
|
+
N("div", Fe, [
|
|
1453
|
+
(C(!0), A(ve, null, me(u.value, (y, p) => (C(), A("div", {
|
|
1454
|
+
key: p,
|
|
1465
1455
|
class: "json-node__child"
|
|
1466
1456
|
}, [
|
|
1467
|
-
|
|
1468
|
-
value:
|
|
1469
|
-
"key-name":
|
|
1457
|
+
fe(c, {
|
|
1458
|
+
value: y,
|
|
1459
|
+
"key-name": g.value ? "" : String(p),
|
|
1470
1460
|
level: u.level + 1,
|
|
1471
|
-
path:
|
|
1461
|
+
path: ee(String(p)),
|
|
1472
1462
|
expanded: u.expanded,
|
|
1473
1463
|
theme: u.theme,
|
|
1474
|
-
"onUpdate:value":
|
|
1475
|
-
onToggleExpand:
|
|
1476
|
-
onCopy:
|
|
1477
|
-
"onUpdate:key":
|
|
1478
|
-
"is-last":
|
|
1464
|
+
"onUpdate:value": i[1] || (i[1] = (v, E) => u.$emit("update:value", v, E)),
|
|
1465
|
+
onToggleExpand: i[2] || (i[2] = (v) => u.$emit("toggle-expand", v)),
|
|
1466
|
+
onCopy: i[3] || (i[3] = (v) => u.$emit("copy", v)),
|
|
1467
|
+
"onUpdate:key": i[4] || (i[4] = (v, E) => u.$emit("update:key", v, E)),
|
|
1468
|
+
"is-last": te(String(p))
|
|
1479
1469
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1480
1470
|
]))), 128))
|
|
1481
1471
|
]),
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
u.isLast ?
|
|
1472
|
+
N("div", Ke, [
|
|
1473
|
+
N("span", Xe, L(B.value), 1),
|
|
1474
|
+
u.isLast ? j("", !0) : (C(), A("span", Qe, ","))
|
|
1485
1475
|
])
|
|
1486
|
-
])) :
|
|
1487
|
-
])) : (
|
|
1488
|
-
u.keyName && !n.value ? (
|
|
1476
|
+
])) : j("", !0)
|
|
1477
|
+
])) : (C(), A("div", Ye, [
|
|
1478
|
+
u.keyName && !n.value ? (C(), A("span", {
|
|
1489
1479
|
key: 0,
|
|
1490
1480
|
class: "json-node__key",
|
|
1491
|
-
onClick:
|
|
1481
|
+
onClick: G,
|
|
1492
1482
|
title: "Click to edit key"
|
|
1493
|
-
}, ' "' +
|
|
1494
|
-
u.keyName && n.value ?
|
|
1483
|
+
}, ' "' + L(w.value) + '" ', 1)) : j("", !0),
|
|
1484
|
+
u.keyName && n.value ? oe((C(), A("input", {
|
|
1495
1485
|
key: 1,
|
|
1496
|
-
"onUpdate:modelValue":
|
|
1486
|
+
"onUpdate:modelValue": i[5] || (i[5] = (y) => l.value = y),
|
|
1497
1487
|
onKeyup: [
|
|
1498
|
-
|
|
1499
|
-
|
|
1488
|
+
Y(K, ["enter"]),
|
|
1489
|
+
Y(X, ["escape"])
|
|
1500
1490
|
],
|
|
1501
|
-
onBlur:
|
|
1491
|
+
onBlur: K,
|
|
1502
1492
|
class: "json-node__key-input"
|
|
1503
1493
|
}, null, 544)), [
|
|
1504
|
-
[
|
|
1505
|
-
]) :
|
|
1506
|
-
u.keyName ? (
|
|
1507
|
-
a.value ?
|
|
1494
|
+
[se, l.value]
|
|
1495
|
+
]) : j("", !0),
|
|
1496
|
+
u.keyName ? (C(), A("span", qe, ": ")) : j("", !0),
|
|
1497
|
+
a.value ? j("", !0) : (C(), A("span", {
|
|
1508
1498
|
key: 3,
|
|
1509
|
-
class:
|
|
1510
|
-
onClick:
|
|
1511
|
-
onDblclick:
|
|
1512
|
-
title:
|
|
1499
|
+
class: pe(["json-node__value", Z.value]),
|
|
1500
|
+
onClick: re,
|
|
1501
|
+
onDblclick: i[6] || (i[6] = (y) => u.$emit("copy", u.value)),
|
|
1502
|
+
title: H.value
|
|
1513
1503
|
}, [
|
|
1514
|
-
|
|
1515
|
-
u.isLast ?
|
|
1516
|
-
], 42,
|
|
1517
|
-
a.value ?
|
|
1504
|
+
ce(L(J.value), 1),
|
|
1505
|
+
u.isLast ? j("", !0) : (C(), A("span", Ge, ","))
|
|
1506
|
+
], 42, ze)),
|
|
1507
|
+
a.value ? oe((C(), A("input", {
|
|
1518
1508
|
key: 4,
|
|
1519
|
-
"onUpdate:modelValue":
|
|
1509
|
+
"onUpdate:modelValue": i[7] || (i[7] = (y) => f.value = y),
|
|
1520
1510
|
onKeyup: [
|
|
1521
|
-
|
|
1522
|
-
|
|
1511
|
+
Y(F, ["enter"]),
|
|
1512
|
+
Y(ne, ["escape"])
|
|
1523
1513
|
],
|
|
1524
|
-
onBlur:
|
|
1514
|
+
onBlur: F,
|
|
1525
1515
|
class: "json-node__value-input"
|
|
1526
1516
|
}, null, 544)), [
|
|
1527
|
-
[
|
|
1528
|
-
]) :
|
|
1517
|
+
[se, f.value]
|
|
1518
|
+
]) : j("", !0)
|
|
1529
1519
|
]))
|
|
1530
1520
|
]);
|
|
1531
1521
|
};
|
|
1532
1522
|
}
|
|
1533
|
-
}),
|
|
1523
|
+
}), ye = (r, e) => {
|
|
1534
1524
|
const t = r.__vccOpts || r;
|
|
1535
|
-
for (const [
|
|
1536
|
-
t[
|
|
1525
|
+
for (const [o, n] of e)
|
|
1526
|
+
t[o] = n;
|
|
1537
1527
|
return t;
|
|
1538
|
-
},
|
|
1528
|
+
}, Ze = /* @__PURE__ */ ye(We, [["__scopeId", "data-v-860beb35"]]), be = {
|
|
1539
1529
|
name: "github-light",
|
|
1540
1530
|
colors: {
|
|
1541
1531
|
// 背景色
|
|
@@ -1574,7 +1564,7 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
1574
1564
|
// 缩进线
|
|
1575
1565
|
indentLine: "#d0d7de"
|
|
1576
1566
|
}
|
|
1577
|
-
},
|
|
1567
|
+
}, Je = {
|
|
1578
1568
|
name: "github-dark",
|
|
1579
1569
|
colors: {
|
|
1580
1570
|
// 背景色
|
|
@@ -1613,7 +1603,7 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
1613
1603
|
// 缩进线
|
|
1614
1604
|
indentLine: "#30363d"
|
|
1615
1605
|
}
|
|
1616
|
-
},
|
|
1606
|
+
}, et = {
|
|
1617
1607
|
name: "min-light",
|
|
1618
1608
|
colors: {
|
|
1619
1609
|
// 背景色 - 纯白简洁
|
|
@@ -1652,7 +1642,7 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
1652
1642
|
// 缩进线
|
|
1653
1643
|
indentLine: "#e5e7eb"
|
|
1654
1644
|
}
|
|
1655
|
-
},
|
|
1645
|
+
}, tt = {
|
|
1656
1646
|
name: "slack-ochin",
|
|
1657
1647
|
colors: {
|
|
1658
1648
|
// 背景色 - 温暖的米色调
|
|
@@ -1691,34 +1681,34 @@ const Ue = { class: "json-node" }, Me = {
|
|
|
1691
1681
|
// 缩进线
|
|
1692
1682
|
indentLine: "#e8d5b7"
|
|
1693
1683
|
}
|
|
1694
|
-
},
|
|
1695
|
-
"github-light":
|
|
1696
|
-
"github-dark":
|
|
1697
|
-
"min-light":
|
|
1698
|
-
"slack-ochin":
|
|
1684
|
+
}, rt = {
|
|
1685
|
+
"github-light": be,
|
|
1686
|
+
"github-dark": Je,
|
|
1687
|
+
"min-light": et,
|
|
1688
|
+
"slack-ochin": tt
|
|
1699
1689
|
};
|
|
1700
|
-
function
|
|
1701
|
-
return
|
|
1690
|
+
function nt(r = "github-light") {
|
|
1691
|
+
return rt[r] || be;
|
|
1702
1692
|
}
|
|
1703
|
-
const
|
|
1693
|
+
const ot = {
|
|
1704
1694
|
key: 0,
|
|
1705
1695
|
class: "json-format__toolbar"
|
|
1706
|
-
},
|
|
1696
|
+
}, st = { class: "json-format__actions" }, it = ["disabled"], at = ["disabled"], lt = ["disabled"], ct = ["disabled"], ut = { class: "json-format__info" }, dt = {
|
|
1707
1697
|
key: 0,
|
|
1708
1698
|
class: "json-format__status json-format__status--success"
|
|
1709
|
-
},
|
|
1699
|
+
}, ht = {
|
|
1710
1700
|
key: 1,
|
|
1711
1701
|
class: "json-format__status json-format__status--error"
|
|
1712
|
-
},
|
|
1702
|
+
}, ft = { class: "json-format__content" }, pt = {
|
|
1713
1703
|
key: 0,
|
|
1714
1704
|
class: "json-format__error"
|
|
1715
|
-
},
|
|
1705
|
+
}, yt = {
|
|
1716
1706
|
key: 1,
|
|
1717
1707
|
class: "json-format__error"
|
|
1718
|
-
},
|
|
1708
|
+
}, bt = {
|
|
1719
1709
|
key: 2,
|
|
1720
1710
|
class: "json-format__viewer"
|
|
1721
|
-
},
|
|
1711
|
+
}, gt = /* @__PURE__ */ de({
|
|
1722
1712
|
name: "JsonFormat",
|
|
1723
1713
|
__name: "index",
|
|
1724
1714
|
props: {
|
|
@@ -1730,88 +1720,69 @@ const lt = {
|
|
|
1730
1720
|
},
|
|
1731
1721
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1732
1722
|
setup(r, { expose: e, emit: t }) {
|
|
1733
|
-
|
|
1734
|
-
"
|
|
1735
|
-
"
|
|
1736
|
-
"
|
|
1737
|
-
"
|
|
1738
|
-
"
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
"
|
|
1742
|
-
|
|
1743
|
-
"
|
|
1744
|
-
"
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
"
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1723
|
+
he((i) => ({
|
|
1724
|
+
"50e4672c": g.value.colors.border,
|
|
1725
|
+
"64d14328": g.value.colors.background,
|
|
1726
|
+
"668c94eb": g.value.colors.text,
|
|
1727
|
+
"8370c286": g.value.colors.surfaceBackground,
|
|
1728
|
+
"1698e888": g.value.colors.buttonBorder,
|
|
1729
|
+
"584924be": g.value.colors.buttonBackground,
|
|
1730
|
+
"325e00bd": g.value.colors.buttonText,
|
|
1731
|
+
"2430fb1e": g.value.colors.buttonBackgroundHover,
|
|
1732
|
+
ea0e2f1c: g.value.colors.buttonPrimary,
|
|
1733
|
+
"3b0b67ea": g.value.colors.buttonPrimaryHover,
|
|
1734
|
+
"2e7b3e93": g.value.colors.successBackground,
|
|
1735
|
+
b24220f6: g.value.colors.success,
|
|
1736
|
+
"0c7db250": g.value.colors.errorBackground,
|
|
1737
|
+
"6a387a0a": g.value.colors.error,
|
|
1738
|
+
"2c13c5fa": g.value.colors.scrollbarTrack,
|
|
1739
|
+
"2c1c44e4": g.value.colors.scrollbarThumb,
|
|
1740
|
+
"8ba97764": g.value.colors.scrollbarThumbHover
|
|
1751
1741
|
}));
|
|
1752
|
-
const
|
|
1742
|
+
const o = r, n = t, a = U(null), l = U(""), f = U(/* @__PURE__ */ new Set()), d = U(null), h = U(""), m = D(() => l.value === ""), g = D(() => nt(o.theme)), _ = D(() => h.value ? null : d.value !== null ? d.value : a.value), b = (i) => {
|
|
1753
1743
|
if (!i.trim()) {
|
|
1754
|
-
a.value = null,
|
|
1744
|
+
a.value = null, l.value = "", d.value = null, h.value = "";
|
|
1755
1745
|
return;
|
|
1756
1746
|
}
|
|
1757
1747
|
try {
|
|
1758
|
-
let
|
|
1759
|
-
const
|
|
1760
|
-
if (!
|
|
1748
|
+
let c = i;
|
|
1749
|
+
const y = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(c), p = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(c);
|
|
1750
|
+
if (!y && !p)
|
|
1761
1751
|
try {
|
|
1762
|
-
a.value = JSON.parse(
|
|
1763
|
-
|
|
1752
|
+
a.value = JSON.parse(c), l.value = "", d.value = null, h.value = "", W(() => {
|
|
1753
|
+
_.value !== null && H();
|
|
1764
1754
|
});
|
|
1765
1755
|
return;
|
|
1766
1756
|
} catch {
|
|
1767
1757
|
}
|
|
1768
|
-
|
|
1769
|
-
let
|
|
1770
|
-
for (;
|
|
1771
|
-
const
|
|
1772
|
-
if (
|
|
1773
|
-
|
|
1774
|
-
else if (
|
|
1775
|
-
|
|
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++;
|
|
1758
|
+
c = ((E) => {
|
|
1759
|
+
let k = "", P = !1, T = !1, R = 0;
|
|
1760
|
+
for (; R < E.length; ) {
|
|
1761
|
+
const Q = E[R];
|
|
1762
|
+
if (P)
|
|
1763
|
+
T ? T = !1 : Q === "\\" ? T = !0 : Q === '"' && (P = !1), k += Q, R++;
|
|
1764
|
+
else if (Q === '"')
|
|
1765
|
+
P = !0, k += Q, R++;
|
|
1795
1766
|
else {
|
|
1796
|
-
const
|
|
1797
|
-
let
|
|
1798
|
-
if (
|
|
1799
|
-
|
|
1767
|
+
const le = E.slice(R);
|
|
1768
|
+
let $ = le.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1769
|
+
if ($) {
|
|
1770
|
+
k += $[1] + '{"__protected_number__":"' + $[2] + '"}' + $[3], R += $[0].length;
|
|
1800
1771
|
continue;
|
|
1801
1772
|
}
|
|
1802
|
-
if (
|
|
1803
|
-
|
|
1773
|
+
if ($ = le.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), $) {
|
|
1774
|
+
k += $[1] + '{"__protected_number__":"' + $[2] + '"}' + $[3], R += $[0].length;
|
|
1804
1775
|
continue;
|
|
1805
1776
|
}
|
|
1806
|
-
|
|
1777
|
+
k += Q, R++;
|
|
1807
1778
|
}
|
|
1808
1779
|
}
|
|
1809
|
-
return
|
|
1810
|
-
})(
|
|
1811
|
-
|
|
1780
|
+
return k;
|
|
1781
|
+
})(c), a.value = JSON.parse(c), l.value = "", d.value = null, h.value = "", W(() => {
|
|
1782
|
+
_.value !== null && H();
|
|
1812
1783
|
});
|
|
1813
|
-
} catch (
|
|
1814
|
-
|
|
1784
|
+
} catch (c) {
|
|
1785
|
+
l.value = c instanceof Error ? c.message : "Unknown parsing error", a.value = null, d.value = null, h.value = "";
|
|
1815
1786
|
}
|
|
1816
1787
|
}, w = (i) => {
|
|
1817
1788
|
if (!i || !i.expression.trim()) {
|
|
@@ -1819,263 +1790,260 @@ const lt = {
|
|
|
1819
1790
|
return;
|
|
1820
1791
|
}
|
|
1821
1792
|
if (!a.value) {
|
|
1822
|
-
|
|
1793
|
+
h.value = "No valid JSON data to filter";
|
|
1823
1794
|
return;
|
|
1824
1795
|
}
|
|
1825
1796
|
try {
|
|
1826
|
-
let
|
|
1797
|
+
let c;
|
|
1827
1798
|
if (i.type === "jsonpath")
|
|
1828
|
-
|
|
1799
|
+
c = x({ path: i.expression, json: a.value }), c.length === 1 && i.expression.includes("$[") === !1 && !i.expression.endsWith("[*]") ? d.value = c[0] : d.value = c;
|
|
1829
1800
|
else if (i.type === "js")
|
|
1830
|
-
|
|
1801
|
+
c = new Function("data", `
|
|
1831
1802
|
try {
|
|
1832
1803
|
return ${i.expression};
|
|
1833
1804
|
} catch (error) {
|
|
1834
1805
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1835
1806
|
}
|
|
1836
|
-
`)(a.value),
|
|
1807
|
+
`)(a.value), d.value = c;
|
|
1837
1808
|
else
|
|
1838
1809
|
throw new Error(`Unsupported filter type: ${i.type}`);
|
|
1839
|
-
|
|
1840
|
-
|
|
1810
|
+
h.value = "", W(() => {
|
|
1811
|
+
H();
|
|
1841
1812
|
});
|
|
1842
|
-
} catch (
|
|
1843
|
-
|
|
1813
|
+
} catch (c) {
|
|
1814
|
+
h.value = c instanceof Error ? c.message : "Filter execution error", d.value = null;
|
|
1844
1815
|
}
|
|
1845
1816
|
}, S = () => {
|
|
1846
|
-
|
|
1817
|
+
d.value = null, h.value = "";
|
|
1847
1818
|
};
|
|
1848
|
-
|
|
1849
|
-
|
|
1819
|
+
Ee(() => o.modelValue, (i) => {
|
|
1820
|
+
b(i);
|
|
1850
1821
|
}, { immediate: !0 });
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
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) => {
|
|
1869
|
-
if (!s.readonly)
|
|
1822
|
+
const B = (i, c, y) => {
|
|
1823
|
+
const p = (k) => {
|
|
1824
|
+
if (k === null || typeof k != "object")
|
|
1825
|
+
return k;
|
|
1826
|
+
if (!Array.isArray(k) && "__protected_number__" in k && Object.keys(k).length === 1)
|
|
1827
|
+
return `__PROTECTED_NUMBER_${k.__protected_number__}_PROTECTED_NUMBER__`;
|
|
1828
|
+
if (Array.isArray(k))
|
|
1829
|
+
return k.map((T) => p(T));
|
|
1830
|
+
const P = {};
|
|
1831
|
+
for (const [T, R] of Object.entries(k))
|
|
1832
|
+
P[T] = p(R);
|
|
1833
|
+
return P;
|
|
1834
|
+
}, v = p(i);
|
|
1835
|
+
return JSON.stringify(v, c, y).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1836
|
+
}, I = (i, c) => {
|
|
1837
|
+
if (!o.readonly)
|
|
1870
1838
|
try {
|
|
1871
|
-
const
|
|
1839
|
+
const y = Z(a.value, i, c), p = B(y, null, 2);
|
|
1872
1840
|
n("update:modelValue", p);
|
|
1873
|
-
} catch (
|
|
1874
|
-
console.error("Failed to update JSON:",
|
|
1841
|
+
} catch (y) {
|
|
1842
|
+
console.error("Failed to update JSON:", y);
|
|
1875
1843
|
}
|
|
1876
|
-
},
|
|
1877
|
-
if (!
|
|
1878
|
-
const p =
|
|
1879
|
-
let
|
|
1880
|
-
for (let
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1844
|
+
}, Z = (i, c, y) => {
|
|
1845
|
+
if (!c || c === "root") return y;
|
|
1846
|
+
const p = c.split("."), v = F(i, p.slice(0, -1));
|
|
1847
|
+
let E = v;
|
|
1848
|
+
for (let P = 0; P < p.length - 1; P++) {
|
|
1849
|
+
const T = p[P];
|
|
1850
|
+
T !== "root" && (Array.isArray(E) ? E = E[parseInt(T)] : E = E[T]);
|
|
1883
1851
|
}
|
|
1884
|
-
const
|
|
1885
|
-
return
|
|
1886
|
-
},
|
|
1852
|
+
const k = p[p.length - 1];
|
|
1853
|
+
return k === "root" ? y : (Array.isArray(E) ? E[parseInt(k)] = y : E[k] = y, v);
|
|
1854
|
+
}, J = (i) => {
|
|
1887
1855
|
f.value.has(i) ? f.value.delete(i) : f.value.add(i);
|
|
1888
|
-
},
|
|
1889
|
-
const i = /* @__PURE__ */ new Set(),
|
|
1890
|
-
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
-
}) : Object.keys(
|
|
1894
|
-
const
|
|
1895
|
-
|
|
1856
|
+
}, H = () => {
|
|
1857
|
+
const i = /* @__PURE__ */ new Set(), c = (y, p = "") => {
|
|
1858
|
+
y !== null && typeof y == "object" && (i.add(p || "root"), Array.isArray(y) ? y.forEach((v, E) => {
|
|
1859
|
+
const k = p ? `${p}.${E}` : `${E}`;
|
|
1860
|
+
c(v, k);
|
|
1861
|
+
}) : Object.keys(y).forEach((v) => {
|
|
1862
|
+
const E = p ? `${p}.${v}` : v;
|
|
1863
|
+
c(y[v], E);
|
|
1896
1864
|
}));
|
|
1897
1865
|
};
|
|
1898
|
-
|
|
1899
|
-
},
|
|
1866
|
+
c(_.value), f.value = i, n("expand-all");
|
|
1867
|
+
}, ee = () => {
|
|
1900
1868
|
f.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1901
|
-
},
|
|
1902
|
-
if (
|
|
1869
|
+
}, te = async () => {
|
|
1870
|
+
if (m.value)
|
|
1903
1871
|
try {
|
|
1904
|
-
const i =
|
|
1905
|
-
await navigator.clipboard.writeText(
|
|
1872
|
+
const i = _.value, c = B(i, null, 2);
|
|
1873
|
+
await navigator.clipboard.writeText(c), n("copy-success", c);
|
|
1906
1874
|
} catch (i) {
|
|
1907
1875
|
console.error("Failed to copy JSON:", i), n("copy-error", i instanceof Error ? i : new Error("Failed to copy JSON"));
|
|
1908
1876
|
}
|
|
1909
|
-
},
|
|
1910
|
-
if (
|
|
1877
|
+
}, z = () => {
|
|
1878
|
+
if (m.value)
|
|
1911
1879
|
try {
|
|
1912
|
-
const i =
|
|
1913
|
-
n("update:modelValue",
|
|
1880
|
+
const i = _.value, c = B(i);
|
|
1881
|
+
n("update:modelValue", c), n("compress", c);
|
|
1914
1882
|
} catch (i) {
|
|
1915
1883
|
console.error("Failed to compress JSON:", i);
|
|
1916
1884
|
}
|
|
1917
|
-
},
|
|
1885
|
+
}, G = async (i) => {
|
|
1918
1886
|
try {
|
|
1919
|
-
let
|
|
1920
|
-
typeof i == "
|
|
1921
|
-
} catch (
|
|
1922
|
-
console.error("Failed to copy value:",
|
|
1887
|
+
let c;
|
|
1888
|
+
typeof i == "object" && i !== null && !Array.isArray(i) && "__protected_number__" in i && Object.keys(i).length === 1 ? c = i.__protected_number__ : typeof i == "string" ? c = `"${i}"` : c = JSON.stringify(i), await navigator.clipboard.writeText(c);
|
|
1889
|
+
} catch (c) {
|
|
1890
|
+
console.error("Failed to copy value:", c);
|
|
1923
1891
|
}
|
|
1924
|
-
},
|
|
1925
|
-
if (!
|
|
1892
|
+
}, re = (i, c) => {
|
|
1893
|
+
if (!o.readonly)
|
|
1926
1894
|
try {
|
|
1927
|
-
const
|
|
1928
|
-
n("update:modelValue", p),
|
|
1929
|
-
} catch (
|
|
1930
|
-
console.error("Failed to rename key:",
|
|
1895
|
+
const y = K(a.value, i, c), p = B(y, null, 2);
|
|
1896
|
+
n("update:modelValue", p), u(i, c);
|
|
1897
|
+
} catch (y) {
|
|
1898
|
+
console.error("Failed to rename key:", y);
|
|
1931
1899
|
}
|
|
1932
|
-
},
|
|
1933
|
-
if (!
|
|
1934
|
-
const p =
|
|
1900
|
+
}, K = (i, c, y) => {
|
|
1901
|
+
if (!c || c === "root") return i;
|
|
1902
|
+
const p = c.split("."), v = F(i, p.slice(0, -1));
|
|
1935
1903
|
if (p.length === 1) {
|
|
1936
|
-
const
|
|
1937
|
-
return
|
|
1904
|
+
const P = p[0];
|
|
1905
|
+
return v && typeof v == "object" && !Array.isArray(v) ? X(v, P, y) : v;
|
|
1938
1906
|
}
|
|
1939
|
-
let
|
|
1940
|
-
for (let
|
|
1941
|
-
const
|
|
1942
|
-
Array.isArray(
|
|
1907
|
+
let E = v;
|
|
1908
|
+
for (let P = 0; P < p.length - 1; P++) {
|
|
1909
|
+
const T = p[P];
|
|
1910
|
+
Array.isArray(E) ? E = E[parseInt(T)] : E = E[T];
|
|
1943
1911
|
}
|
|
1944
|
-
const
|
|
1945
|
-
if (!Array.isArray(
|
|
1946
|
-
const
|
|
1947
|
-
|
|
1912
|
+
const k = p[p.length - 1];
|
|
1913
|
+
if (!Array.isArray(E) && E && typeof E == "object") {
|
|
1914
|
+
const P = X(E, k, y), T = p.slice(0, -1);
|
|
1915
|
+
T.length > 0 && ne(v, T, P);
|
|
1948
1916
|
}
|
|
1949
|
-
return
|
|
1950
|
-
},
|
|
1951
|
-
if (
|
|
1917
|
+
return v;
|
|
1918
|
+
}, F = (i, c) => {
|
|
1919
|
+
if (c.length === 0) return i;
|
|
1952
1920
|
if (Array.isArray(i)) {
|
|
1953
|
-
const
|
|
1954
|
-
return
|
|
1921
|
+
const y = [...i], p = c[0], v = parseInt(p);
|
|
1922
|
+
return c.length === 1 || (y[v] = F(i[v], c.slice(1))), y;
|
|
1955
1923
|
} else if (i && typeof i == "object") {
|
|
1956
|
-
const
|
|
1957
|
-
return
|
|
1924
|
+
const y = { ...i }, p = c[0];
|
|
1925
|
+
return c.length === 1 || (y[p] = F(i[p], c.slice(1))), y;
|
|
1958
1926
|
}
|
|
1959
1927
|
return i;
|
|
1960
|
-
},
|
|
1928
|
+
}, X = (i, c, y) => {
|
|
1961
1929
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
1962
1930
|
return i;
|
|
1963
|
-
const p = Object.keys(i),
|
|
1964
|
-
for (const
|
|
1965
|
-
|
|
1966
|
-
return
|
|
1967
|
-
},
|
|
1931
|
+
const p = Object.keys(i), v = {};
|
|
1932
|
+
for (const E of p)
|
|
1933
|
+
E === c ? v[y] = i[E] : v[E] = i[E];
|
|
1934
|
+
return v;
|
|
1935
|
+
}, ne = (i, c, y) => {
|
|
1968
1936
|
let p = i;
|
|
1969
|
-
for (let
|
|
1970
|
-
const
|
|
1971
|
-
Array.isArray(p) ? p = p[parseInt(
|
|
1937
|
+
for (let E = 0; E < c.length - 1; E++) {
|
|
1938
|
+
const k = c[E];
|
|
1939
|
+
Array.isArray(p) ? p = p[parseInt(k)] : p = p[k];
|
|
1972
1940
|
}
|
|
1973
|
-
const
|
|
1974
|
-
Array.isArray(p) ? p[parseInt(
|
|
1975
|
-
},
|
|
1976
|
-
const
|
|
1941
|
+
const v = c[c.length - 1];
|
|
1942
|
+
Array.isArray(p) ? p[parseInt(v)] = y : p[v] = y;
|
|
1943
|
+
}, u = (i, c) => {
|
|
1944
|
+
const y = /* @__PURE__ */ new Set();
|
|
1977
1945
|
f.value.forEach((p) => {
|
|
1978
1946
|
if (p === i) {
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1947
|
+
const v = i.split(".");
|
|
1948
|
+
v[v.length - 1] = c, y.add(v.join("."));
|
|
1981
1949
|
} else if (p.startsWith(i + ".")) {
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1950
|
+
const v = i.split(".");
|
|
1951
|
+
v[v.length - 1] = c;
|
|
1952
|
+
const E = v.join("."), k = p.substring(i.length);
|
|
1953
|
+
y.add(E + k);
|
|
1986
1954
|
} else
|
|
1987
|
-
|
|
1988
|
-
}), f.value =
|
|
1955
|
+
y.add(p);
|
|
1956
|
+
}), f.value = y;
|
|
1989
1957
|
};
|
|
1990
1958
|
return e({
|
|
1991
1959
|
// 核心操作方法
|
|
1992
|
-
copyJson:
|
|
1993
|
-
compressSource:
|
|
1994
|
-
expandAll:
|
|
1995
|
-
collapseAll:
|
|
1996
|
-
toggleExpand:
|
|
1997
|
-
updateValue:
|
|
1998
|
-
updateKey:
|
|
1960
|
+
copyJson: te,
|
|
1961
|
+
compressSource: z,
|
|
1962
|
+
expandAll: H,
|
|
1963
|
+
collapseAll: ee,
|
|
1964
|
+
toggleExpand: J,
|
|
1965
|
+
updateValue: I,
|
|
1966
|
+
updateKey: re,
|
|
1999
1967
|
// Filter 相关方法
|
|
2000
1968
|
filter: w,
|
|
2001
1969
|
clearFilter: S,
|
|
2002
1970
|
// 状态访问方法
|
|
2003
|
-
isValidJson: () =>
|
|
1971
|
+
isValidJson: () => m.value,
|
|
2004
1972
|
getParsedJson: () => a.value,
|
|
2005
|
-
getFilteredJson: () =>
|
|
1973
|
+
getFilteredJson: () => d.value,
|
|
2006
1974
|
getExpandedNodes: () => f.value,
|
|
2007
|
-
getParseError: () =>
|
|
2008
|
-
getFilterError: () =>
|
|
1975
|
+
getParseError: () => l.value,
|
|
1976
|
+
getFilterError: () => h.value,
|
|
2009
1977
|
// 工具方法
|
|
2010
|
-
parseJson: (i) =>
|
|
2011
|
-
copyValue: (i) =>
|
|
2012
|
-
}), (i,
|
|
2013
|
-
class:
|
|
1978
|
+
parseJson: (i) => b(i),
|
|
1979
|
+
copyValue: (i) => G(i)
|
|
1980
|
+
}), (i, c) => (C(), A("div", {
|
|
1981
|
+
class: pe(["json-format", `json-format--${g.value.name}`])
|
|
2014
1982
|
}, [
|
|
2015
|
-
i.showToolbar ? (
|
|
2016
|
-
|
|
2017
|
-
|
|
1983
|
+
i.showToolbar ? (C(), A("div", ot, [
|
|
1984
|
+
N("div", st, [
|
|
1985
|
+
N("button", {
|
|
2018
1986
|
class: "json-format__btn json-format__btn--primary",
|
|
2019
|
-
onClick:
|
|
2020
|
-
disabled: !
|
|
1987
|
+
onClick: te,
|
|
1988
|
+
disabled: !m.value,
|
|
2021
1989
|
title: "Copy JSON"
|
|
2022
|
-
}, " 📋 Copy ", 8,
|
|
2023
|
-
|
|
1990
|
+
}, " 📋 Copy ", 8, it),
|
|
1991
|
+
N("button", {
|
|
2024
1992
|
class: "json-format__btn json-format__btn--secondary",
|
|
2025
|
-
onClick:
|
|
2026
|
-
disabled: !
|
|
1993
|
+
onClick: H,
|
|
1994
|
+
disabled: !m.value,
|
|
2027
1995
|
title: "Expand All"
|
|
2028
|
-
}, " ⬇️ Expand All ", 8,
|
|
2029
|
-
|
|
1996
|
+
}, " ⬇️ Expand All ", 8, at),
|
|
1997
|
+
N("button", {
|
|
2030
1998
|
class: "json-format__btn json-format__btn--secondary",
|
|
2031
|
-
onClick:
|
|
2032
|
-
disabled: !
|
|
1999
|
+
onClick: ee,
|
|
2000
|
+
disabled: !m.value,
|
|
2033
2001
|
title: "Collapse All"
|
|
2034
|
-
}, " ➡️ Collapse All ", 8,
|
|
2035
|
-
|
|
2002
|
+
}, " ➡️ Collapse All ", 8, lt),
|
|
2003
|
+
N("button", {
|
|
2036
2004
|
class: "json-format__btn json-format__btn--secondary",
|
|
2037
|
-
onClick:
|
|
2038
|
-
disabled: !
|
|
2005
|
+
onClick: z,
|
|
2006
|
+
disabled: !m.value,
|
|
2039
2007
|
title: "Compress JSON"
|
|
2040
|
-
}, " 📦 Compress ", 8,
|
|
2008
|
+
}, " 📦 Compress ", 8, ct)
|
|
2041
2009
|
]),
|
|
2042
|
-
|
|
2043
|
-
|
|
2010
|
+
N("div", ut, [
|
|
2011
|
+
m.value ? (C(), A("span", dt, " ✅ Valid JSON ")) : (C(), A("span", ht, " ❌ Invalid JSON "))
|
|
2044
2012
|
])
|
|
2045
|
-
])) :
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
])) : (
|
|
2051
|
-
|
|
2052
|
-
value:
|
|
2013
|
+
])) : j("", !0),
|
|
2014
|
+
N("div", ft, [
|
|
2015
|
+
m.value ? h.value ? (C(), A("div", yt, [
|
|
2016
|
+
c[1] || (c[1] = N("h4", null, "Filter Error:", -1)),
|
|
2017
|
+
N("pre", null, L(h.value), 1)
|
|
2018
|
+
])) : (C(), A("div", bt, [
|
|
2019
|
+
fe(Ze, {
|
|
2020
|
+
value: _.value,
|
|
2053
2021
|
"key-name": "",
|
|
2054
2022
|
level: 0,
|
|
2055
2023
|
expanded: f.value,
|
|
2056
2024
|
"is-last": !0,
|
|
2057
|
-
theme:
|
|
2058
|
-
"onUpdate:value":
|
|
2059
|
-
onToggleExpand:
|
|
2060
|
-
onCopy:
|
|
2061
|
-
"onUpdate:key":
|
|
2025
|
+
theme: g.value,
|
|
2026
|
+
"onUpdate:value": I,
|
|
2027
|
+
onToggleExpand: J,
|
|
2028
|
+
onCopy: G,
|
|
2029
|
+
"onUpdate:key": re
|
|
2062
2030
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2063
|
-
])) : (
|
|
2064
|
-
|
|
2065
|
-
|
|
2031
|
+
])) : (C(), A("div", pt, [
|
|
2032
|
+
c[0] || (c[0] = N("h4", null, "JSON Parse Error:", -1)),
|
|
2033
|
+
N("pre", null, L(l.value), 1)
|
|
2066
2034
|
]))
|
|
2067
2035
|
])
|
|
2068
2036
|
], 2));
|
|
2069
2037
|
}
|
|
2070
|
-
}),
|
|
2071
|
-
|
|
2038
|
+
}), vt = /* @__PURE__ */ ye(gt, [["__scopeId", "data-v-7a477244"]]), mt = [vt], Et = (r) => {
|
|
2039
|
+
mt.forEach((e) => {
|
|
2072
2040
|
const t = e.name || e.__name || "UnknownComponent";
|
|
2073
2041
|
r.component(t, e);
|
|
2074
2042
|
});
|
|
2075
|
-
},
|
|
2076
|
-
install:
|
|
2043
|
+
}, kt = {
|
|
2044
|
+
install: Et
|
|
2077
2045
|
};
|
|
2078
2046
|
export {
|
|
2079
|
-
|
|
2080
|
-
|
|
2047
|
+
vt as JsonFormat,
|
|
2048
|
+
kt as default
|
|
2081
2049
|
};
|