@lynx-js/types 3.4.3 → 3.5.9

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 CHANGED
@@ -1,8 +1,68 @@
1
1
  # CHANGELOG
2
+ ## 3.5.10
3
+ - Fix list-type to avoid incompatible type error.
4
+
5
+ ## 3.5.9
6
+ - Update `list` and `list-item` typings.
7
+
8
+ ## 3.5.8
9
+ - Update common typings on elements.
10
+
11
+ ## 3.5.6
12
+ - The `flowIds` parameter in the Trace API supports passing an undefined value.
13
+
14
+ ## 3.5.5
15
+ - Add the `pointer-events` CSS property.
16
+
17
+ ## 3.5.4
18
+ - Add `event-through-active-regions`, `enable-exposure-ui-clip` properties.
19
+
20
+ ## 3.5.3
21
+ - Add `harmony-scroll-edge-effect` property for scroll container.
22
+
23
+ ## 3.5.2
24
+ - Add `EventSource` types.
25
+
26
+ ## 3.5.1
27
+ - Add `frame` element types.
28
+
29
+ ## 3.5.0
30
+
31
+ ### Major Changes
32
+ - Update into Lynx3.5.
33
+
34
+ ### Patch Changes
35
+
36
+ - Add a new `flowIds` subfield to the TraceOption parameter in the Trace API to support one-to-many trace associations.
37
+ - Add `pc`, `windows`, `macOS` and `Harmony` platforms to System info.
38
+ - Refactor event definitions for improved IDE compatibility.
39
+
40
+ ## 3.4.11
41
+ - Fix types of `selectAll()` of `SelectorQuery`.
42
+
43
+ ## 3.4.10
44
+ - Add `animate` for `MainThread.Element`
45
+
46
+ ## 3.4.9
47
+ - Add more interface for `scroll-view`.
48
+
49
+ ## 3.4.8
50
+ - Introduce `disabled` for input and textarea.
51
+
52
+ ## 3.4.6
53
+ - fix `TextCodecHelper` defines.
54
+ - Update `fetch` defines for chunk streaming.
55
+
56
+ ## 3.4.5
57
+ - Complete the documentation for image related APIs.
58
+ - Add `recyclable` property for list-item.
59
+
60
+ ## 3.4.4
61
+ - Complete the documentation for text related APIs.
2
62
 
3
63
  ## 3.4.3
4
64
  - Add `font-variation-settings`,`font-feature-settings` and `font-optical-sizing` CSS properties.
5
- - Add `experimental-recycle-available-item-before-layout` property for list.
65
+ - Add `experimental-recycle-available-item-before-layout` and `enable-dynamic-span-count` property for list.
6
66
 
7
67
  ## 3.4.2
8
68
  - And `lynx.fetchBundle` api defines.
@@ -21,24 +81,19 @@
21
81
 
22
82
  - Introduce <input> and <textarea>
23
83
 
24
- ## 3.3.4
25
-
84
+ ## 3.3.2
85
+ - SelectorQuery FieldsParams adds query attribute
86
+ - Revert automatically generated cssTypes
26
87
  - Add typing for the runtime interfaces.
27
-
28
- ## 3.3.3
29
-
30
- - [Infra][Types] Codegen longhand and shorthand properties from css_defines
88
+ - Codegen longhand and shorthand properties from css_defines
31
89
  - Add `experimental-recycle-sticky-item` and `sticky-buffer-count` for list
32
90
  - Add `experimental-update-sticky-for-diff` for list
33
91
  - Add ReloadBundleEntry to standardize the timing of reload behavior.
34
-
35
- ## 3.3.2
36
-
37
92
  - Add typing for MessageEvent.
38
93
 
39
94
  ## 3.3.1
40
95
 
41
- - [Infra][Types] Codegen csstype.d.ts from css_defines
96
+ - Codegen csstype.d.ts from css_defines
42
97
  - Rename `visibleCellsAfterUpdate` to `visibleItemAfterUpdate` for `list`
43
98
  - Rename `visibleCellsBeforeUpdate` to `visibleItemBeforeUpdate` for `list`
44
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/types",
3
- "version": "3.4.3",
3
+ "version": "3.5.9",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lynx",
@@ -1,6 +1,32 @@
1
1
  // Copyright 2024 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
+ import { MessageEvent } from '../common/lynx';
5
+
6
+ /**
7
+ * @description EventSource to support SSE protocol
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource
9
+ * @since 3.5
10
+ */
11
+ export interface EventSource {
12
+ new(url: string | URL, options?: RequestInit): EventSource;
13
+
14
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
15
+ onerror: ((this: EventSource, ev: Event) => any) | null;
16
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
17
+ onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
18
+ /**
19
+ * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
20
+ *
21
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
22
+ */
23
+ close(): void;
24
+ addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any): void;
25
+ addEventListener(type: string, listener: (event: MessageEvent) => void): void;
26
+ removeEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => any): void;
27
+ removeEventListener(type: string, listener: (event: MessageEvent) => void): void;
28
+ }
29
+
4
30
  /**
5
31
  * @description Http Body
6
32
  * @since 2.18
@@ -71,9 +97,13 @@ export interface Request extends Body {
71
97
  */
72
98
  export declare var Request: {
73
99
  prototype: Request;
74
- new (input: RequestInfo | URL, init?: RequestInit): Request;
100
+ new(input: RequestInfo | URL, init?: RequestInit): Request;
75
101
  };
76
102
 
103
+ export interface LynxExtension {
104
+ useStreaming?: boolean;
105
+ }
106
+
77
107
  /**
78
108
  * @description This Fetch API interface represents the response to a request.
79
109
  * @see https://developer.mozilla.org/docs/Web/API/Response
@@ -95,6 +125,11 @@ export interface RequestInit {
95
125
  * @since 2.18
96
126
  */
97
127
  method?: string;
128
+ /**
129
+ * @description Lynx extension, currently used for requesting chunk streaming
130
+ * @since 3.4
131
+ */
132
+ lynxExtension?: LynxExtension;
98
133
  }
99
134
 
100
135
  /**
@@ -133,6 +168,12 @@ export interface Response extends Body {
133
168
  * @since 2.18
134
169
  */
135
170
  readonly url: string;
171
+ /**
172
+ * @description body of ReadableStream
173
+ * @see https://developer.mozilla.org/docs/Web/API/Response/body
174
+ * @since 3.4
175
+ */
176
+ readonly body: ReadableStream;
136
177
  /**
137
178
  * @description clone()
138
179
  * @see https://developer.mozilla.org/docs/Web/API/Response/clone
@@ -148,5 +189,5 @@ export interface Response extends Body {
148
189
  */
149
190
  export declare var Response: {
150
191
  prototype: Response;
151
- new (body?: BodyInit | null, init?: ResponseInit): Response;
192
+ new(body?: BodyInit | null, init?: ResponseInit): Response;
152
193
  };
@@ -9,3 +9,4 @@ export * from './nodes-ref';
9
9
  export * from './performance';
10
10
  export * from './native-modules';
11
11
  export * from './lynx-performance-entry';
12
+ export * from './text-encoder-decoder';
@@ -84,12 +84,29 @@ export interface MetricFcpEntry extends PerformanceEntry {
84
84
  totalFcp: PerformanceMetric;
85
85
  }
86
86
 
87
+ export interface MetricFspEntry extends PerformanceEntry {
88
+ fsp: PerformanceMetric;
89
+ lynxFsp: PerformanceMetric;
90
+ totalFsp: PerformanceMetric;
91
+ }
92
+
87
93
  export interface MetricActualFmpEntry extends PerformanceEntry {
88
94
  actualFmp: PerformanceMetric;
89
95
  lynxActualFmp: PerformanceMetric;
90
96
  totalActualFmp: PerformanceMetric;
91
97
  }
92
98
 
99
+ /**
100
+ * @deprecated Due to the influence of long tasks on this metric, the statistical results are
101
+ * inaccurate, so this type has been deprecated.
102
+ * Since version 3.3, you will no longer receive this event.
103
+ **/
104
+ export interface MetricTtiEntry extends PerformanceEntry {
105
+ tti: PerformanceMetric;
106
+ lynxTti: PerformanceMetric;
107
+ totalTti: PerformanceMetric;
108
+ }
109
+
93
110
  export interface ReloadBundleEntry extends PipelineEntry {
94
111
  reloadBundleStart: number;
95
112
  reloadBundleEnd: number;
@@ -7,7 +7,7 @@ import { AnimationElement } from './animation';
7
7
  import { BeforePublishEvent, GlobalEventEmitter, IntersectionObserver } from './event';
8
8
  import { SelectorQuery } from './nodes-ref';
9
9
  import { Performance } from './performance';
10
- import { Response } from './fetch';
10
+ import { Response, RequestInit, EventSource } from './fetch';
11
11
 
12
12
  export * from './fetch';
13
13
 
@@ -135,6 +135,13 @@ export interface Lynx extends CommonLynx {
135
135
 
136
136
  setObserverFrameRate(options?: { forPageRect?: number; forExposureCheck?: number }): void;
137
137
 
138
+ /**
139
+ * @description EventSource to support SSE protocol
140
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource
141
+ * @since 3.5
142
+ */
143
+ EventSource: EventSource;
144
+
138
145
  /**
139
146
  * @description subset of Fetch API
140
147
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
@@ -47,6 +47,7 @@ export interface FieldsParams {
47
47
  index?: boolean;
48
48
  class?: boolean;
49
49
  attribute?: boolean;
50
+ query?:boolean;
50
51
  }
51
52
 
52
53
  export interface FieldsData {
@@ -56,11 +57,24 @@ export interface FieldsData {
56
57
  index: number;
57
58
  class: Array<string>;
58
59
  attribute: Record<string, unknown>;
60
+ query:SelectorQuery;
59
61
  }
60
62
 
61
- export type PathCallback = (data: PathData, status: { data: string; code: number }) => void;
63
+ export type PathCallback = (data: PathData | null, status: { data: string; code: number }) => void;
62
64
 
63
- export interface NodesRef {
65
+ interface BaseNodesRef {
66
+ animate(animations: AnimationV2[] | AnimationV2): SelectorQuery;
67
+
68
+ playAnimation(ids: string[] | string): SelectorQuery;
69
+
70
+ pauseAnimation(ids: string[] | string): SelectorQuery;
71
+
72
+ cancelAnimation(ids: string[] | string): SelectorQuery;
73
+
74
+ setNativeProps(nativeProps: Record<string, any>): SelectorQuery;
75
+ }
76
+
77
+ export interface NodesRef extends BaseNodesRef {
64
78
  invoke(options: uiMethodOptions): SelectorQuery;
65
79
 
66
80
  path(callback: PathCallback): SelectorQuery;
@@ -70,20 +84,24 @@ export interface NodesRef {
70
84
  callback: (
71
85
  data: {
72
86
  [K in keyof Required<FieldsParams> as T[K] extends true ? K : never]: FieldsData[K];
73
- },
87
+ } | null,
74
88
  status: { data: string; code: number }
75
89
  ) => void
76
90
  ): SelectorQuery;
91
+ }
77
92
 
78
- animate(animations: AnimationV2[] | AnimationV2): SelectorQuery;
79
-
80
- playAnimation(ids: string[] | string): SelectorQuery;
81
-
82
- pauseAnimation(ids: string[] | string): SelectorQuery;
93
+ export interface MultiNodesRef extends BaseNodesRef {
94
+ path(callback: (data: PathData[], status: { data: string; code: number }) => void): SelectorQuery;
83
95
 
84
- cancelAnimation(ids: string[] | string): SelectorQuery;
85
-
86
- setNativeProps(nativeProps: Record<string, any>): SelectorQuery;
96
+ fields<T extends FieldsParams>(
97
+ fields: Required<FieldsParams> extends Record<keyof T, boolean> ? T : FieldsParams,
98
+ callback: (
99
+ data: {
100
+ [K in keyof Required<FieldsParams> as T[K] extends true ? K : never]: FieldsData[K];
101
+ }[],
102
+ status: { data: string; code: number }
103
+ ) => void
104
+ ): SelectorQuery;
87
105
  }
88
106
 
89
107
  export interface SelectorQuery {
@@ -97,7 +115,7 @@ export interface SelectorQuery {
97
115
  * Selects all nodes satisfying CSS selector.
98
116
  * @param selector CSS selector
99
117
  */
100
- selectAll(selector: string): NodesRef;
118
+ selectAll(selector: string): MultiNodesRef;
101
119
 
102
120
  /**
103
121
  * Select root node of the component.
@@ -1,22 +1,16 @@
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;
1
+ // Copyright 2025 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.
16
4
 
17
- export interface TextDecoder {
18
- decode(buffer: ArrayBuffer | TypedArray | DataView): string;
19
- encoding: 'utf-8';
20
- fatal: false;
21
- ignoreBOM: true;
22
- }
5
+ export interface ITextCodecHelper {
6
+ /**
7
+ * @description decode array buffer to string
8
+ * @since 3.4
9
+ */
10
+ decode(input: ArrayBuffer): string;
11
+ /**
12
+ * @description encode string to array buffer
13
+ * @since 3.4
14
+ */
15
+ encode(input: string): ArrayBuffer;
16
+ }