Skip to content

feat: @powersync/adapter-sql-js added to support SQL.js #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed6befc
wip
stevensJourney Jun 27, 2025
1f4dcb3
wip
stevensJourney Jun 30, 2025
35d50bc
override nodejs imports
stevensJourney Jun 30, 2025
b6c8c2a
add patches
stevensJourney Jun 30, 2025
bf24e5e
cleanup
stevensJourney Jun 30, 2025
c52828e
enable table update hooks. using force!
stevensJourney Jun 30, 2025
cedd8a3
Updated patch to have make script also enable FTS5.
Chriztiaan Jul 3, 2025
3679fda
Scheduling writes to a ControlledExecutor.
Chriztiaan Jul 10, 2025
babeefc
Dropped sql.js temp package. Using dev release from standalone project.
Chriztiaan Jul 11, 2025
3edca89
Added tests.
Chriztiaan Jul 11, 2025
6b1f2fa
Revert changes to demo.
Chriztiaan Jul 14, 2025
7491003
Merge branch 'main' into poc-sqljs
Chriztiaan Jul 14, 2025
f664362
Moved to dev package.
Chriztiaan Jul 14, 2025
96fdf4e
Re-exporting dev from react-native.
Chriztiaan Jul 15, 2025
3100988
Updated lock file.
Chriztiaan Jul 15, 2025
f11287d
Added react-native changeset.
Chriztiaan Jul 15, 2025
983d04e
Bumped @ps/sql-js depdenency.
Chriztiaan Jul 15, 2025
237ab9d
Merge branch 'main' into poc-sqljs
Chriztiaan Jul 15, 2025
c5b3b69
Fix build:prod script.
Chriztiaan Jul 15, 2025
097d893
Changeset entry, and making dev package public.
Chriztiaan Jul 15, 2025
782f7b4
Updated readme.
Chriztiaan Jul 15, 2025
46bd668
Updated Dev readme.
Chriztiaan Jul 21, 2025
0e0ef52
Merge branch 'main' into poc-sqljs
Chriztiaan Jul 24, 2025
c8a9af0
Removed dev package re-export from React-Native.
Chriztiaan Jul 24, 2025
4f1e221
Removed unused changeset.
Chriztiaan Jul 28, 2025
aa04921
Minor polish.
Chriztiaan Jul 28, 2025
fc99b93
Minor readme change, updated a comment.
Chriztiaan Jul 28, 2025
dabf474
Renamed dev package to adapter-sql-js.
Chriztiaan Jul 29, 2025
e731bd5
Merge branch 'main' into poc-sqljs
Chriztiaan Jul 29, 2025
19c70c7
Updated changeset.
Chriztiaan Jul 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added demos/.DS_Store
Binary file not shown.
19 changes: 14 additions & 5 deletions demos/react-native-supabase-todolist/library/powersync/system.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import '@azure/core-asynciterator-polyfill';

import { createBaseLogger, LogLevel, PowerSyncDatabase, SyncClientImplementation } from '@powersync/react-native';
import { createBaseLogger, LogLevel, PowerSyncDatabase } from '@powersync/react-native';
import React from 'react';
import { SupabaseStorageAdapter } from '../storage/SupabaseStorageAdapter';

import { type AttachmentRecord } from '@powersync/attachments';
import { SQLJSOpenFactory } from '@powersync/dev-adapter';
import { configureFts } from '../fts/fts_setup';
import { KVStorage } from '../storage/KVStorage';
import { AppConfig } from '../supabase/AppConfig';
Expand All @@ -29,9 +30,17 @@ export class System {
this.storage = this.supabaseConnector.storage;
this.powersync = new PowerSyncDatabase({
schema: AppSchema,
database: {
dbFilename: 'sqlite.db'
},
// database: {
// dbFilename: 'ddd'
// },
database: new SQLJSOpenFactory({
dbFilename: 'powersync.db',
persister: {
// TODO
readFile: async () => null,
writeFile: async () => {}
}
}),
logger
});
/**
Expand Down Expand Up @@ -68,7 +77,7 @@ export class System {

async init() {
await this.powersync.init();
await this.powersync.connect(this.supabaseConnector, { clientImplementation: SyncClientImplementation.RUST });
await this.powersync.connect(this.supabaseConnector);

if (this.attachmentQueue) {
await this.attachmentQueue.init();
Expand Down
1 change: 1 addition & 0 deletions demos/react-native-supabase-todolist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@powersync/attachments": "workspace:*",
"@powersync/common": "workspace:*",
"@powersync/react": "workspace:*",
"@powersync/dev-adapter": "workspace:*",
"@powersync/react-native": "workspace:*",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/drawer": "^7.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/db/crud/SyncProgress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BucketProgress } from 'src/client/sync/stream/core-instruction.js';
import { BucketProgress } from '../../client/sync/stream/core-instruction.js';
import type { SyncStatus } from './SyncStatus.js';

// (bucket, progress) pairs
Expand Down
3 changes: 3 additions & 0 deletions packages/dev-adapter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PowerSync SDK Dev Adapter

A very small development DB Adapter for PowerSync which uses [SQL.js](https://sql.js.org/#/)
40 changes: 40 additions & 0 deletions packages/dev-adapter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@powersync/dev-adapter",
"version": "0.0.0",
"private": "true",
"description": "API definitions for JourneyApps PowerSync",
"type": "module",
"main": "dist/bundle.mjs",
"module": "dist/bundle.mjs",
"types": "lib/index.d.ts",
"author": "JOURNEYAPPS",
"license": "Apache-2.0",
"files": [
"lib",
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/powersync-ja/powersync-js.git"
},
"bugs": {
"url": "https://github.com/powersync-ja/powersync-js/issues"
},
"homepage": "https://docs.powersync.com",
"scripts": {
"build": "tsc -b && rollup -c rollup.config.mjs",
"build:prod": "tsc -b --sourceMap false && && rollup -c rollup.config.mjs --sourceMap false",
"clean": "rm -rf lib dist tsconfig.tsbuildinfo",
"test": "vitest"
},
"dependencies": {
"@powersync/common": "workspace:^",
"async-mutex": "^0.4.0"
},
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",
"@types/sql.js": "^1.4.9",
"rollup": "4.14.3",
"sql.js": "workspace:*"
}
}
40 changes: 40 additions & 0 deletions packages/dev-adapter/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
* @returns {import('rollup').RollupOptions}
*/
export default (commandLineArgs) => {
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';

// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
delete commandLineArgs.sourceMap;

return {
input: 'lib/index.js',
output: {
file: 'dist/bundle.mjs',
format: 'esm',
sourcemap: sourceMap
},
plugins: [
nodeResolve({ preferBuiltins: false, browser: true }),
commonjs({}),
alias({
entries: [
{ find: 'fs', replacement: path.resolve(__dirname, 'vendored/empty.js') },
{ find: 'path', replacement: path.resolve(__dirname, 'vendored/empty.js') },
{ find: 'crypto', replacement: path.resolve(__dirname, 'vendored/empty.js') }
// add others as needed
]
})
],
external: ['@powersync/common']
};
};
Loading
Loading