@bolt-foundry/gambit 0.8.1 → 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.
- package/CHANGELOG.md +110 -2
- package/README.md +108 -23
- package/esm/_dnt.polyfills.d.ts +17 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +122 -0
- package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts +322 -0
- package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.1.5/deep_merge.js +105 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts +14 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.js +34 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts +13 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.js +18 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts +10 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_same_path.js +17 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts +12 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_is_subdir.js +25 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts +9 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/_to_path_string.js +13 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/copy.d.ts +117 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/copy.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/copy.js +313 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts +48 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/empty_dir.js +87 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts +49 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_dir.js +102 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts +47 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_file.js +90 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts +49 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_link.js +61 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts +70 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.js +156 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/eol.d.ts +52 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/eol.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/eol.js +67 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/exists.d.ts +218 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/exists.js +271 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts +267 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/expand_glob.js +442 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/mod.d.ts +29 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/mod.js +29 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/move.d.ts +86 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/move.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/move.js +142 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/walk.d.ts +777 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/walk.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.22/walk.js +846 -0
- package/esm/deps/jsr.io/@std/json/1.0.2/types.d.ts +5 -0
- package/esm/deps/jsr.io/@std/json/1.0.2/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/json/1.0.2/types.js +3 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts +20 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/mod.js +21 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts +21 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.js +320 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +753 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/mod.js +110 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/parse.js +25 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/toml/1.0.11/stringify.js +283 -0
- package/esm/gambit/simulator-ui/dist/bundle.js +12085 -5691
- package/esm/gambit/simulator-ui/dist/bundle.js.map +4 -4
- package/esm/gambit/simulator-ui/dist/favicon.ico +0 -0
- package/esm/mod.d.ts +21 -7
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +14 -4
- package/esm/src/cli_utils.d.ts +1 -0
- package/esm/src/cli_utils.d.ts.map +1 -1
- package/esm/src/cli_utils.js +52 -4
- package/esm/src/default_runtime.d.ts +46 -0
- package/esm/src/default_runtime.d.ts.map +1 -0
- package/esm/src/default_runtime.js +415 -0
- package/esm/src/durable_streams.js +26 -1
- package/esm/src/model_matchers.d.ts +10 -0
- package/esm/src/model_matchers.d.ts.map +1 -0
- package/esm/src/model_matchers.js +26 -0
- package/esm/src/openai_compat.d.ts +74 -0
- package/esm/src/openai_compat.d.ts.map +1 -0
- package/esm/src/openai_compat.js +329 -0
- package/esm/src/project_config.d.ts +47 -0
- package/esm/src/project_config.d.ts.map +1 -0
- package/esm/src/project_config.js +134 -0
- package/esm/src/providers/codex.d.ts +37 -0
- package/esm/src/providers/codex.d.ts.map +1 -0
- package/esm/src/providers/codex.js +810 -0
- package/esm/src/providers/google.d.ts +18 -0
- package/esm/src/providers/google.d.ts.map +1 -0
- package/esm/src/providers/google.js +428 -0
- package/esm/src/providers/ollama.d.ts +19 -0
- package/esm/src/providers/ollama.d.ts.map +1 -0
- package/esm/src/providers/ollama.js +732 -0
- package/esm/src/providers/openrouter.d.ts +26 -0
- package/esm/src/providers/openrouter.d.ts.map +1 -0
- package/esm/src/providers/openrouter.js +829 -0
- package/esm/src/providers/router.d.ts +19 -0
- package/esm/src/providers/router.d.ts.map +1 -0
- package/esm/src/providers/router.js +93 -0
- package/esm/src/server.d.ts +11 -0
- package/esm/src/server.d.ts.map +1 -1
- package/esm/src/server.js +3764 -647
- package/esm/src/server_feedback_grading_routes.d.ts +32 -0
- package/esm/src/server_feedback_grading_routes.d.ts.map +1 -0
- package/esm/src/server_feedback_grading_routes.js +305 -0
- package/esm/src/server_helpers.d.ts +4 -0
- package/esm/src/server_helpers.d.ts.map +1 -0
- package/esm/src/server_helpers.js +46 -0
- package/esm/src/server_session_store.d.ts +87 -0
- package/esm/src/server_session_store.d.ts.map +1 -0
- package/esm/src/server_session_store.js +873 -0
- package/esm/src/server_types.d.ts +110 -0
- package/esm/src/server_types.d.ts.map +1 -0
- package/esm/src/server_types.js +1 -0
- package/esm/src/server_ui_routes.d.ts +33 -0
- package/esm/src/server_ui_routes.d.ts.map +1 -0
- package/esm/src/server_ui_routes.js +135 -0
- package/esm/src/session_artifacts.d.ts +22 -0
- package/esm/src/session_artifacts.d.ts.map +1 -0
- package/esm/src/session_artifacts.js +243 -0
- package/esm/src/trace.d.ts.map +1 -1
- package/esm/src/trace.js +8 -5
- package/esm/src/workspace.d.ts +19 -0
- package/esm/src/workspace.d.ts.map +1 -0
- package/esm/src/workspace.js +164 -0
- package/esm/src/workspace_contract.d.ts +76 -0
- package/esm/src/workspace_contract.d.ts.map +1 -0
- package/esm/src/workspace_contract.js +74 -0
- package/package.json +3 -2
- package/script/_dnt.polyfills.d.ts +17 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +122 -0
- package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts +322 -0
- package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/collections/1.1.5/deep_merge.js +108 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts +14 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_create_walk_entry.js +71 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts +13 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_get_file_info_type.js +21 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts +10 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_same_path.js +20 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts +12 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_is_subdir.js +28 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts +9 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/_to_path_string.js +16 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/copy.d.ts +117 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/copy.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/copy.js +350 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts +48 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/empty_dir.js +124 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts +49 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_dir.js +139 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts +47 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_file.js +127 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts +49 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_link.js +98 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts +70 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/ensure_symlink.js +193 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/eol.d.ts +52 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/eol.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/eol.js +105 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/exists.d.ts +218 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/exists.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/exists.js +308 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts +267 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/expand_glob.js +479 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/mod.d.ts +29 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/mod.js +45 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/move.d.ts +86 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/move.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/move.js +179 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/walk.d.ts +777 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/walk.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.22/walk.js +883 -0
- package/script/deps/jsr.io/@std/json/1.0.2/types.d.ts +5 -0
- package/script/deps/jsr.io/@std/json/1.0.2/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/json/1.0.2/types.js +4 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts +20 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/mod.js +37 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts +21 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/jsonc/1.0.2/parse.js +323 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +781 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts +109 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/mod.js +126 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/parse.js +28 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts +35 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/stringify.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/toml/1.0.11/stringify.js +286 -0
- package/script/gambit/simulator-ui/dist/bundle.js +12085 -5691
- package/script/gambit/simulator-ui/dist/bundle.js.map +4 -4
- package/script/gambit/simulator-ui/dist/favicon.ico +0 -0
- package/script/mod.d.ts +21 -7
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +22 -7
- package/script/src/cli_utils.d.ts +1 -0
- package/script/src/cli_utils.d.ts.map +1 -1
- package/script/src/cli_utils.js +52 -3
- package/script/src/default_runtime.d.ts +46 -0
- package/script/src/default_runtime.d.ts.map +1 -0
- package/script/src/default_runtime.js +452 -0
- package/script/src/durable_streams.js +26 -1
- package/script/src/model_matchers.d.ts +10 -0
- package/script/src/model_matchers.d.ts.map +1 -0
- package/script/src/model_matchers.js +29 -0
- package/script/src/openai_compat.d.ts +74 -0
- package/script/src/openai_compat.d.ts.map +1 -0
- package/script/src/openai_compat.js +366 -0
- package/script/src/project_config.d.ts +47 -0
- package/script/src/project_config.d.ts.map +1 -0
- package/script/src/project_config.js +173 -0
- package/script/src/providers/codex.d.ts +37 -0
- package/script/src/providers/codex.d.ts.map +1 -0
- package/script/src/providers/codex.js +850 -0
- package/script/src/providers/google.d.ts +18 -0
- package/script/src/providers/google.d.ts.map +1 -0
- package/script/src/providers/google.js +435 -0
- package/script/src/providers/ollama.d.ts +19 -0
- package/script/src/providers/ollama.d.ts.map +1 -0
- package/script/src/providers/ollama.js +774 -0
- package/script/src/providers/openrouter.d.ts +26 -0
- package/script/src/providers/openrouter.d.ts.map +1 -0
- package/script/src/providers/openrouter.js +869 -0
- package/script/src/providers/router.d.ts +19 -0
- package/script/src/providers/router.d.ts.map +1 -0
- package/script/src/providers/router.js +96 -0
- package/script/src/server.d.ts +11 -0
- package/script/src/server.d.ts.map +1 -1
- package/script/src/server.js +3768 -651
- package/script/src/server_feedback_grading_routes.d.ts +32 -0
- package/script/src/server_feedback_grading_routes.d.ts.map +1 -0
- package/script/src/server_feedback_grading_routes.js +343 -0
- package/script/src/server_helpers.d.ts +4 -0
- package/script/src/server_helpers.d.ts.map +1 -0
- package/script/src/server_helpers.js +84 -0
- package/script/src/server_session_store.d.ts +87 -0
- package/script/src/server_session_store.d.ts.map +1 -0
- package/script/src/server_session_store.js +910 -0
- package/script/src/server_types.d.ts +110 -0
- package/script/src/server_types.d.ts.map +1 -0
- package/script/src/server_types.js +2 -0
- package/script/src/server_ui_routes.d.ts +33 -0
- package/script/src/server_ui_routes.d.ts.map +1 -0
- package/script/src/server_ui_routes.js +172 -0
- package/script/src/session_artifacts.d.ts +22 -0
- package/script/src/session_artifacts.d.ts.map +1 -0
- package/script/src/session_artifacts.js +279 -0
- package/script/src/trace.d.ts.map +1 -1
- package/script/src/trace.js +8 -5
- package/script/src/workspace.d.ts +19 -0
- package/script/src/workspace.d.ts.map +1 -0
- package/script/src/workspace.js +201 -0
- package/script/src/workspace_contract.d.ts +76 -0
- package/script/src/workspace_contract.d.ts.map +1 -0
- package/script/src/workspace_contract.js +82 -0
|
@@ -0,0 +1,883 @@
|
|
|
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.walk = walk;
|
|
37
|
+
exports.walkSync = walkSync;
|
|
38
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
39
|
+
// Documentation and interface for walk were adapted from Go
|
|
40
|
+
// https://golang.org/pkg/path/filepath/#Walk
|
|
41
|
+
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
|
|
42
|
+
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
43
|
+
const join_js_1 = require("../../path/1.1.4/join.js");
|
|
44
|
+
const _to_path_string_js_1 = require("./_to_path_string.js");
|
|
45
|
+
const _create_walk_entry_js_1 = require("./_create_walk_entry.js");
|
|
46
|
+
function include(path, exts, match, skip) {
|
|
47
|
+
if (exts && !exts.some((ext) => path.endsWith(ext))) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (match && !match.some((pattern) => !!path.match(pattern))) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (skip && skip.some((pattern) => !!path.match(pattern))) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Recursively walks through a directory and yields information about each file
|
|
60
|
+
* and directory encountered.
|
|
61
|
+
*
|
|
62
|
+
* The root path determines whether the file paths are relative or absolute.
|
|
63
|
+
* The root directory is included in the yielded entries.
|
|
64
|
+
*
|
|
65
|
+
* Requires `--allow-read` permission.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
|
|
68
|
+
* for more information on Deno's permissions system.
|
|
69
|
+
*
|
|
70
|
+
* @param root The root directory to start the walk from, as a string or URL.
|
|
71
|
+
* @param options The options for the walk.
|
|
72
|
+
* @throws {Deno.errors.NotFound} If the root directory does not exist.
|
|
73
|
+
*
|
|
74
|
+
* @returns An async iterable iterator that yields the walk entry objects.
|
|
75
|
+
*
|
|
76
|
+
* @example Basic usage
|
|
77
|
+
*
|
|
78
|
+
* File structure:
|
|
79
|
+
* ```
|
|
80
|
+
* folder
|
|
81
|
+
* ├── script.ts
|
|
82
|
+
* └── foo.ts
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* ```ts ignore
|
|
86
|
+
* import { walk } from "@std/fs/walk";
|
|
87
|
+
*
|
|
88
|
+
* await Array.fromAsync(walk("."));
|
|
89
|
+
* // [
|
|
90
|
+
* // {
|
|
91
|
+
* // path: ".",
|
|
92
|
+
* // name: ".",
|
|
93
|
+
* // isFile: false,
|
|
94
|
+
* // isDirectory: true,
|
|
95
|
+
* // isSymlink: false
|
|
96
|
+
* // },
|
|
97
|
+
* // {
|
|
98
|
+
* // path: "script.ts",
|
|
99
|
+
* // name: "script.ts",
|
|
100
|
+
* // isFile: true,
|
|
101
|
+
* // isDirectory: false,
|
|
102
|
+
* // isSymlink: false
|
|
103
|
+
* // },
|
|
104
|
+
* // {
|
|
105
|
+
* // path: "foo.ts",
|
|
106
|
+
* // name: "foo.ts",
|
|
107
|
+
* // isFile: true,
|
|
108
|
+
* // isDirectory: false,
|
|
109
|
+
* // isSymlink: false
|
|
110
|
+
* // },
|
|
111
|
+
* // ]
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example Maximum file depth
|
|
115
|
+
*
|
|
116
|
+
* Setting the `maxDepth` option to `1` will only include the root directory and
|
|
117
|
+
* its immediate children.
|
|
118
|
+
*
|
|
119
|
+
* File structure:
|
|
120
|
+
* ```
|
|
121
|
+
* folder
|
|
122
|
+
* ├── script.ts
|
|
123
|
+
* └── foo
|
|
124
|
+
* └── bar.ts
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* ```ts ignore
|
|
128
|
+
* import { walk } from "@std/fs/walk";
|
|
129
|
+
*
|
|
130
|
+
* await Array.fromAsync(walk(".", { maxDepth: 1 }));
|
|
131
|
+
* // [
|
|
132
|
+
* // {
|
|
133
|
+
* // path: ".",
|
|
134
|
+
* // name: ".",
|
|
135
|
+
* // isFile: false,
|
|
136
|
+
* // isDirectory: true,
|
|
137
|
+
* // isSymlink: false
|
|
138
|
+
* // },
|
|
139
|
+
* // {
|
|
140
|
+
* // path: "script.ts",
|
|
141
|
+
* // name: "script.ts",
|
|
142
|
+
* // isFile: true,
|
|
143
|
+
* // isDirectory: false,
|
|
144
|
+
* // isSymlink: false
|
|
145
|
+
* // },
|
|
146
|
+
* // {
|
|
147
|
+
* // path: "foo",
|
|
148
|
+
* // name: "foo",
|
|
149
|
+
* // isFile: false,
|
|
150
|
+
* // isDirectory: true,
|
|
151
|
+
* // isSymlink: false
|
|
152
|
+
* // },
|
|
153
|
+
* // ]
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Exclude files
|
|
157
|
+
*
|
|
158
|
+
* Setting the `includeFiles` option to `false` will exclude files.
|
|
159
|
+
*
|
|
160
|
+
* File structure:
|
|
161
|
+
* ```
|
|
162
|
+
* folder
|
|
163
|
+
* ├── script.ts
|
|
164
|
+
* └── foo
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* ```ts ignore
|
|
168
|
+
* import { walk } from "@std/fs/walk";
|
|
169
|
+
*
|
|
170
|
+
* await Array.fromAsync(walk(".", { includeFiles: false }));
|
|
171
|
+
* // [
|
|
172
|
+
* // {
|
|
173
|
+
* // path: ".",
|
|
174
|
+
* // name: ".",
|
|
175
|
+
* // isFile: false,
|
|
176
|
+
* // isDirectory: true,
|
|
177
|
+
* // isSymlink: false
|
|
178
|
+
* // },
|
|
179
|
+
* // {
|
|
180
|
+
* // path: "foo",
|
|
181
|
+
* // name: "foo",
|
|
182
|
+
* // isFile: false,
|
|
183
|
+
* // isDirectory: true,
|
|
184
|
+
* // isSymlink: false,
|
|
185
|
+
* // },
|
|
186
|
+
* // ]
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example Exclude directories
|
|
190
|
+
*
|
|
191
|
+
* Setting the `includeDirs` option to `false` will exclude directories.
|
|
192
|
+
*
|
|
193
|
+
* File structure:
|
|
194
|
+
* ```
|
|
195
|
+
* folder
|
|
196
|
+
* ├── script.ts
|
|
197
|
+
* └── foo
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* ```ts ignore
|
|
201
|
+
* import { walk } from "@std/fs/walk";
|
|
202
|
+
*
|
|
203
|
+
* await Array.fromAsync(walk(".", { includeDirs: false }));
|
|
204
|
+
* // [
|
|
205
|
+
* // {
|
|
206
|
+
* // path: "script.ts",
|
|
207
|
+
* // name: "script.ts",
|
|
208
|
+
* // isFile: true,
|
|
209
|
+
* // isDirectory: false,
|
|
210
|
+
* // isSymlink: false
|
|
211
|
+
* // },
|
|
212
|
+
* // ]
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @example Exclude symbolic links
|
|
216
|
+
*
|
|
217
|
+
* Setting the `includeSymlinks` option to `false` will exclude symbolic links.
|
|
218
|
+
*
|
|
219
|
+
* File structure:
|
|
220
|
+
* ```
|
|
221
|
+
* folder
|
|
222
|
+
* ├── script.ts
|
|
223
|
+
* ├── foo
|
|
224
|
+
* └── link -> script.ts (symbolic link)
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* ```ts ignore
|
|
228
|
+
* import { walk } from "@std/fs/walk";
|
|
229
|
+
*
|
|
230
|
+
* await Array.fromAsync(walk(".", { includeSymlinks: false }));
|
|
231
|
+
* // [
|
|
232
|
+
* // {
|
|
233
|
+
* // path: ".",
|
|
234
|
+
* // name: ".",
|
|
235
|
+
* // isFile: false,
|
|
236
|
+
* // isDirectory: true,
|
|
237
|
+
* // isSymlink: false
|
|
238
|
+
* // },
|
|
239
|
+
* // {
|
|
240
|
+
* // path: "script.ts",
|
|
241
|
+
* // name: "script.ts",
|
|
242
|
+
* // isFile: true,
|
|
243
|
+
* // isDirectory: false,
|
|
244
|
+
* // isSymlink: false
|
|
245
|
+
* // },
|
|
246
|
+
* // ]
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @example Follow symbolic links
|
|
250
|
+
*
|
|
251
|
+
* Setting the `followSymlinks` option to `true` will follow symbolic links,
|
|
252
|
+
* affecting the `path` property of the walk entry.
|
|
253
|
+
*
|
|
254
|
+
* File structure:
|
|
255
|
+
* ```
|
|
256
|
+
* folder
|
|
257
|
+
* ├── script.ts
|
|
258
|
+
* └── link -> script.ts (symbolic link)
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* ```ts ignore
|
|
262
|
+
* import { walk } from "@std/fs/walk";
|
|
263
|
+
*
|
|
264
|
+
* await Array.fromAsync(walk(".", { followSymlinks: true }));
|
|
265
|
+
* // [
|
|
266
|
+
* // {
|
|
267
|
+
* // path: ".",
|
|
268
|
+
* // name: ".",
|
|
269
|
+
* // isFile: false,
|
|
270
|
+
* // isDirectory: true,
|
|
271
|
+
* // isSymlink: false
|
|
272
|
+
* // },
|
|
273
|
+
* // {
|
|
274
|
+
* // path: "script.ts",
|
|
275
|
+
* // name: "script.ts",
|
|
276
|
+
* // isFile: true,
|
|
277
|
+
* // isDirectory: false,
|
|
278
|
+
* // isSymlink: false
|
|
279
|
+
* // },
|
|
280
|
+
* // {
|
|
281
|
+
* // path: "script.ts",
|
|
282
|
+
* // name: "link",
|
|
283
|
+
* // isFile: true,
|
|
284
|
+
* // isDirectory: false,
|
|
285
|
+
* // isSymlink: true
|
|
286
|
+
* // },
|
|
287
|
+
* // ]
|
|
288
|
+
* ```
|
|
289
|
+
*
|
|
290
|
+
* @example Canonicalize symbolic links
|
|
291
|
+
*
|
|
292
|
+
* Setting the `canonicalize` option to `false` will canonicalize the path of
|
|
293
|
+
* the followed symbolic link. Meaning, the `path` property of the walk entry
|
|
294
|
+
* will be the path of the symbolic link itself.
|
|
295
|
+
*
|
|
296
|
+
* File structure:
|
|
297
|
+
* ```
|
|
298
|
+
* folder
|
|
299
|
+
* ├── script.ts
|
|
300
|
+
* └── link -> script.ts (symbolic link)
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* ```ts ignore
|
|
304
|
+
* import { walk } from "@std/fs/walk";
|
|
305
|
+
*
|
|
306
|
+
* await Array.fromAsync(walk(".", { followSymlinks: true, canonicalize: true }));
|
|
307
|
+
* // [
|
|
308
|
+
* // {
|
|
309
|
+
* // path: ".",
|
|
310
|
+
* // name: ".",
|
|
311
|
+
* // isFile: false,
|
|
312
|
+
* // isDirectory: true,
|
|
313
|
+
* // isSymlink: false
|
|
314
|
+
* // },
|
|
315
|
+
* // {
|
|
316
|
+
* // path: "script.ts",
|
|
317
|
+
* // name: "script.ts",
|
|
318
|
+
* // isFile: true,
|
|
319
|
+
* // isDirectory: false,
|
|
320
|
+
* // isSymlink: false
|
|
321
|
+
* // },
|
|
322
|
+
* // {
|
|
323
|
+
* // path: "link",
|
|
324
|
+
* // name: "link",
|
|
325
|
+
* // isFile: true,
|
|
326
|
+
* // isDirectory: false,
|
|
327
|
+
* // isSymlink: true
|
|
328
|
+
* // },
|
|
329
|
+
* // ]
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @example Filter by file extensions
|
|
333
|
+
*
|
|
334
|
+
* Setting the `exts` option to `[".ts"]` or `["ts"]` will only include entries
|
|
335
|
+
* with the `.ts` file extension.
|
|
336
|
+
*
|
|
337
|
+
* File structure:
|
|
338
|
+
* ```
|
|
339
|
+
* folder
|
|
340
|
+
* ├── script.ts
|
|
341
|
+
* └── foo.js
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* ```ts ignore
|
|
345
|
+
* import { walk } from "@std/fs/walk";
|
|
346
|
+
*
|
|
347
|
+
* await Array.fromAsync(walk(".", { exts: [".ts"] }));
|
|
348
|
+
* // [
|
|
349
|
+
* // {
|
|
350
|
+
* // path: "script.ts",
|
|
351
|
+
* // name: "script.ts",
|
|
352
|
+
* // isFile: true,
|
|
353
|
+
* // isDirectory: false,
|
|
354
|
+
* // isSymlink: false
|
|
355
|
+
* // },
|
|
356
|
+
* // ]
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @example Filter by regular expressions
|
|
360
|
+
*
|
|
361
|
+
* Setting the `match` option to `[/s/]` will only include entries with the
|
|
362
|
+
* letter `s` in their name.
|
|
363
|
+
*
|
|
364
|
+
* File structure:
|
|
365
|
+
* ```
|
|
366
|
+
* folder
|
|
367
|
+
* ├── script.ts
|
|
368
|
+
* └── README.md
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* ```ts ignore
|
|
372
|
+
* import { walk } from "@std/fs/walk";
|
|
373
|
+
*
|
|
374
|
+
* await Array.fromAsync(walk(".", { match: [/s/] }));
|
|
375
|
+
* // [
|
|
376
|
+
* // {
|
|
377
|
+
* // path: "script.ts",
|
|
378
|
+
* // name: "script.ts",
|
|
379
|
+
* // isFile: true,
|
|
380
|
+
* // isDirectory: false,
|
|
381
|
+
* // isSymlink: false
|
|
382
|
+
* // },
|
|
383
|
+
* // ]
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @example Exclude by regular expressions
|
|
387
|
+
*
|
|
388
|
+
* Setting the `skip` option to `[/s/]` will exclude entries with the letter
|
|
389
|
+
* `s` in their name.
|
|
390
|
+
*
|
|
391
|
+
* File structure:
|
|
392
|
+
* ```
|
|
393
|
+
* folder
|
|
394
|
+
* ├── script.ts
|
|
395
|
+
* └── README.md
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* ```ts ignore
|
|
399
|
+
* import { walk } from "@std/fs/walk";
|
|
400
|
+
*
|
|
401
|
+
* await Array.fromAsync(walk(".", { skip: [/s/] }));
|
|
402
|
+
* // [
|
|
403
|
+
* // {
|
|
404
|
+
* // path: "README.md",
|
|
405
|
+
* // name: "README.md",
|
|
406
|
+
* // isFile: true,
|
|
407
|
+
* // isDirectory: false,
|
|
408
|
+
* // isSymlink: false
|
|
409
|
+
* // },
|
|
410
|
+
* // ]
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
async function* walk(root, options) {
|
|
414
|
+
let { maxDepth = Infinity, includeFiles = true, includeDirs = true, includeSymlinks = true, followSymlinks = false, canonicalize = true, exts = undefined, match = undefined, skip = undefined, } = options ?? {};
|
|
415
|
+
if (maxDepth < 0) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
root = (0, _to_path_string_js_1.toPathString)(root);
|
|
419
|
+
if (exts) {
|
|
420
|
+
exts = exts.map((ext) => ext.startsWith(".") ? ext : `.${ext}`);
|
|
421
|
+
}
|
|
422
|
+
if (includeDirs && include(root, exts, match, skip)) {
|
|
423
|
+
yield await (0, _create_walk_entry_js_1.createWalkEntry)(root);
|
|
424
|
+
}
|
|
425
|
+
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
for await (const entry of dntShim.Deno.readDir(root)) {
|
|
429
|
+
let path = (0, join_js_1.join)(root, entry.name);
|
|
430
|
+
let { isSymlink, isDirectory } = entry;
|
|
431
|
+
if (isSymlink) {
|
|
432
|
+
if (!followSymlinks) {
|
|
433
|
+
if (includeSymlinks && include(path, exts, match, skip)) {
|
|
434
|
+
yield { path, ...entry };
|
|
435
|
+
}
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const realPath = await dntShim.Deno.realPath(path);
|
|
439
|
+
if (canonicalize) {
|
|
440
|
+
path = realPath;
|
|
441
|
+
}
|
|
442
|
+
// Caveat emptor: don't assume |path| is not a symlink. realpath()
|
|
443
|
+
// resolves symlinks but another process can replace the file system
|
|
444
|
+
// entity with a different type of entity before we call lstat().
|
|
445
|
+
({ isSymlink, isDirectory } = await dntShim.Deno.lstat(realPath));
|
|
446
|
+
}
|
|
447
|
+
if (isSymlink || isDirectory) {
|
|
448
|
+
const opts = {
|
|
449
|
+
maxDepth: maxDepth - 1,
|
|
450
|
+
includeFiles,
|
|
451
|
+
includeDirs,
|
|
452
|
+
includeSymlinks,
|
|
453
|
+
followSymlinks,
|
|
454
|
+
};
|
|
455
|
+
if (exts !== undefined) {
|
|
456
|
+
opts.exts = exts;
|
|
457
|
+
}
|
|
458
|
+
if (match !== undefined) {
|
|
459
|
+
opts.match = match;
|
|
460
|
+
}
|
|
461
|
+
if (skip !== undefined) {
|
|
462
|
+
opts.skip = skip;
|
|
463
|
+
}
|
|
464
|
+
yield* walk(path, opts);
|
|
465
|
+
}
|
|
466
|
+
else if (includeFiles && include(path, exts, match, skip)) {
|
|
467
|
+
yield { path, ...entry };
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Recursively walks through a directory and yields information about each file
|
|
473
|
+
* and directory encountered.
|
|
474
|
+
*
|
|
475
|
+
* The root path determines whether the file paths is relative or absolute.
|
|
476
|
+
* The root directory is included in the yielded entries.
|
|
477
|
+
*
|
|
478
|
+
* Requires `--allow-read` permission.
|
|
479
|
+
*
|
|
480
|
+
* @see {@link https://docs.deno.com/runtime/manual/basics/permissions#file-system-access}
|
|
481
|
+
* for more information on Deno's permissions system.
|
|
482
|
+
*
|
|
483
|
+
* @param root The root directory to start the walk from, as a string or URL.
|
|
484
|
+
* @param options The options for the walk.
|
|
485
|
+
*
|
|
486
|
+
* @returns A synchronous iterable iterator that yields the walk entry objects.
|
|
487
|
+
*
|
|
488
|
+
* @example Basic usage
|
|
489
|
+
*
|
|
490
|
+
* File structure:
|
|
491
|
+
* ```
|
|
492
|
+
* folder
|
|
493
|
+
* ├── script.ts
|
|
494
|
+
* └── foo.ts
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* ```ts ignore
|
|
498
|
+
* import { walkSync } from "@std/fs/walk";
|
|
499
|
+
*
|
|
500
|
+
* Array.from(walkSync("."));
|
|
501
|
+
* // [
|
|
502
|
+
* // {
|
|
503
|
+
* // path: ".",
|
|
504
|
+
* // name: ".",
|
|
505
|
+
* // isFile: false,
|
|
506
|
+
* // isDirectory: true,
|
|
507
|
+
* // isSymlink: false
|
|
508
|
+
* // },
|
|
509
|
+
* // {
|
|
510
|
+
* // path: "script.ts",
|
|
511
|
+
* // name: "script.ts",
|
|
512
|
+
* // isFile: true,
|
|
513
|
+
* // isDirectory: false,
|
|
514
|
+
* // isSymlink: false
|
|
515
|
+
* // },
|
|
516
|
+
* // {
|
|
517
|
+
* // path: "foo.ts",
|
|
518
|
+
* // name: "foo.ts",
|
|
519
|
+
* // isFile: true,
|
|
520
|
+
* // isDirectory: false,
|
|
521
|
+
* // isSymlink: false
|
|
522
|
+
* // },
|
|
523
|
+
* // ]
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* @example Maximum file depth
|
|
527
|
+
*
|
|
528
|
+
* Setting the `maxDepth` option to `1` will only include the root directory and
|
|
529
|
+
* its immediate children.
|
|
530
|
+
*
|
|
531
|
+
* File structure:
|
|
532
|
+
* ```
|
|
533
|
+
* folder
|
|
534
|
+
* ├── script.ts
|
|
535
|
+
* └── foo
|
|
536
|
+
* └── bar.ts
|
|
537
|
+
* ```
|
|
538
|
+
*
|
|
539
|
+
* ```ts ignore
|
|
540
|
+
* import { walkSync } from "@std/fs/walk";
|
|
541
|
+
*
|
|
542
|
+
* Array.from(walkSync(".", { maxDepth: 1 }));
|
|
543
|
+
* // [
|
|
544
|
+
* // {
|
|
545
|
+
* // path: ".",
|
|
546
|
+
* // name: ".",
|
|
547
|
+
* // isFile: false,
|
|
548
|
+
* // isDirectory: true,
|
|
549
|
+
* // isSymlink: false
|
|
550
|
+
* // },
|
|
551
|
+
* // {
|
|
552
|
+
* // path: "script.ts",
|
|
553
|
+
* // name: "script.ts",
|
|
554
|
+
* // isFile: true,
|
|
555
|
+
* // isDirectory: false,
|
|
556
|
+
* // isSymlink: false
|
|
557
|
+
* // },
|
|
558
|
+
* // {
|
|
559
|
+
* // path: "foo",
|
|
560
|
+
* // name: "foo",
|
|
561
|
+
* // isFile: false,
|
|
562
|
+
* // isDirectory: true,
|
|
563
|
+
* // isSymlink: false
|
|
564
|
+
* // },
|
|
565
|
+
* // ]
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @example Exclude files
|
|
569
|
+
*
|
|
570
|
+
* Setting the `includeFiles` option to `false` will exclude files.
|
|
571
|
+
*
|
|
572
|
+
* File structure:
|
|
573
|
+
* ```
|
|
574
|
+
* folder
|
|
575
|
+
* ├── script.ts
|
|
576
|
+
* └── foo
|
|
577
|
+
* ```
|
|
578
|
+
*
|
|
579
|
+
* ```ts ignore
|
|
580
|
+
* import { walkSync } from "@std/fs/walk";
|
|
581
|
+
*
|
|
582
|
+
* Array.from(walkSync(".", { includeFiles: false }));
|
|
583
|
+
* // [
|
|
584
|
+
* // {
|
|
585
|
+
* // path: ".",
|
|
586
|
+
* // name: ".",
|
|
587
|
+
* // isFile: false,
|
|
588
|
+
* // isDirectory: true,
|
|
589
|
+
* // isSymlink: false
|
|
590
|
+
* // },
|
|
591
|
+
* // {
|
|
592
|
+
* // path: "foo",
|
|
593
|
+
* // name: "foo",
|
|
594
|
+
* // isFile: false,
|
|
595
|
+
* // isDirectory: true,
|
|
596
|
+
* // isSymlink: false,
|
|
597
|
+
* // },
|
|
598
|
+
* // ]
|
|
599
|
+
* ```
|
|
600
|
+
*
|
|
601
|
+
* @example Exclude directories
|
|
602
|
+
*
|
|
603
|
+
* Setting the `includeDirs` option to `false` will exclude directories.
|
|
604
|
+
*
|
|
605
|
+
* File structure:
|
|
606
|
+
* ```
|
|
607
|
+
* folder
|
|
608
|
+
* ├── script.ts
|
|
609
|
+
* └── foo
|
|
610
|
+
* ```
|
|
611
|
+
*
|
|
612
|
+
* ```ts ignore
|
|
613
|
+
* import { walkSync } from "@std/fs/walk";
|
|
614
|
+
*
|
|
615
|
+
* Array.from(walkSync(".", { includeDirs: false }));
|
|
616
|
+
* // [
|
|
617
|
+
* // {
|
|
618
|
+
* // path: "script.ts",
|
|
619
|
+
* // name: "script.ts",
|
|
620
|
+
* // isFile: true,
|
|
621
|
+
* // isDirectory: false,
|
|
622
|
+
* // isSymlink: false
|
|
623
|
+
* // },
|
|
624
|
+
* // ]
|
|
625
|
+
* ```
|
|
626
|
+
*
|
|
627
|
+
* @example Exclude symbolic links
|
|
628
|
+
*
|
|
629
|
+
* Setting the `includeSymlinks` option to `false` will exclude symbolic links.
|
|
630
|
+
*
|
|
631
|
+
* File structure:
|
|
632
|
+
* ```
|
|
633
|
+
* folder
|
|
634
|
+
* ├── script.ts
|
|
635
|
+
* ├── foo
|
|
636
|
+
* └── link -> script.ts (symbolic link)
|
|
637
|
+
* ```
|
|
638
|
+
*
|
|
639
|
+
* ```ts ignore
|
|
640
|
+
* import { walkSync } from "@std/fs/walk";
|
|
641
|
+
*
|
|
642
|
+
* Array.from(walkSync(".", { includeSymlinks: false }));
|
|
643
|
+
* // [
|
|
644
|
+
* // {
|
|
645
|
+
* // path: ".",
|
|
646
|
+
* // name: ".",
|
|
647
|
+
* // isFile: false,
|
|
648
|
+
* // isDirectory: true,
|
|
649
|
+
* // isSymlink: false
|
|
650
|
+
* // },
|
|
651
|
+
* // {
|
|
652
|
+
* // path: "script.ts",
|
|
653
|
+
* // name: "script.ts",
|
|
654
|
+
* // isFile: true,
|
|
655
|
+
* // isDirectory: false,
|
|
656
|
+
* // isSymlink: false
|
|
657
|
+
* // },
|
|
658
|
+
* // ]
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @example Follow symbolic links
|
|
662
|
+
*
|
|
663
|
+
* Setting the `followSymlinks` option to `true` will follow symbolic links,
|
|
664
|
+
* affecting the `path` property of the walk entry.
|
|
665
|
+
*
|
|
666
|
+
* File structure:
|
|
667
|
+
* ```
|
|
668
|
+
* folder
|
|
669
|
+
* ├── script.ts
|
|
670
|
+
* └── link -> script.ts (symbolic link)
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* ```ts ignore
|
|
674
|
+
* import { walkSync } from "@std/fs/walk";
|
|
675
|
+
*
|
|
676
|
+
* Array.from(walkSync(".", { followSymlinks: true }));
|
|
677
|
+
* // [
|
|
678
|
+
* // {
|
|
679
|
+
* // path: ".",
|
|
680
|
+
* // name: ".",
|
|
681
|
+
* // isFile: false,
|
|
682
|
+
* // isDirectory: true,
|
|
683
|
+
* // isSymlink: false
|
|
684
|
+
* // },
|
|
685
|
+
* // {
|
|
686
|
+
* // path: "script.ts",
|
|
687
|
+
* // name: "script.ts",
|
|
688
|
+
* // isFile: true,
|
|
689
|
+
* // isDirectory: false,
|
|
690
|
+
* // isSymlink: false
|
|
691
|
+
* // },
|
|
692
|
+
* // {
|
|
693
|
+
* // path: "script.ts",
|
|
694
|
+
* // name: "link",
|
|
695
|
+
* // isFile: true,
|
|
696
|
+
* // isDirectory: false,
|
|
697
|
+
* // isSymlink: true
|
|
698
|
+
* // },
|
|
699
|
+
* // ]
|
|
700
|
+
* ```
|
|
701
|
+
*
|
|
702
|
+
* @example Canonicalize symbolic links
|
|
703
|
+
*
|
|
704
|
+
* Setting the `canonicalize` option to `false` will canonicalize the path of
|
|
705
|
+
* the followed symbolic link. Meaning, the `path` property of the walk entry
|
|
706
|
+
* will be the path of the symbolic link itself.
|
|
707
|
+
*
|
|
708
|
+
* File structure:
|
|
709
|
+
* ```
|
|
710
|
+
* folder
|
|
711
|
+
* ├── script.ts
|
|
712
|
+
* └── link -> script.ts (symbolic link)
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* ```ts ignore
|
|
716
|
+
* import { walkSync } from "@std/fs/walk";
|
|
717
|
+
*
|
|
718
|
+
* Array.from(walkSync(".", { followSymlinks: true, canonicalize: true }));
|
|
719
|
+
* // [
|
|
720
|
+
* // {
|
|
721
|
+
* // path: ".",
|
|
722
|
+
* // name: ".",
|
|
723
|
+
* // isFile: false,
|
|
724
|
+
* // isDirectory: true,
|
|
725
|
+
* // isSymlink: false
|
|
726
|
+
* // },
|
|
727
|
+
* // {
|
|
728
|
+
* // path: "script.ts",
|
|
729
|
+
* // name: "script.ts",
|
|
730
|
+
* // isFile: true,
|
|
731
|
+
* // isDirectory: false,
|
|
732
|
+
* // isSymlink: false
|
|
733
|
+
* // },
|
|
734
|
+
* // {
|
|
735
|
+
* // path: "link",
|
|
736
|
+
* // name: "link",
|
|
737
|
+
* // isFile: true,
|
|
738
|
+
* // isDirectory: false,
|
|
739
|
+
* // isSymlink: true
|
|
740
|
+
* // },
|
|
741
|
+
* // ]
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* @example Filter by file extensions
|
|
745
|
+
*
|
|
746
|
+
* Setting the `exts` option to `[".ts"]` or `["ts"]` will only include entries
|
|
747
|
+
* with the `.ts` file extension.
|
|
748
|
+
*
|
|
749
|
+
* File structure:
|
|
750
|
+
* ```
|
|
751
|
+
* folder
|
|
752
|
+
* ├── script.ts
|
|
753
|
+
* └── foo.js
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* ```ts ignore
|
|
757
|
+
* import { walkSync } from "@std/fs/walk";
|
|
758
|
+
*
|
|
759
|
+
* Array.from(walkSync(".", { exts: [".ts"] }));
|
|
760
|
+
* // [
|
|
761
|
+
* // {
|
|
762
|
+
* // path: "script.ts",
|
|
763
|
+
* // name: "script.ts",
|
|
764
|
+
* // isFile: true,
|
|
765
|
+
* // isDirectory: false,
|
|
766
|
+
* // isSymlink: false
|
|
767
|
+
* // },
|
|
768
|
+
* // ]
|
|
769
|
+
* ```
|
|
770
|
+
*
|
|
771
|
+
* @example Filter by regular expressions
|
|
772
|
+
*
|
|
773
|
+
* Setting the `match` option to `[/s/]` will only include entries with the
|
|
774
|
+
* letter `s` in their name.
|
|
775
|
+
*
|
|
776
|
+
* File structure:
|
|
777
|
+
* ```
|
|
778
|
+
* folder
|
|
779
|
+
* ├── script.ts
|
|
780
|
+
* └── README.md
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* ```ts ignore
|
|
784
|
+
* import { walkSync } from "@std/fs/walk";
|
|
785
|
+
*
|
|
786
|
+
* Array.from(walkSync(".", { match: [/s/] }));
|
|
787
|
+
* // [
|
|
788
|
+
* // {
|
|
789
|
+
* // path: "script.ts",
|
|
790
|
+
* // name: "script.ts",
|
|
791
|
+
* // isFile: true,
|
|
792
|
+
* // isDirectory: false,
|
|
793
|
+
* // isSymlink: false
|
|
794
|
+
* // },
|
|
795
|
+
* // ]
|
|
796
|
+
* ```
|
|
797
|
+
*
|
|
798
|
+
* @example Exclude by regular expressions
|
|
799
|
+
*
|
|
800
|
+
* Setting the `skip` option to `[/s/]` will exclude entries with the letter
|
|
801
|
+
* `s` in their name.
|
|
802
|
+
*
|
|
803
|
+
* File structure:
|
|
804
|
+
* ```
|
|
805
|
+
* folder
|
|
806
|
+
* ├── script.ts
|
|
807
|
+
* └── README.md
|
|
808
|
+
* ```
|
|
809
|
+
*
|
|
810
|
+
* ```ts ignore
|
|
811
|
+
* import { walkSync } from "@std/fs/walk";
|
|
812
|
+
*
|
|
813
|
+
* Array.from(walkSync(".", { skip: [/s/] }));
|
|
814
|
+
* // [
|
|
815
|
+
* // {
|
|
816
|
+
* // path: "README.md",
|
|
817
|
+
* // name: "README.md",
|
|
818
|
+
* // isFile: true,
|
|
819
|
+
* // isDirectory: false,
|
|
820
|
+
* // isSymlink: false
|
|
821
|
+
* // },
|
|
822
|
+
* // ]
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
function* walkSync(root, options) {
|
|
826
|
+
let { maxDepth = Infinity, includeFiles = true, includeDirs = true, includeSymlinks = true, followSymlinks = false, canonicalize = true, exts = undefined, match = undefined, skip = undefined, } = options ?? {};
|
|
827
|
+
root = (0, _to_path_string_js_1.toPathString)(root);
|
|
828
|
+
if (exts) {
|
|
829
|
+
exts = exts.map((ext) => ext.startsWith(".") ? ext : `.${ext}`);
|
|
830
|
+
}
|
|
831
|
+
if (maxDepth < 0) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
if (includeDirs && include(root, exts, match, skip)) {
|
|
835
|
+
yield (0, _create_walk_entry_js_1.createWalkEntrySync)(root);
|
|
836
|
+
}
|
|
837
|
+
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
const entries = dntShim.Deno.readDirSync(root);
|
|
841
|
+
for (const entry of entries) {
|
|
842
|
+
let path = (0, join_js_1.join)(root, entry.name);
|
|
843
|
+
let { isSymlink, isDirectory } = entry;
|
|
844
|
+
if (isSymlink) {
|
|
845
|
+
if (!followSymlinks) {
|
|
846
|
+
if (includeSymlinks && include(path, exts, match, skip)) {
|
|
847
|
+
yield { path, ...entry };
|
|
848
|
+
}
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
const realPath = dntShim.Deno.realPathSync(path);
|
|
852
|
+
if (canonicalize) {
|
|
853
|
+
path = realPath;
|
|
854
|
+
}
|
|
855
|
+
// Caveat emptor: don't assume |path| is not a symlink. realpath()
|
|
856
|
+
// resolves symlinks but another process can replace the file system
|
|
857
|
+
// entity with a different type of entity before we call lstat().
|
|
858
|
+
({ isSymlink, isDirectory } = dntShim.Deno.lstatSync(realPath));
|
|
859
|
+
}
|
|
860
|
+
if (isSymlink || isDirectory) {
|
|
861
|
+
const opts = {
|
|
862
|
+
maxDepth: maxDepth - 1,
|
|
863
|
+
includeFiles,
|
|
864
|
+
includeDirs,
|
|
865
|
+
includeSymlinks,
|
|
866
|
+
followSymlinks,
|
|
867
|
+
};
|
|
868
|
+
if (exts !== undefined) {
|
|
869
|
+
opts.exts = exts;
|
|
870
|
+
}
|
|
871
|
+
if (match !== undefined) {
|
|
872
|
+
opts.match = match;
|
|
873
|
+
}
|
|
874
|
+
if (skip !== undefined) {
|
|
875
|
+
opts.skip = skip;
|
|
876
|
+
}
|
|
877
|
+
yield* walkSync(path, opts);
|
|
878
|
+
}
|
|
879
|
+
else if (includeFiles && include(path, exts, match, skip)) {
|
|
880
|
+
yield { path, ...entry };
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|