{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.WsClient = exports.subprotocolsV3 = exports.subprotocolsV2 = void 0;\nconst client_js_1 = require(\"../client.js\");\nconst index_js_1 = require(\"../encoding/index.js\");\nconst errors_js_1 = require(\"../errors.js\");\nconst id_alloc_js_1 = require(\"../id_alloc.js\");\nconst result_js_1 = require(\"../result.js\");\nconst sql_js_1 = require(\"../sql.js\");\nconst util_js_1 = require(\"../util.js\");\nconst stream_js_1 = require(\"./stream.js\");\nconst json_encode_js_1 = require(\"./json_encode.js\");\nconst protobuf_encode_js_1 = require(\"./protobuf_encode.js\");\nconst json_decode_js_1 = require(\"./json_decode.js\");\nconst protobuf_decode_js_1 = require(\"./protobuf_decode.js\");\nexports.subprotocolsV2 = new Map([[\"hrana2\", {\n version: 2,\n encoding: \"json\"\n}], [\"hrana1\", {\n version: 1,\n encoding: \"json\"\n}]]);\nexports.subprotocolsV3 = new Map([[\"hrana3-protobuf\", {\n version: 3,\n encoding: \"protobuf\"\n}], [\"hrana3\", {\n version: 3,\n encoding: \"json\"\n}], [\"hrana2\", {\n version: 2,\n encoding: \"json\"\n}], [\"hrana1\", {\n version: 1,\n encoding: \"json\"\n}]]);\n/** A client for the Hrana protocol over a WebSocket. */\nclass WsClient extends client_js_1.Client {\n #socket;\n // List of callbacks that we queue until the socket transitions from the CONNECTING to the OPEN state.\n #openCallbacks;\n // Have we already transitioned from CONNECTING to OPEN and fired the callbacks in #openCallbacks?\n #opened;\n // Stores the error that caused us to close the client (and the socket). If we are not closed, this is\n // `undefined`.\n #closed;\n // Have we received a response to our \"hello\" from the server?\n #recvdHello;\n // Subprotocol negotiated with the server. It is only available after the socket transitions to the OPEN\n // state.\n #subprotocol;\n // Has the `getVersion()` function been called? This is only used to validate that the API is used\n // correctly.\n #getVersionCalled;\n // A map from request id to the responses that we expect to receive from the server.\n #responseMap;\n // An allocator of request ids.\n #requestIdAlloc;\n // An allocator of stream ids.\n /** @private */\n _streamIdAlloc;\n // An allocator of cursor ids.\n /** @private */\n _cursorIdAlloc;\n // An allocator of SQL text ids.\n #sqlIdAlloc;\n /** @private */\n constructor(socket, jwt) {\n super();\n this.#socket = socket;\n this.#openCallbacks = [];\n this.#opened = false;\n this.#closed = undefined;\n this.#recvdHello = false;\n this.#subprotocol = undefined;\n this.#getVersionCalled = false;\n this.#responseMap = new Map();\n this.#requestIdAlloc = new id_alloc_js_1.IdAlloc();\n this._streamIdAlloc = new id_alloc_js_1.IdAlloc();\n this._cursorIdAlloc = new id_alloc_js_1.IdAlloc();\n this.#sqlIdAlloc = new id_alloc_js_1.IdAlloc();\n this.#socket.binaryType = \"arraybuffer\";\n this.#socket.addEventListener(\"open\", () => this.#onSocketOpen());\n this.#socket.addEventListener(\"close\", event => this.#onSocketClose(event));\n this.#socket.addEventListener(\"error\", event => this.#onSocketError(event));\n this.#socket.addEventListener(\"message\", event => this.#onSocketMessage(event));\n this.#send({\n type: \"hello\",\n jwt\n });\n }\n // Send (or enqueue to send) a message to the server.\n #send(msg) {\n if (this.#closed !== undefined) {\n throw new errors_js_1.InternalError(\"Trying to send a message on a closed client\");\n }\n if (this.#opened) {\n this.#sendToSocket(msg);\n } else {\n const openCallback = () => this.#sendToSocket(msg);\n const errorCallback = () => undefined;\n this.#openCallbacks.push({\n openCallback,\n errorCallback\n });\n }\n }\n // The socket transitioned from CONNECTING to OPEN\n #onSocketOpen() {\n const protocol = this.#socket.protocol;\n if (protocol === undefined) {\n this.#setClosed(new errors_js_1.ClientError(\"The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket \" + \"implementation provided by the environment is broken. If you are using Miniflare 2, \" + \"please update to Miniflare 3, which fixes this problem.\"));\n return;\n } else if (protocol === \"\") {\n this.#subprotocol = {\n version: 1,\n encoding: \"json\"\n };\n } else {\n this.#subprotocol = exports.subprotocolsV3.get(protocol);\n if (this.#subprotocol === undefined) {\n this.#setClosed(new errors_js_1.ProtoError(`Unrecognized WebSocket subprotocol: ${JSON.stringify(protocol)}`));\n return;\n }\n }\n for (const callbacks of this.#openCallbacks) {\n callbacks.openCallback();\n }\n this.#openCallbacks.length = 0;\n this.#opened = true;\n }\n #sendToSocket(msg) {\n const encoding = this.#subprotocol.encoding;\n if (encoding === \"json\") {\n const jsonMsg = (0, index_js_1.writeJsonObject)(msg, json_encode_js_1.ClientMsg);\n this.#socket.send(jsonMsg);\n } else if (encoding === \"protobuf\") {\n const protobufMsg = (0, index_js_1.writeProtobufMessage)(msg, protobuf_encode_js_1.ClientMsg);\n this.#socket.send(protobufMsg);\n } else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n }\n /** Get the protocol version negotiated with the server, possibly waiting until the socket is open. */\n getVersion() {\n return new Promise((versionCallback, errorCallback) => {\n this.#getVersionCalled = true;\n if (this.#closed !== undefined) {\n errorCallback(this.#closed);\n } else if (!this.#opened) {\n const openCallback = () => versionCallback(this.#subprotocol.version);\n this.#openCallbacks.push({\n openCallback,\n errorCallback\n });\n } else {\n versionCallback(this.#subprotocol.version);\n }\n });\n }\n // Make sure that the negotiated version is at least `minVersion`.\n /** @private */\n _ensureVersion(minVersion, feature) {\n if (this.#subprotocol === undefined || !this.#getVersionCalled) {\n throw new errors_js_1.ProtocolVersionError(`${feature} is supported only on protocol version ${minVersion} and higher, ` + \"but the version supported by the WebSocket server is not yet known. \" + \"Use Client.getVersion() to wait until the version is available.\");\n } else if (this.#subprotocol.version < minVersion) {\n throw new errors_js_1.ProtocolVersionError(`${feature} is supported on protocol version ${minVersion} and higher, ` + `but the WebSocket server only supports version ${this.#subprotocol.version}`);\n }\n }\n // Send a request to the server and invoke a callback when we get the response.\n /** @private */\n _sendRequest(request, callbacks) {\n if (this.#closed !== undefined) {\n callbacks.errorCallback(new errors_js_1.ClosedError(\"Client is closed\", this.#closed));\n return;\n }\n const requestId = this.#requestIdAlloc.alloc();\n this.#responseMap.set(requestId, {\n ...callbacks,\n type: request.type\n });\n this.#send({\n type: \"request\",\n requestId,\n request\n });\n }\n // The socket encountered an error.\n #onSocketError(event) {\n const eventMessage = event.message;\n const message = eventMessage ?? \"WebSocket was closed due to an error\";\n this.#setClosed(new errors_js_1.WebSocketError(message));\n }\n // The socket was closed.\n #onSocketClose(event) {\n let message = `WebSocket was closed with code ${event.code}`;\n if (event.reason) {\n message += `: ${event.reason}`;\n }\n this.#setClosed(new errors_js_1.WebSocketError(message));\n }\n // Close the client with the given error.\n #setClosed(error) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#closed = error;\n for (const callbacks of this.#openCallbacks) {\n callbacks.errorCallback(error);\n }\n this.#openCallbacks.length = 0;\n for (const [requestId, responseState] of this.#responseMap.entries()) {\n responseState.errorCallback(error);\n this.#requestIdAlloc.free(requestId);\n }\n this.#responseMap.clear();\n this.#socket.close();\n }\n // We received a message from the socket.\n #onSocketMessage(event) {\n if (this.#closed !== undefined) {\n return;\n }\n try {\n let msg;\n const encoding = this.#subprotocol.encoding;\n if (encoding === \"json\") {\n if (typeof event.data !== \"string\") {\n this.#socket.close(3003, \"Only text messages are accepted with JSON encoding\");\n this.#setClosed(new errors_js_1.ProtoError(\"Received non-text message from server with JSON encoding\"));\n return;\n }\n msg = (0, index_js_1.readJsonObject)(JSON.parse(event.data), json_decode_js_1.ServerMsg);\n } else if (encoding === \"protobuf\") {\n if (!(event.data instanceof ArrayBuffer)) {\n this.#socket.close(3003, \"Only binary messages are accepted with Protobuf encoding\");\n this.#setClosed(new errors_js_1.ProtoError(\"Received non-binary message from server with Protobuf encoding\"));\n return;\n }\n msg = (0, index_js_1.readProtobufMessage)(new Uint8Array(event.data), protobuf_decode_js_1.ServerMsg);\n } else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n this.#handleMsg(msg);\n } catch (e) {\n this.#socket.close(3007, \"Could not handle message\");\n this.#setClosed(e);\n }\n }\n // Handle a message from the server.\n #handleMsg(msg) {\n if (msg.type === \"none\") {\n throw new errors_js_1.ProtoError(\"Received an unrecognized ServerMsg\");\n } else if (msg.type === \"hello_ok\" || msg.type === \"hello_error\") {\n if (this.#recvdHello) {\n throw new errors_js_1.ProtoError(\"Received a duplicated hello response\");\n }\n this.#recvdHello = true;\n if (msg.type === \"hello_error\") {\n throw (0, result_js_1.errorFromProto)(msg.error);\n }\n return;\n } else if (!this.#recvdHello) {\n throw new errors_js_1.ProtoError(\"Received a non-hello message before a hello response\");\n }\n if (msg.type === \"response_ok\") {\n const requestId = msg.requestId;\n const responseState = this.#responseMap.get(requestId);\n this.#responseMap.delete(requestId);\n if (responseState === undefined) {\n throw new errors_js_1.ProtoError(\"Received unexpected OK response\");\n }\n this.#requestIdAlloc.free(requestId);\n try {\n if (responseState.type !== msg.response.type) {\n console.dir({\n responseState,\n msg\n });\n throw new errors_js_1.ProtoError(\"Received unexpected type of response\");\n }\n responseState.responseCallback(msg.response);\n } catch (e) {\n responseState.errorCallback(e);\n throw e;\n }\n } else if (msg.type === \"response_error\") {\n const requestId = msg.requestId;\n const responseState = this.#responseMap.get(requestId);\n this.#responseMap.delete(requestId);\n if (responseState === undefined) {\n throw new errors_js_1.ProtoError(\"Received unexpected error response\");\n }\n this.#requestIdAlloc.free(requestId);\n responseState.errorCallback((0, result_js_1.errorFromProto)(msg.error));\n } else {\n throw (0, util_js_1.impossible)(msg, \"Impossible ServerMsg type\");\n }\n }\n /** Open a {@link WsStream}, a stream for executing SQL statements. */\n openStream() {\n return stream_js_1.WsStream.open(this);\n }\n /** Cache a SQL text on the server. This requires protocol version 2 or higher. */\n storeSql(sql) {\n this._ensureVersion(2, \"storeSql()\");\n const sqlId = this.#sqlIdAlloc.alloc();\n const sqlObj = new sql_js_1.Sql(this, sqlId);\n const responseCallback = () => undefined;\n const errorCallback = e => sqlObj._setClosed(e);\n const request = {\n type: \"store_sql\",\n sqlId,\n sql\n };\n this._sendRequest(request, {\n responseCallback,\n errorCallback\n });\n return sqlObj;\n }\n /** @private */\n _closeSql(sqlId) {\n if (this.#closed !== undefined) {\n return;\n }\n const responseCallback = () => this.#sqlIdAlloc.free(sqlId);\n const errorCallback = e => this.#setClosed(e);\n const request = {\n type: \"close_sql\",\n sqlId\n };\n this._sendRequest(request, {\n responseCallback,\n errorCallback\n });\n }\n /** Close the client and the WebSocket. */\n close() {\n this.#setClosed(new errors_js_1.ClientError(\"Client was manually closed\"));\n }\n /** True if the client is closed. */\n get closed() {\n return this.#closed !== undefined;\n }\n}\nexports.WsClient = WsClient;","map":{"version":3,"names":["Object","defineProperty","exports","value","WsClient","subprotocolsV3","subprotocolsV2","client_js_1","require","index_js_1","errors_js_1","id_alloc_js_1","result_js_1","sql_js_1","util_js_1","stream_js_1","json_encode_js_1","protobuf_encode_js_1","json_decode_js_1","protobuf_decode_js_1","Map","version","encoding","Client","socket","openCallbacks","opened","closed","recvdHello","subprotocol","getVersionCalled","responseMap","requestIdAlloc","_streamIdAlloc","_cursorIdAlloc","sqlIdAlloc","constructor","jwt","undefined","IdAlloc","binaryType","addEventListener","onSocketOpen","event","onSocketClose","onSocketError","onSocketMessage","send","type","#send","msg","InternalError","sendToSocket","openCallback","errorCallback","push","#onSocketOpen","protocol","setClosed","ClientError","get","ProtoError","JSON","stringify","callbacks","length","#sendToSocket","jsonMsg","writeJsonObject","ClientMsg","protobufMsg","writeProtobufMessage","impossible","getVersion","Promise","versionCallback","_ensureVersion","minVersion","feature","ProtocolVersionError","_sendRequest","request","ClosedError","requestId","alloc","set","#onSocketError","eventMessage","message","WebSocketError","#onSocketClose","code","reason","#setClosed","error","responseState","entries","free","clear","close","#onSocketMessage","data","readJsonObject","parse","ServerMsg","ArrayBuffer","readProtobufMessage","Uint8Array","handleMsg","e","#handleMsg","errorFromProto","delete","response","console","dir","responseCallback","openStream","WsStream","open","storeSql","sql","sqlId","sqlObj","Sql","_setClosed","_closeSql"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/ws/client.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.WsClient = exports.subprotocolsV3 = exports.subprotocolsV2 = void 0;\nconst client_js_1 = require(\"../client.js\");\nconst index_js_1 = require(\"../encoding/index.js\");\nconst errors_js_1 = require(\"../errors.js\");\nconst id_alloc_js_1 = require(\"../id_alloc.js\");\nconst result_js_1 = require(\"../result.js\");\nconst sql_js_1 = require(\"../sql.js\");\nconst util_js_1 = require(\"../util.js\");\nconst stream_js_1 = require(\"./stream.js\");\nconst json_encode_js_1 = require(\"./json_encode.js\");\nconst protobuf_encode_js_1 = require(\"./protobuf_encode.js\");\nconst json_decode_js_1 = require(\"./json_decode.js\");\nconst protobuf_decode_js_1 = require(\"./protobuf_decode.js\");\nexports.subprotocolsV2 = new Map([\n [\"hrana2\", { version: 2, encoding: \"json\" }],\n [\"hrana1\", { version: 1, encoding: \"json\" }],\n]);\nexports.subprotocolsV3 = new Map([\n [\"hrana3-protobuf\", { version: 3, encoding: \"protobuf\" }],\n [\"hrana3\", { version: 3, encoding: \"json\" }],\n [\"hrana2\", { version: 2, encoding: \"json\" }],\n [\"hrana1\", { version: 1, encoding: \"json\" }],\n]);\n/** A client for the Hrana protocol over a WebSocket. */\nclass WsClient extends client_js_1.Client {\n #socket;\n // List of callbacks that we queue until the socket transitions from the CONNECTING to the OPEN state.\n #openCallbacks;\n // Have we already transitioned from CONNECTING to OPEN and fired the callbacks in #openCallbacks?\n #opened;\n // Stores the error that caused us to close the client (and the socket). If we are not closed, this is\n // `undefined`.\n #closed;\n // Have we received a response to our \"hello\" from the server?\n #recvdHello;\n // Subprotocol negotiated with the server. It is only available after the socket transitions to the OPEN\n // state.\n #subprotocol;\n // Has the `getVersion()` function been called? This is only used to validate that the API is used\n // correctly.\n #getVersionCalled;\n // A map from request id to the responses that we expect to receive from the server.\n #responseMap;\n // An allocator of request ids.\n #requestIdAlloc;\n // An allocator of stream ids.\n /** @private */\n _streamIdAlloc;\n // An allocator of cursor ids.\n /** @private */\n _cursorIdAlloc;\n // An allocator of SQL text ids.\n #sqlIdAlloc;\n /** @private */\n constructor(socket, jwt) {\n super();\n this.#socket = socket;\n this.#openCallbacks = [];\n this.#opened = false;\n this.#closed = undefined;\n this.#recvdHello = false;\n this.#subprotocol = undefined;\n this.#getVersionCalled = false;\n this.#responseMap = new Map();\n this.#requestIdAlloc = new id_alloc_js_1.IdAlloc();\n this._streamIdAlloc = new id_alloc_js_1.IdAlloc();\n this._cursorIdAlloc = new id_alloc_js_1.IdAlloc();\n this.#sqlIdAlloc = new id_alloc_js_1.IdAlloc();\n this.#socket.binaryType = \"arraybuffer\";\n this.#socket.addEventListener(\"open\", () => this.#onSocketOpen());\n this.#socket.addEventListener(\"close\", (event) => this.#onSocketClose(event));\n this.#socket.addEventListener(\"error\", (event) => this.#onSocketError(event));\n this.#socket.addEventListener(\"message\", (event) => this.#onSocketMessage(event));\n this.#send({ type: \"hello\", jwt });\n }\n // Send (or enqueue to send) a message to the server.\n #send(msg) {\n if (this.#closed !== undefined) {\n throw new errors_js_1.InternalError(\"Trying to send a message on a closed client\");\n }\n if (this.#opened) {\n this.#sendToSocket(msg);\n }\n else {\n const openCallback = () => this.#sendToSocket(msg);\n const errorCallback = () => undefined;\n this.#openCallbacks.push({ openCallback, errorCallback });\n }\n }\n // The socket transitioned from CONNECTING to OPEN\n #onSocketOpen() {\n const protocol = this.#socket.protocol;\n if (protocol === undefined) {\n this.#setClosed(new errors_js_1.ClientError(\"The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket \" +\n \"implementation provided by the environment is broken. If you are using Miniflare 2, \" +\n \"please update to Miniflare 3, which fixes this problem.\"));\n return;\n }\n else if (protocol === \"\") {\n this.#subprotocol = { version: 1, encoding: \"json\" };\n }\n else {\n this.#subprotocol = exports.subprotocolsV3.get(protocol);\n if (this.#subprotocol === undefined) {\n this.#setClosed(new errors_js_1.ProtoError(`Unrecognized WebSocket subprotocol: ${JSON.stringify(protocol)}`));\n return;\n }\n }\n for (const callbacks of this.#openCallbacks) {\n callbacks.openCallback();\n }\n this.#openCallbacks.length = 0;\n this.#opened = true;\n }\n #sendToSocket(msg) {\n const encoding = this.#subprotocol.encoding;\n if (encoding === \"json\") {\n const jsonMsg = (0, index_js_1.writeJsonObject)(msg, json_encode_js_1.ClientMsg);\n this.#socket.send(jsonMsg);\n }\n else if (encoding === \"protobuf\") {\n const protobufMsg = (0, index_js_1.writeProtobufMessage)(msg, protobuf_encode_js_1.ClientMsg);\n this.#socket.send(protobufMsg);\n }\n else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n }\n /** Get the protocol version negotiated with the server, possibly waiting until the socket is open. */\n getVersion() {\n return new Promise((versionCallback, errorCallback) => {\n this.#getVersionCalled = true;\n if (this.#closed !== undefined) {\n errorCallback(this.#closed);\n }\n else if (!this.#opened) {\n const openCallback = () => versionCallback(this.#subprotocol.version);\n this.#openCallbacks.push({ openCallback, errorCallback });\n }\n else {\n versionCallback(this.#subprotocol.version);\n }\n });\n }\n // Make sure that the negotiated version is at least `minVersion`.\n /** @private */\n _ensureVersion(minVersion, feature) {\n if (this.#subprotocol === undefined || !this.#getVersionCalled) {\n throw new errors_js_1.ProtocolVersionError(`${feature} is supported only on protocol version ${minVersion} and higher, ` +\n \"but the version supported by the WebSocket server is not yet known. \" +\n \"Use Client.getVersion() to wait until the version is available.\");\n }\n else if (this.#subprotocol.version < minVersion) {\n throw new errors_js_1.ProtocolVersionError(`${feature} is supported on protocol version ${minVersion} and higher, ` +\n `but the WebSocket server only supports version ${this.#subprotocol.version}`);\n }\n }\n // Send a request to the server and invoke a callback when we get the response.\n /** @private */\n _sendRequest(request, callbacks) {\n if (this.#closed !== undefined) {\n callbacks.errorCallback(new errors_js_1.ClosedError(\"Client is closed\", this.#closed));\n return;\n }\n const requestId = this.#requestIdAlloc.alloc();\n this.#responseMap.set(requestId, { ...callbacks, type: request.type });\n this.#send({ type: \"request\", requestId, request });\n }\n // The socket encountered an error.\n #onSocketError(event) {\n const eventMessage = event.message;\n const message = eventMessage ?? \"WebSocket was closed due to an error\";\n this.#setClosed(new errors_js_1.WebSocketError(message));\n }\n // The socket was closed.\n #onSocketClose(event) {\n let message = `WebSocket was closed with code ${event.code}`;\n if (event.reason) {\n message += `: ${event.reason}`;\n }\n this.#setClosed(new errors_js_1.WebSocketError(message));\n }\n // Close the client with the given error.\n #setClosed(error) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#closed = error;\n for (const callbacks of this.#openCallbacks) {\n callbacks.errorCallback(error);\n }\n this.#openCallbacks.length = 0;\n for (const [requestId, responseState] of this.#responseMap.entries()) {\n responseState.errorCallback(error);\n this.#requestIdAlloc.free(requestId);\n }\n this.#responseMap.clear();\n this.#socket.close();\n }\n // We received a message from the socket.\n #onSocketMessage(event) {\n if (this.#closed !== undefined) {\n return;\n }\n try {\n let msg;\n const encoding = this.#subprotocol.encoding;\n if (encoding === \"json\") {\n if (typeof event.data !== \"string\") {\n this.#socket.close(3003, \"Only text messages are accepted with JSON encoding\");\n this.#setClosed(new errors_js_1.ProtoError(\"Received non-text message from server with JSON encoding\"));\n return;\n }\n msg = (0, index_js_1.readJsonObject)(JSON.parse(event.data), json_decode_js_1.ServerMsg);\n }\n else if (encoding === \"protobuf\") {\n if (!(event.data instanceof ArrayBuffer)) {\n this.#socket.close(3003, \"Only binary messages are accepted with Protobuf encoding\");\n this.#setClosed(new errors_js_1.ProtoError(\"Received non-binary message from server with Protobuf encoding\"));\n return;\n }\n msg = (0, index_js_1.readProtobufMessage)(new Uint8Array(event.data), protobuf_decode_js_1.ServerMsg);\n }\n else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n this.#handleMsg(msg);\n }\n catch (e) {\n this.#socket.close(3007, \"Could not handle message\");\n this.#setClosed(e);\n }\n }\n // Handle a message from the server.\n #handleMsg(msg) {\n if (msg.type === \"none\") {\n throw new errors_js_1.ProtoError(\"Received an unrecognized ServerMsg\");\n }\n else if (msg.type === \"hello_ok\" || msg.type === \"hello_error\") {\n if (this.#recvdHello) {\n throw new errors_js_1.ProtoError(\"Received a duplicated hello response\");\n }\n this.#recvdHello = true;\n if (msg.type === \"hello_error\") {\n throw (0, result_js_1.errorFromProto)(msg.error);\n }\n return;\n }\n else if (!this.#recvdHello) {\n throw new errors_js_1.ProtoError(\"Received a non-hello message before a hello response\");\n }\n if (msg.type === \"response_ok\") {\n const requestId = msg.requestId;\n const responseState = this.#responseMap.get(requestId);\n this.#responseMap.delete(requestId);\n if (responseState === undefined) {\n throw new errors_js_1.ProtoError(\"Received unexpected OK response\");\n }\n this.#requestIdAlloc.free(requestId);\n try {\n if (responseState.type !== msg.response.type) {\n console.dir({ responseState, msg });\n throw new errors_js_1.ProtoError(\"Received unexpected type of response\");\n }\n responseState.responseCallback(msg.response);\n }\n catch (e) {\n responseState.errorCallback(e);\n throw e;\n }\n }\n else if (msg.type === \"response_error\") {\n const requestId = msg.requestId;\n const responseState = this.#responseMap.get(requestId);\n this.#responseMap.delete(requestId);\n if (responseState === undefined) {\n throw new errors_js_1.ProtoError(\"Received unexpected error response\");\n }\n this.#requestIdAlloc.free(requestId);\n responseState.errorCallback((0, result_js_1.errorFromProto)(msg.error));\n }\n else {\n throw (0, util_js_1.impossible)(msg, \"Impossible ServerMsg type\");\n }\n }\n /** Open a {@link WsStream}, a stream for executing SQL statements. */\n openStream() {\n return stream_js_1.WsStream.open(this);\n }\n /** Cache a SQL text on the server. This requires protocol version 2 or higher. */\n storeSql(sql) {\n this._ensureVersion(2, \"storeSql()\");\n const sqlId = this.#sqlIdAlloc.alloc();\n const sqlObj = new sql_js_1.Sql(this, sqlId);\n const responseCallback = () => undefined;\n const errorCallback = (e) => sqlObj._setClosed(e);\n const request = { type: \"store_sql\", sqlId, sql };\n this._sendRequest(request, { responseCallback, errorCallback });\n return sqlObj;\n }\n /** @private */\n _closeSql(sqlId) {\n if (this.#closed !== undefined) {\n return;\n }\n const responseCallback = () => this.#sqlIdAlloc.free(sqlId);\n const errorCallback = (e) => this.#setClosed(e);\n const request = { type: \"close_sql\", sqlId };\n this._sendRequest(request, { responseCallback, errorCallback });\n }\n /** Close the client and the WebSocket. */\n close() {\n this.#setClosed(new errors_js_1.ClientError(\"Client was manually closed\"));\n }\n /** True if the client is closed. */\n get closed() {\n return this.#closed !== undefined;\n }\n}\nexports.WsClient = WsClient;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,QAAQ,GAAGF,OAAO,CAACG,cAAc,GAAGH,OAAO,CAACI,cAAc,GAAG,KAAK,CAAC;AAC3E,MAAMC,WAAW,GAAGC,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAMC,UAAU,GAAGD,OAAO,CAAC,sBAAsB,CAAC;AAClD,MAAME,WAAW,GAAGF,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAMG,aAAa,GAAGH,OAAO,CAAC,gBAAgB,CAAC;AAC/C,MAAMI,WAAW,GAAGJ,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAMK,QAAQ,GAAGL,OAAO,CAAC,WAAW,CAAC;AACrC,MAAMM,SAAS,GAAGN,OAAO,CAAC,YAAY,CAAC;AACvC,MAAMO,WAAW,GAAGP,OAAO,CAAC,aAAa,CAAC;AAC1C,MAAMQ,gBAAgB,GAAGR,OAAO,CAAC,kBAAkB,CAAC;AACpD,MAAMS,oBAAoB,GAAGT,OAAO,CAAC,sBAAsB,CAAC;AAC5D,MAAMU,gBAAgB,GAAGV,OAAO,CAAC,kBAAkB,CAAC;AACpD,MAAMW,oBAAoB,GAAGX,OAAO,CAAC,sBAAsB,CAAC;AAC5DN,OAAO,CAACI,cAAc,GAAG,IAAIc,GAAG,CAAC,CAC7B,CAAC,QAAQ,EAAE;EAAEC,OAAO,EAAE,CAAC;EAAEC,QAAQ,EAAE;AAAO,CAAC,CAAC,EAC5C,CAAC,QAAQ,EAAE;EAAED,OAAO,EAAE,CAAC;EAAEC,QAAQ,EAAE;AAAO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