@node-core/utils 7.1.0 → 7.2.1
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/components/metadata.js +2 -1
- package/lib/ci/build-types/test_build.js +3 -3
- package/lib/ci/failure_aggregator.js +2 -2
- package/lib/ci/run_ci.js +3 -2
- package/lib/cli.js +6 -6
- package/lib/figures.js +6 -6
- package/lib/prepare_security.js +20 -21
- package/lib/request.js +1 -1
- package/lib/update-v8/backport.js +3 -4
- package/lib/utils.js +4 -2
- package/lib/verbosity.js +2 -4
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
- package/node_modules/ansi-regex/index.js +9 -4
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/ansi-regex/readme.md +6 -0
- package/node_modules/ansi-styles/index.d.ts +12 -12
- package/node_modules/ansi-styles/index.js +3 -3
- package/node_modules/ansi-styles/package.json +4 -4
- package/node_modules/cli-truncate/index.d.ts +3 -3
- package/node_modules/cli-truncate/index.js +40 -14
- package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
- package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
- package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
- package/node_modules/cli-truncate/package.json +7 -7
- package/node_modules/cli-truncate/readme.md +2 -3
- package/node_modules/ghauth/.github/dependabot.yml +11 -3
- package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
- package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
- package/node_modules/ghauth/CHANGELOG.md +60 -0
- package/node_modules/ghauth/package.json +30 -6
- package/node_modules/js-yaml/README.md +20 -187
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
- package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
- package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/package.json +8 -7
- package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
- package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
- package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/listr2/node_modules/string-width/index.js +207 -0
- package/node_modules/listr2/node_modules/string-width/package.json +65 -0
- package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
- package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/listr2/package.json +16 -19
- package/node_modules/log-update/index.d.ts +64 -1
- package/node_modules/log-update/index.js +268 -18
- package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/log-update/node_modules/string-width/index.js +207 -0
- package/node_modules/log-update/node_modules/string-width/package.json +65 -0
- package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
- package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/log-update/package.json +14 -12
- package/node_modules/log-update/readme.md +61 -0
- package/node_modules/slice-ansi/index.d.ts +2 -2
- package/node_modules/slice-ansi/index.js +260 -112
- package/node_modules/slice-ansi/package.json +10 -9
- package/node_modules/slice-ansi/readme.md +3 -2
- package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/node_modules/smol-toml/README.md +205 -191
- package/node_modules/smol-toml/dist/date.d.ts +0 -1
- package/node_modules/smol-toml/dist/date.js +0 -1
- package/node_modules/smol-toml/dist/error.d.ts +0 -1
- package/node_modules/smol-toml/dist/error.js +0 -1
- package/node_modules/smol-toml/dist/extract.js +32 -65
- package/node_modules/smol-toml/dist/index.cjs +302 -288
- package/node_modules/smol-toml/dist/index.d.ts +0 -1
- package/node_modules/smol-toml/dist/index.js +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts +1 -3
- package/node_modules/smol-toml/dist/parse.js +22 -21
- package/node_modules/smol-toml/dist/primitive.js +75 -76
- package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
- package/node_modules/smol-toml/dist/stringify.js +43 -30
- package/node_modules/smol-toml/dist/struct.js +90 -93
- package/node_modules/smol-toml/dist/util.d.ts +1 -1
- package/node_modules/smol-toml/dist/util.js +36 -39
- package/node_modules/smol-toml/package.json +6 -6
- package/node_modules/strip-ansi/index.js +5 -0
- package/node_modules/strip-ansi/package.json +5 -5
- package/package.json +3 -9
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
- package/node_modules/chalk/package.json +0 -92
- package/node_modules/chalk/readme.md +0 -331
- package/node_modules/chalk/source/index.d.ts +0 -437
- package/node_modules/chalk/source/index.js +0 -261
- package/node_modules/chalk/source/utilities.js +0 -33
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
- package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
- package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
- package/node_modules/colorette/LICENSE.md +0 -7
- package/node_modules/colorette/README.md +0 -134
- package/node_modules/colorette/index.cjs +0 -218
- package/node_modules/colorette/index.d.ts +0 -93
- package/node_modules/colorette/index.js +0 -150
- package/node_modules/colorette/package.json +0 -40
- package/node_modules/eventemitter3/LICENSE +0 -21
- package/node_modules/eventemitter3/README.md +0 -94
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
- package/node_modules/eventemitter3/index.d.ts +0 -135
- package/node_modules/eventemitter3/index.js +0 -336
- package/node_modules/eventemitter3/index.mjs +0 -4
- package/node_modules/eventemitter3/package.json +0 -67
- package/node_modules/figures/index.d.ts +0 -279
- package/node_modules/figures/index.js +0 -292
- package/node_modules/figures/package.json +0 -49
- package/node_modules/figures/readme.md +0 -337
- package/node_modules/isexe/LICENSE.md +0 -55
- package/node_modules/isexe/README.md +0 -80
- package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
- package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.js +0 -56
- package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
- package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
- package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
- package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/options.js +0 -3
- package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/package.json +0 -3
- package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/posix.js +0 -67
- package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.js +0 -63
- package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.d.ts +0 -14
- package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/index.js +0 -16
- package/node_modules/isexe/dist/esm/index.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.min.js +0 -2
- package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
- package/node_modules/isexe/dist/esm/options.d.ts +0 -32
- package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/options.js +0 -2
- package/node_modules/isexe/dist/esm/options.js.map +0 -1
- package/node_modules/isexe/dist/esm/package.json +0 -3
- package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
- package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/posix.js +0 -62
- package/node_modules/isexe/dist/esm/posix.js.map +0 -1
- package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
- package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/win32.js +0 -58
- package/node_modules/isexe/dist/esm/win32.js.map +0 -1
- package/node_modules/isexe/package.json +0 -78
- package/node_modules/listr2/dist/index.cjs +0 -2189
- package/node_modules/listr2/dist/index.d.ts +0 -1528
- package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
- package/node_modules/rfdc/LICENSE +0 -15
- package/node_modules/rfdc/default.js +0 -3
- package/node_modules/rfdc/index.d.ts +0 -13
- package/node_modules/rfdc/index.js +0 -198
- package/node_modules/rfdc/index.test-d.ts +0 -13
- package/node_modules/rfdc/package.json +0 -73
- package/node_modules/rfdc/readme.md +0 -181
- package/node_modules/rfdc/test/index.js +0 -306
- package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/date.js.map +0 -1
- package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/error.js.map +0 -1
- package/node_modules/smol-toml/dist/extract.js.map +0 -1
- package/node_modules/smol-toml/dist/index.cjs.map +0 -1
- package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/index.js.map +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/parse.js.map +0 -1
- package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
- package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/primitive.js.map +0 -1
- package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/stringify.js.map +0 -1
- package/node_modules/smol-toml/dist/struct.js.map +0 -1
- package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/util.js.map +0 -1
- package/node_modules/smol-toml/src/date.ts +0 -152
- package/node_modules/smol-toml/src/error.ts +0 -77
- package/node_modules/smol-toml/src/extract.ts +0 -113
- package/node_modules/smol-toml/src/index.ts +0 -42
- package/node_modules/smol-toml/src/parse.ts +0 -184
- package/node_modules/smol-toml/src/primitive.ts +0 -249
- package/node_modules/smol-toml/src/stringify.ts +0 -191
- package/node_modules/smol-toml/src/struct.ts +0 -202
- package/node_modules/smol-toml/src/util.ts +0 -106
- package/node_modules/which/LICENSE +0 -15
- package/node_modules/which/README.md +0 -51
- package/node_modules/which/bin/which.js +0 -52
- package/node_modules/which/lib/index.js +0 -111
- package/node_modules/which/package.json +0 -52
- /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
- /package/node_modules/{chalk → ansi-escapes}/license +0 -0
- /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
- /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
26
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
|
-
import type
|
|
29
|
-
import { type TomlTable, type TomlTableWithoutBigInt } from './util.js';
|
|
28
|
+
import { type IntegersAsBigInt, type TomlTable, type TomlTableWithoutBigInt } from './util.js';
|
|
30
29
|
export interface ParseOptions {
|
|
31
30
|
maxDepth?: number;
|
|
32
31
|
integersAsBigInt?: IntegersAsBigInt;
|
|
@@ -35,4 +34,3 @@ export declare function parse(toml: string, options?: ParseOptions & {
|
|
|
35
34
|
integersAsBigInt: Exclude<IntegersAsBigInt, undefined | false>;
|
|
36
35
|
}): TomlTable;
|
|
37
36
|
export declare function parse(toml: string, options?: ParseOptions): TomlTableWithoutBigInt;
|
|
38
|
-
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -93,56 +93,57 @@ function peekTable(key, table, meta, type) {
|
|
|
93
93
|
return [k, t, state.c];
|
|
94
94
|
}
|
|
95
95
|
export function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
96
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
96
97
|
let res = {};
|
|
97
98
|
let meta = {};
|
|
99
|
+
let tmp;
|
|
98
100
|
let tbl = res;
|
|
99
101
|
let m = meta;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
let
|
|
102
|
+
skipVoid(ctx);
|
|
103
|
+
while (ctx.p < toml.length) {
|
|
104
|
+
if (toml.charCodeAt(ctx.p) === 0x5b /* [ */) {
|
|
105
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 0x5b; /* [ */
|
|
106
|
+
tmp = ctx.p += +isTableArray;
|
|
107
|
+
let k = parseKey(ctx, ']');
|
|
104
108
|
if (isTableArray) {
|
|
105
|
-
if (toml
|
|
109
|
+
if (toml.charCodeAt(ctx.p - 1) !== 0x5d /* ] */) {
|
|
106
110
|
throw new TomlError('expected end of table declaration', {
|
|
107
111
|
toml: toml,
|
|
108
|
-
ptr:
|
|
112
|
+
ptr: ctx.p - 1,
|
|
109
113
|
});
|
|
110
114
|
}
|
|
111
|
-
|
|
115
|
+
ctx.p++;
|
|
112
116
|
}
|
|
113
|
-
let p = peekTable(k
|
|
117
|
+
let p = peekTable(k, res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
|
|
114
118
|
if (!p) {
|
|
115
119
|
throw new TomlError('trying to redefine an already defined table or value', {
|
|
116
120
|
toml: toml,
|
|
117
|
-
ptr:
|
|
121
|
+
ptr: tmp,
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
m = p[2];
|
|
121
125
|
tbl = p[1];
|
|
122
|
-
ptr = k[1];
|
|
123
126
|
}
|
|
124
127
|
else {
|
|
125
|
-
|
|
126
|
-
let
|
|
128
|
+
tmp = ctx.p;
|
|
129
|
+
let k = parseKey(ctx);
|
|
130
|
+
let p = peekTable(k, tbl, m, 0 /* Type.DOTTED */);
|
|
127
131
|
if (!p) {
|
|
128
132
|
throw new TomlError('trying to redefine an already defined table or value', {
|
|
129
133
|
toml: toml,
|
|
130
|
-
ptr:
|
|
134
|
+
ptr: tmp,
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
|
-
|
|
134
|
-
p[1][p[0]] = v[0];
|
|
135
|
-
ptr = v[1];
|
|
137
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
136
138
|
}
|
|
137
|
-
|
|
138
|
-
if (toml
|
|
139
|
+
skipVoid(ctx, true);
|
|
140
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 0xa /* \n */ && tmp !== 0xd /* \r */) {
|
|
139
141
|
throw new TomlError('each key-value declaration must be followed by an end-of-line', {
|
|
140
142
|
toml: toml,
|
|
141
|
-
ptr:
|
|
143
|
+
ptr: ctx.p,
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
skipVoid(ctx);
|
|
145
147
|
}
|
|
146
148
|
return res;
|
|
147
149
|
}
|
|
148
|
-
//# sourceMappingURL=parse.js.map
|
|
@@ -27,22 +27,24 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { TomlDate } from './date.js';
|
|
29
29
|
import { TomlError } from './error.js';
|
|
30
|
+
import { skipComment, skipUntil } from './util.js';
|
|
30
31
|
// let CTRL_REGEX = /[\x00-\x08\x0f-\x1f\x7f]/
|
|
31
32
|
let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
32
33
|
let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
33
34
|
let LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
34
35
|
/** @internal */
|
|
35
|
-
export function parseString(
|
|
36
|
-
let
|
|
36
|
+
export function parseString(ctx) {
|
|
37
|
+
let start = ctx.p;
|
|
38
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
37
39
|
let first = c;
|
|
38
|
-
let isLiteral = c ===
|
|
39
|
-
let isMultiline = c ===
|
|
40
|
+
let isLiteral = c === 0x27; /* ' */
|
|
41
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
40
42
|
if (isMultiline) {
|
|
41
43
|
// Trim initial newline
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
else if (
|
|
45
|
-
|
|
44
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 0xa /* \n */)
|
|
45
|
+
ctx.p++;
|
|
46
|
+
else if (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */)
|
|
47
|
+
ctx.p += 2;
|
|
46
48
|
}
|
|
47
49
|
/*
|
|
48
50
|
The fast path does not seem to bring significant performance gains, so it's commented out.
|
|
@@ -76,119 +78,130 @@ export function parseString(str, ptr) {
|
|
|
76
78
|
}
|
|
77
79
|
*/
|
|
78
80
|
let parsed = '';
|
|
79
|
-
let sliceStart =
|
|
81
|
+
let sliceStart = ctx.p;
|
|
80
82
|
// states:
|
|
81
83
|
// 0 - decoding
|
|
82
84
|
// 1 - decoding escape
|
|
83
85
|
// 2 - whitespace escape (no newline encountered yet, must fail on non-whitespace)
|
|
84
86
|
// 3 - whitespace escape (newline encountered, allowed to transition back to normal decode)
|
|
85
87
|
let state = 0;
|
|
86
|
-
for (
|
|
87
|
-
c =
|
|
88
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
89
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
88
90
|
// Deal with newlines first, since that simplifies control character checking and handling across all states
|
|
89
|
-
if (isMultiline && (c ===
|
|
91
|
+
if (isMultiline && (c === 0xa /* \n */ || (c === 0xd /* \r */ && ctx.s.charCodeAt(ctx.p + 1) === 0xa /* \n */))) {
|
|
90
92
|
state = state && 3;
|
|
91
93
|
}
|
|
92
94
|
// Control characters are banned in TOML, so we throw an error if we encounter them
|
|
93
|
-
else if ((c <
|
|
95
|
+
else if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) {
|
|
94
96
|
throw new TomlError('control characters are not allowed in strings', {
|
|
95
|
-
toml:
|
|
96
|
-
ptr:
|
|
97
|
+
toml: ctx.s,
|
|
98
|
+
ptr: ctx.p,
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
// The string might terminate while we're parsing through a newline escape.
|
|
100
102
|
// It must have encountered a newline; otherwise, it'll simply fail in another branch.
|
|
101
|
-
else if ((!state || state === 3) && c === first && (!isMultiline || (
|
|
103
|
+
else if ((!state || state === 3) && c === first && (!isMultiline || (ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first))) {
|
|
102
104
|
if (isMultiline) {
|
|
103
105
|
// If the string ends with 4-5 quotes, then the first 1-2 are part of the string
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
106
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
107
|
+
ctx.p++;
|
|
108
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
109
|
+
ctx.p++;
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
];
|
|
111
|
+
// If we're in a newline escape still, then there's nothing to add.
|
|
112
|
+
if (!state)
|
|
113
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
114
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
115
|
+
return parsed;
|
|
115
116
|
}
|
|
116
117
|
else if (!state) {
|
|
117
|
-
if (!isLiteral && c ===
|
|
118
|
-
parsed +=
|
|
118
|
+
if (!isLiteral && c === 0x5c /* \ */) {
|
|
119
|
+
parsed += ctx.s.slice(sliceStart, (sliceStart = ctx.p));
|
|
119
120
|
state = 1;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
else if (state === 1) {
|
|
123
|
-
if (c ===
|
|
124
|
+
if (c === 0x78 /* x */ || c === 0x75 /* u */ || c === 0x55 /* U */) { // Unicode escape
|
|
124
125
|
let value = 0;
|
|
125
|
-
let len = c ===
|
|
126
|
-
for (let j = 0; j < len; j++,
|
|
127
|
-
let hex =
|
|
126
|
+
let len = c === 0x78 /* x */ ? 2 : c === 0x75 /* u */ ? 4 : 8;
|
|
127
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
128
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
128
129
|
let digit =
|
|
129
130
|
/* 0-9 */ hex >= 0x30 && hex <= 0x39 ? hex - 0x30 :
|
|
130
131
|
/* A-F */ hex >= 0x41 && hex <= 0x46 ? hex - 0x41 + 10 :
|
|
131
132
|
/* a-f */ hex >= 0x61 && hex <= 0x66 ? hex - 0x61 + 10 : -1;
|
|
132
133
|
if (digit < 0)
|
|
133
|
-
throw new TomlError('invalid non-hex character in unicode escape', { toml:
|
|
134
|
+
throw new TomlError('invalid non-hex character in unicode escape', { toml: ctx.s, ptr: ctx.p + 1 });
|
|
134
135
|
value = (value << 4) | digit;
|
|
135
136
|
}
|
|
136
137
|
// Because JS does bitwise on signed 32bit integers, all 0xfzzzzzzz values are actually seen as negative
|
|
137
138
|
if (value < 0 || value > 0x10ffff || (value >= 0xd800 && value <= 0xdfff)) {
|
|
138
|
-
throw new TomlError('invalid unicode escape', { toml:
|
|
139
|
+
throw new TomlError('invalid unicode escape', { toml: ctx.s, ptr: ctx.p });
|
|
139
140
|
}
|
|
140
141
|
parsed += String.fromCodePoint(value);
|
|
141
|
-
sliceStart =
|
|
142
|
+
sliceStart = ctx.p + 1;
|
|
142
143
|
state = 0;
|
|
143
144
|
}
|
|
144
|
-
else if (c ===
|
|
145
|
+
else if (c === 0x20 || c === 0x9 /* \t */) { // If it was a newline, it'd have been handled earlier
|
|
145
146
|
state = 2;
|
|
146
147
|
}
|
|
147
148
|
else {
|
|
148
|
-
if (c ===
|
|
149
|
+
if (c === 0x62 /* b */)
|
|
149
150
|
parsed += '\b';
|
|
150
|
-
else if (c ===
|
|
151
|
+
else if (c === 0x74 /* t */)
|
|
151
152
|
parsed += '\t';
|
|
152
|
-
else if (c ===
|
|
153
|
+
else if (c === 0x6e /* n */)
|
|
153
154
|
parsed += '\n';
|
|
154
|
-
else if (c ===
|
|
155
|
+
else if (c === 0x66 /* f */)
|
|
155
156
|
parsed += '\f';
|
|
156
|
-
else if (c ===
|
|
157
|
+
else if (c === 0x72 /* r */)
|
|
157
158
|
parsed += '\r';
|
|
158
|
-
else if (c ===
|
|
159
|
+
else if (c === 0x65 /* e */)
|
|
159
160
|
parsed += '\x1b';
|
|
160
|
-
else if (c ===
|
|
161
|
+
else if (c === 0x22 /* " */)
|
|
161
162
|
parsed += '"';
|
|
162
|
-
else if (c ===
|
|
163
|
+
else if (c === 0x5c /* \ */)
|
|
163
164
|
parsed += '\\';
|
|
164
165
|
else
|
|
165
|
-
throw new TomlError('unrecognized escape sequence', { toml:
|
|
166
|
-
sliceStart =
|
|
166
|
+
throw new TomlError('unrecognized escape sequence', { toml: ctx.s, ptr: ctx.p });
|
|
167
|
+
sliceStart = ctx.p + 1;
|
|
167
168
|
state = 0;
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
|
-
else if (c !==
|
|
171
|
+
else if (c !== 0x20 && c !== 0x9 /* \t */) {
|
|
171
172
|
if (state === 2) {
|
|
172
173
|
throw new TomlError('invalid escape: only line-ending whitespace may be escaped', {
|
|
173
|
-
toml:
|
|
174
|
+
toml: ctx.s,
|
|
174
175
|
ptr: sliceStart,
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
// State cannot be zero, or we'd have branched earlier already.
|
|
178
179
|
// If it's a backslash, immediately transition to the escape state so it can be processed.
|
|
179
|
-
state = !isLiteral && c ===
|
|
180
|
-
sliceStart =
|
|
180
|
+
state = !isLiteral && c === 0x5c /* \ */ ? 1 : 0;
|
|
181
|
+
sliceStart = ctx.p;
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
|
-
throw new TomlError('unfinished string', { toml:
|
|
184
|
+
throw new TomlError('unfinished string', { toml: ctx.s, ptr: start });
|
|
185
|
+
}
|
|
186
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
187
|
+
let value = ctx.s.slice(start, end);
|
|
188
|
+
let commentIdx = value.indexOf('#');
|
|
189
|
+
if (commentIdx > 0) {
|
|
190
|
+
// The call to skipComment allows to "validate" the comment
|
|
191
|
+
// (absence of control characters)
|
|
192
|
+
skipComment({ s: value, p: commentIdx, d: 0 });
|
|
193
|
+
value = value.slice(0, commentIdx);
|
|
194
|
+
}
|
|
195
|
+
return value.trimEnd();
|
|
184
196
|
}
|
|
185
197
|
/** @internal */
|
|
186
|
-
export function parseValue(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
export function parseValue(ctx, integersAsBigInt, end) {
|
|
199
|
+
let ptr = ctx.p;
|
|
200
|
+
let err = { toml: ctx.s, ptr };
|
|
201
|
+
skipUntil(ctx, 0x2c /* , */, end);
|
|
202
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
203
|
+
if (!value)
|
|
204
|
+
throw new TomlError('incomplete declaration: value expected', err);
|
|
192
205
|
if (value === '-inf')
|
|
193
206
|
return -Infinity;
|
|
194
207
|
if (value === 'inf' || value === '+inf')
|
|
@@ -202,25 +215,16 @@ export function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
202
215
|
let isInt = INT_REGEX.test(value);
|
|
203
216
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
204
217
|
if (LEADING_ZERO.test(value)) {
|
|
205
|
-
throw new TomlError('leading zeroes are not allowed',
|
|
206
|
-
toml: toml,
|
|
207
|
-
ptr: ptr,
|
|
208
|
-
});
|
|
218
|
+
throw new TomlError('leading zeroes are not allowed', err);
|
|
209
219
|
}
|
|
210
220
|
value = value.replace(/_/g, '');
|
|
211
221
|
let numeric = +value;
|
|
212
222
|
if (isNaN(numeric)) {
|
|
213
|
-
throw new TomlError('invalid number',
|
|
214
|
-
toml: toml,
|
|
215
|
-
ptr: ptr,
|
|
216
|
-
});
|
|
223
|
+
throw new TomlError('invalid number', err);
|
|
217
224
|
}
|
|
218
225
|
if (isInt) {
|
|
219
226
|
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
220
|
-
throw new TomlError('integer value cannot be represented losslessly',
|
|
221
|
-
toml: toml,
|
|
222
|
-
ptr: ptr,
|
|
223
|
-
});
|
|
227
|
+
throw new TomlError('integer value cannot be represented losslessly', err);
|
|
224
228
|
}
|
|
225
229
|
if (isInt || integersAsBigInt === true)
|
|
226
230
|
numeric = BigInt(value);
|
|
@@ -228,12 +232,7 @@ export function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
228
232
|
return numeric;
|
|
229
233
|
}
|
|
230
234
|
const date = new TomlDate(value);
|
|
231
|
-
if (!date.isValid())
|
|
232
|
-
throw new TomlError('invalid value',
|
|
233
|
-
toml: toml,
|
|
234
|
-
ptr: ptr,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
235
|
+
if (!date.isValid())
|
|
236
|
+
throw new TomlError('invalid value', err);
|
|
237
237
|
return date;
|
|
238
238
|
}
|
|
239
|
-
//# sourceMappingURL=primitive.js.map
|
|
@@ -31,8 +31,18 @@ function extendedTypeOf(obj) {
|
|
|
31
31
|
if (type === 'object') {
|
|
32
32
|
if (Array.isArray(obj))
|
|
33
33
|
return 'array';
|
|
34
|
-
if (obj instanceof Date)
|
|
34
|
+
if (typeof obj?.getUTCDate === 'function' && obj instanceof Date)
|
|
35
35
|
return 'date';
|
|
36
|
+
if (globalThis.Temporal &&
|
|
37
|
+
// check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
38
|
+
typeof obj?.since === 'function' &&
|
|
39
|
+
(obj instanceof Temporal.Instant ||
|
|
40
|
+
obj instanceof Temporal.PlainDate ||
|
|
41
|
+
obj instanceof Temporal.PlainDateTime ||
|
|
42
|
+
obj instanceof Temporal.PlainTime ||
|
|
43
|
+
obj instanceof Temporal.ZonedDateTime)) {
|
|
44
|
+
return 'temporal';
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
return type;
|
|
38
48
|
}
|
|
@@ -46,38 +56,42 @@ function isArrayOfTables(obj) {
|
|
|
46
56
|
function formatString(s) {
|
|
47
57
|
return JSON.stringify(s).replace(/\x7f/g, '\\u007f');
|
|
48
58
|
}
|
|
59
|
+
function stringifyTemporal(temporal) {
|
|
60
|
+
return temporal.toString({
|
|
61
|
+
calendarName: 'never',
|
|
62
|
+
timeZoneName: 'never',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
49
65
|
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
50
66
|
if (depth === 0) {
|
|
51
67
|
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
52
68
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (type === 'array') {
|
|
80
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
69
|
+
switch (type) {
|
|
70
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
71
|
+
case 'number':
|
|
72
|
+
if (isNaN(val))
|
|
73
|
+
return 'nan';
|
|
74
|
+
if (val === Infinity)
|
|
75
|
+
return 'inf';
|
|
76
|
+
if (val === -Infinity)
|
|
77
|
+
return '-inf';
|
|
78
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
79
|
+
return val.toFixed(1);
|
|
80
|
+
case 'bigint':
|
|
81
|
+
case 'boolean':
|
|
82
|
+
return val.toString();
|
|
83
|
+
case 'string':
|
|
84
|
+
return formatString(val);
|
|
85
|
+
case 'date':
|
|
86
|
+
if (isNaN(val.getTime()))
|
|
87
|
+
throw new TypeError('cannot serialize invalid date');
|
|
88
|
+
return val.toISOString();
|
|
89
|
+
case 'object':
|
|
90
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
91
|
+
case 'array':
|
|
92
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
93
|
+
case 'temporal':
|
|
94
|
+
return stringifyTemporal(val);
|
|
81
95
|
}
|
|
82
96
|
}
|
|
83
97
|
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
@@ -165,4 +179,3 @@ export function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {})
|
|
|
165
179
|
return str + '\n';
|
|
166
180
|
return str;
|
|
167
181
|
}
|
|
168
|
-
//# sourceMappingURL=stringify.js.map
|