@lynx-js/types 3.3.1 → 3.4.3

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.
@@ -0,0 +1,401 @@
1
+ import { BaseEvent, BaseMethod, Callback } from '../events';
2
+ import { StandardProps } from '../props';
3
+
4
+
5
+ export interface TextAreaInputEvent {
6
+ /**
7
+ * Input content
8
+ * @Android
9
+ * @iOS
10
+ * @Harmony
11
+ * @Web
12
+ * @since 3.4
13
+ */
14
+ value: string;
15
+ /**
16
+ * The start position of the selection
17
+ * @Android
18
+ * @iOS
19
+ * @Harmony
20
+ * @Web
21
+ * @since 3.4
22
+ */
23
+ selectionStart: number;
24
+ /**
25
+ * The end position of the selection
26
+ * @Android
27
+ * @iOS
28
+ * @Harmony
29
+ * @Web
30
+ * @since 3.4
31
+ */
32
+ selectionEnd: number;
33
+ /**
34
+ * Is composing or not
35
+ * @iOS
36
+ * @Web
37
+ * @Android
38
+ * @Harmony
39
+ * @since 3.4
40
+ */
41
+ isComposing?: boolean;
42
+ }
43
+
44
+ export interface TextAreaFocusEvent {
45
+ /**
46
+ * Input content
47
+ * @Android
48
+ * @iOS
49
+ * @Harmony
50
+ * @Web
51
+ * @since 3.4
52
+ */
53
+ value: string;
54
+ }
55
+
56
+ export interface TextAreaBlurEvent {
57
+ /**
58
+ * Input content
59
+ * @Android
60
+ * @iOS
61
+ * @Harmony
62
+ * @Web
63
+ * @since 3.4
64
+ */
65
+ value: string;
66
+ }
67
+
68
+ export interface TextAreaConfirmEvent {
69
+ /**
70
+ * Input content
71
+ * @Android
72
+ * @iOS
73
+ * @Harmony
74
+ * @Web
75
+ * @since 3.4
76
+ */
77
+ value: string;
78
+ }
79
+
80
+ export interface TextAreaSelectionChangeEvent {
81
+ /**
82
+ * The start position of the selection
83
+ * @Android
84
+ * @iOS
85
+ * @Harmony
86
+ * @Web
87
+ * @since 3.4
88
+ */
89
+ selectionStart: number;
90
+ /**
91
+ * The end position of the selection
92
+ * @Android
93
+ * @iOS
94
+ * @Harmony
95
+ * @Web
96
+ * @since 3.4
97
+ */
98
+ selectionEnd: number;
99
+ }
100
+
101
+ export interface TextAreaProps extends Omit<StandardProps, 'bindfocus' | 'bindblur'> {
102
+ /**
103
+ * Placeholder
104
+ * @Android
105
+ * @iOS
106
+ * @Harmony
107
+ * @Web
108
+ * @since 3.4
109
+ */
110
+ placeholder?: string
111
+ /**
112
+ * The type of confirm button
113
+ * @defaultValue 'done'
114
+ * @iOS
115
+ * @Harmony
116
+ * @Web
117
+ * @since 3.4
118
+ */
119
+ 'confirm-type'?: 'send' | 'search' | 'go' | 'done' | 'next';
120
+ /**
121
+ * Max input length
122
+ * @defaultValue 140
123
+ * @Android
124
+ * @iOS
125
+ * @Harmony
126
+ * @Web
127
+ * @since 3.4
128
+ */
129
+ maxlength?: number;
130
+ /**
131
+ * Max input lines
132
+ * @defaultValue undefined
133
+ * @Android
134
+ * @iOS
135
+ * @Harmony
136
+ * @since 3.4
137
+ */
138
+ maxlines?: number;
139
+ /**
140
+ * Bounce effect for iOS
141
+ * @defaultValue true
142
+ * @iOS
143
+ * @since 3.4
144
+ */
145
+ bounces?: boolean;
146
+ /**
147
+ * Line spacing
148
+ * @defaultValue undefined
149
+ * @iOS
150
+ * @Android
151
+ * @since 3.4
152
+ */
153
+ 'line-spacing'?: number | `${number}px` | `${number}rpx`;
154
+ /**
155
+ * Interaction enabled
156
+ * @defaultValue false
157
+ * @Android
158
+ * @iOS
159
+ * @Harmony
160
+ * @Web
161
+ * @since 3.4
162
+ */
163
+ readonly?: boolean;
164
+
165
+ /**
166
+ * Show soft input keyboard while focused
167
+ * @defaultValue true
168
+ * @Android
169
+ * @iOS
170
+ * @since 3.4
171
+ */
172
+ 'show-soft-input-on-focus'?: boolean;
173
+
174
+ /**
175
+ * Filter the input content and process it in the form of regular expressions
176
+ * @defaultValue undefined
177
+ * @Android
178
+ * @iOS
179
+ * @Harmony
180
+ * @Web
181
+ * @since 3.4
182
+ */
183
+ 'input-filter'?: string;
184
+
185
+ /**
186
+ * Input content type
187
+ * @defaultValue "text"
188
+ * @Android
189
+ * @iOS
190
+ * @Harmony
191
+ * @Web
192
+ * @since 3.4
193
+ */
194
+ type?: 'text' | 'number' | 'digit' | 'tel' | 'email';
195
+
196
+ /**
197
+ * Auto correct input content on iOS
198
+ * @defaultValue true
199
+ * @iOS
200
+ * @since 3.4
201
+ */
202
+ 'ios-auto-correct'?: boolean;
203
+
204
+ /**
205
+ * Check spelling issue on iOS
206
+ * @defaultValue true
207
+ * @iOS
208
+ * @Web
209
+ * @since 3.4
210
+ */
211
+ 'ios-spell-check'?: boolean;
212
+
213
+ /**
214
+ * Whether to enter the full-screen input mode when in landscape screen, in which the keyboard and input box will take up the entire screen
215
+ * @defaultValue true
216
+ * @Android
217
+ * @since 3.4
218
+ */
219
+ 'android-fullscreen-mode'?: boolean;
220
+
221
+ /**
222
+ * Focused
223
+ * @Android
224
+ * @iOS
225
+ * @Harmony
226
+ * @Web
227
+ * @since 3.4
228
+ */
229
+ bindfocus?: (e: BaseEvent<'bindfocus', TextAreaFocusEvent>) => void;
230
+
231
+ /**
232
+ * Blurred
233
+ * @Android
234
+ * @iOS
235
+ * @Harmony
236
+ * @Web
237
+ * @since 3.4
238
+ */
239
+ bindblur?: (e: BaseEvent<'bindblur', TextAreaBlurEvent>) => void;
240
+
241
+ /**
242
+ * Input content changed
243
+ * @Android
244
+ * @iOS
245
+ * @Harmony
246
+ * @Web
247
+ * @since 3.4
248
+ */
249
+ bindinput?: (e: BaseEvent<'bindinput', TextAreaInputEvent>) => void;
250
+
251
+ /**
252
+ * Input selection changed
253
+ * @Android
254
+ * @iOS
255
+ * @Harmony
256
+ * @Web
257
+ * @since 3.4
258
+ */
259
+ bindselection?: (e: BaseEvent<'bindselection', TextAreaSelectionChangeEvent>) => void;
260
+
261
+ /**
262
+ * Confirm button clicked, only work when confirm-type is defined
263
+ * @Android
264
+ * @iOS
265
+ * @Harmony
266
+ * @Web
267
+ * @since 3.4
268
+ */
269
+ bindconfirm?: (e: BaseEvent<'bindconfirm', TextAreaConfirmEvent>) => void;
270
+ }
271
+
272
+ /**
273
+ * Require focus
274
+ * @Android
275
+ * @iOS
276
+ * @Harmony
277
+ * @Web
278
+ * @since 3.4
279
+ */
280
+ export interface TextAreaFocusMethod extends BaseMethod {
281
+ method: 'focus';
282
+ }
283
+
284
+ /**
285
+ * Release focus
286
+ * @Android
287
+ * @iOS
288
+ * @Harmony
289
+ * @Web
290
+ * @since 3.4
291
+ */
292
+ export interface TextAreaBlurMethod extends BaseMethod {
293
+ method: 'blur';
294
+ }
295
+
296
+ /**
297
+ * Get input content
298
+ * @Android
299
+ * @iOS
300
+ * @Harmony
301
+ * @Web
302
+ * @since 3.4
303
+ */
304
+ export interface TextAreaGetValueMethod extends BaseMethod {
305
+ method: 'getValue';
306
+ success?: Callback<{
307
+ /**
308
+ * Input content
309
+ * @Android
310
+ * @iOS
311
+ * @Harmony
312
+ * @Web
313
+ * @since 3.4
314
+ */
315
+ value: string;
316
+ /**
317
+ * Begin position of the cursor
318
+ * @Android
319
+ * @iOS
320
+ * @Harmony
321
+ * @Web
322
+ * @since 3.4
323
+ */
324
+ selectionStart: number;
325
+ /**
326
+ * End position of the cursor
327
+ * @Android
328
+ * @iOS
329
+ * @Harmony
330
+ * @Web
331
+ * @since 3.4
332
+ */
333
+ selectionEnd: number;
334
+ /**
335
+ * Is composing or not, iOS only
336
+ * @iOS
337
+ * @Android
338
+ * @Harmony
339
+ * @Web
340
+ * @since 3.4
341
+ */
342
+ isComposing: boolean;
343
+ }>;
344
+ }
345
+
346
+ /**
347
+ * Set input content
348
+ * @Android
349
+ * @iOS
350
+ * @Harmony
351
+ * @Web
352
+ * @since 3.4
353
+ */
354
+ export interface TextAreaSetValueMethod extends BaseMethod {
355
+ method: 'setValue';
356
+ params: {
357
+ /**
358
+ * Input content
359
+ * @Android
360
+ * @iOS
361
+ * @Harmony
362
+ * @Web
363
+ * @since 3.4
364
+ */
365
+ value: string;
366
+ };
367
+ }
368
+
369
+ /**
370
+ * Set selection range
371
+ * @Android
372
+ * @iOS
373
+ * @Harmony
374
+ * @Web
375
+ * @since 3.4
376
+ */
377
+ export interface TextAreaSetSelectionRangeMethod extends BaseMethod {
378
+ method: 'setSelectionRange';
379
+ params: {
380
+ /**
381
+ * Start position of the selection
382
+ * @Android
383
+ * @iOS
384
+ * @Harmony
385
+ * @Web
386
+ * @since 3.4
387
+ */
388
+ selectionStart: number;
389
+ /**
390
+ * End position of the selection
391
+ * @Android
392
+ * @iOS
393
+ * @Harmony
394
+ * @Web
395
+ * @since 3.4
396
+ */
397
+ selectionEnd: number;
398
+ };
399
+ }
400
+
401
+ export type TextAreaUIMethods = TextAreaFocusMethod | TextAreaBlurMethod | TextAreaGetValueMethod | TextAreaSetValueMethod | TextAreaSetSelectionRangeMethod;
@@ -80,9 +80,9 @@ export interface BaseTouchEvent<T> extends BaseEventOrig<any, T> {
80
80
  changedTouches: Array<Touch>;
81
81
 
82
82
  detail: {
83
- /** The current position of the touch point relative to the touched element's x-coordinate. */
83
+ /** The current position of the touch point relative to the page's x-coordinate. */
84
84
  x: number;
85
- /** The current position of the touch point relative to the touched element's y-coordinate. */
85
+ /** The current position of the touch point relative to the page's y-coordinate. */
86
86
  y: number;
87
87
  }
88
88
  }
@@ -217,6 +217,12 @@ export interface TextLayoutEventDetail {
217
217
  };
218
218
  }
219
219
 
220
+ export interface TextSelectionChangeEventDetail {
221
+ start: number;
222
+ end: number;
223
+ direction: 'forward' | 'backward';
224
+ }
225
+
220
226
  export interface AccessibilityActionDetailEvent<T> extends BaseEventOrig<{}, T> {
221
227
  detail: {
222
228
  /**
@@ -460,3 +466,73 @@ export interface ITouchEvent extends BaseTouchEvent<Target> {}
460
466
  export interface IMouseEvent extends BaseMouseEvent<Target> {}
461
467
  export interface IWheelEvent extends BaseWheelEvent<Target> {}
462
468
  export interface IKeyEvent extends BaseKeyEvent<Target> {}
469
+
470
+ interface LynxMessageEvents {
471
+ // from native context
472
+ __GlobalEvent: {
473
+ data: [
474
+ // name
475
+ string,
476
+ // params
477
+ any,
478
+ ];
479
+ origin: 'NATIVE';
480
+ };
481
+ __DestroyLifetime: {
482
+ data: [
483
+ // appGUID
484
+ number,
485
+ ];
486
+ origin: 'NATIVE';
487
+ }
488
+
489
+ // from engine context
490
+ __RenderPage: {
491
+ data: [
492
+ // data
493
+ object,
494
+ // renderOptions
495
+ object,
496
+ ];
497
+ origin: 'ENGINE';
498
+ };
499
+ __UpdatePage: {
500
+ data: [
501
+ // data
502
+ object,
503
+ // updateOptions
504
+ object,
505
+ ];
506
+ origin: 'ENGINE';
507
+ };
508
+ __UpdateGlobalProps: {
509
+ data: [
510
+ // data
511
+ Object
512
+ ];
513
+ origin: 'ENGINE';
514
+ };
515
+ __RemoveComponents: {
516
+ data: [];
517
+ origin: 'ENGINE';
518
+ };
519
+ __SSRHydrate: {
520
+ data: [
521
+ // customHydrateInfo
522
+ string,
523
+ // listIDs
524
+ number[],
525
+ ];
526
+ origin: 'ENGINE';
527
+ };
528
+ }
529
+
530
+ type LynxMessageEventType = keyof LynxMessageEvents;
531
+
532
+ type LynxMessageEventsWithType = {
533
+ [k in LynxMessageEventType]: LynxMessageEvents[k] & {
534
+ type: k;
535
+ };
536
+ };
537
+
538
+ export type LynxMessageEvent = LynxMessageEventsWithType[LynxMessageEventType];
@@ -13,6 +13,58 @@ export interface TextMetrics {
13
13
  width: number;
14
14
  content?: Array<string>;
15
15
  }
16
+
17
+ export type DispatchEventResult =
18
+ // 'NotCanceled'
19
+ // Event was not canceled by event handler or default event handler.
20
+ | 0
21
+ // 'CanceledByEventHandler'
22
+ // Event was canceled by event handler; i.e. a script handler calling
23
+ // preventDefault.
24
+ | 1
25
+ // 'CanceledByDefaultEventHandler'
26
+ // Event was canceled by the default event handler; i.e. executing the default
27
+ // action. This result should be used sparingly as it deviates from the DOM
28
+ // Event Dispatch model. Default event handlers really shouldn't be invoked
29
+ // inside of dispatch.
30
+ | 2
31
+ // 'CanceledBeforeDispatch'
32
+ // Event was canceled but suppressed before dispatched to event handler. This
33
+ // result should be used sparingly; and its usage likely indicates there is
34
+ // potential for a bug. Trusted events may return this code; but untrusted
35
+ // events likely should always execute the event handler the developer intends
36
+ // to execute.
37
+ | 3;
38
+
39
+ export interface MessageEvent {
40
+ type: string;
41
+ data: any;
42
+ origin?: string;
43
+ }
44
+
45
+ export interface ContextProxy {
46
+ onTriggerEvent?: (event: MessageEvent) => void;
47
+
48
+ postMessage(message: any): void;
49
+ dispatchEvent(event: MessageEvent): DispatchEventResult;
50
+ addEventListener(type: string, listener: (event: MessageEvent) => void): void;
51
+ removeEventListener(
52
+ type: string,
53
+ listener: (event: MessageEvent) => void
54
+ ): void;
55
+ }
56
+
57
+ export interface BundleInfo {
58
+ url: string;
59
+ code: number;
60
+ error_msg: string;
61
+ }
62
+
63
+ export interface ResponseHandler {
64
+ wait: (timeout: number) => BundleInfo;
65
+ then: (info: BundleInfo) => {}
66
+ }
67
+
16
68
  /*
17
69
  *@description Common Lynx type
18
70
  */
@@ -32,4 +84,12 @@ export interface CommonLynx {
32
84
  * @since main-thread:3.0, background-thread: 2.6
33
85
  */
34
86
  targetSdkVersion?: string;
87
+
88
+ getDevtool(): ContextProxy;
89
+ getCoreContext(): ContextProxy;
90
+ getJSContext(): ContextProxy;
91
+ getUIContext(): ContextProxy;
92
+ getNative(): ContextProxy;
93
+ getEngine(): ContextProxy;
94
+ fetchBundle(url: string, options?: {}): ResponseHandler;
35
95
  }