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 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.4** — official release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
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
  ![Engines](https://img.shields.io/badge/engines-Native%20%7C%20WASM%20%7C%20Pure%20JS-7ee787)
9
9
  ![MySQL](https://img.shields.io/badge/protocol-MySQL%20compatible-1f6feb)
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSQL-NEO v6.4.0-beta.4 — Rust-Powered Embedded Database (WASM + HTTP)
2
+ * JSQL-NEO v6.4.0-beta.5 — Rust-Powered Embedded Database (WASM + HTTP)
3
3
  *
4
4
  * @example
5
5
  * const jsql = require('jsql-neo');
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
- async function runHooks(engine, hookName, args) {
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
- // P3-3: runHooks 异步钩子静默失效——支持异步钩子
256
- const result = await fn(...args);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsql-neo",
3
- "version": "6.4.0-beta.4",
3
+ "version": "6.4.0-beta.5",
4
4
  "description": "JSQL-NEO — Rust-powered embedded database with WASM, REST API, B-Tree indexes, WAL, crash recovery",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",