@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.
Files changed (40) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +56 -0
  3. package/package.json +53 -6
  4. package/types/background-thread/animation.d.ts +47 -0
  5. package/types/background-thread/app.d.ts +28 -0
  6. package/types/background-thread/event.d.ts +97 -0
  7. package/types/background-thread/fetch.d.ts +152 -0
  8. package/types/background-thread/index.d.ts +11 -0
  9. package/types/background-thread/lynx-performance-entry.d.ts +83 -0
  10. package/types/background-thread/lynx.d.ts +144 -0
  11. package/types/background-thread/native-modules.d.ts +21 -0
  12. package/types/background-thread/nodes-ref.d.ts +110 -0
  13. package/types/background-thread/performance.d.ts +100 -0
  14. package/types/common/console.d.ts +14 -0
  15. package/types/common/csstype.d.ts +99 -0
  16. package/types/common/element/attributes.d.ts +59 -0
  17. package/types/common/element/common.d.ts +41 -0
  18. package/types/common/element/component.d.ts +17 -0
  19. package/types/common/element/element.d.ts +59 -0
  20. package/types/common/element/filter-image.d.ts +67 -0
  21. package/types/common/element/image.d.ts +121 -0
  22. package/types/common/element/index.d.ts +16 -0
  23. package/types/common/element/list.d.ts +1161 -0
  24. package/types/common/element/methods.d.ts +84 -0
  25. package/types/common/element/page.d.ts +10 -0
  26. package/types/common/element/scroll-view.d.ts +280 -0
  27. package/types/common/element/text.d.ts +97 -0
  28. package/types/common/element/view.d.ts +7 -0
  29. package/types/common/events.d.ts +448 -0
  30. package/types/common/global.d.ts +47 -0
  31. package/types/common/index.d.ts +13 -0
  32. package/types/common/lynx.d.ts +35 -0
  33. package/types/common/performance.d.ts +78 -0
  34. package/types/common/props.d.ts +119 -0
  35. package/types/common/system-info.d.ts +46 -0
  36. package/types/index.d.ts +8 -0
  37. package/types/main-thread/element.d.ts +85 -0
  38. package/types/main-thread/events.d.ts +20 -0
  39. package/types/main-thread/index.d.ts +7 -0
  40. package/types/main-thread/lynx.d.ts +28 -0
@@ -0,0 +1,84 @@
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 { BaseMethod, Callback } from '../events';
6
+ import { AutoScrollMethod, ScrollToPositionMethod } from './list';
7
+ import { ScrollToMethod } from './scroll-view';
8
+
9
+ export type ListParams = ScrollToPositionMethod;
10
+
11
+ export type ScrollViewParams = ScrollToMethod | AutoScrollMethod;
12
+
13
+ interface BoundingClientRectMethod extends BaseMethod {
14
+ method: 'boundingClientRect';
15
+ success?: Callback<{
16
+ /**
17
+ * Node ID.
18
+ */
19
+ id: string;
20
+
21
+ /**
22
+ * Dataset of nodes.
23
+ */
24
+ dataset: object;
25
+
26
+ /**
27
+ * Left boundary coordinate of the node (in pixels)
28
+ */
29
+ left: number;
30
+
31
+ /**
32
+ * The right boundary coordinates of the node.
33
+ */
34
+ right: number;
35
+
36
+ /**
37
+ * Upper boundary coordinate of the node.
38
+ */
39
+ top: number;
40
+
41
+ /**
42
+ * The lower boundary coordinates of the node
43
+ */
44
+ bottom: number;
45
+
46
+ /**
47
+ * Width of the node.
48
+ */
49
+ width: number;
50
+
51
+ /**
52
+ * height of the node.
53
+ */
54
+ height: number;
55
+ }>;
56
+ }
57
+
58
+ interface SetFocusMethod extends BaseMethod {
59
+ method: 'setFocus';
60
+ params: {
61
+ /** Set whether the element gains focus, `false` means the element loses focus.*/
62
+ focus: boolean;
63
+ /** Whether to scroll the element into the visible area at the same time, default is `true`.*/
64
+ scroll?: boolean;
65
+ };
66
+ }
67
+
68
+ interface IsAnimatingMethod extends BaseMethod {
69
+ method: 'isAnimating';
70
+ success?: Callback<{ data: boolean }>;
71
+ }
72
+
73
+ interface ScrollIntoViewMethod extends BaseMethod {
74
+ method: 'scrollIntoView';
75
+ params: {
76
+ scrollIntoViewOptions: {
77
+ block: 'start' | 'center' | 'end';
78
+ inline: 'start' | 'center' | 'end';
79
+ behavior?: 'smooth';
80
+ };
81
+ };
82
+ }
83
+
84
+ export type InvokeParams = ListParams | ScrollViewParams | BoundingClientRectMethod | SetFocusMethod | IsAnimatingMethod | ScrollIntoViewMethod;
@@ -0,0 +1,10 @@
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 { StandardProps } from '../props';
6
+
7
+ /**
8
+ * View container, used to hold other components.
9
+ */
10
+ export interface PageProps extends StandardProps {}
@@ -0,0 +1,280 @@
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 { BaseEvent, BaseMethod, EventHandler } from '../events';
6
+ import { StandardProps } from '../props';
7
+ import { AutoScrollMethod } from './list';
8
+ import {
9
+ ContentSizeChangedEvent,
10
+ ScrollEndEvent,
11
+ BaseScrollInfo,
12
+ ScrollEvent,
13
+ ScrollToNormalStateEvent,
14
+ ScrollToLowerEvent,
15
+ ScrollToUpperEvent,
16
+ ScrollToUpperEdgeEvent,
17
+ ScrollToLowerEdgeEvent,
18
+ } from './common';
19
+
20
+ export interface ScrollViewProps extends StandardProps {
21
+ /**
22
+ * Scroll horizontaly.
23
+ * @defaultValue false
24
+ * @since 1.4
25
+ * @iOS
26
+ * @Android
27
+ * @H
28
+ */
29
+ 'scroll-x'?: boolean;
30
+
31
+ /**
32
+ * Scroll vertically
33
+ * @defaultValue false
34
+ * @since 1.4
35
+ * @iOS
36
+ * @Android
37
+ * @H
38
+ */
39
+ 'scroll-y'?: boolean;
40
+
41
+ /**
42
+ * Replacement of scroll-x and scroll-y
43
+ * @since 3.0
44
+ * @iOS
45
+ * @Android
46
+ * @H
47
+ */
48
+ 'scroll-orientation'?: 'vertical' | 'horizontal';
49
+
50
+ /**
51
+ * Enable bounce effect
52
+ * @defaultValue false
53
+ * @since 1.4
54
+ * @iOS
55
+ * @Android
56
+ * @H
57
+ */
58
+ bounces?: boolean;
59
+
60
+ /**
61
+ * Enable dragging
62
+ * @defaultValue false
63
+ * @since 1.4
64
+ * @iOS
65
+ * @Android 2.2
66
+ * @H
67
+ */
68
+ 'enable-scroll'?: boolean;
69
+
70
+ /**
71
+ * Enable scrollbar
72
+ * @defaultValue false
73
+ * @since 1.4
74
+ * @iOS
75
+ * @Android
76
+ * @H
77
+ */
78
+ 'scroll-bar-enable'?: boolean;
79
+
80
+ /**
81
+ * Not recommended to use. Please use upper-threshold-item-count instead. Set upper threshold to bindscrolltoupper event.
82
+ * @defaultValue 0
83
+ * @since 1.4
84
+ * @iOS
85
+ * @Android
86
+ * @H
87
+ */
88
+ 'upper-threshold'?: number;
89
+
90
+ /**
91
+ * Not recommended to use. Please use lower-threshold-item-count instead. Set upper threshold to bindscrolltoupper event.
92
+ * @defaultValue 0
93
+ * @since 1.4
94
+ * @iOS
95
+ * @Android
96
+ * @H
97
+ */
98
+ 'lower-threshold'?: number;
99
+
100
+ /**
101
+ * Please use initial-scroll-offset or ScrollTo method. Set the content offset from the top.
102
+ * @defaultValue 0
103
+ * @since 1.4
104
+ * @deprecated 2.17
105
+ * @iOS
106
+ * @Android
107
+ * @H
108
+ */
109
+ 'scroll-top'?: number;
110
+
111
+ /**
112
+ * Please use initial-scroll-offset or ScrollTo method. Set the content offset from the left.
113
+ * @defaultValue 0
114
+ * @since 1.4
115
+ * @deprecated 2.17
116
+ * @iOS
117
+ * @Android
118
+ * @H
119
+ */
120
+ 'scroll-left'?: number;
121
+
122
+ /**
123
+ * Initial scroll position, only effective once
124
+ * @defaultValue 0
125
+ * @since 2.17
126
+ * @iOS
127
+ * @Android
128
+ * @H
129
+ */
130
+ 'initial-scroll-offset'?: number;
131
+
132
+ /**
133
+ * Please use initial-scroll-index or ScrollTo method。Set the first item at the first screen
134
+ * @defaultValue 0
135
+ * @since 2.1
136
+ * @deprecated 2.17
137
+ * @iOS
138
+ * @Android
139
+ */
140
+ 'scroll-to-index'?: number;
141
+
142
+ /**
143
+ * Scroll to specified child node on first screen, only effective once. All direct child nodes must be flatten=false.
144
+ * @defaultValue 0
145
+ * @since 2.17
146
+ * @iOS
147
+ * @Android
148
+ * @H
149
+ */
150
+ 'initial-scroll-to-index'?: number;
151
+
152
+ /**
153
+ * On iOS, force-can-scroll should be used with ios-block-gesture-class and ios-recognized-view-tag. Can be used alone on Android.
154
+ * @defaultValue false
155
+ * @since 2.10.1
156
+ * @iOS
157
+ * @Android
158
+ * @H
159
+ */
160
+ 'force-can-scroll'?: boolean;
161
+
162
+ /**
163
+ * Force-can-scroll should be used with ios-block-gesture-class、ios-recognized-view-tag. Specify the class name of scrollable container that should be blocked by force-can-scroll. Given by container's developer.
164
+ * @defaultValue none
165
+ * @since 2.10.1
166
+ * @iOS
167
+ */
168
+ 'ios-block-gesture-class'?: string;
169
+
170
+ /**
171
+ * force-can-scroll should be used with ios-block-gesture-class、ios-recognized-view-tag. Specify scrollable container's tag, the UIView's tag. Set and given by container's developer.
172
+ * @defaultValue none
173
+ * @since 2.10.1
174
+ * @iOS
175
+ */
176
+ 'ios-recognized-view-tag'?: number;
177
+
178
+ /**
179
+ * This event is triggered when the upper/left edge of the scrolling area intersects with the visible area defined by the upperThreshold.
180
+ * @defaultValue none
181
+ * @since 1.4
182
+ * @iOS
183
+ * @Android
184
+ * @H
185
+ */
186
+ bindscrolltoupper?: EventHandler<ScrollToUpperEvent>;
187
+
188
+ /**
189
+ * This event is triggered when the lower/right edge of the scrolling area intersects with the visible area defined by the lowerThreshold.
190
+ * @defaultValue none
191
+ * @since 1.4
192
+ * @iOS
193
+ * @Android
194
+ * @H
195
+ */
196
+ bindscrolltolower?: EventHandler<ScrollToLowerEvent>;
197
+
198
+ /**
199
+ * This event is triggered when the scrollview is scrolling.
200
+ * @defaultValue none
201
+ * @since 1.4
202
+ * @iOS
203
+ * @Android
204
+ * @H
205
+ */
206
+ bindscroll?: EventHandler<ScrollEvent>;
207
+
208
+ /**
209
+ * This event is triggered when the scrollview's scroll ended.
210
+ * @defaultValue none
211
+ * @since 1.6
212
+ * @iOS
213
+ * @Android
214
+ * @H
215
+ */
216
+ bindscrollend?: EventHandler<ScrollEndEvent>;
217
+
218
+ /**
219
+ * This event is triggered when the scrollview's content size changed.
220
+ * @defaultValue none
221
+ * @since 1.6
222
+ * @iOS
223
+ * @Android
224
+ * @H
225
+ */
226
+ bindcontentsizechanged?: EventHandler<ContentSizeChangedEvent>;
227
+
228
+ /**
229
+ * scrollview scrolls to upper edge
230
+ * @defaultValue none
231
+ * @since 3.0
232
+ * @iOS
233
+ * @Android
234
+ * @H
235
+ */
236
+ bindscrolltoupperedge?: EventHandler<ScrollToUpperEdgeEvent>;
237
+
238
+ /**
239
+ * scrollview scrolls to lower edge
240
+ * @defaultValue none
241
+ * @since 3.0
242
+ * @iOS
243
+ * @Android
244
+ * @H
245
+ */
246
+ bindscrolltoloweredge?: EventHandler<ScrollToLowerEdgeEvent>;
247
+
248
+ /**
249
+ * scrollview scrolls to normal position. Not at upper or lower edge
250
+ * @defaultValue none
251
+ * @since 3.0
252
+ * @iOS
253
+ * @Android
254
+ * @H
255
+ */
256
+ bindscrolltonormalstate?: EventHandler<ScrollToNormalStateEvent>;
257
+ }
258
+
259
+ export interface ScrollToMethod extends BaseMethod {
260
+ method: 'scrollTo';
261
+ params: {
262
+ /**
263
+ * Offset relative to target node
264
+ */
265
+ offset?: number;
266
+
267
+ /**
268
+ * Enable scroll animation
269
+ */
270
+ smooth?: boolean;
271
+
272
+ /**
273
+ * Target item index
274
+ * @defaultValue 0
275
+ */
276
+ index?: number;
277
+ };
278
+ }
279
+
280
+ export type ScrollViewUIMethods = ScrollToMethod | AutoScrollMethod;
@@ -0,0 +1,97 @@
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 { BaseEvent, TextLayoutEventDetail } from '../events';
6
+ import { StandardProps } from '../props';
7
+
8
+ /**
9
+ * Text Component
10
+ */
11
+ export interface TextProps extends StandardProps {
12
+ /**
13
+ * Maximum number of lines for text display
14
+ * @defaultValue "-1"
15
+ * @since 1.0
16
+ */
17
+ 'text-maxline'?: string;
18
+
19
+ /**
20
+ * Maximum number of characters for text display
21
+ * @defaultValue ""
22
+ * @since 1.0
23
+ * @deprecated Suggest preprocessing the text content length.
24
+ */
25
+ 'text-maxlength'?: string;
26
+
27
+ /**
28
+ * Whether font-size is affected by system font scaling
29
+ * @defaultValue false
30
+ * @since 1.6
31
+ */
32
+ 'enable-font-scaling'?: boolean;
33
+
34
+ /**
35
+ * Baseline adjustment strategy in vertical direction; note: setting this value does not guarantee text centering
36
+ * @defaultValue ""
37
+ * @since 1.4
38
+ * @deprecated Use the text-single-line-vertical-align attribute instead.
39
+ */
40
+ 'text-vertical-align'?: 'bottom' | 'center' | 'top';
41
+
42
+ /**
43
+ * By default, if text truncation occurs, the color of the inserted ... will be specified by the style on the nearest inline-text. If this attribute is enabled, the color of ... will be specified by the style on the outermost text tag.
44
+ * @defaultValue false
45
+ * @since 2.0
46
+ */
47
+ 'tail-color-convert'?: boolean;
48
+
49
+ /**
50
+ * Enable long press to select text
51
+ * @defaultValue false
52
+ * @since 2.5
53
+ */
54
+ 'text-selection'?: boolean;
55
+
56
+ /**
57
+ * Set single-line plain text to be centered and aligned within the line. Inline text settings are not supported. Recommended only when the default font doesn't meet center alignment needs, as it increases text measurement time.
58
+ * @defaultValue normal
59
+ * @iOS
60
+ * @Android
61
+ * @since 2.12
62
+ */
63
+ 'text-single-line-vertical-align'?: 'normal' | 'bottom' | 'center' | 'top';
64
+
65
+ /**
66
+ * Enable additional spacing above and below the text on Android; recommended only in high language scenarios to avoid text truncation.
67
+ * @defaultValue false
68
+ * @Android
69
+ * @since 1.0
70
+ */
71
+ 'include-font-padding'?: boolean;
72
+
73
+ /**
74
+ * Enable support for Emoji2 adaptation; requires androidx.emoji2 dependency.
75
+ * @defaultValue false
76
+ * @Android
77
+ * @since 2.9
78
+ */
79
+ 'android-emoji-compat'?: boolean;
80
+
81
+ /**
82
+ * Enables fake bold for fonts when the default bold is not found.
83
+ * @defaultValue false
84
+ * @Android
85
+ * @iOS
86
+ * @since 2.13
87
+ */
88
+ 'text-fake-bold'?: boolean;
89
+
90
+ /**
91
+ * Text layout event
92
+ * @since 2.7
93
+ */
94
+ bindlayout?: (e: LayoutEvent) => void;
95
+ }
96
+
97
+ export type LayoutEvent = BaseEvent<'layout', TextLayoutEventDetail>;
@@ -0,0 +1,7 @@
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 { StandardProps } from '../props';
6
+
7
+ export interface ViewProps extends StandardProps {}