@lynx-js/web-constants 0.15.4 → 0.15.5
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 +17 -0
- package/dist/endpoints.d.ts +1 -0
- package/dist/endpoints.js +1 -0
- package/dist/types/NativeApp.d.ts +14 -1
- package/dist/utils/generateTemplate.d.ts +1 -2
- package/dist/utils/generateTemplate.js +24 -39
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.15.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: load main-thread chunk in ESM format ([#1437](https://github.com/lynx-family/lynx-stack/pull/1437))
|
|
8
|
+
|
|
9
|
+
See [nodejs/node#59362](https://github.com/nodejs/node/issues/59362) for more details.
|
|
10
|
+
|
|
11
|
+
- feat: support path() for `createQuerySelector` ([#1456](https://github.com/lynx-family/lynx-stack/pull/1456))
|
|
12
|
+
|
|
13
|
+
- Added `getPathInfo` API to `NativeApp` and its cross-thread handler for retrieving the path from a DOM node to the root.
|
|
14
|
+
- Implemented endpoint and handler registration in both background and UI threads.
|
|
15
|
+
- Implemented `nativeApp.getPathInfo()`
|
|
16
|
+
|
|
17
|
+
- Updated dependencies []:
|
|
18
|
+
- @lynx-js/web-worker-rpc@0.15.5
|
|
19
|
+
|
|
3
20
|
## 0.15.4
|
|
4
21
|
|
|
5
22
|
### 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);
|
|
@@ -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>;
|
|
@@ -79,50 +79,35 @@ const backgroundInjectWithBind = [
|
|
|
79
79
|
'Card',
|
|
80
80
|
'Component',
|
|
81
81
|
];
|
|
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
|
-
];
|
|
82
|
+
const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, isESM) => [
|
|
83
|
+
'//# allFunctionsCalledOnLoad\n',
|
|
84
|
+
isESM ? 'export default ' : 'globalThis.module.exports =',
|
|
85
|
+
'function(lynx_runtime) {',
|
|
86
|
+
'const module= {exports:{}};let exports = module.exports;',
|
|
87
|
+
'var {',
|
|
88
|
+
injectVars.join(','),
|
|
89
|
+
'} = lynx_runtime;',
|
|
90
|
+
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
91
|
+
';var globDynamicComponentEntry = \'__Card__\';',
|
|
92
|
+
'var {__globalProps} = lynx;',
|
|
93
|
+
'lynx_runtime._updateVars=()=>{',
|
|
94
|
+
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
95
|
+
'};\n',
|
|
96
|
+
content,
|
|
97
|
+
'\n return module.exports;}',
|
|
98
|
+
].join('');
|
|
99
|
+
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, isESM, templateName) {
|
|
100
|
+
const processEntry = async ([name, content]) => [
|
|
101
|
+
name,
|
|
102
|
+
await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
103
|
+
];
|
|
112
104
|
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
|
|
113
105
|
}
|
|
114
106
|
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
107
|
return {
|
|
123
108
|
...template,
|
|
124
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, templateName),
|
|
125
|
-
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, templateName),
|
|
109
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, true, templateName),
|
|
110
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, false, templateName),
|
|
126
111
|
};
|
|
127
112
|
}
|
|
128
113
|
//# 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.5",
|
|
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.5"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@lynx-js/offscreen-document": "0.1.3"
|