subscribable-things
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -0,1 +1,9 @@ | ||
export * from './midi-access'; | ||
export * from './midi-connection-event'; | ||
export * from './midi-input'; | ||
export * from './midi-input-event-map'; | ||
export * from './midi-message-event'; | ||
export * from './midi-output'; | ||
export * from './midi-output-event-map'; | ||
export * from './midi-port'; | ||
export * from './report'; | ||
@@ -2,0 +10,0 @@ export * from './report-body'; |
@@ -0,1 +1,9 @@ | ||
export * from './midi-access'; | ||
export * from './midi-connection-event'; | ||
export * from './midi-input'; | ||
export * from './midi-input-event-map'; | ||
export * from './midi-message-event'; | ||
export * from './midi-output'; | ||
export * from './midi-output-event-map'; | ||
export * from './midi-port'; | ||
export * from './report'; | ||
@@ -2,0 +10,0 @@ export * from './report-body'; |
export * from './interfaces/index'; | ||
export * from './types/index'; | ||
export declare const intersections: import("./types").TIntersectionsFunction; | ||
export declare const mediaDevices: import("./types").TMediaDevicesFunction; | ||
export declare const mediaQueryMatch: import("./types").TMediaQueryMatchFunction; | ||
export declare const midiInputs: import("./types").TMidiInputsFunction; | ||
export declare const midiOutputs: import("./types").TMidiOutputsFunction; | ||
export declare const mutations: import("./types").TMutationsFunction; | ||
@@ -6,0 +9,0 @@ export declare const permissionState: import("./types").TPermissionStateFunction; |
import { patch, toObserver } from 'rxjs-interop'; | ||
import { createIntersections } from './factories/intersections'; | ||
import { createMediaDevices } from './factories/media-devices'; | ||
import { createMediaQueryMatch } from './factories/media-query-match'; | ||
import { createMidiInputs } from './factories/midi-inputs'; | ||
import { createMidiOutputs } from './factories/midi-outputs'; | ||
import { createMutations } from './factories/mutations'; | ||
@@ -19,4 +22,7 @@ import { createPermissionState } from './factories/permission-state'; | ||
const wrapSubscribeFunction = createWrapSubscribeFunction(patch, toObserver); | ||
export const intersections = createIntersections(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const mediaDevices = createMediaDevices(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const mediaQueryMatch = createMediaQueryMatch(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const midiInputs = createMidiInputs(wrapSubscribeFunction); | ||
export const midiOutputs = createMidiOutputs(wrapSubscribeFunction); | ||
export const mutations = createMutations(emitNotSupportedError, window, wrapSubscribeFunction); | ||
@@ -23,0 +29,0 @@ export const permissionState = createPermissionState(emitNotSupportedError, window, wrapSubscribeFunction); |
export * from './emit-not-supported-error-function'; | ||
export * from './event-handler'; | ||
export * from './flexible-subscribe-function'; | ||
export * from './intersections-factory'; | ||
export * from './intersections-function'; | ||
export * from './media-devices-factory'; | ||
@@ -7,2 +10,11 @@ export * from './media-devices-function'; | ||
export * from './media-query-match-function'; | ||
export * from './midi-connection-event-handler'; | ||
export * from './midi-inputs-factory'; | ||
export * from './midi-inputs-function'; | ||
export * from './midi-message-event-handler'; | ||
export * from './midi-outputs-factory'; | ||
export * from './midi-outputs-function'; | ||
export * from './midi-port-connection-state'; | ||
export * from './midi-port-device-state'; | ||
export * from './midi-port-type'; | ||
export * from './mutations-factory'; | ||
@@ -9,0 +21,0 @@ export * from './mutations-function'; |
export * from './emit-not-supported-error-function'; | ||
export * from './event-handler'; | ||
export * from './flexible-subscribe-function'; | ||
export * from './intersections-factory'; | ||
export * from './intersections-function'; | ||
export * from './media-devices-factory'; | ||
@@ -7,2 +10,11 @@ export * from './media-devices-function'; | ||
export * from './media-query-match-function'; | ||
export * from './midi-connection-event-handler'; | ||
export * from './midi-inputs-factory'; | ||
export * from './midi-inputs-function'; | ||
export * from './midi-message-event-handler'; | ||
export * from './midi-outputs-factory'; | ||
export * from './midi-outputs-function'; | ||
export * from './midi-port-connection-state'; | ||
export * from './midi-port-device-state'; | ||
export * from './midi-port-type'; | ||
export * from './mutations-factory'; | ||
@@ -9,0 +21,0 @@ export * from './mutations-function'; |
@@ -7,2 +7,26 @@ (function (global, factory) { | ||
var createIntersections = function createIntersections(emitNotSupportedError, window, wrapSubscribeFunction) { | ||
return function (htmlElement, options) { | ||
return wrapSubscribeFunction(function (observer) { | ||
if (window === null || window.IntersectionObserver === undefined) { | ||
return emitNotSupportedError(observer); | ||
} | ||
var intersectionObserverObserver = new window.IntersectionObserver(function (entries) { | ||
return observer.next(entries); | ||
}, options); | ||
try { | ||
intersectionObserverObserver.observe(htmlElement); | ||
} catch (err) { | ||
observer.error(err); | ||
} | ||
return function () { | ||
return intersectionObserverObserver.disconnect(); | ||
}; | ||
}); | ||
}; | ||
}; | ||
var createMediaDevices = function createMediaDevices(emitNotSupportedError, window, wrapSubscribeFunction) { | ||
@@ -63,2 +87,54 @@ return function () { | ||
var createMidiInputs = function createMidiInputs(wrapSubscribeFunction) { | ||
return function (midiAccess) { | ||
return wrapSubscribeFunction(function (observer) { | ||
var midiInputs = Array.from(midiAccess.inputs.values()); | ||
var emitMidiInputs = function emitMidiInputs() { | ||
var midiAccessInputs = midiAccess.inputs; | ||
if (midiInputs.length !== midiAccessInputs.size || midiInputs.some(function (_ref) { | ||
var id = _ref.id; | ||
return !midiAccessInputs.has(id); | ||
})) { | ||
midiInputs = Array.from(midiAccessInputs.values()); | ||
observer.next(midiInputs); | ||
} | ||
}; | ||
observer.next(midiInputs); | ||
midiAccess.addEventListener('statechange', emitMidiInputs); | ||
return function () { | ||
return midiAccess.removeEventListener('statechange', emitMidiInputs); | ||
}; | ||
}); | ||
}; | ||
}; | ||
var createMidiOutputs = function createMidiOutputs(wrapSubscribeFunction) { | ||
return function (midiAccess) { | ||
return wrapSubscribeFunction(function (observer) { | ||
var midiOutputs = Array.from(midiAccess.outputs.values()); | ||
var emitMidiOutputs = function emitMidiOutputs() { | ||
var midiAccessOutputs = midiAccess.outputs; | ||
if (midiOutputs.length !== midiAccessOutputs.size || midiOutputs.some(function (_ref) { | ||
var id = _ref.id; | ||
return !midiAccessOutputs.has(id); | ||
})) { | ||
midiOutputs = Array.from(midiAccessOutputs.values()); | ||
observer.next(midiOutputs); | ||
} | ||
}; | ||
observer.next(midiOutputs); | ||
midiAccess.addEventListener('statechange', emitMidiOutputs); | ||
return function () { | ||
return midiAccess.removeEventListener('statechange', emitMidiOutputs); | ||
}; | ||
}); | ||
}; | ||
}; | ||
var createMutations = function createMutations(emitNotSupportedError, window, wrapSubscribeFunction) { | ||
@@ -208,4 +284,7 @@ return function (htmlElement, options) { | ||
var wrapSubscribeFunction = createWrapSubscribeFunction(rxjsInterop.patch, rxjsInterop.toObserver); | ||
var intersections = createIntersections(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
var mediaDevices = createMediaDevices(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
var mediaQueryMatch = createMediaQueryMatch(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
var midiInputs = createMidiInputs(wrapSubscribeFunction); | ||
var midiOutputs = createMidiOutputs(wrapSubscribeFunction); | ||
var mutations = createMutations(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
@@ -216,4 +295,7 @@ var permissionState = createPermissionState(emitNotSupportedError, window$1, wrapSubscribeFunction); | ||
exports.intersections = intersections; | ||
exports.mediaDevices = mediaDevices; | ||
exports.mediaQueryMatch = mediaQueryMatch; | ||
exports.midiInputs = midiInputs; | ||
exports.midiOutputs = midiOutputs; | ||
exports.mutations = mutations; | ||
@@ -220,0 +302,0 @@ exports.permissionState = permissionState; |
@@ -46,10 +46,10 @@ { | ||
"mocha": "^7.1.0", | ||
"rollup": "^2.0.2", | ||
"rollup": "^2.0.3", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rxjs": "^6.5.4", | ||
"sinon": "^9.0.0", | ||
"sinon": "^9.0.1", | ||
"sinon-chai": "^3.5.0", | ||
"ts-loader": "^6.2.1", | ||
"tsconfig-holy-grail": "^11.0.3", | ||
"tslint": "^6.0.0", | ||
"tslint": "^6.1.0", | ||
"tslint-config-holy-grail": "^48.0.3", | ||
@@ -91,3 +91,3 @@ "typescript": "^3.8.3", | ||
"types": "build/es2019/module.d.ts", | ||
"version": "1.3.0" | ||
"version": "1.4.0" | ||
} |
@@ -95,2 +95,6 @@ # subscribable-things | ||
### intersections(htmlElement: HTMLElement, options?: IntersectionObserverInit): SubscribableThing\<IntersectionObserverEntry[]> | ||
This function is a wrapper for the [`IntersectionObserver`](https://developer.mozilla.org/docs/Web/API/IntersectionObserver). | ||
### mediaDevices(): SubscribableThing\<MediaDeviceInfo[]> | ||
@@ -104,2 +108,10 @@ | ||
### midiInputs(midiAccess: IMidiAccess): SubscribableThing\<IMidiInput[]> | ||
This function returns the currently available MIDI input devices. It accepts a [`MIDIAccess`](https://developer.mozilla.org/docs/Web/API/MIDIAccess) object of the [Web MIDI API](https://webaudio.github.io/web-midi-api). | ||
### midiOutputs(midiAccess: IMidiAccess): SubscribableThing\<IMidiOutput[]> | ||
This function returns the currently available MIDI output devices. It accepts a [`MIDIAccess`](https://developer.mozilla.org/docs/Web/API/MIDIAccess) object of the [Web MIDI API](https://webaudio.github.io/web-midi-api). | ||
### mutations(htmlElement: HTMLElement, options: MutationObserverInit): SubscribableThing\<MutationRecord[]> | ||
@@ -106,0 +118,0 @@ |
@@ -0,1 +1,9 @@ | ||
export * from './midi-access'; | ||
export * from './midi-connection-event'; | ||
export * from './midi-input'; | ||
export * from './midi-input-event-map'; | ||
export * from './midi-message-event'; | ||
export * from './midi-output'; | ||
export * from './midi-output-event-map'; | ||
export * from './midi-port'; | ||
export * from './report'; | ||
@@ -2,0 +10,0 @@ export * from './report-body'; |
import { patch, toObserver } from 'rxjs-interop'; | ||
import { createIntersections } from './factories/intersections'; | ||
import { createMediaDevices } from './factories/media-devices'; | ||
import { createMediaQueryMatch } from './factories/media-query-match'; | ||
import { createMidiInputs } from './factories/midi-inputs'; | ||
import { createMidiOutputs } from './factories/midi-outputs'; | ||
import { createMutations } from './factories/mutations'; | ||
@@ -22,2 +25,4 @@ import { createPermissionState } from './factories/permission-state'; | ||
export const intersections = createIntersections(emitNotSupportedError, window, wrapSubscribeFunction); | ||
export const mediaDevices = createMediaDevices(emitNotSupportedError, window, wrapSubscribeFunction); | ||
@@ -27,2 +32,6 @@ | ||
export const midiInputs = createMidiInputs(wrapSubscribeFunction); | ||
export const midiOutputs = createMidiOutputs(wrapSubscribeFunction); | ||
export const mutations = createMutations(emitNotSupportedError, window, wrapSubscribeFunction); | ||
@@ -29,0 +38,0 @@ |
export * from './emit-not-supported-error-function'; | ||
export * from './event-handler'; | ||
export * from './flexible-subscribe-function'; | ||
export * from './intersections-factory'; | ||
export * from './intersections-function'; | ||
export * from './media-devices-factory'; | ||
@@ -7,2 +10,11 @@ export * from './media-devices-function'; | ||
export * from './media-query-match-function'; | ||
export * from './midi-connection-event-handler'; | ||
export * from './midi-inputs-factory'; | ||
export * from './midi-inputs-function'; | ||
export * from './midi-message-event-handler'; | ||
export * from './midi-outputs-factory'; | ||
export * from './midi-outputs-function'; | ||
export * from './midi-port-connection-state'; | ||
export * from './midi-port-device-state'; | ||
export * from './midi-port-type'; | ||
export * from './mutations-factory'; | ||
@@ -9,0 +21,0 @@ export * from './mutations-function'; |
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
131486
340
1377
130