diff --git a/packages/firebase_database/firebase_database_web/lib/src/interop/data_snapshot_interop.dart b/packages/firebase_database/firebase_database_web/lib/src/interop/data_snapshot_interop.dart index b36970b0477a..6dbe63f22766 100644 --- a/packages/firebase_database/firebase_database_web/lib/src/interop/data_snapshot_interop.dart +++ b/packages/firebase_database/firebase_database_web/lib/src/interop/data_snapshot_interop.dart @@ -4,12 +4,7 @@ part of 'database_interop.dart'; -@JS('DataSnapshot') -@staticInterop -@anonymous -abstract class DataSnapshotJsImpl {} - -extension DataSnapshotJsImpl$ on DataSnapshotJsImpl { +extension type DataSnapshotJsImpl._(JSObject _) implements JSObject { external JSString? get key; external JSAny? /* JSString | num | null*/ get priority; diff --git a/packages/firebase_database/firebase_database_web/lib/src/interop/database.dart b/packages/firebase_database/firebase_database_web/lib/src/interop/database.dart index f616f00b1852..dd83d80f2314 100755 --- a/packages/firebase_database/firebase_database_web/lib/src/interop/database.dart +++ b/packages/firebase_database/firebase_database_web/lib/src/interop/database.dart @@ -78,8 +78,7 @@ class Database /// can be used for reading or writing data to that database location. /// /// See: . -class DatabaseReference - extends Query { +class DatabaseReference extends Query { static final _expando = Expando(); /// The last part of the current path. @@ -204,11 +203,9 @@ class DatabaseReference applyLocally: applyLocally.toJS), ) .toDart; - final castedJsTransaction = - jsTransactionResult as database_interop.TransactionResultJsImpl; return Transaction( - committed: (castedJsTransaction.committed).toDart, - snapshot: DataSnapshot._fromJsObject(castedJsTransaction.snapshot), + committed: (jsTransactionResult.committed).toDart, + snapshot: DataSnapshot._fromJsObject(jsTransactionResult.snapshot), ); } catch (e, s) { throw convertFirebaseDatabaseException(e, s); @@ -317,8 +314,7 @@ class Query extends JsObjectWrapper { final jsSnapshotPromise = database_interop.get(jsObject); final snapshot = await jsSnapshotPromise.toDart; - return DataSnapshot.getInstance( - snapshot as database_interop.DataSnapshotJsImpl); + return DataSnapshot.getInstance(snapshot); } /// Returns a Query with the ending point [value]. The ending point @@ -674,18 +670,18 @@ class OnDisconnect /// [Future] property. /// /// See: . -class ThenableReference - extends DatabaseReference { - late final Future _future = jsObject - .then(((database_interop.ReferenceJsImpl reference) { - DatabaseReference.getInstance(reference); - }).toJS) - .toDart - .then((value) => value as DatabaseReference); +class ThenableReference extends DatabaseReference { + late final Future _future = + (jsObject as database_interop.ThenableReferenceJsImpl) + .then(((database_interop.ReferenceJsImpl reference) { + DatabaseReference.getInstance(reference); + }).toJS) + .toDart + .then((value) => value as DatabaseReference); /// Creates a new ThenableReference from a [jsObject]. ThenableReference.fromJsObject( - super.jsObject, + database_interop.ThenableReferenceJsImpl super.jsObject, ) : super._fromJsObject(); /// A Future property. diff --git a/packages/firebase_database/firebase_database_web/lib/src/interop/database_interop.dart b/packages/firebase_database/firebase_database_web/lib/src/interop/database_interop.dart index 2a3bcec22451..af438b5d52d2 100755 --- a/packages/firebase_database/firebase_database_web/lib/src/interop/database_interop.dart +++ b/packages/firebase_database/firebase_database_web/lib/src/interop/database_interop.dart @@ -50,7 +50,7 @@ external void forceWebSockets(); @JS() @staticInterop -external JSPromise /*DataSnapshotJsImpl*/ get(QueryJsImpl query); +external JSPromise get(QueryJsImpl query); @JS() @staticInterop @@ -164,13 +164,13 @@ external ReferenceJsImpl refFromURL( @JS() @staticInterop -external JSPromise remove( +external JSPromise remove( ReferenceJsImpl ref, ); @JS() @staticInterop -external JSPromise/**/ runTransaction( +external JSPromise runTransaction( ReferenceJsImpl ref, JSFunction transactionUpdate, // Function(JSAny currentData) transactionUpdate, @@ -220,29 +220,17 @@ abstract class ServerValue { external static JSAny get TIMESTAMP; } -@JS('Database') -@staticInterop -abstract class DatabaseJsImpl {} - -extension DatabaseJsImplExtension on DatabaseJsImpl { +extension type DatabaseJsImpl._(JSObject _) implements JSObject { external AppJsImpl get app; external set app(AppJsImpl a); external JSString get type; } -@JS('QueryConstraint') -@staticInterop -abstract class QueryConstraintJsImpl {} - -extension QueryConstraintJsImplExtension on QueryConstraintJsImpl { +extension type QueryConstraintJsImpl._(JSObject _) implements JSObject { external JSString get type; } -@JS('OnDisconnect') -@staticInterop -abstract class OnDisconnectJsImpl {} - -extension OnDisconnectJsImplExtension on OnDisconnectJsImpl { +extension type OnDisconnectJsImpl._(JSObject _) implements JSObject { external JSPromise cancel([ JSFunction onComplete, //void Function(JSAny) onComplete @@ -269,11 +257,8 @@ extension OnDisconnectJsImplExtension on OnDisconnectJsImpl { ); } -@JS('ThenableReference') -@staticInterop -abstract class ThenableReferenceJsImpl extends ReferenceJsImpl {} - -extension ThenableReferenceJsImplExtension on ThenableReferenceJsImpl { +extension type ThenableReferenceJsImpl._(JSObject _) + implements JSObject, ReferenceJsImpl { external JSPromise then([JSFunction? onResolve, JSFunction? onReject]); } @@ -302,12 +287,7 @@ abstract class ListenOptions { external static JSBoolean get onlyOnce; } -@JS() -@staticInterop -@anonymous -abstract class FirebaseError {} - -extension FirebaseErrorExtension on FirebaseError { +extension type FirebaseError._(JSObject _) implements JSObject { external JSString get code; external JSString get message; external JSString get name; diff --git a/packages/firebase_database/firebase_database_web/lib/src/interop/query_interop.dart b/packages/firebase_database/firebase_database_web/lib/src/interop/query_interop.dart index c88f4bfe14c9..e38735898f0b 100644 --- a/packages/firebase_database/firebase_database_web/lib/src/interop/query_interop.dart +++ b/packages/firebase_database/firebase_database_web/lib/src/interop/query_interop.dart @@ -4,11 +4,7 @@ part of 'database_interop.dart'; -@JS('Query') -@staticInterop -abstract class QueryJsImpl {} - -extension ExtensionQueryJsImpl on QueryJsImpl { +extension type QueryJsImpl._(JSObject _) implements JSObject { external ReferenceJsImpl get ref; external JSBoolean isEqual(QueryJsImpl other); diff --git a/packages/firebase_database/firebase_database_web/lib/src/interop/reference_interop.dart b/packages/firebase_database/firebase_database_web/lib/src/interop/reference_interop.dart index fa4adeadf0ec..c8998784e14f 100644 --- a/packages/firebase_database/firebase_database_web/lib/src/interop/reference_interop.dart +++ b/packages/firebase_database/firebase_database_web/lib/src/interop/reference_interop.dart @@ -4,21 +4,13 @@ part of 'database_interop.dart'; -@JS('TransactionResult') -@staticInterop -abstract class TransactionResultJsImpl {} - -extension TransactionResultJsImplExtension on TransactionResultJsImpl { +extension type TransactionResultJsImpl._(JSObject _) implements JSObject { external JSObject toJSON(); external JSBoolean get committed; external DataSnapshotJsImpl get snapshot; } -@JS('DatabaseReference') -@staticInterop -abstract class ReferenceJsImpl extends QueryJsImpl {} - -extension ReferenceJsImplExtension on ReferenceJsImpl { +extension type ReferenceJsImpl._(JSObject _) implements JSObject, QueryJsImpl { external JSString? get key; external ReferenceJsImpl? get parent;