Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Initial #1

Merged
merged 39 commits into from
Nov 13, 2023
Merged

Initial #1

merged 39 commits into from
Nov 13, 2023

Conversation

stevensJourney
Copy link
Collaborator

@stevensJourney stevensJourney commented Oct 24, 2023

This PR introduces the initial Alpha implementation of the PowerSync Web SDK.

The Alpha release is very much still Alpha.

High level features include:

  • WA SQLite DB adapter running in shared Webworker using IndexDB for persistance.
    • Other storage adapters can be added in future.
  • NextJs Demo app using Web SDK.

Future work not included in this PR:

  • Updating to NodeJS 20 LTS
  • Ability to specify read/write locks in Shared DB Webworker: This will ensure better locking in future when multiple tabs are supported.
  • Potentially making a SharedWebworker implementation of the PowerSyncDatabaseClient: to avoid any potential race conditions when syncing with multiple tabs.
  • The demo apps are currently located in this SDK repo for convenience, however they could be moved to their own repo if required. This repo could also feature a CLI tool for generating new app from the demo app as a template.
  • Demo app does not yet include Attachment helpers
  • Better TypeScript typing for WA-SQLite once that is exported better
  • Update to faster IndexDB based VFS implementation
  • Add PWA support to Demo App

TODOs

  • Bump WA-SQLite packages after approval
  • Bump Common SDK packages after publish
  • Change package access to public

Related PRs powersync-ja/wa-sqlite#1

Some nice screenshots of Demo App follow
image
image
image

.nvmrc Outdated Show resolved Hide resolved
demos/powersync-nextjs-demo/.gitignore Show resolved Hide resolved
demos/powersync-nextjs-demo/package.json Show resolved Hide resolved
demos/powersync-nextjs-demo/src/app/api/supabase/route.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,49 @@
import { Column, ColumnType, Index, IndexedColumn, Schema, Table } from '@journeyapps/powersync-sdk-web';

// TODO move this to a shared NPM package

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if putting this into a package makes sense. I think we should rather look into composable demos, similar to how expo examples templates work:

npx @journeyapps/powersync-create-app --templates "ts-todolist-app" "ts-with-attachments"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I updated the comment for future investigation

packages/powersync-sdk-web/package.json Outdated Show resolved Hide resolved
packages/powersync-sdk-web/tsconfig.json Outdated Show resolved Hide resolved
packages/powersync-sdk-web/package.json Outdated Show resolved Hide resolved
const sqlite3 = SQLite.Factory(module);

// @ts-ignore
const { IDBMinimalVFS } = await import('@journeyapps/wa-sqlite/src/examples/IDBMinimalVFS.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IDBBatchAtomicVFS is much faster than this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one seems to cause a corrupted DB error to occur. I will add this to the list of future items to investigate for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know there were some major db corruption issues related to that, fixed in SQLite 3.44.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that! I updated the wa-sqlite build to use SQLite 3.44 and applied the fixes from the PR in the linked issue. This now uses IDBBatchAtomicVFS

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the demo: Looks good overall, but didn't check the details.
For a next iteration, it would be good to convert it to a PWA (basically just add a service worker and manifest), so that it can work fully offline.

For the database implementation: Looks good, don't see any issues.

@stevensJourney stevensJourney merged commit af78f76 into main Nov 13, 2023
1 check passed
@stevensJourney stevensJourney deleted the intial branch November 13, 2023 13:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants