Skip to content

Commit cc9ccda

Browse files
Merge branch 'master' into mrschmidt/fetchstreams
2 parents ba8cc73 + 22c2621 commit cc9ccda

Some content is hidden

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

69 files changed

+723
-530
lines changed

.changeset/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"firebase-namespace-integration-test",
1414
"firebase-firestore-integration-test",
1515
"firebase-messaging-integration-test",
16+
"firebase-compat-interop-test",
1617
"firebase-compat-typings-test",
1718
"@firebase/app-exp",
1819
"@firebase/analytics-compat",

.changeset/fast-mangos-serve.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/fuzzy-teachers-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/component": patch
3+
---
4+
5+
handle `undefined` correctly from input.

.changeset/perfect-comics-march.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/silent-planets-raise.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/tender-eels-greet.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/twenty-scissors-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"firebase": patch
3+
---
4+
5+
set firebase.SDK_VERSION to the latest value

common/api-review/messaging-exp.api.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ export type _FirebaseMessagingName = 'messaging';
2929
export function getMessaging(app?: FirebaseApp): FirebaseMessaging;
3030

3131
// @public
32-
export function getToken(messaging: FirebaseMessaging, options?: {
33-
vapidKey?: string;
32+
export function getToken(messaging: FirebaseMessaging, options?: GetTokenOptions): Promise<string>;
33+
34+
// @public
35+
export interface GetTokenOptions {
3436
swReg?: ServiceWorkerRegistration;
35-
}): Promise<string>;
37+
vapidKey?: string;
38+
}
3639

3740
// @public
3841
export function isSupported(): Promise<boolean>;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## API Report File for "@firebase/messaging-exp/sw"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
import { FirebaseApp } from '@firebase/app-exp';
8+
import { NextFn } from '@firebase/util';
9+
import { Observer } from '@firebase/util';
10+
import { Unsubscribe } from '@firebase/util';
11+
12+
// @public
13+
export interface FcmOptions {
14+
analyticsLabel?: string;
15+
link?: string;
16+
}
17+
18+
// @public
19+
export interface FirebaseMessaging {
20+
}
21+
22+
// @public
23+
export function getMessaging(app?: FirebaseApp): FirebaseMessaging;
24+
25+
// @public
26+
export function isSupported(): Promise<boolean>;
27+
28+
// @public
29+
export interface MessagePayload {
30+
collapseKey: string;
31+
data?: {
32+
[key: string]: string;
33+
};
34+
fcmOptions?: FcmOptions;
35+
from: string;
36+
notification?: NotificationPayload;
37+
}
38+
39+
export { NextFn }
40+
41+
// @public
42+
export interface NotificationPayload {
43+
body?: string;
44+
image?: string;
45+
title?: string;
46+
}
47+
48+
export { Observer }
49+
50+
// @public
51+
export function onBackgroundMessage(messaging: FirebaseMessaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
52+
53+
export { Unsubscribe }
54+
55+
56+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { getModularInstance } from '@firebase/util';
19+
import { expect } from 'chai';
20+
import { getAnalytics } from '@firebase/analytics-exp';
21+
import firebase from '@firebase/app-compat';
22+
import '@firebase/analytics-compat';
23+
24+
import { TEST_PROJECT_CONFIG } from './util';
25+
26+
firebase.initializeApp(TEST_PROJECT_CONFIG);
27+
28+
const compatAnalytics = firebase.analytics();
29+
const modularAnalytics = getAnalytics();
30+
31+
describe('Analytics compat interop', () => {
32+
it('Analytics compat instance references modular Analytics instance', () => {
33+
expect(getModularInstance(compatAnalytics)).to.equal(modularAnalytics);
34+
});
35+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { getModularInstance } from '@firebase/util';
19+
import { expect } from 'chai';
20+
import { getApp, getApps } from '@firebase/app-exp';
21+
import firebase from '@firebase/app-compat';
22+
23+
import { TEST_PROJECT_CONFIG } from './util';
24+
//TODO: add Storage, Firestore and Database tests once v8 is removed. Currently it's too difficult to set them up in integration tests.
25+
describe('App compat interop', () => {
26+
afterEach(() => {
27+
const deletePromises = [];
28+
for (const app of firebase.apps) {
29+
deletePromises.push(app.delete());
30+
}
31+
32+
return Promise.all(deletePromises);
33+
});
34+
35+
it('App compat instance references modular App instance', () => {
36+
const compatApp = firebase.initializeApp(TEST_PROJECT_CONFIG);
37+
const modularApp = getApp();
38+
expect(getModularInstance(compatApp)).to.equal(modularApp);
39+
});
40+
41+
it('deleting compat app deletes modular app', async () => {
42+
const compatApp = firebase.initializeApp(TEST_PROJECT_CONFIG);
43+
expect(firebase.apps.length).to.equal(1);
44+
expect(getApps().length).to.equal(1);
45+
46+
await compatApp.delete();
47+
expect(firebase.apps.length).to.equal(0);
48+
expect(getApps().length).to.equal(0);
49+
});
50+
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { getModularInstance } from '@firebase/util';
19+
import { expect } from 'chai';
20+
import { getAuth, signOut } from '@firebase/auth-exp';
21+
import firebase from '@firebase/app-compat';
22+
import '@firebase/auth-compat';
23+
24+
import { TEST_PROJECT_CONFIG } from './util';
25+
26+
firebase.initializeApp(TEST_PROJECT_CONFIG);
27+
28+
const compatAuth = firebase.auth();
29+
const modularAuth = getAuth();
30+
31+
describe('Auth compat interop', () => {
32+
it('Auth compat instance references modular Auth instance', () => {
33+
expect(getModularInstance(compatAuth)).to.equal(modularAuth);
34+
});
35+
36+
it('Auth compat and modular Auth share the same user state', async () => {
37+
expect(compatAuth.currentUser).to.equal(null);
38+
expect(modularAuth.currentUser).to.equal(null);
39+
const userCred = await compatAuth.signInAnonymously();
40+
expect(userCred.user?.uid).to.equal(modularAuth.currentUser?.uid);
41+
expect(await userCred.user?.getIdToken()).to.equal(
42+
await modularAuth.currentUser?.getIdToken()
43+
);
44+
45+
await signOut(modularAuth);
46+
expect(compatAuth.currentUser).to.equal(null);
47+
expect(modularAuth.currentUser).to.equal(null);
48+
});
49+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { getModularInstance } from '@firebase/util';
19+
import { expect } from 'chai';
20+
import { getFunctions } from '@firebase/functions-exp';
21+
import firebase from '@firebase/app-compat';
22+
import '@firebase/functions-compat';
23+
24+
import { TEST_PROJECT_CONFIG } from './util';
25+
26+
firebase.initializeApp(TEST_PROJECT_CONFIG);
27+
28+
const compatFunction = firebase.functions();
29+
const modularFunctions = getFunctions();
30+
31+
describe('Functions compat interop', () => {
32+
it('Functions compat instance references modular Functions instance', () => {
33+
expect(getModularInstance(compatFunction)).to.equal(modularFunctions);
34+
});
35+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright 2017 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const karma = require('karma');
19+
const karmaBase = require('../../config/karma.base');
20+
21+
const files = ['*.test.*'];
22+
23+
module.exports = function (config) {
24+
const karmaConfig = Object.assign({}, karmaBase, {
25+
// files to load into karma
26+
files: files,
27+
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
28+
// frameworks to use
29+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
30+
frameworks: ['mocha']
31+
});
32+
33+
config.set(karmaConfig);
34+
};
35+
36+
module.exports.files = files;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { getModularInstance } from '@firebase/util';
19+
import { expect } from 'chai';
20+
import { getMessaging } from '@firebase/messaging-exp';
21+
import firebase from '@firebase/app-compat';
22+
import '@firebase/messaging-compat';
23+
24+
import { TEST_PROJECT_CONFIG } from './util';
25+
26+
firebase.initializeApp(TEST_PROJECT_CONFIG);
27+
28+
const compatMessaging = firebase.messaging();
29+
const modularMessaging = getMessaging();
30+
31+
describe('Messaging compat interop', () => {
32+
it('Messaging compat instance references modular Messaging instance', () => {
33+
expect(getModularInstance(compatMessaging)).to.equal(modularMessaging);
34+
});
35+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "firebase-compat-interop-test",
3+
"private": true,
4+
"version": "0.1.0",
5+
"scripts": {
6+
"test": "karma start --single-run",
7+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
8+
"test:debug": "karma start --browsers Chrome --auto-watch"
9+
},
10+
"dependencies": {
11+
"@firebase/app-exp": "0.0.900",
12+
"@firebase/app-compat": "0.0.900",
13+
"@firebase/analytics-exp": "0.0.900",
14+
"@firebase/analytics-compat": "0.0.900",
15+
"@firebase/auth-exp": "0.0.900",
16+
"@firebase/auth-compat": "0.0.900",
17+
"@firebase/functions-exp": "0.0.900",
18+
"@firebase/functions-compat": "0.0.900",
19+
"@firebase/messaging-exp": "0.0.900",
20+
"@firebase/messaging-compat": "0.0.900",
21+
"@firebase/performance-exp": "0.0.900",
22+
"@firebase/performance-compat": "0.0.900",
23+
"@firebase/remote-config-exp": "0.0.900",
24+
"@firebase/remote-config-compat": "0.0.900"
25+
},
26+
"devDependencies": {
27+
"typescript": "4.2.2"
28+
}
29+
}

0 commit comments

Comments
 (0)