From eae8f1d03d332f2bee888741e5c27d4a92ef55c6 Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 16 Apr 2024 17:43:40 +0200 Subject: [PATCH 1/4] Update description --- README.md | 2 +- packages/powersync-attachments/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 50db5b95..e52e854f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ _Bad connectivity is everywhere, and we're tired of it. PowerSync is on a missio - [packages/powersync-attachments](./packages/powersync-attachments/README.md) - - Attachments helper package for React Native. + - Attachments helper package for React Native and and JS Web. - [packages/kysely-driver](./packages/kysely-driver/README.md) diff --git a/packages/powersync-attachments/README.md b/packages/powersync-attachments/README.md index 5cd62172..c6d33725 100644 --- a/packages/powersync-attachments/README.md +++ b/packages/powersync-attachments/README.md @@ -1,6 +1,6 @@ # @journeyapps/powersync-attachments -A [PowerSync](https://powersync.co) library to manage attachments in TypeScript and React Native apps. +A [PowerSync](https://powersync.com) library to manage attachments in React Native and JavaScript/TypeScript apps. ## Installation From 3c11c38626bdb933c38f8fffa515189e29f294eb Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 16 Apr 2024 17:46:12 +0200 Subject: [PATCH 2/4] Better words --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e52e854f..24d19d78 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ _Bad connectivity is everywhere, and we're tired of it. PowerSync is on a missio - [packages/powersync-attachments](./packages/powersync-attachments/README.md) - - Attachments helper package for React Native and and JS Web. + - Attachments helper package for React Native and JavaScript/TypeScript projects. - [packages/kysely-driver](./packages/kysely-driver/README.md) - - Kysely integration (ORM) for React Native and JS Web. + - Kysely integration (ORM) for React Native and JavaScript/TypeScript projects. - [packages/powersync-sdk-common](./packages/powersync-sdk-common/README.md) - Shared package: TypeScript implementation of a PowerSync database connector and streaming sync bucket implementation. From d31d9f95be711b55a8a1a3a9737541922ec335be Mon Sep 17 00:00:00 2001 From: benitav Date: Tue, 16 Apr 2024 19:21:56 +0200 Subject: [PATCH 3/4] Improve minimal example projects readmes --- demos/example-nextjs/README.md | 6 ++--- demos/example-vite/README.md | 8 ++++--- demos/example-vite/src/index.js | 1 - demos/example-webpack/README.md | 8 ++++--- demos/example-webpack/src/index.js | 37 ++++++++++++++++++++++++++++-- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/demos/example-nextjs/README.md b/demos/example-nextjs/README.md index 45cb62c0..5bda517f 100644 --- a/demos/example-nextjs/README.md +++ b/demos/example-nextjs/README.md @@ -4,7 +4,7 @@ This example is built using [Next.js](https://nextjs.org/) and the [PowerSync JS To see it in action: -1. Make sure to run `pnpm build:packages` in the root directory of this Git repo. +1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo. 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. -3. `pnpm start` -4. Open the localhost URL in the browser displayed in the terminal output. +3. cd into this directory and run `pnpm start`. +4. Open the localhost URL displayed in the terminal output in your browser. diff --git a/demos/example-vite/README.md b/demos/example-vite/README.md index 092f1ff8..7221f637 100644 --- a/demos/example-vite/README.md +++ b/demos/example-vite/README.md @@ -1,7 +1,9 @@ # PowerSync Vite bundling test +This is a minimal example demonstrating bundling with Vite. It attempts a connection to verify that web workers load correctly, but networks requests will fail since no credentials are configured. See [src/index.js](src/index.js) for details. + To see it in action: -1. Make sure to run `pnpm build:packages` in the root directory of this Git repo. -2. `pnpm start` -3. Open the localhost URL in the browser displayed in the terminal output. +1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo. +2. cd into this directory, and run `pnpm start`. +3. Open the localhost URL displayed in the terminal output in your browser. diff --git a/demos/example-vite/src/index.js b/demos/example-vite/src/index.js index 67cdafcc..89fde789 100644 --- a/demos/example-vite/src/index.js +++ b/demos/example-vite/src/index.js @@ -61,6 +61,5 @@ const openDatabase = async () => { }; document.addEventListener('DOMContentLoaded', (event) => { - console.log('hello'); openDatabase(); }); diff --git a/demos/example-webpack/README.md b/demos/example-webpack/README.md index 209c7c52..b44cee34 100644 --- a/demos/example-webpack/README.md +++ b/demos/example-webpack/README.md @@ -1,7 +1,9 @@ # PowerSync Webpack bundling test +This is a minimal example demonstrating bundling with Webpack. It attempts a connection to verify that web workers load correctly, but networks requests will fail since no credentials are configured. See [src/index.js](src/index.js) for details. + To see it in action: -1. Make sure to run `pnpm build:packages` in the root directory of this Git repo. -2. `pnpm start` -3. Open the localhost URL in the browser displayed in the terminal output. +1. Make sure to run `pnpm install` and `pnpm build:packages` in the root directory of this repo. +2. cd into this directory, and run `pnpm start`. +3. Open the localhost URL displayed in the terminal output in your browser. diff --git a/demos/example-webpack/src/index.js b/demos/example-webpack/src/index.js index 4cfb5fcd..3374fb6e 100644 --- a/demos/example-webpack/src/index.js +++ b/demos/example-webpack/src/index.js @@ -6,6 +6,22 @@ import { Table } from '@journeyapps/powersync-sdk-web'; +/** + * A placeholder connector which doesn't do anything. + * This is just used to verify that the sync workers can be loaded + * when connecting. + */ +class DummyConnector { + async fetchCredentials() { + return { + endpoint: '', + token: '' + }; + } + + async uploadData(database) {} +} + export const AppSchema = new Schema([ new Table({ name: 'customers', columns: [new Column({ name: 'name', type: ColumnType.TEXT })] }) ]); @@ -15,7 +31,11 @@ let PowerSync; const openDatabase = async () => { PowerSync = new WASQLitePowerSyncDatabaseOpenFactory({ schema: AppSchema, - dbFilename: 'test.sqlite' + dbFilename: 'test.sqlite', + flags: { + // This is disabled once CSR+SSR functionality is verified to be working correctly + disableSSRWarning: true + } }).getInstance(); await PowerSync.init(); @@ -25,8 +45,21 @@ const openDatabase = async () => { const result = await PowerSync.getAll('SELECT * FROM customers'); console.log('contents of customers: ', result); + + console.log( + `Attempting to connect in order to verify web workers are correctly loaded. + This doesn't use any actual network credentials. + Network errors will be shown: these can be ignored.` + ); + + /** + * Try and connect, this will setup shared sync workers + * This will fail due to not having a valid endpoint, + * but it will try - which is all that matters. + */ + await PowerSync.connect(new DummyConnector()); }; document.addEventListener('DOMContentLoaded', (event) => { openDatabase(); -}); +}); \ No newline at end of file From bc9eca5b20d7d1a06b31c27d190d1a9a300174cd Mon Sep 17 00:00:00 2001 From: benitav Date: Wed, 17 Apr 2024 10:20:37 +0200 Subject: [PATCH 4/4] Remove unnecessary flags --- demos/example-vite/src/index.js | 6 +----- demos/example-webpack/src/index.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/demos/example-vite/src/index.js b/demos/example-vite/src/index.js index 89fde789..64304c8f 100644 --- a/demos/example-vite/src/index.js +++ b/demos/example-vite/src/index.js @@ -31,11 +31,7 @@ let PowerSync; const openDatabase = async () => { PowerSync = new WASQLitePowerSyncDatabaseOpenFactory({ schema: AppSchema, - dbFilename: 'test.sqlite', - flags: { - // This is disabled once CSR+SSR functionality is verified to be working correctly - disableSSRWarning: true - } + dbFilename: 'test.sqlite' }).getInstance(); await PowerSync.init(); diff --git a/demos/example-webpack/src/index.js b/demos/example-webpack/src/index.js index 3374fb6e..97205c43 100644 --- a/demos/example-webpack/src/index.js +++ b/demos/example-webpack/src/index.js @@ -31,11 +31,7 @@ let PowerSync; const openDatabase = async () => { PowerSync = new WASQLitePowerSyncDatabaseOpenFactory({ schema: AppSchema, - dbFilename: 'test.sqlite', - flags: { - // This is disabled once CSR+SSR functionality is verified to be working correctly - disableSSRWarning: true - } + dbFilename: 'test.sqlite' }).getInstance(); await PowerSync.init();