keri-ts 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/README.md +44 -120
  2. package/esm/app/cli/agent.js +0 -19
  3. package/esm/app/cli/annotate.js +7 -2
  4. package/esm/app/cli/benchmark.js +210 -0
  5. package/esm/app/cli/cli.js +50 -52
  6. package/esm/app/cli/command-definitions.js +258 -6
  7. package/esm/app/cli/common/existing.js +40 -0
  8. package/esm/app/cli/common/parsing.js +20 -0
  9. package/esm/app/cli/export.js +51 -0
  10. package/esm/app/cli/incept.js +106 -0
  11. package/esm/app/cli/index.js +9 -0
  12. package/esm/app/cli/init.js +72 -41
  13. package/esm/app/configing.js +261 -0
  14. package/esm/app/habbing.js +386 -0
  15. package/esm/app/index.js +10 -0
  16. package/esm/app/keeping.js +321 -0
  17. package/esm/app/version.js +2 -2
  18. package/esm/db/basing.js +66 -1
  19. package/esm/db/core/lmdber.js +13 -7
  20. package/esm/db/core/path-manager.js +193 -169
  21. package/esm/db/index.js +1 -0
  22. package/esm/db/keeping.js +214 -0
  23. package/esm/deps/jsr.io/@std/internal/1.0.12/_os.js +12 -0
  24. package/esm/deps/jsr.io/@std/internal/1.0.12/os.js +5 -0
  25. package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.js +7 -0
  26. package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.js +40 -0
  27. package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.js +23 -0
  28. package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.js +46 -0
  29. package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.js +8 -0
  30. package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.js +19 -0
  31. package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.js +9 -0
  32. package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.js +235 -0
  33. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.js +8 -0
  34. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.js +77 -0
  35. package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.js +9 -0
  36. package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.js +19 -0
  37. package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.js +15 -0
  38. package/esm/deps/jsr.io/@std/path/1.1.4/basename.js +35 -0
  39. package/esm/deps/jsr.io/@std/path/1.1.4/common.js +33 -0
  40. package/esm/deps/jsr.io/@std/path/1.1.4/constants.js +17 -0
  41. package/esm/deps/jsr.io/@std/path/1.1.4/dirname.js +28 -0
  42. package/esm/deps/jsr.io/@std/path/1.1.4/extname.js +28 -0
  43. package/esm/deps/jsr.io/@std/path/1.1.4/format.js +27 -0
  44. package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.js +28 -0
  45. package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.js +83 -0
  46. package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.js +28 -0
  47. package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.js +42 -0
  48. package/esm/deps/jsr.io/@std/path/1.1.4/join.js +29 -0
  49. package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.js +34 -0
  50. package/esm/deps/jsr.io/@std/path/1.1.4/mod.js +216 -0
  51. package/esm/deps/jsr.io/@std/path/1.1.4/normalize.js +32 -0
  52. package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.js +35 -0
  53. package/esm/deps/jsr.io/@std/path/1.1.4/parse.js +39 -0
  54. package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.js +8 -0
  55. package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.js +52 -0
  56. package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.js +14 -0
  57. package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.js +64 -0
  58. package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.js +93 -0
  59. package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.js +28 -0
  60. package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.js +21 -0
  61. package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.js +82 -0
  62. package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.js +23 -0
  63. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.js +45 -0
  64. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.js +40 -0
  65. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.js +58 -0
  66. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.js +32 -0
  67. package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.js +115 -0
  68. package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.js +106 -0
  69. package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +59 -0
  70. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.js +27 -0
  71. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.js +20 -0
  72. package/esm/deps/jsr.io/@std/path/1.1.4/relative.js +30 -0
  73. package/esm/deps/jsr.io/@std/path/1.1.4/resolve.js +30 -0
  74. package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.js +28 -0
  75. package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.js +29 -0
  76. package/esm/deps/jsr.io/@std/path/1.1.4/types.js +3 -0
  77. package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.js +15 -0
  78. package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.js +47 -0
  79. package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.js +14 -0
  80. package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.js +113 -0
  81. package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.js +82 -0
  82. package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.js +28 -0
  83. package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.js +30 -0
  84. package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.js +82 -0
  85. package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.js +38 -0
  86. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.js +77 -0
  87. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.js +41 -0
  88. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.js +135 -0
  89. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.js +32 -0
  90. package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.js +176 -0
  91. package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.js +131 -0
  92. package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +154 -0
  93. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.js +34 -0
  94. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.js +49 -0
  95. package/esm/npm/index.js +7 -2
  96. package/package.json +6 -3
  97. package/types/app/cli/agent.d.ts.map +1 -1
  98. package/types/app/cli/annotate.d.ts.map +1 -1
  99. package/types/app/cli/benchmark.d.ts +11 -0
  100. package/types/app/cli/benchmark.d.ts.map +1 -0
  101. package/types/app/cli/cli.d.ts.map +1 -1
  102. package/types/app/cli/command-definitions.d.ts +5 -2
  103. package/types/app/cli/command-definitions.d.ts.map +1 -1
  104. package/types/app/cli/command-types.d.ts +12 -0
  105. package/types/app/cli/command-types.d.ts.map +1 -1
  106. package/types/app/cli/common/existing.d.ts +4 -0
  107. package/types/app/cli/common/existing.d.ts.map +1 -0
  108. package/types/app/cli/common/parsing.d.ts +15 -0
  109. package/types/app/cli/common/parsing.d.ts.map +1 -0
  110. package/types/app/cli/export.d.ts +8 -0
  111. package/types/app/cli/export.d.ts.map +1 -0
  112. package/types/app/cli/incept.d.ts +8 -0
  113. package/types/app/cli/incept.d.ts.map +1 -0
  114. package/types/app/cli/index.d.ts +10 -0
  115. package/types/app/cli/index.d.ts.map +1 -0
  116. package/types/app/cli/init.d.ts +5 -0
  117. package/types/app/cli/init.d.ts.map +1 -1
  118. package/types/app/configing.d.ts +57 -0
  119. package/types/app/configing.d.ts.map +1 -0
  120. package/types/app/habbing.d.ts +107 -0
  121. package/types/app/habbing.d.ts.map +1 -0
  122. package/types/app/index.d.ts +11 -0
  123. package/types/app/index.d.ts.map +1 -0
  124. package/types/app/keeping.d.ts +72 -0
  125. package/types/app/keeping.d.ts.map +1 -0
  126. package/types/app/version.d.ts +2 -2
  127. package/types/app/version.d.ts.map +1 -1
  128. package/types/db/basing.d.ts +16 -1
  129. package/types/db/basing.d.ts.map +1 -1
  130. package/types/db/core/lmdber.d.ts +8 -4
  131. package/types/db/core/lmdber.d.ts.map +1 -1
  132. package/types/db/core/path-manager.d.ts +88 -24
  133. package/types/db/core/path-manager.d.ts.map +1 -1
  134. package/types/db/index.d.ts +1 -0
  135. package/types/db/index.d.ts.map +1 -1
  136. package/types/db/keeping.d.ts +73 -0
  137. package/types/db/keeping.d.ts.map +1 -0
  138. package/types/deps/jsr.io/@std/internal/1.0.12/_os.d.ts +2 -0
  139. package/types/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +1 -0
  140. package/types/deps/jsr.io/@std/internal/1.0.12/os.d.ts +3 -0
  141. package/types/deps/jsr.io/@std/internal/1.0.12/os.d.ts.map +1 -0
  142. package/types/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts +2 -0
  143. package/types/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts.map +1 -0
  144. package/types/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts +4 -0
  145. package/types/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts.map +1 -0
  146. package/types/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts +2 -0
  147. package/types/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts.map +1 -0
  148. package/types/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts +40 -0
  149. package/types/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts.map +1 -0
  150. package/types/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts +2 -0
  151. package/types/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts.map +1 -0
  152. package/types/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts +4 -0
  153. package/types/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts.map +1 -0
  154. package/types/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts +2 -0
  155. package/types/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts.map +1 -0
  156. package/types/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts +35 -0
  157. package/types/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts.map +1 -0
  158. package/types/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts +2 -0
  159. package/types/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts.map +1 -0
  160. package/types/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts +2 -0
  161. package/types/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts.map +1 -0
  162. package/types/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts +2 -0
  163. package/types/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts.map +1 -0
  164. package/types/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts +2 -0
  165. package/types/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts.map +1 -0
  166. package/types/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts +2 -0
  167. package/types/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts.map +1 -0
  168. package/types/deps/jsr.io/@std/path/1.1.4/basename.d.ts +27 -0
  169. package/types/deps/jsr.io/@std/path/1.1.4/basename.d.ts.map +1 -0
  170. package/types/deps/jsr.io/@std/path/1.1.4/common.d.ts +28 -0
  171. package/types/deps/jsr.io/@std/path/1.1.4/common.d.ts.map +1 -0
  172. package/types/deps/jsr.io/@std/path/1.1.4/constants.d.ts +15 -0
  173. package/types/deps/jsr.io/@std/path/1.1.4/constants.d.ts.map +1 -0
  174. package/types/deps/jsr.io/@std/path/1.1.4/dirname.d.ts +22 -0
  175. package/types/deps/jsr.io/@std/path/1.1.4/dirname.d.ts.map +1 -0
  176. package/types/deps/jsr.io/@std/path/1.1.4/extname.d.ts +22 -0
  177. package/types/deps/jsr.io/@std/path/1.1.4/extname.d.ts.map +1 -0
  178. package/types/deps/jsr.io/@std/path/1.1.4/format.d.ts +22 -0
  179. package/types/deps/jsr.io/@std/path/1.1.4/format.d.ts.map +1 -0
  180. package/types/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts +22 -0
  181. package/types/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts.map +1 -0
  182. package/types/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts +77 -0
  183. package/types/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts.map +1 -0
  184. package/types/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts +22 -0
  185. package/types/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts.map +1 -0
  186. package/types/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts +17 -0
  187. package/types/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts.map +1 -0
  188. package/types/deps/jsr.io/@std/path/1.1.4/join.d.ts +23 -0
  189. package/types/deps/jsr.io/@std/path/1.1.4/join.d.ts.map +1 -0
  190. package/types/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts +28 -0
  191. package/types/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts.map +1 -0
  192. package/types/deps/jsr.io/@std/path/1.1.4/mod.d.ts +213 -0
  193. package/types/deps/jsr.io/@std/path/1.1.4/mod.d.ts.map +1 -0
  194. package/types/deps/jsr.io/@std/path/1.1.4/normalize.d.ts +26 -0
  195. package/types/deps/jsr.io/@std/path/1.1.4/normalize.d.ts.map +1 -0
  196. package/types/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts +29 -0
  197. package/types/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts.map +1 -0
  198. package/types/deps/jsr.io/@std/path/1.1.4/parse.d.ts +35 -0
  199. package/types/deps/jsr.io/@std/path/1.1.4/parse.d.ts.map +1 -0
  200. package/types/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts +2 -0
  201. package/types/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts.map +1 -0
  202. package/types/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts +39 -0
  203. package/types/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts.map +1 -0
  204. package/types/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts +13 -0
  205. package/types/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -0
  206. package/types/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts +30 -0
  207. package/types/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts.map +1 -0
  208. package/types/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts +37 -0
  209. package/types/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts.map +1 -0
  210. package/types/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts +24 -0
  211. package/types/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts.map +1 -0
  212. package/types/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts +16 -0
  213. package/types/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts.map +1 -0
  214. package/types/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts +72 -0
  215. package/types/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts.map +1 -0
  216. package/types/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts +17 -0
  217. package/types/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts.map +1 -0
  218. package/types/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts +31 -0
  219. package/types/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts.map +1 -0
  220. package/types/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts +20 -0
  221. package/types/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts.map +1 -0
  222. package/types/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts +37 -0
  223. package/types/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts.map +1 -0
  224. package/types/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts +20 -0
  225. package/types/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts.map +1 -0
  226. package/types/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts +25 -0
  227. package/types/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts.map +1 -0
  228. package/types/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts +20 -0
  229. package/types/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts.map +1 -0
  230. package/types/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts +17 -0
  231. package/types/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts.map +1 -0
  232. package/types/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts +17 -0
  233. package/types/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts.map +1 -0
  234. package/types/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts +16 -0
  235. package/types/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts.map +1 -0
  236. package/types/deps/jsr.io/@std/path/1.1.4/relative.d.ts +24 -0
  237. package/types/deps/jsr.io/@std/path/1.1.4/relative.d.ts.map +1 -0
  238. package/types/deps/jsr.io/@std/path/1.1.4/resolve.d.ts +22 -0
  239. package/types/deps/jsr.io/@std/path/1.1.4/resolve.d.ts.map +1 -0
  240. package/types/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts +22 -0
  241. package/types/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts.map +1 -0
  242. package/types/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts +21 -0
  243. package/types/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts.map +1 -0
  244. package/types/deps/jsr.io/@std/path/1.1.4/types.d.ts +38 -0
  245. package/types/deps/jsr.io/@std/path/1.1.4/types.d.ts.map +1 -0
  246. package/types/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts +4 -0
  247. package/types/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts.map +1 -0
  248. package/types/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts +22 -0
  249. package/types/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts.map +1 -0
  250. package/types/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts +13 -0
  251. package/types/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -0
  252. package/types/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts +17 -0
  253. package/types/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts.map +1 -0
  254. package/types/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts +17 -0
  255. package/types/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts.map +1 -0
  256. package/types/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts +24 -0
  257. package/types/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts.map +1 -0
  258. package/types/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts +18 -0
  259. package/types/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts.map +1 -0
  260. package/types/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts +71 -0
  261. package/types/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts.map +1 -0
  262. package/types/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts +17 -0
  263. package/types/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts.map +1 -0
  264. package/types/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts +18 -0
  265. package/types/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts.map +1 -0
  266. package/types/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts +21 -0
  267. package/types/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts.map +1 -0
  268. package/types/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts +19 -0
  269. package/types/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts.map +1 -0
  270. package/types/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts +20 -0
  271. package/types/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts.map +1 -0
  272. package/types/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts +25 -0
  273. package/types/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts.map +1 -0
  274. package/types/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts +23 -0
  275. package/types/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts.map +1 -0
  276. package/types/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts +17 -0
  277. package/types/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts.map +1 -0
  278. package/types/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts +17 -0
  279. package/types/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts.map +1 -0
  280. package/types/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts +17 -0
  281. package/types/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts.map +1 -0
  282. package/types/npm/index.d.ts +7 -2
  283. package/types/npm/index.d.ts.map +1 -1
  284. package/esm/app/cli/stub-commands.js +0 -61
  285. package/types/app/cli/stub-commands.d.ts +0 -6
  286. package/types/app/cli/stub-commands.d.ts.map +0 -1
@@ -0,0 +1,135 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { assertArg } from "../_common/normalize.js";
4
+ import { CHAR_COLON } from "../_common/constants.js";
5
+ import { normalizeString } from "../_common/normalize_string.js";
6
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
7
+ import { fromFileUrl } from "./from_file_url.js";
8
+ /**
9
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
10
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
11
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { normalize } from "@std/path/windows/normalize";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * assertEquals(normalize("C:\\foo\\..\\bar"), "C:\\bar");
19
+ * assertEquals(normalize(new URL("file:///C:/foo/../bar")), "C:\\bar");
20
+ * ```
21
+ *
22
+ * @param path The path to normalize
23
+ * @returns The normalized path
24
+ */
25
+ export function normalize(path) {
26
+ if (path instanceof URL) {
27
+ path = fromFileUrl(path);
28
+ }
29
+ assertArg(path);
30
+ const len = path.length;
31
+ let rootEnd = 0;
32
+ let device;
33
+ let isAbsolute = false;
34
+ const code = path.charCodeAt(0);
35
+ // Try to match a root
36
+ if (len > 1) {
37
+ if (isPathSeparator(code)) {
38
+ // Possible UNC root
39
+ // If we started with a separator, we know we at least have an absolute
40
+ // path of some kind (UNC or otherwise)
41
+ isAbsolute = true;
42
+ if (isPathSeparator(path.charCodeAt(1))) {
43
+ // Matched double path separator at beginning
44
+ let j = 2;
45
+ let last = j;
46
+ // Match 1 or more non-path separators
47
+ for (; j < len; ++j) {
48
+ if (isPathSeparator(path.charCodeAt(j)))
49
+ break;
50
+ }
51
+ if (j < len && j !== last) {
52
+ const firstPart = path.slice(last, j);
53
+ // Matched!
54
+ last = j;
55
+ // Match 1 or more path separators
56
+ for (; j < len; ++j) {
57
+ if (!isPathSeparator(path.charCodeAt(j)))
58
+ break;
59
+ }
60
+ if (j < len && j !== last) {
61
+ // Matched!
62
+ last = j;
63
+ // Match 1 or more non-path separators
64
+ for (; j < len; ++j) {
65
+ if (isPathSeparator(path.charCodeAt(j)))
66
+ break;
67
+ }
68
+ if (j === len) {
69
+ // We matched a UNC root only
70
+ // Return the normalized version of the UNC root since there
71
+ // is nothing left to process
72
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
73
+ }
74
+ else if (j !== last) {
75
+ // We matched a UNC root with leftovers
76
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
77
+ rootEnd = j;
78
+ }
79
+ }
80
+ }
81
+ }
82
+ else {
83
+ rootEnd = 1;
84
+ }
85
+ }
86
+ else if (isWindowsDeviceRoot(code)) {
87
+ // Possible device root
88
+ if (path.charCodeAt(1) === CHAR_COLON) {
89
+ device = path.slice(0, 2);
90
+ rootEnd = 2;
91
+ if (len > 2) {
92
+ if (isPathSeparator(path.charCodeAt(2))) {
93
+ // Treat separator following drive name as an absolute path
94
+ // indicator
95
+ isAbsolute = true;
96
+ rootEnd = 3;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ else if (isPathSeparator(code)) {
103
+ // `path` contains just a path separator, exit early to avoid unnecessary
104
+ // work
105
+ return "\\";
106
+ }
107
+ let tail;
108
+ if (rootEnd < len) {
109
+ tail = normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator);
110
+ }
111
+ else {
112
+ tail = "";
113
+ }
114
+ if (tail.length === 0 && !isAbsolute)
115
+ tail = ".";
116
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
117
+ tail += "\\";
118
+ }
119
+ if (device === undefined) {
120
+ if (isAbsolute) {
121
+ if (tail.length > 0)
122
+ return `\\${tail}`;
123
+ else
124
+ return "\\";
125
+ }
126
+ return tail;
127
+ }
128
+ else if (isAbsolute) {
129
+ if (tail.length > 0)
130
+ return `${device}\\${tail}`;
131
+ else
132
+ return `${device}\\`;
133
+ }
134
+ return device + tail;
135
+ }
@@ -0,0 +1,32 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { normalize } from "./normalize.js";
4
+ import { SEPARATOR_PATTERN } from "./constants.js";
5
+ /**
6
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
7
+ *
8
+ * @example Usage
9
+ * ```ts
10
+ * import { normalizeGlob } from "@std/path/windows/normalize-glob";
11
+ * import { assertEquals } from "@std/assert";
12
+ *
13
+ * const normalized = normalizeGlob("**\\foo\\..\\bar", { globstar: true });
14
+ * assertEquals(normalized, "**\\bar");
15
+ * ```
16
+ *
17
+ * @param glob The glob pattern to normalize.
18
+ * @param options The options for glob pattern.
19
+ * @returns The normalized glob pattern.
20
+ */
21
+ export function normalizeGlob(glob, options = {}) {
22
+ const { globstar = false } = options;
23
+ if (glob.match(/\0/g)) {
24
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
25
+ }
26
+ if (!globstar) {
27
+ return normalize(glob);
28
+ }
29
+ const s = SEPARATOR_PATTERN.source;
30
+ const badParentPattern = new RegExp(`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`, "g");
31
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
32
+ }
@@ -0,0 +1,176 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON, CHAR_DOT } from "../_common/constants.js";
4
+ import { assertPath } from "../_common/assert_path.js";
5
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
6
+ /**
7
+ * Return a `ParsedPath` object of the `path`.
8
+ *
9
+ * @example Usage
10
+ * ```ts
11
+ * import { parse } from "@std/path/windows/parse";
12
+ * import { assertEquals } from "@std/assert";
13
+ *
14
+ * const parsed = parse("C:\\foo\\bar\\baz.ext");
15
+ * assertEquals(parsed, {
16
+ * root: "C:\\",
17
+ * dir: "C:\\foo\\bar",
18
+ * base: "baz.ext",
19
+ * ext: ".ext",
20
+ * name: "baz",
21
+ * });
22
+ * ```
23
+ *
24
+ * @param path The path to parse.
25
+ * @returns The `ParsedPath` object.
26
+ */
27
+ export function parse(path) {
28
+ assertPath(path);
29
+ const ret = { root: "", dir: "", base: "", ext: "", name: "" };
30
+ const len = path.length;
31
+ if (len === 0)
32
+ return ret;
33
+ let rootEnd = 0;
34
+ let code = path.charCodeAt(0);
35
+ // Try to match a root
36
+ if (len > 1) {
37
+ if (isPathSeparator(code)) {
38
+ // Possible UNC root
39
+ rootEnd = 1;
40
+ if (isPathSeparator(path.charCodeAt(1))) {
41
+ // Matched double path separator at beginning
42
+ let j = 2;
43
+ let last = j;
44
+ // Match 1 or more non-path separators
45
+ for (; j < len; ++j) {
46
+ if (isPathSeparator(path.charCodeAt(j)))
47
+ break;
48
+ }
49
+ if (j < len && j !== last) {
50
+ // Matched!
51
+ last = j;
52
+ // Match 1 or more path separators
53
+ for (; j < len; ++j) {
54
+ if (!isPathSeparator(path.charCodeAt(j)))
55
+ break;
56
+ }
57
+ if (j < len && j !== last) {
58
+ // Matched!
59
+ last = j;
60
+ // Match 1 or more non-path separators
61
+ for (; j < len; ++j) {
62
+ if (isPathSeparator(path.charCodeAt(j)))
63
+ break;
64
+ }
65
+ if (j === len) {
66
+ // We matched a UNC root only
67
+ rootEnd = j;
68
+ }
69
+ else if (j !== last) {
70
+ // We matched a UNC root with leftovers
71
+ rootEnd = j + 1;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ else if (isWindowsDeviceRoot(code)) {
78
+ // Possible device root
79
+ if (path.charCodeAt(1) === CHAR_COLON) {
80
+ rootEnd = 2;
81
+ if (len > 2) {
82
+ if (isPathSeparator(path.charCodeAt(2))) {
83
+ if (len === 3) {
84
+ // `path` contains just a drive root, exit early to avoid
85
+ // unnecessary work
86
+ ret.root = ret.dir = path;
87
+ ret.base = "\\";
88
+ return ret;
89
+ }
90
+ rootEnd = 3;
91
+ }
92
+ }
93
+ else {
94
+ // `path` contains just a relative drive root, exit early to avoid
95
+ // unnecessary work
96
+ ret.root = ret.dir = path;
97
+ return ret;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ else if (isPathSeparator(code)) {
103
+ // `path` contains just a path separator, exit early to avoid
104
+ // unnecessary work
105
+ ret.root = ret.dir = path;
106
+ ret.base = "\\";
107
+ return ret;
108
+ }
109
+ if (rootEnd > 0)
110
+ ret.root = path.slice(0, rootEnd);
111
+ let startDot = -1;
112
+ let startPart = rootEnd;
113
+ let end = -1;
114
+ let matchedSlash = true;
115
+ let i = path.length - 1;
116
+ // Track the state of characters (if any) we see before our first dot and
117
+ // after any path separator we find
118
+ let preDotState = 0;
119
+ // Get non-dir info
120
+ for (; i >= rootEnd; --i) {
121
+ code = path.charCodeAt(i);
122
+ if (isPathSeparator(code)) {
123
+ // If we reached a path separator that was not part of a set of path
124
+ // separators at the end of the string, stop now
125
+ if (!matchedSlash) {
126
+ startPart = i + 1;
127
+ break;
128
+ }
129
+ continue;
130
+ }
131
+ if (end === -1) {
132
+ // We saw the first non-path separator, mark this as the end of our
133
+ // extension
134
+ matchedSlash = false;
135
+ end = i + 1;
136
+ }
137
+ if (code === CHAR_DOT) {
138
+ // If this is our first dot, mark it as the start of our extension
139
+ if (startDot === -1)
140
+ startDot = i;
141
+ else if (preDotState !== 1)
142
+ preDotState = 1;
143
+ }
144
+ else if (startDot !== -1) {
145
+ // We saw a non-dot and non-path separator before our dot, so we should
146
+ // have a good chance at having a non-empty extension
147
+ preDotState = -1;
148
+ }
149
+ }
150
+ if (startDot === -1 ||
151
+ end === -1 ||
152
+ // We saw a non-dot character immediately before the dot
153
+ preDotState === 0 ||
154
+ // The (right-most) trimmed path component is exactly '..'
155
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
156
+ if (end !== -1) {
157
+ ret.base = ret.name = path.slice(startPart, end);
158
+ }
159
+ }
160
+ else {
161
+ ret.name = path.slice(startPart, startDot);
162
+ ret.base = path.slice(startPart, end);
163
+ ret.ext = path.slice(startDot, end);
164
+ }
165
+ // Fallback to '\' in case there is no basename
166
+ ret.base = ret.base || "\\";
167
+ // If the directory is the root, use the entire root as the `dir` including
168
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
169
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
170
+ if (startPart > 0 && startPart !== rootEnd) {
171
+ ret.dir = path.slice(0, startPart - 1);
172
+ }
173
+ else
174
+ ret.dir = ret.root;
175
+ return ret;
176
+ }
@@ -0,0 +1,131 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_BACKWARD_SLASH } from "../_common/constants.js";
4
+ import { resolve } from "./resolve.js";
5
+ import { assertArgs } from "../_common/relative.js";
6
+ /**
7
+ * Return the relative path from `from` to `to` based on current working directory.
8
+ *
9
+ * An example in windows, for instance:
10
+ * from = 'C:\\orandea\\test\\aaa'
11
+ * to = 'C:\\orandea\\impl\\bbb'
12
+ * The output of the function should be: '..\\..\\impl\\bbb'
13
+ *
14
+ * @example Usage
15
+ * ```ts
16
+ * import { relative } from "@std/path/windows/relative";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * const relativePath = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
20
+ * assertEquals(relativePath, "..\\..\\impl\\bbb");
21
+ * ```
22
+ *
23
+ * @param from The path from which to calculate the relative path
24
+ * @param to The path to which to calculate the relative path
25
+ * @returns The relative path from `from` to `to`
26
+ */
27
+ export function relative(from, to) {
28
+ assertArgs(from, to);
29
+ const fromOrig = resolve(from);
30
+ const toOrig = resolve(to);
31
+ if (fromOrig === toOrig)
32
+ return "";
33
+ from = fromOrig.toLowerCase();
34
+ to = toOrig.toLowerCase();
35
+ if (from === to)
36
+ return "";
37
+ // Trim any leading backslashes
38
+ let fromStart = 0;
39
+ let fromEnd = from.length;
40
+ for (; fromStart < fromEnd; ++fromStart) {
41
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH)
42
+ break;
43
+ }
44
+ // Trim trailing backslashes (applicable to UNC paths only)
45
+ for (; fromEnd - 1 > fromStart; --fromEnd) {
46
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH)
47
+ break;
48
+ }
49
+ const fromLen = fromEnd - fromStart;
50
+ // Trim any leading backslashes
51
+ let toStart = 0;
52
+ let toEnd = to.length;
53
+ for (; toStart < toEnd; ++toStart) {
54
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH)
55
+ break;
56
+ }
57
+ // Trim trailing backslashes (applicable to UNC paths only)
58
+ for (; toEnd - 1 > toStart; --toEnd) {
59
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH)
60
+ break;
61
+ }
62
+ const toLen = toEnd - toStart;
63
+ // Compare paths to find the longest common path from root
64
+ const length = fromLen < toLen ? fromLen : toLen;
65
+ let lastCommonSep = -1;
66
+ let i = 0;
67
+ for (; i <= length; ++i) {
68
+ if (i === length) {
69
+ if (toLen > length) {
70
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
71
+ // We get here if `from` is the exact base path for `to`.
72
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
73
+ return toOrig.slice(toStart + i + 1);
74
+ }
75
+ else if (i === 2) {
76
+ // We get here if `from` is the device root.
77
+ // For example: from='C:\\'; to='C:\\foo'
78
+ return toOrig.slice(toStart + i);
79
+ }
80
+ }
81
+ if (fromLen > length) {
82
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
83
+ // We get here if `to` is the exact base path for `from`.
84
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
85
+ lastCommonSep = i;
86
+ }
87
+ else if (i === 2) {
88
+ // We get here if `to` is the device root.
89
+ // For example: from='C:\\foo\\bar'; to='C:\\'
90
+ lastCommonSep = 3;
91
+ }
92
+ }
93
+ break;
94
+ }
95
+ const fromCode = from.charCodeAt(fromStart + i);
96
+ const toCode = to.charCodeAt(toStart + i);
97
+ if (fromCode !== toCode)
98
+ break;
99
+ else if (fromCode === CHAR_BACKWARD_SLASH)
100
+ lastCommonSep = i;
101
+ }
102
+ // We found a mismatch before the first common path separator was seen, so
103
+ // return the original `to`.
104
+ if (i !== length && lastCommonSep === -1) {
105
+ return toOrig;
106
+ }
107
+ let out = "";
108
+ if (lastCommonSep === -1)
109
+ lastCommonSep = 0;
110
+ // Generate the relative path based on the path difference between `to` and
111
+ // `from`
112
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
113
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
114
+ if (out.length === 0)
115
+ out += "..";
116
+ else
117
+ out += "\\..";
118
+ }
119
+ }
120
+ // Lastly, append the rest of the destination (`to`) path that comes after
121
+ // the common path parts
122
+ if (out.length > 0) {
123
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
124
+ }
125
+ else {
126
+ toStart += lastCommonSep;
127
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH)
128
+ ++toStart;
129
+ return toOrig.slice(toStart, toEnd);
130
+ }
131
+ }
@@ -0,0 +1,154 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import * as dntShim from "../../../../../../_dnt.shims.js";
4
+ import { CHAR_COLON } from "../_common/constants.js";
5
+ import { normalizeString } from "../_common/normalize_string.js";
6
+ import { assertPath } from "../_common/assert_path.js";
7
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
8
+ /**
9
+ * Resolves path segments into a `path`.
10
+ *
11
+ * @example Usage
12
+ * ```ts
13
+ * import { resolve } from "@std/path/windows/resolve";
14
+ * import { assertEquals } from "@std/assert";
15
+ *
16
+ * const resolved = resolve("C:\\foo\\bar", "..\\baz");
17
+ * assertEquals(resolved, "C:\\foo\\baz");
18
+ * ```
19
+ *
20
+ * @param pathSegments The path segments to process to path
21
+ * @returns The resolved path
22
+ */
23
+ export function resolve(...pathSegments) {
24
+ let resolvedDevice = "";
25
+ let resolvedTail = "";
26
+ let resolvedAbsolute = false;
27
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
28
+ let path;
29
+ // deno-lint-ignore no-explicit-any
30
+ const { Deno } = dntShim.dntGlobalThis;
31
+ if (i >= 0) {
32
+ path = pathSegments[i];
33
+ }
34
+ else if (!resolvedDevice) {
35
+ if (typeof Deno?.cwd !== "function") {
36
+ throw new TypeError("Resolved a drive-letter-less path without a current working directory (CWD)");
37
+ }
38
+ path = Deno.cwd();
39
+ }
40
+ else {
41
+ if (typeof Deno?.env?.get !== "function" || typeof Deno?.cwd !== "function") {
42
+ throw new TypeError("Resolved a relative path without a current working directory (CWD)");
43
+ }
44
+ path = Deno.cwd();
45
+ // Verify that a cwd was found and that it actually points
46
+ // to our drive. If not, default to the drive's root.
47
+ if (path === undefined ||
48
+ path.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`) {
49
+ path = `${resolvedDevice}\\`;
50
+ }
51
+ }
52
+ assertPath(path);
53
+ const len = path.length;
54
+ // Skip empty entries
55
+ if (len === 0)
56
+ continue;
57
+ let rootEnd = 0;
58
+ let device = "";
59
+ let isAbsolute = false;
60
+ const code = path.charCodeAt(0);
61
+ // Try to match a root
62
+ if (len > 1) {
63
+ if (isPathSeparator(code)) {
64
+ // Possible UNC root
65
+ // If we started with a separator, we know we at least have an
66
+ // absolute path of some kind (UNC or otherwise)
67
+ isAbsolute = true;
68
+ if (isPathSeparator(path.charCodeAt(1))) {
69
+ // Matched double path separator at beginning
70
+ let j = 2;
71
+ let last = j;
72
+ // Match 1 or more non-path separators
73
+ for (; j < len; ++j) {
74
+ if (isPathSeparator(path.charCodeAt(j)))
75
+ break;
76
+ }
77
+ if (j < len && j !== last) {
78
+ const firstPart = path.slice(last, j);
79
+ // Matched!
80
+ last = j;
81
+ // Match 1 or more path separators
82
+ for (; j < len; ++j) {
83
+ if (!isPathSeparator(path.charCodeAt(j)))
84
+ break;
85
+ }
86
+ if (j < len && j !== last) {
87
+ // Matched!
88
+ last = j;
89
+ // Match 1 or more non-path separators
90
+ for (; j < len; ++j) {
91
+ if (isPathSeparator(path.charCodeAt(j)))
92
+ break;
93
+ }
94
+ if (j === len) {
95
+ // We matched a UNC root only
96
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
97
+ rootEnd = j;
98
+ }
99
+ else if (j !== last) {
100
+ // We matched a UNC root with leftovers
101
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
102
+ rootEnd = j;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ else {
108
+ rootEnd = 1;
109
+ }
110
+ }
111
+ else if (isWindowsDeviceRoot(code)) {
112
+ // Possible device root
113
+ if (path.charCodeAt(1) === CHAR_COLON) {
114
+ device = path.slice(0, 2);
115
+ rootEnd = 2;
116
+ if (len > 2) {
117
+ if (isPathSeparator(path.charCodeAt(2))) {
118
+ // Treat separator following drive name as an absolute path
119
+ // indicator
120
+ isAbsolute = true;
121
+ rootEnd = 3;
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ else if (isPathSeparator(code)) {
128
+ // `path` contains just a path separator
129
+ rootEnd = 1;
130
+ isAbsolute = true;
131
+ }
132
+ if (device.length > 0 &&
133
+ resolvedDevice.length > 0 &&
134
+ device.toLowerCase() !== resolvedDevice.toLowerCase()) {
135
+ // This path points to another device so it is not applicable
136
+ continue;
137
+ }
138
+ if (resolvedDevice.length === 0 && device.length > 0) {
139
+ resolvedDevice = device;
140
+ }
141
+ if (!resolvedAbsolute) {
142
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
143
+ resolvedAbsolute = isAbsolute;
144
+ }
145
+ if (resolvedAbsolute && resolvedDevice.length > 0)
146
+ break;
147
+ }
148
+ // At this point the path should be resolved to a full absolute path,
149
+ // but handle relative paths to be safe (might happen when Deno.cwd()
150
+ // fails)
151
+ // Normalize the tail path
152
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
153
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
154
+ }
@@ -0,0 +1,34 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import { encodeWhitespace } from "../_common/to_file_url.js";
4
+ import { isAbsolute } from "./is_absolute.js";
5
+ /**
6
+ * Converts a path string to a file URL.
7
+ *
8
+ * @example Usage
9
+ * ```ts
10
+ * import { toFileUrl } from "@std/path/windows/to-file-url";
11
+ * import { assertEquals } from "@std/assert";
12
+ *
13
+ * assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
14
+ * assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
15
+ * assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));
16
+ * ```
17
+ * @param path The path to convert.
18
+ * @returns The file URL.
19
+ */
20
+ export function toFileUrl(path) {
21
+ if (!isAbsolute(path)) {
22
+ throw new TypeError(`Path must be absolute: received "${path}"`);
23
+ }
24
+ const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
25
+ const url = new URL("file:///");
26
+ url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
27
+ if (hostname !== undefined && hostname !== "localhost") {
28
+ url.hostname = hostname;
29
+ if (!url.hostname) {
30
+ throw new TypeError(`Invalid hostname: "${url.hostname}"`);
31
+ }
32
+ }
33
+ return url;
34
+ }