@lytjs/hmr 6.5.0 → 6.6.0

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
@@ -1,79 +1,79 @@
1
- # @lytjs/hmr
2
-
3
- LytJS 热模块替换(Hot Module Replacement)支持。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- pnpm add -D @lytjs/hmr
9
- ```
10
-
11
- ## 快速开始
12
-
13
- ```typescript
14
- import { createHMRClient, getHMRClient, accept } from '@lytjs/hmr';
15
-
16
- // 创建 HMR 客户端
17
- const client = createHMRClient({
18
- url: 'ws://localhost:5173',
19
- autoConnect: true,
20
- });
21
-
22
- // 或者使用全局单例
23
- const globalClient = getHMRClient();
24
-
25
- // 接受模块更新
26
- accept('/path/to/module.ts', (update) => {
27
- console.log('模块已更新:', update);
28
- });
29
- ```
30
-
31
- ## 特性
32
-
33
- - WebSocket 连接管理
34
- - 模块更新处理
35
- - 自动重连
36
- - 状态保持
37
-
38
- ## API
39
-
40
- ### createHMRClient(options)
41
-
42
- 创建 HMR 客户端实例。
43
-
44
- ```typescript
45
- import { createHMRClient } from '@lytjs/hmr';
46
-
47
- const client = createHMRClient({
48
- url: 'ws://localhost:5173',
49
- autoConnect: true,
50
- });
51
- ```
52
-
53
- ### getHMRClient(options)
54
-
55
- 获取全局 HMR 客户端单例。
56
-
57
- ### accept(path, handler)
58
-
59
- 注册模块更新处理函数。
60
-
61
- ### dispose(path, handler)
62
-
63
- 注册模块清理函数。
64
-
65
- ### client.connect()
66
-
67
- 连接到 HMR 服务器。
68
-
69
- ### client.disconnect()
70
-
71
- 断开连接。
72
-
73
- ### client.send(message)
74
-
75
- 发送消息。
76
-
77
- ## 许可证
78
-
79
- MIT
1
+ # @lytjs/hmr
2
+
3
+ LytJS 热模块替换(Hot Module Replacement)支持。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add -D @lytjs/hmr
9
+ ```
10
+
11
+ ## 快速开始
12
+
13
+ ```typescript
14
+ import { createHMRClient, getHMRClient, accept } from '@lytjs/hmr';
15
+
16
+ // 创建 HMR 客户端
17
+ const client = createHMRClient({
18
+ url: 'ws://localhost:5173',
19
+ autoConnect: true,
20
+ });
21
+
22
+ // 或者使用全局单例
23
+ const globalClient = getHMRClient();
24
+
25
+ // 接受模块更新
26
+ accept('/path/to/module.ts', (update) => {
27
+ console.log('模块已更新:', update);
28
+ });
29
+ ```
30
+
31
+ ## 特性
32
+
33
+ - WebSocket 连接管理
34
+ - 模块更新处理
35
+ - 自动重连
36
+ - 状态保持
37
+
38
+ ## API
39
+
40
+ ### createHMRClient(options)
41
+
42
+ 创建 HMR 客户端实例。
43
+
44
+ ```typescript
45
+ import { createHMRClient } from '@lytjs/hmr';
46
+
47
+ const client = createHMRClient({
48
+ url: 'ws://localhost:5173',
49
+ autoConnect: true,
50
+ });
51
+ ```
52
+
53
+ ### getHMRClient(options)
54
+
55
+ 获取全局 HMR 客户端单例。
56
+
57
+ ### accept(path, handler)
58
+
59
+ 注册模块更新处理函数。
60
+
61
+ ### dispose(path, handler)
62
+
63
+ 注册模块清理函数。
64
+
65
+ ### client.connect()
66
+
67
+ 连接到 HMR 服务器。
68
+
69
+ ### client.disconnect()
70
+
71
+ 断开连接。
72
+
73
+ ### client.send(message)
74
+
75
+ 发送消息。
76
+
77
+ ## 许可证
78
+
79
+ MIT
package/dist/index.d.cts CHANGED
@@ -11,7 +11,7 @@ interface HMRMessage {
11
11
  /** 消息类型 */
12
12
  type: 'connected' | 'update' | 'full-reload' | 'custom';
13
13
  /** 数据 */
14
- data?: any;
14
+ data?: unknown;
15
15
  }
16
16
  interface HMRUpdate {
17
17
  /** 模块路径 */
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ interface HMRMessage {
11
11
  /** 消息类型 */
12
12
  type: 'connected' | 'update' | 'full-reload' | 'custom';
13
13
  /** 数据 */
14
- data?: any;
14
+ data?: unknown;
15
15
  }
16
16
  interface HMRUpdate {
17
17
  /** 模块路径 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lytjs/hmr",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "description": "LytJS Hot Module Replacement support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",