@lynx-js/web-constants-canary 0.15.8-canary-20250827-60c81a1e → 0.16.0-canary-20250828-c1f8715a
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 +15 -3
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -7
- package/dist/types/JSRealm.d.ts +5 -0
- package/dist/types/JSRealm.js +2 -0
- package/dist/types/LynxModule.d.ts +1 -0
- package/dist/types/MainThreadGlobalThis.d.ts +0 -5
- package/dist/types/MainThreadLynx.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/generateTemplate.js +72 -99
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.16.0-canary-20250828064127-c1f8715a81b2e69ff46fc363013626db4468c209
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- refactor: provide the mts a real globalThis ([#1589](https://github.com/lynx-family/lynx-stack/pull/1589))
|
|
8
|
+
|
|
9
|
+
Before this change, We create a function wrapper and a fake globalThis for Javascript code.
|
|
10
|
+
|
|
11
|
+
This caused some issues.
|
|
12
|
+
|
|
13
|
+
After this change, we will create an iframe for createing an isolated Javascript context.
|
|
14
|
+
|
|
15
|
+
This means the globalThis will be the real one.
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
6
18
|
|
|
7
19
|
- fix: the SystemInfo in bts should be assigned to the globalThis ([#1599](https://github.com/lynx-family/lynx-stack/pull/1599))
|
|
8
20
|
|
|
9
|
-
- Updated dependencies []:
|
|
10
|
-
- @lynx-js/web-worker-rpc@0.
|
|
21
|
+
- Updated dependencies [[`c1f8715`](https://github.com/lynx-family/lynx-stack/commit/c1f8715a81b2e69ff46fc363013626db4468c209)]:
|
|
22
|
+
- @lynx-js/web-worker-rpc@0.16.0-canary-20250828064127-c1f8715a81b2e69ff46fc363013626db4468c209
|
|
11
23
|
|
|
12
24
|
## 0.15.7
|
|
13
25
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -11,7 +11,5 @@ export declare const lynxPartIdAttribute: "l-part";
|
|
|
11
11
|
export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
|
|
12
12
|
export declare const lynxDefaultOverflowVisibleAttribute: "lynx-default-overflow-visible";
|
|
13
13
|
export declare const __lynx_timing_flag: "__lynx_timing_flag";
|
|
14
|
-
export declare const globalMuteableVars: readonly ["registerDataProcessor", "registerWorkletInternal", "lynxWorkletImpl", "runWorklet"];
|
|
15
14
|
export declare const systemInfo: Record<string, string | number>;
|
|
16
15
|
export declare const inShadowRootStyles: string[];
|
|
17
|
-
export declare const globalDisallowedVars: string[];
|
package/dist/constants.js
CHANGED
|
@@ -14,12 +14,6 @@ export const lynxPartIdAttribute = 'l-part';
|
|
|
14
14
|
export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
15
15
|
export const lynxDefaultOverflowVisibleAttribute = 'lynx-default-overflow-visible';
|
|
16
16
|
export const __lynx_timing_flag = '__lynx_timing_flag';
|
|
17
|
-
export const globalMuteableVars = [
|
|
18
|
-
'registerDataProcessor',
|
|
19
|
-
'registerWorkletInternal',
|
|
20
|
-
'lynxWorkletImpl',
|
|
21
|
-
'runWorklet',
|
|
22
|
-
];
|
|
23
17
|
export const systemInfo = {
|
|
24
18
|
platform: 'web',
|
|
25
19
|
lynxSdkVersion: '3.0',
|
|
@@ -33,5 +27,4 @@ export const inShadowRootStyles = [
|
|
|
33
27
|
overflow: visible;
|
|
34
28
|
}`,
|
|
35
29
|
];
|
|
36
|
-
export const globalDisallowedVars = ['navigator', 'postMessage'];
|
|
37
30
|
//# sourceMappingURL=constants.js.map
|
|
@@ -161,11 +161,6 @@ export interface MainThreadGlobalThis {
|
|
|
161
161
|
__FlushElementTree: (_subTree: unknown, options: FlushElementTreeOptions) => void;
|
|
162
162
|
_I18nResourceTranslation: (options: I18nResourceTranslationOptions) => unknown | undefined;
|
|
163
163
|
_AddEventListener: (...args: unknown[]) => void;
|
|
164
|
-
/**
|
|
165
|
-
* private fields
|
|
166
|
-
*/
|
|
167
|
-
_updateVars: () => void;
|
|
168
|
-
__lynxGlobalBindingValues: Record<string, unknown>;
|
|
169
164
|
renderPage: ((data: unknown) => void) | undefined;
|
|
170
165
|
updatePage?: (data: Cloneable, options?: Record<string, string>) => void;
|
|
171
166
|
runWorklet?: (obj: unknown, event: unknown) => void;
|
|
@@ -9,4 +9,8 @@ export interface MainThreadLynx {
|
|
|
9
9
|
getCustomSectionSync: (key: string) => Cloneable;
|
|
10
10
|
markPipelineTiming: (pipelineId: string, timingKey: string) => void;
|
|
11
11
|
SystemInfo: typeof systemInfo;
|
|
12
|
+
setTimeout: typeof setTimeout;
|
|
13
|
+
clearTimeout: typeof clearTimeout;
|
|
14
|
+
setInterval: typeof setInterval;
|
|
15
|
+
clearInterval: typeof clearInterval;
|
|
12
16
|
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,117 +1,90 @@
|
|
|
1
1
|
// Copyright 2023 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'__SetInlineStyles',
|
|
60
|
-
'__SetCSSId',
|
|
61
|
-
'__OnLifecycleEvent',
|
|
62
|
-
'__FlushElementTree',
|
|
63
|
-
'__LoadLepusChunk',
|
|
64
|
-
'SystemInfo',
|
|
65
|
-
'_I18nResourceTranslation',
|
|
66
|
-
'_AddEventListener',
|
|
67
|
-
'__GetTemplateParts',
|
|
68
|
-
'__MarkPartElement',
|
|
69
|
-
'__MarkTemplateElement',
|
|
70
|
-
'__GetPageElement',
|
|
71
|
-
'__ElementFromBinary',
|
|
4
|
+
const currentSupportedTemplateVersion = 2;
|
|
5
|
+
const globalDisallowedVars = ['navigator', 'postMessage'];
|
|
6
|
+
const templateUpgraders = [
|
|
7
|
+
(template) => {
|
|
8
|
+
const defaultInjectStr = [
|
|
9
|
+
'Card',
|
|
10
|
+
'setTimeout',
|
|
11
|
+
'setInterval',
|
|
12
|
+
'clearInterval',
|
|
13
|
+
'clearTimeout',
|
|
14
|
+
'NativeModules',
|
|
15
|
+
'Component',
|
|
16
|
+
'ReactLynx',
|
|
17
|
+
'nativeAppId',
|
|
18
|
+
'Behavior',
|
|
19
|
+
'LynxJSBI',
|
|
20
|
+
'lynx',
|
|
21
|
+
// BOM API
|
|
22
|
+
'window',
|
|
23
|
+
'document',
|
|
24
|
+
'frames',
|
|
25
|
+
'location',
|
|
26
|
+
'navigator',
|
|
27
|
+
'localStorage',
|
|
28
|
+
'history',
|
|
29
|
+
'Caches',
|
|
30
|
+
'screen',
|
|
31
|
+
'alert',
|
|
32
|
+
'confirm',
|
|
33
|
+
'prompt',
|
|
34
|
+
'fetch',
|
|
35
|
+
'XMLHttpRequest',
|
|
36
|
+
'__WebSocket__', // We would provide `WebSocket` using `ProvidePlugin`
|
|
37
|
+
'webkit',
|
|
38
|
+
'Reporter',
|
|
39
|
+
'print',
|
|
40
|
+
'global',
|
|
41
|
+
// Lynx API
|
|
42
|
+
'requestAnimationFrame',
|
|
43
|
+
'cancelAnimationFrame',
|
|
44
|
+
].join(',');
|
|
45
|
+
/**
|
|
46
|
+
* The template version 1 has no module wrapper for bts code
|
|
47
|
+
*/
|
|
48
|
+
template.manifest = Object.fromEntries(Object.entries(template.manifest).map(([key, value]) => [
|
|
49
|
+
key,
|
|
50
|
+
`{init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:null}; ${value}\n return module.exports; } }`,
|
|
51
|
+
]));
|
|
52
|
+
template.lepusCode = Object.fromEntries(Object.entries(template.lepusCode).map(([key, value]) => [
|
|
53
|
+
key,
|
|
54
|
+
`(()=>{${value}\n})();`,
|
|
55
|
+
]));
|
|
56
|
+
template.version = 2;
|
|
57
|
+
return template;
|
|
58
|
+
},
|
|
72
59
|
];
|
|
73
|
-
const
|
|
74
|
-
'NativeModules',
|
|
75
|
-
'globalThis',
|
|
76
|
-
'lynx',
|
|
77
|
-
'lynxCoreInject',
|
|
78
|
-
];
|
|
79
|
-
const backgroundInjectWithBind = [
|
|
80
|
-
'Card',
|
|
81
|
-
'Component',
|
|
82
|
-
];
|
|
83
|
-
const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, globalDisallowedVars, isESM) => [
|
|
60
|
+
const generateModuleContent = (content) => [
|
|
84
61
|
'//# allFunctionsCalledOnLoad\n',
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
'const module= {exports:{}};let exports = module.exports;',
|
|
88
|
-
'var {',
|
|
89
|
-
injectVars.join(','),
|
|
90
|
-
'} = lynx_runtime;',
|
|
91
|
-
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
92
|
-
';var globDynamicComponentEntry = \'__Card__\';',
|
|
93
|
-
globalDisallowedVars.length !== 0
|
|
94
|
-
? `var ${globalDisallowedVars.join('=')}=undefined;`
|
|
95
|
-
: '',
|
|
96
|
-
'var {__globalProps} = lynx;',
|
|
97
|
-
'lynx_runtime._updateVars=()=>{',
|
|
98
|
-
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
99
|
-
'};\n',
|
|
62
|
+
'"use strict";\n',
|
|
63
|
+
`(() => {const ${globalDisallowedVars.join('=void 0,')}=void 0;module.exports = `,
|
|
100
64
|
content,
|
|
101
|
-
'\n
|
|
65
|
+
'\n})()',
|
|
102
66
|
].join('');
|
|
103
|
-
async function generateJavascriptUrl(obj,
|
|
67
|
+
async function generateJavascriptUrl(obj, createJsModuleUrl, templateName) {
|
|
104
68
|
const processEntry = async ([name, content]) => [
|
|
105
69
|
name,
|
|
106
|
-
await createJsModuleUrl(generateModuleContent(content
|
|
70
|
+
await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
107
71
|
];
|
|
108
72
|
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
|
|
109
73
|
}
|
|
110
74
|
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
75
|
+
template.version = template.version ?? 1;
|
|
76
|
+
if (template.version > currentSupportedTemplateVersion) {
|
|
77
|
+
throw new Error(`Unsupported template, please upgrade your web-platform dependencies`);
|
|
78
|
+
}
|
|
79
|
+
let upgrader;
|
|
80
|
+
while (template.version < currentSupportedTemplateVersion
|
|
81
|
+
&& (upgrader = templateUpgraders[template.version - 1])) {
|
|
82
|
+
template = upgrader(template);
|
|
83
|
+
}
|
|
111
84
|
return {
|
|
112
85
|
...template,
|
|
113
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode,
|
|
114
|
-
manifest: await generateJavascriptUrl(template.manifest,
|
|
86
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, templateName),
|
|
87
|
+
manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, templateName),
|
|
115
88
|
};
|
|
116
89
|
}
|
|
117
90
|
//# sourceMappingURL=generateTemplate.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-constants-canary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-canary-20250828-c1f8715a",
|
|
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": "npm:@lynx-js/web-worker-rpc-canary@0.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.0-canary-20250828-c1f8715a"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.3"
|