Unverified Commit e1645b15 authored by Kevin Moore's avatar Kevin Moore Committed by GitHub

[web] Move JS interop to extension types (#143274)

Now that we can bump the min SDK to latest.
parent 52f923c3
...@@ -33,11 +33,7 @@ external Document get document; ...@@ -33,11 +33,7 @@ external Document get document;
@JS() @JS()
external Window get window; external Window get window;
@JS('CSSStyleDeclaration') extension type CSSStyleDeclaration._(JSObject _) implements JSObject {
@staticInterop
class CSSStyleDeclaration {}
extension CSSStyleDeclarationExtension on CSSStyleDeclaration {
external set backgroundColor(String value); external set backgroundColor(String value);
external String get backgroundColor; external String get backgroundColor;
external set border(String value); external set border(String value);
...@@ -48,22 +44,14 @@ extension CSSStyleDeclarationExtension on CSSStyleDeclaration { ...@@ -48,22 +44,14 @@ extension CSSStyleDeclarationExtension on CSSStyleDeclaration {
external String get width; external String get width;
} }
@JS('CSSStyleSheet') extension type CSSStyleSheet._(JSObject _) implements JSObject {
@staticInterop
class CSSStyleSheet {}
extension CSSStyleSheetExtension on CSSStyleSheet {
external int insertRule( external int insertRule(
String rule, [ String rule, [
int index, int index,
]); ]);
} }
@JS('Document') extension type Document._(JSObject _) implements JSObject {
@staticInterop
class Document implements Node {}
extension DocumentExtension on Document {
external Element createElement( external Element createElement(
String localName, [ String localName, [
JSAny options, JSAny options,
...@@ -72,32 +60,18 @@ extension DocumentExtension on Document { ...@@ -72,32 +60,18 @@ extension DocumentExtension on Document {
external HTMLHeadElement? get head; external HTMLHeadElement? get head;
} }
@JS('DOMTokenList') extension type DOMTokenList._(JSObject _) implements JSObject {
@staticInterop
class DOMTokenList {}
extension DOMTokenListExtension on DOMTokenList {
external void add(String tokens); external void add(String tokens);
} }
@JS('Element') extension type Element._(JSObject _) implements Node, JSObject {
@staticInterop
class Element implements Node {}
extension ElementExtension on Element {
external DOMTokenList get classList; external DOMTokenList get classList;
external void append(JSAny nodes); external void append(JSAny nodes);
} }
@JS('Event') extension type Event._(JSObject _) implements JSObject {}
@staticInterop
class Event {}
@JS('EventTarget')
@staticInterop
class EventTarget {}
extension EventTargetExtension on EventTarget { extension type EventTarget._(JSObject _) implements JSObject {
external void addEventListener( external void addEventListener(
String type, String type,
EventListener? callback, [ EventListener? callback, [
...@@ -105,91 +79,52 @@ extension EventTargetExtension on EventTarget { ...@@ -105,91 +79,52 @@ extension EventTargetExtension on EventTarget {
]); ]);
} }
@JS('HTMLElement') extension type HTMLElement._(JSObject _) implements Element, JSObject {
@staticInterop external String get innerText;
class HTMLElement implements Element {}
extension HTMLElementExtension on HTMLElement {
external set innerText(String value); external set innerText(String value);
external CSSStyleDeclaration get style; external CSSStyleDeclaration get style;
} }
@JS('HTMLHeadElement') extension type HTMLHeadElement._(JSObject _) implements HTMLElement, JSObject {}
@staticInterop
class HTMLHeadElement implements HTMLElement {}
@JS('HTMLStyleElement')
@staticInterop
class HTMLStyleElement implements HTMLElement {}
extension HTMLStyleElementExtension on HTMLStyleElement { extension type HTMLStyleElement._(JSObject _) implements HTMLElement, JSObject {
external CSSStyleSheet? get sheet; external CSSStyleSheet? get sheet;
} }
@JS('MediaQueryList') extension type MediaQueryList._(JSObject _) implements EventTarget, JSObject {
@staticInterop
class MediaQueryList {}
extension MediaQueryListExtension on MediaQueryList {
external bool get matches; external bool get matches;
} }
@JS('MouseEvent') extension type MouseEvent._(JSObject _) implements JSObject {
@staticInterop
class MouseEvent {}
extension MouseEventExtension on MouseEvent {
external num get offsetX; external num get offsetX;
external num get offsetY; external num get offsetY;
external int get button; external int get button;
} }
@JS('Navigator') extension type Navigator._(JSObject _) implements JSObject {
@staticInterop
class Navigator {}
extension NavigatorExtension on Navigator {
external String get platform; external String get platform;
} }
@JS('Node') extension type Node._(JSObject _) implements EventTarget, JSObject {}
@staticInterop
class Node implements EventTarget {}
@JS('Range')
@staticInterop
class Range {}
extension RangeExtension on Range { extension type Range._(JSObject _) implements JSObject {
external void selectNode(Node node); external void selectNode(Node node);
} }
@JS('Selection') extension type Selection._(JSObject _) implements JSObject {
@staticInterop
class Selection {}
extension SelectionExtension on Selection {
external void addRange(Range range); external void addRange(Range range);
external void removeAllRanges(); external void removeAllRanges();
} }
@JS('Window') extension type Window._(JSObject _) implements EventTarget, JSObject {
@staticInterop
class Window {}
extension WindowExtension on Window {
external Navigator get navigator; external Navigator get navigator;
external MediaQueryList matchMedia(String query); external MediaQueryList matchMedia(String query);
external Selection? getSelection(); external Selection? getSelection();
} }
@JS('XMLHttpRequest') extension type XMLHttpRequest._(JSObject _)
@staticInterop implements XMLHttpRequestEventTarget, JSObject {
class XMLHttpRequest implements XMLHttpRequestEventTarget {
external factory XMLHttpRequest(); external factory XMLHttpRequest();
}
extension XMLHttpRequestExtension on XMLHttpRequest {
external void open( external void open(
String method, String method,
String url, [ String url, [
...@@ -208,6 +143,5 @@ extension XMLHttpRequestExtension on XMLHttpRequest { ...@@ -208,6 +143,5 @@ extension XMLHttpRequestExtension on XMLHttpRequest {
external JSAny? get response; external JSAny? get response;
} }
@JS('XMLHttpRequestEventTarget') extension type XMLHttpRequestEventTarget._(JSObject _)
@staticInterop implements EventTarget, JSObject {}
class XMLHttpRequestEventTarget implements EventTarget {}
...@@ -3,7 +3,7 @@ description: A framework for writing Flutter applications ...@@ -3,7 +3,7 @@ description: A framework for writing Flutter applications
homepage: https://flutter.dev homepage: https://flutter.dev
environment: environment:
sdk: '>=3.2.0-0 <4.0.0' sdk: '>=3.3.0-0 <4.0.0'
dependencies: dependencies:
# To update these, use "flutter update-packages --force-upgrade". # To update these, use "flutter update-packages --force-upgrade".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment