@vltpkg/cli-js 0.0.0-7

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 (128) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +10 -0
  3. package/cache-unzip-src-unzip.js +7896 -0
  4. package/cache-unzip-src-unzip.js.map +7 -0
  5. package/chunk-36Z4IEW5.js +1010 -0
  6. package/chunk-36Z4IEW5.js.map +7 -0
  7. package/chunk-433RK6QP.js +72 -0
  8. package/chunk-433RK6QP.js.map +7 -0
  9. package/chunk-457WPPV5.js +969 -0
  10. package/chunk-457WPPV5.js.map +7 -0
  11. package/chunk-66GJ6BNX.js +2666 -0
  12. package/chunk-66GJ6BNX.js.map +7 -0
  13. package/chunk-AYOLWFFJ.js +10972 -0
  14. package/chunk-AYOLWFFJ.js.map +7 -0
  15. package/chunk-GQLKOYXI.js +1451 -0
  16. package/chunk-GQLKOYXI.js.map +7 -0
  17. package/chunk-GU2E2KHZ.js +152 -0
  18. package/chunk-GU2E2KHZ.js.map +7 -0
  19. package/chunk-H75RQSUK.js +5413 -0
  20. package/chunk-H75RQSUK.js.map +7 -0
  21. package/chunk-LJEVKV7R.js +36 -0
  22. package/chunk-LJEVKV7R.js.map +7 -0
  23. package/chunk-MF4RCNHU.js +71 -0
  24. package/chunk-MF4RCNHU.js.map +7 -0
  25. package/chunk-NM754OFF.js +1104 -0
  26. package/chunk-NM754OFF.js.map +7 -0
  27. package/chunk-OGUMFXHI.js +1136 -0
  28. package/chunk-OGUMFXHI.js.map +7 -0
  29. package/chunk-OKDQY2GQ.js +1866 -0
  30. package/chunk-OKDQY2GQ.js.map +7 -0
  31. package/chunk-OOZN2US4.js +61 -0
  32. package/chunk-OOZN2US4.js.map +7 -0
  33. package/chunk-OSVOPGNL.js +782 -0
  34. package/chunk-OSVOPGNL.js.map +7 -0
  35. package/chunk-PKKWJ5FM.js +11836 -0
  36. package/chunk-PKKWJ5FM.js.map +7 -0
  37. package/chunk-PPTEV6PS.js +27 -0
  38. package/chunk-PPTEV6PS.js.map +7 -0
  39. package/chunk-S7LRSSDW.js +40 -0
  40. package/chunk-S7LRSSDW.js.map +7 -0
  41. package/chunk-SJZXAMQQ.js +5233 -0
  42. package/chunk-SJZXAMQQ.js.map +7 -0
  43. package/chunk-TV2RDGWY.js +181 -0
  44. package/chunk-TV2RDGWY.js.map +7 -0
  45. package/chunk-V4TLWRQW.js +34 -0
  46. package/chunk-V4TLWRQW.js.map +7 -0
  47. package/chunk-VIE5PVDF.js +21788 -0
  48. package/chunk-VIE5PVDF.js.map +7 -0
  49. package/chunk-VO2MAWDF.js +53 -0
  50. package/chunk-VO2MAWDF.js.map +7 -0
  51. package/chunk-XCC42LF5.js +511 -0
  52. package/chunk-XCC42LF5.js.map +7 -0
  53. package/chunk-YS3ZYKCN.js +6499 -0
  54. package/chunk-YS3ZYKCN.js.map +7 -0
  55. package/chunk-ZLP22ACI.js +65 -0
  56. package/chunk-ZLP22ACI.js.map +7 -0
  57. package/chunk-ZSTAQQQN.js +2070 -0
  58. package/chunk-ZSTAQQQN.js.map +7 -0
  59. package/cli-package.json +104 -0
  60. package/config-M6ZTMEJC.js +184 -0
  61. package/config-M6ZTMEJC.js.map +7 -0
  62. package/devtools-PSS6DSS6.js +16681 -0
  63. package/devtools-PSS6DSS6.js.map +7 -0
  64. package/exec-5Q6ZP6JI.js +48 -0
  65. package/exec-5Q6ZP6JI.js.map +7 -0
  66. package/gui-667EH2M7.js +44 -0
  67. package/gui-667EH2M7.js.map +7 -0
  68. package/gui-assets/favicon.ico +0 -0
  69. package/gui-assets/fonts/courier-bold-italic.ttf +0 -0
  70. package/gui-assets/fonts/courier-bold.ttf +0 -0
  71. package/gui-assets/fonts/courier-italic.ttf +0 -0
  72. package/gui-assets/fonts/courier-regular.ttf +0 -0
  73. package/gui-assets/fonts/geist-mono.ttf +0 -0
  74. package/gui-assets/fonts/inter.ttf +0 -0
  75. package/gui-assets/images/folder.png +0 -0
  76. package/gui-assets/index.html +34 -0
  77. package/gui-assets/index.js +1573 -0
  78. package/gui-assets/index.js.map +7 -0
  79. package/gui-assets/main.css +1 -0
  80. package/help-JZ3VD6MH.js +24 -0
  81. package/help-JZ3VD6MH.js.map +7 -0
  82. package/init-4JOBGJ4C.js +24 -0
  83. package/init-4JOBGJ4C.js.map +7 -0
  84. package/install-I6UDMAKJ.js +53 -0
  85. package/install-I6UDMAKJ.js.map +7 -0
  86. package/install-exec-BGKORQDZ.js +27 -0
  87. package/install-exec-BGKORQDZ.js.map +7 -0
  88. package/list-NKJNNDAV.js +138 -0
  89. package/list-NKJNNDAV.js.map +7 -0
  90. package/login-5X5JKFYS.js +35 -0
  91. package/login-5X5JKFYS.js.map +7 -0
  92. package/logout-5NO6B4BW.js +35 -0
  93. package/logout-5NO6B4BW.js.map +7 -0
  94. package/package.json +25 -0
  95. package/pkg-CUX23YND.js +363 -0
  96. package/pkg-CUX23YND.js.map +7 -0
  97. package/query-XWAQ6U4O.js +126 -0
  98. package/query-XWAQ6U4O.js.map +7 -0
  99. package/registry-client-package.json +84 -0
  100. package/reporter-GV7DMKAK.js +17 -0
  101. package/reporter-GV7DMKAK.js.map +7 -0
  102. package/rollback-remove-src-remove.js +7397 -0
  103. package/rollback-remove-src-remove.js.map +7 -0
  104. package/run-GJDCKL7X.js +66 -0
  105. package/run-GJDCKL7X.js.map +7 -0
  106. package/run-exec-L3RGBBPL.js +39 -0
  107. package/run-exec-L3RGBBPL.js.map +7 -0
  108. package/source-ALZ2QHEZ.js +32 -0
  109. package/source-ALZ2QHEZ.js.map +7 -0
  110. package/src-XRLOORCU.js +92 -0
  111. package/src-XRLOORCU.js.map +7 -0
  112. package/token-JLM4D6QR.js +85 -0
  113. package/token-JLM4D6QR.js.map +7 -0
  114. package/uninstall-X72YAQHZ.js +53 -0
  115. package/uninstall-X72YAQHZ.js.map +7 -0
  116. package/vlix.js +13 -0
  117. package/vlix.js.map +7 -0
  118. package/vlr.js +13 -0
  119. package/vlr.js.map +7 -0
  120. package/vlrx.js +13 -0
  121. package/vlrx.js.map +7 -0
  122. package/vlt.js +13 -0
  123. package/vlt.js.map +7 -0
  124. package/vlx.js +13 -0
  125. package/vlx.js.map +7 -0
  126. package/whoami-CMKBD6ZT.js +45 -0
  127. package/whoami-CMKBD6ZT.js.map +7 -0
  128. package/yoga.wasm +0 -0
@@ -0,0 +1,1866 @@
1
+ var global = globalThis;
2
+ import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers";
3
+ import {createRequire as _vlt_createRequire} from "node:module";
4
+ var require = _vlt_createRequire(import.meta.filename);
5
+ import {
6
+ error,
7
+ syntaxError,
8
+ typeError
9
+ } from "./chunk-LJEVKV7R.js";
10
+
11
+ // ../../src/types/src/index.ts
12
+ var integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/;
13
+ var isIntegrity = (i) => typeof i === "string" && integrityRE.test(i);
14
+ var isObj = (o) => !!o && typeof o === "object";
15
+ var maybeRecordStringString = (o) => o === void 0 || isRecordStringString(o);
16
+ var isRecordStringString = (o) => isRecordStringT(o, (s) => typeof s === "string");
17
+ var isRecordStringT = (o, check) => isObj(o) && Object.entries(o).every(
18
+ ([k, v]) => typeof k === "string" && check(v)
19
+ );
20
+ var isRecordStringManifest = (o) => isRecordStringT(o, (v) => isManifest(v));
21
+ var maybePeerDependenciesMetaSet = (o) => o === void 0 || isRecordStringT(
22
+ o,
23
+ (v) => isPeerDependenciesMetaValue(v)
24
+ );
25
+ var maybeBoolean = (o) => o === void 0 || typeof o === "boolean";
26
+ var isPeerDependenciesMetaValue = (o) => isObj(o) && maybeBoolean(o.optional);
27
+ var maybeString = (a) => a === void 0 || typeof a === "string";
28
+ var maybeDist = (a) => a === void 0 || isObj(a) && maybeString(a.tarball);
29
+ var isManifest = (m) => isObj(m) && !Array.isArray(m) && maybeString(m.name) && maybeString(m.version) && maybeRecordStringString(m.dependencies) && maybeRecordStringString(m.devDependencies) && maybeRecordStringString(m.optionalDependencies) && maybeRecordStringString(m.peerDependencies) && maybeRecordStringString(m.acceptDependencies) && maybePeerDependenciesMetaSet(m.peerDependenciesMeta) && maybeDist(m.dist);
30
+ var asManifest = (m, from) => {
31
+ if (!isManifest(m)) {
32
+ throw error("invalid manifest", { found: m }, from ?? asManifest);
33
+ }
34
+ return m;
35
+ };
36
+ var isPackument = (p) => {
37
+ if (!isObj(p) || typeof p.name !== "string") return false;
38
+ const { versions, "dist-tags": distTags, time } = p;
39
+ return isRecordStringString(distTags) && isRecordStringManifest(versions) && maybeRecordStringString(time) && Object.values(distTags).every((v) => versions[v]?.name == p.name);
40
+ };
41
+ var asPackument = (p, from) => {
42
+ if (!isPackument(p)) {
43
+ throw error(
44
+ "invalid packument",
45
+ { found: p },
46
+ from ?? asPackument
47
+ );
48
+ }
49
+ return p;
50
+ };
51
+ var longDependencyTypes = /* @__PURE__ */ new Set([
52
+ "dependencies",
53
+ "devDependencies",
54
+ "peerDependencies",
55
+ "optionalDependencies"
56
+ ]);
57
+ var shortDependencyTypes = /* @__PURE__ */ new Set([
58
+ "prod",
59
+ "dev",
60
+ "peer",
61
+ "optional",
62
+ "peerOptional"
63
+ ]);
64
+ var dependencyTypes = /* @__PURE__ */ new Map([
65
+ ["dependencies", "prod"],
66
+ ["devDependencies", "dev"],
67
+ ["peerDependencies", "peer"],
68
+ ["optionalDependencies", "optional"]
69
+ ]);
70
+
71
+ // ../../src/package-json/src/index.ts
72
+ import { readFileSync, writeFileSync } from "node:fs";
73
+ import { resolve } from "node:path";
74
+
75
+ // ../../node_modules/.pnpm/polite-json@5.0.0/node_modules/polite-json/dist/esm/index.js
76
+ var hexify = (s) => Array.from(s).map((c) => "0x" + c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")).join("");
77
+ var parseError = (e, txt, context) => {
78
+ if (!txt) {
79
+ return {
80
+ message: e.message + " while parsing empty string",
81
+ position: 0
82
+ };
83
+ }
84
+ const badToken = e.message.match(/^Unexpected (?:token (.*?))?/i);
85
+ const atPos = e.message.match(/at positions? (\d+)/);
86
+ const errIdx = /^Unexpected end of JSON|Unterminated string in JSON/i.test(e.message) ? txt.length - 1 : atPos && atPos[1] ? +atPos[1] : /is not valid JSON$/.test(e.message) ? 0 : null;
87
+ const msg = badToken && badToken[1] ? e.message.replace(/^Unexpected token ./, `Unexpected token ${JSON.stringify(badToken[1])} (${hexify(badToken[1])})`) : e.message;
88
+ if (errIdx !== null && errIdx !== void 0) {
89
+ const start = errIdx <= context ? 0 : errIdx - context;
90
+ const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
91
+ const slice = (start === 0 ? "" : "...") + txt.slice(start, end) + (end === txt.length ? "" : "...");
92
+ const near = txt === slice ? "" : "near ";
93
+ return {
94
+ message: msg + ` while parsing ${near}${JSON.stringify(slice)}`,
95
+ position: errIdx
96
+ };
97
+ } else {
98
+ return {
99
+ message: msg + ` while parsing '${txt.slice(0, context * 2)}'`,
100
+ position: 0
101
+ };
102
+ }
103
+ };
104
+ var JSONParseError = class extends SyntaxError {
105
+ code;
106
+ cause;
107
+ position;
108
+ constructor(er, txt, context = 20, caller) {
109
+ const { message, position } = parseError(er, txt, context);
110
+ super(message);
111
+ this.cause = er;
112
+ this.position = position;
113
+ this.code = "EJSONPARSE";
114
+ Error.captureStackTrace(this, caller || this.constructor);
115
+ }
116
+ get name() {
117
+ return this.constructor.name;
118
+ }
119
+ set name(_) {
120
+ }
121
+ get [Symbol.toStringTag]() {
122
+ return this.constructor.name;
123
+ }
124
+ };
125
+ var kIndent = Symbol.for("indent");
126
+ var kNewline = Symbol.for("newline");
127
+ var formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/;
128
+ var emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/;
129
+ var parse = (txt, reviver, context) => {
130
+ const parseText = stripBOM(String(txt));
131
+ if (!reviver)
132
+ reviver = void 0;
133
+ context = context || 20;
134
+ try {
135
+ const [, newline = "\n", indent = " "] = parseText.match(emptyRE) || parseText.match(formatRE) || [, "", ""];
136
+ const result = JSON.parse(parseText, reviver);
137
+ if (result && typeof result === "object") {
138
+ result[kNewline] = newline;
139
+ result[kIndent] = indent;
140
+ }
141
+ return result;
142
+ } catch (e) {
143
+ if (typeof txt !== "string" && !Buffer.isBuffer(txt)) {
144
+ const isEmptyArray = Array.isArray(txt) && txt.length === 0;
145
+ throw Object.assign(new TypeError(`Cannot parse ${isEmptyArray ? "an empty array" : String(txt)}`), {
146
+ code: "EJSONPARSE",
147
+ systemError: e
148
+ });
149
+ }
150
+ throw new JSONParseError(e, parseText, context, parse);
151
+ }
152
+ };
153
+ var stripBOM = (txt) => String(txt).replace(/^\uFEFF/, "");
154
+ var stringify = (obj, replacer, indent) => {
155
+ const space = indent === void 0 ? obj[kIndent] : indent;
156
+ const res = (
157
+ /* c8 ignore start */
158
+ typeof replacer === "function" ? JSON.stringify(obj, replacer, space) : JSON.stringify(obj, replacer, space)
159
+ );
160
+ const nl = obj[kNewline] || "\n";
161
+ return space ? (nl === "\n" ? res : res.split("\n").join(nl)) + nl : res;
162
+ };
163
+
164
+ // ../../src/package-json/src/index.ts
165
+ var PackageJson = class {
166
+ /**
167
+ * cache of `package.json` loads
168
+ */
169
+ #cache = /* @__PURE__ */ new Map();
170
+ /**
171
+ * cache of `package.json` paths by manifest
172
+ */
173
+ #pathCache = /* @__PURE__ */ new Map();
174
+ /**
175
+ * cache of load errors
176
+ */
177
+ #errCache = /* @__PURE__ */ new Map();
178
+ /**
179
+ * Reads and parses contents of a `package.json` file at a directory `dir`.
180
+ * `reload` will optionally skip reading from the cache when set to `true`.
181
+ */
182
+ read(dir, { reload } = {}) {
183
+ const cachedPackageJson = !reload && this.#cache.get(dir);
184
+ if (cachedPackageJson) {
185
+ return cachedPackageJson;
186
+ }
187
+ const filename = resolve(dir, "package.json");
188
+ const fail = (err) => error("Could not read package.json file", err, this.read);
189
+ const cachedError = !reload && this.#errCache.get(dir);
190
+ if (cachedError) {
191
+ throw fail(cachedError);
192
+ }
193
+ try {
194
+ const res = asManifest(
195
+ parse(readFileSync(filename, { encoding: "utf8" }))
196
+ );
197
+ this.#cache.set(dir, res);
198
+ this.#pathCache.set(res, dir);
199
+ return res;
200
+ } catch (err) {
201
+ const ec = {
202
+ path: filename,
203
+ cause: err
204
+ };
205
+ this.#errCache.set(dir, ec);
206
+ throw fail(ec);
207
+ }
208
+ }
209
+ write(dir, manifest, indent) {
210
+ const filename = resolve(dir, "package.json");
211
+ this.fix(manifest);
212
+ try {
213
+ writeFileSync(filename, stringify(manifest, void 0, indent));
214
+ this.#cache.set(dir, manifest);
215
+ this.#pathCache.set(manifest, dir);
216
+ } catch (err) {
217
+ this.#cache.delete(dir);
218
+ this.#pathCache.delete(manifest);
219
+ throw error(
220
+ "Could not write package.json file",
221
+ {
222
+ path: filename,
223
+ cause: err
224
+ },
225
+ this.write
226
+ );
227
+ }
228
+ }
229
+ save(manifest) {
230
+ const dir = this.#pathCache.get(manifest);
231
+ if (!dir) {
232
+ throw error(
233
+ "Could not save manifest",
234
+ {
235
+ manifest
236
+ },
237
+ this.save
238
+ );
239
+ }
240
+ this.write(dir, manifest);
241
+ }
242
+ fix(manifest) {
243
+ for (const depType of longDependencyTypes) {
244
+ const deps = manifest[depType];
245
+ if (deps) {
246
+ manifest[depType] = Object.fromEntries(
247
+ Object.entries(deps).sort(
248
+ ([a], [b]) => a.localeCompare(b, "en")
249
+ )
250
+ );
251
+ }
252
+ }
253
+ }
254
+ };
255
+
256
+ // ../../src/spec/src/index.ts
257
+ import { homedir } from "node:os";
258
+ import {
259
+ isAbsolute,
260
+ join,
261
+ resolve as resolve2,
262
+ win32 as winPath
263
+ } from "node:path";
264
+ import { inspect } from "node:util";
265
+
266
+ // ../../src/fast-split/src/index.ts
267
+ function fastSplit(str, delim, limit = -1, onPart) {
268
+ let i = 0;
269
+ let p = 0;
270
+ const l = delim.length;
271
+ const parts = [];
272
+ while (i !== -1) {
273
+ i = str.indexOf(delim, p);
274
+ const part = i === -1 || parts.length === limit - 1 ? str.substring(p) : str.substring(p, i);
275
+ parts.push(onPart?.(part, parts, i) ?? part);
276
+ if (parts.length === limit) {
277
+ return parts;
278
+ }
279
+ p = i + l;
280
+ }
281
+ return parts;
282
+ }
283
+
284
+ // ../../src/semver/src/version.ts
285
+ var maybeNumber = (s) => {
286
+ if (!/^[0-9]+$/.test(s)) return s;
287
+ const n = Number(s);
288
+ return n <= Number.MAX_SAFE_INTEGER ? n : s;
289
+ };
290
+ var safeNumber = (s, version, field) => {
291
+ const n = Number(s);
292
+ if (n > Number.MAX_SAFE_INTEGER) {
293
+ throw invalidVersion(
294
+ version,
295
+ `invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`
296
+ );
297
+ }
298
+ return n;
299
+ };
300
+ var re = {
301
+ prefix: /^[ v=]+/,
302
+ main: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/,
303
+ prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\+)/,
304
+ build: /\+([0-9a-zA-Z_.-]+)$/,
305
+ full: /^[ v=]*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\+([0-9a-zA-Z_.-]+))?$/
306
+ };
307
+ var invalidVersion = (version, message) => {
308
+ const er = syntaxError(
309
+ `invalid version: ${message}`,
310
+ { version },
311
+ Version
312
+ );
313
+ return er;
314
+ };
315
+ var Version = class _Version {
316
+ /** raw string provided to create this Version */
317
+ raw;
318
+ /** major version number */
319
+ major;
320
+ /** minor version number */
321
+ minor;
322
+ /** patch version number */
323
+ patch;
324
+ /**
325
+ * List of `'.'`-separated strings and numbers indicating that this
326
+ * version is a prerelease.
327
+ *
328
+ * This is undefined if the version does not have a prerelease section.
329
+ */
330
+ prerelease;
331
+ /**
332
+ * List of `'.'`-separated strings in the `build` section.
333
+ *
334
+ * This is undefined if the version does not have a build.
335
+ */
336
+ build;
337
+ /** Canonical strict form of this version */
338
+ toString() {
339
+ return `${this.major}.${this.minor}.${this.patch}${this.prerelease ? "-" + this.prerelease.join(".") : ""}${this.build ? "+" + this.build.join(".") : ""}`;
340
+ }
341
+ /** Generate a `Version` object from a SemVer string */
342
+ static parse(version) {
343
+ version = version.replace(re.prefix, "").trim();
344
+ if (version.length > 256) {
345
+ throw invalidVersion(
346
+ version,
347
+ "must be less than 256 characters"
348
+ );
349
+ }
350
+ const parsed = version.match(re.full);
351
+ if (!parsed) {
352
+ const main = version.match(re.main);
353
+ if (!main) {
354
+ throw invalidVersion(
355
+ version,
356
+ "no Major.minor.patch tuple present"
357
+ );
358
+ } else {
359
+ throw invalidVersion(
360
+ version,
361
+ "invalid build or patch section"
362
+ );
363
+ }
364
+ }
365
+ const [_, major_, minor_, patch_, prerelease, build] = parsed;
366
+ const major2 = safeNumber(major_, version, "major");
367
+ const minor2 = safeNumber(minor_, version, "minor");
368
+ const patch2 = safeNumber(patch_, version, "patch");
369
+ return new _Version(
370
+ version,
371
+ major2,
372
+ minor2,
373
+ patch2,
374
+ prerelease,
375
+ build
376
+ );
377
+ }
378
+ constructor(version, major2, minor2, patch2, prerelease, build) {
379
+ this.raw = version;
380
+ this.major = major2;
381
+ this.minor = minor2;
382
+ this.patch = patch2;
383
+ if (prerelease) {
384
+ this.prerelease = fastSplit(prerelease, ".", -1, (c) => {
385
+ if (!c) {
386
+ throw invalidVersion(
387
+ version,
388
+ "invalid prerelease, empty identifiers not allowed"
389
+ );
390
+ }
391
+ return maybeNumber(c);
392
+ });
393
+ }
394
+ if (build) {
395
+ this.build = fastSplit(build, ".", -1, (c) => {
396
+ if (!c) {
397
+ throw invalidVersion(
398
+ version,
399
+ "invalid build metadata, empty identifiers not allowed"
400
+ );
401
+ }
402
+ });
403
+ }
404
+ }
405
+ /**
406
+ * Return 1 if this is > the provided version, -1 if we're less, or 0 if
407
+ * they are equal.
408
+ *
409
+ * No special handling for prerelease versions, this is just a precedence
410
+ * comparison.
411
+ *
412
+ * This can be used to sort a list of versions by precedence:
413
+ *
414
+ * ```ts
415
+ * const versions: Version[] = getVersionsSomehow()
416
+ * const sorted = versions.sort((a, b) => a.compare(b))
417
+ * ```
418
+ */
419
+ compare(v) {
420
+ if (this.major > v.major) return 1;
421
+ if (this.major < v.major) return -1;
422
+ if (this.minor > v.minor) return 1;
423
+ if (this.minor < v.minor) return -1;
424
+ if (this.patch > v.patch) return 1;
425
+ if (this.patch < v.patch) return -1;
426
+ if (!v.prerelease?.length)
427
+ return !this.prerelease?.length ? 0 : -1;
428
+ if (!this.prerelease?.length) return 1;
429
+ const len = Math.max(this.prerelease.length, v.prerelease.length);
430
+ const me = this.prerelease;
431
+ const thee = v.prerelease;
432
+ for (let i = 0; i < len; i++) {
433
+ const m = me[i];
434
+ const t = thee[i];
435
+ if (m === t) continue;
436
+ if (t === void 0) return 1;
437
+ if (m === void 0) return -1;
438
+ if (typeof m !== typeof t) {
439
+ return typeof m === "string" ? 1 : -1;
440
+ }
441
+ return m > t ? 1 : -1;
442
+ }
443
+ return 0;
444
+ }
445
+ /**
446
+ * The inverse of compare, for sorting version lists in reverse order
447
+ */
448
+ rcompare(v) {
449
+ return -1 * this.compare(v);
450
+ }
451
+ /** true if this version is > the argument */
452
+ greaterThan(v) {
453
+ return this.compare(v) === 1;
454
+ }
455
+ /** true if this version is >= the argument */
456
+ greaterThanEqual(v) {
457
+ return this.compare(v) > -1;
458
+ }
459
+ /** true if this version is < the argument */
460
+ lessThan(v) {
461
+ return this.compare(v) === -1;
462
+ }
463
+ /** true if this version is &lt;= the argument */
464
+ lessThanEqual(v) {
465
+ return this.compare(v) < 1;
466
+ }
467
+ /** true if these two versions have equal SemVer precedence */
468
+ equals(v) {
469
+ return this.compare(v) === 0;
470
+ }
471
+ /** just compare the M.m.p parts of the version */
472
+ tupleEquals(v) {
473
+ return this.major === v.major && this.minor === v.minor && this.patch === v.patch;
474
+ }
475
+ /** true if this version satisfies the range */
476
+ satisfies(r) {
477
+ return r.test(this);
478
+ }
479
+ /**
480
+ * Increment the version in place, in the manner specified.
481
+ *
482
+ * Part behaviors:
483
+ *
484
+ * - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
485
+ * simply drop the prerelease. Otherwise, set the minor and patch to 0, and
486
+ * increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
487
+ * `2.0.0`
488
+ *
489
+ * - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
490
+ * simply drop the prerelease. Otherwise, set the patch to 0, and increment the
491
+ * minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
492
+ *
493
+ * - `'patch'` If the version has a prerelease, then simply drop the
494
+ * prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
495
+ * `1.2.3` and `1.2.3` becomes `1.2.4`.
496
+ *
497
+ * - `'premajor'` Set the patch and minor versions to `0`, increment the major
498
+ * version, and add a prerelease, using the optional identifier.
499
+ *
500
+ * - `'preminor'` Set the patch version to `0`, increment the minor version,
501
+ * and add a prerelease, using the optional identifier.
502
+ *
503
+ * - `'prepatch'` If a prerelease is already present, increment the patch
504
+ * version, otherwise leave it untouched, and add a prerelease, using the
505
+ * optional identifier.
506
+ *
507
+ * - `'prerelease'` If a prerelease version is present, then behave the same as
508
+ * `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
509
+ *
510
+ * - `'pre'` This is mostly for use by the other prerelease incrementers.
511
+ *
512
+ * - If a prerelease identifier is provided:
513
+ *
514
+ * Update that named portion of the prerelease. For example,
515
+ * `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
516
+ *
517
+ * If there is no prerelease identifier by that name, then replace the
518
+ * prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
519
+ * would result in `1.2.3-beta`.
520
+ *
521
+ * If the prerelease identifer is present, but has no numeric value
522
+ * following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
523
+ * would result in `1.2.3-beta.0`.
524
+ *
525
+ * - If no prerelease identifier is provided:
526
+ *
527
+ * If there is no current prerelease, then set the prerelease to `0`. So,
528
+ * `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
529
+ *
530
+ * If the last item in the prerelease is numeric, then increment it. So,
531
+ * `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
532
+ */
533
+ inc(part, prereleaseIdentifier) {
534
+ switch (part) {
535
+ case "premajor":
536
+ this.prerelease = void 0;
537
+ this.patch = 0;
538
+ this.minor = 0;
539
+ this.major++;
540
+ this.inc("pre", prereleaseIdentifier);
541
+ break;
542
+ case "preminor":
543
+ this.prerelease = void 0;
544
+ this.patch = 0;
545
+ this.minor++;
546
+ this.inc("pre", prereleaseIdentifier);
547
+ break;
548
+ case "prepatch":
549
+ this.prerelease = void 0;
550
+ this.inc("patch");
551
+ this.inc("pre", prereleaseIdentifier);
552
+ break;
553
+ case "prerelease":
554
+ if (!this.prerelease?.length)
555
+ this.inc("patch", prereleaseIdentifier);
556
+ this.inc("pre", prereleaseIdentifier);
557
+ break;
558
+ case "pre": {
559
+ if (!prereleaseIdentifier) {
560
+ if (!this.prerelease?.length) {
561
+ this.prerelease = [0];
562
+ break;
563
+ }
564
+ const last = this.prerelease[this.prerelease.length - 1];
565
+ if (typeof last === "number") {
566
+ this.prerelease[this.prerelease.length - 1] = last + 1;
567
+ } else {
568
+ this.prerelease.push(0);
569
+ }
570
+ break;
571
+ }
572
+ if (!this.prerelease?.length) {
573
+ this.prerelease = [prereleaseIdentifier];
574
+ break;
575
+ }
576
+ const i = this.prerelease.indexOf(
577
+ maybeNumber(prereleaseIdentifier)
578
+ );
579
+ if (i === -1) {
580
+ this.prerelease = [prereleaseIdentifier];
581
+ break;
582
+ }
583
+ const baseValue = this.prerelease[i + 1];
584
+ if (typeof baseValue === "number") {
585
+ this.prerelease[i + 1] = baseValue + 1;
586
+ break;
587
+ }
588
+ if (i === this.prerelease.length - 1) {
589
+ this.prerelease.push(0);
590
+ break;
591
+ }
592
+ this.prerelease.splice(i + 1, 0, 0);
593
+ break;
594
+ }
595
+ case "major":
596
+ if (!this.prerelease?.length || this.minor || this.patch)
597
+ this.major++;
598
+ this.prerelease = void 0;
599
+ this.patch = 0;
600
+ this.minor = 0;
601
+ break;
602
+ case "minor":
603
+ if (!this.prerelease?.length || this.patch) this.minor++;
604
+ this.prerelease = void 0;
605
+ this.patch = 0;
606
+ break;
607
+ case "patch":
608
+ if (!this.prerelease?.length) this.patch++;
609
+ this.prerelease = void 0;
610
+ break;
611
+ default:
612
+ throw typeError(
613
+ "Invalid increment identifier",
614
+ {
615
+ version: this,
616
+ found: part,
617
+ validOptions: [
618
+ "major",
619
+ "minor",
620
+ "patch",
621
+ "premajor",
622
+ "preminor",
623
+ "prepatch",
624
+ "prerelease",
625
+ "pre"
626
+ ]
627
+ },
628
+ this.inc
629
+ );
630
+ }
631
+ this.raw = this.toString();
632
+ return this;
633
+ }
634
+ };
635
+
636
+ // ../../src/semver/src/comparator.ts
637
+ var isOperator = (o) => !!o && (o === ">" || o === "<" || o === ">=" || o === "<=" || o === "" || o === "~" || o === "^" || o === "~>");
638
+ var preJunk = new Set("=v ");
639
+ var invalidComp = (c, message) => syntaxError(
640
+ `invalid comparator: '${c}' ${message}`,
641
+ { found: c },
642
+ Comparator
643
+ );
644
+ var assertNumber = (value, c, field) => {
645
+ const n = Number(value);
646
+ if (n !== n) {
647
+ throw invalidComp(
648
+ c,
649
+ `${field} must be numeric or 'x', got: '${value}'`
650
+ );
651
+ }
652
+ return n;
653
+ };
654
+ var assertVersion = (v, comp) => {
655
+ if (!v) {
656
+ throw invalidComp(comp, "no value provided for operator");
657
+ }
658
+ };
659
+ var assertMissing = (value, c, field) => {
660
+ if (value && !isX(value)) {
661
+ throw invalidComp(
662
+ c,
663
+ `cannot omit '${field}' and include subsequent fields`
664
+ );
665
+ }
666
+ };
667
+ var MAJOR = 0;
668
+ var MINOR = 1;
669
+ var PATCH = 2;
670
+ var isX = (c) => !c || c === "X" || c === "x" || c === "*";
671
+ var isFullVersion = (parsed) => void 0 !== parsed[PATCH];
672
+ var isXPatch = (parsed) => void 0 !== parsed[MINOR] && void 0 === parsed[PATCH];
673
+ var isXMinor = (parsed) => void 0 !== parsed[MAJOR] && void 0 === parsed[MINOR];
674
+ var isXMajor = (parsed) => void 0 === parsed[MAJOR];
675
+ var Comparator = class {
676
+ /**
677
+ * does this range include prereleases, even when they do not
678
+ * match the tuple in the comparator?
679
+ */
680
+ includePrerelease;
681
+ /** raw string used to create this comparator */
682
+ raw;
683
+ /** tokens extracted from the raw string input */
684
+ tokens;
685
+ /**
686
+ * Either the `any` comparator, the `none` comparator, or an operator
687
+ * and a {@link ParsedXRange}
688
+ */
689
+ tuples = [];
690
+ /** true if this comparator can not match anything */
691
+ isNone = false;
692
+ /**
693
+ * true if this comparator is a `'*'` type of range.
694
+ *
695
+ * Note that it still will not match versions with a prerelease value,
696
+ * unless the tuple in the version matches the tuple provided to the
697
+ * comparator, and the comparator version also has a prerelease value,
698
+ * unless `includePrerelease` is set.
699
+ */
700
+ isAny = false;
701
+ /** the canonical strict simplified parsed form of this constructor */
702
+ toString() {
703
+ return this.isNone ? "<0.0.0-0" : this.isAny ? "*" : (
704
+ /* c8 ignore next */
705
+ this.tuples.map((c) => isAny(c) ? "*" : c.join("")).join(" ")
706
+ );
707
+ }
708
+ constructor(comp, includePrerelease = false) {
709
+ this.includePrerelease = includePrerelease;
710
+ comp = comp.trim();
711
+ this.raw = comp;
712
+ let hyphen = false;
713
+ const rawComps = fastSplit(comp, " ", -1, (part, parts, i) => {
714
+ if (part === "-") {
715
+ if (hyphen) {
716
+ throw invalidComp(
717
+ comp,
718
+ "multiple hyphen ranges not allowed"
719
+ );
720
+ }
721
+ if (parts.length !== 1 || i === -1) {
722
+ throw invalidComp(
723
+ comp,
724
+ "hyphen must be between two versions"
725
+ );
726
+ }
727
+ hyphen = true;
728
+ } else if (hyphen && parts.length !== 2) {
729
+ throw invalidComp(comp, "hyphen range must be alone");
730
+ }
731
+ });
732
+ const comps = [];
733
+ let followingOperator = false;
734
+ let l = 0;
735
+ for (const c of rawComps) {
736
+ if (c === "") continue;
737
+ if (!followingOperator) {
738
+ followingOperator = isOperator(c);
739
+ comps.push(c);
740
+ l++;
741
+ continue;
742
+ }
743
+ comps[l - 1] += c;
744
+ followingOperator = false;
745
+ }
746
+ if (hyphen) {
747
+ const [min, _, max] = comps;
748
+ if (!min || !max) {
749
+ throw invalidComp(comp, "hyphen must be between two versions");
750
+ }
751
+ this.#parseHyphenRange(min, max);
752
+ } else if (!comps.length || comps.length === 1 && isX(comps[0])) {
753
+ this.tuples.push(this.#getComparatorAny());
754
+ } else {
755
+ for (const c of comps) {
756
+ this.#parse(c);
757
+ if (this.isNone) break;
758
+ }
759
+ }
760
+ this.tokens = comps;
761
+ this.isAny = true;
762
+ for (const c of this.tuples) {
763
+ if (Array.isArray(c) || !c.isAny) {
764
+ this.isAny = false;
765
+ break;
766
+ }
767
+ }
768
+ }
769
+ // inclusive min
770
+ #xInclusiveMin(raw) {
771
+ const z = this.includePrerelease ? "0" : void 0;
772
+ const [M, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
773
+ return M === void 0 ? this.#getComparatorAny() : [">=", new Version(raw, M, m, p, pr, build)];
774
+ }
775
+ // exclusive min
776
+ #xExclusiveMin(raw) {
777
+ const parsed = this.#parseX(raw);
778
+ if (isFullVersion(parsed)) {
779
+ return [">", new Version(raw, ...parsed)];
780
+ }
781
+ const z = this.includePrerelease ? "0" : void 0;
782
+ if (isXPatch(parsed)) {
783
+ return [
784
+ ">=",
785
+ new Version(
786
+ raw,
787
+ parsed[MAJOR],
788
+ parsed[MINOR] + 1,
789
+ 0,
790
+ z,
791
+ void 0
792
+ )
793
+ ];
794
+ }
795
+ if (isXMinor(parsed)) {
796
+ return [
797
+ ">=",
798
+ new Version(raw, parsed[MAJOR] + 1, 0, 0, z, void 0)
799
+ ];
800
+ }
801
+ this.isNone = true;
802
+ this.tuples.length = 0;
803
+ return comparatorNone;
804
+ }
805
+ #xInclusiveMax(raw) {
806
+ const parsed = this.#parseX(raw);
807
+ return isFullVersion(parsed) ? ["<=", new Version(raw, ...parsed)] : isXPatch(parsed) ? [
808
+ "<",
809
+ new Version(
810
+ raw,
811
+ parsed[MAJOR],
812
+ parsed[MINOR] + 1,
813
+ 0,
814
+ "0",
815
+ void 0
816
+ )
817
+ ] : isXMinor(parsed) ? [
818
+ "<",
819
+ new Version(raw, parsed[MAJOR] + 1, 0, 0, "0", void 0)
820
+ ] : this.#getComparatorAny();
821
+ }
822
+ #xExclusiveMax(raw) {
823
+ const z = this.includePrerelease ? "0" : void 0;
824
+ const [M = 0, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
825
+ if (M === 0 && m === 0 && p === 0 && pr === "0") {
826
+ this.isNone = true;
827
+ this.tuples.length = 0;
828
+ return comparatorNone;
829
+ }
830
+ return ["<", new Version(raw, M, m, p, pr, build)];
831
+ }
832
+ #validXM(raw, m, p) {
833
+ assertMissing(m, raw, "major");
834
+ assertMissing(p, raw, "major");
835
+ if (m === "" || p === "") {
836
+ throw invalidComp(raw, `(Did you mean '*'?)`);
837
+ }
838
+ return [];
839
+ }
840
+ #validXm(raw, M, m, p) {
841
+ assertMissing(p, raw, "major");
842
+ if (m === "" || p === "") {
843
+ throw invalidComp(raw, `(Did you mean '${M}'?)`);
844
+ }
845
+ return [assertNumber(M, raw, "major")];
846
+ }
847
+ #validXp(raw, M, m, p) {
848
+ if (p === "") {
849
+ throw invalidComp(raw, `(Did you mean '${M}.${m}'?)`);
850
+ }
851
+ return [
852
+ assertNumber(M, raw, "major"),
853
+ assertNumber(m, raw, "minor")
854
+ ];
855
+ }
856
+ #validTuple(raw, M, m, p) {
857
+ return [
858
+ assertNumber(M, raw, "major"),
859
+ assertNumber(m, raw, "minor"),
860
+ assertNumber(p, raw, "patch")
861
+ ];
862
+ }
863
+ #validXbuild(raw, M, m, p, pl) {
864
+ const patch2 = p.substring(0, pl);
865
+ const build = p.substring(pl + 1);
866
+ if (!patch2) {
867
+ throw invalidComp(raw, "cannot specify build without patch");
868
+ }
869
+ if (!build) {
870
+ throw invalidComp(raw, `encountered '+', but no build value`);
871
+ }
872
+ return [
873
+ assertNumber(M, raw, "major"),
874
+ assertNumber(m, raw, "minor"),
875
+ assertNumber(patch2, raw, "patch"),
876
+ void 0,
877
+ build
878
+ ];
879
+ }
880
+ #validXpr(raw, M, m, p, hy) {
881
+ {
882
+ const patch2 = p.substring(0, hy);
883
+ const pr = p.substring(hy + 1);
884
+ if (!patch2) {
885
+ throw invalidComp(
886
+ raw,
887
+ "cannot specify prerelease without patch"
888
+ );
889
+ }
890
+ if (!pr) {
891
+ throw invalidComp(
892
+ raw,
893
+ `encountered '-', but no prerelease value`
894
+ );
895
+ }
896
+ return [
897
+ assertNumber(M, raw, "major"),
898
+ assertNumber(m, raw, "minor"),
899
+ assertNumber(patch2, raw, "patch"),
900
+ pr,
901
+ void 0
902
+ ];
903
+ }
904
+ }
905
+ #validXprbuild(raw, M, m, p, hy, pl) {
906
+ const patch2 = p.substring(0, hy);
907
+ const pr = p.substring(hy + 1, pl);
908
+ const build = p.substring(pl + 1);
909
+ if (!patch2) {
910
+ throw invalidComp(
911
+ raw,
912
+ "cannot specify prerelease without patch"
913
+ );
914
+ }
915
+ if (!pr) {
916
+ throw invalidComp(
917
+ raw,
918
+ `encountered '-', but no prerelease value`
919
+ );
920
+ }
921
+ if (!build) {
922
+ throw invalidComp(raw, `encountered '+', but no build value`);
923
+ }
924
+ return [
925
+ assertNumber(M, raw, "major"),
926
+ assertNumber(m, raw, "minor"),
927
+ assertNumber(patch2, raw, "patch"),
928
+ pr,
929
+ build
930
+ ];
931
+ }
932
+ // pull the relevant values out of an X-range or version
933
+ // return the fields for creating a Version object.
934
+ // only call once operator is stripped off
935
+ #parseX(raw) {
936
+ let [M, m, p] = fastSplit(raw, ".", 3);
937
+ let prune = 0;
938
+ while (M && preJunk.has(M.charAt(prune))) prune++;
939
+ if (M !== void 0 && prune !== 0) M = M.substring(prune);
940
+ if (!M || isX(M)) return this.#validXM(raw, m, p);
941
+ if (!m || isX(m)) return this.#validXm(raw, M, m, p);
942
+ if (!p || isX(p)) return this.#validXp(raw, M, m, p);
943
+ const hy = p.indexOf("-");
944
+ const pl = p.indexOf("+");
945
+ if (pl === -1 && hy === -1) return this.#validTuple(raw, M, m, p);
946
+ if (pl === -1) return this.#validXpr(raw, M, m, p, hy);
947
+ if (hy === -1) return this.#validXbuild(raw, M, m, p, pl);
948
+ return this.#validXprbuild(raw, M, m, p, hy, pl);
949
+ }
950
+ #parseHyphenRange(min, max) {
951
+ const minv = this.#xInclusiveMin(min);
952
+ const maxv = this.#xInclusiveMax(max);
953
+ const minAny = isAny(minv);
954
+ const maxAny = isAny(maxv);
955
+ if (minAny && maxAny) this.tuples.push(this.#getComparatorAny());
956
+ else if (minAny) this.tuples.push(maxv);
957
+ else if (maxAny) this.tuples.push(minv);
958
+ else this.tuples.push(minv, maxv);
959
+ }
960
+ #parse(comp) {
961
+ const first = comp.charAt(0);
962
+ const first2 = comp.substring(0, 2);
963
+ const v1 = comp.substring(1);
964
+ const v2 = comp.substring(2);
965
+ switch (first2) {
966
+ case "~>":
967
+ assertVersion(v2, comp);
968
+ return this.#parseTilde(v2);
969
+ case ">=":
970
+ assertVersion(v2, comp);
971
+ return this.tuples.push(this.#xInclusiveMin(v2));
972
+ case "<=":
973
+ assertVersion(v2, comp);
974
+ return this.tuples.push(this.#xInclusiveMax(v2));
975
+ }
976
+ switch (first) {
977
+ case "~":
978
+ assertVersion(v1, comp);
979
+ return this.#parseTilde(v1);
980
+ case "^":
981
+ assertVersion(v1, comp);
982
+ return this.#parseCaret(v1);
983
+ case ">":
984
+ assertVersion(v1, comp);
985
+ return this.tuples.push(this.#xExclusiveMin(v1));
986
+ case "<":
987
+ assertVersion(v1, comp);
988
+ return this.tuples.push(this.#xExclusiveMax(v1));
989
+ }
990
+ return this.#parseEq(comp);
991
+ }
992
+ #parseTilde(comp) {
993
+ const parsed = this.#parseX(comp);
994
+ if (isXMajor(parsed)) {
995
+ this.tuples.push(this.#getComparatorAny());
996
+ return;
997
+ }
998
+ const z = this.includePrerelease ? "0" : void 0;
999
+ if (isXMinor(parsed)) {
1000
+ const [M2] = parsed;
1001
+ this.tuples.push(
1002
+ [">=", new Version(comp, M2, 0, 0, z, void 0)],
1003
+ ["<", new Version(comp, M2 + 1, 0, 0, "0", void 0)]
1004
+ );
1005
+ return;
1006
+ }
1007
+ if (isXPatch(parsed)) {
1008
+ const [M2, m2] = parsed;
1009
+ const z2 = this.includePrerelease ? "0" : void 0;
1010
+ this.tuples.push(
1011
+ [">=", new Version(comp, M2, m2, 0, z2, void 0)],
1012
+ ["<", new Version(comp, M2, m2 + 1, 0, "0", void 0)]
1013
+ );
1014
+ return;
1015
+ }
1016
+ const [M, m, p, pr = z, build] = parsed;
1017
+ this.tuples.push(
1018
+ [">=", new Version(comp, M, m, p, pr, build)],
1019
+ ["<", new Version(comp, M, m + 1, 0, "0", build)]
1020
+ );
1021
+ }
1022
+ #parseCaret(comp) {
1023
+ const min = this.#xInclusiveMin(comp);
1024
+ if (isAny(min)) {
1025
+ this.tuples.push(min);
1026
+ return;
1027
+ }
1028
+ const minv = min[1];
1029
+ if (minv.major !== 0) {
1030
+ this.tuples.push(min, [
1031
+ "<",
1032
+ new Version(comp, minv.major + 1, 0, 0, "0", void 0)
1033
+ ]);
1034
+ } else if (minv.minor !== 0) {
1035
+ this.tuples.push(min, [
1036
+ "<",
1037
+ new Version(
1038
+ comp,
1039
+ minv.major,
1040
+ minv.minor + 1,
1041
+ 0,
1042
+ "0",
1043
+ void 0
1044
+ )
1045
+ ]);
1046
+ } else if (!minv.prerelease?.length) {
1047
+ this.tuples.push(["", minv]);
1048
+ } else {
1049
+ this.tuples.push(min, [
1050
+ "<",
1051
+ new Version(
1052
+ comp,
1053
+ minv.major,
1054
+ minv.minor,
1055
+ minv.patch + 1,
1056
+ "0",
1057
+ void 0
1058
+ )
1059
+ ]);
1060
+ }
1061
+ }
1062
+ #parseEq(comp) {
1063
+ const parsed = this.#parseX(comp);
1064
+ const z = this.includePrerelease ? "0" : void 0;
1065
+ if (isFullVersion(parsed)) {
1066
+ this.tuples.push(["", new Version(comp, ...parsed)]);
1067
+ } else if (isXMajor(parsed)) {
1068
+ this.tuples.push(this.#getComparatorAny());
1069
+ } else if (isXMinor(parsed)) {
1070
+ this.tuples.push([
1071
+ ">=",
1072
+ new Version(comp, parsed[MAJOR], 0, 0, z, void 0)
1073
+ ]);
1074
+ this.tuples.push([
1075
+ "<",
1076
+ new Version(comp, parsed[MAJOR] + 1, 0, 0, "0", void 0)
1077
+ ]);
1078
+ } else if (isXPatch(parsed)) {
1079
+ this.tuples.push(
1080
+ [
1081
+ ">=",
1082
+ new Version(
1083
+ comp,
1084
+ parsed[MAJOR],
1085
+ parsed[MINOR],
1086
+ 0,
1087
+ z,
1088
+ void 0
1089
+ )
1090
+ ],
1091
+ [
1092
+ "<",
1093
+ new Version(
1094
+ comp,
1095
+ parsed[MAJOR],
1096
+ parsed[MINOR] + 1,
1097
+ 0,
1098
+ "0",
1099
+ void 0
1100
+ )
1101
+ ]
1102
+ );
1103
+ }
1104
+ }
1105
+ /** return true if the version is a match for this comparator */
1106
+ test(v) {
1107
+ if (this.isNone) return false;
1108
+ const ip = this.includePrerelease;
1109
+ const hasPR = !!v.prerelease?.length;
1110
+ let prOK = ip || !hasPR;
1111
+ for (const c of this.tuples) {
1112
+ if (isAny(c)) {
1113
+ continue;
1114
+ }
1115
+ const [op, cv] = c;
1116
+ prOK ||= !!cv.prerelease?.length && v.tupleEquals(cv);
1117
+ switch (op) {
1118
+ case "":
1119
+ if (!v.equals(cv)) return false;
1120
+ continue;
1121
+ case ">":
1122
+ if (!v.greaterThan(cv)) return false;
1123
+ continue;
1124
+ case ">=":
1125
+ if (!v.greaterThanEqual(cv)) return false;
1126
+ continue;
1127
+ case "<":
1128
+ if (!v.lessThan(cv)) return false;
1129
+ continue;
1130
+ case "<=":
1131
+ if (!v.lessThanEqual(cv)) return false;
1132
+ continue;
1133
+ }
1134
+ }
1135
+ return prOK;
1136
+ }
1137
+ #getComparatorAny() {
1138
+ return this.includePrerelease ? comparatorAnyPR : comparatorAny;
1139
+ }
1140
+ };
1141
+ var isAny = (c) => c === comparatorAny || c === comparatorAnyPR;
1142
+ var comparatorAny = {
1143
+ isAny: true,
1144
+ toString: () => "*",
1145
+ includePrerelease: false,
1146
+ test: (v) => !v.prerelease?.length
1147
+ };
1148
+ var comparatorAnyPR = {
1149
+ isAny: true,
1150
+ toString: () => "*",
1151
+ includePrerelease: true,
1152
+ test: (_) => true
1153
+ };
1154
+ var comparatorNone = {
1155
+ isNone: true,
1156
+ toString: () => "<0.0.0-0",
1157
+ includePrerelease: false,
1158
+ test: (_) => false
1159
+ };
1160
+
1161
+ // ../../src/semver/src/range.ts
1162
+ var Range = class {
1163
+ /** raw string used to create this Range */
1164
+ raw;
1165
+ /** true if the range is `*` */
1166
+ isAny;
1167
+ /** true if the range is a single semver version */
1168
+ isSingle;
1169
+ /** true if the range cannot match anything */
1170
+ /**
1171
+ * set of {@link Comparator} objects representing the `||`-separated sections
1172
+ * of the range. If at least one of these matches, then the version is a
1173
+ * match.
1174
+ */
1175
+ set = [];
1176
+ /** true if all prerelease versions should be included */
1177
+ includePrerelease;
1178
+ /** cached toString */
1179
+ #toString;
1180
+ constructor(range, includePrerelease = false) {
1181
+ this.raw = range;
1182
+ this.includePrerelease = includePrerelease;
1183
+ this.isAny = false;
1184
+ let isFirst = true;
1185
+ this.isSingle = false;
1186
+ fastSplit(range, "||", -1, (part) => {
1187
+ if (this.isAny) return;
1188
+ const cmp = new Comparator(part, this.includePrerelease);
1189
+ if (cmp.isAny) {
1190
+ this.set = [cmp];
1191
+ this.isAny = true;
1192
+ return;
1193
+ }
1194
+ this.set.push(cmp);
1195
+ if (!isFirst) this.isSingle = false;
1196
+ else if (Array.isArray(cmp.tuples) && cmp.tuples.length === 1 && Array.isArray(cmp.tuples[0]) && cmp.tuples[0][0] === "") {
1197
+ this.isSingle = true;
1198
+ }
1199
+ isFirst = false;
1200
+ });
1201
+ }
1202
+ /**
1203
+ * test a {@link Version} against the range
1204
+ */
1205
+ test(v) {
1206
+ return this.set.some((c) => c.test(v));
1207
+ }
1208
+ /** return the simplified canonical form of this range */
1209
+ toString() {
1210
+ if (this.#toString) return this.#toString;
1211
+ if (this.isSingle) {
1212
+ this.#toString = String(this.set[0]);
1213
+ return this.#toString;
1214
+ }
1215
+ this.#toString = this.set.map((c) => String(c)).join(" || ");
1216
+ return this.#toString;
1217
+ }
1218
+ };
1219
+
1220
+ // ../../src/semver/src/index.ts
1221
+ var parse2 = (version) => {
1222
+ if (version instanceof Version) return version;
1223
+ try {
1224
+ return Version.parse(String(version));
1225
+ } catch {
1226
+ return void 0;
1227
+ }
1228
+ };
1229
+ var parseRange = (range, includePrerelease = false) => {
1230
+ if (typeof range === "object") {
1231
+ if (range.includePrerelease === includePrerelease) return range;
1232
+ range = range.raw;
1233
+ }
1234
+ try {
1235
+ return new Range(range, includePrerelease);
1236
+ } catch {
1237
+ return void 0;
1238
+ }
1239
+ };
1240
+ var satisfies = (version, range, includePrerelease = false) => {
1241
+ if (typeof version === "string") {
1242
+ const parsed = parse2(version);
1243
+ if (!parsed) return false;
1244
+ version = parsed;
1245
+ }
1246
+ if (typeof range === "string") {
1247
+ const parsed = parseRange(range, includePrerelease);
1248
+ if (!parsed) return false;
1249
+ range = parsed;
1250
+ }
1251
+ return version.satisfies(range);
1252
+ };
1253
+ var compare = (versionA, versionB) => {
1254
+ const a = parse2(versionA);
1255
+ if (!a) {
1256
+ throw syntaxError("invalid version", { found: versionA });
1257
+ }
1258
+ const b = parse2(versionB);
1259
+ if (!b) {
1260
+ throw syntaxError("invalid version", { found: versionB });
1261
+ }
1262
+ return a.compare(b);
1263
+ };
1264
+ var gt = (versionA, versionB) => compare(versionA, versionB) > 0;
1265
+ var gte = (versionA, versionB) => compare(versionA, versionB) >= 0;
1266
+ var lt = (versionA, versionB) => compare(versionA, versionB) < 0;
1267
+ var lte = (versionA, versionB) => compare(versionA, versionB) <= 0;
1268
+ var neq = (versionA, versionB) => compare(versionA, versionB) !== 0;
1269
+ var eq = (versionA, versionB) => compare(versionA, versionB) === 0;
1270
+ var major = (version) => parse2(version)?.major;
1271
+ var minor = (version) => parse2(version)?.minor;
1272
+ var patch = (version) => parse2(version)?.patch;
1273
+
1274
+ // ../../src/spec/src/browser.ts
1275
+ var kCustomInspect = Symbol.for("nodejs.util.inspect.custom");
1276
+ var defaultRegistry = "https://registry.npmjs.org/";
1277
+ var defaultRegistries = {
1278
+ npm: "https://registry.npmjs.org/"
1279
+ };
1280
+ var defaultGitHosts = {
1281
+ github: "git+ssh://git@github.com:$1/$2.git",
1282
+ bitbucket: "git+ssh://git@bitbucket.org:$1/$2.git",
1283
+ gitlab: "git+ssh://git@gitlab.com:$1/$2.git",
1284
+ gist: "git+ssh://git@gist.github.com/$1.git"
1285
+ };
1286
+ var defaultGitHostArchives = {
1287
+ github: "https://codeload.github.com/$1/$2/tar.gz/$committish",
1288
+ bitbucket: "https://bitbucket.org/$1/$2/get/$committish.tar.gz",
1289
+ gist: "https://codeload.github.com/gist/$1/tar.gz/$committish",
1290
+ gitlab: "https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish"
1291
+ };
1292
+ var gitHostWebsites = {
1293
+ github: "https://github.com/",
1294
+ bitbucket: "https://bitbucket.org/",
1295
+ gist: "https://gist.github.com/",
1296
+ gitlab: "https://gitlab.com/"
1297
+ };
1298
+ var defaultScopeRegistries = {};
1299
+ var getOptions = (options) => ({
1300
+ ...options,
1301
+ registry: options?.registry ?? defaultRegistry,
1302
+ "scope-registries": options?.["scope-registries"] ?? {},
1303
+ "git-hosts": options?.["git-hosts"] ? {
1304
+ ...defaultGitHosts,
1305
+ ...options["git-hosts"]
1306
+ } : defaultGitHosts,
1307
+ registries: options?.registries ? {
1308
+ ...defaultRegistries,
1309
+ ...options.registries
1310
+ } : defaultRegistries,
1311
+ "git-host-archives": options?.["git-host-archives"] ? {
1312
+ ...defaultGitHostArchives,
1313
+ ...options["git-host-archives"]
1314
+ } : defaultGitHostArchives
1315
+ });
1316
+ var startsWithSpecIdentifier = (spec, options) => spec.startsWith("/") || spec.startsWith("./") || spec.startsWith("../") || spec.startsWith("file:") || spec.startsWith("http:") || spec.startsWith("https:") || spec.startsWith("workspace:") || spec.startsWith("git@") || spec.startsWith("git://") || spec.startsWith("git+ssh://") || spec.startsWith("git+http://") || spec.startsWith("git+https://") || spec.startsWith("git+file://") || spec.startsWith("git@github.com") || spec.startsWith("registry:") || // anything that starts with a known git host key, or a
1317
+ // custom registered registry protocol e.g: `github:`, `custom:`
1318
+ [
1319
+ ...Object.keys(options["git-hosts"]),
1320
+ ...Object.keys(options.registries)
1321
+ ].some((key) => spec.startsWith(`${key}:`));
1322
+ var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
1323
+ var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
1324
+ var findFileIdentifier = (spec) => spec.includes("/");
1325
+ var Spec = class {
1326
+ static parse(spec, bareOrOptions, options) {
1327
+ return typeof spec === "object" ? spec : new this(spec, bareOrOptions, options);
1328
+ }
1329
+ static parseArgs(specOrBareSpec, opts) {
1330
+ const options = getOptions(opts ?? {});
1331
+ if (startsWithSpecIdentifier(specOrBareSpec, options)) {
1332
+ const parsed = this.parse("(unknown)", specOrBareSpec, options);
1333
+ if (parsed.subspec) {
1334
+ parsed.name = parsed.subspec.name;
1335
+ parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
1336
+ }
1337
+ return parsed;
1338
+ } else {
1339
+ const hasScope = specOrBareSpec.startsWith("@");
1340
+ const at = findFirstAt(specOrBareSpec, hasScope);
1341
+ if (at > -1) {
1342
+ return this.parse(
1343
+ specOrBareSpec.substring(0, at),
1344
+ specOrBareSpec.substring(at + 1),
1345
+ options
1346
+ );
1347
+ } else if (findGitIdentifier(specOrBareSpec) || !hasScope && findFileIdentifier(specOrBareSpec)) {
1348
+ return this.parse("(unknown)", specOrBareSpec, options);
1349
+ } else {
1350
+ return this.parse(`${specOrBareSpec}@`, options);
1351
+ }
1352
+ }
1353
+ }
1354
+ static nodejsDependencies;
1355
+ type;
1356
+ spec;
1357
+ options;
1358
+ name;
1359
+ scope;
1360
+ scopeRegistry;
1361
+ bareSpec;
1362
+ gitRemote;
1363
+ gitSelector;
1364
+ gitSelectorParsed;
1365
+ gitCommittish;
1366
+ namedGitHost;
1367
+ namedGitHostPath;
1368
+ workspaceSpec;
1369
+ workspace;
1370
+ namedRegistry;
1371
+ registry;
1372
+ registrySpec;
1373
+ conventionalRegistryTarball;
1374
+ semver;
1375
+ range;
1376
+ distTag;
1377
+ remoteURL;
1378
+ file;
1379
+ subspec;
1380
+ #final;
1381
+ #toString;
1382
+ /**
1383
+ * Return the final entry in the chain of subspecs
1384
+ * When deciding which thing to actually fetch, spec.final is the thing
1385
+ * to look at.
1386
+ */
1387
+ get final() {
1388
+ if (this.#final) return this.#final;
1389
+ return this.#final = this.subspec ? this.subspec.final : this;
1390
+ }
1391
+ /**
1392
+ * Normally, the string value of a Spec is just the string passed in to
1393
+ * be parsed. However, in the case of a chain of subspecs, like
1394
+ * `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
1395
+ * parts of the chain, returning just `foo@npm:quux@latest`
1396
+ */
1397
+ toString() {
1398
+ if (this.#toString !== void 0) return this.#toString;
1399
+ let sub = this;
1400
+ while (sub.subspec?.subspec) sub = sub.subspec;
1401
+ if (sub.subspec && sub.subspec.type !== "registry")
1402
+ sub = sub.subspec;
1403
+ return this.#toString = this.name + "@" + sub.bareSpec;
1404
+ }
1405
+ constructor(spec, bareOrOptions, options = {}) {
1406
+ if (bareOrOptions && typeof bareOrOptions === "object") {
1407
+ options = bareOrOptions;
1408
+ bareOrOptions = void 0;
1409
+ }
1410
+ this.options = getOptions(options);
1411
+ if (typeof bareOrOptions === "string") {
1412
+ this.name = spec;
1413
+ this.#parseScope(spec);
1414
+ this.bareSpec = bareOrOptions;
1415
+ this.spec = `${this.name}@${bareOrOptions}`;
1416
+ } else {
1417
+ this.spec = spec;
1418
+ const hasScope = spec.startsWith("@");
1419
+ let at = findFirstAt(spec, hasScope);
1420
+ if (at === -1) {
1421
+ at = spec.length;
1422
+ spec += "@";
1423
+ }
1424
+ this.name = spec.substring(0, at);
1425
+ if (hasScope) this.#parseScope(this.name);
1426
+ this.bareSpec = spec.substring(at + 1);
1427
+ }
1428
+ if (this.bareSpec.startsWith("https://")) {
1429
+ for (const [name, origin] of Object.entries(gitHostWebsites)) {
1430
+ if (this.bareSpec.startsWith(origin)) {
1431
+ const parsed = new URL(this.bareSpec);
1432
+ const [user, project] = parsed.pathname.replace(/\.git$/, "").replace(/\/+/g, " ").trim().split(" ");
1433
+ if (user && project) {
1434
+ this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
1435
+ this.spec = `${this.name}@${this.bareSpec}`;
1436
+ break;
1437
+ }
1438
+ }
1439
+ }
1440
+ }
1441
+ if (this.bareSpec.startsWith("workspace:")) {
1442
+ this.type = "workspace";
1443
+ const ws = this.bareSpec.substring("workspace:".length).trim();
1444
+ const w = ws.lastIndexOf("@");
1445
+ if (w === -1) {
1446
+ this.workspace = this.name;
1447
+ } else {
1448
+ const wsName = ws.substring(0, w);
1449
+ if (!wsName || wsName === "*" || wsName === "~" || wsName === "^" || (wsName.startsWith("@") ? wsName.split("/").length !== 2 || wsName.substring(1).includes("@") : wsName.includes("@"))) {
1450
+ throw this.#error(
1451
+ "workspace: name must be a path or valid package name",
1452
+ { found: wsName }
1453
+ );
1454
+ }
1455
+ this.workspace = wsName;
1456
+ }
1457
+ const wss = w === -1 ? ws : ws.substring(w + 1) || "*";
1458
+ const range2 = wss === "*" ? void 0 : parseRange(wss);
1459
+ if (wss !== "*" && wss !== "~" && wss !== "^" && !range2) {
1460
+ throw this.#error(
1461
+ "workspace: spec must be one of *, ~, or ^, or a valid semver range",
1462
+ {
1463
+ found: wss,
1464
+ wanted: `'*'|'~'|'^'|SemverRange`
1465
+ }
1466
+ );
1467
+ }
1468
+ this.workspaceSpec = wss;
1469
+ if (range2) {
1470
+ this.semver = wss;
1471
+ this.range = range2;
1472
+ }
1473
+ return;
1474
+ }
1475
+ if (this.bareSpec.startsWith("git://") || this.bareSpec.startsWith("git+ssh://") || this.bareSpec.startsWith("git+http://") || this.bareSpec.startsWith("git+https://") || this.bareSpec.startsWith("git+file://") || // legacy affordance
1476
+ this.bareSpec.startsWith("git@github.com")) {
1477
+ if (this.bareSpec.startsWith("git@")) {
1478
+ this.bareSpec = `git+ssh://${this.bareSpec}`;
1479
+ this.spec = `${this.name}@${this.bareSpec}`;
1480
+ }
1481
+ this.type = "git";
1482
+ for (const [name, host] of Object.entries(
1483
+ this.options["git-hosts"]
1484
+ )) {
1485
+ const s = host.indexOf("$");
1486
+ if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
1487
+ const p = this.bareSpec.substring(s).replace(/\.git(#.*)?$/, "$1");
1488
+ this.bareSpec = `${name}:${p}`;
1489
+ this.spec = `${this.name}@${this.bareSpec}`;
1490
+ this.#parseHostedGit(name, host);
1491
+ this.type = "git";
1492
+ return;
1493
+ }
1494
+ }
1495
+ this.#parseGitSelector(this.bareSpec);
1496
+ return;
1497
+ }
1498
+ const ghosts = Object.entries(this.options["git-hosts"]);
1499
+ for (const [name, template] of ghosts) {
1500
+ if (this.#parseHostedGit(name, template)) {
1501
+ this.type = "git";
1502
+ return;
1503
+ }
1504
+ }
1505
+ if (this.bareSpec.startsWith("registry:")) {
1506
+ const reg = this.bareSpec.substring("registry:".length);
1507
+ const h = reg.indexOf("#");
1508
+ if (h === -1) {
1509
+ throw this.#error("registry: must include name/version");
1510
+ }
1511
+ this.type = "registry";
1512
+ let url = reg.substring(0, h);
1513
+ if (!url.endsWith("/")) url += "/";
1514
+ const regSpec = reg.substring(h + 1);
1515
+ for (let [name, u] of Object.entries(this.options.registries)) {
1516
+ if (!u.endsWith("/")) {
1517
+ u += "/";
1518
+ this.options.registries[name] = u;
1519
+ }
1520
+ if (u === url) this.namedRegistry = name;
1521
+ }
1522
+ this.#parseRegistrySpec(regSpec, url);
1523
+ this.#guessRegistryTarball();
1524
+ return;
1525
+ }
1526
+ const regs = Object.entries(this.options.registries);
1527
+ for (const [host, url] of regs) {
1528
+ const h = `${host}:`;
1529
+ if (this.bareSpec.startsWith(h)) {
1530
+ this.type = "registry";
1531
+ this.namedRegistry = host;
1532
+ this.#parseRegistrySpec(
1533
+ this.bareSpec.substring(h.length),
1534
+ url
1535
+ ).namedRegistry ??= host;
1536
+ this.#guessRegistryTarball();
1537
+ return;
1538
+ }
1539
+ }
1540
+ if (this.bareSpec.startsWith("https://") || this.bareSpec.startsWith("http://")) {
1541
+ this.remoteURL = this.bareSpec;
1542
+ this.type = "remote";
1543
+ return;
1544
+ }
1545
+ if (this.bareSpec.startsWith("file:")) {
1546
+ this.type = "file";
1547
+ const [path, uri] = getNormalizeFile(
1548
+ this.constructor.nodejsDependencies
1549
+ )(this.bareSpec, this);
1550
+ this.file = path;
1551
+ this.bareSpec = uri.replace(/\/+$/, "");
1552
+ this.spec = `${this.name}@${this.bareSpec}`;
1553
+ return;
1554
+ }
1555
+ if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
1556
+ const hash = this.bareSpec.indexOf("#");
1557
+ const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
1558
+ if (up.split("/").length === 2) {
1559
+ this.bareSpec = `github:${this.bareSpec}`;
1560
+ this.spec = `${this.name}@${this.bareSpec}`;
1561
+ this.#parseHostedGit(
1562
+ "github",
1563
+ this.options["git-hosts"].github
1564
+ );
1565
+ this.type = "git";
1566
+ return;
1567
+ }
1568
+ }
1569
+ if (this.bareSpec.includes("/") || this.bareSpec === "." || this.bareSpec === "..") {
1570
+ this.type = "file";
1571
+ const [file, uri] = getNormalizeFile(
1572
+ this.constructor.nodejsDependencies
1573
+ )(`file:${this.bareSpec}`, this);
1574
+ this.bareSpec = uri;
1575
+ this.spec = `${this.name}@${this.bareSpec}`;
1576
+ this.file = file;
1577
+ return;
1578
+ }
1579
+ this.type = "registry";
1580
+ const range = parseRange(this.bareSpec);
1581
+ if (range) {
1582
+ this.semver = this.bareSpec.trim();
1583
+ this.range = range;
1584
+ } else {
1585
+ this.distTag = this.bareSpec;
1586
+ }
1587
+ this.registrySpec = this.bareSpec;
1588
+ const { "scope-registries": scopeRegs, registry } = this.options;
1589
+ const scopeReg = this.scope && scopeRegs[this.scope];
1590
+ this.registry = scopeReg ?? registry;
1591
+ this.#guessRegistryTarball();
1592
+ }
1593
+ #parseScope(name) {
1594
+ if (!name.startsWith("@")) return;
1595
+ const s = name.indexOf("/");
1596
+ if (s > 1 && s < name.length - 1) {
1597
+ const scope = name.substring(0, s);
1598
+ this.registry = this.scopeRegistry = this.options["scope-registries"][scope];
1599
+ this.scope = scope;
1600
+ }
1601
+ }
1602
+ #parseHostedGit(name, template) {
1603
+ if (this.bareSpec.startsWith(`${name}:`)) {
1604
+ const h = this.bareSpec.indexOf("#");
1605
+ const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
1606
+ const hash = h === -1 ? "" : this.bareSpec.substring(h);
1607
+ const hostPath = bare.substring(name.length + 1);
1608
+ if (!hostPath) {
1609
+ throw error("invalid named git host specifier", {
1610
+ spec: this
1611
+ });
1612
+ }
1613
+ const split = hostPath.split("/");
1614
+ let t = template;
1615
+ for (let i = 0; i < split.length; i++) {
1616
+ t = t.split(`$${i + 1}`).join(split[i]);
1617
+ }
1618
+ t += hash;
1619
+ this.namedGitHost = name;
1620
+ this.namedGitHostPath = hostPath;
1621
+ this.#parseGitSelector(t);
1622
+ if (this.gitCommittish && !this.gitSelectorParsed?.path) {
1623
+ const archiveHost = this.options["git-host-archives"][name];
1624
+ if (archiveHost) {
1625
+ this.type = "remote";
1626
+ let t2 = archiveHost;
1627
+ t2 = t2.split("$committish").join(this.gitCommittish);
1628
+ for (let i = 0; i < split.length; i++) {
1629
+ t2 = t2.split(`$${i + 1}`).join(split[i]);
1630
+ }
1631
+ this.remoteURL = t2;
1632
+ }
1633
+ }
1634
+ return true;
1635
+ }
1636
+ return false;
1637
+ }
1638
+ /* c8 ignore start */
1639
+ [kCustomInspect]() {
1640
+ return `@vltpkg/spec.Spec ${String(this)}`;
1641
+ }
1642
+ /* c8 ignore stop */
1643
+ #guessRegistryTarball() {
1644
+ const { name, registry, range } = this.final;
1645
+ if (!registry || !range?.isSingle) return;
1646
+ const stripScope = /^@[^/]+\//;
1647
+ this.conventionalRegistryTarball = String(
1648
+ new URL(
1649
+ `/${name}/-/${name.replace(stripScope, "")}-${range}.tgz`,
1650
+ registry
1651
+ )
1652
+ );
1653
+ }
1654
+ #parseRegistrySpec(s, url) {
1655
+ this.registry = url;
1656
+ this.subspec = this.constructor.parse(s, {
1657
+ ...this.options,
1658
+ registry: url
1659
+ });
1660
+ return this.subspec;
1661
+ }
1662
+ #error(message, extra = {}) {
1663
+ return error(message, { spec: this.spec, ...extra }, this.#error);
1664
+ }
1665
+ #parseGitSelector(s) {
1666
+ const h = s.indexOf("#");
1667
+ if (h === -1) {
1668
+ this.gitRemote = s;
1669
+ return;
1670
+ }
1671
+ this.gitRemote = s.substring(0, h);
1672
+ this.gitSelector = s.substring(h + 1);
1673
+ const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
1674
+ this.range = range;
1675
+ this.gitCommittish = committish;
1676
+ this.gitSelectorParsed = selectorParsed;
1677
+ }
1678
+ /**
1679
+ * Should only ever be called with the bit that comes AFTER the #
1680
+ * in the git remote url.
1681
+ */
1682
+ static parseGitSelector(selector, spec) {
1683
+ if (!selector) return [{}];
1684
+ const split = selector.split("::");
1685
+ const first = split[0];
1686
+ let committish = void 0;
1687
+ let range = void 0;
1688
+ const parsed = {};
1689
+ if (typeof first !== "string") {
1690
+ throw typeError("impossible", {
1691
+ found: first,
1692
+ wanted: String
1693
+ });
1694
+ }
1695
+ if (!first.includes(":")) {
1696
+ committish = first;
1697
+ split.shift();
1698
+ }
1699
+ for (const kv of split) {
1700
+ const c = kv.indexOf(":");
1701
+ if (c === -1) continue;
1702
+ const k = kv.substring(0, c);
1703
+ const v = kv.substring(c + 1);
1704
+ if (k === "semver") {
1705
+ if (committish) {
1706
+ throw error(
1707
+ "Cannot specify a semver range and committish value",
1708
+ { spec }
1709
+ );
1710
+ }
1711
+ range = parseRange(v);
1712
+ if (!range) {
1713
+ throw error(`Invalid git tag semver range: ${v}`, { spec });
1714
+ }
1715
+ }
1716
+ if (k === "semver" || k === "path") {
1717
+ if (k === "path") {
1718
+ if (
1719
+ /* c8 ignore next */
1720
+ this.nodejsDependencies?.isAbsolute(
1721
+ v
1722
+ ) || /(^|\/|\\)\.\.($|\\|\/)/.test(v)
1723
+ ) {
1724
+ throw error("Invalid path in git selector", { spec });
1725
+ }
1726
+ parsed.path = (this.nodejsDependencies ? this.nodejsDependencies.join("/", v).substring(1) : v).replace(/\\/g, "/");
1727
+ } else {
1728
+ parsed[k] = v;
1729
+ }
1730
+ }
1731
+ }
1732
+ return [parsed, committish, range];
1733
+ }
1734
+ };
1735
+ var getNormalizeFile = (opts) => (bareSpec, spec) => {
1736
+ const slashes = bareSpec.substring(
1737
+ "file:".length,
1738
+ "file://".length
1739
+ );
1740
+ const pref = `file:${slashes === "//" ? slashes : ""}`;
1741
+ const rest = bareSpec.substring(pref.length);
1742
+ const [a = "", b = "/", c = "/", d = "/"] = rest.split("", 4);
1743
+ if (!a) {
1744
+ return [".", "file:."];
1745
+ }
1746
+ if (a === "/" && b === "~" && c !== "/" || a === "~" && b !== "/") {
1747
+ throw error(
1748
+ `invalid file: specifier. '~username' not supported`,
1749
+ { spec }
1750
+ );
1751
+ }
1752
+ if (a === "~") {
1753
+ return (
1754
+ /* c8 ignore start */
1755
+ opts ? [
1756
+ opts.resolve(opts.homedir(), rest.substring(2)),
1757
+ `file:${rest}`
1758
+ ] : [rest, `file:${rest}`]
1759
+ );
1760
+ }
1761
+ if (a === "/" && b === "~") {
1762
+ return opts ? [
1763
+ opts.resolve(opts.homedir(), rest.substring(3)),
1764
+ `file:${rest.substring(1)}`
1765
+ ] : (
1766
+ /* c8 ignore stop */
1767
+ [rest.substring(1), `file:${rest.substring(1)}`]
1768
+ );
1769
+ }
1770
+ if (a === "/" && b === "." && (c === "/" || c === "." && d === "/")) {
1771
+ return [rest.substring(1), `file:${rest.substring(1)}`];
1772
+ }
1773
+ if (a === "." && (b === "/" || b === "." && c === "/")) {
1774
+ return [rest, `file:${rest}`];
1775
+ }
1776
+ if (slashes === "//") {
1777
+ try {
1778
+ const parsed = new URL(bareSpec);
1779
+ if (parsed.host) {
1780
+ if (parsed.host !== "localhost") {
1781
+ throw error(
1782
+ `invalid file:// specifier. host must be empty or 'localhost'`,
1783
+ {
1784
+ spec,
1785
+ found: parsed.host,
1786
+ validOptions: ["", "localhost"]
1787
+ }
1788
+ );
1789
+ }
1790
+ }
1791
+ return [
1792
+ parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, "$1"),
1793
+ `file://${parsed.pathname}`
1794
+ ];
1795
+ } catch (er) {
1796
+ throw error("invalid file:// specifier", {
1797
+ spec,
1798
+ cause: er
1799
+ });
1800
+ }
1801
+ }
1802
+ if (opts?.winPath.isAbsolute(rest)) {
1803
+ return [rest, `file://${rest}`];
1804
+ }
1805
+ return [`./${rest}`, `file:./${rest}`];
1806
+ };
1807
+
1808
+ // ../../src/spec/src/index.ts
1809
+ var Spec2 = class extends Spec {
1810
+ [kCustomInspect](_depth, options) {
1811
+ const str = inspect(
1812
+ Object.fromEntries(
1813
+ Object.entries(this).filter(([k, v]) => {
1814
+ return k !== "options" && v !== void 0;
1815
+ })
1816
+ ),
1817
+ options
1818
+ );
1819
+ return `@vltpkg/spec.Spec ${str}`;
1820
+ }
1821
+ };
1822
+ Spec2.nodejsDependencies = {
1823
+ homedir,
1824
+ isAbsolute,
1825
+ join,
1826
+ resolve: resolve2,
1827
+ winPath
1828
+ };
1829
+
1830
+ export {
1831
+ fastSplit,
1832
+ Version,
1833
+ Range,
1834
+ parse2 as parse,
1835
+ parseRange,
1836
+ satisfies,
1837
+ compare,
1838
+ gt,
1839
+ gte,
1840
+ lt,
1841
+ lte,
1842
+ neq,
1843
+ eq,
1844
+ major,
1845
+ minor,
1846
+ patch,
1847
+ defaultRegistry,
1848
+ defaultRegistries,
1849
+ defaultGitHosts,
1850
+ defaultGitHostArchives,
1851
+ defaultScopeRegistries,
1852
+ Spec,
1853
+ Spec2,
1854
+ isIntegrity,
1855
+ asManifest,
1856
+ asPackument,
1857
+ longDependencyTypes,
1858
+ shortDependencyTypes,
1859
+ dependencyTypes,
1860
+ kIndent,
1861
+ kNewline,
1862
+ parse as parse2,
1863
+ stringify,
1864
+ PackageJson
1865
+ };
1866
+ //# sourceMappingURL=chunk-OKDQY2GQ.js.map