@yagolive/event-kit 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.
- package/CHANGELOG.md +70 -0
- package/README.md +651 -0
- package/build/js/action_bridge.umd.js +744 -0
- package/build/js/action_creator.umd.js +479 -0
- package/package.json +84 -0
- package/src/adapters/MockAdapter.js +44 -0
- package/src/adapters/RNWebViewAdapter.js +76 -0
- package/src/adapters/index.d.ts +44 -0
- package/src/adapters/index.js +2 -0
- package/src/bridge/ActionBridge.js +164 -0
- package/src/bridge/index.d.ts +59 -0
- package/src/bridge/index.js +1 -0
- package/src/core/ActionCreator.js +121 -0
- package/src/core/index.d.ts +182 -0
- package/src/core/index.js +8 -0
- package/src/core/types/Action.js +28 -0
- package/src/core/types/EnterRoom.js +92 -0
- package/src/core/types/Jump.js +27 -0
- package/src/core/types/LiveDetect.js +16 -0
- package/src/core/types/Navigate.js +31 -0
- package/src/core/types/Onelink.js +28 -0
- package/src/core/types/Replace.js +9 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +10 -0
- package/src/integrations/react/index.d.ts +13 -0
- package/src/integrations/react/index.js +41 -0
- package/src/integrations/vue/index.d.ts +13 -0
- package/src/integrations/vue/index.js +28 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## @1.0.0 (2026-05-22)
|
|
4
|
+
|
|
5
|
+
### 新增
|
|
6
|
+
|
|
7
|
+
- **分层架构重构**: 将原有单体文件拆分为 Core / Adapters / Bridge / Integrations 四层架构
|
|
8
|
+
- Core 层: 零环境依赖的 Action 创建逻辑
|
|
9
|
+
- Adapters 层: 可插拔的通信适配器(RNWebViewAdapter、MockAdapter)
|
|
10
|
+
- Bridge 层: 统一的 ActionBridge 接口,注入适配器实现跨环境通信
|
|
11
|
+
- Integrations 层: React / Vue 3 框架集成
|
|
12
|
+
|
|
13
|
+
- **ActionCreator**:
|
|
14
|
+
- `ActionCreator.ActionData`: 包含 Jump、Navigate、Replace、EnterRoom、LiveDetect、Onelink 数据类型
|
|
15
|
+
- `ActionCreator.ActionType`: Action 类型枚举(JUMP、NAVIGATE、REPLACE、ENTER_ROOM、LIVE_DETECT、ONELINK)
|
|
16
|
+
- 工厂方法: buildJump、createJumpAction、createJumpActionWithData、buildNavigate、createNavigateAction、createNavigateActionWithParams、createNavigateActionWithData、buildReplace、createReplaceAction、createReplaceActionWithParams、createReplaceActionWithData、buildEnterRoom、createEnterRoomAction、createEnterRoomActionWithData、buildLiveDetect、createLiveDetectAction、createLiveDetectActionWithData、buildOnelink、createOnelinkAction、createOnelinkActionWithData
|
|
17
|
+
|
|
18
|
+
- **ActionBridge**: 统一桥接接口
|
|
19
|
+
- 构造函数注入适配器,支持自定义通信实现
|
|
20
|
+
- Promise + 回调双重支持: `sendAction(action, callback?)` 返回 Promise
|
|
21
|
+
- 便捷方法: jump、navigate、replace、enterRoom、liveDetect、onelink
|
|
22
|
+
- 委托方法: 每种 Action 类型均提供 buildXxx、createXxxAction、createXxxActionWithData
|
|
23
|
+
- 静态工厂: `createDefault()`、`createWithMock()`
|
|
24
|
+
|
|
25
|
+
- **RNWebViewAdapter**: React Native WebView 通信适配器
|
|
26
|
+
- 自动检测 Android/iOS 平台注册消息监听
|
|
27
|
+
- 超时机制(默认 30 秒)
|
|
28
|
+
- 通过 `window.ReactNativeWebView.postMessage` 发送消息
|
|
29
|
+
|
|
30
|
+
- **MockAdapter**: 测试用适配器
|
|
31
|
+
- mockResult / mockError 配置预期返回
|
|
32
|
+
- getCalls 记录调用历史
|
|
33
|
+
- 可配置响应延迟
|
|
34
|
+
|
|
35
|
+
- **React 集成**: `@yagolive/event-kit/react`
|
|
36
|
+
- `ActionBridgeProvider`: Context Provider 组件
|
|
37
|
+
- `useActionBridge`: Hook 获取 Bridge 实例
|
|
38
|
+
|
|
39
|
+
- **Vue 3 集成**: `@yagolive/event-kit/vue`
|
|
40
|
+
- `createActionBridgePlugin`: Vue 插件
|
|
41
|
+
- `useActionBridge`: Composition API Hook
|
|
42
|
+
- `$actionBridge`: 全局属性访问
|
|
43
|
+
|
|
44
|
+
- **UMD 打包**: esbuild 自动构建
|
|
45
|
+
- `build/js/action_creator.umd.js`: 核心包(全局变量 `__action_creator__`,访问方式: `window.__action_creator__.ActionCreator`)
|
|
46
|
+
- `build/js/action_bridge.umd.js`: 完整包(全局变量 `__action_bridge__`,访问方式: `window.__action_bridge__.ActionBridge`)
|
|
47
|
+
- 支持 Browser script 标签、CommonJS、AMD
|
|
48
|
+
|
|
49
|
+
- **子路径导出**: package.json exports 支持 `@yagolive/event-kit`、`@yagolive/event-kit/core`、`@yagolive/event-kit/react`、`@yagolive/event-kit/vue`、`@yagolive/event-kit/bridge`、`@yagolive/event-kit/adapters`
|
|
50
|
+
- **TypeScript 类型定义**: 每个子路径均提供 `index.d.ts` 类型声明
|
|
51
|
+
|
|
52
|
+
### Action 类型详情
|
|
53
|
+
|
|
54
|
+
| 类型 | 字段 | 说明 |
|
|
55
|
+
|------|------|------|
|
|
56
|
+
| jump | path: string, text?: string | 页面跳转 |
|
|
57
|
+
| navigate | screen: string, params?: Record, text?: string | 导航到指定屏幕 |
|
|
58
|
+
| replace | screen: string, params?: Record, text?: string | 替换当前页面 |
|
|
59
|
+
| enter_room | id?: number, match?: string, callbacks?: Record, useReplace?: boolean, text?: string | 进入房间 |
|
|
60
|
+
| live_detect | text?: string | 活体检测 |
|
|
61
|
+
| onelink | url: string, share?: boolean, text?: string | 分享链接 |
|
|
62
|
+
|
|
63
|
+
### EnterRoom 回调类型
|
|
64
|
+
|
|
65
|
+
| 回调类型 | 字段 | 说明 |
|
|
66
|
+
|----------|------|------|
|
|
67
|
+
| open_gift_popup | id?: number, type?: string, count?: number | 打开礼物弹窗 |
|
|
68
|
+
| open_game | id: number | 打开游戏 |
|
|
69
|
+
| open_activity | id: string | 打开活动页 |
|
|
70
|
+
| switch_room_type | type: string | 切换房间类型 |
|