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