@socketsecurity/lib 1.3.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/agent.js +1 -1
  3. package/dist/agent.js.map +2 -2
  4. package/dist/bin.js +1 -1
  5. package/dist/bin.js.map +3 -3
  6. package/dist/cacache.d.ts +4 -0
  7. package/dist/cacache.js +1 -1
  8. package/dist/cacache.js.map +3 -3
  9. package/dist/constants/packages.js +1 -1
  10. package/dist/constants/packages.js.map +3 -3
  11. package/dist/debug.d.ts +0 -7
  12. package/dist/debug.js +2 -2
  13. package/dist/debug.js.map +3 -3
  14. package/dist/dlx-binary.js +1 -1
  15. package/dist/dlx-binary.js.map +3 -3
  16. package/dist/effects/text-shimmer.js +1 -1
  17. package/dist/effects/text-shimmer.js.map +2 -2
  18. package/dist/env/ci.d.ts +1 -1
  19. package/dist/env/ci.js +1 -1
  20. package/dist/env/ci.js.map +3 -3
  21. package/dist/env/debug.d.ts +1 -1
  22. package/dist/env/debug.js +1 -1
  23. package/dist/env/debug.js.map +3 -3
  24. package/dist/env/github.d.ts +40 -0
  25. package/dist/env/github.js +3 -0
  26. package/dist/env/github.js.map +7 -0
  27. package/dist/env/home.d.ts +1 -1
  28. package/dist/env/home.js +1 -1
  29. package/dist/env/home.js.map +3 -3
  30. package/dist/env/locale.d.ts +15 -0
  31. package/dist/env/locale.js +3 -0
  32. package/dist/env/locale.js.map +7 -0
  33. package/dist/env/node-auth-token.d.ts +1 -1
  34. package/dist/env/node-auth-token.js +1 -1
  35. package/dist/env/node-auth-token.js.map +3 -3
  36. package/dist/env/node-env.d.ts +1 -1
  37. package/dist/env/node-env.js +1 -1
  38. package/dist/env/node-env.js.map +3 -3
  39. package/dist/env/npm.d.ts +25 -0
  40. package/dist/env/npm.js +3 -0
  41. package/dist/env/npm.js.map +7 -0
  42. package/dist/env/path.d.ts +1 -1
  43. package/dist/env/path.js +1 -1
  44. package/dist/env/path.js.map +3 -3
  45. package/dist/env/pre-commit.d.ts +1 -1
  46. package/dist/env/pre-commit.js +1 -1
  47. package/dist/env/pre-commit.js.map +3 -3
  48. package/dist/env/rewire.d.ts +106 -0
  49. package/dist/env/rewire.js +3 -0
  50. package/dist/env/rewire.js.map +7 -0
  51. package/dist/env/shell.d.ts +1 -1
  52. package/dist/env/shell.js +1 -1
  53. package/dist/env/shell.js.map +3 -3
  54. package/dist/env/socket-cli-shadow.d.ts +30 -0
  55. package/dist/env/socket-cli-shadow.js +3 -0
  56. package/dist/env/socket-cli-shadow.js.map +7 -0
  57. package/dist/env/socket-cli.d.ts +72 -0
  58. package/dist/env/socket-cli.js +3 -0
  59. package/dist/env/socket-cli.js.map +7 -0
  60. package/dist/env/socket.d.ts +75 -0
  61. package/dist/env/socket.js +3 -0
  62. package/dist/env/socket.js.map +7 -0
  63. package/dist/env/temp-dir.d.ts +15 -0
  64. package/dist/env/temp-dir.js +3 -0
  65. package/dist/env/temp-dir.js.map +7 -0
  66. package/dist/env/term.d.ts +1 -1
  67. package/dist/env/term.js +1 -1
  68. package/dist/env/term.js.map +3 -3
  69. package/dist/env/test.d.ts +15 -0
  70. package/dist/env/test.js +3 -0
  71. package/dist/env/test.js.map +7 -0
  72. package/dist/env/windows.d.ts +20 -0
  73. package/dist/env/windows.js +3 -0
  74. package/dist/env/windows.js.map +7 -0
  75. package/dist/env/xdg.d.ts +15 -0
  76. package/dist/env/xdg.js +3 -0
  77. package/dist/env/xdg.js.map +7 -0
  78. package/dist/fs.d.ts +7 -0
  79. package/dist/fs.js +3 -3
  80. package/dist/fs.js.map +3 -3
  81. package/dist/github.js +1 -1
  82. package/dist/github.js.map +3 -3
  83. package/dist/globs.js +1 -1
  84. package/dist/globs.js.map +2 -2
  85. package/dist/ipc.d.ts +1 -1
  86. package/dist/ipc.js +1 -1
  87. package/dist/ipc.js.map +3 -3
  88. package/dist/logger.d.ts +2 -1
  89. package/dist/logger.js +1 -1
  90. package/dist/logger.js.map +3 -3
  91. package/dist/packages/isolation.js +1 -1
  92. package/dist/packages/isolation.js.map +3 -3
  93. package/dist/packages/normalize.js +1 -1
  94. package/dist/packages/normalize.js.map +3 -3
  95. package/dist/packages/operations.js +1 -1
  96. package/dist/packages/operations.js.map +3 -3
  97. package/dist/path.d.ts +2 -2
  98. package/dist/path.js +1 -1
  99. package/dist/path.js.map +3 -3
  100. package/dist/paths/rewire.d.ts +71 -0
  101. package/dist/paths/rewire.js +3 -0
  102. package/dist/paths/rewire.js.map +7 -0
  103. package/dist/paths.d.ts +26 -0
  104. package/dist/paths.js +1 -1
  105. package/dist/paths.js.map +3 -3
  106. package/dist/spinner.js +1 -1
  107. package/dist/spinner.js.map +2 -2
  108. package/package.json +39 -226
  109. package/dist/env/appdata.d.ts +0 -1
  110. package/dist/env/appdata.js +0 -3
  111. package/dist/env/appdata.js.map +0 -7
  112. package/dist/env/comspec.d.ts +0 -1
  113. package/dist/env/comspec.js +0 -3
  114. package/dist/env/comspec.js.map +0 -7
  115. package/dist/env/getters.d.ts +0 -40
  116. package/dist/env/getters.js +0 -3
  117. package/dist/env/getters.js.map +0 -7
  118. package/dist/env/github-api-url.d.ts +0 -1
  119. package/dist/env/github-api-url.js +0 -3
  120. package/dist/env/github-api-url.js.map +0 -7
  121. package/dist/env/github-base-ref.d.ts +0 -1
  122. package/dist/env/github-base-ref.js +0 -3
  123. package/dist/env/github-base-ref.js.map +0 -7
  124. package/dist/env/github-ref-name.d.ts +0 -1
  125. package/dist/env/github-ref-name.js +0 -3
  126. package/dist/env/github-ref-name.js.map +0 -7
  127. package/dist/env/github-ref-type.d.ts +0 -1
  128. package/dist/env/github-ref-type.js +0 -3
  129. package/dist/env/github-ref-type.js.map +0 -7
  130. package/dist/env/github-repository.d.ts +0 -1
  131. package/dist/env/github-repository.js +0 -3
  132. package/dist/env/github-repository.js.map +0 -7
  133. package/dist/env/github-server-url.d.ts +0 -1
  134. package/dist/env/github-server-url.js +0 -3
  135. package/dist/env/github-server-url.js.map +0 -7
  136. package/dist/env/github-token.d.ts +0 -1
  137. package/dist/env/github-token.js +0 -3
  138. package/dist/env/github-token.js.map +0 -7
  139. package/dist/env/jest-worker-id.d.ts +0 -1
  140. package/dist/env/jest-worker-id.js +0 -3
  141. package/dist/env/jest-worker-id.js.map +0 -7
  142. package/dist/env/lang.d.ts +0 -1
  143. package/dist/env/lang.js +0 -3
  144. package/dist/env/lang.js.map +0 -7
  145. package/dist/env/lc-all.d.ts +0 -1
  146. package/dist/env/lc-all.js +0 -3
  147. package/dist/env/lc-all.js.map +0 -7
  148. package/dist/env/lc-messages.d.ts +0 -1
  149. package/dist/env/lc-messages.js +0 -3
  150. package/dist/env/lc-messages.js.map +0 -7
  151. package/dist/env/localappdata.d.ts +0 -1
  152. package/dist/env/localappdata.js +0 -3
  153. package/dist/env/localappdata.js.map +0 -7
  154. package/dist/env/npm-config-registry.d.ts +0 -1
  155. package/dist/env/npm-config-registry.js +0 -3
  156. package/dist/env/npm-config-registry.js.map +0 -7
  157. package/dist/env/npm-config-user-agent.d.ts +0 -1
  158. package/dist/env/npm-config-user-agent.js +0 -3
  159. package/dist/env/npm-config-user-agent.js.map +0 -7
  160. package/dist/env/npm-lifecycle-event.d.ts +0 -1
  161. package/dist/env/npm-lifecycle-event.js +0 -3
  162. package/dist/env/npm-lifecycle-event.js.map +0 -7
  163. package/dist/env/npm-registry.d.ts +0 -1
  164. package/dist/env/npm-registry.js +0 -3
  165. package/dist/env/npm-registry.js.map +0 -7
  166. package/dist/env/npm-token.d.ts +0 -1
  167. package/dist/env/npm-token.js +0 -3
  168. package/dist/env/npm-token.js.map +0 -7
  169. package/dist/env/socket-accept-risks.d.ts +0 -1
  170. package/dist/env/socket-accept-risks.js +0 -3
  171. package/dist/env/socket-accept-risks.js.map +0 -7
  172. package/dist/env/socket-api-base-url.d.ts +0 -1
  173. package/dist/env/socket-api-base-url.js +0 -3
  174. package/dist/env/socket-api-base-url.js.map +0 -7
  175. package/dist/env/socket-api-proxy.d.ts +0 -1
  176. package/dist/env/socket-api-proxy.js +0 -3
  177. package/dist/env/socket-api-proxy.js.map +0 -7
  178. package/dist/env/socket-api-timeout.d.ts +0 -1
  179. package/dist/env/socket-api-timeout.js +0 -3
  180. package/dist/env/socket-api-timeout.js.map +0 -7
  181. package/dist/env/socket-api-token.d.ts +0 -1
  182. package/dist/env/socket-api-token.js +0 -3
  183. package/dist/env/socket-api-token.js.map +0 -7
  184. package/dist/env/socket-cacache-dir.d.ts +0 -1
  185. package/dist/env/socket-cacache-dir.js +0 -3
  186. package/dist/env/socket-cacache-dir.js.map +0 -7
  187. package/dist/env/socket-cli-accept-risks.d.ts +0 -1
  188. package/dist/env/socket-cli-accept-risks.js +0 -3
  189. package/dist/env/socket-cli-accept-risks.js.map +0 -7
  190. package/dist/env/socket-cli-api-base-url.d.ts +0 -1
  191. package/dist/env/socket-cli-api-base-url.js +0 -3
  192. package/dist/env/socket-cli-api-base-url.js.map +0 -7
  193. package/dist/env/socket-cli-api-proxy.d.ts +0 -1
  194. package/dist/env/socket-cli-api-proxy.js +0 -3
  195. package/dist/env/socket-cli-api-proxy.js.map +0 -7
  196. package/dist/env/socket-cli-api-timeout.d.ts +0 -1
  197. package/dist/env/socket-cli-api-timeout.js +0 -3
  198. package/dist/env/socket-cli-api-timeout.js.map +0 -7
  199. package/dist/env/socket-cli-api-token.d.ts +0 -1
  200. package/dist/env/socket-cli-api-token.js +0 -3
  201. package/dist/env/socket-cli-api-token.js.map +0 -7
  202. package/dist/env/socket-cli-config.d.ts +0 -1
  203. package/dist/env/socket-cli-config.js +0 -3
  204. package/dist/env/socket-cli-config.js.map +0 -7
  205. package/dist/env/socket-cli-fix.d.ts +0 -1
  206. package/dist/env/socket-cli-fix.js +0 -3
  207. package/dist/env/socket-cli-fix.js.map +0 -7
  208. package/dist/env/socket-cli-no-api-token.d.ts +0 -1
  209. package/dist/env/socket-cli-no-api-token.js +0 -3
  210. package/dist/env/socket-cli-no-api-token.js.map +0 -7
  211. package/dist/env/socket-cli-optimize.d.ts +0 -1
  212. package/dist/env/socket-cli-optimize.js +0 -3
  213. package/dist/env/socket-cli-optimize.js.map +0 -7
  214. package/dist/env/socket-cli-org-slug.d.ts +0 -1
  215. package/dist/env/socket-cli-org-slug.js +0 -3
  216. package/dist/env/socket-cli-org-slug.js.map +0 -7
  217. package/dist/env/socket-cli-shadow-accept-risks.d.ts +0 -1
  218. package/dist/env/socket-cli-shadow-accept-risks.js +0 -3
  219. package/dist/env/socket-cli-shadow-accept-risks.js.map +0 -7
  220. package/dist/env/socket-cli-shadow-api-token.d.ts +0 -1
  221. package/dist/env/socket-cli-shadow-api-token.js +0 -3
  222. package/dist/env/socket-cli-shadow-api-token.js.map +0 -7
  223. package/dist/env/socket-cli-shadow-bin.d.ts +0 -1
  224. package/dist/env/socket-cli-shadow-bin.js +0 -3
  225. package/dist/env/socket-cli-shadow-bin.js.map +0 -7
  226. package/dist/env/socket-cli-shadow-progress.d.ts +0 -1
  227. package/dist/env/socket-cli-shadow-progress.js +0 -3
  228. package/dist/env/socket-cli-shadow-progress.js.map +0 -7
  229. package/dist/env/socket-cli-shadow-silent.d.ts +0 -1
  230. package/dist/env/socket-cli-shadow-silent.js +0 -3
  231. package/dist/env/socket-cli-shadow-silent.js.map +0 -7
  232. package/dist/env/socket-cli-view-all-risks.d.ts +0 -1
  233. package/dist/env/socket-cli-view-all-risks.js +0 -3
  234. package/dist/env/socket-cli-view-all-risks.js.map +0 -7
  235. package/dist/env/socket-config.d.ts +0 -1
  236. package/dist/env/socket-config.js +0 -3
  237. package/dist/env/socket-config.js.map +0 -7
  238. package/dist/env/socket-debug.d.ts +0 -1
  239. package/dist/env/socket-debug.js +0 -3
  240. package/dist/env/socket-debug.js.map +0 -7
  241. package/dist/env/socket-home.d.ts +0 -1
  242. package/dist/env/socket-home.js +0 -3
  243. package/dist/env/socket-home.js.map +0 -7
  244. package/dist/env/socket-no-api-token.d.ts +0 -1
  245. package/dist/env/socket-no-api-token.js +0 -3
  246. package/dist/env/socket-no-api-token.js.map +0 -7
  247. package/dist/env/socket-npm-registry.d.ts +0 -1
  248. package/dist/env/socket-npm-registry.js +0 -3
  249. package/dist/env/socket-npm-registry.js.map +0 -7
  250. package/dist/env/socket-org-slug.d.ts +0 -1
  251. package/dist/env/socket-org-slug.js +0 -3
  252. package/dist/env/socket-org-slug.js.map +0 -7
  253. package/dist/env/socket-registry-url.d.ts +0 -1
  254. package/dist/env/socket-registry-url.js +0 -3
  255. package/dist/env/socket-registry-url.js.map +0 -7
  256. package/dist/env/socket-view-all-risks.d.ts +0 -1
  257. package/dist/env/socket-view-all-risks.js +0 -3
  258. package/dist/env/socket-view-all-risks.js.map +0 -7
  259. package/dist/env/temp.d.ts +0 -1
  260. package/dist/env/temp.js +0 -3
  261. package/dist/env/temp.js.map +0 -7
  262. package/dist/env/tmp.d.ts +0 -1
  263. package/dist/env/tmp.js +0 -3
  264. package/dist/env/tmp.js.map +0 -7
  265. package/dist/env/tmpdir.d.ts +0 -1
  266. package/dist/env/tmpdir.js +0 -3
  267. package/dist/env/tmpdir.js.map +0 -7
  268. package/dist/env/userprofile.d.ts +0 -1
  269. package/dist/env/userprofile.js +0 -3
  270. package/dist/env/userprofile.js.map +0 -7
  271. package/dist/env/vitest.d.ts +0 -1
  272. package/dist/env/vitest.js +0 -3
  273. package/dist/env/vitest.js.map +0 -7
  274. package/dist/env/xdg-cache-home.d.ts +0 -1
  275. package/dist/env/xdg-cache-home.js +0 -3
  276. package/dist/env/xdg-cache-home.js.map +0 -7
  277. package/dist/env/xdg-config-home.d.ts +0 -1
  278. package/dist/env/xdg-config-home.js +0 -3
  279. package/dist/env/xdg-config-home.js.map +0 -7
  280. package/dist/env/xdg-data-home.d.ts +0 -1
  281. package/dist/env/xdg-data-home.js +0 -3
  282. package/dist/env/xdg-data-home.js.map +0 -7
package/dist/debug.d.ts CHANGED
@@ -18,17 +18,14 @@ export type { DebugOptions, NamespacesOrOptions, InspectOptions };
18
18
  /**
19
19
  * Debug output for object inspection with caller info.
20
20
  */
21
- /*@__NO_SIDE_EFFECTS__*/
22
21
  declare function debugDirNs(namespacesOrOpts: NamespacesOrOptions, obj: unknown, inspectOpts?: InspectOptions | undefined): void;
23
22
  /**
24
23
  * Debug output with caller info.
25
24
  */
26
- /*@__NO_SIDE_EFFECTS__*/
27
25
  declare function debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
28
26
  /**
29
27
  * Debug logging function with caller info.
30
28
  */
31
- /*@__NO_SIDE_EFFECTS__*/
32
29
  declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]): void;
33
30
  /**
34
31
  * Debug output for cache operations with caller info.
@@ -36,7 +33,6 @@ declare function debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unkn
36
33
  * Second argument is the cache key or message.
37
34
  * Optional third argument is metadata object.
38
35
  */
39
- /*@__NO_SIDE_EFFECTS__*/
40
36
  declare function debugCacheNs(namespacesOrOpts: NamespacesOrOptions, operation: string, key: string, meta?: unknown | undefined): void;
41
37
  /**
42
38
  * Cache debug function with caller info.
@@ -51,17 +47,14 @@ declare function isDebugNs(namespaces: string | undefined): boolean;
51
47
  /**
52
48
  * Debug output with caller info (wrapper for debugNs with default namespace).
53
49
  */
54
- /*@__NO_SIDE_EFFECTS__*/
55
50
  declare function debug(...args: unknown[]): void;
56
51
  /**
57
52
  * Debug output for object inspection (wrapper for debugDirNs with default namespace).
58
53
  */
59
- /*@__NO_SIDE_EFFECTS__*/
60
54
  declare function debugDir(obj: unknown, inspectOpts?: InspectOptions | undefined): void;
61
55
  /**
62
56
  * Debug logging function (wrapper for debugLogNs with default namespace).
63
57
  */
64
- /*@__NO_SIDE_EFFECTS__*/
65
58
  declare function debugLog(...args: unknown[]): void;
66
59
  /**
67
60
  * Check if debug mode is enabled.
package/dist/debug.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var A=Object.create;var h=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var W=(n,t)=>{for(var e in t)h(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of j(t))!L.call(n,o)&&o!==e&&h(n,o,{get:()=>t[o],enumerable:!(i=G(t,o))||i.enumerable});return n};var I=(n,t,e)=>(e=n!=null?A(T(n)):{},S(t||!n||!n.__esModule?h(e,"default",{value:n,enumerable:!0}):e,n)),J=n=>S(h({},"__esModule",{value:!0}),n);var Y={};W(Y,{debug:()=>P,debugCache:()=>K,debugCacheNs:()=>q,debugDir:()=>z,debugDirNs:()=>H,debugLog:()=>F,debugLogNs:()=>v,debugNs:()=>U,debuglog:()=>V,debugtime:()=>X,isDebug:()=>Q,isDebugNs:()=>M});module.exports=J(Y);var m=require("#constants/process"),C=require("#env/debug"),a=require("#env/socket-debug"),g=I(require("./external/@socketregistry/is-unicode-supported")),f=I(require("./external/debug")),d=require("./logger"),B=require("./objects"),k=require("./strings");const $=Reflect.apply,E=new Map;function _(n){let t=E.get(n);return t||(!C.DEBUG&&a.SOCKET_DEBUG&&(n==="error"||n==="notice")&&f.default.enable(n),t=(0,f.default)(n),t.log=R,E.set(n,t),t)}let D;function N(){return D===void 0&&(D=require("node:util")),D}function b(n=3){let t="";const e=Error.captureStackTrace;if(typeof e=="function"){const i={};e(i,b);const o=i.stack;if(typeof o=="string"){let u=0,c=0;for(let s=0,{length:l}=o;s<l;s+=1)if(o[s]===`
3
- `)if(u+=1,u<n)c=s+1;else{const r=o.slice(c,s).trimStart(),w=/(?<=^at\s+).*?(?=\s+\(|$)/.exec(r)?.[0];if(w&&(t=w.replace(/^(?:async|bound|get|new|set)\s+/,""),t.startsWith("Object."))){const x=t.slice(7);(0,B.hasOwn)(Object,x)||(t=x)}break}}}return t}function R(...n){const t=N(),e=f.default.inspectOpts?{...f.default.inspectOpts,showHidden:f.default.inspectOpts.showHidden===null?void 0:f.default.inspectOpts.showHidden,depth:f.default.inspectOpts.depth===null||typeof f.default.inspectOpts.depth=="boolean"?void 0:f.default.inspectOpts.depth}:{};$(d.logger.info,d.logger,[t.formatWithOptions(e,...n)])}function y(n){return n!==null&&typeof n=="object"?{__proto__:null,...n}:{__proto__:null,namespaces:n}}function O(n){if(!a.SOCKET_DEBUG)return!1;if(typeof n!="string"||!n||n==="*")return!0;const t=n.trim().replace(/\s+/g,",").split(",").filter(Boolean),e=[],i=[];for(const o of t)o.startsWith("-")?i.push(o.slice(1)):e.push(o);return e.length&&!e.some(o=>_(o).enabled)?!1:i.every(o=>!_(o).enabled)}function H(n,t,e){const i=y(n),{namespaces:o}=i;if(!O(o))return;const u=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");let c=e;if(c===void 0){const r=f.default.inspectOpts;r&&(c={...r,showHidden:r.showHidden===null?void 0:r.showHidden,depth:r.depth===null||typeof r.depth=="boolean"?null:r.depth})}const s=i.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),d.logger.info(`[DEBUG] ${u} ${p} object inspection:`),d.logger.dir(t,e),l&&s?.start()}let p;function U(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,k.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:t,s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function v(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,k.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:[`[DEBUG] ${o} ${p}`,...t],s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function q(n,t,e,i){const o=y(n),{namespaces:u}=o;if(!O(u))return;const c=b(4)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const s=`[CACHE] ${c} ${p} ${t}: ${e}`,l=i!==void 0?[s,i]:[s],r=o.spinner||(0,m.getSpinner)(),w=r?.isSpinning;r?.stop(),$(d.logger.info,d.logger,l),w&&r?.start()}function K(n,t,e){if(!a.SOCKET_DEBUG)return;const i=b(3)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const o=`[CACHE] ${i} ${p} ${n}: ${t}`;console.log(...e!==void 0?[o,e]:[o])}function M(n){return!!a.SOCKET_DEBUG&&O(n)}function P(...n){[...n]}function z(n,t){}function F(...n){[...n]}function Q(){return!!a.SOCKET_DEBUG}function V(n){return N().debuglog(n)}function X(n){const t=N();let e;const i=()=>{if(e===void 0)e=Date.now();else{const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}};return i.start=()=>{e=Date.now()},i.end=()=>{if(e!==void 0){const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}},i}0&&(module.exports={debug,debugCache,debugCacheNs,debugDir,debugDirNs,debugLog,debugLogNs,debugNs,debuglog,debugtime,isDebug,isDebugNs});
2
+ var U=Object.create;var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var W=(n,t)=>{for(var e in t)h(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of G(t))!T.call(n,o)&&o!==e&&h(n,o,{get:()=>t[o],enumerable:!(i=j(t,o))||i.enumerable});return n};var I=(n,t,e)=>(e=n!=null?U(L(n)):{},S(t||!n||!n.__esModule?h(e,"default",{value:n,enumerable:!0}):e,n)),J=n=>S(h({},"__esModule",{value:!0}),n);var Y={};W(Y,{debug:()=>z,debugCache:()=>M,debugCacheNs:()=>q,debugDir:()=>F,debugDirNs:()=>v,debugLog:()=>K,debugLogNs:()=>B,debugNs:()=>A,debuglog:()=>V,debugtime:()=>X,isDebug:()=>Q,isDebugNs:()=>P});module.exports=J(Y);var m=require("#constants/process"),E=require("#env/debug"),a=require("#env/socket"),g=I(require("./external/@socketregistry/is-unicode-supported")),f=I(require("./external/debug")),d=require("./logger"),H=require("./objects"),D=require("./strings");const $=Reflect.apply,_=new Map;function C(n){let t=_.get(n);return t||(!(0,E.getDebug)()&&(0,a.getSocketDebug)()&&(n==="error"||n==="notice")&&f.default.enable(n),t=(0,f.default)(n),t.log=R,_.set(n,t),t)}let x;function N(){return x===void 0&&(x=require("node:util")),x}function b(n=3){let t="";const e=Error.captureStackTrace;if(typeof e=="function"){const i={};e(i,b);const o=i.stack;if(typeof o=="string"){let u=0,c=0;for(let s=0,{length:l}=o;s<l;s+=1)if(o[s]===`
3
+ `)if(u+=1,u<n)c=s+1;else{const r=o.slice(c,s).trimStart(),w=/(?<=^at\s+).*?(?=\s+\(|$)/.exec(r)?.[0];if(w&&(t=w.replace(/^(?:async|bound|get|new|set)\s+/,""),t.startsWith("Object."))){const k=t.slice(7);(0,H.hasOwn)(Object,k)||(t=k)}break}}}return t}function R(...n){const t=N(),e=f.default.inspectOpts?{...f.default.inspectOpts,showHidden:f.default.inspectOpts.showHidden===null?void 0:f.default.inspectOpts.showHidden,depth:f.default.inspectOpts.depth===null||typeof f.default.inspectOpts.depth=="boolean"?void 0:f.default.inspectOpts.depth}:{};$(d.logger.info,d.logger,[t.formatWithOptions(e,...n)])}function y(n){return n!==null&&typeof n=="object"?{__proto__:null,...n}:{__proto__:null,namespaces:n}}function O(n){if(!(0,a.getSocketDebug)())return!1;if(typeof n!="string"||!n||n==="*")return!0;const t=n.trim().replace(/\s+/g,",").split(",").filter(Boolean),e=[],i=[];for(const o of t)o.startsWith("-")?i.push(o.slice(1)):e.push(o);return e.length&&!e.some(o=>C(o).enabled)?!1:i.every(o=>!C(o).enabled)}function v(n,t,e){const i=y(n),{namespaces:o}=i;if(!O(o))return;const u=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");let c=e;if(c===void 0){const r=f.default.inspectOpts;r&&(c={...r,showHidden:r.showHidden===null?void 0:r.showHidden,depth:r.depth===null||typeof r.depth=="boolean"?null:r.depth})}const s=i.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),d.logger.info(`[DEBUG] ${u} ${p} object inspection:`),d.logger.dir(t,e),l&&s?.start()}let p;function A(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,D.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:t,s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function B(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,D.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:[`[DEBUG] ${o} ${p}`,...t],s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function q(n,t,e,i){const o=y(n),{namespaces:u}=o;if(!O(u))return;const c=b(4)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const s=`[CACHE] ${c} ${p} ${t}: ${e}`,l=i!==void 0?[s,i]:[s],r=o.spinner||(0,m.getSpinner)(),w=r?.isSpinning;r?.stop(),$(d.logger.info,d.logger,l),w&&r?.start()}function M(n,t,e){if(!(0,a.getSocketDebug)())return;const i=b(3)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const o=`[CACHE] ${i} ${p} ${n}: ${t}`;console.log(...e!==void 0?[o,e]:[o])}function P(n){return!!(0,a.getSocketDebug)()&&O(n)}function z(...n){A("*",...n)}function F(n,t){v("*",n,t)}function K(...n){B("*",...n)}function Q(){return!!(0,a.getSocketDebug)()}function V(n){return N().debuglog(n)}function X(n){const t=N();let e;const i=()=>{if(e===void 0)e=Date.now();else{const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}};return i.start=()=>{e=Date.now()},i.end=()=>{if(e!==void 0){const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}},i}0&&(module.exports={debug,debugCache,debugCacheNs,debugDir,debugDirNs,debugLog,debugLogNs,debugNs,debuglog,debugtime,isDebug,isDebugNs});
4
4
  //# sourceMappingURL=debug.js.map
package/dist/debug.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/debug.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Debug logging utilities with lazy loading and environment-based control.\n * Provides Socket CLI specific debug functionality and logging formatters.\n */\n\nimport { getSpinner } from '#constants/process'\nimport { DEBUG } from '#env/debug'\nimport { SOCKET_DEBUG } from '#env/socket-debug'\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport debugJs from './external/debug'\n\nimport { logger } from './logger'\nimport { hasOwn } from './objects'\nimport { applyLinePrefix } from './strings'\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst ReflectApply = Reflect.apply\n\n// Type definitions\ninterface DebugOptions {\n namespaces?: string\n spinner?: { isSpinning: boolean; stop(): void; start(): void }\n [key: string]: unknown\n}\n\ntype NamespacesOrOptions = string | DebugOptions\n\ninterface InspectOptions {\n depth?: number | null\n colors?: boolean\n [key: string]: unknown\n}\n\nexport type { DebugOptions, NamespacesOrOptions, InspectOptions }\n\nconst debugByNamespace = new Map()\n/**\n * Get or create a debug instance for a namespace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDebugJsInstance(namespace: string) {\n let inst = debugByNamespace.get(namespace)\n if (inst) {\n return inst\n }\n if (\n !DEBUG &&\n SOCKET_DEBUG &&\n (namespace === 'error' || namespace === 'notice')\n ) {\n debugJs.enable(namespace)\n }\n inst = debugJs(namespace)\n inst.log = customLog\n debugByNamespace.set(namespace, inst)\n return inst\n}\n\nlet _util: typeof import('util') | undefined\n/**\n * Lazily load the util module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUtil() {\n if (_util === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _util = /*@__PURE__*/ require('node:util')\n }\n return _util as typeof import('util')\n}\n\n/**\n * Extract caller information from the stack trace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getCallerInfo(stackOffset: number = 3): string {\n let name = ''\n const captureStackTrace = Error.captureStackTrace\n if (typeof captureStackTrace === 'function') {\n const obj: { stack?: unknown } = {}\n captureStackTrace(obj, getCallerInfo)\n const stack = obj.stack\n if (typeof stack === 'string') {\n let lineCount = 0\n let lineStart = 0\n for (let i = 0, { length } = stack; i < length; i += 1) {\n if (stack[i] === '\\n') {\n lineCount += 1\n if (lineCount < stackOffset) {\n // Store the start index of the next line.\n lineStart = i + 1\n } else {\n // Extract the full line and trim it.\n const line = stack.slice(lineStart, i).trimStart()\n // Match the function name portion (e.g., \"async runFix\").\n const match = /(?<=^at\\s+).*?(?=\\s+\\(|$)/.exec(line)?.[0]\n if (match) {\n name = match\n // Strip known V8 invocation prefixes to get the name.\n .replace(/^(?:async|bound|get|new|set)\\s+/, '')\n if (name.startsWith('Object.')) {\n // Strip leading 'Object.' if not an own property of Object.\n const afterDot = name.slice(7 /*'Object.'.length*/)\n if (!hasOwn(Object, afterDot)) {\n name = afterDot\n }\n }\n }\n break\n }\n }\n }\n }\n }\n return name\n}\n\n/**\n * Custom log function for debug output.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction customLog(...args: unknown[]) {\n const util = getUtil()\n const inspectOpts = debugJs.inspectOpts\n ? {\n ...debugJs.inspectOpts,\n showHidden:\n debugJs.inspectOpts.showHidden === null\n ? undefined\n : debugJs.inspectOpts.showHidden,\n depth:\n debugJs.inspectOpts.depth === null ||\n typeof debugJs.inspectOpts.depth === 'boolean'\n ? undefined\n : debugJs.inspectOpts.depth,\n }\n : {}\n ReflectApply(logger.info, logger, [\n util.formatWithOptions(inspectOpts, ...args),\n ])\n}\n\n/**\n * Extract options from namespaces parameter.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction extractOptions(namespaces: NamespacesOrOptions): DebugOptions {\n return namespaces !== null && typeof namespaces === 'object'\n ? ({ __proto__: null, ...namespaces } as DebugOptions)\n : ({ __proto__: null, namespaces } as DebugOptions)\n}\n\n/**\n * Check if debug is enabled for given namespaces.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isEnabled(namespaces: string | undefined) {\n // Check if debugging is enabled at all\n if (!SOCKET_DEBUG) {\n return false\n }\n if (typeof namespaces !== 'string' || !namespaces || namespaces === '*') {\n return true\n }\n // Namespace splitting logic is based the 'debug' package implementation:\n // https://github.com/debug-js/debug/blob/4.4.1/src/common.js#L169-L173.\n const split = namespaces\n .trim()\n .replace(/\\s+/g, ',')\n .split(',')\n .filter(Boolean)\n const names = []\n const skips = []\n for (const ns of split) {\n if (ns.startsWith('-')) {\n skips.push(ns.slice(1))\n } else {\n names.push(ns)\n }\n }\n if (names.length && !names.some(ns => getDebugJsInstance(ns).enabled)) {\n return false\n }\n return skips.every(ns => !getDebugJsInstance(ns).enabled)\n}\n\n/**\n * Debug output for object inspection with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugDirNs(\n namespacesOrOpts: NamespacesOrOptions,\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugDirNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n let opts: InspectOptions | undefined = inspectOpts\n if (opts === undefined) {\n const debugOpts = debugJs.inspectOpts\n if (debugOpts) {\n opts = {\n ...debugOpts,\n showHidden:\n debugOpts.showHidden === null ? undefined : debugOpts.showHidden,\n depth:\n debugOpts.depth === null || typeof debugOpts.depth === 'boolean'\n ? null\n : debugOpts.depth,\n } as InspectOptions\n }\n }\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`)\n logger.dir(obj, inspectOpts)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\nlet pointingTriangle: string | undefined\n/**\n * Debug output with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugNs -> getCallerInfo).\n const name = getCallerInfo(4) || 'anonymous'\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${name ? `${name} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : args\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug logging function with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugLogNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${callerName ? `${callerName} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug output for cache operations with caller info.\n * First argument is the operation type (hit/miss/set/clear).\n * Second argument is the cache key or message.\n * Optional third argument is metadata object.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugCacheNs(\n namespacesOrOpts: NamespacesOrOptions,\n operation: string,\n key: string,\n meta?: unknown | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugCacheNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const logArgs = meta !== undefined ? [prefix, meta] : [prefix]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Cache debug function with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function debugCache(\n operation: string,\n key: string,\n meta?: unknown | undefined,\n): void {\n if (!SOCKET_DEBUG) {\n return\n }\n // Get caller info with stack offset of 3 (caller -> debugCache -> getCallerInfo).\n const callerName = getCallerInfo(3) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const args = meta !== undefined ? [prefix, meta] : [prefix]\n console.log(...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebugNs(namespaces: string | undefined): boolean {\n return !!SOCKET_DEBUG && isEnabled(namespaces)\n}\n\n/**\n * Debug output with caller info (wrapper for debugNs with default namespace).\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debug(...args: unknown[]): void {\n debugNs('*', ...args)\n}\n\n/**\n * Debug output for object inspection (wrapper for debugDirNs with default namespace).\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugDir(\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n): void {\n debugDirNs('*', obj, inspectOpts)\n}\n\n/**\n * Debug logging function (wrapper for debugLogNs with default namespace).\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugLog(...args: unknown[]): void {\n debugLogNs('*', ...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebug(): boolean {\n return !!SOCKET_DEBUG\n}\n\n/**\n * Create a Node.js util.debuglog compatible function.\n * Returns a function that conditionally writes debug messages to stderr.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debuglog(section: string) {\n const util = getUtil()\n return util.debuglog(section)\n}\n\n/**\n * Create timing functions for measuring code execution time.\n * Returns an object with start() and end() methods, plus a callable function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugtime(label: string) {\n const util = getUtil()\n // Node.js util doesn't have debugtime - create a custom implementation\n let startTime: number | undefined\n const impl = () => {\n if (startTime === undefined) {\n startTime = Date.now()\n } else {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n impl.start = () => {\n startTime = Date.now()\n }\n impl.end = () => {\n if (startTime !== undefined) {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n return impl\n}\n\n// Export main debug functions with caller info.\nexport { debug }\n// debugCache is already exported directly above\nexport { debugCacheNs }\nexport { debugDir }\nexport { debugDirNs }\nexport { debugLog }\nexport { debuglog }\nexport { debugLogNs }\nexport { debugNs }\nexport { debugtime }\nexport { isDebug }\nexport { isDebugNs }\n"],
5
- "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA2B,8BAC3BC,EAAsB,sBACtBC,EAA6B,6BAC7BC,EAA+B,8DAC/BF,EAAoB,+BAEpBG,EAAuB,oBACvBC,EAAuB,qBACvBC,EAAgC,qBAMhC,MAAMC,EAAe,QAAQ,MAmBvBC,EAAmB,IAAI,IAM7B,SAASC,EAAmBC,EAAmB,CAC7C,IAAIC,EAAOH,EAAiB,IAAIE,CAAS,EACzC,OAAIC,IAIF,CAAC,SACD,iBACCD,IAAc,SAAWA,IAAc,WAExC,EAAAE,QAAQ,OAAOF,CAAS,EAE1BC,KAAO,EAAAC,SAAQF,CAAS,E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SAAS9C,KAAS0C,EAAuB,CAC1B,IAAGA,EAClB,CAMA,SAASvC,EACP8B,EACAW,EACM,CAER,CAMA,SAASvC,KAAYqC,EAAuB,CAC1B,IAAGA,EACrB,CAMA,SAAShC,GAAmB,CAC1B,MAAO,CAAC,CAAC,cACX,CAOA,SAASF,EAAS2D,EAAiB,CAEjC,OADavC,EAAQ,EACT,SAASuC,CAAO,CAC9B,CAOA,SAAS1D,EAAU2D,EAAe,CAChC,MAAMzB,EAAOf,EAAQ,EAErB,IAAIyC,EACJ,MAAMC,EAAO,IAAM,CACjB,GAAID,IAAc,OAChBA,EAAY,KAAK,IAAI,MAChB,CACL,MAAME,EAAW,KAAK,IAAI,EAAIF,EAC9B1B,EAAK,SAAS,MAAM,EAAE,GAAGyB,CAAK,KAAKG,CAAQ,IAAI,EAC/CF,EAAY,MACd,CACF,EACA,OAAAC,EAAK,MAAQ,IAAM,CACjBD,EAAY,KAAK,IAAI,CACvB,EACAC,EAAK,IAAM,IAAM,CACf,GAAID,IAAc,OAAW,CAC3B,MAAME,EAAW,KAAK,IAAI,EAAIF,EAC9B1B,EAAK,SAAS,MAAM,EAAE,GAAGyB,CAAK,KAAKG,CAAQ,IAAI,EAC/CF,EAAY,MACd,CACF,EACOC,CACT",
6
- "names": ["debug_exports", "__export", "debug", "debugCache", "debugCacheNs", "debugDir", "debugDirNs", "debugLog", "debugLogNs", "debugNs", "debuglog", "debugtime", "isDebug", "isDebugNs", "__toCommonJS", "import_process", "import_debug", "import_socket_debug", "import_is_unicode_supported", "import_logger", "import_objects", "import_strings", "ReflectApply", "debugByNamespace", "getDebugJsInstance", "namespace", "inst", "debugJs", "customLog", "_util", "getUtil", "getCallerInfo", "stackOffset", "name", "captureStackTrace", "obj", "stack", "lineCount", "lineStart", "i", "length", "line", "match", "afterDot", "args", "util", "inspectOpts", "extractOptions", "namespaces", "isEnabled", "split", "names", "skips", "ns", "namespacesOrOpts", "options", "callerName", "pointingTriangle", "isUnicodeSupported", "opts", "debugOpts", "spinnerInstance", "wasSpinning", "text", "logArgs", "operation", "key", "meta", "prefix", "section", "label", "startTime", "impl", "duration"]
4
+ "sourcesContent": ["/**\n * @fileoverview Debug logging utilities with lazy loading and environment-based control.\n * Provides Socket CLI specific debug functionality and logging formatters.\n */\n\nimport { getSpinner } from '#constants/process'\nimport { getDebug } from '#env/debug'\nimport { getSocketDebug } from '#env/socket'\nimport isUnicodeSupported from './external/@socketregistry/is-unicode-supported'\nimport debugJs from './external/debug'\n\nimport { logger } from './logger'\nimport { hasOwn } from './objects'\nimport { applyLinePrefix } from './strings'\n\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst ReflectApply = Reflect.apply\n\n// Type definitions\ninterface DebugOptions {\n namespaces?: string\n spinner?: { isSpinning: boolean; stop(): void; start(): void }\n [key: string]: unknown\n}\n\ntype NamespacesOrOptions = string | DebugOptions\n\ninterface InspectOptions {\n depth?: number | null\n colors?: boolean\n [key: string]: unknown\n}\n\nexport type { DebugOptions, NamespacesOrOptions, InspectOptions }\n\nconst debugByNamespace = new Map()\n/**\n * Get or create a debug instance for a namespace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getDebugJsInstance(namespace: string) {\n let inst = debugByNamespace.get(namespace)\n if (inst) {\n return inst\n }\n if (\n !getDebug() &&\n getSocketDebug() &&\n (namespace === 'error' || namespace === 'notice')\n ) {\n debugJs.enable(namespace)\n }\n inst = debugJs(namespace)\n inst.log = customLog\n debugByNamespace.set(namespace, inst)\n return inst\n}\n\nlet _util: typeof import('util') | undefined\n/**\n * Lazily load the util module.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUtil() {\n if (_util === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _util = /*@__PURE__*/ require('node:util')\n }\n return _util as typeof import('util')\n}\n\n/**\n * Extract caller information from the stack trace.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getCallerInfo(stackOffset: number = 3): string {\n let name = ''\n const captureStackTrace = Error.captureStackTrace\n if (typeof captureStackTrace === 'function') {\n const obj: { stack?: unknown } = {}\n captureStackTrace(obj, getCallerInfo)\n const stack = obj.stack\n if (typeof stack === 'string') {\n let lineCount = 0\n let lineStart = 0\n for (let i = 0, { length } = stack; i < length; i += 1) {\n if (stack[i] === '\\n') {\n lineCount += 1\n if (lineCount < stackOffset) {\n // Store the start index of the next line.\n lineStart = i + 1\n } else {\n // Extract the full line and trim it.\n const line = stack.slice(lineStart, i).trimStart()\n // Match the function name portion (e.g., \"async runFix\").\n const match = /(?<=^at\\s+).*?(?=\\s+\\(|$)/.exec(line)?.[0]\n if (match) {\n name = match\n // Strip known V8 invocation prefixes to get the name.\n .replace(/^(?:async|bound|get|new|set)\\s+/, '')\n if (name.startsWith('Object.')) {\n // Strip leading 'Object.' if not an own property of Object.\n const afterDot = name.slice(7 /*'Object.'.length*/)\n if (!hasOwn(Object, afterDot)) {\n name = afterDot\n }\n }\n }\n break\n }\n }\n }\n }\n }\n return name\n}\n\n/**\n * Custom log function for debug output.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction customLog(...args: unknown[]) {\n const util = getUtil()\n const inspectOpts = debugJs.inspectOpts\n ? {\n ...debugJs.inspectOpts,\n showHidden:\n debugJs.inspectOpts.showHidden === null\n ? undefined\n : debugJs.inspectOpts.showHidden,\n depth:\n debugJs.inspectOpts.depth === null ||\n typeof debugJs.inspectOpts.depth === 'boolean'\n ? undefined\n : debugJs.inspectOpts.depth,\n }\n : {}\n ReflectApply(logger.info, logger, [\n util.formatWithOptions(inspectOpts, ...args),\n ])\n}\n\n/**\n * Extract options from namespaces parameter.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction extractOptions(namespaces: NamespacesOrOptions): DebugOptions {\n return namespaces !== null && typeof namespaces === 'object'\n ? ({ __proto__: null, ...namespaces } as DebugOptions)\n : ({ __proto__: null, namespaces } as DebugOptions)\n}\n\n/**\n * Check if debug is enabled for given namespaces.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isEnabled(namespaces: string | undefined) {\n // Check if debugging is enabled at all\n if (!getSocketDebug()) {\n return false\n }\n if (typeof namespaces !== 'string' || !namespaces || namespaces === '*') {\n return true\n }\n // Namespace splitting logic is based the 'debug' package implementation:\n // https://github.com/debug-js/debug/blob/4.4.1/src/common.js#L169-L173.\n const split = namespaces\n .trim()\n .replace(/\\s+/g, ',')\n .split(',')\n .filter(Boolean)\n const names = []\n const skips = []\n for (const ns of split) {\n if (ns.startsWith('-')) {\n skips.push(ns.slice(1))\n } else {\n names.push(ns)\n }\n }\n if (names.length && !names.some(ns => getDebugJsInstance(ns).enabled)) {\n return false\n }\n return skips.every(ns => !getDebugJsInstance(ns).enabled)\n}\n\n/**\n * Debug output for object inspection with caller info.\n */\nfunction debugDirNs(\n namespacesOrOpts: NamespacesOrOptions,\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugDirNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n let opts: InspectOptions | undefined = inspectOpts\n if (opts === undefined) {\n const debugOpts = debugJs.inspectOpts\n if (debugOpts) {\n opts = {\n ...debugOpts,\n showHidden:\n debugOpts.showHidden === null ? undefined : debugOpts.showHidden,\n depth:\n debugOpts.depth === null || typeof debugOpts.depth === 'boolean'\n ? null\n : debugOpts.depth,\n } as InspectOptions\n }\n }\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`)\n logger.dir(obj, inspectOpts)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\nlet pointingTriangle: string | undefined\n/**\n * Debug output with caller info.\n */\nfunction debugNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugNs -> getCallerInfo).\n const name = getCallerInfo(4) || 'anonymous'\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${name ? `${name} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : args\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug logging function with caller info.\n */\nfunction debugLogNs(namespacesOrOpts: NamespacesOrOptions, ...args: unknown[]) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugLogNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'anonymous'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const text = args.at(0)\n const logArgs =\n typeof text === 'string'\n ? [\n applyLinePrefix(\n `${callerName ? `${callerName} ${pointingTriangle} ` : ''}${text}`,\n { prefix: '[DEBUG] ' },\n ),\n ...args.slice(1),\n ]\n : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Debug output for cache operations with caller info.\n * First argument is the operation type (hit/miss/set/clear).\n * Second argument is the cache key or message.\n * Optional third argument is metadata object.\n */\nfunction debugCacheNs(\n namespacesOrOpts: NamespacesOrOptions,\n operation: string,\n key: string,\n meta?: unknown | undefined,\n) {\n const options = extractOptions(namespacesOrOpts)\n const { namespaces } = options\n if (!isEnabled(namespaces as string)) {\n return\n }\n // Get caller info with stack offset of 4 (caller -> debugCacheNs -> getCallerInfo).\n const callerName = getCallerInfo(4) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const logArgs = meta !== undefined ? [prefix, meta] : [prefix]\n\n const spinnerInstance = options.spinner || getSpinner()\n const wasSpinning = spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n ReflectApply(logger.info, logger, logArgs)\n if (wasSpinning) {\n spinnerInstance?.start()\n }\n}\n\n/**\n * Cache debug function with caller info.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function debugCache(\n operation: string,\n key: string,\n meta?: unknown | undefined,\n): void {\n if (!getSocketDebug()) {\n return\n }\n // Get caller info with stack offset of 3 (caller -> debugCache -> getCallerInfo).\n const callerName = getCallerInfo(3) || 'cache'\n\n if (pointingTriangle === undefined) {\n const supported = isUnicodeSupported()\n pointingTriangle = supported ? '\u25B8' : '>'\n }\n\n const prefix = `[CACHE] ${callerName} ${pointingTriangle} ${operation}: ${key}`\n const args = meta !== undefined ? [prefix, meta] : [prefix]\n console.log(...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebugNs(namespaces: string | undefined): boolean {\n return !!getSocketDebug() && isEnabled(namespaces)\n}\n\n/**\n * Debug output with caller info (wrapper for debugNs with default namespace).\n */\nfunction debug(...args: unknown[]): void {\n debugNs('*', ...args)\n}\n\n/**\n * Debug output for object inspection (wrapper for debugDirNs with default namespace).\n */\nfunction debugDir(\n obj: unknown,\n inspectOpts?: InspectOptions | undefined,\n): void {\n debugDirNs('*', obj, inspectOpts)\n}\n\n/**\n * Debug logging function (wrapper for debugLogNs with default namespace).\n */\nfunction debugLog(...args: unknown[]): void {\n debugLogNs('*', ...args)\n}\n\n/**\n * Check if debug mode is enabled.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isDebug(): boolean {\n return !!getSocketDebug()\n}\n\n/**\n * Create a Node.js util.debuglog compatible function.\n * Returns a function that conditionally writes debug messages to stderr.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debuglog(section: string) {\n const util = getUtil()\n return util.debuglog(section)\n}\n\n/**\n * Create timing functions for measuring code execution time.\n * Returns an object with start() and end() methods, plus a callable function.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction debugtime(label: string) {\n const util = getUtil()\n // Node.js util doesn't have debugtime - create a custom implementation\n let startTime: number | undefined\n const impl = () => {\n if (startTime === undefined) {\n startTime = Date.now()\n } else {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n impl.start = () => {\n startTime = Date.now()\n }\n impl.end = () => {\n if (startTime !== undefined) {\n const duration = Date.now() - startTime\n util.debuglog('time')(`${label}: ${duration}ms`)\n startTime = undefined\n }\n }\n return impl\n}\n\n// Export main debug functions with caller info.\nexport { debug }\n// debugCache is already exported directly above\nexport { debugCacheNs }\nexport { debugDir }\nexport { debugDirNs }\nexport { debugLog }\nexport { debuglog }\nexport { debugLogNs }\nexport { debugNs }\nexport { debugtime }\nexport { isDebug }\nexport { isDebugNs }\n"],
5
+ "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,aAAAC,E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IAAc,OAAW,CAC3B,MAAME,EAAW,KAAK,IAAI,EAAIF,EAC9B1B,EAAK,SAAS,MAAM,EAAE,GAAGyB,CAAK,KAAKG,CAAQ,IAAI,EAC/CF,EAAY,MACd,CACF,EACOC,CACT",
6
+ "names": ["debug_exports", "__export", "debug", "debugCache", "debugCacheNs", "debugDir", "debugDirNs", "debugLog", "debugLogNs", "debugNs", "debuglog", "debugtime", "isDebug", "isDebugNs", "__toCommonJS", "import_process", "import_debug", "import_socket", "import_is_unicode_supported", "import_logger", "import_objects", "import_strings", "ReflectApply", "debugByNamespace", "getDebugJsInstance", "namespace", "inst", "debugJs", "customLog", "_util", "getUtil", "getCallerInfo", "stackOffset", "name", "captureStackTrace", "obj", "stack", "lineCount", "lineStart", "i", "length", "line", "match", "afterDot", "args", "util", "inspectOpts", "extractOptions", "namespaces", "isEnabled", "split", "names", "skips", "ns", "namespacesOrOpts", "options", "callerName", "pointingTriangle", "isUnicodeSupported", "opts", "debugOpts", "spinnerInstance", "wasSpinning", "text", "logArgs", "operation", "key", "meta", "prefix", "section", "label", "startTime", "impl", "duration"]
7
7
  }
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var H=Object.create;var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var q=(t,n)=>{for(var e in n)x(t,e,{get:n[e],enumerable:!0})},C=(t,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of z(n))!L.call(t,r)&&r!==e&&x(t,r,{get:()=>n[r],enumerable:!(a=N(n,r))||a.enumerable});return t};var O=(t,n,e)=>(e=t!=null?H(F(t)):{},C(n||!t||!t.__esModule?x(e,"default",{value:t,enumerable:!0}):e,t)),I=t=>C(x({},"__esModule",{value:!0}),t);var G={};q(G,{cleanDlxCache:()=>X,dlxBinary:()=>Y,getDlxCachePath:()=>P,listDlxCache:()=>V});module.exports=I(G);var j=require("node:crypto"),s=require("node:fs"),D=O(require("node:os")),l=O(require("node:path")),A=require("#constants/platform"),m=require("./fs"),R=require("./http-request"),S=require("./objects"),$=require("./path"),T=require("./paths"),_=require("./spawn");function J(t){return(0,j.createHash)("sha256").update(t).digest("hex")}function g(t){return l.default.join(t,".dlx-metadata.json")}async function K(t,n){try{const e=g(t);if(!(0,s.existsSync)(e))return!1;const a=await(0,m.readJson)(e,{throws:!1});return(0,S.isObjectObject)(a)?Date.now()-(a.timestamp||0)<n:!1}catch{return!1}}async function M(t,n,e){const a=await(0,R.httpRequest)(t);if(!a.ok)throw new Error(`Failed to download binary: ${a.status} ${a.statusText}`);const r=`${n}.download`,c=(0,j.createHash)("sha256");try{await s.promises.mkdir(l.default.dirname(n),{recursive:!0});const i=a.body;c.update(i);const o=c.digest("hex");if(e&&o!==e)throw new Error(`Checksum mismatch: expected ${e}, got ${o}`);return await s.promises.writeFile(r,i),A.WIN32||await s.promises.chmod(r,493),await s.promises.rename(r,n),o}catch(i){try{await(0,m.safeDelete)(r)}catch{}throw i}}async function W(t,n,e){const a=g(t),r={arch:D.default.arch(),checksum:e,platform:D.default.platform(),timestamp:Date.now(),url:n,version:"1.0.0"};await s.promises.writeFile(a,JSON.stringify(r,null,2))}async function X(t=require("./constants/time").DLX_BINARY_CACHE_TTL){const n=P();if(!(0,s.existsSync)(n))return 0;let e=0;const a=Date.now(),r=await s.promises.readdir(n);for(const c of r){const i=l.default.join(n,c),o=g(i);try{if(!await(0,m.isDir)(i))continue;const u=await(0,m.readJson)(o,{throws:!1});if(!u||typeof u!="object"||Array.isArray(u))continue;a-(u.timestamp||0)>t&&(await(0,m.safeDelete)(i,{force:!0,recursive:!0}),e+=1)}catch{try{(await s.promises.readdir(i)).length||(await(0,m.safeDelete)(i),e+=1)}catch{}}}return e}async function Y(t,n,e){const{cacheTtl:a=require("./constants/time").DLX_BINARY_CACHE_TTL,checksum:r,force:c=!1,name:i,spawnOptions:o,url:u}={__proto__:null,...n},h=P(),p=J(u),f=l.default.join(h,p),d=i||`binary-${process.platform}-${D.default.arch()}`,b=(0,$.normalizePath)(l.default.join(f,d));let w=!1,k=r;if(!c&&(0,s.existsSync)(f)&&await K(f,a))try{const E=g(f),y=await(0,m.readJson)(E,{throws:!1});y&&typeof y=="object"&&!Array.isArray(y)&&typeof y.checksum=="string"?k=y.checksum:w=!0}catch{w=!0}else w=!0;w&&(await s.promises.mkdir(f,{recursive:!0}),k=await M(u,b,r),await W(f,u,k||""));const B=A.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(b)?{...o,env:{...o?.env,PATH:`${f}${l.default.delimiter}${process.env.PATH||""}`},shell:!0}:o,v=(0,_.spawn)(b,t,B,e);return{binaryPath:b,downloaded:w,spawnPromise:v}}function P(){return(0,T.getSocketDlxDir)()}async function V(){const t=P();if(!(0,s.existsSync)(t))return[];const n=[],e=Date.now(),a=await s.promises.readdir(t);for(const r of a){const c=l.default.join(t,r);try{if(!await(0,m.isDir)(c))continue;const i=g(c),o=await(0,m.readJson)(i,{throws:!1});if(!o||typeof o!="object"||Array.isArray(o))continue;const h=(await s.promises.readdir(c)).find(p=>!p.startsWith("."));if(h){const p=l.default.join(c,h),f=await s.promises.stat(p),d=o;n.push({age:e-(d.timestamp||0),arch:d.arch||"unknown",checksum:d.checksum||"",name:h,platform:d.platform||"unknown",size:f.size,url:d.url||""})}}catch{}}return n}0&&(module.exports={cleanDlxCache,dlxBinary,getDlxCachePath,listDlxCache});
2
+ var I=Object.create;var b=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var L=(t,n)=>{for(var e in n)b(t,e,{get:n[e],enumerable:!0})},O=(t,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of F(n))!z.call(t,r)&&r!==e&&b(t,r,{get:()=>n[r],enumerable:!(a=N(n,r))||a.enumerable});return t};var $=(t,n,e)=>(e=t!=null?I(H(t)):{},O(n||!t||!t.__esModule?b(e,"default",{value:t,enumerable:!0}):e,t)),q=t=>O(b({},"__esModule",{value:!0}),t);var G={};L(G,{cleanDlxCache:()=>V,dlxBinary:()=>W,getDlxCachePath:()=>P,listDlxCache:()=>X});module.exports=q(G);var j=require("node:crypto"),s=require("node:fs"),x=$(require("node:os")),p=$(require("node:path")),A=require("#constants/platform"),u=require("./fs"),C=require("./http-request"),S=require("./objects"),T=require("./path"),R=require("./paths"),_=require("./spawn");function Y(t,n){return(0,j.createHash)("sha256").update(`${t}:${n}`).digest("hex")}function y(t){return p.default.join(t,".dlx-metadata.json")}async function J(t,n){try{const e=y(t);if(!(0,s.existsSync)(e))return!1;const a=await(0,u.readJson)(e,{throws:!1});if(!(0,S.isObjectObject)(a))return!1;const r=Date.now(),i=a.timestamp;return typeof i!="number"||i<=0?!1:r-i<n}catch{return!1}}async function K(t,n,e){const a=await(0,C.httpRequest)(t);if(!a.ok)throw new Error(`Failed to download binary: ${a.status} ${a.statusText}`);const r=`${n}.download`,i=(0,j.createHash)("sha256");try{await s.promises.mkdir(p.default.dirname(n),{recursive:!0});const o=a.body;i.update(o);const c=i.digest("hex");if(e&&c!==e)throw new Error(`Checksum mismatch: expected ${e}, got ${c}`);return await s.promises.writeFile(r,o),A.WIN32||await s.promises.chmod(r,493),await s.promises.rename(r,n),c}catch(o){try{await(0,u.safeDelete)(r)}catch{}throw o}}async function M(t,n,e){const a=y(t),r={arch:x.default.arch(),checksum:e,platform:x.default.platform(),timestamp:Date.now(),url:n,version:"1.0.0"};await s.promises.writeFile(a,JSON.stringify(r,null,2))}async function V(t=require("#constants/time").DLX_BINARY_CACHE_TTL){const n=P();if(!(0,s.existsSync)(n))return 0;let e=0;const a=Date.now(),r=await s.promises.readdir(n);for(const i of r){const o=p.default.join(n,i),c=y(o);try{if(!await(0,u.isDir)(o))continue;const f=await(0,u.readJson)(c,{throws:!1});if(!f||typeof f!="object"||Array.isArray(f))continue;const l=f.timestamp;(typeof l=="number"&&l>0?a-l:Number.POSITIVE_INFINITY)>t&&(await(0,u.safeDelete)(o,{force:!0,recursive:!0}),e+=1)}catch{try{(await s.promises.readdir(o)).length||(await(0,u.safeDelete)(o),e+=1)}catch{}}}return e}async function W(t,n,e){const{cacheTtl:a=require("#constants/time").DLX_BINARY_CACHE_TTL,checksum:r,force:i=!1,name:o,spawnOptions:c,url:f}={__proto__:null,...n},l=P(),d=o||`binary-${process.platform}-${x.default.arch()}`,D=Y(f,d),m=p.default.join(l,D),g=(0,T.normalizePath)(p.default.join(m,d));let h=!1,k=r;if(!i&&(0,s.existsSync)(m)&&await J(m,a))try{const E=y(m),w=await(0,u.readJson)(E,{throws:!1});w&&typeof w=="object"&&!Array.isArray(w)&&typeof w.checksum=="string"?k=w.checksum:h=!0}catch{h=!0}else h=!0;h&&(await s.promises.mkdir(m,{recursive:!0}),k=await K(f,g,r),await M(m,f,k||""));const B=A.WIN32&&/\.(?:bat|cmd|ps1)$/i.test(g)?{...c,env:{...c?.env,PATH:`${m}${p.default.delimiter}${process.env.PATH||""}`},shell:!0}:c,v=(0,_.spawn)(g,t,B,e);return{binaryPath:g,downloaded:h,spawnPromise:v}}function P(){return(0,R.getSocketDlxDir)()}async function X(){const t=P();if(!(0,s.existsSync)(t))return[];const n=[],e=Date.now(),a=await s.promises.readdir(t);for(const r of a){const i=p.default.join(t,r);try{if(!await(0,u.isDir)(i))continue;const o=y(i),c=await(0,u.readJson)(o,{throws:!1});if(!c||typeof c!="object"||Array.isArray(c))continue;const l=(await s.promises.readdir(i)).find(d=>!d.startsWith("."));if(l){const d=p.default.join(i,l),D=await s.promises.stat(d),m=c;n.push({age:e-(m.timestamp||0),arch:m.arch||"unknown",checksum:m.checksum||"",name:l,platform:m.platform||"unknown",size:D.size,url:m.url||""})}}catch{}}return n}0&&(module.exports={cleanDlxCache,dlxBinary,getDlxCachePath,listDlxCache});
3
3
  //# sourceMappingURL=dlx-binary.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/dlx-binary.ts"],
4
- "sourcesContent": ["/** @fileoverview DLX binary execution utilities for Socket ecosystem. */\n\nimport { createHash } from 'node:crypto'\nimport { existsSync, promises as fs } from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport { WIN32 } from '#constants/platform'\n\nimport { isDir, readJson, safeDelete } from './fs'\nimport { httpRequest } from './http-request'\nimport { isObjectObject } from './objects'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport type { SpawnExtra, SpawnOptions } from './spawn'\nimport { spawn } from './spawn'\n\nexport interface DlxBinaryOptions {\n /** URL to download the binary from. */\n url: string\n /** Optional name for the cached binary (defaults to URL hash). */\n name?: string | undefined\n /** Expected checksum (sha256) for verification. */\n checksum?: string | undefined\n /** Cache TTL in milliseconds (default: 7 days). */\n cacheTtl?: number | undefined\n /** Force re-download even if cached. */\n force?: boolean | undefined\n /** Additional spawn options. */\n spawnOptions?: SpawnOptions | undefined\n}\n\nexport interface DlxBinaryResult {\n /** Path to the cached binary. */\n binaryPath: string\n /** Whether the binary was newly downloaded. */\n downloaded: boolean\n /** The spawn promise for the running process. */\n spawnPromise: ReturnType<typeof spawn>\n}\n\n/**\n * Generate a cache directory name from URL, similar to pnpm/npx.\n * Uses SHA256 hash to create content-addressed storage.\n */\nfunction generateCacheKey(url: string): string {\n return createHash('sha256').update(url).digest('hex')\n}\n\n/**\n * Get metadata file path for a cached binary.\n */\nfunction getMetadataPath(cacheEntryPath: string): string {\n return path.join(cacheEntryPath, '.dlx-metadata.json')\n}\n\n/**\n * Check if a cached binary is still valid.\n */\nasync function isCacheValid(\n cacheEntryPath: string,\n cacheTtl: number,\n): Promise<boolean> {\n try {\n const metaPath = getMetadataPath(cacheEntryPath)\n if (!existsSync(metaPath)) {\n return false\n }\n\n const metadata = await readJson(metaPath, { throws: false })\n if (!isObjectObject(metadata)) {\n return false\n }\n const now = Date.now()\n const age =\n now -\n (((metadata as Record<string, unknown>)['timestamp'] as number) || 0)\n\n return age < cacheTtl\n } catch {\n return false\n }\n}\n\n/**\n * Download a file from a URL with integrity checking.\n */\nasync function downloadBinary(\n url: string,\n destPath: string,\n checksum?: string | undefined,\n): Promise<string> {\n const response = await httpRequest(url)\n if (!response.ok) {\n throw new Error(\n `Failed to download binary: ${response.status} ${response.statusText}`,\n )\n }\n\n // Create a temporary file first.\n const tempPath = `${destPath}.download`\n const hasher = createHash('sha256')\n\n try {\n // Ensure directory exists.\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n\n // Get the response as a buffer and compute hash.\n const buffer = response.body\n\n // Compute hash.\n hasher.update(buffer)\n const actualChecksum = hasher.digest('hex')\n\n // Verify checksum if provided.\n if (checksum && actualChecksum !== checksum) {\n throw new Error(\n `Checksum mismatch: expected ${checksum}, got ${actualChecksum}`,\n )\n }\n\n // Write to temp file.\n await fs.writeFile(tempPath, buffer)\n\n // Make executable on POSIX systems.\n if (!WIN32) {\n await fs.chmod(tempPath, 0o755)\n }\n\n // Move temp file to final location.\n await fs.rename(tempPath, destPath)\n\n return actualChecksum\n } catch (e) {\n // Clean up temp file on error.\n try {\n await safeDelete(tempPath)\n } catch {\n // Ignore cleanup errors.\n }\n throw e\n }\n}\n\n/**\n * Write metadata for a cached binary.\n */\nasync function writeMetadata(\n cacheEntryPath: string,\n url: string,\n checksum: string,\n): Promise<void> {\n const metaPath = getMetadataPath(cacheEntryPath)\n const metadata = {\n arch: os.arch(),\n checksum,\n platform: os.platform(),\n timestamp: Date.now(),\n url,\n version: '1.0.0',\n }\n await fs.writeFile(metaPath, JSON.stringify(metadata, null, 2))\n}\n\n/**\n * Clean expired entries from the DLX cache.\n */\nexport async function cleanDlxCache(\n maxAge: number = /*@__INLINE__*/ require('../constants/time').DLX_BINARY_CACHE_TTL,\n): Promise<number> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return 0\n }\n\n let cleaned = 0\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n const metaPath = getMetadataPath(entryPath)\n\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n const age =\n now -\n (((metadata as Record<string, unknown>)['timestamp'] as number) || 0)\n\n if (age > maxAge) {\n // Remove entire cache entry directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath, { force: true, recursive: true })\n cleaned += 1\n }\n } catch {\n // If we can't read metadata, check if directory is empty or corrupted.\n try {\n // eslint-disable-next-line no-await-in-loop\n const contents = await fs.readdir(entryPath)\n if (!contents.length) {\n // Remove empty directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath)\n cleaned += 1\n }\n } catch {}\n }\n }\n\n return cleaned\n}\n\n/**\n * Download and execute a binary from a URL with caching.\n */\nexport async function dlxBinary(\n args: readonly string[] | string[],\n options?: DlxBinaryOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): Promise<DlxBinaryResult> {\n const {\n cacheTtl = /*@__INLINE__*/ require('../constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n spawnOptions,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const cacheKey = generateCacheKey(url)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n let computedChecksum = checksum\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid, read the checksum from metadata.\n try {\n const metaPath = getMetadataPath(cacheEntryDir)\n const metadata = await readJson(metaPath, { throws: false })\n if (\n metadata &&\n typeof metadata === 'object' &&\n !Array.isArray(metadata) &&\n typeof (metadata as Record<string, unknown>)['checksum'] === 'string'\n ) {\n computedChecksum = (metadata as Record<string, unknown>)[\n 'checksum'\n ] as string\n } else {\n // If metadata is invalid, re-download.\n downloaded = true\n }\n } catch {\n // If we can't read metadata, re-download.\n downloaded = true\n }\n } else {\n downloaded = true\n }\n\n if (downloaded) {\n // Ensure cache directory exists.\n await fs.mkdir(cacheEntryDir, { recursive: true })\n\n // Download the binary.\n computedChecksum = await downloadBinary(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n }\n\n // Execute the binary.\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension (e.g.,\n // C:\\cache\\test.cmd becomes just \"test\"). Windows cmd.exe then searches for \"test\"\n // in directories listed in PATH, trying each extension from PATHEXT environment\n // variable (.COM, .EXE, .BAT, .CMD, etc.) until it finds a match.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH\n // (unlike system package managers like npm/pnpm/yarn which are already in PATH),\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n //\n // This approach is consistent with how other tools handle Windows command execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - Node.js spawn with shell: true: delegates to cmd.exe which uses PATH\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n const spawnPromise = spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n\n return {\n binaryPath,\n downloaded,\n spawnPromise,\n }\n}\n\n/**\n * Get the DLX binary cache directory path.\n * Returns normalized path for cross-platform compatibility.\n * Uses same directory as dlx-package for unified DLX storage.\n */\nexport function getDlxCachePath(): string {\n return getSocketDlxDir()\n}\n\n/**\n * Get information about cached binaries.\n */\nexport async function listDlxCache(): Promise<\n Array<{\n age: number\n arch: string\n checksum: string\n name: string\n platform: string\n size: number\n url: string\n }>\n> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return []\n }\n\n const results = []\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n const metaPath = getMetadataPath(entryPath)\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n\n // Find the binary file in the directory.\n // eslint-disable-next-line no-await-in-loop\n const files = await fs.readdir(entryPath)\n const binaryFile = files.find(f => !f.startsWith('.'))\n\n if (binaryFile) {\n const binaryPath = path.join(entryPath, binaryFile)\n // eslint-disable-next-line no-await-in-loop\n const binaryStats = await fs.stat(binaryPath)\n\n const metaObj = metadata as Record<string, unknown>\n results.push({\n age: now - ((metaObj['timestamp'] as number) || 0),\n arch: (metaObj['arch'] as string) || 'unknown',\n checksum: (metaObj['checksum'] as string) || '',\n name: binaryFile,\n platform: (metaObj['platform'] as string) || 'unknown',\n size: binaryStats.size,\n url: (metaObj['url'] as string) || '',\n })\n }\n } catch {}\n }\n\n return results\n}\n"],
5
- "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,cAAAC,EAAA,oBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAN,GAEA,IAAAO,EAA2B,uBAC3BC,EAA2C,mBAC3CC,EAAe,sBACf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Cache", "dlxBinary", "getDlxCachePath", "listDlxCache", "__toCommonJS", "import_node_crypto", "import_node_fs", "import_node_os", "import_node_path", "import_platform", "import_fs", "import_http_request", "import_objects", "import_path", "import_paths", "import_spawn", "generateCacheKey", "url", "getMetadataPath", "cacheEntryPath", "path", "isCacheValid", "cacheTtl", "metaPath", "metadata", "downloadBinary", "destPath", "checksum", "response", "tempPath", "hasher", "fs", "buffer", "actualChecksum", "e", "writeMetadata", "os", "maxAge", "cacheDir", "cleaned", "now", "entries", "entry", "entryPath", "args", "options", "spawnExtra", "force", "name", "spawnOptions", "cacheKey", "cacheEntryDir", "binaryName", "binaryPath", "downloaded", "computedChecksum", "finalSpawnOptions", "spawnPromise", "results", "binaryFile", "f", "binaryStats", "metaObj"]
4
+ "sourcesContent": ["/** @fileoverview DLX binary execution utilities for Socket ecosystem. */\n\nimport { createHash } from 'node:crypto'\nimport { existsSync, promises as fs } from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport { WIN32 } from '#constants/platform'\n\nimport { isDir, readJson, safeDelete } from './fs'\nimport { httpRequest } from './http-request'\nimport { isObjectObject } from './objects'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport type { SpawnExtra, SpawnOptions } from './spawn'\nimport { spawn } from './spawn'\n\nexport interface DlxBinaryOptions {\n /** URL to download the binary from. */\n url: string\n /** Optional name for the cached binary (defaults to URL hash). */\n name?: string | undefined\n /** Expected checksum (sha256) for verification. */\n checksum?: string | undefined\n /** Cache TTL in milliseconds (default: 7 days). */\n cacheTtl?: number | undefined\n /** Force re-download even if cached. */\n force?: boolean | undefined\n /** Additional spawn options. */\n spawnOptions?: SpawnOptions | undefined\n}\n\nexport interface DlxBinaryResult {\n /** Path to the cached binary. */\n binaryPath: string\n /** Whether the binary was newly downloaded. */\n downloaded: boolean\n /** The spawn promise for the running process. */\n spawnPromise: ReturnType<typeof spawn>\n}\n\n/**\n * Generate a cache directory name from URL and binary name.\n * Uses SHA256 hash to create content-addressed storage.\n * Includes binary name to prevent collisions when multiple binaries\n * are downloaded from the same URL with different names.\n */\nfunction generateCacheKey(url: string, name: string): string {\n return createHash('sha256').update(`${url}:${name}`).digest('hex')\n}\n\n/**\n * Get metadata file path for a cached binary.\n */\nfunction getMetadataPath(cacheEntryPath: string): string {\n return path.join(cacheEntryPath, '.dlx-metadata.json')\n}\n\n/**\n * Check if a cached binary is still valid.\n */\nasync function isCacheValid(\n cacheEntryPath: string,\n cacheTtl: number,\n): Promise<boolean> {\n try {\n const metaPath = getMetadataPath(cacheEntryPath)\n if (!existsSync(metaPath)) {\n return false\n }\n\n const metadata = await readJson(metaPath, { throws: false })\n if (!isObjectObject(metadata)) {\n return false\n }\n const now = Date.now()\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, cache is invalid\n if (typeof timestamp !== 'number' || timestamp <= 0) {\n return false\n }\n const age = now - timestamp\n\n return age < cacheTtl\n } catch {\n return false\n }\n}\n\n/**\n * Download a file from a URL with integrity checking.\n */\nasync function downloadBinary(\n url: string,\n destPath: string,\n checksum?: string | undefined,\n): Promise<string> {\n const response = await httpRequest(url)\n if (!response.ok) {\n throw new Error(\n `Failed to download binary: ${response.status} ${response.statusText}`,\n )\n }\n\n // Create a temporary file first.\n const tempPath = `${destPath}.download`\n const hasher = createHash('sha256')\n\n try {\n // Ensure directory exists.\n await fs.mkdir(path.dirname(destPath), { recursive: true })\n\n // Get the response as a buffer and compute hash.\n const buffer = response.body\n\n // Compute hash.\n hasher.update(buffer)\n const actualChecksum = hasher.digest('hex')\n\n // Verify checksum if provided.\n if (checksum && actualChecksum !== checksum) {\n throw new Error(\n `Checksum mismatch: expected ${checksum}, got ${actualChecksum}`,\n )\n }\n\n // Write to temp file.\n await fs.writeFile(tempPath, buffer)\n\n // Make executable on POSIX systems.\n if (!WIN32) {\n await fs.chmod(tempPath, 0o755)\n }\n\n // Move temp file to final location.\n await fs.rename(tempPath, destPath)\n\n return actualChecksum\n } catch (e) {\n // Clean up temp file on error.\n try {\n await safeDelete(tempPath)\n } catch {\n // Ignore cleanup errors.\n }\n throw e\n }\n}\n\n/**\n * Write metadata for a cached binary.\n */\nasync function writeMetadata(\n cacheEntryPath: string,\n url: string,\n checksum: string,\n): Promise<void> {\n const metaPath = getMetadataPath(cacheEntryPath)\n const metadata = {\n arch: os.arch(),\n checksum,\n platform: os.platform(),\n timestamp: Date.now(),\n url,\n version: '1.0.0',\n }\n await fs.writeFile(metaPath, JSON.stringify(metadata, null, 2))\n}\n\n/**\n * Clean expired entries from the DLX cache.\n */\nexport async function cleanDlxCache(\n maxAge: number = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n): Promise<number> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return 0\n }\n\n let cleaned = 0\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n const metaPath = getMetadataPath(entryPath)\n\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n const timestamp = (metadata as Record<string, unknown>)['timestamp']\n // If timestamp is missing or invalid, treat as expired (age = infinity)\n const age =\n typeof timestamp === 'number' && timestamp > 0\n ? now - timestamp\n : Number.POSITIVE_INFINITY\n\n if (age > maxAge) {\n // Remove entire cache entry directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath, { force: true, recursive: true })\n cleaned += 1\n }\n } catch {\n // If we can't read metadata, check if directory is empty or corrupted.\n try {\n // eslint-disable-next-line no-await-in-loop\n const contents = await fs.readdir(entryPath)\n if (!contents.length) {\n // Remove empty directory.\n // eslint-disable-next-line no-await-in-loop\n await safeDelete(entryPath)\n cleaned += 1\n }\n } catch {}\n }\n }\n\n return cleaned\n}\n\n/**\n * Download and execute a binary from a URL with caching.\n */\nexport async function dlxBinary(\n args: readonly string[] | string[],\n options?: DlxBinaryOptions | undefined,\n spawnExtra?: SpawnExtra | undefined,\n): Promise<DlxBinaryResult> {\n const {\n cacheTtl = /*@__INLINE__*/ require('#constants/time').DLX_BINARY_CACHE_TTL,\n checksum,\n force = false,\n name,\n spawnOptions,\n url,\n } = { __proto__: null, ...options } as DlxBinaryOptions\n\n // Generate cache paths similar to pnpm/npx structure.\n const cacheDir = getDlxCachePath()\n const binaryName = name || `binary-${process.platform}-${os.arch()}`\n const cacheKey = generateCacheKey(url, binaryName)\n const cacheEntryDir = path.join(cacheDir, cacheKey)\n const binaryPath = normalizePath(path.join(cacheEntryDir, binaryName))\n\n let downloaded = false\n let computedChecksum = checksum\n\n // Check if we need to download.\n if (\n !force &&\n existsSync(cacheEntryDir) &&\n (await isCacheValid(cacheEntryDir, cacheTtl))\n ) {\n // Binary is cached and valid, read the checksum from metadata.\n try {\n const metaPath = getMetadataPath(cacheEntryDir)\n const metadata = await readJson(metaPath, { throws: false })\n if (\n metadata &&\n typeof metadata === 'object' &&\n !Array.isArray(metadata) &&\n typeof (metadata as Record<string, unknown>)['checksum'] === 'string'\n ) {\n computedChecksum = (metadata as Record<string, unknown>)[\n 'checksum'\n ] as string\n } else {\n // If metadata is invalid, re-download.\n downloaded = true\n }\n } catch {\n // If we can't read metadata, re-download.\n downloaded = true\n }\n } else {\n downloaded = true\n }\n\n if (downloaded) {\n // Ensure cache directory exists.\n await fs.mkdir(cacheEntryDir, { recursive: true })\n\n // Download the binary.\n computedChecksum = await downloadBinary(url, binaryPath, checksum)\n await writeMetadata(cacheEntryDir, url, computedChecksum || '')\n }\n\n // Execute the binary.\n // On Windows, script files (.bat, .cmd, .ps1) require shell: true because\n // they are not executable on their own and must be run through cmd.exe.\n // Note: .exe files are actual binaries and don't need shell mode.\n const needsShell = WIN32 && /\\.(?:bat|cmd|ps1)$/i.test(binaryPath)\n // Windows cmd.exe PATH resolution behavior:\n // When shell: true on Windows with .cmd/.bat/.ps1 files, spawn will automatically\n // strip the full path down to just the basename without extension (e.g.,\n // C:\\cache\\test.cmd becomes just \"test\"). Windows cmd.exe then searches for \"test\"\n // in directories listed in PATH, trying each extension from PATHEXT environment\n // variable (.COM, .EXE, .BAT, .CMD, etc.) until it finds a match.\n //\n // Since our binaries are downloaded to a custom cache directory that's not in PATH\n // (unlike system package managers like npm/pnpm/yarn which are already in PATH),\n // we must prepend the cache directory to PATH so cmd.exe can locate the binary.\n //\n // This approach is consistent with how other tools handle Windows command execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - Node.js spawn with shell: true: delegates to cmd.exe which uses PATH\n const finalSpawnOptions = needsShell\n ? {\n ...spawnOptions,\n env: {\n ...spawnOptions?.env,\n PATH: `${cacheEntryDir}${path.delimiter}${process.env['PATH'] || ''}`,\n },\n shell: true,\n }\n : spawnOptions\n const spawnPromise = spawn(binaryPath, args, finalSpawnOptions, spawnExtra)\n\n return {\n binaryPath,\n downloaded,\n spawnPromise,\n }\n}\n\n/**\n * Get the DLX binary cache directory path.\n * Returns normalized path for cross-platform compatibility.\n * Uses same directory as dlx-package for unified DLX storage.\n */\nexport function getDlxCachePath(): string {\n return getSocketDlxDir()\n}\n\n/**\n * Get information about cached binaries.\n */\nexport async function listDlxCache(): Promise<\n Array<{\n age: number\n arch: string\n checksum: string\n name: string\n platform: string\n size: number\n url: string\n }>\n> {\n const cacheDir = getDlxCachePath()\n\n if (!existsSync(cacheDir)) {\n return []\n }\n\n const results = []\n const now = Date.now()\n const entries = await fs.readdir(cacheDir)\n\n for (const entry of entries) {\n const entryPath = path.join(cacheDir, entry)\n try {\n // eslint-disable-next-line no-await-in-loop\n if (!(await isDir(entryPath))) {\n continue\n }\n\n const metaPath = getMetadataPath(entryPath)\n // eslint-disable-next-line no-await-in-loop\n const metadata = await readJson(metaPath, { throws: false })\n if (\n !metadata ||\n typeof metadata !== 'object' ||\n Array.isArray(metadata)\n ) {\n continue\n }\n\n // Find the binary file in the directory.\n // eslint-disable-next-line no-await-in-loop\n const files = await fs.readdir(entryPath)\n const binaryFile = files.find(f => !f.startsWith('.'))\n\n if (binaryFile) {\n const binaryPath = path.join(entryPath, binaryFile)\n // eslint-disable-next-line no-await-in-loop\n const binaryStats = await fs.stat(binaryPath)\n\n const metaObj = metadata as Record<string, unknown>\n results.push({\n age: now - ((metaObj['timestamp'] as number) || 0),\n arch: (metaObj['arch'] as string) || 'unknown',\n checksum: (metaObj['checksum'] as string) || '',\n name: binaryFile,\n platform: (metaObj['platform'] as string) || 'unknown',\n size: binaryStats.size,\n url: (metaObj['url'] as string) || '',\n })\n }\n } catch {}\n }\n\n return results\n}\n"],
5
+ "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,cAAAC,EAAA,oBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAN,GAEA,IAAAO,EAA2B,uBAC3BC,EAA2C,mBAC3CC,EAAe,sBACfC,EAAiB,wBAEjBC,EAAsB,+BAEtBC,EAA4C,gBAC5CC,EAA4B,0BAC5BC,EAA+B,qBAC/BC,EAA8B,kBAC9BC,EAAgC,mBAEhCC,EAAsB,mBAgCtB,SAASC,EAAiBC,EAAaC,EAAsB,CAC3D,SAAO,cAAW,QAAQ,EAAE,OAAO,GAAGD,CAAG,IAAIC,CAAI,EAAE,EAAE,OAAO,KAAK,CACnE,CAKA,SAASC,EAAgBC,EAAgC,CACvD,OAAO,EAAAC,QAAK,KAAKD,EAAgB,oBAAoB,CACvD,CAKA,eAAeE,EACbF,EACAG,EACkB,CAClB,GAAI,CACF,MAAMC,EAAWL,EAAgBC,CAAc,EAC/C,GAAI,IAAC,cAAWI,CAAQ,EACtB,MAAO,GAGT,MAAMC,EAAW,QAAM,YAASD,EAAU,CAAE,OAAQ,EAAM,CAAC,EAC3D,GAAI,IAAC,kBAAeC,CAAQ,EAC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UAAWG,KAASD,EAAS,CAC3B,MAAME,EAAY,EAAAxB,QAAK,KAAKoB,EAAUG,CAAK,EAC3C,GAAI,CAEF,GAAI,CAAE,QAAM,SAAMC,CAAS,EACzB,SAGF,MAAMrB,EAAWL,EAAgB0B,CAAS,EAEpCpB,EAAW,QAAM,YAASD,EAAU,CAAE,OAAQ,EAAM,CAAC,EAC3D,GACE,CAACC,GACD,OAAOA,GAAa,UACpB,MAAM,QAAQA,CAAQ,EAEtB,SAMF,MAAMmC,GADQ,MAAM,EAAA1B,SAAG,QAAQW,CAAS,GACf,KAAKgB,GAAK,CAACA,EAAE,WAAW,GAAG,CAAC,EAErD,GAAID,EAAY,CACd,MAAMN,EAAa,EAAAjC,QAAK,KAAKwB,EAAWe,CAAU,EAE5CE,EAAc,MAAM,EAAA5B,SAAG,KAAKoB,CAAU,EAEtCS,EAAUtC,EAChBkC,EAAQ,KAAK,CACX,IAAKjC,GAAQqC,EAAQ,WAA2B,GAChD,KAAOA,EAAQ,MAAsB,UACrC,SAAWA,EAAQ,UAA0B,GAC7C,KAAMH,EACN,SAAWG,EAAQ,UAA0B,UAC7C,KAAMD,EAAY,KAClB,IAAMC,EAAQ,KAAqB,EACrC,CAAC,CACH,CACF,MAAQ,CAAC,CACX,CAEA,OAAOJ,CACT",
6
+ "names": ["dlx_binary_exports", "__export", "cleanDlxCache", "dlxBinary", "getDlxCachePath", "listDlxCache", "__toCommonJS", "import_node_crypto", "import_node_fs", "import_node_os", "import_node_path", "import_platform", "import_fs", "import_http_request", "import_objects", "import_path", "import_paths", "import_spawn", "generateCacheKey", "url", "name", "getMetadataPath", "cacheEntryPath", "path", "isCacheValid", "cacheTtl", "metaPath", "metadata", "now", "timestamp", "downloadBinary", "destPath", "checksum", "response", "tempPath", "hasher", "fs", "buffer", "actualChecksum", "e", "writeMetadata", "os", "maxAge", "cacheDir", "cleaned", "entries", "entry", "entryPath", "args", "options", "spawnExtra", "force", "spawnOptions", "binaryName", "cacheKey", "cacheEntryDir", "binaryPath", "downloaded", "computedChecksum", "finalSpawnOptions", "spawnPromise", "results", "binaryFile", "f", "binaryStats", "metaObj"]
7
7
  }
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var A=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},E=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of G(r))!M.call(e,o)&&o!==t&&y(e,o,{get:()=>r[o],enumerable:!(n=O(r,o))||n.enumerable});return e};var N=e=>E(y({},"__esModule",{value:!0}),e);var H={};A(H,{COLOR_INHERIT:()=>j,DIR_LTR:()=>p,DIR_NONE:()=>x,DIR_RANDOM:()=>a,DIR_RTL:()=>u,MODE_BI:()=>_,applyShimmer:()=>B});module.exports=N(H);var l=require("../ansi"),$=require("../arrays"),C=require("#env/ci");function k(e){return{__proto__:null,bold:/\x1b\[1m/.test(e),dim:/\x1b\[2m/.test(e),italic:/\x1b\[3m/.test(e),strikethrough:/\x1b\[9m/.test(e),underline:/\x1b\[4m/.test(e)}}function D(e){let r="";return e.bold&&(r+="\x1B[1m"),e.dim&&(r+="\x1B[2m"),e.italic&&(r+="\x1B[3m"),e.underline&&(r+="\x1B[4m"),e.strikethrough&&(r+="\x1B[9m"),r}const j="inherit",p="ltr",x="none",a="random",u="rtl",_="bi";function w(e,r=2.5){return e>r?0:(1-e/r)**2.5}function z(e,r,t){const n=Math.round(e[0]+(r[0]-e[0])*t),o=Math.round(e[1]+(r[1]-e[1])*t),s=Math.round(e[2]+(r[2]-e[2])*t);return[n,o,s]}function L(e,r,t,n,o){const s=Math.abs(r-t),m=w(s),b=D(o),i=(0,$.isArray)(n[0])?n[r%n.length]??[140,82,255]:n;if(m===0){const h=`\x1B[38;2;${i[0]};${i[1]};${i[2]}m`;return`${b}${h}${e}${l.ANSI_RESET}`}const d=z(i,[255,255,255],m),c=`\x1B[38;2;${d[0]};${d[1]};${d[2]}m`;return`${b}${c}${e}${l.ANSI_RESET}`}function P(e,r,t,n=2.5){const o=e+n+2;return t===u?e-r%o:r%o}function W(e){return e===a?Math.random()<.5?p:u:e===u?u:p}function B(e,r,t){const n={__proto__:null,...t},o=n.direction??x,s=n.shimmerWidth??2.5,m=n.color??[140,82,255],b=n.styles??k(e),i=(0,l.stripAnsi)(e);if(C.CI||!i||o===x){const h=D(b),S=(0,$.isArray)(m[0]);return i.split("").map((R,T)=>{const f=S?m[T%m.length]??[140,82,255]:m,I=`\x1B[38;2;${f[0]};${f[1]};${f[2]}m`;return`${h}${I}${R}${l.ANSI_RESET}`}).join("")}const g=P(i.length,r.step,r.currentDir,s),d=i.split("").map((h,S)=>L(h,S,g,m,b)).join("");r.step+=r.speed;const c=i.length+s+2;return r.mode===_?r.step>=c&&(r.step=0,r.currentDir=r.currentDir===p?u:p):r.mode===a?r.step>=c&&(r.step=0,r.currentDir=W(a)):r.step>=c&&(r.step=0),d}0&&(module.exports={COLOR_INHERIT,DIR_LTR,DIR_NONE,DIR_RANDOM,DIR_RTL,MODE_BI,applyShimmer});
2
+ var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var A=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},E=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of G(r))!M.call(e,o)&&o!==t&&y(e,o,{get:()=>r[o],enumerable:!(n=O(r,o))||n.enumerable});return e};var N=e=>E(y({},"__esModule",{value:!0}),e);var H={};A(H,{COLOR_INHERIT:()=>j,DIR_LTR:()=>p,DIR_NONE:()=>x,DIR_RANDOM:()=>a,DIR_RTL:()=>u,MODE_BI:()=>_,applyShimmer:()=>B});module.exports=N(H);var l=require("../ansi"),$=require("../arrays"),C=require("#env/ci");function k(e){return{__proto__:null,bold:/\x1b\[1m/.test(e),dim:/\x1b\[2m/.test(e),italic:/\x1b\[3m/.test(e),strikethrough:/\x1b\[9m/.test(e),underline:/\x1b\[4m/.test(e)}}function D(e){let r="";return e.bold&&(r+="\x1B[1m"),e.dim&&(r+="\x1B[2m"),e.italic&&(r+="\x1B[3m"),e.underline&&(r+="\x1B[4m"),e.strikethrough&&(r+="\x1B[9m"),r}const j="inherit",p="ltr",x="none",a="random",u="rtl",_="bi";function w(e,r=2.5){return e>r?0:(1-e/r)**2.5}function z(e,r,t){const n=Math.round(e[0]+(r[0]-e[0])*t),o=Math.round(e[1]+(r[1]-e[1])*t),s=Math.round(e[2]+(r[2]-e[2])*t);return[n,o,s]}function L(e,r,t,n,o){const s=Math.abs(r-t),m=w(s),b=D(o),i=(0,$.isArray)(n[0])?n[r%n.length]??[140,82,255]:n;if(m===0){const h=`\x1B[38;2;${i[0]};${i[1]};${i[2]}m`;return`${b}${h}${e}${l.ANSI_RESET}`}const d=z(i,[255,255,255],m),c=`\x1B[38;2;${d[0]};${d[1]};${d[2]}m`;return`${b}${c}${e}${l.ANSI_RESET}`}function P(e,r,t,n=2.5){const o=e+n+2;return t===u?e-r%o:r%o}function W(e){return e===a?Math.random()<.5?p:u:e===u?u:p}function B(e,r,t){const n={__proto__:null,...t},o=n.direction??x,s=n.shimmerWidth??2.5,m=n.color??[140,82,255],b=n.styles??k(e),i=(0,l.stripAnsi)(e);if((0,C.getCI)()||!i||o===x){const h=D(b),S=(0,$.isArray)(m[0]);return i.split("").map((R,T)=>{const f=S?m[T%m.length]??[140,82,255]:m,I=`\x1B[38;2;${f[0]};${f[1]};${f[2]}m`;return`${h}${I}${R}${l.ANSI_RESET}`}).join("")}const g=P(i.length,r.step,r.currentDir,s),d=i.split("").map((h,S)=>L(h,S,g,m,b)).join("");r.step+=r.speed;const c=i.length+s+2;return r.mode===_?r.step>=c&&(r.step=0,r.currentDir=r.currentDir===p?u:p):r.mode===a?r.step>=c&&(r.step=0,r.currentDir=W(a)):r.step>=c&&(r.step=0),d}0&&(module.exports={COLOR_INHERIT,DIR_LTR,DIR_NONE,DIR_RANDOM,DIR_RTL,MODE_BI,applyShimmer});
3
3
  //# sourceMappingURL=text-shimmer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/effects/text-shimmer.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Text shimmer animation utilities.\n * Provides animated highlight effects for spinner text with configurable directions:\n * - LTR (left-to-right): Shimmer wave moves from left to right\n * - RTL (right-to-left): Shimmer wave moves from right to left\n * - Bidirectional: Alternates between LTR and RTL each cycle\n * - Random: Picks a random direction each cycle\n * - None: No shimmer animation\n *\n * The shimmer effect creates a bright wave that travels across the text,\n * with characters near the wave appearing nearly white and fading to the\n * base color as they get further from the wave position.\n */\n\nimport { ANSI_RESET, stripAnsi } from '../ansi'\nimport { isArray } from '../arrays'\nimport { CI } from '#env/ci'\n\nimport type {\n ShimmerColorGradient,\n ShimmerColorRgb,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n// Re-export types for backward compatibility.\nexport type {\n ShimmerColor,\n ShimmerColorGradient,\n ShimmerColorInherit,\n ShimmerColorRgb,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n/**\n * Detected text formatting styles from ANSI codes.\n */\ntype TextStyles = {\n bold: boolean\n dim: boolean\n italic: boolean\n strikethrough: boolean\n underline: boolean\n}\n\n/**\n * Detect all text formatting styles present in ANSI-coded text.\n * Checks for bold, dim, italic, underline, and strikethrough.\n */\nfunction detectStyles(text: string): TextStyles {\n return {\n __proto__: null,\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n bold: /\\x1b\\[1m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n dim: /\\x1b\\[2m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n italic: /\\x1b\\[3m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n strikethrough: /\\x1b\\[9m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n underline: /\\x1b\\[4m/.test(text),\n } as TextStyles\n}\n\n/**\n * Build ANSI code string from text styles.\n * Returns the concatenated ANSI codes needed to apply the styles.\n */\nfunction stylesToAnsi(styles: TextStyles): string {\n let codes = ''\n if (styles.bold) {\n codes += '\\x1b[1m'\n }\n if (styles.dim) {\n codes += '\\x1b[2m'\n }\n if (styles.italic) {\n codes += '\\x1b[3m'\n }\n if (styles.underline) {\n codes += '\\x1b[4m'\n }\n if (styles.strikethrough) {\n codes += '\\x1b[9m'\n }\n return codes\n}\n\n// Internal options for applyShimmer function.\ntype ShimmerOptions = {\n readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined\n readonly direction?: ShimmerDirection | undefined\n readonly shimmerWidth?: number | undefined\n readonly styles?: TextStyles | undefined\n}\n\nexport const COLOR_INHERIT = 'inherit'\n\nexport const DIR_LTR = 'ltr'\n\nexport const DIR_NONE = 'none'\n\nexport const DIR_RANDOM = 'random'\n\nexport const DIR_RTL = 'rtl'\n\nexport const MODE_BI = 'bi'\n\n/**\n * Calculate shimmer intensity based on distance from shimmer wave position.\n * Uses a power curve for smooth falloff - characters close to the wave\n * get high intensity (bright white), while distant characters get 0.\n */\nfunction shimmerIntensity(\n distance: number,\n shimmerWidth: number = 2.5,\n): number {\n // Characters beyond shimmer width get no effect.\n if (distance > shimmerWidth) {\n return 0\n }\n // Smooth falloff using power curve.\n const normalized = distance / shimmerWidth\n return (1 - normalized) ** 2.5\n}\n\n/**\n * Blend two RGB colors based on a blend factor (0-1).\n * factor 0 = color1, factor 1 = color2, factor 0.5 = 50/50 blend.\n */\nfunction blendColors(\n color1: readonly [number, number, number],\n color2: readonly [number, number, number],\n factor: number,\n): readonly [number, number, number] {\n const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor)\n const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor)\n const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor)\n return [r, g, b] as const\n}\n\n/**\n * Render character with shimmer effect based on distance from shimmer position.\n * Characters closer to the shimmer position get brighter (nearly white),\n * while characters further away use the base color.\n * Creates a smooth gradient by blending base color with white based on intensity.\n * Supports both single color and per-character color gradients.\n */\nfunction renderChar(\n char: string,\n index: number,\n shimmerPos: number,\n baseColor: readonly [number, number, number] | ShimmerColorGradient,\n styles: TextStyles,\n): string {\n // Calculate how far this character is from the shimmer wave.\n const distance = Math.abs(index - shimmerPos)\n const intensity = shimmerIntensity(distance)\n\n const styleCode = stylesToAnsi(styles)\n\n // Get base color for this character (single or per-character from gradient).\n const charColor: readonly [number, number, number] = isArray(baseColor[0])\n ? ((baseColor as ShimmerColorGradient)[index % baseColor.length] ?? [\n 140, 82, 255,\n ])\n : (baseColor as readonly [number, number, number])\n\n // If no shimmer intensity, use base color as-is.\n if (intensity === 0) {\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n }\n\n // Blend base color with white based on intensity to create smooth gradient.\n // Higher intensity = more white, creating the shimmer wave effect.\n const white: readonly [number, number, number] = [255, 255, 255] as const\n const blended = blendColors(charColor, white, intensity)\n\n const color = `\\x1b[38;2;${blended[0]};${blended[1]};${blended[2]}m`\n return `${styleCode}${color}${char}${ANSI_RESET}`\n}\n\n/**\n * Calculate shimmer wave position for current animation step.\n * The shimmer wave moves across the text length, with extra space\n * for the wave to fade in/out at the edges.\n */\nfunction getShimmerPos(\n textLength: number,\n step: number,\n currentDir: 'ltr' | 'rtl',\n shimmerWidth: number = 2.5,\n): number {\n // Total steps for one complete cycle (text length + fade in/out space).\n const totalSteps = textLength + shimmerWidth + 2\n\n // RTL: Shimmer moves from right to left.\n if (currentDir === DIR_RTL) {\n return textLength - (step % totalSteps)\n }\n\n // LTR: Shimmer moves from left to right.\n return step % totalSteps\n}\n\n/**\n * Resolve shimmer direction to a concrete 'ltr' or 'rtl' value.\n * Used for initializing shimmer state and picking random directions.\n */\nfunction pickDirection(direction: ShimmerDirection): 'ltr' | 'rtl' {\n // Random mode: 50/50 chance of LTR or RTL.\n if (direction === DIR_RANDOM) {\n return Math.random() < 0.5 ? DIR_LTR : DIR_RTL\n }\n // RTL mode: Use RTL direction.\n if (direction === DIR_RTL) {\n return DIR_RTL\n }\n // LTR mode (or any other): Default to LTR.\n return DIR_LTR\n}\n\n/**\n * Apply shimmer animation effect to text.\n * This is the main entry point for shimmer animations. It:\n * 1. Strips ANSI codes to get plain text for character positioning\n * 2. Detects any styling (bold, italic, underline, etc.) to preserve\n * 3. Calculates the current shimmer wave position based on animation step\n * 4. Renders each character with appropriate brightness based on distance from wave\n * 5. Updates the animation state for the next frame\n * 6. Handles direction changes for bidirectional and random modes\n */\nexport function applyShimmer(\n text: string,\n state: ShimmerState,\n options?: ShimmerOptions | undefined,\n): string {\n const opts = { __proto__: null, ...options } as ShimmerOptions\n const direction = opts.direction ?? DIR_NONE\n const shimmerWidth = opts.shimmerWidth ?? 2.5\n // Socket purple.\n const color = opts.color ?? ([140, 82, 255] as const)\n\n // Detect text formatting styles from original text.\n const styles = opts.styles ?? detectStyles(text)\n\n // Strip ANSI codes to get plain text.\n const plainText = stripAnsi(text)\n\n // No shimmer effect in CI or when direction is 'none'.\n if (CI || !plainText || direction === DIR_NONE) {\n const styleCode = stylesToAnsi(styles)\n\n // Support gradient colors (array of colors, one per character).\n const isGradient = isArray(color[0])\n\n return plainText\n .split('')\n .map((char, i) => {\n const charColor: readonly [number, number, number] = isGradient\n ? ((color as ShimmerColorGradient)[i % color.length] ?? [\n 140, 82, 255,\n ])\n : (color as readonly [number, number, number])\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n })\n .join('')\n }\n\n // Calculate shimmer position.\n const shimmerPos = getShimmerPos(\n plainText.length,\n state.step,\n state.currentDir,\n shimmerWidth,\n )\n\n // Render text with shimmer.\n const result = plainText\n .split('')\n .map((char, i) => renderChar(char, i, shimmerPos, color, styles))\n .join('')\n\n // Advance shimmer position by speed amount each frame.\n // Speed represents steps per frame (e.g., 0.33 = advance 0.33 steps per frame).\n // This creates smooth animation by moving in small increments every frame\n // instead of jumping larger distances every N frames.\n state.step += state.speed\n\n // Handle bidirectional direction changes.\n const totalSteps = plainText.length + shimmerWidth + 2\n if (state.mode === MODE_BI) {\n if (state.step >= totalSteps) {\n state.step = 0\n // Toggle direction every cycle.\n state.currentDir = state.currentDir === DIR_LTR ? DIR_RTL : DIR_LTR\n }\n } else if (state.mode === DIR_RANDOM) {\n // Change direction randomly at end of each cycle.\n if (state.step >= totalSteps) {\n state.step = 0\n state.currentDir = pickDirection(DIR_RANDOM)\n }\n } else {\n // Reset for continuous loops.\n if (state.step >= totalSteps) {\n state.step = 0\n }\n }\n\n return result\n}\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,YAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAT,GAcA,IAAAU,EAAsC,mBACtCC,EAAwB,qBACxBC,EAAmB,mBAmCnB,SAASC,EAAaC,EAA0B,CAC9C,MAAO,CACL,UAAW,KAEX,KAAM,WAAW,KAAKA,CAAI,EAE1B,IAAK,WAAW,KAAKA,CAAI,EAEzB,OAAQ,WAAW,KAAKA,CAAI,EAE5B,cAAe,WAAW,KAAKA,CAAI,EAEnC,UAAW,WAAW,KAAKA,CAAI,CACjC,CACF,CAMA,SAASC,EAAaC,EAA4B,CAChD,IAAIC,EAAQ,GACZ,OAAID,EAAO,OACTC,GAAS,WAEPD,EAAO,MACTC,GAAS,WAEPD,EAAO,SACTC,GAAS,WAEPD,EAAO,YACTC,GAAS,WAEPD,EAAO,gBACTC,GAAS,WAEJA,CACT,CAUO,MAAMf,EAAgB,UAEhBC,EAAU,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AAaM,EAAU,OAAS7B,EAAe,EACrD,OAAI0B,EAAM,OAASvC,EACbuC,EAAM,MAAQH,IAChBG,EAAM,KAAO,EAEbA,EAAM,WAAaA,EAAM,aAAe3C,EAAUG,EAAUH,GAErD2C,EAAM,OAASzC,EAEpByC,EAAM,MAAQH,IAChBG,EAAM,KAAO,EACbA,EAAM,WAAaF,EAAcvC,CAAU,GAIzCyC,EAAM,MAAQH,IAChBG,EAAM,KAAO,GAIVM,CACT",
4
+ "sourcesContent": ["/**\n * @fileoverview Text shimmer animation utilities.\n * Provides animated highlight effects for spinner text with configurable directions:\n * - LTR (left-to-right): Shimmer wave moves from left to right\n * - RTL (right-to-left): Shimmer wave moves from right to left\n * - Bidirectional: Alternates between LTR and RTL each cycle\n * - Random: Picks a random direction each cycle\n * - None: No shimmer animation\n *\n * The shimmer effect creates a bright wave that travels across the text,\n * with characters near the wave appearing nearly white and fading to the\n * base color as they get further from the wave position.\n */\n\nimport { ANSI_RESET, stripAnsi } from '../ansi'\nimport { isArray } from '../arrays'\nimport { getCI } from '#env/ci'\n\nimport type {\n ShimmerColorGradient,\n ShimmerColorRgb,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n// Re-export types for backward compatibility.\nexport type {\n ShimmerColor,\n ShimmerColorGradient,\n ShimmerColorInherit,\n ShimmerColorRgb,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './types'\n\n/**\n * Detected text formatting styles from ANSI codes.\n */\ntype TextStyles = {\n bold: boolean\n dim: boolean\n italic: boolean\n strikethrough: boolean\n underline: boolean\n}\n\n/**\n * Detect all text formatting styles present in ANSI-coded text.\n * Checks for bold, dim, italic, underline, and strikethrough.\n */\nfunction detectStyles(text: string): TextStyles {\n return {\n __proto__: null,\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n bold: /\\x1b\\[1m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n dim: /\\x1b\\[2m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n italic: /\\x1b\\[3m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n strikethrough: /\\x1b\\[9m/.test(text),\n // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection.\n underline: /\\x1b\\[4m/.test(text),\n } as TextStyles\n}\n\n/**\n * Build ANSI code string from text styles.\n * Returns the concatenated ANSI codes needed to apply the styles.\n */\nfunction stylesToAnsi(styles: TextStyles): string {\n let codes = ''\n if (styles.bold) {\n codes += '\\x1b[1m'\n }\n if (styles.dim) {\n codes += '\\x1b[2m'\n }\n if (styles.italic) {\n codes += '\\x1b[3m'\n }\n if (styles.underline) {\n codes += '\\x1b[4m'\n }\n if (styles.strikethrough) {\n codes += '\\x1b[9m'\n }\n return codes\n}\n\n// Internal options for applyShimmer function.\ntype ShimmerOptions = {\n readonly color?: ShimmerColorRgb | ShimmerColorGradient | undefined\n readonly direction?: ShimmerDirection | undefined\n readonly shimmerWidth?: number | undefined\n readonly styles?: TextStyles | undefined\n}\n\nexport const COLOR_INHERIT = 'inherit'\n\nexport const DIR_LTR = 'ltr'\n\nexport const DIR_NONE = 'none'\n\nexport const DIR_RANDOM = 'random'\n\nexport const DIR_RTL = 'rtl'\n\nexport const MODE_BI = 'bi'\n\n/**\n * Calculate shimmer intensity based on distance from shimmer wave position.\n * Uses a power curve for smooth falloff - characters close to the wave\n * get high intensity (bright white), while distant characters get 0.\n */\nfunction shimmerIntensity(\n distance: number,\n shimmerWidth: number = 2.5,\n): number {\n // Characters beyond shimmer width get no effect.\n if (distance > shimmerWidth) {\n return 0\n }\n // Smooth falloff using power curve.\n const normalized = distance / shimmerWidth\n return (1 - normalized) ** 2.5\n}\n\n/**\n * Blend two RGB colors based on a blend factor (0-1).\n * factor 0 = color1, factor 1 = color2, factor 0.5 = 50/50 blend.\n */\nfunction blendColors(\n color1: readonly [number, number, number],\n color2: readonly [number, number, number],\n factor: number,\n): readonly [number, number, number] {\n const r = Math.round(color1[0] + (color2[0] - color1[0]) * factor)\n const g = Math.round(color1[1] + (color2[1] - color1[1]) * factor)\n const b = Math.round(color1[2] + (color2[2] - color1[2]) * factor)\n return [r, g, b] as const\n}\n\n/**\n * Render character with shimmer effect based on distance from shimmer position.\n * Characters closer to the shimmer position get brighter (nearly white),\n * while characters further away use the base color.\n * Creates a smooth gradient by blending base color with white based on intensity.\n * Supports both single color and per-character color gradients.\n */\nfunction renderChar(\n char: string,\n index: number,\n shimmerPos: number,\n baseColor: readonly [number, number, number] | ShimmerColorGradient,\n styles: TextStyles,\n): string {\n // Calculate how far this character is from the shimmer wave.\n const distance = Math.abs(index - shimmerPos)\n const intensity = shimmerIntensity(distance)\n\n const styleCode = stylesToAnsi(styles)\n\n // Get base color for this character (single or per-character from gradient).\n const charColor: readonly [number, number, number] = isArray(baseColor[0])\n ? ((baseColor as ShimmerColorGradient)[index % baseColor.length] ?? [\n 140, 82, 255,\n ])\n : (baseColor as readonly [number, number, number])\n\n // If no shimmer intensity, use base color as-is.\n if (intensity === 0) {\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n }\n\n // Blend base color with white based on intensity to create smooth gradient.\n // Higher intensity = more white, creating the shimmer wave effect.\n const white: readonly [number, number, number] = [255, 255, 255] as const\n const blended = blendColors(charColor, white, intensity)\n\n const color = `\\x1b[38;2;${blended[0]};${blended[1]};${blended[2]}m`\n return `${styleCode}${color}${char}${ANSI_RESET}`\n}\n\n/**\n * Calculate shimmer wave position for current animation step.\n * The shimmer wave moves across the text length, with extra space\n * for the wave to fade in/out at the edges.\n */\nfunction getShimmerPos(\n textLength: number,\n step: number,\n currentDir: 'ltr' | 'rtl',\n shimmerWidth: number = 2.5,\n): number {\n // Total steps for one complete cycle (text length + fade in/out space).\n const totalSteps = textLength + shimmerWidth + 2\n\n // RTL: Shimmer moves from right to left.\n if (currentDir === DIR_RTL) {\n return textLength - (step % totalSteps)\n }\n\n // LTR: Shimmer moves from left to right.\n return step % totalSteps\n}\n\n/**\n * Resolve shimmer direction to a concrete 'ltr' or 'rtl' value.\n * Used for initializing shimmer state and picking random directions.\n */\nfunction pickDirection(direction: ShimmerDirection): 'ltr' | 'rtl' {\n // Random mode: 50/50 chance of LTR or RTL.\n if (direction === DIR_RANDOM) {\n return Math.random() < 0.5 ? DIR_LTR : DIR_RTL\n }\n // RTL mode: Use RTL direction.\n if (direction === DIR_RTL) {\n return DIR_RTL\n }\n // LTR mode (or any other): Default to LTR.\n return DIR_LTR\n}\n\n/**\n * Apply shimmer animation effect to text.\n * This is the main entry point for shimmer animations. It:\n * 1. Strips ANSI codes to get plain text for character positioning\n * 2. Detects any styling (bold, italic, underline, etc.) to preserve\n * 3. Calculates the current shimmer wave position based on animation step\n * 4. Renders each character with appropriate brightness based on distance from wave\n * 5. Updates the animation state for the next frame\n * 6. Handles direction changes for bidirectional and random modes\n */\nexport function applyShimmer(\n text: string,\n state: ShimmerState,\n options?: ShimmerOptions | undefined,\n): string {\n const opts = { __proto__: null, ...options } as ShimmerOptions\n const direction = opts.direction ?? DIR_NONE\n const shimmerWidth = opts.shimmerWidth ?? 2.5\n // Socket purple.\n const color = opts.color ?? ([140, 82, 255] as const)\n\n // Detect text formatting styles from original text.\n const styles = opts.styles ?? detectStyles(text)\n\n // Strip ANSI codes to get plain text.\n const plainText = stripAnsi(text)\n\n // No shimmer effect in CI or when direction is 'none'.\n if (getCI() || !plainText || direction === DIR_NONE) {\n const styleCode = stylesToAnsi(styles)\n\n // Support gradient colors (array of colors, one per character).\n const isGradient = isArray(color[0])\n\n return plainText\n .split('')\n .map((char, i) => {\n const charColor: readonly [number, number, number] = isGradient\n ? ((color as ShimmerColorGradient)[i % color.length] ?? [\n 140, 82, 255,\n ])\n : (color as readonly [number, number, number])\n const base = `\\x1b[38;2;${charColor[0]};${charColor[1]};${charColor[2]}m`\n return `${styleCode}${base}${char}${ANSI_RESET}`\n })\n .join('')\n }\n\n // Calculate shimmer position.\n const shimmerPos = getShimmerPos(\n plainText.length,\n state.step,\n state.currentDir,\n shimmerWidth,\n )\n\n // Render text with shimmer.\n const result = plainText\n .split('')\n .map((char, i) => renderChar(char, i, shimmerPos, color, styles))\n .join('')\n\n // Advance shimmer position by speed amount each frame.\n // Speed represents steps per frame (e.g., 0.33 = advance 0.33 steps per frame).\n // This creates smooth animation by moving in small increments every frame\n // instead of jumping larger distances every N frames.\n state.step += state.speed\n\n // Handle bidirectional direction changes.\n const totalSteps = plainText.length + shimmerWidth + 2\n if (state.mode === MODE_BI) {\n if (state.step >= totalSteps) {\n state.step = 0\n // Toggle direction every cycle.\n state.currentDir = state.currentDir === DIR_LTR ? DIR_RTL : DIR_LTR\n }\n } else if (state.mode === DIR_RANDOM) {\n // Change direction randomly at end of each cycle.\n if (state.step >= totalSteps) {\n state.step = 0\n state.currentDir = pickDirection(DIR_RANDOM)\n }\n } else {\n // Reset for continuous loops.\n if (state.step >= totalSteps) {\n state.step = 0\n }\n }\n\n return result\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,YAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,YAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAT,GAcA,IAAAU,EAAsC,mBACtCC,EAAwB,qBACxBC,EAAsB,mBAmCtB,SAASC,EAAaC,EAA0B,CAC9C,MAAO,CACL,UAAW,KAEX,KAAM,WAAW,KAAKA,CAAI,EAE1B,IAAK,WAAW,KAAKA,CAAI,EAEzB,OAAQ,WAAW,KAAKA,CAAI,EAE5B,cAAe,WAAW,KAAKA,CAAI,EAEnC,UAAW,WAAW,KAAKA,CAAI,CACjC,CACF,CAMA,SAASC,EAAaC,EAA4B,CAChD,IAAIC,EAAQ,GACZ,OAAID,EAAO,OACTC,GAAS,WAEPD,EAAO,MACTC,GAAS,WAEPD,EA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MvB,EAAWC,EAAMsB,EAAGpB,EAAYO,EAAOtB,CAAM,CAAC,EAC/D,KAAK,EAAE,EAMV8B,EAAM,MAAQA,EAAM,MAGpB,MAAMH,EAAaM,EAAU,OAAS7B,EAAe,EACrD,OAAI0B,EAAM,OAASvC,EACbuC,EAAM,MAAQH,IAChBG,EAAM,KAAO,EAEbA,EAAM,WAAaA,EAAM,aAAe3C,EAAUG,EAAUH,GAErD2C,EAAM,OAASzC,EAEpByC,EAAM,MAAQH,IAChBG,EAAM,KAAO,EACbA,EAAM,WAAaF,EAAcvC,CAAU,GAIzCyC,EAAM,MAAQH,IAChBG,EAAM,KAAO,GAIVM,CACT",
6
6
  "names": ["text_shimmer_exports", "__export", "COLOR_INHERIT", "DIR_LTR", "DIR_NONE", "DIR_RANDOM", "DIR_RTL", "MODE_BI", "applyShimmer", "__toCommonJS", "import_ansi", "import_arrays", "import_ci", "detectStyles", "text", "stylesToAnsi", "styles", "codes", "shimmerIntensity", "distance", "shimmerWidth", "blendColors", "color1", "color2", "factor", "r", "g", "b", "renderChar", "char", "index", "shimmerPos", "baseColor", "intensity", "styleCode", "charColor", "base", "blended", "color", "getShimmerPos", "textLength", "step", "currentDir", "totalSteps", "pickDirection", "direction", "state", "options", "opts", "plainText", "isGradient", "i", "result"]
7
7
  }
package/dist/env/ci.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CI: boolean;
1
+ export declare function getCI(): boolean;
package/dist/env/ci.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var C=(r,o)=>{for(var m in o)n(r,m,{get:o[m],enumerable:!0})},I=(r,o,m,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of s(o))!v.call(r,e)&&e!==m&&n(r,e,{get:()=>o[e],enumerable:!(t=i(o,e))||t.enumerable});return r};var a=r=>I(n({},"__esModule",{value:!0}),r);var l={};C(l,{CI:()=>c});module.exports=a(l);var p=require("node:process"),f=require("#env/helpers");const c=(0,f.envAsBoolean)(p.env.CI);0&&(module.exports={CI});
2
+ var t=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},g=(e,o,r,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of l(o))!p.call(e,n)&&n!==r&&t(e,n,{get:()=>o[n],enumerable:!(m=i(o,n))||m.enumerable});return e};var v=e=>g(t({},"__esModule",{value:!0}),e);var I={};u(I,{getCI:()=>C});module.exports=v(I);var a=require("#env/helpers"),f=require("#env/rewire");function C(){return(0,a.envAsBoolean)((0,f.getEnvValue)("CI"))}0&&(module.exports={getCI});
3
3
  //# sourceMappingURL=ci.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/env/ci.ts"],
4
- "sourcesContent": ["/**\n * CI environment variable snapshot.\n * Determines if code is running in a Continuous Integration environment.\n */\n\nimport { env } from 'node:process'\n\nimport { envAsBoolean } from '#env/helpers'\n\nexport const CI = envAsBoolean(env['CI'])\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAoB,wBAEpBC,EAA6B,wBAEtB,MAAMH,KAAK,gBAAa,MAAI,EAAK",
6
- "names": ["ci_exports", "__export", "CI", "__toCommonJS", "import_node_process", "import_helpers"]
4
+ "sourcesContent": ["/**\n * CI environment variable getter.\n * Determines if code is running in a Continuous Integration environment.\n */\n\nimport { envAsBoolean } from '#env/helpers'\nimport { getEnvValue } from '#env/rewire'\n\nexport function getCI(): boolean {\n return envAsBoolean(getEnvValue('CI'))\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAA6B,wBAC7BC,EAA4B,uBAErB,SAASH,GAAiB,CAC/B,SAAO,mBAAa,eAAY,IAAI,CAAC,CACvC",
6
+ "names": ["ci_exports", "__export", "getCI", "__toCommonJS", "import_helpers", "import_rewire"]
7
7
  }
@@ -1 +1 @@
1
- export declare const DEBUG: string;
1
+ export declare function getDebug(): string | undefined;
package/dist/env/debug.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var m=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var G=(r,o)=>{for(var e in o)m(r,e,{get:o[e],enumerable:!0})},U=(r,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of D(o))!E.call(r,t)&&t!==e&&m(r,t,{get:()=>o[t],enumerable:!(n=B(o,t))||n.enumerable});return r};var c=r=>U(m({},"__esModule",{value:!0}),r);var i={};G(i,{DEBUG:()=>f});module.exports=c(i);var p=require("node:process");const f=p.env.DEBUG;0&&(module.exports={DEBUG});
2
+ var u=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var m=(n,e)=>{for(var r in e)u(n,r,{get:e[r],enumerable:!0})},p=(n,e,r,g)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!d.call(n,t)&&t!==r&&u(n,t,{get:()=>e[t],enumerable:!(g=o(e,t))||g.enumerable});return n};var D=n=>p(u({},"__esModule",{value:!0}),n);var a={};m(a,{getDebug:()=>E});module.exports=D(a);var i=require("#env/rewire");function E(){return(0,i.getEnvValue)("DEBUG")}0&&(module.exports={getDebug});
3
3
  //# sourceMappingURL=debug.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/env/debug.ts"],
4
- "sourcesContent": ["/**\n * DEBUG environment variable snapshot.\n * Controls debug output for the debug package.\n */\n\nimport { env } from 'node:process'\n\nexport const DEBUG = env['DEBUG']\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAoB,wBAEb,MAAMF,EAAQ,MAAI",
6
- "names": ["debug_exports", "__export", "DEBUG", "__toCommonJS", "import_node_process"]
4
+ "sourcesContent": ["/**\n * DEBUG environment variable getter.\n * Controls debug output for the debug package.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\nexport function getDebug(): string | undefined {\n return getEnvValue('DEBUG')\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAA4B,uBAErB,SAASF,GAA+B,CAC7C,SAAO,eAAY,OAAO,CAC5B",
6
+ "names": ["debug_exports", "__export", "getDebug", "__toCommonJS", "import_rewire"]
7
7
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * GITHUB_API_URL environment variable.
3
+ * GitHub API URL (e.g., https://api.github.com).
4
+ */
5
+ export declare function getGithubApiUrl(): string | undefined;
6
+ /**
7
+ * GITHUB_BASE_REF environment variable.
8
+ * GitHub pull request base branch.
9
+ */
10
+ export declare function getGithubBaseRef(): string | undefined;
11
+ /**
12
+ * GITHUB_REF_NAME environment variable.
13
+ * GitHub branch or tag name.
14
+ */
15
+ export declare function getGithubRefName(): string | undefined;
16
+ /**
17
+ * GITHUB_REF_TYPE environment variable.
18
+ * GitHub ref type (branch or tag).
19
+ */
20
+ export declare function getGithubRefType(): string | undefined;
21
+ /**
22
+ * GITHUB_REPOSITORY environment variable.
23
+ * GitHub repository name in owner/repo format.
24
+ */
25
+ export declare function getGithubRepository(): string | undefined;
26
+ /**
27
+ * GITHUB_SERVER_URL environment variable.
28
+ * GitHub server URL (e.g., https://github.com).
29
+ */
30
+ export declare function getGithubServerUrl(): string | undefined;
31
+ /**
32
+ * GITHUB_TOKEN environment variable.
33
+ * GitHub authentication token for API access.
34
+ */
35
+ export declare function getGithubToken(): string | undefined;
36
+ /**
37
+ * GH_TOKEN environment variable.
38
+ * Alternative GitHub authentication token for API access (used by GitHub CLI).
39
+ */
40
+ export declare function getGhToken(): string | undefined;
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var i in e)u(t,i,{get:e[i],enumerable:!0})},T=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!d.call(t,r)&&r!==i&&u(t,r,{get:()=>e[r],enumerable:!(o=f(e,r))||o.enumerable});return t};var R=t=>T(u({},"__esModule",{value:!0}),t);var h={};G(h,{getGhToken:()=>c,getGithubApiUrl:()=>_,getGithubBaseRef:()=>p,getGithubRefName:()=>E,getGithubRefType:()=>U,getGithubRepository:()=>s,getGithubServerUrl:()=>B,getGithubToken:()=>I});module.exports=R(h);var n=require("#env/rewire");function _(){return(0,n.getEnvValue)("GITHUB_API_URL")}function p(){return(0,n.getEnvValue)("GITHUB_BASE_REF")}function E(){return(0,n.getEnvValue)("GITHUB_REF_NAME")}function U(){return(0,n.getEnvValue)("GITHUB_REF_TYPE")}function s(){return(0,n.getEnvValue)("GITHUB_REPOSITORY")}function B(){return(0,n.getEnvValue)("GITHUB_SERVER_URL")}function I(){return(0,n.getEnvValue)("GITHUB_TOKEN")}function c(){return(0,n.getEnvValue)("GH_TOKEN")}0&&(module.exports={getGhToken,getGithubApiUrl,getGithubBaseRef,getGithubRefName,getGithubRefType,getGithubRepository,getGithubServerUrl,getGithubToken});
3
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/env/github.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview GitHub Actions environment variable getters.\n * Provides access to GitHub Actions CI/CD environment variables.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * GITHUB_API_URL environment variable.\n * GitHub API URL (e.g., https://api.github.com).\n */\nexport function getGithubApiUrl(): string | undefined {\n return getEnvValue('GITHUB_API_URL')\n}\n\n/**\n * GITHUB_BASE_REF environment variable.\n * GitHub pull request base branch.\n */\nexport function getGithubBaseRef(): string | undefined {\n return getEnvValue('GITHUB_BASE_REF')\n}\n\n/**\n * GITHUB_REF_NAME environment variable.\n * GitHub branch or tag name.\n */\nexport function getGithubRefName(): string | undefined {\n return getEnvValue('GITHUB_REF_NAME')\n}\n\n/**\n * GITHUB_REF_TYPE environment variable.\n * GitHub ref type (branch or tag).\n */\nexport function getGithubRefType(): string | undefined {\n return getEnvValue('GITHUB_REF_TYPE')\n}\n\n/**\n * GITHUB_REPOSITORY environment variable.\n * GitHub repository name in owner/repo format.\n */\nexport function getGithubRepository(): string | undefined {\n return getEnvValue('GITHUB_REPOSITORY')\n}\n\n/**\n * GITHUB_SERVER_URL environment variable.\n * GitHub server URL (e.g., https://github.com).\n */\nexport function getGithubServerUrl(): string | undefined {\n return getEnvValue('GITHUB_SERVER_URL')\n}\n\n/**\n * GITHUB_TOKEN environment variable.\n * GitHub authentication token for API access.\n */\nexport function getGithubToken(): string | undefined {\n return getEnvValue('GITHUB_TOKEN')\n}\n\n/**\n * GH_TOKEN environment variable.\n * Alternative GitHub authentication token for API access (used by GitHub CLI).\n */\nexport function getGhToken(): string | undefined {\n return getEnvValue('GH_TOKEN')\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,oBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,wBAAAC,EAAA,uBAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAV,GAKA,IAAAW,EAA4B,uBAMrB,SAASR,GAAsC,CACpD,SAAO,eAAY,gBAAgB,CACrC,CAMO,SAASC,GAAuC,CACrD,SAAO,eAAY,iBAAiB,CACtC,CAMO,SAASC,GAAuC,CACrD,SAAO,eAAY,iBAAiB,CACtC,CAMO,SAASC,GAAuC,CACrD,SAAO,eAAY,iBAAiB,CACtC,CAMO,SAASC,GAA0C,CACxD,SAAO,eAAY,mBAAmB,CACxC,CAMO,SAASC,GAAyC,CACvD,SAAO,eAAY,mBAAmB,CACxC,CAMO,SAASC,GAAqC,CACnD,SAAO,eAAY,cAAc,CACnC,CAMO,SAASP,GAAiC,CAC/C,SAAO,eAAY,UAAU,CAC/B",
6
+ "names": ["github_exports", "__export", "getGhToken", "getGithubApiUrl", "getGithubBaseRef", "getGithubRefName", "getGithubRefType", "getGithubRepository", "getGithubServerUrl", "getGithubToken", "__toCommonJS", "import_rewire"]
7
+ }
@@ -1 +1 @@
1
- export declare const HOME: string;
1
+ export declare function getHome(): string | undefined;
package/dist/env/home.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var O=(r,o)=>{for(var e in o)m(r,e,{get:o[e],enumerable:!0})},c=(r,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of H(o))!M.call(r,t)&&t!==e&&m(r,t,{get:()=>o[t],enumerable:!(n=E(o,t))||n.enumerable});return r};var f=r=>c(m({},"__esModule",{value:!0}),r);var s={};O(s,{HOME:()=>i});module.exports=f(s);var p=require("node:process");const i=p.env.HOME;0&&(module.exports={HOME});
2
+ var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var r in e)o(n,r,{get:e[r],enumerable:!0})},p=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!m.call(n,t)&&t!==r&&o(n,t,{get:()=>e[t],enumerable:!(i=f(e,t))||i.enumerable});return n};var E=n=>p(o({},"__esModule",{value:!0}),n);var a={};d(a,{getHome:()=>H});module.exports=E(a);var u=require("#env/rewire");function H(){return(0,u.getEnvValue)("HOME")}0&&(module.exports={getHome});
3
3
  //# sourceMappingURL=home.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/env/home.ts"],
4
- "sourcesContent": ["/**\n * HOME environment variable snapshot.\n * Points to the user's home directory.\n */\n\nimport { env } from 'node:process'\n\nexport const HOME = env['HOME']\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAAoB,wBAEb,MAAMF,EAAO,MAAI",
6
- "names": ["home_exports", "__export", "HOME", "__toCommonJS", "import_node_process"]
4
+ "sourcesContent": ["/**\n * HOME environment variable getter.\n * Points to the user's home directory.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\nexport function getHome(): string | undefined {\n return getEnvValue('HOME')\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAA4B,uBAErB,SAASF,GAA8B,CAC5C,SAAO,eAAY,MAAM,CAC3B",
6
+ "names": ["home_exports", "__export", "getHome", "__toCommonJS", "import_rewire"]
7
7
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * LANG environment variable.
3
+ * System locale and language settings.
4
+ */
5
+ export declare function getLang(): string | undefined;
6
+ /**
7
+ * LC_ALL environment variable.
8
+ * Override for all locale settings.
9
+ */
10
+ export declare function getLcAll(): string | undefined;
11
+ /**
12
+ * LC_MESSAGES environment variable.
13
+ * Locale setting for message translations.
14
+ */
15
+ export declare function getLcMessages(): string | undefined;