Skip to content

Commit

Permalink
chore: add web-sdk (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: DominicGBauer <[email protected]>
  • Loading branch information
DominicGBauer and DominicGBauer authored Feb 8, 2024
1 parent 0f1d246 commit 7bf2bc6
Show file tree
Hide file tree
Showing 116 changed files with 10,636 additions and 784 deletions.
30 changes: 30 additions & 0 deletions demos/example-vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# example-vite

## 0.0.4

### Patch Changes

- Updated dependencies [d20386c]
- @journeyapps/powersync-sdk-web@0.2.0

## 0.0.3

### Patch Changes

- Updated dependencies [412937f]
- @journeyapps/powersync-sdk-web@0.1.3

## 0.0.2

### Patch Changes

- Updated dependencies [7fb9df2]
- Updated dependencies [7fb9df2]
- @journeyapps/powersync-sdk-web@0.1.2

## 0.0.1

### Patch Changes

- Updated dependencies [0e17713]
- @journeyapps/powersync-sdk-web@0.1.1
7 changes: 7 additions & 0 deletions demos/example-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PowerSync Vite bundling test

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.
18 changes: 18 additions & 0 deletions demos/example-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "example-vite",
"private": true,
"version": "0.0.4",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"start": "pnpm build && pnpm preview"
},
"dependencies": {
"@journeyapps/powersync-sdk-web": "workspace:*"
},
"devDependencies": {
"vite": "^5.0.12"
}
}
7 changes: 7 additions & 0 deletions demos/example-vite/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script type="module" src="./index.js"></script>
</head>
<body>Vite bundling test: Check the console to see it in action!</body>
</html>
37 changes: 37 additions & 0 deletions demos/example-vite/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
Column,
ColumnType,
WASQLitePowerSyncDatabaseOpenFactory,
Schema,
Table
} from '@journeyapps/powersync-sdk-web';

export const AppSchema = new Schema([
new Table({ name: 'customers', columns: [new Column({ name: 'name', type: ColumnType.TEXT })] })
]);

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
}
}).getInstance();

await PowerSync.init();

// Run local statements.
await PowerSync.execute('INSERT INTO customers(id, name) VALUES(uuid(), ?)', ['Fred']);

const result = await PowerSync.getAll('SELECT * FROM customers');
console.log('contents of customers: ', result);
};

document.addEventListener('DOMContentLoaded', (event) => {
console.log('hello');
openDatabase();
});
15 changes: 15 additions & 0 deletions demos/example-vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
root: 'src',
build: {
outDir: '../dist',
rollupOptions: {
input: 'src/index.html'
}
},
worker: {
format: 'es'
}
});
30 changes: 30 additions & 0 deletions demos/example-webpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# example-webpack

## null

### Patch Changes

- Updated dependencies [d20386c]
- @journeyapps/powersync-sdk-web@0.2.0

## null

### Patch Changes

- Updated dependencies [412937f]
- @journeyapps/powersync-sdk-web@0.1.3

## null

### Patch Changes

- Updated dependencies [7fb9df2]
- Updated dependencies [7fb9df2]
- @journeyapps/powersync-sdk-web@0.1.2

## null

### Patch Changes

- Updated dependencies [0e17713]
- @journeyapps/powersync-sdk-web@0.1.1
7 changes: 7 additions & 0 deletions demos/example-webpack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PowerSync Webpack bundling test

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.
5 changes: 5 additions & 0 deletions demos/example-webpack/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>

<body>Webpack bundling test: Check the console to see it in action!</body>

</html>
20 changes: 20 additions & 0 deletions demos/example-webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "example-webpack",
"private": true,
"version": null,
"scripts": {
"build": "webpack",
"serve": "serve ./dist",
"start": "pnpm build && pnpm serve"
},
"dependencies": {
"@journeyapps/powersync-sdk-web": "workspace:*"
},
"devDependencies": {
"webpack-cli": "^5.1.4",
"webpack": "^5.90.1",
"@types/webpack": "^5.28.5",
"serve": "^14.2.1",
"html-webpack-plugin": "^5.6.0"
}
}
36 changes: 36 additions & 0 deletions demos/example-webpack/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
Column,
ColumnType,
WASQLitePowerSyncDatabaseOpenFactory,
Schema,
Table
} from '@journeyapps/powersync-sdk-web';

export const AppSchema = new Schema([
new Table({ name: 'customers', columns: [new Column({ name: 'name', type: ColumnType.TEXT })] })
]);

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
}
}).getInstance();

await PowerSync.init();

// Run local statements.
await PowerSync.execute('INSERT INTO customers(id, name) VALUES(uuid(), ?)', ['Fred']);

const result = await PowerSync.getAll('SELECT * FROM customers');
console.log('contents of customers: ', result);
};

document.addEventListener('DOMContentLoaded', (event) => {
openDatabase();
});
23 changes: 23 additions & 0 deletions demos/example-webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
entry: path.join(__dirname, 'src/index.js'),
output: {
filename: 'index.js',
path: path.join(__dirname, 'dist')
},
devtool: 'source-map',
mode: 'development',
resolve: {
extensions: ['.js']
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, './index.html'),
inject: true,
title: 'Test',
filename: 'index.html'
})
]
};
3 changes: 3 additions & 0 deletions demos/powersync-nextjs-demo/.env.local.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUPABASE_URL=
SUPABASE_ANON_KEY=
POWERSYNC_URL=
3 changes: 3 additions & 0 deletions demos/powersync-nextjs-demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
47 changes: 47 additions & 0 deletions demos/powersync-nextjs-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build
# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# ide
.idea
.fleet
.vscode

# PWA
**/public/workbox-*.js
**/public/sw.js
**/public/swe-worker-*
**/public/worker-*.js
**/public/fallback-*.js
61 changes: 61 additions & 0 deletions demos/powersync-nextjs-demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# @journeyapps/powersync-nextjs-demo

## 0.1.8

### Patch Changes

- Updated dependencies [d20386c]
- @journeyapps/powersync-sdk-web@0.2.0

## 0.1.7

### Patch Changes

- Updated dependencies [412937f]
- @journeyapps/powersync-sdk-web@0.1.3

## 0.1.6

### Patch Changes

- 7fb9df2: Autofocus inputs in creation dialogs for a better UX.
- Updated dependencies [7fb9df2]
- Updated dependencies [7fb9df2]
- @journeyapps/powersync-sdk-web@0.1.2

## 0.1.5

### Patch Changes

- Updated dependencies [0e17713]
- @journeyapps/powersync-sdk-web@0.1.1

## 0.1.4

### Patch Changes

- 1fa25e6: Added uploading and downloading status indicator.
- Updated dependencies [1fa25e6]
- @journeyapps/powersync-sdk-web@0.1.0

## 0.1.3

### Patch Changes

- 0bc3758: Added PWA support. Better initialization of client side PowerSync instance.
- Updated dependencies [0bc3758]
- @journeyapps/powersync-sdk-web@0.0.3

## 0.1.2

### Patch Changes

- Updated dependencies [5d9cbb9]
- @journeyapps/powersync-sdk-web@0.0.2

## 0.1.1

### Patch Changes

- Updated dependencies [af78f76]
- @journeyapps/powersync-sdk-web@0.0.1
Loading

0 comments on commit 7bf2bc6

Please sign in to comment.