Skip to content

fix: gate platform implementations on dart.library.io for the Web build - #4

Merged
AmisKwok merged 1 commit into
mainfrom
fix/wasm-platform-support
Sep 15, 2026
Merged

AmisKwok merged 1 commit into
mainfrom
fix/wasm-platform-support

Conversation

@AmisKwok

@AmisKwok AmisKwok commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Summary / 摘要

Gate the platform-specific implementations on dart.library.io so the Web build no longer resolves dart:io. / 将各平台实现改为按 dart.library.io 条件引入,使 Web 构建不再解析到 dart:io。

Changes / 变更

  • Flip the conditional exports in ping_service.dart, connectivity_service.dart, dns_service.dart, port_service.dart and network_capabilities.dart: the browser-based variants are now the default, and the dart:io variants are gated behind dart.library.io. / 反转 5 处条件导出:浏览器版本成为默认,dart:io 版本改为按 dart.library.io 命中时启用。
  • Bump the version to 1.0.4 across pubspec.yaml, both podspecs, README.md, README_zh.md and CHANGELOG.md. / 版本升级至 1.0.4(pubspec、iOS/macOS podspec、两份 README、CHANGELOG)。

Context / 背景

The conditional exports previously defaulted to the dart:io variants and only switched to the browser-based variants when dart.library.html was defined. Any environment that does not define dart.library.html therefore still resolved the dart:io variants and pulled dart:io into the Web build. Making the browser-based variants the default and gating the dart:io variants behind dart.library.io leaves the fallback dart:io-free, while runtime behaviour on every supported platform stays exactly the same. / 此前条件导出默认落到 dart:io 版本,仅在定义了 dart.library.html 时切到浏览器版本;未定义该库的环境仍会解析到 dart:io 版本,从而把 dart:io 带入 Web 构建。改为浏览器版本兜底、原生版本按 dart.library.io 引入后,兜底路径不含 dart:io,且各平台运行时行为完全不变。

Checklist / 检查项

  • Title follows Conventional Commits / 标题符合约定式提交
  • CI checks pass after merge / 合入后 CI 通过

Test plan

  • dart format --set-exit-if-changed ., flutter analyze and flutter test all pass locally (49 tests). / 本地格式化校验、静态分析与测试均通过(49 个用例)。
  • After publishing 1.0.4, confirm the Web platform is reported as compatible with the WASM runtime. / 发布 1.0.4 后确认 Web 平台被判定为兼容 WASM 运行时。

🤖 Generated with Zero Buddy

The conditional exports for ping, connectivity, DNS, port and network capabilities defaulted to the dart:io variants and only switched to the web variants when dart.library.html was defined. Any environment that does not define dart.library.html still resolved the dart:io variants, which pulled dart:io into the Web build. Flip the conditionals so the browser-based variants are the default and the dart:io variants are gated behind dart.library.io. Runtime behaviour on every supported platform is unchanged; only the fallback when neither library is defined becomes dart:io-free.
@AmisKwok
AmisKwok merged commit 0416d32 into main Sep 15, 2026
14 of 15 checks passed
@AmisKwok
AmisKwok deleted the fix/wasm-platform-support branch September 16, 2026 00:00
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