@homeofthings/sqlite3 6.3.1 → 7.0.0

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/package.json CHANGED
@@ -1,18 +1,12 @@
1
1
  {
2
2
  "name": "@homeofthings/sqlite3",
3
3
  "description": "Asynchronous, non-blocking SQLite3 bindings",
4
- "version": "6.3.1",
4
+ "version": "7.0.0",
5
5
  "homepage": "https://github.com/gms1/node-sqlite3",
6
6
  "author": {
7
7
  "name": "Mapbox",
8
8
  "url": "https://mapbox.com/"
9
9
  },
10
- "binary": {
11
- "napi_versions": [
12
- 3,
13
- 6
14
- ]
15
- },
16
10
  "contributors": [
17
11
  "Daniel Lockyer <hi@daniellockyer.com>",
18
12
  "Konstantin Käfer <mail@kkaefer.com>",
@@ -36,7 +30,9 @@
36
30
  "binding.gyp",
37
31
  "deps/",
38
32
  "lib/**/*.js",
33
+ "lib/**/*.mjs",
39
34
  "lib/**/*.d.ts",
35
+ "prebuilds/**",
40
36
  "src/"
41
37
  ],
42
38
  "repository": {
@@ -44,18 +40,16 @@
44
40
  "url": "https://github.com/gms1/node-sqlite3.git"
45
41
  },
46
42
  "dependencies": {
47
- "bindings": "^1.5.0",
48
43
  "node-addon-api": "^8.7.0",
49
- "prebuild-install": "^7.1.3",
50
- "tar": "^7.5.13"
44
+ "node-gyp-build": "^4.8.4"
51
45
  },
52
46
  "devDependencies": {
53
47
  "@eslint/js": "^10.0.1",
54
48
  "eslint": "^10.2.0",
55
- "globals": "^17.4.0",
49
+ "globals": "^17.5.0",
56
50
  "mocha": "11.7.5",
57
51
  "nyc": "^18.0.0",
58
- "prebuild": "13.0.1",
52
+ "prebuildify": "^6.0.1",
59
53
  "tinybench": "^6.0.0"
60
54
  },
61
55
  "peerDependencies": {
@@ -73,13 +67,13 @@
73
67
  "node": ">=20.17.0"
74
68
  },
75
69
  "scripts": {
76
- "install": "prebuild-install -r napi || node-gyp rebuild",
77
- "prebuild": "prebuild --runtime napi --all --verbose",
70
+ "install": "node-gyp-build",
71
+ "prebuild": "prebuildify --napi --strip --tag-libc",
78
72
  "rebuild": "node-gyp rebuild",
79
- "upload": "prebuild --verbose --prerelease",
80
73
  "frozen-install": "yarn install --frozen-lockfile",
81
74
  "lint": "eslint lib/ test/ tools/",
82
- "test": "node test/support/createdb.js && nyc mocha -R spec --timeout 480000"
75
+ "test": "node test/support/createdb.js && nyc --reporter=text --reporter=lcov --reporter=html mocha -R spec --timeout 480000 \"test/*.test.js\" \"test/*.test.mjs\"",
76
+ "bear": "bear -- node-gyp rebuild"
83
77
  },
84
78
  "license": "BSD-3-Clause",
85
79
  "publishConfig": {
@@ -91,6 +85,21 @@
91
85
  "sqlite3",
92
86
  "database"
93
87
  ],
94
- "main": "./lib/sqlite3",
95
- "types": "./lib/sqlite3.d.ts"
88
+ "main": "./lib/sqlite3.js",
89
+ "module": "./lib/sqlite3.mjs",
90
+ "types": "./lib/sqlite3.d.ts",
91
+ "exports": {
92
+ ".": {
93
+ "types": "./lib/sqlite3.d.ts",
94
+ "import": "./lib/sqlite3.mjs",
95
+ "require": "./lib/sqlite3.js",
96
+ "default": "./lib/sqlite3.js"
97
+ },
98
+ "./promise": {
99
+ "types": "./lib/promise/index.d.ts",
100
+ "import": "./lib/promise/index.mjs",
101
+ "require": "./lib/promise/index.js",
102
+ "default": "./lib/promise/index.js"
103
+ }
104
+ }
96
105
  }
package/src/backup.cc CHANGED
@@ -173,6 +173,14 @@ Backup::Backup(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Backup>(info)
173
173
  baton->filenameIsDest = filenameIsDest.Value();
174
174
 
175
175
  this->db->Schedule(Work_BeginInitialize, baton);
176
+
177
+ // Initialize retryErrors with default values so GetRetryErrors() never
178
+ // crashes on an empty Napi::Reference, even if the JS wrapper that sets
179
+ // backup.retryErrors is bypassed (i.e. direct new sqlite3.Backup(...)).
180
+ Napi::Array defaultRetryErrors = Napi::Array::New(env, 2);
181
+ defaultRetryErrors.Set(static_cast<uint32_t>(0), Napi::Number::New(env, SQLITE_BUSY));
182
+ defaultRetryErrors.Set(static_cast<uint32_t>(1), Napi::Number::New(env, SQLITE_LOCKED));
183
+ retryErrors.Reset(defaultRetryErrors, 1);
176
184
  }
177
185
 
178
186
  void Backup::Work_BeginInitialize(Database::Baton* baton) {
package/src/macros.h CHANGED
@@ -4,14 +4,10 @@
4
4
  const char* sqlite_code_string(int code);
5
5
  const char* sqlite_authorizer_string(int type);
6
6
  #include <vector>
7
- #include <atomic>
8
7
 
9
8
  // TODO: better way to work around StringConcat?
10
9
  #include <napi.h>
11
10
 
12
- // Forward declaration of shutdown flag from node_sqlite3.cc
13
- extern std::atomic<bool> g_env_shutting_down;
14
-
15
11
  inline Napi::String StringConcat(Napi::Value str1, Napi::Value str2) {
16
12
  return Napi::String::New(str1.Env(), str1.As<Napi::String>().Utf8Value() +
17
13
  str2.As<Napi::String>().Utf8Value() );
@@ -133,21 +129,8 @@ inline bool OtherIsInt(Napi::Number source) {
133
129
  if ((argc != 0) && (passed_argv != NULL)) {\
134
130
  args.assign(passed_argv, passed_argv + argc);\
135
131
  }\
136
- try {\
137
- Napi::Value res = (callback).Call(Napi::Value(context), args);\
138
- if (res.IsEmpty()) return __VA_ARGS__;\
139
- } catch (const Napi::Error&) {\
140
- /* During Node.js/Electron shutdown, when using NAPI_CPP_EXCEPTIONS,*/\
141
- /* we must take care to not throw any exceptions. */\
142
- /* But when napi_call_function returns napi_cannot_run_js */\
143
- /* this throws a C++ exception, when NAPI_CPP_EXCEPTIONS is enabled. */\
144
- if (g_env_shutting_down.load()) {\
145
- /* We need to silently ignore exceptions during shutdown. */\
146
- return __VA_ARGS__;\
147
- }\
148
- /* Real rror - re-throw to propagate it */\
149
- throw;\
150
- }
132
+ Napi::Value res = (callback).Call(Napi::Value(context), args);\
133
+ if (res.IsEmpty()) return __VA_ARGS__;
151
134
 
152
135
  #define WORK_DEFINITION(name) \
153
136
  Napi::Value name(const Napi::CallbackInfo& info); \
@@ -2,7 +2,6 @@
2
2
  #include <sstream>
3
3
  #include <cstring>
4
4
  #include <string>
5
- #include <atomic>
6
5
  #include <sqlite3.h>
7
6
 
8
7
  #include "macros.h"
@@ -12,21 +11,11 @@
12
11
 
13
12
  using namespace node_sqlite3;
14
13
 
15
- // Global flag set when the environment is shutting down.
16
- std::atomic<bool> g_env_shutting_down{false};
17
-
18
- static void EnvCleanupHook(void* /*data*/) {
19
- g_env_shutting_down.store(true);
20
- }
21
-
22
14
  namespace {
23
15
 
24
16
  Napi::Object RegisterModule(Napi::Env env, Napi::Object exports) {
25
17
  Napi::HandleScope scope(env);
26
18
 
27
- // Register cleanup hook to detect shutdown
28
- napi_add_env_cleanup_hook(env, EnvCleanupHook, nullptr);
29
-
30
19
  Database::Init(env, exports);
31
20
  Statement::Init(env, exports);
32
21
  Backup::Init(env, exports);
package/deps/extract.js DELETED
@@ -1,19 +0,0 @@
1
- const tar = require("tar");
2
- const fs = require("fs");
3
- const path = require("path");
4
- const tarball = path.resolve(process.argv[2]);
5
- const dirname = path.resolve(process.argv[3]);
6
-
7
- tar.extract({
8
- sync: true,
9
- file: tarball,
10
- cwd: dirname,
11
- });
12
-
13
- // SQLite >= 3.49 ships a VERSION file that conflicts with the C++20 <version>
14
- // header on case-insensitive filesystems (macOS/Windows).
15
- const base = path.basename(tarball, ".tar.gz");
16
- const versionFile = path.join(dirname, base, "VERSION");
17
- if (fs.existsSync(versionFile)) {
18
- fs.unlinkSync(versionFile);
19
- }
Binary file