@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
@@ -1,152 +0,0 @@
1
- /*!
2
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3
- * SPDX-License-Identifier: BSD-3-Clause
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of the copyright holder nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software without
15
- * specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
- // Hopefully this class will disappear once Temporal lands in JS
30
- // But for now we have to reinvent the wheel once more!
31
-
32
- type Offset = string | null
33
-
34
- let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i
35
-
36
- export class TomlDate extends Date {
37
- #hasDate = false
38
- #hasTime = false
39
- #offset: Offset = null
40
-
41
- constructor(date: string | Date) {
42
- let hasDate = true
43
- let hasTime = true
44
- let offset: Offset = 'Z'
45
-
46
- if (typeof date === 'string') {
47
- let match = date.match(DATE_TIME_RE)
48
- if (match) {
49
- if (!match[1]) {
50
- hasDate = false
51
- date = `0000-01-01T${date}`
52
- }
53
-
54
- hasTime = !!match[2]
55
- // Make sure to use T instead of a space. Breaks in case of extreme values otherwise.
56
- hasTime && date[10] === ' ' && (date = date.replace(' ', 'T'))
57
- // Do not allow rollover hours.
58
- if (match[2] && +match[2] > 23) {
59
- date = ''
60
- } else {
61
- offset = match[3] || null
62
- date = date.toUpperCase()
63
- if (!offset && hasTime) date += 'Z'
64
- }
65
- } else {
66
- date = ''
67
- }
68
- }
69
-
70
- super(date)
71
- if (!isNaN(this.getTime())) {
72
- this.#hasDate = hasDate
73
- this.#hasTime = hasTime
74
- this.#offset = offset
75
- }
76
- }
77
-
78
- isDateTime() {
79
- return this.#hasDate && this.#hasTime
80
- }
81
-
82
- isLocal() {
83
- return !this.#hasDate || !this.#hasTime || !this.#offset
84
- }
85
-
86
- isDate() {
87
- return this.#hasDate && !this.#hasTime
88
- }
89
-
90
- isTime() {
91
- return this.#hasTime && !this.#hasDate
92
- }
93
-
94
- isValid() {
95
- return this.#hasDate || this.#hasTime
96
- }
97
-
98
- override toISOString() {
99
- let iso = super.toISOString()
100
-
101
- // Local Date
102
- if (this.isDate())
103
- return iso.slice(0, 10)
104
-
105
- // Local Time
106
- if (this.isTime())
107
- return iso.slice(11, 23)
108
-
109
- // Local DateTime
110
- if (this.#offset === null)
111
- return iso.slice(0, -1)
112
-
113
- // Offset DateTime
114
- if (this.#offset === 'Z')
115
- return iso
116
-
117
- // This part is quite annoying: JS strips the original timezone from the ISO string representation
118
- // Instead of using a "modified" date and "Z", we restore the representation "as authored"
119
-
120
- let offset = (+(this.#offset.slice(1, 3)) * 60) + +(this.#offset.slice(4, 6))
121
- offset = this.#offset[0] === '-' ? offset : -offset
122
-
123
- let offsetDate = new Date(this.getTime() - (offset * 60e3))
124
- return offsetDate.toISOString().slice(0, -1) + this.#offset
125
- }
126
-
127
- static wrapAsOffsetDateTime(jsDate: Date, offset = 'Z') {
128
- let date = new TomlDate(jsDate)
129
- date.#offset = offset
130
- return date
131
- }
132
-
133
- static wrapAsLocalDateTime(jsDate: Date) {
134
- let date = new TomlDate(jsDate)
135
- date.#offset = null
136
- return date
137
- }
138
-
139
- static wrapAsLocalDate(jsDate: Date) {
140
- let date = new TomlDate(jsDate)
141
- date.#hasTime = false
142
- date.#offset = null
143
- return date
144
- }
145
-
146
- static wrapAsLocalTime(jsDate: Date) {
147
- let date = new TomlDate(jsDate)
148
- date.#hasDate = false
149
- date.#offset = null
150
- return date
151
- }
152
- }
@@ -1,77 +0,0 @@
1
- /*!
2
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3
- * SPDX-License-Identifier: BSD-3-Clause
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of the copyright holder nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software without
15
- * specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
- type TomlErrorOptions = ErrorOptions & {
30
- toml: string
31
- ptr: number
32
- }
33
-
34
- function getLineColFromPtr(string: string, ptr: number): [number, number] {
35
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g)
36
- return [lines.length, lines.pop()!.length + 1]
37
- }
38
-
39
- function makeCodeBlock(string: string, line: number, column: number) {
40
- let lines = string.split(/\r\n|\n|\r/g)
41
- let codeblock = ''
42
-
43
- let numberLen = (Math.log10(line + 1) | 0) + 1
44
-
45
- for (let i = line - 1; i <= line + 1; i++) {
46
- let l = lines[i - 1]
47
- if (!l) continue
48
-
49
- codeblock += i.toString().padEnd(numberLen, ' ')
50
- codeblock += ': '
51
- codeblock += l
52
- codeblock += '\n'
53
-
54
- if (i === line) {
55
- codeblock += ' '.repeat(numberLen + column + 2)
56
- codeblock += '^\n'
57
- }
58
- }
59
-
60
- return codeblock
61
- }
62
-
63
- export class TomlError extends Error {
64
- line: number
65
- column: number
66
- codeblock: string
67
-
68
- constructor(message: string, options: TomlErrorOptions) {
69
- const [line, column] = getLineColFromPtr(options.toml, options.ptr)
70
- const codeblock = makeCodeBlock(options.toml, line, column)
71
-
72
- super(`Invalid TOML document: ${message}\n\n${codeblock}`, options)
73
- this.line = line
74
- this.column = column
75
- this.codeblock = codeblock
76
- }
77
- }
@@ -1,113 +0,0 @@
1
- /*!
2
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3
- * SPDX-License-Identifier: BSD-3-Clause
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of the copyright holder nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software without
15
- * specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
- import { type IntegersAsBigInt, parseString, parseValue } from './primitive.js'
30
- import { parseArray, parseInlineTable } from './struct.js'
31
- import { skipVoid, skipUntil, skipComment, type TomlValue } from './util.js'
32
- import { TomlError } from './error.js'
33
-
34
- function sliceAndTrimEndOf(str: string, startPtr: number, endPtr: number): [string, number] {
35
- let value = str.slice(startPtr, endPtr)
36
-
37
- let commentIdx = value.indexOf('#')
38
- if (commentIdx > -1) {
39
- // The call to skipComment allows to "validate" the comment
40
- // (absence of control characters)
41
- skipComment(str, commentIdx)
42
- value = value.slice(0, commentIdx)
43
- }
44
-
45
- return [value.trimEnd(), commentIdx]
46
- }
47
-
48
- /** @internal */
49
- export function extractValue(str: string, ptr: number, end: string | undefined, depth: number, integersAsBigInt: IntegersAsBigInt): [TomlValue, number] {
50
- if (depth === 0) {
51
- throw new TomlError('document contains excessively nested structures. aborting.', {
52
- toml: str,
53
- ptr: ptr,
54
- })
55
- }
56
-
57
- let c = str[ptr]
58
- if (c === '[' || c === '{') {
59
- let [value, endPtr] = c === '['
60
- ? parseArray(str, ptr, depth, integersAsBigInt)
61
- : parseInlineTable(str, ptr, depth, integersAsBigInt)
62
-
63
- if (end) {
64
- endPtr = skipVoid(str, endPtr)
65
- if (str[endPtr] === ',') endPtr++
66
- else if (str[endPtr] !== end) {
67
- throw new TomlError('expected comma or end of structure', {
68
- toml: str,
69
- ptr: endPtr,
70
- })
71
- }
72
- }
73
-
74
- return [value, endPtr]
75
- }
76
-
77
- if (c === '"' || c === "'") {
78
- let [parsed, endPtr] = parseString(str, ptr)
79
- if (end) {
80
- endPtr = skipVoid(str, endPtr)
81
-
82
- if (str[endPtr] && str[endPtr] !== ',' && str[endPtr] !== end && str[endPtr] !== '\n' && str[endPtr] !== '\r') {
83
- throw new TomlError('unexpected character encountered', {
84
- toml: str,
85
- ptr: endPtr,
86
- })
87
- }
88
-
89
- if (str[endPtr] === ',') endPtr++
90
- }
91
-
92
- return [parsed, endPtr]
93
- }
94
-
95
- let endPtr = skipUntil(str, ptr, ',', end)
96
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === ',' ? 1 : 0))
97
- if (!slice[0]) {
98
- throw new TomlError('incomplete key-value declaration: no value specified', {
99
- toml: str,
100
- ptr: ptr,
101
- })
102
- }
103
-
104
- if (end && slice[1] > -1) {
105
- endPtr = skipVoid(str, ptr + slice[1])
106
- if (str[endPtr] === ',') endPtr++
107
- }
108
-
109
- return [
110
- parseValue(slice[0], str, ptr, integersAsBigInt),
111
- endPtr,
112
- ]
113
- }
@@ -1,42 +0,0 @@
1
- /*!
2
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3
- * SPDX-License-Identifier: BSD-3-Clause
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of the copyright holder nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software without
15
- * specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
- import { parse } from './parse.js'
30
- import { stringify } from './stringify.js'
31
-
32
- import { TomlDate } from './date.js'
33
- import { TomlError } from './error.js'
34
-
35
- export type { TomlValue, TomlTable, TomlValueWithoutBigInt, TomlTableWithoutBigInt } from './util.js'
36
- export default { parse, stringify, TomlDate, TomlError }
37
- export { parse, stringify, TomlDate, TomlError }
38
-
39
- export type {
40
- /** @deprecated use TomlValue instead */
41
- TomlValue as TomlPrimitive,
42
- } from './util.js'
@@ -1,184 +0,0 @@
1
- /*!
2
- * Copyright (c) Squirrel Chat et al., All rights reserved.
3
- * SPDX-License-Identifier: BSD-3-Clause
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- * 2. Redistributions in binary form must reproduce the above copyright notice,
11
- * this list of conditions and the following disclaimer in the
12
- * documentation and/or other materials provided with the distribution.
13
- * 3. Neither the name of the copyright holder nor the names of its contributors
14
- * may be used to endorse or promote products derived from this software without
15
- * specific prior written permission.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */
28
-
29
- import type { IntegersAsBigInt } from './primitive.js'
30
- import { parseKey } from './struct.js'
31
- import { extractValue } from './extract.js'
32
- import { skipVoid, type TomlTable, type TomlTableWithoutBigInt } from './util.js'
33
- import { TomlError } from './error.js'
34
-
35
- const enum Type { DOTTED, EXPLICIT, ARRAY, ARRAY_DOTTED }
36
-
37
- type MetaState = { t: Type; d: boolean; i: number; c: MetaRecord }
38
- type MetaRecord = { [k: string]: MetaState }
39
- type PeekResult = [string, TomlTable, MetaRecord] | null
40
-
41
- function peekTable(key: string[], table: TomlTable, meta: MetaRecord, type: Type): PeekResult {
42
- let t: any = table
43
- let m = meta
44
- let k: string
45
- let hasOwn = false
46
- let state: MetaState
47
-
48
- for (let i = 0; i < key.length; i++) {
49
- if (i) {
50
- t = hasOwn! ? t[k!] : (t[k!] = {})
51
- m = (state = m[k!]!).c
52
-
53
- if (type === Type.DOTTED && (state.t === Type.EXPLICIT || state.t === Type.ARRAY)) {
54
- return null
55
- }
56
-
57
- if (state.t === Type.ARRAY) {
58
- let l = t.length - 1
59
- t = t[l]
60
- m = m[l]!.c
61
- }
62
- }
63
-
64
- k = key[i]!
65
- if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === Type.DOTTED && m[k]?.d) {
66
- return null
67
- }
68
-
69
- if (!hasOwn) {
70
- if (k === '__proto__') {
71
- Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true })
72
- Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true })
73
- }
74
-
75
- m[k] = {
76
- t: i < key.length - 1 && type === Type.ARRAY
77
- ? Type.ARRAY_DOTTED
78
- : type,
79
- d: false,
80
- i: 0,
81
- c: {},
82
- }
83
- }
84
- }
85
-
86
- state = m[k!]!
87
- if (state.t !== type && !(type === Type.EXPLICIT && state.t === Type.ARRAY_DOTTED)) {
88
- // Bad key type!
89
- return null
90
- }
91
-
92
- if (type === Type.ARRAY) {
93
- if (!state.d) {
94
- state.d = true
95
- t[k!] = []
96
- }
97
-
98
- t[k!].push(t = {})
99
- state.c[state.i++] = (state = { t: Type.EXPLICIT, d: false, i: 0, c: {} })
100
- }
101
-
102
- if (state.d) {
103
- // Redefining a table!
104
- return null
105
- }
106
-
107
- state.d = true
108
- if (type === Type.EXPLICIT) {
109
- t = hasOwn ? t[k!] : (t[k!] = {})
110
- } else if (type === Type.DOTTED && hasOwn) {
111
- return null
112
- }
113
-
114
- return [k!, t, state.c]
115
- }
116
-
117
- export interface ParseOptions {
118
- maxDepth?: number
119
- integersAsBigInt?: IntegersAsBigInt
120
- }
121
-
122
- export function parse(toml: string, options?: ParseOptions & { integersAsBigInt: Exclude<IntegersAsBigInt, undefined | false> }): TomlTable
123
- export function parse(toml: string, options?: ParseOptions): TomlTableWithoutBigInt
124
- export function parse(toml: string, { maxDepth = 1000, integersAsBigInt }: ParseOptions = {}): TomlTable {
125
- let res = {}
126
- let meta = {}
127
-
128
- let tbl = res
129
- let m = meta
130
-
131
- for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
132
- if (toml[ptr] === '[') {
133
- let isTableArray = toml[++ptr] === '['
134
- let k = parseKey(toml, (ptr += +isTableArray), ']')
135
-
136
- if (isTableArray) {
137
- if (toml[k[1] - 1] !== ']') {
138
- throw new TomlError('expected end of table declaration', {
139
- toml: toml,
140
- ptr: k[1] - 1,
141
- })
142
- }
143
-
144
- k[1]++
145
- }
146
-
147
- let p = peekTable(k[0], res, meta, isTableArray ? Type.ARRAY : Type.EXPLICIT)
148
- if (!p) {
149
- throw new TomlError('trying to redefine an already defined table or value', {
150
- toml: toml,
151
- ptr: ptr,
152
- })
153
- }
154
-
155
- m = p[2]
156
- tbl = p[1]
157
- ptr = k[1]
158
- } else {
159
- let k = parseKey(toml, ptr)
160
- let p = peekTable(k[0], tbl, m, Type.DOTTED)
161
- if (!p) {
162
- throw new TomlError('trying to redefine an already defined table or value', {
163
- toml: toml,
164
- ptr: ptr,
165
- })
166
- }
167
-
168
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt)
169
- p[1][p[0]] = v[0]
170
- ptr = v[1]
171
- }
172
-
173
- ptr = skipVoid(toml, ptr, true)
174
- if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') {
175
- throw new TomlError('each key-value declaration must be followed by an end-of-line', {
176
- toml: toml,
177
- ptr: ptr,
178
- })
179
- }
180
- ptr = skipVoid(toml, ptr)
181
- }
182
-
183
- return res
184
- }