@capgo/capacitor-fast-sql 7.0.1

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.
Files changed (37) hide show
  1. package/CapgoCapacitorFastSql.podspec +18 -0
  2. package/Package.swift +30 -0
  3. package/README.md +340 -0
  4. package/android/build.gradle +60 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/app/capgo/capacitor/fastsql/CapgoCapacitorFastSqlPlugin.java +220 -0
  7. package/android/src/main/java/app/capgo/capacitor/fastsql/SQLDatabase.java +231 -0
  8. package/android/src/main/java/app/capgo/capacitor/fastsql/SQLHTTPServer.java +229 -0
  9. package/dist/esm/definitions.d.ts +225 -0
  10. package/dist/esm/definitions.d.ts.map +1 -0
  11. package/dist/esm/definitions.js +10 -0
  12. package/dist/esm/helpers.d.ts +7 -0
  13. package/dist/esm/helpers.d.ts.map +1 -0
  14. package/dist/esm/helpers.js +6 -0
  15. package/dist/esm/index.d.ts +5 -0
  16. package/dist/esm/index.d.ts.map +1 -0
  17. package/dist/esm/index.js +5 -0
  18. package/dist/esm/native-sql.d.ts +42 -0
  19. package/dist/esm/native-sql.d.ts.map +1 -0
  20. package/dist/esm/native-sql.js +69 -0
  21. package/dist/esm/plugin.d.ts +3 -0
  22. package/dist/esm/plugin.d.ts.map +1 -0
  23. package/dist/esm/plugin.js +4 -0
  24. package/dist/esm/sql-connection.d.ts +94 -0
  25. package/dist/esm/sql-connection.d.ts.map +1 -0
  26. package/dist/esm/sql-connection.js +246 -0
  27. package/dist/esm/web.d.ts +67 -0
  28. package/dist/esm/web.d.ts.map +1 -0
  29. package/dist/esm/web.js +215 -0
  30. package/dist/plugin.cjs.js +557 -0
  31. package/dist/plugin.cjs.js.map +1 -0
  32. package/dist/plugin.js +560 -0
  33. package/dist/plugin.js.map +1 -0
  34. package/ios/Sources/CapgoCapacitorFastSqlPlugin/CapgoCapacitorFastSqlPlugin.swift +202 -0
  35. package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLDatabase.swift +215 -0
  36. package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLHTTPServer.swift +311 -0
  37. package/package.json +90 -0
package/dist/plugin.js ADDED
@@ -0,0 +1,560 @@
1
+ var capacitorNativeSql = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Transaction isolation levels
6
+ */
7
+ exports.IsolationLevel = void 0;
8
+ (function (IsolationLevel) {
9
+ IsolationLevel["ReadUncommitted"] = "READ UNCOMMITTED";
10
+ IsolationLevel["ReadCommitted"] = "READ COMMITTED";
11
+ IsolationLevel["RepeatableRead"] = "REPEATABLE READ";
12
+ IsolationLevel["Serializable"] = "SERIALIZABLE";
13
+ })(exports.IsolationLevel || (exports.IsolationLevel = {}));
14
+
15
+ const CapgoCapacitorNativeSql = core.registerPlugin('CapgoCapacitorNativeSql', {
16
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapgoCapacitorNativeSqlWeb()),
17
+ });
18
+
19
+ /**
20
+ * SQL Connection class that uses HTTP protocol for efficient communication
21
+ * with native SQLite databases, bypassing Capacitor's standard bridge.
22
+ *
23
+ * Inspired by capacitor-blob-writer's approach to avoid serialization overhead.
24
+ */
25
+ class SQLConnection {
26
+ constructor(database, port, token) {
27
+ this.inTransaction = false;
28
+ this.database = database;
29
+ this.port = port;
30
+ this.token = token;
31
+ this.baseUrl = `http://localhost:${port}`;
32
+ }
33
+ /**
34
+ * Get the database name
35
+ */
36
+ getDatabaseName() {
37
+ return this.database;
38
+ }
39
+ /**
40
+ * Execute a SQL query via HTTP protocol for optimal performance
41
+ *
42
+ * @param statement - SQL statement to execute
43
+ * @param params - Parameters to bind to the statement
44
+ * @returns Query results
45
+ */
46
+ async execute(statement, params) {
47
+ const response = await fetch(`${this.baseUrl}/execute`, {
48
+ method: 'POST',
49
+ headers: {
50
+ 'Content-Type': 'application/json',
51
+ Authorization: `Bearer ${this.token}`,
52
+ 'X-Database': this.database,
53
+ },
54
+ body: JSON.stringify({
55
+ statement,
56
+ params: params ? this.serializeParams(params) : [],
57
+ }),
58
+ });
59
+ if (!response.ok) {
60
+ const error = await response.text();
61
+ throw new Error(`SQL execution failed: ${error}`);
62
+ }
63
+ const result = await response.json();
64
+ return this.deserializeResult(result);
65
+ }
66
+ /**
67
+ * Execute multiple SQL statements in a batch for better performance
68
+ *
69
+ * @param operations - Array of SQL operations to execute
70
+ * @returns Array of results for each operation
71
+ */
72
+ async executeBatch(operations) {
73
+ const response = await fetch(`${this.baseUrl}/batch`, {
74
+ method: 'POST',
75
+ headers: {
76
+ 'Content-Type': 'application/json',
77
+ Authorization: `Bearer ${this.token}`,
78
+ 'X-Database': this.database,
79
+ },
80
+ body: JSON.stringify({
81
+ operations: operations.map((op) => ({
82
+ statement: op.statement,
83
+ params: op.params ? this.serializeParams(op.params) : [],
84
+ })),
85
+ }),
86
+ });
87
+ if (!response.ok) {
88
+ const error = await response.text();
89
+ throw new Error(`SQL batch execution failed: ${error}`);
90
+ }
91
+ const results = await response.json();
92
+ return results.map((r) => this.deserializeResult(r));
93
+ }
94
+ /**
95
+ * Begin a transaction
96
+ *
97
+ * @param isolationLevel - Optional isolation level
98
+ */
99
+ async beginTransaction(isolationLevel) {
100
+ if (this.inTransaction) {
101
+ throw new Error('Transaction already in progress');
102
+ }
103
+ const response = await fetch(`${this.baseUrl}/transaction/begin`, {
104
+ method: 'POST',
105
+ headers: {
106
+ 'Content-Type': 'application/json',
107
+ Authorization: `Bearer ${this.token}`,
108
+ 'X-Database': this.database,
109
+ },
110
+ body: JSON.stringify({
111
+ isolationLevel: isolationLevel || exports.IsolationLevel.Serializable,
112
+ }),
113
+ });
114
+ if (!response.ok) {
115
+ const error = await response.text();
116
+ throw new Error(`Failed to begin transaction: ${error}`);
117
+ }
118
+ this.inTransaction = true;
119
+ }
120
+ /**
121
+ * Commit the current transaction
122
+ */
123
+ async commit() {
124
+ if (!this.inTransaction) {
125
+ throw new Error('No transaction in progress');
126
+ }
127
+ const response = await fetch(`${this.baseUrl}/transaction/commit`, {
128
+ method: 'POST',
129
+ headers: {
130
+ Authorization: `Bearer ${this.token}`,
131
+ 'X-Database': this.database,
132
+ },
133
+ });
134
+ if (!response.ok) {
135
+ const error = await response.text();
136
+ throw new Error(`Failed to commit transaction: ${error}`);
137
+ }
138
+ this.inTransaction = false;
139
+ }
140
+ /**
141
+ * Rollback the current transaction
142
+ */
143
+ async rollback() {
144
+ if (!this.inTransaction) {
145
+ throw new Error('No transaction in progress');
146
+ }
147
+ const response = await fetch(`${this.baseUrl}/transaction/rollback`, {
148
+ method: 'POST',
149
+ headers: {
150
+ Authorization: `Bearer ${this.token}`,
151
+ 'X-Database': this.database,
152
+ },
153
+ });
154
+ if (!response.ok) {
155
+ const error = await response.text();
156
+ throw new Error(`Failed to rollback transaction: ${error}`);
157
+ }
158
+ this.inTransaction = false;
159
+ }
160
+ /**
161
+ * Execute operations within a transaction automatically
162
+ *
163
+ * @param callback - Function containing operations to execute
164
+ * @param isolationLevel - Optional isolation level
165
+ */
166
+ async transaction(callback, isolationLevel) {
167
+ await this.beginTransaction(isolationLevel);
168
+ try {
169
+ const result = await callback(this);
170
+ await this.commit();
171
+ return result;
172
+ }
173
+ catch (error) {
174
+ await this.rollback();
175
+ throw error;
176
+ }
177
+ }
178
+ /**
179
+ * Query helper for SELECT statements
180
+ *
181
+ * @param statement - SELECT statement
182
+ * @param params - Query parameters
183
+ * @returns Array of rows
184
+ */
185
+ async query(statement, params) {
186
+ const result = await this.execute(statement, params);
187
+ return result.rows;
188
+ }
189
+ /**
190
+ * Execute helper for INSERT/UPDATE/DELETE statements
191
+ *
192
+ * @param statement - SQL statement
193
+ * @param params - Statement parameters
194
+ * @returns Number of affected rows and insert ID if applicable
195
+ */
196
+ async run(statement, params) {
197
+ const result = await this.execute(statement, params);
198
+ return {
199
+ rowsAffected: result.rowsAffected,
200
+ insertId: result.insertId,
201
+ };
202
+ }
203
+ /**
204
+ * Serialize parameters for transmission
205
+ * Binary data (Uint8Array) is converted to base64 for JSON transport
206
+ */
207
+ serializeParams(params) {
208
+ return params.map((param) => {
209
+ if (param instanceof Uint8Array) {
210
+ return {
211
+ _type: 'binary',
212
+ _data: this.uint8ArrayToBase64(param),
213
+ };
214
+ }
215
+ return param;
216
+ });
217
+ }
218
+ /**
219
+ * Deserialize result from server
220
+ * Base64-encoded binary data is converted back to Uint8Array
221
+ */
222
+ deserializeResult(result) {
223
+ return {
224
+ rows: result.rows.map((row) => {
225
+ const deserializedRow = {};
226
+ for (const [key, value] of Object.entries(row)) {
227
+ if (value &&
228
+ typeof value === 'object' &&
229
+ value._type === 'binary') {
230
+ deserializedRow[key] = this.base64ToUint8Array(value._data);
231
+ }
232
+ else {
233
+ deserializedRow[key] = value;
234
+ }
235
+ }
236
+ return deserializedRow;
237
+ }),
238
+ rowsAffected: result.rowsAffected || 0,
239
+ insertId: result.insertId,
240
+ };
241
+ }
242
+ /**
243
+ * Convert Uint8Array to base64 string
244
+ */
245
+ uint8ArrayToBase64(bytes) {
246
+ let binary = '';
247
+ for (let i = 0; i < bytes.byteLength; i++) {
248
+ binary += String.fromCharCode(bytes[i]);
249
+ }
250
+ return btoa(binary);
251
+ }
252
+ /**
253
+ * Convert base64 string to Uint8Array
254
+ */
255
+ base64ToUint8Array(base64) {
256
+ const binary = atob(base64);
257
+ const bytes = new Uint8Array(binary.length);
258
+ for (let i = 0; i < binary.length; i++) {
259
+ bytes[i] = binary.charCodeAt(i);
260
+ }
261
+ return bytes;
262
+ }
263
+ }
264
+
265
+ /**
266
+ * NativeSQL - High-level API for managing SQL connections
267
+ *
268
+ * This class provides a convenient interface for opening/closing database connections
269
+ * and managing multiple databases simultaneously.
270
+ */
271
+ class NativeSQL {
272
+ /**
273
+ * Open a database connection
274
+ *
275
+ * @param options - Connection options
276
+ * @returns SQLConnection instance for executing queries
277
+ */
278
+ static async connect(options) {
279
+ // Check if already connected
280
+ if (this.connections.has(options.database)) {
281
+ return this.connections.get(options.database);
282
+ }
283
+ // Connect via native plugin
284
+ const info = await CapgoCapacitorNativeSql.connect(options);
285
+ // Create connection instance
286
+ const connection = new SQLConnection(info.database, info.port, info.token);
287
+ // Store connection
288
+ this.connections.set(options.database, connection);
289
+ return connection;
290
+ }
291
+ /**
292
+ * Close a database connection
293
+ *
294
+ * @param database - Database name to close
295
+ */
296
+ static async disconnect(database) {
297
+ const connection = this.connections.get(database);
298
+ if (!connection) {
299
+ throw new Error(`Database '${database}' is not connected`);
300
+ }
301
+ // Disconnect via native plugin
302
+ await CapgoCapacitorNativeSql.disconnect({ database });
303
+ // Remove connection
304
+ this.connections.delete(database);
305
+ }
306
+ /**
307
+ * Get an existing connection
308
+ *
309
+ * @param database - Database name
310
+ * @returns SQLConnection instance or null if not connected
311
+ */
312
+ static getConnection(database) {
313
+ return this.connections.get(database) || null;
314
+ }
315
+ /**
316
+ * Close all open connections
317
+ */
318
+ static async disconnectAll() {
319
+ const databases = Array.from(this.connections.keys());
320
+ await Promise.all(databases.map((db) => this.disconnect(db)));
321
+ }
322
+ /**
323
+ * Get list of all open database connections
324
+ *
325
+ * @returns Array of database names
326
+ */
327
+ static getOpenDatabases() {
328
+ return Array.from(this.connections.keys());
329
+ }
330
+ }
331
+ NativeSQL.connections = new Map();
332
+
333
+ /**
334
+ * Web implementation using sql.js (SQLite compiled to WebAssembly)
335
+ *
336
+ * This provides a compatible API on the web platform, storing databases
337
+ * in IndexedDB for persistence.
338
+ */
339
+ class CapgoCapacitorNativeSqlWeb extends core.WebPlugin {
340
+ constructor() {
341
+ super();
342
+ this.databases = new Map();
343
+ this.sqlPromise = null;
344
+ this.nextPort = 9000;
345
+ this.loadSqlJs();
346
+ }
347
+ /**
348
+ * Load sql.js library
349
+ */
350
+ async loadSqlJs() {
351
+ if (this.sqlPromise)
352
+ return;
353
+ this.sqlPromise = new Promise(async (resolve, reject) => {
354
+ try {
355
+ // Load sql.js from CDN
356
+ const script = document.createElement('script');
357
+ script.src =
358
+ 'https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/sql-wasm.js';
359
+ script.onload = async () => {
360
+ const initSqlJs = window.initSqlJs;
361
+ const SQL = await initSqlJs({
362
+ locateFile: (file) => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/${file}`,
363
+ });
364
+ resolve(SQL);
365
+ };
366
+ script.onerror = reject;
367
+ document.head.appendChild(script);
368
+ }
369
+ catch (error) {
370
+ reject(error);
371
+ }
372
+ });
373
+ }
374
+ async connect(options) {
375
+ const SQL = await this.sqlPromise;
376
+ // Check if database already exists in IndexedDB
377
+ const savedData = await this.loadFromIndexedDB(options.database);
378
+ let db;
379
+ if (savedData) {
380
+ db = new SQL.Database(savedData);
381
+ }
382
+ else {
383
+ db = new SQL.Database();
384
+ }
385
+ const token = this.generateToken();
386
+ const port = this.nextPort++;
387
+ this.databases.set(options.database, { db, token, port });
388
+ return {
389
+ port,
390
+ token,
391
+ database: options.database,
392
+ };
393
+ }
394
+ async disconnect(options) {
395
+ const dbInfo = this.databases.get(options.database);
396
+ if (!dbInfo) {
397
+ throw new Error(`Database '${options.database}' is not connected`);
398
+ }
399
+ // Save to IndexedDB before closing
400
+ const data = dbInfo.db.export();
401
+ await this.saveToIndexedDB(options.database, data);
402
+ dbInfo.db.close();
403
+ this.databases.delete(options.database);
404
+ }
405
+ async getServerInfo(options) {
406
+ const dbInfo = this.databases.get(options.database);
407
+ if (!dbInfo) {
408
+ throw new Error(`Database '${options.database}' is not connected`);
409
+ }
410
+ return {
411
+ port: dbInfo.port,
412
+ token: dbInfo.token,
413
+ };
414
+ }
415
+ async execute(options) {
416
+ const dbInfo = this.databases.get(options.database);
417
+ if (!dbInfo) {
418
+ throw new Error(`Database '${options.database}' is not connected`);
419
+ }
420
+ try {
421
+ const stmt = dbInfo.db.prepare(options.statement);
422
+ if (options.params) {
423
+ stmt.bind(options.params);
424
+ }
425
+ const rows = [];
426
+ while (stmt.step()) {
427
+ const row = stmt.getAsObject();
428
+ rows.push(row);
429
+ }
430
+ stmt.free();
431
+ // Get changes and last insert ID
432
+ const changes = dbInfo.db.getRowsModified();
433
+ const insertId = this.getLastInsertId(dbInfo.db);
434
+ return {
435
+ rows,
436
+ rowsAffected: changes,
437
+ insertId: insertId > 0 ? insertId : undefined,
438
+ };
439
+ }
440
+ catch (error) {
441
+ throw new Error(`SQL execution failed: ${error.message}`);
442
+ }
443
+ }
444
+ async beginTransaction(options) {
445
+ await this.execute({
446
+ database: options.database,
447
+ statement: 'BEGIN TRANSACTION',
448
+ });
449
+ }
450
+ async commitTransaction(options) {
451
+ await this.execute({
452
+ database: options.database,
453
+ statement: 'COMMIT',
454
+ });
455
+ }
456
+ async rollbackTransaction(options) {
457
+ await this.execute({
458
+ database: options.database,
459
+ statement: 'ROLLBACK',
460
+ });
461
+ }
462
+ /**
463
+ * Generate a random authentication token
464
+ */
465
+ generateToken() {
466
+ return Array.from(crypto.getRandomValues(new Uint8Array(32)))
467
+ .map((b) => b.toString(16).padStart(2, '0'))
468
+ .join('');
469
+ }
470
+ /**
471
+ * Get last insert row ID
472
+ */
473
+ getLastInsertId(db) {
474
+ try {
475
+ const result = db.exec('SELECT last_insert_rowid()');
476
+ if (result.length > 0 && result[0].values.length > 0) {
477
+ return result[0].values[0][0];
478
+ }
479
+ }
480
+ catch (_a) {
481
+ // Ignore error
482
+ }
483
+ return -1;
484
+ }
485
+ /**
486
+ * Save database to IndexedDB
487
+ */
488
+ async saveToIndexedDB(dbName, data) {
489
+ return new Promise((resolve, reject) => {
490
+ const request = indexedDB.open('CapacitorNativeSQL', 1);
491
+ request.onerror = () => reject(request.error);
492
+ request.onupgradeneeded = (event) => {
493
+ const db = event.target.result;
494
+ if (!db.objectStoreNames.contains('databases')) {
495
+ db.createObjectStore('databases');
496
+ }
497
+ };
498
+ request.onsuccess = () => {
499
+ const db = request.result;
500
+ const transaction = db.transaction(['databases'], 'readwrite');
501
+ const store = transaction.objectStore('databases');
502
+ const putRequest = store.put(data, dbName);
503
+ putRequest.onsuccess = () => {
504
+ db.close();
505
+ resolve();
506
+ };
507
+ putRequest.onerror = () => {
508
+ db.close();
509
+ reject(putRequest.error);
510
+ };
511
+ };
512
+ });
513
+ }
514
+ /**
515
+ * Load database from IndexedDB
516
+ */
517
+ async loadFromIndexedDB(dbName) {
518
+ return new Promise((resolve, reject) => {
519
+ const request = indexedDB.open('CapacitorNativeSQL', 1);
520
+ request.onerror = () => reject(request.error);
521
+ request.onupgradeneeded = (event) => {
522
+ const db = event.target.result;
523
+ if (!db.objectStoreNames.contains('databases')) {
524
+ db.createObjectStore('databases');
525
+ }
526
+ };
527
+ request.onsuccess = () => {
528
+ const db = request.result;
529
+ const transaction = db.transaction(['databases'], 'readonly');
530
+ const store = transaction.objectStore('databases');
531
+ const getRequest = store.get(dbName);
532
+ getRequest.onsuccess = () => {
533
+ db.close();
534
+ resolve(getRequest.result || null);
535
+ };
536
+ getRequest.onerror = () => {
537
+ db.close();
538
+ reject(getRequest.error);
539
+ };
540
+ };
541
+ });
542
+ }
543
+ async getPluginVersion() {
544
+ return { version: "web" };
545
+ }
546
+ }
547
+
548
+ var web = /*#__PURE__*/Object.freeze({
549
+ __proto__: null,
550
+ CapgoCapacitorNativeSqlWeb: CapgoCapacitorNativeSqlWeb
551
+ });
552
+
553
+ exports.CapgoCapacitorNativeSql = CapgoCapacitorNativeSql;
554
+ exports.NativeSQL = NativeSQL;
555
+ exports.SQLConnection = SQLConnection;
556
+
557
+ return exports;
558
+
559
+ })({}, capacitorExports);
560
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/plugin.js","esm/sql-connection.js","esm/native-sql.js","esm/web.js"],"sourcesContent":["/**\n * Transaction isolation levels\n */\nexport var IsolationLevel;\n(function (IsolationLevel) {\n IsolationLevel[\"ReadUncommitted\"] = \"READ UNCOMMITTED\";\n IsolationLevel[\"ReadCommitted\"] = \"READ COMMITTED\";\n IsolationLevel[\"RepeatableRead\"] = \"REPEATABLE READ\";\n IsolationLevel[\"Serializable\"] = \"SERIALIZABLE\";\n})(IsolationLevel || (IsolationLevel = {}));\n","import { registerPlugin } from '@capacitor/core';\nexport const CapgoCapacitorNativeSql = registerPlugin('CapgoCapacitorNativeSql', {\n web: () => import('./web').then((m) => new m.CapgoCapacitorNativeSqlWeb()),\n});\n","import { IsolationLevel } from './definitions';\n/**\n * SQL Connection class that uses HTTP protocol for efficient communication\n * with native SQLite databases, bypassing Capacitor's standard bridge.\n *\n * Inspired by capacitor-blob-writer's approach to avoid serialization overhead.\n */\nexport class SQLConnection {\n constructor(database, port, token) {\n this.inTransaction = false;\n this.database = database;\n this.port = port;\n this.token = token;\n this.baseUrl = `http://localhost:${port}`;\n }\n /**\n * Get the database name\n */\n getDatabaseName() {\n return this.database;\n }\n /**\n * Execute a SQL query via HTTP protocol for optimal performance\n *\n * @param statement - SQL statement to execute\n * @param params - Parameters to bind to the statement\n * @returns Query results\n */\n async execute(statement, params) {\n const response = await fetch(`${this.baseUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n statement,\n params: params ? this.serializeParams(params) : [],\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL execution failed: ${error}`);\n }\n const result = await response.json();\n return this.deserializeResult(result);\n }\n /**\n * Execute multiple SQL statements in a batch for better performance\n *\n * @param operations - Array of SQL operations to execute\n * @returns Array of results for each operation\n */\n async executeBatch(operations) {\n const response = await fetch(`${this.baseUrl}/batch`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n operations: operations.map((op) => ({\n statement: op.statement,\n params: op.params ? this.serializeParams(op.params) : [],\n })),\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL batch execution failed: ${error}`);\n }\n const results = await response.json();\n return results.map((r) => this.deserializeResult(r));\n }\n /**\n * Begin a transaction\n *\n * @param isolationLevel - Optional isolation level\n */\n async beginTransaction(isolationLevel) {\n if (this.inTransaction) {\n throw new Error('Transaction already in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/begin`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n isolationLevel: isolationLevel || IsolationLevel.Serializable,\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to begin transaction: ${error}`);\n }\n this.inTransaction = true;\n }\n /**\n * Commit the current transaction\n */\n async commit() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/commit`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to commit transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Rollback the current transaction\n */\n async rollback() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/rollback`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to rollback transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Execute operations within a transaction automatically\n *\n * @param callback - Function containing operations to execute\n * @param isolationLevel - Optional isolation level\n */\n async transaction(callback, isolationLevel) {\n await this.beginTransaction(isolationLevel);\n try {\n const result = await callback(this);\n await this.commit();\n return result;\n }\n catch (error) {\n await this.rollback();\n throw error;\n }\n }\n /**\n * Query helper for SELECT statements\n *\n * @param statement - SELECT statement\n * @param params - Query parameters\n * @returns Array of rows\n */\n async query(statement, params) {\n const result = await this.execute(statement, params);\n return result.rows;\n }\n /**\n * Execute helper for INSERT/UPDATE/DELETE statements\n *\n * @param statement - SQL statement\n * @param params - Statement parameters\n * @returns Number of affected rows and insert ID if applicable\n */\n async run(statement, params) {\n const result = await this.execute(statement, params);\n return {\n rowsAffected: result.rowsAffected,\n insertId: result.insertId,\n };\n }\n /**\n * Serialize parameters for transmission\n * Binary data (Uint8Array) is converted to base64 for JSON transport\n */\n serializeParams(params) {\n return params.map((param) => {\n if (param instanceof Uint8Array) {\n return {\n _type: 'binary',\n _data: this.uint8ArrayToBase64(param),\n };\n }\n return param;\n });\n }\n /**\n * Deserialize result from server\n * Base64-encoded binary data is converted back to Uint8Array\n */\n deserializeResult(result) {\n return {\n rows: result.rows.map((row) => {\n const deserializedRow = {};\n for (const [key, value] of Object.entries(row)) {\n if (value &&\n typeof value === 'object' &&\n value._type === 'binary') {\n deserializedRow[key] = this.base64ToUint8Array(value._data);\n }\n else {\n deserializedRow[key] = value;\n }\n }\n return deserializedRow;\n }),\n rowsAffected: result.rowsAffected || 0,\n insertId: result.insertId,\n };\n }\n /**\n * Convert Uint8Array to base64 string\n */\n uint8ArrayToBase64(bytes) {\n let binary = '';\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n /**\n * Convert base64 string to Uint8Array\n */\n base64ToUint8Array(base64) {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n}\n","import { CapgoCapacitorNativeSql } from './plugin';\nimport { SQLConnection } from './sql-connection';\n/**\n * NativeSQL - High-level API for managing SQL connections\n *\n * This class provides a convenient interface for opening/closing database connections\n * and managing multiple databases simultaneously.\n */\nexport class NativeSQL {\n /**\n * Open a database connection\n *\n * @param options - Connection options\n * @returns SQLConnection instance for executing queries\n */\n static async connect(options) {\n // Check if already connected\n if (this.connections.has(options.database)) {\n return this.connections.get(options.database);\n }\n // Connect via native plugin\n const info = await CapgoCapacitorNativeSql.connect(options);\n // Create connection instance\n const connection = new SQLConnection(info.database, info.port, info.token);\n // Store connection\n this.connections.set(options.database, connection);\n return connection;\n }\n /**\n * Close a database connection\n *\n * @param database - Database name to close\n */\n static async disconnect(database) {\n const connection = this.connections.get(database);\n if (!connection) {\n throw new Error(`Database '${database}' is not connected`);\n }\n // Disconnect via native plugin\n await CapgoCapacitorNativeSql.disconnect({ database });\n // Remove connection\n this.connections.delete(database);\n }\n /**\n * Get an existing connection\n *\n * @param database - Database name\n * @returns SQLConnection instance or null if not connected\n */\n static getConnection(database) {\n return this.connections.get(database) || null;\n }\n /**\n * Close all open connections\n */\n static async disconnectAll() {\n const databases = Array.from(this.connections.keys());\n await Promise.all(databases.map((db) => this.disconnect(db)));\n }\n /**\n * Get list of all open database connections\n *\n * @returns Array of database names\n */\n static getOpenDatabases() {\n return Array.from(this.connections.keys());\n }\n}\nNativeSQL.connections = new Map();\n","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation using sql.js (SQLite compiled to WebAssembly)\n *\n * This provides a compatible API on the web platform, storing databases\n * in IndexedDB for persistence.\n */\nexport class CapgoCapacitorNativeSqlWeb extends WebPlugin {\n constructor() {\n super();\n this.databases = new Map();\n this.sqlPromise = null;\n this.nextPort = 9000;\n this.loadSqlJs();\n }\n /**\n * Load sql.js library\n */\n async loadSqlJs() {\n if (this.sqlPromise)\n return;\n this.sqlPromise = new Promise(async (resolve, reject) => {\n try {\n // Load sql.js from CDN\n const script = document.createElement('script');\n script.src =\n 'https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/sql-wasm.js';\n script.onload = async () => {\n const initSqlJs = window.initSqlJs;\n const SQL = await initSqlJs({\n locateFile: (file) => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/${file}`,\n });\n resolve(SQL);\n };\n script.onerror = reject;\n document.head.appendChild(script);\n }\n catch (error) {\n reject(error);\n }\n });\n }\n async connect(options) {\n const SQL = await this.sqlPromise;\n // Check if database already exists in IndexedDB\n const savedData = await this.loadFromIndexedDB(options.database);\n let db;\n if (savedData) {\n db = new SQL.Database(savedData);\n }\n else {\n db = new SQL.Database();\n }\n const token = this.generateToken();\n const port = this.nextPort++;\n this.databases.set(options.database, { db, token, port });\n return {\n port,\n token,\n database: options.database,\n };\n }\n async disconnect(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n // Save to IndexedDB before closing\n const data = dbInfo.db.export();\n await this.saveToIndexedDB(options.database, data);\n dbInfo.db.close();\n this.databases.delete(options.database);\n }\n async getServerInfo(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n return {\n port: dbInfo.port,\n token: dbInfo.token,\n };\n }\n async execute(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n try {\n const stmt = dbInfo.db.prepare(options.statement);\n if (options.params) {\n stmt.bind(options.params);\n }\n const rows = [];\n while (stmt.step()) {\n const row = stmt.getAsObject();\n rows.push(row);\n }\n stmt.free();\n // Get changes and last insert ID\n const changes = dbInfo.db.getRowsModified();\n const insertId = this.getLastInsertId(dbInfo.db);\n return {\n rows,\n rowsAffected: changes,\n insertId: insertId > 0 ? insertId : undefined,\n };\n }\n catch (error) {\n throw new Error(`SQL execution failed: ${error.message}`);\n }\n }\n async beginTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'BEGIN TRANSACTION',\n });\n }\n async commitTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'COMMIT',\n });\n }\n async rollbackTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'ROLLBACK',\n });\n }\n /**\n * Generate a random authentication token\n */\n generateToken() {\n return Array.from(crypto.getRandomValues(new Uint8Array(32)))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n }\n /**\n * Get last insert row ID\n */\n getLastInsertId(db) {\n try {\n const result = db.exec('SELECT last_insert_rowid()');\n if (result.length > 0 && result[0].values.length > 0) {\n return result[0].values[0][0];\n }\n }\n catch (_a) {\n // Ignore error\n }\n return -1;\n }\n /**\n * Save database to IndexedDB\n */\n async saveToIndexedDB(dbName, data) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readwrite');\n const store = transaction.objectStore('databases');\n const putRequest = store.put(data, dbName);\n putRequest.onsuccess = () => {\n db.close();\n resolve();\n };\n putRequest.onerror = () => {\n db.close();\n reject(putRequest.error);\n };\n };\n });\n }\n /**\n * Load database from IndexedDB\n */\n async loadFromIndexedDB(dbName) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readonly');\n const store = transaction.objectStore('databases');\n const getRequest = store.get(dbName);\n getRequest.onsuccess = () => {\n db.close();\n resolve(getRequest.result || null);\n };\n getRequest.onerror = () => {\n db.close();\n reject(getRequest.error);\n };\n };\n });\n }\n async getPluginVersion() {\n return { version: \"web\" };\n }\n}\n"],"names":["IsolationLevel","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,cAAc,EAAE;IAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,kBAAkB;IAC1D,IAAI,cAAc,CAAC,eAAe,CAAC,GAAG,gBAAgB;IACtD,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;IACxD,IAAI,cAAc,CAAC,cAAc,CAAC,GAAG,cAAc;IACnD,CAAC,EAAEA,sBAAc,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