Skip to content

♻️ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait#1886

Open
harehare wants to merge 5 commits into
mainfrom
feat/wasm-http-import
Open

♻️ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait#1886
harehare wants to merge 5 commits into
mainfrom
feat/wasm-http-import

Conversation

@harehare

Copy link
Copy Markdown
Owner

harehare added 4 commits June 16, 2026 21:23
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.
@codspeed-hq

codspeed-hq Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing feat/wasm-http-import (e1a08f5) with main (e42d6e1)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant