@powersync/web 0.0.0-dev-20240726145924 → 0.0.0-dev-20240807140418
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 +1 -25
- package/dist/_2e65-_0749-_dcb9-_0b6f-_ff61-_ec48-_1dff-_983a.index.umd.js +84 -0
- package/dist/_2e65-_0749-_dcb9-_0b6f-_ff61-_ec48-_1dff-_983a.index.umd.js.map +1 -0
- package/dist/a7933e62dba1e4ff0664.wasm +0 -0
- package/dist/index.umd.js +4816 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/lib_src_worker_db_SharedWASQLiteDB_worker_js.index.umd.js +490 -0
- package/dist/lib_src_worker_db_SharedWASQLiteDB_worker_js.index.umd.js.map +1 -0
- package/dist/lib_src_worker_db_WASQLiteDB_worker_js.index.umd.js +443 -0
- package/dist/lib_src_worker_db_WASQLiteDB_worker_js.index.umd.js.map +1 -0
- package/dist/lib_src_worker_sync_SharedSyncImplementation_worker_js.index.umd.js +1698 -0
- package/dist/lib_src_worker_sync_SharedSyncImplementation_worker_js.index.umd.js.map +1 -0
- package/dist/vendors-node_modules_async-mutex_index_mjs-node_modules_comlink_dist_esm_comlink_mjs-node_mod-037150.index.umd.js +2339 -0
- package/dist/vendors-node_modules_async-mutex_index_mjs-node_modules_comlink_dist_esm_comlink_mjs-node_mod-037150.index.umd.js.map +1 -0
- package/dist/vendors-node_modules_bson_lib_bson_mjs.index.umd.js +4437 -0
- package/dist/vendors-node_modules_bson_lib_bson_mjs.index.umd.js.map +1 -0
- package/dist/vendors-node_modules_crypto-browserify_index_js.index.umd.js +33502 -0
- package/dist/vendors-node_modules_crypto-browserify_index_js.index.umd.js.map +1 -0
- package/dist/vendors-node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.index.umd.js +173 -0
- package/dist/vendors-node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.index.umd.js.map +1 -0
- package/dist/vendors-node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.index.umd.js +1926 -0
- package/dist/vendors-node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.index.umd.js.map +1 -0
- package/lib/src/db/PowerSyncDatabase.js +32 -24
- package/lib/src/db/PowerSyncDatabase.js.map +1 -0
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +8 -1
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js.map +1 -0
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +3 -0
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js.map +1 -0
- package/lib/src/db/adapters/SSRDBAdapter.js +29 -48
- package/lib/src/db/adapters/SSRDBAdapter.js.map +1 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +106 -124
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js.map +1 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +5 -1
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js.map +1 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +1 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js.map +1 -0
- package/lib/src/db/adapters/web-sql-flags.js +7 -3
- package/lib/src/db/adapters/web-sql-flags.js.map +1 -0
- package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js +3 -0
- package/lib/src/db/sync/SSRWebStreamingSyncImplementation.js.map +1 -0
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +67 -95
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js.map +1 -0
- package/lib/src/db/sync/WebRemote.d.ts +5 -1
- package/lib/src/db/sync/WebRemote.js +30 -21
- package/lib/src/db/sync/WebRemote.js.map +1 -0
- package/lib/src/db/sync/WebStreamingSyncImplementation.js +1 -0
- package/lib/src/db/sync/WebStreamingSyncImplementation.js.map +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/shared/open-db.js +154 -184
- package/lib/src/shared/open-db.js.map +1 -0
- package/lib/src/shared/types.js +1 -0
- package/lib/src/shared/types.js.map +1 -0
- package/lib/src/worker/db/SharedWASQLiteDB.worker.js +16 -23
- package/lib/src/worker/db/SharedWASQLiteDB.worker.js.map +1 -0
- package/lib/src/worker/db/WASQLiteDB.worker.js +2 -10
- package/lib/src/worker/db/WASQLiteDB.worker.js.map +1 -0
- package/lib/src/worker/db/open-worker-database.js +1 -0
- package/lib/src/worker/db/open-worker-database.js.map +1 -0
- package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js +1 -0
- package/lib/src/worker/sync/AbstractSharedSyncClientProvider.js.map +1 -0
- package/lib/src/worker/sync/BroadcastLogger.js +17 -19
- package/lib/src/worker/sync/BroadcastLogger.js.map +1 -0
- package/lib/src/worker/sync/SharedSyncImplementation.js +97 -115
- package/lib/src/worker/sync/SharedSyncImplementation.js.map +1 -0
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js +2 -5
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -7
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { BaseObserver } from '@powersync/common';
|
|
11
2
|
import * as Comlink from 'comlink';
|
|
12
3
|
import Logger from 'js-logger';
|
|
@@ -16,36 +7,25 @@ import { getWorkerDatabaseOpener } from '../../../worker/db/open-worker-database
|
|
|
16
7
|
* Adapter for WA-SQLite SQLite connections.
|
|
17
8
|
*/
|
|
18
9
|
export class WASQLiteDBAdapter extends BaseObserver {
|
|
10
|
+
options;
|
|
11
|
+
initialized;
|
|
12
|
+
logger;
|
|
13
|
+
dbGetHelpers;
|
|
14
|
+
methods;
|
|
15
|
+
debugMode;
|
|
19
16
|
constructor(options) {
|
|
20
|
-
var _a;
|
|
21
17
|
super();
|
|
22
18
|
this.options = options;
|
|
23
|
-
/**
|
|
24
|
-
* Wraps the worker execute function, awaiting for it to be available
|
|
25
|
-
*/
|
|
26
|
-
this._execute = (sql, bindings) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
yield this.initialized;
|
|
28
|
-
const result = yield this.methods.execute(sql, bindings);
|
|
29
|
-
return Object.assign(Object.assign({}, result), { rows: Object.assign(Object.assign({}, result.rows), { item: (idx) => result.rows._array[idx] }) });
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Wraps the worker executeBatch function, awaiting for it to be available
|
|
33
|
-
*/
|
|
34
|
-
this._executeBatch = (query, params) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
yield this.initialized;
|
|
36
|
-
const result = yield this.methods.executeBatch(query, params);
|
|
37
|
-
return Object.assign(Object.assign({}, result), { rows: undefined });
|
|
38
|
-
});
|
|
39
19
|
this.logger = Logger.get('WASQLite');
|
|
40
20
|
this.dbGetHelpers = null;
|
|
41
21
|
this.methods = null;
|
|
42
|
-
this.debugMode =
|
|
22
|
+
this.debugMode = options.debugMode ?? false;
|
|
43
23
|
if (this.debugMode) {
|
|
44
24
|
const originalExecute = this._execute.bind(this);
|
|
45
|
-
this._execute = (sql, bindings) =>
|
|
25
|
+
this._execute = async (sql, bindings) => {
|
|
46
26
|
const start = performance.now();
|
|
47
27
|
try {
|
|
48
|
-
const r =
|
|
28
|
+
const r = await originalExecute(sql, bindings);
|
|
49
29
|
performance.measure(`[SQL] ${sql}`, { start });
|
|
50
30
|
return r;
|
|
51
31
|
}
|
|
@@ -53,7 +33,7 @@ export class WASQLiteDBAdapter extends BaseObserver {
|
|
|
53
33
|
performance.measure(`[SQL] [ERROR: ${e.message}] ${sql}`, { start });
|
|
54
34
|
throw e;
|
|
55
35
|
}
|
|
56
|
-
}
|
|
36
|
+
};
|
|
57
37
|
}
|
|
58
38
|
this.initialized = this.init();
|
|
59
39
|
this.dbGetHelpers = this.generateDBHelpers({
|
|
@@ -64,88 +44,93 @@ export class WASQLiteDBAdapter extends BaseObserver {
|
|
|
64
44
|
return this.options.dbFilename;
|
|
65
45
|
}
|
|
66
46
|
get flags() {
|
|
67
|
-
|
|
68
|
-
return (_a = this.options.flags) !== null && _a !== void 0 ? _a : {};
|
|
47
|
+
return this.options.flags ?? {};
|
|
69
48
|
}
|
|
70
49
|
getWorker() { }
|
|
71
|
-
init() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
this.iterateListeners((cb) => { var _a; return (_a = cb.tablesUpdated) === null || _a === void 0 ? void 0 : _a.call(cb, { opType, table: tableName, rowId }); });
|
|
90
|
-
});
|
|
50
|
+
async init() {
|
|
51
|
+
const { enableMultiTabs, useWebWorker } = this.flags;
|
|
52
|
+
if (!enableMultiTabs) {
|
|
53
|
+
this.logger.warn('Multiple tabs are not enabled in this browser');
|
|
54
|
+
}
|
|
55
|
+
if (useWebWorker) {
|
|
56
|
+
const dbOpener = this.options.workerPort
|
|
57
|
+
? Comlink.wrap(this.options.workerPort)
|
|
58
|
+
: getWorkerDatabaseOpener(this.options.dbFilename, enableMultiTabs);
|
|
59
|
+
this.methods = await dbOpener(this.options.dbFilename);
|
|
60
|
+
this.methods.registerOnTableChange(Comlink.proxy((opType, tableName, rowId) => {
|
|
61
|
+
this.iterateListeners((cb) => cb.tablesUpdated?.({ opType, table: tableName, rowId }));
|
|
62
|
+
}));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.methods = await _openDB(this.options.dbFilename, { useWebWorker: false });
|
|
66
|
+
this.methods.registerOnTableChange((opType, tableName, rowId) => {
|
|
67
|
+
this.iterateListeners((cb) => cb.tablesUpdated?.({ opType, table: tableName, rowId }));
|
|
91
68
|
});
|
|
92
69
|
}
|
|
93
|
-
execute(query, params) {
|
|
94
|
-
return
|
|
95
|
-
return this.writeLock((ctx) => ctx.execute(query, params));
|
|
96
|
-
});
|
|
70
|
+
async execute(query, params) {
|
|
71
|
+
return this.writeLock((ctx) => ctx.execute(query, params));
|
|
97
72
|
}
|
|
98
|
-
executeBatch(query, params) {
|
|
99
|
-
return
|
|
100
|
-
return this.writeLock((ctx) => this._executeBatch(query, params));
|
|
101
|
-
});
|
|
73
|
+
async executeBatch(query, params) {
|
|
74
|
+
return this.writeLock((ctx) => this._executeBatch(query, params));
|
|
102
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Wraps the worker execute function, awaiting for it to be available
|
|
78
|
+
*/
|
|
79
|
+
_execute = async (sql, bindings) => {
|
|
80
|
+
await this.initialized;
|
|
81
|
+
const result = await this.methods.execute(sql, bindings);
|
|
82
|
+
return {
|
|
83
|
+
...result,
|
|
84
|
+
rows: {
|
|
85
|
+
...result.rows,
|
|
86
|
+
item: (idx) => result.rows._array[idx]
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Wraps the worker executeBatch function, awaiting for it to be available
|
|
92
|
+
*/
|
|
93
|
+
_executeBatch = async (query, params) => {
|
|
94
|
+
await this.initialized;
|
|
95
|
+
const result = await this.methods.executeBatch(query, params);
|
|
96
|
+
return {
|
|
97
|
+
...result,
|
|
98
|
+
rows: undefined
|
|
99
|
+
};
|
|
100
|
+
};
|
|
103
101
|
/**
|
|
104
102
|
* Attempts to close the connection.
|
|
105
103
|
* Shared workers might not actually close the connection if other
|
|
106
104
|
* tabs are still using it.
|
|
107
105
|
*/
|
|
108
106
|
close() {
|
|
109
|
-
|
|
110
|
-
(_b = (_a = this.methods) === null || _a === void 0 ? void 0 : _a.close) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
107
|
+
this.methods?.close?.();
|
|
111
108
|
}
|
|
112
|
-
getAll(sql, parameters) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return this.dbGetHelpers.getAll(sql, parameters);
|
|
116
|
-
});
|
|
109
|
+
async getAll(sql, parameters) {
|
|
110
|
+
await this.initialized;
|
|
111
|
+
return this.dbGetHelpers.getAll(sql, parameters);
|
|
117
112
|
}
|
|
118
|
-
getOptional(sql, parameters) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return this.dbGetHelpers.getOptional(sql, parameters);
|
|
122
|
-
});
|
|
113
|
+
async getOptional(sql, parameters) {
|
|
114
|
+
await this.initialized;
|
|
115
|
+
return this.dbGetHelpers.getOptional(sql, parameters);
|
|
123
116
|
}
|
|
124
|
-
get(sql, parameters) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return this.dbGetHelpers.get(sql, parameters);
|
|
128
|
-
});
|
|
117
|
+
async get(sql, parameters) {
|
|
118
|
+
await this.initialized;
|
|
119
|
+
return this.dbGetHelpers.get(sql, parameters);
|
|
129
120
|
}
|
|
130
|
-
readLock(fn, options) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return this.acquireLock(() => __awaiter(this, void 0, void 0, function* () { return fn(this.generateDBHelpers({ execute: this._execute })); }));
|
|
134
|
-
});
|
|
121
|
+
async readLock(fn, options) {
|
|
122
|
+
await this.initialized;
|
|
123
|
+
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute })));
|
|
135
124
|
}
|
|
136
|
-
writeLock(fn, options) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return this.acquireLock(() => __awaiter(this, void 0, void 0, function* () { return fn(this.generateDBHelpers({ execute: this._execute })); }));
|
|
140
|
-
});
|
|
125
|
+
async writeLock(fn, options) {
|
|
126
|
+
await this.initialized;
|
|
127
|
+
return this.acquireLock(async () => fn(this.generateDBHelpers({ execute: this._execute })));
|
|
141
128
|
}
|
|
142
129
|
acquireLock(callback) {
|
|
143
130
|
return navigator.locks.request(`db-lock-${this.options.dbFilename}`, callback);
|
|
144
131
|
}
|
|
145
|
-
readTransaction(fn, options) {
|
|
146
|
-
return
|
|
147
|
-
return this.readLock(this.wrapTransaction(fn));
|
|
148
|
-
});
|
|
132
|
+
async readTransaction(fn, options) {
|
|
133
|
+
return this.readLock(this.wrapTransaction(fn));
|
|
149
134
|
}
|
|
150
135
|
writeTransaction(fn, options) {
|
|
151
136
|
return this.writeLock(this.wrapTransaction(fn));
|
|
@@ -154,32 +139,35 @@ export class WASQLiteDBAdapter extends BaseObserver {
|
|
|
154
139
|
* Wraps a lock context into a transaction context
|
|
155
140
|
*/
|
|
156
141
|
wrapTransaction(cb) {
|
|
157
|
-
return (tx) =>
|
|
158
|
-
|
|
142
|
+
return async (tx) => {
|
|
143
|
+
await this._execute('BEGIN TRANSACTION');
|
|
159
144
|
let finalized = false;
|
|
160
|
-
const commit = () =>
|
|
145
|
+
const commit = async () => {
|
|
161
146
|
if (finalized) {
|
|
162
147
|
return { rowsAffected: 0 };
|
|
163
148
|
}
|
|
164
149
|
finalized = true;
|
|
165
150
|
return this._execute('COMMIT');
|
|
166
|
-
}
|
|
151
|
+
};
|
|
167
152
|
const rollback = () => {
|
|
168
153
|
finalized = true;
|
|
169
154
|
return this._execute('ROLLBACK');
|
|
170
155
|
};
|
|
171
156
|
try {
|
|
172
|
-
const result =
|
|
173
|
-
|
|
157
|
+
const result = await cb({
|
|
158
|
+
...tx,
|
|
159
|
+
commit,
|
|
160
|
+
rollback
|
|
161
|
+
});
|
|
174
162
|
if (!finalized) {
|
|
175
|
-
|
|
163
|
+
await commit();
|
|
176
164
|
}
|
|
177
165
|
return result;
|
|
178
166
|
}
|
|
179
167
|
catch (ex) {
|
|
180
168
|
this.logger.debug('Caught ex in transaction', ex);
|
|
181
169
|
try {
|
|
182
|
-
|
|
170
|
+
await rollback();
|
|
183
171
|
}
|
|
184
172
|
catch (ex2) {
|
|
185
173
|
// In rare cases, a rollback may fail.
|
|
@@ -187,43 +175,37 @@ export class WASQLiteDBAdapter extends BaseObserver {
|
|
|
187
175
|
}
|
|
188
176
|
throw ex;
|
|
189
177
|
}
|
|
190
|
-
}
|
|
178
|
+
};
|
|
191
179
|
}
|
|
192
180
|
generateDBHelpers(tx) {
|
|
193
|
-
return
|
|
181
|
+
return {
|
|
182
|
+
...tx,
|
|
194
183
|
/**
|
|
195
184
|
* Execute a read-only query and return results
|
|
196
185
|
*/
|
|
197
|
-
getAll(sql, parameters) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const res = yield tx.execute(sql, parameters);
|
|
201
|
-
return (_b = (_a = res.rows) === null || _a === void 0 ? void 0 : _a._array) !== null && _b !== void 0 ? _b : [];
|
|
202
|
-
});
|
|
186
|
+
async getAll(sql, parameters) {
|
|
187
|
+
const res = await tx.execute(sql, parameters);
|
|
188
|
+
return res.rows?._array ?? [];
|
|
203
189
|
},
|
|
204
190
|
/**
|
|
205
191
|
* Execute a read-only query and return the first result, or null if the ResultSet is empty.
|
|
206
192
|
*/
|
|
207
|
-
getOptional(sql, parameters) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const res = yield tx.execute(sql, parameters);
|
|
211
|
-
return (_b = (_a = res.rows) === null || _a === void 0 ? void 0 : _a.item(0)) !== null && _b !== void 0 ? _b : null;
|
|
212
|
-
});
|
|
193
|
+
async getOptional(sql, parameters) {
|
|
194
|
+
const res = await tx.execute(sql, parameters);
|
|
195
|
+
return res.rows?.item(0) ?? null;
|
|
213
196
|
},
|
|
214
197
|
/**
|
|
215
198
|
* Execute a read-only query and return the first result, error if the ResultSet is empty.
|
|
216
199
|
*/
|
|
217
|
-
get(sql, parameters) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
});
|
|
227
|
-
} });
|
|
200
|
+
async get(sql, parameters) {
|
|
201
|
+
const res = await tx.execute(sql, parameters);
|
|
202
|
+
const first = res.rows?.item(0);
|
|
203
|
+
if (!first) {
|
|
204
|
+
throw new Error('Result set is empty');
|
|
205
|
+
}
|
|
206
|
+
return first;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
228
209
|
}
|
|
229
210
|
}
|
|
211
|
+
//# sourceMappingURL=WASQLiteDBAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WASQLiteDBAdapter.js","sourceRoot":"","sources":["../../../../../src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAkBlF;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,YAA+B;IAO9C;IANd,WAAW,CAAgB;IAC3B,MAAM,CAAU;IAChB,YAAY,CAAoB;IAChC,OAAO,CAA8B;IACrC,SAAS,CAAU;IAE3B,YAAsB,OAAiC;QACrD,KAAK,EAAE,CAAC;QADY,YAAO,GAAP,OAAO,CAA0B;QAErD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;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|
5
5
|
*/
|
|
6
6
|
export class WASQLiteOpenFactory extends AbstractWebSQLOpenFactory {
|
|
7
7
|
openAdapter() {
|
|
8
|
-
return new WASQLiteDBAdapter(
|
|
8
|
+
return new WASQLiteDBAdapter({
|
|
9
|
+
...this.options,
|
|
10
|
+
flags: this.resolvedFlags
|
|
11
|
+
});
|
|
9
12
|
}
|
|
10
13
|
}
|
|
14
|
+
//# sourceMappingURL=WASQLiteOpenFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WASQLiteOpenFactory.js","sourceRoot":"","sources":["../../../../../src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,yBAAyB;IACtD,WAAW;QACnB,OAAO,IAAI,iBAAiB,CAAC;YAC3B,GAAG,IAAI,CAAC,OAAO;YACf,KAAK,EAAE,IAAI,CAAC,aAAa;SAC1B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WASQLitePowerSyncDatabaseOpenFactory.js","sourceRoot":"","sources":["../../../../../src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4CAA4C,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,OAAO,oCAAqC,SAAQ,uCAAuC;IACrF,MAAM;QACd,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB,CAAC,OAAiC;QAChD,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -16,12 +16,16 @@ export const DEFAULT_WEB_SQL_FLAGS = {
|
|
|
16
16
|
useWebWorker: true
|
|
17
17
|
};
|
|
18
18
|
export function resolveWebSQLFlags(flags) {
|
|
19
|
-
const resolvedFlags =
|
|
20
|
-
|
|
19
|
+
const resolvedFlags = {
|
|
20
|
+
...DEFAULT_WEB_SQL_FLAGS,
|
|
21
|
+
...(flags ?? {})
|
|
22
|
+
};
|
|
23
|
+
if (typeof flags?.enableMultiTabs != 'undefined') {
|
|
21
24
|
resolvedFlags.enableMultiTabs = flags.enableMultiTabs;
|
|
22
25
|
}
|
|
23
|
-
if (
|
|
26
|
+
if (flags?.useWebWorker === false) {
|
|
24
27
|
resolvedFlags.enableMultiTabs = false;
|
|
25
28
|
}
|
|
26
29
|
return resolvedFlags;
|
|
27
30
|
}
|
|
31
|
+
//# sourceMappingURL=web-sql-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-sql-flags.js","sourceRoot":"","sources":["../../../../src/db/adapters/web-sql-flags.ts"],"names":[],"mappings":"AA6CA,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,MAAM,IAAI,WAAW,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,KAAK;IACxB,OAAO,EAAE,YAAY,EAAE;IACvB;;;OAGG;IACH,eAAe,EACb,OAAO,UAAU,CAAC,SAAS,KAAK,WAAW,IAAI,mBAAmB;QAClE,OAAO,YAAY,KAAK,WAAW;QACnC,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,6BAA6B,CAAC;QACzD,CAAE,MAAc,CAAC,MAAM;IACzB,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,MAAM,aAAa,GAAG;QACpB,GAAG,qBAAqB;QACxB,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACjB,CAAC;IACF,IAAI,OAAO,KAAK,EAAE,eAAe,IAAI,WAAW,EAAE,CAAC;QACjD,aAAa,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IACxD,CAAC;IACD,IAAI,KAAK,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;QAClC,aAAa,CAAC,eAAe,GAAG,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AbstractStreamingSyncImplementation, LockType } from '@powersync/common';
|
|
2
2
|
import { Mutex } from 'async-mutex';
|
|
3
3
|
export class SSRStreamingSyncImplementation extends AbstractStreamingSyncImplementation {
|
|
4
|
+
syncMutex;
|
|
5
|
+
crudMutex;
|
|
4
6
|
constructor(options) {
|
|
5
7
|
super(options);
|
|
6
8
|
this.syncMutex = new Mutex();
|
|
@@ -11,3 +13,4 @@ export class SSRStreamingSyncImplementation extends AbstractStreamingSyncImpleme
|
|
|
11
13
|
return mutex.runExclusive(lockOptions.callback);
|
|
12
14
|
}
|
|
13
15
|
}
|
|
16
|
+
//# sourceMappingURL=SSRWebStreamingSyncImplementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSRWebStreamingSyncImplementation.js","sourceRoot":"","sources":["../../../../src/db/sync/SSRWebStreamingSyncImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EAGnC,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,OAAO,8BAA+B,SAAQ,mCAAmC;IACrF,SAAS,CAAQ;IACjB,SAAS,CAAQ;IAEjB,YAAY,OAAmD;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,UAAU,CAAI,WAA2B;QACvC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QAClF,OAAO,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import * as Comlink from 'comlink';
|
|
11
2
|
import { WebStreamingSyncImplementation } from './WebStreamingSyncImplementation';
|
|
12
3
|
import { SharedSyncClientEvent } from '../../worker/sync/SharedSyncImplementation';
|
|
@@ -17,76 +8,70 @@ import { openWorkerDatabasePort } from '../../worker/db/open-worker-database';
|
|
|
17
8
|
* via this client provider.
|
|
18
9
|
*/
|
|
19
10
|
class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
|
|
11
|
+
options;
|
|
12
|
+
statusChanged;
|
|
20
13
|
constructor(options, statusChanged) {
|
|
21
14
|
super();
|
|
22
15
|
this.options = options;
|
|
23
16
|
this.statusChanged = statusChanged;
|
|
24
17
|
}
|
|
25
|
-
fetchCredentials() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
});
|
|
18
|
+
async fetchCredentials() {
|
|
19
|
+
const credentials = await this.options.remote.getCredentials();
|
|
20
|
+
if (credentials == null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The credentials need to be serializable.
|
|
25
|
+
* Users might extend [PowerSyncCredentials] to contain
|
|
26
|
+
* items which are not serializable.
|
|
27
|
+
* This returns only the essential fields.
|
|
28
|
+
*/
|
|
29
|
+
return {
|
|
30
|
+
endpoint: credentials.endpoint,
|
|
31
|
+
token: credentials.token,
|
|
32
|
+
expiresAt: credentials.expiresAt
|
|
33
|
+
};
|
|
43
34
|
}
|
|
44
|
-
uploadCrud() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
yield this.options.uploadCrud();
|
|
51
|
-
});
|
|
35
|
+
async uploadCrud() {
|
|
36
|
+
/**
|
|
37
|
+
* Don't return anything here, just incase something which is not
|
|
38
|
+
* serializable is returned from the `uploadCrud` function.
|
|
39
|
+
*/
|
|
40
|
+
await this.options.uploadCrud();
|
|
52
41
|
}
|
|
53
42
|
get logger() {
|
|
54
43
|
return this.options.logger;
|
|
55
44
|
}
|
|
56
45
|
trace(...x) {
|
|
57
|
-
|
|
58
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace(...x);
|
|
46
|
+
this.logger?.trace(...x);
|
|
59
47
|
}
|
|
60
48
|
debug(...x) {
|
|
61
|
-
|
|
62
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(...x);
|
|
49
|
+
this.logger?.debug(...x);
|
|
63
50
|
}
|
|
64
51
|
info(...x) {
|
|
65
|
-
|
|
66
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.info(...x);
|
|
52
|
+
this.logger?.info(...x);
|
|
67
53
|
}
|
|
68
54
|
log(...x) {
|
|
69
|
-
|
|
70
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(...x);
|
|
55
|
+
this.logger?.log(...x);
|
|
71
56
|
}
|
|
72
57
|
warn(...x) {
|
|
73
|
-
|
|
74
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.warn(...x);
|
|
58
|
+
this.logger?.warn(...x);
|
|
75
59
|
}
|
|
76
60
|
error(...x) {
|
|
77
|
-
|
|
78
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(...x);
|
|
61
|
+
this.logger?.error(...x);
|
|
79
62
|
}
|
|
80
63
|
time(label) {
|
|
81
|
-
|
|
82
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.time(label);
|
|
64
|
+
this.logger?.time(label);
|
|
83
65
|
}
|
|
84
66
|
timeEnd(label) {
|
|
85
|
-
|
|
86
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.timeEnd(label);
|
|
67
|
+
this.logger?.timeEnd(label);
|
|
87
68
|
}
|
|
88
69
|
}
|
|
89
70
|
export class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplementation {
|
|
71
|
+
syncManager;
|
|
72
|
+
clientProvider;
|
|
73
|
+
messagePort;
|
|
74
|
+
isInitialized;
|
|
90
75
|
constructor(options) {
|
|
91
76
|
super(options);
|
|
92
77
|
/**
|
|
@@ -135,53 +120,40 @@ export class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplem
|
|
|
135
120
|
* Starts the sync process, this effectively acts as a call to
|
|
136
121
|
* `connect` if not yet connected.
|
|
137
122
|
*/
|
|
138
|
-
connect(options) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
event: SharedSyncClientEvent.CLOSE_CLIENT,
|
|
167
|
-
data: {}
|
|
168
|
-
};
|
|
169
|
-
this.messagePort.postMessage(closeMessagePayload);
|
|
170
|
-
// Release the proxy
|
|
171
|
-
this.syncManager[Comlink.releaseProxy]();
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
waitForReady() {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
return this.isInitialized;
|
|
177
|
-
});
|
|
123
|
+
async connect(options) {
|
|
124
|
+
await this.waitForReady();
|
|
125
|
+
return this.syncManager.connect(options);
|
|
126
|
+
}
|
|
127
|
+
async disconnect() {
|
|
128
|
+
await this.waitForReady();
|
|
129
|
+
return this.syncManager.disconnect();
|
|
130
|
+
}
|
|
131
|
+
async getWriteCheckpoint() {
|
|
132
|
+
await this.waitForReady();
|
|
133
|
+
return this.syncManager.getWriteCheckpoint();
|
|
134
|
+
}
|
|
135
|
+
async hasCompletedSync() {
|
|
136
|
+
return this.syncManager.hasCompletedSync();
|
|
137
|
+
}
|
|
138
|
+
async dispose() {
|
|
139
|
+
await this.waitForReady();
|
|
140
|
+
// Signal the shared worker that this client is closing its connection to the worker
|
|
141
|
+
const closeMessagePayload = {
|
|
142
|
+
event: SharedSyncClientEvent.CLOSE_CLIENT,
|
|
143
|
+
data: {}
|
|
144
|
+
};
|
|
145
|
+
this.messagePort.postMessage(closeMessagePayload);
|
|
146
|
+
// Release the proxy
|
|
147
|
+
this.syncManager[Comlink.releaseProxy]();
|
|
148
|
+
}
|
|
149
|
+
async waitForReady() {
|
|
150
|
+
return this.isInitialized;
|
|
178
151
|
}
|
|
179
152
|
/**
|
|
180
153
|
* Used in tests to force a connection states
|
|
181
154
|
*/
|
|
182
|
-
_testUpdateStatus(status) {
|
|
183
|
-
return
|
|
184
|
-
return this.syncManager['_testUpdateAllStatuses'](status.toJSON());
|
|
185
|
-
});
|
|
155
|
+
async _testUpdateStatus(status) {
|
|
156
|
+
return this.syncManager['_testUpdateAllStatuses'](status.toJSON());
|
|
186
157
|
}
|
|
187
158
|
}
|
|
159
|
+
//# sourceMappingURL=SharedWebStreamingSyncImplementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedWebStreamingSyncImplementation.js","sourceRoot":"","sources":["../../../../src/db/sync/SharedWebStreamingSyncImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,8BAA8B,EAE/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,qBAAqB,EAEtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oDAAoD,CAAC;AAEtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E;;;GAGG;AACH,MAAM,wBAAyB,SAAQ,gCAAgC;IAEzD;IACH;IAFT,YACY,OAA8C,EACjD,aAAkD;QAEzD,KAAK,EAAE,CAAC;QAHE,YAAO,GAAP,OAAO,CAAuC;QACjD,kBAAa,GAAb,aAAa,CAAqC;IAG3D,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/D,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QACD;;;;;WAKG;QACH,OAAO;YACL,QAAQ,EAAE,WAAW,C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