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
64
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.41.2 to 3.42.0-build1

sqlite-wasm/jswasm/sqlite3-node.mjs

4

bin/index.js

@@ -11,3 +11,3 @@ import fs from 'fs';

const fileName = $('a[name="wasm"]').closest('tr').next().find('a').text();
const sqliteWasmLink = `https://sqlite.org/${fileName}`;
const sqliteWasmLink = `https://sqlite.org/${new Date().getFullYear()}/${fileName}`;
console.log(`Found SQLite Wasm download link: ${sqliteWasmLink}`);

@@ -28,3 +28,3 @@ return sqliteWasmLink;

filter: (file) =>
/jswasm/.test(file.path) && /(?:\.mjs|\.wasm|proxy\.js)$/.test(file.path),
/jswasm/.test(file.path) && /(\.mjs|\.wasm|\.js)$/.test(file.path),
});

@@ -31,0 +31,0 @@ console.log(

{
"name": "@sqlite.org/sqlite-wasm",
"version": "3.41.2+build.1",
"version": "3.42.0-build1",
"description": "SQLite Wasm conveniently wrapped as an ES Module.",
"keywords": [
"sqlite",
"sqlite3",
"sqlite-wasm",
"sqlite3-wasm",
"webassembly",
"wasm",
"esm",
"opfs",
"origin-private-file-system"
],
"main": "index.mjs",

@@ -28,3 +39,4 @@ "type": "module",

"start": "npx http-server --coop",
"fix": "npx prettier . --write"
"fix": "npx prettier . --write",
"deploy": "npm run prepare && git add . && git commit -am 'New release' && git push && npm publish --access public"
},

@@ -47,6 +59,6 @@ "repository": {

"node-fetch": "^3.3.1",
"prettier": "^2.8.7",
"publint": "^0.1.11",
"prettier": "^2.8.8",
"publint": "^0.1.12",
"shx": "^0.3.4"
}
}

@@ -1,1 +0,156 @@

# sqlite-wasm
# SQLite Wasm
SQLite Wasm conveniently wrapped as an ES Module.
> **Note**
>
> This project wraps the code of
> [SQLite Wasm](https://sqlite.org/wasm/doc/trunk/index.md) with _no_ changes.
> Please do _not_ file issues or feature requests regarding the underlying
> SQLite Wasm code here. Instead, please follow the
> [SQLite bug filing instructions](https://www.sqlite.org/src/wiki?name=Bug+Reports).
## Installation
```bash
npm install @sqlite.org/sqlite-wasm
```
## Usage
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.
### 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);
}
});
```
### In a 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
// In `main.js`.
const worker = new Worker('worker.js', { type: 'module' });
```
```js
// In `worker.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);
let db;
if ('opfs' in sqlite3) {
db = new sqlite3.oo1.OpfsDb('/mydb.sqlite3');
log('OPFS is available, created persisted database at', db.filename);
} else {
db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');
log('OPFS is not available, created transient database', db.filename);
}
// Your SQLite code here.
};
log('Loading and initializing SQLite3 module...');
sqlite3InitModule({
print: log,
printErr: error,
}).then((sqlite3) => {
log('Done initializing. Running demo...');
try {
start(sqlite3);
} catch (err) {
error(err.name, err.message);
}
});
```
## Usage with vite
If you are using [vite](https://vitejs.dev/), you need to add the following
config option in `vite.config.js`:
```js
import { defineConfig } from 'vite';
export default defineConfig({
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
optimizeDeps: {
exclude: ['@sqlite.org/sqlite-wasm'],
},
});
```
Check out a
[sample project](https://stackblitz.com/edit/vitejs-vite-3rk63d?file=main.js)
that shows this in action.
## Demo
See the [demo](https://github.com/tomayac/sqlite-wasm/tree/main/demo) folder for
examples of how to use this in the main thread and in a worker. (Note that the
worker variant requires special HTTP headers, so it can't be hosted on GitHub
Pages.) An example that shows how to use this with vite is available on
[StackBlitz](https://stackblitz.com/edit/vitejs-vite-3rk63d?file=main.js).
## Deploying a new version
(These steps can only be executed by maintainers.)
1. Update the version number in `package.json` reflecting the current
[SQLite version number](https://sqlite.org/download.html) and add a build
identifier suffix like `-build1`. The complete version number should read
something like `3.41.2-build1`.
1. Run `npm run build` to build the ES Module. This downloads the latest SQLite
Wasm binary and builds the ES Module.
1. Run `npm run deploy` to commit the changes, push to GitHub, and publish the
new version to npm.
## License
Apache 2.0.
## Acknowledgements
This project is based on [SQLite Wasm](https://sqlite.org/wasm), which it
conveniently wraps as an ES Module and publishes to npm as
[`@sqlite.org/sqlite-wasm`](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm).

@@ -55,3 +55,3 @@ /*

};
if (self.window === self) {
if (globalThis.window === globalThis) {
toss(

@@ -61,3 +61,3 @@ 'This code cannot run from the main thread.',

);
} else if (!navigator.storage.getDirectory) {
} else if (!navigator?.storage?.getDirectory) {
toss('This API requires navigator.storage.getDirectory.');

@@ -119,5 +119,5 @@ }

console.log(
self.location.href,
globalThis?.location?.href,
'metrics for',
self.location.href,
globalThis?.location?.href,
':\n',

@@ -949,3 +949,3 @@ metrics,

state.rootDir = d;
self.onmessage = function ({ data }) {
globalThis.onmessage = function ({ data }) {
switch (data.type) {

@@ -998,3 +998,3 @@ case 'opfs-async-init': {

}; /*installAsyncProxy()*/
if (!self.SharedArrayBuffer) {
if (!globalThis.SharedArrayBuffer) {
wPost(

@@ -1005,3 +1005,3 @@ 'opfs-unavailable',

);
} else if (!self.Atomics) {
} else if (!globalThis.Atomics) {
wPost(

@@ -1013,7 +1013,7 @@ 'opfs-unavailable',

} else if (
!self.FileSystemHandle ||
!self.FileSystemDirectoryHandle ||
!self.FileSystemFileHandle ||
!self.FileSystemFileHandle.prototype.createSyncAccessHandle ||
!navigator.storage.getDirectory
!globalThis.FileSystemHandle ||
!globalThis.FileSystemDirectoryHandle ||
!globalThis.FileSystemFileHandle ||
!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle ||
!navigator?.storage?.getDirectory
) {

@@ -1020,0 +1020,0 @@ wPost('opfs-unavailable', 'Missing required OPFS APIs.');

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

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