Skip to content

Commit

Permalink
fix: Upgrade web_socket_channel for supporting web: ^1.0.0 and th…
Browse files Browse the repository at this point in the history
…erefore WASM compilation on web (#992)

* Upgrade `web_socket_channel` and linting dependency of `realtime_client`

* Migrate test in `supabase` package as well

* Allow wider version range for compatibility

* Upgrade linting for all packages in a non-breaking manner

* Update packages/supabase/lib/src/auth_user.dart

* Update packages/supabase/pubspec.yaml

* Apply suggestions from code review

* fix: minor type fix

---------

Co-authored-by: Tyler <[email protected]>
  • Loading branch information
geoextra and dshukertjr authored Jul 30, 2024
1 parent 9655652 commit 7da6856
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 67 deletions.
2 changes: 1 addition & 1 deletion packages/functions_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ dependencies:
yet_another_json_isolate: 2.0.1

dev_dependencies:
lints: ^2.1.1
lints: ^3.0.0
test: ^1.16.4
5 changes: 2 additions & 3 deletions packages/gotrue/lib/src/types/auth_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AuthException implements Exception {
}

class AuthPKCEGrantCodeExchangeError extends AuthException {
AuthPKCEGrantCodeExchangeError(String message) : super(message);
AuthPKCEGrantCodeExchangeError(super.message);
}

class AuthSessionMissingException extends AuthException {
Expand All @@ -38,8 +38,7 @@ class AuthRetryableFetchException extends AuthException {
}

class AuthApiException extends AuthException {
AuthApiException(String message, {String? statusCode})
: super(message, statusCode: statusCode);
AuthApiException(super.message, {super.statusCode});
}

class AuthUnknownException extends AuthException {
Expand Down
10 changes: 5 additions & 5 deletions packages/gotrue/lib/src/types/user_attributes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ class AdminUserAttributes extends UserAttributes {
final String? banDuration;

AdminUserAttributes({
String? email,
String? phone,
String? password,
Object? data,
super.email,
super.phone,
super.password,
super.data,
this.userMetadata,
this.appMetadata,
this.emailConfirm,
this.phoneConfirm,
this.banDuration,
}) : super(email: email, phone: phone, password: password, data: data);
});

@override
Map<String, dynamic> toJson() {
Expand Down
2 changes: 1 addition & 1 deletion packages/gotrue/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
dev_dependencies:
dart_jsonwebtoken: ^2.4.1
dotenv: ^4.1.0
lints: ^2.1.1
lints: ^3.0.0
test: ^1.16.4
otp: ^3.1.3

Expand Down
2 changes: 1 addition & 1 deletion packages/postgrest/lib/src/postgrest_filter_builder.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of 'postgrest_builder.dart';

class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder<T> {
PostgrestFilterBuilder(PostgrestBuilder<T, T, T> builder) : super(builder);
PostgrestFilterBuilder(super.builder);

@override
PostgrestFilterBuilder<T> copyWithUrl(Uri url) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/postgrest/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ dependencies:

dev_dependencies:
collection: ^1.16.0
lints: ^2.1.1
lints: ^3.0.0
test: ^1.21.4
4 changes: 2 additions & 2 deletions packages/realtime_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ dependencies:
collection: ^1.15.0
http: '>=0.13.0 <2.0.0'
meta: ^1.7.0
web_socket_channel: ^2.3.0
web_socket_channel: '>=2.3.0 <4.0.0'

dev_dependencies:
lints: ^2.1.1
lints: ^3.0.0
mocktail: ^1.0.0
test: ^1.16.5
2 changes: 1 addition & 1 deletion packages/realtime_client/test/socket_test_stubs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MockChannel extends Mock implements RealtimeChannel {}
class MockPush extends Mock implements Push {}

class SocketWithMockedChannel extends RealtimeClient {
SocketWithMockedChannel(String endPoint) : super(endPoint);
SocketWithMockedChannel(super.endPoint);

Map<String, RealtimeChannel> mockedChannelLooker = {};

Expand Down
9 changes: 3 additions & 6 deletions packages/storage_client/lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,10 @@ class SignedUploadURLResponse extends SignedUrl {
final String token;

const SignedUploadURLResponse({
required String signedUrl,
required String path,
required super.signedUrl,
required super.path,
required this.token,
}) : super(
signedUrl: signedUrl,
path: path,
);
});
}

class StorageException implements Exception {
Expand Down
2 changes: 1 addition & 1 deletion packages/storage_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ dependencies:

dev_dependencies:
test: ^1.21.4
lints: ^2.1.1
lints: ^3.0.0
path: ^1.8.2
43 changes: 14 additions & 29 deletions packages/supabase/lib/src/auth_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,18 @@ import 'package:gotrue/gotrue.dart' show User;

class AuthUser extends User {
AuthUser({
required String id,
required Map<String, dynamic> appMetadata,
required Map<String, dynamic> userMetadata,
required String aud,
required String? email,
required String? phone,
required String createdAt,
String? confirmedAt,
String? emailConfirmedAt,
String? phoneConfirmedAt,
String? lastSignInAt,
required String role,
required String updatedAt,
}) : super(
id: id,
appMetadata: appMetadata,
userMetadata: userMetadata,
aud: aud,
email: email,
phone: phone,
createdAt: createdAt,
// ignore: deprecated_member_use
confirmedAt: confirmedAt,
emailConfirmedAt: emailConfirmedAt,
phoneConfirmedAt: phoneConfirmedAt,
lastSignInAt: lastSignInAt,
role: role,
updatedAt: updatedAt,
);
required super.id,
required super.appMetadata,
required super.userMetadata,
required super.aud,
required super.email,
required super.phone,
required super.createdAt,
super.confirmedAt,
super.emailConfirmedAt,
super.phoneConfirmedAt,
super.lastSignInAt,
required super.role,
required super.updatedAt,
});
}
14 changes: 4 additions & 10 deletions packages/supabase/lib/src/supabase_query_builder.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:http/http.dart';
import 'package:supabase/supabase.dart';
import 'package:yet_another_json_isolate/yet_another_json_isolate.dart';

class SupabaseQueryBuilder extends PostgrestQueryBuilder {
final RealtimeClient _realtime;
Expand All @@ -11,22 +9,18 @@ class SupabaseQueryBuilder extends PostgrestQueryBuilder {
SupabaseQueryBuilder(
String url,
RealtimeClient realtime, {
Map<String, String> headers = const {},
required String schema,
super.headers = const {},
required String super.schema,
required String table,
Client? httpClient,
super.httpClient,
required int incrementId,
required YAJsonIsolate isolate,
required super.isolate,
}) : _realtime = realtime,
_schema = schema,
_table = table,
_incrementId = incrementId,
super(
url: Uri.parse(url),
headers: headers,
schema: schema,
httpClient: httpClient,
isolate: isolate,
);

/// Returns real-time data from your table as a `Stream`.
Expand Down
4 changes: 2 additions & 2 deletions packages/supabase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ dependencies:
yet_another_json_isolate: 2.0.1

dev_dependencies:
lints: ^2.1.1
lints: ^3.0.0
test: ^1.17.9
web_socket_channel: ^2.2.0
web_socket_channel: '>=2.2.0 <4.0.0'
2 changes: 1 addition & 1 deletion packages/supabase_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^1.0.4
flutter_lints: ^3.0.1

flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion packages/supabase_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dev_dependencies:
dart_jsonwebtoken: ^2.4.1
flutter_test:
sdk: flutter
flutter_lints: ^2.0.2
flutter_lints: ^3.0.1
path: ^1.8.3

platforms:
Expand Down
3 changes: 2 additions & 1 deletion packages/supabase_flutter/test/widget_test_stubs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:supabase_flutter/supabase_flutter.dart';
import 'utils.dart';

class MockWidget extends StatefulWidget {
const MockWidget({Key? key}) : super(key: key);
const MockWidget({super.key});

@override
State<MockWidget> createState() => _MockWidgetState();
Expand Down Expand Up @@ -127,6 +127,7 @@ void mockAppLink({
const StandardMethodCodec().encodeSuccessEnvelope(initialLink),
(ByteData? data) {},
);
return null;
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/yet_another_json_isolate/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies:
async: ^2.8.0

dev_dependencies:
lints: ^2.1.1
lints: ^3.0.0
test: ^1.16.0

0 comments on commit 7da6856

Please sign in to comment.