@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.
Files changed (232) hide show
  1. package/components/metadata.js +2 -1
  2. package/lib/ci/build-types/test_build.js +3 -3
  3. package/lib/ci/failure_aggregator.js +2 -2
  4. package/lib/ci/run_ci.js +3 -2
  5. package/lib/cli.js +6 -6
  6. package/lib/figures.js +6 -6
  7. package/lib/prepare_security.js +20 -21
  8. package/lib/request.js +1 -1
  9. package/lib/update-v8/backport.js +3 -4
  10. package/lib/utils.js +4 -2
  11. package/lib/verbosity.js +2 -4
  12. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
  13. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
  14. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
  15. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
  16. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
  17. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
  18. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
  19. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
  20. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
  21. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
  22. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
  23. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
  24. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
  25. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
  26. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
  27. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
  28. package/node_modules/ansi-regex/index.js +9 -4
  29. package/node_modules/ansi-regex/package.json +1 -1
  30. package/node_modules/ansi-regex/readme.md +6 -0
  31. package/node_modules/ansi-styles/index.d.ts +12 -12
  32. package/node_modules/ansi-styles/index.js +3 -3
  33. package/node_modules/ansi-styles/package.json +4 -4
  34. package/node_modules/cli-truncate/index.d.ts +3 -3
  35. package/node_modules/cli-truncate/index.js +40 -14
  36. package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
  37. package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
  38. package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
  39. package/node_modules/cli-truncate/package.json +7 -7
  40. package/node_modules/cli-truncate/readme.md +2 -3
  41. package/node_modules/ghauth/.github/dependabot.yml +11 -3
  42. package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
  43. package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
  44. package/node_modules/ghauth/CHANGELOG.md +60 -0
  45. package/node_modules/ghauth/package.json +30 -6
  46. package/node_modules/js-yaml/README.md +20 -187
  47. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
  48. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
  49. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
  50. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
  51. package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
  52. package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
  53. package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
  54. package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
  55. package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
  56. package/node_modules/js-yaml/package.json +8 -7
  57. package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
  58. package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
  59. package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
  60. package/node_modules/listr2/node_modules/string-width/index.js +207 -0
  61. package/node_modules/listr2/node_modules/string-width/package.json +65 -0
  62. package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
  63. package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
  64. package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
  65. package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
  66. package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
  67. package/node_modules/listr2/package.json +16 -19
  68. package/node_modules/log-update/index.d.ts +64 -1
  69. package/node_modules/log-update/index.js +268 -18
  70. package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
  71. package/node_modules/log-update/node_modules/string-width/index.js +207 -0
  72. package/node_modules/log-update/node_modules/string-width/package.json +65 -0
  73. package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
  74. package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
  75. package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
  76. package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
  77. package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
  78. package/node_modules/log-update/package.json +14 -12
  79. package/node_modules/log-update/readme.md +61 -0
  80. package/node_modules/slice-ansi/index.d.ts +2 -2
  81. package/node_modules/slice-ansi/index.js +260 -112
  82. package/node_modules/slice-ansi/package.json +10 -9
  83. package/node_modules/slice-ansi/readme.md +3 -2
  84. package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  85. package/node_modules/smol-toml/README.md +205 -191
  86. package/node_modules/smol-toml/dist/date.d.ts +0 -1
  87. package/node_modules/smol-toml/dist/date.js +0 -1
  88. package/node_modules/smol-toml/dist/error.d.ts +0 -1
  89. package/node_modules/smol-toml/dist/error.js +0 -1
  90. package/node_modules/smol-toml/dist/extract.js +32 -65
  91. package/node_modules/smol-toml/dist/index.cjs +302 -288
  92. package/node_modules/smol-toml/dist/index.d.ts +0 -1
  93. package/node_modules/smol-toml/dist/index.js +0 -1
  94. package/node_modules/smol-toml/dist/parse.d.ts +1 -3
  95. package/node_modules/smol-toml/dist/parse.js +22 -21
  96. package/node_modules/smol-toml/dist/primitive.js +75 -76
  97. package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
  98. package/node_modules/smol-toml/dist/stringify.js +43 -30
  99. package/node_modules/smol-toml/dist/struct.js +90 -93
  100. package/node_modules/smol-toml/dist/util.d.ts +1 -1
  101. package/node_modules/smol-toml/dist/util.js +36 -39
  102. package/node_modules/smol-toml/package.json +6 -6
  103. package/node_modules/strip-ansi/index.js +5 -0
  104. package/node_modules/strip-ansi/package.json +5 -5
  105. package/package.json +3 -9
  106. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
  107. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
  108. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
  109. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
  110. package/node_modules/chalk/package.json +0 -92
  111. package/node_modules/chalk/readme.md +0 -331
  112. package/node_modules/chalk/source/index.d.ts +0 -437
  113. package/node_modules/chalk/source/index.js +0 -261
  114. package/node_modules/chalk/source/utilities.js +0 -33
  115. package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
  116. package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
  117. package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
  118. package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
  119. package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
  120. package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
  121. package/node_modules/colorette/LICENSE.md +0 -7
  122. package/node_modules/colorette/README.md +0 -134
  123. package/node_modules/colorette/index.cjs +0 -218
  124. package/node_modules/colorette/index.d.ts +0 -93
  125. package/node_modules/colorette/index.js +0 -150
  126. package/node_modules/colorette/package.json +0 -40
  127. package/node_modules/eventemitter3/LICENSE +0 -21
  128. package/node_modules/eventemitter3/README.md +0 -94
  129. package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
  130. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
  131. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
  132. package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
  133. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
  134. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
  135. package/node_modules/eventemitter3/index.d.ts +0 -135
  136. package/node_modules/eventemitter3/index.js +0 -336
  137. package/node_modules/eventemitter3/index.mjs +0 -4
  138. package/node_modules/eventemitter3/package.json +0 -67
  139. package/node_modules/figures/index.d.ts +0 -279
  140. package/node_modules/figures/index.js +0 -292
  141. package/node_modules/figures/package.json +0 -49
  142. package/node_modules/figures/readme.md +0 -337
  143. package/node_modules/isexe/LICENSE.md +0 -55
  144. package/node_modules/isexe/README.md +0 -80
  145. package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
  146. package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
  147. package/node_modules/isexe/dist/commonjs/index.js +0 -56
  148. package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
  149. package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
  150. package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
  151. package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
  152. package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
  153. package/node_modules/isexe/dist/commonjs/options.js +0 -3
  154. package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
  155. package/node_modules/isexe/dist/commonjs/package.json +0 -3
  156. package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
  157. package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
  158. package/node_modules/isexe/dist/commonjs/posix.js +0 -67
  159. package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
  160. package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
  161. package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
  162. package/node_modules/isexe/dist/commonjs/win32.js +0 -63
  163. package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
  164. package/node_modules/isexe/dist/esm/index.d.ts +0 -14
  165. package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
  166. package/node_modules/isexe/dist/esm/index.js +0 -16
  167. package/node_modules/isexe/dist/esm/index.js.map +0 -1
  168. package/node_modules/isexe/dist/esm/index.min.js +0 -2
  169. package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
  170. package/node_modules/isexe/dist/esm/options.d.ts +0 -32
  171. package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
  172. package/node_modules/isexe/dist/esm/options.js +0 -2
  173. package/node_modules/isexe/dist/esm/options.js.map +0 -1
  174. package/node_modules/isexe/dist/esm/package.json +0 -3
  175. package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
  176. package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
  177. package/node_modules/isexe/dist/esm/posix.js +0 -62
  178. package/node_modules/isexe/dist/esm/posix.js.map +0 -1
  179. package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
  180. package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
  181. package/node_modules/isexe/dist/esm/win32.js +0 -58
  182. package/node_modules/isexe/dist/esm/win32.js.map +0 -1
  183. package/node_modules/isexe/package.json +0 -78
  184. package/node_modules/listr2/dist/index.cjs +0 -2189
  185. package/node_modules/listr2/dist/index.d.ts +0 -1528
  186. package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
  187. package/node_modules/rfdc/LICENSE +0 -15
  188. package/node_modules/rfdc/default.js +0 -3
  189. package/node_modules/rfdc/index.d.ts +0 -13
  190. package/node_modules/rfdc/index.js +0 -198
  191. package/node_modules/rfdc/index.test-d.ts +0 -13
  192. package/node_modules/rfdc/package.json +0 -73
  193. package/node_modules/rfdc/readme.md +0 -181
  194. package/node_modules/rfdc/test/index.js +0 -306
  195. package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
  196. package/node_modules/smol-toml/dist/date.js.map +0 -1
  197. package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
  198. package/node_modules/smol-toml/dist/error.js.map +0 -1
  199. package/node_modules/smol-toml/dist/extract.js.map +0 -1
  200. package/node_modules/smol-toml/dist/index.cjs.map +0 -1
  201. package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
  202. package/node_modules/smol-toml/dist/index.js.map +0 -1
  203. package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
  204. package/node_modules/smol-toml/dist/parse.js.map +0 -1
  205. package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
  206. package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
  207. package/node_modules/smol-toml/dist/primitive.js.map +0 -1
  208. package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
  209. package/node_modules/smol-toml/dist/stringify.js.map +0 -1
  210. package/node_modules/smol-toml/dist/struct.js.map +0 -1
  211. package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
  212. package/node_modules/smol-toml/dist/util.js.map +0 -1
  213. package/node_modules/smol-toml/src/date.ts +0 -152
  214. package/node_modules/smol-toml/src/error.ts +0 -77
  215. package/node_modules/smol-toml/src/extract.ts +0 -113
  216. package/node_modules/smol-toml/src/index.ts +0 -42
  217. package/node_modules/smol-toml/src/parse.ts +0 -184
  218. package/node_modules/smol-toml/src/primitive.ts +0 -249
  219. package/node_modules/smol-toml/src/stringify.ts +0 -191
  220. package/node_modules/smol-toml/src/struct.ts +0 -202
  221. package/node_modules/smol-toml/src/util.ts +0 -106
  222. package/node_modules/which/LICENSE +0 -15
  223. package/node_modules/which/README.md +0 -51
  224. package/node_modules/which/bin/which.js +0 -52
  225. package/node_modules/which/lib/index.js +0 -111
  226. package/node_modules/which/package.json +0 -52
  227. /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
  228. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
  229. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
  230. /package/node_modules/{chalk → ansi-escapes}/license +0 -0
  231. /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
  232. /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