@bolt-foundry/gambit 0.8.1 → 0.8.5-rc.10

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 (293) hide show
  1. package/CHANGELOG.md +150 -2
  2. package/README.md +109 -23
  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 +123 -0
  6. package/esm/deps/jsr.io/@std/collections/1.1.6/deep_merge.d.ts +322 -0
  7. package/esm/deps/jsr.io/@std/collections/1.1.6/deep_merge.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/collections/1.1.6/deep_merge.js +105 -0
  9. package/esm/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.d.ts +14 -0
  10. package/esm/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.js +34 -0
  12. package/esm/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.d.ts +13 -0
  13. package/esm/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.d.ts.map +1 -0
  14. package/esm/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.js +18 -0
  15. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_same_path.d.ts +10 -0
  16. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_same_path.d.ts.map +1 -0
  17. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_same_path.js +17 -0
  18. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_subdir.d.ts +12 -0
  19. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_subdir.d.ts.map +1 -0
  20. package/esm/deps/jsr.io/@std/fs/1.0.23/_is_subdir.js +25 -0
  21. package/esm/deps/jsr.io/@std/fs/1.0.23/_to_path_string.d.ts +9 -0
  22. package/esm/deps/jsr.io/@std/fs/1.0.23/_to_path_string.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@std/fs/1.0.23/_to_path_string.js +13 -0
  24. package/esm/deps/jsr.io/@std/fs/1.0.23/copy.d.ts +117 -0
  25. package/esm/deps/jsr.io/@std/fs/1.0.23/copy.d.ts.map +1 -0
  26. package/esm/deps/jsr.io/@std/fs/1.0.23/copy.js +313 -0
  27. package/esm/deps/jsr.io/@std/fs/1.0.23/empty_dir.d.ts +48 -0
  28. package/esm/deps/jsr.io/@std/fs/1.0.23/empty_dir.d.ts.map +1 -0
  29. package/esm/deps/jsr.io/@std/fs/1.0.23/empty_dir.js +87 -0
  30. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_dir.d.ts +49 -0
  31. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_dir.d.ts.map +1 -0
  32. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_dir.js +102 -0
  33. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_file.d.ts +47 -0
  34. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_file.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_file.js +90 -0
  36. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_link.d.ts +49 -0
  37. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_link.d.ts.map +1 -0
  38. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_link.js +61 -0
  39. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.d.ts +70 -0
  40. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.d.ts.map +1 -0
  41. package/esm/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.js +156 -0
  42. package/esm/deps/jsr.io/@std/fs/1.0.23/eol.d.ts +52 -0
  43. package/esm/deps/jsr.io/@std/fs/1.0.23/eol.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/fs/1.0.23/eol.js +67 -0
  45. package/esm/deps/jsr.io/@std/fs/1.0.23/exists.d.ts +218 -0
  46. package/esm/deps/jsr.io/@std/fs/1.0.23/exists.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@std/fs/1.0.23/exists.js +271 -0
  48. package/esm/deps/jsr.io/@std/fs/1.0.23/expand_glob.d.ts +267 -0
  49. package/esm/deps/jsr.io/@std/fs/1.0.23/expand_glob.d.ts.map +1 -0
  50. package/esm/deps/jsr.io/@std/fs/1.0.23/expand_glob.js +442 -0
  51. package/esm/deps/jsr.io/@std/fs/1.0.23/mod.d.ts +29 -0
  52. package/esm/deps/jsr.io/@std/fs/1.0.23/mod.d.ts.map +1 -0
  53. package/esm/deps/jsr.io/@std/fs/1.0.23/mod.js +29 -0
  54. package/esm/deps/jsr.io/@std/fs/1.0.23/move.d.ts +86 -0
  55. package/esm/deps/jsr.io/@std/fs/1.0.23/move.d.ts.map +1 -0
  56. package/esm/deps/jsr.io/@std/fs/1.0.23/move.js +142 -0
  57. package/esm/deps/jsr.io/@std/fs/1.0.23/walk.d.ts +777 -0
  58. package/esm/deps/jsr.io/@std/fs/1.0.23/walk.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@std/fs/1.0.23/walk.js +846 -0
  60. package/esm/deps/jsr.io/@std/json/1.0.3/types.d.ts +7 -0
  61. package/esm/deps/jsr.io/@std/json/1.0.3/types.d.ts.map +1 -0
  62. package/esm/deps/jsr.io/@std/json/1.0.3/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/path/1.1.4/constants.d.ts +1 -1
  70. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  71. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +753 -0
  73. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
  74. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/toml/1.0.11/mod.js +110 -0
  76. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  77. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  78. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.js +25 -0
  79. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
  80. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
  81. package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.js +283 -0
  82. package/esm/gambit/simulator-ui/dist/bundle.js +12670 -5471
  83. package/esm/gambit/simulator-ui/dist/bundle.js.map +4 -4
  84. package/esm/gambit/simulator-ui/dist/favicon.ico +0 -0
  85. package/esm/mod.d.ts +21 -7
  86. package/esm/mod.d.ts.map +1 -1
  87. package/esm/mod.js +14 -4
  88. package/esm/src/cli_utils.d.ts +1 -0
  89. package/esm/src/cli_utils.d.ts.map +1 -1
  90. package/esm/src/cli_utils.js +52 -4
  91. package/esm/src/default_runtime.d.ts +46 -0
  92. package/esm/src/default_runtime.d.ts.map +1 -0
  93. package/esm/src/default_runtime.js +415 -0
  94. package/esm/src/durable_streams.js +26 -1
  95. package/esm/src/model_matchers.d.ts +10 -0
  96. package/esm/src/model_matchers.d.ts.map +1 -0
  97. package/esm/src/model_matchers.js +26 -0
  98. package/esm/src/openai_compat.d.ts +74 -0
  99. package/esm/src/openai_compat.d.ts.map +1 -0
  100. package/esm/src/openai_compat.js +329 -0
  101. package/esm/src/project_config.d.ts +47 -0
  102. package/esm/src/project_config.d.ts.map +1 -0
  103. package/esm/src/project_config.js +134 -0
  104. package/esm/src/providers/codex.d.ts +37 -0
  105. package/esm/src/providers/codex.d.ts.map +1 -0
  106. package/esm/src/providers/codex.js +810 -0
  107. package/esm/src/providers/google.d.ts +18 -0
  108. package/esm/src/providers/google.d.ts.map +1 -0
  109. package/esm/src/providers/google.js +428 -0
  110. package/esm/src/providers/ollama.d.ts +19 -0
  111. package/esm/src/providers/ollama.d.ts.map +1 -0
  112. package/esm/src/providers/ollama.js +789 -0
  113. package/esm/src/providers/openrouter.d.ts +26 -0
  114. package/esm/src/providers/openrouter.d.ts.map +1 -0
  115. package/esm/src/providers/openrouter.js +886 -0
  116. package/esm/src/providers/router.d.ts +19 -0
  117. package/esm/src/providers/router.d.ts.map +1 -0
  118. package/esm/src/providers/router.js +93 -0
  119. package/esm/src/server.d.ts +11 -0
  120. package/esm/src/server.d.ts.map +1 -1
  121. package/esm/src/server.js +3927 -689
  122. package/esm/src/server_feedback_grading_routes.d.ts +32 -0
  123. package/esm/src/server_feedback_grading_routes.d.ts.map +1 -0
  124. package/esm/src/server_feedback_grading_routes.js +305 -0
  125. package/esm/src/server_helpers.d.ts +4 -0
  126. package/esm/src/server_helpers.d.ts.map +1 -0
  127. package/esm/src/server_helpers.js +46 -0
  128. package/esm/src/server_session_store.d.ts +87 -0
  129. package/esm/src/server_session_store.d.ts.map +1 -0
  130. package/esm/src/server_session_store.js +873 -0
  131. package/esm/src/server_types.d.ts +110 -0
  132. package/esm/src/server_types.d.ts.map +1 -0
  133. package/esm/src/server_types.js +1 -0
  134. package/esm/src/server_ui_routes.d.ts +33 -0
  135. package/esm/src/server_ui_routes.d.ts.map +1 -0
  136. package/esm/src/server_ui_routes.js +136 -0
  137. package/esm/src/session_artifacts.d.ts +22 -0
  138. package/esm/src/session_artifacts.d.ts.map +1 -0
  139. package/esm/src/session_artifacts.js +243 -0
  140. package/esm/src/trace.d.ts.map +1 -1
  141. package/esm/src/trace.js +8 -5
  142. package/esm/src/workspace.d.ts +19 -0
  143. package/esm/src/workspace.d.ts.map +1 -0
  144. package/esm/src/workspace.js +162 -0
  145. package/esm/src/workspace_contract.d.ts +78 -0
  146. package/esm/src/workspace_contract.d.ts.map +1 -0
  147. package/esm/src/workspace_contract.js +76 -0
  148. package/package.json +3 -2
  149. package/script/_dnt.polyfills.d.ts +17 -0
  150. package/script/_dnt.polyfills.d.ts.map +1 -1
  151. package/script/_dnt.polyfills.js +123 -0
  152. package/script/deps/jsr.io/@std/collections/1.1.6/deep_merge.d.ts +322 -0
  153. package/script/deps/jsr.io/@std/collections/1.1.6/deep_merge.d.ts.map +1 -0
  154. package/script/deps/jsr.io/@std/collections/1.1.6/deep_merge.js +108 -0
  155. package/script/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.d.ts +14 -0
  156. package/script/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.d.ts.map +1 -0
  157. package/script/deps/jsr.io/@std/fs/1.0.23/_create_walk_entry.js +71 -0
  158. package/script/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.d.ts +13 -0
  159. package/script/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.d.ts.map +1 -0
  160. package/script/deps/jsr.io/@std/fs/1.0.23/_get_file_info_type.js +21 -0
  161. package/script/deps/jsr.io/@std/fs/1.0.23/_is_same_path.d.ts +10 -0
  162. package/script/deps/jsr.io/@std/fs/1.0.23/_is_same_path.d.ts.map +1 -0
  163. package/script/deps/jsr.io/@std/fs/1.0.23/_is_same_path.js +20 -0
  164. package/script/deps/jsr.io/@std/fs/1.0.23/_is_subdir.d.ts +12 -0
  165. package/script/deps/jsr.io/@std/fs/1.0.23/_is_subdir.d.ts.map +1 -0
  166. package/script/deps/jsr.io/@std/fs/1.0.23/_is_subdir.js +28 -0
  167. package/script/deps/jsr.io/@std/fs/1.0.23/_to_path_string.d.ts +9 -0
  168. package/script/deps/jsr.io/@std/fs/1.0.23/_to_path_string.d.ts.map +1 -0
  169. package/script/deps/jsr.io/@std/fs/1.0.23/_to_path_string.js +16 -0
  170. package/script/deps/jsr.io/@std/fs/1.0.23/copy.d.ts +117 -0
  171. package/script/deps/jsr.io/@std/fs/1.0.23/copy.d.ts.map +1 -0
  172. package/script/deps/jsr.io/@std/fs/1.0.23/copy.js +350 -0
  173. package/script/deps/jsr.io/@std/fs/1.0.23/empty_dir.d.ts +48 -0
  174. package/script/deps/jsr.io/@std/fs/1.0.23/empty_dir.d.ts.map +1 -0
  175. package/script/deps/jsr.io/@std/fs/1.0.23/empty_dir.js +124 -0
  176. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_dir.d.ts +49 -0
  177. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_dir.d.ts.map +1 -0
  178. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_dir.js +139 -0
  179. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_file.d.ts +47 -0
  180. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_file.d.ts.map +1 -0
  181. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_file.js +127 -0
  182. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_link.d.ts +49 -0
  183. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_link.d.ts.map +1 -0
  184. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_link.js +98 -0
  185. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.d.ts +70 -0
  186. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.d.ts.map +1 -0
  187. package/script/deps/jsr.io/@std/fs/1.0.23/ensure_symlink.js +193 -0
  188. package/script/deps/jsr.io/@std/fs/1.0.23/eol.d.ts +52 -0
  189. package/script/deps/jsr.io/@std/fs/1.0.23/eol.d.ts.map +1 -0
  190. package/script/deps/jsr.io/@std/fs/1.0.23/eol.js +105 -0
  191. package/script/deps/jsr.io/@std/fs/1.0.23/exists.d.ts +218 -0
  192. package/script/deps/jsr.io/@std/fs/1.0.23/exists.d.ts.map +1 -0
  193. package/script/deps/jsr.io/@std/fs/1.0.23/exists.js +308 -0
  194. package/script/deps/jsr.io/@std/fs/1.0.23/expand_glob.d.ts +267 -0
  195. package/script/deps/jsr.io/@std/fs/1.0.23/expand_glob.d.ts.map +1 -0
  196. package/script/deps/jsr.io/@std/fs/1.0.23/expand_glob.js +479 -0
  197. package/script/deps/jsr.io/@std/fs/1.0.23/mod.d.ts +29 -0
  198. package/script/deps/jsr.io/@std/fs/1.0.23/mod.d.ts.map +1 -0
  199. package/script/deps/jsr.io/@std/fs/1.0.23/mod.js +45 -0
  200. package/script/deps/jsr.io/@std/fs/1.0.23/move.d.ts +86 -0
  201. package/script/deps/jsr.io/@std/fs/1.0.23/move.d.ts.map +1 -0
  202. package/script/deps/jsr.io/@std/fs/1.0.23/move.js +179 -0
  203. package/script/deps/jsr.io/@std/fs/1.0.23/walk.d.ts +777 -0
  204. package/script/deps/jsr.io/@std/fs/1.0.23/walk.d.ts.map +1 -0
  205. package/script/deps/jsr.io/@std/fs/1.0.23/walk.js +883 -0
  206. package/script/deps/jsr.io/@std/json/1.0.3/types.d.ts +7 -0
  207. package/script/deps/jsr.io/@std/json/1.0.3/types.d.ts.map +1 -0
  208. package/script/deps/jsr.io/@std/json/1.0.3/types.js +4 -0
  209. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts +20 -0
  210. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts.map +1 -0
  211. package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.js +37 -0
  212. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts +21 -0
  213. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts.map +1 -0
  214. package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.js +323 -0
  215. package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts +1 -1
  216. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  217. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  218. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +781 -0
  219. package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
  220. package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
  221. package/script/deps/jsr.io/@std/toml/1.0.11/mod.js +126 -0
  222. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  223. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  224. package/script/deps/jsr.io/@std/toml/1.0.11/parse.js +28 -0
  225. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
  226. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
  227. package/script/deps/jsr.io/@std/toml/1.0.11/stringify.js +286 -0
  228. package/script/gambit/simulator-ui/dist/bundle.js +12670 -5471
  229. package/script/gambit/simulator-ui/dist/bundle.js.map +4 -4
  230. package/script/gambit/simulator-ui/dist/favicon.ico +0 -0
  231. package/script/mod.d.ts +21 -7
  232. package/script/mod.d.ts.map +1 -1
  233. package/script/mod.js +22 -7
  234. package/script/src/cli_utils.d.ts +1 -0
  235. package/script/src/cli_utils.d.ts.map +1 -1
  236. package/script/src/cli_utils.js +52 -3
  237. package/script/src/default_runtime.d.ts +46 -0
  238. package/script/src/default_runtime.d.ts.map +1 -0
  239. package/script/src/default_runtime.js +452 -0
  240. package/script/src/durable_streams.js +26 -1
  241. package/script/src/model_matchers.d.ts +10 -0
  242. package/script/src/model_matchers.d.ts.map +1 -0
  243. package/script/src/model_matchers.js +29 -0
  244. package/script/src/openai_compat.d.ts +74 -0
  245. package/script/src/openai_compat.d.ts.map +1 -0
  246. package/script/src/openai_compat.js +366 -0
  247. package/script/src/project_config.d.ts +47 -0
  248. package/script/src/project_config.d.ts.map +1 -0
  249. package/script/src/project_config.js +173 -0
  250. package/script/src/providers/codex.d.ts +37 -0
  251. package/script/src/providers/codex.d.ts.map +1 -0
  252. package/script/src/providers/codex.js +850 -0
  253. package/script/src/providers/google.d.ts +18 -0
  254. package/script/src/providers/google.d.ts.map +1 -0
  255. package/script/src/providers/google.js +435 -0
  256. package/script/src/providers/ollama.d.ts +19 -0
  257. package/script/src/providers/ollama.d.ts.map +1 -0
  258. package/script/src/providers/ollama.js +831 -0
  259. package/script/src/providers/openrouter.d.ts +26 -0
  260. package/script/src/providers/openrouter.d.ts.map +1 -0
  261. package/script/src/providers/openrouter.js +926 -0
  262. package/script/src/providers/router.d.ts +19 -0
  263. package/script/src/providers/router.d.ts.map +1 -0
  264. package/script/src/providers/router.js +96 -0
  265. package/script/src/server.d.ts +11 -0
  266. package/script/src/server.d.ts.map +1 -1
  267. package/script/src/server.js +3931 -693
  268. package/script/src/server_feedback_grading_routes.d.ts +32 -0
  269. package/script/src/server_feedback_grading_routes.d.ts.map +1 -0
  270. package/script/src/server_feedback_grading_routes.js +343 -0
  271. package/script/src/server_helpers.d.ts +4 -0
  272. package/script/src/server_helpers.d.ts.map +1 -0
  273. package/script/src/server_helpers.js +84 -0
  274. package/script/src/server_session_store.d.ts +87 -0
  275. package/script/src/server_session_store.d.ts.map +1 -0
  276. package/script/src/server_session_store.js +910 -0
  277. package/script/src/server_types.d.ts +110 -0
  278. package/script/src/server_types.d.ts.map +1 -0
  279. package/script/src/server_types.js +2 -0
  280. package/script/src/server_ui_routes.d.ts +33 -0
  281. package/script/src/server_ui_routes.d.ts.map +1 -0
  282. package/script/src/server_ui_routes.js +173 -0
  283. package/script/src/session_artifacts.d.ts +22 -0
  284. package/script/src/session_artifacts.d.ts.map +1 -0
  285. package/script/src/session_artifacts.js +279 -0
  286. package/script/src/trace.d.ts.map +1 -1
  287. package/script/src/trace.js +8 -5
  288. package/script/src/workspace.d.ts +19 -0
  289. package/script/src/workspace.d.ts.map +1 -0
  290. package/script/src/workspace.js +199 -0
  291. package/script/src/workspace_contract.d.ts +78 -0
  292. package/script/src/workspace_contract.d.ts.map +1 -0
  293. package/script/src/workspace_contract.js +84 -0
@@ -0,0 +1,267 @@
1
+ import { type GlobOptions } from "../../path/1.1.4/glob_to_regexp.js";
2
+ import { type WalkEntry } from "./_create_walk_entry.js";
3
+ export type { GlobOptions, WalkEntry };
4
+ /** Options for {@linkcode expandGlob} and {@linkcode expandGlobSync}. */
5
+ export interface ExpandGlobOptions extends Omit<GlobOptions, "os"> {
6
+ /**
7
+ * File path where to expand from.
8
+ *
9
+ * @default {Deno.cwd()}
10
+ */
11
+ root?: string;
12
+ /**
13
+ * List of glob patterns to be excluded from the expansion.
14
+ *
15
+ * @default {[]}
16
+ */
17
+ exclude?: string[];
18
+ /**
19
+ * Whether to include directories in entries.
20
+ *
21
+ * @default {true}
22
+ */
23
+ includeDirs?: boolean;
24
+ /**
25
+ * Whether to follow symbolic links.
26
+ *
27
+ * @default {false}
28
+ */
29
+ followSymlinks?: boolean;
30
+ /**
31
+ * Indicates whether the followed symlink's path should be canonicalized.
32
+ * This option works only if `followSymlinks` is not `false`.
33
+ *
34
+ * @default {true}
35
+ */
36
+ canonicalize?: boolean;
37
+ }
38
+ /**
39
+ * Returns an async iterator that yields each file path matching the given glob
40
+ * pattern.
41
+ *
42
+ * The file paths are absolute paths. If `root` is not provided, the current
43
+ * working directory is used. The `root` directory is not included in the
44
+ * yielded file paths.
45
+ *
46
+ * Requires `--allow-read` permission.
47
+ *
48
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
49
+ * for more information on Deno's permissions system.
50
+ *
51
+ * @param glob The glob pattern to expand.
52
+ * @param options Additional options for the expansion.
53
+ *
54
+ * @returns An async iterator that yields each walk entry matching the glob
55
+ * pattern.
56
+ *
57
+ * @example Basic usage
58
+ *
59
+ * File structure:
60
+ * ```
61
+ * folder
62
+ * ├── script.ts
63
+ * └── foo.ts
64
+ * ```
65
+ *
66
+ * ```ts ignore
67
+ * // script.ts
68
+ * import { expandGlob } from "@std/fs/expand-glob";
69
+ *
70
+ * await Array.fromAsync(expandGlob("*.ts"));
71
+ * // [
72
+ * // {
73
+ * // path: "/Users/user/folder/script.ts",
74
+ * // name: "script.ts",
75
+ * // isFile: true,
76
+ * // isDirectory: false,
77
+ * // isSymlink: false,
78
+ * // },
79
+ * // {
80
+ * // path: "/Users/user/folder/foo.ts",
81
+ * // name: "foo.ts",
82
+ * // isFile: true,
83
+ * // isDirectory: false,
84
+ * // isSymlink: false,
85
+ * // },
86
+ * // ]
87
+ * ```
88
+ *
89
+ * @example Define root directory
90
+ *
91
+ * Setting the `root` option to `/folder` will expand the glob pattern from the
92
+ * `/folder` directory.
93
+ *
94
+ * File structure:
95
+ * ```
96
+ * folder
97
+ * ├── subdir
98
+ * │ └── bar.ts
99
+ * ├── script.ts
100
+ * └── foo.ts
101
+ * ```
102
+ *
103
+ * ```ts ignore
104
+ * // script.ts
105
+ * import { expandGlob } from "@std/fs/expand-glob";
106
+ *
107
+ * await Array.fromAsync(expandGlob("*.ts", { root: "./subdir" }));
108
+ * // [
109
+ * // {
110
+ * // path: "/Users/user/folder/subdir/bar.ts",
111
+ * // name: "bar.ts",
112
+ * // isFile: true,
113
+ * // isDirectory: false,
114
+ * // isSymlink: false,
115
+ * // },
116
+ * // ]
117
+ * ```
118
+ *
119
+ * @example Exclude files
120
+ *
121
+ * Setting the `exclude` option to `["foo.ts"]` will exclude the `foo.ts` file
122
+ * from the expansion.
123
+ *
124
+ * File structure:
125
+ * ```
126
+ * folder
127
+ * ├── script.ts
128
+ * └── foo.ts
129
+ * ```
130
+ *
131
+ * ```ts ignore
132
+ * // script.ts
133
+ * import { expandGlob } from "@std/fs/expand-glob";
134
+ *
135
+ * await Array.fromAsync(expandGlob("*.ts", { exclude: ["foo.ts"] }));
136
+ * // [
137
+ * // {
138
+ * // path: "/Users/user/folder/script.ts",
139
+ * // name: "true.ts",
140
+ * // isFile: false,
141
+ * // isDirectory: false,
142
+ * // isSymlink: false,
143
+ * // },
144
+ * // ]
145
+ * ```
146
+ *
147
+ * @example Exclude directories
148
+ *
149
+ * Setting the `includeDirs` option to `false` will exclude directories from the
150
+ * expansion.
151
+ *
152
+ * File structure:
153
+ * ```
154
+ * folder
155
+ * ├── subdir
156
+ * │ └── bar.ts
157
+ * ├── script.ts
158
+ * └── foo.ts
159
+ * ```
160
+ *
161
+ * ```ts ignore
162
+ * // script.ts
163
+ * import { expandGlob } from "@std/fs/expand-glob";
164
+ *
165
+ * await Array.fromAsync(expandGlob("*", { includeDirs: false }));
166
+ * // [
167
+ * // {
168
+ * // path: "/Users/user/folder/script.ts",
169
+ * // name: "script.ts",
170
+ * // isFile: true,
171
+ * // isDirectory: false,
172
+ * // isSymlink: false,
173
+ * // },
174
+ * // {
175
+ * // path: "/Users/user/folder/foo.ts",
176
+ * // name: "foo.ts",
177
+ * // isFile: true,
178
+ * // isDirectory: false,
179
+ * // isSymlink: false,
180
+ * // },
181
+ * // ]
182
+ * ```
183
+ *
184
+ * @example Follow symbolic links
185
+ *
186
+ * Setting the `followSymlinks` option to `true` will follow symbolic links.
187
+ *
188
+ * File structure:
189
+ * ```
190
+ * folder
191
+ * ├── script.ts
192
+ * └── link.ts -> script.ts (symbolic link)
193
+ * ```
194
+ *
195
+ * ```ts ignore
196
+ * // script.ts
197
+ * import { expandGlob } from "@std/fs/expand-glob";
198
+ *
199
+ * await Array.fromAsync(expandGlob("*.ts", { followSymlinks: true }));
200
+ * // [
201
+ * // {
202
+ * // path: "/Users/user/folder/script.ts",
203
+ * // name: "script.ts",
204
+ * // isFile: true,
205
+ * // isDirectory: false,
206
+ * // isSymlink: false,
207
+ * // },
208
+ * // {
209
+ * // path: "/Users/user/folder/symlink",
210
+ * // name: "symlink",
211
+ * // isFile: true,
212
+ * // isDirectory: false,
213
+ * // isSymlink: true,
214
+ * // },
215
+ * // ]
216
+ * ```
217
+ */
218
+ export declare function expandGlob(glob: string | URL, options?: ExpandGlobOptions): AsyncIterableIterator<WalkEntry>;
219
+ /**
220
+ * Returns an iterator that yields each file path matching the given glob
221
+ * pattern. The file paths are relative to the provided `root` directory.
222
+ * If `root` is not provided, the current working directory is used.
223
+ * The `root` directory is not included in the yielded file paths.
224
+ *
225
+ * Requires the `--allow-read` flag.
226
+ *
227
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
228
+ * for more information on Deno's permissions system.
229
+ *
230
+ * @param glob The glob pattern to expand.
231
+ * @param options Additional options for the expansion.
232
+ *
233
+ * @returns An iterator that yields each walk entry matching the glob pattern.
234
+ *
235
+ * @example Usage
236
+ *
237
+ * File structure:
238
+ * ```
239
+ * folder
240
+ * ├── script.ts
241
+ * └── foo.ts
242
+ * ```
243
+ *
244
+ * ```ts ignore
245
+ * // script.ts
246
+ * import { expandGlobSync } from "@std/fs/expand-glob";
247
+ *
248
+ * const entries = [];
249
+ * for (const entry of expandGlobSync("*.ts")) {
250
+ * entries.push(entry);
251
+ * }
252
+ *
253
+ * entries[0]!.path; // "/Users/user/folder/script.ts"
254
+ * entries[0]!.name; // "script.ts"
255
+ * entries[0]!.isFile; // false
256
+ * entries[0]!.isDirectory; // true
257
+ * entries[0]!.isSymlink; // false
258
+ *
259
+ * entries[1]!.path; // "/Users/user/folder/foo.ts"
260
+ * entries[1]!.name; // "foo.ts"
261
+ * entries[1]!.isFile; // true
262
+ * entries[1]!.isDirectory; // false
263
+ * entries[1]!.isSymlink; // false
264
+ * ```
265
+ */
266
+ export declare function expandGlobSync(glob: string | URL, options?: ExpandGlobOptions): IterableIterator<WalkEntry>;
267
+ //# sourceMappingURL=expand_glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expand_glob.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fs/1.0.23/expand_glob.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,oCAAoC,CAAC;AAQpF,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAEvC,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IAChE;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAuCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmLG;AACH,wBAAuB,UAAU,CAC/B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,qBAAqB,CAAC,SAAS,CAAC,CAyGlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAiB,cAAc,CAC7B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAAC,SAAS,CAAC,CAuG7B"}
@@ -0,0 +1,442 @@
1
+ // Copyright 2018-2026 the Deno authors. MIT license.
2
+ import * as dntShim from "../../../../../_dnt.shims.js";
3
+ import { globToRegExp } from "../../path/1.1.4/glob_to_regexp.js";
4
+ import { joinGlobs } from "../../path/1.1.4/join_globs.js";
5
+ import { isGlob } from "../../path/1.1.4/is_glob.js";
6
+ import { isAbsolute } from "../../path/1.1.4/is_absolute.js";
7
+ import { resolve } from "../../path/1.1.4/resolve.js";
8
+ import { SEPARATOR_PATTERN } from "../../path/1.1.4/constants.js";
9
+ import { walk, walkSync } from "./walk.js";
10
+ import { toPathString } from "./_to_path_string.js";
11
+ import { createWalkEntry, createWalkEntrySync, } from "./_create_walk_entry.js";
12
+ import { isWindows } from "../../internal/1.0.12/os.js";
13
+ function split(path) {
14
+ const s = SEPARATOR_PATTERN.source;
15
+ const segments = path
16
+ .replace(new RegExp(`^${s}|${s}$`, "g"), "")
17
+ .split(SEPARATOR_PATTERN);
18
+ const isAbsolute_ = isAbsolute(path);
19
+ const split = {
20
+ segments,
21
+ isAbsolute: isAbsolute_,
22
+ hasTrailingSep: path.match(new RegExp(`${s}$`)) !== null,
23
+ };
24
+ if (isWindows && isAbsolute_) {
25
+ split.winRoot = segments.shift();
26
+ }
27
+ return split;
28
+ }
29
+ function throwUnlessNotFound(error) {
30
+ if (!(error instanceof dntShim.Deno.errors.NotFound)) {
31
+ throw error;
32
+ }
33
+ }
34
+ function comparePath(a, b) {
35
+ if (a.path < b.path)
36
+ return -1;
37
+ if (a.path > b.path)
38
+ return 1;
39
+ return 0;
40
+ }
41
+ /**
42
+ * Returns an async iterator that yields each file path matching the given glob
43
+ * pattern.
44
+ *
45
+ * The file paths are absolute paths. If `root` is not provided, the current
46
+ * working directory is used. The `root` directory is not included in the
47
+ * yielded file paths.
48
+ *
49
+ * Requires `--allow-read` permission.
50
+ *
51
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
52
+ * for more information on Deno's permissions system.
53
+ *
54
+ * @param glob The glob pattern to expand.
55
+ * @param options Additional options for the expansion.
56
+ *
57
+ * @returns An async iterator that yields each walk entry matching the glob
58
+ * pattern.
59
+ *
60
+ * @example Basic usage
61
+ *
62
+ * File structure:
63
+ * ```
64
+ * folder
65
+ * ├── script.ts
66
+ * └── foo.ts
67
+ * ```
68
+ *
69
+ * ```ts ignore
70
+ * // script.ts
71
+ * import { expandGlob } from "@std/fs/expand-glob";
72
+ *
73
+ * await Array.fromAsync(expandGlob("*.ts"));
74
+ * // [
75
+ * // {
76
+ * // path: "/Users/user/folder/script.ts",
77
+ * // name: "script.ts",
78
+ * // isFile: true,
79
+ * // isDirectory: false,
80
+ * // isSymlink: false,
81
+ * // },
82
+ * // {
83
+ * // path: "/Users/user/folder/foo.ts",
84
+ * // name: "foo.ts",
85
+ * // isFile: true,
86
+ * // isDirectory: false,
87
+ * // isSymlink: false,
88
+ * // },
89
+ * // ]
90
+ * ```
91
+ *
92
+ * @example Define root directory
93
+ *
94
+ * Setting the `root` option to `/folder` will expand the glob pattern from the
95
+ * `/folder` directory.
96
+ *
97
+ * File structure:
98
+ * ```
99
+ * folder
100
+ * ├── subdir
101
+ * │ └── bar.ts
102
+ * ├── script.ts
103
+ * └── foo.ts
104
+ * ```
105
+ *
106
+ * ```ts ignore
107
+ * // script.ts
108
+ * import { expandGlob } from "@std/fs/expand-glob";
109
+ *
110
+ * await Array.fromAsync(expandGlob("*.ts", { root: "./subdir" }));
111
+ * // [
112
+ * // {
113
+ * // path: "/Users/user/folder/subdir/bar.ts",
114
+ * // name: "bar.ts",
115
+ * // isFile: true,
116
+ * // isDirectory: false,
117
+ * // isSymlink: false,
118
+ * // },
119
+ * // ]
120
+ * ```
121
+ *
122
+ * @example Exclude files
123
+ *
124
+ * Setting the `exclude` option to `["foo.ts"]` will exclude the `foo.ts` file
125
+ * from the expansion.
126
+ *
127
+ * File structure:
128
+ * ```
129
+ * folder
130
+ * ├── script.ts
131
+ * └── foo.ts
132
+ * ```
133
+ *
134
+ * ```ts ignore
135
+ * // script.ts
136
+ * import { expandGlob } from "@std/fs/expand-glob";
137
+ *
138
+ * await Array.fromAsync(expandGlob("*.ts", { exclude: ["foo.ts"] }));
139
+ * // [
140
+ * // {
141
+ * // path: "/Users/user/folder/script.ts",
142
+ * // name: "true.ts",
143
+ * // isFile: false,
144
+ * // isDirectory: false,
145
+ * // isSymlink: false,
146
+ * // },
147
+ * // ]
148
+ * ```
149
+ *
150
+ * @example Exclude directories
151
+ *
152
+ * Setting the `includeDirs` option to `false` will exclude directories from the
153
+ * expansion.
154
+ *
155
+ * File structure:
156
+ * ```
157
+ * folder
158
+ * ├── subdir
159
+ * │ └── bar.ts
160
+ * ├── script.ts
161
+ * └── foo.ts
162
+ * ```
163
+ *
164
+ * ```ts ignore
165
+ * // script.ts
166
+ * import { expandGlob } from "@std/fs/expand-glob";
167
+ *
168
+ * await Array.fromAsync(expandGlob("*", { includeDirs: false }));
169
+ * // [
170
+ * // {
171
+ * // path: "/Users/user/folder/script.ts",
172
+ * // name: "script.ts",
173
+ * // isFile: true,
174
+ * // isDirectory: false,
175
+ * // isSymlink: false,
176
+ * // },
177
+ * // {
178
+ * // path: "/Users/user/folder/foo.ts",
179
+ * // name: "foo.ts",
180
+ * // isFile: true,
181
+ * // isDirectory: false,
182
+ * // isSymlink: false,
183
+ * // },
184
+ * // ]
185
+ * ```
186
+ *
187
+ * @example Follow symbolic links
188
+ *
189
+ * Setting the `followSymlinks` option to `true` will follow symbolic links.
190
+ *
191
+ * File structure:
192
+ * ```
193
+ * folder
194
+ * ├── script.ts
195
+ * └── link.ts -> script.ts (symbolic link)
196
+ * ```
197
+ *
198
+ * ```ts ignore
199
+ * // script.ts
200
+ * import { expandGlob } from "@std/fs/expand-glob";
201
+ *
202
+ * await Array.fromAsync(expandGlob("*.ts", { followSymlinks: true }));
203
+ * // [
204
+ * // {
205
+ * // path: "/Users/user/folder/script.ts",
206
+ * // name: "script.ts",
207
+ * // isFile: true,
208
+ * // isDirectory: false,
209
+ * // isSymlink: false,
210
+ * // },
211
+ * // {
212
+ * // path: "/Users/user/folder/symlink",
213
+ * // name: "symlink",
214
+ * // isFile: true,
215
+ * // isDirectory: false,
216
+ * // isSymlink: true,
217
+ * // },
218
+ * // ]
219
+ * ```
220
+ */
221
+ export async function* expandGlob(glob, options) {
222
+ let { root, exclude = [], includeDirs = true, extended = true, globstar = true, caseInsensitive = false, followSymlinks = false, canonicalize = true, } = options ?? {};
223
+ const { segments, isAbsolute: isGlobAbsolute, hasTrailingSep, winRoot, } = split(toPathString(glob));
224
+ root ??= isGlobAbsolute ? winRoot ?? "/" : dntShim.Deno.cwd();
225
+ const globOptions = { extended, globstar, caseInsensitive };
226
+ const absRoot = isGlobAbsolute ? root : resolve(root); // root is always string here
227
+ const resolveFromRoot = (path) => resolve(absRoot, path);
228
+ const excludePatterns = exclude
229
+ .map(resolveFromRoot)
230
+ .map((s) => globToRegExp(s, globOptions));
231
+ const shouldInclude = (path) => !excludePatterns.some((p) => p.test(path));
232
+ let fixedRoot = isGlobAbsolute ? winRoot ?? "/" : absRoot;
233
+ while (segments.length > 0 && !isGlob(segments[0])) {
234
+ const seg = segments.shift();
235
+ fixedRoot = joinGlobs([fixedRoot, unescapeGlobSegment(seg)], globOptions);
236
+ }
237
+ let fixedRootInfo;
238
+ try {
239
+ fixedRootInfo = await createWalkEntry(fixedRoot);
240
+ }
241
+ catch (error) {
242
+ return throwUnlessNotFound(error);
243
+ }
244
+ async function* advanceMatch(walkInfo, globSegment) {
245
+ if (!walkInfo.isDirectory) {
246
+ return;
247
+ }
248
+ else if (globSegment === "..") {
249
+ const parentPath = joinGlobs([walkInfo.path, ".."], globOptions);
250
+ if (shouldInclude(parentPath)) {
251
+ return yield await createWalkEntry(parentPath);
252
+ }
253
+ return;
254
+ }
255
+ else if (globSegment === "**") {
256
+ return yield* walk(walkInfo.path, {
257
+ skip: excludePatterns,
258
+ maxDepth: globstar ? Infinity : 1,
259
+ followSymlinks,
260
+ canonicalize,
261
+ });
262
+ }
263
+ const globPattern = globToRegExp(globSegment, globOptions);
264
+ for await (const walkEntry of walk(walkInfo.path, {
265
+ maxDepth: 1,
266
+ skip: excludePatterns,
267
+ followSymlinks,
268
+ })) {
269
+ if (walkEntry.path !== walkInfo.path &&
270
+ walkEntry.name.match(globPattern)) {
271
+ yield walkEntry;
272
+ }
273
+ }
274
+ }
275
+ let currentMatches = [fixedRootInfo];
276
+ for (const segment of segments) {
277
+ // Advancing the list of current matches may introduce duplicates, so we
278
+ // pass everything through this Map.
279
+ const nextMatchMap = new Map();
280
+ await Promise.all(currentMatches.map(async (currentMatch) => {
281
+ for await (const nextMatch of advanceMatch(currentMatch, segment)) {
282
+ nextMatchMap.set(nextMatch.path, nextMatch);
283
+ }
284
+ }));
285
+ currentMatches = [...nextMatchMap.values()].sort(comparePath);
286
+ }
287
+ if (hasTrailingSep) {
288
+ currentMatches = currentMatches.filter((entry) => entry.isDirectory);
289
+ }
290
+ if (!includeDirs) {
291
+ currentMatches = currentMatches.filter((entry) => !entry.isDirectory);
292
+ }
293
+ yield* currentMatches;
294
+ }
295
+ /**
296
+ * Returns an iterator that yields each file path matching the given glob
297
+ * pattern. The file paths are relative to the provided `root` directory.
298
+ * If `root` is not provided, the current working directory is used.
299
+ * The `root` directory is not included in the yielded file paths.
300
+ *
301
+ * Requires the `--allow-read` flag.
302
+ *
303
+ * @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
304
+ * for more information on Deno's permissions system.
305
+ *
306
+ * @param glob The glob pattern to expand.
307
+ * @param options Additional options for the expansion.
308
+ *
309
+ * @returns An iterator that yields each walk entry matching the glob pattern.
310
+ *
311
+ * @example Usage
312
+ *
313
+ * File structure:
314
+ * ```
315
+ * folder
316
+ * ├── script.ts
317
+ * └── foo.ts
318
+ * ```
319
+ *
320
+ * ```ts ignore
321
+ * // script.ts
322
+ * import { expandGlobSync } from "@std/fs/expand-glob";
323
+ *
324
+ * const entries = [];
325
+ * for (const entry of expandGlobSync("*.ts")) {
326
+ * entries.push(entry);
327
+ * }
328
+ *
329
+ * entries[0]!.path; // "/Users/user/folder/script.ts"
330
+ * entries[0]!.name; // "script.ts"
331
+ * entries[0]!.isFile; // false
332
+ * entries[0]!.isDirectory; // true
333
+ * entries[0]!.isSymlink; // false
334
+ *
335
+ * entries[1]!.path; // "/Users/user/folder/foo.ts"
336
+ * entries[1]!.name; // "foo.ts"
337
+ * entries[1]!.isFile; // true
338
+ * entries[1]!.isDirectory; // false
339
+ * entries[1]!.isSymlink; // false
340
+ * ```
341
+ */
342
+ export function* expandGlobSync(glob, options) {
343
+ let { root, exclude = [], includeDirs = true, extended = true, globstar = true, caseInsensitive = false, followSymlinks = false, canonicalize = true, } = options ?? {};
344
+ const { segments, isAbsolute: isGlobAbsolute, hasTrailingSep, winRoot, } = split(toPathString(glob));
345
+ root ??= isGlobAbsolute ? winRoot ?? "/" : dntShim.Deno.cwd();
346
+ const globOptions = { extended, globstar, caseInsensitive };
347
+ const absRoot = isGlobAbsolute ? root : resolve(root); // root is always string here
348
+ const resolveFromRoot = (path) => resolve(absRoot, path);
349
+ const excludePatterns = exclude
350
+ .map(resolveFromRoot)
351
+ .map((s) => globToRegExp(s, globOptions));
352
+ const shouldInclude = (path) => !excludePatterns.some((p) => p.test(path));
353
+ let fixedRoot = isGlobAbsolute ? winRoot ?? "/" : absRoot;
354
+ while (segments.length > 0 && !isGlob(segments[0])) {
355
+ const seg = segments.shift();
356
+ fixedRoot = joinGlobs([fixedRoot, unescapeGlobSegment(seg)], globOptions);
357
+ }
358
+ let fixedRootInfo;
359
+ try {
360
+ fixedRootInfo = createWalkEntrySync(fixedRoot);
361
+ }
362
+ catch (error) {
363
+ return throwUnlessNotFound(error);
364
+ }
365
+ function* advanceMatch(walkInfo, globSegment) {
366
+ if (!walkInfo.isDirectory) {
367
+ return;
368
+ }
369
+ else if (globSegment === "..") {
370
+ const parentPath = joinGlobs([walkInfo.path, ".."], globOptions);
371
+ if (shouldInclude(parentPath)) {
372
+ return yield createWalkEntrySync(parentPath);
373
+ }
374
+ return;
375
+ }
376
+ else if (globSegment === "**") {
377
+ return yield* walkSync(walkInfo.path, {
378
+ skip: excludePatterns,
379
+ maxDepth: globstar ? Infinity : 1,
380
+ followSymlinks,
381
+ canonicalize,
382
+ });
383
+ }
384
+ const globPattern = globToRegExp(globSegment, globOptions);
385
+ for (const walkEntry of walkSync(walkInfo.path, {
386
+ maxDepth: 1,
387
+ skip: excludePatterns,
388
+ followSymlinks,
389
+ })) {
390
+ if (walkEntry.path !== walkInfo.path &&
391
+ walkEntry.name.match(globPattern)) {
392
+ yield walkEntry;
393
+ }
394
+ }
395
+ }
396
+ let currentMatches = [fixedRootInfo];
397
+ for (const segment of segments) {
398
+ // Advancing the list of current matches may introduce duplicates, so we
399
+ // pass everything through this Map.
400
+ const nextMatchMap = new Map();
401
+ for (const currentMatch of currentMatches) {
402
+ for (const nextMatch of advanceMatch(currentMatch, segment)) {
403
+ nextMatchMap.set(nextMatch.path, nextMatch);
404
+ }
405
+ }
406
+ currentMatches = [...nextMatchMap.values()].sort(comparePath);
407
+ }
408
+ if (hasTrailingSep) {
409
+ currentMatches = currentMatches.filter((entry) => entry.isDirectory);
410
+ }
411
+ if (!includeDirs) {
412
+ currentMatches = currentMatches.filter((entry) => !entry.isDirectory);
413
+ }
414
+ yield* currentMatches;
415
+ }
416
+ const globEscapeChar =
417
+ // deno-lint-ignore no-explicit-any
418
+ dntShim.dntGlobalThis.Deno?.build.os === "windows" ? "`" : `\\`;
419
+ const globMetachars = "*?{}[]()|+@!";
420
+ function unescapeGlobSegment(segment) {
421
+ let result = "";
422
+ let lastIndex = 0;
423
+ for (let i = 0; i < segment.length; i++) {
424
+ const char = segment[i];
425
+ if (char === globEscapeChar) {
426
+ const nextChar = segment[i + 1];
427
+ if (nextChar && globMetachars.includes(nextChar)) {
428
+ // append the slice before the escape char, then the metachar
429
+ result += segment.slice(lastIndex, i) + nextChar;
430
+ i++; // skip next char since we already processed it
431
+ lastIndex = i + 1;
432
+ }
433
+ }
434
+ }
435
+ // no escaped, return the original segment
436
+ if (lastIndex === 0) {
437
+ return segment;
438
+ }
439
+ // append any remaining characters
440
+ result += segment.slice(lastIndex);
441
+ return result;
442
+ }