@socketsecurity/lib 6.0.3 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (542) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/_virtual/_rolldown/runtime.js +45 -0
  3. package/dist/abort/signal.js +53 -59
  4. package/dist/ai/discover.js +110 -110
  5. package/dist/ai/profiles.js +94 -65
  6. package/dist/ai/spawn.js +172 -194
  7. package/dist/ai/types.js +1 -17
  8. package/dist/ai/worktree.js +160 -183
  9. package/dist/ansi/constants.js +16 -38
  10. package/dist/ansi/strip.js +44 -41
  11. package/dist/archives/_internal.js +64 -73
  12. package/dist/archives/detect.js +30 -43
  13. package/dist/archives/extract.js +43 -50
  14. package/dist/archives/tar.js +197 -228
  15. package/dist/archives/types.js +1 -17
  16. package/dist/archives/zip.js +85 -121
  17. package/dist/argv/flag-predicates.js +203 -101
  18. package/dist/argv/flag-types.js +96 -113
  19. package/dist/argv/parse-args-string.d.ts +16 -14
  20. package/dist/argv/parse-args-string.js +42 -39
  21. package/dist/argv/parse.js +145 -163
  22. package/dist/arrays/_internal.js +65 -48
  23. package/dist/arrays/chunk.js +51 -40
  24. package/dist/arrays/join.js +87 -35
  25. package/dist/arrays/predicates.js +46 -28
  26. package/dist/arrays/unique.js +45 -31
  27. package/dist/bin/_internal.js +34 -42
  28. package/dist/bin/check-primordials.js +175 -233
  29. package/dist/bin/check.js +51 -72
  30. package/dist/bin/exec.js +70 -74
  31. package/dist/bin/find.js +151 -134
  32. package/dist/bin/resolve.js +180 -246
  33. package/dist/bin/shadow.js +24 -33
  34. package/dist/bin/socket-lib.js +51 -73
  35. package/dist/bin/types.js +1 -17
  36. package/dist/bin/which.js +211 -146
  37. package/dist/cacache/_internal.js +25 -40
  38. package/dist/cacache/clear.js +79 -72
  39. package/dist/cacache/read.js +48 -46
  40. package/dist/cacache/tmp.js +29 -36
  41. package/dist/cacache/types.js +1 -17
  42. package/dist/cacache/write.js +43 -48
  43. package/dist/cache/ttl/store.js +232 -288
  44. package/dist/cache/ttl/types.js +1 -17
  45. package/dist/checks/primordials-defaults.js +83 -89
  46. package/dist/checks/primordials.js +225 -277
  47. package/dist/colors/convert.js +45 -37
  48. package/dist/colors/palette.js +88 -45
  49. package/dist/colors/socket-palette.js +74 -84
  50. package/dist/colors/types.js +1 -17
  51. package/dist/compression/_internal.js +57 -72
  52. package/dist/compression/brotli.js +94 -127
  53. package/dist/compression/gzip.js +95 -121
  54. package/dist/compression/types.js +1 -17
  55. package/dist/constants/agents.js +61 -113
  56. package/dist/constants/encoding.js +19 -42
  57. package/dist/constants/github.js +12 -30
  58. package/dist/constants/licenses.js +48 -63
  59. package/dist/constants/lifecycle-script-names.js +31 -45
  60. package/dist/constants/maintained-node-versions.js +22 -37
  61. package/dist/constants/node.js +226 -167
  62. package/dist/constants/package-default-node-range.js +16 -41
  63. package/dist/constants/package-default-socket-categories.js +12 -30
  64. package/dist/constants/packages.js +77 -126
  65. package/dist/constants/platform.js +27 -49
  66. package/dist/constants/sentinels.js +23 -48
  67. package/dist/constants/socket.js +42 -87
  68. package/dist/constants/testing.js +15 -34
  69. package/dist/constants/time.js +16 -36
  70. package/dist/constants/typescript.js +32 -52
  71. package/dist/cover/code.js +111 -142
  72. package/dist/cover/formatters.js +118 -101
  73. package/dist/cover/type.js +50 -76
  74. package/dist/cover/types.js +1 -17
  75. package/dist/crypto/hash.js +54 -46
  76. package/dist/debug/_internal.js +62 -71
  77. package/dist/debug/caller-info.js +53 -64
  78. package/dist/debug/namespace.js +80 -90
  79. package/dist/debug/output.js +172 -188
  80. package/dist/debug/types.js +1 -17
  81. package/dist/dlx/_internal.js +24 -43
  82. package/dist/dlx/arborist.js +162 -160
  83. package/dist/dlx/binary-cache.js +228 -200
  84. package/dist/dlx/binary-download.js +172 -211
  85. package/dist/dlx/binary-resolution.js +165 -157
  86. package/dist/dlx/binary-types.js +1 -17
  87. package/dist/dlx/binary.js +149 -189
  88. package/dist/dlx/cache.js +45 -30
  89. package/dist/dlx/detect.js +245 -159
  90. package/dist/dlx/dir.js +67 -51
  91. package/dist/dlx/firewall.js +62 -100
  92. package/dist/dlx/lockfile.js +122 -127
  93. package/dist/dlx/manifest.js +264 -274
  94. package/dist/dlx/package.js +241 -244
  95. package/dist/dlx/packages.js +99 -96
  96. package/dist/dlx/paths.js +73 -59
  97. package/dist/dlx/spec.js +52 -60
  98. package/dist/dlx/types.js +1 -17
  99. package/dist/eco/cargo/lockfile-format.js +19 -36
  100. package/dist/eco/cargo/manifest-format.js +17 -35
  101. package/dist/eco/cargo/parse-lockfile.js +210 -237
  102. package/dist/eco/manifest/analyze-lockfile.js +46 -63
  103. package/dist/eco/manifest/detect-format.js +66 -90
  104. package/dist/eco/manifest/find-packages.js +39 -64
  105. package/dist/eco/manifest/get-package-versions.js +27 -48
  106. package/dist/eco/manifest/get-package.js +21 -40
  107. package/dist/eco/manifest/manifest-error.js +14 -35
  108. package/dist/eco/manifest/parse-lockfile.js +40 -86
  109. package/dist/eco/manifest/parse-manifest.js +26 -43
  110. package/dist/eco/manifest/parse.js +26 -47
  111. package/dist/eco/manifest/types.js +1 -17
  112. package/dist/eco/npm/bun/exec.js +23 -32
  113. package/dist/eco/npm/manifest-format.js +21 -35
  114. package/dist/eco/npm/npm/exec.js +51 -61
  115. package/dist/eco/npm/npm/extract-package-name-from-path.js +28 -50
  116. package/dist/eco/npm/npm/flags.js +80 -52
  117. package/dist/eco/npm/npm/lockfile-format.js +21 -40
  118. package/dist/eco/npm/npm/parse-git-url.js +26 -40
  119. package/dist/eco/npm/npm/parse-lockfile.js +184 -210
  120. package/dist/eco/npm/parse-package-json.js +71 -102
  121. package/dist/eco/npm/pnpm/detect-pnpm-version.js +22 -43
  122. package/dist/eco/npm/pnpm/exec.js +51 -62
  123. package/dist/eco/npm/pnpm/flags.js +75 -68
  124. package/dist/eco/npm/pnpm/lockfile-format.js +19 -36
  125. package/dist/eco/npm/pnpm/parse-lockfile.js +235 -259
  126. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v5.js +37 -47
  127. package/dist/eco/npm/pnpm/parse-pnpm-package-id-v6-v9.js +36 -49
  128. package/dist/eco/npm/script.js +82 -90
  129. package/dist/eco/npm/vlt/exec.js +24 -32
  130. package/dist/eco/npm/yarnpkg/yarn/exec.js +60 -59
  131. package/dist/eco/npm/yarnpkg/yarn/lockfile-format.js +20 -36
  132. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +194 -242
  133. package/dist/eco/npm/yarnpkg/yarn/parse-yarn-descriptor.js +37 -61
  134. package/dist/eco/purl.js +50 -60
  135. package/dist/eco/types.js +1 -17
  136. package/dist/effects/pulse-frames.js +64 -65
  137. package/dist/effects/shimmer-keyframes.js +71 -52
  138. package/dist/effects/shimmer-terminal.js +81 -50
  139. package/dist/effects/shimmer.js +290 -153
  140. package/dist/env/boolean.js +42 -43
  141. package/dist/env/case-insensitive.js +54 -39
  142. package/dist/env/ci.js +29 -31
  143. package/dist/env/debug.js +28 -31
  144. package/dist/env/github.js +144 -59
  145. package/dist/env/home.js +38 -31
  146. package/dist/env/locale.js +59 -39
  147. package/dist/env/node-auth-token.js +28 -31
  148. package/dist/env/node-env.js +28 -31
  149. package/dist/env/npm.js +94 -47
  150. package/dist/env/number.js +50 -51
  151. package/dist/env/package-manager.js +95 -83
  152. package/dist/env/path.js +28 -31
  153. package/dist/env/pre-commit.js +30 -32
  154. package/dist/env/proxy.js +121 -122
  155. package/dist/env/rewire.js +204 -96
  156. package/dist/env/shell.js +28 -31
  157. package/dist/env/socket-cli.js +233 -81
  158. package/dist/env/socket.js +521 -156
  159. package/dist/env/string.js +43 -44
  160. package/dist/env/temp-dir.js +59 -39
  161. package/dist/env/term.js +28 -31
  162. package/dist/env/test.js +65 -43
  163. package/dist/env/types.js +1 -17
  164. package/dist/env/windows.js +78 -43
  165. package/dist/env/xdg.js +62 -39
  166. package/dist/errors/message.js +40 -46
  167. package/dist/errors/predicates.js +61 -49
  168. package/dist/errors/stack.js +24 -36
  169. package/dist/events/exit/_internal.js +86 -103
  170. package/dist/events/exit/handler.js +48 -55
  171. package/dist/events/exit/intercept.js +49 -70
  172. package/dist/events/exit/lifecycle.js +92 -101
  173. package/dist/events/exit/signals.js +25 -31
  174. package/dist/events/exit/types.js +1 -17
  175. package/dist/events/warning/handler.js +43 -40
  176. package/dist/events/warning/suppress.js +111 -90
  177. package/dist/external/@npmcli/package-json/lib/read-package.js +132 -153
  178. package/dist/external/@npmcli/package-json/lib/sort.js +73 -105
  179. package/dist/external/@npmcli/package-json.js +12705 -15140
  180. package/dist/external/@npmcli/promise-spawn.js +451 -472
  181. package/dist/external/@sinclair/typebox/value.js +7443 -9002
  182. package/dist/external/@sinclair/typebox.js +7516 -7885
  183. package/dist/external/@socketregistry/is-unicode-supported.js +31 -39
  184. package/dist/external/@socketregistry/packageurl-js.js +6127 -7369
  185. package/dist/external/@socketregistry/yocto-spinner.js +394 -455
  186. package/dist/external/@yarnpkg/extensions.js +435 -1022
  187. package/dist/external/adm-zip.js +2313 -2673
  188. package/dist/external/debug.js +700 -687
  189. package/dist/external/external-pack.js +2658 -3171
  190. package/dist/external/fast-sort.js +124 -138
  191. package/dist/external/get-east-asian-width.js +70 -64
  192. package/dist/external/libnpmexec.js +28 -31
  193. package/dist/external/npm-pack.js +43617 -50137
  194. package/dist/external/p-map.js +198 -222
  195. package/dist/external/pico-pack.js +6735 -7304
  196. package/dist/external/pony-cause.js +143 -139
  197. package/dist/external/shell-quote.js +226 -0
  198. package/dist/external/spdx-pack.js +1283 -1403
  199. package/dist/external/streaming-iterables.js +835 -1052
  200. package/dist/external/tar-fs.js +2769 -3048
  201. package/dist/external/which.js +267 -251
  202. package/dist/external/yargs-parser.js +851 -1074
  203. package/dist/external-tools/bazel/asset-names.js +98 -90
  204. package/dist/external-tools/bazel/from-download.js +52 -46
  205. package/dist/external-tools/bazel/from-path.js +27 -38
  206. package/dist/external-tools/bazel/read-bazel-version-file.js +35 -57
  207. package/dist/external-tools/bazel/resolve-asset-url.js +24 -39
  208. package/dist/external-tools/bazel/resolve-bazel-version.js +34 -56
  209. package/dist/external-tools/bazel/resolve.js +44 -58
  210. package/dist/external-tools/bazel/types.js +1 -17
  211. package/dist/external-tools/cdxgen/asset-names.js +59 -66
  212. package/dist/external-tools/cdxgen/from-download.js +52 -80
  213. package/dist/external-tools/cdxgen/from-path.js +19 -37
  214. package/dist/external-tools/cdxgen/from-vfs.js +22 -43
  215. package/dist/external-tools/cdxgen/resolve.js +48 -63
  216. package/dist/external-tools/cdxgen/types.js +1 -17
  217. package/dist/external-tools/from-download.js +107 -67
  218. package/dist/external-tools/janus/asset-names.js +44 -51
  219. package/dist/external-tools/janus/from-download.js +45 -70
  220. package/dist/external-tools/janus/from-path.js +19 -37
  221. package/dist/external-tools/janus/from-vfs.js +22 -43
  222. package/dist/external-tools/janus/resolve.js +45 -63
  223. package/dist/external-tools/janus/types.js +1 -17
  224. package/dist/external-tools/jre/asset-names.js +109 -82
  225. package/dist/external-tools/jre/detect-platform-arch.js +25 -49
  226. package/dist/external-tools/jre/from-download.js +71 -67
  227. package/dist/external-tools/jre/from-java-home.js +27 -54
  228. package/dist/external-tools/jre/from-path.js +27 -49
  229. package/dist/external-tools/jre/from-vfs.js +39 -60
  230. package/dist/external-tools/jre/resolve.js +55 -68
  231. package/dist/external-tools/jre/types.js +1 -17
  232. package/dist/external-tools/manifest.js +130 -150
  233. package/dist/external-tools/opengrep/asset-names.js +60 -72
  234. package/dist/external-tools/opengrep/from-download.js +58 -80
  235. package/dist/external-tools/opengrep/from-path.js +19 -37
  236. package/dist/external-tools/opengrep/from-vfs.js +23 -43
  237. package/dist/external-tools/opengrep/resolve.js +43 -63
  238. package/dist/external-tools/opengrep/types.js +1 -17
  239. package/dist/external-tools/sbt/asset-names.js +21 -30
  240. package/dist/external-tools/sbt/from-download.js +50 -61
  241. package/dist/external-tools/sbt/from-path.js +23 -38
  242. package/dist/external-tools/sbt/from-vfs.js +30 -44
  243. package/dist/external-tools/sbt/resolve.js +45 -63
  244. package/dist/external-tools/sbt/types.js +1 -17
  245. package/dist/external-tools/synp/asset-names.js +11 -29
  246. package/dist/external-tools/synp/from-download.js +24 -41
  247. package/dist/external-tools/synp/from-path.js +19 -37
  248. package/dist/external-tools/synp/from-vfs.js +22 -43
  249. package/dist/external-tools/synp/resolve.js +43 -62
  250. package/dist/external-tools/synp/types.js +1 -17
  251. package/dist/external-tools/trivy/asset-names.js +51 -62
  252. package/dist/external-tools/trivy/from-download.js +42 -64
  253. package/dist/external-tools/trivy/from-path.js +19 -37
  254. package/dist/external-tools/trivy/from-vfs.js +22 -43
  255. package/dist/external-tools/trivy/resolve.js +43 -63
  256. package/dist/external-tools/trivy/types.js +1 -17
  257. package/dist/external-tools/trufflehog/asset-names.js +54 -66
  258. package/dist/external-tools/trufflehog/from-download.js +44 -62
  259. package/dist/external-tools/trufflehog/from-path.js +21 -37
  260. package/dist/external-tools/trufflehog/from-vfs.js +26 -43
  261. package/dist/external-tools/trufflehog/resolve.js +43 -63
  262. package/dist/external-tools/trufflehog/types.js +1 -17
  263. package/dist/external-tools/uv/asset-names.js +64 -74
  264. package/dist/external-tools/uv/from-download.js +44 -65
  265. package/dist/external-tools/uv/from-path.js +19 -37
  266. package/dist/external-tools/uv/from-vfs.js +22 -43
  267. package/dist/external-tools/uv/resolve.js +42 -63
  268. package/dist/external-tools/uv/types.js +1 -17
  269. package/dist/fs/_internal.js +40 -42
  270. package/dist/fs/access.js +57 -54
  271. package/dist/fs/encoding.js +80 -97
  272. package/dist/fs/find-up.js +126 -125
  273. package/dist/fs/inspect.js +168 -99
  274. package/dist/fs/path-cache.js +31 -32
  275. package/dist/fs/read-dir.js +102 -79
  276. package/dist/fs/read-file.js +177 -118
  277. package/dist/fs/read-json-cache.js +150 -134
  278. package/dist/fs/read-json.js +172 -187
  279. package/dist/fs/resolve-module.js +35 -58
  280. package/dist/fs/safe.js +278 -169
  281. package/dist/fs/types.js +1 -17
  282. package/dist/fs/unique.js +52 -48
  283. package/dist/fs/validate.js +56 -40
  284. package/dist/fs/write-json.js +109 -75
  285. package/dist/git/_internal.js +251 -216
  286. package/dist/git/changed.js +191 -74
  287. package/dist/git/repo.js +118 -104
  288. package/dist/git/staged.js +172 -62
  289. package/dist/git/types.js +1 -17
  290. package/dist/git/unstaged.js +175 -62
  291. package/dist/github/constants.js +25 -33
  292. package/dist/github/errors.js +46 -38
  293. package/dist/github/fetch.js +137 -82
  294. package/dist/github/ghsa.js +217 -151
  295. package/dist/github/refs-cache.js +54 -43
  296. package/dist/github/refs-graphql.js +97 -89
  297. package/dist/github/refs-rest.js +70 -101
  298. package/dist/github/refs.js +105 -64
  299. package/dist/github/token.js +96 -48
  300. package/dist/github/types.js +1 -17
  301. package/dist/globs/_internal.js +73 -82
  302. package/dist/globs/defaults.js +40 -59
  303. package/dist/globs/match.js +93 -77
  304. package/dist/globs/matcher.js +104 -92
  305. package/dist/globs/stream.js +43 -55
  306. package/dist/globs/types.js +1 -17
  307. package/dist/http-request/_internal.js +11 -38
  308. package/dist/http-request/browser-fetch.js +19 -29
  309. package/dist/http-request/browser.js +188 -206
  310. package/dist/http-request/checksums.js +101 -65
  311. package/dist/http-request/download-types.js +1 -17
  312. package/dist/http-request/download.js +195 -196
  313. package/dist/http-request/errors.js +39 -47
  314. package/dist/http-request/headers.js +95 -80
  315. package/dist/http-request/http-request.js +10 -35
  316. package/dist/http-request/node.js +71 -97
  317. package/dist/http-request/request-attempt.js +232 -285
  318. package/dist/http-request/request-types.js +1 -17
  319. package/dist/http-request/request.js +106 -108
  320. package/dist/http-request/response-reader.js +47 -51
  321. package/dist/http-request/response-types.js +22 -38
  322. package/dist/http-request/user-agent.js +73 -55
  323. package/dist/integrity.js +105 -106
  324. package/dist/ipc/_internal.js +34 -48
  325. package/dist/ipc/directory.js +55 -63
  326. package/dist/ipc/paths.js +52 -45
  327. package/dist/ipc/types.js +1 -17
  328. package/dist/ipc/write.js +81 -74
  329. package/dist/ipc-cli/get.js +29 -56
  330. package/dist/ipc-cli/types.js +1 -17
  331. package/dist/json/edit.js +182 -242
  332. package/dist/json/format.js +202 -103
  333. package/dist/json/parse.js +206 -109
  334. package/dist/json/types.js +1 -17
  335. package/dist/links/create.js +93 -60
  336. package/dist/links/types.js +1 -17
  337. package/dist/logger/_internal.js +109 -73
  338. package/dist/logger/browser.js +45 -56
  339. package/dist/logger/colors.js +31 -49
  340. package/dist/logger/console.js +89 -112
  341. package/dist/logger/default.js +19 -33
  342. package/dist/logger/logger.js +5 -29
  343. package/dist/logger/node.js +794 -854
  344. package/dist/logger/symbols-builder.js +54 -56
  345. package/dist/logger/symbols.js +135 -118
  346. package/dist/logger/types.js +1 -17
  347. package/dist/memo/_internal.js +39 -49
  348. package/dist/memo/async.js +133 -117
  349. package/dist/memo/clear.js +25 -34
  350. package/dist/memo/decorator.js +43 -37
  351. package/dist/memo/memoize.js +97 -88
  352. package/dist/memo/once.js +42 -41
  353. package/dist/memo/types.js +1 -17
  354. package/dist/memo/weak.js +45 -41
  355. package/dist/node/async-hooks.js +9 -30
  356. package/dist/node/child-process.js +9 -30
  357. package/dist/node/crypto.js +9 -30
  358. package/dist/node/events.js +9 -30
  359. package/dist/node/fs-promises.js +9 -30
  360. package/dist/node/fs.js +9 -30
  361. package/dist/node/http.js +9 -30
  362. package/dist/node/https.js +9 -30
  363. package/dist/node/module.js +20 -34
  364. package/dist/node/os.js +9 -30
  365. package/dist/node/path.js +9 -30
  366. package/dist/node/timers-promises.js +9 -30
  367. package/dist/node/url.js +9 -30
  368. package/dist/node/util.js +9 -30
  369. package/dist/objects/getters.js +185 -126
  370. package/dist/objects/inspect.js +85 -52
  371. package/dist/objects/mutate.js +96 -76
  372. package/dist/objects/predicates.js +112 -59
  373. package/dist/objects/sort.js +120 -76
  374. package/dist/objects/types.js +1 -17
  375. package/dist/packages/edit-class.js +198 -265
  376. package/dist/packages/edit.js +79 -86
  377. package/dist/packages/exports.js +146 -157
  378. package/dist/packages/isolation.js +159 -209
  379. package/dist/packages/licenses.js +207 -189
  380. package/dist/packages/manifest.js +134 -172
  381. package/dist/packages/normalize.js +91 -102
  382. package/dist/packages/operations.d.ts +2 -0
  383. package/dist/packages/operations.js +283 -254
  384. package/dist/packages/provenance.js +195 -245
  385. package/dist/packages/specs.js +94 -84
  386. package/dist/packages/types.js +1 -17
  387. package/dist/packages/validation.js +49 -50
  388. package/dist/paths/_internal.js +82 -86
  389. package/dist/paths/conversion.js +112 -65
  390. package/dist/paths/dirnames.js +17 -42
  391. package/dist/paths/exts.js +23 -54
  392. package/dist/paths/filenames.js +21 -50
  393. package/dist/paths/globs.js +15 -38
  394. package/dist/paths/normalize.js +215 -236
  395. package/dist/paths/packages.js +34 -49
  396. package/dist/paths/predicates.js +184 -106
  397. package/dist/paths/resolve.js +146 -128
  398. package/dist/paths/rewire.js +108 -72
  399. package/dist/paths/socket.js +252 -132
  400. package/dist/paths/walk.js +55 -60
  401. package/dist/perf/_internal.js +10 -28
  402. package/dist/perf/enabled.js +21 -30
  403. package/dist/perf/metrics.js +81 -67
  404. package/dist/perf/report.js +79 -80
  405. package/dist/perf/timer.js +180 -126
  406. package/dist/perf/types.js +1 -17
  407. package/dist/pkg-ext/data.js +29 -82
  408. package/dist/pkg-ext/types.js +1 -17
  409. package/dist/primordials/array.js +120 -198
  410. package/dist/primordials/buffer.js +28 -51
  411. package/dist/primordials/date.js +26 -51
  412. package/dist/primordials/error.js +33 -59
  413. package/dist/primordials/function.js +21 -41
  414. package/dist/primordials/globals.js +25 -48
  415. package/dist/primordials/json.js +14 -30
  416. package/dist/primordials/map-set.js +88 -152
  417. package/dist/primordials/math.js +59 -116
  418. package/dist/primordials/number.js +41 -76
  419. package/dist/primordials/object.js +56 -116
  420. package/dist/primordials/promise.js +28 -52
  421. package/dist/primordials/reflect.js +24 -52
  422. package/dist/primordials/regexp.js +25 -47
  423. package/dist/primordials/string.js +114 -167
  424. package/dist/primordials/symbol.js +40 -72
  425. package/dist/primordials/uncurry.js +38 -55
  426. package/dist/primordials/url.js +27 -66
  427. package/dist/process/_internal.js +7 -32
  428. package/dist/process/abort.js +29 -35
  429. package/dist/process/lock-instance.js +26 -30
  430. package/dist/process/lock-manager.js +279 -307
  431. package/dist/process/lock-types.js +1 -17
  432. package/dist/process/spawn/_internal.js +43 -55
  433. package/dist/process/spawn/child.js +172 -211
  434. package/dist/process/spawn/errors.js +116 -113
  435. package/dist/process/spawn/stdio.js +51 -35
  436. package/dist/process/spawn/types.js +1 -17
  437. package/dist/process/transient.js +49 -66
  438. package/dist/promises/_internal.js +31 -34
  439. package/dist/promises/iterate.js +238 -102
  440. package/dist/promises/options.js +123 -101
  441. package/dist/promises/queue.js +115 -136
  442. package/dist/promises/resolvers.js +77 -46
  443. package/dist/promises/retry.js +156 -101
  444. package/dist/promises/types.js +1 -17
  445. package/dist/regexps/escape.js +32 -30
  446. package/dist/regexps/hex.js +16 -33
  447. package/dist/regexps/spec.js +53 -81
  448. package/dist/releases/github-archives.js +127 -118
  449. package/dist/releases/github-asset-url.js +162 -146
  450. package/dist/releases/github-assets.js +37 -49
  451. package/dist/releases/github-auth.js +32 -48
  452. package/dist/releases/github-downloads.js +118 -138
  453. package/dist/releases/github-listing.js +175 -145
  454. package/dist/releases/github-retry-config.js +41 -47
  455. package/dist/releases/github-types.js +1 -17
  456. package/dist/releases/socket-btm.js +273 -192
  457. package/dist/schema/parse.js +35 -36
  458. package/dist/schema/types.js +1 -17
  459. package/dist/schema/validate.js +118 -99
  460. package/dist/sea/detect.js +57 -52
  461. package/dist/secrets/_internal.js +86 -67
  462. package/dist/secrets/find.js +96 -77
  463. package/dist/secrets/keychain.js +315 -309
  464. package/dist/secrets/linux.js +133 -135
  465. package/dist/secrets/macos.js +151 -147
  466. package/dist/secrets/rc.js +182 -181
  467. package/dist/secrets/socket-api-token.js +28 -43
  468. package/dist/secrets/types.js +1 -17
  469. package/dist/secrets/windows.js +184 -242
  470. package/dist/shadow/skip.js +51 -70
  471. package/dist/shadow/types.js +1 -17
  472. package/dist/shell/parse.d.ts +26 -0
  473. package/dist/shell/parse.js +35 -0
  474. package/dist/shell/quote.d.ts +19 -0
  475. package/dist/shell/quote.js +30 -0
  476. package/dist/smol/detect.js +67 -43
  477. package/dist/smol/http.js +33 -37
  478. package/dist/smol/https.js +31 -37
  479. package/dist/smol/manifest.js +33 -37
  480. package/dist/smol/path.js +33 -37
  481. package/dist/smol/primordial.js +35 -37
  482. package/dist/smol/purl.js +34 -37
  483. package/dist/smol/versions.js +31 -37
  484. package/dist/smol/vfs.js +46 -38
  485. package/dist/sorts/_internal.js +14 -40
  486. package/dist/sorts/natural.js +57 -64
  487. package/dist/sorts/semver.js +33 -43
  488. package/dist/sorts/strings.js +24 -30
  489. package/dist/sorts/types.js +1 -17
  490. package/dist/spinner/default.js +72 -63
  491. package/dist/spinner/format.js +86 -71
  492. package/dist/spinner/spinner.js +749 -797
  493. package/dist/spinner/types.js +1 -17
  494. package/dist/spinner/with.js +193 -137
  495. package/dist/ssri/convert.js +64 -47
  496. package/dist/ssri/parse.js +38 -37
  497. package/dist/ssri/validate.js +51 -34
  498. package/dist/stdio/_internal.js +50 -46
  499. package/dist/stdio/clear.js +208 -86
  500. package/dist/stdio/divider.js +170 -97
  501. package/dist/stdio/footer.js +116 -110
  502. package/dist/stdio/header.js +117 -90
  503. package/dist/stdio/progress.js +189 -218
  504. package/dist/stdio/prompts.js +244 -168
  505. package/dist/stdio/stderr.js +173 -78
  506. package/dist/stdio/stdout.js +177 -94
  507. package/dist/streams/parallel.js +58 -50
  508. package/dist/streams/transform.js +36 -45
  509. package/dist/strings/format.js +145 -63
  510. package/dist/strings/predicates.js +56 -34
  511. package/dist/strings/search.js +52 -42
  512. package/dist/strings/transform.js +113 -72
  513. package/dist/strings/types.js +1 -17
  514. package/dist/strings/width.js +89 -82
  515. package/dist/tables/bordered.js +81 -81
  516. package/dist/tables/padding.js +36 -46
  517. package/dist/tables/simple.js +62 -70
  518. package/dist/tables/types.js +1 -17
  519. package/dist/temporal/instant.js +72 -81
  520. package/dist/temporal/now.js +40 -31
  521. package/dist/temporal/slots.js +42 -36
  522. package/dist/temporal/system.js +36 -36
  523. package/dist/temporal/temporal.js +11 -41
  524. package/dist/themes/context.js +131 -69
  525. package/dist/themes/resolve.js +207 -132
  526. package/dist/themes/themes.js +225 -194
  527. package/dist/themes/types.js +1 -17
  528. package/dist/url/parse.js +48 -51
  529. package/dist/url/predicates.js +24 -31
  530. package/dist/url/search-params.js +133 -101
  531. package/dist/url/types.js +1 -17
  532. package/dist/versions/_internal.js +31 -33
  533. package/dist/versions/compare.js +80 -58
  534. package/dist/versions/modify.js +41 -39
  535. package/dist/versions/parse.js +88 -64
  536. package/dist/versions/range.js +58 -41
  537. package/dist/versions/types.js +1 -17
  538. package/dist/words/article.js +22 -30
  539. package/dist/words/capitalize.js +25 -34
  540. package/dist/words/pluralize.js +23 -31
  541. package/dist/words/types.js +1 -17
  542. package/package.json +17 -5
@@ -1,856 +1,796 @@
1
1
  "use strict";
2
- /* Socket Lib - Built with esbuild */
3
- "use strict";
4
- var __create = Object.create;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
+ const require_primordials_error = require('../primordials/error.js');
6
+ const require_primordials_math = require('../primordials/math.js');
7
+ const require_primordials_array = require('../primordials/array.js');
8
+ const require_primordials_reflect = require('../primordials/reflect.js');
9
+ const require_strings_format = require('../strings/format.js');
10
+ const require_strings_predicates = require('../strings/predicates.js');
11
+ const require_themes_themes = require('../themes/themes.js');
12
+ const require_themes_context = require('../themes/context.js');
13
+ const require_logger__internal = require('./_internal.js');
14
+ const require_logger_symbols_builder = require('./symbols-builder.js');
15
+ const require_logger_symbols = require('./symbols.js');
16
+ const require_logger_console = require('./console.js');
17
+ let node_process = require("node:process");
18
+ node_process = require_runtime.__toESM(node_process);
19
+
20
+ //#region src/logger/node.ts
21
+ /**
22
+ * @file Node-side `Logger` class — owns the per-instance state (parent, bound
23
+ * stream, indent buffers, theme), the symbol-prefixed semantic methods
24
+ * (`success`, `fail`, `info`, ...), and the chainable wrappers around the
25
+ * underlying `node:console` methods. The shared-default singleton lives in
26
+ * `./default`; this file exports only the class. Consumers should import
27
+ * `Logger` from `./logger` (auto-routed by the package.json `browser`
28
+ * condition); `./node` is the explicit Node entry, useful for tests pinning
29
+ * to one implementation. Console construction is deliberately lazy: the
30
+ * constructor only stashes its args in `_internal.privateConstructorArgs`;
31
+ * the actual `node:console` instance is built on first call to
32
+ * `#getConsole()`. This lets the logger be imported during early Node.js
33
+ * bootstrap before stdout is ready, avoiding `ERR_CONSOLE_WRITABLE_STREAM`.
34
+ * Free helpers live in sibling leaves (per `socket-lib`'s
35
+ * export-top-level-functions rule):
36
+ *
37
+ * - color helpers — `./colors` (`applyColor`, `getYoctocolors`)
38
+ * - log symbols + symbol getters — `./symbols`
39
+ * - lazy console init + prototype mirror — `./console-init`
40
+ * - shared private state — `./_internal`
41
+ */
42
+ /**
43
+ * Enhanced console logger with indentation, colored symbols, and stream
44
+ * management.
45
+ */
46
+ /*@__PURE__*/
47
+ var Logger = class Logger {
48
+ /**
49
+ * Static reference to log symbols for convenience.
50
+ */
51
+ static LOG_SYMBOLS = require_logger_symbols.LOG_SYMBOLS;
52
+ #parent;
53
+ #boundStream;
54
+ #stderrLogger;
55
+ #stdoutLogger;
56
+ #stderrIndention = "";
57
+ #stdoutIndention = "";
58
+ #stderrLastWasBlank = false;
59
+ #stdoutLastWasBlank = false;
60
+ #logCallCount = 0;
61
+ #options;
62
+ #originalStdout;
63
+ #theme;
64
+ /**
65
+ * Creates a new Logger instance.
66
+ *
67
+ * When called without arguments, creates a logger using the default
68
+ * `process.stdout` and `process.stderr` streams. Can accept custom console
69
+ * constructor arguments for advanced use cases.
70
+ *
71
+ * @param args - Optional console constructor arguments.
72
+ */
73
+ constructor(...args) {
74
+ require_logger__internal.privateConstructorArgs.set(this, args);
75
+ const options = args["0"];
76
+ if (typeof options === "object" && options !== null) {
77
+ this.#options = {
78
+ __proto__: null,
79
+ ...options
80
+ };
81
+ this.#originalStdout = options.stdout;
82
+ const themeOption = options.theme;
83
+ if (themeOption) if (typeof themeOption === "string") {
84
+ const resolved = require_themes_themes.THEMES[themeOption];
85
+ if (resolved) this.#theme = resolved;
86
+ } else this.#theme = themeOption;
87
+ } else this.#options = { __proto__: null };
88
+ }
89
+ /**
90
+ * Apply a console method with indentation.
91
+ *
92
+ * @private
93
+ */
94
+ #apply(methodName, args, stream) {
95
+ const con = this.#getConsole();
96
+ const text = require_primordials_array.ArrayPrototypeAt(args, 0);
97
+ const hasText = typeof text === "string";
98
+ const targetStream = stream || (methodName === "log" ? "stdout" : "stderr");
99
+ const indent = this.#getIndent(targetStream);
100
+ const logArgs = hasText ? [/* @__PURE__ */ require_strings_format.applyLinePrefix(text, { prefix: indent }), ...require_primordials_array.ArrayPrototypeSlice(args, 1)] : args;
101
+ require_primordials_reflect.ReflectApply(con[methodName], con, logArgs);
102
+ this[require_logger_symbols.lastWasBlankSymbol](hasText && /* @__PURE__ */ require_strings_predicates.isBlankString(logArgs[0]), targetStream);
103
+ this[require_logger_symbols.incLogCallCountSymbol]();
104
+ return this;
105
+ }
106
+ /**
107
+ * Get the Console instance for this logger, creating it lazily on first
108
+ * access.
109
+ *
110
+ * This lazy initialization allows the logger to be imported during early
111
+ * Node.js bootstrap before stdout is ready, avoiding Console initialization
112
+ * errors (ERR_CONSOLE_WRITABLE_STREAM).
113
+ *
114
+ * @private
115
+ */
116
+ #getConsole() {
117
+ require_logger_console.ensurePrototypeInitialized();
118
+ let con = require_logger__internal.privateConsole.get(this);
119
+ /* c8 ignore start */
120
+ if (!con) {
121
+ const ctorArgs = require_logger__internal.privateConstructorArgs.get(this) ?? [];
122
+ if (ctorArgs.length) con = /* @__PURE__ */ require_logger_console.constructConsole(...ctorArgs);
123
+ else {
124
+ con = /* @__PURE__ */ require_logger_console.constructConsole({
125
+ stdout: node_process.default.stdout,
126
+ stderr: node_process.default.stderr
127
+ });
128
+ for (const { 0: key, 1: method } of require_logger__internal.boundConsoleEntries) con[key] = method;
129
+ }
130
+ require_logger__internal.privateConsole.set(this, con);
131
+ require_logger__internal.privateConstructorArgs.delete(this);
132
+ }
133
+ /* c8 ignore stop */
134
+ return con;
135
+ }
136
+ /**
137
+ * Get indentation for a specific stream.
138
+ *
139
+ * @private
140
+ */
141
+ #getIndent(stream) {
142
+ const root = this.#getRoot();
143
+ return stream === "stderr" ? root.#stderrIndention : root.#stdoutIndention;
144
+ }
145
+ /**
146
+ * Get lastWasBlank state for a specific stream.
147
+ *
148
+ * @private
149
+ */
150
+ #getLastWasBlank(stream) {
151
+ const root = this.#getRoot();
152
+ return stream === "stderr" ? root.#stderrLastWasBlank : root.#stdoutLastWasBlank;
153
+ }
154
+ /**
155
+ * Get the root logger (for accessing shared indentation state).
156
+ *
157
+ * @private
158
+ */
159
+ #getRoot() {
160
+ return this.#parent || this;
161
+ }
162
+ /**
163
+ * Get logger-specific symbols using the resolved theme.
164
+ *
165
+ * @private
166
+ */
167
+ #getSymbols() {
168
+ return require_logger_symbols_builder.buildLoggerSymbols(this.#getTheme());
169
+ }
170
+ /**
171
+ * Get the target stream for this logger instance.
172
+ *
173
+ * @private
174
+ */
175
+ #getTargetStream() {
176
+ return this.#boundStream || "stderr";
177
+ }
178
+ /**
179
+ * Get the resolved theme for this logger instance. Returns instance theme if
180
+ * set, otherwise falls back to context theme.
181
+ *
182
+ * @private
183
+ */
184
+ #getTheme() {
185
+ return this.#theme ?? require_themes_context.getTheme();
186
+ }
187
+ /**
188
+ * Set indentation for a specific stream.
189
+ *
190
+ * @private
191
+ */
192
+ #setIndent(stream, value) {
193
+ const root = this.#getRoot();
194
+ if (stream === "stderr") root.#stderrIndention = value;
195
+ else root.#stdoutIndention = value;
196
+ }
197
+ /**
198
+ * Set lastWasBlank state for a specific stream.
199
+ *
200
+ * @private
201
+ */
202
+ #setLastWasBlank(stream, value) {
203
+ const root = this.#getRoot();
204
+ if (stream === "stderr") root.#stderrLastWasBlank = value;
205
+ else root.#stdoutLastWasBlank = value;
206
+ }
207
+ /**
208
+ * Strip log symbols from the start of text.
209
+ *
210
+ * @private
211
+ */
212
+ #stripSymbols(text) {
213
+ return require_logger_symbols_builder.stripLoggerSymbols(text);
214
+ }
215
+ /**
216
+ * Apply a method with a symbol prefix.
217
+ *
218
+ * @private
219
+ */
220
+ #symbolApply(symbolType, args) {
221
+ const con = this.#getConsole();
222
+ let text = require_primordials_array.ArrayPrototypeAt(args, 0);
223
+ let extras;
224
+ /* c8 ignore start */
225
+ if (typeof text === "string") {
226
+ text = this.#stripSymbols(text);
227
+ extras = require_primordials_array.ArrayPrototypeSlice(args, 1);
228
+ } else {
229
+ extras = args;
230
+ text = "";
231
+ }
232
+ /* c8 ignore stop */
233
+ const indent = this.#getIndent("stderr");
234
+ const symbols = this.#getSymbols();
235
+ con.error(/* @__PURE__ */ require_strings_format.applyLinePrefix(`${symbols[symbolType]} ${text}`, { prefix: indent }), ...extras);
236
+ this[require_logger_symbols.lastWasBlankSymbol](false, "stderr");
237
+ this[require_logger_symbols.incLogCallCountSymbol]();
238
+ return this;
239
+ }
240
+ /**
241
+ * Gets a logger instance bound exclusively to stderr.
242
+ *
243
+ * All logging operations on this instance will write to stderr only.
244
+ * Indentation is tracked separately from stdout. The instance is cached and
245
+ * reused on subsequent accesses.
246
+ *
247
+ * @returns A logger instance bound to stderr
248
+ */
249
+ get stderr() {
250
+ if (!this.#stderrLogger) {
251
+ const instance = new Logger(...require_logger__internal.privateConstructorArgs.get(this) ?? []);
252
+ instance.#parent = this;
253
+ instance.#boundStream = "stderr";
254
+ instance.#options = {
255
+ __proto__: null,
256
+ ...this.#options
257
+ };
258
+ if (this.#theme) instance.#theme = this.#theme;
259
+ this.#stderrLogger = instance;
260
+ }
261
+ return this.#stderrLogger;
262
+ }
263
+ /**
264
+ * Gets a logger instance bound exclusively to stdout.
265
+ *
266
+ * All logging operations on this instance will write to stdout only.
267
+ * Indentation is tracked separately from stderr. The instance is cached and
268
+ * reused on subsequent accesses.
269
+ *
270
+ * @returns A logger instance bound to stdout
271
+ */
272
+ get stdout() {
273
+ if (!this.#stdoutLogger) {
274
+ const instance = new Logger(...require_logger__internal.privateConstructorArgs.get(this) ?? []);
275
+ instance.#parent = this;
276
+ instance.#boundStream = "stdout";
277
+ instance.#options = {
278
+ __proto__: null,
279
+ ...this.#options
280
+ };
281
+ if (this.#theme) instance.#theme = this.#theme;
282
+ this.#stdoutLogger = instance;
283
+ }
284
+ return this.#stdoutLogger;
285
+ }
286
+ /**
287
+ * Gets the total number of log calls made on this logger instance.
288
+ *
289
+ * Tracks all logging method calls including `log()`, `error()`, `warn()`,
290
+ * `success()`, `fail()`, etc. Useful for testing and monitoring logging
291
+ * activity.
292
+ *
293
+ * @returns The number of times logging methods have been called
294
+ */
295
+ get logCallCount() {
296
+ return this.#getRoot().#logCallCount;
297
+ }
298
+ /**
299
+ * Increments the internal log call counter.
300
+ *
301
+ * This is called automatically by logging methods and should not be called
302
+ * directly in normal usage.
303
+ */
304
+ [require_logger_symbols.incLogCallCountSymbol]() {
305
+ const root = this.#getRoot();
306
+ root.#logCallCount += 1;
307
+ return this;
308
+ }
309
+ /**
310
+ * Sets whether the last logged line was blank.
311
+ *
312
+ * Used internally to track blank lines and prevent duplicate spacing. This is
313
+ * called automatically by logging methods.
314
+ *
315
+ * @param value - Whether the last line was blank.
316
+ * @param stream - Optional stream to update (defaults to both streams if not
317
+ * bound, or target stream if bound)
318
+ */
319
+ [require_logger_symbols.lastWasBlankSymbol](value, stream) {
320
+ if (stream) this.#setLastWasBlank(stream, !!value);
321
+ else if (this.#boundStream) this.#setLastWasBlank(this.#boundStream, !!value);
322
+ else {
323
+ this.#setLastWasBlank("stderr", !!value);
324
+ this.#setLastWasBlank("stdout", !!value);
325
+ }
326
+ return this;
327
+ }
328
+ /**
329
+ * Logs an assertion failure message if the value is falsy.
330
+ *
331
+ * Works like `console.assert()` but returns the logger for chaining. If the
332
+ * value is truthy, nothing is logged. If falsy, logs an error message with an
333
+ * assertion failure.
334
+ *
335
+ * @param value - The value to test.
336
+ * @param message - Optional message and additional arguments to log.
337
+ */
338
+ assert(value, ...message) {
339
+ this.#getConsole().assert(value, message[0], ...message.slice(1));
340
+ this[require_logger_symbols.lastWasBlankSymbol](false);
341
+ return value ? this : this[require_logger_symbols.incLogCallCountSymbol]();
342
+ }
343
+ /**
344
+ * Clears the current line in the terminal.
345
+ *
346
+ * Moves the cursor to the beginning of the line and clears all content. Works
347
+ * in both TTY and non-TTY environments. Useful for clearing progress
348
+ * indicators created with `progress()`.
349
+ *
350
+ * The stream to clear (stderr or stdout) depends on whether the logger is
351
+ * stream-bound.
352
+ */
353
+ clearLine() {
354
+ const con = this.#getConsole();
355
+ const streamObj = this.#getTargetStream() === "stderr" ? con["_stderr"] : con["_stdout"];
356
+ if (streamObj.isTTY) {
357
+ streamObj.cursorTo(0);
358
+ streamObj.clearLine(0);
359
+ } else streamObj.write("\r\x1B[K");
360
+ return this;
361
+ }
362
+ /**
363
+ * Clears the visible terminal screen.
364
+ *
365
+ * Only available on the main logger instance, not on stream-bound instances
366
+ * (`.stderr` or `.stdout`). Resets the log call count and blank line tracking
367
+ * if the output is a TTY.
368
+ *
369
+ * @throws {Error} If called on a stream-bound logger instance
370
+ */
371
+ clearVisible() {
372
+ /* c8 ignore start - clearVisible TTY-mode behavior; tests use
373
+ non-TTY capture streams so the bound-stream throw and TTY
374
+ clear branches aren't reached. */
375
+ if (this.#boundStream) throw new require_primordials_error.ErrorCtor("clearVisible() is only available on the main logger instance, not on stream-bound instances");
376
+ const con = this.#getConsole();
377
+ con.clear();
378
+ if (con._stdout.isTTY) {
379
+ this[require_logger_symbols.lastWasBlankSymbol](true);
380
+ this.#logCallCount = 0;
381
+ }
382
+ return this;
383
+ /* c8 ignore stop */
384
+ }
385
+ /**
386
+ * Increments and logs a counter for the given label.
387
+ *
388
+ * Each unique label maintains its own counter. Works like `console.count()`.
389
+ *
390
+ * @default 'default'
391
+ *
392
+ * @param label - Optional label for the counter.
393
+ */
394
+ count(label) {
395
+ this.#getConsole().count(label);
396
+ this[require_logger_symbols.lastWasBlankSymbol](false);
397
+ return this[require_logger_symbols.incLogCallCountSymbol]();
398
+ }
399
+ /**
400
+ * Creates a task that logs start and completion messages automatically.
401
+ *
402
+ * Returns a task object with a `run()` method that executes the provided
403
+ * function and logs "Starting task: {name}" before execution and "Completed
404
+ * task: {name}" after completion.
405
+ *
406
+ * @param name - The name of the task.
407
+ *
408
+ * @returns A task object with a `run()` method
409
+ */
410
+ createTask(name) {
411
+ return { run: (f) => {
412
+ this.log(`Starting task: ${name}`);
413
+ const result = f();
414
+ this.log(`Completed task: ${name}`);
415
+ return result;
416
+ } };
417
+ }
418
+ /**
419
+ * Decreases the indentation level by removing spaces from the prefix.
420
+ *
421
+ * When called on the main logger, affects both stderr and stdout indentation.
422
+ * When called on a stream-bound logger (`.stderr` or `.stdout`), affects only
423
+ * that stream's indentation.
424
+ *
425
+ * @default 2
426
+ */
427
+ dedent(spaces = 2) {
428
+ if (this.#boundStream) {
429
+ const current = this.#getIndent(this.#boundStream);
430
+ this.#setIndent(this.#boundStream, current.slice(0, -spaces));
431
+ } else {
432
+ const stderrCurrent = this.#getIndent("stderr");
433
+ const stdoutCurrent = this.#getIndent("stdout");
434
+ this.#setIndent("stderr", stderrCurrent.slice(0, -spaces));
435
+ this.#setIndent("stdout", stdoutCurrent.slice(0, -spaces));
436
+ }
437
+ return this;
438
+ }
439
+ /**
440
+ * Displays an object's properties in a formatted way.
441
+ *
442
+ * Works like `console.dir()` with customizable options for depth, colors,
443
+ * etc. Useful for inspecting complex objects.
444
+ *
445
+ * @param obj - The object to display.
446
+ * @param options - Optional formatting options (Node.js inspect options)
447
+ */
448
+ dir(obj, options) {
449
+ this.#getConsole().dir(obj, options);
450
+ this[require_logger_symbols.lastWasBlankSymbol](false);
451
+ return this[require_logger_symbols.incLogCallCountSymbol]();
452
+ }
453
+ /**
454
+ * Displays data as XML/HTML in a formatted way.
455
+ *
456
+ * Works like `console.dirxml()`. In Node.js, behaves the same as `dir()`.
457
+ *
458
+ * @param data - The data to display.
459
+ */
460
+ dirxml(...data) {
461
+ this.#getConsole().dirxml(data);
462
+ this[require_logger_symbols.lastWasBlankSymbol](false);
463
+ return this[require_logger_symbols.incLogCallCountSymbol]();
464
+ }
465
+ /**
466
+ * Logs a completion message with a success symbol (alias for `success()`).
467
+ *
468
+ * Provides semantic clarity when marking something as "done". Does NOT
469
+ * automatically clear the current line - call `clearLine()` first if needed
470
+ * after using `progress()`.
471
+ */
472
+ done(...args) {
473
+ return this.#symbolApply("success", args);
474
+ }
475
+ /**
476
+ * Logs an error message to stderr.
477
+ *
478
+ * Automatically applies current indentation. All arguments are formatted and
479
+ * logged like `console.error()`.
480
+ */
481
+ error(...args) {
482
+ return this.#apply("error", args);
483
+ }
484
+ /**
485
+ * Logs a newline to stderr only if the last line wasn't already blank.
486
+ *
487
+ * Prevents multiple consecutive blank lines. Useful for adding spacing
488
+ * between sections without creating excessive whitespace.
489
+ */
490
+ errorNewline() {
491
+ return this.#getLastWasBlank("stderr") ? this : this.error("");
492
+ }
493
+ /**
494
+ * Logs a failure message with a red colored fail symbol.
495
+ *
496
+ * Automatically prefixes the message with `LOG_SYMBOLS.fail` (red ✖). Always
497
+ * outputs to stderr. If the message starts with an existing symbol, it will
498
+ * be stripped and replaced.
499
+ */
500
+ fail(...args) {
501
+ return this.#symbolApply("fail", args);
502
+ }
503
+ /**
504
+ * Starts a new indented log group.
505
+ *
506
+ * If a label is provided, it's logged before increasing indentation. Groups
507
+ * can be nested. Each group increases indentation by the `kGroupIndentWidth`
508
+ * (default 2 spaces). Call `groupEnd()` to close.
509
+ *
510
+ * @param label - Optional label to display before the group.
511
+ */
512
+ group(...label) {
513
+ const { length } = label;
514
+ if (length) require_primordials_reflect.ReflectApply(this.log, this, label);
515
+ this.indent(this[require_logger_symbols.getKGroupIndentationWidthSymbol()]);
516
+ if (length) {
517
+ this[require_logger_symbols.lastWasBlankSymbol](false);
518
+ this[require_logger_symbols.incLogCallCountSymbol]();
519
+ }
520
+ return this;
521
+ }
522
+ /**
523
+ * Starts a new collapsed log group (alias for `group()`).
524
+ *
525
+ * In browser consoles, this creates a collapsed group. In Node.js, it behaves
526
+ * identically to `group()`.
527
+ *
528
+ * @param label - Optional label to display before the group.
529
+ */
530
+ groupCollapsed(...label) {
531
+ return require_primordials_reflect.ReflectApply(this.group, this, label);
532
+ }
533
+ /**
534
+ * Ends the current log group and decreases indentation.
535
+ *
536
+ * Must be called once for each `group()` or `groupCollapsed()` call to
537
+ * properly close the group and restore indentation.
538
+ */
539
+ groupEnd() {
540
+ this.dedent(this[require_logger_symbols.getKGroupIndentationWidthSymbol()]);
541
+ return this;
542
+ }
543
+ /**
544
+ * Increases the indentation level by adding spaces to the prefix.
545
+ *
546
+ * When called on the main logger, affects both stderr and stdout indentation.
547
+ * When called on a stream-bound logger (`.stderr` or `.stdout`), affects only
548
+ * that stream's indentation. Maximum indentation is 1000 spaces.
549
+ *
550
+ * @default 2
551
+ */
552
+ indent(spaces = 2) {
553
+ const spacesToAdd = " ".repeat(require_primordials_math.MathMin(spaces, require_logger__internal.maxIndentation));
554
+ if (this.#boundStream) {
555
+ const current = this.#getIndent(this.#boundStream);
556
+ this.#setIndent(this.#boundStream, current + spacesToAdd);
557
+ } else {
558
+ const stderrCurrent = this.#getIndent("stderr");
559
+ const stdoutCurrent = this.#getIndent("stdout");
560
+ this.#setIndent("stderr", stderrCurrent + spacesToAdd);
561
+ this.#setIndent("stdout", stdoutCurrent + spacesToAdd);
562
+ }
563
+ return this;
564
+ }
565
+ /**
566
+ * Logs an informational message with a blue colored info symbol.
567
+ *
568
+ * Automatically prefixes the message with `LOG_SYMBOLS.info` (blue ℹ). Always
569
+ * outputs to stderr. If the message starts with an existing symbol, it will
570
+ * be stripped and replaced.
571
+ */
572
+ info(...args) {
573
+ return this.#symbolApply("info", args);
574
+ }
575
+ /**
576
+ * Logs a message to stdout.
577
+ *
578
+ * Automatically applies current indentation. All arguments are formatted and
579
+ * logged like `console.log()`. This is the primary method for standard
580
+ * output.
581
+ */
582
+ log(...args) {
583
+ return this.#apply("log", args);
584
+ }
585
+ /**
586
+ * Logs a newline to stdout only if the last line wasn't already blank.
587
+ *
588
+ * Prevents multiple consecutive blank lines. Useful for adding spacing
589
+ * between sections without creating excessive whitespace.
590
+ */
591
+ logNewline() {
592
+ return this.#getLastWasBlank("stdout") ? this : this.log("");
593
+ }
594
+ /**
595
+ * Shows a progress indicator that can be cleared with `clearLine()`.
596
+ *
597
+ * Displays a simple status message with a '∴' prefix. Does not include
598
+ * animation or spinner. Intended to be cleared once the operation completes.
599
+ * The output stream (stderr or stdout) depends on whether the logger is
600
+ * stream-bound.
601
+ *
602
+ * Always clears the current line before writing so calling `progress(...)`
603
+ * twice in a row redraws cleanly, and any partially-flushed prior output on
604
+ * the same row gets overwritten. TTY path uses `cursorTo(0) + clearLine(0)`;
605
+ * non-TTY path falls back to `\r\x1b[K` (which still works in CI logs).
606
+ *
607
+ * @param text - The progress message to display.
608
+ */
609
+ progress(text) {
610
+ const con = this.#getConsole();
611
+ const streamObj = this.#getTargetStream() === "stderr" ? con["_stderr"] : con["_stdout"];
612
+ if (streamObj.isTTY) {
613
+ streamObj.cursorTo(0);
614
+ streamObj.clearLine(0);
615
+ } else streamObj.write("\r\x1B[K");
616
+ const symbols = this.#getSymbols();
617
+ streamObj.write(`${symbols.progress} ${text}`);
618
+ this[require_logger_symbols.lastWasBlankSymbol](false);
619
+ return this;
620
+ }
621
+ /**
622
+ * Resets all indentation to zero.
623
+ *
624
+ * When called on the main logger, resets both stderr and stdout indentation.
625
+ * When called on a stream-bound logger (`.stderr` or `.stdout`), resets only
626
+ * that stream's indentation.
627
+ */
628
+ resetIndent() {
629
+ if (this.#boundStream) this.#setIndent(this.#boundStream, "");
630
+ else {
631
+ this.#setIndent("stderr", "");
632
+ this.#setIndent("stdout", "");
633
+ }
634
+ return this;
635
+ }
636
+ /**
637
+ * Logs a skip message with a cyan colored skip symbol.
638
+ *
639
+ * Automatically prefixes the message with `LOG_SYMBOLS.skip` (cyan ↻). Always
640
+ * outputs to stderr. If the message starts with an existing symbol, it will
641
+ * be stripped and replaced.
642
+ */
643
+ skip(...args) {
644
+ return this.#symbolApply("skip", args);
645
+ }
646
+ /**
647
+ * Logs a main step message with a cyan arrow symbol and blank line before it.
648
+ *
649
+ * Automatically prefixes the message with `LOG_SYMBOLS.step` (cyan →) and
650
+ * adds a blank line before the message unless the last line was already
651
+ * blank. Useful for marking major steps in a process with clear visual
652
+ * separation. Always outputs to stdout. If the message starts with an
653
+ * existing symbol, it will be stripped and replaced.
654
+ *
655
+ * @param msg - The step message to log.
656
+ * @param extras - Additional arguments to log.
657
+ */
658
+ step(msg, ...extras) {
659
+ if (!this.#getLastWasBlank("stdout")) this.log("");
660
+ const text = this.#stripSymbols(msg);
661
+ const indent = this.#getIndent("stdout");
662
+ const symbols = this.#getSymbols();
663
+ this.#getConsole().log(/* @__PURE__ */ require_strings_format.applyLinePrefix(`${symbols.step} ${text}`, { prefix: indent }), ...extras);
664
+ this[require_logger_symbols.lastWasBlankSymbol](false, "stdout");
665
+ this[require_logger_symbols.incLogCallCountSymbol]();
666
+ return this;
667
+ }
668
+ /**
669
+ * Logs an indented substep message (stateless).
670
+ *
671
+ * Adds a 2-space indent to the message without affecting the logger's
672
+ * indentation state. Useful for showing sub-items under a main step.
673
+ *
674
+ * @param msg - The substep message to log.
675
+ * @param extras - Additional arguments to log.
676
+ */
677
+ substep(msg, ...extras) {
678
+ const indentedMsg = ` ${msg}`;
679
+ return this.log(indentedMsg, ...extras);
680
+ }
681
+ /**
682
+ * Logs a success message with a green colored success symbol.
683
+ *
684
+ * Automatically prefixes the message with `LOG_SYMBOLS.success` (green ✔).
685
+ * Always outputs to stderr. If the message starts with an existing symbol, it
686
+ * will be stripped and replaced.
687
+ */
688
+ success(...args) {
689
+ return this.#symbolApply("success", args);
690
+ }
691
+ /**
692
+ * Displays data in a table format.
693
+ *
694
+ * Works like `console.table()`. Accepts arrays of objects or objects with
695
+ * nested objects. Optionally specify which properties to include in the
696
+ * table.
697
+ *
698
+ * @param tabularData - The data to display as a table.
699
+ * @param properties - Optional array of property names to include.
700
+ */
701
+ table(tabularData, properties) {
702
+ this.#getConsole().table(tabularData, properties);
703
+ this[require_logger_symbols.lastWasBlankSymbol](false);
704
+ return this[require_logger_symbols.incLogCallCountSymbol]();
705
+ }
706
+ /**
707
+ * Starts a timer for measuring elapsed time.
708
+ *
709
+ * Creates a timer with the given label. Use `timeEnd()` with the same label
710
+ * to stop the timer and log the elapsed time, or use `timeLog()` to check the
711
+ * time without stopping the timer.
712
+ *
713
+ * @default 'default'
714
+ *
715
+ * @param label - Optional label for the timer.
716
+ */
717
+ time(label) {
718
+ this.#getConsole().time(label);
719
+ return this;
720
+ }
721
+ /**
722
+ * Ends a timer and logs the elapsed time.
723
+ *
724
+ * Logs the duration since `console.time()` or `logger.time()` was called with
725
+ * the same label. The timer is stopped and removed.
726
+ *
727
+ * @default 'default'
728
+ *
729
+ * @param label - Optional label for the timer.
730
+ */
731
+ timeEnd(label) {
732
+ this.#getConsole().timeEnd(label);
733
+ this[require_logger_symbols.lastWasBlankSymbol](false);
734
+ return this[require_logger_symbols.incLogCallCountSymbol]();
735
+ }
736
+ /**
737
+ * Logs the current value of a timer without stopping it.
738
+ *
739
+ * Logs the duration since `console.time()` was called with the same label,
740
+ * but keeps the timer running. Can include additional data to log alongside
741
+ * the time.
742
+ *
743
+ * @default 'default'
744
+ *
745
+ * @param label - Optional label for the timer.
746
+ * @param data - Additional data to log with the time.
747
+ */
748
+ timeLog(label, ...data) {
749
+ this.#getConsole().timeLog(label, ...data);
750
+ this[require_logger_symbols.lastWasBlankSymbol](false);
751
+ return this[require_logger_symbols.incLogCallCountSymbol]();
752
+ }
753
+ /**
754
+ * Logs a stack trace to the console.
755
+ *
756
+ * Works like `console.trace()`. Shows the call stack leading to where this
757
+ * method was called. Useful for debugging.
758
+ *
759
+ * @param message - Optional message to display with the trace.
760
+ * @param args - Additional arguments to log.
761
+ */
762
+ trace(message, ...args) {
763
+ this.#getConsole().trace(message, ...args);
764
+ this[require_logger_symbols.lastWasBlankSymbol](false);
765
+ return this[require_logger_symbols.incLogCallCountSymbol]();
766
+ }
767
+ /**
768
+ * Logs a warning message with a yellow colored warning symbol.
769
+ *
770
+ * Automatically prefixes the message with `LOG_SYMBOLS.warn` (yellow ⚠).
771
+ * Always outputs to stderr. If the message starts with an existing symbol, it
772
+ * will be stripped and replaced.
773
+ */
774
+ warn(...args) {
775
+ return this.#symbolApply("warn", args);
776
+ }
777
+ /**
778
+ * Writes text directly to stdout without a newline or indentation.
779
+ *
780
+ * Useful for progress indicators or custom formatting where you need
781
+ * low-level control. Does not apply any indentation or formatting.
782
+ *
783
+ * @param text - The text to write.
784
+ */
785
+ write(text) {
786
+ const con = this.#getConsole();
787
+ const ctorArgs = require_logger__internal.privateConstructorArgs.get(this) ?? [];
788
+ /* c8 ignore stop */
789
+ (this.#originalStdout || ctorArgs[0]?.stdout || con._stdout).write(text);
790
+ this[require_logger_symbols.lastWasBlankSymbol](false);
791
+ return this;
792
+ }
21
793
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
- mod
29
- ));
30
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
- var node_exports = {};
32
- __export(node_exports, {
33
- Logger: () => Logger
34
- });
35
- module.exports = __toCommonJS(node_exports);
36
- var import_node_process = __toESM(require("node:process"));
37
- var import_array = require("../primordials/array");
38
- var import_error = require("../primordials/error");
39
- var import_math = require("../primordials/math");
40
- var import_reflect = require("../primordials/reflect");
41
- var import_format = require("../strings/format");
42
- var import_predicates = require("../strings/predicates");
43
- var import_context = require("../themes/context");
44
- var import_themes = require("../themes/themes");
45
- var import_internal = require("./_internal");
46
- var import_symbols_builder = require("./symbols-builder");
47
- var import_symbols = require("./symbols");
48
- var import_console = require("./console");
49
- class Logger {
50
- /**
51
- * Static reference to log symbols for convenience.
52
- */
53
- static LOG_SYMBOLS = import_symbols.LOG_SYMBOLS;
54
- #parent;
55
- #boundStream;
56
- #stderrLogger;
57
- #stdoutLogger;
58
- #stderrIndention = "";
59
- #stdoutIndention = "";
60
- #stderrLastWasBlank = false;
61
- #stdoutLastWasBlank = false;
62
- #logCallCount = 0;
63
- #options;
64
- #originalStdout;
65
- #theme;
66
- /**
67
- * Creates a new Logger instance.
68
- *
69
- * When called without arguments, creates a logger using the default
70
- * `process.stdout` and `process.stderr` streams. Can accept custom console
71
- * constructor arguments for advanced use cases.
72
- *
73
- * @param args - Optional console constructor arguments.
74
- */
75
- constructor(...args) {
76
- import_internal.privateConstructorArgs.set(this, args);
77
- const options = args["0"];
78
- if (typeof options === "object" && options !== null) {
79
- this.#options = { __proto__: null, ...options };
80
- this.#originalStdout = options.stdout;
81
- const themeOption = options.theme;
82
- if (themeOption) {
83
- if (typeof themeOption === "string") {
84
- const resolved = import_themes.THEMES[themeOption];
85
- if (resolved) {
86
- this.#theme = resolved;
87
- }
88
- } else {
89
- this.#theme = themeOption;
90
- }
91
- }
92
- } else {
93
- this.#options = { __proto__: null };
94
- }
95
- }
96
- /**
97
- * Apply a console method with indentation.
98
- *
99
- * @private
100
- */
101
- #apply(methodName, args, stream) {
102
- const con = this.#getConsole();
103
- const text = (0, import_array.ArrayPrototypeAt)(args, 0);
104
- const hasText = typeof text === "string";
105
- const targetStream = stream || (methodName === "log" ? "stdout" : "stderr");
106
- const indent = this.#getIndent(targetStream);
107
- const logArgs = hasText ? [
108
- (0, import_format.applyLinePrefix)(text, { prefix: indent }),
109
- ...(0, import_array.ArrayPrototypeSlice)(args, 1)
110
- ] : args;
111
- (0, import_reflect.ReflectApply)(
112
- con[methodName],
113
- con,
114
- logArgs
115
- );
116
- this[import_symbols.lastWasBlankSymbol](hasText && (0, import_predicates.isBlankString)(logArgs[0]), targetStream);
117
- this[import_symbols.incLogCallCountSymbol]();
118
- return this;
119
- }
120
- /**
121
- * Get the Console instance for this logger, creating it lazily on first
122
- * access.
123
- *
124
- * This lazy initialization allows the logger to be imported during early
125
- * Node.js bootstrap before stdout is ready, avoiding Console initialization
126
- * errors (ERR_CONSOLE_WRITABLE_STREAM).
127
- *
128
- * @private
129
- */
130
- #getConsole() {
131
- (0, import_console.ensurePrototypeInitialized)();
132
- let con = import_internal.privateConsole.get(this);
133
- if (!con) {
134
- const ctorArgs = import_internal.privateConstructorArgs.get(this) ?? [];
135
- if (ctorArgs.length) {
136
- con = (0, import_console.constructConsole)(...ctorArgs);
137
- } else {
138
- con = (0, import_console.constructConsole)({
139
- stdout: import_node_process.default.stdout,
140
- stderr: import_node_process.default.stderr
141
- });
142
- for (const { 0: key, 1: method } of import_internal.boundConsoleEntries) {
143
- con[key] = method;
144
- }
145
- }
146
- import_internal.privateConsole.set(this, con);
147
- import_internal.privateConstructorArgs.delete(this);
148
- }
149
- return con;
150
- }
151
- /**
152
- * Get indentation for a specific stream.
153
- *
154
- * @private
155
- */
156
- #getIndent(stream) {
157
- const root = this.#getRoot();
158
- return stream === "stderr" ? root.#stderrIndention : root.#stdoutIndention;
159
- }
160
- /**
161
- * Get lastWasBlank state for a specific stream.
162
- *
163
- * @private
164
- */
165
- #getLastWasBlank(stream) {
166
- const root = this.#getRoot();
167
- return stream === "stderr" ? root.#stderrLastWasBlank : root.#stdoutLastWasBlank;
168
- }
169
- /**
170
- * Get the root logger (for accessing shared indentation state).
171
- *
172
- * @private
173
- */
174
- #getRoot() {
175
- return this.#parent || this;
176
- }
177
- /**
178
- * Get logger-specific symbols using the resolved theme.
179
- *
180
- * @private
181
- */
182
- #getSymbols() {
183
- return (0, import_symbols_builder.buildLoggerSymbols)(this.#getTheme());
184
- }
185
- /**
186
- * Get the target stream for this logger instance.
187
- *
188
- * @private
189
- */
190
- #getTargetStream() {
191
- return this.#boundStream || "stderr";
192
- }
193
- /**
194
- * Get the resolved theme for this logger instance. Returns instance theme if
195
- * set, otherwise falls back to context theme.
196
- *
197
- * @private
198
- */
199
- #getTheme() {
200
- return this.#theme ?? (0, import_context.getTheme)();
201
- }
202
- /**
203
- * Set indentation for a specific stream.
204
- *
205
- * @private
206
- */
207
- #setIndent(stream, value) {
208
- const root = this.#getRoot();
209
- if (stream === "stderr") {
210
- root.#stderrIndention = value;
211
- } else {
212
- root.#stdoutIndention = value;
213
- }
214
- }
215
- /**
216
- * Set lastWasBlank state for a specific stream.
217
- *
218
- * @private
219
- */
220
- #setLastWasBlank(stream, value) {
221
- const root = this.#getRoot();
222
- if (stream === "stderr") {
223
- root.#stderrLastWasBlank = value;
224
- } else {
225
- root.#stdoutLastWasBlank = value;
226
- }
227
- }
228
- /**
229
- * Strip log symbols from the start of text.
230
- *
231
- * @private
232
- */
233
- #stripSymbols(text) {
234
- return (0, import_symbols_builder.stripLoggerSymbols)(text);
235
- }
236
- /**
237
- * Apply a method with a symbol prefix.
238
- *
239
- * @private
240
- */
241
- #symbolApply(symbolType, args) {
242
- const con = this.#getConsole();
243
- let text = (0, import_array.ArrayPrototypeAt)(args, 0);
244
- let extras;
245
- if (typeof text === "string") {
246
- text = this.#stripSymbols(text);
247
- extras = (0, import_array.ArrayPrototypeSlice)(args, 1);
248
- } else {
249
- extras = args;
250
- text = "";
251
- }
252
- const indent = this.#getIndent("stderr");
253
- const symbols = this.#getSymbols();
254
- con.error(
255
- (0, import_format.applyLinePrefix)(`${symbols[symbolType]} ${text}`, {
256
- prefix: indent
257
- }),
258
- ...extras
259
- );
260
- this[import_symbols.lastWasBlankSymbol](false, "stderr");
261
- this[import_symbols.incLogCallCountSymbol]();
262
- return this;
263
- }
264
- /**
265
- * Gets a logger instance bound exclusively to stderr.
266
- *
267
- * All logging operations on this instance will write to stderr only.
268
- * Indentation is tracked separately from stdout. The instance is cached and
269
- * reused on subsequent accesses.
270
- *
271
- * @returns A logger instance bound to stderr
272
- */
273
- get stderr() {
274
- if (!this.#stderrLogger) {
275
- const ctorArgs = import_internal.privateConstructorArgs.get(this) ?? [];
276
- const instance = new Logger(...ctorArgs);
277
- instance.#parent = this;
278
- instance.#boundStream = "stderr";
279
- instance.#options = { __proto__: null, ...this.#options };
280
- if (this.#theme) {
281
- instance.#theme = this.#theme;
282
- }
283
- this.#stderrLogger = instance;
284
- }
285
- return this.#stderrLogger;
286
- }
287
- /**
288
- * Gets a logger instance bound exclusively to stdout.
289
- *
290
- * All logging operations on this instance will write to stdout only.
291
- * Indentation is tracked separately from stderr. The instance is cached and
292
- * reused on subsequent accesses.
293
- *
294
- * @returns A logger instance bound to stdout
295
- */
296
- get stdout() {
297
- if (!this.#stdoutLogger) {
298
- const ctorArgs = import_internal.privateConstructorArgs.get(this) ?? [];
299
- const instance = new Logger(...ctorArgs);
300
- instance.#parent = this;
301
- instance.#boundStream = "stdout";
302
- instance.#options = { __proto__: null, ...this.#options };
303
- if (this.#theme) {
304
- instance.#theme = this.#theme;
305
- }
306
- this.#stdoutLogger = instance;
307
- }
308
- return this.#stdoutLogger;
309
- }
310
- /**
311
- * Gets the total number of log calls made on this logger instance.
312
- *
313
- * Tracks all logging method calls including `log()`, `error()`, `warn()`,
314
- * `success()`, `fail()`, etc. Useful for testing and monitoring logging
315
- * activity.
316
- *
317
- * @returns The number of times logging methods have been called
318
- */
319
- get logCallCount() {
320
- const root = this.#getRoot();
321
- return root.#logCallCount;
322
- }
323
- /**
324
- * Increments the internal log call counter.
325
- *
326
- * This is called automatically by logging methods and should not be called
327
- * directly in normal usage.
328
- */
329
- [import_symbols.incLogCallCountSymbol]() {
330
- const root = this.#getRoot();
331
- root.#logCallCount += 1;
332
- return this;
333
- }
334
- /**
335
- * Sets whether the last logged line was blank.
336
- *
337
- * Used internally to track blank lines and prevent duplicate spacing. This is
338
- * called automatically by logging methods.
339
- *
340
- * @param value - Whether the last line was blank.
341
- * @param stream - Optional stream to update (defaults to both streams if not
342
- * bound, or target stream if bound)
343
- */
344
- [import_symbols.lastWasBlankSymbol](value, stream) {
345
- if (stream) {
346
- this.#setLastWasBlank(stream, !!value);
347
- } else if (this.#boundStream) {
348
- this.#setLastWasBlank(this.#boundStream, !!value);
349
- } else {
350
- this.#setLastWasBlank("stderr", !!value);
351
- this.#setLastWasBlank("stdout", !!value);
352
- }
353
- return this;
354
- }
355
- /**
356
- * Logs an assertion failure message if the value is falsy.
357
- *
358
- * Works like `console.assert()` but returns the logger for chaining. If the
359
- * value is truthy, nothing is logged. If falsy, logs an error message with an
360
- * assertion failure.
361
- *
362
- * @param value - The value to test.
363
- * @param message - Optional message and additional arguments to log.
364
- */
365
- assert(value, ...message) {
366
- const con = this.#getConsole();
367
- con.assert(value, message[0], ...message.slice(1));
368
- this[import_symbols.lastWasBlankSymbol](false);
369
- return value ? this : this[import_symbols.incLogCallCountSymbol]();
370
- }
371
- /**
372
- * Clears the current line in the terminal.
373
- *
374
- * Moves the cursor to the beginning of the line and clears all content. Works
375
- * in both TTY and non-TTY environments. Useful for clearing progress
376
- * indicators created with `progress()`.
377
- *
378
- * The stream to clear (stderr or stdout) depends on whether the logger is
379
- * stream-bound.
380
- */
381
- clearLine() {
382
- const con = this.#getConsole();
383
- const stream = this.#getTargetStream();
384
- const streamObj = stream === "stderr" ? con["_stderr"] : con["_stdout"];
385
- if (streamObj.isTTY) {
386
- streamObj.cursorTo(0);
387
- streamObj.clearLine(0);
388
- } else {
389
- streamObj.write("\r\x1B[K");
390
- }
391
- return this;
392
- }
393
- /**
394
- * Clears the visible terminal screen.
395
- *
396
- * Only available on the main logger instance, not on stream-bound instances
397
- * (`.stderr` or `.stdout`). Resets the log call count and blank line tracking
398
- * if the output is a TTY.
399
- *
400
- * @throws {Error} If called on a stream-bound logger instance
401
- */
402
- clearVisible() {
403
- if (this.#boundStream) {
404
- throw new import_error.ErrorCtor(
405
- "clearVisible() is only available on the main logger instance, not on stream-bound instances"
406
- );
407
- }
408
- const con = this.#getConsole();
409
- con.clear();
410
- if (con._stdout.isTTY) {
411
- ;
412
- this[import_symbols.lastWasBlankSymbol](true);
413
- this.#logCallCount = 0;
414
- }
415
- return this;
416
- }
417
- /**
418
- * Increments and logs a counter for the given label.
419
- *
420
- * Each unique label maintains its own counter. Works like `console.count()`.
421
- *
422
- * @default 'default'
423
- *
424
- * @param label - Optional label for the counter.
425
- */
426
- count(label) {
427
- const con = this.#getConsole();
428
- con.count(label);
429
- this[import_symbols.lastWasBlankSymbol](false);
430
- return this[import_symbols.incLogCallCountSymbol]();
431
- }
432
- /**
433
- * Creates a task that logs start and completion messages automatically.
434
- *
435
- * Returns a task object with a `run()` method that executes the provided
436
- * function and logs "Starting task: {name}" before execution and "Completed
437
- * task: {name}" after completion.
438
- *
439
- * @param name - The name of the task.
440
- *
441
- * @returns A task object with a `run()` method
442
- */
443
- createTask(name) {
444
- return {
445
- run: (f) => {
446
- this.log(`Starting task: ${name}`);
447
- const result = f();
448
- this.log(`Completed task: ${name}`);
449
- return result;
450
- }
451
- };
452
- }
453
- /**
454
- * Decreases the indentation level by removing spaces from the prefix.
455
- *
456
- * When called on the main logger, affects both stderr and stdout indentation.
457
- * When called on a stream-bound logger (`.stderr` or `.stdout`), affects only
458
- * that stream's indentation.
459
- *
460
- * @default 2
461
- */
462
- dedent(spaces = 2) {
463
- if (this.#boundStream) {
464
- const current = this.#getIndent(this.#boundStream);
465
- this.#setIndent(this.#boundStream, current.slice(0, -spaces));
466
- } else {
467
- const stderrCurrent = this.#getIndent("stderr");
468
- const stdoutCurrent = this.#getIndent("stdout");
469
- this.#setIndent("stderr", stderrCurrent.slice(0, -spaces));
470
- this.#setIndent("stdout", stdoutCurrent.slice(0, -spaces));
471
- }
472
- return this;
473
- }
474
- /**
475
- * Displays an object's properties in a formatted way.
476
- *
477
- * Works like `console.dir()` with customizable options for depth, colors,
478
- * etc. Useful for inspecting complex objects.
479
- *
480
- * @param obj - The object to display.
481
- * @param options - Optional formatting options (Node.js inspect options)
482
- */
483
- dir(obj, options) {
484
- const con = this.#getConsole();
485
- con.dir(obj, options);
486
- this[import_symbols.lastWasBlankSymbol](false);
487
- return this[import_symbols.incLogCallCountSymbol]();
488
- }
489
- /**
490
- * Displays data as XML/HTML in a formatted way.
491
- *
492
- * Works like `console.dirxml()`. In Node.js, behaves the same as `dir()`.
493
- *
494
- * @param data - The data to display.
495
- */
496
- dirxml(...data) {
497
- const con = this.#getConsole();
498
- con.dirxml(data);
499
- this[import_symbols.lastWasBlankSymbol](false);
500
- return this[import_symbols.incLogCallCountSymbol]();
501
- }
502
- /**
503
- * Logs a completion message with a success symbol (alias for `success()`).
504
- *
505
- * Provides semantic clarity when marking something as "done". Does NOT
506
- * automatically clear the current line - call `clearLine()` first if needed
507
- * after using `progress()`.
508
- */
509
- done(...args) {
510
- return this.#symbolApply("success", args);
511
- }
512
- /**
513
- * Logs an error message to stderr.
514
- *
515
- * Automatically applies current indentation. All arguments are formatted and
516
- * logged like `console.error()`.
517
- */
518
- error(...args) {
519
- return this.#apply("error", args);
520
- }
521
- /**
522
- * Logs a newline to stderr only if the last line wasn't already blank.
523
- *
524
- * Prevents multiple consecutive blank lines. Useful for adding spacing
525
- * between sections without creating excessive whitespace.
526
- */
527
- errorNewline() {
528
- return this.#getLastWasBlank("stderr") ? this : this.error("");
529
- }
530
- /**
531
- * Logs a failure message with a red colored fail symbol.
532
- *
533
- * Automatically prefixes the message with `LOG_SYMBOLS.fail` (red ✖). Always
534
- * outputs to stderr. If the message starts with an existing symbol, it will
535
- * be stripped and replaced.
536
- */
537
- fail(...args) {
538
- return this.#symbolApply("fail", args);
539
- }
540
- /**
541
- * Starts a new indented log group.
542
- *
543
- * If a label is provided, it's logged before increasing indentation. Groups
544
- * can be nested. Each group increases indentation by the `kGroupIndentWidth`
545
- * (default 2 spaces). Call `groupEnd()` to close.
546
- *
547
- * @param label - Optional label to display before the group.
548
- */
549
- group(...label) {
550
- const { length } = label;
551
- if (length) {
552
- (0, import_reflect.ReflectApply)(this.log, this, label);
553
- }
554
- this.indent(this[(0, import_symbols.getKGroupIndentationWidthSymbol)()]);
555
- if (length) {
556
- ;
557
- this[import_symbols.lastWasBlankSymbol](false);
558
- this[import_symbols.incLogCallCountSymbol]();
559
- }
560
- return this;
561
- }
562
- /**
563
- * Starts a new collapsed log group (alias for `group()`).
564
- *
565
- * In browser consoles, this creates a collapsed group. In Node.js, it behaves
566
- * identically to `group()`.
567
- *
568
- * @param label - Optional label to display before the group.
569
- */
570
- // groupCollapsed is an alias of group.
571
- // https://nodejs.org/api/console.html#consolegroupcollapsed
572
- groupCollapsed(...label) {
573
- return (0, import_reflect.ReflectApply)(this.group, this, label);
574
- }
575
- /**
576
- * Ends the current log group and decreases indentation.
577
- *
578
- * Must be called once for each `group()` or `groupCollapsed()` call to
579
- * properly close the group and restore indentation.
580
- */
581
- groupEnd() {
582
- this.dedent(this[(0, import_symbols.getKGroupIndentationWidthSymbol)()]);
583
- return this;
584
- }
585
- /**
586
- * Increases the indentation level by adding spaces to the prefix.
587
- *
588
- * When called on the main logger, affects both stderr and stdout indentation.
589
- * When called on a stream-bound logger (`.stderr` or `.stdout`), affects only
590
- * that stream's indentation. Maximum indentation is 1000 spaces.
591
- *
592
- * @default 2
593
- */
594
- indent(spaces = 2) {
595
- const spacesToAdd = " ".repeat((0, import_math.MathMin)(spaces, import_internal.maxIndentation));
596
- if (this.#boundStream) {
597
- const current = this.#getIndent(this.#boundStream);
598
- this.#setIndent(this.#boundStream, current + spacesToAdd);
599
- } else {
600
- const stderrCurrent = this.#getIndent("stderr");
601
- const stdoutCurrent = this.#getIndent("stdout");
602
- this.#setIndent("stderr", stderrCurrent + spacesToAdd);
603
- this.#setIndent("stdout", stdoutCurrent + spacesToAdd);
604
- }
605
- return this;
606
- }
607
- /**
608
- * Logs an informational message with a blue colored info symbol.
609
- *
610
- * Automatically prefixes the message with `LOG_SYMBOLS.info` (blue ℹ). Always
611
- * outputs to stderr. If the message starts with an existing symbol, it will
612
- * be stripped and replaced.
613
- */
614
- info(...args) {
615
- return this.#symbolApply("info", args);
616
- }
617
- /**
618
- * Logs a message to stdout.
619
- *
620
- * Automatically applies current indentation. All arguments are formatted and
621
- * logged like `console.log()`. This is the primary method for standard
622
- * output.
623
- */
624
- log(...args) {
625
- return this.#apply("log", args);
626
- }
627
- /**
628
- * Logs a newline to stdout only if the last line wasn't already blank.
629
- *
630
- * Prevents multiple consecutive blank lines. Useful for adding spacing
631
- * between sections without creating excessive whitespace.
632
- */
633
- logNewline() {
634
- return this.#getLastWasBlank("stdout") ? this : this.log("");
635
- }
636
- /**
637
- * Shows a progress indicator that can be cleared with `clearLine()`.
638
- *
639
- * Displays a simple status message with a '∴' prefix. Does not include
640
- * animation or spinner. Intended to be cleared once the operation completes.
641
- * The output stream (stderr or stdout) depends on whether the logger is
642
- * stream-bound.
643
- *
644
- * Always clears the current line before writing so calling `progress(...)`
645
- * twice in a row redraws cleanly, and any partially-flushed prior output on
646
- * the same row gets overwritten. TTY path uses `cursorTo(0) + clearLine(0)`;
647
- * non-TTY path falls back to `\r\x1b[K` (which still works in CI logs).
648
- *
649
- * @param text - The progress message to display.
650
- */
651
- progress(text) {
652
- const con = this.#getConsole();
653
- const stream = this.#getTargetStream();
654
- const streamObj = stream === "stderr" ? con["_stderr"] : con["_stdout"];
655
- if (streamObj.isTTY) {
656
- streamObj.cursorTo(0);
657
- streamObj.clearLine(0);
658
- } else {
659
- streamObj.write("\r\x1B[K");
660
- }
661
- const symbols = this.#getSymbols();
662
- streamObj.write(`${symbols.progress} ${text}`);
663
- this[import_symbols.lastWasBlankSymbol](false);
664
- return this;
665
- }
666
- /**
667
- * Resets all indentation to zero.
668
- *
669
- * When called on the main logger, resets both stderr and stdout indentation.
670
- * When called on a stream-bound logger (`.stderr` or `.stdout`), resets only
671
- * that stream's indentation.
672
- */
673
- resetIndent() {
674
- if (this.#boundStream) {
675
- this.#setIndent(this.#boundStream, "");
676
- } else {
677
- this.#setIndent("stderr", "");
678
- this.#setIndent("stdout", "");
679
- }
680
- return this;
681
- }
682
- /**
683
- * Logs a skip message with a cyan colored skip symbol.
684
- *
685
- * Automatically prefixes the message with `LOG_SYMBOLS.skip` (cyan ↻). Always
686
- * outputs to stderr. If the message starts with an existing symbol, it will
687
- * be stripped and replaced.
688
- */
689
- skip(...args) {
690
- return this.#symbolApply("skip", args);
691
- }
692
- /**
693
- * Logs a main step message with a cyan arrow symbol and blank line before it.
694
- *
695
- * Automatically prefixes the message with `LOG_SYMBOLS.step` (cyan →) and
696
- * adds a blank line before the message unless the last line was already
697
- * blank. Useful for marking major steps in a process with clear visual
698
- * separation. Always outputs to stdout. If the message starts with an
699
- * existing symbol, it will be stripped and replaced.
700
- *
701
- * @param msg - The step message to log.
702
- * @param extras - Additional arguments to log.
703
- */
704
- step(msg, ...extras) {
705
- if (!this.#getLastWasBlank("stdout")) {
706
- this.log("");
707
- }
708
- const text = this.#stripSymbols(msg);
709
- const indent = this.#getIndent("stdout");
710
- const symbols = this.#getSymbols();
711
- const con = this.#getConsole();
712
- con.log(
713
- (0, import_format.applyLinePrefix)(`${symbols.step} ${text}`, {
714
- prefix: indent
715
- }),
716
- ...extras
717
- );
718
- this[import_symbols.lastWasBlankSymbol](false, "stdout");
719
- this[import_symbols.incLogCallCountSymbol]();
720
- return this;
721
- }
722
- /**
723
- * Logs an indented substep message (stateless).
724
- *
725
- * Adds a 2-space indent to the message without affecting the logger's
726
- * indentation state. Useful for showing sub-items under a main step.
727
- *
728
- * @param msg - The substep message to log.
729
- * @param extras - Additional arguments to log.
730
- */
731
- substep(msg, ...extras) {
732
- const indentedMsg = ` ${msg}`;
733
- return this.log(indentedMsg, ...extras);
734
- }
735
- /**
736
- * Logs a success message with a green colored success symbol.
737
- *
738
- * Automatically prefixes the message with `LOG_SYMBOLS.success` (green ✔).
739
- * Always outputs to stderr. If the message starts with an existing symbol, it
740
- * will be stripped and replaced.
741
- */
742
- success(...args) {
743
- return this.#symbolApply("success", args);
744
- }
745
- /**
746
- * Displays data in a table format.
747
- *
748
- * Works like `console.table()`. Accepts arrays of objects or objects with
749
- * nested objects. Optionally specify which properties to include in the
750
- * table.
751
- *
752
- * @param tabularData - The data to display as a table.
753
- * @param properties - Optional array of property names to include.
754
- */
755
- table(tabularData, properties) {
756
- const con = this.#getConsole();
757
- con.table(tabularData, properties);
758
- this[import_symbols.lastWasBlankSymbol](false);
759
- return this[import_symbols.incLogCallCountSymbol]();
760
- }
761
- /**
762
- * Starts a timer for measuring elapsed time.
763
- *
764
- * Creates a timer with the given label. Use `timeEnd()` with the same label
765
- * to stop the timer and log the elapsed time, or use `timeLog()` to check the
766
- * time without stopping the timer.
767
- *
768
- * @default 'default'
769
- *
770
- * @param label - Optional label for the timer.
771
- */
772
- time(label) {
773
- const con = this.#getConsole();
774
- con.time(label);
775
- return this;
776
- }
777
- /**
778
- * Ends a timer and logs the elapsed time.
779
- *
780
- * Logs the duration since `console.time()` or `logger.time()` was called with
781
- * the same label. The timer is stopped and removed.
782
- *
783
- * @default 'default'
784
- *
785
- * @param label - Optional label for the timer.
786
- */
787
- timeEnd(label) {
788
- const con = this.#getConsole();
789
- con.timeEnd(label);
790
- this[import_symbols.lastWasBlankSymbol](false);
791
- return this[import_symbols.incLogCallCountSymbol]();
792
- }
793
- /**
794
- * Logs the current value of a timer without stopping it.
795
- *
796
- * Logs the duration since `console.time()` was called with the same label,
797
- * but keeps the timer running. Can include additional data to log alongside
798
- * the time.
799
- *
800
- * @default 'default'
801
- *
802
- * @param label - Optional label for the timer.
803
- * @param data - Additional data to log with the time.
804
- */
805
- timeLog(label, ...data) {
806
- const con = this.#getConsole();
807
- con.timeLog(label, ...data);
808
- this[import_symbols.lastWasBlankSymbol](false);
809
- return this[import_symbols.incLogCallCountSymbol]();
810
- }
811
- /**
812
- * Logs a stack trace to the console.
813
- *
814
- * Works like `console.trace()`. Shows the call stack leading to where this
815
- * method was called. Useful for debugging.
816
- *
817
- * @param message - Optional message to display with the trace.
818
- * @param args - Additional arguments to log.
819
- */
820
- trace(message, ...args) {
821
- const con = this.#getConsole();
822
- con.trace(message, ...args);
823
- this[import_symbols.lastWasBlankSymbol](false);
824
- return this[import_symbols.incLogCallCountSymbol]();
825
- }
826
- /**
827
- * Logs a warning message with a yellow colored warning symbol.
828
- *
829
- * Automatically prefixes the message with `LOG_SYMBOLS.warn` (yellow ⚠).
830
- * Always outputs to stderr. If the message starts with an existing symbol, it
831
- * will be stripped and replaced.
832
- */
833
- warn(...args) {
834
- return this.#symbolApply("warn", args);
835
- }
836
- /**
837
- * Writes text directly to stdout without a newline or indentation.
838
- *
839
- * Useful for progress indicators or custom formatting where you need
840
- * low-level control. Does not apply any indentation or formatting.
841
- *
842
- * @param text - The text to write.
843
- */
844
- write(text) {
845
- const con = this.#getConsole();
846
- const ctorArgs = import_internal.privateConstructorArgs.get(this) ?? [];
847
- const stdout = this.#originalStdout || ctorArgs[0]?.stdout || con._stdout;
848
- stdout.write(text);
849
- this[import_symbols.lastWasBlankSymbol](false);
850
- return this;
851
- }
852
- }
853
- // Annotate the CommonJS export names for ESM import in node:
854
- 0 && (module.exports = {
855
- Logger
856
- });
794
+
795
+ //#endregion
796
+ exports.Logger = Logger;