@shopify/create-app 3.94.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-XLT3JDGP.js +33 -0
- package/dist/analytics-XUVDQAYG.js +39 -0
- package/dist/chunk-37G3KLO2.js +78 -0
- package/dist/chunk-4CS37CS5.js +665 -0
- package/dist/chunk-6OOTYTVB.js +1133 -0
- package/dist/{chunk-NIYBO6HO.js → chunk-ACS6S42W.js} +3 -3
- package/dist/chunk-ANIFE3UR.js +12 -0
- package/dist/{chunk-2ZQ4JUYQ.js → chunk-DHAC6KEL.js} +47 -12
- package/dist/chunk-DJW2W7VA.js +21 -0
- package/dist/chunk-DNF3EUMN.js +1771 -0
- package/dist/{chunk-LI75HRH4.js → chunk-DWGHKWV5.js} +1 -1
- package/dist/chunk-IGDZPTDH.js +371 -0
- package/dist/chunk-JCETIRLI.js +30 -0
- package/dist/chunk-JUV7D377.js +264 -0
- package/dist/{chunk-QCVAV5PM.js → chunk-LNOZTAML.js} +3618 -10143
- package/dist/{chunk-IFG7N3S2.js → chunk-OO33NRTL.js} +8 -12671
- package/dist/chunk-PES3XMQM.js +70 -0
- package/dist/chunk-QMXFPY46.js +55 -0
- package/dist/chunk-QN5KFM2B.js +104 -0
- package/dist/{chunk-XDAJMLCV.js → chunk-STHW3YIX.js} +43773 -43784
- package/dist/chunk-UMSYG5WJ.js +110 -0
- package/dist/chunk-UX6FRPFM.js +11555 -0
- package/dist/{chunk-CXPWSYGC.js → chunk-X2WZCKNE.js} +4 -14
- package/dist/chunk-YIHECXVH.js +5652 -0
- package/dist/chunk-YUPQUA3D.js +6106 -0
- package/dist/conf-store-RAVX2WFV.js +54 -0
- package/dist/custom-oclif-loader-354VAVF4.js +54 -0
- package/dist/deprecations-2QTB3736.js +55 -0
- package/dist/environments-LTWWRWCC.js +26 -0
- package/dist/error-handler-KHJE653Z.js +37 -0
- package/dist/fs-XENRLBMU.js +109 -0
- package/dist/hooks/postrun.js +6 -9
- package/dist/hooks/prerun.js +12 -25
- package/dist/{http-proxy-node16-U5VBDLS3.js → http-proxy-node16-XB2DSBCB.js} +3 -2
- package/dist/index.js +8987 -10518
- package/dist/is-global-KZMSAFQT.js +21 -0
- package/dist/latest-version-3PFKLJZM.js +7713 -0
- package/dist/lib-HWIFANCM.js +11 -0
- package/dist/{local-HD6YAL26.js → local-NQALOHJX.js} +3 -8
- package/dist/metadata-FXCUDE5I.js +20 -0
- package/dist/{node-package-manager-FD3ZCHSY.js → node-package-manager-7R7HDW4R.js} +17 -7
- package/dist/notifications-system-7QMDSL5Y.js +40 -0
- package/dist/output-PQSQ7U45.js +51 -0
- package/dist/{path-NQ6GZ2WO.js → path-EOPO7QNL.js} +2 -2
- package/dist/{prettier-67WYXU6J.js → prettier-UAG5TKE4.js} +2 -2
- package/dist/system-W4MMMHEV.js +47 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typescript-TKTDYKKG.js +6 -0
- package/dist/{ui-TJ7NU25P.js → ui-2FROV2IT.js} +15 -6
- package/dist/{chunk-Q2E5NGP3.js → upgrade-FAUZ7VAF.js} +77 -125
- package/dist/version-HKPHVW5M.js +30 -0
- package/dist/version-T73ZLUJK.js +8 -0
- package/oclif.manifest.json +63 -66
- package/package.json +5 -5
- package/dist/chunk-27ZXSSGX.js +0 -14117
- package/dist/error-handler-ZQMQHJ3W.js +0 -25
- package/dist/lib-PPI2FZOR.js +0 -8
|
@@ -0,0 +1,1771 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderWarning
|
|
3
|
+
} from "./chunk-YIHECXVH.js";
|
|
4
|
+
import {
|
|
5
|
+
addSensitiveMetadata
|
|
6
|
+
} from "./chunk-37G3KLO2.js";
|
|
7
|
+
import {
|
|
8
|
+
fileExists,
|
|
9
|
+
findPathUp,
|
|
10
|
+
readFile,
|
|
11
|
+
writeFile
|
|
12
|
+
} from "./chunk-LNOZTAML.js";
|
|
13
|
+
import {
|
|
14
|
+
cwd
|
|
15
|
+
} from "./chunk-ACS6S42W.js";
|
|
16
|
+
import {
|
|
17
|
+
__commonJS,
|
|
18
|
+
__require,
|
|
19
|
+
__toESM,
|
|
20
|
+
init_cjs_shims
|
|
21
|
+
} from "./chunk-PKR7KJ6P.js";
|
|
22
|
+
|
|
23
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
|
|
24
|
+
var require_parser = __commonJS({
|
|
25
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) {
|
|
26
|
+
"use strict";
|
|
27
|
+
init_cjs_shims();
|
|
28
|
+
var ParserError = class _ParserError extends Error {
|
|
29
|
+
/* istanbul ignore next */
|
|
30
|
+
constructor(msg, filename, linenumber) {
|
|
31
|
+
super("[ParserError] " + msg, filename, linenumber), this.name = "ParserError", this.code = "ParserError", Error.captureStackTrace && Error.captureStackTrace(this, _ParserError);
|
|
32
|
+
}
|
|
33
|
+
}, State = class {
|
|
34
|
+
constructor(parser) {
|
|
35
|
+
this.parser = parser, this.buf = "", this.returned = null, this.result = null, this.resultTable = null, this.resultArr = null;
|
|
36
|
+
}
|
|
37
|
+
}, Parser = class {
|
|
38
|
+
constructor() {
|
|
39
|
+
this.pos = 0, this.col = 0, this.line = 0, this.obj = {}, this.ctx = this.obj, this.stack = [], this._buf = "", this.char = null, this.ii = 0, this.state = new State(this.parseStart);
|
|
40
|
+
}
|
|
41
|
+
parse(str) {
|
|
42
|
+
if (str.length === 0 || str.length == null) return;
|
|
43
|
+
this._buf = String(str), this.ii = -1, this.char = -1;
|
|
44
|
+
let getNext;
|
|
45
|
+
for (; getNext === !1 || this.nextChar(); )
|
|
46
|
+
getNext = this.runOne();
|
|
47
|
+
this._buf = null;
|
|
48
|
+
}
|
|
49
|
+
nextChar() {
|
|
50
|
+
return this.char === 10 && (++this.line, this.col = -1), ++this.ii, this.char = this._buf.codePointAt(this.ii), ++this.pos, ++this.col, this.haveBuffer();
|
|
51
|
+
}
|
|
52
|
+
haveBuffer() {
|
|
53
|
+
return this.ii < this._buf.length;
|
|
54
|
+
}
|
|
55
|
+
runOne() {
|
|
56
|
+
return this.state.parser.call(this, this.state.returned);
|
|
57
|
+
}
|
|
58
|
+
finish() {
|
|
59
|
+
this.char = 1114112;
|
|
60
|
+
let last;
|
|
61
|
+
do
|
|
62
|
+
last = this.state.parser, this.runOne();
|
|
63
|
+
while (this.state.parser !== last);
|
|
64
|
+
return this.ctx = null, this.state = null, this._buf = null, this.obj;
|
|
65
|
+
}
|
|
66
|
+
next(fn) {
|
|
67
|
+
if (typeof fn != "function") throw new ParserError("Tried to set state to non-existent state: " + JSON.stringify(fn));
|
|
68
|
+
this.state.parser = fn;
|
|
69
|
+
}
|
|
70
|
+
goto(fn) {
|
|
71
|
+
return this.next(fn), this.runOne();
|
|
72
|
+
}
|
|
73
|
+
call(fn, returnWith) {
|
|
74
|
+
returnWith && this.next(returnWith), this.stack.push(this.state), this.state = new State(fn);
|
|
75
|
+
}
|
|
76
|
+
callNow(fn, returnWith) {
|
|
77
|
+
return this.call(fn, returnWith), this.runOne();
|
|
78
|
+
}
|
|
79
|
+
return(value) {
|
|
80
|
+
if (this.stack.length === 0) throw this.error(new ParserError("Stack underflow"));
|
|
81
|
+
value === void 0 && (value = this.state.buf), this.state = this.stack.pop(), this.state.returned = value;
|
|
82
|
+
}
|
|
83
|
+
returnNow(value) {
|
|
84
|
+
return this.return(value), this.runOne();
|
|
85
|
+
}
|
|
86
|
+
consume() {
|
|
87
|
+
if (this.char === 1114112) throw this.error(new ParserError("Unexpected end-of-buffer"));
|
|
88
|
+
this.state.buf += this._buf[this.ii];
|
|
89
|
+
}
|
|
90
|
+
error(err) {
|
|
91
|
+
return err.line = this.line, err.col = this.col, err.pos = this.pos, err;
|
|
92
|
+
}
|
|
93
|
+
/* istanbul ignore next */
|
|
94
|
+
parseStart() {
|
|
95
|
+
throw new ParserError("Must declare a parseStart method");
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
Parser.END = 1114112;
|
|
99
|
+
Parser.Error = ParserError;
|
|
100
|
+
module2.exports = Parser;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js
|
|
105
|
+
var require_create_datetime = __commonJS({
|
|
106
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) {
|
|
107
|
+
"use strict";
|
|
108
|
+
init_cjs_shims();
|
|
109
|
+
module2.exports = (value) => {
|
|
110
|
+
let date = new Date(value);
|
|
111
|
+
if (isNaN(date))
|
|
112
|
+
throw new TypeError("Invalid Datetime");
|
|
113
|
+
return date;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js
|
|
119
|
+
var require_format_num = __commonJS({
|
|
120
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) {
|
|
121
|
+
"use strict";
|
|
122
|
+
init_cjs_shims();
|
|
123
|
+
module2.exports = (d, num) => {
|
|
124
|
+
for (num = String(num); num.length < d; ) num = "0" + num;
|
|
125
|
+
return num;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js
|
|
131
|
+
var require_create_datetime_float = __commonJS({
|
|
132
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) {
|
|
133
|
+
"use strict";
|
|
134
|
+
init_cjs_shims();
|
|
135
|
+
var f = require_format_num(), FloatingDateTime = class extends Date {
|
|
136
|
+
constructor(value) {
|
|
137
|
+
super(value + "Z"), this.isFloating = !0;
|
|
138
|
+
}
|
|
139
|
+
toISOString() {
|
|
140
|
+
let date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`, time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
|
|
141
|
+
return `${date}T${time}`;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
module2.exports = (value) => {
|
|
145
|
+
let date = new FloatingDateTime(value);
|
|
146
|
+
if (isNaN(date))
|
|
147
|
+
throw new TypeError("Invalid Datetime");
|
|
148
|
+
return date;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js
|
|
154
|
+
var require_create_date = __commonJS({
|
|
155
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) {
|
|
156
|
+
"use strict";
|
|
157
|
+
init_cjs_shims();
|
|
158
|
+
var f = require_format_num(), DateTime = global.Date, Date2 = class extends DateTime {
|
|
159
|
+
constructor(value) {
|
|
160
|
+
super(value), this.isDate = !0;
|
|
161
|
+
}
|
|
162
|
+
toISOString() {
|
|
163
|
+
return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
module2.exports = (value) => {
|
|
167
|
+
let date = new Date2(value);
|
|
168
|
+
if (isNaN(date))
|
|
169
|
+
throw new TypeError("Invalid Datetime");
|
|
170
|
+
return date;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js
|
|
176
|
+
var require_create_time = __commonJS({
|
|
177
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) {
|
|
178
|
+
"use strict";
|
|
179
|
+
init_cjs_shims();
|
|
180
|
+
var f = require_format_num(), Time = class extends Date {
|
|
181
|
+
constructor(value) {
|
|
182
|
+
super(`0000-01-01T${value}Z`), this.isTime = !0;
|
|
183
|
+
}
|
|
184
|
+
toISOString() {
|
|
185
|
+
return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
module2.exports = (value) => {
|
|
189
|
+
let date = new Time(value);
|
|
190
|
+
if (isNaN(date))
|
|
191
|
+
throw new TypeError("Invalid Datetime");
|
|
192
|
+
return date;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js
|
|
198
|
+
var require_toml_parser = __commonJS({
|
|
199
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports, module) {
|
|
200
|
+
"use strict";
|
|
201
|
+
init_cjs_shims();
|
|
202
|
+
module.exports = makeParserClass(require_parser());
|
|
203
|
+
module.exports.makeParserClass = makeParserClass;
|
|
204
|
+
var TomlError = class _TomlError extends Error {
|
|
205
|
+
constructor(msg) {
|
|
206
|
+
super(msg), this.name = "TomlError", Error.captureStackTrace && Error.captureStackTrace(this, _TomlError), this.fromTOML = !0, this.wrapped = null;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
TomlError.wrap = (err) => {
|
|
210
|
+
let terr = new TomlError(err.message);
|
|
211
|
+
return terr.code = err.code, terr.wrapped = err, terr;
|
|
212
|
+
};
|
|
213
|
+
module.exports.TomlError = TomlError;
|
|
214
|
+
var createDateTime = require_create_datetime(), createDateTimeFloat = require_create_datetime_float(), createDate = require_create_date(), createTime = require_create_time(), CTRL_I = 9, CTRL_J = 10, CTRL_M = 13, CTRL_CHAR_BOUNDARY = 31, CHAR_SP = 32, CHAR_QUOT = 34, CHAR_NUM = 35, CHAR_APOS = 39, CHAR_PLUS = 43, CHAR_COMMA = 44, CHAR_HYPHEN = 45, CHAR_PERIOD = 46, CHAR_0 = 48, CHAR_1 = 49, CHAR_7 = 55, CHAR_9 = 57, CHAR_COLON = 58, CHAR_EQUALS = 61, CHAR_A = 65, CHAR_E = 69, CHAR_F = 70, CHAR_T = 84, CHAR_U = 85, CHAR_Z = 90, CHAR_LOWBAR = 95, CHAR_a = 97, CHAR_b = 98, CHAR_e = 101, CHAR_f = 102, CHAR_i = 105, CHAR_l = 108, CHAR_n = 110, CHAR_o = 111, CHAR_r = 114, CHAR_s = 115, CHAR_t = 116, CHAR_u = 117, CHAR_x = 120, CHAR_z = 122, CHAR_LCUB = 123, CHAR_RCUB = 125, CHAR_LSQB = 91, CHAR_BSOL = 92, CHAR_RSQB = 93, CHAR_DEL = 127, SURROGATE_FIRST = 55296, SURROGATE_LAST = 57343, escapes = {
|
|
215
|
+
[CHAR_b]: "\b",
|
|
216
|
+
[CHAR_t]: " ",
|
|
217
|
+
[CHAR_n]: `
|
|
218
|
+
`,
|
|
219
|
+
[CHAR_f]: "\f",
|
|
220
|
+
[CHAR_r]: "\r",
|
|
221
|
+
[CHAR_QUOT]: '"',
|
|
222
|
+
[CHAR_BSOL]: "\\"
|
|
223
|
+
};
|
|
224
|
+
function isDigit(cp) {
|
|
225
|
+
return cp >= CHAR_0 && cp <= CHAR_9;
|
|
226
|
+
}
|
|
227
|
+
function isHexit(cp) {
|
|
228
|
+
return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
|
|
229
|
+
}
|
|
230
|
+
function isBit(cp) {
|
|
231
|
+
return cp === CHAR_1 || cp === CHAR_0;
|
|
232
|
+
}
|
|
233
|
+
function isOctit(cp) {
|
|
234
|
+
return cp >= CHAR_0 && cp <= CHAR_7;
|
|
235
|
+
}
|
|
236
|
+
function isAlphaNumQuoteHyphen(cp) {
|
|
237
|
+
return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
|
|
238
|
+
}
|
|
239
|
+
function isAlphaNumHyphen(cp) {
|
|
240
|
+
return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
|
|
241
|
+
}
|
|
242
|
+
var _type = /* @__PURE__ */ Symbol("type"), _declared = /* @__PURE__ */ Symbol("declared"), hasOwnProperty = Object.prototype.hasOwnProperty, defineProperty = Object.defineProperty, descriptor = { configurable: !0, enumerable: !0, writable: !0, value: void 0 };
|
|
243
|
+
function hasKey(obj, key) {
|
|
244
|
+
return hasOwnProperty.call(obj, key) ? !0 : (key === "__proto__" && defineProperty(obj, "__proto__", descriptor), !1);
|
|
245
|
+
}
|
|
246
|
+
var INLINE_TABLE = /* @__PURE__ */ Symbol("inline-table");
|
|
247
|
+
function InlineTable() {
|
|
248
|
+
return Object.defineProperties({}, {
|
|
249
|
+
[_type]: { value: INLINE_TABLE }
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function isInlineTable(obj) {
|
|
253
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === INLINE_TABLE;
|
|
254
|
+
}
|
|
255
|
+
var TABLE = /* @__PURE__ */ Symbol("table");
|
|
256
|
+
function Table() {
|
|
257
|
+
return Object.defineProperties({}, {
|
|
258
|
+
[_type]: { value: TABLE },
|
|
259
|
+
[_declared]: { value: !1, writable: !0 }
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function isTable(obj) {
|
|
263
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === TABLE;
|
|
264
|
+
}
|
|
265
|
+
var _contentType = /* @__PURE__ */ Symbol("content-type"), INLINE_LIST = /* @__PURE__ */ Symbol("inline-list");
|
|
266
|
+
function InlineList(type) {
|
|
267
|
+
return Object.defineProperties([], {
|
|
268
|
+
[_type]: { value: INLINE_LIST },
|
|
269
|
+
[_contentType]: { value: type }
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function isInlineList(obj) {
|
|
273
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === INLINE_LIST;
|
|
274
|
+
}
|
|
275
|
+
var LIST = /* @__PURE__ */ Symbol("list");
|
|
276
|
+
function List() {
|
|
277
|
+
return Object.defineProperties([], {
|
|
278
|
+
[_type]: { value: LIST }
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function isList(obj) {
|
|
282
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === LIST;
|
|
283
|
+
}
|
|
284
|
+
var _custom;
|
|
285
|
+
try {
|
|
286
|
+
let utilInspect = eval("require('util').inspect");
|
|
287
|
+
_custom = utilInspect.custom;
|
|
288
|
+
} catch (_) {
|
|
289
|
+
}
|
|
290
|
+
var _inspect = _custom || "inspect", BoxedBigInt = class {
|
|
291
|
+
constructor(value) {
|
|
292
|
+
try {
|
|
293
|
+
this.value = global.BigInt.asIntN(64, value);
|
|
294
|
+
} catch {
|
|
295
|
+
this.value = null;
|
|
296
|
+
}
|
|
297
|
+
Object.defineProperty(this, _type, { value: INTEGER });
|
|
298
|
+
}
|
|
299
|
+
isNaN() {
|
|
300
|
+
return this.value === null;
|
|
301
|
+
}
|
|
302
|
+
/* istanbul ignore next */
|
|
303
|
+
toString() {
|
|
304
|
+
return String(this.value);
|
|
305
|
+
}
|
|
306
|
+
/* istanbul ignore next */
|
|
307
|
+
[_inspect]() {
|
|
308
|
+
return `[BigInt: ${this.toString()}]}`;
|
|
309
|
+
}
|
|
310
|
+
valueOf() {
|
|
311
|
+
return this.value;
|
|
312
|
+
}
|
|
313
|
+
}, INTEGER = /* @__PURE__ */ Symbol("integer");
|
|
314
|
+
function Integer(value) {
|
|
315
|
+
let num = Number(value);
|
|
316
|
+
return Object.is(num, -0) && (num = 0), global.BigInt && !Number.isSafeInteger(num) ? new BoxedBigInt(value) : Object.defineProperties(new Number(num), {
|
|
317
|
+
isNaN: { value: function() {
|
|
318
|
+
return isNaN(this);
|
|
319
|
+
} },
|
|
320
|
+
[_type]: { value: INTEGER },
|
|
321
|
+
[_inspect]: { value: () => `[Integer: ${value}]` }
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function isInteger(obj) {
|
|
325
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === INTEGER;
|
|
326
|
+
}
|
|
327
|
+
var FLOAT = /* @__PURE__ */ Symbol("float");
|
|
328
|
+
function Float(value) {
|
|
329
|
+
return Object.defineProperties(new Number(value), {
|
|
330
|
+
[_type]: { value: FLOAT },
|
|
331
|
+
[_inspect]: { value: () => `[Float: ${value}]` }
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function isFloat(obj) {
|
|
335
|
+
return obj === null || typeof obj != "object" ? !1 : obj[_type] === FLOAT;
|
|
336
|
+
}
|
|
337
|
+
function tomlType(value) {
|
|
338
|
+
let type = typeof value;
|
|
339
|
+
if (type === "object") {
|
|
340
|
+
if (value === null) return "null";
|
|
341
|
+
if (value instanceof Date) return "datetime";
|
|
342
|
+
if (_type in value)
|
|
343
|
+
switch (value[_type]) {
|
|
344
|
+
case INLINE_TABLE:
|
|
345
|
+
return "inline-table";
|
|
346
|
+
case INLINE_LIST:
|
|
347
|
+
return "inline-list";
|
|
348
|
+
/* istanbul ignore next */
|
|
349
|
+
case TABLE:
|
|
350
|
+
return "table";
|
|
351
|
+
/* istanbul ignore next */
|
|
352
|
+
case LIST:
|
|
353
|
+
return "list";
|
|
354
|
+
case FLOAT:
|
|
355
|
+
return "float";
|
|
356
|
+
case INTEGER:
|
|
357
|
+
return "integer";
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return type;
|
|
361
|
+
}
|
|
362
|
+
function makeParserClass(Parser) {
|
|
363
|
+
class TOMLParser extends Parser {
|
|
364
|
+
constructor() {
|
|
365
|
+
super(), this.ctx = this.obj = Table();
|
|
366
|
+
}
|
|
367
|
+
/* MATCH HELPER */
|
|
368
|
+
atEndOfWord() {
|
|
369
|
+
return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
|
|
370
|
+
}
|
|
371
|
+
atEndOfLine() {
|
|
372
|
+
return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
|
|
373
|
+
}
|
|
374
|
+
parseStart() {
|
|
375
|
+
if (this.char === Parser.END)
|
|
376
|
+
return null;
|
|
377
|
+
if (this.char === CHAR_LSQB)
|
|
378
|
+
return this.call(this.parseTableOrList);
|
|
379
|
+
if (this.char === CHAR_NUM)
|
|
380
|
+
return this.call(this.parseComment);
|
|
381
|
+
if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M)
|
|
382
|
+
return null;
|
|
383
|
+
if (isAlphaNumQuoteHyphen(this.char))
|
|
384
|
+
return this.callNow(this.parseAssignStatement);
|
|
385
|
+
throw this.error(new TomlError(`Unknown character "${this.char}"`));
|
|
386
|
+
}
|
|
387
|
+
// HELPER, this strips any whitespace and comments to the end of the line
|
|
388
|
+
// then RETURNS. Last state in a production.
|
|
389
|
+
parseWhitespaceToEOL() {
|
|
390
|
+
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M)
|
|
391
|
+
return null;
|
|
392
|
+
if (this.char === CHAR_NUM)
|
|
393
|
+
return this.goto(this.parseComment);
|
|
394
|
+
if (this.char === Parser.END || this.char === CTRL_J)
|
|
395
|
+
return this.return();
|
|
396
|
+
throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line"));
|
|
397
|
+
}
|
|
398
|
+
/* ASSIGNMENT: key = value */
|
|
399
|
+
parseAssignStatement() {
|
|
400
|
+
return this.callNow(this.parseAssign, this.recordAssignStatement);
|
|
401
|
+
}
|
|
402
|
+
recordAssignStatement(kv) {
|
|
403
|
+
let target = this.ctx, finalKey = kv.key.pop();
|
|
404
|
+
for (let kw of kv.key) {
|
|
405
|
+
if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared]))
|
|
406
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
407
|
+
target = target[kw] = target[kw] || Table();
|
|
408
|
+
}
|
|
409
|
+
if (hasKey(target, finalKey))
|
|
410
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
411
|
+
return isInteger(kv.value) || isFloat(kv.value) ? target[finalKey] = kv.value.valueOf() : target[finalKey] = kv.value, this.goto(this.parseWhitespaceToEOL);
|
|
412
|
+
}
|
|
413
|
+
/* ASSSIGNMENT expression, key = value possibly inside an inline table */
|
|
414
|
+
parseAssign() {
|
|
415
|
+
return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
|
416
|
+
}
|
|
417
|
+
recordAssignKeyword(key) {
|
|
418
|
+
return this.state.resultTable ? this.state.resultTable.push(key) : this.state.resultTable = [key], this.goto(this.parseAssignKeywordPreDot);
|
|
419
|
+
}
|
|
420
|
+
parseAssignKeywordPreDot() {
|
|
421
|
+
if (this.char === CHAR_PERIOD)
|
|
422
|
+
return this.next(this.parseAssignKeywordPostDot);
|
|
423
|
+
if (this.char !== CHAR_SP && this.char !== CTRL_I)
|
|
424
|
+
return this.goto(this.parseAssignEqual);
|
|
425
|
+
}
|
|
426
|
+
parseAssignKeywordPostDot() {
|
|
427
|
+
if (this.char !== CHAR_SP && this.char !== CTRL_I)
|
|
428
|
+
return this.callNow(this.parseKeyword, this.recordAssignKeyword);
|
|
429
|
+
}
|
|
430
|
+
parseAssignEqual() {
|
|
431
|
+
if (this.char === CHAR_EQUALS)
|
|
432
|
+
return this.next(this.parseAssignPreValue);
|
|
433
|
+
throw this.error(new TomlError('Invalid character, expected "="'));
|
|
434
|
+
}
|
|
435
|
+
parseAssignPreValue() {
|
|
436
|
+
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseValue, this.recordAssignValue);
|
|
437
|
+
}
|
|
438
|
+
recordAssignValue(value) {
|
|
439
|
+
return this.returnNow({ key: this.state.resultTable, value });
|
|
440
|
+
}
|
|
441
|
+
/* COMMENTS: #...eol */
|
|
442
|
+
parseComment() {
|
|
443
|
+
do
|
|
444
|
+
if (this.char === Parser.END || this.char === CTRL_J)
|
|
445
|
+
return this.return();
|
|
446
|
+
while (this.nextChar());
|
|
447
|
+
}
|
|
448
|
+
/* TABLES AND LISTS, [foo] and [[foo]] */
|
|
449
|
+
parseTableOrList() {
|
|
450
|
+
if (this.char === CHAR_LSQB)
|
|
451
|
+
this.next(this.parseList);
|
|
452
|
+
else
|
|
453
|
+
return this.goto(this.parseTable);
|
|
454
|
+
}
|
|
455
|
+
/* TABLE [foo.bar.baz] */
|
|
456
|
+
parseTable() {
|
|
457
|
+
return this.ctx = this.obj, this.goto(this.parseTableNext);
|
|
458
|
+
}
|
|
459
|
+
parseTableNext() {
|
|
460
|
+
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseTableMore);
|
|
461
|
+
}
|
|
462
|
+
parseTableMore(keyword) {
|
|
463
|
+
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
464
|
+
return null;
|
|
465
|
+
if (this.char === CHAR_RSQB) {
|
|
466
|
+
if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared]))
|
|
467
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
468
|
+
return this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table(), this.ctx[_declared] = !0, this.next(this.parseWhitespaceToEOL);
|
|
469
|
+
} else if (this.char === CHAR_PERIOD) {
|
|
470
|
+
if (!hasKey(this.ctx, keyword))
|
|
471
|
+
this.ctx = this.ctx[keyword] = Table();
|
|
472
|
+
else if (isTable(this.ctx[keyword]))
|
|
473
|
+
this.ctx = this.ctx[keyword];
|
|
474
|
+
else if (isList(this.ctx[keyword]))
|
|
475
|
+
this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
|
|
476
|
+
else
|
|
477
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
478
|
+
return this.next(this.parseTableNext);
|
|
479
|
+
} else
|
|
480
|
+
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
481
|
+
}
|
|
482
|
+
/* LIST [[a.b.c]] */
|
|
483
|
+
parseList() {
|
|
484
|
+
return this.ctx = this.obj, this.goto(this.parseListNext);
|
|
485
|
+
}
|
|
486
|
+
parseListNext() {
|
|
487
|
+
return this.char === CHAR_SP || this.char === CTRL_I ? null : this.callNow(this.parseKeyword, this.parseListMore);
|
|
488
|
+
}
|
|
489
|
+
parseListMore(keyword) {
|
|
490
|
+
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
491
|
+
return null;
|
|
492
|
+
if (this.char === CHAR_RSQB) {
|
|
493
|
+
if (hasKey(this.ctx, keyword) || (this.ctx[keyword] = List()), isInlineList(this.ctx[keyword]))
|
|
494
|
+
throw this.error(new TomlError("Can't extend an inline array"));
|
|
495
|
+
if (isList(this.ctx[keyword])) {
|
|
496
|
+
let next = Table();
|
|
497
|
+
this.ctx[keyword].push(next), this.ctx = next;
|
|
498
|
+
} else
|
|
499
|
+
throw this.error(new TomlError("Can't redefine an existing key"));
|
|
500
|
+
return this.next(this.parseListEnd);
|
|
501
|
+
} else if (this.char === CHAR_PERIOD) {
|
|
502
|
+
if (!hasKey(this.ctx, keyword))
|
|
503
|
+
this.ctx = this.ctx[keyword] = Table();
|
|
504
|
+
else {
|
|
505
|
+
if (isInlineList(this.ctx[keyword]))
|
|
506
|
+
throw this.error(new TomlError("Can't extend an inline array"));
|
|
507
|
+
if (isInlineTable(this.ctx[keyword]))
|
|
508
|
+
throw this.error(new TomlError("Can't extend an inline table"));
|
|
509
|
+
if (isList(this.ctx[keyword]))
|
|
510
|
+
this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
|
|
511
|
+
else if (isTable(this.ctx[keyword]))
|
|
512
|
+
this.ctx = this.ctx[keyword];
|
|
513
|
+
else
|
|
514
|
+
throw this.error(new TomlError("Can't redefine an existing key"));
|
|
515
|
+
}
|
|
516
|
+
return this.next(this.parseListNext);
|
|
517
|
+
} else
|
|
518
|
+
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
519
|
+
}
|
|
520
|
+
parseListEnd(keyword) {
|
|
521
|
+
if (this.char === CHAR_RSQB)
|
|
522
|
+
return this.next(this.parseWhitespaceToEOL);
|
|
523
|
+
throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
|
|
524
|
+
}
|
|
525
|
+
/* VALUE string, number, boolean, inline list, inline object */
|
|
526
|
+
parseValue() {
|
|
527
|
+
if (this.char === Parser.END)
|
|
528
|
+
throw this.error(new TomlError("Key without value"));
|
|
529
|
+
if (this.char === CHAR_QUOT)
|
|
530
|
+
return this.next(this.parseDoubleString);
|
|
531
|
+
if (this.char === CHAR_APOS)
|
|
532
|
+
return this.next(this.parseSingleString);
|
|
533
|
+
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
534
|
+
return this.goto(this.parseNumberSign);
|
|
535
|
+
if (this.char === CHAR_i)
|
|
536
|
+
return this.next(this.parseInf);
|
|
537
|
+
if (this.char === CHAR_n)
|
|
538
|
+
return this.next(this.parseNan);
|
|
539
|
+
if (isDigit(this.char))
|
|
540
|
+
return this.goto(this.parseNumberOrDateTime);
|
|
541
|
+
if (this.char === CHAR_t || this.char === CHAR_f)
|
|
542
|
+
return this.goto(this.parseBoolean);
|
|
543
|
+
if (this.char === CHAR_LSQB)
|
|
544
|
+
return this.call(this.parseInlineList, this.recordValue);
|
|
545
|
+
if (this.char === CHAR_LCUB)
|
|
546
|
+
return this.call(this.parseInlineTable, this.recordValue);
|
|
547
|
+
throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table"));
|
|
548
|
+
}
|
|
549
|
+
recordValue(value) {
|
|
550
|
+
return this.returnNow(value);
|
|
551
|
+
}
|
|
552
|
+
parseInf() {
|
|
553
|
+
if (this.char === CHAR_n)
|
|
554
|
+
return this.next(this.parseInf2);
|
|
555
|
+
throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
|
556
|
+
}
|
|
557
|
+
parseInf2() {
|
|
558
|
+
if (this.char === CHAR_f)
|
|
559
|
+
return this.state.buf === "-" ? this.return(-1 / 0) : this.return(1 / 0);
|
|
560
|
+
throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
|
|
561
|
+
}
|
|
562
|
+
parseNan() {
|
|
563
|
+
if (this.char === CHAR_a)
|
|
564
|
+
return this.next(this.parseNan2);
|
|
565
|
+
throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
|
566
|
+
}
|
|
567
|
+
parseNan2() {
|
|
568
|
+
if (this.char === CHAR_n)
|
|
569
|
+
return this.return(NaN);
|
|
570
|
+
throw this.error(new TomlError('Unexpected character, expected "nan"'));
|
|
571
|
+
}
|
|
572
|
+
/* KEYS, barewords or basic, literal, or dotted */
|
|
573
|
+
parseKeyword() {
|
|
574
|
+
return this.char === CHAR_QUOT ? this.next(this.parseBasicString) : this.char === CHAR_APOS ? this.next(this.parseLiteralString) : this.goto(this.parseBareKey);
|
|
575
|
+
}
|
|
576
|
+
/* KEYS: barewords */
|
|
577
|
+
parseBareKey() {
|
|
578
|
+
do {
|
|
579
|
+
if (this.char === Parser.END)
|
|
580
|
+
throw this.error(new TomlError("Key ended without value"));
|
|
581
|
+
if (isAlphaNumHyphen(this.char))
|
|
582
|
+
this.consume();
|
|
583
|
+
else {
|
|
584
|
+
if (this.state.buf.length === 0)
|
|
585
|
+
throw this.error(new TomlError("Empty bare keys are not allowed"));
|
|
586
|
+
return this.returnNow();
|
|
587
|
+
}
|
|
588
|
+
} while (this.nextChar());
|
|
589
|
+
}
|
|
590
|
+
/* STRINGS, single quoted (literal) */
|
|
591
|
+
parseSingleString() {
|
|
592
|
+
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiStringMaybe) : this.goto(this.parseLiteralString);
|
|
593
|
+
}
|
|
594
|
+
parseLiteralString() {
|
|
595
|
+
do {
|
|
596
|
+
if (this.char === CHAR_APOS)
|
|
597
|
+
return this.return();
|
|
598
|
+
if (this.atEndOfLine())
|
|
599
|
+
throw this.error(new TomlError("Unterminated string"));
|
|
600
|
+
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)
|
|
601
|
+
throw this.errorControlCharInString();
|
|
602
|
+
this.consume();
|
|
603
|
+
} while (this.nextChar());
|
|
604
|
+
}
|
|
605
|
+
parseLiteralMultiStringMaybe() {
|
|
606
|
+
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiString) : this.returnNow();
|
|
607
|
+
}
|
|
608
|
+
parseLiteralMultiString() {
|
|
609
|
+
return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseLiteralMultiStringContent) : this.goto(this.parseLiteralMultiStringContent);
|
|
610
|
+
}
|
|
611
|
+
parseLiteralMultiStringContent() {
|
|
612
|
+
do {
|
|
613
|
+
if (this.char === CHAR_APOS)
|
|
614
|
+
return this.next(this.parseLiteralMultiEnd);
|
|
615
|
+
if (this.char === Parser.END)
|
|
616
|
+
throw this.error(new TomlError("Unterminated multi-line string"));
|
|
617
|
+
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)
|
|
618
|
+
throw this.errorControlCharInString();
|
|
619
|
+
this.consume();
|
|
620
|
+
} while (this.nextChar());
|
|
621
|
+
}
|
|
622
|
+
parseLiteralMultiEnd() {
|
|
623
|
+
return this.char === CHAR_APOS ? this.next(this.parseLiteralMultiEnd2) : (this.state.buf += "'", this.goto(this.parseLiteralMultiStringContent));
|
|
624
|
+
}
|
|
625
|
+
parseLiteralMultiEnd2() {
|
|
626
|
+
return this.char === CHAR_APOS ? this.return() : (this.state.buf += "''", this.goto(this.parseLiteralMultiStringContent));
|
|
627
|
+
}
|
|
628
|
+
/* STRINGS double quoted */
|
|
629
|
+
parseDoubleString() {
|
|
630
|
+
return this.char === CHAR_QUOT ? this.next(this.parseMultiStringMaybe) : this.goto(this.parseBasicString);
|
|
631
|
+
}
|
|
632
|
+
parseBasicString() {
|
|
633
|
+
do {
|
|
634
|
+
if (this.char === CHAR_BSOL)
|
|
635
|
+
return this.call(this.parseEscape, this.recordEscapeReplacement);
|
|
636
|
+
if (this.char === CHAR_QUOT)
|
|
637
|
+
return this.return();
|
|
638
|
+
if (this.atEndOfLine())
|
|
639
|
+
throw this.error(new TomlError("Unterminated string"));
|
|
640
|
+
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I)
|
|
641
|
+
throw this.errorControlCharInString();
|
|
642
|
+
this.consume();
|
|
643
|
+
} while (this.nextChar());
|
|
644
|
+
}
|
|
645
|
+
recordEscapeReplacement(replacement) {
|
|
646
|
+
return this.state.buf += replacement, this.goto(this.parseBasicString);
|
|
647
|
+
}
|
|
648
|
+
parseMultiStringMaybe() {
|
|
649
|
+
return this.char === CHAR_QUOT ? this.next(this.parseMultiString) : this.returnNow();
|
|
650
|
+
}
|
|
651
|
+
parseMultiString() {
|
|
652
|
+
return this.char === CTRL_M ? null : this.char === CTRL_J ? this.next(this.parseMultiStringContent) : this.goto(this.parseMultiStringContent);
|
|
653
|
+
}
|
|
654
|
+
parseMultiStringContent() {
|
|
655
|
+
do {
|
|
656
|
+
if (this.char === CHAR_BSOL)
|
|
657
|
+
return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
|
|
658
|
+
if (this.char === CHAR_QUOT)
|
|
659
|
+
return this.next(this.parseMultiEnd);
|
|
660
|
+
if (this.char === Parser.END)
|
|
661
|
+
throw this.error(new TomlError("Unterminated multi-line string"));
|
|
662
|
+
if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M)
|
|
663
|
+
throw this.errorControlCharInString();
|
|
664
|
+
this.consume();
|
|
665
|
+
} while (this.nextChar());
|
|
666
|
+
}
|
|
667
|
+
errorControlCharInString() {
|
|
668
|
+
let displayCode = "\\u00";
|
|
669
|
+
return this.char < 16 && (displayCode += "0"), displayCode += this.char.toString(16), this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
|
|
670
|
+
}
|
|
671
|
+
recordMultiEscapeReplacement(replacement) {
|
|
672
|
+
return this.state.buf += replacement, this.goto(this.parseMultiStringContent);
|
|
673
|
+
}
|
|
674
|
+
parseMultiEnd() {
|
|
675
|
+
return this.char === CHAR_QUOT ? this.next(this.parseMultiEnd2) : (this.state.buf += '"', this.goto(this.parseMultiStringContent));
|
|
676
|
+
}
|
|
677
|
+
parseMultiEnd2() {
|
|
678
|
+
return this.char === CHAR_QUOT ? this.return() : (this.state.buf += '""', this.goto(this.parseMultiStringContent));
|
|
679
|
+
}
|
|
680
|
+
parseMultiEscape() {
|
|
681
|
+
return this.char === CTRL_M || this.char === CTRL_J ? this.next(this.parseMultiTrim) : this.char === CHAR_SP || this.char === CTRL_I ? this.next(this.parsePreMultiTrim) : this.goto(this.parseEscape);
|
|
682
|
+
}
|
|
683
|
+
parsePreMultiTrim() {
|
|
684
|
+
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
685
|
+
return null;
|
|
686
|
+
if (this.char === CTRL_M || this.char === CTRL_J)
|
|
687
|
+
return this.next(this.parseMultiTrim);
|
|
688
|
+
throw this.error(new TomlError("Can't escape whitespace"));
|
|
689
|
+
}
|
|
690
|
+
parseMultiTrim() {
|
|
691
|
+
return this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M ? null : this.returnNow();
|
|
692
|
+
}
|
|
693
|
+
parseEscape() {
|
|
694
|
+
if (this.char in escapes)
|
|
695
|
+
return this.return(escapes[this.char]);
|
|
696
|
+
if (this.char === CHAR_u)
|
|
697
|
+
return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
|
|
698
|
+
if (this.char === CHAR_U)
|
|
699
|
+
return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
|
|
700
|
+
throw this.error(new TomlError("Unknown escape character: " + this.char));
|
|
701
|
+
}
|
|
702
|
+
parseUnicodeReturn(char) {
|
|
703
|
+
try {
|
|
704
|
+
let codePoint = parseInt(char, 16);
|
|
705
|
+
if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST)
|
|
706
|
+
throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved"));
|
|
707
|
+
return this.returnNow(String.fromCodePoint(codePoint));
|
|
708
|
+
} catch (err) {
|
|
709
|
+
throw this.error(TomlError.wrap(err));
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
parseSmallUnicode() {
|
|
713
|
+
if (isHexit(this.char)) {
|
|
714
|
+
if (this.consume(), this.state.buf.length >= 4) return this.return();
|
|
715
|
+
} else
|
|
716
|
+
throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
|
|
717
|
+
}
|
|
718
|
+
parseLargeUnicode() {
|
|
719
|
+
if (isHexit(this.char)) {
|
|
720
|
+
if (this.consume(), this.state.buf.length >= 8) return this.return();
|
|
721
|
+
} else
|
|
722
|
+
throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
|
|
723
|
+
}
|
|
724
|
+
/* NUMBERS */
|
|
725
|
+
parseNumberSign() {
|
|
726
|
+
return this.consume(), this.next(this.parseMaybeSignedInfOrNan);
|
|
727
|
+
}
|
|
728
|
+
parseMaybeSignedInfOrNan() {
|
|
729
|
+
return this.char === CHAR_i ? this.next(this.parseInf) : this.char === CHAR_n ? this.next(this.parseNan) : this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
|
|
730
|
+
}
|
|
731
|
+
parseNumberIntegerStart() {
|
|
732
|
+
return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberIntegerExponentOrDecimal)) : this.goto(this.parseNumberInteger);
|
|
733
|
+
}
|
|
734
|
+
parseNumberIntegerExponentOrDecimal() {
|
|
735
|
+
return this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Integer(this.state.buf));
|
|
736
|
+
}
|
|
737
|
+
parseNumberInteger() {
|
|
738
|
+
if (isDigit(this.char))
|
|
739
|
+
this.consume();
|
|
740
|
+
else {
|
|
741
|
+
if (this.char === CHAR_LOWBAR)
|
|
742
|
+
return this.call(this.parseNoUnder);
|
|
743
|
+
if (this.char === CHAR_E || this.char === CHAR_e)
|
|
744
|
+
return this.consume(), this.next(this.parseNumberExponentSign);
|
|
745
|
+
if (this.char === CHAR_PERIOD)
|
|
746
|
+
return this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat);
|
|
747
|
+
{
|
|
748
|
+
let result = Integer(this.state.buf);
|
|
749
|
+
if (result.isNaN())
|
|
750
|
+
throw this.error(new TomlError("Invalid number"));
|
|
751
|
+
return this.returnNow(result);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
parseNoUnder() {
|
|
756
|
+
if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e)
|
|
757
|
+
throw this.error(new TomlError("Unexpected character, expected digit"));
|
|
758
|
+
if (this.atEndOfWord())
|
|
759
|
+
throw this.error(new TomlError("Incomplete number"));
|
|
760
|
+
return this.returnNow();
|
|
761
|
+
}
|
|
762
|
+
parseNoUnderHexOctBinLiteral() {
|
|
763
|
+
if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD)
|
|
764
|
+
throw this.error(new TomlError("Unexpected character, expected digit"));
|
|
765
|
+
if (this.atEndOfWord())
|
|
766
|
+
throw this.error(new TomlError("Incomplete number"));
|
|
767
|
+
return this.returnNow();
|
|
768
|
+
}
|
|
769
|
+
parseNumberFloat() {
|
|
770
|
+
if (this.char === CHAR_LOWBAR)
|
|
771
|
+
return this.call(this.parseNoUnder, this.parseNumberFloat);
|
|
772
|
+
if (isDigit(this.char))
|
|
773
|
+
this.consume();
|
|
774
|
+
else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.returnNow(Float(this.state.buf));
|
|
775
|
+
}
|
|
776
|
+
parseNumberExponentSign() {
|
|
777
|
+
if (isDigit(this.char))
|
|
778
|
+
return this.goto(this.parseNumberExponent);
|
|
779
|
+
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
780
|
+
this.consume(), this.call(this.parseNoUnder, this.parseNumberExponent);
|
|
781
|
+
else
|
|
782
|
+
throw this.error(new TomlError("Unexpected character, expected -, + or digit"));
|
|
783
|
+
}
|
|
784
|
+
parseNumberExponent() {
|
|
785
|
+
if (isDigit(this.char))
|
|
786
|
+
this.consume();
|
|
787
|
+
else return this.char === CHAR_LOWBAR ? this.call(this.parseNoUnder) : this.returnNow(Float(this.state.buf));
|
|
788
|
+
}
|
|
789
|
+
/* NUMBERS or DATETIMES */
|
|
790
|
+
parseNumberOrDateTime() {
|
|
791
|
+
return this.char === CHAR_0 ? (this.consume(), this.next(this.parseNumberBaseOrDateTime)) : this.goto(this.parseNumberOrDateTimeOnly);
|
|
792
|
+
}
|
|
793
|
+
parseNumberOrDateTimeOnly() {
|
|
794
|
+
if (this.char === CHAR_LOWBAR)
|
|
795
|
+
return this.call(this.parseNoUnder, this.parseNumberInteger);
|
|
796
|
+
if (isDigit(this.char))
|
|
797
|
+
this.consume(), this.state.buf.length > 4 && this.next(this.parseNumberInteger);
|
|
798
|
+
else return this.char === CHAR_E || this.char === CHAR_e ? (this.consume(), this.next(this.parseNumberExponentSign)) : this.char === CHAR_PERIOD ? (this.consume(), this.call(this.parseNoUnder, this.parseNumberFloat)) : this.char === CHAR_HYPHEN ? this.goto(this.parseDateTime) : this.char === CHAR_COLON ? this.goto(this.parseOnlyTimeHour) : this.returnNow(Integer(this.state.buf));
|
|
799
|
+
}
|
|
800
|
+
parseDateTimeOnly() {
|
|
801
|
+
if (this.state.buf.length < 4) {
|
|
802
|
+
if (isDigit(this.char))
|
|
803
|
+
return this.consume();
|
|
804
|
+
if (this.char === CHAR_COLON)
|
|
805
|
+
return this.goto(this.parseOnlyTimeHour);
|
|
806
|
+
throw this.error(new TomlError("Expected digit while parsing year part of a date"));
|
|
807
|
+
} else {
|
|
808
|
+
if (this.char === CHAR_HYPHEN)
|
|
809
|
+
return this.goto(this.parseDateTime);
|
|
810
|
+
throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date"));
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
parseNumberBaseOrDateTime() {
|
|
814
|
+
return this.char === CHAR_b ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin)) : this.char === CHAR_o ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct)) : this.char === CHAR_x ? (this.consume(), this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex)) : this.char === CHAR_PERIOD ? this.goto(this.parseNumberInteger) : isDigit(this.char) ? this.goto(this.parseDateTimeOnly) : this.returnNow(Integer(this.state.buf));
|
|
815
|
+
}
|
|
816
|
+
parseIntegerHex() {
|
|
817
|
+
if (isHexit(this.char))
|
|
818
|
+
this.consume();
|
|
819
|
+
else {
|
|
820
|
+
if (this.char === CHAR_LOWBAR)
|
|
821
|
+
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
822
|
+
{
|
|
823
|
+
let result = Integer(this.state.buf);
|
|
824
|
+
if (result.isNaN())
|
|
825
|
+
throw this.error(new TomlError("Invalid number"));
|
|
826
|
+
return this.returnNow(result);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
parseIntegerOct() {
|
|
831
|
+
if (isOctit(this.char))
|
|
832
|
+
this.consume();
|
|
833
|
+
else {
|
|
834
|
+
if (this.char === CHAR_LOWBAR)
|
|
835
|
+
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
836
|
+
{
|
|
837
|
+
let result = Integer(this.state.buf);
|
|
838
|
+
if (result.isNaN())
|
|
839
|
+
throw this.error(new TomlError("Invalid number"));
|
|
840
|
+
return this.returnNow(result);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
parseIntegerBin() {
|
|
845
|
+
if (isBit(this.char))
|
|
846
|
+
this.consume();
|
|
847
|
+
else {
|
|
848
|
+
if (this.char === CHAR_LOWBAR)
|
|
849
|
+
return this.call(this.parseNoUnderHexOctBinLiteral);
|
|
850
|
+
{
|
|
851
|
+
let result = Integer(this.state.buf);
|
|
852
|
+
if (result.isNaN())
|
|
853
|
+
throw this.error(new TomlError("Invalid number"));
|
|
854
|
+
return this.returnNow(result);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
/* DATETIME */
|
|
859
|
+
parseDateTime() {
|
|
860
|
+
if (this.state.buf.length < 4)
|
|
861
|
+
throw this.error(new TomlError("Years less than 1000 must be zero padded to four characters"));
|
|
862
|
+
return this.state.result = this.state.buf, this.state.buf = "", this.next(this.parseDateMonth);
|
|
863
|
+
}
|
|
864
|
+
parseDateMonth() {
|
|
865
|
+
if (this.char === CHAR_HYPHEN) {
|
|
866
|
+
if (this.state.buf.length < 2)
|
|
867
|
+
throw this.error(new TomlError("Months less than 10 must be zero padded to two characters"));
|
|
868
|
+
return this.state.result += "-" + this.state.buf, this.state.buf = "", this.next(this.parseDateDay);
|
|
869
|
+
} else if (isDigit(this.char))
|
|
870
|
+
this.consume();
|
|
871
|
+
else
|
|
872
|
+
throw this.error(new TomlError("Incomplete datetime"));
|
|
873
|
+
}
|
|
874
|
+
parseDateDay() {
|
|
875
|
+
if (this.char === CHAR_T || this.char === CHAR_SP) {
|
|
876
|
+
if (this.state.buf.length < 2)
|
|
877
|
+
throw this.error(new TomlError("Days less than 10 must be zero padded to two characters"));
|
|
878
|
+
return this.state.result += "-" + this.state.buf, this.state.buf = "", this.next(this.parseStartTimeHour);
|
|
879
|
+
} else {
|
|
880
|
+
if (this.atEndOfWord())
|
|
881
|
+
return this.returnNow(createDate(this.state.result + "-" + this.state.buf));
|
|
882
|
+
if (isDigit(this.char))
|
|
883
|
+
this.consume();
|
|
884
|
+
else
|
|
885
|
+
throw this.error(new TomlError("Incomplete datetime"));
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
parseStartTimeHour() {
|
|
889
|
+
return this.atEndOfWord() ? this.returnNow(createDate(this.state.result)) : this.goto(this.parseTimeHour);
|
|
890
|
+
}
|
|
891
|
+
parseTimeHour() {
|
|
892
|
+
if (this.char === CHAR_COLON) {
|
|
893
|
+
if (this.state.buf.length < 2)
|
|
894
|
+
throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
|
|
895
|
+
return this.state.result += "T" + this.state.buf, this.state.buf = "", this.next(this.parseTimeMin);
|
|
896
|
+
} else if (isDigit(this.char))
|
|
897
|
+
this.consume();
|
|
898
|
+
else
|
|
899
|
+
throw this.error(new TomlError("Incomplete datetime"));
|
|
900
|
+
}
|
|
901
|
+
parseTimeMin() {
|
|
902
|
+
if (this.state.buf.length < 2 && isDigit(this.char))
|
|
903
|
+
this.consume();
|
|
904
|
+
else {
|
|
905
|
+
if (this.state.buf.length === 2 && this.char === CHAR_COLON)
|
|
906
|
+
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseTimeSec);
|
|
907
|
+
throw this.error(new TomlError("Incomplete datetime"));
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
parseTimeSec() {
|
|
911
|
+
if (isDigit(this.char)) {
|
|
912
|
+
if (this.consume(), this.state.buf.length === 2)
|
|
913
|
+
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseTimeZoneOrFraction);
|
|
914
|
+
} else
|
|
915
|
+
throw this.error(new TomlError("Incomplete datetime"));
|
|
916
|
+
}
|
|
917
|
+
parseOnlyTimeHour() {
|
|
918
|
+
if (this.char === CHAR_COLON) {
|
|
919
|
+
if (this.state.buf.length < 2)
|
|
920
|
+
throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
|
|
921
|
+
return this.state.result = this.state.buf, this.state.buf = "", this.next(this.parseOnlyTimeMin);
|
|
922
|
+
} else
|
|
923
|
+
throw this.error(new TomlError("Incomplete time"));
|
|
924
|
+
}
|
|
925
|
+
parseOnlyTimeMin() {
|
|
926
|
+
if (this.state.buf.length < 2 && isDigit(this.char))
|
|
927
|
+
this.consume();
|
|
928
|
+
else {
|
|
929
|
+
if (this.state.buf.length === 2 && this.char === CHAR_COLON)
|
|
930
|
+
return this.state.result += ":" + this.state.buf, this.state.buf = "", this.next(this.parseOnlyTimeSec);
|
|
931
|
+
throw this.error(new TomlError("Incomplete time"));
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
parseOnlyTimeSec() {
|
|
935
|
+
if (isDigit(this.char)) {
|
|
936
|
+
if (this.consume(), this.state.buf.length === 2)
|
|
937
|
+
return this.next(this.parseOnlyTimeFractionMaybe);
|
|
938
|
+
} else
|
|
939
|
+
throw this.error(new TomlError("Incomplete time"));
|
|
940
|
+
}
|
|
941
|
+
parseOnlyTimeFractionMaybe() {
|
|
942
|
+
if (this.state.result += ":" + this.state.buf, this.char === CHAR_PERIOD)
|
|
943
|
+
this.state.buf = "", this.next(this.parseOnlyTimeFraction);
|
|
944
|
+
else
|
|
945
|
+
return this.return(createTime(this.state.result));
|
|
946
|
+
}
|
|
947
|
+
parseOnlyTimeFraction() {
|
|
948
|
+
if (isDigit(this.char))
|
|
949
|
+
this.consume();
|
|
950
|
+
else if (this.atEndOfWord()) {
|
|
951
|
+
if (this.state.buf.length === 0) throw this.error(new TomlError("Expected digit in milliseconds"));
|
|
952
|
+
return this.returnNow(createTime(this.state.result + "." + this.state.buf));
|
|
953
|
+
} else
|
|
954
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
955
|
+
}
|
|
956
|
+
parseTimeZoneOrFraction() {
|
|
957
|
+
if (this.char === CHAR_PERIOD)
|
|
958
|
+
this.consume(), this.next(this.parseDateTimeFraction);
|
|
959
|
+
else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
960
|
+
this.consume(), this.next(this.parseTimeZoneHour);
|
|
961
|
+
else {
|
|
962
|
+
if (this.char === CHAR_Z)
|
|
963
|
+
return this.consume(), this.return(createDateTime(this.state.result + this.state.buf));
|
|
964
|
+
if (this.atEndOfWord())
|
|
965
|
+
return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
|
|
966
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
parseDateTimeFraction() {
|
|
970
|
+
if (isDigit(this.char))
|
|
971
|
+
this.consume();
|
|
972
|
+
else {
|
|
973
|
+
if (this.state.buf.length === 1)
|
|
974
|
+
throw this.error(new TomlError("Expected digit in milliseconds"));
|
|
975
|
+
if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS)
|
|
976
|
+
this.consume(), this.next(this.parseTimeZoneHour);
|
|
977
|
+
else {
|
|
978
|
+
if (this.char === CHAR_Z)
|
|
979
|
+
return this.consume(), this.return(createDateTime(this.state.result + this.state.buf));
|
|
980
|
+
if (this.atEndOfWord())
|
|
981
|
+
return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
|
|
982
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
parseTimeZoneHour() {
|
|
987
|
+
if (isDigit(this.char)) {
|
|
988
|
+
if (this.consume(), /\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
|
|
989
|
+
} else
|
|
990
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
|
|
991
|
+
}
|
|
992
|
+
parseTimeZoneSep() {
|
|
993
|
+
if (this.char === CHAR_COLON)
|
|
994
|
+
this.consume(), this.next(this.parseTimeZoneMin);
|
|
995
|
+
else
|
|
996
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected colon"));
|
|
997
|
+
}
|
|
998
|
+
parseTimeZoneMin() {
|
|
999
|
+
if (isDigit(this.char)) {
|
|
1000
|
+
if (this.consume(), /\d\d$/.test(this.state.buf)) return this.return(createDateTime(this.state.result + this.state.buf));
|
|
1001
|
+
} else
|
|
1002
|
+
throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
|
|
1003
|
+
}
|
|
1004
|
+
/* BOOLEAN */
|
|
1005
|
+
parseBoolean() {
|
|
1006
|
+
if (this.char === CHAR_t)
|
|
1007
|
+
return this.consume(), this.next(this.parseTrue_r);
|
|
1008
|
+
if (this.char === CHAR_f)
|
|
1009
|
+
return this.consume(), this.next(this.parseFalse_a);
|
|
1010
|
+
}
|
|
1011
|
+
parseTrue_r() {
|
|
1012
|
+
if (this.char === CHAR_r)
|
|
1013
|
+
return this.consume(), this.next(this.parseTrue_u);
|
|
1014
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1015
|
+
}
|
|
1016
|
+
parseTrue_u() {
|
|
1017
|
+
if (this.char === CHAR_u)
|
|
1018
|
+
return this.consume(), this.next(this.parseTrue_e);
|
|
1019
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1020
|
+
}
|
|
1021
|
+
parseTrue_e() {
|
|
1022
|
+
if (this.char === CHAR_e)
|
|
1023
|
+
return this.return(!0);
|
|
1024
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1025
|
+
}
|
|
1026
|
+
parseFalse_a() {
|
|
1027
|
+
if (this.char === CHAR_a)
|
|
1028
|
+
return this.consume(), this.next(this.parseFalse_l);
|
|
1029
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1030
|
+
}
|
|
1031
|
+
parseFalse_l() {
|
|
1032
|
+
if (this.char === CHAR_l)
|
|
1033
|
+
return this.consume(), this.next(this.parseFalse_s);
|
|
1034
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1035
|
+
}
|
|
1036
|
+
parseFalse_s() {
|
|
1037
|
+
if (this.char === CHAR_s)
|
|
1038
|
+
return this.consume(), this.next(this.parseFalse_e);
|
|
1039
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1040
|
+
}
|
|
1041
|
+
parseFalse_e() {
|
|
1042
|
+
if (this.char === CHAR_e)
|
|
1043
|
+
return this.return(!1);
|
|
1044
|
+
throw this.error(new TomlError("Invalid boolean, expected true or false"));
|
|
1045
|
+
}
|
|
1046
|
+
/* INLINE LISTS */
|
|
1047
|
+
parseInlineList() {
|
|
1048
|
+
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J)
|
|
1049
|
+
return null;
|
|
1050
|
+
if (this.char === Parser.END)
|
|
1051
|
+
throw this.error(new TomlError("Unterminated inline array"));
|
|
1052
|
+
return this.char === CHAR_NUM ? this.call(this.parseComment) : this.char === CHAR_RSQB ? this.return(this.state.resultArr || InlineList()) : this.callNow(this.parseValue, this.recordInlineListValue);
|
|
1053
|
+
}
|
|
1054
|
+
recordInlineListValue(value) {
|
|
1055
|
+
if (this.state.resultArr) {
|
|
1056
|
+
let listType = this.state.resultArr[_contentType], valueType = tomlType(value);
|
|
1057
|
+
if (listType !== valueType)
|
|
1058
|
+
throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
|
|
1059
|
+
} else
|
|
1060
|
+
this.state.resultArr = InlineList(tomlType(value));
|
|
1061
|
+
return isFloat(value) || isInteger(value) ? this.state.resultArr.push(value.valueOf()) : this.state.resultArr.push(value), this.goto(this.parseInlineListNext);
|
|
1062
|
+
}
|
|
1063
|
+
parseInlineListNext() {
|
|
1064
|
+
if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J)
|
|
1065
|
+
return null;
|
|
1066
|
+
if (this.char === CHAR_NUM)
|
|
1067
|
+
return this.call(this.parseComment);
|
|
1068
|
+
if (this.char === CHAR_COMMA)
|
|
1069
|
+
return this.next(this.parseInlineList);
|
|
1070
|
+
if (this.char === CHAR_RSQB)
|
|
1071
|
+
return this.goto(this.parseInlineList);
|
|
1072
|
+
throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
|
|
1073
|
+
}
|
|
1074
|
+
/* INLINE TABLE */
|
|
1075
|
+
parseInlineTable() {
|
|
1076
|
+
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
1077
|
+
return null;
|
|
1078
|
+
if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M)
|
|
1079
|
+
throw this.error(new TomlError("Unterminated inline array"));
|
|
1080
|
+
return this.char === CHAR_RCUB ? this.return(this.state.resultTable || InlineTable()) : (this.state.resultTable || (this.state.resultTable = InlineTable()), this.callNow(this.parseAssign, this.recordInlineTableValue));
|
|
1081
|
+
}
|
|
1082
|
+
recordInlineTableValue(kv) {
|
|
1083
|
+
let target = this.state.resultTable, finalKey = kv.key.pop();
|
|
1084
|
+
for (let kw of kv.key) {
|
|
1085
|
+
if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared]))
|
|
1086
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
1087
|
+
target = target[kw] = target[kw] || Table();
|
|
1088
|
+
}
|
|
1089
|
+
if (hasKey(target, finalKey))
|
|
1090
|
+
throw this.error(new TomlError("Can't redefine existing key"));
|
|
1091
|
+
return isInteger(kv.value) || isFloat(kv.value) ? target[finalKey] = kv.value.valueOf() : target[finalKey] = kv.value, this.goto(this.parseInlineTableNext);
|
|
1092
|
+
}
|
|
1093
|
+
parseInlineTableNext() {
|
|
1094
|
+
if (this.char === CHAR_SP || this.char === CTRL_I)
|
|
1095
|
+
return null;
|
|
1096
|
+
if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M)
|
|
1097
|
+
throw this.error(new TomlError("Unterminated inline array"));
|
|
1098
|
+
if (this.char === CHAR_COMMA)
|
|
1099
|
+
return this.next(this.parseInlineTable);
|
|
1100
|
+
if (this.char === CHAR_RCUB)
|
|
1101
|
+
return this.goto(this.parseInlineTable);
|
|
1102
|
+
throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return TOMLParser;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js
|
|
1111
|
+
var require_parse_pretty_error = __commonJS({
|
|
1112
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) {
|
|
1113
|
+
"use strict";
|
|
1114
|
+
init_cjs_shims();
|
|
1115
|
+
module2.exports = prettyError;
|
|
1116
|
+
function prettyError(err, buf) {
|
|
1117
|
+
if (err.pos == null || err.line == null) return err;
|
|
1118
|
+
let msg = err.message;
|
|
1119
|
+
if (msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:
|
|
1120
|
+
`, buf && buf.split) {
|
|
1121
|
+
let lines = buf.split(/\n/), lineNumWidth = String(Math.min(lines.length, err.line + 3)).length, linePadding = " ";
|
|
1122
|
+
for (; linePadding.length < lineNumWidth; ) linePadding += " ";
|
|
1123
|
+
for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
|
|
1124
|
+
let lineNum = String(ii + 1);
|
|
1125
|
+
if (lineNum.length < lineNumWidth && (lineNum = " " + lineNum), err.line === ii) {
|
|
1126
|
+
msg += lineNum + "> " + lines[ii] + `
|
|
1127
|
+
`, msg += linePadding + " ";
|
|
1128
|
+
for (let hh = 0; hh < err.col; ++hh)
|
|
1129
|
+
msg += " ";
|
|
1130
|
+
msg += `^
|
|
1131
|
+
`;
|
|
1132
|
+
} else
|
|
1133
|
+
msg += lineNum + ": " + lines[ii] + `
|
|
1134
|
+
`;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return err.message = msg + `
|
|
1138
|
+
`, err;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js
|
|
1144
|
+
var require_parse_string = __commonJS({
|
|
1145
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) {
|
|
1146
|
+
"use strict";
|
|
1147
|
+
init_cjs_shims();
|
|
1148
|
+
module2.exports = parseString;
|
|
1149
|
+
var TOMLParser = require_toml_parser(), prettyError = require_parse_pretty_error();
|
|
1150
|
+
function parseString(str) {
|
|
1151
|
+
global.Buffer && global.Buffer.isBuffer(str) && (str = str.toString("utf8"));
|
|
1152
|
+
let parser = new TOMLParser();
|
|
1153
|
+
try {
|
|
1154
|
+
return parser.parse(str), parser.finish();
|
|
1155
|
+
} catch (err) {
|
|
1156
|
+
throw prettyError(err, str);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js
|
|
1163
|
+
var require_parse_async = __commonJS({
|
|
1164
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) {
|
|
1165
|
+
"use strict";
|
|
1166
|
+
init_cjs_shims();
|
|
1167
|
+
module2.exports = parseAsync;
|
|
1168
|
+
var TOMLParser = require_toml_parser(), prettyError = require_parse_pretty_error();
|
|
1169
|
+
function parseAsync(str, opts) {
|
|
1170
|
+
opts || (opts = {});
|
|
1171
|
+
let index = 0, blocksize = opts.blocksize || 40960, parser = new TOMLParser();
|
|
1172
|
+
return new Promise((resolve, reject) => {
|
|
1173
|
+
setImmediate(parseAsyncNext, index, blocksize, resolve, reject);
|
|
1174
|
+
});
|
|
1175
|
+
function parseAsyncNext(index2, blocksize2, resolve, reject) {
|
|
1176
|
+
if (index2 >= str.length)
|
|
1177
|
+
try {
|
|
1178
|
+
return resolve(parser.finish());
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
return reject(prettyError(err, str));
|
|
1181
|
+
}
|
|
1182
|
+
try {
|
|
1183
|
+
parser.parse(str.slice(index2, index2 + blocksize2)), setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve, reject);
|
|
1184
|
+
} catch (err) {
|
|
1185
|
+
reject(prettyError(err, str));
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
|
|
1192
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js
|
|
1193
|
+
var require_parse_stream = __commonJS({
|
|
1194
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) {
|
|
1195
|
+
"use strict";
|
|
1196
|
+
init_cjs_shims();
|
|
1197
|
+
module2.exports = parseStream;
|
|
1198
|
+
var stream = __require("stream"), TOMLParser = require_toml_parser();
|
|
1199
|
+
function parseStream(stm) {
|
|
1200
|
+
return stm ? parseReadable(stm) : parseTransform(stm);
|
|
1201
|
+
}
|
|
1202
|
+
function parseReadable(stm) {
|
|
1203
|
+
let parser = new TOMLParser();
|
|
1204
|
+
return stm.setEncoding("utf8"), new Promise((resolve, reject) => {
|
|
1205
|
+
let readable, ended = !1, errored = !1;
|
|
1206
|
+
function finish() {
|
|
1207
|
+
if (ended = !0, !readable)
|
|
1208
|
+
try {
|
|
1209
|
+
resolve(parser.finish());
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
reject(err);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function error(err) {
|
|
1215
|
+
errored = !0, reject(err);
|
|
1216
|
+
}
|
|
1217
|
+
stm.once("end", finish), stm.once("error", error), readNext();
|
|
1218
|
+
function readNext() {
|
|
1219
|
+
readable = !0;
|
|
1220
|
+
let data;
|
|
1221
|
+
for (; (data = stm.read()) !== null; )
|
|
1222
|
+
try {
|
|
1223
|
+
parser.parse(data);
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
return error(err);
|
|
1226
|
+
}
|
|
1227
|
+
if (readable = !1, ended) return finish();
|
|
1228
|
+
errored || stm.once("readable", readNext);
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
function parseTransform() {
|
|
1233
|
+
let parser = new TOMLParser();
|
|
1234
|
+
return new stream.Transform({
|
|
1235
|
+
objectMode: !0,
|
|
1236
|
+
transform(chunk, encoding, cb) {
|
|
1237
|
+
try {
|
|
1238
|
+
parser.parse(chunk.toString(encoding));
|
|
1239
|
+
} catch (err) {
|
|
1240
|
+
this.emit("error", err);
|
|
1241
|
+
}
|
|
1242
|
+
cb();
|
|
1243
|
+
},
|
|
1244
|
+
flush(cb) {
|
|
1245
|
+
try {
|
|
1246
|
+
this.push(parser.finish());
|
|
1247
|
+
} catch (err) {
|
|
1248
|
+
this.emit("error", err);
|
|
1249
|
+
}
|
|
1250
|
+
cb();
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js
|
|
1258
|
+
var require_parse = __commonJS({
|
|
1259
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) {
|
|
1260
|
+
"use strict";
|
|
1261
|
+
init_cjs_shims();
|
|
1262
|
+
module2.exports = require_parse_string();
|
|
1263
|
+
module2.exports.async = require_parse_async();
|
|
1264
|
+
module2.exports.stream = require_parse_stream();
|
|
1265
|
+
module2.exports.prettyError = require_parse_pretty_error();
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js
|
|
1270
|
+
var require_stringify = __commonJS({
|
|
1271
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) {
|
|
1272
|
+
"use strict";
|
|
1273
|
+
init_cjs_shims();
|
|
1274
|
+
module2.exports = stringify2;
|
|
1275
|
+
module2.exports.value = stringifyInline;
|
|
1276
|
+
function stringify2(obj) {
|
|
1277
|
+
if (obj === null) throw typeError("null");
|
|
1278
|
+
if (obj === void 0) throw typeError("undefined");
|
|
1279
|
+
if (typeof obj != "object") throw typeError(typeof obj);
|
|
1280
|
+
if (typeof obj.toJSON == "function" && (obj = obj.toJSON()), obj == null) return null;
|
|
1281
|
+
let type = tomlType2(obj);
|
|
1282
|
+
if (type !== "table") throw typeError(type);
|
|
1283
|
+
return stringifyObject("", "", obj);
|
|
1284
|
+
}
|
|
1285
|
+
function typeError(type) {
|
|
1286
|
+
return new Error("Can only stringify objects, not " + type);
|
|
1287
|
+
}
|
|
1288
|
+
function arrayOneTypeError() {
|
|
1289
|
+
return new Error("Array values can't have mixed types");
|
|
1290
|
+
}
|
|
1291
|
+
function getInlineKeys(obj) {
|
|
1292
|
+
return Object.keys(obj).filter((key) => isInline(obj[key]));
|
|
1293
|
+
}
|
|
1294
|
+
function getComplexKeys(obj) {
|
|
1295
|
+
return Object.keys(obj).filter((key) => !isInline(obj[key]));
|
|
1296
|
+
}
|
|
1297
|
+
function toJSON(obj) {
|
|
1298
|
+
let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, "__proto__") ? { ["__proto__"]: void 0 } : {};
|
|
1299
|
+
for (let prop of Object.keys(obj))
|
|
1300
|
+
obj[prop] && typeof obj[prop].toJSON == "function" && !("toISOString" in obj[prop]) ? nobj[prop] = obj[prop].toJSON() : nobj[prop] = obj[prop];
|
|
1301
|
+
return nobj;
|
|
1302
|
+
}
|
|
1303
|
+
function stringifyObject(prefix, indent, obj) {
|
|
1304
|
+
obj = toJSON(obj);
|
|
1305
|
+
var inlineKeys, complexKeys;
|
|
1306
|
+
inlineKeys = getInlineKeys(obj), complexKeys = getComplexKeys(obj);
|
|
1307
|
+
var result = [], inlineIndent = indent || "";
|
|
1308
|
+
inlineKeys.forEach((key) => {
|
|
1309
|
+
var type = tomlType2(obj[key]);
|
|
1310
|
+
type !== "undefined" && type !== "null" && result.push(inlineIndent + stringifyKey(key) + " = " + stringifyAnyInline(obj[key], !0));
|
|
1311
|
+
}), result.length > 0 && result.push("");
|
|
1312
|
+
var complexIndent = prefix && inlineKeys.length > 0 ? indent + " " : "";
|
|
1313
|
+
return complexKeys.forEach((key) => {
|
|
1314
|
+
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]));
|
|
1315
|
+
}), result.join(`
|
|
1316
|
+
`);
|
|
1317
|
+
}
|
|
1318
|
+
function isInline(value) {
|
|
1319
|
+
switch (tomlType2(value)) {
|
|
1320
|
+
case "undefined":
|
|
1321
|
+
case "null":
|
|
1322
|
+
case "integer":
|
|
1323
|
+
case "nan":
|
|
1324
|
+
case "float":
|
|
1325
|
+
case "boolean":
|
|
1326
|
+
case "string":
|
|
1327
|
+
case "datetime":
|
|
1328
|
+
return !0;
|
|
1329
|
+
case "array":
|
|
1330
|
+
return value.length === 0 || tomlType2(value[0]) !== "table";
|
|
1331
|
+
case "table":
|
|
1332
|
+
return Object.keys(value).length === 0;
|
|
1333
|
+
/* istanbul ignore next */
|
|
1334
|
+
default:
|
|
1335
|
+
return !1;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
function tomlType2(value) {
|
|
1339
|
+
return value === void 0 ? "undefined" : value === null ? "null" : typeof value == "bigint" || Number.isInteger(value) && !Object.is(value, -0) ? "integer" : typeof value == "number" ? "float" : typeof value == "boolean" ? "boolean" : typeof value == "string" ? "string" : "toISOString" in value ? isNaN(value) ? "undefined" : "datetime" : Array.isArray(value) ? "array" : "table";
|
|
1340
|
+
}
|
|
1341
|
+
function stringifyKey(key) {
|
|
1342
|
+
var keyStr = String(key);
|
|
1343
|
+
return /^[-A-Za-z0-9_]+$/.test(keyStr) ? keyStr : stringifyBasicString(keyStr);
|
|
1344
|
+
}
|
|
1345
|
+
function stringifyBasicString(str) {
|
|
1346
|
+
return '"' + escapeString(str).replace(/"/g, '\\"') + '"';
|
|
1347
|
+
}
|
|
1348
|
+
function stringifyLiteralString(str) {
|
|
1349
|
+
return "'" + str + "'";
|
|
1350
|
+
}
|
|
1351
|
+
function numpad(num, str) {
|
|
1352
|
+
for (; str.length < num; ) str = "0" + str;
|
|
1353
|
+
return str;
|
|
1354
|
+
}
|
|
1355
|
+
function escapeString(str) {
|
|
1356
|
+
return str.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/([\u0000-\u001f\u007f])/, (c) => "\\u" + numpad(4, c.codePointAt(0).toString(16)));
|
|
1357
|
+
}
|
|
1358
|
+
function stringifyMultilineString(str) {
|
|
1359
|
+
let escaped = str.split(/\n/).map((str2) => escapeString(str2).replace(/"(?="")/g, '\\"')).join(`
|
|
1360
|
+
`);
|
|
1361
|
+
return escaped.slice(-1) === '"' && (escaped += `\\
|
|
1362
|
+
`), `"""
|
|
1363
|
+
` + escaped + '"""';
|
|
1364
|
+
}
|
|
1365
|
+
function stringifyAnyInline(value, multilineOk) {
|
|
1366
|
+
let type = tomlType2(value);
|
|
1367
|
+
return type === "string" && (multilineOk && /\n/.test(value) ? type = "string-multiline" : !/[\b\t\n\f\r']/.test(value) && /"/.test(value) && (type = "string-literal")), stringifyInline(value, type);
|
|
1368
|
+
}
|
|
1369
|
+
function stringifyInline(value, type) {
|
|
1370
|
+
switch (type || (type = tomlType2(value)), type) {
|
|
1371
|
+
case "string-multiline":
|
|
1372
|
+
return stringifyMultilineString(value);
|
|
1373
|
+
case "string":
|
|
1374
|
+
return stringifyBasicString(value);
|
|
1375
|
+
case "string-literal":
|
|
1376
|
+
return stringifyLiteralString(value);
|
|
1377
|
+
case "integer":
|
|
1378
|
+
return stringifyInteger(value);
|
|
1379
|
+
case "float":
|
|
1380
|
+
return stringifyFloat(value);
|
|
1381
|
+
case "boolean":
|
|
1382
|
+
return stringifyBoolean(value);
|
|
1383
|
+
case "datetime":
|
|
1384
|
+
return stringifyDatetime(value);
|
|
1385
|
+
case "array":
|
|
1386
|
+
return stringifyInlineArray(value.filter((_) => tomlType2(_) !== "null" && tomlType2(_) !== "undefined" && tomlType2(_) !== "nan"));
|
|
1387
|
+
case "table":
|
|
1388
|
+
return stringifyInlineTable(value);
|
|
1389
|
+
/* istanbul ignore next */
|
|
1390
|
+
default:
|
|
1391
|
+
throw typeError(type);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function stringifyInteger(value) {
|
|
1395
|
+
return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, "_");
|
|
1396
|
+
}
|
|
1397
|
+
function stringifyFloat(value) {
|
|
1398
|
+
if (value === 1 / 0)
|
|
1399
|
+
return "inf";
|
|
1400
|
+
if (value === -1 / 0)
|
|
1401
|
+
return "-inf";
|
|
1402
|
+
if (Object.is(value, NaN))
|
|
1403
|
+
return "nan";
|
|
1404
|
+
if (Object.is(value, -0))
|
|
1405
|
+
return "-0.0";
|
|
1406
|
+
var chunks = String(value).split("."), int = chunks[0], dec = chunks[1] || 0;
|
|
1407
|
+
return stringifyInteger(int) + "." + dec;
|
|
1408
|
+
}
|
|
1409
|
+
function stringifyBoolean(value) {
|
|
1410
|
+
return String(value);
|
|
1411
|
+
}
|
|
1412
|
+
function stringifyDatetime(value) {
|
|
1413
|
+
return value.toISOString();
|
|
1414
|
+
}
|
|
1415
|
+
function isNumber(type) {
|
|
1416
|
+
return type === "float" || type === "integer";
|
|
1417
|
+
}
|
|
1418
|
+
function arrayType(values) {
|
|
1419
|
+
var contentType = tomlType2(values[0]);
|
|
1420
|
+
return values.every((_) => tomlType2(_) === contentType) ? contentType : values.every((_) => isNumber(tomlType2(_))) ? "float" : "mixed";
|
|
1421
|
+
}
|
|
1422
|
+
function validateArray(values) {
|
|
1423
|
+
let type = arrayType(values);
|
|
1424
|
+
if (type === "mixed")
|
|
1425
|
+
throw arrayOneTypeError();
|
|
1426
|
+
return type;
|
|
1427
|
+
}
|
|
1428
|
+
function stringifyInlineArray(values) {
|
|
1429
|
+
values = toJSON(values);
|
|
1430
|
+
let type = validateArray(values);
|
|
1431
|
+
var result = "[", stringified = values.map((_) => stringifyInline(_, type));
|
|
1432
|
+
return stringified.join(", ").length > 60 || /\n/.test(stringified) ? result += `
|
|
1433
|
+
` + stringified.join(`,
|
|
1434
|
+
`) + `
|
|
1435
|
+
` : result += " " + stringified.join(", ") + (stringified.length > 0 ? " " : ""), result + "]";
|
|
1436
|
+
}
|
|
1437
|
+
function stringifyInlineTable(value) {
|
|
1438
|
+
value = toJSON(value);
|
|
1439
|
+
var result = [];
|
|
1440
|
+
return Object.keys(value).forEach((key) => {
|
|
1441
|
+
result.push(stringifyKey(key) + " = " + stringifyAnyInline(value[key], !1));
|
|
1442
|
+
}), "{ " + result.join(", ") + (result.length > 0 ? " " : "") + "}";
|
|
1443
|
+
}
|
|
1444
|
+
function stringifyComplex(prefix, indent, key, value) {
|
|
1445
|
+
var valueType = tomlType2(value);
|
|
1446
|
+
if (valueType === "array")
|
|
1447
|
+
return stringifyArrayOfTables(prefix, indent, key, value);
|
|
1448
|
+
if (valueType === "table")
|
|
1449
|
+
return stringifyComplexTable(prefix, indent, key, value);
|
|
1450
|
+
throw typeError(valueType);
|
|
1451
|
+
}
|
|
1452
|
+
function stringifyArrayOfTables(prefix, indent, key, values) {
|
|
1453
|
+
values = toJSON(values), validateArray(values);
|
|
1454
|
+
var firstValueType = tomlType2(values[0]);
|
|
1455
|
+
if (firstValueType !== "table") throw typeError(firstValueType);
|
|
1456
|
+
var fullKey = prefix + stringifyKey(key), result = "";
|
|
1457
|
+
return values.forEach((table) => {
|
|
1458
|
+
result.length > 0 && (result += `
|
|
1459
|
+
`), result += indent + "[[" + fullKey + `]]
|
|
1460
|
+
`, result += stringifyObject(fullKey + ".", indent, table);
|
|
1461
|
+
}), result;
|
|
1462
|
+
}
|
|
1463
|
+
function stringifyComplexTable(prefix, indent, key, value) {
|
|
1464
|
+
var fullKey = prefix + stringifyKey(key), result = "";
|
|
1465
|
+
return getInlineKeys(value).length > 0 && (result += indent + "[" + fullKey + `]
|
|
1466
|
+
`), result + stringifyObject(fullKey + ".", indent, value);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1471
|
+
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js
|
|
1472
|
+
var require_toml = __commonJS({
|
|
1473
|
+
"../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) {
|
|
1474
|
+
"use strict";
|
|
1475
|
+
init_cjs_shims();
|
|
1476
|
+
exports2.parse = require_parse();
|
|
1477
|
+
exports2.stringify = require_stringify();
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1481
|
+
// ../../node_modules/.pnpm/@shopify+toml-patch@0.3.0/node_modules/@shopify/toml-patch/toml_patch.js
|
|
1482
|
+
var require_toml_patch = __commonJS({
|
|
1483
|
+
"../../node_modules/.pnpm/@shopify+toml-patch@0.3.0/node_modules/@shopify/toml-patch/toml_patch.js"(exports2, module2) {
|
|
1484
|
+
init_cjs_shims();
|
|
1485
|
+
var imports = {};
|
|
1486
|
+
imports.__wbindgen_placeholder__ = module2.exports;
|
|
1487
|
+
var wasm, { TextEncoder, TextDecoder } = __require("util");
|
|
1488
|
+
function isLikeNone(x) {
|
|
1489
|
+
return x == null;
|
|
1490
|
+
}
|
|
1491
|
+
var cachedDataViewMemory0 = null;
|
|
1492
|
+
function getDataViewMemory0() {
|
|
1493
|
+
return (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === !0 || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) && (cachedDataViewMemory0 = new DataView(wasm.memory.buffer)), cachedDataViewMemory0;
|
|
1494
|
+
}
|
|
1495
|
+
var WASM_VECTOR_LEN = 0, cachedUint8ArrayMemory0 = null;
|
|
1496
|
+
function getUint8ArrayMemory0() {
|
|
1497
|
+
return (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) && (cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer)), cachedUint8ArrayMemory0;
|
|
1498
|
+
}
|
|
1499
|
+
var cachedTextEncoder = new TextEncoder("utf-8"), encodeString = typeof cachedTextEncoder.encodeInto == "function" ? function(arg, view) {
|
|
1500
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
1501
|
+
} : function(arg, view) {
|
|
1502
|
+
let buf = cachedTextEncoder.encode(arg);
|
|
1503
|
+
return view.set(buf), {
|
|
1504
|
+
read: arg.length,
|
|
1505
|
+
written: buf.length
|
|
1506
|
+
};
|
|
1507
|
+
};
|
|
1508
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1509
|
+
if (realloc === void 0) {
|
|
1510
|
+
let buf = cachedTextEncoder.encode(arg), ptr2 = malloc(buf.length, 1) >>> 0;
|
|
1511
|
+
return getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf), WASM_VECTOR_LEN = buf.length, ptr2;
|
|
1512
|
+
}
|
|
1513
|
+
let len = arg.length, ptr = malloc(len, 1) >>> 0, mem = getUint8ArrayMemory0(), offset = 0;
|
|
1514
|
+
for (; offset < len; offset++) {
|
|
1515
|
+
let code = arg.charCodeAt(offset);
|
|
1516
|
+
if (code > 127) break;
|
|
1517
|
+
mem[ptr + offset] = code;
|
|
1518
|
+
}
|
|
1519
|
+
if (offset !== len) {
|
|
1520
|
+
offset !== 0 && (arg = arg.slice(offset)), ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1521
|
+
let view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len), ret = encodeString(arg, view);
|
|
1522
|
+
offset += ret.written, ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1523
|
+
}
|
|
1524
|
+
return WASM_VECTOR_LEN = offset, ptr;
|
|
1525
|
+
}
|
|
1526
|
+
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
|
|
1527
|
+
cachedTextDecoder.decode();
|
|
1528
|
+
function getStringFromWasm0(ptr, len) {
|
|
1529
|
+
return ptr = ptr >>> 0, cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1530
|
+
}
|
|
1531
|
+
function takeFromExternrefTable0(idx) {
|
|
1532
|
+
let value = wasm.__wbindgen_export_0.get(idx);
|
|
1533
|
+
return wasm.__externref_table_dealloc(idx), value;
|
|
1534
|
+
}
|
|
1535
|
+
module2.exports.echoToml = function(tomlContent) {
|
|
1536
|
+
let deferred3_0, deferred3_1;
|
|
1537
|
+
try {
|
|
1538
|
+
let ptr0 = passStringToWasm0(tomlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc), len0 = WASM_VECTOR_LEN, ret = wasm.echoToml(ptr0, len0);
|
|
1539
|
+
var ptr2 = ret[0], len2 = ret[1];
|
|
1540
|
+
if (ret[3])
|
|
1541
|
+
throw ptr2 = 0, len2 = 0, takeFromExternrefTable0(ret[2]);
|
|
1542
|
+
return deferred3_0 = ptr2, deferred3_1 = len2, getStringFromWasm0(ptr2, len2);
|
|
1543
|
+
} finally {
|
|
1544
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
module2.exports.updateTomlValues = function(tomlContent, patches) {
|
|
1548
|
+
let deferred3_0, deferred3_1;
|
|
1549
|
+
try {
|
|
1550
|
+
let ptr0 = passStringToWasm0(tomlContent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc), len0 = WASM_VECTOR_LEN, ret = wasm.updateTomlValues(ptr0, len0, patches);
|
|
1551
|
+
var ptr2 = ret[0], len2 = ret[1];
|
|
1552
|
+
if (ret[3])
|
|
1553
|
+
throw ptr2 = 0, len2 = 0, takeFromExternrefTable0(ret[2]);
|
|
1554
|
+
return deferred3_0 = ptr2, deferred3_1 = len2, getStringFromWasm0(ptr2, len2);
|
|
1555
|
+
} finally {
|
|
1556
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
module2.exports.__wbg_from_2a5d3e218e67aa85 = function(arg0) {
|
|
1560
|
+
return Array.from(arg0);
|
|
1561
|
+
};
|
|
1562
|
+
module2.exports.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
1563
|
+
return arg0[arg1 >>> 0];
|
|
1564
|
+
};
|
|
1565
|
+
module2.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
1566
|
+
return arg0.length;
|
|
1567
|
+
};
|
|
1568
|
+
module2.exports.__wbindgen_boolean_get = function(arg0) {
|
|
1569
|
+
let v = arg0;
|
|
1570
|
+
return typeof v == "boolean" ? v ? 1 : 0 : 2;
|
|
1571
|
+
};
|
|
1572
|
+
module2.exports.__wbindgen_init_externref_table = function() {
|
|
1573
|
+
let table = wasm.__wbindgen_export_0, offset = table.grow(4);
|
|
1574
|
+
table.set(0, void 0), table.set(offset + 0, void 0), table.set(offset + 1, null), table.set(offset + 2, !0), table.set(offset + 3, !1);
|
|
1575
|
+
};
|
|
1576
|
+
module2.exports.__wbindgen_is_array = function(arg0) {
|
|
1577
|
+
return Array.isArray(arg0);
|
|
1578
|
+
};
|
|
1579
|
+
module2.exports.__wbindgen_is_undefined = function(arg0) {
|
|
1580
|
+
return arg0 === void 0;
|
|
1581
|
+
};
|
|
1582
|
+
module2.exports.__wbindgen_number_get = function(arg0, arg1) {
|
|
1583
|
+
let obj = arg1, ret = typeof obj == "number" ? obj : void 0;
|
|
1584
|
+
getDataViewMemory0().setFloat64(arg0 + 8, isLikeNone(ret) ? 0 : ret, !0), getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), !0);
|
|
1585
|
+
};
|
|
1586
|
+
module2.exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
1587
|
+
let obj = arg1, ret = typeof obj == "string" ? obj : void 0;
|
|
1588
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc), len1 = WASM_VECTOR_LEN;
|
|
1589
|
+
getDataViewMemory0().setInt32(arg0 + 4, len1, !0), getDataViewMemory0().setInt32(arg0 + 0, ptr1, !0);
|
|
1590
|
+
};
|
|
1591
|
+
module2.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
1592
|
+
return getStringFromWasm0(arg0, arg1);
|
|
1593
|
+
};
|
|
1594
|
+
module2.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
1595
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1596
|
+
};
|
|
1597
|
+
var path = __require("path").join(__dirname, "toml_patch_bg.wasm"), bytes = __require("fs").readFileSync(path), wasmModule = new WebAssembly.Module(bytes), wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
1598
|
+
wasm = wasmInstance.exports;
|
|
1599
|
+
module2.exports.__wasm = wasm;
|
|
1600
|
+
wasm.__wbindgen_start();
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
|
|
1604
|
+
// ../cli-kit/dist/public/node/environments.js
|
|
1605
|
+
init_cjs_shims();
|
|
1606
|
+
|
|
1607
|
+
// ../cli-kit/dist/public/node/toml/toml-file.js
|
|
1608
|
+
init_cjs_shims();
|
|
1609
|
+
|
|
1610
|
+
// ../cli-kit/dist/public/node/toml/codec.js
|
|
1611
|
+
init_cjs_shims();
|
|
1612
|
+
var toml = __toESM(require_toml(), 1);
|
|
1613
|
+
function decodeToml(input) {
|
|
1614
|
+
let normalizedInput = input.replace(/\r\n$/g, `
|
|
1615
|
+
`);
|
|
1616
|
+
return toml.parse(normalizedInput);
|
|
1617
|
+
}
|
|
1618
|
+
function encodeToml(content) {
|
|
1619
|
+
return toml.stringify(content);
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
// ../cli-kit/dist/public/node/toml/toml-file.js
|
|
1623
|
+
var import_toml_patch = __toESM(require_toml_patch()), TomlFileError = class extends Error {
|
|
1624
|
+
constructor(path, message) {
|
|
1625
|
+
super(message), this.name = "TomlFileError", this.path = path;
|
|
1626
|
+
}
|
|
1627
|
+
}, TomlFile = class _TomlFile {
|
|
1628
|
+
/**
|
|
1629
|
+
* Read and parse a TOML file from disk. Throws {@link TomlFileError} if the file
|
|
1630
|
+
* doesn't exist or contains invalid TOML.
|
|
1631
|
+
*
|
|
1632
|
+
* @param path - Absolute path to the TOML file.
|
|
1633
|
+
* @returns A TomlFile instance with parsed content.
|
|
1634
|
+
*/
|
|
1635
|
+
static async read(path) {
|
|
1636
|
+
if (!await fileExists(path))
|
|
1637
|
+
throw new TomlFileError(path, `TOML file not found: ${path}`);
|
|
1638
|
+
let raw = await readFile(path), file = new _TomlFile(path, {});
|
|
1639
|
+
return file.content = file.decode(raw), file;
|
|
1640
|
+
}
|
|
1641
|
+
constructor(path, content) {
|
|
1642
|
+
this.errors = [], this.path = path, this.content = content;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Surgically patch values in the TOML file, preserving comments and formatting.
|
|
1646
|
+
*
|
|
1647
|
+
* Accepts a nested object whose leaf values are set in the TOML. Intermediate tables are
|
|
1648
|
+
* created automatically. Setting a leaf to `undefined` removes it (use `remove()` for a
|
|
1649
|
+
* clearer API when deleting keys).
|
|
1650
|
+
*
|
|
1651
|
+
* @example
|
|
1652
|
+
* ```ts
|
|
1653
|
+
* await file.patch({build: {dev_store_url: 'my-store.myshopify.com'}})
|
|
1654
|
+
* await file.patch({application_url: 'https://example.com', auth: {redirect_urls: ['...']}})
|
|
1655
|
+
* ```
|
|
1656
|
+
*/
|
|
1657
|
+
async patch(changes) {
|
|
1658
|
+
let patches = flattenToPatchEntries(changes), raw = await readFile(this.path), updated = (0, import_toml_patch.updateTomlValues)(raw, patches), parsed = this.decode(updated);
|
|
1659
|
+
await writeFile(this.path, updated), this.content = parsed;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Remove a key from the TOML file by dotted path, preserving comments and formatting.
|
|
1663
|
+
*
|
|
1664
|
+
* @param keyPath - Dotted key path to remove (e.g. 'build.include_config_on_deploy').
|
|
1665
|
+
* @example
|
|
1666
|
+
* ```ts
|
|
1667
|
+
* await file.remove('build.include_config_on_deploy')
|
|
1668
|
+
* ```
|
|
1669
|
+
*/
|
|
1670
|
+
async remove(keyPath) {
|
|
1671
|
+
let keys = keyPath.split("."), raw = await readFile(this.path), updated = (0, import_toml_patch.updateTomlValues)(raw, [[keys, void 0]]), parsed = this.decode(updated);
|
|
1672
|
+
await writeFile(this.path, updated), this.content = parsed;
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Replace the entire file content. The file is fully re-serialized — comments and formatting
|
|
1676
|
+
* are NOT preserved.
|
|
1677
|
+
*
|
|
1678
|
+
* @param content - The new content to write.
|
|
1679
|
+
* @example
|
|
1680
|
+
* ```ts
|
|
1681
|
+
* await file.replace({client_id: 'abc', name: 'My App'})
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
1684
|
+
async replace(content) {
|
|
1685
|
+
let encoded = encodeToml(content);
|
|
1686
|
+
this.decode(encoded), await writeFile(this.path, encoded), this.content = content;
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Transform the raw TOML string on disk. Reads the file, applies the transform function
|
|
1690
|
+
* to the raw text, writes back, and re-parses to keep `content` in sync.
|
|
1691
|
+
*
|
|
1692
|
+
* Use this for text-level operations that can't be expressed as structured edits —
|
|
1693
|
+
* e.g. Injecting comments or positional insertion of keys in arrays-of-tables.
|
|
1694
|
+
* Subsequent `patch()` calls will preserve any comments added this way.
|
|
1695
|
+
*
|
|
1696
|
+
* @param transform - A function that receives the raw TOML string and returns the modified string.
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```ts
|
|
1699
|
+
* await file.transformRaw((raw) => `# Header comment\n${raw}`)
|
|
1700
|
+
* ```
|
|
1701
|
+
*/
|
|
1702
|
+
async transformRaw(transform) {
|
|
1703
|
+
let raw = await readFile(this.path), transformed = transform(raw), parsed = this.decode(transformed);
|
|
1704
|
+
await writeFile(this.path, transformed), this.content = parsed;
|
|
1705
|
+
}
|
|
1706
|
+
decode(raw) {
|
|
1707
|
+
try {
|
|
1708
|
+
return decodeToml(raw);
|
|
1709
|
+
} catch (err) {
|
|
1710
|
+
if (err.line !== void 0 && err.col !== void 0) {
|
|
1711
|
+
let description = String(err.message).split(`
|
|
1712
|
+
`)[0] ?? "Invalid TOML";
|
|
1713
|
+
throw new TomlFileError(this.path, `${description} at row ${err.line}, col ${err.col}`);
|
|
1714
|
+
}
|
|
1715
|
+
throw err;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
function flattenToPatchEntries(obj, prefix = []) {
|
|
1720
|
+
let entries = [];
|
|
1721
|
+
for (let [key, value] of Object.entries(obj)) {
|
|
1722
|
+
let path = [...prefix, key];
|
|
1723
|
+
value !== null && typeof value == "object" && !Array.isArray(value) ? entries.push(...flattenToPatchEntries(value, path)) : entries.push([path, value]);
|
|
1724
|
+
}
|
|
1725
|
+
return entries;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
// ../cli-kit/dist/public/node/environments.js
|
|
1729
|
+
function renderWarningIfNeeded(message, silent) {
|
|
1730
|
+
silent || renderWarning(message);
|
|
1731
|
+
}
|
|
1732
|
+
async function loadEnvironment(environmentName, fileName, options) {
|
|
1733
|
+
let filePath = await environmentFilePath(fileName, options);
|
|
1734
|
+
if (!filePath) {
|
|
1735
|
+
renderWarningIfNeeded({ body: "Environment file not found." }, options?.silent);
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
let environments = (await TomlFile.read(filePath)).content.environments;
|
|
1739
|
+
if (!environments) {
|
|
1740
|
+
renderWarningIfNeeded({
|
|
1741
|
+
body: ["No environments found in", { command: filePath }, { char: "." }]
|
|
1742
|
+
}, options?.silent);
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1745
|
+
let environment = environments[environmentName];
|
|
1746
|
+
if (!environment) {
|
|
1747
|
+
renderWarningIfNeeded({
|
|
1748
|
+
body: ["Environment", { command: environmentName }, "not found."]
|
|
1749
|
+
}, options?.silent);
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
return await addSensitiveMetadata(() => ({
|
|
1753
|
+
environmentFlags: JSON.stringify(environment)
|
|
1754
|
+
})), environment;
|
|
1755
|
+
}
|
|
1756
|
+
async function environmentFilePath(fileName, options) {
|
|
1757
|
+
let basePath = options?.from && options.from !== "." ? options.from : cwd();
|
|
1758
|
+
return findPathUp(fileName, {
|
|
1759
|
+
cwd: basePath,
|
|
1760
|
+
type: "file"
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
export {
|
|
1765
|
+
require_toml_patch,
|
|
1766
|
+
TomlFileError,
|
|
1767
|
+
TomlFile,
|
|
1768
|
+
loadEnvironment,
|
|
1769
|
+
environmentFilePath
|
|
1770
|
+
};
|
|
1771
|
+
//# sourceMappingURL=chunk-DNF3EUMN.js.map
|