@lynx-js/web-constants 0.15.6 → 0.15.7
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 +9 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/utils/generateTemplate.js +9 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.15.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: globalThis is never accessible in MTS ([#1531](https://github.com/lynx-family/lynx-stack/pull/1531))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @lynx-js/web-worker-rpc@0.15.7
|
|
11
|
+
|
|
3
12
|
## 0.15.6
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare const __lynx_timing_flag: "__lynx_timing_flag";
|
|
|
14
14
|
export declare const globalMuteableVars: readonly ["registerDataProcessor", "registerWorkletInternal", "lynxWorkletImpl", "runWorklet"];
|
|
15
15
|
export declare const systemInfo: Record<string, string | number>;
|
|
16
16
|
export declare const inShadowRootStyles: string[];
|
|
17
|
+
export declare const globalDisallowedVars: string[];
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
import { globalMuteableVars } from '../constants.js';
|
|
4
|
+
import { globalDisallowedVars, globalMuteableVars } from '../constants.js';
|
|
5
5
|
const mainThreadInjectVars = [
|
|
6
6
|
'lynx',
|
|
7
7
|
'globalThis',
|
|
@@ -81,7 +81,7 @@ const backgroundInjectWithBind = [
|
|
|
81
81
|
'Card',
|
|
82
82
|
'Component',
|
|
83
83
|
];
|
|
84
|
-
const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, isESM) => [
|
|
84
|
+
const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, globalDisallowedVars, isESM) => [
|
|
85
85
|
'//# allFunctionsCalledOnLoad\n',
|
|
86
86
|
isESM ? 'export default ' : 'globalThis.module.exports =',
|
|
87
87
|
'function(lynx_runtime) {',
|
|
@@ -91,6 +91,9 @@ const generateModuleContent = (content, injectVars, injectWithBind, muteableVars
|
|
|
91
91
|
'} = lynx_runtime;',
|
|
92
92
|
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
93
93
|
';var globDynamicComponentEntry = \'__Card__\';',
|
|
94
|
+
globalDisallowedVars.length !== 0
|
|
95
|
+
? `var ${globalDisallowedVars.join('=')}=undefined;`
|
|
96
|
+
: '',
|
|
94
97
|
'var {__globalProps} = lynx;',
|
|
95
98
|
'lynx_runtime._updateVars=()=>{',
|
|
96
99
|
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
@@ -98,18 +101,18 @@ const generateModuleContent = (content, injectVars, injectWithBind, muteableVars
|
|
|
98
101
|
content,
|
|
99
102
|
'\n return module.exports;}',
|
|
100
103
|
].join('');
|
|
101
|
-
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, isESM, templateName) {
|
|
104
|
+
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, globalDisallowedVars, createJsModuleUrl, isESM, templateName) {
|
|
102
105
|
const processEntry = async ([name, content]) => [
|
|
103
106
|
name,
|
|
104
|
-
await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
107
|
+
await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, globalDisallowedVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
105
108
|
];
|
|
106
109
|
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
|
|
107
110
|
}
|
|
108
111
|
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
109
112
|
return {
|
|
110
113
|
...template,
|
|
111
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, true, templateName),
|
|
112
|
-
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, false, templateName),
|
|
114
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, templateName ? [] : globalDisallowedVars, createJsModuleUrl, true, templateName),
|
|
115
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], templateName ? [] : globalDisallowedVars, createJsModuleUrl, false, templateName),
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
//# 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.7",
|
|
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.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@lynx-js/offscreen-document": "0.1.3"
|