@clearlydev/nx-archweave 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -414,933 +414,8 @@ function resolveDryRun(options) {
414
414
  return process.env["NX_DRY_RUN"] === "true" || (options.dryRun ?? false);
415
415
  }
416
416
 
417
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
418
- function createScanner(text, ignoreTrivia = false) {
419
- const len = text.length;
420
- let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
421
- function scanHexDigits(count, exact) {
422
- let digits = 0;
423
- let value2 = 0;
424
- while (digits < count || !exact) {
425
- let ch = text.charCodeAt(pos);
426
- if (ch >= 48 && ch <= 57) {
427
- value2 = value2 * 16 + ch - 48;
428
- } else if (ch >= 65 && ch <= 70) {
429
- value2 = value2 * 16 + ch - 65 + 10;
430
- } else if (ch >= 97 && ch <= 102) {
431
- value2 = value2 * 16 + ch - 97 + 10;
432
- } else {
433
- break;
434
- }
435
- pos++;
436
- digits++;
437
- }
438
- if (digits < count) {
439
- value2 = -1;
440
- }
441
- return value2;
442
- }
443
- function setPosition(newPosition) {
444
- pos = newPosition;
445
- value = "";
446
- tokenOffset = 0;
447
- token = 16;
448
- scanError = 0;
449
- }
450
- function scanNumber() {
451
- let start = pos;
452
- if (text.charCodeAt(pos) === 48) {
453
- pos++;
454
- } else {
455
- pos++;
456
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
457
- pos++;
458
- }
459
- }
460
- if (pos < text.length && text.charCodeAt(pos) === 46) {
461
- pos++;
462
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
463
- pos++;
464
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
465
- pos++;
466
- }
467
- } else {
468
- scanError = 3;
469
- return text.substring(start, pos);
470
- }
471
- }
472
- let end = pos;
473
- if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
474
- pos++;
475
- if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
476
- pos++;
477
- }
478
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
479
- pos++;
480
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
481
- pos++;
482
- }
483
- end = pos;
484
- } else {
485
- scanError = 3;
486
- }
487
- }
488
- return text.substring(start, end);
489
- }
490
- function scanString() {
491
- let result = "", start = pos;
492
- while (true) {
493
- if (pos >= len) {
494
- result += text.substring(start, pos);
495
- scanError = 2;
496
- break;
497
- }
498
- const ch = text.charCodeAt(pos);
499
- if (ch === 34) {
500
- result += text.substring(start, pos);
501
- pos++;
502
- break;
503
- }
504
- if (ch === 92) {
505
- result += text.substring(start, pos);
506
- pos++;
507
- if (pos >= len) {
508
- scanError = 2;
509
- break;
510
- }
511
- const ch2 = text.charCodeAt(pos++);
512
- switch (ch2) {
513
- case 34:
514
- result += '"';
515
- break;
516
- case 92:
517
- result += "\\";
518
- break;
519
- case 47:
520
- result += "/";
521
- break;
522
- case 98:
523
- result += "\b";
524
- break;
525
- case 102:
526
- result += "\f";
527
- break;
528
- case 110:
529
- result += "\n";
530
- break;
531
- case 114:
532
- result += "\r";
533
- break;
534
- case 116:
535
- result += " ";
536
- break;
537
- case 117:
538
- const ch3 = scanHexDigits(4, true);
539
- if (ch3 >= 0) {
540
- result += String.fromCharCode(ch3);
541
- } else {
542
- scanError = 4;
543
- }
544
- break;
545
- default:
546
- scanError = 5;
547
- }
548
- start = pos;
549
- continue;
550
- }
551
- if (ch >= 0 && ch <= 31) {
552
- if (isLineBreak(ch)) {
553
- result += text.substring(start, pos);
554
- scanError = 2;
555
- break;
556
- } else {
557
- scanError = 6;
558
- }
559
- }
560
- pos++;
561
- }
562
- return result;
563
- }
564
- function scanNext() {
565
- value = "";
566
- scanError = 0;
567
- tokenOffset = pos;
568
- lineStartOffset = lineNumber;
569
- prevTokenLineStartOffset = tokenLineStartOffset;
570
- if (pos >= len) {
571
- tokenOffset = len;
572
- return token = 17;
573
- }
574
- let code = text.charCodeAt(pos);
575
- if (isWhiteSpace(code)) {
576
- do {
577
- pos++;
578
- value += String.fromCharCode(code);
579
- code = text.charCodeAt(pos);
580
- } while (isWhiteSpace(code));
581
- return token = 15;
582
- }
583
- if (isLineBreak(code)) {
584
- pos++;
585
- value += String.fromCharCode(code);
586
- if (code === 13 && text.charCodeAt(pos) === 10) {
587
- pos++;
588
- value += "\n";
589
- }
590
- lineNumber++;
591
- tokenLineStartOffset = pos;
592
- return token = 14;
593
- }
594
- switch (code) {
595
- // tokens: []{}:,
596
- case 123:
597
- pos++;
598
- return token = 1;
599
- case 125:
600
- pos++;
601
- return token = 2;
602
- case 91:
603
- pos++;
604
- return token = 3;
605
- case 93:
606
- pos++;
607
- return token = 4;
608
- case 58:
609
- pos++;
610
- return token = 6;
611
- case 44:
612
- pos++;
613
- return token = 5;
614
- // strings
615
- case 34:
616
- pos++;
617
- value = scanString();
618
- return token = 10;
619
- // comments
620
- case 47:
621
- const start = pos - 1;
622
- if (text.charCodeAt(pos + 1) === 47) {
623
- pos += 2;
624
- while (pos < len) {
625
- if (isLineBreak(text.charCodeAt(pos))) {
626
- break;
627
- }
628
- pos++;
629
- }
630
- value = text.substring(start, pos);
631
- return token = 12;
632
- }
633
- if (text.charCodeAt(pos + 1) === 42) {
634
- pos += 2;
635
- const safeLength = len - 1;
636
- let commentClosed = false;
637
- while (pos < safeLength) {
638
- const ch = text.charCodeAt(pos);
639
- if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
640
- pos += 2;
641
- commentClosed = true;
642
- break;
643
- }
644
- pos++;
645
- if (isLineBreak(ch)) {
646
- if (ch === 13 && text.charCodeAt(pos) === 10) {
647
- pos++;
648
- }
649
- lineNumber++;
650
- tokenLineStartOffset = pos;
651
- }
652
- }
653
- if (!commentClosed) {
654
- pos++;
655
- scanError = 1;
656
- }
657
- value = text.substring(start, pos);
658
- return token = 13;
659
- }
660
- value += String.fromCharCode(code);
661
- pos++;
662
- return token = 16;
663
- // numbers
664
- case 45:
665
- value += String.fromCharCode(code);
666
- pos++;
667
- if (pos === len || !isDigit(text.charCodeAt(pos))) {
668
- return token = 16;
669
- }
670
- // found a minus, followed by a number so
671
- // we fall through to proceed with scanning
672
- // numbers
673
- case 48:
674
- case 49:
675
- case 50:
676
- case 51:
677
- case 52:
678
- case 53:
679
- case 54:
680
- case 55:
681
- case 56:
682
- case 57:
683
- value += scanNumber();
684
- return token = 11;
685
- // literals and unknown symbols
686
- default:
687
- while (pos < len && isUnknownContentCharacter(code)) {
688
- pos++;
689
- code = text.charCodeAt(pos);
690
- }
691
- if (tokenOffset !== pos) {
692
- value = text.substring(tokenOffset, pos);
693
- switch (value) {
694
- case "true":
695
- return token = 8;
696
- case "false":
697
- return token = 9;
698
- case "null":
699
- return token = 7;
700
- }
701
- return token = 16;
702
- }
703
- value += String.fromCharCode(code);
704
- pos++;
705
- return token = 16;
706
- }
707
- }
708
- function isUnknownContentCharacter(code) {
709
- if (isWhiteSpace(code) || isLineBreak(code)) {
710
- return false;
711
- }
712
- switch (code) {
713
- case 125:
714
- case 93:
715
- case 123:
716
- case 91:
717
- case 34:
718
- case 58:
719
- case 44:
720
- case 47:
721
- return false;
722
- }
723
- return true;
724
- }
725
- function scanNextNonTrivia() {
726
- let result;
727
- do {
728
- result = scanNext();
729
- } while (result >= 12 && result <= 15);
730
- return result;
731
- }
732
- return {
733
- setPosition,
734
- getPosition: () => pos,
735
- scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
736
- getToken: () => token,
737
- getTokenValue: () => value,
738
- getTokenOffset: () => tokenOffset,
739
- getTokenLength: () => pos - tokenOffset,
740
- getTokenStartLine: () => lineStartOffset,
741
- getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
742
- getTokenError: () => scanError
743
- };
744
- }
745
- function isWhiteSpace(ch) {
746
- return ch === 32 || ch === 9;
747
- }
748
- function isLineBreak(ch) {
749
- return ch === 10 || ch === 13;
750
- }
751
- function isDigit(ch) {
752
- return ch >= 48 && ch <= 57;
753
- }
754
- var CharacterCodes;
755
- (function(CharacterCodes2) {
756
- CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
757
- CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
758
- CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
759
- CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
760
- CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
761
- CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
762
- CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
763
- CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
764
- CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
765
- CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
766
- CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
767
- CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
768
- CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
769
- CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
770
- CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
771
- CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
772
- CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
773
- CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
774
- CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
775
- CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
776
- CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
777
- CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
778
- CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
779
- CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
780
- CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
781
- CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
782
- CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
783
- CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
784
- CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
785
- CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
786
- CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
787
- CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
788
- CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
789
- CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
790
- CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
791
- CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
792
- CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
793
- CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
794
- CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
795
- CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
796
- CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
797
- CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
798
- CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
799
- CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
800
- CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
801
- CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
802
- CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
803
- CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
804
- CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
805
- CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
806
- CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
807
- CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
808
- CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
809
- CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
810
- CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
811
- CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
812
- CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
813
- CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
814
- CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
815
- CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
816
- CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
817
- CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
818
- CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
819
- CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
820
- CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
821
- CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
822
- CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
823
- CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
824
- CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
825
- CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
826
- CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
827
- CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
828
- CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
829
- CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
830
- CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
831
- CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
832
- CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
833
- CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
834
- CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
835
- CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
836
- })(CharacterCodes || (CharacterCodes = {}));
837
-
838
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
839
- var cachedSpaces = new Array(20).fill(0).map((_, index) => {
840
- return " ".repeat(index);
841
- });
842
- var maxCachedValues = 200;
843
- var cachedBreakLinesWithSpaces = {
844
- " ": {
845
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
846
- return "\n" + " ".repeat(index);
847
- }),
848
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
849
- return "\r" + " ".repeat(index);
850
- }),
851
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
852
- return "\r\n" + " ".repeat(index);
853
- })
854
- },
855
- " ": {
856
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
857
- return "\n" + " ".repeat(index);
858
- }),
859
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
860
- return "\r" + " ".repeat(index);
861
- }),
862
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
863
- return "\r\n" + " ".repeat(index);
864
- })
865
- }
866
- };
867
-
868
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
869
- var ParseOptions;
870
- (function(ParseOptions2) {
871
- ParseOptions2.DEFAULT = {
872
- allowTrailingComma: false
873
- };
874
- })(ParseOptions || (ParseOptions = {}));
875
- function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
876
- let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
877
- function ensurePropertyComplete(endOffset) {
878
- if (currentParent.type === "property") {
879
- currentParent.length = endOffset - currentParent.offset;
880
- currentParent = currentParent.parent;
881
- }
882
- }
883
- function onValue(valueNode) {
884
- currentParent.children.push(valueNode);
885
- return valueNode;
886
- }
887
- const visitor = {
888
- onObjectBegin: (offset) => {
889
- currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
890
- },
891
- onObjectProperty: (name, offset, length) => {
892
- currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
893
- currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
894
- },
895
- onObjectEnd: (offset, length) => {
896
- ensurePropertyComplete(offset + length);
897
- currentParent.length = offset + length - currentParent.offset;
898
- currentParent = currentParent.parent;
899
- ensurePropertyComplete(offset + length);
900
- },
901
- onArrayBegin: (offset, length) => {
902
- currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
903
- },
904
- onArrayEnd: (offset, length) => {
905
- currentParent.length = offset + length - currentParent.offset;
906
- currentParent = currentParent.parent;
907
- ensurePropertyComplete(offset + length);
908
- },
909
- onLiteralValue: (value, offset, length) => {
910
- onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
911
- ensurePropertyComplete(offset + length);
912
- },
913
- onSeparator: (sep, offset, length) => {
914
- if (currentParent.type === "property") {
915
- if (sep === ":") {
916
- currentParent.colonOffset = offset;
917
- } else if (sep === ",") {
918
- ensurePropertyComplete(offset);
919
- }
920
- }
921
- },
922
- onError: (error, offset, length) => {
923
- errors.push({ error, offset, length });
924
- }
925
- };
926
- visit(text, visitor, options);
927
- const result = currentParent.children[0];
928
- if (result) {
929
- delete result.parent;
930
- }
931
- return result;
932
- }
933
- function findNodeAtLocation(root, path) {
934
- if (!root) {
935
- return void 0;
936
- }
937
- let node = root;
938
- for (let segment of path) {
939
- if (typeof segment === "string") {
940
- if (node.type !== "object" || !Array.isArray(node.children)) {
941
- return void 0;
942
- }
943
- let found = false;
944
- for (const propertyNode of node.children) {
945
- if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
946
- node = propertyNode.children[1];
947
- found = true;
948
- break;
949
- }
950
- }
951
- if (!found) {
952
- return void 0;
953
- }
954
- } else {
955
- const index = segment;
956
- if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
957
- return void 0;
958
- }
959
- node = node.children[index];
960
- }
961
- }
962
- return node;
963
- }
964
- function visit(text, visitor, options = ParseOptions.DEFAULT) {
965
- const _scanner = createScanner(text, false);
966
- const _jsonPath = [];
967
- let suppressedCallbacks = 0;
968
- function toNoArgVisit(visitFunction) {
969
- return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
970
- }
971
- function toOneArgVisit(visitFunction) {
972
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
973
- }
974
- function toOneArgVisitWithPath(visitFunction) {
975
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
976
- }
977
- function toBeginVisit(visitFunction) {
978
- return visitFunction ? () => {
979
- if (suppressedCallbacks > 0) {
980
- suppressedCallbacks++;
981
- } else {
982
- let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
983
- if (cbReturn === false) {
984
- suppressedCallbacks = 1;
985
- }
986
- }
987
- } : () => true;
988
- }
989
- function toEndVisit(visitFunction) {
990
- return visitFunction ? () => {
991
- if (suppressedCallbacks > 0) {
992
- suppressedCallbacks--;
993
- }
994
- if (suppressedCallbacks === 0) {
995
- visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
996
- }
997
- } : () => true;
998
- }
999
- const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
1000
- const disallowComments = options && options.disallowComments;
1001
- const allowTrailingComma = options && options.allowTrailingComma;
1002
- function scanNext() {
1003
- while (true) {
1004
- const token = _scanner.scan();
1005
- switch (_scanner.getTokenError()) {
1006
- case 4:
1007
- handleError(
1008
- 14
1009
- /* ParseErrorCode.InvalidUnicode */
1010
- );
1011
- break;
1012
- case 5:
1013
- handleError(
1014
- 15
1015
- /* ParseErrorCode.InvalidEscapeCharacter */
1016
- );
1017
- break;
1018
- case 3:
1019
- handleError(
1020
- 13
1021
- /* ParseErrorCode.UnexpectedEndOfNumber */
1022
- );
1023
- break;
1024
- case 1:
1025
- if (!disallowComments) {
1026
- handleError(
1027
- 11
1028
- /* ParseErrorCode.UnexpectedEndOfComment */
1029
- );
1030
- }
1031
- break;
1032
- case 2:
1033
- handleError(
1034
- 12
1035
- /* ParseErrorCode.UnexpectedEndOfString */
1036
- );
1037
- break;
1038
- case 6:
1039
- handleError(
1040
- 16
1041
- /* ParseErrorCode.InvalidCharacter */
1042
- );
1043
- break;
1044
- }
1045
- switch (token) {
1046
- case 12:
1047
- case 13:
1048
- if (disallowComments) {
1049
- handleError(
1050
- 10
1051
- /* ParseErrorCode.InvalidCommentToken */
1052
- );
1053
- } else {
1054
- onComment();
1055
- }
1056
- break;
1057
- case 16:
1058
- handleError(
1059
- 1
1060
- /* ParseErrorCode.InvalidSymbol */
1061
- );
1062
- break;
1063
- case 15:
1064
- case 14:
1065
- break;
1066
- default:
1067
- return token;
1068
- }
1069
- }
1070
- }
1071
- function handleError(error, skipUntilAfter = [], skipUntil = []) {
1072
- onError(error);
1073
- if (skipUntilAfter.length + skipUntil.length > 0) {
1074
- let token = _scanner.getToken();
1075
- while (token !== 17) {
1076
- if (skipUntilAfter.indexOf(token) !== -1) {
1077
- scanNext();
1078
- break;
1079
- } else if (skipUntil.indexOf(token) !== -1) {
1080
- break;
1081
- }
1082
- token = scanNext();
1083
- }
1084
- }
1085
- }
1086
- function parseString(isValue) {
1087
- const value = _scanner.getTokenValue();
1088
- if (isValue) {
1089
- onLiteralValue(value);
1090
- } else {
1091
- onObjectProperty(value);
1092
- _jsonPath.push(value);
1093
- }
1094
- scanNext();
1095
- return true;
1096
- }
1097
- function parseLiteral() {
1098
- switch (_scanner.getToken()) {
1099
- case 11:
1100
- const tokenValue = _scanner.getTokenValue();
1101
- let value = Number(tokenValue);
1102
- if (isNaN(value)) {
1103
- handleError(
1104
- 2
1105
- /* ParseErrorCode.InvalidNumberFormat */
1106
- );
1107
- value = 0;
1108
- }
1109
- onLiteralValue(value);
1110
- break;
1111
- case 7:
1112
- onLiteralValue(null);
1113
- break;
1114
- case 8:
1115
- onLiteralValue(true);
1116
- break;
1117
- case 9:
1118
- onLiteralValue(false);
1119
- break;
1120
- default:
1121
- return false;
1122
- }
1123
- scanNext();
1124
- return true;
1125
- }
1126
- function parseProperty() {
1127
- if (_scanner.getToken() !== 10) {
1128
- handleError(3, [], [
1129
- 2,
1130
- 5
1131
- /* SyntaxKind.CommaToken */
1132
- ]);
1133
- return false;
1134
- }
1135
- parseString(false);
1136
- if (_scanner.getToken() === 6) {
1137
- onSeparator(":");
1138
- scanNext();
1139
- if (!parseValue()) {
1140
- handleError(4, [], [
1141
- 2,
1142
- 5
1143
- /* SyntaxKind.CommaToken */
1144
- ]);
1145
- }
1146
- } else {
1147
- handleError(5, [], [
1148
- 2,
1149
- 5
1150
- /* SyntaxKind.CommaToken */
1151
- ]);
1152
- }
1153
- _jsonPath.pop();
1154
- return true;
1155
- }
1156
- function parseObject() {
1157
- onObjectBegin();
1158
- scanNext();
1159
- let needsComma = false;
1160
- while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
1161
- if (_scanner.getToken() === 5) {
1162
- if (!needsComma) {
1163
- handleError(4, [], []);
1164
- }
1165
- onSeparator(",");
1166
- scanNext();
1167
- if (_scanner.getToken() === 2 && allowTrailingComma) {
1168
- break;
1169
- }
1170
- } else if (needsComma) {
1171
- handleError(6, [], []);
1172
- }
1173
- if (!parseProperty()) {
1174
- handleError(4, [], [
1175
- 2,
1176
- 5
1177
- /* SyntaxKind.CommaToken */
1178
- ]);
1179
- }
1180
- needsComma = true;
1181
- }
1182
- onObjectEnd();
1183
- if (_scanner.getToken() !== 2) {
1184
- handleError(7, [
1185
- 2
1186
- /* SyntaxKind.CloseBraceToken */
1187
- ], []);
1188
- } else {
1189
- scanNext();
1190
- }
1191
- return true;
1192
- }
1193
- function parseArray() {
1194
- onArrayBegin();
1195
- scanNext();
1196
- let isFirstElement = true;
1197
- let needsComma = false;
1198
- while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
1199
- if (_scanner.getToken() === 5) {
1200
- if (!needsComma) {
1201
- handleError(4, [], []);
1202
- }
1203
- onSeparator(",");
1204
- scanNext();
1205
- if (_scanner.getToken() === 4 && allowTrailingComma) {
1206
- break;
1207
- }
1208
- } else if (needsComma) {
1209
- handleError(6, [], []);
1210
- }
1211
- if (isFirstElement) {
1212
- _jsonPath.push(0);
1213
- isFirstElement = false;
1214
- } else {
1215
- _jsonPath[_jsonPath.length - 1]++;
1216
- }
1217
- if (!parseValue()) {
1218
- handleError(4, [], [
1219
- 4,
1220
- 5
1221
- /* SyntaxKind.CommaToken */
1222
- ]);
1223
- }
1224
- needsComma = true;
1225
- }
1226
- onArrayEnd();
1227
- if (!isFirstElement) {
1228
- _jsonPath.pop();
1229
- }
1230
- if (_scanner.getToken() !== 4) {
1231
- handleError(8, [
1232
- 4
1233
- /* SyntaxKind.CloseBracketToken */
1234
- ], []);
1235
- } else {
1236
- scanNext();
1237
- }
1238
- return true;
1239
- }
1240
- function parseValue() {
1241
- switch (_scanner.getToken()) {
1242
- case 3:
1243
- return parseArray();
1244
- case 1:
1245
- return parseObject();
1246
- case 10:
1247
- return parseString(true);
1248
- default:
1249
- return parseLiteral();
1250
- }
1251
- }
1252
- scanNext();
1253
- if (_scanner.getToken() === 17) {
1254
- if (options.allowEmptyContent) {
1255
- return true;
1256
- }
1257
- handleError(4, [], []);
1258
- return false;
1259
- }
1260
- if (!parseValue()) {
1261
- handleError(4, [], []);
1262
- return false;
1263
- }
1264
- if (_scanner.getToken() !== 17) {
1265
- handleError(9, [], []);
1266
- }
1267
- return true;
1268
- }
1269
- function getNodeType(value) {
1270
- switch (typeof value) {
1271
- case "boolean":
1272
- return "boolean";
1273
- case "number":
1274
- return "number";
1275
- case "string":
1276
- return "string";
1277
- case "object": {
1278
- if (!value) {
1279
- return "null";
1280
- } else if (Array.isArray(value)) {
1281
- return "array";
1282
- }
1283
- return "object";
1284
- }
1285
- default:
1286
- return "null";
1287
- }
1288
- }
1289
-
1290
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
1291
- var ScanError;
1292
- (function(ScanError2) {
1293
- ScanError2[ScanError2["None"] = 0] = "None";
1294
- ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
1295
- ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
1296
- ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
1297
- ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
1298
- ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
1299
- ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
1300
- })(ScanError || (ScanError = {}));
1301
- var SyntaxKind;
1302
- (function(SyntaxKind2) {
1303
- SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
1304
- SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
1305
- SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
1306
- SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
1307
- SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
1308
- SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
1309
- SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
1310
- SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
1311
- SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
1312
- SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
1313
- SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
1314
- SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
1315
- SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
1316
- SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
1317
- SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
1318
- SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
1319
- SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
1320
- })(SyntaxKind || (SyntaxKind = {}));
1321
- var parseTree2 = parseTree;
1322
- var findNodeAtLocation2 = findNodeAtLocation;
1323
- var ParseErrorCode;
1324
- (function(ParseErrorCode2) {
1325
- ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
1326
- ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
1327
- ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
1328
- ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
1329
- ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
1330
- ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
1331
- ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
1332
- ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
1333
- ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
1334
- ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
1335
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
1336
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
1337
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
1338
- ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
1339
- ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
1340
- ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
1341
- })(ParseErrorCode || (ParseErrorCode = {}));
1342
-
1343
417
  // src/generators/shared/json-edit.ts
418
+ import { findNodeAtLocation, parseTree } from "jsonc-parser";
1344
419
  function detectIndent(raw) {
1345
420
  for (const line of raw.split("\n")) {
1346
421
  const match = /^(\t+| +)/.exec(line);
@@ -1398,14 +473,14 @@ function insertProperty(raw, object, key, value, style) {
1398
473
  }
1399
474
  function setJsonValue(raw, path, value) {
1400
475
  const style = styleOf(raw);
1401
- const root = parseTree2(raw);
476
+ const root = parseTree(raw);
1402
477
  if (root === void 0) throw new Error("setJsonValue: not a JSON document");
1403
- const existing = findNodeAtLocation2(root, path);
478
+ const existing = findNodeAtLocation(root, path);
1404
479
  if (existing !== void 0) {
1405
480
  return splice(raw, existing.offset, existing.offset + existing.length, renderValue(value, lineIndentAt(raw, existing.offset), style));
1406
481
  }
1407
482
  for (let depth = path.length - 1; depth >= 0; depth--) {
1408
- const parent = depth === 0 ? root : findNodeAtLocation2(root, path.slice(0, depth));
483
+ const parent = depth === 0 ? root : findNodeAtLocation(root, path.slice(0, depth));
1409
484
  if (parent === void 0) continue;
1410
485
  if (parent.type !== "object") throw new Error(`setJsonValue: ${path.slice(0, depth).join(".") || "the root"} is not an object`);
1411
486
  return insertProperty(raw, parent, path[depth], nest(path.slice(depth + 1), value), style);
@@ -1414,8 +489,8 @@ function setJsonValue(raw, path, value) {
1414
489
  }
1415
490
  function appendJsonArrayItem(raw, path, item) {
1416
491
  const style = styleOf(raw);
1417
- const root = parseTree2(raw);
1418
- const array = root === void 0 ? void 0 : findNodeAtLocation2(root, path);
492
+ const root = parseTree(raw);
493
+ const array = root === void 0 ? void 0 : findNodeAtLocation(root, path);
1419
494
  if (array === void 0) return setJsonValue(raw, path, [item]);
1420
495
  if (array.type !== "array") throw new Error(`appendJsonArrayItem: ${path.join(".")} is not an array`);
1421
496
  const items = array.children ?? [];