@powersync/web 1.11.0 → 1.12.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.
- package/README.md +10 -1
- package/bin/powersync.js +43 -0
- package/dist/index.umd.js +10 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +36 -26
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/lib/package.json +7 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +2 -1
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +4 -1
- package/lib/src/db/adapters/web-sql-flags.d.ts +9 -0
- package/lib/src/db/adapters/web-sql-flags.js +5 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# PowerSync SDK for Web
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._
|
|
8
8
|
|
|
9
9
|
This package (`packages/web`) is the PowerSync SDK for JavaScript Web clients. It is an extension of `packages/common`.
|
|
10
10
|
|
|
@@ -40,6 +40,15 @@ See the [example Vite config](https://github.com/powersync-ja/powersync-js/blob/
|
|
|
40
40
|
|
|
41
41
|
Our [full SDK reference](https://docs.powersync.com/client-sdk-references/js-web) contains everything you need to know to get started implementing PowerSync in your project.
|
|
42
42
|
|
|
43
|
+
# Public Workers
|
|
44
|
+
|
|
45
|
+
For some frameworks, it may be required to configure the web workers ([see the docs](https://docs.powersync.com/client-sdk-references/react-native-and-expo/react-native-web-support)).
|
|
46
|
+
The `@powersync/web` package includes a CLI utility which can copy the required assets to the `public` directory (configurable with the `--output` option).
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm powersync-web copy-assets
|
|
50
|
+
```
|
|
51
|
+
|
|
43
52
|
# Changelog
|
|
44
53
|
|
|
45
54
|
A changelog for this SDK is available [here](https://releases.powersync.com/announcements/powersync-js-web-client-sdk).
|
package/bin/powersync.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const program = new Command();
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fsPromise = require('fs/promises');
|
|
7
|
+
const { version } = require('../package.json');
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.name('powersync-web')
|
|
11
|
+
.description('CLI for PowerSync Web SDK utilities')
|
|
12
|
+
.version(version);
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.command('copy-assets')
|
|
16
|
+
.description('Copy assets to the specified output directory')
|
|
17
|
+
.option('-o, --output <directory>', 'output directory for assets', 'public')
|
|
18
|
+
.action(async(options) => {
|
|
19
|
+
const outputDir = options.output;
|
|
20
|
+
|
|
21
|
+
console.log(`Target directory: ${outputDir}`);
|
|
22
|
+
|
|
23
|
+
const cwd = process.cwd();
|
|
24
|
+
const source = path.join(cwd, 'node_modules', '@powersync', 'web', 'dist');
|
|
25
|
+
const destination = path.join(cwd, outputDir, '@powersync');
|
|
26
|
+
|
|
27
|
+
await fsPromise.rm(destination, { recursive: true, force: true }); // Clear old assets
|
|
28
|
+
|
|
29
|
+
await copyDirectory(source, destination)
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
program.parse(process.argv);
|
|
34
|
+
|
|
35
|
+
async function copyDirectory(source, destination) {
|
|
36
|
+
try {
|
|
37
|
+
await fsPromise.cp(source, destination, { recursive: true });
|
|
38
|
+
console.log(`Assets copied from ${source} to ${destination}`);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`Error copying assets: ${err.message}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/index.umd.js
CHANGED
|
@@ -33860,6 +33860,7 @@ class WASQLiteDBAdapter extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.B
|
|
|
33860
33860
|
if (!enableMultiTabs) {
|
|
33861
33861
|
this.logger.warn('Multiple tabs are not enabled in this browser');
|
|
33862
33862
|
}
|
|
33863
|
+
const tempStoreQuery = `PRAGMA temp_store = ${this.options.temporaryStorage ?? _web_sql_flags__WEBPACK_IMPORTED_MODULE_5__.TemporaryStorageOption.MEMORY};`;
|
|
33863
33864
|
if (useWebWorker) {
|
|
33864
33865
|
const optionsDbWorker = this.options.worker;
|
|
33865
33866
|
const dbOpener = this.options.workerPort
|
|
@@ -33871,12 +33872,14 @@ class WASQLiteDBAdapter extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.B
|
|
|
33871
33872
|
})))
|
|
33872
33873
|
: (0,_worker_db_open_worker_database__WEBPACK_IMPORTED_MODULE_4__.getWorkerDatabaseOpener)(this.options.dbFilename, enableMultiTabs, optionsDbWorker);
|
|
33873
33874
|
this.methods = await dbOpener(this.options.dbFilename);
|
|
33875
|
+
await this.methods.execute(tempStoreQuery);
|
|
33874
33876
|
this.methods.registerOnTableChange(comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((event) => {
|
|
33875
33877
|
this.iterateListeners((cb) => cb.tablesUpdated?.(event));
|
|
33876
33878
|
}));
|
|
33877
33879
|
return;
|
|
33878
33880
|
}
|
|
33879
33881
|
this.methods = await (0,_shared_open_db__WEBPACK_IMPORTED_MODULE_3__._openDB)(this.options.dbFilename, { useWebWorker: false });
|
|
33882
|
+
await this.methods.execute(tempStoreQuery);
|
|
33880
33883
|
this.methods.registerOnTableChange((event) => {
|
|
33881
33884
|
this.iterateListeners((cb) => cb.tablesUpdated?.(event));
|
|
33882
33885
|
});
|
|
@@ -34106,9 +34109,15 @@ class WASQLitePowerSyncDatabaseOpenFactory extends _AbstractWebPowerSyncDatabase
|
|
|
34106
34109
|
__webpack_require__.r(__webpack_exports__);
|
|
34107
34110
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
34108
34111
|
/* harmony export */ DEFAULT_WEB_SQL_FLAGS: () => (/* binding */ DEFAULT_WEB_SQL_FLAGS),
|
|
34112
|
+
/* harmony export */ TemporaryStorageOption: () => (/* binding */ TemporaryStorageOption),
|
|
34109
34113
|
/* harmony export */ isServerSide: () => (/* binding */ isServerSide),
|
|
34110
34114
|
/* harmony export */ resolveWebSQLFlags: () => (/* binding */ resolveWebSQLFlags)
|
|
34111
34115
|
/* harmony export */ });
|
|
34116
|
+
var TemporaryStorageOption;
|
|
34117
|
+
(function (TemporaryStorageOption) {
|
|
34118
|
+
TemporaryStorageOption["MEMORY"] = "memory";
|
|
34119
|
+
TemporaryStorageOption["FILESYSTEM"] = "file";
|
|
34120
|
+
})(TemporaryStorageOption || (TemporaryStorageOption = {}));
|
|
34112
34121
|
function isServerSide() {
|
|
34113
34122
|
return typeof window == 'undefined';
|
|
34114
34123
|
}
|
|
@@ -40208,6 +40217,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
40208
40217
|
/* harmony export */ DEFAULT_WEB_SQL_FLAGS: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_WEB_SQL_FLAGS),
|
|
40209
40218
|
/* harmony export */ PowerSyncDatabase: () => (/* reexport safe */ _db_PowerSyncDatabase__WEBPACK_IMPORTED_MODULE_1__.PowerSyncDatabase),
|
|
40210
40219
|
/* harmony export */ SharedWebStreamingSyncImplementation: () => (/* reexport safe */ _db_sync_SharedWebStreamingSyncImplementation__WEBPACK_IMPORTED_MODULE_4__.SharedWebStreamingSyncImplementation),
|
|
40220
|
+
/* harmony export */ TemporaryStorageOption: () => (/* reexport safe */ _db_adapters_web_sql_flags__WEBPACK_IMPORTED_MODULE_8__.TemporaryStorageOption),
|
|
40211
40221
|
/* harmony export */ WASQLiteDBAdapter: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteDBAdapter__WEBPACK_IMPORTED_MODULE_5__.WASQLiteDBAdapter),
|
|
40212
40222
|
/* harmony export */ WASQLiteOpenFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLiteOpenFactory__WEBPACK_IMPORTED_MODULE_10__.WASQLiteOpenFactory),
|
|
40213
40223
|
/* harmony export */ WASQLitePowerSyncDatabaseOpenFactory: () => (/* reexport safe */ _db_adapters_wa_sqlite_WASQLitePowerSyncDatabaseOpenFactory__WEBPACK_IMPORTED_MODULE_6__.WASQLitePowerSyncDatabaseOpenFactory),
|