angular-audio-context
Version:
An Angular wrapper for the Web Audio API's AudioContext.
126 lines (116 loc) • 5.29 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@angular/common'), require('@angular/core'), require('standardized-audio-context'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/inherits')) :
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@angular/common', '@angular/core', 'standardized-audio-context', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/inherits'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.angularAudioContext = {}, global._classCallCheck, global._createClass, global.common, global.i0, global.standardizedAudioContext, global._possibleConstructorReturn, global._getPrototypeOf, global._inherits));
})(this, (function (exports, _classCallCheck, _createClass, common, i0, standardizedAudioContext, _possibleConstructorReturn, _getPrototypeOf, _inherits) { 'use strict';
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespaceDefault(i0);
function audioContextFactory(latencyHint) {
return new standardizedAudioContext.AudioContext({
latencyHint: latencyHint
});
}
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var AudioContextProxy = /*#__PURE__*/function (_AudioContext) {
function AudioContextProxy() {
_classCallCheck(this, AudioContextProxy);
return _callSuper(this, AudioContextProxy, arguments);
}
_inherits(AudioContextProxy, _AudioContext);
return _createClass(AudioContextProxy);
}(standardizedAudioContext.AudioContext);
function isSupportedFactory() {
return standardizedAudioContext.isSupported;
}
var latencyHintToken = new i0.InjectionToken('LATENCY_HINT');
var isSupported = new i0.InjectionToken('IS_SUPPORTED_PROMISE');
var AudioContextModule = /*#__PURE__*/function () {
function AudioContextModule() {
_classCallCheck(this, AudioContextModule);
}
return _createClass(AudioContextModule, null, [{
key: "forChild",
value: function forChild() {
return {
ngModule: AudioContextModule
};
}
}, {
key: "forRoot",
value: function forRoot(latencyHint) {
return {
ngModule: AudioContextModule,
providers: [{
deps: [latencyHintToken],
provide: AudioContextProxy,
useFactory: audioContextFactory
}, {
provide: latencyHintToken,
useValue: latencyHint
}]
};
}
}]);
}();
AudioContextModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({
minVersion: "12.0.0",
version: "20.3.0",
ngImport: i0__namespace,
type: AudioContextModule,
deps: [],
target: i0__namespace.ɵɵFactoryTarget.NgModule
});
AudioContextModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({
minVersion: "14.0.0",
version: "20.3.0",
ngImport: i0__namespace,
type: AudioContextModule,
imports: [common.CommonModule]
});
AudioContextModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({
minVersion: "12.0.0",
version: "20.3.0",
ngImport: i0__namespace,
type: AudioContextModule,
providers: [{
provide: isSupported,
useFactory: isSupportedFactory
}],
imports: [common.CommonModule]
});
i0__namespace.ɵɵngDeclareClassMetadata({
minVersion: "12.0.0",
version: "20.3.0",
ngImport: i0__namespace,
type: AudioContextModule,
decorators: [{
type: i0.NgModule,
args: [{
imports: [common.CommonModule],
providers: [{
provide: isSupported,
useFactory: isSupportedFactory
}]
}]
}]
});
exports.AudioContext = AudioContextProxy;
exports.AudioContextModule = AudioContextModule;
exports.isSupported = isSupported;
}));