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

[Eval] Update to @staticInterop docs #4331

Closed
Tracked by #49353
MaryaBelanger opened this issue Oct 31, 2022 · 7 comments · Fixed by #4578
Closed
Tracked by #49353

[Eval] Update to @staticInterop docs #4331

MaryaBelanger opened this issue Oct 31, 2022 · 7 comments · Fixed by #4578
Labels
dev.interop Relates to use of native code as part of your Dart app e1-hours Can complete in < 8 hours of normal, not dedicated, work e2-days Can complete in < 5 days of normal, not dedicated, work from.team Reported by Dash docs team member meta.evaluation Need to consider what changes if any are needed p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.blocked Issue cannot continue until another action completes st.triage.ltw Indicates Lead Tech Writer has triaged target.web Target apps on the web platform

Comments

@MaryaBelanger
Copy link
Contributor

MaryaBelanger commented Oct 31, 2022

This is an evaluation issue

Evaluating the possible need for doc updates due to dart-lang/sdk#49350 , dart-lang/sdk#48730 in particular

Summary

Limitations to @staticInterop package:js classes to simplify future implementation and support of JSinterop.

Evaluation

Because @staticInterop is fairly new, there is no documentation to update in dart.dev for the 2.19 release.
With the introduction of views inline classes in the future, more content will need to be added:

  1. Views come out: Polished @staticInterop syntax changes released in a core library
  • Add docs to /libraries/library-tour
  1. Full interop with views inline classes ready: Cleaner language-feature syntax of the same feature
  • Completely shift docs to updated syntax, remove syntax added in 1

The greater documentation on views will include information on interop with views inline classes

References

@MaryaBelanger MaryaBelanger added this to the Next dev release milestone Oct 31, 2022
@parlough parlough added p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. e1-hours Can complete in < 8 hours of normal, not dedicated, work e2-days Can complete in < 5 days of normal, not dedicated, work target.web Target apps on the web platform labels Oct 31, 2022
@parlough parlough modified the milestones: Next dev release, Future Oct 31, 2022
@parlough
Copy link
Member

parlough commented Nov 5, 2022

It will be exciting to have some documentation of this new functionality once views are released. Is there an example of the expected syntax with views or what will be in a core library?

Without the complete context, it doesn't currently sound like a perfect fit for the library tour (outside of maybe a small mention if something is added to a core dart: library). I wonder if it would be better in its own page, such as JavaScript Interoperability which is currently lacking.

@srujzs
Copy link
Contributor

srujzs commented Dec 16, 2022

Sorry Parker, I missed your comment. I agree that the JS interop page on dart.dev is the best place for it to exist. I'd like for that page to be the goto for interop. Ideally, I'd like for it to mention what not to use as well (like dart:js and other attempts at interop).

I don't think we're going to release a polished syntax (1), since we expect to have interop with views (now called inline classes) ready by Dart 3. So, we're going to lean into (2) directly here.

An example syntax was kind of up in the air until recently because the specification for inline classes changed up a bit. :) I can come back with one once we have a prototype we can start working with.

@mnordine
Copy link

@srujzs just curious, any update on the expected syntax?

@srujzs
Copy link
Contributor

srujzs commented Jan 13, 2023

It'll be based on inline classes in conjunction with external members for Dart 3. If you're curious about inline classes, the finalized spec with syntax is here: https://github.com/dart-lang/language/blob/master/accepted/future-releases/inline-classes/feature-specification.md

@mnordine
Copy link

Sorry, I know about inline classes, I should have asked for a specific example. What would it look like in this webgpu example?

inline class Gpu {
  /// ??????
}

void main() {
  final gpu = Gpu();
  final adapter = await gpu.requestAdapter();
  if (adapter == null) {
    print('no adapter');
    return;
  }

  final device = await adapter.requestDevice();
  print(device.capabilities);
}

@srujzs
Copy link
Contributor

srujzs commented Jan 13, 2023

Ah, I see, the syntax would be very similar to what we have today except with inline classes. I'm working on lowerings to adapt them, so the final accepted syntax might be slightly different (specifically around constructors), but here's what I'm imagining:

@JS() // We still need an annotation to signal that this is a JS interop inline class vs other inline classes and for renaming
inline class Gpu {
  final JSObject _gpu;
  external factory Gpu(); // Like before, assumes there's a `globalThis.Gpu` constructor.

  @JS('requestAdapter')
  external Promise _requestAdapter();
  Future<Adapter?> requestAdapter => js_util.promiseToFuture(_requestAdapter());
}

@JS()
inline class Promise {
  final JSObject _promise;
  Promise(this._promise);
}

@JS()
inline class Adapter {
  final JSObject _adapter;
  Adapter(this._adapter);
  
  @JS('requestDevice')
  external Promise _requestDevice();
  Future<Device?> _requestDevice => js_util.promiseToFuture(_requestDevice());
}

@JS()
inline class Device {
  final JSObject _device;
  Device(this._device);

  external Object get capabilities;
}

@MaryaBelanger MaryaBelanger linked a pull request Feb 6, 2023 that will close this issue
@atsansone atsansone added this to the Next Major Release milestone Apr 4, 2023
@atsansone atsansone added the meta.evaluation Need to consider what changes if any are needed label Apr 29, 2023
@atsansone atsansone changed the title @staticInterop docs [Eval] Update to @staticInterop docs Apr 29, 2023
@atsansone atsansone added st.triage.ltw Indicates Lead Tech Writer has triaged dev.interop Relates to use of native code as part of your Dart app labels Apr 29, 2023
@atsansone atsansone added the from.team Reported by Dash docs team member label Aug 8, 2023
@atsansone atsansone added st.blocked Issue cannot continue until another action completes and removed on-hold labels Oct 18, 2023
parlough added a commit that referenced this issue Dec 21, 2023
These tutorials are heavily built around multi-file DartPad support
which is going away and web programming will be changing greatly with
`package:web` and static interop in the future. Due to the low views
these pages get, this PR proposes removing them for now rather than
restructuring them for their short remaining time to live. Reducing our
maintenance costs and unblocking the DartPad work.

Contributes to #5382 and
#4331

We can always revive these pages from Git history if needed or desired
:)

---------

Co-authored-by: Marya <[email protected]>
@parlough
Copy link
Member

Thanks all! I'm closing in favor of the new static interop and package-web umbrella issue as initial evaluation of the necessity of these docs has been completed.

#5438

atsansone pushed a commit to atsansone/site-www that referenced this issue Jan 26, 2024
These tutorials are heavily built around multi-file DartPad support
which is going away and web programming will be changing greatly with
`package:web` and static interop in the future. Due to the low views
these pages get, this PR proposes removing them for now rather than
restructuring them for their short remaining time to live. Reducing our
maintenance costs and unblocking the DartPad work.

Contributes to dart-lang#5382 and
dart-lang#4331

We can always revive these pages from Git history if needed or desired
:)

---------

Co-authored-by: Marya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev.interop Relates to use of native code as part of your Dart app e1-hours Can complete in < 8 hours of normal, not dedicated, work e2-days Can complete in < 5 days of normal, not dedicated, work from.team Reported by Dash docs team member meta.evaluation Need to consider what changes if any are needed p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.blocked Issue cannot continue until another action completes st.triage.ltw Indicates Lead Tech Writer has triaged target.web Target apps on the web platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants