@hile/message-modem 1.0.2 → 1.0.4

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
@@ -92,7 +92,7 @@ try {
92
92
  | `post(data)` | `protected abstract` | 子类实现:如何将消息发送到远端 |
93
93
  | `exec(data)` | `protected abstract` | 子类实现:如何处理收到的请求,返回 Promise |
94
94
  | `_send(data, timeout?)` | `protected` | 发送双向请求(`twoway: true`),返回 `{ abort, response }` |
95
- | `_push(data, timeout?)` | `protected` | 发送单向推送(`twoway: false`),接收方不回复 RESPONSE |
95
+ | `_push(data, timeout?)` | `protected` | 发送单向推送(`twoway: false`),无返回值,接收方不回复 RESPONSE |
96
96
  | `receive(msg)` | `public` | 接收消息入口,根据 mode 分发处理 |
97
97
 
98
98
  ### `_send` 返回值
package/SKILL.md CHANGED
@@ -88,10 +88,7 @@ abstract class MessageModem {
88
88
  abort: () => void;
89
89
  response: <U = any>() => Promise<U>;
90
90
  };
91
- protected _push<T>(data: T, timeout?: number): {
92
- abort: () => void;
93
- response: <U = any>() => Promise<U>;
94
- };
91
+ protected _push<T>(data: T, timeout?: number): void;
95
92
  public receive(msg: MessageTransferFormat): void;
96
93
  }
97
94
  ```
package/dist/index.d.ts CHANGED
@@ -59,10 +59,7 @@ export declare abstract class MessageModem {
59
59
  * @param timeout - 超时时间
60
60
  * @returns 消息响应
61
61
  */
62
- protected _push<T = any>(data: T, timeout?: number): {
63
- abort: () => void;
64
- response: <U = any>() => Promise<U>;
65
- };
62
+ protected _push<T = any>(data: T, timeout?: number): void;
66
63
  /**
67
64
  * 写入消息
68
65
  * @param data - 消息数据
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ export class MessageModem {
54
54
  * @returns 消息响应
55
55
  */
56
56
  _push(data, timeout = 30000) {
57
- return this._write(data, timeout, false);
57
+ this._write(data, timeout, false);
58
58
  }
59
59
  /**
60
60
  * 写入消息
@@ -63,11 +63,14 @@ export class MessageModem {
63
63
  * @returns 消息响应
64
64
  */
65
65
  _write(data, timeout = 30000, twoway = false) {
66
- const controller = new AbortController();
67
66
  // 创建请求消息数据
68
67
  const state = this.createPostData(MESSAGE_MODEM_TYPE.REQUEST, data, twoway);
69
68
  // 发送消息
70
69
  this.post(state);
70
+ // 如果消息是单向的,则直接返回
71
+ if (!twoway)
72
+ return;
73
+ const controller = new AbortController();
71
74
  return {
72
75
  // 终止请求
73
76
  abort: () => controller.abort(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hile/message-modem",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -21,5 +21,5 @@
21
21
  "fix-esm-import-path": "^1.10.3",
22
22
  "vitest": "^4.0.18"
23
23
  },
24
- "gitHead": "86b1ce38e9eeb069acb2188834a0ff5b466a050a"
24
+ "gitHead": "14216a0622f27cc08f3c995fce0e2b5f9133e130"
25
25
  }