Skip to content

Commit

Permalink
[firebase_core_web] Use package:firebase (firebase#1522)
Browse files Browse the repository at this point in the history
* Use package:firebase

* Bump pubspec
  • Loading branch information
Harry Terkelsen authored Dec 2, 2019
1 parent b498372 commit 3140f4c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 105 deletions.
8 changes: 6 additions & 2 deletions packages/firebase_core/firebase_core_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.0
## 0.1.0+1

- Initial open-source release.
* Use `package:firebase` for firebase functionality.

## 0.1.0

* Initial open-source release.
41 changes: 15 additions & 26 deletions packages/firebase_core/firebase_core_web/lib/firebase_core_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@

import 'dart:async';

import 'package:firebase/firebase.dart' as fb;
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:js/js_util.dart' as js_util;

import 'src/firebase_js.dart';

/// The implementation of `firebase_core` for web.
class FirebaseCoreWeb extends FirebaseCorePlatform {
/// Creates a new instance of [FirebaseCoreWeb].
FirebaseCoreWeb() {
if (firebase == null) {
throw StateError('firebase.js has not been loaded');
}
}

/// Registers that [FirebaseCoreWeb] is the platform implementation.
static void registerWith(Registrar registrar) {
FirebaseCorePlatform.instance = FirebaseCoreWeb();
Expand All @@ -27,7 +19,7 @@ class FirebaseCoreWeb extends FirebaseCorePlatform {
@override
Future<PlatformFirebaseApp> appNamed(String name) async {
try {
final App jsApp = firebase.app(name);
final fb.App jsApp = fb.app(name);
if (jsApp == null) {
return null;
}
Expand All @@ -42,12 +34,21 @@ class FirebaseCoreWeb extends FirebaseCorePlatform {

@override
Future<void> configure(String name, FirebaseOptions options) async {
firebase.initializeApp(_createFromFirebaseOptions(options), name);
return fb.initializeApp(
name: name,
apiKey: options.apiKey,
databaseURL: options.databaseURL,
projectId: options.projectID,
storageBucket: options.storageBucket,
messagingSenderId: options.gcmSenderID,
measurementId: options.trackingID,
appId: options.googleAppID,
);
}

@override
Future<List<PlatformFirebaseApp>> allApps() async {
final List<App> jsApps = firebase.apps;
final List<fb.App> jsApps = fb.apps;
return jsApps.map<PlatformFirebaseApp>(_createFromJsApp).toList();
}
}
Expand All @@ -57,11 +58,11 @@ bool _isFirebaseError(dynamic e) {
return js_util.getProperty(e, 'name') == 'FirebaseError';
}

PlatformFirebaseApp _createFromJsApp(App jsApp) {
PlatformFirebaseApp _createFromJsApp(fb.App jsApp) {
return PlatformFirebaseApp(jsApp.name, _createFromJsOptions(jsApp.options));
}

FirebaseOptions _createFromJsOptions(Options options) {
FirebaseOptions _createFromJsOptions(fb.FirebaseOptions options) {
return FirebaseOptions(
apiKey: options.apiKey,
trackingID: options.measurementId,
Expand All @@ -72,15 +73,3 @@ FirebaseOptions _createFromJsOptions(Options options) {
storageBucket: options.storageBucket,
);
}

Options _createFromFirebaseOptions(FirebaseOptions options) {
return Options(
apiKey: options.apiKey,
measurementId: options.trackingID,
messagingSenderId: options.gcmSenderID,
projectId: options.projectID,
appId: options.googleAppID,
databaseURL: options.databaseURL,
storageBucket: options.storageBucket,
);
}
76 changes: 0 additions & 76 deletions packages/firebase_core/firebase_core_web/lib/src/firebase_js.dart

This file was deleted.

3 changes: 2 additions & 1 deletion packages/firebase_core/firebase_core_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: firebase_core_web
description: The web implementation of firebase_core
author: Flutter Team <[email protected]>
homepage: https://github.com/FirebaseExtended/flutterfire/packages/firebase_core/firebase_core_web
version: 0.1.0
version: 0.1.0+1

flutter:
plugin:
Expand All @@ -12,6 +12,7 @@ flutter:
fileName: firebase_core_web.dart

dependencies:
firebase: ^7.0.0
firebase_core_platform_interface: ^1.0.0
flutter:
sdk: flutter
Expand Down

0 comments on commit 3140f4c

Please sign in to comment.