New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sqlite.org/sqlite-wasm

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sqlite.org/sqlite-wasm - npm Package Compare versions

Comparing version 3.44.0-build2 to 3.44.0-build3

4

package.json
{
"name": "@sqlite.org/sqlite-wasm",
"version": "3.44.0-build2",
"version": "3.44.0-build3",
"description": "SQLite Wasm conveniently wrapped as an ES Module.",

@@ -61,3 +61,3 @@ "keywords": [

"node-fetch": "^3.3.2",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"publint": "^0.2.5",

@@ -64,0 +64,0 @@ "prettier-plugin-jsdoc": "^1.1.1",

@@ -23,11 +23,24 @@ # SQLite Wasm

There are two ways to use SQLite Wasm:
[in the main thread](#in-the-main-thread-without-opfs) and
[in a worker](#in-a-worker-with-opfs-if-available). Only the worker version
allows you to use the origin private file system (OPFS) storage back-end.
There are three ways to use SQLite Wasm:
### In the main thread (without OPFS):
- [in the main thread with a wrapped worker](#in-a-wrapped-worker-with-opfs)
(preferred option 💡) and
- [in a worker](#in-a-worker-with-opfs-if-available)
- [in the main thread](#in-the-main-thread-without-opfs)
Only the worker versions allow you to use the origin private file system (OPFS)
storage back-end.
### In a wrapped worker (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`
```js
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
import { sqlite3Worker1Promiser } from '@sqlite.org/sqlite-wasm';

@@ -37,25 +50,40 @@ const log = (...args) => console.log(...args);

const start = function (sqlite3) {
log('Running SQLite3 version', sqlite3.version.libVersion);
const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');
// Your SQLite code here.
};
(async () => {
try {
log('Loading and initializing SQLite3 module...');
log('Loading and initializing SQLite3 module...');
sqlite3InitModule({
print: log,
printErr: error,
}).then((sqlite3) => {
try {
const promiser = await new Promise((resolve) => {
const _promiser = sqlite3Worker1Promiser({
onready: () => {
resolve(_promiser);
},
});
});
log('Done initializing. Running demo...');
start(sqlite3);
let response;
response = await promiser('config-get', {});
log('Running SQLite3 version', response.result.version.libVersion);
response = await promiser('open', {
filename: 'file:mydb.sqlite3?vfs=opfs',
});
const { dbId } = response;
logHtml(
'',
'OPFS is available, created persisted database at',
response.result.filename.replace(/^file:(.*?)\?vfs=opfs/, '$1'),
);
// Your SQLite code here.
} catch (err) {
if (!(err instanceof Error)) {
err = new Error(err.result.message);
}
error(err.name, err.message);
}
});
})();
```
The `db` object above implements the
[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
### In a worker (with OPFS if available):

@@ -110,2 +138,33 @@

### In the main thread (without OPFS):
```js
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
const log = (...args) => console.log(...args);
const error = (...args) => console.error(...args);
const start = function (sqlite3) {
log('Running SQLite3 version', sqlite3.version.libVersion);
const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');
// Your SQLite code here.
};
log('Loading and initializing SQLite3 module...');
sqlite3InitModule({
print: log,
printErr: error,
}).then((sqlite3) => {
try {
log('Done initializing. Running demo...');
start(sqlite3);
} catch (err) {
error(err.name, err.message);
}
});
```
The `db` object above implements the
[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).
## Usage with vite

@@ -112,0 +171,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc