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

subscribable-things

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subscribable-things - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

build/es2019/factories/reports.d.ts

5

build/es2019/factories/media-query-match.js

@@ -1,3 +0,6 @@

export const createMediaQueryMatch = (window, wrapSubscribeFunction) => {
export const createMediaQueryMatch = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (mediaQueryString) => wrapSubscribeFunction((observer) => {
if (window === null || window.matchMedia === undefined) {
return emitNotSupportedError(observer);
}
const mediaQueryList = window.matchMedia(mediaQueryString);

@@ -4,0 +7,0 @@ observer.next(mediaQueryList.matches);

@@ -1,3 +0,6 @@

export const createMutations = (window, wrapSubscribeFunction) => {
export const createMutations = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (htmlElement, options) => wrapSubscribeFunction((observer) => {
if (window === null || window.MutationObserver === undefined) {
return emitNotSupportedError(observer);
}
const mutationObserver = new window.MutationObserver((records) => observer.next(records));

@@ -4,0 +7,0 @@ try {

8

build/es2019/factories/permission-state.js

@@ -1,3 +0,9 @@

export const createPermissionState = (window, wrapSubscribeFunction) => {
export const createPermissionState = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (permissionDescriptor) => wrapSubscribeFunction((observer) => {
if (window === null
|| window.navigator === undefined
|| window.navigator.permissions === undefined
|| window.navigator.permissions.query === undefined) {
return emitNotSupportedError(observer);
}
let isActive = true;

@@ -4,0 +10,0 @@ let unsubscribe = () => { isActive = false; };

@@ -0,2 +1,3 @@

// @todo TypeScript does not include type definitions for the Reporting API yet.
export const createWindow = () => (typeof window === 'undefined') ? null : window;
//# sourceMappingURL=/build/es2019/factories/window.js.map

@@ -0,1 +1,2 @@

export * from './interfaces/index';
export * from './types/index';

@@ -5,2 +6,3 @@ export declare const mediaQueryMatch: import("./types").TMediaQueryMatchFunction;

export declare const permissionState: import("./types").TPermissionStateFunction;
export declare const reports: import("./types").TReportsFunction;
//# sourceMappingURL=/build/es2019/module.d.ts.map

@@ -5,3 +5,6 @@ import { patch, toObserver } from 'rxjs-interop';

import { createPermissionState } from './factories/permission-state';
import { createReports } from './factories/reports';
import { createWindow } from './factories/window';
import { createWrapSubscribeFunction } from './factories/wrap-subscribe-function';
import { emitNotSupportedError } from './functions/emit-not-supported-error';
/*

@@ -11,7 +14,10 @@ * @todo Explicitly referencing the barrel file seems to be necessary when enabling the

*/
export * from './interfaces/index';
export * from './types/index';
const window = createWindow();
const wrapSubscribeFunction = createWrapSubscribeFunction(patch, toObserver);
export const mediaQueryMatch = createMediaQueryMatch(window, wrapSubscribeFunction);
export const mutations = createMutations(window, wrapSubscribeFunction);
export const permissionState = createPermissionState(window, wrapSubscribeFunction);
export const mediaQueryMatch = createMediaQueryMatch(emitNotSupportedError, window, wrapSubscribeFunction);
export const mutations = createMutations(emitNotSupportedError, window, wrapSubscribeFunction);
export const permissionState = createPermissionState(emitNotSupportedError, window, wrapSubscribeFunction);
export const reports = createReports(emitNotSupportedError, window, wrapSubscribeFunction);
//# sourceMappingURL=/build/es2019/module.js.map

@@ -0,1 +1,2 @@

export * from './emit-not-supported-error-function';
export * from './flexible-subscribe-function';

@@ -10,2 +11,4 @@ export * from './media-query-match-factory';

export * from './permission-state-function';
export * from './reports-factory';
export * from './reports-function';
export * from './subscribable-thing';

@@ -12,0 +15,0 @@ export * from './subscribe-function';

@@ -0,1 +1,2 @@

export * from './emit-not-supported-error-function';
export * from './flexible-subscribe-function';

@@ -10,2 +11,4 @@ export * from './media-query-match-factory';

export * from './permission-state-function';
export * from './reports-factory';
export * from './reports-function';
export * from './subscribable-thing';

@@ -12,0 +15,0 @@ export * from './subscribe-function';

@@ -0,4 +1,6 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TMediaQueryMatchFunction } from './media-query-match-function';
import { TWindow } from './window';
import { TWrapSubscribeFunctionFunction } from './wrap-subscribe-function-function';
export declare type TMediaQueryMatchFactory = (window: Window, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMediaQueryMatchFunction;
export declare type TMediaQueryMatchFactory = (emitNotSupportedError: TEmitNotSupportedErrorFunction, window: null | TWindow, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMediaQueryMatchFunction;
//# sourceMappingURL=/build/es2019/types/media-query-match-factory.d.ts.map

@@ -0,5 +1,6 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TMutationsFunction } from './mutations-function';
import { TWindow } from './window';
import { TWrapSubscribeFunctionFunction } from './wrap-subscribe-function-function';
export declare type TMutationsFactory = (window: TWindow, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMutationsFunction;
export declare type TMutationsFactory = (emitNotSupportedError: TEmitNotSupportedErrorFunction, window: null | TWindow, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMutationsFunction;
//# sourceMappingURL=/build/es2019/types/mutations-factory.d.ts.map

@@ -0,4 +1,6 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TPermissionStateFunction } from './permission-state-function';
import { TWindow } from './window';
import { TWrapSubscribeFunctionFunction } from './wrap-subscribe-function-function';
export declare type TPermissionStateFactory = (window: Window, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TPermissionStateFunction;
export declare type TPermissionStateFactory = (emitNotSupportedError: TEmitNotSupportedErrorFunction, window: null | TWindow, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TPermissionStateFunction;
//# sourceMappingURL=/build/es2019/types/permission-state-factory.d.ts.map

@@ -1,2 +0,8 @@

export declare type TWindow = Window & typeof globalThis;
import { IReport, IReportingObserver, IReportingObserverOptions } from '../interfaces';
export declare type TWindow = Window & typeof globalThis & {
ReportingObserver: {
prototype: IReportingObserver;
new (callback: (reports: IReport[]) => void, options?: IReportingObserverOptions): IReportingObserver;
};
};
//# sourceMappingURL=/build/es2019/types/window.d.ts.map

@@ -7,5 +7,9 @@ (function (global, factory) {

var createMediaQueryMatch = function createMediaQueryMatch(window, wrapSubscribeFunction) {
var createMediaQueryMatch = function createMediaQueryMatch(emitNotSupportedError, window, wrapSubscribeFunction) {
return function (mediaQueryString) {
return wrapSubscribeFunction(function (observer) {
if (window === null || window.matchMedia === undefined) {
return emitNotSupportedError(observer);
}
var mediaQueryList = window.matchMedia(mediaQueryString);

@@ -25,5 +29,9 @@ observer.next(mediaQueryList.matches);

var createMutations = function createMutations(window, wrapSubscribeFunction) {
var createMutations = function createMutations(emitNotSupportedError, window, wrapSubscribeFunction) {
return function (htmlElement, options) {
return wrapSubscribeFunction(function (observer) {
if (window === null || window.MutationObserver === undefined) {
return emitNotSupportedError(observer);
}
var mutationObserver = new window.MutationObserver(function (records) {

@@ -46,5 +54,9 @@ return observer.next(records);

var createPermissionState = function createPermissionState(window, wrapSubscribeFunction) {
var createPermissionState = function createPermissionState(emitNotSupportedError, window, wrapSubscribeFunction) {
return function (permissionDescriptor) {
return wrapSubscribeFunction(function (observer) {
if (window === null || window.navigator === undefined || window.navigator.permissions === undefined || window.navigator.permissions.query === undefined) {
return emitNotSupportedError(observer);
}
var isActive = true;

@@ -80,2 +92,25 @@

var createReports = function createReports(emitNotSupportedError, window, wrapSubscribeFunction) {
return function (options) {
return wrapSubscribeFunction(function (observer) {
if (window === null || window.ReportingObserver === undefined) {
return emitNotSupportedError(observer);
}
var reportingObserver = new window.ReportingObserver(function (reportList) {
return observer.next(reportList);
}, options);
reportingObserver.observe();
return function () {
return reportingObserver.disconnect();
};
});
};
};
// @todo TypeScript does not include type definitions for the Reporting API yet.
var createWindow = function createWindow() {
return typeof window === 'undefined' ? null : window;
};
var createWrapSubscribeFunction = function createWrapSubscribeFunction(patch, toObserver) {

@@ -110,6 +145,13 @@ var emptyFunction = function emptyFunction() {}; // tslint:disable-line:no-empty

var emitNotSupportedError = function emitNotSupportedError(observer) {
observer.error(new Error('The required browser API seems to be not supported.'));
return function () {}; // tslint:disable-line:no-empty
};
var window$1 = createWindow();
var wrapSubscribeFunction = createWrapSubscribeFunction(rxjsInterop.patch, rxjsInterop.toObserver);
var mediaQueryMatch = createMediaQueryMatch(window, wrapSubscribeFunction);
var mutations = createMutations(window, wrapSubscribeFunction);
var permissionState = createPermissionState(window, wrapSubscribeFunction);
var mediaQueryMatch = createMediaQueryMatch(emitNotSupportedError, window$1, wrapSubscribeFunction);
var mutations = createMutations(emitNotSupportedError, window$1, wrapSubscribeFunction);
var permissionState = createPermissionState(emitNotSupportedError, window$1, wrapSubscribeFunction);
var reports = createReports(emitNotSupportedError, window$1, wrapSubscribeFunction);

@@ -119,2 +161,3 @@ exports.mediaQueryMatch = mediaQueryMatch;

exports.permissionState = permissionState;
exports.reports = reports;

@@ -121,0 +164,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -88,3 +88,3 @@ {

"types": "build/es2019/module.d.ts",
"version": "1.0.0"
"version": "1.1.0"
}

@@ -79,2 +79,6 @@ # subscribable-things

This function is a wrapper for the [`query()`](https://developer.mozilla.org/docs/Web/API/Permissions/query) method of the Permissions APIs.
This function is a wrapper for the [`query()`](https://developer.mozilla.org/docs/Web/API/Permissions/query) method of the [Permissions API](https://w3c.github.io/permissions).
### reports(options: IReportingObserverOptions): SubscribableThing\<IReport[]>
This function is a wrapper for the [`ReportingObserver`](https://developer.mozilla.org/docs/Web/API/ReportingObserver) of the [Reporting API](https://w3c.github.io/reporting).
import { TMediaQueryMatchFactory } from '../types';
export const createMediaQueryMatch: TMediaQueryMatchFactory = (window, wrapSubscribeFunction) => {
export const createMediaQueryMatch: TMediaQueryMatchFactory = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (mediaQueryString) => wrapSubscribeFunction((observer) => {
if (window === null || window.matchMedia === undefined) {
return emitNotSupportedError(observer);
}
const mediaQueryList = window.matchMedia(mediaQueryString);

@@ -6,0 +10,0 @@

import { TMutationsFactory } from '../types';
export const createMutations: TMutationsFactory = (window, wrapSubscribeFunction) => {
export const createMutations: TMutationsFactory = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (htmlElement, options) => wrapSubscribeFunction((observer) => {
if (window === null || window.MutationObserver === undefined) {
return emitNotSupportedError(observer);
}
const mutationObserver = new window.MutationObserver((records) => observer.next(records));

@@ -6,0 +10,0 @@

import { TPermissionStateFactory } from '../types';
export const createPermissionState: TPermissionStateFactory = (window, wrapSubscribeFunction) => {
export const createPermissionState: TPermissionStateFactory = (emitNotSupportedError, window, wrapSubscribeFunction) => {
return (permissionDescriptor) => wrapSubscribeFunction((observer) => {
if (window === null
|| window.navigator === undefined
|| window.navigator.permissions === undefined
|| window.navigator.permissions.query === undefined) {
return emitNotSupportedError(observer);
}
let isActive = true;

@@ -6,0 +13,0 @@ let unsubscribe = () => { isActive = false; };

@@ -1,3 +0,4 @@

import { TWindowFactory } from '../types';
import { TWindow, TWindowFactory } from '../types';
export const createWindow: TWindowFactory = () => (typeof window === 'undefined') ? null : window;
// @todo TypeScript does not include type definitions for the Reporting API yet.
export const createWindow: TWindowFactory = () => (typeof window === 'undefined') ? null : <TWindow> window;

@@ -5,3 +5,6 @@ import { patch, toObserver } from 'rxjs-interop';

import { createPermissionState } from './factories/permission-state';
import { createReports } from './factories/reports';
import { createWindow } from './factories/window';
import { createWrapSubscribeFunction } from './factories/wrap-subscribe-function';
import { emitNotSupportedError } from './functions/emit-not-supported-error';

@@ -12,10 +15,14 @@ /*

*/
export * from './interfaces/index';
export * from './types/index';
const window = createWindow();
const wrapSubscribeFunction = createWrapSubscribeFunction(patch, toObserver);
export const mediaQueryMatch = createMediaQueryMatch(window, wrapSubscribeFunction);
export const mediaQueryMatch = createMediaQueryMatch(emitNotSupportedError, window, wrapSubscribeFunction);
export const mutations = createMutations(window, wrapSubscribeFunction);
export const mutations = createMutations(emitNotSupportedError, window, wrapSubscribeFunction);
export const permissionState = createPermissionState(window, wrapSubscribeFunction);
export const permissionState = createPermissionState(emitNotSupportedError, window, wrapSubscribeFunction);
export const reports = createReports(emitNotSupportedError, window, wrapSubscribeFunction);

@@ -0,1 +1,2 @@

export * from './emit-not-supported-error-function';
export * from './flexible-subscribe-function';

@@ -10,2 +11,4 @@ export * from './media-query-match-factory';

export * from './permission-state-function';
export * from './reports-factory';
export * from './reports-function';
export * from './subscribable-thing';

@@ -12,0 +15,0 @@ export * from './subscribe-function';

@@ -0,4 +1,10 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TMediaQueryMatchFunction } from './media-query-match-function';
import { TWindow } from './window';
import { TWrapSubscribeFunctionFunction } from './wrap-subscribe-function-function';
export type TMediaQueryMatchFactory = (window: Window, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMediaQueryMatchFunction;
export type TMediaQueryMatchFactory = (
emitNotSupportedError: TEmitNotSupportedErrorFunction,
window: null | TWindow,
wrapSubscribeFunction: TWrapSubscribeFunctionFunction
) => TMediaQueryMatchFunction;

@@ -0,1 +1,2 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TMutationsFunction } from './mutations-function';

@@ -5,2 +6,6 @@ import { TWindow } from './window';

export type TMutationsFactory = (window: TWindow, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TMutationsFunction;
export type TMutationsFactory = (
emitNotSupportedError: TEmitNotSupportedErrorFunction,
window: null | TWindow,
wrapSubscribeFunction: TWrapSubscribeFunctionFunction
) => TMutationsFunction;

@@ -0,4 +1,10 @@

import { TEmitNotSupportedErrorFunction } from './emit-not-supported-error-function';
import { TPermissionStateFunction } from './permission-state-function';
import { TWindow } from './window';
import { TWrapSubscribeFunctionFunction } from './wrap-subscribe-function-function';
export type TPermissionStateFactory = (window: Window, wrapSubscribeFunction: TWrapSubscribeFunctionFunction) => TPermissionStateFunction;
export type TPermissionStateFactory = (
emitNotSupportedError: TEmitNotSupportedErrorFunction,
window: null | TWindow,
wrapSubscribeFunction: TWrapSubscribeFunctionFunction
) => TPermissionStateFunction;

@@ -1,1 +0,14 @@

export type TWindow = Window & typeof globalThis;
import { IReport, IReportingObserver, IReportingObserverOptions } from '../interfaces';
// @todo TypeScript does not include type definitions for the Reporting API yet.
export type TWindow = Window & typeof globalThis & {
ReportingObserver: {
prototype: IReportingObserver;
new(callback: (reports: IReport[]) => void, options?: IReportingObserverOptions): IReportingObserver;
};
};

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

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

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

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

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

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