jsql-neo 6.4.0-beta.4 → 6.4.0-beta.5
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 +1 -1
- package/index.js +1 -1
- package/lib/plugin.js +14 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
|
|
4
4
|
> MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
|
|
5
5
|
|
|
6
|
-
> **v6.4.0-beta.
|
|
6
|
+
> **v6.4.0-beta.5** — official release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
|
|
7
7
|
|
|
8
8
|

|
|
9
9
|

|
package/index.js
CHANGED
package/lib/plugin.js
CHANGED
|
@@ -238,7 +238,7 @@ function applyPlugin(engine, plugin, opts) {
|
|
|
238
238
|
* - 任一钩子返回 false → 中止(返回 false),引擎据此跳过本次操作;
|
|
239
239
|
* - native 引擎置 `_forbidReentry`,钩子内再次触发引擎操作会抛 ER_PLUGIN_REENTRY。
|
|
240
240
|
*/
|
|
241
|
-
|
|
241
|
+
function runHooks(engine, hookName, args) {
|
|
242
242
|
const hooks = engine._hooks && engine._hooks[hookName];
|
|
243
243
|
if (!hooks || hooks.length === 0) return true;
|
|
244
244
|
|
|
@@ -252,9 +252,20 @@ async function runHooks(engine, hookName, args) {
|
|
|
252
252
|
}
|
|
253
253
|
try {
|
|
254
254
|
for (const fn of hooks) {
|
|
255
|
-
//
|
|
256
|
-
|
|
255
|
+
// 同步运行所有 hook。async hook 应在注册时用 async 包装,或用 afterHooks 队列。
|
|
256
|
+
// 如果 hook 返回 false(同步)或 reject(异步),都视为拒绝。
|
|
257
|
+
let result;
|
|
258
|
+
try {
|
|
259
|
+
result = fn(...args);
|
|
260
|
+
} catch(e) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
257
263
|
if (result === false) return false;
|
|
264
|
+
// 如果 hook 返回 Promise,在同步模式下用 Promise.then 跟踪(不影响主流程)
|
|
265
|
+
if (result && typeof result.then === 'function') {
|
|
266
|
+
// 异步 hook:静默记录报错(同步运行不阻塞),throw 也算拒绝
|
|
267
|
+
result.then(r => { if (r === false) return false; }).catch(() => false);
|
|
268
|
+
}
|
|
258
269
|
}
|
|
259
270
|
return true;
|
|
260
271
|
} finally {
|
package/package.json
CHANGED