@lynx-js/web-worker-runtime-canary 0.16.1-canary-20250915-74388494 → 0.16.1-canary-20250915-cb84cf03

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,13 +1,15 @@
1
1
  # @lynx-js/web-worker-runtime
2
2
 
3
- ## 0.16.1-canary-20250915064132-743884945342f58670e037c1a5dab06b782639c2
3
+ ## 0.16.1-canary-20250915080228-cb84cf035f1129b89f4b801335e79a5f7d36c0bd
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies []:
8
- - @lynx-js/web-constants@0.16.1-canary-20250915064132-743884945342f58670e037c1a5dab06b782639c2
9
- - @lynx-js/web-mainthread-apis@0.16.1-canary-20250915064132-743884945342f58670e037c1a5dab06b782639c2
10
- - @lynx-js/web-worker-rpc@0.16.1-canary-20250915064132-743884945342f58670e037c1a5dab06b782639c2
7
+ - feat: supports lazy bundle. (This feature requires `@lynx-js/lynx-core >= 0.1.3`) ([#1235](https://github.com/lynx-family/lynx-stack/pull/1235))
8
+
9
+ - Updated dependencies [[`608f375`](https://github.com/lynx-family/lynx-stack/commit/608f375e20732cc4c9f141bfbf9800ba6896100b)]:
10
+ - @lynx-js/web-mainthread-apis@0.16.1-canary-20250915080228-cb84cf035f1129b89f4b801335e79a5f7d36c0bd
11
+ - @lynx-js/web-constants@0.16.1-canary-20250915080228-cb84cf035f1129b89f4b801335e79a5f7d36c0bd
12
+ - @lynx-js/web-worker-rpc@0.16.1-canary-20250915080228-cb84cf035f1129b89f4b801335e79a5f7d36c0bd
11
13
 
12
14
  ## 0.16.0
13
15
 
@@ -12,4 +12,12 @@ export declare function createBackgroundLynx(config: BackMainThreadContextConfig
12
12
  animate(operation: import("@lynx-js/web-constants").AnimationOperation, id: string, keyframes?: Record<string, any>[], timingOptions?: Record<string, any>): void;
13
13
  };
14
14
  getI18nResource: () => import("@lynx-js/web-constants").Cloneable;
15
+ QueryComponent: (source: string, callback: (ret: {
16
+ __hasReady: boolean;
17
+ } | {
18
+ code: number;
19
+ detail?: {
20
+ schema: string;
21
+ };
22
+ }) => void) => void;
15
23
  };
@@ -31,6 +31,7 @@ export function createBackgroundLynx(config, nativeApp, mainThreadRpc, uiThreadR
31
31
  return createElement(id, uiThreadRpc);
32
32
  },
33
33
  getI18nResource: () => nativeApp.i18nResource.data,
34
+ QueryComponent: (source, callback) => nativeApp.queryComponent(source, callback),
34
35
  };
35
36
  }
36
37
  //# sourceMappingURL=createBackgroundLynx.js.map
@@ -1,4 +1,4 @@
1
- import { callLepusMethodEndpoint, setNativePropsEndpoint, triggerComponentEventEndpoint, selectComponentEndpoint, I18nResource, reportErrorEndpoint, } from '@lynx-js/web-constants';
1
+ import { callLepusMethodEndpoint, setNativePropsEndpoint, triggerComponentEventEndpoint, selectComponentEndpoint, I18nResource, reportErrorEndpoint, queryComponentEndpoint, updateBTSTemplateCacheEndpoint, } from '@lynx-js/web-constants';
2
2
  import { createInvokeUIMethod } from './crossThreadHandlers/createInvokeUIMethod.js';
3
3
  import { registerPublicComponentEventHandler } from './crossThreadHandlers/registerPublicComponentEventHandler.js';
4
4
  import { registerGlobalExposureEventHandler } from './crossThreadHandlers/registerGlobalExposureEventHandler.js';
@@ -20,6 +20,7 @@ export async function createNativeApp(config) {
20
20
  const setNativeProps = uiThreadRpc.createCall(setNativePropsEndpoint);
21
21
  const triggerComponentEvent = uiThreadRpc.createCall(triggerComponentEventEndpoint);
22
22
  const selectComponent = uiThreadRpc.createCallbackify(selectComponentEndpoint, 3);
23
+ const queryComponent = mainThreadRpc.createCall(queryComponentEndpoint);
23
24
  const reportError = uiThreadRpc.createCall(reportErrorEndpoint);
24
25
  const createBundleInitReturnObj = () => {
25
26
  const ret = globalThis.module.exports ?? globalThis.__bundle__holder;
@@ -27,6 +28,10 @@ export async function createNativeApp(config) {
27
28
  globalThis.__bundle__holder = null;
28
29
  return ret;
29
30
  };
31
+ const templateCache = new Map([['__Card__', template]]);
32
+ mainThreadRpc.registerHandler(updateBTSTemplateCacheEndpoint, (url, template) => {
33
+ templateCache.set(url, template);
34
+ });
30
35
  const i18nResource = new I18nResource();
31
36
  let release = '';
32
37
  const nativeApp = {
@@ -37,8 +42,10 @@ export async function createNativeApp(config) {
37
42
  clearTimeout: clearTimeout,
38
43
  clearInterval: clearInterval,
39
44
  nativeModuleProxy: await createNativeModules(uiThreadRpc, mainThreadRpc, nativeModulesMap),
40
- loadScriptAsync: function (sourceURL, callback) {
41
- const manifestUrl = template.manifest[`/${sourceURL}`];
45
+ loadScriptAsync: function (sourceURL, callback, entryName) {
46
+ entryName = entryName ?? '__Card__';
47
+ const manifestUrl = templateCache.get(entryName)
48
+ ?.manifest[`/${sourceURL}`];
42
49
  if (manifestUrl)
43
50
  sourceURL = manifestUrl;
44
51
  globalThis.module.exports = null;
@@ -49,8 +56,10 @@ export async function createNativeApp(config) {
49
56
  callback(null, createBundleInitReturnObj());
50
57
  });
51
58
  },
52
- loadScript: (sourceURL) => {
53
- const manifestUrl = template.manifest[`/${sourceURL}`];
59
+ loadScript: (sourceURL, entryName) => {
60
+ entryName = entryName ?? '__Card__';
61
+ const manifestUrl = templateCache.get(entryName)
62
+ ?.manifest[`/${sourceURL}`];
54
63
  if (manifestUrl)
55
64
  sourceURL = manifestUrl;
56
65
  globalThis.module.exports = null;
@@ -68,6 +77,7 @@ export async function createNativeApp(config) {
68
77
  setNativeProps,
69
78
  getPathInfo: createGetPathInfo(uiThreadRpc),
70
79
  invokeUIMethod: createInvokeUIMethod(uiThreadRpc),
80
+ tt: null,
71
81
  setCard(tt) {
72
82
  registerPublicComponentEventHandler(mainThreadRpc, tt);
73
83
  registerPublishEventHandler(mainThreadRpc, tt);
@@ -78,6 +88,7 @@ export async function createNativeApp(config) {
78
88
  registerUpdateI18nResource(uiThreadRpc, mainThreadRpc, i18nResource, tt);
79
89
  timingSystem.registerGlobalEmitter(tt.GlobalEventEmitter);
80
90
  tt.lynx.getCoreContext().__start();
91
+ nativeApp.tt = tt;
81
92
  },
82
93
  triggerComponentEvent,
83
94
  selectComponent,
@@ -91,6 +102,16 @@ export async function createNativeApp(config) {
91
102
  i18nResource,
92
103
  reportException: (err, _) => reportError(err, _, release),
93
104
  __SetSourceMapRelease: (err) => release = err.message,
105
+ queryComponent: (source, callback) => {
106
+ if (templateCache.has(source)) {
107
+ callback({ __hasReady: true });
108
+ }
109
+ else {
110
+ queryComponent(source).then(res => {
111
+ callback?.(res);
112
+ });
113
+ }
114
+ },
94
115
  };
95
116
  return nativeApp;
96
117
  }
@@ -26,7 +26,11 @@ export function startBackgroundThread(uiThreadPort, mainThreadPort) {
26
26
  globalThis['napiLoaderOnRT' + nativeApp.id] =
27
27
  await createNapiLoader(uiThreadRpc, config.napiModulesMap);
28
28
  const nativeLynx = createBackgroundLynx(config, nativeApp, mainThreadRpc, uiThreadRpc);
29
- lynxCore.then(({ loadCard, destroyCard, callDestroyLifetimeFun }) => {
29
+ lynxCore.then(({ loadCard, destroyCard, callDestroyLifetimeFun, nativeGlobal, loadDynamicComponent, }) => {
30
+ // @lynx-js/lynx-core >= 0.1.3 will export nativeGlobal and loadDynamicComponent
31
+ if (nativeGlobal && loadDynamicComponent) {
32
+ nativeGlobal.loadDynamicComponent = loadDynamicComponent;
33
+ }
30
34
  loadCard(nativeApp, {
31
35
  ...config,
32
36
  // @ts-ignore
@@ -1,7 +1,7 @@
1
1
  // Copyright 2023 The Lynx Authors. All rights reserved.
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
- import { flushElementTreeEndpoint, mainThreadStartEndpoint, postOffscreenEventEndpoint, reportErrorEndpoint, dispatchLynxViewEventEndpoint, i18nResourceMissedEventName, I18nResources, updateI18nResourcesEndpoint, multiThreadExposureChangedEndpoint, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
4
+ import { flushElementTreeEndpoint, mainThreadStartEndpoint, postOffscreenEventEndpoint, reportErrorEndpoint, dispatchLynxViewEventEndpoint, i18nResourceMissedEventName, I18nResources, updateI18nResourcesEndpoint, multiThreadExposureChangedEndpoint, lynxUniqueIdAttribute, loadTemplateMultiThread, } from '@lynx-js/web-constants';
5
5
  import { Rpc } from '@lynx-js/web-worker-rpc';
6
6
  import { createMarkTimingInternal } from './crossThreadHandlers/createMainthreadMarkTimingInternal.js';
7
7
  import { OffscreenDocument } from '@lynx-js/offscreen-document/webworker';
@@ -60,6 +60,7 @@ export async function startMainThreadWorker(uiThreadPort, backgroundThreadPort)
60
60
  const i18nResources = new I18nResources();
61
61
  uiThreadRpc.registerHandler(postOffscreenEventEndpoint, document[_onEvent]);
62
62
  const sendMultiThreadExposureChangedEndpoint = uiThreadRpc.createCall(multiThreadExposureChangedEndpoint);
63
+ const loadTemplate = uiThreadRpc.createCall(loadTemplateMultiThread);
63
64
  const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, document, // rootDom
64
65
  document, mtsRealm, (exposureChangedElementUniqueIds) => {
65
66
  document.commit();
@@ -69,12 +70,12 @@ export async function startMainThreadWorker(uiThreadPort, backgroundThreadPort)
69
70
  }, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, (initI18nResources) => {
70
71
  i18nResources.setData(initI18nResources);
71
72
  return i18nResources;
72
- });
73
+ }, loadTemplate);
73
74
  uiThreadRpc.registerHandler(mainThreadStartEndpoint, async (config) => {
74
75
  await startMainThread(config);
75
76
  registerUpdateDataHandler(uiThreadRpc, globalThis);
76
77
  });
77
- uiThreadRpc?.registerHandler(updateI18nResourcesEndpoint, data => {
78
+ uiThreadRpc.registerHandler(updateI18nResourcesEndpoint, data => {
78
79
  i18nResources.setData(data);
79
80
  });
80
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-worker-runtime-canary",
3
- "version": "0.16.1-canary-20250915-74388494",
3
+ "version": "0.16.1-canary-20250915-cb84cf03",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4",
26
- "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.16.1-canary-20250915-74388494",
27
- "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.16.1-canary-20250915-74388494",
28
- "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.1-canary-20250915-74388494"
26
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.16.1-canary-20250915-cb84cf03",
27
+ "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.16.1-canary-20250915-cb84cf03",
28
+ "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.1-canary-20250915-cb84cf03"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@lynx-js/lynx-core": "0.1.3"