@firebase/messaging-compat
Advanced tools
Comparing version 0.0.900-exp.f8e97019f to 0.1.0-202171919375
@@ -7,2 +7,3 @@ 'use strict'; | ||
var messaging = require('@firebase/messaging'); | ||
var sw = require('@firebase/messaging/sw'); | ||
@@ -14,3 +15,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var name = "@firebase/messaging-compat"; | ||
var version = "0.0.900"; | ||
var version = "0.1.0-202171919375"; | ||
@@ -33,32 +34,30 @@ /** | ||
*/ | ||
var MessagingCompat = /** @class */ (function () { | ||
function MessagingCompat(app, messaging) { | ||
var MessagingCompatImpl = /** @class */ (function () { | ||
function MessagingCompatImpl(app, _delegate) { | ||
this.app = app; | ||
this.messaging = messaging; | ||
this.onBackgroundMessageHandler = null; | ||
this.onMessageHandler = null; | ||
this._delegate = _delegate; | ||
this.app = app; | ||
this.messaging = messaging; | ||
this._delegate = _delegate; | ||
} | ||
MessagingCompat.prototype.getToken = function (options) { | ||
MessagingCompatImpl.prototype.getToken = function (options) { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
return tslib.__generator(this, function (_a) { | ||
return [2 /*return*/, messaging.getToken(this.messaging, options)]; | ||
return [2 /*return*/, messaging.getToken(this._delegate, options)]; | ||
}); | ||
}); | ||
}; | ||
MessagingCompat.prototype.deleteToken = function () { | ||
MessagingCompatImpl.prototype.deleteToken = function () { | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
return tslib.__generator(this, function (_a) { | ||
return [2 /*return*/, messaging.deleteToken(this.messaging)]; | ||
return [2 /*return*/, messaging.deleteToken(this._delegate)]; | ||
}); | ||
}); | ||
}; | ||
MessagingCompat.prototype.onMessage = function (nextOrObserver) { | ||
return messaging.onMessage(this.messaging, nextOrObserver); | ||
MessagingCompatImpl.prototype.onMessage = function (nextOrObserver) { | ||
return messaging.onMessage(this._delegate, nextOrObserver); | ||
}; | ||
MessagingCompat.prototype.onBackgroundMessage = function (nextOrObserver) { | ||
return messaging.onBackgroundMessage(this.messaging, nextOrObserver); | ||
MessagingCompatImpl.prototype.onBackgroundMessage = function (nextOrObserver) { | ||
return sw.onBackgroundMessage(this._delegate, nextOrObserver); | ||
}; | ||
return MessagingCompat; | ||
return MessagingCompatImpl; | ||
}()); | ||
@@ -83,3 +82,10 @@ | ||
var messagingCompatFactory = function (container) { | ||
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate()); | ||
if (!!navigator) { | ||
// in window | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate()); | ||
} | ||
else { | ||
// in sw | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate()); | ||
} | ||
}; | ||
@@ -86,0 +92,0 @@ function registerMessagingCompat() { |
import firebase from '@firebase/app-compat'; | ||
import { Component } from '@firebase/component'; | ||
import { __awaiter, __generator } from 'tslib'; | ||
import { getToken, deleteToken, onMessage, onBackgroundMessage } from '@firebase/messaging'; | ||
import { getToken, deleteToken, onMessage } from '@firebase/messaging'; | ||
import { onBackgroundMessage } from '@firebase/messaging/sw'; | ||
var name = "@firebase/messaging-compat"; | ||
var version = "0.0.900"; | ||
var version = "0.1.0-202171919375"; | ||
@@ -25,32 +26,30 @@ /** | ||
*/ | ||
var MessagingCompat = /** @class */ (function () { | ||
function MessagingCompat(app, messaging) { | ||
var MessagingCompatImpl = /** @class */ (function () { | ||
function MessagingCompatImpl(app, _delegate) { | ||
this.app = app; | ||
this.messaging = messaging; | ||
this.onBackgroundMessageHandler = null; | ||
this.onMessageHandler = null; | ||
this._delegate = _delegate; | ||
this.app = app; | ||
this.messaging = messaging; | ||
this._delegate = _delegate; | ||
} | ||
MessagingCompat.prototype.getToken = function (options) { | ||
MessagingCompatImpl.prototype.getToken = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, getToken(this.messaging, options)]; | ||
return [2 /*return*/, getToken(this._delegate, options)]; | ||
}); | ||
}); | ||
}; | ||
MessagingCompat.prototype.deleteToken = function () { | ||
MessagingCompatImpl.prototype.deleteToken = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, deleteToken(this.messaging)]; | ||
return [2 /*return*/, deleteToken(this._delegate)]; | ||
}); | ||
}); | ||
}; | ||
MessagingCompat.prototype.onMessage = function (nextOrObserver) { | ||
return onMessage(this.messaging, nextOrObserver); | ||
MessagingCompatImpl.prototype.onMessage = function (nextOrObserver) { | ||
return onMessage(this._delegate, nextOrObserver); | ||
}; | ||
MessagingCompat.prototype.onBackgroundMessage = function (nextOrObserver) { | ||
return onBackgroundMessage(this.messaging, nextOrObserver); | ||
MessagingCompatImpl.prototype.onBackgroundMessage = function (nextOrObserver) { | ||
return onBackgroundMessage(this._delegate, nextOrObserver); | ||
}; | ||
return MessagingCompat; | ||
return MessagingCompatImpl; | ||
}()); | ||
@@ -75,3 +74,10 @@ | ||
var messagingCompatFactory = function (container) { | ||
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate()); | ||
if (!!navigator) { | ||
// in window | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate()); | ||
} | ||
else { | ||
// in sw | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate()); | ||
} | ||
}; | ||
@@ -78,0 +84,0 @@ function registerMessagingCompat() { |
import firebase from '@firebase/app-compat'; | ||
import { Component } from '@firebase/component'; | ||
import { getToken, deleteToken, onMessage, onBackgroundMessage } from '@firebase/messaging'; | ||
import { getToken, deleteToken, onMessage } from '@firebase/messaging'; | ||
import { onBackgroundMessage } from '@firebase/messaging/sw'; | ||
const name = "@firebase/messaging-compat"; | ||
const version = "0.0.900"; | ||
const version = "0.1.0-202171919375"; | ||
@@ -24,22 +25,20 @@ /** | ||
*/ | ||
class MessagingCompat { | ||
constructor(app, messaging) { | ||
class MessagingCompatImpl { | ||
constructor(app, _delegate) { | ||
this.app = app; | ||
this.messaging = messaging; | ||
this.onBackgroundMessageHandler = null; | ||
this.onMessageHandler = null; | ||
this._delegate = _delegate; | ||
this.app = app; | ||
this.messaging = messaging; | ||
this._delegate = _delegate; | ||
} | ||
async getToken(options) { | ||
return getToken(this.messaging, options); | ||
return getToken(this._delegate, options); | ||
} | ||
async deleteToken() { | ||
return deleteToken(this.messaging); | ||
return deleteToken(this._delegate); | ||
} | ||
onMessage(nextOrObserver) { | ||
return onMessage(this.messaging, nextOrObserver); | ||
return onMessage(this._delegate, nextOrObserver); | ||
} | ||
onBackgroundMessage(nextOrObserver) { | ||
return onBackgroundMessage(this.messaging, nextOrObserver); | ||
return onBackgroundMessage(this._delegate, nextOrObserver); | ||
} | ||
@@ -65,3 +64,10 @@ } | ||
const messagingCompatFactory = (container) => { | ||
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate()); | ||
if (!!navigator) { | ||
// in window | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate()); | ||
} | ||
else { | ||
// in sw | ||
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate()); | ||
} | ||
}; | ||
@@ -68,0 +74,0 @@ function registerMessagingCompat() { |
@@ -32,1 +32,7 @@ /** | ||
} | ||
import { FirebaseApp as FirebaseAppCompat } from "@firebase/app-compat"; | ||
import { Messaging } from "@firebase/messaging"; | ||
declare module "@firebase/messaging" { | ||
function getMessaging(app?: FirebaseAppCompat): Messaging; | ||
} |
@@ -18,12 +18,18 @@ /** | ||
import { FirebaseApp as AppCompat, _FirebaseService } from '@firebase/app-compat'; | ||
import { FirebaseMessaging, MessagePayload } from "@firebase/messaging"; | ||
import { Messaging, MessagePayload } from '@firebase/messaging'; | ||
import { NextFn, Observer, Unsubscribe } from '@firebase/util'; | ||
export declare class MessagingCompat implements _FirebaseService { | ||
export interface MessagingCompat { | ||
getToken(options?: { | ||
vapidKey?: string; | ||
serviceWorkerRegistration?: ServiceWorkerRegistration; | ||
}): Promise<string>; | ||
deleteToken(): Promise<boolean>; | ||
onMessage(nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe; | ||
onBackgroundMessage(nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe; | ||
} | ||
export declare function isSupported(): boolean; | ||
export declare class MessagingCompatImpl implements MessagingCompat, _FirebaseService { | ||
readonly app: AppCompat; | ||
readonly messaging: FirebaseMessaging; | ||
swRegistration?: ServiceWorkerRegistration; | ||
vapidKey?: string; | ||
onBackgroundMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null; | ||
onMessageHandler: NextFn<MessagePayload> | Observer<MessagePayload> | null; | ||
constructor(app: AppCompat, messaging: FirebaseMessaging); | ||
readonly _delegate: Messaging; | ||
constructor(app: AppCompat, _delegate: Messaging); | ||
getToken(options?: { | ||
@@ -30,0 +36,0 @@ vapidKey?: string; |
@@ -17,8 +17,8 @@ /** | ||
*/ | ||
import { MessagingCompat } from './messaging-compat'; | ||
import { MessagingCompatImpl } from './messaging-compat'; | ||
declare module '@firebase/component' { | ||
interface NameServiceMapping { | ||
'messaging-compat': MessagingCompat; | ||
'messaging-compat': MessagingCompatImpl; | ||
} | ||
} | ||
export declare function registerMessagingCompat(): void; |
@@ -18,4 +18,4 @@ /** | ||
import { FirebaseApp } from '@firebase/app-compat'; | ||
import { FirebaseMessaging } from "@firebase/messaging"; | ||
import { Messaging } from '@firebase/messaging'; | ||
export declare function getFakeApp(): FirebaseApp; | ||
export declare function getFakeModularMessaging(): FirebaseMessaging; | ||
export declare function getFakeModularMessaging(): Messaging; |
{ | ||
"name": "@firebase/messaging-compat", | ||
"version": "0.0.900-exp.f8e97019f", | ||
"version": "0.1.0-202171919375", | ||
"license": "Apache-2.0", | ||
"description": "", | ||
"private": false, | ||
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"esm2017": "dist/index.esm2017.js", | ||
"browser": "dist/index.esm2017.js", | ||
"module": "dist/index.esm2017.js", | ||
"typings": "dist/src/index.d.ts", | ||
@@ -21,3 +20,3 @@ "sw": "dist/index.sw.esm2017.js", | ||
"build:deps": "lerna run --scope @firebase/'messaging-compat' --include-dependencies build", | ||
"build:release": "rollup -c rollup.config.release.js", | ||
"build:release": "yarn build && yarn add-compat-overloads", | ||
"dev": "rollup -c -w", | ||
@@ -28,18 +27,18 @@ "test": "run-p test:karma", | ||
"test:debug": "karma start --browsers=Chrome --auto-watch", | ||
"type-check": "tsc --noEmit" | ||
"type-check": "tsc --noEmit", | ||
"add-compat-overloads": "ts-node-script ../../scripts/exp/create-overloads.ts -i ../messaging/dist/index-public.d.ts -o dist/src/index.d.ts -a -r FirebaseMessaging:MessagingCompat -r FirebaseApp:FirebaseAppCompat --moduleToEnhance @firebase/messaging" | ||
}, | ||
"peerDependencies": { | ||
"@firebase/app-compat": "0.0.900-exp.f8e97019f" | ||
"@firebase/app-compat": "0.1.0-202171919375" | ||
}, | ||
"dependencies": { | ||
"@firebase/messaging": "0.0.900-exp.f8e97019f", | ||
"@firebase/component": "0.2.1", | ||
"@firebase/installations": "0.0.900-exp.f8e97019f", | ||
"@firebase/util": "0.4.0", | ||
"@firebase/messaging": "0.9.0-202171919375", | ||
"@firebase/component": "0.5.6-202171919375", | ||
"@firebase/util": "1.3.0-202171919375", | ||
"tslib": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@firebase/app-compat": "0.0.900", | ||
"@firebase/app-compat": "0.1.0-202171919375", | ||
"@rollup/plugin-json": "4.1.0", | ||
"rollup-plugin-typescript2": "0.29.0", | ||
"rollup-plugin-typescript2": "0.30.0", | ||
"ts-essentials": "7.0.1", | ||
@@ -55,3 +54,4 @@ "typescript": "4.2.2" | ||
"url": "https://github.com/firebase/firebase-js-sdk/issues" | ||
} | ||
} | ||
}, | ||
"esm5": "dist/index.esm.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42882
5
430
+ Added@firebase/app@0.7.0-202171919375(transitive)
+ Added@firebase/app-compat@0.1.0-202171919375(transitive)
+ Added@firebase/component@0.5.6-202171919375(transitive)
+ Added@firebase/installations@0.5.0-202171919375(transitive)
+ Added@firebase/messaging@0.9.0-202171919375(transitive)
+ Added@firebase/util@1.3.0-202171919375(transitive)
- Removed@firebase/app@0.0.900-exp.f8e97019f(transitive)
- Removed@firebase/app-compat@0.0.900-exp.f8e97019f(transitive)
- Removed@firebase/component@0.2.1(transitive)
- Removed@firebase/installations@0.0.900-exp.f8e97019f(transitive)
- Removed@firebase/messaging@0.0.900-exp.f8e97019f(transitive)
- Removed@firebase/util@0.4.0(transitive)
- Removeddom-storage@2.1.0(transitive)
- Removedxmlhttprequest@1.8.0(transitive)