Skip to content

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

Merged
harehare merged 8 commits into
mainfrom
feat/wasm-http-import
Jun 17, 2026
Merged

♻️ refactor(http-import): make HTTP fetcher pluggable via HttpFetcher trait#1886
harehare merged 8 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 (bf23af0) with main (e42d6e1)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (eb53e80) during the generation of this report, so e42d6e1 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@harehare harehare force-pushed the feat/wasm-http-import branch from b0ff5a5 to bf23af0 Compare June 17, 2026 12:50
@harehare harehare merged commit 149a697 into main Jun 17, 2026
11 checks passed
@harehare harehare deleted the feat/wasm-http-import branch June 17, 2026 13:10
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