the-forest/client/node_modules/.cache/babel-loader/8b15d51a6572035a4439b09cde3b52fa23290c2cf0ad9a166e4b999fa5ea7932.json

1 line
42 KiB
JSON
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"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;\