Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add conditional export to support --wasm build #3363

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions drift/lib/src/web/channel_legacy_dummy.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:stream_channel/stream_channel.dart';

/// Extension to transform a raw `MessagePort` from web workers into a Dart
/// [StreamChannel].
extension PortToChannel on dynamic {
/// Converts this port to a two-way communication channel, exposed as a
/// [StreamChannel].
///
/// This can be used to implement a remote database connection over service
/// workers.
///
/// The [explicitClose] parameter can be used to control whether a close
/// message should be sent through the channel when it is closed. This will
/// cause it to be closed on the other end as well. Note that this is not a
/// reliable way of determining channel closures though, as there is no event
/// for channels being closed due to a tab or worker being closed.
/// Both "ends" of a JS channel calling [channel] on their part must use the
/// value for [explicitClose].
@Deprecated(
'Please use MessagePorts from package:web instead of those from dart:html. '
'This extension will be removed from drift once `dart:html` is removed '
'from the SDK.',
)
StreamChannel<Object?> channel({bool explicitClose = false}) {
throw 'If this import was resolved, dart:html is not available.';
}
}
3 changes: 2 additions & 1 deletion drift/lib/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ library drift.web;
export 'src/web/sql_js.dart';
export 'src/web/storage.dart' hide CustomSchemaVersionSave;
export 'src/web/web_db.dart';
export 'src/web/channel_legacy.dart';
export 'src/web/channel_legacy_dummy.dart'
if (dart.library.html) 'src/web/channel_legacy.dart';
export 'src/web/channel_new.dart';
Loading