moost 0.6.46 → 0.6.47

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/dist/index.cjs CHANGED
@@ -48,7 +48,7 @@ let stamped = false;
48
48
  if (stamped) return;
49
49
  stamped = true;
50
50
  stampModuleIdentity({
51
- version: "0.6.46",
51
+ version: "0.6.47",
52
52
  path: typeof __filename === "string" ? __filename : require("url").pathToFileURL(__filename).href
53
53
  });
54
54
  }
@@ -2387,12 +2387,17 @@ function _define_property(obj, key, value) {
2387
2387
  * - before the hook pass starts (including from a controller constructor
2388
2388
  * during binding) — queued;
2389
2389
  * - while the pass runs (from another hook) — runs later in the same pass;
2390
- * - after the pass finished — runs immediately (asynchronously, in its own
2391
- * init context); a failure is logged, since there is no `init()` left to
2390
+ * - after the pass finished — runs once, immediately (asynchronously, in its
2391
+ * own init context) and is NOT stored, so it does not run again on
2392
+ * re-init and per-request callers (`FOR_EVENT` constructors) do not grow
2393
+ * the hook list. A failure is logged, since there is no `init()` left to
2392
2394
  * reject.
2393
2395
  *
2394
- * No de-duplication: registering the same function twice runs it twice.
2395
- * Hooks re-run on re-init exactly like `@MoostInit` hooks.
2396
+ * No de-duplication: registering the same function twice runs it twice
2397
+ * (per-request callers should guard non-idempotent work themselves). Hooks
2398
+ * registered before or during a pass re-run on re-init exactly like
2399
+ * `@MoostInit` hooks; to get a hook on every future init, register it
2400
+ * before `init()`.
2396
2401
  * @since 0.6.46
2397
2402
  */ addInitHook(fn, opts) {
2398
2403
  const hook = {
@@ -2400,10 +2405,13 @@ function _define_property(obj, key, value) {
2400
2405
  priority: opts?.priority ?? 0,
2401
2406
  fn
2402
2407
  };
2408
+ if (this.initHookPhase === "done") {
2409
+ this.runInitHook(hook).catch((error) => {
2410
+ this.logger.error(`Late init hook failed: ${errorMessage(error)}`);
2411
+ });
2412
+ return;
2413
+ }
2403
2414
  this.initHooks.push(hook);
2404
- if (this.initHookPhase === "done") this.runInitHook(hook).catch((error) => {
2405
- this.logger.error(`Late init hook failed: ${errorMessage(error)}`);
2406
- });
2407
2415
  }
2408
2416
  /**
2409
2417
  * ### dispose
package/dist/index.d.ts CHANGED
@@ -777,12 +777,17 @@ declare class Moost extends Hookable {
777
777
  * - before the hook pass starts (including from a controller constructor
778
778
  * during binding) — queued;
779
779
  * - while the pass runs (from another hook) — runs later in the same pass;
780
- * - after the pass finished — runs immediately (asynchronously, in its own
781
- * init context); a failure is logged, since there is no `init()` left to
780
+ * - after the pass finished — runs once, immediately (asynchronously, in its
781
+ * own init context) and is NOT stored, so it does not run again on
782
+ * re-init and per-request callers (`FOR_EVENT` constructors) do not grow
783
+ * the hook list. A failure is logged, since there is no `init()` left to
782
784
  * reject.
783
785
  *
784
- * No de-duplication: registering the same function twice runs it twice.
785
- * Hooks re-run on re-init exactly like `@MoostInit` hooks.
786
+ * No de-duplication: registering the same function twice runs it twice
787
+ * (per-request callers should guard non-idempotent work themselves). Hooks
788
+ * registered before or during a pass re-run on re-init exactly like
789
+ * `@MoostInit` hooks; to get a hook on every future init, register it
790
+ * before `init()`.
786
791
  * @since 0.6.46
787
792
  */
788
793
  addInitHook(fn: (app: this) => unknown, opts?: {
package/dist/index.mjs CHANGED
@@ -47,7 +47,7 @@ let stamped = false;
47
47
  if (stamped) return;
48
48
  stamped = true;
49
49
  stampModuleIdentity({
50
- version: "0.6.46",
50
+ version: "0.6.47",
51
51
  path: typeof __filename === "string" ? __filename : import.meta.url
52
52
  });
53
53
  }
@@ -2386,12 +2386,17 @@ function _define_property(obj, key, value) {
2386
2386
  * - before the hook pass starts (including from a controller constructor
2387
2387
  * during binding) — queued;
2388
2388
  * - while the pass runs (from another hook) — runs later in the same pass;
2389
- * - after the pass finished — runs immediately (asynchronously, in its own
2390
- * init context); a failure is logged, since there is no `init()` left to
2389
+ * - after the pass finished — runs once, immediately (asynchronously, in its
2390
+ * own init context) and is NOT stored, so it does not run again on
2391
+ * re-init and per-request callers (`FOR_EVENT` constructors) do not grow
2392
+ * the hook list. A failure is logged, since there is no `init()` left to
2391
2393
  * reject.
2392
2394
  *
2393
- * No de-duplication: registering the same function twice runs it twice.
2394
- * Hooks re-run on re-init exactly like `@MoostInit` hooks.
2395
+ * No de-duplication: registering the same function twice runs it twice
2396
+ * (per-request callers should guard non-idempotent work themselves). Hooks
2397
+ * registered before or during a pass re-run on re-init exactly like
2398
+ * `@MoostInit` hooks; to get a hook on every future init, register it
2399
+ * before `init()`.
2395
2400
  * @since 0.6.46
2396
2401
  */ addInitHook(fn, opts) {
2397
2402
  const hook = {
@@ -2399,10 +2404,13 @@ function _define_property(obj, key, value) {
2399
2404
  priority: opts?.priority ?? 0,
2400
2405
  fn
2401
2406
  };
2407
+ if (this.initHookPhase === "done") {
2408
+ this.runInitHook(hook).catch((error) => {
2409
+ this.logger.error(`Late init hook failed: ${errorMessage(error)}`);
2410
+ });
2411
+ return;
2412
+ }
2402
2413
  this.initHooks.push(hook);
2403
- if (this.initHookPhase === "done") this.runInitHook(hook).catch((error) => {
2404
- this.logger.error(`Late init hook failed: ${errorMessage(error)}`);
2405
- });
2406
2414
  }
2407
2415
  /**
2408
2416
  * ### dispose
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moost",
3
- "version": "0.6.46",
3
+ "version": "0.6.47",
4
4
  "description": "moost",
5
5
  "keywords": [
6
6
  "composables",
@@ -49,7 +49,7 @@
49
49
  "@wooksjs/event-http": "^0.7.26",
50
50
  "@wooksjs/http-body": "^0.7.26",
51
51
  "vitest": "3.2.7",
52
- "@moostjs/event-http": "^0.6.46"
52
+ "@moostjs/event-http": "^0.6.47"
53
53
  },
54
54
  "scripts": {
55
55
  "pub": "pnpm publish --access public",