@lynx-js/web-worker-runtime-canary 0.17.1-canary-20250925-6180e11d → 0.17.2-canary-20250928-a35a2452

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,29 @@
1
1
  # @lynx-js/web-worker-runtime
2
2
 
3
- ## 0.17.1-canary-20250925132904-6180e11dc18587b00e2a8c02a52a7de190b953ed
3
+ ## 0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: support load bts chunk from remote address ([#1834](https://github.com/lynx-family/lynx-stack/pull/1834))
8
+
9
+ - re-support chunk splitting
10
+ - support lynx.requireModule with a json file
11
+ - support lynx.requireModule, lynx.requireModuleAsync with a remote url
12
+ - support to add a breakpoint in chrome after reloading the web page
13
+
14
+ - Updated dependencies [[`a35a245`](https://github.com/lynx-family/lynx-stack/commit/a35a2452e5355bda3c475f9a750a86085e0cf56a)]:
15
+ - @lynx-js/web-constants@0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
16
+ - @lynx-js/web-mainthread-apis@0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
17
+ - @lynx-js/web-worker-rpc@0.17.2-canary-20250928082931-a35a2452e5355bda3c475f9a750a86085e0cf56a
18
+
19
+ ## 0.17.1
4
20
 
5
21
  ### Patch Changes
6
22
 
7
23
  - Updated dependencies []:
8
- - @lynx-js/web-constants@0.17.1-canary-20250925132904-6180e11dc18587b00e2a8c02a52a7de190b953ed
9
- - @lynx-js/web-mainthread-apis@0.17.1-canary-20250925132904-6180e11dc18587b00e2a8c02a52a7de190b953ed
10
- - @lynx-js/web-worker-rpc@0.17.1-canary-20250925132904-6180e11dc18587b00e2a8c02a52a7de190b953ed
24
+ - @lynx-js/web-constants@0.17.1
25
+ - @lynx-js/web-mainthread-apis@0.17.1
26
+ - @lynx-js/web-worker-rpc@0.17.1
11
27
 
12
28
  ## 0.17.0
13
29
 
@@ -0,0 +1,7 @@
1
+ import type { NativeApp, LynxTemplate } from '@lynx-js/web-constants';
2
+ export declare function createChunkLoading(initialTemplate: LynxTemplate): {
3
+ readScript: NativeApp['readScript'];
4
+ loadScript: NativeApp['loadScript'];
5
+ loadScriptAsync: NativeApp['loadScriptAsync'];
6
+ templateCache: Map<string, LynxTemplate>;
7
+ };
@@ -0,0 +1,73 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ export function createChunkLoading(initialTemplate) {
5
+ const templateCache = new Map([[
6
+ '__Card__',
7
+ initialTemplate,
8
+ ]]);
9
+ const readScript = (sourceURL, entryName = '__Card__') => {
10
+ const jsContentInTemplate = templateCache.get(entryName)
11
+ ?.manifest[`/${sourceURL}`];
12
+ if (jsContentInTemplate)
13
+ return jsContentInTemplate;
14
+ const xhr = new XMLHttpRequest();
15
+ xhr.open('GET', sourceURL, false);
16
+ xhr.send(null);
17
+ if (xhr.status === 200) {
18
+ return xhr.responseText;
19
+ }
20
+ throw new Error(`Failed to load ${sourceURL}, status: ${xhr.status}`);
21
+ };
22
+ const readScriptAsync = async (sourceURL, entryName = '__Card__') => {
23
+ const jsContentInTemplate = templateCache.get(entryName)
24
+ ?.manifest[`/${sourceURL}`];
25
+ if (jsContentInTemplate)
26
+ return jsContentInTemplate;
27
+ return new Promise((resolve, reject) => {
28
+ fetch(sourceURL).then((response) => {
29
+ if (response.ok) {
30
+ response.text().then((text) => resolve(text), reject);
31
+ }
32
+ else {
33
+ reject(new Error(`Failed to load ${sourceURL}, status: ${response.status}`));
34
+ }
35
+ }, reject);
36
+ });
37
+ };
38
+ const createBundleInitReturnObj = (jsContent, fileName) => {
39
+ const foo = new Function('postMessage', 'module', 'exports', 'lynxCoreInject', 'Card', 'setTimeout', 'setInterval', 'clearInterval', 'clearTimeout', 'NativeModules', 'Component', 'ReactLynx', 'nativeAppId', 'Behavior', 'LynxJSBI', 'lynx',
40
+ // BOM API
41
+ 'window', 'document', 'frames', 'location', 'navigator', 'localStorage', 'history', 'Caches', 'screen', 'alert', 'confirm', 'prompt', 'fetch', 'XMLHttpRequest', 'webkit', 'Reporter', 'print', 'global',
42
+ // Lynx API
43
+ 'requestAnimationFrame', 'cancelAnimationFrame', [
44
+ jsContent,
45
+ '\n//# sourceURL=',
46
+ fileName,
47
+ ].join(''));
48
+ return {
49
+ init(lynxCoreInject) {
50
+ const module = { exports: {} };
51
+ const tt = lynxCoreInject.tt;
52
+ foo(undefined, module, module.exports, lynxCoreInject, tt.Card, tt.setTimeout, tt.setInterval, tt.clearInterval, tt.clearTimeout, tt.NativeModules, tt.Component, tt.ReactLynx, tt.nativeAppId, tt.Behavior, tt.LynxJSBI, tt.lynx,
53
+ // BOM API
54
+ tt.window, tt.document, tt.frames, tt.location, tt.navigator, tt.localStorage, tt.history, tt.Caches, tt.screen, tt.alert, tt.confirm, tt.prompt, tt.fetch, tt.XMLHttpRequest, tt.webkit, tt.Reporter, tt.print, tt.global, tt.requestAnimationFrame, tt.cancelAnimationFrame);
55
+ return module.exports;
56
+ },
57
+ };
58
+ };
59
+ return {
60
+ readScript,
61
+ loadScript: (sourceURL, entryName = '__Card__') => {
62
+ const jsContent = readScript(sourceURL, entryName);
63
+ return createBundleInitReturnObj(jsContent, `${encodeURIComponent(entryName)}/${sourceURL}`);
64
+ },
65
+ loadScriptAsync: async (sourceURL, callback, entryName = '__Card__') => {
66
+ readScriptAsync(sourceURL, entryName).then((jsContent) => {
67
+ callback(null, createBundleInitReturnObj(jsContent, `${encodeURIComponent(entryName)}/${sourceURL}`));
68
+ });
69
+ },
70
+ templateCache,
71
+ };
72
+ }
73
+ //# sourceMappingURL=createChunkLoading.js.map
@@ -11,6 +11,7 @@ import { createJSObjectDestructionObserver } from './crossThreadHandlers/createJ
11
11
  import { registerUpdateGlobalPropsHandler } from './crossThreadHandlers/registerUpdateGlobalPropsHandler.js';
12
12
  import { registerUpdateI18nResource } from './crossThreadHandlers/registerUpdateI18nResource.js';
13
13
  import { createGetPathInfo } from './crossThreadHandlers/createGetPathInfo.js';
14
+ import { createChunkLoading } from './createChunkLoading.js';
14
15
  let nativeAppCount = 0;
15
16
  const sharedData = {};
16
17
  export async function createNativeApp(config) {
@@ -22,13 +23,7 @@ export async function createNativeApp(config) {
22
23
  const selectComponent = uiThreadRpc.createCallbackify(selectComponentEndpoint, 3);
23
24
  const queryComponent = mainThreadRpc.createCall(queryComponentEndpoint);
24
25
  const reportError = uiThreadRpc.createCall(reportErrorEndpoint);
25
- const createBundleInitReturnObj = () => {
26
- const ret = globalThis.module.exports ?? globalThis.__bundle__holder;
27
- globalThis.module.exports = null;
28
- globalThis.__bundle__holder = null;
29
- return ret;
30
- };
31
- const templateCache = new Map([['__Card__', template]]);
26
+ const { templateCache, loadScript, loadScriptAsync, readScript } = createChunkLoading(template);
32
27
  mainThreadRpc.registerHandler(updateBTSTemplateCacheEndpoint, (url, template) => {
33
28
  templateCache.set(url, template);
34
29
  });
@@ -42,35 +37,9 @@ export async function createNativeApp(config) {
42
37
  clearTimeout: clearTimeout,
43
38
  clearInterval: clearInterval,
44
39
  nativeModuleProxy: await createNativeModules(uiThreadRpc, mainThreadRpc, nativeModulesMap),
45
- loadScriptAsync: function (sourceURL, callback, entryName) {
46
- entryName = entryName ?? '__Card__';
47
- const manifestUrl = templateCache.get(entryName)
48
- ?.manifest[`/${sourceURL}`];
49
- if (manifestUrl)
50
- sourceURL = manifestUrl;
51
- else
52
- throw Error(`Cannot find ${sourceURL} in manifest`);
53
- globalThis.module.exports = null;
54
- globalThis.__bundle__holder = null;
55
- import(
56
- /* webpackIgnore: true */
57
- sourceURL).catch(callback).then(async () => {
58
- callback(null, createBundleInitReturnObj());
59
- });
60
- },
61
- loadScript: (sourceURL, entryName) => {
62
- entryName = entryName ?? '__Card__';
63
- const manifestUrl = templateCache.get(entryName)
64
- ?.manifest[`/${sourceURL}`];
65
- if (manifestUrl)
66
- sourceURL = manifestUrl;
67
- else
68
- throw Error(`Cannot find ${sourceURL} in manifest`);
69
- globalThis.module.exports = null;
70
- globalThis.__bundle__holder = null;
71
- importScripts(sourceURL);
72
- return createBundleInitReturnObj();
73
- },
40
+ readScript,
41
+ loadScriptAsync,
42
+ loadScript,
74
43
  requestAnimationFrame(cb) {
75
44
  return requestAnimationFrame(cb);
76
45
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-worker-runtime-canary",
3
- "version": "0.17.1-canary-20250925-6180e11d",
3
+ "version": "0.17.2-canary-20250928-a35a2452",
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.17.1-canary-20250925-6180e11d",
27
- "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.1-canary-20250925-6180e11d",
28
- "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.1-canary-20250925-6180e11d"
26
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.17.2-canary-20250928-a35a2452",
27
+ "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.2-canary-20250928-a35a2452",
28
+ "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.2-canary-20250928-a35a2452"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@lynx-js/lynx-core": "0.1.3"