interaction-system 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 +0 -133
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,75 +23,6 @@
|
|
|
23
23
|
npm install interaction-system
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
### 本地使用
|
|
27
|
-
|
|
28
|
-
如果你想在本地项目中使用此包,有以下几种方式:
|
|
29
|
-
|
|
30
|
-
#### 方法 1: npm link(推荐用于开发)
|
|
31
|
-
|
|
32
|
-
这种方式创建全局符号链接,适合频繁修改和测试:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# 在 interaction-system 目录中
|
|
36
|
-
cd interaction-system
|
|
37
|
-
npm link
|
|
38
|
-
|
|
39
|
-
# 在你的项目中
|
|
40
|
-
cd your-project
|
|
41
|
-
npm link interaction-system
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
之后可以像正常的 npm 包一样导入使用:
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { FeaturedInteractionHandler } from 'interaction-system';
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**取消链接:**
|
|
51
|
-
```bash
|
|
52
|
-
# 在你的项目中
|
|
53
|
-
npm unlink interaction-system
|
|
54
|
-
|
|
55
|
-
# 在 interaction-system 目录中(可选)
|
|
56
|
-
npm unlink
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
#### 方法 2: 相对路径安装
|
|
60
|
-
|
|
61
|
-
直接从本地文件系统安装:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
cd your-project
|
|
65
|
-
npm install ../path/to/ws-scrcpy/interaction-system
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### 方法 3: file: 协议
|
|
69
|
-
|
|
70
|
-
在项目的 `package.json` 中添加依赖:
|
|
71
|
-
|
|
72
|
-
```json
|
|
73
|
-
{
|
|
74
|
-
"dependencies": {
|
|
75
|
-
"interaction-system": "file:../ws-scrcpy/interaction-system"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
然后运行 `npm install`。
|
|
81
|
-
|
|
82
|
-
#### 方法 4: 直接引用源码
|
|
83
|
-
|
|
84
|
-
如果在同一个 monorepo 中,可以直接引用 TypeScript 源码:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import { FeaturedInteractionHandler } from '../../interaction-system/src';
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**注意事项:**
|
|
91
|
-
- 使用 `npm link` 时,包的更新会立即反映到所有链接的项目中
|
|
92
|
-
- 使用 `file:` 协议时,需要重新运行 `npm install` 才能获取更新
|
|
93
|
-
- 直接引用源码需要项目的构建工具能够处理 TypeScript
|
|
94
|
-
|
|
95
26
|
## 基本使用
|
|
96
27
|
|
|
97
28
|
### 1. 实现 IPlayer 接口
|
|
@@ -311,67 +242,3 @@ interface IPlayer {
|
|
|
311
242
|
- `ScreenInfo` - 屏幕信息
|
|
312
243
|
- `MotionEvent` - 运动事件常量
|
|
313
244
|
|
|
314
|
-
## 高级用法
|
|
315
|
-
|
|
316
|
-
### 多点触控
|
|
317
|
-
|
|
318
|
-
使用 `FeaturedInteractionHandler` 时,按住 `Ctrl` 键可以激活多点触控模式:
|
|
319
|
-
|
|
320
|
-
- `Ctrl + 鼠标移动` - 创建对称的两个触摸点
|
|
321
|
-
- `Ctrl + Shift + 鼠标` - 以第一个点为中心创建镜像触摸点
|
|
322
|
-
|
|
323
|
-
### 自定义命令
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
import { CommandControlMessage, ControlMessage } from 'interaction-system';
|
|
327
|
-
|
|
328
|
-
// 设置剪贴板
|
|
329
|
-
const clipboardCmd = CommandControlMessage.createSetClipboardCommand('文本内容', false);
|
|
330
|
-
|
|
331
|
-
// 设置屏幕电源模式
|
|
332
|
-
const powerCmd = CommandControlMessage.createSetScreenPowerModeCommand(true);
|
|
333
|
-
|
|
334
|
-
// 创建简单命令
|
|
335
|
-
const expandNotifications = new CommandControlMessage(ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL);
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
## 架构说明
|
|
339
|
-
|
|
340
|
-
```
|
|
341
|
-
interaction-system/
|
|
342
|
-
├── src/
|
|
343
|
-
│ ├── interaction/ # 交互处理器
|
|
344
|
-
│ ├── messages/ # 控制消息
|
|
345
|
-
│ ├── input/ # 键盘输入处理
|
|
346
|
-
│ ├── models/ # 数据模型
|
|
347
|
-
│ ├── utils/ # 工具函数
|
|
348
|
-
│ ├── types/ # TypeScript 接口
|
|
349
|
-
│ └── assets/ # 静态资源(图片等)
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
## 注意事项
|
|
353
|
-
|
|
354
|
-
1. **ScreenInfo 是必需的**:大多数交互功能都需要正确的 `ScreenInfo`,确保在使用前设置。
|
|
355
|
-
|
|
356
|
-
2. **内存管理**:使用完交互处理器后调用 `release()` 方法释放资源。
|
|
357
|
-
|
|
358
|
-
3. **Buffer 依赖**:控制消息序列化依赖 Node.js 的 `Buffer` API(通过 buffer 包提供浏览器支持)。
|
|
359
|
-
|
|
360
|
-
4. **图片资源**:多点触控可视化需要加载图片资源,确保构建工具正确处理 PNG 导入。
|
|
361
|
-
|
|
362
|
-
## TypeScript 支持
|
|
363
|
-
|
|
364
|
-
本库完全使用 TypeScript 编写,提供完整的类型定义。无需额外安装 @types 包。
|
|
365
|
-
|
|
366
|
-
## 许可证
|
|
367
|
-
|
|
368
|
-
本项目采用 Apache-2.0 许可证。
|
|
369
|
-
|
|
370
|
-
## 贡献
|
|
371
|
-
|
|
372
|
-
欢迎提交 Issue 和 Pull Request!
|
|
373
|
-
|
|
374
|
-
## 相关项目
|
|
375
|
-
|
|
376
|
-
- [ws-scrcpy](https://github.com/NetrisTV/ws-scrcpy) - 原始项目
|
|
377
|
-
|