@voidzero-dev/vite-plus-core 0.2.5 → 0.2.6

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 (79) hide show
  1. package/LICENSE +31 -7
  2. package/dist/rolldown/cli.d.mts +1 -1
  3. package/dist/rolldown/cli.mjs +6 -6
  4. package/dist/rolldown/config.d.mts +16 -17
  5. package/dist/rolldown/config.mjs +2 -2
  6. package/dist/rolldown/experimental-index.d.mts +164 -155
  7. package/dist/rolldown/experimental-index.mjs +23 -14
  8. package/dist/rolldown/experimental-runtime-types.d.ts +111 -41
  9. package/dist/rolldown/filter-index.d.mts +6 -5
  10. package/dist/rolldown/get-log-filter.d.mts +2 -2
  11. package/dist/rolldown/index.d.mts +3 -3
  12. package/dist/rolldown/index.mjs +4 -4
  13. package/dist/rolldown/parallel-plugin-worker.d.mts +1 -1
  14. package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
  15. package/dist/rolldown/parallel-plugin.d.mts +3 -4
  16. package/dist/rolldown/parse-ast-index.d.mts +19 -20
  17. package/dist/rolldown/parse-ast-index.mjs +1 -1
  18. package/dist/rolldown/plugins-index.d.mts +27 -28
  19. package/dist/rolldown/plugins-index.mjs +2 -2
  20. package/dist/rolldown/shared/{binding-D26QphWG.d.mts → binding-Dbbi0RbO.d.mts} +37 -25
  21. package/dist/rolldown/shared/{binding-TuFFIE_J.mjs → binding-Dby9rwGk.mjs} +26 -26
  22. package/dist/rolldown/shared/{bindingify-input-options-CwbcQL6W.mjs → bindingify-input-options-DVQ4K-zY.mjs} +5 -5
  23. package/dist/rolldown/shared/{constructors-BbWPse2X.d.mts → constructors-CSWbNgBZ.d.mts} +9 -10
  24. package/dist/rolldown/shared/{constructors-D_3i7dpX.mjs → constructors-CuGa75s-.mjs} +1 -1
  25. package/dist/rolldown/shared/define-config-B-IDOhDz.d.mts +4003 -0
  26. package/dist/rolldown/shared/{error-BHRSI0R7.mjs → error-DFGNOCle.mjs} +1 -1
  27. package/dist/rolldown/shared/get-log-filter-AjBknEEO.d.mts +34 -0
  28. package/dist/rolldown/shared/{load-config-Bd7MgqCK.mjs → load-config-R0z2olkB.mjs} +1 -1
  29. package/dist/rolldown/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
  30. package/dist/rolldown/shared/{normalize-string-or-regex-dnh67V_w.mjs → normalize-string-or-regex-SiXbePVH.mjs} +1 -1
  31. package/dist/rolldown/shared/{parse-B6_waszz.mjs → parse-D5dkElpf.mjs} +2 -2
  32. package/dist/rolldown/shared/{resolve-tsconfig-DxqIJB3x.mjs → resolve-tsconfig-2TXRF_zr.mjs} +2 -2
  33. package/dist/rolldown/shared/{rolldown-CACDGVWV.mjs → rolldown-BnV7isAX.mjs} +1 -1
  34. package/dist/rolldown/shared/{rolldown-build-BV22mk7t.mjs → rolldown-build-BGXNOfvH.mjs} +4 -4
  35. package/dist/rolldown/shared/transform-Cs2bUDRH.d.mts +148 -0
  36. package/dist/rolldown/shared/{watch-CS_JygCu.mjs → watch-DVucf-VG.mjs} +4 -4
  37. package/dist/rolldown/utils-index.d.mts +29 -30
  38. package/dist/rolldown/utils-index.mjs +6 -8
  39. package/dist/tsdown/{build-BlM3pDGJ-C8Uovnt4.js → build-oq13wECG-Bymq3jT5.js} +131 -1240
  40. package/dist/tsdown/debug-BntVTkRq-BGIoAiTa.js +159 -0
  41. package/dist/tsdown/{detect-BNXt7gkp-DKAC9Z7n.js → detect-DGhJGEqb-S-tkSzpt.js} +7 -1
  42. package/dist/tsdown/{dist-Pjag7IPt.js → dist-CxIM8o7n.js} +1936 -2529
  43. package/dist/tsdown/dist-DCMiHFrJ.js +1061 -0
  44. package/dist/tsdown/index-types.d.ts +729 -553
  45. package/dist/tsdown/index.js +4 -4
  46. package/dist/tsdown/internal-C7ewSPAZ.js +3 -0
  47. package/dist/tsdown/load-tsc-BKULZsrs-BFmeD6Bu.js +18 -0
  48. package/dist/tsdown/{main-BlTcyuFi.js → main-BdzlWPt6.js} +214 -9
  49. package/dist/tsdown/{resolver-DtsKFXi2-B8Z3WwZh.js → resolver-cwLsPb2o-oj1hqxK6.js} +4 -3
  50. package/dist/tsdown/run.js +4 -4
  51. package/dist/tsdown/{src-CK50m8R_.js → src-BV-UJr_R.js} +5 -5
  52. package/dist/tsdown/target-CNxIDvSz-eoHNdJNs.js +576 -0
  53. package/dist/tsdown/tsc-context-CA76SkkZ.js +23 -0
  54. package/dist/tsdown/{tsc-CilQvmj4.js → tsc-zcbB6ZVY.js} +49 -116
  55. package/dist/tsdown/tsdown-css.js +5 -5
  56. package/dist/tsdown/tsdown-exe.js +129 -877
  57. package/dist/vite/client/client.mjs +5 -5
  58. package/dist/vite/node/chunks/build.js +19 -19
  59. package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +25 -26
  60. package/dist/vite/node/chunks/node.js +73 -38
  61. package/dist/vite/node/chunks/postcss-import.js +10 -10
  62. package/dist/vite/node/index.d.ts +1282 -1283
  63. package/dist/vite/node/module-runner.d.ts +76 -77
  64. package/dist/vite/node/module-runner.js +6 -7
  65. package/package.json +16 -16
  66. package/dist/rolldown/shared/define-config-BhJ90aEv.d.mts +0 -3978
  67. package/dist/rolldown/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  68. package/dist/rolldown/shared/transform-BPrUvqEZ.d.mts +0 -149
  69. package/dist/tsdown/debug-B1wUEHkd-DhRzGJTf.js +0 -265
  70. package/dist/tsdown/fs-qxJxxoCE-B_amenYz.js +0 -46
  71. package/dist/tsdown/general-Cp4NiJNK-xAqmPhMP.js +0 -97
  72. package/dist/tsdown/internal-Bn6NGoha.js +0 -3
  73. package/dist/tsdown/npm_cjs_chunk_range.cjs +0 -475
  74. package/dist/tsdown/npm_cjs_chunk_semver.cjs +0 -357
  75. package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +0 -52
  76. package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +0 -19
  77. package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +0 -46
  78. package/dist/tsdown/target-CqeSqtms-CIvlAiuG.js +0 -35
  79. package/dist/tsdown/tsc-context-BusiAGCd.js +0 -27
@@ -1,849 +1,23 @@
1
- import { d as __commonJSMin, m as __toESM } from "./general-Cp4NiJNK-xAqmPhMP.js";
2
- import { r as createDebug, t as R } from "./main-BlTcyuFi.js";
3
- import { n as fsExists, r as fsRemove } from "./fs-qxJxxoCE-B_amenYz.js";
4
- import "./internal-Bn6NGoha.js";
5
- import process$1 from "node:process";
1
+ import { r as createDebug, t as R } from "./main-BdzlWPt6.js";
2
+ import { O as fsExists, c as isGreaterOrEqual, f as tryParse, k as fsRemove, l as normalize$1, n as NODE_SEA_MIN_VERSION_PARSED, t as NODE_SEA_MIN_VERSION } from "./target-CNxIDvSz-eoHNdJNs.js";
3
+ import "./internal-C7ewSPAZ.js";
4
+ import process from "node:process";
6
5
  import path from "node:path";
7
- import { chmod, mkdir, rename, writeFile } from "node:fs/promises";
6
+ import { pipeline } from "node:stream/promises";
7
+ import { Readable } from "node:stream";
8
+ import { createReadStream, createWriteStream } from "node:fs";
9
+ import { chmod, mkdir, rename } from "node:fs/promises";
8
10
  import os from "node:os";
9
- import { Buffer } from "node:buffer";
10
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
11
- var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12
- var LRUCache = class {
13
- constructor() {
14
- this.max = 1e3;
15
- this.map = /* @__PURE__ */ new Map();
16
- }
17
- get(key) {
18
- const value = this.map.get(key);
19
- if (value === void 0) return;
20
- else {
21
- this.map.delete(key);
22
- this.map.set(key, value);
23
- return value;
24
- }
25
- }
26
- delete(key) {
27
- return this.map.delete(key);
28
- }
29
- set(key, value) {
30
- if (!this.delete(key) && value !== void 0) {
31
- if (this.map.size >= this.max) {
32
- const firstKey = this.map.keys().next().value;
33
- this.delete(firstKey);
34
- }
35
- this.map.set(key, value);
36
- }
37
- return this;
38
- }
39
- };
40
- module.exports = LRUCache;
41
- }));
42
- //#endregion
43
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
44
- var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
45
- const looseOption = Object.freeze({ loose: true });
46
- const emptyOpts = Object.freeze({});
47
- const parseOptions = (options) => {
48
- if (!options) return emptyOpts;
49
- if (typeof options !== "object") return looseOption;
50
- return options;
51
- };
52
- module.exports = parseOptions;
53
- }));
54
- //#endregion
55
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
56
- var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
57
- const SEMVER_SPEC_VERSION = "2.0.0";
58
- const MAX_LENGTH = 256;
59
- const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
60
- module.exports = {
61
- MAX_LENGTH,
62
- MAX_SAFE_COMPONENT_LENGTH: 16,
63
- MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
64
- MAX_SAFE_INTEGER,
65
- RELEASE_TYPES: [
66
- "major",
67
- "premajor",
68
- "minor",
69
- "preminor",
70
- "patch",
71
- "prepatch",
72
- "prerelease"
73
- ],
74
- SEMVER_SPEC_VERSION,
75
- FLAG_INCLUDE_PRERELEASE: 1,
76
- FLAG_LOOSE: 2
77
- };
78
- }));
79
- //#endregion
80
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
81
- var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
82
- module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
83
- }));
84
- //#endregion
85
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
86
- var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87
- const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
88
- const debug = require_debug();
89
- exports = module.exports = {};
90
- const re = exports.re = [];
91
- const safeRe = exports.safeRe = [];
92
- const src = exports.src = [];
93
- const safeSrc = exports.safeSrc = [];
94
- const t = exports.t = {};
95
- let R = 0;
96
- const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
97
- const safeRegexReplacements = [
98
- ["\\s", 1],
99
- ["\\d", MAX_LENGTH],
100
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
101
- ];
102
- const makeSafeRegex = (value) => {
103
- for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
104
- return value;
105
- };
106
- const createToken = (name, value, isGlobal) => {
107
- const safe = makeSafeRegex(value);
108
- const index = R++;
109
- debug(name, index, value);
110
- t[name] = index;
111
- src[index] = value;
112
- safeSrc[index] = safe;
113
- re[index] = new RegExp(value, isGlobal ? "g" : void 0);
114
- safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
115
- };
116
- createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
117
- createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
118
- createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
119
- createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
120
- createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
121
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
122
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
123
- createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
124
- createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
125
- createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
126
- createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
127
- createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
128
- createToken("FULL", `^${src[t.FULLPLAIN]}$`);
129
- createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
130
- createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
131
- createToken("GTLT", "((?:<|>)?=?)");
132
- createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
133
- createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
134
- createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
135
- createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
136
- createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
137
- createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
138
- createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
139
- createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
140
- createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
141
- createToken("COERCERTL", src[t.COERCE], true);
142
- createToken("COERCERTLFULL", src[t.COERCEFULL], true);
143
- createToken("LONETILDE", "(?:~>?)");
144
- createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
145
- exports.tildeTrimReplace = "$1~";
146
- createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
147
- createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
148
- createToken("LONECARET", "(?:\\^)");
149
- createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
150
- exports.caretTrimReplace = "$1^";
151
- createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
152
- createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
153
- createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
154
- createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
155
- createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
156
- exports.comparatorTrimReplace = "$1$2$3";
157
- createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
158
- createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
159
- createToken("STAR", "(<|>)?=?\\s*\\*");
160
- createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
161
- createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
162
- }));
163
- //#endregion
164
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
165
- var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
166
- const numeric = /^[0-9]+$/;
167
- const compareIdentifiers = (a, b) => {
168
- if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
169
- const anum = numeric.test(a);
170
- const bnum = numeric.test(b);
171
- if (anum && bnum) {
172
- a = +a;
173
- b = +b;
174
- }
175
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
176
- };
177
- const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
178
- module.exports = {
179
- compareIdentifiers,
180
- rcompareIdentifiers
181
- };
182
- }));
183
- //#endregion
184
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
185
- var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
186
- const debug = require_debug();
187
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
188
- const { safeRe: re, t } = require_re();
189
- const parseOptions = require_parse_options();
190
- const { compareIdentifiers } = require_identifiers();
191
- const isPrereleaseIdentifier = (prerelease, identifier) => {
192
- const identifiers = identifier.split(".");
193
- if (identifiers.length > prerelease.length) return false;
194
- for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
195
- return true;
196
- };
197
- module.exports = class SemVer {
198
- constructor(version, options) {
199
- options = parseOptions(options);
200
- if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
201
- else version = version.version;
202
- else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
203
- if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
204
- debug("SemVer", version, options);
205
- this.options = options;
206
- this.loose = !!options.loose;
207
- this.includePrerelease = !!options.includePrerelease;
208
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
209
- if (!m) throw new TypeError(`Invalid Version: ${version}`);
210
- this.raw = version;
211
- this.major = +m[1];
212
- this.minor = +m[2];
213
- this.patch = +m[3];
214
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
215
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
216
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
217
- if (!m[4]) this.prerelease = [];
218
- else this.prerelease = m[4].split(".").map((id) => {
219
- if (/^[0-9]+$/.test(id)) {
220
- const num = +id;
221
- if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
222
- }
223
- return id;
224
- });
225
- this.build = m[5] ? m[5].split(".") : [];
226
- this.format();
227
- }
228
- format() {
229
- this.version = `${this.major}.${this.minor}.${this.patch}`;
230
- if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
231
- return this.version;
232
- }
233
- toString() {
234
- return this.version;
235
- }
236
- compare(other) {
237
- debug("SemVer.compare", this.version, this.options, other);
238
- if (!(other instanceof SemVer)) {
239
- if (typeof other === "string" && other === this.version) return 0;
240
- other = new SemVer(other, this.options);
241
- }
242
- if (other.version === this.version) return 0;
243
- return this.compareMain(other) || this.comparePre(other);
244
- }
245
- compareMain(other) {
246
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
247
- if (this.major < other.major) return -1;
248
- if (this.major > other.major) return 1;
249
- if (this.minor < other.minor) return -1;
250
- if (this.minor > other.minor) return 1;
251
- if (this.patch < other.patch) return -1;
252
- if (this.patch > other.patch) return 1;
253
- return 0;
254
- }
255
- comparePre(other) {
256
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
257
- if (this.prerelease.length && !other.prerelease.length) return -1;
258
- else if (!this.prerelease.length && other.prerelease.length) return 1;
259
- else if (!this.prerelease.length && !other.prerelease.length) return 0;
260
- let i = 0;
261
- do {
262
- const a = this.prerelease[i];
263
- const b = other.prerelease[i];
264
- debug("prerelease compare", i, a, b);
265
- if (a === void 0 && b === void 0) return 0;
266
- else if (b === void 0) return 1;
267
- else if (a === void 0) return -1;
268
- else if (a === b) continue;
269
- else return compareIdentifiers(a, b);
270
- } while (++i);
271
- }
272
- compareBuild(other) {
273
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
274
- let i = 0;
275
- do {
276
- const a = this.build[i];
277
- const b = other.build[i];
278
- debug("build compare", i, a, b);
279
- if (a === void 0 && b === void 0) return 0;
280
- else if (b === void 0) return 1;
281
- else if (a === void 0) return -1;
282
- else if (a === b) continue;
283
- else return compareIdentifiers(a, b);
284
- } while (++i);
285
- }
286
- inc(release, identifier, identifierBase) {
287
- if (release.startsWith("pre")) {
288
- if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
289
- if (identifier) {
290
- const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
291
- if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
292
- }
293
- }
294
- switch (release) {
295
- case "premajor":
296
- this.prerelease.length = 0;
297
- this.patch = 0;
298
- this.minor = 0;
299
- this.major++;
300
- this.inc("pre", identifier, identifierBase);
301
- break;
302
- case "preminor":
303
- this.prerelease.length = 0;
304
- this.patch = 0;
305
- this.minor++;
306
- this.inc("pre", identifier, identifierBase);
307
- break;
308
- case "prepatch":
309
- this.prerelease.length = 0;
310
- this.inc("patch", identifier, identifierBase);
311
- this.inc("pre", identifier, identifierBase);
312
- break;
313
- case "prerelease":
314
- if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
315
- this.inc("pre", identifier, identifierBase);
316
- break;
317
- case "release":
318
- if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
319
- this.prerelease.length = 0;
320
- break;
321
- case "major":
322
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
323
- this.minor = 0;
324
- this.patch = 0;
325
- this.prerelease = [];
326
- break;
327
- case "minor":
328
- if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
329
- this.patch = 0;
330
- this.prerelease = [];
331
- break;
332
- case "patch":
333
- if (this.prerelease.length === 0) this.patch++;
334
- this.prerelease = [];
335
- break;
336
- case "pre": {
337
- const base = Number(identifierBase) ? 1 : 0;
338
- if (this.prerelease.length === 0) this.prerelease = [base];
339
- else {
340
- let i = this.prerelease.length;
341
- while (--i >= 0) if (typeof this.prerelease[i] === "number") {
342
- this.prerelease[i]++;
343
- i = -2;
344
- }
345
- if (i === -1) {
346
- if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
347
- this.prerelease.push(base);
348
- }
349
- }
350
- if (identifier) {
351
- let prerelease = [identifier, base];
352
- if (identifierBase === false) prerelease = [identifier];
353
- if (isPrereleaseIdentifier(this.prerelease, identifier)) {
354
- const prereleaseBase = this.prerelease[identifier.split(".").length];
355
- if (isNaN(prereleaseBase)) this.prerelease = prerelease;
356
- } else this.prerelease = prerelease;
357
- }
358
- break;
359
- }
360
- default: throw new Error(`invalid increment argument: ${release}`);
361
- }
362
- this.raw = this.format();
363
- if (this.build.length) this.raw += `+${this.build.join(".")}`;
364
- return this;
365
- }
366
- };
367
- }));
368
- //#endregion
369
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
370
- var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
371
- const SemVer = require_semver();
372
- const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
373
- module.exports = compare;
374
- }));
375
- //#endregion
376
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
377
- var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
378
- const compare = require_compare();
379
- const eq = (a, b, loose) => compare(a, b, loose) === 0;
380
- module.exports = eq;
381
- }));
382
- //#endregion
383
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
384
- var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
385
- const compare = require_compare();
386
- const neq = (a, b, loose) => compare(a, b, loose) !== 0;
387
- module.exports = neq;
388
- }));
389
- //#endregion
390
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
391
- var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
392
- const compare = require_compare();
393
- const gt = (a, b, loose) => compare(a, b, loose) > 0;
394
- module.exports = gt;
395
- }));
396
- //#endregion
397
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
398
- var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
399
- const compare = require_compare();
400
- const gte = (a, b, loose) => compare(a, b, loose) >= 0;
401
- module.exports = gte;
402
- }));
403
- //#endregion
404
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
405
- var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
406
- const compare = require_compare();
407
- const lt = (a, b, loose) => compare(a, b, loose) < 0;
408
- module.exports = lt;
409
- }));
410
- //#endregion
411
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
412
- var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
413
- const compare = require_compare();
414
- const lte = (a, b, loose) => compare(a, b, loose) <= 0;
415
- module.exports = lte;
416
- }));
417
- //#endregion
418
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
419
- var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
420
- const eq = require_eq();
421
- const neq = require_neq();
422
- const gt = require_gt();
423
- const gte = require_gte();
424
- const lt = require_lt();
425
- const lte = require_lte();
426
- const cmp = (a, op, b, loose) => {
427
- switch (op) {
428
- case "===":
429
- if (typeof a === "object") a = a.version;
430
- if (typeof b === "object") b = b.version;
431
- return a === b;
432
- case "!==":
433
- if (typeof a === "object") a = a.version;
434
- if (typeof b === "object") b = b.version;
435
- return a !== b;
436
- case "":
437
- case "=":
438
- case "==": return eq(a, b, loose);
439
- case "!=": return neq(a, b, loose);
440
- case ">": return gt(a, b, loose);
441
- case ">=": return gte(a, b, loose);
442
- case "<": return lt(a, b, loose);
443
- case "<=": return lte(a, b, loose);
444
- default: throw new TypeError(`Invalid operator: ${op}`);
445
- }
446
- };
447
- module.exports = cmp;
448
- }));
449
- //#endregion
450
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
451
- var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
452
- const ANY = Symbol("SemVer ANY");
453
- module.exports = class Comparator {
454
- static get ANY() {
455
- return ANY;
456
- }
457
- constructor(comp, options) {
458
- options = parseOptions(options);
459
- if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
460
- else comp = comp.value;
461
- comp = comp.trim().split(/\s+/).join(" ");
462
- debug("comparator", comp, options);
463
- this.options = options;
464
- this.loose = !!options.loose;
465
- this.parse(comp);
466
- if (this.semver === ANY) this.value = "";
467
- else this.value = this.operator + this.semver.version;
468
- debug("comp", this);
469
- }
470
- parse(comp) {
471
- const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
472
- const m = comp.match(r);
473
- if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
474
- this.operator = m[1] !== void 0 ? m[1] : "";
475
- if (this.operator === "=") this.operator = "";
476
- if (!m[2]) this.semver = ANY;
477
- else this.semver = new SemVer(m[2], this.options.loose);
478
- }
479
- toString() {
480
- return this.value;
481
- }
482
- test(version) {
483
- debug("Comparator.test", version, this.options.loose);
484
- if (this.semver === ANY || version === ANY) return true;
485
- if (typeof version === "string") try {
486
- version = new SemVer(version, this.options);
487
- } catch (er) {
488
- return false;
489
- }
490
- return cmp(version, this.operator, this.semver, this.options);
491
- }
492
- intersects(comp, options) {
493
- if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
494
- if (this.operator === "") {
495
- if (this.value === "") return true;
496
- return new Range(comp.value, options).test(this.value);
497
- } else if (comp.operator === "") {
498
- if (comp.value === "") return true;
499
- return new Range(this.value, options).test(comp.semver);
500
- }
501
- options = parseOptions(options);
502
- if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
503
- if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
504
- if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
505
- if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
506
- if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
507
- if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
508
- if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
509
- return false;
510
- }
511
- };
512
- const parseOptions = require_parse_options();
513
- const { safeRe: re, t } = require_re();
514
- const cmp = require_cmp();
515
- const debug = require_debug();
516
- const SemVer = require_semver();
517
- const Range = require_range();
518
- }));
519
- //#endregion
520
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
521
- var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
522
- const SPACE_CHARACTERS = /\s+/g;
523
- module.exports = class Range {
524
- constructor(range, options) {
525
- options = parseOptions(options);
526
- if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
527
- else return new Range(range.raw, options);
528
- if (range instanceof Comparator) {
529
- this.raw = range.value;
530
- this.set = [[range]];
531
- this.formatted = void 0;
532
- return this;
533
- }
534
- this.options = options;
535
- this.loose = !!options.loose;
536
- this.includePrerelease = !!options.includePrerelease;
537
- this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
538
- this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
539
- if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
540
- if (this.set.length > 1) {
541
- const first = this.set[0];
542
- this.set = this.set.filter((c) => !isNullSet(c[0]));
543
- if (this.set.length === 0) this.set = [first];
544
- else if (this.set.length > 1) {
545
- for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
546
- this.set = [c];
547
- break;
548
- }
549
- }
550
- }
551
- this.formatted = void 0;
552
- }
553
- get range() {
554
- if (this.formatted === void 0) {
555
- this.formatted = "";
556
- for (let i = 0; i < this.set.length; i++) {
557
- if (i > 0) this.formatted += "||";
558
- const comps = this.set[i];
559
- for (let k = 0; k < comps.length; k++) {
560
- if (k > 0) this.formatted += " ";
561
- this.formatted += comps[k].toString().trim();
562
- }
563
- }
564
- }
565
- return this.formatted;
566
- }
567
- format() {
568
- return this.range;
569
- }
570
- toString() {
571
- return this.range;
572
- }
573
- parseRange(range) {
574
- range = range.replace(BUILDSTRIPRE, "");
575
- const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
576
- const cached = cache.get(memoKey);
577
- if (cached) return cached;
578
- const loose = this.options.loose;
579
- const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
580
- range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
581
- debug("hyphen replace", range);
582
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
583
- debug("comparator trim", range);
584
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
585
- debug("tilde trim", range);
586
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
587
- debug("caret trim", range);
588
- let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
589
- if (loose) rangeList = rangeList.filter((comp) => {
590
- debug("loose invalid filter", comp, this.options);
591
- return !!comp.match(re[t.COMPARATORLOOSE]);
592
- });
593
- debug("range list", rangeList);
594
- const rangeMap = /* @__PURE__ */ new Map();
595
- const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
596
- for (const comp of comparators) {
597
- if (isNullSet(comp)) return [comp];
598
- rangeMap.set(comp.value, comp);
599
- }
600
- if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
601
- const result = [...rangeMap.values()];
602
- cache.set(memoKey, result);
603
- return result;
604
- }
605
- intersects(range, options) {
606
- if (!(range instanceof Range)) throw new TypeError("a Range is required");
607
- return this.set.some((thisComparators) => {
608
- return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
609
- return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
610
- return rangeComparators.every((rangeComparator) => {
611
- return thisComparator.intersects(rangeComparator, options);
612
- });
613
- });
614
- });
615
- });
616
- }
617
- test(version) {
618
- if (!version) return false;
619
- if (typeof version === "string") try {
620
- version = new SemVer(version, this.options);
621
- } catch (er) {
622
- return false;
623
- }
624
- for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
625
- return false;
626
- }
627
- };
628
- const cache = new (require_lrucache())();
629
- const parseOptions = require_parse_options();
630
- const Comparator = require_comparator();
631
- const debug = require_debug();
632
- const SemVer = require_semver();
633
- const { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
634
- const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
635
- const BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
636
- const isNullSet = (c) => c.value === "<0.0.0-0";
637
- const isAny = (c) => c.value === "";
638
- const isSatisfiable = (comparators, options) => {
639
- let result = true;
640
- const remainingComparators = comparators.slice();
641
- let testComparator = remainingComparators.pop();
642
- while (result && remainingComparators.length) {
643
- result = remainingComparators.every((otherComparator) => {
644
- return testComparator.intersects(otherComparator, options);
645
- });
646
- testComparator = remainingComparators.pop();
647
- }
648
- return result;
649
- };
650
- const parseComparator = (comp, options) => {
651
- comp = comp.replace(re[t.BUILD], "");
652
- debug("comp", comp, options);
653
- comp = replaceCarets(comp, options);
654
- debug("caret", comp);
655
- comp = replaceTildes(comp, options);
656
- debug("tildes", comp);
657
- comp = replaceXRanges(comp, options);
658
- debug("xrange", comp);
659
- comp = replaceStars(comp, options);
660
- debug("stars", comp);
661
- return comp;
662
- };
663
- const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
664
- const invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
665
- const replaceTildes = (comp, options) => {
666
- return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
667
- };
668
- const replaceTilde = (comp, options) => {
669
- const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
670
- const z = options.includePrerelease ? "-0" : "";
671
- return comp.replace(r, (_, M, m, p, pr) => {
672
- debug("tilde", comp, _, M, m, p, pr);
673
- let ret;
674
- if (isX(M)) ret = "";
675
- else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
676
- else if (isX(p)) ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
677
- else if (pr) {
678
- debug("replaceTilde pr", pr);
679
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
680
- } else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
681
- debug("tilde return", ret);
682
- return ret;
683
- });
684
- };
685
- const replaceCarets = (comp, options) => {
686
- return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
687
- };
688
- const replaceCaret = (comp, options) => {
689
- debug("caret", comp, options);
690
- const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
691
- const z = options.includePrerelease ? "-0" : "";
692
- return comp.replace(r, (_, M, m, p, pr) => {
693
- debug("caret", comp, _, M, m, p, pr);
694
- let ret;
695
- if (isX(M)) ret = "";
696
- else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
697
- else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
698
- else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
699
- else if (pr) {
700
- debug("replaceCaret pr", pr);
701
- if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
702
- else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
703
- else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
704
- } else {
705
- debug("no pr");
706
- if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
707
- else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
708
- else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
709
- }
710
- debug("caret return", ret);
711
- return ret;
712
- });
713
- };
714
- const replaceXRanges = (comp, options) => {
715
- debug("replaceXRanges", comp, options);
716
- return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
717
- };
718
- const replaceXRange = (comp, options) => {
719
- comp = comp.trim();
720
- const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
721
- return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
722
- debug("xRange", comp, ret, gtlt, M, m, p, pr);
723
- if (invalidXRangeOrder(M, m, p)) return comp;
724
- const xM = isX(M);
725
- const xm = xM || isX(m);
726
- const xp = xm || isX(p);
727
- const anyX = xp;
728
- if (gtlt === "=" && anyX) gtlt = "";
729
- pr = options.includePrerelease ? "-0" : "";
730
- if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
731
- else ret = "*";
732
- else if (gtlt && anyX) {
733
- if (xm) m = 0;
734
- p = 0;
735
- if (gtlt === ">") {
736
- gtlt = ">=";
737
- if (xm) {
738
- M = +M + 1;
739
- m = 0;
740
- p = 0;
741
- } else {
742
- m = +m + 1;
743
- p = 0;
744
- }
745
- } else if (gtlt === "<=") {
746
- gtlt = "<";
747
- if (xm) M = +M + 1;
748
- else m = +m + 1;
749
- }
750
- if (gtlt === "<") pr = "-0";
751
- ret = `${gtlt + M}.${m}.${p}${pr}`;
752
- } else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
753
- else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
754
- debug("xRange return", ret);
755
- return ret;
756
- });
757
- };
758
- const replaceStars = (comp, options) => {
759
- debug("replaceStars", comp, options);
760
- return comp.trim().replace(re[t.STAR], "");
761
- };
762
- const replaceGTE0 = (comp, options) => {
763
- debug("replaceGTE0", comp, options);
764
- return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
765
- };
766
- const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
767
- if (isX(fM)) from = "";
768
- else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
769
- else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
770
- else if (fpr) from = `>=${from}`;
771
- else from = `>=${from}${incPr ? "-0" : ""}`;
772
- if (isX(tM)) to = "";
773
- else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
774
- else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
775
- else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
776
- else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
777
- else to = `<=${to}`;
778
- return `${from} ${to}`.trim();
779
- };
780
- const testSet = (set, version, options) => {
781
- for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
782
- if (version.prerelease.length && !options.includePrerelease) {
783
- for (let i = 0; i < set.length; i++) {
784
- debug(set[i].semver);
785
- if (set[i].semver === Comparator.ANY) continue;
786
- if (set[i].semver.prerelease.length > 0) {
787
- const allowed = set[i].semver;
788
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
789
- }
790
- }
791
- return false;
792
- }
793
- return true;
794
- };
795
- }));
796
- //#endregion
797
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
798
- var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
799
- const Range = require_range();
800
- const satisfies = (version, range, options) => {
801
- try {
802
- range = new Range(range, options);
803
- } catch (er) {
804
- return false;
805
- }
806
- return range.test(version);
807
- };
808
- module.exports = satisfies;
809
- }));
810
- //#endregion
811
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
812
- var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
813
- const SemVer = require_semver();
814
- const parse = (version, options, throwErrors = false) => {
815
- if (version instanceof SemVer) return version;
816
- try {
817
- return new SemVer(version, options);
818
- } catch (er) {
819
- if (!throwErrors) return null;
820
- throw er;
821
- }
822
- };
823
- module.exports = parse;
824
- }));
825
- //#endregion
826
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
827
- var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
828
- const parse = require_parse();
829
- const valid = (version, options) => {
830
- const v = parse(version, options);
831
- return v ? v.version : null;
832
- };
833
- module.exports = valid;
834
- }));
835
- //#endregion
836
- //#region ../../node_modules/.pnpm/@tsdown+exe@0.22.7_tsdown@0.22.7/node_modules/@tsdown/exe/dist/index.mjs
837
- var import_satisfies = /* @__PURE__ */ __toESM(require_satisfies(), 1);
838
- var import_valid = /* @__PURE__ */ __toESM(require_valid(), 1);
11
+ import { createHash } from "node:crypto";
12
+ //#region ../../node_modules/.pnpm/@tsdown+exe@0.22.13_tsdown@0.22.13/node_modules/@tsdown/exe/dist/index.mjs
839
13
  function getCacheDir() {
840
14
  const home = os.homedir();
841
- if (process$1.platform === "win32") {
842
- const localAppData = process$1.env.LOCALAPPDATA || path.join(home, "AppData/Local");
15
+ if (process.platform === "win32") {
16
+ const localAppData = process.env.LOCALAPPDATA || path.join(home, "AppData/Local");
843
17
  return path.join(localAppData, "tsdown/Caches");
844
18
  }
845
- if (process$1.platform === "darwin") return path.join(home, "Library/Caches/tsdown");
846
- const xdgCache = process$1.env.XDG_CACHE_HOME || path.join(home, ".cache");
19
+ if (process.platform === "darwin") return path.join(home, "Library/Caches/tsdown");
20
+ const xdgCache = process.env.XDG_CACHE_HOME || path.join(home, ".cache");
847
21
  return path.join(xdgCache, "tsdown");
848
22
  }
849
23
  function getCachedBinaryPath(target) {
@@ -866,28 +40,28 @@ function getBinaryPathInArchive(target) {
866
40
  if (platform === "win") return `${dirName}/node.exe`;
867
41
  return `${dirName}/bin/node`;
868
42
  }
869
- const NODE_DIST_INDEX_URL = "https://nodejs.org/dist/index.json";
870
- async function resolveNodeVersion(nodeVersion) {
43
+ async function resolveNodeVersion(nodeVersion, nodeDistIndexUrl = "https://nodejs.org/dist/index.json") {
871
44
  if (nodeVersion === "latest" || nodeVersion === "latest-lts") {
872
- const response = await fetch(NODE_DIST_INDEX_URL);
873
- if (!response.ok) throw new Error(`Failed to fetch Node.js releases: HTTP ${response.status} from ${NODE_DIST_INDEX_URL}`);
45
+ const response = await fetch(nodeDistIndexUrl);
46
+ if (!response.ok) throw new Error(`Failed to fetch Node.js releases: HTTP ${response.status} from ${nodeDistIndexUrl}`);
874
47
  const releases = await response.json();
875
48
  const release = nodeVersion === "latest" ? releases[0] : releases.find((r) => r.lts !== false);
876
49
  if (!release) throw new Error(`No matching Node.js release found for "${nodeVersion}".`);
877
50
  nodeVersion = release.version.replace(/^v/, "");
878
51
  }
879
- const version = (0, import_valid.default)(nodeVersion);
52
+ const version = tryParse(nodeVersion);
880
53
  if (!version) throw new Error(`Invalid Node.js version: ${nodeVersion}. Please provide a valid version string (e.g., "25.7.0").`);
881
- if (!(0, import_satisfies.default)(version, ">=25.7.0")) throw new Error(`Node.js ${version} does not support SEA (Single Executable Applications). Required minimum version is 25.7.0. Please update the nodeVersion in your target configuration.`);
882
- return version;
54
+ if (!isGreaterOrEqual(version, NODE_SEA_MIN_VERSION_PARSED)) throw new Error(`Node.js ${version} does not support SEA (Single Executable Applications). Required minimum version is ${NODE_SEA_MIN_VERSION}. Please update the nodeVersion in your target configuration.`);
55
+ return normalize$1(version);
883
56
  }
884
57
  function getTargetSuffix(target) {
885
58
  return `-${target.platform}-${target.arch}`;
886
59
  }
887
60
  const debug = createDebug("tsdown:exe:download");
888
- async function resolveNodeBinary(target, logger) {
61
+ const shasumsManifestCache = /* @__PURE__ */ new Map();
62
+ async function resolveNodeBinary(target, options, logger) {
889
63
  debug("Resolving Node.js binary for target: %O", target);
890
- target.nodeVersion = await resolveNodeVersion(target.nodeVersion);
64
+ target.nodeVersion = await resolveNodeVersion(target.nodeVersion, options.nodeDistIndexUrl);
891
65
  const cachedPath = getCachedBinaryPath(target);
892
66
  debug("Cache path: %s", cachedPath);
893
67
  if (await fsExists(cachedPath)) {
@@ -895,17 +69,13 @@ async function resolveNodeBinary(target, logger) {
895
69
  logger?.info(`Using cached Node.js ${target.nodeVersion} for ${target.platform}-${target.arch}`);
896
70
  return cachedPath;
897
71
  }
898
- const url = getDownloadUrl(target);
72
+ const url = await (options.getDownloadUrl ?? getDownloadUrl)(target);
899
73
  debug("Cache miss, downloading from: %s", url);
900
74
  logger?.info(`Downloading Node.js ${target.nodeVersion} for ${target.platform}-${target.arch}...`);
901
75
  logger?.info(` ${url}`);
902
76
  await mkdir(path.dirname(cachedPath), { recursive: true });
903
- const response = await fetch(url);
904
- if (!response.ok) throw new Error(`Failed to download Node.js binary: HTTP ${response.status} from ${url}`);
905
77
  const archivePath = `${cachedPath}.download.${getArchiveExtension(target.platform)}`;
906
- const buffer = Buffer.from(await response.arrayBuffer());
907
- debug("Downloaded %d bytes, writing to: %s", buffer.length, archivePath);
908
- await writeFile(archivePath, buffer);
78
+ await downloadArchive(url, archivePath, target.nodeVersion);
909
79
  try {
910
80
  await extractBinary(archivePath, cachedPath, target);
911
81
  if (target.platform !== "win") await chmod(cachedPath, 493);
@@ -916,35 +86,117 @@ async function resolveNodeBinary(target, logger) {
916
86
  }
917
87
  return cachedPath;
918
88
  }
89
+ async function downloadArchive(url, archivePath, nodeVersion) {
90
+ const expectedChecksum = await getExpectedArchiveChecksum(nodeVersion, path.posix.basename(new URL(url).pathname));
91
+ const response = await fetch(url);
92
+ if (!response.ok) throw new Error(`Failed to download Node.js binary: HTTP ${response.status} from ${url}`);
93
+ if (!response.body) throw new Error(`Failed to download Node.js binary: empty response from ${url}`);
94
+ const tempArchivePath = `${archivePath}.tmp-${process.pid}-${Date.now()}`;
95
+ try {
96
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(tempArchivePath));
97
+ await verifyArchiveChecksum(tempArchivePath, expectedChecksum);
98
+ await rename(tempArchivePath, archivePath);
99
+ } catch (error) {
100
+ await fsRemove(tempArchivePath);
101
+ throw error;
102
+ }
103
+ }
104
+ async function getExpectedArchiveChecksum(nodeVersion, archiveName) {
105
+ const checksum = (await getShasumsManifest(nodeVersion)).get(archiveName);
106
+ if (!checksum) throw new Error(`Failed to find checksum for Node.js archive "${archiveName}" in SHASUMS256.txt.`);
107
+ return checksum;
108
+ }
109
+ async function getShasumsManifest(nodeVersion) {
110
+ const cachedManifest = shasumsManifestCache.get(nodeVersion);
111
+ if (cachedManifest) return cachedManifest;
112
+ const manifest = (async () => {
113
+ const url = `https://nodejs.org/dist/v${nodeVersion}/SHASUMS256.txt`;
114
+ const response = await fetch(url);
115
+ if (!response.ok) throw new Error(`Failed to download Node.js checksums: HTTP ${response.status} from ${url}`);
116
+ const checksums = /* @__PURE__ */ new Map();
117
+ const text = await response.text();
118
+ for (const line of text.split(/\r?\n/)) {
119
+ const trimmedLine = line.trim();
120
+ if (!trimmedLine) continue;
121
+ const separatorIndex = trimmedLine.search(/\s/);
122
+ if (separatorIndex === -1) continue;
123
+ const checksum = trimmedLine.slice(0, separatorIndex);
124
+ if (!/^[a-f0-9]{64}$/i.test(checksum)) continue;
125
+ const archiveName = trimmedLine.slice(separatorIndex).trimStart().replace(/^\*/, "");
126
+ if (!archiveName) continue;
127
+ checksums.set(archiveName, checksum.toLowerCase());
128
+ }
129
+ return checksums;
130
+ })();
131
+ shasumsManifestCache.set(nodeVersion, manifest);
132
+ try {
133
+ return await manifest;
134
+ } catch (error) {
135
+ shasumsManifestCache.delete(nodeVersion);
136
+ throw error;
137
+ }
138
+ }
139
+ async function verifyArchiveChecksum(archivePath, expectedChecksum) {
140
+ const hash = createHash("sha256");
141
+ const stream = createReadStream(archivePath);
142
+ for await (const chunk of stream) hash.update(chunk);
143
+ const actualChecksum = hash.digest("hex");
144
+ if (actualChecksum !== expectedChecksum) throw new Error(`Checksum mismatch for Node.js archive "${archivePath}": expected ${expectedChecksum}, received ${actualChecksum}.`);
145
+ }
919
146
  async function extractBinary(archivePath, targetBinaryPath, target) {
920
147
  const binaryInArchive = getBinaryPathInArchive(target);
921
148
  const outDir = path.dirname(targetBinaryPath);
922
149
  debug("Extracting %s from archive to %s", binaryInArchive, outDir);
923
- if (target.platform === "win") await R("tar", [
924
- "-xf",
925
- archivePath,
926
- "-C",
927
- outDir,
928
- "--strip-components=1",
929
- binaryInArchive
930
- ], {
931
- nodeOptions: { stdio: "inherit" },
932
- throwOnError: true
933
- });
934
- else await R("tar", [
935
- `-x${archivePath.endsWith(".tar.xz") ? "J" : "z"}f`,
936
- archivePath,
937
- "-C",
938
- outDir,
939
- "--strip-components=2",
940
- binaryInArchive
941
- ], {
942
- nodeOptions: { stdio: "inherit" },
943
- throwOnError: true
944
- });
150
+ const { command, args } = getExtractCommand(archivePath, outDir, binaryInArchive, target);
151
+ try {
152
+ await R(command, args, {
153
+ nodeOptions: { stdio: "inherit" },
154
+ throwOnError: true,
155
+ nodePath: false
156
+ });
157
+ } catch (error) {
158
+ throw new Error(`Failed to extract Node.js archive with \`${command}\`. Please ensure \`${command}\` is installed and available in PATH.`, { cause: error });
159
+ }
945
160
  const extractedName = target.platform === "win" ? "node.exe" : "node";
946
161
  const extractedPath = path.join(outDir, extractedName);
947
162
  if (extractedPath !== targetBinaryPath) await rename(extractedPath, targetBinaryPath);
948
163
  }
164
+ function getExtractCommand(archivePath, outDir, binaryInArchive, target, hostPlatform = process.platform) {
165
+ if (target.platform === "win") {
166
+ if (hostPlatform === "win32") return {
167
+ command: "tar",
168
+ args: [
169
+ "-xf",
170
+ archivePath,
171
+ "-C",
172
+ outDir,
173
+ "--strip-components=1",
174
+ binaryInArchive
175
+ ]
176
+ };
177
+ return {
178
+ command: "unzip",
179
+ args: [
180
+ "-j",
181
+ "-o",
182
+ archivePath,
183
+ binaryInArchive,
184
+ "-d",
185
+ outDir
186
+ ]
187
+ };
188
+ }
189
+ return {
190
+ command: "tar",
191
+ args: [
192
+ `-x${archivePath.endsWith(".tar.xz") ? "J" : "z"}f`,
193
+ archivePath,
194
+ "-C",
195
+ outDir,
196
+ "--strip-components=2",
197
+ binaryInArchive
198
+ ]
199
+ };
200
+ }
949
201
  //#endregion
950
202
  export { getCacheDir, getCachedBinaryPath, getTargetSuffix, resolveNodeBinary };