uneeq-js 2.47.0 → 2.47.2
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 +1 -0
- package/dist/umd/index.js +1594 -41
- package/package.json +64 -62
- package/readme.md +58 -204
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__(334);
|
|
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__(335);
|
|
3678
3678
|
const MessageTypes_1 = __webpack_require__(287);
|
|
3679
|
-
const NewSessionRequest_1 = __webpack_require__(
|
|
3679
|
+
const NewSessionRequest_1 = __webpack_require__(338);
|
|
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__(339);
|
|
3682
|
+
const VoiceInputMode_1 = __webpack_require__(337);
|
|
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
|
|
@@ -4018,8 +4018,8 @@ class Uneeq {
|
|
|
4018
4018
|
sessionId: this.session.id,
|
|
4019
4019
|
messages: this.messages,
|
|
4020
4020
|
assetBasePath: this.options.assetBasePath,
|
|
4021
|
-
locales: this.options.speechToTextLocales ||
|
|
4022
|
-
hintPhrases: this.options.speechRecognitionHintPhrases ||
|
|
4021
|
+
locales: this.options.speechToTextLocales || '',
|
|
4022
|
+
hintPhrases: this.options.speechRecognitionHintPhrases || ''
|
|
4023
4023
|
});
|
|
4024
4024
|
}
|
|
4025
4025
|
else {
|
|
@@ -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.1","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","crossoriginworker":"^1.1.0","fast-text-encoding":"^1.0.0","intrinsic-scale":"^3.0.4","onnxruntime-web":"^1.15.1","opus-media-recorder":"^0.8.0","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,25 +51156,30 @@ 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
|
+
};
|
|
51159
51162
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51160
51163
|
exports.SpeechHandler = void 0;
|
|
51161
|
-
const
|
|
51162
|
-
const
|
|
51164
|
+
const opus_media_recorder_1 = __importDefault(__webpack_require__(324));
|
|
51165
|
+
const ring_buffer_ts_1 = __webpack_require__(327);
|
|
51166
|
+
const real_time_vad_1 = __webpack_require__(328);
|
|
51163
51167
|
const MessageTypes_1 = __webpack_require__(287);
|
|
51164
|
-
const SpeechRecognitionMessageAction_1 = __webpack_require__(
|
|
51168
|
+
const SpeechRecognitionMessageAction_1 = __webpack_require__(333);
|
|
51165
51169
|
const logger_1 = __webpack_require__(250);
|
|
51166
51170
|
const speechBufferLength = 5;
|
|
51167
51171
|
const audioChunkSizeMs = 100;
|
|
51168
51172
|
const audioSampleRate = 48000;
|
|
51169
51173
|
const audioChannelCount = 1;
|
|
51170
|
-
const defaultAssetPath = 'https://
|
|
51174
|
+
const defaultAssetPath = 'https://cdn.uneeq.io/assets/platform/speech-recognition/';
|
|
51171
51175
|
class SpeechHandler {
|
|
51172
51176
|
constructor(options) {
|
|
51173
51177
|
this.options = options;
|
|
51174
51178
|
this.logPrefix = 'UneeQ: Speech Recognition: ';
|
|
51175
51179
|
this.speechBuffer = new ring_buffer_ts_1.RingBuffer(speechBufferLength);
|
|
51176
51180
|
this.recordingLive = false;
|
|
51177
|
-
|
|
51181
|
+
this.OpusMediaRecorder = opus_media_recorder_1.default;
|
|
51182
|
+
console.warn('UneeQ: SPEECH_RECOGNITION input mode is in development, you may experience issues.');
|
|
51178
51183
|
this.options.assetBasePath = this.options.assetBasePath || defaultAssetPath;
|
|
51179
51184
|
this.loadSavedAudioHeaders();
|
|
51180
51185
|
this.initWebsocket(options);
|
|
@@ -51197,7 +51202,7 @@ class SpeechHandler {
|
|
|
51197
51202
|
loadSavedAudioHeaders() {
|
|
51198
51203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51199
51204
|
// this will be replaced with opus media recorder lib that will give us the first packets with header
|
|
51200
|
-
const fileName = this.options.assetBasePath + '
|
|
51205
|
+
const fileName = this.options.assetBasePath + 'opus-media-recorder-header.webm';
|
|
51201
51206
|
// load the saved header and send that:
|
|
51202
51207
|
const response = yield fetch(fileName);
|
|
51203
51208
|
const arrayBuffer = yield response.arrayBuffer();
|
|
@@ -51288,14 +51293,37 @@ class SpeechHandler {
|
|
|
51288
51293
|
.catch((error) => console.error('Error starting recording', error));
|
|
51289
51294
|
}
|
|
51290
51295
|
initMediaRecorder(stream) {
|
|
51291
|
-
|
|
51292
|
-
|
|
51293
|
-
|
|
51294
|
-
|
|
51295
|
-
|
|
51296
|
-
|
|
51297
|
-
|
|
51298
|
-
|
|
51296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51297
|
+
// The script there simply posts back an "Hello" message
|
|
51298
|
+
// Obviously cross-origin here
|
|
51299
|
+
const cross_origin_script_url = this.options.assetBasePath + 'encoderWorker.umd.js';
|
|
51300
|
+
const worker_url = getWorkerURL(cross_origin_script_url);
|
|
51301
|
+
const worker = new Worker(worker_url);
|
|
51302
|
+
// worker.onmessage = (evt) => console.log( evt.data );
|
|
51303
|
+
// URL.revokeObjectURL( worker_url );
|
|
51304
|
+
// Returns a blob:// URL which points
|
|
51305
|
+
// to a javascript file which will call
|
|
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);
|
|
51323
|
+
this.mediaRecorder.ondataavailable = (e) => this.mediaRecorderOnData(e);
|
|
51324
|
+
this.mediaRecorder.onstop = () => this.sendStopMessage();
|
|
51325
|
+
this.mediaRecorder.start(audioChunkSizeMs);
|
|
51326
|
+
});
|
|
51299
51327
|
}
|
|
51300
51328
|
mediaRecorderOnData(event) {
|
|
51301
51329
|
if (event.data && event.data.size > 0) {
|
|
@@ -51320,12 +51348,1537 @@ exports.SpeechHandler = SpeechHandler;
|
|
|
51320
51348
|
|
|
51321
51349
|
/***/ }),
|
|
51322
51350
|
/* 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 */
|
|
51323
52876
|
/***/ (function(module) {
|
|
51324
52877
|
|
|
51325
52878
|
!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})()));
|
|
51326
52879
|
|
|
51327
52880
|
/***/ }),
|
|
51328
|
-
/*
|
|
52881
|
+
/* 328 */
|
|
51329
52882
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51330
52883
|
|
|
51331
52884
|
"use strict";
|
|
@@ -51374,11 +52927,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
51374
52927
|
};
|
|
51375
52928
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51376
52929
|
exports.AudioNodeVAD = exports.MicVAD = exports.defaultRealTimeVADOptions = void 0;
|
|
51377
|
-
const ort = __importStar(__webpack_require__(
|
|
52930
|
+
const ort = __importStar(__webpack_require__(329));
|
|
51378
52931
|
const logger_1 = __webpack_require__(250);
|
|
51379
|
-
const frame_processor_1 = __webpack_require__(
|
|
51380
|
-
const messages_1 = __webpack_require__(
|
|
51381
|
-
const models_1 = __webpack_require__(
|
|
52932
|
+
const frame_processor_1 = __webpack_require__(330);
|
|
52933
|
+
const messages_1 = __webpack_require__(331);
|
|
52934
|
+
const models_1 = __webpack_require__(332);
|
|
51382
52935
|
exports.defaultRealTimeVADOptions = Object.assign(Object.assign({}, frame_processor_1.defaultFrameProcessorOptions), { onFrameProcessed: (probabilities) => { }, onVADMisfire: () => {
|
|
51383
52936
|
logger_1.logger.debug('VAD misfire');
|
|
51384
52937
|
}, onSpeechStart: () => {
|
|
@@ -51514,7 +53067,7 @@ exports.AudioNodeVAD = AudioNodeVAD;
|
|
|
51514
53067
|
|
|
51515
53068
|
|
|
51516
53069
|
/***/ }),
|
|
51517
|
-
/*
|
|
53070
|
+
/* 329 */
|
|
51518
53071
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
51519
53072
|
|
|
51520
53073
|
/* provided dependency */ var process = __webpack_require__(254);
|
|
@@ -51527,7 +53080,7 @@ exports.AudioNodeVAD = AudioNodeVAD;
|
|
|
51527
53080
|
//# sourceMappingURL=ort.min.js.map
|
|
51528
53081
|
|
|
51529
53082
|
/***/ }),
|
|
51530
|
-
/*
|
|
53083
|
+
/* 330 */
|
|
51531
53084
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51532
53085
|
|
|
51533
53086
|
"use strict";
|
|
@@ -51548,7 +53101,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
51548
53101
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51549
53102
|
exports.FrameProcessor = exports.validateOptions = exports.defaultFrameProcessorOptions = void 0;
|
|
51550
53103
|
const logger_1 = __webpack_require__(250);
|
|
51551
|
-
const messages_1 = __webpack_require__(
|
|
53104
|
+
const messages_1 = __webpack_require__(331);
|
|
51552
53105
|
const RECOMMENDED_FRAME_SAMPLES = [512, 1024, 1536];
|
|
51553
53106
|
exports.defaultFrameProcessorOptions = {
|
|
51554
53107
|
positiveSpeechThreshold: 0.5,
|
|
@@ -51681,7 +53234,7 @@ exports.FrameProcessor = FrameProcessor;
|
|
|
51681
53234
|
|
|
51682
53235
|
|
|
51683
53236
|
/***/ }),
|
|
51684
|
-
/*
|
|
53237
|
+
/* 331 */
|
|
51685
53238
|
/***/ ((__unused_webpack_module, exports) => {
|
|
51686
53239
|
|
|
51687
53240
|
"use strict";
|
|
@@ -51698,7 +53251,7 @@ var Message;
|
|
|
51698
53251
|
|
|
51699
53252
|
|
|
51700
53253
|
/***/ }),
|
|
51701
|
-
/*
|
|
53254
|
+
/* 332 */
|
|
51702
53255
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
51703
53256
|
|
|
51704
53257
|
"use strict";
|
|
@@ -51760,7 +53313,7 @@ Silero.new = (ort, modelFetcher) => __awaiter(void 0, void 0, void 0, function*
|
|
|
51760
53313
|
|
|
51761
53314
|
|
|
51762
53315
|
/***/ }),
|
|
51763
|
-
/*
|
|
53316
|
+
/* 333 */
|
|
51764
53317
|
/***/ ((__unused_webpack_module, exports) => {
|
|
51765
53318
|
|
|
51766
53319
|
"use strict";
|
|
@@ -51775,7 +53328,7 @@ var SpeechRecognitionMessageAction;
|
|
|
51775
53328
|
|
|
51776
53329
|
|
|
51777
53330
|
/***/ }),
|
|
51778
|
-
/*
|
|
53331
|
+
/* 334 */
|
|
51779
53332
|
/***/ ((__unused_webpack_module, exports) => {
|
|
51780
53333
|
|
|
51781
53334
|
"use strict";
|
|
@@ -51840,7 +53393,7 @@ exports.StreamManager = StreamManager;
|
|
|
51840
53393
|
|
|
51841
53394
|
|
|
51842
53395
|
/***/ }),
|
|
51843
|
-
/*
|
|
53396
|
+
/* 335 */
|
|
51844
53397
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
51845
53398
|
|
|
51846
53399
|
"use strict";
|
|
@@ -51848,9 +53401,9 @@ exports.StreamManager = StreamManager;
|
|
|
51848
53401
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
51849
53402
|
exports.VoiceInputManager = void 0;
|
|
51850
53403
|
const operators_1 = __webpack_require__(238);
|
|
51851
|
-
const soundmeter_1 = __webpack_require__(
|
|
53404
|
+
const soundmeter_1 = __webpack_require__(336);
|
|
51852
53405
|
const MessageTypes_1 = __webpack_require__(287);
|
|
51853
|
-
const VoiceInputMode_1 = __webpack_require__(
|
|
53406
|
+
const VoiceInputMode_1 = __webpack_require__(337);
|
|
51854
53407
|
const logger_1 = __webpack_require__(250);
|
|
51855
53408
|
class VoiceInputManager {
|
|
51856
53409
|
constructor(options, api, messages, enableMicrophone) {
|
|
@@ -52018,7 +53571,7 @@ exports.VoiceInputManager = VoiceInputManager;
|
|
|
52018
53571
|
|
|
52019
53572
|
|
|
52020
53573
|
/***/ }),
|
|
52021
|
-
/*
|
|
53574
|
+
/* 336 */
|
|
52022
53575
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
52023
53576
|
|
|
52024
53577
|
"use strict";
|
|
@@ -52097,7 +53650,7 @@ exports.SoundMeter = SoundMeter;
|
|
|
52097
53650
|
|
|
52098
53651
|
|
|
52099
53652
|
/***/ }),
|
|
52100
|
-
/*
|
|
53653
|
+
/* 337 */
|
|
52101
53654
|
/***/ ((__unused_webpack_module, exports) => {
|
|
52102
53655
|
|
|
52103
53656
|
"use strict";
|
|
@@ -52113,7 +53666,7 @@ var VoiceInputMode;
|
|
|
52113
53666
|
|
|
52114
53667
|
|
|
52115
53668
|
/***/ }),
|
|
52116
|
-
/*
|
|
53669
|
+
/* 338 */
|
|
52117
53670
|
/***/ ((__unused_webpack_module, exports) => {
|
|
52118
53671
|
|
|
52119
53672
|
"use strict";
|
|
@@ -52127,7 +53680,7 @@ var SessionType;
|
|
|
52127
53680
|
|
|
52128
53681
|
|
|
52129
53682
|
/***/ }),
|
|
52130
|
-
/*
|
|
53683
|
+
/* 339 */
|
|
52131
53684
|
/***/ ((__unused_webpack_module, exports) => {
|
|
52132
53685
|
|
|
52133
53686
|
"use strict";
|