From 9214b8cce48227b597a2d136ef10cdd760759aac Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 2 Sep 2021 11:32:33 -0700 Subject: [PATCH 1/5] [camera_web] Make plugin publishable for the first time. * Clarify in the README that the plugin is not endorsed yet. * Tweak the list of not-supported operations * Call this v 0.6.0 --- packages/camera/camera_web/CHANGELOG.md | 9 +--- packages/camera/camera_web/README.md | 56 +++++++++++++++++-------- packages/camera/camera_web/pubspec.yaml | 7 +--- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/packages/camera/camera_web/CHANGELOG.md b/packages/camera/camera_web/CHANGELOG.md index a481554b540c..3403126c2665 100644 --- a/packages/camera/camera_web/CHANGELOG.md +++ b/packages/camera/camera_web/CHANGELOG.md @@ -1,8 +1,3 @@ -## 0.1.0+1 +## 0.6.0 -* Add `implements` to pubspec. - -## 0.1.0 - -* Initial release - * Added CameraOptions used to constrain the camera audio and video. +* Initial release, adapted from the Flutter [I/O Photobooth](https://photobooth.flutter.dev/) project. diff --git a/packages/camera/camera_web/README.md b/packages/camera/camera_web/README.md index 8c216b3f4e0e..2e1989753a62 100644 --- a/packages/camera/camera_web/README.md +++ b/packages/camera/camera_web/README.md @@ -6,7 +6,10 @@ The web implementation of [`camera`][camera]. ## Usage -This package is [endorsed](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin), which means you can simply use `camera` normally. This package will be automatically included in your app when you do. +### Depend on the package + +This package is not an endorsed implementation of the google_maps_flutter plugin yet, +so you'll need to [add it explicitly](https://pub.dev/packages/camea_web/install). ## Example @@ -16,41 +19,59 @@ Find the example in the [`camera` package](https://pub.dev/packages/camera#examp ### Camera devices -The camera devices are accessed with [Stream Web API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API) with the following [browser support](https://caniuse.com/stream): +The camera devices are accessed with [Stream Web API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API) +with the following [browser support](https://caniuse.com/stream): ![Data on support for the Stream feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/stream.png) -Accessing camera devices requires a [secure browsing context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). This means that you might need to serve your web application over HTTPS. For insecure contexts `CameraPlatform.availableCameras` might throw a `CameraException` with the `permissionDenied` error code. +Accessing camera devices requires a [secure browsing context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). +Broadly speaking, this means that you need to serve your web application over HTTPS +(or `localhost` for local development). For insecure contexts +`CameraPlatform.availableCameras` might throw a `CameraException` with the +`permissionDenied` error code. ### Device orientation -The device orientation implementation is backed by [`Screen Orientation Web API`](https://www.w3.org/TR/screen-orientation/) with the following [browser support](https://caniuse.com/screen-orientation): +The device orientation implementation is backed by [`Screen Orientation Web API`](https://www.w3.org/TR/screen-orientation/) +with the following [browser support](https://caniuse.com/screen-orientation): ![Data on support for the Screen Orientation feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/screen-orientation.png) For the browsers that do not support the device orientation: + - `CameraPlatform.onDeviceOrientationChanged` returns an empty stream. -- `CameraPlatform.lockCaptureOrientation` and `CameraPlatform.unlockCaptureOrientation` throw a `PlatformException` with the `orientationNotSupported` error code. +- `CameraPlatform.lockCaptureOrientation` and `CameraPlatform.unlockCaptureOrientation` +throw a `PlatformException` with the `orientationNotSupported` error code. ### Flash mode and zoom level -The flash mode and zoom level implementation is backed by [Image Capture Web API](https://w3c.github.io/mediacapture-image/) with the following [browser support](https://caniuse.com/mdn-api_imagecapture) (as of 12 August 2021): +The flash mode and zoom level implementation is backed by [Image Capture Web API](https://w3c.github.io/mediacapture-image/) +with the following [browser support](https://caniuse.com/mdn-api_imagecapture): -![Data on support for the Image Capture feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/static/v1/mdn-api__ImageCapture-1628778966589.png) +![Data on support for the Image Capture feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/static/v1/mdn-api__ImageCapture-1628778966589.png) For the browsers that do not support the flash mode: -- `CameraPlatform.setFlashMode` throws a `PlatformException` with the `torchModeNotSupported` error code. + +- `CameraPlatform.setFlashMode` throws a `PlatformException` with the +`torchModeNotSupported` error code. For the browsers that do not support the zoom level: -- `CameraPlatform.getMaxZoomLevel`, `CameraPlatform.getMinZoomLevel` and `CameraPlatform.setZoomLevel` throw a `PlatformException` with the `zoomLevelNotSupported` error code. + +- `CameraPlatform.getMaxZoomLevel`, `CameraPlatform.getMinZoomLevel` and +`CameraPlatform.setZoomLevel` throw a `PlatformException` with the +`zoomLevelNotSupported` error code. ### Taking a picture -The image capturing implementation is backed by [`URL.createObjectUrl` Web API](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) with the following [browser support](https://caniuse.com/bloburls): +The image capturing implementation is backed by [`URL.createObjectUrl` Web API](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) +with the following [browser support](https://caniuse.com/bloburls): ![Data on support for the Blob URLs feature across the major browsers from caniuse.com](https://caniuse.bitsofco.de/image/bloburls.png) -The web platform does not support `dart:io`. Attempts to display a captured image using `Image.file` will throw an error. The capture image contains a network-accessible URL pointing to a location within the browser and should be displayed using `Image.network` or `Image.memory` after loading the image bytes to memory. +The web platform does not support `dart:io`. Attempts to display a captured image +using `Image.file` will throw an error. The capture image contains a network-accessible +URL pointing to a location within the browser (blob) and can be displayed using +`Image.network` or `Image.memory` after loading the image bytes to memory. See the example below: @@ -65,13 +86,14 @@ if (kIsWeb) { ## Missing implementation The web implementation of [`camera`][camera] is missing the following features: -- Video recording + +- Video recording ([in progress](https://github.com/flutter/plugins/pull/4210)) - Exposure mode, point and offset - Focus mode and point -- Camera closing events -- Camera sensor orientation -- Camera image format group -- Camera image streaming +- Sensor orientation +- Image format group +- Streaming of frames -[camera]: https://pub.dev/packages/camera \ No newline at end of file +[Stream Web API]: https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API +[camera]: https://pub.dev/packages/camera diff --git a/packages/camera/camera_web/pubspec.yaml b/packages/camera/camera_web/pubspec.yaml index 70194d9037d4..e7e710e94ce2 100644 --- a/packages/camera/camera_web/pubspec.yaml +++ b/packages/camera/camera_web/pubspec.yaml @@ -2,12 +2,7 @@ name: camera_web description: A Flutter plugin for getting information about and controlling the camera on Web. repository: https://github.com/flutter/plugins/tree/master/packages/camera/camera_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.1.0+1 - -# This plugin is under development and will be published -# when the first working web camera implementation is added. -# TODO(bselwe): Remove when camera_web should be published. -publish_to: none +version: 0.6.0 environment: sdk: ">=2.12.0 <3.0.0" From af5b23ceb9ca62d6afd28b283beb775223e9d570 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 2 Sep 2021 12:28:21 -0700 Subject: [PATCH 2/5] Call this 0.2.0 so it's publishable. --- packages/camera/camera_web/CHANGELOG.md | 2 +- packages/camera/camera_web/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_web/CHANGELOG.md b/packages/camera/camera_web/CHANGELOG.md index 3403126c2665..b116636c2808 100644 --- a/packages/camera/camera_web/CHANGELOG.md +++ b/packages/camera/camera_web/CHANGELOG.md @@ -1,3 +1,3 @@ -## 0.6.0 +## 0.2.0 * Initial release, adapted from the Flutter [I/O Photobooth](https://photobooth.flutter.dev/) project. diff --git a/packages/camera/camera_web/pubspec.yaml b/packages/camera/camera_web/pubspec.yaml index e7e710e94ce2..fc9a7545c0d1 100644 --- a/packages/camera/camera_web/pubspec.yaml +++ b/packages/camera/camera_web/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_web description: A Flutter plugin for getting information about and controlling the camera on Web. repository: https://github.com/flutter/plugins/tree/master/packages/camera/camera_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.6.0 +version: 0.2.0 environment: sdk: ">=2.12.0 <3.0.0" From 3b921f3c5587cdbc9b241d3331753dff94ef2e16 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 2 Sep 2021 16:28:54 -0700 Subject: [PATCH 3/5] Make stream_transform a direct dependency, so we can import it. --- packages/camera/camera_web/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/camera/camera_web/pubspec.yaml b/packages/camera/camera_web/pubspec.yaml index fc9a7545c0d1..fdfe3e38bb98 100644 --- a/packages/camera/camera_web/pubspec.yaml +++ b/packages/camera/camera_web/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter + stream_transform: ^2.0.0 dev_dependencies: flutter_test: From 6c4bc9bc11ca6df1d3c3372f161ddb4b2ab30fb9 Mon Sep 17 00:00:00 2001 From: David Iglesias Date: Fri, 3 Sep 2021 09:53:39 -0700 Subject: [PATCH 4/5] Update README.md --- packages/camera/camera_web/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_web/README.md b/packages/camera/camera_web/README.md index 2e1989753a62..5594aa664bdf 100644 --- a/packages/camera/camera_web/README.md +++ b/packages/camera/camera_web/README.md @@ -8,8 +8,8 @@ The web implementation of [`camera`][camera]. ### Depend on the package -This package is not an endorsed implementation of the google_maps_flutter plugin yet, -so you'll need to [add it explicitly](https://pub.dev/packages/camea_web/install). +This package is not an [endorsed implementation](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin) +of the google_maps_flutter plugin yet, so you'll need to [add it explicitly](https://pub.dev/packages/camera_web/install). ## Example From 6a5b7b83f3392ed8cda04d917b0d125abf1ad496 Mon Sep 17 00:00:00 2001 From: David Iglesias Date: Fri, 3 Sep 2021 09:54:40 -0700 Subject: [PATCH 5/5] Update README.md Remove unused link at the bottom of the file. --- packages/camera/camera_web/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/camera/camera_web/README.md b/packages/camera/camera_web/README.md index 5594aa664bdf..c6e1e0f13cab 100644 --- a/packages/camera/camera_web/README.md +++ b/packages/camera/camera_web/README.md @@ -95,5 +95,4 @@ The web implementation of [`camera`][camera] is missing the following features: - Streaming of frames -[Stream Web API]: https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API [camera]: https://pub.dev/packages/camera