Skip to content

Commit 4e54f22

Browse files
Merge branch 'firestore-multi-tab' into multitab-instancestate
2 parents 1530c9c + 631e1ad commit 4e54f22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1728
-228
lines changed

.github/CODEOWNERS

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ packages/storage @sphippen
1919
packages/storage-types @sphippen
2020

2121
# Messaging Code
22-
packages/messaging @gauntface
23-
packages/messaging-types @gauntface
24-
integration/messaging @gauntface
22+
packages/messaging @gauntface @pinarx
23+
packages/messaging-types @gauntface @pinarx
24+
integration/messaging @gauntface @pinarx
2525

2626
# Auth Code
2727
packages/auth @bojeil-google @wti806 @tmsch

.github/ISSUE_TEMPLATE.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ Are you in the right place?
3232
-->
3333
#### Relevant Code:
3434

35-
<!-- Fork this JSBin, provide your own URL, or a simple code snippet below -->
36-
http://jsbin.com/rinilu/edit?js,console
35+
<!--
36+
Reproduce the issue on StackBlitz and provide your forked URL
37+
or give us some sample code below
38+
-->
39+
https://stackblitz.com/fork/firebase-issue-sandbox
3740

3841
```javascript
3942
// TODO(you): code here to reproduce the problem

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ before_install:
1111
# Yarn defaults to an old version, make sure we
1212
# get an up to date version
1313
- npm install -g yarn
14+
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > $HOME/.npmrc
1415
before_script:
1516
- cp config/ci.config.json config/project.json
1617
script:
@@ -29,3 +30,11 @@ addons:
2930
packages:
3031
- google-chrome-stable
3132
- g++-4.8
33+
34+
# NPM Canary Build Config
35+
deploy:
36+
skip_cleanup: true
37+
provider: script
38+
script: yarn release --canary
39+
on:
40+
branch: master

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry "https://registry.npmjs.org/"

integration/browserify/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "4.9.0"
10+
"firebase": "4.9.1"
1111
},
1212
"devDependencies": {
1313
"browserify": "^14.5.0",

integration/firebase-typings/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "tsc index.ts --outDir dist"
77
},
88
"dependencies": {
9-
"firebase": "4.9.0"
9+
"firebase": "4.9.1"
1010
},
1111
"devDependencies": {
1212
"typescript": "^2.4.2"

integration/messaging/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:manual": "mocha --retries 3 --exit"
99
},
1010
"dependencies": {
11-
"firebase": "4.9.0"
11+
"firebase": "4.9.1"
1212
},
1313
"devDependencies": {
1414
"chai": "^4.1.1",

integration/typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "karma start --single-run"
77
},
88
"dependencies": {
9-
"firebase": "4.9.0"
9+
"firebase": "4.9.1"
1010
},
1111
"devDependencies": {
1212
"@types/chai": "^4.0.4",

integration/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "karma start --single-run"
88
},
99
"dependencies": {
10-
"firebase": "4.9.0"
10+
"firebase": "4.9.1"
1111
},
1212
"devDependencies": {
1313
"chai": "^4.1.1",

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
"prepush": "node tools/gitHooks/prepush.js",
2121
"link:packages": "lerna exec --scope @firebase/* --scope firebase -- yarn link",
2222
"stage:packages": "./scripts/prepublish.sh",
23-
"prepublish:packages": "./scripts/prepublish.sh --prod",
24-
"publish:packages": "./scripts/publish.sh",
2523
"repl": "node tools/repl.js",
24+
"release": "node scripts/release/cli.js",
2625
"pretest": "node tools/pretest.js",
2726
"test": "lerna run --parallel test",
2827
"pretest:coverage": "mkdirp coverage",
@@ -40,22 +39,26 @@
4039
"devDependencies": {
4140
"chalk": "^2.3.0",
4241
"child-process-promise": "^2.2.1",
42+
"clone": "^2.1.1",
4343
"coveralls": "^3.0.0",
44+
"dependency-graph": "^0.7.0",
4445
"firebase-tools": "^3.10.1",
4546
"glob": "^7.1.2",
4647
"gulp-sourcemaps": "^2.6.1",
4748
"gulp-typescript": "^3.2.3",
4849
"husky": "^0.14.3",
49-
"inquirer": "^3.2.3",
50+
"inquirer": "^5.0.0",
5051
"istanbul-instrumenter-loader": "^3.0.0",
5152
"lcov-result-merger": "^1.2.0",
5253
"lerna": "^2.1.0",
54+
"listr": "^0.13.0",
5355
"merge2": "^1.2.0",
5456
"mkdirp": "^0.5.1",
5557
"mz": "^2.7.0",
58+
"npm-run-path": "^2.0.2",
5659
"ora": "^1.3.0",
5760
"prettier": "^1.7.0",
58-
"semver": "^5.4.1",
61+
"semver": "^5.5.0",
5962
"simple-git": "^1.80.1",
6063
"yargs": "^10.0.3"
6164
}

packages/app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/cjs/index.js",
@@ -16,7 +16,7 @@
1616
"license": "Apache-2.0",
1717
"dependencies": {
1818
"@firebase/app-types": "0.1.1",
19-
"@firebase/util": "0.1.7"
19+
"@firebase/util": "0.1.8"
2020
},
2121
"devDependencies": {
2222
"@types/chai": "^4.0.4",

packages/auth/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/auth",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"main": "dist/auth.js",
55
"description": "Javascript library for Firebase Auth SDK",
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",

packages/auth/src/cordovahandler.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ goog.require('fireauth.AuthEvent');
3535
goog.require('fireauth.AuthProvider');
3636
goog.require('fireauth.DynamicLink');
3737
goog.require('fireauth.OAuthSignInHandler');
38+
goog.require('fireauth.UniversalLinkSubscriber');
3839
goog.require('fireauth.authenum.Error');
3940
goog.require('fireauth.iframeclient.IfcHandler');
4041
goog.require('fireauth.storage.AuthEventManager');
@@ -724,16 +725,6 @@ fireauth.CordovaHandler.prototype.extractAuthEventFromUrl_ =
724725
fireauth.CordovaHandler.prototype.setAuthEventListener_ = function() {
725726
// https://github.com/nordnet/cordova-universal-links-plugin
726727
var self = this;
727-
// Get universal link subscriber.
728-
var subscribe = fireauth.util.getObjectRef(
729-
'universalLinks.subscribe', goog.global);
730-
// Should not occur as initializeAndWait will ensure that.
731-
if (typeof subscribe !== 'function') {
732-
// Universal link plugin not installed.
733-
throw new fireauth.AuthError(
734-
fireauth.authenum.Error.INVALID_CORDOVA_CONFIGURATION);
735-
}
736-
// Universal link plugin installed.
737728
// Default no redirect event result.
738729
var noEvent = new fireauth.AuthEvent(
739730
fireauth.AuthEvent.Type.UNKNOWN,
@@ -805,7 +796,7 @@ fireauth.CordovaHandler.prototype.setAuthEventListener_ = function() {
805796
}
806797
}
807798
};
808-
subscribe(null, universalLinkCb);
799+
fireauth.UniversalLinkSubscriber.getInstance().subscribe(universalLinkCb);
809800
};
810801

811802

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/**
2+
* Copyright 2018 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* @fileoverview Provides the universal link subscriber utility to allow
19+
* multiple subscriptions for incoming universal link detection.
20+
*/
21+
goog.provide('fireauth.UniversalLinkSubscriber');
22+
23+
goog.require('fireauth.util');
24+
goog.require('goog.array');
25+
26+
/**
27+
* Defines the universal link subscriber class used to allow multiple universal
28+
* link subscriptions since the underlying plugin only works with one.
29+
* This utility is needed since the universal link cordova plugin can only allow
30+
* one subscriber and multiple app instances can subscribe to this.
31+
* @constructor @final @struct
32+
*/
33+
fireauth.UniversalLinkSubscriber = function() {
34+
/**
35+
* @private {?function(?Object)} The master callback that subscribes directly
36+
* to universalLinks.
37+
*/
38+
this.masterCb_ = null;
39+
/**
40+
* @private {!Array<function(?Object)>} The list of external subscribers that
41+
* are triggered every time the master callback is triggered.
42+
*/
43+
this.cb_ = [];
44+
};
45+
46+
47+
/**
48+
* @return {!fireauth.UniversalLinkSubscriber} The default universal link
49+
* subscriber instance.
50+
*/
51+
fireauth.UniversalLinkSubscriber.getInstance = function() {
52+
if (!fireauth.UniversalLinkSubscriber.instance_) {
53+
fireauth.UniversalLinkSubscriber.instance_ =
54+
new fireauth.UniversalLinkSubscriber();
55+
}
56+
return fireauth.UniversalLinkSubscriber.instance_;
57+
};
58+
59+
60+
/** Clears singleton instance. Useful for testing. */
61+
fireauth.UniversalLinkSubscriber.clear = function() {
62+
fireauth.UniversalLinkSubscriber.instance_ = null;
63+
};
64+
65+
66+
/**
67+
* @private {?fireauth.UniversalLinkSubscriber} The singleton universal
68+
* link subscriber instance.
69+
*/
70+
fireauth.UniversalLinkSubscriber.instance_ = null;
71+
72+
73+
/**
74+
* Subscribes a callback to the universal link plugin listener.
75+
* @param {function(?Object)} cb The callback to subscribe to the universal
76+
* link plugin.
77+
*/
78+
fireauth.UniversalLinkSubscriber.prototype.subscribe = function(cb) {
79+
var self = this;
80+
this.cb_.push(cb);
81+
if (!this.masterCb_) {
82+
this.masterCb_ = function(event) {
83+
for (var i = 0; i < self.cb_.length; i++) {
84+
self.cb_[i](event);
85+
}
86+
};
87+
var subscribe = fireauth.util.getObjectRef(
88+
'universalLinks.subscribe', goog.global);
89+
// For iOS environments, this plugin is not used, therefore this is a no-op
90+
// and no error needs to be thrown.
91+
if (typeof subscribe === 'function') {
92+
subscribe(null, this.masterCb_);
93+
}
94+
}
95+
};
96+
97+
98+
/**
99+
* Unsubscribes a callback from the universal link plugin listener.
100+
* @param {function(?Object)} cb The callback to unsubscribe from the universal
101+
* link plugin.
102+
*/
103+
fireauth.UniversalLinkSubscriber.prototype.unsubscribe = function(cb) {
104+
goog.array.removeAllIf(this.cb_, function(ele) {
105+
return ele == cb;
106+
});
107+
};
108+

packages/auth/test/autheventmanager_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ goog.require('fireauth.InvalidOriginError');
3030
goog.require('fireauth.PopupAuthEventProcessor');
3131
goog.require('fireauth.RedirectAuthEventProcessor');
3232
goog.require('fireauth.RpcHandler');
33+
goog.require('fireauth.UniversalLinkSubscriber');
3334
goog.require('fireauth.authenum.Error');
3435
goog.require('fireauth.constants');
3536
goog.require('fireauth.iframeclient.IfcHandler');
@@ -108,6 +109,7 @@ function tearDown() {
108109
} finally {
109110
mockControl.$tearDown();
110111
}
112+
fireauth.UniversalLinkSubscriber.clear();
111113
}
112114

113115

packages/auth/test/cordovahandler_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ goog.require('fireauth.AuthEvent');
2525
goog.require('fireauth.CordovaHandler');
2626
goog.require('fireauth.EmailAuthProvider');
2727
goog.require('fireauth.GoogleAuthProvider');
28+
goog.require('fireauth.UniversalLinkSubscriber');
2829
goog.require('fireauth.authenum.Error');
2930
goog.require('fireauth.constants');
3031
goog.require('fireauth.iframeclient.IfcHandler');
@@ -183,6 +184,7 @@ function tearDown() {
183184
if (goog.global['handleOpenURL']) {
184185
delete goog.global['handleOpenURL'];
185186
}
187+
fireauth.UniversalLinkSubscriber.clear();
186188
}
187189

188190

0 commit comments

Comments
 (0)