@sqlitecloud/drivers 1.0.289 → 1.0.345
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/drivers/connection-tls.d.ts +2 -2
- package/lib/drivers/connection-tls.js +20 -8
- package/lib/drivers/connection-ws.d.ts +2 -2
- package/lib/drivers/connection-ws.js +4 -2
- package/lib/drivers/connection.d.ts +5 -4
- package/lib/drivers/connection.js +16 -15
- package/lib/drivers/database.d.ts +3 -3
- package/lib/drivers/database.js +45 -36
- package/lib/drivers/protocol.d.ts +3 -3
- package/lib/drivers/protocol.js +58 -15
- package/lib/drivers/pubsub.d.ts +5 -0
- package/lib/drivers/pubsub.js +14 -5
- package/lib/drivers/statement.d.ts +12 -6
- package/lib/drivers/statement.js +53 -56
- package/lib/drivers/types.d.ts +11 -9
- package/lib/drivers/types.js +1 -1
- package/lib/drivers/utilities.d.ts +2 -4
- package/lib/drivers/utilities.js +27 -82
- package/lib/index.d.ts +1 -2
- package/lib/index.js +19 -12
- package/lib/sqlitecloud.drivers.dev.js +65 -76
- package/lib/sqlitecloud.drivers.js +1 -1
- package/package.json +16 -27
|
@@ -26,7 +26,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
26
26
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
27
27
|
|
|
28
28
|
"use strict";
|
|
29
|
-
eval("\n/**\n * connection-tls.ts - connection via tls socket and sqlitecloud protocol\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 = { 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};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudTlsConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst connection_1 = __webpack_require__(/*! ./connection */ \"./lib/drivers/connection.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst protocol_1 = __webpack_require__(/*! ./protocol */ \"./lib/drivers/protocol.js\");\n// explicitly importing buffer library to allow cross-platform support by replacing it\nconst buffer_1 = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\nconst tls = __importStar(__webpack_require__(/*! tls */ \"?4235\"));\n/**\n * Implementation of SQLiteCloudConnection that connects to the database using specific tls APIs\n * that connect to native sockets or tls sockets and communicates via raw, binary protocol.\n */\nclass SQLiteCloudTlsConnection extends connection_1.SQLiteCloudConnection {\n constructor() {\n super(...arguments);\n // processCommands sets up empty buffers, results callback then send the command to the server via socket.write\n // onData is called when data is received, it will process the data until all data is retrieved for a response\n // when response is complete or there's an error, finish is called to call the results callback set by processCommands...\n // buffer to accumulate incoming data until an whole command is received and can be parsed\n this.buffer = buffer_1.Buffer.alloc(0);\n this.startedOn = new Date();\n this.pendingChunks = [];\n }\n /** True if connection is open */\n get connected() {\n return !!this.socket;\n }\n /* Opens a connection with the server and sends the initialization commands. Will throw in case of errors. */\n /* eslint-disable @typescript-eslint/no-unused-vars */\n connectTransport(config, callback) {\n console.assert(!this.connected, 'SQLiteCloudTlsConnection.connect - connection already established');\n if (this.config.verbose) {\n console.debug(`-> connecting ${config === null || config === void 0 ? void 0 : config.host}:${config === null || config === void 0 ? void 0 : config.port}`);\n }\n this.config = config;\n const initializationCommands = (0, utilities_1.getInitializationCommands)(config);\n // connect to plain socket, without encryption, only if insecure parameter specified\n // this option is mainly for testing purposes and is not available on production nodes\n // which would need to connect using tls and proper certificates as per code below\n const connectionOptions = {\n host: config.host,\n port: config.port,\n rejectUnauthorized: config.host != 'localhost',\n // Server name for the SNI (Server Name Indication) TLS extension.\n // https://r2.nodejs.org/docs/v6.11.4/api/tls.html#tls_class_tls_tlssocket\n servername: config.host\n };\n // tls.connect in the react-native-tcp-socket library is tls.connectTLS\n let connector = tls.connect;\n // @ts-ignore\n if (typeof tls.connectTLS !== 'undefined') {\n // @ts-ignore\n connector = tls.connectTLS;\n }\n this.socket = connector(connectionOptions, () => {\n var _a;\n if (this.config.verbose) {\n console.debug(`SQLiteCloudTlsConnection - connected to ${this.config.host}, authorized: ${(_a = this.socket) === null || _a === void 0 ? void 0 : _a.authorized}`);\n }\n this.transportCommands(initializationCommands, error => {\n if (this.config.verbose) {\n console.debug(`SQLiteCloudTlsConnection - initialized connection`);\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n });\n });\n this.socket.on('data', data => {\n this.processCommandsData(data);\n });\n this.socket.on('error', error => {\n this.close();\n this.processCommandsFinish(new types_1.SQLiteCloudError('Connection error', { errorCode: 'ERR_CONNECTION_ERROR', cause: error }));\n });\n this.socket.on('end', () => {\n this.close();\n if (this.processCallback)\n this.processCommandsFinish(new types_1.SQLiteCloudError('Server ended the connection', { errorCode: 'ERR_CONNECTION_ENDED' }));\n });\n this.socket.on('close', () => {\n this.close();\n this.processCommandsFinish(new types_1.SQLiteCloudError('Connection closed', { errorCode: 'ERR_CONNECTION_CLOSED' }));\n });\n return this;\n }\n /** Will send a command immediately (no queueing), return the rowset/result or throw an error */\n transportCommands(commands, callback) {\n var _a, _b, _c, _d, _e;\n // connection needs to be established?\n if (!this.socket) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' }));\n return this;\n }\n // reset buffer and rowset chunks, define response callback\n this.buffer = buffer_1.Buffer.alloc(0);\n this.startedOn = new Date();\n this.processCallback = callback;\n this.executingCommands = commands;\n // compose commands following SCPC protocol\n const formattedCommands = (0, protocol_1.formatCommand)(commands);\n if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.verbose) {\n console.debug(`-> ${formattedCommands}`);\n }\n const timeoutMs = (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.timeout) !== null && _c !== void 0 ? _c : 0;\n if (timeoutMs > 0) {\n const timeout = setTimeout(() => {\n var _a;\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection timeout out', { errorCode: 'ERR_CONNECTION_TIMEOUT' }));\n (_a = this.socket) === null || _a === void 0 ? void 0 : _a.destroy();\n this.socket = undefined;\n }, timeoutMs);\n (_d = this.socket) === null || _d === void 0 ? void 0 : _d.write(formattedCommands, 'utf-8', () => {\n clearTimeout(timeout); // Clear the timeout on successful write\n });\n }\n else {\n (_e = this.socket) === null || _e === void 0 ? void 0 : _e.write(formattedCommands, 'utf-8');\n }\n return this;\n }\n /** Handles data received in response to an outbound command sent by processCommands */\n processCommandsData(data) {\n var _a, _b, _c, _d, _e, _f, _g;\n try {\n // append data to buffer as it arrives\n if (data.length && data.length > 0) {\n // console.debug(`processCommandsData - received ${data.length} bytes`)\n this.buffer = buffer_1.Buffer.concat([this.buffer, data]);\n }\n let dataType = (_a = this.buffer) === null || _a === void 0 ? void 0 : _a.subarray(0, 1).toString();\n if ((0, protocol_1.hasCommandLength)(dataType)) {\n const commandLength = (0, protocol_1.parseCommandLength)(this.buffer);\n const hasReceivedEntireCommand = this.buffer.length - this.buffer.indexOf(' ') - 1 >= commandLength ? true : false;\n if (hasReceivedEntireCommand) {\n if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.verbose) {\n let bufferString = this.buffer.toString('utf8');\n if (bufferString.length > 1000) {\n bufferString = bufferString.substring(0, 100) + '...' + bufferString.substring(bufferString.length - 40);\n }\n const elapsedMs = new Date().getTime() - this.startedOn.getTime();\n console.debug(`<- ${bufferString} (${bufferString.length} bytes, ${elapsedMs}ms)`);\n }\n // need to decompress this buffer before decoding?\n if (dataType === protocol_1.CMD_COMPRESSED) {\n const decompressResults = (0, protocol_1.decompressBuffer)(this.buffer);\n if (decompressResults.dataType === protocol_1.CMD_ROWSET_CHUNK) {\n this.pendingChunks.push(decompressResults.buffer);\n this.buffer = decompressResults.remainingBuffer;\n this.processCommandsData(buffer_1.Buffer.alloc(0));\n return;\n }\n else {\n const { data } = (0, protocol_1.popData)(decompressResults.buffer);\n (_c = this.processCommandsFinish) === null || _c === void 0 ? void 0 : _c.call(this, null, data);\n }\n }\n else {\n if (dataType !== protocol_1.CMD_ROWSET_CHUNK) {\n const { data } = (0, protocol_1.popData)(this.buffer);\n (_d = this.processCommandsFinish) === null || _d === void 0 ? void 0 : _d.call(this, null, data);\n }\n else {\n const completeChunk = (0, protocol_1.bufferEndsWith)(this.buffer, protocol_1.ROWSET_CHUNKS_END);\n if (completeChunk) {\n const parsedData = (0, protocol_1.parseRowsetChunks)([...this.pendingChunks, this.buffer]);\n (_e = this.processCommandsFinish) === null || _e === void 0 ? void 0 : _e.call(this, null, parsedData);\n }\n }\n }\n }\n }\n else {\n // command with no explicit len so make sure that the final character is a space\n const lastChar = this.buffer.subarray(this.buffer.length - 1, this.buffer.length).toString('utf8');\n if (lastChar == ' ') {\n const { data } = (0, protocol_1.popData)(this.buffer);\n (_f = this.processCommandsFinish) === null || _f === void 0 ? void 0 : _f.call(this, null, data);\n }\n }\n }\n catch (error) {\n console.error(`processCommandsData - error: ${error}`);\n console.assert(error instanceof Error, 'An error occoured while processing data');\n if (error instanceof Error) {\n (_g = this.processCommandsFinish) === null || _g === void 0 ? void 0 : _g.call(this, error);\n }\n }\n }\n /** Completes a transaction initiated by processCommands */\n processCommandsFinish(error, result) {\n if (error) {\n if (this.processCallback) {\n console.error('processCommandsFinish - error', error);\n }\n else {\n console.warn('processCommandsFinish - error with no registered callback', error);\n }\n }\n if (this.processCallback) {\n this.processCallback(error, result);\n }\n this.buffer = buffer_1.Buffer.alloc(0);\n this.pendingChunks = [];\n }\n /** Disconnect immediately, release connection, no events. */\n close() {\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n this.operations.clear();\n return this;\n }\n}\nexports.SQLiteCloudTlsConnection = SQLiteCloudTlsConnection;\nexports[\"default\"] = SQLiteCloudTlsConnection;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/connection-tls.js?");
|
|
29
|
+
eval("\n/**\n * connection-tls.ts - connection via tls socket and sqlitecloud protocol\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 = { 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 () {\n var ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n };\n return function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n };\n})();\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudTlsConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst connection_1 = __webpack_require__(/*! ./connection */ \"./lib/drivers/connection.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst protocol_1 = __webpack_require__(/*! ./protocol */ \"./lib/drivers/protocol.js\");\n// explicitly importing buffer library to allow cross-platform support by replacing it\nconst buffer_1 = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\nconst tls = __importStar(__webpack_require__(/*! tls */ \"?4235\"));\n/**\n * Implementation of SQLiteCloudConnection that connects to the database using specific tls APIs\n * that connect to native sockets or tls sockets and communicates via raw, binary protocol.\n */\nclass SQLiteCloudTlsConnection extends connection_1.SQLiteCloudConnection {\n constructor() {\n super(...arguments);\n // processCommands sets up empty buffers, results callback then send the command to the server via socket.write\n // onData is called when data is received, it will process the data until all data is retrieved for a response\n // when response is complete or there's an error, finish is called to call the results callback set by processCommands...\n // buffer to accumulate incoming data until an whole command is received and can be parsed\n this.buffer = buffer_1.Buffer.alloc(0);\n this.startedOn = new Date();\n this.pendingChunks = [];\n }\n /** True if connection is open */\n get connected() {\n return !!this.socket;\n }\n /* Opens a connection with the server and sends the initialization commands. Will throw in case of errors. */\n connectTransport(config, callback) {\n console.assert(!this.connected, 'SQLiteCloudTlsConnection.connect - connection already established');\n if (this.config.verbose) {\n console.debug(`-> connecting ${config === null || config === void 0 ? void 0 : config.host}:${config === null || config === void 0 ? void 0 : config.port}`);\n }\n this.config = config;\n const initializationCommands = (0, utilities_1.getInitializationCommands)(config);\n // connect to plain socket, without encryption, only if insecure parameter specified\n // this option is mainly for testing purposes and is not available on production nodes\n // which would need to connect using tls and proper certificates as per code below\n const connectionOptions = {\n host: config.host,\n port: config.port,\n rejectUnauthorized: config.host != 'localhost',\n // Server name for the SNI (Server Name Indication) TLS extension.\n // https://r2.nodejs.org/docs/v6.11.4/api/tls.html#tls_class_tls_tlssocket\n servername: config.host\n };\n // tls.connect in the react-native-tcp-socket library is tls.connectTLS\n let connector = tls.connect;\n // @ts-ignore\n if (typeof tls.connectTLS !== 'undefined') {\n // @ts-ignore\n connector = tls.connectTLS;\n }\n this.socket = connector(connectionOptions, () => {\n var _a;\n if (this.config.verbose) {\n console.debug(`SQLiteCloudTlsConnection - connected to ${this.config.host}, authorized: ${(_a = this.socket) === null || _a === void 0 ? void 0 : _a.authorized}`);\n }\n this.transportCommands(initializationCommands, error => {\n if (this.config.verbose) {\n console.debug(`SQLiteCloudTlsConnection - initialized connection`);\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n });\n });\n this.socket.on('data', data => {\n this.processCommandsData(data);\n });\n this.socket.on('error', error => {\n this.close();\n this.processCommandsFinish(new types_1.SQLiteCloudError('Connection error', { errorCode: 'ERR_CONNECTION_ERROR', cause: error }));\n });\n this.socket.on('end', () => {\n this.close();\n if (this.processCallback)\n this.processCommandsFinish(new types_1.SQLiteCloudError('Server ended the connection', { errorCode: 'ERR_CONNECTION_ENDED' }));\n });\n this.socket.on('close', () => {\n this.close();\n this.processCommandsFinish(new types_1.SQLiteCloudError('Connection closed', { errorCode: 'ERR_CONNECTION_CLOSED' }));\n });\n return this;\n }\n /** Will send a command immediately (no queueing), return the rowset/result or throw an error */\n transportCommands(commands, callback) {\n var _a, _b, _c, _d, _e;\n // connection needs to be established?\n if (!this.socket) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' }));\n return this;\n }\n if (typeof commands === 'string') {\n commands = { query: commands };\n }\n // reset buffer and rowset chunks, define response callback\n this.buffer = buffer_1.Buffer.alloc(0);\n this.startedOn = new Date();\n this.processCallback = callback;\n this.executingCommands = commands;\n // compose commands following SCPC protocol\n const formattedCommands = (0, protocol_1.formatCommand)(commands);\n if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.verbose) {\n console.debug(`-> ${formattedCommands}`);\n }\n const timeoutMs = (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.timeout) !== null && _c !== void 0 ? _c : 0;\n if (timeoutMs > 0) {\n const timeout = setTimeout(() => {\n var _a;\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection timeout out', { errorCode: 'ERR_CONNECTION_TIMEOUT' }));\n (_a = this.socket) === null || _a === void 0 ? void 0 : _a.destroy();\n this.socket = undefined;\n }, timeoutMs);\n (_d = this.socket) === null || _d === void 0 ? void 0 : _d.write(formattedCommands, 'utf-8', () => {\n clearTimeout(timeout); // Clear the timeout on successful write\n });\n }\n else {\n (_e = this.socket) === null || _e === void 0 ? void 0 : _e.write(formattedCommands, 'utf-8');\n }\n return this;\n }\n /** Handles data received in response to an outbound command sent by processCommands */\n processCommandsData(data) {\n var _a, _b, _c, _d, _e, _f, _g;\n try {\n // append data to buffer as it arrives\n if (data.length && data.length > 0) {\n // console.debug(`processCommandsData - received ${data.length} bytes`)\n this.buffer = buffer_1.Buffer.concat([this.buffer, data]);\n }\n let dataType = (_a = this.buffer) === null || _a === void 0 ? void 0 : _a.subarray(0, 1).toString();\n if ((0, protocol_1.hasCommandLength)(dataType)) {\n const commandLength = (0, protocol_1.parseCommandLength)(this.buffer);\n const hasReceivedEntireCommand = this.buffer.length - this.buffer.indexOf(' ') - 1 >= commandLength ? true : false;\n if (hasReceivedEntireCommand) {\n if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.verbose) {\n let bufferString = this.buffer.toString('utf8');\n if (bufferString.length > 1000) {\n bufferString = bufferString.substring(0, 100) + '...' + bufferString.substring(bufferString.length - 40);\n }\n const elapsedMs = new Date().getTime() - this.startedOn.getTime();\n console.debug(`<- ${bufferString} (${bufferString.length} bytes, ${elapsedMs}ms)`);\n }\n // need to decompress this buffer before decoding?\n if (dataType === protocol_1.CMD_COMPRESSED) {\n const decompressResults = (0, protocol_1.decompressBuffer)(this.buffer);\n if (decompressResults.dataType === protocol_1.CMD_ROWSET_CHUNK) {\n this.pendingChunks.push(decompressResults.buffer);\n this.buffer = decompressResults.remainingBuffer;\n this.processCommandsData(buffer_1.Buffer.alloc(0));\n return;\n }\n else {\n const { data } = (0, protocol_1.popData)(decompressResults.buffer);\n (_c = this.processCommandsFinish) === null || _c === void 0 ? void 0 : _c.call(this, null, data);\n }\n }\n else {\n if (dataType !== protocol_1.CMD_ROWSET_CHUNK) {\n const { data } = (0, protocol_1.popData)(this.buffer);\n (_d = this.processCommandsFinish) === null || _d === void 0 ? void 0 : _d.call(this, null, data);\n }\n else {\n const completeChunk = (0, protocol_1.bufferEndsWith)(this.buffer, protocol_1.ROWSET_CHUNKS_END);\n if (completeChunk) {\n const parsedData = (0, protocol_1.parseRowsetChunks)([...this.pendingChunks, this.buffer]);\n (_e = this.processCommandsFinish) === null || _e === void 0 ? void 0 : _e.call(this, null, parsedData);\n }\n }\n }\n }\n }\n else {\n // command with no explicit len so make sure that the final character is a space\n const lastChar = this.buffer.subarray(this.buffer.length - 1, this.buffer.length).toString('utf8');\n if (lastChar == ' ') {\n const { data } = (0, protocol_1.popData)(this.buffer);\n (_f = this.processCommandsFinish) === null || _f === void 0 ? void 0 : _f.call(this, null, data);\n }\n }\n }\n catch (error) {\n console.error(`processCommandsData - error: ${error}`);\n console.assert(error instanceof Error, 'An error occoured while processing data');\n if (error instanceof Error) {\n (_g = this.processCommandsFinish) === null || _g === void 0 ? void 0 : _g.call(this, error);\n }\n }\n }\n /** Completes a transaction initiated by processCommands */\n processCommandsFinish(error, result) {\n if (error) {\n if (this.processCallback) {\n console.error('processCommandsFinish - error', error);\n }\n else {\n console.warn('processCommandsFinish - error with no registered callback', error);\n }\n }\n if (this.processCallback) {\n this.processCallback(error, result);\n }\n this.buffer = buffer_1.Buffer.alloc(0);\n this.pendingChunks = [];\n }\n /** Disconnect immediately, release connection, no events. */\n close() {\n if (this.socket) {\n this.socket.removeAllListeners();\n this.socket.destroy();\n this.socket = undefined;\n }\n this.operations.clear();\n return this;\n }\n}\nexports.SQLiteCloudTlsConnection = SQLiteCloudTlsConnection;\nexports[\"default\"] = SQLiteCloudTlsConnection;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/connection-tls.js?");
|
|
30
30
|
|
|
31
31
|
/***/ }),
|
|
32
32
|
|
|
@@ -37,7 +37,7 @@ eval("\n/**\n * connection-tls.ts - connection via tls socket and sqlitecloud pr
|
|
|
37
37
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
38
38
|
|
|
39
39
|
"use strict";
|
|
40
|
-
eval("\n/**\n * transport-ws.ts - handles low level communication with sqlitecloud server via socket.io websocket\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudWebsocketConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\nconst connection_1 = __webpack_require__(/*! ./connection */ \"./lib/drivers/connection.js\");\nconst socket_io_client_1 = __webpack_require__(/*! socket.io-client */ \"./node_modules/socket.io-client/build/cjs/index.js\");\n/**\n * Implementation of TransportConnection that connects to the database indirectly\n * via SQLite Cloud Gateway, a socket.io based deamon that responds to sql query\n * requests by returning results and rowsets in json format. The gateway handles\n * connect, disconnect, retries, order of operations, timeouts, etc.\n */\nclass SQLiteCloudWebsocketConnection extends connection_1.SQLiteCloudConnection {\n /** True if connection is open */\n get connected() {\n return !!this.socket;\n }\n /* Opens a connection with the server and sends the initialization commands. Will throw in case of errors. */\n connectTransport(config, callback) {\n var _a;\n try {\n // connection established while we were waiting in line?\n console.assert(!this.connected, 'Connection already established');\n if (!this.socket) {\n this.config = config;\n const connectionstring = this.config.connectionstring;\n const gatewayUrl = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.gatewayurl) || `${this.config.host === 'localhost' ? 'ws' : 'wss'}://${this.config.host}:4000`;\n this.socket = (0, socket_io_client_1.io)(gatewayUrl, { auth: { token: connectionstring } });\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n catch (error) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n }\n return this;\n }\n /** Will send a command immediately (no queueing), return the rowset/result or throw an error */\n transportCommands(commands, callback) {\n // connection needs to be established?\n if (!this.socket) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' }));\n return this;\n }\n this.socket.emit('
|
|
40
|
+
eval("\n/**\n * transport-ws.ts - handles low level communication with sqlitecloud server via socket.io websocket\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudWebsocketConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\nconst connection_1 = __webpack_require__(/*! ./connection */ \"./lib/drivers/connection.js\");\nconst socket_io_client_1 = __webpack_require__(/*! socket.io-client */ \"./node_modules/socket.io-client/build/cjs/index.js\");\n/**\n * Implementation of TransportConnection that connects to the database indirectly\n * via SQLite Cloud Gateway, a socket.io based deamon that responds to sql query\n * requests by returning results and rowsets in json format. The gateway handles\n * connect, disconnect, retries, order of operations, timeouts, etc.\n */\nclass SQLiteCloudWebsocketConnection extends connection_1.SQLiteCloudConnection {\n /** True if connection is open */\n get connected() {\n return !!this.socket;\n }\n /* Opens a connection with the server and sends the initialization commands. Will throw in case of errors. */\n connectTransport(config, callback) {\n var _a;\n try {\n // connection established while we were waiting in line?\n console.assert(!this.connected, 'Connection already established');\n if (!this.socket) {\n this.config = config;\n const connectionstring = this.config.connectionstring;\n const gatewayUrl = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.gatewayurl) || `${this.config.host === 'localhost' ? 'ws' : 'wss'}://${this.config.host}:4000`;\n this.socket = (0, socket_io_client_1.io)(gatewayUrl, { auth: { token: connectionstring } });\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n catch (error) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n }\n return this;\n }\n /** Will send a command immediately (no queueing), return the rowset/result or throw an error */\n transportCommands(commands, callback) {\n // connection needs to be established?\n if (!this.socket) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' }));\n return this;\n }\n if (typeof commands === 'string') {\n commands = { query: commands };\n }\n this.socket.emit('GET /v2/weblite/sql', { sql: commands.query, bind: commands.parameters, row: 'array' }, (response) => {\n if (response === null || response === void 0 ? void 0 : response.error) {\n const error = new types_1.SQLiteCloudError(response.error.detail, Object.assign({}, response.error));\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n }\n else {\n const { data, metadata } = response;\n if (data && metadata) {\n if (metadata.numberOfRows !== undefined && metadata.numberOfColumns !== undefined && metadata.columns !== undefined) {\n console.assert(Array.isArray(data), 'SQLiteCloudWebsocketConnection.transportCommands - data is not an array');\n // we can recreate a SQLiteCloudRowset from the response which we know to be an array of arrays\n const rowset = new rowset_1.SQLiteCloudRowset(metadata, data.flat());\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, rowset);\n return;\n }\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, response === null || response === void 0 ? void 0 : response.data);\n }\n });\n return this;\n }\n /** Disconnect socket.io from server */\n close() {\n var _a;\n console.assert(this.socket !== null, 'SQLiteCloudWebsocketConnection.close - connection already closed');\n if (this.socket) {\n (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();\n this.socket = undefined;\n }\n this.operations.clear();\n this.socket = undefined;\n return this;\n }\n}\nexports.SQLiteCloudWebsocketConnection = SQLiteCloudWebsocketConnection;\nexports[\"default\"] = SQLiteCloudWebsocketConnection;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/connection-ws.js?");
|
|
41
41
|
|
|
42
42
|
/***/ }),
|
|
43
43
|
|
|
@@ -48,7 +48,7 @@ eval("\n/**\n * transport-ws.ts - handles low level communication with sqliteclo
|
|
|
48
48
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
49
49
|
|
|
50
50
|
"use strict";
|
|
51
|
-
eval("\n/**\n * connection.ts - base abstract class for sqlitecloud server connections\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst queue_1 = __webpack_require__(/*! ./queue */ \"./lib/drivers/queue.js\");\nconst utilities_2 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\n/**\n * Base class for SQLiteCloudConnection handles basics and defines methods.\n * Actual connection management and communication with the server in concrete classes.\n */\nclass SQLiteCloudConnection {\n /** Parse and validate provided connectionstring or configuration */\n constructor(config, callback) {\n /** Operations are serialized by waiting an any pending promises */\n this.operations = new queue_1.OperationsQueue();\n if (typeof config === 'string') {\n this.config = (0, utilities_1.validateConfiguration)({ connectionstring: config });\n }\n else {\n this.config = (0, utilities_1.validateConfiguration)(config);\n }\n // connect transport layer to server\n this.connect(callback);\n }\n /** Returns the connection's configuration */\n getConfig() {\n return Object.assign({}, this.config);\n }\n //\n // internal methods (some are implemented in concrete classes using different transport layers)\n //\n /** Connect will establish a tls or websocket transport to the server based on configuration and environment */\n connect(callback) {\n this.operations.enqueue(done => {\n this.connectTransport(this.config, error => {\n if (error) {\n console.error(`SQLiteCloudConnection.connect - error connecting ${this.config.host}:${this.config.port} ${error.toString()}`, error);\n this.close();\n }\n if (callback) {\n callback.call(this, error || null);\n }\n done(error);\n });\n });\n return this;\n }\n /** Will log to console if verbose mode is enabled */\n log(message, ...optionalParams) {\n if (this.config.verbose) {\n message = (0, utilities_2.anonimizeCommand)(message);\n console.log(`${new Date().toISOString()} ${this.config.clientid}: ${message}`, ...optionalParams);\n }\n }\n /** Enable verbose logging for debug purposes */\n verbose() {\n this.config.verbose = true;\n }\n /** Will enquee a command to be executed and callback with the resulting rowset/result/error */\n sendCommands(commands, callback) {\n this.operations.enqueue(done => {\n if (!this.connected) {\n const error = new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' });\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n done(error);\n }\n else {\n this.transportCommands(commands, (error, result) => {\n callback === null || callback === void 0 ? void 0 : callback.call(this, error, result);\n done(error);\n });\n }\n });\n return this;\n }\n /**\n * Sql is a promise based API for executing SQL statements. You can\n * pass a simple string with a SQL statement or a template string\n * using backticks and parameters in ${parameter} format. These parameters\n * will be properly escaped and quoted like when using a prepared statement.\n * @param sql A sql string or a template string in `backticks` format\n * @returns An array of rows in case of selections or an object with\n * metadata in case of insert, update, delete.\n */\n sql(sql, ...values) {\n return __awaiter(this, void 0, void 0, function* () {\n let
|
|
51
|
+
eval("\n/**\n * connection.ts - base abstract class for sqlitecloud server connections\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudConnection = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst queue_1 = __webpack_require__(/*! ./queue */ \"./lib/drivers/queue.js\");\nconst utilities_2 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\n/**\n * Base class for SQLiteCloudConnection handles basics and defines methods.\n * Actual connection management and communication with the server in concrete classes.\n */\nclass SQLiteCloudConnection {\n /** Parse and validate provided connectionstring or configuration */\n constructor(config, callback) {\n /** Operations are serialized by waiting an any pending promises */\n this.operations = new queue_1.OperationsQueue();\n if (typeof config === 'string') {\n this.config = (0, utilities_1.validateConfiguration)({ connectionstring: config });\n }\n else {\n this.config = (0, utilities_1.validateConfiguration)(config);\n }\n // connect transport layer to server\n this.connect(callback);\n }\n /** Returns the connection's configuration */\n getConfig() {\n return Object.assign({}, this.config);\n }\n //\n // internal methods (some are implemented in concrete classes using different transport layers)\n //\n /** Connect will establish a tls or websocket transport to the server based on configuration and environment */\n connect(callback) {\n this.operations.enqueue(done => {\n this.connectTransport(this.config, error => {\n if (error) {\n console.error(`SQLiteCloudConnection.connect - error connecting ${this.config.host}:${this.config.port} ${error.toString()}`, error);\n this.close();\n }\n if (callback) {\n callback.call(this, error || null);\n }\n done(error);\n });\n });\n return this;\n }\n /** Will log to console if verbose mode is enabled */\n log(message, ...optionalParams) {\n if (this.config.verbose) {\n message = (0, utilities_2.anonimizeCommand)(message);\n console.log(`${new Date().toISOString()} ${this.config.clientid}: ${message}`, ...optionalParams);\n }\n }\n /** Enable verbose logging for debug purposes */\n verbose() {\n this.config.verbose = true;\n }\n /** Will enquee a command to be executed and callback with the resulting rowset/result/error */\n sendCommands(commands, callback) {\n this.operations.enqueue(done => {\n if (!this.connected) {\n const error = new types_1.SQLiteCloudError('Connection not established', { errorCode: 'ERR_CONNECTION_NOT_ESTABLISHED' });\n callback === null || callback === void 0 ? void 0 : callback.call(this, error);\n done(error);\n }\n else {\n this.transportCommands(commands, (error, result) => {\n callback === null || callback === void 0 ? void 0 : callback.call(this, error, result);\n done(error);\n });\n }\n });\n return this;\n }\n /**\n * Sql is a promise based API for executing SQL statements. You can\n * pass a simple string with a SQL statement or a template string\n * using backticks and parameters in ${parameter} format. These parameters\n * will be properly escaped and quoted like when using a prepared statement.\n * @param sql A sql string or a template string in `backticks` format\n * A SQLiteCloudCommand when the query is defined with question marks and bindings.\n * @returns An array of rows in case of selections or an object with\n * metadata in case of insert, update, delete.\n */\n sql(sql, ...values) {\n return __awaiter(this, void 0, void 0, function* () {\n let commands = { query: '' };\n // sql is a TemplateStringsArray, the 'raw' property is specific to TemplateStringsArray\n if (Array.isArray(sql) && 'raw' in sql) {\n let query = '';\n sql.forEach((string, i) => {\n // TemplateStringsArray splits the string before each variable\n // used in the template. Add the question mark\n // to the end of the string for the number of used variables.\n query += string + (i < values.length ? '?' : '');\n });\n commands = { query, parameters: values };\n }\n else if (typeof sql === 'string') {\n commands = { query: sql, parameters: values };\n }\n else if (typeof sql === 'object') {\n commands = sql;\n }\n else {\n throw new Error('Invalid sql');\n }\n return new Promise((resolve, reject) => {\n this.sendCommands(commands, (error, results) => {\n if (error) {\n reject(error);\n }\n else {\n // metadata for operations like insert, update, delete?\n const context = (0, utilities_2.getUpdateResults)(results);\n resolve(context ? context : results);\n }\n });\n });\n });\n }\n}\nexports.SQLiteCloudConnection = SQLiteCloudConnection;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/connection.js?");
|
|
52
52
|
|
|
53
53
|
/***/ }),
|
|
54
54
|
|
|
@@ -59,7 +59,7 @@ eval("\n/**\n * connection.ts - base abstract class for sqlitecloud server conne
|
|
|
59
59
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
60
60
|
|
|
61
61
|
"use strict";
|
|
62
|
-
eval("\n//\n// database.ts - database driver api, implements and extends sqlite3\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 = { 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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Database = void 0;\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst statement_1 = __webpack_require__(/*! ./statement */ \"./lib/drivers/statement.js\");\nconst eventemitter3_1 = __importDefault(__webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\"));\nconst utilities_2 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst pubsub_1 = __webpack_require__(/*! ./pubsub */ \"./lib/drivers/pubsub.js\");\n// Uses eventemitter3 instead of node events for browser compatibility\n// https://github.com/primus/eventemitter3\n/**\n * Creating a Database object automatically opens a connection to the SQLite database.\n * When the connection is established the Database object emits an open event and calls\n * the optional provided callback. If the connection cannot be established an error event\n * will be emitted and the optional callback is called with the error information.\n */\nclass Database extends eventemitter3_1.default {\n constructor(config, mode, callback) {\n super();\n /** Database connections */\n this.connections = [];\n this.config = typeof config === 'string' ? { connectionstring: config } : config;\n // mode is optional and so is callback\n // https://github.com/TryGhost/node-sqlite3/wiki/API#new-sqlite3databasefilename--mode--callback\n if (typeof mode === 'function') {\n callback = mode;\n mode = undefined;\n }\n // mode is ignored for now\n // opens first connection to the database automatically\n this.getConnection((error, _connection) => {\n if (callback) {\n callback.call(this, error);\n }\n });\n }\n //\n // private methods\n //\n /** Returns first available connection from connection pool */\n getConnection(callback) {\n var _a, _b, _c;\n // TODO sqlitecloud-js / implement database connection pool #10\n if (((_a = this.connections) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n }\n else {\n // connect using websocket if tls is not supported or if explicitly requested\n const useWebsocket = utilities_2.isBrowser || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.usewebsocket) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.gatewayurl);\n if (useWebsocket) {\n // socket.io transport works in both node.js and browser environments and connects via SQLite Cloud Gateway\n Promise.resolve().then(() => __importStar(__webpack_require__(/*! ./connection-ws */ \"./lib/drivers/connection-ws.js\"))).then(module => {\n this.connections.push(new module.default(this.config, error => {\n if (error) {\n this.handleError(this.connections[0], error, callback);\n }\n else {\n console.assert;\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n this.emitEvent('open');\n }\n }));\n })\n .catch(error => {\n this.handleError(null, error, callback);\n });\n }\n else {\n // tls sockets work only in node.js environments\n Promise.resolve().then(() => __importStar(__webpack_require__(/*! ./connection-tls */ \"./lib/drivers/connection-tls.js\"))).then(module => {\n this.connections.push(new module.default(this.config, error => {\n if (error) {\n this.handleError(this.connections[0], error, callback);\n }\n else {\n console.assert;\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n this.emitEvent('open');\n }\n }));\n })\n .catch(error => {\n this.handleError(null, error, callback);\n });\n }\n }\n }\n /** Handles an error by closing the connection, calling the callback and/or emitting an error event */\n handleError(connection, error, callback) {\n // an errored connection is thrown out\n if (connection) {\n this.connections = this.connections.filter(c => c !== connection);\n connection.close();\n }\n if (callback) {\n callback.call(this, error);\n }\n else {\n this.emitEvent('error', error);\n }\n }\n /**\n * Some queries like inserts or updates processed via run or exec may generate\n * an empty result (eg. no data was selected), but still have some metadata.\n * For example the server may pass the id of the last row that was modified.\n * In this case the callback results should be empty but the context may contain\n * additional information like lastID, etc.\n * @see https://github.com/TryGhost/node-sqlite3/wiki/API#runsql--param---callback\n * @param results Results received from the server\n * @returns A context object if one makes sense, otherwise undefined\n */\n processContext(results) {\n if (results) {\n if (Array.isArray(results) && results.length > 0) {\n switch (results[0]) {\n case types_1.SQLiteCloudArrayType.ARRAY_TYPE_SQLITE_EXEC:\n return {\n lastID: results[2],\n changes: results[3],\n totalChanges: results[4],\n finalized: results[5] // FINALIZED\n };\n }\n }\n }\n return undefined;\n }\n /** Emits given event with optional arguments on the next tick so callbacks can complete first */\n emitEvent(event, ...args) {\n setTimeout(() => {\n this.emit(event, ...args);\n }, 0);\n }\n //\n // public methods\n //\n /**\n * Returns the configuration with which this database was opened.\n * The configuration is readonly and cannot be changed as there may\n * be multiple connections using the same configuration.\n * @returns {SQLiteCloudConfig} A configuration object\n */\n getConfiguration() {\n return JSON.parse(JSON.stringify(this.config));\n }\n /** Enable verbose mode */\n verbose() {\n this.config.verbose = true;\n for (const connection of this.connections) {\n connection.verbose();\n }\n return this;\n }\n /** Set a configuration option for the database */\n configure(_option, _value) {\n // https://github.com/TryGhost/node-sqlite3/wiki/API#configureoption-value\n return this;\n }\n run(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const preparedSql = (args === null || args === void 0 ? void 0 : args.length) > 0 ? (0, utilities_1.prepareSql)(sql, ...args) : sql;\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(preparedSql, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n // context may include id of last row inserted, total changes, etc...\n const context = this.processContext(results);\n callback === null || callback === void 0 ? void 0 : callback.call(context || this, null, context ? context : results);\n }\n });\n }\n });\n return this;\n }\n get(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const preparedSql = (args === null || args === void 0 ? void 0 : args.length) > 0 ? (0, utilities_1.prepareSql)(sql, ...args) : sql;\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(preparedSql, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (results && results instanceof rowset_1.SQLiteCloudRowset && results.length > 0) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, results[0]);\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n }\n });\n }\n });\n return this;\n }\n all(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const preparedSql = (args === null || args === void 0 ? void 0 : args.length) > 0 ? (0, utilities_1.prepareSql)(sql, ...args) : sql;\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(preparedSql, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (results && results instanceof rowset_1.SQLiteCloudRowset) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, results);\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n }\n });\n }\n });\n return this;\n }\n each(sql, ...params) {\n // extract optional parameters and one or two callbacks\n const { args, callback, complete } = (0, utilities_1.popCallback)(params);\n const preparedSql = (args === null || args === void 0 ? void 0 : args.length) > 0 ? (0, utilities_1.prepareSql)(sql, ...args) : sql;\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(preparedSql, (error, rowset) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (rowset && rowset instanceof rowset_1.SQLiteCloudRowset) {\n if (callback) {\n for (const row of rowset) {\n callback.call(this, null, row);\n }\n }\n if (complete) {\n ;\n complete.call(this, null, rowset.numberOfRows);\n }\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Invalid rowset'));\n }\n }\n });\n }\n });\n return this;\n }\n /**\n * Prepares the SQL statement and optionally binds the specified parameters and\n * calls the callback when done. The function returns a Statement object.\n * When preparing was successful, the first and only argument to the callback\n * is null, otherwise it is the error object. When bind parameters are supplied,\n * they are bound to the prepared statement before calling the callback.\n */\n prepare(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n return new statement_1.Statement(this, sql, ...args, callback);\n }\n /**\n * Runs all SQL queries in the supplied string. No result rows are retrieved.\n * The function returns the Database object to allow for function chaining.\n * If a query fails, no subsequent statements will be executed (wrap it in a\n * transaction if you want all or none to be executed). When all statements\n * have been executed successfully, or when an error occurs, the callback\n * function is called, with the first parameter being either null or an error\n * object. When no callback is provided and an error occurs, an error event\n * will be emitted on the database object.\n */\n exec(sql, callback) {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(sql, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n const context = this.processContext(results);\n callback === null || callback === void 0 ? void 0 : callback.call(context ? context : this, null);\n }\n });\n }\n });\n return this;\n }\n /**\n * If the optional callback is provided, this function will be called when the\n * database was closed successfully or when an error occurred. The first argument\n * is an error object. When it is null, closing succeeded. If no callback is provided\n * and an error occurred, an error event with the error object as the only parameter\n * will be emitted on the database object. If closing succeeded, a close event with no\n * parameters is emitted, regardless of whether a callback was provided or not.\n */\n close(callback) {\n var _a;\n if (((_a = this.connections) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n for (const connection of this.connections) {\n connection.close();\n }\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n this.emitEvent('close');\n }\n /**\n * Loads a compiled SQLite extension into the database connection object.\n * @param path Filename of the extension to load.\n * @param callback If provided, this function will be called when the extension\n * was loaded successfully or when an error occurred. The first argument is an\n * error object. When it is null, loading succeeded. If no callback is provided\n * and an error occurred, an error event with the error object as the only parameter\n * will be emitted on the database object.\n */\n loadExtension(_path, callback) {\n // TODO sqlitecloud-js / implement database loadExtension #17\n if (callback) {\n callback.call(this, new Error('Database.loadExtension - Not implemented'));\n }\n else {\n this.emitEvent('error', new Error('Database.loadExtension - Not implemented'));\n }\n return this;\n }\n /**\n * Allows the user to interrupt long-running queries. Wrapper around\n * sqlite3_interrupt and causes other data-fetching functions to be\n * passed an err with code = sqlite3.INTERRUPT. The database must be\n * open to use this function.\n */\n interrupt() {\n // TODO sqlitecloud-js / implement database interrupt #13\n }\n //\n // extended APIs\n //\n /**\n * Sql is a promise based API for executing SQL statements. You can\n * pass a simple string with a SQL statement or a template string\n * using backticks and parameters in ${parameter} format. These parameters\n * will be properly escaped and quoted like when using a prepared statement.\n * @param sql A sql string or a template string in `backticks` format\n * @returns An array of rows in case of selections or an object with\n * metadata in case of insert, update, delete.\n */\n sql(sql, ...values) {\n return __awaiter(this, void 0, void 0, function* () {\n let preparedSql = '';\n // sql is a TemplateStringsArray, the 'raw' property is specific to TemplateStringsArray\n if (Array.isArray(sql) && 'raw' in sql) {\n sql.forEach((string, i) => {\n preparedSql += string + (i < values.length ? '?' : '');\n });\n preparedSql = (0, utilities_1.prepareSql)(preparedSql, ...values);\n }\n else {\n if (typeof sql === 'string') {\n if ((values === null || values === void 0 ? void 0 : values.length) > 0) {\n preparedSql = (0, utilities_1.prepareSql)(sql, ...values);\n }\n else {\n preparedSql = sql;\n }\n }\n else {\n throw new Error('Invalid sql');\n }\n }\n return new Promise((resolve, reject) => {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n reject(error);\n }\n else {\n connection.sendCommands(preparedSql, (error, results) => {\n if (error) {\n reject(error);\n }\n else {\n // metadata for operations like insert, update, delete?\n const context = this.processContext(results);\n resolve(context ? context : results);\n }\n });\n }\n });\n });\n });\n }\n /**\n * PubSub class provides a Pub/Sub real-time updates and notifications system to\n * allow multiple applications to communicate with each other asynchronously.\n * It allows applications to subscribe to tables and receive notifications whenever\n * data changes in the database table. It also enables sending messages to anyone\n * subscribed to a specific channel.\n * @returns {PubSub} A PubSub object\n */\n getPubSub() {\n return __awaiter(this, void 0, void 0, function* () {\n return new Promise((resolve, reject) => {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n reject(error);\n }\n else {\n resolve(new pubsub_1.PubSub(connection));\n }\n });\n });\n });\n }\n}\nexports.Database = Database;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/database.js?");
|
|
62
|
+
eval("\n//\n// database.ts - database driver api, implements and extends sqlite3\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 = { 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 () {\n var ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n };\n return function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Database = void 0;\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst eventemitter3_1 = __importDefault(__webpack_require__(/*! eventemitter3 */ \"./node_modules/eventemitter3/index.js\"));\nconst utilities_2 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\nconst pubsub_1 = __webpack_require__(/*! ./pubsub */ \"./lib/drivers/pubsub.js\");\nconst statement_1 = __webpack_require__(/*! ./statement */ \"./lib/drivers/statement.js\");\n// Uses eventemitter3 instead of node events for browser compatibility\n// https://github.com/primus/eventemitter3\n/**\n * Creating a Database object automatically opens a connection to the SQLite database.\n * When the connection is established the Database object emits an open event and calls\n * the optional provided callback. If the connection cannot be established an error event\n * will be emitted and the optional callback is called with the error information.\n */\nclass Database extends eventemitter3_1.default {\n constructor(config, mode, callback) {\n super();\n /** Database connections */\n this.connections = [];\n this.config = typeof config === 'string' ? { connectionstring: config } : config;\n // mode is optional and so is callback\n // https://github.com/TryGhost/node-sqlite3/wiki/API#new-sqlite3databasefilename--mode--callback\n if (typeof mode === 'function') {\n callback = mode;\n mode = undefined;\n }\n // mode is ignored for now\n // opens first connection to the database automatically\n this.getConnection((error, _connection) => {\n if (callback) {\n callback.call(this, error);\n }\n });\n }\n //\n // private methods\n //\n /** Returns first available connection from connection pool */\n getConnection(callback) {\n var _a, _b, _c;\n // TODO sqlitecloud-js / implement database connection pool #10\n if (((_a = this.connections) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n }\n else {\n // connect using websocket if tls is not supported or if explicitly requested\n const useWebsocket = utilities_2.isBrowser || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.usewebsocket) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.gatewayurl);\n if (useWebsocket) {\n // socket.io transport works in both node.js and browser environments and connects via SQLite Cloud Gateway\n Promise.resolve().then(() => __importStar(__webpack_require__(/*! ./connection-ws */ \"./lib/drivers/connection-ws.js\"))).then(module => {\n this.connections.push(new module.default(this.config, error => {\n if (error) {\n this.handleError(this.connections[0], error, callback);\n }\n else {\n console.assert;\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n this.emitEvent('open');\n }\n }));\n })\n .catch(error => {\n this.handleError(null, error, callback);\n });\n }\n else {\n // tls sockets work only in node.js environments\n Promise.resolve().then(() => __importStar(__webpack_require__(/*! ./connection-tls */ \"./lib/drivers/connection-tls.js\"))).then(module => {\n this.connections.push(new module.default(this.config, error => {\n if (error) {\n this.handleError(this.connections[0], error, callback);\n }\n else {\n console.assert;\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, this.connections[0]);\n this.emitEvent('open');\n }\n }));\n })\n .catch(error => {\n this.handleError(null, error, callback);\n });\n }\n }\n }\n /** Handles an error by closing the connection, calling the callback and/or emitting an error event */\n handleError(connection, error, callback) {\n // an errored connection is thrown out\n if (connection) {\n this.connections = this.connections.filter(c => c !== connection);\n connection.close();\n }\n if (callback) {\n callback.call(this, error);\n }\n else {\n this.emitEvent('error', error);\n }\n }\n /**\n * Some queries like inserts or updates processed via run or exec may generate\n * an empty result (eg. no data was selected), but still have some metadata.\n * For example the server may pass the id of the last row that was modified.\n * In this case the callback results should be empty but the context may contain\n * additional information like lastID, etc.\n * @see https://github.com/TryGhost/node-sqlite3/wiki/API#runsql--param---callback\n * @param results Results received from the server\n * @returns A context object if one makes sense, otherwise undefined\n */\n processContext(results) {\n if (results) {\n if (Array.isArray(results) && results.length > 0) {\n switch (results[0]) {\n case types_1.SQLiteCloudArrayType.ARRAY_TYPE_SQLITE_EXEC:\n return {\n lastID: results[2], // ROWID (sqlite3_last_insert_rowid)\n changes: results[3], // CHANGES(sqlite3_changes)\n totalChanges: results[4], // TOTAL_CHANGES (sqlite3_total_changes)\n finalized: results[5] // FINALIZED\n };\n }\n }\n }\n return undefined;\n }\n /** Emits given event with optional arguments on the next tick so callbacks can complete first */\n emitEvent(event, ...args) {\n setTimeout(() => {\n this.emit(event, ...args);\n }, 0);\n }\n //\n // public methods\n //\n /**\n * Returns the configuration with which this database was opened.\n * The configuration is readonly and cannot be changed as there may\n * be multiple connections using the same configuration.\n * @returns {SQLiteCloudConfig} A configuration object\n */\n getConfiguration() {\n return JSON.parse(JSON.stringify(this.config));\n }\n /** Enable verbose mode */\n verbose() {\n this.config.verbose = true;\n for (const connection of this.connections) {\n connection.verbose();\n }\n return this;\n }\n /** Set a configuration option for the database */\n configure(_option, _value) {\n // https://github.com/TryGhost/node-sqlite3/wiki/API#configureoption-value\n return this;\n }\n run(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const command = { query: sql, parameters: args };\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(command, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n // context may include id of last row inserted, total changes, etc...\n const context = this.processContext(results);\n callback === null || callback === void 0 ? void 0 : callback.call(context || this, null, context ? context : results);\n }\n });\n }\n });\n return this;\n }\n get(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const command = { query: sql, parameters: args };\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(command, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (results && results instanceof rowset_1.SQLiteCloudRowset && results.length > 0) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, results[0]);\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n }\n });\n }\n });\n return this;\n }\n all(sql, ...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n const command = { query: sql, parameters: args };\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(command, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (results && results instanceof rowset_1.SQLiteCloudRowset) {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null, results);\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n }\n }\n });\n }\n });\n return this;\n }\n each(sql, ...params) {\n // extract optional parameters and one or two callbacks\n const { args, callback, complete } = (0, utilities_1.popCallback)(params);\n const command = { query: sql, parameters: args };\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(command, (error, rowset) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n if (rowset && rowset instanceof rowset_1.SQLiteCloudRowset) {\n if (callback) {\n for (const row of rowset) {\n callback.call(this, null, row);\n }\n }\n if (complete) {\n ;\n complete.call(this, null, rowset.numberOfRows);\n }\n }\n else {\n callback === null || callback === void 0 ? void 0 : callback.call(this, new types_1.SQLiteCloudError('Invalid rowset'));\n }\n }\n });\n }\n });\n return this;\n }\n /**\n * Prepares the SQL statement and optionally binds the specified parameters and\n * calls the callback when done. The function returns a Statement object.\n * When preparing was successful, the first and only argument to the callback\n * is null, otherwise it is the error object. When bind parameters are supplied,\n * they are bound to the prepared statement before calling the callback.\n */\n prepare(sql, ...params) {\n return new statement_1.Statement(this, sql, ...params);\n }\n /**\n * Runs all SQL queries in the supplied string. No result rows are retrieved.\n * The function returns the Database object to allow for function chaining.\n * If a query fails, no subsequent statements will be executed (wrap it in a\n * transaction if you want all or none to be executed). When all statements\n * have been executed successfully, or when an error occurs, the callback\n * function is called, with the first parameter being either null or an error\n * object. When no callback is provided and an error occurs, an error event\n * will be emitted on the database object.\n */\n exec(sql, callback) {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n this.handleError(null, error, callback);\n }\n else {\n connection.sendCommands(sql, (error, results) => {\n if (error) {\n this.handleError(connection, error, callback);\n }\n else {\n const context = this.processContext(results);\n callback === null || callback === void 0 ? void 0 : callback.call(context ? context : this, null);\n }\n });\n }\n });\n return this;\n }\n /**\n * If the optional callback is provided, this function will be called when the\n * database was closed successfully or when an error occurred. The first argument\n * is an error object. When it is null, closing succeeded. If no callback is provided\n * and an error occurred, an error event with the error object as the only parameter\n * will be emitted on the database object. If closing succeeded, a close event with no\n * parameters is emitted, regardless of whether a callback was provided or not.\n */\n close(callback) {\n var _a;\n if (((_a = this.connections) === null || _a === void 0 ? void 0 : _a.length) > 0) {\n for (const connection of this.connections) {\n connection.close();\n }\n }\n callback === null || callback === void 0 ? void 0 : callback.call(this, null);\n this.emitEvent('close');\n }\n /**\n * Loads a compiled SQLite extension into the database connection object.\n * @param path Filename of the extension to load.\n * @param callback If provided, this function will be called when the extension\n * was loaded successfully or when an error occurred. The first argument is an\n * error object. When it is null, loading succeeded. If no callback is provided\n * and an error occurred, an error event with the error object as the only parameter\n * will be emitted on the database object.\n */\n loadExtension(_path, callback) {\n // TODO sqlitecloud-js / implement database loadExtension #17\n if (callback) {\n callback.call(this, new Error('Database.loadExtension - Not implemented'));\n }\n else {\n this.emitEvent('error', new Error('Database.loadExtension - Not implemented'));\n }\n return this;\n }\n /**\n * Allows the user to interrupt long-running queries. Wrapper around\n * sqlite3_interrupt and causes other data-fetching functions to be\n * passed an err with code = sqlite3.INTERRUPT. The database must be\n * open to use this function.\n */\n interrupt() {\n // TODO sqlitecloud-js / implement database interrupt #13\n }\n //\n // extended APIs\n //\n /**\n * Sql is a promise based API for executing SQL statements. You can\n * pass a simple string with a SQL statement or a template string\n * using backticks and parameters in ${parameter} format. These parameters\n * will be properly escaped and quoted like when using a prepared statement.\n * @param sql A sql string or a template string in `backticks` format\n * @returns An array of rows in case of selections or an object with\n * metadata in case of insert, update, delete.\n */\n sql(sql, ...values) {\n return __awaiter(this, void 0, void 0, function* () {\n let commands = { query: '' };\n // sql is a TemplateStringsArray, the 'raw' property is specific to TemplateStringsArray\n if (Array.isArray(sql) && 'raw' in sql) {\n let query = '';\n sql.forEach((string, i) => {\n // TemplateStringsArray splits the string before each variable\n // used in the template. Add the question mark\n // to the end of the string for the number of used variables.\n query += string + (i < values.length ? '?' : '');\n });\n commands = { query, parameters: values };\n }\n else if (typeof sql === 'string') {\n commands = { query: sql, parameters: values };\n }\n else if (typeof sql === 'object') {\n commands = sql;\n }\n else {\n throw new Error('Invalid sql');\n }\n return new Promise((resolve, reject) => {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n reject(error);\n }\n else {\n connection.sendCommands(commands, (error, results) => {\n if (error) {\n reject(error);\n }\n else {\n // metadata for operations like insert, update, delete?\n const context = this.processContext(results);\n resolve(context ? context : results);\n }\n });\n }\n });\n });\n });\n }\n /**\n * PubSub class provides a Pub/Sub real-time updates and notifications system to\n * allow multiple applications to communicate with each other asynchronously.\n * It allows applications to subscribe to tables and receive notifications whenever\n * data changes in the database table. It also enables sending messages to anyone\n * subscribed to a specific channel.\n * @returns {PubSub} A PubSub object\n */\n getPubSub() {\n return __awaiter(this, void 0, void 0, function* () {\n return new Promise((resolve, reject) => {\n this.getConnection((error, connection) => {\n if (error || !connection) {\n reject(error);\n }\n else {\n resolve(new pubsub_1.PubSub(connection));\n }\n });\n });\n });\n }\n}\nexports.Database = Database;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/database.js?");
|
|
63
63
|
|
|
64
64
|
/***/ }),
|
|
65
65
|
|
|
@@ -70,7 +70,7 @@ eval("\n//\n// database.ts - database driver api, implements and extends sqlite3
|
|
|
70
70
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
71
71
|
|
|
72
72
|
"use strict";
|
|
73
|
-
eval("\n//\n// protocol.ts - low level protocol handling for SQLiteCloud transport\n//\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.formatCommand = exports.popData = exports.parseRowsetChunks = exports.bufferEndsWith = exports.bufferStartsWith = exports.parseRowsetHeader = exports.parseArray = exports.parseError = exports.decompressBuffer = exports.parseCommandLength = exports.hasCommandLength = exports.ROWSET_CHUNKS_END = exports.CMD_PUBSUB = exports.CMD_ARRAY = exports.CMD_COMMAND = exports.CMD_COMPRESSED = exports.CMD_BLOB = exports.CMD_NULL = exports.CMD_JSON = exports.CMD_ROWSET_CHUNK = exports.CMD_ROWSET = exports.CMD_FLOAT = exports.CMD_INT = exports.CMD_ERROR = exports.CMD_ZEROSTRING = exports.CMD_STRING = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\n// explicitly importing buffer library to allow cross-platform support by replacing it\nconst buffer_1 = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\n// https://www.npmjs.com/package/lz4js\nconst lz4 = __webpack_require__(/*! lz4js */ \"./node_modules/lz4js/lz4.js\");\n// The server communicates with clients via commands defined in\n// SQLiteCloud Server Protocol (SCSP), see more at:\n// https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md\nexports.CMD_STRING = '+';\nexports.CMD_ZEROSTRING = '!';\nexports.CMD_ERROR = '-';\nexports.CMD_INT = ':';\nexports.CMD_FLOAT = ',';\nexports.CMD_ROWSET = '*';\nexports.CMD_ROWSET_CHUNK = '/';\nexports.CMD_JSON = '#';\nexports.CMD_NULL = '_';\nexports.CMD_BLOB = '$';\nexports.CMD_COMPRESSED = '%';\nexports.CMD_COMMAND = '^';\nexports.CMD_ARRAY = '=';\n// const CMD_RAWJSON = '{'\nexports.CMD_PUBSUB = '|';\n// const CMD_RECONNECT = '@'\n// To mark the end of the Rowset, the special string /LEN 0 0 0 is sent (LEN is always 6 in this case)\n// https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-rowset-chunk\nexports.ROWSET_CHUNKS_END = '/6 0 0 0 ';\n//\n// utility functions\n//\n/** Analyze first character to check if corresponding data type has LEN */\nfunction hasCommandLength(firstCharacter) {\n return firstCharacter == exports.CMD_INT || firstCharacter == exports.CMD_FLOAT || firstCharacter == exports.CMD_NULL ? false : true;\n}\nexports.hasCommandLength = hasCommandLength;\n/** Analyze a command with explict LEN and extract it */\nfunction parseCommandLength(data) {\n return parseInt(data.subarray(1, data.indexOf(' ')).toString('utf8'));\n}\nexports.parseCommandLength = parseCommandLength;\n/** Receive a compressed buffer, decompress with lz4, return buffer and datatype */\nfunction decompressBuffer(buffer) {\n // https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-compression\n // jest test/database.test.ts -t \"select large result set\"\n // starts with %<commandLength> <compressed> <uncompressed>\n const spaceIndex = buffer.indexOf(' ');\n const commandLength = parseInt(buffer.subarray(1, spaceIndex).toString('utf8'));\n let commandBuffer = buffer.subarray(spaceIndex + 1, spaceIndex + 1 + commandLength);\n const remainingBuffer = buffer.subarray(spaceIndex + 1 + commandLength);\n // extract compressed + decompressed size\n const compressedSize = parseInt(commandBuffer.subarray(0, commandBuffer.indexOf(' ') + 1).toString('utf8'));\n commandBuffer = commandBuffer.subarray(commandBuffer.indexOf(' ') + 1);\n const decompressedSize = parseInt(commandBuffer.subarray(0, commandBuffer.indexOf(' ') + 1).toString('utf8'));\n commandBuffer = commandBuffer.subarray(commandBuffer.indexOf(' ') + 1);\n // extract compressed dataType\n const dataType = commandBuffer.subarray(0, 1).toString('utf8');\n let decompressedBuffer = buffer_1.Buffer.alloc(decompressedSize);\n const compressedBuffer = commandBuffer.subarray(commandBuffer.length - compressedSize);\n // lz4js library is javascript and doesn't have types so we silence the type check\n // eslint-disable-next-line\n const decompressionResult = lz4.decompressBlock(compressedBuffer, decompressedBuffer, 0, compressedSize, 0);\n // the entire command is composed of the header (which is not compressed) + the decompressed block\n decompressedBuffer = buffer_1.Buffer.concat([commandBuffer.subarray(0, commandBuffer.length - compressedSize), decompressedBuffer]);\n if (decompressionResult <= 0 || decompressionResult !== decompressedSize) {\n throw new Error(`lz4 decompression error at offset ${decompressionResult}`);\n }\n return { buffer: decompressedBuffer, dataType, remainingBuffer };\n}\nexports.decompressBuffer = decompressBuffer;\n/** Parse error message or extended error message */\nfunction parseError(buffer, spaceIndex) {\n const errorBuffer = buffer.subarray(spaceIndex + 1);\n const errorString = errorBuffer.toString('utf8');\n const parts = errorString.split(' ');\n let errorCodeStr = parts.shift() || '0'; // Default errorCode is '0' if not present\n let extErrCodeStr = '0'; // Default extended error code\n let offsetCodeStr = '-1'; // Default offset code\n // Split the errorCode by ':' to check for extended error codes\n const errorCodeParts = errorCodeStr.split(':');\n errorCodeStr = errorCodeParts[0];\n if (errorCodeParts.length > 1) {\n extErrCodeStr = errorCodeParts[1];\n if (errorCodeParts.length > 2) {\n offsetCodeStr = errorCodeParts[2];\n }\n }\n // Rest of the error string is the error message\n const errorMessage = parts.join(' ');\n // Parse error codes to integers safely, defaulting to 0 if NaN\n const errorCode = parseInt(errorCodeStr);\n const extErrCode = parseInt(extErrCodeStr);\n const offsetCode = parseInt(offsetCodeStr);\n // create an Error object and add the custom properties\n throw new types_1.SQLiteCloudError(errorMessage, {\n errorCode: errorCode.toString(),\n externalErrorCode: extErrCode.toString(),\n offsetCode\n });\n}\nexports.parseError = parseError;\n/** Parse an array of items (each of which will be parsed by type separately) */\nfunction parseArray(buffer, spaceIndex) {\n const parsedData = [];\n const array = buffer.subarray(spaceIndex + 1, buffer.length);\n const numberOfItems = parseInt(array.subarray(0, spaceIndex - 2).toString('utf8'));\n let arrayItems = array.subarray(array.indexOf(' ') + 1, array.length);\n for (let i = 0; i < numberOfItems; i++) {\n const { data, fwdBuffer: buffer } = popData(arrayItems);\n parsedData.push(data);\n arrayItems = buffer;\n }\n return parsedData;\n}\nexports.parseArray = parseArray;\n/** Parse header in a rowset or chunk of a chunked rowset */\nfunction parseRowsetHeader(buffer) {\n const index = parseInt(buffer.subarray(0, buffer.indexOf(':') + 1).toString());\n buffer = buffer.subarray(buffer.indexOf(':') + 1);\n // extract rowset header\n const { data, fwdBuffer } = popIntegers(buffer, 3);\n const result = {\n index,\n metadata: {\n version: data[0],\n numberOfRows: data[1],\n numberOfColumns: data[2],\n columns: []\n },\n fwdBuffer\n };\n // console.debug(`parseRowsetHeader`, result)\n return result;\n}\nexports.parseRowsetHeader = parseRowsetHeader;\n/** Extract column names and, optionally, more metadata out of a rowset's header */\nfunction parseRowsetColumnsMetadata(buffer, metadata) {\n function popForward() {\n const { data, fwdBuffer: fwdBuffer } = popData(buffer); // buffer in parent scope\n buffer = fwdBuffer;\n return data;\n }\n for (let i = 0; i < metadata.numberOfColumns; i++) {\n metadata.columns.push({ name: popForward() });\n }\n // extract additional metadata if rowset has version 2\n if (metadata.version == 2) {\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].type = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].database = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].table = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].column = popForward(); // original column name\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].notNull = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].primaryKey = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].autoIncrement = popForward();\n }\n return buffer;\n}\n/** Parse a regular rowset (no chunks) */\nfunction parseRowset(buffer, spaceIndex) {\n buffer = buffer.subarray(spaceIndex + 1, buffer.length);\n const { metadata, fwdBuffer } = parseRowsetHeader(buffer);\n buffer = parseRowsetColumnsMetadata(fwdBuffer, metadata);\n // decode each rowset item\n const data = [];\n for (let j = 0; j < metadata.numberOfRows * metadata.numberOfColumns; j++) {\n const { data: rowData, fwdBuffer } = popData(buffer);\n data.push(rowData);\n buffer = fwdBuffer;\n }\n console.assert(data && data.length === metadata.numberOfRows * metadata.numberOfColumns, 'SQLiteCloudConnection.parseRowset - invalid rowset data');\n return new rowset_1.SQLiteCloudRowset(metadata, data);\n}\nfunction bufferStartsWith(buffer, prefix) {\n return buffer.length >= prefix.length && buffer.subarray(0, prefix.length).toString('utf8') === prefix;\n}\nexports.bufferStartsWith = bufferStartsWith;\nfunction bufferEndsWith(buffer, suffix) {\n return buffer.length >= suffix.length && buffer.subarray(buffer.length - suffix.length, buffer.length).toString('utf8') === suffix;\n}\nexports.bufferEndsWith = bufferEndsWith;\n/**\n * Parse a chunk of a chunked rowset command, eg:\n * *LEN 0:VERS NROWS NCOLS DATA\n * @see https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-rowset-chunk\n */\nfunction parseRowsetChunks(buffers) {\n let buffer = buffer_1.Buffer.concat(buffers);\n if (!bufferStartsWith(buffer, exports.CMD_ROWSET_CHUNK) || !bufferEndsWith(buffer, exports.ROWSET_CHUNKS_END)) {\n throw new Error('SQLiteCloudConnection.parseRowsetChunks - invalid chunks buffer');\n }\n let metadata = { version: 1, numberOfColumns: 0, numberOfRows: 0, columns: [] };\n const data = [];\n // validate and skip data type\n const dataType = buffer.subarray(0, 1).toString();\n if (dataType !== exports.CMD_ROWSET_CHUNK)\n throw new Error(`parseRowsetChunks - dataType: ${dataType} should be CMD_ROWSET_CHUNK`);\n buffer = buffer.subarray(buffer.indexOf(' ') + 1);\n while (buffer.length > 0 && !bufferStartsWith(buffer, exports.ROWSET_CHUNKS_END)) {\n // chunk header, eg: 0:VERS NROWS NCOLS\n const { index: chunkIndex, metadata: chunkMetadata, fwdBuffer } = parseRowsetHeader(buffer);\n buffer = fwdBuffer;\n // first chunk? extract columns metadata\n if (chunkIndex === 1) {\n metadata = chunkMetadata;\n buffer = parseRowsetColumnsMetadata(buffer, metadata);\n }\n else {\n metadata.numberOfRows += chunkMetadata.numberOfRows;\n }\n // extract single rowset row\n for (let k = 0; k < chunkMetadata.numberOfRows * metadata.numberOfColumns; k++) {\n const { data: itemData, fwdBuffer } = popData(buffer);\n data.push(itemData);\n buffer = fwdBuffer;\n }\n }\n console.assert(data && data.length === metadata.numberOfRows * metadata.numberOfColumns, 'parseRowsetChunks - invalid rowset data');\n const rowset = new rowset_1.SQLiteCloudRowset(metadata, data);\n // console.debug(`parseRowsetChunks - ${rowset.numberOfRows} rows, ${rowset.numberOfColumns} columns`)\n return rowset;\n}\nexports.parseRowsetChunks = parseRowsetChunks;\n/** Pop one or more space separated integers from beginning of buffer, move buffer forward */\nfunction popIntegers(buffer, numberOfIntegers = 1) {\n const data = [];\n for (let i = 0; i < numberOfIntegers; i++) {\n const spaceIndex = buffer.indexOf(' ');\n data[i] = parseInt(buffer.subarray(0, spaceIndex).toString());\n buffer = buffer.subarray(spaceIndex + 1);\n }\n return { data, fwdBuffer: buffer };\n}\n/** Parse command, extract its data, return the data and the buffer moved to the first byte after the command */\nfunction popData(buffer) {\n function popResults(data) {\n const fwdBuffer = buffer.subarray(commandEnd);\n return { data, fwdBuffer };\n }\n // first character is the data type\n console.assert(buffer && buffer instanceof buffer_1.Buffer);\n let dataType = buffer.subarray(0, 1).toString('utf8');\n if (dataType == exports.CMD_COMPRESSED)\n throw new Error('Compressed data should be decompressed before parsing');\n if (dataType == exports.CMD_ROWSET_CHUNK)\n throw new Error('Chunked data should be parsed by parseRowsetChunks');\n let spaceIndex = buffer.indexOf(' ');\n if (spaceIndex === -1) {\n spaceIndex = buffer.length - 1;\n }\n let commandEnd = -1, commandLength = -1;\n if (dataType === exports.CMD_INT || dataType === exports.CMD_FLOAT || dataType === exports.CMD_NULL) {\n commandEnd = spaceIndex + 1;\n }\n else {\n commandLength = parseInt(buffer.subarray(1, spaceIndex).toString());\n commandEnd = spaceIndex + 1 + commandLength;\n }\n // console.debug(`popData - dataType: ${dataType}, spaceIndex: ${spaceIndex}, commandLength: ${commandLength}, commandEnd: ${commandEnd}`)\n switch (dataType) {\n case exports.CMD_INT:\n return popResults(parseInt(buffer.subarray(1, spaceIndex).toString()));\n case exports.CMD_FLOAT:\n return popResults(parseFloat(buffer.subarray(1, spaceIndex).toString()));\n case exports.CMD_NULL:\n return popResults(null);\n case exports.CMD_STRING:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_ZEROSTRING:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd - 1).toString('utf8'));\n case exports.CMD_COMMAND:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_PUBSUB:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_JSON:\n return popResults(JSON.parse(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8')));\n case exports.CMD_BLOB:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd));\n case exports.CMD_ARRAY:\n return popResults(parseArray(buffer, spaceIndex));\n case exports.CMD_ROWSET:\n return popResults(parseRowset(buffer, spaceIndex));\n case exports.CMD_ERROR:\n parseError(buffer, spaceIndex); // throws custom error\n break;\n }\n const msg = `popData - Data type: ${Number(dataType)} '${dataType}' is not defined in SCSP, spaceIndex: ${spaceIndex}, commandLength: ${commandLength}, commandEnd: ${commandEnd}`;\n console.error(msg);\n throw new TypeError(msg);\n}\nexports.popData = popData;\n/** Format a command to be sent via SCSP protocol */\nfunction formatCommand(command) {\n const commandLength = buffer_1.Buffer.byteLength(command, 'utf-8');\n return `+${commandLength} ${command}`;\n}\nexports.formatCommand = formatCommand;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/protocol.js?");
|
|
73
|
+
eval("\n//\n// protocol.ts - low level protocol handling for SQLiteCloud transport\n//\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ROWSET_CHUNKS_END = exports.CMD_PUBSUB = exports.CMD_ARRAY = exports.CMD_COMMAND = exports.CMD_COMPRESSED = exports.CMD_BLOB = exports.CMD_NULL = exports.CMD_JSON = exports.CMD_ROWSET_CHUNK = exports.CMD_ROWSET = exports.CMD_FLOAT = exports.CMD_INT = exports.CMD_ERROR = exports.CMD_ZEROSTRING = exports.CMD_STRING = void 0;\nexports.hasCommandLength = hasCommandLength;\nexports.parseCommandLength = parseCommandLength;\nexports.decompressBuffer = decompressBuffer;\nexports.parseError = parseError;\nexports.parseArray = parseArray;\nexports.parseRowsetHeader = parseRowsetHeader;\nexports.bufferStartsWith = bufferStartsWith;\nexports.bufferEndsWith = bufferEndsWith;\nexports.parseRowsetChunks = parseRowsetChunks;\nexports.popData = popData;\nexports.formatCommand = formatCommand;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst rowset_1 = __webpack_require__(/*! ./rowset */ \"./lib/drivers/rowset.js\");\n// explicitly importing buffer library to allow cross-platform support by replacing it\nconst buffer_1 = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\n// https://www.npmjs.com/package/lz4js\nconst lz4 = __webpack_require__(/*! lz4js */ \"./node_modules/lz4js/lz4.js\");\n// The server communicates with clients via commands defined in\n// SQLiteCloud Server Protocol (SCSP), see more at:\n// https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md\nexports.CMD_STRING = '+';\nexports.CMD_ZEROSTRING = '!';\nexports.CMD_ERROR = '-';\nexports.CMD_INT = ':';\nexports.CMD_FLOAT = ',';\nexports.CMD_ROWSET = '*';\nexports.CMD_ROWSET_CHUNK = '/';\nexports.CMD_JSON = '#';\nexports.CMD_NULL = '_';\nexports.CMD_BLOB = '$';\nexports.CMD_COMPRESSED = '%';\nexports.CMD_COMMAND = '^';\nexports.CMD_ARRAY = '=';\n// const CMD_RAWJSON = '{'\nexports.CMD_PUBSUB = '|';\n// const CMD_RECONNECT = '@'\n// To mark the end of the Rowset, the special string /LEN 0 0 0 is sent (LEN is always 6 in this case)\n// https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-rowset-chunk\nexports.ROWSET_CHUNKS_END = '/6 0 0 0 ';\n//\n// utility functions\n//\n/** Analyze first character to check if corresponding data type has LEN */\nfunction hasCommandLength(firstCharacter) {\n return firstCharacter == exports.CMD_INT || firstCharacter == exports.CMD_FLOAT || firstCharacter == exports.CMD_NULL ? false : true;\n}\n/** Analyze a command with explict LEN and extract it */\nfunction parseCommandLength(data) {\n return parseInt(data.subarray(1, data.indexOf(' ')).toString('utf8'));\n}\n/** Receive a compressed buffer, decompress with lz4, return buffer and datatype */\nfunction decompressBuffer(buffer) {\n // https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-compression\n // jest test/database.test.ts -t \"select large result set\"\n // starts with %<commandLength> <compressed> <uncompressed>\n const spaceIndex = buffer.indexOf(' ');\n const commandLength = parseInt(buffer.subarray(1, spaceIndex).toString('utf8'));\n let commandBuffer = buffer.subarray(spaceIndex + 1, spaceIndex + 1 + commandLength);\n const remainingBuffer = buffer.subarray(spaceIndex + 1 + commandLength);\n // extract compressed + decompressed size\n const compressedSize = parseInt(commandBuffer.subarray(0, commandBuffer.indexOf(' ') + 1).toString('utf8'));\n commandBuffer = commandBuffer.subarray(commandBuffer.indexOf(' ') + 1);\n const decompressedSize = parseInt(commandBuffer.subarray(0, commandBuffer.indexOf(' ') + 1).toString('utf8'));\n commandBuffer = commandBuffer.subarray(commandBuffer.indexOf(' ') + 1);\n // extract compressed dataType\n const dataType = commandBuffer.subarray(0, 1).toString('utf8');\n let decompressedBuffer = buffer_1.Buffer.alloc(decompressedSize);\n const compressedBuffer = commandBuffer.subarray(commandBuffer.length - compressedSize);\n // lz4js library is javascript and doesn't have types so we silence the type check\n const decompressionResult = lz4.decompressBlock(compressedBuffer, decompressedBuffer, 0, compressedSize, 0);\n // the entire command is composed of the header (which is not compressed) + the decompressed block\n decompressedBuffer = buffer_1.Buffer.concat([commandBuffer.subarray(0, commandBuffer.length - compressedSize), decompressedBuffer]);\n if (decompressionResult <= 0 || decompressionResult !== decompressedSize) {\n throw new Error(`lz4 decompression error at offset ${decompressionResult}`);\n }\n return { buffer: decompressedBuffer, dataType, remainingBuffer };\n}\n/** Parse error message or extended error message */\nfunction parseError(buffer, spaceIndex) {\n const errorBuffer = buffer.subarray(spaceIndex + 1);\n const errorString = errorBuffer.toString('utf8');\n const parts = errorString.split(' ');\n let errorCodeStr = parts.shift() || '0'; // Default errorCode is '0' if not present\n let extErrCodeStr = '0'; // Default extended error code\n let offsetCodeStr = '-1'; // Default offset code\n // Split the errorCode by ':' to check for extended error codes\n const errorCodeParts = errorCodeStr.split(':');\n errorCodeStr = errorCodeParts[0];\n if (errorCodeParts.length > 1) {\n extErrCodeStr = errorCodeParts[1];\n if (errorCodeParts.length > 2) {\n offsetCodeStr = errorCodeParts[2];\n }\n }\n // Rest of the error string is the error message\n const errorMessage = parts.join(' ');\n // Parse error codes to integers safely, defaulting to 0 if NaN\n const errorCode = parseInt(errorCodeStr);\n const extErrCode = parseInt(extErrCodeStr);\n const offsetCode = parseInt(offsetCodeStr);\n // create an Error object and add the custom properties\n throw new types_1.SQLiteCloudError(errorMessage, {\n errorCode: errorCode.toString(),\n externalErrorCode: extErrCode.toString(),\n offsetCode\n });\n}\n/** Parse an array of items (each of which will be parsed by type separately) */\nfunction parseArray(buffer, spaceIndex) {\n const parsedData = [];\n const array = buffer.subarray(spaceIndex + 1, buffer.length);\n const numberOfItems = parseInt(array.subarray(0, spaceIndex - 2).toString('utf8'));\n let arrayItems = array.subarray(array.indexOf(' ') + 1, array.length);\n for (let i = 0; i < numberOfItems; i++) {\n const { data, fwdBuffer: buffer } = popData(arrayItems);\n parsedData.push(data);\n arrayItems = buffer;\n }\n return parsedData;\n}\n/** Parse header in a rowset or chunk of a chunked rowset */\nfunction parseRowsetHeader(buffer) {\n const index = parseInt(buffer.subarray(0, buffer.indexOf(':') + 1).toString());\n buffer = buffer.subarray(buffer.indexOf(':') + 1);\n // extract rowset header\n const { data, fwdBuffer } = popIntegers(buffer, 3);\n const result = {\n index,\n metadata: {\n version: data[0],\n numberOfRows: data[1],\n numberOfColumns: data[2],\n columns: []\n },\n fwdBuffer\n };\n // console.debug(`parseRowsetHeader`, result)\n return result;\n}\n/** Extract column names and, optionally, more metadata out of a rowset's header */\nfunction parseRowsetColumnsMetadata(buffer, metadata) {\n function popForward() {\n const { data, fwdBuffer: fwdBuffer } = popData(buffer); // buffer in parent scope\n buffer = fwdBuffer;\n return data;\n }\n for (let i = 0; i < metadata.numberOfColumns; i++) {\n metadata.columns.push({ name: popForward() });\n }\n // extract additional metadata if rowset has version 2\n if (metadata.version == 2) {\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].type = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].database = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].table = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].column = popForward(); // original column name\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].notNull = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].primaryKey = popForward();\n for (let i = 0; i < metadata.numberOfColumns; i++)\n metadata.columns[i].autoIncrement = popForward();\n }\n return buffer;\n}\n/** Parse a regular rowset (no chunks) */\nfunction parseRowset(buffer, spaceIndex) {\n buffer = buffer.subarray(spaceIndex + 1, buffer.length);\n const { metadata, fwdBuffer } = parseRowsetHeader(buffer);\n buffer = parseRowsetColumnsMetadata(fwdBuffer, metadata);\n // decode each rowset item\n const data = [];\n for (let j = 0; j < metadata.numberOfRows * metadata.numberOfColumns; j++) {\n const { data: rowData, fwdBuffer } = popData(buffer);\n data.push(rowData);\n buffer = fwdBuffer;\n }\n console.assert(data && data.length === metadata.numberOfRows * metadata.numberOfColumns, 'SQLiteCloudConnection.parseRowset - invalid rowset data');\n return new rowset_1.SQLiteCloudRowset(metadata, data);\n}\nfunction bufferStartsWith(buffer, prefix) {\n return buffer.length >= prefix.length && buffer.subarray(0, prefix.length).toString('utf8') === prefix;\n}\nfunction bufferEndsWith(buffer, suffix) {\n return buffer.length >= suffix.length && buffer.subarray(buffer.length - suffix.length, buffer.length).toString('utf8') === suffix;\n}\n/**\n * Parse a chunk of a chunked rowset command, eg:\n * *LEN 0:VERS NROWS NCOLS DATA\n * @see https://github.com/sqlitecloud/sdk/blob/master/PROTOCOL.md#scsp-rowset-chunk\n */\nfunction parseRowsetChunks(buffers) {\n let buffer = buffer_1.Buffer.concat(buffers);\n if (!bufferStartsWith(buffer, exports.CMD_ROWSET_CHUNK) || !bufferEndsWith(buffer, exports.ROWSET_CHUNKS_END)) {\n throw new Error('SQLiteCloudConnection.parseRowsetChunks - invalid chunks buffer');\n }\n let metadata = { version: 1, numberOfColumns: 0, numberOfRows: 0, columns: [] };\n const data = [];\n // validate and skip data type\n const dataType = buffer.subarray(0, 1).toString();\n if (dataType !== exports.CMD_ROWSET_CHUNK)\n throw new Error(`parseRowsetChunks - dataType: ${dataType} should be CMD_ROWSET_CHUNK`);\n buffer = buffer.subarray(buffer.indexOf(' ') + 1);\n while (buffer.length > 0 && !bufferStartsWith(buffer, exports.ROWSET_CHUNKS_END)) {\n // chunk header, eg: 0:VERS NROWS NCOLS\n const { index: chunkIndex, metadata: chunkMetadata, fwdBuffer } = parseRowsetHeader(buffer);\n buffer = fwdBuffer;\n // first chunk? extract columns metadata\n if (chunkIndex === 1) {\n metadata = chunkMetadata;\n buffer = parseRowsetColumnsMetadata(buffer, metadata);\n }\n else {\n metadata.numberOfRows += chunkMetadata.numberOfRows;\n }\n // extract single rowset row\n for (let k = 0; k < chunkMetadata.numberOfRows * metadata.numberOfColumns; k++) {\n const { data: itemData, fwdBuffer } = popData(buffer);\n data.push(itemData);\n buffer = fwdBuffer;\n }\n }\n console.assert(data && data.length === metadata.numberOfRows * metadata.numberOfColumns, 'parseRowsetChunks - invalid rowset data');\n const rowset = new rowset_1.SQLiteCloudRowset(metadata, data);\n // console.debug(`parseRowsetChunks - ${rowset.numberOfRows} rows, ${rowset.numberOfColumns} columns`)\n return rowset;\n}\n/** Pop one or more space separated integers from beginning of buffer, move buffer forward */\nfunction popIntegers(buffer, numberOfIntegers = 1) {\n const data = [];\n for (let i = 0; i < numberOfIntegers; i++) {\n const spaceIndex = buffer.indexOf(' ');\n data[i] = parseInt(buffer.subarray(0, spaceIndex).toString());\n buffer = buffer.subarray(spaceIndex + 1);\n }\n return { data, fwdBuffer: buffer };\n}\n/** Parse command, extract its data, return the data and the buffer moved to the first byte after the command */\nfunction popData(buffer) {\n function popResults(data) {\n const fwdBuffer = buffer.subarray(commandEnd);\n return { data, fwdBuffer };\n }\n // first character is the data type\n console.assert(buffer && buffer instanceof buffer_1.Buffer);\n let dataType = buffer.subarray(0, 1).toString('utf8');\n if (dataType == exports.CMD_COMPRESSED)\n throw new Error('Compressed data should be decompressed before parsing');\n if (dataType == exports.CMD_ROWSET_CHUNK)\n throw new Error('Chunked data should be parsed by parseRowsetChunks');\n let spaceIndex = buffer.indexOf(' ');\n if (spaceIndex === -1) {\n spaceIndex = buffer.length - 1;\n }\n let commandEnd = -1, commandLength = -1;\n if (dataType === exports.CMD_INT || dataType === exports.CMD_FLOAT || dataType === exports.CMD_NULL) {\n commandEnd = spaceIndex + 1;\n }\n else {\n commandLength = parseInt(buffer.subarray(1, spaceIndex).toString());\n commandEnd = spaceIndex + 1 + commandLength;\n }\n // console.debug(`popData - dataType: ${dataType}, spaceIndex: ${spaceIndex}, commandLength: ${commandLength}, commandEnd: ${commandEnd}`)\n switch (dataType) {\n case exports.CMD_INT:\n return popResults(parseInt(buffer.subarray(1, spaceIndex).toString()));\n case exports.CMD_FLOAT:\n return popResults(parseFloat(buffer.subarray(1, spaceIndex).toString()));\n case exports.CMD_NULL:\n return popResults(null);\n case exports.CMD_STRING:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_ZEROSTRING:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd - 1).toString('utf8'));\n case exports.CMD_COMMAND:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_PUBSUB:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8'));\n case exports.CMD_JSON:\n return popResults(JSON.parse(buffer.subarray(spaceIndex + 1, commandEnd).toString('utf8')));\n case exports.CMD_BLOB:\n return popResults(buffer.subarray(spaceIndex + 1, commandEnd));\n case exports.CMD_ARRAY:\n return popResults(parseArray(buffer, spaceIndex));\n case exports.CMD_ROWSET:\n return popResults(parseRowset(buffer, spaceIndex));\n case exports.CMD_ERROR:\n parseError(buffer, spaceIndex); // throws custom error\n break;\n }\n const msg = `popData - Data type: ${Number(dataType)} '${dataType}' is not defined in SCSP, spaceIndex: ${spaceIndex}, commandLength: ${commandLength}, commandEnd: ${commandEnd}`;\n console.error(msg);\n throw new TypeError(msg);\n}\n/** Format a command to be sent via SCSP protocol */\nfunction formatCommand(command) {\n if (command.parameters && command.parameters.length > 0) {\n // by SCSP the string paramenters in the array are zero-terminated\n return serializeCommand([command.query, ...(command.parameters || [])], true);\n }\n return serializeData(command.query, false);\n}\nfunction serializeCommand(data, zeroString = false) {\n const n = data.length;\n let serializedData = `${n} `;\n for (let i = 0; i < n; i++) {\n // the first string is the sql and it must be zero-terminated\n const zs = i == 0 || zeroString;\n serializedData += serializeData(data[i], zs);\n }\n const header = `${exports.CMD_ARRAY}${serializedData.length} `;\n return header + serializedData;\n}\nfunction serializeData(data, zeroString = false) {\n if (typeof data === 'string') {\n let cmd = exports.CMD_STRING;\n if (zeroString) {\n cmd = exports.CMD_ZEROSTRING;\n data += '\\0';\n }\n const header = `${cmd}${buffer_1.Buffer.byteLength(data, 'utf-8')} `;\n return header + data;\n }\n if (typeof data === 'number') {\n if (Number.isInteger(data)) {\n return `${exports.CMD_INT}${data} `;\n }\n else {\n return `${exports.CMD_FLOAT}${data} `;\n }\n }\n if (buffer_1.Buffer.isBuffer(data)) {\n const header = `${exports.CMD_BLOB}${data.length} `;\n return header + data.toString('utf-8');\n }\n if (data === null || data === undefined) {\n return `${exports.CMD_NULL} `;\n }\n if (Array.isArray(data)) {\n return serializeCommand(data, zeroString);\n }\n throw new Error(`Unsupported data type for serialization: ${typeof data}`);\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/protocol.js?");
|
|
74
74
|
|
|
75
75
|
/***/ }),
|
|
76
76
|
|
|
@@ -81,7 +81,7 @@ eval("\n//\n// protocol.ts - low level protocol handling for SQLiteCloud transpo
|
|
|
81
81
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
82
82
|
|
|
83
83
|
"use strict";
|
|
84
|
-
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.PubSub = exports.PUBSUB_ENTITY_TYPE = void 0;\nconst connection_tls_1 = __importDefault(__webpack_require__(/*! ./connection-tls */ \"./lib/drivers/connection-tls.js\"));\nvar PUBSUB_ENTITY_TYPE;\n(function (PUBSUB_ENTITY_TYPE) {\n PUBSUB_ENTITY_TYPE[\"TABLE\"] = \"TABLE\";\n PUBSUB_ENTITY_TYPE[\"CHANNEL\"] = \"CHANNEL\";\n})(PUBSUB_ENTITY_TYPE
|
|
84
|
+
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.PubSub = exports.PUBSUB_ENTITY_TYPE = void 0;\nconst connection_tls_1 = __importDefault(__webpack_require__(/*! ./connection-tls */ \"./lib/drivers/connection-tls.js\"));\nvar PUBSUB_ENTITY_TYPE;\n(function (PUBSUB_ENTITY_TYPE) {\n PUBSUB_ENTITY_TYPE[\"TABLE\"] = \"TABLE\";\n PUBSUB_ENTITY_TYPE[\"CHANNEL\"] = \"CHANNEL\";\n})(PUBSUB_ENTITY_TYPE || (exports.PUBSUB_ENTITY_TYPE = PUBSUB_ENTITY_TYPE = {}));\n/**\n * Pub/Sub class to receive changes on database tables or to send messages to channels.\n */\nclass PubSub {\n constructor(connection) {\n this.connection = connection;\n this.connectionPubSub = new connection_tls_1.default(connection.getConfig());\n }\n /**\n * Listen for a table or channel and start to receive messages to the provided callback.\n * @param entityType One of TABLE or CHANNEL'\n * @param entityName Name of the table or the channel\n * @param callback Callback to be called when a message is received\n * @param data Extra data to be passed to the callback\n */\n listen(entityType, entityName, callback, data) {\n return __awaiter(this, void 0, void 0, function* () {\n const entity = entityType === 'TABLE' ? 'TABLE ' : '';\n const authCommand = yield this.connection.sql(`LISTEN ${entity}${entityName};`);\n return new Promise((resolve, reject) => {\n this.connectionPubSub.sendCommands(authCommand, (error, results) => {\n if (error) {\n callback.call(this, error, null, data);\n reject(error);\n }\n else {\n // skip results from pubSub auth command\n if (results !== 'OK') {\n callback.call(this, null, results, data);\n }\n resolve(results);\n }\n });\n });\n });\n }\n /**\n * Stop receive messages from a table or channel.\n * @param entityType One of TABLE or CHANNEL\n * @param entityName Name of the table or the channel\n */\n unlisten(entityType, entityName) {\n return __awaiter(this, void 0, void 0, function* () {\n const subject = entityType === 'TABLE' ? 'TABLE ' : '';\n return this.connection.sql(`UNLISTEN ${subject}?;`, entityName);\n });\n }\n /**\n * Create a channel to send messages to.\n * @param name Channel name\n * @param failIfExists Raise an error if the channel already exists\n */\n createChannel(name_1) {\n return __awaiter(this, arguments, void 0, function* (name, failIfExists = true) {\n let notExistsCommand = '';\n if (!failIfExists) {\n notExistsCommand = ' IF NOT EXISTS';\n }\n return this.connection.sql(`CREATE CHANNEL ?${notExistsCommand};`, name);\n });\n }\n /**\n * Deletes a Pub/Sub channel.\n * @param name Channel name\n */\n removeChannel(name) {\n return __awaiter(this, void 0, void 0, function* () {\n return this.connection.sql(`REMOVE CHANNEL ?;`, name);\n });\n }\n /**\n * Send a message to the channel.\n */\n notifyChannel(channelName, message) {\n return this.connection.sql `NOTIFY ${channelName} ${message};`;\n }\n /**\n * Ask the server to close the connection to the database and\n * to keep only open the Pub/Sub connection.\n * Only interaction with Pub/Sub commands will be allowed.\n */\n setPubSubOnly() {\n return new Promise((resolve, reject) => {\n this.connection.sendCommands('PUBSUB ONLY;', (error, results) => {\n if (error) {\n reject(error);\n }\n else {\n this.connection.close();\n resolve(results);\n }\n });\n });\n }\n /** True if Pub/Sub connection is open. */\n connected() {\n return this.connectionPubSub.connected;\n }\n /** Close Pub/Sub connection. */\n close() {\n this.connectionPubSub.close();\n }\n}\nexports.PubSub = PubSub;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/pubsub.js?");
|
|
85
85
|
|
|
86
86
|
/***/ }),
|
|
87
87
|
|
|
@@ -114,7 +114,7 @@ eval("\n//\n// rowset.ts\n//\nvar __classPrivateFieldSet = (this && this.__class
|
|
|
114
114
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
115
115
|
|
|
116
116
|
"use strict";
|
|
117
|
-
eval("\n/**\n * statement.ts\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Statement = void 0;\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\n
|
|
117
|
+
eval("\n/**\n * statement.ts\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Statement = void 0;\nconst utilities_1 = __webpack_require__(/*! ./utilities */ \"./lib/drivers/utilities.js\");\n/**\n * A statement generated by Database.prepare used to prepare SQL with ? bindings.\n *\n * SCSP protocol does not support named placeholders yet.\n */\nclass Statement {\n constructor(database, sql, ...params) {\n /** The SQL statement with binding values applied */\n this._preparedSql = { query: '' };\n this._database = database;\n this._sql = sql;\n this.bind(...params);\n }\n /**\n * Binds parameters to the prepared statement and calls the callback when done\n * or when an error occurs. The function returns the Statement object to allow\n * for function chaining. The first and only argument to the callback is null\n * when binding was successful. Binding parameters with this function completely\n * resets the statement object and row cursor and removes all previously bound\n * parameters, if any.\n *\n * In SQLiteCloud the statement is prepared on the database server and binding errors\n * are raised on execution time.\n */\n bind(...params) {\n const { args, callback } = (0, utilities_1.popCallback)(params);\n this._preparedSql = { query: this._sql, parameters: args };\n if (callback) {\n callback.call(this, null);\n }\n return this;\n }\n run(...params) {\n var _a;\n const { args, callback } = (0, utilities_1.popCallback)(params || []);\n if ((args === null || args === void 0 ? void 0 : args.length) > 0) {\n // apply new bindings then execute\n this.bind(...args, () => {\n var _a;\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.run(query, ...parametes, callback);\n });\n }\n else {\n // execute prepared sql with same bindings\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.run(query, ...parametes, callback);\n }\n return this;\n }\n get(...params) {\n var _a;\n const { args, callback } = (0, utilities_1.popCallback)(params || []);\n if ((args === null || args === void 0 ? void 0 : args.length) > 0) {\n // apply new bindings then execute\n this.bind(...args, () => {\n var _a;\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.get(query, ...parametes, callback);\n });\n }\n else {\n // execute prepared sql with same bindings\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.get(query, ...parametes, callback);\n }\n return this;\n }\n all(...params) {\n var _a;\n const { args, callback } = (0, utilities_1.popCallback)(params || []);\n if ((args === null || args === void 0 ? void 0 : args.length) > 0) {\n // apply new bindings then execute\n this.bind(...args, () => {\n var _a;\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.all(query, ...parametes, callback);\n });\n }\n else {\n // execute prepared sql with same bindings\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : [])];\n this._database.all(query, ...parametes, callback);\n }\n return this;\n }\n each(...params) {\n var _a;\n const { args, callback, complete } = (0, utilities_1.popCallback)(params);\n if ((args === null || args === void 0 ? void 0 : args.length) > 0) {\n // apply new bindings then execute\n this.bind(...args, () => {\n var _a;\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : []), ...[callback, complete]];\n this._database.each(query, ...parametes);\n });\n }\n else {\n // execute prepared sql with same bindings\n const query = this._preparedSql.query || '';\n const parametes = [...((_a = this._preparedSql.parameters) !== null && _a !== void 0 ? _a : []), ...[callback, complete]];\n this._database.each(query, ...parametes);\n }\n return this;\n }\n}\nexports.Statement = Statement;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/statement.js?");
|
|
118
118
|
|
|
119
119
|
/***/ }),
|
|
120
120
|
|
|
@@ -125,7 +125,7 @@ eval("\n/**\n * statement.ts\n */\nObject.defineProperty(exports, \"__esModule\"
|
|
|
125
125
|
/***/ ((__unused_webpack_module, exports) => {
|
|
126
126
|
|
|
127
127
|
"use strict";
|
|
128
|
-
eval("\n/**\n * types.ts - shared types and interfaces\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudArrayType = exports.SQLiteCloudError = exports.DEFAULT_PORT = exports.DEFAULT_TIMEOUT = void 0;\n/** Default timeout value for queries */\nexports.DEFAULT_TIMEOUT = 300 * 1000;\n/** Default tls connection port */\nexports.DEFAULT_PORT = 8860;\n/** Custom error reported by SQLiteCloud drivers */\nclass SQLiteCloudError extends Error {\n constructor(message, args) {\n super(message);\n this.name = 'SQLiteCloudError';\n if (args) {\n Object.assign(this, args);\n }\n }\n}\nexports.SQLiteCloudError = SQLiteCloudError;\n/**\n * Certain responses include arrays with various types of metadata.\n * The first entry is always an array type from this list. This enum\n * is called SQCLOUD_ARRAY_TYPE in the C API.\n */\nvar SQLiteCloudArrayType;\n(function (SQLiteCloudArrayType) {\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_SQLITE_EXEC\"] = 10] = \"ARRAY_TYPE_SQLITE_EXEC\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_DB_STATUS\"] = 11] = \"ARRAY_TYPE_DB_STATUS\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_METADATA\"] = 12] = \"ARRAY_TYPE_METADATA\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STEP\"] = 20] = \"ARRAY_TYPE_VM_STEP\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_COMPILE\"] = 21] = \"ARRAY_TYPE_VM_COMPILE\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STEP_ONE\"] = 22] = \"ARRAY_TYPE_VM_STEP_ONE\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_SQL\"] = 23] = \"ARRAY_TYPE_VM_SQL\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STATUS\"] = 24] = \"ARRAY_TYPE_VM_STATUS\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_LIST\"] = 25] = \"ARRAY_TYPE_VM_LIST\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_INIT\"] = 40] = \"ARRAY_TYPE_BACKUP_INIT\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_STEP\"] = 41] = \"ARRAY_TYPE_BACKUP_STEP\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_END\"] = 42] = \"ARRAY_TYPE_BACKUP_END\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_SQLITE_STATUS\"] = 50] = \"ARRAY_TYPE_SQLITE_STATUS\"; // used in sqlite_status\n})(SQLiteCloudArrayType
|
|
128
|
+
eval("\n/**\n * types.ts - shared types and interfaces\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.SQLiteCloudArrayType = exports.SQLiteCloudError = exports.DEFAULT_PORT = exports.DEFAULT_TIMEOUT = void 0;\n/** Default timeout value for queries */\nexports.DEFAULT_TIMEOUT = 300 * 1000;\n/** Default tls connection port */\nexports.DEFAULT_PORT = 8860;\n/** Custom error reported by SQLiteCloud drivers */\nclass SQLiteCloudError extends Error {\n constructor(message, args) {\n super(message);\n this.name = 'SQLiteCloudError';\n if (args) {\n Object.assign(this, args);\n }\n }\n}\nexports.SQLiteCloudError = SQLiteCloudError;\n/**\n * Certain responses include arrays with various types of metadata.\n * The first entry is always an array type from this list. This enum\n * is called SQCLOUD_ARRAY_TYPE in the C API.\n */\nvar SQLiteCloudArrayType;\n(function (SQLiteCloudArrayType) {\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_SQLITE_EXEC\"] = 10] = \"ARRAY_TYPE_SQLITE_EXEC\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_DB_STATUS\"] = 11] = \"ARRAY_TYPE_DB_STATUS\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_METADATA\"] = 12] = \"ARRAY_TYPE_METADATA\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STEP\"] = 20] = \"ARRAY_TYPE_VM_STEP\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_COMPILE\"] = 21] = \"ARRAY_TYPE_VM_COMPILE\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STEP_ONE\"] = 22] = \"ARRAY_TYPE_VM_STEP_ONE\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_SQL\"] = 23] = \"ARRAY_TYPE_VM_SQL\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_STATUS\"] = 24] = \"ARRAY_TYPE_VM_STATUS\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_VM_LIST\"] = 25] = \"ARRAY_TYPE_VM_LIST\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_INIT\"] = 40] = \"ARRAY_TYPE_BACKUP_INIT\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_STEP\"] = 41] = \"ARRAY_TYPE_BACKUP_STEP\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_BACKUP_END\"] = 42] = \"ARRAY_TYPE_BACKUP_END\";\n SQLiteCloudArrayType[SQLiteCloudArrayType[\"ARRAY_TYPE_SQLITE_STATUS\"] = 50] = \"ARRAY_TYPE_SQLITE_STATUS\"; // used in sqlite_status\n})(SQLiteCloudArrayType || (exports.SQLiteCloudArrayType = SQLiteCloudArrayType = {}));\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/types.js?");
|
|
129
129
|
|
|
130
130
|
/***/ }),
|
|
131
131
|
|
|
@@ -136,7 +136,7 @@ eval("\n/**\n * types.ts - shared types and interfaces\n */\nObject.defineProper
|
|
|
136
136
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
137
137
|
|
|
138
138
|
"use strict";
|
|
139
|
-
eval("\n//\n// utilities.ts - utility methods to manipulate SQL statements\n//\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.parseBooleanToZeroOne = exports.parseBoolean = exports.parseconnectionstring = exports.validateConfiguration = exports.popCallback = exports.getUpdateResults = exports.prepareSql = exports.escapeSqlParameter = exports.getInitializationCommands = exports.anonimizeError = exports.anonimizeCommand = exports.isNode = exports.isBrowser = void 0;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst types_2 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\n// explicitly importing these libraries to allow cross-platform support by replacing them\nconst whatwg_url_1 = __webpack_require__(/*! whatwg-url */ \"./node_modules/whatwg-url/index.js\");\nconst buffer_1 = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\n//\n// determining running environment, thanks to browser-or-node\n// https://www.npmjs.com/package/browser-or-node\n//\nexports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\nexports.isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n//\n// utility methods\n//\n/** Messages going to the server are sometimes logged when error conditions occour and need to be stripped of user credentials */\nfunction anonimizeCommand(message) {\n // hide password in AUTH command if needed\n message = message.replace(/USER \\S+/, 'USER ******');\n message = message.replace(/PASSWORD \\S+?(?=;)/, 'PASSWORD ******');\n message = message.replace(/HASH \\S+?(?=;)/, 'HASH ******');\n return message;\n}\nexports.anonimizeCommand = anonimizeCommand;\n/** Strip message code in error of user credentials */\nfunction anonimizeError(error) {\n if (error === null || error === void 0 ? void 0 : error.message) {\n error.message = anonimizeCommand(error.message);\n }\n return error;\n}\nexports.anonimizeError = anonimizeError;\n/** Initialization commands sent to database when connection is established */\nfunction getInitializationCommands(config) {\n // we check the credentials using non linearizable so we're quicker\n // then we bring back linearizability unless specified otherwise\n let commands = 'SET CLIENT KEY NONLINEARIZABLE TO 1; ';\n // first user authentication, then all other commands\n if (config.apikey) {\n commands += `AUTH APIKEY ${config.apikey}; `;\n }\n else {\n commands += `AUTH USER ${config.username || ''} ${config.password_hashed ? 'HASH' : 'PASSWORD'} ${config.password || ''}; `;\n }\n if (config.compression) {\n commands += 'SET CLIENT KEY COMPRESSION TO 1; ';\n }\n if (config.zerotext) {\n commands += 'SET CLIENT KEY ZEROTEXT TO 1; ';\n }\n if (config.noblob) {\n commands += 'SET CLIENT KEY NOBLOB TO 1; ';\n }\n if (config.maxdata) {\n commands += `SET CLIENT KEY MAXDATA TO ${config.maxdata}; `;\n }\n if (config.maxrows) {\n commands += `SET CLIENT KEY MAXROWS TO ${config.maxrows}; `;\n }\n if (config.maxrowset) {\n commands += `SET CLIENT KEY MAXROWSET TO ${config.maxrowset}; `;\n }\n // we ALWAYS set non linearizable to 1 when we start so we can be quicker on login\n // but then we need to put it back to its default value if \"linearizable\" unless set\n if (!config.non_linearizable) {\n commands += 'SET CLIENT KEY NONLINEARIZABLE TO 0; ';\n }\n if (config.database) {\n if (config.create && !config.memory) {\n commands += `CREATE DATABASE ${config.database} IF NOT EXISTS; `;\n }\n commands += `USE DATABASE ${config.database}; `;\n }\n return commands;\n}\nexports.getInitializationCommands = getInitializationCommands;\n/** Takes a generic value and escapes it so it can replace ? as a binding in a prepared SQL statement */\nfunction escapeSqlParameter(param) {\n if (param === null || param === undefined) {\n return 'NULL';\n }\n if (typeof param === 'string') {\n // replace single quote with two single quotes\n param = param.replace(/'/g, \"''\");\n return `'${param}'`;\n }\n if (typeof param === 'number' || typeof param === 'bigint') {\n return param.toString();\n }\n if (typeof param === 'boolean') {\n return param ? '1' : '0';\n }\n // serialize buffer as X'...' hex encoded string\n if (buffer_1.Buffer.isBuffer(param)) {\n return `X'${param.toString('hex')}'`;\n }\n if (typeof param === 'object') {\n // serialize json then escape single quotes\n let json = JSON.stringify(param);\n json = json.replace(/'/g, \"''\");\n return `'${json}'`;\n }\n throw new types_1.SQLiteCloudError(`Unsupported parameter type: ${typeof param}`);\n}\nexports.escapeSqlParameter = escapeSqlParameter;\n/** Take a sql statement and replaces ? or $named parameters that are properly serialized and escaped. */\nfunction prepareSql(sql, ...params) {\n // parameters where passed as an array of parameters?\n if ((params === null || params === void 0 ? void 0 : params.length) === 1 && Array.isArray(params[0])) {\n params = params[0];\n }\n // replace ? or ?idx parameters passed as args or as an array\n let parameterIndex = 1;\n let preparedSql = sql.replace(/\\?(\\d+)?/g, (match, matchIndex) => {\n const index = matchIndex ? parseInt(matchIndex) : parameterIndex;\n parameterIndex++;\n let sqlParameter;\n if (params[0] && typeof params[0] === 'object' && !(params[0] instanceof buffer_1.Buffer)) {\n sqlParameter = params[0][index];\n }\n if (!sqlParameter) {\n if (index > params.length) {\n throw new types_1.SQLiteCloudError('Not enough parameters');\n }\n sqlParameter = params[index - 1];\n }\n return sqlParameter !== null && sqlParameter !== undefined ? escapeSqlParameter(sqlParameter) : 'NULL';\n });\n // replace $named or :named parameters passed as an object\n if ((params === null || params === void 0 ? void 0 : params.length) === 1 && params[0] && typeof params[0] === 'object') {\n const namedParams = params[0];\n for (const [paramKey, param] of Object.entries(namedParams)) {\n const firstChar = paramKey.charAt(0);\n if (firstChar == '$' || firstChar == ':' || firstChar == '@') {\n const escapedParam = escapeSqlParameter(param);\n preparedSql = preparedSql.replace(new RegExp(`\\\\${paramKey}`, 'g'), escapedParam);\n }\n }\n }\n return preparedSql;\n}\nexports.prepareSql = prepareSql;\n/** Converts results of an update or insert call into a more meaning full result set */\nfunction getUpdateResults(results) {\n if (results) {\n if (Array.isArray(results) && results.length > 0) {\n switch (results[0]) {\n case types_2.SQLiteCloudArrayType.ARRAY_TYPE_SQLITE_EXEC:\n return {\n type: results[0],\n index: results[1],\n lastID: results[2],\n changes: results[3],\n totalChanges: results[4],\n finalized: results[5],\n //\n rowId: results[2] // same as lastId\n };\n }\n }\n }\n return undefined;\n}\nexports.getUpdateResults = getUpdateResults;\n/**\n * Many of the methods in our API may contain a callback as their last argument.\n * This method will take the arguments array passed to the method and return an object\n * containing the arguments array with the callbacks removed (if any), and the callback itself.\n * If there are multiple callbacks, the first one is returned as 'callback' and the last one\n * as 'completeCallback'.\n */\nfunction popCallback(args) {\n const remaining = args;\n // at least 1 callback?\n if (args && args.length > 0 && typeof args[args.length - 1] === 'function') {\n // at least 2 callbacks?\n if (args.length > 1 && typeof args[args.length - 2] === 'function') {\n return { args: remaining.slice(0, -2), callback: args[args.length - 2], complete: args[args.length - 1] };\n }\n return { args: remaining.slice(0, -1), callback: args[args.length - 1] };\n }\n return { args: remaining };\n}\nexports.popCallback = popCallback;\n//\n// configuration validation\n//\n/** Validate configuration, apply defaults, throw if something is missing or misconfigured */\nfunction validateConfiguration(config) {\n console.assert(config, 'SQLiteCloudConnection.validateConfiguration - missing config');\n if (config.connectionstring) {\n config = Object.assign(Object.assign(Object.assign({}, config), parseconnectionstring(config.connectionstring)), { connectionstring: config.connectionstring // keep original connection string\n });\n }\n // apply defaults where needed\n config.port || (config.port = types_1.DEFAULT_PORT);\n config.timeout = config.timeout && config.timeout > 0 ? config.timeout : types_1.DEFAULT_TIMEOUT;\n config.clientid || (config.clientid = 'SQLiteCloud');\n config.verbose = parseBoolean(config.verbose);\n config.noblob = parseBoolean(config.noblob);\n config.compression = config.compression != undefined && config.compression != null ? parseBoolean(config.compression) : true; // default: true\n config.create = parseBoolean(config.create);\n config.non_linearizable = parseBoolean(config.non_linearizable);\n config.insecure = parseBoolean(config.insecure);\n const hasCredentials = (config.username && config.password) || config.apikey;\n if (!config.host || !hasCredentials) {\n console.error('SQLiteCloudConnection.validateConfiguration - missing arguments', config);\n throw new types_1.SQLiteCloudError('The user, password and host arguments or the ?apikey= must be specified.', { errorCode: 'ERR_MISSING_ARGS' });\n }\n if (!config.connectionstring) {\n // build connection string from configuration, values are already validated\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n if (config.apikey) {\n config.connectionstring = `sqlitecloud://${config.host}:${config.port}/${config.database || ''}?apikey=${config.apikey}`;\n }\n else {\n config.connectionstring = `sqlitecloud://${encodeURIComponent(config.username || '')}:${encodeURIComponent(config.password || '')}@${config.host}:${config.port}/${config.database}`;\n }\n }\n return config;\n}\nexports.validateConfiguration = validateConfiguration;\n/**\n * Parse connectionstring like sqlitecloud://username:password@host:port/database?option1=xxx&option2=xxx\n * or sqlitecloud://host.sqlite.cloud:8860/chinook.sqlite?apikey=mIiLARzKm9XBVllbAzkB1wqrgijJ3Gx0X5z1Agm3xBo\n * into its basic components.\n */\nfunction parseconnectionstring(connectionstring) {\n try {\n // The URL constructor throws a TypeError if the URL is not valid.\n // in spite of having the same structure as a regular url\n // protocol://username:password@host:port/database?option1=xxx&option2=xxx)\n // the sqlitecloud: protocol is not recognized by the URL constructor in browsers\n // so we need to replace it with https: to make it work\n const knownProtocolUrl = connectionstring.replace('sqlitecloud:', 'https:');\n const url = new whatwg_url_1.URL(knownProtocolUrl);\n // all lowecase options\n const options = {};\n url.searchParams.forEach((value, key) => {\n options[key.toLowerCase().replaceAll('-', '_')] = value;\n });\n const config = Object.assign({ username: decodeURIComponent(url.username), password: decodeURIComponent(url.password), host: url.hostname, port: url.port ? parseInt(url.port) : undefined }, options);\n // either you use an apikey or username and password\n if (config.apikey) {\n if (config.username || config.password) {\n console.warn('SQLiteCloudConnection.parseconnectionstring - apikey and username/password are both specified, using apikey');\n }\n delete config.username;\n delete config.password;\n }\n const database = url.pathname.replace('/', ''); // pathname is database name, remove the leading slash\n if (database) {\n config.database = database;\n }\n return config;\n }\n catch (error) {\n throw new types_1.SQLiteCloudError(`Invalid connection string: ${connectionstring}`);\n }\n}\nexports.parseconnectionstring = parseconnectionstring;\n/** Returns true if value is 1 or true */\nfunction parseBoolean(value) {\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1';\n }\n return value ? true : false;\n}\nexports.parseBoolean = parseBoolean;\n/** Returns true if value is 1 or true */\nfunction parseBooleanToZeroOne(value) {\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1' ? 1 : 0;\n }\n return value ? 1 : 0;\n}\nexports.parseBooleanToZeroOne = parseBooleanToZeroOne;\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/utilities.js?");
|
|
139
|
+
eval("\n//\n// utilities.ts - utility methods to manipulate SQL statements\n//\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.isNode = exports.isBrowser = void 0;\nexports.anonimizeCommand = anonimizeCommand;\nexports.anonimizeError = anonimizeError;\nexports.getInitializationCommands = getInitializationCommands;\nexports.sanitizeSQLiteIdentifier = sanitizeSQLiteIdentifier;\nexports.getUpdateResults = getUpdateResults;\nexports.popCallback = popCallback;\nexports.validateConfiguration = validateConfiguration;\nexports.parseconnectionstring = parseconnectionstring;\nexports.parseBoolean = parseBoolean;\nexports.parseBooleanToZeroOne = parseBooleanToZeroOne;\nconst types_1 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\nconst types_2 = __webpack_require__(/*! ./types */ \"./lib/drivers/types.js\");\n// explicitly importing these libraries to allow cross-platform support by replacing them\nconst whatwg_url_1 = __webpack_require__(/*! whatwg-url */ \"./node_modules/whatwg-url/index.js\");\n//\n// determining running environment, thanks to browser-or-node\n// https://www.npmjs.com/package/browser-or-node\n//\nexports.isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\nexports.isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n//\n// utility methods\n//\n/** Messages going to the server are sometimes logged when error conditions occour and need to be stripped of user credentials */\nfunction anonimizeCommand(message) {\n // hide password in AUTH command if needed\n message = message.replace(/USER \\S+/, 'USER ******');\n message = message.replace(/PASSWORD \\S+?(?=;)/, 'PASSWORD ******');\n message = message.replace(/HASH \\S+?(?=;)/, 'HASH ******');\n return message;\n}\n/** Strip message code in error of user credentials */\nfunction anonimizeError(error) {\n if (error === null || error === void 0 ? void 0 : error.message) {\n error.message = anonimizeCommand(error.message);\n }\n return error;\n}\n/** Initialization commands sent to database when connection is established */\nfunction getInitializationCommands(config) {\n // we check the credentials using non linearizable so we're quicker\n // then we bring back linearizability unless specified otherwise\n let commands = 'SET CLIENT KEY NONLINEARIZABLE TO 1; ';\n // first user authentication, then all other commands\n if (config.apikey) {\n commands += `AUTH APIKEY ${config.apikey}; `;\n }\n else {\n commands += `AUTH USER ${config.username || ''} ${config.password_hashed ? 'HASH' : 'PASSWORD'} ${config.password || ''}; `;\n }\n if (config.compression) {\n commands += 'SET CLIENT KEY COMPRESSION TO 1; ';\n }\n if (config.zerotext) {\n commands += 'SET CLIENT KEY ZEROTEXT TO 1; ';\n }\n if (config.noblob) {\n commands += 'SET CLIENT KEY NOBLOB TO 1; ';\n }\n if (config.maxdata) {\n commands += `SET CLIENT KEY MAXDATA TO ${config.maxdata}; `;\n }\n if (config.maxrows) {\n commands += `SET CLIENT KEY MAXROWS TO ${config.maxrows}; `;\n }\n if (config.maxrowset) {\n commands += `SET CLIENT KEY MAXROWSET TO ${config.maxrowset}; `;\n }\n // we ALWAYS set non linearizable to 1 when we start so we can be quicker on login\n // but then we need to put it back to its default value if \"linearizable\" unless set\n if (!config.non_linearizable) {\n commands += 'SET CLIENT KEY NONLINEARIZABLE TO 0; ';\n }\n if (config.database) {\n if (config.create && !config.memory) {\n commands += `CREATE DATABASE ${config.database} IF NOT EXISTS; `;\n }\n commands += `USE DATABASE ${config.database}; `;\n }\n return commands;\n}\n/** Sanitizes an SQLite identifier (e.g., table name, column name). */\nfunction sanitizeSQLiteIdentifier(identifier) {\n const trimmed = identifier.trim();\n // it's not empty\n if (trimmed.length === 0) {\n throw new Error('Identifier cannot be empty.');\n }\n // escape double quotes\n const escaped = trimmed.replace(/\"/g, '\"\"');\n // Wrap in double quotes for safety\n return `\"${escaped}\"`;\n}\n/** Converts results of an update or insert call into a more meaning full result set */\nfunction getUpdateResults(results) {\n if (results) {\n if (Array.isArray(results) && results.length > 0) {\n switch (results[0]) {\n case types_2.SQLiteCloudArrayType.ARRAY_TYPE_SQLITE_EXEC:\n return {\n type: results[0],\n index: results[1],\n lastID: results[2], // ROWID (sqlite3_last_insert_rowid)\n changes: results[3], // CHANGES(sqlite3_changes)\n totalChanges: results[4], // TOTAL_CHANGES (sqlite3_total_changes)\n finalized: results[5], // FINALIZED\n //\n rowId: results[2] // same as lastId\n };\n }\n }\n }\n return undefined;\n}\n/**\n * Many of the methods in our API may contain a callback as their last argument.\n * This method will take the arguments array passed to the method and return an object\n * containing the arguments array with the callbacks removed (if any), and the callback itself.\n * If there are multiple callbacks, the first one is returned as 'callback' and the last one\n * as 'completeCallback'.\n */\nfunction popCallback(args) {\n const remaining = args;\n // at least 1 callback?\n if (args && args.length > 0 && typeof args[args.length - 1] === 'function') {\n // at least 2 callbacks?\n if (args.length > 1 && typeof args[args.length - 2] === 'function') {\n return { args: remaining.slice(0, -2), callback: args[args.length - 2], complete: args[args.length - 1] };\n }\n return { args: remaining.slice(0, -1), callback: args[args.length - 1] };\n }\n return { args: remaining };\n}\n//\n// configuration validation\n//\n/** Validate configuration, apply defaults, throw if something is missing or misconfigured */\nfunction validateConfiguration(config) {\n console.assert(config, 'SQLiteCloudConnection.validateConfiguration - missing config');\n if (config.connectionstring) {\n config = Object.assign(Object.assign(Object.assign({}, config), parseconnectionstring(config.connectionstring)), { connectionstring: config.connectionstring // keep original connection string\n });\n }\n // apply defaults where needed\n config.port || (config.port = types_1.DEFAULT_PORT);\n config.timeout = config.timeout && config.timeout > 0 ? config.timeout : types_1.DEFAULT_TIMEOUT;\n config.clientid || (config.clientid = 'SQLiteCloud');\n config.verbose = parseBoolean(config.verbose);\n config.noblob = parseBoolean(config.noblob);\n config.compression = config.compression != undefined && config.compression != null ? parseBoolean(config.compression) : true; // default: true\n config.create = parseBoolean(config.create);\n config.non_linearizable = parseBoolean(config.non_linearizable);\n config.insecure = parseBoolean(config.insecure);\n const hasCredentials = (config.username && config.password) || config.apikey;\n if (!config.host || !hasCredentials) {\n console.error('SQLiteCloudConnection.validateConfiguration - missing arguments', config);\n throw new types_1.SQLiteCloudError('The user, password and host arguments or the ?apikey= must be specified.', { errorCode: 'ERR_MISSING_ARGS' });\n }\n if (!config.connectionstring) {\n // build connection string from configuration, values are already validated\n if (config.apikey) {\n config.connectionstring = `sqlitecloud://${config.host}:${config.port}/${config.database || ''}?apikey=${config.apikey}`;\n }\n else {\n config.connectionstring = `sqlitecloud://${encodeURIComponent(config.username || '')}:${encodeURIComponent(config.password || '')}@${config.host}:${config.port}/${config.database}`;\n }\n }\n return config;\n}\n/**\n * Parse connectionstring like sqlitecloud://username:password@host:port/database?option1=xxx&option2=xxx\n * or sqlitecloud://host.sqlite.cloud:8860/chinook.sqlite?apikey=mIiLARzKm9XBVllbAzkB1wqrgijJ3Gx0X5z1Agm3xBo\n * into its basic components.\n */\nfunction parseconnectionstring(connectionstring) {\n try {\n // The URL constructor throws a TypeError if the URL is not valid.\n // in spite of having the same structure as a regular url\n // protocol://username:password@host:port/database?option1=xxx&option2=xxx)\n // the sqlitecloud: protocol is not recognized by the URL constructor in browsers\n // so we need to replace it with https: to make it work\n const knownProtocolUrl = connectionstring.replace('sqlitecloud:', 'https:');\n const url = new whatwg_url_1.URL(knownProtocolUrl);\n // all lowecase options\n const options = {};\n url.searchParams.forEach((value, key) => {\n options[key.toLowerCase().replace(/-/g, '_')] = value;\n });\n const config = Object.assign({ username: decodeURIComponent(url.username), password: decodeURIComponent(url.password), host: url.hostname, port: url.port ? parseInt(url.port) : undefined }, options);\n // either you use an apikey or username and password\n if (config.apikey) {\n if (config.username || config.password) {\n console.warn('SQLiteCloudConnection.parseconnectionstring - apikey and username/password are both specified, using apikey');\n }\n delete config.username;\n delete config.password;\n }\n const database = url.pathname.replace('/', ''); // pathname is database name, remove the leading slash\n if (database) {\n config.database = database;\n }\n return config;\n }\n catch (error) {\n throw new types_1.SQLiteCloudError(`Invalid connection string: ${connectionstring}`);\n }\n}\n/** Returns true if value is 1 or true */\nfunction parseBoolean(value) {\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1';\n }\n return value ? true : false;\n}\n/** Returns true if value is 1 or true */\nfunction parseBooleanToZeroOne(value) {\n if (typeof value === 'string') {\n return value.toLowerCase() === 'true' || value === '1' ? 1 : 0;\n }\n return value ? 1 : 0;\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/drivers/utilities.js?");
|
|
140
140
|
|
|
141
141
|
/***/ }),
|
|
142
142
|
|
|
@@ -147,7 +147,7 @@ eval("\n//\n// utilities.ts - utility methods to manipulate SQL statements\n//\n
|
|
|
147
147
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
148
148
|
|
|
149
149
|
"use strict";
|
|
150
|
-
eval("\n//\n// index.ts - export drivers classes, utilities, types\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 = { 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 (
|
|
150
|
+
eval("\n//\n// index.ts - export drivers classes, utilities, types\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 = { 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 () {\n var ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n };\n return function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n };\n})();\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.protocol = exports.sanitizeSQLiteIdentifier = exports.getInitializationCommands = exports.validateConfiguration = exports.parseconnectionstring = exports.SQLiteCloudRow = exports.SQLiteCloudRowset = exports.SQLiteCloudError = exports.SQLiteCloudConnection = exports.Database = void 0;\n// include ONLY packages used by drivers\n// do NOT include anything related to gateway or bun or express\n// connection-tls does not want/need to load on browser and is loaded dynamically by Database\n// connection-ws does not want/need to load on node and is loaded dynamically by Database\nvar database_1 = __webpack_require__(/*! ./drivers/database */ \"./lib/drivers/database.js\");\nObject.defineProperty(exports, \"Database\", ({ enumerable: true, get: function () { return database_1.Database; } }));\nvar connection_1 = __webpack_require__(/*! ./drivers/connection */ \"./lib/drivers/connection.js\");\nObject.defineProperty(exports, \"SQLiteCloudConnection\", ({ enumerable: true, get: function () { return connection_1.SQLiteCloudConnection; } }));\nvar types_1 = __webpack_require__(/*! ./drivers/types */ \"./lib/drivers/types.js\");\nObject.defineProperty(exports, \"SQLiteCloudError\", ({ enumerable: true, get: function () { return types_1.SQLiteCloudError; } }));\nvar rowset_1 = __webpack_require__(/*! ./drivers/rowset */ \"./lib/drivers/rowset.js\");\nObject.defineProperty(exports, \"SQLiteCloudRowset\", ({ enumerable: true, get: function () { return rowset_1.SQLiteCloudRowset; } }));\nObject.defineProperty(exports, \"SQLiteCloudRow\", ({ enumerable: true, get: function () { return rowset_1.SQLiteCloudRow; } }));\nvar utilities_1 = __webpack_require__(/*! ./drivers/utilities */ \"./lib/drivers/utilities.js\");\nObject.defineProperty(exports, \"parseconnectionstring\", ({ enumerable: true, get: function () { return utilities_1.parseconnectionstring; } }));\nObject.defineProperty(exports, \"validateConfiguration\", ({ enumerable: true, get: function () { return utilities_1.validateConfiguration; } }));\nObject.defineProperty(exports, \"getInitializationCommands\", ({ enumerable: true, get: function () { return utilities_1.getInitializationCommands; } }));\nObject.defineProperty(exports, \"sanitizeSQLiteIdentifier\", ({ enumerable: true, get: function () { return utilities_1.sanitizeSQLiteIdentifier; } }));\nexports.protocol = __importStar(__webpack_require__(/*! ./drivers/protocol */ \"./lib/drivers/protocol.js\"));\n\n\n//# sourceURL=webpack://sqlitecloud/./lib/index.js?");
|
|
151
151
|
|
|
152
152
|
/***/ }),
|
|
153
153
|
|
|
@@ -338,7 +338,7 @@ eval("\n\nconst conversions = __webpack_require__(/*! webidl-conversions */ \"./
|
|
|
338
338
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
339
339
|
|
|
340
340
|
"use strict";
|
|
341
|
-
eval("\nconst usm = __webpack_require__(/*! ./url-state-machine */ \"./node_modules/whatwg-url/lib/url-state-machine.js\");\nconst urlencoded = __webpack_require__(/*! ./urlencoded */ \"./node_modules/whatwg-url/lib/urlencoded.js\");\nconst URLSearchParams = __webpack_require__(/*! ./URLSearchParams */ \"./node_modules/whatwg-url/lib/URLSearchParams.js\");\n\nexports.implementation = class URLImpl {\n // Unlike the spec, we duplicate some code between the constructor and canParse, because we want to give useful error\n // messages in the constructor that distinguish between the different causes of failure.\n constructor(globalObject,
|
|
341
|
+
eval("\nconst usm = __webpack_require__(/*! ./url-state-machine */ \"./node_modules/whatwg-url/lib/url-state-machine.js\");\nconst urlencoded = __webpack_require__(/*! ./urlencoded */ \"./node_modules/whatwg-url/lib/urlencoded.js\");\nconst URLSearchParams = __webpack_require__(/*! ./URLSearchParams */ \"./node_modules/whatwg-url/lib/URLSearchParams.js\");\n\nexports.implementation = class URLImpl {\n // Unlike the spec, we duplicate some code between the constructor and canParse, because we want to give useful error\n // messages in the constructor that distinguish between the different causes of failure.\n constructor(globalObject, [url, base]) {\n let parsedBase = null;\n if (base !== undefined) {\n parsedBase = usm.basicURLParse(base);\n if (parsedBase === null) {\n throw new TypeError(`Invalid base URL: ${base}`);\n }\n }\n\n const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });\n if (parsedURL === null) {\n throw new TypeError(`Invalid URL: ${url}`);\n }\n\n const query = parsedURL.query !== null ? parsedURL.query : \"\";\n\n this._url = parsedURL;\n\n // We cannot invoke the \"new URLSearchParams object\" algorithm without going through the constructor, which strips\n // question mark by default. Therefore the doNotStripQMark hack is used.\n this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });\n this._query._url = this;\n }\n\n static parse(globalObject, input, base) {\n try {\n return new URLImpl(globalObject, [input, base]);\n } catch {\n return null;\n }\n }\n\n static canParse(url, base) {\n let parsedBase = null;\n if (base !== undefined) {\n parsedBase = usm.basicURLParse(base);\n if (parsedBase === null) {\n return false;\n }\n }\n\n const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });\n if (parsedURL === null) {\n return false;\n }\n\n return true;\n }\n\n get href() {\n return usm.serializeURL(this._url);\n }\n\n set href(v) {\n const parsedURL = usm.basicURLParse(v);\n if (parsedURL === null) {\n throw new TypeError(`Invalid URL: ${v}`);\n }\n\n this._url = parsedURL;\n\n this._query._list.splice(0);\n const { query } = parsedURL;\n if (query !== null) {\n this._query._list = urlencoded.parseUrlencodedString(query);\n }\n }\n\n get origin() {\n return usm.serializeURLOrigin(this._url);\n }\n\n get protocol() {\n return `${this._url.scheme}:`;\n }\n\n set protocol(v) {\n usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: \"scheme start\" });\n }\n\n get username() {\n return this._url.username;\n }\n\n set username(v) {\n if (usm.cannotHaveAUsernamePasswordPort(this._url)) {\n return;\n }\n\n usm.setTheUsername(this._url, v);\n }\n\n get password() {\n return this._url.password;\n }\n\n set password(v) {\n if (usm.cannotHaveAUsernamePasswordPort(this._url)) {\n return;\n }\n\n usm.setThePassword(this._url, v);\n }\n\n get host() {\n const url = this._url;\n\n if (url.host === null) {\n return \"\";\n }\n\n if (url.port === null) {\n return usm.serializeHost(url.host);\n }\n\n return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;\n }\n\n set host(v) {\n if (usm.hasAnOpaquePath(this._url)) {\n return;\n }\n\n usm.basicURLParse(v, { url: this._url, stateOverride: \"host\" });\n }\n\n get hostname() {\n if (this._url.host === null) {\n return \"\";\n }\n\n return usm.serializeHost(this._url.host);\n }\n\n set hostname(v) {\n if (usm.hasAnOpaquePath(this._url)) {\n return;\n }\n\n usm.basicURLParse(v, { url: this._url, stateOverride: \"hostname\" });\n }\n\n get port() {\n if (this._url.port === null) {\n return \"\";\n }\n\n return usm.serializeInteger(this._url.port);\n }\n\n set port(v) {\n if (usm.cannotHaveAUsernamePasswordPort(this._url)) {\n return;\n }\n\n if (v === \"\") {\n this._url.port = null;\n } else {\n usm.basicURLParse(v, { url: this._url, stateOverride: \"port\" });\n }\n }\n\n get pathname() {\n return usm.serializePath(this._url);\n }\n\n set pathname(v) {\n if (usm.hasAnOpaquePath(this._url)) {\n return;\n }\n\n this._url.path = [];\n usm.basicURLParse(v, { url: this._url, stateOverride: \"path start\" });\n }\n\n get search() {\n if (this._url.query === null || this._url.query === \"\") {\n return \"\";\n }\n\n return `?${this._url.query}`;\n }\n\n set search(v) {\n const url = this._url;\n\n if (v === \"\") {\n url.query = null;\n this._query._list = [];\n this._potentiallyStripTrailingSpacesFromAnOpaquePath();\n return;\n }\n\n const input = v[0] === \"?\" ? v.substring(1) : v;\n url.query = \"\";\n usm.basicURLParse(input, { url, stateOverride: \"query\" });\n this._query._list = urlencoded.parseUrlencodedString(input);\n }\n\n get searchParams() {\n return this._query;\n }\n\n get hash() {\n if (this._url.fragment === null || this._url.fragment === \"\") {\n return \"\";\n }\n\n return `#${this._url.fragment}`;\n }\n\n set hash(v) {\n if (v === \"\") {\n this._url.fragment = null;\n this._potentiallyStripTrailingSpacesFromAnOpaquePath();\n return;\n }\n\n const input = v[0] === \"#\" ? v.substring(1) : v;\n this._url.fragment = \"\";\n usm.basicURLParse(input, { url: this._url, stateOverride: \"fragment\" });\n }\n\n toJSON() {\n return this.href;\n }\n\n _potentiallyStripTrailingSpacesFromAnOpaquePath() {\n if (!usm.hasAnOpaquePath(this._url)) {\n return;\n }\n\n if (this._url.fragment !== null) {\n return;\n }\n\n if (this._url.query !== null) {\n return;\n }\n\n this._url.path = this._url.path.replace(/\\u0020+$/u, \"\");\n }\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/whatwg-url/lib/URL-impl.js?");
|
|
342
342
|
|
|
343
343
|
/***/ }),
|
|
344
344
|
|
|
@@ -349,7 +349,7 @@ eval("\nconst usm = __webpack_require__(/*! ./url-state-machine */ \"./node_modu
|
|
|
349
349
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
350
350
|
|
|
351
351
|
"use strict";
|
|
352
|
-
eval("\n\nconst conversions = __webpack_require__(/*! webidl-conversions */ \"./node_modules/webidl-conversions/lib/index.js\");\nconst utils = __webpack_require__(/*! ./utils.js */ \"./node_modules/whatwg-url/lib/utils.js\");\n\nconst implSymbol = utils.implSymbol;\nconst ctorRegistrySymbol = utils.ctorRegistrySymbol;\n\nconst interfaceName = \"URL\";\n\nexports.is = value => {\n return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;\n};\nexports.isImpl = value => {\n return utils.isObject(value) && value instanceof Impl.implementation;\n};\nexports.convert = (globalObject, value, { context = \"The provided value\" } = {}) => {\n if (exports.is(value)) {\n return utils.implForWrapper(value);\n }\n throw new globalObject.TypeError(`${context} is not of type 'URL'.`);\n};\n\nfunction makeWrapper(globalObject, newTarget) {\n let proto;\n if (newTarget !== undefined) {\n proto = newTarget.prototype;\n }\n\n if (!utils.isObject(proto)) {\n proto = globalObject[ctorRegistrySymbol][\"URL\"].prototype;\n }\n\n return Object.create(proto);\n}\n\nexports.create = (globalObject, constructorArgs, privateData) => {\n const wrapper = makeWrapper(globalObject);\n return exports.setup(wrapper, globalObject, constructorArgs, privateData);\n};\n\nexports.createImpl = (globalObject, constructorArgs, privateData) => {\n const wrapper = exports.create(globalObject, constructorArgs, privateData);\n return utils.implForWrapper(wrapper);\n};\n\nexports._internalSetup = (wrapper, globalObject) => {};\n\nexports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {\n privateData.wrapper = wrapper;\n\n exports._internalSetup(wrapper, globalObject);\n Object.defineProperty(wrapper, implSymbol, {\n value: new Impl.implementation(globalObject, constructorArgs, privateData),\n configurable: true\n });\n\n wrapper[implSymbol][utils.wrapperSymbol] = wrapper;\n if (Impl.init) {\n Impl.init(wrapper[implSymbol]);\n }\n return wrapper;\n};\n\nexports[\"new\"] = (globalObject, newTarget) => {\n const wrapper = makeWrapper(globalObject, newTarget);\n\n exports._internalSetup(wrapper, globalObject);\n Object.defineProperty(wrapper, implSymbol, {\n value: Object.create(Impl.implementation.prototype),\n configurable: true\n });\n\n wrapper[implSymbol][utils.wrapperSymbol] = wrapper;\n if (Impl.init) {\n Impl.init(wrapper[implSymbol]);\n }\n return wrapper[implSymbol];\n};\n\nconst exposed = new Set([\"Window\", \"Worker\"]);\n\nexports.install = (globalObject, globalNames) => {\n if (!globalNames.some(globalName => exposed.has(globalName))) {\n return;\n }\n\n const ctorRegistry = utils.initCtorRegistry(globalObject);\n class URL {\n constructor(url) {\n if (arguments.length < 1) {\n throw new globalObject.TypeError(\n `Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`\n );\n }\n const args = [];\n {\n let curArg = arguments[0];\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to construct 'URL': parameter 1\",\n globals: globalObject\n });\n args.push(curArg);\n }\n {\n let curArg = arguments[1];\n if (curArg !== undefined) {\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to construct 'URL': parameter 2\",\n globals: globalObject\n });\n }\n args.push(curArg);\n }\n return exports.setup(Object.create(new.target.prototype), globalObject, args);\n }\n\n toJSON() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'toJSON' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol].toJSON();\n }\n\n get href() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get href' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"href\"];\n }\n\n set href(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set href' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'href' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"href\"] = V;\n }\n\n toString() {\n const esValue = this;\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'toString' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"href\"];\n }\n\n get origin() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get origin' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"origin\"];\n }\n\n get protocol() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get protocol' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"protocol\"];\n }\n\n set protocol(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set protocol' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'protocol' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"protocol\"] = V;\n }\n\n get username() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get username' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"username\"];\n }\n\n set username(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set username' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'username' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"username\"] = V;\n }\n\n get password() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get password' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"password\"];\n }\n\n set password(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set password' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'password' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"password\"] = V;\n }\n\n get host() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get host' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"host\"];\n }\n\n set host(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set host' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'host' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"host\"] = V;\n }\n\n get hostname() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get hostname' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"hostname\"];\n }\n\n set hostname(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set hostname' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'hostname' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"hostname\"] = V;\n }\n\n get port() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get port' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"port\"];\n }\n\n set port(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set port' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'port' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"port\"] = V;\n }\n\n get pathname() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get pathname' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"pathname\"];\n }\n\n set pathname(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set pathname' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'pathname' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"pathname\"] = V;\n }\n\n get search() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get search' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"search\"];\n }\n\n set search(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set search' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'search' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"search\"] = V;\n }\n\n get searchParams() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get searchParams' called on an object that is not a valid instance of URL.\");\n }\n\n return utils.getSameObject(this, \"searchParams\", () => {\n return utils.tryWrapperForImpl(esValue[implSymbol][\"searchParams\"]);\n });\n }\n\n get hash() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get hash' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"hash\"];\n }\n\n set hash(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set hash' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'hash' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"hash\"] = V;\n }\n\n static canParse(url) {\n if (arguments.length < 1) {\n throw new globalObject.TypeError(\n `Failed to execute 'canParse' on 'URL': 1 argument required, but only ${arguments.length} present.`\n );\n }\n const args = [];\n {\n let curArg = arguments[0];\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'canParse' on 'URL': parameter 1\",\n globals: globalObject\n });\n args.push(curArg);\n }\n {\n let curArg = arguments[1];\n if (curArg !== undefined) {\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'canParse' on 'URL': parameter 2\",\n globals: globalObject\n });\n }\n args.push(curArg);\n }\n return Impl.implementation.canParse(...args);\n }\n }\n Object.defineProperties(URL.prototype, {\n toJSON: { enumerable: true },\n href: { enumerable: true },\n toString: { enumerable: true },\n origin: { enumerable: true },\n protocol: { enumerable: true },\n username: { enumerable: true },\n password: { enumerable: true },\n host: { enumerable: true },\n hostname: { enumerable: true },\n port: { enumerable: true },\n pathname: { enumerable: true },\n search: { enumerable: true },\n searchParams: { enumerable: true },\n hash: { enumerable: true },\n [Symbol.toStringTag]: { value: \"URL\", configurable: true }\n });\n Object.defineProperties(URL, { canParse: { enumerable: true } });\n ctorRegistry[interfaceName] = URL;\n\n Object.defineProperty(globalObject, interfaceName, {\n configurable: true,\n writable: true,\n value: URL\n });\n\n if (globalNames.includes(\"Window\")) {\n Object.defineProperty(globalObject, \"webkitURL\", {\n configurable: true,\n writable: true,\n value: URL\n });\n }\n};\n\nconst Impl = __webpack_require__(/*! ./URL-impl.js */ \"./node_modules/whatwg-url/lib/URL-impl.js\");\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/whatwg-url/lib/URL.js?");
|
|
352
|
+
eval("\n\nconst conversions = __webpack_require__(/*! webidl-conversions */ \"./node_modules/webidl-conversions/lib/index.js\");\nconst utils = __webpack_require__(/*! ./utils.js */ \"./node_modules/whatwg-url/lib/utils.js\");\n\nconst implSymbol = utils.implSymbol;\nconst ctorRegistrySymbol = utils.ctorRegistrySymbol;\n\nconst interfaceName = \"URL\";\n\nexports.is = value => {\n return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;\n};\nexports.isImpl = value => {\n return utils.isObject(value) && value instanceof Impl.implementation;\n};\nexports.convert = (globalObject, value, { context = \"The provided value\" } = {}) => {\n if (exports.is(value)) {\n return utils.implForWrapper(value);\n }\n throw new globalObject.TypeError(`${context} is not of type 'URL'.`);\n};\n\nfunction makeWrapper(globalObject, newTarget) {\n let proto;\n if (newTarget !== undefined) {\n proto = newTarget.prototype;\n }\n\n if (!utils.isObject(proto)) {\n proto = globalObject[ctorRegistrySymbol][\"URL\"].prototype;\n }\n\n return Object.create(proto);\n}\n\nexports.create = (globalObject, constructorArgs, privateData) => {\n const wrapper = makeWrapper(globalObject);\n return exports.setup(wrapper, globalObject, constructorArgs, privateData);\n};\n\nexports.createImpl = (globalObject, constructorArgs, privateData) => {\n const wrapper = exports.create(globalObject, constructorArgs, privateData);\n return utils.implForWrapper(wrapper);\n};\n\nexports._internalSetup = (wrapper, globalObject) => {};\n\nexports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {\n privateData.wrapper = wrapper;\n\n exports._internalSetup(wrapper, globalObject);\n Object.defineProperty(wrapper, implSymbol, {\n value: new Impl.implementation(globalObject, constructorArgs, privateData),\n configurable: true\n });\n\n wrapper[implSymbol][utils.wrapperSymbol] = wrapper;\n if (Impl.init) {\n Impl.init(wrapper[implSymbol]);\n }\n return wrapper;\n};\n\nexports[\"new\"] = (globalObject, newTarget) => {\n const wrapper = makeWrapper(globalObject, newTarget);\n\n exports._internalSetup(wrapper, globalObject);\n Object.defineProperty(wrapper, implSymbol, {\n value: Object.create(Impl.implementation.prototype),\n configurable: true\n });\n\n wrapper[implSymbol][utils.wrapperSymbol] = wrapper;\n if (Impl.init) {\n Impl.init(wrapper[implSymbol]);\n }\n return wrapper[implSymbol];\n};\n\nconst exposed = new Set([\"Window\", \"Worker\"]);\n\nexports.install = (globalObject, globalNames) => {\n if (!globalNames.some(globalName => exposed.has(globalName))) {\n return;\n }\n\n const ctorRegistry = utils.initCtorRegistry(globalObject);\n class URL {\n constructor(url) {\n if (arguments.length < 1) {\n throw new globalObject.TypeError(\n `Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`\n );\n }\n const args = [];\n {\n let curArg = arguments[0];\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to construct 'URL': parameter 1\",\n globals: globalObject\n });\n args.push(curArg);\n }\n {\n let curArg = arguments[1];\n if (curArg !== undefined) {\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to construct 'URL': parameter 2\",\n globals: globalObject\n });\n }\n args.push(curArg);\n }\n return exports.setup(Object.create(new.target.prototype), globalObject, args);\n }\n\n toJSON() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'toJSON' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol].toJSON();\n }\n\n get href() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get href' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"href\"];\n }\n\n set href(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set href' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'href' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"href\"] = V;\n }\n\n toString() {\n const esValue = this;\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'toString' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"href\"];\n }\n\n get origin() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get origin' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"origin\"];\n }\n\n get protocol() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get protocol' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"protocol\"];\n }\n\n set protocol(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set protocol' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'protocol' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"protocol\"] = V;\n }\n\n get username() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get username' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"username\"];\n }\n\n set username(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set username' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'username' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"username\"] = V;\n }\n\n get password() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get password' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"password\"];\n }\n\n set password(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set password' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'password' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"password\"] = V;\n }\n\n get host() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get host' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"host\"];\n }\n\n set host(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set host' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'host' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"host\"] = V;\n }\n\n get hostname() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get hostname' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"hostname\"];\n }\n\n set hostname(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set hostname' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'hostname' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"hostname\"] = V;\n }\n\n get port() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get port' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"port\"];\n }\n\n set port(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set port' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'port' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"port\"] = V;\n }\n\n get pathname() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get pathname' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"pathname\"];\n }\n\n set pathname(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set pathname' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'pathname' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"pathname\"] = V;\n }\n\n get search() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get search' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"search\"];\n }\n\n set search(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set search' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'search' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"search\"] = V;\n }\n\n get searchParams() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get searchParams' called on an object that is not a valid instance of URL.\");\n }\n\n return utils.getSameObject(this, \"searchParams\", () => {\n return utils.tryWrapperForImpl(esValue[implSymbol][\"searchParams\"]);\n });\n }\n\n get hash() {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'get hash' called on an object that is not a valid instance of URL.\");\n }\n\n return esValue[implSymbol][\"hash\"];\n }\n\n set hash(V) {\n const esValue = this !== null && this !== undefined ? this : globalObject;\n\n if (!exports.is(esValue)) {\n throw new globalObject.TypeError(\"'set hash' called on an object that is not a valid instance of URL.\");\n }\n\n V = conversions[\"USVString\"](V, {\n context: \"Failed to set the 'hash' property on 'URL': The provided value\",\n globals: globalObject\n });\n\n esValue[implSymbol][\"hash\"] = V;\n }\n\n static parse(url) {\n if (arguments.length < 1) {\n throw new globalObject.TypeError(\n `Failed to execute 'parse' on 'URL': 1 argument required, but only ${arguments.length} present.`\n );\n }\n const args = [];\n {\n let curArg = arguments[0];\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'parse' on 'URL': parameter 1\",\n globals: globalObject\n });\n args.push(curArg);\n }\n {\n let curArg = arguments[1];\n if (curArg !== undefined) {\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'parse' on 'URL': parameter 2\",\n globals: globalObject\n });\n }\n args.push(curArg);\n }\n return utils.tryWrapperForImpl(Impl.implementation.parse(globalObject, ...args));\n }\n\n static canParse(url) {\n if (arguments.length < 1) {\n throw new globalObject.TypeError(\n `Failed to execute 'canParse' on 'URL': 1 argument required, but only ${arguments.length} present.`\n );\n }\n const args = [];\n {\n let curArg = arguments[0];\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'canParse' on 'URL': parameter 1\",\n globals: globalObject\n });\n args.push(curArg);\n }\n {\n let curArg = arguments[1];\n if (curArg !== undefined) {\n curArg = conversions[\"USVString\"](curArg, {\n context: \"Failed to execute 'canParse' on 'URL': parameter 2\",\n globals: globalObject\n });\n }\n args.push(curArg);\n }\n return Impl.implementation.canParse(...args);\n }\n }\n Object.defineProperties(URL.prototype, {\n toJSON: { enumerable: true },\n href: { enumerable: true },\n toString: { enumerable: true },\n origin: { enumerable: true },\n protocol: { enumerable: true },\n username: { enumerable: true },\n password: { enumerable: true },\n host: { enumerable: true },\n hostname: { enumerable: true },\n port: { enumerable: true },\n pathname: { enumerable: true },\n search: { enumerable: true },\n searchParams: { enumerable: true },\n hash: { enumerable: true },\n [Symbol.toStringTag]: { value: \"URL\", configurable: true }\n });\n Object.defineProperties(URL, { parse: { enumerable: true }, canParse: { enumerable: true } });\n ctorRegistry[interfaceName] = URL;\n\n Object.defineProperty(globalObject, interfaceName, {\n configurable: true,\n writable: true,\n value: URL\n });\n\n if (globalNames.includes(\"Window\")) {\n Object.defineProperty(globalObject, \"webkitURL\", {\n configurable: true,\n writable: true,\n value: URL\n });\n }\n};\n\nconst Impl = __webpack_require__(/*! ./URL-impl.js */ \"./node_modules/whatwg-url/lib/URL-impl.js\");\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/whatwg-url/lib/URL.js?");
|
|
353
353
|
|
|
354
354
|
/***/ }),
|
|
355
355
|
|
|
@@ -415,7 +415,7 @@ eval("\nconst { isASCIIHex } = __webpack_require__(/*! ./infra */ \"./node_modul
|
|
|
415
415
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
416
416
|
|
|
417
417
|
"use strict";
|
|
418
|
-
eval("\nconst tr46 = __webpack_require__(/*! tr46 */ \"./node_modules/tr46/index.js\");\n\nconst infra = __webpack_require__(/*! ./infra */ \"./node_modules/whatwg-url/lib/infra.js\");\nconst { utf8DecodeWithoutBOM } = __webpack_require__(/*! ./encoding */ \"./node_modules/whatwg-url/lib/encoding.js\");\nconst { percentDecodeString, utf8PercentEncodeCodePoint, utf8PercentEncodeString, isC0ControlPercentEncode,\n isFragmentPercentEncode, isQueryPercentEncode, isSpecialQueryPercentEncode, isPathPercentEncode,\n isUserinfoPercentEncode } = __webpack_require__(/*! ./percent-encoding */ \"./node_modules/whatwg-url/lib/percent-encoding.js\");\n\nfunction p(char) {\n return char.codePointAt(0);\n}\n\nconst specialSchemes = {\n ftp: 21,\n file: null,\n http: 80,\n https: 443,\n ws: 80,\n wss: 443\n};\n\nconst failure = Symbol(\"failure\");\n\nfunction countSymbols(str) {\n return [...str].length;\n}\n\nfunction at(input, idx) {\n const c = input[idx];\n return isNaN(c) ? undefined : String.fromCodePoint(c);\n}\n\nfunction isSingleDot(buffer) {\n return buffer === \".\" || buffer.toLowerCase() === \"%2e\";\n}\n\nfunction isDoubleDot(buffer) {\n buffer = buffer.toLowerCase();\n return buffer === \"..\" || buffer === \"%2e.\" || buffer === \".%2e\" || buffer === \"%2e%2e\";\n}\n\nfunction isWindowsDriveLetterCodePoints(cp1, cp2) {\n return infra.isASCIIAlpha(cp1) && (cp2 === p(\":\") || cp2 === p(\"|\"));\n}\n\nfunction isWindowsDriveLetterString(string) {\n return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && (string[1] === \":\" || string[1] === \"|\");\n}\n\nfunction isNormalizedWindowsDriveLetterString(string) {\n return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && string[1] === \":\";\n}\n\nfunction containsForbiddenHostCodePoint(string) {\n return string.search(/\\u0000|\\u0009|\\u000A|\\u000D|\\u0020|#|\\/|:|<|>|\\?|@|\\[|\\\\|\\]|\\^|\\|/u) !== -1;\n}\n\nfunction containsForbiddenDomainCodePoint(string) {\n return containsForbiddenHostCodePoint(string) || string.search(/[\\u0000-\\u001F]|%|\\u007F/u) !== -1;\n}\n\nfunction isSpecialScheme(scheme) {\n return specialSchemes[scheme] !== undefined;\n}\n\nfunction isSpecial(url) {\n return isSpecialScheme(url.scheme);\n}\n\nfunction isNotSpecial(url) {\n return !isSpecialScheme(url.scheme);\n}\n\nfunction defaultPort(scheme) {\n return specialSchemes[scheme];\n}\n\nfunction parseIPv4Number(input) {\n if (input === \"\") {\n return failure;\n }\n\n let R = 10;\n\n if (input.length >= 2 && input.charAt(0) === \"0\" && input.charAt(1).toLowerCase() === \"x\") {\n input = input.substring(2);\n R = 16;\n } else if (input.length >= 2 && input.charAt(0) === \"0\") {\n input = input.substring(1);\n R = 8;\n }\n\n if (input === \"\") {\n return 0;\n }\n\n let regex = /[^0-7]/u;\n if (R === 10) {\n regex = /[^0-9]/u;\n }\n if (R === 16) {\n regex = /[^0-9A-Fa-f]/u;\n }\n\n if (regex.test(input)) {\n return failure;\n }\n\n return parseInt(input, R);\n}\n\nfunction parseIPv4(input) {\n const parts = input.split(\".\");\n if (parts[parts.length - 1] === \"\") {\n if (parts.length > 1) {\n parts.pop();\n }\n }\n\n if (parts.length > 4) {\n return failure;\n }\n\n const numbers = [];\n for (const part of parts) {\n const n = parseIPv4Number(part);\n if (n === failure) {\n return failure;\n }\n\n numbers.push(n);\n }\n\n for (let i = 0; i < numbers.length - 1; ++i) {\n if (numbers[i] > 255) {\n return failure;\n }\n }\n if (numbers[numbers.length - 1] >= 256 ** (5 - numbers.length)) {\n return failure;\n }\n\n let ipv4 = numbers.pop();\n let counter = 0;\n\n for (const n of numbers) {\n ipv4 += n * 256 ** (3 - counter);\n ++counter;\n }\n\n return ipv4;\n}\n\nfunction serializeIPv4(address) {\n let output = \"\";\n let n = address;\n\n for (let i = 1; i <= 4; ++i) {\n output = String(n % 256) + output;\n if (i !== 4) {\n output = `.${output}`;\n }\n n = Math.floor(n / 256);\n }\n\n return output;\n}\n\nfunction parseIPv6(input) {\n const address = [0, 0, 0, 0, 0, 0, 0, 0];\n let pieceIndex = 0;\n let compress = null;\n let pointer = 0;\n\n input = Array.from(input, c => c.codePointAt(0));\n\n if (input[pointer] === p(\":\")) {\n if (input[pointer + 1] !== p(\":\")) {\n return failure;\n }\n\n pointer += 2;\n ++pieceIndex;\n compress = pieceIndex;\n }\n\n while (pointer < input.length) {\n if (pieceIndex === 8) {\n return failure;\n }\n\n if (input[pointer] === p(\":\")) {\n if (compress !== null) {\n return failure;\n }\n ++pointer;\n ++pieceIndex;\n compress = pieceIndex;\n continue;\n }\n\n let value = 0;\n let length = 0;\n\n while (length < 4 && infra.isASCIIHex(input[pointer])) {\n value = value * 0x10 + parseInt(at(input, pointer), 16);\n ++pointer;\n ++length;\n }\n\n if (input[pointer] === p(\".\")) {\n if (length === 0) {\n return failure;\n }\n\n pointer -= length;\n\n if (pieceIndex > 6) {\n return failure;\n }\n\n let numbersSeen = 0;\n\n while (input[pointer] !== undefined) {\n let ipv4Piece = null;\n\n if (numbersSeen > 0) {\n if (input[pointer] === p(\".\") && numbersSeen < 4) {\n ++pointer;\n } else {\n return failure;\n }\n }\n\n if (!infra.isASCIIDigit(input[pointer])) {\n return failure;\n }\n\n while (infra.isASCIIDigit(input[pointer])) {\n const number = parseInt(at(input, pointer));\n if (ipv4Piece === null) {\n ipv4Piece = number;\n } else if (ipv4Piece === 0) {\n return failure;\n } else {\n ipv4Piece = ipv4Piece * 10 + number;\n }\n if (ipv4Piece > 255) {\n return failure;\n }\n ++pointer;\n }\n\n address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece;\n\n ++numbersSeen;\n\n if (numbersSeen === 2 || numbersSeen === 4) {\n ++pieceIndex;\n }\n }\n\n if (numbersSeen !== 4) {\n return failure;\n }\n\n break;\n } else if (input[pointer] === p(\":\")) {\n ++pointer;\n if (input[pointer] === undefined) {\n return failure;\n }\n } else if (input[pointer] !== undefined) {\n return failure;\n }\n\n address[pieceIndex] = value;\n ++pieceIndex;\n }\n\n if (compress !== null) {\n let swaps = pieceIndex - compress;\n pieceIndex = 7;\n while (pieceIndex !== 0 && swaps > 0) {\n const temp = address[compress + swaps - 1];\n address[compress + swaps - 1] = address[pieceIndex];\n address[pieceIndex] = temp;\n --pieceIndex;\n --swaps;\n }\n } else if (compress === null && pieceIndex !== 8) {\n return failure;\n }\n\n return address;\n}\n\nfunction serializeIPv6(address) {\n let output = \"\";\n const compress = findLongestZeroSequence(address);\n let ignore0 = false;\n\n for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {\n if (ignore0 && address[pieceIndex] === 0) {\n continue;\n } else if (ignore0) {\n ignore0 = false;\n }\n\n if (compress === pieceIndex) {\n const separator = pieceIndex === 0 ? \"::\" : \":\";\n output += separator;\n ignore0 = true;\n continue;\n }\n\n output += address[pieceIndex].toString(16);\n\n if (pieceIndex !== 7) {\n output += \":\";\n }\n }\n\n return output;\n}\n\nfunction parseHost(input, isNotSpecialArg = false) {\n if (input[0] === \"[\") {\n if (input[input.length - 1] !== \"]\") {\n return failure;\n }\n\n return parseIPv6(input.substring(1, input.length - 1));\n }\n\n if (isNotSpecialArg) {\n return parseOpaqueHost(input);\n }\n\n const domain = utf8DecodeWithoutBOM(percentDecodeString(input));\n const asciiDomain = domainToASCII(domain);\n if (asciiDomain === failure) {\n return failure;\n }\n\n if (containsForbiddenDomainCodePoint(asciiDomain)) {\n return failure;\n }\n\n if (endsInANumber(asciiDomain)) {\n return parseIPv4(asciiDomain);\n }\n\n return asciiDomain;\n}\n\nfunction endsInANumber(input) {\n const parts = input.split(\".\");\n if (parts[parts.length - 1] === \"\") {\n if (parts.length === 1) {\n return false;\n }\n parts.pop();\n }\n\n const last = parts[parts.length - 1];\n if (parseIPv4Number(last) !== failure) {\n return true;\n }\n\n if (/^[0-9]+$/u.test(last)) {\n return true;\n }\n\n return false;\n}\n\nfunction parseOpaqueHost(input) {\n if (containsForbiddenHostCodePoint(input)) {\n return failure;\n }\n\n return utf8PercentEncodeString(input, isC0ControlPercentEncode);\n}\n\nfunction findLongestZeroSequence(arr) {\n let maxIdx = null;\n let maxLen = 1; // only find elements > 1\n let currStart = null;\n let currLen = 0;\n\n for (let i = 0; i < arr.length; ++i) {\n if (arr[i] !== 0) {\n if (currLen > maxLen) {\n maxIdx = currStart;\n maxLen = currLen;\n }\n\n currStart = null;\n currLen = 0;\n } else {\n if (currStart === null) {\n currStart = i;\n }\n ++currLen;\n }\n }\n\n // if trailing zeros\n if (currLen > maxLen) {\n return currStart;\n }\n\n return maxIdx;\n}\n\nfunction serializeHost(host) {\n if (typeof host === \"number\") {\n return serializeIPv4(host);\n }\n\n // IPv6 serializer\n if (host instanceof Array) {\n return `[${serializeIPv6(host)}]`;\n }\n\n return host;\n}\n\nfunction domainToASCII(domain, beStrict = false) {\n const result = tr46.toASCII(domain, {\n checkBidi: true,\n checkHyphens: false,\n checkJoiners: true,\n useSTD3ASCIIRules: beStrict,\n verifyDNSLength: beStrict\n });\n if (result === null || result === \"\") {\n return failure;\n }\n return result;\n}\n\nfunction trimControlChars(url) {\n return url.replace(/^[\\u0000-\\u001F\\u0020]+|[\\u0000-\\u001F\\u0020]+$/ug, \"\");\n}\n\nfunction trimTabAndNewline(url) {\n return url.replace(/\\u0009|\\u000A|\\u000D/ug, \"\");\n}\n\nfunction shortenPath(url) {\n const { path } = url;\n if (path.length === 0) {\n return;\n }\n if (url.scheme === \"file\" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) {\n return;\n }\n\n path.pop();\n}\n\nfunction includesCredentials(url) {\n return url.username !== \"\" || url.password !== \"\";\n}\n\nfunction cannotHaveAUsernamePasswordPort(url) {\n return url.host === null || url.host === \"\" || url.scheme === \"file\";\n}\n\nfunction hasAnOpaquePath(url) {\n return typeof url.path === \"string\";\n}\n\nfunction isNormalizedWindowsDriveLetter(string) {\n return /^[A-Za-z]:$/u.test(string);\n}\n\nfunction URLStateMachine(input, base, encodingOverride, url, stateOverride) {\n this.pointer = 0;\n this.input = input;\n this.base = base || null;\n this.encodingOverride = encodingOverride || \"utf-8\";\n this.stateOverride = stateOverride;\n this.url = url;\n this.failure = false;\n this.parseError = false;\n\n if (!this.url) {\n this.url = {\n scheme: \"\",\n username: \"\",\n password: \"\",\n host: null,\n port: null,\n path: [],\n query: null,\n fragment: null\n };\n\n const res = trimControlChars(this.input);\n if (res !== this.input) {\n this.parseError = true;\n }\n this.input = res;\n }\n\n const res = trimTabAndNewline(this.input);\n if (res !== this.input) {\n this.parseError = true;\n }\n this.input = res;\n\n this.state = stateOverride || \"scheme start\";\n\n this.buffer = \"\";\n this.atFlag = false;\n this.arrFlag = false;\n this.passwordTokenSeenFlag = false;\n\n this.input = Array.from(this.input, c => c.codePointAt(0));\n\n for (; this.pointer <= this.input.length; ++this.pointer) {\n const c = this.input[this.pointer];\n const cStr = isNaN(c) ? undefined : String.fromCodePoint(c);\n\n // exec state machine\n const ret = this[`parse ${this.state}`](c, cStr);\n if (!ret) {\n break; // terminate algorithm\n } else if (ret === failure) {\n this.failure = true;\n break;\n }\n }\n}\n\nURLStateMachine.prototype[\"parse scheme start\"] = function parseSchemeStart(c, cStr) {\n if (infra.isASCIIAlpha(c)) {\n this.buffer += cStr.toLowerCase();\n this.state = \"scheme\";\n } else if (!this.stateOverride) {\n this.state = \"no scheme\";\n --this.pointer;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse scheme\"] = function parseScheme(c, cStr) {\n if (infra.isASCIIAlphanumeric(c) || c === p(\"+\") || c === p(\"-\") || c === p(\".\")) {\n this.buffer += cStr.toLowerCase();\n } else if (c === p(\":\")) {\n if (this.stateOverride) {\n if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) {\n return false;\n }\n\n if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) {\n return false;\n }\n\n if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === \"file\") {\n return false;\n }\n\n if (this.url.scheme === \"file\" && this.url.host === \"\") {\n return false;\n }\n }\n this.url.scheme = this.buffer;\n if (this.stateOverride) {\n if (this.url.port === defaultPort(this.url.scheme)) {\n this.url.port = null;\n }\n return false;\n }\n this.buffer = \"\";\n if (this.url.scheme === \"file\") {\n if (this.input[this.pointer + 1] !== p(\"/\") || this.input[this.pointer + 2] !== p(\"/\")) {\n this.parseError = true;\n }\n this.state = \"file\";\n } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) {\n this.state = \"special relative or authority\";\n } else if (isSpecial(this.url)) {\n this.state = \"special authority slashes\";\n } else if (this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"path or authority\";\n ++this.pointer;\n } else {\n this.url.path = \"\";\n this.state = \"opaque path\";\n }\n } else if (!this.stateOverride) {\n this.buffer = \"\";\n this.state = \"no scheme\";\n this.pointer = -1;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse no scheme\"] = function parseNoScheme(c) {\n if (this.base === null || (hasAnOpaquePath(this.base) && c !== p(\"#\"))) {\n return failure;\n } else if (hasAnOpaquePath(this.base) && c === p(\"#\")) {\n this.url.scheme = this.base.scheme;\n this.url.path = this.base.path;\n this.url.query = this.base.query;\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (this.base.scheme === \"file\") {\n this.state = \"file\";\n --this.pointer;\n } else {\n this.state = \"relative\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special relative or authority\"] = function parseSpecialRelativeOrAuthority(c) {\n if (c === p(\"/\") && this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"special authority ignore slashes\";\n ++this.pointer;\n } else {\n this.parseError = true;\n this.state = \"relative\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path or authority\"] = function parsePathOrAuthority(c) {\n if (c === p(\"/\")) {\n this.state = \"authority\";\n } else {\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse relative\"] = function parseRelative(c) {\n this.url.scheme = this.base.scheme;\n if (c === p(\"/\")) {\n this.state = \"relative slash\";\n } else if (isSpecial(this.url) && c === p(\"\\\\\")) {\n this.parseError = true;\n this.state = \"relative slash\";\n } else {\n this.url.username = this.base.username;\n this.url.password = this.base.password;\n this.url.host = this.base.host;\n this.url.port = this.base.port;\n this.url.path = this.base.path.slice();\n this.url.query = this.base.query;\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (!isNaN(c)) {\n this.url.query = null;\n this.url.path.pop();\n this.state = \"path\";\n --this.pointer;\n }\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse relative slash\"] = function parseRelativeSlash(c) {\n if (isSpecial(this.url) && (c === p(\"/\") || c === p(\"\\\\\"))) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"special authority ignore slashes\";\n } else if (c === p(\"/\")) {\n this.state = \"authority\";\n } else {\n this.url.username = this.base.username;\n this.url.password = this.base.password;\n this.url.host = this.base.host;\n this.url.port = this.base.port;\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special authority slashes\"] = function parseSpecialAuthoritySlashes(c) {\n if (c === p(\"/\") && this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"special authority ignore slashes\";\n ++this.pointer;\n } else {\n this.parseError = true;\n this.state = \"special authority ignore slashes\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special authority ignore slashes\"] = function parseSpecialAuthorityIgnoreSlashes(c) {\n if (c !== p(\"/\") && c !== p(\"\\\\\")) {\n this.state = \"authority\";\n --this.pointer;\n } else {\n this.parseError = true;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse authority\"] = function parseAuthority(c, cStr) {\n if (c === p(\"@\")) {\n this.parseError = true;\n if (this.atFlag) {\n this.buffer = `%40${this.buffer}`;\n }\n this.atFlag = true;\n\n // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars\n const len = countSymbols(this.buffer);\n for (let pointer = 0; pointer < len; ++pointer) {\n const codePoint = this.buffer.codePointAt(pointer);\n\n if (codePoint === p(\":\") && !this.passwordTokenSeenFlag) {\n this.passwordTokenSeenFlag = true;\n continue;\n }\n const encodedCodePoints = utf8PercentEncodeCodePoint(codePoint, isUserinfoPercentEncode);\n if (this.passwordTokenSeenFlag) {\n this.url.password += encodedCodePoints;\n } else {\n this.url.username += encodedCodePoints;\n }\n }\n this.buffer = \"\";\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\"))) {\n if (this.atFlag && this.buffer === \"\") {\n this.parseError = true;\n return failure;\n }\n this.pointer -= countSymbols(this.buffer) + 1;\n this.buffer = \"\";\n this.state = \"host\";\n } else {\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse hostname\"] =\nURLStateMachine.prototype[\"parse host\"] = function parseHostName(c, cStr) {\n if (this.stateOverride && this.url.scheme === \"file\") {\n --this.pointer;\n this.state = \"file host\";\n } else if (c === p(\":\") && !this.arrFlag) {\n if (this.buffer === \"\") {\n this.parseError = true;\n return failure;\n }\n\n if (this.stateOverride === \"hostname\") {\n return false;\n }\n\n const host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n\n this.url.host = host;\n this.buffer = \"\";\n this.state = \"port\";\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\"))) {\n --this.pointer;\n if (isSpecial(this.url) && this.buffer === \"\") {\n this.parseError = true;\n return failure;\n } else if (this.stateOverride && this.buffer === \"\" &&\n (includesCredentials(this.url) || this.url.port !== null)) {\n this.parseError = true;\n return false;\n }\n\n const host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n\n this.url.host = host;\n this.buffer = \"\";\n this.state = \"path start\";\n if (this.stateOverride) {\n return false;\n }\n } else {\n if (c === p(\"[\")) {\n this.arrFlag = true;\n } else if (c === p(\"]\")) {\n this.arrFlag = false;\n }\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse port\"] = function parsePort(c, cStr) {\n if (infra.isASCIIDigit(c)) {\n this.buffer += cStr;\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\")) ||\n this.stateOverride) {\n if (this.buffer !== \"\") {\n const port = parseInt(this.buffer);\n if (port > 2 ** 16 - 1) {\n this.parseError = true;\n return failure;\n }\n this.url.port = port === defaultPort(this.url.scheme) ? null : port;\n this.buffer = \"\";\n }\n if (this.stateOverride) {\n return false;\n }\n this.state = \"path start\";\n --this.pointer;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nconst fileOtherwiseCodePoints = new Set([p(\"/\"), p(\"\\\\\"), p(\"?\"), p(\"#\")]);\n\nfunction startsWithWindowsDriveLetter(input, pointer) {\n const length = input.length - pointer;\n return length >= 2 &&\n isWindowsDriveLetterCodePoints(input[pointer], input[pointer + 1]) &&\n (length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));\n}\n\nURLStateMachine.prototype[\"parse file\"] = function parseFile(c) {\n this.url.scheme = \"file\";\n this.url.host = \"\";\n\n if (c === p(\"/\") || c === p(\"\\\\\")) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"file slash\";\n } else if (this.base !== null && this.base.scheme === \"file\") {\n this.url.host = this.base.host;\n this.url.path = this.base.path.slice();\n this.url.query = this.base.query;\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (!isNaN(c)) {\n this.url.query = null;\n if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {\n shortenPath(this.url);\n } else {\n this.parseError = true;\n this.url.path = [];\n }\n\n this.state = \"path\";\n --this.pointer;\n }\n } else {\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse file slash\"] = function parseFileSlash(c) {\n if (c === p(\"/\") || c === p(\"\\\\\")) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"file host\";\n } else {\n if (this.base !== null && this.base.scheme === \"file\") {\n if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&\n isNormalizedWindowsDriveLetterString(this.base.path[0])) {\n this.url.path.push(this.base.path[0]);\n }\n this.url.host = this.base.host;\n }\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse file host\"] = function parseFileHost(c, cStr) {\n if (isNaN(c) || c === p(\"/\") || c === p(\"\\\\\") || c === p(\"?\") || c === p(\"#\")) {\n --this.pointer;\n if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) {\n this.parseError = true;\n this.state = \"path\";\n } else if (this.buffer === \"\") {\n this.url.host = \"\";\n if (this.stateOverride) {\n return false;\n }\n this.state = \"path start\";\n } else {\n let host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n if (host === \"localhost\") {\n host = \"\";\n }\n this.url.host = host;\n\n if (this.stateOverride) {\n return false;\n }\n\n this.buffer = \"\";\n this.state = \"path start\";\n }\n } else {\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path start\"] = function parsePathStart(c) {\n if (isSpecial(this.url)) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"path\";\n\n if (c !== p(\"/\") && c !== p(\"\\\\\")) {\n --this.pointer;\n }\n } else if (!this.stateOverride && c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (!this.stateOverride && c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (c !== undefined) {\n this.state = \"path\";\n if (c !== p(\"/\")) {\n --this.pointer;\n }\n } else if (this.stateOverride && this.url.host === null) {\n this.url.path.push(\"\");\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path\"] = function parsePath(c) {\n if (isNaN(c) || c === p(\"/\") || (isSpecial(this.url) && c === p(\"\\\\\")) ||\n (!this.stateOverride && (c === p(\"?\") || c === p(\"#\")))) {\n if (isSpecial(this.url) && c === p(\"\\\\\")) {\n this.parseError = true;\n }\n\n if (isDoubleDot(this.buffer)) {\n shortenPath(this.url);\n if (c !== p(\"/\") && !(isSpecial(this.url) && c === p(\"\\\\\"))) {\n this.url.path.push(\"\");\n }\n } else if (isSingleDot(this.buffer) && c !== p(\"/\") &&\n !(isSpecial(this.url) && c === p(\"\\\\\"))) {\n this.url.path.push(\"\");\n } else if (!isSingleDot(this.buffer)) {\n if (this.url.scheme === \"file\" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {\n this.buffer = `${this.buffer[0]}:`;\n }\n this.url.path.push(this.buffer);\n }\n this.buffer = \"\";\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n }\n if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n }\n } else {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.buffer += utf8PercentEncodeCodePoint(c, isPathPercentEncode);\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse opaque path\"] = function parseOpaquePath(c) {\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else {\n // TODO: Add: not a URL code point\n if (!isNaN(c) && c !== p(\"%\")) {\n this.parseError = true;\n }\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n if (!isNaN(c)) {\n this.url.path += utf8PercentEncodeCodePoint(c, isC0ControlPercentEncode);\n }\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse query\"] = function parseQuery(c, cStr) {\n if (!isSpecial(this.url) || this.url.scheme === \"ws\" || this.url.scheme === \"wss\") {\n this.encodingOverride = \"utf-8\";\n }\n\n if ((!this.stateOverride && c === p(\"#\")) || isNaN(c)) {\n const queryPercentEncodePredicate = isSpecial(this.url) ? isSpecialQueryPercentEncode : isQueryPercentEncode;\n this.url.query += utf8PercentEncodeString(this.buffer, queryPercentEncodePredicate);\n\n this.buffer = \"\";\n\n if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n }\n } else if (!isNaN(c)) {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse fragment\"] = function parseFragment(c) {\n if (!isNaN(c)) {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.url.fragment += utf8PercentEncodeCodePoint(c, isFragmentPercentEncode);\n }\n\n return true;\n};\n\nfunction serializeURL(url, excludeFragment) {\n let output = `${url.scheme}:`;\n if (url.host !== null) {\n output += \"//\";\n\n if (url.username !== \"\" || url.password !== \"\") {\n output += url.username;\n if (url.password !== \"\") {\n output += `:${url.password}`;\n }\n output += \"@\";\n }\n\n output += serializeHost(url.host);\n\n if (url.port !== null) {\n output += `:${url.port}`;\n }\n }\n\n if (url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === \"\") {\n output += \"/.\";\n }\n output += serializePath(url);\n\n if (url.query !== null) {\n output += `?${url.query}`;\n }\n\n if (!excludeFragment && url.fragment !== null) {\n output += `#${url.fragment}`;\n }\n\n return output;\n}\n\nfunction serializeOrigin(tuple) {\n let result = `${tuple.scheme}://`;\n result += serializeHost(tuple.host);\n\n if (tuple.port !== null) {\n result += `:${tuple.port}`;\n }\n\n return result;\n}\n\nfunction serializePath(url) {\n if (hasAnOpaquePath(url)) {\n return url.path;\n }\n\n let output = \"\";\n for (const segment of url.path) {\n output += `/${segment}`;\n }\n return output;\n}\n\nmodule.exports.serializeURL = serializeURL;\n\nmodule.exports.serializePath = serializePath;\n\nmodule.exports.serializeURLOrigin = function (url) {\n // https://url.spec.whatwg.org/#concept-url-origin\n switch (url.scheme) {\n case \"blob\": {\n const pathURL = module.exports.parseURL(serializePath(url));\n if (pathURL === null) {\n return \"null\";\n }\n if (pathURL.scheme !== \"http\" && pathURL.scheme !== \"https\") {\n return \"null\";\n }\n return module.exports.serializeURLOrigin(pathURL);\n }\n case \"ftp\":\n case \"http\":\n case \"https\":\n case \"ws\":\n case \"wss\":\n return serializeOrigin({\n scheme: url.scheme,\n host: url.host,\n port: url.port\n });\n case \"file\":\n // The spec says:\n // > Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.\n // Browsers tested so far:\n // - Chrome says \"file://\", but treats file: URLs as cross-origin for most (all?) purposes; see e.g.\n // https://bugs.chromium.org/p/chromium/issues/detail?id=37586\n // - Firefox says \"null\", but treats file: URLs as same-origin sometimes based on directory stuff; see\n // https://developer.mozilla.org/en-US/docs/Archive/Misc_top_level/Same-origin_policy_for_file:_URIs\n return \"null\";\n default:\n // serializing an opaque origin returns \"null\"\n return \"null\";\n }\n};\n\nmodule.exports.basicURLParse = function (input, options) {\n if (options === undefined) {\n options = {};\n }\n\n const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride);\n if (usm.failure) {\n return null;\n }\n\n return usm.url;\n};\n\nmodule.exports.setTheUsername = function (url, username) {\n url.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);\n};\n\nmodule.exports.setThePassword = function (url, password) {\n url.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);\n};\n\nmodule.exports.serializeHost = serializeHost;\n\nmodule.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;\n\nmodule.exports.hasAnOpaquePath = hasAnOpaquePath;\n\nmodule.exports.serializeInteger = function (integer) {\n return String(integer);\n};\n\nmodule.exports.parseURL = function (input, options) {\n if (options === undefined) {\n options = {};\n }\n\n // We don't handle blobs, so this just delegates:\n return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride });\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/whatwg-url/lib/url-state-machine.js?");
|
|
418
|
+
eval("\nconst tr46 = __webpack_require__(/*! tr46 */ \"./node_modules/tr46/index.js\");\n\nconst infra = __webpack_require__(/*! ./infra */ \"./node_modules/whatwg-url/lib/infra.js\");\nconst { utf8DecodeWithoutBOM } = __webpack_require__(/*! ./encoding */ \"./node_modules/whatwg-url/lib/encoding.js\");\nconst { percentDecodeString, utf8PercentEncodeCodePoint, utf8PercentEncodeString, isC0ControlPercentEncode,\n isFragmentPercentEncode, isQueryPercentEncode, isSpecialQueryPercentEncode, isPathPercentEncode,\n isUserinfoPercentEncode } = __webpack_require__(/*! ./percent-encoding */ \"./node_modules/whatwg-url/lib/percent-encoding.js\");\n\nfunction p(char) {\n return char.codePointAt(0);\n}\n\nconst specialSchemes = {\n ftp: 21,\n file: null,\n http: 80,\n https: 443,\n ws: 80,\n wss: 443\n};\n\nconst failure = Symbol(\"failure\");\n\nfunction countSymbols(str) {\n return [...str].length;\n}\n\nfunction at(input, idx) {\n const c = input[idx];\n return isNaN(c) ? undefined : String.fromCodePoint(c);\n}\n\nfunction isSingleDot(buffer) {\n return buffer === \".\" || buffer.toLowerCase() === \"%2e\";\n}\n\nfunction isDoubleDot(buffer) {\n buffer = buffer.toLowerCase();\n return buffer === \"..\" || buffer === \"%2e.\" || buffer === \".%2e\" || buffer === \"%2e%2e\";\n}\n\nfunction isWindowsDriveLetterCodePoints(cp1, cp2) {\n return infra.isASCIIAlpha(cp1) && (cp2 === p(\":\") || cp2 === p(\"|\"));\n}\n\nfunction isWindowsDriveLetterString(string) {\n return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && (string[1] === \":\" || string[1] === \"|\");\n}\n\nfunction isNormalizedWindowsDriveLetterString(string) {\n return string.length === 2 && infra.isASCIIAlpha(string.codePointAt(0)) && string[1] === \":\";\n}\n\nfunction containsForbiddenHostCodePoint(string) {\n return string.search(/\\u0000|\\u0009|\\u000A|\\u000D|\\u0020|#|\\/|:|<|>|\\?|@|\\[|\\\\|\\]|\\^|\\|/u) !== -1;\n}\n\nfunction containsForbiddenDomainCodePoint(string) {\n return containsForbiddenHostCodePoint(string) || string.search(/[\\u0000-\\u001F]|%|\\u007F/u) !== -1;\n}\n\nfunction isSpecialScheme(scheme) {\n return specialSchemes[scheme] !== undefined;\n}\n\nfunction isSpecial(url) {\n return isSpecialScheme(url.scheme);\n}\n\nfunction isNotSpecial(url) {\n return !isSpecialScheme(url.scheme);\n}\n\nfunction defaultPort(scheme) {\n return specialSchemes[scheme];\n}\n\nfunction parseIPv4Number(input) {\n if (input === \"\") {\n return failure;\n }\n\n let R = 10;\n\n if (input.length >= 2 && input.charAt(0) === \"0\" && input.charAt(1).toLowerCase() === \"x\") {\n input = input.substring(2);\n R = 16;\n } else if (input.length >= 2 && input.charAt(0) === \"0\") {\n input = input.substring(1);\n R = 8;\n }\n\n if (input === \"\") {\n return 0;\n }\n\n let regex = /[^0-7]/u;\n if (R === 10) {\n regex = /[^0-9]/u;\n }\n if (R === 16) {\n regex = /[^0-9A-Fa-f]/u;\n }\n\n if (regex.test(input)) {\n return failure;\n }\n\n return parseInt(input, R);\n}\n\nfunction parseIPv4(input) {\n const parts = input.split(\".\");\n if (parts[parts.length - 1] === \"\") {\n if (parts.length > 1) {\n parts.pop();\n }\n }\n\n if (parts.length > 4) {\n return failure;\n }\n\n const numbers = [];\n for (const part of parts) {\n const n = parseIPv4Number(part);\n if (n === failure) {\n return failure;\n }\n\n numbers.push(n);\n }\n\n for (let i = 0; i < numbers.length - 1; ++i) {\n if (numbers[i] > 255) {\n return failure;\n }\n }\n if (numbers[numbers.length - 1] >= 256 ** (5 - numbers.length)) {\n return failure;\n }\n\n let ipv4 = numbers.pop();\n let counter = 0;\n\n for (const n of numbers) {\n ipv4 += n * 256 ** (3 - counter);\n ++counter;\n }\n\n return ipv4;\n}\n\nfunction serializeIPv4(address) {\n let output = \"\";\n let n = address;\n\n for (let i = 1; i <= 4; ++i) {\n output = String(n % 256) + output;\n if (i !== 4) {\n output = `.${output}`;\n }\n n = Math.floor(n / 256);\n }\n\n return output;\n}\n\nfunction parseIPv6(input) {\n const address = [0, 0, 0, 0, 0, 0, 0, 0];\n let pieceIndex = 0;\n let compress = null;\n let pointer = 0;\n\n input = Array.from(input, c => c.codePointAt(0));\n\n if (input[pointer] === p(\":\")) {\n if (input[pointer + 1] !== p(\":\")) {\n return failure;\n }\n\n pointer += 2;\n ++pieceIndex;\n compress = pieceIndex;\n }\n\n while (pointer < input.length) {\n if (pieceIndex === 8) {\n return failure;\n }\n\n if (input[pointer] === p(\":\")) {\n if (compress !== null) {\n return failure;\n }\n ++pointer;\n ++pieceIndex;\n compress = pieceIndex;\n continue;\n }\n\n let value = 0;\n let length = 0;\n\n while (length < 4 && infra.isASCIIHex(input[pointer])) {\n value = value * 0x10 + parseInt(at(input, pointer), 16);\n ++pointer;\n ++length;\n }\n\n if (input[pointer] === p(\".\")) {\n if (length === 0) {\n return failure;\n }\n\n pointer -= length;\n\n if (pieceIndex > 6) {\n return failure;\n }\n\n let numbersSeen = 0;\n\n while (input[pointer] !== undefined) {\n let ipv4Piece = null;\n\n if (numbersSeen > 0) {\n if (input[pointer] === p(\".\") && numbersSeen < 4) {\n ++pointer;\n } else {\n return failure;\n }\n }\n\n if (!infra.isASCIIDigit(input[pointer])) {\n return failure;\n }\n\n while (infra.isASCIIDigit(input[pointer])) {\n const number = parseInt(at(input, pointer));\n if (ipv4Piece === null) {\n ipv4Piece = number;\n } else if (ipv4Piece === 0) {\n return failure;\n } else {\n ipv4Piece = ipv4Piece * 10 + number;\n }\n if (ipv4Piece > 255) {\n return failure;\n }\n ++pointer;\n }\n\n address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece;\n\n ++numbersSeen;\n\n if (numbersSeen === 2 || numbersSeen === 4) {\n ++pieceIndex;\n }\n }\n\n if (numbersSeen !== 4) {\n return failure;\n }\n\n break;\n } else if (input[pointer] === p(\":\")) {\n ++pointer;\n if (input[pointer] === undefined) {\n return failure;\n }\n } else if (input[pointer] !== undefined) {\n return failure;\n }\n\n address[pieceIndex] = value;\n ++pieceIndex;\n }\n\n if (compress !== null) {\n let swaps = pieceIndex - compress;\n pieceIndex = 7;\n while (pieceIndex !== 0 && swaps > 0) {\n const temp = address[compress + swaps - 1];\n address[compress + swaps - 1] = address[pieceIndex];\n address[pieceIndex] = temp;\n --pieceIndex;\n --swaps;\n }\n } else if (compress === null && pieceIndex !== 8) {\n return failure;\n }\n\n return address;\n}\n\nfunction serializeIPv6(address) {\n let output = \"\";\n const compress = findTheIPv6AddressCompressedPieceIndex(address);\n let ignore0 = false;\n\n for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) {\n if (ignore0 && address[pieceIndex] === 0) {\n continue;\n } else if (ignore0) {\n ignore0 = false;\n }\n\n if (compress === pieceIndex) {\n const separator = pieceIndex === 0 ? \"::\" : \":\";\n output += separator;\n ignore0 = true;\n continue;\n }\n\n output += address[pieceIndex].toString(16);\n\n if (pieceIndex !== 7) {\n output += \":\";\n }\n }\n\n return output;\n}\n\nfunction parseHost(input, isOpaque = false) {\n if (input[0] === \"[\") {\n if (input[input.length - 1] !== \"]\") {\n return failure;\n }\n\n return parseIPv6(input.substring(1, input.length - 1));\n }\n\n if (isOpaque) {\n return parseOpaqueHost(input);\n }\n\n const domain = utf8DecodeWithoutBOM(percentDecodeString(input));\n const asciiDomain = domainToASCII(domain);\n if (asciiDomain === failure) {\n return failure;\n }\n\n if (containsForbiddenDomainCodePoint(asciiDomain)) {\n return failure;\n }\n\n if (endsInANumber(asciiDomain)) {\n return parseIPv4(asciiDomain);\n }\n\n return asciiDomain;\n}\n\nfunction endsInANumber(input) {\n const parts = input.split(\".\");\n if (parts[parts.length - 1] === \"\") {\n if (parts.length === 1) {\n return false;\n }\n parts.pop();\n }\n\n const last = parts[parts.length - 1];\n if (parseIPv4Number(last) !== failure) {\n return true;\n }\n\n if (/^[0-9]+$/u.test(last)) {\n return true;\n }\n\n return false;\n}\n\nfunction parseOpaqueHost(input) {\n if (containsForbiddenHostCodePoint(input)) {\n return failure;\n }\n\n return utf8PercentEncodeString(input, isC0ControlPercentEncode);\n}\n\nfunction findTheIPv6AddressCompressedPieceIndex(address) {\n let longestIndex = null;\n let longestSize = 1; // only find elements > 1\n let foundIndex = null;\n let foundSize = 0;\n\n for (let pieceIndex = 0; pieceIndex < address.length; ++pieceIndex) {\n if (address[pieceIndex] !== 0) {\n if (foundSize > longestSize) {\n longestIndex = foundIndex;\n longestSize = foundSize;\n }\n\n foundIndex = null;\n foundSize = 0;\n } else {\n if (foundIndex === null) {\n foundIndex = pieceIndex;\n }\n ++foundSize;\n }\n }\n\n if (foundSize > longestSize) {\n return foundIndex;\n }\n\n return longestIndex;\n}\n\nfunction serializeHost(host) {\n if (typeof host === \"number\") {\n return serializeIPv4(host);\n }\n\n // IPv6 serializer\n if (host instanceof Array) {\n return `[${serializeIPv6(host)}]`;\n }\n\n return host;\n}\n\nfunction domainToASCII(domain, beStrict = false) {\n const result = tr46.toASCII(domain, {\n checkBidi: true,\n checkHyphens: false,\n checkJoiners: true,\n useSTD3ASCIIRules: beStrict,\n verifyDNSLength: beStrict\n });\n if (result === null || result === \"\") {\n return failure;\n }\n return result;\n}\n\nfunction trimControlChars(url) {\n return url.replace(/^[\\u0000-\\u001F\\u0020]+|[\\u0000-\\u001F\\u0020]+$/ug, \"\");\n}\n\nfunction trimTabAndNewline(url) {\n return url.replace(/\\u0009|\\u000A|\\u000D/ug, \"\");\n}\n\nfunction shortenPath(url) {\n const { path } = url;\n if (path.length === 0) {\n return;\n }\n if (url.scheme === \"file\" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) {\n return;\n }\n\n path.pop();\n}\n\nfunction includesCredentials(url) {\n return url.username !== \"\" || url.password !== \"\";\n}\n\nfunction cannotHaveAUsernamePasswordPort(url) {\n return url.host === null || url.host === \"\" || url.scheme === \"file\";\n}\n\nfunction hasAnOpaquePath(url) {\n return typeof url.path === \"string\";\n}\n\nfunction isNormalizedWindowsDriveLetter(string) {\n return /^[A-Za-z]:$/u.test(string);\n}\n\nfunction URLStateMachine(input, base, encodingOverride, url, stateOverride) {\n this.pointer = 0;\n this.input = input;\n this.base = base || null;\n this.encodingOverride = encodingOverride || \"utf-8\";\n this.stateOverride = stateOverride;\n this.url = url;\n this.failure = false;\n this.parseError = false;\n\n if (!this.url) {\n this.url = {\n scheme: \"\",\n username: \"\",\n password: \"\",\n host: null,\n port: null,\n path: [],\n query: null,\n fragment: null\n };\n\n const res = trimControlChars(this.input);\n if (res !== this.input) {\n this.parseError = true;\n }\n this.input = res;\n }\n\n const res = trimTabAndNewline(this.input);\n if (res !== this.input) {\n this.parseError = true;\n }\n this.input = res;\n\n this.state = stateOverride || \"scheme start\";\n\n this.buffer = \"\";\n this.atFlag = false;\n this.arrFlag = false;\n this.passwordTokenSeenFlag = false;\n\n this.input = Array.from(this.input, c => c.codePointAt(0));\n\n for (; this.pointer <= this.input.length; ++this.pointer) {\n const c = this.input[this.pointer];\n const cStr = isNaN(c) ? undefined : String.fromCodePoint(c);\n\n // exec state machine\n const ret = this[`parse ${this.state}`](c, cStr);\n if (!ret) {\n break; // terminate algorithm\n } else if (ret === failure) {\n this.failure = true;\n break;\n }\n }\n}\n\nURLStateMachine.prototype[\"parse scheme start\"] = function parseSchemeStart(c, cStr) {\n if (infra.isASCIIAlpha(c)) {\n this.buffer += cStr.toLowerCase();\n this.state = \"scheme\";\n } else if (!this.stateOverride) {\n this.state = \"no scheme\";\n --this.pointer;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse scheme\"] = function parseScheme(c, cStr) {\n if (infra.isASCIIAlphanumeric(c) || c === p(\"+\") || c === p(\"-\") || c === p(\".\")) {\n this.buffer += cStr.toLowerCase();\n } else if (c === p(\":\")) {\n if (this.stateOverride) {\n if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) {\n return false;\n }\n\n if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) {\n return false;\n }\n\n if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === \"file\") {\n return false;\n }\n\n if (this.url.scheme === \"file\" && this.url.host === \"\") {\n return false;\n }\n }\n this.url.scheme = this.buffer;\n if (this.stateOverride) {\n if (this.url.port === defaultPort(this.url.scheme)) {\n this.url.port = null;\n }\n return false;\n }\n this.buffer = \"\";\n if (this.url.scheme === \"file\") {\n if (this.input[this.pointer + 1] !== p(\"/\") || this.input[this.pointer + 2] !== p(\"/\")) {\n this.parseError = true;\n }\n this.state = \"file\";\n } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) {\n this.state = \"special relative or authority\";\n } else if (isSpecial(this.url)) {\n this.state = \"special authority slashes\";\n } else if (this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"path or authority\";\n ++this.pointer;\n } else {\n this.url.path = \"\";\n this.state = \"opaque path\";\n }\n } else if (!this.stateOverride) {\n this.buffer = \"\";\n this.state = \"no scheme\";\n this.pointer = -1;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse no scheme\"] = function parseNoScheme(c) {\n if (this.base === null || (hasAnOpaquePath(this.base) && c !== p(\"#\"))) {\n return failure;\n } else if (hasAnOpaquePath(this.base) && c === p(\"#\")) {\n this.url.scheme = this.base.scheme;\n this.url.path = this.base.path;\n this.url.query = this.base.query;\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (this.base.scheme === \"file\") {\n this.state = \"file\";\n --this.pointer;\n } else {\n this.state = \"relative\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special relative or authority\"] = function parseSpecialRelativeOrAuthority(c) {\n if (c === p(\"/\") && this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"special authority ignore slashes\";\n ++this.pointer;\n } else {\n this.parseError = true;\n this.state = \"relative\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path or authority\"] = function parsePathOrAuthority(c) {\n if (c === p(\"/\")) {\n this.state = \"authority\";\n } else {\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse relative\"] = function parseRelative(c) {\n this.url.scheme = this.base.scheme;\n if (c === p(\"/\")) {\n this.state = \"relative slash\";\n } else if (isSpecial(this.url) && c === p(\"\\\\\")) {\n this.parseError = true;\n this.state = \"relative slash\";\n } else {\n this.url.username = this.base.username;\n this.url.password = this.base.password;\n this.url.host = this.base.host;\n this.url.port = this.base.port;\n this.url.path = this.base.path.slice();\n this.url.query = this.base.query;\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (!isNaN(c)) {\n this.url.query = null;\n this.url.path.pop();\n this.state = \"path\";\n --this.pointer;\n }\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse relative slash\"] = function parseRelativeSlash(c) {\n if (isSpecial(this.url) && (c === p(\"/\") || c === p(\"\\\\\"))) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"special authority ignore slashes\";\n } else if (c === p(\"/\")) {\n this.state = \"authority\";\n } else {\n this.url.username = this.base.username;\n this.url.password = this.base.password;\n this.url.host = this.base.host;\n this.url.port = this.base.port;\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special authority slashes\"] = function parseSpecialAuthoritySlashes(c) {\n if (c === p(\"/\") && this.input[this.pointer + 1] === p(\"/\")) {\n this.state = \"special authority ignore slashes\";\n ++this.pointer;\n } else {\n this.parseError = true;\n this.state = \"special authority ignore slashes\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse special authority ignore slashes\"] = function parseSpecialAuthorityIgnoreSlashes(c) {\n if (c !== p(\"/\") && c !== p(\"\\\\\")) {\n this.state = \"authority\";\n --this.pointer;\n } else {\n this.parseError = true;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse authority\"] = function parseAuthority(c, cStr) {\n if (c === p(\"@\")) {\n this.parseError = true;\n if (this.atFlag) {\n this.buffer = `%40${this.buffer}`;\n }\n this.atFlag = true;\n\n // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars\n const len = countSymbols(this.buffer);\n for (let pointer = 0; pointer < len; ++pointer) {\n const codePoint = this.buffer.codePointAt(pointer);\n\n if (codePoint === p(\":\") && !this.passwordTokenSeenFlag) {\n this.passwordTokenSeenFlag = true;\n continue;\n }\n const encodedCodePoints = utf8PercentEncodeCodePoint(codePoint, isUserinfoPercentEncode);\n if (this.passwordTokenSeenFlag) {\n this.url.password += encodedCodePoints;\n } else {\n this.url.username += encodedCodePoints;\n }\n }\n this.buffer = \"\";\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\"))) {\n if (this.atFlag && this.buffer === \"\") {\n this.parseError = true;\n return failure;\n }\n this.pointer -= countSymbols(this.buffer) + 1;\n this.buffer = \"\";\n this.state = \"host\";\n } else {\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse hostname\"] =\nURLStateMachine.prototype[\"parse host\"] = function parseHostName(c, cStr) {\n if (this.stateOverride && this.url.scheme === \"file\") {\n --this.pointer;\n this.state = \"file host\";\n } else if (c === p(\":\") && !this.arrFlag) {\n if (this.buffer === \"\") {\n this.parseError = true;\n return failure;\n }\n\n if (this.stateOverride === \"hostname\") {\n return false;\n }\n\n const host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n\n this.url.host = host;\n this.buffer = \"\";\n this.state = \"port\";\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\"))) {\n --this.pointer;\n if (isSpecial(this.url) && this.buffer === \"\") {\n this.parseError = true;\n return failure;\n } else if (this.stateOverride && this.buffer === \"\" &&\n (includesCredentials(this.url) || this.url.port !== null)) {\n this.parseError = true;\n return false;\n }\n\n const host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n\n this.url.host = host;\n this.buffer = \"\";\n this.state = \"path start\";\n if (this.stateOverride) {\n return false;\n }\n } else {\n if (c === p(\"[\")) {\n this.arrFlag = true;\n } else if (c === p(\"]\")) {\n this.arrFlag = false;\n }\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse port\"] = function parsePort(c, cStr) {\n if (infra.isASCIIDigit(c)) {\n this.buffer += cStr;\n } else if (isNaN(c) || c === p(\"/\") || c === p(\"?\") || c === p(\"#\") ||\n (isSpecial(this.url) && c === p(\"\\\\\")) ||\n this.stateOverride) {\n if (this.buffer !== \"\") {\n const port = parseInt(this.buffer);\n if (port > 2 ** 16 - 1) {\n this.parseError = true;\n return failure;\n }\n this.url.port = port === defaultPort(this.url.scheme) ? null : port;\n this.buffer = \"\";\n }\n if (this.stateOverride) {\n return false;\n }\n this.state = \"path start\";\n --this.pointer;\n } else {\n this.parseError = true;\n return failure;\n }\n\n return true;\n};\n\nconst fileOtherwiseCodePoints = new Set([p(\"/\"), p(\"\\\\\"), p(\"?\"), p(\"#\")]);\n\nfunction startsWithWindowsDriveLetter(input, pointer) {\n const length = input.length - pointer;\n return length >= 2 &&\n isWindowsDriveLetterCodePoints(input[pointer], input[pointer + 1]) &&\n (length === 2 || fileOtherwiseCodePoints.has(input[pointer + 2]));\n}\n\nURLStateMachine.prototype[\"parse file\"] = function parseFile(c) {\n this.url.scheme = \"file\";\n this.url.host = \"\";\n\n if (c === p(\"/\") || c === p(\"\\\\\")) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"file slash\";\n } else if (this.base !== null && this.base.scheme === \"file\") {\n this.url.host = this.base.host;\n this.url.path = this.base.path.slice();\n this.url.query = this.base.query;\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (!isNaN(c)) {\n this.url.query = null;\n if (!startsWithWindowsDriveLetter(this.input, this.pointer)) {\n shortenPath(this.url);\n } else {\n this.parseError = true;\n this.url.path = [];\n }\n\n this.state = \"path\";\n --this.pointer;\n }\n } else {\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse file slash\"] = function parseFileSlash(c) {\n if (c === p(\"/\") || c === p(\"\\\\\")) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"file host\";\n } else {\n if (this.base !== null && this.base.scheme === \"file\") {\n if (!startsWithWindowsDriveLetter(this.input, this.pointer) &&\n isNormalizedWindowsDriveLetterString(this.base.path[0])) {\n this.url.path.push(this.base.path[0]);\n }\n this.url.host = this.base.host;\n }\n this.state = \"path\";\n --this.pointer;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse file host\"] = function parseFileHost(c, cStr) {\n if (isNaN(c) || c === p(\"/\") || c === p(\"\\\\\") || c === p(\"?\") || c === p(\"#\")) {\n --this.pointer;\n if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) {\n this.parseError = true;\n this.state = \"path\";\n } else if (this.buffer === \"\") {\n this.url.host = \"\";\n if (this.stateOverride) {\n return false;\n }\n this.state = \"path start\";\n } else {\n let host = parseHost(this.buffer, isNotSpecial(this.url));\n if (host === failure) {\n return failure;\n }\n if (host === \"localhost\") {\n host = \"\";\n }\n this.url.host = host;\n\n if (this.stateOverride) {\n return false;\n }\n\n this.buffer = \"\";\n this.state = \"path start\";\n }\n } else {\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path start\"] = function parsePathStart(c) {\n if (isSpecial(this.url)) {\n if (c === p(\"\\\\\")) {\n this.parseError = true;\n }\n this.state = \"path\";\n\n if (c !== p(\"/\") && c !== p(\"\\\\\")) {\n --this.pointer;\n }\n } else if (!this.stateOverride && c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (!this.stateOverride && c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else if (c !== undefined) {\n this.state = \"path\";\n if (c !== p(\"/\")) {\n --this.pointer;\n }\n } else if (this.stateOverride && this.url.host === null) {\n this.url.path.push(\"\");\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse path\"] = function parsePath(c) {\n if (isNaN(c) || c === p(\"/\") || (isSpecial(this.url) && c === p(\"\\\\\")) ||\n (!this.stateOverride && (c === p(\"?\") || c === p(\"#\")))) {\n if (isSpecial(this.url) && c === p(\"\\\\\")) {\n this.parseError = true;\n }\n\n if (isDoubleDot(this.buffer)) {\n shortenPath(this.url);\n if (c !== p(\"/\") && !(isSpecial(this.url) && c === p(\"\\\\\"))) {\n this.url.path.push(\"\");\n }\n } else if (isSingleDot(this.buffer) && c !== p(\"/\") &&\n !(isSpecial(this.url) && c === p(\"\\\\\"))) {\n this.url.path.push(\"\");\n } else if (!isSingleDot(this.buffer)) {\n if (this.url.scheme === \"file\" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) {\n this.buffer = `${this.buffer[0]}:`;\n }\n this.url.path.push(this.buffer);\n }\n this.buffer = \"\";\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n }\n if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n }\n } else {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.buffer += utf8PercentEncodeCodePoint(c, isPathPercentEncode);\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse opaque path\"] = function parseOpaquePath(c) {\n if (c === p(\"?\")) {\n this.url.query = \"\";\n this.state = \"query\";\n } else if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n } else {\n // TODO: Add: not a URL code point\n if (!isNaN(c) && c !== p(\"%\")) {\n this.parseError = true;\n }\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n if (!isNaN(c)) {\n this.url.path += utf8PercentEncodeCodePoint(c, isC0ControlPercentEncode);\n }\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse query\"] = function parseQuery(c, cStr) {\n if (!isSpecial(this.url) || this.url.scheme === \"ws\" || this.url.scheme === \"wss\") {\n this.encodingOverride = \"utf-8\";\n }\n\n if ((!this.stateOverride && c === p(\"#\")) || isNaN(c)) {\n const queryPercentEncodePredicate = isSpecial(this.url) ? isSpecialQueryPercentEncode : isQueryPercentEncode;\n this.url.query += utf8PercentEncodeString(this.buffer, queryPercentEncodePredicate);\n\n this.buffer = \"\";\n\n if (c === p(\"#\")) {\n this.url.fragment = \"\";\n this.state = \"fragment\";\n }\n } else if (!isNaN(c)) {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.buffer += cStr;\n }\n\n return true;\n};\n\nURLStateMachine.prototype[\"parse fragment\"] = function parseFragment(c) {\n if (!isNaN(c)) {\n // TODO: If c is not a URL code point and not \"%\", parse error.\n if (c === p(\"%\") &&\n (!infra.isASCIIHex(this.input[this.pointer + 1]) ||\n !infra.isASCIIHex(this.input[this.pointer + 2]))) {\n this.parseError = true;\n }\n\n this.url.fragment += utf8PercentEncodeCodePoint(c, isFragmentPercentEncode);\n }\n\n return true;\n};\n\nfunction serializeURL(url, excludeFragment) {\n let output = `${url.scheme}:`;\n if (url.host !== null) {\n output += \"//\";\n\n if (url.username !== \"\" || url.password !== \"\") {\n output += url.username;\n if (url.password !== \"\") {\n output += `:${url.password}`;\n }\n output += \"@\";\n }\n\n output += serializeHost(url.host);\n\n if (url.port !== null) {\n output += `:${url.port}`;\n }\n }\n\n if (url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === \"\") {\n output += \"/.\";\n }\n output += serializePath(url);\n\n if (url.query !== null) {\n output += `?${url.query}`;\n }\n\n if (!excludeFragment && url.fragment !== null) {\n output += `#${url.fragment}`;\n }\n\n return output;\n}\n\nfunction serializeOrigin(tuple) {\n let result = `${tuple.scheme}://`;\n result += serializeHost(tuple.host);\n\n if (tuple.port !== null) {\n result += `:${tuple.port}`;\n }\n\n return result;\n}\n\nfunction serializePath(url) {\n if (hasAnOpaquePath(url)) {\n return url.path;\n }\n\n let output = \"\";\n for (const segment of url.path) {\n output += `/${segment}`;\n }\n return output;\n}\n\nmodule.exports.serializeURL = serializeURL;\n\nmodule.exports.serializePath = serializePath;\n\nmodule.exports.serializeURLOrigin = function (url) {\n // https://url.spec.whatwg.org/#concept-url-origin\n switch (url.scheme) {\n case \"blob\": {\n const pathURL = module.exports.parseURL(serializePath(url));\n if (pathURL === null) {\n return \"null\";\n }\n if (pathURL.scheme !== \"http\" && pathURL.scheme !== \"https\") {\n return \"null\";\n }\n return module.exports.serializeURLOrigin(pathURL);\n }\n case \"ftp\":\n case \"http\":\n case \"https\":\n case \"ws\":\n case \"wss\":\n return serializeOrigin({\n scheme: url.scheme,\n host: url.host,\n port: url.port\n });\n case \"file\":\n // The spec says:\n // > Unfortunate as it is, this is left as an exercise to the reader. When in doubt, return a new opaque origin.\n // Browsers tested so far:\n // - Chrome says \"file://\", but treats file: URLs as cross-origin for most (all?) purposes; see e.g.\n // https://bugs.chromium.org/p/chromium/issues/detail?id=37586\n // - Firefox says \"null\", but treats file: URLs as same-origin sometimes based on directory stuff; see\n // https://developer.mozilla.org/en-US/docs/Archive/Misc_top_level/Same-origin_policy_for_file:_URIs\n return \"null\";\n default:\n // serializing an opaque origin returns \"null\"\n return \"null\";\n }\n};\n\nmodule.exports.basicURLParse = function (input, options) {\n if (options === undefined) {\n options = {};\n }\n\n const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride);\n if (usm.failure) {\n return null;\n }\n\n return usm.url;\n};\n\nmodule.exports.setTheUsername = function (url, username) {\n url.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);\n};\n\nmodule.exports.setThePassword = function (url, password) {\n url.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);\n};\n\nmodule.exports.serializeHost = serializeHost;\n\nmodule.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;\n\nmodule.exports.hasAnOpaquePath = hasAnOpaquePath;\n\nmodule.exports.serializeInteger = function (integer) {\n return String(integer);\n};\n\nmodule.exports.parseURL = function (input, options) {\n if (options === undefined) {\n options = {};\n }\n\n // We don't handle blobs, so this just delegates:\n return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride });\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/whatwg-url/lib/url-state-machine.js?");
|
|
419
419
|
|
|
420
420
|
/***/ }),
|
|
421
421
|
|
|
@@ -480,7 +480,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
480
480
|
/***/ ((__unused_webpack_module, exports) => {
|
|
481
481
|
|
|
482
482
|
"use strict";
|
|
483
|
-
eval("\n// imported from https://github.com/galkn/querystring\n/**\n * Compiles a querystring\n * Returns string representation of the object\n *\n * @param {Object}\n * @api private\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.
|
|
483
|
+
eval("\n// imported from https://github.com/galkn/querystring\n/**\n * Compiles a querystring\n * Returns string representation of the object\n *\n * @param {Object}\n * @api private\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.encode = encode;\nexports.decode = decode;\nfunction encode(obj) {\n let str = '';\n for (let i in obj) {\n if (obj.hasOwnProperty(i)) {\n if (str.length)\n str += '&';\n str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);\n }\n }\n return str;\n}\n/**\n * Parses a simple querystring into an object\n *\n * @param {String} qs\n * @api private\n */\nfunction decode(qs) {\n let qry = {};\n let pairs = qs.split('&');\n for (let i = 0, l = pairs.length; i < l; i++) {\n let pair = pairs[i].split('=');\n qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);\n }\n return qry;\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/contrib/parseqs.js?");
|
|
484
484
|
|
|
485
485
|
/***/ }),
|
|
486
486
|
|
|
@@ -491,29 +491,18 @@ eval("\n// imported from https://github.com/galkn/querystring\n/**\n * Compiles
|
|
|
491
491
|
/***/ ((__unused_webpack_module, exports) => {
|
|
492
492
|
|
|
493
493
|
"use strict";
|
|
494
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.parse =
|
|
494
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.parse = parse;\n// imported from https://github.com/galkn/parseuri\n/**\n * Parses a URI\n *\n * Note: we could also have used the built-in URL object, but it isn't supported on all platforms.\n *\n * See:\n * - https://developer.mozilla.org/en-US/docs/Web/API/URL\n * - https://caniuse.com/url\n * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B\n *\n * History of the parse() method:\n * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c\n * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3\n * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242\n *\n * @author Steven Levithan <stevenlevithan.com> (MIT license)\n * @api private\n */\nconst re = /^(?:(?![^:@\\/?#]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@\\/?#]*)(?::([^:@\\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/;\nconst parts = [\n 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'\n];\nfunction parse(str) {\n if (str.length > 8000) {\n throw \"URI too long\";\n }\n const src = str, b = str.indexOf('['), e = str.indexOf(']');\n if (b != -1 && e != -1) {\n str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);\n }\n let m = re.exec(str || ''), uri = {}, i = 14;\n while (i--) {\n uri[parts[i]] = m[i] || '';\n }\n if (b != -1 && e != -1) {\n uri.source = src;\n uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');\n uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');\n uri.ipv6uri = true;\n }\n uri.pathNames = pathNames(uri, uri['path']);\n uri.queryKey = queryKey(uri, uri['query']);\n return uri;\n}\nfunction pathNames(obj, path) {\n const regx = /\\/{2,9}/g, names = path.replace(regx, \"/\").split(\"/\");\n if (path.slice(0, 1) == '/' || path.length === 0) {\n names.splice(0, 1);\n }\n if (path.slice(-1) == '/') {\n names.splice(names.length - 1, 1);\n }\n return names;\n}\nfunction queryKey(uri, query) {\n const data = {};\n query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {\n if ($1) {\n data[$1] = $2;\n }\n });\n return data;\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/contrib/parseuri.js?");
|
|
495
495
|
|
|
496
496
|
/***/ }),
|
|
497
497
|
|
|
498
|
-
/***/ "./node_modules/engine.io-client/build/cjs/
|
|
499
|
-
|
|
500
|
-
!*** ./node_modules/engine.io-client/build/cjs/
|
|
501
|
-
|
|
502
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
503
|
-
|
|
504
|
-
"use strict";
|
|
505
|
-
eval("// imported from https://github.com/unshiftio/yeast\n\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.yeast = exports.decode = exports.encode = void 0;\nconst alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''), length = 64, map = {};\nlet seed = 0, i = 0, prev;\n/**\n * Return a string representing the specified number.\n *\n * @param {Number} num The number to convert.\n * @returns {String} The string representation of the number.\n * @api public\n */\nfunction encode(num) {\n let encoded = '';\n do {\n encoded = alphabet[num % length] + encoded;\n num = Math.floor(num / length);\n } while (num > 0);\n return encoded;\n}\nexports.encode = encode;\n/**\n * Return the integer value specified by the given string.\n *\n * @param {String} str The string to convert.\n * @returns {Number} The integer value represented by the string.\n * @api public\n */\nfunction decode(str) {\n let decoded = 0;\n for (i = 0; i < str.length; i++) {\n decoded = decoded * length + map[str.charAt(i)];\n }\n return decoded;\n}\nexports.decode = decode;\n/**\n * Yeast: A tiny growing id generator.\n *\n * @returns {String} A unique id.\n * @api public\n */\nfunction yeast() {\n const now = encode(+new Date());\n if (now !== prev)\n return seed = 0, prev = now;\n return now + '.' + encode(seed++);\n}\nexports.yeast = yeast;\n//\n// Map each character to its index.\n//\nfor (; i < length; i++)\n map[alphabet[i]] = i;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/contrib/yeast.js?");
|
|
506
|
-
|
|
507
|
-
/***/ }),
|
|
508
|
-
|
|
509
|
-
/***/ "./node_modules/engine.io-client/build/cjs/globalThis.browser.js":
|
|
510
|
-
/*!***********************************************************************!*\
|
|
511
|
-
!*** ./node_modules/engine.io-client/build/cjs/globalThis.browser.js ***!
|
|
512
|
-
\***********************************************************************/
|
|
498
|
+
/***/ "./node_modules/engine.io-client/build/cjs/globals.js":
|
|
499
|
+
/*!************************************************************!*\
|
|
500
|
+
!*** ./node_modules/engine.io-client/build/cjs/globals.js ***!
|
|
501
|
+
\************************************************************/
|
|
513
502
|
/***/ ((__unused_webpack_module, exports) => {
|
|
514
503
|
|
|
515
504
|
"use strict";
|
|
516
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.globalThisShim = void 0;\nexports.globalThisShim = (() => {\n if (typeof self !== \"undefined\") {\n return self;\n }\n else if (typeof window !== \"undefined\") {\n return window;\n }\n else {\n return Function(\"return this\")();\n }\n})();\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/
|
|
505
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.defaultBinaryType = exports.globalThisShim = exports.nextTick = void 0;\nexports.createCookieJar = createCookieJar;\nexports.nextTick = (() => {\n const isPromiseAvailable = typeof Promise === \"function\" && typeof Promise.resolve === \"function\";\n if (isPromiseAvailable) {\n return (cb) => Promise.resolve().then(cb);\n }\n else {\n return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);\n }\n})();\nexports.globalThisShim = (() => {\n if (typeof self !== \"undefined\") {\n return self;\n }\n else if (typeof window !== \"undefined\") {\n return window;\n }\n else {\n return Function(\"return this\")();\n }\n})();\nexports.defaultBinaryType = \"arraybuffer\";\nfunction createCookieJar() { }\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/globals.js?");
|
|
517
506
|
|
|
518
507
|
/***/ }),
|
|
519
508
|
|
|
@@ -524,7 +513,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
524
513
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
525
514
|
|
|
526
515
|
"use strict";
|
|
527
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.Socket = void 0;\nconst socket_js_1 = __webpack_require__(/*! ./socket.js */ \"./node_modules/engine.io-client/build/cjs/socket.js\");\nObject.defineProperty(exports, \"Socket\", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));\nexports.protocol = socket_js_1.Socket.protocol;\nvar transport_js_1 = __webpack_require__(/*! ./transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nObject.defineProperty(exports, \"Transport\", ({ enumerable: true, get: function () { return transport_js_1.Transport; } }));\nObject.defineProperty(exports, \"TransportError\", ({ enumerable: true, get: function () { return transport_js_1.TransportError; } }));\nvar index_js_1 = __webpack_require__(/*! ./transports/index.js */ \"./node_modules/engine.io-client/build/cjs/transports/index.js\");\nObject.defineProperty(exports, \"transports\", ({ enumerable: true, get: function () { return index_js_1.transports; } }));\nvar util_js_1 = __webpack_require__(/*! ./util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nObject.defineProperty(exports, \"installTimerFunctions\", ({ enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }));\nvar parseuri_js_1 = __webpack_require__(/*! ./contrib/parseuri.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseuri.js\");\nObject.defineProperty(exports, \"parse\", ({ enumerable: true, get: function () { return parseuri_js_1.parse; } }));\nvar
|
|
516
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.nextTick = exports.parse = exports.installTimerFunctions = exports.transports = exports.TransportError = exports.Transport = exports.protocol = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = exports.Socket = void 0;\nconst socket_js_1 = __webpack_require__(/*! ./socket.js */ \"./node_modules/engine.io-client/build/cjs/socket.js\");\nObject.defineProperty(exports, \"Socket\", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));\nvar socket_js_2 = __webpack_require__(/*! ./socket.js */ \"./node_modules/engine.io-client/build/cjs/socket.js\");\nObject.defineProperty(exports, \"SocketWithoutUpgrade\", ({ enumerable: true, get: function () { return socket_js_2.SocketWithoutUpgrade; } }));\nObject.defineProperty(exports, \"SocketWithUpgrade\", ({ enumerable: true, get: function () { return socket_js_2.SocketWithUpgrade; } }));\nexports.protocol = socket_js_1.Socket.protocol;\nvar transport_js_1 = __webpack_require__(/*! ./transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nObject.defineProperty(exports, \"Transport\", ({ enumerable: true, get: function () { return transport_js_1.Transport; } }));\nObject.defineProperty(exports, \"TransportError\", ({ enumerable: true, get: function () { return transport_js_1.TransportError; } }));\nvar index_js_1 = __webpack_require__(/*! ./transports/index.js */ \"./node_modules/engine.io-client/build/cjs/transports/index.js\");\nObject.defineProperty(exports, \"transports\", ({ enumerable: true, get: function () { return index_js_1.transports; } }));\nvar util_js_1 = __webpack_require__(/*! ./util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nObject.defineProperty(exports, \"installTimerFunctions\", ({ enumerable: true, get: function () { return util_js_1.installTimerFunctions; } }));\nvar parseuri_js_1 = __webpack_require__(/*! ./contrib/parseuri.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseuri.js\");\nObject.defineProperty(exports, \"parse\", ({ enumerable: true, get: function () { return parseuri_js_1.parse; } }));\nvar globals_node_js_1 = __webpack_require__(/*! ./globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nObject.defineProperty(exports, \"nextTick\", ({ enumerable: true, get: function () { return globals_node_js_1.nextTick; } }));\nvar polling_fetch_js_1 = __webpack_require__(/*! ./transports/polling-fetch.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling-fetch.js\");\nObject.defineProperty(exports, \"Fetch\", ({ enumerable: true, get: function () { return polling_fetch_js_1.Fetch; } }));\nvar polling_xhr_node_js_1 = __webpack_require__(/*! ./transports/polling-xhr.node.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js\");\nObject.defineProperty(exports, \"NodeXHR\", ({ enumerable: true, get: function () { return polling_xhr_node_js_1.XHR; } }));\nvar polling_xhr_js_1 = __webpack_require__(/*! ./transports/polling-xhr.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js\");\nObject.defineProperty(exports, \"XHR\", ({ enumerable: true, get: function () { return polling_xhr_js_1.XHR; } }));\nvar websocket_node_js_1 = __webpack_require__(/*! ./transports/websocket.node.js */ \"./node_modules/engine.io-client/build/cjs/transports/websocket.js\");\nObject.defineProperty(exports, \"NodeWebSocket\", ({ enumerable: true, get: function () { return websocket_node_js_1.WS; } }));\nvar websocket_js_1 = __webpack_require__(/*! ./transports/websocket.js */ \"./node_modules/engine.io-client/build/cjs/transports/websocket.js\");\nObject.defineProperty(exports, \"WebSocket\", ({ enumerable: true, get: function () { return websocket_js_1.WS; } }));\nvar webtransport_js_1 = __webpack_require__(/*! ./transports/webtransport.js */ \"./node_modules/engine.io-client/build/cjs/transports/webtransport.js\");\nObject.defineProperty(exports, \"WebTransport\", ({ enumerable: true, get: function () { return webtransport_js_1.WT; } }));\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/index.js?");
|
|
528
517
|
|
|
529
518
|
/***/ }),
|
|
530
519
|
|
|
@@ -535,7 +524,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
535
524
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
536
525
|
|
|
537
526
|
"use strict";
|
|
538
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Socket = void 0;\nconst index_js_1 = __webpack_require__(/*! ./transports/index.js */ \"./node_modules/engine.io-client/build/cjs/transports/index.js\");\nconst util_js_1 = __webpack_require__(/*! ./util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst parseqs_js_1 = __webpack_require__(/*! ./contrib/parseqs.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseqs.js\");\nconst parseuri_js_1 = __webpack_require__(/*! ./contrib/parseuri.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseuri.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/lib/esm/index.js\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst websocket_constructor_js_1 = __webpack_require__(/*! ./transports/websocket-constructor.js */ \"./node_modules/engine.io-client/build/cjs/transports/websocket-constructor.browser.js\");\nconst debug = (0, debug_1.default)(\"engine.io-client:socket\"); // debug()\nclass Socket extends component_emitter_1.Emitter {\n /**\n * Socket constructor.\n *\n * @param {String|Object} uri - uri or options\n * @param {Object} opts - options\n */\n constructor(uri, opts = {}) {\n super();\n this.binaryType = websocket_constructor_js_1.defaultBinaryType;\n this.writeBuffer = [];\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = null;\n }\n if (uri) {\n uri = (0, parseuri_js_1.parse)(uri);\n opts.hostname = uri.host;\n opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n opts.port = uri.port;\n if (uri.query)\n opts.query = uri.query;\n }\n else if (opts.host) {\n opts.hostname = (0, parseuri_js_1.parse)(opts.host).host;\n }\n (0, util_js_1.installTimerFunctions)(this, opts);\n this.secure =\n null != opts.secure\n ? opts.secure\n : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n if (opts.hostname && !opts.port) {\n // if no port is specified manually, use the protocol default\n opts.port = this.secure ? \"443\" : \"80\";\n }\n this.hostname =\n opts.hostname ||\n (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n this.port =\n opts.port ||\n (typeof location !== \"undefined\" && location.port\n ? location.port\n : this.secure\n ? \"443\"\n : \"80\");\n this.transports = opts.transports || [\n \"polling\",\n \"websocket\",\n \"webtransport\",\n ];\n this.writeBuffer = [];\n this.prevBufferLen = 0;\n this.opts = Object.assign({\n path: \"/engine.io\",\n agent: false,\n withCredentials: false,\n upgrade: true,\n timestampParam: \"t\",\n rememberUpgrade: false,\n addTrailingSlash: true,\n rejectUnauthorized: true,\n perMessageDeflate: {\n threshold: 1024,\n },\n transportOptions: {},\n closeOnBeforeunload: false,\n }, opts);\n this.opts.path =\n this.opts.path.replace(/\\/$/, \"\") +\n (this.opts.addTrailingSlash ? \"/\" : \"\");\n if (typeof this.opts.query === \"string\") {\n this.opts.query = (0, parseqs_js_1.decode)(this.opts.query);\n }\n // set on handshake\n this.id = null;\n this.upgrades = null;\n this.pingInterval = null;\n this.pingTimeout = null;\n // set on heartbeat\n this.pingTimeoutTimer = null;\n if (typeof addEventListener === \"function\") {\n if (this.opts.closeOnBeforeunload) {\n // Firefox closes the connection when the \"beforeunload\" event is emitted but not Chrome. This event listener\n // ensures every browser behaves the same (no \"disconnect\" event at the Socket.IO level when the page is\n // closed/reloaded)\n this.beforeunloadEventListener = () => {\n if (this.transport) {\n // silently close the transport\n this.transport.removeAllListeners();\n this.transport.close();\n }\n };\n addEventListener(\"beforeunload\", this.beforeunloadEventListener, false);\n }\n if (this.hostname !== \"localhost\") {\n this.offlineEventListener = () => {\n this.onClose(\"transport close\", {\n description: \"network connection lost\",\n });\n };\n addEventListener(\"offline\", this.offlineEventListener, false);\n }\n }\n this.open();\n }\n /**\n * Creates transport of the given type.\n *\n * @param {String} name - transport name\n * @return {Transport}\n * @private\n */\n createTransport(name) {\n debug('creating transport \"%s\"', name);\n const query = Object.assign({}, this.opts.query);\n // append engine.io protocol identifier\n query.EIO = engine_io_parser_1.protocol;\n // transport name\n query.transport = name;\n // session id if we already have one\n if (this.id)\n query.sid = this.id;\n const opts = Object.assign({}, this.opts, {\n query,\n socket: this,\n hostname: this.hostname,\n secure: this.secure,\n port: this.port,\n }, this.opts.transportOptions[name]);\n debug(\"options: %j\", opts);\n return new index_js_1.transports[name](opts);\n }\n /**\n * Initializes transport to use and starts probe.\n *\n * @private\n */\n open() {\n let transport;\n if (this.opts.rememberUpgrade &&\n Socket.priorWebsocketSuccess &&\n this.transports.indexOf(\"websocket\") !== -1) {\n transport = \"websocket\";\n }\n else if (0 === this.transports.length) {\n // Emit error on next tick so it can be listened to\n this.setTimeoutFn(() => {\n this.emitReserved(\"error\", \"No transports available\");\n }, 0);\n return;\n }\n else {\n transport = this.transports[0];\n }\n this.readyState = \"opening\";\n // Retry with the next transport if the transport is disabled (jsonp: false)\n try {\n transport = this.createTransport(transport);\n }\n catch (e) {\n debug(\"error while creating transport: %s\", e);\n this.transports.shift();\n this.open();\n return;\n }\n transport.open();\n this.setTransport(transport);\n }\n /**\n * Sets the current transport. Disables the existing one (if any).\n *\n * @private\n */\n setTransport(transport) {\n debug(\"setting transport %s\", transport.name);\n if (this.transport) {\n debug(\"clearing existing transport %s\", this.transport.name);\n this.transport.removeAllListeners();\n }\n // set up transport\n this.transport = transport;\n // set up transport listeners\n transport\n .on(\"drain\", this.onDrain.bind(this))\n .on(\"packet\", this.onPacket.bind(this))\n .on(\"error\", this.onError.bind(this))\n .on(\"close\", (reason) => this.onClose(\"transport close\", reason));\n }\n /**\n * Probes a transport.\n *\n * @param {String} name - transport name\n * @private\n */\n probe(name) {\n debug('probing transport \"%s\"', name);\n let transport = this.createTransport(name);\n let failed = false;\n Socket.priorWebsocketSuccess = false;\n const onTransportOpen = () => {\n if (failed)\n return;\n debug('probe transport \"%s\" opened', name);\n transport.send([{ type: \"ping\", data: \"probe\" }]);\n transport.once(\"packet\", (msg) => {\n if (failed)\n return;\n if (\"pong\" === msg.type && \"probe\" === msg.data) {\n debug('probe transport \"%s\" pong', name);\n this.upgrading = true;\n this.emitReserved(\"upgrading\", transport);\n if (!transport)\n return;\n Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n debug('pausing current transport \"%s\"', this.transport.name);\n this.transport.pause(() => {\n if (failed)\n return;\n if (\"closed\" === this.readyState)\n return;\n debug(\"changing transport and sending upgrade packet\");\n cleanup();\n this.setTransport(transport);\n transport.send([{ type: \"upgrade\" }]);\n this.emitReserved(\"upgrade\", transport);\n transport = null;\n this.upgrading = false;\n this.flush();\n });\n }\n else {\n debug('probe transport \"%s\" failed', name);\n const err = new Error(\"probe error\");\n // @ts-ignore\n err.transport = transport.name;\n this.emitReserved(\"upgradeError\", err);\n }\n });\n };\n function freezeTransport() {\n if (failed)\n return;\n // Any callback called by transport should be ignored since now\n failed = true;\n cleanup();\n transport.close();\n transport = null;\n }\n // Handle any error that happens while probing\n const onerror = (err) => {\n const error = new Error(\"probe error: \" + err);\n // @ts-ignore\n error.transport = transport.name;\n freezeTransport();\n debug('probe transport \"%s\" failed because of error: %s', name, err);\n this.emitReserved(\"upgradeError\", error);\n };\n function onTransportClose() {\n onerror(\"transport closed\");\n }\n // When the socket is closed while we're probing\n function onclose() {\n onerror(\"socket closed\");\n }\n // When the socket is upgraded while we're probing\n function onupgrade(to) {\n if (transport && to.name !== transport.name) {\n debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n freezeTransport();\n }\n }\n // Remove all listeners on the transport and on self\n const cleanup = () => {\n transport.removeListener(\"open\", onTransportOpen);\n transport.removeListener(\"error\", onerror);\n transport.removeListener(\"close\", onTransportClose);\n this.off(\"close\", onclose);\n this.off(\"upgrading\", onupgrade);\n };\n transport.once(\"open\", onTransportOpen);\n transport.once(\"error\", onerror);\n transport.once(\"close\", onTransportClose);\n this.once(\"close\", onclose);\n this.once(\"upgrading\", onupgrade);\n if (this.upgrades.indexOf(\"webtransport\") !== -1 &&\n name !== \"webtransport\") {\n // favor WebTransport\n this.setTimeoutFn(() => {\n if (!failed) {\n transport.open();\n }\n }, 200);\n }\n else {\n transport.open();\n }\n }\n /**\n * Called when connection is deemed open.\n *\n * @private\n */\n onOpen() {\n debug(\"socket open\");\n this.readyState = \"open\";\n Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n this.emitReserved(\"open\");\n this.flush();\n // we check for `readyState` in case an `open`\n // listener already closed the socket\n if (\"open\" === this.readyState && this.opts.upgrade) {\n debug(\"starting upgrade probes\");\n let i = 0;\n const l = this.upgrades.length;\n for (; i < l; i++) {\n this.probe(this.upgrades[i]);\n }\n }\n }\n /**\n * Handles a packet.\n *\n * @private\n */\n onPacket(packet) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n this.emitReserved(\"packet\", packet);\n // Socket is live - any packet counts\n this.emitReserved(\"heartbeat\");\n this.resetPingTimeout();\n switch (packet.type) {\n case \"open\":\n this.onHandshake(JSON.parse(packet.data));\n break;\n case \"ping\":\n this.sendPacket(\"pong\");\n this.emitReserved(\"ping\");\n this.emitReserved(\"pong\");\n break;\n case \"error\":\n const err = new Error(\"server error\");\n // @ts-ignore\n err.code = packet.data;\n this.onError(err);\n break;\n case \"message\":\n this.emitReserved(\"data\", packet.data);\n this.emitReserved(\"message\", packet.data);\n break;\n }\n }\n else {\n debug('packet received with socket readyState \"%s\"', this.readyState);\n }\n }\n /**\n * Called upon handshake completion.\n *\n * @param {Object} data - handshake obj\n * @private\n */\n onHandshake(data) {\n this.emitReserved(\"handshake\", data);\n this.id = data.sid;\n this.transport.query.sid = data.sid;\n this.upgrades = this.filterUpgrades(data.upgrades);\n this.pingInterval = data.pingInterval;\n this.pingTimeout = data.pingTimeout;\n this.maxPayload = data.maxPayload;\n this.onOpen();\n // In case open handler closes socket\n if (\"closed\" === this.readyState)\n return;\n this.resetPingTimeout();\n }\n /**\n * Sets and resets ping timeout timer based on server pings.\n *\n * @private\n */\n resetPingTimeout() {\n this.clearTimeoutFn(this.pingTimeoutTimer);\n this.pingTimeoutTimer = this.setTimeoutFn(() => {\n this.onClose(\"ping timeout\");\n }, this.pingInterval + this.pingTimeout);\n if (this.opts.autoUnref) {\n this.pingTimeoutTimer.unref();\n }\n }\n /**\n * Called on `drain` event\n *\n * @private\n */\n onDrain() {\n this.writeBuffer.splice(0, this.prevBufferLen);\n // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and a nonzero prevBufferLen could cause problems on `drain`\n this.prevBufferLen = 0;\n if (0 === this.writeBuffer.length) {\n this.emitReserved(\"drain\");\n }\n else {\n this.flush();\n }\n }\n /**\n * Flush write buffers.\n *\n * @private\n */\n flush() {\n if (\"closed\" !== this.readyState &&\n this.transport.writable &&\n !this.upgrading &&\n this.writeBuffer.length) {\n const packets = this.getWritablePackets();\n debug(\"flushing %d packets in socket\", packets.length);\n this.transport.send(packets);\n // keep track of current length of writeBuffer\n // splice writeBuffer and callbackBuffer on `drain`\n this.prevBufferLen = packets.length;\n this.emitReserved(\"flush\");\n }\n }\n /**\n * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP\n * long-polling)\n *\n * @private\n */\n getWritablePackets() {\n const shouldCheckPayloadSize = this.maxPayload &&\n this.transport.name === \"polling\" &&\n this.writeBuffer.length > 1;\n if (!shouldCheckPayloadSize) {\n return this.writeBuffer;\n }\n let payloadSize = 1; // first packet type\n for (let i = 0; i < this.writeBuffer.length; i++) {\n const data = this.writeBuffer[i].data;\n if (data) {\n payloadSize += (0, util_js_1.byteLength)(data);\n }\n if (i > 0 && payloadSize > this.maxPayload) {\n debug(\"only send %d out of %d packets\", i, this.writeBuffer.length);\n return this.writeBuffer.slice(0, i);\n }\n payloadSize += 2; // separator + packet type\n }\n debug(\"payload size is %d (max: %d)\", payloadSize, this.maxPayload);\n return this.writeBuffer;\n }\n /**\n * Sends a message.\n *\n * @param {String} msg - message.\n * @param {Object} options.\n * @param {Function} callback function.\n * @return {Socket} for chaining.\n */\n write(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n send(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a packet.\n *\n * @param {String} type: packet type.\n * @param {String} data.\n * @param {Object} options.\n * @param {Function} fn - callback function.\n * @private\n */\n sendPacket(type, data, options, fn) {\n if (\"function\" === typeof data) {\n fn = data;\n data = undefined;\n }\n if (\"function\" === typeof options) {\n fn = options;\n options = null;\n }\n if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n return;\n }\n options = options || {};\n options.compress = false !== options.compress;\n const packet = {\n type: type,\n data: data,\n options: options,\n };\n this.emitReserved(\"packetCreate\", packet);\n this.writeBuffer.push(packet);\n if (fn)\n this.once(\"flush\", fn);\n this.flush();\n }\n /**\n * Closes the connection.\n */\n close() {\n const close = () => {\n this.onClose(\"forced close\");\n debug(\"socket closing - telling transport to close\");\n this.transport.close();\n };\n const cleanupAndClose = () => {\n this.off(\"upgrade\", cleanupAndClose);\n this.off(\"upgradeError\", cleanupAndClose);\n close();\n };\n const waitForUpgrade = () => {\n // wait for upgrade to finish since we can't send packets while pausing a transport\n this.once(\"upgrade\", cleanupAndClose);\n this.once(\"upgradeError\", cleanupAndClose);\n };\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.readyState = \"closing\";\n if (this.writeBuffer.length) {\n this.once(\"drain\", () => {\n if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n });\n }\n else if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n }\n return this;\n }\n /**\n * Called upon transport error\n *\n * @private\n */\n onError(err) {\n debug(\"socket error %j\", err);\n Socket.priorWebsocketSuccess = false;\n this.emitReserved(\"error\", err);\n this.onClose(\"transport error\", err);\n }\n /**\n * Called upon transport close.\n *\n * @private\n */\n onClose(reason, description) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n debug('socket close with reason: \"%s\"', reason);\n // clear timers\n this.clearTimeoutFn(this.pingTimeoutTimer);\n // stop event from firing again for transport\n this.transport.removeAllListeners(\"close\");\n // ensure transport won't stay open\n this.transport.close();\n // ignore further transport communication\n this.transport.removeAllListeners();\n if (typeof removeEventListener === \"function\") {\n removeEventListener(\"beforeunload\", this.beforeunloadEventListener, false);\n removeEventListener(\"offline\", this.offlineEventListener, false);\n }\n // set ready state\n this.readyState = \"closed\";\n // clear session id\n this.id = null;\n // emit close event\n this.emitReserved(\"close\", reason, description);\n // clean buffers after, so users can still\n // grab the buffers on `close` event\n this.writeBuffer = [];\n this.prevBufferLen = 0;\n }\n }\n /**\n * Filters upgrades, returning only those matching client transports.\n *\n * @param {Array} upgrades - server upgrades\n * @private\n */\n filterUpgrades(upgrades) {\n const filteredUpgrades = [];\n let i = 0;\n const j = upgrades.length;\n for (; i < j; i++) {\n if (~this.transports.indexOf(upgrades[i]))\n filteredUpgrades.push(upgrades[i]);\n }\n return filteredUpgrades;\n }\n}\nexports.Socket = Socket;\nSocket.protocol = engine_io_parser_1.protocol;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/socket.js?");
|
|
527
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Socket = exports.SocketWithUpgrade = exports.SocketWithoutUpgrade = void 0;\nconst index_js_1 = __webpack_require__(/*! ./transports/index.js */ \"./node_modules/engine.io-client/build/cjs/transports/index.js\");\nconst util_js_1 = __webpack_require__(/*! ./util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst parseqs_js_1 = __webpack_require__(/*! ./contrib/parseqs.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseqs.js\");\nconst parseuri_js_1 = __webpack_require__(/*! ./contrib/parseuri.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseuri.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst globals_node_js_1 = __webpack_require__(/*! ./globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:socket\"); // debug()\nconst withEventListeners = typeof addEventListener === \"function\" &&\n typeof removeEventListener === \"function\";\nconst OFFLINE_EVENT_LISTENERS = [];\nif (withEventListeners) {\n // within a ServiceWorker, any event handler for the 'offline' event must be added on the initial evaluation of the\n // script, so we create one single event listener here which will forward the event to the socket instances\n addEventListener(\"offline\", () => {\n debug(\"closing %d connection(s) because the network was lost\", OFFLINE_EVENT_LISTENERS.length);\n OFFLINE_EVENT_LISTENERS.forEach((listener) => listener());\n }, false);\n}\n/**\n * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established\n * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.\n *\n * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that\n * successfully establishes the connection.\n *\n * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.\n *\n * @example\n * import { SocketWithoutUpgrade, WebSocket } from \"engine.io-client\";\n *\n * const socket = new SocketWithoutUpgrade({\n * transports: [WebSocket]\n * });\n *\n * socket.on(\"open\", () => {\n * socket.send(\"hello\");\n * });\n *\n * @see SocketWithUpgrade\n * @see Socket\n */\nclass SocketWithoutUpgrade extends component_emitter_1.Emitter {\n /**\n * Socket constructor.\n *\n * @param {String|Object} uri - uri or options\n * @param {Object} opts - options\n */\n constructor(uri, opts) {\n super();\n this.binaryType = globals_node_js_1.defaultBinaryType;\n this.writeBuffer = [];\n this._prevBufferLen = 0;\n this._pingInterval = -1;\n this._pingTimeout = -1;\n this._maxPayload = -1;\n /**\n * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the\n * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked.\n */\n this._pingTimeoutTime = Infinity;\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = null;\n }\n if (uri) {\n const parsedUri = (0, parseuri_js_1.parse)(uri);\n opts.hostname = parsedUri.host;\n opts.secure =\n parsedUri.protocol === \"https\" || parsedUri.protocol === \"wss\";\n opts.port = parsedUri.port;\n if (parsedUri.query)\n opts.query = parsedUri.query;\n }\n else if (opts.host) {\n opts.hostname = (0, parseuri_js_1.parse)(opts.host).host;\n }\n (0, util_js_1.installTimerFunctions)(this, opts);\n this.secure =\n null != opts.secure\n ? opts.secure\n : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n if (opts.hostname && !opts.port) {\n // if no port is specified manually, use the protocol default\n opts.port = this.secure ? \"443\" : \"80\";\n }\n this.hostname =\n opts.hostname ||\n (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n this.port =\n opts.port ||\n (typeof location !== \"undefined\" && location.port\n ? location.port\n : this.secure\n ? \"443\"\n : \"80\");\n this.transports = [];\n this._transportsByName = {};\n opts.transports.forEach((t) => {\n const transportName = t.prototype.name;\n this.transports.push(transportName);\n this._transportsByName[transportName] = t;\n });\n this.opts = Object.assign({\n path: \"/engine.io\",\n agent: false,\n withCredentials: false,\n upgrade: true,\n timestampParam: \"t\",\n rememberUpgrade: false,\n addTrailingSlash: true,\n rejectUnauthorized: true,\n perMessageDeflate: {\n threshold: 1024,\n },\n transportOptions: {},\n closeOnBeforeunload: false,\n }, opts);\n this.opts.path =\n this.opts.path.replace(/\\/$/, \"\") +\n (this.opts.addTrailingSlash ? \"/\" : \"\");\n if (typeof this.opts.query === \"string\") {\n this.opts.query = (0, parseqs_js_1.decode)(this.opts.query);\n }\n if (withEventListeners) {\n if (this.opts.closeOnBeforeunload) {\n // Firefox closes the connection when the \"beforeunload\" event is emitted but not Chrome. This event listener\n // ensures every browser behaves the same (no \"disconnect\" event at the Socket.IO level when the page is\n // closed/reloaded)\n this._beforeunloadEventListener = () => {\n if (this.transport) {\n // silently close the transport\n this.transport.removeAllListeners();\n this.transport.close();\n }\n };\n addEventListener(\"beforeunload\", this._beforeunloadEventListener, false);\n }\n if (this.hostname !== \"localhost\") {\n debug(\"adding listener for the 'offline' event\");\n this._offlineEventListener = () => {\n this._onClose(\"transport close\", {\n description: \"network connection lost\",\n });\n };\n OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener);\n }\n }\n if (this.opts.withCredentials) {\n this._cookieJar = (0, globals_node_js_1.createCookieJar)();\n }\n this._open();\n }\n /**\n * Creates transport of the given type.\n *\n * @param {String} name - transport name\n * @return {Transport}\n * @private\n */\n createTransport(name) {\n debug('creating transport \"%s\"', name);\n const query = Object.assign({}, this.opts.query);\n // append engine.io protocol identifier\n query.EIO = engine_io_parser_1.protocol;\n // transport name\n query.transport = name;\n // session id if we already have one\n if (this.id)\n query.sid = this.id;\n const opts = Object.assign({}, this.opts, {\n query,\n socket: this,\n hostname: this.hostname,\n secure: this.secure,\n port: this.port,\n }, this.opts.transportOptions[name]);\n debug(\"options: %j\", opts);\n return new this._transportsByName[name](opts);\n }\n /**\n * Initializes transport to use and starts probe.\n *\n * @private\n */\n _open() {\n if (this.transports.length === 0) {\n // Emit error on next tick so it can be listened to\n this.setTimeoutFn(() => {\n this.emitReserved(\"error\", \"No transports available\");\n }, 0);\n return;\n }\n const transportName = this.opts.rememberUpgrade &&\n SocketWithoutUpgrade.priorWebsocketSuccess &&\n this.transports.indexOf(\"websocket\") !== -1\n ? \"websocket\"\n : this.transports[0];\n this.readyState = \"opening\";\n const transport = this.createTransport(transportName);\n transport.open();\n this.setTransport(transport);\n }\n /**\n * Sets the current transport. Disables the existing one (if any).\n *\n * @private\n */\n setTransport(transport) {\n debug(\"setting transport %s\", transport.name);\n if (this.transport) {\n debug(\"clearing existing transport %s\", this.transport.name);\n this.transport.removeAllListeners();\n }\n // set up transport\n this.transport = transport;\n // set up transport listeners\n transport\n .on(\"drain\", this._onDrain.bind(this))\n .on(\"packet\", this._onPacket.bind(this))\n .on(\"error\", this._onError.bind(this))\n .on(\"close\", (reason) => this._onClose(\"transport close\", reason));\n }\n /**\n * Called when connection is deemed open.\n *\n * @private\n */\n onOpen() {\n debug(\"socket open\");\n this.readyState = \"open\";\n SocketWithoutUpgrade.priorWebsocketSuccess =\n \"websocket\" === this.transport.name;\n this.emitReserved(\"open\");\n this.flush();\n }\n /**\n * Handles a packet.\n *\n * @private\n */\n _onPacket(packet) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n debug('socket receive: type \"%s\", data \"%s\"', packet.type, packet.data);\n this.emitReserved(\"packet\", packet);\n // Socket is live - any packet counts\n this.emitReserved(\"heartbeat\");\n switch (packet.type) {\n case \"open\":\n this.onHandshake(JSON.parse(packet.data));\n break;\n case \"ping\":\n this._sendPacket(\"pong\");\n this.emitReserved(\"ping\");\n this.emitReserved(\"pong\");\n this._resetPingTimeout();\n break;\n case \"error\":\n const err = new Error(\"server error\");\n // @ts-ignore\n err.code = packet.data;\n this._onError(err);\n break;\n case \"message\":\n this.emitReserved(\"data\", packet.data);\n this.emitReserved(\"message\", packet.data);\n break;\n }\n }\n else {\n debug('packet received with socket readyState \"%s\"', this.readyState);\n }\n }\n /**\n * Called upon handshake completion.\n *\n * @param {Object} data - handshake obj\n * @private\n */\n onHandshake(data) {\n this.emitReserved(\"handshake\", data);\n this.id = data.sid;\n this.transport.query.sid = data.sid;\n this._pingInterval = data.pingInterval;\n this._pingTimeout = data.pingTimeout;\n this._maxPayload = data.maxPayload;\n this.onOpen();\n // In case open handler closes socket\n if (\"closed\" === this.readyState)\n return;\n this._resetPingTimeout();\n }\n /**\n * Sets and resets ping timeout timer based on server pings.\n *\n * @private\n */\n _resetPingTimeout() {\n this.clearTimeoutFn(this._pingTimeoutTimer);\n const delay = this._pingInterval + this._pingTimeout;\n this._pingTimeoutTime = Date.now() + delay;\n this._pingTimeoutTimer = this.setTimeoutFn(() => {\n this._onClose(\"ping timeout\");\n }, delay);\n if (this.opts.autoUnref) {\n this._pingTimeoutTimer.unref();\n }\n }\n /**\n * Called on `drain` event\n *\n * @private\n */\n _onDrain() {\n this.writeBuffer.splice(0, this._prevBufferLen);\n // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and a nonzero prevBufferLen could cause problems on `drain`\n this._prevBufferLen = 0;\n if (0 === this.writeBuffer.length) {\n this.emitReserved(\"drain\");\n }\n else {\n this.flush();\n }\n }\n /**\n * Flush write buffers.\n *\n * @private\n */\n flush() {\n if (\"closed\" !== this.readyState &&\n this.transport.writable &&\n !this.upgrading &&\n this.writeBuffer.length) {\n const packets = this._getWritablePackets();\n debug(\"flushing %d packets in socket\", packets.length);\n this.transport.send(packets);\n // keep track of current length of writeBuffer\n // splice writeBuffer and callbackBuffer on `drain`\n this._prevBufferLen = packets.length;\n this.emitReserved(\"flush\");\n }\n }\n /**\n * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP\n * long-polling)\n *\n * @private\n */\n _getWritablePackets() {\n const shouldCheckPayloadSize = this._maxPayload &&\n this.transport.name === \"polling\" &&\n this.writeBuffer.length > 1;\n if (!shouldCheckPayloadSize) {\n return this.writeBuffer;\n }\n let payloadSize = 1; // first packet type\n for (let i = 0; i < this.writeBuffer.length; i++) {\n const data = this.writeBuffer[i].data;\n if (data) {\n payloadSize += (0, util_js_1.byteLength)(data);\n }\n if (i > 0 && payloadSize > this._maxPayload) {\n debug(\"only send %d out of %d packets\", i, this.writeBuffer.length);\n return this.writeBuffer.slice(0, i);\n }\n payloadSize += 2; // separator + packet type\n }\n debug(\"payload size is %d (max: %d)\", payloadSize, this._maxPayload);\n return this.writeBuffer;\n }\n /**\n * Checks whether the heartbeat timer has expired but the socket has not yet been notified.\n *\n * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the\n * `write()` method then the message would not be buffered by the Socket.IO client.\n *\n * @return {boolean}\n * @private\n */\n /* private */ _hasPingExpired() {\n if (!this._pingTimeoutTime)\n return true;\n const hasExpired = Date.now() > this._pingTimeoutTime;\n if (hasExpired) {\n debug(\"throttled timer detected, scheduling connection close\");\n this._pingTimeoutTime = 0;\n (0, globals_node_js_1.nextTick)(() => {\n this._onClose(\"ping timeout\");\n }, this.setTimeoutFn);\n }\n return hasExpired;\n }\n /**\n * Sends a message.\n *\n * @param {String} msg - message.\n * @param {Object} options.\n * @param {Function} fn - callback function.\n * @return {Socket} for chaining.\n */\n write(msg, options, fn) {\n this._sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a message. Alias of {@link Socket#write}.\n *\n * @param {String} msg - message.\n * @param {Object} options.\n * @param {Function} fn - callback function.\n * @return {Socket} for chaining.\n */\n send(msg, options, fn) {\n this._sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a packet.\n *\n * @param {String} type: packet type.\n * @param {String} data.\n * @param {Object} options.\n * @param {Function} fn - callback function.\n * @private\n */\n _sendPacket(type, data, options, fn) {\n if (\"function\" === typeof data) {\n fn = data;\n data = undefined;\n }\n if (\"function\" === typeof options) {\n fn = options;\n options = null;\n }\n if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n return;\n }\n options = options || {};\n options.compress = false !== options.compress;\n const packet = {\n type: type,\n data: data,\n options: options,\n };\n this.emitReserved(\"packetCreate\", packet);\n this.writeBuffer.push(packet);\n if (fn)\n this.once(\"flush\", fn);\n this.flush();\n }\n /**\n * Closes the connection.\n */\n close() {\n const close = () => {\n this._onClose(\"forced close\");\n debug(\"socket closing - telling transport to close\");\n this.transport.close();\n };\n const cleanupAndClose = () => {\n this.off(\"upgrade\", cleanupAndClose);\n this.off(\"upgradeError\", cleanupAndClose);\n close();\n };\n const waitForUpgrade = () => {\n // wait for upgrade to finish since we can't send packets while pausing a transport\n this.once(\"upgrade\", cleanupAndClose);\n this.once(\"upgradeError\", cleanupAndClose);\n };\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.readyState = \"closing\";\n if (this.writeBuffer.length) {\n this.once(\"drain\", () => {\n if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n });\n }\n else if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n }\n return this;\n }\n /**\n * Called upon transport error\n *\n * @private\n */\n _onError(err) {\n debug(\"socket error %j\", err);\n SocketWithoutUpgrade.priorWebsocketSuccess = false;\n if (this.opts.tryAllTransports &&\n this.transports.length > 1 &&\n this.readyState === \"opening\") {\n debug(\"trying next transport\");\n this.transports.shift();\n return this._open();\n }\n this.emitReserved(\"error\", err);\n this._onClose(\"transport error\", err);\n }\n /**\n * Called upon transport close.\n *\n * @private\n */\n _onClose(reason, description) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n debug('socket close with reason: \"%s\"', reason);\n // clear timers\n this.clearTimeoutFn(this._pingTimeoutTimer);\n // stop event from firing again for transport\n this.transport.removeAllListeners(\"close\");\n // ensure transport won't stay open\n this.transport.close();\n // ignore further transport communication\n this.transport.removeAllListeners();\n if (withEventListeners) {\n if (this._beforeunloadEventListener) {\n removeEventListener(\"beforeunload\", this._beforeunloadEventListener, false);\n }\n if (this._offlineEventListener) {\n const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);\n if (i !== -1) {\n debug(\"removing listener for the 'offline' event\");\n OFFLINE_EVENT_LISTENERS.splice(i, 1);\n }\n }\n }\n // set ready state\n this.readyState = \"closed\";\n // clear session id\n this.id = null;\n // emit close event\n this.emitReserved(\"close\", reason, description);\n // clean buffers after, so users can still\n // grab the buffers on `close` event\n this.writeBuffer = [];\n this._prevBufferLen = 0;\n }\n }\n}\nexports.SocketWithoutUpgrade = SocketWithoutUpgrade;\nSocketWithoutUpgrade.protocol = engine_io_parser_1.protocol;\n/**\n * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established\n * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.\n *\n * This class comes with an upgrade mechanism, which means that once the connection is established with the first\n * low-level transport, it will try to upgrade to a better transport.\n *\n * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.\n *\n * @example\n * import { SocketWithUpgrade, WebSocket } from \"engine.io-client\";\n *\n * const socket = new SocketWithUpgrade({\n * transports: [WebSocket]\n * });\n *\n * socket.on(\"open\", () => {\n * socket.send(\"hello\");\n * });\n *\n * @see SocketWithoutUpgrade\n * @see Socket\n */\nclass SocketWithUpgrade extends SocketWithoutUpgrade {\n constructor() {\n super(...arguments);\n this._upgrades = [];\n }\n onOpen() {\n super.onOpen();\n if (\"open\" === this.readyState && this.opts.upgrade) {\n debug(\"starting upgrade probes\");\n for (let i = 0; i < this._upgrades.length; i++) {\n this._probe(this._upgrades[i]);\n }\n }\n }\n /**\n * Probes a transport.\n *\n * @param {String} name - transport name\n * @private\n */\n _probe(name) {\n debug('probing transport \"%s\"', name);\n let transport = this.createTransport(name);\n let failed = false;\n SocketWithoutUpgrade.priorWebsocketSuccess = false;\n const onTransportOpen = () => {\n if (failed)\n return;\n debug('probe transport \"%s\" opened', name);\n transport.send([{ type: \"ping\", data: \"probe\" }]);\n transport.once(\"packet\", (msg) => {\n if (failed)\n return;\n if (\"pong\" === msg.type && \"probe\" === msg.data) {\n debug('probe transport \"%s\" pong', name);\n this.upgrading = true;\n this.emitReserved(\"upgrading\", transport);\n if (!transport)\n return;\n SocketWithoutUpgrade.priorWebsocketSuccess =\n \"websocket\" === transport.name;\n debug('pausing current transport \"%s\"', this.transport.name);\n this.transport.pause(() => {\n if (failed)\n return;\n if (\"closed\" === this.readyState)\n return;\n debug(\"changing transport and sending upgrade packet\");\n cleanup();\n this.setTransport(transport);\n transport.send([{ type: \"upgrade\" }]);\n this.emitReserved(\"upgrade\", transport);\n transport = null;\n this.upgrading = false;\n this.flush();\n });\n }\n else {\n debug('probe transport \"%s\" failed', name);\n const err = new Error(\"probe error\");\n // @ts-ignore\n err.transport = transport.name;\n this.emitReserved(\"upgradeError\", err);\n }\n });\n };\n function freezeTransport() {\n if (failed)\n return;\n // Any callback called by transport should be ignored since now\n failed = true;\n cleanup();\n transport.close();\n transport = null;\n }\n // Handle any error that happens while probing\n const onerror = (err) => {\n const error = new Error(\"probe error: \" + err);\n // @ts-ignore\n error.transport = transport.name;\n freezeTransport();\n debug('probe transport \"%s\" failed because of error: %s', name, err);\n this.emitReserved(\"upgradeError\", error);\n };\n function onTransportClose() {\n onerror(\"transport closed\");\n }\n // When the socket is closed while we're probing\n function onclose() {\n onerror(\"socket closed\");\n }\n // When the socket is upgraded while we're probing\n function onupgrade(to) {\n if (transport && to.name !== transport.name) {\n debug('\"%s\" works - aborting \"%s\"', to.name, transport.name);\n freezeTransport();\n }\n }\n // Remove all listeners on the transport and on self\n const cleanup = () => {\n transport.removeListener(\"open\", onTransportOpen);\n transport.removeListener(\"error\", onerror);\n transport.removeListener(\"close\", onTransportClose);\n this.off(\"close\", onclose);\n this.off(\"upgrading\", onupgrade);\n };\n transport.once(\"open\", onTransportOpen);\n transport.once(\"error\", onerror);\n transport.once(\"close\", onTransportClose);\n this.once(\"close\", onclose);\n this.once(\"upgrading\", onupgrade);\n if (this._upgrades.indexOf(\"webtransport\") !== -1 &&\n name !== \"webtransport\") {\n // favor WebTransport\n this.setTimeoutFn(() => {\n if (!failed) {\n transport.open();\n }\n }, 200);\n }\n else {\n transport.open();\n }\n }\n onHandshake(data) {\n this._upgrades = this._filterUpgrades(data.upgrades);\n super.onHandshake(data);\n }\n /**\n * Filters upgrades, returning only those matching client transports.\n *\n * @param {Array} upgrades - server upgrades\n * @private\n */\n _filterUpgrades(upgrades) {\n const filteredUpgrades = [];\n for (let i = 0; i < upgrades.length; i++) {\n if (~this.transports.indexOf(upgrades[i]))\n filteredUpgrades.push(upgrades[i]);\n }\n return filteredUpgrades;\n }\n}\nexports.SocketWithUpgrade = SocketWithUpgrade;\n/**\n * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established\n * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.\n *\n * This class comes with an upgrade mechanism, which means that once the connection is established with the first\n * low-level transport, it will try to upgrade to a better transport.\n *\n * @example\n * import { Socket } from \"engine.io-client\";\n *\n * const socket = new Socket();\n *\n * socket.on(\"open\", () => {\n * socket.send(\"hello\");\n * });\n *\n * @see SocketWithoutUpgrade\n * @see SocketWithUpgrade\n */\nclass Socket extends SocketWithUpgrade {\n constructor(uri, opts = {}) {\n const o = typeof uri === \"object\" ? uri : opts;\n if (!o.transports ||\n (o.transports && typeof o.transports[0] === \"string\")) {\n o.transports = (o.transports || [\"polling\", \"websocket\", \"webtransport\"])\n .map((transportName) => index_js_1.transports[transportName])\n .filter((t) => !!t);\n }\n super(uri, o);\n }\n}\nexports.Socket = Socket;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/socket.js?");
|
|
539
528
|
|
|
540
529
|
/***/ }),
|
|
541
530
|
|
|
@@ -546,7 +535,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
546
535
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
547
536
|
|
|
548
537
|
"use strict";
|
|
549
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Transport = exports.TransportError = void 0;\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/
|
|
538
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Transport = exports.TransportError = void 0;\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst util_js_1 = __webpack_require__(/*! ./util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst parseqs_js_1 = __webpack_require__(/*! ./contrib/parseqs.js */ \"./node_modules/engine.io-client/build/cjs/contrib/parseqs.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:transport\"); // debug()\nclass TransportError extends Error {\n constructor(reason, description, context) {\n super(reason);\n this.description = description;\n this.context = context;\n this.type = \"TransportError\";\n }\n}\nexports.TransportError = TransportError;\nclass Transport extends component_emitter_1.Emitter {\n /**\n * Transport abstract constructor.\n *\n * @param {Object} opts - options\n * @protected\n */\n constructor(opts) {\n super();\n this.writable = false;\n (0, util_js_1.installTimerFunctions)(this, opts);\n this.opts = opts;\n this.query = opts.query;\n this.socket = opts.socket;\n this.supportsBinary = !opts.forceBase64;\n }\n /**\n * Emits an error.\n *\n * @param {String} reason\n * @param description\n * @param context - the error context\n * @return {Transport} for chaining\n * @protected\n */\n onError(reason, description, context) {\n super.emitReserved(\"error\", new TransportError(reason, description, context));\n return this;\n }\n /**\n * Opens the transport.\n */\n open() {\n this.readyState = \"opening\";\n this.doOpen();\n return this;\n }\n /**\n * Closes the transport.\n */\n close() {\n if (this.readyState === \"opening\" || this.readyState === \"open\") {\n this.doClose();\n this.onClose();\n }\n return this;\n }\n /**\n * Sends multiple packets.\n *\n * @param {Array} packets\n */\n send(packets) {\n if (this.readyState === \"open\") {\n this.write(packets);\n }\n else {\n // this might happen if the transport was silently closed in the beforeunload event handler\n debug(\"transport is not open, discarding packets\");\n }\n }\n /**\n * Called upon open\n *\n * @protected\n */\n onOpen() {\n this.readyState = \"open\";\n this.writable = true;\n super.emitReserved(\"open\");\n }\n /**\n * Called with data.\n *\n * @param {String} data\n * @protected\n */\n onData(data) {\n const packet = (0, engine_io_parser_1.decodePacket)(data, this.socket.binaryType);\n this.onPacket(packet);\n }\n /**\n * Called with a decoded packet.\n *\n * @protected\n */\n onPacket(packet) {\n super.emitReserved(\"packet\", packet);\n }\n /**\n * Called upon close.\n *\n * @protected\n */\n onClose(details) {\n this.readyState = \"closed\";\n super.emitReserved(\"close\", details);\n }\n /**\n * Pauses the transport, in order not to lose packets during an upgrade.\n *\n * @param onPause\n */\n pause(onPause) { }\n createUri(schema, query = {}) {\n return (schema +\n \"://\" +\n this._hostname() +\n this._port() +\n this.opts.path +\n this._query(query));\n }\n _hostname() {\n const hostname = this.opts.hostname;\n return hostname.indexOf(\":\") === -1 ? hostname : \"[\" + hostname + \"]\";\n }\n _port() {\n if (this.opts.port &&\n ((this.opts.secure && Number(this.opts.port !== 443)) ||\n (!this.opts.secure && Number(this.opts.port) !== 80))) {\n return \":\" + this.opts.port;\n }\n else {\n return \"\";\n }\n }\n _query(query) {\n const encodedQuery = (0, parseqs_js_1.encode)(query);\n return encodedQuery.length ? \"?\" + encodedQuery : \"\";\n }\n}\nexports.Transport = Transport;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transport.js?");
|
|
550
539
|
|
|
551
540
|
/***/ }),
|
|
552
541
|
|
|
@@ -557,29 +546,40 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
557
546
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
558
547
|
|
|
559
548
|
"use strict";
|
|
560
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.transports = void 0;\nconst
|
|
549
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.transports = void 0;\nconst polling_xhr_node_js_1 = __webpack_require__(/*! ./polling-xhr.node.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js\");\nconst websocket_node_js_1 = __webpack_require__(/*! ./websocket.node.js */ \"./node_modules/engine.io-client/build/cjs/transports/websocket.js\");\nconst webtransport_js_1 = __webpack_require__(/*! ./webtransport.js */ \"./node_modules/engine.io-client/build/cjs/transports/webtransport.js\");\nexports.transports = {\n websocket: websocket_node_js_1.WS,\n webtransport: webtransport_js_1.WT,\n polling: polling_xhr_node_js_1.XHR,\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/index.js?");
|
|
561
550
|
|
|
562
551
|
/***/ }),
|
|
563
552
|
|
|
564
|
-
/***/ "./node_modules/engine.io-client/build/cjs/transports/polling.js":
|
|
565
|
-
|
|
566
|
-
!*** ./node_modules/engine.io-client/build/cjs/transports/polling.js ***!
|
|
567
|
-
|
|
553
|
+
/***/ "./node_modules/engine.io-client/build/cjs/transports/polling-fetch.js":
|
|
554
|
+
/*!*****************************************************************************!*\
|
|
555
|
+
!*** ./node_modules/engine.io-client/build/cjs/transports/polling-fetch.js ***!
|
|
556
|
+
\*****************************************************************************/
|
|
557
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
558
|
+
|
|
559
|
+
"use strict";
|
|
560
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Fetch = void 0;\nconst polling_js_1 = __webpack_require__(/*! ./polling.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling.js\");\n/**\n * HTTP long-polling based on the built-in `fetch()` method.\n *\n * Usage: browser, Node.js (since v18), Deno, Bun\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch\n * @see https://caniuse.com/fetch\n * @see https://nodejs.org/api/globals.html#fetch\n */\nclass Fetch extends polling_js_1.Polling {\n doPoll() {\n this._fetch()\n .then((res) => {\n if (!res.ok) {\n return this.onError(\"fetch read error\", res.status, res);\n }\n res.text().then((data) => this.onData(data));\n })\n .catch((err) => {\n this.onError(\"fetch read error\", err);\n });\n }\n doWrite(data, callback) {\n this._fetch(data)\n .then((res) => {\n if (!res.ok) {\n return this.onError(\"fetch write error\", res.status, res);\n }\n callback();\n })\n .catch((err) => {\n this.onError(\"fetch write error\", err);\n });\n }\n _fetch(data) {\n var _a;\n const isPost = data !== undefined;\n const headers = new Headers(this.opts.extraHeaders);\n if (isPost) {\n headers.set(\"content-type\", \"text/plain;charset=UTF-8\");\n }\n (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.appendCookies(headers);\n return fetch(this.uri(), {\n method: isPost ? \"POST\" : \"GET\",\n body: isPost ? data : null,\n headers,\n credentials: this.opts.withCredentials ? \"include\" : \"omit\",\n }).then((res) => {\n var _a;\n // @ts-ignore getSetCookie() was added in Node.js v19.7.0\n (_a = this.socket._cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(res.headers.getSetCookie());\n return res;\n });\n }\n}\nexports.Fetch = Fetch;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/polling-fetch.js?");
|
|
561
|
+
|
|
562
|
+
/***/ }),
|
|
563
|
+
|
|
564
|
+
/***/ "./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js":
|
|
565
|
+
/*!***************************************************************************!*\
|
|
566
|
+
!*** ./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js ***!
|
|
567
|
+
\***************************************************************************/
|
|
568
568
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
569
569
|
|
|
570
570
|
"use strict";
|
|
571
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Request = exports.Polling = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst yeast_js_1 = __webpack_require__(/*! ../contrib/yeast.js */ \"./node_modules/engine.io-client/build/cjs/contrib/yeast.js\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst xmlhttprequest_js_1 = __webpack_require__(/*! ./xmlhttprequest.js */ \"./node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/lib/esm/index.js\");\nconst util_js_1 = __webpack_require__(/*! ../util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst globalThis_js_1 = __webpack_require__(/*! ../globalThis.js */ \"./node_modules/engine.io-client/build/cjs/globalThis.browser.js\");\nconst debug = (0, debug_1.default)(\"engine.io-client:polling\"); // debug()\nfunction empty() { }\nconst hasXHR2 = (function () {\n const xhr = new xmlhttprequest_js_1.XHR({\n xdomain: false,\n });\n return null != xhr.responseType;\n})();\nclass Polling extends transport_js_1.Transport {\n /**\n * XHR Polling constructor.\n *\n * @param {Object} opts\n * @package\n */\n constructor(opts) {\n super(opts);\n this.polling = false;\n if (typeof location !== \"undefined\") {\n const isSSL = \"https:\" === location.protocol;\n let port = location.port;\n // some user agents have empty `location.port`\n if (!port) {\n port = isSSL ? \"443\" : \"80\";\n }\n this.xd =\n (typeof location !== \"undefined\" &&\n opts.hostname !== location.hostname) ||\n port !== opts.port;\n }\n /**\n * XHR supports binary\n */\n const forceBase64 = opts && opts.forceBase64;\n this.supportsBinary = hasXHR2 && !forceBase64;\n if (this.opts.withCredentials) {\n this.cookieJar = (0, xmlhttprequest_js_1.createCookieJar)();\n }\n }\n get name() {\n return \"polling\";\n }\n /**\n * Opens the socket (triggers polling). We write a PING message to determine\n * when the transport is open.\n *\n * @protected\n */\n doOpen() {\n this.poll();\n }\n /**\n * Pauses polling.\n *\n * @param {Function} onPause - callback upon buffers are flushed and transport is paused\n * @package\n */\n pause(onPause) {\n this.readyState = \"pausing\";\n const pause = () => {\n debug(\"paused\");\n this.readyState = \"paused\";\n onPause();\n };\n if (this.polling || !this.writable) {\n let total = 0;\n if (this.polling) {\n debug(\"we are currently polling - waiting to pause\");\n total++;\n this.once(\"pollComplete\", function () {\n debug(\"pre-pause polling complete\");\n --total || pause();\n });\n }\n if (!this.writable) {\n debug(\"we are currently writing - waiting to pause\");\n total++;\n this.once(\"drain\", function () {\n debug(\"pre-pause writing complete\");\n --total || pause();\n });\n }\n }\n else {\n pause();\n }\n }\n /**\n * Starts polling cycle.\n *\n * @private\n */\n poll() {\n debug(\"polling\");\n this.polling = true;\n this.doPoll();\n this.emitReserved(\"poll\");\n }\n /**\n * Overloads onData to detect payloads.\n *\n * @protected\n */\n onData(data) {\n debug(\"polling got data %s\", data);\n const callback = (packet) => {\n // if its the first message we consider the transport open\n if (\"opening\" === this.readyState && packet.type === \"open\") {\n this.onOpen();\n }\n // if its a close packet, we close the ongoing requests\n if (\"close\" === packet.type) {\n this.onClose({ description: \"transport closed by the server\" });\n return false;\n }\n // otherwise bypass onData and handle the message\n this.onPacket(packet);\n };\n // decode payload\n (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback);\n // if an event did not trigger closing\n if (\"closed\" !== this.readyState) {\n // if we got data we're not polling\n this.polling = false;\n this.emitReserved(\"pollComplete\");\n if (\"open\" === this.readyState) {\n this.poll();\n }\n else {\n debug('ignoring poll - transport state \"%s\"', this.readyState);\n }\n }\n }\n /**\n * For polling, send a close packet.\n *\n * @protected\n */\n doClose() {\n const close = () => {\n debug(\"writing close packet\");\n this.write([{ type: \"close\" }]);\n };\n if (\"open\" === this.readyState) {\n debug(\"transport open - closing\");\n close();\n }\n else {\n // in case we're trying to close while\n // handshaking is in progress (GH-164)\n debug(\"transport not open - deferring close\");\n this.once(\"open\", close);\n }\n }\n /**\n * Writes a packets payload.\n *\n * @param {Array} packets - data packets\n * @protected\n */\n write(packets) {\n this.writable = false;\n (0, engine_io_parser_1.encodePayload)(packets, (data) => {\n this.doWrite(data, () => {\n this.writable = true;\n this.emitReserved(\"drain\");\n });\n });\n }\n /**\n * Generates uri for connection.\n *\n * @private\n */\n uri() {\n const schema = this.opts.secure ? \"https\" : \"http\";\n const query = this.query || {};\n // cache busting is forced\n if (false !== this.opts.timestampRequests) {\n query[this.opts.timestampParam] = (0, yeast_js_1.yeast)();\n }\n if (!this.supportsBinary && !query.sid) {\n query.b64 = 1;\n }\n return this.createUri(schema, query);\n }\n /**\n * Creates a request.\n *\n * @param {String} method\n * @private\n */\n request(opts = {}) {\n Object.assign(opts, { xd: this.xd, cookieJar: this.cookieJar }, this.opts);\n return new Request(this.uri(), opts);\n }\n /**\n * Sends data.\n *\n * @param {String} data to send.\n * @param {Function} called upon flush.\n * @private\n */\n doWrite(data, fn) {\n const req = this.request({\n method: \"POST\",\n data: data,\n });\n req.on(\"success\", fn);\n req.on(\"error\", (xhrStatus, context) => {\n this.onError(\"xhr post error\", xhrStatus, context);\n });\n }\n /**\n * Starts a poll cycle.\n *\n * @private\n */\n doPoll() {\n debug(\"xhr poll\");\n const req = this.request();\n req.on(\"data\", this.onData.bind(this));\n req.on(\"error\", (xhrStatus, context) => {\n this.onError(\"xhr poll error\", xhrStatus, context);\n });\n this.pollXhr = req;\n }\n}\nexports.Polling = Polling;\nclass Request extends component_emitter_1.Emitter {\n /**\n * Request constructor\n *\n * @param {Object} options\n * @package\n */\n constructor(uri, opts) {\n super();\n (0, util_js_1.installTimerFunctions)(this, opts);\n this.opts = opts;\n this.method = opts.method || \"GET\";\n this.uri = uri;\n this.data = undefined !== opts.data ? opts.data : null;\n this.create();\n }\n /**\n * Creates the XHR object and sends the request.\n *\n * @private\n */\n create() {\n var _a;\n const opts = (0, util_js_1.pick)(this.opts, \"agent\", \"pfx\", \"key\", \"passphrase\", \"cert\", \"ca\", \"ciphers\", \"rejectUnauthorized\", \"autoUnref\");\n opts.xdomain = !!this.opts.xd;\n const xhr = (this.xhr = new xmlhttprequest_js_1.XHR(opts));\n try {\n debug(\"xhr open %s: %s\", this.method, this.uri);\n xhr.open(this.method, this.uri, true);\n try {\n if (this.opts.extraHeaders) {\n xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);\n for (let i in this.opts.extraHeaders) {\n if (this.opts.extraHeaders.hasOwnProperty(i)) {\n xhr.setRequestHeader(i, this.opts.extraHeaders[i]);\n }\n }\n }\n }\n catch (e) { }\n if (\"POST\" === this.method) {\n try {\n xhr.setRequestHeader(\"Content-type\", \"text/plain;charset=UTF-8\");\n }\n catch (e) { }\n }\n try {\n xhr.setRequestHeader(\"Accept\", \"*/*\");\n }\n catch (e) { }\n (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr);\n // ie6 check\n if (\"withCredentials\" in xhr) {\n xhr.withCredentials = this.opts.withCredentials;\n }\n if (this.opts.requestTimeout) {\n xhr.timeout = this.opts.requestTimeout;\n }\n xhr.onreadystatechange = () => {\n var _a;\n if (xhr.readyState === 3) {\n (_a = this.opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(xhr);\n }\n if (4 !== xhr.readyState)\n return;\n if (200 === xhr.status || 1223 === xhr.status) {\n this.onLoad();\n }\n else {\n // make sure the `error` event handler that's user-set\n // does not throw in the same tick and gets caught here\n this.setTimeoutFn(() => {\n this.onError(typeof xhr.status === \"number\" ? xhr.status : 0);\n }, 0);\n }\n };\n debug(\"xhr data %s\", this.data);\n xhr.send(this.data);\n }\n catch (e) {\n // Need to defer since .create() is called directly from the constructor\n // and thus the 'error' event can only be only bound *after* this exception\n // occurs. Therefore, also, we cannot throw here at all.\n this.setTimeoutFn(() => {\n this.onError(e);\n }, 0);\n return;\n }\n if (typeof document !== \"undefined\") {\n this.index = Request.requestsCount++;\n Request.requests[this.index] = this;\n }\n }\n /**\n * Called upon error.\n *\n * @private\n */\n onError(err) {\n this.emitReserved(\"error\", err, this.xhr);\n this.cleanup(true);\n }\n /**\n * Cleans up house.\n *\n * @private\n */\n cleanup(fromError) {\n if (\"undefined\" === typeof this.xhr || null === this.xhr) {\n return;\n }\n this.xhr.onreadystatechange = empty;\n if (fromError) {\n try {\n this.xhr.abort();\n }\n catch (e) { }\n }\n if (typeof document !== \"undefined\") {\n delete Request.requests[this.index];\n }\n this.xhr = null;\n }\n /**\n * Called upon load.\n *\n * @private\n */\n onLoad() {\n const data = this.xhr.responseText;\n if (data !== null) {\n this.emitReserved(\"data\", data);\n this.emitReserved(\"success\");\n this.cleanup();\n }\n }\n /**\n * Aborts the request.\n *\n * @package\n */\n abort() {\n this.cleanup();\n }\n}\nexports.Request = Request;\nRequest.requestsCount = 0;\nRequest.requests = {};\n/**\n * Aborts pending requests when unloading the window. This is needed to prevent\n * memory leaks (e.g. when using IE) and to ensure that no spurious error is\n * emitted.\n */\nif (typeof document !== \"undefined\") {\n // @ts-ignore\n if (typeof attachEvent === \"function\") {\n // @ts-ignore\n attachEvent(\"onunload\", unloadHandler);\n }\n else if (typeof addEventListener === \"function\") {\n const terminationEvent = \"onpagehide\" in globalThis_js_1.globalThisShim ? \"pagehide\" : \"unload\";\n addEventListener(terminationEvent, unloadHandler, false);\n }\n}\nfunction unloadHandler() {\n for (let i in Request.requests) {\n if (Request.requests.hasOwnProperty(i)) {\n Request.requests[i].abort();\n }\n }\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/polling.js?");
|
|
571
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.XHR = exports.Request = exports.BaseXHR = void 0;\nconst polling_js_1 = __webpack_require__(/*! ./polling.js */ \"./node_modules/engine.io-client/build/cjs/transports/polling.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst util_js_1 = __webpack_require__(/*! ../util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst globals_node_js_1 = __webpack_require__(/*! ../globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nconst has_cors_js_1 = __webpack_require__(/*! ../contrib/has-cors.js */ \"./node_modules/engine.io-client/build/cjs/contrib/has-cors.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:polling\"); // debug()\nfunction empty() { }\nclass BaseXHR extends polling_js_1.Polling {\n /**\n * XHR Polling constructor.\n *\n * @param {Object} opts\n * @package\n */\n constructor(opts) {\n super(opts);\n if (typeof location !== \"undefined\") {\n const isSSL = \"https:\" === location.protocol;\n let port = location.port;\n // some user agents have empty `location.port`\n if (!port) {\n port = isSSL ? \"443\" : \"80\";\n }\n this.xd =\n (typeof location !== \"undefined\" &&\n opts.hostname !== location.hostname) ||\n port !== opts.port;\n }\n }\n /**\n * Sends data.\n *\n * @param {String} data to send.\n * @param {Function} called upon flush.\n * @private\n */\n doWrite(data, fn) {\n const req = this.request({\n method: \"POST\",\n data: data,\n });\n req.on(\"success\", fn);\n req.on(\"error\", (xhrStatus, context) => {\n this.onError(\"xhr post error\", xhrStatus, context);\n });\n }\n /**\n * Starts a poll cycle.\n *\n * @private\n */\n doPoll() {\n debug(\"xhr poll\");\n const req = this.request();\n req.on(\"data\", this.onData.bind(this));\n req.on(\"error\", (xhrStatus, context) => {\n this.onError(\"xhr poll error\", xhrStatus, context);\n });\n this.pollXhr = req;\n }\n}\nexports.BaseXHR = BaseXHR;\nclass Request extends component_emitter_1.Emitter {\n /**\n * Request constructor\n *\n * @param {Object} options\n * @package\n */\n constructor(createRequest, uri, opts) {\n super();\n this.createRequest = createRequest;\n (0, util_js_1.installTimerFunctions)(this, opts);\n this._opts = opts;\n this._method = opts.method || \"GET\";\n this._uri = uri;\n this._data = undefined !== opts.data ? opts.data : null;\n this._create();\n }\n /**\n * Creates the XHR object and sends the request.\n *\n * @private\n */\n _create() {\n var _a;\n const opts = (0, util_js_1.pick)(this._opts, \"agent\", \"pfx\", \"key\", \"passphrase\", \"cert\", \"ca\", \"ciphers\", \"rejectUnauthorized\", \"autoUnref\");\n opts.xdomain = !!this._opts.xd;\n const xhr = (this._xhr = this.createRequest(opts));\n try {\n debug(\"xhr open %s: %s\", this._method, this._uri);\n xhr.open(this._method, this._uri, true);\n try {\n if (this._opts.extraHeaders) {\n // @ts-ignore\n xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);\n for (let i in this._opts.extraHeaders) {\n if (this._opts.extraHeaders.hasOwnProperty(i)) {\n xhr.setRequestHeader(i, this._opts.extraHeaders[i]);\n }\n }\n }\n }\n catch (e) { }\n if (\"POST\" === this._method) {\n try {\n xhr.setRequestHeader(\"Content-type\", \"text/plain;charset=UTF-8\");\n }\n catch (e) { }\n }\n try {\n xhr.setRequestHeader(\"Accept\", \"*/*\");\n }\n catch (e) { }\n (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr);\n // ie6 check\n if (\"withCredentials\" in xhr) {\n xhr.withCredentials = this._opts.withCredentials;\n }\n if (this._opts.requestTimeout) {\n xhr.timeout = this._opts.requestTimeout;\n }\n xhr.onreadystatechange = () => {\n var _a;\n if (xhr.readyState === 3) {\n (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.parseCookies(\n // @ts-ignore\n xhr.getResponseHeader(\"set-cookie\"));\n }\n if (4 !== xhr.readyState)\n return;\n if (200 === xhr.status || 1223 === xhr.status) {\n this._onLoad();\n }\n else {\n // make sure the `error` event handler that's user-set\n // does not throw in the same tick and gets caught here\n this.setTimeoutFn(() => {\n this._onError(typeof xhr.status === \"number\" ? xhr.status : 0);\n }, 0);\n }\n };\n debug(\"xhr data %s\", this._data);\n xhr.send(this._data);\n }\n catch (e) {\n // Need to defer since .create() is called directly from the constructor\n // and thus the 'error' event can only be only bound *after* this exception\n // occurs. Therefore, also, we cannot throw here at all.\n this.setTimeoutFn(() => {\n this._onError(e);\n }, 0);\n return;\n }\n if (typeof document !== \"undefined\") {\n this._index = Request.requestsCount++;\n Request.requests[this._index] = this;\n }\n }\n /**\n * Called upon error.\n *\n * @private\n */\n _onError(err) {\n this.emitReserved(\"error\", err, this._xhr);\n this._cleanup(true);\n }\n /**\n * Cleans up house.\n *\n * @private\n */\n _cleanup(fromError) {\n if (\"undefined\" === typeof this._xhr || null === this._xhr) {\n return;\n }\n this._xhr.onreadystatechange = empty;\n if (fromError) {\n try {\n this._xhr.abort();\n }\n catch (e) { }\n }\n if (typeof document !== \"undefined\") {\n delete Request.requests[this._index];\n }\n this._xhr = null;\n }\n /**\n * Called upon load.\n *\n * @private\n */\n _onLoad() {\n const data = this._xhr.responseText;\n if (data !== null) {\n this.emitReserved(\"data\", data);\n this.emitReserved(\"success\");\n this._cleanup();\n }\n }\n /**\n * Aborts the request.\n *\n * @package\n */\n abort() {\n this._cleanup();\n }\n}\nexports.Request = Request;\nRequest.requestsCount = 0;\nRequest.requests = {};\n/**\n * Aborts pending requests when unloading the window. This is needed to prevent\n * memory leaks (e.g. when using IE) and to ensure that no spurious error is\n * emitted.\n */\nif (typeof document !== \"undefined\") {\n // @ts-ignore\n if (typeof attachEvent === \"function\") {\n // @ts-ignore\n attachEvent(\"onunload\", unloadHandler);\n }\n else if (typeof addEventListener === \"function\") {\n const terminationEvent = \"onpagehide\" in globals_node_js_1.globalThisShim ? \"pagehide\" : \"unload\";\n addEventListener(terminationEvent, unloadHandler, false);\n }\n}\nfunction unloadHandler() {\n for (let i in Request.requests) {\n if (Request.requests.hasOwnProperty(i)) {\n Request.requests[i].abort();\n }\n }\n}\nconst hasXHR2 = (function () {\n const xhr = newRequest({\n xdomain: false,\n });\n return xhr && xhr.responseType !== null;\n})();\n/**\n * HTTP long-polling based on the built-in `XMLHttpRequest` object.\n *\n * Usage: browser\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest\n */\nclass XHR extends BaseXHR {\n constructor(opts) {\n super(opts);\n const forceBase64 = opts && opts.forceBase64;\n this.supportsBinary = hasXHR2 && !forceBase64;\n }\n request(opts = {}) {\n Object.assign(opts, { xd: this.xd }, this.opts);\n return new Request(newRequest, this.uri(), opts);\n }\n}\nexports.XHR = XHR;\nfunction newRequest(opts) {\n const xdomain = opts.xdomain;\n // XMLHttpRequest can be disabled on IE\n try {\n if (\"undefined\" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) {\n return new XMLHttpRequest();\n }\n }\n catch (e) { }\n if (!xdomain) {\n try {\n return new globals_node_js_1.globalThisShim[[\"Active\"].concat(\"Object\").join(\"X\")](\"Microsoft.XMLHTTP\");\n }\n catch (e) { }\n }\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/polling-xhr.js?");
|
|
572
572
|
|
|
573
573
|
/***/ }),
|
|
574
574
|
|
|
575
|
-
/***/ "./node_modules/engine.io-client/build/cjs/transports/
|
|
576
|
-
|
|
577
|
-
!*** ./node_modules/engine.io-client/build/cjs/transports/
|
|
578
|
-
|
|
579
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
575
|
+
/***/ "./node_modules/engine.io-client/build/cjs/transports/polling.js":
|
|
576
|
+
/*!***********************************************************************!*\
|
|
577
|
+
!*** ./node_modules/engine.io-client/build/cjs/transports/polling.js ***!
|
|
578
|
+
\***********************************************************************/
|
|
579
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
580
580
|
|
|
581
581
|
"use strict";
|
|
582
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.
|
|
582
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Polling = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst util_js_1 = __webpack_require__(/*! ../util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:polling\"); // debug()\nclass Polling extends transport_js_1.Transport {\n constructor() {\n super(...arguments);\n this._polling = false;\n }\n get name() {\n return \"polling\";\n }\n /**\n * Opens the socket (triggers polling). We write a PING message to determine\n * when the transport is open.\n *\n * @protected\n */\n doOpen() {\n this._poll();\n }\n /**\n * Pauses polling.\n *\n * @param {Function} onPause - callback upon buffers are flushed and transport is paused\n * @package\n */\n pause(onPause) {\n this.readyState = \"pausing\";\n const pause = () => {\n debug(\"paused\");\n this.readyState = \"paused\";\n onPause();\n };\n if (this._polling || !this.writable) {\n let total = 0;\n if (this._polling) {\n debug(\"we are currently polling - waiting to pause\");\n total++;\n this.once(\"pollComplete\", function () {\n debug(\"pre-pause polling complete\");\n --total || pause();\n });\n }\n if (!this.writable) {\n debug(\"we are currently writing - waiting to pause\");\n total++;\n this.once(\"drain\", function () {\n debug(\"pre-pause writing complete\");\n --total || pause();\n });\n }\n }\n else {\n pause();\n }\n }\n /**\n * Starts polling cycle.\n *\n * @private\n */\n _poll() {\n debug(\"polling\");\n this._polling = true;\n this.doPoll();\n this.emitReserved(\"poll\");\n }\n /**\n * Overloads onData to detect payloads.\n *\n * @protected\n */\n onData(data) {\n debug(\"polling got data %s\", data);\n const callback = (packet) => {\n // if its the first message we consider the transport open\n if (\"opening\" === this.readyState && packet.type === \"open\") {\n this.onOpen();\n }\n // if its a close packet, we close the ongoing requests\n if (\"close\" === packet.type) {\n this.onClose({ description: \"transport closed by the server\" });\n return false;\n }\n // otherwise bypass onData and handle the message\n this.onPacket(packet);\n };\n // decode payload\n (0, engine_io_parser_1.decodePayload)(data, this.socket.binaryType).forEach(callback);\n // if an event did not trigger closing\n if (\"closed\" !== this.readyState) {\n // if we got data we're not polling\n this._polling = false;\n this.emitReserved(\"pollComplete\");\n if (\"open\" === this.readyState) {\n this._poll();\n }\n else {\n debug('ignoring poll - transport state \"%s\"', this.readyState);\n }\n }\n }\n /**\n * For polling, send a close packet.\n *\n * @protected\n */\n doClose() {\n const close = () => {\n debug(\"writing close packet\");\n this.write([{ type: \"close\" }]);\n };\n if (\"open\" === this.readyState) {\n debug(\"transport open - closing\");\n close();\n }\n else {\n // in case we're trying to close while\n // handshaking is in progress (GH-164)\n debug(\"transport not open - deferring close\");\n this.once(\"open\", close);\n }\n }\n /**\n * Writes a packets payload.\n *\n * @param {Array} packets - data packets\n * @protected\n */\n write(packets) {\n this.writable = false;\n (0, engine_io_parser_1.encodePayload)(packets, (data) => {\n this.doWrite(data, () => {\n this.writable = true;\n this.emitReserved(\"drain\");\n });\n });\n }\n /**\n * Generates uri for connection.\n *\n * @private\n */\n uri() {\n const schema = this.opts.secure ? \"https\" : \"http\";\n const query = this.query || {};\n // cache busting is forced\n if (false !== this.opts.timestampRequests) {\n query[this.opts.timestampParam] = (0, util_js_1.randomString)();\n }\n if (!this.supportsBinary && !query.sid) {\n query.b64 = 1;\n }\n return this.createUri(schema, query);\n }\n}\nexports.Polling = Polling;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/polling.js?");
|
|
583
583
|
|
|
584
584
|
/***/ }),
|
|
585
585
|
|
|
@@ -590,7 +590,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
590
590
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
591
591
|
|
|
592
592
|
"use strict";
|
|
593
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WS = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst
|
|
593
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WS = exports.BaseWS = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst util_js_1 = __webpack_require__(/*! ../util.js */ \"./node_modules/engine.io-client/build/cjs/util.js\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst globals_node_js_1 = __webpack_require__(/*! ../globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:websocket\"); // debug()\n// detect ReactNative environment\nconst isReactNative = typeof navigator !== \"undefined\" &&\n typeof navigator.product === \"string\" &&\n navigator.product.toLowerCase() === \"reactnative\";\nclass BaseWS extends transport_js_1.Transport {\n get name() {\n return \"websocket\";\n }\n doOpen() {\n const uri = this.uri();\n const protocols = this.opts.protocols;\n // React Native only supports the 'headers' option, and will print a warning if anything else is passed\n const opts = isReactNative\n ? {}\n : (0, util_js_1.pick)(this.opts, \"agent\", \"perMessageDeflate\", \"pfx\", \"key\", \"passphrase\", \"cert\", \"ca\", \"ciphers\", \"rejectUnauthorized\", \"localAddress\", \"protocolVersion\", \"origin\", \"maxPayload\", \"family\", \"checkServerIdentity\");\n if (this.opts.extraHeaders) {\n opts.headers = this.opts.extraHeaders;\n }\n try {\n this.ws = this.createSocket(uri, protocols, opts);\n }\n catch (err) {\n return this.emitReserved(\"error\", err);\n }\n this.ws.binaryType = this.socket.binaryType;\n this.addEventListeners();\n }\n /**\n * Adds event listeners to the socket\n *\n * @private\n */\n addEventListeners() {\n this.ws.onopen = () => {\n if (this.opts.autoUnref) {\n this.ws._socket.unref();\n }\n this.onOpen();\n };\n this.ws.onclose = (closeEvent) => this.onClose({\n description: \"websocket connection closed\",\n context: closeEvent,\n });\n this.ws.onmessage = (ev) => this.onData(ev.data);\n this.ws.onerror = (e) => this.onError(\"websocket error\", e);\n }\n write(packets) {\n this.writable = false;\n // encodePacket efficient as it uses WS framing\n // no need for encodePayload\n for (let i = 0; i < packets.length; i++) {\n const packet = packets[i];\n const lastPacket = i === packets.length - 1;\n (0, engine_io_parser_1.encodePacket)(packet, this.supportsBinary, (data) => {\n // Sometimes the websocket has already been closed but the browser didn't\n // have a chance of informing us about it yet, in that case send will\n // throw an error\n try {\n this.doWrite(packet, data);\n }\n catch (e) {\n debug(\"websocket closed before onclose event\");\n }\n if (lastPacket) {\n // fake drain\n // defer to next tick to allow Socket to clear writeBuffer\n (0, globals_node_js_1.nextTick)(() => {\n this.writable = true;\n this.emitReserved(\"drain\");\n }, this.setTimeoutFn);\n }\n });\n }\n }\n doClose() {\n if (typeof this.ws !== \"undefined\") {\n this.ws.onerror = () => { };\n this.ws.close();\n this.ws = null;\n }\n }\n /**\n * Generates uri for connection.\n *\n * @private\n */\n uri() {\n const schema = this.opts.secure ? \"wss\" : \"ws\";\n const query = this.query || {};\n // append timestamp to URI\n if (this.opts.timestampRequests) {\n query[this.opts.timestampParam] = (0, util_js_1.randomString)();\n }\n // communicate binary support capabilities\n if (!this.supportsBinary) {\n query.b64 = 1;\n }\n return this.createUri(schema, query);\n }\n}\nexports.BaseWS = BaseWS;\nconst WebSocketCtor = globals_node_js_1.globalThisShim.WebSocket || globals_node_js_1.globalThisShim.MozWebSocket;\n/**\n * WebSocket transport based on the built-in `WebSocket` object.\n *\n * Usage: browser, Node.js (since v21), Deno, Bun\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket\n * @see https://caniuse.com/mdn-api_websocket\n * @see https://nodejs.org/api/globals.html#websocket\n */\nclass WS extends BaseWS {\n createSocket(uri, protocols, opts) {\n return !isReactNative\n ? protocols\n ? new WebSocketCtor(uri, protocols)\n : new WebSocketCtor(uri)\n : new WebSocketCtor(uri, protocols, opts);\n }\n doWrite(_packet, data) {\n this.ws.send(data);\n }\n}\nexports.WS = WS;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/websocket.js?");
|
|
594
594
|
|
|
595
595
|
/***/ }),
|
|
596
596
|
|
|
@@ -601,18 +601,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
601
601
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
602
602
|
|
|
603
603
|
"use strict";
|
|
604
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WT = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst
|
|
605
|
-
|
|
606
|
-
/***/ }),
|
|
607
|
-
|
|
608
|
-
/***/ "./node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js":
|
|
609
|
-
/*!**************************************************************************************!*\
|
|
610
|
-
!*** ./node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js ***!
|
|
611
|
-
\**************************************************************************************/
|
|
612
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
613
|
-
|
|
614
|
-
"use strict";
|
|
615
|
-
eval("\n// browser shim for xmlhttprequest module\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.createCookieJar = exports.XHR = void 0;\nconst has_cors_js_1 = __webpack_require__(/*! ../contrib/has-cors.js */ \"./node_modules/engine.io-client/build/cjs/contrib/has-cors.js\");\nconst globalThis_js_1 = __webpack_require__(/*! ../globalThis.js */ \"./node_modules/engine.io-client/build/cjs/globalThis.browser.js\");\nfunction XHR(opts) {\n const xdomain = opts.xdomain;\n // XMLHttpRequest can be disabled on IE\n try {\n if (\"undefined\" !== typeof XMLHttpRequest && (!xdomain || has_cors_js_1.hasCORS)) {\n return new XMLHttpRequest();\n }\n }\n catch (e) { }\n if (!xdomain) {\n try {\n return new globalThis_js_1.globalThisShim[[\"Active\"].concat(\"Object\").join(\"X\")](\"Microsoft.XMLHTTP\");\n }\n catch (e) { }\n }\n}\nexports.XHR = XHR;\nfunction createCookieJar() { }\nexports.createCookieJar = createCookieJar;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/xmlhttprequest.browser.js?");
|
|
604
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WT = void 0;\nconst transport_js_1 = __webpack_require__(/*! ../transport.js */ \"./node_modules/engine.io-client/build/cjs/transport.js\");\nconst globals_node_js_1 = __webpack_require__(/*! ../globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nconst engine_io_parser_1 = __webpack_require__(/*! engine.io-parser */ \"./node_modules/engine.io-parser/build/cjs/index.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"engine.io-client:webtransport\"); // debug()\n/**\n * WebTransport transport based on the built-in `WebTransport` object.\n *\n * Usage: browser, Node.js (with the `@fails-components/webtransport` package)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport\n * @see https://caniuse.com/webtransport\n */\nclass WT extends transport_js_1.Transport {\n get name() {\n return \"webtransport\";\n }\n doOpen() {\n try {\n // @ts-ignore\n this._transport = new WebTransport(this.createUri(\"https\"), this.opts.transportOptions[this.name]);\n }\n catch (err) {\n return this.emitReserved(\"error\", err);\n }\n this._transport.closed\n .then(() => {\n debug(\"transport closed gracefully\");\n this.onClose();\n })\n .catch((err) => {\n debug(\"transport closed due to %s\", err);\n this.onError(\"webtransport error\", err);\n });\n // note: we could have used async/await, but that would require some additional polyfills\n this._transport.ready.then(() => {\n this._transport.createBidirectionalStream().then((stream) => {\n const decoderStream = (0, engine_io_parser_1.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER, this.socket.binaryType);\n const reader = stream.readable.pipeThrough(decoderStream).getReader();\n const encoderStream = (0, engine_io_parser_1.createPacketEncoderStream)();\n encoderStream.readable.pipeTo(stream.writable);\n this._writer = encoderStream.writable.getWriter();\n const read = () => {\n reader\n .read()\n .then(({ done, value }) => {\n if (done) {\n debug(\"session is closed\");\n return;\n }\n debug(\"received chunk: %o\", value);\n this.onPacket(value);\n read();\n })\n .catch((err) => {\n debug(\"an error occurred while reading: %s\", err);\n });\n };\n read();\n const packet = { type: \"open\" };\n if (this.query.sid) {\n packet.data = `{\"sid\":\"${this.query.sid}\"}`;\n }\n this._writer.write(packet).then(() => this.onOpen());\n });\n });\n }\n write(packets) {\n this.writable = false;\n for (let i = 0; i < packets.length; i++) {\n const packet = packets[i];\n const lastPacket = i === packets.length - 1;\n this._writer.write(packet).then(() => {\n if (lastPacket) {\n (0, globals_node_js_1.nextTick)(() => {\n this.writable = true;\n this.emitReserved(\"drain\");\n }, this.setTimeoutFn);\n }\n });\n }\n }\n doClose() {\n var _a;\n (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close();\n }\n}\nexports.WT = WT;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/transports/webtransport.js?");
|
|
616
605
|
|
|
617
606
|
/***/ }),
|
|
618
607
|
|
|
@@ -623,7 +612,7 @@ eval("\n// browser shim for xmlhttprequest module\nObject.defineProperty(exports
|
|
|
623
612
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
624
613
|
|
|
625
614
|
"use strict";
|
|
626
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.
|
|
615
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.pick = pick;\nexports.installTimerFunctions = installTimerFunctions;\nexports.byteLength = byteLength;\nexports.randomString = randomString;\nconst globals_node_js_1 = __webpack_require__(/*! ./globals.node.js */ \"./node_modules/engine.io-client/build/cjs/globals.js\");\nfunction pick(obj, ...attr) {\n return attr.reduce((acc, k) => {\n if (obj.hasOwnProperty(k)) {\n acc[k] = obj[k];\n }\n return acc;\n }, {});\n}\n// Keep a reference to the real timeout functions so they can be used when overridden\nconst NATIVE_SET_TIMEOUT = globals_node_js_1.globalThisShim.setTimeout;\nconst NATIVE_CLEAR_TIMEOUT = globals_node_js_1.globalThisShim.clearTimeout;\nfunction installTimerFunctions(obj, opts) {\n if (opts.useNativeTimers) {\n obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globals_node_js_1.globalThisShim);\n obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globals_node_js_1.globalThisShim);\n }\n else {\n obj.setTimeoutFn = globals_node_js_1.globalThisShim.setTimeout.bind(globals_node_js_1.globalThisShim);\n obj.clearTimeoutFn = globals_node_js_1.globalThisShim.clearTimeout.bind(globals_node_js_1.globalThisShim);\n }\n}\n// base64 encoded buffers are about 33% bigger (https://en.wikipedia.org/wiki/Base64)\nconst BASE64_OVERHEAD = 1.33;\n// we could also have used `new Blob([obj]).size`, but it isn't supported in IE9\nfunction byteLength(obj) {\n if (typeof obj === \"string\") {\n return utf8Length(obj);\n }\n // arraybuffer or blob\n return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);\n}\nfunction utf8Length(str) {\n let c = 0, length = 0;\n for (let i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n length += 1;\n }\n else if (c < 0x800) {\n length += 2;\n }\n else if (c < 0xd800 || c >= 0xe000) {\n length += 3;\n }\n else {\n i++;\n length += 4;\n }\n }\n return length;\n}\n/**\n * Generates a random 8-characters string.\n */\nfunction randomString() {\n return (Date.now().toString(36).substring(3) +\n Math.random().toString(36).substring(2, 5));\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-client/build/cjs/util.js?");
|
|
627
616
|
|
|
628
617
|
/***/ }),
|
|
629
618
|
|
|
@@ -634,7 +623,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
634
623
|
/***/ ((__unused_webpack_module, exports) => {
|
|
635
624
|
|
|
636
625
|
"use strict";
|
|
637
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;\nconst PACKET_TYPES = Object.create(null); // no Map = no polyfill\nexports.PACKET_TYPES = PACKET_TYPES;\nPACKET_TYPES[\"open\"] = \"0\";\nPACKET_TYPES[\"close\"] = \"1\";\nPACKET_TYPES[\"ping\"] = \"2\";\nPACKET_TYPES[\"pong\"] = \"3\";\nPACKET_TYPES[\"message\"] = \"4\";\nPACKET_TYPES[\"upgrade\"] = \"5\";\nPACKET_TYPES[\"noop\"] = \"6\";\nconst PACKET_TYPES_REVERSE = Object.create(null);\nexports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;\nObject.keys(PACKET_TYPES).forEach(
|
|
626
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.ERROR_PACKET = exports.PACKET_TYPES_REVERSE = exports.PACKET_TYPES = void 0;\nconst PACKET_TYPES = Object.create(null); // no Map = no polyfill\nexports.PACKET_TYPES = PACKET_TYPES;\nPACKET_TYPES[\"open\"] = \"0\";\nPACKET_TYPES[\"close\"] = \"1\";\nPACKET_TYPES[\"ping\"] = \"2\";\nPACKET_TYPES[\"pong\"] = \"3\";\nPACKET_TYPES[\"message\"] = \"4\";\nPACKET_TYPES[\"upgrade\"] = \"5\";\nPACKET_TYPES[\"noop\"] = \"6\";\nconst PACKET_TYPES_REVERSE = Object.create(null);\nexports.PACKET_TYPES_REVERSE = PACKET_TYPES_REVERSE;\nObject.keys(PACKET_TYPES).forEach(key => {\n PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;\n});\nconst ERROR_PACKET = { type: \"error\", data: \"parser error\" };\nexports.ERROR_PACKET = ERROR_PACKET;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-parser/build/cjs/commons.js?");
|
|
638
627
|
|
|
639
628
|
/***/ }),
|
|
640
629
|
|
|
@@ -656,7 +645,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
656
645
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
657
646
|
|
|
658
647
|
"use strict";
|
|
659
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.decodePacket = void 0;\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst base64_arraybuffer_js_1 = __webpack_require__(/*! ./contrib/base64-arraybuffer.js */ \"./node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js\");\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\nconst decodePacket = (encodedPacket, binaryType) => {\n if (typeof encodedPacket !== \"string\") {\n return {\n type: \"message\",\n data: mapBinary(encodedPacket, binaryType)
|
|
648
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.decodePacket = void 0;\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst base64_arraybuffer_js_1 = __webpack_require__(/*! ./contrib/base64-arraybuffer.js */ \"./node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js\");\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\nconst decodePacket = (encodedPacket, binaryType) => {\n if (typeof encodedPacket !== \"string\") {\n return {\n type: \"message\",\n data: mapBinary(encodedPacket, binaryType)\n };\n }\n const type = encodedPacket.charAt(0);\n if (type === \"b\") {\n return {\n type: \"message\",\n data: decodeBase64Packet(encodedPacket.substring(1), binaryType)\n };\n }\n const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];\n if (!packetType) {\n return commons_js_1.ERROR_PACKET;\n }\n return encodedPacket.length > 1\n ? {\n type: commons_js_1.PACKET_TYPES_REVERSE[type],\n data: encodedPacket.substring(1)\n }\n : {\n type: commons_js_1.PACKET_TYPES_REVERSE[type]\n };\n};\nexports.decodePacket = decodePacket;\nconst decodeBase64Packet = (data, binaryType) => {\n if (withNativeArrayBuffer) {\n const decoded = (0, base64_arraybuffer_js_1.decode)(data);\n return mapBinary(decoded, binaryType);\n }\n else {\n return { base64: true, data }; // fallback for old browsers\n }\n};\nconst mapBinary = (data, binaryType) => {\n switch (binaryType) {\n case \"blob\":\n if (data instanceof Blob) {\n // from WebSocket + binaryType \"blob\"\n return data;\n }\n else {\n // from HTTP long-polling or WebTransport\n return new Blob([data]);\n }\n case \"arraybuffer\":\n default:\n if (data instanceof ArrayBuffer) {\n // from HTTP long-polling (base64) or WebSocket + binaryType \"arraybuffer\"\n return data;\n }\n else {\n // from WebTransport (Uint8Array)\n return data.buffer;\n }\n }\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-parser/build/cjs/decodePacket.browser.js?");
|
|
660
649
|
|
|
661
650
|
/***/ }),
|
|
662
651
|
|
|
@@ -667,7 +656,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
667
656
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
668
657
|
|
|
669
658
|
"use strict";
|
|
670
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.encodePacket = exports.encodePacketToBinary = void 0;\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst withNativeBlob = typeof Blob === \"function\" ||\n (typeof Blob !== \"undefined\" &&\n Object.prototype.toString.call(Blob) === \"[object BlobConstructor]\");\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\n// ArrayBuffer.isView method is not defined in IE10\nconst isView =
|
|
659
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.encodePacket = exports.encodePacketToBinary = void 0;\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst withNativeBlob = typeof Blob === \"function\" ||\n (typeof Blob !== \"undefined\" &&\n Object.prototype.toString.call(Blob) === \"[object BlobConstructor]\");\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\n// ArrayBuffer.isView method is not defined in IE10\nconst isView = obj => {\n return typeof ArrayBuffer.isView === \"function\"\n ? ArrayBuffer.isView(obj)\n : obj && obj.buffer instanceof ArrayBuffer;\n};\nconst encodePacket = ({ type, data }, supportsBinary, callback) => {\n if (withNativeBlob && data instanceof Blob) {\n if (supportsBinary) {\n return callback(data);\n }\n else {\n return encodeBlobAsBase64(data, callback);\n }\n }\n else if (withNativeArrayBuffer &&\n (data instanceof ArrayBuffer || isView(data))) {\n if (supportsBinary) {\n return callback(data);\n }\n else {\n return encodeBlobAsBase64(new Blob([data]), callback);\n }\n }\n // plain string\n return callback(commons_js_1.PACKET_TYPES[type] + (data || \"\"));\n};\nexports.encodePacket = encodePacket;\nconst encodeBlobAsBase64 = (data, callback) => {\n const fileReader = new FileReader();\n fileReader.onload = function () {\n const content = fileReader.result.split(\",\")[1];\n callback(\"b\" + (content || \"\"));\n };\n return fileReader.readAsDataURL(data);\n};\nfunction toArray(data) {\n if (data instanceof Uint8Array) {\n return data;\n }\n else if (data instanceof ArrayBuffer) {\n return new Uint8Array(data);\n }\n else {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n }\n}\nlet TEXT_ENCODER;\nfunction encodePacketToBinary(packet, callback) {\n if (withNativeBlob && packet.data instanceof Blob) {\n return packet.data\n .arrayBuffer()\n .then(toArray)\n .then(callback);\n }\n else if (withNativeArrayBuffer &&\n (packet.data instanceof ArrayBuffer || isView(packet.data))) {\n return callback(toArray(packet.data));\n }\n encodePacket(packet, false, encoded => {\n if (!TEXT_ENCODER) {\n TEXT_ENCODER = new TextEncoder();\n }\n callback(TEXT_ENCODER.encode(encoded));\n });\n}\nexports.encodePacketToBinary = encodePacketToBinary;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-parser/build/cjs/encodePacket.browser.js?");
|
|
671
660
|
|
|
672
661
|
/***/ }),
|
|
673
662
|
|
|
@@ -678,7 +667,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
678
667
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
679
668
|
|
|
680
669
|
"use strict";
|
|
681
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0;\nconst encodePacket_js_1 = __webpack_require__(/*! ./encodePacket.js */ \"./node_modules/engine.io-parser/build/cjs/encodePacket.browser.js\");\nObject.defineProperty(exports, \"encodePacket\", ({ enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }));\nconst decodePacket_js_1 = __webpack_require__(/*! ./decodePacket.js */ \"./node_modules/engine.io-parser/build/cjs/decodePacket.browser.js\");\nObject.defineProperty(exports, \"decodePacket\", ({ enumerable: true, get: function () { return decodePacket_js_1.decodePacket; } }));\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text\nconst encodePayload = (packets, callback) => {\n // some packets may be added to the array while encoding, so the initial length must be saved\n const length = packets.length;\n const encodedPackets = new Array(length);\n let count = 0;\n packets.forEach((packet, i) => {\n // force base64 encoding for binary packets\n (0, encodePacket_js_1.encodePacket)(packet, false,
|
|
670
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = exports.createPacketDecoderStream = exports.createPacketEncoderStream = void 0;\nconst encodePacket_js_1 = __webpack_require__(/*! ./encodePacket.js */ \"./node_modules/engine.io-parser/build/cjs/encodePacket.browser.js\");\nObject.defineProperty(exports, \"encodePacket\", ({ enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } }));\nconst decodePacket_js_1 = __webpack_require__(/*! ./decodePacket.js */ \"./node_modules/engine.io-parser/build/cjs/decodePacket.browser.js\");\nObject.defineProperty(exports, \"decodePacket\", ({ enumerable: true, get: function () { return decodePacket_js_1.decodePacket; } }));\nconst commons_js_1 = __webpack_require__(/*! ./commons.js */ \"./node_modules/engine.io-parser/build/cjs/commons.js\");\nconst SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text\nconst encodePayload = (packets, callback) => {\n // some packets may be added to the array while encoding, so the initial length must be saved\n const length = packets.length;\n const encodedPackets = new Array(length);\n let count = 0;\n packets.forEach((packet, i) => {\n // force base64 encoding for binary packets\n (0, encodePacket_js_1.encodePacket)(packet, false, encodedPacket => {\n encodedPackets[i] = encodedPacket;\n if (++count === length) {\n callback(encodedPackets.join(SEPARATOR));\n }\n });\n });\n};\nexports.encodePayload = encodePayload;\nconst decodePayload = (encodedPayload, binaryType) => {\n const encodedPackets = encodedPayload.split(SEPARATOR);\n const packets = [];\n for (let i = 0; i < encodedPackets.length; i++) {\n const decodedPacket = (0, decodePacket_js_1.decodePacket)(encodedPackets[i], binaryType);\n packets.push(decodedPacket);\n if (decodedPacket.type === \"error\") {\n break;\n }\n }\n return packets;\n};\nexports.decodePayload = decodePayload;\nfunction createPacketEncoderStream() {\n return new TransformStream({\n transform(packet, controller) {\n (0, encodePacket_js_1.encodePacketToBinary)(packet, encodedPacket => {\n const payloadLength = encodedPacket.length;\n let header;\n // inspired by the WebSocket format: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#decoding_payload_length\n if (payloadLength < 126) {\n header = new Uint8Array(1);\n new DataView(header.buffer).setUint8(0, payloadLength);\n }\n else if (payloadLength < 65536) {\n header = new Uint8Array(3);\n const view = new DataView(header.buffer);\n view.setUint8(0, 126);\n view.setUint16(1, payloadLength);\n }\n else {\n header = new Uint8Array(9);\n const view = new DataView(header.buffer);\n view.setUint8(0, 127);\n view.setBigUint64(1, BigInt(payloadLength));\n }\n // first bit indicates whether the payload is plain text (0) or binary (1)\n if (packet.data && typeof packet.data !== \"string\") {\n header[0] |= 0x80;\n }\n controller.enqueue(header);\n controller.enqueue(encodedPacket);\n });\n }\n });\n}\nexports.createPacketEncoderStream = createPacketEncoderStream;\nlet TEXT_DECODER;\nfunction totalLength(chunks) {\n return chunks.reduce((acc, chunk) => acc + chunk.length, 0);\n}\nfunction concatChunks(chunks, size) {\n if (chunks[0].length === size) {\n return chunks.shift();\n }\n const buffer = new Uint8Array(size);\n let j = 0;\n for (let i = 0; i < size; i++) {\n buffer[i] = chunks[0][j++];\n if (j === chunks[0].length) {\n chunks.shift();\n j = 0;\n }\n }\n if (chunks.length && j < chunks[0].length) {\n chunks[0] = chunks[0].slice(j);\n }\n return buffer;\n}\nfunction createPacketDecoderStream(maxPayload, binaryType) {\n if (!TEXT_DECODER) {\n TEXT_DECODER = new TextDecoder();\n }\n const chunks = [];\n let state = 0 /* READ_HEADER */;\n let expectedLength = -1;\n let isBinary = false;\n return new TransformStream({\n transform(chunk, controller) {\n chunks.push(chunk);\n while (true) {\n if (state === 0 /* READ_HEADER */) {\n if (totalLength(chunks) < 1) {\n break;\n }\n const header = concatChunks(chunks, 1);\n isBinary = (header[0] & 0x80) === 0x80;\n expectedLength = header[0] & 0x7f;\n if (expectedLength < 126) {\n state = 3 /* READ_PAYLOAD */;\n }\n else if (expectedLength === 126) {\n state = 1 /* READ_EXTENDED_LENGTH_16 */;\n }\n else {\n state = 2 /* READ_EXTENDED_LENGTH_64 */;\n }\n }\n else if (state === 1 /* READ_EXTENDED_LENGTH_16 */) {\n if (totalLength(chunks) < 2) {\n break;\n }\n const headerArray = concatChunks(chunks, 2);\n expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);\n state = 3 /* READ_PAYLOAD */;\n }\n else if (state === 2 /* READ_EXTENDED_LENGTH_64 */) {\n if (totalLength(chunks) < 8) {\n break;\n }\n const headerArray = concatChunks(chunks, 8);\n const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);\n const n = view.getUint32(0);\n if (n > Math.pow(2, 53 - 32) - 1) {\n // the maximum safe integer in JavaScript is 2^53 - 1\n controller.enqueue(commons_js_1.ERROR_PACKET);\n break;\n }\n expectedLength = n * Math.pow(2, 32) + view.getUint32(4);\n state = 3 /* READ_PAYLOAD */;\n }\n else {\n if (totalLength(chunks) < expectedLength) {\n break;\n }\n const data = concatChunks(chunks, expectedLength);\n controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType));\n state = 0 /* READ_HEADER */;\n }\n if (expectedLength === 0 || expectedLength > maxPayload) {\n controller.enqueue(commons_js_1.ERROR_PACKET);\n break;\n }\n }\n }\n });\n}\nexports.createPacketDecoderStream = createPacketDecoderStream;\nexports.protocol = 4;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/engine.io-parser/build/cjs/index.js?");
|
|
682
671
|
|
|
683
672
|
/***/ }),
|
|
684
673
|
|
|
@@ -689,7 +678,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
689
678
|
/***/ ((__unused_webpack_module, exports) => {
|
|
690
679
|
|
|
691
680
|
"use strict";
|
|
692
|
-
eval("\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial timeout in milliseconds [100]\n * - `max` max timeout [10000]\n * - `jitter` [0]\n * - `factor` [2]\n *\n * @param {Object} opts\n * @api public\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Backoff =
|
|
681
|
+
eval("\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial timeout in milliseconds [100]\n * - `max` max timeout [10000]\n * - `jitter` [0]\n * - `factor` [2]\n *\n * @param {Object} opts\n * @api public\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Backoff = Backoff;\nfunction Backoff(opts) {\n opts = opts || {};\n this.ms = opts.min || 100;\n this.max = opts.max || 10000;\n this.factor = opts.factor || 2;\n this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;\n this.attempts = 0;\n}\n/**\n * Return the backoff duration.\n *\n * @return {Number}\n * @api public\n */\nBackoff.prototype.duration = function () {\n var ms = this.ms * Math.pow(this.factor, this.attempts++);\n if (this.jitter) {\n var rand = Math.random();\n var deviation = Math.floor(rand * this.jitter * ms);\n ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;\n }\n return Math.min(ms, this.max) | 0;\n};\n/**\n * Reset the number of attempts.\n *\n * @api public\n */\nBackoff.prototype.reset = function () {\n this.attempts = 0;\n};\n/**\n * Set the minimum duration\n *\n * @api public\n */\nBackoff.prototype.setMin = function (min) {\n this.ms = min;\n};\n/**\n * Set the maximum duration\n *\n * @api public\n */\nBackoff.prototype.setMax = function (max) {\n this.max = max;\n};\n/**\n * Set the jitter\n *\n * @api public\n */\nBackoff.prototype.setJitter = function (jitter) {\n this.jitter = jitter;\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/contrib/backo2.js?");
|
|
693
682
|
|
|
694
683
|
/***/ }),
|
|
695
684
|
|
|
@@ -700,7 +689,7 @@ eval("\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial ti
|
|
|
700
689
|
/***/ (function(module, exports, __webpack_require__) {
|
|
701
690
|
|
|
702
691
|
"use strict";
|
|
703
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports
|
|
692
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.WebTransport = exports.WebSocket = exports.NodeWebSocket = exports.XHR = exports.NodeXHR = exports.Fetch = exports.Socket = exports.Manager = exports.protocol = void 0;\nexports.io = lookup;\nexports.connect = lookup;\nexports[\"default\"] = lookup;\nconst url_js_1 = __webpack_require__(/*! ./url.js */ \"./node_modules/socket.io-client/build/cjs/url.js\");\nconst manager_js_1 = __webpack_require__(/*! ./manager.js */ \"./node_modules/socket.io-client/build/cjs/manager.js\");\nObject.defineProperty(exports, \"Manager\", ({ enumerable: true, get: function () { return manager_js_1.Manager; } }));\nconst socket_js_1 = __webpack_require__(/*! ./socket.js */ \"./node_modules/socket.io-client/build/cjs/socket.js\");\nObject.defineProperty(exports, \"Socket\", ({ enumerable: true, get: function () { return socket_js_1.Socket; } }));\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-client\"); // debug()\n/**\n * Managers cache.\n */\nconst cache = {};\nfunction lookup(uri, opts) {\n if (typeof uri === \"object\") {\n opts = uri;\n uri = undefined;\n }\n opts = opts || {};\n const parsed = (0, url_js_1.url)(uri, opts.path || \"/socket.io\");\n const source = parsed.source;\n const id = parsed.id;\n const path = parsed.path;\n const sameNamespace = cache[id] && path in cache[id][\"nsps\"];\n const newConnection = opts.forceNew ||\n opts[\"force new connection\"] ||\n false === opts.multiplex ||\n sameNamespace;\n let io;\n if (newConnection) {\n debug(\"ignoring socket cache for %s\", source);\n io = new manager_js_1.Manager(source, opts);\n }\n else {\n if (!cache[id]) {\n debug(\"new io instance for %s\", source);\n cache[id] = new manager_js_1.Manager(source, opts);\n }\n io = cache[id];\n }\n if (parsed.query && !opts.query) {\n opts.query = parsed.queryKey;\n }\n return io.socket(parsed.path, opts);\n}\n// so that \"lookup\" can be used both as a function (e.g. `io(...)`) and as a\n// namespace (e.g. `io.connect(...)`), for backward compatibility\nObject.assign(lookup, {\n Manager: manager_js_1.Manager,\n Socket: socket_js_1.Socket,\n io: lookup,\n connect: lookup,\n});\n/**\n * Protocol version.\n *\n * @public\n */\nvar socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ \"./node_modules/socket.io-parser/build/cjs/index.js\");\nObject.defineProperty(exports, \"protocol\", ({ enumerable: true, get: function () { return socket_io_parser_1.protocol; } }));\nvar engine_io_client_1 = __webpack_require__(/*! engine.io-client */ \"./node_modules/engine.io-client/build/cjs/index.js\");\nObject.defineProperty(exports, \"Fetch\", ({ enumerable: true, get: function () { return engine_io_client_1.Fetch; } }));\nObject.defineProperty(exports, \"NodeXHR\", ({ enumerable: true, get: function () { return engine_io_client_1.NodeXHR; } }));\nObject.defineProperty(exports, \"XHR\", ({ enumerable: true, get: function () { return engine_io_client_1.XHR; } }));\nObject.defineProperty(exports, \"NodeWebSocket\", ({ enumerable: true, get: function () { return engine_io_client_1.NodeWebSocket; } }));\nObject.defineProperty(exports, \"WebSocket\", ({ enumerable: true, get: function () { return engine_io_client_1.WebSocket; } }));\nObject.defineProperty(exports, \"WebTransport\", ({ enumerable: true, get: function () { return engine_io_client_1.WebTransport; } }));\n\nmodule.exports = lookup;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/index.js?");
|
|
704
693
|
|
|
705
694
|
/***/ }),
|
|
706
695
|
|
|
@@ -711,7 +700,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
711
700
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
712
701
|
|
|
713
702
|
"use strict";
|
|
714
|
-
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Manager = void 0;\nconst engine_io_client_1 = __webpack_require__(/*! engine.io-client */ \"./node_modules/engine.io-client/build/cjs/index.js\");\nconst socket_js_1 = __webpack_require__(/*! ./socket.js */ \"./node_modules/socket.io-client/build/cjs/socket.js\");\nconst parser = __importStar(__webpack_require__(/*! socket.io-parser */ \"./node_modules/socket.io-parser/build/cjs/index.js\"));\nconst on_js_1 = __webpack_require__(/*! ./on.js */ \"./node_modules/socket.io-client/build/cjs/on.js\");\nconst backo2_js_1 = __webpack_require__(/*! ./contrib/backo2.js */ \"./node_modules/socket.io-client/build/cjs/contrib/backo2.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/lib/esm/index.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = debug_1.default(\"socket.io-client:manager\"); // debug()\nclass Manager extends component_emitter_1.Emitter {\n constructor(uri, opts) {\n var _a;\n super();\n this.nsps = {};\n this.subs = [];\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = undefined;\n }\n opts = opts || {};\n opts.path = opts.path || \"/socket.io\";\n this.opts = opts;\n engine_io_client_1.installTimerFunctions(this, opts);\n this.reconnection(opts.reconnection !== false);\n this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);\n this.reconnectionDelay(opts.reconnectionDelay || 1000);\n this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);\n this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);\n this.backoff = new backo2_js_1.Backoff({\n min: this.reconnectionDelay(),\n max: this.reconnectionDelayMax(),\n jitter: this.randomizationFactor(),\n });\n this.timeout(null == opts.timeout ? 20000 : opts.timeout);\n this._readyState = \"closed\";\n this.uri = uri;\n const _parser = opts.parser || parser;\n this.encoder = new _parser.Encoder();\n this.decoder = new _parser.Decoder();\n this._autoConnect = opts.autoConnect !== false;\n if (this._autoConnect)\n this.open();\n }\n reconnection(v) {\n if (!arguments.length)\n return this._reconnection;\n this._reconnection = !!v;\n return this;\n }\n reconnectionAttempts(v) {\n if (v === undefined)\n return this._reconnectionAttempts;\n this._reconnectionAttempts = v;\n return this;\n }\n reconnectionDelay(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelay;\n this._reconnectionDelay = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);\n return this;\n }\n randomizationFactor(v) {\n var _a;\n if (v === undefined)\n return this._randomizationFactor;\n this._randomizationFactor = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);\n return this;\n }\n reconnectionDelayMax(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelayMax;\n this._reconnectionDelayMax = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);\n return this;\n }\n timeout(v) {\n if (!arguments.length)\n return this._timeout;\n this._timeout = v;\n return this;\n }\n /**\n * Starts trying to reconnect if reconnection is enabled and we have not\n * started reconnecting yet\n *\n * @private\n */\n maybeReconnectOnOpen() {\n // Only try to reconnect if it's the first time we're connecting\n if (!this._reconnecting &&\n this._reconnection &&\n this.backoff.attempts === 0) {\n // keeps reconnection from firing twice for the same reconnection loop\n this.reconnect();\n }\n }\n /**\n * Sets the current transport `socket`.\n *\n * @param {Function} fn - optional, callback\n * @return self\n * @public\n */\n open(fn) {\n debug(\"readyState %s\", this._readyState);\n if (~this._readyState.indexOf(\"open\"))\n return this;\n debug(\"opening %s\", this.uri);\n this.engine = new engine_io_client_1.Socket(this.uri, this.opts);\n const socket = this.engine;\n const self = this;\n this._readyState = \"opening\";\n this.skipReconnect = false;\n // emit `open`\n const openSubDestroy = on_js_1.on(socket, \"open\", function () {\n self.onopen();\n fn && fn();\n });\n const onError = (err) => {\n debug(\"error\");\n this.cleanup();\n this._readyState = \"closed\";\n this.emitReserved(\"error\", err);\n if (fn) {\n fn(err);\n }\n else {\n // Only do this if there is no fn to handle the error\n this.maybeReconnectOnOpen();\n }\n };\n // emit `error`\n const errorSub = on_js_1.on(socket, \"error\", onError);\n if (false !== this._timeout) {\n const timeout = this._timeout;\n debug(\"connect attempt will timeout after %d\", timeout);\n // set timer\n const timer = this.setTimeoutFn(() => {\n debug(\"connect attempt timed out after %d\", timeout);\n openSubDestroy();\n onError(new Error(\"timeout\"));\n socket.close();\n }, timeout);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(() => {\n this.clearTimeoutFn(timer);\n });\n }\n this.subs.push(openSubDestroy);\n this.subs.push(errorSub);\n return this;\n }\n /**\n * Alias for open()\n *\n * @return self\n * @public\n */\n connect(fn) {\n return this.open(fn);\n }\n /**\n * Called upon transport open.\n *\n * @private\n */\n onopen() {\n debug(\"open\");\n // clear old subs\n this.cleanup();\n // mark as open\n this._readyState = \"open\";\n this.emitReserved(\"open\");\n // add new subs\n const socket = this.engine;\n this.subs.push(on_js_1.on(socket, \"ping\", this.onping.bind(this)), on_js_1.on(socket, \"data\", this.ondata.bind(this)), on_js_1.on(socket, \"error\", this.onerror.bind(this)), on_js_1.on(socket, \"close\", this.onclose.bind(this)), on_js_1.on(this.decoder, \"decoded\", this.ondecoded.bind(this)));\n }\n /**\n * Called upon a ping.\n *\n * @private\n */\n onping() {\n this.emitReserved(\"ping\");\n }\n /**\n * Called with data.\n *\n * @private\n */\n ondata(data) {\n try {\n this.decoder.add(data);\n }\n catch (e) {\n this.onclose(\"parse error\", e);\n }\n }\n /**\n * Called when parser fully decodes a packet.\n *\n * @private\n */\n ondecoded(packet) {\n // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a \"parse error\"\n engine_io_client_1.nextTick(() => {\n this.emitReserved(\"packet\", packet);\n }, this.setTimeoutFn);\n }\n /**\n * Called upon socket error.\n *\n * @private\n */\n onerror(err) {\n debug(\"error\", err);\n this.emitReserved(\"error\", err);\n }\n /**\n * Creates a new socket for the given `nsp`.\n *\n * @return {Socket}\n * @public\n */\n socket(nsp, opts) {\n let socket = this.nsps[nsp];\n if (!socket) {\n socket = new socket_js_1.Socket(this, nsp, opts);\n this.nsps[nsp] = socket;\n }\n else if (this._autoConnect && !socket.active) {\n socket.connect();\n }\n return socket;\n }\n /**\n * Called upon a socket close.\n *\n * @param socket\n * @private\n */\n _destroy(socket) {\n const nsps = Object.keys(this.nsps);\n for (const nsp of nsps) {\n const socket = this.nsps[nsp];\n if (socket.active) {\n debug(\"socket %s is still active, skipping close\", nsp);\n return;\n }\n }\n this._close();\n }\n /**\n * Writes a packet.\n *\n * @param packet\n * @private\n */\n _packet(packet) {\n debug(\"writing packet %j\", packet);\n const encodedPackets = this.encoder.encode(packet);\n for (let i = 0; i < encodedPackets.length; i++) {\n this.engine.write(encodedPackets[i], packet.options);\n }\n }\n /**\n * Clean up transport subscriptions and packet buffer.\n *\n * @private\n */\n cleanup() {\n debug(\"cleanup\");\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs.length = 0;\n this.decoder.destroy();\n }\n /**\n * Close the current socket.\n *\n * @private\n */\n _close() {\n debug(\"disconnect\");\n this.skipReconnect = true;\n this._reconnecting = false;\n this.onclose(\"forced close\");\n if (this.engine)\n this.engine.close();\n }\n /**\n * Alias for close()\n *\n * @private\n */\n disconnect() {\n return this._close();\n }\n /**\n * Called upon engine close.\n *\n * @private\n */\n onclose(reason, description) {\n debug(\"closed due to %s\", reason);\n this.cleanup();\n this.backoff.reset();\n this._readyState = \"closed\";\n this.emitReserved(\"close\", reason, description);\n if (this._reconnection && !this.skipReconnect) {\n this.reconnect();\n }\n }\n /**\n * Attempt a reconnection.\n *\n * @private\n */\n reconnect() {\n if (this._reconnecting || this.skipReconnect)\n return this;\n const self = this;\n if (this.backoff.attempts >= this._reconnectionAttempts) {\n debug(\"reconnect failed\");\n this.backoff.reset();\n this.emitReserved(\"reconnect_failed\");\n this._reconnecting = false;\n }\n else {\n const delay = this.backoff.duration();\n debug(\"will wait %dms before reconnect attempt\", delay);\n this._reconnecting = true;\n const timer = this.setTimeoutFn(() => {\n if (self.skipReconnect)\n return;\n debug(\"attempting reconnect\");\n this.emitReserved(\"reconnect_attempt\", self.backoff.attempts);\n // check again for the case socket closed in above events\n if (self.skipReconnect)\n return;\n self.open((err) => {\n if (err) {\n debug(\"reconnect attempt error\");\n self._reconnecting = false;\n self.reconnect();\n this.emitReserved(\"reconnect_error\", err);\n }\n else {\n debug(\"reconnect success\");\n self.onreconnect();\n }\n });\n }, delay);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(() => {\n this.clearTimeoutFn(timer);\n });\n }\n }\n /**\n * Called upon successful reconnect.\n *\n * @private\n */\n onreconnect() {\n const attempt = this.backoff.attempts;\n this._reconnecting = false;\n this.backoff.reset();\n this.emitReserved(\"reconnect\", attempt);\n }\n}\nexports.Manager = Manager;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/manager.js?");
|
|
703
|
+
eval("\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 __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Manager = void 0;\nconst engine_io_client_1 = __webpack_require__(/*! engine.io-client */ \"./node_modules/engine.io-client/build/cjs/index.js\");\nconst socket_js_1 = __webpack_require__(/*! ./socket.js */ \"./node_modules/socket.io-client/build/cjs/socket.js\");\nconst parser = __importStar(__webpack_require__(/*! socket.io-parser */ \"./node_modules/socket.io-parser/build/cjs/index.js\"));\nconst on_js_1 = __webpack_require__(/*! ./on.js */ \"./node_modules/socket.io-client/build/cjs/on.js\");\nconst backo2_js_1 = __webpack_require__(/*! ./contrib/backo2.js */ \"./node_modules/socket.io-client/build/cjs/contrib/backo2.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-client:manager\"); // debug()\nclass Manager extends component_emitter_1.Emitter {\n constructor(uri, opts) {\n var _a;\n super();\n this.nsps = {};\n this.subs = [];\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = undefined;\n }\n opts = opts || {};\n opts.path = opts.path || \"/socket.io\";\n this.opts = opts;\n (0, engine_io_client_1.installTimerFunctions)(this, opts);\n this.reconnection(opts.reconnection !== false);\n this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);\n this.reconnectionDelay(opts.reconnectionDelay || 1000);\n this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);\n this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);\n this.backoff = new backo2_js_1.Backoff({\n min: this.reconnectionDelay(),\n max: this.reconnectionDelayMax(),\n jitter: this.randomizationFactor(),\n });\n this.timeout(null == opts.timeout ? 20000 : opts.timeout);\n this._readyState = \"closed\";\n this.uri = uri;\n const _parser = opts.parser || parser;\n this.encoder = new _parser.Encoder();\n this.decoder = new _parser.Decoder();\n this._autoConnect = opts.autoConnect !== false;\n if (this._autoConnect)\n this.open();\n }\n reconnection(v) {\n if (!arguments.length)\n return this._reconnection;\n this._reconnection = !!v;\n if (!v) {\n this.skipReconnect = true;\n }\n return this;\n }\n reconnectionAttempts(v) {\n if (v === undefined)\n return this._reconnectionAttempts;\n this._reconnectionAttempts = v;\n return this;\n }\n reconnectionDelay(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelay;\n this._reconnectionDelay = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);\n return this;\n }\n randomizationFactor(v) {\n var _a;\n if (v === undefined)\n return this._randomizationFactor;\n this._randomizationFactor = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);\n return this;\n }\n reconnectionDelayMax(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelayMax;\n this._reconnectionDelayMax = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);\n return this;\n }\n timeout(v) {\n if (!arguments.length)\n return this._timeout;\n this._timeout = v;\n return this;\n }\n /**\n * Starts trying to reconnect if reconnection is enabled and we have not\n * started reconnecting yet\n *\n * @private\n */\n maybeReconnectOnOpen() {\n // Only try to reconnect if it's the first time we're connecting\n if (!this._reconnecting &&\n this._reconnection &&\n this.backoff.attempts === 0) {\n // keeps reconnection from firing twice for the same reconnection loop\n this.reconnect();\n }\n }\n /**\n * Sets the current transport `socket`.\n *\n * @param {Function} fn - optional, callback\n * @return self\n * @public\n */\n open(fn) {\n debug(\"readyState %s\", this._readyState);\n if (~this._readyState.indexOf(\"open\"))\n return this;\n debug(\"opening %s\", this.uri);\n this.engine = new engine_io_client_1.Socket(this.uri, this.opts);\n const socket = this.engine;\n const self = this;\n this._readyState = \"opening\";\n this.skipReconnect = false;\n // emit `open`\n const openSubDestroy = (0, on_js_1.on)(socket, \"open\", function () {\n self.onopen();\n fn && fn();\n });\n const onError = (err) => {\n debug(\"error\");\n this.cleanup();\n this._readyState = \"closed\";\n this.emitReserved(\"error\", err);\n if (fn) {\n fn(err);\n }\n else {\n // Only do this if there is no fn to handle the error\n this.maybeReconnectOnOpen();\n }\n };\n // emit `error`\n const errorSub = (0, on_js_1.on)(socket, \"error\", onError);\n if (false !== this._timeout) {\n const timeout = this._timeout;\n debug(\"connect attempt will timeout after %d\", timeout);\n // set timer\n const timer = this.setTimeoutFn(() => {\n debug(\"connect attempt timed out after %d\", timeout);\n openSubDestroy();\n onError(new Error(\"timeout\"));\n socket.close();\n }, timeout);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(() => {\n this.clearTimeoutFn(timer);\n });\n }\n this.subs.push(openSubDestroy);\n this.subs.push(errorSub);\n return this;\n }\n /**\n * Alias for open()\n *\n * @return self\n * @public\n */\n connect(fn) {\n return this.open(fn);\n }\n /**\n * Called upon transport open.\n *\n * @private\n */\n onopen() {\n debug(\"open\");\n // clear old subs\n this.cleanup();\n // mark as open\n this._readyState = \"open\";\n this.emitReserved(\"open\");\n // add new subs\n const socket = this.engine;\n this.subs.push((0, on_js_1.on)(socket, \"ping\", this.onping.bind(this)), (0, on_js_1.on)(socket, \"data\", this.ondata.bind(this)), (0, on_js_1.on)(socket, \"error\", this.onerror.bind(this)), (0, on_js_1.on)(socket, \"close\", this.onclose.bind(this)), \n // @ts-ignore\n (0, on_js_1.on)(this.decoder, \"decoded\", this.ondecoded.bind(this)));\n }\n /**\n * Called upon a ping.\n *\n * @private\n */\n onping() {\n this.emitReserved(\"ping\");\n }\n /**\n * Called with data.\n *\n * @private\n */\n ondata(data) {\n try {\n this.decoder.add(data);\n }\n catch (e) {\n this.onclose(\"parse error\", e);\n }\n }\n /**\n * Called when parser fully decodes a packet.\n *\n * @private\n */\n ondecoded(packet) {\n // the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a \"parse error\"\n (0, engine_io_client_1.nextTick)(() => {\n this.emitReserved(\"packet\", packet);\n }, this.setTimeoutFn);\n }\n /**\n * Called upon socket error.\n *\n * @private\n */\n onerror(err) {\n debug(\"error\", err);\n this.emitReserved(\"error\", err);\n }\n /**\n * Creates a new socket for the given `nsp`.\n *\n * @return {Socket}\n * @public\n */\n socket(nsp, opts) {\n let socket = this.nsps[nsp];\n if (!socket) {\n socket = new socket_js_1.Socket(this, nsp, opts);\n this.nsps[nsp] = socket;\n }\n else if (this._autoConnect && !socket.active) {\n socket.connect();\n }\n return socket;\n }\n /**\n * Called upon a socket close.\n *\n * @param socket\n * @private\n */\n _destroy(socket) {\n const nsps = Object.keys(this.nsps);\n for (const nsp of nsps) {\n const socket = this.nsps[nsp];\n if (socket.active) {\n debug(\"socket %s is still active, skipping close\", nsp);\n return;\n }\n }\n this._close();\n }\n /**\n * Writes a packet.\n *\n * @param packet\n * @private\n */\n _packet(packet) {\n debug(\"writing packet %j\", packet);\n const encodedPackets = this.encoder.encode(packet);\n for (let i = 0; i < encodedPackets.length; i++) {\n this.engine.write(encodedPackets[i], packet.options);\n }\n }\n /**\n * Clean up transport subscriptions and packet buffer.\n *\n * @private\n */\n cleanup() {\n debug(\"cleanup\");\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs.length = 0;\n this.decoder.destroy();\n }\n /**\n * Close the current socket.\n *\n * @private\n */\n _close() {\n debug(\"disconnect\");\n this.skipReconnect = true;\n this._reconnecting = false;\n this.onclose(\"forced close\");\n }\n /**\n * Alias for close()\n *\n * @private\n */\n disconnect() {\n return this._close();\n }\n /**\n * Called when:\n *\n * - the low-level engine is closed\n * - the parser encountered a badly formatted packet\n * - all sockets are disconnected\n *\n * @private\n */\n onclose(reason, description) {\n var _a;\n debug(\"closed due to %s\", reason);\n this.cleanup();\n (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close();\n this.backoff.reset();\n this._readyState = \"closed\";\n this.emitReserved(\"close\", reason, description);\n if (this._reconnection && !this.skipReconnect) {\n this.reconnect();\n }\n }\n /**\n * Attempt a reconnection.\n *\n * @private\n */\n reconnect() {\n if (this._reconnecting || this.skipReconnect)\n return this;\n const self = this;\n if (this.backoff.attempts >= this._reconnectionAttempts) {\n debug(\"reconnect failed\");\n this.backoff.reset();\n this.emitReserved(\"reconnect_failed\");\n this._reconnecting = false;\n }\n else {\n const delay = this.backoff.duration();\n debug(\"will wait %dms before reconnect attempt\", delay);\n this._reconnecting = true;\n const timer = this.setTimeoutFn(() => {\n if (self.skipReconnect)\n return;\n debug(\"attempting reconnect\");\n this.emitReserved(\"reconnect_attempt\", self.backoff.attempts);\n // check again for the case socket closed in above events\n if (self.skipReconnect)\n return;\n self.open((err) => {\n if (err) {\n debug(\"reconnect attempt error\");\n self._reconnecting = false;\n self.reconnect();\n this.emitReserved(\"reconnect_error\", err);\n }\n else {\n debug(\"reconnect success\");\n self.onreconnect();\n }\n });\n }, delay);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(() => {\n this.clearTimeoutFn(timer);\n });\n }\n }\n /**\n * Called upon successful reconnect.\n *\n * @private\n */\n onreconnect() {\n const attempt = this.backoff.attempts;\n this._reconnecting = false;\n this.backoff.reset();\n this.emitReserved(\"reconnect\", attempt);\n }\n}\nexports.Manager = Manager;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/manager.js?");
|
|
715
704
|
|
|
716
705
|
/***/ }),
|
|
717
706
|
|
|
@@ -722,7 +711,7 @@ eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ?
|
|
|
722
711
|
/***/ ((__unused_webpack_module, exports) => {
|
|
723
712
|
|
|
724
713
|
"use strict";
|
|
725
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.on =
|
|
714
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.on = on;\nfunction on(obj, ev, fn) {\n obj.on(ev, fn);\n return function subDestroy() {\n obj.off(ev, fn);\n };\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/on.js?");
|
|
726
715
|
|
|
727
716
|
/***/ }),
|
|
728
717
|
|
|
@@ -733,7 +722,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
733
722
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
734
723
|
|
|
735
724
|
"use strict";
|
|
736
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Socket = void 0;\nconst socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ \"./node_modules/socket.io-parser/build/cjs/index.js\");\nconst on_js_1 = __webpack_require__(/*! ./on.js */ \"./node_modules/socket.io-client/build/cjs/on.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/lib/esm/index.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = debug_1.default(\"socket.io-client:socket\"); // debug()\n/**\n * Internal events.\n * These events can't be emitted by the user.\n */\nconst RESERVED_EVENTS = Object.freeze({\n connect: 1,\n connect_error: 1,\n disconnect: 1,\n disconnecting: 1,\n // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener\n newListener: 1,\n removeListener: 1,\n});\n/**\n * A Socket is the fundamental class for interacting with the server.\n *\n * A Socket belongs to a certain Namespace (by default /) and uses an underlying {@link Manager} to communicate.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(\"connected\");\n * });\n *\n * // send an event to the server\n * socket.emit(\"foo\", \"bar\");\n *\n * socket.on(\"foobar\", () => {\n * // an event was received from the server\n * });\n *\n * // upon disconnection\n * socket.on(\"disconnect\", (reason) => {\n * console.log(`disconnected due to ${reason}`);\n * });\n */\nclass Socket extends component_emitter_1.Emitter {\n /**\n * `Socket` constructor.\n */\n constructor(io, nsp, opts) {\n super();\n /**\n * Whether the socket is currently connected to the server.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(socket.connected); // true\n * });\n *\n * socket.on(\"disconnect\", () => {\n * console.log(socket.connected); // false\n * });\n */\n this.connected = false;\n /**\n * Whether the connection state was recovered after a temporary disconnection. In that case, any missed packets will\n * be transmitted by the server.\n */\n this.recovered = false;\n /**\n * Buffer for packets received before the CONNECT packet\n */\n this.receiveBuffer = [];\n /**\n * Buffer for packets that will be sent once the socket is connected\n */\n this.sendBuffer = [];\n /**\n * The queue of packets to be sent with retry in case of failure.\n *\n * Packets are sent one by one, each waiting for the server acknowledgement, in order to guarantee the delivery order.\n * @private\n */\n this._queue = [];\n /**\n * A sequence to generate the ID of the {@link QueuedPacket}.\n * @private\n */\n this._queueSeq = 0;\n this.ids = 0;\n /**\n * A map containing acknowledgement handlers.\n *\n * The `withError` attribute is used to differentiate handlers that accept an error as first argument:\n *\n * - `socket.emit(\"test\", (err, value) => { ... })` with `ackTimeout` option\n * - `socket.timeout(5000).emit(\"test\", (err, value) => { ... })`\n * - `const value = await socket.emitWithAck(\"test\")`\n *\n * From those that don't:\n *\n * - `socket.emit(\"test\", (value) => { ... });`\n *\n * In the first case, the handlers will be called with an error when:\n *\n * - the timeout is reached\n * - the socket gets disconnected\n *\n * In the second case, the handlers will be simply discarded upon disconnection, since the client will never receive\n * an acknowledgement from the server.\n *\n * @private\n */\n this.acks = {};\n this.flags = {};\n this.io = io;\n this.nsp = nsp;\n if (opts && opts.auth) {\n this.auth = opts.auth;\n }\n this._opts = Object.assign({}, opts);\n if (this.io._autoConnect)\n this.open();\n }\n /**\n * Whether the socket is currently disconnected\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(socket.disconnected); // false\n * });\n *\n * socket.on(\"disconnect\", () => {\n * console.log(socket.disconnected); // true\n * });\n */\n get disconnected() {\n return !this.connected;\n }\n /**\n * Subscribe to open, close and packet events\n *\n * @private\n */\n subEvents() {\n if (this.subs)\n return;\n const io = this.io;\n this.subs = [\n on_js_1.on(io, \"open\", this.onopen.bind(this)),\n on_js_1.on(io, \"packet\", this.onpacket.bind(this)),\n on_js_1.on(io, \"error\", this.onerror.bind(this)),\n on_js_1.on(io, \"close\", this.onclose.bind(this)),\n ];\n }\n /**\n * Whether the Socket will try to reconnect when its Manager connects or reconnects.\n *\n * @example\n * const socket = io();\n *\n * console.log(socket.active); // true\n *\n * socket.on(\"disconnect\", (reason) => {\n * if (reason === \"io server disconnect\") {\n * // the disconnection was initiated by the server, you need to manually reconnect\n * console.log(socket.active); // false\n * }\n * // else the socket will automatically try to reconnect\n * console.log(socket.active); // true\n * });\n */\n get active() {\n return !!this.subs;\n }\n /**\n * \"Opens\" the socket.\n *\n * @example\n * const socket = io({\n * autoConnect: false\n * });\n *\n * socket.connect();\n */\n connect() {\n if (this.connected)\n return this;\n this.subEvents();\n if (!this.io[\"_reconnecting\"])\n this.io.open(); // ensure open\n if (\"open\" === this.io._readyState)\n this.onopen();\n return this;\n }\n /**\n * Alias for {@link connect()}.\n */\n open() {\n return this.connect();\n }\n /**\n * Sends a `message` event.\n *\n * This method mimics the WebSocket.send() method.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send\n *\n * @example\n * socket.send(\"hello\");\n *\n * // this is equivalent to\n * socket.emit(\"message\", \"hello\");\n *\n * @return self\n */\n send(...args) {\n args.unshift(\"message\");\n this.emit.apply(this, args);\n return this;\n }\n /**\n * Override `emit`.\n * If the event is in `events`, it's emitted normally.\n *\n * @example\n * socket.emit(\"hello\", \"world\");\n *\n * // all serializable datastructures are supported (no need to call JSON.stringify)\n * socket.emit(\"hello\", 1, \"2\", { 3: [\"4\"], 5: Uint8Array.from([6]) });\n *\n * // with an acknowledgement from the server\n * socket.emit(\"hello\", \"world\", (val) => {\n * // ...\n * });\n *\n * @return self\n */\n emit(ev, ...args) {\n if (RESERVED_EVENTS.hasOwnProperty(ev)) {\n throw new Error('\"' + ev.toString() + '\" is a reserved event name');\n }\n args.unshift(ev);\n if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {\n this._addToQueue(args);\n return this;\n }\n const packet = {\n type: socket_io_parser_1.PacketType.EVENT,\n data: args,\n };\n packet.options = {};\n packet.options.compress = this.flags.compress !== false;\n // event ack callback\n if (\"function\" === typeof args[args.length - 1]) {\n const id = this.ids++;\n debug(\"emitting packet with ack id %d\", id);\n const ack = args.pop();\n this._registerAckCallback(id, ack);\n packet.id = id;\n }\n const isTransportWritable = this.io.engine &&\n this.io.engine.transport &&\n this.io.engine.transport.writable;\n const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected);\n if (discardPacket) {\n debug(\"discard packet as the transport is not currently writable\");\n }\n else if (this.connected) {\n this.notifyOutgoingListeners(packet);\n this.packet(packet);\n }\n else {\n this.sendBuffer.push(packet);\n }\n this.flags = {};\n return this;\n }\n /**\n * @private\n */\n _registerAckCallback(id, ack) {\n var _a;\n const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;\n if (timeout === undefined) {\n this.acks[id] = ack;\n return;\n }\n // @ts-ignore\n const timer = this.io.setTimeoutFn(() => {\n delete this.acks[id];\n for (let i = 0; i < this.sendBuffer.length; i++) {\n if (this.sendBuffer[i].id === id) {\n debug(\"removing packet with ack id %d from the buffer\", id);\n this.sendBuffer.splice(i, 1);\n }\n }\n debug(\"event with ack id %d has timed out after %d ms\", id, timeout);\n ack.call(this, new Error(\"operation has timed out\"));\n }, timeout);\n const fn = (...args) => {\n // @ts-ignore\n this.io.clearTimeoutFn(timer);\n ack.apply(this, args);\n };\n fn.withError = true;\n this.acks[id] = fn;\n }\n /**\n * Emits an event and waits for an acknowledgement\n *\n * @example\n * // without timeout\n * const response = await socket.emitWithAck(\"hello\", \"world\");\n *\n * // with a specific timeout\n * try {\n * const response = await socket.timeout(1000).emitWithAck(\"hello\", \"world\");\n * } catch (err) {\n * // the server did not acknowledge the event in the given delay\n * }\n *\n * @return a Promise that will be fulfilled when the server acknowledges the event\n */\n emitWithAck(ev, ...args) {\n return new Promise((resolve, reject) => {\n const fn = (arg1, arg2) => {\n return arg1 ? reject(arg1) : resolve(arg2);\n };\n fn.withError = true;\n args.push(fn);\n this.emit(ev, ...args);\n });\n }\n /**\n * Add the packet to the queue.\n * @param args\n * @private\n */\n _addToQueue(args) {\n let ack;\n if (typeof args[args.length - 1] === \"function\") {\n ack = args.pop();\n }\n const packet = {\n id: this._queueSeq++,\n tryCount: 0,\n pending: false,\n args,\n flags: Object.assign({ fromQueue: true }, this.flags),\n };\n args.push((err, ...responseArgs) => {\n if (packet !== this._queue[0]) {\n // the packet has already been acknowledged\n return;\n }\n const hasError = err !== null;\n if (hasError) {\n if (packet.tryCount > this._opts.retries) {\n debug(\"packet [%d] is discarded after %d tries\", packet.id, packet.tryCount);\n this._queue.shift();\n if (ack) {\n ack(err);\n }\n }\n }\n else {\n debug(\"packet [%d] was successfully sent\", packet.id);\n this._queue.shift();\n if (ack) {\n ack(null, ...responseArgs);\n }\n }\n packet.pending = false;\n return this._drainQueue();\n });\n this._queue.push(packet);\n this._drainQueue();\n }\n /**\n * Send the first packet of the queue, and wait for an acknowledgement from the server.\n * @param force - whether to resend a packet that has not been acknowledged yet\n *\n * @private\n */\n _drainQueue(force = false) {\n debug(\"draining queue\");\n if (!this.connected || this._queue.length === 0) {\n return;\n }\n const packet = this._queue[0];\n if (packet.pending && !force) {\n debug(\"packet [%d] has already been sent and is waiting for an ack\", packet.id);\n return;\n }\n packet.pending = true;\n packet.tryCount++;\n debug(\"sending packet [%d] (try n°%d)\", packet.id, packet.tryCount);\n this.flags = packet.flags;\n this.emit.apply(this, packet.args);\n }\n /**\n * Sends a packet.\n *\n * @param packet\n * @private\n */\n packet(packet) {\n packet.nsp = this.nsp;\n this.io._packet(packet);\n }\n /**\n * Called upon engine `open`.\n *\n * @private\n */\n onopen() {\n debug(\"transport is open - connecting\");\n if (typeof this.auth == \"function\") {\n this.auth((data) => {\n this._sendConnectPacket(data);\n });\n }\n else {\n this._sendConnectPacket(this.auth);\n }\n }\n /**\n * Sends a CONNECT packet to initiate the Socket.IO session.\n *\n * @param data\n * @private\n */\n _sendConnectPacket(data) {\n this.packet({\n type: socket_io_parser_1.PacketType.CONNECT,\n data: this._pid\n ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data)\n : data,\n });\n }\n /**\n * Called upon engine or manager `error`.\n *\n * @param err\n * @private\n */\n onerror(err) {\n if (!this.connected) {\n this.emitReserved(\"connect_error\", err);\n }\n }\n /**\n * Called upon engine `close`.\n *\n * @param reason\n * @param description\n * @private\n */\n onclose(reason, description) {\n debug(\"close (%s)\", reason);\n this.connected = false;\n delete this.id;\n this.emitReserved(\"disconnect\", reason, description);\n this._clearAcks();\n }\n /**\n * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from\n * the server.\n *\n * @private\n */\n _clearAcks() {\n Object.keys(this.acks).forEach((id) => {\n const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);\n if (!isBuffered) {\n // note: handlers that do not accept an error as first argument are ignored here\n const ack = this.acks[id];\n delete this.acks[id];\n if (ack.withError) {\n ack.call(this, new Error(\"socket has been disconnected\"));\n }\n }\n });\n }\n /**\n * Called with socket packet.\n *\n * @param packet\n * @private\n */\n onpacket(packet) {\n const sameNamespace = packet.nsp === this.nsp;\n if (!sameNamespace)\n return;\n switch (packet.type) {\n case socket_io_parser_1.PacketType.CONNECT:\n if (packet.data && packet.data.sid) {\n this.onconnect(packet.data.sid, packet.data.pid);\n }\n else {\n this.emitReserved(\"connect_error\", new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));\n }\n break;\n case socket_io_parser_1.PacketType.EVENT:\n case socket_io_parser_1.PacketType.BINARY_EVENT:\n this.onevent(packet);\n break;\n case socket_io_parser_1.PacketType.ACK:\n case socket_io_parser_1.PacketType.BINARY_ACK:\n this.onack(packet);\n break;\n case socket_io_parser_1.PacketType.DISCONNECT:\n this.ondisconnect();\n break;\n case socket_io_parser_1.PacketType.CONNECT_ERROR:\n this.destroy();\n const err = new Error(packet.data.message);\n // @ts-ignore\n err.data = packet.data.data;\n this.emitReserved(\"connect_error\", err);\n break;\n }\n }\n /**\n * Called upon a server event.\n *\n * @param packet\n * @private\n */\n onevent(packet) {\n const args = packet.data || [];\n debug(\"emitting event %j\", args);\n if (null != packet.id) {\n debug(\"attaching ack callback to event\");\n args.push(this.ack(packet.id));\n }\n if (this.connected) {\n this.emitEvent(args);\n }\n else {\n this.receiveBuffer.push(Object.freeze(args));\n }\n }\n emitEvent(args) {\n if (this._anyListeners && this._anyListeners.length) {\n const listeners = this._anyListeners.slice();\n for (const listener of listeners) {\n listener.apply(this, args);\n }\n }\n super.emit.apply(this, args);\n if (this._pid && args.length && typeof args[args.length - 1] === \"string\") {\n this._lastOffset = args[args.length - 1];\n }\n }\n /**\n * Produces an ack callback to emit with an event.\n *\n * @private\n */\n ack(id) {\n const self = this;\n let sent = false;\n return function (...args) {\n // prevent double callbacks\n if (sent)\n return;\n sent = true;\n debug(\"sending ack %j\", args);\n self.packet({\n type: socket_io_parser_1.PacketType.ACK,\n id: id,\n data: args,\n });\n };\n }\n /**\n * Called upon a server acknowledgement.\n *\n * @param packet\n * @private\n */\n onack(packet) {\n const ack = this.acks[packet.id];\n if (typeof ack !== \"function\") {\n debug(\"bad ack %s\", packet.id);\n return;\n }\n delete this.acks[packet.id];\n debug(\"calling ack %s with %j\", packet.id, packet.data);\n // @ts-ignore FIXME ack is incorrectly inferred as 'never'\n if (ack.withError) {\n packet.data.unshift(null);\n }\n // @ts-ignore\n ack.apply(this, packet.data);\n }\n /**\n * Called upon server connect.\n *\n * @private\n */\n onconnect(id, pid) {\n debug(\"socket connected with id %s\", id);\n this.id = id;\n this.recovered = pid && this._pid === pid;\n this._pid = pid; // defined only if connection state recovery is enabled\n this.connected = true;\n this.emitBuffered();\n this.emitReserved(\"connect\");\n this._drainQueue(true);\n }\n /**\n * Emit buffered events (received and emitted).\n *\n * @private\n */\n emitBuffered() {\n this.receiveBuffer.forEach((args) => this.emitEvent(args));\n this.receiveBuffer = [];\n this.sendBuffer.forEach((packet) => {\n this.notifyOutgoingListeners(packet);\n this.packet(packet);\n });\n this.sendBuffer = [];\n }\n /**\n * Called upon server disconnect.\n *\n * @private\n */\n ondisconnect() {\n debug(\"server disconnect (%s)\", this.nsp);\n this.destroy();\n this.onclose(\"io server disconnect\");\n }\n /**\n * Called upon forced client/server side disconnections,\n * this method ensures the manager stops tracking us and\n * that reconnections don't get triggered for this.\n *\n * @private\n */\n destroy() {\n if (this.subs) {\n // clean subscriptions to avoid reconnections\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs = undefined;\n }\n this.io[\"_destroy\"](this);\n }\n /**\n * Disconnects the socket manually. In that case, the socket will not try to reconnect.\n *\n * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"disconnect\", (reason) => {\n * // console.log(reason); prints \"io client disconnect\"\n * });\n *\n * socket.disconnect();\n *\n * @return self\n */\n disconnect() {\n if (this.connected) {\n debug(\"performing disconnect (%s)\", this.nsp);\n this.packet({ type: socket_io_parser_1.PacketType.DISCONNECT });\n }\n // remove socket from pool\n this.destroy();\n if (this.connected) {\n // fire events\n this.onclose(\"io client disconnect\");\n }\n return this;\n }\n /**\n * Alias for {@link disconnect()}.\n *\n * @return self\n */\n close() {\n return this.disconnect();\n }\n /**\n * Sets the compress flag.\n *\n * @example\n * socket.compress(false).emit(\"hello\");\n *\n * @param compress - if `true`, compresses the sending data\n * @return self\n */\n compress(compress) {\n this.flags.compress = compress;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not\n * ready to send messages.\n *\n * @example\n * socket.volatile.emit(\"hello\"); // the server may or may not receive it\n *\n * @returns self\n */\n get volatile() {\n this.flags.volatile = true;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the callback will be called with an error when the\n * given number of milliseconds have elapsed without an acknowledgement from the server:\n *\n * @example\n * socket.timeout(5000).emit(\"my-event\", (err) => {\n * if (err) {\n * // the server did not acknowledge the event in the given delay\n * }\n * });\n *\n * @returns self\n */\n timeout(timeout) {\n this.flags.timeout = timeout;\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback.\n *\n * @example\n * socket.onAny((event, ...args) => {\n * console.log(`got ${event}`);\n * });\n *\n * @param listener\n */\n onAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.push(listener);\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback. The listener is added to the beginning of the listeners array.\n *\n * @example\n * socket.prependAny((event, ...args) => {\n * console.log(`got event ${event}`);\n * });\n *\n * @param listener\n */\n prependAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.unshift(listener);\n return this;\n }\n /**\n * Removes the listener that will be fired when any event is emitted.\n *\n * @example\n * const catchAllListener = (event, ...args) => {\n * console.log(`got event ${event}`);\n * }\n *\n * socket.onAny(catchAllListener);\n *\n * // remove a specific listener\n * socket.offAny(catchAllListener);\n *\n * // or remove all listeners\n * socket.offAny();\n *\n * @param listener\n */\n offAny(listener) {\n if (!this._anyListeners) {\n return this;\n }\n if (listener) {\n const listeners = this._anyListeners;\n for (let i = 0; i < listeners.length; i++) {\n if (listener === listeners[i]) {\n listeners.splice(i, 1);\n return this;\n }\n }\n }\n else {\n this._anyListeners = [];\n }\n return this;\n }\n /**\n * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,\n * e.g. to remove listeners.\n */\n listenersAny() {\n return this._anyListeners || [];\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback.\n *\n * Note: acknowledgements sent to the server are not included.\n *\n * @example\n * socket.onAnyOutgoing((event, ...args) => {\n * console.log(`sent event ${event}`);\n * });\n *\n * @param listener\n */\n onAnyOutgoing(listener) {\n this._anyOutgoingListeners = this._anyOutgoingListeners || [];\n this._anyOutgoingListeners.push(listener);\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback. The listener is added to the beginning of the listeners array.\n *\n * Note: acknowledgements sent to the server are not included.\n *\n * @example\n * socket.prependAnyOutgoing((event, ...args) => {\n * console.log(`sent event ${event}`);\n * });\n *\n * @param listener\n */\n prependAnyOutgoing(listener) {\n this._anyOutgoingListeners = this._anyOutgoingListeners || [];\n this._anyOutgoingListeners.unshift(listener);\n return this;\n }\n /**\n * Removes the listener that will be fired when any event is emitted.\n *\n * @example\n * const catchAllListener = (event, ...args) => {\n * console.log(`sent event ${event}`);\n * }\n *\n * socket.onAnyOutgoing(catchAllListener);\n *\n * // remove a specific listener\n * socket.offAnyOutgoing(catchAllListener);\n *\n * // or remove all listeners\n * socket.offAnyOutgoing();\n *\n * @param [listener] - the catch-all listener (optional)\n */\n offAnyOutgoing(listener) {\n if (!this._anyOutgoingListeners) {\n return this;\n }\n if (listener) {\n const listeners = this._anyOutgoingListeners;\n for (let i = 0; i < listeners.length; i++) {\n if (listener === listeners[i]) {\n listeners.splice(i, 1);\n return this;\n }\n }\n }\n else {\n this._anyOutgoingListeners = [];\n }\n return this;\n }\n /**\n * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,\n * e.g. to remove listeners.\n */\n listenersAnyOutgoing() {\n return this._anyOutgoingListeners || [];\n }\n /**\n * Notify the listeners for each packet sent\n *\n * @param packet\n *\n * @private\n */\n notifyOutgoingListeners(packet) {\n if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {\n const listeners = this._anyOutgoingListeners.slice();\n for (const listener of listeners) {\n listener.apply(this, packet.data);\n }\n }\n }\n}\nexports.Socket = Socket;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/socket.js?");
|
|
725
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Socket = void 0;\nconst socket_io_parser_1 = __webpack_require__(/*! socket.io-parser */ \"./node_modules/socket.io-parser/build/cjs/index.js\");\nconst on_js_1 = __webpack_require__(/*! ./on.js */ \"./node_modules/socket.io-client/build/cjs/on.js\");\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-client:socket\"); // debug()\n/**\n * Internal events.\n * These events can't be emitted by the user.\n */\nconst RESERVED_EVENTS = Object.freeze({\n connect: 1,\n connect_error: 1,\n disconnect: 1,\n disconnecting: 1,\n // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener\n newListener: 1,\n removeListener: 1,\n});\n/**\n * A Socket is the fundamental class for interacting with the server.\n *\n * A Socket belongs to a certain Namespace (by default /) and uses an underlying {@link Manager} to communicate.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(\"connected\");\n * });\n *\n * // send an event to the server\n * socket.emit(\"foo\", \"bar\");\n *\n * socket.on(\"foobar\", () => {\n * // an event was received from the server\n * });\n *\n * // upon disconnection\n * socket.on(\"disconnect\", (reason) => {\n * console.log(`disconnected due to ${reason}`);\n * });\n */\nclass Socket extends component_emitter_1.Emitter {\n /**\n * `Socket` constructor.\n */\n constructor(io, nsp, opts) {\n super();\n /**\n * Whether the socket is currently connected to the server.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(socket.connected); // true\n * });\n *\n * socket.on(\"disconnect\", () => {\n * console.log(socket.connected); // false\n * });\n */\n this.connected = false;\n /**\n * Whether the connection state was recovered after a temporary disconnection. In that case, any missed packets will\n * be transmitted by the server.\n */\n this.recovered = false;\n /**\n * Buffer for packets received before the CONNECT packet\n */\n this.receiveBuffer = [];\n /**\n * Buffer for packets that will be sent once the socket is connected\n */\n this.sendBuffer = [];\n /**\n * The queue of packets to be sent with retry in case of failure.\n *\n * Packets are sent one by one, each waiting for the server acknowledgement, in order to guarantee the delivery order.\n * @private\n */\n this._queue = [];\n /**\n * A sequence to generate the ID of the {@link QueuedPacket}.\n * @private\n */\n this._queueSeq = 0;\n this.ids = 0;\n /**\n * A map containing acknowledgement handlers.\n *\n * The `withError` attribute is used to differentiate handlers that accept an error as first argument:\n *\n * - `socket.emit(\"test\", (err, value) => { ... })` with `ackTimeout` option\n * - `socket.timeout(5000).emit(\"test\", (err, value) => { ... })`\n * - `const value = await socket.emitWithAck(\"test\")`\n *\n * From those that don't:\n *\n * - `socket.emit(\"test\", (value) => { ... });`\n *\n * In the first case, the handlers will be called with an error when:\n *\n * - the timeout is reached\n * - the socket gets disconnected\n *\n * In the second case, the handlers will be simply discarded upon disconnection, since the client will never receive\n * an acknowledgement from the server.\n *\n * @private\n */\n this.acks = {};\n this.flags = {};\n this.io = io;\n this.nsp = nsp;\n if (opts && opts.auth) {\n this.auth = opts.auth;\n }\n this._opts = Object.assign({}, opts);\n if (this.io._autoConnect)\n this.open();\n }\n /**\n * Whether the socket is currently disconnected\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"connect\", () => {\n * console.log(socket.disconnected); // false\n * });\n *\n * socket.on(\"disconnect\", () => {\n * console.log(socket.disconnected); // true\n * });\n */\n get disconnected() {\n return !this.connected;\n }\n /**\n * Subscribe to open, close and packet events\n *\n * @private\n */\n subEvents() {\n if (this.subs)\n return;\n const io = this.io;\n this.subs = [\n (0, on_js_1.on)(io, \"open\", this.onopen.bind(this)),\n (0, on_js_1.on)(io, \"packet\", this.onpacket.bind(this)),\n (0, on_js_1.on)(io, \"error\", this.onerror.bind(this)),\n (0, on_js_1.on)(io, \"close\", this.onclose.bind(this)),\n ];\n }\n /**\n * Whether the Socket will try to reconnect when its Manager connects or reconnects.\n *\n * @example\n * const socket = io();\n *\n * console.log(socket.active); // true\n *\n * socket.on(\"disconnect\", (reason) => {\n * if (reason === \"io server disconnect\") {\n * // the disconnection was initiated by the server, you need to manually reconnect\n * console.log(socket.active); // false\n * }\n * // else the socket will automatically try to reconnect\n * console.log(socket.active); // true\n * });\n */\n get active() {\n return !!this.subs;\n }\n /**\n * \"Opens\" the socket.\n *\n * @example\n * const socket = io({\n * autoConnect: false\n * });\n *\n * socket.connect();\n */\n connect() {\n if (this.connected)\n return this;\n this.subEvents();\n if (!this.io[\"_reconnecting\"])\n this.io.open(); // ensure open\n if (\"open\" === this.io._readyState)\n this.onopen();\n return this;\n }\n /**\n * Alias for {@link connect()}.\n */\n open() {\n return this.connect();\n }\n /**\n * Sends a `message` event.\n *\n * This method mimics the WebSocket.send() method.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send\n *\n * @example\n * socket.send(\"hello\");\n *\n * // this is equivalent to\n * socket.emit(\"message\", \"hello\");\n *\n * @return self\n */\n send(...args) {\n args.unshift(\"message\");\n this.emit.apply(this, args);\n return this;\n }\n /**\n * Override `emit`.\n * If the event is in `events`, it's emitted normally.\n *\n * @example\n * socket.emit(\"hello\", \"world\");\n *\n * // all serializable datastructures are supported (no need to call JSON.stringify)\n * socket.emit(\"hello\", 1, \"2\", { 3: [\"4\"], 5: Uint8Array.from([6]) });\n *\n * // with an acknowledgement from the server\n * socket.emit(\"hello\", \"world\", (val) => {\n * // ...\n * });\n *\n * @return self\n */\n emit(ev, ...args) {\n var _a, _b, _c;\n if (RESERVED_EVENTS.hasOwnProperty(ev)) {\n throw new Error('\"' + ev.toString() + '\" is a reserved event name');\n }\n args.unshift(ev);\n if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {\n this._addToQueue(args);\n return this;\n }\n const packet = {\n type: socket_io_parser_1.PacketType.EVENT,\n data: args,\n };\n packet.options = {};\n packet.options.compress = this.flags.compress !== false;\n // event ack callback\n if (\"function\" === typeof args[args.length - 1]) {\n const id = this.ids++;\n debug(\"emitting packet with ack id %d\", id);\n const ack = args.pop();\n this._registerAckCallback(id, ack);\n packet.id = id;\n }\n const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable;\n const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());\n const discardPacket = this.flags.volatile && !isTransportWritable;\n if (discardPacket) {\n debug(\"discard packet as the transport is not currently writable\");\n }\n else if (isConnected) {\n this.notifyOutgoingListeners(packet);\n this.packet(packet);\n }\n else {\n this.sendBuffer.push(packet);\n }\n this.flags = {};\n return this;\n }\n /**\n * @private\n */\n _registerAckCallback(id, ack) {\n var _a;\n const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;\n if (timeout === undefined) {\n this.acks[id] = ack;\n return;\n }\n // @ts-ignore\n const timer = this.io.setTimeoutFn(() => {\n delete this.acks[id];\n for (let i = 0; i < this.sendBuffer.length; i++) {\n if (this.sendBuffer[i].id === id) {\n debug(\"removing packet with ack id %d from the buffer\", id);\n this.sendBuffer.splice(i, 1);\n }\n }\n debug(\"event with ack id %d has timed out after %d ms\", id, timeout);\n ack.call(this, new Error(\"operation has timed out\"));\n }, timeout);\n const fn = (...args) => {\n // @ts-ignore\n this.io.clearTimeoutFn(timer);\n ack.apply(this, args);\n };\n fn.withError = true;\n this.acks[id] = fn;\n }\n /**\n * Emits an event and waits for an acknowledgement\n *\n * @example\n * // without timeout\n * const response = await socket.emitWithAck(\"hello\", \"world\");\n *\n * // with a specific timeout\n * try {\n * const response = await socket.timeout(1000).emitWithAck(\"hello\", \"world\");\n * } catch (err) {\n * // the server did not acknowledge the event in the given delay\n * }\n *\n * @return a Promise that will be fulfilled when the server acknowledges the event\n */\n emitWithAck(ev, ...args) {\n return new Promise((resolve, reject) => {\n const fn = (arg1, arg2) => {\n return arg1 ? reject(arg1) : resolve(arg2);\n };\n fn.withError = true;\n args.push(fn);\n this.emit(ev, ...args);\n });\n }\n /**\n * Add the packet to the queue.\n * @param args\n * @private\n */\n _addToQueue(args) {\n let ack;\n if (typeof args[args.length - 1] === \"function\") {\n ack = args.pop();\n }\n const packet = {\n id: this._queueSeq++,\n tryCount: 0,\n pending: false,\n args,\n flags: Object.assign({ fromQueue: true }, this.flags),\n };\n args.push((err, ...responseArgs) => {\n if (packet !== this._queue[0]) {\n // the packet has already been acknowledged\n return;\n }\n const hasError = err !== null;\n if (hasError) {\n if (packet.tryCount > this._opts.retries) {\n debug(\"packet [%d] is discarded after %d tries\", packet.id, packet.tryCount);\n this._queue.shift();\n if (ack) {\n ack(err);\n }\n }\n }\n else {\n debug(\"packet [%d] was successfully sent\", packet.id);\n this._queue.shift();\n if (ack) {\n ack(null, ...responseArgs);\n }\n }\n packet.pending = false;\n return this._drainQueue();\n });\n this._queue.push(packet);\n this._drainQueue();\n }\n /**\n * Send the first packet of the queue, and wait for an acknowledgement from the server.\n * @param force - whether to resend a packet that has not been acknowledged yet\n *\n * @private\n */\n _drainQueue(force = false) {\n debug(\"draining queue\");\n if (!this.connected || this._queue.length === 0) {\n return;\n }\n const packet = this._queue[0];\n if (packet.pending && !force) {\n debug(\"packet [%d] has already been sent and is waiting for an ack\", packet.id);\n return;\n }\n packet.pending = true;\n packet.tryCount++;\n debug(\"sending packet [%d] (try n°%d)\", packet.id, packet.tryCount);\n this.flags = packet.flags;\n this.emit.apply(this, packet.args);\n }\n /**\n * Sends a packet.\n *\n * @param packet\n * @private\n */\n packet(packet) {\n packet.nsp = this.nsp;\n this.io._packet(packet);\n }\n /**\n * Called upon engine `open`.\n *\n * @private\n */\n onopen() {\n debug(\"transport is open - connecting\");\n if (typeof this.auth == \"function\") {\n this.auth((data) => {\n this._sendConnectPacket(data);\n });\n }\n else {\n this._sendConnectPacket(this.auth);\n }\n }\n /**\n * Sends a CONNECT packet to initiate the Socket.IO session.\n *\n * @param data\n * @private\n */\n _sendConnectPacket(data) {\n this.packet({\n type: socket_io_parser_1.PacketType.CONNECT,\n data: this._pid\n ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data)\n : data,\n });\n }\n /**\n * Called upon engine or manager `error`.\n *\n * @param err\n * @private\n */\n onerror(err) {\n if (!this.connected) {\n this.emitReserved(\"connect_error\", err);\n }\n }\n /**\n * Called upon engine `close`.\n *\n * @param reason\n * @param description\n * @private\n */\n onclose(reason, description) {\n debug(\"close (%s)\", reason);\n this.connected = false;\n delete this.id;\n this.emitReserved(\"disconnect\", reason, description);\n this._clearAcks();\n }\n /**\n * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from\n * the server.\n *\n * @private\n */\n _clearAcks() {\n Object.keys(this.acks).forEach((id) => {\n const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);\n if (!isBuffered) {\n // note: handlers that do not accept an error as first argument are ignored here\n const ack = this.acks[id];\n delete this.acks[id];\n if (ack.withError) {\n ack.call(this, new Error(\"socket has been disconnected\"));\n }\n }\n });\n }\n /**\n * Called with socket packet.\n *\n * @param packet\n * @private\n */\n onpacket(packet) {\n const sameNamespace = packet.nsp === this.nsp;\n if (!sameNamespace)\n return;\n switch (packet.type) {\n case socket_io_parser_1.PacketType.CONNECT:\n if (packet.data && packet.data.sid) {\n this.onconnect(packet.data.sid, packet.data.pid);\n }\n else {\n this.emitReserved(\"connect_error\", new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));\n }\n break;\n case socket_io_parser_1.PacketType.EVENT:\n case socket_io_parser_1.PacketType.BINARY_EVENT:\n this.onevent(packet);\n break;\n case socket_io_parser_1.PacketType.ACK:\n case socket_io_parser_1.PacketType.BINARY_ACK:\n this.onack(packet);\n break;\n case socket_io_parser_1.PacketType.DISCONNECT:\n this.ondisconnect();\n break;\n case socket_io_parser_1.PacketType.CONNECT_ERROR:\n this.destroy();\n const err = new Error(packet.data.message);\n // @ts-ignore\n err.data = packet.data.data;\n this.emitReserved(\"connect_error\", err);\n break;\n }\n }\n /**\n * Called upon a server event.\n *\n * @param packet\n * @private\n */\n onevent(packet) {\n const args = packet.data || [];\n debug(\"emitting event %j\", args);\n if (null != packet.id) {\n debug(\"attaching ack callback to event\");\n args.push(this.ack(packet.id));\n }\n if (this.connected) {\n this.emitEvent(args);\n }\n else {\n this.receiveBuffer.push(Object.freeze(args));\n }\n }\n emitEvent(args) {\n if (this._anyListeners && this._anyListeners.length) {\n const listeners = this._anyListeners.slice();\n for (const listener of listeners) {\n listener.apply(this, args);\n }\n }\n super.emit.apply(this, args);\n if (this._pid && args.length && typeof args[args.length - 1] === \"string\") {\n this._lastOffset = args[args.length - 1];\n }\n }\n /**\n * Produces an ack callback to emit with an event.\n *\n * @private\n */\n ack(id) {\n const self = this;\n let sent = false;\n return function (...args) {\n // prevent double callbacks\n if (sent)\n return;\n sent = true;\n debug(\"sending ack %j\", args);\n self.packet({\n type: socket_io_parser_1.PacketType.ACK,\n id: id,\n data: args,\n });\n };\n }\n /**\n * Called upon a server acknowledgement.\n *\n * @param packet\n * @private\n */\n onack(packet) {\n const ack = this.acks[packet.id];\n if (typeof ack !== \"function\") {\n debug(\"bad ack %s\", packet.id);\n return;\n }\n delete this.acks[packet.id];\n debug(\"calling ack %s with %j\", packet.id, packet.data);\n // @ts-ignore FIXME ack is incorrectly inferred as 'never'\n if (ack.withError) {\n packet.data.unshift(null);\n }\n // @ts-ignore\n ack.apply(this, packet.data);\n }\n /**\n * Called upon server connect.\n *\n * @private\n */\n onconnect(id, pid) {\n debug(\"socket connected with id %s\", id);\n this.id = id;\n this.recovered = pid && this._pid === pid;\n this._pid = pid; // defined only if connection state recovery is enabled\n this.connected = true;\n this.emitBuffered();\n this.emitReserved(\"connect\");\n this._drainQueue(true);\n }\n /**\n * Emit buffered events (received and emitted).\n *\n * @private\n */\n emitBuffered() {\n this.receiveBuffer.forEach((args) => this.emitEvent(args));\n this.receiveBuffer = [];\n this.sendBuffer.forEach((packet) => {\n this.notifyOutgoingListeners(packet);\n this.packet(packet);\n });\n this.sendBuffer = [];\n }\n /**\n * Called upon server disconnect.\n *\n * @private\n */\n ondisconnect() {\n debug(\"server disconnect (%s)\", this.nsp);\n this.destroy();\n this.onclose(\"io server disconnect\");\n }\n /**\n * Called upon forced client/server side disconnections,\n * this method ensures the manager stops tracking us and\n * that reconnections don't get triggered for this.\n *\n * @private\n */\n destroy() {\n if (this.subs) {\n // clean subscriptions to avoid reconnections\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs = undefined;\n }\n this.io[\"_destroy\"](this);\n }\n /**\n * Disconnects the socket manually. In that case, the socket will not try to reconnect.\n *\n * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.\n *\n * @example\n * const socket = io();\n *\n * socket.on(\"disconnect\", (reason) => {\n * // console.log(reason); prints \"io client disconnect\"\n * });\n *\n * socket.disconnect();\n *\n * @return self\n */\n disconnect() {\n if (this.connected) {\n debug(\"performing disconnect (%s)\", this.nsp);\n this.packet({ type: socket_io_parser_1.PacketType.DISCONNECT });\n }\n // remove socket from pool\n this.destroy();\n if (this.connected) {\n // fire events\n this.onclose(\"io client disconnect\");\n }\n return this;\n }\n /**\n * Alias for {@link disconnect()}.\n *\n * @return self\n */\n close() {\n return this.disconnect();\n }\n /**\n * Sets the compress flag.\n *\n * @example\n * socket.compress(false).emit(\"hello\");\n *\n * @param compress - if `true`, compresses the sending data\n * @return self\n */\n compress(compress) {\n this.flags.compress = compress;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not\n * ready to send messages.\n *\n * @example\n * socket.volatile.emit(\"hello\"); // the server may or may not receive it\n *\n * @returns self\n */\n get volatile() {\n this.flags.volatile = true;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the callback will be called with an error when the\n * given number of milliseconds have elapsed without an acknowledgement from the server:\n *\n * @example\n * socket.timeout(5000).emit(\"my-event\", (err) => {\n * if (err) {\n * // the server did not acknowledge the event in the given delay\n * }\n * });\n *\n * @returns self\n */\n timeout(timeout) {\n this.flags.timeout = timeout;\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback.\n *\n * @example\n * socket.onAny((event, ...args) => {\n * console.log(`got ${event}`);\n * });\n *\n * @param listener\n */\n onAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.push(listener);\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback. The listener is added to the beginning of the listeners array.\n *\n * @example\n * socket.prependAny((event, ...args) => {\n * console.log(`got event ${event}`);\n * });\n *\n * @param listener\n */\n prependAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.unshift(listener);\n return this;\n }\n /**\n * Removes the listener that will be fired when any event is emitted.\n *\n * @example\n * const catchAllListener = (event, ...args) => {\n * console.log(`got event ${event}`);\n * }\n *\n * socket.onAny(catchAllListener);\n *\n * // remove a specific listener\n * socket.offAny(catchAllListener);\n *\n * // or remove all listeners\n * socket.offAny();\n *\n * @param listener\n */\n offAny(listener) {\n if (!this._anyListeners) {\n return this;\n }\n if (listener) {\n const listeners = this._anyListeners;\n for (let i = 0; i < listeners.length; i++) {\n if (listener === listeners[i]) {\n listeners.splice(i, 1);\n return this;\n }\n }\n }\n else {\n this._anyListeners = [];\n }\n return this;\n }\n /**\n * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,\n * e.g. to remove listeners.\n */\n listenersAny() {\n return this._anyListeners || [];\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback.\n *\n * Note: acknowledgements sent to the server are not included.\n *\n * @example\n * socket.onAnyOutgoing((event, ...args) => {\n * console.log(`sent event ${event}`);\n * });\n *\n * @param listener\n */\n onAnyOutgoing(listener) {\n this._anyOutgoingListeners = this._anyOutgoingListeners || [];\n this._anyOutgoingListeners.push(listener);\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback. The listener is added to the beginning of the listeners array.\n *\n * Note: acknowledgements sent to the server are not included.\n *\n * @example\n * socket.prependAnyOutgoing((event, ...args) => {\n * console.log(`sent event ${event}`);\n * });\n *\n * @param listener\n */\n prependAnyOutgoing(listener) {\n this._anyOutgoingListeners = this._anyOutgoingListeners || [];\n this._anyOutgoingListeners.unshift(listener);\n return this;\n }\n /**\n * Removes the listener that will be fired when any event is emitted.\n *\n * @example\n * const catchAllListener = (event, ...args) => {\n * console.log(`sent event ${event}`);\n * }\n *\n * socket.onAnyOutgoing(catchAllListener);\n *\n * // remove a specific listener\n * socket.offAnyOutgoing(catchAllListener);\n *\n * // or remove all listeners\n * socket.offAnyOutgoing();\n *\n * @param [listener] - the catch-all listener (optional)\n */\n offAnyOutgoing(listener) {\n if (!this._anyOutgoingListeners) {\n return this;\n }\n if (listener) {\n const listeners = this._anyOutgoingListeners;\n for (let i = 0; i < listeners.length; i++) {\n if (listener === listeners[i]) {\n listeners.splice(i, 1);\n return this;\n }\n }\n }\n else {\n this._anyOutgoingListeners = [];\n }\n return this;\n }\n /**\n * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,\n * e.g. to remove listeners.\n */\n listenersAnyOutgoing() {\n return this._anyOutgoingListeners || [];\n }\n /**\n * Notify the listeners for each packet sent\n *\n * @param packet\n *\n * @private\n */\n notifyOutgoingListeners(packet) {\n if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {\n const listeners = this._anyOutgoingListeners.slice();\n for (const listener of listeners) {\n listener.apply(this, packet.data);\n }\n }\n }\n}\nexports.Socket = Socket;\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/socket.js?");
|
|
737
726
|
|
|
738
727
|
/***/ }),
|
|
739
728
|
|
|
@@ -744,7 +733,7 @@ eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
744
733
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
745
734
|
|
|
746
735
|
"use strict";
|
|
747
|
-
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.url =
|
|
736
|
+
eval("\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.url = url;\nconst engine_io_client_1 = __webpack_require__(/*! engine.io-client */ \"./node_modules/engine.io-client/build/cjs/index.js\");\nconst debug_1 = __importDefault(__webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\")); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-client:url\"); // debug()\n/**\n * URL parser.\n *\n * @param uri - url\n * @param path - the request path of the connection\n * @param loc - An object meant to mimic window.location.\n * Defaults to window.location.\n * @public\n */\nfunction url(uri, path = \"\", loc) {\n let obj = uri;\n // default to window.location\n loc = loc || (typeof location !== \"undefined\" && location);\n if (null == uri)\n uri = loc.protocol + \"//\" + loc.host;\n // relative path support\n if (typeof uri === \"string\") {\n if (\"/\" === uri.charAt(0)) {\n if (\"/\" === uri.charAt(1)) {\n uri = loc.protocol + uri;\n }\n else {\n uri = loc.host + uri;\n }\n }\n if (!/^(https?|wss?):\\/\\//.test(uri)) {\n debug(\"protocol-less url %s\", uri);\n if (\"undefined\" !== typeof loc) {\n uri = loc.protocol + \"//\" + uri;\n }\n else {\n uri = \"https://\" + uri;\n }\n }\n // parse\n debug(\"parse %s\", uri);\n obj = (0, engine_io_client_1.parse)(uri);\n }\n // make sure we treat `localhost:80` and `localhost` equally\n if (!obj.port) {\n if (/^(http|ws)$/.test(obj.protocol)) {\n obj.port = \"80\";\n }\n else if (/^(http|ws)s$/.test(obj.protocol)) {\n obj.port = \"443\";\n }\n }\n obj.path = obj.path || \"/\";\n const ipv6 = obj.host.indexOf(\":\") !== -1;\n const host = ipv6 ? \"[\" + obj.host + \"]\" : obj.host;\n // define unique id\n obj.id = obj.protocol + \"://\" + host + \":\" + obj.port + path;\n // define href\n obj.href =\n obj.protocol +\n \"://\" +\n host +\n (loc && loc.port === obj.port ? \"\" : \":\" + obj.port);\n return obj;\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-client/build/cjs/url.js?");
|
|
748
737
|
|
|
749
738
|
/***/ }),
|
|
750
739
|
|
|
@@ -766,7 +755,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
766
755
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
767
756
|
|
|
768
757
|
"use strict";
|
|
769
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/lib/esm/index.js\");\nconst binary_js_1 = __webpack_require__(/*! ./binary.js */ \"./node_modules/socket.io-parser/build/cjs/binary.js\");\nconst is_binary_js_1 = __webpack_require__(/*! ./is-binary.js */ \"./node_modules/socket.io-parser/build/cjs/is-binary.js\");\nconst debug_1 = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\"); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-parser\"); // debug()\n/**\n * These strings must not be used as event names, as they have a special meaning.\n */\nconst RESERVED_EVENTS = [\n \"connect\",\n \"connect_error\",\n \"disconnect\",\n \"disconnecting\",\n \"newListener\",\n \"removeListener\", // used by the Node.js EventEmitter\n];\n/**\n * Protocol version.\n *\n * @public\n */\nexports.protocol = 5;\nvar PacketType;\n(function (PacketType) {\n PacketType[PacketType[\"CONNECT\"] = 0] = \"CONNECT\";\n PacketType[PacketType[\"DISCONNECT\"] = 1] = \"DISCONNECT\";\n PacketType[PacketType[\"EVENT\"] = 2] = \"EVENT\";\n PacketType[PacketType[\"ACK\"] = 3] = \"ACK\";\n PacketType[PacketType[\"CONNECT_ERROR\"] = 4] = \"CONNECT_ERROR\";\n PacketType[PacketType[\"BINARY_EVENT\"] = 5] = \"BINARY_EVENT\";\n PacketType[PacketType[\"BINARY_ACK\"] = 6] = \"BINARY_ACK\";\n})(PacketType = exports.PacketType || (exports.PacketType = {}));\n/**\n * A socket.io Encoder instance\n */\nclass Encoder {\n /**\n * Encoder constructor\n *\n * @param {function} replacer - custom replacer to pass down to JSON.parse\n */\n constructor(replacer) {\n this.replacer = replacer;\n }\n /**\n * Encode a packet as a single string if non-binary, or as a\n * buffer sequence, depending on packet type.\n *\n * @param {Object} obj - packet object\n */\n encode(obj) {\n debug(\"encoding packet %j\", obj);\n if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {\n if ((0, is_binary_js_1.hasBinary)(obj)) {\n return this.encodeAsBinary({\n type: obj.type === PacketType.EVENT\n ? PacketType.BINARY_EVENT\n : PacketType.BINARY_ACK,\n nsp: obj.nsp,\n data: obj.data,\n id: obj.id,\n });\n }\n }\n return [this.encodeAsString(obj)];\n }\n /**\n * Encode packet as string.\n */\n encodeAsString(obj) {\n // first is type\n let str = \"\" + obj.type;\n // attachments if we have them\n if (obj.type === PacketType.BINARY_EVENT ||\n obj.type === PacketType.BINARY_ACK) {\n str += obj.attachments + \"-\";\n }\n // if we have a namespace other than `/`\n // we append it followed by a comma `,`\n if (obj.nsp && \"/\" !== obj.nsp) {\n str += obj.nsp + \",\";\n }\n // immediately followed by the id\n if (null != obj.id) {\n str += obj.id;\n }\n // json data\n if (null != obj.data) {\n str += JSON.stringify(obj.data, this.replacer);\n }\n debug(\"encoded %j as %s\", obj, str);\n return str;\n }\n /**\n * Encode packet as 'buffer sequence' by removing blobs, and\n * deconstructing packet into object with placeholders and\n * a list of buffers.\n */\n encodeAsBinary(obj) {\n const deconstruction = (0, binary_js_1.deconstructPacket)(obj);\n const pack = this.encodeAsString(deconstruction.packet);\n const buffers = deconstruction.buffers;\n buffers.unshift(pack); // add packet info to beginning of data list\n return buffers; // write all the buffers\n }\n}\nexports.Encoder = Encoder;\n// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === \"[object Object]\";\n}\n/**\n * A socket.io Decoder instance\n *\n * @return {Object} decoder\n */\nclass Decoder extends component_emitter_1.Emitter {\n /**\n * Decoder constructor\n *\n * @param {function} reviver - custom reviver to pass down to JSON.stringify\n */\n constructor(reviver) {\n super();\n this.reviver = reviver;\n }\n /**\n * Decodes an encoded packet string into packet JSON.\n *\n * @param {String} obj - encoded packet\n */\n add(obj) {\n let packet;\n if (typeof obj === \"string\") {\n if (this.reconstructor) {\n throw new Error(\"got plaintext data when reconstructing a packet\");\n }\n packet = this.decodeString(obj);\n const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;\n if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {\n packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;\n // binary packet's json\n this.reconstructor = new BinaryReconstructor(packet);\n // no attachments, labeled binary but no binary data to follow\n if (packet.attachments === 0) {\n super.emitReserved(\"decoded\", packet);\n }\n }\n else {\n // non-binary full packet\n super.emitReserved(\"decoded\", packet);\n }\n }\n else if ((0, is_binary_js_1.isBinary)(obj) || obj.base64) {\n // raw binary data\n if (!this.reconstructor) {\n throw new Error(\"got binary data when not reconstructing a packet\");\n }\n else {\n packet = this.reconstructor.takeBinaryData(obj);\n if (packet) {\n // received final buffer\n this.reconstructor = null;\n super.emitReserved(\"decoded\", packet);\n }\n }\n }\n else {\n throw new Error(\"Unknown type: \" + obj);\n }\n }\n /**\n * Decode a packet String (JSON data)\n *\n * @param {String} str\n * @return {Object} packet\n */\n decodeString(str) {\n let i = 0;\n // look up type\n const p = {\n type: Number(str.charAt(0)),\n };\n if (PacketType[p.type] === undefined) {\n throw new Error(\"unknown packet type \" + p.type);\n }\n // look up attachments if type binary\n if (p.type === PacketType.BINARY_EVENT ||\n p.type === PacketType.BINARY_ACK) {\n const start = i + 1;\n while (str.charAt(++i) !== \"-\" && i != str.length) { }\n const buf = str.substring(start, i);\n if (buf != Number(buf) || str.charAt(i) !== \"-\") {\n throw new Error(\"Illegal attachments\");\n }\n p.attachments = Number(buf);\n }\n // look up namespace (if any)\n if (\"/\" === str.charAt(i + 1)) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (\",\" === c)\n break;\n if (i === str.length)\n break;\n }\n p.nsp = str.substring(start, i);\n }\n else {\n p.nsp = \"/\";\n }\n // look up id\n const next = str.charAt(i + 1);\n if (\"\" !== next && Number(next) == next) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (null == c || Number(c) != c) {\n --i;\n break;\n }\n if (i === str.length)\n break;\n }\n p.id = Number(str.substring(start, i + 1));\n }\n // look up json data\n if (str.charAt(++i)) {\n const payload = this.tryParse(str.substr(i));\n if (Decoder.isPayloadValid(p.type, payload)) {\n p.data = payload;\n }\n else {\n throw new Error(\"invalid payload\");\n }\n }\n debug(\"decoded %s as %j\", str, p);\n return p;\n }\n tryParse(str) {\n try {\n return JSON.parse(str, this.reviver);\n }\n catch (e) {\n return false;\n }\n }\n static isPayloadValid(type, payload) {\n switch (type) {\n case PacketType.CONNECT:\n return isObject(payload);\n case PacketType.DISCONNECT:\n return payload === undefined;\n case PacketType.CONNECT_ERROR:\n return typeof payload === \"string\" || isObject(payload);\n case PacketType.EVENT:\n case PacketType.BINARY_EVENT:\n return (Array.isArray(payload) &&\n (typeof payload[0] === \"number\" ||\n (typeof payload[0] === \"string\" &&\n RESERVED_EVENTS.indexOf(payload[0]) === -1)));\n case PacketType.ACK:\n case PacketType.BINARY_ACK:\n return Array.isArray(payload);\n }\n }\n /**\n * Deallocates a parser's resources\n */\n destroy() {\n if (this.reconstructor) {\n this.reconstructor.finishedReconstruction();\n this.reconstructor = null;\n }\n }\n}\nexports.Decoder = Decoder;\n/**\n * A manager of a binary event's 'buffer sequence'. Should\n * be constructed whenever a packet of type BINARY_EVENT is\n * decoded.\n *\n * @param {Object} packet\n * @return {BinaryReconstructor} initialized reconstructor\n */\nclass BinaryReconstructor {\n constructor(packet) {\n this.packet = packet;\n this.buffers = [];\n this.reconPack = packet;\n }\n /**\n * Method to be called when binary data received from connection\n * after a BINARY_EVENT packet.\n *\n * @param {Buffer | ArrayBuffer} binData - the raw binary data received\n * @return {null | Object} returns null if more binary data is expected or\n * a reconstructed packet object if all buffers have been received.\n */\n takeBinaryData(binData) {\n this.buffers.push(binData);\n if (this.buffers.length === this.reconPack.attachments) {\n // done with buffer list\n const packet = (0, binary_js_1.reconstructPacket)(this.reconPack, this.buffers);\n this.finishedReconstruction();\n return packet;\n }\n return null;\n }\n /**\n * Cleans up binary packet reconstruction variables.\n */\n finishedReconstruction() {\n this.reconPack = null;\n this.buffers = [];\n }\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-parser/build/cjs/index.js?");
|
|
758
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;\nconst component_emitter_1 = __webpack_require__(/*! @socket.io/component-emitter */ \"./node_modules/@socket.io/component-emitter/index.mjs\");\nconst binary_js_1 = __webpack_require__(/*! ./binary.js */ \"./node_modules/socket.io-parser/build/cjs/binary.js\");\nconst is_binary_js_1 = __webpack_require__(/*! ./is-binary.js */ \"./node_modules/socket.io-parser/build/cjs/is-binary.js\");\nconst debug_1 = __webpack_require__(/*! debug */ \"./node_modules/debug/src/browser.js\"); // debug()\nconst debug = (0, debug_1.default)(\"socket.io-parser\"); // debug()\n/**\n * These strings must not be used as event names, as they have a special meaning.\n */\nconst RESERVED_EVENTS = [\n \"connect\",\n \"connect_error\",\n \"disconnect\",\n \"disconnecting\",\n \"newListener\",\n \"removeListener\", // used by the Node.js EventEmitter\n];\n/**\n * Protocol version.\n *\n * @public\n */\nexports.protocol = 5;\nvar PacketType;\n(function (PacketType) {\n PacketType[PacketType[\"CONNECT\"] = 0] = \"CONNECT\";\n PacketType[PacketType[\"DISCONNECT\"] = 1] = \"DISCONNECT\";\n PacketType[PacketType[\"EVENT\"] = 2] = \"EVENT\";\n PacketType[PacketType[\"ACK\"] = 3] = \"ACK\";\n PacketType[PacketType[\"CONNECT_ERROR\"] = 4] = \"CONNECT_ERROR\";\n PacketType[PacketType[\"BINARY_EVENT\"] = 5] = \"BINARY_EVENT\";\n PacketType[PacketType[\"BINARY_ACK\"] = 6] = \"BINARY_ACK\";\n})(PacketType = exports.PacketType || (exports.PacketType = {}));\n/**\n * A socket.io Encoder instance\n */\nclass Encoder {\n /**\n * Encoder constructor\n *\n * @param {function} replacer - custom replacer to pass down to JSON.parse\n */\n constructor(replacer) {\n this.replacer = replacer;\n }\n /**\n * Encode a packet as a single string if non-binary, or as a\n * buffer sequence, depending on packet type.\n *\n * @param {Object} obj - packet object\n */\n encode(obj) {\n debug(\"encoding packet %j\", obj);\n if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {\n if ((0, is_binary_js_1.hasBinary)(obj)) {\n return this.encodeAsBinary({\n type: obj.type === PacketType.EVENT\n ? PacketType.BINARY_EVENT\n : PacketType.BINARY_ACK,\n nsp: obj.nsp,\n data: obj.data,\n id: obj.id,\n });\n }\n }\n return [this.encodeAsString(obj)];\n }\n /**\n * Encode packet as string.\n */\n encodeAsString(obj) {\n // first is type\n let str = \"\" + obj.type;\n // attachments if we have them\n if (obj.type === PacketType.BINARY_EVENT ||\n obj.type === PacketType.BINARY_ACK) {\n str += obj.attachments + \"-\";\n }\n // if we have a namespace other than `/`\n // we append it followed by a comma `,`\n if (obj.nsp && \"/\" !== obj.nsp) {\n str += obj.nsp + \",\";\n }\n // immediately followed by the id\n if (null != obj.id) {\n str += obj.id;\n }\n // json data\n if (null != obj.data) {\n str += JSON.stringify(obj.data, this.replacer);\n }\n debug(\"encoded %j as %s\", obj, str);\n return str;\n }\n /**\n * Encode packet as 'buffer sequence' by removing blobs, and\n * deconstructing packet into object with placeholders and\n * a list of buffers.\n */\n encodeAsBinary(obj) {\n const deconstruction = (0, binary_js_1.deconstructPacket)(obj);\n const pack = this.encodeAsString(deconstruction.packet);\n const buffers = deconstruction.buffers;\n buffers.unshift(pack); // add packet info to beginning of data list\n return buffers; // write all the buffers\n }\n}\nexports.Encoder = Encoder;\n// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === \"[object Object]\";\n}\n/**\n * A socket.io Decoder instance\n *\n * @return {Object} decoder\n */\nclass Decoder extends component_emitter_1.Emitter {\n /**\n * Decoder constructor\n *\n * @param {function} reviver - custom reviver to pass down to JSON.stringify\n */\n constructor(reviver) {\n super();\n this.reviver = reviver;\n }\n /**\n * Decodes an encoded packet string into packet JSON.\n *\n * @param {String} obj - encoded packet\n */\n add(obj) {\n let packet;\n if (typeof obj === \"string\") {\n if (this.reconstructor) {\n throw new Error(\"got plaintext data when reconstructing a packet\");\n }\n packet = this.decodeString(obj);\n const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;\n if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {\n packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;\n // binary packet's json\n this.reconstructor = new BinaryReconstructor(packet);\n // no attachments, labeled binary but no binary data to follow\n if (packet.attachments === 0) {\n super.emitReserved(\"decoded\", packet);\n }\n }\n else {\n // non-binary full packet\n super.emitReserved(\"decoded\", packet);\n }\n }\n else if ((0, is_binary_js_1.isBinary)(obj) || obj.base64) {\n // raw binary data\n if (!this.reconstructor) {\n throw new Error(\"got binary data when not reconstructing a packet\");\n }\n else {\n packet = this.reconstructor.takeBinaryData(obj);\n if (packet) {\n // received final buffer\n this.reconstructor = null;\n super.emitReserved(\"decoded\", packet);\n }\n }\n }\n else {\n throw new Error(\"Unknown type: \" + obj);\n }\n }\n /**\n * Decode a packet String (JSON data)\n *\n * @param {String} str\n * @return {Object} packet\n */\n decodeString(str) {\n let i = 0;\n // look up type\n const p = {\n type: Number(str.charAt(0)),\n };\n if (PacketType[p.type] === undefined) {\n throw new Error(\"unknown packet type \" + p.type);\n }\n // look up attachments if type binary\n if (p.type === PacketType.BINARY_EVENT ||\n p.type === PacketType.BINARY_ACK) {\n const start = i + 1;\n while (str.charAt(++i) !== \"-\" && i != str.length) { }\n const buf = str.substring(start, i);\n if (buf != Number(buf) || str.charAt(i) !== \"-\") {\n throw new Error(\"Illegal attachments\");\n }\n p.attachments = Number(buf);\n }\n // look up namespace (if any)\n if (\"/\" === str.charAt(i + 1)) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (\",\" === c)\n break;\n if (i === str.length)\n break;\n }\n p.nsp = str.substring(start, i);\n }\n else {\n p.nsp = \"/\";\n }\n // look up id\n const next = str.charAt(i + 1);\n if (\"\" !== next && Number(next) == next) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (null == c || Number(c) != c) {\n --i;\n break;\n }\n if (i === str.length)\n break;\n }\n p.id = Number(str.substring(start, i + 1));\n }\n // look up json data\n if (str.charAt(++i)) {\n const payload = this.tryParse(str.substr(i));\n if (Decoder.isPayloadValid(p.type, payload)) {\n p.data = payload;\n }\n else {\n throw new Error(\"invalid payload\");\n }\n }\n debug(\"decoded %s as %j\", str, p);\n return p;\n }\n tryParse(str) {\n try {\n return JSON.parse(str, this.reviver);\n }\n catch (e) {\n return false;\n }\n }\n static isPayloadValid(type, payload) {\n switch (type) {\n case PacketType.CONNECT:\n return isObject(payload);\n case PacketType.DISCONNECT:\n return payload === undefined;\n case PacketType.CONNECT_ERROR:\n return typeof payload === \"string\" || isObject(payload);\n case PacketType.EVENT:\n case PacketType.BINARY_EVENT:\n return (Array.isArray(payload) &&\n (typeof payload[0] === \"number\" ||\n (typeof payload[0] === \"string\" &&\n RESERVED_EVENTS.indexOf(payload[0]) === -1)));\n case PacketType.ACK:\n case PacketType.BINARY_ACK:\n return Array.isArray(payload);\n }\n }\n /**\n * Deallocates a parser's resources\n */\n destroy() {\n if (this.reconstructor) {\n this.reconstructor.finishedReconstruction();\n this.reconstructor = null;\n }\n }\n}\nexports.Decoder = Decoder;\n/**\n * A manager of a binary event's 'buffer sequence'. Should\n * be constructed whenever a packet of type BINARY_EVENT is\n * decoded.\n *\n * @param {Object} packet\n * @return {BinaryReconstructor} initialized reconstructor\n */\nclass BinaryReconstructor {\n constructor(packet) {\n this.packet = packet;\n this.buffers = [];\n this.reconPack = packet;\n }\n /**\n * Method to be called when binary data received from connection\n * after a BINARY_EVENT packet.\n *\n * @param {Buffer | ArrayBuffer} binData - the raw binary data received\n * @return {null | Object} returns null if more binary data is expected or\n * a reconstructed packet object if all buffers have been received.\n */\n takeBinaryData(binData) {\n this.buffers.push(binData);\n if (this.buffers.length === this.reconPack.attachments) {\n // done with buffer list\n const packet = (0, binary_js_1.reconstructPacket)(this.reconPack, this.buffers);\n this.finishedReconstruction();\n return packet;\n }\n return null;\n }\n /**\n * Cleans up binary packet reconstruction variables.\n */\n finishedReconstruction() {\n this.reconPack = null;\n this.buffers = [];\n }\n}\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/socket.io-parser/build/cjs/index.js?");
|
|
770
759
|
|
|
771
760
|
/***/ }),
|
|
772
761
|
|
|
@@ -781,14 +770,14 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
781
770
|
|
|
782
771
|
/***/ }),
|
|
783
772
|
|
|
784
|
-
/***/ "./node_modules/@socket.io/component-emitter/
|
|
785
|
-
|
|
786
|
-
!*** ./node_modules/@socket.io/component-emitter/
|
|
787
|
-
|
|
773
|
+
/***/ "./node_modules/@socket.io/component-emitter/index.mjs":
|
|
774
|
+
/*!*************************************************************!*\
|
|
775
|
+
!*** ./node_modules/@socket.io/component-emitter/index.mjs ***!
|
|
776
|
+
\*************************************************************/
|
|
788
777
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
789
778
|
|
|
790
779
|
"use strict";
|
|
791
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Emitter: () => (/* binding */ Emitter)\n/* harmony export */ });\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n}\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n function on() {\n this.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks['$' + event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks['$' + event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n\n // Remove event specific arrays for event types that no\n // one is subscribed for to avoid memory leak.\n if (callbacks.length === 0) {\n delete this._callbacks['$' + event];\n }\n\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n\n var args = new Array(arguments.length - 1)\n , callbacks = this._callbacks['$' + event];\n\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n// alias used for reserved events (protected method)\nEmitter.prototype.emitReserved = Emitter.prototype.emit;\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks['$' + event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/@socket.io/component-emitter/
|
|
780
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Emitter: () => (/* binding */ Emitter)\n/* harmony export */ });\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n}\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n function on() {\n this.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks['$' + event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks['$' + event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n\n // Remove event specific arrays for event types that no\n // one is subscribed for to avoid memory leak.\n if (callbacks.length === 0) {\n delete this._callbacks['$' + event];\n }\n\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n\n var args = new Array(arguments.length - 1)\n , callbacks = this._callbacks['$' + event];\n\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n// alias used for reserved events (protected method)\nEmitter.prototype.emitReserved = Emitter.prototype.emit;\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks['$' + event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n\n//# sourceURL=webpack://sqlitecloud/./node_modules/@socket.io/component-emitter/index.mjs?");
|
|
792
781
|
|
|
793
782
|
/***/ }),
|
|
794
783
|
|