@lynx-js/web-core-canary 0.18.0-canary-20251012-dd7c14a8 → 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 CHANGED
@@ -1,6 +1,23 @@
1
1
  # @lynx-js/web-core
2
2
 
3
- ## 0.18.0-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
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
+
20
+ ## 0.18.0
4
21
 
5
22
  ### Minor Changes
6
23
 
@@ -17,11 +34,10 @@
17
34
  ### Patch Changes
18
35
 
19
36
  - Updated dependencies [[`77397fd`](https://github.com/lynx-family/lynx-stack/commit/77397fd535cf60556f8f82f7ef8dae8a623d1625), [`7d90ed5`](https://github.com/lynx-family/lynx-stack/commit/7d90ed52a20fd7665a3517507800e7e29426f6f9)]:
20
- - @lynx-js/web-worker-runtime@0.18.0-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
21
- - @lynx-js/web-constants@0.18.0-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
22
- - @lynx-js/web-elements@0.8.8-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
23
- - @lynx-js/web-mainthread-apis@0.18.0-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
24
- - @lynx-js/web-worker-rpc@0.18.0-canary-20251012050336-dd7c14a838a10804949a953d0f5b54f34ba7cc67
37
+ - @lynx-js/web-worker-runtime@0.18.0
38
+ - @lynx-js/web-constants@0.18.0
39
+ - @lynx-js/web-mainthread-apis@0.18.0
40
+ - @lynx-js/web-worker-rpc@0.18.0
25
41
 
26
42
  ## 0.17.2
27
43
 
@@ -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
- if (mtsGlobalThis) {
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.0-canary-20251012-dd7c14a8",
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.0-canary-20251012-dd7c14a8",
29
- "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.18.0-canary-20251012-dd7c14a8",
30
- "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.18.0-canary-20251012-dd7c14a8",
31
- "@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.18.0-canary-20251012-dd7c14a8"
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.8-canary-20251012-dd7c14a8"
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",