@lynx-js/web-worker-runtime 0.14.2 → 0.15.1
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,73 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.15.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @lynx-js/web-mainthread-apis@0.15.1
|
|
9
|
+
- @lynx-js/web-constants@0.15.1
|
|
10
|
+
- @lynx-js/web-worker-rpc@0.15.1
|
|
11
|
+
|
|
12
|
+
## 0.15.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- refactor: move exposure system to web-core ([#1254](https://github.com/lynx-family/lynx-stack/pull/1254))
|
|
17
|
+
|
|
18
|
+
**THIS IS A BREAKING CHANGE**
|
|
19
|
+
|
|
20
|
+
**You'll need to upgrade your @lynx-js/web-elements to >= 0.8.0**
|
|
21
|
+
|
|
22
|
+
For SSR and better performance, we moved the lynx's exposure system from web-element to web-core.
|
|
23
|
+
|
|
24
|
+
Before this commit, we create Intersection observers by creating HTMLElements.
|
|
25
|
+
|
|
26
|
+
After this commit, we will create such Intersection observers after dom stabled.
|
|
27
|
+
|
|
28
|
+
Also, the setInterval for exposure has been removed, now we use an on time lazy timer for such features.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- feat: add `napiModulesPath` to bundle napiModules into worker runtime. ([#1134](https://github.com/lynx-family/lynx-stack/pull/1134))
|
|
33
|
+
|
|
34
|
+
Usage:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { pluginWebPlatform } from '@lynx-js/web-platform-rsbuild-plugin';
|
|
38
|
+
import { defineConfig } from '@rsbuild/core';
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [
|
|
42
|
+
pluginWebPlatform({
|
|
43
|
+
// replace with your actual napi-modules file path
|
|
44
|
+
napiModulesPath: path.resolve(__dirname, './index.napi-modules.ts'),
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`napi-modules.ts` example:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// index.napi-modules.ts
|
|
54
|
+
export default {
|
|
55
|
+
custom_module: function(NapiModules, NapiModulesCall) {
|
|
56
|
+
return {
|
|
57
|
+
async test(name) {
|
|
58
|
+
console.log('CustomModule', NapiModules, NapiModulesCall);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [[`7b75469`](https://github.com/lynx-family/lynx-stack/commit/7b75469d05dd2ec78bf6e1e54b94c8dff938eb40), [`224c653`](https://github.com/lynx-family/lynx-stack/commit/224c653f370d807281fa0a9ffbb4f4dd5c9d308e)]:
|
|
66
|
+
- @lynx-js/offscreen-document@0.1.3
|
|
67
|
+
- @lynx-js/web-mainthread-apis@0.15.0
|
|
68
|
+
- @lynx-js/web-constants@0.15.0
|
|
69
|
+
- @lynx-js/web-worker-rpc@0.15.0
|
|
70
|
+
|
|
3
71
|
## 0.14.2
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
|
@@ -1,6 +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
|
+
/* LYNX_NAPI_MODULES_IMPORT */
|
|
4
5
|
import { dispatchNapiModuleEndpoint, napiModulesCallEndpoint, } from '@lynx-js/web-constants';
|
|
5
6
|
export const createNapiLoader = async (rpc, napiModulesMap) => {
|
|
6
7
|
const napiModulesCall = rpc.createCall(napiModulesCallEndpoint);
|
|
@@ -8,6 +9,7 @@ export const createNapiLoader = async (rpc, napiModulesMap) => {
|
|
|
8
9
|
await Promise.all(Object.entries(napiModulesMap).map(([moduleName, moduleStr]) => import(/* webpackIgnore: true */ moduleStr).then(module => napiModules[moduleName] = module?.default?.(napiModules, (name, data) => napiModulesCall(name, data, moduleName), (func) => {
|
|
9
10
|
rpc.registerHandler(dispatchNapiModuleEndpoint, (data) => func(data));
|
|
10
11
|
}))));
|
|
12
|
+
/* LYNX_NAPI_MODULES_ADD */
|
|
11
13
|
return {
|
|
12
14
|
load(moduleName) {
|
|
13
15
|
return napiModules[moduleName];
|
|
@@ -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, } from '@lynx-js/web-constants';
|
|
4
|
+
import { flushElementTreeEndpoint, mainThreadStartEndpoint, postOffscreenEventEndpoint, reportErrorEndpoint, dispatchLynxViewEventEndpoint, i18nResourceMissedEventName, I18nResources, updateI18nResourcesEndpoint, multiThreadExposureChangedEndpoint, lynxUniqueIdAttribute, } 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';
|
|
@@ -25,7 +25,13 @@ export function startMainThreadWorker(uiThreadPort, backgroundThreadPort) {
|
|
|
25
25
|
});
|
|
26
26
|
const i18nResources = new I18nResources();
|
|
27
27
|
uiThreadRpc.registerHandler(postOffscreenEventEndpoint, docu[_onEvent]);
|
|
28
|
-
const
|
|
28
|
+
const sendMultiThreadExposureChangedEndpoint = uiThreadRpc.createCall(multiThreadExposureChangedEndpoint);
|
|
29
|
+
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, docu, docu.createElement.bind(docu), (exposureChangedElementUniqueIds) => {
|
|
30
|
+
docu.commit();
|
|
31
|
+
sendMultiThreadExposureChangedEndpoint(exposureChangedElementUniqueIds
|
|
32
|
+
.map(e => e.getAttribute(lynxUniqueIdAttribute))
|
|
33
|
+
.filter(id => id !== null));
|
|
34
|
+
}, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, (initI18nResources) => {
|
|
29
35
|
i18nResources.setData(initI18nResources);
|
|
30
36
|
return i18nResources;
|
|
31
37
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@lynx-js/offscreen-document": "0.1.
|
|
26
|
-
"@lynx-js/web-constants": "0.
|
|
27
|
-
"@lynx-js/web-mainthread-apis": "0.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
25
|
+
"@lynx-js/offscreen-document": "0.1.3",
|
|
26
|
+
"@lynx-js/web-constants": "0.15.1",
|
|
27
|
+
"@lynx-js/web-mainthread-apis": "0.15.1",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "0.15.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@lynx-js/lynx-core": "0.1.2"
|