♻️ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait#1886
Open
harehare wants to merge 5 commits into
Open
♻️ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait#1886harehare wants to merge 5 commits into
harehare wants to merge 5 commits into
Conversation
Support fetching mq modules from HTTP/GitHub URLs in the WASM runtime using the browser Fetch API. Versioned (tagged) imports are cached persistently in OPFS; mutable (HEAD/branch) imports use a refreshable cache. Adds clearHttpCache and clearAllHttpCache WASM exports for cache management from the host.
… trait Split `http-import` feature into `http-import` (URL utils + trait + generic resolver) and `http-import-ureq` (adds UreqFetcher with disk cache + ureq). - Add `HttpFetcher` trait covering both fetch and cache responsibility - Introduce generic `HttpModuleResolver<F: HttpFetcher>` replacing the ureq-coupled implementation - Add `UreqFetcher` behind `http-import-ureq` feature (disk cache with versioned/mutable subdirs and SHA-256 sidecar, ureq HTTPS fetch) - Add `WasmFetcher` in mq-wasm: reads from a pre-populated in-memory HashMap, bridging async OPFS preload with sync module resolution - mq-run enables `mq-lang/http-import-ureq`; mq-wasm enables `mq-lang/http-import` (no ureq dependency in WASM)
`extract_http_import_urls` previously only scanned `import` nodes; `include "https://..."` and `include "github.com/..."` were silently skipped, so OPFS caching never ran for them. ✅ test(http-import): add rstest parametrized and proptest property tests Add comprehensive rstest cases and proptest property-based tests for all URL utility functions in `http_import.rs` (is_remote_url, is_github_url, github_to_raw_url, extract_module_name, normalize_allowed_domain, is_allowed_url, is_versioned_url, prefix_matches). Add wasm_bindgen_test cases for extract_http_import_urls covering import and include with HTTPS/GitHub URLs, local exclusions, mixed code, invalid syntax, and empty input.
Add parametrized rstest cases and proptest property-based tests for is_remote_url, is_github_url, github_to_raw_url, extract_module_name, normalize_allowed_domain, is_allowed_url, is_versioned_url, and prefix_matches covering edge cases, prefix-attack prevention, scheme stripping, and mutable/versioned ref classification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1884