Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearly define future-proof JS-interop #50721

Closed
kevmoo opened this issue Dec 15, 2022 · 14 comments
Closed

Clearly define future-proof JS-interop #50721

kevmoo opened this issue Dec 15, 2022 · 14 comments
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-js P1 A high priority bug; for example, a single project is unusable or has many test failures web-js-interop Issues that impact all js interop

Comments

@kevmoo
Copy link
Member

kevmoo commented Dec 15, 2022

@kevmoo kevmoo added library-js web-js-interop Issues that impact all js interop area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Dec 15, 2022
@kevmoo kevmoo added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Dec 15, 2022
@srujzs
Copy link
Contributor

srujzs commented Dec 15, 2022

Below are the set of features we expect to work across both the JS and Wasm compilers for JS interop. Inline classes will be in this list, but they don't exist yet. :)

Disclaimer: The following should work, but none of this necessarily works performantly on dart2wasm. In fact, it's quite slow today. That's a longer-term project involving JS types that will need further work and significant user migration.

Dart SDK Constraint: >= 2.19
package:js constraint >= 0.6.6

  • Subset of package:js
    • @staticInterop interfaces
      • External factory constructors with and without @anonymous
      • External static class members
      • External non-static extension members on a @staticInterop class (fields, getters, setters, methods)
      • Non-external extension members on a @staticInterop class
    • Top-level external members
    • @JSExport to do mocking and exports
  • Subset of dart:js_util (these are just the current ones that work, we may add more before Dart 3 for dart2wasm)
    • jsify
    • dartify
    • getProperty
    • hasProperty
    • setProperty
    • callMethod
    • callConstructor
    • instanceof
    • promiseToFuture
    • globalThis
    • newObject
    • createStaticInteropMock
    • createDartExport
    • allowInterop

@kevmoo
Copy link
Member Author

kevmoo commented Dec 16, 2022

Awesome, @srujzs – thanks!

RE package:js – are we going to publish 0.6.6 along with Dart 2.19?

@parlough
Copy link
Member

parlough commented Dec 16, 2022

We don't really have any JS interop docs on dart.dev right now, but would it be worth mentioning (alongside 2.19) in JS Interop that Dart's JS interop story is currently evolving and to stick to this set of functionality to help ease the transition?

\cc @MaryaBelanger

@kevmoo
Copy link
Member Author

kevmoo commented Dec 16, 2022

We should absolutely create a tracking issue in https://github.com/dart-lang/site-www/ and put it in my list at the top, @parlough

I don't think this is super urgent to get landed the day 2.19 launches – but early-ish in 2023 would be great.

I swear I chatted with @atsansone about this, too – but maybe not.

@parlough
Copy link
Member

parlough commented Dec 16, 2022

We have a tracking issue for general @staticInterop docs: dart-lang/site-www#4331

I've created a new issue to track the possibility of documenting the defined "future-proof" JS-interop outlined here: dart-lang/site-www#4450

@eernstg
Copy link
Member

eernstg commented Dec 16, 2022

Inline classes will be in this list, but they don't exist yet. :)

They can exist now: https://github.com/dart-lang/language/blob/master/accepted/future-releases/inline-classes/feature-specification.md.

@srujzs
Copy link
Contributor

srujzs commented Dec 16, 2022

RE package:js – are we going to publish 0.6.6 along with Dart 2.19?

Yeah, I think we should. Mocking is useful - I'll plan on publishing today.

Re: documentation - In the tracking issue, we originally thought of having a polished syntax for @staticInterop for Dart 3, but it's looking very likely we can get interop with inline classes out instead, making that unneeded.

As for whether it's worth documenting future-proof interop, I think it's worth it, with a disclaimer that this is really meant for people eagerly interested in making dart2wasm work, and we'll codify better syntax in Dart 3.

@srujzs
Copy link
Contributor

srujzs commented Jul 13, 2023

I think this is resolved. There is some other stuff that was proposed for this but we haven't done, and we might not do for the context of this bug. @kevmoo , any objections?

@sigmundch
Copy link
Member

sgtm, I was about to ask too. Based on @itsjustkevin proposal this week for improving our tracking, seems like we could move any remaining work to individual tasks in our project page, and potentially use a different issue for all future discussions of the feature. Do we have the canonical bug for that yet?

@srujzs
Copy link
Contributor

srujzs commented Jul 13, 2023

We have the project here: https://github.com/orgs/dart-lang/projects/65, but I don't think we have a bug to keep track of all future discussions on next-gen interop. I think you had one that labeled work for Dart 3 (before we decided to add JS types), but I can't seem to find it. We could repurpose/update that.

@itsjustkevin
Copy link
Contributor

sgtm, I was about to ask too. Based on @itsjustkevin proposal this week for improving our tracking, seems like we could move any remaining work to individual tasks in our project page, and potentially use a different issue for all future discussions of the feature. Do we have the canonical bug for that yet?

I created #52684 last month based on some prior conversation we had. Could this be used as the discussion issue?

@ditman
Copy link
Member

ditman commented Jul 13, 2023

This doc page was very handy responding to a customer, and I had no idea it existed. 🙏

@sigmundch
Copy link
Member

... I created #52684 last month based on some prior conversation we had. Could this be used as the discussion issue?

I fear that issue may be more for inline classes and not necessarily the right place for interop related discussions.

Searching for previous issues we have used for this purpose, I came across this other issue:
#49353

Seems like potentially a good candidate (and looks like we'll want to transfer all of the subissues to our project too)

@sigmundch
Copy link
Member

I'm going to go ahead and close this issue in favor of #49353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-js P1 A high priority bug; for example, a single project is unusable or has many test failures web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

7 participants