@bolt-foundry/gambit 0.8.3 → 0.8.5-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/README.md +79 -16
  3. package/esm/_dnt.polyfills.d.ts +17 -0
  4. package/esm/_dnt.polyfills.d.ts.map +1 -1
  5. package/esm/_dnt.polyfills.js +122 -0
  6. package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts +322 -0
  7. package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.js +105 -0
  9. package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts +14 -0
  10. package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.js +34 -0
  12. package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts +13 -0
  13. package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts.map +1 -0
  14. package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.js +18 -0
  15. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts +10 -0
  16. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts.map +1 -0
  17. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.js +17 -0
  18. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts +12 -0
  19. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts.map +1 -0
  20. package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.js +25 -0
  21. package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts +9 -0
  22. package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.js +13 -0
  24. package/esm/deps/jsr.io/@std/fs/1.0.22/copy.d.ts +117 -0
  25. package/esm/deps/jsr.io/@std/fs/1.0.22/copy.d.ts.map +1 -0
  26. package/esm/deps/jsr.io/@std/fs/1.0.22/copy.js +313 -0
  27. package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts +48 -0
  28. package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts.map +1 -0
  29. package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.js +87 -0
  30. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts +49 -0
  31. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts.map +1 -0
  32. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.js +102 -0
  33. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts +47 -0
  34. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.js +90 -0
  36. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts +49 -0
  37. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts.map +1 -0
  38. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.js +61 -0
  39. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts +70 -0
  40. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts.map +1 -0
  41. package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.js +156 -0
  42. package/esm/deps/jsr.io/@std/fs/1.0.22/eol.d.ts +52 -0
  43. package/esm/deps/jsr.io/@std/fs/1.0.22/eol.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/fs/1.0.22/eol.js +67 -0
  45. package/esm/deps/jsr.io/@std/fs/1.0.22/exists.d.ts +218 -0
  46. package/esm/deps/jsr.io/@std/fs/1.0.22/exists.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/fs/1.0.22/exists.js +271 -0
  48. package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts +267 -0
  49. package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts.map +1 -0
  50. package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.js +442 -0
  51. package/esm/deps/jsr.io/@std/fs/1.0.22/mod.d.ts +29 -0
  52. package/esm/deps/jsr.io/@std/fs/1.0.22/mod.d.ts.map +1 -0
  53. package/esm/deps/jsr.io/@std/fs/1.0.22/mod.js +29 -0
  54. package/esm/deps/jsr.io/@std/fs/1.0.22/move.d.ts +86 -0
  55. package/esm/deps/jsr.io/@std/fs/1.0.22/move.d.ts.map +1 -0
  56. package/esm/deps/jsr.io/@std/fs/1.0.22/move.js +142 -0
  57. package/esm/deps/jsr.io/@std/fs/1.0.22/walk.d.ts +777 -0
  58. package/esm/deps/jsr.io/@std/fs/1.0.22/walk.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@std/fs/1.0.22/walk.js +846 -0
  60. package/esm/deps/jsr.io/@std/json/1.0.2/types.d.ts +5 -0
  61. package/esm/deps/jsr.io/@std/json/1.0.2/types.d.ts.map +1 -0
  62. package/esm/deps/jsr.io/@std/json/1.0.2/types.js +3 -0
  63. package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts +20 -0
  64. package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts.map +1 -0
  65. package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.js +21 -0
  66. package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts +21 -0
  67. package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.js +320 -0
  69. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  70. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  71. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +753 -0
  72. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
  73. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
  74. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.js +110 -0
  75. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  76. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  77. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.js +25 -0
  78. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
  79. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
  80. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.js +283 -0
  81. package/esm/gambit/simulator-ui/dist/bundle.js +10647 -4637
  82. package/esm/gambit/simulator-ui/dist/bundle.js.map +4 -4
  83. package/esm/mod.d.ts +13 -3
  84. package/esm/mod.d.ts.map +1 -1
  85. package/esm/mod.js +8 -2
  86. package/esm/src/cli_utils.d.ts +1 -0
  87. package/esm/src/cli_utils.d.ts.map +1 -1
  88. package/esm/src/cli_utils.js +13 -1
  89. package/esm/src/default_runtime.d.ts +46 -0
  90. package/esm/src/default_runtime.d.ts.map +1 -0
  91. package/esm/src/default_runtime.js +415 -0
  92. package/esm/src/durable_streams.js +26 -1
  93. package/esm/src/model_matchers.d.ts +10 -0
  94. package/esm/src/model_matchers.d.ts.map +1 -0
  95. package/esm/src/model_matchers.js +26 -0
  96. package/esm/src/openai_compat.d.ts +12 -1
  97. package/esm/src/openai_compat.d.ts.map +1 -1
  98. package/esm/src/openai_compat.js +53 -1
  99. package/esm/src/project_config.d.ts +47 -0
  100. package/esm/src/project_config.d.ts.map +1 -0
  101. package/esm/src/project_config.js +134 -0
  102. package/esm/src/providers/codex.d.ts +37 -0
  103. package/esm/src/providers/codex.d.ts.map +1 -0
  104. package/esm/src/providers/codex.js +810 -0
  105. package/esm/src/providers/google.d.ts +3 -1
  106. package/esm/src/providers/google.d.ts.map +1 -1
  107. package/esm/src/providers/google.js +82 -6
  108. package/esm/src/providers/ollama.d.ts +3 -1
  109. package/esm/src/providers/ollama.d.ts.map +1 -1
  110. package/esm/src/providers/ollama.js +238 -15
  111. package/esm/src/providers/openrouter.d.ts +6 -2
  112. package/esm/src/providers/openrouter.d.ts.map +1 -1
  113. package/esm/src/providers/openrouter.js +260 -23
  114. package/esm/src/providers/router.d.ts +19 -0
  115. package/esm/src/providers/router.d.ts.map +1 -0
  116. package/esm/src/providers/router.js +93 -0
  117. package/esm/src/server.d.ts +9 -0
  118. package/esm/src/server.d.ts.map +1 -1
  119. package/esm/src/server.js +3186 -652
  120. package/esm/src/server_feedback_grading_routes.d.ts +32 -0
  121. package/esm/src/server_feedback_grading_routes.d.ts.map +1 -0
  122. package/esm/src/server_feedback_grading_routes.js +305 -0
  123. package/esm/src/server_helpers.d.ts +4 -0
  124. package/esm/src/server_helpers.d.ts.map +1 -0
  125. package/esm/src/server_helpers.js +46 -0
  126. package/esm/src/server_session_store.d.ts +87 -0
  127. package/esm/src/server_session_store.d.ts.map +1 -0
  128. package/esm/src/server_session_store.js +873 -0
  129. package/esm/src/server_types.d.ts +110 -0
  130. package/esm/src/server_types.d.ts.map +1 -0
  131. package/esm/src/server_types.js +1 -0
  132. package/esm/src/server_ui_routes.d.ts +33 -0
  133. package/esm/src/server_ui_routes.d.ts.map +1 -0
  134. package/esm/src/server_ui_routes.js +135 -0
  135. package/esm/src/session_artifacts.d.ts +22 -0
  136. package/esm/src/session_artifacts.d.ts.map +1 -0
  137. package/esm/src/session_artifacts.js +243 -0
  138. package/esm/src/trace.d.ts.map +1 -1
  139. package/esm/src/trace.js +6 -3
  140. package/esm/src/workspace.d.ts +19 -0
  141. package/esm/src/workspace.d.ts.map +1 -0
  142. package/esm/src/workspace.js +164 -0
  143. package/esm/src/workspace_contract.d.ts +76 -0
  144. package/esm/src/workspace_contract.d.ts.map +1 -0
  145. package/esm/src/workspace_contract.js +74 -0
  146. package/package.json +2 -2
  147. package/script/_dnt.polyfills.d.ts +17 -0
  148. package/script/_dnt.polyfills.d.ts.map +1 -1
  149. package/script/_dnt.polyfills.js +122 -0
  150. package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts +322 -0
  151. package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts.map +1 -0
  152. package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.js +108 -0
  153. package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts +14 -0
  154. package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts.map +1 -0
  155. package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.js +71 -0
  156. package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts +13 -0
  157. package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts.map +1 -0
  158. package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.js +21 -0
  159. package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts +10 -0
  160. package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts.map +1 -0
  161. package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.js +20 -0
  162. package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts +12 -0
  163. package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts.map +1 -0
  164. package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.js +28 -0
  165. package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts +9 -0
  166. package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts.map +1 -0
  167. package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.js +16 -0
  168. package/script/deps/jsr.io/@std/fs/1.0.22/copy.d.ts +117 -0
  169. package/script/deps/jsr.io/@std/fs/1.0.22/copy.d.ts.map +1 -0
  170. package/script/deps/jsr.io/@std/fs/1.0.22/copy.js +350 -0
  171. package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts +48 -0
  172. package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts.map +1 -0
  173. package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.js +124 -0
  174. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts +49 -0
  175. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts.map +1 -0
  176. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.js +139 -0
  177. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts +47 -0
  178. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts.map +1 -0
  179. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.js +127 -0
  180. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts +49 -0
  181. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts.map +1 -0
  182. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.js +98 -0
  183. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts +70 -0
  184. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts.map +1 -0
  185. package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.js +193 -0
  186. package/script/deps/jsr.io/@std/fs/1.0.22/eol.d.ts +52 -0
  187. package/script/deps/jsr.io/@std/fs/1.0.22/eol.d.ts.map +1 -0
  188. package/script/deps/jsr.io/@std/fs/1.0.22/eol.js +105 -0
  189. package/script/deps/jsr.io/@std/fs/1.0.22/exists.d.ts +218 -0
  190. package/script/deps/jsr.io/@std/fs/1.0.22/exists.d.ts.map +1 -0
  191. package/script/deps/jsr.io/@std/fs/1.0.22/exists.js +308 -0
  192. package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts +267 -0
  193. package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts.map +1 -0
  194. package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.js +479 -0
  195. package/script/deps/jsr.io/@std/fs/1.0.22/mod.d.ts +29 -0
  196. package/script/deps/jsr.io/@std/fs/1.0.22/mod.d.ts.map +1 -0
  197. package/script/deps/jsr.io/@std/fs/1.0.22/mod.js +45 -0
  198. package/script/deps/jsr.io/@std/fs/1.0.22/move.d.ts +86 -0
  199. package/script/deps/jsr.io/@std/fs/1.0.22/move.d.ts.map +1 -0
  200. package/script/deps/jsr.io/@std/fs/1.0.22/move.js +179 -0
  201. package/script/deps/jsr.io/@std/fs/1.0.22/walk.d.ts +777 -0
  202. package/script/deps/jsr.io/@std/fs/1.0.22/walk.d.ts.map +1 -0
  203. package/script/deps/jsr.io/@std/fs/1.0.22/walk.js +883 -0
  204. package/script/deps/jsr.io/@std/json/1.0.2/types.d.ts +5 -0
  205. package/script/deps/jsr.io/@std/json/1.0.2/types.d.ts.map +1 -0
  206. package/script/deps/jsr.io/@std/json/1.0.2/types.js +4 -0
  207. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts +20 -0
  208. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts.map +1 -0
  209. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.js +37 -0
  210. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts +21 -0
  211. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts.map +1 -0
  212. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.js +323 -0
  213. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  214. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  215. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +781 -0
  216. package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
  217. package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
  218. package/script/deps/jsr.io/@std/toml/1.0.11/mod.js +126 -0
  219. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  220. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  221. package/script/deps/jsr.io/@std/toml/1.0.11/parse.js +28 -0
  222. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
  223. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
  224. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.js +286 -0
  225. package/script/gambit/simulator-ui/dist/bundle.js +10647 -4637
  226. package/script/gambit/simulator-ui/dist/bundle.js.map +4 -4
  227. package/script/mod.d.ts +13 -3
  228. package/script/mod.d.ts.map +1 -1
  229. package/script/mod.js +14 -5
  230. package/script/src/cli_utils.d.ts +1 -0
  231. package/script/src/cli_utils.d.ts.map +1 -1
  232. package/script/src/cli_utils.js +14 -1
  233. package/script/src/default_runtime.d.ts +46 -0
  234. package/script/src/default_runtime.d.ts.map +1 -0
  235. package/script/src/default_runtime.js +452 -0
  236. package/script/src/durable_streams.js +26 -1
  237. package/script/src/model_matchers.d.ts +10 -0
  238. package/script/src/model_matchers.d.ts.map +1 -0
  239. package/script/src/model_matchers.js +29 -0
  240. package/script/src/openai_compat.d.ts +12 -1
  241. package/script/src/openai_compat.d.ts.map +1 -1
  242. package/script/src/openai_compat.js +85 -0
  243. package/script/src/project_config.d.ts +47 -0
  244. package/script/src/project_config.d.ts.map +1 -0
  245. package/script/src/project_config.js +173 -0
  246. package/script/src/providers/codex.d.ts +37 -0
  247. package/script/src/providers/codex.d.ts.map +1 -0
  248. package/script/src/providers/codex.js +850 -0
  249. package/script/src/providers/google.d.ts +3 -1
  250. package/script/src/providers/google.d.ts.map +1 -1
  251. package/script/src/providers/google.js +82 -6
  252. package/script/src/providers/ollama.d.ts +3 -1
  253. package/script/src/providers/ollama.d.ts.map +1 -1
  254. package/script/src/providers/ollama.js +238 -15
  255. package/script/src/providers/openrouter.d.ts +6 -2
  256. package/script/src/providers/openrouter.d.ts.map +1 -1
  257. package/script/src/providers/openrouter.js +260 -23
  258. package/script/src/providers/router.d.ts +19 -0
  259. package/script/src/providers/router.d.ts.map +1 -0
  260. package/script/src/providers/router.js +96 -0
  261. package/script/src/server.d.ts +9 -0
  262. package/script/src/server.d.ts.map +1 -1
  263. package/script/src/server.js +3193 -659
  264. package/script/src/server_feedback_grading_routes.d.ts +32 -0
  265. package/script/src/server_feedback_grading_routes.d.ts.map +1 -0
  266. package/script/src/server_feedback_grading_routes.js +343 -0
  267. package/script/src/server_helpers.d.ts +4 -0
  268. package/script/src/server_helpers.d.ts.map +1 -0
  269. package/script/src/server_helpers.js +84 -0
  270. package/script/src/server_session_store.d.ts +87 -0
  271. package/script/src/server_session_store.d.ts.map +1 -0
  272. package/script/src/server_session_store.js +910 -0
  273. package/script/src/server_types.d.ts +110 -0
  274. package/script/src/server_types.d.ts.map +1 -0
  275. package/script/src/server_types.js +2 -0
  276. package/script/src/server_ui_routes.d.ts +33 -0
  277. package/script/src/server_ui_routes.d.ts.map +1 -0
  278. package/script/src/server_ui_routes.js +172 -0
  279. package/script/src/session_artifacts.d.ts +22 -0
  280. package/script/src/session_artifacts.d.ts.map +1 -0
  281. package/script/src/session_artifacts.js +279 -0
  282. package/script/src/trace.d.ts.map +1 -1
  283. package/script/src/trace.js +6 -3
  284. package/script/src/workspace.d.ts +19 -0
  285. package/script/src/workspace.d.ts.map +1 -0
  286. package/script/src/workspace.js +201 -0
  287. package/script/src/workspace_contract.d.ts +76 -0
  288. package/script/src/workspace_contract.d.ts.map +1 -0
  289. package/script/src/workspace_contract.js +82 -0
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // Copyright 2018-2026 the Deno authors. MIT license.
3
+ // Copyright the Browserify authors. MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.toPathString = toPathString;
6
+ const from_file_url_js_1 = require("../../path/1.1.4/from_file_url.js");
7
+ /**
8
+ * Convert a URL or string to a path.
9
+ *
10
+ * @param pathUrl A URL or string to be converted.
11
+ *
12
+ * @returns The path as a string.
13
+ */
14
+ function toPathString(pathUrl) {
15
+ return pathUrl instanceof URL ? (0, from_file_url_js_1.fromFileUrl)(pathUrl) : pathUrl;
16
+ }
@@ -0,0 +1,117 @@
1
+ /** Options for {@linkcode copy} and {@linkcode copySync}. */
2
+ export interface CopyOptions {
3
+ /**
4
+ * Whether to overwrite existing file or directory.
5
+ *
6
+ * @default {false}
7
+ */
8
+ overwrite?: boolean;
9
+ /**
10
+ * When `true`, will set last modification and access times to the ones of
11
+ * the original source files. When `false`, timestamp behavior is
12
+ * OS-dependent.
13
+ *
14
+ * > [!NOTE]
15
+ * > This option is currently unsupported for symbolic links.
16
+ *
17
+ * @default {false}
18
+ */
19
+ preserveTimestamps?: boolean;
20
+ }
21
+ /**
22
+ * Asynchronously copy a file or directory (along with its contents), like
23
+ * {@linkcode https://www.ibm.com/docs/en/aix/7.3?topic=c-cp-command#cp__cp_flagr | cp -r}.
24
+ *
25
+ * Both `src` and `dest` must both be a file or directory.
26
+ *
27
+ * Requires `--allow-read` and `--allow-write` permissions.
28
+ *
29
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
30
+ * for more information on Deno's permissions system.
31
+ *
32
+ * @param src The source file/directory path as a string or URL.
33
+ * @param dest The destination file/directory path as a string or URL.
34
+ * @param options Options for copying.
35
+ *
36
+ * @returns A promise that resolves once the copy operation completes.
37
+ *
38
+ * @example Basic usage
39
+ * ```ts ignore
40
+ * import { copy } from "@std/fs/copy";
41
+ *
42
+ * await copy("./foo", "./bar");
43
+ * ```
44
+ *
45
+ * This will copy the file or directory at `./foo` to `./bar` without
46
+ * overwriting.
47
+ *
48
+ * @example Overwriting files/directories
49
+ * ```ts ignore
50
+ * import { copy } from "@std/fs/copy";
51
+ *
52
+ * await copy("./foo", "./bar", { overwrite: true });
53
+ * ```
54
+ *
55
+ * This will copy the file or directory at `./foo` to `./bar` and overwrite
56
+ * any existing files or directories.
57
+ *
58
+ * @example Preserving timestamps
59
+ * ```ts ignore
60
+ * import { copy } from "@std/fs/copy";
61
+ *
62
+ * await copy("./foo", "./bar", { preserveTimestamps: true });
63
+ * ```
64
+ *
65
+ * This will copy the file or directory at `./foo` to `./bar` and set the
66
+ * last modification and access times to the ones of the original source files.
67
+ */
68
+ export declare function copy(src: string | URL, dest: string | URL, options?: CopyOptions): Promise<void>;
69
+ /**
70
+ * Synchronously copy a file or directory (along with its contents), like
71
+ * {@linkcode https://www.ibm.com/docs/en/aix/7.3?topic=c-cp-command#cp__cp_flagr | cp -r}.
72
+ *
73
+ * Both `src` and `dest` must both be a file or directory.
74
+ *
75
+ * Requires `--allow-read` and `--allow-write` permissions.
76
+ *
77
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
78
+ * for more information on Deno's permissions system.
79
+ *
80
+ * @param src The source file/directory path as a string or URL.
81
+ * @param dest The destination file/directory path as a string or URL.
82
+ * @param options Options for copying.
83
+ *
84
+ * @returns A void value that returns once the copy operation completes.
85
+ *
86
+ * @example Basic usage
87
+ * ```ts ignore
88
+ * import { copySync } from "@std/fs/copy";
89
+ *
90
+ * copySync("./foo", "./bar");
91
+ * ```
92
+ *
93
+ * This will copy the file or directory at `./foo` to `./bar` without
94
+ * overwriting.
95
+ *
96
+ * @example Overwriting files/directories
97
+ * ```ts ignore
98
+ * import { copySync } from "@std/fs/copy";
99
+ *
100
+ * copySync("./foo", "./bar", { overwrite: true });
101
+ * ```
102
+ *
103
+ * This will copy the file or directory at `./foo` to `./bar` and overwrite
104
+ * any existing files or directories.
105
+ *
106
+ * @example Preserving timestamps
107
+ * ```ts ignore
108
+ * import { copySync } from "@std/fs/copy";
109
+ *
110
+ * copySync("./foo", "./bar", { preserveTimestamps: true });
111
+ * ```
112
+ *
113
+ * This will copy the file or directory at `./foo` to `./bar` and set the
114
+ * last modification and access times to the ones of the original source files.
115
+ */
116
+ export declare function copySync(src: string | URL, dest: string | URL, options?: CopyOptions): void;
117
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.22/copy.ts"],"names":[],"mappings":"AAaA,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAoOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,GAAE,WAAgB,iBAwB1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,GAAE,WAAgB,QAwB1B"}
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.copy = copy;
37
+ exports.copySync = copySync;
38
+ // Copyright 2018-2026 the Deno authors. MIT license.
39
+ const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
40
+ const basename_js_1 = require("../../path/1.1.4/basename.js");
41
+ const join_js_1 = require("../../path/1.1.4/join.js");
42
+ const resolve_js_1 = require("../../path/1.1.4/resolve.js");
43
+ const ensure_dir_js_1 = require("./ensure_dir.js");
44
+ const _get_file_info_type_js_1 = require("./_get_file_info_type.js");
45
+ const _to_path_string_js_1 = require("./_to_path_string.js");
46
+ const _is_subdir_js_1 = require("./_is_subdir.js");
47
+ const os_js_1 = require("../../internal/1.0.12/os.js");
48
+ function assertIsDate(date, name) {
49
+ if (date === null) {
50
+ throw new Error(`${name} is unavailable`);
51
+ }
52
+ }
53
+ async function ensureValidCopy(src, dest, options) {
54
+ let destStat;
55
+ try {
56
+ destStat = await dntShim.Deno.lstat(dest);
57
+ }
58
+ catch (err) {
59
+ if (err instanceof dntShim.Deno.errors.NotFound) {
60
+ return;
61
+ }
62
+ throw err;
63
+ }
64
+ if (options.isFolder && !destStat.isDirectory) {
65
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'`);
66
+ }
67
+ if (!options.overwrite) {
68
+ throw new dntShim.Deno.errors.AlreadyExists(`'${dest}' already exists.`);
69
+ }
70
+ return destStat;
71
+ }
72
+ function ensureValidCopySync(src, dest, options) {
73
+ let destStat;
74
+ try {
75
+ destStat = dntShim.Deno.lstatSync(dest);
76
+ }
77
+ catch (err) {
78
+ if (err instanceof dntShim.Deno.errors.NotFound) {
79
+ return;
80
+ }
81
+ throw err;
82
+ }
83
+ if (options.isFolder && !destStat.isDirectory) {
84
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'`);
85
+ }
86
+ if (!options.overwrite) {
87
+ throw new dntShim.Deno.errors.AlreadyExists(`'${dest}' already exists`);
88
+ }
89
+ return destStat;
90
+ }
91
+ /* copy file to dest */
92
+ async function copyFile(src, dest, options) {
93
+ await ensureValidCopy(src, dest, options);
94
+ await dntShim.Deno.copyFile(src, dest);
95
+ if (options.preserveTimestamps) {
96
+ const statInfo = await dntShim.Deno.stat(src);
97
+ assertIsDate(statInfo.atime, "statInfo.atime");
98
+ assertIsDate(statInfo.mtime, "statInfo.mtime");
99
+ await dntShim.Deno.utime(dest, statInfo.atime, statInfo.mtime);
100
+ }
101
+ }
102
+ /* copy file to dest synchronously */
103
+ function copyFileSync(src, dest, options) {
104
+ ensureValidCopySync(src, dest, options);
105
+ dntShim.Deno.copyFileSync(src, dest);
106
+ if (options.preserveTimestamps) {
107
+ const statInfo = dntShim.Deno.statSync(src);
108
+ assertIsDate(statInfo.atime, "statInfo.atime");
109
+ assertIsDate(statInfo.mtime, "statInfo.mtime");
110
+ dntShim.Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
111
+ }
112
+ }
113
+ /* copy symlink to dest */
114
+ async function copySymLink(src, dest, options) {
115
+ await ensureValidCopy(src, dest, options);
116
+ const originSrcFilePath = await dntShim.Deno.readLink(src);
117
+ const type = (0, _get_file_info_type_js_1.getFileInfoType)(await dntShim.Deno.lstat(src));
118
+ if (os_js_1.isWindows) {
119
+ await dntShim.Deno.symlink(originSrcFilePath, dest, {
120
+ type: type === "dir" ? "dir" : "file",
121
+ });
122
+ }
123
+ else {
124
+ await dntShim.Deno.symlink(originSrcFilePath, dest);
125
+ }
126
+ if (options.preserveTimestamps) {
127
+ const statInfo = await dntShim.Deno.lstat(src);
128
+ assertIsDate(statInfo.atime, "statInfo.atime");
129
+ assertIsDate(statInfo.mtime, "statInfo.mtime");
130
+ await dntShim.Deno.utime(dest, statInfo.atime, statInfo.mtime);
131
+ }
132
+ }
133
+ /* copy symlink to dest synchronously */
134
+ function copySymlinkSync(src, dest, options) {
135
+ ensureValidCopySync(src, dest, options);
136
+ const originSrcFilePath = dntShim.Deno.readLinkSync(src);
137
+ const type = (0, _get_file_info_type_js_1.getFileInfoType)(dntShim.Deno.lstatSync(src));
138
+ if (os_js_1.isWindows) {
139
+ dntShim.Deno.symlinkSync(originSrcFilePath, dest, {
140
+ type: type === "dir" ? "dir" : "file",
141
+ });
142
+ }
143
+ else {
144
+ dntShim.Deno.symlinkSync(originSrcFilePath, dest);
145
+ }
146
+ if (options.preserveTimestamps) {
147
+ const statInfo = dntShim.Deno.lstatSync(src);
148
+ assertIsDate(statInfo.atime, "statInfo.atime");
149
+ assertIsDate(statInfo.mtime, "statInfo.mtime");
150
+ dntShim.Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
151
+ }
152
+ }
153
+ /* copy folder from src to dest. */
154
+ async function copyDir(src, dest, options) {
155
+ const destStat = await ensureValidCopy(src, dest, {
156
+ ...options,
157
+ isFolder: true,
158
+ });
159
+ if (!destStat) {
160
+ await (0, ensure_dir_js_1.ensureDir)(dest);
161
+ }
162
+ if (options.preserveTimestamps) {
163
+ const srcStatInfo = await dntShim.Deno.stat(src);
164
+ assertIsDate(srcStatInfo.atime, "statInfo.atime");
165
+ assertIsDate(srcStatInfo.mtime, "statInfo.mtime");
166
+ await dntShim.Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime);
167
+ }
168
+ src = (0, _to_path_string_js_1.toPathString)(src);
169
+ dest = (0, _to_path_string_js_1.toPathString)(dest);
170
+ const promises = [];
171
+ for await (const entry of dntShim.Deno.readDir(src)) {
172
+ const srcPath = (0, join_js_1.join)(src, entry.name);
173
+ const destPath = (0, join_js_1.join)(dest, (0, basename_js_1.basename)(srcPath));
174
+ if (entry.isSymlink) {
175
+ promises.push(copySymLink(srcPath, destPath, options));
176
+ }
177
+ else if (entry.isDirectory) {
178
+ promises.push(copyDir(srcPath, destPath, options));
179
+ }
180
+ else if (entry.isFile) {
181
+ promises.push(copyFile(srcPath, destPath, options));
182
+ }
183
+ }
184
+ await Promise.all(promises);
185
+ }
186
+ /* copy folder from src to dest synchronously */
187
+ function copyDirSync(src, dest, options) {
188
+ const destStat = ensureValidCopySync(src, dest, {
189
+ ...options,
190
+ isFolder: true,
191
+ });
192
+ if (!destStat) {
193
+ (0, ensure_dir_js_1.ensureDirSync)(dest);
194
+ }
195
+ if (options.preserveTimestamps) {
196
+ const srcStatInfo = dntShim.Deno.statSync(src);
197
+ assertIsDate(srcStatInfo.atime, "statInfo.atime");
198
+ assertIsDate(srcStatInfo.mtime, "statInfo.mtime");
199
+ dntShim.Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime);
200
+ }
201
+ src = (0, _to_path_string_js_1.toPathString)(src);
202
+ dest = (0, _to_path_string_js_1.toPathString)(dest);
203
+ for (const entry of dntShim.Deno.readDirSync(src)) {
204
+ const srcPath = (0, join_js_1.join)(src, entry.name);
205
+ const destPath = (0, join_js_1.join)(dest, (0, basename_js_1.basename)(srcPath));
206
+ if (entry.isSymlink) {
207
+ copySymlinkSync(srcPath, destPath, options);
208
+ }
209
+ else if (entry.isDirectory) {
210
+ copyDirSync(srcPath, destPath, options);
211
+ }
212
+ else if (entry.isFile) {
213
+ copyFileSync(srcPath, destPath, options);
214
+ }
215
+ }
216
+ }
217
+ /**
218
+ * Asynchronously copy a file or directory (along with its contents), like
219
+ * {@linkcode https://www.ibm.com/docs/en/aix/7.3?topic=c-cp-command#cp__cp_flagr | cp -r}.
220
+ *
221
+ * Both `src` and `dest` must both be a file or directory.
222
+ *
223
+ * Requires `--allow-read` and `--allow-write` permissions.
224
+ *
225
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
226
+ * for more information on Deno's permissions system.
227
+ *
228
+ * @param src The source file/directory path as a string or URL.
229
+ * @param dest The destination file/directory path as a string or URL.
230
+ * @param options Options for copying.
231
+ *
232
+ * @returns A promise that resolves once the copy operation completes.
233
+ *
234
+ * @example Basic usage
235
+ * ```ts ignore
236
+ * import { copy } from "@std/fs/copy";
237
+ *
238
+ * await copy("./foo", "./bar");
239
+ * ```
240
+ *
241
+ * This will copy the file or directory at `./foo` to `./bar` without
242
+ * overwriting.
243
+ *
244
+ * @example Overwriting files/directories
245
+ * ```ts ignore
246
+ * import { copy } from "@std/fs/copy";
247
+ *
248
+ * await copy("./foo", "./bar", { overwrite: true });
249
+ * ```
250
+ *
251
+ * This will copy the file or directory at `./foo` to `./bar` and overwrite
252
+ * any existing files or directories.
253
+ *
254
+ * @example Preserving timestamps
255
+ * ```ts ignore
256
+ * import { copy } from "@std/fs/copy";
257
+ *
258
+ * await copy("./foo", "./bar", { preserveTimestamps: true });
259
+ * ```
260
+ *
261
+ * This will copy the file or directory at `./foo` to `./bar` and set the
262
+ * last modification and access times to the ones of the original source files.
263
+ */
264
+ async function copy(src, dest, options = {}) {
265
+ src = (0, resolve_js_1.resolve)((0, _to_path_string_js_1.toPathString)(src));
266
+ dest = (0, resolve_js_1.resolve)((0, _to_path_string_js_1.toPathString)(dest));
267
+ if (src === dest) {
268
+ throw new Error("Source and destination cannot be the same");
269
+ }
270
+ const srcStat = await dntShim.Deno.lstat(src);
271
+ if (srcStat.isDirectory && (0, _is_subdir_js_1.isSubdir)(src, dest)) {
272
+ throw new Error(`Cannot copy '${src}' to a subdirectory of itself: '${dest}'`);
273
+ }
274
+ if (srcStat.isSymlink) {
275
+ await copySymLink(src, dest, options);
276
+ }
277
+ else if (srcStat.isDirectory) {
278
+ await copyDir(src, dest, options);
279
+ }
280
+ else if (srcStat.isFile) {
281
+ await copyFile(src, dest, options);
282
+ }
283
+ }
284
+ /**
285
+ * Synchronously copy a file or directory (along with its contents), like
286
+ * {@linkcode https://www.ibm.com/docs/en/aix/7.3?topic=c-cp-command#cp__cp_flagr | cp -r}.
287
+ *
288
+ * Both `src` and `dest` must both be a file or directory.
289
+ *
290
+ * Requires `--allow-read` and `--allow-write` permissions.
291
+ *
292
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
293
+ * for more information on Deno's permissions system.
294
+ *
295
+ * @param src The source file/directory path as a string or URL.
296
+ * @param dest The destination file/directory path as a string or URL.
297
+ * @param options Options for copying.
298
+ *
299
+ * @returns A void value that returns once the copy operation completes.
300
+ *
301
+ * @example Basic usage
302
+ * ```ts ignore
303
+ * import { copySync } from "@std/fs/copy";
304
+ *
305
+ * copySync("./foo", "./bar");
306
+ * ```
307
+ *
308
+ * This will copy the file or directory at `./foo` to `./bar` without
309
+ * overwriting.
310
+ *
311
+ * @example Overwriting files/directories
312
+ * ```ts ignore
313
+ * import { copySync } from "@std/fs/copy";
314
+ *
315
+ * copySync("./foo", "./bar", { overwrite: true });
316
+ * ```
317
+ *
318
+ * This will copy the file or directory at `./foo` to `./bar` and overwrite
319
+ * any existing files or directories.
320
+ *
321
+ * @example Preserving timestamps
322
+ * ```ts ignore
323
+ * import { copySync } from "@std/fs/copy";
324
+ *
325
+ * copySync("./foo", "./bar", { preserveTimestamps: true });
326
+ * ```
327
+ *
328
+ * This will copy the file or directory at `./foo` to `./bar` and set the
329
+ * last modification and access times to the ones of the original source files.
330
+ */
331
+ function copySync(src, dest, options = {}) {
332
+ src = (0, resolve_js_1.resolve)((0, _to_path_string_js_1.toPathString)(src));
333
+ dest = (0, resolve_js_1.resolve)((0, _to_path_string_js_1.toPathString)(dest));
334
+ if (src === dest) {
335
+ throw new Error("Source and destination cannot be the same");
336
+ }
337
+ const srcStat = dntShim.Deno.lstatSync(src);
338
+ if (srcStat.isDirectory && (0, _is_subdir_js_1.isSubdir)(src, dest)) {
339
+ throw new Error(`Cannot copy '${src}' to a subdirectory of itself: '${dest}'`);
340
+ }
341
+ if (srcStat.isSymlink) {
342
+ copySymlinkSync(src, dest, options);
343
+ }
344
+ else if (srcStat.isDirectory) {
345
+ copyDirSync(src, dest, options);
346
+ }
347
+ else if (srcStat.isFile) {
348
+ copyFileSync(src, dest, options);
349
+ }
350
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Asynchronously ensures that a directory is empty.
3
+ *
4
+ * If the directory does not exist, it is created. The directory itself is not
5
+ * deleted.
6
+ *
7
+ * Requires `--allow-read` and `--allow-write` permissions.
8
+ *
9
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
10
+ * for more information on Deno's permissions system.
11
+ *
12
+ * @param dir The path of the directory to empty, as a string or URL.
13
+ *
14
+ * @returns A void promise that resolves once the directory is empty.
15
+ *
16
+ * @example Usage
17
+ * ```ts ignore
18
+ * import { emptyDir } from "@std/fs/empty-dir";
19
+ *
20
+ * await emptyDir("./foo");
21
+ * ```
22
+ */
23
+ export declare function emptyDir(dir: string | URL): Promise<void>;
24
+ /**
25
+ * Synchronously ensures that a directory is empty deletes the directory
26
+ * contents it is not empty.
27
+ *
28
+ * If the directory does not exist, it is created. The directory itself is not
29
+ * deleted.
30
+ *
31
+ * Requires `--allow-read` and `--allow-write` permissions.
32
+ *
33
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
34
+ * for more information on Deno's permissions system.
35
+ *
36
+ * @param dir The path of the directory to empty, as a string or URL.
37
+ *
38
+ * @returns A void value that returns once the directory is empty.
39
+ *
40
+ * @example Usage
41
+ * ```ts ignore
42
+ * import { emptyDirSync } from "@std/fs/empty-dir";
43
+ *
44
+ * emptyDirSync("./foo");
45
+ * ```
46
+ */
47
+ export declare function emptyDirSync(dir: string | URL): void;
48
+ //# sourceMappingURL=empty_dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty_dir.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.22/empty_dir.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,iBAkB/C;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,QAmB7C"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.emptyDir = emptyDir;
37
+ exports.emptyDirSync = emptyDirSync;
38
+ // Copyright 2018-2026 the Deno authors. MIT license.
39
+ const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
40
+ const join_js_1 = require("../../path/1.1.4/join.js");
41
+ const _to_path_string_js_1 = require("./_to_path_string.js");
42
+ /**
43
+ * Asynchronously ensures that a directory is empty.
44
+ *
45
+ * If the directory does not exist, it is created. The directory itself is not
46
+ * deleted.
47
+ *
48
+ * Requires `--allow-read` and `--allow-write` permissions.
49
+ *
50
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
51
+ * for more information on Deno's permissions system.
52
+ *
53
+ * @param dir The path of the directory to empty, as a string or URL.
54
+ *
55
+ * @returns A void promise that resolves once the directory is empty.
56
+ *
57
+ * @example Usage
58
+ * ```ts ignore
59
+ * import { emptyDir } from "@std/fs/empty-dir";
60
+ *
61
+ * await emptyDir("./foo");
62
+ * ```
63
+ */
64
+ async function emptyDir(dir) {
65
+ try {
66
+ const items = await Array.fromAsync(dntShim.Deno.readDir(dir));
67
+ await Promise.all(items.map((item) => {
68
+ if (item && item.name) {
69
+ const filepath = (0, join_js_1.join)((0, _to_path_string_js_1.toPathString)(dir), item.name);
70
+ return dntShim.Deno.remove(filepath, { recursive: true });
71
+ }
72
+ }));
73
+ }
74
+ catch (err) {
75
+ if (!(err instanceof dntShim.Deno.errors.NotFound)) {
76
+ throw err;
77
+ }
78
+ // if not exist. then create it
79
+ await dntShim.Deno.mkdir(dir, { recursive: true });
80
+ }
81
+ }
82
+ /**
83
+ * Synchronously ensures that a directory is empty deletes the directory
84
+ * contents it is not empty.
85
+ *
86
+ * If the directory does not exist, it is created. The directory itself is not
87
+ * deleted.
88
+ *
89
+ * Requires `--allow-read` and `--allow-write` permissions.
90
+ *
91
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
92
+ * for more information on Deno's permissions system.
93
+ *
94
+ * @param dir The path of the directory to empty, as a string or URL.
95
+ *
96
+ * @returns A void value that returns once the directory is empty.
97
+ *
98
+ * @example Usage
99
+ * ```ts ignore
100
+ * import { emptyDirSync } from "@std/fs/empty-dir";
101
+ *
102
+ * emptyDirSync("./foo");
103
+ * ```
104
+ */
105
+ function emptyDirSync(dir) {
106
+ try {
107
+ const items = [...dntShim.Deno.readDirSync(dir)];
108
+ // If the directory exists, remove all entries inside it.
109
+ while (items.length) {
110
+ const item = items.shift();
111
+ if (item && item.name) {
112
+ const filepath = (0, join_js_1.join)((0, _to_path_string_js_1.toPathString)(dir), item.name);
113
+ dntShim.Deno.removeSync(filepath, { recursive: true });
114
+ }
115
+ }
116
+ }
117
+ catch (err) {
118
+ if (!(err instanceof dntShim.Deno.errors.NotFound)) {
119
+ throw err;
120
+ }
121
+ // if not exist. then create it
122
+ dntShim.Deno.mkdirSync(dir, { recursive: true });
123
+ }
124
+ }