lone-format 0.3.1 → 0.3.2
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 +2703 -837
- package/dist/lone-format.umd.cjs +11 -4
- package/package.json +4 -2
package/dist/lone-format.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
class
|
|
1
|
+
import { defineComponent as be, useCssVars as Ce, ref as G, computed as L, resolveComponent as Me, createElementBlock as N, openBlock as x, createElementVNode as E, createCommentVNode as F, withDirectives as ve, toDisplayString as R, withKeys as le, vModelText as _e, createTextVNode as Se, Fragment as he, renderList as pe, createVNode as Ue, normalizeClass as Oe, nextTick as ce, watch as Fe, normalizeStyle as I, createBlock as Xe } from "vue";
|
|
2
|
+
class De {
|
|
3
3
|
/**
|
|
4
4
|
* @callback HookCallback
|
|
5
5
|
* @this {*|Jsep} this
|
|
@@ -18,13 +18,13 @@ class _e {
|
|
|
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,12 +37,12 @@ class _e {
|
|
|
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
|
}
|
|
45
|
-
class
|
|
45
|
+
class Je {
|
|
46
46
|
constructor(e) {
|
|
47
47
|
this.jsep = e, this.registered = {};
|
|
48
48
|
}
|
|
@@ -60,8 +60,8 @@ class xe {
|
|
|
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 xe {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class c {
|
|
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" + c.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 c.max_unop_len = Math.max(e.length, c.max_unop_len), c.unary_ops[e] = 1, c;
|
|
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 c.max_binop_len = Math.max(e.length, c.max_binop_len), c.binary_ops[e] = t, s ? c.right_associative.add(e) : c.right_associative.delete(e), c;
|
|
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 c.additional_identifier_chars.add(e), c;
|
|
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 c.literals[e] = t, c;
|
|
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 c.unary_ops[e], e.length === c.max_unop_len && (c.max_unop_len = c.getMaxKeyLen(c.unary_ops)), c;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* @method removeAllUnaryOps
|
|
131
131
|
* @returns {Jsep}
|
|
132
132
|
*/
|
|
133
133
|
static removeAllUnaryOps() {
|
|
134
|
-
return
|
|
134
|
+
return c.unary_ops = {}, c.max_unop_len = 0, c;
|
|
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 c.additional_identifier_chars.delete(e), c;
|
|
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 c.binary_ops[e], e.length === c.max_binop_len && (c.max_binop_len = c.getMaxKeyLen(c.binary_ops)), c.right_associative.delete(e), c;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* @method removeAllBinaryOps
|
|
154
154
|
* @returns {Jsep}
|
|
155
155
|
*/
|
|
156
156
|
static removeAllBinaryOps() {
|
|
157
|
-
return
|
|
157
|
+
return c.binary_ops = {}, c.max_binop_len = 0, c;
|
|
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 c.literals[e], c;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* @method removeAllLiterals
|
|
169
169
|
* @returns {Jsep}
|
|
170
170
|
*/
|
|
171
171
|
static removeAllLiterals() {
|
|
172
|
-
return
|
|
172
|
+
return c.literals = {}, c;
|
|
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 c(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 c.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 && !c.binary_ops[String.fromCharCode(e)] || // any non-ASCII that is not an operator
|
|
234
|
+
c.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 c.isIdentifierStart(e) || c.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 (c.hooks[e]) {
|
|
260
|
+
const s = {
|
|
261
261
|
context: this,
|
|
262
262
|
node: t
|
|
263
263
|
};
|
|
264
|
-
return
|
|
264
|
+
return c.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 (c.hooks[e]) {
|
|
275
275
|
const t = {
|
|
276
276
|
context: this
|
|
277
277
|
};
|
|
278
|
-
return
|
|
279
|
-
return
|
|
278
|
+
return c.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 === c.SPACE_CODE || e === c.TAB_CODE || e === c.LF_CODE || e === c.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: c.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 === c.SEMCOL_CODE || s === c.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, c.max_binop_len), t = e.length;
|
|
341
341
|
for (; t > 0; ) {
|
|
342
|
-
if (
|
|
342
|
+
if (c.binary_ops.hasOwnProperty(e) && (!c.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !c.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 s {
|
|
|
351
351
|
* @returns {?jsep.BinaryExpression}
|
|
352
352
|
*/
|
|
353
353
|
gobbleBinaryExpression() {
|
|
354
|
-
let e, t,
|
|
355
|
-
if (
|
|
356
|
-
return
|
|
357
|
-
for (
|
|
354
|
+
let e, t, s, n, o, i, u, a, l;
|
|
355
|
+
if (i = this.gobbleToken(), !i || (t = this.gobbleBinaryOp(), !t))
|
|
356
|
+
return i;
|
|
357
|
+
for (o = {
|
|
358
358
|
value: t,
|
|
359
|
-
prec:
|
|
360
|
-
right_a:
|
|
361
|
-
},
|
|
362
|
-
if (
|
|
359
|
+
prec: c.binaryPrecedence(t),
|
|
360
|
+
right_a: c.right_associative.has(t)
|
|
361
|
+
}, u = this.gobbleToken(), u || this.throwError("Expected expression after " + t), n = [i, o, u]; t = this.gobbleBinaryOp(); ) {
|
|
362
|
+
if (s = c.binaryPrecedence(t), s === 0) {
|
|
363
363
|
this.index -= t.length;
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
|
-
|
|
366
|
+
o = {
|
|
367
367
|
value: t,
|
|
368
|
-
prec:
|
|
369
|
-
right_a:
|
|
370
|
-
},
|
|
371
|
-
const
|
|
372
|
-
for (; n.length > 2 &&
|
|
373
|
-
|
|
374
|
-
type:
|
|
368
|
+
prec: s,
|
|
369
|
+
right_a: c.right_associative.has(t)
|
|
370
|
+
}, l = t;
|
|
371
|
+
const h = (f) => o.right_a && f.right_a ? s > f.prec : s <= f.prec;
|
|
372
|
+
for (; n.length > 2 && h(n[n.length - 2]); )
|
|
373
|
+
u = n.pop(), t = n.pop().value, i = n.pop(), e = {
|
|
374
|
+
type: c.BINARY_EXP,
|
|
375
375
|
operator: t,
|
|
376
|
-
left:
|
|
377
|
-
right:
|
|
376
|
+
left: i,
|
|
377
|
+
right: u
|
|
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 " + l), n.push(o, e);
|
|
380
380
|
}
|
|
381
|
-
for (
|
|
381
|
+
for (a = n.length - 1, e = n[a]; a > 1; )
|
|
382
382
|
e = {
|
|
383
|
-
type:
|
|
384
|
-
operator: n[
|
|
385
|
-
left: n[
|
|
383
|
+
type: c.BINARY_EXP,
|
|
384
|
+
operator: n[a - 1].value,
|
|
385
|
+
left: n[a - 2],
|
|
386
386
|
right: e
|
|
387
|
-
},
|
|
387
|
+
}, a -= 2;
|
|
388
388
|
return e;
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
@@ -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, c.isDecimalDigit(e) || e === c.PERIOD_CODE)
|
|
400
400
|
return this.gobbleNumericLiteral();
|
|
401
|
-
if (e ===
|
|
401
|
+
if (e === c.SQUOTE_CODE || e === c.DQUOTE_CODE)
|
|
402
402
|
n = this.gobbleStringLiteral();
|
|
403
|
-
else if (e ===
|
|
403
|
+
else if (e === c.OBRACK_CODE)
|
|
404
404
|
n = this.gobbleArray();
|
|
405
405
|
else {
|
|
406
|
-
for (t = this.expr.substr(this.index,
|
|
407
|
-
if (
|
|
408
|
-
this.index +=
|
|
409
|
-
const
|
|
410
|
-
return
|
|
411
|
-
type:
|
|
406
|
+
for (t = this.expr.substr(this.index, c.max_unop_len), s = t.length; s > 0; ) {
|
|
407
|
+
if (c.unary_ops.hasOwnProperty(t) && (!c.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !c.isIdentifierPart(this.expr.charCodeAt(this.index + t.length)))) {
|
|
408
|
+
this.index += s;
|
|
409
|
+
const o = this.gobbleToken();
|
|
410
|
+
return o || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
411
|
+
type: c.UNARY_EXP,
|
|
412
412
|
operator: t,
|
|
413
|
-
argument:
|
|
413
|
+
argument: o,
|
|
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
|
+
c.isIdentifierStart(e) ? (n = this.gobbleIdentifier(), c.literals.hasOwnProperty(n.name) ? n = {
|
|
420
|
+
type: c.LITERAL,
|
|
421
|
+
value: c.literals[n.name],
|
|
422
422
|
raw: n.name
|
|
423
|
-
} : n.name ===
|
|
424
|
-
type:
|
|
425
|
-
})) : e ===
|
|
423
|
+
} : n.name === c.this_str && (n = {
|
|
424
|
+
type: c.THIS_EXP
|
|
425
|
+
})) : e === c.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 === c.PERIOD_CODE || t === c.OBRACK_CODE || t === c.OPAREN_CODE || t === c.QUMARK_CODE; ) {
|
|
441
|
+
let s;
|
|
442
|
+
if (t === c.QUMARK_CODE) {
|
|
443
|
+
if (this.expr.charCodeAt(this.index + 1) !== c.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 === c.OBRACK_CODE ? (e = {
|
|
448
|
+
type: c.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 !== c.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : t === c.OPAREN_CODE ? e = {
|
|
453
|
+
type: c.CALL_EXP,
|
|
454
|
+
arguments: this.gobbleArguments(c.CPAREN_CODE),
|
|
455
455
|
callee: e
|
|
456
|
-
} : (t ===
|
|
457
|
-
type:
|
|
456
|
+
} : (t === c.PERIOD_CODE || s) && (s && this.index--, this.gobbleSpaces(), e = {
|
|
457
|
+
type: c.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 (; c.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 === c.PERIOD_CODE)
|
|
475
|
+
for (e += this.expr.charAt(this.index++); c.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++)); c.isDecimalDigit(this.code); )
|
|
479
479
|
e += this.expr.charAt(this.index++);
|
|
480
|
-
|
|
480
|
+
c.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, c.isIdentifierStart(s) ? this.throwError("Variable names cannot start with a number (" + e + this.char + ")") : (s === c.PERIOD_CODE || e.length === 1 && e.charCodeAt(0) === c.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
483
|
+
type: c.LITERAL,
|
|
484
484
|
value: parseFloat(e),
|
|
485
485
|
raw: e
|
|
486
486
|
};
|
|
@@ -492,15 +492,15 @@ 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
|
-
let
|
|
499
|
-
if (
|
|
498
|
+
let o = this.expr.charAt(this.index++);
|
|
499
|
+
if (o === s) {
|
|
500
500
|
n = !0;
|
|
501
501
|
break;
|
|
502
|
-
} else if (
|
|
503
|
-
switch (
|
|
502
|
+
} else if (o === "\\")
|
|
503
|
+
switch (o = this.expr.charAt(this.index++), o) {
|
|
504
504
|
case "n":
|
|
505
505
|
e += `
|
|
506
506
|
`;
|
|
@@ -521,13 +521,13 @@ class s {
|
|
|
521
521
|
e += "\v";
|
|
522
522
|
break;
|
|
523
523
|
default:
|
|
524
|
-
e +=
|
|
524
|
+
e += o;
|
|
525
525
|
}
|
|
526
526
|
else
|
|
527
|
-
e +=
|
|
527
|
+
e += o;
|
|
528
528
|
}
|
|
529
529
|
return n || this.throwError('Unclosed quote after "' + e + '"'), {
|
|
530
|
-
type:
|
|
530
|
+
type: c.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 (c.isIdentifierStart(e) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (e = this.code, c.isIdentifierPart(e)); )
|
|
545
545
|
this.index++;
|
|
546
546
|
return {
|
|
547
|
-
type:
|
|
547
|
+
type: c.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
|
-
let
|
|
566
|
-
if (
|
|
567
|
-
|
|
565
|
+
let o = this.code;
|
|
566
|
+
if (o === e) {
|
|
567
|
+
s = !0, this.index++, e === c.CPAREN_CODE && n && n >= t.length && this.throwError("Unexpected token " + String.fromCharCode(e));
|
|
568
568
|
break;
|
|
569
|
-
} else if (
|
|
569
|
+
} else if (o === c.COMMA_CODE) {
|
|
570
570
|
if (this.index++, n++, n !== t.length) {
|
|
571
|
-
if (e ===
|
|
571
|
+
if (e === c.CPAREN_CODE)
|
|
572
572
|
this.throwError("Unexpected token ,");
|
|
573
|
-
else if (e ===
|
|
574
|
-
for (let
|
|
573
|
+
else if (e === c.CBRACK_CODE)
|
|
574
|
+
for (let i = t.length; i < n; i++)
|
|
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 i = this.gobbleExpression();
|
|
581
|
+
(!i || i.type === c.COMPOUND) && this.throwError("Expected comma"), t.push(i);
|
|
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(c.CPAREN_CODE);
|
|
598
|
+
if (this.code === c.CPAREN_CODE)
|
|
599
599
|
return this.index++, e.length === 1 ? e[0] : e.length ? {
|
|
600
|
-
type:
|
|
600
|
+
type: c.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: c.ARRAY_EXP,
|
|
614
|
+
elements: this.gobbleArguments(c.CBRACK_CODE)
|
|
615
615
|
};
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
const
|
|
619
|
-
Object.assign(
|
|
620
|
-
hooks:
|
|
621
|
-
plugins: new
|
|
618
|
+
const et = new De();
|
|
619
|
+
Object.assign(c, {
|
|
620
|
+
hooks: et,
|
|
621
|
+
plugins: new Je(c),
|
|
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(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
|
|
715
|
+
c.max_unop_len = c.getMaxKeyLen(c.unary_ops);
|
|
716
|
+
c.max_binop_len = c.getMaxKeyLen(c.binary_ops);
|
|
717
|
+
const ee = (r) => new c(r).parse(), tt = Object.getOwnPropertyNames(class {
|
|
718
718
|
});
|
|
719
|
-
Object.getOwnPropertyNames(
|
|
720
|
-
|
|
719
|
+
Object.getOwnPropertyNames(c).filter((r) => !tt.includes(r) && ee[r] === void 0).forEach((r) => {
|
|
720
|
+
ee[r] = c[r];
|
|
721
721
|
});
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
var
|
|
722
|
+
ee.Jsep = c;
|
|
723
|
+
const rt = "ConditionalExpression";
|
|
724
|
+
var nt = {
|
|
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 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
|
-
const
|
|
734
|
-
if (
|
|
735
|
-
type:
|
|
736
|
-
test:
|
|
733
|
+
const o = this.gobbleExpression();
|
|
734
|
+
if (o || this.throwError("Expected expression"), t.node = {
|
|
735
|
+
type: rt,
|
|
736
|
+
test: s,
|
|
737
737
|
consequent: n,
|
|
738
|
-
alternate:
|
|
739
|
-
},
|
|
740
|
-
let
|
|
741
|
-
for (;
|
|
742
|
-
|
|
743
|
-
t.node.test =
|
|
738
|
+
alternate: o
|
|
739
|
+
}, s.operator && r.binary_ops[s.operator] <= 0.9) {
|
|
740
|
+
let i = s;
|
|
741
|
+
for (; i.right.operator && r.binary_ops[i.right.operator] <= 0.9; )
|
|
742
|
+
i = i.right;
|
|
743
|
+
t.node.test = i.right, i.right = t.node, t.node = s;
|
|
744
744
|
}
|
|
745
745
|
} else
|
|
746
746
|
this.throwError("Expected :");
|
|
@@ -748,66 +748,66 @@ var Ce = {
|
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
|
-
|
|
752
|
-
const
|
|
753
|
-
var
|
|
751
|
+
ee.plugins.register(nt);
|
|
752
|
+
const Ie = 47, st = 92;
|
|
753
|
+
var ot = {
|
|
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 === Ie) {
|
|
758
|
+
const s = ++this.index;
|
|
759
759
|
let n = !1;
|
|
760
760
|
for (; this.index < this.expr.length; ) {
|
|
761
|
-
if (this.code ===
|
|
762
|
-
const
|
|
763
|
-
let
|
|
761
|
+
if (this.code === Ie && !n) {
|
|
762
|
+
const o = this.expr.slice(s, this.index);
|
|
763
|
+
let i = "";
|
|
764
764
|
for (; ++this.index < this.expr.length; ) {
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
|
|
765
|
+
const a = this.code;
|
|
766
|
+
if (a >= 97 && a <= 122 || a >= 65 && a <= 90 || a >= 48 && a <= 57)
|
|
767
|
+
i += this.char;
|
|
768
768
|
else
|
|
769
769
|
break;
|
|
770
770
|
}
|
|
771
|
-
let
|
|
771
|
+
let u;
|
|
772
772
|
try {
|
|
773
|
-
|
|
774
|
-
} catch (
|
|
775
|
-
this.throwError(
|
|
773
|
+
u = new RegExp(o, i);
|
|
774
|
+
} catch (a) {
|
|
775
|
+
this.throwError(a.message);
|
|
776
776
|
}
|
|
777
777
|
return t.node = {
|
|
778
778
|
type: r.LITERAL,
|
|
779
|
-
value:
|
|
780
|
-
raw: this.expr.slice(
|
|
779
|
+
value: u,
|
|
780
|
+
raw: this.expr.slice(s - 1, this.index)
|
|
781
781
|
}, t.node = this.gobbleTokenProperty(t.node), t.node;
|
|
782
782
|
}
|
|
783
|
-
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code ===
|
|
783
|
+
this.code === r.OBRACK_CODE ? n = !0 : n && this.code === r.CBRACK_CODE && (n = !1), this.index += this.code === st ? 2 : 1;
|
|
784
784
|
}
|
|
785
785
|
this.throwError("Unclosed Regex");
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
|
-
const
|
|
790
|
+
const xe = 43, it = 45, ue = {
|
|
791
791
|
name: "assignment",
|
|
792
792
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
793
|
-
updateOperators: [
|
|
793
|
+
updateOperators: [xe, it],
|
|
794
794
|
assignmentPrecedence: 0.9,
|
|
795
795
|
init(r) {
|
|
796
796
|
const e = [r.IDENTIFIER, r.MEMBER_EXP];
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
|
|
797
|
+
ue.assignmentOperators.forEach((s) => r.addBinaryOp(s, ue.assignmentPrecedence, !0)), r.hooks.add("gobble-token", function(n) {
|
|
798
|
+
const o = this.code;
|
|
799
|
+
ue.updateOperators.some((i) => i === o && i === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, n.node = {
|
|
800
800
|
type: "UpdateExpression",
|
|
801
|
-
operator:
|
|
801
|
+
operator: o === xe ? "++" : "--",
|
|
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
|
-
const
|
|
808
|
-
|
|
807
|
+
const o = this.code;
|
|
808
|
+
ue.updateOperators.some((i) => i === o && i === this.expr.charCodeAt(this.index + 1)) && (e.includes(n.node.type) || this.throwError(`Unexpected ${n.node.operator}`), this.index += 2, n.node = {
|
|
809
809
|
type: "UpdateExpression",
|
|
810
|
-
operator:
|
|
810
|
+
operator: o === xe ? "++" : "--",
|
|
811
811
|
argument: n.node,
|
|
812
812
|
prefix: !1
|
|
813
813
|
});
|
|
@@ -815,18 +815,18 @@ const ie = 43, Pe = 45, q = {
|
|
|
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(s) {
|
|
819
|
+
ue.assignmentOperators.has(s.operator) ? (s.type = "AssignmentExpression", t(s.left), t(s.right)) : s.operator || Object.values(s).forEach((n) => {
|
|
820
820
|
n && typeof n == "object" && t(n);
|
|
821
821
|
});
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const
|
|
825
|
+
ee.plugins.register(ot, ue);
|
|
826
|
+
ee.addUnaryOp("typeof");
|
|
827
|
+
ee.addLiteral("null", null);
|
|
828
|
+
ee.addLiteral("undefined", void 0);
|
|
829
|
+
const at = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__"]), V = {
|
|
830
830
|
/**
|
|
831
831
|
* @param {jsep.Expression} ast
|
|
832
832
|
* @param {Record<string, any>} subs
|
|
@@ -835,67 +835,67 @@ const Te = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
835
835
|
switch (r.type) {
|
|
836
836
|
case "BinaryExpression":
|
|
837
837
|
case "LogicalExpression":
|
|
838
|
-
return
|
|
838
|
+
return V.evalBinaryExpression(r, e);
|
|
839
839
|
case "Compound":
|
|
840
|
-
return
|
|
840
|
+
return V.evalCompound(r, e);
|
|
841
841
|
case "ConditionalExpression":
|
|
842
|
-
return
|
|
842
|
+
return V.evalConditionalExpression(r, e);
|
|
843
843
|
case "Identifier":
|
|
844
|
-
return
|
|
844
|
+
return V.evalIdentifier(r, e);
|
|
845
845
|
case "Literal":
|
|
846
|
-
return
|
|
846
|
+
return V.evalLiteral(r, e);
|
|
847
847
|
case "MemberExpression":
|
|
848
|
-
return
|
|
848
|
+
return V.evalMemberExpression(r, e);
|
|
849
849
|
case "UnaryExpression":
|
|
850
|
-
return
|
|
850
|
+
return V.evalUnaryExpression(r, e);
|
|
851
851
|
case "ArrayExpression":
|
|
852
|
-
return
|
|
852
|
+
return V.evalArrayExpression(r, e);
|
|
853
853
|
case "CallExpression":
|
|
854
|
-
return
|
|
854
|
+
return V.evalCallExpression(r, e);
|
|
855
855
|
case "AssignmentExpression":
|
|
856
|
-
return
|
|
856
|
+
return V.evalAssignmentExpression(r, e);
|
|
857
857
|
default:
|
|
858
858
|
throw SyntaxError("Unexpected expression", r);
|
|
859
859
|
}
|
|
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
|
-
"%": (
|
|
886
|
-
}[r.operator](
|
|
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
|
+
}[r.operator](V.evalAst(r.left, e), () => V.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[
|
|
893
|
-
t =
|
|
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
|
+
t = V.evalAst(n, e);
|
|
894
894
|
}
|
|
895
895
|
return t;
|
|
896
896
|
},
|
|
897
897
|
evalConditionalExpression(r, e) {
|
|
898
|
-
return
|
|
898
|
+
return V.evalAst(r.test, e) ? V.evalAst(r.consequent, e) : V.evalAst(r.alternate, e);
|
|
899
899
|
},
|
|
900
900
|
evalIdentifier(r, e) {
|
|
901
901
|
if (Object.hasOwn(e, r.name))
|
|
@@ -910,46 +910,46 @@ const Te = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
910
910
|
// NOTE: `String(value)` throws error when
|
|
911
911
|
// value has overwritten the toString method to return non-string
|
|
912
912
|
// i.e. `value = {toString: () => []}`
|
|
913
|
-
r.computed ?
|
|
913
|
+
r.computed ? V.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 = V.evalAst(r.object, e);
|
|
916
|
+
if (s == null)
|
|
917
|
+
throw TypeError(`Cannot read properties of ${s} (reading '${t}')`);
|
|
918
|
+
if (!Object.hasOwn(s, t) && at.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) => -V.evalAst(s, e),
|
|
926
|
+
"!": (s) => !V.evalAst(s, e),
|
|
927
|
+
"~": (s) => ~V.evalAst(s, e),
|
|
928
928
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
929
|
-
"+": (
|
|
930
|
-
typeof: (
|
|
929
|
+
"+": (s) => +V.evalAst(s, e),
|
|
930
|
+
typeof: (s) => typeof V.evalAst(s, e)
|
|
931
931
|
}[r.operator](r.argument);
|
|
932
932
|
},
|
|
933
933
|
evalArrayExpression(r, e) {
|
|
934
|
-
return r.elements.map((t) =>
|
|
934
|
+
return r.elements.map((t) => V.evalAst(t, e));
|
|
935
935
|
},
|
|
936
936
|
evalCallExpression(r, e) {
|
|
937
|
-
const t = r.arguments.map((n) =>
|
|
938
|
-
return
|
|
937
|
+
const t = r.arguments.map((n) => V.evalAst(n, e));
|
|
938
|
+
return V.evalAst(r.callee, e)(...t);
|
|
939
939
|
},
|
|
940
940
|
evalAssignmentExpression(r, e) {
|
|
941
941
|
if (r.left.type !== "Identifier")
|
|
942
942
|
throw SyntaxError("Invalid left-hand side in assignment");
|
|
943
|
-
const t = r.left.name,
|
|
944
|
-
return e[t] =
|
|
943
|
+
const t = r.left.name, s = V.evalAst(r.right, e);
|
|
944
|
+
return e[t] = s, e[t];
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
|
-
class
|
|
947
|
+
class lt {
|
|
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 = ee(this.code);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* @param {object} context Object whose items will be added
|
|
@@ -958,16 +958,16 @@ class Ne {
|
|
|
958
958
|
*/
|
|
959
959
|
runInNewContext(e) {
|
|
960
960
|
const t = Object.assign(/* @__PURE__ */ Object.create(null), e);
|
|
961
|
-
return
|
|
961
|
+
return V.evalAst(this.ast, t);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
function
|
|
964
|
+
function te(r, e) {
|
|
965
965
|
return r = r.slice(), r.push(e), r;
|
|
966
966
|
}
|
|
967
|
-
function
|
|
967
|
+
function ke(r, e) {
|
|
968
968
|
return e = e.slice(), e.unshift(r), e;
|
|
969
969
|
}
|
|
970
|
-
class
|
|
970
|
+
class ut extends Error {
|
|
971
971
|
/**
|
|
972
972
|
* @param {AnyResult} value The evaluated scalar value
|
|
973
973
|
*/
|
|
@@ -975,304 +975,304 @@ class je 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 $(r, e, t, s, n) {
|
|
979
|
+
if (!(this instanceof $))
|
|
980
980
|
try {
|
|
981
|
-
return new
|
|
982
|
-
} catch (
|
|
983
|
-
if (!
|
|
984
|
-
throw
|
|
985
|
-
return
|
|
981
|
+
return new $(r, e, t, s, n);
|
|
982
|
+
} catch (i) {
|
|
983
|
+
if (!i.avoidNew)
|
|
984
|
+
throw i;
|
|
985
|
+
return i.value;
|
|
986
986
|
}
|
|
987
|
-
typeof r == "string" && (n =
|
|
988
|
-
const
|
|
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 ||
|
|
987
|
+
typeof r == "string" && (n = s, s = t, t = e, e = r, r = null);
|
|
988
|
+
const o = 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 || 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
|
|
993
|
-
path:
|
|
992
|
+
const i = {
|
|
993
|
+
path: o ? r.path : e
|
|
994
994
|
};
|
|
995
|
-
|
|
996
|
-
const
|
|
997
|
-
if (!
|
|
998
|
-
throw new
|
|
999
|
-
return
|
|
995
|
+
o ? "json" in r && (i.json = r.json) : i.json = t;
|
|
996
|
+
const u = this.evaluate(i);
|
|
997
|
+
if (!u || typeof u != "object")
|
|
998
|
+
throw new ut(u);
|
|
999
|
+
return u;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1003
|
-
let n = this.parent,
|
|
1004
|
-
flatten:
|
|
1005
|
-
wrap:
|
|
1002
|
+
$.prototype.evaluate = function(r, e, t, s) {
|
|
1003
|
+
let n = this.parent, o = this.parentProperty, {
|
|
1004
|
+
flatten: i,
|
|
1005
|
+
wrap: u
|
|
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), i = Object.hasOwn(r, "flatten") ? r.flatten : i, this.currResultType = Object.hasOwn(r, "resultType") ? r.resultType : this.currResultType, this.currSandbox = Object.hasOwn(r, "sandbox") ? r.sandbox : this.currSandbox, u = Object.hasOwn(r, "wrap") ? r.wrap : u, this.currEval = Object.hasOwn(r, "eval") ? r.eval : this.currEval, t = Object.hasOwn(r, "callback") ? r.callback : t, this.currOtherTypeCallback = Object.hasOwn(r, "otherTypeCallback") ? r.otherTypeCallback : this.currOtherTypeCallback, n = Object.hasOwn(r, "parent") ? r.parent : n, o = Object.hasOwn(r, "parentProperty") ? r.parentProperty : o, r = r.path;
|
|
1015
1015
|
}
|
|
1016
|
-
if (n = n || null,
|
|
1016
|
+
if (n = n || null, o = o || null, Array.isArray(r) && (r = $.toPathString(r)), !r && r !== "" || !e)
|
|
1017
1017
|
return;
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1018
|
+
const a = $.toPathArray(r);
|
|
1019
|
+
a[0] === "$" && a.length > 1 && a.shift(), this._hasParentSelector = null;
|
|
1020
|
+
const l = this._trace(a, e, ["$"], n, o, t).filter(function(h) {
|
|
1021
|
+
return h && !h.isParentSelector;
|
|
1022
1022
|
});
|
|
1023
|
-
return
|
|
1024
|
-
const
|
|
1025
|
-
return
|
|
1026
|
-
}, []) :
|
|
1023
|
+
return l.length ? !u && l.length === 1 && !l[0].hasArrExpr ? this._getPreferredOutput(l[0]) : l.reduce((h, f) => {
|
|
1024
|
+
const y = this._getPreferredOutput(f);
|
|
1025
|
+
return i && Array.isArray(y) ? h = h.concat(y) : h.push(y), h;
|
|
1026
|
+
}, []) : u ? [] : void 0;
|
|
1027
1027
|
};
|
|
1028
|
-
|
|
1028
|
+
$.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 : $.toPathArray(r.path);
|
|
1033
|
+
return r.pointer = $.toPointer(t), r.path = typeof r.path == "string" ? r.path : $.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 $.toPathString(r[e]);
|
|
1041
1041
|
case "pointer":
|
|
1042
|
-
return
|
|
1042
|
+
return $.toPointer(r.path);
|
|
1043
1043
|
default:
|
|
1044
1044
|
throw new TypeError("Unknown result type");
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
|
-
|
|
1047
|
+
$.prototype._handleCallback = function(r, e, t) {
|
|
1048
1048
|
if (e) {
|
|
1049
|
-
const
|
|
1050
|
-
r.path = typeof r.path == "string" ? r.path :
|
|
1049
|
+
const s = this._getPreferredOutput(r);
|
|
1050
|
+
r.path = typeof r.path == "string" ? r.path : $.toPathString(r.path), e(s, t, r);
|
|
1051
1051
|
}
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1054
|
-
let
|
|
1053
|
+
$.prototype._trace = function(r, e, t, s, n, o, i, u) {
|
|
1054
|
+
let a;
|
|
1055
1055
|
if (!r.length)
|
|
1056
|
-
return
|
|
1056
|
+
return a = {
|
|
1057
1057
|
path: t,
|
|
1058
1058
|
value: e,
|
|
1059
|
-
parent:
|
|
1059
|
+
parent: s,
|
|
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: i
|
|
1062
|
+
}, this._handleCallback(a, o, "value"), a;
|
|
1063
|
+
const l = r[0], h = r.slice(1), f = [];
|
|
1064
|
+
function y(m) {
|
|
1065
|
+
Array.isArray(m) ? m.forEach((C) => {
|
|
1066
|
+
f.push(C);
|
|
1067
|
+
}) : f.push(m);
|
|
1068
|
+
}
|
|
1069
|
+
if ((typeof l != "string" || u) && e && Object.hasOwn(e, l))
|
|
1070
|
+
y(this._trace(h, e[l], te(t, l), e, l, o, i));
|
|
1071
|
+
else if (l === "*")
|
|
1072
|
+
this._walk(e, (m) => {
|
|
1073
|
+
y(this._trace(h, e[m], te(t, m), e, m, o, !0, !0));
|
|
1074
1074
|
});
|
|
1075
|
-
else if (
|
|
1076
|
-
|
|
1077
|
-
typeof e[
|
|
1075
|
+
else if (l === "..")
|
|
1076
|
+
y(this._trace(h, e, t, s, n, o, i)), this._walk(e, (m) => {
|
|
1077
|
+
typeof e[m] == "object" && y(this._trace(r.slice(), e[m], te(t, m), e, m, o, !0));
|
|
1078
1078
|
});
|
|
1079
1079
|
else {
|
|
1080
|
-
if (
|
|
1080
|
+
if (l === "^")
|
|
1081
1081
|
return this._hasParentSelector = !0, {
|
|
1082
1082
|
path: t.slice(0, -1),
|
|
1083
|
-
expr:
|
|
1083
|
+
expr: h,
|
|
1084
1084
|
isParentSelector: !0
|
|
1085
1085
|
};
|
|
1086
|
-
if (
|
|
1087
|
-
return
|
|
1088
|
-
path:
|
|
1086
|
+
if (l === "~")
|
|
1087
|
+
return a = {
|
|
1088
|
+
path: te(t, l),
|
|
1089
1089
|
value: n,
|
|
1090
|
-
parent:
|
|
1090
|
+
parent: s,
|
|
1091
1091
|
parentProperty: null
|
|
1092
|
-
}, this._handleCallback(
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1095
|
-
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(
|
|
1096
|
-
|
|
1097
|
-
else if (
|
|
1092
|
+
}, this._handleCallback(a, o, "property"), a;
|
|
1093
|
+
if (l === "$")
|
|
1094
|
+
y(this._trace(h, e, t, null, null, o, i));
|
|
1095
|
+
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))
|
|
1096
|
+
y(this._slice(l, h, e, t, s, n, o));
|
|
1097
|
+
else if (l.indexOf("?(") === 0) {
|
|
1098
1098
|
if (this.currEval === !1)
|
|
1099
1099
|
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
const
|
|
1103
|
-
this._trace(
|
|
1104
|
-
}) : this._walk(e, (
|
|
1105
|
-
this._eval(
|
|
1100
|
+
const m = l.replace(/^\?\((.*?)\)$/u, "$1"), C = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(m);
|
|
1101
|
+
C ? this._walk(e, (O) => {
|
|
1102
|
+
const P = [C[2]], M = C[1] ? e[O][C[1]] : e[O];
|
|
1103
|
+
this._trace(P, M, t, s, n, o, !0).length > 0 && y(this._trace(h, e[O], te(t, O), e, O, o, !0));
|
|
1104
|
+
}) : this._walk(e, (O) => {
|
|
1105
|
+
this._eval(m, e[O], O, t, s, n) && y(this._trace(h, e[O], te(t, O), e, O, o, !0));
|
|
1106
1106
|
});
|
|
1107
|
-
} else if (
|
|
1107
|
+
} else if (l[0] === "(") {
|
|
1108
1108
|
if (this.currEval === !1)
|
|
1109
1109
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1110
|
-
|
|
1111
|
-
} else if (
|
|
1112
|
-
let
|
|
1113
|
-
const
|
|
1114
|
-
switch (
|
|
1110
|
+
y(this._trace(ke(this._eval(l, e, t.at(-1), t.slice(0, -1), s, n), h), e, t, s, n, o, i));
|
|
1111
|
+
} else if (l[0] === "@") {
|
|
1112
|
+
let m = !1;
|
|
1113
|
+
const C = l.slice(1, -2);
|
|
1114
|
+
switch (C) {
|
|
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 ===
|
|
1122
|
+
typeof e === C && (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 ===
|
|
1134
|
+
e && typeof e === C && (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
|
-
throw new TypeError("Unknown value type " +
|
|
1147
|
+
throw new TypeError("Unknown value type " + C);
|
|
1148
1148
|
}
|
|
1149
|
-
if (
|
|
1150
|
-
return
|
|
1149
|
+
if (m)
|
|
1150
|
+
return a = {
|
|
1151
1151
|
path: t,
|
|
1152
1152
|
value: e,
|
|
1153
|
-
parent:
|
|
1153
|
+
parent: s,
|
|
1154
1154
|
parentProperty: n
|
|
1155
|
-
}, this._handleCallback(
|
|
1156
|
-
} else if (
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
} else if (
|
|
1160
|
-
const
|
|
1161
|
-
for (const
|
|
1162
|
-
|
|
1163
|
-
} else !
|
|
1155
|
+
}, this._handleCallback(a, o, "value"), a;
|
|
1156
|
+
} else if (l[0] === "`" && e && Object.hasOwn(e, l.slice(1))) {
|
|
1157
|
+
const m = l.slice(1);
|
|
1158
|
+
y(this._trace(h, e[m], te(t, m), e, m, o, i, !0));
|
|
1159
|
+
} else if (l.includes(",")) {
|
|
1160
|
+
const m = l.split(",");
|
|
1161
|
+
for (const C of m)
|
|
1162
|
+
y(this._trace(ke(C, h), e, t, s, n, o, !0));
|
|
1163
|
+
} else !u && e && Object.hasOwn(e, l) && y(this._trace(h, e[l], te(t, l), e, l, o, i, !0));
|
|
1164
1164
|
}
|
|
1165
1165
|
if (this._hasParentSelector)
|
|
1166
|
-
for (let
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
const
|
|
1170
|
-
if (Array.isArray(
|
|
1171
|
-
|
|
1172
|
-
const
|
|
1173
|
-
for (let
|
|
1174
|
-
|
|
1166
|
+
for (let m = 0; m < f.length; m++) {
|
|
1167
|
+
const C = f[m];
|
|
1168
|
+
if (C && C.isParentSelector) {
|
|
1169
|
+
const O = this._trace(C.expr, e, C.path, s, n, o, i);
|
|
1170
|
+
if (Array.isArray(O)) {
|
|
1171
|
+
f[m] = O[0];
|
|
1172
|
+
const P = O.length;
|
|
1173
|
+
for (let M = 1; M < P; M++)
|
|
1174
|
+
m++, f.splice(m, 0, O[M]);
|
|
1175
1175
|
} else
|
|
1176
|
-
|
|
1176
|
+
f[m] = O;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
return
|
|
1179
|
+
return f;
|
|
1180
1180
|
};
|
|
1181
|
-
|
|
1181
|
+
$.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
|
-
|
|
1190
|
+
$.prototype._slice = function(r, e, t, s, n, o, i) {
|
|
1191
1191
|
if (!Array.isArray(t))
|
|
1192
1192
|
return;
|
|
1193
|
-
const
|
|
1194
|
-
let
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
for (let
|
|
1198
|
-
this._trace(
|
|
1199
|
-
|
|
1193
|
+
const u = t.length, a = r.split(":"), l = a[2] && Number.parseInt(a[2]) || 1;
|
|
1194
|
+
let h = a[0] && Number.parseInt(a[0]) || 0, f = a[1] && Number.parseInt(a[1]) || u;
|
|
1195
|
+
h = h < 0 ? Math.max(0, h + u) : Math.min(u, h), f = f < 0 ? Math.max(0, f + u) : Math.min(u, f);
|
|
1196
|
+
const y = [];
|
|
1197
|
+
for (let m = h; m < f; m += l)
|
|
1198
|
+
this._trace(ke(m, e), t, s, n, o, i, !0).forEach((O) => {
|
|
1199
|
+
y.push(O);
|
|
1200
1200
|
});
|
|
1201
|
-
return
|
|
1201
|
+
return y;
|
|
1202
1202
|
};
|
|
1203
|
-
|
|
1204
|
-
this.currSandbox._$_parentProperty =
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1208
|
-
if (
|
|
1209
|
-
let
|
|
1210
|
-
if (
|
|
1211
|
-
|
|
1203
|
+
$.prototype._eval = function(r, e, t, s, n, o) {
|
|
1204
|
+
this.currSandbox._$_parentProperty = o, this.currSandbox._$_parent = n, this.currSandbox._$_property = t, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
|
|
1205
|
+
const i = r.includes("@path");
|
|
1206
|
+
i && (this.currSandbox._$_path = $.toPathString(s.concat([t])));
|
|
1207
|
+
const u = this.currEval + "Script:" + r;
|
|
1208
|
+
if (!$.cache[u]) {
|
|
1209
|
+
let a = r.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
1210
|
+
if (i && (a = a.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
1211
|
+
$.cache[u] = new this.safeVm.Script(a);
|
|
1212
1212
|
else if (this.currEval === "native")
|
|
1213
|
-
|
|
1213
|
+
$.cache[u] = new this.vm.Script(a);
|
|
1214
1214
|
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1215
|
+
const l = this.currEval;
|
|
1216
|
+
$.cache[u] = new l(a);
|
|
1217
1217
|
} else if (typeof this.currEval == "function")
|
|
1218
|
-
|
|
1219
|
-
runInNewContext: (
|
|
1218
|
+
$.cache[u] = {
|
|
1219
|
+
runInNewContext: (l) => this.currEval(a, l)
|
|
1220
1220
|
};
|
|
1221
1221
|
else
|
|
1222
1222
|
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
1223
1223
|
}
|
|
1224
1224
|
try {
|
|
1225
|
-
return
|
|
1226
|
-
} catch (
|
|
1225
|
+
return $.cache[u].runInNewContext(this.currSandbox);
|
|
1226
|
+
} catch (a) {
|
|
1227
1227
|
if (this.ignoreEvalErrors)
|
|
1228
1228
|
return !1;
|
|
1229
|
-
throw new Error("jsonPath: " +
|
|
1229
|
+
throw new Error("jsonPath: " + a.message + ": " + r);
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
|
-
|
|
1233
|
-
|
|
1232
|
+
$.cache = {};
|
|
1233
|
+
$.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
|
+
$.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
|
+
$.toPathArray = function(r) {
|
|
1248
1248
|
const {
|
|
1249
1249
|
cache: e
|
|
1250
|
-
} =
|
|
1250
|
+
} = $;
|
|
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(
|
|
1254
|
-
return "[#" + (t.push(
|
|
1255
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(
|
|
1256
|
-
return "['" +
|
|
1257
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(
|
|
1258
|
-
return ";" +
|
|
1259
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(
|
|
1260
|
-
const
|
|
1261
|
-
return !
|
|
1253
|
+
const t = [], n = r.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(o, i) {
|
|
1254
|
+
return "[#" + (t.push(i) - 1) + "]";
|
|
1255
|
+
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(o, i) {
|
|
1256
|
+
return "['" + i.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
1257
|
+
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(o, i) {
|
|
1258
|
+
return ";" + i.split("").join(";") + ";";
|
|
1259
|
+
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(o) {
|
|
1260
|
+
const i = o.match(/#(\d+)/u);
|
|
1261
|
+
return !i || !i[1] ? o : t[i[1]];
|
|
1262
1262
|
});
|
|
1263
1263
|
return e[r] = n, e[r].concat();
|
|
1264
1264
|
};
|
|
1265
|
-
|
|
1266
|
-
Script:
|
|
1265
|
+
$.prototype.safeVm = {
|
|
1266
|
+
Script: lt
|
|
1267
1267
|
};
|
|
1268
|
-
const
|
|
1269
|
-
const
|
|
1270
|
-
for (let n = 0; n <
|
|
1271
|
-
const
|
|
1272
|
-
t(
|
|
1268
|
+
const ct = function(r, e, t) {
|
|
1269
|
+
const s = r.length;
|
|
1270
|
+
for (let n = 0; n < s; n++) {
|
|
1271
|
+
const o = r[n];
|
|
1272
|
+
t(o) && e.push(r.splice(n--, 1)[0]);
|
|
1273
1273
|
}
|
|
1274
1274
|
};
|
|
1275
|
-
class
|
|
1275
|
+
class dt {
|
|
1276
1276
|
/**
|
|
1277
1277
|
* @param {string} expr Expression to evaluate
|
|
1278
1278
|
*/
|
|
@@ -1286,48 +1286,48 @@ class Be {
|
|
|
1286
1286
|
*/
|
|
1287
1287
|
runInNewContext(e) {
|
|
1288
1288
|
let t = this.code;
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
const
|
|
1292
|
-
t = n.reduce((
|
|
1293
|
-
let
|
|
1294
|
-
return /function/u.test(
|
|
1295
|
-
}, "") + t, !/(['"])use strict\1/u.test(t) && !
|
|
1296
|
-
const
|
|
1297
|
-
return new Function(...
|
|
1289
|
+
const s = Object.keys(e), n = [];
|
|
1290
|
+
ct(s, n, (l) => typeof e[l] == "function");
|
|
1291
|
+
const o = s.map((l) => e[l]);
|
|
1292
|
+
t = n.reduce((l, h) => {
|
|
1293
|
+
let f = e[h].toString();
|
|
1294
|
+
return /function/u.test(f) || (f = "function " + f), "var " + h + "=" + f + ";" + l;
|
|
1295
|
+
}, "") + t, !/(['"])use strict\1/u.test(t) && !s.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;\s*$/u, "");
|
|
1296
|
+
const u = t.lastIndexOf(";"), a = u !== -1 ? t.slice(0, u + 1) + " return " + t.slice(u + 1) : " return " + t;
|
|
1297
|
+
return new Function(...s, a)(...o);
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
|
-
|
|
1301
|
-
Script:
|
|
1300
|
+
$.prototype.vm = {
|
|
1301
|
+
Script: dt
|
|
1302
1302
|
};
|
|
1303
|
-
const
|
|
1303
|
+
const ft = { class: "json-node" }, ht = {
|
|
1304
1304
|
key: 0,
|
|
1305
1305
|
class: "json-node__container"
|
|
1306
|
-
},
|
|
1306
|
+
}, pt = { class: "json-node__line" }, gt = {
|
|
1307
1307
|
key: 2,
|
|
1308
1308
|
class: "json-node__colon"
|
|
1309
|
-
},
|
|
1309
|
+
}, bt = ["title"], mt = {
|
|
1310
1310
|
key: 3,
|
|
1311
1311
|
class: "json-node__collapsed"
|
|
1312
|
-
},
|
|
1312
|
+
}, yt = {
|
|
1313
1313
|
key: 4,
|
|
1314
1314
|
class: "json-node__comma"
|
|
1315
|
-
},
|
|
1315
|
+
}, Et = {
|
|
1316
1316
|
key: 0,
|
|
1317
1317
|
class: "json-node__children"
|
|
1318
|
-
},
|
|
1318
|
+
}, vt = { class: "json-node__children-content" }, _t = { class: "json-node__line json-node__closing-bracket" }, xt = { class: "json-node__bracket" }, Nt = {
|
|
1319
1319
|
key: 0,
|
|
1320
1320
|
class: "json-node__comma"
|
|
1321
|
-
},
|
|
1321
|
+
}, kt = {
|
|
1322
1322
|
key: 1,
|
|
1323
1323
|
class: "json-node__primitive"
|
|
1324
|
-
},
|
|
1324
|
+
}, wt = {
|
|
1325
1325
|
key: 2,
|
|
1326
1326
|
class: "json-node__colon"
|
|
1327
|
-
},
|
|
1327
|
+
}, At = ["title"], Ct = {
|
|
1328
1328
|
key: 0,
|
|
1329
1329
|
class: "json-node__comma"
|
|
1330
|
-
},
|
|
1330
|
+
}, Ot = /* @__PURE__ */ be({
|
|
1331
1331
|
name: "JsonNode",
|
|
1332
1332
|
__name: "JsonNode",
|
|
1333
1333
|
props: {
|
|
@@ -1341,191 +1341,191 @@ const $e = { class: "json-node" }, Ie = {
|
|
|
1341
1341
|
},
|
|
1342
1342
|
emits: ["update:value", "toggle-expand", "copy", "update:key"],
|
|
1343
1343
|
setup(r, { emit: e }) {
|
|
1344
|
-
|
|
1345
|
-
"7b112182":
|
|
1346
|
-
"1501a3a8":
|
|
1347
|
-
"4c2226b6":
|
|
1348
|
-
"30aa351e":
|
|
1349
|
-
"090e30f3":
|
|
1350
|
-
cf872bb0:
|
|
1351
|
-
e0803540:
|
|
1352
|
-
"3954b61e":
|
|
1353
|
-
e9972d44:
|
|
1354
|
-
"231c0282":
|
|
1355
|
-
e1dce7d8:
|
|
1344
|
+
Ce((b) => ({
|
|
1345
|
+
"7b112182": b.level,
|
|
1346
|
+
"1501a3a8": b.theme.colors.syntaxKey,
|
|
1347
|
+
"4c2226b6": b.theme.colors.hoverBackground,
|
|
1348
|
+
"30aa351e": b.theme.colors.syntaxBracket,
|
|
1349
|
+
"090e30f3": b.theme.colors.textSecondary,
|
|
1350
|
+
cf872bb0: b.theme.colors.syntaxString,
|
|
1351
|
+
e0803540: b.theme.colors.syntaxNumber,
|
|
1352
|
+
"3954b61e": b.theme.colors.syntaxBoolean,
|
|
1353
|
+
e9972d44: b.theme.colors.syntaxNull,
|
|
1354
|
+
"231c0282": b.theme.colors.background,
|
|
1355
|
+
e1dce7d8: b.theme.colors.indentLine
|
|
1356
1356
|
}));
|
|
1357
|
-
const t = r,
|
|
1357
|
+
const t = r, s = e, n = G(!1), o = G(!1), i = G(""), u = G(""), a = (b) => b !== null && typeof b == "object" && !Array.isArray(b) && "__protected_number__" in b && Object.keys(b).length === 1, l = (b) => a(b) ? b.__protected_number__ : "", h = L(() => a(t.value) ? !1 : t.value !== null && typeof t.value == "object"), f = L(() => Array.isArray(t.value)), y = L(() => t.path ? t.path : t.keyName ? t.keyName : "root"), m = L(() => t.expanded.has(y.value)), C = L(() => t.keyName), O = L(() => f.value ? "[" : "{"), P = L(() => f.value ? "]" : "}"), M = L(() => {
|
|
1358
1358
|
if (!t.value) return "";
|
|
1359
|
-
const
|
|
1360
|
-
return
|
|
1361
|
-
}),
|
|
1362
|
-
const
|
|
1363
|
-
return t.value === null ? "json-node__value--null" :
|
|
1364
|
-
}),
|
|
1365
|
-
const
|
|
1366
|
-
return
|
|
1367
|
-
},
|
|
1368
|
-
|
|
1369
|
-
},
|
|
1370
|
-
t.level !== 0 && (n.value = !0,
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1359
|
+
const d = Object.keys(t.value).length;
|
|
1360
|
+
return f.value ? d > 0 ? ` ${d} items ` : " " : d > 0 ? ` ${d} keys ` : " ";
|
|
1361
|
+
}), k = L(() => {
|
|
1362
|
+
const b = typeof t.value;
|
|
1363
|
+
return t.value === null ? "json-node__value--null" : b === "boolean" ? "json-node__value--boolean" : b === "number" || a(t.value) ? "json-node__value--number" : b === "string" ? "json-node__value--string" : "";
|
|
1364
|
+
}), S = L(() => o.value ? u.value : t.value === null ? "null" : typeof t.value == "boolean" || typeof t.value == "number" ? String(t.value) : a(t.value) ? l(t.value) : typeof t.value == "string" ? `"${t.value}"` : String(t.value)), g = L(() => "Click to edit, double-click to copy"), T = (b) => t.level === 0 ? b : y.value ? `${y.value}.${b}` : b, X = (b) => {
|
|
1365
|
+
const d = Object.keys(t.value);
|
|
1366
|
+
return d.indexOf(b) === d.length - 1;
|
|
1367
|
+
}, j = () => {
|
|
1368
|
+
s("toggle-expand", y.value);
|
|
1369
|
+
}, Y = () => {
|
|
1370
|
+
t.level !== 0 && (n.value = !0, i.value = t.keyName, ce(() => {
|
|
1371
|
+
const b = document.querySelectorAll(".json-node__key-input"), d = b[b.length - 1];
|
|
1372
|
+
d && (d.focus(), d.select());
|
|
1373
1373
|
}));
|
|
1374
|
-
},
|
|
1375
|
-
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1374
|
+
}, Z = () => {
|
|
1375
|
+
h.value || (o.value = !0, a(t.value) ? u.value = l(t.value) : typeof t.value == "string" ? u.value = t.value : u.value = String(t.value), ce(() => {
|
|
1376
|
+
const b = document.querySelectorAll(".json-node__value-input"), d = b[b.length - 1];
|
|
1377
|
+
d && (d.focus(), d.select());
|
|
1378
1378
|
}));
|
|
1379
|
-
},
|
|
1379
|
+
}, D = () => {
|
|
1380
1380
|
if (t.level === 0 || !n.value) return;
|
|
1381
|
-
const
|
|
1382
|
-
if (!
|
|
1383
|
-
|
|
1381
|
+
const b = i.value.trim();
|
|
1382
|
+
if (!b) {
|
|
1383
|
+
ie();
|
|
1384
1384
|
return;
|
|
1385
1385
|
}
|
|
1386
|
-
if (
|
|
1386
|
+
if (b === t.keyName) {
|
|
1387
1387
|
n.value = !1;
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
|
-
n.value = !1,
|
|
1391
|
-
},
|
|
1390
|
+
n.value = !1, s("update:key", y.value, b);
|
|
1391
|
+
}, J = () => {
|
|
1392
1392
|
try {
|
|
1393
|
-
let
|
|
1394
|
-
const
|
|
1395
|
-
if (
|
|
1396
|
-
|
|
1397
|
-
else if (
|
|
1398
|
-
|
|
1399
|
-
else if (!isNaN(Number(
|
|
1400
|
-
const
|
|
1401
|
-
!Number.isSafeInteger(
|
|
1393
|
+
let b;
|
|
1394
|
+
const d = u.value.trim();
|
|
1395
|
+
if (d === "null")
|
|
1396
|
+
b = null;
|
|
1397
|
+
else if (d === "true" || d === "false")
|
|
1398
|
+
b = d === "true";
|
|
1399
|
+
else if (!isNaN(Number(d)) && d !== "") {
|
|
1400
|
+
const p = Number(d);
|
|
1401
|
+
!Number.isSafeInteger(p) || d.length > 15 ? b = { __protected_number__: d } : b = p;
|
|
1402
1402
|
} else
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
} catch (
|
|
1406
|
-
console.error("Failed to parse value:",
|
|
1403
|
+
b = u.value;
|
|
1404
|
+
s("update:value", y.value, b), o.value = !1;
|
|
1405
|
+
} catch (b) {
|
|
1406
|
+
console.error("Failed to parse value:", b), o.value = !1;
|
|
1407
1407
|
}
|
|
1408
|
-
},
|
|
1409
|
-
n.value = !1,
|
|
1410
|
-
},
|
|
1411
|
-
|
|
1408
|
+
}, ie = () => {
|
|
1409
|
+
n.value = !1, i.value = t.keyName;
|
|
1410
|
+
}, Ee = () => {
|
|
1411
|
+
o.value = !1, a(t.value) ? u.value = l(t.value) : typeof t.value == "string" ? u.value = t.value : u.value = String(t.value);
|
|
1412
1412
|
};
|
|
1413
|
-
return (
|
|
1414
|
-
const
|
|
1415
|
-
return
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1413
|
+
return (b, d) => {
|
|
1414
|
+
const p = Me("JsonNode", !0);
|
|
1415
|
+
return x(), N("div", ft, [
|
|
1416
|
+
h.value ? (x(), N("div", ht, [
|
|
1417
|
+
E("div", pt, [
|
|
1418
|
+
b.keyName && !n.value ? (x(), N("span", {
|
|
1419
1419
|
key: 0,
|
|
1420
1420
|
class: "json-node__key",
|
|
1421
|
-
onClick:
|
|
1421
|
+
onClick: Y,
|
|
1422
1422
|
title: "Click to edit key"
|
|
1423
|
-
}, ' "' +
|
|
1424
|
-
|
|
1423
|
+
}, ' "' + R(C.value) + '" ', 1)) : F("", !0),
|
|
1424
|
+
b.keyName && n.value ? ve((x(), N("input", {
|
|
1425
1425
|
key: 1,
|
|
1426
|
-
"onUpdate:modelValue":
|
|
1426
|
+
"onUpdate:modelValue": d[0] || (d[0] = (_) => i.value = _),
|
|
1427
1427
|
onKeyup: [
|
|
1428
|
-
|
|
1429
|
-
|
|
1428
|
+
le(D, ["enter"]),
|
|
1429
|
+
le(ie, ["escape"])
|
|
1430
1430
|
],
|
|
1431
|
-
onBlur:
|
|
1431
|
+
onBlur: D,
|
|
1432
1432
|
class: "json-node__key-input"
|
|
1433
1433
|
}, null, 544)), [
|
|
1434
|
-
[
|
|
1435
|
-
]) :
|
|
1436
|
-
|
|
1437
|
-
|
|
1434
|
+
[_e, i.value]
|
|
1435
|
+
]) : F("", !0),
|
|
1436
|
+
b.keyName ? (x(), N("span", gt, ": ")) : F("", !0),
|
|
1437
|
+
E("span", {
|
|
1438
1438
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1439
|
-
onClick:
|
|
1440
|
-
title:
|
|
1441
|
-
},
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1439
|
+
onClick: j,
|
|
1440
|
+
title: m.value ? "Click to collapse" : "Click to expand"
|
|
1441
|
+
}, R(O.value), 9, bt),
|
|
1442
|
+
m.value ? F("", !0) : (x(), N("span", mt, [
|
|
1443
|
+
Se(R(M.value) + " ", 1),
|
|
1444
|
+
E("span", {
|
|
1445
1445
|
class: "json-node__bracket json-node__bracket--clickable",
|
|
1446
|
-
onClick:
|
|
1447
|
-
},
|
|
1446
|
+
onClick: j
|
|
1447
|
+
}, R(P.value), 1)
|
|
1448
1448
|
])),
|
|
1449
|
-
!
|
|
1449
|
+
!m.value && !b.isLast ? (x(), N("span", yt, ",")) : F("", !0)
|
|
1450
1450
|
]),
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
(
|
|
1454
|
-
key:
|
|
1451
|
+
m.value ? (x(), N("div", Et, [
|
|
1452
|
+
E("div", vt, [
|
|
1453
|
+
(x(!0), N(he, null, pe(b.value, (_, v) => (x(), N("div", {
|
|
1454
|
+
key: v,
|
|
1455
1455
|
class: "json-node__child"
|
|
1456
1456
|
}, [
|
|
1457
|
-
|
|
1458
|
-
value:
|
|
1459
|
-
"key-name":
|
|
1460
|
-
level:
|
|
1461
|
-
path:
|
|
1462
|
-
expanded:
|
|
1463
|
-
theme:
|
|
1464
|
-
"onUpdate:value":
|
|
1465
|
-
onToggleExpand:
|
|
1466
|
-
onCopy:
|
|
1467
|
-
"onUpdate:key":
|
|
1468
|
-
"is-last":
|
|
1457
|
+
Ue(p, {
|
|
1458
|
+
value: _,
|
|
1459
|
+
"key-name": f.value ? "" : String(v),
|
|
1460
|
+
level: b.level + 1,
|
|
1461
|
+
path: T(String(v)),
|
|
1462
|
+
expanded: b.expanded,
|
|
1463
|
+
theme: b.theme,
|
|
1464
|
+
"onUpdate:value": d[1] || (d[1] = (w, A) => b.$emit("update:value", w, A)),
|
|
1465
|
+
onToggleExpand: d[2] || (d[2] = (w) => b.$emit("toggle-expand", w)),
|
|
1466
|
+
onCopy: d[3] || (d[3] = (w) => b.$emit("copy", w)),
|
|
1467
|
+
"onUpdate:key": d[4] || (d[4] = (w, A) => b.$emit("update:key", w, A)),
|
|
1468
|
+
"is-last": X(String(v))
|
|
1469
1469
|
}, null, 8, ["value", "key-name", "level", "path", "expanded", "theme", "is-last"])
|
|
1470
1470
|
]))), 128))
|
|
1471
1471
|
]),
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1472
|
+
E("div", _t, [
|
|
1473
|
+
E("span", xt, R(P.value), 1),
|
|
1474
|
+
b.isLast ? F("", !0) : (x(), N("span", Nt, ","))
|
|
1475
1475
|
])
|
|
1476
|
-
])) :
|
|
1477
|
-
])) : (
|
|
1478
|
-
|
|
1476
|
+
])) : F("", !0)
|
|
1477
|
+
])) : (x(), N("div", kt, [
|
|
1478
|
+
b.keyName && !n.value ? (x(), N("span", {
|
|
1479
1479
|
key: 0,
|
|
1480
1480
|
class: "json-node__key",
|
|
1481
|
-
onClick:
|
|
1481
|
+
onClick: Y,
|
|
1482
1482
|
title: "Click to edit key"
|
|
1483
|
-
}, ' "' +
|
|
1484
|
-
|
|
1483
|
+
}, ' "' + R(C.value) + '" ', 1)) : F("", !0),
|
|
1484
|
+
b.keyName && n.value ? ve((x(), N("input", {
|
|
1485
1485
|
key: 1,
|
|
1486
|
-
"onUpdate:modelValue":
|
|
1486
|
+
"onUpdate:modelValue": d[5] || (d[5] = (_) => i.value = _),
|
|
1487
1487
|
onKeyup: [
|
|
1488
|
-
|
|
1489
|
-
|
|
1488
|
+
le(D, ["enter"]),
|
|
1489
|
+
le(ie, ["escape"])
|
|
1490
1490
|
],
|
|
1491
|
-
onBlur:
|
|
1491
|
+
onBlur: D,
|
|
1492
1492
|
class: "json-node__key-input"
|
|
1493
1493
|
}, null, 544)), [
|
|
1494
|
-
[
|
|
1495
|
-
]) :
|
|
1496
|
-
|
|
1497
|
-
|
|
1494
|
+
[_e, i.value]
|
|
1495
|
+
]) : F("", !0),
|
|
1496
|
+
b.keyName ? (x(), N("span", wt, ": ")) : F("", !0),
|
|
1497
|
+
o.value ? F("", !0) : (x(), N("span", {
|
|
1498
1498
|
key: 3,
|
|
1499
|
-
class:
|
|
1500
|
-
onClick:
|
|
1501
|
-
onDblclick:
|
|
1502
|
-
title:
|
|
1499
|
+
class: Oe(["json-node__value", k.value]),
|
|
1500
|
+
onClick: Z,
|
|
1501
|
+
onDblclick: d[6] || (d[6] = (_) => b.$emit("copy", b.value)),
|
|
1502
|
+
title: g.value
|
|
1503
1503
|
}, [
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
], 42,
|
|
1507
|
-
|
|
1504
|
+
Se(R(S.value), 1),
|
|
1505
|
+
b.isLast ? F("", !0) : (x(), N("span", Ct, ","))
|
|
1506
|
+
], 42, At)),
|
|
1507
|
+
o.value ? ve((x(), N("input", {
|
|
1508
1508
|
key: 4,
|
|
1509
|
-
"onUpdate:modelValue":
|
|
1509
|
+
"onUpdate:modelValue": d[7] || (d[7] = (_) => u.value = _),
|
|
1510
1510
|
onKeyup: [
|
|
1511
|
-
|
|
1512
|
-
|
|
1511
|
+
le(J, ["enter"]),
|
|
1512
|
+
le(Ee, ["escape"])
|
|
1513
1513
|
],
|
|
1514
|
-
onBlur:
|
|
1514
|
+
onBlur: J,
|
|
1515
1515
|
class: "json-node__value-input"
|
|
1516
1516
|
}, null, 544)), [
|
|
1517
|
-
[
|
|
1518
|
-
]) :
|
|
1517
|
+
[_e, u.value]
|
|
1518
|
+
]) : F("", !0)
|
|
1519
1519
|
]))
|
|
1520
1520
|
]);
|
|
1521
1521
|
};
|
|
1522
1522
|
}
|
|
1523
|
-
}),
|
|
1523
|
+
}), me = (r, e) => {
|
|
1524
1524
|
const t = r.__vccOpts || r;
|
|
1525
|
-
for (const [
|
|
1526
|
-
t[
|
|
1525
|
+
for (const [s, n] of e)
|
|
1526
|
+
t[s] = n;
|
|
1527
1527
|
return t;
|
|
1528
|
-
},
|
|
1528
|
+
}, Tt = /* @__PURE__ */ me(Ot, [["__scopeId", "data-v-860beb35"]]), He = {
|
|
1529
1529
|
name: "github-light",
|
|
1530
1530
|
colors: {
|
|
1531
1531
|
// 背景色
|
|
@@ -1564,7 +1564,7 @@ const $e = { class: "json-node" }, Ie = {
|
|
|
1564
1564
|
// 缩进线
|
|
1565
1565
|
indentLine: "#d0d7de"
|
|
1566
1566
|
}
|
|
1567
|
-
},
|
|
1567
|
+
}, Pt = {
|
|
1568
1568
|
name: "github-dark",
|
|
1569
1569
|
colors: {
|
|
1570
1570
|
// 背景色
|
|
@@ -1603,7 +1603,7 @@ const $e = { class: "json-node" }, Ie = {
|
|
|
1603
1603
|
// 缩进线
|
|
1604
1604
|
indentLine: "#30363d"
|
|
1605
1605
|
}
|
|
1606
|
-
},
|
|
1606
|
+
}, St = {
|
|
1607
1607
|
name: "min-light",
|
|
1608
1608
|
colors: {
|
|
1609
1609
|
// 背景色 - 纯白简洁
|
|
@@ -1642,7 +1642,7 @@ const $e = { class: "json-node" }, Ie = {
|
|
|
1642
1642
|
// 缩进线
|
|
1643
1643
|
indentLine: "#e5e7eb"
|
|
1644
1644
|
}
|
|
1645
|
-
},
|
|
1645
|
+
}, It = {
|
|
1646
1646
|
name: "slack-ochin",
|
|
1647
1647
|
colors: {
|
|
1648
1648
|
// 背景色 - 温暖的米色调
|
|
@@ -1681,34 +1681,34 @@ const $e = { class: "json-node" }, Ie = {
|
|
|
1681
1681
|
// 缩进线
|
|
1682
1682
|
indentLine: "#e8d5b7"
|
|
1683
1683
|
}
|
|
1684
|
-
},
|
|
1685
|
-
"github-light":
|
|
1686
|
-
"github-dark":
|
|
1687
|
-
"min-light":
|
|
1688
|
-
"slack-ochin":
|
|
1684
|
+
}, $t = {
|
|
1685
|
+
"github-light": He,
|
|
1686
|
+
"github-dark": Pt,
|
|
1687
|
+
"min-light": St,
|
|
1688
|
+
"slack-ochin": It
|
|
1689
1689
|
};
|
|
1690
|
-
function
|
|
1691
|
-
return
|
|
1690
|
+
function Bt(r = "github-light") {
|
|
1691
|
+
return $t[r] || He;
|
|
1692
1692
|
}
|
|
1693
|
-
const
|
|
1693
|
+
const Lt = {
|
|
1694
1694
|
key: 0,
|
|
1695
1695
|
class: "json-format__toolbar"
|
|
1696
|
-
},
|
|
1696
|
+
}, Vt = { class: "json-format__actions" }, Rt = ["disabled"], jt = ["disabled"], Mt = ["disabled"], Ut = ["disabled"], Ft = { class: "json-format__info" }, Xt = {
|
|
1697
1697
|
key: 0,
|
|
1698
1698
|
class: "json-format__status json-format__status--success"
|
|
1699
|
-
},
|
|
1699
|
+
}, Ht = {
|
|
1700
1700
|
key: 1,
|
|
1701
1701
|
class: "json-format__status json-format__status--error"
|
|
1702
|
-
},
|
|
1702
|
+
}, Kt = { class: "json-format__content" }, Yt = {
|
|
1703
1703
|
key: 0,
|
|
1704
1704
|
class: "json-format__error"
|
|
1705
|
-
},
|
|
1705
|
+
}, qt = {
|
|
1706
1706
|
key: 1,
|
|
1707
1707
|
class: "json-format__error"
|
|
1708
|
-
},
|
|
1708
|
+
}, Qt = {
|
|
1709
1709
|
key: 2,
|
|
1710
1710
|
class: "json-format__viewer"
|
|
1711
|
-
},
|
|
1711
|
+
}, Gt = /* @__PURE__ */ be({
|
|
1712
1712
|
name: "JsonFormat",
|
|
1713
1713
|
__name: "index",
|
|
1714
1714
|
props: {
|
|
@@ -1720,330 +1720,2196 @@ const ot = {
|
|
|
1720
1720
|
},
|
|
1721
1721
|
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress"],
|
|
1722
1722
|
setup(r, { expose: e, emit: t }) {
|
|
1723
|
-
|
|
1724
|
-
"50e4672c":
|
|
1725
|
-
"64d14328":
|
|
1726
|
-
"668c94eb":
|
|
1727
|
-
"8370c286":
|
|
1728
|
-
"1698e888":
|
|
1729
|
-
"584924be":
|
|
1730
|
-
"325e00bd":
|
|
1731
|
-
"2430fb1e":
|
|
1732
|
-
ea0e2f1c:
|
|
1733
|
-
"3b0b67ea":
|
|
1734
|
-
"2e7b3e93":
|
|
1735
|
-
b24220f6:
|
|
1736
|
-
"0c7db250":
|
|
1737
|
-
"6a387a0a":
|
|
1738
|
-
"2c13c5fa":
|
|
1739
|
-
"2c1c44e4":
|
|
1740
|
-
"8ba97764":
|
|
1723
|
+
Ce((d) => ({
|
|
1724
|
+
"50e4672c": f.value.colors.border,
|
|
1725
|
+
"64d14328": f.value.colors.background,
|
|
1726
|
+
"668c94eb": f.value.colors.text,
|
|
1727
|
+
"8370c286": f.value.colors.surfaceBackground,
|
|
1728
|
+
"1698e888": f.value.colors.buttonBorder,
|
|
1729
|
+
"584924be": f.value.colors.buttonBackground,
|
|
1730
|
+
"325e00bd": f.value.colors.buttonText,
|
|
1731
|
+
"2430fb1e": f.value.colors.buttonBackgroundHover,
|
|
1732
|
+
ea0e2f1c: f.value.colors.buttonPrimary,
|
|
1733
|
+
"3b0b67ea": f.value.colors.buttonPrimaryHover,
|
|
1734
|
+
"2e7b3e93": f.value.colors.successBackground,
|
|
1735
|
+
b24220f6: f.value.colors.success,
|
|
1736
|
+
"0c7db250": f.value.colors.errorBackground,
|
|
1737
|
+
"6a387a0a": f.value.colors.error,
|
|
1738
|
+
"2c13c5fa": f.value.colors.scrollbarTrack,
|
|
1739
|
+
"2c1c44e4": f.value.colors.scrollbarThumb,
|
|
1740
|
+
"8ba97764": f.value.colors.scrollbarThumbHover
|
|
1741
1741
|
}));
|
|
1742
|
-
const
|
|
1743
|
-
if (!
|
|
1744
|
-
|
|
1742
|
+
const s = r, n = t, o = G(null), i = G(""), u = G(/* @__PURE__ */ new Set()), a = G(null), l = G(""), h = L(() => i.value === ""), f = L(() => Bt(s.theme)), y = L(() => l.value ? null : a.value !== null ? a.value : o.value), m = (d) => {
|
|
1743
|
+
if (!d.trim()) {
|
|
1744
|
+
o.value = null, i.value = "", a.value = null, l.value = "";
|
|
1745
1745
|
return;
|
|
1746
1746
|
}
|
|
1747
1747
|
try {
|
|
1748
|
-
let
|
|
1749
|
-
const
|
|
1750
|
-
if (!
|
|
1748
|
+
let p = d;
|
|
1749
|
+
const _ = /(:\s*|,\s*|\[\s*)-?\d{16,}/.test(p), v = /(:\s*|,\s*|\[\s*)-?\d+\.\d*0+\s*[,}\]\s]*/.test(p);
|
|
1750
|
+
if (!_ && !v)
|
|
1751
1751
|
try {
|
|
1752
|
-
|
|
1753
|
-
|
|
1752
|
+
o.value = JSON.parse(p), i.value = "", a.value = null, l.value = "", ce(() => {
|
|
1753
|
+
y.value !== null && g();
|
|
1754
1754
|
});
|
|
1755
1755
|
return;
|
|
1756
1756
|
} catch {
|
|
1757
1757
|
}
|
|
1758
|
-
|
|
1759
|
-
let
|
|
1760
|
-
for (;
|
|
1761
|
-
const
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
else if (
|
|
1765
|
-
|
|
1758
|
+
p = ((A) => {
|
|
1759
|
+
let B = "", H = !1, K = !1, z = 0;
|
|
1760
|
+
for (; z < A.length; ) {
|
|
1761
|
+
const ae = A[z];
|
|
1762
|
+
if (H)
|
|
1763
|
+
K ? K = !1 : ae === "\\" ? K = !0 : ae === '"' && (H = !1), B += ae, z++;
|
|
1764
|
+
else if (ae === '"')
|
|
1765
|
+
H = !0, B += ae, z++;
|
|
1766
1766
|
else {
|
|
1767
|
-
const
|
|
1768
|
-
let
|
|
1769
|
-
if (
|
|
1770
|
-
|
|
1767
|
+
const Pe = A.slice(z);
|
|
1768
|
+
let W = Pe.match(/^([:,\[\s]*)(-?\d{16,})(\s*[,\}\]\s]|$)/);
|
|
1769
|
+
if (W) {
|
|
1770
|
+
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3], z += W[0].length;
|
|
1771
1771
|
continue;
|
|
1772
1772
|
}
|
|
1773
|
-
if (
|
|
1774
|
-
|
|
1773
|
+
if (W = Pe.match(/^([:,\[\s]*)(-?\d+\.\d*0+)(\s*[,\}\]\s]|$)/), W) {
|
|
1774
|
+
B += W[1] + '{"__protected_number__":"' + W[2] + '"}' + W[3], z += W[0].length;
|
|
1775
1775
|
continue;
|
|
1776
1776
|
}
|
|
1777
|
-
|
|
1777
|
+
B += ae, z++;
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
|
-
return
|
|
1781
|
-
})(
|
|
1782
|
-
|
|
1780
|
+
return B;
|
|
1781
|
+
})(p), o.value = JSON.parse(p), i.value = "", a.value = null, l.value = "", ce(() => {
|
|
1782
|
+
y.value !== null && g();
|
|
1783
1783
|
});
|
|
1784
|
-
} catch (
|
|
1785
|
-
|
|
1784
|
+
} catch (p) {
|
|
1785
|
+
i.value = p instanceof Error ? p.message : "Unknown parsing error", o.value = null, a.value = null, l.value = "";
|
|
1786
1786
|
}
|
|
1787
|
-
},
|
|
1788
|
-
if (!
|
|
1789
|
-
|
|
1787
|
+
}, C = (d) => {
|
|
1788
|
+
if (!d || !d.expression.trim()) {
|
|
1789
|
+
O();
|
|
1790
1790
|
return;
|
|
1791
1791
|
}
|
|
1792
|
-
if (!
|
|
1793
|
-
|
|
1792
|
+
if (!o.value) {
|
|
1793
|
+
l.value = "No valid JSON data to filter";
|
|
1794
1794
|
return;
|
|
1795
1795
|
}
|
|
1796
1796
|
try {
|
|
1797
|
-
let
|
|
1798
|
-
if (
|
|
1799
|
-
|
|
1800
|
-
else if (
|
|
1801
|
-
|
|
1797
|
+
let p;
|
|
1798
|
+
if (d.type === "jsonpath")
|
|
1799
|
+
p = $({ path: d.expression, json: o.value }), p.length === 1 && d.expression.includes("$[") === !1 && !d.expression.endsWith("[*]") ? a.value = p[0] : a.value = p;
|
|
1800
|
+
else if (d.type === "js")
|
|
1801
|
+
p = new Function("data", `
|
|
1802
1802
|
try {
|
|
1803
|
-
return ${
|
|
1803
|
+
return ${d.expression};
|
|
1804
1804
|
} catch (error) {
|
|
1805
1805
|
throw new Error('JavaScript expression error: ' + error.message);
|
|
1806
1806
|
}
|
|
1807
|
-
`)(
|
|
1807
|
+
`)(o.value), a.value = p;
|
|
1808
1808
|
else
|
|
1809
|
-
throw new Error(`Unsupported filter type: ${
|
|
1810
|
-
|
|
1811
|
-
|
|
1809
|
+
throw new Error(`Unsupported filter type: ${d.type}`);
|
|
1810
|
+
l.value = "", ce(() => {
|
|
1811
|
+
g();
|
|
1812
1812
|
});
|
|
1813
|
-
} catch (
|
|
1814
|
-
|
|
1813
|
+
} catch (p) {
|
|
1814
|
+
l.value = p instanceof Error ? p.message : "Filter execution error", a.value = null;
|
|
1815
1815
|
}
|
|
1816
|
-
},
|
|
1817
|
-
|
|
1816
|
+
}, O = () => {
|
|
1817
|
+
a.value = null, l.value = "";
|
|
1818
1818
|
};
|
|
1819
|
-
|
|
1820
|
-
|
|
1819
|
+
Fe(() => s.modelValue, (d) => {
|
|
1820
|
+
m(d);
|
|
1821
1821
|
}, { immediate: !0 });
|
|
1822
|
-
const
|
|
1823
|
-
const
|
|
1824
|
-
if (
|
|
1825
|
-
return
|
|
1826
|
-
if (!Array.isArray(
|
|
1827
|
-
return `__PROTECTED_NUMBER_${
|
|
1828
|
-
if (Array.isArray(
|
|
1829
|
-
return
|
|
1830
|
-
const
|
|
1831
|
-
for (const [
|
|
1832
|
-
|
|
1833
|
-
return
|
|
1834
|
-
},
|
|
1835
|
-
return JSON.stringify(
|
|
1836
|
-
},
|
|
1837
|
-
if (!
|
|
1822
|
+
const P = (d, p, _) => {
|
|
1823
|
+
const v = (B) => {
|
|
1824
|
+
if (B === null || typeof B != "object")
|
|
1825
|
+
return B;
|
|
1826
|
+
if (!Array.isArray(B) && "__protected_number__" in B && Object.keys(B).length === 1)
|
|
1827
|
+
return `__PROTECTED_NUMBER_${B.__protected_number__}_PROTECTED_NUMBER__`;
|
|
1828
|
+
if (Array.isArray(B))
|
|
1829
|
+
return B.map((K) => v(K));
|
|
1830
|
+
const H = {};
|
|
1831
|
+
for (const [K, z] of Object.entries(B))
|
|
1832
|
+
H[K] = v(z);
|
|
1833
|
+
return H;
|
|
1834
|
+
}, w = v(d);
|
|
1835
|
+
return JSON.stringify(w, p, _).replace(/"__PROTECTED_NUMBER_(.+?)_PROTECTED_NUMBER__"/g, "$1");
|
|
1836
|
+
}, M = (d, p) => {
|
|
1837
|
+
if (!s.readonly)
|
|
1838
1838
|
try {
|
|
1839
|
-
const
|
|
1840
|
-
n("update:modelValue",
|
|
1841
|
-
} catch (
|
|
1842
|
-
console.error("Failed to update JSON:",
|
|
1839
|
+
const _ = k(o.value, d, p), v = P(_, null, 2);
|
|
1840
|
+
n("update:modelValue", v);
|
|
1841
|
+
} catch (_) {
|
|
1842
|
+
console.error("Failed to update JSON:", _);
|
|
1843
1843
|
}
|
|
1844
|
-
},
|
|
1845
|
-
if (!
|
|
1846
|
-
const
|
|
1847
|
-
let
|
|
1848
|
-
for (let
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1844
|
+
}, k = (d, p, _) => {
|
|
1845
|
+
if (!p || p === "root") return _;
|
|
1846
|
+
const v = p.split("."), w = J(d, v.slice(0, -1));
|
|
1847
|
+
let A = w;
|
|
1848
|
+
for (let H = 0; H < v.length - 1; H++) {
|
|
1849
|
+
const K = v[H];
|
|
1850
|
+
K !== "root" && (Array.isArray(A) ? A = A[parseInt(K)] : A = A[K]);
|
|
1851
1851
|
}
|
|
1852
|
-
const
|
|
1853
|
-
return
|
|
1854
|
-
},
|
|
1855
|
-
|
|
1856
|
-
},
|
|
1857
|
-
const
|
|
1858
|
-
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
}) : Object.keys(
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1852
|
+
const B = v[v.length - 1];
|
|
1853
|
+
return B === "root" ? _ : (Array.isArray(A) ? A[parseInt(B)] = _ : A[B] = _, w);
|
|
1854
|
+
}, S = (d) => {
|
|
1855
|
+
u.value.has(d) ? u.value.delete(d) : u.value.add(d);
|
|
1856
|
+
}, g = () => {
|
|
1857
|
+
const d = /* @__PURE__ */ new Set(), p = (_, v = "") => {
|
|
1858
|
+
_ !== null && typeof _ == "object" && (d.add(v || "root"), Array.isArray(_) ? _.forEach((w, A) => {
|
|
1859
|
+
const B = v ? `${v}.${A}` : `${A}`;
|
|
1860
|
+
p(w, B);
|
|
1861
|
+
}) : Object.keys(_).forEach((w) => {
|
|
1862
|
+
const A = v ? `${v}.${w}` : w;
|
|
1863
|
+
p(_[w], A);
|
|
1864
1864
|
}));
|
|
1865
1865
|
};
|
|
1866
|
-
|
|
1867
|
-
},
|
|
1868
|
-
|
|
1869
|
-
},
|
|
1870
|
-
if (
|
|
1866
|
+
p(y.value), u.value = d, n("expand-all");
|
|
1867
|
+
}, T = () => {
|
|
1868
|
+
u.value = /* @__PURE__ */ new Set(["root"]), n("collapse-all");
|
|
1869
|
+
}, X = async () => {
|
|
1870
|
+
if (h.value)
|
|
1871
1871
|
try {
|
|
1872
|
-
const
|
|
1873
|
-
await navigator.clipboard.writeText(
|
|
1874
|
-
} catch (
|
|
1875
|
-
console.error("Failed to copy JSON:",
|
|
1872
|
+
const d = y.value, p = P(d, null, 2);
|
|
1873
|
+
await navigator.clipboard.writeText(p), n("copy-success", p);
|
|
1874
|
+
} catch (d) {
|
|
1875
|
+
console.error("Failed to copy JSON:", d), n("copy-error", d instanceof Error ? d : new Error("Failed to copy JSON"));
|
|
1876
1876
|
}
|
|
1877
|
-
},
|
|
1878
|
-
if (
|
|
1877
|
+
}, j = () => {
|
|
1878
|
+
if (h.value)
|
|
1879
1879
|
try {
|
|
1880
|
-
const
|
|
1881
|
-
n("update:modelValue",
|
|
1882
|
-
} catch (
|
|
1883
|
-
console.error("Failed to compress JSON:",
|
|
1880
|
+
const d = y.value, p = P(d);
|
|
1881
|
+
n("update:modelValue", p), n("compress", p);
|
|
1882
|
+
} catch (d) {
|
|
1883
|
+
console.error("Failed to compress JSON:", d);
|
|
1884
1884
|
}
|
|
1885
|
-
},
|
|
1885
|
+
}, Y = async (d) => {
|
|
1886
1886
|
try {
|
|
1887
|
-
let
|
|
1888
|
-
typeof
|
|
1889
|
-
} catch (
|
|
1890
|
-
console.error("Failed to copy value:",
|
|
1887
|
+
let p;
|
|
1888
|
+
typeof d == "object" && d !== null && !Array.isArray(d) && "__protected_number__" in d && Object.keys(d).length === 1 ? p = d.__protected_number__ : typeof d == "string" ? p = `"${d}"` : p = JSON.stringify(d), await navigator.clipboard.writeText(p);
|
|
1889
|
+
} catch (p) {
|
|
1890
|
+
console.error("Failed to copy value:", p);
|
|
1891
1891
|
}
|
|
1892
|
-
},
|
|
1893
|
-
if (!
|
|
1892
|
+
}, Z = (d, p) => {
|
|
1893
|
+
if (!s.readonly)
|
|
1894
1894
|
try {
|
|
1895
|
-
const
|
|
1896
|
-
n("update:modelValue",
|
|
1897
|
-
} catch (
|
|
1898
|
-
console.error("Failed to rename key:",
|
|
1895
|
+
const _ = D(o.value, d, p), v = P(_, null, 2);
|
|
1896
|
+
n("update:modelValue", v), b(d, p);
|
|
1897
|
+
} catch (_) {
|
|
1898
|
+
console.error("Failed to rename key:", _);
|
|
1899
1899
|
}
|
|
1900
|
-
},
|
|
1901
|
-
if (!
|
|
1902
|
-
const
|
|
1903
|
-
if (
|
|
1904
|
-
const
|
|
1905
|
-
return
|
|
1900
|
+
}, D = (d, p, _) => {
|
|
1901
|
+
if (!p || p === "root") return d;
|
|
1902
|
+
const v = p.split("."), w = J(d, v.slice(0, -1));
|
|
1903
|
+
if (v.length === 1) {
|
|
1904
|
+
const H = v[0];
|
|
1905
|
+
return w && typeof w == "object" && !Array.isArray(w) ? ie(w, H, _) : w;
|
|
1906
1906
|
}
|
|
1907
|
-
let
|
|
1908
|
-
for (let
|
|
1909
|
-
const
|
|
1910
|
-
Array.isArray(
|
|
1907
|
+
let A = w;
|
|
1908
|
+
for (let H = 0; H < v.length - 1; H++) {
|
|
1909
|
+
const K = v[H];
|
|
1910
|
+
Array.isArray(A) ? A = A[parseInt(K)] : A = A[K];
|
|
1911
1911
|
}
|
|
1912
|
-
const
|
|
1913
|
-
if (!Array.isArray(
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1912
|
+
const B = v[v.length - 1];
|
|
1913
|
+
if (!Array.isArray(A) && A && typeof A == "object") {
|
|
1914
|
+
const H = ie(A, B, _), K = v.slice(0, -1);
|
|
1915
|
+
K.length > 0 && Ee(w, K, H);
|
|
1916
1916
|
}
|
|
1917
|
-
return
|
|
1918
|
-
},
|
|
1919
|
-
if (
|
|
1920
|
-
if (Array.isArray(
|
|
1921
|
-
const
|
|
1922
|
-
return
|
|
1923
|
-
} else if (
|
|
1924
|
-
const
|
|
1925
|
-
return
|
|
1917
|
+
return w;
|
|
1918
|
+
}, J = (d, p) => {
|
|
1919
|
+
if (p.length === 0) return d;
|
|
1920
|
+
if (Array.isArray(d)) {
|
|
1921
|
+
const _ = [...d], v = p[0], w = parseInt(v);
|
|
1922
|
+
return p.length === 1 || (_[w] = J(d[w], p.slice(1))), _;
|
|
1923
|
+
} else if (d && typeof d == "object") {
|
|
1924
|
+
const _ = { ...d }, v = p[0];
|
|
1925
|
+
return p.length === 1 || (_[v] = J(d[v], p.slice(1))), _;
|
|
1926
1926
|
}
|
|
1927
|
-
return
|
|
1928
|
-
},
|
|
1929
|
-
if (!
|
|
1930
|
-
return
|
|
1931
|
-
const
|
|
1932
|
-
for (const
|
|
1933
|
-
|
|
1934
|
-
return
|
|
1935
|
-
},
|
|
1936
|
-
let
|
|
1937
|
-
for (let
|
|
1938
|
-
const
|
|
1939
|
-
Array.isArray(
|
|
1927
|
+
return d;
|
|
1928
|
+
}, ie = (d, p, _) => {
|
|
1929
|
+
if (!d || typeof d != "object" || Array.isArray(d))
|
|
1930
|
+
return d;
|
|
1931
|
+
const v = Object.keys(d), w = {};
|
|
1932
|
+
for (const A of v)
|
|
1933
|
+
A === p ? w[_] = d[A] : w[A] = d[A];
|
|
1934
|
+
return w;
|
|
1935
|
+
}, Ee = (d, p, _) => {
|
|
1936
|
+
let v = d;
|
|
1937
|
+
for (let A = 0; A < p.length - 1; A++) {
|
|
1938
|
+
const B = p[A];
|
|
1939
|
+
Array.isArray(v) ? v = v[parseInt(B)] : v = v[B];
|
|
1940
1940
|
}
|
|
1941
|
-
const
|
|
1942
|
-
Array.isArray(
|
|
1943
|
-
},
|
|
1944
|
-
const
|
|
1945
|
-
|
|
1946
|
-
if (
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
} else if (
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1941
|
+
const w = p[p.length - 1];
|
|
1942
|
+
Array.isArray(v) ? v[parseInt(w)] = _ : v[w] = _;
|
|
1943
|
+
}, b = (d, p) => {
|
|
1944
|
+
const _ = /* @__PURE__ */ new Set();
|
|
1945
|
+
u.value.forEach((v) => {
|
|
1946
|
+
if (v === d) {
|
|
1947
|
+
const w = d.split(".");
|
|
1948
|
+
w[w.length - 1] = p, _.add(w.join("."));
|
|
1949
|
+
} else if (v.startsWith(d + ".")) {
|
|
1950
|
+
const w = d.split(".");
|
|
1951
|
+
w[w.length - 1] = p;
|
|
1952
|
+
const A = w.join("."), B = v.substring(d.length);
|
|
1953
|
+
_.add(A + B);
|
|
1954
1954
|
} else
|
|
1955
|
-
|
|
1956
|
-
}),
|
|
1955
|
+
_.add(v);
|
|
1956
|
+
}), u.value = _;
|
|
1957
1957
|
};
|
|
1958
1958
|
return e({
|
|
1959
1959
|
// 核心操作方法
|
|
1960
|
-
copyJson:
|
|
1961
|
-
compressSource:
|
|
1962
|
-
expandAll:
|
|
1963
|
-
collapseAll:
|
|
1964
|
-
toggleExpand:
|
|
1965
|
-
updateValue:
|
|
1966
|
-
updateKey:
|
|
1960
|
+
copyJson: X,
|
|
1961
|
+
compressSource: j,
|
|
1962
|
+
expandAll: g,
|
|
1963
|
+
collapseAll: T,
|
|
1964
|
+
toggleExpand: S,
|
|
1965
|
+
updateValue: M,
|
|
1966
|
+
updateKey: Z,
|
|
1967
1967
|
// Filter 相关方法
|
|
1968
|
-
filter:
|
|
1969
|
-
clearFilter:
|
|
1968
|
+
filter: C,
|
|
1969
|
+
clearFilter: O,
|
|
1970
1970
|
// 状态访问方法
|
|
1971
|
-
isValidJson: () =>
|
|
1972
|
-
getParsedJson: () =>
|
|
1973
|
-
getFilteredJson: () =>
|
|
1974
|
-
getExpandedNodes: () =>
|
|
1975
|
-
getParseError: () =>
|
|
1976
|
-
getFilterError: () =>
|
|
1971
|
+
isValidJson: () => h.value,
|
|
1972
|
+
getParsedJson: () => o.value,
|
|
1973
|
+
getFilteredJson: () => a.value,
|
|
1974
|
+
getExpandedNodes: () => u.value,
|
|
1975
|
+
getParseError: () => i.value,
|
|
1976
|
+
getFilterError: () => l.value,
|
|
1977
1977
|
// 工具方法
|
|
1978
|
-
parseJson: (
|
|
1979
|
-
copyValue: (
|
|
1980
|
-
}), (
|
|
1981
|
-
class:
|
|
1978
|
+
parseJson: (d) => m(d),
|
|
1979
|
+
copyValue: (d) => Y(d)
|
|
1980
|
+
}), (d, p) => (x(), N("div", {
|
|
1981
|
+
class: Oe(["json-format", `json-format--${f.value.name}`])
|
|
1982
1982
|
}, [
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1983
|
+
d.showToolbar ? (x(), N("div", Lt, [
|
|
1984
|
+
E("div", Vt, [
|
|
1985
|
+
E("button", {
|
|
1986
1986
|
class: "json-format__btn json-format__btn--primary",
|
|
1987
|
-
onClick:
|
|
1988
|
-
disabled: !
|
|
1987
|
+
onClick: X,
|
|
1988
|
+
disabled: !h.value,
|
|
1989
1989
|
title: "Copy JSON"
|
|
1990
|
-
}, " 📋 Copy ", 8,
|
|
1991
|
-
|
|
1990
|
+
}, " 📋 Copy ", 8, Rt),
|
|
1991
|
+
E("button", {
|
|
1992
1992
|
class: "json-format__btn json-format__btn--secondary",
|
|
1993
|
-
onClick:
|
|
1994
|
-
disabled: !
|
|
1993
|
+
onClick: g,
|
|
1994
|
+
disabled: !h.value,
|
|
1995
1995
|
title: "Expand All"
|
|
1996
|
-
}, " ⬇️ Expand All ", 8,
|
|
1997
|
-
|
|
1996
|
+
}, " ⬇️ Expand All ", 8, jt),
|
|
1997
|
+
E("button", {
|
|
1998
1998
|
class: "json-format__btn json-format__btn--secondary",
|
|
1999
|
-
onClick:
|
|
2000
|
-
disabled: !
|
|
1999
|
+
onClick: T,
|
|
2000
|
+
disabled: !h.value,
|
|
2001
2001
|
title: "Collapse All"
|
|
2002
|
-
}, " ➡️ Collapse All ", 8,
|
|
2003
|
-
|
|
2002
|
+
}, " ➡️ Collapse All ", 8, Mt),
|
|
2003
|
+
E("button", {
|
|
2004
2004
|
class: "json-format__btn json-format__btn--secondary",
|
|
2005
|
-
onClick:
|
|
2006
|
-
disabled: !
|
|
2005
|
+
onClick: j,
|
|
2006
|
+
disabled: !h.value,
|
|
2007
2007
|
title: "Compress JSON"
|
|
2008
|
-
}, " 📦 Compress ", 8,
|
|
2008
|
+
}, " 📦 Compress ", 8, Ut)
|
|
2009
2009
|
]),
|
|
2010
|
-
|
|
2011
|
-
|
|
2010
|
+
E("div", Ft, [
|
|
2011
|
+
h.value ? (x(), N("span", Xt, " ✅ Valid JSON ")) : (x(), N("span", Ht, " ❌ Invalid JSON "))
|
|
2012
2012
|
])
|
|
2013
|
-
])) :
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
])) : (
|
|
2019
|
-
|
|
2020
|
-
value:
|
|
2013
|
+
])) : F("", !0),
|
|
2014
|
+
E("div", Kt, [
|
|
2015
|
+
h.value ? l.value ? (x(), N("div", qt, [
|
|
2016
|
+
p[1] || (p[1] = E("h4", null, "Filter Error:", -1)),
|
|
2017
|
+
E("pre", null, R(l.value), 1)
|
|
2018
|
+
])) : (x(), N("div", Qt, [
|
|
2019
|
+
Ue(Tt, {
|
|
2020
|
+
value: y.value,
|
|
2021
2021
|
"key-name": "",
|
|
2022
2022
|
level: 0,
|
|
2023
|
-
expanded:
|
|
2023
|
+
expanded: u.value,
|
|
2024
2024
|
"is-last": !0,
|
|
2025
|
-
theme:
|
|
2026
|
-
"onUpdate:value":
|
|
2027
|
-
onToggleExpand:
|
|
2028
|
-
onCopy:
|
|
2029
|
-
"onUpdate:key":
|
|
2025
|
+
theme: f.value,
|
|
2026
|
+
"onUpdate:value": M,
|
|
2027
|
+
onToggleExpand: S,
|
|
2028
|
+
onCopy: Y,
|
|
2029
|
+
"onUpdate:key": Z
|
|
2030
2030
|
}, null, 8, ["value", "expanded", "theme"])
|
|
2031
|
-
])) : (
|
|
2032
|
-
|
|
2033
|
-
|
|
2031
|
+
])) : (x(), N("div", Yt, [
|
|
2032
|
+
p[0] || (p[0] = E("h4", null, "JSON Parse Error:", -1)),
|
|
2033
|
+
E("pre", null, R(i.value), 1)
|
|
2034
|
+
]))
|
|
2035
|
+
])
|
|
2036
|
+
], 2));
|
|
2037
|
+
}
|
|
2038
|
+
}), Wt = /* @__PURE__ */ me(Gt, [["__scopeId", "data-v-7a477244"]]), Ke = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", Zt = Ke + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", zt = "[" + Ke + "][" + Zt + "]*", Dt = new RegExp("^" + zt + "$");
|
|
2039
|
+
function Ye(r, e) {
|
|
2040
|
+
const t = [];
|
|
2041
|
+
let s = e.exec(r);
|
|
2042
|
+
for (; s; ) {
|
|
2043
|
+
const n = [];
|
|
2044
|
+
n.startIndex = e.lastIndex - s[0].length;
|
|
2045
|
+
const o = s.length;
|
|
2046
|
+
for (let i = 0; i < o; i++)
|
|
2047
|
+
n.push(s[i]);
|
|
2048
|
+
t.push(n), s = e.exec(r);
|
|
2049
|
+
}
|
|
2050
|
+
return t;
|
|
2051
|
+
}
|
|
2052
|
+
const ye = function(r) {
|
|
2053
|
+
const e = Dt.exec(r);
|
|
2054
|
+
return !(e === null || typeof e > "u");
|
|
2055
|
+
};
|
|
2056
|
+
function Jt(r) {
|
|
2057
|
+
return typeof r < "u";
|
|
2058
|
+
}
|
|
2059
|
+
const er = {
|
|
2060
|
+
allowBooleanAttributes: !1,
|
|
2061
|
+
//A tag can have attributes without any value
|
|
2062
|
+
unpairedTags: []
|
|
2063
|
+
};
|
|
2064
|
+
function qe(r, e) {
|
|
2065
|
+
e = Object.assign({}, er, e);
|
|
2066
|
+
const t = [];
|
|
2067
|
+
let s = !1, n = !1;
|
|
2068
|
+
r[0] === "\uFEFF" && (r = r.substr(1));
|
|
2069
|
+
for (let o = 0; o < r.length; o++)
|
|
2070
|
+
if (r[o] === "<" && r[o + 1] === "?") {
|
|
2071
|
+
if (o += 2, o = Be(r, o), o.err) return o;
|
|
2072
|
+
} else if (r[o] === "<") {
|
|
2073
|
+
let i = o;
|
|
2074
|
+
if (o++, r[o] === "!") {
|
|
2075
|
+
o = Le(r, o);
|
|
2076
|
+
continue;
|
|
2077
|
+
} else {
|
|
2078
|
+
let u = !1;
|
|
2079
|
+
r[o] === "/" && (u = !0, o++);
|
|
2080
|
+
let a = "";
|
|
2081
|
+
for (; o < r.length && r[o] !== ">" && r[o] !== " " && r[o] !== " " && r[o] !== `
|
|
2082
|
+
` && r[o] !== "\r"; o++)
|
|
2083
|
+
a += r[o];
|
|
2084
|
+
if (a = a.trim(), a[a.length - 1] === "/" && (a = a.substring(0, a.length - 1), o--), !lr(a)) {
|
|
2085
|
+
let f;
|
|
2086
|
+
return a.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + a + "' is an invalid name.", U("InvalidTag", f, q(r, o));
|
|
2087
|
+
}
|
|
2088
|
+
const l = nr(r, o);
|
|
2089
|
+
if (l === !1)
|
|
2090
|
+
return U("InvalidAttr", "Attributes for '" + a + "' have open quote.", q(r, o));
|
|
2091
|
+
let h = l.value;
|
|
2092
|
+
if (o = l.index, h[h.length - 1] === "/") {
|
|
2093
|
+
const f = o - h.length;
|
|
2094
|
+
h = h.substring(0, h.length - 1);
|
|
2095
|
+
const y = Ve(h, e);
|
|
2096
|
+
if (y === !0)
|
|
2097
|
+
s = !0;
|
|
2098
|
+
else
|
|
2099
|
+
return U(y.err.code, y.err.msg, q(r, f + y.err.line));
|
|
2100
|
+
} else if (u)
|
|
2101
|
+
if (l.tagClosed) {
|
|
2102
|
+
if (h.trim().length > 0)
|
|
2103
|
+
return U("InvalidTag", "Closing tag '" + a + "' can't have attributes or invalid starting.", q(r, i));
|
|
2104
|
+
if (t.length === 0)
|
|
2105
|
+
return U("InvalidTag", "Closing tag '" + a + "' has not been opened.", q(r, i));
|
|
2106
|
+
{
|
|
2107
|
+
const f = t.pop();
|
|
2108
|
+
if (a !== f.tagName) {
|
|
2109
|
+
let y = q(r, f.tagStartPos);
|
|
2110
|
+
return U(
|
|
2111
|
+
"InvalidTag",
|
|
2112
|
+
"Expected closing tag '" + f.tagName + "' (opened in line " + y.line + ", col " + y.col + ") instead of closing tag '" + a + "'.",
|
|
2113
|
+
q(r, i)
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
t.length == 0 && (n = !0);
|
|
2117
|
+
}
|
|
2118
|
+
} else return U("InvalidTag", "Closing tag '" + a + "' doesn't have proper closing.", q(r, o));
|
|
2119
|
+
else {
|
|
2120
|
+
const f = Ve(h, e);
|
|
2121
|
+
if (f !== !0)
|
|
2122
|
+
return U(f.err.code, f.err.msg, q(r, o - h.length + f.err.line));
|
|
2123
|
+
if (n === !0)
|
|
2124
|
+
return U("InvalidXml", "Multiple possible root nodes found.", q(r, o));
|
|
2125
|
+
e.unpairedTags.indexOf(a) !== -1 || t.push({ tagName: a, tagStartPos: i }), s = !0;
|
|
2126
|
+
}
|
|
2127
|
+
for (o++; o < r.length; o++)
|
|
2128
|
+
if (r[o] === "<")
|
|
2129
|
+
if (r[o + 1] === "!") {
|
|
2130
|
+
o++, o = Le(r, o);
|
|
2131
|
+
continue;
|
|
2132
|
+
} else if (r[o + 1] === "?") {
|
|
2133
|
+
if (o = Be(r, ++o), o.err) return o;
|
|
2134
|
+
} else
|
|
2135
|
+
break;
|
|
2136
|
+
else if (r[o] === "&") {
|
|
2137
|
+
const f = ir(r, o);
|
|
2138
|
+
if (f == -1)
|
|
2139
|
+
return U("InvalidChar", "char '&' is not expected.", q(r, o));
|
|
2140
|
+
o = f;
|
|
2141
|
+
} else if (n === !0 && !$e(r[o]))
|
|
2142
|
+
return U("InvalidXml", "Extra text at the end", q(r, o));
|
|
2143
|
+
r[o] === "<" && o--;
|
|
2144
|
+
}
|
|
2145
|
+
} else {
|
|
2146
|
+
if ($e(r[o]))
|
|
2147
|
+
continue;
|
|
2148
|
+
return U("InvalidChar", "char '" + r[o] + "' is not expected.", q(r, o));
|
|
2149
|
+
}
|
|
2150
|
+
if (s) {
|
|
2151
|
+
if (t.length == 1)
|
|
2152
|
+
return U("InvalidTag", "Unclosed tag '" + t[0].tagName + "'.", q(r, t[0].tagStartPos));
|
|
2153
|
+
if (t.length > 0)
|
|
2154
|
+
return U("InvalidXml", "Invalid '" + JSON.stringify(t.map((o) => o.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
2155
|
+
} else return U("InvalidXml", "Start tag expected.", 1);
|
|
2156
|
+
return !0;
|
|
2157
|
+
}
|
|
2158
|
+
function $e(r) {
|
|
2159
|
+
return r === " " || r === " " || r === `
|
|
2160
|
+
` || r === "\r";
|
|
2161
|
+
}
|
|
2162
|
+
function Be(r, e) {
|
|
2163
|
+
const t = e;
|
|
2164
|
+
for (; e < r.length; e++)
|
|
2165
|
+
if (r[e] == "?" || r[e] == " ") {
|
|
2166
|
+
const s = r.substr(t, e - t);
|
|
2167
|
+
if (e > 5 && s === "xml")
|
|
2168
|
+
return U("InvalidXml", "XML declaration allowed only at the start of the document.", q(r, e));
|
|
2169
|
+
if (r[e] == "?" && r[e + 1] == ">") {
|
|
2170
|
+
e++;
|
|
2171
|
+
break;
|
|
2172
|
+
} else
|
|
2173
|
+
continue;
|
|
2174
|
+
}
|
|
2175
|
+
return e;
|
|
2176
|
+
}
|
|
2177
|
+
function Le(r, e) {
|
|
2178
|
+
if (r.length > e + 5 && r[e + 1] === "-" && r[e + 2] === "-") {
|
|
2179
|
+
for (e += 3; e < r.length; e++)
|
|
2180
|
+
if (r[e] === "-" && r[e + 1] === "-" && r[e + 2] === ">") {
|
|
2181
|
+
e += 2;
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2184
|
+
} else if (r.length > e + 8 && r[e + 1] === "D" && r[e + 2] === "O" && r[e + 3] === "C" && r[e + 4] === "T" && r[e + 5] === "Y" && r[e + 6] === "P" && r[e + 7] === "E") {
|
|
2185
|
+
let t = 1;
|
|
2186
|
+
for (e += 8; e < r.length; e++)
|
|
2187
|
+
if (r[e] === "<")
|
|
2188
|
+
t++;
|
|
2189
|
+
else if (r[e] === ">" && (t--, t === 0))
|
|
2190
|
+
break;
|
|
2191
|
+
} else if (r.length > e + 9 && r[e + 1] === "[" && r[e + 2] === "C" && r[e + 3] === "D" && r[e + 4] === "A" && r[e + 5] === "T" && r[e + 6] === "A" && r[e + 7] === "[") {
|
|
2192
|
+
for (e += 8; e < r.length; e++)
|
|
2193
|
+
if (r[e] === "]" && r[e + 1] === "]" && r[e + 2] === ">") {
|
|
2194
|
+
e += 2;
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
return e;
|
|
2199
|
+
}
|
|
2200
|
+
const tr = '"', rr = "'";
|
|
2201
|
+
function nr(r, e) {
|
|
2202
|
+
let t = "", s = "", n = !1;
|
|
2203
|
+
for (; e < r.length; e++) {
|
|
2204
|
+
if (r[e] === tr || r[e] === rr)
|
|
2205
|
+
s === "" ? s = r[e] : s !== r[e] || (s = "");
|
|
2206
|
+
else if (r[e] === ">" && s === "") {
|
|
2207
|
+
n = !0;
|
|
2208
|
+
break;
|
|
2209
|
+
}
|
|
2210
|
+
t += r[e];
|
|
2211
|
+
}
|
|
2212
|
+
return s !== "" ? !1 : {
|
|
2213
|
+
value: t,
|
|
2214
|
+
index: e,
|
|
2215
|
+
tagClosed: n
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
const sr = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
2219
|
+
function Ve(r, e) {
|
|
2220
|
+
const t = Ye(r, sr), s = {};
|
|
2221
|
+
for (let n = 0; n < t.length; n++) {
|
|
2222
|
+
if (t[n][1].length === 0)
|
|
2223
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' has no space in starting.", de(t[n]));
|
|
2224
|
+
if (t[n][3] !== void 0 && t[n][4] === void 0)
|
|
2225
|
+
return U("InvalidAttr", "Attribute '" + t[n][2] + "' is without value.", de(t[n]));
|
|
2226
|
+
if (t[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
2227
|
+
return U("InvalidAttr", "boolean attribute '" + t[n][2] + "' is not allowed.", de(t[n]));
|
|
2228
|
+
const o = t[n][2];
|
|
2229
|
+
if (!ar(o))
|
|
2230
|
+
return U("InvalidAttr", "Attribute '" + o + "' is an invalid name.", de(t[n]));
|
|
2231
|
+
if (!s.hasOwnProperty(o))
|
|
2232
|
+
s[o] = 1;
|
|
2233
|
+
else
|
|
2234
|
+
return U("InvalidAttr", "Attribute '" + o + "' is repeated.", de(t[n]));
|
|
2235
|
+
}
|
|
2236
|
+
return !0;
|
|
2237
|
+
}
|
|
2238
|
+
function or(r, e) {
|
|
2239
|
+
let t = /\d/;
|
|
2240
|
+
for (r[e] === "x" && (e++, t = /[\da-fA-F]/); e < r.length; e++) {
|
|
2241
|
+
if (r[e] === ";")
|
|
2242
|
+
return e;
|
|
2243
|
+
if (!r[e].match(t))
|
|
2244
|
+
break;
|
|
2245
|
+
}
|
|
2246
|
+
return -1;
|
|
2247
|
+
}
|
|
2248
|
+
function ir(r, e) {
|
|
2249
|
+
if (e++, r[e] === ";")
|
|
2250
|
+
return -1;
|
|
2251
|
+
if (r[e] === "#")
|
|
2252
|
+
return e++, or(r, e);
|
|
2253
|
+
let t = 0;
|
|
2254
|
+
for (; e < r.length; e++, t++)
|
|
2255
|
+
if (!(r[e].match(/\w/) && t < 20)) {
|
|
2256
|
+
if (r[e] === ";")
|
|
2257
|
+
break;
|
|
2258
|
+
return -1;
|
|
2259
|
+
}
|
|
2260
|
+
return e;
|
|
2261
|
+
}
|
|
2262
|
+
function U(r, e, t) {
|
|
2263
|
+
return {
|
|
2264
|
+
err: {
|
|
2265
|
+
code: r,
|
|
2266
|
+
msg: e,
|
|
2267
|
+
line: t.line || t,
|
|
2268
|
+
col: t.col
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
function ar(r) {
|
|
2273
|
+
return ye(r);
|
|
2274
|
+
}
|
|
2275
|
+
function lr(r) {
|
|
2276
|
+
return ye(r);
|
|
2277
|
+
}
|
|
2278
|
+
function q(r, e) {
|
|
2279
|
+
const t = r.substring(0, e).split(/\r?\n/);
|
|
2280
|
+
return {
|
|
2281
|
+
line: t.length,
|
|
2282
|
+
// column number is last line's length + 1, because column numbering starts at 1:
|
|
2283
|
+
col: t[t.length - 1].length + 1
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
function de(r) {
|
|
2287
|
+
return r.startIndex + r[1].length;
|
|
2288
|
+
}
|
|
2289
|
+
const ur = {
|
|
2290
|
+
preserveOrder: !1,
|
|
2291
|
+
attributeNamePrefix: "@_",
|
|
2292
|
+
attributesGroupName: !1,
|
|
2293
|
+
textNodeName: "#text",
|
|
2294
|
+
ignoreAttributes: !0,
|
|
2295
|
+
removeNSPrefix: !1,
|
|
2296
|
+
// remove NS from tag name or attribute name if true
|
|
2297
|
+
allowBooleanAttributes: !1,
|
|
2298
|
+
//a tag can have attributes without any value
|
|
2299
|
+
//ignoreRootElement : false,
|
|
2300
|
+
parseTagValue: !0,
|
|
2301
|
+
parseAttributeValue: !1,
|
|
2302
|
+
trimValues: !0,
|
|
2303
|
+
//Trim string values of tag and attributes
|
|
2304
|
+
cdataPropName: !1,
|
|
2305
|
+
numberParseOptions: {
|
|
2306
|
+
hex: !0,
|
|
2307
|
+
leadingZeros: !0,
|
|
2308
|
+
eNotation: !0
|
|
2309
|
+
},
|
|
2310
|
+
tagValueProcessor: function(r, e) {
|
|
2311
|
+
return e;
|
|
2312
|
+
},
|
|
2313
|
+
attributeValueProcessor: function(r, e) {
|
|
2314
|
+
return e;
|
|
2315
|
+
},
|
|
2316
|
+
stopNodes: [],
|
|
2317
|
+
//nested tags will not be parsed even for errors
|
|
2318
|
+
alwaysCreateTextNode: !1,
|
|
2319
|
+
isArray: () => !1,
|
|
2320
|
+
commentPropName: !1,
|
|
2321
|
+
unpairedTags: [],
|
|
2322
|
+
processEntities: !0,
|
|
2323
|
+
htmlEntities: !1,
|
|
2324
|
+
ignoreDeclaration: !1,
|
|
2325
|
+
ignorePiTags: !1,
|
|
2326
|
+
transformTagName: !1,
|
|
2327
|
+
transformAttributeName: !1,
|
|
2328
|
+
updateTag: function(r, e, t) {
|
|
2329
|
+
return r;
|
|
2330
|
+
},
|
|
2331
|
+
// skipEmptyListItem: false
|
|
2332
|
+
captureMetaData: !1
|
|
2333
|
+
}, cr = function(r) {
|
|
2334
|
+
return Object.assign({}, ur, r);
|
|
2335
|
+
};
|
|
2336
|
+
let ge;
|
|
2337
|
+
typeof Symbol != "function" ? ge = "@@xmlMetadata" : ge = Symbol("XML Node Metadata");
|
|
2338
|
+
let se = class {
|
|
2339
|
+
constructor(e) {
|
|
2340
|
+
this.tagname = e, this.child = [], this[":@"] = {};
|
|
2341
|
+
}
|
|
2342
|
+
add(e, t) {
|
|
2343
|
+
e === "__proto__" && (e = "#__proto__"), this.child.push({ [e]: t });
|
|
2344
|
+
}
|
|
2345
|
+
addChild(e, t) {
|
|
2346
|
+
e.tagname === "__proto__" && (e.tagname = "#__proto__"), e[":@"] && Object.keys(e[":@"]).length > 0 ? this.child.push({ [e.tagname]: e.child, ":@": e[":@"] }) : this.child.push({ [e.tagname]: e.child }), t !== void 0 && (this.child[this.child.length - 1][ge] = { startIndex: t });
|
|
2347
|
+
}
|
|
2348
|
+
/** symbol used for metadata */
|
|
2349
|
+
static getMetaDataSymbol() {
|
|
2350
|
+
return ge;
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
class dr {
|
|
2354
|
+
constructor(e) {
|
|
2355
|
+
this.suppressValidationErr = !e;
|
|
2356
|
+
}
|
|
2357
|
+
readDocType(e, t) {
|
|
2358
|
+
const s = {};
|
|
2359
|
+
if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
|
|
2360
|
+
t = t + 9;
|
|
2361
|
+
let n = 1, o = !1, i = !1, u = "";
|
|
2362
|
+
for (; t < e.length; t++)
|
|
2363
|
+
if (e[t] === "<" && !i) {
|
|
2364
|
+
if (o && ne(e, "!ENTITY", t)) {
|
|
2365
|
+
t += 7;
|
|
2366
|
+
let a, l;
|
|
2367
|
+
[a, l, t] = this.readEntityExp(e, t + 1, this.suppressValidationErr), l.indexOf("&") === -1 && (s[a] = {
|
|
2368
|
+
regx: RegExp(`&${a};`, "g"),
|
|
2369
|
+
val: l
|
|
2370
|
+
});
|
|
2371
|
+
} else if (o && ne(e, "!ELEMENT", t)) {
|
|
2372
|
+
t += 8;
|
|
2373
|
+
const { index: a } = this.readElementExp(e, t + 1);
|
|
2374
|
+
t = a;
|
|
2375
|
+
} else if (o && ne(e, "!ATTLIST", t))
|
|
2376
|
+
t += 8;
|
|
2377
|
+
else if (o && ne(e, "!NOTATION", t)) {
|
|
2378
|
+
t += 9;
|
|
2379
|
+
const { index: a } = this.readNotationExp(e, t + 1, this.suppressValidationErr);
|
|
2380
|
+
t = a;
|
|
2381
|
+
} else if (ne(e, "!--", t)) i = !0;
|
|
2382
|
+
else throw new Error("Invalid DOCTYPE");
|
|
2383
|
+
n++, u = "";
|
|
2384
|
+
} else if (e[t] === ">") {
|
|
2385
|
+
if (i ? e[t - 1] === "-" && e[t - 2] === "-" && (i = !1, n--) : n--, n === 0)
|
|
2386
|
+
break;
|
|
2387
|
+
} else e[t] === "[" ? o = !0 : u += e[t];
|
|
2388
|
+
if (n !== 0)
|
|
2389
|
+
throw new Error("Unclosed DOCTYPE");
|
|
2390
|
+
} else
|
|
2391
|
+
throw new Error("Invalid Tag instead of DOCTYPE");
|
|
2392
|
+
return { entities: s, i: t };
|
|
2393
|
+
}
|
|
2394
|
+
readEntityExp(e, t) {
|
|
2395
|
+
t = Q(e, t);
|
|
2396
|
+
let s = "";
|
|
2397
|
+
for (; t < e.length && !/\s/.test(e[t]) && e[t] !== '"' && e[t] !== "'"; )
|
|
2398
|
+
s += e[t], t++;
|
|
2399
|
+
if (fe(s), t = Q(e, t), !this.suppressValidationErr) {
|
|
2400
|
+
if (e.substring(t, t + 6).toUpperCase() === "SYSTEM")
|
|
2401
|
+
throw new Error("External entities are not supported");
|
|
2402
|
+
if (e[t] === "%")
|
|
2403
|
+
throw new Error("Parameter entities are not supported");
|
|
2404
|
+
}
|
|
2405
|
+
let n = "";
|
|
2406
|
+
return [t, n] = this.readIdentifierVal(e, t, "entity"), t--, [s, n, t];
|
|
2407
|
+
}
|
|
2408
|
+
readNotationExp(e, t) {
|
|
2409
|
+
t = Q(e, t);
|
|
2410
|
+
let s = "";
|
|
2411
|
+
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2412
|
+
s += e[t], t++;
|
|
2413
|
+
!this.suppressValidationErr && fe(s), t = Q(e, t);
|
|
2414
|
+
const n = e.substring(t, t + 6).toUpperCase();
|
|
2415
|
+
if (!this.suppressValidationErr && n !== "SYSTEM" && n !== "PUBLIC")
|
|
2416
|
+
throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);
|
|
2417
|
+
t += n.length, t = Q(e, t);
|
|
2418
|
+
let o = null, i = null;
|
|
2419
|
+
if (n === "PUBLIC")
|
|
2420
|
+
[t, o] = this.readIdentifierVal(e, t, "publicIdentifier"), t = Q(e, t), (e[t] === '"' || e[t] === "'") && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"));
|
|
2421
|
+
else if (n === "SYSTEM" && ([t, i] = this.readIdentifierVal(e, t, "systemIdentifier"), !this.suppressValidationErr && !i))
|
|
2422
|
+
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
2423
|
+
return { notationName: s, publicIdentifier: o, systemIdentifier: i, index: --t };
|
|
2424
|
+
}
|
|
2425
|
+
readIdentifierVal(e, t, s) {
|
|
2426
|
+
let n = "";
|
|
2427
|
+
const o = e[t];
|
|
2428
|
+
if (o !== '"' && o !== "'")
|
|
2429
|
+
throw new Error(`Expected quoted string, found "${o}"`);
|
|
2430
|
+
for (t++; t < e.length && e[t] !== o; )
|
|
2431
|
+
n += e[t], t++;
|
|
2432
|
+
if (e[t] !== o)
|
|
2433
|
+
throw new Error(`Unterminated ${s} value`);
|
|
2434
|
+
return t++, [t, n];
|
|
2435
|
+
}
|
|
2436
|
+
readElementExp(e, t) {
|
|
2437
|
+
t = Q(e, t);
|
|
2438
|
+
let s = "";
|
|
2439
|
+
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2440
|
+
s += e[t], t++;
|
|
2441
|
+
if (!this.suppressValidationErr && !ye(s))
|
|
2442
|
+
throw new Error(`Invalid element name: "${s}"`);
|
|
2443
|
+
t = Q(e, t);
|
|
2444
|
+
let n = "";
|
|
2445
|
+
if (e[t] === "E" && ne(e, "MPTY", t)) t += 4;
|
|
2446
|
+
else if (e[t] === "A" && ne(e, "NY", t)) t += 2;
|
|
2447
|
+
else if (e[t] === "(") {
|
|
2448
|
+
for (t++; t < e.length && e[t] !== ")"; )
|
|
2449
|
+
n += e[t], t++;
|
|
2450
|
+
if (e[t] !== ")")
|
|
2451
|
+
throw new Error("Unterminated content model");
|
|
2452
|
+
} else if (!this.suppressValidationErr)
|
|
2453
|
+
throw new Error(`Invalid Element Expression, found "${e[t]}"`);
|
|
2454
|
+
return {
|
|
2455
|
+
elementName: s,
|
|
2456
|
+
contentModel: n.trim(),
|
|
2457
|
+
index: t
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
readAttlistExp(e, t) {
|
|
2461
|
+
t = Q(e, t);
|
|
2462
|
+
let s = "";
|
|
2463
|
+
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2464
|
+
s += e[t], t++;
|
|
2465
|
+
fe(s), t = Q(e, t);
|
|
2466
|
+
let n = "";
|
|
2467
|
+
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2468
|
+
n += e[t], t++;
|
|
2469
|
+
if (!fe(n))
|
|
2470
|
+
throw new Error(`Invalid attribute name: "${n}"`);
|
|
2471
|
+
t = Q(e, t);
|
|
2472
|
+
let o = "";
|
|
2473
|
+
if (e.substring(t, t + 8).toUpperCase() === "NOTATION") {
|
|
2474
|
+
if (o = "NOTATION", t += 8, t = Q(e, t), e[t] !== "(")
|
|
2475
|
+
throw new Error(`Expected '(', found "${e[t]}"`);
|
|
2476
|
+
t++;
|
|
2477
|
+
let u = [];
|
|
2478
|
+
for (; t < e.length && e[t] !== ")"; ) {
|
|
2479
|
+
let a = "";
|
|
2480
|
+
for (; t < e.length && e[t] !== "|" && e[t] !== ")"; )
|
|
2481
|
+
a += e[t], t++;
|
|
2482
|
+
if (a = a.trim(), !fe(a))
|
|
2483
|
+
throw new Error(`Invalid notation name: "${a}"`);
|
|
2484
|
+
u.push(a), e[t] === "|" && (t++, t = Q(e, t));
|
|
2485
|
+
}
|
|
2486
|
+
if (e[t] !== ")")
|
|
2487
|
+
throw new Error("Unterminated list of notations");
|
|
2488
|
+
t++, o += " (" + u.join("|") + ")";
|
|
2489
|
+
} else {
|
|
2490
|
+
for (; t < e.length && !/\s/.test(e[t]); )
|
|
2491
|
+
o += e[t], t++;
|
|
2492
|
+
const u = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
2493
|
+
if (!this.suppressValidationErr && !u.includes(o.toUpperCase()))
|
|
2494
|
+
throw new Error(`Invalid attribute type: "${o}"`);
|
|
2495
|
+
}
|
|
2496
|
+
t = Q(e, t);
|
|
2497
|
+
let i = "";
|
|
2498
|
+
return e.substring(t, t + 8).toUpperCase() === "#REQUIRED" ? (i = "#REQUIRED", t += 8) : e.substring(t, t + 7).toUpperCase() === "#IMPLIED" ? (i = "#IMPLIED", t += 7) : [t, i] = this.readIdentifierVal(e, t, "ATTLIST"), {
|
|
2499
|
+
elementName: s,
|
|
2500
|
+
attributeName: n,
|
|
2501
|
+
attributeType: o,
|
|
2502
|
+
defaultValue: i,
|
|
2503
|
+
index: t
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
const Q = (r, e) => {
|
|
2508
|
+
for (; e < r.length && /\s/.test(r[e]); )
|
|
2509
|
+
e++;
|
|
2510
|
+
return e;
|
|
2511
|
+
};
|
|
2512
|
+
function ne(r, e, t) {
|
|
2513
|
+
for (let s = 0; s < e.length; s++)
|
|
2514
|
+
if (e[s] !== r[t + s + 1]) return !1;
|
|
2515
|
+
return !0;
|
|
2516
|
+
}
|
|
2517
|
+
function fe(r) {
|
|
2518
|
+
if (ye(r))
|
|
2519
|
+
return r;
|
|
2520
|
+
throw new Error(`Invalid entity name ${r}`);
|
|
2521
|
+
}
|
|
2522
|
+
const fr = /^[-+]?0x[a-fA-F0-9]+$/, hr = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, pr = {
|
|
2523
|
+
hex: !0,
|
|
2524
|
+
// oct: false,
|
|
2525
|
+
leadingZeros: !0,
|
|
2526
|
+
decimalPoint: ".",
|
|
2527
|
+
eNotation: !0
|
|
2528
|
+
//skipLike: /regex/
|
|
2529
|
+
};
|
|
2530
|
+
function gr(r, e = {}) {
|
|
2531
|
+
if (e = Object.assign({}, pr, e), !r || typeof r != "string") return r;
|
|
2532
|
+
let t = r.trim();
|
|
2533
|
+
if (e.skipLike !== void 0 && e.skipLike.test(t)) return r;
|
|
2534
|
+
if (r === "0") return 0;
|
|
2535
|
+
if (e.hex && fr.test(t))
|
|
2536
|
+
return Er(t, 16);
|
|
2537
|
+
if (t.search(/.+[eE].+/) !== -1)
|
|
2538
|
+
return mr(r, t, e);
|
|
2539
|
+
{
|
|
2540
|
+
const s = hr.exec(t);
|
|
2541
|
+
if (s) {
|
|
2542
|
+
const n = s[1] || "", o = s[2];
|
|
2543
|
+
let i = yr(s[3]);
|
|
2544
|
+
const u = n ? (
|
|
2545
|
+
// 0., -00., 000.
|
|
2546
|
+
r[o.length + 1] === "."
|
|
2547
|
+
) : r[o.length] === ".";
|
|
2548
|
+
if (!e.leadingZeros && (o.length > 1 || o.length === 1 && !u))
|
|
2549
|
+
return r;
|
|
2550
|
+
{
|
|
2551
|
+
const a = Number(t), l = String(a);
|
|
2552
|
+
if (a === 0) return a;
|
|
2553
|
+
if (l.search(/[eE]/) !== -1)
|
|
2554
|
+
return e.eNotation ? a : r;
|
|
2555
|
+
if (t.indexOf(".") !== -1)
|
|
2556
|
+
return l === "0" || l === i || l === `${n}${i}` ? a : r;
|
|
2557
|
+
let h = o ? i : t;
|
|
2558
|
+
return o ? h === l || n + h === l ? a : r : h === l || h === n + l ? a : r;
|
|
2559
|
+
}
|
|
2560
|
+
} else
|
|
2561
|
+
return r;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
const br = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
2565
|
+
function mr(r, e, t) {
|
|
2566
|
+
if (!t.eNotation) return r;
|
|
2567
|
+
const s = e.match(br);
|
|
2568
|
+
if (s) {
|
|
2569
|
+
let n = s[1] || "";
|
|
2570
|
+
const o = s[3].indexOf("e") === -1 ? "E" : "e", i = s[2], u = n ? (
|
|
2571
|
+
// 0E.
|
|
2572
|
+
r[i.length + 1] === o
|
|
2573
|
+
) : r[i.length] === o;
|
|
2574
|
+
return i.length > 1 && u ? r : i.length === 1 && (s[3].startsWith(`.${o}`) || s[3][0] === o) ? Number(e) : t.leadingZeros && !u ? (e = (s[1] || "") + s[3], Number(e)) : r;
|
|
2575
|
+
} else
|
|
2576
|
+
return r;
|
|
2577
|
+
}
|
|
2578
|
+
function yr(r) {
|
|
2579
|
+
return r && r.indexOf(".") !== -1 && (r = r.replace(/0+$/, ""), r === "." ? r = "0" : r[0] === "." ? r = "0" + r : r[r.length - 1] === "." && (r = r.substring(0, r.length - 1))), r;
|
|
2580
|
+
}
|
|
2581
|
+
function Er(r, e) {
|
|
2582
|
+
if (parseInt) return parseInt(r, e);
|
|
2583
|
+
if (Number.parseInt) return Number.parseInt(r, e);
|
|
2584
|
+
if (window && window.parseInt) return window.parseInt(r, e);
|
|
2585
|
+
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
2586
|
+
}
|
|
2587
|
+
function Qe(r) {
|
|
2588
|
+
return typeof r == "function" ? r : Array.isArray(r) ? (e) => {
|
|
2589
|
+
for (const t of r)
|
|
2590
|
+
if (typeof t == "string" && e === t || t instanceof RegExp && t.test(e))
|
|
2591
|
+
return !0;
|
|
2592
|
+
} : () => !1;
|
|
2593
|
+
}
|
|
2594
|
+
class vr {
|
|
2595
|
+
constructor(e) {
|
|
2596
|
+
this.options = e, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
2597
|
+
apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
2598
|
+
gt: { regex: /&(gt|#62|#x3E);/g, val: ">" },
|
|
2599
|
+
lt: { regex: /&(lt|#60|#x3C);/g, val: "<" },
|
|
2600
|
+
quot: { regex: /&(quot|#34|#x22);/g, val: '"' }
|
|
2601
|
+
}, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = {
|
|
2602
|
+
space: { regex: /&(nbsp|#160);/g, val: " " },
|
|
2603
|
+
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
2604
|
+
// "gt" : { regex: /&(gt|#62);/g, val: ">" },
|
|
2605
|
+
// "amp" : { regex: /&(amp|#38);/g, val: "&" },
|
|
2606
|
+
// "quot" : { regex: /&(quot|#34);/g, val: "\"" },
|
|
2607
|
+
// "apos" : { regex: /&(apos|#39);/g, val: "'" },
|
|
2608
|
+
cent: { regex: /&(cent|#162);/g, val: "¢" },
|
|
2609
|
+
pound: { regex: /&(pound|#163);/g, val: "£" },
|
|
2610
|
+
yen: { regex: /&(yen|#165);/g, val: "¥" },
|
|
2611
|
+
euro: { regex: /&(euro|#8364);/g, val: "€" },
|
|
2612
|
+
copyright: { regex: /&(copy|#169);/g, val: "©" },
|
|
2613
|
+
reg: { regex: /&(reg|#174);/g, val: "®" },
|
|
2614
|
+
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
2615
|
+
num_dec: { regex: /&#([0-9]{1,7});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 10)) },
|
|
2616
|
+
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t, s) => String.fromCodePoint(Number.parseInt(s, 16)) }
|
|
2617
|
+
}, this.addExternalEntities = _r, this.parseXml = Ar, this.parseTextData = xr, this.resolveNameSpace = Nr, this.buildAttributesMap = wr, this.isItStopNode = Pr, this.replaceEntitiesValue = Or, this.readStopNodeData = Ir, this.saveTextToParentTag = Tr, this.addChild = Cr, this.ignoreAttributesFn = Qe(this.options.ignoreAttributes);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
function _r(r) {
|
|
2621
|
+
const e = Object.keys(r);
|
|
2622
|
+
for (let t = 0; t < e.length; t++) {
|
|
2623
|
+
const s = e[t];
|
|
2624
|
+
this.lastEntities[s] = {
|
|
2625
|
+
regex: new RegExp("&" + s + ";", "g"),
|
|
2626
|
+
val: r[s]
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
function xr(r, e, t, s, n, o, i) {
|
|
2631
|
+
if (r !== void 0 && (this.options.trimValues && !s && (r = r.trim()), r.length > 0)) {
|
|
2632
|
+
i || (r = this.replaceEntitiesValue(r));
|
|
2633
|
+
const u = this.options.tagValueProcessor(e, r, t, n, o);
|
|
2634
|
+
return u == null ? r : typeof u != typeof r || u !== r ? u : this.options.trimValues ? Ae(r, this.options.parseTagValue, this.options.numberParseOptions) : r.trim() === r ? Ae(r, this.options.parseTagValue, this.options.numberParseOptions) : r;
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
function Nr(r) {
|
|
2638
|
+
if (this.options.removeNSPrefix) {
|
|
2639
|
+
const e = r.split(":"), t = r.charAt(0) === "/" ? "/" : "";
|
|
2640
|
+
if (e[0] === "xmlns")
|
|
2641
|
+
return "";
|
|
2642
|
+
e.length === 2 && (r = t + e[1]);
|
|
2643
|
+
}
|
|
2644
|
+
return r;
|
|
2645
|
+
}
|
|
2646
|
+
const kr = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
2647
|
+
function wr(r, e, t) {
|
|
2648
|
+
if (this.options.ignoreAttributes !== !0 && typeof r == "string") {
|
|
2649
|
+
const s = Ye(r, kr), n = s.length, o = {};
|
|
2650
|
+
for (let i = 0; i < n; i++) {
|
|
2651
|
+
const u = this.resolveNameSpace(s[i][1]);
|
|
2652
|
+
if (this.ignoreAttributesFn(u, e))
|
|
2653
|
+
continue;
|
|
2654
|
+
let a = s[i][4], l = this.options.attributeNamePrefix + u;
|
|
2655
|
+
if (u.length)
|
|
2656
|
+
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), a !== void 0) {
|
|
2657
|
+
this.options.trimValues && (a = a.trim()), a = this.replaceEntitiesValue(a);
|
|
2658
|
+
const h = this.options.attributeValueProcessor(u, a, e);
|
|
2659
|
+
h == null ? o[l] = a : typeof h != typeof a || h !== a ? o[l] = h : o[l] = Ae(
|
|
2660
|
+
a,
|
|
2661
|
+
this.options.parseAttributeValue,
|
|
2662
|
+
this.options.numberParseOptions
|
|
2663
|
+
);
|
|
2664
|
+
} else this.options.allowBooleanAttributes && (o[l] = !0);
|
|
2665
|
+
}
|
|
2666
|
+
if (!Object.keys(o).length)
|
|
2667
|
+
return;
|
|
2668
|
+
if (this.options.attributesGroupName) {
|
|
2669
|
+
const i = {};
|
|
2670
|
+
return i[this.options.attributesGroupName] = o, i;
|
|
2671
|
+
}
|
|
2672
|
+
return o;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
const Ar = function(r) {
|
|
2676
|
+
r = r.replace(/\r\n?/g, `
|
|
2677
|
+
`);
|
|
2678
|
+
const e = new se("!xml");
|
|
2679
|
+
let t = e, s = "", n = "";
|
|
2680
|
+
const o = new dr(this.options.processEntities);
|
|
2681
|
+
for (let i = 0; i < r.length; i++)
|
|
2682
|
+
if (r[i] === "<")
|
|
2683
|
+
if (r[i + 1] === "/") {
|
|
2684
|
+
const a = oe(r, ">", i, "Closing Tag is not closed.");
|
|
2685
|
+
let l = r.substring(i + 2, a).trim();
|
|
2686
|
+
if (this.options.removeNSPrefix) {
|
|
2687
|
+
const y = l.indexOf(":");
|
|
2688
|
+
y !== -1 && (l = l.substr(y + 1));
|
|
2689
|
+
}
|
|
2690
|
+
this.options.transformTagName && (l = this.options.transformTagName(l)), t && (s = this.saveTextToParentTag(s, t, n));
|
|
2691
|
+
const h = n.substring(n.lastIndexOf(".") + 1);
|
|
2692
|
+
if (l && this.options.unpairedTags.indexOf(l) !== -1)
|
|
2693
|
+
throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);
|
|
2694
|
+
let f = 0;
|
|
2695
|
+
h && this.options.unpairedTags.indexOf(h) !== -1 ? (f = n.lastIndexOf(".", n.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : f = n.lastIndexOf("."), n = n.substring(0, f), t = this.tagsNodeStack.pop(), s = "", i = a;
|
|
2696
|
+
} else if (r[i + 1] === "?") {
|
|
2697
|
+
let a = we(r, i, !1, "?>");
|
|
2698
|
+
if (!a) throw new Error("Pi Tag is not closed.");
|
|
2699
|
+
if (s = this.saveTextToParentTag(s, t, n), !(this.options.ignoreDeclaration && a.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
2700
|
+
const l = new se(a.tagName);
|
|
2701
|
+
l.add(this.options.textNodeName, ""), a.tagName !== a.tagExp && a.attrExpPresent && (l[":@"] = this.buildAttributesMap(a.tagExp, n, a.tagName)), this.addChild(t, l, n, i);
|
|
2702
|
+
}
|
|
2703
|
+
i = a.closeIndex + 1;
|
|
2704
|
+
} else if (r.substr(i + 1, 3) === "!--") {
|
|
2705
|
+
const a = oe(r, "-->", i + 4, "Comment is not closed.");
|
|
2706
|
+
if (this.options.commentPropName) {
|
|
2707
|
+
const l = r.substring(i + 4, a - 2);
|
|
2708
|
+
s = this.saveTextToParentTag(s, t, n), t.add(this.options.commentPropName, [{ [this.options.textNodeName]: l }]);
|
|
2709
|
+
}
|
|
2710
|
+
i = a;
|
|
2711
|
+
} else if (r.substr(i + 1, 2) === "!D") {
|
|
2712
|
+
const a = o.readDocType(r, i);
|
|
2713
|
+
this.docTypeEntities = a.entities, i = a.i;
|
|
2714
|
+
} else if (r.substr(i + 1, 2) === "![") {
|
|
2715
|
+
const a = oe(r, "]]>", i, "CDATA is not closed.") - 2, l = r.substring(i + 9, a);
|
|
2716
|
+
s = this.saveTextToParentTag(s, t, n);
|
|
2717
|
+
let h = this.parseTextData(l, t.tagname, n, !0, !1, !0, !0);
|
|
2718
|
+
h == null && (h = ""), this.options.cdataPropName ? t.add(this.options.cdataPropName, [{ [this.options.textNodeName]: l }]) : t.add(this.options.textNodeName, h), i = a + 2;
|
|
2719
|
+
} else {
|
|
2720
|
+
let a = we(r, i, this.options.removeNSPrefix), l = a.tagName;
|
|
2721
|
+
const h = a.rawTagName;
|
|
2722
|
+
let f = a.tagExp, y = a.attrExpPresent, m = a.closeIndex;
|
|
2723
|
+
this.options.transformTagName && (l = this.options.transformTagName(l)), t && s && t.tagname !== "!xml" && (s = this.saveTextToParentTag(s, t, n, !1));
|
|
2724
|
+
const C = t;
|
|
2725
|
+
C && this.options.unpairedTags.indexOf(C.tagname) !== -1 && (t = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), l !== e.tagname && (n += n ? "." + l : l);
|
|
2726
|
+
const O = i;
|
|
2727
|
+
if (this.isItStopNode(this.options.stopNodes, n, l)) {
|
|
2728
|
+
let P = "";
|
|
2729
|
+
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1)
|
|
2730
|
+
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), n = n.substr(0, n.length - 1), f = l) : f = f.substr(0, f.length - 1), i = a.closeIndex;
|
|
2731
|
+
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
2732
|
+
i = a.closeIndex;
|
|
2733
|
+
else {
|
|
2734
|
+
const k = this.readStopNodeData(r, h, m + 1);
|
|
2735
|
+
if (!k) throw new Error(`Unexpected end of ${h}`);
|
|
2736
|
+
i = k.i, P = k.tagContent;
|
|
2737
|
+
}
|
|
2738
|
+
const M = new se(l);
|
|
2739
|
+
l !== f && y && (M[":@"] = this.buildAttributesMap(f, n, l)), P && (P = this.parseTextData(P, l, n, !0, y, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), M.add(this.options.textNodeName, P), this.addChild(t, M, n, O);
|
|
2740
|
+
} else {
|
|
2741
|
+
if (f.length > 0 && f.lastIndexOf("/") === f.length - 1) {
|
|
2742
|
+
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), n = n.substr(0, n.length - 1), f = l) : f = f.substr(0, f.length - 1), this.options.transformTagName && (l = this.options.transformTagName(l));
|
|
2743
|
+
const P = new se(l);
|
|
2744
|
+
l !== f && y && (P[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, P, n, O), n = n.substr(0, n.lastIndexOf("."));
|
|
2745
|
+
} else {
|
|
2746
|
+
const P = new se(l);
|
|
2747
|
+
this.tagsNodeStack.push(t), l !== f && y && (P[":@"] = this.buildAttributesMap(f, n, l)), this.addChild(t, P, n, O), t = P;
|
|
2748
|
+
}
|
|
2749
|
+
s = "", i = m;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
else
|
|
2753
|
+
s += r[i];
|
|
2754
|
+
return e.child;
|
|
2755
|
+
};
|
|
2756
|
+
function Cr(r, e, t, s) {
|
|
2757
|
+
this.options.captureMetaData || (s = void 0);
|
|
2758
|
+
const n = this.options.updateTag(e.tagname, t, e[":@"]);
|
|
2759
|
+
n === !1 || (typeof n == "string" && (e.tagname = n), r.addChild(e, s));
|
|
2760
|
+
}
|
|
2761
|
+
const Or = function(r) {
|
|
2762
|
+
if (this.options.processEntities) {
|
|
2763
|
+
for (let e in this.docTypeEntities) {
|
|
2764
|
+
const t = this.docTypeEntities[e];
|
|
2765
|
+
r = r.replace(t.regx, t.val);
|
|
2766
|
+
}
|
|
2767
|
+
for (let e in this.lastEntities) {
|
|
2768
|
+
const t = this.lastEntities[e];
|
|
2769
|
+
r = r.replace(t.regex, t.val);
|
|
2770
|
+
}
|
|
2771
|
+
if (this.options.htmlEntities)
|
|
2772
|
+
for (let e in this.htmlEntities) {
|
|
2773
|
+
const t = this.htmlEntities[e];
|
|
2774
|
+
r = r.replace(t.regex, t.val);
|
|
2775
|
+
}
|
|
2776
|
+
r = r.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
2777
|
+
}
|
|
2778
|
+
return r;
|
|
2779
|
+
};
|
|
2780
|
+
function Tr(r, e, t, s) {
|
|
2781
|
+
return r && (s === void 0 && (s = e.child.length === 0), r = this.parseTextData(
|
|
2782
|
+
r,
|
|
2783
|
+
e.tagname,
|
|
2784
|
+
t,
|
|
2785
|
+
!1,
|
|
2786
|
+
e[":@"] ? Object.keys(e[":@"]).length !== 0 : !1,
|
|
2787
|
+
s
|
|
2788
|
+
), r !== void 0 && r !== "" && e.add(this.options.textNodeName, r), r = ""), r;
|
|
2789
|
+
}
|
|
2790
|
+
function Pr(r, e, t) {
|
|
2791
|
+
const s = "*." + t;
|
|
2792
|
+
for (const n in r) {
|
|
2793
|
+
const o = r[n];
|
|
2794
|
+
if (s === o || e === o) return !0;
|
|
2795
|
+
}
|
|
2796
|
+
return !1;
|
|
2797
|
+
}
|
|
2798
|
+
function Sr(r, e, t = ">") {
|
|
2799
|
+
let s, n = "";
|
|
2800
|
+
for (let o = e; o < r.length; o++) {
|
|
2801
|
+
let i = r[o];
|
|
2802
|
+
if (s)
|
|
2803
|
+
i === s && (s = "");
|
|
2804
|
+
else if (i === '"' || i === "'")
|
|
2805
|
+
s = i;
|
|
2806
|
+
else if (i === t[0])
|
|
2807
|
+
if (t[1]) {
|
|
2808
|
+
if (r[o + 1] === t[1])
|
|
2809
|
+
return {
|
|
2810
|
+
data: n,
|
|
2811
|
+
index: o
|
|
2812
|
+
};
|
|
2813
|
+
} else
|
|
2814
|
+
return {
|
|
2815
|
+
data: n,
|
|
2816
|
+
index: o
|
|
2817
|
+
};
|
|
2818
|
+
else i === " " && (i = " ");
|
|
2819
|
+
n += i;
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
function oe(r, e, t, s) {
|
|
2823
|
+
const n = r.indexOf(e, t);
|
|
2824
|
+
if (n === -1)
|
|
2825
|
+
throw new Error(s);
|
|
2826
|
+
return n + e.length - 1;
|
|
2827
|
+
}
|
|
2828
|
+
function we(r, e, t, s = ">") {
|
|
2829
|
+
const n = Sr(r, e + 1, s);
|
|
2830
|
+
if (!n) return;
|
|
2831
|
+
let o = n.data;
|
|
2832
|
+
const i = n.index, u = o.search(/\s/);
|
|
2833
|
+
let a = o, l = !0;
|
|
2834
|
+
u !== -1 && (a = o.substring(0, u), o = o.substring(u + 1).trimStart());
|
|
2835
|
+
const h = a;
|
|
2836
|
+
if (t) {
|
|
2837
|
+
const f = a.indexOf(":");
|
|
2838
|
+
f !== -1 && (a = a.substr(f + 1), l = a !== n.data.substr(f + 1));
|
|
2839
|
+
}
|
|
2840
|
+
return {
|
|
2841
|
+
tagName: a,
|
|
2842
|
+
tagExp: o,
|
|
2843
|
+
closeIndex: i,
|
|
2844
|
+
attrExpPresent: l,
|
|
2845
|
+
rawTagName: h
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
function Ir(r, e, t) {
|
|
2849
|
+
const s = t;
|
|
2850
|
+
let n = 1;
|
|
2851
|
+
for (; t < r.length; t++)
|
|
2852
|
+
if (r[t] === "<")
|
|
2853
|
+
if (r[t + 1] === "/") {
|
|
2854
|
+
const o = oe(r, ">", t, `${e} is not closed`);
|
|
2855
|
+
if (r.substring(t + 2, o).trim() === e && (n--, n === 0))
|
|
2856
|
+
return {
|
|
2857
|
+
tagContent: r.substring(s, t),
|
|
2858
|
+
i: o
|
|
2859
|
+
};
|
|
2860
|
+
t = o;
|
|
2861
|
+
} else if (r[t + 1] === "?")
|
|
2862
|
+
t = oe(r, "?>", t + 1, "StopNode is not closed.");
|
|
2863
|
+
else if (r.substr(t + 1, 3) === "!--")
|
|
2864
|
+
t = oe(r, "-->", t + 3, "StopNode is not closed.");
|
|
2865
|
+
else if (r.substr(t + 1, 2) === "![")
|
|
2866
|
+
t = oe(r, "]]>", t, "StopNode is not closed.") - 2;
|
|
2867
|
+
else {
|
|
2868
|
+
const o = we(r, t, ">");
|
|
2869
|
+
o && ((o && o.tagName) === e && o.tagExp[o.tagExp.length - 1] !== "/" && n++, t = o.closeIndex);
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
function Ae(r, e, t) {
|
|
2873
|
+
if (e && typeof r == "string") {
|
|
2874
|
+
const s = r.trim();
|
|
2875
|
+
return s === "true" ? !0 : s === "false" ? !1 : gr(r, t);
|
|
2876
|
+
} else
|
|
2877
|
+
return Jt(r) ? r : "";
|
|
2878
|
+
}
|
|
2879
|
+
const Ne = se.getMetaDataSymbol();
|
|
2880
|
+
function $r(r, e) {
|
|
2881
|
+
return Ge(r, e);
|
|
2882
|
+
}
|
|
2883
|
+
function Ge(r, e, t) {
|
|
2884
|
+
let s;
|
|
2885
|
+
const n = {};
|
|
2886
|
+
for (let o = 0; o < r.length; o++) {
|
|
2887
|
+
const i = r[o], u = Br(i);
|
|
2888
|
+
let a = "";
|
|
2889
|
+
if (t === void 0 ? a = u : a = t + "." + u, u === e.textNodeName)
|
|
2890
|
+
s === void 0 ? s = i[u] : s += "" + i[u];
|
|
2891
|
+
else {
|
|
2892
|
+
if (u === void 0)
|
|
2893
|
+
continue;
|
|
2894
|
+
if (i[u]) {
|
|
2895
|
+
let l = Ge(i[u], e, a);
|
|
2896
|
+
const h = Vr(l, e);
|
|
2897
|
+
i[Ne] !== void 0 && (l[Ne] = i[Ne]), i[":@"] ? Lr(l, i[":@"], a, e) : Object.keys(l).length === 1 && l[e.textNodeName] !== void 0 && !e.alwaysCreateTextNode ? l = l[e.textNodeName] : Object.keys(l).length === 0 && (e.alwaysCreateTextNode ? l[e.textNodeName] = "" : l = ""), n[u] !== void 0 && n.hasOwnProperty(u) ? (Array.isArray(n[u]) || (n[u] = [n[u]]), n[u].push(l)) : e.isArray(u, a, h) ? n[u] = [l] : n[u] = l;
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
return typeof s == "string" ? s.length > 0 && (n[e.textNodeName] = s) : s !== void 0 && (n[e.textNodeName] = s), n;
|
|
2902
|
+
}
|
|
2903
|
+
function Br(r) {
|
|
2904
|
+
const e = Object.keys(r);
|
|
2905
|
+
for (let t = 0; t < e.length; t++) {
|
|
2906
|
+
const s = e[t];
|
|
2907
|
+
if (s !== ":@") return s;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
function Lr(r, e, t, s) {
|
|
2911
|
+
if (e) {
|
|
2912
|
+
const n = Object.keys(e), o = n.length;
|
|
2913
|
+
for (let i = 0; i < o; i++) {
|
|
2914
|
+
const u = n[i];
|
|
2915
|
+
s.isArray(u, t + "." + u, !0, !0) ? r[u] = [e[u]] : r[u] = e[u];
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
function Vr(r, e) {
|
|
2920
|
+
const { textNodeName: t } = e, s = Object.keys(r).length;
|
|
2921
|
+
return !!(s === 0 || s === 1 && (r[t] || typeof r[t] == "boolean" || r[t] === 0));
|
|
2922
|
+
}
|
|
2923
|
+
class Rr {
|
|
2924
|
+
constructor(e) {
|
|
2925
|
+
this.externalEntities = {}, this.options = cr(e);
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Parse XML dats to JS object
|
|
2929
|
+
* @param {string|Uint8Array} xmlData
|
|
2930
|
+
* @param {boolean|Object} validationOption
|
|
2931
|
+
*/
|
|
2932
|
+
parse(e, t) {
|
|
2933
|
+
if (typeof e != "string" && e.toString)
|
|
2934
|
+
e = e.toString();
|
|
2935
|
+
else if (typeof e != "string")
|
|
2936
|
+
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
2937
|
+
if (t) {
|
|
2938
|
+
t === !0 && (t = {});
|
|
2939
|
+
const o = qe(e, t);
|
|
2940
|
+
if (o !== !0)
|
|
2941
|
+
throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`);
|
|
2942
|
+
}
|
|
2943
|
+
const s = new vr(this.options);
|
|
2944
|
+
s.addExternalEntities(this.externalEntities);
|
|
2945
|
+
const n = s.parseXml(e);
|
|
2946
|
+
return this.options.preserveOrder || n === void 0 ? n : $r(n, this.options);
|
|
2947
|
+
}
|
|
2948
|
+
/**
|
|
2949
|
+
* Add Entity which is not by default supported by this library
|
|
2950
|
+
* @param {string} key
|
|
2951
|
+
* @param {string} value
|
|
2952
|
+
*/
|
|
2953
|
+
addEntity(e, t) {
|
|
2954
|
+
if (t.indexOf("&") !== -1)
|
|
2955
|
+
throw new Error("Entity value can't have '&'");
|
|
2956
|
+
if (e.indexOf("&") !== -1 || e.indexOf(";") !== -1)
|
|
2957
|
+
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
2958
|
+
if (t === "&")
|
|
2959
|
+
throw new Error("An entity with value '&' is not permitted");
|
|
2960
|
+
this.externalEntities[e] = t;
|
|
2961
|
+
}
|
|
2962
|
+
/**
|
|
2963
|
+
* Returns a Symbol that can be used to access the metadata
|
|
2964
|
+
* property on a node.
|
|
2965
|
+
*
|
|
2966
|
+
* If Symbol is not available in the environment, an ordinary property is used
|
|
2967
|
+
* and the name of the property is here returned.
|
|
2968
|
+
*
|
|
2969
|
+
* The XMLMetaData property is only present when `captureMetaData`
|
|
2970
|
+
* is true in the options.
|
|
2971
|
+
*/
|
|
2972
|
+
static getMetaDataSymbol() {
|
|
2973
|
+
return se.getMetaDataSymbol();
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
const jr = `
|
|
2977
|
+
`;
|
|
2978
|
+
function Mr(r, e) {
|
|
2979
|
+
let t = "";
|
|
2980
|
+
return e.format && e.indentBy.length > 0 && (t = jr), We(r, e, "", t);
|
|
2981
|
+
}
|
|
2982
|
+
function We(r, e, t, s) {
|
|
2983
|
+
let n = "", o = !1;
|
|
2984
|
+
for (let i = 0; i < r.length; i++) {
|
|
2985
|
+
const u = r[i], a = Ur(u);
|
|
2986
|
+
if (a === void 0) continue;
|
|
2987
|
+
let l = "";
|
|
2988
|
+
if (t.length === 0 ? l = a : l = `${t}.${a}`, a === e.textNodeName) {
|
|
2989
|
+
let C = u[a];
|
|
2990
|
+
Fr(l, e) || (C = e.tagValueProcessor(a, C), C = Ze(C, e)), o && (n += s), n += C, o = !1;
|
|
2991
|
+
continue;
|
|
2992
|
+
} else if (a === e.cdataPropName) {
|
|
2993
|
+
o && (n += s), n += `<![CDATA[${u[a][0][e.textNodeName]}]]>`, o = !1;
|
|
2994
|
+
continue;
|
|
2995
|
+
} else if (a === e.commentPropName) {
|
|
2996
|
+
n += s + `<!--${u[a][0][e.textNodeName]}-->`, o = !0;
|
|
2997
|
+
continue;
|
|
2998
|
+
} else if (a[0] === "?") {
|
|
2999
|
+
const C = Re(u[":@"], e), O = a === "?xml" ? "" : s;
|
|
3000
|
+
let P = u[a][0][e.textNodeName];
|
|
3001
|
+
P = P.length !== 0 ? " " + P : "", n += O + `<${a}${P}${C}?>`, o = !0;
|
|
3002
|
+
continue;
|
|
3003
|
+
}
|
|
3004
|
+
let h = s;
|
|
3005
|
+
h !== "" && (h += e.indentBy);
|
|
3006
|
+
const f = Re(u[":@"], e), y = s + `<${a}${f}`, m = We(u[a], e, l, h);
|
|
3007
|
+
e.unpairedTags.indexOf(a) !== -1 ? e.suppressUnpairedNode ? n += y + ">" : n += y + "/>" : (!m || m.length === 0) && e.suppressEmptyNode ? n += y + "/>" : m && m.endsWith(">") ? n += y + `>${m}${s}</${a}>` : (n += y + ">", m && s !== "" && (m.includes("/>") || m.includes("</")) ? n += s + e.indentBy + m + s : n += m, n += `</${a}>`), o = !0;
|
|
3008
|
+
}
|
|
3009
|
+
return n;
|
|
3010
|
+
}
|
|
3011
|
+
function Ur(r) {
|
|
3012
|
+
const e = Object.keys(r);
|
|
3013
|
+
for (let t = 0; t < e.length; t++) {
|
|
3014
|
+
const s = e[t];
|
|
3015
|
+
if (r.hasOwnProperty(s) && s !== ":@")
|
|
3016
|
+
return s;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
function Re(r, e) {
|
|
3020
|
+
let t = "";
|
|
3021
|
+
if (r && !e.ignoreAttributes)
|
|
3022
|
+
for (let s in r) {
|
|
3023
|
+
if (!r.hasOwnProperty(s)) continue;
|
|
3024
|
+
let n = e.attributeValueProcessor(s, r[s]);
|
|
3025
|
+
n = Ze(n, e), n === !0 && e.suppressBooleanAttributes ? t += ` ${s.substr(e.attributeNamePrefix.length)}` : t += ` ${s.substr(e.attributeNamePrefix.length)}="${n}"`;
|
|
3026
|
+
}
|
|
3027
|
+
return t;
|
|
3028
|
+
}
|
|
3029
|
+
function Fr(r, e) {
|
|
3030
|
+
r = r.substr(0, r.length - e.textNodeName.length - 1);
|
|
3031
|
+
let t = r.substr(r.lastIndexOf(".") + 1);
|
|
3032
|
+
for (let s in e.stopNodes)
|
|
3033
|
+
if (e.stopNodes[s] === r || e.stopNodes[s] === "*." + t) return !0;
|
|
3034
|
+
return !1;
|
|
3035
|
+
}
|
|
3036
|
+
function Ze(r, e) {
|
|
3037
|
+
if (r && r.length > 0 && e.processEntities)
|
|
3038
|
+
for (let t = 0; t < e.entities.length; t++) {
|
|
3039
|
+
const s = e.entities[t];
|
|
3040
|
+
r = r.replace(s.regex, s.val);
|
|
3041
|
+
}
|
|
3042
|
+
return r;
|
|
3043
|
+
}
|
|
3044
|
+
const Xr = {
|
|
3045
|
+
attributeNamePrefix: "@_",
|
|
3046
|
+
attributesGroupName: !1,
|
|
3047
|
+
textNodeName: "#text",
|
|
3048
|
+
ignoreAttributes: !0,
|
|
3049
|
+
cdataPropName: !1,
|
|
3050
|
+
format: !1,
|
|
3051
|
+
indentBy: " ",
|
|
3052
|
+
suppressEmptyNode: !1,
|
|
3053
|
+
suppressUnpairedNode: !0,
|
|
3054
|
+
suppressBooleanAttributes: !0,
|
|
3055
|
+
tagValueProcessor: function(r, e) {
|
|
3056
|
+
return e;
|
|
3057
|
+
},
|
|
3058
|
+
attributeValueProcessor: function(r, e) {
|
|
3059
|
+
return e;
|
|
3060
|
+
},
|
|
3061
|
+
preserveOrder: !1,
|
|
3062
|
+
commentPropName: !1,
|
|
3063
|
+
unpairedTags: [],
|
|
3064
|
+
entities: [
|
|
3065
|
+
{ regex: new RegExp("&", "g"), val: "&" },
|
|
3066
|
+
//it must be on top
|
|
3067
|
+
{ regex: new RegExp(">", "g"), val: ">" },
|
|
3068
|
+
{ regex: new RegExp("<", "g"), val: "<" },
|
|
3069
|
+
{ regex: new RegExp("'", "g"), val: "'" },
|
|
3070
|
+
{ regex: new RegExp('"', "g"), val: """ }
|
|
3071
|
+
],
|
|
3072
|
+
processEntities: !0,
|
|
3073
|
+
stopNodes: [],
|
|
3074
|
+
// transformTagName: false,
|
|
3075
|
+
// transformAttributeName: false,
|
|
3076
|
+
oneListGroup: !1
|
|
3077
|
+
};
|
|
3078
|
+
function re(r) {
|
|
3079
|
+
this.options = Object.assign({}, Xr, r), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
3080
|
+
return !1;
|
|
3081
|
+
} : (this.ignoreAttributesFn = Qe(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Yr), this.processTextOrObjNode = Hr, this.options.format ? (this.indentate = Kr, this.tagEndChar = `>
|
|
3082
|
+
`, this.newLine = `
|
|
3083
|
+
`) : (this.indentate = function() {
|
|
3084
|
+
return "";
|
|
3085
|
+
}, this.tagEndChar = ">", this.newLine = "");
|
|
3086
|
+
}
|
|
3087
|
+
re.prototype.build = function(r) {
|
|
3088
|
+
return this.options.preserveOrder ? Mr(r, this.options) : (Array.isArray(r) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (r = {
|
|
3089
|
+
[this.options.arrayNodeName]: r
|
|
3090
|
+
}), this.j2x(r, 0, []).val);
|
|
3091
|
+
};
|
|
3092
|
+
re.prototype.j2x = function(r, e, t) {
|
|
3093
|
+
let s = "", n = "";
|
|
3094
|
+
const o = t.join(".");
|
|
3095
|
+
for (let i in r)
|
|
3096
|
+
if (Object.prototype.hasOwnProperty.call(r, i))
|
|
3097
|
+
if (typeof r[i] > "u")
|
|
3098
|
+
this.isAttribute(i) && (n += "");
|
|
3099
|
+
else if (r[i] === null)
|
|
3100
|
+
this.isAttribute(i) || i === this.options.cdataPropName ? n += "" : i[0] === "?" ? n += this.indentate(e) + "<" + i + "?" + this.tagEndChar : n += this.indentate(e) + "<" + i + "/" + this.tagEndChar;
|
|
3101
|
+
else if (r[i] instanceof Date)
|
|
3102
|
+
n += this.buildTextValNode(r[i], i, "", e);
|
|
3103
|
+
else if (typeof r[i] != "object") {
|
|
3104
|
+
const u = this.isAttribute(i);
|
|
3105
|
+
if (u && !this.ignoreAttributesFn(u, o))
|
|
3106
|
+
s += this.buildAttrPairStr(u, "" + r[i]);
|
|
3107
|
+
else if (!u)
|
|
3108
|
+
if (i === this.options.textNodeName) {
|
|
3109
|
+
let a = this.options.tagValueProcessor(i, "" + r[i]);
|
|
3110
|
+
n += this.replaceEntitiesValue(a);
|
|
3111
|
+
} else
|
|
3112
|
+
n += this.buildTextValNode(r[i], i, "", e);
|
|
3113
|
+
} else if (Array.isArray(r[i])) {
|
|
3114
|
+
const u = r[i].length;
|
|
3115
|
+
let a = "", l = "";
|
|
3116
|
+
for (let h = 0; h < u; h++) {
|
|
3117
|
+
const f = r[i][h];
|
|
3118
|
+
if (!(typeof f > "u")) if (f === null)
|
|
3119
|
+
i[0] === "?" ? n += this.indentate(e) + "<" + i + "?" + this.tagEndChar : n += this.indentate(e) + "<" + i + "/" + this.tagEndChar;
|
|
3120
|
+
else if (typeof f == "object")
|
|
3121
|
+
if (this.options.oneListGroup) {
|
|
3122
|
+
const y = this.j2x(f, e + 1, t.concat(i));
|
|
3123
|
+
a += y.val, this.options.attributesGroupName && f.hasOwnProperty(this.options.attributesGroupName) && (l += y.attrStr);
|
|
3124
|
+
} else
|
|
3125
|
+
a += this.processTextOrObjNode(f, i, e, t);
|
|
3126
|
+
else if (this.options.oneListGroup) {
|
|
3127
|
+
let y = this.options.tagValueProcessor(i, f);
|
|
3128
|
+
y = this.replaceEntitiesValue(y), a += y;
|
|
3129
|
+
} else
|
|
3130
|
+
a += this.buildTextValNode(f, i, "", e);
|
|
3131
|
+
}
|
|
3132
|
+
this.options.oneListGroup && (a = this.buildObjectNode(a, i, l, e)), n += a;
|
|
3133
|
+
} else if (this.options.attributesGroupName && i === this.options.attributesGroupName) {
|
|
3134
|
+
const u = Object.keys(r[i]), a = u.length;
|
|
3135
|
+
for (let l = 0; l < a; l++)
|
|
3136
|
+
s += this.buildAttrPairStr(u[l], "" + r[i][u[l]]);
|
|
3137
|
+
} else
|
|
3138
|
+
n += this.processTextOrObjNode(r[i], i, e, t);
|
|
3139
|
+
return { attrStr: s, val: n };
|
|
3140
|
+
};
|
|
3141
|
+
re.prototype.buildAttrPairStr = function(r, e) {
|
|
3142
|
+
return e = this.options.attributeValueProcessor(r, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + r : " " + r + '="' + e + '"';
|
|
3143
|
+
};
|
|
3144
|
+
function Hr(r, e, t, s) {
|
|
3145
|
+
const n = this.j2x(r, t + 1, s.concat(e));
|
|
3146
|
+
return r[this.options.textNodeName] !== void 0 && Object.keys(r).length === 1 ? this.buildTextValNode(r[this.options.textNodeName], e, n.attrStr, t) : this.buildObjectNode(n.val, e, n.attrStr, t);
|
|
3147
|
+
}
|
|
3148
|
+
re.prototype.buildObjectNode = function(r, e, t, s) {
|
|
3149
|
+
if (r === "")
|
|
3150
|
+
return e[0] === "?" ? this.indentate(s) + "<" + e + t + "?" + this.tagEndChar : this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar;
|
|
3151
|
+
{
|
|
3152
|
+
let n = "</" + e + this.tagEndChar, o = "";
|
|
3153
|
+
return e[0] === "?" && (o = "?", n = ""), (t || t === "") && r.indexOf("<") === -1 ? this.indentate(s) + "<" + e + t + o + ">" + r + n : this.options.commentPropName !== !1 && e === this.options.commentPropName && o.length === 0 ? this.indentate(s) + `<!--${r}-->` + this.newLine : this.indentate(s) + "<" + e + t + o + this.tagEndChar + r + this.indentate(s) + n;
|
|
3154
|
+
}
|
|
3155
|
+
};
|
|
3156
|
+
re.prototype.closeTag = function(r) {
|
|
3157
|
+
let e = "";
|
|
3158
|
+
return this.options.unpairedTags.indexOf(r) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${r}`, e;
|
|
3159
|
+
};
|
|
3160
|
+
re.prototype.buildTextValNode = function(r, e, t, s) {
|
|
3161
|
+
if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
|
|
3162
|
+
return this.indentate(s) + `<![CDATA[${r}]]>` + this.newLine;
|
|
3163
|
+
if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
|
|
3164
|
+
return this.indentate(s) + `<!--${r}-->` + this.newLine;
|
|
3165
|
+
if (e[0] === "?")
|
|
3166
|
+
return this.indentate(s) + "<" + e + t + "?" + this.tagEndChar;
|
|
3167
|
+
{
|
|
3168
|
+
let n = this.options.tagValueProcessor(e, r);
|
|
3169
|
+
return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(s) + "<" + e + t + this.closeTag(e) + this.tagEndChar : this.indentate(s) + "<" + e + t + ">" + n + "</" + e + this.tagEndChar;
|
|
3170
|
+
}
|
|
3171
|
+
};
|
|
3172
|
+
re.prototype.replaceEntitiesValue = function(r) {
|
|
3173
|
+
if (r && r.length > 0 && this.options.processEntities)
|
|
3174
|
+
for (let e = 0; e < this.options.entities.length; e++) {
|
|
3175
|
+
const t = this.options.entities[e];
|
|
3176
|
+
r = r.replace(t.regex, t.val);
|
|
3177
|
+
}
|
|
3178
|
+
return r;
|
|
3179
|
+
};
|
|
3180
|
+
function Kr(r) {
|
|
3181
|
+
return this.options.indentBy.repeat(r);
|
|
3182
|
+
}
|
|
3183
|
+
function Yr(r) {
|
|
3184
|
+
return r.startsWith(this.options.attributeNamePrefix) && r !== this.options.textNodeName ? r.substr(this.attrPrefixLen) : !1;
|
|
3185
|
+
}
|
|
3186
|
+
const qr = {
|
|
3187
|
+
validate: qe
|
|
3188
|
+
}, Qr = {
|
|
3189
|
+
ignoreAttributes: !1,
|
|
3190
|
+
// 保留属性
|
|
3191
|
+
attributeNamePrefix: "@_",
|
|
3192
|
+
// 属性前缀
|
|
3193
|
+
textNodeName: "#text",
|
|
3194
|
+
// 文本节点名
|
|
3195
|
+
ignoreDeclaration: !1,
|
|
3196
|
+
// 保留 XML 声明
|
|
3197
|
+
commentPropName: "#comment",
|
|
3198
|
+
// 注释属性名
|
|
3199
|
+
cdataPropName: "__cdata",
|
|
3200
|
+
// CDATA 属性名
|
|
3201
|
+
preserveOrder: !1,
|
|
3202
|
+
// 不保留顺序(使用对象结构)
|
|
3203
|
+
parseAttributeValue: !1,
|
|
3204
|
+
// 不解析属性值(保持字符串)
|
|
3205
|
+
trimValues: !0,
|
|
3206
|
+
// 去除首尾空白
|
|
3207
|
+
parseTagValue: !1,
|
|
3208
|
+
// 不解析标签值(保持字符串)
|
|
3209
|
+
processEntities: !0,
|
|
3210
|
+
// 处理实体
|
|
3211
|
+
htmlEntities: !1,
|
|
3212
|
+
// 不是 HTML 实体
|
|
3213
|
+
ignoreNameSpace: !1,
|
|
3214
|
+
// 保留命名空间
|
|
3215
|
+
allowBooleanAttributes: !0,
|
|
3216
|
+
// 允许布尔属性
|
|
3217
|
+
unpairedTags: [],
|
|
3218
|
+
// 未配对的标签
|
|
3219
|
+
stopNodes: [],
|
|
3220
|
+
// 停止解析的节点
|
|
3221
|
+
alwaysCreateTextNode: !1
|
|
3222
|
+
// 仅在有文本时创建文本节点
|
|
3223
|
+
}, Gr = {
|
|
3224
|
+
ignoreAttributes: !1,
|
|
3225
|
+
attributeNamePrefix: "@_",
|
|
3226
|
+
textNodeName: "#text",
|
|
3227
|
+
format: !0,
|
|
3228
|
+
// 格式化输出
|
|
3229
|
+
indentBy: " ",
|
|
3230
|
+
// 缩进 2 空格
|
|
3231
|
+
suppressEmptyNode: !1,
|
|
3232
|
+
// 不抑制空节点
|
|
3233
|
+
suppressBooleanAttributes: !1,
|
|
3234
|
+
suppressUnpairedNode: !1
|
|
3235
|
+
}, Wr = (r) => {
|
|
3236
|
+
try {
|
|
3237
|
+
const e = qr.validate(r, {
|
|
3238
|
+
allowBooleanAttributes: !0
|
|
3239
|
+
});
|
|
3240
|
+
return e === !0 ? { valid: !0 } : {
|
|
3241
|
+
valid: !1,
|
|
3242
|
+
error: `Line ${e.err.line}: ${e.err.msg}`
|
|
3243
|
+
};
|
|
3244
|
+
} catch (e) {
|
|
3245
|
+
return {
|
|
3246
|
+
valid: !1,
|
|
3247
|
+
error: e instanceof Error ? e.message : "Unknown validation error"
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
}, ze = (r, e) => {
|
|
3251
|
+
try {
|
|
3252
|
+
return new Rr({
|
|
3253
|
+
...Qr,
|
|
3254
|
+
...e
|
|
3255
|
+
}).parse(r);
|
|
3256
|
+
} catch (t) {
|
|
3257
|
+
throw new Error(
|
|
3258
|
+
`XML 解析失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3259
|
+
);
|
|
3260
|
+
}
|
|
3261
|
+
}, Te = (r, e) => {
|
|
3262
|
+
try {
|
|
3263
|
+
let s = new re({
|
|
3264
|
+
...Gr,
|
|
3265
|
+
format: e?.format ?? !0,
|
|
3266
|
+
indentBy: e?.indentBy ?? " "
|
|
3267
|
+
}).build(r);
|
|
3268
|
+
return e?.showDeclaration !== !1 && !s.startsWith("<?xml") && (s = `<?xml version="1.0" encoding="UTF-8"?>
|
|
3269
|
+
` + s), s;
|
|
3270
|
+
} catch (t) {
|
|
3271
|
+
throw new Error(
|
|
3272
|
+
`XML 构建失败: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
}, Zr = (r) => Te(r, { format: !1, showDeclaration: !1 }), zr = (r, e) => {
|
|
3276
|
+
const t = ze(r);
|
|
3277
|
+
return Te(t, e);
|
|
3278
|
+
}, Dr = (r) => {
|
|
3279
|
+
if (!r || typeof r != "object") return {};
|
|
3280
|
+
const e = {};
|
|
3281
|
+
return Object.keys(r).forEach((t) => {
|
|
3282
|
+
if (t.startsWith("@_")) {
|
|
3283
|
+
const s = t.substring(2);
|
|
3284
|
+
e[s] = r[t];
|
|
3285
|
+
}
|
|
3286
|
+
}), e;
|
|
3287
|
+
}, Jr = (r) => !r || typeof r != "object" ? typeof r == "string" ? r : null : r["#text"] || null, en = {
|
|
3288
|
+
key: 0,
|
|
3289
|
+
class: "xml-node__element"
|
|
3290
|
+
}, tn = {
|
|
3291
|
+
key: 0,
|
|
3292
|
+
class: "xml-node__line"
|
|
3293
|
+
}, rn = { key: 1 }, nn = { class: "xml-node__line" }, sn = ["title"], on = { key: 1 }, an = ["title"], ln = {
|
|
3294
|
+
key: 0,
|
|
3295
|
+
class: "xml-node__children"
|
|
3296
|
+
}, un = {
|
|
3297
|
+
key: 0,
|
|
3298
|
+
class: "xml-node__text"
|
|
3299
|
+
}, cn = {
|
|
3300
|
+
key: 1,
|
|
3301
|
+
class: "xml-node__line"
|
|
3302
|
+
}, dn = {
|
|
3303
|
+
key: 1,
|
|
3304
|
+
class: "xml-node__text"
|
|
3305
|
+
}, fn = {
|
|
3306
|
+
key: 2,
|
|
3307
|
+
class: "xml-node__comment"
|
|
3308
|
+
}, hn = {
|
|
3309
|
+
key: 3,
|
|
3310
|
+
class: "xml-node__cdata"
|
|
3311
|
+
}, pn = /* @__PURE__ */ be({
|
|
3312
|
+
__name: "XmlNode",
|
|
3313
|
+
props: {
|
|
3314
|
+
value: {},
|
|
3315
|
+
tagName: {},
|
|
3316
|
+
level: { default: 0 },
|
|
3317
|
+
path: { default: "" },
|
|
3318
|
+
expanded: {},
|
|
3319
|
+
theme: {}
|
|
3320
|
+
},
|
|
3321
|
+
emits: ["toggle-expand", "copy"],
|
|
3322
|
+
setup(r, { emit: e }) {
|
|
3323
|
+
const t = r, s = e, n = L(() => t.path || t.tagName), o = L(() => t.expanded.has(n.value)), i = L(() => t.tagName && !t.tagName.startsWith("#") && t.tagName !== "__cdata" ? !0 : t.value !== null && typeof t.value == "object"), u = L(() => !t.tagName && typeof t.value == "string"), a = L(() => t.tagName === "#comment"), l = L(() => t.tagName === "__cdata"), h = L(() => i.value ? Dr(t.value) : {}), f = L(() => typeof t.value == "string" ? t.value : i.value ? Jr(t.value) || "" : t.value || ""), y = L(() => t.value || ""), m = L(() => t.value || ""), C = L(() => {
|
|
3324
|
+
if (typeof t.value != "object" || t.value === null)
|
|
3325
|
+
return [];
|
|
3326
|
+
const g = [];
|
|
3327
|
+
return Object.keys(t.value).forEach((T) => {
|
|
3328
|
+
if (T.startsWith("@_") || T === "#text") return;
|
|
3329
|
+
const X = t.value[T];
|
|
3330
|
+
Array.isArray(X) ? X.forEach((j) => {
|
|
3331
|
+
g.push({ tagName: T, value: j });
|
|
3332
|
+
}) : g.push({ tagName: T, value: X });
|
|
3333
|
+
}), g;
|
|
3334
|
+
}), O = L(() => C.value.length > 0 ? !0 : f.value.trim() !== ""), P = L(() => i.value && C.value.length === 0 && f.value.trim() !== ""), M = () => {
|
|
3335
|
+
O.value && s("toggle-expand", n.value);
|
|
3336
|
+
}, k = (g, T) => `${n.value}.${g}[${T}]`, S = (g, T) => `${g.tagName}-${T}`;
|
|
3337
|
+
return (g, T) => {
|
|
3338
|
+
const X = Me("XmlNode", !0);
|
|
3339
|
+
return x(), N("div", {
|
|
3340
|
+
class: "xml-node",
|
|
3341
|
+
style: I({ paddingLeft: g.level > 0 ? "16px" : "0" })
|
|
3342
|
+
}, [
|
|
3343
|
+
i.value ? (x(), N("div", en, [
|
|
3344
|
+
P.value ? (x(), N("div", tn, [
|
|
3345
|
+
E("span", {
|
|
3346
|
+
class: "xml-node__bracket",
|
|
3347
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3348
|
+
}, "<", 4),
|
|
3349
|
+
E("span", {
|
|
3350
|
+
class: "xml-node__tag",
|
|
3351
|
+
style: I({ color: g.theme.colors.xmlTag })
|
|
3352
|
+
}, R(g.tagName), 5),
|
|
3353
|
+
(x(!0), N(he, null, pe(h.value, (j, Y) => (x(), N("span", {
|
|
3354
|
+
key: Y,
|
|
3355
|
+
class: "xml-node__attribute"
|
|
3356
|
+
}, [
|
|
3357
|
+
E("span", {
|
|
3358
|
+
class: "xml-node__attr-name",
|
|
3359
|
+
style: I({ color: g.theme.colors.xmlAttribute })
|
|
3360
|
+
}, R(Y), 5),
|
|
3361
|
+
E("span", {
|
|
3362
|
+
class: "xml-node__equals",
|
|
3363
|
+
style: I({ color: g.theme.colors.xmlEquals })
|
|
3364
|
+
}, "=", 4),
|
|
3365
|
+
E("span", {
|
|
3366
|
+
class: "xml-node__quote",
|
|
3367
|
+
style: I({ color: g.theme.colors.xmlQuote })
|
|
3368
|
+
}, '"', 4),
|
|
3369
|
+
E("span", {
|
|
3370
|
+
class: "xml-node__attr-value",
|
|
3371
|
+
style: I({ color: g.theme.colors.xmlAttributeValue })
|
|
3372
|
+
}, R(j), 5),
|
|
3373
|
+
E("span", {
|
|
3374
|
+
class: "xml-node__quote",
|
|
3375
|
+
style: I({ color: g.theme.colors.xmlQuote })
|
|
3376
|
+
}, '"', 4)
|
|
3377
|
+
]))), 128)),
|
|
3378
|
+
E("span", {
|
|
3379
|
+
class: "xml-node__bracket",
|
|
3380
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3381
|
+
}, ">", 4),
|
|
3382
|
+
E("span", {
|
|
3383
|
+
class: "xml-node__text-content",
|
|
3384
|
+
style: I({ color: g.theme.colors.xmlText })
|
|
3385
|
+
}, R(f.value), 5),
|
|
3386
|
+
E("span", {
|
|
3387
|
+
class: "xml-node__bracket",
|
|
3388
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3389
|
+
}, "</", 4),
|
|
3390
|
+
E("span", {
|
|
3391
|
+
class: "xml-node__tag",
|
|
3392
|
+
style: I({ color: g.theme.colors.xmlTag })
|
|
3393
|
+
}, R(g.tagName), 5),
|
|
3394
|
+
E("span", {
|
|
3395
|
+
class: "xml-node__bracket",
|
|
3396
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3397
|
+
}, ">", 4)
|
|
3398
|
+
])) : (x(), N("div", rn, [
|
|
3399
|
+
E("div", nn, [
|
|
3400
|
+
O.value ? (x(), N("span", {
|
|
3401
|
+
key: 0,
|
|
3402
|
+
class: "xml-node__clickable-part",
|
|
3403
|
+
onClick: T[0] || (T[0] = (j) => M()),
|
|
3404
|
+
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3405
|
+
}, [
|
|
3406
|
+
E("span", {
|
|
3407
|
+
class: "xml-node__bracket",
|
|
3408
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3409
|
+
}, "<", 4),
|
|
3410
|
+
E("span", {
|
|
3411
|
+
class: "xml-node__tag",
|
|
3412
|
+
style: I({ color: g.theme.colors.xmlTag })
|
|
3413
|
+
}, R(g.tagName), 5)
|
|
3414
|
+
], 8, sn)) : (x(), N("span", on, [
|
|
3415
|
+
E("span", {
|
|
3416
|
+
class: "xml-node__bracket",
|
|
3417
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3418
|
+
}, "<", 4),
|
|
3419
|
+
E("span", {
|
|
3420
|
+
class: "xml-node__tag",
|
|
3421
|
+
style: I({ color: g.theme.colors.xmlTag })
|
|
3422
|
+
}, R(g.tagName), 5)
|
|
3423
|
+
])),
|
|
3424
|
+
(x(!0), N(he, null, pe(h.value, (j, Y) => (x(), N("span", {
|
|
3425
|
+
key: Y,
|
|
3426
|
+
class: "xml-node__attribute"
|
|
3427
|
+
}, [
|
|
3428
|
+
E("span", {
|
|
3429
|
+
class: "xml-node__attr-name",
|
|
3430
|
+
style: I({ color: g.theme.colors.xmlAttribute })
|
|
3431
|
+
}, R(Y), 5),
|
|
3432
|
+
E("span", {
|
|
3433
|
+
class: "xml-node__equals",
|
|
3434
|
+
style: I({ color: g.theme.colors.xmlEquals })
|
|
3435
|
+
}, "=", 4),
|
|
3436
|
+
E("span", {
|
|
3437
|
+
class: "xml-node__quote",
|
|
3438
|
+
style: I({ color: g.theme.colors.xmlQuote })
|
|
3439
|
+
}, '"', 4),
|
|
3440
|
+
E("span", {
|
|
3441
|
+
class: "xml-node__attr-value",
|
|
3442
|
+
style: I({ color: g.theme.colors.xmlAttributeValue })
|
|
3443
|
+
}, R(j), 5),
|
|
3444
|
+
E("span", {
|
|
3445
|
+
class: "xml-node__quote",
|
|
3446
|
+
style: I({ color: g.theme.colors.xmlQuote })
|
|
3447
|
+
}, '"', 4)
|
|
3448
|
+
]))), 128)),
|
|
3449
|
+
O.value ? (x(), N("span", {
|
|
3450
|
+
key: 2,
|
|
3451
|
+
class: "xml-node__clickable-part",
|
|
3452
|
+
onClick: T[1] || (T[1] = (j) => M()),
|
|
3453
|
+
title: o.value ? "Click to collapse" : "Click to expand"
|
|
3454
|
+
}, [
|
|
3455
|
+
E("span", {
|
|
3456
|
+
class: "xml-node__bracket",
|
|
3457
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3458
|
+
}, ">", 4)
|
|
3459
|
+
], 8, an)) : (x(), N("span", {
|
|
3460
|
+
key: 3,
|
|
3461
|
+
class: "xml-node__bracket",
|
|
3462
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3463
|
+
}, R(O.value ? ">" : "/>"), 5)),
|
|
3464
|
+
!o.value && O.value ? (x(), N("span", {
|
|
3465
|
+
key: 4,
|
|
3466
|
+
class: "xml-node__collapsed xml-node__collapsed--clickable",
|
|
3467
|
+
style: I({ color: g.theme.colors.textSecondary }),
|
|
3468
|
+
onClick: T[2] || (T[2] = (j) => M()),
|
|
3469
|
+
title: "Click to expand"
|
|
3470
|
+
}, "...", 4)) : F("", !0)
|
|
3471
|
+
]),
|
|
3472
|
+
o.value && O.value ? (x(), N("div", ln, [
|
|
3473
|
+
C.value.length === 0 && f.value.trim() ? (x(), N("div", un, [
|
|
3474
|
+
E("span", {
|
|
3475
|
+
class: "xml-node__text-content",
|
|
3476
|
+
style: I({ color: g.theme.colors.xmlText })
|
|
3477
|
+
}, R(f.value), 5)
|
|
3478
|
+
])) : F("", !0),
|
|
3479
|
+
(x(!0), N(he, null, pe(C.value, (j, Y) => (x(), Xe(X, {
|
|
3480
|
+
key: S(j, Y),
|
|
3481
|
+
value: j.value,
|
|
3482
|
+
"tag-name": j.tagName,
|
|
3483
|
+
level: g.level + 1,
|
|
3484
|
+
path: k(j.tagName, Y),
|
|
3485
|
+
expanded: g.expanded,
|
|
3486
|
+
theme: g.theme,
|
|
3487
|
+
onToggleExpand: T[3] || (T[3] = (Z) => g.$emit("toggle-expand", Z)),
|
|
3488
|
+
onCopy: T[4] || (T[4] = (Z) => g.$emit("copy", Z))
|
|
3489
|
+
}, null, 8, ["value", "tag-name", "level", "path", "expanded", "theme"]))), 128))
|
|
3490
|
+
])) : F("", !0),
|
|
3491
|
+
o.value && O.value ? (x(), N("div", cn, [
|
|
3492
|
+
E("span", {
|
|
3493
|
+
class: "xml-node__clickable-part",
|
|
3494
|
+
onClick: T[5] || (T[5] = (j) => M()),
|
|
3495
|
+
title: "Click to collapse"
|
|
3496
|
+
}, [
|
|
3497
|
+
E("span", {
|
|
3498
|
+
class: "xml-node__bracket",
|
|
3499
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3500
|
+
}, "</", 4),
|
|
3501
|
+
E("span", {
|
|
3502
|
+
class: "xml-node__tag",
|
|
3503
|
+
style: I({ color: g.theme.colors.xmlTag })
|
|
3504
|
+
}, R(g.tagName), 5),
|
|
3505
|
+
E("span", {
|
|
3506
|
+
class: "xml-node__bracket",
|
|
3507
|
+
style: I({ color: g.theme.colors.xmlBracket })
|
|
3508
|
+
}, ">", 4)
|
|
3509
|
+
])
|
|
3510
|
+
])) : F("", !0)
|
|
3511
|
+
]))
|
|
3512
|
+
])) : u.value ? (x(), N("div", dn, [
|
|
3513
|
+
E("span", {
|
|
3514
|
+
class: "xml-node__text-content",
|
|
3515
|
+
style: I({ color: g.theme.colors.xmlText })
|
|
3516
|
+
}, R(f.value), 5)
|
|
3517
|
+
])) : a.value ? (x(), N("div", fn, [
|
|
3518
|
+
E("span", {
|
|
3519
|
+
style: I({ color: g.theme.colors.xmlComment })
|
|
3520
|
+
}, " <!-- " + R(y.value) + " --> ", 5)
|
|
3521
|
+
])) : l.value ? (x(), N("div", hn, [
|
|
3522
|
+
E("span", {
|
|
3523
|
+
style: I({ color: g.theme.colors.xmlCdata })
|
|
3524
|
+
}, " <![CDATA[" + R(m.value) + "]]> ", 5)
|
|
3525
|
+
])) : F("", !0)
|
|
3526
|
+
], 4);
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
}), gn = /* @__PURE__ */ me(pn, [["__scopeId", "data-v-c3ce3f83"]]), bn = {
|
|
3530
|
+
name: "github-light",
|
|
3531
|
+
colors: {
|
|
3532
|
+
// 背景色
|
|
3533
|
+
background: "#ffffff",
|
|
3534
|
+
surfaceBackground: "#f6f8fa",
|
|
3535
|
+
// 边框色
|
|
3536
|
+
border: "#d0d7de",
|
|
3537
|
+
// 文本色
|
|
3538
|
+
text: "#24292f",
|
|
3539
|
+
textSecondary: "#57606a",
|
|
3540
|
+
// 按钮样式
|
|
3541
|
+
buttonBackground: "#f6f8fa",
|
|
3542
|
+
buttonBackgroundHover: "#f3f4f6",
|
|
3543
|
+
buttonBorder: "#d0d7de",
|
|
3544
|
+
buttonText: "#24292f",
|
|
3545
|
+
buttonPrimary: "#1f883d",
|
|
3546
|
+
buttonPrimaryHover: "#1a7f37",
|
|
3547
|
+
// 状态指示
|
|
3548
|
+
success: "#1f883d",
|
|
3549
|
+
successBackground: "#dafbe1",
|
|
3550
|
+
error: "#cf222e",
|
|
3551
|
+
errorBackground: "#ffebe9",
|
|
3552
|
+
// XML 语法高亮
|
|
3553
|
+
xmlTag: "#116329",
|
|
3554
|
+
// 标签名 - 绿色
|
|
3555
|
+
xmlAttribute: "#0550ae",
|
|
3556
|
+
// 属性名 - 蓝色
|
|
3557
|
+
xmlAttributeValue: "#0a3069",
|
|
3558
|
+
// 属性值 - 深蓝
|
|
3559
|
+
xmlText: "#24292f",
|
|
3560
|
+
// 文本内容 - 黑色
|
|
3561
|
+
xmlComment: "#6e7781",
|
|
3562
|
+
// 注释 - 灰色
|
|
3563
|
+
xmlCdata: "#8250df",
|
|
3564
|
+
// CDATA - 紫色
|
|
3565
|
+
xmlDeclaration: "#953800",
|
|
3566
|
+
// 声明 - 橙色
|
|
3567
|
+
xmlBracket: "#6e7781",
|
|
3568
|
+
// 括号 - 灰色
|
|
3569
|
+
xmlEquals: "#6e7781",
|
|
3570
|
+
// 等号 - 灰色
|
|
3571
|
+
xmlQuote: "#0550ae"
|
|
3572
|
+
// 引号 - 蓝色
|
|
3573
|
+
}
|
|
3574
|
+
}, mn = {
|
|
3575
|
+
name: "github-dark",
|
|
3576
|
+
colors: {
|
|
3577
|
+
// 背景色
|
|
3578
|
+
background: "#0d1117",
|
|
3579
|
+
surfaceBackground: "#161b22",
|
|
3580
|
+
// 边框色
|
|
3581
|
+
border: "#30363d",
|
|
3582
|
+
// 文本色
|
|
3583
|
+
text: "#c9d1d9",
|
|
3584
|
+
textSecondary: "#8b949e",
|
|
3585
|
+
// 按钮样式
|
|
3586
|
+
buttonBackground: "#21262d",
|
|
3587
|
+
buttonBackgroundHover: "#30363d",
|
|
3588
|
+
buttonBorder: "#30363d",
|
|
3589
|
+
buttonText: "#c9d1d9",
|
|
3590
|
+
buttonPrimary: "#238636",
|
|
3591
|
+
buttonPrimaryHover: "#2ea043",
|
|
3592
|
+
// 状态指示
|
|
3593
|
+
success: "#3fb950",
|
|
3594
|
+
successBackground: "#0f2e1c",
|
|
3595
|
+
error: "#f85149",
|
|
3596
|
+
errorBackground: "#3d1319",
|
|
3597
|
+
// XML 语法高亮
|
|
3598
|
+
xmlTag: "#7ee787",
|
|
3599
|
+
// 标签名 - 亮绿色
|
|
3600
|
+
xmlAttribute: "#79c0ff",
|
|
3601
|
+
// 属性名 - 亮蓝色
|
|
3602
|
+
xmlAttributeValue: "#a5d6ff",
|
|
3603
|
+
// 属性值 - 淡蓝色
|
|
3604
|
+
xmlText: "#c9d1d9",
|
|
3605
|
+
// 文本内容 - 白色
|
|
3606
|
+
xmlComment: "#8b949e",
|
|
3607
|
+
// 注释 - 灰色
|
|
3608
|
+
xmlCdata: "#d2a8ff",
|
|
3609
|
+
// CDATA - 紫色
|
|
3610
|
+
xmlDeclaration: "#ffa657",
|
|
3611
|
+
// 声明 - 橙色
|
|
3612
|
+
xmlBracket: "#8b949e",
|
|
3613
|
+
// 括号 - 灰色
|
|
3614
|
+
xmlEquals: "#8b949e",
|
|
3615
|
+
// 等号 - 灰色
|
|
3616
|
+
xmlQuote: "#79c0ff"
|
|
3617
|
+
// 引号 - 亮蓝色
|
|
3618
|
+
}
|
|
3619
|
+
}, yn = {
|
|
3620
|
+
name: "min-light",
|
|
3621
|
+
colors: {
|
|
3622
|
+
// 背景色
|
|
3623
|
+
background: "#ffffff",
|
|
3624
|
+
surfaceBackground: "#fafafa",
|
|
3625
|
+
// 边框色
|
|
3626
|
+
border: "#e5e5e5",
|
|
3627
|
+
// 文本色
|
|
3628
|
+
text: "#171717",
|
|
3629
|
+
textSecondary: "#737373",
|
|
3630
|
+
// 按钮样式
|
|
3631
|
+
buttonBackground: "#fafafa",
|
|
3632
|
+
buttonBackgroundHover: "#f5f5f5",
|
|
3633
|
+
buttonBorder: "#e5e5e5",
|
|
3634
|
+
buttonText: "#171717",
|
|
3635
|
+
buttonPrimary: "#22c55e",
|
|
3636
|
+
buttonPrimaryHover: "#16a34a",
|
|
3637
|
+
// 状态指示
|
|
3638
|
+
success: "#22c55e",
|
|
3639
|
+
successBackground: "#dcfce7",
|
|
3640
|
+
error: "#ef4444",
|
|
3641
|
+
errorBackground: "#fee2e2",
|
|
3642
|
+
// XML 语法高亮
|
|
3643
|
+
xmlTag: "#16a34a",
|
|
3644
|
+
// 标签名 - 绿色
|
|
3645
|
+
xmlAttribute: "#2563eb",
|
|
3646
|
+
// 属性名 - 蓝色
|
|
3647
|
+
xmlAttributeValue: "#1e40af",
|
|
3648
|
+
// 属性值 - 深蓝
|
|
3649
|
+
xmlText: "#171717",
|
|
3650
|
+
// 文本内容 - 黑色
|
|
3651
|
+
xmlComment: "#737373",
|
|
3652
|
+
// 注释 - 灰色
|
|
3653
|
+
xmlCdata: "#9333ea",
|
|
3654
|
+
// CDATA - 紫色
|
|
3655
|
+
xmlDeclaration: "#ea580c",
|
|
3656
|
+
// 声明 - 橙色
|
|
3657
|
+
xmlBracket: "#737373",
|
|
3658
|
+
// 括号 - 灰色
|
|
3659
|
+
xmlEquals: "#737373",
|
|
3660
|
+
// 等号 - 灰色
|
|
3661
|
+
xmlQuote: "#2563eb"
|
|
3662
|
+
// 引号 - 蓝色
|
|
3663
|
+
}
|
|
3664
|
+
}, En = {
|
|
3665
|
+
name: "slack-ochin",
|
|
3666
|
+
colors: {
|
|
3667
|
+
// 背景色
|
|
3668
|
+
background: "#fef5ed",
|
|
3669
|
+
surfaceBackground: "#fef9f3",
|
|
3670
|
+
// 边框色
|
|
3671
|
+
border: "#e9dcc9",
|
|
3672
|
+
// 文本色
|
|
3673
|
+
text: "#3d3c40",
|
|
3674
|
+
textSecondary: "#616061",
|
|
3675
|
+
// 按钮样式
|
|
3676
|
+
buttonBackground: "#fef9f3",
|
|
3677
|
+
buttonBackgroundHover: "#f9f0e5",
|
|
3678
|
+
buttonBorder: "#e9dcc9",
|
|
3679
|
+
buttonText: "#3d3c40",
|
|
3680
|
+
buttonPrimary: "#007a5a",
|
|
3681
|
+
buttonPrimaryHover: "#006644",
|
|
3682
|
+
// 状态指示
|
|
3683
|
+
success: "#007a5a",
|
|
3684
|
+
successBackground: "#d1f4e0",
|
|
3685
|
+
error: "#e01e5a",
|
|
3686
|
+
errorBackground: "#ffdbea",
|
|
3687
|
+
// XML 语法高亮
|
|
3688
|
+
xmlTag: "#007a5a",
|
|
3689
|
+
// 标签名 - 绿色
|
|
3690
|
+
xmlAttribute: "#1264a3",
|
|
3691
|
+
// 属性名 - 蓝色
|
|
3692
|
+
xmlAttributeValue: "#0b4c8c",
|
|
3693
|
+
// 属性值 - 深蓝
|
|
3694
|
+
xmlText: "#3d3c40",
|
|
3695
|
+
// 文本内容 - 黑色
|
|
3696
|
+
xmlComment: "#616061",
|
|
3697
|
+
// 注释 - 灰色
|
|
3698
|
+
xmlCdata: "#8b2eff",
|
|
3699
|
+
// CDATA - 紫色
|
|
3700
|
+
xmlDeclaration: "#e8912d",
|
|
3701
|
+
// 声明 - 橙色
|
|
3702
|
+
xmlBracket: "#616061",
|
|
3703
|
+
// 括号 - 灰色
|
|
3704
|
+
xmlEquals: "#616061",
|
|
3705
|
+
// 等号 - 灰色
|
|
3706
|
+
xmlQuote: "#1264a3"
|
|
3707
|
+
// 引号 - 蓝色
|
|
3708
|
+
}
|
|
3709
|
+
}, je = {
|
|
3710
|
+
"github-light": bn,
|
|
3711
|
+
"github-dark": mn,
|
|
3712
|
+
"min-light": yn,
|
|
3713
|
+
"slack-ochin": En
|
|
3714
|
+
}, vn = (r) => je[r] || je["github-light"], _n = {
|
|
3715
|
+
key: 0,
|
|
3716
|
+
class: "xml-format__toolbar"
|
|
3717
|
+
}, xn = { class: "xml-format__actions" }, Nn = ["disabled"], kn = ["disabled"], wn = ["disabled"], An = ["disabled"], Cn = ["disabled"], On = { class: "xml-format__info" }, Tn = {
|
|
3718
|
+
key: 0,
|
|
3719
|
+
class: "xml-format__status xml-format__status--success"
|
|
3720
|
+
}, Pn = {
|
|
3721
|
+
key: 1,
|
|
3722
|
+
class: "xml-format__status xml-format__status--error"
|
|
3723
|
+
}, Sn = { class: "xml-format__content" }, In = {
|
|
3724
|
+
key: 0,
|
|
3725
|
+
class: "xml-format__error"
|
|
3726
|
+
}, $n = {
|
|
3727
|
+
key: 1,
|
|
3728
|
+
class: "xml-format__viewer"
|
|
3729
|
+
}, Bn = /* @__PURE__ */ be({
|
|
3730
|
+
__name: "index",
|
|
3731
|
+
props: {
|
|
3732
|
+
modelValue: { default: "" },
|
|
3733
|
+
readonly: { type: Boolean, default: !1 },
|
|
3734
|
+
maxDepth: { default: 10 },
|
|
3735
|
+
showToolbar: { type: Boolean, default: !0 },
|
|
3736
|
+
theme: { default: "github-light" },
|
|
3737
|
+
showComments: { type: Boolean, default: !0 },
|
|
3738
|
+
showCdata: { type: Boolean, default: !0 },
|
|
3739
|
+
preserveWhitespace: { type: Boolean, default: !1 }
|
|
3740
|
+
},
|
|
3741
|
+
emits: ["update:modelValue", "copy-success", "copy-error", "expand-all", "collapse-all", "compress", "format"],
|
|
3742
|
+
setup(r, { emit: e }) {
|
|
3743
|
+
Ce((k) => ({
|
|
3744
|
+
"5da93aa4": a.value.colors.border,
|
|
3745
|
+
"138f9aa0": a.value.colors.background,
|
|
3746
|
+
"9abf940e": a.value.colors.surfaceBackground,
|
|
3747
|
+
"78705f00": a.value.colors.buttonBorder,
|
|
3748
|
+
"3f22b602": a.value.colors.buttonBackground,
|
|
3749
|
+
"5afed501": a.value.colors.buttonText,
|
|
3750
|
+
"7fb3945a": a.value.colors.buttonBackgroundHover,
|
|
3751
|
+
"7ed67dae": a.value.colors.buttonPrimary,
|
|
3752
|
+
"5c748fa4": a.value.colors.buttonPrimaryHover,
|
|
3753
|
+
"3e17bc7e": a.value.colors.success,
|
|
3754
|
+
"22d3d5cf": a.value.colors.successBackground,
|
|
3755
|
+
"0f2d0b46": a.value.colors.error,
|
|
3756
|
+
"6c8e5d14": a.value.colors.errorBackground,
|
|
3757
|
+
"7c62ec2f": a.value.colors.text
|
|
3758
|
+
}));
|
|
3759
|
+
const t = r, s = e, n = G(null), o = G(""), i = G(/* @__PURE__ */ new Set()), u = L(() => o.value === ""), a = L(() => vn(t.theme)), l = L(() => {
|
|
3760
|
+
if (!n.value) return {};
|
|
3761
|
+
const k = {};
|
|
3762
|
+
return Object.keys(n.value).forEach((S) => {
|
|
3763
|
+
!S.startsWith("?") && !S.startsWith("#") && (k[S] = n.value[S]);
|
|
3764
|
+
}), k;
|
|
3765
|
+
}), h = (k) => {
|
|
3766
|
+
if (!k || !k.trim()) {
|
|
3767
|
+
o.value = "XML string is empty", n.value = null;
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
try {
|
|
3771
|
+
const S = Wr(k);
|
|
3772
|
+
if (!S.valid) {
|
|
3773
|
+
o.value = S.error || "Invalid XML", n.value = null;
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3776
|
+
n.value = ze(k), o.value = "", ce(() => {
|
|
3777
|
+
Object.keys(l.value).forEach((g) => {
|
|
3778
|
+
i.value.add(g);
|
|
3779
|
+
});
|
|
3780
|
+
});
|
|
3781
|
+
} catch (S) {
|
|
3782
|
+
o.value = S instanceof Error ? S.message : "Unknown parse error", n.value = null;
|
|
3783
|
+
}
|
|
3784
|
+
}, f = (k) => {
|
|
3785
|
+
i.value.has(k) ? i.value.delete(k) : i.value.add(k);
|
|
3786
|
+
}, y = () => {
|
|
3787
|
+
const k = /* @__PURE__ */ new Set(), S = (g, T = "") => {
|
|
3788
|
+
g !== null && typeof g == "object" && (T && k.add(T), Object.keys(g).forEach((X) => {
|
|
3789
|
+
if (X.startsWith("@_") || X === "#text") return;
|
|
3790
|
+
const j = g[X], Y = T ? `${T}.${X}[0]` : X;
|
|
3791
|
+
Array.isArray(j) ? j.forEach((Z, D) => {
|
|
3792
|
+
const J = T ? `${T}.${X}[${D}]` : `${X}[${D}]`;
|
|
3793
|
+
S(Z, J);
|
|
3794
|
+
}) : S(j, Y);
|
|
3795
|
+
}));
|
|
3796
|
+
};
|
|
3797
|
+
Object.keys(l.value).forEach((g) => {
|
|
3798
|
+
S(l.value[g], g);
|
|
3799
|
+
}), i.value = k, s("expand-all");
|
|
3800
|
+
}, m = () => {
|
|
3801
|
+
i.value.clear(), s("collapse-all");
|
|
3802
|
+
}, C = async () => {
|
|
3803
|
+
if (!(!u.value || !n.value))
|
|
3804
|
+
try {
|
|
3805
|
+
const k = Te(n.value, {
|
|
3806
|
+
format: !0,
|
|
3807
|
+
indentBy: " "
|
|
3808
|
+
});
|
|
3809
|
+
await navigator.clipboard.writeText(k), s("copy-success", k);
|
|
3810
|
+
} catch (k) {
|
|
3811
|
+
const S = k instanceof Error ? k : new Error("Copy failed");
|
|
3812
|
+
s("copy-error", S), console.error("Failed to copy XML:", k);
|
|
3813
|
+
}
|
|
3814
|
+
}, O = () => {
|
|
3815
|
+
if (!(!u.value || !n.value))
|
|
3816
|
+
try {
|
|
3817
|
+
const k = Zr(n.value);
|
|
3818
|
+
s("update:modelValue", k), s("compress", k);
|
|
3819
|
+
} catch (k) {
|
|
3820
|
+
console.error("Failed to compress XML:", k);
|
|
3821
|
+
}
|
|
3822
|
+
}, P = () => {
|
|
3823
|
+
if (u.value)
|
|
3824
|
+
try {
|
|
3825
|
+
const k = zr(t.modelValue, {
|
|
3826
|
+
format: !0,
|
|
3827
|
+
indentBy: " "
|
|
3828
|
+
});
|
|
3829
|
+
s("update:modelValue", k), s("format", k);
|
|
3830
|
+
} catch (k) {
|
|
3831
|
+
console.error("Failed to format XML:", k);
|
|
3832
|
+
}
|
|
3833
|
+
}, M = async (k) => {
|
|
3834
|
+
try {
|
|
3835
|
+
const S = typeof k == "string" ? k : JSON.stringify(k, null, 2);
|
|
3836
|
+
await navigator.clipboard.writeText(S), s("copy-success", S);
|
|
3837
|
+
} catch (S) {
|
|
3838
|
+
const g = S instanceof Error ? S : new Error("Copy failed");
|
|
3839
|
+
s("copy-error", g), console.error("Failed to copy value:", S);
|
|
3840
|
+
}
|
|
3841
|
+
};
|
|
3842
|
+
return Fe(() => t.modelValue, (k) => {
|
|
3843
|
+
h(k);
|
|
3844
|
+
}, { immediate: !0 }), (k, S) => (x(), N("div", {
|
|
3845
|
+
class: Oe(["xml-format", `xml-format--${a.value.name}`])
|
|
3846
|
+
}, [
|
|
3847
|
+
k.showToolbar ? (x(), N("div", _n, [
|
|
3848
|
+
E("div", xn, [
|
|
3849
|
+
E("button", {
|
|
3850
|
+
class: "xml-format__btn xml-format__btn--primary",
|
|
3851
|
+
onClick: C,
|
|
3852
|
+
disabled: !u.value,
|
|
3853
|
+
title: "Copy XML"
|
|
3854
|
+
}, " 📋 Copy ", 8, Nn),
|
|
3855
|
+
E("button", {
|
|
3856
|
+
class: "xml-format__btn xml-format__btn--secondary",
|
|
3857
|
+
onClick: y,
|
|
3858
|
+
disabled: !u.value,
|
|
3859
|
+
title: "Expand All"
|
|
3860
|
+
}, " ⬇️ Expand All ", 8, kn),
|
|
3861
|
+
E("button", {
|
|
3862
|
+
class: "xml-format__btn xml-format__btn--secondary",
|
|
3863
|
+
onClick: m,
|
|
3864
|
+
disabled: !u.value,
|
|
3865
|
+
title: "Collapse All"
|
|
3866
|
+
}, " ➡️ Collapse All ", 8, wn),
|
|
3867
|
+
E("button", {
|
|
3868
|
+
class: "xml-format__btn xml-format__btn--secondary",
|
|
3869
|
+
onClick: O,
|
|
3870
|
+
disabled: !u.value,
|
|
3871
|
+
title: "Compress XML"
|
|
3872
|
+
}, " 📦 Compress ", 8, An),
|
|
3873
|
+
E("button", {
|
|
3874
|
+
class: "xml-format__btn xml-format__btn--secondary",
|
|
3875
|
+
onClick: P,
|
|
3876
|
+
disabled: !u.value,
|
|
3877
|
+
title: "Format XML"
|
|
3878
|
+
}, " ✨ Format ", 8, Cn)
|
|
3879
|
+
]),
|
|
3880
|
+
E("div", On, [
|
|
3881
|
+
u.value ? (x(), N("span", Tn, " ✅ Valid XML ")) : (x(), N("span", Pn, " ❌ Invalid XML "))
|
|
3882
|
+
])
|
|
3883
|
+
])) : F("", !0),
|
|
3884
|
+
E("div", Sn, [
|
|
3885
|
+
u.value ? (x(), N("div", $n, [
|
|
3886
|
+
(x(!0), N(he, null, pe(l.value, (g, T) => (x(), Xe(gn, {
|
|
3887
|
+
key: String(T),
|
|
3888
|
+
value: g,
|
|
3889
|
+
"tag-name": String(T),
|
|
3890
|
+
level: 0,
|
|
3891
|
+
expanded: i.value,
|
|
3892
|
+
theme: a.value,
|
|
3893
|
+
onToggleExpand: f,
|
|
3894
|
+
onCopy: M
|
|
3895
|
+
}, null, 8, ["value", "tag-name", "expanded", "theme"]))), 128))
|
|
3896
|
+
])) : (x(), N("div", In, [
|
|
3897
|
+
S[0] || (S[0] = E("h4", null, "XML Parse Error:", -1)),
|
|
3898
|
+
E("pre", null, R(o.value), 1)
|
|
2034
3899
|
]))
|
|
2035
3900
|
])
|
|
2036
3901
|
], 2));
|
|
2037
3902
|
}
|
|
2038
|
-
}),
|
|
2039
|
-
|
|
3903
|
+
}), Un = /* @__PURE__ */ me(Bn, [["__scopeId", "data-v-2b795c5a"]]), Ln = [Wt], Vn = (r) => {
|
|
3904
|
+
Ln.forEach((e) => {
|
|
2040
3905
|
const t = e.name || e.__name || "UnknownComponent";
|
|
2041
3906
|
r.component(t, e);
|
|
2042
3907
|
});
|
|
2043
|
-
},
|
|
2044
|
-
install:
|
|
3908
|
+
}, Fn = {
|
|
3909
|
+
install: Vn
|
|
2045
3910
|
};
|
|
2046
3911
|
export {
|
|
2047
|
-
|
|
2048
|
-
|
|
3912
|
+
Wt as JsonFormat,
|
|
3913
|
+
Un as XmlFormat,
|
|
3914
|
+
Fn as default
|
|
2049
3915
|
};
|