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