@lynx-js/web-worker-runtime-canary 0.17.2 → 0.18.0-canary-20251010-77397fd5
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 +44 -25
- package/dist/backgroundThread/background-apis/createNativeApp.js +1 -1
- package/dist/mainThread/crossThreadHandlers/registerUpdateDataHandler.d.ts +1 -2
- package/dist/mainThread/crossThreadHandlers/registerUpdateDataHandler.js +3 -5
- package/dist/mainThread/startMainThread.js +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.18.0-canary-20251010092201-77397fd535cf60556f8f82f7ef8dae8a623d1625
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: ([#1837](https://github.com/lynx-family/lynx-stack/pull/1837))
|
|
8
|
+
|
|
9
|
+
1. `LynxView.updateData()` cannot trigger `dataProcessor`.
|
|
10
|
+
|
|
11
|
+
2. **This is a break change:** The second parameter of `LynxView.updateData()` has been changed from `UpdateDataType` to `string`, which is the `processorName` (default is `default` which will use `defaultDataProcessor`). This change is to better align with Native. The current complete type is as follows:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
LynxView.updateData(data: Cloneable, processorName?: string | undefined, callback?: (() => void) | undefined): void
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`77397fd`](https://github.com/lynx-family/lynx-stack/commit/77397fd535cf60556f8f82f7ef8dae8a623d1625)]:
|
|
18
|
+
- @lynx-js/web-constants@0.18.0-canary-20251010092201-77397fd535cf60556f8f82f7ef8dae8a623d1625
|
|
19
|
+
- @lynx-js/web-mainthread-apis@0.18.0-canary-20251010092201-77397fd535cf60556f8f82f7ef8dae8a623d1625
|
|
20
|
+
- @lynx-js/web-worker-rpc@0.18.0-canary-20251010092201-77397fd535cf60556f8f82f7ef8dae8a623d1625
|
|
21
|
+
|
|
3
22
|
## 0.17.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -167,14 +186,14 @@
|
|
|
167
186
|
Usage:
|
|
168
187
|
|
|
169
188
|
```ts
|
|
170
|
-
import { pluginWebPlatform } from
|
|
171
|
-
import { defineConfig } from
|
|
189
|
+
import { pluginWebPlatform } from "@lynx-js/web-platform-rsbuild-plugin";
|
|
190
|
+
import { defineConfig } from "@rsbuild/core";
|
|
172
191
|
|
|
173
192
|
export default defineConfig({
|
|
174
193
|
plugins: [
|
|
175
194
|
pluginWebPlatform({
|
|
176
195
|
// replace with your actual napi-modules file path
|
|
177
|
-
napiModulesPath: path.resolve(__dirname,
|
|
196
|
+
napiModulesPath: path.resolve(__dirname, "./index.napi-modules.ts"),
|
|
178
197
|
}),
|
|
179
198
|
],
|
|
180
199
|
});
|
|
@@ -185,10 +204,10 @@
|
|
|
185
204
|
```ts
|
|
186
205
|
// index.napi-modules.ts
|
|
187
206
|
export default {
|
|
188
|
-
custom_module: function(NapiModules, NapiModulesCall) {
|
|
207
|
+
custom_module: function (NapiModules, NapiModulesCall) {
|
|
189
208
|
return {
|
|
190
209
|
async test(name) {
|
|
191
|
-
console.log(
|
|
210
|
+
console.log("CustomModule", NapiModules, NapiModulesCall);
|
|
192
211
|
},
|
|
193
212
|
};
|
|
194
213
|
},
|
|
@@ -240,25 +259,25 @@
|
|
|
240
259
|
lynxView.initI18nResources = [
|
|
241
260
|
{
|
|
242
261
|
options: {
|
|
243
|
-
locale:
|
|
244
|
-
channel:
|
|
245
|
-
fallback_url:
|
|
262
|
+
locale: "en",
|
|
263
|
+
channel: "1",
|
|
264
|
+
fallback_url: "",
|
|
246
265
|
},
|
|
247
266
|
resource: {
|
|
248
|
-
hello:
|
|
249
|
-
lynx:
|
|
267
|
+
hello: "hello",
|
|
268
|
+
lynx: "lynx web platform1",
|
|
250
269
|
},
|
|
251
270
|
},
|
|
252
271
|
];
|
|
253
|
-
lynxView.addEventListener(
|
|
272
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
254
273
|
console.log(e);
|
|
255
274
|
});
|
|
256
275
|
|
|
257
276
|
// mts
|
|
258
277
|
_I18nResourceTranslation({
|
|
259
|
-
locale:
|
|
260
|
-
channel:
|
|
261
|
-
fallback_url:
|
|
278
|
+
locale: "en",
|
|
279
|
+
channel: "1",
|
|
280
|
+
fallback_url: "",
|
|
262
281
|
});
|
|
263
282
|
```
|
|
264
283
|
|
|
@@ -508,8 +527,8 @@
|
|
|
508
527
|
}
|
|
509
528
|
};`,
|
|
510
529
|
],
|
|
511
|
-
{ type:
|
|
512
|
-
)
|
|
530
|
+
{ type: "text/javascript" }
|
|
531
|
+
)
|
|
513
532
|
),
|
|
514
533
|
};
|
|
515
534
|
lynxView.nativeModulesMap = nativeModulesMap;
|
|
@@ -599,8 +618,8 @@
|
|
|
599
618
|
};
|
|
600
619
|
};`,
|
|
601
620
|
],
|
|
602
|
-
{ type:
|
|
603
|
-
)
|
|
621
|
+
{ type: "text/javascript" }
|
|
622
|
+
)
|
|
604
623
|
);
|
|
605
624
|
|
|
606
625
|
const color_methods = URL.createObjectURL(
|
|
@@ -615,8 +634,8 @@
|
|
|
615
634
|
};
|
|
616
635
|
};`,
|
|
617
636
|
],
|
|
618
|
-
{ type:
|
|
619
|
-
)
|
|
637
|
+
{ type: "text/javascript" }
|
|
638
|
+
)
|
|
620
639
|
);
|
|
621
640
|
|
|
622
641
|
lynxView.napiModuleMap = {
|
|
@@ -633,7 +652,7 @@
|
|
|
633
652
|
|
|
634
653
|
```js
|
|
635
654
|
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
636
|
-
if (name ===
|
|
655
|
+
if (name === "getColor" && moduleName === "color_methods") {
|
|
637
656
|
return data.color;
|
|
638
657
|
}
|
|
639
658
|
};
|
|
@@ -688,8 +707,8 @@
|
|
|
688
707
|
}
|
|
689
708
|
};`,
|
|
690
709
|
],
|
|
691
|
-
{ type:
|
|
692
|
-
)
|
|
710
|
+
{ type: "text/javascript" }
|
|
711
|
+
)
|
|
693
712
|
);
|
|
694
713
|
```
|
|
695
714
|
|
|
@@ -701,7 +720,7 @@
|
|
|
701
720
|
|
|
702
721
|
```js
|
|
703
722
|
lynxView.onNativeModulesCall = (name, data, callback) => {
|
|
704
|
-
if (name ===
|
|
723
|
+
if (name === "getColor") {
|
|
705
724
|
callback(data.color);
|
|
706
725
|
}
|
|
707
726
|
};
|
|
@@ -711,7 +730,7 @@
|
|
|
711
730
|
|
|
712
731
|
```js
|
|
713
732
|
lynxView.onNativeModulesCall = (name, data, moduleName) => {
|
|
714
|
-
if (name ===
|
|
733
|
+
if (name === "getColor" && moduleName === "bridge") {
|
|
715
734
|
return data.color;
|
|
716
735
|
}
|
|
717
736
|
};
|
|
@@ -55,7 +55,7 @@ export async function createNativeApp(config) {
|
|
|
55
55
|
registerPublicComponentEventHandler(mainThreadRpc, tt);
|
|
56
56
|
registerPublishEventHandler(mainThreadRpc, tt);
|
|
57
57
|
registerGlobalExposureEventHandler(mainThreadRpc, tt);
|
|
58
|
-
registerUpdateDataHandler(
|
|
58
|
+
registerUpdateDataHandler(mainThreadRpc, tt);
|
|
59
59
|
registerSendGlobalEventHandler(uiThreadRpc, tt);
|
|
60
60
|
registerUpdateGlobalPropsHandler(uiThreadRpc, tt);
|
|
61
61
|
registerUpdateI18nResource(uiThreadRpc, mainThreadRpc, i18nResource, tt);
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { type MainThreadGlobalThis } from '@lynx-js/web-constants';
|
|
2
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
-
export declare function registerUpdateDataHandler(
|
|
2
|
+
export declare function registerUpdateDataHandler(mainThreadRpc: Rpc, handleUpdatedData: ReturnType<typeof import('@lynx-js/web-mainthread-apis').prepareMainThreadAPIs>['handleUpdatedData']): void;
|
|
@@ -1,10 +1,8 @@
|
|
|
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 { updateDataEndpoint
|
|
5
|
-
export function registerUpdateDataHandler(
|
|
6
|
-
|
|
7
|
-
runtime.updatePage?.(...args);
|
|
8
|
-
});
|
|
4
|
+
import { updateDataEndpoint } from '@lynx-js/web-constants';
|
|
5
|
+
export function registerUpdateDataHandler(mainThreadRpc, handleUpdatedData) {
|
|
6
|
+
mainThreadRpc.registerHandler(updateDataEndpoint, (newData, options) => handleUpdatedData(newData, options));
|
|
9
7
|
}
|
|
10
8
|
//# sourceMappingURL=registerUpdateDataHandler.js.map
|
|
@@ -61,7 +61,7 @@ export async function startMainThreadWorker(uiThreadPort, backgroundThreadPort)
|
|
|
61
61
|
uiThreadRpc.registerHandler(postOffscreenEventEndpoint, document[_onEvent]);
|
|
62
62
|
const sendMultiThreadExposureChangedEndpoint = uiThreadRpc.createCall(multiThreadExposureChangedEndpoint);
|
|
63
63
|
const loadTemplate = uiThreadRpc.createCall(loadTemplateMultiThread);
|
|
64
|
-
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, document, // rootDom
|
|
64
|
+
const { startMainThread, handleUpdatedData } = prepareMainThreadAPIs(backgroundThreadRpc, document, // rootDom
|
|
65
65
|
document, mtsRealm, (exposureChangedElementUniqueIds) => {
|
|
66
66
|
document.commit();
|
|
67
67
|
sendMultiThreadExposureChangedEndpoint(exposureChangedElementUniqueIds
|
|
@@ -73,7 +73,7 @@ export async function startMainThreadWorker(uiThreadPort, backgroundThreadPort)
|
|
|
73
73
|
}, loadTemplate);
|
|
74
74
|
uiThreadRpc.registerHandler(mainThreadStartEndpoint, async (config) => {
|
|
75
75
|
await startMainThread(config);
|
|
76
|
-
registerUpdateDataHandler(uiThreadRpc,
|
|
76
|
+
registerUpdateDataHandler(uiThreadRpc, handleUpdatedData);
|
|
77
77
|
});
|
|
78
78
|
uiThreadRpc.registerHandler(updateI18nResourcesEndpoint, data => {
|
|
79
79
|
i18nResources.setData(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime-canary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-canary-20251010-77397fd5",
|
|
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.
|
|
27
|
-
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.
|
|
26
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.0-canary-20251010-77397fd5",
|
|
27
|
+
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.18.0-canary-20251010-77397fd5",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.18.0-canary-20251010-77397fd5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@lynx-js/lynx-core": "0.1.3"
|