@socketsecurity/lib 3.0.2 → 3.0.4

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