spice-client 1.0.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.
Files changed (74) hide show
  1. package/COPYING +674 -0
  2. package/COPYING.LESSER +165 -0
  3. package/LICENSE +14 -0
  4. package/README.cn.md +143 -0
  5. package/README.md +143 -0
  6. package/dist/cjs/index.js +14 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/esm/atKeynames.d.ts +92 -0
  9. package/dist/esm/atKeynames.d.ts.map +1 -0
  10. package/dist/esm/bitmap.d.ts +11 -0
  11. package/dist/esm/bitmap.d.ts.map +1 -0
  12. package/dist/esm/code_to_scancode.d.ts +148 -0
  13. package/dist/esm/code_to_scancode.d.ts.map +1 -0
  14. package/dist/esm/cursor.d.ts +6 -0
  15. package/dist/esm/cursor.d.ts.map +1 -0
  16. package/dist/esm/display.d.ts +26 -0
  17. package/dist/esm/display.d.ts.map +1 -0
  18. package/dist/esm/enums.d.ts +312 -0
  19. package/dist/esm/enums.d.ts.map +1 -0
  20. package/dist/esm/filexfer.d.ts +14 -0
  21. package/dist/esm/filexfer.d.ts.map +1 -0
  22. package/dist/esm/index.d.ts +9 -0
  23. package/dist/esm/index.d.ts.map +1 -0
  24. package/dist/esm/index.js +5328 -0
  25. package/dist/esm/index.js.map +1 -0
  26. package/dist/esm/inputs.d.ts +31 -0
  27. package/dist/esm/inputs.d.ts.map +1 -0
  28. package/dist/esm/lz.d.ts +2 -0
  29. package/dist/esm/lz.d.ts.map +1 -0
  30. package/dist/esm/main.d.ts +49 -0
  31. package/dist/esm/main.d.ts.map +1 -0
  32. package/dist/esm/playback.d.ts +18 -0
  33. package/dist/esm/playback.d.ts.map +1 -0
  34. package/dist/esm/png.d.ts +2 -0
  35. package/dist/esm/png.d.ts.map +1 -0
  36. package/dist/esm/port.d.ts +9 -0
  37. package/dist/esm/port.d.ts.map +1 -0
  38. package/dist/esm/quic.d.ts +19 -0
  39. package/dist/esm/quic.d.ts.map +1 -0
  40. package/dist/esm/resize.d.ts +4 -0
  41. package/dist/esm/resize.d.ts.map +1 -0
  42. package/dist/esm/simulatecursor.d.ts +26 -0
  43. package/dist/esm/simulatecursor.d.ts.map +1 -0
  44. package/dist/esm/spicearraybuffer.d.ts +2 -0
  45. package/dist/esm/spicearraybuffer.d.ts.map +1 -0
  46. package/dist/esm/spiceconn.d.ts +46 -0
  47. package/dist/esm/spiceconn.d.ts.map +1 -0
  48. package/dist/esm/spicedataview.d.ts +13 -0
  49. package/dist/esm/spicedataview.d.ts.map +1 -0
  50. package/dist/esm/spicemsg.d.ts +469 -0
  51. package/dist/esm/spicemsg.d.ts.map +1 -0
  52. package/dist/esm/spicetype.d.ts +125 -0
  53. package/dist/esm/spicetype.d.ts.map +1 -0
  54. package/dist/esm/thirdparty/jsbn.d.ts +52 -0
  55. package/dist/esm/thirdparty/jsbn.d.ts.map +1 -0
  56. package/dist/esm/thirdparty/prng4.d.ts +12 -0
  57. package/dist/esm/thirdparty/prng4.d.ts.map +1 -0
  58. package/dist/esm/thirdparty/rng.d.ts +4 -0
  59. package/dist/esm/thirdparty/rng.d.ts.map +1 -0
  60. package/dist/esm/thirdparty/rsa.d.ts +15 -0
  61. package/dist/esm/thirdparty/rsa.d.ts.map +1 -0
  62. package/dist/esm/thirdparty/sha1.d.ts +10 -0
  63. package/dist/esm/thirdparty/sha1.d.ts.map +1 -0
  64. package/dist/esm/ticket.d.ts +4 -0
  65. package/dist/esm/ticket.d.ts.map +1 -0
  66. package/dist/esm/utils.d.ts +16 -0
  67. package/dist/esm/utils.d.ts.map +1 -0
  68. package/dist/esm/webm.d.ts +142 -0
  69. package/dist/esm/webm.d.ts.map +1 -0
  70. package/dist/esm/wire.d.ts +14 -0
  71. package/dist/esm/wire.d.ts.map +1 -0
  72. package/dist/global/spice-client.min.js +14 -0
  73. package/dist/global/spice-client.min.js.map +1 -0
  74. package/package.json +436 -0
package/COPYING.LESSER ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+
6
+ This project is licensed under the GNU Lesser General Public License v3.0 or later.
7
+
8
+ See COPYING for the full text of the GNU General Public License v3.0.
9
+ See COPYING.LESSER for the full text of the GNU Lesser General Public License v3.0.
10
+
11
+ This project is a TypeScript port of spice-html5:
12
+ https://gitlab.freedesktop.org/spice/spice-html5.git
13
+
14
+ Original authors: SPICE Project <spice-devel@lists.freedesktop.org>
package/README.cn.md ADDED
@@ -0,0 +1,143 @@
1
+ # spice-client
2
+
3
+ [English](./README.md)
4
+
5
+ [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) 的 TypeScript 移植版 - SPICE 协议的 JavaScript 客户端。
6
+
7
+ ## 归属说明
8
+
9
+ **本项目是原始 [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) 项目的 TypeScript 移植版。**
10
+
11
+ - **原始项目**: https://gitlab.freedesktop.org/spice/spice-html5.git
12
+ - **原始作者**: SPICE Project <spice-devel@lists.freedesktop.org> (https://www.spice-space.org)
13
+ - **原始许可证**: LGPL-3.0-or-later
14
+
15
+ **所有荣誉归于原始作者。** 本项目仅做了以下工作:
16
+ - 将 JavaScript 代码转换为 TypeScript
17
+ - 添加了单元测试
18
+ - 使用 Vite 实现了现代化的构建流程
19
+ - 添加了 LZ4 图像压缩支持
20
+
21
+ TypeScript 转换和构建配置代码是在 Trae Solo Coder 模式下借助 GLM-5 模型辅助生成的。
22
+
23
+ ## 许可证
24
+
25
+ 本项目采用 GNU 通用公共许可证 v3.0 或更高版本授权 - 详见 [LICENSE](LICENSE) 文件。
26
+
27
+ 本项目包含以下文件的副本:
28
+ - [COPYING](COPYING) - GNU 通用公共许可证 v3.0
29
+ - [COPYING.LESSER](COPYING.LESSER) - GNU 通用公共许可证 v3.0
30
+
31
+ ## 安装
32
+
33
+ ```bash
34
+ npm install spice-client
35
+ ```
36
+
37
+ ## 使用方法
38
+
39
+ ### ES Modules
40
+
41
+ ```javascript
42
+ import { SpiceMainConn, Constants } from 'spice-client';
43
+
44
+ const spice = new SpiceMainConn({
45
+ uri: 'ws://localhost:5959',
46
+ password: 'your-password',
47
+ onsuccess: () => console.log('已连接!'),
48
+ onerror: (e) => console.error('错误:', e)
49
+ });
50
+ ```
51
+
52
+ ### CommonJS
53
+
54
+ ```javascript
55
+ const { SpiceMainConn, Constants } = require('spice-client');
56
+ ```
57
+
58
+ ### 浏览器全局变量 (IIFE)
59
+
60
+ 引入压缩后的包:
61
+
62
+ ```html
63
+ <script src="node_modules/spice-client/dist/global/spice-client.min.js"></script>
64
+ <script>
65
+ const spice = new SpiceClient.SpiceMainConn({
66
+ uri: 'ws://localhost:5959',
67
+ password: 'your-password'
68
+ });
69
+ </script>
70
+ ```
71
+
72
+ ## 环境要求
73
+
74
+ 1. 现代浏览器(Firefox、Chrome 或 Edge)
75
+ 2. WebSocket 代理(例如 [websockify](https://github.com/novnc/websockify))
76
+ 3. SPICE 服务器
77
+
78
+ ## 快速开始
79
+
80
+ 1. 启动 SPICE 服务器
81
+ 2. 启动 websockify:
82
+ ```bash
83
+ websockify 5959 localhost:5900
84
+ ```
85
+ 3. 使用客户端连接
86
+
87
+ ## API
88
+
89
+ ### 导出
90
+
91
+ | 导出 | 描述 |
92
+ |--------|-------------|
93
+ | `SpiceMainConn` | SPICE 主连接类 |
94
+ | `SpiceConn` | 基础 SPICE 连接 |
95
+ | `SpiceDisplayConn` | 显示通道连接 |
96
+ | `SpiceInputsConn` | 输入(键盘/鼠标)通道 |
97
+ | `SpiceCursorConn` | 光标通道连接 |
98
+ | `SpicePlaybackConn` | 音频播放通道 |
99
+ | `SpicePortConn` | 端口通道连接 |
100
+ | `Constants` | SPICE 协议常量 |
101
+ | `handle_file_dragover` | 文件拖放处理函数 |
102
+ | `handle_file_drop` | 文件释放处理函数 |
103
+ | `resize_helper` | 调整大小辅助函数 |
104
+ | `handle_resize` | 调整大小处理函数 |
105
+ | `sendCtrlAltDel` | 发送 Ctrl+Alt+Del 组合键 |
106
+
107
+ ## 构建
108
+
109
+ ```bash
110
+ # 构建所有格式(ESM、CJS、浏览器全局压缩版)
111
+ npm run build
112
+ ```
113
+
114
+ 构建输出:
115
+ ```
116
+ dist/
117
+ ├── esm/ # ES Module 构建
118
+ ├── cjs/ # CommonJS 构建
119
+ └── global/ # 浏览器用压缩版 IIFE
120
+ ```
121
+
122
+ ## 开发
123
+
124
+ ```bash
125
+ # 安装依赖
126
+ npm install
127
+
128
+ # 运行测试
129
+ npm test
130
+
131
+ # 监听模式运行测试
132
+ npm run test:watch
133
+
134
+ # 运行端到端测试
135
+ npm run test:e2e
136
+ ```
137
+
138
+ ## 相关项目
139
+
140
+ - [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) - 原始 JavaScript 实现
141
+ - [websockify](https://github.com/novnc/websockify) - WebSocket 转 TCP 代理
142
+ - [SPICE Project](https://www.spice-space.org/) - 官方 SPICE 项目
143
+ - [Electerm](https://github.com/electerm/electerm) - 使用此库的终端/SSH/SFTP/Spice/Telnet/Ftp/RDP/VNC/Serial 客户端
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # spice-client
2
+
3
+ [中文](./README.cn.md)
4
+
5
+ A TypeScript port of [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) - a JavaScript client for the SPICE protocol.
6
+
7
+ ## Attribution
8
+
9
+ **This project is a TypeScript port of the original [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) project.**
10
+
11
+ - **Original Project**: https://gitlab.freedesktop.org/spice/spice-html5.git
12
+ - **Original Authors**: SPICE Project <spice-devel@lists.freedesktop.org> (https://www.spice-space.org)
13
+ - **Original License**: LGPL-3.0-or-later
14
+
15
+ **All credit goes to the original authors.** This project simply:
16
+ - Converted the JavaScript code to TypeScript
17
+ - Added unit tests
18
+ - Implemented a modern build process with Vite
19
+ - Added LZ4 image compression support
20
+
21
+ The TypeScript conversion and build setup code was generated with the assistance of the GLM-5 model in Trae Solo Coder mode.
22
+
23
+ ## License
24
+
25
+ This project is licensed under the GNU Lesser General Public License v3.0 or later - see the [LICENSE](LICENSE) file for details.
26
+
27
+ This project includes copies of:
28
+ - [COPYING](COPYING) - GNU General Public License v3.0
29
+ - [COPYING.LESSER](COPYING.LESSER) - GNU Lesser General Public License v3.0
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ npm install spice-client
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ### ES Modules
40
+
41
+ ```javascript
42
+ import { SpiceMainConn, Constants } from 'spice-client';
43
+
44
+ const spice = new SpiceMainConn({
45
+ uri: 'ws://localhost:5959',
46
+ password: 'your-password',
47
+ onsuccess: () => console.log('Connected!'),
48
+ onerror: (e) => console.error('Error:', e)
49
+ });
50
+ ```
51
+
52
+ ### CommonJS
53
+
54
+ ```javascript
55
+ const { SpiceMainConn, Constants } = require('spice-client');
56
+ ```
57
+
58
+ ### Browser Global (IIFE)
59
+
60
+ Include the minified bundle:
61
+
62
+ ```html
63
+ <script src="node_modules/spice-client/dist/global/spice-client.min.js"></script>
64
+ <script>
65
+ const spice = new SpiceClient.SpiceMainConn({
66
+ uri: 'ws://localhost:5959',
67
+ password: 'your-password'
68
+ });
69
+ </script>
70
+ ```
71
+
72
+ ## Requirements
73
+
74
+ 1. A modern browser (Firefox, Chrome, or Edge)
75
+ 2. A WebSocket proxy (e.g., [websockify](https://github.com/novnc/websockify))
76
+ 3. A SPICE server
77
+
78
+ ## Quick Start
79
+
80
+ 1. Start your SPICE server
81
+ 2. Start websockify:
82
+ ```bash
83
+ websockify 5959 localhost:5900
84
+ ```
85
+ 3. Connect using the client
86
+
87
+ ## API
88
+
89
+ ### Exports
90
+
91
+ | Export | Description |
92
+ |--------|-------------|
93
+ | `SpiceMainConn` | Main SPICE connection class |
94
+ | `SpiceConn` | Base SPICE connection |
95
+ | `SpiceDisplayConn` | Display channel connection |
96
+ | `SpiceInputsConn` | Inputs (keyboard/mouse) channel |
97
+ | `SpiceCursorConn` | Cursor channel connection |
98
+ | `SpicePlaybackConn` | Audio playback channel |
99
+ | `SpicePortConn` | Port channel connection |
100
+ | `Constants` | SPICE protocol constants |
101
+ | `handle_file_dragover` | File drag handler |
102
+ | `handle_file_drop` | File drop handler |
103
+ | `resize_helper` | Resize helper function |
104
+ | `handle_resize` | Resize handler |
105
+ | `sendCtrlAltDel` | Send Ctrl+Alt+Del sequence |
106
+
107
+ ## Build
108
+
109
+ ```bash
110
+ # Build all formats (ESM, CJS, global minified)
111
+ npm run build
112
+ ```
113
+
114
+ Build output:
115
+ ```
116
+ dist/
117
+ ├── esm/ # ES Module build
118
+ ├── cjs/ # CommonJS build
119
+ └── global/ # Minified IIFE for browsers
120
+ ```
121
+
122
+ ## Development
123
+
124
+ ```bash
125
+ # Install dependencies
126
+ npm install
127
+
128
+ # Run tests
129
+ npm test
130
+
131
+ # Run tests in watch mode
132
+ npm run test:watch
133
+
134
+ # Run e2e tests
135
+ npm run test:e2e
136
+ ```
137
+
138
+ ## Related Projects
139
+
140
+ - [spice-html5](https://gitlab.freedesktop.org/spice/spice-html5.git) - Original JavaScript implementation
141
+ - [websockify](https://github.com/novnc/websockify) - WebSocket to TCP proxy
142
+ - [SPICE Project](https://www.spice-space.org/) - Official SPICE project
143
+ - [Electerm](https://github.com/electerm/electerm) - Terminal/SSH/SFTP/Spice/Telnet/Ftp/RDP/VNC/Serial client using this library