@meistrari/tela-cli 0.7.53 → 0.7.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2152 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,9 +6,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
9
12
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
13
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
14
|
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
12
19
|
var __copyProps = (to, from, except, desc) => {
|
|
13
20
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
21
|
for (let key of __getOwnPropNames(from))
|
|
@@ -25,6 +32,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
32
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
33
|
mod
|
|
27
34
|
));
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
36
|
|
|
29
37
|
// ../../packages/local-config/dist/credentials.js
|
|
30
38
|
var require_credentials = __commonJS({
|
|
@@ -7706,10 +7714,2149 @@ var require_dist2 = __commonJS({
|
|
|
7706
7714
|
}
|
|
7707
7715
|
});
|
|
7708
7716
|
|
|
7717
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
7718
|
+
function createScanner(text, ignoreTrivia = false) {
|
|
7719
|
+
const len = text.length;
|
|
7720
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
7721
|
+
function scanHexDigits(count, exact) {
|
|
7722
|
+
let digits = 0;
|
|
7723
|
+
let value2 = 0;
|
|
7724
|
+
while (digits < count || !exact) {
|
|
7725
|
+
let ch = text.charCodeAt(pos);
|
|
7726
|
+
if (ch >= 48 && ch <= 57) {
|
|
7727
|
+
value2 = value2 * 16 + ch - 48;
|
|
7728
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
7729
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
7730
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
7731
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
7732
|
+
} else {
|
|
7733
|
+
break;
|
|
7734
|
+
}
|
|
7735
|
+
pos++;
|
|
7736
|
+
digits++;
|
|
7737
|
+
}
|
|
7738
|
+
if (digits < count) {
|
|
7739
|
+
value2 = -1;
|
|
7740
|
+
}
|
|
7741
|
+
return value2;
|
|
7742
|
+
}
|
|
7743
|
+
function setPosition(newPosition) {
|
|
7744
|
+
pos = newPosition;
|
|
7745
|
+
value = "";
|
|
7746
|
+
tokenOffset = 0;
|
|
7747
|
+
token = 16;
|
|
7748
|
+
scanError = 0;
|
|
7749
|
+
}
|
|
7750
|
+
function scanNumber() {
|
|
7751
|
+
let start = pos;
|
|
7752
|
+
if (text.charCodeAt(pos) === 48) {
|
|
7753
|
+
pos++;
|
|
7754
|
+
} else {
|
|
7755
|
+
pos++;
|
|
7756
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
7757
|
+
pos++;
|
|
7758
|
+
}
|
|
7759
|
+
}
|
|
7760
|
+
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
7761
|
+
pos++;
|
|
7762
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
7763
|
+
pos++;
|
|
7764
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
7765
|
+
pos++;
|
|
7766
|
+
}
|
|
7767
|
+
} else {
|
|
7768
|
+
scanError = 3;
|
|
7769
|
+
return text.substring(start, pos);
|
|
7770
|
+
}
|
|
7771
|
+
}
|
|
7772
|
+
let end = pos;
|
|
7773
|
+
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
7774
|
+
pos++;
|
|
7775
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
7776
|
+
pos++;
|
|
7777
|
+
}
|
|
7778
|
+
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
7779
|
+
pos++;
|
|
7780
|
+
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
7781
|
+
pos++;
|
|
7782
|
+
}
|
|
7783
|
+
end = pos;
|
|
7784
|
+
} else {
|
|
7785
|
+
scanError = 3;
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
return text.substring(start, end);
|
|
7789
|
+
}
|
|
7790
|
+
function scanString() {
|
|
7791
|
+
let result = "", start = pos;
|
|
7792
|
+
while (true) {
|
|
7793
|
+
if (pos >= len) {
|
|
7794
|
+
result += text.substring(start, pos);
|
|
7795
|
+
scanError = 2;
|
|
7796
|
+
break;
|
|
7797
|
+
}
|
|
7798
|
+
const ch = text.charCodeAt(pos);
|
|
7799
|
+
if (ch === 34) {
|
|
7800
|
+
result += text.substring(start, pos);
|
|
7801
|
+
pos++;
|
|
7802
|
+
break;
|
|
7803
|
+
}
|
|
7804
|
+
if (ch === 92) {
|
|
7805
|
+
result += text.substring(start, pos);
|
|
7806
|
+
pos++;
|
|
7807
|
+
if (pos >= len) {
|
|
7808
|
+
scanError = 2;
|
|
7809
|
+
break;
|
|
7810
|
+
}
|
|
7811
|
+
const ch2 = text.charCodeAt(pos++);
|
|
7812
|
+
switch (ch2) {
|
|
7813
|
+
case 34:
|
|
7814
|
+
result += '"';
|
|
7815
|
+
break;
|
|
7816
|
+
case 92:
|
|
7817
|
+
result += "\\";
|
|
7818
|
+
break;
|
|
7819
|
+
case 47:
|
|
7820
|
+
result += "/";
|
|
7821
|
+
break;
|
|
7822
|
+
case 98:
|
|
7823
|
+
result += "\b";
|
|
7824
|
+
break;
|
|
7825
|
+
case 102:
|
|
7826
|
+
result += "\f";
|
|
7827
|
+
break;
|
|
7828
|
+
case 110:
|
|
7829
|
+
result += "\n";
|
|
7830
|
+
break;
|
|
7831
|
+
case 114:
|
|
7832
|
+
result += "\r";
|
|
7833
|
+
break;
|
|
7834
|
+
case 116:
|
|
7835
|
+
result += " ";
|
|
7836
|
+
break;
|
|
7837
|
+
case 117:
|
|
7838
|
+
const ch3 = scanHexDigits(4, true);
|
|
7839
|
+
if (ch3 >= 0) {
|
|
7840
|
+
result += String.fromCharCode(ch3);
|
|
7841
|
+
} else {
|
|
7842
|
+
scanError = 4;
|
|
7843
|
+
}
|
|
7844
|
+
break;
|
|
7845
|
+
default:
|
|
7846
|
+
scanError = 5;
|
|
7847
|
+
}
|
|
7848
|
+
start = pos;
|
|
7849
|
+
continue;
|
|
7850
|
+
}
|
|
7851
|
+
if (ch >= 0 && ch <= 31) {
|
|
7852
|
+
if (isLineBreak(ch)) {
|
|
7853
|
+
result += text.substring(start, pos);
|
|
7854
|
+
scanError = 2;
|
|
7855
|
+
break;
|
|
7856
|
+
} else {
|
|
7857
|
+
scanError = 6;
|
|
7858
|
+
}
|
|
7859
|
+
}
|
|
7860
|
+
pos++;
|
|
7861
|
+
}
|
|
7862
|
+
return result;
|
|
7863
|
+
}
|
|
7864
|
+
function scanNext() {
|
|
7865
|
+
value = "";
|
|
7866
|
+
scanError = 0;
|
|
7867
|
+
tokenOffset = pos;
|
|
7868
|
+
lineStartOffset = lineNumber;
|
|
7869
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
7870
|
+
if (pos >= len) {
|
|
7871
|
+
tokenOffset = len;
|
|
7872
|
+
return token = 17;
|
|
7873
|
+
}
|
|
7874
|
+
let code = text.charCodeAt(pos);
|
|
7875
|
+
if (isWhiteSpace(code)) {
|
|
7876
|
+
do {
|
|
7877
|
+
pos++;
|
|
7878
|
+
value += String.fromCharCode(code);
|
|
7879
|
+
code = text.charCodeAt(pos);
|
|
7880
|
+
} while (isWhiteSpace(code));
|
|
7881
|
+
return token = 15;
|
|
7882
|
+
}
|
|
7883
|
+
if (isLineBreak(code)) {
|
|
7884
|
+
pos++;
|
|
7885
|
+
value += String.fromCharCode(code);
|
|
7886
|
+
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
7887
|
+
pos++;
|
|
7888
|
+
value += "\n";
|
|
7889
|
+
}
|
|
7890
|
+
lineNumber++;
|
|
7891
|
+
tokenLineStartOffset = pos;
|
|
7892
|
+
return token = 14;
|
|
7893
|
+
}
|
|
7894
|
+
switch (code) {
|
|
7895
|
+
// tokens: []{}:,
|
|
7896
|
+
case 123:
|
|
7897
|
+
pos++;
|
|
7898
|
+
return token = 1;
|
|
7899
|
+
case 125:
|
|
7900
|
+
pos++;
|
|
7901
|
+
return token = 2;
|
|
7902
|
+
case 91:
|
|
7903
|
+
pos++;
|
|
7904
|
+
return token = 3;
|
|
7905
|
+
case 93:
|
|
7906
|
+
pos++;
|
|
7907
|
+
return token = 4;
|
|
7908
|
+
case 58:
|
|
7909
|
+
pos++;
|
|
7910
|
+
return token = 6;
|
|
7911
|
+
case 44:
|
|
7912
|
+
pos++;
|
|
7913
|
+
return token = 5;
|
|
7914
|
+
// strings
|
|
7915
|
+
case 34:
|
|
7916
|
+
pos++;
|
|
7917
|
+
value = scanString();
|
|
7918
|
+
return token = 10;
|
|
7919
|
+
// comments
|
|
7920
|
+
case 47:
|
|
7921
|
+
const start = pos - 1;
|
|
7922
|
+
if (text.charCodeAt(pos + 1) === 47) {
|
|
7923
|
+
pos += 2;
|
|
7924
|
+
while (pos < len) {
|
|
7925
|
+
if (isLineBreak(text.charCodeAt(pos))) {
|
|
7926
|
+
break;
|
|
7927
|
+
}
|
|
7928
|
+
pos++;
|
|
7929
|
+
}
|
|
7930
|
+
value = text.substring(start, pos);
|
|
7931
|
+
return token = 12;
|
|
7932
|
+
}
|
|
7933
|
+
if (text.charCodeAt(pos + 1) === 42) {
|
|
7934
|
+
pos += 2;
|
|
7935
|
+
const safeLength = len - 1;
|
|
7936
|
+
let commentClosed = false;
|
|
7937
|
+
while (pos < safeLength) {
|
|
7938
|
+
const ch = text.charCodeAt(pos);
|
|
7939
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
7940
|
+
pos += 2;
|
|
7941
|
+
commentClosed = true;
|
|
7942
|
+
break;
|
|
7943
|
+
}
|
|
7944
|
+
pos++;
|
|
7945
|
+
if (isLineBreak(ch)) {
|
|
7946
|
+
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
7947
|
+
pos++;
|
|
7948
|
+
}
|
|
7949
|
+
lineNumber++;
|
|
7950
|
+
tokenLineStartOffset = pos;
|
|
7951
|
+
}
|
|
7952
|
+
}
|
|
7953
|
+
if (!commentClosed) {
|
|
7954
|
+
pos++;
|
|
7955
|
+
scanError = 1;
|
|
7956
|
+
}
|
|
7957
|
+
value = text.substring(start, pos);
|
|
7958
|
+
return token = 13;
|
|
7959
|
+
}
|
|
7960
|
+
value += String.fromCharCode(code);
|
|
7961
|
+
pos++;
|
|
7962
|
+
return token = 16;
|
|
7963
|
+
// numbers
|
|
7964
|
+
case 45:
|
|
7965
|
+
value += String.fromCharCode(code);
|
|
7966
|
+
pos++;
|
|
7967
|
+
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
7968
|
+
return token = 16;
|
|
7969
|
+
}
|
|
7970
|
+
// found a minus, followed by a number so
|
|
7971
|
+
// we fall through to proceed with scanning
|
|
7972
|
+
// numbers
|
|
7973
|
+
case 48:
|
|
7974
|
+
case 49:
|
|
7975
|
+
case 50:
|
|
7976
|
+
case 51:
|
|
7977
|
+
case 52:
|
|
7978
|
+
case 53:
|
|
7979
|
+
case 54:
|
|
7980
|
+
case 55:
|
|
7981
|
+
case 56:
|
|
7982
|
+
case 57:
|
|
7983
|
+
value += scanNumber();
|
|
7984
|
+
return token = 11;
|
|
7985
|
+
// literals and unknown symbols
|
|
7986
|
+
default:
|
|
7987
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
7988
|
+
pos++;
|
|
7989
|
+
code = text.charCodeAt(pos);
|
|
7990
|
+
}
|
|
7991
|
+
if (tokenOffset !== pos) {
|
|
7992
|
+
value = text.substring(tokenOffset, pos);
|
|
7993
|
+
switch (value) {
|
|
7994
|
+
case "true":
|
|
7995
|
+
return token = 8;
|
|
7996
|
+
case "false":
|
|
7997
|
+
return token = 9;
|
|
7998
|
+
case "null":
|
|
7999
|
+
return token = 7;
|
|
8000
|
+
}
|
|
8001
|
+
return token = 16;
|
|
8002
|
+
}
|
|
8003
|
+
value += String.fromCharCode(code);
|
|
8004
|
+
pos++;
|
|
8005
|
+
return token = 16;
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
function isUnknownContentCharacter(code) {
|
|
8009
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
8010
|
+
return false;
|
|
8011
|
+
}
|
|
8012
|
+
switch (code) {
|
|
8013
|
+
case 125:
|
|
8014
|
+
case 93:
|
|
8015
|
+
case 123:
|
|
8016
|
+
case 91:
|
|
8017
|
+
case 34:
|
|
8018
|
+
case 58:
|
|
8019
|
+
case 44:
|
|
8020
|
+
case 47:
|
|
8021
|
+
return false;
|
|
8022
|
+
}
|
|
8023
|
+
return true;
|
|
8024
|
+
}
|
|
8025
|
+
function scanNextNonTrivia() {
|
|
8026
|
+
let result;
|
|
8027
|
+
do {
|
|
8028
|
+
result = scanNext();
|
|
8029
|
+
} while (result >= 12 && result <= 15);
|
|
8030
|
+
return result;
|
|
8031
|
+
}
|
|
8032
|
+
return {
|
|
8033
|
+
setPosition,
|
|
8034
|
+
getPosition: () => pos,
|
|
8035
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
8036
|
+
getToken: () => token,
|
|
8037
|
+
getTokenValue: () => value,
|
|
8038
|
+
getTokenOffset: () => tokenOffset,
|
|
8039
|
+
getTokenLength: () => pos - tokenOffset,
|
|
8040
|
+
getTokenStartLine: () => lineStartOffset,
|
|
8041
|
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
8042
|
+
getTokenError: () => scanError
|
|
8043
|
+
};
|
|
8044
|
+
}
|
|
8045
|
+
function isWhiteSpace(ch) {
|
|
8046
|
+
return ch === 32 || ch === 9;
|
|
8047
|
+
}
|
|
8048
|
+
function isLineBreak(ch) {
|
|
8049
|
+
return ch === 10 || ch === 13;
|
|
8050
|
+
}
|
|
8051
|
+
function isDigit(ch) {
|
|
8052
|
+
return ch >= 48 && ch <= 57;
|
|
8053
|
+
}
|
|
8054
|
+
var CharacterCodes;
|
|
8055
|
+
var init_scanner = __esm({
|
|
8056
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js"() {
|
|
8057
|
+
"use strict";
|
|
8058
|
+
(function(CharacterCodes2) {
|
|
8059
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
8060
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
8061
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
8062
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
8063
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
8064
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
8065
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
8066
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
8067
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
8068
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
8069
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
8070
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
8071
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
8072
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
8073
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
8074
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
8075
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
8076
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
8077
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
8078
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
8079
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
8080
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
8081
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
8082
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
8083
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
8084
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
8085
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
8086
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
8087
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
8088
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
8089
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
8090
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
8091
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
8092
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
8093
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
8094
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
8095
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
8096
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
8097
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
8098
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
8099
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
8100
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
8101
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
8102
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
8103
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
8104
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
8105
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
8106
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
8107
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
8108
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
8109
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
8110
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
8111
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
8112
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
8113
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
8114
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
8115
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
8116
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
8117
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
8118
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
8119
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
8120
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
8121
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
8122
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
8123
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
8124
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
8125
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
8126
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
8127
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
8128
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
8129
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
8130
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
8131
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
8132
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
8133
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
8134
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
8135
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
8136
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
8137
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
8138
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
8139
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
8140
|
+
}
|
|
8141
|
+
});
|
|
8142
|
+
|
|
8143
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
8144
|
+
var cachedSpaces, maxCachedValues, cachedBreakLinesWithSpaces, supportedEols;
|
|
8145
|
+
var init_string_intern = __esm({
|
|
8146
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js"() {
|
|
8147
|
+
cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
8148
|
+
return " ".repeat(index);
|
|
8149
|
+
});
|
|
8150
|
+
maxCachedValues = 200;
|
|
8151
|
+
cachedBreakLinesWithSpaces = {
|
|
8152
|
+
" ": {
|
|
8153
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8154
|
+
return "\n" + " ".repeat(index);
|
|
8155
|
+
}),
|
|
8156
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8157
|
+
return "\r" + " ".repeat(index);
|
|
8158
|
+
}),
|
|
8159
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8160
|
+
return "\r\n" + " ".repeat(index);
|
|
8161
|
+
})
|
|
8162
|
+
},
|
|
8163
|
+
" ": {
|
|
8164
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8165
|
+
return "\n" + " ".repeat(index);
|
|
8166
|
+
}),
|
|
8167
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8168
|
+
return "\r" + " ".repeat(index);
|
|
8169
|
+
}),
|
|
8170
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8171
|
+
return "\r\n" + " ".repeat(index);
|
|
8172
|
+
})
|
|
8173
|
+
}
|
|
8174
|
+
};
|
|
8175
|
+
supportedEols = ["\n", "\r", "\r\n"];
|
|
8176
|
+
}
|
|
8177
|
+
});
|
|
8178
|
+
|
|
8179
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
|
|
8180
|
+
function format(documentText, range, options) {
|
|
8181
|
+
let initialIndentLevel;
|
|
8182
|
+
let formatText;
|
|
8183
|
+
let formatTextStart;
|
|
8184
|
+
let rangeStart;
|
|
8185
|
+
let rangeEnd;
|
|
8186
|
+
if (range) {
|
|
8187
|
+
rangeStart = range.offset;
|
|
8188
|
+
rangeEnd = rangeStart + range.length;
|
|
8189
|
+
formatTextStart = rangeStart;
|
|
8190
|
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
8191
|
+
formatTextStart--;
|
|
8192
|
+
}
|
|
8193
|
+
let endOffset = rangeEnd;
|
|
8194
|
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
8195
|
+
endOffset++;
|
|
8196
|
+
}
|
|
8197
|
+
formatText = documentText.substring(formatTextStart, endOffset);
|
|
8198
|
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
8199
|
+
} else {
|
|
8200
|
+
formatText = documentText;
|
|
8201
|
+
initialIndentLevel = 0;
|
|
8202
|
+
formatTextStart = 0;
|
|
8203
|
+
rangeStart = 0;
|
|
8204
|
+
rangeEnd = documentText.length;
|
|
8205
|
+
}
|
|
8206
|
+
const eol = getEOL(options, documentText);
|
|
8207
|
+
const eolFastPathSupported = supportedEols.includes(eol);
|
|
8208
|
+
let numberLineBreaks = 0;
|
|
8209
|
+
let indentLevel = 0;
|
|
8210
|
+
let indentValue;
|
|
8211
|
+
if (options.insertSpaces) {
|
|
8212
|
+
indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
|
|
8213
|
+
} else {
|
|
8214
|
+
indentValue = " ";
|
|
8215
|
+
}
|
|
8216
|
+
const indentType = indentValue === " " ? " " : " ";
|
|
8217
|
+
let scanner = createScanner(formatText, false);
|
|
8218
|
+
let hasError = false;
|
|
8219
|
+
function newLinesAndIndent() {
|
|
8220
|
+
if (numberLineBreaks > 1) {
|
|
8221
|
+
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
8222
|
+
}
|
|
8223
|
+
const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
|
|
8224
|
+
if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
|
|
8225
|
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
8226
|
+
}
|
|
8227
|
+
if (amountOfSpaces <= 0) {
|
|
8228
|
+
return eol;
|
|
8229
|
+
}
|
|
8230
|
+
return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
|
|
8231
|
+
}
|
|
8232
|
+
function scanNext() {
|
|
8233
|
+
let token = scanner.scan();
|
|
8234
|
+
numberLineBreaks = 0;
|
|
8235
|
+
while (token === 15 || token === 14) {
|
|
8236
|
+
if (token === 14 && options.keepLines) {
|
|
8237
|
+
numberLineBreaks += 1;
|
|
8238
|
+
} else if (token === 14) {
|
|
8239
|
+
numberLineBreaks = 1;
|
|
8240
|
+
}
|
|
8241
|
+
token = scanner.scan();
|
|
8242
|
+
}
|
|
8243
|
+
hasError = token === 16 || scanner.getTokenError() !== 0;
|
|
8244
|
+
return token;
|
|
8245
|
+
}
|
|
8246
|
+
const editOperations = [];
|
|
8247
|
+
function addEdit(text, startOffset, endOffset) {
|
|
8248
|
+
if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text) {
|
|
8249
|
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
|
8250
|
+
}
|
|
8251
|
+
}
|
|
8252
|
+
let firstToken = scanNext();
|
|
8253
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
8254
|
+
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
|
8255
|
+
}
|
|
8256
|
+
if (firstToken !== 17) {
|
|
8257
|
+
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
8258
|
+
let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
|
|
8259
|
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
8260
|
+
}
|
|
8261
|
+
while (firstToken !== 17) {
|
|
8262
|
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
8263
|
+
let secondToken = scanNext();
|
|
8264
|
+
let replaceContent = "";
|
|
8265
|
+
let needsLineBreak = false;
|
|
8266
|
+
while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
|
|
8267
|
+
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
8268
|
+
addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
|
|
8269
|
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
8270
|
+
needsLineBreak = secondToken === 12;
|
|
8271
|
+
replaceContent = needsLineBreak ? newLinesAndIndent() : "";
|
|
8272
|
+
secondToken = scanNext();
|
|
8273
|
+
}
|
|
8274
|
+
if (secondToken === 2) {
|
|
8275
|
+
if (firstToken !== 1) {
|
|
8276
|
+
indentLevel--;
|
|
8277
|
+
}
|
|
8278
|
+
;
|
|
8279
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
|
|
8280
|
+
replaceContent = newLinesAndIndent();
|
|
8281
|
+
} else if (options.keepLines) {
|
|
8282
|
+
replaceContent = cachedSpaces[1];
|
|
8283
|
+
}
|
|
8284
|
+
} else if (secondToken === 4) {
|
|
8285
|
+
if (firstToken !== 3) {
|
|
8286
|
+
indentLevel--;
|
|
8287
|
+
}
|
|
8288
|
+
;
|
|
8289
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
|
|
8290
|
+
replaceContent = newLinesAndIndent();
|
|
8291
|
+
} else if (options.keepLines) {
|
|
8292
|
+
replaceContent = cachedSpaces[1];
|
|
8293
|
+
}
|
|
8294
|
+
} else {
|
|
8295
|
+
switch (firstToken) {
|
|
8296
|
+
case 3:
|
|
8297
|
+
case 1:
|
|
8298
|
+
indentLevel++;
|
|
8299
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
8300
|
+
replaceContent = newLinesAndIndent();
|
|
8301
|
+
} else {
|
|
8302
|
+
replaceContent = cachedSpaces[1];
|
|
8303
|
+
}
|
|
8304
|
+
break;
|
|
8305
|
+
case 5:
|
|
8306
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
8307
|
+
replaceContent = newLinesAndIndent();
|
|
8308
|
+
} else {
|
|
8309
|
+
replaceContent = cachedSpaces[1];
|
|
8310
|
+
}
|
|
8311
|
+
break;
|
|
8312
|
+
case 12:
|
|
8313
|
+
replaceContent = newLinesAndIndent();
|
|
8314
|
+
break;
|
|
8315
|
+
case 13:
|
|
8316
|
+
if (numberLineBreaks > 0) {
|
|
8317
|
+
replaceContent = newLinesAndIndent();
|
|
8318
|
+
} else if (!needsLineBreak) {
|
|
8319
|
+
replaceContent = cachedSpaces[1];
|
|
8320
|
+
}
|
|
8321
|
+
break;
|
|
8322
|
+
case 6:
|
|
8323
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
8324
|
+
replaceContent = newLinesAndIndent();
|
|
8325
|
+
} else if (!needsLineBreak) {
|
|
8326
|
+
replaceContent = cachedSpaces[1];
|
|
8327
|
+
}
|
|
8328
|
+
break;
|
|
8329
|
+
case 10:
|
|
8330
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
8331
|
+
replaceContent = newLinesAndIndent();
|
|
8332
|
+
} else if (secondToken === 6 && !needsLineBreak) {
|
|
8333
|
+
replaceContent = "";
|
|
8334
|
+
}
|
|
8335
|
+
break;
|
|
8336
|
+
case 7:
|
|
8337
|
+
case 8:
|
|
8338
|
+
case 9:
|
|
8339
|
+
case 11:
|
|
8340
|
+
case 2:
|
|
8341
|
+
case 4:
|
|
8342
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
8343
|
+
replaceContent = newLinesAndIndent();
|
|
8344
|
+
} else {
|
|
8345
|
+
if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
|
|
8346
|
+
replaceContent = cachedSpaces[1];
|
|
8347
|
+
} else if (secondToken !== 5 && secondToken !== 17) {
|
|
8348
|
+
hasError = true;
|
|
8349
|
+
}
|
|
8350
|
+
}
|
|
8351
|
+
break;
|
|
8352
|
+
case 16:
|
|
8353
|
+
hasError = true;
|
|
8354
|
+
break;
|
|
8355
|
+
}
|
|
8356
|
+
if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
|
|
8357
|
+
replaceContent = newLinesAndIndent();
|
|
8358
|
+
}
|
|
8359
|
+
}
|
|
8360
|
+
if (secondToken === 17) {
|
|
8361
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
8362
|
+
replaceContent = newLinesAndIndent();
|
|
8363
|
+
} else {
|
|
8364
|
+
replaceContent = options.insertFinalNewline ? eol : "";
|
|
8365
|
+
}
|
|
8366
|
+
}
|
|
8367
|
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
8368
|
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
8369
|
+
firstToken = secondToken;
|
|
8370
|
+
}
|
|
8371
|
+
return editOperations;
|
|
8372
|
+
}
|
|
8373
|
+
function repeat(s, count) {
|
|
8374
|
+
let result = "";
|
|
8375
|
+
for (let i = 0; i < count; i++) {
|
|
8376
|
+
result += s;
|
|
8377
|
+
}
|
|
8378
|
+
return result;
|
|
8379
|
+
}
|
|
8380
|
+
function computeIndentLevel(content, options) {
|
|
8381
|
+
let i = 0;
|
|
8382
|
+
let nChars = 0;
|
|
8383
|
+
const tabSize = options.tabSize || 4;
|
|
8384
|
+
while (i < content.length) {
|
|
8385
|
+
let ch = content.charAt(i);
|
|
8386
|
+
if (ch === cachedSpaces[1]) {
|
|
8387
|
+
nChars++;
|
|
8388
|
+
} else if (ch === " ") {
|
|
8389
|
+
nChars += tabSize;
|
|
8390
|
+
} else {
|
|
8391
|
+
break;
|
|
8392
|
+
}
|
|
8393
|
+
i++;
|
|
8394
|
+
}
|
|
8395
|
+
return Math.floor(nChars / tabSize);
|
|
8396
|
+
}
|
|
8397
|
+
function getEOL(options, text) {
|
|
8398
|
+
for (let i = 0; i < text.length; i++) {
|
|
8399
|
+
const ch = text.charAt(i);
|
|
8400
|
+
if (ch === "\r") {
|
|
8401
|
+
if (i + 1 < text.length && text.charAt(i + 1) === "\n") {
|
|
8402
|
+
return "\r\n";
|
|
8403
|
+
}
|
|
8404
|
+
return "\r";
|
|
8405
|
+
} else if (ch === "\n") {
|
|
8406
|
+
return "\n";
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
return options && options.eol || "\n";
|
|
8410
|
+
}
|
|
8411
|
+
function isEOL(text, offset) {
|
|
8412
|
+
return "\r\n".indexOf(text.charAt(offset)) !== -1;
|
|
8413
|
+
}
|
|
8414
|
+
var init_format = __esm({
|
|
8415
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js"() {
|
|
8416
|
+
"use strict";
|
|
8417
|
+
init_scanner();
|
|
8418
|
+
init_string_intern();
|
|
8419
|
+
}
|
|
8420
|
+
});
|
|
8421
|
+
|
|
8422
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
8423
|
+
function getLocation(text, position) {
|
|
8424
|
+
const segments = [];
|
|
8425
|
+
const earlyReturnException = new Object();
|
|
8426
|
+
let previousNode = void 0;
|
|
8427
|
+
const previousNodeInst = {
|
|
8428
|
+
value: {},
|
|
8429
|
+
offset: 0,
|
|
8430
|
+
length: 0,
|
|
8431
|
+
type: "object",
|
|
8432
|
+
parent: void 0
|
|
8433
|
+
};
|
|
8434
|
+
let isAtPropertyKey = false;
|
|
8435
|
+
function setPreviousNode(value, offset, length, type) {
|
|
8436
|
+
previousNodeInst.value = value;
|
|
8437
|
+
previousNodeInst.offset = offset;
|
|
8438
|
+
previousNodeInst.length = length;
|
|
8439
|
+
previousNodeInst.type = type;
|
|
8440
|
+
previousNodeInst.colonOffset = void 0;
|
|
8441
|
+
previousNode = previousNodeInst;
|
|
8442
|
+
}
|
|
8443
|
+
try {
|
|
8444
|
+
visit(text, {
|
|
8445
|
+
onObjectBegin: (offset, length) => {
|
|
8446
|
+
if (position <= offset) {
|
|
8447
|
+
throw earlyReturnException;
|
|
8448
|
+
}
|
|
8449
|
+
previousNode = void 0;
|
|
8450
|
+
isAtPropertyKey = position > offset;
|
|
8451
|
+
segments.push("");
|
|
8452
|
+
},
|
|
8453
|
+
onObjectProperty: (name, offset, length) => {
|
|
8454
|
+
if (position < offset) {
|
|
8455
|
+
throw earlyReturnException;
|
|
8456
|
+
}
|
|
8457
|
+
setPreviousNode(name, offset, length, "property");
|
|
8458
|
+
segments[segments.length - 1] = name;
|
|
8459
|
+
if (position <= offset + length) {
|
|
8460
|
+
throw earlyReturnException;
|
|
8461
|
+
}
|
|
8462
|
+
},
|
|
8463
|
+
onObjectEnd: (offset, length) => {
|
|
8464
|
+
if (position <= offset) {
|
|
8465
|
+
throw earlyReturnException;
|
|
8466
|
+
}
|
|
8467
|
+
previousNode = void 0;
|
|
8468
|
+
segments.pop();
|
|
8469
|
+
},
|
|
8470
|
+
onArrayBegin: (offset, length) => {
|
|
8471
|
+
if (position <= offset) {
|
|
8472
|
+
throw earlyReturnException;
|
|
8473
|
+
}
|
|
8474
|
+
previousNode = void 0;
|
|
8475
|
+
segments.push(0);
|
|
8476
|
+
},
|
|
8477
|
+
onArrayEnd: (offset, length) => {
|
|
8478
|
+
if (position <= offset) {
|
|
8479
|
+
throw earlyReturnException;
|
|
8480
|
+
}
|
|
8481
|
+
previousNode = void 0;
|
|
8482
|
+
segments.pop();
|
|
8483
|
+
},
|
|
8484
|
+
onLiteralValue: (value, offset, length) => {
|
|
8485
|
+
if (position < offset) {
|
|
8486
|
+
throw earlyReturnException;
|
|
8487
|
+
}
|
|
8488
|
+
setPreviousNode(value, offset, length, getNodeType(value));
|
|
8489
|
+
if (position <= offset + length) {
|
|
8490
|
+
throw earlyReturnException;
|
|
8491
|
+
}
|
|
8492
|
+
},
|
|
8493
|
+
onSeparator: (sep, offset, length) => {
|
|
8494
|
+
if (position <= offset) {
|
|
8495
|
+
throw earlyReturnException;
|
|
8496
|
+
}
|
|
8497
|
+
if (sep === ":" && previousNode && previousNode.type === "property") {
|
|
8498
|
+
previousNode.colonOffset = offset;
|
|
8499
|
+
isAtPropertyKey = false;
|
|
8500
|
+
previousNode = void 0;
|
|
8501
|
+
} else if (sep === ",") {
|
|
8502
|
+
const last = segments[segments.length - 1];
|
|
8503
|
+
if (typeof last === "number") {
|
|
8504
|
+
segments[segments.length - 1] = last + 1;
|
|
8505
|
+
} else {
|
|
8506
|
+
isAtPropertyKey = true;
|
|
8507
|
+
segments[segments.length - 1] = "";
|
|
8508
|
+
}
|
|
8509
|
+
previousNode = void 0;
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
});
|
|
8513
|
+
} catch (e) {
|
|
8514
|
+
if (e !== earlyReturnException) {
|
|
8515
|
+
throw e;
|
|
8516
|
+
}
|
|
8517
|
+
}
|
|
8518
|
+
return {
|
|
8519
|
+
path: segments,
|
|
8520
|
+
previousNode,
|
|
8521
|
+
isAtPropertyKey,
|
|
8522
|
+
matches: (pattern) => {
|
|
8523
|
+
let k = 0;
|
|
8524
|
+
for (let i = 0; k < pattern.length && i < segments.length; i++) {
|
|
8525
|
+
if (pattern[k] === segments[i] || pattern[k] === "*") {
|
|
8526
|
+
k++;
|
|
8527
|
+
} else if (pattern[k] !== "**") {
|
|
8528
|
+
return false;
|
|
8529
|
+
}
|
|
8530
|
+
}
|
|
8531
|
+
return k === pattern.length;
|
|
8532
|
+
}
|
|
8533
|
+
};
|
|
8534
|
+
}
|
|
8535
|
+
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
8536
|
+
let currentProperty = null;
|
|
8537
|
+
let currentParent = [];
|
|
8538
|
+
const previousParents = [];
|
|
8539
|
+
function onValue(value) {
|
|
8540
|
+
if (Array.isArray(currentParent)) {
|
|
8541
|
+
currentParent.push(value);
|
|
8542
|
+
} else if (currentProperty !== null) {
|
|
8543
|
+
currentParent[currentProperty] = value;
|
|
8544
|
+
}
|
|
8545
|
+
}
|
|
8546
|
+
const visitor = {
|
|
8547
|
+
onObjectBegin: () => {
|
|
8548
|
+
const object = {};
|
|
8549
|
+
onValue(object);
|
|
8550
|
+
previousParents.push(currentParent);
|
|
8551
|
+
currentParent = object;
|
|
8552
|
+
currentProperty = null;
|
|
8553
|
+
},
|
|
8554
|
+
onObjectProperty: (name) => {
|
|
8555
|
+
currentProperty = name;
|
|
8556
|
+
},
|
|
8557
|
+
onObjectEnd: () => {
|
|
8558
|
+
currentParent = previousParents.pop();
|
|
8559
|
+
},
|
|
8560
|
+
onArrayBegin: () => {
|
|
8561
|
+
const array = [];
|
|
8562
|
+
onValue(array);
|
|
8563
|
+
previousParents.push(currentParent);
|
|
8564
|
+
currentParent = array;
|
|
8565
|
+
currentProperty = null;
|
|
8566
|
+
},
|
|
8567
|
+
onArrayEnd: () => {
|
|
8568
|
+
currentParent = previousParents.pop();
|
|
8569
|
+
},
|
|
8570
|
+
onLiteralValue: onValue,
|
|
8571
|
+
onError: (error, offset, length) => {
|
|
8572
|
+
errors.push({ error, offset, length });
|
|
8573
|
+
}
|
|
8574
|
+
};
|
|
8575
|
+
visit(text, visitor, options);
|
|
8576
|
+
return currentParent[0];
|
|
8577
|
+
}
|
|
8578
|
+
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
8579
|
+
let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
|
|
8580
|
+
function ensurePropertyComplete(endOffset) {
|
|
8581
|
+
if (currentParent.type === "property") {
|
|
8582
|
+
currentParent.length = endOffset - currentParent.offset;
|
|
8583
|
+
currentParent = currentParent.parent;
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
function onValue(valueNode) {
|
|
8587
|
+
currentParent.children.push(valueNode);
|
|
8588
|
+
return valueNode;
|
|
8589
|
+
}
|
|
8590
|
+
const visitor = {
|
|
8591
|
+
onObjectBegin: (offset) => {
|
|
8592
|
+
currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
|
|
8593
|
+
},
|
|
8594
|
+
onObjectProperty: (name, offset, length) => {
|
|
8595
|
+
currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
|
|
8596
|
+
currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
|
|
8597
|
+
},
|
|
8598
|
+
onObjectEnd: (offset, length) => {
|
|
8599
|
+
ensurePropertyComplete(offset + length);
|
|
8600
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
8601
|
+
currentParent = currentParent.parent;
|
|
8602
|
+
ensurePropertyComplete(offset + length);
|
|
8603
|
+
},
|
|
8604
|
+
onArrayBegin: (offset, length) => {
|
|
8605
|
+
currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
|
|
8606
|
+
},
|
|
8607
|
+
onArrayEnd: (offset, length) => {
|
|
8608
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
8609
|
+
currentParent = currentParent.parent;
|
|
8610
|
+
ensurePropertyComplete(offset + length);
|
|
8611
|
+
},
|
|
8612
|
+
onLiteralValue: (value, offset, length) => {
|
|
8613
|
+
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
8614
|
+
ensurePropertyComplete(offset + length);
|
|
8615
|
+
},
|
|
8616
|
+
onSeparator: (sep, offset, length) => {
|
|
8617
|
+
if (currentParent.type === "property") {
|
|
8618
|
+
if (sep === ":") {
|
|
8619
|
+
currentParent.colonOffset = offset;
|
|
8620
|
+
} else if (sep === ",") {
|
|
8621
|
+
ensurePropertyComplete(offset);
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
},
|
|
8625
|
+
onError: (error, offset, length) => {
|
|
8626
|
+
errors.push({ error, offset, length });
|
|
8627
|
+
}
|
|
8628
|
+
};
|
|
8629
|
+
visit(text, visitor, options);
|
|
8630
|
+
const result = currentParent.children[0];
|
|
8631
|
+
if (result) {
|
|
8632
|
+
delete result.parent;
|
|
8633
|
+
}
|
|
8634
|
+
return result;
|
|
8635
|
+
}
|
|
8636
|
+
function findNodeAtLocation(root, path) {
|
|
8637
|
+
if (!root) {
|
|
8638
|
+
return void 0;
|
|
8639
|
+
}
|
|
8640
|
+
let node = root;
|
|
8641
|
+
for (let segment of path) {
|
|
8642
|
+
if (typeof segment === "string") {
|
|
8643
|
+
if (node.type !== "object" || !Array.isArray(node.children)) {
|
|
8644
|
+
return void 0;
|
|
8645
|
+
}
|
|
8646
|
+
let found = false;
|
|
8647
|
+
for (const propertyNode of node.children) {
|
|
8648
|
+
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
8649
|
+
node = propertyNode.children[1];
|
|
8650
|
+
found = true;
|
|
8651
|
+
break;
|
|
8652
|
+
}
|
|
8653
|
+
}
|
|
8654
|
+
if (!found) {
|
|
8655
|
+
return void 0;
|
|
8656
|
+
}
|
|
8657
|
+
} else {
|
|
8658
|
+
const index = segment;
|
|
8659
|
+
if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
|
8660
|
+
return void 0;
|
|
8661
|
+
}
|
|
8662
|
+
node = node.children[index];
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
return node;
|
|
8666
|
+
}
|
|
8667
|
+
function getNodePath(node) {
|
|
8668
|
+
if (!node.parent || !node.parent.children) {
|
|
8669
|
+
return [];
|
|
8670
|
+
}
|
|
8671
|
+
const path = getNodePath(node.parent);
|
|
8672
|
+
if (node.parent.type === "property") {
|
|
8673
|
+
const key = node.parent.children[0].value;
|
|
8674
|
+
path.push(key);
|
|
8675
|
+
} else if (node.parent.type === "array") {
|
|
8676
|
+
const index = node.parent.children.indexOf(node);
|
|
8677
|
+
if (index !== -1) {
|
|
8678
|
+
path.push(index);
|
|
8679
|
+
}
|
|
8680
|
+
}
|
|
8681
|
+
return path;
|
|
8682
|
+
}
|
|
8683
|
+
function getNodeValue(node) {
|
|
8684
|
+
switch (node.type) {
|
|
8685
|
+
case "array":
|
|
8686
|
+
return node.children.map(getNodeValue);
|
|
8687
|
+
case "object":
|
|
8688
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
8689
|
+
for (let prop of node.children) {
|
|
8690
|
+
const valueNode = prop.children[1];
|
|
8691
|
+
if (valueNode) {
|
|
8692
|
+
obj[prop.children[0].value] = getNodeValue(valueNode);
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8695
|
+
return obj;
|
|
8696
|
+
case "null":
|
|
8697
|
+
case "string":
|
|
8698
|
+
case "number":
|
|
8699
|
+
case "boolean":
|
|
8700
|
+
return node.value;
|
|
8701
|
+
default:
|
|
8702
|
+
return void 0;
|
|
8703
|
+
}
|
|
8704
|
+
}
|
|
8705
|
+
function contains(node, offset, includeRightBound = false) {
|
|
8706
|
+
return offset >= node.offset && offset < node.offset + node.length || includeRightBound && offset === node.offset + node.length;
|
|
8707
|
+
}
|
|
8708
|
+
function findNodeAtOffset(node, offset, includeRightBound = false) {
|
|
8709
|
+
if (contains(node, offset, includeRightBound)) {
|
|
8710
|
+
const children = node.children;
|
|
8711
|
+
if (Array.isArray(children)) {
|
|
8712
|
+
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
|
8713
|
+
const item = findNodeAtOffset(children[i], offset, includeRightBound);
|
|
8714
|
+
if (item) {
|
|
8715
|
+
return item;
|
|
8716
|
+
}
|
|
8717
|
+
}
|
|
8718
|
+
}
|
|
8719
|
+
return node;
|
|
8720
|
+
}
|
|
8721
|
+
return void 0;
|
|
8722
|
+
}
|
|
8723
|
+
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
8724
|
+
const _scanner = createScanner(text, false);
|
|
8725
|
+
const _jsonPath = [];
|
|
8726
|
+
let suppressedCallbacks = 0;
|
|
8727
|
+
function toNoArgVisit(visitFunction) {
|
|
8728
|
+
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
8729
|
+
}
|
|
8730
|
+
function toOneArgVisit(visitFunction) {
|
|
8731
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
8732
|
+
}
|
|
8733
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
8734
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
8735
|
+
}
|
|
8736
|
+
function toBeginVisit(visitFunction) {
|
|
8737
|
+
return visitFunction ? () => {
|
|
8738
|
+
if (suppressedCallbacks > 0) {
|
|
8739
|
+
suppressedCallbacks++;
|
|
8740
|
+
} else {
|
|
8741
|
+
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
8742
|
+
if (cbReturn === false) {
|
|
8743
|
+
suppressedCallbacks = 1;
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
} : () => true;
|
|
8747
|
+
}
|
|
8748
|
+
function toEndVisit(visitFunction) {
|
|
8749
|
+
return visitFunction ? () => {
|
|
8750
|
+
if (suppressedCallbacks > 0) {
|
|
8751
|
+
suppressedCallbacks--;
|
|
8752
|
+
}
|
|
8753
|
+
if (suppressedCallbacks === 0) {
|
|
8754
|
+
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
8755
|
+
}
|
|
8756
|
+
} : () => true;
|
|
8757
|
+
}
|
|
8758
|
+
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);
|
|
8759
|
+
const disallowComments = options && options.disallowComments;
|
|
8760
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
8761
|
+
function scanNext() {
|
|
8762
|
+
while (true) {
|
|
8763
|
+
const token = _scanner.scan();
|
|
8764
|
+
switch (_scanner.getTokenError()) {
|
|
8765
|
+
case 4:
|
|
8766
|
+
handleError(
|
|
8767
|
+
14
|
|
8768
|
+
/* ParseErrorCode.InvalidUnicode */
|
|
8769
|
+
);
|
|
8770
|
+
break;
|
|
8771
|
+
case 5:
|
|
8772
|
+
handleError(
|
|
8773
|
+
15
|
|
8774
|
+
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
8775
|
+
);
|
|
8776
|
+
break;
|
|
8777
|
+
case 3:
|
|
8778
|
+
handleError(
|
|
8779
|
+
13
|
|
8780
|
+
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
8781
|
+
);
|
|
8782
|
+
break;
|
|
8783
|
+
case 1:
|
|
8784
|
+
if (!disallowComments) {
|
|
8785
|
+
handleError(
|
|
8786
|
+
11
|
|
8787
|
+
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
8788
|
+
);
|
|
8789
|
+
}
|
|
8790
|
+
break;
|
|
8791
|
+
case 2:
|
|
8792
|
+
handleError(
|
|
8793
|
+
12
|
|
8794
|
+
/* ParseErrorCode.UnexpectedEndOfString */
|
|
8795
|
+
);
|
|
8796
|
+
break;
|
|
8797
|
+
case 6:
|
|
8798
|
+
handleError(
|
|
8799
|
+
16
|
|
8800
|
+
/* ParseErrorCode.InvalidCharacter */
|
|
8801
|
+
);
|
|
8802
|
+
break;
|
|
8803
|
+
}
|
|
8804
|
+
switch (token) {
|
|
8805
|
+
case 12:
|
|
8806
|
+
case 13:
|
|
8807
|
+
if (disallowComments) {
|
|
8808
|
+
handleError(
|
|
8809
|
+
10
|
|
8810
|
+
/* ParseErrorCode.InvalidCommentToken */
|
|
8811
|
+
);
|
|
8812
|
+
} else {
|
|
8813
|
+
onComment();
|
|
8814
|
+
}
|
|
8815
|
+
break;
|
|
8816
|
+
case 16:
|
|
8817
|
+
handleError(
|
|
8818
|
+
1
|
|
8819
|
+
/* ParseErrorCode.InvalidSymbol */
|
|
8820
|
+
);
|
|
8821
|
+
break;
|
|
8822
|
+
case 15:
|
|
8823
|
+
case 14:
|
|
8824
|
+
break;
|
|
8825
|
+
default:
|
|
8826
|
+
return token;
|
|
8827
|
+
}
|
|
8828
|
+
}
|
|
8829
|
+
}
|
|
8830
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
8831
|
+
onError(error);
|
|
8832
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
8833
|
+
let token = _scanner.getToken();
|
|
8834
|
+
while (token !== 17) {
|
|
8835
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
8836
|
+
scanNext();
|
|
8837
|
+
break;
|
|
8838
|
+
} else if (skipUntil.indexOf(token) !== -1) {
|
|
8839
|
+
break;
|
|
8840
|
+
}
|
|
8841
|
+
token = scanNext();
|
|
8842
|
+
}
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
function parseString(isValue) {
|
|
8846
|
+
const value = _scanner.getTokenValue();
|
|
8847
|
+
if (isValue) {
|
|
8848
|
+
onLiteralValue(value);
|
|
8849
|
+
} else {
|
|
8850
|
+
onObjectProperty(value);
|
|
8851
|
+
_jsonPath.push(value);
|
|
8852
|
+
}
|
|
8853
|
+
scanNext();
|
|
8854
|
+
return true;
|
|
8855
|
+
}
|
|
8856
|
+
function parseLiteral() {
|
|
8857
|
+
switch (_scanner.getToken()) {
|
|
8858
|
+
case 11:
|
|
8859
|
+
const tokenValue = _scanner.getTokenValue();
|
|
8860
|
+
let value = Number(tokenValue);
|
|
8861
|
+
if (isNaN(value)) {
|
|
8862
|
+
handleError(
|
|
8863
|
+
2
|
|
8864
|
+
/* ParseErrorCode.InvalidNumberFormat */
|
|
8865
|
+
);
|
|
8866
|
+
value = 0;
|
|
8867
|
+
}
|
|
8868
|
+
onLiteralValue(value);
|
|
8869
|
+
break;
|
|
8870
|
+
case 7:
|
|
8871
|
+
onLiteralValue(null);
|
|
8872
|
+
break;
|
|
8873
|
+
case 8:
|
|
8874
|
+
onLiteralValue(true);
|
|
8875
|
+
break;
|
|
8876
|
+
case 9:
|
|
8877
|
+
onLiteralValue(false);
|
|
8878
|
+
break;
|
|
8879
|
+
default:
|
|
8880
|
+
return false;
|
|
8881
|
+
}
|
|
8882
|
+
scanNext();
|
|
8883
|
+
return true;
|
|
8884
|
+
}
|
|
8885
|
+
function parseProperty() {
|
|
8886
|
+
if (_scanner.getToken() !== 10) {
|
|
8887
|
+
handleError(3, [], [
|
|
8888
|
+
2,
|
|
8889
|
+
5
|
|
8890
|
+
/* SyntaxKind.CommaToken */
|
|
8891
|
+
]);
|
|
8892
|
+
return false;
|
|
8893
|
+
}
|
|
8894
|
+
parseString(false);
|
|
8895
|
+
if (_scanner.getToken() === 6) {
|
|
8896
|
+
onSeparator(":");
|
|
8897
|
+
scanNext();
|
|
8898
|
+
if (!parseValue()) {
|
|
8899
|
+
handleError(4, [], [
|
|
8900
|
+
2,
|
|
8901
|
+
5
|
|
8902
|
+
/* SyntaxKind.CommaToken */
|
|
8903
|
+
]);
|
|
8904
|
+
}
|
|
8905
|
+
} else {
|
|
8906
|
+
handleError(5, [], [
|
|
8907
|
+
2,
|
|
8908
|
+
5
|
|
8909
|
+
/* SyntaxKind.CommaToken */
|
|
8910
|
+
]);
|
|
8911
|
+
}
|
|
8912
|
+
_jsonPath.pop();
|
|
8913
|
+
return true;
|
|
8914
|
+
}
|
|
8915
|
+
function parseObject() {
|
|
8916
|
+
onObjectBegin();
|
|
8917
|
+
scanNext();
|
|
8918
|
+
let needsComma = false;
|
|
8919
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
8920
|
+
if (_scanner.getToken() === 5) {
|
|
8921
|
+
if (!needsComma) {
|
|
8922
|
+
handleError(4, [], []);
|
|
8923
|
+
}
|
|
8924
|
+
onSeparator(",");
|
|
8925
|
+
scanNext();
|
|
8926
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
8927
|
+
break;
|
|
8928
|
+
}
|
|
8929
|
+
} else if (needsComma) {
|
|
8930
|
+
handleError(6, [], []);
|
|
8931
|
+
}
|
|
8932
|
+
if (!parseProperty()) {
|
|
8933
|
+
handleError(4, [], [
|
|
8934
|
+
2,
|
|
8935
|
+
5
|
|
8936
|
+
/* SyntaxKind.CommaToken */
|
|
8937
|
+
]);
|
|
8938
|
+
}
|
|
8939
|
+
needsComma = true;
|
|
8940
|
+
}
|
|
8941
|
+
onObjectEnd();
|
|
8942
|
+
if (_scanner.getToken() !== 2) {
|
|
8943
|
+
handleError(7, [
|
|
8944
|
+
2
|
|
8945
|
+
/* SyntaxKind.CloseBraceToken */
|
|
8946
|
+
], []);
|
|
8947
|
+
} else {
|
|
8948
|
+
scanNext();
|
|
8949
|
+
}
|
|
8950
|
+
return true;
|
|
8951
|
+
}
|
|
8952
|
+
function parseArray() {
|
|
8953
|
+
onArrayBegin();
|
|
8954
|
+
scanNext();
|
|
8955
|
+
let isFirstElement = true;
|
|
8956
|
+
let needsComma = false;
|
|
8957
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
8958
|
+
if (_scanner.getToken() === 5) {
|
|
8959
|
+
if (!needsComma) {
|
|
8960
|
+
handleError(4, [], []);
|
|
8961
|
+
}
|
|
8962
|
+
onSeparator(",");
|
|
8963
|
+
scanNext();
|
|
8964
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
8965
|
+
break;
|
|
8966
|
+
}
|
|
8967
|
+
} else if (needsComma) {
|
|
8968
|
+
handleError(6, [], []);
|
|
8969
|
+
}
|
|
8970
|
+
if (isFirstElement) {
|
|
8971
|
+
_jsonPath.push(0);
|
|
8972
|
+
isFirstElement = false;
|
|
8973
|
+
} else {
|
|
8974
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
8975
|
+
}
|
|
8976
|
+
if (!parseValue()) {
|
|
8977
|
+
handleError(4, [], [
|
|
8978
|
+
4,
|
|
8979
|
+
5
|
|
8980
|
+
/* SyntaxKind.CommaToken */
|
|
8981
|
+
]);
|
|
8982
|
+
}
|
|
8983
|
+
needsComma = true;
|
|
8984
|
+
}
|
|
8985
|
+
onArrayEnd();
|
|
8986
|
+
if (!isFirstElement) {
|
|
8987
|
+
_jsonPath.pop();
|
|
8988
|
+
}
|
|
8989
|
+
if (_scanner.getToken() !== 4) {
|
|
8990
|
+
handleError(8, [
|
|
8991
|
+
4
|
|
8992
|
+
/* SyntaxKind.CloseBracketToken */
|
|
8993
|
+
], []);
|
|
8994
|
+
} else {
|
|
8995
|
+
scanNext();
|
|
8996
|
+
}
|
|
8997
|
+
return true;
|
|
8998
|
+
}
|
|
8999
|
+
function parseValue() {
|
|
9000
|
+
switch (_scanner.getToken()) {
|
|
9001
|
+
case 3:
|
|
9002
|
+
return parseArray();
|
|
9003
|
+
case 1:
|
|
9004
|
+
return parseObject();
|
|
9005
|
+
case 10:
|
|
9006
|
+
return parseString(true);
|
|
9007
|
+
default:
|
|
9008
|
+
return parseLiteral();
|
|
9009
|
+
}
|
|
9010
|
+
}
|
|
9011
|
+
scanNext();
|
|
9012
|
+
if (_scanner.getToken() === 17) {
|
|
9013
|
+
if (options.allowEmptyContent) {
|
|
9014
|
+
return true;
|
|
9015
|
+
}
|
|
9016
|
+
handleError(4, [], []);
|
|
9017
|
+
return false;
|
|
9018
|
+
}
|
|
9019
|
+
if (!parseValue()) {
|
|
9020
|
+
handleError(4, [], []);
|
|
9021
|
+
return false;
|
|
9022
|
+
}
|
|
9023
|
+
if (_scanner.getToken() !== 17) {
|
|
9024
|
+
handleError(9, [], []);
|
|
9025
|
+
}
|
|
9026
|
+
return true;
|
|
9027
|
+
}
|
|
9028
|
+
function stripComments(text, replaceCh) {
|
|
9029
|
+
let _scanner = createScanner(text), parts = [], kind, offset = 0, pos;
|
|
9030
|
+
do {
|
|
9031
|
+
pos = _scanner.getPosition();
|
|
9032
|
+
kind = _scanner.scan();
|
|
9033
|
+
switch (kind) {
|
|
9034
|
+
case 12:
|
|
9035
|
+
case 13:
|
|
9036
|
+
case 17:
|
|
9037
|
+
if (offset !== pos) {
|
|
9038
|
+
parts.push(text.substring(offset, pos));
|
|
9039
|
+
}
|
|
9040
|
+
if (replaceCh !== void 0) {
|
|
9041
|
+
parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
|
|
9042
|
+
}
|
|
9043
|
+
offset = _scanner.getPosition();
|
|
9044
|
+
break;
|
|
9045
|
+
}
|
|
9046
|
+
} while (kind !== 17);
|
|
9047
|
+
return parts.join("");
|
|
9048
|
+
}
|
|
9049
|
+
function getNodeType(value) {
|
|
9050
|
+
switch (typeof value) {
|
|
9051
|
+
case "boolean":
|
|
9052
|
+
return "boolean";
|
|
9053
|
+
case "number":
|
|
9054
|
+
return "number";
|
|
9055
|
+
case "string":
|
|
9056
|
+
return "string";
|
|
9057
|
+
case "object": {
|
|
9058
|
+
if (!value) {
|
|
9059
|
+
return "null";
|
|
9060
|
+
} else if (Array.isArray(value)) {
|
|
9061
|
+
return "array";
|
|
9062
|
+
}
|
|
9063
|
+
return "object";
|
|
9064
|
+
}
|
|
9065
|
+
default:
|
|
9066
|
+
return "null";
|
|
9067
|
+
}
|
|
9068
|
+
}
|
|
9069
|
+
var ParseOptions;
|
|
9070
|
+
var init_parser = __esm({
|
|
9071
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js"() {
|
|
9072
|
+
"use strict";
|
|
9073
|
+
init_scanner();
|
|
9074
|
+
(function(ParseOptions2) {
|
|
9075
|
+
ParseOptions2.DEFAULT = {
|
|
9076
|
+
allowTrailingComma: false
|
|
9077
|
+
};
|
|
9078
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
9079
|
+
}
|
|
9080
|
+
});
|
|
9081
|
+
|
|
9082
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
|
|
9083
|
+
function setProperty(text, originalPath, value, options) {
|
|
9084
|
+
const path = originalPath.slice();
|
|
9085
|
+
const errors = [];
|
|
9086
|
+
const root = parseTree(text, errors);
|
|
9087
|
+
let parent = void 0;
|
|
9088
|
+
let lastSegment = void 0;
|
|
9089
|
+
while (path.length > 0) {
|
|
9090
|
+
lastSegment = path.pop();
|
|
9091
|
+
parent = findNodeAtLocation(root, path);
|
|
9092
|
+
if (parent === void 0 && value !== void 0) {
|
|
9093
|
+
if (typeof lastSegment === "string") {
|
|
9094
|
+
value = { [lastSegment]: value };
|
|
9095
|
+
} else {
|
|
9096
|
+
value = [value];
|
|
9097
|
+
}
|
|
9098
|
+
} else {
|
|
9099
|
+
break;
|
|
9100
|
+
}
|
|
9101
|
+
}
|
|
9102
|
+
if (!parent) {
|
|
9103
|
+
if (value === void 0) {
|
|
9104
|
+
throw new Error("Can not delete in empty document");
|
|
9105
|
+
}
|
|
9106
|
+
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
|
9107
|
+
} else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
|
|
9108
|
+
const existing = findNodeAtLocation(parent, [lastSegment]);
|
|
9109
|
+
if (existing !== void 0) {
|
|
9110
|
+
if (value === void 0) {
|
|
9111
|
+
if (!existing.parent) {
|
|
9112
|
+
throw new Error("Malformed AST");
|
|
9113
|
+
}
|
|
9114
|
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
9115
|
+
let removeBegin;
|
|
9116
|
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
9117
|
+
if (propertyIndex > 0) {
|
|
9118
|
+
let previous = parent.children[propertyIndex - 1];
|
|
9119
|
+
removeBegin = previous.offset + previous.length;
|
|
9120
|
+
} else {
|
|
9121
|
+
removeBegin = parent.offset + 1;
|
|
9122
|
+
if (parent.children.length > 1) {
|
|
9123
|
+
let next = parent.children[1];
|
|
9124
|
+
removeEnd = next.offset;
|
|
9125
|
+
}
|
|
9126
|
+
}
|
|
9127
|
+
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
|
|
9128
|
+
} else {
|
|
9129
|
+
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
|
9130
|
+
}
|
|
9131
|
+
} else {
|
|
9132
|
+
if (value === void 0) {
|
|
9133
|
+
return [];
|
|
9134
|
+
}
|
|
9135
|
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
9136
|
+
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
|
|
9137
|
+
let edit;
|
|
9138
|
+
if (index > 0) {
|
|
9139
|
+
let previous = parent.children[index - 1];
|
|
9140
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
9141
|
+
} else if (parent.children.length === 0) {
|
|
9142
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
9143
|
+
} else {
|
|
9144
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
|
|
9145
|
+
}
|
|
9146
|
+
return withFormatting(text, edit, options);
|
|
9147
|
+
}
|
|
9148
|
+
} else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
|
|
9149
|
+
const insertIndex = lastSegment;
|
|
9150
|
+
if (insertIndex === -1) {
|
|
9151
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
9152
|
+
let edit;
|
|
9153
|
+
if (parent.children.length === 0) {
|
|
9154
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
9155
|
+
} else {
|
|
9156
|
+
const previous = parent.children[parent.children.length - 1];
|
|
9157
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
9158
|
+
}
|
|
9159
|
+
return withFormatting(text, edit, options);
|
|
9160
|
+
} else if (value === void 0 && parent.children.length >= 0) {
|
|
9161
|
+
const removalIndex = lastSegment;
|
|
9162
|
+
const toRemove = parent.children[removalIndex];
|
|
9163
|
+
let edit;
|
|
9164
|
+
if (parent.children.length === 1) {
|
|
9165
|
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
|
|
9166
|
+
} else if (parent.children.length - 1 === removalIndex) {
|
|
9167
|
+
let previous = parent.children[removalIndex - 1];
|
|
9168
|
+
let offset = previous.offset + previous.length;
|
|
9169
|
+
let parentEndOffset = parent.offset + parent.length;
|
|
9170
|
+
edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
|
|
9171
|
+
} else {
|
|
9172
|
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
|
|
9173
|
+
}
|
|
9174
|
+
return withFormatting(text, edit, options);
|
|
9175
|
+
} else if (value !== void 0) {
|
|
9176
|
+
let edit;
|
|
9177
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
9178
|
+
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
|
9179
|
+
const toModify = parent.children[lastSegment];
|
|
9180
|
+
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
|
9181
|
+
} else if (parent.children.length === 0 || lastSegment === 0) {
|
|
9182
|
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
|
|
9183
|
+
} else {
|
|
9184
|
+
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
9185
|
+
const previous = parent.children[index - 1];
|
|
9186
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
9187
|
+
}
|
|
9188
|
+
return withFormatting(text, edit, options);
|
|
9189
|
+
} else {
|
|
9190
|
+
throw new Error(`Can not ${value === void 0 ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
|
|
9191
|
+
}
|
|
9192
|
+
} else {
|
|
9193
|
+
throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
|
|
9194
|
+
}
|
|
9195
|
+
}
|
|
9196
|
+
function withFormatting(text, edit, options) {
|
|
9197
|
+
if (!options.formattingOptions) {
|
|
9198
|
+
return [edit];
|
|
9199
|
+
}
|
|
9200
|
+
let newText = applyEdit(text, edit);
|
|
9201
|
+
let begin = edit.offset;
|
|
9202
|
+
let end = edit.offset + edit.content.length;
|
|
9203
|
+
if (edit.length === 0 || edit.content.length === 0) {
|
|
9204
|
+
while (begin > 0 && !isEOL(newText, begin - 1)) {
|
|
9205
|
+
begin--;
|
|
9206
|
+
}
|
|
9207
|
+
while (end < newText.length && !isEOL(newText, end)) {
|
|
9208
|
+
end++;
|
|
9209
|
+
}
|
|
9210
|
+
}
|
|
9211
|
+
const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
|
9212
|
+
for (let i = edits.length - 1; i >= 0; i--) {
|
|
9213
|
+
const edit2 = edits[i];
|
|
9214
|
+
newText = applyEdit(newText, edit2);
|
|
9215
|
+
begin = Math.min(begin, edit2.offset);
|
|
9216
|
+
end = Math.max(end, edit2.offset + edit2.length);
|
|
9217
|
+
end += edit2.content.length - edit2.length;
|
|
9218
|
+
}
|
|
9219
|
+
const editLength = text.length - (newText.length - end) - begin;
|
|
9220
|
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
|
9221
|
+
}
|
|
9222
|
+
function applyEdit(text, edit) {
|
|
9223
|
+
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
|
9224
|
+
}
|
|
9225
|
+
var init_edit = __esm({
|
|
9226
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js"() {
|
|
9227
|
+
"use strict";
|
|
9228
|
+
init_format();
|
|
9229
|
+
init_parser();
|
|
9230
|
+
}
|
|
9231
|
+
});
|
|
9232
|
+
|
|
9233
|
+
// ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
|
|
9234
|
+
var main_exports = {};
|
|
9235
|
+
__export(main_exports, {
|
|
9236
|
+
ParseErrorCode: () => ParseErrorCode,
|
|
9237
|
+
ScanError: () => ScanError,
|
|
9238
|
+
SyntaxKind: () => SyntaxKind,
|
|
9239
|
+
applyEdits: () => applyEdits,
|
|
9240
|
+
createScanner: () => createScanner2,
|
|
9241
|
+
findNodeAtLocation: () => findNodeAtLocation2,
|
|
9242
|
+
findNodeAtOffset: () => findNodeAtOffset2,
|
|
9243
|
+
format: () => format2,
|
|
9244
|
+
getLocation: () => getLocation2,
|
|
9245
|
+
getNodePath: () => getNodePath2,
|
|
9246
|
+
getNodeValue: () => getNodeValue2,
|
|
9247
|
+
modify: () => modify,
|
|
9248
|
+
parse: () => parse2,
|
|
9249
|
+
parseTree: () => parseTree2,
|
|
9250
|
+
printParseErrorCode: () => printParseErrorCode,
|
|
9251
|
+
stripComments: () => stripComments2,
|
|
9252
|
+
visit: () => visit2
|
|
9253
|
+
});
|
|
9254
|
+
function printParseErrorCode(code) {
|
|
9255
|
+
switch (code) {
|
|
9256
|
+
case 1:
|
|
9257
|
+
return "InvalidSymbol";
|
|
9258
|
+
case 2:
|
|
9259
|
+
return "InvalidNumberFormat";
|
|
9260
|
+
case 3:
|
|
9261
|
+
return "PropertyNameExpected";
|
|
9262
|
+
case 4:
|
|
9263
|
+
return "ValueExpected";
|
|
9264
|
+
case 5:
|
|
9265
|
+
return "ColonExpected";
|
|
9266
|
+
case 6:
|
|
9267
|
+
return "CommaExpected";
|
|
9268
|
+
case 7:
|
|
9269
|
+
return "CloseBraceExpected";
|
|
9270
|
+
case 8:
|
|
9271
|
+
return "CloseBracketExpected";
|
|
9272
|
+
case 9:
|
|
9273
|
+
return "EndOfFileExpected";
|
|
9274
|
+
case 10:
|
|
9275
|
+
return "InvalidCommentToken";
|
|
9276
|
+
case 11:
|
|
9277
|
+
return "UnexpectedEndOfComment";
|
|
9278
|
+
case 12:
|
|
9279
|
+
return "UnexpectedEndOfString";
|
|
9280
|
+
case 13:
|
|
9281
|
+
return "UnexpectedEndOfNumber";
|
|
9282
|
+
case 14:
|
|
9283
|
+
return "InvalidUnicode";
|
|
9284
|
+
case 15:
|
|
9285
|
+
return "InvalidEscapeCharacter";
|
|
9286
|
+
case 16:
|
|
9287
|
+
return "InvalidCharacter";
|
|
9288
|
+
}
|
|
9289
|
+
return "<unknown ParseErrorCode>";
|
|
9290
|
+
}
|
|
9291
|
+
function format2(documentText, range, options) {
|
|
9292
|
+
return format(documentText, range, options);
|
|
9293
|
+
}
|
|
9294
|
+
function modify(text, path, value, options) {
|
|
9295
|
+
return setProperty(text, path, value, options);
|
|
9296
|
+
}
|
|
9297
|
+
function applyEdits(text, edits) {
|
|
9298
|
+
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
9299
|
+
const diff = a.offset - b.offset;
|
|
9300
|
+
if (diff === 0) {
|
|
9301
|
+
return a.length - b.length;
|
|
9302
|
+
}
|
|
9303
|
+
return diff;
|
|
9304
|
+
});
|
|
9305
|
+
let lastModifiedOffset = text.length;
|
|
9306
|
+
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
9307
|
+
let e = sortedEdits[i];
|
|
9308
|
+
if (e.offset + e.length <= lastModifiedOffset) {
|
|
9309
|
+
text = applyEdit(text, e);
|
|
9310
|
+
} else {
|
|
9311
|
+
throw new Error("Overlapping edit");
|
|
9312
|
+
}
|
|
9313
|
+
lastModifiedOffset = e.offset;
|
|
9314
|
+
}
|
|
9315
|
+
return text;
|
|
9316
|
+
}
|
|
9317
|
+
var createScanner2, ScanError, SyntaxKind, getLocation2, parse2, parseTree2, findNodeAtLocation2, findNodeAtOffset2, getNodePath2, getNodeValue2, visit2, stripComments2, ParseErrorCode;
|
|
9318
|
+
var init_main = __esm({
|
|
9319
|
+
"../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js"() {
|
|
9320
|
+
"use strict";
|
|
9321
|
+
init_format();
|
|
9322
|
+
init_edit();
|
|
9323
|
+
init_scanner();
|
|
9324
|
+
init_parser();
|
|
9325
|
+
createScanner2 = createScanner;
|
|
9326
|
+
(function(ScanError2) {
|
|
9327
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
9328
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
9329
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
9330
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
9331
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
9332
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
9333
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
9334
|
+
})(ScanError || (ScanError = {}));
|
|
9335
|
+
(function(SyntaxKind2) {
|
|
9336
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
9337
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
9338
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
9339
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
9340
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
9341
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
9342
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
9343
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
9344
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
9345
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
9346
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
9347
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
9348
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
9349
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
9350
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
9351
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
9352
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
9353
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
9354
|
+
getLocation2 = getLocation;
|
|
9355
|
+
parse2 = parse;
|
|
9356
|
+
parseTree2 = parseTree;
|
|
9357
|
+
findNodeAtLocation2 = findNodeAtLocation;
|
|
9358
|
+
findNodeAtOffset2 = findNodeAtOffset;
|
|
9359
|
+
getNodePath2 = getNodePath;
|
|
9360
|
+
getNodeValue2 = getNodeValue;
|
|
9361
|
+
visit2 = visit;
|
|
9362
|
+
stripComments2 = stripComments;
|
|
9363
|
+
(function(ParseErrorCode2) {
|
|
9364
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
9365
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
9366
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
9367
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
9368
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
9369
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
9370
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
9371
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
9372
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
9373
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
9374
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
9375
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
9376
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
9377
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
9378
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
9379
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
9380
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
9381
|
+
}
|
|
9382
|
+
});
|
|
9383
|
+
|
|
9384
|
+
// ../../packages/workflow-code/dist/cli/contracts/diagnostics.js
|
|
9385
|
+
var require_diagnostics = __commonJS({
|
|
9386
|
+
"../../packages/workflow-code/dist/cli/contracts/diagnostics.js"(exports2) {
|
|
9387
|
+
"use strict";
|
|
9388
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9389
|
+
exports2.diagnostic = diagnostic;
|
|
9390
|
+
function diagnostic(code, severity, message, hint) {
|
|
9391
|
+
return Object.freeze({
|
|
9392
|
+
code,
|
|
9393
|
+
severity,
|
|
9394
|
+
message,
|
|
9395
|
+
...hint === void 0 ? {} : { hint }
|
|
9396
|
+
});
|
|
9397
|
+
}
|
|
9398
|
+
}
|
|
9399
|
+
});
|
|
9400
|
+
|
|
9401
|
+
// ../../packages/workflow-code/dist/cli/config/load-config.js
|
|
9402
|
+
var require_load_config = __commonJS({
|
|
9403
|
+
"../../packages/workflow-code/dist/cli/config/load-config.js"(exports2) {
|
|
9404
|
+
"use strict";
|
|
9405
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9406
|
+
exports2.loadWorkflowCodeConfig = loadWorkflowCodeConfig;
|
|
9407
|
+
var promises_1 = require("node:fs/promises");
|
|
9408
|
+
var node_path_1 = require("node:path");
|
|
9409
|
+
var jsonc_parser_1 = (init_main(), __toCommonJS(main_exports));
|
|
9410
|
+
var diagnostics_1 = require_diagnostics();
|
|
9411
|
+
async function loadWorkflowCodeConfig(cwd, configPath) {
|
|
9412
|
+
const path = (0, node_path_1.resolve)(cwd, configPath ?? "workflow-code.config.jsonc");
|
|
9413
|
+
let content;
|
|
9414
|
+
try {
|
|
9415
|
+
content = await (0, promises_1.readFile)(path, "utf8");
|
|
9416
|
+
} catch (error) {
|
|
9417
|
+
return {
|
|
9418
|
+
ok: false,
|
|
9419
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("config.read_failed", "error", `Unable to read Workflow Code config at ${path}`, error instanceof Error ? error.message : void 0)]
|
|
9420
|
+
};
|
|
9421
|
+
}
|
|
9422
|
+
const parseErrors = [];
|
|
9423
|
+
const parsed = (0, jsonc_parser_1.parse)(content, parseErrors, {
|
|
9424
|
+
allowTrailingComma: true,
|
|
9425
|
+
disallowComments: false
|
|
9426
|
+
});
|
|
9427
|
+
if (parseErrors.length > 0) {
|
|
9428
|
+
return {
|
|
9429
|
+
ok: false,
|
|
9430
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("config.parse_failed", "error", `Unable to parse Workflow Code config at ${path}`, parseErrors.map((error) => (0, jsonc_parser_1.printParseErrorCode)(error.error)).join(", "))]
|
|
9431
|
+
};
|
|
9432
|
+
}
|
|
9433
|
+
const diagnostics = validateWorkflowCodeConfig(parsed);
|
|
9434
|
+
if (diagnostics.length > 0)
|
|
9435
|
+
return { ok: false, diagnostics };
|
|
9436
|
+
return { ok: true, value: { path, config: parsed } };
|
|
9437
|
+
}
|
|
9438
|
+
function validateWorkflowCodeConfig(value) {
|
|
9439
|
+
const diagnostics = [];
|
|
9440
|
+
if (!isRecord2(value)) {
|
|
9441
|
+
return [(0, diagnostics_1.diagnostic)("config.invalid", "error", "Workflow Code config must be an object")];
|
|
9442
|
+
}
|
|
9443
|
+
if (value.version !== 1) {
|
|
9444
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.version.invalid", "error", "Workflow Code config version must be 1"));
|
|
9445
|
+
}
|
|
9446
|
+
if (value.tsconfig !== void 0 && typeof value.tsconfig !== "string") {
|
|
9447
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.tsconfig.invalid", "error", "Config field tsconfig must be a string when provided"));
|
|
9448
|
+
}
|
|
9449
|
+
if (value.outDir !== void 0 && typeof value.outDir !== "string") {
|
|
9450
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.out_dir.invalid", "error", "Config field outDir must be a string when provided"));
|
|
9451
|
+
}
|
|
9452
|
+
if (!isRecord2(value.workflows) || Object.keys(value.workflows).length === 0) {
|
|
9453
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.workflows.invalid", "error", "Config field workflows must contain at least one workflow target"));
|
|
9454
|
+
return diagnostics;
|
|
9455
|
+
}
|
|
9456
|
+
for (const [targetName, target] of Object.entries(value.workflows)) {
|
|
9457
|
+
diagnostics.push(...validateWorkflowTarget(targetName, target));
|
|
9458
|
+
}
|
|
9459
|
+
return diagnostics;
|
|
9460
|
+
}
|
|
9461
|
+
function validateWorkflowTarget(targetName, value) {
|
|
9462
|
+
const diagnostics = [];
|
|
9463
|
+
if (!isRecord2(value)) {
|
|
9464
|
+
return [(0, diagnostics_1.diagnostic)("config.workflow.invalid", "error", `Workflow target ${targetName} must be an object`)];
|
|
9465
|
+
}
|
|
9466
|
+
const target = value;
|
|
9467
|
+
if (!target.entry || typeof target.entry !== "string") {
|
|
9468
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.workflow.entry.invalid", "error", `Workflow target ${targetName} must define string field entry`));
|
|
9469
|
+
}
|
|
9470
|
+
if (!target.projectId || typeof target.projectId !== "string") {
|
|
9471
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.workflow.project_id.invalid", "error", `Workflow target ${targetName} must define string field projectId`));
|
|
9472
|
+
}
|
|
9473
|
+
if (target.export !== void 0 && target.export !== "default") {
|
|
9474
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.workflow.export.invalid", "error", `Workflow target ${targetName} only supports export: "default"`));
|
|
9475
|
+
}
|
|
9476
|
+
for (const field of ["promptId", "workflowKey", "title"]) {
|
|
9477
|
+
if (target[field] !== void 0 && typeof target[field] !== "string") {
|
|
9478
|
+
diagnostics.push((0, diagnostics_1.diagnostic)("config.workflow.optional_field.invalid", "error", `Workflow target ${targetName} field ${field} must be a string when provided`));
|
|
9479
|
+
}
|
|
9480
|
+
}
|
|
9481
|
+
return diagnostics;
|
|
9482
|
+
}
|
|
9483
|
+
function isRecord2(value) {
|
|
9484
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9485
|
+
}
|
|
9486
|
+
}
|
|
9487
|
+
});
|
|
9488
|
+
|
|
9489
|
+
// ../../packages/workflow-code/dist/cli/ui.js
|
|
9490
|
+
var require_ui2 = __commonJS({
|
|
9491
|
+
"../../packages/workflow-code/dist/cli/ui.js"(exports2) {
|
|
9492
|
+
"use strict";
|
|
9493
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9494
|
+
exports2.heading = heading;
|
|
9495
|
+
exports2.pane = pane;
|
|
9496
|
+
exports2.section = section;
|
|
9497
|
+
exports2.kvList = kvList;
|
|
9498
|
+
exports2.stepList = stepList;
|
|
9499
|
+
exports2.bulletList = bulletList;
|
|
9500
|
+
exports2.callout = callout;
|
|
9501
|
+
exports2.resultCard = resultCard;
|
|
9502
|
+
exports2.nextActions = nextActions;
|
|
9503
|
+
exports2.table = table;
|
|
9504
|
+
exports2.joinBlocks = joinBlocks;
|
|
9505
|
+
function isDecorated(options = {}) {
|
|
9506
|
+
return options.decorate ?? true;
|
|
9507
|
+
}
|
|
9508
|
+
function applyAnsi(text, code, options = {}) {
|
|
9509
|
+
if (!isDecorated(options)) {
|
|
9510
|
+
return text;
|
|
9511
|
+
}
|
|
9512
|
+
return `\x1B[${code}m${text}\x1B[0m`;
|
|
9513
|
+
}
|
|
9514
|
+
function bold(text, options = {}) {
|
|
9515
|
+
return applyAnsi(text, 1, options);
|
|
9516
|
+
}
|
|
9517
|
+
function color(text, code, options = {}) {
|
|
9518
|
+
return applyAnsi(text, code, options);
|
|
9519
|
+
}
|
|
9520
|
+
function linesOf(input) {
|
|
9521
|
+
return Array.isArray(input) ? input.flatMap((part) => String(part).split("\n")) : String(input).split("\n");
|
|
9522
|
+
}
|
|
9523
|
+
function stripAnsi(input) {
|
|
9524
|
+
const escape = String.fromCharCode(27);
|
|
9525
|
+
return input.replace(new RegExp(`${escape}\\[[0-9;]*m`, "g"), "");
|
|
9526
|
+
}
|
|
9527
|
+
function visibleWidth(input) {
|
|
9528
|
+
return stripAnsi(input).length;
|
|
9529
|
+
}
|
|
9530
|
+
function padRight(input, width) {
|
|
9531
|
+
const padding = Math.max(0, width - visibleWidth(input));
|
|
9532
|
+
return `${input}${" ".repeat(padding)}`;
|
|
9533
|
+
}
|
|
9534
|
+
function heading(text, options = {}) {
|
|
9535
|
+
return bold(text, options);
|
|
9536
|
+
}
|
|
9537
|
+
function pane(title, content, options = {}) {
|
|
9538
|
+
const decorate = isDecorated(options);
|
|
9539
|
+
const inner = linesOf(content);
|
|
9540
|
+
const header = decorate ? color(`\u250C\u2500 ${title}`, 36, options) : `[${title}]`;
|
|
9541
|
+
const body = inner.map((line) => decorate ? `\u2502 ${line}` : line);
|
|
9542
|
+
return [header, ...body].join("\n");
|
|
9543
|
+
}
|
|
9544
|
+
function section(title, content, options = {}) {
|
|
9545
|
+
const lines = linesOf(content);
|
|
9546
|
+
return [
|
|
9547
|
+
heading(title, options),
|
|
9548
|
+
...lines.map((line) => line ? ` ${line}` : "")
|
|
9549
|
+
].join("\n");
|
|
9550
|
+
}
|
|
9551
|
+
function kvList(entries) {
|
|
9552
|
+
if (entries.length === 0) {
|
|
9553
|
+
return "";
|
|
9554
|
+
}
|
|
9555
|
+
const labelWidth = entries.reduce((max, entry) => Math.max(max, entry.label.length), 0);
|
|
9556
|
+
return entries.map((entry) => `${padRight(`${entry.label}:`, labelWidth + 1)} ${entry.value}`).join("\n");
|
|
9557
|
+
}
|
|
9558
|
+
function stepList(steps) {
|
|
9559
|
+
return steps.map((step, index) => `${index + 1}. ${step}`).join("\n");
|
|
9560
|
+
}
|
|
9561
|
+
function bulletList(items, prefix = "- ") {
|
|
9562
|
+
return items.map((item) => `${prefix}${item}`).join("\n");
|
|
9563
|
+
}
|
|
9564
|
+
function callout(kind, title, content, options = {}) {
|
|
9565
|
+
const prefixMap = {
|
|
9566
|
+
info: { symbol: "i", color: 36 },
|
|
9567
|
+
warn: { symbol: "!", color: 33 },
|
|
9568
|
+
error: { symbol: "x", color: 31 },
|
|
9569
|
+
success: { symbol: "\u2713", color: 32 }
|
|
9570
|
+
};
|
|
9571
|
+
const prefix = prefixMap[kind];
|
|
9572
|
+
const decorate = isDecorated(options);
|
|
9573
|
+
const marker = decorate ? color(prefix.symbol, prefix.color, options) : prefix.symbol;
|
|
9574
|
+
return pane(`${marker} ${title}`, content, options);
|
|
9575
|
+
}
|
|
9576
|
+
function resultCard(title, sections, options = {}) {
|
|
9577
|
+
return pane(title, sections.filter(Boolean).join("\n\n"), options);
|
|
9578
|
+
}
|
|
9579
|
+
function nextActions(actions, options = {}) {
|
|
9580
|
+
return section("Next actions", stepList(actions), options);
|
|
9581
|
+
}
|
|
9582
|
+
function table(headers, rows, options = {}) {
|
|
9583
|
+
const allRows = [headers, ...rows];
|
|
9584
|
+
const widths = headers.map((_, columnIndex) => allRows.reduce((max, row) => {
|
|
9585
|
+
return Math.max(max, visibleWidth(row[columnIndex] ?? ""));
|
|
9586
|
+
}, 0));
|
|
9587
|
+
const divider = widths.map((width) => "-".repeat(width)).join(" ");
|
|
9588
|
+
const renderedRows = allRows.map((row, rowIndex) => {
|
|
9589
|
+
const rendered = row.map((cell, columnIndex) => padRight(cell ?? "", widths[columnIndex] ?? 0)).join(" ");
|
|
9590
|
+
if (rowIndex === 0 && isDecorated(options)) {
|
|
9591
|
+
return bold(rendered, options);
|
|
9592
|
+
}
|
|
9593
|
+
return rendered;
|
|
9594
|
+
});
|
|
9595
|
+
return [renderedRows[0] ?? "", divider, ...renderedRows.slice(1)].join("\n");
|
|
9596
|
+
}
|
|
9597
|
+
function joinBlocks(blocks) {
|
|
9598
|
+
return blocks.filter((block) => Boolean(block && block.trim())).join("\n\n");
|
|
9599
|
+
}
|
|
9600
|
+
}
|
|
9601
|
+
});
|
|
9602
|
+
|
|
9603
|
+
// ../../packages/workflow-code/dist/cli/commands/compile.js
|
|
9604
|
+
var require_compile = __commonJS({
|
|
9605
|
+
"../../packages/workflow-code/dist/cli/commands/compile.js"(exports2) {
|
|
9606
|
+
"use strict";
|
|
9607
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9608
|
+
exports2.compileCommand = compileCommand;
|
|
9609
|
+
var load_config_1 = require_load_config();
|
|
9610
|
+
var ui_1 = require_ui2();
|
|
9611
|
+
async function compileCommand(context) {
|
|
9612
|
+
const configPath = typeof context.flags.config === "string" ? context.flags.config : void 0;
|
|
9613
|
+
const result = await (0, load_config_1.loadWorkflowCodeConfig)(context.cwd, configPath);
|
|
9614
|
+
if (!result.ok)
|
|
9615
|
+
return { exitCode: 1, diagnostics: result.diagnostics };
|
|
9616
|
+
const workflowNames = Object.keys(result.value.config.workflows);
|
|
9617
|
+
const targetLabel = workflowNames.length === 1 ? "target" : "targets";
|
|
9618
|
+
const targetList = workflowNames.map((name, index) => `${index + 1}: ${name}`).join("\n");
|
|
9619
|
+
const output = [
|
|
9620
|
+
`tela workflow compile scaffold: validated config for ${workflowNames.length} workflow ${targetLabel} from ${result.value.path}`,
|
|
9621
|
+
targetList
|
|
9622
|
+
].filter(Boolean).join("\n");
|
|
9623
|
+
return {
|
|
9624
|
+
exitCode: 0,
|
|
9625
|
+
output,
|
|
9626
|
+
render: () => (0, ui_1.resultCard)("Workflow compile scaffold", [
|
|
9627
|
+
(0, ui_1.section)("Summary", (0, ui_1.kvList)([
|
|
9628
|
+
{ label: "Config", value: result.value.path },
|
|
9629
|
+
{ label: "Targets", value: String(workflowNames.length) }
|
|
9630
|
+
])),
|
|
9631
|
+
workflowNames.length ? (0, ui_1.section)("Workflow targets", (0, ui_1.stepList)(workflowNames)) : void 0
|
|
9632
|
+
])
|
|
9633
|
+
};
|
|
9634
|
+
}
|
|
9635
|
+
}
|
|
9636
|
+
});
|
|
9637
|
+
|
|
9638
|
+
// ../../packages/workflow-code/dist/cli/commands/init.js
|
|
9639
|
+
var require_init = __commonJS({
|
|
9640
|
+
"../../packages/workflow-code/dist/cli/commands/init.js"(exports2) {
|
|
9641
|
+
"use strict";
|
|
9642
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9643
|
+
exports2.initCommand = initCommand;
|
|
9644
|
+
var promises_1 = require("node:fs/promises");
|
|
9645
|
+
var node_path_1 = require("node:path");
|
|
9646
|
+
var diagnostics_1 = require_diagnostics();
|
|
9647
|
+
var ui_1 = require_ui2();
|
|
9648
|
+
var DEFAULT_CONFIG = `{
|
|
9649
|
+
// Workflow Code config for tela workflow commands.
|
|
9650
|
+
"version": 1,
|
|
9651
|
+
"tsconfig": "./tsconfig.json",
|
|
9652
|
+
"outDir": ".workflow-code",
|
|
9653
|
+
"workflows": {
|
|
9654
|
+
"demo": {
|
|
9655
|
+
"entry": "./src/workflows/demo.workflow.ts",
|
|
9656
|
+
"projectId": "replace-with-project-id"
|
|
9657
|
+
}
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
`;
|
|
9661
|
+
async function initCommand(context) {
|
|
9662
|
+
const configPath = typeof context.flags.config === "string" ? context.flags.config : "workflow-code.config.jsonc";
|
|
9663
|
+
const path = (0, node_path_1.resolve)(context.cwd, configPath);
|
|
9664
|
+
try {
|
|
9665
|
+
await (0, promises_1.writeFile)(path, DEFAULT_CONFIG, { flag: "wx" });
|
|
9666
|
+
} catch (error) {
|
|
9667
|
+
if (isFileExistsError(error)) {
|
|
9668
|
+
return {
|
|
9669
|
+
exitCode: 1,
|
|
9670
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("init.config_exists", "error", `Workflow Code config already exists at ${path}`, "Move the existing file or pass --config with a different path.")]
|
|
9671
|
+
};
|
|
9672
|
+
}
|
|
9673
|
+
return {
|
|
9674
|
+
exitCode: 1,
|
|
9675
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("init.write_failed", "error", `Unable to write Workflow Code config at ${path}`, error instanceof Error ? error.message : void 0)]
|
|
9676
|
+
};
|
|
9677
|
+
}
|
|
9678
|
+
return {
|
|
9679
|
+
exitCode: 0,
|
|
9680
|
+
output: `tela workflow init: created ${path}`,
|
|
9681
|
+
render: () => (0, ui_1.resultCard)("Workflow init complete", [
|
|
9682
|
+
(0, ui_1.section)("Config", (0, ui_1.kvList)([
|
|
9683
|
+
{ label: "Path", value: path }
|
|
9684
|
+
])),
|
|
9685
|
+
(0, ui_1.nextActions)([
|
|
9686
|
+
"Edit workflow targets in `workflow-code.config.jsonc`.",
|
|
9687
|
+
"Run `tela workflow compile` to validate the config."
|
|
9688
|
+
])
|
|
9689
|
+
])
|
|
9690
|
+
};
|
|
9691
|
+
}
|
|
9692
|
+
function isFileExistsError(error) {
|
|
9693
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST";
|
|
9694
|
+
}
|
|
9695
|
+
}
|
|
9696
|
+
});
|
|
9697
|
+
|
|
9698
|
+
// ../../packages/workflow-code/dist/cli/commands/not-implemented.js
|
|
9699
|
+
var require_not_implemented = __commonJS({
|
|
9700
|
+
"../../packages/workflow-code/dist/cli/commands/not-implemented.js"(exports2) {
|
|
9701
|
+
"use strict";
|
|
9702
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9703
|
+
exports2.notImplementedCommand = notImplementedCommand;
|
|
9704
|
+
var diagnostics_1 = require_diagnostics();
|
|
9705
|
+
function notImplementedCommand(command) {
|
|
9706
|
+
return {
|
|
9707
|
+
exitCode: 1,
|
|
9708
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("cli.command.not_implemented", "error", `tela workflow ${command} is not yet available.`, "This command is planned for a future release.")]
|
|
9709
|
+
};
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
});
|
|
9713
|
+
|
|
9714
|
+
// ../../packages/workflow-code/dist/cli.js
|
|
9715
|
+
var require_cli2 = __commonJS({
|
|
9716
|
+
"../../packages/workflow-code/dist/cli.js"(exports2) {
|
|
9717
|
+
"use strict";
|
|
9718
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9719
|
+
exports2.parseWorkflowCliArgs = parseWorkflowCliArgs;
|
|
9720
|
+
exports2.runWorkflowCli = runWorkflowCli2;
|
|
9721
|
+
var compile_1 = require_compile();
|
|
9722
|
+
var init_1 = require_init();
|
|
9723
|
+
var not_implemented_1 = require_not_implemented();
|
|
9724
|
+
var diagnostics_1 = require_diagnostics();
|
|
9725
|
+
var ui_1 = require_ui2();
|
|
9726
|
+
var COMMANDS = /* @__PURE__ */ new Set([
|
|
9727
|
+
"compile",
|
|
9728
|
+
"init",
|
|
9729
|
+
"codegen",
|
|
9730
|
+
"sync",
|
|
9731
|
+
"publish",
|
|
9732
|
+
"run",
|
|
9733
|
+
"create",
|
|
9734
|
+
"watch"
|
|
9735
|
+
]);
|
|
9736
|
+
function parseWorkflowCliArgs(argv) {
|
|
9737
|
+
const [command = "help", ...rest] = argv;
|
|
9738
|
+
const flags = {};
|
|
9739
|
+
const passthrough = [];
|
|
9740
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
9741
|
+
const token = rest[index] ?? "";
|
|
9742
|
+
if (!token.startsWith("--")) {
|
|
9743
|
+
passthrough.push(token);
|
|
9744
|
+
continue;
|
|
9745
|
+
}
|
|
9746
|
+
const key = token.slice(2);
|
|
9747
|
+
if (key === "json" || key === "verbose")
|
|
9748
|
+
continue;
|
|
9749
|
+
const next = rest[index + 1];
|
|
9750
|
+
if (!next || next.startsWith("--")) {
|
|
9751
|
+
flags[key] = true;
|
|
9752
|
+
continue;
|
|
9753
|
+
}
|
|
9754
|
+
flags[key] = next;
|
|
9755
|
+
index += 1;
|
|
9756
|
+
}
|
|
9757
|
+
return { command, flags, passthrough };
|
|
9758
|
+
}
|
|
9759
|
+
async function runWorkflowCli2(argv, io, globalOptions) {
|
|
9760
|
+
const { command, flags, passthrough } = parseWorkflowCliArgs(argv);
|
|
9761
|
+
let result;
|
|
9762
|
+
if (command === "help" || command === "--help" || command === "-h") {
|
|
9763
|
+
writeHelp2(io);
|
|
9764
|
+
return 0;
|
|
9765
|
+
} else if (command === "compile") {
|
|
9766
|
+
result = missingFlagValueResult(command, flags) ?? unexpectedPassthroughResult(command, passthrough) ?? await (0, compile_1.compileCommand)({ cwd: globalOptions.cwd ?? process.cwd(), flags, passthrough });
|
|
9767
|
+
} else if (command === "init") {
|
|
9768
|
+
result = missingFlagValueResult(command, flags) ?? unexpectedPassthroughResult(command, passthrough) ?? await (0, init_1.initCommand)({ cwd: globalOptions.cwd ?? process.cwd(), flags, passthrough });
|
|
9769
|
+
} else if (COMMANDS.has(command)) {
|
|
9770
|
+
result = (0, not_implemented_1.notImplementedCommand)(command);
|
|
9771
|
+
} else {
|
|
9772
|
+
result = {
|
|
9773
|
+
exitCode: 1,
|
|
9774
|
+
diagnostics: [{
|
|
9775
|
+
code: "cli.command.unknown",
|
|
9776
|
+
severity: "error",
|
|
9777
|
+
message: `Unknown tela workflow command: ${command}`
|
|
9778
|
+
}]
|
|
9779
|
+
};
|
|
9780
|
+
}
|
|
9781
|
+
if (globalOptions.json === true) {
|
|
9782
|
+
io.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
9783
|
+
`);
|
|
9784
|
+
return result.exitCode;
|
|
9785
|
+
}
|
|
9786
|
+
if (result.render) {
|
|
9787
|
+
io.stdout.write(`${result.render()}
|
|
9788
|
+
`);
|
|
9789
|
+
} else if (result.output) {
|
|
9790
|
+
io.stdout.write(`${String(result.output)}
|
|
9791
|
+
`);
|
|
9792
|
+
}
|
|
9793
|
+
const diagnostics = result.diagnostics ?? [];
|
|
9794
|
+
if (diagnostics.length > 0) {
|
|
9795
|
+
const rendered = renderDiagnostics(diagnostics);
|
|
9796
|
+
const hasErrors = diagnostics.some((item) => item.severity === "error");
|
|
9797
|
+
const stream = hasErrors ? io.stderr : io.stdout;
|
|
9798
|
+
stream.write(`${rendered}
|
|
9799
|
+
`);
|
|
9800
|
+
}
|
|
9801
|
+
return result.exitCode;
|
|
9802
|
+
}
|
|
9803
|
+
function missingFlagValueResult(command, flags) {
|
|
9804
|
+
if (flags.config !== true)
|
|
9805
|
+
return void 0;
|
|
9806
|
+
return {
|
|
9807
|
+
exitCode: 1,
|
|
9808
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("cli.flag.missing_value", "error", "Flag --config requires a value.", `Use --config <path>, for example: tela workflow ${command} --config workflow-code.config.jsonc`)]
|
|
9809
|
+
};
|
|
9810
|
+
}
|
|
9811
|
+
function unexpectedPassthroughResult(command, passthrough) {
|
|
9812
|
+
if (passthrough.length === 0)
|
|
9813
|
+
return void 0;
|
|
9814
|
+
return {
|
|
9815
|
+
exitCode: 1,
|
|
9816
|
+
diagnostics: [(0, diagnostics_1.diagnostic)("cli.command.unexpected_args", "error", `Unexpected positional arguments for tela workflow ${command}: ${passthrough.join(" ")}`, `Run tela workflow ${command} --help to see supported arguments.`)]
|
|
9817
|
+
};
|
|
9818
|
+
}
|
|
9819
|
+
function writeHelp2(io) {
|
|
9820
|
+
io.stdout.write(`${[
|
|
9821
|
+
"Usage: tela workflow <command> [args]",
|
|
9822
|
+
"",
|
|
9823
|
+
"Commands:",
|
|
9824
|
+
" init [--config <path>] [--json]",
|
|
9825
|
+
" compile [--config <path>] [--json]",
|
|
9826
|
+
" codegen [--json]",
|
|
9827
|
+
" create [--json]",
|
|
9828
|
+
" sync [--json]",
|
|
9829
|
+
" publish [--json]",
|
|
9830
|
+
" run [--json]",
|
|
9831
|
+
" watch [--json]",
|
|
9832
|
+
"",
|
|
9833
|
+
(0, ui_1.table)(["Examples", ""], [
|
|
9834
|
+
["tela workflow init", "Create workflow-code.config.jsonc"],
|
|
9835
|
+
["tela workflow compile", "Validate local workflow config"],
|
|
9836
|
+
["tela workflow compile --config custom.jsonc", "Validate a custom config path"],
|
|
9837
|
+
["tela workflow init --json", "Create config and emit JSON result envelope"]
|
|
9838
|
+
])
|
|
9839
|
+
].join("\n")}
|
|
9840
|
+
`);
|
|
9841
|
+
}
|
|
9842
|
+
function renderDiagnostics(diagnostics) {
|
|
9843
|
+
return (0, ui_1.joinBlocks)(diagnostics.map((item) => (0, ui_1.callout)(item.severity === "error" ? "error" : item.severity === "warning" ? "warn" : "info", item.severity === "error" ? "Workflow command failed" : "Workflow command notice", [
|
|
9844
|
+
(0, ui_1.section)("Diagnostic", (0, ui_1.kvList)([
|
|
9845
|
+
{ label: "Code", value: item.code },
|
|
9846
|
+
{ label: "Severity", value: item.severity }
|
|
9847
|
+
])),
|
|
9848
|
+
(0, ui_1.section)("Message", item.message),
|
|
9849
|
+
item.hint ? (0, ui_1.section)("Hint", item.hint) : void 0
|
|
9850
|
+
].filter((part) => Boolean(part)))));
|
|
9851
|
+
}
|
|
9852
|
+
}
|
|
9853
|
+
});
|
|
9854
|
+
|
|
7709
9855
|
// src/program.ts
|
|
7710
9856
|
var import_node_fs2 = require("node:fs");
|
|
7711
9857
|
var import_node_path2 = require("node:path");
|
|
7712
9858
|
var import_tela_agent = __toESM(require_dist2());
|
|
9859
|
+
var import_cli = __toESM(require_cli2());
|
|
7713
9860
|
|
|
7714
9861
|
// src/output.ts
|
|
7715
9862
|
function writeJson(io, value) {
|
|
@@ -8770,6 +10917,8 @@ async function runCli(argv, io) {
|
|
|
8770
10917
|
if (command === "env") return runEnvCommand(rest, options, io);
|
|
8771
10918
|
if (command === "doctor") return runDoctorCommand(rest, options, io);
|
|
8772
10919
|
if (command === "agent") return (0, import_tela_agent.runAgentCli)(rest, io, options);
|
|
10920
|
+
if (command === "workflow")
|
|
10921
|
+
return (0, import_cli.runWorkflowCli)(rest, io, options);
|
|
8773
10922
|
if (command === "update" || command === "api" || command === "docs" || command === "whoami" || command === "token") {
|
|
8774
10923
|
return runTelactlCommand(command, rest, options, io);
|
|
8775
10924
|
}
|
|
@@ -8813,6 +10962,9 @@ function writeHelp(io) {
|
|
|
8813
10962
|
writeLine(io, " whoami [--context <context-id>] [-p|--pretty]");
|
|
8814
10963
|
writeLine(io, " token [--context <context-id>]");
|
|
8815
10964
|
writeLine(io, " version");
|
|
10965
|
+
writeLine(io, " workflow init [--config <path>] [--json]");
|
|
10966
|
+
writeLine(io, " workflow compile [--config <path>] [--json]");
|
|
10967
|
+
writeLine(io, " workflow codegen|create|sync|publish|run|watch [--json]");
|
|
8816
10968
|
writeLine(io, " agent sync [repo] [--current] [--all] [--dry-run] [--json] [--verbose]");
|
|
8817
10969
|
writeLine(io, " agent run [--input <name=path>...] [--mode one-shot|chat] [--input-conflict fail|overwrite|rename] [--plain] [--json] [--verbose]");
|
|
8818
10970
|
writeLine(io, " agent push [--message <text>|--claude|--manual] [--dry-run] [--json] [--verbose]");
|