@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,119 @@
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 { CSSProperties } from './csstype';
6
+ import { LynxEventProps } from './events';
7
+
8
+ export interface StandardProps extends LynxEventProps {
9
+ /** The unique identifier of the component, ensuring the uniqueness of the entire page. */
10
+ id?: string;
11
+ /** In React, similar to class, className is generally used as an alias for class.*/
12
+ className?: string;
13
+ class?: string;
14
+ /** Component Display, All Components Display by Default. */
15
+ hidden?: boolean;
16
+ /** Animation Properties */
17
+ animation?: { actions: Record<string, unknown>[] };
18
+ /** "flatten" attribute only works for Lynx. */
19
+ flatten?: boolean;
20
+ name?: string;
21
+ overlap?: boolean;
22
+ enableLayoutOnly?: boolean;
23
+ cssAlignWithLegacyW3C?: boolean;
24
+ /**
25
+ * Accessibility reading content
26
+ * @Android
27
+ * @iOS
28
+ * @spec {@link https://developer.apple.com/documentation/objectivec/nsobject/1615181-accessibilitylabel?language=objc | iOS}
29
+ * @spec {@link https://developer.android.com/reference/android/view/View.html#setContentDescription(java.lang.CharSequence) | Android}
30
+ */
31
+ 'accessibility-label'?: string;
32
+ /**
33
+ * The combination of accessibility traits that best characterizes the accessibility element.
34
+ * @defaultValue 'none'
35
+ * @iOS
36
+ * @spec {@link https://developer.apple.com/documentation/objectivec/nsobject/1615202-accessibilitytraits?language=objc | iOS}
37
+ */
38
+ 'accessibility-traits'?:
39
+ | 'text'
40
+ | 'image'
41
+ | 'button'
42
+ | 'link'
43
+ | 'header'
44
+ | 'search'
45
+ | 'selected'
46
+ | 'playable'
47
+ | 'keyboard'
48
+ | 'summary'
49
+ | 'disabled'
50
+ | 'updating'
51
+ | 'adjustable'
52
+ | 'tabbar'
53
+ | 'none';
54
+ /**
55
+ * A Boolean value that indicates whether the element is an accessibility element that an assistive app can access.
56
+ * @iOS
57
+ * @Android
58
+ * @spec {@link https://developer.apple.com/documentation/objectivec/nsobject/1615141-isaccessibilityelement?language=objc | iOS}
59
+ * @spec {@link https://developer.android.com/reference/android/view/View.html#setImportantForAccessibility(int) | Android}
60
+ */
61
+ 'accessibility-element'?: boolean;
62
+ /**
63
+ * A localized string that contains the value of the accessibility element.
64
+ * @iOS
65
+ * @Android
66
+ * @spec {@link https://developer.apple.com/documentation/objectivec/nsobject/1615117-accessibilityvalue?language=objc | iOS}
67
+ * @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#setStateDescription(java.lang.CharSequence) | Android}
68
+ */
69
+ 'accessibility-value'?: string;
70
+ /**
71
+ * Sets whether the node represents a heading.
72
+ * @defaultValue false
73
+ * @Android
74
+ * @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#setHeading(boolean) | Android}
75
+ */
76
+ 'accessibility-heading'?: boolean;
77
+ /**
78
+ * Sets the class this node comes from, or, sets the custom role description.
79
+ * @Android
80
+ * @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#setClassName(java.lang.CharSequence) | Android}
81
+ * @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#setRoleDescription(java.lang.CharSequence) | Android}
82
+ */
83
+ 'accessibility-role-description'?: 'switch' | 'checkbox' | 'image' | 'progressbar' | string;
84
+ /**
85
+ * The custom actions of the current accessibility element.
86
+ * @Android
87
+ * @iOS
88
+ * @spec {@link https://developer.apple.com/documentation/appkit/nsaccessibility/2869551-accessibilitycustomactions/ | iOS}
89
+ * @spec {@link https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat?hl=en#addAction(androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat) | Android}
90
+ */
91
+ 'accessibility-actions'?: string[];
92
+
93
+ /** Control whether the component can receive focus. Default is false */
94
+ focusable?: boolean;
95
+ /** Use two-dimensional coordinates such as "0, 0" to represent the focus priority of the x and y axes respectively. Nodes with the same priority will switch focus based on their position. */
96
+ 'focus-index'?: string;
97
+ /** Manually specify the node ID that will receive focus when the user presses the "up" arrow key. */
98
+ 'next-focus-up'?: string;
99
+ /** Manually specify the node ID that will receive focus when the user presses the "down" arrow key. */
100
+ 'next-focus-down'?: string;
101
+ /** Manually specify the node ID that will receive focus when the user presses the "left" arrow key.*/
102
+ 'next-focus-left'?: string;
103
+ /**
104
+ * Manually specify the node id that receives focus when the user presses the "right" arrow key.
105
+ */
106
+ 'next-focus-right'?: string;
107
+
108
+ /**
109
+ * Custom Timing Flag
110
+ * @since Lynx 2.10
111
+ */
112
+ __lynx_timing_flag?: string;
113
+
114
+ style?: string | CSSProperties;
115
+ }
116
+
117
+ export interface NoProps {
118
+ // empty props
119
+ }
@@ -0,0 +1,46 @@
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 type PlatformType = 'Android' | 'iOS';
6
+
7
+ export interface SystemInfo {
8
+ /**
9
+ * The version of the Lynx SDK.
10
+ * @example '2.4', '2.10'
11
+ */
12
+ readonly lynxSdkVersion: string;
13
+
14
+ /**
15
+ * The current operating system version.
16
+ */
17
+ readonly osVersion: string;
18
+
19
+ /**
20
+ * The physical pixel height of the real device.
21
+ */
22
+ readonly pixelHeight: number;
23
+
24
+ /**
25
+ * The physical pixel width of the real device.
26
+ */
27
+ readonly pixelWidth: number;
28
+
29
+ /**
30
+ * The physical pixel ratio of the real device.
31
+ */
32
+ readonly pixelRatio: number;
33
+
34
+ /**
35
+ * The platform of the current device.
36
+ */
37
+ readonly platform: PlatformType;
38
+
39
+ /**
40
+ * The JavaScript engine currently used.
41
+ * @note Not available in lepus
42
+ */
43
+ readonly runtimeType: 'v8' | 'jsc' | 'quickjs';
44
+
45
+ readonly theme?: object;
46
+ }
@@ -0,0 +1,8 @@
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 './background-thread';
6
+ export * from './common';
7
+ export * as MainThread from './main-thread';
8
+ export * as Background from './background-thread';
@@ -0,0 +1,85 @@
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 { CSSProperties } from '../common';
6
+
7
+ export interface Element {
8
+ styles: CSSProperties;
9
+ attributes: Record<string, any>;
10
+ scrollBy: (
11
+ width: number,
12
+ height: number
13
+ ) => {
14
+ consumedX: number;
15
+ consumedY: number;
16
+ unconsumedX: number;
17
+ unconsumedY: number;
18
+ };
19
+ getBoundingClientRect: () => {
20
+ width: number;
21
+ height: number;
22
+ top: number;
23
+ bottom: number;
24
+ left: number;
25
+ right: number;
26
+ };
27
+
28
+ /**
29
+ * Set an attribute.
30
+ * @param attributeName The name of the attribute.
31
+ * @since Lynx 2.14
32
+ */
33
+ getAttribute(attributeName: string): any;
34
+
35
+ /**
36
+ * Get all attribute names as an array.
37
+ * @since Lynx 2.14
38
+ */
39
+ getAttributeNames(): string[];
40
+
41
+ /**
42
+ * Set an attribute.
43
+ * @param name The name of the attribute to set.
44
+ * @param value The value to set.
45
+ * @since Lynx 2.14
46
+ */
47
+ setAttribute(name: string, value: any): void;
48
+
49
+ /**
50
+ * Set a style property.
51
+ * @param name The name of the style property, in kebab-case.
52
+ * @param value The value of the property.
53
+ * @since Lynx 2.14
54
+ */
55
+ setStyleProperty(name: string, value: string): void;
56
+
57
+ /**
58
+ * Set a list of style properties.
59
+ * @param styles The object containing key-value pair of the style properties to set, name of the property in kebab-case.
60
+ * @since Lynx 2.14
61
+ */
62
+ setStyleProperties(styles: Record<string, string>): void;
63
+
64
+ /**
65
+ * Select the first element matching the given CSS selector in this element's children.
66
+ * @param selector CSS Selector string.
67
+ * @since Lynx 2.14
68
+ */
69
+ querySelector(selector: string): Element | null;
70
+
71
+ /**
72
+ * Select all the elements matching the given CSS selector in this element's children.
73
+ * @param selector CSS Selector string.
74
+ * @since Lynx 2.14
75
+ */
76
+ querySelectorAll(selector: string): Element[];
77
+
78
+ /**
79
+ * Invoke a UI method.
80
+ * @param methodName The UI method to invoke.
81
+ * @param params Params of the UI method.
82
+ * @since Lynx 2.14
83
+ */
84
+ invoke(methodName: string, params?: Record<string, any>): Promise<any>;
85
+ }
@@ -0,0 +1,20 @@
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 { LynxEventPropsBase, BaseTouchEvent, BaseMouseEvent, BaseWheelEvent, BaseKeyEvent } from '../common/events';
6
+ import { Element } from './element';
7
+
8
+ // worklet event
9
+ export interface TouchEvent extends BaseTouchEvent<Element> {}
10
+ export interface MouseEvent extends BaseMouseEvent<Element> {}
11
+ export interface WheelEvent extends BaseWheelEvent<Element> {}
12
+ export interface KeyEvent extends BaseKeyEvent<Element> {}
13
+ type LynxWorkletEventPropsImpl = {
14
+ [K in keyof LynxEventPropsBase<Element> as Lowercase<`main-thread:${K}`>]: LynxEventPropsBase<Element>[K];
15
+ };
16
+ export interface LynxWorkletEventProps extends LynxWorkletEventPropsImpl {}
17
+
18
+ declare module '../common/props.d.ts' {
19
+ interface StandardProps extends LynxWorkletEventProps {}
20
+ }
@@ -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
+ export * from './lynx';
6
+ export * from './element';
7
+ export * from './events';
@@ -0,0 +1,28 @@
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 { LynxClearTimeout, LynxSetTimeout, CommonLynx } from '../common';
6
+ import { CommonPerformance } from '../common/performance';
7
+
8
+ /**
9
+ * @description Lynx provide `main-thread lynx` public api.
10
+ */
11
+ export interface Lynx extends CommonLynx {
12
+ // Currently is internal.
13
+ // setTimeout: LynxSetTimeout;
14
+
15
+ // setInterval: LynxSetTimeout;
16
+
17
+ // clearTimeout: LynxClearTimeout;
18
+
19
+ // clearInterval: LynxClearTimeout;
20
+
21
+ // triggerLepusBridge: <Params = Record<string, unknown>>(methodName: string, methodDetail: Params, cb: (...args: unknown[]) => void) => void;
22
+ // triggerLepusBridgeSync: <Ret = unknown, Params = Record<string, unknown>>(methodName: string, methodDetail: Params) => Ret;
23
+
24
+ /**
25
+ * Support from Lynx 3.0
26
+ */
27
+ performance: CommonPerformance;
28
+ }