jsonc-morph 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -22
- package/esm/lib/rs_lib.internal.d.ts +1120 -129
- package/esm/lib/rs_lib.internal.d.ts.map +1 -1
- package/esm/lib/rs_lib.internal.js +1750 -270
- package/esm/lib/rs_lib.js +3116 -2782
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/package.json +1 -1
- package/script/lib/rs_lib.internal.d.ts +1120 -129
- package/script/lib/rs_lib.internal.d.ts.map +1 -1
- package/script/lib/rs_lib.internal.js +1776 -289
- package/script/lib/rs_lib.js +3116 -2782
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +8 -1
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// deno-lint-ignore-file
|
|
5
5
|
// deno-fmt-ignore-file
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.RootNode = exports.ObjectProp = exports.Node = exports.JsonObject = exports.JsonArray = void 0;
|
|
7
|
+
exports.WordLit = exports.StringLit = exports.RootNode = exports.ObjectPropName = exports.ObjectProp = exports.NumberLit = exports.NullKeyword = exports.Node = exports.JsonObject = exports.JsonArray = exports.BooleanLit = void 0;
|
|
8
8
|
exports.__wbg_set_wasm = __wbg_set_wasm;
|
|
9
|
+
exports.parse = parse;
|
|
9
10
|
exports.__wbg_Error_90f14b053b2af32f = __wbg_Error_90f14b053b2af32f;
|
|
10
11
|
exports.__wbg_String_8f0eb39a4a4c2f66 = __wbg_String_8f0eb39a4a4c2f66;
|
|
11
12
|
exports.__wbg_call_90bf4b9978d51034 = __wbg_call_90bf4b9978d51034;
|
|
@@ -234,6 +235,24 @@ function takeFromExternrefTable0(idx) {
|
|
|
234
235
|
wasm.__externref_table_dealloc(idx);
|
|
235
236
|
return value;
|
|
236
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Parses a JSONC (JSON with Comments) string into a concrete syntax tree.
|
|
240
|
+
* @param text - The JSONC text to parse
|
|
241
|
+
* @param options - Optional parsing options
|
|
242
|
+
* @returns The root node of the parsed CST
|
|
243
|
+
* @param {string} text
|
|
244
|
+
* @param {{ allowComments?: boolean; allowTrailingCommas?: boolean; allowLooseObjectPropertyNames?: boolean; } | null} [options]
|
|
245
|
+
* @returns {RootNode}
|
|
246
|
+
*/
|
|
247
|
+
function parse(text, options) {
|
|
248
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
250
|
+
const ret = wasm.parse(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
251
|
+
if (ret[2]) {
|
|
252
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
253
|
+
}
|
|
254
|
+
return RootNode.__wrap(ret[0]);
|
|
255
|
+
}
|
|
237
256
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
238
257
|
ptr = ptr >>> 0;
|
|
239
258
|
const mem = getDataViewMemory0();
|
|
@@ -244,9 +263,180 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
244
263
|
wasm.__externref_drop_slice(ptr, len);
|
|
245
264
|
return result;
|
|
246
265
|
}
|
|
266
|
+
const BooleanLitFinalization = (typeof FinalizationRegistry === "undefined")
|
|
267
|
+
? { register: () => { }, unregister: () => { } }
|
|
268
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_booleanlit_free(ptr >>> 0, 1));
|
|
269
|
+
/**
|
|
270
|
+
* Represents a boolean literal node in the CST.
|
|
271
|
+
* Provides methods for manipulating boolean values.
|
|
272
|
+
*/
|
|
273
|
+
class BooleanLit {
|
|
274
|
+
static __wrap(ptr) {
|
|
275
|
+
ptr = ptr >>> 0;
|
|
276
|
+
const obj = Object.create(BooleanLit.prototype);
|
|
277
|
+
obj.__wbg_ptr = ptr;
|
|
278
|
+
BooleanLitFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
279
|
+
return obj;
|
|
280
|
+
}
|
|
281
|
+
__destroy_into_raw() {
|
|
282
|
+
const ptr = this.__wbg_ptr;
|
|
283
|
+
this.__wbg_ptr = 0;
|
|
284
|
+
BooleanLitFinalization.unregister(this);
|
|
285
|
+
return ptr;
|
|
286
|
+
}
|
|
287
|
+
free() {
|
|
288
|
+
const ptr = this.__destroy_into_raw();
|
|
289
|
+
wasm.__wbg_booleanlit_free(ptr, 0);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Returns the boolean value (true or false).
|
|
293
|
+
* @returns The boolean value
|
|
294
|
+
* @returns {boolean}
|
|
295
|
+
*/
|
|
296
|
+
value() {
|
|
297
|
+
const ret = wasm.booleanlit_value(this.__wbg_ptr);
|
|
298
|
+
return ret !== 0;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Sets the boolean value.
|
|
302
|
+
* @param value - The new boolean value (true or false)
|
|
303
|
+
* @param {boolean} value
|
|
304
|
+
*/
|
|
305
|
+
setValue(value) {
|
|
306
|
+
wasm.booleanlit_setValue(this.__wbg_ptr, value);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Replaces this boolean literal with a new value.
|
|
310
|
+
* @param replacement - The new value to replace this boolean with
|
|
311
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
312
|
+
* @param {any} replacement
|
|
313
|
+
* @returns {Node | undefined}
|
|
314
|
+
*/
|
|
315
|
+
replaceWith(replacement) {
|
|
316
|
+
const ret = wasm.booleanlit_replaceWith(this.__wbg_ptr, replacement);
|
|
317
|
+
if (ret[2]) {
|
|
318
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
319
|
+
}
|
|
320
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Removes this node from its parent.
|
|
324
|
+
* After calling this method, the node is detached from the CST and can no longer be used.
|
|
325
|
+
*/
|
|
326
|
+
remove() {
|
|
327
|
+
const ptr = this.__destroy_into_raw();
|
|
328
|
+
wasm.booleanlit_remove(ptr);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Returns the parent node in the CST.
|
|
332
|
+
* @returns The parent node, or undefined if this is the root
|
|
333
|
+
* @returns {Node | undefined}
|
|
334
|
+
*/
|
|
335
|
+
parent() {
|
|
336
|
+
const ret = wasm.booleanlit_parent(this.__wbg_ptr);
|
|
337
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Returns all ancestor nodes from parent to root.
|
|
341
|
+
* @returns Array of ancestor nodes
|
|
342
|
+
* @returns {Node[]}
|
|
343
|
+
*/
|
|
344
|
+
ancestors() {
|
|
345
|
+
const ret = wasm.booleanlit_ancestors(this.__wbg_ptr);
|
|
346
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
347
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
348
|
+
return v1;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns the index of this node within its parent's children.
|
|
352
|
+
* @returns The child index
|
|
353
|
+
* @returns {number}
|
|
354
|
+
*/
|
|
355
|
+
childIndex() {
|
|
356
|
+
const ret = wasm.booleanlit_childIndex(this.__wbg_ptr);
|
|
357
|
+
return ret >>> 0;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Returns the previous sibling node.
|
|
361
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
362
|
+
* @returns {Node | undefined}
|
|
363
|
+
*/
|
|
364
|
+
previousSibling() {
|
|
365
|
+
const ret = wasm.booleanlit_previousSibling(this.__wbg_ptr);
|
|
366
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Returns all previous sibling nodes.
|
|
370
|
+
* @returns Array of previous siblings
|
|
371
|
+
* @returns {Node[]}
|
|
372
|
+
*/
|
|
373
|
+
previousSiblings() {
|
|
374
|
+
const ret = wasm.booleanlit_previousSiblings(this.__wbg_ptr);
|
|
375
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
376
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
377
|
+
return v1;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Returns the next sibling node.
|
|
381
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
382
|
+
* @returns {Node | undefined}
|
|
383
|
+
*/
|
|
384
|
+
nextSibling() {
|
|
385
|
+
const ret = wasm.booleanlit_nextSibling(this.__wbg_ptr);
|
|
386
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Returns all next sibling nodes.
|
|
390
|
+
* @returns Array of next siblings
|
|
391
|
+
* @returns {Node[]}
|
|
392
|
+
*/
|
|
393
|
+
nextSiblings() {
|
|
394
|
+
const ret = wasm.booleanlit_nextSiblings(this.__wbg_ptr);
|
|
395
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
396
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
397
|
+
return v1;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Returns the root node of the document.
|
|
401
|
+
* @returns The root node, or undefined if detached
|
|
402
|
+
* @returns {RootNode | undefined}
|
|
403
|
+
*/
|
|
404
|
+
rootNode() {
|
|
405
|
+
const ret = wasm.booleanlit_rootNode(this.__wbg_ptr);
|
|
406
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Returns the indentation string used at this node's depth.
|
|
410
|
+
* @returns The indentation string, or undefined if not applicable
|
|
411
|
+
* @returns {string | undefined}
|
|
412
|
+
*/
|
|
413
|
+
indentText() {
|
|
414
|
+
const ret = wasm.booleanlit_indentText(this.__wbg_ptr);
|
|
415
|
+
let v1;
|
|
416
|
+
if (ret[0] !== 0) {
|
|
417
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
418
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
419
|
+
}
|
|
420
|
+
return v1;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Returns whether this node's container uses trailing commas.
|
|
424
|
+
* @returns true if trailing commas are used
|
|
425
|
+
* @returns {boolean}
|
|
426
|
+
*/
|
|
427
|
+
usesTrailingCommas() {
|
|
428
|
+
const ret = wasm.booleanlit_usesTrailingCommas(this.__wbg_ptr);
|
|
429
|
+
return ret !== 0;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
exports.BooleanLit = BooleanLit;
|
|
247
433
|
const JsonArrayFinalization = (typeof FinalizationRegistry === "undefined")
|
|
248
434
|
? { register: () => { }, unregister: () => { } }
|
|
249
435
|
: new FinalizationRegistry((ptr) => wasm.__wbg_jsonarray_free(ptr >>> 0, 1));
|
|
436
|
+
/**
|
|
437
|
+
* Represents a JSON array node in the CST.
|
|
438
|
+
* Provides methods for manipulating array elements.
|
|
439
|
+
*/
|
|
250
440
|
class JsonArray {
|
|
251
441
|
static __wrap(ptr) {
|
|
252
442
|
ptr = ptr >>> 0;
|
|
@@ -266,6 +456,8 @@ class JsonArray {
|
|
|
266
456
|
wasm.__wbg_jsonarray_free(ptr, 0);
|
|
267
457
|
}
|
|
268
458
|
/**
|
|
459
|
+
* Returns all element nodes in the array.
|
|
460
|
+
* @returns Array of element nodes
|
|
269
461
|
* @returns {Node[]}
|
|
270
462
|
*/
|
|
271
463
|
elements() {
|
|
@@ -274,14 +466,23 @@ class JsonArray {
|
|
|
274
466
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
275
467
|
return v1;
|
|
276
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Removes this array from its parent.
|
|
471
|
+
* After calling this method, the array is detached from the CST and can no longer be used.
|
|
472
|
+
*/
|
|
277
473
|
remove() {
|
|
278
474
|
const ptr = this.__destroy_into_raw();
|
|
279
475
|
wasm.jsonarray_remove(ptr);
|
|
280
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Ensures the array is formatted with each element on its own line.
|
|
479
|
+
*/
|
|
281
480
|
ensureMultiline() {
|
|
282
481
|
wasm.jsonarray_ensureMultiline(this.__wbg_ptr);
|
|
283
482
|
}
|
|
284
483
|
/**
|
|
484
|
+
* Returns all child nodes including whitespace and punctuation.
|
|
485
|
+
* @returns Array of all child nodes
|
|
285
486
|
* @returns {Node[]}
|
|
286
487
|
*/
|
|
287
488
|
children() {
|
|
@@ -291,6 +492,9 @@ class JsonArray {
|
|
|
291
492
|
return v1;
|
|
292
493
|
}
|
|
293
494
|
/**
|
|
495
|
+
* Appends a new element to the end of the array.
|
|
496
|
+
* @param value - The value to append
|
|
497
|
+
* @returns The newly created element node
|
|
294
498
|
* @param {any} value
|
|
295
499
|
* @returns {Node}
|
|
296
500
|
*/
|
|
@@ -302,6 +506,10 @@ class JsonArray {
|
|
|
302
506
|
return Node.__wrap(ret[0]);
|
|
303
507
|
}
|
|
304
508
|
/**
|
|
509
|
+
* Inserts a new element at the specified index.
|
|
510
|
+
* @param index - The position to insert at
|
|
511
|
+
* @param value - The value to insert
|
|
512
|
+
* @returns The newly created element node
|
|
305
513
|
* @param {number} index
|
|
306
514
|
* @param {any} value
|
|
307
515
|
* @returns {Node}
|
|
@@ -314,22 +522,31 @@ class JsonArray {
|
|
|
314
522
|
return Node.__wrap(ret[0]);
|
|
315
523
|
}
|
|
316
524
|
/**
|
|
525
|
+
* Configures whether trailing commas should be used in this array.
|
|
526
|
+
* When enabled, trailing commas are added for multiline formatting.
|
|
527
|
+
* @param enabled - Whether to enable trailing commas
|
|
317
528
|
* @param {boolean} enabled
|
|
318
529
|
*/
|
|
319
530
|
setTrailingCommas(enabled) {
|
|
320
531
|
wasm.jsonarray_setTrailingCommas(this.__wbg_ptr, enabled);
|
|
321
532
|
}
|
|
322
533
|
/**
|
|
323
|
-
*
|
|
534
|
+
* Replaces this array with a new value.
|
|
535
|
+
* @param value - The new value to replace this array with
|
|
536
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
537
|
+
* @param {any} value
|
|
324
538
|
* @returns {Node | undefined}
|
|
325
539
|
*/
|
|
326
|
-
replaceWith(
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
540
|
+
replaceWith(value) {
|
|
541
|
+
const ret = wasm.jsonarray_replaceWith(this.__wbg_ptr, value);
|
|
542
|
+
if (ret[2]) {
|
|
543
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
544
|
+
}
|
|
545
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
331
546
|
}
|
|
332
547
|
/**
|
|
548
|
+
* Returns the parent node in the CST.
|
|
549
|
+
* @returns The parent node, or undefined if this is the root
|
|
333
550
|
* @returns {Node | undefined}
|
|
334
551
|
*/
|
|
335
552
|
parent() {
|
|
@@ -337,6 +554,8 @@ class JsonArray {
|
|
|
337
554
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
338
555
|
}
|
|
339
556
|
/**
|
|
557
|
+
* Returns the index of this node within its parent's children.
|
|
558
|
+
* @returns The child index
|
|
340
559
|
* @returns {number}
|
|
341
560
|
*/
|
|
342
561
|
childIndex() {
|
|
@@ -344,6 +563,8 @@ class JsonArray {
|
|
|
344
563
|
return ret >>> 0;
|
|
345
564
|
}
|
|
346
565
|
/**
|
|
566
|
+
* Returns all ancestor nodes from parent to root.
|
|
567
|
+
* @returns Array of ancestor nodes
|
|
347
568
|
* @returns {Node[]}
|
|
348
569
|
*/
|
|
349
570
|
ancestors() {
|
|
@@ -353,6 +574,8 @@ class JsonArray {
|
|
|
353
574
|
return v1;
|
|
354
575
|
}
|
|
355
576
|
/**
|
|
577
|
+
* Returns the previous sibling node.
|
|
578
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
356
579
|
* @returns {Node | undefined}
|
|
357
580
|
*/
|
|
358
581
|
previousSibling() {
|
|
@@ -360,6 +583,8 @@ class JsonArray {
|
|
|
360
583
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
361
584
|
}
|
|
362
585
|
/**
|
|
586
|
+
* Returns all previous sibling nodes.
|
|
587
|
+
* @returns Array of previous siblings
|
|
363
588
|
* @returns {Node[]}
|
|
364
589
|
*/
|
|
365
590
|
previousSiblings() {
|
|
@@ -369,6 +594,8 @@ class JsonArray {
|
|
|
369
594
|
return v1;
|
|
370
595
|
}
|
|
371
596
|
/**
|
|
597
|
+
* Returns the next sibling node.
|
|
598
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
372
599
|
* @returns {Node | undefined}
|
|
373
600
|
*/
|
|
374
601
|
nextSibling() {
|
|
@@ -376,6 +603,8 @@ class JsonArray {
|
|
|
376
603
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
377
604
|
}
|
|
378
605
|
/**
|
|
606
|
+
* Returns all next sibling nodes.
|
|
607
|
+
* @returns Array of next siblings
|
|
379
608
|
* @returns {Node[]}
|
|
380
609
|
*/
|
|
381
610
|
nextSiblings() {
|
|
@@ -385,6 +614,8 @@ class JsonArray {
|
|
|
385
614
|
return v1;
|
|
386
615
|
}
|
|
387
616
|
/**
|
|
617
|
+
* Returns the root node of the document.
|
|
618
|
+
* @returns The root node, or undefined if detached
|
|
388
619
|
* @returns {RootNode | undefined}
|
|
389
620
|
*/
|
|
390
621
|
rootNode() {
|
|
@@ -392,6 +623,8 @@ class JsonArray {
|
|
|
392
623
|
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
393
624
|
}
|
|
394
625
|
/**
|
|
626
|
+
* Returns the indentation string used at this node's depth.
|
|
627
|
+
* @returns The indentation string, or undefined if not applicable
|
|
395
628
|
* @returns {string | undefined}
|
|
396
629
|
*/
|
|
397
630
|
indentText() {
|
|
@@ -404,6 +637,8 @@ class JsonArray {
|
|
|
404
637
|
return v1;
|
|
405
638
|
}
|
|
406
639
|
/**
|
|
640
|
+
* Returns whether this node's container uses trailing commas.
|
|
641
|
+
* @returns true if trailing commas are used
|
|
407
642
|
* @returns {boolean}
|
|
408
643
|
*/
|
|
409
644
|
usesTrailingCommas() {
|
|
@@ -411,6 +646,8 @@ class JsonArray {
|
|
|
411
646
|
return ret !== 0;
|
|
412
647
|
}
|
|
413
648
|
/**
|
|
649
|
+
* Returns child nodes excluding whitespace, comments, and punctuation.
|
|
650
|
+
* @returns Array of significant child nodes
|
|
414
651
|
* @returns {Node[]}
|
|
415
652
|
*/
|
|
416
653
|
childrenExcludeTriviaAndTokens() {
|
|
@@ -420,6 +657,9 @@ class JsonArray {
|
|
|
420
657
|
return v1;
|
|
421
658
|
}
|
|
422
659
|
/**
|
|
660
|
+
* Returns the child node at the specified index.
|
|
661
|
+
* @param index - The child index
|
|
662
|
+
* @returns The child node, or undefined if index is out of bounds
|
|
423
663
|
* @param {number} index
|
|
424
664
|
* @returns {Node | undefined}
|
|
425
665
|
*/
|
|
@@ -432,6 +672,10 @@ exports.JsonArray = JsonArray;
|
|
|
432
672
|
const JsonObjectFinalization = (typeof FinalizationRegistry === "undefined")
|
|
433
673
|
? { register: () => { }, unregister: () => { } }
|
|
434
674
|
: new FinalizationRegistry((ptr) => wasm.__wbg_jsonobject_free(ptr >>> 0, 1));
|
|
675
|
+
/**
|
|
676
|
+
* Represents a JSON object node in the CST.
|
|
677
|
+
* Provides methods for manipulating object properties.
|
|
678
|
+
*/
|
|
435
679
|
class JsonObject {
|
|
436
680
|
static __wrap(ptr) {
|
|
437
681
|
ptr = ptr >>> 0;
|
|
@@ -451,6 +695,8 @@ class JsonObject {
|
|
|
451
695
|
wasm.__wbg_jsonobject_free(ptr, 0);
|
|
452
696
|
}
|
|
453
697
|
/**
|
|
698
|
+
* Returns all properties in the object.
|
|
699
|
+
* @returns Array of object properties
|
|
454
700
|
* @returns {ObjectProp[]}
|
|
455
701
|
*/
|
|
456
702
|
properties() {
|
|
@@ -460,6 +706,9 @@ class JsonObject {
|
|
|
460
706
|
return v1;
|
|
461
707
|
}
|
|
462
708
|
/**
|
|
709
|
+
* Gets a property by name.
|
|
710
|
+
* @param key - The property name to look up
|
|
711
|
+
* @returns The property, or undefined if not found
|
|
463
712
|
* @param {string} key
|
|
464
713
|
* @returns {ObjectProp | undefined}
|
|
465
714
|
*/
|
|
@@ -470,6 +719,10 @@ class JsonObject {
|
|
|
470
719
|
return ret === 0 ? undefined : ObjectProp.__wrap(ret);
|
|
471
720
|
}
|
|
472
721
|
/**
|
|
722
|
+
* Gets a property by name, throwing if not found.
|
|
723
|
+
* @param key - The property name to look up
|
|
724
|
+
* @returns The property
|
|
725
|
+
* @throws If the property is not found
|
|
473
726
|
* @param {string} key
|
|
474
727
|
* @returns {ObjectProp}
|
|
475
728
|
*/
|
|
@@ -483,96 +736,132 @@ class JsonObject {
|
|
|
483
736
|
return ObjectProp.__wrap(ret[0]);
|
|
484
737
|
}
|
|
485
738
|
/**
|
|
739
|
+
* Gets a property value if it's an object.
|
|
740
|
+
* @param name - The property name to look up
|
|
741
|
+
* @returns The object value, or undefined if property doesn't exist or is not an object
|
|
486
742
|
* @param {string} name
|
|
487
743
|
* @returns {JsonObject | undefined}
|
|
488
744
|
*/
|
|
489
|
-
|
|
745
|
+
getIfObject(name) {
|
|
490
746
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
491
747
|
const len0 = WASM_VECTOR_LEN;
|
|
492
|
-
const ret = wasm.
|
|
748
|
+
const ret = wasm.jsonobject_getIfObject(this.__wbg_ptr, ptr0, len0);
|
|
493
749
|
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
494
750
|
}
|
|
495
751
|
/**
|
|
752
|
+
* Gets a property value as an object, throwing if not found or wrong type.
|
|
753
|
+
* @param name - The property name to look up
|
|
754
|
+
* @returns The object value
|
|
755
|
+
* @throws If the property doesn't exist or is not an object
|
|
496
756
|
* @param {string} name
|
|
497
757
|
* @returns {JsonObject}
|
|
498
758
|
*/
|
|
499
|
-
|
|
759
|
+
getIfObjectOrThrow(name) {
|
|
500
760
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
761
|
const len0 = WASM_VECTOR_LEN;
|
|
502
|
-
const ret = wasm.
|
|
762
|
+
const ret = wasm.jsonobject_getIfObjectOrThrow(this.__wbg_ptr, ptr0, len0);
|
|
503
763
|
if (ret[2]) {
|
|
504
764
|
throw takeFromExternrefTable0(ret[1]);
|
|
505
765
|
}
|
|
506
766
|
return JsonObject.__wrap(ret[0]);
|
|
507
767
|
}
|
|
508
768
|
/**
|
|
769
|
+
* Gets a property value as an object, creating an empty object if the property doesn't exist.
|
|
770
|
+
* Returns undefined if the property exists but has a non-object value.
|
|
771
|
+
* @param name - The property name to get
|
|
772
|
+
* @returns The object value, or undefined if property has a non-object value
|
|
509
773
|
* @param {string} name
|
|
510
774
|
* @returns {JsonObject | undefined}
|
|
511
775
|
*/
|
|
512
|
-
|
|
776
|
+
getIfObjectOrCreate(name) {
|
|
513
777
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
514
778
|
const len0 = WASM_VECTOR_LEN;
|
|
515
|
-
const ret = wasm.
|
|
779
|
+
const ret = wasm.jsonobject_getIfObjectOrCreate(this.__wbg_ptr, ptr0, len0);
|
|
516
780
|
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
517
781
|
}
|
|
518
782
|
/**
|
|
783
|
+
* Gets a property value as an object, creating or replacing the value with an empty object if needed.
|
|
784
|
+
* Unlike getIfObjectOrCreate, this always returns an object by replacing non-object values.
|
|
785
|
+
* @param name - The property name to get
|
|
786
|
+
* @returns The object value (always succeeds)
|
|
519
787
|
* @param {string} name
|
|
520
788
|
* @returns {JsonObject}
|
|
521
789
|
*/
|
|
522
|
-
|
|
790
|
+
getIfObjectOrForce(name) {
|
|
523
791
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
524
792
|
const len0 = WASM_VECTOR_LEN;
|
|
525
|
-
const ret = wasm.
|
|
793
|
+
const ret = wasm.jsonobject_getIfObjectOrForce(this.__wbg_ptr, ptr0, len0);
|
|
526
794
|
return JsonObject.__wrap(ret);
|
|
527
795
|
}
|
|
528
796
|
/**
|
|
797
|
+
* Gets a property value if it's an array.
|
|
798
|
+
* @param name - The property name to look up
|
|
799
|
+
* @returns The array value, or undefined if property doesn't exist or is not an array
|
|
529
800
|
* @param {string} name
|
|
530
801
|
* @returns {JsonArray | undefined}
|
|
531
802
|
*/
|
|
532
|
-
|
|
803
|
+
getIfArray(name) {
|
|
533
804
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
534
805
|
const len0 = WASM_VECTOR_LEN;
|
|
535
|
-
const ret = wasm.
|
|
806
|
+
const ret = wasm.jsonobject_getIfArray(this.__wbg_ptr, ptr0, len0);
|
|
536
807
|
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
537
808
|
}
|
|
538
809
|
/**
|
|
810
|
+
* Gets a property value as an array, throwing if not found or wrong type.
|
|
811
|
+
* @param name - The property name to look up
|
|
812
|
+
* @returns The array value
|
|
813
|
+
* @throws If the property doesn't exist or is not an array
|
|
539
814
|
* @param {string} name
|
|
540
815
|
* @returns {JsonArray}
|
|
541
816
|
*/
|
|
542
|
-
|
|
817
|
+
getIfArrayOrThrow(name) {
|
|
543
818
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
544
819
|
const len0 = WASM_VECTOR_LEN;
|
|
545
|
-
const ret = wasm.
|
|
820
|
+
const ret = wasm.jsonobject_getIfArrayOrThrow(this.__wbg_ptr, ptr0, len0);
|
|
546
821
|
if (ret[2]) {
|
|
547
822
|
throw takeFromExternrefTable0(ret[1]);
|
|
548
823
|
}
|
|
549
824
|
return JsonArray.__wrap(ret[0]);
|
|
550
825
|
}
|
|
551
826
|
/**
|
|
827
|
+
* Gets a property value as an array, creating an empty array if the property doesn't exist.
|
|
828
|
+
* Returns undefined if the property exists but has a non-array value.
|
|
829
|
+
* @param name - The property name to get
|
|
830
|
+
* @returns The array value, or undefined if property has a non-array value
|
|
552
831
|
* @param {string} name
|
|
553
832
|
* @returns {JsonArray | undefined}
|
|
554
833
|
*/
|
|
555
|
-
|
|
834
|
+
getIfArrayOrCreate(name) {
|
|
556
835
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
557
836
|
const len0 = WASM_VECTOR_LEN;
|
|
558
|
-
const ret = wasm.
|
|
837
|
+
const ret = wasm.jsonobject_getIfArrayOrCreate(this.__wbg_ptr, ptr0, len0);
|
|
559
838
|
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
560
839
|
}
|
|
561
840
|
/**
|
|
841
|
+
* Gets a property value as an array, creating or replacing the value with an empty array if needed.
|
|
842
|
+
* Unlike getIfArrayOrCreate, this always returns an array by replacing non-array values.
|
|
843
|
+
* @param name - The property name to get
|
|
844
|
+
* @returns The array value (always succeeds)
|
|
562
845
|
* @param {string} name
|
|
563
846
|
* @returns {JsonArray}
|
|
564
847
|
*/
|
|
565
|
-
|
|
848
|
+
getIfArrayOrForce(name) {
|
|
566
849
|
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
567
850
|
const len0 = WASM_VECTOR_LEN;
|
|
568
|
-
const ret = wasm.
|
|
851
|
+
const ret = wasm.jsonobject_getIfArrayOrForce(this.__wbg_ptr, ptr0, len0);
|
|
569
852
|
return JsonArray.__wrap(ret);
|
|
570
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Removes this object from its parent.
|
|
856
|
+
* After calling this method, the object is detached from the CST and can no longer be used.
|
|
857
|
+
*/
|
|
571
858
|
remove() {
|
|
572
859
|
const ptr = this.__destroy_into_raw();
|
|
573
860
|
wasm.jsonobject_remove(ptr);
|
|
574
861
|
}
|
|
575
862
|
/**
|
|
863
|
+
* Returns all child nodes including whitespace and punctuation.
|
|
864
|
+
* @returns Array of all child nodes
|
|
576
865
|
* @returns {Node[]}
|
|
577
866
|
*/
|
|
578
867
|
children() {
|
|
@@ -582,12 +871,16 @@ class JsonObject {
|
|
|
582
871
|
return v1;
|
|
583
872
|
}
|
|
584
873
|
/**
|
|
585
|
-
*
|
|
874
|
+
* Appends a new property to the object.
|
|
875
|
+
* @param key - The name of the property to add
|
|
876
|
+
* @param value - The value to set for the property
|
|
877
|
+
* @returns The newly created property
|
|
878
|
+
* @param {string} key
|
|
586
879
|
* @param {any} value
|
|
587
880
|
* @returns {ObjectProp}
|
|
588
881
|
*/
|
|
589
|
-
append(
|
|
590
|
-
const ptr0 = passStringToWasm0(
|
|
882
|
+
append(key, value) {
|
|
883
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
591
884
|
const len0 = WASM_VECTOR_LEN;
|
|
592
885
|
const ret = wasm.jsonobject_append(this.__wbg_ptr, ptr0, len0, value);
|
|
593
886
|
if (ret[2]) {
|
|
@@ -596,13 +889,18 @@ class JsonObject {
|
|
|
596
889
|
return ObjectProp.__wrap(ret[0]);
|
|
597
890
|
}
|
|
598
891
|
/**
|
|
892
|
+
* Inserts a new property at the specified index.
|
|
893
|
+
* @param index - The position to insert the property at
|
|
894
|
+
* @param key - The name of the property to add
|
|
895
|
+
* @param value - The value to set for the property
|
|
896
|
+
* @returns The newly created property
|
|
599
897
|
* @param {number} index
|
|
600
|
-
* @param {string}
|
|
898
|
+
* @param {string} key
|
|
601
899
|
* @param {any} value
|
|
602
900
|
* @returns {ObjectProp}
|
|
603
901
|
*/
|
|
604
|
-
insert(index,
|
|
605
|
-
const ptr0 = passStringToWasm0(
|
|
902
|
+
insert(index, key, value) {
|
|
903
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
606
904
|
const len0 = WASM_VECTOR_LEN;
|
|
607
905
|
const ret = wasm.jsonobject_insert(this.__wbg_ptr, index, ptr0, len0, value);
|
|
608
906
|
if (ret[2]) {
|
|
@@ -611,25 +909,37 @@ class JsonObject {
|
|
|
611
909
|
return ObjectProp.__wrap(ret[0]);
|
|
612
910
|
}
|
|
613
911
|
/**
|
|
912
|
+
* Configures whether trailing commas should be used in this object.
|
|
913
|
+
* When enabled, trailing commas are added for multiline formatting.
|
|
914
|
+
* @param enabled - Whether to enable trailing commas
|
|
614
915
|
* @param {boolean} enabled
|
|
615
916
|
*/
|
|
616
917
|
setTrailingCommas(enabled) {
|
|
617
918
|
wasm.jsonobject_setTrailingCommas(this.__wbg_ptr, enabled);
|
|
618
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Ensures the object is formatted with each property on its own line.
|
|
922
|
+
*/
|
|
619
923
|
ensureMultiline() {
|
|
620
924
|
wasm.jsonobject_ensureMultiline(this.__wbg_ptr);
|
|
621
925
|
}
|
|
622
926
|
/**
|
|
623
|
-
*
|
|
927
|
+
* Replaces this object with a new value.
|
|
928
|
+
* @param replacement - The new value to replace this object with
|
|
929
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
930
|
+
* @param {any} replacement
|
|
624
931
|
* @returns {Node | undefined}
|
|
625
932
|
*/
|
|
626
933
|
replaceWith(replacement) {
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
934
|
+
const ret = wasm.jsonobject_replaceWith(this.__wbg_ptr, replacement);
|
|
935
|
+
if (ret[2]) {
|
|
936
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
937
|
+
}
|
|
938
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
631
939
|
}
|
|
632
940
|
/**
|
|
941
|
+
* Returns the parent node in the CST.
|
|
942
|
+
* @returns The parent node, or undefined if this is the root
|
|
633
943
|
* @returns {Node | undefined}
|
|
634
944
|
*/
|
|
635
945
|
parent() {
|
|
@@ -637,6 +947,8 @@ class JsonObject {
|
|
|
637
947
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
638
948
|
}
|
|
639
949
|
/**
|
|
950
|
+
* Returns all ancestor nodes from parent to root.
|
|
951
|
+
* @returns Array of ancestor nodes
|
|
640
952
|
* @returns {Node[]}
|
|
641
953
|
*/
|
|
642
954
|
ancestors() {
|
|
@@ -646,6 +958,8 @@ class JsonObject {
|
|
|
646
958
|
return v1;
|
|
647
959
|
}
|
|
648
960
|
/**
|
|
961
|
+
* Returns the index of this node within its parent's children.
|
|
962
|
+
* @returns The child index
|
|
649
963
|
* @returns {number}
|
|
650
964
|
*/
|
|
651
965
|
childIndex() {
|
|
@@ -653,6 +967,8 @@ class JsonObject {
|
|
|
653
967
|
return ret >>> 0;
|
|
654
968
|
}
|
|
655
969
|
/**
|
|
970
|
+
* Returns the previous sibling node.
|
|
971
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
656
972
|
* @returns {Node | undefined}
|
|
657
973
|
*/
|
|
658
974
|
previousSibling() {
|
|
@@ -660,6 +976,8 @@ class JsonObject {
|
|
|
660
976
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
661
977
|
}
|
|
662
978
|
/**
|
|
979
|
+
* Returns all previous sibling nodes.
|
|
980
|
+
* @returns Array of previous siblings
|
|
663
981
|
* @returns {Node[]}
|
|
664
982
|
*/
|
|
665
983
|
previousSiblings() {
|
|
@@ -669,6 +987,8 @@ class JsonObject {
|
|
|
669
987
|
return v1;
|
|
670
988
|
}
|
|
671
989
|
/**
|
|
990
|
+
* Returns the next sibling node.
|
|
991
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
672
992
|
* @returns {Node | undefined}
|
|
673
993
|
*/
|
|
674
994
|
nextSibling() {
|
|
@@ -676,6 +996,8 @@ class JsonObject {
|
|
|
676
996
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
677
997
|
}
|
|
678
998
|
/**
|
|
999
|
+
* Returns all next sibling nodes.
|
|
1000
|
+
* @returns Array of next siblings
|
|
679
1001
|
* @returns {Node[]}
|
|
680
1002
|
*/
|
|
681
1003
|
nextSiblings() {
|
|
@@ -685,6 +1007,8 @@ class JsonObject {
|
|
|
685
1007
|
return v1;
|
|
686
1008
|
}
|
|
687
1009
|
/**
|
|
1010
|
+
* Returns the root node of the document.
|
|
1011
|
+
* @returns The root node, or undefined if detached
|
|
688
1012
|
* @returns {RootNode | undefined}
|
|
689
1013
|
*/
|
|
690
1014
|
rootNode() {
|
|
@@ -692,6 +1016,8 @@ class JsonObject {
|
|
|
692
1016
|
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
693
1017
|
}
|
|
694
1018
|
/**
|
|
1019
|
+
* Returns the indentation string used at this node's depth.
|
|
1020
|
+
* @returns The indentation string, or undefined if not applicable
|
|
695
1021
|
* @returns {string | undefined}
|
|
696
1022
|
*/
|
|
697
1023
|
indentText() {
|
|
@@ -704,6 +1030,8 @@ class JsonObject {
|
|
|
704
1030
|
return v1;
|
|
705
1031
|
}
|
|
706
1032
|
/**
|
|
1033
|
+
* Returns whether this node's container uses trailing commas.
|
|
1034
|
+
* @returns true if trailing commas are used
|
|
707
1035
|
* @returns {boolean}
|
|
708
1036
|
*/
|
|
709
1037
|
usesTrailingCommas() {
|
|
@@ -711,6 +1039,8 @@ class JsonObject {
|
|
|
711
1039
|
return ret !== 0;
|
|
712
1040
|
}
|
|
713
1041
|
/**
|
|
1042
|
+
* Returns child nodes excluding whitespace, comments, and punctuation.
|
|
1043
|
+
* @returns Array of significant child nodes
|
|
714
1044
|
* @returns {Node[]}
|
|
715
1045
|
*/
|
|
716
1046
|
childrenExcludeTriviaAndTokens() {
|
|
@@ -720,6 +1050,9 @@ class JsonObject {
|
|
|
720
1050
|
return v1;
|
|
721
1051
|
}
|
|
722
1052
|
/**
|
|
1053
|
+
* Returns the child node at the specified index.
|
|
1054
|
+
* @param index - The child index
|
|
1055
|
+
* @returns The child node, or undefined if index is out of bounds
|
|
723
1056
|
* @param {number} index
|
|
724
1057
|
* @returns {Node | undefined}
|
|
725
1058
|
*/
|
|
@@ -732,6 +1065,10 @@ exports.JsonObject = JsonObject;
|
|
|
732
1065
|
const NodeFinalization = (typeof FinalizationRegistry === "undefined")
|
|
733
1066
|
? { register: () => { }, unregister: () => { } }
|
|
734
1067
|
: new FinalizationRegistry((ptr) => wasm.__wbg_node_free(ptr >>> 0, 1));
|
|
1068
|
+
/**
|
|
1069
|
+
* Represents a generic node in the CST.
|
|
1070
|
+
* Can be a container node (object, array, property) or a leaf node (string, number, boolean, null).
|
|
1071
|
+
*/
|
|
735
1072
|
class Node {
|
|
736
1073
|
static __wrap(ptr) {
|
|
737
1074
|
ptr = ptr >>> 0;
|
|
@@ -751,6 +1088,8 @@ class Node {
|
|
|
751
1088
|
wasm.__wbg_node_free(ptr, 0);
|
|
752
1089
|
}
|
|
753
1090
|
/**
|
|
1091
|
+
* Returns true if this node is a container (object, array, or property).
|
|
1092
|
+
* @returns true if this is a container node
|
|
754
1093
|
* @returns {boolean}
|
|
755
1094
|
*/
|
|
756
1095
|
isContainer() {
|
|
@@ -758,6 +1097,8 @@ class Node {
|
|
|
758
1097
|
return ret !== 0;
|
|
759
1098
|
}
|
|
760
1099
|
/**
|
|
1100
|
+
* Returns true if this node is a leaf value (string, number, boolean, null).
|
|
1101
|
+
* @returns true if this is a leaf node
|
|
761
1102
|
* @returns {boolean}
|
|
762
1103
|
*/
|
|
763
1104
|
isLeaf() {
|
|
@@ -765,6 +1106,8 @@ class Node {
|
|
|
765
1106
|
return ret !== 0;
|
|
766
1107
|
}
|
|
767
1108
|
/**
|
|
1109
|
+
* Converts this node to an object if it is one.
|
|
1110
|
+
* @returns The object, or undefined if this node is not an object
|
|
768
1111
|
* @returns {JsonObject | undefined}
|
|
769
1112
|
*/
|
|
770
1113
|
asObject() {
|
|
@@ -772,6 +1115,9 @@ class Node {
|
|
|
772
1115
|
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
773
1116
|
}
|
|
774
1117
|
/**
|
|
1118
|
+
* Converts this node to an object, throwing if it's not an object.
|
|
1119
|
+
* @returns The object
|
|
1120
|
+
* @throws If this node is not an object
|
|
775
1121
|
* @returns {JsonObject}
|
|
776
1122
|
*/
|
|
777
1123
|
asObjectOrThrow() {
|
|
@@ -782,6 +1128,8 @@ class Node {
|
|
|
782
1128
|
return JsonObject.__wrap(ret[0]);
|
|
783
1129
|
}
|
|
784
1130
|
/**
|
|
1131
|
+
* Converts this node to an array if it is one.
|
|
1132
|
+
* @returns The array, or undefined if this node is not an array
|
|
785
1133
|
* @returns {JsonArray | undefined}
|
|
786
1134
|
*/
|
|
787
1135
|
asArray() {
|
|
@@ -789,6 +1137,9 @@ class Node {
|
|
|
789
1137
|
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
790
1138
|
}
|
|
791
1139
|
/**
|
|
1140
|
+
* Converts this node to an array, throwing if it's not an array.
|
|
1141
|
+
* @returns The array
|
|
1142
|
+
* @throws If this node is not an array
|
|
792
1143
|
* @returns {JsonArray}
|
|
793
1144
|
*/
|
|
794
1145
|
asArrayOrThrow() {
|
|
@@ -799,6 +1150,8 @@ class Node {
|
|
|
799
1150
|
return JsonArray.__wrap(ret[0]);
|
|
800
1151
|
}
|
|
801
1152
|
/**
|
|
1153
|
+
* Converts this node to the root node if it is one.
|
|
1154
|
+
* @returns The root node, or undefined if this is not a root node
|
|
802
1155
|
* @returns {RootNode | undefined}
|
|
803
1156
|
*/
|
|
804
1157
|
asRootNode() {
|
|
@@ -806,6 +1159,9 @@ class Node {
|
|
|
806
1159
|
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
807
1160
|
}
|
|
808
1161
|
/**
|
|
1162
|
+
* Converts this node to the root node, throwing if it's not a root node.
|
|
1163
|
+
* @returns The root node
|
|
1164
|
+
* @throws If this node is not a root node
|
|
809
1165
|
* @returns {RootNode}
|
|
810
1166
|
*/
|
|
811
1167
|
asRootNodeOrThrow() {
|
|
@@ -816,6 +1172,8 @@ class Node {
|
|
|
816
1172
|
return RootNode.__wrap(ret[0]);
|
|
817
1173
|
}
|
|
818
1174
|
/**
|
|
1175
|
+
* Returns the decoded string value if this node is a string literal.
|
|
1176
|
+
* @returns The string value, or undefined if this node is not a string
|
|
819
1177
|
* @returns {string | undefined}
|
|
820
1178
|
*/
|
|
821
1179
|
asString() {
|
|
@@ -828,6 +1186,9 @@ class Node {
|
|
|
828
1186
|
return v1;
|
|
829
1187
|
}
|
|
830
1188
|
/**
|
|
1189
|
+
* Returns the decoded string value, throwing if not a string.
|
|
1190
|
+
* @returns The string value
|
|
1191
|
+
* @throws If this node is not a string
|
|
831
1192
|
* @returns {string}
|
|
832
1193
|
*/
|
|
833
1194
|
asStringOrThrow() {
|
|
@@ -851,6 +1212,9 @@ class Node {
|
|
|
851
1212
|
}
|
|
852
1213
|
}
|
|
853
1214
|
/**
|
|
1215
|
+
* Returns the raw string representation of a number literal.
|
|
1216
|
+
* Returns a string to preserve the exact formatting (e.g., "1.0" vs "1", "1e10" vs "10000000000").
|
|
1217
|
+
* @returns The number as a string, or undefined if this node is not a number
|
|
854
1218
|
* @returns {string | undefined}
|
|
855
1219
|
*/
|
|
856
1220
|
numberValue() {
|
|
@@ -863,6 +1227,10 @@ class Node {
|
|
|
863
1227
|
return v1;
|
|
864
1228
|
}
|
|
865
1229
|
/**
|
|
1230
|
+
* Returns the raw string representation of a number literal, throwing if not a number.
|
|
1231
|
+
* Returns a string to preserve the exact formatting (e.g., "1.0" vs "1", "1e10" vs "10000000000").
|
|
1232
|
+
* @returns The number as a string
|
|
1233
|
+
* @throws If this node is not a number
|
|
866
1234
|
* @returns {string}
|
|
867
1235
|
*/
|
|
868
1236
|
numberValueOrThrow() {
|
|
@@ -886,6 +1254,8 @@ class Node {
|
|
|
886
1254
|
}
|
|
887
1255
|
}
|
|
888
1256
|
/**
|
|
1257
|
+
* Returns the boolean value if this node is a boolean literal.
|
|
1258
|
+
* @returns The boolean value, or undefined if this node is not a boolean
|
|
889
1259
|
* @returns {boolean | undefined}
|
|
890
1260
|
*/
|
|
891
1261
|
asBoolean() {
|
|
@@ -893,6 +1263,9 @@ class Node {
|
|
|
893
1263
|
return ret === 0xFFFFFF ? undefined : ret !== 0;
|
|
894
1264
|
}
|
|
895
1265
|
/**
|
|
1266
|
+
* Returns the boolean value, throwing if not a boolean.
|
|
1267
|
+
* @returns The boolean value
|
|
1268
|
+
* @throws If this node is not a boolean
|
|
896
1269
|
* @returns {boolean}
|
|
897
1270
|
*/
|
|
898
1271
|
asBooleanOrThrow() {
|
|
@@ -903,6 +1276,8 @@ class Node {
|
|
|
903
1276
|
return ret[0] !== 0;
|
|
904
1277
|
}
|
|
905
1278
|
/**
|
|
1279
|
+
* Returns true if this node is a null keyword.
|
|
1280
|
+
* @returns true if this node represents null
|
|
906
1281
|
* @returns {boolean}
|
|
907
1282
|
*/
|
|
908
1283
|
isNull() {
|
|
@@ -910,6 +1285,8 @@ class Node {
|
|
|
910
1285
|
return ret !== 0;
|
|
911
1286
|
}
|
|
912
1287
|
/**
|
|
1288
|
+
* Returns true if this node is a string literal.
|
|
1289
|
+
* @returns true if this node is a string
|
|
913
1290
|
* @returns {boolean}
|
|
914
1291
|
*/
|
|
915
1292
|
isString() {
|
|
@@ -917,6 +1294,8 @@ class Node {
|
|
|
917
1294
|
return ret !== 0;
|
|
918
1295
|
}
|
|
919
1296
|
/**
|
|
1297
|
+
* Returns true if this node is a number literal.
|
|
1298
|
+
* @returns true if this node is a number
|
|
920
1299
|
* @returns {boolean}
|
|
921
1300
|
*/
|
|
922
1301
|
isNumber() {
|
|
@@ -924,6 +1303,8 @@ class Node {
|
|
|
924
1303
|
return ret !== 0;
|
|
925
1304
|
}
|
|
926
1305
|
/**
|
|
1306
|
+
* Returns true if this node is a boolean literal.
|
|
1307
|
+
* @returns true if this node is a boolean
|
|
927
1308
|
* @returns {boolean}
|
|
928
1309
|
*/
|
|
929
1310
|
isBoolean() {
|
|
@@ -931,6 +1312,118 @@ class Node {
|
|
|
931
1312
|
return ret !== 0;
|
|
932
1313
|
}
|
|
933
1314
|
/**
|
|
1315
|
+
* Returns this node as a StringLit if it is one.
|
|
1316
|
+
* @returns The StringLit, or undefined if this node is not a string literal
|
|
1317
|
+
* @returns {StringLit | undefined}
|
|
1318
|
+
*/
|
|
1319
|
+
asStringLit() {
|
|
1320
|
+
const ret = wasm.node_asStringLit(this.__wbg_ptr);
|
|
1321
|
+
return ret === 0 ? undefined : StringLit.__wrap(ret);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Returns this node as a StringLit, throwing if it's not a string literal.
|
|
1325
|
+
* @returns The StringLit
|
|
1326
|
+
* @throws If this node is not a string literal
|
|
1327
|
+
* @returns {StringLit}
|
|
1328
|
+
*/
|
|
1329
|
+
asStringLitOrThrow() {
|
|
1330
|
+
const ret = wasm.node_asStringLitOrThrow(this.__wbg_ptr);
|
|
1331
|
+
if (ret[2]) {
|
|
1332
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1333
|
+
}
|
|
1334
|
+
return StringLit.__wrap(ret[0]);
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Returns this node as a NumberLit if it is one.
|
|
1338
|
+
* @returns The NumberLit, or undefined if this node is not a number literal
|
|
1339
|
+
* @returns {NumberLit | undefined}
|
|
1340
|
+
*/
|
|
1341
|
+
asNumberLit() {
|
|
1342
|
+
const ret = wasm.node_asNumberLit(this.__wbg_ptr);
|
|
1343
|
+
return ret === 0 ? undefined : NumberLit.__wrap(ret);
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns this node as a NumberLit, throwing if it's not a number literal.
|
|
1347
|
+
* @returns The NumberLit
|
|
1348
|
+
* @throws If this node is not a number literal
|
|
1349
|
+
* @returns {NumberLit}
|
|
1350
|
+
*/
|
|
1351
|
+
asNumberLitOrThrow() {
|
|
1352
|
+
const ret = wasm.node_asNumberLitOrThrow(this.__wbg_ptr);
|
|
1353
|
+
if (ret[2]) {
|
|
1354
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1355
|
+
}
|
|
1356
|
+
return NumberLit.__wrap(ret[0]);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Returns this node as a BooleanLit if it is one.
|
|
1360
|
+
* @returns The BooleanLit, or undefined if this node is not a boolean literal
|
|
1361
|
+
* @returns {BooleanLit | undefined}
|
|
1362
|
+
*/
|
|
1363
|
+
asBooleanLit() {
|
|
1364
|
+
const ret = wasm.node_asBooleanLit(this.__wbg_ptr);
|
|
1365
|
+
return ret === 0 ? undefined : BooleanLit.__wrap(ret);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Returns this node as a BooleanLit, throwing if it's not a boolean literal.
|
|
1369
|
+
* @returns The BooleanLit
|
|
1370
|
+
* @throws If this node is not a boolean literal
|
|
1371
|
+
* @returns {BooleanLit}
|
|
1372
|
+
*/
|
|
1373
|
+
asBooleanLitOrThrow() {
|
|
1374
|
+
const ret = wasm.node_asBooleanLitOrThrow(this.__wbg_ptr);
|
|
1375
|
+
if (ret[2]) {
|
|
1376
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1377
|
+
}
|
|
1378
|
+
return BooleanLit.__wrap(ret[0]);
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Returns this node as a NullKeyword if it is one.
|
|
1382
|
+
* @returns The NullKeyword, or undefined if this node is not a null keyword
|
|
1383
|
+
* @returns {NullKeyword | undefined}
|
|
1384
|
+
*/
|
|
1385
|
+
asNullKeyword() {
|
|
1386
|
+
const ret = wasm.node_asNullKeyword(this.__wbg_ptr);
|
|
1387
|
+
return ret === 0 ? undefined : NullKeyword.__wrap(ret);
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Returns this node as a NullKeyword, throwing if it's not a null keyword.
|
|
1391
|
+
* @returns The NullKeyword
|
|
1392
|
+
* @throws If this node is not a null keyword
|
|
1393
|
+
* @returns {NullKeyword}
|
|
1394
|
+
*/
|
|
1395
|
+
asNullKeywordOrThrow() {
|
|
1396
|
+
const ret = wasm.node_asNullKeywordOrThrow(this.__wbg_ptr);
|
|
1397
|
+
if (ret[2]) {
|
|
1398
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1399
|
+
}
|
|
1400
|
+
return NullKeyword.__wrap(ret[0]);
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Returns this node as a WordLit if it is one.
|
|
1404
|
+
* @returns The WordLit, or undefined if this node is not a word literal
|
|
1405
|
+
* @returns {WordLit | undefined}
|
|
1406
|
+
*/
|
|
1407
|
+
asWordLit() {
|
|
1408
|
+
const ret = wasm.node_asWordLit(this.__wbg_ptr);
|
|
1409
|
+
return ret === 0 ? undefined : WordLit.__wrap(ret);
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Returns this node as a WordLit, throwing if it's not a word literal.
|
|
1413
|
+
* @returns The WordLit
|
|
1414
|
+
* @throws If this node is not a word literal
|
|
1415
|
+
* @returns {WordLit}
|
|
1416
|
+
*/
|
|
1417
|
+
asWordLitOrThrow() {
|
|
1418
|
+
const ret = wasm.node_asWordLitOrThrow(this.__wbg_ptr);
|
|
1419
|
+
if (ret[2]) {
|
|
1420
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1421
|
+
}
|
|
1422
|
+
return WordLit.__wrap(ret[0]);
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Returns the parent node in the CST.
|
|
1426
|
+
* @returns The parent node, or undefined if this is the root
|
|
934
1427
|
* @returns {Node | undefined}
|
|
935
1428
|
*/
|
|
936
1429
|
parent() {
|
|
@@ -938,6 +1431,9 @@ class Node {
|
|
|
938
1431
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
939
1432
|
}
|
|
940
1433
|
/**
|
|
1434
|
+
* Returns the parent node, throwing if this is the root.
|
|
1435
|
+
* @returns The parent node
|
|
1436
|
+
* @throws If this node has no parent
|
|
941
1437
|
* @returns {Node}
|
|
942
1438
|
*/
|
|
943
1439
|
parentOrThrow() {
|
|
@@ -948,6 +1444,8 @@ class Node {
|
|
|
948
1444
|
return Node.__wrap(ret[0]);
|
|
949
1445
|
}
|
|
950
1446
|
/**
|
|
1447
|
+
* Returns the index of this node within its parent's children.
|
|
1448
|
+
* @returns The child index
|
|
951
1449
|
* @returns {number}
|
|
952
1450
|
*/
|
|
953
1451
|
childIndex() {
|
|
@@ -955,6 +1453,8 @@ class Node {
|
|
|
955
1453
|
return ret >>> 0;
|
|
956
1454
|
}
|
|
957
1455
|
/**
|
|
1456
|
+
* Returns all ancestor nodes from parent to root.
|
|
1457
|
+
* @returns Array of ancestor nodes
|
|
958
1458
|
* @returns {Node[]}
|
|
959
1459
|
*/
|
|
960
1460
|
ancestors() {
|
|
@@ -964,6 +1464,8 @@ class Node {
|
|
|
964
1464
|
return v1;
|
|
965
1465
|
}
|
|
966
1466
|
/**
|
|
1467
|
+
* Returns the previous sibling node.
|
|
1468
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
967
1469
|
* @returns {Node | undefined}
|
|
968
1470
|
*/
|
|
969
1471
|
previousSibling() {
|
|
@@ -971,6 +1473,8 @@ class Node {
|
|
|
971
1473
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
972
1474
|
}
|
|
973
1475
|
/**
|
|
1476
|
+
* Returns all previous sibling nodes.
|
|
1477
|
+
* @returns Array of previous siblings
|
|
974
1478
|
* @returns {Node[]}
|
|
975
1479
|
*/
|
|
976
1480
|
previousSiblings() {
|
|
@@ -980,6 +1484,8 @@ class Node {
|
|
|
980
1484
|
return v1;
|
|
981
1485
|
}
|
|
982
1486
|
/**
|
|
1487
|
+
* Returns the next sibling node.
|
|
1488
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
983
1489
|
* @returns {Node | undefined}
|
|
984
1490
|
*/
|
|
985
1491
|
nextSibling() {
|
|
@@ -987,6 +1493,8 @@ class Node {
|
|
|
987
1493
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
988
1494
|
}
|
|
989
1495
|
/**
|
|
1496
|
+
* Returns all next sibling nodes.
|
|
1497
|
+
* @returns Array of next siblings
|
|
990
1498
|
* @returns {Node[]}
|
|
991
1499
|
*/
|
|
992
1500
|
nextSiblings() {
|
|
@@ -996,6 +1504,8 @@ class Node {
|
|
|
996
1504
|
return v1;
|
|
997
1505
|
}
|
|
998
1506
|
/**
|
|
1507
|
+
* Returns the root node of the document.
|
|
1508
|
+
* @returns The root node, or undefined if detached
|
|
999
1509
|
* @returns {RootNode | undefined}
|
|
1000
1510
|
*/
|
|
1001
1511
|
rootNode() {
|
|
@@ -1003,6 +1513,9 @@ class Node {
|
|
|
1003
1513
|
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
1004
1514
|
}
|
|
1005
1515
|
/**
|
|
1516
|
+
* Returns the root node, throwing if detached.
|
|
1517
|
+
* @returns The root node
|
|
1518
|
+
* @throws If this node is detached from the CST
|
|
1006
1519
|
* @returns {RootNode}
|
|
1007
1520
|
*/
|
|
1008
1521
|
rootNodeOrThrow() {
|
|
@@ -1013,6 +1526,8 @@ class Node {
|
|
|
1013
1526
|
return RootNode.__wrap(ret[0]);
|
|
1014
1527
|
}
|
|
1015
1528
|
/**
|
|
1529
|
+
* Returns the indentation string used at this node's depth.
|
|
1530
|
+
* @returns The indentation string, or undefined if not applicable
|
|
1016
1531
|
* @returns {string | undefined}
|
|
1017
1532
|
*/
|
|
1018
1533
|
indentText() {
|
|
@@ -1025,6 +1540,8 @@ class Node {
|
|
|
1025
1540
|
return v1;
|
|
1026
1541
|
}
|
|
1027
1542
|
/**
|
|
1543
|
+
* Returns whether this node's container uses trailing commas.
|
|
1544
|
+
* @returns true if trailing commas are used
|
|
1028
1545
|
* @returns {boolean}
|
|
1029
1546
|
*/
|
|
1030
1547
|
usesTrailingCommas() {
|
|
@@ -1032,6 +1549,8 @@ class Node {
|
|
|
1032
1549
|
return ret !== 0;
|
|
1033
1550
|
}
|
|
1034
1551
|
/**
|
|
1552
|
+
* Returns true if this node is trivia (whitespace or comments).
|
|
1553
|
+
* @returns true if this node is trivia
|
|
1035
1554
|
* @returns {boolean}
|
|
1036
1555
|
*/
|
|
1037
1556
|
isTrivia() {
|
|
@@ -1039,6 +1558,8 @@ class Node {
|
|
|
1039
1558
|
return ret !== 0;
|
|
1040
1559
|
}
|
|
1041
1560
|
/**
|
|
1561
|
+
* Returns true if this node is a newline character.
|
|
1562
|
+
* @returns true if this node is a newline
|
|
1042
1563
|
* @returns {boolean}
|
|
1043
1564
|
*/
|
|
1044
1565
|
isNewline() {
|
|
@@ -1046,6 +1567,8 @@ class Node {
|
|
|
1046
1567
|
return ret !== 0;
|
|
1047
1568
|
}
|
|
1048
1569
|
/**
|
|
1570
|
+
* Returns true if this node is a comma token.
|
|
1571
|
+
* @returns true if this node is a comma
|
|
1049
1572
|
* @returns {boolean}
|
|
1050
1573
|
*/
|
|
1051
1574
|
isComma() {
|
|
@@ -1053,6 +1576,8 @@ class Node {
|
|
|
1053
1576
|
return ret !== 0;
|
|
1054
1577
|
}
|
|
1055
1578
|
/**
|
|
1579
|
+
* Returns true if this node is a comment.
|
|
1580
|
+
* @returns true if this node is a comment
|
|
1056
1581
|
* @returns {boolean}
|
|
1057
1582
|
*/
|
|
1058
1583
|
isComment() {
|
|
@@ -1060,6 +1585,8 @@ class Node {
|
|
|
1060
1585
|
return ret !== 0;
|
|
1061
1586
|
}
|
|
1062
1587
|
/**
|
|
1588
|
+
* Returns true if this node is a punctuation token (bracket, brace, colon, comma).
|
|
1589
|
+
* @returns true if this node is a token
|
|
1063
1590
|
* @returns {boolean}
|
|
1064
1591
|
*/
|
|
1065
1592
|
isToken() {
|
|
@@ -1067,6 +1594,8 @@ class Node {
|
|
|
1067
1594
|
return ret !== 0;
|
|
1068
1595
|
}
|
|
1069
1596
|
/**
|
|
1597
|
+
* Returns true if this node is whitespace.
|
|
1598
|
+
* @returns true if this node is whitespace
|
|
1070
1599
|
* @returns {boolean}
|
|
1071
1600
|
*/
|
|
1072
1601
|
isWhitespace() {
|
|
@@ -1074,6 +1603,8 @@ class Node {
|
|
|
1074
1603
|
return ret !== 0;
|
|
1075
1604
|
}
|
|
1076
1605
|
/**
|
|
1606
|
+
* Returns the character if this node is a single-character token.
|
|
1607
|
+
* @returns The token character, or undefined if not a token
|
|
1077
1608
|
* @returns {string | undefined}
|
|
1078
1609
|
*/
|
|
1079
1610
|
tokenChar() {
|
|
@@ -1086,6 +1617,8 @@ class Node {
|
|
|
1086
1617
|
return v1;
|
|
1087
1618
|
}
|
|
1088
1619
|
/**
|
|
1620
|
+
* Returns the element index if this node is an array element.
|
|
1621
|
+
* @returns The element index, or undefined if not an array element
|
|
1089
1622
|
* @returns {number | undefined}
|
|
1090
1623
|
*/
|
|
1091
1624
|
elementIndex() {
|
|
@@ -1093,6 +1626,8 @@ class Node {
|
|
|
1093
1626
|
return ret === 0x100000001 ? undefined : ret;
|
|
1094
1627
|
}
|
|
1095
1628
|
/**
|
|
1629
|
+
* Returns all child nodes including whitespace and punctuation.
|
|
1630
|
+
* @returns Array of all child nodes
|
|
1096
1631
|
* @returns {Node[]}
|
|
1097
1632
|
*/
|
|
1098
1633
|
children() {
|
|
@@ -1102,6 +1637,8 @@ class Node {
|
|
|
1102
1637
|
return v1;
|
|
1103
1638
|
}
|
|
1104
1639
|
/**
|
|
1640
|
+
* Returns child nodes excluding whitespace, comments, and punctuation.
|
|
1641
|
+
* @returns Array of significant child nodes
|
|
1105
1642
|
* @returns {Node[]}
|
|
1106
1643
|
*/
|
|
1107
1644
|
childrenExcludeTriviaAndTokens() {
|
|
@@ -1111,6 +1648,9 @@ class Node {
|
|
|
1111
1648
|
return v1;
|
|
1112
1649
|
}
|
|
1113
1650
|
/**
|
|
1651
|
+
* Returns the child node at the specified index.
|
|
1652
|
+
* @param index - The child index
|
|
1653
|
+
* @returns The child node, or undefined if index is out of bounds
|
|
1114
1654
|
* @param {number} index
|
|
1115
1655
|
* @returns {Node | undefined}
|
|
1116
1656
|
*/
|
|
@@ -1120,241 +1660,317 @@ class Node {
|
|
|
1120
1660
|
}
|
|
1121
1661
|
}
|
|
1122
1662
|
exports.Node = Node;
|
|
1123
|
-
const
|
|
1663
|
+
const NullKeywordFinalization = (typeof FinalizationRegistry === "undefined")
|
|
1124
1664
|
? { register: () => { }, unregister: () => { } }
|
|
1125
|
-
: new FinalizationRegistry((ptr) => wasm.
|
|
1126
|
-
|
|
1665
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_nullkeyword_free(ptr >>> 0, 1));
|
|
1666
|
+
/**
|
|
1667
|
+
* Represents a null keyword node in the CST.
|
|
1668
|
+
*/
|
|
1669
|
+
class NullKeyword {
|
|
1127
1670
|
static __wrap(ptr) {
|
|
1128
1671
|
ptr = ptr >>> 0;
|
|
1129
|
-
const obj = Object.create(
|
|
1672
|
+
const obj = Object.create(NullKeyword.prototype);
|
|
1130
1673
|
obj.__wbg_ptr = ptr;
|
|
1131
|
-
|
|
1674
|
+
NullKeywordFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1132
1675
|
return obj;
|
|
1133
1676
|
}
|
|
1134
1677
|
__destroy_into_raw() {
|
|
1135
1678
|
const ptr = this.__wbg_ptr;
|
|
1136
1679
|
this.__wbg_ptr = 0;
|
|
1137
|
-
|
|
1680
|
+
NullKeywordFinalization.unregister(this);
|
|
1138
1681
|
return ptr;
|
|
1139
1682
|
}
|
|
1140
1683
|
free() {
|
|
1141
1684
|
const ptr = this.__destroy_into_raw();
|
|
1142
|
-
wasm.
|
|
1685
|
+
wasm.__wbg_nullkeyword_free(ptr, 0);
|
|
1143
1686
|
}
|
|
1144
1687
|
/**
|
|
1145
|
-
*
|
|
1688
|
+
* Replaces this null keyword with a new value.
|
|
1689
|
+
* @param replacement - The new value to replace this null with
|
|
1690
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
1691
|
+
* @param {any} replacement
|
|
1692
|
+
* @returns {Node | undefined}
|
|
1146
1693
|
*/
|
|
1147
|
-
|
|
1148
|
-
const ret = wasm.
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1152
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1694
|
+
replaceWith(replacement) {
|
|
1695
|
+
const ret = wasm.nullkeyword_replaceWith(this.__wbg_ptr, replacement);
|
|
1696
|
+
if (ret[2]) {
|
|
1697
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1153
1698
|
}
|
|
1154
|
-
return
|
|
1699
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
1155
1700
|
}
|
|
1156
1701
|
/**
|
|
1157
|
-
*
|
|
1702
|
+
* Removes this node from its parent.
|
|
1703
|
+
* After calling this method, the node is detached from the CST and can no longer be used.
|
|
1158
1704
|
*/
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
try {
|
|
1163
|
-
const ret = wasm.objectprop_nameOrThrow(this.__wbg_ptr);
|
|
1164
|
-
var ptr1 = ret[0];
|
|
1165
|
-
var len1 = ret[1];
|
|
1166
|
-
if (ret[3]) {
|
|
1167
|
-
ptr1 = 0;
|
|
1168
|
-
len1 = 0;
|
|
1169
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
1170
|
-
}
|
|
1171
|
-
deferred2_0 = ptr1;
|
|
1172
|
-
deferred2_1 = len1;
|
|
1173
|
-
return getStringFromWasm0(ptr1, len1);
|
|
1174
|
-
}
|
|
1175
|
-
finally {
|
|
1176
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1177
|
-
}
|
|
1705
|
+
remove() {
|
|
1706
|
+
const ptr = this.__destroy_into_raw();
|
|
1707
|
+
wasm.nullkeyword_remove(ptr);
|
|
1178
1708
|
}
|
|
1179
1709
|
/**
|
|
1710
|
+
* Returns the parent node in the CST.
|
|
1711
|
+
* @returns The parent node, or undefined if this is the root
|
|
1180
1712
|
* @returns {Node | undefined}
|
|
1181
1713
|
*/
|
|
1182
|
-
|
|
1183
|
-
const ret = wasm.
|
|
1714
|
+
parent() {
|
|
1715
|
+
const ret = wasm.nullkeyword_parent(this.__wbg_ptr);
|
|
1184
1716
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1185
1717
|
}
|
|
1186
1718
|
/**
|
|
1187
|
-
*
|
|
1719
|
+
* Returns all ancestor nodes from parent to root.
|
|
1720
|
+
* @returns Array of ancestor nodes
|
|
1721
|
+
* @returns {Node[]}
|
|
1188
1722
|
*/
|
|
1189
|
-
|
|
1190
|
-
const ret = wasm.
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return Node.__wrap(ret[0]);
|
|
1723
|
+
ancestors() {
|
|
1724
|
+
const ret = wasm.nullkeyword_ancestors(this.__wbg_ptr);
|
|
1725
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1726
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1727
|
+
return v1;
|
|
1195
1728
|
}
|
|
1196
1729
|
/**
|
|
1197
|
-
*
|
|
1730
|
+
* Returns the index of this node within its parent's children.
|
|
1731
|
+
* @returns The child index
|
|
1732
|
+
* @returns {number}
|
|
1198
1733
|
*/
|
|
1199
|
-
|
|
1200
|
-
const ret = wasm.
|
|
1201
|
-
return ret
|
|
1734
|
+
childIndex() {
|
|
1735
|
+
const ret = wasm.nullkeyword_childIndex(this.__wbg_ptr);
|
|
1736
|
+
return ret >>> 0;
|
|
1202
1737
|
}
|
|
1203
1738
|
/**
|
|
1204
|
-
*
|
|
1739
|
+
* Returns the previous sibling node.
|
|
1740
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
1741
|
+
* @returns {Node | undefined}
|
|
1205
1742
|
*/
|
|
1206
|
-
|
|
1207
|
-
const ret = wasm.
|
|
1208
|
-
|
|
1209
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
1210
|
-
}
|
|
1211
|
-
return JsonObject.__wrap(ret[0]);
|
|
1743
|
+
previousSibling() {
|
|
1744
|
+
const ret = wasm.nullkeyword_previousSibling(this.__wbg_ptr);
|
|
1745
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1212
1746
|
}
|
|
1213
1747
|
/**
|
|
1214
|
-
*
|
|
1748
|
+
* Returns all previous sibling nodes.
|
|
1749
|
+
* @returns Array of previous siblings
|
|
1750
|
+
* @returns {Node[]}
|
|
1215
1751
|
*/
|
|
1216
|
-
|
|
1217
|
-
const ret = wasm.
|
|
1218
|
-
|
|
1752
|
+
previousSiblings() {
|
|
1753
|
+
const ret = wasm.nullkeyword_previousSiblings(this.__wbg_ptr);
|
|
1754
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1755
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1756
|
+
return v1;
|
|
1219
1757
|
}
|
|
1220
1758
|
/**
|
|
1221
|
-
*
|
|
1759
|
+
* Returns the next sibling node.
|
|
1760
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
1761
|
+
* @returns {Node | undefined}
|
|
1222
1762
|
*/
|
|
1223
|
-
|
|
1224
|
-
const ret = wasm.
|
|
1225
|
-
return ret === 0 ? undefined :
|
|
1763
|
+
nextSibling() {
|
|
1764
|
+
const ret = wasm.nullkeyword_nextSibling(this.__wbg_ptr);
|
|
1765
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1226
1766
|
}
|
|
1227
1767
|
/**
|
|
1228
|
-
*
|
|
1768
|
+
* Returns all next sibling nodes.
|
|
1769
|
+
* @returns Array of next siblings
|
|
1770
|
+
* @returns {Node[]}
|
|
1229
1771
|
*/
|
|
1230
|
-
|
|
1231
|
-
const ret = wasm.
|
|
1232
|
-
|
|
1233
|
-
|
|
1772
|
+
nextSiblings() {
|
|
1773
|
+
const ret = wasm.nullkeyword_nextSiblings(this.__wbg_ptr);
|
|
1774
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1775
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1776
|
+
return v1;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Returns the root node of the document.
|
|
1780
|
+
* @returns The root node, or undefined if detached
|
|
1781
|
+
* @returns {RootNode | undefined}
|
|
1782
|
+
*/
|
|
1783
|
+
rootNode() {
|
|
1784
|
+
const ret = wasm.nullkeyword_rootNode(this.__wbg_ptr);
|
|
1785
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Returns the indentation string used at this node's depth.
|
|
1789
|
+
* @returns The indentation string, or undefined if not applicable
|
|
1790
|
+
* @returns {string | undefined}
|
|
1791
|
+
*/
|
|
1792
|
+
indentText() {
|
|
1793
|
+
const ret = wasm.nullkeyword_indentText(this.__wbg_ptr);
|
|
1794
|
+
let v1;
|
|
1795
|
+
if (ret[0] !== 0) {
|
|
1796
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1797
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1234
1798
|
}
|
|
1235
|
-
return
|
|
1799
|
+
return v1;
|
|
1236
1800
|
}
|
|
1237
1801
|
/**
|
|
1238
|
-
*
|
|
1802
|
+
* Returns whether this node's container uses trailing commas.
|
|
1803
|
+
* @returns true if trailing commas are used
|
|
1804
|
+
* @returns {boolean}
|
|
1239
1805
|
*/
|
|
1240
|
-
|
|
1241
|
-
const ret = wasm.
|
|
1242
|
-
return
|
|
1806
|
+
usesTrailingCommas() {
|
|
1807
|
+
const ret = wasm.nullkeyword_usesTrailingCommas(this.__wbg_ptr);
|
|
1808
|
+
return ret !== 0;
|
|
1243
1809
|
}
|
|
1244
|
-
|
|
1810
|
+
}
|
|
1811
|
+
exports.NullKeyword = NullKeyword;
|
|
1812
|
+
const NumberLitFinalization = (typeof FinalizationRegistry === "undefined")
|
|
1813
|
+
? { register: () => { }, unregister: () => { } }
|
|
1814
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_numberlit_free(ptr >>> 0, 1));
|
|
1815
|
+
/**
|
|
1816
|
+
* Represents a number literal node in the CST.
|
|
1817
|
+
* Provides methods for manipulating number values.
|
|
1818
|
+
*/
|
|
1819
|
+
class NumberLit {
|
|
1820
|
+
static __wrap(ptr) {
|
|
1821
|
+
ptr = ptr >>> 0;
|
|
1822
|
+
const obj = Object.create(NumberLit.prototype);
|
|
1823
|
+
obj.__wbg_ptr = ptr;
|
|
1824
|
+
NumberLitFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1825
|
+
return obj;
|
|
1826
|
+
}
|
|
1827
|
+
__destroy_into_raw() {
|
|
1828
|
+
const ptr = this.__wbg_ptr;
|
|
1829
|
+
this.__wbg_ptr = 0;
|
|
1830
|
+
NumberLitFinalization.unregister(this);
|
|
1831
|
+
return ptr;
|
|
1832
|
+
}
|
|
1833
|
+
free() {
|
|
1245
1834
|
const ptr = this.__destroy_into_raw();
|
|
1246
|
-
wasm.
|
|
1835
|
+
wasm.__wbg_numberlit_free(ptr, 0);
|
|
1247
1836
|
}
|
|
1248
1837
|
/**
|
|
1249
|
-
*
|
|
1838
|
+
* Returns the raw string representation of the number.
|
|
1839
|
+
* Returns a string to preserve the exact formatting (e.g., "1.0" vs "1", "1e10" vs "10000000000").
|
|
1840
|
+
* @returns The number as a string
|
|
1841
|
+
* @returns {string}
|
|
1250
1842
|
*/
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1843
|
+
value() {
|
|
1844
|
+
let deferred1_0;
|
|
1845
|
+
let deferred1_1;
|
|
1846
|
+
try {
|
|
1847
|
+
const ret = wasm.numberlit_value(this.__wbg_ptr);
|
|
1848
|
+
deferred1_0 = ret[0];
|
|
1849
|
+
deferred1_1 = ret[1];
|
|
1850
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1851
|
+
}
|
|
1852
|
+
finally {
|
|
1853
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1854
|
+
}
|
|
1254
1855
|
}
|
|
1255
1856
|
/**
|
|
1256
|
-
*
|
|
1857
|
+
* Sets the raw number value.
|
|
1858
|
+
* The value should be a valid JSON number string (e.g., "42", "3.14", "1e10").
|
|
1859
|
+
* @param value - The raw number string to set
|
|
1860
|
+
* @param {string} value
|
|
1257
1861
|
*/
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1862
|
+
setRawValue(value) {
|
|
1863
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1864
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1865
|
+
wasm.numberlit_setRawValue(this.__wbg_ptr, ptr0, len0);
|
|
1263
1866
|
}
|
|
1264
1867
|
/**
|
|
1265
|
-
*
|
|
1266
|
-
* @param
|
|
1868
|
+
* Replaces this number literal with a new value.
|
|
1869
|
+
* @param replacement - The new value to replace this number with
|
|
1870
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
1871
|
+
* @param {any} replacement
|
|
1267
1872
|
* @returns {Node | undefined}
|
|
1268
1873
|
*/
|
|
1269
|
-
replaceWith(
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1874
|
+
replaceWith(replacement) {
|
|
1875
|
+
const ret = wasm.numberlit_replaceWith(this.__wbg_ptr, replacement);
|
|
1876
|
+
if (ret[2]) {
|
|
1877
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1878
|
+
}
|
|
1879
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
1276
1880
|
}
|
|
1277
1881
|
/**
|
|
1882
|
+
* Removes this node from its parent.
|
|
1883
|
+
* After calling this method, the node is detached from the CST and can no longer be used.
|
|
1884
|
+
*/
|
|
1885
|
+
remove() {
|
|
1886
|
+
const ptr = this.__destroy_into_raw();
|
|
1887
|
+
wasm.numberlit_remove(ptr);
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Returns the parent node in the CST.
|
|
1891
|
+
* @returns The parent node, or undefined if this is the root
|
|
1278
1892
|
* @returns {Node | undefined}
|
|
1279
1893
|
*/
|
|
1280
1894
|
parent() {
|
|
1281
|
-
const ret = wasm.
|
|
1895
|
+
const ret = wasm.numberlit_parent(this.__wbg_ptr);
|
|
1282
1896
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1283
1897
|
}
|
|
1284
1898
|
/**
|
|
1899
|
+
* Returns all ancestor nodes from parent to root.
|
|
1900
|
+
* @returns Array of ancestor nodes
|
|
1285
1901
|
* @returns {Node[]}
|
|
1286
1902
|
*/
|
|
1287
1903
|
ancestors() {
|
|
1288
|
-
const ret = wasm.
|
|
1904
|
+
const ret = wasm.numberlit_ancestors(this.__wbg_ptr);
|
|
1289
1905
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1290
1906
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1291
1907
|
return v1;
|
|
1292
1908
|
}
|
|
1293
1909
|
/**
|
|
1910
|
+
* Returns the index of this node within its parent's children.
|
|
1911
|
+
* @returns The child index
|
|
1294
1912
|
* @returns {number}
|
|
1295
1913
|
*/
|
|
1296
1914
|
childIndex() {
|
|
1297
|
-
const ret = wasm.
|
|
1915
|
+
const ret = wasm.numberlit_childIndex(this.__wbg_ptr);
|
|
1298
1916
|
return ret >>> 0;
|
|
1299
1917
|
}
|
|
1300
1918
|
/**
|
|
1919
|
+
* Returns the previous sibling node.
|
|
1920
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
1301
1921
|
* @returns {Node | undefined}
|
|
1302
1922
|
*/
|
|
1303
1923
|
previousSibling() {
|
|
1304
|
-
const ret = wasm.
|
|
1924
|
+
const ret = wasm.numberlit_previousSibling(this.__wbg_ptr);
|
|
1305
1925
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1306
1926
|
}
|
|
1307
1927
|
/**
|
|
1928
|
+
* Returns all previous sibling nodes.
|
|
1929
|
+
* @returns Array of previous siblings
|
|
1308
1930
|
* @returns {Node[]}
|
|
1309
1931
|
*/
|
|
1310
1932
|
previousSiblings() {
|
|
1311
|
-
const ret = wasm.
|
|
1933
|
+
const ret = wasm.numberlit_previousSiblings(this.__wbg_ptr);
|
|
1312
1934
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1313
1935
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1314
1936
|
return v1;
|
|
1315
1937
|
}
|
|
1316
1938
|
/**
|
|
1939
|
+
* Returns the next sibling node.
|
|
1940
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
1317
1941
|
* @returns {Node | undefined}
|
|
1318
1942
|
*/
|
|
1319
1943
|
nextSibling() {
|
|
1320
|
-
const ret = wasm.
|
|
1944
|
+
const ret = wasm.numberlit_nextSibling(this.__wbg_ptr);
|
|
1321
1945
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1322
1946
|
}
|
|
1323
1947
|
/**
|
|
1948
|
+
* Returns all next sibling nodes.
|
|
1949
|
+
* @returns Array of next siblings
|
|
1324
1950
|
* @returns {Node[]}
|
|
1325
1951
|
*/
|
|
1326
1952
|
nextSiblings() {
|
|
1327
|
-
const ret = wasm.
|
|
1953
|
+
const ret = wasm.numberlit_nextSiblings(this.__wbg_ptr);
|
|
1328
1954
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1329
1955
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1330
1956
|
return v1;
|
|
1331
1957
|
}
|
|
1332
1958
|
/**
|
|
1333
|
-
*
|
|
1334
|
-
|
|
1335
|
-
previousProperty() {
|
|
1336
|
-
const ret = wasm.objectprop_previousProperty(this.__wbg_ptr);
|
|
1337
|
-
return ret === 0 ? undefined : ObjectProp.__wrap(ret);
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
* @returns {ObjectProp | undefined}
|
|
1341
|
-
*/
|
|
1342
|
-
nextProperty() {
|
|
1343
|
-
const ret = wasm.objectprop_nextProperty(this.__wbg_ptr);
|
|
1344
|
-
return ret === 0 ? undefined : ObjectProp.__wrap(ret);
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1959
|
+
* Returns the root node of the document.
|
|
1960
|
+
* @returns The root node, or undefined if detached
|
|
1347
1961
|
* @returns {RootNode | undefined}
|
|
1348
1962
|
*/
|
|
1349
1963
|
rootNode() {
|
|
1350
|
-
const ret = wasm.
|
|
1964
|
+
const ret = wasm.numberlit_rootNode(this.__wbg_ptr);
|
|
1351
1965
|
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
1352
1966
|
}
|
|
1353
1967
|
/**
|
|
1968
|
+
* Returns the indentation string used at this node's depth.
|
|
1969
|
+
* @returns The indentation string, or undefined if not applicable
|
|
1354
1970
|
* @returns {string | undefined}
|
|
1355
1971
|
*/
|
|
1356
1972
|
indentText() {
|
|
1357
|
-
const ret = wasm.
|
|
1973
|
+
const ret = wasm.numberlit_indentText(this.__wbg_ptr);
|
|
1358
1974
|
let v1;
|
|
1359
1975
|
if (ret[0] !== 0) {
|
|
1360
1976
|
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
@@ -1363,256 +1979,732 @@ class ObjectProp {
|
|
|
1363
1979
|
return v1;
|
|
1364
1980
|
}
|
|
1365
1981
|
/**
|
|
1982
|
+
* Returns whether this node's container uses trailing commas.
|
|
1983
|
+
* @returns true if trailing commas are used
|
|
1366
1984
|
* @returns {boolean}
|
|
1367
1985
|
*/
|
|
1368
1986
|
usesTrailingCommas() {
|
|
1369
|
-
const ret = wasm.
|
|
1987
|
+
const ret = wasm.numberlit_usesTrailingCommas(this.__wbg_ptr);
|
|
1370
1988
|
return ret !== 0;
|
|
1371
1989
|
}
|
|
1372
|
-
/**
|
|
1373
|
-
* @returns {Node[]}
|
|
1374
|
-
*/
|
|
1375
|
-
children() {
|
|
1376
|
-
const ret = wasm.objectprop_children(this.__wbg_ptr);
|
|
1377
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1378
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1379
|
-
return v1;
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* @returns {Node[]}
|
|
1383
|
-
*/
|
|
1384
|
-
childrenExcludeTriviaAndTokens() {
|
|
1385
|
-
const ret = wasm.objectprop_childrenExcludeTriviaAndTokens(this.__wbg_ptr);
|
|
1386
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1387
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1388
|
-
return v1;
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* @param {number} index
|
|
1392
|
-
* @returns {Node | undefined}
|
|
1393
|
-
*/
|
|
1394
|
-
childAtIndex(index) {
|
|
1395
|
-
const ret = wasm.objectprop_childAtIndex(this.__wbg_ptr, index);
|
|
1396
|
-
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1397
|
-
}
|
|
1398
1990
|
}
|
|
1399
|
-
exports.
|
|
1400
|
-
const
|
|
1991
|
+
exports.NumberLit = NumberLit;
|
|
1992
|
+
const ObjectPropFinalization = (typeof FinalizationRegistry === "undefined")
|
|
1401
1993
|
? { register: () => { }, unregister: () => { } }
|
|
1402
|
-
: new FinalizationRegistry((ptr) => wasm.
|
|
1403
|
-
|
|
1994
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_objectprop_free(ptr >>> 0, 1));
|
|
1995
|
+
/**
|
|
1996
|
+
* Represents an object property (key-value pair) in the CST.
|
|
1997
|
+
* Provides methods for accessing and manipulating both the property name and its value.
|
|
1998
|
+
*/
|
|
1999
|
+
class ObjectProp {
|
|
1404
2000
|
static __wrap(ptr) {
|
|
1405
2001
|
ptr = ptr >>> 0;
|
|
1406
|
-
const obj = Object.create(
|
|
2002
|
+
const obj = Object.create(ObjectProp.prototype);
|
|
1407
2003
|
obj.__wbg_ptr = ptr;
|
|
1408
|
-
|
|
2004
|
+
ObjectPropFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1409
2005
|
return obj;
|
|
1410
2006
|
}
|
|
1411
2007
|
__destroy_into_raw() {
|
|
1412
2008
|
const ptr = this.__wbg_ptr;
|
|
1413
2009
|
this.__wbg_ptr = 0;
|
|
1414
|
-
|
|
2010
|
+
ObjectPropFinalization.unregister(this);
|
|
1415
2011
|
return ptr;
|
|
1416
2012
|
}
|
|
1417
2013
|
free() {
|
|
1418
2014
|
const ptr = this.__destroy_into_raw();
|
|
1419
|
-
wasm.
|
|
2015
|
+
wasm.__wbg_objectprop_free(ptr, 0);
|
|
1420
2016
|
}
|
|
1421
2017
|
/**
|
|
1422
|
-
*
|
|
1423
|
-
* @
|
|
1424
|
-
* @returns {
|
|
2018
|
+
* Returns the property name.
|
|
2019
|
+
* @returns The property name, or undefined if malformed
|
|
2020
|
+
* @returns {ObjectPropName | undefined}
|
|
1425
2021
|
*/
|
|
1426
|
-
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
|
|
2022
|
+
name() {
|
|
2023
|
+
const ret = wasm.objectprop_name(this.__wbg_ptr);
|
|
2024
|
+
return ret === 0 ? undefined : ObjectPropName.__wrap(ret);
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Returns the property name, throwing if malformed.
|
|
2028
|
+
* @returns The property name
|
|
2029
|
+
* @throws If the property name is malformed
|
|
2030
|
+
* @returns {ObjectPropName}
|
|
2031
|
+
*/
|
|
2032
|
+
nameOrThrow() {
|
|
2033
|
+
const ret = wasm.objectprop_nameOrThrow(this.__wbg_ptr);
|
|
1430
2034
|
if (ret[2]) {
|
|
1431
2035
|
throw takeFromExternrefTable0(ret[1]);
|
|
1432
2036
|
}
|
|
1433
|
-
return
|
|
2037
|
+
return ObjectPropName.__wrap(ret[0]);
|
|
1434
2038
|
}
|
|
1435
2039
|
/**
|
|
2040
|
+
* Returns the property value.
|
|
2041
|
+
* @returns The property value, or undefined if malformed
|
|
1436
2042
|
* @returns {Node | undefined}
|
|
1437
2043
|
*/
|
|
1438
2044
|
value() {
|
|
1439
|
-
const ret = wasm.
|
|
2045
|
+
const ret = wasm.objectprop_value(this.__wbg_ptr);
|
|
1440
2046
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1441
2047
|
}
|
|
1442
2048
|
/**
|
|
2049
|
+
* Returns the property value, throwing if malformed.
|
|
2050
|
+
* @returns The property value
|
|
2051
|
+
* @throws If the property value is malformed
|
|
1443
2052
|
* @returns {Node}
|
|
1444
2053
|
*/
|
|
1445
2054
|
valueOrThrow() {
|
|
1446
|
-
const ret = wasm.
|
|
2055
|
+
const ret = wasm.objectprop_valueOrThrow(this.__wbg_ptr);
|
|
1447
2056
|
if (ret[2]) {
|
|
1448
2057
|
throw takeFromExternrefTable0(ret[1]);
|
|
1449
2058
|
}
|
|
1450
2059
|
return Node.__wrap(ret[0]);
|
|
1451
2060
|
}
|
|
1452
2061
|
/**
|
|
2062
|
+
* Returns the property value if it's an object.
|
|
2063
|
+
* @returns The object value, or undefined if not an object
|
|
1453
2064
|
* @returns {JsonObject | undefined}
|
|
1454
2065
|
*/
|
|
1455
|
-
|
|
1456
|
-
const ret = wasm.
|
|
2066
|
+
valueIfObject() {
|
|
2067
|
+
const ret = wasm.objectprop_valueIfObject(this.__wbg_ptr);
|
|
1457
2068
|
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
1458
2069
|
}
|
|
1459
2070
|
/**
|
|
2071
|
+
* Returns the property value as an object, throwing if not an object.
|
|
2072
|
+
* @returns The object value
|
|
2073
|
+
* @throws If the property value is not an object
|
|
1460
2074
|
* @returns {JsonObject}
|
|
1461
2075
|
*/
|
|
1462
|
-
|
|
1463
|
-
const ret = wasm.
|
|
2076
|
+
valueIfObjectOrThrow() {
|
|
2077
|
+
const ret = wasm.objectprop_valueIfObjectOrThrow(this.__wbg_ptr);
|
|
1464
2078
|
if (ret[2]) {
|
|
1465
2079
|
throw takeFromExternrefTable0(ret[1]);
|
|
1466
2080
|
}
|
|
1467
2081
|
return JsonObject.__wrap(ret[0]);
|
|
1468
2082
|
}
|
|
1469
2083
|
/**
|
|
1470
|
-
*
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
const ret = wasm.rootnode_objectValueOrCreate(this.__wbg_ptr);
|
|
1474
|
-
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
1475
|
-
}
|
|
1476
|
-
/**
|
|
2084
|
+
* Gets the property value as an object, replacing the value with an empty object if needed.
|
|
2085
|
+
* Always returns an object by replacing non-object values.
|
|
2086
|
+
* @returns The object value (always succeeds)
|
|
1477
2087
|
* @returns {JsonObject}
|
|
1478
2088
|
*/
|
|
1479
|
-
|
|
1480
|
-
const ret = wasm.
|
|
2089
|
+
valueIfObjectOrForce() {
|
|
2090
|
+
const ret = wasm.objectprop_valueIfObjectOrForce(this.__wbg_ptr);
|
|
1481
2091
|
return JsonObject.__wrap(ret);
|
|
1482
2092
|
}
|
|
1483
2093
|
/**
|
|
2094
|
+
* Returns the property value if it's an array.
|
|
2095
|
+
* @returns The array value, or undefined if not an array
|
|
1484
2096
|
* @returns {JsonArray | undefined}
|
|
1485
2097
|
*/
|
|
1486
|
-
|
|
1487
|
-
const ret = wasm.
|
|
2098
|
+
valueIfArray() {
|
|
2099
|
+
const ret = wasm.objectprop_valueIfArray(this.__wbg_ptr);
|
|
1488
2100
|
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
1489
2101
|
}
|
|
1490
2102
|
/**
|
|
2103
|
+
* Returns the property value as an array, throwing if not an array.
|
|
2104
|
+
* @returns The array value
|
|
2105
|
+
* @throws If the property value is not an array
|
|
1491
2106
|
* @returns {JsonArray}
|
|
1492
2107
|
*/
|
|
1493
|
-
|
|
1494
|
-
const ret = wasm.
|
|
2108
|
+
valueIfArrayOrThrow() {
|
|
2109
|
+
const ret = wasm.objectprop_valueIfArrayOrThrow(this.__wbg_ptr);
|
|
1495
2110
|
if (ret[2]) {
|
|
1496
2111
|
throw takeFromExternrefTable0(ret[1]);
|
|
1497
2112
|
}
|
|
1498
2113
|
return JsonArray.__wrap(ret[0]);
|
|
1499
2114
|
}
|
|
1500
2115
|
/**
|
|
1501
|
-
*
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
const ret = wasm.rootnode_arrayValueOrCreate(this.__wbg_ptr);
|
|
1505
|
-
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
2116
|
+
* Gets the property value as an array, replacing the value with an empty array if needed.
|
|
2117
|
+
* Always returns an array by replacing non-array values.
|
|
2118
|
+
* @returns The array value (always succeeds)
|
|
1508
2119
|
* @returns {JsonArray}
|
|
1509
2120
|
*/
|
|
1510
|
-
|
|
1511
|
-
const ret = wasm.
|
|
2121
|
+
valueIfArrayOrForce() {
|
|
2122
|
+
const ret = wasm.objectprop_valueIfArrayOrForce(this.__wbg_ptr);
|
|
1512
2123
|
return JsonArray.__wrap(ret);
|
|
1513
2124
|
}
|
|
1514
2125
|
/**
|
|
1515
|
-
*
|
|
2126
|
+
* Removes this property from its parent object.
|
|
2127
|
+
* After calling this method, the property is detached from the CST and can no longer be used.
|
|
1516
2128
|
*/
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
try {
|
|
1521
|
-
const ret = wasm.rootnode_toString(this.__wbg_ptr);
|
|
1522
|
-
deferred1_0 = ret[0];
|
|
1523
|
-
deferred1_1 = ret[1];
|
|
1524
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
1525
|
-
}
|
|
1526
|
-
finally {
|
|
1527
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1528
|
-
}
|
|
2129
|
+
remove() {
|
|
2130
|
+
const ptr = this.__destroy_into_raw();
|
|
2131
|
+
wasm.objectprop_remove(ptr);
|
|
1529
2132
|
}
|
|
1530
2133
|
/**
|
|
1531
|
-
*
|
|
2134
|
+
* Returns the index of this property within its parent object.
|
|
2135
|
+
* @returns The property index
|
|
2136
|
+
* @returns {number}
|
|
1532
2137
|
*/
|
|
1533
|
-
|
|
1534
|
-
const ret = wasm.
|
|
1535
|
-
|
|
1536
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1537
|
-
return v1;
|
|
2138
|
+
propertyIndex() {
|
|
2139
|
+
const ret = wasm.objectprop_propertyIndex(this.__wbg_ptr);
|
|
2140
|
+
return ret >>> 0;
|
|
1538
2141
|
}
|
|
1539
2142
|
/**
|
|
1540
|
-
*
|
|
2143
|
+
* Sets the value of this property.
|
|
2144
|
+
* @param value - The new value to set
|
|
2145
|
+
* @param {any} value
|
|
1541
2146
|
*/
|
|
1542
|
-
setValue(
|
|
1543
|
-
const ret = wasm.
|
|
2147
|
+
setValue(value) {
|
|
2148
|
+
const ret = wasm.objectprop_setValue(this.__wbg_ptr, value);
|
|
1544
2149
|
if (ret[1]) {
|
|
1545
2150
|
throw takeFromExternrefTable0(ret[0]);
|
|
1546
2151
|
}
|
|
1547
2152
|
}
|
|
1548
2153
|
/**
|
|
1549
|
-
*
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
/**
|
|
1558
|
-
* @returns {string | undefined}
|
|
1559
|
-
*/
|
|
1560
|
-
singleIndentText() {
|
|
1561
|
-
const ret = wasm.rootnode_singleIndentText(this.__wbg_ptr);
|
|
1562
|
-
let v1;
|
|
1563
|
-
if (ret[0] !== 0) {
|
|
1564
|
-
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1565
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1566
|
-
}
|
|
1567
|
-
return v1;
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* @returns {string}
|
|
2154
|
+
* Replaces this property with a new property.
|
|
2155
|
+
* This allows changing both the property name and its value.
|
|
2156
|
+
* @param key - The new property name
|
|
2157
|
+
* @param replacement - The new value for the property
|
|
2158
|
+
* @returns The new node that replaced this property, or undefined if this was the root value
|
|
2159
|
+
* @param {string} key
|
|
2160
|
+
* @param {any} replacement
|
|
2161
|
+
* @returns {Node | undefined}
|
|
1571
2162
|
*/
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
deferred1_1 = ret[1];
|
|
1579
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
1580
|
-
}
|
|
1581
|
-
finally {
|
|
1582
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2163
|
+
replaceWith(key, replacement) {
|
|
2164
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2165
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2166
|
+
const ret = wasm.objectprop_replaceWith(this.__wbg_ptr, ptr0, len0, replacement);
|
|
2167
|
+
if (ret[2]) {
|
|
2168
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1583
2169
|
}
|
|
2170
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
1584
2171
|
}
|
|
1585
2172
|
/**
|
|
2173
|
+
* Returns the parent node in the CST.
|
|
2174
|
+
* @returns The parent node, or undefined if this is the root
|
|
1586
2175
|
* @returns {Node | undefined}
|
|
1587
2176
|
*/
|
|
1588
2177
|
parent() {
|
|
1589
|
-
const ret = wasm.
|
|
2178
|
+
const ret = wasm.objectprop_parent(this.__wbg_ptr);
|
|
1590
2179
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1591
2180
|
}
|
|
1592
2181
|
/**
|
|
1593
|
-
*
|
|
1594
|
-
|
|
1595
|
-
childIndex() {
|
|
1596
|
-
const ret = wasm.rootnode_childIndex(this.__wbg_ptr);
|
|
1597
|
-
return ret >>> 0;
|
|
1598
|
-
}
|
|
1599
|
-
/**
|
|
2182
|
+
* Returns all ancestor nodes from parent to root.
|
|
2183
|
+
* @returns Array of ancestor nodes
|
|
1600
2184
|
* @returns {Node[]}
|
|
1601
2185
|
*/
|
|
1602
2186
|
ancestors() {
|
|
1603
|
-
const ret = wasm.
|
|
2187
|
+
const ret = wasm.objectprop_ancestors(this.__wbg_ptr);
|
|
1604
2188
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1605
2189
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1606
2190
|
return v1;
|
|
1607
2191
|
}
|
|
1608
2192
|
/**
|
|
1609
|
-
*
|
|
2193
|
+
* Returns the index of this node within its parent's children.
|
|
2194
|
+
* @returns The child index
|
|
2195
|
+
* @returns {number}
|
|
1610
2196
|
*/
|
|
1611
|
-
|
|
1612
|
-
const ret = wasm.
|
|
2197
|
+
childIndex() {
|
|
2198
|
+
const ret = wasm.objectprop_childIndex(this.__wbg_ptr);
|
|
2199
|
+
return ret >>> 0;
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Returns the previous sibling node.
|
|
2203
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
2204
|
+
* @returns {Node | undefined}
|
|
2205
|
+
*/
|
|
2206
|
+
previousSibling() {
|
|
2207
|
+
const ret = wasm.objectprop_previousSibling(this.__wbg_ptr);
|
|
2208
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Returns all previous sibling nodes.
|
|
2212
|
+
* @returns Array of previous siblings
|
|
2213
|
+
* @returns {Node[]}
|
|
2214
|
+
*/
|
|
2215
|
+
previousSiblings() {
|
|
2216
|
+
const ret = wasm.objectprop_previousSiblings(this.__wbg_ptr);
|
|
2217
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2218
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2219
|
+
return v1;
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Returns the next sibling node.
|
|
2223
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
2224
|
+
* @returns {Node | undefined}
|
|
2225
|
+
*/
|
|
2226
|
+
nextSibling() {
|
|
2227
|
+
const ret = wasm.objectprop_nextSibling(this.__wbg_ptr);
|
|
2228
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Returns all next sibling nodes.
|
|
2232
|
+
* @returns Array of next siblings
|
|
2233
|
+
* @returns {Node[]}
|
|
2234
|
+
*/
|
|
2235
|
+
nextSiblings() {
|
|
2236
|
+
const ret = wasm.objectprop_nextSiblings(this.__wbg_ptr);
|
|
2237
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2238
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2239
|
+
return v1;
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Returns the previous property in the same object.
|
|
2243
|
+
* @returns The previous property, or undefined if this is the first property
|
|
2244
|
+
* @returns {ObjectProp | undefined}
|
|
2245
|
+
*/
|
|
2246
|
+
previousProperty() {
|
|
2247
|
+
const ret = wasm.objectprop_previousProperty(this.__wbg_ptr);
|
|
2248
|
+
return ret === 0 ? undefined : ObjectProp.__wrap(ret);
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Returns the next property in the same object.
|
|
2252
|
+
* @returns The next property, or undefined if this is the last property
|
|
2253
|
+
* @returns {ObjectProp | undefined}
|
|
2254
|
+
*/
|
|
2255
|
+
nextProperty() {
|
|
2256
|
+
const ret = wasm.objectprop_nextProperty(this.__wbg_ptr);
|
|
2257
|
+
return ret === 0 ? undefined : ObjectProp.__wrap(ret);
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Returns the root node of the document.
|
|
2261
|
+
* @returns The root node, or undefined if detached
|
|
2262
|
+
* @returns {RootNode | undefined}
|
|
2263
|
+
*/
|
|
2264
|
+
rootNode() {
|
|
2265
|
+
const ret = wasm.objectprop_rootNode(this.__wbg_ptr);
|
|
2266
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Returns the indentation string used at this node's depth.
|
|
2270
|
+
* @returns The indentation string, or undefined if not applicable
|
|
2271
|
+
* @returns {string | undefined}
|
|
2272
|
+
*/
|
|
2273
|
+
indentText() {
|
|
2274
|
+
const ret = wasm.objectprop_indentText(this.__wbg_ptr);
|
|
2275
|
+
let v1;
|
|
2276
|
+
if (ret[0] !== 0) {
|
|
2277
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
2278
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2279
|
+
}
|
|
2280
|
+
return v1;
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* Returns whether this node's container uses trailing commas.
|
|
2284
|
+
* @returns true if trailing commas are used
|
|
2285
|
+
* @returns {boolean}
|
|
2286
|
+
*/
|
|
2287
|
+
usesTrailingCommas() {
|
|
2288
|
+
const ret = wasm.objectprop_usesTrailingCommas(this.__wbg_ptr);
|
|
2289
|
+
return ret !== 0;
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Returns all child nodes including whitespace and punctuation.
|
|
2293
|
+
* @returns Array of all child nodes
|
|
2294
|
+
* @returns {Node[]}
|
|
2295
|
+
*/
|
|
2296
|
+
children() {
|
|
2297
|
+
const ret = wasm.objectprop_children(this.__wbg_ptr);
|
|
2298
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2299
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2300
|
+
return v1;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Returns child nodes excluding whitespace, comments, and punctuation.
|
|
2304
|
+
* @returns Array of significant child nodes
|
|
2305
|
+
* @returns {Node[]}
|
|
2306
|
+
*/
|
|
2307
|
+
childrenExcludeTriviaAndTokens() {
|
|
2308
|
+
const ret = wasm.objectprop_childrenExcludeTriviaAndTokens(this.__wbg_ptr);
|
|
2309
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2310
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2311
|
+
return v1;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Returns the child node at the specified index.
|
|
2315
|
+
* @param index - The child index
|
|
2316
|
+
* @returns The child node, or undefined if index is out of bounds
|
|
2317
|
+
* @param {number} index
|
|
2318
|
+
* @returns {Node | undefined}
|
|
2319
|
+
*/
|
|
2320
|
+
childAtIndex(index) {
|
|
2321
|
+
const ret = wasm.objectprop_childAtIndex(this.__wbg_ptr, index);
|
|
2322
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
exports.ObjectProp = ObjectProp;
|
|
2326
|
+
const ObjectPropNameFinalization = (typeof FinalizationRegistry === "undefined")
|
|
2327
|
+
? { register: () => { }, unregister: () => { } }
|
|
2328
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_objectpropname_free(ptr >>> 0, 1));
|
|
2329
|
+
/**
|
|
2330
|
+
* Represents the name part of an object property in the CST.
|
|
2331
|
+
* Can be either a quoted string or an unquoted word literal (when allowLooseObjectPropertyNames is enabled).
|
|
2332
|
+
*/
|
|
2333
|
+
class ObjectPropName {
|
|
2334
|
+
static __wrap(ptr) {
|
|
2335
|
+
ptr = ptr >>> 0;
|
|
2336
|
+
const obj = Object.create(ObjectPropName.prototype);
|
|
2337
|
+
obj.__wbg_ptr = ptr;
|
|
2338
|
+
ObjectPropNameFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2339
|
+
return obj;
|
|
2340
|
+
}
|
|
2341
|
+
__destroy_into_raw() {
|
|
2342
|
+
const ptr = this.__wbg_ptr;
|
|
2343
|
+
this.__wbg_ptr = 0;
|
|
2344
|
+
ObjectPropNameFinalization.unregister(this);
|
|
2345
|
+
return ptr;
|
|
2346
|
+
}
|
|
2347
|
+
free() {
|
|
2348
|
+
const ptr = this.__destroy_into_raw();
|
|
2349
|
+
wasm.__wbg_objectpropname_free(ptr, 0);
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Returns the decoded property name (unquoted and unescaped).
|
|
2353
|
+
* @returns The decoded property name
|
|
2354
|
+
* @returns {string}
|
|
2355
|
+
*/
|
|
2356
|
+
decodedValue() {
|
|
2357
|
+
let deferred2_0;
|
|
2358
|
+
let deferred2_1;
|
|
2359
|
+
try {
|
|
2360
|
+
const ret = wasm.objectpropname_decodedValue(this.__wbg_ptr);
|
|
2361
|
+
var ptr1 = ret[0];
|
|
2362
|
+
var len1 = ret[1];
|
|
2363
|
+
if (ret[3]) {
|
|
2364
|
+
ptr1 = 0;
|
|
2365
|
+
len1 = 0;
|
|
2366
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2367
|
+
}
|
|
2368
|
+
deferred2_0 = ptr1;
|
|
2369
|
+
deferred2_1 = len1;
|
|
2370
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2371
|
+
}
|
|
2372
|
+
finally {
|
|
2373
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Returns the parent node in the CST.
|
|
2378
|
+
* @returns The parent node, or undefined if this is the root
|
|
2379
|
+
* @returns {Node | undefined}
|
|
2380
|
+
*/
|
|
2381
|
+
parent() {
|
|
2382
|
+
const ret = wasm.objectpropname_parent(this.__wbg_ptr);
|
|
2383
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Returns the root node of the document.
|
|
2387
|
+
* @returns The root node, or undefined if detached
|
|
2388
|
+
* @returns {RootNode | undefined}
|
|
2389
|
+
*/
|
|
2390
|
+
rootNode() {
|
|
2391
|
+
const ret = wasm.objectpropname_rootNode(this.__wbg_ptr);
|
|
2392
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
2393
|
+
}
|
|
2394
|
+
/**
|
|
2395
|
+
* Returns the index of this node within its parent's children.
|
|
2396
|
+
* @returns The child index
|
|
2397
|
+
* @returns {number}
|
|
2398
|
+
*/
|
|
2399
|
+
childIndex() {
|
|
2400
|
+
const ret = wasm.objectpropname_childIndex(this.__wbg_ptr);
|
|
2401
|
+
return ret >>> 0;
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Returns all ancestor nodes from parent to root.
|
|
2405
|
+
* @returns Array of ancestor nodes
|
|
2406
|
+
* @returns {Node[]}
|
|
2407
|
+
*/
|
|
2408
|
+
ancestors() {
|
|
2409
|
+
const ret = wasm.objectpropname_ancestors(this.__wbg_ptr);
|
|
2410
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2411
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2412
|
+
return v1;
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* Returns the previous sibling node.
|
|
2416
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
2417
|
+
* @returns {Node | undefined}
|
|
2418
|
+
*/
|
|
2419
|
+
previousSibling() {
|
|
2420
|
+
const ret = wasm.objectpropname_previousSibling(this.__wbg_ptr);
|
|
2421
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Returns the next sibling node.
|
|
2425
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
2426
|
+
* @returns {Node | undefined}
|
|
2427
|
+
*/
|
|
2428
|
+
nextSibling() {
|
|
2429
|
+
const ret = wasm.objectpropname_nextSibling(this.__wbg_ptr);
|
|
2430
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Returns the indentation string used at this node's depth.
|
|
2434
|
+
* @returns The indentation string, or undefined if not applicable
|
|
2435
|
+
* @returns {string | undefined}
|
|
2436
|
+
*/
|
|
2437
|
+
indentText() {
|
|
2438
|
+
const ret = wasm.objectpropname_indentText(this.__wbg_ptr);
|
|
2439
|
+
let v1;
|
|
2440
|
+
if (ret[0] !== 0) {
|
|
2441
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
2442
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2443
|
+
}
|
|
2444
|
+
return v1;
|
|
2445
|
+
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Returns whether this node's container uses trailing commas.
|
|
2448
|
+
* @returns true if trailing commas are used
|
|
2449
|
+
* @returns {boolean}
|
|
2450
|
+
*/
|
|
2451
|
+
usesTrailingCommas() {
|
|
2452
|
+
const ret = wasm.objectpropname_usesTrailingCommas(this.__wbg_ptr);
|
|
2453
|
+
return ret !== 0;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
exports.ObjectPropName = ObjectPropName;
|
|
2457
|
+
const RootNodeFinalization = (typeof FinalizationRegistry === "undefined")
|
|
2458
|
+
? { register: () => { }, unregister: () => { } }
|
|
2459
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_rootnode_free(ptr >>> 0, 1));
|
|
2460
|
+
/**
|
|
2461
|
+
* Represents the root node of a JSONC document.
|
|
2462
|
+
* This is the entry point for manipulating the concrete syntax tree.
|
|
2463
|
+
*/
|
|
2464
|
+
class RootNode {
|
|
2465
|
+
static __wrap(ptr) {
|
|
2466
|
+
ptr = ptr >>> 0;
|
|
2467
|
+
const obj = Object.create(RootNode.prototype);
|
|
2468
|
+
obj.__wbg_ptr = ptr;
|
|
2469
|
+
RootNodeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2470
|
+
return obj;
|
|
2471
|
+
}
|
|
2472
|
+
__destroy_into_raw() {
|
|
2473
|
+
const ptr = this.__wbg_ptr;
|
|
2474
|
+
this.__wbg_ptr = 0;
|
|
2475
|
+
RootNodeFinalization.unregister(this);
|
|
2476
|
+
return ptr;
|
|
2477
|
+
}
|
|
2478
|
+
free() {
|
|
2479
|
+
const ptr = this.__destroy_into_raw();
|
|
2480
|
+
wasm.__wbg_rootnode_free(ptr, 0);
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Returns the root value node.
|
|
2484
|
+
* @returns The root value, or undefined if the document is empty
|
|
2485
|
+
* @returns {Node | undefined}
|
|
2486
|
+
*/
|
|
2487
|
+
value() {
|
|
2488
|
+
const ret = wasm.rootnode_value(this.__wbg_ptr);
|
|
2489
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2492
|
+
* Returns the root value node, throwing if empty.
|
|
2493
|
+
* @returns The root value
|
|
2494
|
+
* @throws If the document is empty
|
|
2495
|
+
* @returns {Node}
|
|
2496
|
+
*/
|
|
2497
|
+
valueOrThrow() {
|
|
2498
|
+
const ret = wasm.rootnode_valueOrThrow(this.__wbg_ptr);
|
|
2499
|
+
if (ret[2]) {
|
|
2500
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2501
|
+
}
|
|
2502
|
+
return Node.__wrap(ret[0]);
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Returns the root value as an object if it is one.
|
|
2506
|
+
* @returns The object, or undefined if root is not an object
|
|
2507
|
+
* @returns {JsonObject | undefined}
|
|
2508
|
+
*/
|
|
2509
|
+
asObject() {
|
|
2510
|
+
const ret = wasm.rootnode_asObject(this.__wbg_ptr);
|
|
2511
|
+
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
2512
|
+
}
|
|
2513
|
+
/**
|
|
2514
|
+
* Returns the root value as an object, throwing if it's not an object.
|
|
2515
|
+
* @returns The object
|
|
2516
|
+
* @throws If the root is not an object
|
|
2517
|
+
* @returns {JsonObject}
|
|
2518
|
+
*/
|
|
2519
|
+
asObjectOrThrow() {
|
|
2520
|
+
const ret = wasm.rootnode_asObjectOrThrow(this.__wbg_ptr);
|
|
2521
|
+
if (ret[2]) {
|
|
2522
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2523
|
+
}
|
|
2524
|
+
return JsonObject.__wrap(ret[0]);
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Returns the root value as an object, creating an empty object if the root is empty.
|
|
2528
|
+
* Returns undefined if the root contains a value of a different type.
|
|
2529
|
+
* @returns The object, or undefined if a non-object value exists
|
|
2530
|
+
* @returns {JsonObject | undefined}
|
|
2531
|
+
*/
|
|
2532
|
+
asObjectOrCreate() {
|
|
2533
|
+
const ret = wasm.rootnode_asObjectOrCreate(this.__wbg_ptr);
|
|
2534
|
+
return ret === 0 ? undefined : JsonObject.__wrap(ret);
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Returns the root value as an object, replacing any existing value with an empty object if needed.
|
|
2538
|
+
* Unlike asObjectOrCreate, this always returns an object by replacing non-object values.
|
|
2539
|
+
* @returns The object (always succeeds)
|
|
2540
|
+
* @returns {JsonObject}
|
|
2541
|
+
*/
|
|
2542
|
+
asObjectOrForce() {
|
|
2543
|
+
const ret = wasm.rootnode_asObjectOrForce(this.__wbg_ptr);
|
|
2544
|
+
return JsonObject.__wrap(ret);
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* Returns the root value as an array if it is one.
|
|
2548
|
+
* @returns The array, or undefined if root is not an array
|
|
2549
|
+
* @returns {JsonArray | undefined}
|
|
2550
|
+
*/
|
|
2551
|
+
asArray() {
|
|
2552
|
+
const ret = wasm.rootnode_asArray(this.__wbg_ptr);
|
|
2553
|
+
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
2554
|
+
}
|
|
2555
|
+
/**
|
|
2556
|
+
* Returns the root value as an array, throwing if it's not an array.
|
|
2557
|
+
* @returns The array
|
|
2558
|
+
* @throws If the root is not an array
|
|
2559
|
+
* @returns {JsonArray}
|
|
2560
|
+
*/
|
|
2561
|
+
asArrayOrThrow() {
|
|
2562
|
+
const ret = wasm.rootnode_asArrayOrThrow(this.__wbg_ptr);
|
|
2563
|
+
if (ret[2]) {
|
|
2564
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2565
|
+
}
|
|
2566
|
+
return JsonArray.__wrap(ret[0]);
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Returns the root value as an array, creating an empty array if the root is empty.
|
|
2570
|
+
* Returns undefined if the root contains a value of a different type.
|
|
2571
|
+
* @returns The array, or undefined if a non-array value exists
|
|
2572
|
+
* @returns {JsonArray | undefined}
|
|
2573
|
+
*/
|
|
2574
|
+
asArrayOrCreate() {
|
|
2575
|
+
const ret = wasm.rootnode_asArrayOrCreate(this.__wbg_ptr);
|
|
2576
|
+
return ret === 0 ? undefined : JsonArray.__wrap(ret);
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* Returns the root value as an array, replacing any existing value with an empty array if needed.
|
|
2580
|
+
* Unlike asArrayOrCreate, this always returns an array by replacing non-array values.
|
|
2581
|
+
* @returns The array (always succeeds)
|
|
2582
|
+
* @returns {JsonArray}
|
|
2583
|
+
*/
|
|
2584
|
+
asArrayOrForce() {
|
|
2585
|
+
const ret = wasm.rootnode_asArrayOrForce(this.__wbg_ptr);
|
|
2586
|
+
return JsonArray.__wrap(ret);
|
|
2587
|
+
}
|
|
2588
|
+
/**
|
|
2589
|
+
* Converts the CST back to a string representation.
|
|
2590
|
+
* @returns The JSONC string
|
|
2591
|
+
* @returns {string}
|
|
2592
|
+
*/
|
|
2593
|
+
toString() {
|
|
2594
|
+
let deferred1_0;
|
|
2595
|
+
let deferred1_1;
|
|
2596
|
+
try {
|
|
2597
|
+
const ret = wasm.rootnode_toString(this.__wbg_ptr);
|
|
2598
|
+
deferred1_0 = ret[0];
|
|
2599
|
+
deferred1_1 = ret[1];
|
|
2600
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2601
|
+
}
|
|
2602
|
+
finally {
|
|
2603
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
/**
|
|
2607
|
+
* Returns all child nodes including whitespace and punctuation.
|
|
2608
|
+
* @returns Array of all child nodes
|
|
2609
|
+
* @returns {Node[]}
|
|
2610
|
+
*/
|
|
2611
|
+
children() {
|
|
2612
|
+
const ret = wasm.rootnode_children(this.__wbg_ptr);
|
|
2613
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2614
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2615
|
+
return v1;
|
|
2616
|
+
}
|
|
2617
|
+
/**
|
|
2618
|
+
* Sets the root value of the document.
|
|
2619
|
+
* Accepts any JSON value: string, number, boolean, null, array, or object.
|
|
2620
|
+
* @param value - The new value to set
|
|
2621
|
+
* @param {any} value
|
|
2622
|
+
*/
|
|
2623
|
+
setValue(value) {
|
|
2624
|
+
const ret = wasm.rootnode_setValue(this.__wbg_ptr, value);
|
|
2625
|
+
if (ret[1]) {
|
|
2626
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
/**
|
|
2630
|
+
* Configures whether trailing commas should be used throughout the document.
|
|
2631
|
+
* When enabled, trailing commas are added for multiline formatting in objects and arrays.
|
|
2632
|
+
* @param enabled - Whether to enable trailing commas
|
|
2633
|
+
* @param {boolean} enabled
|
|
2634
|
+
*/
|
|
2635
|
+
setTrailingCommas(enabled) {
|
|
2636
|
+
wasm.rootnode_setTrailingCommas(this.__wbg_ptr, enabled);
|
|
2637
|
+
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Clears all children from the root node, leaving an empty document.
|
|
2640
|
+
*/
|
|
2641
|
+
clearChildren() {
|
|
2642
|
+
wasm.rootnode_clearChildren(this.__wbg_ptr);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Returns the indentation string used for a single level.
|
|
2646
|
+
* @returns The single-level indentation string (e.g., " " or "\t")
|
|
2647
|
+
* @returns {string | undefined}
|
|
2648
|
+
*/
|
|
2649
|
+
singleIndentText() {
|
|
2650
|
+
const ret = wasm.rootnode_singleIndentText(this.__wbg_ptr);
|
|
2651
|
+
let v1;
|
|
2652
|
+
if (ret[0] !== 0) {
|
|
2653
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
2654
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2655
|
+
}
|
|
2656
|
+
return v1;
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Returns the newline kind used in the document.
|
|
2660
|
+
* @returns Either "\n" or "\r\n"
|
|
2661
|
+
* @returns {string}
|
|
2662
|
+
*/
|
|
2663
|
+
newlineKind() {
|
|
2664
|
+
const ret = wasm.rootnode_newlineKind(this.__wbg_ptr);
|
|
2665
|
+
return ret;
|
|
2666
|
+
}
|
|
2667
|
+
/**
|
|
2668
|
+
* Returns the parent node in the CST.
|
|
2669
|
+
* @returns The parent node, or undefined if this is the root
|
|
2670
|
+
* @returns {Node | undefined}
|
|
2671
|
+
*/
|
|
2672
|
+
parent() {
|
|
2673
|
+
const ret = wasm.rootnode_parent(this.__wbg_ptr);
|
|
2674
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2675
|
+
}
|
|
2676
|
+
/**
|
|
2677
|
+
* Returns the index of this node within its parent's children.
|
|
2678
|
+
* @returns The child index
|
|
2679
|
+
* @returns {number}
|
|
2680
|
+
*/
|
|
2681
|
+
childIndex() {
|
|
2682
|
+
const ret = wasm.rootnode_childIndex(this.__wbg_ptr);
|
|
2683
|
+
return ret >>> 0;
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns all ancestor nodes from parent to root.
|
|
2687
|
+
* @returns Array of ancestor nodes
|
|
2688
|
+
* @returns {Node[]}
|
|
2689
|
+
*/
|
|
2690
|
+
ancestors() {
|
|
2691
|
+
const ret = wasm.rootnode_ancestors(this.__wbg_ptr);
|
|
2692
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2693
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2694
|
+
return v1;
|
|
2695
|
+
}
|
|
2696
|
+
/**
|
|
2697
|
+
* Returns the previous sibling node.
|
|
2698
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
2699
|
+
* @returns {Node | undefined}
|
|
2700
|
+
*/
|
|
2701
|
+
previousSibling() {
|
|
2702
|
+
const ret = wasm.rootnode_previousSibling(this.__wbg_ptr);
|
|
1613
2703
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1614
2704
|
}
|
|
1615
2705
|
/**
|
|
2706
|
+
* Returns all previous sibling nodes.
|
|
2707
|
+
* @returns Array of previous siblings
|
|
1616
2708
|
* @returns {Node[]}
|
|
1617
2709
|
*/
|
|
1618
2710
|
previousSiblings() {
|
|
@@ -1622,6 +2714,8 @@ class RootNode {
|
|
|
1622
2714
|
return v1;
|
|
1623
2715
|
}
|
|
1624
2716
|
/**
|
|
2717
|
+
* Returns the next sibling node.
|
|
2718
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
1625
2719
|
* @returns {Node | undefined}
|
|
1626
2720
|
*/
|
|
1627
2721
|
nextSibling() {
|
|
@@ -1629,6 +2723,8 @@ class RootNode {
|
|
|
1629
2723
|
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
1630
2724
|
}
|
|
1631
2725
|
/**
|
|
2726
|
+
* Returns all next sibling nodes.
|
|
2727
|
+
* @returns Array of next siblings
|
|
1632
2728
|
* @returns {Node[]}
|
|
1633
2729
|
*/
|
|
1634
2730
|
nextSiblings() {
|
|
@@ -1638,6 +2734,8 @@ class RootNode {
|
|
|
1638
2734
|
return v1;
|
|
1639
2735
|
}
|
|
1640
2736
|
/**
|
|
2737
|
+
* Returns the indentation string used at this node's depth.
|
|
2738
|
+
* @returns The indentation string, or undefined if not applicable
|
|
1641
2739
|
* @returns {string | undefined}
|
|
1642
2740
|
*/
|
|
1643
2741
|
indentText() {
|
|
@@ -1650,6 +2748,8 @@ class RootNode {
|
|
|
1650
2748
|
return v1;
|
|
1651
2749
|
}
|
|
1652
2750
|
/**
|
|
2751
|
+
* Returns whether this node's container uses trailing commas.
|
|
2752
|
+
* @returns true if trailing commas are used
|
|
1653
2753
|
* @returns {boolean}
|
|
1654
2754
|
*/
|
|
1655
2755
|
usesTrailingCommas() {
|
|
@@ -1657,6 +2757,8 @@ class RootNode {
|
|
|
1657
2757
|
return ret !== 0;
|
|
1658
2758
|
}
|
|
1659
2759
|
/**
|
|
2760
|
+
* Returns child nodes excluding whitespace, comments, and punctuation.
|
|
2761
|
+
* @returns Array of significant child nodes
|
|
1660
2762
|
* @returns {Node[]}
|
|
1661
2763
|
*/
|
|
1662
2764
|
childrenExcludeTriviaAndTokens() {
|
|
@@ -1666,6 +2768,9 @@ class RootNode {
|
|
|
1666
2768
|
return v1;
|
|
1667
2769
|
}
|
|
1668
2770
|
/**
|
|
2771
|
+
* Returns the child node at the specified index.
|
|
2772
|
+
* @param index - The child index
|
|
2773
|
+
* @returns The child node, or undefined if index is out of bounds
|
|
1669
2774
|
* @param {number} index
|
|
1670
2775
|
* @returns {Node | undefined}
|
|
1671
2776
|
*/
|
|
@@ -1675,6 +2780,388 @@ class RootNode {
|
|
|
1675
2780
|
}
|
|
1676
2781
|
}
|
|
1677
2782
|
exports.RootNode = RootNode;
|
|
2783
|
+
const StringLitFinalization = (typeof FinalizationRegistry === "undefined")
|
|
2784
|
+
? { register: () => { }, unregister: () => { } }
|
|
2785
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_stringlit_free(ptr >>> 0, 1));
|
|
2786
|
+
/**
|
|
2787
|
+
* Represents a string literal node in the CST.
|
|
2788
|
+
* Provides methods for manipulating string values and their formatting.
|
|
2789
|
+
*/
|
|
2790
|
+
class StringLit {
|
|
2791
|
+
static __wrap(ptr) {
|
|
2792
|
+
ptr = ptr >>> 0;
|
|
2793
|
+
const obj = Object.create(StringLit.prototype);
|
|
2794
|
+
obj.__wbg_ptr = ptr;
|
|
2795
|
+
StringLitFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2796
|
+
return obj;
|
|
2797
|
+
}
|
|
2798
|
+
__destroy_into_raw() {
|
|
2799
|
+
const ptr = this.__wbg_ptr;
|
|
2800
|
+
this.__wbg_ptr = 0;
|
|
2801
|
+
StringLitFinalization.unregister(this);
|
|
2802
|
+
return ptr;
|
|
2803
|
+
}
|
|
2804
|
+
free() {
|
|
2805
|
+
const ptr = this.__destroy_into_raw();
|
|
2806
|
+
wasm.__wbg_stringlit_free(ptr, 0);
|
|
2807
|
+
}
|
|
2808
|
+
/**
|
|
2809
|
+
* Returns the decoded string value (without quotes and with escape sequences processed).
|
|
2810
|
+
* @returns The decoded string value
|
|
2811
|
+
* @returns {string}
|
|
2812
|
+
*/
|
|
2813
|
+
decodedValue() {
|
|
2814
|
+
let deferred2_0;
|
|
2815
|
+
let deferred2_1;
|
|
2816
|
+
try {
|
|
2817
|
+
const ret = wasm.stringlit_decodedValue(this.__wbg_ptr);
|
|
2818
|
+
var ptr1 = ret[0];
|
|
2819
|
+
var len1 = ret[1];
|
|
2820
|
+
if (ret[3]) {
|
|
2821
|
+
ptr1 = 0;
|
|
2822
|
+
len1 = 0;
|
|
2823
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2824
|
+
}
|
|
2825
|
+
deferred2_0 = ptr1;
|
|
2826
|
+
deferred2_1 = len1;
|
|
2827
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2828
|
+
}
|
|
2829
|
+
finally {
|
|
2830
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
/**
|
|
2834
|
+
* Returns the raw string value including quotes and escape sequences.
|
|
2835
|
+
* @returns The raw string representation
|
|
2836
|
+
* @returns {string}
|
|
2837
|
+
*/
|
|
2838
|
+
rawValue() {
|
|
2839
|
+
let deferred1_0;
|
|
2840
|
+
let deferred1_1;
|
|
2841
|
+
try {
|
|
2842
|
+
const ret = wasm.stringlit_rawValue(this.__wbg_ptr);
|
|
2843
|
+
deferred1_0 = ret[0];
|
|
2844
|
+
deferred1_1 = ret[1];
|
|
2845
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2846
|
+
}
|
|
2847
|
+
finally {
|
|
2848
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
/**
|
|
2852
|
+
* Sets the raw string value (should include quotes).
|
|
2853
|
+
* @param value - The new raw string value
|
|
2854
|
+
* @param {string} value
|
|
2855
|
+
*/
|
|
2856
|
+
setRawValue(value) {
|
|
2857
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2858
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2859
|
+
wasm.stringlit_setRawValue(this.__wbg_ptr, ptr0, len0);
|
|
2860
|
+
}
|
|
2861
|
+
/**
|
|
2862
|
+
* Replaces this string literal with a new value.
|
|
2863
|
+
* @param replacement - The new value to replace this string with
|
|
2864
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
2865
|
+
* @param {any} replacement
|
|
2866
|
+
* @returns {Node | undefined}
|
|
2867
|
+
*/
|
|
2868
|
+
replaceWith(replacement) {
|
|
2869
|
+
const ret = wasm.stringlit_replaceWith(this.__wbg_ptr, replacement);
|
|
2870
|
+
if (ret[2]) {
|
|
2871
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2872
|
+
}
|
|
2873
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
2874
|
+
}
|
|
2875
|
+
/**
|
|
2876
|
+
* Removes this string literal from its parent.
|
|
2877
|
+
* After calling this method, the node is detached from the CST and can no longer be used.
|
|
2878
|
+
*/
|
|
2879
|
+
remove() {
|
|
2880
|
+
const ptr = this.__destroy_into_raw();
|
|
2881
|
+
wasm.stringlit_remove(ptr);
|
|
2882
|
+
}
|
|
2883
|
+
/**
|
|
2884
|
+
* Returns the parent node in the CST.
|
|
2885
|
+
* @returns The parent node, or undefined if this is the root
|
|
2886
|
+
* @returns {Node | undefined}
|
|
2887
|
+
*/
|
|
2888
|
+
parent() {
|
|
2889
|
+
const ret = wasm.stringlit_parent(this.__wbg_ptr);
|
|
2890
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Returns all ancestor nodes from parent to root.
|
|
2894
|
+
* @returns Array of ancestor nodes
|
|
2895
|
+
* @returns {Node[]}
|
|
2896
|
+
*/
|
|
2897
|
+
ancestors() {
|
|
2898
|
+
const ret = wasm.stringlit_ancestors(this.__wbg_ptr);
|
|
2899
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2900
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2901
|
+
return v1;
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2904
|
+
* Returns the index of this node within its parent's children.
|
|
2905
|
+
* @returns The child index
|
|
2906
|
+
* @returns {number}
|
|
2907
|
+
*/
|
|
2908
|
+
childIndex() {
|
|
2909
|
+
const ret = wasm.stringlit_childIndex(this.__wbg_ptr);
|
|
2910
|
+
return ret >>> 0;
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* Returns the previous sibling node.
|
|
2914
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
2915
|
+
* @returns {Node | undefined}
|
|
2916
|
+
*/
|
|
2917
|
+
previousSibling() {
|
|
2918
|
+
const ret = wasm.stringlit_previousSibling(this.__wbg_ptr);
|
|
2919
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Returns all previous sibling nodes.
|
|
2923
|
+
* @returns Array of previous siblings
|
|
2924
|
+
* @returns {Node[]}
|
|
2925
|
+
*/
|
|
2926
|
+
previousSiblings() {
|
|
2927
|
+
const ret = wasm.stringlit_previousSiblings(this.__wbg_ptr);
|
|
2928
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2929
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2930
|
+
return v1;
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* Returns the next sibling node.
|
|
2934
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
2935
|
+
* @returns {Node | undefined}
|
|
2936
|
+
*/
|
|
2937
|
+
nextSibling() {
|
|
2938
|
+
const ret = wasm.stringlit_nextSibling(this.__wbg_ptr);
|
|
2939
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* Returns all next sibling nodes.
|
|
2943
|
+
* @returns Array of next siblings
|
|
2944
|
+
* @returns {Node[]}
|
|
2945
|
+
*/
|
|
2946
|
+
nextSiblings() {
|
|
2947
|
+
const ret = wasm.stringlit_nextSiblings(this.__wbg_ptr);
|
|
2948
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2949
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2950
|
+
return v1;
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* Returns the root node of the document.
|
|
2954
|
+
* @returns The root node, or undefined if detached
|
|
2955
|
+
* @returns {RootNode | undefined}
|
|
2956
|
+
*/
|
|
2957
|
+
rootNode() {
|
|
2958
|
+
const ret = wasm.stringlit_rootNode(this.__wbg_ptr);
|
|
2959
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
2960
|
+
}
|
|
2961
|
+
/**
|
|
2962
|
+
* Returns the indentation string used at this node's depth.
|
|
2963
|
+
* @returns The indentation string, or undefined if not applicable
|
|
2964
|
+
* @returns {string | undefined}
|
|
2965
|
+
*/
|
|
2966
|
+
indentText() {
|
|
2967
|
+
const ret = wasm.stringlit_indentText(this.__wbg_ptr);
|
|
2968
|
+
let v1;
|
|
2969
|
+
if (ret[0] !== 0) {
|
|
2970
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
2971
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2972
|
+
}
|
|
2973
|
+
return v1;
|
|
2974
|
+
}
|
|
2975
|
+
/**
|
|
2976
|
+
* Returns whether this node's container uses trailing commas.
|
|
2977
|
+
* @returns true if trailing commas are used
|
|
2978
|
+
* @returns {boolean}
|
|
2979
|
+
*/
|
|
2980
|
+
usesTrailingCommas() {
|
|
2981
|
+
const ret = wasm.stringlit_usesTrailingCommas(this.__wbg_ptr);
|
|
2982
|
+
return ret !== 0;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
exports.StringLit = StringLit;
|
|
2986
|
+
const WordLitFinalization = (typeof FinalizationRegistry === "undefined")
|
|
2987
|
+
? { register: () => { }, unregister: () => { } }
|
|
2988
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_wordlit_free(ptr >>> 0, 1));
|
|
2989
|
+
/**
|
|
2990
|
+
* Represents an unquoted word literal node in the CST.
|
|
2991
|
+
* Used for unquoted property names when `allowLooseObjectPropertyNames` is enabled.
|
|
2992
|
+
*/
|
|
2993
|
+
class WordLit {
|
|
2994
|
+
static __wrap(ptr) {
|
|
2995
|
+
ptr = ptr >>> 0;
|
|
2996
|
+
const obj = Object.create(WordLit.prototype);
|
|
2997
|
+
obj.__wbg_ptr = ptr;
|
|
2998
|
+
WordLitFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2999
|
+
return obj;
|
|
3000
|
+
}
|
|
3001
|
+
__destroy_into_raw() {
|
|
3002
|
+
const ptr = this.__wbg_ptr;
|
|
3003
|
+
this.__wbg_ptr = 0;
|
|
3004
|
+
WordLitFinalization.unregister(this);
|
|
3005
|
+
return ptr;
|
|
3006
|
+
}
|
|
3007
|
+
free() {
|
|
3008
|
+
const ptr = this.__destroy_into_raw();
|
|
3009
|
+
wasm.__wbg_wordlit_free(ptr, 0);
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Returns the unquoted word value.
|
|
3013
|
+
* @returns The word literal as a string
|
|
3014
|
+
* @returns {string}
|
|
3015
|
+
*/
|
|
3016
|
+
value() {
|
|
3017
|
+
let deferred1_0;
|
|
3018
|
+
let deferred1_1;
|
|
3019
|
+
try {
|
|
3020
|
+
const ret = wasm.wordlit_value(this.__wbg_ptr);
|
|
3021
|
+
deferred1_0 = ret[0];
|
|
3022
|
+
deferred1_1 = ret[1];
|
|
3023
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
3024
|
+
}
|
|
3025
|
+
finally {
|
|
3026
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
/**
|
|
3030
|
+
* Sets the raw word value.
|
|
3031
|
+
* The value should be a valid unquoted identifier (alphanumeric and underscores).
|
|
3032
|
+
* @param value - The raw word string to set
|
|
3033
|
+
* @param {string} value
|
|
3034
|
+
*/
|
|
3035
|
+
setRawValue(value) {
|
|
3036
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3037
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3038
|
+
wasm.wordlit_setRawValue(this.__wbg_ptr, ptr0, len0);
|
|
3039
|
+
}
|
|
3040
|
+
/**
|
|
3041
|
+
* Replaces this word literal with a new value.
|
|
3042
|
+
* @param replacement - The new value to replace this word with
|
|
3043
|
+
* @returns The new node that replaced this one, or undefined if this was the root value
|
|
3044
|
+
* @param {any} replacement
|
|
3045
|
+
* @returns {Node | undefined}
|
|
3046
|
+
*/
|
|
3047
|
+
replaceWith(replacement) {
|
|
3048
|
+
const ret = wasm.wordlit_replaceWith(this.__wbg_ptr, replacement);
|
|
3049
|
+
if (ret[2]) {
|
|
3050
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3051
|
+
}
|
|
3052
|
+
return ret[0] === 0 ? undefined : Node.__wrap(ret[0]);
|
|
3053
|
+
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Removes this node from its parent.
|
|
3056
|
+
* After calling this method, the node is detached from the CST and can no longer be used.
|
|
3057
|
+
*/
|
|
3058
|
+
remove() {
|
|
3059
|
+
const ptr = this.__destroy_into_raw();
|
|
3060
|
+
wasm.wordlit_remove(ptr);
|
|
3061
|
+
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Returns the parent node in the CST.
|
|
3064
|
+
* @returns The parent node, or undefined if this is the root
|
|
3065
|
+
* @returns {Node | undefined}
|
|
3066
|
+
*/
|
|
3067
|
+
parent() {
|
|
3068
|
+
const ret = wasm.wordlit_parent(this.__wbg_ptr);
|
|
3069
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Returns all ancestor nodes from parent to root.
|
|
3073
|
+
* @returns Array of ancestor nodes
|
|
3074
|
+
* @returns {Node[]}
|
|
3075
|
+
*/
|
|
3076
|
+
ancestors() {
|
|
3077
|
+
const ret = wasm.wordlit_ancestors(this.__wbg_ptr);
|
|
3078
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
3079
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3080
|
+
return v1;
|
|
3081
|
+
}
|
|
3082
|
+
/**
|
|
3083
|
+
* Returns the index of this node within its parent's children.
|
|
3084
|
+
* @returns The child index
|
|
3085
|
+
* @returns {number}
|
|
3086
|
+
*/
|
|
3087
|
+
childIndex() {
|
|
3088
|
+
const ret = wasm.wordlit_childIndex(this.__wbg_ptr);
|
|
3089
|
+
return ret >>> 0;
|
|
3090
|
+
}
|
|
3091
|
+
/**
|
|
3092
|
+
* Returns the previous sibling node.
|
|
3093
|
+
* @returns The previous sibling, or undefined if this is the first child
|
|
3094
|
+
* @returns {Node | undefined}
|
|
3095
|
+
*/
|
|
3096
|
+
previousSibling() {
|
|
3097
|
+
const ret = wasm.wordlit_previousSibling(this.__wbg_ptr);
|
|
3098
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
3099
|
+
}
|
|
3100
|
+
/**
|
|
3101
|
+
* Returns all previous sibling nodes.
|
|
3102
|
+
* @returns Array of previous siblings
|
|
3103
|
+
* @returns {Node[]}
|
|
3104
|
+
*/
|
|
3105
|
+
previousSiblings() {
|
|
3106
|
+
const ret = wasm.wordlit_previousSiblings(this.__wbg_ptr);
|
|
3107
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
3108
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3109
|
+
return v1;
|
|
3110
|
+
}
|
|
3111
|
+
/**
|
|
3112
|
+
* Returns the next sibling node.
|
|
3113
|
+
* @returns The next sibling, or undefined if this is the last child
|
|
3114
|
+
* @returns {Node | undefined}
|
|
3115
|
+
*/
|
|
3116
|
+
nextSibling() {
|
|
3117
|
+
const ret = wasm.wordlit_nextSibling(this.__wbg_ptr);
|
|
3118
|
+
return ret === 0 ? undefined : Node.__wrap(ret);
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Returns all next sibling nodes.
|
|
3122
|
+
* @returns Array of next siblings
|
|
3123
|
+
* @returns {Node[]}
|
|
3124
|
+
*/
|
|
3125
|
+
nextSiblings() {
|
|
3126
|
+
const ret = wasm.wordlit_nextSiblings(this.__wbg_ptr);
|
|
3127
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
3128
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3129
|
+
return v1;
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Returns the root node of the document.
|
|
3133
|
+
* @returns The root node, or undefined if detached
|
|
3134
|
+
* @returns {RootNode | undefined}
|
|
3135
|
+
*/
|
|
3136
|
+
rootNode() {
|
|
3137
|
+
const ret = wasm.wordlit_rootNode(this.__wbg_ptr);
|
|
3138
|
+
return ret === 0 ? undefined : RootNode.__wrap(ret);
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Returns the indentation string used at this node's depth.
|
|
3142
|
+
* @returns The indentation string, or undefined if not applicable
|
|
3143
|
+
* @returns {string | undefined}
|
|
3144
|
+
*/
|
|
3145
|
+
indentText() {
|
|
3146
|
+
const ret = wasm.wordlit_indentText(this.__wbg_ptr);
|
|
3147
|
+
let v1;
|
|
3148
|
+
if (ret[0] !== 0) {
|
|
3149
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
3150
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
3151
|
+
}
|
|
3152
|
+
return v1;
|
|
3153
|
+
}
|
|
3154
|
+
/**
|
|
3155
|
+
* Returns whether this node's container uses trailing commas.
|
|
3156
|
+
* @returns true if trailing commas are used
|
|
3157
|
+
* @returns {boolean}
|
|
3158
|
+
*/
|
|
3159
|
+
usesTrailingCommas() {
|
|
3160
|
+
const ret = wasm.wordlit_usesTrailingCommas(this.__wbg_ptr);
|
|
3161
|
+
return ret !== 0;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
exports.WordLit = WordLit;
|
|
1678
3165
|
function __wbg_Error_90f14b053b2af32f(arg0, arg1) {
|
|
1679
3166
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1680
3167
|
return ret;
|