@socketsecurity/lib 1.3.1 → 1.3.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 (337) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/abort.js +1 -60
  3. package/dist/abort.js.map +2 -2
  4. package/dist/agent.js +1 -289
  5. package/dist/agent.js.map +2 -2
  6. package/dist/ansi.js +1 -60
  7. package/dist/ansi.js.map +2 -2
  8. package/dist/argv/flags.js +1 -282
  9. package/dist/argv/flags.js.map +2 -2
  10. package/dist/argv/parse.js +1 -171
  11. package/dist/argv/parse.js.map +2 -2
  12. package/dist/arrays.js +1 -85
  13. package/dist/arrays.js.map +2 -2
  14. package/dist/bin.js +1 -402
  15. package/dist/bin.js.map +2 -2
  16. package/dist/cacache.js +1 -137
  17. package/dist/cacache.js.map +2 -2
  18. package/dist/cache-with-ttl.js +1 -223
  19. package/dist/cache-with-ttl.js.map +2 -2
  20. package/dist/constants/agents.js +1 -126
  21. package/dist/constants/agents.js.map +2 -2
  22. package/dist/constants/core.js +2 -57
  23. package/dist/constants/core.js.map +2 -2
  24. package/dist/constants/encoding.js +1 -48
  25. package/dist/constants/encoding.js.map +2 -2
  26. package/dist/constants/github.js +1 -30
  27. package/dist/constants/github.js.map +2 -2
  28. package/dist/constants/licenses.js +1 -66
  29. package/dist/constants/licenses.js.map +2 -2
  30. package/dist/constants/node.js +1 -171
  31. package/dist/constants/node.js.map +2 -2
  32. package/dist/constants/packages.js +1 -128
  33. package/dist/constants/packages.js.map +2 -2
  34. package/dist/constants/paths.js +1 -150
  35. package/dist/constants/paths.js.map +2 -2
  36. package/dist/constants/platform.js +1 -41
  37. package/dist/constants/platform.js.map +2 -2
  38. package/dist/constants/process.js +1 -52
  39. package/dist/constants/process.js.map +2 -2
  40. package/dist/constants/socket.js +1 -81
  41. package/dist/constants/socket.js.map +2 -2
  42. package/dist/constants/testing.js +1 -36
  43. package/dist/constants/testing.js.map +2 -2
  44. package/dist/constants/time.js +1 -39
  45. package/dist/constants/time.js.map +2 -2
  46. package/dist/constants/typescript.js +1 -54
  47. package/dist/constants/typescript.js.map +2 -2
  48. package/dist/cover/code.js +1 -135
  49. package/dist/cover/code.js.map +2 -2
  50. package/dist/cover/formatters.js +11 -101
  51. package/dist/cover/formatters.js.map +2 -2
  52. package/dist/cover/type.js +1 -63
  53. package/dist/cover/type.js.map +2 -2
  54. package/dist/cover/types.js +1 -15
  55. package/dist/cover/types.js.map +2 -2
  56. package/dist/debug.js +2 -343
  57. package/dist/debug.js.map +2 -2
  58. package/dist/dlx-binary.js +1 -259
  59. package/dist/dlx-binary.js.map +2 -2
  60. package/dist/dlx-package.js +1 -149
  61. package/dist/dlx-package.js.map +2 -2
  62. package/dist/dlx.js +1 -166
  63. package/dist/dlx.js.map +2 -2
  64. package/dist/download-lock.js +1 -137
  65. package/dist/download-lock.js.map +2 -2
  66. package/dist/effects/pulse-frames.js +1 -64
  67. package/dist/effects/pulse-frames.js.map +2 -2
  68. package/dist/effects/text-shimmer.js +1 -174
  69. package/dist/effects/text-shimmer.js.map +2 -2
  70. package/dist/effects/types.js +1 -15
  71. package/dist/effects/types.js.map +2 -2
  72. package/dist/effects/ultra.js +1 -61
  73. package/dist/effects/ultra.js.map +2 -2
  74. package/dist/env/appdata.js +1 -28
  75. package/dist/env/appdata.js.map +2 -2
  76. package/dist/env/ci.js +1 -29
  77. package/dist/env/ci.js.map +2 -2
  78. package/dist/env/comspec.js +1 -28
  79. package/dist/env/comspec.js.map +2 -2
  80. package/dist/env/debug.js +1 -28
  81. package/dist/env/debug.js.map +2 -2
  82. package/dist/env/getters.js +1 -281
  83. package/dist/env/getters.js.map +2 -2
  84. package/dist/env/github-api-url.js +1 -28
  85. package/dist/env/github-api-url.js.map +2 -2
  86. package/dist/env/github-base-ref.js +1 -28
  87. package/dist/env/github-base-ref.js.map +2 -2
  88. package/dist/env/github-ref-name.js +1 -28
  89. package/dist/env/github-ref-name.js.map +2 -2
  90. package/dist/env/github-ref-type.js +1 -28
  91. package/dist/env/github-ref-type.js.map +2 -2
  92. package/dist/env/github-repository.js +1 -28
  93. package/dist/env/github-repository.js.map +2 -2
  94. package/dist/env/github-server-url.js +1 -28
  95. package/dist/env/github-server-url.js.map +2 -2
  96. package/dist/env/github-token.js +1 -28
  97. package/dist/env/github-token.js.map +2 -2
  98. package/dist/env/helpers.js +1 -47
  99. package/dist/env/helpers.js.map +2 -2
  100. package/dist/env/home.js +1 -28
  101. package/dist/env/home.js.map +2 -2
  102. package/dist/env/jest-worker-id.js +1 -28
  103. package/dist/env/jest-worker-id.js.map +2 -2
  104. package/dist/env/lang.js +1 -28
  105. package/dist/env/lang.js.map +2 -2
  106. package/dist/env/lc-all.js +1 -28
  107. package/dist/env/lc-all.js.map +2 -2
  108. package/dist/env/lc-messages.js +1 -28
  109. package/dist/env/lc-messages.js.map +2 -2
  110. package/dist/env/localappdata.js +1 -28
  111. package/dist/env/localappdata.js.map +2 -2
  112. package/dist/env/node-auth-token.js +1 -28
  113. package/dist/env/node-auth-token.js.map +2 -2
  114. package/dist/env/node-env.js +1 -28
  115. package/dist/env/node-env.js.map +2 -2
  116. package/dist/env/npm-config-registry.js +1 -28
  117. package/dist/env/npm-config-registry.js.map +2 -2
  118. package/dist/env/npm-config-user-agent.js +1 -28
  119. package/dist/env/npm-config-user-agent.js.map +2 -2
  120. package/dist/env/npm-lifecycle-event.js +1 -28
  121. package/dist/env/npm-lifecycle-event.js.map +2 -2
  122. package/dist/env/npm-registry.js +1 -28
  123. package/dist/env/npm-registry.js.map +2 -2
  124. package/dist/env/npm-token.js +1 -28
  125. package/dist/env/npm-token.js.map +2 -2
  126. package/dist/env/path.js +1 -28
  127. package/dist/env/path.js.map +2 -2
  128. package/dist/env/pre-commit.js +1 -29
  129. package/dist/env/pre-commit.js.map +2 -2
  130. package/dist/env/shell.js +1 -28
  131. package/dist/env/shell.js.map +2 -2
  132. package/dist/env/socket-accept-risks.js +1 -29
  133. package/dist/env/socket-accept-risks.js.map +2 -2
  134. package/dist/env/socket-api-base-url.js +1 -28
  135. package/dist/env/socket-api-base-url.js.map +2 -2
  136. package/dist/env/socket-api-proxy.js +1 -28
  137. package/dist/env/socket-api-proxy.js.map +2 -2
  138. package/dist/env/socket-api-timeout.js +1 -29
  139. package/dist/env/socket-api-timeout.js.map +2 -2
  140. package/dist/env/socket-api-token.js +1 -28
  141. package/dist/env/socket-api-token.js.map +2 -2
  142. package/dist/env/socket-cacache-dir.js +1 -28
  143. package/dist/env/socket-cacache-dir.js.map +2 -2
  144. package/dist/env/socket-cli-accept-risks.js +1 -31
  145. package/dist/env/socket-cli-accept-risks.js.map +2 -2
  146. package/dist/env/socket-cli-api-base-url.js +1 -28
  147. package/dist/env/socket-cli-api-base-url.js.map +2 -2
  148. package/dist/env/socket-cli-api-proxy.js +1 -28
  149. package/dist/env/socket-cli-api-proxy.js.map +2 -2
  150. package/dist/env/socket-cli-api-timeout.js +1 -29
  151. package/dist/env/socket-cli-api-timeout.js.map +2 -2
  152. package/dist/env/socket-cli-api-token.js +1 -28
  153. package/dist/env/socket-cli-api-token.js.map +2 -2
  154. package/dist/env/socket-cli-config.js +1 -28
  155. package/dist/env/socket-cli-config.js.map +2 -2
  156. package/dist/env/socket-cli-fix.js +1 -28
  157. package/dist/env/socket-cli-fix.js.map +2 -2
  158. package/dist/env/socket-cli-no-api-token.js +1 -31
  159. package/dist/env/socket-cli-no-api-token.js.map +2 -2
  160. package/dist/env/socket-cli-optimize.js +1 -29
  161. package/dist/env/socket-cli-optimize.js.map +2 -2
  162. package/dist/env/socket-cli-org-slug.js +1 -28
  163. package/dist/env/socket-cli-org-slug.js.map +2 -2
  164. package/dist/env/socket-cli-shadow-accept-risks.js +1 -31
  165. package/dist/env/socket-cli-shadow-accept-risks.js.map +2 -2
  166. package/dist/env/socket-cli-shadow-api-token.js +1 -28
  167. package/dist/env/socket-cli-shadow-api-token.js.map +2 -2
  168. package/dist/env/socket-cli-shadow-bin.js +1 -28
  169. package/dist/env/socket-cli-shadow-bin.js.map +2 -2
  170. package/dist/env/socket-cli-shadow-progress.js +1 -31
  171. package/dist/env/socket-cli-shadow-progress.js.map +2 -2
  172. package/dist/env/socket-cli-shadow-silent.js +1 -31
  173. package/dist/env/socket-cli-shadow-silent.js.map +2 -2
  174. package/dist/env/socket-cli-view-all-risks.js +1 -31
  175. package/dist/env/socket-cli-view-all-risks.js.map +2 -2
  176. package/dist/env/socket-config.js +1 -28
  177. package/dist/env/socket-config.js.map +2 -2
  178. package/dist/env/socket-debug.js +1 -28
  179. package/dist/env/socket-debug.js.map +2 -2
  180. package/dist/env/socket-home.js +1 -28
  181. package/dist/env/socket-home.js.map +2 -2
  182. package/dist/env/socket-no-api-token.js +1 -29
  183. package/dist/env/socket-no-api-token.js.map +2 -2
  184. package/dist/env/socket-npm-registry.js +1 -28
  185. package/dist/env/socket-npm-registry.js.map +2 -2
  186. package/dist/env/socket-org-slug.js +1 -28
  187. package/dist/env/socket-org-slug.js.map +2 -2
  188. package/dist/env/socket-registry-url.js +1 -28
  189. package/dist/env/socket-registry-url.js.map +2 -2
  190. package/dist/env/socket-view-all-risks.js +1 -29
  191. package/dist/env/socket-view-all-risks.js.map +2 -2
  192. package/dist/env/temp.js +1 -28
  193. package/dist/env/temp.js.map +2 -2
  194. package/dist/env/term.js +1 -28
  195. package/dist/env/term.js.map +2 -2
  196. package/dist/env/tmp.js +1 -28
  197. package/dist/env/tmp.js.map +2 -2
  198. package/dist/env/tmpdir.js +1 -28
  199. package/dist/env/tmpdir.js.map +2 -2
  200. package/dist/env/userprofile.js +1 -28
  201. package/dist/env/userprofile.js.map +2 -2
  202. package/dist/env/vitest.js +1 -29
  203. package/dist/env/vitest.js.map +2 -2
  204. package/dist/env/xdg-cache-home.js +1 -28
  205. package/dist/env/xdg-cache-home.js.map +2 -2
  206. package/dist/env/xdg-config-home.js +1 -28
  207. package/dist/env/xdg-config-home.js.map +2 -2
  208. package/dist/env/xdg-data-home.js +1 -28
  209. package/dist/env/xdg-data-home.js.map +2 -2
  210. package/dist/env.js +1 -61
  211. package/dist/env.js.map +2 -2
  212. package/dist/fs.js +3 -626
  213. package/dist/fs.js.map +2 -2
  214. package/dist/functions.js +1 -68
  215. package/dist/functions.js.map +2 -2
  216. package/dist/git.js +2 -320
  217. package/dist/git.js.map +2 -2
  218. package/dist/github.js +1 -201
  219. package/dist/github.js.map +2 -2
  220. package/dist/globs.js +1 -152
  221. package/dist/globs.js.map +2 -2
  222. package/dist/http-request.js +1 -313
  223. package/dist/http-request.js.map +2 -2
  224. package/dist/index.js +1 -62
  225. package/dist/index.js.map +2 -2
  226. package/dist/ipc.js +1 -232
  227. package/dist/ipc.js.map +2 -2
  228. package/dist/json.js +1 -73
  229. package/dist/json.js.map +2 -2
  230. package/dist/logger.js +1 -1254
  231. package/dist/logger.js.map +2 -2
  232. package/dist/maintained-node-versions.js +1 -35
  233. package/dist/maintained-node-versions.js.map +2 -2
  234. package/dist/memoization.js +1 -210
  235. package/dist/memoization.js.map +2 -2
  236. package/dist/objects.d.ts +0 -3
  237. package/dist/objects.js +1 -319
  238. package/dist/objects.js.map +3 -3
  239. package/dist/packages/editable.js +9 -356
  240. package/dist/packages/editable.js.map +2 -2
  241. package/dist/packages/exports.js +1 -162
  242. package/dist/packages/exports.js.map +2 -2
  243. package/dist/packages/isolation.js +1 -195
  244. package/dist/packages/isolation.js.map +2 -2
  245. package/dist/packages/licenses.js +1 -214
  246. package/dist/packages/licenses.js.map +2 -2
  247. package/dist/packages/manifest.js +1 -190
  248. package/dist/packages/manifest.js.map +2 -2
  249. package/dist/packages/normalize.js +1 -120
  250. package/dist/packages/normalize.js.map +2 -2
  251. package/dist/packages/operations.js +1 -304
  252. package/dist/packages/operations.js.map +2 -2
  253. package/dist/packages/paths.js +1 -53
  254. package/dist/packages/paths.js.map +2 -2
  255. package/dist/packages/provenance.js +1 -178
  256. package/dist/packages/provenance.js.map +2 -2
  257. package/dist/packages/registry.js +1 -28
  258. package/dist/packages/registry.js.map +2 -2
  259. package/dist/packages/specs.js +1 -83
  260. package/dist/packages/specs.js.map +2 -2
  261. package/dist/packages/validation.js +1 -51
  262. package/dist/packages/validation.js.map +2 -2
  263. package/dist/packages.js +1 -129
  264. package/dist/packages.js.map +2 -2
  265. package/dist/path.js +1 -448
  266. package/dist/path.js.map +2 -2
  267. package/dist/paths.js +1 -143
  268. package/dist/paths.js.map +2 -2
  269. package/dist/performance.js +15 -216
  270. package/dist/performance.js.map +2 -2
  271. package/dist/promise-queue.js +1 -109
  272. package/dist/promise-queue.js.map +2 -2
  273. package/dist/promises.js +1 -269
  274. package/dist/promises.js.map +2 -2
  275. package/dist/prompts.js +1 -58
  276. package/dist/prompts.js.map +2 -2
  277. package/dist/regexps.js +1 -30
  278. package/dist/regexps.js.map +2 -2
  279. package/dist/sea.js +1 -44
  280. package/dist/sea.js.map +2 -2
  281. package/dist/shadow.js +1 -58
  282. package/dist/shadow.js.map +2 -2
  283. package/dist/signal-exit.js +1 -248
  284. package/dist/signal-exit.js.map +2 -2
  285. package/dist/sorts.js +1 -94
  286. package/dist/sorts.js.map +2 -2
  287. package/dist/spawn.js +1 -199
  288. package/dist/spawn.js.map +2 -2
  289. package/dist/spinner.js +1 -865
  290. package/dist/spinner.js.map +2 -2
  291. package/dist/ssri.js +1 -71
  292. package/dist/ssri.js.map +2 -2
  293. package/dist/stdio/clear.js +1 -82
  294. package/dist/stdio/clear.js.map +2 -2
  295. package/dist/stdio/divider.js +3 -89
  296. package/dist/stdio/divider.js.map +2 -2
  297. package/dist/stdio/footer.js +2 -94
  298. package/dist/stdio/footer.js.map +2 -2
  299. package/dist/stdio/header.js +2 -100
  300. package/dist/stdio/header.js.map +2 -2
  301. package/dist/stdio/mask.js +5 -206
  302. package/dist/stdio/mask.js.map +2 -2
  303. package/dist/stdio/progress.js +2 -209
  304. package/dist/stdio/progress.js.map +2 -2
  305. package/dist/stdio/prompts.js +1 -88
  306. package/dist/stdio/prompts.js.map +2 -2
  307. package/dist/stdio/stderr.js +2 -89
  308. package/dist/stdio/stderr.js.map +2 -2
  309. package/dist/stdio/stdout.js +2 -103
  310. package/dist/stdio/stdout.js.map +2 -2
  311. package/dist/streams.js +1 -78
  312. package/dist/streams.js.map +2 -2
  313. package/dist/strings.js +3 -251
  314. package/dist/strings.js.map +2 -2
  315. package/dist/suppress-warnings.js +1 -98
  316. package/dist/suppress-warnings.js.map +2 -2
  317. package/dist/tables.js +3 -128
  318. package/dist/tables.js.map +2 -2
  319. package/dist/temporary-executor.js +1 -53
  320. package/dist/temporary-executor.js.map +2 -2
  321. package/dist/types.js +1 -72
  322. package/dist/types.js.map +2 -2
  323. package/dist/url.js +1 -142
  324. package/dist/url.js.map +2 -2
  325. package/dist/utils/get-ipc.js +1 -58
  326. package/dist/utils/get-ipc.js.map +2 -2
  327. package/dist/validation/json-parser.js +1 -127
  328. package/dist/validation/json-parser.js.map +2 -2
  329. package/dist/validation/types.js +1 -15
  330. package/dist/validation/types.js.map +2 -2
  331. package/dist/versions.js +1 -153
  332. package/dist/versions.js.map +2 -2
  333. package/dist/words.js +1 -50
  334. package/dist/words.js.map +2 -2
  335. package/dist/zod.js +1 -27
  336. package/dist/zod.js.map +2 -2
  337. package/package.json +2 -2
package/dist/spinner.js CHANGED
@@ -1,867 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
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, desc2) => {
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: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var spinner_exports = {};
30
- __export(spinner_exports, {
31
- Spinner: () => Spinner,
32
- ciSpinner: () => ciSpinner,
33
- getCliSpinners: () => getCliSpinners,
34
- getDefaultSpinner: () => getDefaultSpinner,
35
- spinner: () => spinner,
36
- withSpinner: () => withSpinner,
37
- withSpinnerRestore: () => withSpinnerRestore,
38
- withSpinnerSync: () => withSpinnerSync
39
- });
40
- module.exports = __toCommonJS(spinner_exports);
41
- var import_ci = require("#env/ci");
42
- var import_pulse_frames = require("./effects/pulse-frames");
43
- var import_text_shimmer = require("./effects/text-shimmer");
44
- var import_yocto_spinner = __toESM(require("./external/@socketregistry/yocto-spinner"));
45
- var import_objects = require("./objects");
46
- var import_strings = require("./strings");
47
- const colorToRgb = {
48
- __proto__: null,
49
- black: [0, 0, 0],
50
- blue: [0, 0, 255],
51
- blueBright: [100, 149, 237],
52
- cyan: [0, 255, 255],
53
- cyanBright: [0, 255, 255],
54
- gray: [128, 128, 128],
55
- green: [0, 128, 0],
56
- greenBright: [0, 255, 0],
57
- magenta: [255, 0, 255],
58
- magentaBright: [255, 105, 180],
59
- red: [255, 0, 0],
60
- redBright: [255, 69, 0],
61
- white: [255, 255, 255],
62
- whiteBright: [255, 255, 255],
63
- yellow: [255, 255, 0],
64
- yellowBright: [255, 255, 153]
65
- };
66
- function isRgbTuple(value) {
67
- return Array.isArray(value);
68
- }
69
- function toRgb(color) {
70
- if (isRgbTuple(color)) {
71
- return color;
72
- }
73
- return colorToRgb[color];
74
- }
75
- const ciSpinner = {
76
- frames: [""],
77
- interval: 2147483647
78
- };
79
- function desc(value) {
80
- return {
81
- __proto__: null,
82
- configurable: true,
83
- value,
84
- writable: true
85
- };
86
- }
87
- function normalizeText(value) {
88
- return typeof value === "string" ? value.trimStart() : "";
89
- }
90
- function formatProgress(progress) {
91
- const { current, total, unit } = progress;
92
- const percentage = Math.round(current / total * 100);
93
- const bar = renderProgressBar(percentage);
94
- const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`;
95
- return `${bar} ${percentage}% (${count})`;
96
- }
97
- function renderProgressBar(percentage, width = 20) {
98
- const filled = Math.round(percentage / 100 * width);
99
- const empty = width - filled;
100
- const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
101
- const colors = require("./external/yoctocolors-cjs");
102
- return colors.cyan(bar);
103
- }
104
- let _cliSpinners;
105
- // @__NO_SIDE_EFFECTS__
106
- function getCliSpinners(styleName) {
107
- if (_cliSpinners === void 0) {
108
- const YoctoCtor = import_yocto_spinner.default;
109
- const tempInstance = YoctoCtor({});
110
- const YoctoSpinnerClass = tempInstance.constructor;
111
- _cliSpinners = {
112
- __proto__: null,
113
- ...YoctoSpinnerClass.spinners,
114
- socket: (0, import_pulse_frames.generateSocketSpinnerFrames)()
115
- };
116
- }
117
- if (typeof styleName === "string" && _cliSpinners) {
118
- return (0, import_objects.hasOwn)(_cliSpinners, styleName) ? _cliSpinners[styleName] : void 0;
119
- }
120
- return _cliSpinners;
121
- }
122
- let _Spinner;
123
- let _defaultSpinner;
124
- // @__NO_SIDE_EFFECTS__
125
- function Spinner(options) {
126
- if (_Spinner === void 0) {
127
- const YoctoCtor = import_yocto_spinner.default;
128
- const tempInstance = YoctoCtor({});
129
- const YoctoSpinnerClass = tempInstance.constructor;
130
- _Spinner = class SpinnerClass extends YoctoSpinnerClass {
131
- #baseText = "";
132
- #indentation = "";
133
- #progress;
134
- #shimmer;
135
- #shimmerSavedConfig;
136
- constructor(options2) {
137
- const opts = { __proto__: null, ...options2 };
138
- const spinnerColor = opts.color ?? [140, 82, 255];
139
- if (isRgbTuple(spinnerColor) && (spinnerColor.length !== 3 || !spinnerColor.every(
140
- (n) => typeof n === "number" && n >= 0 && n <= 255
141
- ))) {
142
- throw new TypeError(
143
- "RGB color must be an array of 3 numbers between 0 and 255"
144
- );
145
- }
146
- const spinnerColorRgb = toRgb(spinnerColor);
147
- let shimmerInfo;
148
- if (opts.shimmer) {
149
- let shimmerDir;
150
- let shimmerColor;
151
- let shimmerSpeed = 1 / 3;
152
- if (typeof opts.shimmer === "string") {
153
- shimmerDir = opts.shimmer;
154
- } else {
155
- const shimmerConfig = {
156
- __proto__: null,
157
- ...opts.shimmer
158
- };
159
- shimmerDir = shimmerConfig.dir ?? import_text_shimmer.DIR_LTR;
160
- shimmerColor = shimmerConfig.color ?? import_text_shimmer.COLOR_INHERIT;
161
- shimmerSpeed = shimmerConfig.speed ?? 1 / 3;
162
- }
163
- shimmerInfo = {
164
- __proto__: null,
165
- color: shimmerColor === void 0 ? import_text_shimmer.COLOR_INHERIT : shimmerColor,
166
- currentDir: import_text_shimmer.DIR_LTR,
167
- mode: shimmerDir,
168
- speed: shimmerSpeed,
169
- step: 0
170
- };
171
- }
172
- super({
173
- signal: require("#constants/process").getAbortSignal(),
174
- ...opts,
175
- // Pass RGB color directly to yocto-spinner (it now supports RGB).
176
- color: spinnerColorRgb,
177
- // onRenderFrame callback provides full control over frame + text layout.
178
- // Calculates spacing based on frame width to prevent text jumping.
179
- onRenderFrame: (frame, text, applyColor) => {
180
- const width = (0, import_strings.stringWidth)(frame);
181
- const spacing = width === 1 ? " " : " ";
182
- return frame ? `${applyColor(frame)}${spacing}${text}` : text;
183
- },
184
- // onFrameUpdate callback is called by yocto-spinner whenever a frame advances.
185
- // This ensures shimmer updates are perfectly synchronized with animation beats.
186
- onFrameUpdate: shimmerInfo ? () => {
187
- if (this.#baseText) {
188
- super.text = this.#buildDisplayText();
189
- }
190
- } : void 0
191
- });
192
- this.#shimmer = shimmerInfo;
193
- this.#shimmerSavedConfig = shimmerInfo;
194
- }
195
- // Override color getter to ensure it's always RGB.
196
- get color() {
197
- const value = super.color;
198
- return isRgbTuple(value) ? value : toRgb(value);
199
- }
200
- // Override color setter to always convert to RGB before passing to yocto-spinner.
201
- set color(value) {
202
- super.color = isRgbTuple(value) ? value : toRgb(value);
203
- }
204
- /**
205
- * Apply a yocto-spinner method and update logger state.
206
- * Handles text normalization, extra arguments, and logger tracking.
207
- * @private
208
- */
209
- #apply(methodName, args) {
210
- let extras;
211
- let text = args.at(0);
212
- if (typeof text === "string") {
213
- extras = args.slice(1);
214
- } else {
215
- extras = args;
216
- text = "";
217
- }
218
- const wasSpinning = this.isSpinning;
219
- const normalized = normalizeText(text);
220
- super[methodName](normalized);
221
- const {
222
- incLogCallCountSymbol,
223
- lastWasBlankSymbol,
224
- logger
225
- } = require("./logger.js");
226
- if (methodName === "stop") {
227
- if (wasSpinning && normalized) {
228
- logger[lastWasBlankSymbol]((0, import_strings.isBlankString)(normalized));
229
- logger[incLogCallCountSymbol]();
230
- }
231
- } else {
232
- logger[lastWasBlankSymbol](false);
233
- logger[incLogCallCountSymbol]();
234
- }
235
- if (extras.length) {
236
- logger.log(...extras);
237
- logger[lastWasBlankSymbol](false);
238
- }
239
- return this;
240
- }
241
- /**
242
- * Build the complete display text with progress, shimmer, and indentation.
243
- * Combines base text, progress bar, shimmer effects, and indentation.
244
- * @private
245
- */
246
- #buildDisplayText() {
247
- let displayText = this.#baseText;
248
- if (this.#progress) {
249
- const progressText = formatProgress(this.#progress);
250
- displayText = displayText ? `${displayText} ${progressText}` : progressText;
251
- }
252
- if (displayText && this.#shimmer) {
253
- let shimmerColor;
254
- if (this.#shimmer.color === import_text_shimmer.COLOR_INHERIT) {
255
- shimmerColor = this.color;
256
- } else if (Array.isArray(this.#shimmer.color[0])) {
257
- shimmerColor = this.#shimmer.color;
258
- } else {
259
- shimmerColor = toRgb(this.#shimmer.color);
260
- }
261
- displayText = (0, import_text_shimmer.applyShimmer)(displayText, this.#shimmer, {
262
- color: shimmerColor,
263
- direction: this.#shimmer.mode
264
- });
265
- }
266
- if (this.#indentation && displayText) {
267
- displayText = this.#indentation + displayText;
268
- }
269
- return displayText;
270
- }
271
- /**
272
- * Show a status message without stopping the spinner.
273
- * Outputs the symbol and message to stderr, then continues spinning.
274
- */
275
- #showStatusAndKeepSpinning(symbolType, args) {
276
- let text = args.at(0);
277
- let extras;
278
- if (typeof text === "string") {
279
- extras = args.slice(1);
280
- } else {
281
- extras = args;
282
- text = "";
283
- }
284
- const { LOG_SYMBOLS, logger } = require("./logger.js");
285
- logger.error(`${LOG_SYMBOLS[symbolType]} ${text}`, ...extras);
286
- return this;
287
- }
288
- /**
289
- * Update the spinner's displayed text.
290
- * Rebuilds display text and triggers render.
291
- * @private
292
- */
293
- #updateSpinnerText() {
294
- super.text = this.#buildDisplayText();
295
- }
296
- /**
297
- * Show a debug message (ℹ) without stopping the spinner.
298
- * Only displays if debug mode is enabled via environment variable.
299
- * Outputs to stderr and continues spinning.
300
- *
301
- * @param text - Debug message to display
302
- * @param extras - Additional values to log
303
- * @returns This spinner for chaining
304
- */
305
- debug(text, ...extras) {
306
- const { isDebug } = require("./debug.js");
307
- if (isDebug()) {
308
- return this.#showStatusAndKeepSpinning("info", [text, ...extras]);
309
- }
310
- return this;
311
- }
312
- /**
313
- * Show a debug message (ℹ) and stop the spinner.
314
- * Only displays if debug mode is enabled via environment variable.
315
- * Auto-clears the spinner line before displaying the message.
316
- *
317
- * @param text - Debug message to display
318
- * @param extras - Additional values to log
319
- * @returns This spinner for chaining
320
- */
321
- debugAndStop(text, ...extras) {
322
- const { isDebug } = require("./debug.js");
323
- if (isDebug()) {
324
- return this.#apply("info", [text, ...extras]);
325
- }
326
- return this;
327
- }
328
- /**
329
- * Decrease indentation level by removing spaces from the left.
330
- * Pass 0 to reset indentation to zero completely.
331
- *
332
- * @param spaces - Number of spaces to remove
333
- * @returns This spinner for chaining
334
- * @default spaces=2
335
- *
336
- * @example
337
- * ```ts
338
- * spinner.dedent() // Remove 2 spaces
339
- * spinner.dedent(4) // Remove 4 spaces
340
- * spinner.dedent(0) // Reset to zero indentation
341
- * ```
342
- */
343
- dedent(spaces) {
344
- if (spaces === 0) {
345
- this.#indentation = "";
346
- } else {
347
- const amount = spaces ?? 2;
348
- const newLength = Math.max(0, this.#indentation.length - amount);
349
- this.#indentation = this.#indentation.slice(0, newLength);
350
- }
351
- this.#updateSpinnerText();
352
- return this;
353
- }
354
- /**
355
- * Show a done/success message (✓) without stopping the spinner.
356
- * Alias for `success()` with a shorter name.
357
- *
358
- * DESIGN DECISION: Unlike yocto-spinner, our `done()` does NOT stop the spinner.
359
- * Use `doneAndStop()` if you want to stop the spinner.
360
- *
361
- * @param text - Message to display
362
- * @param extras - Additional values to log
363
- * @returns This spinner for chaining
364
- */
365
- done(text, ...extras) {
366
- return this.#showStatusAndKeepSpinning("success", [text, ...extras]);
367
- }
368
- /**
369
- * Show a done/success message (✓) and stop the spinner.
370
- * Auto-clears the spinner line before displaying the success message.
371
- *
372
- * @param text - Message to display
373
- * @param extras - Additional values to log
374
- * @returns This spinner for chaining
375
- */
376
- doneAndStop(text, ...extras) {
377
- return this.#apply("success", [text, ...extras]);
378
- }
379
- /**
380
- * Show a failure message (✗) without stopping the spinner.
381
- * DESIGN DECISION: Unlike yocto-spinner, our `fail()` does NOT stop the spinner.
382
- * This allows displaying errors while continuing to spin.
383
- * Use `failAndStop()` if you want to stop the spinner.
384
- *
385
- * @param text - Error message to display
386
- * @param extras - Additional values to log
387
- * @returns This spinner for chaining
388
- */
389
- fail(text, ...extras) {
390
- return this.#showStatusAndKeepSpinning("fail", [text, ...extras]);
391
- }
392
- /**
393
- * Show a failure message (✗) and stop the spinner.
394
- * Auto-clears the spinner line before displaying the error message.
395
- *
396
- * @param text - Error message to display
397
- * @param extras - Additional values to log
398
- * @returns This spinner for chaining
399
- */
400
- failAndStop(text, ...extras) {
401
- return this.#apply("error", [text, ...extras]);
402
- }
403
- /**
404
- * Increase indentation level by adding spaces to the left.
405
- * Pass 0 to reset indentation to zero completely.
406
- *
407
- * @param spaces - Number of spaces to add
408
- * @returns This spinner for chaining
409
- * @default spaces=2
410
- *
411
- * @example
412
- * ```ts
413
- * spinner.indent() // Add 2 spaces
414
- * spinner.indent(4) // Add 4 spaces
415
- * spinner.indent(0) // Reset to zero indentation
416
- * ```
417
- */
418
- indent(spaces) {
419
- if (spaces === 0) {
420
- this.#indentation = "";
421
- } else {
422
- const amount = spaces ?? 2;
423
- this.#indentation += " ".repeat(amount);
424
- }
425
- this.#updateSpinnerText();
426
- return this;
427
- }
428
- /**
429
- * Show an info message (ℹ) without stopping the spinner.
430
- * Outputs to stderr and continues spinning.
431
- *
432
- * @param text - Info message to display
433
- * @param extras - Additional values to log
434
- * @returns This spinner for chaining
435
- */
436
- info(text, ...extras) {
437
- return this.#showStatusAndKeepSpinning("info", [text, ...extras]);
438
- }
439
- /**
440
- * Show an info message (ℹ) and stop the spinner.
441
- * Auto-clears the spinner line before displaying the message.
442
- *
443
- * @param text - Info message to display
444
- * @param extras - Additional values to log
445
- * @returns This spinner for chaining
446
- */
447
- infoAndStop(text, ...extras) {
448
- return this.#apply("info", [text, ...extras]);
449
- }
450
- /**
451
- * Log a message to stdout without stopping the spinner.
452
- * Unlike other status methods, this outputs to stdout for data logging.
453
- *
454
- * @param args - Values to log to stdout
455
- * @returns This spinner for chaining
456
- */
457
- log(...args) {
458
- const { logger } = require("./logger.js");
459
- logger.log(...args);
460
- return this;
461
- }
462
- /**
463
- * Log a message to stdout and stop the spinner.
464
- * Auto-clears the spinner line before displaying the message.
465
- *
466
- * @param text - Message to display
467
- * @param extras - Additional values to log
468
- * @returns This spinner for chaining
469
- */
470
- logAndStop(text, ...extras) {
471
- return this.#apply("stop", [text, ...extras]);
472
- }
473
- /**
474
- * Update progress information displayed with the spinner.
475
- * Shows a progress bar with percentage and optional unit label.
476
- *
477
- * @param current - Current progress value
478
- * @param total - Total/maximum progress value
479
- * @param unit - Optional unit label (e.g., 'files', 'items')
480
- * @returns This spinner for chaining
481
- *
482
- * @example
483
- * ```ts
484
- * spinner.progress(5, 10) // "███████░░░░░░░░░░░░░ 50% (5/10)"
485
- * spinner.progress(7, 20, 'files') // "███████░░░░░░░░░░░░░ 35% (7/20 files)"
486
- * ```
487
- */
488
- progress = (current, total, unit) => {
489
- this.#progress = {
490
- __proto__: null,
491
- current,
492
- total,
493
- ...unit ? { unit } : {}
494
- };
495
- this.#updateSpinnerText();
496
- return this;
497
- };
498
- /**
499
- * Increment progress by a specified amount.
500
- * Updates the progress bar displayed with the spinner.
501
- * Clamps the result between 0 and the total value.
502
- *
503
- * @param amount - Amount to increment by
504
- * @returns This spinner for chaining
505
- * @default amount=1
506
- *
507
- * @example
508
- * ```ts
509
- * spinner.progress(0, 10, 'files')
510
- * spinner.progressStep() // Progress: 1/10
511
- * spinner.progressStep(3) // Progress: 4/10
512
- * ```
513
- */
514
- progressStep(amount = 1) {
515
- if (this.#progress) {
516
- const newCurrent = this.#progress.current + amount;
517
- this.#progress = {
518
- __proto__: null,
519
- current: Math.max(0, Math.min(newCurrent, this.#progress.total)),
520
- total: this.#progress.total,
521
- ...this.#progress.unit ? { unit: this.#progress.unit } : {}
522
- };
523
- this.#updateSpinnerText();
524
- }
525
- return this;
526
- }
527
- /**
528
- * Start the spinner animation with optional text.
529
- * Begins displaying the animated spinner on stderr.
530
- *
531
- * @param text - Optional text to display with the spinner
532
- * @returns This spinner for chaining
533
- *
534
- * @example
535
- * ```ts
536
- * spinner.start('Loading…')
537
- * // Later:
538
- * spinner.successAndStop('Done!')
539
- * ```
540
- */
541
- start(...args) {
542
- if (args.length) {
543
- const text = args.at(0);
544
- const normalized = normalizeText(text);
545
- if (!normalized) {
546
- this.#baseText = "";
547
- super.text = "";
548
- } else {
549
- this.#baseText = normalized;
550
- }
551
- }
552
- this.#updateSpinnerText();
553
- return this.#apply("start", args);
554
- }
555
- /**
556
- * Log a main step message to stderr without stopping the spinner.
557
- * Adds a blank line before the message for visual separation.
558
- * Aligns with `logger.step()` to use stderr for status messages.
559
- *
560
- * @param text - Step message to display
561
- * @param extras - Additional values to log
562
- * @returns This spinner for chaining
563
- *
564
- * @example
565
- * ```ts
566
- * spinner.step('Building application')
567
- * spinner.substep('Compiling TypeScript')
568
- * spinner.substep('Bundling assets')
569
- * ```
570
- */
571
- step(text, ...extras) {
572
- const { logger } = require("./logger.js");
573
- if (typeof text === "string") {
574
- logger.error("");
575
- logger.error(text, ...extras);
576
- }
577
- return this;
578
- }
579
- /**
580
- * Log an indented substep message to stderr without stopping the spinner.
581
- * Adds 2-space indentation to the message.
582
- * Aligns with `logger.substep()` to use stderr for status messages.
583
- *
584
- * @param text - Substep message to display
585
- * @param extras - Additional values to log
586
- * @returns This spinner for chaining
587
- *
588
- * @example
589
- * ```ts
590
- * spinner.step('Building application')
591
- * spinner.substep('Compiling TypeScript')
592
- * spinner.substep('Bundling assets')
593
- * ```
594
- */
595
- substep(text, ...extras) {
596
- if (typeof text === "string") {
597
- const { logger } = require("./logger.js");
598
- logger.error(` ${text}`, ...extras);
599
- }
600
- return this;
601
- }
602
- /**
603
- * Stop the spinner animation and clear internal state.
604
- * Auto-clears the spinner line via yocto-spinner.stop().
605
- * Resets progress, shimmer, and text state.
606
- *
607
- * @param text - Optional final text to display after stopping
608
- * @returns This spinner for chaining
609
- *
610
- * @example
611
- * ```ts
612
- * spinner.start('Processing…')
613
- * // Do work
614
- * spinner.stop() // Just stop, no message
615
- * // or
616
- * spinner.stop('Finished processing')
617
- * ```
618
- */
619
- stop(...args) {
620
- this.#baseText = "";
621
- this.#progress = void 0;
622
- if (this.#shimmer) {
623
- this.#shimmer.currentDir = import_text_shimmer.DIR_LTR;
624
- this.#shimmer.step = 0;
625
- }
626
- const result = this.#apply("stop", args);
627
- super.text = "";
628
- return result;
629
- }
630
- /**
631
- * Show a success message (✓) without stopping the spinner.
632
- * DESIGN DECISION: Unlike yocto-spinner, our `success()` does NOT stop the spinner.
633
- * This allows displaying success messages while continuing to spin for multi-step operations.
634
- * Use `successAndStop()` if you want to stop the spinner.
635
- *
636
- * @param text - Success message to display
637
- * @param extras - Additional values to log
638
- * @returns This spinner for chaining
639
- */
640
- success(text, ...extras) {
641
- return this.#showStatusAndKeepSpinning("success", [text, ...extras]);
642
- }
643
- /**
644
- * Show a success message (✓) and stop the spinner.
645
- * Auto-clears the spinner line before displaying the success message.
646
- *
647
- * @param text - Success message to display
648
- * @param extras - Additional values to log
649
- * @returns This spinner for chaining
650
- */
651
- successAndStop(text, ...extras) {
652
- return this.#apply("success", [text, ...extras]);
653
- }
654
- text(value) {
655
- if (arguments.length === 0) {
656
- return this.#baseText;
657
- }
658
- this.#baseText = value ?? "";
659
- this.#updateSpinnerText();
660
- return this;
661
- }
662
- /**
663
- * Show a warning message (⚠) without stopping the spinner.
664
- * Outputs to stderr and continues spinning.
665
- *
666
- * @param text - Warning message to display
667
- * @param extras - Additional values to log
668
- * @returns This spinner for chaining
669
- */
670
- warn(text, ...extras) {
671
- return this.#showStatusAndKeepSpinning("warn", [text, ...extras]);
672
- }
673
- /**
674
- * Show a warning message (⚠) and stop the spinner.
675
- * Auto-clears the spinner line before displaying the warning message.
676
- *
677
- * @param text - Warning message to display
678
- * @param extras - Additional values to log
679
- * @returns This spinner for chaining
680
- */
681
- warnAndStop(text, ...extras) {
682
- return this.#apply("warning", [text, ...extras]);
683
- }
684
- /**
685
- * Toggle shimmer effect or update shimmer configuration.
686
- * Preserves shimmer config when toggling off, allowing easy re-enable.
687
- * Supports partial config updates to tweak specific properties.
688
- *
689
- * @param enabledOrConfig - Boolean to toggle, partial config to update, or direction string
690
- * @returns This spinner for chaining
691
- *
692
- * @example
693
- * // Toggle off (preserves config for later re-enable)
694
- * spinner.shimmer(false)
695
- *
696
- * // Toggle on (restores saved config or uses defaults)
697
- * spinner.shimmer(true)
698
- *
699
- * // Update specific properties
700
- * spinner.shimmer({ speed: 0.5 })
701
- * spinner.shimmer({ color: [255, 0, 0] })
702
- *
703
- * // Set direction
704
- * spinner.shimmer('rtl')
705
- */
706
- shimmer(enabledOrConfig) {
707
- if (enabledOrConfig === false) {
708
- this.#shimmer = void 0;
709
- } else if (enabledOrConfig === true) {
710
- if (this.#shimmerSavedConfig) {
711
- this.#shimmer = { ...this.#shimmerSavedConfig };
712
- } else {
713
- this.#shimmer = {
714
- color: import_text_shimmer.COLOR_INHERIT,
715
- currentDir: import_text_shimmer.DIR_LTR,
716
- mode: import_text_shimmer.DIR_LTR,
717
- speed: 1 / 3,
718
- step: 0
719
- };
720
- this.#shimmerSavedConfig = this.#shimmer;
721
- }
722
- } else if (typeof enabledOrConfig === "string") {
723
- if (this.#shimmer) {
724
- this.#shimmer = {
725
- ...this.#shimmer,
726
- mode: enabledOrConfig
727
- };
728
- this.#shimmerSavedConfig = this.#shimmer;
729
- } else if (this.#shimmerSavedConfig) {
730
- this.#shimmer = {
731
- ...this.#shimmerSavedConfig,
732
- mode: enabledOrConfig
733
- };
734
- this.#shimmerSavedConfig = this.#shimmer;
735
- } else {
736
- this.#shimmer = {
737
- color: import_text_shimmer.COLOR_INHERIT,
738
- currentDir: import_text_shimmer.DIR_LTR,
739
- mode: enabledOrConfig,
740
- speed: 1 / 3,
741
- step: 0
742
- };
743
- this.#shimmerSavedConfig = this.#shimmer;
744
- }
745
- } else if (enabledOrConfig && typeof enabledOrConfig === "object") {
746
- const partialConfig = {
747
- __proto__: null,
748
- ...enabledOrConfig
749
- };
750
- if (this.#shimmer) {
751
- this.#shimmer = {
752
- ...this.#shimmer,
753
- ...partialConfig.color !== void 0 ? { color: partialConfig.color } : {},
754
- ...partialConfig.dir !== void 0 ? { mode: partialConfig.dir } : {},
755
- ...partialConfig.speed !== void 0 ? { speed: partialConfig.speed } : {}
756
- };
757
- this.#shimmerSavedConfig = this.#shimmer;
758
- } else if (this.#shimmerSavedConfig) {
759
- this.#shimmer = {
760
- ...this.#shimmerSavedConfig,
761
- ...partialConfig.color !== void 0 ? { color: partialConfig.color } : {},
762
- ...partialConfig.dir !== void 0 ? { mode: partialConfig.dir } : {},
763
- ...partialConfig.speed !== void 0 ? { speed: partialConfig.speed } : {}
764
- };
765
- this.#shimmerSavedConfig = this.#shimmer;
766
- } else {
767
- this.#shimmer = {
768
- color: partialConfig.color ?? import_text_shimmer.COLOR_INHERIT,
769
- currentDir: import_text_shimmer.DIR_LTR,
770
- mode: partialConfig.dir ?? import_text_shimmer.DIR_LTR,
771
- speed: partialConfig.speed ?? 1 / 3,
772
- step: 0
773
- };
774
- this.#shimmerSavedConfig = this.#shimmer;
775
- }
776
- }
777
- this.#updateSpinnerText();
778
- return this;
779
- }
780
- };
781
- Object.defineProperties(_Spinner.prototype, {
782
- error: desc(_Spinner.prototype.fail),
783
- errorAndStop: desc(_Spinner.prototype.failAndStop),
784
- warning: desc(_Spinner.prototype.warn),
785
- warningAndStop: desc(_Spinner.prototype.warnAndStop)
786
- });
787
- _defaultSpinner = import_ci.CI ? ciSpinner : /* @__PURE__ */ getCliSpinners("socket");
788
- }
789
- return new _Spinner({
790
- spinner: _defaultSpinner,
791
- ...options
792
- });
793
- }
794
- let _spinner;
795
- function getDefaultSpinner() {
796
- if (_spinner === void 0) {
797
- _spinner = /* @__PURE__ */ Spinner();
798
- }
799
- return _spinner;
800
- }
801
- const spinner = /* @__PURE__ */ (() => {
802
- let _lazySpinner;
803
- return new Proxy({}, {
804
- get(_target, prop) {
805
- if (_lazySpinner === void 0) {
806
- _lazySpinner = /* @__PURE__ */ Spinner();
807
- }
808
- const value = _lazySpinner[prop];
809
- return typeof value === "function" ? value.bind(_lazySpinner) : value;
810
- }
811
- });
812
- })();
813
- async function withSpinner(options) {
814
- const { message, operation, spinner: spinner2 } = {
815
- __proto__: null,
816
- ...options
817
- };
818
- if (!spinner2) {
819
- return await operation();
820
- }
821
- spinner2.start(message);
822
- try {
823
- return await operation();
824
- } finally {
825
- spinner2.stop();
826
- }
827
- }
828
- async function withSpinnerRestore(options) {
829
- const { operation, spinner: spinner2, wasSpinning } = {
830
- __proto__: null,
831
- ...options
832
- };
833
- try {
834
- return await operation();
835
- } finally {
836
- if (spinner2 && wasSpinning) {
837
- spinner2.start();
838
- }
839
- }
840
- }
841
- function withSpinnerSync(options) {
842
- const { message, operation, spinner: spinner2 } = {
843
- __proto__: null,
844
- ...options
845
- };
846
- if (!spinner2) {
847
- return operation();
848
- }
849
- spinner2.start(message);
850
- try {
851
- return operation();
852
- } finally {
853
- spinner2.stop();
854
- }
855
- }
856
- // Annotate the CommonJS export names for ESM import in node:
857
- 0 && (module.exports = {
858
- Spinner,
859
- ciSpinner,
860
- getCliSpinners,
861
- getDefaultSpinner,
862
- spinner,
863
- withSpinner,
864
- withSpinnerRestore,
865
- withSpinnerSync
866
- });
2
+ var W=Object.create;var S=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(t,o)=>{for(var i in o)S(t,i,{get:o[i],enumerable:!0})},T=(t,o,i,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of V(o))!G.call(t,d)&&d!==i&&S(t,d,{get:()=>o[d],enumerable:!(s=q(o,d))||s.enumerable});return t};var L=(t,o,i)=>(i=t!=null?W(Y(t)):{},T(o||!t||!t.__esModule?S(i,"default",{value:t,enumerable:!0}):i,t)),M=t=>T(S({},"__esModule",{value:!0}),t);var J={};v(J,{Spinner:()=>C,ciSpinner:()=>D,getCliSpinners:()=>$,getDefaultSpinner:()=>E,spinner:()=>N,withSpinner:()=>H,withSpinnerRestore:()=>K,withSpinnerSync:()=>U});module.exports=M(J);var I=require("#env/ci"),B=require("./effects/pulse-frames"),u=require("./effects/text-shimmer"),k=L(require("./external/@socketregistry/yocto-spinner")),P=require("./objects"),b=require("./strings");const z={__proto__:null,black:[0,0,0],blue:[0,0,255],blueBright:[100,149,237],cyan:[0,255,255],cyanBright:[0,255,255],gray:[128,128,128],green:[0,128,0],greenBright:[0,255,0],magenta:[255,0,255],magentaBright:[255,105,180],red:[255,0,0],redBright:[255,69,0],white:[255,255,255],whiteBright:[255,255,255],yellow:[255,255,0],yellowBright:[255,255,153]};function x(t){return Array.isArray(t)}function y(t){return x(t)?t:z[t]}const D={frames:[""],interval:2147483647};function w(t){return{__proto__:null,configurable:!0,value:t,writable:!0}}function R(t){return typeof t=="string"?t.trimStart():""}function F(t){const{current:o,total:i,unit:s}=t,d=Math.round(o/i*100),n=j(d),e=s?`${o}/${i} ${s}`:`${o}/${i}`;return`${n} ${d}% (${e})`}function j(t,o=20){const i=Math.round(t/100*o),s=o-i,d="\u2588".repeat(i)+"\u2591".repeat(s);return require("./external/yoctocolors-cjs").cyan(d)}let m;function $(t){return m===void 0&&(m={__proto__:null,...(0,k.default)({}).constructor.spinners,socket:(0,B.generateSocketSpinnerFrames)()}),typeof t=="string"&&m?(0,P.hasOwn)(m,t)?m[t]:void 0:m}let g,A;function C(t){if(g===void 0){const s=(0,k.default)({}).constructor;g=class extends s{#o="";#i="";#t;#n;#e;constructor(n){const e={__proto__:null,...n},r=e.color??[140,82,255];if(x(r)&&(r.length!==3||!r.every(p=>typeof p=="number"&&p>=0&&p<=255)))throw new TypeError("RGB color must be an array of 3 numbers between 0 and 255");const a=y(r);let h;if(e.shimmer){let p,f,c=.3333333333333333;if(typeof e.shimmer=="string")p=e.shimmer;else{const l={__proto__:null,...e.shimmer};p=l.dir??u.DIR_LTR,f=l.color??u.COLOR_INHERIT,c=l.speed??1/3}h={__proto__:null,color:f===void 0?u.COLOR_INHERIT:f,currentDir:u.DIR_LTR,mode:p,speed:c,step:0}}super({signal:require("#constants/process").getAbortSignal(),...e,color:a,onRenderFrame:(p,f,c)=>{const O=(0,b.stringWidth)(p)===1?" ":" ";return p?`${c(p)}${O}${f}`:f},onFrameUpdate:h?()=>{this.#o&&(super.text=this.#p())}:void 0}),this.#n=h,this.#e=h}get color(){const n=super.color;return x(n)?n:y(n)}set color(n){super.color=x(n)?n:y(n)}#r(n,e){let r,a=e.at(0);typeof a=="string"?r=e.slice(1):(r=e,a="");const h=this.isSpinning,p=R(a);super[n](p);const{incLogCallCountSymbol:f,lastWasBlankSymbol:c,logger:l}=require("./logger.js");return n==="stop"?h&&p&&(l[c]((0,b.isBlankString)(p)),l[f]()):(l[c](!1),l[f]()),r.length&&(l.log(...r),l[c](!1)),this}#p(){let n=this.#o;if(this.#t){const e=F(this.#t);n=n?`${n} ${e}`:e}if(n&&this.#n){let e;this.#n.color===u.COLOR_INHERIT?e=this.color:Array.isArray(this.#n.color[0])?e=this.#n.color:e=y(this.#n.color),n=(0,u.applyShimmer)(n,this.#n,{color:e,direction:this.#n.mode})}return this.#i&&n&&(n=this.#i+n),n}#u(n,e){let r=e.at(0),a;typeof r=="string"?a=e.slice(1):(a=e,r="");const{LOG_SYMBOLS:h,logger:p}=require("./logger.js");return p.error(`${h[n]} ${r}`,...a),this}#s(){super.text=this.#p()}debug(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#u("info",[n,...e]):this}debugAndStop(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#r("info",[n,...e]):this}dedent(n){if(n===0)this.#i="";else{const e=n??2,r=Math.max(0,this.#i.length-e);this.#i=this.#i.slice(0,r)}return this.#s(),this}done(n,...e){return this.#u("success",[n,...e])}doneAndStop(n,...e){return this.#r("success",[n,...e])}fail(n,...e){return this.#u("fail",[n,...e])}failAndStop(n,...e){return this.#r("error",[n,...e])}indent(n){if(n===0)this.#i="";else{const e=n??2;this.#i+=" ".repeat(e)}return this.#s(),this}info(n,...e){return this.#u("info",[n,...e])}infoAndStop(n,...e){return this.#r("info",[n,...e])}log(...n){const{logger:e}=require("./logger.js");return e.log(...n),this}logAndStop(n,...e){return this.#r("stop",[n,...e])}progress=(n,e,r)=>(this.#t={__proto__:null,current:n,total:e,...r?{unit:r}:{}},this.#s(),this);progressStep(n=1){if(this.#t){const e=this.#t.current+n;this.#t={__proto__:null,current:Math.max(0,Math.min(e,this.#t.total)),total:this.#t.total,...this.#t.unit?{unit:this.#t.unit}:{}},this.#s()}return this}start(...n){if(n.length){const e=n.at(0),r=R(e);r?this.#o=r:(this.#o="",super.text="")}return this.#s(),this.#r("start",n)}step(n,...e){const{logger:r}=require("./logger.js");return typeof n=="string"&&(r.error(""),r.error(n,...e)),this}substep(n,...e){if(typeof n=="string"){const{logger:r}=require("./logger.js");r.error(` ${n}`,...e)}return this}stop(...n){this.#o="",this.#t=void 0,this.#n&&(this.#n.currentDir=u.DIR_LTR,this.#n.step=0);const e=this.#r("stop",n);return super.text="",e}success(n,...e){return this.#u("success",[n,...e])}successAndStop(n,...e){return this.#r("success",[n,...e])}text(n){return arguments.length===0?this.#o:(this.#o=n??"",this.#s(),this)}warn(n,...e){return this.#u("warn",[n,...e])}warnAndStop(n,...e){return this.#r("warning",[n,...e])}shimmer(n){if(n===!1)this.#n=void 0;else if(n===!0)this.#e?this.#n={...this.#e}:(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:u.DIR_LTR,speed:1/3,step:0},this.#e=this.#n);else if(typeof n=="string")this.#n?(this.#n={...this.#n,mode:n},this.#e=this.#n):this.#e?(this.#n={...this.#e,mode:n},this.#e=this.#n):(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:n,speed:1/3,step:0},this.#e=this.#n);else if(n&&typeof n=="object"){const e={__proto__:null,...n};this.#n?(this.#n={...this.#n,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):this.#e?(this.#n={...this.#e,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):(this.#n={color:e.color??u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:e.dir??u.DIR_LTR,speed:e.speed??1/3,step:0},this.#e=this.#n)}return this.#s(),this}},Object.defineProperties(g.prototype,{error:w(g.prototype.fail),errorAndStop:w(g.prototype.failAndStop),warning:w(g.prototype.warn),warningAndStop:w(g.prototype.warnAndStop)}),A=I.CI?D:$("socket")}return new g({spinner:A,...t})}let _;function E(){return _===void 0&&(_=C()),_}const N=(()=>{let t;return new Proxy({},{get(o,i){t===void 0&&(t=C());const s=t[i];return typeof s=="function"?s.bind(t):s}})})();async function H(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return await i();s.start(o);try{return await i()}finally{s.stop()}}async function K(t){const{operation:o,spinner:i,wasSpinning:s}={__proto__:null,...t};try{return await o()}finally{i&&s&&i.start()}}function U(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return i();s.start(o);try{return i()}finally{s.stop()}}0&&(module.exports={Spinner,ciSpinner,getCliSpinners,getDefaultSpinner,spinner,withSpinner,withSpinnerRestore,withSpinnerSync});
867
3
  //# sourceMappingURL=spinner.js.map