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

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 +38 -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 +10639 -4629
  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 +10639 -4629
  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,90 @@
1
+ // Copyright 2018-2026 the Deno authors. MIT license.
2
+ import * as dntShim from "../../../../../_dnt.shims.js";
3
+ import { dirname } from "../../path/1.1.4/dirname.js";
4
+ import { ensureDir, ensureDirSync } from "./ensure_dir.js";
5
+ import { getFileInfoType } from "./_get_file_info_type.js";
6
+ import { toPathString } from "./_to_path_string.js";
7
+ /**
8
+ * Asynchronously ensures that the file exists.
9
+ *
10
+ * If the file already exists, this function does nothing. If the parent
11
+ * directories for the file do not exist, they are created.
12
+ *
13
+ * Requires `--allow-read` and `--allow-write` permissions.
14
+ *
15
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
16
+ * for more information on Deno's permissions system.
17
+ *
18
+ * @param filePath The path of the file to ensure, as a string or URL.
19
+ *
20
+ * @returns A void promise that resolves once the file exists.
21
+ *
22
+ * @example Usage
23
+ * ```ts ignore
24
+ * import { ensureFile } from "@std/fs/ensure-file";
25
+ *
26
+ * await ensureFile("./folder/targetFile.dat");
27
+ * ```
28
+ */
29
+ export async function ensureFile(filePath) {
30
+ try {
31
+ // if file exists
32
+ const stat = await dntShim.Deno.lstat(filePath);
33
+ if (!stat.isFile) {
34
+ throw new Error(`Failed to ensure file exists: expected 'file', got '${getFileInfoType(stat)}'`);
35
+ }
36
+ }
37
+ catch (err) {
38
+ // if file not exists
39
+ if (err instanceof dntShim.Deno.errors.NotFound) {
40
+ // ensure dir exists
41
+ await ensureDir(dirname(toPathString(filePath)));
42
+ // create file
43
+ await dntShim.Deno.writeFile(filePath, new Uint8Array());
44
+ return;
45
+ }
46
+ throw err;
47
+ }
48
+ }
49
+ /**
50
+ * Synchronously ensures that the file exists.
51
+ *
52
+ * If the file already exists, this function does nothing. If the parent
53
+ * directories for the file do not exist, they are created.
54
+ *
55
+ * Requires `--allow-read` and `--allow-write` permissions.
56
+ *
57
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
58
+ * for more information on Deno's permissions system.
59
+ *
60
+ * @param filePath The path of the file to ensure, as a string or URL.
61
+ *
62
+ * @returns A void value that returns once the file exists.
63
+ *
64
+ * @example Usage
65
+ * ```ts ignore
66
+ * import { ensureFileSync } from "@std/fs/ensure-file";
67
+ *
68
+ * ensureFileSync("./folder/targetFile.dat");
69
+ * ```
70
+ */
71
+ export function ensureFileSync(filePath) {
72
+ try {
73
+ // if file exists
74
+ const stat = dntShim.Deno.lstatSync(filePath);
75
+ if (!stat.isFile) {
76
+ throw new Error(`Failed to ensure file exists: expected 'file', got '${getFileInfoType(stat)}'`);
77
+ }
78
+ }
79
+ catch (err) {
80
+ // if file not exists
81
+ if (err instanceof dntShim.Deno.errors.NotFound) {
82
+ // ensure dir exists
83
+ ensureDirSync(dirname(toPathString(filePath)));
84
+ // create file
85
+ dntShim.Deno.writeFileSync(filePath, new Uint8Array());
86
+ return;
87
+ }
88
+ throw err;
89
+ }
90
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Asynchronously ensures that the hard link exists.
3
+ *
4
+ * If the parent directories for the hard link do not exist, they are created.
5
+ *
6
+ * Requires `--allow-read` and `--allow-write` permissions.
7
+ *
8
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
9
+ * for more information on Deno's permissions system.
10
+ *
11
+ * @param src The source file path as a string or URL. Directory hard links are
12
+ * not allowed.
13
+ * @param dest The destination link path as a string or URL.
14
+ *
15
+ * @returns A void promise that resolves once the hard link exists.
16
+ *
17
+ * @example Usage
18
+ * ```ts ignore
19
+ * import { ensureLink } from "@std/fs/ensure-link";
20
+ *
21
+ * await ensureLink("./folder/targetFile.dat", "./folder/targetFile.link.dat");
22
+ * ```
23
+ */
24
+ export declare function ensureLink(src: string | URL, dest: string | URL): Promise<void>;
25
+ /**
26
+ * Synchronously ensures that the hard link exists.
27
+ *
28
+ * If the parent directories for the hard link do not exist, they are created.
29
+ *
30
+ * Requires `--allow-read` and `--allow-write` permissions.
31
+ *
32
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
33
+ * for more information on Deno's permissions system.
34
+ *
35
+ * @param src The source file path as a string or URL. Directory hard links are
36
+ * not allowed.
37
+ * @param dest The destination link path as a string or URL.
38
+ *
39
+ * @returns A void value that returns once the hard link exists.
40
+ *
41
+ * @example Usage
42
+ * ```ts ignore
43
+ * import { ensureLinkSync } from "@std/fs/ensure-link";
44
+ *
45
+ * ensureLinkSync("./folder/targetFile.dat", "./folder/targetFile.link.dat");
46
+ * ```
47
+ */
48
+ export declare function ensureLinkSync(src: string | URL, dest: string | URL): void;
49
+ //# sourceMappingURL=ensure_link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure_link.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.22/ensure_link.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,iBAKrE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,QAKnE"}
@@ -0,0 +1,61 @@
1
+ // Copyright 2018-2026 the Deno authors. MIT license.
2
+ import * as dntShim from "../../../../../_dnt.shims.js";
3
+ import { dirname } from "../../path/1.1.4/dirname.js";
4
+ import { ensureDir, ensureDirSync } from "./ensure_dir.js";
5
+ import { toPathString } from "./_to_path_string.js";
6
+ /**
7
+ * Asynchronously ensures that the hard link exists.
8
+ *
9
+ * If the parent directories for the hard link do not exist, they are created.
10
+ *
11
+ * Requires `--allow-read` and `--allow-write` permissions.
12
+ *
13
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
14
+ * for more information on Deno's permissions system.
15
+ *
16
+ * @param src The source file path as a string or URL. Directory hard links are
17
+ * not allowed.
18
+ * @param dest The destination link path as a string or URL.
19
+ *
20
+ * @returns A void promise that resolves once the hard link exists.
21
+ *
22
+ * @example Usage
23
+ * ```ts ignore
24
+ * import { ensureLink } from "@std/fs/ensure-link";
25
+ *
26
+ * await ensureLink("./folder/targetFile.dat", "./folder/targetFile.link.dat");
27
+ * ```
28
+ */
29
+ export async function ensureLink(src, dest) {
30
+ dest = toPathString(dest);
31
+ await ensureDir(dirname(dest));
32
+ await dntShim.Deno.link(toPathString(src), dest);
33
+ }
34
+ /**
35
+ * Synchronously ensures that the hard link exists.
36
+ *
37
+ * If the parent directories for the hard link do not exist, they are created.
38
+ *
39
+ * Requires `--allow-read` and `--allow-write` permissions.
40
+ *
41
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
42
+ * for more information on Deno's permissions system.
43
+ *
44
+ * @param src The source file path as a string or URL. Directory hard links are
45
+ * not allowed.
46
+ * @param dest The destination link path as a string or URL.
47
+ *
48
+ * @returns A void value that returns once the hard link exists.
49
+ *
50
+ * @example Usage
51
+ * ```ts ignore
52
+ * import { ensureLinkSync } from "@std/fs/ensure-link";
53
+ *
54
+ * ensureLinkSync("./folder/targetFile.dat", "./folder/targetFile.link.dat");
55
+ * ```
56
+ */
57
+ export function ensureLinkSync(src, dest) {
58
+ dest = toPathString(dest);
59
+ ensureDirSync(dirname(dest));
60
+ dntShim.Deno.linkSync(toPathString(src), dest);
61
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Asynchronously ensures that the link exists, and points to a valid file.
3
+ *
4
+ * If the parent directories for the link do not exist, they are created. If the
5
+ * link already exists, and it is not modified, this function does nothing. If
6
+ * the link already exists, and it does not point to the given target, an error
7
+ * is thrown.
8
+ *
9
+ * Requires `--allow-read` and `--allow-write` permissions.
10
+ *
11
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
12
+ * for more information on Deno's permissions system.
13
+ *
14
+ * @param target The source file path as a string or URL. If it is a relative path string, it have to be relative to the link path.
15
+ * @param linkName The destination link path as a string or URL.
16
+ *
17
+ * @returns A void promise that resolves once the link exists.
18
+ *
19
+ * @example Basic usage
20
+ * ```ts ignore
21
+ * import { ensureSymlink } from "@std/fs/ensure-symlink";
22
+ *
23
+ * // Ensures the link `./targetFile.link.dat` exists and points to `./targetFile.dat`
24
+ * await ensureSymlink("./targetFile.dat", "./targetFile.link.dat");
25
+ * ```
26
+ *
27
+ * @example Ensuring a link in a folder
28
+ * ```ts ignore
29
+ * import { ensureSymlink } from "@std/fs/ensure-symlink";
30
+ *
31
+ * // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
32
+ * await ensureSymlink("./targetFile.dat", "./folder/targetFile.link.dat");
33
+ * ```
34
+ */
35
+ export declare function ensureSymlink(target: string | URL, linkName: string | URL): Promise<void>;
36
+ /**
37
+ * Synchronously ensures that the link exists, and points to a valid file.
38
+ *
39
+ * If the parent directories for the link do not exist, they are created. If the
40
+ * link already exists, and it is not modified, this function does nothing. If
41
+ * the link already exists, and it does not point to the given target, an error
42
+ * is thrown.
43
+ *
44
+ * Requires `--allow-read` and `--allow-write` permissions.
45
+ *
46
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
47
+ * for more information on Deno's permissions system.
48
+ *
49
+ * @param target The source file path as a string or URL. If it is a relative path string, it have to be relative to the link path.
50
+ * @param linkName The destination link path as a string or URL.
51
+ * @returns A void value that returns once the link exists.
52
+ *
53
+ * @example Basic usage
54
+ * ```ts ignore
55
+ * import { ensureSymlinkSync } from "@std/fs/ensure-symlink";
56
+ *
57
+ * // Ensures the link `./targetFile.link.dat` exists and points to `./targetFile.dat`
58
+ * ensureSymlinkSync("./targetFile.dat", "./targetFile.link.dat");
59
+ * ```
60
+ *
61
+ * @example Ensuring a link in a folder
62
+ * ```ts ignore
63
+ * import { ensureSymlinkSync } from "@std/fs/ensure-symlink";
64
+ *
65
+ * // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
66
+ * ensureSymlinkSync("./targetFile.dat", "./folder/targetFile.link.dat");
67
+ * ```
68
+ */
69
+ export declare function ensureSymlinkSync(target: string | URL, linkName: string | URL): void;
70
+ //# sourceMappingURL=ensure_symlink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure_symlink.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,GAAG,GAAG,EACpB,QAAQ,EAAE,MAAM,GAAG,GAAG,iBAyCvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,GAAG,EACpB,QAAQ,EAAE,MAAM,GAAG,GAAG,QAyCvB"}
@@ -0,0 +1,156 @@
1
+ // Copyright 2018-2026 the Deno authors. MIT license.
2
+ import * as dntShim from "../../../../../_dnt.shims.js";
3
+ import { dirname } from "../../path/1.1.4/dirname.js";
4
+ import { resolve } from "../../path/1.1.4/resolve.js";
5
+ import { ensureDir, ensureDirSync } from "./ensure_dir.js";
6
+ import { getFileInfoType } from "./_get_file_info_type.js";
7
+ import { toPathString } from "./_to_path_string.js";
8
+ import { isWindows } from "../../internal/1.0.12/os.js";
9
+ function resolveSymlinkTarget(target, linkName) {
10
+ if (typeof target !== "string")
11
+ return target; // URL is always absolute path
12
+ if (typeof linkName === "string") {
13
+ return resolve(dirname(linkName), target);
14
+ }
15
+ else {
16
+ return new URL(target, linkName);
17
+ }
18
+ }
19
+ function getSymlinkOption(type) {
20
+ return isWindows ? { type: type === "dir" ? "dir" : "file" } : undefined;
21
+ }
22
+ /**
23
+ * Asynchronously ensures that the link exists, and points to a valid file.
24
+ *
25
+ * If the parent directories for the link do not exist, they are created. If the
26
+ * link already exists, and it is not modified, this function does nothing. If
27
+ * the link already exists, and it does not point to the given target, an error
28
+ * is thrown.
29
+ *
30
+ * Requires `--allow-read` and `--allow-write` permissions.
31
+ *
32
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
33
+ * for more information on Deno's permissions system.
34
+ *
35
+ * @param target The source file path as a string or URL. If it is a relative path string, it have to be relative to the link path.
36
+ * @param linkName The destination link path as a string or URL.
37
+ *
38
+ * @returns A void promise that resolves once the link exists.
39
+ *
40
+ * @example Basic usage
41
+ * ```ts ignore
42
+ * import { ensureSymlink } from "@std/fs/ensure-symlink";
43
+ *
44
+ * // Ensures the link `./targetFile.link.dat` exists and points to `./targetFile.dat`
45
+ * await ensureSymlink("./targetFile.dat", "./targetFile.link.dat");
46
+ * ```
47
+ *
48
+ * @example Ensuring a link in a folder
49
+ * ```ts ignore
50
+ * import { ensureSymlink } from "@std/fs/ensure-symlink";
51
+ *
52
+ * // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
53
+ * await ensureSymlink("./targetFile.dat", "./folder/targetFile.link.dat");
54
+ * ```
55
+ */
56
+ export async function ensureSymlink(target, linkName) {
57
+ const targetRealPath = resolveSymlinkTarget(target, linkName);
58
+ let srcStatInfo;
59
+ try {
60
+ srcStatInfo = await dntShim.Deno.lstat(targetRealPath);
61
+ }
62
+ catch (error) {
63
+ if (error instanceof dntShim.Deno.errors.NotFound) {
64
+ throw new dntShim.Deno.errors.NotFound(`Cannot ensure symlink as the target path does not exist: ${targetRealPath}`);
65
+ }
66
+ throw error;
67
+ }
68
+ const srcFilePathType = getFileInfoType(srcStatInfo);
69
+ await ensureDir(dirname(toPathString(linkName)));
70
+ const options = getSymlinkOption(srcFilePathType);
71
+ try {
72
+ await dntShim.Deno.symlink(target, linkName, options);
73
+ }
74
+ catch (error) {
75
+ if (!(error instanceof dntShim.Deno.errors.AlreadyExists)) {
76
+ throw error;
77
+ }
78
+ const linkStatInfo = await dntShim.Deno.lstat(linkName);
79
+ if (!linkStatInfo.isSymlink) {
80
+ const type = getFileInfoType(linkStatInfo);
81
+ throw new dntShim.Deno.errors.AlreadyExists(`A '${type}' already exists at the path: ${linkName}`);
82
+ }
83
+ const linkPath = await dntShim.Deno.readLink(linkName);
84
+ const linkRealPath = resolve(linkPath);
85
+ if (linkRealPath !== targetRealPath) {
86
+ throw new dntShim.Deno.errors.AlreadyExists(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
87
+ }
88
+ }
89
+ }
90
+ /**
91
+ * Synchronously ensures that the link exists, and points to a valid file.
92
+ *
93
+ * If the parent directories for the link do not exist, they are created. If the
94
+ * link already exists, and it is not modified, this function does nothing. If
95
+ * the link already exists, and it does not point to the given target, an error
96
+ * is thrown.
97
+ *
98
+ * Requires `--allow-read` and `--allow-write` permissions.
99
+ *
100
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
101
+ * for more information on Deno's permissions system.
102
+ *
103
+ * @param target The source file path as a string or URL. If it is a relative path string, it have to be relative to the link path.
104
+ * @param linkName The destination link path as a string or URL.
105
+ * @returns A void value that returns once the link exists.
106
+ *
107
+ * @example Basic usage
108
+ * ```ts ignore
109
+ * import { ensureSymlinkSync } from "@std/fs/ensure-symlink";
110
+ *
111
+ * // Ensures the link `./targetFile.link.dat` exists and points to `./targetFile.dat`
112
+ * ensureSymlinkSync("./targetFile.dat", "./targetFile.link.dat");
113
+ * ```
114
+ *
115
+ * @example Ensuring a link in a folder
116
+ * ```ts ignore
117
+ * import { ensureSymlinkSync } from "@std/fs/ensure-symlink";
118
+ *
119
+ * // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
120
+ * ensureSymlinkSync("./targetFile.dat", "./folder/targetFile.link.dat");
121
+ * ```
122
+ */
123
+ export function ensureSymlinkSync(target, linkName) {
124
+ const targetRealPath = resolveSymlinkTarget(target, linkName);
125
+ let srcStatInfo;
126
+ try {
127
+ srcStatInfo = dntShim.Deno.lstatSync(targetRealPath);
128
+ }
129
+ catch (error) {
130
+ if (error instanceof dntShim.Deno.errors.NotFound) {
131
+ throw new dntShim.Deno.errors.NotFound(`Cannot ensure symlink as the target path does not exist: ${targetRealPath}`);
132
+ }
133
+ throw error;
134
+ }
135
+ const srcFilePathType = getFileInfoType(srcStatInfo);
136
+ ensureDirSync(dirname(toPathString(linkName)));
137
+ const options = getSymlinkOption(srcFilePathType);
138
+ try {
139
+ dntShim.Deno.symlinkSync(target, linkName, options);
140
+ }
141
+ catch (error) {
142
+ if (!(error instanceof dntShim.Deno.errors.AlreadyExists)) {
143
+ throw error;
144
+ }
145
+ const linkStatInfo = dntShim.Deno.lstatSync(linkName);
146
+ if (!linkStatInfo.isSymlink) {
147
+ const type = getFileInfoType(linkStatInfo);
148
+ throw new dntShim.Deno.errors.AlreadyExists(`A '${type}' already exists at the path: ${linkName}`);
149
+ }
150
+ const linkPath = dntShim.Deno.readLinkSync(linkName);
151
+ const linkRealPath = resolve(linkPath);
152
+ if (linkRealPath !== targetRealPath) {
153
+ throw new dntShim.Deno.errors.AlreadyExists(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
154
+ }
155
+ }
156
+ }
@@ -0,0 +1,52 @@
1
+ export declare const LF: "\n";
2
+ /** End-of-line character for Windows platforms. */
3
+ export declare const CRLF: "\r\n";
4
+ /**
5
+ * End-of-line character evaluated for the current platform.
6
+ *
7
+ * @example Usage
8
+ * ```ts ignore
9
+ * import { EOL } from "@std/fs/eol";
10
+ *
11
+ * EOL; // "\n" on POSIX platforms and "\r\n" on Windows
12
+ * ```
13
+ */
14
+ export declare const EOL: "\n" | "\r\n";
15
+ /**
16
+ * Returns the detected EOL character(s) detected in the input string. If no EOL
17
+ * character is detected, `null` is returned.
18
+ *
19
+ * @param content The input string to detect EOL characters.
20
+ *
21
+ * @returns The detected EOL character(s) or `null` if no EOL character is detected.
22
+ *
23
+ * @example Usage
24
+ * ```ts ignore
25
+ * import { detect } from "@std/fs/eol";
26
+ *
27
+ * detect("deno\r\nis not\r\nnode"); // "\r\n"
28
+ * detect("deno\nis not\r\nnode"); // "\r\n"
29
+ * detect("deno\nis not\nnode"); // "\n"
30
+ * detect("deno is not node"); // null
31
+ * ```
32
+ */
33
+ export declare function detect(content: string): typeof EOL | null;
34
+ /**
35
+ * Normalize the input string to the targeted EOL.
36
+ *
37
+ * @param content The input string to normalize.
38
+ * @param eol The EOL character(s) to normalize the input string to.
39
+ *
40
+ * @returns The input string normalized to the targeted EOL.
41
+ *
42
+ * @example Usage
43
+ * ```ts ignore
44
+ * import { LF, format } from "@std/fs/eol";
45
+ *
46
+ * const CRLFinput = "deno\r\nis not\r\nnode";
47
+ *
48
+ * format(CRLFinput, LF); // "deno\nis not\nnode"
49
+ * ```
50
+ */
51
+ export declare function format(content: string, eol: typeof EOL): string;
52
+ //# sourceMappingURL=eol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eol.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.22/eol.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,EAAE,EAAG,IAAa,CAAC;AAEhC,mDAAmD;AACnD,eAAO,MAAM,IAAI,EAAG,MAAe,CAAC;AAEpC;;;;;;;;;GASG;AACH,eAAO,MAAM,GAAG,EAAE,IAAI,GAAG,MAEgD,CAAC;AAI1E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,GAAG,IAAI,CAQzD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,67 @@
1
+ // Copyright 2018-2026 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ /** End-of-line character for POSIX platforms such as macOS and Linux. */
4
+ import * as dntShim from "../../../../../_dnt.shims.js";
5
+ export const LF = "\n";
6
+ /** End-of-line character for Windows platforms. */
7
+ export const CRLF = "\r\n";
8
+ /**
9
+ * End-of-line character evaluated for the current platform.
10
+ *
11
+ * @example Usage
12
+ * ```ts ignore
13
+ * import { EOL } from "@std/fs/eol";
14
+ *
15
+ * EOL; // "\n" on POSIX platforms and "\r\n" on Windows
16
+ * ```
17
+ */
18
+ export const EOL =
19
+ // deno-lint-ignore no-explicit-any
20
+ dntShim.dntGlobalThis.Deno?.build.os === "windows" ? CRLF : LF;
21
+ const regDetect = /(?:\r?\n)/g;
22
+ /**
23
+ * Returns the detected EOL character(s) detected in the input string. If no EOL
24
+ * character is detected, `null` is returned.
25
+ *
26
+ * @param content The input string to detect EOL characters.
27
+ *
28
+ * @returns The detected EOL character(s) or `null` if no EOL character is detected.
29
+ *
30
+ * @example Usage
31
+ * ```ts ignore
32
+ * import { detect } from "@std/fs/eol";
33
+ *
34
+ * detect("deno\r\nis not\r\nnode"); // "\r\n"
35
+ * detect("deno\nis not\r\nnode"); // "\r\n"
36
+ * detect("deno\nis not\nnode"); // "\n"
37
+ * detect("deno is not node"); // null
38
+ * ```
39
+ */
40
+ export function detect(content) {
41
+ const d = content.match(regDetect);
42
+ if (!d || d.length === 0) {
43
+ return null;
44
+ }
45
+ const hasCRLF = d.some((x) => x === CRLF);
46
+ return hasCRLF ? CRLF : LF;
47
+ }
48
+ /**
49
+ * Normalize the input string to the targeted EOL.
50
+ *
51
+ * @param content The input string to normalize.
52
+ * @param eol The EOL character(s) to normalize the input string to.
53
+ *
54
+ * @returns The input string normalized to the targeted EOL.
55
+ *
56
+ * @example Usage
57
+ * ```ts ignore
58
+ * import { LF, format } from "@std/fs/eol";
59
+ *
60
+ * const CRLFinput = "deno\r\nis not\r\nnode";
61
+ *
62
+ * format(CRLFinput, LF); // "deno\nis not\nnode"
63
+ * ```
64
+ */
65
+ export function format(content, eol) {
66
+ return content.replace(regDetect, eol);
67
+ }