@lynx-js/web-core-canary 0.18.0 → 0.18.1-canary-20251016-70a18fce
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 +43 -26
- package/dist/uiThread/createRenderAllOnUI.js +13 -23
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @lynx-js/web-core
|
|
2
2
|
|
|
3
|
+
## 0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: mts freeze after reload() ([#1892](https://github.com/lynx-family/lynx-stack/pull/1892))
|
|
8
|
+
|
|
9
|
+
The mts may be freezed after reload() called.
|
|
10
|
+
|
|
11
|
+
We fixed it by waiting until the all-on-ui Javascript realm implementation, an iframe, to be fully loaded.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`df5ebcf`](https://github.com/lynx-family/lynx-stack/commit/df5ebcf0408950d0380b6d53ad0b9d43eacf36b6), [`e500bc6`](https://github.com/lynx-family/lynx-stack/commit/e500bc6ee865fe1ab17c2ace77c3bcf8462f74c5), [`70a18fc`](https://github.com/lynx-family/lynx-stack/commit/70a18fce0083743e4516eefc91c0392d748b855f), [`e42b906`](https://github.com/lynx-family/lynx-stack/commit/e42b906ae0d771739e0e1897def646ad159274eb)]:
|
|
14
|
+
- @lynx-js/web-elements@0.8.9-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
15
|
+
- @lynx-js/web-mainthread-apis@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
16
|
+
- @lynx-js/web-worker-runtime@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
17
|
+
- @lynx-js/web-constants@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
18
|
+
- @lynx-js/web-worker-rpc@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
|
|
19
|
+
|
|
3
20
|
## 0.18.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -352,25 +369,25 @@
|
|
|
352
369
|
lynxView.initI18nResources = [
|
|
353
370
|
{
|
|
354
371
|
options: {
|
|
355
|
-
locale:
|
|
356
|
-
channel:
|
|
357
|
-
fallback_url:
|
|
372
|
+
locale: "en",
|
|
373
|
+
channel: "1",
|
|
374
|
+
fallback_url: "",
|
|
358
375
|
},
|
|
359
376
|
resource: {
|
|
360
|
-
hello:
|
|
361
|
-
lynx:
|
|
377
|
+
hello: "hello",
|
|
378
|
+
lynx: "lynx web platform1",
|
|
362
379
|
},
|
|
363
380
|
},
|
|
364
381
|
];
|
|
365
|
-
lynxView.addEventListener(
|
|
382
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
366
383
|
console.log(e);
|
|
367
384
|
});
|
|
368
385
|
|
|
369
386
|
// mts
|
|
370
387
|
_I18nResourceTranslation({
|
|
371
|
-
locale:
|
|
372
|
-
channel:
|
|
373
|
-
fallback_url:
|
|
388
|
+
locale: "en",
|
|
389
|
+
channel: "1",
|
|
390
|
+
fallback_url: "",
|
|
374
391
|
});
|
|
375
392
|
```
|
|
376
393
|
|
|
@@ -778,8 +795,8 @@
|
|
|
778
795
|
}
|
|
779
796
|
};`,
|
|
780
797
|
],
|
|
781
|
-
{ type:
|
|
782
|
-
)
|
|
798
|
+
{ type: "text/javascript" }
|
|
799
|
+
)
|
|
783
800
|
),
|
|
784
801
|
};
|
|
785
802
|
lynxView.nativeModulesMap = nativeModulesMap;
|
|
@@ -894,8 +911,8 @@
|
|
|
894
911
|
};
|
|
895
912
|
};`,
|
|
896
913
|
],
|
|
897
|
-
{ type:
|
|
898
|
-
)
|
|
914
|
+
{ type: "text/javascript" }
|
|
915
|
+
)
|
|
899
916
|
);
|
|
900
917
|
|
|
901
918
|
const color_methods = URL.createObjectURL(
|
|
@@ -910,8 +927,8 @@
|
|
|
910
927
|
};
|
|
911
928
|
};`,
|
|
912
929
|
],
|
|
913
|
-
{ type:
|
|
914
|
-
)
|
|
930
|
+
{ type: "text/javascript" }
|
|
931
|
+
)
|
|
915
932
|
);
|
|
916
933
|
|
|
917
934
|
lynxView.napiModuleMap = {
|
|
@@ -928,7 +945,7 @@
|
|
|
928
945
|
|
|
929
946
|
```js
|
|
930
947
|
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
931
|
-
if (name ===
|
|
948
|
+
if (name === "getColor" && moduleName === "color_methods") {
|
|
932
949
|
return data.color;
|
|
933
950
|
}
|
|
934
951
|
};
|
|
@@ -1007,8 +1024,8 @@
|
|
|
1007
1024
|
}
|
|
1008
1025
|
};`,
|
|
1009
1026
|
],
|
|
1010
|
-
{ type:
|
|
1011
|
-
)
|
|
1027
|
+
{ type: "text/javascript" }
|
|
1028
|
+
)
|
|
1012
1029
|
);
|
|
1013
1030
|
```
|
|
1014
1031
|
|
|
@@ -1020,7 +1037,7 @@
|
|
|
1020
1037
|
|
|
1021
1038
|
```js
|
|
1022
1039
|
lynxView.onNativeModulesCall = (name, data, callback) => {
|
|
1023
|
-
if (name ===
|
|
1040
|
+
if (name === "getColor") {
|
|
1024
1041
|
callback(data.color);
|
|
1025
1042
|
}
|
|
1026
1043
|
};
|
|
@@ -1030,7 +1047,7 @@
|
|
|
1030
1047
|
|
|
1031
1048
|
```js
|
|
1032
1049
|
lynxView.onNativeModulesCall = (name, data, moduleName) => {
|
|
1033
|
-
if (name ===
|
|
1050
|
+
if (name === "getColor" && moduleName === "bridge") {
|
|
1034
1051
|
return data.color;
|
|
1035
1052
|
}
|
|
1036
1053
|
};
|
|
@@ -1388,7 +1405,7 @@
|
|
|
1388
1405
|
This flag changes the behaviour of cascading. It provide a way to do this
|
|
1389
1406
|
|
|
1390
1407
|
```jsx
|
|
1391
|
-
<view class=
|
|
1408
|
+
<view class="class-a class-b" />
|
|
1392
1409
|
```
|
|
1393
1410
|
|
|
1394
1411
|
The class-b will override (cascading) styles of class-a.
|
|
@@ -1488,11 +1505,11 @@
|
|
|
1488
1505
|
There is also a simple way to use this feature
|
|
1489
1506
|
|
|
1490
1507
|
```javascript
|
|
1491
|
-
import { LynxCard } from
|
|
1492
|
-
import { loadElement } from
|
|
1493
|
-
import
|
|
1494
|
-
import
|
|
1495
|
-
import
|
|
1508
|
+
import { LynxCard } from "@lynx-js/web-core";
|
|
1509
|
+
import { loadElement } from "@lynx-js/web-elements/lazy";
|
|
1510
|
+
import "@lynx-js/web-elements/index.css";
|
|
1511
|
+
import "@lynx-js/web-core/index.css";
|
|
1512
|
+
import "./index.css";
|
|
1496
1513
|
|
|
1497
1514
|
const lynxcard = new LynxCard({
|
|
1498
1515
|
...beforeConfigs,
|
|
@@ -16,27 +16,30 @@ const { prepareMainThreadAPIs, } = await import(
|
|
|
16
16
|
* Creates a isolated JavaScript context for executing mts code.
|
|
17
17
|
* This context has its own global variables and functions.
|
|
18
18
|
*/
|
|
19
|
-
function createIFrameRealm(parent) {
|
|
19
|
+
async function createIFrameRealm(parent) {
|
|
20
20
|
const iframe = document.createElement('iframe');
|
|
21
|
+
const iframeReadyPromise = new Promise((resolve) => {
|
|
22
|
+
const listener = (event) => {
|
|
23
|
+
if (event.data === 'lynx:mtsready' && event.source === iframe.contentWindow) {
|
|
24
|
+
resolve();
|
|
25
|
+
globalThis.removeEventListener('message', listener);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
globalThis.addEventListener('message', listener);
|
|
29
|
+
});
|
|
21
30
|
iframe.style.display = 'none';
|
|
22
31
|
iframe.srcdoc =
|
|
23
|
-
'<!DOCTYPE html><html><head></head><body style="display:none"></body></html>';
|
|
32
|
+
'<!DOCTYPE html><html><head><script>parent.postMessage("lynx:mtsready","*")</script></head><body style="display:none"></body></html>';
|
|
24
33
|
iframe.sandbox = 'allow-same-origin allow-scripts'; // Restrict capabilities for security
|
|
25
34
|
iframe.loading = 'eager';
|
|
26
35
|
parent.appendChild(iframe);
|
|
36
|
+
await iframeReadyPromise;
|
|
27
37
|
const iframeWindow = iframe.contentWindow;
|
|
28
38
|
const loadScript = async (url) => {
|
|
29
39
|
const script = iframe.contentDocument.createElement('script');
|
|
30
40
|
script.fetchPriority = 'high';
|
|
31
41
|
script.defer = true;
|
|
32
42
|
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
43
|
iframe.contentDocument.head.appendChild(script);
|
|
41
44
|
return new Promise(async (resolve, reject) => {
|
|
42
45
|
script.onload = () => {
|
|
@@ -82,14 +85,12 @@ export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, loadTemplat
|
|
|
82
85
|
const i18nResources = new I18nResources();
|
|
83
86
|
const { exposureChangedCallback } = createExposureMonitor(shadowRoot);
|
|
84
87
|
const mtsRealm = createIFrameRealm(shadowRoot);
|
|
85
|
-
const mtsGlobalThis = mtsRealm.globalWindow;
|
|
86
88
|
const { startMainThread, handleUpdatedData } = prepareMainThreadAPIs(mainToBackgroundRpc, shadowRoot, document, mtsRealm, exposureChangedCallback, markTimingInternal, flushMarkTimingInternal, (err, _, release) => {
|
|
87
89
|
callbacks.onError?.(err, release, 'lepus.js');
|
|
88
90
|
}, triggerI18nResourceFallback, (initI18nResources) => {
|
|
89
91
|
i18nResources.setData(initI18nResources);
|
|
90
92
|
return i18nResources;
|
|
91
93
|
}, loadTemplate);
|
|
92
|
-
const pendingUpdateCalls = [];
|
|
93
94
|
const start = async (configs) => {
|
|
94
95
|
if (ssrDumpInfo) {
|
|
95
96
|
const lynxUniqueIdToElement = [];
|
|
@@ -124,20 +125,9 @@ export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, loadTemplat
|
|
|
124
125
|
else {
|
|
125
126
|
await startMainThread(configs);
|
|
126
127
|
}
|
|
127
|
-
// Process any pending update calls that were queued while mtsGlobalThis was undefined
|
|
128
|
-
for (const [newData, options] of pendingUpdateCalls) {
|
|
129
|
-
handleUpdatedData(newData, options);
|
|
130
|
-
}
|
|
131
|
-
pendingUpdateCalls.length = 0;
|
|
132
128
|
};
|
|
133
129
|
const updateDataMainThread = async (newData, options) => {
|
|
134
|
-
|
|
135
|
-
return handleUpdatedData(newData, options);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Cache the call if mtsGlobalThis is not yet initialized
|
|
139
|
-
pendingUpdateCalls.push([newData, options]);
|
|
140
|
-
}
|
|
130
|
+
return handleUpdatedData(newData, options);
|
|
141
131
|
};
|
|
142
132
|
const updateI18nResourcesMainThread = (data) => {
|
|
143
133
|
i18nResources.setData(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core-canary",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1-canary-20251016-70a18fce",
|
|
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.18.
|
|
29
|
-
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.18.
|
|
30
|
-
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.18.
|
|
31
|
-
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.18.
|
|
28
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.1-canary-20251016-70a18fce",
|
|
29
|
+
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.18.1-canary-20251016-70a18fce",
|
|
30
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.18.1-canary-20251016-70a18fce",
|
|
31
|
+
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.18.1-canary-20251016-70a18fce"
|
|
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.9-canary-20251016-70a18fce"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@lynx-js/lynx-core": "0.1.3",
|