@lynx-js/web-core-canary 0.16.1 → 0.17.0-canary-20250918-b69a986a
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 +65 -26
- package/dist/uiThread/createRenderAllOnUI.js +18 -15
- package/dist/utils/loadTemplate.js +26 -15
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @lynx-js/web-core
|
|
2
2
|
|
|
3
|
+
## 0.17.0-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- break(web): temporary remove support for chunk split ([#1739](https://github.com/lynx-family/lynx-stack/pull/1739))
|
|
8
|
+
|
|
9
|
+
Since the global variables cannot be accessed in the splited chunk, we temporary remove supporting for chunk spliting
|
|
10
|
+
|
|
11
|
+
Developers could easily remove the chunk Split settings in Rspeedy for migration
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
performance: {
|
|
18
|
+
chunkSplit: {
|
|
19
|
+
strategy: 'all-in-one',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- fix: avoid duplicate style transformation ([#1748](https://github.com/lynx-family/lynx-stack/pull/1748))
|
|
28
|
+
|
|
29
|
+
After this commit, we use DAG methods to handle the styleInfos
|
|
30
|
+
|
|
31
|
+
- fix: add sandbox attribute to iframe for enhanced security ([#1709](https://github.com/lynx-family/lynx-stack/pull/1709))
|
|
32
|
+
|
|
33
|
+
- fix: the default template loader won't fetch twice for one url ([#1709](https://github.com/lynx-family/lynx-stack/pull/1709))
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`721635d`](https://github.com/lynx-family/lynx-stack/commit/721635de6c1d2d617c7cbaa86e7d816c42d62930), [`b69a986`](https://github.com/lynx-family/lynx-stack/commit/b69a986acd19ecbcb6246a7c9dccd99544415131), [`93d707b`](https://github.com/lynx-family/lynx-stack/commit/93d707b82a59f7256952e21da6dcad2999f8233d)]:
|
|
36
|
+
- @lynx-js/web-mainthread-apis@0.17.0-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
37
|
+
- @lynx-js/web-elements@0.8.7-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
38
|
+
- @lynx-js/web-constants@0.17.0-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
39
|
+
- @lynx-js/web-worker-runtime@0.17.0-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
40
|
+
- @lynx-js/web-worker-rpc@0.17.0-canary-20250918085607-b69a986acd19ecbcb6246a7c9dccd99544415131
|
|
41
|
+
|
|
3
42
|
## 0.16.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -261,25 +300,25 @@
|
|
|
261
300
|
lynxView.initI18nResources = [
|
|
262
301
|
{
|
|
263
302
|
options: {
|
|
264
|
-
locale:
|
|
265
|
-
channel:
|
|
266
|
-
fallback_url:
|
|
303
|
+
locale: "en",
|
|
304
|
+
channel: "1",
|
|
305
|
+
fallback_url: "",
|
|
267
306
|
},
|
|
268
307
|
resource: {
|
|
269
|
-
hello:
|
|
270
|
-
lynx:
|
|
308
|
+
hello: "hello",
|
|
309
|
+
lynx: "lynx web platform1",
|
|
271
310
|
},
|
|
272
311
|
},
|
|
273
312
|
];
|
|
274
|
-
lynxView.addEventListener(
|
|
313
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
275
314
|
console.log(e);
|
|
276
315
|
});
|
|
277
316
|
|
|
278
317
|
// mts
|
|
279
318
|
_I18nResourceTranslation({
|
|
280
|
-
locale:
|
|
281
|
-
channel:
|
|
282
|
-
fallback_url:
|
|
319
|
+
locale: "en",
|
|
320
|
+
channel: "1",
|
|
321
|
+
fallback_url: "",
|
|
283
322
|
});
|
|
284
323
|
```
|
|
285
324
|
|
|
@@ -687,8 +726,8 @@
|
|
|
687
726
|
}
|
|
688
727
|
};`,
|
|
689
728
|
],
|
|
690
|
-
{ type:
|
|
691
|
-
)
|
|
729
|
+
{ type: "text/javascript" }
|
|
730
|
+
)
|
|
692
731
|
),
|
|
693
732
|
};
|
|
694
733
|
lynxView.nativeModulesMap = nativeModulesMap;
|
|
@@ -803,8 +842,8 @@
|
|
|
803
842
|
};
|
|
804
843
|
};`,
|
|
805
844
|
],
|
|
806
|
-
{ type:
|
|
807
|
-
)
|
|
845
|
+
{ type: "text/javascript" }
|
|
846
|
+
)
|
|
808
847
|
);
|
|
809
848
|
|
|
810
849
|
const color_methods = URL.createObjectURL(
|
|
@@ -819,8 +858,8 @@
|
|
|
819
858
|
};
|
|
820
859
|
};`,
|
|
821
860
|
],
|
|
822
|
-
{ type:
|
|
823
|
-
)
|
|
861
|
+
{ type: "text/javascript" }
|
|
862
|
+
)
|
|
824
863
|
);
|
|
825
864
|
|
|
826
865
|
lynxView.napiModuleMap = {
|
|
@@ -837,7 +876,7 @@
|
|
|
837
876
|
|
|
838
877
|
```js
|
|
839
878
|
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
840
|
-
if (name ===
|
|
879
|
+
if (name === "getColor" && moduleName === "color_methods") {
|
|
841
880
|
return data.color;
|
|
842
881
|
}
|
|
843
882
|
};
|
|
@@ -916,8 +955,8 @@
|
|
|
916
955
|
}
|
|
917
956
|
};`,
|
|
918
957
|
],
|
|
919
|
-
{ type:
|
|
920
|
-
)
|
|
958
|
+
{ type: "text/javascript" }
|
|
959
|
+
)
|
|
921
960
|
);
|
|
922
961
|
```
|
|
923
962
|
|
|
@@ -929,7 +968,7 @@
|
|
|
929
968
|
|
|
930
969
|
```js
|
|
931
970
|
lynxView.onNativeModulesCall = (name, data, callback) => {
|
|
932
|
-
if (name ===
|
|
971
|
+
if (name === "getColor") {
|
|
933
972
|
callback(data.color);
|
|
934
973
|
}
|
|
935
974
|
};
|
|
@@ -939,7 +978,7 @@
|
|
|
939
978
|
|
|
940
979
|
```js
|
|
941
980
|
lynxView.onNativeModulesCall = (name, data, moduleName) => {
|
|
942
|
-
if (name ===
|
|
981
|
+
if (name === "getColor" && moduleName === "bridge") {
|
|
943
982
|
return data.color;
|
|
944
983
|
}
|
|
945
984
|
};
|
|
@@ -1297,7 +1336,7 @@
|
|
|
1297
1336
|
This flag changes the behaviour of cascading. It provide a way to do this
|
|
1298
1337
|
|
|
1299
1338
|
```jsx
|
|
1300
|
-
<view class=
|
|
1339
|
+
<view class="class-a class-b" />
|
|
1301
1340
|
```
|
|
1302
1341
|
|
|
1303
1342
|
The class-b will override (cascading) styles of class-a.
|
|
@@ -1397,11 +1436,11 @@
|
|
|
1397
1436
|
There is also a simple way to use this feature
|
|
1398
1437
|
|
|
1399
1438
|
```javascript
|
|
1400
|
-
import { LynxCard } from
|
|
1401
|
-
import { loadElement } from
|
|
1402
|
-
import
|
|
1403
|
-
import
|
|
1404
|
-
import
|
|
1439
|
+
import { LynxCard } from "@lynx-js/web-core";
|
|
1440
|
+
import { loadElement } from "@lynx-js/web-elements/lazy";
|
|
1441
|
+
import "@lynx-js/web-elements/index.css";
|
|
1442
|
+
import "@lynx-js/web-core/index.css";
|
|
1443
|
+
import "./index.css";
|
|
1405
1444
|
|
|
1406
1445
|
const lynxcard = new LynxCard({
|
|
1407
1446
|
...beforeConfigs,
|
|
@@ -18,24 +18,27 @@ const { prepareMainThreadAPIs, } = await import(
|
|
|
18
18
|
*/
|
|
19
19
|
function createIFrameRealm(parent) {
|
|
20
20
|
const iframe = document.createElement('iframe');
|
|
21
|
-
const iframeLoaded = new Promise((resolve) => {
|
|
22
|
-
iframe.onload = () => resolve();
|
|
23
|
-
});
|
|
24
21
|
iframe.style.display = 'none';
|
|
25
|
-
iframe.
|
|
22
|
+
iframe.srcdoc =
|
|
23
|
+
'<!DOCTYPE html><html><head></head><body style="display:none"></body></html>';
|
|
24
|
+
iframe.sandbox = 'allow-same-origin allow-scripts'; // Restrict capabilities for security
|
|
25
|
+
iframe.loading = 'eager';
|
|
26
26
|
parent.appendChild(iframe);
|
|
27
27
|
const iframeWindow = iframe.contentWindow;
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const loadScript = async (url) => {
|
|
29
|
+
const script = iframe.contentDocument.createElement('script');
|
|
30
|
+
script.fetchPriority = 'high';
|
|
31
|
+
script.defer = true;
|
|
32
|
+
script.async = false;
|
|
33
|
+
if (!iframe.contentDocument.head) {
|
|
34
|
+
await new Promise((resolve) => {
|
|
35
|
+
iframe.onload = () => resolve();
|
|
36
|
+
// In case iframe is already loaded, wait a macro task
|
|
37
|
+
setTimeout(() => resolve(), 0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
iframe.contentDocument.head.appendChild(script);
|
|
30
41
|
return new Promise(async (resolve, reject) => {
|
|
31
|
-
if (iframeDocument.readyState !== 'complete') {
|
|
32
|
-
await iframeLoaded;
|
|
33
|
-
}
|
|
34
|
-
const script = iframeDocument.createElement('script');
|
|
35
|
-
script.src = url;
|
|
36
|
-
script.fetchPriority = 'high';
|
|
37
|
-
script.defer = true;
|
|
38
|
-
script.async = false;
|
|
39
42
|
script.onload = () => {
|
|
40
43
|
const ret = iframeWindow?.module?.exports;
|
|
41
44
|
// @ts-expect-error
|
|
@@ -45,7 +48,7 @@ function createIFrameRealm(parent) {
|
|
|
45
48
|
script.onerror = (err) => reject(new Error(`Failed to load script: ${url}`, { cause: err }));
|
|
46
49
|
// @ts-expect-error
|
|
47
50
|
iframeWindow.module = { exports: undefined };
|
|
48
|
-
|
|
51
|
+
script.src = url;
|
|
49
52
|
});
|
|
50
53
|
};
|
|
51
54
|
const loadScriptSync = (url) => {
|
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
import { generateTemplate, } from '@lynx-js/web-constants';
|
|
2
|
-
const templateCache =
|
|
2
|
+
const templateCache = new Map();
|
|
3
3
|
function createJsModuleUrl(content) {
|
|
4
4
|
return URL.createObjectURL(new Blob([content], { type: 'text/javascript' }));
|
|
5
5
|
}
|
|
6
6
|
export function createTemplateLoader(customTemplateLoader, markTimingInternal) {
|
|
7
7
|
const loadTemplate = async (url) => {
|
|
8
8
|
markTimingInternal('load_template_start');
|
|
9
|
-
const cachedTemplate = templateCache
|
|
9
|
+
const cachedTemplate = templateCache.get(url);
|
|
10
10
|
if (cachedTemplate) {
|
|
11
11
|
markTimingInternal('load_template_end');
|
|
12
12
|
return cachedTemplate;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
else {
|
|
15
|
+
const promise = new Promise(async (resolve, reject) => {
|
|
16
|
+
try {
|
|
17
|
+
const template = customTemplateLoader
|
|
18
|
+
? await customTemplateLoader(url)
|
|
19
|
+
: (await (await fetch(url, {
|
|
20
|
+
method: 'GET',
|
|
21
|
+
})).json());
|
|
22
|
+
const decodedTemplate = await generateTemplate(template, createJsModuleUrl);
|
|
23
|
+
resolve(decodedTemplate);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
templateCache.delete(url);
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
templateCache.set(url, promise);
|
|
31
|
+
/**
|
|
32
|
+
* This will cause a memory leak, which is expected.
|
|
33
|
+
* We cannot ensure that the `URL.createObjectURL` created url will never be used, therefore here we keep it for the entire lifetime of this page.
|
|
34
|
+
*/
|
|
35
|
+
markTimingInternal('load_template_end');
|
|
36
|
+
return promise;
|
|
37
|
+
}
|
|
27
38
|
};
|
|
28
39
|
return loadTemplate;
|
|
29
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core-canary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0-canary-20250918-b69a986a",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4",
|
|
28
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.
|
|
29
|
-
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.
|
|
30
|
-
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.
|
|
31
|
-
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.
|
|
28
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.17.0-canary-20250918-b69a986a",
|
|
29
|
+
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.0-canary-20250918-b69a986a",
|
|
30
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.0-canary-20250918-b69a986a",
|
|
31
|
+
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.17.0-canary-20250918-b69a986a"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@lynx-js/lynx-core": "0.1.3",
|
|
35
|
-
"@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.
|
|
35
|
+
"@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.7-canary-20250918-b69a986a"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@lynx-js/lynx-core": "0.1.3",
|