uneeq-js 2.47.2 → 2.47.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/src/service/speech-handler.d.ts +3 -1
- package/dist/umd/index.js +56 -1586
- package/package.json +62 -64
- package/readme.md +210 -58
package/dist/umd/index.js
CHANGED
|
@@ -3672,14 +3672,14 @@ const online_status_service_1 = __webpack_require__(320);
|
|
|
3672
3672
|
const prom_1 = __webpack_require__(290);
|
|
3673
3673
|
const resume_session_check_1 = __webpack_require__(321);
|
|
3674
3674
|
const speech_handler_1 = __webpack_require__(323);
|
|
3675
|
-
const stream_manager_1 = __webpack_require__(
|
|
3675
|
+
const stream_manager_1 = __webpack_require__(331);
|
|
3676
3676
|
const uneeq_local_storage_1 = __webpack_require__(322);
|
|
3677
|
-
const voice_input_manager_1 = __webpack_require__(
|
|
3677
|
+
const voice_input_manager_1 = __webpack_require__(332);
|
|
3678
3678
|
const MessageTypes_1 = __webpack_require__(287);
|
|
3679
|
-
const NewSessionRequest_1 = __webpack_require__(
|
|
3679
|
+
const NewSessionRequest_1 = __webpack_require__(335);
|
|
3680
3680
|
const PublishSubscribeState_1 = __webpack_require__(248);
|
|
3681
|
-
const SourceApp_1 = __webpack_require__(
|
|
3682
|
-
const VoiceInputMode_1 = __webpack_require__(
|
|
3681
|
+
const SourceApp_1 = __webpack_require__(336);
|
|
3682
|
+
const VoiceInputMode_1 = __webpack_require__(334);
|
|
3683
3683
|
class Uneeq {
|
|
3684
3684
|
/**
|
|
3685
3685
|
* The active session id as a string. If the session has not started yet value will be null
|
|
@@ -13240,7 +13240,7 @@ exports.race = race;
|
|
|
13240
13240
|
/***/ ((module) => {
|
|
13241
13241
|
|
|
13242
13242
|
"use strict";
|
|
13243
|
-
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.
|
|
13243
|
+
module.exports = JSON.parse('{"name":"uneeq-js","version":"2.47.3","description":"","main":"dist/index.js","types":"dist/src/index.d.ts","scripts":{"start":"npx webpack -w","test-local":"npx karma start karma.conf.js -logLevel=DEBUG","test":"npx karma start --browsers ChromeHeadless --single-run","test:windows":"karma start karma.conf.js","build":"webpack --config webpack.config.prod.js && webpack --config webpack.config.umd.js","lint":"npx tslint -p tsconfig.json --fix","docs":"npx typedoc --options"},"files":["dist","!dist/test"],"author":"","license":"ISC","dependencies":{"@stomp/stompjs":"^6.0.0","@uehreka/seriously":"^1.0.1","fast-text-encoding":"^1.0.0","intrinsic-scale":"^3.0.4","onnxruntime-web":"^1.15.1","promjs":"^0.4.1","ring-buffer-ts":"^1.2.0","rxjs":"^7.8.1","rxjs-compat":"^6.6.7","simple-peer":"^9.11.1","webrtc-adapter":"^8.2.3"},"devDependencies":{"@types/dom-mediacapture-record":"^1.0.16","@types/jasmine":"^2.8.8","@types/node":"^10.9.4","fetch-mock":"7.7.3","ignore-styles":"^5.0.1","jasmine":"^5.1.0","jasmine-core":"^5.1.0","karma":"^6.4.2","karma-chrome-launcher":"^3.2.0","karma-firefox-launcher":"^2.1.2","karma-jasmine":"^5.1.0","karma-jasmine-html-reporter":"^2.1.0","karma-requirejs":"^1.1.0","karma-typescript":"^5.5.4","karma-typescript-es6-transform":"^5.5.4","nock":"^9.6.1","requirejs":"^2.3.6","ts-loader":"^9.4.4","ts-node":"^7.0.1","tslint":"^5.11.0","tslint-no-focused-test":"^0.5.0","typedoc":"^0.18.0","typescript":"^5.1.6","webpack":"^5.88.2","webpack-cli":"^5.1.4"}}');
|
|
13244
13244
|
|
|
13245
13245
|
/***/ }),
|
|
13246
13246
|
/* 242 */
|
|
@@ -51156,16 +51156,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
51156
51156
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51157
51157
|
});
|
|
51158
51158
|
};
|
|
51159
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51160
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51161
|
-
};
|
|
51162
51159
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51163
51160
|
exports.SpeechHandler = void 0;
|
|
51164
|
-
const
|
|
51165
|
-
const
|
|
51166
|
-
const real_time_vad_1 = __webpack_require__(328);
|
|
51161
|
+
const ring_buffer_ts_1 = __webpack_require__(324);
|
|
51162
|
+
const real_time_vad_1 = __webpack_require__(325);
|
|
51167
51163
|
const MessageTypes_1 = __webpack_require__(287);
|
|
51168
|
-
const SpeechRecognitionMessageAction_1 = __webpack_require__(
|
|
51164
|
+
const SpeechRecognitionMessageAction_1 = __webpack_require__(330);
|
|
51169
51165
|
const logger_1 = __webpack_require__(250);
|
|
51170
51166
|
const speechBufferLength = 5;
|
|
51171
51167
|
const audioChunkSizeMs = 100;
|
|
@@ -51178,11 +51174,24 @@ class SpeechHandler {
|
|
|
51178
51174
|
this.logPrefix = 'UneeQ: Speech Recognition: ';
|
|
51179
51175
|
this.speechBuffer = new ring_buffer_ts_1.RingBuffer(speechBufferLength);
|
|
51180
51176
|
this.recordingLive = false;
|
|
51181
|
-
this.
|
|
51177
|
+
this.scriptsLoadedPromise = [];
|
|
51182
51178
|
console.warn('UneeQ: SPEECH_RECOGNITION input mode is in development, you may experience issues.');
|
|
51183
51179
|
this.options.assetBasePath = this.options.assetBasePath || defaultAssetPath;
|
|
51184
51180
|
this.loadSavedAudioHeaders();
|
|
51185
|
-
this.
|
|
51181
|
+
this.loadScripts();
|
|
51182
|
+
this.initWebsocket(this.options);
|
|
51183
|
+
}
|
|
51184
|
+
loadScripts() {
|
|
51185
|
+
const loadScript = (url) => {
|
|
51186
|
+
return new Promise((resolve) => {
|
|
51187
|
+
const script = document.createElement('script');
|
|
51188
|
+
script.src = url;
|
|
51189
|
+
script.onload = resolve;
|
|
51190
|
+
document.body.appendChild(script);
|
|
51191
|
+
});
|
|
51192
|
+
};
|
|
51193
|
+
this.scriptsLoadedPromise.push(loadScript(this.options.assetBasePath + 'OpusMediaRecorder.umd.js'));
|
|
51194
|
+
this.scriptsLoadedPromise.push(loadScript(this.options.assetBasePath + 'encoderWorker.umd.js'));
|
|
51186
51195
|
}
|
|
51187
51196
|
initWebsocket(options) {
|
|
51188
51197
|
let connectionUrl = options.apiUrl.replace('https://api.', 'wss://speech-recognition-service.');
|
|
@@ -51292,34 +51301,20 @@ class SpeechHandler {
|
|
|
51292
51301
|
})
|
|
51293
51302
|
.catch((error) => console.error('Error starting recording', error));
|
|
51294
51303
|
}
|
|
51304
|
+
getMediaRecorder(stream, mediaOptions, workerOptions) {
|
|
51305
|
+
return new window.OpusMediaRecorder(stream, mediaOptions, workerOptions);
|
|
51306
|
+
}
|
|
51295
51307
|
initMediaRecorder(stream) {
|
|
51296
|
-
|
|
51297
|
-
|
|
51298
|
-
|
|
51299
|
-
|
|
51300
|
-
|
|
51301
|
-
|
|
51302
|
-
|
|
51303
|
-
|
|
51304
|
-
|
|
51305
|
-
|
|
51306
|
-
// importScripts with the given URL
|
|
51307
|
-
function getWorkerURL(url) {
|
|
51308
|
-
const content = `importScripts( "${url}" );`;
|
|
51309
|
-
return URL.createObjectURL(new Blob([content], { type: "text/javascript" }));
|
|
51310
|
-
}
|
|
51311
|
-
const workerOptions = {
|
|
51312
|
-
encoderWorkerFactory: () => {
|
|
51313
|
-
return worker;
|
|
51314
|
-
},
|
|
51315
|
-
OggOpusEncoderWasmPath: this.options.assetBasePath + 'OggOpusEncoder.wasm',
|
|
51316
|
-
WebMOpusEncoderWasmPath: this.options.assetBasePath + 'WebMOpusEncoder.wasm'
|
|
51317
|
-
};
|
|
51318
|
-
const mediaOptions = {
|
|
51319
|
-
mimeType: 'audio/webm',
|
|
51320
|
-
audioBitsPerSecond: audioSampleRate
|
|
51321
|
-
};
|
|
51322
|
-
this.mediaRecorder = new this.OpusMediaRecorder(stream, mediaOptions, workerOptions);
|
|
51308
|
+
const workerOptions = {
|
|
51309
|
+
OggOpusEncoderWasmPath: this.options.assetBasePath + 'OggOpusEncoder.wasm',
|
|
51310
|
+
WebMOpusEncoderWasmPath: this.options.assetBasePath + 'WebMOpusEncoder.wasm'
|
|
51311
|
+
};
|
|
51312
|
+
const mediaOptions = {
|
|
51313
|
+
mimeType: 'audio/webm',
|
|
51314
|
+
audioBitsPerSecond: audioSampleRate
|
|
51315
|
+
};
|
|
51316
|
+
return Promise.all(this.scriptsLoadedPromise).then(() => {
|
|
51317
|
+
this.mediaRecorder = this.getMediaRecorder(stream, mediaOptions, workerOptions);
|
|
51323
51318
|
this.mediaRecorder.ondataavailable = (e) => this.mediaRecorderOnData(e);
|
|
51324
51319
|
this.mediaRecorder.onstop = () => this.sendStopMessage();
|
|
51325
51320
|
this.mediaRecorder.start(audioChunkSizeMs);
|
|
@@ -51348,1537 +51343,12 @@ exports.SpeechHandler = SpeechHandler;
|
|
|
51348
51343
|
|
|
51349
51344
|
/***/ }),
|
|
51350
51345
|
/* 324 */
|
|
51351
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
51352
|
-
|
|
51353
|
-
const { EventTarget, defineEventAttribute } = __webpack_require__(325);
|
|
51354
|
-
const { detect } = __webpack_require__(326);
|
|
51355
|
-
const browser = detect();
|
|
51356
|
-
|
|
51357
|
-
const AudioContext = __webpack_require__.g.AudioContext || __webpack_require__.g.webkitAudioContext;
|
|
51358
|
-
const BUFFER_SIZE = 4096;
|
|
51359
|
-
|
|
51360
|
-
/**
|
|
51361
|
-
* Reference: https://w3c.github.io/mediacapture-record/#mediarecorder-api
|
|
51362
|
-
* @extends EventTarget
|
|
51363
|
-
*/
|
|
51364
|
-
class OpusMediaRecorder extends EventTarget {
|
|
51365
|
-
/**
|
|
51366
|
-
* A function that returns the encoder web worker
|
|
51367
|
-
* @name workerFactory
|
|
51368
|
-
* @function
|
|
51369
|
-
* @returns {worker} An instance of ./encoderWorker.js web worker.
|
|
51370
|
-
*/
|
|
51371
|
-
|
|
51372
|
-
/**
|
|
51373
|
-
*
|
|
51374
|
-
* @param {MediaStream} stream - The MediaStream to be recorded. This will
|
|
51375
|
-
* be the value of the stream attribute.
|
|
51376
|
-
* @param {MediaRecorderOptions} [options] - A dictionary of options to for
|
|
51377
|
-
* the UA instructing how the recording will take part.
|
|
51378
|
-
* options.mimeType, if present, will become the value of mimeType
|
|
51379
|
-
* attribute.
|
|
51380
|
-
* @param {Object} [workerOptions] This is a NON-STANDARD options to
|
|
51381
|
-
* configure how to import the web worker .wasm compiled binaries
|
|
51382
|
-
* used for encoding.
|
|
51383
|
-
* @param {workerFactory} [workerOptions.encoderWorkerFactory] A factory
|
|
51384
|
-
* function that create a web worker instance of ./encoderWorker.js
|
|
51385
|
-
* and returns it. function(){return new Worker('./encoderWorker.umd.js')}
|
|
51386
|
-
* is used by default. This is NON-STANDARD.
|
|
51387
|
-
* @param {string} [workerOptions.OggOpusEncoderWasmPath]
|
|
51388
|
-
* Path of ./OggOpusEncoder.wasm which is used for OGG Opus encoding
|
|
51389
|
-
* by the encoder worker. This is NON-STANDARD.
|
|
51390
|
-
* @param {string} [workerOptions.WebMOpusEncoderWasmPath]
|
|
51391
|
-
* Path of ./WebMOpusEncoder.wasm which is used for WebM Opus encoding
|
|
51392
|
-
* by the encoder worker. This is NON-STANDARD.
|
|
51393
|
-
*/
|
|
51394
|
-
constructor (stream, options = {}, workerOptions = {}) {
|
|
51395
|
-
const { mimeType, audioBitsPerSecond, videoBitsPerSecond, bitsPerSecond } = options; // eslint-disable-line
|
|
51396
|
-
// NON-STANDARD options
|
|
51397
|
-
const { encoderWorkerFactory, OggOpusEncoderWasmPath, WebMOpusEncoderWasmPath } = workerOptions;
|
|
51398
|
-
|
|
51399
|
-
super();
|
|
51400
|
-
// Attributes for the specification conformance. These have their own getters.
|
|
51401
|
-
this._stream = stream;
|
|
51402
|
-
this._state = 'inactive';
|
|
51403
|
-
this._mimeType = mimeType || '';
|
|
51404
|
-
this._audioBitsPerSecond = audioBitsPerSecond || bitsPerSecond;
|
|
51405
|
-
/** @type {'inactive'|'readyToInit'|'encoding'|'closed'} */
|
|
51406
|
-
this.workerState = 'inactive';
|
|
51407
|
-
|
|
51408
|
-
// Parse MIME Type
|
|
51409
|
-
if (!OpusMediaRecorder.isTypeSupported(this._mimeType)) {
|
|
51410
|
-
throw new TypeError('invalid arguments, a MIME Type is not supported');
|
|
51411
|
-
}
|
|
51412
|
-
switch (OpusMediaRecorder._parseType(this._mimeType).subtype) {
|
|
51413
|
-
case 'wave':
|
|
51414
|
-
case 'wav':
|
|
51415
|
-
this._mimeType = 'audio/wave';
|
|
51416
|
-
break;
|
|
51417
|
-
|
|
51418
|
-
case 'webm':
|
|
51419
|
-
this._mimeType = 'audio/webm';
|
|
51420
|
-
break;
|
|
51421
|
-
|
|
51422
|
-
case 'ogg':
|
|
51423
|
-
this._mimeType = 'audio/ogg';
|
|
51424
|
-
break;
|
|
51425
|
-
|
|
51426
|
-
default:
|
|
51427
|
-
// Select a type depending on OS.
|
|
51428
|
-
switch (browser && browser.name) {
|
|
51429
|
-
case 'chrome':
|
|
51430
|
-
this._mimeType = 'audio/webm';
|
|
51431
|
-
break;
|
|
51432
|
-
|
|
51433
|
-
case 'firefox':
|
|
51434
|
-
this._mimeType = 'audio/ogg';
|
|
51435
|
-
break;
|
|
51436
|
-
|
|
51437
|
-
case 'edge':
|
|
51438
|
-
this._mimeType = 'audio/webm';
|
|
51439
|
-
break;
|
|
51440
|
-
|
|
51441
|
-
case 'ios':
|
|
51442
|
-
case 'safari':
|
|
51443
|
-
this._mimeType = 'audio/wave';
|
|
51444
|
-
break;
|
|
51445
|
-
|
|
51446
|
-
default:
|
|
51447
|
-
this._mimeType = 'audio/webm';
|
|
51448
|
-
}
|
|
51449
|
-
}
|
|
51450
|
-
switch (this._mimeType) {
|
|
51451
|
-
case 'audio/wave':
|
|
51452
|
-
this._wasmPath = ''; // wasm is not used
|
|
51453
|
-
break;
|
|
51454
|
-
|
|
51455
|
-
case 'audio/webm':
|
|
51456
|
-
this._wasmPath = WebMOpusEncoderWasmPath || '';
|
|
51457
|
-
break;
|
|
51458
|
-
|
|
51459
|
-
case 'audio/ogg':
|
|
51460
|
-
this._wasmPath = OggOpusEncoderWasmPath || '';
|
|
51461
|
-
break;
|
|
51462
|
-
|
|
51463
|
-
default:
|
|
51464
|
-
throw new Error(`Internal Error: Unexpected MIME Type: ${this._mimeType}`);
|
|
51465
|
-
}
|
|
51466
|
-
|
|
51467
|
-
// Get current directory for worker
|
|
51468
|
-
let workerDir = '';
|
|
51469
|
-
if (document.currentScript) {
|
|
51470
|
-
workerDir = document.currentScript.src;
|
|
51471
|
-
} else if (self.location) {
|
|
51472
|
-
workerDir = self.location.href;
|
|
51473
|
-
}
|
|
51474
|
-
workerDir = workerDir.substr(0, workerDir.lastIndexOf('/')) +
|
|
51475
|
-
'/encoderWorker.umd.js';
|
|
51476
|
-
// If worker function is imported via <script> tag, make it blob to get URL.
|
|
51477
|
-
if (typeof OpusMediaRecorder.encoderWorker === 'function') {
|
|
51478
|
-
workerDir = URL.createObjectURL(new Blob([`(${OpusMediaRecorder.encoderWorker})()`]));
|
|
51479
|
-
}
|
|
51480
|
-
|
|
51481
|
-
// Spawn a encoder worker
|
|
51482
|
-
this._workerFactory = typeof encoderWorkerFactory === 'function'
|
|
51483
|
-
? encoderWorkerFactory
|
|
51484
|
-
: _ => new Worker(workerDir);
|
|
51485
|
-
this._spawnWorker();
|
|
51486
|
-
}
|
|
51487
|
-
|
|
51488
|
-
/**
|
|
51489
|
-
* The MediaStream [GETUSERMEDIA] to be recorded.
|
|
51490
|
-
* @return {MediaStream}
|
|
51491
|
-
*/
|
|
51492
|
-
get stream () {
|
|
51493
|
-
return this._stream;
|
|
51494
|
-
}
|
|
51495
|
-
|
|
51496
|
-
/**
|
|
51497
|
-
* The MIME type [RFC2046] that has been selected as the container for
|
|
51498
|
-
* recording. This entry includes all the parameters to the base
|
|
51499
|
-
* mimeType. The UA should be able to play back any of the MIME types
|
|
51500
|
-
* it supports for recording. For example, it should be able to display
|
|
51501
|
-
* a video recording in the HTML <video> tag. The default value for
|
|
51502
|
-
* this property is platform-specific.
|
|
51503
|
-
* @return {string}
|
|
51504
|
-
*/
|
|
51505
|
-
get mimeType () {
|
|
51506
|
-
return this._mimeType;
|
|
51507
|
-
}
|
|
51508
|
-
|
|
51509
|
-
/**
|
|
51510
|
-
* The current state of the OpusMediaRecorder object. When the OpusMediaRecorder
|
|
51511
|
-
* is created, the UA MUST set this attribute to inactive.
|
|
51512
|
-
* @return {"inactive"|"recording"|"paused"}
|
|
51513
|
-
*/
|
|
51514
|
-
get state () {
|
|
51515
|
-
return this._state;
|
|
51516
|
-
}
|
|
51517
|
-
|
|
51518
|
-
/**
|
|
51519
|
-
* The value of the Video encoding. Unsupported.
|
|
51520
|
-
* @return {undefined}
|
|
51521
|
-
*/
|
|
51522
|
-
get videoBitsPerSecond () {
|
|
51523
|
-
// Video encoding is not supported
|
|
51524
|
-
return undefined;
|
|
51525
|
-
}
|
|
51526
|
-
|
|
51527
|
-
/**
|
|
51528
|
-
* The value of the Audio encoding target bit rate that was passed to
|
|
51529
|
-
* the Platform (potentially truncated, rounded, etc), or the calculated one
|
|
51530
|
-
* if the user has specified bitsPerSecond.
|
|
51531
|
-
* @return {number|undefined}
|
|
51532
|
-
*/
|
|
51533
|
-
get audioBitsPerSecond () {
|
|
51534
|
-
return this._audioBitsPerSecond;
|
|
51535
|
-
}
|
|
51536
|
-
|
|
51537
|
-
/**
|
|
51538
|
-
* Initialize worker
|
|
51539
|
-
*/
|
|
51540
|
-
_spawnWorker () {
|
|
51541
|
-
this.worker = this._workerFactory();
|
|
51542
|
-
this.worker.onmessage = (e) => this._onmessageFromWorker(e);
|
|
51543
|
-
this.worker.onerror = (e) => this._onerrorFromWorker(e);
|
|
51544
|
-
|
|
51545
|
-
this._postMessageToWorker('loadEncoder',
|
|
51546
|
-
{ mimeType: this._mimeType,
|
|
51547
|
-
wasmPath: this._wasmPath });
|
|
51548
|
-
}
|
|
51549
|
-
|
|
51550
|
-
/**
|
|
51551
|
-
* Post message to the encoder web worker.
|
|
51552
|
-
* @param {"init"|"pushInputData"|"getEncodedData"|"done"} command - Type of message to send to the worker
|
|
51553
|
-
* @param {object} message - Payload to the worker
|
|
51554
|
-
*/
|
|
51555
|
-
_postMessageToWorker (command, message = {}) {
|
|
51556
|
-
switch (command) {
|
|
51557
|
-
case 'loadEncoder':
|
|
51558
|
-
let { mimeType, wasmPath } = message;
|
|
51559
|
-
this.worker.postMessage({ command, mimeType, wasmPath });
|
|
51560
|
-
break;
|
|
51561
|
-
|
|
51562
|
-
case 'init':
|
|
51563
|
-
// Initialize the worker
|
|
51564
|
-
let { sampleRate, channelCount, bitsPerSecond } = message;
|
|
51565
|
-
this.worker.postMessage({ command, sampleRate, channelCount, bitsPerSecond });
|
|
51566
|
-
this.workerState = 'encoding';
|
|
51567
|
-
|
|
51568
|
-
// Start streaming
|
|
51569
|
-
this.source.connect(this.processor);
|
|
51570
|
-
this.processor.connect(this.context.destination);
|
|
51571
|
-
let eventToPush = new __webpack_require__.g.Event('start');
|
|
51572
|
-
this.dispatchEvent(eventToPush);
|
|
51573
|
-
break;
|
|
51574
|
-
|
|
51575
|
-
case 'pushInputData':
|
|
51576
|
-
// Pass input audio buffer to the encoder to encode.
|
|
51577
|
-
// The worker MAY trigger 'encodedData'.
|
|
51578
|
-
let { channelBuffers, length, duration } = message;
|
|
51579
|
-
this.worker.postMessage({
|
|
51580
|
-
command, channelBuffers, length, duration
|
|
51581
|
-
});
|
|
51582
|
-
break;
|
|
51583
|
-
|
|
51584
|
-
case 'getEncodedData':
|
|
51585
|
-
// Request encoded result.
|
|
51586
|
-
// Expected 'encodedData' event from the worker
|
|
51587
|
-
this.worker.postMessage({ command });
|
|
51588
|
-
break;
|
|
51589
|
-
|
|
51590
|
-
case 'done':
|
|
51591
|
-
// Tell encoder finallize the job and destory itself.
|
|
51592
|
-
// Expected 'lastEncodedData' event from the worker.
|
|
51593
|
-
this.worker.postMessage({ command });
|
|
51594
|
-
break;
|
|
51595
|
-
|
|
51596
|
-
default:
|
|
51597
|
-
// This is an error case
|
|
51598
|
-
throw new Error('Internal Error: Incorrect postMessage requested.');
|
|
51599
|
-
}
|
|
51600
|
-
}
|
|
51601
|
-
|
|
51602
|
-
/**
|
|
51603
|
-
* onmessage() callback from the worker.
|
|
51604
|
-
* @param {message} event - message from the worker
|
|
51605
|
-
*/
|
|
51606
|
-
_onmessageFromWorker (event) {
|
|
51607
|
-
const { command, buffers } = event.data;
|
|
51608
|
-
let eventToPush;
|
|
51609
|
-
switch (command) {
|
|
51610
|
-
case 'readyToInit':
|
|
51611
|
-
const { sampleRate, channelCount } = this;
|
|
51612
|
-
this.workerState = 'readyToInit';
|
|
51613
|
-
|
|
51614
|
-
// If start() is already called initialize worker
|
|
51615
|
-
if (this.state === 'recording') {
|
|
51616
|
-
this._postMessageToWorker('init',
|
|
51617
|
-
{ sampleRate,
|
|
51618
|
-
channelCount,
|
|
51619
|
-
bitsPerSecond: this.audioBitsPerSecond});
|
|
51620
|
-
}
|
|
51621
|
-
break;
|
|
51622
|
-
|
|
51623
|
-
case 'encodedData':
|
|
51624
|
-
case 'lastEncodedData':
|
|
51625
|
-
let data = new Blob(buffers, {'type': this._mimeType});
|
|
51626
|
-
eventToPush = new __webpack_require__.g.Event('dataavailable');
|
|
51627
|
-
eventToPush.data = data;
|
|
51628
|
-
this.dispatchEvent(eventToPush);
|
|
51629
|
-
|
|
51630
|
-
// Detect of stop() called before
|
|
51631
|
-
if (command === 'lastEncodedData') {
|
|
51632
|
-
eventToPush = new __webpack_require__.g.Event('stop');
|
|
51633
|
-
this.dispatchEvent(eventToPush);
|
|
51634
|
-
|
|
51635
|
-
this.workerState = 'closed';
|
|
51636
|
-
}
|
|
51637
|
-
break;
|
|
51638
|
-
|
|
51639
|
-
default:
|
|
51640
|
-
break; // Ignore
|
|
51641
|
-
}
|
|
51642
|
-
}
|
|
51643
|
-
|
|
51644
|
-
/**
|
|
51645
|
-
* onerror() callback from the worker.
|
|
51646
|
-
* @param {ErrorEvent} error - error object from the worker
|
|
51647
|
-
*/
|
|
51648
|
-
_onerrorFromWorker (error) {
|
|
51649
|
-
// Stop stream first
|
|
51650
|
-
this.source.disconnect();
|
|
51651
|
-
this.processor.disconnect();
|
|
51652
|
-
|
|
51653
|
-
this.worker.terminate();
|
|
51654
|
-
this.workerState = 'closed';
|
|
51655
|
-
|
|
51656
|
-
// Send message to host
|
|
51657
|
-
let message = [
|
|
51658
|
-
'FileName: ' + error.filename,
|
|
51659
|
-
'LineNumber: ' + error.lineno,
|
|
51660
|
-
'Message: ' + error.message
|
|
51661
|
-
].join(' - ');
|
|
51662
|
-
let errorToPush = new __webpack_require__.g.Event('error');
|
|
51663
|
-
errorToPush.name = 'UnknownError';
|
|
51664
|
-
errorToPush.message = message;
|
|
51665
|
-
this.dispatchEvent(errorToPush);
|
|
51666
|
-
}
|
|
51667
|
-
|
|
51668
|
-
/**
|
|
51669
|
-
* Enable onaudioprocess() callback.
|
|
51670
|
-
* @param {number} timeslice - In seconds. OpusMediaRecorder should request data
|
|
51671
|
-
* from the worker every timeslice seconds.
|
|
51672
|
-
*/
|
|
51673
|
-
_enableAudioProcessCallback (timeslice) {
|
|
51674
|
-
// pass frame buffers to the worker
|
|
51675
|
-
let elapsedTime = 0;
|
|
51676
|
-
this.processor.onaudioprocess = (e) => {
|
|
51677
|
-
const { inputBuffer, playbackTime } = e; // eslint-disable-line
|
|
51678
|
-
const { sampleRate, length, duration, numberOfChannels } = inputBuffer; // eslint-disable-line
|
|
51679
|
-
|
|
51680
|
-
// Create channel buffers to pass to the worker
|
|
51681
|
-
const channelBuffers = new Array(numberOfChannels);
|
|
51682
|
-
for (let i = 0; i < numberOfChannels; i++) {
|
|
51683
|
-
channelBuffers[i] = inputBuffer.getChannelData(i);
|
|
51684
|
-
}
|
|
51685
|
-
|
|
51686
|
-
// Pass data to the worker
|
|
51687
|
-
const message = { channelBuffers, length, duration };
|
|
51688
|
-
this._postMessageToWorker('pushInputData', message);
|
|
51689
|
-
|
|
51690
|
-
// Calculate time
|
|
51691
|
-
elapsedTime += duration;
|
|
51692
|
-
if (elapsedTime >= timeslice) {
|
|
51693
|
-
this._postMessageToWorker('getEncodedData');
|
|
51694
|
-
elapsedTime = 0;
|
|
51695
|
-
}
|
|
51696
|
-
};
|
|
51697
|
-
}
|
|
51698
|
-
|
|
51699
|
-
/**
|
|
51700
|
-
* Begins recording media; this method can optionally be passed a timeslice
|
|
51701
|
-
* argument with a value in milliseconds.
|
|
51702
|
-
* @param {number} timeslice - If this is specified, the media will be captured
|
|
51703
|
-
* in separate chunks of that duration, rather than the default behavior
|
|
51704
|
-
* of recording the media in a single large chunk. In other words, an
|
|
51705
|
-
* undefined value of timeslice will be understood as the largest long value.
|
|
51706
|
-
*/
|
|
51707
|
-
start (timeslice = Number.MAX_SAFE_INTEGER) {
|
|
51708
|
-
if (this.state !== 'inactive') {
|
|
51709
|
-
throw new Error('DOMException: INVALID_STATE_ERR, state must be inactive.');
|
|
51710
|
-
}
|
|
51711
|
-
if (timeslice < 0) {
|
|
51712
|
-
throw new TypeError('invalid arguments, timeslice should be 0 or higher.');
|
|
51713
|
-
}
|
|
51714
|
-
timeslice /= 1000; // Convert milliseconds to seconds
|
|
51715
|
-
|
|
51716
|
-
// Check worker is closed (usually by stop()) and init.
|
|
51717
|
-
if (this.workerState === 'closed') {
|
|
51718
|
-
this._spawnWorker();
|
|
51719
|
-
}
|
|
51720
|
-
|
|
51721
|
-
// Get channel count and sampling rate
|
|
51722
|
-
// channelCount: https://www.w3.org/TR/mediacapture-streams/#media-track-settings
|
|
51723
|
-
// sampleRate: https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/sampleRate
|
|
51724
|
-
this.context = new AudioContext();
|
|
51725
|
-
let tracks = this.stream.getAudioTracks();
|
|
51726
|
-
if (!tracks[0]) {
|
|
51727
|
-
throw new Error('DOMException: UnkownError, media track not found.');
|
|
51728
|
-
}
|
|
51729
|
-
this.channelCount = tracks[0].getSettings().channelCount || 1;
|
|
51730
|
-
this.sampleRate = this.context.sampleRate;
|
|
51731
|
-
|
|
51732
|
-
/** @type {MediaStreamAudioSourceNode} */
|
|
51733
|
-
this.source = this.context.createMediaStreamSource(this.stream);
|
|
51734
|
-
/** @type {ScriptProcessorNode} */
|
|
51735
|
-
this.processor = this.context.createScriptProcessor(BUFFER_SIZE, this.channelCount, this.channelCount);
|
|
51736
|
-
|
|
51737
|
-
// Start recording
|
|
51738
|
-
this._state = 'recording';
|
|
51739
|
-
this._enableAudioProcessCallback(timeslice);
|
|
51740
|
-
|
|
51741
|
-
// If the worker is already loaded then start
|
|
51742
|
-
if (this.workerState === 'readyToInit') {
|
|
51743
|
-
const { sampleRate, channelCount } = this;
|
|
51744
|
-
this._postMessageToWorker('init',
|
|
51745
|
-
{ sampleRate,
|
|
51746
|
-
channelCount,
|
|
51747
|
-
bitsPerSecond: this.audioBitsPerSecond });
|
|
51748
|
-
}
|
|
51749
|
-
}
|
|
51750
|
-
|
|
51751
|
-
/**
|
|
51752
|
-
* Stops recording, at which point a dataavailable event containing
|
|
51753
|
-
* the final Blob of saved data is fired. No more recording occurs.
|
|
51754
|
-
*/
|
|
51755
|
-
stop () {
|
|
51756
|
-
if (this.state === 'inactive') {
|
|
51757
|
-
throw new Error('DOMException: INVALID_STATE_ERR, state must NOT be inactive.');
|
|
51758
|
-
}
|
|
51759
|
-
|
|
51760
|
-
// Stop stream first
|
|
51761
|
-
this.source.disconnect();
|
|
51762
|
-
this.processor.disconnect();
|
|
51763
|
-
this.context.close();
|
|
51764
|
-
|
|
51765
|
-
// Stop event will be triggered at _onmessageFromWorker(),
|
|
51766
|
-
this._postMessageToWorker('done');
|
|
51767
|
-
|
|
51768
|
-
this._state = 'inactive';
|
|
51769
|
-
}
|
|
51770
|
-
|
|
51771
|
-
/**
|
|
51772
|
-
* Pauses the recording of media.
|
|
51773
|
-
*/
|
|
51774
|
-
pause () {
|
|
51775
|
-
if (this.state === 'inactive') {
|
|
51776
|
-
throw new Error('DOMException: INVALID_STATE_ERR, state must NOT be inactive.');
|
|
51777
|
-
}
|
|
51778
|
-
|
|
51779
|
-
// Stop stream first
|
|
51780
|
-
this.source.disconnect();
|
|
51781
|
-
this.processor.disconnect();
|
|
51782
|
-
|
|
51783
|
-
let event = new __webpack_require__.g.Event('pause');
|
|
51784
|
-
this.dispatchEvent(event);
|
|
51785
|
-
this._state = 'paused';
|
|
51786
|
-
}
|
|
51787
|
-
|
|
51788
|
-
/**
|
|
51789
|
-
* Resumes recording of media after having been paused.
|
|
51790
|
-
*/
|
|
51791
|
-
resume () {
|
|
51792
|
-
if (this.state === 'inactive') {
|
|
51793
|
-
throw new Error('DOMException: INVALID_STATE_ERR, state must NOT be inactive.');
|
|
51794
|
-
}
|
|
51795
|
-
|
|
51796
|
-
// Restart streaming data
|
|
51797
|
-
this.source.connect(this.processor);
|
|
51798
|
-
this.processor.connect(this.context.destination);
|
|
51799
|
-
|
|
51800
|
-
let event = new __webpack_require__.g.Event('resume');
|
|
51801
|
-
this.dispatchEvent(event);
|
|
51802
|
-
this._state = 'recording';
|
|
51803
|
-
}
|
|
51804
|
-
|
|
51805
|
-
/**
|
|
51806
|
-
* Requests a Blob containing the saved data received thus far (or since
|
|
51807
|
-
* the last time requestData() was called. After calling this method,
|
|
51808
|
-
* recording continues, but in a new Blob.
|
|
51809
|
-
*/
|
|
51810
|
-
requestData () {
|
|
51811
|
-
if (this.state === 'inactive') {
|
|
51812
|
-
throw new Error('DOMException: INVALID_STATE_ERR, state must NOT be inactive.');
|
|
51813
|
-
}
|
|
51814
|
-
|
|
51815
|
-
// dataavailable event will be triggerd at _onmessageFromWorker()
|
|
51816
|
-
this._postMessageToWorker('getEncodedData');
|
|
51817
|
-
}
|
|
51818
|
-
|
|
51819
|
-
/**
|
|
51820
|
-
* Returns a Boolean value indicating if the given MIME type is supported
|
|
51821
|
-
* by the current user agent .
|
|
51822
|
-
* @param {string} typeType - A MIME Type, including parameters when needed,
|
|
51823
|
-
* specifying a container and/or codec formats for recording.
|
|
51824
|
-
* @return {boolean}
|
|
51825
|
-
*/
|
|
51826
|
-
static isTypeSupported (mimeType) {
|
|
51827
|
-
// See: https://w3c.github.io/mediacapture-record/#dom-mediarecorder-istypesupported
|
|
51828
|
-
|
|
51829
|
-
// 1. If empty string, return true.
|
|
51830
|
-
if (typeof mimeType === 'string' && !mimeType) {
|
|
51831
|
-
return true;
|
|
51832
|
-
}
|
|
51833
|
-
try {
|
|
51834
|
-
var {type, subtype, codec} = OpusMediaRecorder._parseType(mimeType);
|
|
51835
|
-
} catch (error) {
|
|
51836
|
-
// 2. If not a valid string, return false.
|
|
51837
|
-
return false;
|
|
51838
|
-
}
|
|
51839
|
-
if (type !== 'audio' ||
|
|
51840
|
-
!(subtype === 'ogg' || subtype === 'webm' ||
|
|
51841
|
-
subtype === 'wave' || subtype === 'wav')) {
|
|
51842
|
-
// 3,4. If type and subtype are unsupported the return false.
|
|
51843
|
-
return false;
|
|
51844
|
-
}
|
|
51845
|
-
// 5. If codec is unsupported then return false.
|
|
51846
|
-
// 6. If the specified combination of all is not supported than return false.
|
|
51847
|
-
switch (subtype) {
|
|
51848
|
-
case 'ogg':
|
|
51849
|
-
if (codec !== 'opus' && codec) {
|
|
51850
|
-
return false;
|
|
51851
|
-
}
|
|
51852
|
-
break;
|
|
51853
|
-
case 'webm':
|
|
51854
|
-
if (codec !== 'opus' && codec) {
|
|
51855
|
-
return false;
|
|
51856
|
-
}
|
|
51857
|
-
break;
|
|
51858
|
-
case 'wave':
|
|
51859
|
-
case 'wav':
|
|
51860
|
-
if (codec) {
|
|
51861
|
-
return false; // Currently only supports signed 16 bits
|
|
51862
|
-
}
|
|
51863
|
-
break;
|
|
51864
|
-
}
|
|
51865
|
-
// 7. return true.
|
|
51866
|
-
return true;
|
|
51867
|
-
}
|
|
51868
|
-
|
|
51869
|
-
/**
|
|
51870
|
-
* Parse MIME. A helper function for isTypeSupported() and etc.
|
|
51871
|
-
* @param {string} mimeType - typeType - A MIME Type, including parameters when needed,
|
|
51872
|
-
* specifying a container and/or codec formats for recording.
|
|
51873
|
-
* @return {?object} - An object with type, subtype, codec attributes
|
|
51874
|
-
* if parsed correctly. null is returned if parsing failed.
|
|
51875
|
-
* If mimeType is an empty string then return an object with attributes
|
|
51876
|
-
* are empty strings
|
|
51877
|
-
*/
|
|
51878
|
-
static _parseType (mimeType) {
|
|
51879
|
-
try {
|
|
51880
|
-
const regex = /^(\w+)\/(\w+)(;\s*codecs=(\w+))?$/;
|
|
51881
|
-
var [, type, subtype, , codec] = mimeType.match(regex);
|
|
51882
|
-
} catch (error) {
|
|
51883
|
-
if (typeof mimeType === 'string' && !mimeType) {
|
|
51884
|
-
return {type: '', subtype: '', codec: ''};
|
|
51885
|
-
}
|
|
51886
|
-
return null;
|
|
51887
|
-
}
|
|
51888
|
-
return {type, subtype, codec};
|
|
51889
|
-
}
|
|
51890
|
-
}
|
|
51891
|
-
|
|
51892
|
-
// EventHandler attributes.
|
|
51893
|
-
// This code is a non-standard EventTarget but required by event-target-shim.
|
|
51894
|
-
[
|
|
51895
|
-
'start', // Called to handle the {@link MediaRecorder#start} event.
|
|
51896
|
-
'stop', // Called to handle the stop event.
|
|
51897
|
-
'dataavailable', /* Called to handle the dataavailable event. The Blob of
|
|
51898
|
-
recorded data is contained in this event and can be
|
|
51899
|
-
accessed via its data attribute. */
|
|
51900
|
-
'pause', // Called to handle the pause event.
|
|
51901
|
-
'resume', // Called to handle the resume event.
|
|
51902
|
-
'error' // Called to handle a MediaRecorderErrorEvent.
|
|
51903
|
-
].forEach(name => defineEventAttribute(OpusMediaRecorder.prototype, name));
|
|
51904
|
-
|
|
51905
|
-
// MS Edge specific monkey patching:
|
|
51906
|
-
// onaudioprocess callback cannot be triggered more than twice when postMessage
|
|
51907
|
-
// uses the seconde transfer argument. So disable the transfer argument only in Edge.
|
|
51908
|
-
if (browser && browser.name === 'edge') {
|
|
51909
|
-
(function () {
|
|
51910
|
-
var original = Worker.prototype.postMessage;
|
|
51911
|
-
Worker.prototype.postMessage = function (message, transfer = null) {
|
|
51912
|
-
original.apply(this, [message]);
|
|
51913
|
-
};
|
|
51914
|
-
})();
|
|
51915
|
-
}
|
|
51916
|
-
|
|
51917
|
-
module.exports = OpusMediaRecorder;
|
|
51918
|
-
|
|
51919
|
-
|
|
51920
|
-
/***/ }),
|
|
51921
|
-
/* 325 */
|
|
51922
|
-
/***/ ((module, exports) => {
|
|
51923
|
-
|
|
51924
|
-
"use strict";
|
|
51925
|
-
/**
|
|
51926
|
-
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
51927
|
-
* @copyright 2015 Toru Nagashima. All rights reserved.
|
|
51928
|
-
* See LICENSE file in root directory for full license.
|
|
51929
|
-
*/
|
|
51930
|
-
|
|
51931
|
-
|
|
51932
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51933
|
-
|
|
51934
|
-
/**
|
|
51935
|
-
* @typedef {object} PrivateData
|
|
51936
|
-
* @property {EventTarget} eventTarget The event target.
|
|
51937
|
-
* @property {{type:string}} event The original event object.
|
|
51938
|
-
* @property {number} eventPhase The current event phase.
|
|
51939
|
-
* @property {EventTarget|null} currentTarget The current event target.
|
|
51940
|
-
* @property {boolean} canceled The flag to prevent default.
|
|
51941
|
-
* @property {boolean} stopped The flag to stop propagation immediately.
|
|
51942
|
-
* @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null.
|
|
51943
|
-
* @property {number} timeStamp The unix time.
|
|
51944
|
-
* @private
|
|
51945
|
-
*/
|
|
51946
|
-
|
|
51947
|
-
/**
|
|
51948
|
-
* Private data for event wrappers.
|
|
51949
|
-
* @type {WeakMap<Event, PrivateData>}
|
|
51950
|
-
* @private
|
|
51951
|
-
*/
|
|
51952
|
-
const privateData = new WeakMap();
|
|
51953
|
-
|
|
51954
|
-
/**
|
|
51955
|
-
* Cache for wrapper classes.
|
|
51956
|
-
* @type {WeakMap<Object, Function>}
|
|
51957
|
-
* @private
|
|
51958
|
-
*/
|
|
51959
|
-
const wrappers = new WeakMap();
|
|
51960
|
-
|
|
51961
|
-
/**
|
|
51962
|
-
* Get private data.
|
|
51963
|
-
* @param {Event} event The event object to get private data.
|
|
51964
|
-
* @returns {PrivateData} The private data of the event.
|
|
51965
|
-
* @private
|
|
51966
|
-
*/
|
|
51967
|
-
function pd(event) {
|
|
51968
|
-
const retv = privateData.get(event);
|
|
51969
|
-
console.assert(retv != null, "'this' is expected an Event object, but got", event);
|
|
51970
|
-
return retv
|
|
51971
|
-
}
|
|
51972
|
-
|
|
51973
|
-
/**
|
|
51974
|
-
* @see https://dom.spec.whatwg.org/#interface-event
|
|
51975
|
-
* @private
|
|
51976
|
-
*/
|
|
51977
|
-
/**
|
|
51978
|
-
* The event wrapper.
|
|
51979
|
-
* @constructor
|
|
51980
|
-
* @param {EventTarget} eventTarget The event target of this dispatching.
|
|
51981
|
-
* @param {Event|{type:string}} event The original event to wrap.
|
|
51982
|
-
*/
|
|
51983
|
-
function Event(eventTarget, event) {
|
|
51984
|
-
privateData.set(this, {
|
|
51985
|
-
eventTarget,
|
|
51986
|
-
event,
|
|
51987
|
-
eventPhase: 2,
|
|
51988
|
-
currentTarget: eventTarget,
|
|
51989
|
-
canceled: false,
|
|
51990
|
-
stopped: false,
|
|
51991
|
-
passiveListener: null,
|
|
51992
|
-
timeStamp: event.timeStamp || Date.now(),
|
|
51993
|
-
});
|
|
51994
|
-
|
|
51995
|
-
// https://heycam.github.io/webidl/#Unforgeable
|
|
51996
|
-
Object.defineProperty(this, "isTrusted", { value: false, enumerable: true });
|
|
51997
|
-
|
|
51998
|
-
// Define accessors
|
|
51999
|
-
const keys = Object.keys(event);
|
|
52000
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
52001
|
-
const key = keys[i];
|
|
52002
|
-
if (!(key in this)) {
|
|
52003
|
-
Object.defineProperty(this, key, defineRedirectDescriptor(key));
|
|
52004
|
-
}
|
|
52005
|
-
}
|
|
52006
|
-
}
|
|
52007
|
-
|
|
52008
|
-
// Should be enumerable, but class methods are not enumerable.
|
|
52009
|
-
Event.prototype = {
|
|
52010
|
-
/**
|
|
52011
|
-
* The type of this event.
|
|
52012
|
-
* @type {string}
|
|
52013
|
-
*/
|
|
52014
|
-
get type() {
|
|
52015
|
-
return pd(this).event.type
|
|
52016
|
-
},
|
|
52017
|
-
|
|
52018
|
-
/**
|
|
52019
|
-
* The target of this event.
|
|
52020
|
-
* @type {EventTarget}
|
|
52021
|
-
*/
|
|
52022
|
-
get target() {
|
|
52023
|
-
return pd(this).eventTarget
|
|
52024
|
-
},
|
|
52025
|
-
|
|
52026
|
-
/**
|
|
52027
|
-
* The target of this event.
|
|
52028
|
-
* @type {EventTarget}
|
|
52029
|
-
*/
|
|
52030
|
-
get currentTarget() {
|
|
52031
|
-
return pd(this).currentTarget
|
|
52032
|
-
},
|
|
52033
|
-
|
|
52034
|
-
/**
|
|
52035
|
-
* @returns {EventTarget[]} The composed path of this event.
|
|
52036
|
-
*/
|
|
52037
|
-
composedPath() {
|
|
52038
|
-
const currentTarget = pd(this).currentTarget;
|
|
52039
|
-
if (currentTarget == null) {
|
|
52040
|
-
return []
|
|
52041
|
-
}
|
|
52042
|
-
return [currentTarget]
|
|
52043
|
-
},
|
|
52044
|
-
|
|
52045
|
-
/**
|
|
52046
|
-
* Constant of NONE.
|
|
52047
|
-
* @type {number}
|
|
52048
|
-
*/
|
|
52049
|
-
get NONE() {
|
|
52050
|
-
return 0
|
|
52051
|
-
},
|
|
52052
|
-
|
|
52053
|
-
/**
|
|
52054
|
-
* Constant of CAPTURING_PHASE.
|
|
52055
|
-
* @type {number}
|
|
52056
|
-
*/
|
|
52057
|
-
get CAPTURING_PHASE() {
|
|
52058
|
-
return 1
|
|
52059
|
-
},
|
|
52060
|
-
|
|
52061
|
-
/**
|
|
52062
|
-
* Constant of AT_TARGET.
|
|
52063
|
-
* @type {number}
|
|
52064
|
-
*/
|
|
52065
|
-
get AT_TARGET() {
|
|
52066
|
-
return 2
|
|
52067
|
-
},
|
|
52068
|
-
|
|
52069
|
-
/**
|
|
52070
|
-
* Constant of BUBBLING_PHASE.
|
|
52071
|
-
* @type {number}
|
|
52072
|
-
*/
|
|
52073
|
-
get BUBBLING_PHASE() {
|
|
52074
|
-
return 3
|
|
52075
|
-
},
|
|
52076
|
-
|
|
52077
|
-
/**
|
|
52078
|
-
* The target of this event.
|
|
52079
|
-
* @type {number}
|
|
52080
|
-
*/
|
|
52081
|
-
get eventPhase() {
|
|
52082
|
-
return pd(this).eventPhase
|
|
52083
|
-
},
|
|
52084
|
-
|
|
52085
|
-
/**
|
|
52086
|
-
* Stop event bubbling.
|
|
52087
|
-
* @returns {void}
|
|
52088
|
-
*/
|
|
52089
|
-
stopPropagation() {
|
|
52090
|
-
const data = pd(this);
|
|
52091
|
-
if (typeof data.event.stopPropagation === "function") {
|
|
52092
|
-
data.event.stopPropagation();
|
|
52093
|
-
}
|
|
52094
|
-
},
|
|
52095
|
-
|
|
52096
|
-
/**
|
|
52097
|
-
* Stop event bubbling.
|
|
52098
|
-
* @returns {void}
|
|
52099
|
-
*/
|
|
52100
|
-
stopImmediatePropagation() {
|
|
52101
|
-
const data = pd(this);
|
|
52102
|
-
|
|
52103
|
-
data.stopped = true;
|
|
52104
|
-
if (typeof data.event.stopImmediatePropagation === "function") {
|
|
52105
|
-
data.event.stopImmediatePropagation();
|
|
52106
|
-
}
|
|
52107
|
-
},
|
|
52108
|
-
|
|
52109
|
-
/**
|
|
52110
|
-
* The flag to be bubbling.
|
|
52111
|
-
* @type {boolean}
|
|
52112
|
-
*/
|
|
52113
|
-
get bubbles() {
|
|
52114
|
-
return Boolean(pd(this).event.bubbles)
|
|
52115
|
-
},
|
|
52116
|
-
|
|
52117
|
-
/**
|
|
52118
|
-
* The flag to be cancelable.
|
|
52119
|
-
* @type {boolean}
|
|
52120
|
-
*/
|
|
52121
|
-
get cancelable() {
|
|
52122
|
-
return Boolean(pd(this).event.cancelable)
|
|
52123
|
-
},
|
|
52124
|
-
|
|
52125
|
-
/**
|
|
52126
|
-
* Cancel this event.
|
|
52127
|
-
* @returns {void}
|
|
52128
|
-
*/
|
|
52129
|
-
preventDefault() {
|
|
52130
|
-
const data = pd(this);
|
|
52131
|
-
if (data.passiveListener != null) {
|
|
52132
|
-
console.warn("Event#preventDefault() was called from a passive listener:", data.passiveListener);
|
|
52133
|
-
return
|
|
52134
|
-
}
|
|
52135
|
-
if (!data.event.cancelable) {
|
|
52136
|
-
return
|
|
52137
|
-
}
|
|
52138
|
-
|
|
52139
|
-
data.canceled = true;
|
|
52140
|
-
if (typeof data.event.preventDefault === "function") {
|
|
52141
|
-
data.event.preventDefault();
|
|
52142
|
-
}
|
|
52143
|
-
},
|
|
52144
|
-
|
|
52145
|
-
/**
|
|
52146
|
-
* The flag to indicate cancellation state.
|
|
52147
|
-
* @type {boolean}
|
|
52148
|
-
*/
|
|
52149
|
-
get defaultPrevented() {
|
|
52150
|
-
return pd(this).canceled
|
|
52151
|
-
},
|
|
52152
|
-
|
|
52153
|
-
/**
|
|
52154
|
-
* The flag to be composed.
|
|
52155
|
-
* @type {boolean}
|
|
52156
|
-
*/
|
|
52157
|
-
get composed() {
|
|
52158
|
-
return Boolean(pd(this).event.composed)
|
|
52159
|
-
},
|
|
52160
|
-
|
|
52161
|
-
/**
|
|
52162
|
-
* The unix time of this event.
|
|
52163
|
-
* @type {number}
|
|
52164
|
-
*/
|
|
52165
|
-
get timeStamp() {
|
|
52166
|
-
return pd(this).timeStamp
|
|
52167
|
-
},
|
|
52168
|
-
};
|
|
52169
|
-
|
|
52170
|
-
// `constructor` is not enumerable.
|
|
52171
|
-
Object.defineProperty(Event.prototype, "constructor", { value: Event, configurable: true, writable: true });
|
|
52172
|
-
|
|
52173
|
-
// Ensure `event instanceof window.Event` is `true`.
|
|
52174
|
-
if (typeof window !== "undefined" && typeof window.Event !== "undefined") {
|
|
52175
|
-
Object.setPrototypeOf(Event.prototype, window.Event.prototype);
|
|
52176
|
-
|
|
52177
|
-
// Make association for wrappers.
|
|
52178
|
-
wrappers.set(window.Event.prototype, Event);
|
|
52179
|
-
}
|
|
52180
|
-
|
|
52181
|
-
/**
|
|
52182
|
-
* Get the property descriptor to redirect a given property.
|
|
52183
|
-
* @param {string} key Property name to define property descriptor.
|
|
52184
|
-
* @returns {PropertyDescriptor} The property descriptor to redirect the property.
|
|
52185
|
-
* @private
|
|
52186
|
-
*/
|
|
52187
|
-
function defineRedirectDescriptor(key) {
|
|
52188
|
-
return {
|
|
52189
|
-
get() {
|
|
52190
|
-
return pd(this).event[key]
|
|
52191
|
-
},
|
|
52192
|
-
set(value) {
|
|
52193
|
-
pd(this).event[key] = value;
|
|
52194
|
-
},
|
|
52195
|
-
configurable: true,
|
|
52196
|
-
enumerable: true,
|
|
52197
|
-
}
|
|
52198
|
-
}
|
|
52199
|
-
|
|
52200
|
-
/**
|
|
52201
|
-
* Get the property descriptor to call a given method property.
|
|
52202
|
-
* @param {string} key Property name to define property descriptor.
|
|
52203
|
-
* @returns {PropertyDescriptor} The property descriptor to call the method property.
|
|
52204
|
-
* @private
|
|
52205
|
-
*/
|
|
52206
|
-
function defineCallDescriptor(key) {
|
|
52207
|
-
return {
|
|
52208
|
-
value() {
|
|
52209
|
-
const event = pd(this).event;
|
|
52210
|
-
return event[key].apply(event, arguments)
|
|
52211
|
-
},
|
|
52212
|
-
configurable: true,
|
|
52213
|
-
enumerable: true,
|
|
52214
|
-
}
|
|
52215
|
-
}
|
|
52216
|
-
|
|
52217
|
-
/**
|
|
52218
|
-
* Define new wrapper class.
|
|
52219
|
-
* @param {Function} BaseEvent The base wrapper class.
|
|
52220
|
-
* @param {Object} proto The prototype of the original event.
|
|
52221
|
-
* @returns {Function} The defined wrapper class.
|
|
52222
|
-
* @private
|
|
52223
|
-
*/
|
|
52224
|
-
function defineWrapper(BaseEvent, proto) {
|
|
52225
|
-
const keys = Object.keys(proto);
|
|
52226
|
-
if (keys.length === 0) {
|
|
52227
|
-
return BaseEvent
|
|
52228
|
-
}
|
|
52229
|
-
|
|
52230
|
-
/** CustomEvent */
|
|
52231
|
-
function CustomEvent(eventTarget, event) {
|
|
52232
|
-
BaseEvent.call(this, eventTarget, event);
|
|
52233
|
-
}
|
|
52234
|
-
|
|
52235
|
-
CustomEvent.prototype = Object.create(BaseEvent.prototype, {
|
|
52236
|
-
constructor: { value: CustomEvent, configurable: true, writable: true },
|
|
52237
|
-
});
|
|
52238
|
-
|
|
52239
|
-
// Define accessors.
|
|
52240
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
52241
|
-
const key = keys[i];
|
|
52242
|
-
if (!(key in BaseEvent.prototype)) {
|
|
52243
|
-
const descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
|
52244
|
-
const isFunc = (typeof descriptor.value === "function");
|
|
52245
|
-
Object.defineProperty(
|
|
52246
|
-
CustomEvent.prototype,
|
|
52247
|
-
key,
|
|
52248
|
-
isFunc ? defineCallDescriptor(key) : defineRedirectDescriptor(key)
|
|
52249
|
-
);
|
|
52250
|
-
}
|
|
52251
|
-
}
|
|
52252
|
-
|
|
52253
|
-
return CustomEvent
|
|
52254
|
-
}
|
|
52255
|
-
|
|
52256
|
-
/**
|
|
52257
|
-
* Get the wrapper class of a given prototype.
|
|
52258
|
-
* @param {Object} proto The prototype of the original event to get its wrapper.
|
|
52259
|
-
* @returns {Function} The wrapper class.
|
|
52260
|
-
* @private
|
|
52261
|
-
*/
|
|
52262
|
-
function getWrapper(proto) {
|
|
52263
|
-
if (proto == null || proto === Object.prototype) {
|
|
52264
|
-
return Event
|
|
52265
|
-
}
|
|
52266
|
-
|
|
52267
|
-
let wrapper = wrappers.get(proto);
|
|
52268
|
-
if (wrapper == null) {
|
|
52269
|
-
wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto);
|
|
52270
|
-
wrappers.set(proto, wrapper);
|
|
52271
|
-
}
|
|
52272
|
-
return wrapper
|
|
52273
|
-
}
|
|
52274
|
-
|
|
52275
|
-
/**
|
|
52276
|
-
* Wrap a given event to management a dispatching.
|
|
52277
|
-
* @param {EventTarget} eventTarget The event target of this dispatching.
|
|
52278
|
-
* @param {Object} event The event to wrap.
|
|
52279
|
-
* @returns {Event} The wrapper instance.
|
|
52280
|
-
* @private
|
|
52281
|
-
*/
|
|
52282
|
-
function wrapEvent(eventTarget, event) {
|
|
52283
|
-
const Wrapper = getWrapper(Object.getPrototypeOf(event));
|
|
52284
|
-
return new Wrapper(eventTarget, event)
|
|
52285
|
-
}
|
|
52286
|
-
|
|
52287
|
-
/**
|
|
52288
|
-
* Get the stopped flag of a given event.
|
|
52289
|
-
* @param {Event} event The event to get.
|
|
52290
|
-
* @returns {boolean} The flag to stop propagation immediately.
|
|
52291
|
-
* @private
|
|
52292
|
-
*/
|
|
52293
|
-
function isStopped(event) {
|
|
52294
|
-
return pd(event).stopped
|
|
52295
|
-
}
|
|
52296
|
-
|
|
52297
|
-
/**
|
|
52298
|
-
* Set the current event phase of a given event.
|
|
52299
|
-
* @param {Event} event The event to set current target.
|
|
52300
|
-
* @param {number} eventPhase New event phase.
|
|
52301
|
-
* @returns {void}
|
|
52302
|
-
* @private
|
|
52303
|
-
*/
|
|
52304
|
-
function setEventPhase(event, eventPhase) {
|
|
52305
|
-
pd(event).eventPhase = eventPhase;
|
|
52306
|
-
}
|
|
52307
|
-
|
|
52308
|
-
/**
|
|
52309
|
-
* Set the current target of a given event.
|
|
52310
|
-
* @param {Event} event The event to set current target.
|
|
52311
|
-
* @param {EventTarget|null} currentTarget New current target.
|
|
52312
|
-
* @returns {void}
|
|
52313
|
-
* @private
|
|
52314
|
-
*/
|
|
52315
|
-
function setCurrentTarget(event, currentTarget) {
|
|
52316
|
-
pd(event).currentTarget = currentTarget;
|
|
52317
|
-
}
|
|
52318
|
-
|
|
52319
|
-
/**
|
|
52320
|
-
* Set a passive listener of a given event.
|
|
52321
|
-
* @param {Event} event The event to set current target.
|
|
52322
|
-
* @param {Function|null} passiveListener New passive listener.
|
|
52323
|
-
* @returns {void}
|
|
52324
|
-
* @private
|
|
52325
|
-
*/
|
|
52326
|
-
function setPassiveListener(event, passiveListener) {
|
|
52327
|
-
pd(event).passiveListener = passiveListener;
|
|
52328
|
-
}
|
|
52329
|
-
|
|
52330
|
-
/**
|
|
52331
|
-
* @typedef {object} ListenerNode
|
|
52332
|
-
* @property {Function} listener
|
|
52333
|
-
* @property {1|2|3} listenerType
|
|
52334
|
-
* @property {boolean} passive
|
|
52335
|
-
* @property {boolean} once
|
|
52336
|
-
* @property {ListenerNode|null} next
|
|
52337
|
-
* @private
|
|
52338
|
-
*/
|
|
52339
|
-
|
|
52340
|
-
/**
|
|
52341
|
-
* @type {WeakMap<object, Map<string, ListenerNode>>}
|
|
52342
|
-
* @private
|
|
52343
|
-
*/
|
|
52344
|
-
const listenersMap = new WeakMap();
|
|
52345
|
-
|
|
52346
|
-
// Listener types
|
|
52347
|
-
const CAPTURE = 1;
|
|
52348
|
-
const BUBBLE = 2;
|
|
52349
|
-
const ATTRIBUTE = 3;
|
|
52350
|
-
|
|
52351
|
-
/**
|
|
52352
|
-
* Check whether a given value is an object or not.
|
|
52353
|
-
* @param {any} x The value to check.
|
|
52354
|
-
* @returns {boolean} `true` if the value is an object.
|
|
52355
|
-
*/
|
|
52356
|
-
function isObject(x) {
|
|
52357
|
-
return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax
|
|
52358
|
-
}
|
|
52359
|
-
|
|
52360
|
-
/**
|
|
52361
|
-
* Get listeners.
|
|
52362
|
-
* @param {EventTarget} eventTarget The event target to get.
|
|
52363
|
-
* @returns {Map<string, ListenerNode>} The listeners.
|
|
52364
|
-
* @private
|
|
52365
|
-
*/
|
|
52366
|
-
function getListeners(eventTarget) {
|
|
52367
|
-
const listeners = listenersMap.get(eventTarget);
|
|
52368
|
-
if (listeners == null) {
|
|
52369
|
-
throw new TypeError("'this' is expected an EventTarget object, but got another value.")
|
|
52370
|
-
}
|
|
52371
|
-
return listeners
|
|
52372
|
-
}
|
|
52373
|
-
|
|
52374
|
-
/**
|
|
52375
|
-
* Get the property descriptor for the event attribute of a given event.
|
|
52376
|
-
* @param {string} eventName The event name to get property descriptor.
|
|
52377
|
-
* @returns {PropertyDescriptor} The property descriptor.
|
|
52378
|
-
* @private
|
|
52379
|
-
*/
|
|
52380
|
-
function defineEventAttributeDescriptor(eventName) {
|
|
52381
|
-
return {
|
|
52382
|
-
get() {
|
|
52383
|
-
const listeners = getListeners(this);
|
|
52384
|
-
let node = listeners.get(eventName);
|
|
52385
|
-
while (node != null) {
|
|
52386
|
-
if (node.listenerType === ATTRIBUTE) {
|
|
52387
|
-
return node.listener
|
|
52388
|
-
}
|
|
52389
|
-
node = node.next;
|
|
52390
|
-
}
|
|
52391
|
-
return null
|
|
52392
|
-
},
|
|
52393
|
-
|
|
52394
|
-
set(listener) {
|
|
52395
|
-
if (typeof listener !== "function" && !isObject(listener)) {
|
|
52396
|
-
listener = null; // eslint-disable-line no-param-reassign
|
|
52397
|
-
}
|
|
52398
|
-
const listeners = getListeners(this);
|
|
52399
|
-
|
|
52400
|
-
// Traverse to the tail while removing old value.
|
|
52401
|
-
let prev = null;
|
|
52402
|
-
let node = listeners.get(eventName);
|
|
52403
|
-
while (node != null) {
|
|
52404
|
-
if (node.listenerType === ATTRIBUTE) {
|
|
52405
|
-
// Remove old value.
|
|
52406
|
-
if (prev !== null) {
|
|
52407
|
-
prev.next = node.next;
|
|
52408
|
-
}
|
|
52409
|
-
else if (node.next !== null) {
|
|
52410
|
-
listeners.set(eventName, node.next);
|
|
52411
|
-
}
|
|
52412
|
-
else {
|
|
52413
|
-
listeners.delete(eventName);
|
|
52414
|
-
}
|
|
52415
|
-
}
|
|
52416
|
-
else {
|
|
52417
|
-
prev = node;
|
|
52418
|
-
}
|
|
52419
|
-
|
|
52420
|
-
node = node.next;
|
|
52421
|
-
}
|
|
52422
|
-
|
|
52423
|
-
// Add new value.
|
|
52424
|
-
if (listener !== null) {
|
|
52425
|
-
const newNode = {
|
|
52426
|
-
listener,
|
|
52427
|
-
listenerType: ATTRIBUTE,
|
|
52428
|
-
passive: false,
|
|
52429
|
-
once: false,
|
|
52430
|
-
next: null,
|
|
52431
|
-
};
|
|
52432
|
-
if (prev === null) {
|
|
52433
|
-
listeners.set(eventName, newNode);
|
|
52434
|
-
}
|
|
52435
|
-
else {
|
|
52436
|
-
prev.next = newNode;
|
|
52437
|
-
}
|
|
52438
|
-
}
|
|
52439
|
-
},
|
|
52440
|
-
configurable: true,
|
|
52441
|
-
enumerable: true,
|
|
52442
|
-
}
|
|
52443
|
-
}
|
|
52444
|
-
|
|
52445
|
-
/**
|
|
52446
|
-
* Define an event attribute (e.g. `eventTarget.onclick`).
|
|
52447
|
-
* @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.
|
|
52448
|
-
* @param {string} eventName The event name to define.
|
|
52449
|
-
* @returns {void}
|
|
52450
|
-
*/
|
|
52451
|
-
function defineEventAttribute(eventTargetPrototype, eventName) {
|
|
52452
|
-
Object.defineProperty(eventTargetPrototype, `on${eventName}`, defineEventAttributeDescriptor(eventName));
|
|
52453
|
-
}
|
|
52454
|
-
|
|
52455
|
-
/**
|
|
52456
|
-
* Define a custom EventTarget with event attributes.
|
|
52457
|
-
* @param {string[]} eventNames Event names for event attributes.
|
|
52458
|
-
* @returns {EventTarget} The custom EventTarget.
|
|
52459
|
-
* @private
|
|
52460
|
-
*/
|
|
52461
|
-
function defineCustomEventTarget(eventNames) {
|
|
52462
|
-
/** CustomEventTarget */
|
|
52463
|
-
function CustomEventTarget() {
|
|
52464
|
-
EventTarget.call(this);
|
|
52465
|
-
}
|
|
52466
|
-
|
|
52467
|
-
CustomEventTarget.prototype = Object.create(EventTarget.prototype, {
|
|
52468
|
-
constructor: { value: CustomEventTarget, configurable: true, writable: true },
|
|
52469
|
-
});
|
|
52470
|
-
|
|
52471
|
-
for (let i = 0; i < eventNames.length; ++i) {
|
|
52472
|
-
defineEventAttribute(CustomEventTarget.prototype, eventNames[i]);
|
|
52473
|
-
}
|
|
52474
|
-
|
|
52475
|
-
return CustomEventTarget
|
|
52476
|
-
}
|
|
52477
|
-
|
|
52478
|
-
/**
|
|
52479
|
-
* EventTarget.
|
|
52480
|
-
*
|
|
52481
|
-
* - This is constructor if no arguments.
|
|
52482
|
-
* - This is a function which returns a CustomEventTarget constructor if there are arguments.
|
|
52483
|
-
*
|
|
52484
|
-
* For example:
|
|
52485
|
-
*
|
|
52486
|
-
* class A extends EventTarget {}
|
|
52487
|
-
* class B extends EventTarget("message") {}
|
|
52488
|
-
* class C extends EventTarget("message", "error") {}
|
|
52489
|
-
* class D extends EventTarget(["message", "error"]) {}
|
|
52490
|
-
*/
|
|
52491
|
-
function EventTarget() {
|
|
52492
|
-
/*eslint-disable consistent-return */
|
|
52493
|
-
if (this instanceof EventTarget) {
|
|
52494
|
-
listenersMap.set(this, new Map());
|
|
52495
|
-
return
|
|
52496
|
-
}
|
|
52497
|
-
if (arguments.length === 1 && Array.isArray(arguments[0])) {
|
|
52498
|
-
return defineCustomEventTarget(arguments[0])
|
|
52499
|
-
}
|
|
52500
|
-
if (arguments.length > 0) {
|
|
52501
|
-
const types = new Array(arguments.length);
|
|
52502
|
-
for (let i = 0; i < arguments.length; ++i) {
|
|
52503
|
-
types[i] = arguments[i];
|
|
52504
|
-
}
|
|
52505
|
-
return defineCustomEventTarget(types)
|
|
52506
|
-
}
|
|
52507
|
-
throw new TypeError("Cannot call a class as a function")
|
|
52508
|
-
/*eslint-enable consistent-return */
|
|
52509
|
-
}
|
|
52510
|
-
|
|
52511
|
-
// Should be enumerable, but class methods are not enumerable.
|
|
52512
|
-
EventTarget.prototype = {
|
|
52513
|
-
/**
|
|
52514
|
-
* Add a given listener to this event target.
|
|
52515
|
-
* @param {string} eventName The event name to add.
|
|
52516
|
-
* @param {Function} listener The listener to add.
|
|
52517
|
-
* @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
|
|
52518
|
-
* @returns {boolean} `true` if the listener was added actually.
|
|
52519
|
-
*/
|
|
52520
|
-
addEventListener(eventName, listener, options) {
|
|
52521
|
-
if (listener == null) {
|
|
52522
|
-
return false
|
|
52523
|
-
}
|
|
52524
|
-
if (typeof listener !== "function" && !isObject(listener)) {
|
|
52525
|
-
throw new TypeError("'listener' should be a function or an object.")
|
|
52526
|
-
}
|
|
52527
|
-
|
|
52528
|
-
const listeners = getListeners(this);
|
|
52529
|
-
const optionsIsObj = isObject(options);
|
|
52530
|
-
const capture = optionsIsObj ? Boolean(options.capture) : Boolean(options);
|
|
52531
|
-
const listenerType = (capture ? CAPTURE : BUBBLE);
|
|
52532
|
-
const newNode = {
|
|
52533
|
-
listener,
|
|
52534
|
-
listenerType,
|
|
52535
|
-
passive: optionsIsObj && Boolean(options.passive),
|
|
52536
|
-
once: optionsIsObj && Boolean(options.once),
|
|
52537
|
-
next: null,
|
|
52538
|
-
};
|
|
52539
|
-
|
|
52540
|
-
// Set it as the first node if the first node is null.
|
|
52541
|
-
let node = listeners.get(eventName);
|
|
52542
|
-
if (node === undefined) {
|
|
52543
|
-
listeners.set(eventName, newNode);
|
|
52544
|
-
return true
|
|
52545
|
-
}
|
|
52546
|
-
|
|
52547
|
-
// Traverse to the tail while checking duplication..
|
|
52548
|
-
let prev = null;
|
|
52549
|
-
while (node != null) {
|
|
52550
|
-
if (node.listener === listener && node.listenerType === listenerType) {
|
|
52551
|
-
// Should ignore duplication.
|
|
52552
|
-
return false
|
|
52553
|
-
}
|
|
52554
|
-
prev = node;
|
|
52555
|
-
node = node.next;
|
|
52556
|
-
}
|
|
52557
|
-
|
|
52558
|
-
// Add it.
|
|
52559
|
-
prev.next = newNode;
|
|
52560
|
-
return true
|
|
52561
|
-
},
|
|
52562
|
-
|
|
52563
|
-
/**
|
|
52564
|
-
* Remove a given listener from this event target.
|
|
52565
|
-
* @param {string} eventName The event name to remove.
|
|
52566
|
-
* @param {Function} listener The listener to remove.
|
|
52567
|
-
* @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
|
|
52568
|
-
* @returns {boolean} `true` if the listener was removed actually.
|
|
52569
|
-
*/
|
|
52570
|
-
removeEventListener(eventName, listener, options) {
|
|
52571
|
-
if (listener == null) {
|
|
52572
|
-
return false
|
|
52573
|
-
}
|
|
52574
|
-
|
|
52575
|
-
const listeners = getListeners(this);
|
|
52576
|
-
const capture = isObject(options) ? Boolean(options.capture) : Boolean(options);
|
|
52577
|
-
const listenerType = (capture ? CAPTURE : BUBBLE);
|
|
52578
|
-
|
|
52579
|
-
let prev = null;
|
|
52580
|
-
let node = listeners.get(eventName);
|
|
52581
|
-
while (node != null) {
|
|
52582
|
-
if (node.listener === listener && node.listenerType === listenerType) {
|
|
52583
|
-
if (prev !== null) {
|
|
52584
|
-
prev.next = node.next;
|
|
52585
|
-
}
|
|
52586
|
-
else if (node.next !== null) {
|
|
52587
|
-
listeners.set(eventName, node.next);
|
|
52588
|
-
}
|
|
52589
|
-
else {
|
|
52590
|
-
listeners.delete(eventName);
|
|
52591
|
-
}
|
|
52592
|
-
return true
|
|
52593
|
-
}
|
|
52594
|
-
|
|
52595
|
-
prev = node;
|
|
52596
|
-
node = node.next;
|
|
52597
|
-
}
|
|
52598
|
-
|
|
52599
|
-
return false
|
|
52600
|
-
},
|
|
52601
|
-
|
|
52602
|
-
/**
|
|
52603
|
-
* Dispatch a given event.
|
|
52604
|
-
* @param {Event|{type:string}} event The event to dispatch.
|
|
52605
|
-
* @returns {boolean} `false` if canceled.
|
|
52606
|
-
*/
|
|
52607
|
-
dispatchEvent(event) { //eslint-disable-line complexity
|
|
52608
|
-
if (event == null || typeof event.type !== "string") {
|
|
52609
|
-
throw new TypeError("\"event.type\" should be a string.")
|
|
52610
|
-
}
|
|
52611
|
-
|
|
52612
|
-
// If listeners aren't registered, terminate.
|
|
52613
|
-
const listeners = getListeners(this);
|
|
52614
|
-
const eventName = event.type;
|
|
52615
|
-
let node = listeners.get(eventName);
|
|
52616
|
-
if (node == null) {
|
|
52617
|
-
return true
|
|
52618
|
-
}
|
|
52619
|
-
|
|
52620
|
-
// Since we cannot rewrite several properties, so wrap object.
|
|
52621
|
-
const wrappedEvent = wrapEvent(this, event);
|
|
52622
|
-
|
|
52623
|
-
// This doesn't process capturing phase and bubbling phase.
|
|
52624
|
-
// This isn't participating in a tree.
|
|
52625
|
-
let prev = null;
|
|
52626
|
-
while (node != null) {
|
|
52627
|
-
// Remove this listener if it's once
|
|
52628
|
-
if (node.once) {
|
|
52629
|
-
if (prev !== null) {
|
|
52630
|
-
prev.next = node.next;
|
|
52631
|
-
}
|
|
52632
|
-
else if (node.next !== null) {
|
|
52633
|
-
listeners.set(eventName, node.next);
|
|
52634
|
-
}
|
|
52635
|
-
else {
|
|
52636
|
-
listeners.delete(eventName);
|
|
52637
|
-
}
|
|
52638
|
-
}
|
|
52639
|
-
else {
|
|
52640
|
-
prev = node;
|
|
52641
|
-
}
|
|
52642
|
-
|
|
52643
|
-
// Call this listener
|
|
52644
|
-
setPassiveListener(wrappedEvent, (node.passive ? node.listener : null));
|
|
52645
|
-
if (typeof node.listener === "function") {
|
|
52646
|
-
try {
|
|
52647
|
-
node.listener.call(this, wrappedEvent);
|
|
52648
|
-
}
|
|
52649
|
-
catch (err) {
|
|
52650
|
-
/*eslint-disable no-console */
|
|
52651
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
52652
|
-
console.error(err);
|
|
52653
|
-
}
|
|
52654
|
-
/*eslint-enable no-console */
|
|
52655
|
-
}
|
|
52656
|
-
}
|
|
52657
|
-
else if (node.listenerType !== ATTRIBUTE && typeof node.listener.handleEvent === "function") {
|
|
52658
|
-
node.listener.handleEvent(wrappedEvent);
|
|
52659
|
-
}
|
|
52660
|
-
|
|
52661
|
-
// Break if `event.stopImmediatePropagation` was called.
|
|
52662
|
-
if (isStopped(wrappedEvent)) {
|
|
52663
|
-
break
|
|
52664
|
-
}
|
|
52665
|
-
|
|
52666
|
-
node = node.next;
|
|
52667
|
-
}
|
|
52668
|
-
setPassiveListener(wrappedEvent, null);
|
|
52669
|
-
setEventPhase(wrappedEvent, 0);
|
|
52670
|
-
setCurrentTarget(wrappedEvent, null);
|
|
52671
|
-
|
|
52672
|
-
return !wrappedEvent.defaultPrevented
|
|
52673
|
-
},
|
|
52674
|
-
};
|
|
52675
|
-
|
|
52676
|
-
// `constructor` is not enumerable.
|
|
52677
|
-
Object.defineProperty(EventTarget.prototype, "constructor", { value: EventTarget, configurable: true, writable: true });
|
|
52678
|
-
|
|
52679
|
-
// Ensure `eventTarget instanceof window.EventTarget` is `true`.
|
|
52680
|
-
if (typeof window !== "undefined" && typeof window.EventTarget !== "undefined") {
|
|
52681
|
-
Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype);
|
|
52682
|
-
}
|
|
52683
|
-
|
|
52684
|
-
exports.defineEventAttribute = defineEventAttribute;
|
|
52685
|
-
exports.EventTarget = EventTarget;
|
|
52686
|
-
exports["default"] = EventTarget;
|
|
52687
|
-
|
|
52688
|
-
module.exports = EventTarget
|
|
52689
|
-
module.exports.EventTarget = module.exports["default"] = EventTarget
|
|
52690
|
-
module.exports.defineEventAttribute = defineEventAttribute
|
|
52691
|
-
//# sourceMappingURL=event-target-shim.js.map
|
|
52692
|
-
|
|
52693
|
-
|
|
52694
|
-
/***/ }),
|
|
52695
|
-
/* 326 */
|
|
52696
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
52697
|
-
|
|
52698
|
-
"use strict";
|
|
52699
|
-
/* provided dependency */ var process = __webpack_require__(254);
|
|
52700
|
-
|
|
52701
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
52702
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
52703
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
52704
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
52705
|
-
r[k] = a[j];
|
|
52706
|
-
return r;
|
|
52707
|
-
};
|
|
52708
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
52709
|
-
var BrowserInfo = /** @class */ (function () {
|
|
52710
|
-
function BrowserInfo(name, version, os) {
|
|
52711
|
-
this.name = name;
|
|
52712
|
-
this.version = version;
|
|
52713
|
-
this.os = os;
|
|
52714
|
-
}
|
|
52715
|
-
return BrowserInfo;
|
|
52716
|
-
}());
|
|
52717
|
-
exports.BrowserInfo = BrowserInfo;
|
|
52718
|
-
var NodeInfo = /** @class */ (function () {
|
|
52719
|
-
function NodeInfo(version) {
|
|
52720
|
-
this.version = version;
|
|
52721
|
-
this.name = 'node';
|
|
52722
|
-
this.os = process.platform;
|
|
52723
|
-
}
|
|
52724
|
-
return NodeInfo;
|
|
52725
|
-
}());
|
|
52726
|
-
exports.NodeInfo = NodeInfo;
|
|
52727
|
-
var BotInfo = /** @class */ (function () {
|
|
52728
|
-
function BotInfo() {
|
|
52729
|
-
this.bot = true; // NOTE: deprecated test name instead
|
|
52730
|
-
this.name = 'bot';
|
|
52731
|
-
this.version = null;
|
|
52732
|
-
this.os = null;
|
|
52733
|
-
}
|
|
52734
|
-
return BotInfo;
|
|
52735
|
-
}());
|
|
52736
|
-
exports.BotInfo = BotInfo;
|
|
52737
|
-
// tslint:disable-next-line:max-line-length
|
|
52738
|
-
var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;
|
|
52739
|
-
var SEARCHBOT_OS_REGEX = /(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/;
|
|
52740
|
-
var REQUIRED_VERSION_PARTS = 3;
|
|
52741
|
-
var userAgentRules = [
|
|
52742
|
-
['aol', /AOLShield\/([0-9\._]+)/],
|
|
52743
|
-
['edge', /Edge\/([0-9\._]+)/],
|
|
52744
|
-
['edge-ios', /EdgiOS\/([0-9\._]+)/],
|
|
52745
|
-
['yandexbrowser', /YaBrowser\/([0-9\._]+)/],
|
|
52746
|
-
['vivaldi', /Vivaldi\/([0-9\.]+)/],
|
|
52747
|
-
['kakaotalk', /KAKAOTALK\s([0-9\.]+)/],
|
|
52748
|
-
['samsung', /SamsungBrowser\/([0-9\.]+)/],
|
|
52749
|
-
['silk', /\bSilk\/([0-9._-]+)\b/],
|
|
52750
|
-
['miui', /MiuiBrowser\/([0-9\.]+)$/],
|
|
52751
|
-
['beaker', /BeakerBrowser\/([0-9\.]+)/],
|
|
52752
|
-
['edge-chromium', /Edg\/([0-9\.]+)/],
|
|
52753
|
-
[
|
|
52754
|
-
'chromium-webview',
|
|
52755
|
-
/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/,
|
|
52756
|
-
],
|
|
52757
|
-
['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
|
|
52758
|
-
['phantomjs', /PhantomJS\/([0-9\.]+)(:?\s|$)/],
|
|
52759
|
-
['crios', /CriOS\/([0-9\.]+)(:?\s|$)/],
|
|
52760
|
-
['firefox', /Firefox\/([0-9\.]+)(?:\s|$)/],
|
|
52761
|
-
['fxios', /FxiOS\/([0-9\.]+)/],
|
|
52762
|
-
['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
|
|
52763
|
-
['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
|
|
52764
|
-
['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
|
|
52765
|
-
['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
|
|
52766
|
-
['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
|
|
52767
|
-
['ie', /MSIE\s(7\.0)/],
|
|
52768
|
-
['bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/],
|
|
52769
|
-
['android', /Android\s([0-9\.]+)/],
|
|
52770
|
-
['ios', /Version\/([0-9\._]+).*Mobile.*Safari.*/],
|
|
52771
|
-
['safari', /Version\/([0-9\._]+).*Safari/],
|
|
52772
|
-
['facebook', /FBAV\/([0-9\.]+)/],
|
|
52773
|
-
['instagram', /Instagram\s([0-9\.]+)/],
|
|
52774
|
-
['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/],
|
|
52775
|
-
['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
|
|
52776
|
-
['searchbot', SEARCHBOX_UA_REGEX],
|
|
52777
|
-
];
|
|
52778
|
-
var operatingSystemRules = [
|
|
52779
|
-
['iOS', /iP(hone|od|ad)/],
|
|
52780
|
-
['Android OS', /Android/],
|
|
52781
|
-
['BlackBerry OS', /BlackBerry|BB10/],
|
|
52782
|
-
['Windows Mobile', /IEMobile/],
|
|
52783
|
-
['Amazon OS', /Kindle/],
|
|
52784
|
-
['Windows 3.11', /Win16/],
|
|
52785
|
-
['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],
|
|
52786
|
-
['Windows 98', /(Windows 98)|(Win98)/],
|
|
52787
|
-
['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],
|
|
52788
|
-
['Windows XP', /(Windows NT 5.1)|(Windows XP)/],
|
|
52789
|
-
['Windows Server 2003', /(Windows NT 5.2)/],
|
|
52790
|
-
['Windows Vista', /(Windows NT 6.0)/],
|
|
52791
|
-
['Windows 7', /(Windows NT 6.1)/],
|
|
52792
|
-
['Windows 8', /(Windows NT 6.2)/],
|
|
52793
|
-
['Windows 8.1', /(Windows NT 6.3)/],
|
|
52794
|
-
['Windows 10', /(Windows NT 10.0)/],
|
|
52795
|
-
['Windows ME', /Windows ME/],
|
|
52796
|
-
['Open BSD', /OpenBSD/],
|
|
52797
|
-
['Sun OS', /SunOS/],
|
|
52798
|
-
['Chrome OS', /CrOS/],
|
|
52799
|
-
['Linux', /(Linux)|(X11)/],
|
|
52800
|
-
['Mac OS', /(Mac_PowerPC)|(Macintosh)/],
|
|
52801
|
-
['QNX', /QNX/],
|
|
52802
|
-
['BeOS', /BeOS/],
|
|
52803
|
-
['OS/2', /OS\/2/],
|
|
52804
|
-
['Search Bot', SEARCHBOT_OS_REGEX],
|
|
52805
|
-
];
|
|
52806
|
-
function detect(userAgent) {
|
|
52807
|
-
if (!!userAgent) {
|
|
52808
|
-
return parseUserAgent(userAgent);
|
|
52809
|
-
}
|
|
52810
|
-
if (typeof navigator !== 'undefined') {
|
|
52811
|
-
return parseUserAgent(navigator.userAgent);
|
|
52812
|
-
}
|
|
52813
|
-
return getNodeVersion();
|
|
52814
|
-
}
|
|
52815
|
-
exports.detect = detect;
|
|
52816
|
-
function parseUserAgent(ua) {
|
|
52817
|
-
// opted for using reduce here rather than Array#first with a regex.test call
|
|
52818
|
-
// this is primarily because using the reduce we only perform the regex
|
|
52819
|
-
// execution once rather than once for the test and for the exec again below
|
|
52820
|
-
// probably something that needs to be benchmarked though
|
|
52821
|
-
var matchedRule = ua !== '' &&
|
|
52822
|
-
userAgentRules.reduce(function (matched, _a) {
|
|
52823
|
-
var browser = _a[0], regex = _a[1];
|
|
52824
|
-
if (matched) {
|
|
52825
|
-
return matched;
|
|
52826
|
-
}
|
|
52827
|
-
var uaMatch = regex.exec(ua);
|
|
52828
|
-
return !!uaMatch && [browser, uaMatch];
|
|
52829
|
-
}, false);
|
|
52830
|
-
if (!matchedRule) {
|
|
52831
|
-
return null;
|
|
52832
|
-
}
|
|
52833
|
-
var name = matchedRule[0], match = matchedRule[1];
|
|
52834
|
-
if (name === 'searchbot') {
|
|
52835
|
-
return new BotInfo();
|
|
52836
|
-
}
|
|
52837
|
-
var versionParts = match[1] && match[1].split(/[._]/).slice(0, 3);
|
|
52838
|
-
if (versionParts) {
|
|
52839
|
-
if (versionParts.length < REQUIRED_VERSION_PARTS) {
|
|
52840
|
-
versionParts = __spreadArrays(versionParts, createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length));
|
|
52841
|
-
}
|
|
52842
|
-
}
|
|
52843
|
-
else {
|
|
52844
|
-
versionParts = [];
|
|
52845
|
-
}
|
|
52846
|
-
return new BrowserInfo(name, versionParts.join('.'), detectOS(ua));
|
|
52847
|
-
}
|
|
52848
|
-
exports.parseUserAgent = parseUserAgent;
|
|
52849
|
-
function detectOS(ua) {
|
|
52850
|
-
for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {
|
|
52851
|
-
var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];
|
|
52852
|
-
var match = regex.test(ua);
|
|
52853
|
-
if (match) {
|
|
52854
|
-
return os;
|
|
52855
|
-
}
|
|
52856
|
-
}
|
|
52857
|
-
return null;
|
|
52858
|
-
}
|
|
52859
|
-
exports.detectOS = detectOS;
|
|
52860
|
-
function getNodeVersion() {
|
|
52861
|
-
var isNode = typeof process !== 'undefined' && process.version;
|
|
52862
|
-
return isNode ? new NodeInfo(process.version.slice(1)) : null;
|
|
52863
|
-
}
|
|
52864
|
-
exports.getNodeVersion = getNodeVersion;
|
|
52865
|
-
function createVersionParts(count) {
|
|
52866
|
-
var output = [];
|
|
52867
|
-
for (var ii = 0; ii < count; ii++) {
|
|
52868
|
-
output.push('0');
|
|
52869
|
-
}
|
|
52870
|
-
return output;
|
|
52871
|
-
}
|
|
52872
|
-
|
|
52873
|
-
|
|
52874
|
-
/***/ }),
|
|
52875
|
-
/* 327 */
|
|
52876
51346
|
/***/ (function(module) {
|
|
52877
51347
|
|
|
52878
51348
|
!function(e,t){if(true)module.exports=t();else { var s, r; }}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{RingBuffer:()=>r});class r{static fromArray(e,t=0){const s=new r(t);return s.fromArray(e,0===t),s}constructor(e){if(this.buffer=[],this.pos=0,e<0)throw new RangeError("Invalid size.");this.size=e}getSize(){return this.size}getPos(){return this.pos}getBufferLength(){return this.buffer.length}add(...e){e.forEach((e=>{this.buffer[this.pos]=e,this.pos=(this.pos+1)%this.size}))}get(e){if(e<0&&(e+=this.buffer.length),!(e<0||e>this.buffer.length))return this.buffer.length<this.size?this.buffer[e]:this.buffer[(this.pos+e)%this.size]}getFirst(){return this.get(0)}getLast(){return this.get(-1)}getFirstN(e){return 0===e?[]:e<0?this.getLastN(-e):this.toArray().slice(0,e)}getLastN(e){return 0===e?[]:e<0?this.getFirstN(-e):this.toArray().slice(-e)}remove(e,t=1){if(e<0&&(e+=this.buffer.length),e<0||e>this.buffer.length)return[];const r=this.toArray(),s=r.splice(e,t);return this.fromArray(r),s}removeFirst(){return this.remove(0)[0]}removeLast(){return this.remove(-1)[0]}toArray(){return this.buffer.slice(this.pos).concat(this.buffer.slice(0,this.pos))}fromArray(e,t=!1){if(!Array.isArray(e))throw new TypeError("Input value is not an array.");t&&this.resize(e.length),0!==this.size&&(this.buffer=e.slice(-this.size),this.pos=this.buffer.length%this.size)}clear(){this.buffer=[],this.pos=0}resize(e){if(e<0)throw new RangeError("The size does not allow negative values.");if(0===e)this.clear();else if(e!==this.size){const t=this.toArray();this.fromArray(t.slice(-e)),this.pos=this.buffer.length%e}this.size=e}isFull(){return this.buffer.length===this.size}isEmpty(){return 0===this.buffer.length}}return t})()));
|
|
52879
51349
|
|
|
52880
51350
|
/***/ }),
|
|
52881
|
-
/*
|
|
51351
|
+
/* 325 */
|
|
52882
51352
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
52883
51353
|
|
|
52884
51354
|
"use strict";
|
|
@@ -52927,11 +51397,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
52927
51397
|
};
|
|
52928
51398
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
52929
51399
|
exports.AudioNodeVAD = exports.MicVAD = exports.defaultRealTimeVADOptions = void 0;
|
|
52930
|
-
const ort = __importStar(__webpack_require__(
|
|
51400
|
+
const ort = __importStar(__webpack_require__(326));
|
|
52931
51401
|
const logger_1 = __webpack_require__(250);
|
|
52932
|
-
const frame_processor_1 = __webpack_require__(
|
|
52933
|
-
const messages_1 = __webpack_require__(
|
|
52934
|
-
const models_1 = __webpack_require__(
|
|
51402
|
+
const frame_processor_1 = __webpack_require__(327);
|
|
51403
|
+
const messages_1 = __webpack_require__(328);
|
|
51404
|
+
const models_1 = __webpack_require__(329);
|
|
52935
51405
|
exports.defaultRealTimeVADOptions = Object.assign(Object.assign({}, frame_processor_1.defaultFrameProcessorOptions), { onFrameProcessed: (probabilities) => { }, onVADMisfire: () => {
|
|
52936
51406
|
logger_1.logger.debug('VAD misfire');
|
|
52937
51407
|
}, onSpeechStart: () => {
|
|
@@ -53067,7 +51537,7 @@ exports.AudioNodeVAD = AudioNodeVAD;
|
|
|
53067
51537
|
|
|
53068
51538
|
|
|
53069
51539
|
/***/ }),
|
|
53070
|
-
/*
|
|
51540
|
+
/* 326 */
|
|
53071
51541
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
53072
51542
|
|
|
53073
51543
|
/* provided dependency */ var process = __webpack_require__(254);
|
|
@@ -53080,7 +51550,7 @@ exports.AudioNodeVAD = AudioNodeVAD;
|
|
|
53080
51550
|
//# sourceMappingURL=ort.min.js.map
|
|
53081
51551
|
|
|
53082
51552
|
/***/ }),
|
|
53083
|
-
/*
|
|
51553
|
+
/* 327 */
|
|
53084
51554
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
53085
51555
|
|
|
53086
51556
|
"use strict";
|
|
@@ -53101,7 +51571,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
53101
51571
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
53102
51572
|
exports.FrameProcessor = exports.validateOptions = exports.defaultFrameProcessorOptions = void 0;
|
|
53103
51573
|
const logger_1 = __webpack_require__(250);
|
|
53104
|
-
const messages_1 = __webpack_require__(
|
|
51574
|
+
const messages_1 = __webpack_require__(328);
|
|
53105
51575
|
const RECOMMENDED_FRAME_SAMPLES = [512, 1024, 1536];
|
|
53106
51576
|
exports.defaultFrameProcessorOptions = {
|
|
53107
51577
|
positiveSpeechThreshold: 0.5,
|
|
@@ -53234,7 +51704,7 @@ exports.FrameProcessor = FrameProcessor;
|
|
|
53234
51704
|
|
|
53235
51705
|
|
|
53236
51706
|
/***/ }),
|
|
53237
|
-
/*
|
|
51707
|
+
/* 328 */
|
|
53238
51708
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53239
51709
|
|
|
53240
51710
|
"use strict";
|
|
@@ -53251,7 +51721,7 @@ var Message;
|
|
|
53251
51721
|
|
|
53252
51722
|
|
|
53253
51723
|
/***/ }),
|
|
53254
|
-
/*
|
|
51724
|
+
/* 329 */
|
|
53255
51725
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
53256
51726
|
|
|
53257
51727
|
"use strict";
|
|
@@ -53313,7 +51783,7 @@ Silero.new = (ort, modelFetcher) => __awaiter(void 0, void 0, void 0, function*
|
|
|
53313
51783
|
|
|
53314
51784
|
|
|
53315
51785
|
/***/ }),
|
|
53316
|
-
/*
|
|
51786
|
+
/* 330 */
|
|
53317
51787
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53318
51788
|
|
|
53319
51789
|
"use strict";
|
|
@@ -53328,7 +51798,7 @@ var SpeechRecognitionMessageAction;
|
|
|
53328
51798
|
|
|
53329
51799
|
|
|
53330
51800
|
/***/ }),
|
|
53331
|
-
/*
|
|
51801
|
+
/* 331 */
|
|
53332
51802
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53333
51803
|
|
|
53334
51804
|
"use strict";
|
|
@@ -53393,7 +51863,7 @@ exports.StreamManager = StreamManager;
|
|
|
53393
51863
|
|
|
53394
51864
|
|
|
53395
51865
|
/***/ }),
|
|
53396
|
-
/*
|
|
51866
|
+
/* 332 */
|
|
53397
51867
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
53398
51868
|
|
|
53399
51869
|
"use strict";
|
|
@@ -53401,9 +51871,9 @@ exports.StreamManager = StreamManager;
|
|
|
53401
51871
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
53402
51872
|
exports.VoiceInputManager = void 0;
|
|
53403
51873
|
const operators_1 = __webpack_require__(238);
|
|
53404
|
-
const soundmeter_1 = __webpack_require__(
|
|
51874
|
+
const soundmeter_1 = __webpack_require__(333);
|
|
53405
51875
|
const MessageTypes_1 = __webpack_require__(287);
|
|
53406
|
-
const VoiceInputMode_1 = __webpack_require__(
|
|
51876
|
+
const VoiceInputMode_1 = __webpack_require__(334);
|
|
53407
51877
|
const logger_1 = __webpack_require__(250);
|
|
53408
51878
|
class VoiceInputManager {
|
|
53409
51879
|
constructor(options, api, messages, enableMicrophone) {
|
|
@@ -53571,7 +52041,7 @@ exports.VoiceInputManager = VoiceInputManager;
|
|
|
53571
52041
|
|
|
53572
52042
|
|
|
53573
52043
|
/***/ }),
|
|
53574
|
-
/*
|
|
52044
|
+
/* 333 */
|
|
53575
52045
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
53576
52046
|
|
|
53577
52047
|
"use strict";
|
|
@@ -53650,7 +52120,7 @@ exports.SoundMeter = SoundMeter;
|
|
|
53650
52120
|
|
|
53651
52121
|
|
|
53652
52122
|
/***/ }),
|
|
53653
|
-
/*
|
|
52123
|
+
/* 334 */
|
|
53654
52124
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53655
52125
|
|
|
53656
52126
|
"use strict";
|
|
@@ -53666,7 +52136,7 @@ var VoiceInputMode;
|
|
|
53666
52136
|
|
|
53667
52137
|
|
|
53668
52138
|
/***/ }),
|
|
53669
|
-
/*
|
|
52139
|
+
/* 335 */
|
|
53670
52140
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53671
52141
|
|
|
53672
52142
|
"use strict";
|
|
@@ -53680,7 +52150,7 @@ var SessionType;
|
|
|
53680
52150
|
|
|
53681
52151
|
|
|
53682
52152
|
/***/ }),
|
|
53683
|
-
/*
|
|
52153
|
+
/* 336 */
|
|
53684
52154
|
/***/ ((__unused_webpack_module, exports) => {
|
|
53685
52155
|
|
|
53686
52156
|
"use strict";
|