@lynx-js/web-mainthread-apis-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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @lynx-js/web-mainthread-apis
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 []:
14
+ - @lynx-js/web-constants@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
15
+ - @lynx-js/web-style-transformer@0.18.1-canary-20251016065218-70a18fce0083743e4516eefc91c0392d748b855f
16
+
3
17
  ## 0.18.0
4
18
 
5
19
  ### Patch Changes
@@ -264,25 +278,25 @@
264
278
  lynxView.initI18nResources = [
265
279
  {
266
280
  options: {
267
- locale: 'en',
268
- channel: '1',
269
- fallback_url: '',
281
+ locale: "en",
282
+ channel: "1",
283
+ fallback_url: "",
270
284
  },
271
285
  resource: {
272
- hello: 'hello',
273
- lynx: 'lynx web platform1',
286
+ hello: "hello",
287
+ lynx: "lynx web platform1",
274
288
  },
275
289
  },
276
290
  ];
277
- lynxView.addEventListener('i18nResourceMissed', (e) => {
291
+ lynxView.addEventListener("i18nResourceMissed", (e) => {
278
292
  console.log(e);
279
293
  });
280
294
 
281
295
  // mts
282
296
  _I18nResourceTranslation({
283
- locale: 'en',
284
- channel: '1',
285
- fallback_url: '',
297
+ locale: "en",
298
+ channel: "1",
299
+ fallback_url: "",
286
300
  });
287
301
  ```
288
302
 
@@ -1,5 +1,5 @@
1
1
  import { type Rpc, type StartMainThreadContextConfig, type RpcCallType, type reportErrorEndpoint, type I18nResourceTranslationOptions, type InitI18nResources, type I18nResources, type Cloneable, type SSRHydrateInfo, type SSRDehydrateHooks, type JSRealm, type TemplateLoader, type UpdateDataOptions } from '@lynx-js/web-constants';
2
- export declare function prepareMainThreadAPIs(backgroundThreadRpc: Rpc, rootDom: Document | ShadowRoot, document: Document, mtsRealm: JSRealm, commitDocument: (exposureChangedElements: HTMLElement[]) => Promise<void> | void, markTimingInternal: (timingKey: string, pipelineId?: string) => void, flushMarkTimingInternal: () => void, reportError: RpcCallType<typeof reportErrorEndpoint>, triggerI18nResourceFallback: (options: I18nResourceTranslationOptions) => void, initialI18nResources: (data: InitI18nResources) => I18nResources, loadTemplate: TemplateLoader, ssrHooks?: SSRDehydrateHooks): {
2
+ export declare function prepareMainThreadAPIs(backgroundThreadRpc: Rpc, rootDom: Document | ShadowRoot, document: Document, mtsRealmPromise: JSRealm | Promise<JSRealm>, commitDocument: (exposureChangedElements: HTMLElement[]) => Promise<void> | void, markTimingInternal: (timingKey: string, pipelineId?: string) => void, flushMarkTimingInternal: () => void, reportError: RpcCallType<typeof reportErrorEndpoint>, triggerI18nResourceFallback: (options: I18nResourceTranslationOptions) => void, initialI18nResources: (data: InitI18nResources) => I18nResources, loadTemplate: TemplateLoader, ssrHooks?: SSRDehydrateHooks): {
3
3
  startMainThread: (config: StartMainThreadContextConfig, ssrHydrateInfo?: SSRHydrateInfo) => Promise<void>;
4
4
  handleUpdatedData: (newData: Cloneable, options: UpdateDataOptions | undefined) => Promise<void>;
5
5
  };
@@ -10,7 +10,7 @@ import { initWasm } from '@lynx-js/web-style-transformer';
10
10
  import { appendStyleElement } from './utils/processStyleInfo.js';
11
11
  import { createQueryComponent } from './crossThreadHandlers/createQueryComponent.js';
12
12
  const initWasmPromise = initWasm();
13
- export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealm, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks) {
13
+ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealmPromise, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks) {
14
14
  const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
15
15
  const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
16
16
  const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
@@ -23,6 +23,7 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mt
23
23
  let isFp = true;
24
24
  const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, initI18nResources, } = config;
25
25
  const { styleInfo, pageConfig, customSections, cardType, } = template;
26
+ const mtsRealm = await mtsRealmPromise;
26
27
  markTimingInternal('decode_start');
27
28
  await initWasmPromise;
28
29
  const jsContext = new LynxCrossThreadContext({
@@ -141,7 +142,8 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mt
141
142
  await mtsRealm.loadScript(template.lepusCode.root);
142
143
  jsContext.__start(); // start the jsContext after the runtime is created
143
144
  }
144
- function handleUpdatedData(newData, options) {
145
+ async function handleUpdatedData(newData, options) {
146
+ const mtsRealm = await mtsRealmPromise;
145
147
  const runtime = mtsRealm.globalWindow;
146
148
  const processedData = runtime.processData
147
149
  ? runtime.processData(newData, options?.processorName)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-mainthread-apis-canary",
3
- "version": "0.18.0",
3
+ "version": "0.18.1-canary-20251016-70a18fce",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -24,8 +24,8 @@
24
24
  "**/*.css"
25
25
  ],
26
26
  "dependencies": {
27
- "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.0",
28
- "@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.18.0",
27
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.1-canary-20251016-70a18fce",
28
+ "@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.18.1-canary-20251016-70a18fce",
29
29
  "hyphenate-style-name": "^1.1.0"
30
30
  }
31
31
  }