@lynx-js/types 0.0.1 → 3.2.1
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 +67 -0
- package/LICENSE +203 -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 +157 -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/background-thread/text-encoder-decoder.d.ts +22 -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 +1189 -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 +128 -0
- package/types/common/system-info.d.ts +55 -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,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 FrameworkRenderingTiming {
|
|
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
|
+
frameworkRenderingTiming: FrameworkRenderingTiming[keyof FrameworkRenderingTiming];
|
|
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
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
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 { CommonLynx, GlobalProps } from '../common';
|
|
6
|
+
import { AnimationElement } from './animation';
|
|
7
|
+
import { BeforePublishEvent, GlobalEventEmitter, IntersectionObserver } from './event';
|
|
8
|
+
import { SelectorQuery } from './nodes-ref';
|
|
9
|
+
import { Performance } from './performance';
|
|
10
|
+
import { Response } from './fetch';
|
|
11
|
+
|
|
12
|
+
export * from './fetch';
|
|
13
|
+
|
|
14
|
+
export interface LoadDynamicComponentSuccessResult {
|
|
15
|
+
code: 0;
|
|
16
|
+
detail?: {
|
|
17
|
+
schema: string;
|
|
18
|
+
errMsg: '';
|
|
19
|
+
cache: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LoadDynamicComponentFailedResult {
|
|
24
|
+
// E_DYNAMIC_COMPONENT_LOAD_BAD_RESPONSE = 160102,
|
|
25
|
+
// E_DYNAMIC_COMPONENT_LOAD_EMPTY_FILE = 160102,
|
|
26
|
+
// E_DYNAMIC_COMPONENT_LOAD_DECODE_FAIL = 160103,
|
|
27
|
+
code: 160101 | 160102 | 160103;
|
|
28
|
+
detail?: {
|
|
29
|
+
url: string;
|
|
30
|
+
errMsg: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type LoadDynamicComponentFunc = {
|
|
35
|
+
(url: string, options?: Record<string, any>): Promise<LoadDynamicComponentSuccessResult | LoadDynamicComponentFailedResult>;
|
|
36
|
+
(id: string | string[], url: string, options?: Record<string, any>): Promise<LoadDynamicComponentSuccessResult | LoadDynamicComponentFailedResult>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//TODO(liyanbo.monster): migrate component type.
|
|
40
|
+
export type CreateIntersectionObserverFunc = (
|
|
41
|
+
component: unknown,
|
|
42
|
+
options?: {
|
|
43
|
+
thresholds?: [];
|
|
44
|
+
initialRatio?: number;
|
|
45
|
+
observeAll?: boolean;
|
|
46
|
+
}
|
|
47
|
+
) => IntersectionObserver;
|
|
48
|
+
|
|
49
|
+
export interface ResourcePrefetchData {
|
|
50
|
+
data: {
|
|
51
|
+
uri: string;
|
|
52
|
+
type: 'image' | 'video';
|
|
53
|
+
param?: {
|
|
54
|
+
priority?: 'high' | 'medium' | 'low';
|
|
55
|
+
cacheTarget?: 'disk' | 'bitmap';
|
|
56
|
+
preloadKey?: string;
|
|
57
|
+
size: number;
|
|
58
|
+
};
|
|
59
|
+
}[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ResourcePrefetchResult {
|
|
63
|
+
code: number;
|
|
64
|
+
msg: string;
|
|
65
|
+
details: {
|
|
66
|
+
code: number;
|
|
67
|
+
msg: string;
|
|
68
|
+
uri: string;
|
|
69
|
+
type: 'image' | 'video';
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type GetElementByIdFunc = (id: string) => AnimationElement;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Lynx provide `background-thread lynx` public api.
|
|
77
|
+
*/
|
|
78
|
+
export interface Lynx extends CommonLynx {
|
|
79
|
+
/**
|
|
80
|
+
* @description Properties inside `lynx.__globalProps` is NOT managed by Lynx, so you MUST extends this interface yourself
|
|
81
|
+
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
82
|
+
*/
|
|
83
|
+
__globalProps: GlobalProps;
|
|
84
|
+
__presetData: Record<string, unknown>; // readonly data injected by client via LynxBackgroundRuntimeOptions
|
|
85
|
+
|
|
86
|
+
performance: Performance;
|
|
87
|
+
|
|
88
|
+
beforePublishEvent: BeforePublishEvent;
|
|
89
|
+
|
|
90
|
+
getElementById: GetElementByIdFunc;
|
|
91
|
+
|
|
92
|
+
// cancelAnimationFrame(animationId: number): void;
|
|
93
|
+
|
|
94
|
+
// requestAnimationFrame(callback: () => void): number;
|
|
95
|
+
|
|
96
|
+
cancelResourcePrefetch(data: ResourcePrefetchData, callback: (res: ResourcePrefetchResult) => void): void;
|
|
97
|
+
|
|
98
|
+
createIntersectionObserver: CreateIntersectionObserverFunc;
|
|
99
|
+
|
|
100
|
+
createSelectorQuery(): SelectorQuery;
|
|
101
|
+
|
|
102
|
+
getJSModule<Module = unknown>(name: string): Module;
|
|
103
|
+
|
|
104
|
+
getJSModule(name: 'GlobalEventEmitter'): GlobalEventEmitter;
|
|
105
|
+
|
|
106
|
+
setSharedData<T>(dataKey: string, dataVal: T): void;
|
|
107
|
+
getSharedData<T = unknown>(dataKey: string): T;
|
|
108
|
+
|
|
109
|
+
loadDynamicComponent: LoadDynamicComponentFunc;
|
|
110
|
+
|
|
111
|
+
registerModule<Module extends object>(name: string, module: Module): void;
|
|
112
|
+
|
|
113
|
+
registerSharedDataObserver<T>(callback: (data: T) => void): void;
|
|
114
|
+
|
|
115
|
+
removeSharedDataObserver<T>(callback: (data: T) => void): void;
|
|
116
|
+
|
|
117
|
+
reload(value: object, callback: () => void): void;
|
|
118
|
+
|
|
119
|
+
requestResourcePrefetch(data: ResourcePrefetchData, callback: (res: ResourcePrefetchResult) => void): void;
|
|
120
|
+
|
|
121
|
+
requireModuleAsync<T>(path: string, callback: (error: Error | null, exports?: T) => void): void;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @description requireModule
|
|
125
|
+
* @param path: the source's path
|
|
126
|
+
* @param entryName: the resource's entry's name
|
|
127
|
+
* @param options(@since 3.2): timeout is waiting time,the unit is seconds
|
|
128
|
+
* @since 1.0
|
|
129
|
+
*/
|
|
130
|
+
requireModule<T>(path: string, entryName?: string, options?: {timeout: number }): T;
|
|
131
|
+
|
|
132
|
+
resumeExposure(): void;
|
|
133
|
+
stopExposure(options?: { sendEvent: boolean }): void;
|
|
134
|
+
|
|
135
|
+
setObserverFrameRate(options?: { forPageRect?: number; forExposureCheck?: number }): void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @description subset of Fetch API
|
|
139
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
140
|
+
* @since 2.18
|
|
141
|
+
*/
|
|
142
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @description queue microtask
|
|
146
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/queueMicrotask
|
|
147
|
+
* @since 3.1
|
|
148
|
+
*/
|
|
149
|
+
queueMicrotask(callback: () => void): void;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @description Callback when an error occurs
|
|
153
|
+
* @since 1.0
|
|
154
|
+
*/
|
|
155
|
+
onError?: (error: Error) => void;
|
|
156
|
+
|
|
157
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { AnyObject } from '../common';
|
|
6
|
+
import { NODE_REF_INVOKE_ERROR_CODE } from './nodes-ref';
|
|
7
|
+
|
|
8
|
+
export interface NativeModules {
|
|
9
|
+
LynxUIMethodModule?: {
|
|
10
|
+
invokeUIMethod?(componentId: string, ancestors: string[], method: string, params: AnyObject, callback: (res: { code: NODE_REF_INVOKE_ERROR_CODE }) => void): void;
|
|
11
|
+
};
|
|
12
|
+
NetworkingModule?: any;
|
|
13
|
+
LynxTestModule?: any;
|
|
14
|
+
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
|
|
17
|
+
bridge: {
|
|
18
|
+
call: (name: string, params: Record<string, unknown>, cb: (...args: unknown[]) => void) => void;
|
|
19
|
+
on: (name: string, cb: (...args: unknown[]) => void) => void;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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 { AnyObject } from '../common';
|
|
6
|
+
|
|
7
|
+
export enum NODE_REF_INVOKE_ERROR_CODE {
|
|
8
|
+
SUCCESS = 0,
|
|
9
|
+
UNKNOWN = 1,
|
|
10
|
+
NODE_NOT_FOUND = 2,
|
|
11
|
+
METHOD_NOT_FOUND = 3,
|
|
12
|
+
PARAM_INVALID = 4, // Determined by the implementer of the component.
|
|
13
|
+
SELECTOR_NOT_SUPPORTED = 5, // Currently only supports ID selectors.
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface uiMethodOptions {
|
|
17
|
+
method: string;
|
|
18
|
+
params?: AnyObject;
|
|
19
|
+
success?(res: any): void;
|
|
20
|
+
fail?(res: { code: NODE_REF_INVOKE_ERROR_CODE; data?: any }): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface uiFieldsOptions {
|
|
24
|
+
id?: boolean;
|
|
25
|
+
dataset?: boolean;
|
|
26
|
+
tag?: boolean;
|
|
27
|
+
query?: boolean;
|
|
28
|
+
unique_id?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface PathData {
|
|
32
|
+
data: Array<{
|
|
33
|
+
tag: string;
|
|
34
|
+
id: string;
|
|
35
|
+
class: string[];
|
|
36
|
+
dataSet: Record<string, unknown>;
|
|
37
|
+
// index of parent's children
|
|
38
|
+
index: number;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface FieldsParams {
|
|
43
|
+
id?: boolean;
|
|
44
|
+
dataset?: boolean;
|
|
45
|
+
tag?: boolean;
|
|
46
|
+
index?: boolean;
|
|
47
|
+
class?: boolean;
|
|
48
|
+
attribute?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FieldsData {
|
|
52
|
+
id: string;
|
|
53
|
+
tag: string;
|
|
54
|
+
dataset: Record<string, unknown>;
|
|
55
|
+
index: number;
|
|
56
|
+
class: Array<string>;
|
|
57
|
+
attribute: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type PathCallback = (data: PathData, status: { data: string; code: number }) => void;
|
|
61
|
+
|
|
62
|
+
export interface NodesRef {
|
|
63
|
+
invoke(options: uiMethodOptions): SelectorQuery;
|
|
64
|
+
|
|
65
|
+
path(callback: PathCallback): SelectorQuery;
|
|
66
|
+
|
|
67
|
+
fields<T extends FieldsParams>(
|
|
68
|
+
fields: Required<FieldsParams> extends Record<keyof T, boolean> ? T : FieldsParams,
|
|
69
|
+
callback: (
|
|
70
|
+
data: {
|
|
71
|
+
[K in keyof Required<FieldsParams> as T[K] extends true ? K : never]: FieldsData[K];
|
|
72
|
+
},
|
|
73
|
+
status: { data: string; code: number }
|
|
74
|
+
) => void
|
|
75
|
+
): SelectorQuery;
|
|
76
|
+
|
|
77
|
+
setNativeProps(nativeProps: Record<string, any>): SelectorQuery;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface SelectorQuery {
|
|
81
|
+
/**
|
|
82
|
+
* Selects a single node by CSS selector.
|
|
83
|
+
* @param selector CSS selector
|
|
84
|
+
*/
|
|
85
|
+
select(selector: string): NodesRef;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Selects all nodes satisfying CSS selector.
|
|
89
|
+
* @param selector CSS selector
|
|
90
|
+
*/
|
|
91
|
+
selectAll(selector: string): NodesRef;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Select root node of the component.
|
|
95
|
+
*/
|
|
96
|
+
selectRoot(): NodesRef;
|
|
97
|
+
|
|
98
|
+
// /**
|
|
99
|
+
// * Selects a single node by element id.
|
|
100
|
+
// * When a touch event is triggered, the element id of the node is passed to the event handler as 'uid',
|
|
101
|
+
// * by which can a node be selected in its event handler.
|
|
102
|
+
// */
|
|
103
|
+
// selectUniqueID(uniqueId: string | number): NodesRef;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Execute all tasks in the task queue.
|
|
107
|
+
* When `this._fire_immediately` is set to true, this method is called automatically.
|
|
108
|
+
*/
|
|
109
|
+
exec(): void;
|
|
110
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { CommonPerformance } from "../common/performance";
|
|
6
|
+
import { PerformanceEntry } from "./lynx-performance-entry";
|
|
7
|
+
|
|
8
|
+
export interface SetupTimingInfo {
|
|
9
|
+
create_lynx_start: number;
|
|
10
|
+
create_lynx_end: number;
|
|
11
|
+
load_core_start: number;
|
|
12
|
+
load_core_end: number;
|
|
13
|
+
load_app_start: number;
|
|
14
|
+
load_app_end: number;
|
|
15
|
+
load_template_start: number;
|
|
16
|
+
load_template_end: number;
|
|
17
|
+
decode_start: number;
|
|
18
|
+
decode_end: number;
|
|
19
|
+
lepus_excute_start: number;
|
|
20
|
+
lepus_excute_end: number;
|
|
21
|
+
set_init_data_start: number;
|
|
22
|
+
set_init_data_end: number;
|
|
23
|
+
data_processor_start: number;
|
|
24
|
+
data_processor_end: number;
|
|
25
|
+
create_vdom_start: number;
|
|
26
|
+
create_vdom_end: number;
|
|
27
|
+
dispatch_start: number;
|
|
28
|
+
dispatch_end: number;
|
|
29
|
+
layout_start: number;
|
|
30
|
+
layout_end: number;
|
|
31
|
+
ui_operation_flush_start: number;
|
|
32
|
+
ui_operation_flush_end: number;
|
|
33
|
+
draw_end: number;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface UpdateTimingInfo {
|
|
37
|
+
set_state_trigger?: number;
|
|
38
|
+
create_vdom_start?: number;
|
|
39
|
+
create_vdom_end?: number;
|
|
40
|
+
dispatch_start?: number;
|
|
41
|
+
dispatch_end?: number;
|
|
42
|
+
layout_start?: number;
|
|
43
|
+
layout_end?: number;
|
|
44
|
+
ui_operation_flush_start?: number;
|
|
45
|
+
ui_operation_flush_end?: number;
|
|
46
|
+
draw_end: number;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface ExtraTimingInfo {
|
|
50
|
+
prepare_template_start?: number;
|
|
51
|
+
prepare_template_end?: number;
|
|
52
|
+
container_init_start?: number;
|
|
53
|
+
container_init_end?: number;
|
|
54
|
+
open_time?: number;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface MetricsTimingInfo {
|
|
59
|
+
tti?: number;
|
|
60
|
+
lynx_tti?: number;
|
|
61
|
+
total_tti?: number;
|
|
62
|
+
fcp?: number;
|
|
63
|
+
lynx_fcp?: number;
|
|
64
|
+
total_fcp?: number;
|
|
65
|
+
actual_fmp?: number;
|
|
66
|
+
lynx_actual_fmp?: number;
|
|
67
|
+
total_actual_fmp?: number;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface TimingInfo {
|
|
71
|
+
extra_timing: ExtraTimingInfo;
|
|
72
|
+
setup_timing: SetupTimingInfo;
|
|
73
|
+
update_timings: {
|
|
74
|
+
[key: string]: UpdateTimingInfo;
|
|
75
|
+
};
|
|
76
|
+
metrics: MetricsTimingInfo;
|
|
77
|
+
has_reload: boolean;
|
|
78
|
+
thread_strategy: number;
|
|
79
|
+
url: string;
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
export interface TimingListener {
|
|
83
|
+
onSetup: (info: TimingInfo) => void;
|
|
84
|
+
onUpdate: (info: TimingInfo) => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Performance extends CommonPerformance {
|
|
88
|
+
addTimingListener(listener: TimingListener): void;
|
|
89
|
+
removeTimingListener(listener: TimingListener): void;
|
|
90
|
+
removeAllTimingListener(): void;
|
|
91
|
+
createObserver(callback: PerformanceCallback): PerformanceObserver;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export type PerformanceCallback = (entry: PerformanceEntry) => void;
|
|
96
|
+
export interface PerformanceObserver {
|
|
97
|
+
observe(name: string[]): void;
|
|
98
|
+
disconnect(): void;
|
|
99
|
+
onPerformanceEvent(entry: PerformanceEntry): void
|
|
100
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface TextEncoder {
|
|
2
|
+
encode(str: string): ArrayBuffer;
|
|
3
|
+
encoding: 'utf-8';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
type TypedArray =
|
|
7
|
+
| Int8Array
|
|
8
|
+
| Uint8Array
|
|
9
|
+
| Uint8ClampedArray
|
|
10
|
+
| Int16Array
|
|
11
|
+
| Uint16Array
|
|
12
|
+
| Int32Array
|
|
13
|
+
| Uint32Array
|
|
14
|
+
| Float32Array
|
|
15
|
+
| Float64Array;
|
|
16
|
+
|
|
17
|
+
export interface TextDecoder {
|
|
18
|
+
decode(buffer: ArrayBuffer | TypedArray | DataView): string;
|
|
19
|
+
encoding: 'utf-8';
|
|
20
|
+
fatal: false;
|
|
21
|
+
ignoreBOM: true;
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 Console {
|
|
6
|
+
debug(...args: any[]): void;
|
|
7
|
+
error(...args: any[]): void;
|
|
8
|
+
group(label?: string): void;
|
|
9
|
+
groupEnd(): void;
|
|
10
|
+
info(...args: any[]): void;
|
|
11
|
+
log(...args: any[]): void;
|
|
12
|
+
alog(...args: any[]): void;
|
|
13
|
+
warn(...args: any[]): void;
|
|
14
|
+
}
|