Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,6 @@ sqlite3InitModule({
});
```

## Usage with the bundled `SQLiteClient` (with OPFS if available):

> **Warning**
>
> For this to work, you need to set the following headers on your server:
>
> `Cross-Origin-Opener-Policy: same-origin`
>
> `Cross-Origin-Embedder-Policy: require-corp`

Import the `@sqlite.org/sqlite-wasm` library in your code and use it as such:

```js
import { SqliteClient } from '@sqlite.org/sqlite-wasm';

// Must correspond to the path in your final deployed build.
const sqliteWorkerPath = 'assets/js/sqlite-worker.js';
// This is the name of your database. It corresponds to the path in the OPFS.
const filename = '/test.sqlite3';

const sqlite = new SqliteClient(filename, sqliteWorkerPath);
await sqlite.init();

await sqlite.executeSql('CREATE TABLE IF NOT EXISTS test(a,b)');
await sqlite.executeSql('INSERT INTO test VALUES(?, ?)', [6, 7]);
const results = await sqlite.executeSql('SELECT * FROM test');
```

## Usage with vite

If you are using [vite](https://vitejs.dev/), you need to add the following
Expand Down
8 changes: 0 additions & 8 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ async function main() {
const sqliteWasmLink = await getSqliteWasmDownloadLink();
await downloadAndUnzipSqliteWasm(sqliteWasmLink);
try {
fs.copyFileSync(
'./node_modules/comlink/dist/esm/comlink.mjs',
'./src/comlink.mjs',
);
fs.copyFileSync(
'./node_modules/comlink/dist/esm/comlink.mjs.map',
'./src/comlink.mjs.map',
);
fs.copyFileSync(
'./node_modules/module-workers-polyfill/module-workers-polyfill.min.js',
'./demo/module-workers-polyfill.min.js',
Expand Down
19 changes: 0 additions & 19 deletions demo/comlink.js

This file was deleted.

3 changes: 0 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
<title>SQLite Wasm Demo</title>
<script type="module" src="script.js"></script>
<script type="module" src="main-thread.js"></script>
<script type="module" src="comlink.js"></script>
</head>
<body>
<h1>SQLite Wasm Demo</h1>
<h2>Main thread</h2>
<div class="main-thread"></div>
<h2>Worker</h2>
<div class="worker"></div>
<h2>Main thread using Worker via Comlink</h2>
<div class="comlink"></div>
</body>
</html>
14 changes: 0 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8025,17 +8025,3 @@ declare type CAPI = {
SQLITE_FAIL: 3;
SQLITE_REPLACE: 5;
};

export class SqliteClient {
dbFile: string;
sqliteWorkerPath: string;

constructor(dFile: string, sqliteWorkerPath: string);

init(): Promise<void>;

executeSql(
sqlStatement: string,
bindParameters: SqlValue[],
): Promise<SqlValue[][]>;
}
1 change: 0 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { default as sqlite3InitModule } from './sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs';

export default sqlite3InitModule;
export * from './src/sqlite-client.mjs';
13 changes: 2 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sqlite.org/sqlite-wasm",
"version": "3.43.2-prebuild1",
"version": "3.43.2-build1",
"description": "SQLite Wasm conveniently wrapped as an ES Module.",
"keywords": [
"sqlite",
Expand All @@ -18,22 +18,18 @@
"files": [
"index.d.ts",
"index.mjs",
"sqlite-wasm/",
"src/"
"sqlite-wasm/"
],
"types": "index.d.ts",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"main": "./index.mjs",
"browser": "./index.mjs",
"types": "./index.d.ts"
"browser": "./index.mjs"
},
"./src/comlink.mjs": "./src/comlink.mjs",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"bin": {
"sqlite-wasm": "bin/index.js"
},
Expand Down Expand Up @@ -66,8 +62,5 @@
"publint": "^0.2.4",
"prettier-plugin-jsdoc": "^1.1.1",
"shx": "^0.3.4"
},
"optionalDependencies": {
"comlink": "^4.4.1"
}
}
Loading