{"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ChunkedArrayBufferStream = void 0;\nconst Exports_js_1 = require(\"./Exports.js\");\nclass ChunkedArrayBufferStream extends Exports_js_1.Stream {\n constructor(targetChunkSize, streamId) {\n super(streamId);\n this.privTargetChunkSize = Math.round(targetChunkSize);\n this.privNextBufferReadyBytes = 0;\n }\n writeStreamChunk(chunk) {\n // No pending write, and the buffer is the right size so write it.\n if (chunk.isEnd || 0 === this.privNextBufferReadyBytes && chunk.buffer.byteLength === this.privTargetChunkSize) {\n super.writeStreamChunk(chunk);\n return;\n }\n let bytesCopiedFromBuffer = 0;\n while (bytesCopiedFromBuffer < chunk.buffer.byteLength) {\n // Fill the next buffer.\n if (undefined === this.privNextBufferToWrite) {\n this.privNextBufferToWrite = new ArrayBuffer(this.privTargetChunkSize);\n this.privNextBufferStartTime = chunk.timeReceived;\n }\n // Find out how many bytes we can copy into the read buffer.\n const bytesToCopy = Math.min(chunk.buffer.byteLength - bytesCopiedFromBuffer, this.privTargetChunkSize - this.privNextBufferReadyBytes);\n const targetView = new Uint8Array(this.privNextBufferToWrite);\n const sourceView = new Uint8Array(chunk.buffer.slice(bytesCopiedFromBuffer, bytesToCopy + bytesCopiedFromBuffer));\n targetView.set(sourceView, this.privNextBufferReadyBytes);\n this.privNextBufferReadyBytes += bytesToCopy;\n bytesCopiedFromBuffer += bytesToCopy;\n // Are we ready to write?\n if (this.privNextBufferReadyBytes === this.privTargetChunkSize) {\n super.writeStreamChunk({\n buffer: this.privNextBufferToWrite,\n isEnd: false,\n timeReceived: this.privNextBufferStartTime\n });\n this.privNextBufferReadyBytes = 0;\n this.privNextBufferToWrite = undefined;\n }\n }\n }\n close() {\n // Send whatever is pending, then close the base class.\n if (0 !== this.privNextBufferReadyBytes && !this.isClosed) {\n super.writeStreamChunk({\n buffer: this.privNextBufferToWrite.slice(0, this.privNextBufferReadyBytes),\n isEnd: false,\n timeReceived: this.privNextBufferStartTime\n });\n }\n super.close();\n }\n}\nexports.ChunkedArrayBufferStream = ChunkedArrayBufferStream;","map":{"version":3,"names":["Object","defineProperty","exports","value","ChunkedArrayBufferStream","Exports_js_1","require","Stream","constructor","targetChunkSize","streamId","privTargetChunkSize","Math","round","privNextBufferReadyBytes","writeStreamChunk","chunk","isEnd","buffer","byteLength","bytesCopiedFromBuffer","undefined","privNextBufferToWrite","ArrayBuffer","privNextBufferStartTime","timeReceived","bytesToCopy","min","targetView","Uint8Array","sourceView","slice","set","close","isClosed"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/ChunkedArrayBufferStream.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.ChunkedArrayBufferStream = void 0;\nconst Exports_js_1 = require(\"./Exports.js\");\nclass ChunkedArrayBufferStream extends Exports_js_1.Stream {\n constructor(targetChunkSize, streamId) {\n super(streamId);\n this.privTargetChunkSize = Math.round(targetChunkSize);\n this.privNextBufferReadyBytes = 0;\n }\n writeStreamChunk(chunk) {\n // No pending write, and the buffer is the right size so write it.\n if (chunk.isEnd ||\n (0 === this.privNextBufferReadyBytes && chunk.buffer.byteLength === this.privTargetChunkSize)) {\n super.writeStreamChunk(chunk);\n return;\n }\n let bytesCopiedFromBuffer = 0;\n while (bytesCopiedFromBuffer < chunk.buffer.byteLength) {\n // Fill the next buffer.\n if (undefined === this.privNextBufferToWrite) {\n this.privNextBufferToWrite = new ArrayBuffer(this.privTargetChunkSize);\n this.privNextBufferStartTime = chunk.timeReceived;\n }\n // Find out how many bytes we can copy into the read buffer.\n const bytesToCopy = Math.min(chunk.buffer.byteLength - bytesCopiedFromBuffer, this.privTargetChunkSize - this.privNextBufferReadyBytes);\n const targetView = new Uint8Array(this.privNextBufferToWrite);\n const sourceView = new Uint8Array(chunk.buffer.slice(bytesCopiedFromBuffer, bytesToCopy + bytesCopiedFromBuffer));\n targetView.set(sourceView, this.privNextBufferReadyBytes);\n this.privNextBufferReadyBytes += bytesToCopy;\n bytesCopiedFromBuffer += bytesToCopy;\n // Are we ready to write?\n if (this.privNextBufferReadyBytes === this.privTargetChunkSize) {\n super.writeStreamChunk({\n buffer: this.privNextBufferToWrite,\n isEnd: false,\n timeReceived: this.privNextBufferStartTime,\n });\n this.privNextBufferReadyBytes = 0;\n this.privNextBufferToWrite = undefined;\n }\n }\n }\n close() {\n // Send whatever is pending, then close the base class.\n if (0 !== this.privNextBufferReadyBytes && !this.isClosed) {\n super.writeStreamChunk({\n buffer: this.privNextBufferToWrite.slice(0, this.privNextBufferReadyBytes),\n isEnd: false,\n timeReceived: this.privNextBufferStartTime,\n });\n }\n super.close();\n }\n}\nexports.ChunkedArrayBufferStream = ChunkedArrayBufferStream;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,wBAAwB,GAAG,KAAK,CAAC;AACzC,MAAMC,YAAY,GAAGC,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAMF,wBAAwB,SAASC,YAAY,CAACE,MAAM,CAAC;EACvDC,WAAWA,CAACC,eAAe,EAAEC,QAAQ,EAAE;IACnC,KAAK,CAACA,QAAQ,CAAC;IACf,IAAI,CAACC,mBAAmB,GAAGC,IAAI,CAACC,KAAK,CAACJ,eAAe,CAAC;IACtD,IAAI,CAACK,wBAAwB,GAAG,CAAC;EACrC;EACAC,gBAAgBA,CAACC,KAAK,EAAE;IACpB;IACA,IAAIA,KAAK,CAACC,KAAK,IACV,CAAC,KAAK,IAAI,CAACH,wBAAwB,IAAIE,KAAK,CAACE,MAAM,CAACC,UAAU,KAAK,IAAI,CAACR,mBAAoB,E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