Skip to content

Commit d63c034

Browse files
authored
refactor(functions, web): convert classes to extension types for improved interop (#17825)
1 parent 16037fb commit d63c034

File tree

1 file changed

+9
-41
lines changed

1 file changed

+9
-41
lines changed

packages/cloud_functions/cloud_functions_web/lib/interop/functions_interop.dart

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ external JSFunction httpsCallableFromURL(
3939
///
4040
/// Do not call this constructor directly. Instead, use firebase.functions().
4141
/// See: <https://firebase.google.com/docs/reference/js/firebase.functions.Functions>.
42-
@JS('Functions')
43-
@staticInterop
44-
abstract class FunctionsJsImpl {}
45-
46-
extension FunctionsJsImplExtension on FunctionsJsImpl {
42+
extension type FunctionsJsImpl._(JSObject _) implements JSObject {
4743
external AppJsImpl get app;
4844
external JSString? get customDomain;
4945
external JSString get region;
@@ -52,15 +48,9 @@ extension FunctionsJsImplExtension on FunctionsJsImpl {
5248
/// An HttpsCallableOptions is an option to set timeout property
5349
///
5450
/// See: <https://firebase.google.com/docs/reference/js/firebase.functions.HttpsCallableOptions>.
55-
@JS('HttpsCallableOptions')
56-
@staticInterop
57-
@anonymous
58-
abstract class HttpsCallableOptions {
51+
extension type HttpsCallableOptions._(JSObject _) implements JSObject {
5952
external factory HttpsCallableOptions(
6053
{JSNumber? timeout, JSBoolean? limitedUseAppCheckTokens});
61-
}
62-
63-
extension HttpsCallableOptionsExtension on HttpsCallableOptions {
6454
external JSNumber? get timeout;
6555
external set timeout(JSNumber? t);
6656
external JSBoolean? get limitedUseAppCheckTokens;
@@ -70,45 +60,27 @@ extension HttpsCallableOptionsExtension on HttpsCallableOptions {
7060
/// An HttpsCallableResult wraps a single result from a function call.
7161
///
7262
/// See: <https://firebase.google.com/docs/reference/js/functions.httpscallableresult>.
73-
@JS('HttpsCallableResult')
74-
@staticInterop
75-
@anonymous
76-
abstract class HttpsCallableResultJsImpl {}
77-
78-
extension HttpsCallableResultJsImplExtension on HttpsCallableResultJsImpl {
63+
extension type HttpsCallableResultJsImpl._(JSObject _) implements JSObject {
7964
external JSAny? get data;
8065
}
8166

82-
@JS('HttpsCallable')
83-
@staticInterop
84-
class HttpsCallable {}
85-
86-
extension HttpsCallableExtension on HttpsCallable {
67+
extension type HttpsCallable._(JSObject _) implements JSObject {
8768
external JSPromise stream([JSAny? data, HttpsCallableStreamOptions? options]);
8869
}
8970

90-
@JS('HttpsCallableStreamResult')
91-
@staticInterop
92-
class HttpsCallableStreamResultJsImpl {}
93-
94-
extension HttpsCallableStreamResultJsImplExtension
95-
on HttpsCallableStreamResultJsImpl {
71+
extension type HttpsCallableStreamResultJsImpl._(JSObject _)
72+
implements JSObject {
9673
external JSPromise data;
9774
external JsAsyncIterator<JSAny> stream;
9875
}
9976

100-
@JS('HttpsCallableStreamOptions')
101-
@staticInterop
102-
@anonymous
103-
abstract class HttpsCallableStreamOptions {
77+
extension type HttpsCallableStreamOptions._(JSObject _) implements JSObject {
10478
external factory HttpsCallableStreamOptions(
10579
{JSBoolean? limitedUseAppCheckTokens, web.AbortSignal? signal});
106-
}
107-
108-
extension HttpsCallableStreamOptionsExtension on HttpsCallableStreamOptions {
10980
external JSBoolean? get limitedUseAppCheckTokens;
11081
external set limitedUseAppCheckTokens(JSBoolean? t);
11182
external web.AbortSignal? signal;
83+
// ignore: avoid_setters_without_getters
11284
external set siganl(web.AbortSignal? s);
11385
}
11486

@@ -134,10 +106,6 @@ extension type JsAsyncIterator<T extends JSAny>._(JSObject _)
134106
}
135107
}
136108

137-
@JS()
138-
@staticInterop
139-
abstract class HttpsStreamIterableResult {}
140-
141-
extension HttpsStreamIterableResultExtension on HttpsStreamIterableResult {
109+
extension type HttpsStreamIterableResult._(JSObject _) implements JSObject {
142110
external JSAny? get value;
143111
}

0 commit comments

Comments
 (0)