cf-workers-native 0.0.0-stage → 0.1.2-beta.local.sha2f5e4e6956f4

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 (629) hide show
  1. package/LICENSE +21 -0
  2. package/Package.swift +25 -0
  3. package/README.md +92 -2
  4. package/dist/android.d.ts +2 -0
  5. package/dist/android.js +1 -0
  6. package/dist/browser/abort/index.d.ts +13 -0
  7. package/dist/browser/abort/index.js +66 -0
  8. package/dist/browser/body/index.d.ts +24 -0
  9. package/dist/browser/body/index.js +116 -0
  10. package/dist/browser/body/stream-body.d.ts +13 -0
  11. package/dist/browser/body/stream-body.js +84 -0
  12. package/dist/browser/documents/body.d.ts +3 -0
  13. package/dist/browser/documents/body.js +48 -0
  14. package/dist/browser/documents/form-body.d.ts +1 -0
  15. package/dist/browser/documents/form-body.js +54 -0
  16. package/dist/browser/documents/host.d.ts +11 -0
  17. package/dist/browser/documents/host.js +256 -0
  18. package/dist/browser/documents/links-source.d.ts +1 -0
  19. package/dist/browser/documents/links-source.js +1 -0
  20. package/dist/browser/documents/links.d.ts +1 -0
  21. package/dist/browser/documents/links.js +33 -0
  22. package/dist/browser/documents/page-config.d.ts +5 -0
  23. package/dist/browser/documents/page-config.js +5 -0
  24. package/dist/browser/documents/page-source.d.ts +1 -0
  25. package/dist/browser/documents/page-source.js +1 -0
  26. package/dist/browser/documents/page.d.ts +2 -0
  27. package/dist/browser/documents/page.js +153 -0
  28. package/dist/browser/documents/registration.d.ts +5 -0
  29. package/dist/browser/documents/registration.js +75 -0
  30. package/dist/browser/documents/runtime.d.ts +7 -0
  31. package/dist/browser/documents/runtime.js +161 -0
  32. package/dist/browser/documents/service-worker.js +285 -0
  33. package/dist/browser/encoding/index.d.ts +7 -0
  34. package/dist/browser/encoding/index.js +3 -0
  35. package/dist/browser/fetch/LICENSE-3RD-PARTY.md +9 -0
  36. package/dist/browser/fetch/LICENSE-APACHE +177 -0
  37. package/dist/browser/fetch/host-call.d.ts +3 -0
  38. package/dist/browser/fetch/host-call.js +67 -0
  39. package/dist/browser/fetch/index.d.ts +5 -0
  40. package/dist/browser/fetch/index.js +96 -0
  41. package/dist/browser/fetch/interop.d.ts +6 -0
  42. package/dist/browser/fetch/interop.js +48 -0
  43. package/dist/browser/fetch/native-network.d.ts +20 -0
  44. package/dist/browser/fetch/native-network.js +233 -0
  45. package/dist/browser/fetch/outbound.d.ts +2 -0
  46. package/dist/browser/fetch/outbound.js +11 -0
  47. package/dist/browser/fetch/relay.d.ts +7 -0
  48. package/dist/browser/fetch/relay.js +100 -0
  49. package/dist/browser/fetch/scope.d.ts +8 -0
  50. package/dist/browser/fetch/scope.js +108 -0
  51. package/dist/browser/fetch/transport.d.ts +39 -0
  52. package/dist/browser/fetch/transport.js +136 -0
  53. package/dist/browser/headers/LICENSE-3RD-PARTY.md +9 -0
  54. package/dist/browser/headers/LICENSE-APACHE +177 -0
  55. package/dist/browser/headers/index.d.ts +20 -0
  56. package/dist/browser/headers/index.js +194 -0
  57. package/dist/browser/isolated/bridge.d.ts +8 -0
  58. package/dist/browser/isolated/bridge.js +267 -0
  59. package/dist/browser/isolated/protocol.d.ts +40 -0
  60. package/dist/browser/isolated/protocol.js +1 -0
  61. package/dist/browser/isolated/transport.d.ts +2 -0
  62. package/dist/browser/isolated/transport.js +157 -0
  63. package/dist/browser/request/LICENSE-3RD-PARTY.md +10 -0
  64. package/dist/browser/request/LICENSE-APACHE +177 -0
  65. package/dist/browser/request/index.d.ts +48 -0
  66. package/dist/browser/request/index.js +182 -0
  67. package/dist/browser/response/LICENSE-3RD-PARTY.md +10 -0
  68. package/dist/browser/response/LICENSE-APACHE +177 -0
  69. package/dist/browser/response/index.d.ts +43 -0
  70. package/dist/browser/response/index.js +192 -0
  71. package/dist/browser/response/status.d.ts +1 -0
  72. package/dist/browser/response/status.js +75 -0
  73. package/dist/browser/structured-clone/index.d.ts +1 -0
  74. package/dist/browser/structured-clone/index.js +479 -0
  75. package/dist/cloudflare/apis/cloudflare-node/index.d.ts +18 -0
  76. package/dist/cloudflare/apis/cloudflare-node/index.js +150 -0
  77. package/dist/cloudflare/apis/cloudflare-workers/index.d.ts +8 -0
  78. package/dist/cloudflare/apis/cloudflare-workers/index.js +37 -0
  79. package/dist/cloudflare/apis/types.d.ts +7 -0
  80. package/dist/cloudflare/apis/types.js +1 -0
  81. package/dist/cloudflare/bindings/config.d.ts +42 -0
  82. package/dist/cloudflare/bindings/config.js +280 -0
  83. package/dist/cloudflare/bindings/kv/contract.d.ts +6 -0
  84. package/dist/cloudflare/bindings/kv/contract.js +181 -0
  85. package/dist/cloudflare/bindings/kv/index.d.ts +18 -0
  86. package/dist/cloudflare/bindings/kv/index.js +61 -0
  87. package/dist/cloudflare/bindings/kv/storage.d.ts +25 -0
  88. package/dist/cloudflare/bindings/kv/storage.js +320 -0
  89. package/dist/cloudflare/bindings/kv/types.d.ts +50 -0
  90. package/dist/cloudflare/bindings/kv/types.js +1 -0
  91. package/dist/cloudflare/bindings/remote.d.ts +8 -0
  92. package/dist/cloudflare/bindings/remote.js +261 -0
  93. package/dist/cloudflare/workers/contract.d.ts +8 -0
  94. package/dist/cloudflare/workers/contract.js +65 -0
  95. package/dist/cloudflare/workers/feature.d.ts +10 -0
  96. package/dist/cloudflare/workers/feature.js +28 -0
  97. package/dist/cloudflare/workers/runtime.d.ts +23 -0
  98. package/dist/cloudflare/workers/runtime.js +121 -0
  99. package/dist/cloudflare/workers/types.d.ts +49 -0
  100. package/dist/cloudflare/workers/types.js +1 -0
  101. package/dist/cloudflare/workers/worker-runtime.d.ts +44 -0
  102. package/dist/cloudflare/workers/worker-runtime.js +267 -0
  103. package/dist/compat/assert/LICENSE-3RD-PARTY.md +5 -0
  104. package/dist/compat/assert/LICENSE-APACHE +177 -0
  105. package/dist/compat/assert/assertion-error.d.ts +26 -0
  106. package/dist/compat/assert/assertion-error.js +468 -0
  107. package/dist/compat/assert/diff.d.ts +26 -0
  108. package/dist/compat/assert/diff.js +329 -0
  109. package/dist/compat/assert/errors.d.ts +11 -0
  110. package/dist/compat/assert/errors.js +55 -0
  111. package/dist/compat/assert/index.cjs +24 -0
  112. package/dist/compat/assert/index.d.cts +43 -0
  113. package/dist/compat/assert/index.d.ts +50 -0
  114. package/dist/compat/assert/index.js +858 -0
  115. package/dist/compat/async-hooks/LICENSE-APACHE +177 -0
  116. package/dist/compat/async-hooks/NOTICE.md +8 -0
  117. package/dist/compat/async-hooks/callbacks.d.ts +7 -0
  118. package/dist/compat/async-hooks/callbacks.js +18 -0
  119. package/dist/compat/async-hooks/hooks.d.ts +10 -0
  120. package/dist/compat/async-hooks/hooks.js +111 -0
  121. package/dist/compat/async-hooks/index.d.ts +41 -0
  122. package/dist/compat/async-hooks/index.js +298 -0
  123. package/dist/compat/buffer/LICENSE-3RD-PARTY.md +15 -0
  124. package/dist/compat/buffer/LICENSE-APACHE +177 -0
  125. package/dist/compat/buffer/blob.d.ts +22 -0
  126. package/dist/compat/buffer/blob.js +210 -0
  127. package/dist/compat/buffer/bytes.d.ts +34 -0
  128. package/dist/compat/buffer/bytes.js +228 -0
  129. package/dist/compat/buffer/errors.d.ts +41 -0
  130. package/dist/compat/buffer/errors.js +265 -0
  131. package/dist/compat/buffer/index.d.ts +25 -0
  132. package/dist/compat/buffer/index.js +24 -0
  133. package/dist/compat/buffer/internal-buffer.d.ts +148 -0
  134. package/dist/compat/buffer/internal-buffer.js +1809 -0
  135. package/dist/compat/buffer/support.d.ts +13 -0
  136. package/dist/compat/buffer/support.js +65 -0
  137. package/dist/compat/child-process/LICENSE-3RD-PARTY.md +8 -0
  138. package/dist/compat/child-process/LICENSE-APACHE +177 -0
  139. package/dist/compat/child-process/errors.d.ts +4 -0
  140. package/dist/compat/child-process/errors.js +6 -0
  141. package/dist/compat/child-process/index.d.ts +49 -0
  142. package/dist/compat/child-process/index.js +96 -0
  143. package/dist/compat/cluster/LICENSE-3RD-PARTY.md +40 -0
  144. package/dist/compat/cluster/LICENSE-APACHE +177 -0
  145. package/dist/compat/cluster/errors.d.ts +4 -0
  146. package/dist/compat/cluster/errors.js +6 -0
  147. package/dist/compat/cluster/index.d.ts +47 -0
  148. package/dist/compat/cluster/index.js +88 -0
  149. package/dist/compat/constants/LICENSE-3RD-PARTY.md +6 -0
  150. package/dist/compat/constants/LICENSE-APACHE +177 -0
  151. package/dist/compat/constants/index.d.ts +481 -0
  152. package/dist/compat/constants/index.js +488 -0
  153. package/dist/compat/dgram/LICENSE-3RD-PARTY.md +8 -0
  154. package/dist/compat/dgram/LICENSE-APACHE +177 -0
  155. package/dist/compat/dgram/index.d.ts +10 -0
  156. package/dist/compat/dgram/index.js +132 -0
  157. package/dist/compat/diagnostics-channel/LICENSE-3RD-PARTY.md +13 -0
  158. package/dist/compat/diagnostics-channel/LICENSE-APACHE +177 -0
  159. package/dist/compat/diagnostics-channel/index.d.ts +73 -0
  160. package/dist/compat/diagnostics-channel/index.js +261 -0
  161. package/dist/compat/diagnostics-channel/native.d.ts +26 -0
  162. package/dist/compat/diagnostics-channel/native.js +154 -0
  163. package/dist/compat/dns/LICENSE-3RD-PARTY.md +5 -0
  164. package/dist/compat/dns/LICENSE-APACHE +177 -0
  165. package/dist/compat/dns/client.d.ts +72 -0
  166. package/dist/compat/dns/client.js +161 -0
  167. package/dist/compat/dns/constants.d.ts +27 -0
  168. package/dist/compat/dns/constants.js +31 -0
  169. package/dist/compat/dns/errors.d.ts +8 -0
  170. package/dist/compat/dns/errors.js +12 -0
  171. package/dist/compat/dns/index.d.ts +97 -0
  172. package/dist/compat/dns/index.js +127 -0
  173. package/dist/compat/dns/parser.d.ts +18 -0
  174. package/dist/compat/dns/parser.js +144 -0
  175. package/dist/compat/dns/promise-resolver.d.ts +82 -0
  176. package/dist/compat/dns/promise-resolver.js +113 -0
  177. package/dist/compat/dns/promises.d.ts +50 -0
  178. package/dist/compat/dns/promises.js +53 -0
  179. package/dist/compat/dns/resolver.d.ts +34 -0
  180. package/dist/compat/dns/resolver.js +415 -0
  181. package/dist/compat/domain/LICENSE-3RD-PARTY.md +5 -0
  182. package/dist/compat/domain/LICENSE-APACHE +177 -0
  183. package/dist/compat/domain/index.d.ts +22 -0
  184. package/dist/compat/domain/index.js +79 -0
  185. package/dist/compat/fs/index.d.ts +85 -0
  186. package/dist/compat/fs/index.js +255 -0
  187. package/dist/compat/fs/promises/index.d.ts +3 -0
  188. package/dist/compat/fs/promises/index.js +3 -0
  189. package/dist/compat/http/index.d.ts +322 -0
  190. package/dist/compat/http/index.js +1356 -0
  191. package/dist/compat/http/registry.d.ts +19 -0
  192. package/dist/compat/http/registry.js +13 -0
  193. package/dist/compat/http-agent/LICENSE-3RD-PARTY.md +5 -0
  194. package/dist/compat/http-agent/LICENSE-APACHE +177 -0
  195. package/dist/compat/http-agent/index.d.ts +7 -0
  196. package/dist/compat/http-agent/index.js +10 -0
  197. package/dist/compat/http-client/LICENSE-3RD-PARTY.md +5 -0
  198. package/dist/compat/http-client/LICENSE-APACHE +177 -0
  199. package/dist/compat/http-client/index.d.ts +6 -0
  200. package/dist/compat/http-client/index.js +7 -0
  201. package/dist/compat/http-incoming/LICENSE-3RD-PARTY.md +5 -0
  202. package/dist/compat/http-incoming/LICENSE-APACHE +177 -0
  203. package/dist/compat/http-incoming/index.d.ts +6 -0
  204. package/dist/compat/http-incoming/index.js +9 -0
  205. package/dist/compat/http2/LICENSE-3RD-PARTY.md +29 -0
  206. package/dist/compat/http2/LICENSE-APACHE +177 -0
  207. package/dist/compat/http2/constants.d.ts +255 -0
  208. package/dist/compat/http2/constants.js +515 -0
  209. package/dist/compat/http2/errors.d.ts +4 -0
  210. package/dist/compat/http2/errors.js +6 -0
  211. package/dist/compat/http2/index.d.ts +283 -0
  212. package/dist/compat/http2/index.js +68 -0
  213. package/dist/compat/https/LICENSE-3RD-PARTY.md +5 -0
  214. package/dist/compat/https/LICENSE-APACHE +177 -0
  215. package/dist/compat/https/agent.d.ts +10 -0
  216. package/dist/compat/https/agent.js +99 -0
  217. package/dist/compat/https/errors.d.ts +4 -0
  218. package/dist/compat/https/errors.js +6 -0
  219. package/dist/compat/https/index.d.ts +20 -0
  220. package/dist/compat/https/index.js +50 -0
  221. package/dist/compat/https/server.d.ts +8 -0
  222. package/dist/compat/https/server.js +27 -0
  223. package/dist/compat/immediate/index.d.ts +11 -0
  224. package/dist/compat/immediate/index.js +58 -0
  225. package/dist/compat/inspector/LICENSE-3RD-PARTY.md +34 -0
  226. package/dist/compat/inspector/LICENSE-APACHE +177 -0
  227. package/dist/compat/inspector/errors.d.ts +4 -0
  228. package/dist/compat/inspector/errors.js +6 -0
  229. package/dist/compat/inspector/index.d.ts +18 -0
  230. package/dist/compat/inspector/index.js +117 -0
  231. package/dist/compat/inspector/promises.d.ts +18 -0
  232. package/dist/compat/inspector/promises.js +114 -0
  233. package/dist/compat/module/index.cjs +2 -0
  234. package/dist/compat/module/index.d.cts +2 -0
  235. package/dist/compat/module/index.d.ts +11 -0
  236. package/dist/compat/module/index.js +44 -0
  237. package/dist/compat/module/resolve-unavailable.d.ts +1 -0
  238. package/dist/compat/module/resolve-unavailable.js +3 -0
  239. package/dist/compat/net/LICENSE-3RD-PARTY.md +15 -0
  240. package/dist/compat/net/LICENSE-APACHE +177 -0
  241. package/dist/compat/net/error-base.d.ts +14 -0
  242. package/dist/compat/net/error-base.js +62 -0
  243. package/dist/compat/net/errors.d.ts +76 -0
  244. package/dist/compat/net/errors.js +333 -0
  245. package/dist/compat/net/index.d.ts +23 -0
  246. package/dist/compat/net/index.js +46 -0
  247. package/dist/compat/net/internal-net.d.ts +236 -0
  248. package/dist/compat/net/internal-net.js +2292 -0
  249. package/dist/compat/net/ports.d.ts +32 -0
  250. package/dist/compat/net/ports.js +149 -0
  251. package/dist/compat/net/reader.d.ts +8 -0
  252. package/dist/compat/net/reader.js +36 -0
  253. package/dist/compat/net/sockets.d.ts +20 -0
  254. package/dist/compat/net/sockets.js +195 -0
  255. package/dist/compat/net/validators.d.ts +18 -0
  256. package/dist/compat/net/validators.js +154 -0
  257. package/dist/compat/os/LICENSE-3RD-PARTY.md +8 -0
  258. package/dist/compat/os/LICENSE-APACHE +177 -0
  259. package/dist/compat/os/index.d.ts +329 -0
  260. package/dist/compat/os/index.js +278 -0
  261. package/dist/compat/path/LICENSE-3RD-PARTY.md +35 -0
  262. package/dist/compat/path/LICENSE-APACHE +177 -0
  263. package/dist/compat/path/index.d.ts +4 -0
  264. package/dist/compat/path/index.js +11 -0
  265. package/dist/compat/path/internal-path.d.ts +95 -0
  266. package/dist/compat/path/internal-path.js +1542 -0
  267. package/dist/compat/path/posix/index.d.ts +4 -0
  268. package/dist/compat/path/posix/index.js +5 -0
  269. package/dist/compat/path/win32/index.d.ts +4 -0
  270. package/dist/compat/path/win32/index.js +5 -0
  271. package/dist/compat/perf-hooks/LICENSE-3RD-PARTY.md +5 -0
  272. package/dist/compat/perf-hooks/LICENSE-APACHE +177 -0
  273. package/dist/compat/perf-hooks/index.d.ts +85 -0
  274. package/dist/compat/perf-hooks/index.js +79 -0
  275. package/dist/compat/perf-hooks/performance.d.ts +96 -0
  276. package/dist/compat/perf-hooks/performance.js +445 -0
  277. package/dist/compat/punycode/LICENSE-3RD-PARTY.md +7 -0
  278. package/dist/compat/punycode/LICENSE-APACHE +177 -0
  279. package/dist/compat/punycode/index.d.ts +93 -0
  280. package/dist/compat/punycode/index.js +410 -0
  281. package/dist/compat/querystring/LICENSE-3RD-PARTY.md +35 -0
  282. package/dist/compat/querystring/LICENSE-APACHE +177 -0
  283. package/dist/compat/querystring/index.d.ts +14 -0
  284. package/dist/compat/querystring/index.js +18 -0
  285. package/dist/compat/querystring/internal-querystring.d.ts +22 -0
  286. package/dist/compat/querystring/internal-querystring.js +498 -0
  287. package/dist/compat/readline/LICENSE-3RD-PARTY.md +37 -0
  288. package/dist/compat/readline/LICENSE-APACHE +177 -0
  289. package/dist/compat/readline/index.d.ts +21 -0
  290. package/dist/compat/readline/index.js +56 -0
  291. package/dist/compat/readline/interface.d.ts +22 -0
  292. package/dist/compat/readline/interface.js +85 -0
  293. package/dist/compat/readline/internal-promises.d.ts +32 -0
  294. package/dist/compat/readline/internal-promises.js +104 -0
  295. package/dist/compat/readline/promises.d.ts +8 -0
  296. package/dist/compat/readline/promises.js +32 -0
  297. package/dist/compat/repl/LICENSE-3RD-PARTY.md +5 -0
  298. package/dist/compat/repl/LICENSE-APACHE +177 -0
  299. package/dist/compat/repl/builtin-modules.d.ts +1 -0
  300. package/dist/compat/repl/builtin-modules.js +101 -0
  301. package/dist/compat/repl/errors.d.ts +4 -0
  302. package/dist/compat/repl/errors.js +6 -0
  303. package/dist/compat/repl/index.d.ts +53 -0
  304. package/dist/compat/repl/index.js +106 -0
  305. package/dist/compat/sqlite/LICENSE-3RD-PARTY.md +6 -0
  306. package/dist/compat/sqlite/LICENSE-APACHE +177 -0
  307. package/dist/compat/sqlite/index.d.ts +12 -0
  308. package/dist/compat/sqlite/index.js +101 -0
  309. package/dist/compat/sqlite/native.d.ts +16 -0
  310. package/dist/compat/sqlite/native.js +33 -0
  311. package/dist/compat/stream/LICENSE-3RD-PARTY.md +13 -0
  312. package/dist/compat/stream/LICENSE-APACHE +177 -0
  313. package/dist/compat/stream/add-abort-signal.d.ts +4 -0
  314. package/dist/compat/stream/add-abort-signal.js +73 -0
  315. package/dist/compat/stream/compose.d.ts +1 -0
  316. package/dist/compat/stream/compose.js +313 -0
  317. package/dist/compat/stream/destroy.d.ts +5 -0
  318. package/dist/compat/stream/destroy.js +315 -0
  319. package/dist/compat/stream/duplex.d.ts +48 -0
  320. package/dist/compat/stream/duplex.js +789 -0
  321. package/dist/compat/stream/end-of-stream.d.ts +16 -0
  322. package/dist/compat/stream/end-of-stream.js +269 -0
  323. package/dist/compat/stream/errors.d.ts +40 -0
  324. package/dist/compat/stream/errors.js +86 -0
  325. package/dist/compat/stream/events.d.ts +6 -0
  326. package/dist/compat/stream/events.js +28 -0
  327. package/dist/compat/stream/index.cjs +27 -0
  328. package/dist/compat/stream/index.d.cts +25 -0
  329. package/dist/compat/stream/index.d.ts +20 -0
  330. package/dist/compat/stream/index.js +55 -0
  331. package/dist/compat/stream/legacy.d.ts +8 -0
  332. package/dist/compat/stream/legacy.js +105 -0
  333. package/dist/compat/stream/once.d.ts +7 -0
  334. package/dist/compat/stream/once.js +13 -0
  335. package/dist/compat/stream/pipeline.d.ts +5 -0
  336. package/dist/compat/stream/pipeline.js +567 -0
  337. package/dist/compat/stream/process.d.ts +1 -0
  338. package/dist/compat/stream/process.js +4 -0
  339. package/dist/compat/stream/promises.d.ts +7 -0
  340. package/dist/compat/stream/promises.js +60 -0
  341. package/dist/compat/stream/readable.d.ts +29 -0
  342. package/dist/compat/stream/readable.js +2267 -0
  343. package/dist/compat/stream/state.d.ts +8 -0
  344. package/dist/compat/stream/state.js +63 -0
  345. package/dist/compat/stream/transform.d.ts +2 -0
  346. package/dist/compat/stream/transform.js +202 -0
  347. package/dist/compat/stream/util.d.ts +55 -0
  348. package/dist/compat/stream/util.js +345 -0
  349. package/dist/compat/stream/validators.d.ts +2 -0
  350. package/dist/compat/stream/validators.js +14 -0
  351. package/dist/compat/stream/writable.d.ts +21 -0
  352. package/dist/compat/stream/writable.js +1325 -0
  353. package/dist/compat/stream-consumers/LICENSE-3RD-PARTY.md +5 -0
  354. package/dist/compat/stream-consumers/LICENSE-APACHE +177 -0
  355. package/dist/compat/stream-consumers/index.d.ts +14 -0
  356. package/dist/compat/stream-consumers/index.js +62 -0
  357. package/dist/compat/stream-consumers/iterable.d.ts +1 -0
  358. package/dist/compat/stream-consumers/iterable.js +34 -0
  359. package/dist/compat/stream-duplex/LICENSE-3RD-PARTY.md +13 -0
  360. package/dist/compat/stream-duplex/LICENSE-APACHE +177 -0
  361. package/dist/compat/stream-duplex/index.cjs +3 -0
  362. package/dist/compat/stream-duplex/index.d.cts +2 -0
  363. package/dist/compat/stream-duplex/index.d.ts +3 -0
  364. package/dist/compat/stream-duplex/index.js +8 -0
  365. package/dist/compat/stream-passthrough/LICENSE-3RD-PARTY.md +13 -0
  366. package/dist/compat/stream-passthrough/LICENSE-APACHE +177 -0
  367. package/dist/compat/stream-passthrough/index.cjs +3 -0
  368. package/dist/compat/stream-passthrough/index.d.cts +2 -0
  369. package/dist/compat/stream-passthrough/index.d.ts +3 -0
  370. package/dist/compat/stream-passthrough/index.js +8 -0
  371. package/dist/compat/stream-promises/LICENSE-3RD-PARTY.md +13 -0
  372. package/dist/compat/stream-promises/LICENSE-APACHE +177 -0
  373. package/dist/compat/stream-promises/index.d.ts +1 -0
  374. package/dist/compat/stream-promises/index.js +1 -0
  375. package/dist/compat/stream-readable/LICENSE-3RD-PARTY.md +13 -0
  376. package/dist/compat/stream-readable/LICENSE-APACHE +177 -0
  377. package/dist/compat/stream-readable/index.cjs +3 -0
  378. package/dist/compat/stream-readable/index.d.cts +2 -0
  379. package/dist/compat/stream-readable/index.d.ts +3 -0
  380. package/dist/compat/stream-readable/index.js +8 -0
  381. package/dist/compat/stream-transform/LICENSE-3RD-PARTY.md +13 -0
  382. package/dist/compat/stream-transform/LICENSE-APACHE +177 -0
  383. package/dist/compat/stream-transform/index.cjs +3 -0
  384. package/dist/compat/stream-transform/index.d.cts +2 -0
  385. package/dist/compat/stream-transform/index.d.ts +3 -0
  386. package/dist/compat/stream-transform/index.js +8 -0
  387. package/dist/compat/stream-web/LICENSE-MIT +22 -0
  388. package/dist/compat/stream-web/NOTICE.md +3 -0
  389. package/dist/compat/stream-web/context.d.ts +2 -0
  390. package/dist/compat/stream-web/context.js +35 -0
  391. package/dist/compat/stream-web/index.d.ts +80 -0
  392. package/dist/compat/stream-web/index.js +129 -0
  393. package/dist/compat/stream-web/interop.d.ts +6 -0
  394. package/dist/compat/stream-web/interop.js +72 -0
  395. package/dist/compat/stream-web/ponyfill.d.ts +1 -0
  396. package/dist/compat/stream-web/ponyfill.js +2093 -0
  397. package/dist/compat/stream-web/runtime.d.ts +16 -0
  398. package/dist/compat/stream-web/runtime.js +51 -0
  399. package/dist/compat/stream-writable/LICENSE-3RD-PARTY.md +13 -0
  400. package/dist/compat/stream-writable/LICENSE-APACHE +177 -0
  401. package/dist/compat/stream-writable/index.cjs +3 -0
  402. package/dist/compat/stream-writable/index.d.cts +2 -0
  403. package/dist/compat/stream-writable/index.d.ts +3 -0
  404. package/dist/compat/stream-writable/index.js +8 -0
  405. package/dist/compat/string-decoder/LICENSE-3RD-PARTY.md +38 -0
  406. package/dist/compat/string-decoder/LICENSE-APACHE +177 -0
  407. package/dist/compat/string-decoder/index.d.ts +33 -0
  408. package/dist/compat/string-decoder/index.js +518 -0
  409. package/dist/compat/test/LICENSE-3RD-PARTY.md +37 -0
  410. package/dist/compat/test/LICENSE-APACHE +177 -0
  411. package/dist/compat/test/index.d.ts +9 -0
  412. package/dist/compat/test/index.js +11 -0
  413. package/dist/compat/test/mock.d.ts +103 -0
  414. package/dist/compat/test/mock.js +397 -0
  415. package/dist/compat/test/validators.d.ts +2 -0
  416. package/dist/compat/test/validators.js +14 -0
  417. package/dist/compat/timers/LICENSE-3RD-PARTY.md +7 -0
  418. package/dist/compat/timers/LICENSE-APACHE +177 -0
  419. package/dist/compat/timers/errors.d.ts +28 -0
  420. package/dist/compat/timers/errors.js +206 -0
  421. package/dist/compat/timers/host.d.ts +11 -0
  422. package/dist/compat/timers/host.js +60 -0
  423. package/dist/compat/timers/index.cjs +3 -0
  424. package/dist/compat/timers/index.d.cts +23 -0
  425. package/dist/compat/timers/index.d.ts +36 -0
  426. package/dist/compat/timers/index.js +20 -0
  427. package/dist/compat/timers/installation.d.ts +4 -0
  428. package/dist/compat/timers/installation.js +61 -0
  429. package/dist/compat/timers/internal-promises.d.ts +19 -0
  430. package/dist/compat/timers/internal-promises.js +173 -0
  431. package/dist/compat/timers/promises.cjs +2 -0
  432. package/dist/compat/timers/promises.d.cts +12 -0
  433. package/dist/compat/timers/promises.d.ts +14 -0
  434. package/dist/compat/timers/promises.js +3 -0
  435. package/dist/compat/timers/timers.d.ts +32 -0
  436. package/dist/compat/timers/timers.js +147 -0
  437. package/dist/compat/timers/validation.d.ts +5 -0
  438. package/dist/compat/timers/validation.js +22 -0
  439. package/dist/compat/timers/wait.d.ts +4 -0
  440. package/dist/compat/timers/wait.js +91 -0
  441. package/dist/compat/tls-common/LICENSE-3RD-PARTY.md +11 -0
  442. package/dist/compat/tls-common/LICENSE-APACHE +177 -0
  443. package/dist/compat/tls-common/index.d.ts +14 -0
  444. package/dist/compat/tls-common/index.js +88 -0
  445. package/dist/compat/trace-events/LICENSE-3RD-PARTY.md +5 -0
  446. package/dist/compat/trace-events/LICENSE-APACHE +177 -0
  447. package/dist/compat/trace-events/index.d.ts +18 -0
  448. package/dist/compat/trace-events/index.js +88 -0
  449. package/dist/compat/tty/LICENSE-3RD-PARTY.md +8 -0
  450. package/dist/compat/tty/LICENSE-APACHE +177 -0
  451. package/dist/compat/tty/index.d.ts +17 -0
  452. package/dist/compat/tty/index.js +101 -0
  453. package/dist/compat/url/LICENSE-3RD-PARTY.md +63 -0
  454. package/dist/compat/url/LICENSE-ADA +18 -0
  455. package/dist/compat/url/LICENSE-APACHE +177 -0
  456. package/dist/compat/url/LICENSE-UNICODE +39 -0
  457. package/dist/compat/url/LICENSE-WHATWG-URL +21 -0
  458. package/dist/compat/url/brand.d.ts +4 -0
  459. package/dist/compat/url/brand.js +10 -0
  460. package/dist/compat/url/constants.d.ts +27 -0
  461. package/dist/compat/url/constants.js +28 -0
  462. package/dist/compat/url/errors.d.ts +44 -0
  463. package/dist/compat/url/errors.js +248 -0
  464. package/dist/compat/url/idna-data.d.ts +3958 -0
  465. package/dist/compat/url/idna-data.js +22 -0
  466. package/dist/compat/url/idna.d.ts +9 -0
  467. package/dist/compat/url/idna.js +47 -0
  468. package/dist/compat/url/index.d.ts +48 -0
  469. package/dist/compat/url/index.js +39 -0
  470. package/dist/compat/url/installation.d.ts +4 -0
  471. package/dist/compat/url/installation.js +61 -0
  472. package/dist/compat/url/internal-url.d.ts +34 -0
  473. package/dist/compat/url/internal-url.js +264 -0
  474. package/dist/compat/url/legacy-url.d.ts +28 -0
  475. package/dist/compat/url/legacy-url.js +870 -0
  476. package/dist/compat/url/parser-platform.d.ts +3 -0
  477. package/dist/compat/url/parser-platform.js +26 -0
  478. package/dist/compat/url/standard-url.d.ts +2 -0
  479. package/dist/compat/url/standard-url.js +3189 -0
  480. package/dist/compat/url/unicode.d.ts +2 -0
  481. package/dist/compat/url/unicode.js +119 -0
  482. package/dist/compat/url/validation.d.ts +2 -0
  483. package/dist/compat/url/validation.js +9 -0
  484. package/dist/compat/url/web-url.d.ts +27 -0
  485. package/dist/compat/url/web-url.js +119 -0
  486. package/dist/compat/util/LICENSE-3RD-PARTY.md +5 -0
  487. package/dist/compat/util/LICENSE-APACHE +177 -0
  488. package/dist/compat/util/additional.d.ts +11 -0
  489. package/dist/compat/util/additional.js +121 -0
  490. package/dist/compat/util/comparison-types.d.ts +16 -0
  491. package/dist/compat/util/comparison-types.js +50 -0
  492. package/dist/compat/util/comparisons.d.ts +1 -0
  493. package/dist/compat/util/comparisons.js +527 -0
  494. package/dist/compat/util/core.d.ts +18 -0
  495. package/dist/compat/util/core.js +265 -0
  496. package/dist/compat/util/debuglog.d.ts +1 -0
  497. package/dist/compat/util/debuglog.js +78 -0
  498. package/dist/compat/util/index.d.ts +35 -0
  499. package/dist/compat/util/index.js +77 -0
  500. package/dist/compat/util/inspect-binding.d.ts +13 -0
  501. package/dist/compat/util/inspect-binding.js +39 -0
  502. package/dist/compat/util/inspect-types.d.ts +13 -0
  503. package/dist/compat/util/inspect-types.js +30 -0
  504. package/dist/compat/util/inspect.d.ts +152 -0
  505. package/dist/compat/util/inspect.js +2503 -0
  506. package/dist/compat/util/mime.d.ts +24 -0
  507. package/dist/compat/util/mime.js +284 -0
  508. package/dist/compat/util/properties.d.ts +9 -0
  509. package/dist/compat/util/properties.js +76 -0
  510. package/dist/compat/v8/LICENSE-3RD-PARTY.md +6 -0
  511. package/dist/compat/v8/LICENSE-APACHE +177 -0
  512. package/dist/compat/v8/errors.d.ts +5 -0
  513. package/dist/compat/v8/errors.js +7 -0
  514. package/dist/compat/v8/index.d.ts +106 -0
  515. package/dist/compat/v8/index.js +280 -0
  516. package/dist/compat/vm/LICENSE-3RD-PARTY.md +39 -0
  517. package/dist/compat/vm/LICENSE-APACHE +177 -0
  518. package/dist/compat/vm/errors.d.ts +5 -0
  519. package/dist/compat/vm/errors.js +7 -0
  520. package/dist/compat/vm/index.d.ts +47 -0
  521. package/dist/compat/vm/index.js +231 -0
  522. package/dist/compat/vm/validation.d.ts +3 -0
  523. package/dist/compat/vm/validation.js +14 -0
  524. package/dist/compat/wasi/LICENSE-3RD-PARTY.md +8 -0
  525. package/dist/compat/wasi/LICENSE-APACHE +177 -0
  526. package/dist/compat/wasi/errors.d.ts +4 -0
  527. package/dist/compat/wasi/errors.js +6 -0
  528. package/dist/compat/wasi/index.d.ts +15 -0
  529. package/dist/compat/wasi/index.js +44 -0
  530. package/dist/compat/worker-threads/LICENSE-3RD-PARTY.md +5 -0
  531. package/dist/compat/worker-threads/LICENSE-APACHE +177 -0
  532. package/dist/compat/worker-threads/errors.d.ts +4 -0
  533. package/dist/compat/worker-threads/errors.js +6 -0
  534. package/dist/compat/worker-threads/index.d.ts +71 -0
  535. package/dist/compat/worker-threads/index.js +138 -0
  536. package/dist/compat/worker-threads/message-channel.d.ts +18 -0
  537. package/dist/compat/worker-threads/message-channel.js +157 -0
  538. package/dist/configured.d.ts +3 -0
  539. package/dist/configured.js +4 -0
  540. package/dist/environment.d.ts +4 -0
  541. package/dist/environment.js +18 -0
  542. package/dist/index.d.ts +11 -0
  543. package/dist/index.js +107 -0
  544. package/dist/ios.d.ts +2 -0
  545. package/dist/ios.js +1 -0
  546. package/dist/native-entry.d.ts +8 -0
  547. package/dist/native-entry.js +67 -0
  548. package/dist/shared/brotli/LICENSE-APACHE +201 -0
  549. package/dist/shared/brotli/LICENSE-MIT +9 -0
  550. package/dist/shared/brotli/NOTICE +3 -0
  551. package/dist/shared/brotli/index.d.ts +2 -0
  552. package/dist/shared/brotli/index.js +288 -0
  553. package/dist/shared/contracts/index.d.ts +42 -0
  554. package/dist/shared/contracts/index.js +88 -0
  555. package/dist/shared/contracts/testing.d.ts +22 -0
  556. package/dist/shared/contracts/testing.js +57 -0
  557. package/dist/shared/globals/index.d.ts +3 -0
  558. package/dist/shared/globals/index.js +87 -0
  559. package/dist/shared/globals/inject.d.ts +2 -0
  560. package/dist/shared/globals/inject.js +3 -0
  561. package/dist/shared/globals/install.d.ts +1 -0
  562. package/dist/shared/globals/install.js +15 -0
  563. package/dist/shared/globals/node-install.d.ts +1 -0
  564. package/dist/shared/globals/node-install.js +4 -0
  565. package/dist/shared/globals/platform.d.ts +104 -0
  566. package/dist/shared/globals/platform.js +37 -0
  567. package/dist/shared/globals/runtime.d.ts +6 -0
  568. package/dist/shared/globals/runtime.js +8 -0
  569. package/dist/shared/globals/symbols.d.ts +4 -0
  570. package/dist/shared/globals/symbols.js +35 -0
  571. package/dist/shared/globals/web.d.ts +4 -0
  572. package/dist/shared/globals/web.js +108 -0
  573. package/dist/shared/http-wire/LICENSE.llhttp +22 -0
  574. package/dist/shared/http-wire/LICENSE.undici +21 -0
  575. package/dist/shared/http-wire/NOTICE.md +14 -0
  576. package/dist/shared/http-wire/index.d.ts +27 -0
  577. package/dist/shared/http-wire/index.js +132 -0
  578. package/dist/shared/http-wire/wasm.d.ts +2 -0
  579. package/dist/shared/http-wire/wasm.js +2 -0
  580. package/dist/tooling/async.d.ts +7 -0
  581. package/dist/tooling/async.js +99 -0
  582. package/dist/tooling/build-isolation.d.ts +4 -0
  583. package/dist/tooling/build-isolation.js +34 -0
  584. package/dist/tooling/documents.d.ts +7 -0
  585. package/dist/tooling/documents.js +26 -0
  586. package/dist/tooling/esbuild.d.ts +15 -0
  587. package/dist/tooling/esbuild.js +193 -0
  588. package/dist/tooling/files.d.ts +2 -0
  589. package/dist/tooling/files.js +18 -0
  590. package/dist/tooling/opennext/build.d.ts +1 -0
  591. package/dist/tooling/opennext/build.js +121 -0
  592. package/dist/tooling/opennext/index.d.ts +3 -0
  593. package/dist/tooling/opennext/index.js +213 -0
  594. package/dist/tooling/opennext/plan.d.ts +9 -0
  595. package/dist/tooling/opennext/plan.js +36 -0
  596. package/dist/tooling/opennext/safety.d.ts +4 -0
  597. package/dist/tooling/opennext/safety.js +36 -0
  598. package/dist/tooling/route-permissions.d.ts +3 -0
  599. package/dist/tooling/route-permissions.js +15 -0
  600. package/dist/tooling/server-modules.d.ts +30 -0
  601. package/dist/tooling/server-modules.js +98 -0
  602. package/dist/tooling/server-only-html.d.ts +1 -0
  603. package/dist/tooling/server-only-html.js +66 -0
  604. package/dist/tooling/server-only.d.ts +6 -0
  605. package/dist/tooling/server-only.js +53 -0
  606. package/dist/tooling/server.d.ts +25 -0
  607. package/dist/tooling/server.js +981 -0
  608. package/dist/tooling/shared.d.ts +13 -0
  609. package/dist/tooling/shared.js +130 -0
  610. package/dist/tooling/vite.d.ts +18 -0
  611. package/dist/tooling/vite.js +448 -0
  612. package/dist/tooling/void/index.d.ts +3 -0
  613. package/dist/tooling/void/index.js +205 -0
  614. package/dist/tooling/void/plan.d.ts +17 -0
  615. package/dist/tooling/void/plan.js +288 -0
  616. package/native/android/build.gradle +68 -0
  617. package/native/android/consumer-rules.pro +2 -0
  618. package/native/android/src/main/AndroidManifest.xml +6 -0
  619. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +202 -0
  620. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +256 -0
  621. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNative.java +22 -0
  622. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeActivity.java +178 -0
  623. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeBridge.java +45 -0
  624. package/native/ios/DocumentBridge.swift +330 -0
  625. package/native/ios/NetworkBridge.swift +51 -0
  626. package/native/ios/SocketBridge.swift +180 -0
  627. package/native/ios/WorkersCapacitorPlugin.swift +152 -0
  628. package/native/ios-host/WorkersView.swift +194 -0
  629. package/package.json +154 -4
@@ -0,0 +1,1542 @@
1
+ // Vendored from cloudflare/workerd v1.20261012.1 (src/node/internal/internal_path.ts),
2
+ // which is itself adapted from Node.js lib/path.js.
3
+ //
4
+ // Copyright (c) 2026 Cloudflare, Inc.
5
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
6
+ // https://opensource.org/licenses/Apache-2.0
7
+ //
8
+ // Copyright Joyent, Inc. and other Node contributors.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a
11
+ // copy of this software and associated documentation files (the
12
+ // "Software"), to deal in the Software without restriction, including
13
+ // without limitation the rights to use, copy, modify, merge, publish,
14
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
15
+ // persons to whom the Software is furnished to do so, subject to the
16
+ // following conditions:
17
+ //
18
+ // The above copyright notice and this permission notice shall be included
19
+ // in all copies or substantial portions of the Software.
20
+ //
21
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
24
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ //
29
+ // Workers differences vs Node lib/path.js, preserved from workerd: the
30
+ // virtual process cwd is hardcoded to '/', there are no per-drive cwd
31
+ // environment lookups, and matchesGlob reproduces Workers' not-implemented
32
+ // rejection.
33
+ const CHAR_DOT = 46;
34
+ const CHAR_FORWARD_SLASH = 47;
35
+ const CHAR_COLON = 58;
36
+ const CHAR_UPPERCASE_A = 65;
37
+ const CHAR_UPPERCASE_Z = 90;
38
+ const CHAR_LOWERCASE_A = 97;
39
+ const CHAR_LOWERCASE_Z = 122;
40
+ const CHAR_BACKWARD_SLASH = 92;
41
+ const CHAR_QUESTION_MARK = 63;
42
+ // Minimal reproduction of node-internal:validators/errors used by this
43
+ // module: TypeError instances carrying the Node error code.
44
+ const classRegExp = /^([A-Z][a-z0-9]*)+$/;
45
+ const kTypes = [
46
+ "string",
47
+ "function",
48
+ "number",
49
+ "object",
50
+ "Function",
51
+ "Object",
52
+ "boolean",
53
+ "bigint",
54
+ "symbol",
55
+ ];
56
+ function inspect(input) {
57
+ if (typeof input === "string")
58
+ return `'${input}'`;
59
+ if (typeof input === "symbol")
60
+ return String(input);
61
+ if (typeof input === "object" && input !== null) {
62
+ // Fixed rendering for constructor-less objects: never enumerates
63
+ // properties and never invokes getters, so cyclic inputs and
64
+ // side-effectful properties cannot fail or run user code here.
65
+ if (Array.isArray(input))
66
+ return "[ Array ]";
67
+ return Object.getPrototypeOf(input) === null
68
+ ? "[Object: null prototype] {}"
69
+ : "{}";
70
+ }
71
+ return `${input}`;
72
+ }
73
+ function createInvalidArgType(name, expected) {
74
+ const expectedList = Array.isArray(expected) ? expected : [expected];
75
+ let msg = "The ";
76
+ if (name.endsWith(" argument")) {
77
+ msg += `${name} `;
78
+ }
79
+ else {
80
+ const type = name.includes(".") ? "property" : "argument";
81
+ msg += `"${name}" ${type} `;
82
+ }
83
+ msg += "must be ";
84
+ const types = [];
85
+ const instances = [];
86
+ const other = [];
87
+ for (const value of expectedList) {
88
+ if (kTypes.includes(value)) {
89
+ types.push(value.toLocaleLowerCase());
90
+ }
91
+ else if (classRegExp.test(value)) {
92
+ instances.push(value);
93
+ }
94
+ else {
95
+ other.push(value);
96
+ }
97
+ }
98
+ if (instances.length > 0) {
99
+ const pos = types.indexOf("object");
100
+ if (pos !== -1) {
101
+ types.splice(pos, 1);
102
+ instances.push("Object");
103
+ }
104
+ }
105
+ if (types.length > 0) {
106
+ if (types.length > 2) {
107
+ const last = types.pop();
108
+ msg += `one of type ${types.join(", ")}, or ${last}`;
109
+ }
110
+ else if (types.length === 2) {
111
+ msg += `one of type ${types[0]} or ${types[1]}`;
112
+ }
113
+ else {
114
+ msg += `of type ${types[0]}`;
115
+ }
116
+ if (instances.length > 0 || other.length > 0) {
117
+ msg += " or ";
118
+ }
119
+ }
120
+ if (instances.length > 0) {
121
+ if (instances.length > 2) {
122
+ const last = instances.pop();
123
+ msg += `an instance of ${instances.join(", ")}, or ${last}`;
124
+ }
125
+ else {
126
+ msg += `an instance of ${instances[0]}`;
127
+ if (instances.length === 2) {
128
+ msg += ` or ${instances[1]}`;
129
+ }
130
+ }
131
+ if (other.length > 0) {
132
+ msg += " or ";
133
+ }
134
+ }
135
+ if (other.length > 0) {
136
+ if (other.length > 2) {
137
+ const last = other.pop();
138
+ msg += `one of ${other.join(", ")}, or ${last}`;
139
+ }
140
+ else if (other.length === 2) {
141
+ msg += `one of ${other[0]} or ${other[1]}`;
142
+ }
143
+ else {
144
+ const first = other[0];
145
+ if (first.toLowerCase() !== first) {
146
+ msg += "an ";
147
+ }
148
+ msg += `${first}`;
149
+ }
150
+ }
151
+ return msg;
152
+ }
153
+ function invalidArgTypeHelper(input) {
154
+ if (input == null) {
155
+ return ` Received ${input}`;
156
+ }
157
+ if (typeof input === "function" && input.name) {
158
+ return ` Received function ${input.name}`;
159
+ }
160
+ if (typeof input === "object") {
161
+ const ctor = input.constructor;
162
+ if (ctor?.name) {
163
+ return ` Received an instance of ${ctor.name}`;
164
+ }
165
+ return ` Received ${inspect(input)}`;
166
+ }
167
+ let inspected = inspect(input);
168
+ if (inspected.length > 25) {
169
+ inspected = `${inspected.slice(0, 25)}...`;
170
+ }
171
+ return ` Received type ${typeof input} (${inspected})`;
172
+ }
173
+ class ERR_INVALID_ARG_TYPE extends TypeError {
174
+ code;
175
+ constructor(name, expected, actual) {
176
+ super(`${createInvalidArgType(name, expected)}.${invalidArgTypeHelper(actual)}`);
177
+ this.code = "ERR_INVALID_ARG_TYPE";
178
+ }
179
+ }
180
+ function validateString(value, name) {
181
+ if (typeof value !== "string") {
182
+ throw new ERR_INVALID_ARG_TYPE(name, "string", value);
183
+ }
184
+ }
185
+ function validateObject(value, name) {
186
+ if (value === null || Array.isArray(value) || typeof value !== "object") {
187
+ throw new ERR_INVALID_ARG_TYPE(name, "Object", value);
188
+ }
189
+ }
190
+ function isPathSeparator(code) {
191
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
192
+ }
193
+ function isPosixPathSeparator(code) {
194
+ return code === CHAR_FORWARD_SLASH;
195
+ }
196
+ function isWindowsDeviceRoot(code) {
197
+ return ((code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
198
+ (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z));
199
+ }
200
+ // Resolves . and .. elements in a path with directory names
201
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
202
+ let res = "";
203
+ let lastSegmentLength = 0;
204
+ let lastSlash = -1;
205
+ let dots = 0;
206
+ let code = 0;
207
+ for (let i = 0; i <= path.length; ++i) {
208
+ if (i < path.length)
209
+ code = path.charCodeAt(i);
210
+ else if (isPathSeparator(code))
211
+ break;
212
+ else
213
+ code = CHAR_FORWARD_SLASH;
214
+ if (isPathSeparator(code)) {
215
+ if (lastSlash === i - 1 || dots === 1) {
216
+ // NOOP
217
+ }
218
+ else if (dots === 2) {
219
+ if (res.length < 2 ||
220
+ lastSegmentLength !== 2 ||
221
+ res.charCodeAt(res.length - 1) !== CHAR_DOT ||
222
+ res.charCodeAt(res.length - 2) !== CHAR_DOT) {
223
+ if (res.length > 2) {
224
+ const lastSlashIndex = res.lastIndexOf(separator);
225
+ if (lastSlashIndex === -1) {
226
+ res = "";
227
+ lastSegmentLength = 0;
228
+ }
229
+ else {
230
+ res = res.slice(0, lastSlashIndex);
231
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
232
+ }
233
+ lastSlash = i;
234
+ dots = 0;
235
+ continue;
236
+ }
237
+ else if (res.length !== 0) {
238
+ res = "";
239
+ lastSegmentLength = 0;
240
+ lastSlash = i;
241
+ dots = 0;
242
+ continue;
243
+ }
244
+ }
245
+ if (allowAboveRoot) {
246
+ res += res.length > 0 ? `${separator}..` : "..";
247
+ lastSegmentLength = 2;
248
+ }
249
+ }
250
+ else {
251
+ if (res.length > 0)
252
+ res += `${separator}${path.slice(lastSlash + 1, i)}`;
253
+ else
254
+ res = path.slice(lastSlash + 1, i);
255
+ lastSegmentLength = i - lastSlash - 1;
256
+ }
257
+ lastSlash = i;
258
+ dots = 0;
259
+ }
260
+ else if (code === CHAR_DOT && dots !== -1) {
261
+ ++dots;
262
+ }
263
+ else {
264
+ dots = -1;
265
+ }
266
+ }
267
+ return res;
268
+ }
269
+ function formatExt(ext) {
270
+ return ext ? `${ext[0] === "." ? "" : "."}${ext}` : "";
271
+ }
272
+ function _format(sep, pathObject) {
273
+ validateObject(pathObject, "pathObject");
274
+ const dir = pathObject.dir || pathObject.root;
275
+ const base = pathObject.base ||
276
+ `${pathObject.name || ""}${formatExt(pathObject.ext)}`;
277
+ if (!dir) {
278
+ return base;
279
+ }
280
+ return dir === pathObject.root ? `${dir}${base}` : `${dir}${sep}${base}`;
281
+ }
282
+ const win32 = {
283
+ resolve(...args) {
284
+ let resolvedDevice = "";
285
+ let resolvedTail = "";
286
+ let resolvedAbsolute = false;
287
+ for (let i = args.length - 1; i >= -1; i--) {
288
+ let path;
289
+ if (i >= 0) {
290
+ path = args[i];
291
+ validateString(path, `paths[${i}]`);
292
+ // Skip empty entries
293
+ if (path.length === 0) {
294
+ continue;
295
+ }
296
+ }
297
+ else if (resolvedDevice.length === 0) {
298
+ path = "/";
299
+ }
300
+ else {
301
+ // Windows has the concept of drive-specific current working
302
+ // directories. If we've resolved a drive letter but not yet an
303
+ // absolute path, get cwd for that drive, or the process cwd if
304
+ // the drive cwd is not available. We're sure the device is not
305
+ // a UNC path at this points, because UNC paths are always absolute.
306
+ path = "/";
307
+ // Verify that a cwd was found and that it actually points
308
+ // to our drive. If not, default to the drive's root.
309
+ if (path.slice(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() &&
310
+ path.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
311
+ path = `${resolvedDevice}\\`;
312
+ }
313
+ }
314
+ const len = path.length;
315
+ let rootEnd = 0;
316
+ let device = "";
317
+ let isAbsolute = false;
318
+ const code = path.charCodeAt(0);
319
+ // Try to match a root
320
+ if (len === 1) {
321
+ if (isPathSeparator(code)) {
322
+ // `path` contains just a path separator
323
+ rootEnd = 1;
324
+ isAbsolute = true;
325
+ }
326
+ }
327
+ else if (isPathSeparator(code)) {
328
+ // Possible UNC root
329
+ // If we started with a separator, we know we at least have an
330
+ // absolute path of some kind (UNC or otherwise)
331
+ isAbsolute = true;
332
+ if (isPathSeparator(path.charCodeAt(1))) {
333
+ // Matched double path separator at beginning
334
+ let j = 2;
335
+ let last = j;
336
+ // Match 1 or more non-path separators
337
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
338
+ j++;
339
+ }
340
+ if (j < len && j !== last) {
341
+ const firstPart = path.slice(last, j);
342
+ // Matched!
343
+ last = j;
344
+ // Match 1 or more path separators
345
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
346
+ j++;
347
+ }
348
+ if (j < len && j !== last) {
349
+ // Matched!
350
+ last = j;
351
+ // Match 1 or more non-path separators
352
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
353
+ j++;
354
+ }
355
+ if (j === len || j !== last) {
356
+ // We matched a UNC root
357
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
358
+ rootEnd = j;
359
+ }
360
+ }
361
+ }
362
+ }
363
+ else {
364
+ rootEnd = 1;
365
+ }
366
+ }
367
+ else if (isWindowsDeviceRoot(code) &&
368
+ path.charCodeAt(1) === CHAR_COLON) {
369
+ // Possible device root
370
+ device = path.slice(0, 2);
371
+ rootEnd = 2;
372
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
373
+ // Treat separator following drive name as an absolute path
374
+ // indicator
375
+ isAbsolute = true;
376
+ rootEnd = 3;
377
+ }
378
+ }
379
+ if (device.length > 0) {
380
+ if (resolvedDevice.length > 0) {
381
+ if (device.toLowerCase() !== resolvedDevice.toLowerCase())
382
+ // This path points to another device so it is not applicable
383
+ continue;
384
+ }
385
+ else {
386
+ resolvedDevice = device;
387
+ }
388
+ }
389
+ if (resolvedAbsolute) {
390
+ if (resolvedDevice.length > 0)
391
+ break;
392
+ }
393
+ else {
394
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
395
+ resolvedAbsolute = isAbsolute;
396
+ if (isAbsolute && resolvedDevice.length > 0) {
397
+ break;
398
+ }
399
+ }
400
+ }
401
+ // At this point the path should be resolved to a full absolute path,
402
+ // but handle relative paths to be safe (might happen when process.cwd()
403
+ // fails)
404
+ // Normalize the tail path
405
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
406
+ return resolvedAbsolute
407
+ ? `${resolvedDevice}\\${resolvedTail}`
408
+ : `${resolvedDevice}${resolvedTail}` || ".";
409
+ },
410
+ normalize(path) {
411
+ validateString(path, "path");
412
+ const len = path.length;
413
+ if (len === 0)
414
+ return ".";
415
+ let rootEnd = 0;
416
+ let device;
417
+ let isAbsolute = false;
418
+ const code = path.charCodeAt(0);
419
+ // Try to match a root
420
+ if (len === 1) {
421
+ // `path` contains just a single char, exit early to avoid
422
+ // unnecessary work
423
+ return isPosixPathSeparator(code) ? "\\" : path;
424
+ }
425
+ if (isPathSeparator(code)) {
426
+ // Possible UNC root
427
+ // If we started with a separator, we know we at least have an absolute
428
+ // path of some kind (UNC or otherwise)
429
+ isAbsolute = true;
430
+ if (isPathSeparator(path.charCodeAt(1))) {
431
+ // Matched double path separator at beginning
432
+ let j = 2;
433
+ let last = j;
434
+ // Match 1 or more non-path separators
435
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
436
+ j++;
437
+ }
438
+ if (j < len && j !== last) {
439
+ const firstPart = path.slice(last, j);
440
+ // Matched!
441
+ last = j;
442
+ // Match 1 or more path separators
443
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
444
+ j++;
445
+ }
446
+ if (j < len && j !== last) {
447
+ // Matched!
448
+ last = j;
449
+ // Match 1 or more non-path separators
450
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
451
+ j++;
452
+ }
453
+ if (j === len) {
454
+ // We matched a UNC root only
455
+ // Return the normalized version of the UNC root since there
456
+ // is nothing left to process
457
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
458
+ }
459
+ if (j !== last) {
460
+ // We matched a UNC root with leftovers
461
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
462
+ rootEnd = j;
463
+ }
464
+ }
465
+ }
466
+ }
467
+ else {
468
+ rootEnd = 1;
469
+ }
470
+ }
471
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
472
+ // Possible device root
473
+ device = path.slice(0, 2);
474
+ rootEnd = 2;
475
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
476
+ // Treat separator following drive name as an absolute path
477
+ // indicator
478
+ isAbsolute = true;
479
+ rootEnd = 3;
480
+ }
481
+ }
482
+ let tail = rootEnd < len
483
+ ? normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator)
484
+ : "";
485
+ if (tail.length === 0 && !isAbsolute)
486
+ tail = ".";
487
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1)))
488
+ tail += "\\";
489
+ if (device === undefined) {
490
+ return isAbsolute ? `\\${tail}` : tail;
491
+ }
492
+ return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
493
+ },
494
+ isAbsolute(path) {
495
+ validateString(path, "path");
496
+ const len = path.length;
497
+ if (len === 0)
498
+ return false;
499
+ const code = path.charCodeAt(0);
500
+ return (isPathSeparator(code) ||
501
+ // Possible device root
502
+ (len > 2 &&
503
+ isWindowsDeviceRoot(code) &&
504
+ path.charCodeAt(1) === CHAR_COLON &&
505
+ isPathSeparator(path.charCodeAt(2))));
506
+ },
507
+ join(...args) {
508
+ if (args.length === 0)
509
+ return ".";
510
+ let joined;
511
+ let firstPart;
512
+ for (let i = 0; i < args.length; ++i) {
513
+ const arg = args[i];
514
+ validateString(arg, "path");
515
+ if (arg.length > 0) {
516
+ if (joined === undefined) {
517
+ joined = arg;
518
+ firstPart = arg;
519
+ }
520
+ else
521
+ joined += `\\${arg}`;
522
+ }
523
+ }
524
+ if (joined === undefined || firstPart === undefined)
525
+ return ".";
526
+ // Make sure that the joined path doesn't start with two slashes, because
527
+ // normalize() will mistake it for a UNC path then.
528
+ //
529
+ // This step is skipped when it is very clear that the user actually
530
+ // intended to point at a UNC path. This is assumed when the first
531
+ // non-empty string arguments starts with exactly two slashes followed by
532
+ // at least one more non-slash character.
533
+ //
534
+ // Note that for normalize() to treat a path as a UNC path it needs to
535
+ // have at least 2 components, so we don't filter for that here.
536
+ // This means that the user can use join to construct UNC paths from
537
+ // a server name and a share name; for example:
538
+ // path.join('//server', 'share') -> '\\\\server\\share\\')
539
+ let needsReplace = true;
540
+ let slashCount = 0;
541
+ if (isPathSeparator(firstPart.charCodeAt(0))) {
542
+ ++slashCount;
543
+ const firstLen = firstPart.length;
544
+ if (firstLen > 1 && isPathSeparator(firstPart.charCodeAt(1))) {
545
+ ++slashCount;
546
+ if (firstLen > 2) {
547
+ if (isPathSeparator(firstPart.charCodeAt(2)))
548
+ ++slashCount;
549
+ else {
550
+ // We matched a UNC path in the first part
551
+ needsReplace = false;
552
+ }
553
+ }
554
+ }
555
+ }
556
+ if (needsReplace) {
557
+ // Find any more consecutive slashes we need to replace
558
+ while (slashCount < joined.length &&
559
+ isPathSeparator(joined.charCodeAt(slashCount))) {
560
+ slashCount++;
561
+ }
562
+ // Replace the slashes if needed
563
+ if (slashCount >= 2)
564
+ joined = `\\${joined.slice(slashCount)}`;
565
+ }
566
+ return win32.normalize(joined);
567
+ },
568
+ relative(from, to) {
569
+ validateString(from, "from");
570
+ validateString(to, "to");
571
+ if (from === to)
572
+ return "";
573
+ const fromOrig = win32.resolve(from);
574
+ const toOrig = win32.resolve(to);
575
+ if (fromOrig === toOrig)
576
+ return "";
577
+ from = fromOrig.toLowerCase();
578
+ to = toOrig.toLowerCase();
579
+ if (from === to)
580
+ return "";
581
+ if (fromOrig.length !== from.length || toOrig.length !== to.length) {
582
+ const fromSplit = fromOrig.split("\\");
583
+ const toSplit = toOrig.split("\\");
584
+ if (fromSplit[fromSplit.length - 1] === "") {
585
+ fromSplit.pop();
586
+ }
587
+ if (toSplit[toSplit.length - 1] === "") {
588
+ toSplit.pop();
589
+ }
590
+ const fromLen = fromSplit.length;
591
+ const toLen = toSplit.length;
592
+ const length = fromLen < toLen ? fromLen : toLen;
593
+ let i;
594
+ for (i = 0; i < length; i++) {
595
+ if (fromSplit[i]?.toLowerCase() !== toSplit[i]?.toLowerCase()) {
596
+ break;
597
+ }
598
+ }
599
+ if (i === 0) {
600
+ return toOrig;
601
+ }
602
+ else if (i === length) {
603
+ if (toLen > length) {
604
+ return toSplit.slice(i).join("\\");
605
+ }
606
+ if (fromLen > length) {
607
+ return "..\\".repeat(fromLen - 1 - i) + "..";
608
+ }
609
+ return "";
610
+ }
611
+ return "..\\".repeat(fromLen - i) + toSplit.slice(i).join("\\");
612
+ }
613
+ // Trim any leading backslashes
614
+ let fromStart = 0;
615
+ while (fromStart < from.length &&
616
+ from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
617
+ fromStart++;
618
+ }
619
+ // Trim trailing backslashes (applicable to UNC paths only)
620
+ let fromEnd = from.length;
621
+ while (fromEnd - 1 > fromStart &&
622
+ from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
623
+ fromEnd--;
624
+ }
625
+ const fromLen = fromEnd - fromStart;
626
+ // Trim any leading backslashes
627
+ let toStart = 0;
628
+ while (toStart < to.length &&
629
+ to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
630
+ toStart++;
631
+ }
632
+ // Trim trailing backslashes (applicable to UNC paths only)
633
+ let toEnd = to.length;
634
+ while (toEnd - 1 > toStart &&
635
+ to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
636
+ toEnd--;
637
+ }
638
+ const toLen = toEnd - toStart;
639
+ // Compare paths to find the longest common path from root
640
+ const length = fromLen < toLen ? fromLen : toLen;
641
+ let lastCommonSep = -1;
642
+ let i = 0;
643
+ for (; i < length; i++) {
644
+ const fromCode = from.charCodeAt(fromStart + i);
645
+ if (fromCode !== to.charCodeAt(toStart + i))
646
+ break;
647
+ else if (fromCode === CHAR_BACKWARD_SLASH)
648
+ lastCommonSep = i;
649
+ }
650
+ // We found a mismatch before the first common path separator was seen, so
651
+ // return the original `to`.
652
+ if (i !== length) {
653
+ if (lastCommonSep === -1)
654
+ return toOrig;
655
+ }
656
+ else {
657
+ if (toLen > length) {
658
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
659
+ // We get here if `from` is the exact base path for `to`.
660
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
661
+ return toOrig.slice(toStart + i + 1);
662
+ }
663
+ if (i === 2) {
664
+ // We get here if `from` is the device root.
665
+ // For example: from='C:\\'; to='C:\\foo'
666
+ return toOrig.slice(toStart + i);
667
+ }
668
+ }
669
+ if (fromLen > length) {
670
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
671
+ // We get here if `to` is the exact base path for `from`.
672
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
673
+ lastCommonSep = i;
674
+ }
675
+ else if (i === 2) {
676
+ // We get here if `to` is the device root.
677
+ // For example: from='C:\\foo\\bar'; to='C:\\'
678
+ lastCommonSep = 3;
679
+ }
680
+ }
681
+ if (lastCommonSep === -1)
682
+ lastCommonSep = 0;
683
+ }
684
+ let out = "";
685
+ // Generate the relative path based on the path difference between `to` and
686
+ // `from`
687
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
688
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
689
+ out += out.length === 0 ? ".." : "\\..";
690
+ }
691
+ }
692
+ toStart += lastCommonSep;
693
+ // Lastly, append the rest of the destination (`to`) path that comes after
694
+ // the common path parts
695
+ if (out.length > 0)
696
+ return `${out}${toOrig.slice(toStart, toEnd)}`;
697
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH)
698
+ ++toStart;
699
+ return toOrig.slice(toStart, toEnd);
700
+ },
701
+ toNamespacedPath(path) {
702
+ // Note: this will *probably* throw somewhere.
703
+ if (typeof path !== "string" || path.length === 0)
704
+ return path;
705
+ const resolvedPath = win32.resolve(path);
706
+ if (resolvedPath.length <= 2)
707
+ return path;
708
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
709
+ // Possible UNC root
710
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
711
+ const code = resolvedPath.charCodeAt(2);
712
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
713
+ // Matched non-long UNC root, convert the path to a long UNC path
714
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
715
+ }
716
+ }
717
+ }
718
+ else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) &&
719
+ resolvedPath.charCodeAt(1) === CHAR_COLON &&
720
+ resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
721
+ // Matched device root, convert the path to a long UNC path
722
+ return `\\\\?\\${resolvedPath}`;
723
+ }
724
+ return resolvedPath;
725
+ },
726
+ dirname(path) {
727
+ validateString(path, "path");
728
+ const len = path.length;
729
+ if (len === 0)
730
+ return ".";
731
+ let rootEnd = -1;
732
+ let offset = 0;
733
+ const code = path.charCodeAt(0);
734
+ if (len === 1) {
735
+ // `path` contains just a path separator, exit early to avoid
736
+ // unnecessary work or a dot.
737
+ return isPathSeparator(code) ? path : ".";
738
+ }
739
+ // Try to match a root
740
+ if (isPathSeparator(code)) {
741
+ // Possible UNC root
742
+ rootEnd = offset = 1;
743
+ if (isPathSeparator(path.charCodeAt(1))) {
744
+ // Matched double path separator at beginning
745
+ let j = 2;
746
+ let last = j;
747
+ // Match 1 or more non-path separators
748
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
749
+ j++;
750
+ }
751
+ if (j < len && j !== last) {
752
+ // Matched!
753
+ last = j;
754
+ // Match 1 or more path separators
755
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
756
+ j++;
757
+ }
758
+ if (j < len && j !== last) {
759
+ // Matched!
760
+ last = j;
761
+ // Match 1 or more non-path separators
762
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
763
+ j++;
764
+ }
765
+ if (j === len) {
766
+ // We matched a UNC root only
767
+ return path;
768
+ }
769
+ if (j !== last) {
770
+ // We matched a UNC root with leftovers
771
+ // Offset by 1 to include the separator after the UNC root to
772
+ // treat it as a "normal root" on top of a (UNC) root
773
+ rootEnd = offset = j + 1;
774
+ }
775
+ }
776
+ }
777
+ }
778
+ // Possible device root
779
+ }
780
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
781
+ rootEnd = len > 2 && isPathSeparator(path.charCodeAt(2)) ? 3 : 2;
782
+ offset = rootEnd;
783
+ }
784
+ let end = -1;
785
+ let matchedSlash = true;
786
+ for (let i = len - 1; i >= offset; --i) {
787
+ if (isPathSeparator(path.charCodeAt(i))) {
788
+ if (!matchedSlash) {
789
+ end = i;
790
+ break;
791
+ }
792
+ }
793
+ else {
794
+ // We saw the first non-path separator
795
+ matchedSlash = false;
796
+ }
797
+ }
798
+ if (end === -1) {
799
+ if (rootEnd === -1)
800
+ return ".";
801
+ end = rootEnd;
802
+ }
803
+ return path.slice(0, end);
804
+ },
805
+ basename(path, suffix) {
806
+ if (suffix !== undefined)
807
+ validateString(suffix, "suffix");
808
+ validateString(path, "path");
809
+ let start = 0;
810
+ let end = -1;
811
+ let matchedSlash = true;
812
+ // Check for a drive letter prefix so as not to mistake the following
813
+ // path separator as an extra separator at the end of the path that can be
814
+ // disregarded
815
+ if (path.length >= 2 &&
816
+ isWindowsDeviceRoot(path.charCodeAt(0)) &&
817
+ path.charCodeAt(1) === CHAR_COLON) {
818
+ start = 2;
819
+ }
820
+ if (suffix !== undefined &&
821
+ suffix.length > 0 &&
822
+ suffix.length <= path.length) {
823
+ if (suffix === path)
824
+ return "";
825
+ let extIdx = suffix.length - 1;
826
+ let firstNonSlashEnd = -1;
827
+ for (let i = path.length - 1; i >= start; --i) {
828
+ const code = path.charCodeAt(i);
829
+ if (isPathSeparator(code)) {
830
+ // If we reached a path separator that was not part of a set of path
831
+ // separators at the end of the string, stop now
832
+ if (!matchedSlash) {
833
+ start = i + 1;
834
+ break;
835
+ }
836
+ }
837
+ else {
838
+ if (firstNonSlashEnd === -1) {
839
+ // We saw the first non-path separator, remember this index in case
840
+ // we need it if the extension ends up not matching
841
+ matchedSlash = false;
842
+ firstNonSlashEnd = i + 1;
843
+ }
844
+ if (extIdx >= 0) {
845
+ // Try to match the explicit extension
846
+ if (code === suffix.charCodeAt(extIdx)) {
847
+ if (--extIdx === -1) {
848
+ // We matched the extension, so mark this as the end of our path
849
+ // component
850
+ end = i;
851
+ }
852
+ }
853
+ else {
854
+ // Extension does not match, so our result is the entire path
855
+ // component
856
+ extIdx = -1;
857
+ end = firstNonSlashEnd;
858
+ }
859
+ }
860
+ }
861
+ }
862
+ if (start === end)
863
+ end = firstNonSlashEnd;
864
+ else if (end === -1)
865
+ end = path.length;
866
+ return path.slice(start, end);
867
+ }
868
+ for (let i = path.length - 1; i >= start; --i) {
869
+ if (isPathSeparator(path.charCodeAt(i))) {
870
+ // If we reached a path separator that was not part of a set of path
871
+ // separators at the end of the string, stop now
872
+ if (!matchedSlash) {
873
+ start = i + 1;
874
+ break;
875
+ }
876
+ }
877
+ else if (end === -1) {
878
+ // We saw the first non-path separator, mark this as the end of our
879
+ // path component
880
+ matchedSlash = false;
881
+ end = i + 1;
882
+ }
883
+ }
884
+ if (end === -1)
885
+ return "";
886
+ return path.slice(start, end);
887
+ },
888
+ extname(path) {
889
+ validateString(path, "path");
890
+ let start = 0;
891
+ let startDot = -1;
892
+ let startPart = 0;
893
+ let end = -1;
894
+ let matchedSlash = true;
895
+ // Track the state of characters (if any) we see before our first dot and
896
+ // after any path separator we find
897
+ let preDotState = 0;
898
+ // Check for a drive letter prefix so as not to mistake the following
899
+ // path separator as an extra separator at the end of the path that can be
900
+ // disregarded
901
+ if (path.length >= 2 &&
902
+ path.charCodeAt(1) === CHAR_COLON &&
903
+ isWindowsDeviceRoot(path.charCodeAt(0))) {
904
+ start = startPart = 2;
905
+ }
906
+ for (let i = path.length - 1; i >= start; --i) {
907
+ const code = path.charCodeAt(i);
908
+ if (isPathSeparator(code)) {
909
+ // If we reached a path separator that was not part of a set of path
910
+ // separators at the end of the string, stop now
911
+ if (!matchedSlash) {
912
+ startPart = i + 1;
913
+ break;
914
+ }
915
+ continue;
916
+ }
917
+ if (end === -1) {
918
+ // We saw the first non-path separator, mark this as the end of our
919
+ // extension
920
+ matchedSlash = false;
921
+ end = i + 1;
922
+ }
923
+ if (code === CHAR_DOT) {
924
+ // If this is our first dot, mark it as the start of our extension
925
+ if (startDot === -1)
926
+ startDot = i;
927
+ else if (preDotState !== 1)
928
+ preDotState = 1;
929
+ }
930
+ else if (startDot !== -1) {
931
+ // We saw a non-dot and non-path separator before our dot, so we should
932
+ // have a good chance at having a non-empty extension
933
+ preDotState = -1;
934
+ }
935
+ }
936
+ if (startDot === -1 ||
937
+ end === -1 ||
938
+ // We saw a non-dot character immediately before the dot
939
+ preDotState === 0 ||
940
+ // The (right-most) trimmed path component is exactly '..'
941
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
942
+ return "";
943
+ }
944
+ return path.slice(startDot, end);
945
+ },
946
+ format(path) {
947
+ return _format("\\", path);
948
+ },
949
+ parse(path) {
950
+ validateString(path, "path");
951
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
952
+ if (path.length === 0)
953
+ return ret;
954
+ const len = path.length;
955
+ let rootEnd = 0;
956
+ let code = path.charCodeAt(0);
957
+ if (len === 1) {
958
+ if (isPathSeparator(code)) {
959
+ // `path` contains just a path separator, exit early to avoid
960
+ // unnecessary work
961
+ ret.root = ret.dir = path;
962
+ return ret;
963
+ }
964
+ ret.base = ret.name = path;
965
+ return ret;
966
+ }
967
+ // Try to match a root
968
+ if (isPathSeparator(code)) {
969
+ // Possible UNC root
970
+ rootEnd = 1;
971
+ if (isPathSeparator(path.charCodeAt(1))) {
972
+ // Matched double path separator at beginning
973
+ let j = 2;
974
+ let last = j;
975
+ // Match 1 or more non-path separators
976
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
977
+ j++;
978
+ }
979
+ if (j < len && j !== last) {
980
+ // Matched!
981
+ last = j;
982
+ // Match 1 or more path separators
983
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
984
+ j++;
985
+ }
986
+ if (j < len && j !== last) {
987
+ // Matched!
988
+ last = j;
989
+ // Match 1 or more non-path separators
990
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
991
+ j++;
992
+ }
993
+ if (j === len) {
994
+ // We matched a UNC root only
995
+ rootEnd = j;
996
+ }
997
+ else if (j !== last) {
998
+ // We matched a UNC root with leftovers
999
+ rootEnd = j + 1;
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+ }
1005
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
1006
+ // Possible device root
1007
+ if (len <= 2) {
1008
+ // `path` contains just a drive root, exit early to avoid
1009
+ // unnecessary work
1010
+ ret.root = ret.dir = path;
1011
+ return ret;
1012
+ }
1013
+ rootEnd = 2;
1014
+ if (isPathSeparator(path.charCodeAt(2))) {
1015
+ if (len === 3) {
1016
+ // `path` contains just a drive root, exit early to avoid
1017
+ // unnecessary work
1018
+ ret.root = ret.dir = path;
1019
+ return ret;
1020
+ }
1021
+ rootEnd = 3;
1022
+ }
1023
+ }
1024
+ if (rootEnd > 0)
1025
+ ret.root = path.slice(0, rootEnd);
1026
+ let startDot = -1;
1027
+ let startPart = rootEnd;
1028
+ let end = -1;
1029
+ let matchedSlash = true;
1030
+ let i = path.length - 1;
1031
+ // Track the state of characters (if any) we see before our first dot and
1032
+ // after any path separator we find
1033
+ let preDotState = 0;
1034
+ // Get non-dir info
1035
+ for (; i >= rootEnd; --i) {
1036
+ code = path.charCodeAt(i);
1037
+ if (isPathSeparator(code)) {
1038
+ // If we reached a path separator that was not part of a set of path
1039
+ // separators at the end of the string, stop now
1040
+ if (!matchedSlash) {
1041
+ startPart = i + 1;
1042
+ break;
1043
+ }
1044
+ continue;
1045
+ }
1046
+ if (end === -1) {
1047
+ // We saw the first non-path separator, mark this as the end of our
1048
+ // extension
1049
+ matchedSlash = false;
1050
+ end = i + 1;
1051
+ }
1052
+ if (code === CHAR_DOT) {
1053
+ // If this is our first dot, mark it as the start of our extension
1054
+ if (startDot === -1)
1055
+ startDot = i;
1056
+ else if (preDotState !== 1)
1057
+ preDotState = 1;
1058
+ }
1059
+ else if (startDot !== -1) {
1060
+ // We saw a non-dot and non-path separator before our dot, so we should
1061
+ // have a good chance at having a non-empty extension
1062
+ preDotState = -1;
1063
+ }
1064
+ }
1065
+ if (end !== -1) {
1066
+ if (startDot === -1 ||
1067
+ // We saw a non-dot character immediately before the dot
1068
+ preDotState === 0 ||
1069
+ // The (right-most) trimmed path component is exactly '..'
1070
+ (preDotState === 1 &&
1071
+ startDot === end - 1 &&
1072
+ startDot === startPart + 1)) {
1073
+ ret.base = ret.name = path.slice(startPart, end);
1074
+ }
1075
+ else {
1076
+ ret.name = path.slice(startPart, startDot);
1077
+ ret.base = path.slice(startPart, end);
1078
+ ret.ext = path.slice(startDot, end);
1079
+ }
1080
+ }
1081
+ // If the directory is the root, use the entire root as the `dir` including
1082
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
1083
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
1084
+ if (startPart > 0 && startPart !== rootEnd)
1085
+ ret.dir = path.slice(0, startPart - 1);
1086
+ else
1087
+ ret.dir = ret.root;
1088
+ return ret;
1089
+ },
1090
+ matchesGlob(_path, _pattern) {
1091
+ throw new Error("path.win32.matchesGlob() is not implemented.");
1092
+ },
1093
+ sep: "\\",
1094
+ delimiter: ";",
1095
+ win32: null,
1096
+ posix: null,
1097
+ };
1098
+ const posix = {
1099
+ /**
1100
+ * path.resolve([from ...], to)
1101
+ * @param {...string} args
1102
+ * @returns {string}
1103
+ */
1104
+ resolve(...args) {
1105
+ let resolvedPath = "";
1106
+ let resolvedAbsolute = false;
1107
+ for (let i = args.length - 1; i >= 0 && !resolvedAbsolute; i--) {
1108
+ const path = args[i];
1109
+ validateString(path, `paths[${i}]`);
1110
+ // Skip empty entries
1111
+ if (path.length === 0) {
1112
+ continue;
1113
+ }
1114
+ resolvedPath = `${path}/${resolvedPath}`;
1115
+ resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1116
+ }
1117
+ if (!resolvedAbsolute) {
1118
+ const cwd = "/";
1119
+ resolvedPath = `${cwd}/${resolvedPath}`;
1120
+ resolvedAbsolute = true;
1121
+ }
1122
+ // At this point the path should be resolved to a full absolute path, but
1123
+ // handle relative paths to be safe (might happen when process.cwd() fails)
1124
+ // Normalize the path
1125
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
1126
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1127
+ if (resolvedAbsolute) {
1128
+ return `/${resolvedPath}`;
1129
+ }
1130
+ return resolvedPath.length > 0 ? resolvedPath : ".";
1131
+ },
1132
+ /**
1133
+ * @param {string} path
1134
+ * @returns {string}
1135
+ */
1136
+ normalize(path) {
1137
+ validateString(path, "path");
1138
+ if (path.length === 0)
1139
+ return ".";
1140
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1141
+ const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
1142
+ // Normalize the path
1143
+ path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
1144
+ if (path.length === 0) {
1145
+ if (isAbsolute)
1146
+ return "/";
1147
+ return trailingSeparator ? "./" : ".";
1148
+ }
1149
+ if (trailingSeparator)
1150
+ path += "/";
1151
+ return isAbsolute ? `/${path}` : path;
1152
+ },
1153
+ /**
1154
+ * @param {string} path
1155
+ * @returns {boolean}
1156
+ */
1157
+ isAbsolute(path) {
1158
+ validateString(path, "path");
1159
+ return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1160
+ },
1161
+ /**
1162
+ * @param {...string} args
1163
+ * @returns {string}
1164
+ */
1165
+ join(...args) {
1166
+ if (args.length === 0)
1167
+ return ".";
1168
+ let joined;
1169
+ for (let i = 0; i < args.length; ++i) {
1170
+ const arg = args[i];
1171
+ validateString(arg, "path");
1172
+ if (arg.length > 0) {
1173
+ if (joined === undefined)
1174
+ joined = arg;
1175
+ else
1176
+ joined += `/${arg}`;
1177
+ }
1178
+ }
1179
+ if (joined === undefined)
1180
+ return ".";
1181
+ return posix.normalize(joined);
1182
+ },
1183
+ /**
1184
+ * @param {string} from
1185
+ * @param {string} to
1186
+ * @returns {string}
1187
+ */
1188
+ relative(from, to) {
1189
+ validateString(from, "from");
1190
+ validateString(to, "to");
1191
+ if (from === to)
1192
+ return "";
1193
+ // Trim leading forward slashes.
1194
+ from = posix.resolve(from);
1195
+ to = posix.resolve(to);
1196
+ if (from === to)
1197
+ return "";
1198
+ // Trim any leading slashes
1199
+ let fromStart = 0;
1200
+ while (fromStart < from.length &&
1201
+ from.charCodeAt(fromStart) === CHAR_FORWARD_SLASH) {
1202
+ fromStart++;
1203
+ }
1204
+ // Trim trailing slashes
1205
+ let fromEnd = from.length;
1206
+ while (fromEnd - 1 > fromStart &&
1207
+ from.charCodeAt(fromEnd - 1) === CHAR_FORWARD_SLASH) {
1208
+ fromEnd--;
1209
+ }
1210
+ const fromLen = fromEnd - fromStart;
1211
+ // Trim any leading slashes
1212
+ let toStart = 0;
1213
+ while (toStart < to.length &&
1214
+ to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
1215
+ toStart++;
1216
+ }
1217
+ // Trim trailing slashes
1218
+ let toEnd = to.length;
1219
+ while (toEnd - 1 > toStart &&
1220
+ to.charCodeAt(toEnd - 1) === CHAR_FORWARD_SLASH) {
1221
+ toEnd--;
1222
+ }
1223
+ const toLen = toEnd - toStart;
1224
+ // Compare paths to find the longest common path from root
1225
+ const length = fromLen < toLen ? fromLen : toLen;
1226
+ let lastCommonSep = -1;
1227
+ let i = 0;
1228
+ for (; i < length; i++) {
1229
+ const fromCode = from.charCodeAt(fromStart + i);
1230
+ if (fromCode !== to.charCodeAt(toStart + i))
1231
+ break;
1232
+ else if (fromCode === CHAR_FORWARD_SLASH)
1233
+ lastCommonSep = i;
1234
+ }
1235
+ if (i === length) {
1236
+ if (toLen > length) {
1237
+ if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
1238
+ // We get here if `from` is the exact base path for `to`.
1239
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
1240
+ return to.slice(toStart + i + 1);
1241
+ }
1242
+ if (i === 0) {
1243
+ // We get here if `from` is the root
1244
+ // For example: from='/'; to='/foo'
1245
+ return to.slice(toStart + i);
1246
+ }
1247
+ }
1248
+ else if (fromLen > length) {
1249
+ if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
1250
+ // We get here if `to` is the exact base path for `from`.
1251
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
1252
+ lastCommonSep = i;
1253
+ }
1254
+ else if (i === 0) {
1255
+ // We get here if `to` is the root.
1256
+ // For example: from='/foo/bar'; to='/'
1257
+ lastCommonSep = 0;
1258
+ }
1259
+ }
1260
+ }
1261
+ let out = "";
1262
+ // Generate the relative path based on the path difference between `to`
1263
+ // and `from`.
1264
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
1265
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1266
+ out += out.length === 0 ? ".." : "/..";
1267
+ }
1268
+ }
1269
+ // Lastly, append the rest of the destination (`to`) path that comes after
1270
+ // the common path parts.
1271
+ return `${out}${to.slice(toStart + lastCommonSep)}`;
1272
+ },
1273
+ /**
1274
+ * @param {string} path
1275
+ * @returns {string}
1276
+ */
1277
+ toNamespacedPath(path) {
1278
+ // No-op on Posix systems
1279
+ return path;
1280
+ },
1281
+ /**
1282
+ * @param {string} path
1283
+ * @returns {string}
1284
+ */
1285
+ dirname(path) {
1286
+ validateString(path, "path");
1287
+ if (path.length === 0)
1288
+ return ".";
1289
+ const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1290
+ let end = -1;
1291
+ let matchedSlash = true;
1292
+ for (let i = path.length - 1; i >= 1; --i) {
1293
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1294
+ if (!matchedSlash) {
1295
+ end = i;
1296
+ break;
1297
+ }
1298
+ }
1299
+ else {
1300
+ // We saw the first non-path separator
1301
+ matchedSlash = false;
1302
+ }
1303
+ }
1304
+ if (end === -1)
1305
+ return hasRoot ? "/" : ".";
1306
+ if (hasRoot && end === 1)
1307
+ return "//";
1308
+ return path.slice(0, end);
1309
+ },
1310
+ /**
1311
+ * @param {string} path
1312
+ * @param {string} [suffix]
1313
+ * @returns {string}
1314
+ */
1315
+ basename(path, suffix) {
1316
+ if (suffix !== undefined)
1317
+ validateString(suffix, "ext");
1318
+ validateString(path, "path");
1319
+ let start = 0;
1320
+ let end = -1;
1321
+ let matchedSlash = true;
1322
+ if (suffix !== undefined &&
1323
+ suffix.length > 0 &&
1324
+ suffix.length <= path.length) {
1325
+ if (suffix === path)
1326
+ return "";
1327
+ let extIdx = suffix.length - 1;
1328
+ let firstNonSlashEnd = -1;
1329
+ for (let i = path.length - 1; i >= 0; --i) {
1330
+ const code = path.charCodeAt(i);
1331
+ if (code === CHAR_FORWARD_SLASH) {
1332
+ // If we reached a path separator that was not part of a set of path
1333
+ // separators at the end of the string, stop now
1334
+ if (!matchedSlash) {
1335
+ start = i + 1;
1336
+ break;
1337
+ }
1338
+ }
1339
+ else {
1340
+ if (firstNonSlashEnd === -1) {
1341
+ // We saw the first non-path separator, remember this index in case
1342
+ // we need it if the extension ends up not matching
1343
+ matchedSlash = false;
1344
+ firstNonSlashEnd = i + 1;
1345
+ }
1346
+ if (extIdx >= 0) {
1347
+ // Try to match the explicit extension
1348
+ if (code === suffix.charCodeAt(extIdx)) {
1349
+ if (--extIdx === -1) {
1350
+ // We matched the extension, so mark this as the end of our path
1351
+ // component
1352
+ end = i;
1353
+ }
1354
+ }
1355
+ else {
1356
+ // Extension does not match, so our result is the entire path
1357
+ // component
1358
+ extIdx = -1;
1359
+ end = firstNonSlashEnd;
1360
+ }
1361
+ }
1362
+ }
1363
+ }
1364
+ if (start === end)
1365
+ end = firstNonSlashEnd;
1366
+ else if (end === -1)
1367
+ end = path.length;
1368
+ return path.slice(start, end);
1369
+ }
1370
+ for (let i = path.length - 1; i >= 0; --i) {
1371
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1372
+ // If we reached a path separator that was not part of a set of path
1373
+ // separators at the end of the string, stop now
1374
+ if (!matchedSlash) {
1375
+ start = i + 1;
1376
+ break;
1377
+ }
1378
+ }
1379
+ else if (end === -1) {
1380
+ // We saw the first non-path separator, mark this as the end of our
1381
+ // path component
1382
+ matchedSlash = false;
1383
+ end = i + 1;
1384
+ }
1385
+ }
1386
+ if (end === -1)
1387
+ return "";
1388
+ return path.slice(start, end);
1389
+ },
1390
+ /**
1391
+ * @param {string} path
1392
+ * @returns {string}
1393
+ */
1394
+ extname(path) {
1395
+ validateString(path, "path");
1396
+ let startDot = -1;
1397
+ let startPart = 0;
1398
+ let end = -1;
1399
+ let matchedSlash = true;
1400
+ // Track the state of characters (if any) we see before our first dot and
1401
+ // after any path separator we find
1402
+ let preDotState = 0;
1403
+ for (let i = path.length - 1; i >= 0; --i) {
1404
+ const code = path.charCodeAt(i);
1405
+ if (code === CHAR_FORWARD_SLASH) {
1406
+ // If we reached a path separator that was not part of a set of path
1407
+ // separators at the end of the string, stop now
1408
+ if (!matchedSlash) {
1409
+ startPart = i + 1;
1410
+ break;
1411
+ }
1412
+ continue;
1413
+ }
1414
+ if (end === -1) {
1415
+ // We saw the first non-path separator, mark this as the end of our
1416
+ // extension
1417
+ matchedSlash = false;
1418
+ end = i + 1;
1419
+ }
1420
+ if (code === CHAR_DOT) {
1421
+ // If this is our first dot, mark it as the start of our extension
1422
+ if (startDot === -1)
1423
+ startDot = i;
1424
+ else if (preDotState !== 1)
1425
+ preDotState = 1;
1426
+ }
1427
+ else if (startDot !== -1) {
1428
+ // We saw a non-dot and non-path separator before our dot, so we should
1429
+ // have a good chance at having a non-empty extension
1430
+ preDotState = -1;
1431
+ }
1432
+ }
1433
+ if (startDot === -1 ||
1434
+ end === -1 ||
1435
+ // We saw a non-dot character immediately before the dot
1436
+ preDotState === 0 ||
1437
+ // The (right-most) trimmed path component is exactly '..'
1438
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
1439
+ return "";
1440
+ }
1441
+ return path.slice(startDot, end);
1442
+ },
1443
+ format: _format.bind(null, "/"),
1444
+ /**
1445
+ * @param {string} path
1446
+ * @returns {{
1447
+ * dir: string;
1448
+ * root: string;
1449
+ * base: string;
1450
+ * name: string;
1451
+ * ext: string;
1452
+ * }}
1453
+ */
1454
+ parse(path) {
1455
+ validateString(path, "path");
1456
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
1457
+ if (path.length === 0)
1458
+ return ret;
1459
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1460
+ let start;
1461
+ if (isAbsolute) {
1462
+ ret.root = "/";
1463
+ start = 1;
1464
+ }
1465
+ else {
1466
+ start = 0;
1467
+ }
1468
+ let startDot = -1;
1469
+ let startPart = 0;
1470
+ let end = -1;
1471
+ let matchedSlash = true;
1472
+ let i = path.length - 1;
1473
+ // Track the state of characters (if any) we see before our first dot and
1474
+ // after any path separator we find
1475
+ let preDotState = 0;
1476
+ // Get non-dir info
1477
+ for (; i >= start; --i) {
1478
+ const code = path.charCodeAt(i);
1479
+ if (code === CHAR_FORWARD_SLASH) {
1480
+ // If we reached a path separator that was not part of a set of path
1481
+ // separators at the end of the string, stop now
1482
+ if (!matchedSlash) {
1483
+ startPart = i + 1;
1484
+ break;
1485
+ }
1486
+ continue;
1487
+ }
1488
+ if (end === -1) {
1489
+ // We saw the first non-path separator, mark this as the end of our
1490
+ // extension
1491
+ matchedSlash = false;
1492
+ end = i + 1;
1493
+ }
1494
+ if (code === CHAR_DOT) {
1495
+ // If this is our first dot, mark it as the start of our extension
1496
+ if (startDot === -1)
1497
+ startDot = i;
1498
+ else if (preDotState !== 1)
1499
+ preDotState = 1;
1500
+ }
1501
+ else if (startDot !== -1) {
1502
+ // We saw a non-dot and non-path separator before our dot, so we should
1503
+ // have a good chance at having a non-empty extension
1504
+ preDotState = -1;
1505
+ }
1506
+ }
1507
+ if (end !== -1) {
1508
+ const start = startPart === 0 && isAbsolute ? 1 : startPart;
1509
+ if (startDot === -1 ||
1510
+ // We saw a non-dot character immediately before the dot
1511
+ preDotState === 0 ||
1512
+ // The (right-most) trimmed path component is exactly '..'
1513
+ (preDotState === 1 &&
1514
+ startDot === end - 1 &&
1515
+ startDot === startPart + 1)) {
1516
+ ret.base = ret.name = path.slice(start, end);
1517
+ }
1518
+ else {
1519
+ ret.name = path.slice(start, startDot);
1520
+ ret.base = path.slice(start, end);
1521
+ ret.ext = path.slice(startDot, end);
1522
+ }
1523
+ }
1524
+ if (startPart > 0)
1525
+ ret.dir = path.slice(0, startPart - 1);
1526
+ else if (isAbsolute)
1527
+ ret.dir = "/";
1528
+ return ret;
1529
+ },
1530
+ matchesGlob(_path, _pattern) {
1531
+ throw new Error("path.posix.matchesGlob() is not implemented.");
1532
+ },
1533
+ sep: "/",
1534
+ delimiter: ":",
1535
+ win32: null,
1536
+ posix: null,
1537
+ };
1538
+ posix.win32 = win32.win32 = win32;
1539
+ posix.posix = win32.posix = posix;
1540
+ // Workers always exposes the posix flavor as the default module object.
1541
+ export default posix;
1542
+ export { posix, win32 };