spice-client 1.0.0 → 1.1.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.cn.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # spice-client
2
2
 
3
- [English](./README.md)
3
+ [English](./README.md) | [中文](./README.cn.md)
4
4
 
5
5
  [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) 的 TypeScript 移植版 - SPICE 协议的 JavaScript 客户端。
6
6
 
@@ -17,6 +17,9 @@
17
17
  - 添加了单元测试
18
18
  - 使用 Vite 实现了现代化的构建流程
19
19
  - 添加了 LZ4 图像压缩支持
20
+ - 优化消息处理,直接处理多个 ArrayBuffer,避免缓冲区拼接开销
21
+ - 单 ArrayBuffer 操作使用原生 DataView,仅在多缓冲区场景下使用自定义 SpiceDataView
22
+ - 改进鼠标移动处理,采用队列+折叠策略和 requestIdleCallback 实现更流畅的输入
20
23
 
21
24
  TypeScript 转换和构建配置代码是在 Trae Solo Coder 模式下借助 GLM-5 模型辅助生成的。
22
25
 
@@ -98,12 +101,41 @@ const { SpiceMainConn, Constants } = require('spice-client');
98
101
  | `SpicePlaybackConn` | 音频播放通道 |
99
102
  | `SpicePortConn` | 端口通道连接 |
100
103
  | `Constants` | SPICE 协议常量 |
104
+ | `SpiceEventType` | 事件类型定义 |
105
+ | `SpiceEventHandlers` | 事件处理器类型定义 |
101
106
  | `handle_file_dragover` | 文件拖放处理函数 |
102
107
  | `handle_file_drop` | 文件释放处理函数 |
103
108
  | `resize_helper` | 调整大小辅助函数 |
104
109
  | `handle_resize` | 调整大小处理函数 |
105
110
  | `sendCtrlAltDel` | 发送 Ctrl+Alt+Del 组合键 |
106
111
 
112
+ ### 事件
113
+
114
+ `SpiceMainConn` 类支持使用 `on()` 和 `off()` 方法注册事件。
115
+
116
+ #### connection_status
117
+
118
+ 连接状态变化时触发。
119
+
120
+ ```javascript
121
+ spice.on('connection_status', (status) => {
122
+ console.log('连接状态:', status);
123
+ // 可能的值: 'connecting', 'connected', 'error', 'disconnected'
124
+ });
125
+ ```
126
+
127
+ #### keyboard_modifiers
128
+
129
+ 键盘修饰键(NumLock、CapsLock、ScrollLock)状态变化时触发。
130
+
131
+ ```javascript
132
+ spice.on('keyboard_modifiers', (modifiers) => {
133
+ console.log('NumLock:', modifiers.num_lock);
134
+ console.log('CapsLock:', modifiers.caps_lock);
135
+ console.log('ScrollLock:', modifiers.scroll_lock);
136
+ });
137
+ ```
138
+
107
139
  ## 构建
108
140
 
109
141
  ```bash
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # spice-client
2
2
 
3
- [中文](./README.cn.md)
3
+ [中文](./README.cn.md) | [English](./README.md)
4
4
 
5
5
  A TypeScript port of [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) - a JavaScript client for the SPICE protocol.
6
6
 
@@ -17,6 +17,9 @@ A TypeScript port of [spice-html5](https://gitlab.freedesktop.org/spice/spice-ht
17
17
  - Added unit tests
18
18
  - Implemented a modern build process with Vite
19
19
  - Added LZ4 image compression support
20
+ - Optimized message processing to handle multiple ArrayBuffers directly, avoiding buffer concatenation overhead
21
+ - Uses native DataView for single ArrayBuffer operations, falling back to custom SpiceDataView only for multi-buffer scenarios
22
+ - Improved mouse motion handling with queue + collapse strategy and requestIdleCallback for smoother input
20
23
 
21
24
  The TypeScript conversion and build setup code was generated with the assistance of the GLM-5 model in Trae Solo Coder mode.
22
25
 
@@ -98,12 +101,41 @@ Include the minified bundle:
98
101
  | `SpicePlaybackConn` | Audio playback channel |
99
102
  | `SpicePortConn` | Port channel connection |
100
103
  | `Constants` | SPICE protocol constants |
104
+ | `SpiceEventType` | Event type definitions |
105
+ | `SpiceEventHandlers` | Event handler type definitions |
101
106
  | `handle_file_dragover` | File drag handler |
102
107
  | `handle_file_drop` | File drop handler |
103
108
  | `resize_helper` | Resize helper function |
104
109
  | `handle_resize` | Resize handler |
105
110
  | `sendCtrlAltDel` | Send Ctrl+Alt+Del sequence |
106
111
 
112
+ ### Events
113
+
114
+ The `SpiceMainConn` class supports event registration using `on()` and `off()` methods.
115
+
116
+ #### connection_status
117
+
118
+ Emitted when the connection status changes.
119
+
120
+ ```javascript
121
+ spice.on('connection_status', (status) => {
122
+ console.log('Connection status:', status);
123
+ // Possible values: 'connecting', 'connected', 'error', 'disconnected'
124
+ });
125
+ ```
126
+
127
+ #### keyboard_modifiers
128
+
129
+ Emitted when keyboard modifier keys (NumLock, CapsLock, ScrollLock) state changes.
130
+
131
+ ```javascript
132
+ spice.on('keyboard_modifiers', (modifiers) => {
133
+ console.log('NumLock:', modifiers.num_lock);
134
+ console.log('CapsLock:', modifiers.caps_lock);
135
+ console.log('ScrollLock:', modifiers.scroll_lock);
136
+ });
137
+ ```
138
+
107
139
  ## Build
108
140
 
109
141
  ```bash