@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # CHANGELOG
2
+
3
+ ## 3.2.0
4
+
5
+ ### Major Changes
6
+
7
+ - Rename @lynx-dev/types to @lynx-js/types
8
+
9
+ ## 1.0.15
10
+
11
+ ### Patch Changes
12
+
13
+ - Refine the related type of event
14
+
15
+ ## 1.0.14
16
+
17
+ ### Patch Changes
18
+
19
+ - Support nestedScrollOptions for hm
20
+
21
+ ## 1.0.10
22
+
23
+ ### Patch Changes
24
+
25
+ - Support lynx.queueMicrotask
26
+
27
+ ## 1.0.5
28
+
29
+ ### Patch Changes
30
+
31
+ - Format the error code of dynamic component with new ErrorCodeFormat
32
+
33
+ ## 1.0.4
34
+
35
+ ### Patch Changes
36
+
37
+ - Export common scrollEvent in type-lynx.
38
+
39
+ ## 1.0.3
40
+
41
+ ### Patch Changes
42
+
43
+ - Add new Trace API `lynx.performance.isProfileRecording` to minimizes the performance overhead.
44
+
45
+ ## 1.0.2
46
+
47
+ ### Patch Changes
48
+
49
+ - Support `inline-truncation` element.
50
+
51
+ ## 1.0.1
52
+
53
+ ### Major Changes
54
+
55
+ - Add all lynx public api on this packages.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Introduction
2
+
3
+ @lynx-js/types is a type package of all public APIs officially provided by the Lynx team. Using this package can help you better use Lynx APIs to develop your applications.
4
+
5
+ # Implementation
6
+
7
+ There are three pieces of content in the entire package, namely:
8
+
9
+ 1. background-thread
10
+ 2. main-thread
11
+ 3. common
12
+
13
+ These three sections contain all of Lynx's publicly available features:
14
+
15
+ 1. The **background-thread** contains all the APIs that can be used in the background-thread runtime, including animation functions, the lynx family of APIs, NativeModules, and so on.
16
+ 2. **main-thread** is the API that can only be called in the main thread, and contains worklet-related functions. Be careful when using this part of the API, as it is called in the main thread, and evaluate the performance impact carefully.
17
+ 3. **common** are all the APIs common to **background-thread** and **main-thread**, such as setting attributes for element, event listening, and so on.
18
+
19
+ # Usage
20
+
21
+ ## For Framework Developers
22
+
23
+ ```json
24
+ "peerDependencies": {
25
+ "@lynx-js/types": "latest"
26
+ }
27
+ ```
28
+
29
+ ## For Product Developers
30
+
31
+ ```json
32
+ "devDependencies": {
33
+ "@lynx-js/types": "latest"
34
+ }
35
+ ```
36
+
37
+ After installing the dependencies, you can use them directly, for example:
38
+
39
+ ```typescript
40
+ import { ListProps } from '@lynx-js/types';
41
+ let prop: ListProps;
42
+ ```
43
+
44
+ If you need to extend the type, for example, GlobalProps, each business will be extended according to its own type, and can be extended like this:
45
+
46
+ ```typescript
47
+ declare module '@lynx-js/types' {
48
+ interface GlobalProps {
49
+ foo: string;
50
+ bar: number;
51
+ }
52
+ }
53
+ ```
54
+
55
+ Once extended, it can be used anywhere in the package.
56
+
package/package.json CHANGED
@@ -1,11 +1,58 @@
1
1
  {
2
2
  "name": "@lynx-js/types",
3
- "version": "0.0.1",
4
- "main": "index.js",
3
+ "version": "3.2.0",
4
+ "description": "",
5
+ "keywords": ["lynx" , "types"],
6
+ "license": "Apache-2.0",
7
+ "author": "Lynx Authors",
8
+ "types":"types/index.d.ts",
9
+ "main": "types/index.d.ts",
5
10
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": ""
7
12
  },
8
- "author": "",
9
- "license": "ISC",
10
- "description": ""
13
+ "exports": {
14
+ ".": {
15
+ "types": "./types/index.d.ts"
16
+ },
17
+ "./background": {
18
+ "types": "./types/background-thread/index.d.ts"
19
+ },
20
+ "./main-thread": {
21
+ "types": "./types/main-thread/index.d.ts"
22
+ },
23
+ "./common": {
24
+ "types": "./types/common/index.d.ts"
25
+ },
26
+ "./element": {
27
+ "types": "./types/common/element/index.d.ts"
28
+ },
29
+ "./events": {
30
+ "types": "./types/common/events.d.ts"
31
+ },
32
+ "./props": {
33
+ "types": "./types/common/props.d.ts"
34
+ }
35
+ },
36
+ "typesVersions": {
37
+ "*": {
38
+ "background": [
39
+ "./types/background-thread/index.d.ts"
40
+ ],
41
+ "common": ["./types/common/index.d.ts"],
42
+ "element": ["./types/common/element/index.d.ts"],
43
+ "events": ["./types/common/events.d.ts"],
44
+ "props": ["./types/common/props.d.ts"],
45
+ "main-thread": ["./types/main-thread/index.d.ts"]
46
+ }
47
+ },
48
+ "files": [
49
+ "types/",
50
+ "CHANGELOG.md"
51
+ ],
52
+ "dependencies": {
53
+ "csstype": "3.1.3"
54
+ },
55
+ "devDependencies": {
56
+ "tsd": "0.30.4"
57
+ }
11
58
  }
@@ -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
+ export interface AnimationElement {
6
+ // keyframes: see https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats
7
+ // Either an array of keyframe objects, or a keyframe object whose property are arrays of values to iterate over. See Keyframe Formats for more details.
8
+ //
9
+ // timingOptions: see https://developer.mozilla.org/en-US/docs/Web/API/Element/animate
10
+ // id Optional: A property unique to animate(): a DOMString with which to reference the animation.
11
+ // delay Optional: The number of milliseconds to delay the start of the animation. Defaults to 0.
12
+ // direction Optional: Whether the animation runs forwards (normal), backwards (reverse), switches direction after each iteration (alternate), or runs backwards and switches direction after each iteration (alternate-reverse). Defaults to "normal".
13
+ // duration Optional: The number of milliseconds each iteration of the animation takes to complete. Defaults to 0. Although this is technically optional, keep in mind that your animation will not run if this value is 0.
14
+ // easing Optional: The rate of the animation's change over time. Accepts the pre-defined values "linear", "ease", "ease-in", "ease-out", and "ease-in-out", or a custom "cubic-bezier" value like "cubic-bezier(0.42, 0, 0.58, 1)". Defaults to "linear".
15
+ // endDelay Optional: The number of milliseconds to delay after the end of an animation. This is primarily of use when sequencing animations based on the end time of another animation. Defaults to 0.
16
+ // fill Optional: Dictates whether the animation's effects should be reflected by the element(s) prior to playing ("backwards"), retained after the animation has completed playing ("forwards"), or both. Defaults to "none".
17
+ // iterationStart Optional: Describes at what point in the iteration the animation should start. 0.5 would indicate starting halfway through the first iteration for example, and with this value set, an animation with 2 iterations would end halfway through a third iteration. Defaults to 0.0.
18
+ // iterations Optional: The number of times the animation should repeat. Defaults to 1, and can also take a value of Infinity to make it repeat for as long as the element exists.
19
+ animate(keyframes: Array<Record<string, any>>, timingOptions: Record<string, any>): Animation;
20
+
21
+ playAnimate(ani: Animation): void;
22
+
23
+ pauseAnimate(ani: Animation): void;
24
+
25
+ cancelAnimate(ani: Animation): void;
26
+
27
+ finishAnimate(ani: Animation): void;
28
+
29
+ setProperty(propsObj: string | Record<string, string>, propsVal?: string): void;
30
+ }
31
+
32
+ export interface KeyframeEffect {
33
+ readonly target: AnimationElement;
34
+ readonly keyframes: Array<Record<string, any>>;
35
+ readonly options: Record<string, any>;
36
+ }
37
+
38
+ export interface Animation {
39
+ readonly effect: KeyframeEffect;
40
+ readonly id: string;
41
+
42
+ cancel(): void;
43
+
44
+ pause(): void;
45
+
46
+ play(): void;
47
+ }
@@ -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 { LynxSetTimeout } from '../common';
6
+ import { AnimationElement } from './animation';
7
+ import { EventEmitter } from './event';
8
+ import { NodesRef } from './nodes-ref';
9
+
10
+ /**
11
+ * @description LynxRuntimeCommonMethod is the public interface that app context implements
12
+ */
13
+ export interface LynxRuntimeCommonMethod {
14
+ setTimeout: LynxSetTimeout;
15
+ setInterval: LynxSetTimeout;
16
+ clearTimeout(timeoutId: number): void;
17
+ clearInterval(intervalId: number): void;
18
+ getNodeRef(id: string): NodesRef;
19
+ GlobalEventEmitter: EventEmitter;
20
+ getJSModule(name: string): EventEmitter;
21
+ getElementById(id: string): AnimationElement;
22
+ selectComponent(name: string, completeCb: (...args: any[]) => void): void;
23
+ }
24
+
25
+ export interface LynxComponentRuntimeMethod extends LynxRuntimeCommonMethod {
26
+ triggerEvent(evtName: string, ...evtPrams: any[]): void;
27
+ getNodeRefFromRoot(id: string): NodesRef;
28
+ }
@@ -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
+ export interface EventEmitter {
6
+ addListener(eventName: string, listener: (...args: unknown[]) => void, context?: object): void;
7
+
8
+ removeListener(eventName: string, listener: (...args: unknown[]) => void): void;
9
+
10
+ emit(eventName: string, data: unknown): void;
11
+
12
+ removeAllListeners(eventName?: string): void;
13
+
14
+ trigger(eventName: string, params: string | Record<any, any>): void;
15
+
16
+ toggle(eventName: string, ...data: unknown[]): void;
17
+ }
18
+
19
+ export type GlobalEventEmitter = EventEmitter;
20
+
21
+ export interface BeforePublishEvent extends EventEmitter {
22
+ add(eventName: string, callback: (...args: unknown[]) => void, context?: object): BeforePublishEvent;
23
+
24
+ remove(eventName: string, callback: (...args: unknown[]) => void): BeforePublishEvent;
25
+ }
26
+
27
+ export interface RelativeToMargins {
28
+ bottom?: number;
29
+ left?: number;
30
+ right?: number;
31
+ top?: number;
32
+ }
33
+
34
+ export interface BoundingClientRectResult {
35
+ bottom: number;
36
+ height: number;
37
+ left: number;
38
+ right: number;
39
+ top: number;
40
+ width: number;
41
+ }
42
+
43
+ export interface IntersectionRectResult {
44
+ bottom: number;
45
+ height: number;
46
+ left: number;
47
+ right: number;
48
+ top: number;
49
+ width: number;
50
+ }
51
+
52
+ export interface RelativeRectResult {
53
+ bottom: number;
54
+ left: number;
55
+ right: number;
56
+ top: number;
57
+ }
58
+
59
+ export interface RectResult {
60
+ top: number;
61
+ right: number;
62
+ bottom: number;
63
+ left: number;
64
+ }
65
+
66
+ export interface ObserveCallbackResult {
67
+ isIntersecting: boolean;
68
+ intersectionRatio: number;
69
+ intersectionRect: RectResult;
70
+ boundingClientRect: RectResult;
71
+ relativeRect: RectResult;
72
+ observerId: string;
73
+ time: number;
74
+ }
75
+
76
+ export type ObserveCallback = (result: ObserveCallbackResult) => void;
77
+
78
+ export interface RelativeToViewportMargins {
79
+ top?: number;
80
+ right?: number;
81
+ bottom?: number;
82
+ left?: number;
83
+ }
84
+
85
+ export interface IntersectionObserver {
86
+ relativeTo(selector: string, margins?: RelativeToMargins): IntersectionObserver;
87
+
88
+ relativeToViewport(margins?: RelativeToViewportMargins): IntersectionObserver;
89
+
90
+ relativeToScreen(margins?: RelativeToViewportMargins): IntersectionObserver;
91
+
92
+ observe(selector: string, callback: ObserveCallback): void;
93
+
94
+ disconnect(): void;
95
+
96
+ invokeCallback(callbackId: number, data: Record<string, any>): void;
97
+ }
@@ -0,0 +1,152 @@
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
+ * @description Http Body
6
+ * @since 2.18
7
+ */
8
+ export interface Body {
9
+ /**
10
+ * @description body used
11
+ * @see https://developer.mozilla.org/docs/Web/API/Request/bodyUsed
12
+ * @since 2.18
13
+ */
14
+ readonly bodyUsed: boolean;
15
+ /**
16
+ * @description arrayBuffer()
17
+ * @see https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer
18
+ * @since 2.18
19
+ */
20
+ arrayBuffer(): Promise<ArrayBuffer>;
21
+ /**
22
+ * @description json()
23
+ * @see https://developer.mozilla.org/docs/Web/API/Request/json
24
+ * @since 2.18
25
+ */
26
+ json(): Promise<any>;
27
+ /**
28
+ * @description text()
29
+ * @see https://developer.mozilla.org/docs/Web/API/Request/text
30
+ * @since 2.18
31
+ */
32
+ text(): Promise<string>;
33
+ }
34
+
35
+ /**
36
+ * @description This Fetch API interface represents a resource request.
37
+ * @see https://developer.mozilla.org/docs/Web/API/Request
38
+ * @since 2.18
39
+ */
40
+ export interface Request extends Body {
41
+ /**
42
+ * @description Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
43
+ * @see https://developer.mozilla.org/docs/Web/API/Request/headers
44
+ * @since 2.18
45
+ */
46
+ readonly headers: Headers;
47
+ /**
48
+ * @description Returns request's HTTP method, which is "GET" by default.
49
+ * @see https://developer.mozilla.org/docs/Web/API/Request/method
50
+ * @since 2.18
51
+ */
52
+ readonly method: string;
53
+ /**
54
+ * @description Returns the URL of request as a string.
55
+ * @see https://developer.mozilla.org/docs/Web/API/Request/url
56
+ * @since 2.18
57
+ */
58
+ readonly url: string;
59
+ /**
60
+ * @description clone()
61
+ * @see https://developer.mozilla.org/docs/Web/API/Request/clone
62
+ * @since 2.18
63
+ */
64
+ clone(): Request;
65
+ }
66
+
67
+ /**
68
+ * @description This Fetch API interface represents a resource request.
69
+ * @see https://developer.mozilla.org/docs/Web/API/Request
70
+ * @since 2.18
71
+ */
72
+ export declare var Request: {
73
+ prototype: Request;
74
+ new (input: RequestInfo | URL, init?: RequestInit): Request;
75
+ };
76
+
77
+ /**
78
+ * @description This Fetch API interface represents the response to a request.
79
+ * @see https://developer.mozilla.org/docs/Web/API/Response
80
+ * @since 2.18
81
+ */
82
+ export interface RequestInit {
83
+ /**
84
+ * @description A BodyInit object or null to set request's body.
85
+ * @since 2.18
86
+ */
87
+ body?: BodyInit | null;
88
+ /**
89
+ * @description A Headers object, an object literal, or an array of two-item arrays to set request's headers.
90
+ * @since 2.18
91
+ */
92
+ headers?: HeadersInit;
93
+ /**
94
+ * @description A string to set request's method.
95
+ * @since 2.18
96
+ */
97
+ method?: string;
98
+ }
99
+
100
+ /**
101
+ * @description This Fetch API interface represents the response to a request.
102
+ * @see https://developer.mozilla.org/docs/Web/API/Response
103
+ * @since 2.18
104
+ */
105
+ export interface Response extends Body {
106
+ /**
107
+ * @description headers
108
+ * @see https://developer.mozilla.org/docs/Web/API/Response/headers
109
+ * @since 2.18
110
+ */
111
+ readonly headers: Headers;
112
+ /**
113
+ * @description ok
114
+ * @see https://developer.mozilla.org/docs/Web/API/Response/ok
115
+ * @since 2.18
116
+ */
117
+ readonly ok: boolean;
118
+ /**
119
+ * @description status
120
+ * @see https://developer.mozilla.org/docs/Web/API/Response/status
121
+ * @since 2.18
122
+ */
123
+ readonly status: number;
124
+ /**
125
+ * @description statusText
126
+ * @see https://developer.mozilla.org/docs/Web/API/Response/statusText
127
+ * @since 2.18
128
+ */
129
+ readonly statusText: string;
130
+ /**
131
+ * @description url
132
+ * @see https://developer.mozilla.org/docs/Web/API/Response/url
133
+ * @since 2.18
134
+ */
135
+ readonly url: string;
136
+ /**
137
+ * @description clone()
138
+ * @see https://developer.mozilla.org/docs/Web/API/Response/clone
139
+ * @since 2.18
140
+ */
141
+ clone(): Response;
142
+ }
143
+
144
+ /**
145
+ * @description This Fetch API interface represents the response to a request.
146
+ * @see https://developer.mozilla.org/docs/Web/API/Response
147
+ * @since 2.18
148
+ */
149
+ export declare var Response: {
150
+ prototype: Response;
151
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
152
+ };
@@ -0,0 +1,11 @@
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
+ export * from './animation';
5
+ export * from './app';
6
+ export * from './event';
7
+ export * from './lynx';
8
+ export * from './nodes-ref';
9
+ export * from './performance';
10
+ export * from './native-modules';
11
+ export * from './lynx-performance-entry';
@@ -0,0 +1,83 @@
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
+ export interface PerformanceEntry {
5
+ name: string;
6
+ entryType: string;
7
+ }
8
+
9
+ export interface FrameworkPipelineTiming {
10
+ }
11
+
12
+ export interface PipelineEntry extends PerformanceEntry {
13
+ identifier: string;
14
+ pipelineStart: number;
15
+ pipelineEnd: number;
16
+ mtsRenderStart: number;
17
+ mtsRenderEnd: number;
18
+ resolveStart: number;
19
+ resolveEnd: number;
20
+ layoutStart: number;
21
+ layoutEnd: number;
22
+ paintingUiOperationExecuteStart: number;
23
+ paintingUiOperationExecuteEnd: number;
24
+ layoutUiOperationExecuteStart: number;
25
+ layoutUiOperationExecuteEnd: number;
26
+ paintEnd: number;
27
+ frameworkPipelineTiming: FrameworkPipelineTiming[keyof FrameworkPipelineTiming];
28
+ }
29
+
30
+ export interface LoadBundleEntry extends PipelineEntry {
31
+ loadBundleStart: number;
32
+ loadBundleEnd: number;
33
+ parseStart: number;
34
+ parseEnd: number;
35
+ loadBackgroundStart: number;
36
+ loadBackgroundEnd: number;
37
+ }
38
+
39
+ export interface InitContainerEntry extends PerformanceEntry {
40
+ openTime: number;
41
+ containerInitStart: number;
42
+ containerInitEnd: number;
43
+ prepareTemplateStart: number;
44
+ prepareTemplateEnd: number;
45
+ extraTiming: Record<string, number>;
46
+ }
47
+
48
+ export interface InitLynxviewEntry extends PerformanceEntry {
49
+ createLynxStart: number;
50
+ createLynxEnd: number;
51
+ }
52
+
53
+ export interface InitBackgroundRuntimeEntry extends PerformanceEntry {
54
+ loadCoreStart: number;
55
+ loadCoreEnd: number;
56
+ }
57
+
58
+ export interface PerformanceMetric {
59
+ name: string;
60
+ duration: number;
61
+ startTimestampName: string;
62
+ startTimestamp: number;
63
+ endTimestampName: string;
64
+ endTimestamp: number;
65
+ }
66
+
67
+ export interface MetricFcpEntry extends PerformanceEntry {
68
+ fcp: PerformanceMetric;
69
+ lynxFcp: PerformanceMetric;
70
+ totalFcp: PerformanceMetric;
71
+ }
72
+
73
+ export interface MetricTtiEntry extends PerformanceEntry {
74
+ tti: PerformanceMetric;
75
+ lynxTti: PerformanceMetric;
76
+ totalTti: PerformanceMetric;
77
+ }
78
+
79
+ export interface MetricActualFmpEntry extends PerformanceEntry {
80
+ actualFmp: PerformanceMetric;
81
+ lynxActualFmp: PerformanceMetric;
82
+ totalActualFmp: PerformanceMetric;
83
+ }