Skip to content

WASM compatibility: drop dart:io from import graph (pana 160/160)#95

Merged
anilcancakir merged 5 commits into
masterfrom
feat/wasm-compatibility
Jun 8, 2026
Merged

WASM compatibility: drop dart:io from import graph (pana 160/160)#95
anilcancakir merged 5 commits into
masterfrom
feat/wasm-compatibility

Conversation

@anilcancakir

@anilcancakir anilcancakir commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

WASM compatibility — pana 150 → 160

Removes dart:io from the fluttersdk_wind public import graph so the package becomes is:wasm-ready, raising pana Platform support 10/20 → 20/20 (total 150 → 160), with zero public-API change.

Changes

  • platform_service.dart: platform detection now uses Flutter's WASM-safe defaultTargetPlatform via a pure @visibleForTesting resolvePlatform() mapper (exhaustive TargetPlatform switch, no default). The 7 platform strings (ios/android/linux/macos/windows/unknown/web) and isMobile semantics are preserved exactly (they back parser platform-prefixes + the cache key). Tests now cover every branch via debugDefaultTargetPlatformOverride, dropping 4 host-dependent coverage:ignore-line pragmas.
  • background_parser.dart: the absolute-path bg-[/...] FileImage(File(path)) path moves behind a 2-file conditional import (file_image_stub.dart returns null on web/WASM; file_image_io.dart returns FileImage on native). dart:io and the redundant kIsWeb branch are removed; graceful web degradation unchanged.
  • CI guard (deploy.yml): a run:-only step asserts the is:wasm-ready pana tag in the Lint & Test job, so dart:io can't silently regress the score. No new pinned action (stays clear of the zizmor SHA-pin policy).
  • CHANGELOG: entry under ### Fixed.

Verification

  • dart analyze lib/ test/ → 0 issues
  • dart format → no diff
  • flutter test → 1253 pass, ./tool/coverage.sh 90 → 90.4%
  • flutter pub publish --dry-run → 0 warnings (post-commit)
  • pana160/160, is:wasm-ready: true, Platform support 20/20
  • grep -rl "dart:io" lib/ → only file_image_io.dart (the intended io arm)

Planned + executed via /ac:plan/ac:execute (standard plan, reviewer + code-review both APPROVED).

Summary by CodeRabbit

  • New Features

    • Library declared WASM-ready and improved web compatibility.
  • Bug Fixes

    • Removed native-only file API usage that caused web incompatibilities; image handling now degrades gracefully on unsupported platforms.
  • Chores

    • Switched platform detection to a Flutter-native approach.
    • CI updated to validate WASM readiness.

Replace dart:io Platform.is* with Flutter's WASM-safe defaultTargetPlatform
through a pure @VisibleForTesting resolvePlatform() mapper over an exhaustive
TargetPlatform switch. Preserves the 7 platform strings and isMobile semantics.
Tests exercise every branch via debugDefaultTargetPlatformOverride.
Move FileImage(File(path)) behind a 2-file conditional import (stub returns
null on web/WASM; io arm returns FileImage on native). Removes the dart:io
import and the redundant kIsWeb branch from background_parser.
Run pana and fail the job if the is:wasm-ready tag is absent, guarding against
dart:io re-entering the import graph. run-only step (no new pinned action).
Copilot AI review requested due to automatic review settings June 8, 2026 14:12
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fdc1bdb4-3b63-4640-b574-d87e6b2649de

📥 Commits

Reviewing files that changed from the base of the PR and between be488d4 and 8e511e0.

📒 Files selected for processing (2)
  • .github/workflows/deploy.yml
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/deploy.yml

📝 Walkthrough

Walkthrough

This PR makes the Wind library WASM-ready by removing dart:io from the import graph. Platform detection now uses Flutter's defaultTargetPlatform via a new resolvePlatform() method, and file image loading is abstracted behind conditional platform-specific implementations. A CI step validates the WASM-ready tag.

Changes

WASM-ready refactoring

Layer / File(s) Summary
Platform detection abstraction
lib/src/core/platform_service.dart, test/core/platform_service_test.dart
WindPlatformService replaces dart:io Platform checks with a new static resolvePlatform() method that maps Flutter's defaultTargetPlatform to platform names and mobile flags. Singleton initialization calls resolvePlatform() instead of _initialize(). Test suite validates tuple results for each platform via debugDefaultTargetPlatformOverride.
File image provider abstraction
lib/src/parser/parsers/file_image_io.dart, lib/src/parser/parsers/file_image_stub.dart, lib/src/parser/parsers/background_parser.dart, test/parser/parsers/background_parser_test.dart
New platform-specific implementations: file_image_io.dart provides native VM support using dart:io and FileImage, while file_image_stub.dart returns null for web/WASM targets. BackgroundParser uses conditional import to select the appropriate provider and gracefully degrades when unavailable. Tests validate the IO arm returns correct FileImage objects.
CI validation and changelog
.github/workflows/deploy.yml, CHANGELOG.md
Deploy workflow adds a pana check requiring the is:wasm-ready tag to pass CI. Changelog documents the removal of dart:io from the import graph and gated absolute-path image resolution.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 With platforms mapped and images gated,
The library's WASM-ready, elevated,
No IO chains to break the code,
Through web and native, the same road,
A hundred percent support, celebrated!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'WASM compatibility: drop dart:io from import graph (pana 160/160)' directly and accurately summarizes the main objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wasm-compatibility

Comment @coderabbitai help to get the list of available commands and usage tips.

@sentry

sentry Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the package WASM-compatible by removing unconditional dart:io usage from the library import graph (while preserving existing platform-string semantics), adding targeted tests for the new behavior, and enforcing the is:wasm-ready pana tag in CI.

Changes:

  • Replaced dart:io-based platform detection with a WASM-safe defaultTargetPlatform mapper (resolvePlatform()), plus exhaustive tests via debugDefaultTargetPlatformOverride.
  • Moved absolute-path background image loading behind a conditional import (file_image_stub.dart vs file_image_io.dart) to avoid dart:io on web/WASM.
  • Added a CI guard step to assert the is:wasm-ready pana tag and documented the fix in the changelog.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/parser/parsers/background_parser_test.dart Adds coverage for the native (io) fileImageProvider() behavior.
test/core/platform_service_test.dart Adds deterministic branch coverage for resolvePlatform() using debugDefaultTargetPlatformOverride.
lib/src/parser/parsers/file_image_stub.dart Introduces web/WASM stub returning null to avoid File usage.
lib/src/parser/parsers/file_image_io.dart Introduces native dart:io implementation returning FileImage.
lib/src/parser/parsers/background_parser.dart Switches absolute-path handling to use conditional-imported fileImageProvider().
lib/src/core/platform_service.dart Removes dart:io dependency; resolves platform via defaultTargetPlatform (plus kIsWeb).
CHANGELOG.md Documents the WASM-readiness change under “Fixed”.
.github/workflows/deploy.yml Adds a pana-based CI assertion that is:wasm-ready remains present.

Comment on lines +72 to +75
dart pub global activate pana
dart pub global run pana --json --no-warning . > pana.json
python3 -c "import json,sys; tags=json.load(open('pana.json')).get('tags',[]); sys.exit(0 if 'is:wasm-ready' in tags else 'is:wasm-ready missing from pana tags')"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e511e0: the step now prints the present tags and exits with an explicit integer (sys.exit(0 if ok else 1)), so a failure shows which tags were found.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
CHANGELOG.md (1)

59-59: ⚡ Quick win

Add the issue reference to this changelog bullet.

Line 59 describes the behavior change but omits the relevant tracker reference; append (#95) to match the repo’s changelog format contract.

As per coding guidelines, CHANGELOG.md entries should include GitHub issue numbers ((#XX)) when relevant.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 59, Update the CHANGELOG entry that starts with "WASM
compatibility: removed `dart:io` from the library import graph
(`platform_service.dart` now uses `defaultTargetPlatform`; absolute-path
`bg-[/...]` image resolution moved behind a conditional import)." to append the
issue reference "(`#95`)" at the end of that bullet so it reads with the tracker
number; locate the bullet by that exact text and add the `(`#95`)` suffix to match
the repo changelog format.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@CHANGELOG.md`:
- Line 59: Update the CHANGELOG entry that starts with "WASM compatibility:
removed `dart:io` from the library import graph (`platform_service.dart` now
uses `defaultTargetPlatform`; absolute-path `bg-[/...]` image resolution moved
behind a conditional import)." to append the issue reference "(`#95`)" at the end
of that bullet so it reads with the tracker number; locate the bullet by that
exact text and add the `(`#95`)` suffix to match the repo changelog format.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b64de13-5fe7-4e53-8cdb-2fc565f64d28

📥 Commits

Reviewing files that changed from the base of the PR and between 4c965da and be488d4.

📒 Files selected for processing (8)
  • .github/workflows/deploy.yml
  • CHANGELOG.md
  • lib/src/core/platform_service.dart
  • lib/src/parser/parsers/background_parser.dart
  • lib/src/parser/parsers/file_image_io.dart
  • lib/src/parser/parsers/file_image_stub.dart
  • test/core/platform_service_test.dart
  • test/parser/parsers/background_parser_test.dart

Address PR review: print the present tags and exit with an explicit integer
instead of sys.exit(<string>), so a CI failure shows which tags were found.
Also add the (#95) reference to the CHANGELOG entry.
@anilcancakir

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback in 8e511e0:

  • Copilot (deploy.yml): wasm-ready check now prints the present tags and exits with an explicit integer instead of sys.exit(<string>).
  • CodeRabbit (CHANGELOG.md): appended the (#95) reference per the changelog convention.

@anilcancakir anilcancakir merged commit c817f15 into master Jun 8, 2026
12 checks passed
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.

2 participants