@ray-js/ray-ipc-player 2.0.18-beta-1 → 2.0.18-beta-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.
@@ -12,6 +12,7 @@
12
12
  .load_box {
13
13
  color: #ffffff;
14
14
  font-size: 0.3rem;
15
+ z-index: 200;
15
16
  }
16
17
 
17
18
  .bg_center {
@@ -24,6 +25,7 @@
24
25
  justify-content: center;
25
26
  align-items: center;
26
27
  background: var(--video-bg);
28
+ z-index: 200;
27
29
  }
28
30
 
29
31
  .state_label {
@@ -0,0 +1,7 @@
1
+ declare module '*.module.less' {
2
+ const classes: { [key: string]: string };
3
+ export default classes;
4
+ }
5
+
6
+ declare module '*.less';
7
+ declare module '*.png';
package/lib/utils.js CHANGED
@@ -1,37 +1,31 @@
1
- import "core-js/modules/es.object.to-string.js";
2
- import "core-js/modules/es.promise.js";
3
- export var putDpData = function (dpIds, deviceId) {
4
- return new Promise(function (resolve, reject) {
1
+ export const putDpData = (dpIds, deviceId) => {
2
+ return new Promise((resolve, reject) => {
5
3
  ty.device.publishDps({
6
4
  deviceId: deviceId,
7
5
  mode: 2,
8
6
  pipelines: [],
9
7
  options: {},
10
8
  dps: dpIds,
11
- success: function success(res) {
12
- return resolve(res);
13
- },
14
- fail: function fail(e) {
15
- return reject(e);
16
- }
9
+ success: res => resolve(res),
10
+ fail: e => reject(e)
17
11
  });
18
12
  });
19
13
  };
14
+
20
15
  /**
21
16
  * 获取当前是否Connected (p2p连接状态)
22
17
  * @param ipcCtx
23
18
  * @returns
24
19
  */
25
-
26
- export var getIsConnected = function (ipcCtx) {
27
- return new Promise(function (resolve) {
20
+ export const getIsConnected = ipcCtx => {
21
+ return new Promise(resolve => {
28
22
  if (typeof (ipcCtx === null || ipcCtx === void 0 ? void 0 : ipcCtx.isConnected) === 'function') {
29
- ipcCtx === null || ipcCtx === void 0 ? void 0 : ipcCtx.isConnected({
30
- success: function success(res) {
23
+ ipcCtx === null || ipcCtx === void 0 || ipcCtx.isConnected({
24
+ success: res => {
31
25
  // console.log(res, 'getIsConnected---');
32
26
  resolve(res);
33
27
  },
34
- fail: function fail() {
28
+ fail: () => {
35
29
  // console.error(e, 'getIsConnected---');
36
30
  resolve(false);
37
31
  }
@@ -41,21 +35,21 @@ export var getIsConnected = function (ipcCtx) {
41
35
  }
42
36
  });
43
37
  };
38
+
44
39
  /**
45
40
  * 获取当前是否已经在拉流状态
46
41
  * @param ipcCtx
47
42
  * @returns
48
43
  */
49
-
50
- export var getIsOnPreview = function (ipcCtx) {
51
- return new Promise(function (resolve) {
44
+ export const getIsOnPreview = ipcCtx => {
45
+ return new Promise(resolve => {
52
46
  if (typeof (ipcCtx === null || ipcCtx === void 0 ? void 0 : ipcCtx.isOnPreview) === 'function') {
53
- ipcCtx === null || ipcCtx === void 0 ? void 0 : ipcCtx.isOnPreview({
54
- success: function success(res) {
47
+ ipcCtx === null || ipcCtx === void 0 || ipcCtx.isOnPreview({
48
+ success: res => {
55
49
  // console.log(res, 'getIsOnPreview---');
56
50
  resolve(res);
57
51
  },
58
- fail: function fail() {
52
+ fail: () => {
59
53
  // console.error(e, 'getIsOnPreview---');
60
54
  resolve(false);
61
55
  }
package/package.json CHANGED
@@ -1,59 +1,66 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-player",
3
- "version": "2.0.18-beta-1",
3
+ "version": "2.0.18-beta-2",
4
4
  "description": "ray小程序播放器",
5
5
  "keywords": [
6
6
  "tuya-miniapp",
7
7
  "ray"
8
8
  ],
9
- "main": "lib/index.js",
9
+ "main": "lib/index",
10
+ "files": [
11
+ "lib"
12
+ ],
13
+ "license": "MIT",
10
14
  "types": "lib/index.d.ts",
15
+ "maintainers": [
16
+ "tuya_npm",
17
+ {
18
+ "name": "tuyafe",
19
+ "email": "tuyafe@tuya.com"
20
+ }
21
+ ],
11
22
  "scripts": {
12
23
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
13
24
  "build": "ray build --type=component",
14
- "watch": "ray start --type=component",
15
- "build:tuya": "ray build ./example --target=tuya",
25
+ "watch": "ray start --type=component --output ./example/src/lib",
26
+ "build:tuya": "ray build -t tuya ./example",
16
27
  "build:wechat": "ray build ./example --target=wechat",
17
28
  "build:web": "ray build ./example --target=web",
18
29
  "build:native": "ray build ./example --target=native",
19
30
  "start:native": "ray start ./example -t native --verbose",
20
- "start:tuya": "ray start ./example -t tuya --verbose",
31
+ "start:tuya": "ray start -t tuya ./example --bundler=webpack",
21
32
  "start:wechat": "ray start ./example -t wechat --verbose",
22
33
  "start:web": "ray start ./example -t web",
23
34
  "prepublishOnly": "yarn build",
24
35
  "release-it": "standard-version"
25
36
  },
26
- "license": "MIT",
37
+ "peerDependencies": {},
27
38
  "dependencies": {
28
- "@ray-js/panel-sdk": "latest",
29
39
  "classnames": "^2.3.1",
30
40
  "immer": "^9.0.15",
31
- "use-immer": "^0.5.1"
41
+ "use-immer": "^0.5.1",
42
+ "@ray-js/panel-sdk": "^1.13.1"
32
43
  },
33
44
  "devDependencies": {
34
45
  "@commitlint/cli": "^7.2.1",
35
46
  "@commitlint/config-conventional": "^9.0.1",
36
- "@ray-js/babel-preset-standard": "latest",
37
- "@ray-js/cli": "latest",
38
- "@ray-js/ray": "1.5.44-beta.0",
39
- "@ray-js/rn-transformer-helper": "latest",
40
- "@ray-js/types": "latest",
41
- "@types/node": "^17.0.43",
47
+ "@ray-js/cli": "^1.4.9",
48
+ "@ray-js/ray": "^1.4.9",
49
+ "@testing-library/react-hooks": "^8.0.1",
50
+ "@types/jest": "^29.5.14",
42
51
  "core-js": "^3.19.1",
43
- "eslint-config-tuya-panel": "^0.4.1",
52
+ "eslint-config-tuya-panel": "^0.4.2",
44
53
  "husky": "^1.2.0",
45
54
  "lint-staged": "^10.2.11",
46
55
  "standard-version": "9.3.2"
47
56
  },
48
57
  "resolutions": {
49
- "follow-redirects": "1.15.6",
50
- "shell-quote": "1.7.3",
51
- "@babel/traverse": "7.23.2",
52
- "decode-uri-component": "0.2.1"
58
+ "@ray-js/builder-mp": "1.6.2"
53
59
  },
54
60
  "husky": {
55
61
  "hooks": {
56
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js"
62
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
63
+ "pre-commit": "lint-staged"
57
64
  }
58
65
  },
59
66
  "lint-staged": {
@@ -65,11 +72,5 @@
65
72
  "prettier --write",
66
73
  "git add"
67
74
  ]
68
- },
69
- "maintainers": [
70
- {
71
- "name": "tuyafe",
72
- "email": "tuyafe@tuya.com"
73
- }
74
- ]
75
+ }
75
76
  }
package/README-zh_CN.md DELETED
@@ -1,209 +0,0 @@
1
- [English](./README.md) | 简体中文
2
-
3
- # ray-ipc-player
4
-
5
- 针对 ipc-player 基础能力进行封装,包含 loading、设备异常、离线等提示
6
-
7
- ### 属性
8
-
9
- ```ts
10
- export type IProps = {
11
- /**
12
- * @description.en devId
13
- * @description.zh 设备id
14
- * @default ""
15
- */
16
- devId: string;
17
- /**
18
- * @description.en onlineStatus
19
- * @description.zh 设备是否在线
20
- * @default true
21
- */
22
- onlineStatus: boolean;
23
- /**
24
- * @description.en privateState
25
- * @description.zh 隐私模式
26
- * @default false
27
- */
28
- privateState?: boolean;
29
- /**
30
- * @description.en defaultMute
31
- * @description.zh 默认静音
32
- * @default true
33
- */
34
- defaultMute?: boolean;
35
- /**
36
- * @description.en clarity
37
- * @description.zh 清晰度 normal:标清,hd:高清
38
- * @default "normal"
39
- */
40
- clarity?: 'normal' | 'hd';
41
- /**
42
- * @description.en updateLayout
43
- * @description.zh 外层父节点样式变化,播放器监听不到,需要主动触发播放器视图更新,每次需要设置不同的字符串值
44
- * @default ""
45
- */
46
- updateLayout?: any;
47
- /**
48
- * @description.en onChangeStreamStatus
49
- * @description.zh 通知视频流状态发生变化
50
- * @default (data) => void
51
- */
52
- onChangeStreamStatus?: (data) => void;
53
- /**
54
- * @description.en onCtx
55
- * @description.zh 获取ipcPlayer实例ctx以及重试方法retry
56
- * @default (playerRef) => void
57
- */
58
- onCtx?: (playerRef) => void;
59
- /**
60
- * @description.en onInitPreview
61
- * @description.zh 初始化预览成功通知
62
- * @default (devId) => void
63
- */
64
- onInitPreview?: (data) => void;
65
- /**
66
- * @description.en onPlayerTap
67
- * @description.zh 播放器区域点击事件
68
- * @default (devId) => void
69
- */
70
- onPlayerTap?: (data) => void;
71
- /**
72
- * @description.en scalable
73
- * @description.zh 是否可缩放
74
- * @default true
75
- */
76
- scalable?: boolean;
77
- /**
78
- * @description.en scaleMultiple
79
- * @description.zh 缩放比例
80
- * @default 0
81
- */
82
- scaleMultiple?: number;
83
- /**
84
- * @description.en rotateZ
85
- * @description.zh 摄像头旋转角度
86
- * @default 0
87
- */
88
- rotateZ?: number;
89
- /**
90
- * @description.en ptzControllable
91
- * @description.zh 是否开启视频区云平台控制
92
- * @default true
93
- */
94
- ptzControllable?: boolean;
95
- /**
96
- * @description.en playerStyle
97
- * @description.zh 播放器样式
98
- * @default {}
99
- */
100
- playerStyle?: {
101
- bgColor?: string; // 背景底色
102
- borderRadius?: number | string; // 边框圆角
103
- borderStyle?: 'solid' | 'dashed'; // 边框样式
104
- borderColor?: string; // 边框颜色
105
- borderWidth?: string | number; // 边框宽度
106
- };
107
- /**
108
- * @description.en loadText
109
- * @description.zh 加载过程中的文案,可结合onChangeStreamStatus事件做文案配置
110
- * @default "正在获取视频流..."
111
- */
112
- loadText?: string;
113
- /**
114
- * @description.en objectFit:contain|fillCrop
115
- * @description.zh 填充模式设置:contain: 图像长边填满屏幕,短边区域会被填充⿊⾊, fillCrop: 图像铺满屏幕
116
- * @default "contain"
117
- */
118
- objectFit?: string;
119
- /**
120
- * @description.en extend
121
- * @description.zh 扩展属性
122
- * @default {}
123
- */
124
- extend?: Record<string, any>;
125
- };
126
- ```
127
-
128
- #### onChangeStreamStatus 说明
129
-
130
- 主要暴露出拉流过程中的一些状态事件:
131
-
132
- - -1000: 未知异常
133
-
134
- - 1001: connect 连接成功
135
-
136
- - -1001: connect 连接失败
137
-
138
- - 1002: preview 成功
139
-
140
- - -1002: preview 失败
141
-
142
- - -1010: 网络状态不可用
143
-
144
- - -1012: 设备被移除
145
-
146
- - 1009: disconnect 成功
147
-
148
- - -1009: disconnect 失败
149
-
150
- ### 用法
151
-
152
- ```tsx
153
- import React, { useState, useCallback } from 'react';
154
- import Player from '@ray-js/ray-ipc-player';
155
- import { Button, View } from '@ray-js/components';
156
-
157
- const PlayerDemo = () => {
158
- const [updateLayout, setUpdateLayout] = useState('');
159
- const [state, setState] = useState({}); // player实例
160
- const [playerWidth, setPlayerWidth] = useState('200px'); // player宽度
161
- /** onCtx用法
162
- * playerCtx.ctx: 拿到的是通过createIpcPlayerContext创建的ipc-player实例,包含预览、清晰度、静音、录像、截图等方法
163
- * playerCtx.retry: 暴露出的重试方法
164
- */
165
- const onCtx = playerCtx => {
166
- setState(playerCtx);
167
- };
168
-
169
- // 切换清晰度
170
- const handleClarity = useCallback(() => {
171
- if (previewStatus) {
172
- state.ctx.setClarity({
173
- clarity: 'hd',
174
- success: res => {
175
- console.log('切换清晰度成功:', res);
176
- },
177
- fail: e => {
178
- console.log('切换清晰度失败:', e);
179
- },
180
- });
181
- }
182
- }, [previewStatus]);
183
-
184
- const handleChangeWidth = () => {
185
- setPlayerWidth(playerWidth);
186
- // 更新外层父节点宽度样式时,同步通知更新播放器视图
187
- setUpdateLayout(Math.random().toString());
188
- };
189
-
190
- return (
191
- <View style={{ width: playerWidth }}>
192
- <Player
193
- devId={devId}
194
- onlineStatus={true}
195
- onCtx={onCtx}
196
- updateLayout={updateLayout}
197
- extend={{
198
- soundMode: 'speaker',
199
- orientation: 'vertical',
200
- }}
201
- />
202
- <Button onClick={() => handleClarity}>切换清晰度</Button>
203
- <Button onClick={() => handleChangeWidth}>更新宽度</Button>
204
- </View>
205
- );
206
- };
207
-
208
- export default PlayerDemo;
209
- ```