Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/messaging-compat

Package Overview
Dependencies
Maintainers
5
Versions
1119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/messaging-compat - npm Package Compare versions

Comparing version 0.0.900-exp.f8e97019f to 0.1.0-20217250818

80

dist/index.cjs.js

@@ -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-20217250818";

@@ -33,32 +34,65 @@ /**

*/
var MessagingCompat = /** @class */ (function () {
function MessagingCompat(app, messaging) {
function isSupported() {
if (self && 'ServiceWorkerGlobalScope' in self) {
// Running in ServiceWorker context
return isSwSupported();
}
else {
// Assume we are in the window context.
return isWindowSupported();
}
}
/**
* Checks to see if the required APIs exist.
*/
function isWindowSupported() {
return ('indexedDB' in window &&
indexedDB !== null &&
navigator.cookieEnabled &&
'serviceWorker' in navigator &&
'PushManager' in window &&
'Notification' in window &&
'fetch' in window &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
/**
* Checks to see if the required APIs exist within SW Context.
*/
function isSwSupported() {
return ('indexedDB' in self &&
indexedDB !== null &&
'PushManager' in self &&
'Notification' in self &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
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,6 +117,16 @@

var messagingCompatFactory = function (container) {
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate());
if (self && 'ServiceWorkerGlobalScope' in self) {
// in sw
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
}
else {
// in window
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
}
};
var NAMESPACE_EXPORTS = {
isSupported: isSupported
};
function registerMessagingCompat() {
firebase__default['default'].INTERNAL.registerComponent(new component.Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */));
firebase__default['default'].INTERNAL.registerComponent(new component.Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
}

@@ -89,0 +133,0 @@

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-20217250818";

@@ -25,32 +26,65 @@ /**

*/
var MessagingCompat = /** @class */ (function () {
function MessagingCompat(app, messaging) {
function isSupported() {
if (self && 'ServiceWorkerGlobalScope' in self) {
// Running in ServiceWorker context
return isSwSupported();
}
else {
// Assume we are in the window context.
return isWindowSupported();
}
}
/**
* Checks to see if the required APIs exist.
*/
function isWindowSupported() {
return ('indexedDB' in window &&
indexedDB !== null &&
navigator.cookieEnabled &&
'serviceWorker' in navigator &&
'PushManager' in window &&
'Notification' in window &&
'fetch' in window &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
/**
* Checks to see if the required APIs exist within SW Context.
*/
function isSwSupported() {
return ('indexedDB' in self &&
indexedDB !== null &&
'PushManager' in self &&
'Notification' in self &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
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,6 +109,16 @@

var messagingCompatFactory = function (container) {
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate());
if (self && 'ServiceWorkerGlobalScope' in self) {
// in sw
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
}
else {
// in window
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
}
};
var NAMESPACE_EXPORTS = {
isSupported: isSupported
};
function registerMessagingCompat() {
firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */));
firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
}

@@ -81,0 +125,0 @@

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-20217250818";

@@ -24,22 +25,55 @@ /**

*/
class MessagingCompat {
constructor(app, messaging) {
function isSupported() {
if (self && 'ServiceWorkerGlobalScope' in self) {
// Running in ServiceWorker context
return isSwSupported();
}
else {
// Assume we are in the window context.
return isWindowSupported();
}
}
/**
* Checks to see if the required APIs exist.
*/
function isWindowSupported() {
return ('indexedDB' in window &&
indexedDB !== null &&
navigator.cookieEnabled &&
'serviceWorker' in navigator &&
'PushManager' in window &&
'Notification' in window &&
'fetch' in window &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
/**
* Checks to see if the required APIs exist within SW Context.
*/
function isSwSupported() {
return ('indexedDB' in self &&
indexedDB !== null &&
'PushManager' in self &&
'Notification' in self &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey'));
}
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,6 +99,16 @@ }

const messagingCompatFactory = (container) => {
return new MessagingCompat(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-exp').getImmediate());
if (self && 'ServiceWorkerGlobalScope' in self) {
// in sw
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
}
else {
// in window
return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
}
};
const NAMESPACE_EXPORTS = {
isSupported
};
function registerMessagingCompat() {
firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */));
firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
}

@@ -71,0 +115,0 @@

@@ -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-20217250818",
"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-20217250818"
},
"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-20217250818",
"@firebase/component": "0.5.6",
"@firebase/util": "1.3.0",
"tslib": "^2.1.0"
},
"devDependencies": {
"@firebase/app-compat": "0.0.900",
"@firebase/app-compat": "0.1.0-20217250818",
"@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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc