{"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nvar _asyncToGenerator = require(\"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/asyncToGenerator.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Queue = void 0;\nconst Error_js_1 = require(\"./Error.js\");\nconst List_js_1 = require(\"./List.js\");\nconst Promise_js_1 = require(\"./Promise.js\");\nvar SubscriberType;\n(function (SubscriberType) {\n SubscriberType[SubscriberType[\"Dequeue\"] = 0] = \"Dequeue\";\n SubscriberType[SubscriberType[\"Peek\"] = 1] = \"Peek\";\n})(SubscriberType || (SubscriberType = {}));\nclass Queue {\n constructor(list) {\n this.privPromiseStore = new List_js_1.List();\n this.privIsDrainInProgress = false;\n this.privIsDisposing = false;\n this.privDisposeReason = null;\n this.privList = list ? list : new List_js_1.List();\n this.privDetachables = [];\n this.privSubscribers = new List_js_1.List();\n this.privDetachables.push(this.privList.onAdded(() => this.drain()));\n }\n enqueue(item) {\n this.throwIfDispose();\n this.enqueueFromPromise(new Promise(resolve => resolve(item)));\n }\n enqueueFromPromise(promise) {\n this.throwIfDispose();\n promise.then(val => {\n this.privList.add(val);\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n }, () => {});\n }\n dequeue() {\n this.throwIfDispose();\n const deferredSubscriber = new Promise_js_1.Deferred();\n if (this.privSubscribers) {\n this.privSubscribers.add({\n deferral: deferredSubscriber,\n type: SubscriberType.Dequeue\n });\n this.drain();\n }\n return deferredSubscriber.promise;\n }\n peek() {\n this.throwIfDispose();\n const deferredSubscriber = new Promise_js_1.Deferred();\n const subs = this.privSubscribers;\n if (subs) {\n this.privSubscribers.add({\n deferral: deferredSubscriber,\n type: SubscriberType.Peek\n });\n this.drain();\n }\n return deferredSubscriber.promise;\n }\n length() {\n this.throwIfDispose();\n return this.privList.length();\n }\n isDisposed() {\n return this.privSubscribers == null;\n }\n drainAndDispose(pendingItemProcessor, reason) {\n var _this = this;\n return _asyncToGenerator(function* () {\n if (!_this.isDisposed() && !_this.privIsDisposing) {\n _this.privDisposeReason = reason;\n _this.privIsDisposing = true;\n const subs = _this.privSubscribers;\n if (subs) {\n while (subs.length() > 0) {\n const subscriber = subs.removeFirst();\n // TODO: this needs work (Resolve(null) instead?).\n subscriber.deferral.resolve(undefined);\n // subscriber.deferral.reject(\"Disposed\");\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (_this.privSubscribers === subs) {\n _this.privSubscribers = subs;\n }\n }\n for (const detachable of _this.privDetachables) {\n yield detachable.detach();\n }\n if (_this.privPromiseStore.length() > 0 && pendingItemProcessor) {\n const promiseArray = [];\n _this.privPromiseStore.toArray().forEach(wrapper => {\n promiseArray.push(wrapper);\n });\n return Promise.all(promiseArray).finally(() => {\n _this.privSubscribers = null;\n _this.privList.forEach(item => {\n pendingItemProcessor(item);\n });\n _this.privList = null;\n return;\n }).then();\n } else {\n _this.privSubscribers = null;\n _this.privList = null;\n }\n }\n })();\n }\n dispose(reason) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n yield _this2.drainAndDispose(null, reason);\n })();\n }\n drain() {\n if (!this.privIsDrainInProgress && !this.privIsDisposing) {\n this.privIsDrainInProgress = true;\n const subs = this.privSubscribers;\n const lists = this.privList;\n if (subs && lists) {\n while (lists.length() > 0 && subs.length() > 0 && !this.privIsDisposing) {\n const subscriber = subs.removeFirst();\n if (subscriber.type === SubscriberType.Peek) {\n subscriber.deferral.resolve(lists.first());\n } else {\n const dequeuedItem = lists.removeFirst();\n subscriber.deferral.resolve(dequeuedItem);\n }\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (this.privSubscribers === subs) {\n this.privSubscribers = subs;\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (this.privList === lists) {\n this.privList = lists;\n }\n }\n this.privIsDrainInProgress = false;\n }\n }\n throwIfDispose() {\n if (this.isDisposed()) {\n if (this.privDisposeReason) {\n throw new Error_js_1.InvalidOperationError(this.privDisposeReason);\n }\n throw new Error_js_1.ObjectDisposedError(\"Queue\");\n } else if (this.privIsDisposing) {\n throw new Error_js_1.InvalidOperationError(\"Queue disposing\");\n }\n }\n}\nexports.Queue = Queue;","map":{"version":3,"names":["_asyncToGenerator","require","default","Object","defineProperty","exports","value","Queue","Error_js_1","List_js_1","Promise_js_1","SubscriberType","constructor","list","privPromiseStore","List","privIsDrainInProgress","privIsDisposing","privDisposeReason","privList","privDetachables","privSubscribers","push","onAdded","drain","enqueue","item","throwIfDispose","enqueueFromPromise","Promise","resolve","promise","then","val","add","dequeue","deferredSubscriber","Deferred","deferral","type","Dequeue","peek","subs","Peek","length","isDisposed","drainAndDispose","pendingItemProcessor","reason","_this","subscriber","removeFirst","undefined","detachable","detach","promiseArray","toArray","forEach","wrapper","all","finally","dispose","_this2","lists","first","dequeuedItem","InvalidOperationError","ObjectDisposedError"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/Queue.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Queue = void 0;\nconst Error_js_1 = require(\"./Error.js\");\nconst List_js_1 = require(\"./List.js\");\nconst Promise_js_1 = require(\"./Promise.js\");\nvar SubscriberType;\n(function (SubscriberType) {\n SubscriberType[SubscriberType[\"Dequeue\"] = 0] = \"Dequeue\";\n SubscriberType[SubscriberType[\"Peek\"] = 1] = \"Peek\";\n})(SubscriberType || (SubscriberType = {}));\nclass Queue {\n constructor(list) {\n this.privPromiseStore = new List_js_1.List();\n this.privIsDrainInProgress = false;\n this.privIsDisposing = false;\n this.privDisposeReason = null;\n this.privList = list ? list : new List_js_1.List();\n this.privDetachables = [];\n this.privSubscribers = new List_js_1.List();\n this.privDetachables.push(this.privList.onAdded(() => this.drain()));\n }\n enqueue(item) {\n this.throwIfDispose();\n this.enqueueFromPromise(new Promise((resolve) => resolve(item)));\n }\n enqueueFromPromise(promise) {\n this.throwIfDispose();\n promise.then((val) => {\n this.privList.add(val);\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n }, () => { });\n }\n dequeue() {\n this.throwIfDispose();\n const deferredSubscriber = new Promise_js_1.Deferred();\n if (this.privSubscribers) {\n this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Dequeue });\n this.drain();\n }\n return deferredSubscriber.promise;\n }\n peek() {\n this.throwIfDispose();\n const deferredSubscriber = new Promise_js_1.Deferred();\n const subs = this.privSubscribers;\n if (subs) {\n this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Peek });\n this.drain();\n }\n return deferredSubscriber.promise;\n }\n length() {\n this.throwIfDispose();\n return this.privList.length();\n }\n isDisposed() {\n return this.privSubscribers == null;\n }\n async drainAndDispose(pendingItemProcessor, reason) {\n if (!this.isDisposed() && !this.privIsDisposing) {\n this.privDisposeReason = reason;\n this.privIsDisposing = true;\n const subs = this.privSubscribers;\n if (subs) {\n while (subs.length() > 0) {\n const subscriber = subs.removeFirst();\n // TODO: this needs work (Resolve(null) instead?).\n subscriber.deferral.resolve(undefined);\n // subscriber.deferral.reject(\"Disposed\");\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (this.privSubscribers === subs) {\n this.privSubscribers = subs;\n }\n }\n for (const detachable of this.privDetachables) {\n await detachable.detach();\n }\n if (this.privPromiseStore.length() > 0 && pendingItemProcessor) {\n const promiseArray = [];\n this.privPromiseStore.toArray().forEach((wrapper) => {\n promiseArray.push(wrapper);\n });\n return Promise.all(promiseArray).finally(() => {\n this.privSubscribers = null;\n this.privList.forEach((item) => {\n pendingItemProcessor(item);\n });\n this.privList = null;\n return;\n }).then();\n }\n else {\n this.privSubscribers = null;\n this.privList = null;\n }\n }\n }\n async dispose(reason) {\n await this.drainAndDispose(null, reason);\n }\n drain() {\n if (!this.privIsDrainInProgress && !this.privIsDisposing) {\n this.privIsDrainInProgress = true;\n const subs = this.privSubscribers;\n const lists = this.privList;\n if (subs && lists) {\n while (lists.length() > 0 && subs.length() > 0 && !this.privIsDisposing) {\n const subscriber = subs.removeFirst();\n if (subscriber.type === SubscriberType.Peek) {\n subscriber.deferral.resolve(lists.first());\n }\n else {\n const dequeuedItem = lists.removeFirst();\n subscriber.deferral.resolve(dequeuedItem);\n }\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (this.privSubscribers === subs) {\n this.privSubscribers = subs;\n }\n // note: this block assumes cooperative multitasking, i.e.,\n // between the if-statement and the assignment there are no\n // thread switches.\n // Reason is that between the initial const = this.; and this\n // point there is the derral.resolve() operation that might have\n // caused recursive calls to the Queue, especially, calling\n // Dispose() on the queue alredy (which would reset the var\n // here to null!).\n // That should generally hold true for javascript...\n if (this.privList === lists) {\n this.privList = lists;\n }\n }\n this.privIsDrainInProgress = false;\n }\n }\n throwIfDispose() {\n if (this.isDisposed()) {\n if (this.privDisposeReason) {\n throw new Error_js_1.InvalidOperationError(this.privDisposeReason);\n }\n throw new Error_js_1.ObjectDisposedError(\"Queue\");\n }\n else if (this.privIsDisposing) {\n throw new Error_js_1.InvalidOperationError(\"Queue disposing\");\n }\n }\n}\nexports.Queue = Queue;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AAAA,IAAAA,iBAAA,GAAAC,OAAA,qGAAAC,OAAA;AACAC,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,KAAK,GAAG,KAAK,CAAC;AACtB,MAAMC,UAAU,GAAGP,OAAO,CAAC,YAAY,CAAC;AACxC,MAAMQ,SAAS,GAAGR,OAAO,CAAC,WAAW,CAAC;AACtC,MAAMS,YAAY,GAAGT,OAAO,CAAC,cAAc,CAAC;AAC5C,IAAIU,cAAc;AAClB,CAAC,UAAUA,cAAc,EAAE;EACvBA,cAAc,CAACA,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;EACzDA,cAAc,CAACA,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACvD,CAAC,EAAEA,cAAc,KAAKA,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAMJ,KAAK,CAAC;EACRK,WAAWA,CAACC,IAAI,EAAE;IACd,IAAI,CAACC,gBAAgB,GAAG,IAAIL,SAAS,CAACM,IAAI,CAAC,CAAC;IAC5C,IAAI,CAACC,qBAAqB,GAAG,KAAK;IAClC,IAAI,CAACC,eAAe,GAAG,KAAK;IAC5B,IAAI,CAACC,iBAAiB,GAAG,IAAI;IAC7B,IAAI,CAACC,QAAQ,GAAGN,IAAI,GAAGA,IAAI,GA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