@lynx-js/web-constants 0.15.4 → 0.15.6
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 +34 -0
- package/dist/endpoints.d.ts +1 -0
- package/dist/endpoints.js +1 -0
- package/dist/types/LynxModule.d.ts +7 -6
- package/dist/types/MainThreadGlobalThis.d.ts +10 -0
- package/dist/types/MainThreadLynx.d.ts +2 -0
- package/dist/types/NativeApp.d.ts +14 -1
- package/dist/utils/generateTemplate.d.ts +1 -2
- package/dist/utils/generateTemplate.js +26 -39
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.15.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: systeminfo in mts function ([#1537](https://github.com/lynx-family/lynx-stack/pull/1537))
|
|
8
|
+
|
|
9
|
+
- feat: add MTS API: \_\_UpdateComponentInfo ([#1485](https://github.com/lynx-family/lynx-stack/pull/1485))
|
|
10
|
+
|
|
11
|
+
- fix: `__ElementFromBinary` needs to correctly apply the dataset in elementTemplate to the Element ([#1487](https://github.com/lynx-family/lynx-stack/pull/1487))
|
|
12
|
+
|
|
13
|
+
- fix: all attributes except `id` and `type` under ElementTemplateData are optional. ([#1483](https://github.com/lynx-family/lynx-stack/pull/1483))
|
|
14
|
+
|
|
15
|
+
- feat: add MTS API \_\_GetAttributeByName ([#1486](https://github.com/lynx-family/lynx-stack/pull/1486))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies []:
|
|
18
|
+
- @lynx-js/web-worker-rpc@0.15.6
|
|
19
|
+
|
|
20
|
+
## 0.15.5
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- fix: load main-thread chunk in ESM format ([#1437](https://github.com/lynx-family/lynx-stack/pull/1437))
|
|
25
|
+
|
|
26
|
+
See [nodejs/node#59362](https://github.com/nodejs/node/issues/59362) for more details.
|
|
27
|
+
|
|
28
|
+
- feat: support path() for `createQuerySelector` ([#1456](https://github.com/lynx-family/lynx-stack/pull/1456))
|
|
29
|
+
|
|
30
|
+
- Added `getPathInfo` API to `NativeApp` and its cross-thread handler for retrieving the path from a DOM node to the root.
|
|
31
|
+
- Implemented endpoint and handler registration in both background and UI threads.
|
|
32
|
+
- Implemented `nativeApp.getPathInfo()`
|
|
33
|
+
|
|
34
|
+
- Updated dependencies []:
|
|
35
|
+
- @lynx-js/web-worker-rpc@0.15.5
|
|
36
|
+
|
|
3
37
|
## 0.15.4
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/di
|
|
|
30
30
|
export declare const multiThreadExposureChangedEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string[]]>;
|
|
31
31
|
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>;
|
|
32
32
|
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>;
|
|
33
|
+
export declare const getPathInfoEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[type: IdentifierType, identifier: string, component_id: string, first_only: boolean, root_unique_id?: number | undefined], InvokeCallbackRes>;
|
|
33
34
|
export declare const nativeModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: Cloneable, moduleName: string], any>;
|
|
34
35
|
export declare const napiModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncWithTransfer<[name: string, data: Cloneable, moduleName: string], any>;
|
|
35
36
|
export declare const getCustomSectionsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], Cloneable>;
|
package/dist/endpoints.js
CHANGED
|
@@ -21,6 +21,7 @@ export const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', fals
|
|
|
21
21
|
export const multiThreadExposureChangedEndpoint = createRpcEndpoint('multiThreadExposureChangedEndpoint', false, false);
|
|
22
22
|
export const invokeUIMethodEndpoint = createRpcEndpoint('__invokeUIMethod', false, true);
|
|
23
23
|
export const setNativePropsEndpoint = createRpcEndpoint('__setNativeProps', false, true);
|
|
24
|
+
export const getPathInfoEndpoint = createRpcEndpoint('__getPathInfo', false, true);
|
|
24
25
|
export const nativeModulesCallEndpoint = createRpcEndpoint('nativeModulesCall', false, true);
|
|
25
26
|
export const napiModulesCallEndpoint = createRpcEndpoint('napiModulesCall', false, true, true);
|
|
26
27
|
export const getCustomSectionsEndpoint = createRpcEndpoint('getCustomSections', false, true);
|
|
@@ -5,16 +5,17 @@ import type { StyleInfo } from './StyleInfo.js';
|
|
|
5
5
|
export type ElementTemplateData = {
|
|
6
6
|
id: string;
|
|
7
7
|
type: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
attributes
|
|
11
|
-
builtinAttributes
|
|
12
|
-
children
|
|
13
|
-
events
|
|
8
|
+
idSelector?: string;
|
|
9
|
+
class?: string[];
|
|
10
|
+
attributes?: Record<string, string>;
|
|
11
|
+
builtinAttributes?: Record<string, string>;
|
|
12
|
+
children?: ElementTemplateData[];
|
|
13
|
+
events?: {
|
|
14
14
|
type: LynxEventType;
|
|
15
15
|
name: string;
|
|
16
16
|
value: string;
|
|
17
17
|
}[];
|
|
18
|
+
dataset?: Record<string, string>;
|
|
18
19
|
};
|
|
19
20
|
export interface LynxTemplate {
|
|
20
21
|
styleInfo: StyleInfo;
|
|
@@ -47,6 +47,13 @@ export type SetConfigPAPI = (element: WebFiberElementImpl, config: Record<string
|
|
|
47
47
|
export type SetDatasetPAPI = (element: WebFiberElementImpl, dataset: Record<string, Cloneable>) => void;
|
|
48
48
|
export type SetIDPAPI = (element: WebFiberElementImpl, id: string | null) => void;
|
|
49
49
|
export type UpdateComponentIDPAPI = (element: WebFiberElementImpl, componentID: string) => void;
|
|
50
|
+
export type UpdateComponentInfoPAPI = (element: WebFiberElementImpl, params: {
|
|
51
|
+
componentID?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
path?: string;
|
|
54
|
+
entry?: string;
|
|
55
|
+
cssID?: number;
|
|
56
|
+
}) => void;
|
|
50
57
|
export type GetClassesPAPI = (element: WebFiberElementImpl) => string[];
|
|
51
58
|
export type CreateViewPAPI = (parentComponentUniqueID: number) => WebFiberElementImpl;
|
|
52
59
|
export type SwapElementPAPI = (childA: WebFiberElementImpl, childB: WebFiberElementImpl) => void;
|
|
@@ -82,6 +89,7 @@ interface JSErrorInfo {
|
|
|
82
89
|
release: string;
|
|
83
90
|
}
|
|
84
91
|
export type ElementFromBinaryPAPI = (templateId: string, parentComponentUniId: number) => WebFiberElementImpl[];
|
|
92
|
+
export type GetAttributeByNamePAPI = (element: WebFiberElementImpl, name: string) => string | null;
|
|
85
93
|
export interface MainThreadGlobalThis {
|
|
86
94
|
__ElementFromBinary: ElementFromBinaryPAPI;
|
|
87
95
|
__GetTemplateParts?: GetTemplatePartsPAPI;
|
|
@@ -117,6 +125,7 @@ export interface MainThreadGlobalThis {
|
|
|
117
125
|
__SetDataset: SetDatasetPAPI;
|
|
118
126
|
__SetID: SetIDPAPI;
|
|
119
127
|
__UpdateComponentID: UpdateComponentIDPAPI;
|
|
128
|
+
__UpdateComponentInfo: UpdateComponentInfoPAPI;
|
|
120
129
|
__GetClasses: GetClassesPAPI;
|
|
121
130
|
__CreateView: CreateViewPAPI;
|
|
122
131
|
__SwapElement: SwapElementPAPI;
|
|
@@ -137,6 +146,7 @@ export interface MainThreadGlobalThis {
|
|
|
137
146
|
__SetInlineStyles: SetInlineStylesPAPI;
|
|
138
147
|
__SetCSSId: SetCSSIdPAPI;
|
|
139
148
|
__GetPageElement: GetPageElementPAPI;
|
|
149
|
+
__GetAttributeByName: GetAttributeByNamePAPI;
|
|
140
150
|
__globalProps: unknown;
|
|
141
151
|
SystemInfo: typeof systemInfo;
|
|
142
152
|
globalThis?: MainThreadGlobalThis;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { systemInfo } from '../constants.js';
|
|
1
2
|
import type { Cloneable } from './Cloneable.js';
|
|
2
3
|
import type { LynxContextEventTarget } from './LynxContextEventTarget.js';
|
|
3
4
|
export interface MainThreadLynx {
|
|
@@ -7,4 +8,5 @@ export interface MainThreadLynx {
|
|
|
7
8
|
__globalProps: unknown;
|
|
8
9
|
getCustomSectionSync: (key: string) => Cloneable;
|
|
9
10
|
markPipelineTiming: (pipelineId: string, timingKey: string) => void;
|
|
11
|
+
SystemInfo: typeof systemInfo;
|
|
10
12
|
}
|
|
@@ -71,7 +71,7 @@ export declare const enum ErrorCode {
|
|
|
71
71
|
}
|
|
72
72
|
export interface InvokeCallbackRes {
|
|
73
73
|
code: ErrorCode;
|
|
74
|
-
data?:
|
|
74
|
+
data?: unknown;
|
|
75
75
|
}
|
|
76
76
|
export interface NativeApp {
|
|
77
77
|
id: string;
|
|
@@ -87,6 +87,7 @@ export interface NativeApp {
|
|
|
87
87
|
nativeModuleProxy: Record<string, any>;
|
|
88
88
|
setNativeProps: (type: IdentifierType, identifier: string, component_id: string, first_only: boolean, native_props: Record<string, unknown>, root_unique_id: number | undefined) => void;
|
|
89
89
|
invokeUIMethod: (type: IdentifierType, identifier: string, component_id: string, method: string, params: object, callback: (ret: InvokeCallbackRes) => void, root_unique_id: number) => void;
|
|
90
|
+
getPathInfo: (type: IdentifierType, identifier: string, component_id: string, first_only: boolean, callback: (ret: InvokeCallbackRes) => void, root_unique_id?: number) => void;
|
|
90
91
|
setCard(tt: NativeTTObject): void;
|
|
91
92
|
generatePipelineOptions: () => PerformancePipelineOptions;
|
|
92
93
|
onPipelineStart: (pipeline_id: string) => void;
|
|
@@ -100,6 +101,18 @@ export interface NativeApp {
|
|
|
100
101
|
* Support from Lynx 3.0
|
|
101
102
|
*/
|
|
102
103
|
profileEnd: () => void;
|
|
104
|
+
/***
|
|
105
|
+
* Support from Lynx 3.0
|
|
106
|
+
*/
|
|
107
|
+
profileMark: () => void;
|
|
108
|
+
/**
|
|
109
|
+
* Support from Lynx 3.0
|
|
110
|
+
*/
|
|
111
|
+
profileFlowId: () => number;
|
|
112
|
+
/**
|
|
113
|
+
* Support from Lynx 2.18
|
|
114
|
+
*/
|
|
115
|
+
isProfileRecording: () => boolean;
|
|
103
116
|
triggerComponentEvent(id: string, params: {
|
|
104
117
|
eventDetail: CloneableObject;
|
|
105
118
|
eventOption: CloneableObject;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { LynxTemplate } from '../types/LynxModule.js';
|
|
2
|
-
export declare function generateTemplate(template: LynxTemplate, createJsModuleUrl: (content: string) => string): Promise<LynxTemplate>;
|
|
3
|
-
export declare function generateTemplate(template: LynxTemplate, createJsModuleUrl: (content: string, name: string) => Promise<string>, templateName: string): Promise<LynxTemplate>;
|
|
2
|
+
export declare function generateTemplate(template: LynxTemplate, createJsModuleUrl: ((content: string, name: string) => Promise<string>) | ((content: string) => string), templateName?: string): Promise<LynxTemplate>;
|
|
@@ -22,7 +22,9 @@ const mainThreadInjectVars = [
|
|
|
22
22
|
'__SetDataset',
|
|
23
23
|
'__SetID',
|
|
24
24
|
'__UpdateComponentID',
|
|
25
|
+
'__UpdateComponentInfo',
|
|
25
26
|
'__GetConfig',
|
|
27
|
+
'__GetAttributeByName',
|
|
26
28
|
'__UpdateListCallbacks',
|
|
27
29
|
'__AppendElement',
|
|
28
30
|
'__ElementIsEqual',
|
|
@@ -79,50 +81,35 @@ const backgroundInjectWithBind = [
|
|
|
79
81
|
'Card',
|
|
80
82
|
'Component',
|
|
81
83
|
];
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
? async ([name, content]) => [
|
|
105
|
-
name,
|
|
106
|
-
await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
107
|
-
]
|
|
108
|
-
: async ([name, content]) => [
|
|
109
|
-
name,
|
|
110
|
-
await createJsModuleUrl(generateModuleContent(content)),
|
|
111
|
-
];
|
|
84
|
+
const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, isESM) => [
|
|
85
|
+
'//# allFunctionsCalledOnLoad\n',
|
|
86
|
+
isESM ? 'export default ' : 'globalThis.module.exports =',
|
|
87
|
+
'function(lynx_runtime) {',
|
|
88
|
+
'const module= {exports:{}};let exports = module.exports;',
|
|
89
|
+
'var {',
|
|
90
|
+
injectVars.join(','),
|
|
91
|
+
'} = lynx_runtime;',
|
|
92
|
+
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
93
|
+
';var globDynamicComponentEntry = \'__Card__\';',
|
|
94
|
+
'var {__globalProps} = lynx;',
|
|
95
|
+
'lynx_runtime._updateVars=()=>{',
|
|
96
|
+
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
97
|
+
'};\n',
|
|
98
|
+
content,
|
|
99
|
+
'\n return module.exports;}',
|
|
100
|
+
].join('');
|
|
101
|
+
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, isESM, templateName) {
|
|
102
|
+
const processEntry = async ([name, content]) => [
|
|
103
|
+
name,
|
|
104
|
+
await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
105
|
+
];
|
|
112
106
|
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
|
|
113
107
|
}
|
|
114
108
|
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
115
|
-
if (!templateName) {
|
|
116
|
-
return {
|
|
117
|
-
...template,
|
|
118
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl),
|
|
119
|
-
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
109
|
return {
|
|
123
110
|
...template,
|
|
124
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, templateName),
|
|
125
|
-
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, templateName),
|
|
111
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, true, templateName),
|
|
112
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, false, templateName),
|
|
126
113
|
};
|
|
127
114
|
}
|
|
128
115
|
//# sourceMappingURL=generateTemplate.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-constants",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"**/*.css"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lynx-js/web-worker-rpc": "0.15.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "0.15.6"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@lynx-js/offscreen-document": "0.1.3"
|