@lynx-js/web-constants 0.14.1 → 0.15.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 +34 -0
- package/dist/endpoints.d.ts +3 -2
- package/dist/endpoints.js +1 -0
- package/dist/types/MarkTiming.d.ts +5 -0
- package/dist/types/MarkTiming.js +5 -0
- package/dist/types/StyleInfo.d.ts +4 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/LynxCrossThreadContext.js +3 -0
- package/dist/utils/generateTemplate.d.ts +3 -0
- package/dist/utils/generateTemplate.js +123 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/markTiming.d.ts +15 -0
- package/dist/utils/markTiming.js +26 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- refactor: move exposure system to web-core ([#1254](https://github.com/lynx-family/lynx-stack/pull/1254))
|
|
8
|
+
|
|
9
|
+
**THIS IS A BREAKING CHANGE**
|
|
10
|
+
|
|
11
|
+
**You'll need to upgrade your @lynx-js/web-elements to >= 0.8.0**
|
|
12
|
+
|
|
13
|
+
For SSR and better performance, we moved the lynx's exposure system from web-element to web-core.
|
|
14
|
+
|
|
15
|
+
Before this commit, we create Intersection observers by creating HTMLElements.
|
|
16
|
+
|
|
17
|
+
After this commit, we will create such Intersection observers after dom stabled.
|
|
18
|
+
|
|
19
|
+
Also, the setInterval for exposure has been removed, now we use an on time lazy timer for such features.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies []:
|
|
24
|
+
- @lynx-js/web-worker-rpc@0.15.0
|
|
25
|
+
|
|
26
|
+
## 0.14.2
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- feat: merge multiple markTiming RPC communication events together and send them together, which can effectively reduce the number of RPC communications. ([#1178](https://github.com/lynx-family/lynx-stack/pull/1178))
|
|
31
|
+
|
|
32
|
+
- chore: extract shared logic from web-core and web-core-server's loadTemplate into a unified generateTemplate function ([#1211](https://github.com/lynx-family/lynx-stack/pull/1211))
|
|
33
|
+
|
|
34
|
+
- Updated dependencies []:
|
|
35
|
+
- @lynx-js/web-worker-rpc@0.14.2
|
|
36
|
+
|
|
3
37
|
## 0.14.1
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Cloneable, CloneableObject } from './types/Cloneable.js';
|
|
|
3
3
|
import type { StartMainThreadContextConfig } from './types/MainThreadStartConfigs.js';
|
|
4
4
|
import type { IdentifierType, InvokeCallbackRes } from './types/NativeApp.js';
|
|
5
5
|
import type { ElementAnimationOptions } from './types/Element.js';
|
|
6
|
-
import type { BackMainThreadContextConfig } from './types/index.js';
|
|
6
|
+
import type { BackMainThreadContextConfig, MarkTiming } from './types/index.js';
|
|
7
7
|
export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
|
|
8
8
|
exposures: ExposureWorkerEvent[];
|
|
9
9
|
disExposures: ExposureWorkerEvent[];
|
|
@@ -27,12 +27,13 @@ export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-
|
|
|
27
27
|
export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Error, unknown, string]>;
|
|
28
28
|
export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[operations: (string | number)[]], void>;
|
|
29
29
|
export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: unknown], void>;
|
|
30
|
+
export declare const multiThreadExposureChangedEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string[]]>;
|
|
30
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>;
|
|
31
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>;
|
|
32
33
|
export declare const nativeModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: Cloneable, moduleName: string], any>;
|
|
33
34
|
export declare const napiModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncWithTransfer<[name: string, data: Cloneable, moduleName: string], any>;
|
|
34
35
|
export declare const getCustomSectionsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], Cloneable>;
|
|
35
|
-
export declare const markTimingEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[
|
|
36
|
+
export declare const markTimingEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[MarkTiming[]]>;
|
|
36
37
|
export declare const postTimingFlagsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingFlags: string[], pipelineId: string | undefined]>;
|
|
37
38
|
export declare const triggerComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[id: string, params: {
|
|
38
39
|
eventDetail: CloneableObject;
|
package/dist/endpoints.js
CHANGED
|
@@ -18,6 +18,7 @@ export const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, t
|
|
|
18
18
|
export const reportErrorEndpoint = createRpcEndpoint('reportError', false, false);
|
|
19
19
|
export const flushElementTreeEndpoint = createRpcEndpoint('flushElementTree', false, true);
|
|
20
20
|
export const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', false, true);
|
|
21
|
+
export const multiThreadExposureChangedEndpoint = createRpcEndpoint('multiThreadExposureChangedEndpoint', false, false);
|
|
21
22
|
export const invokeUIMethodEndpoint = createRpcEndpoint('__invokeUIMethod', false, true);
|
|
22
23
|
export const setNativePropsEndpoint = createRpcEndpoint('__setNativeProps', false, true);
|
|
23
24
|
export const nativeModulesCallEndpoint = createRpcEndpoint('nativeModulesCall', false, true);
|
|
@@ -16,7 +16,10 @@ export interface OneInfo {
|
|
|
16
16
|
export interface StyleInfo {
|
|
17
17
|
[cssId: string]: OneInfo;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* CSS Info for Old Generation CSS System
|
|
21
|
+
*/
|
|
22
|
+
export interface CssOGInfo {
|
|
20
23
|
[cssId: string]: {
|
|
21
24
|
[className: string]: [string, string][];
|
|
22
25
|
};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2023 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.
|
|
1
4
|
import { DispatchEventResult, } from '../types/LynxContextEventTarget.js';
|
|
2
5
|
export class LynxCrossThreadContext extends EventTarget {
|
|
3
6
|
_config;
|
|
@@ -0,0 +1,3 @@
|
|
|
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>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Copyright 2023 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.
|
|
4
|
+
import { globalMuteableVars } from '../constants.js';
|
|
5
|
+
const mainThreadInjectVars = [
|
|
6
|
+
'lynx',
|
|
7
|
+
'globalThis',
|
|
8
|
+
'_ReportError',
|
|
9
|
+
'_SetSourceMapRelease',
|
|
10
|
+
'__AddConfig',
|
|
11
|
+
'__AddDataset',
|
|
12
|
+
'__GetAttributes',
|
|
13
|
+
'__GetComponentID',
|
|
14
|
+
'__GetDataByKey',
|
|
15
|
+
'__GetDataset',
|
|
16
|
+
'__GetElementConfig',
|
|
17
|
+
'__GetElementUniqueID',
|
|
18
|
+
'__GetID',
|
|
19
|
+
'__GetTag',
|
|
20
|
+
'__SetAttribute',
|
|
21
|
+
'__SetConfig',
|
|
22
|
+
'__SetDataset',
|
|
23
|
+
'__SetID',
|
|
24
|
+
'__UpdateComponentID',
|
|
25
|
+
'__GetConfig',
|
|
26
|
+
'__UpdateListCallbacks',
|
|
27
|
+
'__AppendElement',
|
|
28
|
+
'__ElementIsEqual',
|
|
29
|
+
'__FirstElement',
|
|
30
|
+
'__GetChildren',
|
|
31
|
+
'__GetParent',
|
|
32
|
+
'__InsertElementBefore',
|
|
33
|
+
'__LastElement',
|
|
34
|
+
'__NextElement',
|
|
35
|
+
'__RemoveElement',
|
|
36
|
+
'__ReplaceElement',
|
|
37
|
+
'__ReplaceElements',
|
|
38
|
+
'__SwapElement',
|
|
39
|
+
'__CreateComponent',
|
|
40
|
+
'__CreateElement',
|
|
41
|
+
'__CreatePage',
|
|
42
|
+
'__CreateView',
|
|
43
|
+
'__CreateText',
|
|
44
|
+
'__CreateRawText',
|
|
45
|
+
'__CreateImage',
|
|
46
|
+
'__CreateScrollView',
|
|
47
|
+
'__CreateWrapperElement',
|
|
48
|
+
'__CreateList',
|
|
49
|
+
'__AddEvent',
|
|
50
|
+
'__GetEvent',
|
|
51
|
+
'__GetEvents',
|
|
52
|
+
'__SetEvents',
|
|
53
|
+
'__AddClass',
|
|
54
|
+
'__SetClasses',
|
|
55
|
+
'__GetClasses',
|
|
56
|
+
'__AddInlineStyle',
|
|
57
|
+
'__SetInlineStyles',
|
|
58
|
+
'__SetCSSId',
|
|
59
|
+
'__OnLifecycleEvent',
|
|
60
|
+
'__FlushElementTree',
|
|
61
|
+
'__LoadLepusChunk',
|
|
62
|
+
'SystemInfo',
|
|
63
|
+
'_I18nResourceTranslation',
|
|
64
|
+
'_AddEventListener',
|
|
65
|
+
];
|
|
66
|
+
const backgroundInjectVars = [
|
|
67
|
+
'NativeModules',
|
|
68
|
+
'globalThis',
|
|
69
|
+
'lynx',
|
|
70
|
+
'lynxCoreInject',
|
|
71
|
+
'SystemInfo',
|
|
72
|
+
];
|
|
73
|
+
const backgroundInjectWithBind = [
|
|
74
|
+
'Card',
|
|
75
|
+
'Component',
|
|
76
|
+
];
|
|
77
|
+
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, templateName) {
|
|
78
|
+
injectVars = injectVars.concat(muteableVars);
|
|
79
|
+
const generateModuleContent = (content) => [
|
|
80
|
+
'//# allFunctionsCalledOnLoad\n',
|
|
81
|
+
'globalThis.module.exports = function(lynx_runtime) {',
|
|
82
|
+
'const module= {exports:{}};let exports = module.exports;',
|
|
83
|
+
'var {',
|
|
84
|
+
injectVars.join(','),
|
|
85
|
+
'} = lynx_runtime;',
|
|
86
|
+
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
87
|
+
';var globDynamicComponentEntry = \'__Card__\';',
|
|
88
|
+
'var {__globalProps} = lynx;',
|
|
89
|
+
'lynx_runtime._updateVars=()=>{',
|
|
90
|
+
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
91
|
+
'};\n',
|
|
92
|
+
content,
|
|
93
|
+
'\n return module.exports;}',
|
|
94
|
+
].join('');
|
|
95
|
+
if (!templateName) {
|
|
96
|
+
createJsModuleUrl;
|
|
97
|
+
}
|
|
98
|
+
const processEntry = templateName
|
|
99
|
+
? async ([name, content]) => [
|
|
100
|
+
name,
|
|
101
|
+
await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
102
|
+
]
|
|
103
|
+
: async ([name, content]) => [
|
|
104
|
+
name,
|
|
105
|
+
await createJsModuleUrl(generateModuleContent(content)),
|
|
106
|
+
];
|
|
107
|
+
return Promise.all(Object.entries(obj).map(processEntry)).then(Object.fromEntries);
|
|
108
|
+
}
|
|
109
|
+
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
110
|
+
if (!templateName) {
|
|
111
|
+
return {
|
|
112
|
+
...template,
|
|
113
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl),
|
|
114
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
...template,
|
|
119
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, templateName),
|
|
120
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, templateName),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=generateTemplate.js.map
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
// Copyright 2023 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.
|
|
1
4
|
export { LynxCrossThreadContext } from './LynxCrossThreadContext.js';
|
|
5
|
+
export { dispatchMarkTiming, flushMarkTiming } from './markTiming.js';
|
|
6
|
+
export { generateTemplate } from './generateTemplate.js';
|
|
2
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MarkTiming } from '../types/MarkTiming.js';
|
|
2
|
+
export declare const dispatchMarkTiming: ({ timingKey, pipelineId, timeStamp, markTiming, cacheMarkTimings }: {
|
|
3
|
+
timingKey: string;
|
|
4
|
+
pipelineId?: string;
|
|
5
|
+
timeStamp?: number;
|
|
6
|
+
markTiming: (markTimings: MarkTiming[]) => void;
|
|
7
|
+
cacheMarkTimings: {
|
|
8
|
+
records: MarkTiming[];
|
|
9
|
+
timeout: NodeJS.Timeout | null;
|
|
10
|
+
};
|
|
11
|
+
}) => void;
|
|
12
|
+
export declare const flushMarkTiming: (markTiming: (markTimings: MarkTiming[]) => void, cacheMarkTimings: {
|
|
13
|
+
records: MarkTiming[];
|
|
14
|
+
timeout: NodeJS.Timeout | null;
|
|
15
|
+
}) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2023 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.
|
|
4
|
+
export const dispatchMarkTiming = ({ timingKey, pipelineId, timeStamp, markTiming, cacheMarkTimings }) => {
|
|
5
|
+
cacheMarkTimings.records.push({
|
|
6
|
+
timingKey,
|
|
7
|
+
pipelineId,
|
|
8
|
+
timeStamp: timeStamp ?? performance.now() + performance.timeOrigin,
|
|
9
|
+
});
|
|
10
|
+
if (!cacheMarkTimings.timeout) {
|
|
11
|
+
cacheMarkTimings.timeout = setTimeout(() => {
|
|
12
|
+
markTiming(cacheMarkTimings.records);
|
|
13
|
+
cacheMarkTimings.records = [];
|
|
14
|
+
cacheMarkTimings.timeout = null;
|
|
15
|
+
}, 500);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const flushMarkTiming = (markTiming, cacheMarkTimings) => {
|
|
19
|
+
markTiming(cacheMarkTimings.records);
|
|
20
|
+
cacheMarkTimings.records = [];
|
|
21
|
+
if (cacheMarkTimings.timeout) {
|
|
22
|
+
clearTimeout(cacheMarkTimings.timeout);
|
|
23
|
+
cacheMarkTimings.timeout = null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=markTiming.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-constants",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"**/*.css"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "0.15.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@lynx-js/offscreen-document": "0.1.
|
|
29
|
+
"@lynx-js/offscreen-document": "0.1.3"
|
|
30
30
|
}
|
|
31
31
|
}
|