@node-core/utils 7.2.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.
Files changed (182) hide show
  1. package/lib/ci/build-types/test_build.js +3 -3
  2. package/lib/ci/failure_aggregator.js +2 -2
  3. package/lib/ci/run_ci.js +3 -2
  4. package/lib/cli.js +6 -6
  5. package/lib/figures.js +6 -6
  6. package/lib/update-v8/backport.js +3 -4
  7. package/lib/verbosity.js +2 -4
  8. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
  9. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
  10. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
  11. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
  12. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
  13. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
  14. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
  15. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
  16. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
  17. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
  18. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
  19. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
  20. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
  21. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
  22. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
  23. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
  24. package/node_modules/ansi-regex/index.js +9 -4
  25. package/node_modules/ansi-regex/package.json +1 -1
  26. package/node_modules/ansi-regex/readme.md +6 -0
  27. package/node_modules/ansi-styles/index.d.ts +12 -12
  28. package/node_modules/ansi-styles/index.js +3 -3
  29. package/node_modules/ansi-styles/package.json +4 -4
  30. package/node_modules/cli-truncate/index.d.ts +3 -3
  31. package/node_modules/cli-truncate/index.js +40 -14
  32. package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
  33. package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
  34. package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
  35. package/node_modules/cli-truncate/package.json +7 -7
  36. package/node_modules/cli-truncate/readme.md +2 -3
  37. package/node_modules/ghauth/.github/dependabot.yml +11 -3
  38. package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
  39. package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
  40. package/node_modules/ghauth/CHANGELOG.md +60 -0
  41. package/node_modules/ghauth/package.json +30 -6
  42. package/node_modules/js-yaml/README.md +20 -187
  43. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
  44. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
  45. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
  46. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
  47. package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
  48. package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
  49. package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
  50. package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
  51. package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
  52. package/node_modules/js-yaml/package.json +8 -7
  53. package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
  54. package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
  55. package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
  56. package/node_modules/listr2/node_modules/string-width/index.js +207 -0
  57. package/node_modules/listr2/node_modules/string-width/package.json +65 -0
  58. package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
  59. package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
  60. package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
  61. package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
  62. package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
  63. package/node_modules/listr2/package.json +16 -19
  64. package/node_modules/log-update/index.d.ts +64 -1
  65. package/node_modules/log-update/index.js +268 -18
  66. package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
  67. package/node_modules/log-update/node_modules/string-width/index.js +207 -0
  68. package/node_modules/log-update/node_modules/string-width/package.json +65 -0
  69. package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
  70. package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
  71. package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
  72. package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
  73. package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
  74. package/node_modules/log-update/package.json +14 -12
  75. package/node_modules/log-update/readme.md +61 -0
  76. package/node_modules/slice-ansi/index.d.ts +2 -2
  77. package/node_modules/slice-ansi/index.js +260 -112
  78. package/node_modules/slice-ansi/package.json +10 -9
  79. package/node_modules/slice-ansi/readme.md +3 -2
  80. package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  81. package/node_modules/smol-toml/README.md +205 -191
  82. package/node_modules/smol-toml/dist/date.d.ts +0 -1
  83. package/node_modules/smol-toml/dist/date.js +0 -1
  84. package/node_modules/smol-toml/dist/error.d.ts +0 -1
  85. package/node_modules/smol-toml/dist/error.js +0 -1
  86. package/node_modules/smol-toml/dist/extract.js +32 -65
  87. package/node_modules/smol-toml/dist/index.cjs +302 -288
  88. package/node_modules/smol-toml/dist/index.d.ts +0 -1
  89. package/node_modules/smol-toml/dist/index.js +0 -1
  90. package/node_modules/smol-toml/dist/parse.d.ts +1 -3
  91. package/node_modules/smol-toml/dist/parse.js +22 -21
  92. package/node_modules/smol-toml/dist/primitive.js +75 -76
  93. package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
  94. package/node_modules/smol-toml/dist/stringify.js +43 -30
  95. package/node_modules/smol-toml/dist/struct.js +90 -93
  96. package/node_modules/smol-toml/dist/util.d.ts +1 -1
  97. package/node_modules/smol-toml/dist/util.js +36 -39
  98. package/node_modules/smol-toml/package.json +6 -6
  99. package/node_modules/strip-ansi/index.js +5 -0
  100. package/node_modules/strip-ansi/package.json +5 -5
  101. package/package.json +3 -5
  102. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
  103. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
  104. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
  105. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
  106. package/node_modules/chalk/package.json +0 -92
  107. package/node_modules/chalk/readme.md +0 -331
  108. package/node_modules/chalk/source/index.d.ts +0 -437
  109. package/node_modules/chalk/source/index.js +0 -261
  110. package/node_modules/chalk/source/utilities.js +0 -33
  111. package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
  112. package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
  113. package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
  114. package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
  115. package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
  116. package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
  117. package/node_modules/colorette/LICENSE.md +0 -7
  118. package/node_modules/colorette/README.md +0 -134
  119. package/node_modules/colorette/index.cjs +0 -218
  120. package/node_modules/colorette/index.d.ts +0 -93
  121. package/node_modules/colorette/index.js +0 -150
  122. package/node_modules/colorette/package.json +0 -40
  123. package/node_modules/eventemitter3/LICENSE +0 -21
  124. package/node_modules/eventemitter3/README.md +0 -94
  125. package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
  126. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
  127. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
  128. package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
  129. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
  130. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
  131. package/node_modules/eventemitter3/index.d.ts +0 -135
  132. package/node_modules/eventemitter3/index.js +0 -336
  133. package/node_modules/eventemitter3/index.mjs +0 -4
  134. package/node_modules/eventemitter3/package.json +0 -67
  135. package/node_modules/figures/index.d.ts +0 -279
  136. package/node_modules/figures/index.js +0 -292
  137. package/node_modules/figures/package.json +0 -49
  138. package/node_modules/figures/readme.md +0 -337
  139. package/node_modules/listr2/dist/index.cjs +0 -2189
  140. package/node_modules/listr2/dist/index.d.ts +0 -1528
  141. package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
  142. package/node_modules/rfdc/LICENSE +0 -15
  143. package/node_modules/rfdc/default.js +0 -3
  144. package/node_modules/rfdc/index.d.ts +0 -13
  145. package/node_modules/rfdc/index.js +0 -198
  146. package/node_modules/rfdc/index.test-d.ts +0 -13
  147. package/node_modules/rfdc/package.json +0 -73
  148. package/node_modules/rfdc/readme.md +0 -181
  149. package/node_modules/rfdc/test/index.js +0 -306
  150. package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
  151. package/node_modules/smol-toml/dist/date.js.map +0 -1
  152. package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
  153. package/node_modules/smol-toml/dist/error.js.map +0 -1
  154. package/node_modules/smol-toml/dist/extract.js.map +0 -1
  155. package/node_modules/smol-toml/dist/index.cjs.map +0 -1
  156. package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
  157. package/node_modules/smol-toml/dist/index.js.map +0 -1
  158. package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
  159. package/node_modules/smol-toml/dist/parse.js.map +0 -1
  160. package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
  161. package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
  162. package/node_modules/smol-toml/dist/primitive.js.map +0 -1
  163. package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
  164. package/node_modules/smol-toml/dist/stringify.js.map +0 -1
  165. package/node_modules/smol-toml/dist/struct.js.map +0 -1
  166. package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
  167. package/node_modules/smol-toml/dist/util.js.map +0 -1
  168. package/node_modules/smol-toml/src/date.ts +0 -152
  169. package/node_modules/smol-toml/src/error.ts +0 -77
  170. package/node_modules/smol-toml/src/extract.ts +0 -113
  171. package/node_modules/smol-toml/src/index.ts +0 -42
  172. package/node_modules/smol-toml/src/parse.ts +0 -184
  173. package/node_modules/smol-toml/src/primitive.ts +0 -249
  174. package/node_modules/smol-toml/src/stringify.ts +0 -191
  175. package/node_modules/smol-toml/src/struct.ts +0 -202
  176. package/node_modules/smol-toml/src/util.ts +0 -106
  177. /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
  178. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
  179. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
  180. /package/node_modules/{chalk → ansi-escapes}/license +0 -0
  181. /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
  182. /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
@@ -41,4 +41,3 @@ export { parse, stringify, TomlDate, TomlError };
41
41
  export type {
42
42
  /** @deprecated use TomlValue instead */
43
43
  TomlValue as TomlPrimitive, } from './util.js';
44
- //# sourceMappingURL=index.d.ts.map
@@ -31,4 +31,3 @@ import { TomlDate } from './date.js';
31
31
  import { TomlError } from './error.js';
32
32
  export default { parse, stringify, TomlDate, TomlError };
33
33
  export { parse, stringify, TomlDate, TomlError };
34
- //# sourceMappingURL=index.js.map
@@ -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 { IntegersAsBigInt } from './primitive.js';
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
- for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
101
- if (toml[ptr] === '[') {
102
- let isTableArray = toml[++ptr] === '[';
103
- let k = parseKey(toml, (ptr += +isTableArray), ']');
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[k[1] - 1] !== ']') {
109
+ if (toml.charCodeAt(ctx.p - 1) !== 0x5d /* ] */) {
106
110
  throw new TomlError('expected end of table declaration', {
107
111
  toml: toml,
108
- ptr: k[1] - 1,
112
+ ptr: ctx.p - 1,
109
113
  });
110
114
  }
111
- k[1]++;
115
+ ctx.p++;
112
116
  }
113
- let p = peekTable(k[0], res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
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: 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
- let k = parseKey(toml, ptr);
126
- let p = peekTable(k[0], tbl, m, 0 /* Type.DOTTED */);
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: ptr,
134
+ ptr: tmp,
131
135
  });
132
136
  }
133
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
134
- p[1][p[0]] = v[0];
135
- ptr = v[1];
137
+ p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
136
138
  }
137
- ptr = skipVoid(toml, ptr, true);
138
- if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') {
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: ptr,
143
+ ptr: ctx.p,
142
144
  });
143
145
  }
144
- ptr = skipVoid(toml, ptr);
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(str, ptr) {
36
- let c = str[ptr++];
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 === str[ptr] && c === str[ptr + 1];
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 (str[ptr += 2] === '\n')
43
- ptr++;
44
- else if (str[ptr] === '\r' && str[ptr + 1] === '\n')
45
- ptr += 2;
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 = ptr;
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 (let i = ptr; i < str.length; i++) {
87
- c = str[i];
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 === '\n' || (c === '\r' && str[i + 1] === '\n'))) {
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 < '\x20' && c !== '\t') || c === '\x7f') {
95
+ else if ((c < 0x20 && c !== 0x9 /* \t */) || c === 0x7f) {
94
96
  throw new TomlError('control characters are not allowed in strings', {
95
- toml: str,
96
- ptr: i,
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 || (str[i + 1] === first && str[i + 2] === first))) {
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 (str[i + 3] === first)
105
- i++;
106
- if (str[i + 3] === first)
107
- i++;
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
- return [
110
- // If we're in a newline escape still, then there's nothing to add.
111
- // Also try to avoid concat if there's nothing to add to parsed, or nothing has been added to parsed.
112
- state ? parsed : parsed + str.slice(sliceStart, i),
113
- i + (isMultiline ? 3 : 1),
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 += str.slice(sliceStart, (sliceStart = i));
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 === 'x' || c === 'u' || c === 'U') { // Unicode escape
124
+ if (c === 0x78 /* x */ || c === 0x75 /* u */ || c === 0x55 /* U */) { // Unicode escape
124
125
  let value = 0;
125
- let len = c === 'x' ? 2 : c === 'u' ? 4 : 8;
126
- for (let j = 0; j < len; j++, i++) {
127
- let hex = str.charCodeAt(i + 1);
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: str, ptr: i + 1 });
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: str, ptr: i });
139
+ throw new TomlError('invalid unicode escape', { toml: ctx.s, ptr: ctx.p });
139
140
  }
140
141
  parsed += String.fromCodePoint(value);
141
- sliceStart = i + 1;
142
+ sliceStart = ctx.p + 1;
142
143
  state = 0;
143
144
  }
144
- else if (c === ' ' || c === '\t') { // If it was a newline, it'd have been handled earlier
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 === 'b')
149
+ if (c === 0x62 /* b */)
149
150
  parsed += '\b';
150
- else if (c === 't')
151
+ else if (c === 0x74 /* t */)
151
152
  parsed += '\t';
152
- else if (c === 'n')
153
+ else if (c === 0x6e /* n */)
153
154
  parsed += '\n';
154
- else if (c === 'f')
155
+ else if (c === 0x66 /* f */)
155
156
  parsed += '\f';
156
- else if (c === 'r')
157
+ else if (c === 0x72 /* r */)
157
158
  parsed += '\r';
158
- else if (c === 'e')
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: str, ptr: i });
166
- sliceStart = i + 1;
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 !== ' ' && c !== '\t') {
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: str,
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 === '\\' ? 1 : 0;
180
- sliceStart = i;
180
+ state = !isLiteral && c === 0x5c /* \ */ ? 1 : 0;
181
+ sliceStart = ctx.p;
181
182
  }
182
183
  }
183
- throw new TomlError('unfinished string', { toml: str, ptr });
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(value, toml, ptr, integersAsBigInt) {
187
- // Constant values
188
- if (value === 'true')
189
- return true;
190
- if (value === 'false')
191
- return false;
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
@@ -29,4 +29,3 @@ export declare function stringify(obj: any, { maxDepth, numbersAsFloat }?: {
29
29
  maxDepth?: number;
30
30
  numbersAsFloat?: boolean;
31
31
  }): string;
32
- //# sourceMappingURL=stringify.d.ts.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
- if (type === 'number') {
54
- if (isNaN(val))
55
- return 'nan';
56
- if (val === Infinity)
57
- return 'inf';
58
- if (val === -Infinity)
59
- return '-inf';
60
- if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
61
- return val.toFixed(1);
62
- return val.toString();
63
- }
64
- if (type === 'bigint' || type === 'boolean') {
65
- return val.toString();
66
- }
67
- if (type === 'string') {
68
- return formatString(val);
69
- }
70
- if (type === 'date') {
71
- if (isNaN(val.getTime())) {
72
- throw new TypeError('cannot serialize invalid date');
73
- }
74
- return val.toISOString();
75
- }
76
- if (type === 'object') {
77
- return stringifyInlineTable(val, depth, numberAsFloat);
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