@hyperfrontend/versioning 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/ARCHITECTURE.md +593 -0
  2. package/CHANGELOG.md +35 -0
  3. package/FUNDING.md +141 -0
  4. package/LICENSE.md +21 -0
  5. package/README.md +195 -0
  6. package/SECURITY.md +82 -0
  7. package/changelog/compare/diff.d.ts +128 -0
  8. package/changelog/compare/diff.d.ts.map +1 -0
  9. package/changelog/compare/index.cjs.js +628 -0
  10. package/changelog/compare/index.cjs.js.map +1 -0
  11. package/changelog/compare/index.d.ts +4 -0
  12. package/changelog/compare/index.d.ts.map +1 -0
  13. package/changelog/compare/index.esm.js +612 -0
  14. package/changelog/compare/index.esm.js.map +1 -0
  15. package/changelog/compare/is-equal.d.ts +114 -0
  16. package/changelog/compare/is-equal.d.ts.map +1 -0
  17. package/changelog/index.cjs.js +6448 -0
  18. package/changelog/index.cjs.js.map +1 -0
  19. package/changelog/index.d.ts +6 -0
  20. package/changelog/index.d.ts.map +1 -0
  21. package/changelog/index.esm.js +6358 -0
  22. package/changelog/index.esm.js.map +1 -0
  23. package/changelog/models/changelog.d.ts +86 -0
  24. package/changelog/models/changelog.d.ts.map +1 -0
  25. package/changelog/models/commit-ref.d.ts +51 -0
  26. package/changelog/models/commit-ref.d.ts.map +1 -0
  27. package/changelog/models/entry.d.ts +84 -0
  28. package/changelog/models/entry.d.ts.map +1 -0
  29. package/changelog/models/index.cjs.js +2043 -0
  30. package/changelog/models/index.cjs.js.map +1 -0
  31. package/changelog/models/index.d.ts +11 -0
  32. package/changelog/models/index.d.ts.map +1 -0
  33. package/changelog/models/index.esm.js +2026 -0
  34. package/changelog/models/index.esm.js.map +1 -0
  35. package/changelog/models/schema.d.ts +68 -0
  36. package/changelog/models/schema.d.ts.map +1 -0
  37. package/changelog/models/section.d.ts +25 -0
  38. package/changelog/models/section.d.ts.map +1 -0
  39. package/changelog/operations/add-entry.d.ts +56 -0
  40. package/changelog/operations/add-entry.d.ts.map +1 -0
  41. package/changelog/operations/add-item.d.ts +18 -0
  42. package/changelog/operations/add-item.d.ts.map +1 -0
  43. package/changelog/operations/filter-by-predicate.d.ts +81 -0
  44. package/changelog/operations/filter-by-predicate.d.ts.map +1 -0
  45. package/changelog/operations/filter-by-range.d.ts +63 -0
  46. package/changelog/operations/filter-by-range.d.ts.map +1 -0
  47. package/changelog/operations/filter-entries.d.ts +9 -0
  48. package/changelog/operations/filter-entries.d.ts.map +1 -0
  49. package/changelog/operations/index.cjs.js +2455 -0
  50. package/changelog/operations/index.cjs.js.map +1 -0
  51. package/changelog/operations/index.d.ts +15 -0
  52. package/changelog/operations/index.d.ts.map +1 -0
  53. package/changelog/operations/index.esm.js +2411 -0
  54. package/changelog/operations/index.esm.js.map +1 -0
  55. package/changelog/operations/merge.d.ts +88 -0
  56. package/changelog/operations/merge.d.ts.map +1 -0
  57. package/changelog/operations/remove-entry.d.ts +45 -0
  58. package/changelog/operations/remove-entry.d.ts.map +1 -0
  59. package/changelog/operations/remove-section.d.ts +50 -0
  60. package/changelog/operations/remove-section.d.ts.map +1 -0
  61. package/changelog/operations/transform.d.ts +143 -0
  62. package/changelog/operations/transform.d.ts.map +1 -0
  63. package/changelog/parse/index.cjs.js +1282 -0
  64. package/changelog/parse/index.cjs.js.map +1 -0
  65. package/changelog/parse/index.d.ts +5 -0
  66. package/changelog/parse/index.d.ts.map +1 -0
  67. package/changelog/parse/index.esm.js +1275 -0
  68. package/changelog/parse/index.esm.js.map +1 -0
  69. package/changelog/parse/line.d.ts +48 -0
  70. package/changelog/parse/line.d.ts.map +1 -0
  71. package/changelog/parse/parser.d.ts +16 -0
  72. package/changelog/parse/parser.d.ts.map +1 -0
  73. package/changelog/parse/tokenizer.d.ts +49 -0
  74. package/changelog/parse/tokenizer.d.ts.map +1 -0
  75. package/changelog/serialize/index.cjs.js +574 -0
  76. package/changelog/serialize/index.cjs.js.map +1 -0
  77. package/changelog/serialize/index.d.ts +6 -0
  78. package/changelog/serialize/index.d.ts.map +1 -0
  79. package/changelog/serialize/index.esm.js +564 -0
  80. package/changelog/serialize/index.esm.js.map +1 -0
  81. package/changelog/serialize/templates.d.ts +81 -0
  82. package/changelog/serialize/templates.d.ts.map +1 -0
  83. package/changelog/serialize/to-json.d.ts +57 -0
  84. package/changelog/serialize/to-json.d.ts.map +1 -0
  85. package/changelog/serialize/to-string.d.ts +30 -0
  86. package/changelog/serialize/to-string.d.ts.map +1 -0
  87. package/commits/index.cjs.js +648 -0
  88. package/commits/index.cjs.js.map +1 -0
  89. package/commits/index.d.ts +3 -0
  90. package/commits/index.d.ts.map +1 -0
  91. package/commits/index.esm.js +629 -0
  92. package/commits/index.esm.js.map +1 -0
  93. package/commits/models/breaking.d.ts +39 -0
  94. package/commits/models/breaking.d.ts.map +1 -0
  95. package/commits/models/commit-type.d.ts +32 -0
  96. package/commits/models/commit-type.d.ts.map +1 -0
  97. package/commits/models/conventional.d.ts +49 -0
  98. package/commits/models/conventional.d.ts.map +1 -0
  99. package/commits/models/index.cjs.js +207 -0
  100. package/commits/models/index.cjs.js.map +1 -0
  101. package/commits/models/index.d.ts +7 -0
  102. package/commits/models/index.d.ts.map +1 -0
  103. package/commits/models/index.esm.js +193 -0
  104. package/commits/models/index.esm.js.map +1 -0
  105. package/commits/parse/body.d.ts +18 -0
  106. package/commits/parse/body.d.ts.map +1 -0
  107. package/commits/parse/footer.d.ts +16 -0
  108. package/commits/parse/footer.d.ts.map +1 -0
  109. package/commits/parse/header.d.ts +15 -0
  110. package/commits/parse/header.d.ts.map +1 -0
  111. package/commits/parse/index.cjs.js +505 -0
  112. package/commits/parse/index.cjs.js.map +1 -0
  113. package/commits/parse/index.d.ts +5 -0
  114. package/commits/parse/index.d.ts.map +1 -0
  115. package/commits/parse/index.esm.js +499 -0
  116. package/commits/parse/index.esm.js.map +1 -0
  117. package/commits/parse/message.d.ts +17 -0
  118. package/commits/parse/message.d.ts.map +1 -0
  119. package/commits/utils/replace-char.d.ts +19 -0
  120. package/commits/utils/replace-char.d.ts.map +1 -0
  121. package/flow/executor/execute.d.ts +72 -0
  122. package/flow/executor/execute.d.ts.map +1 -0
  123. package/flow/executor/index.cjs.js +4402 -0
  124. package/flow/executor/index.cjs.js.map +1 -0
  125. package/flow/executor/index.d.ts +3 -0
  126. package/flow/executor/index.d.ts.map +1 -0
  127. package/flow/executor/index.esm.js +4398 -0
  128. package/flow/executor/index.esm.js.map +1 -0
  129. package/flow/factory.d.ts +58 -0
  130. package/flow/factory.d.ts.map +1 -0
  131. package/flow/index.cjs.js +8506 -0
  132. package/flow/index.cjs.js.map +1 -0
  133. package/flow/index.d.ts +7 -0
  134. package/flow/index.d.ts.map +1 -0
  135. package/flow/index.esm.js +8451 -0
  136. package/flow/index.esm.js.map +1 -0
  137. package/flow/models/flow.d.ts +130 -0
  138. package/flow/models/flow.d.ts.map +1 -0
  139. package/flow/models/index.cjs.js +285 -0
  140. package/flow/models/index.cjs.js.map +1 -0
  141. package/flow/models/index.d.ts +7 -0
  142. package/flow/models/index.d.ts.map +1 -0
  143. package/flow/models/index.esm.js +268 -0
  144. package/flow/models/index.esm.js.map +1 -0
  145. package/flow/models/step.d.ts +108 -0
  146. package/flow/models/step.d.ts.map +1 -0
  147. package/flow/models/types.d.ts +150 -0
  148. package/flow/models/types.d.ts.map +1 -0
  149. package/flow/presets/conventional.d.ts +59 -0
  150. package/flow/presets/conventional.d.ts.map +1 -0
  151. package/flow/presets/independent.d.ts +61 -0
  152. package/flow/presets/independent.d.ts.map +1 -0
  153. package/flow/presets/index.cjs.js +3903 -0
  154. package/flow/presets/index.cjs.js.map +1 -0
  155. package/flow/presets/index.d.ts +4 -0
  156. package/flow/presets/index.d.ts.map +1 -0
  157. package/flow/presets/index.esm.js +3889 -0
  158. package/flow/presets/index.esm.js.map +1 -0
  159. package/flow/presets/synced.d.ts +65 -0
  160. package/flow/presets/synced.d.ts.map +1 -0
  161. package/flow/steps/analyze-commits.d.ts +19 -0
  162. package/flow/steps/analyze-commits.d.ts.map +1 -0
  163. package/flow/steps/calculate-bump.d.ts +27 -0
  164. package/flow/steps/calculate-bump.d.ts.map +1 -0
  165. package/flow/steps/create-commit.d.ts +16 -0
  166. package/flow/steps/create-commit.d.ts.map +1 -0
  167. package/flow/steps/create-tag.d.ts +22 -0
  168. package/flow/steps/create-tag.d.ts.map +1 -0
  169. package/flow/steps/fetch-registry.d.ts +19 -0
  170. package/flow/steps/fetch-registry.d.ts.map +1 -0
  171. package/flow/steps/generate-changelog.d.ts +25 -0
  172. package/flow/steps/generate-changelog.d.ts.map +1 -0
  173. package/flow/steps/index.cjs.js +3523 -0
  174. package/flow/steps/index.cjs.js.map +1 -0
  175. package/flow/steps/index.d.ts +8 -0
  176. package/flow/steps/index.d.ts.map +1 -0
  177. package/flow/steps/index.esm.js +3504 -0
  178. package/flow/steps/index.esm.js.map +1 -0
  179. package/flow/steps/update-packages.d.ts +25 -0
  180. package/flow/steps/update-packages.d.ts.map +1 -0
  181. package/flow/utils/interpolate.d.ts +11 -0
  182. package/flow/utils/interpolate.d.ts.map +1 -0
  183. package/git/factory.d.ts +233 -0
  184. package/git/factory.d.ts.map +1 -0
  185. package/git/index.cjs.js +2863 -0
  186. package/git/index.cjs.js.map +1 -0
  187. package/git/index.d.ts +5 -0
  188. package/git/index.d.ts.map +1 -0
  189. package/git/index.esm.js +2785 -0
  190. package/git/index.esm.js.map +1 -0
  191. package/git/models/commit.d.ts +129 -0
  192. package/git/models/commit.d.ts.map +1 -0
  193. package/git/models/index.cjs.js +755 -0
  194. package/git/models/index.cjs.js.map +1 -0
  195. package/git/models/index.d.ts +7 -0
  196. package/git/models/index.d.ts.map +1 -0
  197. package/git/models/index.esm.js +729 -0
  198. package/git/models/index.esm.js.map +1 -0
  199. package/git/models/ref.d.ts +120 -0
  200. package/git/models/ref.d.ts.map +1 -0
  201. package/git/models/tag.d.ts +141 -0
  202. package/git/models/tag.d.ts.map +1 -0
  203. package/git/operations/commit.d.ts +97 -0
  204. package/git/operations/commit.d.ts.map +1 -0
  205. package/git/operations/head-info.d.ts +29 -0
  206. package/git/operations/head-info.d.ts.map +1 -0
  207. package/git/operations/index.cjs.js +1954 -0
  208. package/git/operations/index.cjs.js.map +1 -0
  209. package/git/operations/index.d.ts +14 -0
  210. package/git/operations/index.d.ts.map +1 -0
  211. package/git/operations/index.esm.js +1903 -0
  212. package/git/operations/index.esm.js.map +1 -0
  213. package/git/operations/log.d.ts +104 -0
  214. package/git/operations/log.d.ts.map +1 -0
  215. package/git/operations/manage-tags.d.ts +60 -0
  216. package/git/operations/manage-tags.d.ts.map +1 -0
  217. package/git/operations/query-tags.d.ts +88 -0
  218. package/git/operations/query-tags.d.ts.map +1 -0
  219. package/git/operations/stage.d.ts +66 -0
  220. package/git/operations/stage.d.ts.map +1 -0
  221. package/git/operations/status.d.ts +173 -0
  222. package/git/operations/status.d.ts.map +1 -0
  223. package/index.cjs.js +16761 -0
  224. package/index.cjs.js.map +1 -0
  225. package/index.d.ts +102 -0
  226. package/index.d.ts.map +1 -0
  227. package/index.esm.js +16427 -0
  228. package/index.esm.js.map +1 -0
  229. package/package.json +200 -0
  230. package/registry/factory.d.ts +18 -0
  231. package/registry/factory.d.ts.map +1 -0
  232. package/registry/index.cjs.js +543 -0
  233. package/registry/index.cjs.js.map +1 -0
  234. package/registry/index.d.ts +5 -0
  235. package/registry/index.d.ts.map +1 -0
  236. package/registry/index.esm.js +535 -0
  237. package/registry/index.esm.js.map +1 -0
  238. package/registry/models/index.cjs.js +69 -0
  239. package/registry/models/index.cjs.js.map +1 -0
  240. package/registry/models/index.d.ts +6 -0
  241. package/registry/models/index.d.ts.map +1 -0
  242. package/registry/models/index.esm.js +66 -0
  243. package/registry/models/index.esm.js.map +1 -0
  244. package/registry/models/package-info.d.ts +55 -0
  245. package/registry/models/package-info.d.ts.map +1 -0
  246. package/registry/models/registry.d.ts +62 -0
  247. package/registry/models/registry.d.ts.map +1 -0
  248. package/registry/models/version-info.d.ts +67 -0
  249. package/registry/models/version-info.d.ts.map +1 -0
  250. package/registry/npm/cache.d.ts +50 -0
  251. package/registry/npm/cache.d.ts.map +1 -0
  252. package/registry/npm/client.d.ts +30 -0
  253. package/registry/npm/client.d.ts.map +1 -0
  254. package/registry/npm/index.cjs.js +456 -0
  255. package/registry/npm/index.cjs.js.map +1 -0
  256. package/registry/npm/index.d.ts +4 -0
  257. package/registry/npm/index.d.ts.map +1 -0
  258. package/registry/npm/index.esm.js +451 -0
  259. package/registry/npm/index.esm.js.map +1 -0
  260. package/semver/compare/compare.d.ts +100 -0
  261. package/semver/compare/compare.d.ts.map +1 -0
  262. package/semver/compare/index.cjs.js +386 -0
  263. package/semver/compare/index.cjs.js.map +1 -0
  264. package/semver/compare/index.d.ts +3 -0
  265. package/semver/compare/index.d.ts.map +1 -0
  266. package/semver/compare/index.esm.js +370 -0
  267. package/semver/compare/index.esm.js.map +1 -0
  268. package/semver/compare/sort.d.ts +36 -0
  269. package/semver/compare/sort.d.ts.map +1 -0
  270. package/semver/format/index.cjs.js +58 -0
  271. package/semver/format/index.cjs.js.map +1 -0
  272. package/semver/format/index.d.ts +2 -0
  273. package/semver/format/index.d.ts.map +1 -0
  274. package/semver/format/index.esm.js +53 -0
  275. package/semver/format/index.esm.js.map +1 -0
  276. package/semver/format/to-string.d.ts +31 -0
  277. package/semver/format/to-string.d.ts.map +1 -0
  278. package/semver/increment/bump.d.ts +37 -0
  279. package/semver/increment/bump.d.ts.map +1 -0
  280. package/semver/increment/index.cjs.js +223 -0
  281. package/semver/increment/index.cjs.js.map +1 -0
  282. package/semver/increment/index.d.ts +2 -0
  283. package/semver/increment/index.d.ts.map +1 -0
  284. package/semver/increment/index.esm.js +219 -0
  285. package/semver/increment/index.esm.js.map +1 -0
  286. package/semver/index.cjs.js +1499 -0
  287. package/semver/index.cjs.js.map +1 -0
  288. package/semver/index.d.ts +6 -0
  289. package/semver/index.d.ts.map +1 -0
  290. package/semver/index.esm.js +1458 -0
  291. package/semver/index.esm.js.map +1 -0
  292. package/semver/models/index.cjs.js +153 -0
  293. package/semver/models/index.cjs.js.map +1 -0
  294. package/semver/models/index.d.ts +5 -0
  295. package/semver/models/index.d.ts.map +1 -0
  296. package/semver/models/index.esm.js +139 -0
  297. package/semver/models/index.esm.js.map +1 -0
  298. package/semver/models/range.d.ts +83 -0
  299. package/semver/models/range.d.ts.map +1 -0
  300. package/semver/models/version.d.ts +78 -0
  301. package/semver/models/version.d.ts.map +1 -0
  302. package/semver/parse/index.cjs.js +799 -0
  303. package/semver/parse/index.cjs.js.map +1 -0
  304. package/semver/parse/index.d.ts +5 -0
  305. package/semver/parse/index.d.ts.map +1 -0
  306. package/semver/parse/index.esm.js +793 -0
  307. package/semver/parse/index.esm.js.map +1 -0
  308. package/semver/parse/range.d.ts +38 -0
  309. package/semver/parse/range.d.ts.map +1 -0
  310. package/semver/parse/version.d.ts +49 -0
  311. package/semver/parse/version.d.ts.map +1 -0
  312. package/workspace/discovery/changelog-path.d.ts +21 -0
  313. package/workspace/discovery/changelog-path.d.ts.map +1 -0
  314. package/workspace/discovery/dependencies.d.ts +145 -0
  315. package/workspace/discovery/dependencies.d.ts.map +1 -0
  316. package/workspace/discovery/discover-changelogs.d.ts +76 -0
  317. package/workspace/discovery/discover-changelogs.d.ts.map +1 -0
  318. package/workspace/discovery/index.cjs.js +2300 -0
  319. package/workspace/discovery/index.cjs.js.map +1 -0
  320. package/workspace/discovery/index.d.ts +13 -0
  321. package/workspace/discovery/index.d.ts.map +1 -0
  322. package/workspace/discovery/index.esm.js +2283 -0
  323. package/workspace/discovery/index.esm.js.map +1 -0
  324. package/workspace/discovery/packages.d.ts +83 -0
  325. package/workspace/discovery/packages.d.ts.map +1 -0
  326. package/workspace/index.cjs.js +4445 -0
  327. package/workspace/index.cjs.js.map +1 -0
  328. package/workspace/index.d.ts +52 -0
  329. package/workspace/index.d.ts.map +1 -0
  330. package/workspace/index.esm.js +4394 -0
  331. package/workspace/index.esm.js.map +1 -0
  332. package/workspace/models/index.cjs.js +284 -0
  333. package/workspace/models/index.cjs.js.map +1 -0
  334. package/workspace/models/index.d.ts +10 -0
  335. package/workspace/models/index.d.ts.map +1 -0
  336. package/workspace/models/index.esm.js +261 -0
  337. package/workspace/models/index.esm.js.map +1 -0
  338. package/workspace/models/project.d.ts +118 -0
  339. package/workspace/models/project.d.ts.map +1 -0
  340. package/workspace/models/workspace.d.ts +139 -0
  341. package/workspace/models/workspace.d.ts.map +1 -0
  342. package/workspace/operations/batch-update.d.ts +99 -0
  343. package/workspace/operations/batch-update.d.ts.map +1 -0
  344. package/workspace/operations/cascade-bump.d.ts +125 -0
  345. package/workspace/operations/cascade-bump.d.ts.map +1 -0
  346. package/workspace/operations/index.cjs.js +2675 -0
  347. package/workspace/operations/index.cjs.js.map +1 -0
  348. package/workspace/operations/index.d.ts +12 -0
  349. package/workspace/operations/index.d.ts.map +1 -0
  350. package/workspace/operations/index.esm.js +2663 -0
  351. package/workspace/operations/index.esm.js.map +1 -0
  352. package/workspace/operations/validate.d.ts +85 -0
  353. package/workspace/operations/validate.d.ts.map +1 -0
@@ -0,0 +1,799 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Safe copies of Error built-ins via factory functions.
5
+ *
6
+ * Since constructors cannot be safely captured via Object.assign, this module
7
+ * provides factory functions that use Reflect.construct internally.
8
+ *
9
+ * These references are captured at module initialization time to protect against
10
+ * prototype pollution attacks. Import only what you need for tree-shaking.
11
+ *
12
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/error
13
+ */
14
+ // Capture references at module initialization time
15
+ const _Error = globalThis.Error;
16
+ const _Reflect = globalThis.Reflect;
17
+ /**
18
+ * (Safe copy) Creates a new Error using the captured Error constructor.
19
+ * Use this instead of `new Error()`.
20
+ *
21
+ * @param message - Optional error message.
22
+ * @param options - Optional error options.
23
+ * @returns A new Error instance.
24
+ */
25
+ const createError = (message, options) => _Reflect.construct(_Error, [message, options]);
26
+
27
+ /**
28
+ * Creates a new SemVer object.
29
+ *
30
+ * @param options - Version components
31
+ * @returns A new SemVer object
32
+ */
33
+ function createSemVer(options) {
34
+ return {
35
+ major: options.major,
36
+ minor: options.minor,
37
+ patch: options.patch,
38
+ prerelease: options.prerelease ?? [],
39
+ build: options.build ?? [],
40
+ raw: options.raw,
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Maximum version string length to prevent memory exhaustion.
46
+ */
47
+ const MAX_VERSION_LENGTH = 256;
48
+ /**
49
+ * Parses a semantic version string.
50
+ *
51
+ * Accepts versions in the format: MAJOR.MINOR.PATCH[-prerelease][+build]
52
+ * Optional leading 'v' or '=' prefixes are stripped.
53
+ *
54
+ * @param input - The version string to parse
55
+ * @returns A ParseVersionResult with the parsed version or error
56
+ *
57
+ * @example
58
+ * parseVersion('1.2.3') // { success: true, version: { major: 1, minor: 2, patch: 3, ... } }
59
+ * parseVersion('v1.0.0-alpha.1+build.123') // { success: true, ... }
60
+ * parseVersion('invalid') // { success: false, error: '...' }
61
+ */
62
+ function parseVersion(input) {
63
+ // Input validation
64
+ if (!input || typeof input !== 'string') {
65
+ return { success: false, error: 'Version string is required' };
66
+ }
67
+ if (input.length > MAX_VERSION_LENGTH) {
68
+ return { success: false, error: `Version string exceeds maximum length of ${MAX_VERSION_LENGTH}` };
69
+ }
70
+ // Strip leading whitespace
71
+ let pos = 0;
72
+ while (pos < input.length && isWhitespace(input.charCodeAt(pos))) {
73
+ pos++;
74
+ }
75
+ // Strip trailing whitespace
76
+ let end = input.length;
77
+ while (end > pos && isWhitespace(input.charCodeAt(end - 1))) {
78
+ end--;
79
+ }
80
+ // Strip optional leading 'v' or '='
81
+ if (pos < end) {
82
+ const code = input.charCodeAt(pos);
83
+ if (code === 118 || code === 86) {
84
+ // 'v' or 'V'
85
+ pos++;
86
+ }
87
+ else if (code === 61) {
88
+ // '='
89
+ pos++;
90
+ }
91
+ }
92
+ // Parse major version
93
+ const majorResult = parseNumericIdentifier(input, pos, end);
94
+ if (!majorResult.success) {
95
+ return { success: false, error: majorResult.error ?? 'Invalid major version' };
96
+ }
97
+ pos = majorResult.endPos;
98
+ // Expect dot
99
+ if (pos >= end || input.charCodeAt(pos) !== 46) {
100
+ // '.'
101
+ return { success: false, error: 'Expected "." after major version' };
102
+ }
103
+ pos++;
104
+ // Parse minor version
105
+ const minorResult = parseNumericIdentifier(input, pos, end);
106
+ if (!minorResult.success) {
107
+ return { success: false, error: minorResult.error ?? 'Invalid minor version' };
108
+ }
109
+ pos = minorResult.endPos;
110
+ // Expect dot
111
+ if (pos >= end || input.charCodeAt(pos) !== 46) {
112
+ // '.'
113
+ return { success: false, error: 'Expected "." after minor version' };
114
+ }
115
+ pos++;
116
+ // Parse patch version
117
+ const patchResult = parseNumericIdentifier(input, pos, end);
118
+ if (!patchResult.success) {
119
+ return { success: false, error: patchResult.error ?? 'Invalid patch version' };
120
+ }
121
+ pos = patchResult.endPos;
122
+ // Parse optional prerelease
123
+ const prerelease = [];
124
+ if (pos < end && input.charCodeAt(pos) === 45) {
125
+ // '-'
126
+ pos++;
127
+ const prereleaseResult = parseIdentifiers(input, pos, end, [43]); // Stop at '+'
128
+ if (!prereleaseResult.success) {
129
+ return { success: false, error: prereleaseResult.error ?? 'Invalid prerelease' };
130
+ }
131
+ prerelease.push(...prereleaseResult.identifiers);
132
+ pos = prereleaseResult.endPos;
133
+ }
134
+ // Parse optional build metadata
135
+ const build = [];
136
+ if (pos < end && input.charCodeAt(pos) === 43) {
137
+ // '+'
138
+ pos++;
139
+ const buildResult = parseIdentifiers(input, pos, end, []);
140
+ if (!buildResult.success) {
141
+ return { success: false, error: buildResult.error ?? 'Invalid build metadata' };
142
+ }
143
+ build.push(...buildResult.identifiers);
144
+ pos = buildResult.endPos;
145
+ }
146
+ // Check for trailing characters
147
+ if (pos < end) {
148
+ return { success: false, error: `Unexpected character at position ${pos}: "${input[pos]}"` };
149
+ }
150
+ return {
151
+ success: true,
152
+ version: createSemVer({
153
+ major: majorResult.value,
154
+ minor: minorResult.value,
155
+ patch: patchResult.value,
156
+ prerelease,
157
+ build,
158
+ raw: input,
159
+ }),
160
+ };
161
+ }
162
+ /**
163
+ * Parses a version string, throwing on invalid input.
164
+ *
165
+ * @param input - The version string to parse
166
+ * @returns The parsed SemVer
167
+ * @throws {Error} If the input is not a valid version
168
+ */
169
+ function parseVersionStrict(input) {
170
+ const result = parseVersion(input);
171
+ if (!result.success || !result.version) {
172
+ throw createError(result.error ?? 'Invalid version');
173
+ }
174
+ return result.version;
175
+ }
176
+ /**
177
+ * Attempts to coerce a string into a valid semver.
178
+ * More lenient than parseVersion - accepts partial versions.
179
+ *
180
+ * @param input - The string to coerce
181
+ * @returns The parsed SemVer or null if coercion failed
182
+ *
183
+ * @example
184
+ * coerceVersion('1') // { major: 1, minor: 0, patch: 0, ... }
185
+ * coerceVersion('1.2') // { major: 1, minor: 2, patch: 0, ... }
186
+ * coerceVersion('v2.0') // { major: 2, minor: 0, patch: 0, ... }
187
+ */
188
+ function coerceVersion(input) {
189
+ if (!input || typeof input !== 'string') {
190
+ return null;
191
+ }
192
+ // Try strict parse first
193
+ const strict = parseVersion(input);
194
+ if (strict.success && strict.version) {
195
+ return strict.version;
196
+ }
197
+ // Strip leading/trailing whitespace
198
+ let pos = 0;
199
+ while (pos < input.length && isWhitespace(input.charCodeAt(pos))) {
200
+ pos++;
201
+ }
202
+ let end = input.length;
203
+ while (end > pos && isWhitespace(input.charCodeAt(end - 1))) {
204
+ end--;
205
+ }
206
+ // Strip optional 'v' prefix
207
+ if (pos < end) {
208
+ const code = input.charCodeAt(pos);
209
+ if (code === 118 || code === 86) {
210
+ // 'v' or 'V'
211
+ pos++;
212
+ }
213
+ }
214
+ // Parse major
215
+ const majorResult = parseNumericIdentifier(input, pos, end);
216
+ if (!majorResult.success) {
217
+ return null;
218
+ }
219
+ const major = majorResult.value;
220
+ pos = majorResult.endPos;
221
+ // Parse optional minor
222
+ let minor = 0;
223
+ if (pos < end && input.charCodeAt(pos) === 46) {
224
+ pos++;
225
+ const minorResult = parseNumericIdentifier(input, pos, end);
226
+ if (minorResult.success) {
227
+ minor = minorResult.value;
228
+ pos = minorResult.endPos;
229
+ }
230
+ }
231
+ // Parse optional patch
232
+ let patch = 0;
233
+ if (pos < end && input.charCodeAt(pos) === 46) {
234
+ pos++;
235
+ const patchResult = parseNumericIdentifier(input, pos, end);
236
+ if (patchResult.success) {
237
+ patch = patchResult.value;
238
+ // pos = patchResult.endPos // We ignore anything after patch in coerce
239
+ }
240
+ }
241
+ return createSemVer({
242
+ major,
243
+ minor,
244
+ patch,
245
+ prerelease: [],
246
+ build: [],
247
+ raw: input,
248
+ });
249
+ }
250
+ /**
251
+ * Parses a numeric identifier (non-negative integer, no leading zeros except for "0").
252
+ *
253
+ * @param input - Input string to parse
254
+ * @param start - Start position in the input
255
+ * @param end - End position in the input
256
+ * @returns Numeric parsing result
257
+ */
258
+ function parseNumericIdentifier(input, start, end) {
259
+ if (start >= end) {
260
+ return { success: false, value: 0, endPos: start, error: 'Expected numeric identifier' };
261
+ }
262
+ let pos = start;
263
+ const firstCode = input.charCodeAt(pos);
264
+ // Must start with a digit
265
+ if (!isDigit(firstCode)) {
266
+ return { success: false, value: 0, endPos: pos, error: 'Expected digit' };
267
+ }
268
+ // Check for leading zero (only "0" is valid, not "01", "007", etc.)
269
+ if (firstCode === 48 && pos + 1 < end && isDigit(input.charCodeAt(pos + 1))) {
270
+ return { success: false, value: 0, endPos: pos, error: 'Numeric identifier cannot have leading zeros' };
271
+ }
272
+ // Consume digits
273
+ let value = 0;
274
+ while (pos < end && isDigit(input.charCodeAt(pos))) {
275
+ value = value * 10 + (input.charCodeAt(pos) - 48);
276
+ pos++;
277
+ // Prevent overflow
278
+ if (value > Number.MAX_SAFE_INTEGER) {
279
+ return { success: false, value: 0, endPos: pos, error: 'Numeric identifier is too large' };
280
+ }
281
+ }
282
+ return { success: true, value, endPos: pos };
283
+ }
284
+ /**
285
+ * Parses dot-separated identifiers (for prerelease/build).
286
+ *
287
+ * @param input - Input string to parse
288
+ * @param start - Start position in the input
289
+ * @param end - End position in the input
290
+ * @param stopCodes - Character codes that signal end of identifiers
291
+ * @returns Identifiers parsing result
292
+ */
293
+ function parseIdentifiers(input, start, end, stopCodes) {
294
+ const identifiers = [];
295
+ let pos = start;
296
+ while (pos < end) {
297
+ // Check for stop characters
298
+ if (stopCodes.includes(input.charCodeAt(pos))) {
299
+ break;
300
+ }
301
+ // Parse one identifier
302
+ const identStart = pos;
303
+ while (pos < end) {
304
+ const code = input.charCodeAt(pos);
305
+ // Stop at dot or stop characters
306
+ if (code === 46 || stopCodes.includes(code)) {
307
+ break;
308
+ }
309
+ // Must be alphanumeric or hyphen
310
+ if (!isAlphanumeric(code) && code !== 45) {
311
+ return { success: false, identifiers: [], endPos: pos, error: `Invalid character in identifier: "${input[pos]}"` };
312
+ }
313
+ pos++;
314
+ }
315
+ // Empty identifier is not allowed
316
+ if (pos === identStart) {
317
+ return { success: false, identifiers: [], endPos: pos, error: 'Empty identifier' };
318
+ }
319
+ identifiers.push(input.slice(identStart, pos));
320
+ // Consume dot separator
321
+ if (pos < end && input.charCodeAt(pos) === 46) {
322
+ pos++;
323
+ // Dot at end is invalid
324
+ if (pos >= end || stopCodes.includes(input.charCodeAt(pos))) {
325
+ return { success: false, identifiers: [], endPos: pos, error: 'Identifier expected after dot' };
326
+ }
327
+ }
328
+ }
329
+ return { success: true, identifiers, endPos: pos };
330
+ }
331
+ /**
332
+ * Checks if a character code is a digit (0-9).
333
+ *
334
+ * @param code - Character code to check
335
+ * @returns True if the code represents a digit
336
+ */
337
+ function isDigit(code) {
338
+ return code >= 48 && code <= 57;
339
+ }
340
+ /**
341
+ * Checks if a character code is alphanumeric or hyphen.
342
+ *
343
+ * @param code - Character code to check
344
+ * @returns True if the code represents an alphanumeric character
345
+ */
346
+ function isAlphanumeric(code) {
347
+ return ((code >= 48 && code <= 57) || // 0-9
348
+ (code >= 65 && code <= 90) || // A-Z
349
+ (code >= 97 && code <= 122) // a-z
350
+ );
351
+ }
352
+ /**
353
+ * Checks if a character code is whitespace.
354
+ *
355
+ * @param code - Character code to check
356
+ * @returns True if the code represents whitespace
357
+ */
358
+ function isWhitespace(code) {
359
+ return code === 32 || code === 9 || code === 10 || code === 13;
360
+ }
361
+
362
+ /**
363
+ * Safe copies of Number built-in methods and constants.
364
+ *
365
+ * These references are captured at module initialization time to protect against
366
+ * prototype pollution attacks. Import only what you need for tree-shaking.
367
+ *
368
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/number
369
+ */
370
+ // Capture references at module initialization time
371
+ const _parseInt = globalThis.parseInt;
372
+ const _isNaN = globalThis.isNaN;
373
+ // ============================================================================
374
+ // Parsing
375
+ // ============================================================================
376
+ /**
377
+ * (Safe copy) Parses a string and returns an integer.
378
+ */
379
+ const parseInt = _parseInt;
380
+ // ============================================================================
381
+ // Global Type Checking (legacy, less strict)
382
+ // ============================================================================
383
+ /**
384
+ * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN).
385
+ */
386
+ const globalIsNaN = _isNaN;
387
+
388
+ /**
389
+ * Creates a new Comparator.
390
+ *
391
+ * @param operator - The comparison operator
392
+ * @param version - The version to compare against
393
+ * @returns A new Comparator
394
+ */
395
+ function createComparator(operator, version) {
396
+ return { operator, version };
397
+ }
398
+ /**
399
+ * Creates a new ComparatorSet.
400
+ *
401
+ * @param comparators - Array of comparators (AND logic)
402
+ * @returns A new ComparatorSet
403
+ */
404
+ function createComparatorSet(comparators) {
405
+ return { comparators };
406
+ }
407
+ /**
408
+ * Creates a new Range.
409
+ *
410
+ * @param sets - Array of comparator sets (OR logic)
411
+ * @param raw - Original raw string
412
+ * @returns A new Range
413
+ */
414
+ function createRange(sets, raw) {
415
+ return { sets, raw };
416
+ }
417
+
418
+ /**
419
+ * Maximum range string length.
420
+ */
421
+ const MAX_RANGE_LENGTH = 1024;
422
+ /**
423
+ * Parses a semver range string.
424
+ *
425
+ * Supports:
426
+ * - Exact: 1.2.3, =1.2.3
427
+ * - Comparators: >1.0.0, >=1.0.0, <2.0.0, <=2.0.0
428
+ * - Caret: ^1.2.3 (compatible with version)
429
+ * - Tilde: ~1.2.3 (approximately equivalent)
430
+ * - X-ranges: 1.x, 1.2.x, *
431
+ * - Hyphen ranges: 1.0.0 - 2.0.0
432
+ * - OR: 1.0.0 || 2.0.0
433
+ * - AND: >=1.0.0 <2.0.0
434
+ *
435
+ * @param input - The range string to parse
436
+ * @returns A ParseRangeResult with the parsed range or error
437
+ */
438
+ function parseRange(input) {
439
+ if (!input || typeof input !== 'string') {
440
+ return { success: false, error: 'Range string is required' };
441
+ }
442
+ if (input.length > MAX_RANGE_LENGTH) {
443
+ return { success: false, error: `Range string exceeds maximum length of ${MAX_RANGE_LENGTH}` };
444
+ }
445
+ // Trim whitespace
446
+ const trimmed = input.trim();
447
+ // Handle wildcard/any
448
+ if (trimmed === '' || trimmed === '*' || trimmed.toLowerCase() === 'x') {
449
+ return { success: true, range: createRange([], input) };
450
+ }
451
+ // Split by || for OR logic
452
+ const orParts = splitByOr(trimmed);
453
+ const sets = [];
454
+ for (const part of orParts) {
455
+ const setResult = parseComparatorSet(part.trim());
456
+ if (!setResult.success) {
457
+ return { success: false, error: setResult.error };
458
+ }
459
+ if (setResult.set) {
460
+ sets.push(setResult.set);
461
+ }
462
+ }
463
+ return { success: true, range: createRange(sets, input) };
464
+ }
465
+ /**
466
+ * Parses a range string, throwing on invalid input.
467
+ *
468
+ * @param input - The range string to parse
469
+ * @returns The parsed Range
470
+ * @throws {Error} If the input is not a valid range
471
+ */
472
+ function parseRangeStrict(input) {
473
+ const result = parseRange(input);
474
+ if (!result.success || !result.range) {
475
+ throw createError(result.error ?? 'Invalid range');
476
+ }
477
+ return result.range;
478
+ }
479
+ /**
480
+ * Splits a string by || delimiter, respecting nesting.
481
+ *
482
+ * @param input - Range string containing OR groups
483
+ * @returns Array of OR-separated parts
484
+ */
485
+ function splitByOr(input) {
486
+ const parts = [];
487
+ let current = '';
488
+ let pos = 0;
489
+ while (pos < input.length) {
490
+ if (input[pos] === '|' && pos + 1 < input.length && input[pos + 1] === '|') {
491
+ parts.push(current);
492
+ current = '';
493
+ pos += 2;
494
+ }
495
+ else {
496
+ current += input[pos];
497
+ pos++;
498
+ }
499
+ }
500
+ parts.push(current);
501
+ return parts;
502
+ }
503
+ /**
504
+ * Parses a single comparator set (space-separated comparators = AND logic).
505
+ *
506
+ * @param input - Comparator set string
507
+ * @returns Parsed set result
508
+ */
509
+ function parseComparatorSet(input) {
510
+ if (!input || input.trim() === '') {
511
+ return { success: true }; // Empty set matches any
512
+ }
513
+ const trimmed = input.trim();
514
+ // Check for hyphen range: "1.0.0 - 2.0.0"
515
+ const hyphenMatch = parseHyphenRange(trimmed);
516
+ if (hyphenMatch.isHyphenRange) {
517
+ if (!hyphenMatch.success) {
518
+ return { success: false, error: hyphenMatch.error };
519
+ }
520
+ return { success: true, set: hyphenMatch.set };
521
+ }
522
+ // Split by whitespace for AND logic
523
+ const tokens = splitByWhitespace(trimmed);
524
+ const comparators = [];
525
+ for (const token of tokens) {
526
+ const compResult = parseSingleComparator(token);
527
+ if (!compResult.success) {
528
+ return { success: false, error: compResult.error };
529
+ }
530
+ if (compResult.comparators) {
531
+ comparators.push(...compResult.comparators);
532
+ }
533
+ }
534
+ if (comparators.length === 0) {
535
+ return { success: true }; // Empty matches any
536
+ }
537
+ return { success: true, set: createComparatorSet(comparators) };
538
+ }
539
+ /**
540
+ * Checks for and parses hyphen ranges like "1.0.0 - 2.0.0".
541
+ *
542
+ * @param input - Potential hyphen range string
543
+ * @returns Hyphen range parsing result
544
+ */
545
+ function parseHyphenRange(input) {
546
+ // Look for " - " (space-hyphen-space)
547
+ let hyphenPos = -1;
548
+ for (let i = 0; i < input.length - 2; i++) {
549
+ if (input[i] === ' ' && input[i + 1] === '-' && input[i + 2] === ' ') {
550
+ hyphenPos = i;
551
+ break;
552
+ }
553
+ }
554
+ if (hyphenPos === -1) {
555
+ return { isHyphenRange: false, success: true };
556
+ }
557
+ const leftPart = input.slice(0, hyphenPos).trim();
558
+ const rightPart = input.slice(hyphenPos + 3).trim();
559
+ const leftVersion = parseSimpleVersion(leftPart);
560
+ if (!leftVersion) {
561
+ return { isHyphenRange: true, success: false, error: `Invalid left side of hyphen range: "${leftPart}"` };
562
+ }
563
+ const rightVersion = parseSimpleVersion(rightPart);
564
+ if (!rightVersion) {
565
+ return { isHyphenRange: true, success: false, error: `Invalid right side of hyphen range: "${rightPart}"` };
566
+ }
567
+ // Hyphen range: >=left <=right
568
+ const comparators = [createComparator('>=', leftVersion), createComparator('<=', rightVersion)];
569
+ return {
570
+ isHyphenRange: true,
571
+ success: true,
572
+ set: createComparatorSet(comparators),
573
+ };
574
+ }
575
+ /**
576
+ * Splits by whitespace.
577
+ *
578
+ * @param input - String to split
579
+ * @returns Array of whitespace-separated tokens
580
+ */
581
+ function splitByWhitespace(input) {
582
+ const tokens = [];
583
+ let current = '';
584
+ for (const char of input) {
585
+ if (char === ' ' || char === '\t') {
586
+ if (current) {
587
+ tokens.push(current);
588
+ current = '';
589
+ }
590
+ }
591
+ else {
592
+ current += char;
593
+ }
594
+ }
595
+ if (current) {
596
+ tokens.push(current);
597
+ }
598
+ return tokens;
599
+ }
600
+ /**
601
+ * Parses a single comparator token (e.g., ">=1.0.0", "^1.2.3", "~1.0").
602
+ *
603
+ * @param token - Comparator token to parse
604
+ * @returns Parsed comparator result
605
+ */
606
+ function parseSingleComparator(token) {
607
+ let pos = 0;
608
+ let operator = '=';
609
+ // Parse operator
610
+ if (token[pos] === '^') {
611
+ operator = '^';
612
+ pos++;
613
+ }
614
+ else if (token[pos] === '~') {
615
+ operator = '~';
616
+ pos++;
617
+ }
618
+ else if (token[pos] === '>') {
619
+ if (token[pos + 1] === '=') {
620
+ operator = '>=';
621
+ pos += 2;
622
+ }
623
+ else {
624
+ operator = '>';
625
+ pos++;
626
+ }
627
+ }
628
+ else if (token[pos] === '<') {
629
+ if (token[pos + 1] === '=') {
630
+ operator = '<=';
631
+ pos += 2;
632
+ }
633
+ else {
634
+ operator = '<';
635
+ pos++;
636
+ }
637
+ }
638
+ else if (token[pos] === '=') {
639
+ operator = '=';
640
+ pos++;
641
+ }
642
+ const versionPart = token.slice(pos);
643
+ // Handle wildcards: *, x, X
644
+ if (versionPart === '*' || versionPart.toLowerCase() === 'x') {
645
+ // Wildcard matches any - return empty (will be handled as match-all)
646
+ return { success: true, comparators: [] };
647
+ }
648
+ // Handle x-ranges: 1.x, 1.2.x
649
+ if (versionPart.includes('x') || versionPart.includes('X') || versionPart.includes('*')) {
650
+ return parseXRange(versionPart);
651
+ }
652
+ // Parse version
653
+ const version = parseSimpleVersion(versionPart);
654
+ if (!version) {
655
+ return { success: false, error: `Invalid version in comparator: "${versionPart}"` };
656
+ }
657
+ // For caret and tilde, expand to range
658
+ if (operator === '^') {
659
+ return expandCaretRange(version);
660
+ }
661
+ if (operator === '~') {
662
+ return expandTildeRange(version);
663
+ }
664
+ return { success: true, comparators: [createComparator(operator, version)] };
665
+ }
666
+ /**
667
+ * Parses x-ranges like 1.x, 1.2.x, etc.
668
+ *
669
+ * @param input - X-range string to parse
670
+ * @param _operator - Range operator (unused but kept for interface consistency)
671
+ * @returns Comparator result
672
+ */
673
+ function parseXRange(input, _operator) {
674
+ const parts = input.split('.');
675
+ const nums = [];
676
+ for (const part of parts) {
677
+ const lower = part.toLowerCase();
678
+ if (lower === 'x' || lower === '*' || lower === '') {
679
+ break;
680
+ }
681
+ const num = parseInt(part, 10);
682
+ if (globalIsNaN(num) || num < 0) {
683
+ return { success: false, error: `Invalid x-range: "${input}"` };
684
+ }
685
+ nums.push(num);
686
+ }
687
+ if (nums.length === 0) {
688
+ // * or X alone - match any
689
+ return { success: true, comparators: [] };
690
+ }
691
+ if (nums.length === 1) {
692
+ // 1.x or 1.* -> >=1.0.0 <2.0.0
693
+ const lower = createSemVer({ major: nums[0], minor: 0, patch: 0 });
694
+ const upper = createSemVer({ major: nums[0] + 1, minor: 0, patch: 0 });
695
+ return { success: true, comparators: [createComparator('>=', lower), createComparator('<', upper)] };
696
+ }
697
+ // 1.2.x -> >=1.2.0 <1.3.0
698
+ const lower = createSemVer({ major: nums[0], minor: nums[1], patch: 0 });
699
+ const upper = createSemVer({ major: nums[0], minor: nums[1] + 1, patch: 0 });
700
+ return { success: true, comparators: [createComparator('>=', lower), createComparator('<', upper)] };
701
+ }
702
+ /**
703
+ * Expands caret range: ^1.2.3 -> >=1.2.3 <2.0.0
704
+ *
705
+ * @param version - Base version for caret range
706
+ * @returns Expanded comparator result
707
+ */
708
+ function expandCaretRange(version) {
709
+ let upperMajor = version.major;
710
+ let upperMinor = 0;
711
+ let upperPatch = 0;
712
+ if (version.major === 0) {
713
+ if (version.minor === 0) {
714
+ // ^0.0.x -> >=0.0.x <0.0.(x+1)
715
+ upperPatch = version.patch + 1;
716
+ upperMinor = version.minor;
717
+ }
718
+ else {
719
+ // ^0.x.y -> >=0.x.y <0.(x+1).0
720
+ upperMinor = version.minor + 1;
721
+ }
722
+ }
723
+ else {
724
+ // ^x.y.z -> >=x.y.z <(x+1).0.0
725
+ upperMajor = version.major + 1;
726
+ }
727
+ const upper = createSemVer({ major: upperMajor, minor: upperMinor, patch: upperPatch });
728
+ return { success: true, comparators: [createComparator('>=', version), createComparator('<', upper)] };
729
+ }
730
+ /**
731
+ * Expands tilde range: ~1.2.3 -> >=1.2.3 <1.3.0
732
+ *
733
+ * @param version - Base version for tilde range
734
+ * @returns Expanded comparator result
735
+ */
736
+ function expandTildeRange(version) {
737
+ const upper = createSemVer({
738
+ major: version.major,
739
+ minor: version.minor + 1,
740
+ patch: 0,
741
+ });
742
+ return { success: true, comparators: [createComparator('>=', version), createComparator('<', upper)] };
743
+ }
744
+ /**
745
+ * Parses a simple version string (no range operators).
746
+ * More lenient - accepts partial versions.
747
+ *
748
+ * @param input - Version string to parse
749
+ * @returns Parsed SemVer or null if invalid
750
+ */
751
+ function parseSimpleVersion(input) {
752
+ if (!input)
753
+ return null;
754
+ let pos = 0;
755
+ // Skip leading v
756
+ if (input[pos] === 'v' || input[pos] === 'V') {
757
+ pos++;
758
+ }
759
+ const parts = input.slice(pos).split('.');
760
+ if (parts.length === 0)
761
+ return null;
762
+ const nums = [];
763
+ for (const part of parts) {
764
+ // Stop at prerelease or build
765
+ const dashIdx = part.indexOf('-');
766
+ const plusIdx = part.indexOf('+');
767
+ let numPart = part;
768
+ if (dashIdx !== -1) {
769
+ numPart = part.slice(0, dashIdx);
770
+ }
771
+ else if (plusIdx !== -1) {
772
+ numPart = part.slice(0, plusIdx);
773
+ }
774
+ if (numPart === '' || numPart.toLowerCase() === 'x' || numPart === '*') {
775
+ break;
776
+ }
777
+ const num = parseInt(numPart, 10);
778
+ if (globalIsNaN(num) || num < 0)
779
+ return null;
780
+ nums.push(num);
781
+ }
782
+ if (nums.length === 0)
783
+ return null;
784
+ return createSemVer({
785
+ major: nums[0],
786
+ minor: nums[1] ?? 0,
787
+ patch: nums[2] ?? 0,
788
+ prerelease: [],
789
+ build: [],
790
+ raw: input,
791
+ });
792
+ }
793
+
794
+ exports.coerceVersion = coerceVersion;
795
+ exports.parseRange = parseRange;
796
+ exports.parseRangeStrict = parseRangeStrict;
797
+ exports.parseVersion = parseVersion;
798
+ exports.parseVersionStrict = parseVersionStrict;
799
+ //# sourceMappingURL=index.cjs.js.map