@lynx-js/web-worker-runtime 0.7.1 → 0.9.0
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 +168 -0
- package/dist/backgroundThread/background-apis/createNapiLoader.d.ts +5 -0
- package/dist/backgroundThread/background-apis/createNapiLoader.js +15 -0
- package/dist/backgroundThread/background-apis/createNativeApp.d.ts +3 -3
- package/dist/backgroundThread/background-apis/createNativeApp.js +3 -3
- package/dist/backgroundThread/background-apis/createNativeModules.d.ts +2 -1
- package/dist/backgroundThread/background-apis/createNativeModules.js +7 -29
- package/dist/backgroundThread/background-apis/startBackgroundThread.js +4 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/mainThread/startMainThread.js +7 -9
- package/package.json +4 -4
- package/dist/mainThread/crossThreadHandlers/createReportError.d.ts +0 -2
- package/dist/mainThread/crossThreadHandlers/createReportError.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,173 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: `nativeModulesUrl` of lynx-view is changed to `nativeModulesMap`, and the usage is completely aligned with `napiModulesMap`. ([#220](https://github.com/lynx-family/lynx-stack/pull/220))
|
|
8
|
+
|
|
9
|
+
"warning: This is a breaking change."
|
|
10
|
+
|
|
11
|
+
`nativeModulesMap` will be a map: key is module-name, value should be a esm url which export default a
|
|
12
|
+
function with two parameters(you never need to use `this`):
|
|
13
|
+
|
|
14
|
+
- `NativeModules`: oriented `NativeModules`, which you can use to call
|
|
15
|
+
other Native-Modules.
|
|
16
|
+
|
|
17
|
+
- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the deprecated `this.nativeModulesCall`.
|
|
18
|
+
|
|
19
|
+
example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const nativeModulesMap = {
|
|
23
|
+
CustomModule: URL.createObjectURL(
|
|
24
|
+
new Blob(
|
|
25
|
+
[
|
|
26
|
+
`export default function(NativeModules, NativeModulesCall) {
|
|
27
|
+
return {
|
|
28
|
+
async getColor(data, callback) {
|
|
29
|
+
const color = await NativeModulesCall('getColor', data);
|
|
30
|
+
callback(color);
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
};`,
|
|
34
|
+
],
|
|
35
|
+
{ type: 'text/javascript' },
|
|
36
|
+
),
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
lynxView.nativeModulesMap = nativeModulesMap;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
In addition, we will use Promise.all to load `nativeModules`, which will optimize performance in the case of multiple modules.
|
|
43
|
+
|
|
44
|
+
- refractor: remove entryId concept ([#217](https://github.com/lynx-family/lynx-stack/pull/217))
|
|
45
|
+
|
|
46
|
+
After the PR #198
|
|
47
|
+
All contents are isolated by a shadowroot.
|
|
48
|
+
Therefore we don't need to add the entryId selector to avoid the lynx-view's style taking effect on the whole page.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- refactor: remove customelement defined detecting logic ([#247](https://github.com/lynx-family/lynx-stack/pull/247))
|
|
53
|
+
|
|
54
|
+
Before this commit, for those element with tag without `-`, we always try to detect if the `x-${tagName}` is defined.
|
|
55
|
+
|
|
56
|
+
After this commit, we pre-define a map(could be override by the `overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.
|
|
57
|
+
|
|
58
|
+
This change is a path to SSR and the MTS support.
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`5b5e090`](https://github.com/lynx-family/lynx-stack/commit/5b5e090fdf0e896f1c38a49bf3ed9889117c4fb8), [`b844e75`](https://github.com/lynx-family/lynx-stack/commit/b844e751f566d924256365d37aec4c86c520ec00), [`53230f0`](https://github.com/lynx-family/lynx-stack/commit/53230f012216f3a627853e11d544e4be175c5b9b), [`6f16827`](https://github.com/lynx-family/lynx-stack/commit/6f16827d1f4d7364870d354fc805a8868c110f1e), [`d2d55ef`](https://github.com/lynx-family/lynx-stack/commit/d2d55ef9fe438c35921d9db0daa40d5228822ecc)]:
|
|
61
|
+
- @lynx-js/web-constants@0.9.0
|
|
62
|
+
- @lynx-js/web-mainthread-apis@0.9.0
|
|
63
|
+
- @lynx-js/web-worker-rpc@0.9.0
|
|
64
|
+
|
|
65
|
+
## 0.8.0
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- refactor: remove web-elements/lazy and loadNewTag ([#123](https://github.com/lynx-family/lynx-stack/pull/123))
|
|
70
|
+
|
|
71
|
+
- remove @lynx-js/web-elements/lazy
|
|
72
|
+
- remove loadElement
|
|
73
|
+
- remove loadNewTag callback
|
|
74
|
+
|
|
75
|
+
**This is a breaking change**
|
|
76
|
+
|
|
77
|
+
Now we removed the default lazy loading preinstalled in web-core
|
|
78
|
+
|
|
79
|
+
Please add the following statement in your web project
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
import "@lynx-js/web-elements/all";
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- feat: add pixelRatio of SystemInfo, now you can use `SystemInfo.pixelRatio`. ([#150](https://github.com/lynx-family/lynx-stack/pull/150))
|
|
88
|
+
|
|
89
|
+
- feat: add two prop of lynx-view about `napiLoader`: ([#173](https://github.com/lynx-family/lynx-stack/pull/173))
|
|
90
|
+
|
|
91
|
+
- `napiModulesMap`: [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
92
|
+
|
|
93
|
+
- `onNapiModulesCall`: [optional] the NapiModule value handler.
|
|
94
|
+
|
|
95
|
+
**Warning:** This is the internal implementation of `@lynx-js/lynx-core`. In most cases, this API is not required for projects.
|
|
96
|
+
|
|
97
|
+
1. The `napiModulesMap` value should be a esm url which export default a function with two parameters:
|
|
98
|
+
|
|
99
|
+
- `NapiModules`: oriented `napiModulesMap`, which you can use to call other Napi-Modules
|
|
100
|
+
|
|
101
|
+
- `NapiModulesCall`: trigger `onNapiModulesCall`
|
|
102
|
+
|
|
103
|
+
example:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
const color_environment = URL.createObjectURL(
|
|
107
|
+
new Blob(
|
|
108
|
+
[
|
|
109
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
110
|
+
return {
|
|
111
|
+
getColor() {
|
|
112
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
113
|
+
console.log(color);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
ColorEngine: class ColorEngine {
|
|
117
|
+
getColor(name) {
|
|
118
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
119
|
+
console.log(color);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};`,
|
|
125
|
+
],
|
|
126
|
+
{ type: 'text/javascript' },
|
|
127
|
+
),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const color_methods = URL.createObjectURL(
|
|
131
|
+
new Blob(
|
|
132
|
+
[
|
|
133
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
134
|
+
return {
|
|
135
|
+
async getColor(data, callback) {
|
|
136
|
+
const color = await NapiModulesCall('getColor', data);
|
|
137
|
+
callback(color);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
};`,
|
|
141
|
+
],
|
|
142
|
+
{ type: 'text/javascript' },
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
lynxView.napiModuleMap = {
|
|
147
|
+
color_environment: color_environment,
|
|
148
|
+
color_methods: color_methods,
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
2. The `onNapiModulesCall` function has three parameters:
|
|
153
|
+
|
|
154
|
+
- `name`: the first parameter of `NapiModulesCall`, the function name
|
|
155
|
+
- `data`: the second parameter of `NapiModulesCall`, data
|
|
156
|
+
- `moduleName`: the module-name of the called napi-module
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
160
|
+
if (name === 'getColor' && moduleName === 'color_methods') {
|
|
161
|
+
return data.color;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- Updated dependencies [[`e9e8370`](https://github.com/lynx-family/lynx-stack/commit/e9e8370e070a50cbf65a4ebc46c2e37ea1e0be40), [`ec4e1ce`](https://github.com/lynx-family/lynx-stack/commit/ec4e1ce0d7612d6c0701792a46c78cd52130bad4), [`f0a717c`](https://github.com/lynx-family/lynx-stack/commit/f0a717c630700e16ab0af7f1fe370fd60ac75b30), [`63fab7b`](https://github.com/lynx-family/lynx-stack/commit/63fab7b515b7456750b5f7e06844f244a20ca4f1)]:
|
|
167
|
+
- @lynx-js/web-mainthread-apis@0.8.0
|
|
168
|
+
- @lynx-js/web-constants@0.8.0
|
|
169
|
+
- @lynx-js/web-worker-rpc@0.8.0
|
|
170
|
+
|
|
3
171
|
## 0.7.1
|
|
4
172
|
|
|
5
173
|
### Patch Changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type NapiModulesMap } from '@lynx-js/web-constants';
|
|
2
|
+
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
+
export declare const createNapiLoader: (rpc: Rpc, napiModulesMap: NapiModulesMap) => Promise<{
|
|
4
|
+
load(moduleName: string): Record<string, any> | undefined;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import { napiModulesCallEndpoint, } from '@lynx-js/web-constants';
|
|
5
|
+
export const createNapiLoader = async (rpc, napiModulesMap) => {
|
|
6
|
+
const napiModulesCall = rpc.createCall(napiModulesCallEndpoint);
|
|
7
|
+
const napiModules = {};
|
|
8
|
+
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)))));
|
|
9
|
+
return {
|
|
10
|
+
load(moduleName) {
|
|
11
|
+
return napiModules[moduleName];
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=createNapiLoader.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
import { type LynxTemplate, type NativeApp } from '@lynx-js/web-constants';
|
|
2
|
+
import { type LynxTemplate, type NativeApp, type NativeModulesMap } from '@lynx-js/web-constants';
|
|
3
3
|
export declare function createNativeApp(config: {
|
|
4
4
|
template: LynxTemplate;
|
|
5
5
|
uiThreadRpc: Rpc;
|
|
6
6
|
mainThreadRpc: Rpc;
|
|
7
7
|
markTimingInternal: (timingKey: string, pipelineId?: string) => void;
|
|
8
|
-
|
|
9
|
-
}): NativeApp
|
|
8
|
+
nativeModulesMap: NativeModulesMap;
|
|
9
|
+
}): Promise<NativeApp>;
|
|
@@ -12,8 +12,8 @@ import { registerOnNativeAppReadyHandler } from './crossThreadHandlers/registerO
|
|
|
12
12
|
import { registerSendGlobalEventHandler } from './crossThreadHandlers/registerSendGlobalEvent.js';
|
|
13
13
|
import { createJSObjectDestructionObserver } from './crossThreadHandlers/createJSObjectDestructionObserver.js';
|
|
14
14
|
let nativeAppCount = 0;
|
|
15
|
-
export function createNativeApp(config) {
|
|
16
|
-
const { mainThreadRpc, uiThreadRpc, markTimingInternal, template,
|
|
15
|
+
export async function createNativeApp(config) {
|
|
16
|
+
const { mainThreadRpc, uiThreadRpc, markTimingInternal, template, nativeModulesMap, } = config;
|
|
17
17
|
const { performanceApis, pipelineIdToTimingFlags } = createPerformanceApis(markTimingInternal);
|
|
18
18
|
const callLepusMethod = mainThreadRpc.createCallbackify(callLepusMethodEndpoint, 2);
|
|
19
19
|
const setNativeProps = uiThreadRpc.createCall(setNativePropsEndpoint);
|
|
@@ -26,7 +26,7 @@ export function createNativeApp(config) {
|
|
|
26
26
|
setInterval: setInterval,
|
|
27
27
|
clearTimeout: clearTimeout,
|
|
28
28
|
clearInterval: clearInterval,
|
|
29
|
-
nativeModuleProxy: createNativeModules(uiThreadRpc,
|
|
29
|
+
nativeModuleProxy: await createNativeModules(uiThreadRpc, nativeModulesMap),
|
|
30
30
|
loadScriptAsync: function (sourceURL, callback) {
|
|
31
31
|
const mainfestUrl = template.manifest[`/${sourceURL}`];
|
|
32
32
|
if (mainfestUrl)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { type NativeModulesMap } from '@lynx-js/web-constants';
|
|
1
2
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function createNativeModules(rpc: Rpc,
|
|
3
|
+
export declare function createNativeModules(rpc: Rpc, nativeModulesMap: NativeModulesMap): Promise<Record<string, any>>;
|
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
import { nativeModulesCallEndpoint, switchExposureService, } from '@lynx-js/web-constants';
|
|
5
|
-
export function createNativeModules(rpc,
|
|
5
|
+
export async function createNativeModules(rpc, nativeModulesMap) {
|
|
6
6
|
const switchExposure = rpc.createCall(switchExposureService);
|
|
7
7
|
const nativeModulesCall = rpc.createCall(nativeModulesCallEndpoint);
|
|
8
8
|
const lynxExposureModule = {
|
|
@@ -18,35 +18,13 @@ export function createNativeModules(rpc, customNativeModules) {
|
|
|
18
18
|
nativeModulesCall(name, data, 'bridge').then(callback);
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
const nativeModules = {};
|
|
22
|
+
const customNativeModules = {};
|
|
23
|
+
await Promise.all(Object.entries(nativeModulesMap).map(([moduleName, moduleStr]) => import(/* webpackIgnore: true */ moduleStr).then(module => customNativeModules[moduleName] = module?.default?.(nativeModules, (name, data) => nativeModulesCall(name, data, moduleName)))));
|
|
24
|
+
return Object.assign(nativeModules, {
|
|
22
25
|
bridge: bridgeModule,
|
|
23
26
|
LynxExposureModule: lynxExposureModule,
|
|
24
|
-
...
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function recursiveFunctionCallBinder(nativeModulesCall, customNativeModules) {
|
|
28
|
-
const newObj = Object.fromEntries(Object.entries(customNativeModules).map(([moduleName, moduleImpl]) => {
|
|
29
|
-
if (typeof moduleImpl === 'object') {
|
|
30
|
-
for (const [property, value] of Object.entries(moduleImpl)) {
|
|
31
|
-
if (typeof value === 'function') {
|
|
32
|
-
moduleImpl[property] = bindThisContext({
|
|
33
|
-
nativeModulesCall,
|
|
34
|
-
moduleName,
|
|
35
|
-
func: value,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return [moduleName, moduleImpl];
|
|
41
|
-
}));
|
|
42
|
-
return newObj;
|
|
43
|
-
}
|
|
44
|
-
function bindThisContext({ nativeModulesCall, moduleName, func }) {
|
|
45
|
-
const context = {
|
|
46
|
-
nativeModulesCall(name, data) {
|
|
47
|
-
return nativeModulesCall(name, data, moduleName);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
return func.bind(context);
|
|
27
|
+
...customNativeModules,
|
|
28
|
+
});
|
|
51
29
|
}
|
|
52
30
|
//# sourceMappingURL=createNativeModules.js.map
|
|
@@ -7,6 +7,7 @@ import { createNativeApp } from './createNativeApp.js';
|
|
|
7
7
|
import { registerDisposeHandler } from './crossThreadHandlers/registerDisposeHandler.js';
|
|
8
8
|
import { createMarkTimingInternal } from './crossThreadHandlers/createBackgroundMarkTimingInternal.js';
|
|
9
9
|
import { BackgroundThreadStartEndpoint } from '@lynx-js/web-constants';
|
|
10
|
+
import { createNapiLoader } from './createNapiLoader.js';
|
|
10
11
|
const lynxCore = import(
|
|
11
12
|
/* webpackMode: "eager" */ '@lynx-js/lynx-core/web');
|
|
12
13
|
export function startBackgroundThread(uiThreadPort, mainThreadPort) {
|
|
@@ -16,17 +17,14 @@ export function startBackgroundThread(uiThreadPort, mainThreadPort) {
|
|
|
16
17
|
markTimingInternal('load_core_start');
|
|
17
18
|
mainThreadRpc.registerHandler(BackgroundThreadStartEndpoint, async (config) => {
|
|
18
19
|
markTimingInternal('load_core_end');
|
|
19
|
-
const
|
|
20
|
-
? (await import(
|
|
21
|
-
/* webpackIgnore: true */ config.nativeModulesUrl))?.default ?? {}
|
|
22
|
-
: {};
|
|
23
|
-
const nativeApp = createNativeApp({
|
|
20
|
+
const nativeApp = await createNativeApp({
|
|
24
21
|
...config,
|
|
25
22
|
uiThreadRpc,
|
|
26
23
|
mainThreadRpc,
|
|
27
24
|
markTimingInternal,
|
|
28
|
-
customNativeModules,
|
|
29
25
|
});
|
|
26
|
+
globalThis['napiLoaderOnRT' + nativeApp.id] =
|
|
27
|
+
await createNapiLoader(uiThreadRpc, config.napiModulesMap);
|
|
30
28
|
const nativeLynx = createBackgroundLynx(config, nativeApp, mainThreadRpc);
|
|
31
29
|
lynxCore.then(({ loadCard, destroyCard, callDestroyLifetimeFun }) => {
|
|
32
30
|
loadCard(nativeApp, config, nativeLynx);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
import { startBackgroundThread } from './backgroundThread/index.js';
|
|
5
5
|
import { startMainThread } from './mainThread/startMainThread.js';
|
|
6
6
|
self.onmessage = (ev) => {
|
|
7
|
-
const { mode, toPeerThread, toUIThread } = ev
|
|
7
|
+
const { mode, toPeerThread, toUIThread, pixelRatio } = ev
|
|
8
|
+
.data;
|
|
9
|
+
globalThis.SystemInfo.pixelRatio = pixelRatio;
|
|
8
10
|
if (mode === 'main') {
|
|
9
11
|
startMainThread(toUIThread, toPeerThread);
|
|
10
12
|
}
|
|
@@ -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 { BackgroundThreadStartEndpoint, mainThreadChunkReadyEndpoint, mainThreadStartEndpoint, onLifecycleEventEndpoint,
|
|
4
|
+
import { BackgroundThreadStartEndpoint, mainThreadChunkReadyEndpoint, mainThreadStartEndpoint, onLifecycleEventEndpoint, flushElementTreeEndpoint, reportErrorEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { Rpc } from '@lynx-js/web-worker-rpc';
|
|
6
6
|
import { MainThreadRuntime } from '@lynx-js/web-mainthread-apis';
|
|
7
7
|
import { registerCallLepusMethodHandler } from './crossThreadHandlers/registerCallLepusMethodHandler.js';
|
|
@@ -16,18 +16,18 @@ export function startMainThread(uiThreadPort, backgroundThreadPort) {
|
|
|
16
16
|
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
17
17
|
const __OnLifecycleEvent = backgroundThreadRpc.createCall(onLifecycleEventEndpoint);
|
|
18
18
|
const mainThreadChunkReady = uiThreadRpc.createCall(mainThreadChunkReadyEndpoint);
|
|
19
|
-
const onNewTag = uiThreadRpc.createCall(loadNewTagEndpoint);
|
|
20
19
|
const flushElementTree = uiThreadRpc.createCall(flushElementTreeEndpoint);
|
|
20
|
+
const reportError = uiThreadRpc.createCall(reportErrorEndpoint);
|
|
21
21
|
markTimingInternal('lepus_excute_start');
|
|
22
22
|
uiThreadRpc.registerHandler(mainThreadStartEndpoint, async (config) => {
|
|
23
|
-
const { globalProps, template,
|
|
23
|
+
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, } = config;
|
|
24
24
|
const { styleInfo, pageConfig, customSections, cardType, lepusCode } = template;
|
|
25
25
|
markTimingInternal('decode_start');
|
|
26
26
|
await import(
|
|
27
27
|
/* webpackIgnore: true */ template.lepusCode.root);
|
|
28
28
|
const entry = globalThis.module.exports;
|
|
29
29
|
const runtime = new MainThreadRuntime({
|
|
30
|
-
|
|
30
|
+
tagMap,
|
|
31
31
|
browserConfig,
|
|
32
32
|
customSections,
|
|
33
33
|
globalProps,
|
|
@@ -52,16 +52,14 @@ export function startMainThread(uiThreadPort, backgroundThreadPort) {
|
|
|
52
52
|
template,
|
|
53
53
|
cardType: cardType ?? 'react',
|
|
54
54
|
customSections: Object.fromEntries(Object.entries(customSections).filter(([, value]) => value.type !== 'lazy').map(([k, v]) => [k, v.content])),
|
|
55
|
-
|
|
55
|
+
nativeModulesMap,
|
|
56
|
+
napiModulesMap,
|
|
56
57
|
});
|
|
57
58
|
runtime.renderPage(initData);
|
|
58
59
|
runtime.__FlushElementTree(undefined, {});
|
|
59
60
|
},
|
|
60
|
-
onNewTag,
|
|
61
61
|
flushElementTree,
|
|
62
|
-
_ReportError:
|
|
63
|
-
console.error('main-thread:', error, info);
|
|
64
|
-
},
|
|
62
|
+
_ReportError: reportError,
|
|
65
63
|
__OnLifecycleEvent,
|
|
66
64
|
/**
|
|
67
65
|
* Note :
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@lynx-js/web-constants": "0.
|
|
26
|
-
"@lynx-js/web-mainthread-apis": "0.
|
|
27
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
25
|
+
"@lynx-js/web-constants": "0.9.0",
|
|
26
|
+
"@lynx-js/web-mainthread-apis": "0.9.0",
|
|
27
|
+
"@lynx-js/web-worker-rpc": "0.9.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@lynx-js/lynx-core": "0.1.0"
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
import { reportErrorEndpoint } from '@lynx-js/web-constants';
|
|
5
|
-
export function createReportError(rpc) {
|
|
6
|
-
return (error, info) => {
|
|
7
|
-
rpc.invoke(reportErrorEndpoint, ['main-thread', error.toString(), info]);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=createReportError.js.map
|