You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@sqlite.org/sqlite-wasm

Package Overview
Dependencies
Maintainers
2
Versions
71
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

to
3.46.1-build1

6

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

@@ -60,4 +60,4 @@ "keywords": [

"node-fetch": "^3.3.2",
"prettier": "^3.3.0",
"publint": "^0.2.8",
"prettier": "^3.3.3",
"publint": "^0.2.10",
"prettier-plugin-jsdoc": "^1.3.0",

@@ -64,0 +64,0 @@ "shx": "^0.3.4"

@@ -82,44 +82,2 @@ /*

const error = (...args) => logImpl(0, ...args);
const metrics = Object.create(null);
metrics.reset = () => {
let k;
const r = (m) => (m.count = m.time = m.wait = 0);
for (k in state.opIds) {
r((metrics[k] = Object.create(null)));
}
let s = (metrics.s11n = Object.create(null));
s = s.serialize = Object.create(null);
s.count = s.time = 0;
s = metrics.s11n.deserialize = Object.create(null);
s.count = s.time = 0;
};
metrics.dump = () => {
let k,
n = 0,
t = 0,
w = 0;
for (k in state.opIds) {
const m = metrics[k];
n += m.count;
t += m.time;
w += m.wait;
m.avgTime = m.count && m.time ? m.time / m.count : 0;
}
console.log(
globalThis?.location?.href,
'metrics for',
globalThis?.location?.href,
':\n',
metrics,
'\nTotal of',
n,
'op(s) for',
t,
'ms',
'approx',
w,
'ms spent waiting on OPFS APIs.',
);
console.log('Serialization metrics:', metrics.s11n);
};

@@ -193,13 +151,18 @@ const __openFiles = Object.create(null);

}
GetSyncHandleError.convertRc = (e, rc) => {
if (1) {
return e instanceof GetSyncHandleError &&
(e.cause.name === 'NoModificationAllowedError' ||
(e.cause.name === 'DOMException' &&
0 === e.cause.message.indexOf('Access Handles cannot')))
? state.sq3Codes.SQLITE_BUSY
: rc;
} else {
return rc;
if (e instanceof GetSyncHandleError) {
if (
e.cause.name === 'NoModificationAllowedError' ||
(e.cause.name === 'DOMException' &&
0 === e.cause.message.indexOf('Access Handles cannot'))
) {
return state.sq3Codes.SQLITE_BUSY;
} else if ('NotFoundError' === e.cause.name) {
return state.sq3Codes.SQLITE_CANTOPEN;
}
} else if ('NotFoundError' === e?.name) {
return state.sq3Codes.SQLITE_CANTOPEN;
}
return rc;
};

@@ -272,32 +235,5 @@

const __mTimer = Object.create(null);
__mTimer.op = undefined;
__mTimer.start = undefined;
const mTimeStart = (op) => {
__mTimer.start = performance.now();
__mTimer.op = op;
++metrics[op].count;
};
const mTimeEnd = () =>
(metrics[__mTimer.op].time += performance.now() - __mTimer.start);
const __wTimer = Object.create(null);
__wTimer.op = undefined;
__wTimer.start = undefined;
const wTimeStart = (op) => {
__wTimer.start = performance.now();
__wTimer.op = op;
};
const wTimeEnd = () =>
(metrics[__wTimer.op].wait += performance.now() - __wTimer.start);
let flagAsyncShutdown = false;
const vfsAsyncImpls = {
'opfs-async-metrics': async () => {
mTimeStart('opfs-async-metrics');
metrics.dump();
storeAndNotify('opfs-async-metrics', 0);
mTimeEnd();
},
'opfs-async-shutdown': async () => {

@@ -308,5 +244,3 @@ flagAsyncShutdown = true;

mkdir: async (dirname) => {
mTimeStart('mkdir');
let rc = 0;
wTimeStart('mkdir');
try {

@@ -317,13 +251,7 @@ await getDirForFilename(dirname + '/filepart', true);

rc = state.sq3Codes.SQLITE_IOERR;
} finally {
wTimeEnd();
}
storeAndNotify('mkdir', rc);
mTimeEnd();
},
xAccess: async (filename) => {
mTimeStart('xAccess');
let rc = 0;
wTimeStart('xAccess');
try {

@@ -335,15 +263,10 @@ const [dh, fn] = await getDirForFilename(filename);

rc = state.sq3Codes.SQLITE_IOERR;
} finally {
wTimeEnd();
}
storeAndNotify('xAccess', rc);
mTimeEnd();
},
xClose: async function (fid) {
const opName = 'xClose';
mTimeStart(opName);
__implicitLocks.delete(fid);
const fh = __openFiles[fid];
let rc = 0;
wTimeStart(opName);
if (fh) {

@@ -363,15 +286,10 @@ delete __openFiles[fid];

}
wTimeEnd();
storeAndNotify(opName, rc);
mTimeEnd();
},
xDelete: async function (...args) {
mTimeStart('xDelete');
const rc = await vfsAsyncImpls.xDeleteNoWait(...args);
storeAndNotify('xDelete', rc);
mTimeEnd();
},
xDeleteNoWait: async function (filename, syncDir = 0, recursive = false) {
let rc = 0;
wTimeStart('xDelete');
try {

@@ -392,10 +310,7 @@ while (filename) {

}
wTimeEnd();
return rc;
},
xFileSize: async function (fid) {
mTimeStart('xFileSize');
const fh = __openFiles[fid];
let rc = 0;
wTimeStart('xFileSize');
try {

@@ -409,8 +324,5 @@ const sz = await (await getSyncHandle(fh, 'xFileSize')).getSize();

await releaseImplicitLock(fh);
wTimeEnd();
storeAndNotify('xFileSize', rc);
mTimeEnd();
},
xLock: async function (fid, lockType) {
mTimeStart('xLock');
const fh = __openFiles[fid];

@@ -421,3 +333,2 @@ let rc = 0;

if (!fh.syncHandle) {
wTimeStart('xLock');
try {

@@ -434,12 +345,8 @@ await getSyncHandle(fh, 'xLock');

}
wTimeEnd();
}
storeAndNotify('xLock', rc);
mTimeEnd();
},
xOpen: async function (fid, filename, flags, opfsFlags) {
const opName = 'xOpen';
mTimeStart(opName);
const create = state.sq3Codes.SQLITE_OPEN_CREATE & flags;
wTimeStart('xOpen');
try {

@@ -452,4 +359,2 @@ let hDir, filenamePart;

storeAndNotify(opName, state.sq3Codes.SQLITE_NOTFOUND);
mTimeEnd();
wTimeEnd();
return;

@@ -463,3 +368,2 @@ }

const hFile = await hDir.getFileHandle(filenamePart, { create });
wTimeEnd();
const fh = Object.assign(Object.create(null), {

@@ -480,10 +384,5 @@ fid: fid,

state.opfsFlags.defaultUnlockAsap;
if (0 && 0 === (flags & state.sq3Codes.SQLITE_OPEN_MAIN_DB)) {
fh.xLock = 'xOpen';
await getSyncHandle(fh, 'xOpen');
}
__openFiles[fid] = fh;
storeAndNotify(opName, 0);
} catch (e) {
wTimeEnd();
error(opName, e);

@@ -493,6 +392,4 @@ state.s11n.storeException(1, e);

}
mTimeEnd();
},
xRead: async function (fid, n, offset64) {
mTimeStart('xRead');
let rc = 0,

@@ -502,3 +399,2 @@ nRead;

try {
wTimeStart('xRead');
nRead = (await getSyncHandle(fh, 'xRead')).read(

@@ -508,3 +404,2 @@ fh.sabView.subarray(0, n),

);
wTimeEnd();
if (nRead < n) {

@@ -515,3 +410,2 @@ fh.sabView.fill(0, nRead, n);

} catch (e) {
if (undefined === nRead) wTimeEnd();
error('xRead() failed', e, fh);

@@ -523,6 +417,4 @@ state.s11n.storeException(1, e);

storeAndNotify('xRead', rc);
mTimeEnd();
},
xSync: async function (fid, flags) {
mTimeStart('xSync');
const fh = __openFiles[fid];

@@ -532,3 +424,2 @@ let rc = 0;

try {
wTimeStart('xSync');
await fh.syncHandle.flush();

@@ -539,12 +430,8 @@ } catch (e) {

}
wTimeEnd();
}
storeAndNotify('xSync', rc);
mTimeEnd();
},
xTruncate: async function (fid, size) {
mTimeStart('xTruncate');
let rc = 0;
const fh = __openFiles[fid];
wTimeStart('xTruncate');
try {

@@ -562,12 +449,8 @@ affirmNotRO('xTruncate', fh);

await releaseImplicitLock(fh);
wTimeEnd();
storeAndNotify('xTruncate', rc);
mTimeEnd();
},
xUnlock: async function (fid, lockType) {
mTimeStart('xUnlock');
let rc = 0;
const fh = __openFiles[fid];
if (state.sq3Codes.SQLITE_LOCK_NONE === lockType && fh.syncHandle) {
wTimeStart('xUnlock');
try {

@@ -579,12 +462,8 @@ await closeSyncHandle(fh);

}
wTimeEnd();
}
storeAndNotify('xUnlock', rc);
mTimeEnd();
},
xWrite: async function (fid, n, offset64) {
mTimeStart('xWrite');
let rc;
const fh = __openFiles[fid];
wTimeStart('xWrite');
try {

@@ -605,5 +484,3 @@ affirmNotRO('xWrite', fh);

await releaseImplicitLock(fh);
wTimeEnd();
storeAndNotify('xWrite', rc);
mTimeEnd();
},

@@ -665,4 +542,2 @@ };

state.s11n.deserialize = function (clear = false) {
++metrics.s11n.deserialize.count;
const t = performance.now();
const argc = viewU8[0];

@@ -695,8 +570,5 @@ const rc = argc ? [] : null;

metrics.s11n.deserialize.time += performance.now() - t;
return rc;
};
state.s11n.serialize = function (...args) {
const t = performance.now();
++metrics.s11n.serialize.count;
if (args.length) {

@@ -727,3 +599,2 @@ const typeIds = [];

}
metrics.s11n.serialize.time += performance.now() - t;
};

@@ -807,3 +678,2 @@

initS11n();
metrics.reset();
log('init state', state);

@@ -823,5 +693,2 @@ wPost('opfs-async-inited');

break;
case 'opfs-async-metrics':
metrics.dump();
break;
}

@@ -828,0 +695,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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet