From 572df736a5a8f93906df3db6bd67d24800a88db1 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 11:56:24 -0800 Subject: [PATCH 01/12] Phase 1 of web implementation: add a platform interface for the cloud_functions plugin. --- .../CHANGELOG.md | 3 + .../LICENSE | 27 +++++ .../README.md | 26 +++++ .../cloud_functions_platform_interface.dart | 82 ++++++++++++++++ .../lib/src/https_callable.dart | 29 ++++++ .../lib/src/https_callable_result.dart | 13 +++ .../src/method_channel_cloud_functions.dart | 98 +++++++++++++++++++ .../pubspec.yaml | 21 ++++ ...oud_functions_platform_interface_test.dart | 40 ++++++++ .../method_channel_cloud_functions_test.dart | 87 ++++++++++++++++ 10 files changed, 426 insertions(+) create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/CHANGELOG.md create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/LICENSE create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/README.md create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart diff --git a/packages/cloud_functions/cloud_functions_platform_interface/CHANGELOG.md b/packages/cloud_functions/cloud_functions_platform_interface/CHANGELOG.md new file mode 100644 index 000000000000..9d241d49741c --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +Initial release diff --git a/packages/cloud_functions/cloud_functions_platform_interface/LICENSE b/packages/cloud_functions/cloud_functions_platform_interface/LICENSE new file mode 100644 index 000000000000..3b8d61a546d4 --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2017-2020 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/cloud_functions/cloud_functions_platform_interface/README.md b/packages/cloud_functions/cloud_functions_platform_interface/README.md new file mode 100644 index 000000000000..cbc890dc140c --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/README.md @@ -0,0 +1,26 @@ +# cloud_functions_platform_interface + +A common platform interface for the [`cloud_functions`][1] plugin. + +This interface allows platform-specific implementations of the `cloud_functions` +plugin, as well as the plugin itself, to ensure they are supporting the +same interface. + +# Usage + +To implement a new platform-specific implementation of `cloud_functions`, extend +[`CloudFunctionsPlatform`][2] with an implementation that performs the +platform-specific behavior, and when you register your plugin, set the default +`CloudFunctionsPlatform` by calling +`CloudFunctionsPlatform.instance = MyCloudFunctions()`. + +# Note on breaking changes + +Strongly prefer non-breaking changes (such as adding a method to the interface) +over breaking changes for this package. + +See https://flutter.dev/go/platform-interface-breaking-changes for a discussion +on why a less-clean interface is preferable to a breaking change. + +[1]: ../cloud_functions +[2]: lib/cloud_functions_platform_interface.dart diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart new file mode 100644 index 000000000000..6d39d5e550ce --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -0,0 +1,82 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library cloud_functions_platform_interface; + +import 'dart:async'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/services.dart'; +import 'package:meta/meta.dart' show required, visibleForTesting; + +part 'src/https_callable.dart'; +part 'src/https_callable_result.dart'; +part 'src/method_channel_cloud_functions.dart'; + +/// The interface that implementations of `cloud_functions` must extend. +/// +/// Platform implementations should extend this class rather than implement it +/// as `cloud_functions` does not consider newly added methods to be breaking +/// changes. Extending this class (using `extends`) ensures that the subclass +/// will get the default implementation, while platform implementations that +/// `implements` this interface will be broken by newly added +/// [CloudFunctionsPlatform] methods. +abstract class CloudFunctionsPlatform { + /// Only mock implementations should set this to `true`. + /// + /// Mockito mocks implement this class with `implements` which is forbidden + /// (see class docs). This property provides a backdoor for mocks to skip the + /// verification that the class isn't implemented with `implements`. + @visibleForTesting + bool get isMock => false; + + /// The default instance of [CloudFunctionsPlatform] to use. + /// + /// Platform-specific plugins should override this with their own class + /// that extends [CloudFunctionsPlatform] when they register themselves. + /// + /// Defaults to [MethodChannelCloudFunctions]. + static CloudFunctionsPlatform get instance => _instance; + + static CloudFunctionsPlatform _instance = MethodChannelCloudFunctions(); + + // TODO(amirh): Extract common platform interface logic. + // https://github.com/flutter/flutter/issues/43368 + static set instance(CloudFunctionsPlatform instance) { + if (!instance.isMock) { + try { + instance._verifyProvidesDefaultImplementations(); + } on NoSuchMethodError catch (_) { + throw AssertionError( + 'Platform interfaces must not be implemented with `implements`'); + } + } + _instance = instance; + } + + /// This method ensures that [CloudFunctionsPlatform] isn't implemented with `implements`. + /// + /// See class docs for more details on why using `implements` to implement + /// [CloudFunctionsPlatform] is forbidden. + /// + /// This private method is called by the [instance] setter, which should fail + /// if the provided instance is a class implemented with `implements`. + void _verifyProvidesDefaultImplementations() {} + + /// Gets an instance of a Callable HTTPS trigger in Cloud Functions. + /// + /// Can then be executed by calling `call()` on it. + /// + /// @param functionName The name of the callable function. + HttpsCallable getHttpsCallable({@required String functionName}) { + throw UnimplementedError('getHttpsCallable() is not implemented'); + } + + /// Changes this instance to point to a Cloud Functions emulator running locally. + /// + /// @param origin The origin of the local emulator, such as "//10.0.2.2:5005". + CloudFunctionsPlatform useFunctionsEmulator({@required String origin}) { + throw UnimplementedError('useFunctionsEmulator() is not implemented'); + } +} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart new file mode 100644 index 000000000000..1cec7b211f6e --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart @@ -0,0 +1,29 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +part of cloud_functions_platform_interface; + +/// A reference to a particular Callable HTTPS trigger in Cloud Functions. +/// +/// You can get an instance by calling [CloudFunctionsPlatform.instance.getHTTPSCallable]. +abstract class HttpsCallable { + /// Executes this Callable HTTPS trigger asynchronously. + /// + /// The data passed into the trigger can be any of the following types: + /// + /// `null` + /// `String` + /// `num` + /// [List], where the contained objects are also one of these types. + /// [Map], where the values are also one of these types. + /// + /// The request to the Cloud Functions backend made by this method + /// automatically includes a Firebase Instance ID token to identify the app + /// instance. If a user is logged in with Firebase Auth, an auth ID token for + /// the user is also automatically included. + Future call([dynamic parameters]); + + /// The timeout to use when calling the function. Defaults to 60 seconds. + Duration timeout = Duration(seconds: 60); +} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart new file mode 100644 index 000000000000..9c351d5eee0f --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart @@ -0,0 +1,13 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +part of cloud_functions_platform_interface; + +/// The result of calling a [HttpsCallable] function. +class HttpsCallableResult { + HttpsCallableResult(this.data); + + /// Returns the data that was returned from the Callable HTTPS trigger. + final dynamic data; +} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart new file mode 100644 index 000000000000..587d60ab1016 --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart @@ -0,0 +1,98 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +part of cloud_functions_platform_interface; + +class CloudFunctionsException implements Exception { + CloudFunctionsException._(this.code, this.message, this.details); + + final String code; + final String message; + final dynamic details; +} + +class MethodChannelCloudFunctions extends CloudFunctionsPlatform { + MethodChannelCloudFunctions({FirebaseApp app, String region}) + : _app = app ?? FirebaseApp.instance, + _region = region; + + @visibleForTesting + static const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/cloud_functions', + ); + + final FirebaseApp _app; + + final String _region; + + String _origin; + + /// Gets an instance of a Callable HTTPS trigger in Cloud Functions. + /// + /// Can then be executed by calling `call()` on it. + /// + /// @param functionName The name of the callable function. + HttpsCallable getHttpsCallable({@required String functionName}) { + return MethodChannelHttpsCallable._(this, functionName); + } + + /// Changes this instance to point to a Cloud Functions emulator running locally. + /// + /// @param origin The origin of the local emulator, such as "//10.0.2.2:5005". + CloudFunctionsPlatform useFunctionsEmulator({@required String origin}) { + _origin = origin; + return this; + } +} + +/// MethodChannel implementation of [HttpsCallable]. +// +/// You can get an instance by calling [CloudFunctionsPlatform.instance.getHttpsCallable]. +class MethodChannelHttpsCallable extends HttpsCallable { + MethodChannelHttpsCallable._(this._cloudFunctions, this._functionName); + + final MethodChannelCloudFunctions _cloudFunctions; + final String _functionName; + + /// Executes this Callable HTTPS trigger asynchronously. + /// + /// The data passed into the trigger can be any of the following types: + /// + /// `null` + /// `String` + /// `num` + /// [List], where the contained objects are also one of these types. + /// [Map], where the values are also one of these types. + /// + /// The request to the Cloud Functions backend made by this method + /// automatically includes a Firebase Instance ID token to identify the app + /// instance. If a user is logged in with Firebase Auth, an auth ID token for + /// the user is also automatically included. + Future call([dynamic parameters]) async { + try { + final MethodChannel channel = MethodChannelCloudFunctions.channel; + final dynamic response = await channel + .invokeMethod('CloudFunctions#call', { + 'app': _cloudFunctions._app.name, + 'region': _cloudFunctions._region, + 'origin': _cloudFunctions._origin, + 'timeoutMicroseconds': timeout?.inMicroseconds, + 'functionName': _functionName, + 'parameters': parameters, + }); + return HttpsCallableResult(response); + } on PlatformException catch (e) { + if (e.code == 'functionsError') { + final String code = e.details['code']; + final String message = e.details['message']; + final dynamic details = e.details['details']; + throw CloudFunctionsException._(code, message, details); + } else { + throw Exception('Unable to call function ' + _functionName); + } + } catch (e) { + rethrow; + } + } +} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml new file mode 100644 index 000000000000..ac4a8ca38a8c --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml @@ -0,0 +1,21 @@ +name: cloud_functions_platform_interface +description: A common platform interface for the cloud_functions plugin. +homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions/cloud_functions_platform_interface +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +dependencies: + flutter: + sdk: flutter + meta: ^1.0.5 + firebase_core: ^0.4.0 + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^4.1.1 + +environment: + sdk: ">=2.0.0-dev.28.0 <3.0.0" + flutter: ">=1.9.1+hotfix.5 <2.0.0" diff --git a/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart b/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart new file mode 100644 index 000000000000..d7d19f8655c6 --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart @@ -0,0 +1,40 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('$CloudFunctionsPlatform()', () { + test('$MethodChannelCloudFunctions is the default instance', () { + expect( + CloudFunctionsPlatform.instance, isA()); + }); + + test('Cannot be implemented with `implements`', () { + expect(() { + CloudFunctionsPlatform.instance = ImplementsCloudFunctionsPlatform(); + }, throwsAssertionError); + }); + + test('Can be extended', () { + CloudFunctionsPlatform.instance = ExtendsCloudFunctionsPlatform(); + }); + + test('Can be mocked with `implements`', () { + final ImplementsCloudFunctionsPlatform mock = + ImplementsCloudFunctionsPlatform(); + when(mock.isMock).thenReturn(true); + CloudFunctionsPlatform.instance = mock; + }); + }); +} + +class ImplementsCloudFunctionsPlatform extends Mock + implements CloudFunctionsPlatform {} + +class ExtendsCloudFunctionsPlatform extends CloudFunctionsPlatform {} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart b/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart new file mode 100644 index 000000000000..5755af9e68d4 --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart @@ -0,0 +1,87 @@ +// Copyright 2018-2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('$CloudFunctionsPlatform', () { + final List log = []; + + setUp(() async { + MethodChannelCloudFunctions.channel + .setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + switch (methodCall.method) { + case 'FirebaseFunctions#call': + return { + 'foo': 'bar', + }; + default: + return true; + } + }); + log.clear(); + }); + + test('call', () async { + await CloudFunctionsPlatform.instance + .getHttpsCallable(functionName: 'baz') + .call(); + final HttpsCallable callable = MethodChannelCloudFunctions( + app: FirebaseApp(name: '1337'), region: 'space') + .getHttpsCallable(functionName: 'qux') + ..timeout = const Duration(days: 300); + await callable.call({ + 'quux': 'quuz', + }); + await CloudFunctionsPlatform.instance + .useFunctionsEmulator(origin: 'http://localhost:5001') + .getHttpsCallable(functionName: 'bez') + .call(); + expect( + log, + [ + isMethodCall( + 'CloudFunctions#call', + arguments: { + 'app': '[DEFAULT]', + 'region': null, + 'origin': null, + 'functionName': 'baz', + 'timeoutMicroseconds': null, + 'parameters': null, + }, + ), + isMethodCall( + 'CloudFunctions#call', + arguments: { + 'app': '1337', + 'region': 'space', + 'origin': null, + 'functionName': 'qux', + 'timeoutMicroseconds': (const Duration(days: 300)).inMicroseconds, + 'parameters': {'quux': 'quuz'}, + }, + ), + isMethodCall( + 'CloudFunctions#call', + arguments: { + 'app': '[DEFAULT]', + 'region': null, + 'origin': 'http://localhost:5001', + 'functionName': 'bez', + 'timeoutMicroseconds': null, + 'parameters': null, + }, + ), + ], + ); + }); + }); +} From d7920460876cca8623f6791c25949bf97da1566a Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 12:26:01 -0800 Subject: [PATCH 02/12] Remove comment about default timeout, leave default timeout as null. --- .../lib/src/https_callable.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart index 1cec7b211f6e..022f926b0132 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart @@ -24,6 +24,6 @@ abstract class HttpsCallable { /// the user is also automatically included. Future call([dynamic parameters]); - /// The timeout to use when calling the function. Defaults to 60 seconds. - Duration timeout = Duration(seconds: 60); + /// The timeout to use when calling the function. + Duration timeout; } From 18dde6e64054605e0367a22714fd156dcb91dda3 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 16:21:29 -0800 Subject: [PATCH 03/12] Move existing cloud_functions plugin code into its own subfolder, to isolate it from following changes. --- .../{ => cloud_functions}/.gitignore | 3 +++ .../{ => cloud_functions}/CHANGELOG.md | 0 .../cloud_functions/{ => cloud_functions}/LICENSE | 0 .../cloud_functions/{ => cloud_functions}/README.md | 0 .../{ => cloud_functions}/analysis_options.yaml | 2 +- .../{ => cloud_functions}/android/build.gradle | 0 .../{ => cloud_functions}/android/gradle.properties | 0 .../{ => cloud_functions}/android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../cloudfunctions/CloudFunctionsPlugin.java | 0 .../cloudfunctions/FlutterFirebaseAppRegistrar.java | 0 .../{ => cloud_functions}/android/user-agent.gradle | 0 .../{ => cloud_functions}/example/.metadata | 0 .../{ => cloud_functions}/example/README.md | 0 .../example/android/app/build.gradle | 0 .../example/android/app/google-services.json | 0 .../app/gradle/wrapper/gradle-wrapper.properties | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../cloudfunctionsexample/MainActivity.java | 0 .../app/src/main/res/drawable/launch_background.xml | 0 .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../android/app/src/main/res/values/styles.xml | 0 .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../example/ios/Flutter/AppFrameworkInfo.plist | 0 .../example/ios/Flutter/Debug.xcconfig | 0 .../example/ios/Flutter/Release.xcconfig | 0 .../example/ios/Runner.xcodeproj/project.pbxproj | 0 .../xcshareddata/xcschemes/Runner.xcscheme | 0 .../example/ios/Runner/AppDelegate.h | 0 .../example/ios/Runner/AppDelegate.m | 0 .../AppIcon.appiconset/Contents.json | 0 .../AppIcon.appiconset/Icon-App-1024x1024@1x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin .../AppIcon.appiconset/Icon-App-83.5x83.5@2x.png | Bin .../LaunchImage.imageset/Contents.json | 0 .../LaunchImage.imageset/LaunchImage.png | Bin .../LaunchImage.imageset/LaunchImage@2x.png | Bin .../LaunchImage.imageset/LaunchImage@3x.png | Bin .../Assets.xcassets/LaunchImage.imageset/README.md | 0 .../ios/Runner/Base.lproj/LaunchScreen.storyboard | 0 .../example/ios/Runner/Base.lproj/Main.storyboard | 0 .../example/ios/Runner/GoogleService-Info.plist | 0 .../example/ios/Runner/Info.plist | 0 .../{ => cloud_functions}/example/ios/Runner/main.m | 0 .../{ => cloud_functions}/example/lib/main.dart | 0 .../{ => cloud_functions}/example/pubspec.yaml | 0 .../example/test/cloud_functions.dart | 0 .../example/test/cloud_functions_test.dart | 0 .../example/test_driver/cloud_functions_test.dart | 0 .../{ => cloud_functions}/ios/Assets/.gitkeep | 0 .../ios/Classes/CloudFunctionsPlugin.h | 0 .../ios/Classes/CloudFunctionsPlugin.m | 0 .../ios/cloud_functions.podspec | 0 .../{ => cloud_functions}/lib/cloud_functions.dart | 0 .../lib/src/cloud_functions.dart | 0 .../lib/src/https_callable.dart | 0 .../lib/src/https_callable_result.dart | 0 .../{ => cloud_functions}/pubspec.yaml | 0 .../test/cloud_functions_test.dart | 0 .../cloud_functions_platform_interface/.gitignore | 1 + .../project.xcworkspace/contents.xcworkspacedata | 7 ------- .../ios/Runner.xcworkspace/contents.xcworkspacedata | 10 ---------- 81 files changed, 5 insertions(+), 18 deletions(-) rename packages/cloud_functions/{ => cloud_functions}/.gitignore (93%) rename packages/cloud_functions/{ => cloud_functions}/CHANGELOG.md (100%) rename packages/cloud_functions/{ => cloud_functions}/LICENSE (100%) rename packages/cloud_functions/{ => cloud_functions}/README.md (100%) rename packages/cloud_functions/{ => cloud_functions}/analysis_options.yaml (91%) rename packages/cloud_functions/{ => cloud_functions}/android/build.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/android/gradle.properties (100%) rename packages/cloud_functions/{ => cloud_functions}/android/settings.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/android/src/main/AndroidManifest.xml (100%) rename packages/cloud_functions/{ => cloud_functions}/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java (100%) rename packages/cloud_functions/{ => cloud_functions}/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/FlutterFirebaseAppRegistrar.java (100%) rename packages/cloud_functions/{ => cloud_functions}/android/user-agent.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/example/.metadata (100%) rename packages/cloud_functions/{ => cloud_functions}/example/README.md (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/build.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/google-services.json (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/AndroidManifest.xml (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctionsexample/MainActivity.java (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/drawable/launch_background.xml (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/app/src/main/res/values/styles.xml (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/build.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/gradle.properties (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/cloud_functions/{ => cloud_functions}/example/android/settings.gradle (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Flutter/AppFrameworkInfo.plist (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Flutter/Debug.xcconfig (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Flutter/Release.xcconfig (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner.xcodeproj/project.pbxproj (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/AppDelegate.h (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/AppDelegate.m (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Base.lproj/LaunchScreen.storyboard (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Base.lproj/Main.storyboard (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/GoogleService-Info.plist (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/Info.plist (100%) rename packages/cloud_functions/{ => cloud_functions}/example/ios/Runner/main.m (100%) rename packages/cloud_functions/{ => cloud_functions}/example/lib/main.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/example/pubspec.yaml (100%) rename packages/cloud_functions/{ => cloud_functions}/example/test/cloud_functions.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/example/test/cloud_functions_test.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/example/test_driver/cloud_functions_test.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/ios/Assets/.gitkeep (100%) rename packages/cloud_functions/{ => cloud_functions}/ios/Classes/CloudFunctionsPlugin.h (100%) rename packages/cloud_functions/{ => cloud_functions}/ios/Classes/CloudFunctionsPlugin.m (100%) rename packages/cloud_functions/{ => cloud_functions}/ios/cloud_functions.podspec (100%) rename packages/cloud_functions/{ => cloud_functions}/lib/cloud_functions.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/lib/src/cloud_functions.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/lib/src/https_callable.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/lib/src/https_callable_result.dart (100%) rename packages/cloud_functions/{ => cloud_functions}/pubspec.yaml (100%) rename packages/cloud_functions/{ => cloud_functions}/test/cloud_functions_test.dart (100%) create mode 100644 packages/cloud_functions/cloud_functions_platform_interface/.gitignore delete mode 100644 packages/cloud_functions/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 packages/cloud_functions/example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/packages/cloud_functions/.gitignore b/packages/cloud_functions/cloud_functions/.gitignore similarity index 93% rename from packages/cloud_functions/.gitignore rename to packages/cloud_functions/cloud_functions/.gitignore index b7209965bef4..e63fb2b15019 100644 --- a/packages/cloud_functions/.gitignore +++ b/packages/cloud_functions/cloud_functions/.gitignore @@ -33,3 +33,6 @@ build/ .flutter-plugins ios/Classes/UserAgent.h + +.flutter-plugins-dependencies + diff --git a/packages/cloud_functions/CHANGELOG.md b/packages/cloud_functions/cloud_functions/CHANGELOG.md similarity index 100% rename from packages/cloud_functions/CHANGELOG.md rename to packages/cloud_functions/cloud_functions/CHANGELOG.md diff --git a/packages/cloud_functions/LICENSE b/packages/cloud_functions/cloud_functions/LICENSE similarity index 100% rename from packages/cloud_functions/LICENSE rename to packages/cloud_functions/cloud_functions/LICENSE diff --git a/packages/cloud_functions/README.md b/packages/cloud_functions/cloud_functions/README.md similarity index 100% rename from packages/cloud_functions/README.md rename to packages/cloud_functions/cloud_functions/README.md diff --git a/packages/cloud_functions/analysis_options.yaml b/packages/cloud_functions/cloud_functions/analysis_options.yaml similarity index 91% rename from packages/cloud_functions/analysis_options.yaml rename to packages/cloud_functions/cloud_functions/analysis_options.yaml index df2fa2cf8dfa..905ac7b9e373 100644 --- a/packages/cloud_functions/analysis_options.yaml +++ b/packages/cloud_functions/cloud_functions/analysis_options.yaml @@ -3,7 +3,7 @@ # the new lints that are already failing on this plugin, for this plugin. It # should be deleted and the failing lints addressed as soon as possible. -include: ../../analysis_options.yaml +include: ../../../analysis_options.yaml analyzer: errors: diff --git a/packages/cloud_functions/android/build.gradle b/packages/cloud_functions/cloud_functions/android/build.gradle similarity index 100% rename from packages/cloud_functions/android/build.gradle rename to packages/cloud_functions/cloud_functions/android/build.gradle diff --git a/packages/cloud_functions/android/gradle.properties b/packages/cloud_functions/cloud_functions/android/gradle.properties similarity index 100% rename from packages/cloud_functions/android/gradle.properties rename to packages/cloud_functions/cloud_functions/android/gradle.properties diff --git a/packages/cloud_functions/android/settings.gradle b/packages/cloud_functions/cloud_functions/android/settings.gradle similarity index 100% rename from packages/cloud_functions/android/settings.gradle rename to packages/cloud_functions/cloud_functions/android/settings.gradle diff --git a/packages/cloud_functions/android/src/main/AndroidManifest.xml b/packages/cloud_functions/cloud_functions/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/cloud_functions/android/src/main/AndroidManifest.xml rename to packages/cloud_functions/cloud_functions/android/src/main/AndroidManifest.xml diff --git a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java b/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java similarity index 100% rename from packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java rename to packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java diff --git a/packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/FlutterFirebaseAppRegistrar.java b/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/FlutterFirebaseAppRegistrar.java similarity index 100% rename from packages/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/FlutterFirebaseAppRegistrar.java rename to packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/FlutterFirebaseAppRegistrar.java diff --git a/packages/cloud_functions/android/user-agent.gradle b/packages/cloud_functions/cloud_functions/android/user-agent.gradle similarity index 100% rename from packages/cloud_functions/android/user-agent.gradle rename to packages/cloud_functions/cloud_functions/android/user-agent.gradle diff --git a/packages/cloud_functions/example/.metadata b/packages/cloud_functions/cloud_functions/example/.metadata similarity index 100% rename from packages/cloud_functions/example/.metadata rename to packages/cloud_functions/cloud_functions/example/.metadata diff --git a/packages/cloud_functions/example/README.md b/packages/cloud_functions/cloud_functions/example/README.md similarity index 100% rename from packages/cloud_functions/example/README.md rename to packages/cloud_functions/cloud_functions/example/README.md diff --git a/packages/cloud_functions/example/android/app/build.gradle b/packages/cloud_functions/cloud_functions/example/android/app/build.gradle similarity index 100% rename from packages/cloud_functions/example/android/app/build.gradle rename to packages/cloud_functions/cloud_functions/example/android/app/build.gradle diff --git a/packages/cloud_functions/example/android/app/google-services.json b/packages/cloud_functions/cloud_functions/example/android/app/google-services.json similarity index 100% rename from packages/cloud_functions/example/android/app/google-services.json rename to packages/cloud_functions/cloud_functions/example/android/app/google-services.json diff --git a/packages/cloud_functions/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/cloud_functions/cloud_functions/example/android/app/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/cloud_functions/example/android/app/gradle/wrapper/gradle-wrapper.properties rename to packages/cloud_functions/cloud_functions/example/android/app/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/cloud_functions/example/android/app/src/main/AndroidManifest.xml b/packages/cloud_functions/cloud_functions/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/AndroidManifest.xml rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/AndroidManifest.xml diff --git a/packages/cloud_functions/example/android/app/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctionsexample/MainActivity.java b/packages/cloud_functions/cloud_functions/example/android/app/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctionsexample/MainActivity.java similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctionsexample/MainActivity.java rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/java/io/flutter/plugins/firebase/cloudfunctions/cloudfunctionsexample/MainActivity.java diff --git a/packages/cloud_functions/example/android/app/src/main/res/drawable/launch_background.xml b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/drawable/launch_background.xml rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/drawable/launch_background.xml diff --git a/packages/cloud_functions/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/packages/cloud_functions/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/packages/cloud_functions/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/packages/cloud_functions/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/packages/cloud_functions/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/packages/cloud_functions/example/android/app/src/main/res/values/styles.xml b/packages/cloud_functions/cloud_functions/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from packages/cloud_functions/example/android/app/src/main/res/values/styles.xml rename to packages/cloud_functions/cloud_functions/example/android/app/src/main/res/values/styles.xml diff --git a/packages/cloud_functions/example/android/build.gradle b/packages/cloud_functions/cloud_functions/example/android/build.gradle similarity index 100% rename from packages/cloud_functions/example/android/build.gradle rename to packages/cloud_functions/cloud_functions/example/android/build.gradle diff --git a/packages/cloud_functions/example/android/gradle.properties b/packages/cloud_functions/cloud_functions/example/android/gradle.properties similarity index 100% rename from packages/cloud_functions/example/android/gradle.properties rename to packages/cloud_functions/cloud_functions/example/android/gradle.properties diff --git a/packages/cloud_functions/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/cloud_functions/cloud_functions/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/cloud_functions/example/android/gradle/wrapper/gradle-wrapper.properties rename to packages/cloud_functions/cloud_functions/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/cloud_functions/example/android/settings.gradle b/packages/cloud_functions/cloud_functions/example/android/settings.gradle similarity index 100% rename from packages/cloud_functions/example/android/settings.gradle rename to packages/cloud_functions/cloud_functions/example/android/settings.gradle diff --git a/packages/cloud_functions/example/ios/Flutter/AppFrameworkInfo.plist b/packages/cloud_functions/cloud_functions/example/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from packages/cloud_functions/example/ios/Flutter/AppFrameworkInfo.plist rename to packages/cloud_functions/cloud_functions/example/ios/Flutter/AppFrameworkInfo.plist diff --git a/packages/cloud_functions/example/ios/Flutter/Debug.xcconfig b/packages/cloud_functions/cloud_functions/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from packages/cloud_functions/example/ios/Flutter/Debug.xcconfig rename to packages/cloud_functions/cloud_functions/example/ios/Flutter/Debug.xcconfig diff --git a/packages/cloud_functions/example/ios/Flutter/Release.xcconfig b/packages/cloud_functions/cloud_functions/example/ios/Flutter/Release.xcconfig similarity index 100% rename from packages/cloud_functions/example/ios/Flutter/Release.xcconfig rename to packages/cloud_functions/cloud_functions/example/ios/Flutter/Release.xcconfig diff --git a/packages/cloud_functions/example/ios/Runner.xcodeproj/project.pbxproj b/packages/cloud_functions/cloud_functions/example/ios/Runner.xcodeproj/project.pbxproj similarity index 100% rename from packages/cloud_functions/example/ios/Runner.xcodeproj/project.pbxproj rename to packages/cloud_functions/cloud_functions/example/ios/Runner.xcodeproj/project.pbxproj diff --git a/packages/cloud_functions/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/cloud_functions/cloud_functions/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from packages/cloud_functions/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to packages/cloud_functions/cloud_functions/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/packages/cloud_functions/example/ios/Runner/AppDelegate.h b/packages/cloud_functions/cloud_functions/example/ios/Runner/AppDelegate.h similarity index 100% rename from packages/cloud_functions/example/ios/Runner/AppDelegate.h rename to packages/cloud_functions/cloud_functions/example/ios/Runner/AppDelegate.h diff --git a/packages/cloud_functions/example/ios/Runner/AppDelegate.m b/packages/cloud_functions/cloud_functions/example/ios/Runner/AppDelegate.m similarity index 100% rename from packages/cloud_functions/example/ios/Runner/AppDelegate.m rename to packages/cloud_functions/cloud_functions/example/ios/Runner/AppDelegate.m diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/packages/cloud_functions/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/cloud_functions/cloud_functions/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/packages/cloud_functions/example/ios/Runner/Base.lproj/Main.storyboard b/packages/cloud_functions/cloud_functions/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Base.lproj/Main.storyboard rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Base.lproj/Main.storyboard diff --git a/packages/cloud_functions/example/ios/Runner/GoogleService-Info.plist b/packages/cloud_functions/cloud_functions/example/ios/Runner/GoogleService-Info.plist similarity index 100% rename from packages/cloud_functions/example/ios/Runner/GoogleService-Info.plist rename to packages/cloud_functions/cloud_functions/example/ios/Runner/GoogleService-Info.plist diff --git a/packages/cloud_functions/example/ios/Runner/Info.plist b/packages/cloud_functions/cloud_functions/example/ios/Runner/Info.plist similarity index 100% rename from packages/cloud_functions/example/ios/Runner/Info.plist rename to packages/cloud_functions/cloud_functions/example/ios/Runner/Info.plist diff --git a/packages/cloud_functions/example/ios/Runner/main.m b/packages/cloud_functions/cloud_functions/example/ios/Runner/main.m similarity index 100% rename from packages/cloud_functions/example/ios/Runner/main.m rename to packages/cloud_functions/cloud_functions/example/ios/Runner/main.m diff --git a/packages/cloud_functions/example/lib/main.dart b/packages/cloud_functions/cloud_functions/example/lib/main.dart similarity index 100% rename from packages/cloud_functions/example/lib/main.dart rename to packages/cloud_functions/cloud_functions/example/lib/main.dart diff --git a/packages/cloud_functions/example/pubspec.yaml b/packages/cloud_functions/cloud_functions/example/pubspec.yaml similarity index 100% rename from packages/cloud_functions/example/pubspec.yaml rename to packages/cloud_functions/cloud_functions/example/pubspec.yaml diff --git a/packages/cloud_functions/example/test/cloud_functions.dart b/packages/cloud_functions/cloud_functions/example/test/cloud_functions.dart similarity index 100% rename from packages/cloud_functions/example/test/cloud_functions.dart rename to packages/cloud_functions/cloud_functions/example/test/cloud_functions.dart diff --git a/packages/cloud_functions/example/test/cloud_functions_test.dart b/packages/cloud_functions/cloud_functions/example/test/cloud_functions_test.dart similarity index 100% rename from packages/cloud_functions/example/test/cloud_functions_test.dart rename to packages/cloud_functions/cloud_functions/example/test/cloud_functions_test.dart diff --git a/packages/cloud_functions/example/test_driver/cloud_functions_test.dart b/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_test.dart similarity index 100% rename from packages/cloud_functions/example/test_driver/cloud_functions_test.dart rename to packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_test.dart diff --git a/packages/cloud_functions/ios/Assets/.gitkeep b/packages/cloud_functions/cloud_functions/ios/Assets/.gitkeep similarity index 100% rename from packages/cloud_functions/ios/Assets/.gitkeep rename to packages/cloud_functions/cloud_functions/ios/Assets/.gitkeep diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.h b/packages/cloud_functions/cloud_functions/ios/Classes/CloudFunctionsPlugin.h similarity index 100% rename from packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.h rename to packages/cloud_functions/cloud_functions/ios/Classes/CloudFunctionsPlugin.h diff --git a/packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m b/packages/cloud_functions/cloud_functions/ios/Classes/CloudFunctionsPlugin.m similarity index 100% rename from packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m rename to packages/cloud_functions/cloud_functions/ios/Classes/CloudFunctionsPlugin.m diff --git a/packages/cloud_functions/ios/cloud_functions.podspec b/packages/cloud_functions/cloud_functions/ios/cloud_functions.podspec similarity index 100% rename from packages/cloud_functions/ios/cloud_functions.podspec rename to packages/cloud_functions/cloud_functions/ios/cloud_functions.podspec diff --git a/packages/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/cloud_functions/lib/cloud_functions.dart similarity index 100% rename from packages/cloud_functions/lib/cloud_functions.dart rename to packages/cloud_functions/cloud_functions/lib/cloud_functions.dart diff --git a/packages/cloud_functions/lib/src/cloud_functions.dart b/packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart similarity index 100% rename from packages/cloud_functions/lib/src/cloud_functions.dart rename to packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart diff --git a/packages/cloud_functions/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart similarity index 100% rename from packages/cloud_functions/lib/src/https_callable.dart rename to packages/cloud_functions/cloud_functions/lib/src/https_callable.dart diff --git a/packages/cloud_functions/lib/src/https_callable_result.dart b/packages/cloud_functions/cloud_functions/lib/src/https_callable_result.dart similarity index 100% rename from packages/cloud_functions/lib/src/https_callable_result.dart rename to packages/cloud_functions/cloud_functions/lib/src/https_callable_result.dart diff --git a/packages/cloud_functions/pubspec.yaml b/packages/cloud_functions/cloud_functions/pubspec.yaml similarity index 100% rename from packages/cloud_functions/pubspec.yaml rename to packages/cloud_functions/cloud_functions/pubspec.yaml diff --git a/packages/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart similarity index 100% rename from packages/cloud_functions/test/cloud_functions_test.dart rename to packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart diff --git a/packages/cloud_functions/cloud_functions_platform_interface/.gitignore b/packages/cloud_functions/cloud_functions_platform_interface/.gitignore new file mode 100644 index 000000000000..c5fa4f8189fa --- /dev/null +++ b/packages/cloud_functions/cloud_functions_platform_interface/.gitignore @@ -0,0 +1 @@ +.flutter-plugins-dependencies diff --git a/packages/cloud_functions/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/cloud_functions/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 1d526a16ed0f..000000000000 --- a/packages/cloud_functions/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/packages/cloud_functions/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/cloud_functions/example/ios/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 21a3cc14c74e..000000000000 --- a/packages/cloud_functions/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - From f9378a3357e1712b6565ef3412e0334338dfcd99 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 17:47:47 -0800 Subject: [PATCH 04/12] Update CloudFunctionsPlatform to extend PlatformInterface. Change the interface to be a close reflection of the MethodChannel interface. --- .../cloud_functions_platform_interface.dart | 70 ++++++++-------- .../lib/src/https_callable.dart | 29 ------- .../lib/src/https_callable_result.dart | 13 --- .../src/method_channel_cloud_functions.dart | 80 +++++-------------- .../pubspec.yaml | 1 + ...oud_functions_platform_interface_test.dart | 9 ++- .../method_channel_cloud_functions_test.dart | 31 ++++--- 7 files changed, 79 insertions(+), 154 deletions(-) delete mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart delete mode 100644 packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart index 6d39d5e550ce..ccf6cf2df9e7 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -9,9 +9,8 @@ import 'dart:async'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart' show required, visibleForTesting; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -part 'src/https_callable.dart'; -part 'src/https_callable_result.dart'; part 'src/method_channel_cloud_functions.dart'; /// The interface that implementations of `cloud_functions` must extend. @@ -22,14 +21,12 @@ part 'src/method_channel_cloud_functions.dart'; /// will get the default implementation, while platform implementations that /// `implements` this interface will be broken by newly added /// [CloudFunctionsPlatform] methods. -abstract class CloudFunctionsPlatform { - /// Only mock implementations should set this to `true`. - /// - /// Mockito mocks implement this class with `implements` which is forbidden - /// (see class docs). This property provides a backdoor for mocks to skip the - /// verification that the class isn't implemented with `implements`. - @visibleForTesting - bool get isMock => false; +abstract class CloudFunctionsPlatform extends PlatformInterface { + + static final Object _token = Object(); + + /// Constructs a CloudFunctionsPlatform + CloudFunctionsPlatform(): super(token: _token); /// The default instance of [CloudFunctionsPlatform] to use. /// @@ -41,42 +38,39 @@ abstract class CloudFunctionsPlatform { static CloudFunctionsPlatform _instance = MethodChannelCloudFunctions(); + /// Platform-specific plugins should set this with their own platform-specific + /// class that extends [CloudFunctionsPlatform] when they register themselves. // TODO(amirh): Extract common platform interface logic. // https://github.com/flutter/flutter/issues/43368 static set instance(CloudFunctionsPlatform instance) { - if (!instance.isMock) { - try { - instance._verifyProvidesDefaultImplementations(); - } on NoSuchMethodError catch (_) { - throw AssertionError( - 'Platform interfaces must not be implemented with `implements`'); - } - } + PlatformInterface.verifyToken(instance, _token); _instance = instance; } - /// This method ensures that [CloudFunctionsPlatform] isn't implemented with `implements`. - /// - /// See class docs for more details on why using `implements` to implement - /// [CloudFunctionsPlatform] is forbidden. - /// - /// This private method is called by the [instance] setter, which should fail - /// if the provided instance is a class implemented with `implements`. - void _verifyProvidesDefaultImplementations() {} - - /// Gets an instance of a Callable HTTPS trigger in Cloud Functions. + /// Invokes the specified cloud function. /// - /// Can then be executed by calling `call()` on it. + /// The data passed into the cloud function can be any of the following types: /// - /// @param functionName The name of the callable function. - HttpsCallable getHttpsCallable({@required String functionName}) { - throw UnimplementedError('getHttpsCallable() is not implemented'); - } - - /// Changes this instance to point to a Cloud Functions emulator running locally. + /// `null` + /// `String` + /// `num` + /// [List], where the contained objects are also one of these types. + /// [Map], where the values are also one of these types. /// - /// @param origin The origin of the local emulator, such as "//10.0.2.2:5005". - CloudFunctionsPlatform useFunctionsEmulator({@required String origin}) { - throw UnimplementedError('useFunctionsEmulator() is not implemented'); + /// @param appName name of the Firebase application to which the function belongs + /// @param functionName the function being called + /// @param region the region in which the function will be called. If `null`, defaults to `us-central1` + /// @param origin URL base of the function. If set, this can be used to send requests to a local emulator. + /// @param timeout Request timeout. Defaults to 60 seconds this parameter is `null`. + /// @param parameters The data payload for the function. + dynamic callCloudFunction({ + @required String appName, + @required String functionName, + String region, + String origin, + Duration timeout, + dynamic parameters, + }) { + throw UnimplementedError('callCloudFunction() has not been implemented'); } } diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart deleted file mode 100644 index 022f926b0132..000000000000 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable.dart +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -part of cloud_functions_platform_interface; - -/// A reference to a particular Callable HTTPS trigger in Cloud Functions. -/// -/// You can get an instance by calling [CloudFunctionsPlatform.instance.getHTTPSCallable]. -abstract class HttpsCallable { - /// Executes this Callable HTTPS trigger asynchronously. - /// - /// The data passed into the trigger can be any of the following types: - /// - /// `null` - /// `String` - /// `num` - /// [List], where the contained objects are also one of these types. - /// [Map], where the values are also one of these types. - /// - /// The request to the Cloud Functions backend made by this method - /// automatically includes a Firebase Instance ID token to identify the app - /// instance. If a user is logged in with Firebase Auth, an auth ID token for - /// the user is also automatically included. - Future call([dynamic parameters]); - - /// The timeout to use when calling the function. - Duration timeout; -} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart deleted file mode 100644 index 9c351d5eee0f..000000000000 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/https_callable_result.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -part of cloud_functions_platform_interface; - -/// The result of calling a [HttpsCallable] function. -class HttpsCallableResult { - HttpsCallableResult(this.data); - - /// Returns the data that was returned from the Callable HTTPS trigger. - final dynamic data; -} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart index 587d60ab1016..1b5d0fa39aac 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart @@ -4,84 +4,48 @@ part of cloud_functions_platform_interface; +/// Exception that can be thrown by [MethodChannelCloudFunctions] to report +/// errors that occurred inside the channel. A convenience wrapper for [PlatformException]. class CloudFunctionsException implements Exception { CloudFunctionsException._(this.code, this.message, this.details); + /// Error code reported by the platform final String code; + /// Error message reported by the platform final String message; + /// Additional info provided by the platform's exception final dynamic details; } +/// [CloudFunctionsPlatform] implementation that delegates to a [MethodChannel]. class MethodChannelCloudFunctions extends CloudFunctionsPlatform { - MethodChannelCloudFunctions({FirebaseApp app, String region}) - : _app = app ?? FirebaseApp.instance, - _region = region; + /// The [MethodChannel] to which calls will be delegated. @visibleForTesting static const MethodChannel channel = MethodChannel( 'plugins.flutter.io/cloud_functions', ); - final FirebaseApp _app; - - final String _region; - - String _origin; - - /// Gets an instance of a Callable HTTPS trigger in Cloud Functions. - /// - /// Can then be executed by calling `call()` on it. - /// - /// @param functionName The name of the callable function. - HttpsCallable getHttpsCallable({@required String functionName}) { - return MethodChannelHttpsCallable._(this, functionName); - } - - /// Changes this instance to point to a Cloud Functions emulator running locally. - /// - /// @param origin The origin of the local emulator, such as "//10.0.2.2:5005". - CloudFunctionsPlatform useFunctionsEmulator({@required String origin}) { - _origin = origin; - return this; - } -} - -/// MethodChannel implementation of [HttpsCallable]. -// -/// You can get an instance by calling [CloudFunctionsPlatform.instance.getHttpsCallable]. -class MethodChannelHttpsCallable extends HttpsCallable { - MethodChannelHttpsCallable._(this._cloudFunctions, this._functionName); - - final MethodChannelCloudFunctions _cloudFunctions; - final String _functionName; - - /// Executes this Callable HTTPS trigger asynchronously. - /// - /// The data passed into the trigger can be any of the following types: - /// - /// `null` - /// `String` - /// `num` - /// [List], where the contained objects are also one of these types. - /// [Map], where the values are also one of these types. - /// - /// The request to the Cloud Functions backend made by this method - /// automatically includes a Firebase Instance ID token to identify the app - /// instance. If a user is logged in with Firebase Auth, an auth ID token for - /// the user is also automatically included. - Future call([dynamic parameters]) async { + @override + dynamic callCloudFunction({ + @required String appName, + @required String functionName, + String region, + String origin, + Duration timeout, + dynamic parameters, + }) async { try { - final MethodChannel channel = MethodChannelCloudFunctions.channel; final dynamic response = await channel .invokeMethod('CloudFunctions#call', { - 'app': _cloudFunctions._app.name, - 'region': _cloudFunctions._region, - 'origin': _cloudFunctions._origin, + 'app': appName, + 'region': region, + 'origin': origin, 'timeoutMicroseconds': timeout?.inMicroseconds, - 'functionName': _functionName, + 'functionName': functionName, 'parameters': parameters, }); - return HttpsCallableResult(response); + return response; } on PlatformException catch (e) { if (e.code == 'functionsError') { final String code = e.details['code']; @@ -89,7 +53,7 @@ class MethodChannelHttpsCallable extends HttpsCallable { final dynamic details = e.details['details']; throw CloudFunctionsException._(code, message, details); } else { - throw Exception('Unable to call function ' + _functionName); + throw Exception('Unable to call function ' + functionName); } } catch (e) { rethrow; diff --git a/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml index ac4a8ca38a8c..ffb73e687d2e 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions_platform_interface/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: sdk: flutter meta: ^1.0.5 firebase_core: ^0.4.0 + plugin_platform_interface: ^1.0.1 dev_dependencies: flutter_test: diff --git a/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart b/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart index d7d19f8655c6..fd8732b601a5 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart @@ -5,6 +5,7 @@ import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -26,9 +27,7 @@ void main() { }); test('Can be mocked with `implements`', () { - final ImplementsCloudFunctionsPlatform mock = - ImplementsCloudFunctionsPlatform(); - when(mock.isMock).thenReturn(true); + final CloudFunctionsPlatform mock = MocksCloudFunctionsPlatform(); CloudFunctionsPlatform.instance = mock; }); }); @@ -37,4 +36,8 @@ void main() { class ImplementsCloudFunctionsPlatform extends Mock implements CloudFunctionsPlatform {} +class MocksCloudFunctionsPlatform extends Mock + with MockPlatformInterfaceMixin + implements CloudFunctionsPlatform {} + class ExtendsCloudFunctionsPlatform extends CloudFunctionsPlatform {} diff --git a/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart b/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart index 5755af9e68d4..aa53f0f2f94c 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart @@ -30,20 +30,25 @@ void main() { }); test('call', () async { + final String appName = FirebaseApp.instance.name; await CloudFunctionsPlatform.instance - .getHttpsCallable(functionName: 'baz') - .call(); - final HttpsCallable callable = MethodChannelCloudFunctions( - app: FirebaseApp(name: '1337'), region: 'space') - .getHttpsCallable(functionName: 'qux') - ..timeout = const Duration(days: 300); - await callable.call({ - 'quux': 'quuz', - }); - await CloudFunctionsPlatform.instance - .useFunctionsEmulator(origin: 'http://localhost:5001') - .getHttpsCallable(functionName: 'bez') - .call(); + .callCloudFunction(appName: appName, functionName: 'baz'); + + Map params = {'quux': 'quuz'}; + await CloudFunctionsPlatform.instance.callCloudFunction( + appName: '1337', + functionName: 'qux', + region: 'space', + timeout: Duration(days: 300), + parameters: params, + ); + + await CloudFunctionsPlatform.instance.callCloudFunction( + appName: appName, + functionName: 'bez', + origin: 'http://localhost:5001', + ); + expect( log, [ From e04d5cc3d65437fbdd817c88ef662b306dc0f35f Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 17:58:09 -0800 Subject: [PATCH 05/12] Clean up imports --- .../lib/cloud_functions_platform_interface.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart index ccf6cf2df9e7..71b60e591bed 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -4,9 +4,6 @@ library cloud_functions_platform_interface; -import 'dart:async'; - -import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart' show required, visibleForTesting; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; From e906dc63a7494aff28a116850366d3c55b646d30 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 16 Jan 2020 18:03:58 -0800 Subject: [PATCH 06/12] Reformat with dartfmt --- .../lib/cloud_functions_platform_interface.dart | 3 +-- .../lib/src/method_channel_cloud_functions.dart | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart index 71b60e591bed..7c5a5beb9d6f 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -19,11 +19,10 @@ part 'src/method_channel_cloud_functions.dart'; /// `implements` this interface will be broken by newly added /// [CloudFunctionsPlatform] methods. abstract class CloudFunctionsPlatform extends PlatformInterface { - static final Object _token = Object(); /// Constructs a CloudFunctionsPlatform - CloudFunctionsPlatform(): super(token: _token); + CloudFunctionsPlatform() : super(token: _token); /// The default instance of [CloudFunctionsPlatform] to use. /// diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart index 1b5d0fa39aac..5c07d40df0ff 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart @@ -11,15 +11,16 @@ class CloudFunctionsException implements Exception { /// Error code reported by the platform final String code; + /// Error message reported by the platform final String message; + /// Additional info provided by the platform's exception final dynamic details; } /// [CloudFunctionsPlatform] implementation that delegates to a [MethodChannel]. class MethodChannelCloudFunctions extends CloudFunctionsPlatform { - /// The [MethodChannel] to which calls will be delegated. @visibleForTesting static const MethodChannel channel = MethodChannel( From b13e1a7e6a198c427dea3182b444b0727553d0ae Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Sat, 18 Jan 2020 12:38:20 -0800 Subject: [PATCH 07/12] Fix document comments, remove CloudFunctionsException --- .../cloud_functions_platform_interface.dart | 21 +++--- .../src/method_channel_cloud_functions.dart | 67 ++++++++----------- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart index 7c5a5beb9d6f..c523926057f9 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -21,7 +21,7 @@ part 'src/method_channel_cloud_functions.dart'; abstract class CloudFunctionsPlatform extends PlatformInterface { static final Object _token = Object(); - /// Constructs a CloudFunctionsPlatform + /// Constructs a CloudFunctionsPlatform. CloudFunctionsPlatform() : super(token: _token); /// The default instance of [CloudFunctionsPlatform] to use. @@ -45,20 +45,23 @@ abstract class CloudFunctionsPlatform extends PlatformInterface { /// Invokes the specified cloud function. /// - /// The data passed into the cloud function can be any of the following types: + /// The required parameters, [appName] and [functionName], specify which + /// cloud function will be called. + /// + /// The rest of the parameters are optional and used to invoke the function + /// with something other than the defaults. [region] defaults to `us-central1` + /// and [timeout] defaults to 60 seconds. + /// + /// The [origin] parameter may be used to provide the base URL for the function. + /// This can be used to send requests to a local emulator. + /// + /// The data passed into the cloud function via [parameters] can be any of the following types: /// /// `null` /// `String` /// `num` /// [List], where the contained objects are also one of these types. /// [Map], where the values are also one of these types. - /// - /// @param appName name of the Firebase application to which the function belongs - /// @param functionName the function being called - /// @param region the region in which the function will be called. If `null`, defaults to `us-central1` - /// @param origin URL base of the function. If set, this can be used to send requests to a local emulator. - /// @param timeout Request timeout. Defaults to 60 seconds this parameter is `null`. - /// @param parameters The data payload for the function. dynamic callCloudFunction({ @required String appName, @required String functionName, diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart index 5c07d40df0ff..fdf089fdf2fd 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart @@ -4,21 +4,6 @@ part of cloud_functions_platform_interface; -/// Exception that can be thrown by [MethodChannelCloudFunctions] to report -/// errors that occurred inside the channel. A convenience wrapper for [PlatformException]. -class CloudFunctionsException implements Exception { - CloudFunctionsException._(this.code, this.message, this.details); - - /// Error code reported by the platform - final String code; - - /// Error message reported by the platform - final String message; - - /// Additional info provided by the platform's exception - final dynamic details; -} - /// [CloudFunctionsPlatform] implementation that delegates to a [MethodChannel]. class MethodChannelCloudFunctions extends CloudFunctionsPlatform { /// The [MethodChannel] to which calls will be delegated. @@ -27,6 +12,25 @@ class MethodChannelCloudFunctions extends CloudFunctionsPlatform { 'plugins.flutter.io/cloud_functions', ); + /// Invokes the specified cloud function. + /// + /// The required parameters, [appName] and [functionName], specify which + /// cloud function will be called. + /// + /// The rest of the parameters are optional and used to invoke the function + /// with something other than the defaults. [region] defaults to `us-central1` + /// and [timeout] defaults to 60 seconds. + /// + /// The [origin] parameter may be used to provide the base URL for the function. + /// This can be used to send requests to a local emulator. + /// + /// The data passed into the cloud function via [parameters] can be any of the following types: + /// + /// `null` + /// `String` + /// `num` + /// [List], where the contained objects are also one of these types. + /// [Map], where the values are also one of these types. @override dynamic callCloudFunction({ @required String appName, @@ -36,28 +40,15 @@ class MethodChannelCloudFunctions extends CloudFunctionsPlatform { Duration timeout, dynamic parameters, }) async { - try { - final dynamic response = await channel - .invokeMethod('CloudFunctions#call', { - 'app': appName, - 'region': region, - 'origin': origin, - 'timeoutMicroseconds': timeout?.inMicroseconds, - 'functionName': functionName, - 'parameters': parameters, - }); - return response; - } on PlatformException catch (e) { - if (e.code == 'functionsError') { - final String code = e.details['code']; - final String message = e.details['message']; - final dynamic details = e.details['details']; - throw CloudFunctionsException._(code, message, details); - } else { - throw Exception('Unable to call function ' + functionName); - } - } catch (e) { - rethrow; - } + final dynamic response = await channel + .invokeMethod('CloudFunctions#call', { + 'app': appName, + 'region': region, + 'origin': origin, + 'timeoutMicroseconds': timeout?.inMicroseconds, + 'functionName': functionName, + 'parameters': parameters, + }); + return response; } } From df57c79e90fa86f62b6c6cffd40ba0f942e1b6ad Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Tue, 21 Jan 2020 15:53:33 -0800 Subject: [PATCH 08/12] Update signature of callCloudFunction() to return a Future. Update copyright date in LICENSE. --- .../LICENSE | 2 +- .../cloud_functions_platform_interface.dart | 4 +++- .../src/method_channel_cloud_functions.dart | 23 ++++++++----------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/cloud_functions/cloud_functions_platform_interface/LICENSE b/packages/cloud_functions/cloud_functions_platform_interface/LICENSE index 3b8d61a546d4..8940a4be1b58 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/LICENSE +++ b/packages/cloud_functions/cloud_functions_platform_interface/LICENSE @@ -1,4 +1,4 @@ -// Copyright 2017-2020 The Chromium Authors. All rights reserved. +// Copyright 2018 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart index c523926057f9..581d29f07d3a 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/cloud_functions_platform_interface.dart @@ -4,6 +4,8 @@ library cloud_functions_platform_interface; +import 'dart:async'; + import 'package:flutter/services.dart'; import 'package:meta/meta.dart' show required, visibleForTesting; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -62,7 +64,7 @@ abstract class CloudFunctionsPlatform extends PlatformInterface { /// `num` /// [List], where the contained objects are also one of these types. /// [Map], where the values are also one of these types. - dynamic callCloudFunction({ + Future callCloudFunction({ @required String appName, @required String functionName, String region, diff --git a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart index fdf089fdf2fd..ba1a52a35990 100644 --- a/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel_cloud_functions.dart @@ -32,23 +32,20 @@ class MethodChannelCloudFunctions extends CloudFunctionsPlatform { /// [List], where the contained objects are also one of these types. /// [Map], where the values are also one of these types. @override - dynamic callCloudFunction({ + Future callCloudFunction({ @required String appName, @required String functionName, String region, String origin, Duration timeout, dynamic parameters, - }) async { - final dynamic response = await channel - .invokeMethod('CloudFunctions#call', { - 'app': appName, - 'region': region, - 'origin': origin, - 'timeoutMicroseconds': timeout?.inMicroseconds, - 'functionName': functionName, - 'parameters': parameters, - }); - return response; - } + }) => + channel.invokeMethod('CloudFunctions#call', { + 'app': appName, + 'region': region, + 'origin': origin, + 'timeoutMicroseconds': timeout?.inMicroseconds, + 'functionName': functionName, + 'parameters': parameters, + }); } From 52ceebf713aa60257eed6212788ca9633d11df4e Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Tue, 21 Jan 2020 16:43:07 -0800 Subject: [PATCH 09/12] Update the cloud_functions plugin to use the platform interface. --- AUTHORS | 3 ++- .../cloud_functions/CHANGELOG.md | 6 ++++++ .../cloudfunctions/CloudFunctionsPlugin.java | 6 +++--- .../cloud_functions/lib/cloud_functions.dart | 2 ++ .../lib/src/cloud_functions.dart | 3 --- .../lib/src/https_callable.dart | 21 +++++++++---------- .../cloud_functions/pubspec.yaml | 7 +++++-- .../test/cloud_functions_test.dart | 3 ++- 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/AUTHORS b/AUTHORS index 946ae58c5e3d..3e92a7ecf400 100644 --- a/AUTHORS +++ b/AUTHORS @@ -43,4 +43,5 @@ Audrius Karosevicius Lukasz Piliszczuk SoundReply Solutions GmbH Michel Feinstein -Tobias Löfstrand \ No newline at end of file +Tobias Löfstrand +Stephen Beitzel \ No newline at end of file diff --git a/packages/cloud_functions/cloud_functions/CHANGELOG.md b/packages/cloud_functions/cloud_functions/CHANGELOG.md index c3b1d36a75a7..7456344122cc 100644 --- a/packages/cloud_functions/cloud_functions/CHANGELOG.md +++ b/packages/cloud_functions/cloud_functions/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.4.2 + +* Update to use the platform interface to execute calls. +* Fix timeout for Android (which had been ignoring explicit timeouts due to unit mismatch). +* Update repository location based on platform interface refactoring. + ## 0.4.1+6 * Fix analysis failures diff --git a/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java b/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java index 7f7316727751..34a570c1d73d 100644 --- a/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java +++ b/packages/cloud_functions/cloud_functions/android/src/main/java/io/flutter/plugins/firebase/cloudfunctions/CloudFunctionsPlugin.java @@ -49,9 +49,9 @@ public void onMethodCall(MethodCall call, final Result result) { functions.useFunctionsEmulator(origin); } HttpsCallableReference httpsCallableReference = functions.getHttpsCallable(functionName); - Number timeoutMilliseconds = call.argument("timeoutMilliseconds"); - if (timeoutMilliseconds != null) { - httpsCallableReference.setTimeout(timeoutMilliseconds.longValue(), TimeUnit.MILLISECONDS); + Number timeoutMicroseconds = call.argument("timeoutMicroseconds"); + if (timeoutMicroseconds != null) { + httpsCallableReference.setTimeout(timeoutMicroseconds.longValue(), TimeUnit.MICROSECONDS); } httpsCallableReference .call(parameters) diff --git a/packages/cloud_functions/cloud_functions/lib/cloud_functions.dart b/packages/cloud_functions/cloud_functions/lib/cloud_functions.dart index 068d3040cfee..0a0ae1ea4d51 100644 --- a/packages/cloud_functions/cloud_functions/lib/cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions/lib/cloud_functions.dart @@ -5,6 +5,8 @@ library cloud_functions; import 'dart:async'; + +import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; diff --git a/packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart b/packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart index d15db7b49a1f..7575d6f2fb7f 100644 --- a/packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart +++ b/packages/cloud_functions/cloud_functions/lib/src/cloud_functions.dart @@ -20,9 +20,6 @@ class CloudFunctions { : _app = app ?? FirebaseApp.instance, _region = region; - @visibleForTesting - static const MethodChannel channel = MethodChannel('cloud_functions'); - static CloudFunctions _instance = CloudFunctions(); static CloudFunctions get instance => _instance; diff --git a/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart index 6ae34dbf73f5..52ee11099d4b 100644 --- a/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart +++ b/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart @@ -29,17 +29,16 @@ class HttpsCallable { /// the user is also automatically included. Future call([dynamic parameters]) async { try { - final MethodChannel channel = CloudFunctions.channel; - final dynamic response = await channel - .invokeMethod('CloudFunctions#call', { - 'app': _cloudFunctions._app.name, - 'region': _cloudFunctions._region, - 'origin': _cloudFunctions._origin, - 'timeoutMicroseconds': timeout?.inMicroseconds, - 'functionName': _functionName, - 'parameters': parameters, - }); - return HttpsCallableResult._(response); + return CloudFunctionsPlatform.instance + .callCloudFunction( + appName: _cloudFunctions._app.name, + region: _cloudFunctions._region, + origin: _cloudFunctions._origin, + timeout: timeout, + functionName: _functionName, + parameters: parameters, + ) + .then((response) => HttpsCallableResult._(response)); } on PlatformException catch (e) { if (e.code == 'functionsError') { final String code = e.details['code']; diff --git a/packages/cloud_functions/cloud_functions/pubspec.yaml b/packages/cloud_functions/cloud_functions/pubspec.yaml index f8b0f87b15cb..f8c47b196642 100644 --- a/packages/cloud_functions/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions/pubspec.yaml @@ -1,7 +1,7 @@ name: cloud_functions description: Flutter plugin for Cloud Functions. -version: 0.4.1+6 -homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions +version: 0.4.2 +homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions/cloud_functions flutter: plugin: @@ -17,6 +17,9 @@ dependencies: flutter: sdk: flutter firebase_core: ^0.4.0 + # TODO(sbeitzel) update to version number once the platform interface PR is accepted + cloud_functions_platform_interface: + path: ../cloud_functions_platform_interface dev_dependencies: flutter_test: diff --git a/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart b/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart index 7b07212e96da..c9271d78208e 100644 --- a/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart +++ b/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:cloud_functions/cloud_functions.dart'; +import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -14,7 +15,7 @@ void main() { final List log = []; setUp(() async { - CloudFunctions.channel + MethodChannelCloudFunctions.channel .setMockMethodCallHandler((MethodCall methodCall) async { log.add(methodCall); switch (methodCall.method) { From 0362978536b6f6b9c6303cdbe3522690d6246b63 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Wed, 22 Jan 2020 12:27:10 -0800 Subject: [PATCH 10/12] Update pubspec with published version of platform interface. --- packages/cloud_functions/cloud_functions/pubspec.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cloud_functions/cloud_functions/pubspec.yaml b/packages/cloud_functions/cloud_functions/pubspec.yaml index f8c47b196642..e6895e75a67d 100644 --- a/packages/cloud_functions/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions/pubspec.yaml @@ -17,9 +17,7 @@ dependencies: flutter: sdk: flutter firebase_core: ^0.4.0 - # TODO(sbeitzel) update to version number once the platform interface PR is accepted - cloud_functions_platform_interface: - path: ../cloud_functions_platform_interface + cloud_functions_platform_interface: ^1.0.0 dev_dependencies: flutter_test: From 6c82249f4177e5fddf207fdd421ad5a6529bd099 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Wed, 22 Jan 2020 13:05:39 -0800 Subject: [PATCH 11/12] Remove redundant async keyword from method signature. --- .../cloud_functions/cloud_functions/lib/src/https_callable.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart b/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart index 52ee11099d4b..b06a85831866 100644 --- a/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart +++ b/packages/cloud_functions/cloud_functions/lib/src/https_callable.dart @@ -27,7 +27,7 @@ class HttpsCallable { /// automatically includes a Firebase Instance ID token to identify the app /// instance. If a user is logged in with Firebase Auth, an auth ID token for /// the user is also automatically included. - Future call([dynamic parameters]) async { + Future call([dynamic parameters]) { try { return CloudFunctionsPlatform.instance .callCloudFunction( From f1e659777bf4ebbf285deab8f19bc32ee9db35b1 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Wed, 22 Jan 2020 17:20:50 -0800 Subject: [PATCH 12/12] update version number --- packages/cloud_functions/cloud_functions/CHANGELOG.md | 2 +- packages/cloud_functions/cloud_functions/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cloud_functions/cloud_functions/CHANGELOG.md b/packages/cloud_functions/cloud_functions/CHANGELOG.md index 7456344122cc..b2a37afbee68 100644 --- a/packages/cloud_functions/cloud_functions/CHANGELOG.md +++ b/packages/cloud_functions/cloud_functions/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.4.2 +## 0.4.1+7 * Update to use the platform interface to execute calls. * Fix timeout for Android (which had been ignoring explicit timeouts due to unit mismatch). diff --git a/packages/cloud_functions/cloud_functions/pubspec.yaml b/packages/cloud_functions/cloud_functions/pubspec.yaml index e6895e75a67d..cd51800d9fbe 100644 --- a/packages/cloud_functions/cloud_functions/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions/pubspec.yaml @@ -1,6 +1,6 @@ name: cloud_functions description: Flutter plugin for Cloud Functions. -version: 0.4.2 +version: 0.4.1+7 homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_functions/cloud_functions flutter: