-
Notifications
You must be signed in to change notification settings - Fork 700
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
Comments
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 |
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 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. |
@srujzs just curious, any update on the expected syntax? |
It'll be based on inline classes in conjunction with |
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);
} |
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;
} |
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]>
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. |
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]>
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
viewsinline classes in the future, more content will need to be added:Views come out: Polished@staticInterop
syntax changes released in a core libraryAdd docs to /libraries/library-tourviewsinline classes ready: Cleaner language-feature syntax of the same featureThe greater documentation on views will include information on interop with
viewsinline classesReferences
The text was updated successfully, but these errors were encountered: