Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add _fluttefire_internals and extract firebase_core/src/intern…
…als to the new package (#9628)
- Loading branch information
1 parent
33a71e9
commit 7cd76a1
Showing
64 changed files
with
277 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
Initial release of \_fluttefire_internals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2017, the Chromium project 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# \_flutterfire_internals | ||
|
||
This package is hosting Dart code shared between FlutterFire plugins. It is not | ||
meant for public consumption. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ignore_for_file: require_trailing_commas | ||
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file | ||
// for details. 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:firebase_core/firebase_core.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Catches a [PlatformException] and returns an [Exception]. | ||
/// | ||
/// If the [Exception] is a [PlatformException], a [FirebaseException] is returned. | ||
Never convertPlatformExceptionToFirebaseException( | ||
Object exception, | ||
StackTrace stackTrace, { | ||
required String plugin, | ||
}) { | ||
if (exception is! Exception || exception is! PlatformException) { | ||
Error.throwWithStackTrace(exception, stackTrace); | ||
} | ||
|
||
Error.throwWithStackTrace( | ||
platformExceptionToFirebaseException(exception, plugin: plugin), | ||
stackTrace, | ||
); | ||
} | ||
|
||
/// Converts a [PlatformException] into a [FirebaseException]. | ||
/// | ||
/// A [PlatformException] can only be converted to a [FirebaseException] if the | ||
/// `details` of the exception exist. Firebase returns specific codes and messages | ||
/// which can be converted into user friendly exceptions. | ||
FirebaseException platformExceptionToFirebaseException( | ||
PlatformException platformException, { | ||
required String plugin, | ||
}) { | ||
Map<String, String>? details = platformException.details != null | ||
? Map<String, String>.from(platformException.details) | ||
: null; | ||
|
||
String? code; | ||
String message = platformException.message ?? ''; | ||
|
||
if (details != null) { | ||
code = details['code'] ?? code; | ||
message = details['message'] ?? message; | ||
} | ||
|
||
return FirebaseException( | ||
plugin: plugin, | ||
code: code, | ||
message: message, | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: _flutterfire_internals | ||
description: A package hosting Dart code shared between FlutterFire plugins. | ||
homepage: https://firebase.google.com/docs/firestore | ||
repository: https://github.com/firebase/flutterfire/tree/master/packages/_flutterfire_internals | ||
version: 1.0.0 | ||
|
||
environment: | ||
sdk: '>=2.16.0 <3.0.0' | ||
flutter: '>=1.12.13+hotfix.5' | ||
|
||
dependencies: | ||
cloud_firestore_platform_interface: ^5.7.5 | ||
cloud_firestore_web: ^2.8.8 | ||
collection: ^1.0.0 | ||
firebase_core: ^1.10.2 | ||
firebase_core_platform_interface: ^4.5.1 | ||
flutter: | ||
sdk: flutter | ||
meta: ^1.3.0 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
mockito: ^5.0.0 | ||
test: any |
4 changes: 2 additions & 2 deletions
4
...e_core/firebase_core/test/guard_test.dart → ...lutterfire_internals/test/guard_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 4 additions & 30 deletions
34
..._firestore/cloud_firestore_platform_interface/lib/src/method_channel/utils/exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,18 @@ | ||
// ignore_for_file: require_trailing_commas | ||
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file | ||
// for details. 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:firebase_core/firebase_core.dart'; | ||
import 'package:_flutterfire_internals/_flutterfire_internals.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Catches a [PlatformException] and returns an [Exception]. | ||
/// | ||
/// If the [Exception] is a [PlatformException], a [FirebaseException] is returned. | ||
Never convertPlatformException(Object exception, StackTrace stackTrace) { | ||
if (exception is! Exception || exception is! PlatformException) { | ||
Error.throwWithStackTrace(exception, stackTrace); | ||
} | ||
|
||
Error.throwWithStackTrace( | ||
platformExceptionToFirebaseException(exception), | ||
convertPlatformExceptionToFirebaseException( | ||
exception, | ||
stackTrace, | ||
plugin: 'cloud_firestore', | ||
); | ||
} | ||
|
||
/// Converts a [PlatformException] into a [FirebaseException]. | ||
/// | ||
/// A [PlatformException] can only be converted to a [FirebaseException] if the | ||
/// `details` of the exception exist. Firebase returns specific codes and messages | ||
/// which can be converted into user friendly exceptions. | ||
FirebaseException platformExceptionToFirebaseException( | ||
PlatformException platformException) { | ||
Map<String, String>? details = platformException.details != null | ||
? Map<String, String>.from(platformException.details) | ||
: null; | ||
|
||
String code = 'unknown'; | ||
String message = platformException.message ?? ''; | ||
|
||
if (details != null) { | ||
code = details['code'] ?? code; | ||
message = details['message'] ?? message; | ||
} | ||
|
||
return FirebaseException( | ||
plugin: 'cloud_firestore', code: code, message: message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
packages/cloud_firestore/cloud_firestore_web/lib/src/internals.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
packages/firebase_analytics/firebase_analytics_web/lib/utils/exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.