Skip to content

Migrate to pkg:web #6606

Closed
Closed

Description

@kevmoo

Required to support compilation to wasm

Googlers: go/wasm-ready-pkg-migrate

Activity

  1. kenzieschmoll commented on Oct 31, 2023

    @kenzieschmoll
    Member

    migrations for devtools_app that are not straightforward, or just need a little more attention to figure out:

  2. kevmoo commented on Oct 31, 2023

    @kevmoo
    ContributorAuthor
  3. srujzs commented on Nov 7, 2023

    @srujzs
    Contributor
    • MouseEvent.offset: The dart:html version returns a Point with offsetX and offsetY. There's some checking to make sure offsetX is supported, but that's stale since modern browsers should support it: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX. If the Point class is heavily used in devtools, then maybe we should add it as a helper class in package:web. If not, using a record with offsetX and offsetY should probably suffice.
    • createObjectURL: The dart:html version checks for a webkitURL. This is no longer needed as it seems all browsers nowadays support URL: https://developer.mozilla.org/en-US/docs/Web/API/URL so it should be safe to use the package:web version => URL.createObjectURL.
    • html.window.onMessage: I think this needs _ElementEventStreamImpl to be added to the helpers in package:web. A workaround is using event listeners, but Streams are nicer. Sorry, was looking at the wrong code. I think this just needs the existing onMessage to be exposed on top of Window. I think you can just do EventStreamProviders.messageEvent.forTarget(window).
  4. kenzieschmoll commented on Nov 9, 2023

    @kenzieschmoll
    Member

    @srujzs
    re: MouseEvent, what about the dataTransfer property?
    event.dataTransfer.dropEffect = 'move';

    re: createObjectURL - more issues:
    Screenshot 2023-11-09 at 2 59 46 PM
    Screenshot 2023-11-09 at 3 00 39 PM

    re: html.window.onMessage

  5. srujzs commented on Nov 10, 2023

    @srujzs
    Contributor
    • I think you'll need to downcast MouseEvent to DragEvent to get dataTransfer, which then has a dropEffect property.

    • You want to avoid importing dart:js here. The type you want is JSArray (I know the naming is unfortunate, but alas). To convert from a list to one, you need a List<JSAny>. This can be created by making content itself a JSString: [content.toJS].toJS should get you want you the JSArray you need.

  6. kenzieschmoll commented on Nov 10, 2023

    @kenzieschmoll
    Member

    Thanks @srujzs. Getting closer! A few more errors to go:

    • reader is a FileReader object, and droppedFile is a File object:
      Screenshot 2023-11-09 at 11 29 03 PM
    • element.style.display = 'none'
    • document.body!.append(element);
    • element.click()
      Screenshot 2023-11-09 at 11 31 26 PM
  7. srujzs commented on Nov 10, 2023

    @srujzs
    Contributor

    Nice!

    • I think this is similar to the other issues where this stream getter is not available (onLoadEnd). It does seems to exist on Element, so a hacky workaround until we publish a version with it is to just cast to Element and use onLoad (note that we don't check whether that cast is correct since they're both just some random JS objects in the type system's eyes).
    • lastModifiedData is deprecated in the browser. The right equivalent here is using lastModified to get the ms since epoch to construct a DateTime e.g. DateTime.fromMillisecondsSinceEpoch(droppedFile.lastModifiedDate, isUtc: true).
    • You'll need to downcast here to the Element type you want. I believe downcasting element to HTMLAnchorElement should resolve the rest. Using createElement and then downcasting is a downgrade from the nice dart:html constructors, and maybe we should have a createElementAs<HTMLAnchorElement>()-like helper somewhere.
  8. kevmoo commented on Nov 13, 2023

    @kevmoo
    ContributorAuthor

    Closing this out as completed via #6626 - still waiting for dependencies to migrate so we can build w/ wasm

  9. kenzieschmoll commented on Nov 13, 2023

    @kenzieschmoll
    Member

    Everything has been migrated to package:web except for one file: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/shared/config_specific/post_message/_post_message_web.dart#L5-L9. Removing this is blocked on a new version of package:web getting rolled into flutter.

    However, if we want to start experimenting with dart2wasm now, apply the changes from this patch and it should compile fine: https://github.com/flutter/devtools/compare/master...kenzieschmoll:dart2wasm-experiment?expand=1.

    @kevmoo

  10. kevmoo commented on Nov 13, 2023

    @kevmoo
    ContributorAuthor

    Reopening then. To stay on top of #6606 (comment)

  11. reopened this on Nov 13, 2023
  12. self-assigned this
    on Nov 15, 2023
  13. 4 remaining items

  14. kevmoo commented on Dec 13, 2023

    @kevmoo
    ContributorAuthor

    Glad we're getting numbers on this. I think the only concrete thing blocking us is either migrating the inline gtags or moving to unified_analytics.

    Is the latter tracked anywhere?

  15. kenzieschmoll commented on Dec 13, 2023

    @kenzieschmoll
    Member

    migrating to unified_analytics is tracked here: #6242. This is something that @eliasyishak may be picking up in the short term.

  16. added
    blockedIssue or PR is blocked on another issue or PR.
    on Dec 13, 2023
  17. removed
    blockedIssue or PR is blocked on another issue or PR.
    on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions