@socketsecurity/lib 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/abort.js +1 -60
  3. package/dist/abort.js.map +2 -2
  4. package/dist/agent.js +1 -289
  5. package/dist/agent.js.map +2 -2
  6. package/dist/ansi.js +1 -60
  7. package/dist/ansi.js.map +2 -2
  8. package/dist/argv/flags.js +1 -282
  9. package/dist/argv/flags.js.map +2 -2
  10. package/dist/argv/parse.js +1 -171
  11. package/dist/argv/parse.js.map +2 -2
  12. package/dist/arrays.js +1 -85
  13. package/dist/arrays.js.map +2 -2
  14. package/dist/bin.js +1 -402
  15. package/dist/bin.js.map +2 -2
  16. package/dist/cacache.js +1 -137
  17. package/dist/cacache.js.map +2 -2
  18. package/dist/cache-with-ttl.js +1 -223
  19. package/dist/cache-with-ttl.js.map +2 -2
  20. package/dist/constants/agents.js +1 -126
  21. package/dist/constants/agents.js.map +2 -2
  22. package/dist/constants/core.js +2 -57
  23. package/dist/constants/core.js.map +2 -2
  24. package/dist/constants/encoding.js +1 -48
  25. package/dist/constants/encoding.js.map +2 -2
  26. package/dist/constants/github.js +1 -30
  27. package/dist/constants/github.js.map +2 -2
  28. package/dist/constants/licenses.js +1 -66
  29. package/dist/constants/licenses.js.map +2 -2
  30. package/dist/constants/node.js +1 -171
  31. package/dist/constants/node.js.map +2 -2
  32. package/dist/constants/packages.js +1 -128
  33. package/dist/constants/packages.js.map +2 -2
  34. package/dist/constants/paths.js +1 -150
  35. package/dist/constants/paths.js.map +2 -2
  36. package/dist/constants/platform.js +1 -41
  37. package/dist/constants/platform.js.map +2 -2
  38. package/dist/constants/process.js +1 -52
  39. package/dist/constants/process.js.map +2 -2
  40. package/dist/constants/socket.js +1 -81
  41. package/dist/constants/socket.js.map +2 -2
  42. package/dist/constants/testing.js +1 -36
  43. package/dist/constants/testing.js.map +2 -2
  44. package/dist/constants/time.js +1 -39
  45. package/dist/constants/time.js.map +2 -2
  46. package/dist/constants/typescript.js +1 -54
  47. package/dist/constants/typescript.js.map +2 -2
  48. package/dist/cover/code.js +1 -135
  49. package/dist/cover/code.js.map +2 -2
  50. package/dist/cover/formatters.js +11 -101
  51. package/dist/cover/formatters.js.map +2 -2
  52. package/dist/cover/type.js +1 -63
  53. package/dist/cover/type.js.map +2 -2
  54. package/dist/cover/types.js +1 -15
  55. package/dist/cover/types.js.map +2 -2
  56. package/dist/debug.js +2 -343
  57. package/dist/debug.js.map +2 -2
  58. package/dist/dlx-binary.js +1 -259
  59. package/dist/dlx-binary.js.map +2 -2
  60. package/dist/dlx-package.js +1 -149
  61. package/dist/dlx-package.js.map +2 -2
  62. package/dist/dlx.js +1 -166
  63. package/dist/dlx.js.map +2 -2
  64. package/dist/download-lock.js +1 -137
  65. package/dist/download-lock.js.map +2 -2
  66. package/dist/effects/pulse-frames.js +1 -64
  67. package/dist/effects/pulse-frames.js.map +2 -2
  68. package/dist/effects/text-shimmer.js +1 -174
  69. package/dist/effects/text-shimmer.js.map +2 -2
  70. package/dist/effects/types.js +1 -15
  71. package/dist/effects/types.js.map +2 -2
  72. package/dist/effects/ultra.js +1 -61
  73. package/dist/effects/ultra.js.map +2 -2
  74. package/dist/env/appdata.js +1 -28
  75. package/dist/env/appdata.js.map +2 -2
  76. package/dist/env/ci.js +1 -29
  77. package/dist/env/ci.js.map +2 -2
  78. package/dist/env/comspec.js +1 -28
  79. package/dist/env/comspec.js.map +2 -2
  80. package/dist/env/debug.js +1 -28
  81. package/dist/env/debug.js.map +2 -2
  82. package/dist/env/getters.js +1 -281
  83. package/dist/env/getters.js.map +2 -2
  84. package/dist/env/github-api-url.js +1 -28
  85. package/dist/env/github-api-url.js.map +2 -2
  86. package/dist/env/github-base-ref.js +1 -28
  87. package/dist/env/github-base-ref.js.map +2 -2
  88. package/dist/env/github-ref-name.js +1 -28
  89. package/dist/env/github-ref-name.js.map +2 -2
  90. package/dist/env/github-ref-type.js +1 -28
  91. package/dist/env/github-ref-type.js.map +2 -2
  92. package/dist/env/github-repository.js +1 -28
  93. package/dist/env/github-repository.js.map +2 -2
  94. package/dist/env/github-server-url.js +1 -28
  95. package/dist/env/github-server-url.js.map +2 -2
  96. package/dist/env/github-token.js +1 -28
  97. package/dist/env/github-token.js.map +2 -2
  98. package/dist/env/helpers.js +1 -47
  99. package/dist/env/helpers.js.map +2 -2
  100. package/dist/env/home.js +1 -28
  101. package/dist/env/home.js.map +2 -2
  102. package/dist/env/jest-worker-id.js +1 -28
  103. package/dist/env/jest-worker-id.js.map +2 -2
  104. package/dist/env/lang.js +1 -28
  105. package/dist/env/lang.js.map +2 -2
  106. package/dist/env/lc-all.js +1 -28
  107. package/dist/env/lc-all.js.map +2 -2
  108. package/dist/env/lc-messages.js +1 -28
  109. package/dist/env/lc-messages.js.map +2 -2
  110. package/dist/env/localappdata.js +1 -28
  111. package/dist/env/localappdata.js.map +2 -2
  112. package/dist/env/node-auth-token.js +1 -28
  113. package/dist/env/node-auth-token.js.map +2 -2
  114. package/dist/env/node-env.js +1 -28
  115. package/dist/env/node-env.js.map +2 -2
  116. package/dist/env/npm-config-registry.js +1 -28
  117. package/dist/env/npm-config-registry.js.map +2 -2
  118. package/dist/env/npm-config-user-agent.js +1 -28
  119. package/dist/env/npm-config-user-agent.js.map +2 -2
  120. package/dist/env/npm-lifecycle-event.js +1 -28
  121. package/dist/env/npm-lifecycle-event.js.map +2 -2
  122. package/dist/env/npm-registry.js +1 -28
  123. package/dist/env/npm-registry.js.map +2 -2
  124. package/dist/env/npm-token.js +1 -28
  125. package/dist/env/npm-token.js.map +2 -2
  126. package/dist/env/path.js +1 -28
  127. package/dist/env/path.js.map +2 -2
  128. package/dist/env/pre-commit.js +1 -29
  129. package/dist/env/pre-commit.js.map +2 -2
  130. package/dist/env/shell.js +1 -28
  131. package/dist/env/shell.js.map +2 -2
  132. package/dist/env/socket-accept-risks.js +1 -29
  133. package/dist/env/socket-accept-risks.js.map +2 -2
  134. package/dist/env/socket-api-base-url.js +1 -28
  135. package/dist/env/socket-api-base-url.js.map +2 -2
  136. package/dist/env/socket-api-proxy.js +1 -28
  137. package/dist/env/socket-api-proxy.js.map +2 -2
  138. package/dist/env/socket-api-timeout.js +1 -29
  139. package/dist/env/socket-api-timeout.js.map +2 -2
  140. package/dist/env/socket-api-token.js +1 -28
  141. package/dist/env/socket-api-token.js.map +2 -2
  142. package/dist/env/socket-cacache-dir.js +1 -28
  143. package/dist/env/socket-cacache-dir.js.map +2 -2
  144. package/dist/env/socket-cli-accept-risks.js +1 -31
  145. package/dist/env/socket-cli-accept-risks.js.map +2 -2
  146. package/dist/env/socket-cli-api-base-url.js +1 -28
  147. package/dist/env/socket-cli-api-base-url.js.map +2 -2
  148. package/dist/env/socket-cli-api-proxy.js +1 -28
  149. package/dist/env/socket-cli-api-proxy.js.map +2 -2
  150. package/dist/env/socket-cli-api-timeout.js +1 -29
  151. package/dist/env/socket-cli-api-timeout.js.map +2 -2
  152. package/dist/env/socket-cli-api-token.js +1 -28
  153. package/dist/env/socket-cli-api-token.js.map +2 -2
  154. package/dist/env/socket-cli-config.js +1 -28
  155. package/dist/env/socket-cli-config.js.map +2 -2
  156. package/dist/env/socket-cli-fix.js +1 -28
  157. package/dist/env/socket-cli-fix.js.map +2 -2
  158. package/dist/env/socket-cli-no-api-token.js +1 -31
  159. package/dist/env/socket-cli-no-api-token.js.map +2 -2
  160. package/dist/env/socket-cli-optimize.js +1 -29
  161. package/dist/env/socket-cli-optimize.js.map +2 -2
  162. package/dist/env/socket-cli-org-slug.js +1 -28
  163. package/dist/env/socket-cli-org-slug.js.map +2 -2
  164. package/dist/env/socket-cli-shadow-accept-risks.js +1 -31
  165. package/dist/env/socket-cli-shadow-accept-risks.js.map +2 -2
  166. package/dist/env/socket-cli-shadow-api-token.js +1 -28
  167. package/dist/env/socket-cli-shadow-api-token.js.map +2 -2
  168. package/dist/env/socket-cli-shadow-bin.js +1 -28
  169. package/dist/env/socket-cli-shadow-bin.js.map +2 -2
  170. package/dist/env/socket-cli-shadow-progress.js +1 -31
  171. package/dist/env/socket-cli-shadow-progress.js.map +2 -2
  172. package/dist/env/socket-cli-shadow-silent.js +1 -31
  173. package/dist/env/socket-cli-shadow-silent.js.map +2 -2
  174. package/dist/env/socket-cli-view-all-risks.js +1 -31
  175. package/dist/env/socket-cli-view-all-risks.js.map +2 -2
  176. package/dist/env/socket-config.js +1 -28
  177. package/dist/env/socket-config.js.map +2 -2
  178. package/dist/env/socket-debug.js +1 -28
  179. package/dist/env/socket-debug.js.map +2 -2
  180. package/dist/env/socket-home.js +1 -28
  181. package/dist/env/socket-home.js.map +2 -2
  182. package/dist/env/socket-no-api-token.js +1 -29
  183. package/dist/env/socket-no-api-token.js.map +2 -2
  184. package/dist/env/socket-npm-registry.js +1 -28
  185. package/dist/env/socket-npm-registry.js.map +2 -2
  186. package/dist/env/socket-org-slug.js +1 -28
  187. package/dist/env/socket-org-slug.js.map +2 -2
  188. package/dist/env/socket-registry-url.js +1 -28
  189. package/dist/env/socket-registry-url.js.map +2 -2
  190. package/dist/env/socket-view-all-risks.js +1 -29
  191. package/dist/env/socket-view-all-risks.js.map +2 -2
  192. package/dist/env/temp.js +1 -28
  193. package/dist/env/temp.js.map +2 -2
  194. package/dist/env/term.js +1 -28
  195. package/dist/env/term.js.map +2 -2
  196. package/dist/env/tmp.js +1 -28
  197. package/dist/env/tmp.js.map +2 -2
  198. package/dist/env/tmpdir.js +1 -28
  199. package/dist/env/tmpdir.js.map +2 -2
  200. package/dist/env/userprofile.js +1 -28
  201. package/dist/env/userprofile.js.map +2 -2
  202. package/dist/env/vitest.js +1 -29
  203. package/dist/env/vitest.js.map +2 -2
  204. package/dist/env/xdg-cache-home.js +1 -28
  205. package/dist/env/xdg-cache-home.js.map +2 -2
  206. package/dist/env/xdg-config-home.js +1 -28
  207. package/dist/env/xdg-config-home.js.map +2 -2
  208. package/dist/env/xdg-data-home.js +1 -28
  209. package/dist/env/xdg-data-home.js.map +2 -2
  210. package/dist/env.js +1 -61
  211. package/dist/env.js.map +2 -2
  212. package/dist/fs.js +3 -626
  213. package/dist/fs.js.map +2 -2
  214. package/dist/functions.js +1 -68
  215. package/dist/functions.js.map +2 -2
  216. package/dist/git.js +2 -320
  217. package/dist/git.js.map +2 -2
  218. package/dist/github.js +1 -201
  219. package/dist/github.js.map +2 -2
  220. package/dist/globs.js +1 -152
  221. package/dist/globs.js.map +2 -2
  222. package/dist/http-request.js +1 -313
  223. package/dist/http-request.js.map +2 -2
  224. package/dist/index.js +1 -62
  225. package/dist/index.js.map +2 -2
  226. package/dist/ipc.js +1 -232
  227. package/dist/ipc.js.map +2 -2
  228. package/dist/json.js +1 -73
  229. package/dist/json.js.map +2 -2
  230. package/dist/logger.js +1 -1254
  231. package/dist/logger.js.map +2 -2
  232. package/dist/maintained-node-versions.js +1 -35
  233. package/dist/maintained-node-versions.js.map +2 -2
  234. package/dist/memoization.js +1 -210
  235. package/dist/memoization.js.map +2 -2
  236. package/dist/objects.d.ts +0 -3
  237. package/dist/objects.js +1 -319
  238. package/dist/objects.js.map +3 -3
  239. package/dist/packages/editable.js +9 -356
  240. package/dist/packages/editable.js.map +2 -2
  241. package/dist/packages/exports.js +1 -162
  242. package/dist/packages/exports.js.map +2 -2
  243. package/dist/packages/isolation.js +1 -195
  244. package/dist/packages/isolation.js.map +2 -2
  245. package/dist/packages/licenses.js +1 -214
  246. package/dist/packages/licenses.js.map +2 -2
  247. package/dist/packages/manifest.js +1 -190
  248. package/dist/packages/manifest.js.map +2 -2
  249. package/dist/packages/normalize.js +1 -120
  250. package/dist/packages/normalize.js.map +2 -2
  251. package/dist/packages/operations.js +1 -304
  252. package/dist/packages/operations.js.map +2 -2
  253. package/dist/packages/paths.js +1 -53
  254. package/dist/packages/paths.js.map +2 -2
  255. package/dist/packages/provenance.js +1 -178
  256. package/dist/packages/provenance.js.map +2 -2
  257. package/dist/packages/registry.js +1 -28
  258. package/dist/packages/registry.js.map +2 -2
  259. package/dist/packages/specs.js +1 -83
  260. package/dist/packages/specs.js.map +2 -2
  261. package/dist/packages/validation.js +1 -51
  262. package/dist/packages/validation.js.map +2 -2
  263. package/dist/packages.js +1 -129
  264. package/dist/packages.js.map +2 -2
  265. package/dist/path.js +1 -448
  266. package/dist/path.js.map +2 -2
  267. package/dist/paths.js +1 -143
  268. package/dist/paths.js.map +2 -2
  269. package/dist/performance.js +15 -216
  270. package/dist/performance.js.map +2 -2
  271. package/dist/promise-queue.js +1 -109
  272. package/dist/promise-queue.js.map +2 -2
  273. package/dist/promises.js +1 -269
  274. package/dist/promises.js.map +2 -2
  275. package/dist/prompts.js +1 -58
  276. package/dist/prompts.js.map +2 -2
  277. package/dist/regexps.js +1 -30
  278. package/dist/regexps.js.map +2 -2
  279. package/dist/sea.js +1 -44
  280. package/dist/sea.js.map +2 -2
  281. package/dist/shadow.js +1 -58
  282. package/dist/shadow.js.map +2 -2
  283. package/dist/signal-exit.js +1 -248
  284. package/dist/signal-exit.js.map +2 -2
  285. package/dist/sorts.js +1 -94
  286. package/dist/sorts.js.map +2 -2
  287. package/dist/spawn.js +1 -199
  288. package/dist/spawn.js.map +2 -2
  289. package/dist/spinner.js +1 -865
  290. package/dist/spinner.js.map +2 -2
  291. package/dist/ssri.js +1 -71
  292. package/dist/ssri.js.map +2 -2
  293. package/dist/stdio/clear.js +1 -82
  294. package/dist/stdio/clear.js.map +2 -2
  295. package/dist/stdio/divider.js +3 -89
  296. package/dist/stdio/divider.js.map +2 -2
  297. package/dist/stdio/footer.js +2 -94
  298. package/dist/stdio/footer.js.map +2 -2
  299. package/dist/stdio/header.js +2 -100
  300. package/dist/stdio/header.js.map +2 -2
  301. package/dist/stdio/mask.js +5 -206
  302. package/dist/stdio/mask.js.map +2 -2
  303. package/dist/stdio/progress.js +2 -209
  304. package/dist/stdio/progress.js.map +2 -2
  305. package/dist/stdio/prompts.js +1 -88
  306. package/dist/stdio/prompts.js.map +2 -2
  307. package/dist/stdio/stderr.js +2 -89
  308. package/dist/stdio/stderr.js.map +2 -2
  309. package/dist/stdio/stdout.js +2 -103
  310. package/dist/stdio/stdout.js.map +2 -2
  311. package/dist/streams.js +1 -78
  312. package/dist/streams.js.map +2 -2
  313. package/dist/strings.js +3 -251
  314. package/dist/strings.js.map +2 -2
  315. package/dist/suppress-warnings.js +1 -98
  316. package/dist/suppress-warnings.js.map +2 -2
  317. package/dist/tables.js +3 -128
  318. package/dist/tables.js.map +2 -2
  319. package/dist/temporary-executor.js +1 -53
  320. package/dist/temporary-executor.js.map +2 -2
  321. package/dist/types.js +1 -72
  322. package/dist/types.js.map +2 -2
  323. package/dist/url.js +1 -142
  324. package/dist/url.js.map +2 -2
  325. package/dist/utils/get-ipc.js +1 -58
  326. package/dist/utils/get-ipc.js.map +2 -2
  327. package/dist/validation/json-parser.js +1 -127
  328. package/dist/validation/json-parser.js.map +2 -2
  329. package/dist/validation/types.js +1 -15
  330. package/dist/validation/types.js.map +2 -2
  331. package/dist/versions.js +1 -153
  332. package/dist/versions.js.map +2 -2
  333. package/dist/words.js +1 -50
  334. package/dist/words.js.map +2 -2
  335. package/dist/zod.js +1 -27
  336. package/dist/zod.js.map +2 -2
  337. package/package.json +1 -1
package/dist/path.js CHANGED
@@ -1,450 +1,3 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var path_exports = {};
20
- __export(path_exports, {
21
- isAbsolute: () => isAbsolute,
22
- isNodeModules: () => isNodeModules,
23
- isPath: () => isPath,
24
- isRelative: () => isRelative,
25
- normalizePath: () => normalizePath,
26
- pathLikeToString: () => pathLikeToString,
27
- relativeResolve: () => relativeResolve,
28
- splitPath: () => splitPath,
29
- trimLeadingDotSlash: () => trimLeadingDotSlash
30
- });
31
- module.exports = __toCommonJS(path_exports);
32
- var import_platform = require("#constants/platform");
33
- var import_strings = require("./strings");
34
- const CHAR_BACKWARD_SLASH = 92;
35
- const CHAR_COLON = 58;
36
- const CHAR_FORWARD_SLASH = 47;
37
- const CHAR_LOWERCASE_A = 97;
38
- const CHAR_LOWERCASE_Z = 122;
39
- const CHAR_UPPERCASE_A = 65;
40
- const CHAR_UPPERCASE_Z = 90;
41
- const slashRegExp = /[/\\]/;
42
- const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
43
- // @__NO_SIDE_EFFECTS__
44
- function isPathSeparator(code) {
45
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
46
- }
47
- // @__NO_SIDE_EFFECTS__
48
- function isWindowsDeviceRoot(code) {
49
- return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z || code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
50
- }
51
- let _buffer;
52
- // @__NO_SIDE_EFFECTS__
53
- function getBuffer() {
54
- if (_buffer === void 0) {
55
- _buffer = require("node:buffer");
56
- }
57
- return _buffer;
58
- }
59
- let _url;
60
- // @__NO_SIDE_EFFECTS__
61
- function getUrl() {
62
- if (_url === void 0) {
63
- _url = require("node:url");
64
- }
65
- return _url;
66
- }
67
- // @__NO_SIDE_EFFECTS__
68
- function isNodeModules(pathLike) {
69
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
70
- return nodeModulesPathRegExp.test(filepath);
71
- }
72
- // @__NO_SIDE_EFFECTS__
73
- function isAbsolute(pathLike) {
74
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
75
- const { length } = filepath;
76
- if (length === 0) {
77
- return false;
78
- }
79
- const code = filepath.charCodeAt(0);
80
- if (code === CHAR_FORWARD_SLASH) {
81
- return true;
82
- }
83
- if (code === CHAR_BACKWARD_SLASH) {
84
- return true;
85
- }
86
- if (import_platform.WIN32 && length > 2) {
87
- if (/* @__PURE__ */ isWindowsDeviceRoot(code) && filepath.charCodeAt(1) === CHAR_COLON && /* @__PURE__ */ isPathSeparator(filepath.charCodeAt(2))) {
88
- return true;
89
- }
90
- }
91
- return false;
92
- }
93
- // @__NO_SIDE_EFFECTS__
94
- function isPath(pathLike) {
95
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
96
- if (typeof filepath !== "string" || filepath.length === 0) {
97
- return false;
98
- }
99
- if (/^[a-z][a-z0-9+.-]+:/i.test(filepath)) {
100
- return false;
101
- }
102
- if (filepath === "." || filepath === "..") {
103
- return true;
104
- }
105
- if (/* @__PURE__ */ isAbsolute(filepath)) {
106
- return true;
107
- }
108
- if (filepath.includes("/") || filepath.includes("\\")) {
109
- if (filepath.startsWith("@") && !filepath.startsWith("@/")) {
110
- const parts = filepath.split("/");
111
- if (parts.length <= 2 && !parts[1]?.includes("\\")) {
112
- return false;
113
- }
114
- }
115
- return true;
116
- }
117
- return false;
118
- }
119
- // @__NO_SIDE_EFFECTS__
120
- function isRelative(pathLike) {
121
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
122
- if (typeof filepath !== "string") {
123
- return false;
124
- }
125
- if (filepath.length === 0) {
126
- return true;
127
- }
128
- return !/* @__PURE__ */ isAbsolute(filepath);
129
- }
130
- // @__NO_SIDE_EFFECTS__
131
- function normalizePath(pathLike) {
132
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
133
- const { length } = filepath;
134
- if (length === 0) {
135
- return ".";
136
- }
137
- if (length < 2) {
138
- return length === 1 && filepath.charCodeAt(0) === 92 ? "/" : filepath;
139
- }
140
- let code = 0;
141
- let start = 0;
142
- let prefix = "";
143
- if (length > 4 && filepath.charCodeAt(3) === 92) {
144
- const code2 = filepath.charCodeAt(2);
145
- if ((code2 === 63 || code2 === 46) && filepath.charCodeAt(0) === 92 && filepath.charCodeAt(1) === 92) {
146
- start = 2;
147
- prefix = "//";
148
- }
149
- }
150
- if (start === 0) {
151
- if (length > 2 && (filepath.charCodeAt(0) === 92 && filepath.charCodeAt(1) === 92 && filepath.charCodeAt(2) !== 92 || filepath.charCodeAt(0) === 47 && filepath.charCodeAt(1) === 47 && filepath.charCodeAt(2) !== 47)) {
152
- let firstSegmentEnd = -1;
153
- let hasSecondSegment = false;
154
- let i = 2;
155
- while (i < length && (filepath.charCodeAt(i) === 47 || filepath.charCodeAt(i) === 92)) {
156
- i++;
157
- }
158
- while (i < length) {
159
- const char = filepath.charCodeAt(i);
160
- if (char === 47 || char === 92) {
161
- firstSegmentEnd = i;
162
- break;
163
- }
164
- i++;
165
- }
166
- if (firstSegmentEnd > 2) {
167
- i = firstSegmentEnd;
168
- while (i < length && (filepath.charCodeAt(i) === 47 || filepath.charCodeAt(i) === 92)) {
169
- i++;
170
- }
171
- if (i < length) {
172
- hasSecondSegment = true;
173
- }
174
- }
175
- if (firstSegmentEnd > 2 && hasSecondSegment) {
176
- start = 2;
177
- prefix = "//";
178
- } else {
179
- code = filepath.charCodeAt(start);
180
- while (code === 47 || code === 92) {
181
- start += 1;
182
- code = filepath.charCodeAt(start);
183
- }
184
- if (start) {
185
- prefix = "/";
186
- }
187
- }
188
- } else {
189
- code = filepath.charCodeAt(start);
190
- while (code === 47 || code === 92) {
191
- start += 1;
192
- code = filepath.charCodeAt(start);
193
- }
194
- if (start) {
195
- prefix = "/";
196
- }
197
- }
198
- }
199
- let nextIndex = (0, import_strings.search)(filepath, slashRegExp, { fromIndex: start });
200
- if (nextIndex === -1) {
201
- const segment = filepath.slice(start);
202
- if (segment === "." || segment.length === 0) {
203
- return prefix || ".";
204
- }
205
- if (segment === "..") {
206
- return prefix ? prefix.slice(0, -1) || "/" : "..";
207
- }
208
- return prefix + segment;
209
- }
210
- let collapsed = "";
211
- let segmentCount = 0;
212
- let leadingDotDots = 0;
213
- while (nextIndex !== -1) {
214
- const segment = filepath.slice(start, nextIndex);
215
- if (segment.length > 0 && segment !== ".") {
216
- if (segment === "..") {
217
- if (segmentCount > 0) {
218
- const lastSeparatorIndex = collapsed.lastIndexOf("/");
219
- if (lastSeparatorIndex === -1) {
220
- collapsed = "";
221
- segmentCount = 0;
222
- if (leadingDotDots > 0 && !prefix) {
223
- collapsed = "..";
224
- leadingDotDots = 1;
225
- }
226
- } else {
227
- const lastSegmentStart = lastSeparatorIndex + 1;
228
- const lastSegmentValue = collapsed.slice(lastSegmentStart);
229
- if (lastSegmentValue === "..") {
230
- collapsed = `${collapsed}/${segment}`;
231
- leadingDotDots += 1;
232
- } else {
233
- collapsed = collapsed.slice(0, lastSeparatorIndex);
234
- segmentCount -= 1;
235
- }
236
- }
237
- } else if (!prefix) {
238
- collapsed = collapsed + (collapsed.length === 0 ? "" : "/") + segment;
239
- leadingDotDots += 1;
240
- }
241
- } else {
242
- collapsed = collapsed + (collapsed.length === 0 ? "" : "/") + segment;
243
- segmentCount += 1;
244
- }
245
- }
246
- start = nextIndex + 1;
247
- code = filepath.charCodeAt(start);
248
- while (code === 47 || code === 92) {
249
- start += 1;
250
- code = filepath.charCodeAt(start);
251
- }
252
- nextIndex = (0, import_strings.search)(filepath, slashRegExp, { fromIndex: start });
253
- }
254
- const lastSegment = filepath.slice(start);
255
- if (lastSegment.length > 0 && lastSegment !== ".") {
256
- if (lastSegment === "..") {
257
- if (segmentCount > 0) {
258
- const lastSeparatorIndex = collapsed.lastIndexOf("/");
259
- if (lastSeparatorIndex === -1) {
260
- collapsed = "";
261
- segmentCount = 0;
262
- if (leadingDotDots > 0 && !prefix) {
263
- collapsed = "..";
264
- leadingDotDots = 1;
265
- }
266
- } else {
267
- const lastSegmentStart = lastSeparatorIndex + 1;
268
- const lastSegmentValue = collapsed.slice(lastSegmentStart);
269
- if (lastSegmentValue === "..") {
270
- collapsed = `${collapsed}/${lastSegment}`;
271
- leadingDotDots += 1;
272
- } else {
273
- collapsed = collapsed.slice(0, lastSeparatorIndex);
274
- segmentCount -= 1;
275
- }
276
- }
277
- } else if (!prefix) {
278
- collapsed = collapsed + (collapsed.length === 0 ? "" : "/") + lastSegment;
279
- leadingDotDots += 1;
280
- }
281
- } else {
282
- collapsed = collapsed + (collapsed.length === 0 ? "" : "/") + lastSegment;
283
- segmentCount += 1;
284
- }
285
- }
286
- if (collapsed.length === 0) {
287
- return prefix || ".";
288
- }
289
- return prefix + collapsed;
290
- }
291
- // @__NO_SIDE_EFFECTS__
292
- function pathLikeToString(pathLike) {
293
- if (pathLike === null || pathLike === void 0) {
294
- return "";
295
- }
296
- if (typeof pathLike === "string") {
297
- return pathLike;
298
- }
299
- const { Buffer: Buffer2 } = /* @__PURE__ */ getBuffer();
300
- if (Buffer2.isBuffer(pathLike)) {
301
- return pathLike.toString("utf8");
302
- }
303
- const url = /* @__PURE__ */ getUrl();
304
- if (pathLike instanceof URL) {
305
- try {
306
- return url.fileURLToPath(pathLike);
307
- } catch {
308
- const pathname = pathLike.pathname;
309
- const decodedPathname = decodeURIComponent(pathname);
310
- const WIN322 = require("./constants/platform").WIN32;
311
- if (WIN322 && decodedPathname.startsWith("/")) {
312
- const letter = decodedPathname.charCodeAt(1) | 32;
313
- const hasValidDriveLetter = decodedPathname.length >= 3 && letter >= 97 && // 'a' to 'z'
314
- letter <= 122 && decodedPathname.charAt(2) === ":";
315
- if (!hasValidDriveLetter) {
316
- return decodedPathname;
317
- }
318
- }
319
- return decodedPathname;
320
- }
321
- }
322
- return String(pathLike);
323
- }
324
- // @__NO_SIDE_EFFECTS__
325
- function splitPath(pathLike) {
326
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
327
- if (filepath === "") {
328
- return [];
329
- }
330
- return filepath.split(slashRegExp);
331
- }
332
- // @__NO_SIDE_EFFECTS__
333
- function trimLeadingDotSlash(pathLike) {
334
- const filepath = /* @__PURE__ */ pathLikeToString(pathLike);
335
- if (filepath.startsWith("./") || filepath.startsWith(".\\")) {
336
- return filepath.slice(2);
337
- }
338
- return filepath;
339
- }
340
- // @__NO_SIDE_EFFECTS__
341
- function resolve(...segments) {
342
- let resolvedPath = "";
343
- let resolvedAbsolute = false;
344
- for (let i = segments.length - 1; i >= 0 && !resolvedAbsolute; i -= 1) {
345
- const segment = segments[i];
346
- if (typeof segment !== "string" || segment.length === 0) {
347
- continue;
348
- }
349
- resolvedPath = segment + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
350
- resolvedAbsolute = /* @__PURE__ */ isAbsolute(segment);
351
- }
352
- if (!resolvedAbsolute) {
353
- const cwd = /* @__PURE__ */ require("node:process").cwd();
354
- resolvedPath = cwd + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
355
- }
356
- return /* @__PURE__ */ normalizePath(resolvedPath);
357
- }
358
- // @__NO_SIDE_EFFECTS__
359
- function relative(from, to) {
360
- if (from === to) {
361
- return "";
362
- }
363
- const actualFrom = /* @__PURE__ */ resolve(from);
364
- const actualTo = /* @__PURE__ */ resolve(to);
365
- if (actualFrom === actualTo) {
366
- return "";
367
- }
368
- const WIN322 = require("./constants/platform").WIN32;
369
- if (WIN322) {
370
- const fromLower = actualFrom.toLowerCase();
371
- const toLower = actualTo.toLowerCase();
372
- if (fromLower === toLower) {
373
- return "";
374
- }
375
- }
376
- const fromStart = 1;
377
- const fromEnd = actualFrom.length;
378
- const fromLen = fromEnd - fromStart;
379
- const toStart = 1;
380
- const toEnd = actualTo.length;
381
- const toLen = toEnd - toStart;
382
- const length = fromLen < toLen ? fromLen : toLen;
383
- let lastCommonSep = -1;
384
- let i = 0;
385
- for (; i < length; i += 1) {
386
- let fromCode = actualFrom.charCodeAt(fromStart + i);
387
- let toCode = actualTo.charCodeAt(toStart + i);
388
- if (WIN322) {
389
- if (fromCode >= CHAR_UPPERCASE_A && fromCode <= CHAR_UPPERCASE_Z) {
390
- fromCode += 32;
391
- }
392
- if (toCode >= CHAR_UPPERCASE_A && toCode <= CHAR_UPPERCASE_Z) {
393
- toCode += 32;
394
- }
395
- }
396
- if (fromCode !== toCode) {
397
- break;
398
- }
399
- if (/* @__PURE__ */ isPathSeparator(actualFrom.charCodeAt(fromStart + i))) {
400
- lastCommonSep = i;
401
- }
402
- }
403
- if (i === length) {
404
- if (toLen > length) {
405
- const toCode = actualTo.charCodeAt(toStart + i);
406
- if (/* @__PURE__ */ isPathSeparator(toCode)) {
407
- return actualTo.slice(toStart + i + 1);
408
- }
409
- if (i === 0) {
410
- return actualTo.slice(toStart + i);
411
- }
412
- } else if (fromLen > length) {
413
- const fromCode = actualFrom.charCodeAt(fromStart + i);
414
- if (/* @__PURE__ */ isPathSeparator(fromCode)) {
415
- lastCommonSep = i;
416
- } else if (i === 0) {
417
- lastCommonSep = 0;
418
- }
419
- }
420
- }
421
- let out = "";
422
- for (i = fromStart + lastCommonSep + 1; i <= fromEnd; i += 1) {
423
- const code = actualFrom.charCodeAt(i);
424
- if (i === fromEnd || /* @__PURE__ */ isPathSeparator(code)) {
425
- out += out.length === 0 ? ".." : "/..";
426
- }
427
- }
428
- return out + actualTo.slice(toStart + lastCommonSep);
429
- }
430
- // @__NO_SIDE_EFFECTS__
431
- function relativeResolve(from, to) {
432
- const rel = /* @__PURE__ */ relative(from, to);
433
- if (rel === "") {
434
- return "";
435
- }
436
- return /* @__PURE__ */ normalizePath(rel);
437
- }
438
- // Annotate the CommonJS export names for ESM import in node:
439
- 0 && (module.exports = {
440
- isAbsolute,
441
- isNodeModules,
442
- isPath,
443
- isRelative,
444
- normalizePath,
445
- pathLikeToString,
446
- relativeResolve,
447
- splitPath,
448
- trimLeadingDotSlash
449
- });
2
+ var S=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},N=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!H.call(t,r)&&r!==n&&S(t,r,{get:()=>e[r],enumerable:!(i=v(e,r))||i.enumerable});return t};var O=t=>N(S({},"__esModule",{value:!0}),t);var Y={};D(Y,{isAbsolute:()=>R,isNodeModules:()=>Z,isPath:()=>K,isRelative:()=>j,normalizePath:()=>E,pathLikeToString:()=>C,relativeResolve:()=>X,splitPath:()=>G,trimLeadingDotSlash:()=>J});module.exports=O(Y);var U=require("#constants/platform"),W=require("./strings");const B=92,$=58,P=47,V=97,q=122,_=65,b=90,w=/[/\\]/,z=/(?:^|[/\\])node_modules(?:[/\\]|$)/;function p(t){return t===P||t===B}function T(t){return t>=_&&t<=b||t>=V&&t<=q}let x;function F(){return x===void 0&&(x=require("node:buffer")),x}let L;function M(){return L===void 0&&(L=require("node:url")),L}function Z(t){const e=C(t);return z.test(e)}function R(t){const e=C(t),{length:n}=e;if(n===0)return!1;const i=e.charCodeAt(0);return!!(i===P||i===B||U.WIN32&&n>2&&T(i)&&e.charCodeAt(1)===$&&p(e.charCodeAt(2)))}function K(t){const e=C(t);if(typeof e!="string"||e.length===0||/^[a-z][a-z0-9+.-]+:/i.test(e))return!1;if(e==="."||e===".."||R(e))return!0;if(e.includes("/")||e.includes("\\")){if(e.startsWith("@")&&!e.startsWith("@/")){const n=e.split("/");if(n.length<=2&&!n[1]?.includes("\\"))return!1}return!0}return!1}function j(t){const e=C(t);return typeof e!="string"?!1:e.length===0?!0:!R(e)}function E(t){const e=C(t),{length:n}=e;if(n===0)return".";if(n<2)return n===1&&e.charCodeAt(0)===92?"/":e;let i=0,r=0,l="";if(n>4&&e.charCodeAt(3)===92){const f=e.charCodeAt(2);(f===63||f===46)&&e.charCodeAt(0)===92&&e.charCodeAt(1)===92&&(r=2,l="//")}if(r===0)if(n>2&&(e.charCodeAt(0)===92&&e.charCodeAt(1)===92&&e.charCodeAt(2)!==92||e.charCodeAt(0)===47&&e.charCodeAt(1)===47&&e.charCodeAt(2)!==47)){let f=-1,a=!1,o=2;for(;o<n&&(e.charCodeAt(o)===47||e.charCodeAt(o)===92);)o++;for(;o<n;){const A=e.charCodeAt(o);if(A===47||A===92){f=o;break}o++}if(f>2){for(o=f;o<n&&(e.charCodeAt(o)===47||e.charCodeAt(o)===92);)o++;o<n&&(a=!0)}if(f>2&&a)r=2,l="//";else{for(i=e.charCodeAt(r);i===47||i===92;)r+=1,i=e.charCodeAt(r);r&&(l="/")}}else{for(i=e.charCodeAt(r);i===47||i===92;)r+=1,i=e.charCodeAt(r);r&&(l="/")}let u=(0,W.search)(e,w,{fromIndex:r});if(u===-1){const f=e.slice(r);return f==="."||f.length===0?l||".":f===".."?l?l.slice(0,-1)||"/":"..":l+f}let s="",c=0,g=0;for(;u!==-1;){const f=e.slice(r,u);if(f.length>0&&f!==".")if(f==="..")if(c>0){const a=s.lastIndexOf("/");if(a===-1)s="",c=0,g>0&&!l&&(s="..",g=1);else{const o=a+1;s.slice(o)===".."?(s=`${s}/${f}`,g+=1):(s=s.slice(0,a),c-=1)}}else l||(s=s+(s.length===0?"":"/")+f,g+=1);else s=s+(s.length===0?"":"/")+f,c+=1;for(r=u+1,i=e.charCodeAt(r);i===47||i===92;)r+=1,i=e.charCodeAt(r);u=(0,W.search)(e,w,{fromIndex:r})}const h=e.slice(r);if(h.length>0&&h!==".")if(h==="..")if(c>0){const f=s.lastIndexOf("/");if(f===-1)s="",c=0,g>0&&!l&&(s="..",g=1);else{const a=f+1;s.slice(a)===".."?(s=`${s}/${h}`,g+=1):(s=s.slice(0,f),c-=1)}}else l||(s=s+(s.length===0?"":"/")+h,g+=1);else s=s+(s.length===0?"":"/")+h,c+=1;return s.length===0?l||".":l+s}function C(t){if(t==null)return"";if(typeof t=="string")return t;const{Buffer:e}=F();if(e.isBuffer(t))return t.toString("utf8");const n=M();if(t instanceof URL)try{return n.fileURLToPath(t)}catch{const i=t.pathname,r=decodeURIComponent(i);if(require("./constants/platform").WIN32&&r.startsWith("/")){const u=r.charCodeAt(1)|32;if(!(r.length>=3&&u>=97&&u<=122&&r.charAt(2)===":"))return r}return r}return String(t)}function G(t){const e=C(t);return e===""?[]:e.split(w)}function J(t){const e=C(t);return e.startsWith("./")||e.startsWith(".\\")?e.slice(2):e}function I(...t){let e="",n=!1;for(let i=t.length-1;i>=0&&!n;i-=1){const r=t[i];typeof r!="string"||r.length===0||(e=r+(e.length===0?"":`/${e}`),n=R(r))}return n||(e=require("node:process").cwd()+(e.length===0?"":`/${e}`)),E(e)}function Q(t,e){if(t===e)return"";const n=I(t),i=I(e);if(n===i)return"";const r=require("./constants/platform").WIN32;if(r){const d=n.toLowerCase(),m=i.toLowerCase();if(d===m)return""}const l=1,u=n.length,s=u-l,c=1,h=i.length-c,f=s<h?s:h;let a=-1,o=0;for(;o<f;o+=1){let d=n.charCodeAt(l+o),m=i.charCodeAt(c+o);if(r&&(d>=_&&d<=b&&(d+=32),m>=_&&m<=b&&(m+=32)),d!==m)break;p(n.charCodeAt(l+o))&&(a=o)}if(o===f){if(h>f){const d=i.charCodeAt(c+o);if(p(d))return i.slice(c+o+1);if(o===0)return i.slice(c+o)}else if(s>f){const d=n.charCodeAt(l+o);p(d)?a=o:o===0&&(a=0)}}let A="";for(o=l+a+1;o<=u;o+=1){const d=n.charCodeAt(o);(o===u||p(d))&&(A+=A.length===0?"..":"/..")}return A+i.slice(c+a)}function X(t,e){const n=Q(t,e);return n===""?"":E(n)}0&&(module.exports={isAbsolute,isNodeModules,isPath,isRelative,normalizePath,pathLikeToString,relativeResolve,splitPath,trimLeadingDotSlash});
450
3
  //# sourceMappingURL=path.js.map