@socketsecurity/lib 5.18.2 → 5.19.1

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 (296) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  142. package/dist/external/external-pack.js +1562 -1673
  143. package/dist/external/npm-pack.js +5 -1
  144. package/dist/fs.d.ts +92 -113
  145. package/dist/fs.js +35 -35
  146. package/dist/git.d.ts +170 -164
  147. package/dist/git.js +113 -87
  148. package/dist/github.d.ts +249 -227
  149. package/dist/github.js +82 -81
  150. package/dist/globs.d.ts +31 -17
  151. package/dist/globs.js +51 -58
  152. package/dist/http-request.d.ts +99 -99
  153. package/dist/http-request.js +182 -156
  154. package/dist/ipc-cli.d.ts +28 -0
  155. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  156. package/dist/ipc.d.ts +9 -299
  157. package/dist/ipc.js +18 -204
  158. package/dist/json/edit.d.ts +3 -1
  159. package/dist/json/edit.js +30 -30
  160. package/dist/json/format.d.ts +36 -36
  161. package/dist/json/format.js +22 -21
  162. package/dist/json/parse.d.ts +4 -2
  163. package/dist/json/parse.js +1 -0
  164. package/dist/json/types.js +1 -0
  165. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  166. package/dist/{links/index.js → links.js} +5 -4
  167. package/dist/logger.d.ts +4 -6
  168. package/dist/logger.js +61 -53
  169. package/dist/memoization.d.ts +52 -49
  170. package/dist/memoization.js +55 -33
  171. package/dist/objects.d.ts +25 -44
  172. package/dist/objects.js +2 -1
  173. package/dist/package-extensions.d.ts +6 -0
  174. package/dist/package-extensions.js +2 -1
  175. package/dist/packages/edit.d.ts +3 -5
  176. package/dist/packages/edit.js +4 -3
  177. package/dist/packages/exports.d.ts +11 -14
  178. package/dist/packages/exports.js +11 -10
  179. package/dist/packages/isolation.d.ts +4 -0
  180. package/dist/packages/isolation.js +20 -19
  181. package/dist/packages/licenses.d.ts +3 -10
  182. package/dist/packages/licenses.js +2 -1
  183. package/dist/packages/manifest.d.ts +3 -3
  184. package/dist/packages/manifest.js +1 -0
  185. package/dist/packages/normalize.d.ts +3 -4
  186. package/dist/packages/normalize.js +1 -0
  187. package/dist/packages/operations.d.ts +3 -10
  188. package/dist/packages/operations.js +1 -0
  189. package/dist/packages/provenance.d.ts +10 -8
  190. package/dist/packages/provenance.js +55 -54
  191. package/dist/packages/specs.d.ts +3 -5
  192. package/dist/packages/specs.js +1 -0
  193. package/dist/packages/validation.d.ts +3 -3
  194. package/dist/packages/validation.js +1 -0
  195. package/dist/packages.d.ts +2 -17
  196. package/dist/packages.js +2 -1
  197. package/dist/paths/dirnames.d.ts +0 -2
  198. package/dist/paths/dirnames.js +1 -0
  199. package/dist/paths/exts.d.ts +0 -1
  200. package/dist/paths/exts.js +1 -0
  201. package/dist/paths/filenames.d.ts +0 -1
  202. package/dist/paths/filenames.js +1 -0
  203. package/dist/paths/globs.d.ts +0 -1
  204. package/dist/paths/globs.js +1 -0
  205. package/dist/paths/normalize.d.ts +115 -123
  206. package/dist/paths/normalize.js +128 -127
  207. package/dist/paths/packages.d.ts +3 -2
  208. package/dist/paths/packages.js +2 -1
  209. package/dist/paths/rewire.d.ts +9 -0
  210. package/dist/paths/rewire.js +5 -3
  211. package/dist/paths/socket.d.ts +37 -23
  212. package/dist/paths/socket.js +26 -25
  213. package/dist/performance.d.ts +87 -84
  214. package/dist/performance.js +97 -96
  215. package/dist/process-lock.d.ts +41 -1
  216. package/dist/process-lock.js +24 -17
  217. package/dist/promise-queue.d.ts +6 -0
  218. package/dist/promise-queue.js +1 -0
  219. package/dist/promises.d.ts +40 -55
  220. package/dist/promises.js +12 -11
  221. package/dist/regexps.d.ts +0 -5
  222. package/dist/regexps.js +1 -0
  223. package/dist/releases/github.d.ts +59 -63
  224. package/dist/releases/github.js +95 -100
  225. package/dist/releases/socket-btm.d.ts +9 -2
  226. package/dist/releases/socket-btm.js +32 -25
  227. package/dist/sea.d.ts +5 -0
  228. package/dist/sea.js +1 -0
  229. package/dist/shadow.d.ts +4 -0
  230. package/dist/shadow.js +1 -0
  231. package/dist/signal-exit.d.ts +7 -7
  232. package/dist/signal-exit.js +46 -45
  233. package/dist/sorts.d.ts +5 -7
  234. package/dist/sorts.js +11 -10
  235. package/dist/spawn.d.ts +96 -77
  236. package/dist/spawn.js +39 -38
  237. package/dist/spinner.d.ts +21 -22
  238. package/dist/spinner.js +15 -11
  239. package/dist/ssri.d.ts +31 -36
  240. package/dist/ssri.js +15 -14
  241. package/dist/stdio/_stream.d.ts +31 -0
  242. package/dist/stdio/_stream.js +57 -0
  243. package/dist/stdio/clear.d.ts +38 -15
  244. package/dist/stdio/clear.js +5 -4
  245. package/dist/stdio/divider.d.ts +40 -36
  246. package/dist/stdio/divider.js +10 -9
  247. package/dist/stdio/footer.d.ts +20 -0
  248. package/dist/stdio/footer.js +12 -2
  249. package/dist/stdio/header.d.ts +4 -16
  250. package/dist/stdio/header.js +1 -9
  251. package/dist/stdio/progress.d.ts +4 -0
  252. package/dist/stdio/progress.js +13 -8
  253. package/dist/stdio/prompts.d.ts +24 -23
  254. package/dist/stdio/prompts.js +10 -9
  255. package/dist/stdio/stderr.d.ts +51 -39
  256. package/dist/stdio/stderr.js +19 -22
  257. package/dist/stdio/stdout.d.ts +54 -52
  258. package/dist/stdio/stdout.js +35 -33
  259. package/dist/streams.d.ts +4 -3
  260. package/dist/streams.js +1 -0
  261. package/dist/strings.d.ts +31 -85
  262. package/dist/strings.js +5 -49
  263. package/dist/suppress-warnings.d.ts +32 -15
  264. package/dist/suppress-warnings.js +14 -13
  265. package/dist/tables.d.ts +30 -26
  266. package/dist/tables.js +24 -23
  267. package/dist/temporary-executor.d.ts +4 -0
  268. package/dist/temporary-executor.js +1 -0
  269. package/dist/themes/context.d.ts +30 -26
  270. package/dist/themes/context.js +19 -18
  271. package/dist/themes/index.d.ts +0 -4
  272. package/dist/themes/index.js +1 -0
  273. package/dist/themes/themes.d.ts +1 -1
  274. package/dist/themes/themes.js +1 -0
  275. package/dist/themes/types.js +1 -0
  276. package/dist/themes/utils.d.ts +46 -43
  277. package/dist/themes/utils.js +45 -44
  278. package/dist/types.d.ts +48 -52
  279. package/dist/types.js +35 -35
  280. package/dist/url.d.ts +48 -53
  281. package/dist/url.js +38 -37
  282. package/dist/validation/json-parser.d.ts +19 -190
  283. package/dist/validation/json-parser.js +5 -69
  284. package/dist/validation/types.d.ts +9 -33
  285. package/dist/validation/types.js +1 -0
  286. package/dist/versions.d.ts +1 -0
  287. package/dist/versions.js +2 -1
  288. package/dist/words.d.ts +3 -6
  289. package/dist/words.js +1 -0
  290. package/dist/zod.js +1 -0
  291. package/package.json +40 -54
  292. package/dist/functions.d.ts +0 -57
  293. package/dist/functions.js +0 -70
  294. package/dist/stdio/mask.d.ts +0 -151
  295. package/dist/stdio/mask.js +0 -224
  296. package/dist/utils/get-ipc.d.ts +0 -15
package/dist/spawn.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -37,15 +38,37 @@ __export(spawn_exports, {
37
38
  });
38
39
  module.exports = __toCommonJS(spawn_exports);
39
40
  var import_node_process = __toESM(require("node:process"));
40
- var import_process = require("./constants/process");
41
- var import_errors = require("./errors");
42
41
  var import_arrays = require("./arrays");
43
42
  var import_bin = require("./bin");
44
- var import_normalize = require("./paths/normalize");
43
+ var import_process = require("./constants/process");
44
+ var import_errors = require("./errors");
45
45
  var import_objects = require("./objects");
46
+ var import_normalize = require("./paths/normalize");
46
47
  var import_spinner = require("./spinner");
47
48
  var import_strings = require("./strings");
49
+ const abortSignal = (0, import_process.getAbortSignal)();
50
+ const spinner = (0, import_spinner.getDefaultSpinner)();
51
+ const stackCache = /* @__PURE__ */ new WeakMap();
52
+ const spawnBinPathCache = /* @__PURE__ */ new Map();
53
+ const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
48
54
  let _npmCliPromiseSpawn;
55
+ let _path;
56
+ let _fs;
57
+ let _child_process;
58
+ // @__NO_SIDE_EFFECTS__
59
+ function getChildProcess() {
60
+ if (_child_process === void 0) {
61
+ _child_process = require("node:child_process");
62
+ }
63
+ return _child_process;
64
+ }
65
+ // @__NO_SIDE_EFFECTS__
66
+ function getFs() {
67
+ if (_fs === void 0) {
68
+ _fs = require("node:fs");
69
+ }
70
+ return _fs;
71
+ }
49
72
  // @__NO_SIDE_EFFECTS__
50
73
  function getNpmCliPromiseSpawn() {
51
74
  if (_npmCliPromiseSpawn === void 0) {
@@ -53,34 +76,24 @@ function getNpmCliPromiseSpawn() {
53
76
  }
54
77
  return _npmCliPromiseSpawn;
55
78
  }
56
- let _path;
57
79
  // @__NO_SIDE_EFFECTS__
58
80
  function getPath() {
59
81
  if (_path === void 0) {
60
- _path = require("path");
82
+ _path = require("node:path");
61
83
  }
62
84
  return _path;
63
85
  }
64
- let _fs;
65
86
  // @__NO_SIDE_EFFECTS__
66
- function getFs() {
67
- if (_fs === void 0) {
68
- _fs = require("fs");
87
+ function stripAnsiFromSpawnResult(result) {
88
+ const res = result;
89
+ const { stderr, stdout } = res;
90
+ if (typeof stdout === "string") {
91
+ res.stdout = (0, import_strings.stripAnsi)(stdout);
69
92
  }
70
- return _fs;
71
- }
72
- const abortSignal = (0, import_process.getAbortSignal)();
73
- const spinner = (0, import_spinner.getDefaultSpinner)();
74
- const stackCache = /* @__PURE__ */ new WeakMap();
75
- const spawnBinPathCache = /* @__PURE__ */ new Map();
76
- const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
77
- let _child_process;
78
- // @__NO_SIDE_EFFECTS__
79
- function getChildProcess() {
80
- if (_child_process === void 0) {
81
- _child_process = require("child_process");
93
+ if (typeof stderr === "string") {
94
+ res.stderr = (0, import_strings.stripAnsi)(stderr);
82
95
  }
83
- return _child_process;
96
+ return res;
84
97
  }
85
98
  // @__NO_SIDE_EFFECTS__
86
99
  function enhanceSpawnError(error) {
@@ -133,8 +146,8 @@ ${firstLine.slice(0, 197)}...`;
133
146
  cause: err
134
147
  });
135
148
  const descriptors = Object.getOwnPropertyDescriptors(err);
136
- delete descriptors.message;
137
- delete descriptors.stack;
149
+ Reflect.deleteProperty(descriptors, "message");
150
+ Reflect.deleteProperty(descriptors, "stack");
138
151
  Object.defineProperties(enhancedError, descriptors);
139
152
  Object.defineProperty(enhancedError, "stack", {
140
153
  __proto__: null,
@@ -171,18 +184,6 @@ function isStdioType(stdio, type) {
171
184
  }
172
185
  return stdio === type || (stdio === null || stdio === void 0) && type === "pipe" || (0, import_arrays.isArray)(stdio) && stdio.length > 2 && stdio[0] === type && stdio[1] === type && stdio[2] === type;
173
186
  }
174
- // @__NO_SIDE_EFFECTS__
175
- function stripAnsiFromSpawnResult(result) {
176
- const res = result;
177
- const { stderr, stdout } = res;
178
- if (typeof stdout === "string") {
179
- res.stdout = (0, import_strings.stripAnsi)(stdout);
180
- }
181
- if (typeof stderr === "string") {
182
- res.stderr = (0, import_strings.stripAnsi)(stderr);
183
- }
184
- return res;
185
- }
186
187
  function spawn(cmd, args, options, extra) {
187
188
  const {
188
189
  spinner: optionsSpinner = spinner,
@@ -266,9 +267,9 @@ function spawn(cmd, args, options, extra) {
266
267
  });
267
268
  } else {
268
269
  newSpawnPromise = spawnPromise.then((result) => {
269
- if ("code" in result) {
270
+ if (result !== null && typeof result === "object" && "code" in result) {
270
271
  const res = result;
271
- res.exitCode = result.code;
272
+ res.exitCode = res.code;
272
273
  return res;
273
274
  }
274
275
  return result;
package/dist/spinner.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { Writable } from 'stream';
1
+ /**
2
+ * @fileoverview CLI spinner utilities for long-running operations.
3
+ * Provides animated progress indicators with CI environment detection.
4
+ */
5
+ import type { Writable } from 'node:stream';
2
6
  import type { ColorInherit, ColorRgb, ColorValue } from './colors';
3
7
  import type { ShimmerColorGradient, ShimmerConfig, ShimmerDirection, ShimmerState } from './effects/text-shimmer';
4
8
  /**
@@ -208,8 +212,23 @@ export declare const ciSpinner: SpinnerStyle;
208
212
  * const dotsStyle = getCliSpinners('dots')
209
213
  * ```
210
214
  */
211
- /*@__NO_SIDE_EFFECTS__*/
212
215
  export declare function getCliSpinners(styleName?: string | undefined): SpinnerStyle | Record<string, SpinnerStyle> | undefined;
216
+ /**
217
+ * Get the default spinner instance.
218
+ * Lazily creates the spinner to avoid circular dependencies during module initialization.
219
+ * Reuses the same instance across calls.
220
+ *
221
+ * @returns Shared default spinner instance
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * import { getDefaultSpinner } from '@socketsecurity/lib/spinner'
226
+ *
227
+ * const spinner = getDefaultSpinner()
228
+ * spinner.start('Loading…')
229
+ * ```
230
+ */
231
+ export declare function getDefaultSpinner(): ReturnType<typeof Spinner>;
213
232
  /**
214
233
  * Create a spinner instance for displaying loading indicators.
215
234
  * Provides an animated CLI spinner with status messages, progress tracking, and shimmer effects.
@@ -261,27 +280,7 @@ export declare function getCliSpinners(styleName?: string | undefined): SpinnerS
261
280
  * spinner.progressStep() // Increment by 1
262
281
  * ```
263
282
  */
264
- /*@__NO_SIDE_EFFECTS__*/
265
283
  export declare function Spinner(options?: SpinnerOptions | undefined): Spinner;
266
- /**
267
- * Get the default spinner instance.
268
- * Lazily creates the spinner to avoid circular dependencies during module initialization.
269
- * Reuses the same instance across calls.
270
- *
271
- * @returns Shared default spinner instance
272
- *
273
- * @example
274
- * ```ts
275
- * import { getDefaultSpinner } from '@socketsecurity/lib/spinner'
276
- *
277
- * const spinner = getDefaultSpinner()
278
- * spinner.start('Loading…')
279
- * ```
280
- */
281
- export declare function getDefaultSpinner(): ReturnType<typeof Spinner>;
282
- // REMOVED: Deprecated `spinner` export
283
- // Migration: Use getDefaultSpinner() instead
284
- // See: getDefaultSpinner() function above
285
284
  /**
286
285
  * Configuration options for `withSpinner()` helper.
287
286
  * @template T - Return type of the async operation
package/dist/spinner.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -76,8 +77,11 @@ function normalizeText(value) {
76
77
  return typeof value === "string" ? value.trimStart() : "";
77
78
  }
78
79
  function renderProgressBar(percentage, width = 20) {
79
- const filled = Math.round(percentage / 100 * width);
80
- const empty = width - filled;
80
+ const filled = Math.max(
81
+ 0,
82
+ Math.min(width, Math.round(percentage / 100 * width))
83
+ );
84
+ const empty = Math.max(0, width - filled);
81
85
  const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
82
86
  return import_yoctocolors_cjs.default.cyan(bar);
83
87
  }
@@ -101,6 +105,13 @@ function getCliSpinners(styleName) {
101
105
  }
102
106
  let _Spinner;
103
107
  let _defaultSpinner;
108
+ let _spinner;
109
+ function getDefaultSpinner() {
110
+ if (_spinner === void 0) {
111
+ _spinner = /* @__PURE__ */ Spinner();
112
+ }
113
+ return _spinner;
114
+ }
104
115
  // @__NO_SIDE_EFFECTS__
105
116
  function Spinner(options) {
106
117
  if (_Spinner === void 0) {
@@ -119,7 +130,7 @@ function Spinner(options) {
119
130
  let theme = (0, import_context.getTheme)();
120
131
  if (opts.theme) {
121
132
  if (typeof opts.theme === "string") {
122
- theme = import_themes.THEMES[opts.theme];
133
+ theme = import_themes.THEMES[opts.theme] ?? theme;
123
134
  } else {
124
135
  theme = opts.theme;
125
136
  }
@@ -601,7 +612,7 @@ function Spinner(options) {
601
612
  this.#apply("stop", []);
602
613
  const normalized = normalizeText(text);
603
614
  if (normalized) {
604
- logger.error(`${import_logger.LOG_SYMBOLS.skip} ${normalized}`, ...extras);
615
+ logger.error(`${import_logger.LOG_SYMBOLS["skip"]} ${normalized}`, ...extras);
605
616
  }
606
617
  return this;
607
618
  }
@@ -848,13 +859,6 @@ function Spinner(options) {
848
859
  ...options
849
860
  });
850
861
  }
851
- let _spinner;
852
- function getDefaultSpinner() {
853
- if (_spinner === void 0) {
854
- _spinner = /* @__PURE__ */ Spinner();
855
- }
856
- return _spinner;
857
- }
858
862
  async function withSpinner(options) {
859
863
  const { message, operation, spinner, withOptions } = {
860
864
  __proto__: null,
package/dist/ssri.d.ts CHANGED
@@ -2,24 +2,6 @@
2
2
  * @fileoverview SSRI (Subresource Integrity) hash format utilities.
3
3
  * Provides conversion and validation for SSRI and hex hash formats.
4
4
  */
5
- /**
6
- * Convert SSRI format hash to hex format.
7
- *
8
- * Takes a hash in SSRI format (e.g., "sha256-base64hash") and converts it to
9
- * standard hex format (e.g., "hexstring").
10
- *
11
- * @param ssri - Hash in SSRI format (algorithm-base64)
12
- * @returns Hex string representation of the hash
13
- * @throws Error if SSRI format is invalid
14
- *
15
- * @example
16
- * ```typescript
17
- * const hex = ssriToHex('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=')
18
- * // Returns: '76682a9fc3bbe62975176e2541f39a8168877d828d5cad8b56461fc36ac2b856'
19
- * ```
20
- */
21
- /*@__NO_SIDE_EFFECTS__*/
22
- export declare function ssriToHex(ssri: string): string;
23
5
  /**
24
6
  * Convert hex format hash to SSRI format.
25
7
  *
@@ -37,42 +19,39 @@ export declare function ssriToHex(ssri: string): string;
37
19
  * // Returns: 'sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY='
38
20
  * ```
39
21
  */
40
- /*@__NO_SIDE_EFFECTS__*/
41
22
  export declare function hexToSsri(hex: string, algorithm?: string): string;
42
23
  /**
43
- * Check if a string is valid SSRI format.
24
+ * Check if a string is valid hex format.
44
25
  *
45
- * Validates that a string matches the SSRI format pattern (algorithm-base64).
46
- * Does not verify that the base64 encoding is valid.
26
+ * Validates that a string contains only hexadecimal characters (0-9, a-f).
27
+ * Does not verify hash length or algorithm.
47
28
  *
48
29
  * @param value - String to validate
49
- * @returns True if string matches SSRI format
30
+ * @returns True if string is valid hex format
50
31
  *
51
32
  * @example
52
33
  * ```typescript
53
- * isValidSsri('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=') // true
54
- * isValidSsri('76682a9f...') // false
34
+ * isValidHex('76682a9fc3bbe62975176e2541f39a8168877d828d5cad8b56461fc36ac2b856') // true
35
+ * isValidHex('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=') // false
55
36
  * ```
56
37
  */
57
- /*@__NO_SIDE_EFFECTS__*/
58
- export declare function isValidSsri(value: string): boolean;
38
+ export declare function isValidHex(value: string): boolean;
59
39
  /**
60
- * Check if a string is valid hex format.
40
+ * Check if a string is valid SSRI format.
61
41
  *
62
- * Validates that a string contains only hexadecimal characters (0-9, a-f).
63
- * Does not verify hash length or algorithm.
42
+ * Validates that a string matches the SSRI format pattern (algorithm-base64).
43
+ * Does not verify that the base64 encoding is valid.
64
44
  *
65
45
  * @param value - String to validate
66
- * @returns True if string is valid hex format
46
+ * @returns True if string matches SSRI format
67
47
  *
68
48
  * @example
69
49
  * ```typescript
70
- * isValidHex('76682a9fc3bbe62975176e2541f39a8168877d828d5cad8b56461fc36ac2b856') // true
71
- * isValidHex('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=') // false
50
+ * isValidSsri('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=') // true
51
+ * isValidSsri('76682a9f...') // false
72
52
  * ```
73
53
  */
74
- /*@__NO_SIDE_EFFECTS__*/
75
- export declare function isValidHex(value: string): boolean;
54
+ export declare function isValidSsri(value: string): boolean;
76
55
  /**
77
56
  * Parse SSRI format into components.
78
57
  *
@@ -88,8 +67,24 @@ export declare function isValidHex(value: string): boolean;
88
67
  * // Returns: { algorithm: 'sha256', base64Hash: 'dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=' }
89
68
  * ```
90
69
  */
91
- /*@__NO_SIDE_EFFECTS__*/
92
70
  export declare function parseSsri(ssri: string): {
93
71
  algorithm: string;
94
72
  base64Hash: string;
95
73
  };
74
+ /**
75
+ * Convert SSRI format hash to hex format.
76
+ *
77
+ * Takes a hash in SSRI format (e.g., "sha256-base64hash") and converts it to
78
+ * standard hex format (e.g., "hexstring").
79
+ *
80
+ * @param ssri - Hash in SSRI format (algorithm-base64)
81
+ * @returns Hex string representation of the hash
82
+ * @throws Error if SSRI format is invalid
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const hex = ssriToHex('sha256-dmgqn8O75il1F24lQfOagWiHfYKNXK2LVkYfw2rCuFY=')
87
+ * // Returns: '76682a9fc3bbe62975176e2541f39a8168877d828d5cad8b56461fc36ac2b856'
88
+ * ```
89
+ */
90
+ export declare function ssriToHex(ssri: string): string;
package/dist/ssri.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -27,16 +28,6 @@ __export(ssri_exports, {
27
28
  });
28
29
  module.exports = __toCommonJS(ssri_exports);
29
30
  // @__NO_SIDE_EFFECTS__
30
- function ssriToHex(ssri) {
31
- const match = /^([a-z0-9]+)-([A-Za-z0-9+/]+=*)$/i.exec(ssri);
32
- if (!match || !match[2] || match[2].length < 2) {
33
- throw new Error(`Invalid SSRI format: ${ssri}`);
34
- }
35
- const base64Hash = match[2];
36
- const buffer = Buffer.from(base64Hash, "base64");
37
- return buffer.toString("hex");
38
- }
39
- // @__NO_SIDE_EFFECTS__
40
31
  function hexToSsri(hex, algorithm = "sha256") {
41
32
  if (!/^[a-f0-9]+$/i.test(hex)) {
42
33
  throw new Error(`Invalid hex format: ${hex}`);
@@ -46,14 +37,14 @@ function hexToSsri(hex, algorithm = "sha256") {
46
37
  return `${algorithm}-${base64Hash}`;
47
38
  }
48
39
  // @__NO_SIDE_EFFECTS__
49
- function isValidSsri(value) {
50
- return /^[a-z0-9]+-[A-Za-z0-9+/]{2,}=*$/i.test(value);
51
- }
52
- // @__NO_SIDE_EFFECTS__
53
40
  function isValidHex(value) {
54
41
  return /^[a-f0-9]+$/i.test(value);
55
42
  }
56
43
  // @__NO_SIDE_EFFECTS__
44
+ function isValidSsri(value) {
45
+ return /^[a-z0-9]+-[A-Za-z0-9+/]{2,}=*$/i.test(value);
46
+ }
47
+ // @__NO_SIDE_EFFECTS__
57
48
  function parseSsri(ssri) {
58
49
  const match = /^([a-z0-9]+)-([A-Za-z0-9+/]+=*)$/i.exec(ssri);
59
50
  if (!match || !match[1] || !match[2] || match[2].length < 2) {
@@ -63,6 +54,16 @@ function parseSsri(ssri) {
63
54
  const base64Hash = match[2];
64
55
  return { algorithm, base64Hash };
65
56
  }
57
+ // @__NO_SIDE_EFFECTS__
58
+ function ssriToHex(ssri) {
59
+ const match = /^([a-z0-9]+)-([A-Za-z0-9+/]+=*)$/i.exec(ssri);
60
+ if (!match || !match[2] || match[2].length < 2) {
61
+ throw new Error(`Invalid SSRI format: ${ssri}`);
62
+ }
63
+ const base64Hash = match[2];
64
+ const buffer = Buffer.from(base64Hash, "base64");
65
+ return buffer.toString("hex");
66
+ }
66
67
  // Annotate the CommonJS export names for ESM import in node:
67
68
  0 && (module.exports = {
68
69
  hexToSsri,
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview Shared TTY primitives for stdio/stdout.ts + stdio/stderr.ts.
3
+ * @private
4
+ */
5
+ /**
6
+ * Clear the current line on the given stream.
7
+ * Only works in TTY environments.
8
+ * @private
9
+ */
10
+ export declare function clearLineOn(stream: NodeJS.WriteStream): void;
11
+ /**
12
+ * Move cursor to specific position on the given stream.
13
+ * Only works in TTY environments.
14
+ * @private
15
+ */
16
+ export declare function cursorToOn(stream: NodeJS.WriteStream, x: number, y?: number | undefined): void;
17
+ /**
18
+ * Get the number of columns on the given stream (or 80 fallback).
19
+ * @private
20
+ */
21
+ export declare function getColumnsOf(stream: NodeJS.WriteStream): number;
22
+ /**
23
+ * Get the number of rows on the given stream (or 24 fallback).
24
+ * @private
25
+ */
26
+ export declare function getRowsOf(stream: NodeJS.WriteStream): number;
27
+ /**
28
+ * Check if the given stream is connected to a TTY.
29
+ * @private
30
+ */
31
+ export declare function isTTYOf(stream: NodeJS.WriteStream): boolean;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with esbuild */
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var stream_exports = {};
22
+ __export(stream_exports, {
23
+ clearLineOn: () => clearLineOn,
24
+ cursorToOn: () => cursorToOn,
25
+ getColumnsOf: () => getColumnsOf,
26
+ getRowsOf: () => getRowsOf,
27
+ isTTYOf: () => isTTYOf
28
+ });
29
+ module.exports = __toCommonJS(stream_exports);
30
+ function clearLineOn(stream) {
31
+ if (stream.isTTY) {
32
+ stream.cursorTo(0);
33
+ stream.clearLine(0);
34
+ }
35
+ }
36
+ function cursorToOn(stream, x, y) {
37
+ if (stream.isTTY) {
38
+ stream.cursorTo(x, y);
39
+ }
40
+ }
41
+ function getColumnsOf(stream) {
42
+ return stream.columns || 80;
43
+ }
44
+ function getRowsOf(stream) {
45
+ return stream.rows || 24;
46
+ }
47
+ function isTTYOf(stream) {
48
+ return stream.isTTY || false;
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ clearLineOn,
53
+ cursorToOn,
54
+ getColumnsOf,
55
+ getRowsOf,
56
+ isTTYOf
57
+ });
@@ -1,3 +1,26 @@
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
+ * Uses native TTY methods when available and falls back to `\r\x1b[K` ANSI
9
+ * escapes on non-TTY streams.
10
+ *
11
+ * ANSI Sequences:
12
+ * - `\r`: Carriage return (move to line start)
13
+ * - `\x1b[K`: Clear from cursor to end of line
14
+ *
15
+ * @param stream - Output stream to clear (defaults to `process.stdout`)
16
+ * @default stream process.stdout
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * clearLine() // Clear current line on stdout
21
+ * clearLine(process.stderr) // Clear on stderr
22
+ * ```
23
+ */
1
24
  export declare function clearLine(stream?: NodeJS.WriteStream): void;
2
25
  /**
3
26
  * Clear multiple lines above the current cursor position.
@@ -83,23 +106,24 @@ export declare function cursorToStart(stream?: NodeJS.WriteStream): void;
83
106
  */
84
107
  export declare function hideCursor(stream?: NodeJS.WriteStream): void;
85
108
  /**
86
- * Show the terminal cursor.
87
- * Should be called after `hideCursor()` to restore normal cursor visibility.
109
+ * Restore cursor to previously saved position.
110
+ * Must be called after `saveCursor()`.
88
111
  *
89
112
  * ANSI Sequence:
90
- * - `\x1b[?25h`: DECTCEM show cursor
113
+ * - `\x1b8`: DECRC restore cursor
91
114
  *
92
115
  * @param stream - Output stream to manipulate
93
116
  * @default stream process.stdout
94
117
  *
95
118
  * @example
96
119
  * ```ts
97
- * hideCursor()
98
- * // ... show animation
99
- * showCursor()
120
+ * saveCursor()
121
+ * console.log('Temporary text')
122
+ * restoreCursor()
123
+ * console.log('Back at saved position')
100
124
  * ```
101
125
  */
102
- export declare function showCursor(stream?: NodeJS.WriteStream): void;
126
+ export declare function restoreCursor(stream?: NodeJS.WriteStream): void;
103
127
  /**
104
128
  * Save the current cursor position.
105
129
  * Can be restored later with `restoreCursor()`.
@@ -120,21 +144,20 @@ export declare function showCursor(stream?: NodeJS.WriteStream): void;
120
144
  */
121
145
  export declare function saveCursor(stream?: NodeJS.WriteStream): void;
122
146
  /**
123
- * Restore cursor to previously saved position.
124
- * Must be called after `saveCursor()`.
147
+ * Show the terminal cursor.
148
+ * Should be called after `hideCursor()` to restore normal cursor visibility.
125
149
  *
126
150
  * ANSI Sequence:
127
- * - `\x1b8`: DECRC restore cursor
151
+ * - `\x1b[?25h`: DECTCEM show cursor
128
152
  *
129
153
  * @param stream - Output stream to manipulate
130
154
  * @default stream process.stdout
131
155
  *
132
156
  * @example
133
157
  * ```ts
134
- * saveCursor()
135
- * console.log('Temporary text')
136
- * restoreCursor()
137
- * console.log('Back at saved position')
158
+ * hideCursor()
159
+ * // ... show animation
160
+ * showCursor()
138
161
  * ```
139
162
  */
140
- export declare function restoreCursor(stream?: NodeJS.WriteStream): void;
163
+ export declare function showCursor(stream?: NodeJS.WriteStream): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ "use strict";
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -72,14 +73,14 @@ function cursorToStart(stream = import_node_process.default.stdout) {
72
73
  function hideCursor(stream = import_node_process.default.stdout) {
73
74
  stream.write("\x1B[?25l");
74
75
  }
75
- function showCursor(stream = import_node_process.default.stdout) {
76
- stream.write("\x1B[?25h");
76
+ function restoreCursor(stream = import_node_process.default.stdout) {
77
+ stream.write("\x1B8");
77
78
  }
78
79
  function saveCursor(stream = import_node_process.default.stdout) {
79
80
  stream.write("\x1B7");
80
81
  }
81
- function restoreCursor(stream = import_node_process.default.stdout) {
82
- stream.write("\x1B8");
82
+ function showCursor(stream = import_node_process.default.stdout) {
83
+ stream.write("\x1B[?25h");
83
84
  }
84
85
  // Annotate the CommonJS export names for ESM import in node:
85
86
  0 && (module.exports = {