@zudojs/messaging 1.0.1 → 1.0.2

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
@@ -2,6 +2,12 @@
2
2
 
3
3
  In-process message bus infrastructure with handlers, middleware, and publish/subscribe patterns.
4
4
 
5
+ <!-- zudo-docs:start -->
6
+
7
+ **Documentation:** [zudojs.oyinlola.site/docs/packages-messaging](https://zudojs.oyinlola.site/docs/packages-messaging) · **For AI agents:** [Markdown version](https://zudojs.oyinlola.site/docs/packages-messaging.md), [llms.txt](https://zudojs.oyinlola.site/llms.txt)
8
+
9
+ <!-- zudo-docs:end -->
10
+
5
11
  ## Installation
6
12
 
7
13
  ```bash
@@ -13,6 +13,6 @@ export function resolveMessageHandler(handler) {
13
13
  if (typeof handler === "function") {
14
14
  return handler;
15
15
  }
16
- return handler.handle;
16
+ return handler.handle.bind(handler);
17
17
  }
18
18
  //# sourceMappingURL=messageHandlerType.type.js.map
@@ -3,32 +3,7 @@
3
3
  *
4
4
  * @module messageMiddleware/messageMiddlewarePipeline
5
5
  */
6
- /**
7
- * Compose an array of middleware into a single function.
8
- *
9
- * The returned function executes middleware in order.
10
- * If no middleware is provided, the handler is called directly.
11
- */
12
- function compose(middlewareList, handler) {
13
- if (middlewareList.length === 0) {
14
- return handler;
15
- }
16
- return async (context) => {
17
- let index = -1;
18
- async function dispatch(i) {
19
- if (i <= index) {
20
- throw new Error("next() called multiple times");
21
- }
22
- index = i;
23
- if (i < middlewareList.length) {
24
- const mw = middlewareList[i];
25
- return mw(context, () => dispatch(i + 1));
26
- }
27
- return handler(context);
28
- }
29
- return dispatch(0);
30
- };
31
- }
6
+ import { compose } from "@zudojs/middleware";
32
7
  /**
33
8
  * Resolves a MessageMiddlewareLike to a plain MessageMiddleware function.
34
9
  */
@@ -36,7 +11,7 @@ function resolveMiddlewareLike(mw) {
36
11
  if (typeof mw === "function") {
37
12
  return mw;
38
13
  }
39
- return mw.handle;
14
+ return mw.handle.bind(mw);
40
15
  }
41
16
  /**
42
17
  * Runs a handler through a middleware pipeline and returns the
@@ -78,7 +53,8 @@ export async function runMessagePipeline(middlewareList, handler, message, optio
78
53
  };
79
54
  });
80
55
  const pipelineStart = performance.now();
81
- const composed = compose(resolvedMiddleware, async (ctx) => handler(message, ctx));
56
+ // Unbounded depth: the list length is fixed by the registered middleware.
57
+ const composed = compose(resolvedMiddleware, async (ctx) => handler(message, ctx), { maxDepth: Number.POSITIVE_INFINITY });
82
58
  const context = {
83
59
  message,
84
60
  context: options.context ?? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/messaging",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "In-process message bus infrastructure with handlers, middleware, and publish/subscribe patterns.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,8 +19,9 @@
19
19
  "!dist/.tsbuildinfo"
20
20
  ],
21
21
  "dependencies": {
22
- "@zudojs/errors": "1.0.1",
23
- "@zudojs/constants": "1.0.1"
22
+ "@zudojs/constants": "1.1.0",
23
+ "@zudojs/errors": "1.1.0",
24
+ "@zudojs/middleware": "1.0.2"
24
25
  },
25
26
  "engines": {
26
27
  "node": ">=24.0.0"