@lynx-js/web-constants 0.9.1 → 0.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @lynx-js/web-constants
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: rewrite the main thread Element PAPIs ([#343](https://github.com/lynx-family/lynx-stack/pull/343))
8
+
9
+ In this commit we've rewritten the main thread apis.
10
+
11
+ The most highlighted change is that
12
+
13
+ - Before this commit we send events directly to bts
14
+ - After this change, we send events to mts then send them to bts with some data combined.
15
+
16
+ ### Patch Changes
17
+
18
+ - feat: The onNapiModulesCall function of lynx-view provides the fourth parameter: `lynxView`, which is the actual lynx-view DOM. ([#350](https://github.com/lynx-family/lynx-stack/pull/350))
19
+
20
+ - fix: publicComponentEvent args order ([#401](https://github.com/lynx-family/lynx-stack/pull/401))
21
+
22
+ - Updated dependencies [[`a521759`](https://github.com/lynx-family/lynx-stack/commit/a5217592f5aebea4b17860e729d523ecabb5f691)]:
23
+ - @lynx-js/web-worker-rpc@0.10.0
24
+
3
25
  ## 0.9.1
4
26
 
5
27
  ### Patch Changes
@@ -1,9 +1,8 @@
1
1
  export declare const lynxUniqueIdAttribute: "lynx-unique-id";
2
2
  export declare const cssIdAttribute: "lynx-css-id";
3
3
  export declare const componentIdAttribute: "lynx-component-id";
4
- export declare const parentComponentUniqueIdAttribute: "lynx-parent-component-uid";
5
4
  export declare const lynxTagAttribute: "lynx-tag";
6
- export declare const lynxRuntimeValue: unique symbol;
7
5
  export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
6
+ export declare const lynxDefaultOverflowVisibleAttribute: "lynx-default-overflow-visible";
8
7
  export declare const __lynx_timing_flag: "__lynx_timing_flag";
9
8
  export declare const globalMuteableVars: readonly ["registerDataProcessor"];
package/dist/constants.js CHANGED
@@ -4,10 +4,9 @@
4
4
  export const lynxUniqueIdAttribute = 'lynx-unique-id';
5
5
  export const cssIdAttribute = 'lynx-css-id';
6
6
  export const componentIdAttribute = 'lynx-component-id';
7
- export const parentComponentUniqueIdAttribute = 'lynx-parent-component-uid';
8
7
  export const lynxTagAttribute = 'lynx-tag';
9
- export const lynxRuntimeValue = Symbol('lynx-runtime-value');
10
8
  export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
9
+ export const lynxDefaultOverflowVisibleAttribute = 'lynx-default-overflow-visible';
11
10
  export const __lynx_timing_flag = '__lynx_timing_flag';
12
11
  export const globalMuteableVars = [
13
12
  'registerDataProcessor',
@@ -2,31 +2,27 @@ import type { ExposureWorkerEvent, LynxCrossThreadEvent } from './types/EventTyp
2
2
  import type { Cloneable, CloneableObject } from './types/Cloneable.js';
3
3
  import type { MainThreadStartConfigs } from './types/MainThreadStartConfigs.js';
4
4
  import type { LynxLifecycleEvent } from './types/LynxLifecycleEvent.js';
5
- import type { ElementOperation, FlushElementTreeOptions } from './types/ElementOperation.js';
6
- import type { PageConfig } from './types/PageConfig.js';
7
5
  import type { IdentifierType, InvokeCallbackRes } from './types/NativeApp.js';
8
6
  import type { LynxTemplate } from './types/LynxModule.js';
9
7
  import type { NapiModulesMap } from './types/NapiModules.js';
10
8
  import type { NativeModulesMap } from './types/NativeModules.js';
9
+ import type { ElementOperation } from '@lynx-js/offscreen-document';
11
10
  export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
12
11
  exposures: ExposureWorkerEvent[];
13
12
  disExposures: ExposureWorkerEvent[];
14
13
  }]>;
15
- export declare const publicComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, string, LynxCrossThreadEvent<{
14
+ export declare const publicComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[componentId: string, hname: string, LynxCrossThreadEvent<{
16
15
  [key: string]: string | number | null | undefined;
17
16
  }>]>;
18
17
  export declare const publishEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, LynxCrossThreadEvent<{
19
18
  [key: string]: string | number | null | undefined;
20
19
  }>]>;
21
- export declare const postMainThreadEvent: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[LynxCrossThreadEvent<{
22
- [key: string]: string | number | null | undefined;
23
- }>]>;
24
- export declare const switchExposureService: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[boolean, boolean]>;
20
+ export declare const postOffscreenEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[eventType: string, targetUniqueId: number, bubbles: boolean, unknown]>;
21
+ export declare const switchExposureServiceEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[boolean, boolean]>;
25
22
  export declare const mainThreadStartEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[MainThreadStartConfigs]>;
26
23
  export declare const updateDataEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[Cloneable, Record<string, string>], void>;
27
24
  export declare const sendGlobalEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, Cloneable[] | undefined]>;
28
25
  export declare const disposeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[], void>;
29
- export declare const postTimingResult: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[pipelineId: string | undefined, updateTimingStamps: Record<string, number>, timingFlags: string[], setupTimingStamps: Record<string, number> | undefined]>;
30
26
  export declare const uiThreadFpReadyEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[]>;
31
27
  export declare const onLifecycleEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[LynxLifecycleEvent]>;
32
28
  export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[{
@@ -42,21 +38,20 @@ export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-
42
38
  * Error message, info
43
39
  */
44
40
  export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, unknown]>;
45
- export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[operations: ElementOperation[], FlushElementTreeOptions, styleContent: string | undefined, timingFlags: string[]]>;
46
- export declare const mainThreadChunkReadyEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
47
- pageConfig: PageConfig;
48
- }]>;
49
- export declare const postTimingInfoFromMainThread: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingKey: string, pipelineId: string | undefined, timeStamp: number]>;
41
+ export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[operations: ElementOperation[]], void>;
42
+ export declare const mainThreadChunkReadyEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[]>;
50
43
  export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: unknown], void>;
51
44
  export declare const invokeUIMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[type: IdentifierType, identifier: string, component_id: string, method: string, params: object, root_unique_id: number | undefined], InvokeCallbackRes>;
52
45
  export declare const setNativePropsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[type: IdentifierType, identifier: string, component_id: string, first_only: boolean, native_props: object, root_unique_id: number | undefined], void>;
53
46
  export declare const nativeModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: Cloneable, moduleName: string], any>;
54
47
  export declare const napiModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncWithTransfer<[name: string, data: Cloneable, moduleName: string], any>;
55
48
  export declare const getCustomSectionsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], Cloneable>;
56
- export declare const postTimingInfoFromBackgroundThread: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingKey: string, pipelineId: string | undefined, timeStamp: number]>;
49
+ export declare const markTimingEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingKey: string, pipelineId: string | undefined, timeStamp: number]>;
50
+ export declare const postTimingFlagsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingFlags: string[], pipelineId: string | undefined]>;
57
51
  export declare const triggerComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[id: string, params: {
58
52
  eventDetail: CloneableObject;
59
53
  eventOption: CloneableObject;
60
54
  componentId: string;
61
55
  }]>;
62
56
  export declare const selectComponentEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[componentId: string, idSelector: string, single: boolean], void>;
57
+ export declare const dispatchLynxViewEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[eventType: string, detail: CloneableObject], void>;
package/dist/endpoints.js CHANGED
@@ -5,13 +5,12 @@ import { createRpcEndpoint } from '@lynx-js/web-worker-rpc';
5
5
  export const postExposureEndpoint = createRpcEndpoint('__postExposure', false, false);
6
6
  export const publicComponentEventEndpoint = createRpcEndpoint('publicComponentEvent', false, false);
7
7
  export const publishEventEndpoint = createRpcEndpoint('publishEvent', false, false);
8
- export const postMainThreadEvent = createRpcEndpoint('postMainThreadEvent', false, false);
9
- export const switchExposureService = createRpcEndpoint('__switchExposureService', false, false);
8
+ export const postOffscreenEventEndpoint = createRpcEndpoint('postOffscreenEventEndpoint', false, false);
9
+ export const switchExposureServiceEndpoint = createRpcEndpoint('switchExposureServiceEndpoint', false, false);
10
10
  export const mainThreadStartEndpoint = createRpcEndpoint('mainThreadStart', false, false);
11
11
  export const updateDataEndpoint = createRpcEndpoint('updateData', false, true);
12
12
  export const sendGlobalEventEndpoint = createRpcEndpoint('sendGlobalEventEndpoint', false, false);
13
13
  export const disposeEndpoint = createRpcEndpoint('dispose', false, true);
14
- export const postTimingResult = createRpcEndpoint('postTimingResult', false, false);
15
14
  export const uiThreadFpReadyEndpoint = createRpcEndpoint('uiThreadFpReady', false, false);
16
15
  export const onLifecycleEventEndpoint = createRpcEndpoint('__OnLifecycleEvent', false, false);
17
16
  export const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, true);
@@ -19,16 +18,17 @@ export const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, t
19
18
  * Error message, info
20
19
  */
21
20
  export const reportErrorEndpoint = createRpcEndpoint('reportError', false, false);
22
- export const flushElementTreeEndpoint = createRpcEndpoint('flushElementTree', false, false);
21
+ export const flushElementTreeEndpoint = createRpcEndpoint('flushElementTree', false, true);
23
22
  export const mainThreadChunkReadyEndpoint = createRpcEndpoint('mainThreadChunkReady', false, false);
24
- export const postTimingInfoFromMainThread = createRpcEndpoint('postTimingInfoFromMainThread', false, false);
25
23
  export const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', false, true);
26
24
  export const invokeUIMethodEndpoint = createRpcEndpoint('__invokeUIMethod', false, true);
27
25
  export const setNativePropsEndpoint = createRpcEndpoint('__setNativeProps', false, true);
28
26
  export const nativeModulesCallEndpoint = createRpcEndpoint('nativeModulesCall', false, true);
29
27
  export const napiModulesCallEndpoint = createRpcEndpoint('napiModulesCall', false, true, true);
30
28
  export const getCustomSectionsEndpoint = createRpcEndpoint('getCustomSections', false, true);
31
- export const postTimingInfoFromBackgroundThread = createRpcEndpoint('postTimingInfoFromBackgroundThread', false, false);
29
+ export const markTimingEndpoint = createRpcEndpoint('markTiming', false, false);
30
+ export const postTimingFlagsEndpoint = createRpcEndpoint('postTimingFlags', false, false);
32
31
  export const triggerComponentEventEndpoint = createRpcEndpoint('__triggerComponentEvent', false, false);
33
32
  export const selectComponentEndpoint = createRpcEndpoint('__selectComponent', false, true);
33
+ export const dispatchLynxViewEventEndpoint = createRpcEndpoint('dispatchLynxViewEvent', false, true);
34
34
  //# sourceMappingURL=endpoints.js.map
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './constants.js';
2
2
  export * from './eventName.js';
3
3
  export * from './endpoints.js';
4
4
  export * from './types/index.js';
5
+ export type * from '@lynx-js/web-worker-rpc';
@@ -13,7 +13,7 @@ export interface LynxCrossThreadEvent<T = {
13
13
  type: string;
14
14
  timestamp: number;
15
15
  target: LynxCrossThreadEventTarget;
16
- currentTarget: LynxCrossThreadEventTarget;
16
+ currentTarget: LynxCrossThreadEventTarget | null;
17
17
  detail: T;
18
18
  [key: string]: string | number | undefined | null | {};
19
19
  }
@@ -0,0 +1,4 @@
1
+ import type { PerformancePipelineOptions } from './Performance.js';
2
+ export interface FlushElementTreeOptions {
3
+ pipelineOptions?: PerformancePipelineOptions;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FlushElementTreeOptions.js.map
@@ -1,2 +1,8 @@
1
1
  export type NapiModulesMap = Record<string, string>;
2
- export type NapiModulesCall = (name: string, data: any, moduleName: string) => Promise<any> | any;
2
+ export type NapiModulesCall = (name: string, data: any, moduleName: string) => Promise<{
3
+ data: unknown;
4
+ transfer?: unknown[];
5
+ }> | {
6
+ data: unknown;
7
+ transfer?: unknown[];
8
+ } | undefined;
@@ -2,6 +2,7 @@ export interface PageConfig {
2
2
  enableCSSSelector: boolean;
3
3
  enableRemoveCSSScope: boolean;
4
4
  defaultDisplayLinear: boolean;
5
+ defaultOverflowVisible: boolean;
5
6
  }
6
7
  export interface BrowserConfig {
7
8
  }
@@ -1,6 +1,5 @@
1
1
  export * from './StyleInfo.js';
2
2
  export * from './EventType.js';
3
- export * from './ElementOperation.js';
4
3
  export * from './PageConfig.js';
5
4
  export * from './Cloneable.js';
6
5
  export * from './LynxModule.js';
@@ -12,3 +11,4 @@ export * from './NativeApp.js';
12
11
  export * from './UpdateDataOptions.js';
13
12
  export * from './NativeModules.js';
14
13
  export * from './NapiModules.js';
14
+ export * from './FlushElementTreeOptions.js';
@@ -1,6 +1,5 @@
1
1
  export * from './StyleInfo.js';
2
2
  export * from './EventType.js';
3
- export * from './ElementOperation.js';
4
3
  export * from './PageConfig.js';
5
4
  export * from './Cloneable.js';
6
5
  export * from './LynxModule.js';
@@ -12,4 +11,5 @@ export * from './NativeApp.js';
12
11
  export * from './UpdateDataOptions.js';
13
12
  export * from './NativeModules.js';
14
13
  export * from './NapiModules.js';
14
+ export * from './FlushElementTreeOptions.js';
15
15
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-constants",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -23,6 +23,9 @@
23
23
  "**/*.css"
24
24
  ],
25
25
  "dependencies": {
26
- "@lynx-js/web-worker-rpc": "0.9.1"
26
+ "@lynx-js/web-worker-rpc": "0.10.0"
27
+ },
28
+ "devDependencies": {
29
+ "@lynx-js/offscreen-document": "0.0.0"
27
30
  }
28
31
  }
@@ -1,115 +0,0 @@
1
- import type { Cloneable } from './Cloneable.js';
2
- import type { LynxEventType } from './EventType.js';
3
- import type { PerformancePipelineOptions } from './Performance.js';
4
- export interface FlushElementTreeOptions {
5
- pipelineOptions?: PerformancePipelineOptions;
6
- }
7
- export declare enum OperationType {
8
- Create = 0,
9
- SetAttribute = 1,
10
- SetProperty = 2,
11
- SwapElement = 3,
12
- Append = 4,
13
- Remove = 5,
14
- Replace = 6,
15
- SetDatasetProperty = 7,
16
- InsertBefore = 8,
17
- SetStyleProperty = 9,
18
- UpdateCssInJs = 10,
19
- RegisterEventHandler = 11
20
- }
21
- interface ElementOperationBase {
22
- type: OperationType;
23
- /**
24
- * uniqueId
25
- */
26
- uid: number;
27
- }
28
- export interface CreateOperation extends ElementOperationBase {
29
- type: OperationType.Create;
30
- tag: string;
31
- cssId?: number;
32
- }
33
- export interface SetAttributeOperation extends ElementOperationBase {
34
- type: OperationType.SetAttribute;
35
- key: string;
36
- value: string | null;
37
- }
38
- export interface SetPropertyOperation extends ElementOperationBase {
39
- type: OperationType.SetProperty;
40
- /**
41
- * property name
42
- */
43
- key: string;
44
- value: Cloneable;
45
- }
46
- export interface SwapOperation extends ElementOperationBase {
47
- type: OperationType.SwapElement;
48
- /**
49
- * target uniqueId
50
- */
51
- tid: number;
52
- }
53
- export interface AppendOperation extends ElementOperationBase {
54
- type: OperationType.Append;
55
- /**
56
- * child uniqueId
57
- */
58
- cid: number[];
59
- }
60
- export interface RemoveOperation extends ElementOperationBase {
61
- type: OperationType.Remove;
62
- cid: number[];
63
- }
64
- export interface SetDatasetPropertyOperation extends ElementOperationBase {
65
- type: OperationType.SetDatasetProperty;
66
- /**
67
- * propert name in dataset
68
- */
69
- key: string;
70
- value: Cloneable;
71
- }
72
- export interface InsertBeforeOperation extends ElementOperationBase {
73
- type: OperationType.InsertBefore;
74
- /**
75
- * child uniqueId
76
- */
77
- cid: number;
78
- ref?: number;
79
- }
80
- export interface ReplaceOperation extends ElementOperationBase {
81
- type: OperationType.Replace;
82
- /**
83
- * the new element's unique id.
84
- */
85
- nid: number[];
86
- }
87
- export interface UpdateCssInJsOperation extends ElementOperationBase {
88
- type: OperationType.UpdateCssInJs;
89
- classStyleStr: string;
90
- }
91
- export interface SetStylePropertyOperation extends ElementOperationBase {
92
- type: OperationType.SetStyleProperty;
93
- key: string;
94
- value: string | null;
95
- /**
96
- * important
97
- */
98
- im?: boolean;
99
- }
100
- export interface RegisterEventHandlerOperation extends ElementOperationBase {
101
- type: OperationType.RegisterEventHandler;
102
- eventType: LynxEventType;
103
- /**
104
- * lynx event name
105
- */
106
- ename: string;
107
- /**
108
- * If it's a background thread hander, it will have a handler name.
109
- * If it's a main-thread handler, it will be null
110
- * If it's going to be removed, it will be undefined
111
- */
112
- hname: string | undefined | null;
113
- }
114
- export type ElementOperation = RegisterEventHandlerOperation | SetStylePropertyOperation | UpdateCssInJsOperation | ReplaceOperation | InsertBeforeOperation | SetDatasetPropertyOperation | CreateOperation | SetAttributeOperation | SetPropertyOperation | SwapOperation | AppendOperation | RemoveOperation;
115
- export {};
@@ -1,16 +0,0 @@
1
- export var OperationType;
2
- (function (OperationType) {
3
- OperationType[OperationType["Create"] = 0] = "Create";
4
- OperationType[OperationType["SetAttribute"] = 1] = "SetAttribute";
5
- OperationType[OperationType["SetProperty"] = 2] = "SetProperty";
6
- OperationType[OperationType["SwapElement"] = 3] = "SwapElement";
7
- OperationType[OperationType["Append"] = 4] = "Append";
8
- OperationType[OperationType["Remove"] = 5] = "Remove";
9
- OperationType[OperationType["Replace"] = 6] = "Replace";
10
- OperationType[OperationType["SetDatasetProperty"] = 7] = "SetDatasetProperty";
11
- OperationType[OperationType["InsertBefore"] = 8] = "InsertBefore";
12
- OperationType[OperationType["SetStyleProperty"] = 9] = "SetStyleProperty";
13
- OperationType[OperationType["UpdateCssInJs"] = 10] = "UpdateCssInJs";
14
- OperationType[OperationType["RegisterEventHandler"] = 11] = "RegisterEventHandler";
15
- })(OperationType || (OperationType = {}));
16
- //# sourceMappingURL=ElementOperation.js.map