@lynx-js/web-constants-canary 0.17.1 → 0.17.2-canary-20250928-a35a2452
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,19 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: support load bts chunk from remote address ([#1834](https://github.com/lynx-family/lynx-stack/pull/1834))
|
|
8
|
+
|
|
9
|
+
- re-support chunk splitting
|
|
10
|
+
- support lynx.requireModule with a json file
|
|
11
|
+
- support lynx.requireModule, lynx.requireModuleAsync with a remote url
|
|
12
|
+
- support to add a breakpoint in chrome after reloading the web page
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @lynx-js/web-worker-rpc@0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
|
|
16
|
+
|
|
3
17
|
## 0.17.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -205,25 +219,25 @@
|
|
|
205
219
|
lynxView.initI18nResources = [
|
|
206
220
|
{
|
|
207
221
|
options: {
|
|
208
|
-
locale:
|
|
209
|
-
channel:
|
|
210
|
-
fallback_url:
|
|
222
|
+
locale: "en",
|
|
223
|
+
channel: "1",
|
|
224
|
+
fallback_url: "",
|
|
211
225
|
},
|
|
212
226
|
resource: {
|
|
213
|
-
hello:
|
|
214
|
-
lynx:
|
|
227
|
+
hello: "hello",
|
|
228
|
+
lynx: "lynx web platform1",
|
|
215
229
|
},
|
|
216
230
|
},
|
|
217
231
|
];
|
|
218
|
-
lynxView.addEventListener(
|
|
232
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
219
233
|
console.log(e);
|
|
220
234
|
});
|
|
221
235
|
|
|
222
236
|
// mts
|
|
223
237
|
_I18nResourceTranslation({
|
|
224
|
-
locale:
|
|
225
|
-
channel:
|
|
226
|
-
fallback_url:
|
|
238
|
+
locale: "en",
|
|
239
|
+
channel: "1",
|
|
240
|
+
fallback_url: "",
|
|
227
241
|
});
|
|
228
242
|
```
|
|
229
243
|
|
|
@@ -462,8 +476,8 @@
|
|
|
462
476
|
}
|
|
463
477
|
};`,
|
|
464
478
|
],
|
|
465
|
-
{ type:
|
|
466
|
-
)
|
|
479
|
+
{ type: "text/javascript" }
|
|
480
|
+
)
|
|
467
481
|
),
|
|
468
482
|
};
|
|
469
483
|
lynxView.nativeModulesMap = nativeModulesMap;
|
|
@@ -549,8 +563,8 @@
|
|
|
549
563
|
};
|
|
550
564
|
};`,
|
|
551
565
|
],
|
|
552
|
-
{ type:
|
|
553
|
-
)
|
|
566
|
+
{ type: "text/javascript" }
|
|
567
|
+
)
|
|
554
568
|
);
|
|
555
569
|
|
|
556
570
|
const color_methods = URL.createObjectURL(
|
|
@@ -565,8 +579,8 @@
|
|
|
565
579
|
};
|
|
566
580
|
};`,
|
|
567
581
|
],
|
|
568
|
-
{ type:
|
|
569
|
-
)
|
|
582
|
+
{ type: "text/javascript" }
|
|
583
|
+
)
|
|
570
584
|
);
|
|
571
585
|
|
|
572
586
|
lynxView.napiModuleMap = {
|
|
@@ -583,7 +597,7 @@
|
|
|
583
597
|
|
|
584
598
|
```js
|
|
585
599
|
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
586
|
-
if (name ===
|
|
600
|
+
if (name === "getColor" && moduleName === "color_methods") {
|
|
587
601
|
return data.color;
|
|
588
602
|
}
|
|
589
603
|
};
|
|
@@ -647,8 +661,8 @@
|
|
|
647
661
|
}
|
|
648
662
|
};`,
|
|
649
663
|
],
|
|
650
|
-
{ type:
|
|
651
|
-
)
|
|
664
|
+
{ type: "text/javascript" }
|
|
665
|
+
)
|
|
652
666
|
);
|
|
653
667
|
```
|
|
654
668
|
|
|
@@ -660,7 +674,7 @@
|
|
|
660
674
|
|
|
661
675
|
```js
|
|
662
676
|
lynxView.onNativeModulesCall = (name, data, callback) => {
|
|
663
|
-
if (name ===
|
|
677
|
+
if (name === "getColor") {
|
|
664
678
|
callback(data.color);
|
|
665
679
|
}
|
|
666
680
|
};
|
|
@@ -670,7 +684,7 @@
|
|
|
670
684
|
|
|
671
685
|
```js
|
|
672
686
|
lynxView.onNativeModulesCall = (name, data, moduleName) => {
|
|
673
|
-
if (name ===
|
|
687
|
+
if (name === "getColor" && moduleName === "bridge") {
|
|
674
688
|
return data.color;
|
|
675
689
|
}
|
|
676
690
|
};
|
|
@@ -39,6 +39,9 @@ export interface LynxTemplate {
|
|
|
39
39
|
version?: number;
|
|
40
40
|
appType: 'card' | 'lazy';
|
|
41
41
|
}
|
|
42
|
+
export type BTSChunkEntry = (postMessage: undefined, module: {
|
|
43
|
+
exports: unknown;
|
|
44
|
+
}, exports: unknown, lynxCoreInject: unknown, Card: unknown, setTimeout: unknown, setInterval: unknown, clearInterval: unknown, clearTimeout: unknown, NativeModules: unknown, Component: unknown, ReactLynx: unknown, nativeAppId: unknown, Behavior: unknown, LynxJSBI: unknown, lynx: unknown, window: unknown, document: unknown, frames: unknown, location: unknown, navigator: unknown, localStorage: unknown, history: unknown, Caches: unknown, screen: unknown, alert: unknown, confirm: unknown, prompt: unknown, fetch: unknown, XMLHttpRequest: unknown, webkit: unknown, Reporter: unknown, print: unknown, global: unknown, requestAnimationFrame: unknown, cancelAnimationFrame: unknown) => unknown;
|
|
42
45
|
export interface LynxJSModule {
|
|
43
46
|
exports?: (lynx_runtime: any) => unknown;
|
|
44
47
|
}
|
|
@@ -82,8 +82,9 @@ export interface NativeApp {
|
|
|
82
82
|
clearInterval: typeof clearInterval;
|
|
83
83
|
requestAnimationFrame: (cb: () => void) => void;
|
|
84
84
|
cancelAnimationFrame: (id: number) => void;
|
|
85
|
+
readScript: (sourceURL: string, entryName?: string) => string;
|
|
85
86
|
loadScript: (sourceURL: string, entryName?: string) => BundleInitReturnObj;
|
|
86
|
-
loadScriptAsync(sourceURL: string, callback: (message: string | null, exports?: BundleInitReturnObj) => void): void;
|
|
87
|
+
loadScriptAsync(sourceURL: string, callback: (message: string | null, exports?: BundleInitReturnObj) => void, entryName?: string): void;
|
|
87
88
|
nativeModuleProxy: Record<string, any>;
|
|
88
89
|
setNativeProps: (type: IdentifierType, identifier: string, component_id: string, first_only: boolean, native_props: Record<string, unknown>, root_unique_id: number | undefined) => void;
|
|
89
90
|
invokeUIMethod: (type: IdentifierType, identifier: string, component_id: string, method: string, params: object, callback: (ret: InvokeCallbackRes) => void, root_unique_id: number) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LynxTemplate } from '../types/LynxModule.js';
|
|
2
|
-
export declare function generateTemplate(template: LynxTemplate, createJsModuleUrl: ((content: string, name: string) => Promise<string>) | ((content: string) => string), templateName
|
|
2
|
+
export declare function generateTemplate(template: LynxTemplate, createJsModuleUrl: ((content: string, name: string) => Promise<string>) | ((content: string) => string), templateName: string): Promise<LynxTemplate>;
|
|
@@ -2,61 +2,18 @@
|
|
|
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
4
|
const currentSupportedTemplateVersion = 2;
|
|
5
|
-
const globalDisallowedVars = ['navigator', 'postMessage'];
|
|
5
|
+
const globalDisallowedVars = ['navigator', 'postMessage', 'window'];
|
|
6
6
|
const templateUpgraders = [
|
|
7
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
8
|
template.appType = template.appType ?? (template.lepusCode.root.startsWith('(function (globDynamicComponentEntry')
|
|
46
9
|
? 'lazy'
|
|
47
10
|
: 'card');
|
|
48
|
-
/**
|
|
49
|
-
* The template version 1 has no module wrapper for bts code
|
|
50
|
-
*/
|
|
51
|
-
template.manifest = Object.fromEntries(Object.entries(template.manifest).map(([key, value]) => [
|
|
52
|
-
key,
|
|
53
|
-
`module.exports={init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:{}}; var exports=module.exports; ${value}\n return module.exports; } }`,
|
|
54
|
-
]));
|
|
55
11
|
template.version = 2;
|
|
12
|
+
template.lepusCode = Object.fromEntries(Object.entries(template.lepusCode).filter(([_, content]) => typeof content === 'string'));
|
|
56
13
|
return template;
|
|
57
14
|
},
|
|
58
15
|
];
|
|
59
|
-
const generateModuleContent = (content, eager, appType) =>
|
|
16
|
+
const generateModuleContent = (fileName, content, eager, appType) =>
|
|
60
17
|
/**
|
|
61
18
|
* About the `allFunctionsCalledOnLoad` directive:
|
|
62
19
|
* https://v8.dev/blog/preparser#pife
|
|
@@ -75,13 +32,16 @@ const generateModuleContent = (content, eager, appType) =>
|
|
|
75
32
|
appType !== 'card' ? 'module.exports=\n' : '',
|
|
76
33
|
content,
|
|
77
34
|
'\n})()',
|
|
35
|
+
'\n//# sourceURL=',
|
|
36
|
+
fileName,
|
|
78
37
|
].join('');
|
|
79
38
|
async function generateJavascriptUrl(obj, createJsModuleUrl, eager, appType, templateName) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
39
|
+
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(async ([name, content]) => {
|
|
40
|
+
return [
|
|
41
|
+
name,
|
|
42
|
+
await createJsModuleUrl(generateModuleContent(`${templateName}/${name.replaceAll('/', '_')}.js`, content, eager, appType), `${templateName}-${name.replaceAll('/', '_')}.js`),
|
|
43
|
+
];
|
|
44
|
+
})).then(Object.fromEntries);
|
|
85
45
|
}
|
|
86
46
|
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
87
47
|
template.version = template.version ?? 1;
|
|
@@ -96,7 +56,6 @@ export async function generateTemplate(template, createJsModuleUrl, templateName
|
|
|
96
56
|
return {
|
|
97
57
|
...template,
|
|
98
58
|
lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, true, template.appType, templateName),
|
|
99
|
-
manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, false, template.appType, templateName),
|
|
100
59
|
};
|
|
101
60
|
}
|
|
102
61
|
//# 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.17.
|
|
3
|
+
"version": "0.17.2-canary-20250928-a35a2452",
|
|
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.17.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.2-canary-20250928-a35a2452"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4"
|