@lynx-js/web-constants 0.15.3 → 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 CHANGED
@@ -1,5 +1,31 @@
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
+
20
+ ## 0.15.4
21
+
22
+ ### Patch Changes
23
+
24
+ - feat: support `__ElementFromBinary` ([#1391](https://github.com/lynx-family/lynx-stack/pull/1391))
25
+
26
+ - Updated dependencies []:
27
+ - @lynx-js/web-worker-rpc@0.15.4
28
+
3
29
  ## 0.15.3
4
30
 
5
31
  ### Patch Changes
@@ -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);
@@ -1,6 +1,21 @@
1
1
  import type { Cloneable } from './Cloneable.js';
2
+ import type { LynxEventType } from './EventType.js';
2
3
  import type { PageConfig } from './PageConfig.js';
3
4
  import type { StyleInfo } from './StyleInfo.js';
5
+ export type ElementTemplateData = {
6
+ id: string;
7
+ type: string;
8
+ class: string[];
9
+ idSelector: string;
10
+ attributes: Record<string, string>;
11
+ builtinAttributes: Record<string, string>;
12
+ children: ElementTemplateData[];
13
+ events: {
14
+ type: LynxEventType;
15
+ name: string;
16
+ value: string;
17
+ }[];
18
+ };
4
19
  export interface LynxTemplate {
5
20
  styleInfo: StyleInfo;
6
21
  pageConfig: PageConfig;
@@ -19,6 +34,7 @@ export interface LynxTemplate {
19
34
  '/app-service.js': string;
20
35
  [key: string]: string;
21
36
  };
37
+ elementTemplate: Record<string, ElementTemplateData[]>;
22
38
  }
23
39
  export interface LynxJSModule {
24
40
  exports?: (lynx_runtime: any) => unknown;
@@ -81,7 +81,9 @@ export type GetTemplatePartsPAPI = (templateElement: WebFiberElementImpl) => Rec
81
81
  interface JSErrorInfo {
82
82
  release: string;
83
83
  }
84
+ export type ElementFromBinaryPAPI = (templateId: string, parentComponentUniId: number) => WebFiberElementImpl[];
84
85
  export interface MainThreadGlobalThis {
86
+ __ElementFromBinary: ElementFromBinaryPAPI;
85
87
  __GetTemplateParts?: GetTemplatePartsPAPI;
86
88
  __MarkPartElement: MarkPartElementPAPI;
87
89
  __MarkTemplateElement: MarkTemplateElementPAPI;
@@ -71,7 +71,7 @@ export declare const enum ErrorCode {
71
71
  }
72
72
  export interface InvokeCallbackRes {
73
73
  code: ErrorCode;
74
- data?: string;
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>;
@@ -66,6 +66,7 @@ const mainThreadInjectVars = [
66
66
  '__MarkPartElement',
67
67
  '__MarkTemplateElement',
68
68
  '__GetPageElement',
69
+ '__ElementFromBinary',
69
70
  ];
70
71
  const backgroundInjectVars = [
71
72
  'NativeModules',
@@ -78,50 +79,35 @@ const backgroundInjectWithBind = [
78
79
  'Card',
79
80
  'Component',
80
81
  ];
81
- async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, templateName) {
82
- injectVars = injectVars.concat(muteableVars);
83
- const generateModuleContent = (content) => [
84
- '//# allFunctionsCalledOnLoad\n',
85
- 'globalThis.module.exports = 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
- if (!templateName) {
100
- createJsModuleUrl;
101
- }
102
- const processEntry = templateName
103
- ? async ([name, content]) => [
104
- name,
105
- await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`),
106
- ]
107
- : async ([name, content]) => [
108
- name,
109
- await createJsModuleUrl(generateModuleContent(content)),
110
- ];
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
+ ];
111
104
  return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
112
105
  }
113
106
  export async function generateTemplate(template, createJsModuleUrl, templateName) {
114
- if (!templateName) {
115
- return {
116
- ...template,
117
- lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl),
118
- manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl),
119
- };
120
- }
121
107
  return {
122
108
  ...template,
123
- lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, templateName),
124
- 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),
125
111
  };
126
112
  }
127
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",
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.3"
26
+ "@lynx-js/web-worker-rpc": "0.15.5"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lynx-js/offscreen-document": "0.1.3"