@firebase/messaging-compat 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.esm2017.js +1 -1
- package/dist/index.cjs.js +18 -28
- package/dist/index.cjs.js.map +1 -1
- package/package.json +5 -7
- package/dist/esm/index.esm.js +0 -144
- package/dist/esm/index.esm.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var firebase = require('@firebase/app-compat');
|
|
4
4
|
var component = require('@firebase/component');
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var messaging = require('@firebase/messaging');
|
|
7
6
|
var util = require('@firebase/util');
|
|
8
7
|
var sw = require('@firebase/messaging/sw');
|
|
@@ -11,8 +10,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
11
10
|
|
|
12
11
|
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const name = "@firebase/messaging-compat";
|
|
14
|
+
const version = "0.2.13";
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* @license
|
|
@@ -66,35 +65,26 @@ function isSwSupported() {
|
|
|
66
65
|
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
|
|
67
66
|
PushSubscription.prototype.hasOwnProperty('getKey'));
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
class MessagingCompatImpl {
|
|
69
|
+
constructor(app, _delegate) {
|
|
71
70
|
this.app = app;
|
|
72
71
|
this._delegate = _delegate;
|
|
73
72
|
this.app = app;
|
|
74
73
|
this._delegate = _delegate;
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
MessagingCompatImpl.prototype.deleteToken = function () {
|
|
84
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
85
|
-
return tslib.__generator(this, function (_a) {
|
|
86
|
-
return [2 /*return*/, messaging.deleteToken(this._delegate)];
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
MessagingCompatImpl.prototype.onMessage = function (nextOrObserver) {
|
|
75
|
+
async getToken(options) {
|
|
76
|
+
return messaging.getToken(this._delegate, options);
|
|
77
|
+
}
|
|
78
|
+
async deleteToken() {
|
|
79
|
+
return messaging.deleteToken(this._delegate);
|
|
80
|
+
}
|
|
81
|
+
onMessage(nextOrObserver) {
|
|
91
82
|
return messaging.onMessage(this._delegate, nextOrObserver);
|
|
92
|
-
}
|
|
93
|
-
|
|
83
|
+
}
|
|
84
|
+
onBackgroundMessage(nextOrObserver) {
|
|
94
85
|
return sw.onBackgroundMessage(this._delegate, nextOrObserver);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
98
88
|
|
|
99
89
|
/**
|
|
100
90
|
* @license
|
|
@@ -112,7 +102,7 @@ var MessagingCompatImpl = /** @class */ (function () {
|
|
|
112
102
|
* See the License for the specific language governing permissions and
|
|
113
103
|
* limitations under the License.
|
|
114
104
|
*/
|
|
115
|
-
|
|
105
|
+
const messagingCompatFactory = (container) => {
|
|
116
106
|
if (self && 'ServiceWorkerGlobalScope' in self) {
|
|
117
107
|
// in sw
|
|
118
108
|
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
|
|
@@ -122,8 +112,8 @@ var messagingCompatFactory = function (container) {
|
|
|
122
112
|
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
|
|
123
113
|
}
|
|
124
114
|
};
|
|
125
|
-
|
|
126
|
-
isSupported
|
|
115
|
+
const NAMESPACE_EXPORTS = {
|
|
116
|
+
isSupported
|
|
127
117
|
};
|
|
128
118
|
function registerMessagingCompat() {
|
|
129
119
|
firebase__default["default"].INTERNAL.registerComponent(new component.Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/messaging-compat.ts","../src/registerMessagingCompat.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n FirebaseApp as AppCompat,\n _FirebaseService\n} from '@firebase/app-compat';\nimport {\n Messaging,\n MessagePayload,\n deleteToken,\n getToken,\n onMessage\n} from '@firebase/messaging';\nimport {\n areCookiesEnabled,\n isIndexedDBAvailable,\n NextFn,\n Observer,\n Unsubscribe\n} from '@firebase/util';\n\nimport { onBackgroundMessage } from '@firebase/messaging/sw';\n\nexport interface MessagingCompat {\n getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string>;\n\n deleteToken(): Promise<boolean>;\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n}\n\nexport function isSupported(): boolean {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // Running in ServiceWorker context\n return isSwSupported();\n } else {\n // Assume we are in the window context.\n return isWindowSupported();\n }\n}\n\n/**\n * Checks to see if the required APIs exist.\n * Unlike the modular version, it does not check if IndexedDB.open() is allowed\n * in order to keep isSupported() synchronous and maintain v8 compatibility.\n */\nfunction isWindowSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n isIndexedDBAvailable() &&\n areCookiesEnabled() &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window &&\n 'Notification' in window &&\n 'fetch' in window &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\n/**\n * Checks to see if the required APIs exist within SW Context.\n */\nfunction isSwSupported(): boolean {\n return (\n isIndexedDBAvailable() &&\n 'PushManager' in self &&\n 'Notification' in self &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\nexport class MessagingCompatImpl implements MessagingCompat, _FirebaseService {\n constructor(readonly app: AppCompat, readonly _delegate: Messaging) {\n this.app = app;\n this._delegate = _delegate;\n }\n\n async getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string> {\n return getToken(this._delegate, options);\n }\n\n async deleteToken(): Promise<boolean> {\n return deleteToken(this._delegate);\n }\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onMessage(this._delegate, nextOrObserver);\n }\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onBackgroundMessage(this._delegate, nextOrObserver);\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { MessagingCompatImpl, isSupported } from './messaging-compat';\nimport firebase, { _FirebaseNamespace } from '@firebase/app-compat';\n\ndeclare module '@firebase/component' {\n interface NameServiceMapping {\n 'messaging-compat': MessagingCompatImpl;\n }\n}\n\nconst messagingCompatFactory: InstanceFactory<'messaging-compat'> = (\n container: ComponentContainer\n) => {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // in sw\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging-sw').getImmediate()\n );\n } else {\n // in window\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging').getImmediate()\n );\n }\n};\n\nconst NAMESPACE_EXPORTS = {\n isSupported\n};\n\nexport function registerMessagingCompat(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'messaging-compat',\n messagingCompatFactory,\n ComponentType.PUBLIC\n ).setServiceProps(NAMESPACE_EXPORTS)\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { name, version } from '../package.json';\n\nimport firebase from '@firebase/app-compat';\nimport { registerMessagingCompat } from './registerMessagingCompat';\nimport { MessagingCompat } from './messaging-compat';\n\nregisterMessagingCompat();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerMessaging`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n messaging: {\n (app?: FirebaseApp): MessagingCompat;\n isSupported(): boolean;\n };\n }\n interface FirebaseApp {\n messaging(): MessagingCompat;\n }\n}\n"],"names":["isIndexedDBAvailable","areCookiesEnabled","getToken","deleteToken","onMessage","onBackgroundMessage","firebase","Component"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/messaging-compat.ts","../src/registerMessagingCompat.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n FirebaseApp as AppCompat,\n _FirebaseService\n} from '@firebase/app-compat';\nimport {\n Messaging,\n MessagePayload,\n deleteToken,\n getToken,\n onMessage\n} from '@firebase/messaging';\nimport {\n areCookiesEnabled,\n isIndexedDBAvailable,\n NextFn,\n Observer,\n Unsubscribe\n} from '@firebase/util';\n\nimport { onBackgroundMessage } from '@firebase/messaging/sw';\n\nexport interface MessagingCompat {\n getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string>;\n\n deleteToken(): Promise<boolean>;\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n}\n\nexport function isSupported(): boolean {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // Running in ServiceWorker context\n return isSwSupported();\n } else {\n // Assume we are in the window context.\n return isWindowSupported();\n }\n}\n\n/**\n * Checks to see if the required APIs exist.\n * Unlike the modular version, it does not check if IndexedDB.open() is allowed\n * in order to keep isSupported() synchronous and maintain v8 compatibility.\n */\nfunction isWindowSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n isIndexedDBAvailable() &&\n areCookiesEnabled() &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window &&\n 'Notification' in window &&\n 'fetch' in window &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\n/**\n * Checks to see if the required APIs exist within SW Context.\n */\nfunction isSwSupported(): boolean {\n return (\n isIndexedDBAvailable() &&\n 'PushManager' in self &&\n 'Notification' in self &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\nexport class MessagingCompatImpl implements MessagingCompat, _FirebaseService {\n constructor(readonly app: AppCompat, readonly _delegate: Messaging) {\n this.app = app;\n this._delegate = _delegate;\n }\n\n async getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string> {\n return getToken(this._delegate, options);\n }\n\n async deleteToken(): Promise<boolean> {\n return deleteToken(this._delegate);\n }\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onMessage(this._delegate, nextOrObserver);\n }\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onBackgroundMessage(this._delegate, nextOrObserver);\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { MessagingCompatImpl, isSupported } from './messaging-compat';\nimport firebase, { _FirebaseNamespace } from '@firebase/app-compat';\n\ndeclare module '@firebase/component' {\n interface NameServiceMapping {\n 'messaging-compat': MessagingCompatImpl;\n }\n}\n\nconst messagingCompatFactory: InstanceFactory<'messaging-compat'> = (\n container: ComponentContainer\n) => {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // in sw\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging-sw').getImmediate()\n );\n } else {\n // in window\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging').getImmediate()\n );\n }\n};\n\nconst NAMESPACE_EXPORTS = {\n isSupported\n};\n\nexport function registerMessagingCompat(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'messaging-compat',\n messagingCompatFactory,\n ComponentType.PUBLIC\n ).setServiceProps(NAMESPACE_EXPORTS)\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { name, version } from '../package.json';\n\nimport firebase from '@firebase/app-compat';\nimport { registerMessagingCompat } from './registerMessagingCompat';\nimport { MessagingCompat } from './messaging-compat';\n\nregisterMessagingCompat();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerMessaging`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n messaging: {\n (app?: FirebaseApp): MessagingCompat;\n isSupported(): boolean;\n };\n }\n interface FirebaseApp {\n messaging(): MessagingCompat;\n }\n}\n"],"names":["isIndexedDBAvailable","areCookiesEnabled","getToken","deleteTo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EAAE,OAAO,CAAC;;"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/messaging-compat",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
7
7
|
"main": "dist/index.cjs.js",
|
|
8
8
|
"browser": "dist/esm/index.esm2017.js",
|
|
9
9
|
"module": "dist/esm/index.esm2017.js",
|
|
10
|
-
"esm5": "dist/esm/index.esm.js",
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
12
|
"types": "./dist/src/index.d.ts",
|
|
14
13
|
"require": "./dist/index.cjs.js",
|
|
15
|
-
"esm5": "./dist/esm/index.esm.js",
|
|
16
14
|
"default": "./dist/esm/index.esm2017.js"
|
|
17
15
|
},
|
|
18
16
|
"./package.json": "./package.json"
|
|
@@ -40,13 +38,13 @@
|
|
|
40
38
|
"@firebase/app-compat": "0.x"
|
|
41
39
|
},
|
|
42
40
|
"dependencies": {
|
|
43
|
-
"@firebase/messaging": "0.12.
|
|
44
|
-
"@firebase/component": "0.6.
|
|
45
|
-
"@firebase/util": "1.10.
|
|
41
|
+
"@firebase/messaging": "0.12.13",
|
|
42
|
+
"@firebase/component": "0.6.10",
|
|
43
|
+
"@firebase/util": "1.10.1",
|
|
46
44
|
"tslib": "^2.1.0"
|
|
47
45
|
},
|
|
48
46
|
"devDependencies": {
|
|
49
|
-
"@firebase/app-compat": "0.2.
|
|
47
|
+
"@firebase/app-compat": "0.2.44",
|
|
50
48
|
"@rollup/plugin-json": "4.1.0",
|
|
51
49
|
"rollup-plugin-typescript2": "0.31.2",
|
|
52
50
|
"ts-essentials": "9.3.0",
|
package/dist/esm/index.esm.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import firebase from '@firebase/app-compat';
|
|
2
|
-
import { Component } from '@firebase/component';
|
|
3
|
-
import { __awaiter, __generator } from 'tslib';
|
|
4
|
-
import { getToken, deleteToken, onMessage } from '@firebase/messaging';
|
|
5
|
-
import { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';
|
|
6
|
-
import { onBackgroundMessage } from '@firebase/messaging/sw';
|
|
7
|
-
|
|
8
|
-
var name = "@firebase/messaging-compat";
|
|
9
|
-
var version = "0.2.12";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @license
|
|
13
|
-
* Copyright 2020 Google LLC
|
|
14
|
-
*
|
|
15
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* you may not use this file except in compliance with the License.
|
|
17
|
-
* You may obtain a copy of the License at
|
|
18
|
-
*
|
|
19
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
-
* See the License for the specific language governing permissions and
|
|
25
|
-
* limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
function isSupported() {
|
|
28
|
-
if (self && 'ServiceWorkerGlobalScope' in self) {
|
|
29
|
-
// Running in ServiceWorker context
|
|
30
|
-
return isSwSupported();
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// Assume we are in the window context.
|
|
34
|
-
return isWindowSupported();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Checks to see if the required APIs exist.
|
|
39
|
-
* Unlike the modular version, it does not check if IndexedDB.open() is allowed
|
|
40
|
-
* in order to keep isSupported() synchronous and maintain v8 compatibility.
|
|
41
|
-
*/
|
|
42
|
-
function isWindowSupported() {
|
|
43
|
-
return (typeof window !== 'undefined' &&
|
|
44
|
-
isIndexedDBAvailable() &&
|
|
45
|
-
areCookiesEnabled() &&
|
|
46
|
-
'serviceWorker' in navigator &&
|
|
47
|
-
'PushManager' in window &&
|
|
48
|
-
'Notification' in window &&
|
|
49
|
-
'fetch' in window &&
|
|
50
|
-
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
|
|
51
|
-
PushSubscription.prototype.hasOwnProperty('getKey'));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Checks to see if the required APIs exist within SW Context.
|
|
55
|
-
*/
|
|
56
|
-
function isSwSupported() {
|
|
57
|
-
return (isIndexedDBAvailable() &&
|
|
58
|
-
'PushManager' in self &&
|
|
59
|
-
'Notification' in self &&
|
|
60
|
-
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
|
|
61
|
-
PushSubscription.prototype.hasOwnProperty('getKey'));
|
|
62
|
-
}
|
|
63
|
-
var MessagingCompatImpl = /** @class */ (function () {
|
|
64
|
-
function MessagingCompatImpl(app, _delegate) {
|
|
65
|
-
this.app = app;
|
|
66
|
-
this._delegate = _delegate;
|
|
67
|
-
this.app = app;
|
|
68
|
-
this._delegate = _delegate;
|
|
69
|
-
}
|
|
70
|
-
MessagingCompatImpl.prototype.getToken = function (options) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
return [2 /*return*/, getToken(this._delegate, options)];
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
MessagingCompatImpl.prototype.deleteToken = function () {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
return [2 /*return*/, deleteToken(this._delegate)];
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
MessagingCompatImpl.prototype.onMessage = function (nextOrObserver) {
|
|
85
|
-
return onMessage(this._delegate, nextOrObserver);
|
|
86
|
-
};
|
|
87
|
-
MessagingCompatImpl.prototype.onBackgroundMessage = function (nextOrObserver) {
|
|
88
|
-
return onBackgroundMessage(this._delegate, nextOrObserver);
|
|
89
|
-
};
|
|
90
|
-
return MessagingCompatImpl;
|
|
91
|
-
}());
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @license
|
|
95
|
-
* Copyright 2020 Google LLC
|
|
96
|
-
*
|
|
97
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
98
|
-
* you may not use this file except in compliance with the License.
|
|
99
|
-
* You may obtain a copy of the License at
|
|
100
|
-
*
|
|
101
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
102
|
-
*
|
|
103
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
104
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
105
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
106
|
-
* See the License for the specific language governing permissions and
|
|
107
|
-
* limitations under the License.
|
|
108
|
-
*/
|
|
109
|
-
var messagingCompatFactory = function (container) {
|
|
110
|
-
if (self && 'ServiceWorkerGlobalScope' in self) {
|
|
111
|
-
// in sw
|
|
112
|
-
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
// in window
|
|
116
|
-
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
var NAMESPACE_EXPORTS = {
|
|
120
|
-
isSupported: isSupported
|
|
121
|
-
};
|
|
122
|
-
function registerMessagingCompat() {
|
|
123
|
-
firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @license
|
|
128
|
-
* Copyright 2020 Google LLC
|
|
129
|
-
*
|
|
130
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
131
|
-
* you may not use this file except in compliance with the License.
|
|
132
|
-
* You may obtain a copy of the License at
|
|
133
|
-
*
|
|
134
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
135
|
-
*
|
|
136
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
137
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
138
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
139
|
-
* See the License for the specific language governing permissions and
|
|
140
|
-
* limitations under the License.
|
|
141
|
-
*/
|
|
142
|
-
registerMessagingCompat();
|
|
143
|
-
firebase.registerVersion(name, version);
|
|
144
|
-
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/messaging-compat.ts","../../src/registerMessagingCompat.ts","../../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n FirebaseApp as AppCompat,\n _FirebaseService\n} from '@firebase/app-compat';\nimport {\n Messaging,\n MessagePayload,\n deleteToken,\n getToken,\n onMessage\n} from '@firebase/messaging';\nimport {\n areCookiesEnabled,\n isIndexedDBAvailable,\n NextFn,\n Observer,\n Unsubscribe\n} from '@firebase/util';\n\nimport { onBackgroundMessage } from '@firebase/messaging/sw';\n\nexport interface MessagingCompat {\n getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string>;\n\n deleteToken(): Promise<boolean>;\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe;\n}\n\nexport function isSupported(): boolean {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // Running in ServiceWorker context\n return isSwSupported();\n } else {\n // Assume we are in the window context.\n return isWindowSupported();\n }\n}\n\n/**\n * Checks to see if the required APIs exist.\n * Unlike the modular version, it does not check if IndexedDB.open() is allowed\n * in order to keep isSupported() synchronous and maintain v8 compatibility.\n */\nfunction isWindowSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n isIndexedDBAvailable() &&\n areCookiesEnabled() &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window &&\n 'Notification' in window &&\n 'fetch' in window &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\n/**\n * Checks to see if the required APIs exist within SW Context.\n */\nfunction isSwSupported(): boolean {\n return (\n isIndexedDBAvailable() &&\n 'PushManager' in self &&\n 'Notification' in self &&\n ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&\n PushSubscription.prototype.hasOwnProperty('getKey')\n );\n}\n\nexport class MessagingCompatImpl implements MessagingCompat, _FirebaseService {\n constructor(readonly app: AppCompat, readonly _delegate: Messaging) {\n this.app = app;\n this._delegate = _delegate;\n }\n\n async getToken(options?: {\n vapidKey?: string;\n serviceWorkerRegistration?: ServiceWorkerRegistration;\n }): Promise<string> {\n return getToken(this._delegate, options);\n }\n\n async deleteToken(): Promise<boolean> {\n return deleteToken(this._delegate);\n }\n\n onMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onMessage(this._delegate, nextOrObserver);\n }\n\n onBackgroundMessage(\n nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>\n ): Unsubscribe {\n return onBackgroundMessage(this._delegate, nextOrObserver);\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Component,\n ComponentContainer,\n ComponentType,\n InstanceFactory\n} from '@firebase/component';\nimport { MessagingCompatImpl, isSupported } from './messaging-compat';\nimport firebase, { _FirebaseNamespace } from '@firebase/app-compat';\n\ndeclare module '@firebase/component' {\n interface NameServiceMapping {\n 'messaging-compat': MessagingCompatImpl;\n }\n}\n\nconst messagingCompatFactory: InstanceFactory<'messaging-compat'> = (\n container: ComponentContainer\n) => {\n if (self && 'ServiceWorkerGlobalScope' in self) {\n // in sw\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging-sw').getImmediate()\n );\n } else {\n // in window\n return new MessagingCompatImpl(\n container.getProvider('app-compat').getImmediate(),\n container.getProvider('messaging').getImmediate()\n );\n }\n};\n\nconst NAMESPACE_EXPORTS = {\n isSupported\n};\n\nexport function registerMessagingCompat(): void {\n (firebase as _FirebaseNamespace).INTERNAL.registerComponent(\n new Component(\n 'messaging-compat',\n messagingCompatFactory,\n ComponentType.PUBLIC\n ).setServiceProps(NAMESPACE_EXPORTS)\n );\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { name, version } from '../package.json';\n\nimport firebase from '@firebase/app-compat';\nimport { registerMessagingCompat } from './registerMessagingCompat';\nimport { MessagingCompat } from './messaging-compat';\n\nregisterMessagingCompat();\nfirebase.registerVersion(name, version);\n\n/**\n * Define extension behavior of `registerMessaging`\n */\ndeclare module '@firebase/app-compat' {\n interface FirebaseNamespace {\n messaging: {\n (app?: FirebaseApp): MessagingCompat;\n isSupported(): boolean;\n };\n }\n interface FirebaseApp {\n messaging(): MessagingCompat;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;SAwCa,WAAW,GAAA;AACzB,IAAA,IAAI,IAAI,IAAI,0BAA0B,IAAI,IAAI,EAAE;;QAE9C,OAAO,aAAa,EAAE,CAAC;AACxB,KAAA;AAAM,SAAA;;QAEL,OAAO,iBAAiB,EAAE,CAAC;AAC5B,KAAA;AACH,CAAC;AAED;;;;AAIG;AACH,SAAS,iBAAiB,GAAA;AACxB,IAAA,QACE,OAAO,MAAM,KAAK,WAAW;AAC7B,QAAA,oBAAoB,EAAE;AACtB,QAAA,iBAAiB,EAAE;AACnB,QAAA,eAAe,IAAI,SAAS;AAC5B,QAAA,aAAa,IAAI,MAAM;AACvB,QAAA,cAAc,IAAI,MAAM;AACxB,QAAA,OAAO,IAAI,MAAM;AACjB,QAAA,yBAAyB,CAAC,SAAS,CAAC,cAAc,CAAC,kBAAkB,CAAC;QACtE,gBAAgB,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,EACnD;AACJ,CAAC;AAED;;AAEG;AACH,SAAS,aAAa,GAAA;IACpB,QACE,oBAAoB,EAAE;AACtB,QAAA,aAAa,IAAI,IAAI;AACrB,QAAA,cAAc,IAAI,IAAI;AACtB,QAAA,yBAAyB,CAAC,SAAS,CAAC,cAAc,CAAC,kBAAkB,CAAC;QACtE,gBAAgB,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,EACnD;AACJ,CAAC;AAED,IAAA,m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