Reland manual roll of Dart SDK from 82c4571bb2de to a677378ae254 (flutter/engine#49034)

Includes type annotations for JSArray/JSPromise
(see https://dart-review.googlesource.com/c/sdk/+/337923)
This commit is contained in:
Jason Simmons 2023-12-14 12:01:01 -08:00 committed by GitHub
parent d5968a10c0
commit 9538c024ca
11 changed files with 56 additions and 55 deletions

2
DEPS
View File

@ -66,7 +66,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': '82c4571bb2ded15cca71862158f2a7a78ee9127f',
'dart_revision': 'a677378ae25424f8e74b2f750e879458e9a17488',
# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py

View File

@ -1,4 +1,4 @@
Signature: fa0827b53a214003c14110498dcee743
Signature: 9566e23501be49ccdb4d0e710a9b74e7
====================================================================================================
LIBRARY: dart

View File

@ -2942,7 +2942,7 @@ extension SkTextStylePropertiesExtension on SkTextStyleProperties {
external set fontStyle(SkFontStyle? value);
@JS('shadows')
external set _shadows(JSArray? value);
external set _shadows(JSArray<JSAny?>? value);
set shadows(List<SkTextShadow>? value) =>
// TODO(joshualitt): remove this cast when we reify JS types on JS
// backends.
@ -2950,7 +2950,7 @@ extension SkTextStylePropertiesExtension on SkTextStyleProperties {
_shadows = (value as List<JSAny>?)?.toJS;
@JS('fontFeatures')
external set _fontFeatures(JSArray? value);
external set _fontFeatures(JSArray<JSAny?>? value);
set fontFeatures(List<SkFontFeature>? value) =>
// TODO(joshualitt): remove this cast when we reify JS types on JS
// backends.
@ -2958,7 +2958,7 @@ extension SkTextStylePropertiesExtension on SkTextStyleProperties {
_fontFeatures = (value as List<JSAny>?)?.toJS;
@JS('fontVariations')
external set _fontVariations(JSArray? value);
external set _fontVariations(JSArray<JSAny?>? value);
set fontVariations(List<SkFontVariation>? value) =>
// TODO(joshualitt): remove this cast when we reify JS types on JS
// backends.
@ -3200,7 +3200,7 @@ class SkGlyphClusterInfo {}
extension SkGlyphClusterInfoExtension on SkGlyphClusterInfo {
@JS('graphemeLayoutBounds')
external JSArray get _bounds;
external JSArray<JSAny?> get _bounds;
@JS('dir')
external SkTextDirection get _direction;
@ -3256,7 +3256,7 @@ extension SkParagraphExtension on SkParagraph {
double getIdeographicBaseline() => _getIdeographicBaseline().toDartDouble;
@JS('getLineMetrics')
external JSArray _getLineMetrics();
external JSArray<JSAny?> _getLineMetrics();
List<SkLineMetrics> getLineMetrics() =>
_getLineMetrics().toDart.cast<SkLineMetrics>();
@ -3289,7 +3289,7 @@ extension SkParagraphExtension on SkParagraph {
double getMaxWidth() => _getMaxWidth().toDartDouble;
@JS('getRectsForRange')
external JSArray _getRectsForRange(
external JSArray<JSAny?> _getRectsForRange(
JSNumber start,
JSNumber end,
SkRectHeightStyle heightStyle,
@ -3304,7 +3304,7 @@ extension SkParagraphExtension on SkParagraph {
widthStyle).toDart.cast<SkRectWithDirection>();
@JS('getRectsForPlaceholders')
external JSArray _getRectsForPlaceholders();
external JSArray<JSAny?> _getRectsForPlaceholders();
List<SkRectWithDirection> getRectsForPlaceholders() =>
_getRectsForPlaceholders().toDart.cast<SkRectWithDirection>();

View File

@ -142,7 +142,7 @@ Future<ByteBuffer> readVideoFramePixelsUnmodified(VideoFrame videoFrame) async {
// In dart2wasm, Uint8List is not the same as a JS Uint8Array. So we
// explicitly construct the JS object here.
final JSUint8Array destination = createUint8ArrayFromLength(size);
final JSPromise copyPromise = videoFrame.copyTo(destination);
final JSPromise<JSAny?> copyPromise = videoFrame.copyTo(destination);
await promiseToFuture<void>(copyPromise);
// In dart2wasm, `toDart` incurs a copy here. On JS backends, this is a

View File

@ -110,9 +110,9 @@ extension DomWindowExtension on DomWindow {
}
@JS('fetch')
external JSPromise _fetch1(JSString url);
external JSPromise<JSAny?> _fetch1(JSString url);
@JS('fetch')
external JSPromise _fetch2(JSString url, JSAny headers);
external JSPromise<JSAny?> _fetch2(JSString url, JSAny headers);
// ignore: non_constant_identifier_names
external DomURL get URL;
@ -149,7 +149,7 @@ extension DomWindowExtension on DomWindow {
external JSVoid _postMessage1(JSAny message, JSString targetOrigin);
@JS('postMessage')
external JSVoid _postMessage2(
JSAny message, JSString targetOrigin, JSArray messagePorts);
JSAny message, JSString targetOrigin, JSArray<JSAny?> messagePorts);
void postMessage(Object message, String targetOrigin,
[List<DomMessagePort>? messagePorts]) {
if (messagePorts == null) {
@ -199,18 +199,18 @@ external DomIntl get domIntl;
external DomSymbol get domSymbol;
@JS('createImageBitmap')
external JSPromise _createImageBitmap1(
external JSPromise<JSAny?> _createImageBitmap1(
JSAny source,
);
@JS('createImageBitmap')
external JSPromise _createImageBitmap2(
external JSPromise<JSAny?> _createImageBitmap2(
JSAny source,
JSNumber x,
JSNumber y,
JSNumber width,
JSNumber height,
);
JSPromise createImageBitmap(JSAny source,
JSPromise<JSAny?> createImageBitmap(JSAny source,
[({int x, int y, int width, int height})? bounds]) {
if (bounds != null) {
return _createImageBitmap2(source, bounds.x.toJS, bounds.y.toJS,
@ -248,7 +248,7 @@ extension DomNavigatorExtension on DomNavigator {
String get userAgent => _userAgent.toDart;
@JS('languages')
external JSArray? get _languages;
external JSArray<JSAny?>? get _languages;
List<String>? get languages => _languages?.toDart
.map<String>((JSAny? any) => (any! as JSString).toDart)
.toList();
@ -947,7 +947,7 @@ extension DomHTMLImageElementExtension on DomHTMLImageElement {
set height(double? value) => _height = value?.toJS;
@JS('decode')
external JSPromise _decode();
external JSPromise<JSAny?> _decode();
Future<Object?> decode() => js_util.promiseToFuture<Object?>(_decode());
}
@ -1886,16 +1886,16 @@ extension DomResponseExtension on DomResponse {
external _DomReadableStream get body;
@JS('arrayBuffer')
external JSPromise _arrayBuffer();
external JSPromise<JSAny?> _arrayBuffer();
Future<Object?> arrayBuffer() =>
js_util.promiseToFuture<Object?>(_arrayBuffer());
@JS('json')
external JSPromise _json();
external JSPromise<JSAny?> _json();
Future<Object?> json() => js_util.promiseToFuture<Object?>(_json());
@JS('text')
external JSPromise _text();
external JSPromise<JSAny?> _text();
Future<String> text() => js_util.promiseToFuture<String>(_text());
}
@ -1923,7 +1923,7 @@ class _DomStreamReader {}
extension _DomStreamReaderExtension on _DomStreamReader {
@JS('read')
external JSPromise _read();
external JSPromise<JSAny?> _read();
Future<_DomStreamChunk> read() =>
js_util.promiseToFuture<_DomStreamChunk>(_read());
}
@ -2045,7 +2045,7 @@ DomFontFace createDomFontFace(String family, Object source,
extension DomFontFaceExtension on DomFontFace {
@JS('load')
external JSPromise _load();
external JSPromise<JSAny?> _load();
Future<DomFontFace> load() => js_util.promiseToFuture(_load());
@JS('family')
@ -2166,11 +2166,11 @@ class DomClipboard extends DomEventTarget {}
extension DomClipboardExtension on DomClipboard {
@JS('readText')
external JSPromise _readText();
external JSPromise<JSAny?> _readText();
Future<String> readText() => js_util.promiseToFuture<String>(_readText());
@JS('writeText')
external JSPromise _writeText(JSString data);
external JSPromise<JSAny?> _writeText(JSString data);
Future<dynamic> writeText(String data) =>
js_util.promiseToFuture(_writeText(data.toJS));
}
@ -2340,26 +2340,26 @@ extension DomURLExtension on DomURL {
@JS('Blob')
@staticInterop
class DomBlob {
external factory DomBlob(JSArray parts);
external factory DomBlob(JSArray<JSAny?> parts);
external factory DomBlob.withOptions(JSArray parts, JSAny options);
external factory DomBlob.withOptions(JSArray<JSAny?> parts, JSAny options);
}
extension DomBlobExtension on DomBlob {
external JSPromise arrayBuffer();
external JSPromise<JSAny?> arrayBuffer();
}
DomBlob createDomBlob(List<Object?> parts, [Map<String, dynamic>? options]) {
if (options == null) {
return DomBlob(parts.toJSAnyShallow as JSArray);
return DomBlob(parts.toJSAnyShallow as JSArray<JSAny?>);
} else {
return DomBlob.withOptions(
parts.toJSAnyShallow as JSArray, options.toJSAnyDeep);
parts.toJSAnyShallow as JSArray<JSAny?>, options.toJSAnyDeep);
}
}
typedef DomMutationCallback = void Function(
JSArray mutation, DomMutationObserver observer);
JSArray<JSAny?> mutation, DomMutationObserver observer);
@JS('MutationObserver')
@staticInterop
@ -2565,7 +2565,7 @@ extension DomPointerEventExtension on DomPointerEvent {
double? get tiltY => _tiltY?.toDartDouble;
@JS('getCoalescedEvents')
external JSArray _getCoalescedEvents();
external JSArray<JSAny?> _getCoalescedEvents();
List<DomPointerEvent> getCoalescedEvents() =>
_getCoalescedEvents().toDart.cast<DomPointerEvent>();
}
@ -2886,11 +2886,11 @@ extension DomOffscreenCanvasExtension on DomOffscreenCanvas {
}
@JS('convertToBlob')
external JSPromise _convertToBlob1();
external JSPromise<JSAny?> _convertToBlob1();
@JS('convertToBlob')
external JSPromise _convertToBlob2(JSAny options);
external JSPromise<JSAny?> _convertToBlob2(JSAny options);
Future<DomBlob> convertToBlob([Map<Object?, Object?>? options]) {
final JSPromise blob;
final JSPromise<JSAny?> blob;
if (options == null) {
blob = _convertToBlob1();
} else {
@ -3013,7 +3013,7 @@ class DomScreenOrientation extends DomEventTarget {}
extension DomScreenOrientationExtension on DomScreenOrientation {
@JS('lock')
external JSPromise _lock(JSString orientation);
external JSPromise<JSAny?> _lock(JSString orientation);
Future<dynamic> lock(String orientation) =>
js_util.promiseToFuture(_lock(orientation.toJS));
@ -3163,7 +3163,7 @@ abstract class DomResizeObserver {
/// Internally converts the `List<dynamic>` of entries into the expected
/// `List<DomResizeObserverEntry>`
DomResizeObserver? createDomResizeObserver(DomResizeObserverCallbackFn fn) =>
DomResizeObserver((JSArray entries, DomResizeObserver observer) {
DomResizeObserver((JSArray<JSAny?> entries, DomResizeObserver observer) {
fn(entries.toDart.cast<DomResizeObserverEntry>(), observer);
}.toJS);
@ -3480,7 +3480,7 @@ class DomSegmenter {
// TODO(joshualitt): `locales` should really be typed as `JSAny?`, and we
// should pass `JSUndefined`. Revisit this after we reify `JSUndefined` on
// Dart2Wasm.
external factory DomSegmenter(JSArray locales, JSAny options);
external factory DomSegmenter(JSArray<JSAny?> locales, JSAny options);
}
extension DomSegmenterExtension on DomSegmenter {
@ -3580,7 +3580,7 @@ DomSegmenter createIntlSegmenter({required String granularity}) {
@JS('Intl.v8BreakIterator')
@staticInterop
class DomV8BreakIterator {
external factory DomV8BreakIterator(JSArray locales, JSAny options);
external factory DomV8BreakIterator(JSArray<JSAny?> locales, JSAny options);
}
extension DomV8BreakIteratorExtension on DomV8BreakIterator {
@ -3679,7 +3679,7 @@ bool get browserSupportsCreateImageBitmap =>
@JS()
@staticInterop
extension JSArrayExtension on JSArray {
extension JSArrayExtension on JSArray<JSAny?> {
external void push(JSAny value);
external JSNumber get length;
}

View File

@ -18,14 +18,14 @@ extension CallExtension on JSFunction {
@JS('Promise')
external JSAny get _promiseConstructor;
JSPromise createPromise(JSFunction executor) =>
JSPromise<JSAny?> createPromise(JSFunction executor) =>
js_util.callConstructor(
_promiseConstructor,
<Object>[executor],
);
JSPromise futureToPromise<T extends JSAny?>(Future<T> future) {
JSPromise<JSAny?> futureToPromise<T extends JSAny?>(Future<T> future) {
return createPromise((JSFunction resolver, JSFunction rejecter) {
future.then(
(T value) => resolver.call(null, value),

View File

@ -986,8 +986,8 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
void _addFontSizeObserver() {
const String styleAttribute = 'style';
_fontSizeObserver =
createDomMutationObserver((JSArray mutations, DomMutationObserver _) {
_fontSizeObserver = createDomMutationObserver(
(JSArray<JSAny?> mutations, DomMutationObserver _) {
for (final JSAny? mutation in mutations.toDart) {
final DomMutationRecord record = mutation! as DomMutationRecord;
if (record.type == 'attributes' &&

View File

@ -214,7 +214,7 @@ extension ImageDecoderExtension on ImageDecoder {
external JSBoolean get _complete;
bool get complete => _complete.toDart;
external JSPromise decode(DecodeOptions options);
external JSPromise<JSAny?> decode(DecodeOptions options);
external JSVoid close();
}
@ -288,8 +288,9 @@ extension VideoFrameExtension on VideoFrame {
double allocationSize() => _allocationSize().toDartDouble;
@JS('copyTo')
external JSPromise _copyTo(JSAny destination);
JSPromise copyTo(Object destination) => _copyTo(destination.toJSAnyShallow);
external JSPromise<JSAny?> _copyTo(JSAny destination);
JSPromise<JSAny?> copyTo(Object destination) =>
_copyTo(destination.toJSAnyShallow);
@JS('format')
external JSString? get _format;
@ -330,7 +331,7 @@ extension VideoFrameExtension on VideoFrame {
class ImageTrackList {}
extension ImageTrackListExtension on ImageTrackList {
external JSPromise get ready;
external JSPromise<JSAny?> get ready;
external ImageTrack? get selectedTrack;
}

View File

@ -13,10 +13,10 @@ import '../dom.dart';
/// to clear. Delay removal of old visible state to make the
/// transition appear smooth.
@JS('window.__flutterState')
external JSArray? get _jsHotRestartStore;
external JSArray<JSAny?>? get _jsHotRestartStore;
@JS('window.__flutterState')
external set _jsHotRestartStore(JSArray? nodes);
external set _jsHotRestartStore(JSArray<JSAny?>? nodes);
/// Handles [DomElement]s that need to be removed after a hot-restart.
///
@ -36,7 +36,7 @@ class HotRestartCacheHandler {
/// Removes every element that was registered prior to the hot-restart from
/// the DOM.
void _resetHotRestartStore() {
final JSArray? jsStore = _jsHotRestartStore;
final JSArray<JSAny?>? jsStore = _jsHotRestartStore;
if (jsStore != null) {
// We are in a post hot-restart world, clear the elements now.
@ -47,7 +47,7 @@ class HotRestartCacheHandler {
}
}
}
_jsHotRestartStore = JSArray();
_jsHotRestartStore = JSArray<JSAny?>();
}
/// Registers a [DomElement] to be removed after hot-restart.

View File

@ -487,7 +487,7 @@ void testMain() {
// Watches DOM mutations and counts deletions and additions to the child
// list of the `<flt-scene>` element.
final DomMutationObserver observer = createDomMutationObserver((JSArray mutations, _) {
final DomMutationObserver observer = createDomMutationObserver((JSArray<JSAny?> mutations, _) {
for (final DomMutationRecord record in mutations.toDart.cast<DomMutationRecord>()) {
actualDeletions.addAll(record.removedNodes!);
actualAdditions.addAll(record.addedNodes!);

View File

@ -13,10 +13,10 @@ import 'package:ui/src/engine/dom.dart';
import 'package:ui/src/engine/view_embedder/hot_restart_cache_handler.dart';
@JS('window.__flutterState')
external JSArray? get _jsHotRestartStore;
external JSArray<JSAny?>? get _jsHotRestartStore;
@JS('window.__flutterState')
external set _jsHotRestartStore(JSArray? nodes);
external set _jsHotRestartStore(JSArray<JSAny?>? nodes);
void main() {
internalBootstrapBrowserTest(() => doTests);