feat: add partial web platform support - #1
Merged
Merged
Conversation
Split the services that depend on dart:io into io/web variants behind conditional imports so the plugin compiles for Flutter Web. Connectivity uses connectivity_plus, ping degrades to an HTTPS round trip, DNS uses DNS-over-HTTPS, and the speed test, quality score and benchmarks are unchanged. Capabilities the browser sandbox forbids degrade to null or an unavailable result instead of throwing. 将依赖 dart:io 的服务拆分为 io/web 两份实现并以条件导入隔离,使插件可编译到 Flutter Web;浏览器沙箱禁止的能力优雅降级为 null 或不可用结果而非抛异常。
Cache-Control is not a CORS-safelisted header, so sending it forces an OPTIONS preflight that speed-test endpoints reject, surfacing as Failed to fetch on the web. The endpoints already send Cache-Control: no-store themselves. Cache-Control 不属于 CORS 安全头,发送它会触发被测速端点拒绝的 OPTIONS 预检,在 Web 上表现为 Failed to fetch;端点自身已下发 no-store。
Only IF_TYPE_TUNNEL was treated as a VPN, which missed TAP-Windows, Wintun, WireGuard and OpenVPN adapters. IF_TYPE_PPP is deliberately excluded because PPPoE broadband reports the same interface type and would be misreported. 此前仅将 IF_TYPE_TUNNEL 视为 VPN,漏掉 TAP-Windows、Wintun、WireGuard、OpenVPN 等网卡;有意排除 IF_TYPE_PPP,因为 PPPoE 宽带上报同一接口类型,会被误报。
Sync the iOS and macOS podspecs and the README dependency constraint to 1.0.1, document the partial web support in both READMEs, and add the bilingual 1.0.1 changelog entry. 同步 iOS 与 macOS podspec 及 README 依赖约束至 1.0.1,在两份 README 中说明 Web 部分支持,并补充双语的 1.0.1 变更日志。
Platform-Support.md no longer claims Web is unsupported: the intro, capability matrix and NetworkCapabilities rules now cover the web, and a dedicated Web support section lists which capabilities degrade and notes that browsers expose no VPN API. FAQ.md is updated to match. Platform-Support.md 不再声称不支持 Web:开头、能力矩阵与 NetworkCapabilities 规则均已覆盖 Web,并新增 Web 支持章节列出各能力的降级行为,同时说明浏览器不暴露 VPN 接口;FAQ.md 同步更新。
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 / 摘要
Add partial Flutter Web support and ship it as 1.0.1, together with a CORS fix for the speed test, broader Windows VPN detection, and recovery of the app icons an earlier line-ending normalisation corrupted.
为插件新增 Flutter Web 部分支持并发布 1.0.1,同时修复 Web 端测速的 CORS 预检问题、扩展 Windows VPN 判定,并恢复此前换行归一化损坏的应用图标。
Changes / 变更
dart:io-dependent services intoio/webvariants behind conditional imports, add thewebplatform entry plusZeroNetworkKitWeb, and add anexample/web/entry point / 将依赖dart:io的服务拆分为io/web两份实现并以条件导入隔离,新增web平台声明与ZeroNetworkKitWeb,并补充example/web/入口connectivity_plus, ping degrades to an HTTPS round trip, DNS uses DNS-over-HTTPS; the speed test, quality score and benchmarks keep working unchanged / 连通性走connectivity_plus,Ping 退化为 HTTPS 往返耗时,DNS 改用 DNS-over-HTTPS;测速、质量评分与基准测试行为不变null, port checks return an "unavailable" result, andNetworkCapabilities.current()exposes the supported set / 优雅降级:原生详情返回null,端口检测返回"不可用"结果,NetworkCapabilities.current()暴露当前支持的能力集合Cache-Controlrequest header: it is not CORS-safelisted, so it forced an OPTIONS preflight that endpoints reject, surfacing asFailed to fetchon the web / 移除Cache-Control请求头:它不属于 CORS 安全头,会触发被端点拒绝的 OPTIONS 预检,在 Web 上表现为Failed to fetchIF_TYPE_PPPis deliberately excluded because PPPoE broadband shares that interface type / Windows 额外按驱动名识别 VPN 网卡(TAP-Windows / Wintun / WireGuard / OpenVPN);有意排除IF_TYPE_PPP,因为 PPPoE 宽带共用该接口类型Context / 背景
The plugin previously could not compile for the web at all because its services imported
dart:io, so every consumer targeting Flutter Web was blocked. Browsers also forbid raw TCP/UDP sockets and expose no VPN API, so web support is intentionally partial and documented as such instead of silently returning wrong values.此前插件因服务层导入
dart:io而完全无法编译到 Web,所有面向 Flutter Web 的使用方都被阻塞。浏览器同时禁止原生 TCP/UDP 套接字且不暴露 VPN 接口,因此 Web 支持有意设计为部分支持并明确文档化,而不是静默返回错误结果。Checklist / 检查项
Test plan
flutter analyzereports no issues andflutter testpasses (49 tests) /flutter analyze无问题,flutter test通过(49 个用例)flutter build websucceeds inexample// 在example/下flutter build web构建成功isVpnstaysfalseeven with a VPN or proxy active / 在 Web 上运行 example:连通性、DNS(DoH)、测速可用,端口检测返回"不可用",即使开启 VPN 或代理isVpn仍为false🤖 Generated with Zero Buddy