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