subscribable-things
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -5,2 +5,6 @@ export * from './report'; | ||
export * from './reporting-observer-options'; | ||
export * from './resize-observer'; | ||
export * from './resize-observer-entry'; | ||
export * from './resize-observer-options'; | ||
export * from './resize-observer-size'; | ||
//# sourceMappingURL=/build/es2019/interfaces/index.d.ts.map |
@@ -5,2 +5,6 @@ export * from './report'; | ||
export * from './reporting-observer-options'; | ||
export * from './resize-observer'; | ||
export * from './resize-observer-entry'; | ||
export * from './resize-observer-options'; | ||
export * from './resize-observer-size'; | ||
//# sourceMappingURL=/build/es2019/interfaces/index.js.map |
@@ -8,2 +8,3 @@ export * from './interfaces/index'; | ||
export declare const reports: import("./types").TReportsFunction; | ||
export declare const resizes: import("./types").TResizesFunction; | ||
//# sourceMappingURL=/build/es2019/module.d.ts.map |
@@ -7,2 +7,3 @@ import { patch, toObserver } from 'rxjs-interop'; | ||
import { createReports } from './factories/reports'; | ||
import { createResizes } from './factories/resizes'; | ||
import { createWindow } from './factories/window'; | ||
@@ -24,2 +25,3 @@ import { createWrapSubscribeFunction } from './factories/wrap-subscribe-function'; | ||
export const reports = createReports(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const resizes = createResizes(emitNotSupportedError, window, wrapSubscribeFunction); | ||
//# sourceMappingURL=/build/es2019/module.js.map |
@@ -15,2 +15,5 @@ export * from './emit-not-supported-error-function'; | ||
export * from './reports-function'; | ||
export * from './resize-observer-box-options'; | ||
export * from './resizes-factory'; | ||
export * from './resizes-function'; | ||
export * from './subscribable-thing'; | ||
@@ -17,0 +20,0 @@ export * from './subscribe-function'; |
@@ -15,2 +15,5 @@ export * from './emit-not-supported-error-function'; | ||
export * from './reports-function'; | ||
export * from './resize-observer-box-options'; | ||
export * from './resizes-factory'; | ||
export * from './resizes-function'; | ||
export * from './subscribable-thing'; | ||
@@ -17,0 +20,0 @@ export * from './subscribe-function'; |
@@ -1,8 +0,12 @@ | ||
import { IReport, IReportingObserver, IReportingObserverOptions } from '../interfaces'; | ||
import { IReport, IReportingObserver, IReportingObserverOptions, IResizeObserver, IResizeObserverEntry } from '../interfaces'; | ||
export declare type TWindow = Window & typeof globalThis & { | ||
ReportingObserver: { | ||
prototype: IReportingObserver; | ||
new (callback: (reports: IReport[]) => void, options?: IReportingObserverOptions): IReportingObserver; | ||
new (callback: (reports: IReport[], observer: IReportingObserver) => void, options?: IReportingObserverOptions): IReportingObserver; | ||
}; | ||
ResizeObserver: { | ||
prototype: IResizeObserver; | ||
new (callback: (entries: IResizeObserverEntry[], observer: IResizeObserver) => void): IResizeObserver; | ||
}; | ||
}; | ||
//# sourceMappingURL=/build/es2019/types/window.d.ts.map |
@@ -141,2 +141,26 @@ (function (global, factory) { | ||
var createResizes = function createResizes(emitNotSupportedError, window, wrapSubscribeFunction) { | ||
return function (htmlElement, options) { | ||
return wrapSubscribeFunction(function (observer) { | ||
if (window === null || window.ResizeObserver === undefined) { | ||
return emitNotSupportedError(observer); | ||
} | ||
var resizeObserver = new window.ResizeObserver(function (entries) { | ||
return observer.next(entries); | ||
}); | ||
try { | ||
resizeObserver.observe(htmlElement, options); | ||
} catch (err) { | ||
observer.error(err); | ||
} | ||
return function () { | ||
return resizeObserver.disconnect(); | ||
}; | ||
}); | ||
}; | ||
}; | ||
// @todo TypeScript does not include type definitions for the Reporting API yet. | ||
@@ -188,2 +212,3 @@ var createWindow = function createWindow() { | ||
var reports = createReports(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
var resizes = createResizes(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
@@ -195,2 +220,3 @@ exports.mediaDevices = mediaDevices; | ||
exports.reports = reports; | ||
exports.resizes = resizes; | ||
@@ -197,0 +223,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -30,3 +30,3 @@ { | ||
"eslint": "^6.8.0", | ||
"eslint-config-holy-grail": "^46.0.7", | ||
"eslint-config-holy-grail": "^46.0.9", | ||
"grunt": "^1.0.4", | ||
@@ -91,3 +91,3 @@ "grunt-cli": "^1.3.2", | ||
"types": "build/es2019/module.d.ts", | ||
"version": "1.2.0" | ||
"version": "1.3.0" | ||
} |
@@ -111,4 +111,8 @@ # subscribable-things | ||
### reports(options: IReportingObserverOptions): SubscribableThing\<IReport[]> | ||
### 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). | ||
### resizes(htmlElement: HTMLElement, options?: IResizesObserverOptions): SubscribableThing\<IResizeObserverEntry[]> | ||
This function is a wrapper for the [`ResizeObserver`](https://developer.mozilla.org/docs/Web/API/ResizeObserver) of the [Resize Observer specification](https://drafts.csswg.org/resize-observer). |
@@ -5,1 +5,5 @@ export * from './report'; | ||
export * from './reporting-observer-options'; | ||
export * from './resize-observer'; | ||
export * from './resize-observer-entry'; | ||
export * from './resize-observer-options'; | ||
export * from './resize-observer-size'; |
@@ -7,2 +7,3 @@ import { patch, toObserver } from 'rxjs-interop'; | ||
import { createReports } from './factories/reports'; | ||
import { createResizes } from './factories/resizes'; | ||
import { createWindow } from './factories/window'; | ||
@@ -31,1 +32,3 @@ import { createWrapSubscribeFunction } from './factories/wrap-subscribe-function'; | ||
export const reports = createReports(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const resizes = createResizes(emitNotSupportedError, window, wrapSubscribeFunction); |
@@ -15,2 +15,5 @@ export * from './emit-not-supported-error-function'; | ||
export * from './reports-function'; | ||
export * from './resize-observer-box-options'; | ||
export * from './resizes-factory'; | ||
export * from './resizes-function'; | ||
export * from './subscribable-thing'; | ||
@@ -17,0 +20,0 @@ export * from './subscribe-function'; |
@@ -1,2 +0,2 @@ | ||
import { IReport, IReportingObserver, IReportingObserverOptions } from '../interfaces'; | ||
import { IReport, IReportingObserver, IReportingObserverOptions, IResizeObserver, IResizeObserverEntry } from '../interfaces'; | ||
@@ -10,6 +10,15 @@ // @todo TypeScript does not include type definitions for the Reporting API yet. | ||
new(callback: (reports: IReport[]) => void, options?: IReportingObserverOptions): IReportingObserver; | ||
new(callback: (reports: IReport[], observer: IReportingObserver) => void, options?: IReportingObserverOptions): IReportingObserver; | ||
}; | ||
// @todo TypeScript does not include type definitions for the Resize Observer specification yet. | ||
ResizeObserver: { | ||
prototype: IResizeObserver; | ||
new(callback: (entries: IResizeObserverEntry[], observer: IResizeObserver) => void): IResizeObserver; | ||
}; | ||
}; |
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
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
87520
225
912
118