@socketsecurity/lib 5.11.3 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fs.js CHANGED
@@ -63,7 +63,6 @@ module.exports = __toCommonJS(fs_exports);
63
63
  var import_node_process = __toESM(require("node:process"));
64
64
  var import_process = require("./constants/process");
65
65
  var import_arrays = require("./arrays");
66
- var import_del = require("./external/del");
67
66
  var import_promises = require("./promises");
68
67
  var import_globs = require("./globs");
69
68
  var import_parse = require("./json/parse");
@@ -72,6 +71,14 @@ var import_normalize = require("./paths/normalize");
72
71
  var import_rewire = require("./paths/rewire");
73
72
  var import_socket = require("./paths/socket");
74
73
  var import_sorts = require("./sorts");
74
+ let _del;
75
+ // @__NO_SIDE_EFFECTS__
76
+ function getDel() {
77
+ if (_del === void 0) {
78
+ _del = require("./external/del");
79
+ }
80
+ return _del;
81
+ }
75
82
  const abortSignal = (0, import_process.getAbortSignal)();
76
83
  const defaultRemoveOptions = (0, import_objects.objectFreeze)({
77
84
  __proto__: null,
@@ -541,9 +548,10 @@ async function safeDelete(filepath, options) {
541
548
  }
542
549
  const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
543
550
  const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
551
+ const del = /* @__PURE__ */ getDel();
544
552
  await (0, import_promises.pRetry)(
545
553
  async () => {
546
- await (0, import_del.deleteAsync)(patterns, {
554
+ await del.deleteAsync(patterns, {
547
555
  dryRun: false,
548
556
  force: shouldForce,
549
557
  onlyFiles: false
@@ -582,11 +590,12 @@ function safeDeleteSync(filepath, options) {
582
590
  }
583
591
  const maxRetries = opts.maxRetries ?? defaultRemoveOptions.maxRetries;
584
592
  const retryDelay = opts.retryDelay ?? defaultRemoveOptions.retryDelay;
593
+ const del = /* @__PURE__ */ getDel();
585
594
  let lastError;
586
595
  let delay = retryDelay;
587
596
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
588
597
  try {
589
- (0, import_del.deleteSync)(patterns, {
598
+ del.deleteSync(patterns, {
590
599
  dryRun: false,
591
600
  force: shouldForce,
592
601
  onlyFiles: false
package/dist/globs.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var globs_exports = {};
31
21
  __export(globs_exports, {
@@ -36,10 +26,24 @@ __export(globs_exports, {
36
26
  globSync: () => globSync
37
27
  });
38
28
  module.exports = __toCommonJS(globs_exports);
39
- var fastGlob = __toESM(require("./external/fast-glob.js"));
40
- var import_picomatch = __toESM(require("./external/picomatch.js"));
41
29
  var import_objects = require("./objects");
42
30
  var import_globs = require("./paths/globs");
31
+ let _fastGlob;
32
+ // @__NO_SIDE_EFFECTS__
33
+ function getFastGlob() {
34
+ if (_fastGlob === void 0) {
35
+ _fastGlob = require("./external/fast-glob.js");
36
+ }
37
+ return _fastGlob;
38
+ }
39
+ let _picomatch;
40
+ // @__NO_SIDE_EFFECTS__
41
+ function getPicomatch() {
42
+ if (_picomatch === void 0) {
43
+ _picomatch = require("./external/picomatch.js");
44
+ }
45
+ return _picomatch;
46
+ }
43
47
  const defaultIgnore = (0, import_objects.objectFreeze)([
44
48
  // Most of these ignored files can be included specifically if included in the
45
49
  // files globs. Exceptions to this are:
@@ -95,6 +99,7 @@ function globStreamLicenses(dirname, options) {
95
99
  if (ignoreOriginals) {
96
100
  ignore.push(import_globs.LICENSE_ORIGINAL_GLOB_RECURSIVE);
97
101
  }
102
+ const fastGlob = /* @__PURE__ */ getFastGlob();
98
103
  return fastGlob.globStream(
99
104
  [recursive ? import_globs.LICENSE_GLOB_RECURSIVE : import_globs.LICENSE_GLOB],
100
105
  {
@@ -142,7 +147,8 @@ function getGlobMatcher(glob2, options) {
142
147
  ...options,
143
148
  ...negativePatterns.length > 0 ? { ignore: negativePatterns } : {}
144
149
  };
145
- matcher = (0, import_picomatch.default)(
150
+ const picomatch = /* @__PURE__ */ getPicomatch();
151
+ matcher = picomatch(
146
152
  positivePatterns.length > 0 ? positivePatterns : patterns,
147
153
  matchOptions
148
154
  );
@@ -152,10 +158,12 @@ function getGlobMatcher(glob2, options) {
152
158
  }
153
159
  // @__NO_SIDE_EFFECTS__
154
160
  function glob(patterns, options) {
161
+ const fastGlob = /* @__PURE__ */ getFastGlob();
155
162
  return fastGlob.glob(patterns, options);
156
163
  }
157
164
  // @__NO_SIDE_EFFECTS__
158
165
  function globSync(patterns, options) {
166
+ const fastGlob = /* @__PURE__ */ getFastGlob();
159
167
  return fastGlob.globSync(patterns, options);
160
168
  }
161
169
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,34 @@
1
+ import type { IncomingHttpHeaders, IncomingMessage } from 'http';
1
2
  import type { Logger } from './logger.js';
3
+ /**
4
+ * Information passed to the onRequest hook before each request attempt.
5
+ */
6
+ export interface HttpHookRequestInfo {
7
+ headers: Record<string, string>;
8
+ method: string;
9
+ timeout: number;
10
+ url: string;
11
+ }
12
+ /**
13
+ * Information passed to the onResponse hook after each request attempt.
14
+ */
15
+ export interface HttpHookResponseInfo {
16
+ duration: number;
17
+ error?: Error | undefined;
18
+ headers?: IncomingHttpHeaders | undefined;
19
+ method: string;
20
+ status?: number | undefined;
21
+ statusText?: string | undefined;
22
+ url: string;
23
+ }
24
+ /**
25
+ * Lifecycle hooks for observing HTTP request/response events.
26
+ * Hooks fire per-attempt (retries produce multiple hook calls).
27
+ */
28
+ export interface HttpHooks {
29
+ onRequest?: ((info: HttpHookRequestInfo) => void) | undefined;
30
+ onResponse?: ((info: HttpHookResponseInfo) => void) | undefined;
31
+ }
2
32
  /**
3
33
  * Configuration options for HTTP/HTTPS requests.
4
34
  */
@@ -61,6 +91,11 @@ export interface HttpRequestOptions {
61
91
  * ```
62
92
  */
63
93
  followRedirects?: boolean | undefined;
94
+ /**
95
+ * Lifecycle hooks for observing request/response events.
96
+ * Hooks fire per-attempt — retries and redirects each trigger separate hook calls.
97
+ */
98
+ hooks?: HttpHooks | undefined;
64
99
  /**
65
100
  * HTTP headers to send with the request.
66
101
  * A `User-Agent` header is automatically added if not provided.
@@ -92,6 +127,14 @@ export interface HttpRequestOptions {
92
127
  * ```
93
128
  */
94
129
  maxRedirects?: number | undefined;
130
+ /**
131
+ * Maximum response body size in bytes. Responses exceeding this limit
132
+ * will be rejected with an error. Prevents memory exhaustion from
133
+ * unexpectedly large responses.
134
+ *
135
+ * @default undefined (no limit)
136
+ */
137
+ maxResponseSize?: number | undefined;
95
138
  /**
96
139
  * HTTP method to use for the request.
97
140
  *
@@ -205,7 +248,7 @@ export interface HttpResponse {
205
248
  * console.log(response.headers['set-cookie']) // May be string[]
206
249
  * ```
207
250
  */
208
- headers: Record<string, string | string[] | undefined>;
251
+ headers: IncomingHttpHeaders;
209
252
  /**
210
253
  * Parse response body as JSON.
211
254
  * Type parameter `T` allows specifying the expected JSON structure.
@@ -270,6 +313,12 @@ export interface HttpResponse {
270
313
  * ```
271
314
  */
272
315
  text(): string;
316
+ /**
317
+ * The underlying Node.js IncomingMessage for advanced use cases
318
+ * (e.g., streaming, custom header inspection). Only available when
319
+ * the response was not consumed by the convenience methods.
320
+ */
321
+ rawResponse?: IncomingMessage | undefined;
273
322
  }
274
323
  /**
275
324
  * Configuration options for file downloads.
@@ -567,6 +616,11 @@ export interface FetchChecksumsOptions {
567
616
  * ```
568
617
  */
569
618
  export declare function fetchChecksums(url: string, options?: FetchChecksumsOptions | undefined): Promise<Checksums>;
619
+ /**
620
+ * Build an enriched error message based on the error code.
621
+ * Generic guidance (no product-specific branding).
622
+ */
623
+ export declare function enrichErrorMessage(url: string, method: string, error: NodeJS.ErrnoException): string;
570
624
  /**
571
625
  * Download a file from a URL to a local path with redirect support, retry logic, and progress callbacks.
572
626
  * Uses streaming to avoid loading entire file in memory.
@@ -19,6 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var http_request_exports = {};
21
21
  __export(http_request_exports, {
22
+ enrichErrorMessage: () => enrichErrorMessage,
22
23
  fetchChecksums: () => fetchChecksums,
23
24
  httpDownload: () => httpDownload,
24
25
  httpJson: () => httpJson,
@@ -147,6 +148,15 @@ async function httpDownloadAttempt(url, destPath, options) {
147
148
  return;
148
149
  }
149
150
  const redirectUrl = res.headers.location.startsWith("http") ? res.headers.location : new URL(res.headers.location, url).toString();
151
+ const redirectParsed = new URL(redirectUrl);
152
+ if (isHttps && redirectParsed.protocol !== "https:") {
153
+ reject(
154
+ new Error(
155
+ `Redirect from HTTPS to HTTP is not allowed: ${redirectUrl}`
156
+ )
157
+ );
158
+ return;
159
+ }
150
160
  resolve(
151
161
  httpDownloadAttempt(redirectUrl, destPath, {
152
162
  ca,
@@ -229,25 +239,51 @@ async function httpDownloadAttempt(url, destPath, options) {
229
239
  request.end();
230
240
  });
231
241
  }
242
+ function enrichErrorMessage(url, method, error) {
243
+ const code = error.code;
244
+ let message = `${method} request failed: ${url}`;
245
+ if (code === "ECONNREFUSED") {
246
+ message += "\n\u2192 Connection refused. Server is unreachable.\n\u2192 Check: Network connectivity and firewall settings.";
247
+ } else if (code === "ENOTFOUND") {
248
+ message += "\n\u2192 DNS lookup failed. Cannot resolve hostname.\n\u2192 Check: Internet connection and DNS settings.";
249
+ } else if (code === "ETIMEDOUT") {
250
+ message += "\n\u2192 Connection timed out. Network or server issue.\n\u2192 Try: Check network connectivity and retry.";
251
+ } else if (code === "ECONNRESET") {
252
+ message += "\n\u2192 Connection reset by server. Possible network interruption.\n\u2192 Try: Retry the request.";
253
+ } else if (code === "EPIPE") {
254
+ message += "\n\u2192 Broken pipe. Server closed connection unexpectedly.\n\u2192 Check: Authentication credentials and permissions.";
255
+ } else if (code === "CERT_HAS_EXPIRED" || code === "UNABLE_TO_VERIFY_LEAF_SIGNATURE") {
256
+ message += "\n\u2192 SSL/TLS certificate error.\n\u2192 Check: System time and date are correct.\n\u2192 Try: Update CA certificates on your system.";
257
+ } else if (code) {
258
+ message += `
259
+ \u2192 Error code: ${code}`;
260
+ }
261
+ return message;
262
+ }
232
263
  async function httpRequestAttempt(url, options) {
233
264
  const {
234
265
  body,
235
266
  ca,
236
267
  followRedirects = true,
237
268
  headers = {},
269
+ hooks,
238
270
  maxRedirects = 5,
271
+ maxResponseSize,
239
272
  method = "GET",
240
273
  timeout = 3e4
241
274
  } = { __proto__: null, ...options };
275
+ const startTime = Date.now();
276
+ const mergedHeaders = {
277
+ "User-Agent": "socket-registry/1.0",
278
+ ...headers
279
+ };
280
+ hooks?.onRequest?.({ method, url, headers: mergedHeaders, timeout });
242
281
  return await new Promise((resolve, reject) => {
243
282
  const parsedUrl = new URL(url);
244
283
  const isHttps = parsedUrl.protocol === "https:";
245
284
  const httpModule = isHttps ? /* @__PURE__ */ getHttps() : /* @__PURE__ */ getHttp();
246
285
  const requestOptions = {
247
- headers: {
248
- "User-Agent": "socket-registry/1.0",
249
- ...headers
250
- },
286
+ headers: mergedHeaders,
251
287
  hostname: parsedUrl.hostname,
252
288
  method,
253
289
  path: parsedUrl.pathname + parsedUrl.search,
@@ -257,10 +293,23 @@ async function httpRequestAttempt(url, options) {
257
293
  if (ca && isHttps) {
258
294
  requestOptions["ca"] = ca;
259
295
  }
296
+ const emitResponse = (info) => {
297
+ hooks?.onResponse?.({
298
+ duration: Date.now() - startTime,
299
+ method,
300
+ url,
301
+ ...info
302
+ });
303
+ };
260
304
  const request = httpModule.request(
261
305
  requestOptions,
262
306
  (res) => {
263
307
  if (followRedirects && res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
308
+ emitResponse({
309
+ headers: res.headers,
310
+ status: res.statusCode,
311
+ statusText: res.statusMessage
312
+ });
264
313
  if (maxRedirects <= 0) {
265
314
  reject(
266
315
  new Error(
@@ -270,13 +319,24 @@ async function httpRequestAttempt(url, options) {
270
319
  return;
271
320
  }
272
321
  const redirectUrl = res.headers.location.startsWith("http") ? res.headers.location : new URL(res.headers.location, url).toString();
322
+ const redirectParsed = new URL(redirectUrl);
323
+ if (isHttps && redirectParsed.protocol !== "https:") {
324
+ reject(
325
+ new Error(
326
+ `Redirect from HTTPS to HTTP is not allowed: ${redirectUrl}`
327
+ )
328
+ );
329
+ return;
330
+ }
273
331
  resolve(
274
332
  httpRequestAttempt(redirectUrl, {
275
333
  body,
276
334
  ca,
277
335
  followRedirects,
278
336
  headers,
337
+ hooks,
279
338
  maxRedirects: maxRedirects - 1,
339
+ maxResponseSize,
280
340
  method,
281
341
  timeout
282
342
  })
@@ -284,7 +344,20 @@ async function httpRequestAttempt(url, options) {
284
344
  return;
285
345
  }
286
346
  const chunks = [];
347
+ let totalBytes = 0;
287
348
  res.on("data", (chunk) => {
349
+ totalBytes += chunk.length;
350
+ if (maxResponseSize && totalBytes > maxResponseSize) {
351
+ res.destroy();
352
+ const sizeMB = (totalBytes / (1024 * 1024)).toFixed(2);
353
+ const maxMB = (maxResponseSize / (1024 * 1024)).toFixed(2);
354
+ const err = new Error(
355
+ `Response exceeds maximum size limit (${sizeMB}MB > ${maxMB}MB)`
356
+ );
357
+ emitResponse({ error: err });
358
+ reject(err);
359
+ return;
360
+ }
288
361
  chunks.push(chunk);
289
362
  });
290
363
  res.on("end", () => {
@@ -303,39 +376,45 @@ async function httpRequestAttempt(url, options) {
303
376
  return JSON.parse(responseBody.toString("utf8"));
304
377
  },
305
378
  ok,
379
+ rawResponse: res,
306
380
  status: res.statusCode || 0,
307
381
  statusText: res.statusMessage || "",
308
382
  text() {
309
383
  return responseBody.toString("utf8");
310
384
  }
311
385
  };
386
+ emitResponse({
387
+ headers: res.headers,
388
+ status: res.statusCode,
389
+ statusText: res.statusMessage
390
+ });
312
391
  resolve(response);
313
392
  });
314
393
  res.on("error", (error) => {
394
+ emitResponse({ error });
315
395
  reject(error);
316
396
  });
317
397
  }
318
398
  );
319
399
  request.on("error", (error) => {
320
- const code = error.code;
321
- let message = `HTTP request failed for ${url}: ${error.message}
322
- `;
323
- if (code === "ENOTFOUND") {
324
- message += "DNS lookup failed. Check the hostname and your network connection.";
325
- } else if (code === "ECONNREFUSED") {
326
- message += "Connection refused. Verify the server is running and accessible.";
327
- } else if (code === "ETIMEDOUT") {
328
- message += "Request timed out. Check your network or increase the timeout value.";
329
- } else if (code === "ECONNRESET") {
330
- message += "Connection reset. The server may have closed the connection unexpectedly.";
331
- } else {
332
- message += "Check your network connection and verify the URL is correct.";
333
- }
334
- reject(new Error(message, { cause: error }));
400
+ const message = enrichErrorMessage(
401
+ url,
402
+ method,
403
+ error
404
+ );
405
+ const enhanced = new Error(message, { cause: error });
406
+ emitResponse({ error: enhanced });
407
+ reject(enhanced);
335
408
  });
336
409
  request.on("timeout", () => {
337
410
  request.destroy();
338
- reject(new Error(`Request timed out after ${timeout}ms`));
411
+ const err = new Error(
412
+ `${method} request timed out after ${timeout}ms: ${url}
413
+ \u2192 Server did not respond in time.
414
+ \u2192 Try: Increase timeout or check network connectivity.`
415
+ );
416
+ emitResponse({ error: err });
417
+ reject(err);
339
418
  });
340
419
  if (body) {
341
420
  request.write(body);
@@ -372,8 +451,10 @@ async function httpDownload(url, destPath, options) {
372
451
  }
373
452
  };
374
453
  }
454
+ const crypto = /* @__PURE__ */ getCrypto();
375
455
  const fs = /* @__PURE__ */ getFs();
376
- const tempPath = `${destPath}.download`;
456
+ const tempSuffix = crypto.randomBytes(6).toString("hex");
457
+ const tempPath = `${destPath}.${tempSuffix}.download`;
377
458
  if (fs.existsSync(tempPath)) {
378
459
  await (0, import_fs.safeDelete)(tempPath);
379
460
  }
@@ -389,14 +470,17 @@ async function httpDownload(url, destPath, options) {
389
470
  timeout
390
471
  });
391
472
  if (sha256) {
392
- const crypto = /* @__PURE__ */ getCrypto();
393
473
  const fileContent = await fs.promises.readFile(tempPath);
394
474
  const computedHash = crypto.createHash("sha256").update(fileContent).digest("hex");
395
- if (computedHash !== sha256.toLowerCase()) {
475
+ const expectedHash = sha256.toLowerCase();
476
+ if (computedHash.length !== expectedHash.length || !crypto.timingSafeEqual(
477
+ Buffer.from(computedHash),
478
+ Buffer.from(expectedHash)
479
+ )) {
396
480
  await (0, import_fs.safeDelete)(tempPath);
397
481
  throw new Error(
398
482
  `Checksum verification failed for ${url}
399
- Expected: ${sha256.toLowerCase()}
483
+ Expected: ${expectedHash}
400
484
  Computed: ${computedHash}`
401
485
  );
402
486
  }
@@ -459,7 +543,9 @@ async function httpRequest(url, options) {
459
543
  ca,
460
544
  followRedirects = true,
461
545
  headers = {},
546
+ hooks,
462
547
  maxRedirects = 5,
548
+ maxResponseSize,
463
549
  method = "GET",
464
550
  retries = 0,
465
551
  retryDelay = 1e3,
@@ -473,7 +559,9 @@ async function httpRequest(url, options) {
473
559
  ca,
474
560
  followRedirects,
475
561
  headers,
562
+ hooks,
476
563
  maxRedirects,
564
+ maxResponseSize,
477
565
  method,
478
566
  timeout
479
567
  });
@@ -519,6 +607,7 @@ async function httpText(url, options) {
519
607
  }
520
608
  // Annotate the CommonJS export names for ESM import in node:
521
609
  0 && (module.exports = {
610
+ enrichErrorMessage,
522
611
  fetchChecksums,
523
612
  httpDownload,
524
613
  httpJson,
package/dist/ipc.js CHANGED
@@ -116,7 +116,7 @@ async function ensureIpcDirectory(filePath) {
116
116
  const fs = /* @__PURE__ */ getFs();
117
117
  const path = /* @__PURE__ */ getPath();
118
118
  const dir = path.dirname(filePath);
119
- await fs.promises.mkdir(dir, { recursive: true });
119
+ await fs.promises.mkdir(dir, { recursive: true, mode: 448 });
120
120
  }
121
121
  async function writeIpcStub(appName, data) {
122
122
  const stubPath = getIpcStubPath(appName);
@@ -128,11 +128,10 @@ async function writeIpcStub(appName, data) {
128
128
  };
129
129
  const validated = IpcStubSchema.parse(ipcData);
130
130
  const fs = /* @__PURE__ */ getFs();
131
- await fs.promises.writeFile(
132
- stubPath,
133
- JSON.stringify(validated, null, 2),
134
- "utf8"
135
- );
131
+ await fs.promises.writeFile(stubPath, JSON.stringify(validated, null, 2), {
132
+ encoding: "utf8",
133
+ mode: 384
134
+ });
136
135
  return stubPath;
137
136
  }
138
137
  async function readIpcStub(stubPath) {
@@ -179,6 +178,7 @@ async function cleanupIpcStubs(appName) {
179
178
  const contentAge = now - validated.timestamp;
180
179
  isStale = isStale || contentAge > maxAgeMs;
181
180
  } catch {
181
+ isStale = true;
182
182
  }
183
183
  if (isStale) {
184
184
  (0, import_fs.safeDeleteSync)(filePath, { force: true });
package/dist/sorts.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var sorts_exports = {};
31
21
  __export(sorts_exports, {
@@ -36,10 +26,23 @@ __export(sorts_exports, {
36
26
  naturalSorter: () => naturalSorter
37
27
  });
38
28
  module.exports = __toCommonJS(sorts_exports);
39
- var fastSort = __toESM(require("./external/fast-sort.js"));
40
- var semver = __toESM(require("./external/semver.js"));
29
+ let _semver;
30
+ function getSemver() {
31
+ if (_semver === void 0) {
32
+ _semver = require("./external/semver.js");
33
+ }
34
+ return _semver;
35
+ }
36
+ let _fastSort;
37
+ function getFastSort() {
38
+ if (_fastSort === void 0) {
39
+ _fastSort = require("./external/fast-sort.js");
40
+ }
41
+ return _fastSort;
42
+ }
41
43
  // @__NO_SIDE_EFFECTS__
42
44
  function compareSemver(a, b) {
45
+ const semver = getSemver();
43
46
  const validA = semver.valid(a);
44
47
  const validB = semver.valid(b);
45
48
  if (!validA && !validB) {
@@ -90,6 +93,7 @@ let _naturalSorter;
90
93
  // @__NO_SIDE_EFFECTS__
91
94
  function naturalSorter(arrayToSort) {
92
95
  if (_naturalSorter === void 0) {
96
+ const fastSort = getFastSort();
93
97
  _naturalSorter = fastSort.createNewSortInstance({
94
98
  comparer: naturalCompare
95
99
  });
package/dist/spawn.js CHANGED
@@ -39,13 +39,20 @@ module.exports = __toCommonJS(spawn_exports);
39
39
  var import_node_process = __toESM(require("node:process"));
40
40
  var import_process = require("./constants/process");
41
41
  var import_errors = require("./errors");
42
- var import_promise_spawn = __toESM(require("./external/@npmcli/promise-spawn"));
43
42
  var import_arrays = require("./arrays");
44
43
  var import_bin = require("./bin");
45
44
  var import_normalize = require("./paths/normalize");
46
45
  var import_objects = require("./objects");
47
46
  var import_spinner = require("./spinner");
48
47
  var import_strings = require("./strings");
48
+ let _npmCliPromiseSpawn;
49
+ // @__NO_SIDE_EFFECTS__
50
+ function getNpmCliPromiseSpawn() {
51
+ if (_npmCliPromiseSpawn === void 0) {
52
+ _npmCliPromiseSpawn = require("./external/@npmcli/promise-spawn");
53
+ }
54
+ return _npmCliPromiseSpawn;
55
+ }
49
56
  let _path;
50
57
  // @__NO_SIDE_EFFECTS__
51
58
  function getPath() {
@@ -235,7 +242,8 @@ function spawn(cmd, args, options, extra) {
235
242
  uid: spawnOptions.uid,
236
243
  gid: spawnOptions.gid
237
244
  };
238
- const spawnPromise = (0, import_promise_spawn.default)(
245
+ const npmCliPromiseSpawn = /* @__PURE__ */ getNpmCliPromiseSpawn();
246
+ const spawnPromise = npmCliPromiseSpawn(
239
247
  actualCmd,
240
248
  args ? [...args] : [],
241
249
  promiseSpawnOpts,
package/dist/strings.js CHANGED
@@ -37,7 +37,14 @@ __export(strings_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(strings_exports);
39
39
  var import_ansi = require("./ansi");
40
- var import_get_east_asian_width = require("./external/get-east-asian-width");
40
+ let _eastAsianWidth;
41
+ // @__NO_SIDE_EFFECTS__
42
+ function getEastAsianWidth() {
43
+ if (_eastAsianWidth === void 0) {
44
+ _eastAsianWidth = require("./external/get-east-asian-width").eastAsianWidth;
45
+ }
46
+ return _eastAsianWidth;
47
+ }
41
48
  const fromCharCode = String.fromCharCode;
42
49
  // @__NO_SIDE_EFFECTS__
43
50
  function applyLinePrefix(str, options) {
@@ -164,6 +171,7 @@ function stringWidth(text) {
164
171
  }
165
172
  let width = 0;
166
173
  const eastAsianWidthOptions = { ambiguousAsWide: false };
174
+ const eastAsianWidth = /* @__PURE__ */ getEastAsianWidth();
167
175
  for (const { segment } of segmenter.segment(plainText)) {
168
176
  if (zeroWidthClusterRegex.test(segment)) {
169
177
  continue;
@@ -177,14 +185,14 @@ function stringWidth(text) {
177
185
  if (codePoint === void 0) {
178
186
  continue;
179
187
  }
180
- width += (0, import_get_east_asian_width.eastAsianWidth)(codePoint, eastAsianWidthOptions);
188
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
181
189
  if (segment.length > 1) {
182
190
  for (const char of segment.slice(1)) {
183
191
  const charCode = char.charCodeAt(0);
184
192
  if (charCode >= 65280 && charCode <= 65519) {
185
193
  const trailingCodePoint = char.codePointAt(0);
186
194
  if (trailingCodePoint !== void 0) {
187
- width += (0, import_get_east_asian_width.eastAsianWidth)(trailingCodePoint, eastAsianWidthOptions);
195
+ width += eastAsianWidth(trailingCodePoint, eastAsianWidthOptions);
188
196
  }
189
197
  }
190
198
  }