@lynx-js/types 0.0.1 → 3.2.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 +55 -0
- package/README.md +56 -0
- package/package.json +53 -6
- package/types/background-thread/animation.d.ts +47 -0
- package/types/background-thread/app.d.ts +28 -0
- package/types/background-thread/event.d.ts +97 -0
- package/types/background-thread/fetch.d.ts +152 -0
- package/types/background-thread/index.d.ts +11 -0
- package/types/background-thread/lynx-performance-entry.d.ts +83 -0
- package/types/background-thread/lynx.d.ts +144 -0
- package/types/background-thread/native-modules.d.ts +21 -0
- package/types/background-thread/nodes-ref.d.ts +110 -0
- package/types/background-thread/performance.d.ts +100 -0
- package/types/common/console.d.ts +14 -0
- package/types/common/csstype.d.ts +99 -0
- package/types/common/element/attributes.d.ts +59 -0
- package/types/common/element/common.d.ts +41 -0
- package/types/common/element/component.d.ts +17 -0
- package/types/common/element/element.d.ts +59 -0
- package/types/common/element/filter-image.d.ts +67 -0
- package/types/common/element/image.d.ts +121 -0
- package/types/common/element/index.d.ts +16 -0
- package/types/common/element/list.d.ts +1161 -0
- package/types/common/element/methods.d.ts +84 -0
- package/types/common/element/page.d.ts +10 -0
- package/types/common/element/scroll-view.d.ts +280 -0
- package/types/common/element/text.d.ts +97 -0
- package/types/common/element/view.d.ts +7 -0
- package/types/common/events.d.ts +448 -0
- package/types/common/global.d.ts +47 -0
- package/types/common/index.d.ts +13 -0
- package/types/common/lynx.d.ts +35 -0
- package/types/common/performance.d.ts +78 -0
- package/types/common/props.d.ts +119 -0
- package/types/common/system-info.d.ts +46 -0
- package/types/index.d.ts +8 -0
- package/types/main-thread/element.d.ts +85 -0
- package/types/main-thread/events.d.ts +20 -0
- package/types/main-thread/index.d.ts +7 -0
- package/types/main-thread/lynx.d.ts +28 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { Element as MainThreadElement } from '../main-thread/element';
|
|
6
|
+
|
|
7
|
+
export interface Target {
|
|
8
|
+
/** The id selector of the event target. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** The unique identifier of the event target. */
|
|
11
|
+
uid: number;
|
|
12
|
+
/** The collection of custom attributes starting with data- on the event target. */
|
|
13
|
+
dataset: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BaseEventOrig<T, TargetType = Target> {
|
|
19
|
+
/** Event type. */
|
|
20
|
+
type: string;
|
|
21
|
+
|
|
22
|
+
/** Timestamp when the event was generated. */
|
|
23
|
+
timestamp: number;
|
|
24
|
+
|
|
25
|
+
/** Collection of attribute values of the target that triggers the event. */
|
|
26
|
+
target: TargetType;
|
|
27
|
+
|
|
28
|
+
/** Collection of attribute values of the target that listens to the event. */
|
|
29
|
+
currentTarget: TargetType;
|
|
30
|
+
|
|
31
|
+
/** Additional information. */
|
|
32
|
+
detail: T;
|
|
33
|
+
|
|
34
|
+
/** Preventing elements from performing default behavior. */
|
|
35
|
+
preventDefault: () => void;
|
|
36
|
+
|
|
37
|
+
/** Prevent the event from bubbling up to the parent element, preventing any parent event handlers from being executed. */
|
|
38
|
+
stopPropagation: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Touch {
|
|
42
|
+
/** The unique identifier of the finger touching the screen. */
|
|
43
|
+
identifier: number;
|
|
44
|
+
/** The current position of the touch point relative to the touched element's x-coordinate. */
|
|
45
|
+
x: number;
|
|
46
|
+
/** The current position of the touch point relative to the touched element's y-coordinate. */
|
|
47
|
+
y: number;
|
|
48
|
+
/** The current position of the touch point relative to the page's x-coordinate. */
|
|
49
|
+
pageX: number;
|
|
50
|
+
/** The current position of the touch point relative to the page's y-coordinate. */
|
|
51
|
+
pageY: number;
|
|
52
|
+
/** The current position of the touch point relative to the display area's x-coordinate. */
|
|
53
|
+
clientX: number;
|
|
54
|
+
/** The current position of the touch point relative to the display area's y-coordinate. */
|
|
55
|
+
clientY: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ChangedTouch {
|
|
59
|
+
identifier: number;
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface BaseCommonEvent<T> extends BaseEventOrig<any, T> {}
|
|
65
|
+
export interface CommonEvent extends BaseCommonEvent<Target | MainThreadElement> {}
|
|
66
|
+
|
|
67
|
+
export interface AppearanceEvent {
|
|
68
|
+
type: 'nodeappear' | 'nodedisappear';
|
|
69
|
+
detail: {
|
|
70
|
+
position: number;
|
|
71
|
+
key: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface BaseTouchEvent<T> extends BaseEventOrig<any, T> {
|
|
76
|
+
/** The touch points currently on the touch plane. */
|
|
77
|
+
touches: Array<Touch>;
|
|
78
|
+
|
|
79
|
+
/** The touch points whose state has changed compared to the last touch event. */
|
|
80
|
+
changedTouches: Array<Touch>;
|
|
81
|
+
|
|
82
|
+
detail: {
|
|
83
|
+
/** The current position of the touch point relative to the touched element's x-coordinate. */
|
|
84
|
+
x: number;
|
|
85
|
+
/** The current position of the touch point relative to the touched element's y-coordinate. */
|
|
86
|
+
y: number;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface TouchEvent extends BaseTouchEvent<Target> {}
|
|
91
|
+
|
|
92
|
+
export interface BaseMouseEvent<T> extends BaseEventOrig<{}, T> {
|
|
93
|
+
/** The currently pressed mouse button, if multiple buttons are pressed simultaneously, is the last one pressed. */
|
|
94
|
+
button: number;
|
|
95
|
+
/** The current mouse button being pressed, if multiple buttons are simultaneously pressed, it is a bit field composed of all button codes. */
|
|
96
|
+
buttons: number;
|
|
97
|
+
/** clientX */
|
|
98
|
+
x: number;
|
|
99
|
+
/** clientY */
|
|
100
|
+
y: number;
|
|
101
|
+
/** The current position of the cursor relative to the page's x-coordinate. */
|
|
102
|
+
pageX: number;
|
|
103
|
+
/** The current position of the cursor relative to the page's y-coordinate. */
|
|
104
|
+
pageY: number;
|
|
105
|
+
/** The current position of the cursor relative to the element's x-coordinate. */
|
|
106
|
+
clientX: number;
|
|
107
|
+
/** The current position of the cursor relative to the element's y-coordinate. */
|
|
108
|
+
clientY: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface MouseEvent extends BaseMouseEvent<Target> {}
|
|
112
|
+
|
|
113
|
+
export interface BaseWheelEvent<T> extends BaseEventOrig<{}, T> {
|
|
114
|
+
/** clientX */
|
|
115
|
+
x: number;
|
|
116
|
+
/** clientY */
|
|
117
|
+
y: number;
|
|
118
|
+
/** The current position of the cursor relative to the page's x-coordinate. */
|
|
119
|
+
pageX: number;
|
|
120
|
+
/** The current position of the cursor relative to the page's y-coordinate. */
|
|
121
|
+
pageY: number;
|
|
122
|
+
/** The current position of the cursor relative to the element's x-coordinate. */
|
|
123
|
+
clientX: number;
|
|
124
|
+
/** The current position of the cursor relative to the element's y-coordinate. */
|
|
125
|
+
clientY: number;
|
|
126
|
+
/** The distance of x-axis scrolling on the mouse wheel. */
|
|
127
|
+
deltaX: number;
|
|
128
|
+
/** The distance of y-axis scrolling on the mouse wheel. */
|
|
129
|
+
deltaY: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface WheelEvent extends BaseWheelEvent<Target> {}
|
|
133
|
+
|
|
134
|
+
export interface BaseKeyEvent<T> extends BaseEventOrig<{}, T> {
|
|
135
|
+
/** Button Name. */
|
|
136
|
+
key: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface KeyEvent extends BaseKeyEvent<Target> {}
|
|
140
|
+
|
|
141
|
+
export interface BaseAnimationEvent<T> extends BaseEventOrig<{}, T> {
|
|
142
|
+
params: {
|
|
143
|
+
animation_type: 'keyframe-animation';
|
|
144
|
+
animation_name: string;
|
|
145
|
+
new_animator?: true;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface AnimationEvent extends BaseAnimationEvent<Target | MainThreadElement> {}
|
|
150
|
+
|
|
151
|
+
export interface BaseTransitionEvent<T> extends BaseEventOrig<{}, T> {
|
|
152
|
+
params:
|
|
153
|
+
| {
|
|
154
|
+
animation_type: 'transition-animation';
|
|
155
|
+
animation_name: 'width' | 'height' | 'left' | 'top' | 'right' | 'bottom' | 'background-color' | 'opacity';
|
|
156
|
+
new_animator: true;
|
|
157
|
+
}
|
|
158
|
+
| {
|
|
159
|
+
new_animator: undefined;
|
|
160
|
+
animation_name: undefined;
|
|
161
|
+
animation_type:
|
|
162
|
+
| 'transition-width'
|
|
163
|
+
| 'transition-height'
|
|
164
|
+
| 'transition-left'
|
|
165
|
+
| 'transition-top'
|
|
166
|
+
| 'transition-right'
|
|
167
|
+
| 'transition-bottom'
|
|
168
|
+
| 'transition-transform'
|
|
169
|
+
| 'transition-background-color'
|
|
170
|
+
| 'transition-opacity';
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface TransitionEvent extends BaseTransitionEvent<Target | MainThreadElement> {}
|
|
174
|
+
|
|
175
|
+
export interface ImageLoadEvent {
|
|
176
|
+
detail: {
|
|
177
|
+
width: number;
|
|
178
|
+
height: number;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface ImageErrorEvent {
|
|
183
|
+
detail: {
|
|
184
|
+
errMsg: string;
|
|
185
|
+
error_code: number;
|
|
186
|
+
lynx_categorized_code: number;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface TextLineInfo {
|
|
191
|
+
start: number;
|
|
192
|
+
end: number;
|
|
193
|
+
ellipsisCount: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface TextLayoutEventDetail {
|
|
197
|
+
lineCount: number;
|
|
198
|
+
lines: TextLineInfo[];
|
|
199
|
+
size: {
|
|
200
|
+
width: number;
|
|
201
|
+
height: number;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface AccessibilityActionDetailEvent<T> extends BaseEventOrig<{}, T> {
|
|
206
|
+
detail: {
|
|
207
|
+
/**
|
|
208
|
+
* The name of the custom action.
|
|
209
|
+
* @Android
|
|
210
|
+
* @iOS
|
|
211
|
+
* @spec {@link https://developer.apple.com/documentation/appkit/nsaccessibility/2869551-accessibilitycustomactions/ | iOS}
|
|
212
|
+
* @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#addAction(androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat) | Android}
|
|
213
|
+
*/
|
|
214
|
+
name: string;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface LayoutChangeDetailEvent<T> extends BaseEventOrig<{}, T> {
|
|
219
|
+
type: 'layoutchange';
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Use 'detail' field instead.
|
|
222
|
+
* This field is only available on the Android platform.
|
|
223
|
+
* */
|
|
224
|
+
params: {
|
|
225
|
+
width: number;
|
|
226
|
+
height: number;
|
|
227
|
+
left: number;
|
|
228
|
+
top: number;
|
|
229
|
+
right: number;
|
|
230
|
+
bottom: number;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* This field is available on other platforms.
|
|
235
|
+
* */
|
|
236
|
+
detail: {
|
|
237
|
+
/** The id selector of the target. */
|
|
238
|
+
id: string;
|
|
239
|
+
/** The width of the target. */
|
|
240
|
+
width: number;
|
|
241
|
+
/** The height of the target. */
|
|
242
|
+
height: number;
|
|
243
|
+
/** The position of the target's top border relative to the page's coordinate. */
|
|
244
|
+
top: number;
|
|
245
|
+
/** The position of the target's right border relative to the page's coordinate. */
|
|
246
|
+
right: number;
|
|
247
|
+
/** The position of the target's bottom border relative to the page's coordinate. */
|
|
248
|
+
bottom: number;
|
|
249
|
+
/** The position of the target's left border relative to the page's coordinate. */
|
|
250
|
+
left: number;
|
|
251
|
+
/** The collection of custom attributes starting with data- on the event target. */
|
|
252
|
+
dataset: {
|
|
253
|
+
[key: string]: any;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface UIAppearanceDetailEvent<T> extends BaseEventOrig<{}, T> {
|
|
259
|
+
type: 'uiappear' | 'uidisappear';
|
|
260
|
+
detail: {
|
|
261
|
+
/** exposure-id set on the target. */
|
|
262
|
+
'exposure-id': string;
|
|
263
|
+
/** exposure-scene set on the target. */
|
|
264
|
+
'exposure-scene': string;
|
|
265
|
+
/** uid of the target */
|
|
266
|
+
'unique-id': string;
|
|
267
|
+
/** The collection of custom attributes starting with data- on the event target. */
|
|
268
|
+
dataset: {
|
|
269
|
+
[key: string]: any;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type Callback<T = any> = (res: T) => void;
|
|
275
|
+
|
|
276
|
+
export interface BaseMethod {
|
|
277
|
+
success?: Callback;
|
|
278
|
+
fail?: Callback;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface LepusEventInstance {
|
|
282
|
+
querySelector: (...params: any[]) => any;
|
|
283
|
+
querySelectorAll: (...params: any[]) => any;
|
|
284
|
+
requestAnimationFrame: (...params: any[]) => any;
|
|
285
|
+
cancelAnimationFrame: (...params: any[]) => any;
|
|
286
|
+
triggerEvent: (...params: any[]) => any;
|
|
287
|
+
getStore: (...params: any[]) => any;
|
|
288
|
+
setStore: (...params: any[]) => any;
|
|
289
|
+
getData: (...params: any[]) => any;
|
|
290
|
+
setData: (...params: any[]) => any;
|
|
291
|
+
getProperties: (...params: any[]) => any;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export type EventHandler<T> = (event: T, instance?: LepusEventInstance) => void;
|
|
295
|
+
|
|
296
|
+
export interface BaseEvent<T = string, D = any> {
|
|
297
|
+
/** Event type. */
|
|
298
|
+
type: T;
|
|
299
|
+
|
|
300
|
+
/** Timestamp when the event was generated. */
|
|
301
|
+
timestamp: number;
|
|
302
|
+
|
|
303
|
+
/** Collection of attribute values of the target that triggers the event. */
|
|
304
|
+
target: Target;
|
|
305
|
+
|
|
306
|
+
/** Collection of attribute values of the target that listens to the event. */
|
|
307
|
+
currentTarget: Target;
|
|
308
|
+
|
|
309
|
+
/** Additional information. */
|
|
310
|
+
detail: D;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface LynxEvent<Target> {
|
|
314
|
+
/**
|
|
315
|
+
* Listening for background image loading success.
|
|
316
|
+
* @since since Lynx 2.6
|
|
317
|
+
*/
|
|
318
|
+
BGLoad?: EventHandler<ImageLoadEvent>;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Failed to load background image for listening.
|
|
322
|
+
* @since since: Android: Lynx 2.6, iOS: Lynx 2.8
|
|
323
|
+
*/
|
|
324
|
+
BGError?: EventHandler<ImageErrorEvent>;
|
|
325
|
+
|
|
326
|
+
// NodeAppear?: EventHandler<ReactLynx.AppearanceEvent>;
|
|
327
|
+
|
|
328
|
+
// NodeDisappear?: EventHandler<ReactLynx.AppearanceEvent>;
|
|
329
|
+
|
|
330
|
+
/** Finger touch action begins. */
|
|
331
|
+
TouchStart?: EventHandler<BaseTouchEvent<Target>>;
|
|
332
|
+
|
|
333
|
+
/** Moving after touching with fingers. */
|
|
334
|
+
TouchMove?: EventHandler<BaseTouchEvent<Target>>;
|
|
335
|
+
|
|
336
|
+
/** Finger touch actions are interrupted by incoming call reminders and pop-up windows. */
|
|
337
|
+
TouchCancel?: EventHandler<BaseTouchEvent<Target>>;
|
|
338
|
+
|
|
339
|
+
/** Finger touch action ends. */
|
|
340
|
+
TouchEnd?: EventHandler<BaseTouchEvent<Target>>;
|
|
341
|
+
|
|
342
|
+
/** After touching the finger, if it leaves after more than 350ms and the event callback function is specified and triggered, the tap event will not be triggered. */
|
|
343
|
+
LongPress?: EventHandler<BaseCommonEvent<Target>>;
|
|
344
|
+
|
|
345
|
+
/** It will trigger during a transition animation start. */
|
|
346
|
+
TransitionStart?: EventHandler<BaseTransitionEvent<Target>>;
|
|
347
|
+
|
|
348
|
+
/** It will trigger when a transition animation is cancelled. */
|
|
349
|
+
TransitionCancel?: EventHandler<BaseTransitionEvent<Target>>;
|
|
350
|
+
|
|
351
|
+
/** It will trigger after the transition or createAnimation animation is finished. */
|
|
352
|
+
TransitionEnd?: EventHandler<BaseTransitionEvent<Target>>;
|
|
353
|
+
|
|
354
|
+
/** It will trigger at the beginning of an animation. */
|
|
355
|
+
AnimationStart?: EventHandler<BaseAnimationEvent<Target>>;
|
|
356
|
+
|
|
357
|
+
/** It will trigger during an animation iteration. */
|
|
358
|
+
AnimationIteration?: EventHandler<BaseAnimationEvent<Target>>;
|
|
359
|
+
|
|
360
|
+
/** It will trigger when an animation is cancelled. */
|
|
361
|
+
AnimationCancel?: EventHandler<BaseAnimationEvent<Target>>;
|
|
362
|
+
|
|
363
|
+
/** It will trigger upon completion of an animation. */
|
|
364
|
+
AnimationEnd?: EventHandler<BaseAnimationEvent<Target>>;
|
|
365
|
+
|
|
366
|
+
/** Mouse Clicked. */
|
|
367
|
+
MouseDown?: EventHandler<BaseMouseEvent<Target>>;
|
|
368
|
+
|
|
369
|
+
/** Mouse released. */
|
|
370
|
+
MouseUp?: EventHandler<BaseMouseEvent<Target>>;
|
|
371
|
+
|
|
372
|
+
/** Mouse movement. */
|
|
373
|
+
MouseMove?: EventHandler<BaseMouseEvent<Target>>;
|
|
374
|
+
|
|
375
|
+
/** Mouse click. */
|
|
376
|
+
MouseClick?: EventHandler<BaseMouseEvent<Target>>;
|
|
377
|
+
|
|
378
|
+
/** Double-click the mouse. */
|
|
379
|
+
MouseDblClick?: EventHandler<BaseMouseEvent<Target>>;
|
|
380
|
+
|
|
381
|
+
/** Long press on the mouse. */
|
|
382
|
+
MouseLongPress?: EventHandler<BaseMouseEvent<Target>>;
|
|
383
|
+
|
|
384
|
+
/** Mouse (or touchpad) scrolling. */
|
|
385
|
+
Wheel?: EventHandler<BaseWheelEvent<Target>>;
|
|
386
|
+
|
|
387
|
+
/** Keyboard (or remote control) button pressed. */
|
|
388
|
+
KeyDown?: EventHandler<BaseKeyEvent<Target>>;
|
|
389
|
+
|
|
390
|
+
/** Keyboard (or remote control) key released. */
|
|
391
|
+
KeyUp?: EventHandler<BaseKeyEvent<Target>>;
|
|
392
|
+
|
|
393
|
+
/** Element gets focus. */
|
|
394
|
+
Focus?: EventHandler<BaseCommonEvent<Target>>;
|
|
395
|
+
|
|
396
|
+
/** Element loses focus. */
|
|
397
|
+
Blur?: EventHandler<BaseCommonEvent<Target>>;
|
|
398
|
+
|
|
399
|
+
/** layout info Change event */
|
|
400
|
+
LayoutChange?: LayoutChangeEvent;
|
|
401
|
+
|
|
402
|
+
/** UI appear event */
|
|
403
|
+
UIAppear?: UIAppearanceEvent;
|
|
404
|
+
|
|
405
|
+
/** UI disappear event */
|
|
406
|
+
UIDisappear?: UIAppearanceEvent;
|
|
407
|
+
/**
|
|
408
|
+
* The text layout event is triggered when the text layout changes.
|
|
409
|
+
* @since since: Android: Lynx 2.6, iOS: Lynx 2.8
|
|
410
|
+
*/
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The custom actions of the current accessibility element is triggered.
|
|
414
|
+
* @Android
|
|
415
|
+
* @iOS
|
|
416
|
+
* @spec {@link https://developer.apple.com/documentation/appkit/nsaccessibility/2869551-accessibilitycustomactions/ | iOS}
|
|
417
|
+
* @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#addAction(androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat) | Android}
|
|
418
|
+
*/
|
|
419
|
+
AccessibilityAction?: EventHandler<AccessibilityActionDetailEvent<Target>>;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export type LayoutChangeEvent = EventHandler<LayoutChangeDetailEvent<Target>>;
|
|
423
|
+
|
|
424
|
+
export type UIAppearanceEvent = EventHandler<UIAppearanceDetailEvent<Target>>;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* This type is different with LynxEvent that they only have `bind` and `catch` event. But not `on` Event.
|
|
428
|
+
*/
|
|
429
|
+
export interface LynxBindCatchEvent<Target = any> {
|
|
430
|
+
/** Immediately lift your finger after touching. */
|
|
431
|
+
Tap?: EventHandler<BaseTouchEvent<Target>>;
|
|
432
|
+
|
|
433
|
+
/** After touching the finger, leave after more than 350ms (it is recommended to use the longpress event instead). */
|
|
434
|
+
LongTap?: EventHandler<BaseTouchEvent<Target>>;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export type LynxEventPropsBase<Target> = {
|
|
438
|
+
[K in keyof LynxEvent<Target> as Lowercase<`bind${K}` | `catch${K}` | `capture-bind${K}` | `capture-catch${K}` | `global-bind${K}`>]: LynxEvent<Target>[K];
|
|
439
|
+
} & {
|
|
440
|
+
[K in keyof LynxBindCatchEvent<Target> as Lowercase<`bind${K}` | `catch${K}` | `capture-bind${K}` | `capture-catch${K}` | `global-bind${K}`>]: LynxBindCatchEvent<Target>[K];
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export type LynxEventProps = LynxEventPropsBase<Target>;
|
|
444
|
+
|
|
445
|
+
export interface ITouchEvent extends BaseTouchEvent<Target> {}
|
|
446
|
+
export interface IMouseEvent extends BaseMouseEvent<Target> {}
|
|
447
|
+
export interface IWheelEvent extends BaseWheelEvent<Target> {}
|
|
448
|
+
export interface IKeyEvent extends BaseKeyEvent<Target> {}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { SystemInfo } from './system-info';
|
|
6
|
+
import { Lynx as BackgroundLynx, NativeModules as INativeModules, GetElementByIdFunc } from '../background-thread';
|
|
7
|
+
import { Lynx as MainThreadLynx } from '../main-thread';
|
|
8
|
+
import { CommonLynx } from './lynx';
|
|
9
|
+
|
|
10
|
+
export type LynxSetTimeout = (callback: (...args: unknown[]) => unknown, number: number) => number;
|
|
11
|
+
|
|
12
|
+
export type LynxClearTimeout = (timeoutId: number) => void;
|
|
13
|
+
|
|
14
|
+
export type AnyObject = Record<string, any>;
|
|
15
|
+
|
|
16
|
+
export interface GlobalProps {}
|
|
17
|
+
|
|
18
|
+
export type UnsafeLynx = BackgroundLynx & MainThreadLynx;
|
|
19
|
+
export type SafeLynx = CommonLynx;
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
var SystemInfo: SystemInfo;
|
|
23
|
+
var lynx: UnsafeLynx;
|
|
24
|
+
|
|
25
|
+
var getElementById: GetElementByIdFunc;
|
|
26
|
+
|
|
27
|
+
var NativeModules: INativeModules;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @description requestAnimationFrame
|
|
31
|
+
* @since 3.0
|
|
32
|
+
* below Lynx 3.0, use lynx.requestAnimationFrame.
|
|
33
|
+
*/
|
|
34
|
+
function requestAnimationFrame(cb?: (timeStamp?: number) => void): number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @description requestAnimationFrame
|
|
38
|
+
* @since 3.0
|
|
39
|
+
* below Lynx 3.0, use lynx.cancelAnimationFrame.
|
|
40
|
+
*/
|
|
41
|
+
function cancelAnimationFrame(requestID?: number): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function setTimeout(callback: (...args: unknown[]) => unknown, number: number): number;
|
|
45
|
+
declare function setInterval(callback: (...args: unknown[]) => unknown, number: number): number;
|
|
46
|
+
declare function clearTimeout(timeoutId: number): void;
|
|
47
|
+
declare function clearInterval(timeoutId: number): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
export * from './csstype';
|
|
6
|
+
export * from './events';
|
|
7
|
+
export * from './global';
|
|
8
|
+
export * from './props';
|
|
9
|
+
export * from './system-info';
|
|
10
|
+
export * from './element';
|
|
11
|
+
export * from './console';
|
|
12
|
+
export * from './lynx';
|
|
13
|
+
export * from './performance';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
export interface TextInfo {
|
|
6
|
+
fontSize: string;
|
|
7
|
+
fontFamily?: string;
|
|
8
|
+
maxWidth?: string;
|
|
9
|
+
maxLine?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TextMetrics {
|
|
13
|
+
width: number;
|
|
14
|
+
content?: Array<string>;
|
|
15
|
+
}
|
|
16
|
+
/*
|
|
17
|
+
*@description Common Lynx type
|
|
18
|
+
*/
|
|
19
|
+
export interface CommonLynx {
|
|
20
|
+
getTextInfo(text: string, info: TextInfo): TextMetrics;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @description proactively report error
|
|
24
|
+
* @param error errorInfo
|
|
25
|
+
* @param options level warning or error
|
|
26
|
+
* @since main-thread:3.0; background-thread:2.3;
|
|
27
|
+
*/
|
|
28
|
+
reportError(error: string | Error, options?: { level?: 'error' | 'warning' }): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @description get project's targetSdkVersion config.
|
|
32
|
+
* @since main-thread:3.0, background-thread: 2.6
|
|
33
|
+
*/
|
|
34
|
+
targetSdkVersion?: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Support from Lynx 3.0
|
|
7
|
+
*/
|
|
8
|
+
export interface TraceOption {
|
|
9
|
+
/**
|
|
10
|
+
* An optional unique identifier for tracing the event flow.
|
|
11
|
+
*/
|
|
12
|
+
flowId?: number;
|
|
13
|
+
/**
|
|
14
|
+
* An optional collection of key-value pairs providing additional context for the tracing event.
|
|
15
|
+
*/
|
|
16
|
+
args?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CommonPerformance {
|
|
20
|
+
/**
|
|
21
|
+
* Support from Lynx 3.0
|
|
22
|
+
*
|
|
23
|
+
* Start a performance tracing event.
|
|
24
|
+
*
|
|
25
|
+
* @param traceName - The name used to identify the tracing event.
|
|
26
|
+
* @param option - Optional parameters providing `flowId` and additional context.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* lynx.performance.profileStart("myEvent", { flowId: 123, args: { key: "value" } });
|
|
30
|
+
*/
|
|
31
|
+
profileStart: (traceName: string, option?: TraceOption) => void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Support from Lynx 3.0
|
|
35
|
+
*
|
|
36
|
+
* End a performance tracing event.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* lynx.performance.profileEnd();
|
|
40
|
+
*/
|
|
41
|
+
profileEnd: () => void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Support from Lynx 3.0
|
|
45
|
+
*
|
|
46
|
+
* Mark a instant trace event. Can connect with `ProfileStart` trace through `flowId`.
|
|
47
|
+
* @param traceName - The name used to identify the tracing mark.
|
|
48
|
+
* @param option - Optional parameters providing `flowId` and additional context.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* lynx.performance.profileMark("myMark", { args: { key: "value" }, flowId:123 });
|
|
52
|
+
*/
|
|
53
|
+
profileMark: (traceName: string, option?: TraceOption) => void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Support from Lynx 3.0
|
|
57
|
+
*
|
|
58
|
+
* Generate a unique flow identifier.
|
|
59
|
+
*
|
|
60
|
+
* @returns A unique numerical identifier for tracing event flows.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const flowId = lynx.performance.profileFlowId();
|
|
64
|
+
*/
|
|
65
|
+
profileFlowId: () => number;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Support from Lynx 2.18
|
|
69
|
+
*
|
|
70
|
+
* Check if the current device is recording trace data.
|
|
71
|
+
*
|
|
72
|
+
* @returns A boolean indicating whether the device is currently recording trace data.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const isRecording = lynx.performance.isProfileRecording();
|
|
76
|
+
*/
|
|
77
|
+
isProfileRecording: () => boolean;
|
|
78
|
+
}
|