@socketsecurity/lib 5.26.0 → 5.27.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.
Files changed (183) hide show
  1. package/CHANGELOG.md +371 -1185
  2. package/README.md +1 -1
  3. package/dist/abort.js +7 -6
  4. package/dist/agent.js +16 -15
  5. package/dist/ansi.js +3 -2
  6. package/dist/archives.js +18 -17
  7. package/dist/argv/flags.js +29 -28
  8. package/dist/argv/parse.js +4 -3
  9. package/dist/arrays.js +3 -2
  10. package/dist/bin.js +12 -11
  11. package/dist/cacache.js +16 -11
  12. package/dist/cache-with-ttl.js +26 -21
  13. package/dist/colors.js +2 -1
  14. package/dist/constants/licenses.js +2 -1
  15. package/dist/constants/lifecycle-script-names.js +2 -1
  16. package/dist/constants/maintained-node-versions.js +2 -1
  17. package/dist/constants/node.js +4 -3
  18. package/dist/constants/package-default-socket-categories.js +2 -1
  19. package/dist/constants/packages.js +4 -3
  20. package/dist/constants/socket.js +1 -1
  21. package/dist/cover/code.js +9 -8
  22. package/dist/cover/formatters.js +12 -11
  23. package/dist/cover/type.js +5 -4
  24. package/dist/crypto.d.ts +36 -0
  25. package/dist/{effects/ultra.js → crypto.js} +26 -37
  26. package/dist/debug.js +12 -15
  27. package/dist/dlx/arborist.js +10 -9
  28. package/dist/dlx/binary.js +27 -24
  29. package/dist/dlx/cache.js +2 -10
  30. package/dist/dlx/detect.js +6 -5
  31. package/dist/dlx/integrity.js +13 -11
  32. package/dist/dlx/lockfile.js +7 -6
  33. package/dist/dlx/manifest.js +6 -5
  34. package/dist/dlx/package.js +17 -16
  35. package/dist/dlx/packages.js +6 -5
  36. package/dist/dlx/paths.d.ts +1 -1
  37. package/dist/dlx/paths.js +2 -1
  38. package/dist/effects/pulse-frames.js +4 -3
  39. package/dist/effects/shimmer-keyframes.d.ts +62 -0
  40. package/dist/effects/shimmer-keyframes.js +55 -0
  41. package/dist/effects/shimmer-terminal.d.ts +66 -0
  42. package/dist/effects/shimmer-terminal.js +57 -0
  43. package/dist/effects/shimmer.d.ts +293 -0
  44. package/dist/effects/shimmer.js +180 -0
  45. package/dist/env/rewire.js +4 -3
  46. package/dist/env.js +5 -4
  47. package/dist/errors.js +1 -1
  48. package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
  49. package/dist/external/@npmcli/package-json.js +372 -372
  50. package/dist/external/@npmcli/promise-spawn.js +24 -24
  51. package/dist/external/@socketregistry/packageurl-js.js +19 -18
  52. package/dist/external/@socketregistry/yocto-spinner.js +4 -3
  53. package/dist/external/@yarnpkg/extensions.js +2 -1
  54. package/dist/external/adm-zip.js +71 -71
  55. package/dist/external/debug.js +22 -22
  56. package/dist/external/external-pack.js +45 -45
  57. package/dist/external/fast-sort.js +5 -5
  58. package/dist/external/libnpmexec.js +4 -3
  59. package/dist/external/npm-pack.js +369 -369
  60. package/dist/external/p-map.js +9 -9
  61. package/dist/external/pico-pack.js +190 -190
  62. package/dist/external/pony-cause.js +2 -1
  63. package/dist/external/spdx-pack.js +11 -10
  64. package/dist/external/tar-fs.js +58 -58
  65. package/dist/external/which.js +13 -13
  66. package/dist/external/yargs-parser.js +71 -71
  67. package/dist/fs.js +50 -68
  68. package/dist/git.js +14 -13
  69. package/dist/github.d.ts +34 -0
  70. package/dist/github.js +248 -23
  71. package/dist/globs.d.ts +20 -0
  72. package/dist/globs.js +134 -25
  73. package/dist/http-request.d.ts +4 -3
  74. package/dist/http-request.js +39 -32
  75. package/dist/ipc-cli.js +2 -1
  76. package/dist/ipc.js +5 -4
  77. package/dist/json/edit.js +4 -3
  78. package/dist/json/format.js +3 -2
  79. package/dist/json/parse.js +7 -6
  80. package/dist/links.js +2 -1
  81. package/dist/logger.js +21 -14
  82. package/dist/memoization.js +16 -15
  83. package/dist/node/async-hooks.d.ts +6 -0
  84. package/dist/node/async-hooks.js +34 -0
  85. package/dist/node/child-process.d.ts +11 -0
  86. package/dist/node/child-process.js +34 -0
  87. package/dist/node/crypto.d.ts +6 -0
  88. package/dist/node/crypto.js +34 -0
  89. package/dist/node/events.d.ts +6 -0
  90. package/dist/node/events.js +34 -0
  91. package/dist/node/fs-promises.d.ts +6 -0
  92. package/dist/node/fs-promises.js +34 -0
  93. package/dist/node/fs.d.ts +14 -0
  94. package/dist/node/fs.js +34 -0
  95. package/dist/node/http.d.ts +6 -0
  96. package/dist/node/http.js +34 -0
  97. package/dist/node/https.d.ts +6 -0
  98. package/dist/node/https.js +34 -0
  99. package/dist/node/os.d.ts +6 -0
  100. package/dist/node/os.js +34 -0
  101. package/dist/node/path.d.ts +6 -0
  102. package/dist/node/path.js +34 -0
  103. package/dist/node/timers-promises.d.ts +6 -0
  104. package/dist/node/timers-promises.js +34 -0
  105. package/dist/node/url.d.ts +6 -0
  106. package/dist/node/url.js +34 -0
  107. package/dist/node/util.d.ts +6 -0
  108. package/dist/node/util.js +34 -0
  109. package/dist/objects.js +2 -2
  110. package/dist/packages/edit.js +8 -7
  111. package/dist/packages/exports.js +17 -16
  112. package/dist/packages/isolation.js +20 -13
  113. package/dist/packages/licenses.js +6 -3
  114. package/dist/packages/manifest.js +2 -1
  115. package/dist/packages/normalize.js +8 -4
  116. package/dist/packages/operations.js +5 -4
  117. package/dist/packages/provenance.js +7 -6
  118. package/dist/packages/specs.js +2 -1
  119. package/dist/packages/validation.js +2 -1
  120. package/dist/paths/normalize.js +32 -40
  121. package/dist/paths/packages.js +2 -1
  122. package/dist/paths/rewire.js +3 -2
  123. package/dist/performance.js +19 -18
  124. package/dist/primordials.d.ts +85 -2
  125. package/dist/primordials.js +311 -23
  126. package/dist/process-lock.js +14 -13
  127. package/dist/promise-queue.js +17 -9
  128. package/dist/promises.d.ts +29 -6
  129. package/dist/promises.js +19 -15
  130. package/dist/regexps.js +9 -8
  131. package/dist/releases/github-api.d.ts +56 -0
  132. package/dist/releases/github-api.js +275 -0
  133. package/dist/releases/github-archives.d.ts +60 -0
  134. package/dist/releases/github-archives.js +136 -0
  135. package/dist/releases/github-assets.d.ts +21 -0
  136. package/dist/releases/github-assets.js +52 -0
  137. package/dist/releases/github-auth.d.ts +16 -0
  138. package/dist/releases/github-auth.js +51 -0
  139. package/dist/releases/github-downloads.d.ts +42 -0
  140. package/dist/releases/github-downloads.js +155 -0
  141. package/dist/releases/github-types.d.ts +66 -0
  142. package/dist/{effects/types.js → releases/github-types.js} +2 -2
  143. package/dist/releases/socket-btm.d.ts +1 -1
  144. package/dist/releases/socket-btm.js +17 -17
  145. package/dist/schema/parse.js +2 -1
  146. package/dist/schema/validate.js +6 -5
  147. package/dist/sea/util.d.ts +43 -0
  148. package/dist/{sea.js → sea/util.js} +7 -7
  149. package/dist/shadow.js +2 -1
  150. package/dist/signal-exit.js +2 -2
  151. package/dist/smol/primordial.d.ts +80 -0
  152. package/dist/smol/primordial.js +46 -0
  153. package/dist/smol/util.d.ts +87 -0
  154. package/dist/smol/util.js +59 -0
  155. package/dist/smol/versions.d.ts +46 -0
  156. package/dist/smol/versions.js +46 -0
  157. package/dist/spawn.js +58 -63
  158. package/dist/spinner.d.ts +13 -6
  159. package/dist/spinner.js +75 -57
  160. package/dist/ssri.js +8 -7
  161. package/dist/stdio/footer.js +13 -12
  162. package/dist/stdio/header.js +5 -4
  163. package/dist/stdio/progress.js +13 -12
  164. package/dist/strings.js +19 -18
  165. package/dist/suppress-warnings.js +2 -2
  166. package/dist/tables.js +16 -13
  167. package/dist/temporary-executor.js +2 -1
  168. package/dist/themes/context.js +2 -1
  169. package/dist/themes/types.d.ts +1 -1
  170. package/dist/themes/utils.d.ts +8 -3
  171. package/dist/themes/utils.js +29 -5
  172. package/dist/url.js +4 -3
  173. package/dist/versions.js +27 -22
  174. package/package.json +120 -26
  175. package/dist/effects/text-shimmer.d.ts +0 -58
  176. package/dist/effects/text-shimmer.js +0 -192
  177. package/dist/effects/types.d.ts +0 -47
  178. package/dist/effects/ultra.d.ts +0 -22
  179. package/dist/releases/github.d.ts +0 -234
  180. package/dist/releases/github.js +0 -417
  181. package/dist/sea.d.ts +0 -30
  182. package/dist/themes/index.d.ts +0 -49
  183. package/dist/themes/index.js +0 -60
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @fileoverview Smol detection + lazy-loader for `node:smol-util`.
3
+ *
4
+ * Two responsibilities:
5
+ *
6
+ * 1. `isSmol()` — memoized boolean detector for socket-btm's smol
7
+ * Node binary. Mirrors `isSeaBinary()` from `src/sea.ts`. Probes
8
+ * via `node:module.isBuiltin('node:smol-util')` since only the
9
+ * smol binary registers any `node:smol-*` builtins.
10
+ *
11
+ * 2. `getSmolUtil()` — lazy-loader for the `node:smol-util` binding,
12
+ * which provides native `uncurryThis` and `applyBind` (single
13
+ * V8 dispatch via `args.Data()` + `v8::Function::Call`, skipping
14
+ * the BoundFunction adapter + `Function.prototype.call` trampoline
15
+ * that the JS form `bind.bind(call)(fn)` hits twice per invocation).
16
+ * ~2x faster on hot uncurried-call sites.
17
+ *
18
+ * `getSmolUtil()` returns `undefined` on stock Node + non-Node
19
+ * runtimes. Result is cached across calls; the lazy-loader follows
20
+ * the same shape as `src/node/fs.ts` etc.
21
+ *
22
+ * @see https://github.com/SocketDev/socket-btm — socket-btm builds
23
+ * the smol binary that exposes the `node:smol-util` binding.
24
+ */
25
+ /**
26
+ * Detect if the current process is running on socket-btm's smol Node
27
+ * binary. Memoized on first call.
28
+ *
29
+ * Defensive across runtimes: returns `false` on stock Node, browsers
30
+ * (no `node:module`), Deno / Bun (different module resolution), and
31
+ * worker threads (each has its own builtin table).
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { isSmol } from '@socketsecurity/lib/smol/util'
36
+ *
37
+ * if (isSmol()) {
38
+ * // running on the smol binary; native fast paths available
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function isSmol(): boolean;
43
+ /**
44
+ * Surface of `node:smol-util`. See socket-btm's
45
+ * additions/source-patched/lib/smol-util.js for the canonical shape.
46
+ */
47
+ export interface SmolUtilBinding {
48
+ /**
49
+ * Native equivalent of `Function.prototype.bind.bind(apply)(fn)`.
50
+ */
51
+ applyBind: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R;
52
+ /**
53
+ * Native equivalent of:
54
+ * `(self, args) => { try { return fn.apply(self, args) } catch {} }`.
55
+ * Returns a function that swallows synchronous throws and returns
56
+ * `undefined`. Avoids JS-level throw construction on the swallow
57
+ * path — useful for logger sinks, debug hooks, abort handlers, etc.
58
+ */
59
+ applySafe: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, args: A) => R | undefined;
60
+ /**
61
+ * Native equivalent of:
62
+ * `(...newArgs) => fn.call(thisArg, ...presetArgs, ...newArgs)`.
63
+ * Same shape as `Function.prototype.bind` but with a single C++
64
+ * dispatch instead of going through V8's BoundFunction adapter.
65
+ * Useful where `bind` would be hot — captured callbacks fed to
66
+ * `setImmediate`/`setTimeout`/promise continuations.
67
+ */
68
+ bindCall: <T, P extends readonly unknown[], A extends readonly unknown[], R>(fn: (this: T, ...args: [...P, ...A]) => R, thisArg: T, ...presetArgs: P) => (...newArgs: A) => R;
69
+ /**
70
+ * Native equivalent of `Function.prototype.bind.bind(call)(fn)`.
71
+ * Single C++ dispatch via `args.Data()` + `v8::Function::Call`.
72
+ */
73
+ uncurryThis: <T, A extends readonly unknown[], R>(fn: (this: T, ...args: A) => R) => (self: T, ...args: A) => R;
74
+ /**
75
+ * Native equivalent of:
76
+ * `try { return new WeakRef(target) } catch { return undefined }`.
77
+ * Returns `undefined` for non-Object, non-Symbol inputs that would
78
+ * make the constructor throw. The Safe suffix follows the project's
79
+ * non-throwing-wrapper convention.
80
+ */
81
+ weakRefSafe: <T extends object | symbol>(target: T) => WeakRef<T> | undefined;
82
+ }
83
+ /**
84
+ * Returns `node:smol-util` when running on the smol Node binary,
85
+ * otherwise `undefined`. Result is cached across calls.
86
+ */
87
+ export declare function getSmolUtil(): SmolUtilBinding | undefined;
@@ -0,0 +1,59 @@
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 util_exports = {};
22
+ __export(util_exports, {
23
+ getSmolUtil: () => getSmolUtil,
24
+ isSmol: () => isSmol
25
+ });
26
+ module.exports = __toCommonJS(util_exports);
27
+ let _isSmol;
28
+ function isSmol() {
29
+ if (_isSmol === void 0) {
30
+ try {
31
+ const mod = require("node:module");
32
+ _isSmol = typeof mod.isBuiltin === "function" && mod.isBuiltin("node:smol-util");
33
+ } catch {
34
+ _isSmol = false;
35
+ }
36
+ }
37
+ return _isSmol ?? false;
38
+ }
39
+ let _smolUtil;
40
+ // @__NO_SIDE_EFFECTS__
41
+ function getSmolUtil() {
42
+ if (_smolUtil === void 0) {
43
+ if (isSmol()) {
44
+ try {
45
+ _smolUtil = require("node:smol-util");
46
+ } catch {
47
+ _smolUtil = null;
48
+ }
49
+ } else {
50
+ _smolUtil = null;
51
+ }
52
+ }
53
+ return _smolUtil ?? void 0;
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ getSmolUtil,
58
+ isSmol
59
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @fileoverview Lazy-loader for socket-btm's `node:smol-versions`.
3
+ *
4
+ * `node:smol-versions` is the multi-ecosystem version helper exposed
5
+ * by socket-btm's smol Node binary. It supports npm/maven/pypi/nuget/
6
+ * gem version comparison + range satisfies with internal C++
7
+ * acceleration on the npm hot path.
8
+ *
9
+ * Returns `undefined` on stock Node + non-Node runtimes. Result is
10
+ * cached across calls.
11
+ *
12
+ * @internal — used by `src/versions.ts` to resolve smol-aware version
13
+ * ops. Most callers should use the standard `versions` exports,
14
+ * which already route through this when smol is present.
15
+ */
16
+ /**
17
+ * Surface of `node:smol-versions`. See socket-btm's
18
+ * additions/source-patched/lib/smol-versions.js for the canonical
19
+ * shape. Each entry takes an optional `ecosystem` (default `'npm'`)
20
+ * — pass it for non-npm versions; npm callers can omit.
21
+ */
22
+ export interface SmolVersionsBinding {
23
+ compare(a: string, b: string, ecosystem?: string): -1 | 0 | 1;
24
+ eq(a: string, b: string, ecosystem?: string): boolean;
25
+ gt(a: string, b: string, ecosystem?: string): boolean;
26
+ gte(a: string, b: string, ecosystem?: string): boolean;
27
+ inc(version: string, release: 'major' | 'minor' | 'patch' | 'prerelease', ecosystem?: string, identifier?: string): string | undefined;
28
+ lt(a: string, b: string, ecosystem?: string): boolean;
29
+ lte(a: string, b: string, ecosystem?: string): boolean;
30
+ max(versions: readonly string[], ecosystem?: string): string | undefined;
31
+ maxSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
32
+ min(versions: readonly string[], ecosystem?: string): string | undefined;
33
+ minSatisfying(versions: readonly string[], range: string, ecosystem?: string): string | undefined;
34
+ neq(a: string, b: string, ecosystem?: string): boolean;
35
+ rsort(versions: readonly string[], ecosystem?: string): string[];
36
+ satisfies(version: string, range: string, ecosystem?: string): boolean;
37
+ sort(versions: readonly string[], ecosystem?: string): string[];
38
+ valid(version: string, ecosystem?: string): string | undefined;
39
+ filter(versions: readonly string[], range: string, ecosystem?: string): string[];
40
+ coerce(version: string, ecosystem?: string): string | undefined;
41
+ }
42
+ /**
43
+ * Returns `node:smol-versions` when running on the smol Node binary,
44
+ * otherwise `undefined`. Result is cached across calls.
45
+ */
46
+ export declare function getSmolVersions(): SmolVersionsBinding | undefined;
@@ -0,0 +1,46 @@
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 versions_exports = {};
22
+ __export(versions_exports, {
23
+ getSmolVersions: () => getSmolVersions
24
+ });
25
+ module.exports = __toCommonJS(versions_exports);
26
+ var import_util = require("./util");
27
+ let _smolVersions;
28
+ // @__NO_SIDE_EFFECTS__
29
+ function getSmolVersions() {
30
+ if (_smolVersions === void 0) {
31
+ if ((0, import_util.isSmol)()) {
32
+ try {
33
+ _smolVersions = require("node:smol-versions");
34
+ } catch {
35
+ _smolVersions = null;
36
+ }
37
+ } else {
38
+ _smolVersions = null;
39
+ }
40
+ }
41
+ return _smolVersions ?? void 0;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ getSmolVersions
46
+ });
package/dist/spawn.js CHANGED
@@ -42,33 +42,20 @@ var import_arrays = require("./arrays");
42
42
  var import_bin = require("./bin");
43
43
  var import_process = require("./constants/process");
44
44
  var import_errors = require("./errors");
45
+ var import_child_process = require("./node/child-process");
46
+ var import_fs = require("./node/fs");
47
+ var import_path = require("./node/path");
45
48
  var import_objects = require("./objects");
46
49
  var import_normalize = require("./paths/normalize");
47
50
  var import_spinner = require("./spinner");
48
51
  var import_strings = require("./strings");
52
+ var import_primordials = require("./primordials");
49
53
  const abortSignal = (0, import_process.getAbortSignal)();
50
54
  const spinner = (0, import_spinner.getDefaultSpinner)();
51
- const stackCache = /* @__PURE__ */ new WeakMap();
52
- const spawnBinPathCache = /* @__PURE__ */ new Map();
55
+ const stackCache = new import_primordials.WeakMapCtor();
56
+ const spawnBinPathCache = new import_primordials.MapCtor();
53
57
  const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i;
54
58
  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
- }
72
59
  // @__NO_SIDE_EFFECTS__
73
60
  function getNpmCliPromiseSpawn() {
74
61
  if (_npmCliPromiseSpawn === void 0) {
@@ -77,13 +64,6 @@ function getNpmCliPromiseSpawn() {
77
64
  return _npmCliPromiseSpawn;
78
65
  }
79
66
  // @__NO_SIDE_EFFECTS__
80
- function getPath() {
81
- if (_path === void 0) {
82
- _path = require("node:path");
83
- }
84
- return _path;
85
- }
86
- // @__NO_SIDE_EFFECTS__
87
67
  function stripAnsiFromSpawnResult(result) {
88
68
  const res = result;
89
69
  const { stderr, stdout } = res;
@@ -133,7 +113,7 @@ ${firstLine.slice(0, 197)}...`;
133
113
  }
134
114
  const isSynthetic = err.message === "command failed";
135
115
  if (isSynthetic) {
136
- Object.defineProperty(err, "message", {
116
+ (0, import_primordials.ObjectDefineProperty)(err, "message", {
137
117
  __proto__: null,
138
118
  value: enhancedMessage,
139
119
  writable: true,
@@ -142,14 +122,14 @@ ${firstLine.slice(0, 197)}...`;
142
122
  });
143
123
  return err;
144
124
  }
145
- const enhancedError = new Error(enhancedMessage, {
125
+ const enhancedError = new import_primordials.ErrorCtor(enhancedMessage, {
146
126
  cause: err
147
127
  });
148
- const descriptors = Object.getOwnPropertyDescriptors(err);
149
- Reflect.deleteProperty(descriptors, "message");
150
- Reflect.deleteProperty(descriptors, "stack");
151
- Object.defineProperties(enhancedError, descriptors);
152
- Object.defineProperty(enhancedError, "stack", {
128
+ const descriptors = (0, import_primordials.ObjectGetOwnPropertyDescriptors)(err);
129
+ (0, import_primordials.ReflectDeleteProperty)(descriptors, "message");
130
+ (0, import_primordials.ReflectDeleteProperty)(descriptors, "stack");
131
+ (0, import_primordials.ObjectDefineProperties)(enhancedError, descriptors);
132
+ (0, import_primordials.ObjectDefineProperty)(enhancedError, "stack", {
153
133
  __proto__: null,
154
134
  configurable: true,
155
135
  enumerable: false,
@@ -196,7 +176,7 @@ function spawn(cmd, args, options, extra) {
196
176
  const cwd = spawnOptions.cwd ? String(spawnOptions.cwd) : void 0;
197
177
  let actualCmd = cmd;
198
178
  if (!(0, import_normalize.isPath)(cmd)) {
199
- const fs = /* @__PURE__ */ getFs();
179
+ const fs = (0, import_fs.getNodeFs)();
200
180
  const cached = spawnBinPathCache.get(cmd);
201
181
  if (cached) {
202
182
  if (fs.existsSync(cached)) {
@@ -214,9 +194,12 @@ function spawn(cmd, args, options, extra) {
214
194
  }
215
195
  }
216
196
  const WIN32 = import_node_process.default.platform === "win32";
217
- if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
197
+ if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
218
198
  if (!(0, import_normalize.isPath)(actualCmd)) {
219
- actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
199
+ actualCmd = (0, import_path.getNodePath)().basename(
200
+ actualCmd,
201
+ (0, import_path.getNodePath)().extname(actualCmd)
202
+ );
220
203
  }
221
204
  }
222
205
  const wasSpinning = !!spinnerInstance?.isSpinning;
@@ -253,35 +236,44 @@ function spawn(cmd, args, options, extra) {
253
236
  const oldSpawnPromise = spawnPromise;
254
237
  let newSpawnPromise;
255
238
  if (shouldStripAnsi && stdioString) {
256
- newSpawnPromise = spawnPromise.then((result) => {
257
- const strippedResult = /* @__PURE__ */ stripAnsiFromSpawnResult(result);
258
- if ("code" in strippedResult) {
259
- ;
260
- strippedResult.exitCode = strippedResult.code;
239
+ newSpawnPromise = (async () => {
240
+ try {
241
+ const result = await spawnPromise;
242
+ const strippedResult = /* @__PURE__ */ stripAnsiFromSpawnResult(result);
243
+ if ("code" in strippedResult) {
244
+ ;
245
+ strippedResult.exitCode = strippedResult.code;
246
+ }
247
+ return strippedResult;
248
+ } catch (error) {
249
+ const strippedError = /* @__PURE__ */ stripAnsiFromSpawnResult(error);
250
+ throw /* @__PURE__ */ enhanceSpawnError(strippedError);
261
251
  }
262
- return strippedResult;
263
- }).catch((error) => {
264
- const strippedError = /* @__PURE__ */ stripAnsiFromSpawnResult(error);
265
- const enhancedError = /* @__PURE__ */ enhanceSpawnError(strippedError);
266
- throw enhancedError;
267
- });
252
+ })();
268
253
  } else {
269
- newSpawnPromise = spawnPromise.then((result) => {
270
- if (result !== null && typeof result === "object" && "code" in result) {
271
- const res = result;
272
- res.exitCode = res.code;
273
- return res;
254
+ newSpawnPromise = (async () => {
255
+ try {
256
+ const result = await spawnPromise;
257
+ if (result !== null && typeof result === "object" && "code" in result) {
258
+ const res = result;
259
+ res.exitCode = res.code;
260
+ return res;
261
+ }
262
+ return result;
263
+ } catch (error) {
264
+ throw /* @__PURE__ */ enhanceSpawnError(error);
274
265
  }
275
- return result;
276
- }).catch((error) => {
277
- const enhancedError = /* @__PURE__ */ enhanceSpawnError(error);
278
- throw enhancedError;
279
- });
266
+ })();
280
267
  }
281
268
  if (shouldRestartSpinner) {
282
- newSpawnPromise = newSpawnPromise.finally(() => {
283
- spinnerInstance.start();
284
- });
269
+ const prevPromise = newSpawnPromise;
270
+ newSpawnPromise = (async () => {
271
+ try {
272
+ return await prevPromise;
273
+ } finally {
274
+ spinnerInstance.start();
275
+ }
276
+ })();
285
277
  }
286
278
  ;
287
279
  newSpawnPromise.process = oldSpawnPromise.process;
@@ -301,9 +293,12 @@ function spawnSync(cmd, args, options) {
301
293
  }
302
294
  const shell = (0, import_objects.getOwn)(options, "shell");
303
295
  const WIN32 = import_node_process.default.platform === "win32";
304
- if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {
296
+ if (WIN32 && shell && (0, import_primordials.RegExpPrototypeTest)(windowsScriptExtRegExp, actualCmd)) {
305
297
  if (!(0, import_normalize.isPath)(actualCmd)) {
306
- actualCmd = (/* @__PURE__ */ getPath()).basename(actualCmd, (/* @__PURE__ */ getPath()).extname(actualCmd));
298
+ actualCmd = (0, import_path.getNodePath)().basename(
299
+ actualCmd,
300
+ (0, import_path.getNodePath)().extname(actualCmd)
301
+ );
307
302
  }
308
303
  }
309
304
  const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
@@ -317,7 +312,7 @@ function spawnSync(cmd, args, options) {
317
312
  ...rawSpawnOptions
318
313
  };
319
314
  const stdioString = spawnOptions.encoding !== "buffer";
320
- const result = (/* @__PURE__ */ getChildProcess()).spawnSync(actualCmd, args, spawnOptions);
315
+ const result = (0, import_child_process.getNodeChildProcess)().spawnSync(actualCmd, args, spawnOptions);
321
316
  if (stdioString) {
322
317
  const { stderr, stdout } = result;
323
318
  if (stdout) {
package/dist/spinner.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { Writable } from 'node:stream';
6
6
  import type { ColorInherit, ColorRgb, ColorValue } from './colors';
7
- import type { ShimmerColorGradient, ShimmerConfig, ShimmerDirection, ShimmerState } from './effects/text-shimmer';
7
+ import type { Palette, ShimmerConfig, ShimmerDirection } from './effects/shimmer';
8
8
  /**
9
9
  * Symbol types for status messages.
10
10
  * Maps to log symbols: fail (✗), info (ℹ), skip (↻), success (✓), warn (⚠).
@@ -23,12 +23,19 @@ export type ProgressInfo = {
23
23
  unit?: string | undefined;
24
24
  };
25
25
  /**
26
- * Internal shimmer state with color configuration.
27
- * Extends `ShimmerState` with additional color property that can be inherited from spinner.
26
+ * Internal shimmer runtime state. Holds the user-facing config plus a
27
+ * monotonic frame counter; the spinner advances `frame` on each animation
28
+ * tick and feeds the current frame to the shimmer engine.
28
29
  */
29
- export type ShimmerInfo = ShimmerState & {
30
- /** Color for shimmer effect - can inherit from spinner, use explicit color, or gradient */
31
- color: ColorInherit | ColorValue | ShimmerColorGradient;
30
+ export type ShimmerInfo = {
31
+ /** User-facing color reference (inherit, explicit value, or palette). */
32
+ color: ColorInherit | ColorValue | Palette;
33
+ /** Current direction (driven by config, snapshotted here for getters). */
34
+ direction: ShimmerDirection;
35
+ /** Steps per frame. */
36
+ speed: number;
37
+ /** Monotonic frame counter — advanced on each animation tick. */
38
+ frame: number;
32
39
  };
33
40
  /**
34
41
  * Spinner instance for displaying animated loading indicators.