web-speech-cognitive-services 8.0.0-main.aa5b13b → 8.0.0-main.d9ef940
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/web-speech-cognitive-services.d.mts +189 -58
- package/dist/web-speech-cognitive-services.d.ts +189 -58
- package/dist/web-speech-cognitive-services.development.js +1457 -1382
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +453 -316
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +452 -315
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +12 -12
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -792,7 +792,7 @@
|
|
|
792
792
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
793
793
|
exports.AudioStreamNodeErrorEvent = exports.AudioStreamNodeDetachedEvent = exports.AudioStreamNodeAttachedEvent = exports.AudioStreamNodeAttachingEvent = exports.AudioStreamNodeEvent = exports.AudioSourceErrorEvent = exports.AudioSourceOffEvent = exports.AudioSourceReadyEvent = exports.AudioSourceInitializingEvent = exports.AudioSourceEvent = void 0;
|
|
794
794
|
var PlatformEvent_js_1 = require_PlatformEvent();
|
|
795
|
-
var
|
|
795
|
+
var AudioSourceEvent2 = class extends PlatformEvent_js_1.PlatformEvent {
|
|
796
796
|
constructor(eventName, audioSourceId, eventType = PlatformEvent_js_1.EventType.Info) {
|
|
797
797
|
super(eventName, eventType);
|
|
798
798
|
this.privAudioSourceId = audioSourceId;
|
|
@@ -801,26 +801,26 @@
|
|
|
801
801
|
return this.privAudioSourceId;
|
|
802
802
|
}
|
|
803
803
|
};
|
|
804
|
-
exports.AudioSourceEvent =
|
|
805
|
-
var AudioSourceInitializingEvent = class extends
|
|
804
|
+
exports.AudioSourceEvent = AudioSourceEvent2;
|
|
805
|
+
var AudioSourceInitializingEvent = class extends AudioSourceEvent2 {
|
|
806
806
|
constructor(audioSourceId) {
|
|
807
807
|
super("AudioSourceInitializingEvent", audioSourceId);
|
|
808
808
|
}
|
|
809
809
|
};
|
|
810
810
|
exports.AudioSourceInitializingEvent = AudioSourceInitializingEvent;
|
|
811
|
-
var AudioSourceReadyEvent = class extends
|
|
811
|
+
var AudioSourceReadyEvent = class extends AudioSourceEvent2 {
|
|
812
812
|
constructor(audioSourceId) {
|
|
813
813
|
super("AudioSourceReadyEvent", audioSourceId);
|
|
814
814
|
}
|
|
815
815
|
};
|
|
816
816
|
exports.AudioSourceReadyEvent = AudioSourceReadyEvent;
|
|
817
|
-
var AudioSourceOffEvent = class extends
|
|
817
|
+
var AudioSourceOffEvent = class extends AudioSourceEvent2 {
|
|
818
818
|
constructor(audioSourceId) {
|
|
819
819
|
super("AudioSourceOffEvent", audioSourceId);
|
|
820
820
|
}
|
|
821
821
|
};
|
|
822
822
|
exports.AudioSourceOffEvent = AudioSourceOffEvent;
|
|
823
|
-
var AudioSourceErrorEvent = class extends
|
|
823
|
+
var AudioSourceErrorEvent = class extends AudioSourceEvent2 {
|
|
824
824
|
constructor(audioSourceId, error) {
|
|
825
825
|
super("AudioSourceErrorEvent", audioSourceId, PlatformEvent_js_1.EventType.Error);
|
|
826
826
|
this.privError = error;
|
|
@@ -830,7 +830,7 @@
|
|
|
830
830
|
}
|
|
831
831
|
};
|
|
832
832
|
exports.AudioSourceErrorEvent = AudioSourceErrorEvent;
|
|
833
|
-
var AudioStreamNodeEvent = class extends
|
|
833
|
+
var AudioStreamNodeEvent = class extends AudioSourceEvent2 {
|
|
834
834
|
constructor(eventName, audioSourceId, audioNodeId) {
|
|
835
835
|
super(eventName, audioSourceId);
|
|
836
836
|
this.privAudioNodeId = audioNodeId;
|
|
@@ -5519,7 +5519,7 @@
|
|
|
5519
5519
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5520
5520
|
exports.SpeechRecognitionResult = void 0;
|
|
5521
5521
|
var Exports_js_1 = require_Exports3();
|
|
5522
|
-
var
|
|
5522
|
+
var SpeechRecognitionResult2 = class extends Exports_js_1.RecognitionResult {
|
|
5523
5523
|
/**
|
|
5524
5524
|
* Creates and initializes an instance of this class.
|
|
5525
5525
|
* @constructor
|
|
@@ -5551,7 +5551,7 @@
|
|
|
5551
5551
|
return this.privSpeakerId;
|
|
5552
5552
|
}
|
|
5553
5553
|
};
|
|
5554
|
-
exports.SpeechRecognitionResult =
|
|
5554
|
+
exports.SpeechRecognitionResult = SpeechRecognitionResult2;
|
|
5555
5555
|
}
|
|
5556
5556
|
});
|
|
5557
5557
|
|
|
@@ -6920,7 +6920,7 @@
|
|
|
6920
6920
|
var Exports_js_2 = require_Exports();
|
|
6921
6921
|
var Contracts_js_1 = require_Contracts();
|
|
6922
6922
|
var Exports_js_3 = require_Exports3();
|
|
6923
|
-
var
|
|
6923
|
+
var SpeechRecognizer4 = class _SpeechRecognizer extends Exports_js_3.Recognizer {
|
|
6924
6924
|
/**
|
|
6925
6925
|
* SpeechRecognizer constructor.
|
|
6926
6926
|
* @constructor
|
|
@@ -7123,7 +7123,7 @@
|
|
|
7123
7123
|
return new Exports_js_1.SpeechServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this);
|
|
7124
7124
|
}
|
|
7125
7125
|
};
|
|
7126
|
-
exports.SpeechRecognizer =
|
|
7126
|
+
exports.SpeechRecognizer = SpeechRecognizer4;
|
|
7127
7127
|
}
|
|
7128
7128
|
});
|
|
7129
7129
|
|
|
@@ -23432,1352 +23432,564 @@
|
|
|
23432
23432
|
}
|
|
23433
23433
|
});
|
|
23434
23434
|
|
|
23435
|
-
//
|
|
23436
|
-
|
|
23437
|
-
"
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
ret.resolve = resolve;
|
|
23443
|
-
ret.reject = reject;
|
|
23444
|
-
});
|
|
23445
|
-
return ret;
|
|
23446
|
-
};
|
|
23447
|
-
}
|
|
23448
|
-
});
|
|
23435
|
+
// src/SpeechServices/resolveFunctionOrReturnValue.ts
|
|
23436
|
+
function isFunction(value) {
|
|
23437
|
+
return typeof value === "function";
|
|
23438
|
+
}
|
|
23439
|
+
function resolveFunctionOrReturnValue(fnOrValue) {
|
|
23440
|
+
return isFunction(fnOrValue) ? fnOrValue() : fnOrValue;
|
|
23441
|
+
}
|
|
23449
23442
|
|
|
23450
|
-
//
|
|
23451
|
-
var
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
23455
|
-
|
|
23456
|
-
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23464
|
-
|
|
23465
|
-
|
|
23443
|
+
// src/SpeechServices/patchOptions.ts
|
|
23444
|
+
var shouldWarnOnSubscriptionKey = true;
|
|
23445
|
+
function patchOptions(init) {
|
|
23446
|
+
const {
|
|
23447
|
+
audioConfig,
|
|
23448
|
+
authorizationToken,
|
|
23449
|
+
enableTelemetry,
|
|
23450
|
+
looseEvent,
|
|
23451
|
+
referenceGrammars,
|
|
23452
|
+
region = "westus",
|
|
23453
|
+
speechRecognitionEndpointId,
|
|
23454
|
+
subscriptionKey,
|
|
23455
|
+
textNormalization
|
|
23456
|
+
} = init;
|
|
23457
|
+
let { credentials, looseEvents } = init;
|
|
23458
|
+
if (typeof looseEvent !== "undefined") {
|
|
23459
|
+
console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".');
|
|
23460
|
+
looseEvents = looseEvent;
|
|
23461
|
+
}
|
|
23462
|
+
if (!credentials) {
|
|
23463
|
+
if (!authorizationToken && !subscriptionKey) {
|
|
23464
|
+
throw new Error("web-speech-cognitive-services: Credentials must be specified.");
|
|
23465
|
+
} else {
|
|
23466
|
+
console.warn(
|
|
23467
|
+
"web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."
|
|
23468
|
+
);
|
|
23469
|
+
credentials = async () => typeof init.authorizationToken !== "undefined" ? { authorizationToken: await resolveFunctionOrReturnValue(init.authorizationToken), region } : { region, subscriptionKey: await resolveFunctionOrReturnValue(init.subscriptionKey) };
|
|
23466
23470
|
}
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23471
|
+
}
|
|
23472
|
+
return Object.freeze({
|
|
23473
|
+
audioConfig,
|
|
23474
|
+
enableTelemetry,
|
|
23475
|
+
fetchCredentials: async () => {
|
|
23476
|
+
const {
|
|
23477
|
+
authorizationToken: authorizationToken2,
|
|
23478
|
+
customVoiceHostname,
|
|
23479
|
+
region: region2,
|
|
23480
|
+
speechRecognitionHostname,
|
|
23481
|
+
speechSynthesisHostname,
|
|
23482
|
+
subscriptionKey: subscriptionKey2
|
|
23483
|
+
} = await resolveFunctionOrReturnValue(credentials);
|
|
23484
|
+
if (!authorizationToken2 && !subscriptionKey2 || authorizationToken2 && subscriptionKey2) {
|
|
23485
|
+
throw new Error(
|
|
23486
|
+
'web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.'
|
|
23487
|
+
);
|
|
23488
|
+
} else if (!region2 && !(speechRecognitionHostname && speechSynthesisHostname)) {
|
|
23489
|
+
throw new Error(
|
|
23490
|
+
'web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.'
|
|
23491
|
+
);
|
|
23492
|
+
} else if (region2 && (customVoiceHostname || speechRecognitionHostname || speechSynthesisHostname)) {
|
|
23493
|
+
throw new Error(
|
|
23494
|
+
'web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.'
|
|
23495
|
+
);
|
|
23496
|
+
} else if (authorizationToken2) {
|
|
23497
|
+
if (typeof authorizationToken2 !== "string") {
|
|
23498
|
+
throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.');
|
|
23499
|
+
}
|
|
23500
|
+
} else if (typeof subscriptionKey2 !== "string") {
|
|
23501
|
+
throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');
|
|
23475
23502
|
}
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
23481
|
-
_defineProperties(Constructor, staticProps);
|
|
23482
|
-
return Constructor;
|
|
23483
|
-
}
|
|
23484
|
-
var EventAsPromise2 = /* @__PURE__ */ function() {
|
|
23485
|
-
function EventAsPromise3() {
|
|
23486
|
-
var _this = this;
|
|
23487
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
23488
|
-
_classCallCheck(this, EventAsPromise3);
|
|
23489
|
-
this.defers = [];
|
|
23490
|
-
this.upcomingDeferred = null;
|
|
23491
|
-
this.eventListener = this.eventListener.bind(this);
|
|
23492
|
-
this.options = options;
|
|
23493
|
-
this.one = this.one.bind(this);
|
|
23494
|
-
this.upcoming = this.upcoming.bind(this);
|
|
23495
|
-
this[Symbol.iterator] = function() {
|
|
23496
|
-
return {
|
|
23497
|
-
next: function next() {
|
|
23498
|
-
return {
|
|
23499
|
-
done: false,
|
|
23500
|
-
value: _this.upcoming()
|
|
23501
|
-
};
|
|
23502
|
-
}
|
|
23503
|
-
};
|
|
23504
|
-
};
|
|
23503
|
+
if (shouldWarnOnSubscriptionKey && subscriptionKey2) {
|
|
23504
|
+
console.warn(
|
|
23505
|
+
"web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."
|
|
23506
|
+
);
|
|
23507
|
+
shouldWarnOnSubscriptionKey = false;
|
|
23505
23508
|
}
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
if (this.upcomingDeferred) {
|
|
23513
|
-
this.upcomingDeferred.resolve(args);
|
|
23514
|
-
this.upcomingDeferred = null;
|
|
23515
|
-
}
|
|
23516
|
-
}
|
|
23517
|
-
}, {
|
|
23518
|
-
key: "one",
|
|
23519
|
-
value: function one() {
|
|
23520
|
-
var deferred = (0, _pDefer.default)();
|
|
23521
|
-
this.defers.push(deferred);
|
|
23522
|
-
return deferred.promise;
|
|
23523
|
-
}
|
|
23524
|
-
}, {
|
|
23525
|
-
key: "upcoming",
|
|
23526
|
-
value: function upcoming() {
|
|
23527
|
-
if (!this.upcomingDeferred) {
|
|
23528
|
-
this.upcomingDeferred = (0, _pDefer.default)();
|
|
23529
|
-
}
|
|
23530
|
-
return this.upcomingDeferred.promise;
|
|
23509
|
+
return {
|
|
23510
|
+
...typeof authorizationToken2 !== "undefined" ? { authorizationToken: authorizationToken2 } : { subscriptionKey: subscriptionKey2 },
|
|
23511
|
+
...typeof region2 !== "undefined" ? { region: region2 } : {
|
|
23512
|
+
customVoiceHostname,
|
|
23513
|
+
speechRecognitionHostname,
|
|
23514
|
+
speechSynthesisHostname
|
|
23531
23515
|
}
|
|
23532
|
-
}
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
}
|
|
23539
|
-
});
|
|
23540
|
-
|
|
23541
|
-
// ../../node_modules/event-target-shim/index.mjs
|
|
23542
|
-
function assertType(condition, message, ...args) {
|
|
23543
|
-
if (!condition) {
|
|
23544
|
-
throw new TypeError(format(message, args));
|
|
23545
|
-
}
|
|
23546
|
-
}
|
|
23547
|
-
function format(message, args) {
|
|
23548
|
-
let i = 0;
|
|
23549
|
-
return message.replace(/%[os]/gu, () => anyToString(args[i++]));
|
|
23516
|
+
};
|
|
23517
|
+
},
|
|
23518
|
+
looseEvents: !!looseEvents,
|
|
23519
|
+
referenceGrammars: referenceGrammars && Object.freeze([...referenceGrammars]),
|
|
23520
|
+
speechRecognitionEndpointId,
|
|
23521
|
+
textNormalization
|
|
23522
|
+
});
|
|
23550
23523
|
}
|
|
23551
|
-
|
|
23552
|
-
|
|
23553
|
-
|
|
23554
|
-
|
|
23555
|
-
|
|
23524
|
+
|
|
23525
|
+
// src/SpeechServices/SpeechSDK.ts
|
|
23526
|
+
var import_microsoft_cognitiveservices_speech = __toESM(require_microsoft_cognitiveservices_speech_sdk());
|
|
23527
|
+
var SpeechSDK_default = {
|
|
23528
|
+
AudioConfig: import_microsoft_cognitiveservices_speech.AudioConfig,
|
|
23529
|
+
OutputFormat: import_microsoft_cognitiveservices_speech.OutputFormat,
|
|
23530
|
+
ResultReason: import_microsoft_cognitiveservices_speech.ResultReason,
|
|
23531
|
+
SpeechConfig: import_microsoft_cognitiveservices_speech.SpeechConfig,
|
|
23532
|
+
SpeechRecognizer: import_microsoft_cognitiveservices_speech.SpeechRecognizer
|
|
23533
|
+
};
|
|
23534
|
+
|
|
23535
|
+
// ../../node_modules/p-defer/index.js
|
|
23536
|
+
function pDefer() {
|
|
23537
|
+
const deferred = {};
|
|
23538
|
+
deferred.promise = new Promise((resolve, reject) => {
|
|
23539
|
+
deferred.resolve = resolve;
|
|
23540
|
+
deferred.reject = reject;
|
|
23541
|
+
});
|
|
23542
|
+
return deferred;
|
|
23556
23543
|
}
|
|
23557
|
-
|
|
23558
|
-
|
|
23559
|
-
|
|
23560
|
-
|
|
23561
|
-
|
|
23562
|
-
|
|
23563
|
-
|
|
23544
|
+
|
|
23545
|
+
// src/Util/createPromiseQueue.js
|
|
23546
|
+
function createPromiseQueue_default() {
|
|
23547
|
+
let shiftDeferred;
|
|
23548
|
+
const queue = [];
|
|
23549
|
+
const push = (value) => {
|
|
23550
|
+
if (shiftDeferred) {
|
|
23551
|
+
const { resolve } = shiftDeferred;
|
|
23552
|
+
shiftDeferred = null;
|
|
23553
|
+
resolve(value);
|
|
23554
|
+
} else {
|
|
23555
|
+
queue.push(value);
|
|
23564
23556
|
}
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
return;
|
|
23557
|
+
};
|
|
23558
|
+
const shift = () => {
|
|
23559
|
+
if (queue.length) {
|
|
23560
|
+
return Promise.resolve(queue.shift());
|
|
23570
23561
|
}
|
|
23571
|
-
|
|
23572
|
-
}
|
|
23573
|
-
|
|
23562
|
+
return (shiftDeferred || (shiftDeferred = pDefer())).promise;
|
|
23563
|
+
};
|
|
23564
|
+
return {
|
|
23565
|
+
push,
|
|
23566
|
+
shift
|
|
23567
|
+
};
|
|
23574
23568
|
}
|
|
23575
|
-
|
|
23576
|
-
|
|
23577
|
-
var
|
|
23578
|
-
constructor(
|
|
23579
|
-
this
|
|
23580
|
-
this
|
|
23569
|
+
|
|
23570
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionAlternative.ts
|
|
23571
|
+
var SpeechRecognitionAlternative = class {
|
|
23572
|
+
constructor({ confidence, transcript }) {
|
|
23573
|
+
this.#confidence = confidence;
|
|
23574
|
+
this.#transcript = transcript;
|
|
23581
23575
|
}
|
|
23582
|
-
|
|
23583
|
-
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
if (currentWarnHandler) {
|
|
23590
|
-
currentWarnHandler({ ...this, args });
|
|
23591
|
-
return;
|
|
23592
|
-
}
|
|
23593
|
-
const stack = ((_a = new Error().stack) !== null && _a !== void 0 ? _a : "").replace(/^(?:.+?\n){2}/gu, "\n");
|
|
23594
|
-
console.warn(this.message, ...args, stack);
|
|
23595
|
-
} catch (_b) {
|
|
23596
|
-
}
|
|
23576
|
+
#confidence;
|
|
23577
|
+
#transcript;
|
|
23578
|
+
get confidence() {
|
|
23579
|
+
return this.#confidence;
|
|
23580
|
+
}
|
|
23581
|
+
get transcript() {
|
|
23582
|
+
return this.#transcript;
|
|
23597
23583
|
}
|
|
23598
23584
|
};
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
var
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23611
|
-
|
|
23612
|
-
|
|
23613
|
-
|
|
23585
|
+
|
|
23586
|
+
// src/SpeechServices/SpeechToText/private/FakeArray.ts
|
|
23587
|
+
var FakeArray = class {
|
|
23588
|
+
constructor(array) {
|
|
23589
|
+
if (!array) {
|
|
23590
|
+
throw new Error("array must be set.");
|
|
23591
|
+
}
|
|
23592
|
+
this.#array = array;
|
|
23593
|
+
for (const key in array) {
|
|
23594
|
+
Object.defineProperty(this, key, {
|
|
23595
|
+
enumerable: true,
|
|
23596
|
+
get() {
|
|
23597
|
+
return array[key];
|
|
23598
|
+
}
|
|
23599
|
+
});
|
|
23600
|
+
}
|
|
23614
23601
|
}
|
|
23615
|
-
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
static get CAPTURING_PHASE() {
|
|
23619
|
-
return CAPTURING_PHASE;
|
|
23602
|
+
#array;
|
|
23603
|
+
[Symbol.iterator]() {
|
|
23604
|
+
return this.#array[Symbol.iterator]();
|
|
23620
23605
|
}
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
-
*/
|
|
23624
|
-
static get AT_TARGET() {
|
|
23625
|
-
return AT_TARGET;
|
|
23606
|
+
get length() {
|
|
23607
|
+
return this.#array.length;
|
|
23626
23608
|
}
|
|
23627
|
-
|
|
23628
|
-
|
|
23629
|
-
|
|
23630
|
-
|
|
23631
|
-
|
|
23609
|
+
};
|
|
23610
|
+
|
|
23611
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionResult.ts
|
|
23612
|
+
var SpeechRecognitionResult = class extends FakeArray {
|
|
23613
|
+
constructor(init) {
|
|
23614
|
+
super(init.results);
|
|
23615
|
+
this.#isFinal = init.isFinal;
|
|
23632
23616
|
}
|
|
23633
|
-
|
|
23634
|
-
|
|
23635
|
-
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
|
|
23639
|
-
|
|
23640
|
-
|
|
23641
|
-
|
|
23642
|
-
|
|
23617
|
+
#isFinal;
|
|
23618
|
+
get isFinal() {
|
|
23619
|
+
return this.#isFinal;
|
|
23620
|
+
}
|
|
23621
|
+
};
|
|
23622
|
+
|
|
23623
|
+
// src/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResult.ts
|
|
23624
|
+
var {
|
|
23625
|
+
ResultReason: { RecognizingSpeech, RecognizedSpeech }
|
|
23626
|
+
} = SpeechSDK_default;
|
|
23627
|
+
function cognitiveServiceEventResultToWebSpeechRecognitionResult_default(result, init) {
|
|
23628
|
+
const { maxAlternatives = Infinity, textNormalization = "display" } = init || {};
|
|
23629
|
+
const json = typeof result.json === "string" ? JSON.parse(result.json) : result.json;
|
|
23630
|
+
if (result.reason === RecognizingSpeech || result.reason === RecognizedSpeech && !json.NBest) {
|
|
23631
|
+
return new SpeechRecognitionResult({
|
|
23632
|
+
isFinal: result.reason === RecognizedSpeech,
|
|
23633
|
+
results: [
|
|
23634
|
+
new SpeechRecognitionAlternative({
|
|
23635
|
+
confidence: 0.5,
|
|
23636
|
+
transcript: result.text
|
|
23637
|
+
})
|
|
23638
|
+
]
|
|
23643
23639
|
});
|
|
23644
|
-
|
|
23645
|
-
|
|
23646
|
-
|
|
23647
|
-
|
|
23648
|
-
|
|
23649
|
-
|
|
23650
|
-
|
|
23651
|
-
|
|
23652
|
-
|
|
23653
|
-
stopImmediatePropagationFlag: false,
|
|
23654
|
-
canceledFlag: false,
|
|
23655
|
-
inPassiveListenerFlag: false,
|
|
23656
|
-
dispatchFlag: false,
|
|
23657
|
-
timeStamp: Date.now()
|
|
23640
|
+
} else if (result.reason === RecognizedSpeech) {
|
|
23641
|
+
return new SpeechRecognitionResult({
|
|
23642
|
+
isFinal: true,
|
|
23643
|
+
results: (json.NBest || []).slice(0, maxAlternatives).map(
|
|
23644
|
+
({ Confidence: confidence, Display: display, ITN: itn, Lexical: lexical, MaskedITN: maskedITN }) => new SpeechRecognitionAlternative({
|
|
23645
|
+
confidence,
|
|
23646
|
+
transcript: textNormalization === "itn" ? itn : textNormalization === "lexical" ? lexical : textNormalization === "maskeditn" ? maskedITN : display
|
|
23647
|
+
})
|
|
23648
|
+
)
|
|
23658
23649
|
});
|
|
23659
23650
|
}
|
|
23660
|
-
|
|
23661
|
-
|
|
23662
|
-
|
|
23663
|
-
|
|
23664
|
-
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
|
|
23672
|
-
|
|
23673
|
-
|
|
23674
|
-
|
|
23675
|
-
|
|
23676
|
-
* @deprecated Use the `target` property instead.
|
|
23677
|
-
* @see https://dom.spec.whatwg.org/#dom-event-srcelement
|
|
23678
|
-
*/
|
|
23679
|
-
get srcElement() {
|
|
23680
|
-
return $(this).target;
|
|
23651
|
+
return new SpeechRecognitionResult({ isFinal: false, results: [] });
|
|
23652
|
+
}
|
|
23653
|
+
|
|
23654
|
+
// src/SpeechServices/SpeechToText/cognitiveServicesAsyncToPromise.ts
|
|
23655
|
+
function cognitiveServicesAsyncToPromise(fn, context = void 0) {
|
|
23656
|
+
return (...args) => (
|
|
23657
|
+
// eslint-disable-next-line prefer-spread
|
|
23658
|
+
new Promise((resolve, reject) => fn.apply(context, [...args, resolve, reject]))
|
|
23659
|
+
);
|
|
23660
|
+
}
|
|
23661
|
+
|
|
23662
|
+
// src/SpeechServices/SpeechToText/private/EventListenerMap.ts
|
|
23663
|
+
var EventListenerMap = class {
|
|
23664
|
+
constructor(eventTarget) {
|
|
23665
|
+
this.#eventTarget = eventTarget;
|
|
23666
|
+
this.#propertyMap = {};
|
|
23681
23667
|
}
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
get currentTarget() {
|
|
23687
|
-
return $(this).currentTarget;
|
|
23668
|
+
#eventTarget;
|
|
23669
|
+
#propertyMap;
|
|
23670
|
+
getProperty(name) {
|
|
23671
|
+
return this.#propertyMap[name];
|
|
23688
23672
|
}
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
composedPath() {
|
|
23695
|
-
const currentTarget = $(this).currentTarget;
|
|
23696
|
-
if (currentTarget) {
|
|
23697
|
-
return [currentTarget];
|
|
23673
|
+
setProperty(name, value) {
|
|
23674
|
+
const existing = this.#propertyMap[name];
|
|
23675
|
+
existing && this.#eventTarget.removeEventListener(name, existing);
|
|
23676
|
+
if (value) {
|
|
23677
|
+
this.#eventTarget.addEventListener(name, value);
|
|
23698
23678
|
}
|
|
23699
|
-
|
|
23700
|
-
}
|
|
23701
|
-
/**
|
|
23702
|
-
* @see https://dom.spec.whatwg.org/#dom-event-none
|
|
23703
|
-
*/
|
|
23704
|
-
get NONE() {
|
|
23705
|
-
return NONE;
|
|
23706
|
-
}
|
|
23707
|
-
/**
|
|
23708
|
-
* @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
|
|
23709
|
-
*/
|
|
23710
|
-
get CAPTURING_PHASE() {
|
|
23711
|
-
return CAPTURING_PHASE;
|
|
23712
|
-
}
|
|
23713
|
-
/**
|
|
23714
|
-
* @see https://dom.spec.whatwg.org/#dom-event-at_target
|
|
23715
|
-
*/
|
|
23716
|
-
get AT_TARGET() {
|
|
23717
|
-
return AT_TARGET;
|
|
23718
|
-
}
|
|
23719
|
-
/**
|
|
23720
|
-
* @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
|
|
23721
|
-
*/
|
|
23722
|
-
get BUBBLING_PHASE() {
|
|
23723
|
-
return BUBBLING_PHASE;
|
|
23679
|
+
this.#propertyMap[name] = value;
|
|
23724
23680
|
}
|
|
23725
|
-
|
|
23726
|
-
|
|
23727
|
-
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23681
|
+
};
|
|
23682
|
+
|
|
23683
|
+
// src/SpeechServices/SpeechToText/private/prepareAudioConfig.ts
|
|
23684
|
+
var import_AudioSourceEvents = __toESM(require_AudioSourceEvents());
|
|
23685
|
+
|
|
23686
|
+
// src/SpeechServices/SpeechToText/private/averageAmplitude.ts
|
|
23687
|
+
function averageAmplitude(arrayBuffer) {
|
|
23688
|
+
const array = Array.from(new Int16Array(arrayBuffer));
|
|
23689
|
+
return array.reduce((averageAmplitude2, amplitude) => averageAmplitude2 + Math.abs(amplitude), 0) / array.length;
|
|
23690
|
+
}
|
|
23691
|
+
|
|
23692
|
+
// src/SpeechServices/SpeechToText/private/prepareAudioConfig.ts
|
|
23693
|
+
function prepareAudioConfig(audioConfig) {
|
|
23694
|
+
const audioConfigImpl = audioConfig;
|
|
23695
|
+
const originalAttach = audioConfigImpl.attach;
|
|
23696
|
+
const boundOriginalAttach = audioConfigImpl.attach.bind(audioConfigImpl);
|
|
23697
|
+
let firstChunk = false;
|
|
23698
|
+
let muted = false;
|
|
23699
|
+
audioConfigImpl.attach = async () => {
|
|
23700
|
+
const reader = await boundOriginalAttach("");
|
|
23701
|
+
return {
|
|
23702
|
+
...reader,
|
|
23703
|
+
read: async () => {
|
|
23704
|
+
const chunk = await reader.read();
|
|
23705
|
+
if (!firstChunk && averageAmplitude(chunk.buffer) > 150) {
|
|
23706
|
+
audioConfigImpl.events.onEvent(new import_AudioSourceEvents.AudioSourceEvent("FirstAudibleChunk", ""));
|
|
23707
|
+
firstChunk = true;
|
|
23708
|
+
}
|
|
23709
|
+
if (muted) {
|
|
23710
|
+
return { buffer: new ArrayBuffer(0), isEnd: true, timeReceived: Date.now() };
|
|
23711
|
+
}
|
|
23712
|
+
return chunk;
|
|
23713
|
+
}
|
|
23714
|
+
};
|
|
23715
|
+
};
|
|
23716
|
+
return {
|
|
23717
|
+
audioConfig,
|
|
23718
|
+
pause: () => {
|
|
23719
|
+
muted = true;
|
|
23720
|
+
},
|
|
23721
|
+
unprepare: () => {
|
|
23722
|
+
audioConfigImpl.attach = originalAttach;
|
|
23723
|
+
}
|
|
23724
|
+
};
|
|
23725
|
+
}
|
|
23726
|
+
|
|
23727
|
+
// src/SpeechServices/SpeechToText/private/serializeRecognitionResult.ts
|
|
23728
|
+
function serializeRecognitionResult({
|
|
23729
|
+
duration,
|
|
23730
|
+
errorDetails,
|
|
23731
|
+
json,
|
|
23732
|
+
offset,
|
|
23733
|
+
properties,
|
|
23734
|
+
reason,
|
|
23735
|
+
resultId,
|
|
23736
|
+
text
|
|
23737
|
+
}) {
|
|
23738
|
+
return Object.freeze({
|
|
23739
|
+
duration,
|
|
23740
|
+
errorDetails,
|
|
23741
|
+
json: json && JSON.parse(json),
|
|
23742
|
+
offset,
|
|
23743
|
+
properties,
|
|
23744
|
+
reason,
|
|
23745
|
+
resultId,
|
|
23746
|
+
text
|
|
23747
|
+
});
|
|
23748
|
+
}
|
|
23749
|
+
|
|
23750
|
+
// src/SpeechServices/SpeechToText/SpeechGrammarList.ts
|
|
23751
|
+
var SpeechGrammarList = class {
|
|
23752
|
+
constructor() {
|
|
23753
|
+
this.#phrases = [];
|
|
23731
23754
|
}
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
* Because this shim doesn't support node tree, this merely changes the `cancelBubble` property value.
|
|
23735
|
-
* @see https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
|
23736
|
-
*/
|
|
23737
|
-
stopPropagation() {
|
|
23738
|
-
$(this).stopPropagationFlag = true;
|
|
23755
|
+
addFromString() {
|
|
23756
|
+
throw new Error("JSGF is not supported");
|
|
23739
23757
|
}
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
* @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
|
|
23744
|
-
*/
|
|
23745
|
-
get cancelBubble() {
|
|
23746
|
-
return $(this).stopPropagationFlag;
|
|
23758
|
+
#phrases;
|
|
23759
|
+
get phrases() {
|
|
23760
|
+
return this.#phrases;
|
|
23747
23761
|
}
|
|
23748
|
-
|
|
23749
|
-
|
|
23750
|
-
|
|
23751
|
-
|
|
23752
|
-
|
|
23753
|
-
set cancelBubble(value) {
|
|
23754
|
-
if (value) {
|
|
23755
|
-
$(this).stopPropagationFlag = true;
|
|
23762
|
+
set phrases(value) {
|
|
23763
|
+
if (Array.isArray(value)) {
|
|
23764
|
+
this.#phrases = Object.freeze([...value]);
|
|
23765
|
+
} else if (typeof value === "string") {
|
|
23766
|
+
this.#phrases = Object.freeze([value]);
|
|
23756
23767
|
} else {
|
|
23757
|
-
|
|
23768
|
+
throw new Error(`The provided value is not an array or of type 'string'`);
|
|
23758
23769
|
}
|
|
23759
23770
|
}
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
/**
|
|
23769
|
-
* `true` if this event will bubble.
|
|
23770
|
-
* @see https://dom.spec.whatwg.org/#dom-event-bubbles
|
|
23771
|
-
*/
|
|
23772
|
-
get bubbles() {
|
|
23773
|
-
return $(this).bubbles;
|
|
23771
|
+
};
|
|
23772
|
+
|
|
23773
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionErrorEvent.ts
|
|
23774
|
+
var SpeechRecognitionErrorEvent = class extends Event {
|
|
23775
|
+
constructor(type, { error, message }) {
|
|
23776
|
+
super(type);
|
|
23777
|
+
this.#error = error;
|
|
23778
|
+
this.#message = message;
|
|
23774
23779
|
}
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
get cancelable() {
|
|
23780
|
-
return $(this).cancelable;
|
|
23780
|
+
#error;
|
|
23781
|
+
#message;
|
|
23782
|
+
get error() {
|
|
23783
|
+
return this.#error;
|
|
23781
23784
|
}
|
|
23782
|
-
|
|
23783
|
-
|
|
23784
|
-
* @deprecated Use the `defaultPrevented` proeprty instead.
|
|
23785
|
-
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
23786
|
-
*/
|
|
23787
|
-
get returnValue() {
|
|
23788
|
-
return !$(this).canceledFlag;
|
|
23785
|
+
get message() {
|
|
23786
|
+
return this.#message;
|
|
23789
23787
|
}
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
* @deprecated Use the `preventDefault()` method instead.
|
|
23793
|
-
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
23794
|
-
*/
|
|
23795
|
-
set returnValue(value) {
|
|
23796
|
-
if (!value) {
|
|
23797
|
-
setCancelFlag($(this));
|
|
23798
|
-
} else {
|
|
23799
|
-
TruthyWasAssignedToReturnValue.warn();
|
|
23800
|
-
}
|
|
23788
|
+
get type() {
|
|
23789
|
+
return "error";
|
|
23801
23790
|
}
|
|
23802
|
-
|
|
23803
|
-
|
|
23804
|
-
|
|
23805
|
-
|
|
23806
|
-
|
|
23807
|
-
|
|
23791
|
+
};
|
|
23792
|
+
|
|
23793
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionResultList.ts
|
|
23794
|
+
var SpeechRecognitionResultList = class extends FakeArray {
|
|
23795
|
+
constructor(result) {
|
|
23796
|
+
super(result);
|
|
23808
23797
|
}
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
|
|
23813
|
-
|
|
23814
|
-
|
|
23798
|
+
};
|
|
23799
|
+
|
|
23800
|
+
// src/SpeechServices/SpeechToText/SpeechRecognitionEvent.ts
|
|
23801
|
+
var SpeechRecognitionEvent = class extends Event {
|
|
23802
|
+
constructor(type, { data, resultIndex, results } = {}) {
|
|
23803
|
+
super(type);
|
|
23804
|
+
this.#data = data;
|
|
23805
|
+
this.#resultIndex = resultIndex;
|
|
23806
|
+
this.#results = results || new SpeechRecognitionResultList([]);
|
|
23815
23807
|
}
|
|
23816
|
-
|
|
23817
|
-
|
|
23818
|
-
|
|
23819
|
-
|
|
23820
|
-
|
|
23808
|
+
#data;
|
|
23809
|
+
// TODO: "resultIndex" should be set.
|
|
23810
|
+
#resultIndex;
|
|
23811
|
+
#results;
|
|
23812
|
+
get data() {
|
|
23813
|
+
return this.#data;
|
|
23821
23814
|
}
|
|
23822
|
-
|
|
23823
|
-
|
|
23824
|
-
*/
|
|
23825
|
-
//istanbul ignore next
|
|
23826
|
-
get isTrusted() {
|
|
23827
|
-
return false;
|
|
23815
|
+
get resultIndex() {
|
|
23816
|
+
return this.#resultIndex;
|
|
23828
23817
|
}
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
*/
|
|
23832
|
-
get timeStamp() {
|
|
23833
|
-
return $(this).timeStamp;
|
|
23818
|
+
get results() {
|
|
23819
|
+
return this.#results;
|
|
23834
23820
|
}
|
|
23835
|
-
|
|
23836
|
-
|
|
23837
|
-
*/
|
|
23838
|
-
initEvent(type, bubbles = false, cancelable = false) {
|
|
23839
|
-
const data = $(this);
|
|
23840
|
-
if (data.dispatchFlag) {
|
|
23841
|
-
InitEventWasCalledWhileDispatching.warn();
|
|
23842
|
-
return;
|
|
23843
|
-
}
|
|
23844
|
-
internalDataMap.set(this, {
|
|
23845
|
-
...data,
|
|
23846
|
-
type: String(type),
|
|
23847
|
-
bubbles: Boolean(bubbles),
|
|
23848
|
-
cancelable: Boolean(cancelable),
|
|
23849
|
-
target: null,
|
|
23850
|
-
currentTarget: null,
|
|
23851
|
-
stopPropagationFlag: false,
|
|
23852
|
-
stopImmediatePropagationFlag: false,
|
|
23853
|
-
canceledFlag: false
|
|
23854
|
-
});
|
|
23821
|
+
get type() {
|
|
23822
|
+
return super.type;
|
|
23855
23823
|
}
|
|
23856
23824
|
};
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
var
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
}
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
|
|
23875
|
-
|
|
23876
|
-
|
|
23877
|
-
|
|
23878
|
-
|
|
23879
|
-
|
|
23880
|
-
|
|
23881
|
-
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
continue;
|
|
23886
|
-
}
|
|
23887
|
-
Object.defineProperty(Event.prototype, keys[i], { enumerable: true });
|
|
23888
|
-
}
|
|
23889
|
-
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
23890
|
-
Object.setPrototypeOf(Event.prototype, Global.Event.prototype);
|
|
23891
|
-
}
|
|
23892
|
-
function createInvalidStateError(message) {
|
|
23893
|
-
if (Global.DOMException) {
|
|
23894
|
-
return new Global.DOMException(message, "InvalidStateError");
|
|
23895
|
-
}
|
|
23896
|
-
if (DOMException == null) {
|
|
23897
|
-
DOMException = class DOMException2 extends Error {
|
|
23898
|
-
constructor(msg) {
|
|
23899
|
-
super(msg);
|
|
23900
|
-
if (Error.captureStackTrace) {
|
|
23901
|
-
Error.captureStackTrace(this, DOMException2);
|
|
23902
|
-
}
|
|
23903
|
-
}
|
|
23904
|
-
// eslint-disable-next-line class-methods-use-this
|
|
23905
|
-
get code() {
|
|
23906
|
-
return 11;
|
|
23907
|
-
}
|
|
23908
|
-
// eslint-disable-next-line class-methods-use-this
|
|
23909
|
-
get name() {
|
|
23910
|
-
return "InvalidStateError";
|
|
23911
|
-
}
|
|
23912
|
-
};
|
|
23913
|
-
Object.defineProperties(DOMException.prototype, {
|
|
23914
|
-
code: { enumerable: true },
|
|
23915
|
-
name: { enumerable: true }
|
|
23916
|
-
});
|
|
23917
|
-
defineErrorCodeProperties(DOMException);
|
|
23918
|
-
defineErrorCodeProperties(DOMException.prototype);
|
|
23919
|
-
}
|
|
23920
|
-
return new DOMException(message);
|
|
23921
|
-
}
|
|
23922
|
-
var DOMException;
|
|
23923
|
-
var ErrorCodeMap = {
|
|
23924
|
-
INDEX_SIZE_ERR: 1,
|
|
23925
|
-
DOMSTRING_SIZE_ERR: 2,
|
|
23926
|
-
HIERARCHY_REQUEST_ERR: 3,
|
|
23927
|
-
WRONG_DOCUMENT_ERR: 4,
|
|
23928
|
-
INVALID_CHARACTER_ERR: 5,
|
|
23929
|
-
NO_DATA_ALLOWED_ERR: 6,
|
|
23930
|
-
NO_MODIFICATION_ALLOWED_ERR: 7,
|
|
23931
|
-
NOT_FOUND_ERR: 8,
|
|
23932
|
-
NOT_SUPPORTED_ERR: 9,
|
|
23933
|
-
INUSE_ATTRIBUTE_ERR: 10,
|
|
23934
|
-
INVALID_STATE_ERR: 11,
|
|
23935
|
-
SYNTAX_ERR: 12,
|
|
23936
|
-
INVALID_MODIFICATION_ERR: 13,
|
|
23937
|
-
NAMESPACE_ERR: 14,
|
|
23938
|
-
INVALID_ACCESS_ERR: 15,
|
|
23939
|
-
VALIDATION_ERR: 16,
|
|
23940
|
-
TYPE_MISMATCH_ERR: 17,
|
|
23941
|
-
SECURITY_ERR: 18,
|
|
23942
|
-
NETWORK_ERR: 19,
|
|
23943
|
-
ABORT_ERR: 20,
|
|
23944
|
-
URL_MISMATCH_ERR: 21,
|
|
23945
|
-
QUOTA_EXCEEDED_ERR: 22,
|
|
23946
|
-
TIMEOUT_ERR: 23,
|
|
23947
|
-
INVALID_NODE_TYPE_ERR: 24,
|
|
23948
|
-
DATA_CLONE_ERR: 25
|
|
23949
|
-
};
|
|
23950
|
-
function defineErrorCodeProperties(obj) {
|
|
23951
|
-
const keys2 = Object.keys(ErrorCodeMap);
|
|
23952
|
-
for (let i = 0; i < keys2.length; ++i) {
|
|
23953
|
-
const key = keys2[i];
|
|
23954
|
-
const value = ErrorCodeMap[key];
|
|
23955
|
-
Object.defineProperty(obj, key, {
|
|
23956
|
-
get() {
|
|
23957
|
-
return value;
|
|
23958
|
-
},
|
|
23959
|
-
configurable: true,
|
|
23960
|
-
enumerable: true
|
|
23961
|
-
});
|
|
23962
|
-
}
|
|
23963
|
-
}
|
|
23964
|
-
var EventWrapper = class extends Event {
|
|
23965
|
-
/**
|
|
23966
|
-
* Wrap a given event object to control states.
|
|
23967
|
-
* @param event The event-like object to wrap.
|
|
23968
|
-
*/
|
|
23969
|
-
static wrap(event) {
|
|
23970
|
-
return new (getWrapperClassOf(event))(event);
|
|
23971
|
-
}
|
|
23972
|
-
constructor(event) {
|
|
23973
|
-
super(event.type, {
|
|
23974
|
-
bubbles: event.bubbles,
|
|
23975
|
-
cancelable: event.cancelable,
|
|
23976
|
-
composed: event.composed
|
|
23977
|
-
});
|
|
23978
|
-
if (event.cancelBubble) {
|
|
23979
|
-
super.stopPropagation();
|
|
23825
|
+
|
|
23826
|
+
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfillFromRecognizer.ts
|
|
23827
|
+
var { ResultReason: ResultReason2, SpeechRecognizer: SpeechRecognizer2 } = SpeechSDK_default;
|
|
23828
|
+
function createSpeechRecognitionPonyfillFromRecognizer({
|
|
23829
|
+
createRecognizer,
|
|
23830
|
+
enableTelemetry,
|
|
23831
|
+
looseEvents,
|
|
23832
|
+
referenceGrammars,
|
|
23833
|
+
textNormalization
|
|
23834
|
+
}) {
|
|
23835
|
+
SpeechRecognizer2.enableTelemetry(enableTelemetry !== false);
|
|
23836
|
+
class SpeechRecognition extends EventTarget {
|
|
23837
|
+
#continuous = false;
|
|
23838
|
+
#eventListenerMap = new EventListenerMap(this);
|
|
23839
|
+
#grammars = new SpeechGrammarList();
|
|
23840
|
+
#interimResults = false;
|
|
23841
|
+
#lang = typeof window !== "undefined" ? window.document.documentElement.getAttribute("lang") || window.navigator.language : "en-US";
|
|
23842
|
+
// eslint-disable-next-line no-magic-numbers
|
|
23843
|
+
#maxAlternatives = 1;
|
|
23844
|
+
emitCognitiveServices(type, event) {
|
|
23845
|
+
this.dispatchEvent(
|
|
23846
|
+
new SpeechRecognitionEvent("cognitiveservices", {
|
|
23847
|
+
data: {
|
|
23848
|
+
...event,
|
|
23849
|
+
type
|
|
23850
|
+
}
|
|
23851
|
+
})
|
|
23852
|
+
);
|
|
23980
23853
|
}
|
|
23981
|
-
|
|
23982
|
-
|
|
23854
|
+
get continuous() {
|
|
23855
|
+
return this.#continuous;
|
|
23983
23856
|
}
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23857
|
+
set continuous(value) {
|
|
23858
|
+
this.#continuous = value;
|
|
23859
|
+
}
|
|
23860
|
+
get grammars() {
|
|
23861
|
+
return this.#grammars;
|
|
23862
|
+
}
|
|
23863
|
+
set grammars(value) {
|
|
23864
|
+
if (value instanceof SpeechGrammarList) {
|
|
23865
|
+
this.#grammars = value;
|
|
23866
|
+
} else {
|
|
23867
|
+
throw new Error(`The provided value is not of type 'SpeechGrammarList'`);
|
|
23990
23868
|
}
|
|
23991
23869
|
}
|
|
23992
|
-
|
|
23993
|
-
|
|
23994
|
-
super.stopPropagation();
|
|
23995
|
-
const { original } = $$1(this);
|
|
23996
|
-
if ("stopPropagation" in original) {
|
|
23997
|
-
original.stopPropagation();
|
|
23870
|
+
get interimResults() {
|
|
23871
|
+
return this.#interimResults;
|
|
23998
23872
|
}
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
return super.cancelBubble;
|
|
24002
|
-
}
|
|
24003
|
-
set cancelBubble(value) {
|
|
24004
|
-
super.cancelBubble = value;
|
|
24005
|
-
const { original } = $$1(this);
|
|
24006
|
-
if ("cancelBubble" in original) {
|
|
24007
|
-
original.cancelBubble = value;
|
|
23873
|
+
set interimResults(value) {
|
|
23874
|
+
this.#interimResults = value;
|
|
24008
23875
|
}
|
|
24009
|
-
|
|
24010
|
-
|
|
24011
|
-
super.stopImmediatePropagation();
|
|
24012
|
-
const { original } = $$1(this);
|
|
24013
|
-
if ("stopImmediatePropagation" in original) {
|
|
24014
|
-
original.stopImmediatePropagation();
|
|
23876
|
+
get maxAlternatives() {
|
|
23877
|
+
return this.#maxAlternatives;
|
|
24015
23878
|
}
|
|
24016
|
-
|
|
24017
|
-
|
|
24018
|
-
return super.returnValue;
|
|
24019
|
-
}
|
|
24020
|
-
set returnValue(value) {
|
|
24021
|
-
super.returnValue = value;
|
|
24022
|
-
const { original } = $$1(this);
|
|
24023
|
-
if ("returnValue" in original) {
|
|
24024
|
-
original.returnValue = value;
|
|
23879
|
+
set maxAlternatives(value) {
|
|
23880
|
+
this.#maxAlternatives = value;
|
|
24025
23881
|
}
|
|
24026
|
-
|
|
24027
|
-
|
|
24028
|
-
super.preventDefault();
|
|
24029
|
-
const { original } = $$1(this);
|
|
24030
|
-
if ("preventDefault" in original) {
|
|
24031
|
-
original.preventDefault();
|
|
23882
|
+
get lang() {
|
|
23883
|
+
return this.#lang;
|
|
24032
23884
|
}
|
|
24033
|
-
|
|
24034
|
-
|
|
24035
|
-
const { original } = $$1(this);
|
|
24036
|
-
if ("timeStamp" in original) {
|
|
24037
|
-
return original.timeStamp;
|
|
23885
|
+
set lang(value) {
|
|
23886
|
+
this.#lang = value;
|
|
24038
23887
|
}
|
|
24039
|
-
|
|
24040
|
-
|
|
24041
|
-
};
|
|
24042
|
-
var internalDataMap$1 = /* @__PURE__ */ new WeakMap();
|
|
24043
|
-
function $$1(event) {
|
|
24044
|
-
const retv = internalDataMap$1.get(event);
|
|
24045
|
-
assertType(retv != null, "'this' is expected an Event object, but got", event);
|
|
24046
|
-
return retv;
|
|
24047
|
-
}
|
|
24048
|
-
var wrapperClassCache = /* @__PURE__ */ new WeakMap();
|
|
24049
|
-
wrapperClassCache.set(Object.prototype, EventWrapper);
|
|
24050
|
-
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
24051
|
-
wrapperClassCache.set(Global.Event.prototype, EventWrapper);
|
|
24052
|
-
}
|
|
24053
|
-
function getWrapperClassOf(originalEvent) {
|
|
24054
|
-
const prototype = Object.getPrototypeOf(originalEvent);
|
|
24055
|
-
if (prototype == null) {
|
|
24056
|
-
return EventWrapper;
|
|
24057
|
-
}
|
|
24058
|
-
let wrapper = wrapperClassCache.get(prototype);
|
|
24059
|
-
if (wrapper == null) {
|
|
24060
|
-
wrapper = defineWrapper(getWrapperClassOf(prototype), prototype);
|
|
24061
|
-
wrapperClassCache.set(prototype, wrapper);
|
|
24062
|
-
}
|
|
24063
|
-
return wrapper;
|
|
24064
|
-
}
|
|
24065
|
-
function defineWrapper(BaseEventWrapper, originalPrototype) {
|
|
24066
|
-
class CustomEventWrapper extends BaseEventWrapper {
|
|
24067
|
-
}
|
|
24068
|
-
const keys2 = Object.keys(originalPrototype);
|
|
24069
|
-
for (let i = 0; i < keys2.length; ++i) {
|
|
24070
|
-
Object.defineProperty(CustomEventWrapper.prototype, keys2[i], defineRedirectDescriptor(originalPrototype, keys2[i]));
|
|
24071
|
-
}
|
|
24072
|
-
return CustomEventWrapper;
|
|
24073
|
-
}
|
|
24074
|
-
function defineRedirectDescriptor(obj, key) {
|
|
24075
|
-
const d = Object.getOwnPropertyDescriptor(obj, key);
|
|
24076
|
-
return {
|
|
24077
|
-
get() {
|
|
24078
|
-
const original = $$1(this).original;
|
|
24079
|
-
const value = original[key];
|
|
24080
|
-
if (typeof value === "function") {
|
|
24081
|
-
return value.bind(original);
|
|
24082
|
-
}
|
|
24083
|
-
return value;
|
|
24084
|
-
},
|
|
24085
|
-
set(value) {
|
|
24086
|
-
const original = $$1(this).original;
|
|
24087
|
-
original[key] = value;
|
|
24088
|
-
},
|
|
24089
|
-
configurable: d.configurable,
|
|
24090
|
-
enumerable: d.enumerable
|
|
24091
|
-
};
|
|
24092
|
-
}
|
|
24093
|
-
function createListener(callback, capture, passive, once, signal, signalListener) {
|
|
24094
|
-
return {
|
|
24095
|
-
callback,
|
|
24096
|
-
flags: (capture ? 1 : 0) | (passive ? 2 : 0) | (once ? 4 : 0),
|
|
24097
|
-
signal,
|
|
24098
|
-
signalListener
|
|
24099
|
-
};
|
|
24100
|
-
}
|
|
24101
|
-
function setRemoved(listener) {
|
|
24102
|
-
listener.flags |= 8;
|
|
24103
|
-
}
|
|
24104
|
-
function isCapture(listener) {
|
|
24105
|
-
return (listener.flags & 1) === 1;
|
|
24106
|
-
}
|
|
24107
|
-
function isPassive(listener) {
|
|
24108
|
-
return (listener.flags & 2) === 2;
|
|
24109
|
-
}
|
|
24110
|
-
function isOnce(listener) {
|
|
24111
|
-
return (listener.flags & 4) === 4;
|
|
24112
|
-
}
|
|
24113
|
-
function isRemoved(listener) {
|
|
24114
|
-
return (listener.flags & 8) === 8;
|
|
24115
|
-
}
|
|
24116
|
-
function invokeCallback({ callback }, target, event) {
|
|
24117
|
-
try {
|
|
24118
|
-
if (typeof callback === "function") {
|
|
24119
|
-
callback.call(target, event);
|
|
24120
|
-
} else if (typeof callback.handleEvent === "function") {
|
|
24121
|
-
callback.handleEvent(event);
|
|
23888
|
+
get onaudioend() {
|
|
23889
|
+
return this.#eventListenerMap.getProperty("audioend");
|
|
24122
23890
|
}
|
|
24123
|
-
|
|
24124
|
-
|
|
24125
|
-
}
|
|
24126
|
-
}
|
|
24127
|
-
function findIndexOfListener({ listeners }, callback, capture) {
|
|
24128
|
-
for (let i = 0; i < listeners.length; ++i) {
|
|
24129
|
-
if (listeners[i].callback === callback && isCapture(listeners[i]) === capture) {
|
|
24130
|
-
return i;
|
|
23891
|
+
set onaudioend(value) {
|
|
23892
|
+
this.#eventListenerMap.setProperty("audioend", value);
|
|
24131
23893
|
}
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24135
|
-
function addListener(list, callback, capture, passive, once, signal) {
|
|
24136
|
-
let signalListener;
|
|
24137
|
-
if (signal) {
|
|
24138
|
-
signalListener = removeListener.bind(null, list, callback, capture);
|
|
24139
|
-
signal.addEventListener("abort", signalListener);
|
|
24140
|
-
}
|
|
24141
|
-
const listener = createListener(callback, capture, passive, once, signal, signalListener);
|
|
24142
|
-
if (list.cow) {
|
|
24143
|
-
list.cow = false;
|
|
24144
|
-
list.listeners = [...list.listeners, listener];
|
|
24145
|
-
} else {
|
|
24146
|
-
list.listeners.push(listener);
|
|
24147
|
-
}
|
|
24148
|
-
return listener;
|
|
24149
|
-
}
|
|
24150
|
-
function removeListener(list, callback, capture) {
|
|
24151
|
-
const index = findIndexOfListener(list, callback, capture);
|
|
24152
|
-
if (index !== -1) {
|
|
24153
|
-
return removeListenerAt(list, index);
|
|
24154
|
-
}
|
|
24155
|
-
return false;
|
|
24156
|
-
}
|
|
24157
|
-
function removeListenerAt(list, index, disableCow = false) {
|
|
24158
|
-
const listener = list.listeners[index];
|
|
24159
|
-
setRemoved(listener);
|
|
24160
|
-
if (listener.signal) {
|
|
24161
|
-
listener.signal.removeEventListener("abort", listener.signalListener);
|
|
24162
|
-
}
|
|
24163
|
-
if (list.cow && !disableCow) {
|
|
24164
|
-
list.cow = false;
|
|
24165
|
-
list.listeners = list.listeners.filter((_, i) => i !== index);
|
|
24166
|
-
return false;
|
|
24167
|
-
}
|
|
24168
|
-
list.listeners.splice(index, 1);
|
|
24169
|
-
return true;
|
|
24170
|
-
}
|
|
24171
|
-
function createListenerListMap() {
|
|
24172
|
-
return /* @__PURE__ */ Object.create(null);
|
|
24173
|
-
}
|
|
24174
|
-
function ensureListenerList(listenerMap, type) {
|
|
24175
|
-
var _a;
|
|
24176
|
-
return (_a = listenerMap[type]) !== null && _a !== void 0 ? _a : listenerMap[type] = {
|
|
24177
|
-
attrCallback: void 0,
|
|
24178
|
-
attrListener: void 0,
|
|
24179
|
-
cow: false,
|
|
24180
|
-
listeners: []
|
|
24181
|
-
};
|
|
24182
|
-
}
|
|
24183
|
-
var EventTarget = class {
|
|
24184
|
-
/**
|
|
24185
|
-
* Initialize this instance.
|
|
24186
|
-
*/
|
|
24187
|
-
constructor() {
|
|
24188
|
-
internalDataMap$2.set(this, createListenerListMap());
|
|
24189
|
-
}
|
|
24190
|
-
// Implementation
|
|
24191
|
-
addEventListener(type0, callback0, options0) {
|
|
24192
|
-
const listenerMap = $$2(this);
|
|
24193
|
-
const { callback, capture, once, passive, signal, type } = normalizeAddOptions(type0, callback0, options0);
|
|
24194
|
-
if (callback == null || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
24195
|
-
return;
|
|
23894
|
+
/** @type { ((event: SpeechRecognitionEvent<'audiostart'>) => void) | undefined } */
|
|
23895
|
+
get onaudiostart() {
|
|
23896
|
+
return this.#eventListenerMap.getProperty("audiostart");
|
|
24196
23897
|
}
|
|
24197
|
-
|
|
24198
|
-
|
|
24199
|
-
if (i !== -1) {
|
|
24200
|
-
warnDuplicate(list.listeners[i], passive, once, signal);
|
|
24201
|
-
return;
|
|
23898
|
+
set onaudiostart(value) {
|
|
23899
|
+
this.#eventListenerMap.setProperty("audiostart", value);
|
|
24202
23900
|
}
|
|
24203
|
-
|
|
24204
|
-
|
|
24205
|
-
|
|
24206
|
-
removeEventListener(type0, callback0, options0) {
|
|
24207
|
-
const listenerMap = $$2(this);
|
|
24208
|
-
const { callback, capture, type } = normalizeOptions(type0, callback0, options0);
|
|
24209
|
-
const list = listenerMap[type];
|
|
24210
|
-
if (callback != null && list) {
|
|
24211
|
-
removeListener(list, callback, capture);
|
|
23901
|
+
/** @type { ((event: SpeechRecognitionEvent<'cognitiveservices'>) => void) | undefined } */
|
|
23902
|
+
get oncognitiveservices() {
|
|
23903
|
+
return this.#eventListenerMap.getProperty("cognitiveservices");
|
|
24212
23904
|
}
|
|
24213
|
-
|
|
24214
|
-
|
|
24215
|
-
dispatchEvent(e) {
|
|
24216
|
-
const list = $$2(this)[String(e.type)];
|
|
24217
|
-
if (list == null) {
|
|
24218
|
-
return true;
|
|
23905
|
+
set oncognitiveservices(value) {
|
|
23906
|
+
this.#eventListenerMap.setProperty("cognitiveservices", value);
|
|
24219
23907
|
}
|
|
24220
|
-
|
|
24221
|
-
|
|
24222
|
-
|
|
24223
|
-
throw createInvalidStateError("This event has been in dispatching.");
|
|
23908
|
+
/** @type { ((event: SpeechRecognitionEvent<'end'>) => void) | undefined } */
|
|
23909
|
+
get onend() {
|
|
23910
|
+
return this.#eventListenerMap.getProperty("end");
|
|
24224
23911
|
}
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
if (!eventData.stopPropagationFlag) {
|
|
24228
|
-
const { cow, listeners } = list;
|
|
24229
|
-
list.cow = true;
|
|
24230
|
-
for (let i = 0; i < listeners.length; ++i) {
|
|
24231
|
-
const listener = listeners[i];
|
|
24232
|
-
if (isRemoved(listener)) {
|
|
24233
|
-
continue;
|
|
24234
|
-
}
|
|
24235
|
-
if (isOnce(listener) && removeListenerAt(list, i, !cow)) {
|
|
24236
|
-
i -= 1;
|
|
24237
|
-
}
|
|
24238
|
-
eventData.inPassiveListenerFlag = isPassive(listener);
|
|
24239
|
-
invokeCallback(listener, this, event);
|
|
24240
|
-
eventData.inPassiveListenerFlag = false;
|
|
24241
|
-
if (eventData.stopImmediatePropagationFlag) {
|
|
24242
|
-
break;
|
|
24243
|
-
}
|
|
24244
|
-
}
|
|
24245
|
-
if (!cow) {
|
|
24246
|
-
list.cow = false;
|
|
24247
|
-
}
|
|
23912
|
+
set onend(value) {
|
|
23913
|
+
this.#eventListenerMap.setProperty("end", value);
|
|
24248
23914
|
}
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
eventData.stopPropagationFlag = false;
|
|
24253
|
-
eventData.dispatchFlag = false;
|
|
24254
|
-
return !eventData.canceledFlag;
|
|
24255
|
-
}
|
|
24256
|
-
};
|
|
24257
|
-
var internalDataMap$2 = /* @__PURE__ */ new WeakMap();
|
|
24258
|
-
function $$2(target, name = "this") {
|
|
24259
|
-
const retv = internalDataMap$2.get(target);
|
|
24260
|
-
assertType(retv != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", name, target);
|
|
24261
|
-
return retv;
|
|
24262
|
-
}
|
|
24263
|
-
function normalizeAddOptions(type, callback, options) {
|
|
24264
|
-
var _a;
|
|
24265
|
-
assertCallback(callback);
|
|
24266
|
-
if (typeof options === "object" && options !== null) {
|
|
24267
|
-
return {
|
|
24268
|
-
type: String(type),
|
|
24269
|
-
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24270
|
-
capture: Boolean(options.capture),
|
|
24271
|
-
passive: Boolean(options.passive),
|
|
24272
|
-
once: Boolean(options.once),
|
|
24273
|
-
signal: (_a = options.signal) !== null && _a !== void 0 ? _a : void 0
|
|
24274
|
-
};
|
|
24275
|
-
}
|
|
24276
|
-
return {
|
|
24277
|
-
type: String(type),
|
|
24278
|
-
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24279
|
-
capture: Boolean(options),
|
|
24280
|
-
passive: false,
|
|
24281
|
-
once: false,
|
|
24282
|
-
signal: void 0
|
|
24283
|
-
};
|
|
24284
|
-
}
|
|
24285
|
-
function normalizeOptions(type, callback, options) {
|
|
24286
|
-
assertCallback(callback);
|
|
24287
|
-
if (typeof options === "object" && options !== null) {
|
|
24288
|
-
return {
|
|
24289
|
-
type: String(type),
|
|
24290
|
-
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24291
|
-
capture: Boolean(options.capture)
|
|
24292
|
-
};
|
|
24293
|
-
}
|
|
24294
|
-
return {
|
|
24295
|
-
type: String(type),
|
|
24296
|
-
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24297
|
-
capture: Boolean(options)
|
|
24298
|
-
};
|
|
24299
|
-
}
|
|
24300
|
-
function assertCallback(callback) {
|
|
24301
|
-
if (typeof callback === "function" || typeof callback === "object" && callback !== null && typeof callback.handleEvent === "function") {
|
|
24302
|
-
return;
|
|
24303
|
-
}
|
|
24304
|
-
if (callback == null || typeof callback === "object") {
|
|
24305
|
-
InvalidEventListener.warn(callback);
|
|
24306
|
-
return;
|
|
24307
|
-
}
|
|
24308
|
-
throw new TypeError(format(InvalidEventListener.message, [callback]));
|
|
24309
|
-
}
|
|
24310
|
-
function warnDuplicate(listener, passive, once, signal) {
|
|
24311
|
-
EventListenerWasDuplicated.warn(isCapture(listener) ? "capture" : "bubble", listener.callback);
|
|
24312
|
-
if (isPassive(listener) !== passive) {
|
|
24313
|
-
OptionWasIgnored.warn("passive");
|
|
24314
|
-
}
|
|
24315
|
-
if (isOnce(listener) !== once) {
|
|
24316
|
-
OptionWasIgnored.warn("once");
|
|
24317
|
-
}
|
|
24318
|
-
if (listener.signal !== signal) {
|
|
24319
|
-
OptionWasIgnored.warn("signal");
|
|
24320
|
-
}
|
|
24321
|
-
}
|
|
24322
|
-
var keys$1 = Object.getOwnPropertyNames(EventTarget.prototype);
|
|
24323
|
-
for (let i = 0; i < keys$1.length; ++i) {
|
|
24324
|
-
if (keys$1[i] === "constructor") {
|
|
24325
|
-
continue;
|
|
24326
|
-
}
|
|
24327
|
-
Object.defineProperty(EventTarget.prototype, keys$1[i], { enumerable: true });
|
|
24328
|
-
}
|
|
24329
|
-
if (typeof Global !== "undefined" && typeof Global.EventTarget !== "undefined") {
|
|
24330
|
-
Object.setPrototypeOf(EventTarget.prototype, Global.EventTarget.prototype);
|
|
24331
|
-
}
|
|
24332
|
-
function getEventAttributeValue(target, type) {
|
|
24333
|
-
var _a, _b;
|
|
24334
|
-
const listMap = $$2(target, "target");
|
|
24335
|
-
return (_b = (_a = listMap[type]) === null || _a === void 0 ? void 0 : _a.attrCallback) !== null && _b !== void 0 ? _b : null;
|
|
24336
|
-
}
|
|
24337
|
-
function setEventAttributeValue(target, type, callback) {
|
|
24338
|
-
if (callback != null && typeof callback !== "function") {
|
|
24339
|
-
InvalidAttributeHandler.warn(callback);
|
|
24340
|
-
}
|
|
24341
|
-
if (typeof callback === "function" || typeof callback === "object" && callback !== null) {
|
|
24342
|
-
upsertEventAttributeListener(target, type, callback);
|
|
24343
|
-
} else {
|
|
24344
|
-
removeEventAttributeListener(target, type);
|
|
24345
|
-
}
|
|
24346
|
-
}
|
|
24347
|
-
function upsertEventAttributeListener(target, type, callback) {
|
|
24348
|
-
const list = ensureListenerList($$2(target, "target"), String(type));
|
|
24349
|
-
list.attrCallback = callback;
|
|
24350
|
-
if (list.attrListener == null) {
|
|
24351
|
-
list.attrListener = addListener(list, defineEventAttributeCallback(list), false, false, false, void 0);
|
|
24352
|
-
}
|
|
24353
|
-
}
|
|
24354
|
-
function removeEventAttributeListener(target, type) {
|
|
24355
|
-
const listMap = $$2(target, "target");
|
|
24356
|
-
const list = listMap[String(type)];
|
|
24357
|
-
if (list && list.attrListener) {
|
|
24358
|
-
removeListener(list, list.attrListener.callback, false);
|
|
24359
|
-
list.attrCallback = list.attrListener = void 0;
|
|
24360
|
-
}
|
|
24361
|
-
}
|
|
24362
|
-
function defineEventAttributeCallback(list) {
|
|
24363
|
-
return function(event) {
|
|
24364
|
-
const callback = list.attrCallback;
|
|
24365
|
-
if (typeof callback === "function") {
|
|
24366
|
-
callback.call(this, event);
|
|
24367
|
-
}
|
|
24368
|
-
};
|
|
24369
|
-
}
|
|
24370
|
-
|
|
24371
|
-
// src/Util/arrayToMap.js
|
|
24372
|
-
function arrayToMap_default(array, extras) {
|
|
24373
|
-
const map = {
|
|
24374
|
-
...[].reduce.call(
|
|
24375
|
-
array,
|
|
24376
|
-
(map2, value, index) => {
|
|
24377
|
-
map2[index] = value;
|
|
24378
|
-
return map2;
|
|
24379
|
-
},
|
|
24380
|
-
{}
|
|
24381
|
-
),
|
|
24382
|
-
...extras,
|
|
24383
|
-
length: array.length,
|
|
24384
|
-
[Symbol.iterator]: () => [].slice.call(map)[Symbol.iterator]()
|
|
24385
|
-
};
|
|
24386
|
-
return map;
|
|
24387
|
-
}
|
|
24388
|
-
|
|
24389
|
-
// src/SpeechServices/SpeechSDK.js
|
|
24390
|
-
var import_microsoft_cognitiveservices_speech = __toESM(require_microsoft_cognitiveservices_speech_sdk());
|
|
24391
|
-
var SpeechSDK_default = {
|
|
24392
|
-
AudioConfig: import_microsoft_cognitiveservices_speech.AudioConfig,
|
|
24393
|
-
OutputFormat: import_microsoft_cognitiveservices_speech.OutputFormat,
|
|
24394
|
-
ResultReason: import_microsoft_cognitiveservices_speech.ResultReason,
|
|
24395
|
-
SpeechConfig: import_microsoft_cognitiveservices_speech.SpeechConfig,
|
|
24396
|
-
SpeechRecognizer: import_microsoft_cognitiveservices_speech.SpeechRecognizer
|
|
24397
|
-
};
|
|
24398
|
-
|
|
24399
|
-
// src/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js
|
|
24400
|
-
var {
|
|
24401
|
-
ResultReason: { RecognizingSpeech, RecognizedSpeech }
|
|
24402
|
-
} = SpeechSDK_default;
|
|
24403
|
-
function cognitiveServiceEventResultToWebSpeechRecognitionResultList_default(result, { maxAlternatives = Infinity, textNormalization = "display" } = {}) {
|
|
24404
|
-
if (result.reason === RecognizingSpeech || result.reason === RecognizedSpeech && !result.json.NBest) {
|
|
24405
|
-
const resultList = [
|
|
24406
|
-
{
|
|
24407
|
-
confidence: 0.5,
|
|
24408
|
-
transcript: result.text
|
|
24409
|
-
}
|
|
24410
|
-
];
|
|
24411
|
-
if (result.reason === RecognizedSpeech) {
|
|
24412
|
-
resultList.isFinal = true;
|
|
24413
|
-
}
|
|
24414
|
-
return resultList;
|
|
24415
|
-
} else if (result.reason === RecognizedSpeech) {
|
|
24416
|
-
const resultList = arrayToMap_default(
|
|
24417
|
-
(result.json.NBest || []).slice(0, maxAlternatives).map(({ Confidence: confidence, Display: display, ITN: itn, Lexical: lexical, MaskedITN: maskedITN }) => ({
|
|
24418
|
-
confidence,
|
|
24419
|
-
transcript: textNormalization === "itn" ? itn : textNormalization === "lexical" ? lexical : textNormalization === "maskeditn" ? maskedITN : display
|
|
24420
|
-
})),
|
|
24421
|
-
{ isFinal: true }
|
|
24422
|
-
);
|
|
24423
|
-
return resultList;
|
|
24424
|
-
}
|
|
24425
|
-
return [];
|
|
24426
|
-
}
|
|
24427
|
-
|
|
24428
|
-
// ../../node_modules/p-defer/index.js
|
|
24429
|
-
function pDefer() {
|
|
24430
|
-
const deferred = {};
|
|
24431
|
-
deferred.promise = new Promise((resolve, reject) => {
|
|
24432
|
-
deferred.resolve = resolve;
|
|
24433
|
-
deferred.reject = reject;
|
|
24434
|
-
});
|
|
24435
|
-
return deferred;
|
|
24436
|
-
}
|
|
24437
|
-
|
|
24438
|
-
// src/Util/createPromiseQueue.js
|
|
24439
|
-
function createPromiseQueue_default() {
|
|
24440
|
-
let shiftDeferred;
|
|
24441
|
-
const queue = [];
|
|
24442
|
-
const push = (value) => {
|
|
24443
|
-
if (shiftDeferred) {
|
|
24444
|
-
const { resolve } = shiftDeferred;
|
|
24445
|
-
shiftDeferred = null;
|
|
24446
|
-
resolve(value);
|
|
24447
|
-
} else {
|
|
24448
|
-
queue.push(value);
|
|
24449
|
-
}
|
|
24450
|
-
};
|
|
24451
|
-
const shift = () => {
|
|
24452
|
-
if (queue.length) {
|
|
24453
|
-
return Promise.resolve(queue.shift());
|
|
24454
|
-
}
|
|
24455
|
-
return (shiftDeferred || (shiftDeferred = pDefer())).promise;
|
|
24456
|
-
};
|
|
24457
|
-
return {
|
|
24458
|
-
push,
|
|
24459
|
-
shift
|
|
24460
|
-
};
|
|
24461
|
-
}
|
|
24462
|
-
|
|
24463
|
-
// src/SpeechServices/resolveFunctionOrReturnValue.ts
|
|
24464
|
-
function isFunction(value) {
|
|
24465
|
-
return typeof value === "function";
|
|
24466
|
-
}
|
|
24467
|
-
function resolveFunctionOrReturnValue(fnOrValue) {
|
|
24468
|
-
return isFunction(fnOrValue) ? fnOrValue() : fnOrValue;
|
|
24469
|
-
}
|
|
24470
|
-
|
|
24471
|
-
// src/SpeechServices/patchOptions.js
|
|
24472
|
-
var shouldWarnOnSubscriptionKey = true;
|
|
24473
|
-
function patchOptions({
|
|
24474
|
-
authorizationToken,
|
|
24475
|
-
credentials,
|
|
24476
|
-
looseEvent,
|
|
24477
|
-
looseEvents,
|
|
24478
|
-
region = "westus",
|
|
24479
|
-
subscriptionKey,
|
|
24480
|
-
...otherOptions
|
|
24481
|
-
} = {}) {
|
|
24482
|
-
if (typeof looseEvent !== "undefined") {
|
|
24483
|
-
console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".');
|
|
24484
|
-
looseEvents = looseEvent;
|
|
24485
|
-
}
|
|
24486
|
-
if (!credentials) {
|
|
24487
|
-
if (!authorizationToken && !subscriptionKey) {
|
|
24488
|
-
throw new Error("web-speech-cognitive-services: Credentials must be specified.");
|
|
24489
|
-
} else {
|
|
24490
|
-
console.warn(
|
|
24491
|
-
"web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."
|
|
24492
|
-
);
|
|
24493
|
-
credentials = async () => authorizationToken ? { authorizationToken: await resolveFunctionOrReturnValue(authorizationToken), region } : { region, subscriptionKey: await resolveFunctionOrReturnValue(subscriptionKey) };
|
|
24494
|
-
}
|
|
24495
|
-
}
|
|
24496
|
-
return {
|
|
24497
|
-
...otherOptions,
|
|
24498
|
-
fetchCredentials: async () => {
|
|
24499
|
-
const {
|
|
24500
|
-
authorizationToken: authorizationToken2,
|
|
24501
|
-
customVoiceHostname,
|
|
24502
|
-
region: region2,
|
|
24503
|
-
speechRecognitionHostname,
|
|
24504
|
-
speechSynthesisHostname,
|
|
24505
|
-
subscriptionKey: subscriptionKey2
|
|
24506
|
-
} = await resolveFunctionOrReturnValue(credentials);
|
|
24507
|
-
if (!authorizationToken2 && !subscriptionKey2 || authorizationToken2 && subscriptionKey2) {
|
|
24508
|
-
throw new Error(
|
|
24509
|
-
'web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.'
|
|
24510
|
-
);
|
|
24511
|
-
} else if (!region2 && !(speechRecognitionHostname && speechSynthesisHostname)) {
|
|
24512
|
-
throw new Error(
|
|
24513
|
-
'web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.'
|
|
24514
|
-
);
|
|
24515
|
-
} else if (region2 && (customVoiceHostname || speechRecognitionHostname || speechSynthesisHostname)) {
|
|
24516
|
-
throw new Error(
|
|
24517
|
-
'web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.'
|
|
24518
|
-
);
|
|
24519
|
-
} else if (authorizationToken2) {
|
|
24520
|
-
if (typeof authorizationToken2 !== "string") {
|
|
24521
|
-
throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.');
|
|
24522
|
-
}
|
|
24523
|
-
} else if (typeof subscriptionKey2 !== "string") {
|
|
24524
|
-
throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');
|
|
24525
|
-
}
|
|
24526
|
-
if (shouldWarnOnSubscriptionKey && subscriptionKey2) {
|
|
24527
|
-
console.warn(
|
|
24528
|
-
"web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."
|
|
24529
|
-
);
|
|
24530
|
-
shouldWarnOnSubscriptionKey = false;
|
|
24531
|
-
}
|
|
24532
|
-
const resolvedCredentials = authorizationToken2 ? { authorizationToken: authorizationToken2 } : { subscriptionKey: subscriptionKey2 };
|
|
24533
|
-
if (region2) {
|
|
24534
|
-
resolvedCredentials.region = region2;
|
|
24535
|
-
} else {
|
|
24536
|
-
resolvedCredentials.customVoiceHostname = customVoiceHostname;
|
|
24537
|
-
resolvedCredentials.speechRecognitionHostname = speechRecognitionHostname;
|
|
24538
|
-
resolvedCredentials.speechSynthesisHostname = speechSynthesisHostname;
|
|
24539
|
-
}
|
|
24540
|
-
return resolvedCredentials;
|
|
24541
|
-
},
|
|
24542
|
-
looseEvents
|
|
24543
|
-
};
|
|
24544
|
-
}
|
|
24545
|
-
|
|
24546
|
-
// src/SpeechServices/SpeechToText/SpeechGrammarList.js
|
|
24547
|
-
var SpeechGrammarList_default = class {
|
|
24548
|
-
constructor() {
|
|
24549
|
-
this._phrases = [];
|
|
24550
|
-
}
|
|
24551
|
-
addFromString() {
|
|
24552
|
-
throw new Error("JSGF is not supported");
|
|
24553
|
-
}
|
|
24554
|
-
get phrases() {
|
|
24555
|
-
return this._phrases;
|
|
24556
|
-
}
|
|
24557
|
-
set phrases(value) {
|
|
24558
|
-
if (Array.isArray(value)) {
|
|
24559
|
-
this._phrases = value;
|
|
24560
|
-
} else if (typeof value === "string") {
|
|
24561
|
-
this._phrases = [value];
|
|
24562
|
-
} else {
|
|
24563
|
-
throw new Error(`The provided value is not an array or of type 'string'`);
|
|
24564
|
-
}
|
|
24565
|
-
}
|
|
24566
|
-
};
|
|
24567
|
-
|
|
24568
|
-
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js
|
|
24569
|
-
var { AudioConfig: AudioConfig2, OutputFormat: OutputFormat2, ResultReason: ResultReason2, SpeechConfig: SpeechConfig2, SpeechRecognizer: SpeechRecognizer2 } = SpeechSDK_default;
|
|
24570
|
-
function serializeRecognitionResult({ duration, errorDetails, json, offset, properties, reason, resultId, text }) {
|
|
24571
|
-
return {
|
|
24572
|
-
duration,
|
|
24573
|
-
errorDetails,
|
|
24574
|
-
json: JSON.parse(json),
|
|
24575
|
-
offset,
|
|
24576
|
-
properties,
|
|
24577
|
-
reason,
|
|
24578
|
-
resultId,
|
|
24579
|
-
text
|
|
24580
|
-
};
|
|
24581
|
-
}
|
|
24582
|
-
function averageAmplitude(arrayBuffer) {
|
|
24583
|
-
const array = new Int16Array(arrayBuffer);
|
|
24584
|
-
return [].reduce.call(array, (averageAmplitude2, amplitude) => averageAmplitude2 + Math.abs(amplitude), 0) / array.length;
|
|
24585
|
-
}
|
|
24586
|
-
function cognitiveServicesAsyncToPromise(fn) {
|
|
24587
|
-
return (...args) => new Promise((resolve, reject) => fn(...args, resolve, reject));
|
|
24588
|
-
}
|
|
24589
|
-
var SpeechRecognitionEvent = class extends Event {
|
|
24590
|
-
constructor(type, { data, emma, interpretation, resultIndex, results } = {}) {
|
|
24591
|
-
super(type);
|
|
24592
|
-
this.data = data;
|
|
24593
|
-
this.emma = emma;
|
|
24594
|
-
this.interpretation = interpretation;
|
|
24595
|
-
this.resultIndex = resultIndex;
|
|
24596
|
-
this.results = results;
|
|
24597
|
-
}
|
|
24598
|
-
};
|
|
24599
|
-
function prepareAudioConfig(audioConfig) {
|
|
24600
|
-
const originalAttach = audioConfig.attach;
|
|
24601
|
-
const boundOriginalAttach = audioConfig.attach.bind(audioConfig);
|
|
24602
|
-
let firstChunk;
|
|
24603
|
-
let muted;
|
|
24604
|
-
audioConfig.attach = async () => {
|
|
24605
|
-
const reader = await boundOriginalAttach();
|
|
24606
|
-
return {
|
|
24607
|
-
...reader,
|
|
24608
|
-
read: async () => {
|
|
24609
|
-
const chunk = await reader.read();
|
|
24610
|
-
if (!firstChunk && averageAmplitude(chunk.buffer) > 150) {
|
|
24611
|
-
audioConfig.events.onEvent({ name: "FirstAudibleChunk" });
|
|
24612
|
-
firstChunk = true;
|
|
24613
|
-
}
|
|
24614
|
-
if (muted) {
|
|
24615
|
-
return { buffer: new ArrayBuffer(0), isEnd: true, timeReceived: Date.now() };
|
|
24616
|
-
}
|
|
24617
|
-
return chunk;
|
|
24618
|
-
}
|
|
24619
|
-
};
|
|
24620
|
-
};
|
|
24621
|
-
return {
|
|
24622
|
-
audioConfig,
|
|
24623
|
-
pause: () => {
|
|
24624
|
-
muted = true;
|
|
24625
|
-
},
|
|
24626
|
-
unprepare: () => {
|
|
24627
|
-
audioConfig.attach = originalAttach;
|
|
24628
|
-
}
|
|
24629
|
-
};
|
|
24630
|
-
}
|
|
24631
|
-
function createSpeechRecognitionPonyfillFromRecognizer({
|
|
24632
|
-
createRecognizer,
|
|
24633
|
-
enableTelemetry,
|
|
24634
|
-
looseEvents,
|
|
24635
|
-
referenceGrammars,
|
|
24636
|
-
textNormalization
|
|
24637
|
-
}) {
|
|
24638
|
-
SpeechRecognizer2.enableTelemetry(enableTelemetry !== false);
|
|
24639
|
-
class SpeechRecognition extends EventTarget {
|
|
24640
|
-
constructor() {
|
|
24641
|
-
super();
|
|
24642
|
-
this._continuous = false;
|
|
24643
|
-
this._interimResults = false;
|
|
24644
|
-
this._lang = typeof window !== "undefined" ? window.document.documentElement.getAttribute("lang") || window.navigator.language : "en-US";
|
|
24645
|
-
this._grammars = new SpeechGrammarList_default();
|
|
24646
|
-
this._maxAlternatives = 1;
|
|
24647
|
-
}
|
|
24648
|
-
emitCognitiveServices(type, event) {
|
|
24649
|
-
this.dispatchEvent(
|
|
24650
|
-
new SpeechRecognitionEvent("cognitiveservices", {
|
|
24651
|
-
data: {
|
|
24652
|
-
...event,
|
|
24653
|
-
type
|
|
24654
|
-
}
|
|
24655
|
-
})
|
|
24656
|
-
);
|
|
24657
|
-
}
|
|
24658
|
-
get continuous() {
|
|
24659
|
-
return this._continuous;
|
|
24660
|
-
}
|
|
24661
|
-
set continuous(value) {
|
|
24662
|
-
this._continuous = value;
|
|
24663
|
-
}
|
|
24664
|
-
get grammars() {
|
|
24665
|
-
return this._grammars;
|
|
24666
|
-
}
|
|
24667
|
-
set grammars(value) {
|
|
24668
|
-
if (value instanceof SpeechGrammarList_default) {
|
|
24669
|
-
this._grammars = value;
|
|
24670
|
-
} else {
|
|
24671
|
-
throw new Error(`The provided value is not of type 'SpeechGrammarList'`);
|
|
24672
|
-
}
|
|
24673
|
-
}
|
|
24674
|
-
get interimResults() {
|
|
24675
|
-
return this._interimResults;
|
|
24676
|
-
}
|
|
24677
|
-
set interimResults(value) {
|
|
24678
|
-
this._interimResults = value;
|
|
24679
|
-
}
|
|
24680
|
-
get maxAlternatives() {
|
|
24681
|
-
return this._maxAlternatives;
|
|
24682
|
-
}
|
|
24683
|
-
set maxAlternatives(value) {
|
|
24684
|
-
this._maxAlternatives = value;
|
|
24685
|
-
}
|
|
24686
|
-
get lang() {
|
|
24687
|
-
return this._lang;
|
|
24688
|
-
}
|
|
24689
|
-
set lang(value) {
|
|
24690
|
-
this._lang = value;
|
|
24691
|
-
}
|
|
24692
|
-
get onaudioend() {
|
|
24693
|
-
return getEventAttributeValue(this, "audioend");
|
|
24694
|
-
}
|
|
24695
|
-
set onaudioend(value) {
|
|
24696
|
-
setEventAttributeValue(this, "audioend", value);
|
|
24697
|
-
}
|
|
24698
|
-
get onaudiostart() {
|
|
24699
|
-
return getEventAttributeValue(this, "audiostart");
|
|
24700
|
-
}
|
|
24701
|
-
set onaudiostart(value) {
|
|
24702
|
-
setEventAttributeValue(this, "audiostart", value);
|
|
24703
|
-
}
|
|
24704
|
-
get oncognitiveservices() {
|
|
24705
|
-
return getEventAttributeValue(this, "cognitiveservices");
|
|
24706
|
-
}
|
|
24707
|
-
set oncognitiveservices(value) {
|
|
24708
|
-
setEventAttributeValue(this, "cognitiveservices", value);
|
|
24709
|
-
}
|
|
24710
|
-
get onend() {
|
|
24711
|
-
return getEventAttributeValue(this, "end");
|
|
24712
|
-
}
|
|
24713
|
-
set onend(value) {
|
|
24714
|
-
setEventAttributeValue(this, "end", value);
|
|
24715
|
-
}
|
|
24716
|
-
get onerror() {
|
|
24717
|
-
return getEventAttributeValue(this, "error");
|
|
23915
|
+
/** @type { ((event: SpeechRecognitionErrorEvent) => void) | undefined } */
|
|
23916
|
+
get onerror() {
|
|
23917
|
+
return this.#eventListenerMap.getProperty("error");
|
|
24718
23918
|
}
|
|
24719
23919
|
set onerror(value) {
|
|
24720
|
-
|
|
23920
|
+
this.#eventListenerMap.setProperty("error", value);
|
|
24721
23921
|
}
|
|
23922
|
+
/** @type { ((event: SpeechRecognitionEvent<'result'>) => void) | undefined } */
|
|
24722
23923
|
get onresult() {
|
|
24723
|
-
return
|
|
23924
|
+
return this.#eventListenerMap.getProperty("result");
|
|
24724
23925
|
}
|
|
24725
23926
|
set onresult(value) {
|
|
24726
|
-
|
|
23927
|
+
this.#eventListenerMap.setProperty("result", value);
|
|
24727
23928
|
}
|
|
23929
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundend'>) => void) | undefined } */
|
|
24728
23930
|
get onsoundend() {
|
|
24729
|
-
return
|
|
23931
|
+
return this.#eventListenerMap.getProperty("soundend");
|
|
24730
23932
|
}
|
|
24731
23933
|
set onsoundend(value) {
|
|
24732
|
-
|
|
23934
|
+
this.#eventListenerMap.setProperty("soundend", value);
|
|
24733
23935
|
}
|
|
23936
|
+
/** @type { ((event: SpeechRecognitionEvent<'soundstart'>) => void) | undefined } */
|
|
24734
23937
|
get onsoundstart() {
|
|
24735
|
-
return
|
|
23938
|
+
return this.#eventListenerMap.getProperty("soundstart");
|
|
24736
23939
|
}
|
|
24737
23940
|
set onsoundstart(value) {
|
|
24738
|
-
|
|
23941
|
+
this.#eventListenerMap.setProperty("soundstart", value);
|
|
24739
23942
|
}
|
|
23943
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechend'>) => void) | undefined } */
|
|
24740
23944
|
get onspeechend() {
|
|
24741
|
-
return
|
|
23945
|
+
return this.#eventListenerMap.getProperty("speechend");
|
|
24742
23946
|
}
|
|
24743
23947
|
set onspeechend(value) {
|
|
24744
|
-
|
|
23948
|
+
this.#eventListenerMap.setProperty("speechend", value);
|
|
24745
23949
|
}
|
|
23950
|
+
/** @type { ((event: SpeechRecognitionEvent<'speechstart'>) => void) | undefined } */
|
|
24746
23951
|
get onspeechstart() {
|
|
24747
|
-
return
|
|
23952
|
+
return this.#eventListenerMap.getProperty("speechstart");
|
|
24748
23953
|
}
|
|
24749
23954
|
set onspeechstart(value) {
|
|
24750
|
-
|
|
23955
|
+
this.#eventListenerMap.setProperty("speechstart", value);
|
|
24751
23956
|
}
|
|
23957
|
+
/** @type { ((event: SpeechRecognitionEvent<'start'>) => void) | undefined } */
|
|
24752
23958
|
get onstart() {
|
|
24753
|
-
return
|
|
23959
|
+
return this.#eventListenerMap.getProperty("start");
|
|
24754
23960
|
}
|
|
24755
23961
|
set onstart(value) {
|
|
24756
|
-
|
|
23962
|
+
this.#eventListenerMap.setProperty("start", value);
|
|
24757
23963
|
}
|
|
23964
|
+
abort;
|
|
23965
|
+
stop;
|
|
24758
23966
|
start() {
|
|
24759
23967
|
this._startOnce().catch((err) => {
|
|
24760
|
-
this.dispatchEvent(
|
|
23968
|
+
this.dispatchEvent(
|
|
23969
|
+
new SpeechRecognitionErrorEvent("error", { error: err, message: err && (err.stack || err.message) })
|
|
23970
|
+
);
|
|
24761
23971
|
});
|
|
24762
23972
|
}
|
|
24763
23973
|
async _startOnce() {
|
|
24764
23974
|
const recognizer = await createRecognizer(this.lang);
|
|
24765
|
-
const { pause, unprepare } = prepareAudioConfig(recognizer
|
|
23975
|
+
const { pause, unprepare } = prepareAudioConfig(recognizer["audioConfig"]);
|
|
24766
23976
|
try {
|
|
24767
23977
|
const queue = createPromiseQueue_default();
|
|
24768
23978
|
let soundStarted;
|
|
24769
23979
|
let speechStarted;
|
|
24770
23980
|
let stopping;
|
|
24771
|
-
const { detach: detachAudioConfigEvent } = recognizer
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
23981
|
+
const { detach: detachAudioConfigEvent } = recognizer["audioConfig"].events.attach(
|
|
23982
|
+
(event) => {
|
|
23983
|
+
const { name } = event;
|
|
23984
|
+
if (name === "AudioSourceReadyEvent") {
|
|
23985
|
+
queue.push({ audioSourceReady: {} });
|
|
23986
|
+
} else if (name === "AudioSourceOffEvent") {
|
|
23987
|
+
queue.push({ audioSourceOff: {} });
|
|
23988
|
+
} else if (name === "FirstAudibleChunk") {
|
|
23989
|
+
queue.push({ firstAudibleChunk: {} });
|
|
23990
|
+
}
|
|
24779
23991
|
}
|
|
24780
|
-
|
|
23992
|
+
);
|
|
24781
23993
|
recognizer.canceled = (_, { errorDetails, offset, reason, sessionId }) => {
|
|
24782
23994
|
queue.push({
|
|
24783
23995
|
canceled: {
|
|
@@ -24819,18 +24031,18 @@
|
|
|
24819
24031
|
queue.push({ speechEndDetected: { sessionId } });
|
|
24820
24032
|
};
|
|
24821
24033
|
const { phrases } = this.grammars;
|
|
24822
|
-
const { dynamicGrammar } = recognizer
|
|
24823
|
-
referenceGrammars && referenceGrammars.length && dynamicGrammar.addReferenceGrammar(referenceGrammars);
|
|
24824
|
-
phrases && phrases.length && dynamicGrammar.addPhrase(phrases);
|
|
24825
|
-
await cognitiveServicesAsyncToPromise(recognizer.startContinuousRecognitionAsync
|
|
24826
|
-
if (recognizer.stopContinuousRecognitionAsync) {
|
|
24034
|
+
const { dynamicGrammar } = recognizer["privReco"];
|
|
24035
|
+
referenceGrammars && referenceGrammars.length && dynamicGrammar.addReferenceGrammar([...referenceGrammars]);
|
|
24036
|
+
phrases && phrases.length && dynamicGrammar.addPhrase([...phrases]);
|
|
24037
|
+
await cognitiveServicesAsyncToPromise(recognizer.startContinuousRecognitionAsync, recognizer)();
|
|
24038
|
+
if (typeof recognizer.stopContinuousRecognitionAsync === "function") {
|
|
24827
24039
|
this.abort = () => queue.push({ abort: {} });
|
|
24828
24040
|
this.stop = () => queue.push({ stop: {} });
|
|
24829
24041
|
} else {
|
|
24830
24042
|
this.abort = this.stop = void 0;
|
|
24831
24043
|
}
|
|
24832
24044
|
let audioStarted;
|
|
24833
|
-
let finalEvent;
|
|
24045
|
+
let finalEvent = void 0;
|
|
24834
24046
|
let finalizedResults = [];
|
|
24835
24047
|
for (let loop = 0; !stopping || audioStarted; loop++) {
|
|
24836
24048
|
const event = await queue.shift();
|
|
@@ -24847,10 +24059,7 @@
|
|
|
24847
24059
|
Object.keys(event).forEach((name) => this.emitCognitiveServices(name, event[name]));
|
|
24848
24060
|
const errorMessage = canceled && canceled.errorDetails;
|
|
24849
24061
|
if (/Permission\sdenied/u.test(errorMessage || "")) {
|
|
24850
|
-
finalEvent = {
|
|
24851
|
-
error: "not-allowed",
|
|
24852
|
-
type: "error"
|
|
24853
|
-
};
|
|
24062
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "not-allowed" });
|
|
24854
24063
|
break;
|
|
24855
24064
|
}
|
|
24856
24065
|
if (!loop) {
|
|
@@ -24862,30 +24071,21 @@
|
|
|
24862
24071
|
this.dispatchEvent(new SpeechRecognitionEvent("audiostart"));
|
|
24863
24072
|
this.dispatchEvent(new SpeechRecognitionEvent("audioend"));
|
|
24864
24073
|
}
|
|
24865
|
-
finalEvent = {
|
|
24866
|
-
error: "network",
|
|
24867
|
-
type: "error"
|
|
24868
|
-
};
|
|
24074
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "network" });
|
|
24869
24075
|
} else {
|
|
24870
|
-
finalEvent = {
|
|
24871
|
-
error: "unknown",
|
|
24872
|
-
type: "error"
|
|
24873
|
-
};
|
|
24076
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "unknown" });
|
|
24874
24077
|
}
|
|
24875
24078
|
break;
|
|
24876
24079
|
} else if (abort || stop) {
|
|
24877
24080
|
if (abort) {
|
|
24878
|
-
finalEvent = {
|
|
24879
|
-
error: "aborted",
|
|
24880
|
-
type: "error"
|
|
24881
|
-
};
|
|
24081
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "aborted" });
|
|
24882
24082
|
stopping = "abort";
|
|
24883
24083
|
} else {
|
|
24884
24084
|
pause();
|
|
24885
24085
|
stopping = "stop";
|
|
24886
24086
|
}
|
|
24887
24087
|
if (abort && recognizer.stopContinuousRecognitionAsync) {
|
|
24888
|
-
await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync
|
|
24088
|
+
await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync, recognizer)();
|
|
24889
24089
|
}
|
|
24890
24090
|
} else if (audioSourceReady) {
|
|
24891
24091
|
this.dispatchEvent(new SpeechRecognitionEvent("audiostart"));
|
|
@@ -24901,10 +24101,16 @@
|
|
|
24901
24101
|
break;
|
|
24902
24102
|
} else if (stopping !== "abort") {
|
|
24903
24103
|
if (recognized && recognized.result && recognized.result.reason === ResultReason2.NoMatch) {
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
|
|
24104
|
+
if (!this.continuous || stopping === "stop") {
|
|
24105
|
+
finalEvent = new SpeechRecognitionEvent("result", {
|
|
24106
|
+
results: new SpeechRecognitionResultList(finalizedResults)
|
|
24107
|
+
});
|
|
24108
|
+
recognizer.stopContinuousRecognitionAsync && await cognitiveServicesAsyncToPromise(
|
|
24109
|
+
recognizer.stopContinuousRecognitionAsync,
|
|
24110
|
+
recognizer
|
|
24111
|
+
)();
|
|
24112
|
+
break;
|
|
24113
|
+
}
|
|
24908
24114
|
} else if (recognized || recognizing) {
|
|
24909
24115
|
if (!audioStarted) {
|
|
24910
24116
|
this.dispatchEvent(new SpeechRecognitionEvent("audiostart"));
|
|
@@ -24919,44 +24125,43 @@
|
|
|
24919
24125
|
speechStarted = true;
|
|
24920
24126
|
}
|
|
24921
24127
|
if (recognized) {
|
|
24922
|
-
const result =
|
|
24128
|
+
const result = cognitiveServiceEventResultToWebSpeechRecognitionResult_default(recognized.result, {
|
|
24923
24129
|
maxAlternatives: this.maxAlternatives,
|
|
24924
24130
|
textNormalization
|
|
24925
24131
|
});
|
|
24926
|
-
const recognizable = !!result[0]
|
|
24132
|
+
const recognizable = !!result[0]?.transcript;
|
|
24927
24133
|
if (recognizable) {
|
|
24928
24134
|
finalizedResults = [...finalizedResults, result];
|
|
24929
24135
|
this.continuous && this.dispatchEvent(
|
|
24930
24136
|
new SpeechRecognitionEvent("result", {
|
|
24931
|
-
results: finalizedResults
|
|
24137
|
+
results: new SpeechRecognitionResultList(finalizedResults)
|
|
24932
24138
|
})
|
|
24933
24139
|
);
|
|
24934
24140
|
}
|
|
24935
24141
|
if (this.continuous && recognizable) {
|
|
24936
|
-
finalEvent =
|
|
24142
|
+
finalEvent = void 0;
|
|
24937
24143
|
} else {
|
|
24938
|
-
finalEvent = {
|
|
24939
|
-
results: finalizedResults
|
|
24940
|
-
|
|
24941
|
-
};
|
|
24144
|
+
finalEvent = new SpeechRecognitionEvent("result", {
|
|
24145
|
+
results: new SpeechRecognitionResultList(finalizedResults)
|
|
24146
|
+
});
|
|
24942
24147
|
}
|
|
24943
|
-
if (!this.continuous && recognizer.stopContinuousRecognitionAsync) {
|
|
24944
|
-
await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync
|
|
24148
|
+
if ((!this.continuous || stopping === "stop") && recognizer.stopContinuousRecognitionAsync) {
|
|
24149
|
+
await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync, recognizer)();
|
|
24945
24150
|
}
|
|
24946
24151
|
if (looseEvents && finalEvent && recognizable) {
|
|
24947
|
-
this.dispatchEvent(
|
|
24948
|
-
finalEvent =
|
|
24152
|
+
this.dispatchEvent(finalEvent);
|
|
24153
|
+
finalEvent = void 0;
|
|
24949
24154
|
}
|
|
24950
24155
|
} else if (recognizing) {
|
|
24951
24156
|
this.interimResults && this.dispatchEvent(
|
|
24952
24157
|
new SpeechRecognitionEvent("result", {
|
|
24953
|
-
results: [
|
|
24158
|
+
results: new SpeechRecognitionResultList([
|
|
24954
24159
|
...finalizedResults,
|
|
24955
|
-
|
|
24160
|
+
cognitiveServiceEventResultToWebSpeechRecognitionResult_default(recognizing.result, {
|
|
24956
24161
|
maxAlternatives: this.maxAlternatives,
|
|
24957
24162
|
textNormalization
|
|
24958
24163
|
})
|
|
24959
|
-
]
|
|
24164
|
+
])
|
|
24960
24165
|
})
|
|
24961
24166
|
);
|
|
24962
24167
|
}
|
|
@@ -24969,90 +24174,916 @@
|
|
|
24969
24174
|
if (soundStarted) {
|
|
24970
24175
|
this.dispatchEvent(new SpeechRecognitionEvent("soundend"));
|
|
24971
24176
|
}
|
|
24972
|
-
if (audioStarted) {
|
|
24973
|
-
this.dispatchEvent(new SpeechRecognitionEvent("audioend"));
|
|
24177
|
+
if (audioStarted) {
|
|
24178
|
+
this.dispatchEvent(new SpeechRecognitionEvent("audioend"));
|
|
24179
|
+
}
|
|
24180
|
+
if (finalEvent) {
|
|
24181
|
+
if (finalEvent.type === "result" && !finalEvent.results.length) {
|
|
24182
|
+
finalEvent = new SpeechRecognitionErrorEvent("error", { error: "no-speech" });
|
|
24183
|
+
}
|
|
24184
|
+
this.dispatchEvent(finalEvent);
|
|
24185
|
+
}
|
|
24186
|
+
this.dispatchEvent(new SpeechRecognitionEvent("end"));
|
|
24187
|
+
detachAudioConfigEvent();
|
|
24188
|
+
} catch (err) {
|
|
24189
|
+
console.error(err);
|
|
24190
|
+
throw err;
|
|
24191
|
+
} finally {
|
|
24192
|
+
unprepare();
|
|
24193
|
+
recognizer["dispose"](false);
|
|
24194
|
+
}
|
|
24195
|
+
}
|
|
24196
|
+
}
|
|
24197
|
+
return {
|
|
24198
|
+
SpeechGrammarList,
|
|
24199
|
+
SpeechRecognition,
|
|
24200
|
+
SpeechRecognitionEvent
|
|
24201
|
+
};
|
|
24202
|
+
}
|
|
24203
|
+
|
|
24204
|
+
// src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.ts
|
|
24205
|
+
var { AudioConfig: AudioConfig2, OutputFormat: OutputFormat2, SpeechConfig: SpeechConfig2, SpeechRecognizer: SpeechRecognizer3 } = SpeechSDK_default;
|
|
24206
|
+
function createSpeechRecognitionPonyfill(options) {
|
|
24207
|
+
const {
|
|
24208
|
+
audioConfig = AudioConfig2.fromDefaultMicrophoneInput(),
|
|
24209
|
+
// We set telemetry to true to honor the default telemetry settings of Speech SDK
|
|
24210
|
+
// https://github.com/Microsoft/cognitive-services-speech-sdk-js#data--telemetry
|
|
24211
|
+
enableTelemetry = true,
|
|
24212
|
+
fetchCredentials,
|
|
24213
|
+
looseEvents,
|
|
24214
|
+
referenceGrammars,
|
|
24215
|
+
speechRecognitionEndpointId,
|
|
24216
|
+
textNormalization = "display"
|
|
24217
|
+
} = patchOptions(options);
|
|
24218
|
+
if (!audioConfig && (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia)) {
|
|
24219
|
+
console.warn(
|
|
24220
|
+
"web-speech-cognitive-services: This browser does not support WebRTC and it will not work with Cognitive Services Speech Services."
|
|
24221
|
+
);
|
|
24222
|
+
return {};
|
|
24223
|
+
}
|
|
24224
|
+
const createRecognizer = async (lang) => {
|
|
24225
|
+
const credentials = await fetchCredentials();
|
|
24226
|
+
let speechConfig;
|
|
24227
|
+
if (typeof credentials.speechRecognitionHostname !== "undefined") {
|
|
24228
|
+
const host = new URL("wss://hostname:443");
|
|
24229
|
+
host.hostname = credentials.speechRecognitionHostname;
|
|
24230
|
+
if (credentials.authorizationToken) {
|
|
24231
|
+
speechConfig = SpeechConfig2.fromHost(host);
|
|
24232
|
+
speechConfig.authorizationToken = credentials.authorizationToken;
|
|
24233
|
+
} else {
|
|
24234
|
+
speechConfig = SpeechConfig2.fromHost(host, credentials.subscriptionKey);
|
|
24235
|
+
}
|
|
24236
|
+
} else {
|
|
24237
|
+
speechConfig = typeof credentials.authorizationToken !== "undefined" ? SpeechConfig2.fromAuthorizationToken(credentials.authorizationToken, credentials.region) : SpeechConfig2.fromSubscription(credentials.subscriptionKey, credentials.region);
|
|
24238
|
+
}
|
|
24239
|
+
if (speechRecognitionEndpointId) {
|
|
24240
|
+
speechConfig.endpointId = speechRecognitionEndpointId;
|
|
24241
|
+
}
|
|
24242
|
+
speechConfig.outputFormat = OutputFormat2.Detailed;
|
|
24243
|
+
speechConfig.speechRecognitionLanguage = lang || "en-US";
|
|
24244
|
+
return new SpeechRecognizer3(speechConfig, audioConfig);
|
|
24245
|
+
};
|
|
24246
|
+
return createSpeechRecognitionPonyfillFromRecognizer({
|
|
24247
|
+
createRecognizer,
|
|
24248
|
+
enableTelemetry,
|
|
24249
|
+
looseEvents,
|
|
24250
|
+
referenceGrammars,
|
|
24251
|
+
textNormalization
|
|
24252
|
+
});
|
|
24253
|
+
}
|
|
24254
|
+
|
|
24255
|
+
// src/SpeechServices/SpeechToText.ts
|
|
24256
|
+
var SpeechToText_default = createSpeechRecognitionPonyfill;
|
|
24257
|
+
|
|
24258
|
+
// ../../node_modules/event-target-shim/index.mjs
|
|
24259
|
+
function assertType(condition, message, ...args) {
|
|
24260
|
+
if (!condition) {
|
|
24261
|
+
throw new TypeError(format(message, args));
|
|
24262
|
+
}
|
|
24263
|
+
}
|
|
24264
|
+
function format(message, args) {
|
|
24265
|
+
let i = 0;
|
|
24266
|
+
return message.replace(/%[os]/gu, () => anyToString(args[i++]));
|
|
24267
|
+
}
|
|
24268
|
+
function anyToString(x) {
|
|
24269
|
+
if (typeof x !== "object" || x === null) {
|
|
24270
|
+
return String(x);
|
|
24271
|
+
}
|
|
24272
|
+
return Object.prototype.toString.call(x);
|
|
24273
|
+
}
|
|
24274
|
+
var currentErrorHandler;
|
|
24275
|
+
function reportError(maybeError) {
|
|
24276
|
+
try {
|
|
24277
|
+
const error = maybeError instanceof Error ? maybeError : new Error(anyToString(maybeError));
|
|
24278
|
+
if (currentErrorHandler) {
|
|
24279
|
+
currentErrorHandler(error);
|
|
24280
|
+
return;
|
|
24281
|
+
}
|
|
24282
|
+
if (typeof dispatchEvent === "function" && typeof ErrorEvent === "function") {
|
|
24283
|
+
dispatchEvent(new ErrorEvent("error", { error, message: error.message }));
|
|
24284
|
+
} else if (typeof process !== "undefined" && typeof process.emit === "function") {
|
|
24285
|
+
process.emit("uncaughtException", error);
|
|
24286
|
+
return;
|
|
24287
|
+
}
|
|
24288
|
+
console.error(error);
|
|
24289
|
+
} catch (_a) {
|
|
24290
|
+
}
|
|
24291
|
+
}
|
|
24292
|
+
var Global = typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
24293
|
+
var currentWarnHandler;
|
|
24294
|
+
var Warning = class {
|
|
24295
|
+
constructor(code, message) {
|
|
24296
|
+
this.code = code;
|
|
24297
|
+
this.message = message;
|
|
24298
|
+
}
|
|
24299
|
+
/**
|
|
24300
|
+
* Report this warning.
|
|
24301
|
+
* @param args The arguments of the warning.
|
|
24302
|
+
*/
|
|
24303
|
+
warn(...args) {
|
|
24304
|
+
var _a;
|
|
24305
|
+
try {
|
|
24306
|
+
if (currentWarnHandler) {
|
|
24307
|
+
currentWarnHandler({ ...this, args });
|
|
24308
|
+
return;
|
|
24309
|
+
}
|
|
24310
|
+
const stack = ((_a = new Error().stack) !== null && _a !== void 0 ? _a : "").replace(/^(?:.+?\n){2}/gu, "\n");
|
|
24311
|
+
console.warn(this.message, ...args, stack);
|
|
24312
|
+
} catch (_b) {
|
|
24313
|
+
}
|
|
24314
|
+
}
|
|
24315
|
+
};
|
|
24316
|
+
var InitEventWasCalledWhileDispatching = new Warning("W01", "Unable to initialize event under dispatching.");
|
|
24317
|
+
var FalsyWasAssignedToCancelBubble = new Warning("W02", "Assigning any falsy value to 'cancelBubble' property has no effect.");
|
|
24318
|
+
var TruthyWasAssignedToReturnValue = new Warning("W03", "Assigning any truthy value to 'returnValue' property has no effect.");
|
|
24319
|
+
var NonCancelableEventWasCanceled = new Warning("W04", "Unable to preventDefault on non-cancelable events.");
|
|
24320
|
+
var CanceledInPassiveListener = new Warning("W05", "Unable to preventDefault inside passive event listener invocation.");
|
|
24321
|
+
var EventListenerWasDuplicated = new Warning("W06", "An event listener wasn't added because it has been added already: %o, %o");
|
|
24322
|
+
var OptionWasIgnored = new Warning("W07", "The %o option value was abandoned because the event listener wasn't added as duplicated.");
|
|
24323
|
+
var InvalidEventListener = new Warning("W08", "The 'callback' argument must be a function or an object that has 'handleEvent' method: %o");
|
|
24324
|
+
var InvalidAttributeHandler = new Warning("W09", "Event attribute handler must be a function: %o");
|
|
24325
|
+
var Event2 = class {
|
|
24326
|
+
/**
|
|
24327
|
+
* @see https://dom.spec.whatwg.org/#dom-event-none
|
|
24328
|
+
*/
|
|
24329
|
+
static get NONE() {
|
|
24330
|
+
return NONE;
|
|
24331
|
+
}
|
|
24332
|
+
/**
|
|
24333
|
+
* @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
|
|
24334
|
+
*/
|
|
24335
|
+
static get CAPTURING_PHASE() {
|
|
24336
|
+
return CAPTURING_PHASE;
|
|
24337
|
+
}
|
|
24338
|
+
/**
|
|
24339
|
+
* @see https://dom.spec.whatwg.org/#dom-event-at_target
|
|
24340
|
+
*/
|
|
24341
|
+
static get AT_TARGET() {
|
|
24342
|
+
return AT_TARGET;
|
|
24343
|
+
}
|
|
24344
|
+
/**
|
|
24345
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
|
|
24346
|
+
*/
|
|
24347
|
+
static get BUBBLING_PHASE() {
|
|
24348
|
+
return BUBBLING_PHASE;
|
|
24349
|
+
}
|
|
24350
|
+
/**
|
|
24351
|
+
* Initialize this event instance.
|
|
24352
|
+
* @param type The type of this event.
|
|
24353
|
+
* @param eventInitDict Options to initialize.
|
|
24354
|
+
* @see https://dom.spec.whatwg.org/#dom-event-event
|
|
24355
|
+
*/
|
|
24356
|
+
constructor(type, eventInitDict) {
|
|
24357
|
+
Object.defineProperty(this, "isTrusted", {
|
|
24358
|
+
value: false,
|
|
24359
|
+
enumerable: true
|
|
24360
|
+
});
|
|
24361
|
+
const opts = eventInitDict !== null && eventInitDict !== void 0 ? eventInitDict : {};
|
|
24362
|
+
internalDataMap.set(this, {
|
|
24363
|
+
type: String(type),
|
|
24364
|
+
bubbles: Boolean(opts.bubbles),
|
|
24365
|
+
cancelable: Boolean(opts.cancelable),
|
|
24366
|
+
composed: Boolean(opts.composed),
|
|
24367
|
+
target: null,
|
|
24368
|
+
currentTarget: null,
|
|
24369
|
+
stopPropagationFlag: false,
|
|
24370
|
+
stopImmediatePropagationFlag: false,
|
|
24371
|
+
canceledFlag: false,
|
|
24372
|
+
inPassiveListenerFlag: false,
|
|
24373
|
+
dispatchFlag: false,
|
|
24374
|
+
timeStamp: Date.now()
|
|
24375
|
+
});
|
|
24376
|
+
}
|
|
24377
|
+
/**
|
|
24378
|
+
* The type of this event.
|
|
24379
|
+
* @see https://dom.spec.whatwg.org/#dom-event-type
|
|
24380
|
+
*/
|
|
24381
|
+
get type() {
|
|
24382
|
+
return $(this).type;
|
|
24383
|
+
}
|
|
24384
|
+
/**
|
|
24385
|
+
* The event target of the current dispatching.
|
|
24386
|
+
* @see https://dom.spec.whatwg.org/#dom-event-target
|
|
24387
|
+
*/
|
|
24388
|
+
get target() {
|
|
24389
|
+
return $(this).target;
|
|
24390
|
+
}
|
|
24391
|
+
/**
|
|
24392
|
+
* The event target of the current dispatching.
|
|
24393
|
+
* @deprecated Use the `target` property instead.
|
|
24394
|
+
* @see https://dom.spec.whatwg.org/#dom-event-srcelement
|
|
24395
|
+
*/
|
|
24396
|
+
get srcElement() {
|
|
24397
|
+
return $(this).target;
|
|
24398
|
+
}
|
|
24399
|
+
/**
|
|
24400
|
+
* The event target of the current dispatching.
|
|
24401
|
+
* @see https://dom.spec.whatwg.org/#dom-event-currenttarget
|
|
24402
|
+
*/
|
|
24403
|
+
get currentTarget() {
|
|
24404
|
+
return $(this).currentTarget;
|
|
24405
|
+
}
|
|
24406
|
+
/**
|
|
24407
|
+
* The event target of the current dispatching.
|
|
24408
|
+
* This doesn't support node tree.
|
|
24409
|
+
* @see https://dom.spec.whatwg.org/#dom-event-composedpath
|
|
24410
|
+
*/
|
|
24411
|
+
composedPath() {
|
|
24412
|
+
const currentTarget = $(this).currentTarget;
|
|
24413
|
+
if (currentTarget) {
|
|
24414
|
+
return [currentTarget];
|
|
24415
|
+
}
|
|
24416
|
+
return [];
|
|
24417
|
+
}
|
|
24418
|
+
/**
|
|
24419
|
+
* @see https://dom.spec.whatwg.org/#dom-event-none
|
|
24420
|
+
*/
|
|
24421
|
+
get NONE() {
|
|
24422
|
+
return NONE;
|
|
24423
|
+
}
|
|
24424
|
+
/**
|
|
24425
|
+
* @see https://dom.spec.whatwg.org/#dom-event-capturing_phase
|
|
24426
|
+
*/
|
|
24427
|
+
get CAPTURING_PHASE() {
|
|
24428
|
+
return CAPTURING_PHASE;
|
|
24429
|
+
}
|
|
24430
|
+
/**
|
|
24431
|
+
* @see https://dom.spec.whatwg.org/#dom-event-at_target
|
|
24432
|
+
*/
|
|
24433
|
+
get AT_TARGET() {
|
|
24434
|
+
return AT_TARGET;
|
|
24435
|
+
}
|
|
24436
|
+
/**
|
|
24437
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase
|
|
24438
|
+
*/
|
|
24439
|
+
get BUBBLING_PHASE() {
|
|
24440
|
+
return BUBBLING_PHASE;
|
|
24441
|
+
}
|
|
24442
|
+
/**
|
|
24443
|
+
* The current event phase.
|
|
24444
|
+
* @see https://dom.spec.whatwg.org/#dom-event-eventphase
|
|
24445
|
+
*/
|
|
24446
|
+
get eventPhase() {
|
|
24447
|
+
return $(this).dispatchFlag ? 2 : 0;
|
|
24448
|
+
}
|
|
24449
|
+
/**
|
|
24450
|
+
* Stop event bubbling.
|
|
24451
|
+
* Because this shim doesn't support node tree, this merely changes the `cancelBubble` property value.
|
|
24452
|
+
* @see https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
|
24453
|
+
*/
|
|
24454
|
+
stopPropagation() {
|
|
24455
|
+
$(this).stopPropagationFlag = true;
|
|
24456
|
+
}
|
|
24457
|
+
/**
|
|
24458
|
+
* `true` if event bubbling was stopped.
|
|
24459
|
+
* @deprecated
|
|
24460
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
|
|
24461
|
+
*/
|
|
24462
|
+
get cancelBubble() {
|
|
24463
|
+
return $(this).stopPropagationFlag;
|
|
24464
|
+
}
|
|
24465
|
+
/**
|
|
24466
|
+
* Stop event bubbling if `true` is set.
|
|
24467
|
+
* @deprecated Use the `stopPropagation()` method instead.
|
|
24468
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelbubble
|
|
24469
|
+
*/
|
|
24470
|
+
set cancelBubble(value) {
|
|
24471
|
+
if (value) {
|
|
24472
|
+
$(this).stopPropagationFlag = true;
|
|
24473
|
+
} else {
|
|
24474
|
+
FalsyWasAssignedToCancelBubble.warn();
|
|
24475
|
+
}
|
|
24476
|
+
}
|
|
24477
|
+
/**
|
|
24478
|
+
* Stop event bubbling and subsequent event listener callings.
|
|
24479
|
+
* @see https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
|
24480
|
+
*/
|
|
24481
|
+
stopImmediatePropagation() {
|
|
24482
|
+
const data = $(this);
|
|
24483
|
+
data.stopPropagationFlag = data.stopImmediatePropagationFlag = true;
|
|
24484
|
+
}
|
|
24485
|
+
/**
|
|
24486
|
+
* `true` if this event will bubble.
|
|
24487
|
+
* @see https://dom.spec.whatwg.org/#dom-event-bubbles
|
|
24488
|
+
*/
|
|
24489
|
+
get bubbles() {
|
|
24490
|
+
return $(this).bubbles;
|
|
24491
|
+
}
|
|
24492
|
+
/**
|
|
24493
|
+
* `true` if this event can be canceled by the `preventDefault()` method.
|
|
24494
|
+
* @see https://dom.spec.whatwg.org/#dom-event-cancelable
|
|
24495
|
+
*/
|
|
24496
|
+
get cancelable() {
|
|
24497
|
+
return $(this).cancelable;
|
|
24498
|
+
}
|
|
24499
|
+
/**
|
|
24500
|
+
* `true` if the default behavior will act.
|
|
24501
|
+
* @deprecated Use the `defaultPrevented` proeprty instead.
|
|
24502
|
+
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
24503
|
+
*/
|
|
24504
|
+
get returnValue() {
|
|
24505
|
+
return !$(this).canceledFlag;
|
|
24506
|
+
}
|
|
24507
|
+
/**
|
|
24508
|
+
* Cancel the default behavior if `false` is set.
|
|
24509
|
+
* @deprecated Use the `preventDefault()` method instead.
|
|
24510
|
+
* @see https://dom.spec.whatwg.org/#dom-event-returnvalue
|
|
24511
|
+
*/
|
|
24512
|
+
set returnValue(value) {
|
|
24513
|
+
if (!value) {
|
|
24514
|
+
setCancelFlag($(this));
|
|
24515
|
+
} else {
|
|
24516
|
+
TruthyWasAssignedToReturnValue.warn();
|
|
24517
|
+
}
|
|
24518
|
+
}
|
|
24519
|
+
/**
|
|
24520
|
+
* Cancel the default behavior.
|
|
24521
|
+
* @see https://dom.spec.whatwg.org/#dom-event-preventdefault
|
|
24522
|
+
*/
|
|
24523
|
+
preventDefault() {
|
|
24524
|
+
setCancelFlag($(this));
|
|
24525
|
+
}
|
|
24526
|
+
/**
|
|
24527
|
+
* `true` if the default behavior was canceled.
|
|
24528
|
+
* @see https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
|
24529
|
+
*/
|
|
24530
|
+
get defaultPrevented() {
|
|
24531
|
+
return $(this).canceledFlag;
|
|
24532
|
+
}
|
|
24533
|
+
/**
|
|
24534
|
+
* @see https://dom.spec.whatwg.org/#dom-event-composed
|
|
24535
|
+
*/
|
|
24536
|
+
get composed() {
|
|
24537
|
+
return $(this).composed;
|
|
24538
|
+
}
|
|
24539
|
+
/**
|
|
24540
|
+
* @see https://dom.spec.whatwg.org/#dom-event-istrusted
|
|
24541
|
+
*/
|
|
24542
|
+
//istanbul ignore next
|
|
24543
|
+
get isTrusted() {
|
|
24544
|
+
return false;
|
|
24545
|
+
}
|
|
24546
|
+
/**
|
|
24547
|
+
* @see https://dom.spec.whatwg.org/#dom-event-timestamp
|
|
24548
|
+
*/
|
|
24549
|
+
get timeStamp() {
|
|
24550
|
+
return $(this).timeStamp;
|
|
24551
|
+
}
|
|
24552
|
+
/**
|
|
24553
|
+
* @deprecated Don't use this method. The constructor did initialization.
|
|
24554
|
+
*/
|
|
24555
|
+
initEvent(type, bubbles = false, cancelable = false) {
|
|
24556
|
+
const data = $(this);
|
|
24557
|
+
if (data.dispatchFlag) {
|
|
24558
|
+
InitEventWasCalledWhileDispatching.warn();
|
|
24559
|
+
return;
|
|
24560
|
+
}
|
|
24561
|
+
internalDataMap.set(this, {
|
|
24562
|
+
...data,
|
|
24563
|
+
type: String(type),
|
|
24564
|
+
bubbles: Boolean(bubbles),
|
|
24565
|
+
cancelable: Boolean(cancelable),
|
|
24566
|
+
target: null,
|
|
24567
|
+
currentTarget: null,
|
|
24568
|
+
stopPropagationFlag: false,
|
|
24569
|
+
stopImmediatePropagationFlag: false,
|
|
24570
|
+
canceledFlag: false
|
|
24571
|
+
});
|
|
24572
|
+
}
|
|
24573
|
+
};
|
|
24574
|
+
var NONE = 0;
|
|
24575
|
+
var CAPTURING_PHASE = 1;
|
|
24576
|
+
var AT_TARGET = 2;
|
|
24577
|
+
var BUBBLING_PHASE = 3;
|
|
24578
|
+
var internalDataMap = /* @__PURE__ */ new WeakMap();
|
|
24579
|
+
function $(event, name = "this") {
|
|
24580
|
+
const retv = internalDataMap.get(event);
|
|
24581
|
+
assertType(retv != null, "'%s' must be an object that Event constructor created, but got another one: %o", name, event);
|
|
24582
|
+
return retv;
|
|
24583
|
+
}
|
|
24584
|
+
function setCancelFlag(data) {
|
|
24585
|
+
if (data.inPassiveListenerFlag) {
|
|
24586
|
+
CanceledInPassiveListener.warn();
|
|
24587
|
+
return;
|
|
24588
|
+
}
|
|
24589
|
+
if (!data.cancelable) {
|
|
24590
|
+
NonCancelableEventWasCanceled.warn();
|
|
24591
|
+
return;
|
|
24592
|
+
}
|
|
24593
|
+
data.canceledFlag = true;
|
|
24594
|
+
}
|
|
24595
|
+
Object.defineProperty(Event2, "NONE", { enumerable: true });
|
|
24596
|
+
Object.defineProperty(Event2, "CAPTURING_PHASE", { enumerable: true });
|
|
24597
|
+
Object.defineProperty(Event2, "AT_TARGET", { enumerable: true });
|
|
24598
|
+
Object.defineProperty(Event2, "BUBBLING_PHASE", { enumerable: true });
|
|
24599
|
+
var keys = Object.getOwnPropertyNames(Event2.prototype);
|
|
24600
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
24601
|
+
if (keys[i] === "constructor") {
|
|
24602
|
+
continue;
|
|
24603
|
+
}
|
|
24604
|
+
Object.defineProperty(Event2.prototype, keys[i], { enumerable: true });
|
|
24605
|
+
}
|
|
24606
|
+
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
24607
|
+
Object.setPrototypeOf(Event2.prototype, Global.Event.prototype);
|
|
24608
|
+
}
|
|
24609
|
+
function createInvalidStateError(message) {
|
|
24610
|
+
if (Global.DOMException) {
|
|
24611
|
+
return new Global.DOMException(message, "InvalidStateError");
|
|
24612
|
+
}
|
|
24613
|
+
if (DOMException == null) {
|
|
24614
|
+
DOMException = class DOMException2 extends Error {
|
|
24615
|
+
constructor(msg) {
|
|
24616
|
+
super(msg);
|
|
24617
|
+
if (Error.captureStackTrace) {
|
|
24618
|
+
Error.captureStackTrace(this, DOMException2);
|
|
24619
|
+
}
|
|
24620
|
+
}
|
|
24621
|
+
// eslint-disable-next-line class-methods-use-this
|
|
24622
|
+
get code() {
|
|
24623
|
+
return 11;
|
|
24624
|
+
}
|
|
24625
|
+
// eslint-disable-next-line class-methods-use-this
|
|
24626
|
+
get name() {
|
|
24627
|
+
return "InvalidStateError";
|
|
24628
|
+
}
|
|
24629
|
+
};
|
|
24630
|
+
Object.defineProperties(DOMException.prototype, {
|
|
24631
|
+
code: { enumerable: true },
|
|
24632
|
+
name: { enumerable: true }
|
|
24633
|
+
});
|
|
24634
|
+
defineErrorCodeProperties(DOMException);
|
|
24635
|
+
defineErrorCodeProperties(DOMException.prototype);
|
|
24636
|
+
}
|
|
24637
|
+
return new DOMException(message);
|
|
24638
|
+
}
|
|
24639
|
+
var DOMException;
|
|
24640
|
+
var ErrorCodeMap = {
|
|
24641
|
+
INDEX_SIZE_ERR: 1,
|
|
24642
|
+
DOMSTRING_SIZE_ERR: 2,
|
|
24643
|
+
HIERARCHY_REQUEST_ERR: 3,
|
|
24644
|
+
WRONG_DOCUMENT_ERR: 4,
|
|
24645
|
+
INVALID_CHARACTER_ERR: 5,
|
|
24646
|
+
NO_DATA_ALLOWED_ERR: 6,
|
|
24647
|
+
NO_MODIFICATION_ALLOWED_ERR: 7,
|
|
24648
|
+
NOT_FOUND_ERR: 8,
|
|
24649
|
+
NOT_SUPPORTED_ERR: 9,
|
|
24650
|
+
INUSE_ATTRIBUTE_ERR: 10,
|
|
24651
|
+
INVALID_STATE_ERR: 11,
|
|
24652
|
+
SYNTAX_ERR: 12,
|
|
24653
|
+
INVALID_MODIFICATION_ERR: 13,
|
|
24654
|
+
NAMESPACE_ERR: 14,
|
|
24655
|
+
INVALID_ACCESS_ERR: 15,
|
|
24656
|
+
VALIDATION_ERR: 16,
|
|
24657
|
+
TYPE_MISMATCH_ERR: 17,
|
|
24658
|
+
SECURITY_ERR: 18,
|
|
24659
|
+
NETWORK_ERR: 19,
|
|
24660
|
+
ABORT_ERR: 20,
|
|
24661
|
+
URL_MISMATCH_ERR: 21,
|
|
24662
|
+
QUOTA_EXCEEDED_ERR: 22,
|
|
24663
|
+
TIMEOUT_ERR: 23,
|
|
24664
|
+
INVALID_NODE_TYPE_ERR: 24,
|
|
24665
|
+
DATA_CLONE_ERR: 25
|
|
24666
|
+
};
|
|
24667
|
+
function defineErrorCodeProperties(obj) {
|
|
24668
|
+
const keys2 = Object.keys(ErrorCodeMap);
|
|
24669
|
+
for (let i = 0; i < keys2.length; ++i) {
|
|
24670
|
+
const key = keys2[i];
|
|
24671
|
+
const value = ErrorCodeMap[key];
|
|
24672
|
+
Object.defineProperty(obj, key, {
|
|
24673
|
+
get() {
|
|
24674
|
+
return value;
|
|
24675
|
+
},
|
|
24676
|
+
configurable: true,
|
|
24677
|
+
enumerable: true
|
|
24678
|
+
});
|
|
24679
|
+
}
|
|
24680
|
+
}
|
|
24681
|
+
var EventWrapper = class extends Event2 {
|
|
24682
|
+
/**
|
|
24683
|
+
* Wrap a given event object to control states.
|
|
24684
|
+
* @param event The event-like object to wrap.
|
|
24685
|
+
*/
|
|
24686
|
+
static wrap(event) {
|
|
24687
|
+
return new (getWrapperClassOf(event))(event);
|
|
24688
|
+
}
|
|
24689
|
+
constructor(event) {
|
|
24690
|
+
super(event.type, {
|
|
24691
|
+
bubbles: event.bubbles,
|
|
24692
|
+
cancelable: event.cancelable,
|
|
24693
|
+
composed: event.composed
|
|
24694
|
+
});
|
|
24695
|
+
if (event.cancelBubble) {
|
|
24696
|
+
super.stopPropagation();
|
|
24697
|
+
}
|
|
24698
|
+
if (event.defaultPrevented) {
|
|
24699
|
+
super.preventDefault();
|
|
24700
|
+
}
|
|
24701
|
+
internalDataMap$1.set(this, { original: event });
|
|
24702
|
+
const keys2 = Object.keys(event);
|
|
24703
|
+
for (let i = 0; i < keys2.length; ++i) {
|
|
24704
|
+
const key = keys2[i];
|
|
24705
|
+
if (!(key in this)) {
|
|
24706
|
+
Object.defineProperty(this, key, defineRedirectDescriptor(event, key));
|
|
24707
|
+
}
|
|
24708
|
+
}
|
|
24709
|
+
}
|
|
24710
|
+
stopPropagation() {
|
|
24711
|
+
super.stopPropagation();
|
|
24712
|
+
const { original } = $$1(this);
|
|
24713
|
+
if ("stopPropagation" in original) {
|
|
24714
|
+
original.stopPropagation();
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
get cancelBubble() {
|
|
24718
|
+
return super.cancelBubble;
|
|
24719
|
+
}
|
|
24720
|
+
set cancelBubble(value) {
|
|
24721
|
+
super.cancelBubble = value;
|
|
24722
|
+
const { original } = $$1(this);
|
|
24723
|
+
if ("cancelBubble" in original) {
|
|
24724
|
+
original.cancelBubble = value;
|
|
24725
|
+
}
|
|
24726
|
+
}
|
|
24727
|
+
stopImmediatePropagation() {
|
|
24728
|
+
super.stopImmediatePropagation();
|
|
24729
|
+
const { original } = $$1(this);
|
|
24730
|
+
if ("stopImmediatePropagation" in original) {
|
|
24731
|
+
original.stopImmediatePropagation();
|
|
24732
|
+
}
|
|
24733
|
+
}
|
|
24734
|
+
get returnValue() {
|
|
24735
|
+
return super.returnValue;
|
|
24736
|
+
}
|
|
24737
|
+
set returnValue(value) {
|
|
24738
|
+
super.returnValue = value;
|
|
24739
|
+
const { original } = $$1(this);
|
|
24740
|
+
if ("returnValue" in original) {
|
|
24741
|
+
original.returnValue = value;
|
|
24742
|
+
}
|
|
24743
|
+
}
|
|
24744
|
+
preventDefault() {
|
|
24745
|
+
super.preventDefault();
|
|
24746
|
+
const { original } = $$1(this);
|
|
24747
|
+
if ("preventDefault" in original) {
|
|
24748
|
+
original.preventDefault();
|
|
24749
|
+
}
|
|
24750
|
+
}
|
|
24751
|
+
get timeStamp() {
|
|
24752
|
+
const { original } = $$1(this);
|
|
24753
|
+
if ("timeStamp" in original) {
|
|
24754
|
+
return original.timeStamp;
|
|
24755
|
+
}
|
|
24756
|
+
return super.timeStamp;
|
|
24757
|
+
}
|
|
24758
|
+
};
|
|
24759
|
+
var internalDataMap$1 = /* @__PURE__ */ new WeakMap();
|
|
24760
|
+
function $$1(event) {
|
|
24761
|
+
const retv = internalDataMap$1.get(event);
|
|
24762
|
+
assertType(retv != null, "'this' is expected an Event object, but got", event);
|
|
24763
|
+
return retv;
|
|
24764
|
+
}
|
|
24765
|
+
var wrapperClassCache = /* @__PURE__ */ new WeakMap();
|
|
24766
|
+
wrapperClassCache.set(Object.prototype, EventWrapper);
|
|
24767
|
+
if (typeof Global !== "undefined" && typeof Global.Event !== "undefined") {
|
|
24768
|
+
wrapperClassCache.set(Global.Event.prototype, EventWrapper);
|
|
24769
|
+
}
|
|
24770
|
+
function getWrapperClassOf(originalEvent) {
|
|
24771
|
+
const prototype = Object.getPrototypeOf(originalEvent);
|
|
24772
|
+
if (prototype == null) {
|
|
24773
|
+
return EventWrapper;
|
|
24774
|
+
}
|
|
24775
|
+
let wrapper = wrapperClassCache.get(prototype);
|
|
24776
|
+
if (wrapper == null) {
|
|
24777
|
+
wrapper = defineWrapper(getWrapperClassOf(prototype), prototype);
|
|
24778
|
+
wrapperClassCache.set(prototype, wrapper);
|
|
24779
|
+
}
|
|
24780
|
+
return wrapper;
|
|
24781
|
+
}
|
|
24782
|
+
function defineWrapper(BaseEventWrapper, originalPrototype) {
|
|
24783
|
+
class CustomEventWrapper extends BaseEventWrapper {
|
|
24784
|
+
}
|
|
24785
|
+
const keys2 = Object.keys(originalPrototype);
|
|
24786
|
+
for (let i = 0; i < keys2.length; ++i) {
|
|
24787
|
+
Object.defineProperty(CustomEventWrapper.prototype, keys2[i], defineRedirectDescriptor(originalPrototype, keys2[i]));
|
|
24788
|
+
}
|
|
24789
|
+
return CustomEventWrapper;
|
|
24790
|
+
}
|
|
24791
|
+
function defineRedirectDescriptor(obj, key) {
|
|
24792
|
+
const d = Object.getOwnPropertyDescriptor(obj, key);
|
|
24793
|
+
return {
|
|
24794
|
+
get() {
|
|
24795
|
+
const original = $$1(this).original;
|
|
24796
|
+
const value = original[key];
|
|
24797
|
+
if (typeof value === "function") {
|
|
24798
|
+
return value.bind(original);
|
|
24799
|
+
}
|
|
24800
|
+
return value;
|
|
24801
|
+
},
|
|
24802
|
+
set(value) {
|
|
24803
|
+
const original = $$1(this).original;
|
|
24804
|
+
original[key] = value;
|
|
24805
|
+
},
|
|
24806
|
+
configurable: d.configurable,
|
|
24807
|
+
enumerable: d.enumerable
|
|
24808
|
+
};
|
|
24809
|
+
}
|
|
24810
|
+
function createListener(callback, capture, passive, once, signal, signalListener) {
|
|
24811
|
+
return {
|
|
24812
|
+
callback,
|
|
24813
|
+
flags: (capture ? 1 : 0) | (passive ? 2 : 0) | (once ? 4 : 0),
|
|
24814
|
+
signal,
|
|
24815
|
+
signalListener
|
|
24816
|
+
};
|
|
24817
|
+
}
|
|
24818
|
+
function setRemoved(listener) {
|
|
24819
|
+
listener.flags |= 8;
|
|
24820
|
+
}
|
|
24821
|
+
function isCapture(listener) {
|
|
24822
|
+
return (listener.flags & 1) === 1;
|
|
24823
|
+
}
|
|
24824
|
+
function isPassive(listener) {
|
|
24825
|
+
return (listener.flags & 2) === 2;
|
|
24826
|
+
}
|
|
24827
|
+
function isOnce(listener) {
|
|
24828
|
+
return (listener.flags & 4) === 4;
|
|
24829
|
+
}
|
|
24830
|
+
function isRemoved(listener) {
|
|
24831
|
+
return (listener.flags & 8) === 8;
|
|
24832
|
+
}
|
|
24833
|
+
function invokeCallback({ callback }, target, event) {
|
|
24834
|
+
try {
|
|
24835
|
+
if (typeof callback === "function") {
|
|
24836
|
+
callback.call(target, event);
|
|
24837
|
+
} else if (typeof callback.handleEvent === "function") {
|
|
24838
|
+
callback.handleEvent(event);
|
|
24839
|
+
}
|
|
24840
|
+
} catch (thrownError) {
|
|
24841
|
+
reportError(thrownError);
|
|
24842
|
+
}
|
|
24843
|
+
}
|
|
24844
|
+
function findIndexOfListener({ listeners }, callback, capture) {
|
|
24845
|
+
for (let i = 0; i < listeners.length; ++i) {
|
|
24846
|
+
if (listeners[i].callback === callback && isCapture(listeners[i]) === capture) {
|
|
24847
|
+
return i;
|
|
24848
|
+
}
|
|
24849
|
+
}
|
|
24850
|
+
return -1;
|
|
24851
|
+
}
|
|
24852
|
+
function addListener(list, callback, capture, passive, once, signal) {
|
|
24853
|
+
let signalListener;
|
|
24854
|
+
if (signal) {
|
|
24855
|
+
signalListener = removeListener.bind(null, list, callback, capture);
|
|
24856
|
+
signal.addEventListener("abort", signalListener);
|
|
24857
|
+
}
|
|
24858
|
+
const listener = createListener(callback, capture, passive, once, signal, signalListener);
|
|
24859
|
+
if (list.cow) {
|
|
24860
|
+
list.cow = false;
|
|
24861
|
+
list.listeners = [...list.listeners, listener];
|
|
24862
|
+
} else {
|
|
24863
|
+
list.listeners.push(listener);
|
|
24864
|
+
}
|
|
24865
|
+
return listener;
|
|
24866
|
+
}
|
|
24867
|
+
function removeListener(list, callback, capture) {
|
|
24868
|
+
const index = findIndexOfListener(list, callback, capture);
|
|
24869
|
+
if (index !== -1) {
|
|
24870
|
+
return removeListenerAt(list, index);
|
|
24871
|
+
}
|
|
24872
|
+
return false;
|
|
24873
|
+
}
|
|
24874
|
+
function removeListenerAt(list, index, disableCow = false) {
|
|
24875
|
+
const listener = list.listeners[index];
|
|
24876
|
+
setRemoved(listener);
|
|
24877
|
+
if (listener.signal) {
|
|
24878
|
+
listener.signal.removeEventListener("abort", listener.signalListener);
|
|
24879
|
+
}
|
|
24880
|
+
if (list.cow && !disableCow) {
|
|
24881
|
+
list.cow = false;
|
|
24882
|
+
list.listeners = list.listeners.filter((_, i) => i !== index);
|
|
24883
|
+
return false;
|
|
24884
|
+
}
|
|
24885
|
+
list.listeners.splice(index, 1);
|
|
24886
|
+
return true;
|
|
24887
|
+
}
|
|
24888
|
+
function createListenerListMap() {
|
|
24889
|
+
return /* @__PURE__ */ Object.create(null);
|
|
24890
|
+
}
|
|
24891
|
+
function ensureListenerList(listenerMap, type) {
|
|
24892
|
+
var _a;
|
|
24893
|
+
return (_a = listenerMap[type]) !== null && _a !== void 0 ? _a : listenerMap[type] = {
|
|
24894
|
+
attrCallback: void 0,
|
|
24895
|
+
attrListener: void 0,
|
|
24896
|
+
cow: false,
|
|
24897
|
+
listeners: []
|
|
24898
|
+
};
|
|
24899
|
+
}
|
|
24900
|
+
var EventTarget2 = class {
|
|
24901
|
+
/**
|
|
24902
|
+
* Initialize this instance.
|
|
24903
|
+
*/
|
|
24904
|
+
constructor() {
|
|
24905
|
+
internalDataMap$2.set(this, createListenerListMap());
|
|
24906
|
+
}
|
|
24907
|
+
// Implementation
|
|
24908
|
+
addEventListener(type0, callback0, options0) {
|
|
24909
|
+
const listenerMap = $$2(this);
|
|
24910
|
+
const { callback, capture, once, passive, signal, type } = normalizeAddOptions(type0, callback0, options0);
|
|
24911
|
+
if (callback == null || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
|
|
24912
|
+
return;
|
|
24913
|
+
}
|
|
24914
|
+
const list = ensureListenerList(listenerMap, type);
|
|
24915
|
+
const i = findIndexOfListener(list, callback, capture);
|
|
24916
|
+
if (i !== -1) {
|
|
24917
|
+
warnDuplicate(list.listeners[i], passive, once, signal);
|
|
24918
|
+
return;
|
|
24919
|
+
}
|
|
24920
|
+
addListener(list, callback, capture, passive, once, signal);
|
|
24921
|
+
}
|
|
24922
|
+
// Implementation
|
|
24923
|
+
removeEventListener(type0, callback0, options0) {
|
|
24924
|
+
const listenerMap = $$2(this);
|
|
24925
|
+
const { callback, capture, type } = normalizeOptions(type0, callback0, options0);
|
|
24926
|
+
const list = listenerMap[type];
|
|
24927
|
+
if (callback != null && list) {
|
|
24928
|
+
removeListener(list, callback, capture);
|
|
24929
|
+
}
|
|
24930
|
+
}
|
|
24931
|
+
// Implementation
|
|
24932
|
+
dispatchEvent(e) {
|
|
24933
|
+
const list = $$2(this)[String(e.type)];
|
|
24934
|
+
if (list == null) {
|
|
24935
|
+
return true;
|
|
24936
|
+
}
|
|
24937
|
+
const event = e instanceof Event2 ? e : EventWrapper.wrap(e);
|
|
24938
|
+
const eventData = $(event, "event");
|
|
24939
|
+
if (eventData.dispatchFlag) {
|
|
24940
|
+
throw createInvalidStateError("This event has been in dispatching.");
|
|
24941
|
+
}
|
|
24942
|
+
eventData.dispatchFlag = true;
|
|
24943
|
+
eventData.target = eventData.currentTarget = this;
|
|
24944
|
+
if (!eventData.stopPropagationFlag) {
|
|
24945
|
+
const { cow, listeners } = list;
|
|
24946
|
+
list.cow = true;
|
|
24947
|
+
for (let i = 0; i < listeners.length; ++i) {
|
|
24948
|
+
const listener = listeners[i];
|
|
24949
|
+
if (isRemoved(listener)) {
|
|
24950
|
+
continue;
|
|
24951
|
+
}
|
|
24952
|
+
if (isOnce(listener) && removeListenerAt(list, i, !cow)) {
|
|
24953
|
+
i -= 1;
|
|
24974
24954
|
}
|
|
24975
|
-
|
|
24976
|
-
|
|
24977
|
-
|
|
24978
|
-
|
|
24979
|
-
|
|
24980
|
-
};
|
|
24981
|
-
}
|
|
24982
|
-
if (finalEvent.type === "error") {
|
|
24983
|
-
this.dispatchEvent(new ErrorEvent("error", finalEvent));
|
|
24984
|
-
} else {
|
|
24985
|
-
this.dispatchEvent(new SpeechRecognitionEvent(finalEvent.type, finalEvent));
|
|
24986
|
-
}
|
|
24955
|
+
eventData.inPassiveListenerFlag = isPassive(listener);
|
|
24956
|
+
invokeCallback(listener, this, event);
|
|
24957
|
+
eventData.inPassiveListenerFlag = false;
|
|
24958
|
+
if (eventData.stopImmediatePropagationFlag) {
|
|
24959
|
+
break;
|
|
24987
24960
|
}
|
|
24988
|
-
|
|
24989
|
-
|
|
24990
|
-
|
|
24991
|
-
console.error(err);
|
|
24992
|
-
throw err;
|
|
24993
|
-
} finally {
|
|
24994
|
-
unprepare();
|
|
24995
|
-
recognizer.dispose();
|
|
24961
|
+
}
|
|
24962
|
+
if (!cow) {
|
|
24963
|
+
list.cow = false;
|
|
24996
24964
|
}
|
|
24997
24965
|
}
|
|
24966
|
+
eventData.target = null;
|
|
24967
|
+
eventData.currentTarget = null;
|
|
24968
|
+
eventData.stopImmediatePropagationFlag = false;
|
|
24969
|
+
eventData.stopPropagationFlag = false;
|
|
24970
|
+
eventData.dispatchFlag = false;
|
|
24971
|
+
return !eventData.canceledFlag;
|
|
24972
|
+
}
|
|
24973
|
+
};
|
|
24974
|
+
var internalDataMap$2 = /* @__PURE__ */ new WeakMap();
|
|
24975
|
+
function $$2(target, name = "this") {
|
|
24976
|
+
const retv = internalDataMap$2.get(target);
|
|
24977
|
+
assertType(retv != null, "'%s' must be an object that EventTarget constructor created, but got another one: %o", name, target);
|
|
24978
|
+
return retv;
|
|
24979
|
+
}
|
|
24980
|
+
function normalizeAddOptions(type, callback, options) {
|
|
24981
|
+
var _a;
|
|
24982
|
+
assertCallback(callback);
|
|
24983
|
+
if (typeof options === "object" && options !== null) {
|
|
24984
|
+
return {
|
|
24985
|
+
type: String(type),
|
|
24986
|
+
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24987
|
+
capture: Boolean(options.capture),
|
|
24988
|
+
passive: Boolean(options.passive),
|
|
24989
|
+
once: Boolean(options.once),
|
|
24990
|
+
signal: (_a = options.signal) !== null && _a !== void 0 ? _a : void 0
|
|
24991
|
+
};
|
|
24998
24992
|
}
|
|
24999
24993
|
return {
|
|
25000
|
-
|
|
25001
|
-
|
|
25002
|
-
|
|
24994
|
+
type: String(type),
|
|
24995
|
+
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
24996
|
+
capture: Boolean(options),
|
|
24997
|
+
passive: false,
|
|
24998
|
+
once: false,
|
|
24999
|
+
signal: void 0
|
|
25003
25000
|
};
|
|
25004
25001
|
}
|
|
25005
|
-
|
|
25006
|
-
|
|
25007
|
-
|
|
25008
|
-
|
|
25009
|
-
|
|
25010
|
-
|
|
25011
|
-
|
|
25012
|
-
|
|
25013
|
-
referenceGrammars,
|
|
25014
|
-
speechRecognitionEndpointId,
|
|
25015
|
-
textNormalization = "display"
|
|
25016
|
-
} = patchOptions(options);
|
|
25017
|
-
if (!audioConfig && (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia)) {
|
|
25018
|
-
console.warn(
|
|
25019
|
-
"web-speech-cognitive-services: This browser does not support WebRTC and it will not work with Cognitive Services Speech Services."
|
|
25020
|
-
);
|
|
25021
|
-
return {};
|
|
25002
|
+
function normalizeOptions(type, callback, options) {
|
|
25003
|
+
assertCallback(callback);
|
|
25004
|
+
if (typeof options === "object" && options !== null) {
|
|
25005
|
+
return {
|
|
25006
|
+
type: String(type),
|
|
25007
|
+
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
25008
|
+
capture: Boolean(options.capture)
|
|
25009
|
+
};
|
|
25022
25010
|
}
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25011
|
+
return {
|
|
25012
|
+
type: String(type),
|
|
25013
|
+
callback: callback !== null && callback !== void 0 ? callback : void 0,
|
|
25014
|
+
capture: Boolean(options)
|
|
25015
|
+
};
|
|
25016
|
+
}
|
|
25017
|
+
function assertCallback(callback) {
|
|
25018
|
+
if (typeof callback === "function" || typeof callback === "object" && callback !== null && typeof callback.handleEvent === "function") {
|
|
25019
|
+
return;
|
|
25020
|
+
}
|
|
25021
|
+
if (callback == null || typeof callback === "object") {
|
|
25022
|
+
InvalidEventListener.warn(callback);
|
|
25023
|
+
return;
|
|
25024
|
+
}
|
|
25025
|
+
throw new TypeError(format(InvalidEventListener.message, [callback]));
|
|
25026
|
+
}
|
|
25027
|
+
function warnDuplicate(listener, passive, once, signal) {
|
|
25028
|
+
EventListenerWasDuplicated.warn(isCapture(listener) ? "capture" : "bubble", listener.callback);
|
|
25029
|
+
if (isPassive(listener) !== passive) {
|
|
25030
|
+
OptionWasIgnored.warn("passive");
|
|
25031
|
+
}
|
|
25032
|
+
if (isOnce(listener) !== once) {
|
|
25033
|
+
OptionWasIgnored.warn("once");
|
|
25034
|
+
}
|
|
25035
|
+
if (listener.signal !== signal) {
|
|
25036
|
+
OptionWasIgnored.warn("signal");
|
|
25037
|
+
}
|
|
25038
|
+
}
|
|
25039
|
+
var keys$1 = Object.getOwnPropertyNames(EventTarget2.prototype);
|
|
25040
|
+
for (let i = 0; i < keys$1.length; ++i) {
|
|
25041
|
+
if (keys$1[i] === "constructor") {
|
|
25042
|
+
continue;
|
|
25043
|
+
}
|
|
25044
|
+
Object.defineProperty(EventTarget2.prototype, keys$1[i], { enumerable: true });
|
|
25045
|
+
}
|
|
25046
|
+
if (typeof Global !== "undefined" && typeof Global.EventTarget !== "undefined") {
|
|
25047
|
+
Object.setPrototypeOf(EventTarget2.prototype, Global.EventTarget.prototype);
|
|
25048
|
+
}
|
|
25049
|
+
function getEventAttributeValue(target, type) {
|
|
25050
|
+
var _a, _b;
|
|
25051
|
+
const listMap = $$2(target, "target");
|
|
25052
|
+
return (_b = (_a = listMap[type]) === null || _a === void 0 ? void 0 : _a.attrCallback) !== null && _b !== void 0 ? _b : null;
|
|
25053
|
+
}
|
|
25054
|
+
function setEventAttributeValue(target, type, callback) {
|
|
25055
|
+
if (callback != null && typeof callback !== "function") {
|
|
25056
|
+
InvalidAttributeHandler.warn(callback);
|
|
25057
|
+
}
|
|
25058
|
+
if (typeof callback === "function" || typeof callback === "object" && callback !== null) {
|
|
25059
|
+
upsertEventAttributeListener(target, type, callback);
|
|
25060
|
+
} else {
|
|
25061
|
+
removeEventAttributeListener(target, type);
|
|
25062
|
+
}
|
|
25063
|
+
}
|
|
25064
|
+
function upsertEventAttributeListener(target, type, callback) {
|
|
25065
|
+
const list = ensureListenerList($$2(target, "target"), String(type));
|
|
25066
|
+
list.attrCallback = callback;
|
|
25067
|
+
if (list.attrListener == null) {
|
|
25068
|
+
list.attrListener = addListener(list, defineEventAttributeCallback(list), false, false, false, void 0);
|
|
25069
|
+
}
|
|
25070
|
+
}
|
|
25071
|
+
function removeEventAttributeListener(target, type) {
|
|
25072
|
+
const listMap = $$2(target, "target");
|
|
25073
|
+
const list = listMap[String(type)];
|
|
25074
|
+
if (list && list.attrListener) {
|
|
25075
|
+
removeListener(list, list.attrListener.callback, false);
|
|
25076
|
+
list.attrCallback = list.attrListener = void 0;
|
|
25077
|
+
}
|
|
25078
|
+
}
|
|
25079
|
+
function defineEventAttributeCallback(list) {
|
|
25080
|
+
return function(event) {
|
|
25081
|
+
const callback = list.attrCallback;
|
|
25082
|
+
if (typeof callback === "function") {
|
|
25083
|
+
callback.call(this, event);
|
|
25039
25084
|
}
|
|
25040
|
-
speechConfig.outputFormat = OutputFormat2.Detailed;
|
|
25041
|
-
speechConfig.speechRecognitionLanguage = lang || "en-US";
|
|
25042
|
-
return new SpeechRecognizer2(speechConfig, audioConfig);
|
|
25043
25085
|
};
|
|
25044
|
-
|
|
25045
|
-
audioConfig,
|
|
25046
|
-
createRecognizer,
|
|
25047
|
-
enableTelemetry,
|
|
25048
|
-
looseEvents,
|
|
25049
|
-
referenceGrammars,
|
|
25050
|
-
textNormalization
|
|
25051
|
-
});
|
|
25052
|
-
};
|
|
25053
|
-
|
|
25054
|
-
// src/SpeechServices/SpeechToText.js
|
|
25055
|
-
var SpeechToText_default = createSpeechRecognitionPonyfill_default;
|
|
25086
|
+
}
|
|
25056
25087
|
|
|
25057
25088
|
// ../../node_modules/on-error-resume-next/dist/chunk-MBTBSBLB.mjs
|
|
25058
25089
|
function isPromise(value) {
|
|
@@ -25196,14 +25227,58 @@
|
|
|
25196
25227
|
};
|
|
25197
25228
|
|
|
25198
25229
|
// src/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js
|
|
25199
|
-
var SpeechSynthesisEvent = class extends
|
|
25230
|
+
var SpeechSynthesisEvent = class extends Event2 {
|
|
25200
25231
|
constructor(type) {
|
|
25201
25232
|
super(type);
|
|
25202
25233
|
}
|
|
25203
25234
|
};
|
|
25204
25235
|
|
|
25205
|
-
//
|
|
25206
|
-
|
|
25236
|
+
// node_modules/event-as-promise/dist/event-as-promise.mjs
|
|
25237
|
+
function withResolvers() {
|
|
25238
|
+
const resolvers = {};
|
|
25239
|
+
resolvers.promise = new Promise((resolve, reject) => {
|
|
25240
|
+
resolvers.reject = reject;
|
|
25241
|
+
resolvers.resolve = resolve;
|
|
25242
|
+
});
|
|
25243
|
+
return resolvers;
|
|
25244
|
+
}
|
|
25245
|
+
var EventAsPromise = class {
|
|
25246
|
+
constructor() {
|
|
25247
|
+
this.#eventListener = (event) => {
|
|
25248
|
+
const deferred = this.#orderedResolvers.shift();
|
|
25249
|
+
deferred && deferred.resolve(event);
|
|
25250
|
+
if (this.#upcomingResolvers) {
|
|
25251
|
+
this.#upcomingResolvers.resolve(event);
|
|
25252
|
+
this.#upcomingResolvers = void 0;
|
|
25253
|
+
}
|
|
25254
|
+
};
|
|
25255
|
+
}
|
|
25256
|
+
#eventListener;
|
|
25257
|
+
#orderedResolvers = [];
|
|
25258
|
+
#upcomingResolvers = void 0;
|
|
25259
|
+
get eventListener() {
|
|
25260
|
+
return this.#eventListener;
|
|
25261
|
+
}
|
|
25262
|
+
[Symbol.iterator]() {
|
|
25263
|
+
return {
|
|
25264
|
+
next: () => ({
|
|
25265
|
+
done: false,
|
|
25266
|
+
value: this.upcoming()
|
|
25267
|
+
})
|
|
25268
|
+
};
|
|
25269
|
+
}
|
|
25270
|
+
one() {
|
|
25271
|
+
const deferred = withResolvers();
|
|
25272
|
+
this.#orderedResolvers.push(deferred);
|
|
25273
|
+
return deferred.promise;
|
|
25274
|
+
}
|
|
25275
|
+
upcoming() {
|
|
25276
|
+
if (!this.#upcomingResolvers) {
|
|
25277
|
+
this.#upcomingResolvers = withResolvers();
|
|
25278
|
+
}
|
|
25279
|
+
return this.#upcomingResolvers.promise;
|
|
25280
|
+
}
|
|
25281
|
+
};
|
|
25207
25282
|
|
|
25208
25283
|
// ../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js
|
|
25209
25284
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -25323,8 +25398,8 @@
|
|
|
25323
25398
|
}
|
|
25324
25399
|
function playDecoded(audioContext, audioBuffer, source) {
|
|
25325
25400
|
return new Promise((resolve, reject) => {
|
|
25326
|
-
const audioContextClosed = new
|
|
25327
|
-
const sourceEnded = new
|
|
25401
|
+
const audioContextClosed = new EventAsPromise();
|
|
25402
|
+
const sourceEnded = new EventAsPromise();
|
|
25328
25403
|
const unsubscribe = subscribeEvent(
|
|
25329
25404
|
audioContext,
|
|
25330
25405
|
"statechange",
|
|
@@ -25343,7 +25418,7 @@
|
|
|
25343
25418
|
}
|
|
25344
25419
|
});
|
|
25345
25420
|
}
|
|
25346
|
-
var SpeechSynthesisUtterance = class extends
|
|
25421
|
+
var SpeechSynthesisUtterance = class extends EventTarget2 {
|
|
25347
25422
|
constructor(text) {
|
|
25348
25423
|
super();
|
|
25349
25424
|
this._lang = null;
|
|
@@ -25558,7 +25633,7 @@
|
|
|
25558
25633
|
);
|
|
25559
25634
|
return {};
|
|
25560
25635
|
}
|
|
25561
|
-
class SpeechSynthesis extends
|
|
25636
|
+
class SpeechSynthesis extends EventTarget2 {
|
|
25562
25637
|
constructor() {
|
|
25563
25638
|
super();
|
|
25564
25639
|
this.queue = new AudioContextQueue_default({ audioContext, ponyfill: ponyfill2 });
|
|
@@ -25654,7 +25729,7 @@
|
|
|
25654
25729
|
}
|
|
25655
25730
|
var meta = document.createElement("meta");
|
|
25656
25731
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
25657
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
25732
|
+
meta.setAttribute("content", `version=${"8.0.0-main.d9ef940"}`);
|
|
25658
25733
|
document.head.appendChild(meta);
|
|
25659
25734
|
|
|
25660
25735
|
// src/index.umd.js
|