1 line
42 KiB
JSON
1 line
42 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = {\n enumerable: true,\n get: function () {\n return m[k];\n }\n };\n }\n Object.defineProperty(o, k2, desc);\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\nvar __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {\n Object.defineProperty(o, \"default\", {\n enumerable: true,\n value: v\n });\n} : function (o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = this && this.__importStar || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.WsTransaction = exports.WsClient = exports._createClient = exports.createClient = void 0;\nconst hrana = __importStar(require(\"@libsql/hrana-client\"));\nconst api_1 = require(\"@libsql/core/api\");\nconst config_1 = require(\"@libsql/core/config\");\nconst hrana_js_1 = require(\"./hrana.js\");\nconst sql_cache_js_1 = require(\"./sql_cache.js\");\nconst uri_1 = require(\"@libsql/core/uri\");\nconst util_1 = require(\"@libsql/core/util\");\nconst promise_limit_1 = __importDefault(require(\"promise-limit\"));\n__exportStar(require(\"@libsql/core/api\"), exports);\nfunction createClient(config) {\n return _createClient((0, config_1.expandConfig)(config, false));\n}\nexports.createClient = createClient;\n/** @private */\nfunction _createClient(config) {\n if (config.scheme !== \"wss\" && config.scheme !== \"ws\") {\n throw new api_1.LibsqlError('The WebSocket client supports only \"libsql:\", \"wss:\" and \"ws:\" URLs, ' + `got ${JSON.stringify(config.scheme + \":\")}. For more information, please read ${util_1.supportedUrlLink}`, \"URL_SCHEME_NOT_SUPPORTED\");\n }\n if (config.encryptionKey !== undefined) {\n throw new api_1.LibsqlError(\"Encryption key is not supported by the remote client.\", \"ENCRYPTION_KEY_NOT_SUPPORTED\");\n }\n if (config.scheme === \"ws\" && config.tls) {\n throw new api_1.LibsqlError(`A \"ws:\" URL cannot opt into TLS by using ?tls=1`, \"URL_INVALID\");\n } else if (config.scheme === \"wss\" && !config.tls) {\n throw new api_1.LibsqlError(`A \"wss:\" URL cannot opt out of TLS by using ?tls=0`, \"URL_INVALID\");\n }\n const url = (0, uri_1.encodeBaseUrl)(config.scheme, config.authority, config.path);\n let client;\n try {\n client = hrana.openWs(url, config.authToken);\n } catch (e) {\n if (e instanceof hrana.WebSocketUnsupportedError) {\n const suggestedScheme = config.scheme === \"wss\" ? \"https\" : \"http\";\n const suggestedUrl = (0, uri_1.encodeBaseUrl)(suggestedScheme, config.authority, config.path);\n throw new api_1.LibsqlError(\"This environment does not support WebSockets, please switch to the HTTP client by using \" + `a \"${suggestedScheme}:\" URL (${JSON.stringify(suggestedUrl)}). ` + `For more information, please read ${util_1.supportedUrlLink}`, \"WEBSOCKETS_NOT_SUPPORTED\");\n }\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n return new WsClient(client, url, config.authToken, config.intMode, config.concurrency);\n}\nexports._createClient = _createClient;\nconst maxConnAgeMillis = 60 * 1000;\nconst sqlCacheCapacity = 100;\nclass WsClient {\n #url;\n #authToken;\n #intMode;\n // State of the current connection. The `hrana.WsClient` inside may be closed at any moment due to an\n // asynchronous error.\n #connState;\n // If defined, this is a connection that will be used in the future, once it is ready.\n #futureConnState;\n closed;\n protocol;\n #isSchemaDatabase;\n #promiseLimitFunction;\n /** @private */\n constructor(client, url, authToken, intMode, concurrency) {\n this.#url = url;\n this.#authToken = authToken;\n this.#intMode = intMode;\n this.#connState = this.#openConn(client);\n this.#futureConnState = undefined;\n this.closed = false;\n this.protocol = \"ws\";\n this.#promiseLimitFunction = (0, promise_limit_1.default)(concurrency);\n }\n async limit(fn) {\n return this.#promiseLimitFunction(fn);\n }\n async execute(stmtOrSql, args) {\n let stmt;\n if (typeof stmtOrSql === \"string\") {\n stmt = {\n sql: stmtOrSql,\n args: args || []\n };\n } else {\n stmt = stmtOrSql;\n }\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmt = (0, hrana_js_1.stmtToHrana)(stmt);\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n streamState.conn.sqlCache.apply([hranaStmt]);\n const hranaRowsPromise = streamState.stream.query(hranaStmt);\n streamState.stream.closeGracefully();\n const hranaRowsResult = await hranaRowsPromise;\n return (0, hrana_js_1.resultSetFromHrana)(hranaRowsResult);\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n } finally {\n this._closeStream(streamState);\n }\n });\n }\n async batch(stmts, mode = \"deferred\") {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);\n const version = await streamState.conn.client.getVersion();\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n streamState.conn.sqlCache.apply(hranaStmts);\n const batch = streamState.stream.batch(version >= 3);\n const resultsPromise = (0, hrana_js_1.executeHranaBatch)(mode, version, batch, hranaStmts);\n const results = await resultsPromise;\n return results;\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n } finally {\n this._closeStream(streamState);\n }\n });\n }\n async migrate(stmts) {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);\n const version = await streamState.conn.client.getVersion();\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n const batch = streamState.stream.batch(version >= 3);\n const resultsPromise = (0, hrana_js_1.executeHranaBatch)(\"deferred\", version, batch, hranaStmts, true);\n const results = await resultsPromise;\n return results;\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n } finally {\n this._closeStream(streamState);\n }\n });\n }\n async transaction(mode = \"write\") {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const version = await streamState.conn.client.getVersion();\n // the BEGIN statement will be batched with the first statement on the transaction to save a\n // network roundtrip\n return new WsTransaction(this, streamState, mode, version);\n } catch (e) {\n this._closeStream(streamState);\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n });\n }\n async executeMultiple(sql) {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n const promise = streamState.stream.sequence(sql);\n streamState.stream.closeGracefully();\n await promise;\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n } finally {\n this._closeStream(streamState);\n }\n });\n }\n sync() {\n throw new api_1.LibsqlError(\"sync not supported in ws mode\", \"SYNC_NOT_SUPPORTED\");\n }\n async #openStream() {\n if (this.closed) {\n throw new api_1.LibsqlError(\"The client is closed\", \"CLIENT_CLOSED\");\n }\n const now = new Date();\n const ageMillis = now.valueOf() - this.#connState.openTime.valueOf();\n if (ageMillis > maxConnAgeMillis && this.#futureConnState === undefined) {\n // The existing connection is too old, let's open a new one.\n const futureConnState = this.#openConn();\n this.#futureConnState = futureConnState;\n // However, if we used `futureConnState` immediately, we would introduce additional latency,\n // because we would have to wait for the WebSocket handshake to complete, even though we may a\n // have perfectly good existing connection in `this.#connState`!\n //\n // So we wait until the `hrana.Client.getVersion()` operation completes (which happens when the\n // WebSocket hanshake completes), and only then we replace `this.#connState` with\n // `futureConnState`, which is stored in `this.#futureConnState` in the meantime.\n futureConnState.client.getVersion().then(_version => {\n if (this.#connState !== futureConnState) {\n // We need to close `this.#connState` before we replace it. However, it is possible\n // that `this.#connState` has already been replaced: see the code below.\n if (this.#connState.streamStates.size === 0) {\n this.#connState.client.close();\n } else {\n // If there are existing streams on the connection, we must not close it, because\n // these streams would be broken. The last stream to be closed will also close the\n // connection in `_closeStream()`.\n }\n }\n this.#connState = futureConnState;\n this.#futureConnState = undefined;\n }, _e => {\n // If the new connection could not be established, let's just ignore the error and keep\n // using the existing connection.\n this.#futureConnState = undefined;\n });\n }\n if (this.#connState.client.closed) {\n // An error happened on this connection and it has been closed. Let's try to seamlessly reconnect.\n try {\n if (this.#futureConnState !== undefined) {\n // We are already in the process of opening a new connection, so let's just use it\n // immediately.\n this.#connState = this.#futureConnState;\n } else {\n this.#connState = this.#openConn();\n }\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n const connState = this.#connState;\n try {\n // Now we wait for the WebSocket handshake to complete (if it hasn't completed yet). Note that\n // this does not increase latency, because any messages that we would send on the WebSocket before\n // the handshake would be queued until the handshake is completed anyway.\n if (connState.useSqlCache === undefined) {\n connState.useSqlCache = (await connState.client.getVersion()) >= 2;\n if (connState.useSqlCache) {\n connState.sqlCache.capacity = sqlCacheCapacity;\n }\n }\n const stream = connState.client.openStream();\n stream.intMode = this.#intMode;\n const streamState = {\n conn: connState,\n stream\n };\n connState.streamStates.add(streamState);\n return streamState;\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n #openConn(client) {\n try {\n client ??= hrana.openWs(this.#url, this.#authToken);\n return {\n client,\n useSqlCache: undefined,\n sqlCache: new sql_cache_js_1.SqlCache(client, 0),\n openTime: new Date(),\n streamStates: new Set()\n };\n } catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n _closeStream(streamState) {\n streamState.stream.close();\n const connState = streamState.conn;\n connState.streamStates.delete(streamState);\n if (connState.streamStates.size === 0 && connState !== this.#connState) {\n // We are not using this connection anymore and this is the last stream that was using it, so we\n // must close it now.\n connState.client.close();\n }\n }\n close() {\n this.#connState.client.close();\n this.closed = true;\n }\n}\nexports.WsClient = WsClient;\nclass WsTransaction extends hrana_js_1.HranaTransaction {\n #client;\n #streamState;\n /** @private */\n constructor(client, state, mode, version) {\n super(mode, version);\n this.#client = client;\n this.#streamState = state;\n }\n /** @private */\n _getStream() {\n return this.#streamState.stream;\n }\n /** @private */\n _getSqlCache() {\n return this.#streamState.conn.sqlCache;\n }\n close() {\n this.#client._closeStream(this.#streamState);\n }\n get closed() {\n return this.#streamState.stream.closed;\n }\n}\nexports.WsTransaction = WsTransaction;","map":{"version":3,"names":["__createBinding","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__setModuleDefault","v","value","__importStar","mod","result","prototype","hasOwnProperty","call","__exportStar","exports","p","__importDefault","WsTransaction","WsClient","_createClient","createClient","hrana","require","api_1","config_1","hrana_js_1","sql_cache_js_1","uri_1","util_1","promise_limit_1","config","expandConfig","scheme","LibsqlError","JSON","stringify","supportedUrlLink","encryptionKey","tls","url","encodeBaseUrl","authority","path","client","openWs","authToken","e","WebSocketUnsupportedError","suggestedScheme","suggestedUrl","mapHranaError","intMode","concurrency","maxConnAgeMillis","sqlCacheCapacity","connState","futureConnState","closed","protocol","isSchemaDatabase","promiseLimitFunction","constructor","openConn","default","limit","fn","execute","stmtOrSql","args","stmt","sql","streamState","openStream","hranaStmt","stmtToHrana","conn","sqlCache","apply","hranaRowsPromise","stream","query","closeGracefully","hranaRowsResult","resultSetFromHrana","_closeStream","batch","stmts","mode","hranaStmts","map","version","getVersion","resultsPromise","executeHranaBatch","results","migrate","transaction","executeMultiple","promise","sequence","sync","#openStream","now","Date","ageMillis","valueOf","openTime","then","_version","streamStates","size","close","_e","useSqlCache","capacity","add","#openConn","SqlCache","Set","delete","HranaTransaction","state","_getStream","_getSqlCache"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/client/lib-cjs/ws.js"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.WsTransaction = exports.WsClient = exports._createClient = exports.createClient = void 0;\nconst hrana = __importStar(require(\"@libsql/hrana-client\"));\nconst api_1 = require(\"@libsql/core/api\");\nconst config_1 = require(\"@libsql/core/config\");\nconst hrana_js_1 = require(\"./hrana.js\");\nconst sql_cache_js_1 = require(\"./sql_cache.js\");\nconst uri_1 = require(\"@libsql/core/uri\");\nconst util_1 = require(\"@libsql/core/util\");\nconst promise_limit_1 = __importDefault(require(\"promise-limit\"));\n__exportStar(require(\"@libsql/core/api\"), exports);\nfunction createClient(config) {\n return _createClient((0, config_1.expandConfig)(config, false));\n}\nexports.createClient = createClient;\n/** @private */\nfunction _createClient(config) {\n if (config.scheme !== \"wss\" && config.scheme !== \"ws\") {\n throw new api_1.LibsqlError('The WebSocket client supports only \"libsql:\", \"wss:\" and \"ws:\" URLs, ' +\n `got ${JSON.stringify(config.scheme + \":\")}. For more information, please read ${util_1.supportedUrlLink}`, \"URL_SCHEME_NOT_SUPPORTED\");\n }\n if (config.encryptionKey !== undefined) {\n throw new api_1.LibsqlError(\"Encryption key is not supported by the remote client.\", \"ENCRYPTION_KEY_NOT_SUPPORTED\");\n }\n if (config.scheme === \"ws\" && config.tls) {\n throw new api_1.LibsqlError(`A \"ws:\" URL cannot opt into TLS by using ?tls=1`, \"URL_INVALID\");\n }\n else if (config.scheme === \"wss\" && !config.tls) {\n throw new api_1.LibsqlError(`A \"wss:\" URL cannot opt out of TLS by using ?tls=0`, \"URL_INVALID\");\n }\n const url = (0, uri_1.encodeBaseUrl)(config.scheme, config.authority, config.path);\n let client;\n try {\n client = hrana.openWs(url, config.authToken);\n }\n catch (e) {\n if (e instanceof hrana.WebSocketUnsupportedError) {\n const suggestedScheme = config.scheme === \"wss\" ? \"https\" : \"http\";\n const suggestedUrl = (0, uri_1.encodeBaseUrl)(suggestedScheme, config.authority, config.path);\n throw new api_1.LibsqlError(\"This environment does not support WebSockets, please switch to the HTTP client by using \" +\n `a \"${suggestedScheme}:\" URL (${JSON.stringify(suggestedUrl)}). ` +\n `For more information, please read ${util_1.supportedUrlLink}`, \"WEBSOCKETS_NOT_SUPPORTED\");\n }\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n return new WsClient(client, url, config.authToken, config.intMode, config.concurrency);\n}\nexports._createClient = _createClient;\nconst maxConnAgeMillis = 60 * 1000;\nconst sqlCacheCapacity = 100;\nclass WsClient {\n #url;\n #authToken;\n #intMode;\n // State of the current connection. The `hrana.WsClient` inside may be closed at any moment due to an\n // asynchronous error.\n #connState;\n // If defined, this is a connection that will be used in the future, once it is ready.\n #futureConnState;\n closed;\n protocol;\n #isSchemaDatabase;\n #promiseLimitFunction;\n /** @private */\n constructor(client, url, authToken, intMode, concurrency) {\n this.#url = url;\n this.#authToken = authToken;\n this.#intMode = intMode;\n this.#connState = this.#openConn(client);\n this.#futureConnState = undefined;\n this.closed = false;\n this.protocol = \"ws\";\n this.#promiseLimitFunction = (0, promise_limit_1.default)(concurrency);\n }\n async limit(fn) {\n return this.#promiseLimitFunction(fn);\n }\n async execute(stmtOrSql, args) {\n let stmt;\n if (typeof stmtOrSql === \"string\") {\n stmt = {\n sql: stmtOrSql,\n args: args || [],\n };\n }\n else {\n stmt = stmtOrSql;\n }\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmt = (0, hrana_js_1.stmtToHrana)(stmt);\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n streamState.conn.sqlCache.apply([hranaStmt]);\n const hranaRowsPromise = streamState.stream.query(hranaStmt);\n streamState.stream.closeGracefully();\n const hranaRowsResult = await hranaRowsPromise;\n return (0, hrana_js_1.resultSetFromHrana)(hranaRowsResult);\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n finally {\n this._closeStream(streamState);\n }\n });\n }\n async batch(stmts, mode = \"deferred\") {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);\n const version = await streamState.conn.client.getVersion();\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n streamState.conn.sqlCache.apply(hranaStmts);\n const batch = streamState.stream.batch(version >= 3);\n const resultsPromise = (0, hrana_js_1.executeHranaBatch)(mode, version, batch, hranaStmts);\n const results = await resultsPromise;\n return results;\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n finally {\n this._closeStream(streamState);\n }\n });\n }\n async migrate(stmts) {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);\n const version = await streamState.conn.client.getVersion();\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n const batch = streamState.stream.batch(version >= 3);\n const resultsPromise = (0, hrana_js_1.executeHranaBatch)(\"deferred\", version, batch, hranaStmts, true);\n const results = await resultsPromise;\n return results;\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n finally {\n this._closeStream(streamState);\n }\n });\n }\n async transaction(mode = \"write\") {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n const version = await streamState.conn.client.getVersion();\n // the BEGIN statement will be batched with the first statement on the transaction to save a\n // network roundtrip\n return new WsTransaction(this, streamState, mode, version);\n }\n catch (e) {\n this._closeStream(streamState);\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n });\n }\n async executeMultiple(sql) {\n return this.limit(async () => {\n const streamState = await this.#openStream();\n try {\n // Schedule all operations synchronously, so they will be pipelined and executed in a single\n // network roundtrip.\n const promise = streamState.stream.sequence(sql);\n streamState.stream.closeGracefully();\n await promise;\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n finally {\n this._closeStream(streamState);\n }\n });\n }\n sync() {\n throw new api_1.LibsqlError(\"sync not supported in ws mode\", \"SYNC_NOT_SUPPORTED\");\n }\n async #openStream() {\n if (this.closed) {\n throw new api_1.LibsqlError(\"The client is closed\", \"CLIENT_CLOSED\");\n }\n const now = new Date();\n const ageMillis = now.valueOf() - this.#connState.openTime.valueOf();\n if (ageMillis > maxConnAgeMillis &&\n this.#futureConnState === undefined) {\n // The existing connection is too old, let's open a new one.\n const futureConnState = this.#openConn();\n this.#futureConnState = futureConnState;\n // However, if we used `futureConnState` immediately, we would introduce additional latency,\n // because we would have to wait for the WebSocket handshake to complete, even though we may a\n // have perfectly good existing connection in `this.#connState`!\n //\n // So we wait until the `hrana.Client.getVersion()` operation completes (which happens when the\n // WebSocket hanshake completes), and only then we replace `this.#connState` with\n // `futureConnState`, which is stored in `this.#futureConnState` in the meantime.\n futureConnState.client.getVersion().then((_version) => {\n if (this.#connState !== futureConnState) {\n // We need to close `this.#connState` before we replace it. However, it is possible\n // that `this.#connState` has already been replaced: see the code below.\n if (this.#connState.streamStates.size === 0) {\n this.#connState.client.close();\n }\n else {\n // If there are existing streams on the connection, we must not close it, because\n // these streams would be broken. The last stream to be closed will also close the\n // connection in `_closeStream()`.\n }\n }\n this.#connState = futureConnState;\n this.#futureConnState = undefined;\n }, (_e) => {\n // If the new connection could not be established, let's just ignore the error and keep\n // using the existing connection.\n this.#futureConnState = undefined;\n });\n }\n if (this.#connState.client.closed) {\n // An error happened on this connection and it has been closed. Let's try to seamlessly reconnect.\n try {\n if (this.#futureConnState !== undefined) {\n // We are already in the process of opening a new connection, so let's just use it\n // immediately.\n this.#connState = this.#futureConnState;\n }\n else {\n this.#connState = this.#openConn();\n }\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n const connState = this.#connState;\n try {\n // Now we wait for the WebSocket handshake to complete (if it hasn't completed yet). Note that\n // this does not increase latency, because any messages that we would send on the WebSocket before\n // the handshake would be queued until the handshake is completed anyway.\n if (connState.useSqlCache === undefined) {\n connState.useSqlCache =\n (await connState.client.getVersion()) >= 2;\n if (connState.useSqlCache) {\n connState.sqlCache.capacity = sqlCacheCapacity;\n }\n }\n const stream = connState.client.openStream();\n stream.intMode = this.#intMode;\n const streamState = { conn: connState, stream };\n connState.streamStates.add(streamState);\n return streamState;\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n #openConn(client) {\n try {\n client ??= hrana.openWs(this.#url, this.#authToken);\n return {\n client,\n useSqlCache: undefined,\n sqlCache: new sql_cache_js_1.SqlCache(client, 0),\n openTime: new Date(),\n streamStates: new Set(),\n };\n }\n catch (e) {\n throw (0, hrana_js_1.mapHranaError)(e);\n }\n }\n _closeStream(streamState) {\n streamState.stream.close();\n const connState = streamState.conn;\n connState.streamStates.delete(streamState);\n if (connState.streamStates.size === 0 &&\n connState !== this.#connState) {\n // We are not using this connection anymore and this is the last stream that was using it, so we\n // must close it now.\n connState.client.close();\n }\n }\n close() {\n this.#connState.client.close();\n this.closed = true;\n }\n}\nexports.WsClient = WsClient;\nclass WsTransaction extends hrana_js_1.HranaTransaction {\n #client;\n #streamState;\n /** @private */\n constructor(client, state, mode, version) {\n super(mode, version);\n this.#client = client;\n this.#streamState = state;\n }\n /** @private */\n _getStream() {\n return this.#streamState.stream;\n }\n /** @private */\n _getSqlCache() {\n return this.#streamState.conn.sqlCache;\n }\n close() {\n this.#client._closeStream(this.#streamState);\n }\n get closed() {\n return this.#streamState.stream.closed;\n }\n}\nexports.WsTransaction = WsTransaction;\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,eAAe,GAAI,IAAI,IAAI,IAAI,CAACA,eAAe,KAAMC,MAAM,CAACC,MAAM,GAAI,UAASC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,EAAE,EAAE;EAC5F,IAAIA,EAAE,KAAKC,SAAS,EAAED,EAAE,GAAGD,CAAC;EAC5B,IAAIG,IAAI,GAAGP,MAAM,CAACQ,wBAAwB,CAACL,CAAC,EAAEC,CAAC,CAAC;EAChD,IAAI,CAACG,IAAI,KAAK,KAAK,IAAIA,IAAI,GAAG,CAACJ,CAAC,CAACM,UAAU,GAAGF,IAAI,CAACG,QAAQ,IAAIH,IAAI,CAACI,YAAY,CAAC,EAAE;IACjFJ,IAAI,GAAG;MAAEK,UAAU,EAAE,IAAI;MAAEC,GAAG,EAAE,SAAAA,CAAA,EAAW;QAAE,OAAOV,CAAC,CAACC,CAAC,CAAC;MAAE;IAAE,CAAC;EAC/D;EACAJ,MAAM,CAACc,cAAc,CAACZ,CAAC,EAAEG,EAAE,EAAEE,IAAI,CAAC;AACtC,CAAC,GAAK,UAASL,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,EAAE,EAAE;EACxB,IAAIA,EAAE,KAAKC,SAAS,EAAED,EAAE,GAAGD,CAAC;EAC5BF,CAAC,CAACG,EAAE,CAAC,GAAGF,CAAC,CAACC,CAAC,CAAC;AAChB,CAAE,CAAC;AACH,IAAIW,kBAAkB,GAAI,IAAI,IAAI,IAAI,CAAC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