@socketsecurity/lib 1.3.5 → 2.1.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 (291) hide show
  1. package/CHANGELOG.md +84 -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/dlx-package.d.ts +51 -0
  17. package/dist/dlx-package.js +1 -1
  18. package/dist/dlx-package.js.map +3 -3
  19. package/dist/dlx.d.ts +15 -0
  20. package/dist/dlx.js +1 -1
  21. package/dist/dlx.js.map +3 -3
  22. package/dist/effects/text-shimmer.js +1 -1
  23. package/dist/effects/text-shimmer.js.map +2 -2
  24. package/dist/env/ci.d.ts +1 -1
  25. package/dist/env/ci.js +1 -1
  26. package/dist/env/ci.js.map +3 -3
  27. package/dist/env/debug.d.ts +1 -1
  28. package/dist/env/debug.js +1 -1
  29. package/dist/env/debug.js.map +3 -3
  30. package/dist/env/github.d.ts +40 -0
  31. package/dist/env/github.js +3 -0
  32. package/dist/env/github.js.map +7 -0
  33. package/dist/env/home.d.ts +1 -1
  34. package/dist/env/home.js +1 -1
  35. package/dist/env/home.js.map +3 -3
  36. package/dist/env/locale.d.ts +15 -0
  37. package/dist/env/locale.js +3 -0
  38. package/dist/env/locale.js.map +7 -0
  39. package/dist/env/node-auth-token.d.ts +1 -1
  40. package/dist/env/node-auth-token.js +1 -1
  41. package/dist/env/node-auth-token.js.map +3 -3
  42. package/dist/env/node-env.d.ts +1 -1
  43. package/dist/env/node-env.js +1 -1
  44. package/dist/env/node-env.js.map +3 -3
  45. package/dist/env/npm.d.ts +25 -0
  46. package/dist/env/npm.js +3 -0
  47. package/dist/env/npm.js.map +7 -0
  48. package/dist/env/package-manager.d.ts +58 -0
  49. package/dist/env/package-manager.js +3 -0
  50. package/dist/env/package-manager.js.map +7 -0
  51. package/dist/env/path.d.ts +1 -1
  52. package/dist/env/path.js +1 -1
  53. package/dist/env/path.js.map +3 -3
  54. package/dist/env/pre-commit.d.ts +1 -1
  55. package/dist/env/pre-commit.js +1 -1
  56. package/dist/env/pre-commit.js.map +3 -3
  57. package/dist/env/rewire.d.ts +106 -0
  58. package/dist/env/rewire.js +3 -0
  59. package/dist/env/rewire.js.map +7 -0
  60. package/dist/env/shell.d.ts +1 -1
  61. package/dist/env/shell.js +1 -1
  62. package/dist/env/shell.js.map +3 -3
  63. package/dist/env/socket-cli-shadow.d.ts +30 -0
  64. package/dist/env/socket-cli-shadow.js +3 -0
  65. package/dist/env/socket-cli-shadow.js.map +7 -0
  66. package/dist/env/socket-cli.d.ts +72 -0
  67. package/dist/env/socket-cli.js +3 -0
  68. package/dist/env/socket-cli.js.map +7 -0
  69. package/dist/env/socket.d.ts +75 -0
  70. package/dist/env/socket.js +3 -0
  71. package/dist/env/socket.js.map +7 -0
  72. package/dist/env/temp-dir.d.ts +15 -0
  73. package/dist/env/temp-dir.js +3 -0
  74. package/dist/env/temp-dir.js.map +7 -0
  75. package/dist/env/term.d.ts +1 -1
  76. package/dist/env/term.js +1 -1
  77. package/dist/env/term.js.map +3 -3
  78. package/dist/env/test.d.ts +15 -0
  79. package/dist/env/test.js +3 -0
  80. package/dist/env/test.js.map +7 -0
  81. package/dist/env/windows.d.ts +20 -0
  82. package/dist/env/windows.js +3 -0
  83. package/dist/env/windows.js.map +7 -0
  84. package/dist/env/xdg.d.ts +15 -0
  85. package/dist/env/xdg.js +3 -0
  86. package/dist/env/xdg.js.map +7 -0
  87. package/dist/fs.d.ts +7 -0
  88. package/dist/fs.js +3 -3
  89. package/dist/fs.js.map +3 -3
  90. package/dist/github.js +1 -1
  91. package/dist/github.js.map +3 -3
  92. package/dist/globs.js +1 -1
  93. package/dist/globs.js.map +2 -2
  94. package/dist/ipc.d.ts +1 -1
  95. package/dist/ipc.js +1 -1
  96. package/dist/ipc.js.map +3 -3
  97. package/dist/logger.d.ts +2 -1
  98. package/dist/logger.js +1 -1
  99. package/dist/logger.js.map +3 -3
  100. package/dist/packages/isolation.js +1 -1
  101. package/dist/packages/isolation.js.map +3 -3
  102. package/dist/packages/normalize.js +1 -1
  103. package/dist/packages/normalize.js.map +3 -3
  104. package/dist/packages/operations.js +1 -1
  105. package/dist/packages/operations.js.map +3 -3
  106. package/dist/path.d.ts +2 -2
  107. package/dist/path.js +1 -1
  108. package/dist/path.js.map +3 -3
  109. package/dist/paths/rewire.d.ts +71 -0
  110. package/dist/paths/rewire.js +3 -0
  111. package/dist/paths/rewire.js.map +7 -0
  112. package/dist/paths.d.ts +26 -0
  113. package/dist/paths.js +1 -1
  114. package/dist/paths.js.map +3 -3
  115. package/dist/spinner.js +1 -1
  116. package/dist/spinner.js.map +2 -2
  117. package/package.json +42 -225
  118. package/dist/env/appdata.d.ts +0 -1
  119. package/dist/env/appdata.js +0 -3
  120. package/dist/env/appdata.js.map +0 -7
  121. package/dist/env/comspec.d.ts +0 -1
  122. package/dist/env/comspec.js +0 -3
  123. package/dist/env/comspec.js.map +0 -7
  124. package/dist/env/getters.d.ts +0 -40
  125. package/dist/env/getters.js +0 -3
  126. package/dist/env/getters.js.map +0 -7
  127. package/dist/env/github-api-url.d.ts +0 -1
  128. package/dist/env/github-api-url.js +0 -3
  129. package/dist/env/github-api-url.js.map +0 -7
  130. package/dist/env/github-base-ref.d.ts +0 -1
  131. package/dist/env/github-base-ref.js +0 -3
  132. package/dist/env/github-base-ref.js.map +0 -7
  133. package/dist/env/github-ref-name.d.ts +0 -1
  134. package/dist/env/github-ref-name.js +0 -3
  135. package/dist/env/github-ref-name.js.map +0 -7
  136. package/dist/env/github-ref-type.d.ts +0 -1
  137. package/dist/env/github-ref-type.js +0 -3
  138. package/dist/env/github-ref-type.js.map +0 -7
  139. package/dist/env/github-repository.d.ts +0 -1
  140. package/dist/env/github-repository.js +0 -3
  141. package/dist/env/github-repository.js.map +0 -7
  142. package/dist/env/github-server-url.d.ts +0 -1
  143. package/dist/env/github-server-url.js +0 -3
  144. package/dist/env/github-server-url.js.map +0 -7
  145. package/dist/env/github-token.d.ts +0 -1
  146. package/dist/env/github-token.js +0 -3
  147. package/dist/env/github-token.js.map +0 -7
  148. package/dist/env/jest-worker-id.d.ts +0 -1
  149. package/dist/env/jest-worker-id.js +0 -3
  150. package/dist/env/jest-worker-id.js.map +0 -7
  151. package/dist/env/lang.d.ts +0 -1
  152. package/dist/env/lang.js +0 -3
  153. package/dist/env/lang.js.map +0 -7
  154. package/dist/env/lc-all.d.ts +0 -1
  155. package/dist/env/lc-all.js +0 -3
  156. package/dist/env/lc-all.js.map +0 -7
  157. package/dist/env/lc-messages.d.ts +0 -1
  158. package/dist/env/lc-messages.js +0 -3
  159. package/dist/env/lc-messages.js.map +0 -7
  160. package/dist/env/localappdata.d.ts +0 -1
  161. package/dist/env/localappdata.js +0 -3
  162. package/dist/env/localappdata.js.map +0 -7
  163. package/dist/env/npm-config-registry.d.ts +0 -1
  164. package/dist/env/npm-config-registry.js +0 -3
  165. package/dist/env/npm-config-registry.js.map +0 -7
  166. package/dist/env/npm-config-user-agent.d.ts +0 -1
  167. package/dist/env/npm-config-user-agent.js +0 -3
  168. package/dist/env/npm-config-user-agent.js.map +0 -7
  169. package/dist/env/npm-lifecycle-event.d.ts +0 -1
  170. package/dist/env/npm-lifecycle-event.js +0 -3
  171. package/dist/env/npm-lifecycle-event.js.map +0 -7
  172. package/dist/env/npm-registry.d.ts +0 -1
  173. package/dist/env/npm-registry.js +0 -3
  174. package/dist/env/npm-registry.js.map +0 -7
  175. package/dist/env/npm-token.d.ts +0 -1
  176. package/dist/env/npm-token.js +0 -3
  177. package/dist/env/npm-token.js.map +0 -7
  178. package/dist/env/socket-accept-risks.d.ts +0 -1
  179. package/dist/env/socket-accept-risks.js +0 -3
  180. package/dist/env/socket-accept-risks.js.map +0 -7
  181. package/dist/env/socket-api-base-url.d.ts +0 -1
  182. package/dist/env/socket-api-base-url.js +0 -3
  183. package/dist/env/socket-api-base-url.js.map +0 -7
  184. package/dist/env/socket-api-proxy.d.ts +0 -1
  185. package/dist/env/socket-api-proxy.js +0 -3
  186. package/dist/env/socket-api-proxy.js.map +0 -7
  187. package/dist/env/socket-api-timeout.d.ts +0 -1
  188. package/dist/env/socket-api-timeout.js +0 -3
  189. package/dist/env/socket-api-timeout.js.map +0 -7
  190. package/dist/env/socket-api-token.d.ts +0 -1
  191. package/dist/env/socket-api-token.js +0 -3
  192. package/dist/env/socket-api-token.js.map +0 -7
  193. package/dist/env/socket-cacache-dir.d.ts +0 -1
  194. package/dist/env/socket-cacache-dir.js +0 -3
  195. package/dist/env/socket-cacache-dir.js.map +0 -7
  196. package/dist/env/socket-cli-accept-risks.d.ts +0 -1
  197. package/dist/env/socket-cli-accept-risks.js +0 -3
  198. package/dist/env/socket-cli-accept-risks.js.map +0 -7
  199. package/dist/env/socket-cli-api-base-url.d.ts +0 -1
  200. package/dist/env/socket-cli-api-base-url.js +0 -3
  201. package/dist/env/socket-cli-api-base-url.js.map +0 -7
  202. package/dist/env/socket-cli-api-proxy.d.ts +0 -1
  203. package/dist/env/socket-cli-api-proxy.js +0 -3
  204. package/dist/env/socket-cli-api-proxy.js.map +0 -7
  205. package/dist/env/socket-cli-api-timeout.d.ts +0 -1
  206. package/dist/env/socket-cli-api-timeout.js +0 -3
  207. package/dist/env/socket-cli-api-timeout.js.map +0 -7
  208. package/dist/env/socket-cli-api-token.d.ts +0 -1
  209. package/dist/env/socket-cli-api-token.js +0 -3
  210. package/dist/env/socket-cli-api-token.js.map +0 -7
  211. package/dist/env/socket-cli-config.d.ts +0 -1
  212. package/dist/env/socket-cli-config.js +0 -3
  213. package/dist/env/socket-cli-config.js.map +0 -7
  214. package/dist/env/socket-cli-fix.d.ts +0 -1
  215. package/dist/env/socket-cli-fix.js +0 -3
  216. package/dist/env/socket-cli-fix.js.map +0 -7
  217. package/dist/env/socket-cli-no-api-token.d.ts +0 -1
  218. package/dist/env/socket-cli-no-api-token.js +0 -3
  219. package/dist/env/socket-cli-no-api-token.js.map +0 -7
  220. package/dist/env/socket-cli-optimize.d.ts +0 -1
  221. package/dist/env/socket-cli-optimize.js +0 -3
  222. package/dist/env/socket-cli-optimize.js.map +0 -7
  223. package/dist/env/socket-cli-org-slug.d.ts +0 -1
  224. package/dist/env/socket-cli-org-slug.js +0 -3
  225. package/dist/env/socket-cli-org-slug.js.map +0 -7
  226. package/dist/env/socket-cli-shadow-accept-risks.d.ts +0 -1
  227. package/dist/env/socket-cli-shadow-accept-risks.js +0 -3
  228. package/dist/env/socket-cli-shadow-accept-risks.js.map +0 -7
  229. package/dist/env/socket-cli-shadow-api-token.d.ts +0 -1
  230. package/dist/env/socket-cli-shadow-api-token.js +0 -3
  231. package/dist/env/socket-cli-shadow-api-token.js.map +0 -7
  232. package/dist/env/socket-cli-shadow-bin.d.ts +0 -1
  233. package/dist/env/socket-cli-shadow-bin.js +0 -3
  234. package/dist/env/socket-cli-shadow-bin.js.map +0 -7
  235. package/dist/env/socket-cli-shadow-progress.d.ts +0 -1
  236. package/dist/env/socket-cli-shadow-progress.js +0 -3
  237. package/dist/env/socket-cli-shadow-progress.js.map +0 -7
  238. package/dist/env/socket-cli-shadow-silent.d.ts +0 -1
  239. package/dist/env/socket-cli-shadow-silent.js +0 -3
  240. package/dist/env/socket-cli-shadow-silent.js.map +0 -7
  241. package/dist/env/socket-cli-view-all-risks.d.ts +0 -1
  242. package/dist/env/socket-cli-view-all-risks.js +0 -3
  243. package/dist/env/socket-cli-view-all-risks.js.map +0 -7
  244. package/dist/env/socket-config.d.ts +0 -1
  245. package/dist/env/socket-config.js +0 -3
  246. package/dist/env/socket-config.js.map +0 -7
  247. package/dist/env/socket-debug.d.ts +0 -1
  248. package/dist/env/socket-debug.js +0 -3
  249. package/dist/env/socket-debug.js.map +0 -7
  250. package/dist/env/socket-home.d.ts +0 -1
  251. package/dist/env/socket-home.js +0 -3
  252. package/dist/env/socket-home.js.map +0 -7
  253. package/dist/env/socket-no-api-token.d.ts +0 -1
  254. package/dist/env/socket-no-api-token.js +0 -3
  255. package/dist/env/socket-no-api-token.js.map +0 -7
  256. package/dist/env/socket-npm-registry.d.ts +0 -1
  257. package/dist/env/socket-npm-registry.js +0 -3
  258. package/dist/env/socket-npm-registry.js.map +0 -7
  259. package/dist/env/socket-org-slug.d.ts +0 -1
  260. package/dist/env/socket-org-slug.js +0 -3
  261. package/dist/env/socket-org-slug.js.map +0 -7
  262. package/dist/env/socket-registry-url.d.ts +0 -1
  263. package/dist/env/socket-registry-url.js +0 -3
  264. package/dist/env/socket-registry-url.js.map +0 -7
  265. package/dist/env/socket-view-all-risks.d.ts +0 -1
  266. package/dist/env/socket-view-all-risks.js +0 -3
  267. package/dist/env/socket-view-all-risks.js.map +0 -7
  268. package/dist/env/temp.d.ts +0 -1
  269. package/dist/env/temp.js +0 -3
  270. package/dist/env/temp.js.map +0 -7
  271. package/dist/env/tmp.d.ts +0 -1
  272. package/dist/env/tmp.js +0 -3
  273. package/dist/env/tmp.js.map +0 -7
  274. package/dist/env/tmpdir.d.ts +0 -1
  275. package/dist/env/tmpdir.js +0 -3
  276. package/dist/env/tmpdir.js.map +0 -7
  277. package/dist/env/userprofile.d.ts +0 -1
  278. package/dist/env/userprofile.js +0 -3
  279. package/dist/env/userprofile.js.map +0 -7
  280. package/dist/env/vitest.d.ts +0 -1
  281. package/dist/env/vitest.js +0 -3
  282. package/dist/env/vitest.js.map +0 -7
  283. package/dist/env/xdg-cache-home.d.ts +0 -1
  284. package/dist/env/xdg-cache-home.js +0 -3
  285. package/dist/env/xdg-cache-home.js.map +0 -7
  286. package/dist/env/xdg-config-home.d.ts +0 -1
  287. package/dist/env/xdg-config-home.js +0 -3
  288. package/dist/env/xdg-config-home.js.map +0 -7
  289. package/dist/env/xdg-data-home.d.ts +0 -1
  290. package/dist/env/xdg-data-home.js +0 -3
  291. package/dist/env/xdg-data-home.js.map +0 -7
package/dist/path.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/path.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Path manipulation utilities with cross-platform support.\n * Provides path normalization, validation, and file extension handling.\n */\n\nimport { WIN32 } from '#constants/platform'\n\nimport { search } from './strings'\n\n// Character code constants.\n// '\\'\nconst CHAR_BACKWARD_SLASH = 92\n// ':'\nconst CHAR_COLON = 58\n// '/'\nconst CHAR_FORWARD_SLASH = 47\n// 'a'\nconst CHAR_LOWERCASE_A = 97\n// 'z'\nconst CHAR_LOWERCASE_Z = 122\n// 'A'\nconst CHAR_UPPERCASE_A = 65\n// 'Z'\nconst CHAR_UPPERCASE_Z = 90\n\n// Regular expressions.\nconst slashRegExp = /[/\\\\]/\nconst nodeModulesPathRegExp = /(?:^|[/\\\\])node_modules(?:[/\\\\]|$)/\n\n/**\n * Check if a character code represents a path separator.\n *\n * Determines whether the given character code is either a forward slash (/) or\n * backslash (\\), which are used as path separators across different platforms.\n *\n * @param {number} code - The character code to check\n * @returns {boolean} `true` if the code represents a path separator, `false` otherwise\n *\n * @example\n * ```typescript\n * isPathSeparator(47) // true - forward slash '/'\n * isPathSeparator(92) // true - backslash '\\'\n * isPathSeparator(65) // false - letter 'A'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isPathSeparator(code: number): boolean {\n return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH\n}\n\n/**\n * Check if a character code represents a Windows device root letter.\n *\n * Tests whether the given character code falls within the valid range for\n * Windows drive letters (A-Z or a-z). These letters are used at the start\n * of Windows absolute paths (e.g., `C:\\`, `D:\\`).\n *\n * @param {number} code - The character code to check\n * @returns {boolean} `true` if the code is a valid drive letter, `false` otherwise\n *\n * @example\n * ```typescript\n * isWindowsDeviceRoot(67) // true - letter 'C'\n * isWindowsDeviceRoot(99) // true - letter 'c'\n * isWindowsDeviceRoot(58) // false - colon ':'\n * isWindowsDeviceRoot(47) // false - forward slash '/'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isWindowsDeviceRoot(code: number): boolean {\n return (\n (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||\n (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z)\n )\n}\n\nlet _buffer: typeof import('node:buffer') | undefined\n/**\n * Lazily load the buffer module.\n *\n * Performs on-demand loading of Node.js buffer module to avoid initialization\n * overhead and potential Webpack bundling errors.\n *\n * @private\n * @returns {typeof import('node:buffer')} The buffer module\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getBuffer() {\n if (_buffer === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _buffer = /*@__PURE__*/ require('node:buffer')\n }\n return _buffer as typeof import('node:buffer')\n}\n\nlet _url: typeof import('node:url') | undefined\n/**\n * Lazily load the url module.\n *\n * Performs on-demand loading of Node.js url module to avoid initialization\n * overhead and potential Webpack bundling errors.\n *\n * @private\n * @returns {typeof import('node:url')} The url module\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUrl() {\n if (_url === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _url = /*@__PURE__*/ require('node:url')\n }\n return _url as typeof import('node:url')\n}\n\n/**\n * Check if a path contains node_modules directory.\n *\n * Detects whether a given path includes a `node_modules` directory segment.\n * This is useful for identifying npm package dependencies and filtering\n * dependency-related paths.\n *\n * The check matches `node_modules` appearing as a complete path segment,\n * ensuring it is either at the start, end, or surrounded by path separators.\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path contains `node_modules`, `false` otherwise\n *\n * @example\n * ```typescript\n * isNodeModules('/project/node_modules/package') // true\n * isNodeModules('node_modules/package/index.js') // true\n * isNodeModules('/src/my_node_modules_backup') // false\n * isNodeModules('/project/src/index.js') // false\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isNodeModules(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n return nodeModulesPathRegExp.test(filepath)\n}\n\n/**\n * Check if a path is absolute.\n *\n * An absolute path is one that specifies a location from the root of the file system.\n * This function handles both POSIX and Windows path formats.\n *\n * POSIX absolute paths:\n * - Start with forward slash '/'\n * - Examples: '/home/user', '/usr/bin/node'\n *\n * Windows absolute paths (3 types):\n * 1. Drive-letter paths: Start with drive letter + colon + separator\n * - Format: [A-Za-z]:[\\\\/]\n * - Examples: 'C:\\Windows', 'D:/data', 'c:\\Program Files'\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#file-and-directory-names\n *\n * 2. UNC paths: Start with double backslash (handled by backslash check)\n * - Format: \\\\server\\share\n * - Examples: '\\\\server\\share\\file', '\\\\?\\C:\\path'\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#unc-names\n *\n * 3. Device paths: Start with backslash\n * - Examples: '\\Windows', '\\\\.\\device'\n * - Note: Single backslash paths are relative to current drive\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path is absolute, `false` otherwise\n *\n * @example\n * ```typescript\n * // POSIX paths\n * isAbsolute('/home/user') // true\n * isAbsolute('/usr/bin/node') // true\n *\n * // Windows paths\n * isAbsolute('C:\\\\Windows') // true\n * isAbsolute('D:/data') // true\n * isAbsolute('\\\\\\\\server\\\\share') // true\n *\n * // Relative paths\n * isAbsolute('../relative') // false\n * isAbsolute('relative/path') // false\n * isAbsolute('.') // false\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isAbsolute(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n const { length } = filepath\n\n // Empty paths are not absolute.\n if (length === 0) {\n return false\n }\n\n const code = filepath.charCodeAt(0)\n\n // POSIX: absolute paths start with forward slash '/'.\n // This is the simplest case and works for all UNIX-like systems.\n if (code === CHAR_FORWARD_SLASH) {\n return true\n }\n\n // Windows: absolute paths can start with backslash '\\'.\n // This includes UNC paths (\\\\server\\share) and device paths (\\\\.\\ or \\\\?\\).\n // Single backslash is technically relative to current drive, but treated as absolute.\n if (code === CHAR_BACKWARD_SLASH) {\n return true\n }\n\n // Windows: drive-letter absolute paths (e.g., C:\\, D:\\).\n // Format: [A-Za-z]:[\\\\/]\n // Requires at least 3 characters: drive letter + colon + separator.\n // Only treat as absolute on Windows platforms.\n if (WIN32 && length > 2) {\n // Check if first character is a letter (A-Z or a-z).\n // Check if second character is colon ':'.\n // Check if third character is a path separator (forward or backslash).\n // This matches patterns like 'C:\\', 'D:/', 'c:\\Users', etc.\n if (\n isWindowsDeviceRoot(code) &&\n filepath.charCodeAt(1) === CHAR_COLON &&\n isPathSeparator(filepath.charCodeAt(2))\n ) {\n return true\n }\n }\n\n // Not an absolute path.\n return false\n}\n\n/**\n * Check if a value is a valid file path (absolute or relative).\n *\n * Determines whether a given value represents a valid file system path.\n * This function distinguishes between file paths and other string formats\n * like package names, URLs, or bare module specifiers.\n *\n * Valid paths include:\n * - Absolute paths (e.g., `/usr/bin`, `C:\\Windows`)\n * - Relative paths with separators (e.g., `./src`, `../lib`)\n * - Special relative paths (`.`, `..`)\n * - Paths starting with `@` that have subpaths (e.g., `@scope/name/file`)\n *\n * Not considered paths:\n * - URLs with protocols (e.g., `http://`, `file://`, `git:`)\n * - Bare package names (e.g., `lodash`, `react`)\n * - Scoped package names without subpaths (e.g., `@scope/name`)\n *\n * @param {string | Buffer | URL} pathLike - The value to check\n * @returns {boolean} `true` if the value is a valid file path, `false` otherwise\n *\n * @example\n * ```typescript\n * // Valid paths\n * isPath('/absolute/path') // true\n * isPath('./relative/path') // true\n * isPath('../parent/dir') // true\n * isPath('.') // true\n * isPath('..') // true\n * isPath('@scope/name/subpath') // true\n * isPath('C:\\\\Windows') // true (Windows)\n *\n * // Not paths\n * isPath('lodash') // false - bare package name\n * isPath('@scope/package') // false - scoped package name\n * isPath('http://example.com') // false - URL\n * isPath('file://path') // false - file URL\n * isPath('') // false - empty string\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isPath(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n if (typeof filepath !== 'string' || filepath.length === 0) {\n return false\n }\n\n // Exclude URLs with protocols (file:, http:, https:, git:, etc.).\n // These should be handled by package spec parsers, not treated as file paths.\n // Require at least 2 characters before colon to exclude Windows drive letters (C:, D:).\n if (/^[a-z][a-z0-9+.-]+:/i.test(filepath)) {\n return false\n }\n\n // Special relative paths.\n if (filepath === '.' || filepath === '..') {\n return true\n }\n\n // Absolute paths are always valid paths.\n if (isAbsolute(filepath)) {\n return true\n }\n\n // Contains path separators, so it's a path.\n if (filepath.includes('/') || filepath.includes('\\\\')) {\n // Distinguish scoped package names from paths starting with '@'.\n // Scoped packages: @scope/name (exactly 2 parts, no backslashes).\n // Paths: @scope/name/subpath (3+ parts) or @scope\\name (Windows backslash).\n // Special case: '@/' is a valid path (already handled by separator check).\n if (filepath.startsWith('@') && !filepath.startsWith('@/')) {\n const parts = filepath.split('/')\n // If exactly @scope/name with no Windows separators, it's a package name.\n if (parts.length <= 2 && !parts[1]?.includes('\\\\')) {\n return false\n }\n }\n return true\n }\n\n // Bare names without separators are package names, not paths.\n return false\n}\n\n/**\n * Check if a path is relative.\n *\n * Determines whether a given path is relative (i.e., not absolute). A path\n * is considered relative if it does not specify a location from the root of\n * the file system.\n *\n * Relative paths include:\n * - Paths starting with `.` or `..` (e.g., `./src`, `../lib`)\n * - Paths without leading separators (e.g., `src/file.js`)\n * - Empty strings (treated as relative)\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path is relative, `false` if absolute\n *\n * @example\n * ```typescript\n * // Relative paths\n * isRelative('./src/index.js') // true\n * isRelative('../lib/util.js') // true\n * isRelative('src/file.js') // true\n * isRelative('') // true\n *\n * // Absolute paths\n * isRelative('/home/user') // false\n * isRelative('C:\\\\Windows') // false (Windows)\n * isRelative('\\\\\\\\server\\\\share') // false (Windows UNC)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isRelative(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n if (typeof filepath !== 'string') {\n return false\n }\n // Empty string is considered relative.\n if (filepath.length === 0) {\n return true\n }\n // A path is relative if it's not absolute.\n return !isAbsolute(filepath)\n}\n\n/**\n * Normalize a path by converting backslashes to forward slashes and collapsing segments.\n *\n * This function performs several normalization operations:\n * - Converts all backslashes (`\\`) to forward slashes (`/`)\n * - Collapses repeated slashes into single slashes\n * - Resolves `.` (current directory) segments\n * - Resolves `..` (parent directory) segments\n * - Preserves UNC path prefixes (`//server/share`)\n * - Preserves Windows namespace prefixes (`//./`, `//?/`)\n * - Returns `.` for empty or collapsed paths\n *\n * Special handling:\n * - UNC paths: Maintains double leading slashes for `//server/share` format\n * - Windows namespaces: Preserves `//./` and `//?/` prefixes\n * - Leading `..` segments: Preserved in relative paths without prefix\n * - Trailing components: Properly handled when resolving `..`\n *\n * @param {string | Buffer | URL} pathLike - The path to normalize\n * @returns {string} The normalized path with forward slashes and collapsed segments\n *\n * @example\n * ```typescript\n * // Basic normalization\n * normalizePath('foo/bar//baz') // 'foo/bar/baz'\n * normalizePath('foo/./bar') // 'foo/bar'\n * normalizePath('foo/bar/../baz') // 'foo/baz'\n *\n * // Windows paths\n * normalizePath('C:\\\\Users\\\\John\\\\file.txt') // 'C:/Users/John/file.txt'\n * normalizePath('foo\\\\bar\\\\baz') // 'foo/bar/baz'\n *\n * // UNC paths\n * normalizePath('\\\\\\\\server\\\\share\\\\file') // '//server/share/file'\n *\n * // Edge cases\n * normalizePath('') // '.'\n * normalizePath('.') // '.'\n * normalizePath('..') // '..'\n * normalizePath('///foo///bar///') // '/foo/bar'\n * normalizePath('foo/../..') // '..'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function normalizePath(pathLike: string | Buffer | URL): string {\n const filepath = pathLikeToString(pathLike)\n const { length } = filepath\n if (length === 0) {\n return '.'\n }\n if (length < 2) {\n return length === 1 && filepath.charCodeAt(0) === 92 /*'\\\\'*/\n ? '/'\n : filepath\n }\n\n let code = 0\n let start = 0\n\n // Ensure win32 namespaces have two leading slashes so they are handled properly\n // by path.win32.parse() after being normalized.\n // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces\n // UNC paths, paths starting with double slashes, e.g. \"\\\\\\\\wsl.localhost\\\\Ubuntu\\home\\\\\",\n // are okay to convert to forward slashes.\n // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions\n let prefix = ''\n if (length > 4 && filepath.charCodeAt(3) === 92 /*'\\\\'*/) {\n const code2 = filepath.charCodeAt(2)\n // Look for \\\\?\\ or \\\\.\\\n if (\n (code2 === 63 /*'?'*/ || code2 === 46) /*'.'*/ &&\n filepath.charCodeAt(0) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(1) === 92 /*'\\\\'*/\n ) {\n start = 2\n prefix = '//'\n }\n }\n if (start === 0) {\n // Check for UNC paths first (\\\\server\\share or //server/share)\n // UNC paths must start with exactly two slashes, not more\n if (\n length > 2 &&\n ((filepath.charCodeAt(0) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(1) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(2) !== 92) /*'\\\\'*/ ||\n (filepath.charCodeAt(0) === 47 /*'/'*/ &&\n filepath.charCodeAt(1) === 47 /*'/'*/ &&\n filepath.charCodeAt(2) !== 47)) /*'/'*/\n ) {\n // Check if this is a valid UNC path: must have server/share format\n // Find the first segment (server name) and second segment (share name)\n let firstSegmentEnd = -1\n let hasSecondSegment = false\n\n // Skip leading slashes after the initial double slash\n let i = 2\n while (\n i < length &&\n (filepath.charCodeAt(i) === 47 /*'/'*/ ||\n filepath.charCodeAt(i) === 92) /*'\\\\'*/\n ) {\n i++\n }\n\n // Find the end of first segment (server name)\n while (i < length) {\n const char = filepath.charCodeAt(i)\n if (char === 47 /*'/'*/ || char === 92 /*'\\\\'*/) {\n firstSegmentEnd = i\n break\n }\n i++\n }\n\n if (firstSegmentEnd > 2) {\n // Skip slashes after server name\n i = firstSegmentEnd\n while (\n i < length &&\n (filepath.charCodeAt(i) === 47 /*'/'*/ ||\n filepath.charCodeAt(i) === 92) /*'\\\\'*/\n ) {\n i++\n }\n // Check if there's a share name (second segment)\n if (i < length) {\n hasSecondSegment = true\n }\n }\n\n if (firstSegmentEnd > 2 && hasSecondSegment) {\n // Valid UNC path - preserve double leading slashes\n start = 2\n prefix = '//'\n } else {\n // Just repeated slashes, treat as regular path\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n if (start) {\n prefix = '/'\n }\n }\n } else {\n // Trim leading slashes for regular paths\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n if (start) {\n prefix = '/'\n }\n }\n }\n let nextIndex = search(filepath, slashRegExp, { fromIndex: start })\n if (nextIndex === -1) {\n const segment = filepath.slice(start)\n if (segment === '.' || segment.length === 0) {\n return prefix || '.'\n }\n if (segment === '..') {\n return prefix ? prefix.slice(0, -1) || '/' : '..'\n }\n return prefix + segment\n }\n // Process segments and handle '.', '..', and empty segments.\n let collapsed = ''\n let segmentCount = 0\n let leadingDotDots = 0\n while (nextIndex !== -1) {\n const segment = filepath.slice(start, nextIndex)\n if (segment.length > 0 && segment !== '.') {\n if (segment === '..') {\n // Handle '..' by removing the last segment if possible.\n if (segmentCount > 0) {\n // Find the last separator and remove the last segment.\n const lastSeparatorIndex = collapsed.lastIndexOf('/')\n if (lastSeparatorIndex === -1) {\n // Only one segment, remove it entirely.\n collapsed = ''\n segmentCount = 0\n // Check if this was a leading '..', restore it.\n if (leadingDotDots > 0 && !prefix) {\n collapsed = '..'\n leadingDotDots = 1\n }\n } else {\n const lastSegmentStart = lastSeparatorIndex + 1\n const lastSegmentValue = collapsed.slice(lastSegmentStart)\n // Don't collapse leading '..' segments.\n if (lastSegmentValue === '..') {\n // Preserve the '..' and add another one.\n collapsed = `${collapsed}/${segment}`\n leadingDotDots += 1\n } else {\n // Normal collapse: remove the last segment.\n collapsed = collapsed.slice(0, lastSeparatorIndex)\n segmentCount -= 1\n }\n }\n } else if (!prefix) {\n // Preserve '..' for relative paths.\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + segment\n leadingDotDots += 1\n }\n } else {\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + segment\n segmentCount += 1\n }\n }\n start = nextIndex + 1\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n nextIndex = search(filepath, slashRegExp, { fromIndex: start })\n }\n const lastSegment = filepath.slice(start)\n if (lastSegment.length > 0 && lastSegment !== '.') {\n if (lastSegment === '..') {\n if (segmentCount > 0) {\n const lastSeparatorIndex = collapsed.lastIndexOf('/')\n if (lastSeparatorIndex === -1) {\n collapsed = ''\n segmentCount = 0\n // Check if this was a leading '..', restore it.\n if (leadingDotDots > 0 && !prefix) {\n collapsed = '..'\n leadingDotDots = 1\n }\n } else {\n const lastSegmentStart = lastSeparatorIndex + 1\n const lastSegmentValue = collapsed.slice(lastSegmentStart)\n // Don't collapse leading '..' segments.\n if (lastSegmentValue === '..') {\n // Preserve the '..' and add another one.\n collapsed = `${collapsed}/${lastSegment}`\n leadingDotDots += 1\n } else {\n // Normal collapse: remove the last segment.\n collapsed = collapsed.slice(0, lastSeparatorIndex)\n segmentCount -= 1\n }\n }\n } else if (!prefix) {\n collapsed =\n collapsed + (collapsed.length === 0 ? '' : '/') + lastSegment\n leadingDotDots += 1\n }\n } else {\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + lastSegment\n segmentCount += 1\n }\n }\n\n if (collapsed.length === 0) {\n return prefix || '.'\n }\n return prefix + collapsed\n}\n\n/**\n * Convert a path-like value to a string.\n *\n * Converts various path-like types (string, Buffer, URL) into a normalized\n * string representation. This function handles different input formats and\n * provides consistent string output for path operations.\n *\n * Supported input types:\n * - `string`: Returned as-is\n * - `Buffer`: Decoded as UTF-8 string\n * - `URL`: Converted using `fileURLToPath()`, with fallback for malformed URLs\n * - `null` / `undefined`: Returns empty string\n *\n * URL handling:\n * - Valid file URLs are converted via `url.fileURLToPath()`\n * - Malformed URLs fall back to pathname extraction with decoding\n * - Windows drive letters in URLs are handled specially\n * - Percent-encoded characters are decoded (e.g., `%20` becomes space)\n *\n * @param {string | Buffer | URL | null | undefined} pathLike - The path-like value to convert\n * @returns {string} The string representation of the path, or empty string for null/undefined\n *\n * @example\n * ```typescript\n * // String input\n * pathLikeToString('/home/user') // '/home/user'\n *\n * // Buffer input\n * pathLikeToString(Buffer.from('/tmp/file')) // '/tmp/file'\n *\n * // URL input\n * pathLikeToString(new URL('file:///home/user')) // '/home/user'\n * pathLikeToString(new URL('file:///C:/Windows')) // 'C:/Windows' (Windows)\n *\n * // Null/undefined input\n * pathLikeToString(null) // ''\n * pathLikeToString(undefined) // ''\n *\n * // Percent-encoded URLs\n * pathLikeToString(new URL('file:///path%20with%20spaces')) // '/path with spaces'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function pathLikeToString(\n pathLike: string | Buffer | URL | null | undefined,\n): string {\n if (pathLike === null || pathLike === undefined) {\n return ''\n }\n if (typeof pathLike === 'string') {\n return pathLike\n }\n const { Buffer } = getBuffer()\n if (Buffer.isBuffer(pathLike)) {\n return pathLike.toString('utf8')\n }\n const url = getUrl()\n if (pathLike instanceof URL) {\n try {\n return url.fileURLToPath(pathLike)\n } catch {\n // On Windows, file URLs like `file:///C:/path` include drive letters.\n // If a file URL is missing its drive letter (malformed), fileURLToPath() throws an error.\n // This fallback extracts the pathname directly from the URL object.\n //\n // Example flows:\n // - Unix: file:///home/user \u2192 pathname '/home/user' \u2192 keep as-is\n // - Windows valid: file:///C:/path \u2192 handled by fileURLToPath()\n // - Windows invalid: file:///path \u2192 pathname '/path' \u2192 strips to 'path'\n const pathname = pathLike.pathname\n\n // Decode percent-encoded characters (e.g., %20 \u2192 space).\n // The pathname property keeps URL encoding, but file paths need decoded characters.\n // This is not platform-specific; all URLs use percent-encoding regardless of OS.\n const decodedPathname = decodeURIComponent(pathname)\n\n // URL pathnames always start with `/`.\n // On Windows, strip the leading slash only for malformed URLs that lack drive letters\n // (e.g., `/path` should be `path`, but `/C:/path` should be `C:/path`).\n // On Unix, keep the leading slash for absolute paths (e.g., `/home/user`).\n const WIN32 = require('../constants/platform').WIN32\n if (WIN32 && decodedPathname.startsWith('/')) {\n // Check for drive letter pattern following Node.js source: /[a-zA-Z]:/\n // Character at index 1 should be a letter, character at index 2 should be ':'\n // Convert to lowercase\n const letter = decodedPathname.charCodeAt(1) | 0x20\n const hasValidDriveLetter =\n decodedPathname.length >= 3 &&\n letter >= 97 &&\n // 'a' to 'z'\n letter <= 122 &&\n decodedPathname.charAt(2) === ':'\n\n if (!hasValidDriveLetter) {\n // On Windows, preserve Unix-style absolute paths that don't start with a drive letter.\n // Only strip the leading slash for truly malformed Windows paths.\n // Since fileURLToPath() failed, this is likely a valid Unix-style absolute path.\n return decodedPathname\n }\n }\n return decodedPathname\n }\n }\n return String(pathLike)\n}\n\n/**\n * Split a path into an array of segments.\n *\n * Divides a path into individual components by splitting on path separators\n * (both forward slashes and backslashes). This is useful for path traversal,\n * analysis, and manipulation.\n *\n * The function handles:\n * - Forward slashes (`/`) on all platforms\n * - Backslashes (`\\`) on Windows\n * - Mixed separators in a single path\n * - Empty paths (returns empty array)\n *\n * Note: The resulting array may contain empty strings if the path has leading,\n * trailing, or consecutive separators (e.g., `/foo//bar/` becomes `['', 'foo', '', 'bar', '']`).\n *\n * @param {string | Buffer | URL} pathLike - The path to split\n * @returns {string[]} Array of path segments, or empty array for empty paths\n *\n * @example\n * ```typescript\n * // POSIX paths\n * splitPath('/home/user/file.txt') // ['', 'home', 'user', 'file.txt']\n * splitPath('src/lib/util.js') // ['src', 'lib', 'util.js']\n *\n * // Windows paths\n * splitPath('C:\\\\Users\\\\John') // ['C:', 'Users', 'John']\n * splitPath('folder\\\\file.txt') // ['folder', 'file.txt']\n *\n * // Mixed separators\n * splitPath('path/to\\\\file') // ['path', 'to', 'file']\n *\n * // Edge cases\n * splitPath('') // []\n * splitPath('/') // ['', '']\n * splitPath('/foo//bar/') // ['', 'foo', '', 'bar', '']\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function splitPath(pathLike: string | Buffer | URL): string[] {\n const filepath = pathLikeToString(pathLike)\n if (filepath === '') {\n return []\n }\n return filepath.split(slashRegExp)\n}\n\n/**\n * Remove leading ./ or ../ from a path.\n *\n * Strips the `./` or `.\\` prefix from relative paths. This is useful for\n * normalizing paths when the current directory reference is implicit or\n * unwanted.\n *\n * Note: This function only removes a single leading `./` or `.\\`. It does\n * not remove `../` prefixes or process the rest of the path.\n *\n * @param {string | Buffer | URL} pathLike - The path to process\n * @returns {string} The path without leading `./` or `.\\`, or unchanged if no such prefix\n *\n * @example\n * ```typescript\n * // Remove ./ prefix\n * trimLeadingDotSlash('./src/index.js') // 'src/index.js'\n * trimLeadingDotSlash('.\\\\src\\\\file.txt') // 'src\\\\file.txt'\n *\n * // Preserve ../ prefix\n * trimLeadingDotSlash('../lib/util.js') // '../lib/util.js'\n *\n * // No change for other paths\n * trimLeadingDotSlash('/absolute/path') // '/absolute/path'\n * trimLeadingDotSlash('relative/path') // 'relative/path'\n * trimLeadingDotSlash('.') // '.'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function trimLeadingDotSlash(pathLike: string | Buffer | URL): string {\n const filepath = pathLikeToString(pathLike)\n // Only trim ./ not ../\n if (filepath.startsWith('./') || filepath.startsWith('.\\\\')) {\n return filepath.slice(2)\n }\n return filepath\n}\n\n/**\n * Resolve an absolute path from path segments.\n *\n * This function mimics Node.js `path.resolve()` behavior by building an\n * absolute path from the given segments. It processes segments from right\n * to left, stopping when an absolute path is encountered. If no absolute\n * path is found, it prepends the current working directory.\n *\n * Algorithm:\n * 1. Process segments from right to left\n * 2. Stop when an absolute path is found\n * 3. Prepend current working directory if no absolute path found\n * 4. Normalize the final path\n *\n * Key behaviors:\n * - Later segments override earlier ones (e.g., `resolve('/foo', '/bar')` returns `/bar`)\n * - Empty or non-string segments are skipped\n * - Result is always an absolute path\n * - Path separators are normalized to forward slashes\n *\n * @param {...string} segments - Path segments to resolve\n * @returns {string} The resolved absolute path\n *\n * @example\n * ```typescript\n * // Basic resolution\n * resolve('foo', 'bar', 'baz') // '/cwd/foo/bar/baz' (assuming cwd is '/cwd')\n * resolve('/foo', 'bar', 'baz') // '/foo/bar/baz'\n * resolve('foo', '/bar', 'baz') // '/bar/baz'\n *\n * // Windows paths\n * resolve('C:\\\\foo', 'bar') // 'C:/foo/bar'\n *\n * // Empty segments\n * resolve('foo', '', 'bar') // '/cwd/foo/bar'\n * resolve() // '/cwd' (current directory)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction resolve(...segments: string[]): string {\n let resolvedPath = ''\n let resolvedAbsolute = false\n\n // Process segments from right to left until we find an absolute path.\n // This allows later segments to override earlier ones.\n // Example: resolve('/foo', '/bar') returns '/bar', not '/foo/bar'.\n for (let i = segments.length - 1; i >= 0 && !resolvedAbsolute; i -= 1) {\n const segment = segments[i]\n\n // Skip empty or non-string segments.\n if (typeof segment !== 'string' || segment.length === 0) {\n continue\n }\n\n // Prepend the segment to the resolved path.\n // Use forward slashes as separators (normalized later).\n resolvedPath =\n segment + (resolvedPath.length === 0 ? '' : `/${resolvedPath}`)\n\n // Check if this segment is absolute.\n // Absolute paths stop the resolution process.\n resolvedAbsolute = isAbsolute(segment)\n }\n\n // If no absolute path was found in segments, prepend current working directory.\n // This ensures the final path is always absolute.\n if (!resolvedAbsolute) {\n const cwd = /*@__PURE__*/ require('node:process').cwd()\n resolvedPath = cwd + (resolvedPath.length === 0 ? '' : `/${resolvedPath}`)\n }\n\n // Normalize the resolved path (collapse '..' and '.', convert separators).\n return normalizePath(resolvedPath)\n}\n\n/**\n * Calculate the relative path from one path to another.\n *\n * This function computes how to get from the `from` path to the `to` path\n * using relative path notation. Both paths are first resolved to absolute\n * paths, then compared to find the common base path, and finally a relative\n * path is constructed using `../` for parent directory traversal.\n *\n * Algorithm:\n * 1. Resolve both paths to absolute\n * 2. Find the longest common path prefix (up to a separator)\n * 3. For each remaining directory in `from`, add `../` to go up\n * 4. Append the remaining path from `to`\n *\n * Windows-specific behavior:\n * - File system paths are case-insensitive on Windows (NTFS, FAT32)\n * - `C:\\Foo` and `c:\\foo` are considered the same path\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n * - Case is preserved but not significant for comparison\n *\n * @param {string} from - The source path (starting point)\n * @param {string} to - The destination path (target)\n * @returns {string} The relative path from `from` to `to`, or empty string if paths are identical\n *\n * @example\n * ```typescript\n * // Basic relative paths\n * relative('/foo/bar', '/foo/baz') // '../baz'\n * relative('/foo/bar/baz', '/foo') // '../..'\n * relative('/foo', '/foo/bar') // 'bar'\n *\n * // Same paths\n * relative('/foo/bar', '/foo/bar') // ''\n *\n * // Windows case-insensitive\n * relative('C:\\\\Foo\\\\bar', 'C:\\\\foo\\\\baz') // '../baz' (Windows)\n *\n * // Root paths\n * relative('/', '/foo/bar') // 'foo/bar'\n * relative('/foo/bar', '/') // '../..'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction relative(from: string, to: string): string {\n // Quick return if paths are already identical.\n if (from === to) {\n return ''\n }\n\n // Resolve both paths to absolute.\n // This handles relative paths, '.', '..', and ensures consistent format.\n const actualFrom = resolve(from)\n const actualTo = resolve(to)\n\n // Check again after resolution (paths might have been equivalent).\n if (actualFrom === actualTo) {\n return ''\n }\n\n const WIN32 = require('../constants/platform').WIN32\n\n // Windows: perform case-insensitive comparison.\n // NTFS and FAT32 preserve case but are case-insensitive for lookups.\n // This means 'C:\\Foo\\bar.txt' and 'c:\\foo\\BAR.TXT' refer to the same file.\n // Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#case-sensitivity\n if (WIN32) {\n const fromLower = actualFrom.toLowerCase()\n const toLower = actualTo.toLowerCase()\n if (fromLower === toLower) {\n return ''\n }\n }\n\n // Skip the leading separator for comparison.\n // We compare paths starting after the root separator to find common directories.\n // Example: '/foo/bar' becomes 'foo/bar' for comparison (index 1).\n const fromStart = 1\n const fromEnd = actualFrom.length\n const fromLen = fromEnd - fromStart\n const toStart = 1\n const toEnd = actualTo.length\n const toLen = toEnd - toStart\n\n // Compare paths character by character to find the longest common prefix.\n // We only consider a common prefix valid if it ends at a directory separator.\n const length = fromLen < toLen ? fromLen : toLen\n // Index of last common directory separator.\n let lastCommonSep = -1\n let i = 0\n\n for (; i < length; i += 1) {\n let fromCode = actualFrom.charCodeAt(fromStart + i)\n let toCode = actualTo.charCodeAt(toStart + i)\n\n // Paths diverge at this character.\n // On Windows, perform case-insensitive comparison.\n if (WIN32) {\n // Normalize to lowercase for case-insensitive comparison.\n // Convert A-Z (65-90) to a-z (97-122).\n if (fromCode >= CHAR_UPPERCASE_A && fromCode <= CHAR_UPPERCASE_Z) {\n fromCode += 32\n }\n if (toCode >= CHAR_UPPERCASE_A && toCode <= CHAR_UPPERCASE_Z) {\n toCode += 32\n }\n }\n\n if (fromCode !== toCode) {\n break\n }\n\n // Track directory separators (both forward and backslash for Windows compatibility).\n // We need this to ensure we only split at directory boundaries.\n // Use original fromCode from actualFrom (before case normalization).\n if (isPathSeparator(actualFrom.charCodeAt(fromStart + i))) {\n lastCommonSep = i\n }\n }\n\n // Handle edge cases where one path is a prefix of the other.\n if (i === length) {\n if (toLen > length) {\n // Destination path is longer.\n const toCode = actualTo.charCodeAt(toStart + i)\n if (isPathSeparator(toCode)) {\n // `from` is the exact base path for `to`.\n // Example: from='/foo/bar'; to='/foo/bar/baz' \u2192 'baz'\n // Skip the separator character (+1) to get just the relative portion.\n return actualTo.slice(toStart + i + 1)\n }\n if (i === 0) {\n // `from` is the root directory.\n // Example: from='/'; to='/foo' \u2192 'foo'\n return actualTo.slice(toStart + i)\n }\n } else if (fromLen > length) {\n // Source path is longer.\n const fromCode = actualFrom.charCodeAt(fromStart + i)\n if (isPathSeparator(fromCode)) {\n // `to` is the exact base path for `from`.\n // Example: from='/foo/bar/baz'; to='/foo/bar' \u2192 '..'\n // We need to go up from the extra directory.\n lastCommonSep = i\n } else if (i === 0) {\n // `to` is the root directory.\n // Example: from='/foo'; to='/' \u2192 '..'\n lastCommonSep = 0\n }\n }\n }\n\n // Generate the relative path by constructing '../' segments.\n let out = ''\n\n // Count the number of directories in `from` after the common base.\n // For each directory, we need to go up one level ('../').\n // Example: from='/a/b/c', to='/a/x' \u2192 common='a', need '../..' (up from c, up from b)\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; i += 1) {\n const code = actualFrom.charCodeAt(i)\n\n // At the end of the path or at a separator, add '../'.\n if (i === fromEnd || isPathSeparator(code)) {\n out += out.length === 0 ? '..' : '/..'\n }\n }\n\n // Append the rest of the destination path after the common base.\n // This gives us the path from the common ancestor to the destination.\n return out + actualTo.slice(toStart + lastCommonSep)\n}\n\n/**\n * Get the relative path from one path to another.\n *\n * Computes the relative path from `from` to `to` and normalizes the result.\n * This is a convenience wrapper around the `relative()` function that adds\n * path normalization (converting separators and collapsing segments).\n *\n * The function:\n * 1. Calculates the relative path using `relative()`\n * 2. Normalizes the result using `normalizePath()`\n * 3. Preserves empty strings (same path) without converting to `.`\n *\n * @param {string} from - The source path (starting point)\n * @param {string} to - The destination path (target)\n * @returns {string} The normalized relative path from `from` to `to`, or empty string if paths are identical\n *\n * @example\n * ```typescript\n * // Basic usage\n * relativeResolve('/foo/bar', '/foo/baz') // '../baz'\n * relativeResolve('/foo/bar/baz', '/foo') // '../..'\n * relativeResolve('/foo', '/foo/bar') // 'bar'\n *\n * // Same paths\n * relativeResolve('/foo/bar', '/foo/bar') // ''\n *\n * // Windows paths (normalized)\n * relativeResolve('C:\\\\foo\\\\bar', 'C:\\\\foo\\\\baz') // '../baz'\n *\n * // With normalization\n * relativeResolve('/foo/./bar', '/foo/baz') // '../baz'\n * relativeResolve('/foo/bar/../baz', '/foo/qux') // '../qux'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function relativeResolve(from: string, to: string): string {\n const rel = relative(from, to)\n // Empty string means same path - don't normalize to '.'\n if (rel === '') {\n return ''\n }\n return normalizePath(rel)\n}\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,kBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,kBAAAC,EAAA,qBAAAC,EAAA,oBAAAC,EAAA,cAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAX,GAKA,IAAAY,EAAsB,+BAEtBC,EAAuB,qBAIvB,MAAMC,EAAsB,GAEtBC,EAAa,GAEbC,EAAqB,GAErBC,EAAmB,GAEnBC,EAAmB,IAEnBC,EAAmB,GAEnBC,EAAmB,GAGnBC,EAAc,QACdC,EAAwB,qCAmB9B,SAASC,EAAgBC,EAAuB,CAC9C,OAAOA,IAASR,GAAsBQ,IAASV,CACjD,CAqBA,SAASW,EAAoBD,EAAuB,CAClD,OACGA,GAAQL,GAAoBK,GAAQJ,GACpCI,GAAQP,GAAoBO,GAAQN,CAEzC,CAEA,IAAIQ,EAWJ,SAASC,GAAY,CACnB,OAAID,IAAY,SAGdA,EAAwB,QAAQ,aAAa,GAExCA,CACT,CAEA,IAAIE,EAWJ,SAASC,GAAS,CAChB,OAAID,IAAS,SAGXA,EAAqB,QAAQ,UAAU,GAElCA,CACT,CAwBO,SAASzB,EAAc2B,EAA0C,CACtE,MAAMC,EAAWxB,EAAiBu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GACH,GAEFrE,EAAcqE,CAAG,CAC1B",
6
- "names": ["path_exports", "__export", "isAbsolute", "isNodeModules", "isPath", "isRelative", "normalizePath", "pathLikeToString", "relativeResolve", "splitPath", "trimLeadingDotSlash", "__toCommonJS", "import_platform", "import_strings", "CHAR_BACKWARD_SLASH", "CHAR_COLON", "CHAR_FORWARD_SLASH", "CHAR_LOWERCASE_A", "CHAR_LOWERCASE_Z", "CHAR_UPPERCASE_A", "CHAR_UPPERCASE_Z", "slashRegExp", "nodeModulesPathRegExp", "isPathSeparator", "code", "isWindowsDeviceRoot", "_buffer", "getBuffer", "_url", "getUrl", "pathLike", "filepath", "length", "parts", "start", "prefix", "code2", "firstSegmentEnd", "hasSecondSegment", "i", "char", "nextIndex", "segment", "collapsed", "segmentCount", "leadingDotDots", "lastSeparatorIndex", "lastSegmentStart", "lastSegment", "Buffer", "url", "pathname", "decodedPathname", "letter", "resolve", "segments", "resolvedPath", "resolvedAbsolute", "relative", "from", "to", "actualFrom", "actualTo", "WIN32", "fromLower", "toLower", "fromStart", "fromEnd", "fromLen", "toStart", "toLen", "lastCommonSep", "fromCode", "toCode", "out", "rel"]
4
+ "sourcesContent": ["/**\n * @fileoverview Path manipulation utilities with cross-platform support.\n * Provides path normalization, validation, and file extension handling.\n */\n\nimport { WIN32 } from '#constants/platform'\n\nimport { search } from './strings'\n\n// Character code constants.\n// '\\'\nconst CHAR_BACKWARD_SLASH = 92\n// ':'\nconst CHAR_COLON = 58\n// '/'\nconst CHAR_FORWARD_SLASH = 47\n// 'a'\nconst CHAR_LOWERCASE_A = 97\n// 'z'\nconst CHAR_LOWERCASE_Z = 122\n// 'A'\nconst CHAR_UPPERCASE_A = 65\n// 'Z'\nconst CHAR_UPPERCASE_Z = 90\n\n// Regular expressions.\nconst slashRegExp = /[/\\\\]/\nconst nodeModulesPathRegExp = /(?:^|[/\\\\])node_modules(?:[/\\\\]|$)/\n\n/**\n * Check if a character code represents a path separator.\n *\n * Determines whether the given character code is either a forward slash (/) or\n * backslash (\\), which are used as path separators across different platforms.\n *\n * @param {number} code - The character code to check\n * @returns {boolean} `true` if the code represents a path separator, `false` otherwise\n *\n * @example\n * ```typescript\n * isPathSeparator(47) // true - forward slash '/'\n * isPathSeparator(92) // true - backslash '\\'\n * isPathSeparator(65) // false - letter 'A'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isPathSeparator(code: number): boolean {\n return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH\n}\n\n/**\n * Check if a character code represents a Windows device root letter.\n *\n * Tests whether the given character code falls within the valid range for\n * Windows drive letters (A-Z or a-z). These letters are used at the start\n * of Windows absolute paths (e.g., `C:\\`, `D:\\`).\n *\n * @param {number} code - The character code to check\n * @returns {boolean} `true` if the code is a valid drive letter, `false` otherwise\n *\n * @example\n * ```typescript\n * isWindowsDeviceRoot(67) // true - letter 'C'\n * isWindowsDeviceRoot(99) // true - letter 'c'\n * isWindowsDeviceRoot(58) // false - colon ':'\n * isWindowsDeviceRoot(47) // false - forward slash '/'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction isWindowsDeviceRoot(code: number): boolean {\n return (\n (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||\n (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z)\n )\n}\n\nlet _buffer: typeof import('node:buffer') | undefined\n/**\n * Lazily load the buffer module.\n *\n * Performs on-demand loading of Node.js buffer module to avoid initialization\n * overhead and potential Webpack bundling errors.\n *\n * @private\n * @returns {typeof import('node:buffer')} The buffer module\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getBuffer() {\n if (_buffer === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _buffer = /*@__PURE__*/ require('node:buffer')\n }\n return _buffer as typeof import('node:buffer')\n}\n\nlet _url: typeof import('node:url') | undefined\n/**\n * Lazily load the url module.\n *\n * Performs on-demand loading of Node.js url module to avoid initialization\n * overhead and potential Webpack bundling errors.\n *\n * @private\n * @returns {typeof import('node:url')} The url module\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getUrl() {\n if (_url === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _url = /*@__PURE__*/ require('node:url')\n }\n return _url as typeof import('node:url')\n}\n\n/**\n * Check if a path contains node_modules directory.\n *\n * Detects whether a given path includes a `node_modules` directory segment.\n * This is useful for identifying npm package dependencies and filtering\n * dependency-related paths.\n *\n * The check matches `node_modules` appearing as a complete path segment,\n * ensuring it is either at the start, end, or surrounded by path separators.\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path contains `node_modules`, `false` otherwise\n *\n * @example\n * ```typescript\n * isNodeModules('/project/node_modules/package') // true\n * isNodeModules('node_modules/package/index.js') // true\n * isNodeModules('/src/my_node_modules_backup') // false\n * isNodeModules('/project/src/index.js') // false\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isNodeModules(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n return nodeModulesPathRegExp.test(filepath)\n}\n\n/**\n * Check if a path is absolute.\n *\n * An absolute path is one that specifies a location from the root of the file system.\n * This function handles both POSIX and Windows path formats.\n *\n * POSIX absolute paths:\n * - Start with forward slash '/'\n * - Examples: '/home/user', '/usr/bin/node'\n *\n * Windows absolute paths (3 types):\n * 1. Drive-letter paths: Start with drive letter + colon + separator\n * - Format: [A-Za-z]:[\\\\/]\n * - Examples: 'C:\\Windows', 'D:/data', 'c:\\Program Files'\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#file-and-directory-names\n *\n * 2. UNC paths: Start with double backslash (handled by backslash check)\n * - Format: \\\\server\\share\n * - Examples: '\\\\server\\share\\file', '\\\\?\\C:\\path'\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#unc-names\n *\n * 3. Device paths: Start with backslash\n * - Examples: '\\Windows', '\\\\.\\device'\n * - Note: Single backslash paths are relative to current drive\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path is absolute, `false` otherwise\n *\n * @example\n * ```typescript\n * // POSIX paths\n * isAbsolute('/home/user') // true\n * isAbsolute('/usr/bin/node') // true\n *\n * // Windows paths\n * isAbsolute('C:\\\\Windows') // true\n * isAbsolute('D:/data') // true\n * isAbsolute('\\\\\\\\server\\\\share') // true\n *\n * // Relative paths\n * isAbsolute('../relative') // false\n * isAbsolute('relative/path') // false\n * isAbsolute('.') // false\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isAbsolute(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n const { length } = filepath\n\n // Empty paths are not absolute.\n if (length === 0) {\n return false\n }\n\n const code = filepath.charCodeAt(0)\n\n // POSIX: absolute paths start with forward slash '/'.\n // This is the simplest case and works for all UNIX-like systems.\n if (code === CHAR_FORWARD_SLASH) {\n return true\n }\n\n // Windows: absolute paths can start with backslash '\\'.\n // This includes UNC paths (\\\\server\\share) and device paths (\\\\.\\ or \\\\?\\).\n // Single backslash is technically relative to current drive, but treated as absolute.\n if (code === CHAR_BACKWARD_SLASH) {\n return true\n }\n\n // Windows: drive-letter absolute paths (e.g., C:\\, D:\\).\n // Format: [A-Za-z]:[\\\\/]\n // Requires at least 3 characters: drive letter + colon + separator.\n // Only treat as absolute on Windows platforms.\n if (WIN32 && length > 2) {\n // Check if first character is a letter (A-Z or a-z).\n // Check if second character is colon ':'.\n // Check if third character is a path separator (forward or backslash).\n // This matches patterns like 'C:\\', 'D:/', 'c:\\Users', etc.\n if (\n isWindowsDeviceRoot(code) &&\n filepath.charCodeAt(1) === CHAR_COLON &&\n isPathSeparator(filepath.charCodeAt(2))\n ) {\n return true\n }\n }\n\n // Not an absolute path.\n return false\n}\n\n/**\n * Check if a value is a valid file path (absolute or relative).\n *\n * Determines whether a given value represents a valid file system path.\n * This function distinguishes between file paths and other string formats\n * like package names, URLs, or bare module specifiers.\n *\n * Valid paths include:\n * - Absolute paths (e.g., `/usr/bin`, `C:\\Windows`)\n * - Relative paths with separators (e.g., `./src`, `../lib`)\n * - Special relative paths (`.`, `..`)\n * - Paths starting with `@` that have subpaths (e.g., `@scope/name/file`)\n *\n * Not considered paths:\n * - URLs with protocols (e.g., `http://`, `file://`, `git:`)\n * - Bare package names (e.g., `lodash`, `react`)\n * - Scoped package names without subpaths (e.g., `@scope/name`)\n *\n * @param {string | Buffer | URL} pathLike - The value to check\n * @returns {boolean} `true` if the value is a valid file path, `false` otherwise\n *\n * @example\n * ```typescript\n * // Valid paths\n * isPath('/absolute/path') // true\n * isPath('./relative/path') // true\n * isPath('../parent/dir') // true\n * isPath('.') // true\n * isPath('..') // true\n * isPath('@scope/name/subpath') // true\n * isPath('C:\\\\Windows') // true (Windows)\n *\n * // Not paths\n * isPath('lodash') // false - bare package name\n * isPath('@scope/package') // false - scoped package name\n * isPath('http://example.com') // false - URL\n * isPath('file://path') // false - file URL\n * isPath('') // false - empty string\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isPath(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n if (typeof filepath !== 'string' || filepath.length === 0) {\n return false\n }\n\n // Exclude URLs with protocols (file:, http:, https:, git:, etc.).\n // These should be handled by package spec parsers, not treated as file paths.\n // Require at least 2 characters before colon to exclude Windows drive letters (C:, D:).\n if (/^[a-z][a-z0-9+.-]+:/i.test(filepath)) {\n return false\n }\n\n // Special relative paths.\n if (filepath === '.' || filepath === '..') {\n return true\n }\n\n // Absolute paths are always valid paths.\n if (isAbsolute(filepath)) {\n return true\n }\n\n // Contains path separators, so it's a path.\n if (filepath.includes('/') || filepath.includes('\\\\')) {\n // Distinguish scoped package names from paths starting with '@'.\n // Scoped packages: @scope/name (exactly 2 parts, no backslashes).\n // Paths: @scope/name/subpath (3+ parts) or @scope\\name (Windows backslash).\n // Special case: '@/' is a valid path (already handled by separator check).\n if (filepath.startsWith('@') && !filepath.startsWith('@/')) {\n const parts = filepath.split('/')\n // If exactly @scope/name with no Windows separators, it's a package name.\n if (parts.length <= 2 && !parts[1]?.includes('\\\\')) {\n return false\n }\n }\n return true\n }\n\n // Bare names without separators are package names, not paths.\n return false\n}\n\n/**\n * Check if a path is relative.\n *\n * Determines whether a given path is relative (i.e., not absolute). A path\n * is considered relative if it does not specify a location from the root of\n * the file system.\n *\n * Relative paths include:\n * - Paths starting with `.` or `..` (e.g., `./src`, `../lib`)\n * - Paths without leading separators (e.g., `src/file.js`)\n * - Empty strings (treated as relative)\n *\n * @param {string | Buffer | URL} pathLike - The path to check\n * @returns {boolean} `true` if the path is relative, `false` if absolute\n *\n * @example\n * ```typescript\n * // Relative paths\n * isRelative('./src/index.js') // true\n * isRelative('../lib/util.js') // true\n * isRelative('src/file.js') // true\n * isRelative('') // true\n *\n * // Absolute paths\n * isRelative('/home/user') // false\n * isRelative('C:\\\\Windows') // false (Windows)\n * isRelative('\\\\\\\\server\\\\share') // false (Windows UNC)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isRelative(pathLike: string | Buffer | URL): boolean {\n const filepath = pathLikeToString(pathLike)\n if (typeof filepath !== 'string') {\n return false\n }\n // Empty string is considered relative.\n if (filepath.length === 0) {\n return true\n }\n // A path is relative if it's not absolute.\n return !isAbsolute(filepath)\n}\n\n/**\n * Normalize a path by converting backslashes to forward slashes and collapsing segments.\n *\n * This function performs several normalization operations:\n * - Converts all backslashes (`\\`) to forward slashes (`/`)\n * - Collapses repeated slashes into single slashes\n * - Resolves `.` (current directory) segments\n * - Resolves `..` (parent directory) segments\n * - Preserves UNC path prefixes (`//server/share`)\n * - Preserves Windows namespace prefixes (`//./`, `//?/`)\n * - Returns `.` for empty or collapsed paths\n *\n * Special handling:\n * - UNC paths: Maintains double leading slashes for `//server/share` format\n * - Windows namespaces: Preserves `//./` and `//?/` prefixes\n * - Leading `..` segments: Preserved in relative paths without prefix\n * - Trailing components: Properly handled when resolving `..`\n *\n * @param {string | Buffer | URL} pathLike - The path to normalize\n * @returns {string} The normalized path with forward slashes and collapsed segments\n *\n * @example\n * ```typescript\n * // Basic normalization\n * normalizePath('foo/bar//baz') // 'foo/bar/baz'\n * normalizePath('foo/./bar') // 'foo/bar'\n * normalizePath('foo/bar/../baz') // 'foo/baz'\n *\n * // Windows paths\n * normalizePath('C:\\\\Users\\\\username\\\\file.txt') // 'C:/Users/username/file.txt'\n * normalizePath('foo\\\\bar\\\\baz') // 'foo/bar/baz'\n *\n * // UNC paths\n * normalizePath('\\\\\\\\server\\\\share\\\\file') // '//server/share/file'\n *\n * // Edge cases\n * normalizePath('') // '.'\n * normalizePath('.') // '.'\n * normalizePath('..') // '..'\n * normalizePath('///foo///bar///') // '/foo/bar'\n * normalizePath('foo/../..') // '..'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function normalizePath(pathLike: string | Buffer | URL): string {\n const filepath = pathLikeToString(pathLike)\n const { length } = filepath\n if (length === 0) {\n return '.'\n }\n if (length < 2) {\n return length === 1 && filepath.charCodeAt(0) === 92 /*'\\\\'*/\n ? '/'\n : filepath\n }\n\n let code = 0\n let start = 0\n\n // Ensure win32 namespaces have two leading slashes so they are handled properly\n // by path.win32.parse() after being normalized.\n // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces\n // UNC paths, paths starting with double slashes, e.g. \"\\\\\\\\wsl.localhost\\\\Ubuntu\\home\\\\\",\n // are okay to convert to forward slashes.\n // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions\n let prefix = ''\n if (length > 4 && filepath.charCodeAt(3) === 92 /*'\\\\'*/) {\n const code2 = filepath.charCodeAt(2)\n // Look for \\\\?\\ or \\\\.\\\n if (\n (code2 === 63 /*'?'*/ || code2 === 46) /*'.'*/ &&\n filepath.charCodeAt(0) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(1) === 92 /*'\\\\'*/\n ) {\n start = 2\n prefix = '//'\n }\n }\n if (start === 0) {\n // Check for UNC paths first (\\\\server\\share or //server/share)\n // UNC paths must start with exactly two slashes, not more\n if (\n length > 2 &&\n ((filepath.charCodeAt(0) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(1) === 92 /*'\\\\'*/ &&\n filepath.charCodeAt(2) !== 92) /*'\\\\'*/ ||\n (filepath.charCodeAt(0) === 47 /*'/'*/ &&\n filepath.charCodeAt(1) === 47 /*'/'*/ &&\n filepath.charCodeAt(2) !== 47)) /*'/'*/\n ) {\n // Check if this is a valid UNC path: must have server/share format\n // Find the first segment (server name) and second segment (share name)\n let firstSegmentEnd = -1\n let hasSecondSegment = false\n\n // Skip leading slashes after the initial double slash\n let i = 2\n while (\n i < length &&\n (filepath.charCodeAt(i) === 47 /*'/'*/ ||\n filepath.charCodeAt(i) === 92) /*'\\\\'*/\n ) {\n i++\n }\n\n // Find the end of first segment (server name)\n while (i < length) {\n const char = filepath.charCodeAt(i)\n if (char === 47 /*'/'*/ || char === 92 /*'\\\\'*/) {\n firstSegmentEnd = i\n break\n }\n i++\n }\n\n if (firstSegmentEnd > 2) {\n // Skip slashes after server name\n i = firstSegmentEnd\n while (\n i < length &&\n (filepath.charCodeAt(i) === 47 /*'/'*/ ||\n filepath.charCodeAt(i) === 92) /*'\\\\'*/\n ) {\n i++\n }\n // Check if there's a share name (second segment)\n if (i < length) {\n hasSecondSegment = true\n }\n }\n\n if (firstSegmentEnd > 2 && hasSecondSegment) {\n // Valid UNC path - preserve double leading slashes\n start = 2\n prefix = '//'\n } else {\n // Just repeated slashes, treat as regular path\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n if (start) {\n prefix = '/'\n }\n }\n } else {\n // Trim leading slashes for regular paths\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n if (start) {\n prefix = '/'\n }\n }\n }\n let nextIndex = search(filepath, slashRegExp, { fromIndex: start })\n if (nextIndex === -1) {\n const segment = filepath.slice(start)\n if (segment === '.' || segment.length === 0) {\n return prefix || '.'\n }\n if (segment === '..') {\n return prefix ? prefix.slice(0, -1) || '/' : '..'\n }\n return prefix + segment\n }\n // Process segments and handle '.', '..', and empty segments.\n let collapsed = ''\n let segmentCount = 0\n let leadingDotDots = 0\n while (nextIndex !== -1) {\n const segment = filepath.slice(start, nextIndex)\n if (segment.length > 0 && segment !== '.') {\n if (segment === '..') {\n // Handle '..' by removing the last segment if possible.\n if (segmentCount > 0) {\n // Find the last separator and remove the last segment.\n const lastSeparatorIndex = collapsed.lastIndexOf('/')\n if (lastSeparatorIndex === -1) {\n // Only one segment, remove it entirely.\n collapsed = ''\n segmentCount = 0\n // Check if this was a leading '..', restore it.\n if (leadingDotDots > 0 && !prefix) {\n collapsed = '..'\n leadingDotDots = 1\n }\n } else {\n const lastSegmentStart = lastSeparatorIndex + 1\n const lastSegmentValue = collapsed.slice(lastSegmentStart)\n // Don't collapse leading '..' segments.\n if (lastSegmentValue === '..') {\n // Preserve the '..' and add another one.\n collapsed = `${collapsed}/${segment}`\n leadingDotDots += 1\n } else {\n // Normal collapse: remove the last segment.\n collapsed = collapsed.slice(0, lastSeparatorIndex)\n segmentCount -= 1\n }\n }\n } else if (!prefix) {\n // Preserve '..' for relative paths.\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + segment\n leadingDotDots += 1\n }\n } else {\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + segment\n segmentCount += 1\n }\n }\n start = nextIndex + 1\n code = filepath.charCodeAt(start)\n while (code === 47 /*'/'*/ || code === 92 /*'\\\\'*/) {\n start += 1\n code = filepath.charCodeAt(start)\n }\n nextIndex = search(filepath, slashRegExp, { fromIndex: start })\n }\n const lastSegment = filepath.slice(start)\n if (lastSegment.length > 0 && lastSegment !== '.') {\n if (lastSegment === '..') {\n if (segmentCount > 0) {\n const lastSeparatorIndex = collapsed.lastIndexOf('/')\n if (lastSeparatorIndex === -1) {\n collapsed = ''\n segmentCount = 0\n // Check if this was a leading '..', restore it.\n if (leadingDotDots > 0 && !prefix) {\n collapsed = '..'\n leadingDotDots = 1\n }\n } else {\n const lastSegmentStart = lastSeparatorIndex + 1\n const lastSegmentValue = collapsed.slice(lastSegmentStart)\n // Don't collapse leading '..' segments.\n if (lastSegmentValue === '..') {\n // Preserve the '..' and add another one.\n collapsed = `${collapsed}/${lastSegment}`\n leadingDotDots += 1\n } else {\n // Normal collapse: remove the last segment.\n collapsed = collapsed.slice(0, lastSeparatorIndex)\n segmentCount -= 1\n }\n }\n } else if (!prefix) {\n collapsed =\n collapsed + (collapsed.length === 0 ? '' : '/') + lastSegment\n leadingDotDots += 1\n }\n } else {\n collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + lastSegment\n segmentCount += 1\n }\n }\n\n if (collapsed.length === 0) {\n return prefix || '.'\n }\n return prefix + collapsed\n}\n\n/**\n * Convert a path-like value to a string.\n *\n * Converts various path-like types (string, Buffer, URL) into a normalized\n * string representation. This function handles different input formats and\n * provides consistent string output for path operations.\n *\n * Supported input types:\n * - `string`: Returned as-is\n * - `Buffer`: Decoded as UTF-8 string\n * - `URL`: Converted using `fileURLToPath()`, with fallback for malformed URLs\n * - `null` / `undefined`: Returns empty string\n *\n * URL handling:\n * - Valid file URLs are converted via `url.fileURLToPath()`\n * - Malformed URLs fall back to pathname extraction with decoding\n * - Windows drive letters in URLs are handled specially\n * - Percent-encoded characters are decoded (e.g., `%20` becomes space)\n *\n * @param {string | Buffer | URL | null | undefined} pathLike - The path-like value to convert\n * @returns {string} The string representation of the path, or empty string for null/undefined\n *\n * @example\n * ```typescript\n * // String input\n * pathLikeToString('/home/user') // '/home/user'\n *\n * // Buffer input\n * pathLikeToString(Buffer.from('/tmp/file')) // '/tmp/file'\n *\n * // URL input\n * pathLikeToString(new URL('file:///home/user')) // '/home/user'\n * pathLikeToString(new URL('file:///C:/Windows')) // 'C:/Windows' (Windows)\n *\n * // Null/undefined input\n * pathLikeToString(null) // ''\n * pathLikeToString(undefined) // ''\n *\n * // Percent-encoded URLs\n * pathLikeToString(new URL('file:///path%20with%20spaces')) // '/path with spaces'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function pathLikeToString(\n pathLike: string | Buffer | URL | null | undefined,\n): string {\n if (pathLike === null || pathLike === undefined) {\n return ''\n }\n if (typeof pathLike === 'string') {\n return pathLike\n }\n const { Buffer } = getBuffer()\n if (Buffer.isBuffer(pathLike)) {\n return pathLike.toString('utf8')\n }\n const url = getUrl()\n if (pathLike instanceof URL) {\n try {\n return url.fileURLToPath(pathLike)\n } catch {\n // On Windows, file URLs like `file:///C:/path` include drive letters.\n // If a file URL is missing its drive letter (malformed), fileURLToPath() throws an error.\n // This fallback extracts the pathname directly from the URL object.\n //\n // Example flows:\n // - Unix: file:///home/user \u2192 pathname '/home/user' \u2192 keep as-is\n // - Windows valid: file:///C:/path \u2192 handled by fileURLToPath()\n // - Windows invalid: file:///path \u2192 pathname '/path' \u2192 strips to 'path'\n const pathname = pathLike.pathname\n\n // Decode percent-encoded characters (e.g., %20 \u2192 space).\n // The pathname property keeps URL encoding, but file paths need decoded characters.\n // This is not platform-specific; all URLs use percent-encoding regardless of OS.\n const decodedPathname = decodeURIComponent(pathname)\n\n // URL pathnames always start with `/`.\n // On Windows, strip the leading slash only for malformed URLs that lack drive letters\n // (e.g., `/path` should be `path`, but `/C:/path` should be `C:/path`).\n // On Unix, keep the leading slash for absolute paths (e.g., `/home/user`).\n if (WIN32 && decodedPathname.startsWith('/')) {\n // Check for drive letter pattern following Node.js source: /[a-zA-Z]:/\n // Character at index 1 should be a letter, character at index 2 should be ':'\n // Convert to lowercase\n const letter = decodedPathname.charCodeAt(1) | 0x20\n const hasValidDriveLetter =\n decodedPathname.length >= 3 &&\n letter >= 97 &&\n // 'a' to 'z'\n letter <= 122 &&\n decodedPathname.charAt(2) === ':'\n\n if (!hasValidDriveLetter) {\n // On Windows, preserve Unix-style absolute paths that don't start with a drive letter.\n // Only strip the leading slash for truly malformed Windows paths.\n // Since fileURLToPath() failed, this is likely a valid Unix-style absolute path.\n return decodedPathname\n }\n }\n return decodedPathname\n }\n }\n return String(pathLike)\n}\n\n/**\n * Split a path into an array of segments.\n *\n * Divides a path into individual components by splitting on path separators\n * (both forward slashes and backslashes). This is useful for path traversal,\n * analysis, and manipulation.\n *\n * The function handles:\n * - Forward slashes (`/`) on all platforms\n * - Backslashes (`\\`) on Windows\n * - Mixed separators in a single path\n * - Empty paths (returns empty array)\n *\n * Note: The resulting array may contain empty strings if the path has leading,\n * trailing, or consecutive separators (e.g., `/foo//bar/` becomes `['', 'foo', '', 'bar', '']`).\n *\n * @param {string | Buffer | URL} pathLike - The path to split\n * @returns {string[]} Array of path segments, or empty array for empty paths\n *\n * @example\n * ```typescript\n * // POSIX paths\n * splitPath('/home/user/file.txt') // ['', 'home', 'user', 'file.txt']\n * splitPath('src/lib/util.js') // ['src', 'lib', 'util.js']\n *\n * // Windows paths\n * splitPath('C:\\\\Users\\\\John') // ['C:', 'Users', 'John']\n * splitPath('folder\\\\file.txt') // ['folder', 'file.txt']\n *\n * // Mixed separators\n * splitPath('path/to\\\\file') // ['path', 'to', 'file']\n *\n * // Edge cases\n * splitPath('') // []\n * splitPath('/') // ['', '']\n * splitPath('/foo//bar/') // ['', 'foo', '', 'bar', '']\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function splitPath(pathLike: string | Buffer | URL): string[] {\n const filepath = pathLikeToString(pathLike)\n if (filepath === '') {\n return []\n }\n return filepath.split(slashRegExp)\n}\n\n/**\n * Remove leading ./ or ../ from a path.\n *\n * Strips the `./` or `.\\` prefix from relative paths. This is useful for\n * normalizing paths when the current directory reference is implicit or\n * unwanted.\n *\n * Note: This function only removes a single leading `./` or `.\\`. It does\n * not remove `../` prefixes or process the rest of the path.\n *\n * @param {string | Buffer | URL} pathLike - The path to process\n * @returns {string} The path without leading `./` or `.\\`, or unchanged if no such prefix\n *\n * @example\n * ```typescript\n * // Remove ./ prefix\n * trimLeadingDotSlash('./src/index.js') // 'src/index.js'\n * trimLeadingDotSlash('.\\\\src\\\\file.txt') // 'src\\\\file.txt'\n *\n * // Preserve ../ prefix\n * trimLeadingDotSlash('../lib/util.js') // '../lib/util.js'\n *\n * // No change for other paths\n * trimLeadingDotSlash('/absolute/path') // '/absolute/path'\n * trimLeadingDotSlash('relative/path') // 'relative/path'\n * trimLeadingDotSlash('.') // '.'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function trimLeadingDotSlash(pathLike: string | Buffer | URL): string {\n const filepath = pathLikeToString(pathLike)\n // Only trim ./ not ../\n if (filepath.startsWith('./') || filepath.startsWith('.\\\\')) {\n return filepath.slice(2)\n }\n return filepath\n}\n\n/**\n * Resolve an absolute path from path segments.\n *\n * This function mimics Node.js `path.resolve()` behavior by building an\n * absolute path from the given segments. It processes segments from right\n * to left, stopping when an absolute path is encountered. If no absolute\n * path is found, it prepends the current working directory.\n *\n * Algorithm:\n * 1. Process segments from right to left\n * 2. Stop when an absolute path is found\n * 3. Prepend current working directory if no absolute path found\n * 4. Normalize the final path\n *\n * Key behaviors:\n * - Later segments override earlier ones (e.g., `resolve('/foo', '/bar')` returns `/bar`)\n * - Empty or non-string segments are skipped\n * - Result is always an absolute path\n * - Path separators are normalized to forward slashes\n *\n * @param {...string} segments - Path segments to resolve\n * @returns {string} The resolved absolute path\n *\n * @example\n * ```typescript\n * // Basic resolution\n * resolve('foo', 'bar', 'baz') // '/cwd/foo/bar/baz' (assuming cwd is '/cwd')\n * resolve('/foo', 'bar', 'baz') // '/foo/bar/baz'\n * resolve('foo', '/bar', 'baz') // '/bar/baz'\n *\n * // Windows paths\n * resolve('C:\\\\foo', 'bar') // 'C:/foo/bar'\n *\n * // Empty segments\n * resolve('foo', '', 'bar') // '/cwd/foo/bar'\n * resolve() // '/cwd' (current directory)\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction resolve(...segments: string[]): string {\n let resolvedPath = ''\n let resolvedAbsolute = false\n\n // Process segments from right to left until we find an absolute path.\n // This allows later segments to override earlier ones.\n // Example: resolve('/foo', '/bar') returns '/bar', not '/foo/bar'.\n for (let i = segments.length - 1; i >= 0 && !resolvedAbsolute; i -= 1) {\n const segment = segments[i]\n\n // Skip empty or non-string segments.\n if (typeof segment !== 'string' || segment.length === 0) {\n continue\n }\n\n // Prepend the segment to the resolved path.\n // Use forward slashes as separators (normalized later).\n resolvedPath =\n segment + (resolvedPath.length === 0 ? '' : `/${resolvedPath}`)\n\n // Check if this segment is absolute.\n // Absolute paths stop the resolution process.\n resolvedAbsolute = isAbsolute(segment)\n }\n\n // If no absolute path was found in segments, prepend current working directory.\n // This ensures the final path is always absolute.\n if (!resolvedAbsolute) {\n const cwd = /*@__PURE__*/ require('node:process').cwd()\n resolvedPath = cwd + (resolvedPath.length === 0 ? '' : `/${resolvedPath}`)\n }\n\n // Normalize the resolved path (collapse '..' and '.', convert separators).\n return normalizePath(resolvedPath)\n}\n\n/**\n * Calculate the relative path from one path to another.\n *\n * This function computes how to get from the `from` path to the `to` path\n * using relative path notation. Both paths are first resolved to absolute\n * paths, then compared to find the common base path, and finally a relative\n * path is constructed using `../` for parent directory traversal.\n *\n * Algorithm:\n * 1. Resolve both paths to absolute\n * 2. Find the longest common path prefix (up to a separator)\n * 3. For each remaining directory in `from`, add `../` to go up\n * 4. Append the remaining path from `to`\n *\n * Windows-specific behavior:\n * - File system paths are case-insensitive on Windows (NTFS, FAT32)\n * - `C:\\Foo` and `c:\\foo` are considered the same path\n * - Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n * - Case is preserved but not significant for comparison\n *\n * @param {string} from - The source path (starting point)\n * @param {string} to - The destination path (target)\n * @returns {string} The relative path from `from` to `to`, or empty string if paths are identical\n *\n * @example\n * ```typescript\n * // Basic relative paths\n * relative('/foo/bar', '/foo/baz') // '../baz'\n * relative('/foo/bar/baz', '/foo') // '../..'\n * relative('/foo', '/foo/bar') // 'bar'\n *\n * // Same paths\n * relative('/foo/bar', '/foo/bar') // ''\n *\n * // Windows case-insensitive\n * relative('C:\\\\Foo\\\\bar', 'C:\\\\foo\\\\baz') // '../baz' (Windows)\n *\n * // Root paths\n * relative('/', '/foo/bar') // 'foo/bar'\n * relative('/foo/bar', '/') // '../..'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction relative(from: string, to: string): string {\n // Quick return if paths are already identical.\n if (from === to) {\n return ''\n }\n\n // Resolve both paths to absolute.\n // This handles relative paths, '.', '..', and ensures consistent format.\n const actualFrom = resolve(from)\n const actualTo = resolve(to)\n\n // Check again after resolution (paths might have been equivalent).\n if (actualFrom === actualTo) {\n return ''\n }\n\n // Windows: perform case-insensitive comparison.\n // NTFS and FAT32 preserve case but are case-insensitive for lookups.\n // This means 'C:\\Foo\\bar.txt' and 'c:\\foo\\BAR.TXT' refer to the same file.\n // Reference: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#case-sensitivity\n if (WIN32) {\n const fromLower = actualFrom.toLowerCase()\n const toLower = actualTo.toLowerCase()\n if (fromLower === toLower) {\n return ''\n }\n }\n\n // Skip the leading separator for comparison.\n // We compare paths starting after the root separator to find common directories.\n // Example: '/foo/bar' becomes 'foo/bar' for comparison (index 1).\n const fromStart = 1\n const fromEnd = actualFrom.length\n const fromLen = fromEnd - fromStart\n const toStart = 1\n const toEnd = actualTo.length\n const toLen = toEnd - toStart\n\n // Compare paths character by character to find the longest common prefix.\n // We only consider a common prefix valid if it ends at a directory separator.\n const length = fromLen < toLen ? fromLen : toLen\n // Index of last common directory separator.\n let lastCommonSep = -1\n let i = 0\n\n for (; i < length; i += 1) {\n let fromCode = actualFrom.charCodeAt(fromStart + i)\n let toCode = actualTo.charCodeAt(toStart + i)\n\n // Paths diverge at this character.\n // On Windows, perform case-insensitive comparison.\n if (WIN32) {\n // Normalize to lowercase for case-insensitive comparison.\n // Convert A-Z (65-90) to a-z (97-122).\n if (fromCode >= CHAR_UPPERCASE_A && fromCode <= CHAR_UPPERCASE_Z) {\n fromCode += 32\n }\n if (toCode >= CHAR_UPPERCASE_A && toCode <= CHAR_UPPERCASE_Z) {\n toCode += 32\n }\n }\n\n if (fromCode !== toCode) {\n break\n }\n\n // Track directory separators (both forward and backslash for Windows compatibility).\n // We need this to ensure we only split at directory boundaries.\n // Use original fromCode from actualFrom (before case normalization).\n if (isPathSeparator(actualFrom.charCodeAt(fromStart + i))) {\n lastCommonSep = i\n }\n }\n\n // Handle edge cases where one path is a prefix of the other.\n if (i === length) {\n if (toLen > length) {\n // Destination path is longer.\n const toCode = actualTo.charCodeAt(toStart + i)\n if (isPathSeparator(toCode)) {\n // `from` is the exact base path for `to`.\n // Example: from='/foo/bar'; to='/foo/bar/baz' \u2192 'baz'\n // Skip the separator character (+1) to get just the relative portion.\n return actualTo.slice(toStart + i + 1)\n }\n if (i === 0) {\n // `from` is the root directory.\n // Example: from='/'; to='/foo' \u2192 'foo'\n return actualTo.slice(toStart + i)\n }\n } else if (fromLen > length) {\n // Source path is longer.\n const fromCode = actualFrom.charCodeAt(fromStart + i)\n if (isPathSeparator(fromCode)) {\n // `to` is the exact base path for `from`.\n // Example: from='/foo/bar/baz'; to='/foo/bar' \u2192 '..'\n // We need to go up from the extra directory.\n lastCommonSep = i\n } else if (i === 0) {\n // `to` is the root directory.\n // Example: from='/foo'; to='/' \u2192 '..'\n lastCommonSep = 0\n }\n }\n }\n\n // Generate the relative path by constructing '../' segments.\n let out = ''\n\n // Count the number of directories in `from` after the common base.\n // For each directory, we need to go up one level ('../').\n // Example: from='/a/b/c', to='/a/x' \u2192 common='a', need '../..' (up from c, up from b)\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; i += 1) {\n const code = actualFrom.charCodeAt(i)\n\n // At the end of the path or at a separator, add '../'.\n if (i === fromEnd || isPathSeparator(code)) {\n out += out.length === 0 ? '..' : '/..'\n }\n }\n\n // Append the rest of the destination path after the common base.\n // This gives us the path from the common ancestor to the destination.\n return out + actualTo.slice(toStart + lastCommonSep)\n}\n\n/**\n * Get the relative path from one path to another.\n *\n * Computes the relative path from `from` to `to` and normalizes the result.\n * This is a convenience wrapper around the `relative()` function that adds\n * path normalization (converting separators and collapsing segments).\n *\n * The function:\n * 1. Calculates the relative path using `relative()`\n * 2. Normalizes the result using `normalizePath()`\n * 3. Preserves empty strings (same path) without converting to `.`\n *\n * @param {string} from - The source path (starting point)\n * @param {string} to - The destination path (target)\n * @returns {string} The normalized relative path from `from` to `to`, or empty string if paths are identical\n *\n * @example\n * ```typescript\n * // Basic usage\n * relativeResolve('/foo/bar', '/foo/baz') // '../baz'\n * relativeResolve('/foo/bar/baz', '/foo') // '../..'\n * relativeResolve('/foo', '/foo/bar') // 'bar'\n *\n * // Same paths\n * relativeResolve('/foo/bar', '/foo/bar') // ''\n *\n * // Windows paths (normalized)\n * relativeResolve('C:\\\\foo\\\\bar', 'C:\\\\foo\\\\baz') // '../baz'\n *\n * // With normalization\n * relativeResolve('/foo/./bar', '/foo/baz') // '../baz'\n * relativeResolve('/foo/bar/../baz', '/foo/qux') // '../qux'\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function relativeResolve(from: string, to: string): string {\n const rel = relative(from, to)\n // Empty string means same path - don't normalize to '.'\n if (rel === '') {\n return ''\n }\n return normalizePath(rel)\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,kBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,kBAAAC,EAAA,qBAAAC,EAAA,oBAAAC,EAAA,cAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAX,GAKA,IAAAY,EAAsB,+BAEtBC,EAAuB,qBAIvB,MAAMC,EAAsB,GAEtBC,EAAa,GAEbC,EAAqB,GAErBC,EAAmB,GAEnBC,EAAmB,IAEnBC,EAAmB,GAEnBC,EAAmB,GAGnBC,EAAc,QACdC,EAAwB,qCAmB9B,SA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B,EAAYK,EAAgB,EAAG/B,GAAK2B,EAAS3B,GAAK,EAAG,CAC5D,MAAMf,EAAOqC,EAAW,WAAWtB,CAAC,GAGhCA,IAAM2B,GAAW3C,EAAgBC,CAAI,KACvCiD,GAAOA,EAAI,SAAW,EAAI,KAAO,MAErC,CAIA,OAAOA,EAAMX,EAAS,MAAMM,EAAUE,CAAa,CACrD,CAqCO,SAAS9D,EAAgBmD,EAAcC,EAAoB,CAChE,MAAMc,EAAMhB,EAASC,EAAMC,CAAE,EAE7B,OAAIc,IAAQ,GACH,GAEFpE,EAAcoE,CAAG,CAC1B",
6
+ "names": ["path_exports", "__export", "isAbsolute", "isNodeModules", "isPath", "isRelative", "normalizePath", "pathLikeToString", "relativeResolve", "splitPath", "trimLeadingDotSlash", "__toCommonJS", "import_platform", "import_strings", "CHAR_BACKWARD_SLASH", "CHAR_COLON", "CHAR_FORWARD_SLASH", "CHAR_LOWERCASE_A", "CHAR_LOWERCASE_Z", "CHAR_UPPERCASE_A", "CHAR_UPPERCASE_Z", "slashRegExp", "nodeModulesPathRegExp", "isPathSeparator", "code", "isWindowsDeviceRoot", "_buffer", "getBuffer", "_url", "getUrl", "pathLike", "filepath", "length", "parts", "start", "prefix", "code2", "firstSegmentEnd", "hasSecondSegment", "i", "char", "nextIndex", "segment", "collapsed", "segmentCount", "leadingDotDots", "lastSeparatorIndex", "lastSegmentStart", "lastSegment", "Buffer", "url", "pathname", "decodedPathname", "letter", "resolve", "segments", "resolvedPath", "resolvedAbsolute", "relative", "from", "to", "actualFrom", "actualTo", "fromLower", "toLower", "fromStart", "fromEnd", "fromLen", "toStart", "toLen", "lastCommonSep", "fromCode", "toCode", "out", "rel"]
7
7
  }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Clear a specific path override.
3
+ */
4
+ export declare function clearPath(key: string): void;
5
+ /**
6
+ * Get a path value, checking overrides first.
7
+ *
8
+ * Resolution order:
9
+ * 1. Test overrides (set via setPath in beforeEach)
10
+ * 2. Cached value (for performance)
11
+ * 3. Original function call (cached for subsequent calls)
12
+ *
13
+ * @internal Used by path getters to support test rewiring
14
+ */
15
+ export declare function getPathValue(key: string, originalFn: () => string): string;
16
+ /**
17
+ * Check if a path has been overridden.
18
+ */
19
+ export declare function hasOverride(key: string): boolean;
20
+ /**
21
+ * Invalidate all cached paths.
22
+ * Called automatically when setPath/clearPath/resetPaths are used.
23
+ * Can also be called manually for advanced testing scenarios.
24
+ *
25
+ * @internal Primarily for internal use, but exported for advanced testing
26
+ */
27
+ export declare function invalidateCaches(): void;
28
+ /**
29
+ * Register a cache invalidation callback.
30
+ * Called by modules that need to clear their caches when paths change.
31
+ *
32
+ * @internal Used by paths.ts and fs.ts
33
+ */
34
+ export declare function registerCacheInvalidation(callback: () => void): void;
35
+ /**
36
+ * Clear all path overrides and reset caches.
37
+ * Useful in afterEach hooks to ensure clean test state.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { resetPaths } from '#paths/rewire'
42
+ *
43
+ * afterEach(() => {
44
+ * resetPaths()
45
+ * })
46
+ * ```
47
+ */
48
+ export declare function resetPaths(): void;
49
+ /**
50
+ * Set a path override for testing.
51
+ * This triggers cache invalidation for path-dependent modules.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * import { setPath, resetPaths } from '#paths/rewire'
56
+ * import { getOsTmpDir } from '#lib/paths'
57
+ *
58
+ * beforeEach(() => {
59
+ * setPath('tmpdir', '/custom/tmp')
60
+ * })
61
+ *
62
+ * afterEach(() => {
63
+ * resetPaths()
64
+ * })
65
+ *
66
+ * it('should use custom temp directory', () => {
67
+ * expect(getOsTmpDir()).toBe('/custom/tmp')
68
+ * })
69
+ * ```
70
+ */
71
+ export declare function setPath(key: string, value: string | undefined): void;
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var h=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},v=(t,n,e,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of u(n))!l.call(t,i)&&i!==e&&o(t,i,{get:()=>n[i],enumerable:!(c=g(n,i))||c.enumerable});return t};var f=t=>v(o({},"__esModule",{value:!0}),t);var I={};h(I,{clearPath:()=>p,getPathValue:()=>x,hasOverride:()=>C,invalidateCaches:()=>s,registerCacheInvalidation:()=>P,resetPaths:()=>b,setPath:()=>w});module.exports=f(I);const r=new Map,a=new Map,d=[];function p(t){r.delete(t),s()}function x(t,n){if(r.has(t))return r.get(t);if(a.has(t))return a.get(t);const e=n();return a.set(t,e),e}function C(t){return r.has(t)}function s(){a.clear();for(const t of d)try{t()}catch{}}function P(t){d.push(t)}function b(){r.clear(),s()}function w(t,n){r.set(t,n),s()}0&&(module.exports={clearPath,getPathValue,hasOverride,invalidateCaches,registerCacheInvalidation,resetPaths,setPath});
3
+ //# sourceMappingURL=rewire.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/paths/rewire.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Path rewiring utilities for testing.\n * Allows tests to override os.tmpdir() and os.homedir() without directly modifying them.\n *\n * Features:\n * - Test-friendly setPath/clearPath/resetPaths that work in beforeEach/afterEach\n * - Automatic cache invalidation for path-dependent modules\n * - Thread-safe for concurrent test execution\n */\n\n// Per-test overrides\n// Each test file gets its own instance due to Vitest's module isolation\nconst testOverrides = new Map<string, string | undefined>()\n\n// Cache for computed values (cleared when overrides change)\nconst valueCache = new Map<string, string>()\n\n// Cache invalidation callbacks - registered by modules that need to clear their caches\nconst cacheInvalidationCallbacks: Array<() => void> = []\n\n/**\n * Clear a specific path override.\n */\nexport function clearPath(key: string): void {\n testOverrides.delete(key)\n // Invalidate all path-related caches\n invalidateCaches()\n}\n\n/**\n * Get a path value, checking overrides first.\n *\n * Resolution order:\n * 1. Test overrides (set via setPath in beforeEach)\n * 2. Cached value (for performance)\n * 3. Original function call (cached for subsequent calls)\n *\n * @internal Used by path getters to support test rewiring\n */\nexport function getPathValue(key: string, originalFn: () => string): string {\n // Check test overrides first\n if (testOverrides.has(key)) {\n return testOverrides.get(key) as string\n }\n\n // Check cache\n if (valueCache.has(key)) {\n return valueCache.get(key) as string\n }\n\n // Compute and cache\n const value = originalFn()\n valueCache.set(key, value)\n return value\n}\n\n/**\n * Check if a path has been overridden.\n */\nexport function hasOverride(key: string): boolean {\n return testOverrides.has(key)\n}\n\n/**\n * Invalidate all cached paths.\n * Called automatically when setPath/clearPath/resetPaths are used.\n * Can also be called manually for advanced testing scenarios.\n *\n * @internal Primarily for internal use, but exported for advanced testing\n */\nexport function invalidateCaches(): void {\n // Clear the value cache\n valueCache.clear()\n\n // Call registered callbacks\n for (const callback of cacheInvalidationCallbacks) {\n try {\n callback()\n } catch {\n // Ignore errors from cache invalidation\n }\n }\n}\n\n/**\n * Register a cache invalidation callback.\n * Called by modules that need to clear their caches when paths change.\n *\n * @internal Used by paths.ts and fs.ts\n */\nexport function registerCacheInvalidation(callback: () => void): void {\n cacheInvalidationCallbacks.push(callback)\n}\n\n/**\n * Clear all path overrides and reset caches.\n * Useful in afterEach hooks to ensure clean test state.\n *\n * @example\n * ```typescript\n * import { resetPaths } from '#paths/rewire'\n *\n * afterEach(() => {\n * resetPaths()\n * })\n * ```\n */\nexport function resetPaths(): void {\n testOverrides.clear()\n // Invalidate all path-related caches\n invalidateCaches()\n}\n\n/**\n * Set a path override for testing.\n * This triggers cache invalidation for path-dependent modules.\n *\n * @example\n * ```typescript\n * import { setPath, resetPaths } from '#paths/rewire'\n * import { getOsTmpDir } from '#lib/paths'\n *\n * beforeEach(() => {\n * setPath('tmpdir', '/custom/tmp')\n * })\n *\n * afterEach(() => {\n * resetPaths()\n * })\n *\n * it('should use custom temp directory', () => {\n * expect(getOsTmpDir()).toBe('/custom/tmp')\n * })\n * ```\n */\nexport function setPath(key: string, value: string | undefined): void {\n testOverrides.set(key, value)\n // Invalidate all path-related caches\n invalidateCaches()\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,iBAAAC,EAAA,gBAAAC,EAAA,qBAAAC,EAAA,8BAAAC,EAAA,eAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAT,GAYA,MAAMU,EAAgB,IAAI,IAGpBC,EAAa,IAAI,IAGjBC,EAAgD,CAAC,EAKhD,SAASV,EAAUW,EAAmB,CAC3CH,EAAc,OAAOG,CAAG,EAExBR,EAAiB,CACnB,CAYO,SAASF,EAAaU,EAAaC,EAAkC,CAE1E,GAAIJ,EAAc,IAAIG,CAAG,EACvB,OAAOH,EAAc,IAAIG,CAAG,EAI9B,GAAIF,EAAW,IAAIE,CAAG,EACpB,OAAOF,EAAW,IAAIE,CAAG,EAI3B,MAAME,EAAQD,EAAW,EACzB,OAAAH,EAAW,IAAIE,EAAKE,CAAK,EAClBA,CACT,CAKO,SAASX,EAAYS,EAAsB,CAChD,OAAOH,EAAc,IAAIG,CAAG,CAC9B,CASO,SAASR,GAAyB,CAEvCM,EAAW,MAAM,EAGjB,UAAWK,KAAYJ,EACrB,GAAI,CACFI,EAAS,CACX,MAAQ,CAER,CAEJ,CAQO,SAASV,EAA0BU,EAA4B,CACpEJ,EAA2B,KAAKI,CAAQ,CAC1C,CAeO,SAAST,GAAmB,CACjCG,EAAc,MAAM,EAEpBL,EAAiB,CACnB,CAwBO,SAASG,EAAQK,EAAaE,EAAiC,CACpEL,EAAc,IAAIG,EAAKE,CAAK,EAE5BV,EAAiB,CACnB",
6
+ "names": ["rewire_exports", "__export", "clearPath", "getPathValue", "hasOverride", "invalidateCaches", "registerCacheInvalidation", "resetPaths", "setPath", "__toCommonJS", "testOverrides", "valueCache", "cacheInvalidationCallbacks", "key", "originalFn", "value", "callback"]
7
+ }
package/dist/paths.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Get the OS home directory.
3
+ * Can be overridden in tests using setPath('homedir', ...) from paths/rewire.
4
+ */
5
+ export declare function getOsHomeDir(): string;
6
+ /**
7
+ * Get the OS temporary directory.
8
+ * Can be overridden in tests using setPath('tmpdir', ...) from paths/rewire.
9
+ */
10
+ export declare function getOsTmpDir(): string;
1
11
  /**
2
12
  * Get the Socket home directory (~/.socket).
3
13
  * Alias for getSocketUserDir() for consistency across Socket projects.
@@ -5,6 +15,7 @@
5
15
  export declare function getSocketHomePath(): string;
6
16
  /**
7
17
  * Get the Socket user directory (~/.socket).
18
+ * Result is memoized for performance.
8
19
  */
9
20
  export declare function getSocketUserDir(): string;
10
21
  /**
@@ -14,10 +25,12 @@ export declare function getSocketAppDir(appName: string): string;
14
25
  /**
15
26
  * Get the Socket cacache directory (~/.socket/_cacache).
16
27
  * Can be overridden with SOCKET_CACACHE_DIR environment variable for testing.
28
+ * Result is memoized for performance.
17
29
  */
18
30
  export declare function getSocketCacacheDir(): string;
19
31
  /**
20
32
  * Get the Socket DLX directory (~/.socket/_dlx).
33
+ * Can be overridden with SOCKET_DLX_DIR environment variable for testing.
21
34
  */
22
35
  export declare function getSocketDlxDir(): string;
23
36
  /**
@@ -40,3 +53,16 @@ export declare function getSocketRegistryDir(): string;
40
53
  * Get the Socket Registry GitHub cache directory (~/.socket/_registry/cache/ttl/github).
41
54
  */
42
55
  export declare function getSocketRegistryGithubCacheDir(): string;
56
+ /**
57
+ * Get the user's home directory.
58
+ * Uses environment variables directly to support test mocking.
59
+ * Falls back to os.homedir() if env vars not set.
60
+ */
61
+ export declare function getUserHomeDir(): string;
62
+ /**
63
+ * Invalidate all cached path values.
64
+ * Called automatically by the paths/rewire module when setPath/clearPath/resetPaths are used.
65
+ *
66
+ * @internal Used for test rewiring
67
+ */
68
+ export declare function invalidateCache(): void;
package/dist/paths.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var A=Object.create;var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var R=(r,t)=>{for(var i in t)c(r,i,{get:t[i],enumerable:!0})},E=(r,t,i,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!f.call(r,o)&&o!==i&&c(r,o,{get:()=>t[o],enumerable:!(C=P(t,o))||C.enumerable});return r};var p=(r,t,i)=>(i=r!=null?A(T(r)):{},E(t||!r||!r.__esModule?c(i,"default",{value:r,enumerable:!0}):i,r)),a=r=>E(c({},"__esModule",{value:!0}),r);var K={};R(K,{getSocketAppCacheDir:()=>S,getSocketAppCacheTtlDir:()=>s,getSocketAppDir:()=>_,getSocketCacacheDir:()=>q,getSocketCliDir:()=>h,getSocketDlxDir:()=>x,getSocketHomePath:()=>m,getSocketRegistryDir:()=>k,getSocketRegistryGithubCacheDir:()=>O,getSocketUserDir:()=>u});module.exports=a(K);var I=p(require("node:os")),n=p(require("node:path")),g=require("#env/socket-cacache-dir"),e=require("./path");function m(){return u()}function u(){return(0,e.normalizePath)(n.join(I.homedir(),require("./constants/paths").DOT_SOCKET_DIR))}function _(r){return(0,e.normalizePath)(n.join(u(),`${require("./constants/socket").SOCKET_APP_PREFIX}${r}`))}function q(){return g.SOCKET_CACACHE_DIR?(0,e.normalizePath)(g.SOCKET_CACACHE_DIR):(0,e.normalizePath)(n.join(u(),`${require("./constants/socket").SOCKET_APP_PREFIX}cacache`))}function x(){return(0,e.normalizePath)(n.join(u(),`${require("./constants/socket").SOCKET_APP_PREFIX}${require("./constants/socket").SOCKET_DLX_APP_NAME}`))}function S(r){return(0,e.normalizePath)(n.join(_(r),require("./constants/paths").CACHE_DIR))}function s(r){return(0,e.normalizePath)(n.join(S(r),require("./constants/paths").CACHE_TTL_DIR))}function h(){return _(require("./constants/socket").SOCKET_CLI_APP_NAME)}function k(){return _(require("./constants/socket").SOCKET_REGISTRY_APP_NAME)}function O(){return(0,e.normalizePath)(n.join(s(require("./constants/socket").SOCKET_REGISTRY_APP_NAME),require("./constants/github").CACHE_GITHUB_DIR))}0&&(module.exports={getSocketAppCacheDir,getSocketAppCacheTtlDir,getSocketAppDir,getSocketCacacheDir,getSocketCliDir,getSocketDlxDir,getSocketHomePath,getSocketRegistryDir,getSocketRegistryGithubCacheDir,getSocketUserDir});
2
+ var T=Object.create;var f=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var q=(e,r)=>{for(var i in r)f(e,i,{get:r[i],enumerable:!0})},m=(e,r,i,_)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of l(r))!I.call(e,c)&&c!==i&&f(e,c,{get:()=>r[c],enumerable:!(_=k(r,c))||_.enumerable});return e};var C=(e,r,i)=>(i=e!=null?T(R(e)):{},m(r||!e||!e.__esModule?f(i,"default",{value:e,enumerable:!0}):i,e)),O=e=>m(f({},"__esModule",{value:!0}),e);var M={};q(M,{getOsHomeDir:()=>d,getOsTmpDir:()=>H,getSocketAppCacheDir:()=>P,getSocketAppCacheTtlDir:()=>h,getSocketAppDir:()=>p,getSocketCacacheDir:()=>j,getSocketCliDir:()=>U,getSocketDlxDir:()=>v,getSocketHomePath:()=>K,getSocketRegistryDir:()=>$,getSocketRegistryGithubCacheDir:()=>G,getSocketUserDir:()=>s,getUserHomeDir:()=>A,invalidateCache:()=>x});module.exports=O(M);var D=C(require("node:os")),n=C(require("node:path")),S=require("#env/home"),o=require("#env/socket"),E=require("#env/windows"),t=require("./path"),g=require("./paths/rewire");function d(){return(0,g.getPathValue)("homedir",()=>D.homedir())}function H(){return(0,g.getPathValue)("tmpdir",()=>D.tmpdir())}function K(){return s()}let a;function s(){return a===void 0&&(a=(0,t.normalizePath)(n.join(A(),require("#constants/paths").DOT_SOCKET_DIR))),a}function p(e){return(0,t.normalizePath)(n.join(s(),`${require("#constants/socket").SOCKET_APP_PREFIX}${e}`))}let u;function j(){return u===void 0&&((0,o.getSocketCacacheDir)()?u=(0,t.normalizePath)((0,o.getSocketCacacheDir)()):u=(0,t.normalizePath)(n.join(s(),`${require("#constants/socket").SOCKET_APP_PREFIX}cacache`))),u}function v(){return(0,o.getSocketDlxDirEnv)()?(0,t.normalizePath)((0,o.getSocketDlxDirEnv)()):(0,t.normalizePath)(n.join(s(),`${require("#constants/socket").SOCKET_APP_PREFIX}${require("#constants/socket").SOCKET_DLX_APP_NAME}`))}function P(e){return(0,t.normalizePath)(n.join(p(e),require("#constants/paths").CACHE_DIR))}function h(e){return(0,t.normalizePath)(n.join(P(e),require("#constants/paths").CACHE_TTL_DIR))}function U(){return p(require("#constants/socket").SOCKET_CLI_APP_NAME)}function $(){return p(require("#constants/socket").SOCKET_REGISTRY_APP_NAME)}function G(){return(0,t.normalizePath)(n.join(h(require("#constants/socket").SOCKET_REGISTRY_APP_NAME),require("#constants/github").CACHE_GITHUB_DIR))}function A(){const e=(0,S.getHome)();if(e)return e;const r=(0,E.getUserprofile)();return r||d()}function x(){a=void 0,u=void 0}(0,g.registerCacheInvalidation)(x);0&&(module.exports={getOsHomeDir,getOsTmpDir,getSocketAppCacheDir,getSocketAppCacheTtlDir,getSocketAppDir,getSocketCacacheDir,getSocketCliDir,getSocketDlxDir,getSocketHomePath,getSocketRegistryDir,getSocketRegistryGithubCacheDir,getSocketUserDir,getUserHomeDir,invalidateCache});
3
3
  //# sourceMappingURL=paths.js.map
package/dist/paths.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/paths.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Path utilities for Socket ecosystem directories.\n * Provides platform-aware path resolution for Socket tools' shared directory structure.\n *\n * Directory Structure:\n * ~/.socket/\n * \u251C\u2500\u2500 _cacache/ # Content-addressable cache for npm packages\n * \u251C\u2500\u2500 _dlx/ # DLX installations (content-addressed by hash)\n * \u2502 \u251C\u2500\u2500 <hash>/ # npm package installs (dlx-package)\n * \u2502 \u2514\u2500\u2500 <hash>/ # binary downloads (dlx-binary)\n * \u251C\u2500\u2500 _socket/ # Socket CLI app directory\n * \u251C\u2500\u2500 _registry/ # Socket Registry app directory\n * \u2514\u2500\u2500 _sfw/ # Socket Firewall app directory\n */\n\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nimport { SOCKET_CACACHE_DIR } from '#env/socket-cacache-dir'\n\nimport { normalizePath } from './path'\n\n/**\n * Get the Socket home directory (~/.socket).\n * Alias for getSocketUserDir() for consistency across Socket projects.\n */\nexport function getSocketHomePath(): string {\n return getSocketUserDir()\n}\n\n/**\n * Get the Socket user directory (~/.socket).\n */\nexport function getSocketUserDir(): string {\n return normalizePath(\n path.join(\n os.homedir(),\n /*@__INLINE__*/ require('./constants/paths').DOT_SOCKET_DIR,\n ),\n )\n}\n\n/**\n * Get a Socket app directory (~/.socket/_<appName>).\n */\nexport function getSocketAppDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('./constants/socket').SOCKET_APP_PREFIX}${appName}`,\n ),\n )\n}\n\n/**\n * Get the Socket cacache directory (~/.socket/_cacache).\n * Can be overridden with SOCKET_CACACHE_DIR environment variable for testing.\n */\nexport function getSocketCacacheDir(): string {\n if (SOCKET_CACACHE_DIR) {\n return normalizePath(SOCKET_CACACHE_DIR)\n }\n return normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('./constants/socket').SOCKET_APP_PREFIX}cacache`,\n ),\n )\n}\n\n/**\n * Get the Socket DLX directory (~/.socket/_dlx).\n */\nexport function getSocketDlxDir(): string {\n return normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('./constants/socket').SOCKET_APP_PREFIX}${/*@__INLINE__*/ require('./constants/socket').SOCKET_DLX_APP_NAME}`,\n ),\n )\n}\n\n/**\n * Get a Socket app cache directory (~/.socket/_<appName>/cache).\n */\nexport function getSocketAppCacheDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketAppDir(appName),\n /*@__INLINE__*/ require('./constants/paths').CACHE_DIR,\n ),\n )\n}\n\n/**\n * Get a Socket app TTL cache directory (~/.socket/_<appName>/cache/ttl).\n */\nexport function getSocketAppCacheTtlDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketAppCacheDir(appName),\n /*@__INLINE__*/ require('./constants/paths').CACHE_TTL_DIR,\n ),\n )\n}\n\n/**\n * Get the Socket CLI directory (~/.socket/_socket).\n */\nexport function getSocketCliDir(): string {\n return getSocketAppDir(\n /*@__INLINE__*/ require('./constants/socket').SOCKET_CLI_APP_NAME,\n )\n}\n\n/**\n * Get the Socket Registry directory (~/.socket/_registry).\n */\nexport function getSocketRegistryDir(): string {\n return getSocketAppDir(\n /*@__INLINE__*/ require('./constants/socket').SOCKET_REGISTRY_APP_NAME,\n )\n}\n\n/**\n * Get the Socket Registry GitHub cache directory (~/.socket/_registry/cache/ttl/github).\n */\nexport function getSocketRegistryGithubCacheDir(): string {\n return normalizePath(\n path.join(\n getSocketAppCacheTtlDir(\n /*@__INLINE__*/ require('./constants/socket').SOCKET_REGISTRY_APP_NAME,\n ),\n /*@__INLINE__*/ require('./constants/github').CACHE_GITHUB_DIR,\n ),\n )\n}\n"],
5
- "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,4BAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,oCAAAC,EAAA,qBAAAC,IAAA,eAAAC,EAAAZ,GAeA,IAAAa,EAAoB,sBACpBC,EAAsB,wBAEtBC,EAAmC,mCAEnCC,EAA8B,kBAMvB,SAASR,GAA4B,CAC1C,OAAOG,EAAiB,CAC1B,CAKO,SAASA,GAA2B,CACzC,SAAO,iBACLG,EAAK,KACHD,EAAG,QAAQ,EACK,QAAQ,mBAAmB,EAAE,cAC/C,CACF,CACF,CAKO,SAAST,EAAgBa,EAAyB,CACvD,SAAO,iBACLH,EAAK,KACHH,EAAiB,EACjB,GAAmB,QAAQ,oBAAoB,EAAE,iBAAiB,GAAGM,CAAO,EAC9E,CACF,CACF,CAMO,SAASZ,GAA8B,CAC5C,OAAI,wBACK,iBAAc,oBAAkB,KAElC,iBACLS,EAAK,KACHH,EAAiB,EACjB,GAAmB,QAAQ,oBAAoB,EAAE,iBAAiB,SACpE,CACF,CACF,CAKO,SAASJ,GAA0B,CACxC,SAAO,iBACLO,EAAK,KACHH,EAAiB,EACjB,GAAmB,QAAQ,oBAAoB,EAAE,iBAAiB,GAAmB,QAAQ,oBAAoB,EAAE,mBAAmB,EACxI,CACF,CACF,CAKO,SAAST,EAAqBe,EAAyB,CAC5D,SAAO,iBACLH,EAAK,KACHV,EAAgBa,CAAO,EACP,QAAQ,mBAAmB,EAAE,SAC/C,CACF,CACF,CAKO,SAASd,EAAwBc,EAAyB,CAC/D,SAAO,iBACLH,EAAK,KACHZ,EAAqBe,CAAO,EACZ,QAAQ,mBAAmB,EAAE,aAC/C,CACF,CACF,CAKO,SAASX,GAA0B,CACxC,OAAOF,EACW,QAAQ,oBAAoB,EAAE,mBAChD,CACF,CAKO,SAASK,GAA+B,CAC7C,OAAOL,EACW,QAAQ,oBAAoB,EAAE,wBAChD,CACF,CAKO,SAASM,GAA0C,CACxD,SAAO,iBACLI,EAAK,KACHX,EACkB,QAAQ,oBAAoB,EAAE,wBAChD,EACgB,QAAQ,oBAAoB,EAAE,gBAChD,CACF,CACF",
6
- "names": ["paths_exports", "__export", "getSocketAppCacheDir", "getSocketAppCacheTtlDir", "getSocketAppDir", "getSocketCacacheDir", "getSocketCliDir", "getSocketDlxDir", "getSocketHomePath", "getSocketRegistryDir", "getSocketRegistryGithubCacheDir", "getSocketUserDir", "__toCommonJS", "os", "path", "import_socket_cacache_dir", "import_path", "appName"]
4
+ "sourcesContent": ["/**\n * @fileoverview Path utilities for Socket ecosystem directories.\n * Provides platform-aware path resolution for Socket tools' shared directory structure.\n *\n * Directory Structure:\n * ~/.socket/\n * \u251C\u2500\u2500 _cacache/ # Content-addressable cache for npm packages\n * \u251C\u2500\u2500 _dlx/ # DLX installations (content-addressed by hash)\n * \u2502 \u251C\u2500\u2500 <hash>/ # npm package installs (dlx-package)\n * \u2502 \u2514\u2500\u2500 <hash>/ # binary downloads (dlx-binary)\n * \u251C\u2500\u2500 _socket/ # Socket CLI app directory\n * \u251C\u2500\u2500 _registry/ # Socket Registry app directory\n * \u2514\u2500\u2500 _sfw/ # Socket Firewall app directory\n */\n\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nimport { getHome } from '#env/home'\nimport {\n getSocketCacacheDir as getSocketCacacheDirEnv,\n getSocketDlxDirEnv,\n} from '#env/socket'\nimport { getUserprofile } from '#env/windows'\n\nimport { normalizePath } from './path'\nimport { getPathValue, registerCacheInvalidation } from './paths/rewire'\n\n/**\n * Get the OS home directory.\n * Can be overridden in tests using setPath('homedir', ...) from paths/rewire.\n */\nexport function getOsHomeDir(): string {\n // Always check for overrides - don't cache when using rewire\n return getPathValue('homedir', () => os.homedir())\n}\n\n/**\n * Get the OS temporary directory.\n * Can be overridden in tests using setPath('tmpdir', ...) from paths/rewire.\n */\nexport function getOsTmpDir(): string {\n // Always check for overrides - don't cache when using rewire\n return getPathValue('tmpdir', () => os.tmpdir())\n}\n\n/**\n * Get the Socket home directory (~/.socket).\n * Alias for getSocketUserDir() for consistency across Socket projects.\n */\nexport function getSocketHomePath(): string {\n return getSocketUserDir()\n}\n\nlet _cachedSocketUserDir: string | undefined\n\n/**\n * Get the Socket user directory (~/.socket).\n * Result is memoized for performance.\n */\nexport function getSocketUserDir(): string {\n if (_cachedSocketUserDir === undefined) {\n _cachedSocketUserDir = normalizePath(\n path.join(\n getUserHomeDir(),\n /*@__INLINE__*/ require('#constants/paths').DOT_SOCKET_DIR,\n ),\n )\n }\n return _cachedSocketUserDir\n}\n\n/**\n * Get a Socket app directory (~/.socket/_<appName>).\n */\nexport function getSocketAppDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('#constants/socket').SOCKET_APP_PREFIX}${appName}`,\n ),\n )\n}\n\nlet _cachedSocketCacacheDir: string | undefined\n\n/**\n * Get the Socket cacache directory (~/.socket/_cacache).\n * Can be overridden with SOCKET_CACACHE_DIR environment variable for testing.\n * Result is memoized for performance.\n */\nexport function getSocketCacacheDir(): string {\n if (_cachedSocketCacacheDir === undefined) {\n if (getSocketCacacheDirEnv()) {\n _cachedSocketCacacheDir = normalizePath(\n getSocketCacacheDirEnv() as string,\n )\n } else {\n _cachedSocketCacacheDir = normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('#constants/socket').SOCKET_APP_PREFIX}cacache`,\n ),\n )\n }\n }\n return _cachedSocketCacacheDir\n}\n\n/**\n * Get the Socket DLX directory (~/.socket/_dlx).\n * Can be overridden with SOCKET_DLX_DIR environment variable for testing.\n */\nexport function getSocketDlxDir(): string {\n if (getSocketDlxDirEnv()) {\n return normalizePath(getSocketDlxDirEnv() as string)\n }\n return normalizePath(\n path.join(\n getSocketUserDir(),\n `${/*@__INLINE__*/ require('#constants/socket').SOCKET_APP_PREFIX}${/*@__INLINE__*/ require('#constants/socket').SOCKET_DLX_APP_NAME}`,\n ),\n )\n}\n\n/**\n * Get a Socket app cache directory (~/.socket/_<appName>/cache).\n */\nexport function getSocketAppCacheDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketAppDir(appName),\n /*@__INLINE__*/ require('#constants/paths').CACHE_DIR,\n ),\n )\n}\n\n/**\n * Get a Socket app TTL cache directory (~/.socket/_<appName>/cache/ttl).\n */\nexport function getSocketAppCacheTtlDir(appName: string): string {\n return normalizePath(\n path.join(\n getSocketAppCacheDir(appName),\n /*@__INLINE__*/ require('#constants/paths').CACHE_TTL_DIR,\n ),\n )\n}\n\n/**\n * Get the Socket CLI directory (~/.socket/_socket).\n */\nexport function getSocketCliDir(): string {\n return getSocketAppDir(\n /*@__INLINE__*/ require('#constants/socket').SOCKET_CLI_APP_NAME,\n )\n}\n\n/**\n * Get the Socket Registry directory (~/.socket/_registry).\n */\nexport function getSocketRegistryDir(): string {\n return getSocketAppDir(\n /*@__INLINE__*/ require('#constants/socket').SOCKET_REGISTRY_APP_NAME,\n )\n}\n\n/**\n * Get the Socket Registry GitHub cache directory (~/.socket/_registry/cache/ttl/github).\n */\nexport function getSocketRegistryGithubCacheDir(): string {\n return normalizePath(\n path.join(\n getSocketAppCacheTtlDir(\n /*@__INLINE__*/ require('#constants/socket').SOCKET_REGISTRY_APP_NAME,\n ),\n /*@__INLINE__*/ require('#constants/github').CACHE_GITHUB_DIR,\n ),\n )\n}\n\n/**\n * Get the user's home directory.\n * Uses environment variables directly to support test mocking.\n * Falls back to os.homedir() if env vars not set.\n */\nexport function getUserHomeDir(): string {\n // Try HOME first (Unix)\n const home = getHome()\n if (home) {\n return home\n }\n // Try USERPROFILE (Windows)\n const userProfile = getUserprofile()\n if (userProfile) {\n return userProfile\n }\n // Fallback to os.homedir()\n return getOsHomeDir()\n}\n\n/**\n * Invalidate all cached path values.\n * Called automatically by the paths/rewire module when setPath/clearPath/resetPaths are used.\n *\n * @internal Used for test rewiring\n */\nexport function invalidateCache(): void {\n _cachedSocketUserDir = undefined\n _cachedSocketCacacheDir = undefined\n}\n\n// Register cache invalidation with the rewire module\nregisterCacheInvalidation(invalidateCache)\n"],
5
+ "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,gBAAAC,EAAA,yBAAAC,EAAA,4BAAAC,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,yBAAAC,EAAA,oCAAAC,EAAA,qBAAAC,EAAA,mBAAAC,EAAA,oBAAAC,IAAA,eAAAC,EAAAhB,GAeA,IAAAiB,EAAoB,sBACpBC,EAAsB,wBAEtBC,EAAwB,qBACxBC,EAGO,uBACPC,EAA+B,wBAE/BC,EAA8B,kBAC9BC,EAAwD,0BAMjD,SAASrB,GAAuB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A+B,CAC7C,OAAOL,EACW,QAAQ,mBAAmB,EAAE,wBAC/C,CACF,CAKO,SAASM,GAA0C,CACxD,SAAO,iBACLM,EAAK,KACHb,EACkB,QAAQ,mBAAmB,EAAE,wBAC/C,EACgB,QAAQ,mBAAmB,EAAE,gBAC/C,CACF,CACF,CAOO,SAASS,GAAyB,CAEvC,MAAMc,KAAO,WAAQ,EACrB,GAAIA,EACF,OAAOA,EAGT,MAAMC,KAAc,kBAAe,EACnC,OAAIA,GAIG3B,EAAa,CACtB,CAQO,SAASa,GAAwB,CACtCS,EAAuB,OACvBE,EAA0B,MAC5B,IAGA,6BAA0BX,CAAe",
6
+ "names": ["paths_exports", "__export", "getOsHomeDir", "getOsTmpDir", "getSocketAppCacheDir", "getSocketAppCacheTtlDir", "getSocketAppDir", "getSocketCacacheDir", "getSocketCliDir", "getSocketDlxDir", "getSocketHomePath", "getSocketRegistryDir", "getSocketRegistryGithubCacheDir", "getSocketUserDir", "getUserHomeDir", "invalidateCache", "__toCommonJS", "os", "path", "import_home", "import_socket", "import_windows", "import_path", "import_rewire", "_cachedSocketUserDir", "appName", "_cachedSocketCacacheDir", "getSocketCacacheDirEnv", "home", "userProfile"]
7
7
  }
package/dist/spinner.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var W=Object.create;var S=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(t,o)=>{for(var i in o)S(t,i,{get:o[i],enumerable:!0})},T=(t,o,i,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of V(o))!G.call(t,d)&&d!==i&&S(t,d,{get:()=>o[d],enumerable:!(s=q(o,d))||s.enumerable});return t};var L=(t,o,i)=>(i=t!=null?W(Y(t)):{},T(o||!t||!t.__esModule?S(i,"default",{value:t,enumerable:!0}):i,t)),M=t=>T(S({},"__esModule",{value:!0}),t);var J={};v(J,{Spinner:()=>C,ciSpinner:()=>D,getCliSpinners:()=>$,getDefaultSpinner:()=>E,spinner:()=>N,withSpinner:()=>H,withSpinnerRestore:()=>K,withSpinnerSync:()=>U});module.exports=M(J);var I=require("#env/ci"),B=require("./effects/pulse-frames"),u=require("./effects/text-shimmer"),k=L(require("./external/@socketregistry/yocto-spinner")),P=require("./objects"),b=require("./strings");const z={__proto__:null,black:[0,0,0],blue:[0,0,255],blueBright:[100,149,237],cyan:[0,255,255],cyanBright:[0,255,255],gray:[128,128,128],green:[0,128,0],greenBright:[0,255,0],magenta:[255,0,255],magentaBright:[255,105,180],red:[255,0,0],redBright:[255,69,0],white:[255,255,255],whiteBright:[255,255,255],yellow:[255,255,0],yellowBright:[255,255,153]};function x(t){return Array.isArray(t)}function y(t){return x(t)?t:z[t]}const D={frames:[""],interval:2147483647};function w(t){return{__proto__:null,configurable:!0,value:t,writable:!0}}function R(t){return typeof t=="string"?t.trimStart():""}function F(t){const{current:o,total:i,unit:s}=t,d=Math.round(o/i*100),n=j(d),e=s?`${o}/${i} ${s}`:`${o}/${i}`;return`${n} ${d}% (${e})`}function j(t,o=20){const i=Math.round(t/100*o),s=o-i,d="\u2588".repeat(i)+"\u2591".repeat(s);return require("./external/yoctocolors-cjs").cyan(d)}let m;function $(t){return m===void 0&&(m={__proto__:null,...(0,k.default)({}).constructor.spinners,socket:(0,B.generateSocketSpinnerFrames)()}),typeof t=="string"&&m?(0,P.hasOwn)(m,t)?m[t]:void 0:m}let g,A;function C(t){if(g===void 0){const s=(0,k.default)({}).constructor;g=class extends s{#o="";#i="";#t;#n;#e;constructor(n){const e={__proto__:null,...n},r=e.color??[140,82,255];if(x(r)&&(r.length!==3||!r.every(p=>typeof p=="number"&&p>=0&&p<=255)))throw new TypeError("RGB color must be an array of 3 numbers between 0 and 255");const a=y(r);let h;if(e.shimmer){let p,f,c=.3333333333333333;if(typeof e.shimmer=="string")p=e.shimmer;else{const l={__proto__:null,...e.shimmer};p=l.dir??u.DIR_LTR,f=l.color??u.COLOR_INHERIT,c=l.speed??1/3}h={__proto__:null,color:f===void 0?u.COLOR_INHERIT:f,currentDir:u.DIR_LTR,mode:p,speed:c,step:0}}super({signal:require("#constants/process").getAbortSignal(),...e,color:a,onRenderFrame:(p,f,c)=>{const O=(0,b.stringWidth)(p)===1?" ":" ";return p?`${c(p)}${O}${f}`:f},onFrameUpdate:h?()=>{this.#o&&(super.text=this.#p())}:void 0}),this.#n=h,this.#e=h}get color(){const n=super.color;return x(n)?n:y(n)}set color(n){super.color=x(n)?n:y(n)}#r(n,e){let r,a=e.at(0);typeof a=="string"?r=e.slice(1):(r=e,a="");const h=this.isSpinning,p=R(a);super[n](p);const{incLogCallCountSymbol:f,lastWasBlankSymbol:c,logger:l}=require("./logger.js");return n==="stop"?h&&p&&(l[c]((0,b.isBlankString)(p)),l[f]()):(l[c](!1),l[f]()),r.length&&(l.log(...r),l[c](!1)),this}#p(){let n=this.#o;if(this.#t){const e=F(this.#t);n=n?`${n} ${e}`:e}if(n&&this.#n){let e;this.#n.color===u.COLOR_INHERIT?e=this.color:Array.isArray(this.#n.color[0])?e=this.#n.color:e=y(this.#n.color),n=(0,u.applyShimmer)(n,this.#n,{color:e,direction:this.#n.mode})}return this.#i&&n&&(n=this.#i+n),n}#u(n,e){let r=e.at(0),a;typeof r=="string"?a=e.slice(1):(a=e,r="");const{LOG_SYMBOLS:h,logger:p}=require("./logger.js");return p.error(`${h[n]} ${r}`,...a),this}#s(){super.text=this.#p()}debug(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#u("info",[n,...e]):this}debugAndStop(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#r("info",[n,...e]):this}dedent(n){if(n===0)this.#i="";else{const e=n??2,r=Math.max(0,this.#i.length-e);this.#i=this.#i.slice(0,r)}return this.#s(),this}done(n,...e){return this.#u("success",[n,...e])}doneAndStop(n,...e){return this.#r("success",[n,...e])}fail(n,...e){return this.#u("fail",[n,...e])}failAndStop(n,...e){return this.#r("error",[n,...e])}indent(n){if(n===0)this.#i="";else{const e=n??2;this.#i+=" ".repeat(e)}return this.#s(),this}info(n,...e){return this.#u("info",[n,...e])}infoAndStop(n,...e){return this.#r("info",[n,...e])}log(...n){const{logger:e}=require("./logger.js");return e.log(...n),this}logAndStop(n,...e){return this.#r("stop",[n,...e])}progress=(n,e,r)=>(this.#t={__proto__:null,current:n,total:e,...r?{unit:r}:{}},this.#s(),this);progressStep(n=1){if(this.#t){const e=this.#t.current+n;this.#t={__proto__:null,current:Math.max(0,Math.min(e,this.#t.total)),total:this.#t.total,...this.#t.unit?{unit:this.#t.unit}:{}},this.#s()}return this}start(...n){if(n.length){const e=n.at(0),r=R(e);r?this.#o=r:(this.#o="",super.text="")}return this.#s(),this.#r("start",n)}step(n,...e){const{logger:r}=require("./logger.js");return typeof n=="string"&&(r.error(""),r.error(n,...e)),this}substep(n,...e){if(typeof n=="string"){const{logger:r}=require("./logger.js");r.error(` ${n}`,...e)}return this}stop(...n){this.#o="",this.#t=void 0,this.#n&&(this.#n.currentDir=u.DIR_LTR,this.#n.step=0);const e=this.#r("stop",n);return super.text="",e}success(n,...e){return this.#u("success",[n,...e])}successAndStop(n,...e){return this.#r("success",[n,...e])}text(n){return arguments.length===0?this.#o:(this.#o=n??"",this.#s(),this)}warn(n,...e){return this.#u("warn",[n,...e])}warnAndStop(n,...e){return this.#r("warning",[n,...e])}shimmer(n){if(n===!1)this.#n=void 0;else if(n===!0)this.#e?this.#n={...this.#e}:(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:u.DIR_LTR,speed:1/3,step:0},this.#e=this.#n);else if(typeof n=="string")this.#n?(this.#n={...this.#n,mode:n},this.#e=this.#n):this.#e?(this.#n={...this.#e,mode:n},this.#e=this.#n):(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:n,speed:1/3,step:0},this.#e=this.#n);else if(n&&typeof n=="object"){const e={__proto__:null,...n};this.#n?(this.#n={...this.#n,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):this.#e?(this.#n={...this.#e,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):(this.#n={color:e.color??u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:e.dir??u.DIR_LTR,speed:e.speed??1/3,step:0},this.#e=this.#n)}return this.#s(),this}},Object.defineProperties(g.prototype,{error:w(g.prototype.fail),errorAndStop:w(g.prototype.failAndStop),warning:w(g.prototype.warn),warningAndStop:w(g.prototype.warnAndStop)}),A=I.CI?D:$("socket")}return new g({spinner:A,...t})}let _;function E(){return _===void 0&&(_=C()),_}const N=(()=>{let t;return new Proxy({},{get(o,i){t===void 0&&(t=C());const s=t[i];return typeof s=="function"?s.bind(t):s}})})();async function H(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return await i();s.start(o);try{return await i()}finally{s.stop()}}async function K(t){const{operation:o,spinner:i,wasSpinning:s}={__proto__:null,...t};try{return await o()}finally{i&&s&&i.start()}}function U(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return i();s.start(o);try{return i()}finally{s.stop()}}0&&(module.exports={Spinner,ciSpinner,getCliSpinners,getDefaultSpinner,spinner,withSpinner,withSpinnerRestore,withSpinnerSync});
2
+ var W=Object.create;var S=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var v=(t,o)=>{for(var i in o)S(t,i,{get:o[i],enumerable:!0})},T=(t,o,i,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of V(o))!G.call(t,d)&&d!==i&&S(t,d,{get:()=>o[d],enumerable:!(s=q(o,d))||s.enumerable});return t};var L=(t,o,i)=>(i=t!=null?W(Y(t)):{},T(o||!t||!t.__esModule?S(i,"default",{value:t,enumerable:!0}):i,t)),M=t=>T(S({},"__esModule",{value:!0}),t);var J={};v(J,{Spinner:()=>C,ciSpinner:()=>D,getCliSpinners:()=>$,getDefaultSpinner:()=>E,spinner:()=>N,withSpinner:()=>H,withSpinnerRestore:()=>K,withSpinnerSync:()=>U});module.exports=M(J);var I=require("#env/ci"),B=require("./effects/pulse-frames"),u=require("./effects/text-shimmer"),k=L(require("./external/@socketregistry/yocto-spinner")),P=require("./objects"),b=require("./strings");const z={__proto__:null,black:[0,0,0],blue:[0,0,255],blueBright:[100,149,237],cyan:[0,255,255],cyanBright:[0,255,255],gray:[128,128,128],green:[0,128,0],greenBright:[0,255,0],magenta:[255,0,255],magentaBright:[255,105,180],red:[255,0,0],redBright:[255,69,0],white:[255,255,255],whiteBright:[255,255,255],yellow:[255,255,0],yellowBright:[255,255,153]};function x(t){return Array.isArray(t)}function y(t){return x(t)?t:z[t]}const D={frames:[""],interval:2147483647};function w(t){return{__proto__:null,configurable:!0,value:t,writable:!0}}function R(t){return typeof t=="string"?t.trimStart():""}function F(t){const{current:o,total:i,unit:s}=t,d=Math.round(o/i*100),n=j(d),e=s?`${o}/${i} ${s}`:`${o}/${i}`;return`${n} ${d}% (${e})`}function j(t,o=20){const i=Math.round(t/100*o),s=o-i,d="\u2588".repeat(i)+"\u2591".repeat(s);return require("./external/yoctocolors-cjs").cyan(d)}let m;function $(t){return m===void 0&&(m={__proto__:null,...(0,k.default)({}).constructor.spinners,socket:(0,B.generateSocketSpinnerFrames)()}),typeof t=="string"&&m?(0,P.hasOwn)(m,t)?m[t]:void 0:m}let g,A;function C(t){if(g===void 0){const s=(0,k.default)({}).constructor;g=class extends s{#o="";#i="";#t;#n;#e;constructor(n){const e={__proto__:null,...n},r=e.color??[140,82,255];if(x(r)&&(r.length!==3||!r.every(p=>typeof p=="number"&&p>=0&&p<=255)))throw new TypeError("RGB color must be an array of 3 numbers between 0 and 255");const a=y(r);let h;if(e.shimmer){let p,f,c=.3333333333333333;if(typeof e.shimmer=="string")p=e.shimmer;else{const l={__proto__:null,...e.shimmer};p=l.dir??u.DIR_LTR,f=l.color??u.COLOR_INHERIT,c=l.speed??1/3}h={__proto__:null,color:f===void 0?u.COLOR_INHERIT:f,currentDir:u.DIR_LTR,mode:p,speed:c,step:0}}super({signal:require("#constants/process").getAbortSignal(),...e,color:a,onRenderFrame:(p,f,c)=>{const O=(0,b.stringWidth)(p)===1?" ":" ";return p?`${c(p)}${O}${f}`:f},onFrameUpdate:h?()=>{this.#o&&(super.text=this.#p())}:void 0}),this.#n=h,this.#e=h}get color(){const n=super.color;return x(n)?n:y(n)}set color(n){super.color=x(n)?n:y(n)}#r(n,e){let r,a=e.at(0);typeof a=="string"?r=e.slice(1):(r=e,a="");const h=this.isSpinning,p=R(a);super[n](p);const{incLogCallCountSymbol:f,lastWasBlankSymbol:c,logger:l}=require("./logger.js");return n==="stop"?h&&p&&(l[c]((0,b.isBlankString)(p)),l[f]()):(l[c](!1),l[f]()),r.length&&(l.log(...r),l[c](!1)),this}#p(){let n=this.#o;if(this.#t){const e=F(this.#t);n=n?`${n} ${e}`:e}if(n&&this.#n){let e;this.#n.color===u.COLOR_INHERIT?e=this.color:Array.isArray(this.#n.color[0])?e=this.#n.color:e=y(this.#n.color),n=(0,u.applyShimmer)(n,this.#n,{color:e,direction:this.#n.mode})}return this.#i&&n&&(n=this.#i+n),n}#u(n,e){let r=e.at(0),a;typeof r=="string"?a=e.slice(1):(a=e,r="");const{LOG_SYMBOLS:h,logger:p}=require("./logger.js");return p.error(`${h[n]} ${r}`,...a),this}#s(){super.text=this.#p()}debug(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#u("info",[n,...e]):this}debugAndStop(n,...e){const{isDebug:r}=require("./debug.js");return r()?this.#r("info",[n,...e]):this}dedent(n){if(n===0)this.#i="";else{const e=n??2,r=Math.max(0,this.#i.length-e);this.#i=this.#i.slice(0,r)}return this.#s(),this}done(n,...e){return this.#u("success",[n,...e])}doneAndStop(n,...e){return this.#r("success",[n,...e])}fail(n,...e){return this.#u("fail",[n,...e])}failAndStop(n,...e){return this.#r("error",[n,...e])}indent(n){if(n===0)this.#i="";else{const e=n??2;this.#i+=" ".repeat(e)}return this.#s(),this}info(n,...e){return this.#u("info",[n,...e])}infoAndStop(n,...e){return this.#r("info",[n,...e])}log(...n){const{logger:e}=require("./logger.js");return e.log(...n),this}logAndStop(n,...e){return this.#r("stop",[n,...e])}progress=(n,e,r)=>(this.#t={__proto__:null,current:n,total:e,...r?{unit:r}:{}},this.#s(),this);progressStep(n=1){if(this.#t){const e=this.#t.current+n;this.#t={__proto__:null,current:Math.max(0,Math.min(e,this.#t.total)),total:this.#t.total,...this.#t.unit?{unit:this.#t.unit}:{}},this.#s()}return this}start(...n){if(n.length){const e=n.at(0),r=R(e);r?this.#o=r:(this.#o="",super.text="")}return this.#s(),this.#r("start",n)}step(n,...e){const{logger:r}=require("./logger.js");return typeof n=="string"&&(r.error(""),r.error(n,...e)),this}substep(n,...e){if(typeof n=="string"){const{logger:r}=require("./logger.js");r.error(` ${n}`,...e)}return this}stop(...n){this.#o="",this.#t=void 0,this.#n&&(this.#n.currentDir=u.DIR_LTR,this.#n.step=0);const e=this.#r("stop",n);return super.text="",e}success(n,...e){return this.#u("success",[n,...e])}successAndStop(n,...e){return this.#r("success",[n,...e])}text(n){return arguments.length===0?this.#o:(this.#o=n??"",this.#s(),this)}warn(n,...e){return this.#u("warn",[n,...e])}warnAndStop(n,...e){return this.#r("warning",[n,...e])}shimmer(n){if(n===!1)this.#n=void 0;else if(n===!0)this.#e?this.#n={...this.#e}:(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:u.DIR_LTR,speed:1/3,step:0},this.#e=this.#n);else if(typeof n=="string")this.#n?(this.#n={...this.#n,mode:n},this.#e=this.#n):this.#e?(this.#n={...this.#e,mode:n},this.#e=this.#n):(this.#n={color:u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:n,speed:1/3,step:0},this.#e=this.#n);else if(n&&typeof n=="object"){const e={__proto__:null,...n};this.#n?(this.#n={...this.#n,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):this.#e?(this.#n={...this.#e,...e.color!==void 0?{color:e.color}:{},...e.dir!==void 0?{mode:e.dir}:{},...e.speed!==void 0?{speed:e.speed}:{}},this.#e=this.#n):(this.#n={color:e.color??u.COLOR_INHERIT,currentDir:u.DIR_LTR,mode:e.dir??u.DIR_LTR,speed:e.speed??1/3,step:0},this.#e=this.#n)}return this.#s(),this}},Object.defineProperties(g.prototype,{error:w(g.prototype.fail),errorAndStop:w(g.prototype.failAndStop),warning:w(g.prototype.warn),warningAndStop:w(g.prototype.warnAndStop)}),A=(0,I.getCI)()?D:$("socket")}return new g({spinner:A,...t})}let _;function E(){return _===void 0&&(_=C()),_}const N=(()=>{let t;return new Proxy({},{get(o,i){t===void 0&&(t=C());const s=t[i];return typeof s=="function"?s.bind(t):s}})})();async function H(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return await i();s.start(o);try{return await i()}finally{s.stop()}}async function K(t){const{operation:o,spinner:i,wasSpinning:s}={__proto__:null,...t};try{return await o()}finally{i&&s&&i.start()}}function U(t){const{message:o,operation:i,spinner:s}={__proto__:null,...t};if(!s)return i();s.start(o);try{return i()}finally{s.stop()}}0&&(module.exports={Spinner,ciSpinner,getCliSpinners,getDefaultSpinner,spinner,withSpinner,withSpinnerRestore,withSpinnerSync});
3
3
  //# sourceMappingURL=spinner.js.map