You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pre-package all the PowerSync Rust extension binaries for all supported platforms and architectures in the NPM package `lib` folder. Install scripts are no longer required to download the PowerSync core.
6
+
7
+
The binary files relevant to a specific architecture now have updated filenames. Custom code which previously referenced binary filenames requires updating. A helper function is available to automatically provide the correct filename.
8
+
9
+
```diff
10
+
+ import { getPowerSyncExtensionFilename } from '@powersync/node/worker.js';
11
+
12
+
function resolvePowerSyncCoreExtension() {
13
+
- const platform = OS.platform();
14
+
- let extensionPath: string;
15
+
- if (platform === 'win32') {
16
+
- extensionPath = 'powersync.dll';
17
+
- } else if (platform === 'linux') {
18
+
- extensionPath = 'libpowersync.so';
19
+
- } else if (platform === 'darwin') {
20
+
- extensionPath = 'libpowersync.dylib';
21
+
- } else {
22
+
- throw 'Unknown platform, PowerSync for Node.js currently supports Windows, Linux and macOS.';
Copy file name to clipboardExpand all lines: demos/example-electron-node/README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,9 @@ In particular:
9
9
queries. This worker is part of the `@powersync/node` package and wouldn't be copied into the resulting Electron
10
10
app by default. For this reason, this example has its own `src/main/worker.ts` loaded with `new URL('./worker.ts', import.meta.url)`.
11
11
2. In addition to the worker, PowerSync requires access to a SQLite extension providing sync functionality.
12
-
This file is also part of the `@powersync/node` package and called `powersync.dll`, `libpowersync.dylib` or
13
-
`libpowersync.so` depending on the operating system.
12
+
This file is also part of the `@powersync/node` package and is the prebuilt release asset (for example
13
+
`powersync_x64.dll`, `libpowersync_x64.dylib` or `libpowersync_x64.so`) depending on the operating system and
14
+
architecture.
14
15
We use the `copy-webpack-plugin` package to make sure a copy of that file is available to the main process,
15
16
and load it in the custom `src/main/worker.ts`.
16
17
3. The `get()` and `getAll()` methods are exposed to the renderer process with an IPC channel.
@@ -21,7 +22,7 @@ To see it in action:
21
22
2. Copy `.env.local.template` to `.env.local`, and complete the environment variables. You can generate a [temporary development token](https://docs.powersync.com/usage/installation/authentication-setup/development-tokens), or leave blank to test with local-only data.
22
23
The example works with the schema from the [PowerSync + Supabase tutorial](https://docs.powersync.com/integration-guides/supabase-+-powersync#supabase-powersync).
23
24
3.`cd` into this directory. In this mono-repo, you'll have to run `./node_modules/.bin/electron-rebuild` once to make sure `@powersync/better-sqlite3` was compiled with Electron's toolchain.
24
-
3. Finally, run `pnpm start`.
25
+
4. Finally, run `pnpm start`.
25
26
26
27
Apart from the build setup, this example is purposefully kept simple.
27
28
To make sure PowerSync is working, you can run `await powersync.get('SELECT powersync_rs_version()');` in the DevTools
0 commit comments