Skip to content

fix: make package WASM-compatible by implementing web connectivity via package:web - #3

Merged
AmisKwok merged 6 commits into
mainfrom
fix/wasm-compat-connectivity
Sep 15, 2026
Merged

AmisKwok merged 6 commits into
mainfrom
fix/wasm-compat-connectivity

Conversation

@AmisKwok

Copy link
Copy Markdown
Member

Summary / 摘要

Make the package WASM-compatible so pana scores full platform-support points (20/20) instead of 10/20.
让包具备 WASM 兼容性,pana 平台支持评分从 10/20 提升到 20/20(满分)。

Changes / 变更

  • The web ConnectivityService no longer imports connectivity_plus; it now talks to the browser directly through package:web (navigator.onLine + online/offline events) via a new WebConnectivityAdapter. / Web 端的 ConnectivityService 不再导入 connectivity_plus,改为通过新增的 WebConnectivityAdapter 用 package:web(navigator.onLine 与 online/offline 事件)直接与浏览器交互。
  • Added web as a direct dependency in pubspec.yaml. / 在 pubspec.yaml 中把 web 提升为直接依赖。
  • connectivity_plus is still used on native platforms through the injectable ConnectivityAdapter. / 原生平台仍通过可注入的 ConnectivityAdapter 使用 connectivity_plus。
  • Bumped package version to 1.0.3 (pubspec, iOS/macOS podspecs, README/README_zh, CHANGELOG). / 包版本提升到 1.0.3(pubspec、iOS/macOS podspec、README/README_zh、CHANGELOG)。

Context / 背景

connectivity_plus 7.3.1's non-web default branch (connectivity_plus_linux.dart) imports the Linux-only nm package. Because the web connectivity adapter imported connectivity_plus, pana's transitive import-graph analysis reached nm (FFI), so it flagged the package as not WASM-compatible and gave a partial platform score (10/20). Implementing web connectivity on package:web directly removes nm from the web import graph; the native path is unchanged.
connectivity_plus 7.3.1 的非 Web 默认分支(connectivity_plus_linux.dart)会引入仅限 Linux 的 nm 包。由于 Web 连通性适配器曾导入 connectivity_plus,pana 的传递导入图分析追到了 nm(FFI),从而判定包不可 WASM 并给半分(10/20)。改用 package:web 直接实现后,nm 不再出现在 Web 导入图中,原生路径不变。

Checklist / 检查项

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

Test plan

  • flutter analyze reports no issues and flutter test passes (49 tests). / flutter analyze 无问题、flutter test 通过(49 个测试)。
  • Local pana run shows ## ✓ Platform support (20 / 20) with no "Package not compatible with runtime wasm" note. / 本地 pana 显示 ## ✓ Platform support (20 / 20) 且无 "Package not compatible with runtime wasm" 提示。

🤖 Generated with Zero Buddy

AmisKwok and others added 6 commits September 16, 2026 06:43
…a package:web

The web connectivity implementation imported connectivity_plus, whose non-web default branch pulls in the Linux-only nm package (FFI). pana therefore scored the package 10/20 on platform support (partial WASM, 'Package not compatible with runtime wasm').

Implement web connectivity directly on package:web (window.navigator.onLine plus the online/offline events) so the web import graph no longer reaches nm. Native platforms still use connectivity_plus via the injectable ConnectivityAdapter. Verified locally: pana Platform support is now 20/20 with no WASM incompatibility note; flutter analyze and the 49-test suite pass.
@AmisKwok
AmisKwok merged commit f341c1a into main Sep 15, 2026
7 checks passed
@AmisKwok
AmisKwok deleted the fix/wasm-compat-connectivity branch September 15, 2026 23:05
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