-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow for web sdk to be used without web worker (#178)
Co-authored-by: DominicGBauer <[email protected]>
- Loading branch information
1 parent
3a584a0
commit 7943626
Showing
21 changed files
with
276 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@powersync/web': minor | ||
--- | ||
|
||
Allow package to be used without web workers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { QueryResult } from '@powersync/common'; | ||
|
||
export type WASQLExecuteResult = Omit<QueryResult, 'rows'> & { | ||
rows: { | ||
_array: any[]; | ||
length: number; | ||
}; | ||
}; | ||
|
||
export type DBFunctionsInterface = { | ||
// Close is only exposed when used in a single non shared webworker | ||
close?: () => void; | ||
execute: WASQLiteExecuteMethod; | ||
executeBatch: WASQLiteExecuteBatchMethod; | ||
registerOnTableChange: (callback: OnTableChangeCallback) => void; | ||
}; | ||
|
||
/** | ||
* @deprecated use [DBFunctionsInterface instead] | ||
*/ | ||
export type DBWorkerInterface = DBFunctionsInterface; | ||
|
||
export type WASQLiteExecuteMethod = (sql: string, params?: any[]) => Promise<WASQLExecuteResult>; | ||
export type WASQLiteExecuteBatchMethod = (sql: string, params?: any[]) => Promise<WASQLExecuteResult>; | ||
export type OnTableChangeCallback = (opType: number, tableName: string, rowId: number) => void; | ||
export type OpenDB = (dbFileName: string) => DBWorkerInterface; | ||
|
||
export type SQLBatchTuple = [string] | [string, Array<any> | Array<Array<any>>]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as Comlink from 'comlink'; | ||
import { _openDB } from './open-db'; | ||
import { _openDB } from '../../shared/open-db'; | ||
|
||
Comlink.expose(async (dbFileName: string) => Comlink.proxy(await _openDB(dbFileName))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/web/src/worker/sync/AbstractSharedSyncClientProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.