1 line
5.7 KiB
JSON
1 line
5.7 KiB
JSON
|
{"ast":null,"code":"import { WebSocket } from \"@libsql/isomorphic-ws\";\nimport { subprotocolsV2, subprotocolsV3 } from \"./ws/client.js\";\nimport { WebSocketUnsupportedError } from \"./errors.js\";\nimport { HttpClient } from \"./http/client.js\";\nimport { WsClient } from \"./ws/client.js\";\nexport { WebSocket } from \"@libsql/isomorphic-ws\";\nexport { fetch, Request, Headers } from \"@libsql/isomorphic-fetch\";\nexport { Client } from \"./client.js\";\nexport * from \"./errors.js\";\nexport { Batch, BatchStep, BatchCond } from \"./batch.js\";\nexport { parseLibsqlUrl } from \"./libsql_url.js\";\nexport { Sql } from \"./sql.js\";\nexport { Stmt } from \"./stmt.js\";\nexport { Stream } from \"./stream.js\";\nexport { HttpClient } from \"./http/client.js\";\nexport { HttpStream } from \"./http/stream.js\";\nexport { WsClient } from \"./ws/client.js\";\nexport { WsStream } from \"./ws/stream.js\";\n/** Open a Hrana client over WebSocket connected to the given `url`. */\nexport function openWs(url, jwt, protocolVersion = 2) {\n if (typeof WebSocket === \"undefined\") {\n throw new WebSocketUnsupportedError(\"WebSockets are not supported in this environment\");\n }\n var subprotocols = undefined;\n if (protocolVersion == 3) {\n subprotocols = Array.from(subprotocolsV3.keys());\n } else {\n subprotocols = Array.from(subprotocolsV2.keys());\n }\n const socket = new WebSocket(url, subprotocols);\n return new WsClient(socket, jwt);\n}\n/** Open a Hrana client over HTTP connected to the given `url`.\n *\n * If the `customFetch` argument is passed and not `undefined`, it is used in place of the `fetch` function\n * from `@libsql/isomorphic-fetch`. This function is always called with a `Request` object from\n * `@libsql/isomorphic-fetch`.\n */\nexport function openHttp(url, jwt, customFetch, protocolVersion = 2) {\n return new HttpClient(url instanceof URL ? url : new URL(url), jwt, customFetch, protocolVersion);\n}","map":{"version":3,"names":["WebSocket","subprotocolsV2","subprotocolsV3","WebSocketUnsupportedError","HttpClient","WsClient","fetch","Request","Headers","Client","Batch","BatchStep","BatchCond","parseLibsqlUrl","Sql","Stmt","Stream","HttpStream","WsStream","openWs","url","jwt","protocolVersion","subprotocols","undefined","Array","from","keys","socket","openHttp","customFetch","URL"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/index.js"],"sourcesContent":["import { WebSocket } from \"@libsql/isomorphic-ws\";\nimport { subprotocolsV2, subprotocolsV3 } from \"./ws/client.js\";\nimport { WebSocketUnsupportedError } from \"./errors.js\";\nimport { HttpClient } from \"./http/client.js\";\nimport { WsClient } from \"./ws/client.js\";\nexport { WebSocket } from \"@libsql/isomorphic-ws\";\nexport { fetch, Request, Headers } from \"@libsql/isomorphic-fetch\";\nexport { Client } from \"./client.js\";\nexport * from \"./errors.js\";\nexport { Batch, BatchStep, BatchCond } from \"./batch.js\";\nexport { parseLibsqlUrl } from \"./libsql_url.js\";\nexport { Sql } from \"./sql.js\";\nexport { Stmt } from \"./stmt.js\";\nexport { Stream } from \"./stream.js\";\nexport { HttpClient } from \"./http/client.js\";\nexport { HttpStream } from \"./http/stream.js\";\nexport { WsClient } from \"./ws/client.js\";\nexport { WsStream } from \"./ws/stream.js\";\n/** Open a Hrana client over WebSocket connected to the given `url`. */\nexport function openWs(url, jwt, protocolVersion = 2) {\n if (typeof WebSocket === \"undefined\") {\n throw new WebSocketUnsupportedError(\"WebSockets are not supported in this environment\");\n }\n var subprotocols = undefined;\n if (protocolVersion == 3) {\n subprotocols = Array.from(subprotocolsV3.keys());\n }\n else {\n subprotocols = Array.from(subprotocolsV2.keys());\n }\n const socket = new WebSocket(url, subprotocols);\n return new WsClient(socket, jwt);\n}\n/** Open a Hrana client over HTTP connected to the given `url`.\n *\n * If the `customFetch` argument is passed and not `undefined`, it is
|