fix: make package WASM-compatible by implementing web connectivity via package:web - #3
Merged
Merged
Conversation
…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.
…o-labsco/zero_network_kit into fix/wasm-compat-connectivity
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.
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 / 变更
ConnectivityServiceno longer importsconnectivity_plus; it now talks to the browser directly throughpackage:web(navigator.onLine+online/offlineevents) via a newWebConnectivityAdapter. / Web 端的ConnectivityService不再导入connectivity_plus,改为通过新增的WebConnectivityAdapter用package:web(navigator.onLine与online/offline事件)直接与浏览器交互。webas a direct dependency inpubspec.yaml. / 在pubspec.yaml中把web提升为直接依赖。connectivity_plusis still used on native platforms through the injectableConnectivityAdapter. / 原生平台仍通过可注入的ConnectivityAdapter使用connectivity_plus。Context / 背景
connectivity_plus7.3.1's non-web default branch (connectivity_plus_linux.dart) imports the Linux-onlynmpackage. Because the web connectivity adapter importedconnectivity_plus, pana's transitive import-graph analysis reachednm(FFI), so it flagged the package as not WASM-compatible and gave a partial platform score (10/20). Implementing web connectivity onpackage:webdirectly removesnmfrom the web import graph; the native path is unchanged.connectivity_plus7.3.1 的非 Web 默认分支(connectivity_plus_linux.dart)会引入仅限 Linux 的nm包。由于 Web 连通性适配器曾导入connectivity_plus,pana 的传递导入图分析追到了nm(FFI),从而判定包不可 WASM 并给半分(10/20)。改用package:web直接实现后,nm不再出现在 Web 导入图中,原生路径不变。Checklist / 检查项
Test plan
flutter analyzereports no issues andflutter testpasses (49 tests). /flutter analyze无问题、flutter test通过(49 个测试)。panarun 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