@ray-js/adapter 1.7.79 → 1.7.81

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 (94) hide show
  1. package/cjs/hostComponents/Camera/index.d.ts +105 -10
  2. package/cjs/hostComponents/Camera/index.js +16 -1
  3. package/cjs/hostComponents/Canvas/index.d.ts +197 -15
  4. package/cjs/hostComponents/Canvas/index.js +12 -1
  5. package/cjs/hostComponents/CoverView/index.d.ts +8 -1
  6. package/cjs/hostComponents/Iframe/index.d.ts +59 -19
  7. package/cjs/hostComponents/Iframe/index.js +8 -1
  8. package/cjs/hostComponents/Iframe/node.d.ts +1 -0
  9. package/cjs/hostComponents/Iframe/node.js +1 -1
  10. package/cjs/hostComponents/Input/index.d.ts +1 -1
  11. package/cjs/hostComponents/IpcPlayer/index.d.ts +297 -172
  12. package/cjs/hostComponents/IpcPlayer/index.js +26 -1
  13. package/cjs/hostComponents/Map/index.d.ts +202 -49
  14. package/cjs/hostComponents/Map/index.js +17 -1
  15. package/cjs/hostComponents/MovableArea/index.d.ts +18 -0
  16. package/cjs/hostComponents/MovableArea/index.js +10 -1
  17. package/cjs/hostComponents/MovableView/index.d.ts +92 -6
  18. package/cjs/hostComponents/MovableView/index.js +19 -3
  19. package/cjs/hostComponents/NativeVideo/index.d.ts +172 -14
  20. package/cjs/hostComponents/NativeVideo/index.js +24 -1
  21. package/cjs/hostComponents/Navigator/index.d.ts +126 -22
  22. package/cjs/hostComponents/Navigator/index.js +16 -4
  23. package/cjs/hostComponents/Picker/index.d.ts +98 -43
  24. package/cjs/hostComponents/Picker/index.js +19 -1
  25. package/cjs/hostComponents/PickerView/index.d.ts +64 -14
  26. package/cjs/hostComponents/PickerView/index.js +12 -1
  27. package/cjs/hostComponents/PickerViewColumn/index.d.ts +11 -1
  28. package/cjs/hostComponents/Progress/index.d.ts +39 -1
  29. package/cjs/hostComponents/Progress/index.js +19 -2
  30. package/cjs/hostComponents/RichText/index.d.ts +50 -7
  31. package/cjs/hostComponents/RichText/index.js +8 -1
  32. package/cjs/hostComponents/ScrollView/index.d.ts +190 -54
  33. package/cjs/hostComponents/ScrollView/index.js +26 -1
  34. package/cjs/hostComponents/Slider/node.d.ts +1 -0
  35. package/cjs/hostComponents/Slider/node.js +1 -1
  36. package/cjs/hostComponents/SvgRender/index.d.ts +16 -1
  37. package/cjs/hostComponents/SvgRender/index.js +13 -1
  38. package/cjs/hostComponents/Swiper/node.js +1 -1
  39. package/cjs/hostComponents/SwiperItem/index.d.ts +86 -1
  40. package/cjs/hostComponents/Video/index.d.ts +176 -28
  41. package/cjs/hostComponents/Video/index.js +41 -1
  42. package/cjs/hostComponents/WebView/index.d.ts +64 -14
  43. package/cjs/hostComponents/WebView/index.js +10 -1
  44. package/cjs/types/component.d.ts +15 -6
  45. package/cjs/types/index.d.ts +2 -2
  46. package/cjs/types/index.js +1 -1
  47. package/esm/hostComponents/Camera/index.d.ts +105 -10
  48. package/esm/hostComponents/Camera/index.js +15 -0
  49. package/esm/hostComponents/Canvas/index.d.ts +197 -15
  50. package/esm/hostComponents/Canvas/index.js +11 -0
  51. package/esm/hostComponents/CoverView/index.d.ts +8 -1
  52. package/esm/hostComponents/Iframe/index.d.ts +59 -19
  53. package/esm/hostComponents/Iframe/index.js +7 -0
  54. package/esm/hostComponents/Iframe/node.d.ts +1 -0
  55. package/esm/hostComponents/Iframe/node.js +1 -1
  56. package/esm/hostComponents/Input/index.d.ts +1 -1
  57. package/esm/hostComponents/IpcPlayer/index.d.ts +297 -172
  58. package/esm/hostComponents/IpcPlayer/index.js +25 -0
  59. package/esm/hostComponents/Map/index.d.ts +202 -49
  60. package/esm/hostComponents/Map/index.js +16 -0
  61. package/esm/hostComponents/MovableArea/index.d.ts +18 -0
  62. package/esm/hostComponents/MovableArea/index.js +9 -0
  63. package/esm/hostComponents/MovableView/index.d.ts +92 -6
  64. package/esm/hostComponents/MovableView/index.js +18 -2
  65. package/esm/hostComponents/NativeVideo/index.d.ts +172 -14
  66. package/esm/hostComponents/NativeVideo/index.js +23 -0
  67. package/esm/hostComponents/Navigator/index.d.ts +126 -22
  68. package/esm/hostComponents/Navigator/index.js +15 -3
  69. package/esm/hostComponents/Picker/index.d.ts +98 -43
  70. package/esm/hostComponents/Picker/index.js +18 -0
  71. package/esm/hostComponents/PickerView/index.d.ts +64 -14
  72. package/esm/hostComponents/PickerView/index.js +11 -0
  73. package/esm/hostComponents/PickerViewColumn/index.d.ts +11 -1
  74. package/esm/hostComponents/Progress/index.d.ts +39 -1
  75. package/esm/hostComponents/Progress/index.js +18 -1
  76. package/esm/hostComponents/RichText/index.d.ts +50 -7
  77. package/esm/hostComponents/RichText/index.js +7 -0
  78. package/esm/hostComponents/ScrollView/index.d.ts +190 -54
  79. package/esm/hostComponents/ScrollView/index.js +25 -0
  80. package/esm/hostComponents/Slider/node.d.ts +1 -0
  81. package/esm/hostComponents/Slider/node.js +1 -1
  82. package/esm/hostComponents/SvgRender/index.d.ts +16 -1
  83. package/esm/hostComponents/SvgRender/index.js +12 -0
  84. package/esm/hostComponents/Swiper/node.js +1 -1
  85. package/esm/hostComponents/SwiperItem/index.d.ts +86 -1
  86. package/esm/hostComponents/Video/index.d.ts +176 -28
  87. package/esm/hostComponents/Video/index.js +40 -0
  88. package/esm/hostComponents/WebView/index.d.ts +64 -14
  89. package/esm/hostComponents/WebView/index.js +9 -0
  90. package/esm/types/component.d.ts +15 -6
  91. package/esm/types/index.d.ts +2 -2
  92. package/esm/types/index.js +1 -1
  93. package/node.js +1 -1
  94. package/package.json +3 -3
@@ -1,5 +1,20 @@
1
1
  import createHostComponent from '../createHostComponent.js';
2
2
  export const Camera = createHostComponent('camera');
3
+ /**
4
+ * @belong Camera
5
+ * @defaults
6
+ */
7
+ export const cameraDefaultProps = {
8
+ mode: 'normal',
9
+ resolution: 'medium',
10
+ devicePosition: 'back',
11
+ flash: 'auto',
12
+ borderWidth: 0,
13
+ borderStyle: 'solid',
14
+ borderColor: '#ffffff',
15
+ borderRadius: 0,
16
+ backgroundColor: '#ffffff',
17
+ };
3
18
  Camera.defaultProps = {
4
19
  mode: 'normal',
5
20
  resolution: 'medium',
@@ -1,19 +1,201 @@
1
1
  import * as React from 'react';
2
- import { GenericEvent } from '../../types/index.js';
3
- export interface CanvasProps {
4
- readonly dataset?: DOMStringMap;
5
- id?: string;
6
- style?: React.CSSProperties;
7
- className?: string;
8
- onTap?: (e: any) => void;
9
- type?: string;
2
+ import { BaseEvent, BaseProps, TouchEvent } from '../../types/component';
3
+ /** Canvas 触摸点信息(与标准 DOM Touch 不同,仅包含 identifier/x/y) */
4
+ export interface CanvasTouchInfo {
5
+ /** 触摸点标识符 */
6
+ identifier: number;
7
+ /** 触摸点相对于 canvas 左上角的 x 坐标 */
8
+ x: number;
9
+ /** 触摸点相对于 canvas 左上角的 y 坐标 */
10
+ y: number;
11
+ }
12
+ /** Canvas 触摸事件类型 */
13
+ export type CanvasTouchEvent = TouchEvent<CanvasTouchInfo>;
14
+ /** canvas 错误事件详情 */
15
+ export interface CanvasErrorEventDetail {
16
+ /** 错误信息 */
17
+ errMsg: string;
18
+ }
19
+ /** canvas 错误事件对象 */
20
+ export interface CanvasErrorEvent extends BaseEvent {
21
+ /** 事件类型 */
22
+ type: 'error';
23
+ /** 事件详情 */
24
+ detail: CanvasErrorEventDetail;
25
+ }
26
+ /**
27
+ * 画布组件。
28
+ *
29
+ * @alias Canvas
30
+ * @since @ray-js/ray 0.5.10
31
+ * @example 使用 RJS 进行绘制(推荐)
32
+ * ```tsx
33
+ * // index.tsx
34
+ * import React, { useRef, useEffect } from 'react';
35
+ * import { Canvas, View, Text, usePageEvent } from '@ray-js/ray';
36
+ * import Render from './render.rjs';
37
+ *
38
+ * export default function () {
39
+ * const canvasRef = useRef(null);
40
+ *
41
+ * usePageEvent('onShow', () => {
42
+ * if (canvasRef.current) {
43
+ * const canvas = canvasRef.current;
44
+ * const render = new Render(canvas, canvas.width, canvas.height);
45
+ * render.start();
46
+ * }
47
+ * });
48
+ *
49
+ * return (
50
+ * <View style={{ padding: '20px' }}>
51
+ * <Text style={{ marginBottom: '10px', fontSize: '16px' }}>Canvas RJS 绘制示例</Text>
52
+ * <Canvas
53
+ * ref={canvasRef}
54
+ * type="2d"
55
+ * canvasId="rjsCanvas"
56
+ * style={{ width: '100%', height: '300px', backgroundColor: '#f5f5f5' }}
57
+ * />
58
+ * </View>
59
+ * );
60
+ * }
61
+ * ```
62
+ * ```javascript
63
+ * // render.rjs
64
+ * export default class Render {
65
+ * constructor(canvas, width, height) {
66
+ * this.canvas = canvas;
67
+ * this.width = width;
68
+ * this.height = height;
69
+ * this.ctx = canvas.getContext('2d');
70
+ * }
71
+ *
72
+ * start() {
73
+ * this.drawBackground();
74
+ * this.drawCircle();
75
+ * this.drawRect();
76
+ * this.drawText();
77
+ * }
78
+ *
79
+ * drawBackground() {
80
+ * this.ctx.fillStyle = '#ffffff';
81
+ * this.ctx.fillRect(0, 0, this.width, this.height);
82
+ * }
83
+ *
84
+ * drawCircle() {
85
+ * this.ctx.beginPath();
86
+ * this.ctx.arc(100, 100, 50, 0, 2 * Math.PI);
87
+ * this.ctx.fillStyle = '#ff6b6b';
88
+ * this.ctx.fill();
89
+ * this.ctx.strokeStyle = '#c92a2a';
90
+ * this.ctx.lineWidth = 3;
91
+ * this.ctx.stroke();
92
+ * }
93
+ *
94
+ * drawRect() {
95
+ * this.ctx.fillStyle = '#4dabf7';
96
+ * this.ctx.fillRect(200, 50, 100, 100);
97
+ * this.ctx.strokeStyle = '#1971c2';
98
+ * this.ctx.lineWidth = 3;
99
+ * this.ctx.strokeRect(200, 50, 100, 100);
100
+ * }
101
+ *
102
+ * drawText() {
103
+ * this.ctx.font = '20px sans-serif';
104
+ * this.ctx.fillStyle = '#333';
105
+ * this.ctx.fillText('RJS Canvas', 120, 200);
106
+ * }
107
+ * }
108
+ * ```
109
+ * @example 使用 createCanvasContext API 绘制
110
+ * ```tsx | sandbox previewTitle="使用 API 绘制" ide
111
+ * import React, { useEffect } from 'react';
112
+ * import { Canvas, View, Button, createCanvasContext } from '@ray-js/ray';
113
+ *
114
+ * export default function () {
115
+ * const drawSmile = () => {
116
+ * const context = createCanvasContext('apiCanvas');
117
+ * context.setStrokeStyle('#ff0000');
118
+ * context.setLineWidth(2);
119
+ * context.arc(100, 100, 60, 0, 2 * Math.PI, true);
120
+ * context.stroke();
121
+ * context.beginPath();
122
+ * context.arc(100, 100, 40, 0, Math.PI, false);
123
+ * context.stroke();
124
+ * context.beginPath();
125
+ * context.arc(80, 80, 5, 0, 2 * Math.PI, true);
126
+ * context.fill();
127
+ * context.beginPath();
128
+ * context.arc(120, 80, 5, 0, 2 * Math.PI, true);
129
+ * context.fill();
130
+ * context.draw();
131
+ * };
132
+ *
133
+ * const drawRect = () => {
134
+ * const context = createCanvasContext('apiCanvas');
135
+ * context.setFillStyle('rgb(200, 0, 0)');
136
+ * context.fillRect(10, 10, 55, 50);
137
+ * context.setFillStyle('rgba(0, 0, 200, 0.5)');
138
+ * context.fillRect(30, 30, 55, 50);
139
+ * context.draw();
140
+ * };
141
+ *
142
+ * const clearCanvas = () => {
143
+ * const context = createCanvasContext('apiCanvas');
144
+ * context.clearRect(0, 0, 300, 200);
145
+ * context.draw();
146
+ * };
147
+ *
148
+ * useEffect(() => {
149
+ * drawSmile();
150
+ * }, []);
151
+ *
152
+ * return (
153
+ * <View style={{ padding: '20px' }}>
154
+ * <Canvas
155
+ * canvasId="apiCanvas"
156
+ * type="2d"
157
+ * style={{ width: '100%', height: '200px', border: '1px solid #eee' }}
158
+ * onTouchStart={(e) => console.log('触摸开始:', e.touches[0]?.x, e.touches[0]?.y)}
159
+ * />
160
+ * <View style={{ marginTop: '10px', display: 'flex', flexDirection: 'row', gap: '8px', flexWrap: 'wrap' }}>
161
+ * <Button size="mini" onClick={drawSmile}>绘制笑脸</Button>
162
+ * <Button size="mini" onClick={drawRect}>绘制矩形</Button>
163
+ * <Button size="mini" onClick={clearCanvas}>清空画布</Button>
164
+ * </View>
165
+ * </View>
166
+ * );
167
+ * }
168
+ * ```
169
+ */
170
+ export interface CanvasProps extends Omit<BaseProps, 'onTouchStart' | 'onTouchMove' | 'onTouchEnd' | 'onTouchCancel' | 'onLongTap'> {
171
+ /** 指定 canvas 类型,有效值为 2d、webgl */
172
+ type?: '2d' | 'webgl' | string;
173
+ /** canvas 组件的唯一标识符;若指定了 type 为 2d/webgl 可不再指定 */
10
174
  canvasId?: string;
11
- disableScroll?: string;
12
- onTouchStart?: (event: GenericEvent) => void;
13
- onTouchMove?: (event: GenericEvent) => void;
14
- onTouchEnd?: (event: GenericEvent) => void;
15
- onTouchCancel?: (event: GenericEvent) => void;
16
- onLongTap?: (event: GenericEvent) => void;
17
- onError?: (event: GenericEvent) => void;
175
+ /** 在 canvas 中移动且绑定了手势事件时,是否禁止页面滚动与下拉刷新 */
176
+ disableScroll?: boolean;
177
+ /** 手指触摸动作开始 */
178
+ onTouchStart?: (event: CanvasTouchEvent) => void;
179
+ /** 手指触摸后移动 */
180
+ onTouchMove?: (event: CanvasTouchEvent) => void;
181
+ /** 手指触摸动作结束 */
182
+ onTouchEnd?: (event: CanvasTouchEvent) => void;
183
+ /** 手指触摸动作被打断,如来电提醒、弹窗 */
184
+ onTouchCancel?: (event: CanvasTouchEvent) => void;
185
+ /** 手指长按约 500ms 后触发;触发后移动不会引起页面滚动 */
186
+ onLongTap?: (event: CanvasTouchEvent) => void;
187
+ /** 当发生错误时触发,detail 含 errMsg */
188
+ onError?: (event: CanvasErrorEvent) => void;
18
189
  }
19
190
  export declare const Canvas: React.ComponentType<CanvasProps>;
191
+ /**
192
+ * Canvas 组件文档用默认值(与运行时 defaultProps 分离;当前运行时未设置 defaultProps)
193
+ *
194
+ * @belong Canvas
195
+ * @defaults
196
+ */
197
+ export declare const canvasDefaultProps: {
198
+ type: string;
199
+ canvasId: string;
200
+ disableScroll: boolean;
201
+ };
@@ -1,2 +1,13 @@
1
1
  import createHostComponent from '../createHostComponent.js';
2
2
  export const Canvas = createHostComponent('canvas');
3
+ /**
4
+ * Canvas 组件文档用默认值(与运行时 defaultProps 分离;当前运行时未设置 defaultProps)
5
+ *
6
+ * @belong Canvas
7
+ * @defaults
8
+ */
9
+ export const canvasDefaultProps = {
10
+ type: '2d',
11
+ canvasId: '',
12
+ disableScroll: false,
13
+ };
@@ -1,6 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { BaseProps } from '../../types/component.js';
3
+ /**
4
+ * 覆盖在原生组件之上的视图容器,可覆盖 Map、Video 等原生组件。
5
+ *
6
+ * @public
7
+ * @alias CoverView
8
+ * @since @ray-js/ray 0.5.10
9
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
10
+ */
3
11
  export interface CoverViewProps extends BaseProps {
4
- children?: any;
5
12
  }
6
13
  export declare const CoverView: React.ComponentType<CoverViewProps>;
@@ -1,25 +1,65 @@
1
1
  import * as React from 'react';
2
- import { BaseProps, DiffLayer, GenericEvent } from '../../types/component.js';
2
+ import type { BaseEvent, BaseProps, DiffLayer } from '../../types/component';
3
+ /** iframe 网页加载失败事件数据 */
4
+ export interface IframeErrorDetail {
5
+ /** 加载失败的地址 */
6
+ url: string;
7
+ /** 加载失败时的完整 URL */
8
+ fullUrl: string;
9
+ }
10
+ /** 网页加载失败时触发 */
11
+ export interface IframeErrorEvent extends BaseEvent {
12
+ /** 事件类型 */
13
+ type: 'error';
14
+ /** 事件数据 */
15
+ detail: IframeErrorDetail;
16
+ }
17
+ /** iframe 网页加载成功事件数据 */
18
+ export interface IframeLoadDetail {
19
+ /** 已加载网页地址 */
20
+ src: string;
21
+ }
22
+ /** 网页加载成功时触发 */
23
+ export interface IframeLoadEvent extends BaseEvent {
24
+ /** 事件类型 */
25
+ type: 'load';
26
+ /** 事件数据 */
27
+ detail: IframeLoadDetail;
28
+ }
29
+ /** iframe 网页向小程序 postMessage 事件数据 */
30
+ export interface IframeMessageDetail {
31
+ /** 多次 `postMessage` 入参组成的数组 */
32
+ data: unknown[];
33
+ }
34
+ /** 在特定时机收到网页 `postMessage` 时触发 */
35
+ export interface IframeMessageEvent extends BaseEvent {
36
+ /** 事件类型 */
37
+ type: 'message';
38
+ /** 事件数据 */
39
+ detail: IframeMessageDetail;
40
+ }
41
+ /**
42
+ * 内嵌网页(iframe)
43
+ *
44
+ * @internal
45
+ */
3
46
  export interface IframeProps extends BaseProps, DiffLayer {
4
- /**
5
- * webview 指向网页的链接,网页需登录小程序管理后台配置业务域名。
6
- */
47
+ /** 网页链接(需在小程序后台配置业务域名) */
7
48
  src?: string;
8
- /**
9
- * 是否向 iframe 中注入 TTT SDK
10
- */
49
+ /** 是否向 iframe 中注入 TTT SDK */
11
50
  injectTTT?: boolean;
12
- /**
13
- * 网页加载失败的时候触发此事件。e.detail = { url, fullUrl },其中 fullUrl 为加载失败时的完整 url
14
- */
15
- onError?: (event: GenericEvent) => any;
16
- /**
17
- * 网页加载成功时候触发此事件。e.detail = { src }
18
- */
19
- onLoad?: (event: GenericEvent) => any;
20
- /**
21
- * 网页向小程序 postMessage 时,会在特定时机(小程序后退、组件销毁、分享)触发并收到消息。e.detail = { data },data是多次 postMessage 的参数组成的数组
22
- */
23
- onMessage?: (event: GenericEvent) => any;
51
+ /** 网页加载失败时触发 */
52
+ onError?: (event: IframeErrorEvent) => void;
53
+ /** 网页加载成功时触发 */
54
+ onLoad?: (event: IframeLoadEvent) => void;
55
+ /** 网页向小程序 postMessage 时,在特定时机触发并收到消息 */
56
+ onMessage?: (event: IframeMessageEvent) => void;
24
57
  }
25
58
  export declare const Iframe: React.ComponentType<IframeProps>;
59
+ /**
60
+ * Iframe 组件默认值
61
+ *
62
+ * @belong Iframe
63
+ * @defaults
64
+ */
65
+ export declare const iframeDefaultProps: {};
@@ -1,3 +1,10 @@
1
1
  import createHostComponent from '../createHostComponent.js';
2
2
  export const Iframe = createHostComponent('iframe');
3
+ /**
4
+ * Iframe 组件默认值
5
+ *
6
+ * @belong Iframe
7
+ * @defaults
8
+ */
9
+ export const iframeDefaultProps = {};
3
10
  Iframe.defaultProps = {};
@@ -1,6 +1,7 @@
1
1
  export declare const alias: {
2
2
  src: string;
3
3
  injectTTT: string;
4
+ updateLayout: string;
4
5
  onError: string;
5
6
  onLoad: string;
6
7
  onMessage: string;
@@ -1,3 +1,3 @@
1
1
  import { universalAlias } from '../universal.js';
2
- export const alias = Object.assign(Object.assign({}, universalAlias), { src: 'src', injectTTT: 'inject-ttt', onError: 'bind:error', onLoad: 'bind:load', onMessage: 'bind:message' });
2
+ export const alias = Object.assign(Object.assign({}, universalAlias), { src: 'src', injectTTT: 'inject-ttt', updateLayout: 'update-layout', onError: 'bind:error', onLoad: 'bind:load', onMessage: 'bind:message' });
3
3
  export const props = Object.values(alias);
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { BaseProps, GenericEvent } from '../../types/component.js';
3
3
  export interface InputProps extends BaseProps {
4
4
  value?: string;
5
- type?: 'text' | 'number';
5
+ type?: 'text' | 'number' | 'digit';
6
6
  password?: boolean;
7
7
  placeholder?: string;
8
8
  placeholderStyle?: string;