@socketsecurity/lib 5.11.1 → 5.11.3

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 (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/abort.js +1 -3
  3. package/dist/agent.js +12 -1
  4. package/dist/ansi.js +1 -1
  5. package/dist/archives.js +7 -6
  6. package/dist/argv/flags.d.ts +0 -7
  7. package/dist/argv/flags.js +12 -1
  8. package/dist/argv/parse.js +5 -9
  9. package/dist/bin.js +2 -1
  10. package/dist/cache-with-ttl.js +10 -3
  11. package/dist/constants/node.js +14 -3
  12. package/dist/cover/code.js +13 -2
  13. package/dist/cover/type.js +12 -1
  14. package/dist/dlx/binary.js +16 -5
  15. package/dist/dlx/manifest.js +22 -33
  16. package/dist/env/package-manager.js +12 -1
  17. package/dist/env/rewire.js +14 -3
  18. package/dist/external/@npmcli/package-json.js +5 -3
  19. package/dist/external/adm-zip.js +1 -0
  20. package/dist/external/debug.js +18 -10
  21. package/dist/external/external-pack.js +8 -2
  22. package/dist/external/libnpmexec.js +2 -2
  23. package/dist/external/npm-pack.js +380 -367
  24. package/dist/external/p-map.js +240 -0
  25. package/dist/external/pico-pack.js +245 -12
  26. package/dist/external/zod.js +1 -0
  27. package/dist/fs.d.ts +0 -4
  28. package/dist/fs.js +13 -2
  29. package/dist/git.js +12 -1
  30. package/dist/github.js +15 -6
  31. package/dist/http-request.d.ts +29 -0
  32. package/dist/http-request.js +23 -2
  33. package/dist/ipc.js +17 -5
  34. package/dist/json/edit.js +14 -3
  35. package/dist/logger.js +5 -4
  36. package/dist/memoization.js +46 -13
  37. package/dist/packages/isolation.js +9 -1
  38. package/dist/performance.js +13 -2
  39. package/dist/process-lock.js +16 -3
  40. package/dist/promise-queue.d.ts +2 -0
  41. package/dist/promise-queue.js +20 -9
  42. package/dist/promises.js +1 -3
  43. package/dist/releases/github.js +9 -4
  44. package/dist/sea.js +12 -1
  45. package/dist/shadow.js +14 -3
  46. package/dist/spawn.js +5 -4
  47. package/dist/spinner.d.ts +0 -4
  48. package/dist/spinner.js +2 -1
  49. package/dist/stdio/clear.d.ts +0 -21
  50. package/dist/stdio/clear.js +20 -9
  51. package/dist/stdio/mask.js +27 -16
  52. package/dist/stdio/progress.js +3 -2
  53. package/dist/stdio/stderr.d.ts +0 -13
  54. package/dist/stdio/stderr.js +12 -1
  55. package/dist/stdio/stdout.js +17 -6
  56. package/dist/suppress-warnings.d.ts +0 -9
  57. package/dist/suppress-warnings.js +17 -6
  58. package/dist/temporary-executor.js +14 -3
  59. package/dist/validation/json-parser.js +10 -12
  60. package/package.json +8 -6
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(promise_queue_exports);
25
25
  class PromiseQueue {
26
26
  queue = [];
27
27
  running = 0;
28
+ idleResolvers = [];
28
29
  maxConcurrency;
29
30
  maxQueueLength;
30
31
  /**
@@ -47,7 +48,7 @@ class PromiseQueue {
47
48
  async add(fn) {
48
49
  return await new Promise((resolve, reject) => {
49
50
  const task = { fn, resolve, reject };
50
- if (this.maxQueueLength && this.queue.length >= this.maxQueueLength) {
51
+ if (this.maxQueueLength !== void 0 && this.queue.length >= this.maxQueueLength) {
51
52
  const droppedTask = this.queue.shift();
52
53
  if (droppedTask) {
53
54
  droppedTask.reject(new Error("Task dropped: queue length exceeded"));
@@ -59,6 +60,7 @@ class PromiseQueue {
59
60
  }
60
61
  runNext() {
61
62
  if (this.running >= this.maxConcurrency || this.queue.length === 0) {
63
+ this.notifyIdleIfNeeded();
62
64
  return;
63
65
  }
64
66
  const task = this.queue.shift();
@@ -71,19 +73,23 @@ class PromiseQueue {
71
73
  this.runNext();
72
74
  });
73
75
  }
76
+ notifyIdleIfNeeded() {
77
+ if (this.running === 0 && this.queue.length === 0) {
78
+ for (const resolve of this.idleResolvers) {
79
+ resolve();
80
+ }
81
+ this.idleResolvers = [];
82
+ }
83
+ }
74
84
  /**
75
85
  * Wait for all queued and running tasks to complete
76
86
  */
77
87
  async onIdle() {
88
+ if (this.running === 0 && this.queue.length === 0) {
89
+ return;
90
+ }
78
91
  return await new Promise((resolve) => {
79
- const check = () => {
80
- if (this.running === 0 && this.queue.length === 0) {
81
- resolve();
82
- } else {
83
- setImmediate(check);
84
- }
85
- };
86
- check();
92
+ this.idleResolvers.push(resolve);
87
93
  });
88
94
  }
89
95
  /**
@@ -102,7 +108,12 @@ class PromiseQueue {
102
108
  * Clear all pending tasks from the queue (does not affect running tasks)
103
109
  */
104
110
  clear() {
111
+ const pending = this.queue;
105
112
  this.queue = [];
113
+ for (const task of pending) {
114
+ task.reject(new Error("Task cancelled: queue cleared"));
115
+ }
116
+ this.notifyIdleIfNeeded();
106
117
  }
107
118
  }
108
119
  // Annotate the CommonJS export names for ESM import in node:
package/dist/promises.js CHANGED
@@ -203,9 +203,7 @@ async function pRetry(callbackFn, options) {
203
203
  try {
204
204
  return await callbackFn(...args || [], { signal });
205
205
  } catch (e) {
206
- if (error === import_core.UNDEFINED_TOKEN) {
207
- error = e;
208
- }
206
+ error = e;
209
207
  if (attempts < 0) {
210
208
  break;
211
209
  }
@@ -40,6 +40,7 @@ __export(github_exports, {
40
40
  getReleaseAssetUrl: () => getReleaseAssetUrl
41
41
  });
42
42
  module.exports = __toCommonJS(github_exports);
43
+ var import_node_process = __toESM(require("node:process"));
43
44
  var import_picomatch = __toESM(require("../external/picomatch.js"));
44
45
  var import_archives = require("../archives.js");
45
46
  var import_fs = require("../fs.js");
@@ -92,7 +93,7 @@ async function downloadGitHubRelease(config) {
92
93
  const {
93
94
  assetName,
94
95
  binaryName,
95
- cwd = process.cwd(),
96
+ cwd = import_node_process.default.cwd(),
96
97
  downloadDir = "build/downloaded",
97
98
  owner,
98
99
  platformArch,
@@ -147,7 +148,7 @@ async function downloadGitHubRelease(config) {
147
148
  const isWindows = binaryName.endsWith(".exe");
148
149
  if (!isWindows) {
149
150
  fs.chmodSync(binaryPath, 493);
150
- if (removeMacOSQuarantine && process.platform === "darwin" && platformArch.startsWith("darwin")) {
151
+ if (removeMacOSQuarantine && import_node_process.default.platform === "darwin" && platformArch.startsWith("darwin")) {
151
152
  try {
152
153
  await (0, import_spawn.spawn)("xattr", ["-d", "com.apple.quarantine", binaryPath], {
153
154
  stdio: "ignore"
@@ -185,7 +186,7 @@ async function downloadReleaseAsset(tag, assetPattern, outputPath, repoConfig, o
185
186
  });
186
187
  }
187
188
  function getAuthHeaders() {
188
- const token = process.env["GH_TOKEN"] || process.env["GITHUB_TOKEN"];
189
+ const token = import_node_process.default.env["GH_TOKEN"] || import_node_process.default.env["GITHUB_TOKEN"];
189
190
  const headers = {
190
191
  Accept: "application/vnd.github+json",
191
192
  "X-GitHub-Api-Version": "2022-11-28"
@@ -293,7 +294,11 @@ async function getReleaseAssetUrl(tag, assetPattern, repoConfig, options = {}) {
293
294
  { cause }
294
295
  );
295
296
  }
296
- const asset = release.assets.find((a) => isMatch(a.name));
297
+ const assets = release.assets;
298
+ if (!Array.isArray(assets)) {
299
+ throw new Error(`Release ${tag} has no assets`);
300
+ }
301
+ const asset = assets.find((a) => isMatch(a.name));
297
302
  if (!asset) {
298
303
  const patternDesc = typeof assetPattern === "string" ? assetPattern : "matching pattern";
299
304
  throw new Error(`Asset ${patternDesc} not found in release ${tag}`);
package/dist/sea.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var sea_exports = {};
21
31
  __export(sea_exports, {
@@ -23,10 +33,11 @@ __export(sea_exports, {
23
33
  isSeaBinary: () => isSeaBinary
24
34
  });
25
35
  module.exports = __toCommonJS(sea_exports);
36
+ var import_node_process = __toESM(require("node:process"));
26
37
  var import_normalize = require("./paths/normalize");
27
38
  let _isSea;
28
39
  function getSeaBinaryPath() {
29
- return isSeaBinary() && process.argv[0] ? (0, import_normalize.normalizePath)(process.argv[0]) : void 0;
40
+ return isSeaBinary() && import_node_process.default.argv[0] ? (0, import_normalize.normalizePath)(import_node_process.default.argv[0]) : void 0;
30
41
  }
31
42
  function isSeaBinary() {
32
43
  if (_isSea === void 0) {
package/dist/shadow.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,27 +18,36 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var shadow_exports = {};
21
31
  __export(shadow_exports, {
22
32
  shouldSkipShadow: () => shouldSkipShadow
23
33
  });
24
34
  module.exports = __toCommonJS(shadow_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_normalize = require("./paths/normalize");
26
37
  function shouldSkipShadow(binPath, options) {
27
- const { cwd = process.cwd(), win32 = false } = {
38
+ const { cwd = import_node_process.default.cwd(), win32 = false } = {
28
39
  __proto__: null,
29
40
  ...options
30
41
  };
31
42
  if (win32 && binPath) {
32
43
  return true;
33
44
  }
34
- const userAgent = process.env["npm_config_user_agent"];
45
+ const userAgent = import_node_process.default.env["npm_config_user_agent"];
35
46
  if (userAgent?.includes("exec") || userAgent?.includes("npx") || userAgent?.includes("dlx")) {
36
47
  return true;
37
48
  }
38
49
  const normalizedCwd = (0, import_normalize.normalizePath)(cwd);
39
- const npmCache = process.env["npm_config_cache"];
50
+ const npmCache = import_node_process.default.env["npm_config_cache"];
40
51
  if (npmCache && normalizedCwd.includes((0, import_normalize.normalizePath)(npmCache))) {
41
52
  return true;
42
53
  }
package/dist/spawn.js CHANGED
@@ -36,6 +36,7 @@ __export(spawn_exports, {
36
36
  spawnSync: () => spawnSync
37
37
  });
38
38
  module.exports = __toCommonJS(spawn_exports);
39
+ var import_node_process = __toESM(require("node:process"));
39
40
  var import_process = require("./constants/process");
40
41
  var import_errors = require("./errors");
41
42
  var import_promise_spawn = __toESM(require("./external/@npmcli/promise-spawn"));
@@ -204,7 +205,7 @@ function spawn(cmd, args, options, extra) {
204
205
  }
205
206
  }
206
207
  }
207
- const WIN32 = process.platform === "win32";
208
+ const WIN32 = import_node_process.default.platform === "win32";
208
209
  if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
209
210
  if (!(0, import_normalize.isPath)(actualCmd)) {
210
211
  actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
@@ -218,9 +219,9 @@ function spawn(cmd, args, options, extra) {
218
219
  }
219
220
  const envToUse = env ? {
220
221
  __proto__: null,
221
- ...process.env,
222
+ ...import_node_process.default.env,
222
223
  ...env
223
- } : process.env;
224
+ } : import_node_process.default.env;
224
225
  const promiseSpawnOpts = {
225
226
  __proto__: null,
226
227
  cwd: typeof spawnOptions.cwd === "string" ? spawnOptions.cwd : void 0,
@@ -290,7 +291,7 @@ function spawnSync(cmd, args, options) {
290
291
  }
291
292
  }
292
293
  const shell = (0, import_objects.getOwn)(options, "shell");
293
- const WIN32 = process.platform === "win32";
294
+ const WIN32 = import_node_process.default.platform === "win32";
294
295
  if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
295
296
  if (!(0, import_normalize.isPath)(actualCmd)) {
296
297
  actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
package/dist/spinner.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- /**
2
- * @fileoverview CLI spinner utilities for long-running operations.
3
- * Provides animated progress indicators with CI environment detection.
4
- */
5
1
  import type { Writable } from 'stream';
6
2
  import type { ColorInherit, ColorRgb, ColorValue } from './colors';
7
3
  import type { ShimmerColorGradient, ShimmerConfig, ShimmerDirection, ShimmerState } from './effects/text-shimmer';
package/dist/spinner.js CHANGED
@@ -38,6 +38,7 @@ __export(spinner_exports, {
38
38
  withSpinnerSync: () => withSpinnerSync
39
39
  });
40
40
  module.exports = __toCommonJS(spinner_exports);
41
+ var import_node_process = __toESM(require("node:process"));
41
42
  var import_yoctocolors_cjs = __toESM(require("./external/yoctocolors-cjs"));
42
43
  var import_colors = require("./colors");
43
44
  var import_process = require("./constants/process");
@@ -881,7 +882,7 @@ async function withSpinner(options) {
881
882
  const wasSpinning = spinner.isSpinning;
882
883
  spinner.stop();
883
884
  if (wasSpinning) {
884
- process.stderr.write("\r\x1B[2K");
885
+ import_node_process.default.stderr.write("\r\x1B[2K");
885
886
  }
886
887
  if (savedColor !== void 0) {
887
888
  spinner.color = savedColor;
@@ -1,24 +1,3 @@
1
- /**
2
- * @fileoverview Terminal clearing and cursor utilities.
3
- * Provides functions for clearing lines, screens, and managing cursor position.
4
- */
5
- /**
6
- * Clear the current line in the terminal.
7
- * Uses native TTY methods when available, falls back to ANSI escape codes.
8
- *
9
- * ANSI Sequences:
10
- * - `\r`: Carriage return (move to line start)
11
- * - `\x1b[K`: Clear from cursor to end of line
12
- *
13
- * @param stream - Output stream to clear
14
- * @default stream process.stdout
15
- *
16
- * @example
17
- * ```ts
18
- * clearLine() // Clear current line on stdout
19
- * clearLine(process.stderr) // Clear on stderr
20
- * ```
21
- */
22
1
  export declare function clearLine(stream?: NodeJS.WriteStream): void;
23
2
  /**
24
3
  * Clear multiple lines above the current cursor position.
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var clear_exports = {};
21
31
  __export(clear_exports, {
@@ -30,7 +40,8 @@ __export(clear_exports, {
30
40
  showCursor: () => showCursor
31
41
  });
32
42
  module.exports = __toCommonJS(clear_exports);
33
- function clearLine(stream = process.stdout) {
43
+ var import_node_process = __toESM(require("node:process"));
44
+ function clearLine(stream = import_node_process.default.stdout) {
34
45
  if (stream.isTTY) {
35
46
  stream.cursorTo(0);
36
47
  stream.clearLine(0);
@@ -38,36 +49,36 @@ function clearLine(stream = process.stdout) {
38
49
  stream.write("\r\x1B[K");
39
50
  }
40
51
  }
41
- function clearLines(count, stream = process.stdout) {
52
+ function clearLines(count, stream = import_node_process.default.stdout) {
42
53
  for (let i = 0; i < count; i++) {
43
54
  stream.write("\x1B[1A\x1B[2K");
44
55
  }
45
56
  }
46
- function clearScreen(stream = process.stdout) {
57
+ function clearScreen(stream = import_node_process.default.stdout) {
47
58
  if (stream.isTTY) {
48
59
  stream.write("\x1Bc");
49
60
  }
50
61
  }
51
- function clearVisible(stream = process.stdout) {
62
+ function clearVisible(stream = import_node_process.default.stdout) {
52
63
  clearScreen(stream);
53
64
  }
54
- function cursorToStart(stream = process.stdout) {
65
+ function cursorToStart(stream = import_node_process.default.stdout) {
55
66
  if (stream.isTTY) {
56
67
  stream.cursorTo(0);
57
68
  } else {
58
69
  stream.write("\r");
59
70
  }
60
71
  }
61
- function hideCursor(stream = process.stdout) {
72
+ function hideCursor(stream = import_node_process.default.stdout) {
62
73
  stream.write("\x1B[?25l");
63
74
  }
64
- function showCursor(stream = process.stdout) {
75
+ function showCursor(stream = import_node_process.default.stdout) {
65
76
  stream.write("\x1B[?25h");
66
77
  }
67
- function saveCursor(stream = process.stdout) {
78
+ function saveCursor(stream = import_node_process.default.stdout) {
68
79
  stream.write("\x1B7");
69
80
  }
70
- function restoreCursor(stream = process.stdout) {
81
+ function restoreCursor(stream = import_node_process.default.stdout) {
71
82
  stream.write("\x1B8");
72
83
  }
73
84
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var mask_exports = {};
21
31
  __export(mask_exports, {
@@ -25,6 +35,7 @@ __export(mask_exports, {
25
35
  runWithMask: () => runWithMask
26
36
  });
27
37
  module.exports = __toCommonJS(mask_exports);
38
+ var import_node_process = __toESM(require("node:process"));
28
39
  var import_spinner = require("../spinner.js");
29
40
  var import_clear = require("./clear.js");
30
41
  var import_stdout = require("./stdout.js");
@@ -76,7 +87,7 @@ function createKeyboardHandler(mask, child, options = {}) {
76
87
  if (mask.outputBuffer.length > 0) {
77
88
  const lineCount = mask.outputBuffer.join("").split("\n").length + 1;
78
89
  for (let i = 0; i < lineCount; i += 1) {
79
- process.stdout.write("\x1B[1A\x1B[2K");
90
+ import_node_process.default.stdout.write("\x1B[1A\x1B[2K");
80
91
  }
81
92
  }
82
93
  (0, import_clear.clearLine)();
@@ -88,8 +99,8 @@ function createKeyboardHandler(mask, child, options = {}) {
88
99
  }
89
100
  } else if (key?.ctrl && key.name === "c") {
90
101
  child.kill("SIGTERM");
91
- if (process.stdin.isTTY) {
92
- process.stdin.setRawMode(false);
102
+ if (import_node_process.default.stdin.isTTY) {
103
+ import_node_process.default.stdin.setRawMode(false);
93
104
  }
94
105
  throw new Error("Process cancelled by user");
95
106
  }
@@ -99,20 +110,20 @@ function attachOutputMask(child, options = {}) {
99
110
  return new Promise((resolve, reject) => {
100
111
  const { message = "Running\u2026" } = options;
101
112
  const mask = createOutputMask(options);
102
- if (mask.isSpinning && process.stdout.isTTY) {
113
+ if (mask.isSpinning && import_node_process.default.stdout.isTTY) {
103
114
  spinner.start(
104
115
  `${message} (ctrl+o ${options.toggleText || "to see full output"})`
105
116
  );
106
117
  }
107
- if (process.stdin.isTTY) {
108
- (/* @__PURE__ */ getReadline()).emitKeypressEvents(process.stdin);
109
- process.stdin.setRawMode(true);
118
+ if (import_node_process.default.stdin.isTTY) {
119
+ (/* @__PURE__ */ getReadline()).emitKeypressEvents(import_node_process.default.stdin);
120
+ import_node_process.default.stdin.setRawMode(true);
110
121
  const keypressHandler = createKeyboardHandler(mask, child, options);
111
- process.stdin.on("keypress", keypressHandler);
122
+ import_node_process.default.stdin.on("keypress", keypressHandler);
112
123
  child.on("exit", () => {
113
- if (process.stdin.isTTY) {
114
- process.stdin.setRawMode(false);
115
- process.stdin.removeListener("keypress", keypressHandler);
124
+ if (import_node_process.default.stdin.isTTY) {
125
+ import_node_process.default.stdin.setRawMode(false);
126
+ import_node_process.default.stdin.removeListener("keypress", keypressHandler);
116
127
  }
117
128
  });
118
129
  }
@@ -143,7 +154,7 @@ function attachOutputMask(child, options = {}) {
143
154
  return void 0;
144
155
  }
145
156
  if (mask.verbose) {
146
- process.stderr.write(text);
157
+ import_node_process.default.stderr.write(text);
147
158
  } else {
148
159
  mask.outputBuffer.push(text);
149
160
  }
@@ -151,8 +162,8 @@ function attachOutputMask(child, options = {}) {
151
162
  });
152
163
  }
153
164
  child.on("exit", (code) => {
154
- if (process.stdin.isTTY) {
155
- process.stdin.setRawMode(false);
165
+ if (import_node_process.default.stdin.isTTY) {
166
+ import_node_process.default.stdin.setRawMode(false);
156
167
  }
157
168
  let finalCode = code || 0;
158
169
  if (options.overrideExitCode) {
@@ -181,8 +192,8 @@ function attachOutputMask(child, options = {}) {
181
192
  resolve(finalCode);
182
193
  });
183
194
  child.on("error", (error) => {
184
- if (process.stdin.isTTY) {
185
- process.stdin.setRawMode(false);
195
+ if (import_node_process.default.stdin.isTTY) {
196
+ import_node_process.default.stdin.setRawMode(false);
186
197
  }
187
198
  if (mask.isSpinning) {
188
199
  spinner.failAndStop(`${message} error`);
@@ -33,6 +33,7 @@ __export(progress_exports, {
33
33
  createProgressIndicator: () => createProgressIndicator
34
34
  });
35
35
  module.exports = __toCommonJS(progress_exports);
36
+ var import_node_process = __toESM(require("node:process"));
36
37
  var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
37
38
  var import_strings = require("../strings");
38
39
  class ProgressBar {
@@ -62,7 +63,7 @@ class ProgressBar {
62
63
  constructor(total, options) {
63
64
  this.total = total;
64
65
  this.startTime = Date.now();
65
- this.stream = options?.stream || process.stderr;
66
+ this.stream = options?.stream || import_node_process.default.stderr;
66
67
  this.options = {
67
68
  width: 40,
68
69
  format: ":bar :percent :current/:total",
@@ -195,7 +196,7 @@ class ProgressBar {
195
196
  }
196
197
  }
197
198
  function createProgressIndicator(current, total, label) {
198
- const percent = Math.floor(current / total * 100);
199
+ const percent = total === 0 ? 0 : Math.floor(current / total * 100);
199
200
  const progress = `${current}/${total}`;
200
201
  let output = "";
201
202
  if (label) {
@@ -4,19 +4,6 @@
4
4
  */
5
5
  // Get the actual stderr stream
6
6
  declare const stderr: NodeJS.WriteStream;
7
- /**
8
- * Write a line to stderr with trailing newline.
9
- * Used for error messages, warnings, and diagnostic output.
10
- *
11
- * @param text - Text to write
12
- * @default text ''
13
- *
14
- * @example
15
- * ```ts
16
- * writeErrorLine('Error: File not found')
17
- * writeErrorLine() // Write empty line
18
- * ```
19
- */
20
7
  export declare function writeErrorLine(text?: string): void;
21
8
  /**
22
9
  * Write text to stderr without adding a newline.
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var stderr_exports = {};
21
31
  __export(stderr_exports, {
@@ -32,7 +42,8 @@ __export(stderr_exports, {
32
42
  writeWarning: () => writeWarning
33
43
  });
34
44
  module.exports = __toCommonJS(stderr_exports);
35
- const stderr = process.stderr;
45
+ var import_node_process = __toESM(require("node:process"));
46
+ const stderr = import_node_process.default.stderr;
36
47
  function writeErrorLine(text = "") {
37
48
  stderr.write(`${text}
38
49
  `);
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
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
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var stdout_exports = {};
21
31
  __export(stdout_exports, {
@@ -33,8 +43,9 @@ __export(stdout_exports, {
33
43
  writeLine: () => writeLine
34
44
  });
35
45
  module.exports = __toCommonJS(stdout_exports);
46
+ var import_node_process = __toESM(require("node:process"));
36
47
  var import_tty = require("tty");
37
- const stdout = process.stdout;
48
+ const stdout = import_node_process.default.stdout;
38
49
  function writeLine(text = "") {
39
50
  stdout.write(`${text}
40
51
  `);
@@ -78,14 +89,14 @@ function showCursor() {
78
89
  }
79
90
  }
80
91
  function ensureCursorOnExit() {
81
- process.on("exit", showCursor);
82
- process.on("SIGINT", () => {
92
+ import_node_process.default.on("exit", showCursor);
93
+ import_node_process.default.on("SIGINT", () => {
83
94
  showCursor();
84
- process.exit(130);
95
+ import_node_process.default.exit(130);
85
96
  });
86
- process.on("SIGTERM", () => {
97
+ import_node_process.default.on("SIGTERM", () => {
87
98
  showCursor();
88
- process.exit(143);
99
+ import_node_process.default.exit(143);
89
100
  });
90
101
  }
91
102
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,12 +1,3 @@
1
- /**
2
- * Suppress MaxListenersExceededWarning messages.
3
- * This is useful in tests or scripts where multiple listeners are expected.
4
- *
5
- * @example
6
- * import { suppressMaxListenersWarning } from '@socketsecurity/lib/suppress-warnings'
7
- *
8
- * suppressMaxListenersWarning()
9
- */
10
1
  export declare function suppressMaxListenersWarning(): void;
11
2
  /**
12
3
  * Suppress all process warnings of a specific type.