75b2a63ea181cdcf7a6087a9e2784ee851eacbb5e7c3e35b07a11f69ae8fff81.json 6.3 KB

1
  1. {"ast":null,"code":"\"use strict\";\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.RawWebsocketMessage = void 0;\nconst ConnectionMessage_js_1 = require(\"./ConnectionMessage.js\");\nconst Error_js_1 = require(\"./Error.js\");\nconst Guid_js_1 = require(\"./Guid.js\");\nclass RawWebsocketMessage {\n constructor(messageType, payload, id) {\n this.privPayload = null;\n if (!payload) {\n throw new Error_js_1.ArgumentNullError(\"payload\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (messageType === ConnectionMessage_js_1.MessageType.Binary && Object.getPrototypeOf(payload).constructor.name !== \"ArrayBuffer\") {\n throw new Error_js_1.InvalidOperationError(\"Payload must be ArrayBuffer\");\n }\n if (messageType === ConnectionMessage_js_1.MessageType.Text && !(typeof payload === \"string\")) {\n throw new Error_js_1.InvalidOperationError(\"Payload must be a string\");\n }\n this.privMessageType = messageType;\n this.privPayload = payload;\n this.privId = id ? id : Guid_js_1.createNoDashGuid();\n }\n get messageType() {\n return this.privMessageType;\n }\n get payload() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.privPayload;\n }\n get textContent() {\n if (this.privMessageType === ConnectionMessage_js_1.MessageType.Binary) {\n throw new Error_js_1.InvalidOperationError(\"Not supported for binary message\");\n }\n return this.privPayload;\n }\n get binaryContent() {\n if (this.privMessageType === ConnectionMessage_js_1.MessageType.Text) {\n throw new Error_js_1.InvalidOperationError(\"Not supported for text message\");\n }\n return this.privPayload;\n }\n get id() {\n return this.privId;\n }\n}\nexports.RawWebsocketMessage = RawWebsocketMessage;","map":{"version":3,"names":["Object","defineProperty","exports","value","RawWebsocketMessage","ConnectionMessage_js_1","require","Error_js_1","Guid_js_1","constructor","messageType","payload","id","privPayload","ArgumentNullError","MessageType","Binary","getPrototypeOf","name","InvalidOperationError","Text","privMessageType","privId","createNoDashGuid","textContent","binaryContent"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/RawWebsocketMessage.js"],"sourcesContent":["\"use strict\";\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.RawWebsocketMessage = void 0;\nconst ConnectionMessage_js_1 = require(\"./ConnectionMessage.js\");\nconst Error_js_1 = require(\"./Error.js\");\nconst Guid_js_1 = require(\"./Guid.js\");\nclass RawWebsocketMessage {\n constructor(messageType, payload, id) {\n this.privPayload = null;\n if (!payload) {\n throw new Error_js_1.ArgumentNullError(\"payload\");\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (messageType === ConnectionMessage_js_1.MessageType.Binary && Object.getPrototypeOf(payload).constructor.name !== \"ArrayBuffer\") {\n throw new Error_js_1.InvalidOperationError(\"Payload must be ArrayBuffer\");\n }\n if (messageType === ConnectionMessage_js_1.MessageType.Text && !(typeof (payload) === \"string\")) {\n throw new Error_js_1.InvalidOperationError(\"Payload must be a string\");\n }\n this.privMessageType = messageType;\n this.privPayload = payload;\n this.privId = id ? id : Guid_js_1.createNoDashGuid();\n }\n get messageType() {\n return this.privMessageType;\n }\n get payload() {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.privPayload;\n }\n get textContent() {\n if (this.privMessageType === ConnectionMessage_js_1.MessageType.Binary) {\n throw new Error_js_1.InvalidOperationError(\"Not supported for binary message\");\n }\n return this.privPayload;\n }\n get binaryContent() {\n if (this.privMessageType === ConnectionMessage_js_1.MessageType.Text) {\n throw new Error_js_1.InvalidOperationError(\"Not supported for text message\");\n }\n return this.privPayload;\n }\n get id() {\n return this.privId;\n }\n}\nexports.RawWebsocketMessage = RawWeb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