Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8800cc7
depend on package:web
navaronbracke Oct 27, 2023
0c9fc45
fix comment
navaronbracke Oct 27, 2023
8960e3d
update import in base file
navaronbracke Oct 27, 2023
b420f32
depend on package web in the example app
navaronbracke Oct 28, 2023
a0637f1
add utility function to create divs
navaronbracke Oct 28, 2023
636e71f
migrate overlay.dart
navaronbracke Oct 28, 2023
639fe97
migrate markers.dart
navaronbracke Oct 28, 2023
c22678e
migrate marker.dart
navaronbracke Oct 28, 2023
147e570
migrate convert.dart
navaronbracke Oct 28, 2023
5ff2982
migrate google_maps_controller.dart
navaronbracke Oct 28, 2023
c4581dd
migrate google map controller test
navaronbracke Oct 28, 2023
0fb3d67
migrate markers test
navaronbracke Oct 28, 2023
9898737
migrate another markers test
navaronbracke Oct 28, 2023
18564d2
migrate overlay_test.dart
navaronbracke Oct 28, 2023
aa9533a
migrate overlays_test.dart
navaronbracke Oct 28, 2023
1667de9
migrate shapes_test.dart
navaronbracke Oct 28, 2023
c43f31e
add missing imports
navaronbracke Oct 28, 2023
a14981c
remove space
navaronbracke Oct 28, 2023
32d66fa
switch to pkg google_maps beta
navaronbracke Jan 11, 2024
788d35a
add casts due to pkg:web 0.4.0 removing "implements JSObject" from Blob
navaronbracke Jan 11, 2024
1040103
format
navaronbracke Jan 11, 2024
edc00a8
fix event listener type
navaronbracke Jan 11, 2024
cd2b0e8
add directionality
navaronbracke Jan 23, 2024
861f294
fix version constraint for pkg:web
navaronbracke Jan 23, 2024
bb8810f
fix type error in overlay test
navaronbracke Jan 23, 2024
e578d86
fix lint warnings
navaronbracke Jan 23, 2024
638a466
fix hanging test
navaronbracke Jan 23, 2024
75db30d
use .toJS on Function directly
navaronbracke Jan 23, 2024
2c086d2
fix test
navaronbracke Jan 31, 2024
fb7f53a
bump google_maps to 7.0.0
navaronbracke Feb 8, 2024
aee9770
remove the utility in integration tests
navaronbracke Feb 14, 2024
9f2716e
assert on Uint8List for the bitmap descriptor
navaronbracke Feb 14, 2024
cb9c665
use trusted types policy to sanitize html
navaronbracke Feb 14, 2024
aa46171
fix constructor
navaronbracke Feb 14, 2024
0523daa
fix argument
navaronbracke Feb 14, 2024
e2df4b1
handle undefined trusted types policy
navaronbracke Feb 15, 2024
e358399
bump version of google_maps_flutter_web
navaronbracke Feb 19, 2024
736aec1
fix license headers
navaronbracke Feb 19, 2024
8b4d7bb
adjust trusted types binding usage
navaronbracke Feb 23, 2024
d8adca1
fix quotes in pubspec & add ignore for upcoming lint
navaronbracke Feb 27, 2024
52baeca
add JS binding for MapStyler
navaronbracke Feb 27, 2024
1951a6a
set inner html to trusted html instance
navaronbracke Feb 27, 2024
6583739
Make getTTPolicy a little bit less generic looking.
ditman Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adjust trusted types binding usage
  • Loading branch information
navaronbracke committed Feb 27, 2024
commit 8b4d7bbd007c072b148d1b01cc85080312f9656c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ dependencies:
google_maps_flutter_platform_interface: ^2.4.0
google_maps_flutter_web:
path: ../
web: "^0.5.0"
web: ^0.5.0

dev_dependencies:
build_runner: ^2.1.1
flutter_test:
sdk: flutter
google_maps: ^7.0.0
google_maps: ^7.1.0
Copy link
Member

Choose a reason for hiding this comment

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

This is not blocking for this review, but when I tried to do a Wasm build of the google maps' example app for web, I still get some errors coming from the google_maps package:

  • google_maps-7.1.0
    • lib/src/generated/google_maps_core.js.g.dart:26:8:
      Error: Dart library 'dart:web_gl' is not available on this platform.
    • lib/src/google_maps.dart:15:1: Error: JS interop
      library 'package:js/js.dart' can't be imported when compiling to Wasm.
    • lib/src/google_maps.dart:16:1: Error: JS interop
      library 'package:js/js_util.dart' can't be imported when compiling to Wasm.
  • js_wrapping-0.7.4
    • lib/js_wrapping.dart:9:1: Error: JS interop library
      'package:js/js.dart' can't be imported when compiling to Wasm.
    • lib/js_wrapping.dart:10:1: Error: JS interop library
      'package:js/js_util.dart' can't be imported when compiling to Wasm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we file a tracking issue for google_maps WASM support?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should, compiling to --wasm is the main goal of this migration.

Copy link
Member

Choose a reason for hiding this comment

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

/FYI @kevmoo!

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah 💩 . Ugh...

Copy link
Contributor

Choose a reason for hiding this comment

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

google_maps_flutter: ^2.2.0 # Needed for projection_test.dart
http: ">=0.13.0 <2.0.0"
integration_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,15 @@ String _sanitizeHtml(String htmlString) {
try {
// Firefox and Safari don't support Trusted Types yet.
// See https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicyFactory#browser_compatibility
trustedTypePolicy = window.trustedTypesNullable?.createPolicy(
'google_maps_flutter_sanitize',
TrustedTypePolicyOptions(
createHTML: (String html, JSAny? arguments) {
return sanitizeHtml(html);
}.toJS,
),
);
trustedTypePolicy =
WindowWithTrustedTypes(window).trustedTypesNullable?.createPolicy(
'google_maps_flutter_sanitize',
TrustedTypePolicyOptions(
createHTML: (String html, JSAny? arguments) {
return sanitizeHtml(html);
}.toJS,
),
);
} catch (_) {
// Fallback to not using the trusted types policy.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,54 @@ import 'dart:js_interop';

import 'package:web/web.dart';

/// This extension exists to handle unsupported features by certain browsers.
extension DomWindowExtension on Window {
/// This extension type exists to handle unsupported features by certain browsers.
@JS()
extension type WindowWithTrustedTypes(Window _) implements JSObject {
/// Get the `trustedTypes` object from the window, if it is supported.
@JS('trustedTypes')
external TrustedTypePolicyFactory? get trustedTypesNullable;
}

// TODO(ditman): remove this extension type when we depend on package:web 0.5.1
/// This extension exists as a stop gap until `package:web 0.5.1` is released.
/// That version provides the `TrustedTypes` API.
@JS()
extension type TrustedTypePolicyFactory._(JSObject _) implements JSObject {
Copy link
Member

Choose a reason for hiding this comment

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

@srujzs if the extension type has the same name as the one in package:web, would we get an error because of the duplicate Dart name? Should this be named something else that is not an exact copy of the one defined in package:web?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for the sake of name collisions, I prefixed these stubs with GoogleMaps. These will go away in the short term anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll see an error just because of the collision in Dart names, so if there's code that's importing this and package:web and uses the symbol, you'll see a collision. Namespacing the import or renaming via the @JS annotation are both valid alternatives.

/// Create a new `TrustedTypePolicy` instance
/// with the given [policyName] and [policyOptions].
external TrustedTypePolicy createPolicy(
String policyName, [
TrustedTypePolicyOptions policyOptions,
]);
}

// TODO(ditman): remove this extension type when we depend on package:web 0.5.1
/// This extension exists as a stop gap until `package:web 0.5.1` is released.
/// That version provides the `TrustedTypes` API.
extension type TrustedTypePolicy._(JSObject _) implements JSObject {
/// Create a new `TrustedHTML` instance with the given [input] and [arguments].
external TrustedHTML createHTML(
String input,
JSAny? arguments,
);
}

// TODO(ditman): remove this extension type when we depend on package:web 0.5.1
/// This extension exists as a stop gap until `package:web 0.5.1` is released.
/// That version provides the `TrustedTypes` API.
@JS()
extension type TrustedTypePolicyOptions._(JSObject _) implements JSObject {
/// Create a new `TrustedTypePolicyOptions` instance.
external factory TrustedTypePolicyOptions({
JSFunction createHTML,
});
}

// TODO(ditman): remove this extension type when we depend on package:web 0.5.1
/// This extension exists as a stop gap until `package:web 0.5.1` is released.
/// That version provides the `TrustedTypes` API.
@JS()
extension type TrustedHTML._(JSObject _) implements JSObject {
// This type inherits `toString()` from `Object`.
// See also: https://developer.mozilla.org/en-US/docs/Web/API/TrustedHTML/toString
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
google_maps: ^7.0.0
google_maps: ^7.1.0
google_maps_flutter_platform_interface: ^2.4.0
sanitize_html: ^2.0.0
stream_transform: ^2.0.0
web: "^0.5.0"
web: ^0.5.0

dev_dependencies:
flutter_test:
Expand Down