@lynx-js/web-worker-runtime-canary 0.17.1 → 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,5 +1,21 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
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
|
+
|
|
3
19
|
## 0.17.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -151,14 +167,14 @@
|
|
|
151
167
|
Usage:
|
|
152
168
|
|
|
153
169
|
```ts
|
|
154
|
-
import { pluginWebPlatform } from
|
|
155
|
-
import { defineConfig } from
|
|
170
|
+
import { pluginWebPlatform } from "@lynx-js/web-platform-rsbuild-plugin";
|
|
171
|
+
import { defineConfig } from "@rsbuild/core";
|
|
156
172
|
|
|
157
173
|
export default defineConfig({
|
|
158
174
|
plugins: [
|
|
159
175
|
pluginWebPlatform({
|
|
160
176
|
// replace with your actual napi-modules file path
|
|
161
|
-
napiModulesPath: path.resolve(__dirname,
|
|
177
|
+
napiModulesPath: path.resolve(__dirname, "./index.napi-modules.ts"),
|
|
162
178
|
}),
|
|
163
179
|
],
|
|
164
180
|
});
|
|
@@ -169,10 +185,10 @@
|
|
|
169
185
|
```ts
|
|
170
186
|
// index.napi-modules.ts
|
|
171
187
|
export default {
|
|
172
|
-
custom_module: function(NapiModules, NapiModulesCall) {
|
|
188
|
+
custom_module: function (NapiModules, NapiModulesCall) {
|
|
173
189
|
return {
|
|
174
190
|
async test(name) {
|
|
175
|
-
console.log(
|
|
191
|
+
console.log("CustomModule", NapiModules, NapiModulesCall);
|
|
176
192
|
},
|
|
177
193
|
};
|
|
178
194
|
},
|
|
@@ -224,25 +240,25 @@
|
|
|
224
240
|
lynxView.initI18nResources = [
|
|
225
241
|
{
|
|
226
242
|
options: {
|
|
227
|
-
locale:
|
|
228
|
-
channel:
|
|
229
|
-
fallback_url:
|
|
243
|
+
locale: "en",
|
|
244
|
+
channel: "1",
|
|
245
|
+
fallback_url: "",
|
|
230
246
|
},
|
|
231
247
|
resource: {
|
|
232
|
-
hello:
|
|
233
|
-
lynx:
|
|
248
|
+
hello: "hello",
|
|
249
|
+
lynx: "lynx web platform1",
|
|
234
250
|
},
|
|
235
251
|
},
|
|
236
252
|
];
|
|
237
|
-
lynxView.addEventListener(
|
|
253
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
238
254
|
console.log(e);
|
|
239
255
|
});
|
|
240
256
|
|
|
241
257
|
// mts
|
|
242
258
|
_I18nResourceTranslation({
|
|
243
|
-
locale:
|
|
244
|
-
channel:
|
|
245
|
-
fallback_url:
|
|
259
|
+
locale: "en",
|
|
260
|
+
channel: "1",
|
|
261
|
+
fallback_url: "",
|
|
246
262
|
});
|
|
247
263
|
```
|
|
248
264
|
|
|
@@ -492,8 +508,8 @@
|
|
|
492
508
|
}
|
|
493
509
|
};`,
|
|
494
510
|
],
|
|
495
|
-
{ type:
|
|
496
|
-
)
|
|
511
|
+
{ type: "text/javascript" }
|
|
512
|
+
)
|
|
497
513
|
),
|
|
498
514
|
};
|
|
499
515
|
lynxView.nativeModulesMap = nativeModulesMap;
|
|
@@ -583,8 +599,8 @@
|
|
|
583
599
|
};
|
|
584
600
|
};`,
|
|
585
601
|
],
|
|
586
|
-
{ type:
|
|
587
|
-
)
|
|
602
|
+
{ type: "text/javascript" }
|
|
603
|
+
)
|
|
588
604
|
);
|
|
589
605
|
|
|
590
606
|
const color_methods = URL.createObjectURL(
|
|
@@ -599,8 +615,8 @@
|
|
|
599
615
|
};
|
|
600
616
|
};`,
|
|
601
617
|
],
|
|
602
|
-
{ type:
|
|
603
|
-
)
|
|
618
|
+
{ type: "text/javascript" }
|
|
619
|
+
)
|
|
604
620
|
);
|
|
605
621
|
|
|
606
622
|
lynxView.napiModuleMap = {
|
|
@@ -617,7 +633,7 @@
|
|
|
617
633
|
|
|
618
634
|
```js
|
|
619
635
|
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
620
|
-
if (name ===
|
|
636
|
+
if (name === "getColor" && moduleName === "color_methods") {
|
|
621
637
|
return data.color;
|
|
622
638
|
}
|
|
623
639
|
};
|
|
@@ -672,8 +688,8 @@
|
|
|
672
688
|
}
|
|
673
689
|
};`,
|
|
674
690
|
],
|
|
675
|
-
{ type:
|
|
676
|
-
)
|
|
691
|
+
{ type: "text/javascript" }
|
|
692
|
+
)
|
|
677
693
|
);
|
|
678
694
|
```
|
|
679
695
|
|
|
@@ -685,7 +701,7 @@
|
|
|
685
701
|
|
|
686
702
|
```js
|
|
687
703
|
lynxView.onNativeModulesCall = (name, data, callback) => {
|
|
688
|
-
if (name ===
|
|
704
|
+
if (name === "getColor") {
|
|
689
705
|
callback(data.color);
|
|
690
706
|
}
|
|
691
707
|
};
|
|
@@ -695,7 +711,7 @@
|
|
|
695
711
|
|
|
696
712
|
```js
|
|
697
713
|
lynxView.onNativeModulesCall = (name, data, moduleName) => {
|
|
698
|
-
if (name ===
|
|
714
|
+
if (name === "getColor" && moduleName === "bridge") {
|
|
699
715
|
return data.color;
|
|
700
716
|
}
|
|
701
717
|
};
|
|
@@ -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
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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.
|
|
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.
|
|
27
|
-
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.
|
|
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"
|