@powersync/node 0.11.1 → 0.13.0

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 (36) hide show
  1. package/README.md +91 -10
  2. package/dist/DefaultWorker.cjs +140 -62
  3. package/dist/DefaultWorker.cjs.map +1 -1
  4. package/dist/bundle.cjs +31 -13
  5. package/dist/bundle.cjs.map +1 -1
  6. package/dist/bundle.d.cts +23 -1
  7. package/dist/worker.cjs +141 -62
  8. package/dist/worker.cjs.map +1 -1
  9. package/dist/worker.d.cts +9 -1
  10. package/download_core.js +75 -32
  11. package/lib/db/AsyncDatabase.d.ts +7 -2
  12. package/lib/db/BetterSqliteWorker.d.ts +26 -0
  13. package/lib/db/BetterSqliteWorker.js +58 -0
  14. package/lib/db/NodeSqliteWorker.d.ts +21 -0
  15. package/lib/db/NodeSqliteWorker.js +46 -0
  16. package/lib/db/PowerSyncDatabase.js +2 -2
  17. package/lib/db/SqliteWorker.d.ts +8 -0
  18. package/lib/db/SqliteWorker.js +75 -98
  19. package/lib/db/{BetterSQLite3DBAdapter.d.ts → WorkerConnectionPool.d.ts} +2 -2
  20. package/lib/db/{BetterSQLite3DBAdapter.js → WorkerConnectionPool.js} +30 -6
  21. package/lib/db/options.d.ts +23 -1
  22. package/lib/libpowersync_aarch64.dylib +0 -0
  23. package/lib/libpowersync_aarch64.so +0 -0
  24. package/lib/libpowersync_armv7.so +0 -0
  25. package/lib/libpowersync_riscv64gc.so +0 -0
  26. package/lib/libpowersync_x64.dylib +0 -0
  27. package/lib/libpowersync_x86.so +0 -0
  28. package/lib/powersync_aarch64.dll +0 -0
  29. package/lib/powersync_x64.dll +0 -0
  30. package/lib/powersync_x86.dll +0 -0
  31. package/lib/utils/modules.d.ts +2 -0
  32. package/lib/utils/modules.js +5 -0
  33. package/lib/utils/modules_commonjs.d.ts +2 -0
  34. package/lib/utils/modules_commonjs.js +6 -0
  35. package/package.json +15 -8
  36. /package/lib/{libpowersync.so → libpowersync_x64.so} +0 -0
@@ -1,11 +1,27 @@
1
1
  import { type Worker } from 'node:worker_threads';
2
- import { SQLOpenOptions } from '@powersync/common';
2
+ import { LockContext, SQLOpenOptions } from '@powersync/common';
3
3
  export type WorkerOpener = (...args: ConstructorParameters<typeof Worker>) => InstanceType<typeof Worker>;
4
+ /**
5
+ * Use the [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) package as a SQLite driver for PowerSync.
6
+ */
7
+ export interface BetterSqlite3Options {
8
+ type: 'better-sqlite3';
9
+ }
10
+ /**
11
+ * Use the experimental `node:sqlite` interface as a SQLite driver for PowerSync.
12
+ *
13
+ * Note that this option is not currently tested and highly unstable.
14
+ */
15
+ export interface NodeSqliteOptions {
16
+ type: 'node:sqlite';
17
+ }
18
+ export type NodeDatabaseImplementation = BetterSqlite3Options | NodeSqliteOptions;
4
19
  /**
5
20
  * The {@link SQLOpenOptions} available across all PowerSync SDKs for JavaScript extended with
6
21
  * Node.JS-specific options.
7
22
  */
8
23
  export interface NodeSQLOpenOptions extends SQLOpenOptions {
24
+ implementation?: NodeDatabaseImplementation;
9
25
  /**
10
26
  * The Node.JS SDK will use one worker to run writing queries and additional workers to run reads.
11
27
  * This option controls how many workers to use for reads.
@@ -19,4 +35,10 @@ export interface NodeSQLOpenOptions extends SQLOpenOptions {
19
35
  * @returns the resolved worker.
20
36
  */
21
37
  openWorker?: WorkerOpener;
38
+ /**
39
+ * Initializes a created database connection.
40
+ *
41
+ * This can be used to e.g. set encryption keys, if an encrypted database should be used.
42
+ */
43
+ initializeConnection?: (db: LockContext, isWriter: boolean) => Promise<void>;
22
44
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ export declare const isBundledToCommonJs: boolean;
2
+ export declare function dynamicImport(path: string): Promise<any>;
@@ -0,0 +1,5 @@
1
+ // Note: When updating this file, always update module_commonjs.ts as well.
2
+ export const isBundledToCommonJs = false;
3
+ export async function dynamicImport(path) {
4
+ return await import(path);
5
+ }
@@ -0,0 +1,2 @@
1
+ export declare const isBundledToCommonJs: boolean;
2
+ export declare function dynamicImport(path: string): Promise<any>;
@@ -0,0 +1,6 @@
1
+ // NOTE! Do not import this file directly! We have a rollup plugin that rewrites imports to modules.js to this file when
2
+ // bundling to CommonJS.
3
+ export const isBundledToCommonJs = true;
4
+ export async function dynamicImport(path) {
5
+ return require(path);
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/node",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -47,18 +47,25 @@
47
47
  },
48
48
  "homepage": "https://docs.powersync.com/",
49
49
  "peerDependencies": {
50
- "@powersync/common": "^1.40.0"
50
+ "@powersync/common": "^1.41.0",
51
+ "better-sqlite3": "12.x"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "better-sqlite3": {
55
+ "optional": true
56
+ }
51
57
  },
52
58
  "dependencies": {
53
- "@powersync/better-sqlite3": "^0.2.0",
54
59
  "async-lock": "^1.4.0",
55
60
  "bson": "^6.6.0",
56
61
  "comlink": "^4.4.2",
57
62
  "undici": "^7.11.0",
58
- "@powersync/common": "1.40.0"
63
+ "@powersync/common": "1.41.0"
59
64
  },
60
65
  "devDependencies": {
61
66
  "@types/async-lock": "^1.4.0",
67
+ "@types/node": "^24.2.0",
68
+ "better-sqlite3": "^12.2.0",
62
69
  "drizzle-orm": "^0.35.2",
63
70
  "rollup": "4.14.3",
64
71
  "typescript": "^5.5.3",
@@ -73,12 +80,12 @@
73
80
  "live data"
74
81
  ],
75
82
  "scripts": {
76
- "install": "node download_core.js",
77
- "build": "tsc -b && rollup --config",
78
- "build:prod": "tsc -b --sourceMap false && rollup --config",
83
+ "prepare:core": "node download_core.js",
84
+ "build": " pnpm prepare:core && tsc -b && rollup --config",
85
+ "build:prod": "pnpm prepare:core && tsc -b --sourceMap false && rollup --config",
79
86
  "clean": "rm -rf lib dist tsconfig.tsbuildinfo",
80
87
  "watch": "tsc -b -w",
81
- "test": "vitest",
88
+ "test": " pnpm prepare:core && vitest",
82
89
  "test:exports": "attw --pack . --ignore-rules no-resolution"
83
90
  }
84
91
  }
File without changes