Skip to content

Commit 99819d5

Browse files
simolus3kevmooharryterkelsen
authored
Import dart:_js_interop_wasm in addition to dart:_wasm to convert between JSAny and WasmExternRef? (#186974)
Currently, `dart:_wasm` exports `externRefForJSAny` and `WasmExternRefToJSAny.toJS` functions and extension getters to convert between `JSAny` and `WasmExternRef?`. Flutter relies on these exports in its `skwasm` implementation. We want to refactor `dart:_wasm` to not export these members from anymore (dart-lang/sdk#63166). The reason is that there'll be a standalone WebAssembly target for Dart, which supports `dart:_wasm` but not `dart:js_interop`. To be able to remove these methods, we've added a `dart:_js_interop_wasm` library defining these helpers (dart-lang/sdk@3196571). Because we're not allowed to break `dart analyze` in Flutter, we need to do this migration in stages. `dart:_wasm` currently re-exports `dart:_js_interop_wasm`, only for this reason. To be able to remove that export, Flutter needs to import `dart:_js_interop_wasm` directly. Once this PR is merged, we can drop the export in the Dart SDk and then remove the `unnecessary_import` lint (`import_internal_library` is an oversight, the analyzer should special-case that library just like `dart:_wasm` itself). ### Tests This doesn't actually change anything, `dart:_wasm` and `dart:_js_interop_wasm` export the same members (everything else would be a compilation error). I've manually ran `dart analyze` with an SDK built from [this change I want to land afterwards](https://dart-review.googlesource.com/c/sdk/+/505960) to ensure Flutter builds correctly once we really remove the export. So I think I'll need a test-exempt status here. Closes #186973. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Kevin Moore <kevmoo@users.noreply.github.com> Co-authored-by: Harry Terkelsen <1961493+harryterkelsen@users.noreply.github.com>
1 parent 0af497b commit 99819d5

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_image.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
@DefaultAsset('skwasm')
66
library skwasm_impl;
77

8+
// TODO(simolus3): Remove these analyzer ignores, https://dartbug.com/63166.
9+
// ignore: unnecessary_import, import_internal_library
10+
import 'dart:_js_interop_wasm';
811
import 'dart:_wasm';
912
import 'dart:ffi';
1013
import 'dart:js_interop';

engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_surface.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
@DefaultAsset('skwasm')
66
library skwasm_impl;
77

8+
// TODO(simolus3): Remove these analyzer ignores, https://dartbug.com/63166.
9+
// ignore: unnecessary_import, import_internal_library
10+
import 'dart:_js_interop_wasm';
811
import 'dart:_wasm';
912
import 'dart:ffi';
1013
import 'dart:js_interop';

engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// TODO(simolus3): Remove these analyzer ignores, https://dartbug.com/63166.
6+
// ignore: unnecessary_import, import_internal_library
7+
import 'dart:_js_interop_wasm';
58
import 'dart:_wasm';
69
import 'dart:async';
710
import 'dart:ffi';

0 commit comments

Comments
 (0)