From 7335a113c8671de1d28b1b508c5b96ca3e8567ad Mon Sep 17 00:00:00 2001 From: Jesse Ezell Date: Thu, 8 Aug 2024 00:18:31 -0700 Subject: [PATCH 1/2] update to web 1.0 --- lib/src/frame_cryptor_impl.dart | 2 +- lib/src/mediadevices_impl.dart | 31 ++++++++----------------------- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/lib/src/frame_cryptor_impl.dart b/lib/src/frame_cryptor_impl.dart index 9e16bf4..a1dc9c5 100644 --- a/lib/src/frame_cryptor_impl.dart +++ b/lib/src/frame_cryptor_impl.dart @@ -367,7 +367,7 @@ class KeyProviderImpl implements KeyProvider { class FrameCryptorFactoryImpl implements FrameCryptorFactory { FrameCryptorFactoryImpl._internal() { - worker = web.Worker('e2ee.worker.dart.js'); + worker = web.Worker('e2ee.worker.dart.js'.toJS); worker.addEventListener( 'message', (web.MessageEvent msg) { diff --git a/lib/src/mediadevices_impl.dart b/lib/src/mediadevices_impl.dart index 105a034..755c232 100644 --- a/lib/src/mediadevices_impl.dart +++ b/lib/src/mediadevices_impl.dart @@ -32,19 +32,12 @@ class MediaDevicesWeb extends MediaDevices { return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( audio: mediaConstraints['audio'], video: mediaConstraints['video'], - ), - (web.MediaStream stream) {}.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - - final jsStream = await streamCompleter.future; + )) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { @@ -64,19 +57,11 @@ class MediaDevicesWeb extends MediaDevices { jsutil.callMethod(mediaDevices, 'getDisplayMedia', [arg])); return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( video: jsutil.jsify({'mediaSource': 'screen'}), - audio: mediaConstraints['audio'] ?? false), - (web.MediaStream stream) { - streamCompleter.complete(stream); - }.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - final jsStream = await streamCompleter.future; + audio: mediaConstraints['audio'] ?? false)) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { diff --git a/pubspec.yaml b/pubspec.yaml index 5682271..51e76cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: meta: ^1.8.0 platform_detect: ^2.0.7 synchronized: ^3.0.0+3 - web: ^0.5.1 + web: ^1.0.0 webrtc_interface: ^1.1.2 dev_dependencies: From 38badf0f78052ec54ae7331db816ebe92ff0392b Mon Sep 17 00:00:00 2001 From: Jesse Ezell Date: Thu, 8 Aug 2024 00:29:31 -0700 Subject: [PATCH 2/2] update to web 1.0 --- lib/src/frame_cryptor_impl.dart | 2 +- lib/src/mediadevices_impl.dart | 33 ++++++++------------------------- pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/lib/src/frame_cryptor_impl.dart b/lib/src/frame_cryptor_impl.dart index 30b0e4c..4666c41 100644 --- a/lib/src/frame_cryptor_impl.dart +++ b/lib/src/frame_cryptor_impl.dart @@ -400,7 +400,7 @@ class KeyProviderImpl implements KeyProvider { class FrameCryptorFactoryImpl implements FrameCryptorFactory { FrameCryptorFactoryImpl._internal() { - worker = web.Worker('e2ee.worker.dart.js'); + worker = web.Worker('e2ee.worker.dart.js'.toJS); worker.addEventListener( 'message', (web.MessageEvent msg) { diff --git a/lib/src/mediadevices_impl.dart b/lib/src/mediadevices_impl.dart index 52a1c03..1f3b5cb 100644 --- a/lib/src/mediadevices_impl.dart +++ b/lib/src/mediadevices_impl.dart @@ -59,21 +59,12 @@ class MediaDevicesWeb extends MediaDevices { return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( audio: mediaConstraints['audio'], video: mediaConstraints['video'], - ), - (web.MediaStream stream) { - streamCompleter.complete(stream); - }.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - - final jsStream = await streamCompleter.future; + )) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { @@ -93,19 +84,11 @@ class MediaDevicesWeb extends MediaDevices { jsutil.callMethod(mediaDevices, 'getDisplayMedia', [arg])); return MediaStreamWeb(jsStream, 'local'); } else { - final streamCompleter = Completer(); - - web.window.navigator.getUserMedia( - web.MediaStreamConstraints( + final jsStream = await web.window.navigator.mediaDevices + .getUserMedia(web.MediaStreamConstraints( video: jsutil.jsify({'mediaSource': 'screen'}), - audio: mediaConstraints['audio'] ?? false), - (web.MediaStream stream) { - streamCompleter.complete(stream); - }.toJS, - (JSAny err) { - streamCompleter.completeError(err); - }.toJS); - final jsStream = await streamCompleter.future; + audio: mediaConstraints['audio'] ?? false)) + .toDart; return MediaStreamWeb(jsStream, 'local'); } } catch (e) { diff --git a/pubspec.yaml b/pubspec.yaml index 2264bde..ebcf797 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: meta: ^1.8.0 platform_detect: ^2.0.7 synchronized: ^3.0.0+3 - web: ^0.5.1 + web: ^1.0.0 webrtc_interface: ^1.2.0 dev_dependencies: