@homeofthings/sqlite3 7.0.2 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/deps/common-sqlite.gypi +1 -1
- package/deps/extract.js +130 -0
- package/deps/sqlite-amalgamation-3530200.zip +0 -0
- package/deps/sqlite3.gyp +32 -4
- package/package.json +6 -6
- package/prebuilds/darwin-arm64/@homeofthings+sqlite3.glibc.node +0 -0
- package/prebuilds/darwin-x64/@homeofthings+sqlite3.glibc.node +0 -0
- package/prebuilds/linux-arm64/@homeofthings+sqlite3.glibc.node +0 -0
- package/prebuilds/linux-arm64/@homeofthings+sqlite3.musl.node +0 -0
- package/prebuilds/linux-x64/@homeofthings+sqlite3.glibc.node +0 -0
- package/prebuilds/linux-x64/@homeofthings+sqlite3.musl.node +0 -0
- package/prebuilds/win32-arm64/@homeofthings+sqlite3.glibc.node +0 -0
- package/prebuilds/win32-x64/@homeofthings+sqlite3.glibc.node +0 -0
- package/deps/sqlite-amalgamation-3530100/shell.c +0 -37308
- package/deps/sqlite-amalgamation-3530100/sqlite3.c +0 -268860
- package/deps/sqlite-amalgamation-3530100/sqlite3.h +0 -14335
- package/deps/sqlite-amalgamation-3530100/sqlite3ext.h +0 -739
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js]
|
|
|
18
18
|
|
|
19
19
|
# Features
|
|
20
20
|
|
|
21
|
-
- Bundles SQLite v3.53.
|
|
21
|
+
- Bundles SQLite v3.53.2, or you can build using a local SQLite (or SqlCipher,...)
|
|
22
22
|
- Straightforward query and parameter binding interface
|
|
23
23
|
- Full Buffer/Blob support
|
|
24
24
|
- Extensive debugging support via [verbose mode](docs/API.md#verbose-mode)
|
|
@@ -43,7 +43,7 @@ yarn add @homeofthings/sqlite3
|
|
|
43
43
|
|
|
44
44
|
### Prebuilt binaries
|
|
45
45
|
|
|
46
|
-
`@homeofthings/sqlite3` uses [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. Prebuilt binaries are built as NAPI-version-agnostic (`@homeofthings+sqlite3.*.node`) using the `--napi` flag, and work on any Node.js version that supports the NAPI version used at compile time. Requires Node.js
|
|
46
|
+
`@homeofthings/sqlite3` uses [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. Prebuilt binaries are built as NAPI-version-agnostic (`@homeofthings+sqlite3.*.node`) using the `--napi` flag, and work on any Node.js version that supports the NAPI version used at compile time. Requires Node.js v22.1.0 or later.
|
|
47
47
|
|
|
48
48
|
Prebuilt binaries are bundled inside the npm package using [`prebuildify`](https://github.com/prebuild/prebuildify) and loaded at runtime by [`node-gyp-build`](https://github.com/prebuild/node-gyp-build). No separate download step is needed — `npm install` just works. The following targets are currently provided:
|
|
49
49
|
|
package/deps/common-sqlite.gypi
CHANGED
package/deps/extract.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const zlib = require('zlib');
|
|
7
|
+
|
|
8
|
+
const LOCAL_FILE_HEADER_SIG = 0x04034b50;
|
|
9
|
+
const COMPRESSION_STORE = 0;
|
|
10
|
+
const COMPRESSION_DEFLATE = 8;
|
|
11
|
+
|
|
12
|
+
function extractZip(zipPath, destDir) {
|
|
13
|
+
const data = fs.readFileSync(zipPath);
|
|
14
|
+
let offset = 0;
|
|
15
|
+
let entries = 0;
|
|
16
|
+
|
|
17
|
+
// Detect top-level directory prefix to strip (e.g., "sqlite-amalgamation-3530100/")
|
|
18
|
+
let prefixToStrip = '';
|
|
19
|
+
let firstEntry = true;
|
|
20
|
+
|
|
21
|
+
while (offset < data.length) {
|
|
22
|
+
const sig = data.readUInt32LE(offset);
|
|
23
|
+
if (sig !== LOCAL_FILE_HEADER_SIG) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const compressionMethod = data.readUInt16LE(offset + 8);
|
|
28
|
+
const compressedSize = data.readUInt32LE(offset + 18);
|
|
29
|
+
const fileNameLength = data.readUInt16LE(offset + 26);
|
|
30
|
+
const extraFieldLength = data.readUInt16LE(offset + 28);
|
|
31
|
+
|
|
32
|
+
const fileName = data.toString('utf8', offset + 30, offset + 30 + fileNameLength);
|
|
33
|
+
const dataOffset = offset + 30 + fileNameLength + extraFieldLength;
|
|
34
|
+
const compressedData = data.subarray(dataOffset, dataOffset + compressedSize);
|
|
35
|
+
|
|
36
|
+
// Detect top-level directory prefix from first entry
|
|
37
|
+
if (firstEntry && fileName.includes('/')) {
|
|
38
|
+
prefixToStrip = fileName.substring(0, fileName.indexOf('/') + 1);
|
|
39
|
+
firstEntry = false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Strip prefix from filename
|
|
43
|
+
let outFileName = fileName;
|
|
44
|
+
if (prefixToStrip && outFileName.startsWith(prefixToStrip)) {
|
|
45
|
+
outFileName = outFileName.substring(prefixToStrip.length);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let fileData;
|
|
49
|
+
if (compressionMethod === COMPRESSION_STORE) {
|
|
50
|
+
fileData = compressedData;
|
|
51
|
+
} else if (compressionMethod === COMPRESSION_DEFLATE) {
|
|
52
|
+
fileData = zlib.inflateRawSync(compressedData);
|
|
53
|
+
} else {
|
|
54
|
+
throw new Error(`Unsupported compression method ${compressionMethod} for file ${fileName}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (outFileName && !outFileName.endsWith('/')) {
|
|
58
|
+
const outPath = path.join(destDir, outFileName);
|
|
59
|
+
const resolvedDest = path.resolve(destDir);
|
|
60
|
+
const resolvedOut = path.resolve(outPath);
|
|
61
|
+
if (!resolvedOut.startsWith(resolvedDest + path.sep)) {
|
|
62
|
+
throw new Error(`Zip Slip detected: ${outFileName} resolves outside destination directory`);
|
|
63
|
+
}
|
|
64
|
+
const dir = path.dirname(outPath);
|
|
65
|
+
if (!fs.existsSync(dir)) {
|
|
66
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
fs.writeFileSync(outPath, fileData);
|
|
69
|
+
entries++;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
offset = dataOffset + compressedSize;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (entries === 0) {
|
|
76
|
+
throw new Error('No files extracted — zip may be corrupted or empty');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return entries;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function main() {
|
|
83
|
+
const archivePath = path.resolve(process.argv[2]);
|
|
84
|
+
const destDir = path.resolve(process.argv[3]);
|
|
85
|
+
|
|
86
|
+
if (!archivePath || !destDir) {
|
|
87
|
+
console.error('Usage: extract.js <archive_path> <dest_dir>');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Resolve archive path relative to script directory if not absolute
|
|
92
|
+
const zipFile = path.isAbsolute(archivePath)
|
|
93
|
+
? archivePath
|
|
94
|
+
: path.join(__dirname, archivePath);
|
|
95
|
+
|
|
96
|
+
// Compute extraction directory: destDir + archive basename without .zip
|
|
97
|
+
const archiveName = path.basename(archivePath, '.zip');
|
|
98
|
+
const extractDir = path.join(destDir, archiveName);
|
|
99
|
+
const stampFile = path.join(extractDir, '.extract-stamp');
|
|
100
|
+
|
|
101
|
+
if (fs.existsSync(stampFile)) {
|
|
102
|
+
console.log(`[extract] Already extracted: ${extractDir}`);
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!fs.existsSync(zipFile)) {
|
|
107
|
+
console.error(`[extract] ERROR: Zip file not found: ${zipFile}`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (fs.existsSync(extractDir)) {
|
|
112
|
+
console.log(`[extract] Removing stale extraction directory: ${extractDir}`);
|
|
113
|
+
fs.rmSync(extractDir, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log(`[extract] Extracting ${path.basename(zipFile)}...`);
|
|
117
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const entries = extractZip(zipFile, extractDir);
|
|
121
|
+
fs.writeFileSync(stampFile, `Extracted from ${path.basename(zipFile)}\n`);
|
|
122
|
+
console.log(`[extract] Extraction complete: ${entries} file(s) extracted to ${extractDir}`);
|
|
123
|
+
} catch (err) {
|
|
124
|
+
console.error(`[extract] ERROR: ${err.message}`);
|
|
125
|
+
fs.rmSync(extractDir, { recursive: true, force: true });
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
main();
|
|
Binary file
|
package/deps/sqlite3.gyp
CHANGED
|
@@ -47,15 +47,40 @@
|
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
'targets': [
|
|
50
|
+
{
|
|
51
|
+
'target_name': 'action_before_build',
|
|
52
|
+
'type': 'none',
|
|
53
|
+
'hard_dependency': 1,
|
|
54
|
+
'actions': [
|
|
55
|
+
{
|
|
56
|
+
'action_name': 'unpack_sqlite_dep',
|
|
57
|
+
'inputs': [
|
|
58
|
+
'./sqlite-amalgamation-<@(sqlite_version).zip'
|
|
59
|
+
],
|
|
60
|
+
'outputs': [
|
|
61
|
+
'<(SHARED_INTERMEDIATE_DIR)/sqlite-amalgamation-<@(sqlite_version)/sqlite3.c'
|
|
62
|
+
],
|
|
63
|
+
'action': ['node', './extract.js', './sqlite-amalgamation-<@(sqlite_version).zip', '<(SHARED_INTERMEDIATE_DIR)']
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
'direct_dependent_settings': {
|
|
67
|
+
'include_dirs': [
|
|
68
|
+
'<(SHARED_INTERMEDIATE_DIR)/sqlite-amalgamation-<@(sqlite_version)/',
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
},
|
|
50
72
|
{
|
|
51
73
|
'target_name': 'sqlite3',
|
|
52
74
|
'type': 'static_library',
|
|
53
|
-
'include_dirs': [ '
|
|
75
|
+
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-amalgamation-<@(sqlite_version)/' ],
|
|
76
|
+
'dependencies': [
|
|
77
|
+
'action_before_build'
|
|
78
|
+
],
|
|
54
79
|
'sources': [
|
|
55
|
-
'
|
|
80
|
+
'<(SHARED_INTERMEDIATE_DIR)/sqlite-amalgamation-<@(sqlite_version)/sqlite3.c'
|
|
56
81
|
],
|
|
57
82
|
'direct_dependent_settings': {
|
|
58
|
-
'include_dirs': [ '
|
|
83
|
+
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-amalgamation-<@(sqlite_version)/' ],
|
|
59
84
|
'defines': [
|
|
60
85
|
'SQLITE_THREADSAFE=1',
|
|
61
86
|
'HAVE_USLEEP=1',
|
|
@@ -81,6 +106,9 @@
|
|
|
81
106
|
'SQLITE_ENABLE_DBSTAT_VTAB=1',
|
|
82
107
|
'SQLITE_ENABLE_MATH_FUNCTIONS'
|
|
83
108
|
],
|
|
109
|
+
'export_dependent_settings': [
|
|
110
|
+
'action_before_build',
|
|
111
|
+
],
|
|
84
112
|
'conditions': [
|
|
85
113
|
["sqlite_magic != ''", {
|
|
86
114
|
'defines': [
|
|
@@ -90,4 +118,4 @@
|
|
|
90
118
|
],
|
|
91
119
|
}
|
|
92
120
|
]
|
|
93
|
-
}
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homeofthings/sqlite3",
|
|
3
3
|
"description": "Asynchronous, non-blocking SQLite3 bindings",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.3",
|
|
5
5
|
"homepage": "https://github.com/gms1/node-sqlite3",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Mapbox",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"url": "https://github.com/gms1/node-sqlite3.git"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"node-addon-api": "^8.
|
|
43
|
+
"node-addon-api": "^8.8.0",
|
|
44
44
|
"node-gyp-build": "^4.8.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/js": "^10.0.1",
|
|
48
|
-
"eslint": "^10.
|
|
48
|
+
"eslint": "^10.4.1",
|
|
49
49
|
"globals": "^17.6.0",
|
|
50
|
-
"mocha": "11.7.
|
|
50
|
+
"mocha": "11.7.6",
|
|
51
51
|
"nyc": "^18.0.0",
|
|
52
52
|
"prebuildify": "^6.0.1",
|
|
53
|
-
"tinybench": "^6.0.
|
|
53
|
+
"tinybench": "^6.0.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"node-gyp": "12.x"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"node-gyp": "12.x"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
67
|
+
"node": ">=22.1.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"install": "node-gyp-build",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|