@lynx-js/web-worker-runtime 0.12.0 → 0.13.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 +49 -0
- package/dist/backgroundThread/background-apis/createBackgroundLynx.d.ts +2 -2
- package/dist/backgroundThread/background-apis/createBackgroundLynx.js +4 -2
- package/dist/backgroundThread/background-apis/createNativeApp.d.ts +2 -1
- package/dist/backgroundThread/background-apis/createNativeApp.js +18 -19
- package/dist/backgroundThread/background-apis/createNativeModules.js +2 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/dist/mainThread/startMainThread.js +13 -106
- package/package.json +5 -5
- package/dist/common/LynxCrossThreadContext.d.ts +0 -12
- package/dist/common/LynxCrossThreadContext.js +0 -24
- package/dist/mainThread/crossThreadHandlers/registerCallLepusMethodHandler.d.ts +0 -3
- package/dist/mainThread/crossThreadHandlers/registerCallLepusMethodHandler.js +0 -10
- package/dist/mainThread/crossThreadHandlers/registerGetCustomSectionHandler.d.ts +0 -3
- package/dist/mainThread/crossThreadHandlers/registerGetCustomSectionHandler.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: support for using `lynx.queueMicrotask`. ([#702](https://github.com/lynx-family/lynx-stack/pull/702))
|
|
8
|
+
|
|
9
|
+
- feat: support touch events for MTS ([#641](https://github.com/lynx-family/lynx-stack/pull/641))
|
|
10
|
+
|
|
11
|
+
now we support
|
|
12
|
+
|
|
13
|
+
- main-thread:bindtouchstart
|
|
14
|
+
- main-thread:bindtouchend
|
|
15
|
+
- main-thread:bindtouchmove
|
|
16
|
+
- main-thread:bindtouchcancel
|
|
17
|
+
|
|
18
|
+
- feat: provide comments for `@lynx-js/web-platform-rsbuild-plugin`. ([#668](https://github.com/lynx-family/lynx-stack/pull/668))
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91), [`9ad394e`](https://github.com/lynx-family/lynx-stack/commit/9ad394ea9ef28688a3b810b4051868b2a28eb7de), [`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91)]:
|
|
21
|
+
- @lynx-js/offscreen-document@0.0.2
|
|
22
|
+
- @lynx-js/web-mainthread-apis@0.13.1
|
|
23
|
+
- @lynx-js/web-constants@0.13.1
|
|
24
|
+
- @lynx-js/web-worker-rpc@0.13.1
|
|
25
|
+
|
|
26
|
+
## 0.13.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- refactor: isolate SystemInfo ([#628](https://github.com/lynx-family/lynx-stack/pull/628))
|
|
31
|
+
|
|
32
|
+
Never assign `SystemInfo` on worker's self object.
|
|
33
|
+
|
|
34
|
+
- feat: support thread strategy `all-on-ui` ([#625](https://github.com/lynx-family/lynx-stack/pull/625))
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<lynx-view thread-strategy="all-on-ui"></lynx-view>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This will make the lynx's main-thread run on the UA's main thread.
|
|
41
|
+
|
|
42
|
+
Note that the `all-on-ui` does not support the HMR & chunk splitting yet.
|
|
43
|
+
|
|
44
|
+
- refactor: move mainthread impl into mainthread-api packages ([#622](https://github.com/lynx-family/lynx-stack/pull/622))
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`4ee0465`](https://github.com/lynx-family/lynx-stack/commit/4ee0465f6e5846a0d038b49d2a7c95e87c9e5c77), [`74b5bd1`](https://github.com/lynx-family/lynx-stack/commit/74b5bd15339b70107a7c42525494da46e8f8f6bd), [`06bb78a`](https://github.com/lynx-family/lynx-stack/commit/06bb78a6b93d4a7be7177a6269dd4337852ce90d), [`5a3d9af`](https://github.com/lynx-family/lynx-stack/commit/5a3d9afe52ba639987db124ca35580261e0718b5), [`5269cab`](https://github.com/lynx-family/lynx-stack/commit/5269cabef7609159bdd0dd14a03c5da667907424), [`74b5bd1`](https://github.com/lynx-family/lynx-stack/commit/74b5bd15339b70107a7c42525494da46e8f8f6bd), [`2b069f8`](https://github.com/lynx-family/lynx-stack/commit/2b069f8786c95bdb9ac1f35091f05f7fd3b52225)]:
|
|
47
|
+
- @lynx-js/web-mainthread-apis@0.13.0
|
|
48
|
+
- @lynx-js/web-constants@0.13.0
|
|
49
|
+
- @lynx-js/offscreen-document@0.0.1
|
|
50
|
+
- @lynx-js/web-worker-rpc@0.13.0
|
|
51
|
+
|
|
3
52
|
## 0.12.0
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type Cloneable, type NativeApp } from '@lynx-js/web-constants';
|
|
1
|
+
import { LynxCrossThreadContext, type Cloneable, type NativeApp } from '@lynx-js/web-constants';
|
|
2
2
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
-
import { LynxCrossThreadContext } from '../../common/LynxCrossThreadContext.js';
|
|
4
3
|
export interface CreateLynxConfig {
|
|
5
4
|
globalProps: unknown;
|
|
6
5
|
customSections: Record<string, Cloneable>;
|
|
@@ -12,4 +11,5 @@ export declare function createBackgroundLynx(config: CreateLynxConfig, nativeApp
|
|
|
12
11
|
getCoreContext(): LynxCrossThreadContext;
|
|
13
12
|
getCustomSectionSync(key: string): Cloneable;
|
|
14
13
|
getCustomSection: (key: string, callback: (object: Cloneable) => void) => void;
|
|
14
|
+
queueMicrotask: (callback: () => void) => void;
|
|
15
15
|
};
|
|
@@ -1,9 +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 { dispatchCoreContextOnBackgroundEndpoint, dispatchJSContextOnMainThreadEndpoint, } from '@lynx-js/web-constants';
|
|
4
|
+
import { dispatchCoreContextOnBackgroundEndpoint, dispatchJSContextOnMainThreadEndpoint, LynxCrossThreadContext, } from '@lynx-js/web-constants';
|
|
5
5
|
import { createGetCustomSection } from './crossThreadHandlers/createGetCustomSection.js';
|
|
6
|
-
import { LynxCrossThreadContext } from '../../common/LynxCrossThreadContext.js';
|
|
7
6
|
export function createBackgroundLynx(config, nativeApp, mainThreadRpc) {
|
|
8
7
|
const coreContext = new LynxCrossThreadContext({
|
|
9
8
|
rpc: mainThreadRpc,
|
|
@@ -24,6 +23,9 @@ export function createBackgroundLynx(config, nativeApp, mainThreadRpc) {
|
|
|
24
23
|
return config.customSections[key];
|
|
25
24
|
},
|
|
26
25
|
getCustomSection: createGetCustomSection(mainThreadRpc, config.customSections),
|
|
26
|
+
queueMicrotask: (callback) => {
|
|
27
|
+
queueMicrotask(callback);
|
|
28
|
+
},
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=createBackgroundLynx.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
import { type LynxTemplate, type NativeApp, type NativeModulesMap } from '@lynx-js/web-constants';
|
|
2
|
+
import { type LynxTemplate, type NativeApp, type NativeModulesMap, type BrowserConfig } from '@lynx-js/web-constants';
|
|
3
3
|
import type { TimingSystem } from './createTimingSystem.js';
|
|
4
4
|
export declare function createNativeApp(config: {
|
|
5
5
|
template: LynxTemplate;
|
|
@@ -7,4 +7,5 @@ export declare function createNativeApp(config: {
|
|
|
7
7
|
mainThreadRpc: Rpc;
|
|
8
8
|
nativeModulesMap: NativeModulesMap;
|
|
9
9
|
timingSystem: TimingSystem;
|
|
10
|
+
browserConfig: BrowserConfig;
|
|
10
11
|
}): Promise<NativeApp>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { callLepusMethodEndpoint, setNativePropsEndpoint, triggerComponentEventEndpoint, selectComponentEndpoint, } from '@lynx-js/web-constants';
|
|
1
|
+
import { callLepusMethodEndpoint, setNativePropsEndpoint, triggerComponentEventEndpoint, selectComponentEndpoint, systemInfo, } from '@lynx-js/web-constants';
|
|
2
2
|
import { createInvokeUIMethod } from './crossThreadHandlers/createInvokeUIMethod.js';
|
|
3
3
|
import { registerPublicComponentEventHandler } from './crossThreadHandlers/registerPublicComponentEventHandler.js';
|
|
4
4
|
import { registerGlobalExposureEventHandler } from './crossThreadHandlers/registerGlobalExposureEventHandler.js';
|
|
@@ -11,12 +11,26 @@ import { createJSObjectDestructionObserver } from './crossThreadHandlers/createJ
|
|
|
11
11
|
let nativeAppCount = 0;
|
|
12
12
|
const sharedData = {};
|
|
13
13
|
export async function createNativeApp(config) {
|
|
14
|
-
const { mainThreadRpc, uiThreadRpc, template, nativeModulesMap, timingSystem, } = config;
|
|
14
|
+
const { mainThreadRpc, uiThreadRpc, template, nativeModulesMap, timingSystem, browserConfig, } = config;
|
|
15
15
|
const performanceApis = createPerformanceApis(timingSystem);
|
|
16
16
|
const callLepusMethod = mainThreadRpc.createCallbackify(callLepusMethodEndpoint, 2);
|
|
17
17
|
const setNativeProps = uiThreadRpc.createCall(setNativePropsEndpoint);
|
|
18
18
|
const triggerComponentEvent = uiThreadRpc.createCall(triggerComponentEventEndpoint);
|
|
19
19
|
const selectComponent = uiThreadRpc.createCallbackify(selectComponentEndpoint, 3);
|
|
20
|
+
const createBundleInitReturnObj = () => {
|
|
21
|
+
const entry = globalThis.module.exports;
|
|
22
|
+
return {
|
|
23
|
+
init: (lynxCoreInject) => {
|
|
24
|
+
lynxCoreInject.tt.lynxCoreInject = lynxCoreInject;
|
|
25
|
+
lynxCoreInject.tt.globalThis ??= lynxCoreInject;
|
|
26
|
+
Object.assign(lynxCoreInject.tt, {
|
|
27
|
+
SystemInfo: { ...systemInfo, ...browserConfig },
|
|
28
|
+
});
|
|
29
|
+
const ret = entry?.(lynxCoreInject.tt);
|
|
30
|
+
return ret;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
20
34
|
const nativeApp = {
|
|
21
35
|
id: (nativeAppCount++).toString(),
|
|
22
36
|
...performanceApis,
|
|
@@ -32,15 +46,7 @@ export async function createNativeApp(config) {
|
|
|
32
46
|
import(
|
|
33
47
|
/* webpackIgnore: true */
|
|
34
48
|
sourceURL).catch(callback).then(async () => {
|
|
35
|
-
callback(null,
|
|
36
|
-
init: (lynxCoreInject) => {
|
|
37
|
-
lynxCoreInject.tt.lynxCoreInject = lynxCoreInject;
|
|
38
|
-
lynxCoreInject.tt.globalThis ??= lynxCoreInject;
|
|
39
|
-
const entry = globalThis.module.exports;
|
|
40
|
-
const ret = entry?.(lynxCoreInject.tt);
|
|
41
|
-
return ret;
|
|
42
|
-
},
|
|
43
|
-
});
|
|
49
|
+
callback(null, createBundleInitReturnObj());
|
|
44
50
|
});
|
|
45
51
|
},
|
|
46
52
|
loadScript: (sourceURL) => {
|
|
@@ -48,14 +54,7 @@ export async function createNativeApp(config) {
|
|
|
48
54
|
if (mainfestUrl)
|
|
49
55
|
sourceURL = mainfestUrl;
|
|
50
56
|
importScripts(sourceURL);
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
init: (lynxCoreInject) => {
|
|
54
|
-
lynxCoreInject.tt.lynxCoreInject = lynxCoreInject;
|
|
55
|
-
lynxCoreInject.tt.globalThis ??= lynxCoreInject;
|
|
56
|
-
return entry?.(lynxCoreInject.tt);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
57
|
+
return createBundleInitReturnObj();
|
|
59
58
|
},
|
|
60
59
|
requestAnimationFrame(cb) {
|
|
61
60
|
return requestAnimationFrame(cb);
|
|
@@ -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_NATIVE_MODULES_IMPORT */
|
|
4
5
|
import { nativeModulesCallEndpoint, switchExposureServiceEndpoint, } from '@lynx-js/web-constants';
|
|
5
6
|
export async function createNativeModules(uiThreadRpc, mainThreadRpc, nativeModulesMap) {
|
|
6
7
|
const switchExposure = mainThreadRpc.createCall(switchExposureServiceEndpoint);
|
|
@@ -21,6 +22,7 @@ export async function createNativeModules(uiThreadRpc, mainThreadRpc, nativeModu
|
|
|
21
22
|
const nativeModules = {};
|
|
22
23
|
const customNativeModules = {};
|
|
23
24
|
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)))));
|
|
25
|
+
/* LYNX_NATIVE_MODULES_ADD */
|
|
24
26
|
return Object.assign(nativeModules, {
|
|
25
27
|
bridge: bridgeModule,
|
|
26
28
|
LynxExposureModule: lynxExposureModule,
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
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
|
|
7
|
+
const { mode, toPeerThread, toUIThread } = ev
|
|
8
8
|
.data;
|
|
9
|
-
globalThis.SystemInfo.pixelRatio = pixelRatio;
|
|
10
9
|
if (mode === 'main') {
|
|
11
10
|
startMainThread(toUIThread, toPeerThread);
|
|
12
11
|
}
|
|
@@ -15,7 +14,6 @@ self.onmessage = (ev) => {
|
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
16
|
Object.assign(globalThis, {
|
|
18
|
-
SystemInfo: { platform: 'web', lynxSdkVersion: '3.0' },
|
|
19
17
|
module: { exports: null },
|
|
20
18
|
});
|
|
21
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,121 +1,28 @@
|
|
|
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 {
|
|
4
|
+
import { flushElementTreeEndpoint, mainThreadStartEndpoint, postOffscreenEventEndpoint, reportErrorEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { Rpc } from '@lynx-js/web-worker-rpc';
|
|
6
|
-
import { MainThreadRuntime, switchExposureService, } from '@lynx-js/web-mainthread-apis';
|
|
7
|
-
import { registerCallLepusMethodHandler } from './crossThreadHandlers/registerCallLepusMethodHandler.js';
|
|
8
|
-
import { registerGetCustomSectionHandler } from './crossThreadHandlers/registerGetCustomSectionHandler.js';
|
|
9
6
|
import { createMarkTimingInternal } from './crossThreadHandlers/createMainthreadMarkTimingInternal.js';
|
|
10
|
-
import { registerUpdateDataHandler } from './crossThreadHandlers/registerUpdateDataHandler.js';
|
|
11
7
|
import { OffscreenDocument } from '@lynx-js/offscreen-document/webworker';
|
|
12
|
-
import { _onEvent
|
|
13
|
-
import {
|
|
8
|
+
import { _onEvent } from '@lynx-js/offscreen-document/webworker';
|
|
9
|
+
import { registerUpdateDataHandler } from './crossThreadHandlers/registerUpdateDataHandler.js';
|
|
10
|
+
const { loadMainThread } = await import('@lynx-js/web-mainthread-apis');
|
|
14
11
|
export function startMainThread(uiThreadPort, backgroundThreadPort) {
|
|
15
12
|
const uiThreadRpc = new Rpc(uiThreadPort, 'main-to-ui');
|
|
16
13
|
const backgroundThreadRpc = new Rpc(backgroundThreadPort, 'main-to-bg');
|
|
17
14
|
const markTimingInternal = createMarkTimingInternal(backgroundThreadRpc);
|
|
18
|
-
const
|
|
19
|
-
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
20
|
-
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
21
|
-
const publicComponentEvent = backgroundThreadRpc.createCall(publicComponentEventEndpoint);
|
|
22
|
-
const postExposure = backgroundThreadRpc.createCall(postExposureEndpoint);
|
|
23
|
-
let operations = [];
|
|
24
|
-
const flushElementTree = uiThreadRpc.createCall(flushElementTreeEndpoint);
|
|
15
|
+
const uiFlush = uiThreadRpc.createCall(flushElementTreeEndpoint);
|
|
25
16
|
const reportError = uiThreadRpc.createCall(reportErrorEndpoint);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const entry = globalThis.module.exports;
|
|
35
|
-
const docu = new OffscreenDocument({
|
|
36
|
-
onCommit: (currentOperations) => {
|
|
37
|
-
operations = currentOperations;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
uiThreadRpc.registerHandler(postOffscreenEventEndpoint, docu[_onEvent]);
|
|
41
|
-
const jsContext = new LynxCrossThreadContext({
|
|
42
|
-
rpc: backgroundThreadRpc,
|
|
43
|
-
receiveEventEndpoint: dispatchJSContextOnMainThreadEndpoint,
|
|
44
|
-
sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint,
|
|
17
|
+
const docu = new OffscreenDocument({
|
|
18
|
+
onCommit: uiFlush,
|
|
19
|
+
});
|
|
20
|
+
uiThreadRpc.registerHandler(postOffscreenEventEndpoint, docu[_onEvent]);
|
|
21
|
+
const { startMainThread } = loadMainThread(backgroundThreadRpc, docu, docu.commit.bind(docu), markTimingInternal, reportError);
|
|
22
|
+
uiThreadRpc.registerHandler(mainThreadStartEndpoint, (config) => {
|
|
23
|
+
startMainThread(config).then((runtime) => {
|
|
24
|
+
registerUpdateDataHandler(uiThreadRpc, runtime);
|
|
45
25
|
});
|
|
46
|
-
const runtime = new MainThreadRuntime({
|
|
47
|
-
jsContext,
|
|
48
|
-
tagMap,
|
|
49
|
-
browserConfig,
|
|
50
|
-
customSections,
|
|
51
|
-
globalProps,
|
|
52
|
-
pageConfig,
|
|
53
|
-
styleInfo,
|
|
54
|
-
lepusCode,
|
|
55
|
-
docu,
|
|
56
|
-
callbacks: {
|
|
57
|
-
mainChunkReady: () => {
|
|
58
|
-
markTimingInternal('data_processor_start');
|
|
59
|
-
const initData = runtime.processData
|
|
60
|
-
? runtime.processData(config.initData)
|
|
61
|
-
: config.initData;
|
|
62
|
-
markTimingInternal('data_processor_end');
|
|
63
|
-
registerCallLepusMethodHandler(backgroundThreadRpc, runtime);
|
|
64
|
-
registerGetCustomSectionHandler(backgroundThreadRpc, customSections);
|
|
65
|
-
registerUpdateDataHandler(uiThreadRpc, runtime);
|
|
66
|
-
backgroundThreadRpc.registerHandler(switchExposureServiceEndpoint, runtime[switchExposureService]);
|
|
67
|
-
backgroundStart({
|
|
68
|
-
initData,
|
|
69
|
-
globalProps,
|
|
70
|
-
template,
|
|
71
|
-
cardType: cardType ?? 'react',
|
|
72
|
-
customSections: Object.fromEntries(Object.entries(customSections).filter(([, value]) => value.type !== 'lazy').map(([k, v]) => [k, v.content])),
|
|
73
|
-
nativeModulesMap,
|
|
74
|
-
napiModulesMap,
|
|
75
|
-
});
|
|
76
|
-
runtime.renderPage(initData);
|
|
77
|
-
runtime.__FlushElementTree(undefined, {});
|
|
78
|
-
},
|
|
79
|
-
flushElementTree: async (options, timingFlags) => {
|
|
80
|
-
const pipelineId = options?.pipelineOptions?.pipelineID;
|
|
81
|
-
markTimingInternal('dispatch_start', pipelineId);
|
|
82
|
-
docu.commit();
|
|
83
|
-
if (isFp) {
|
|
84
|
-
isFp = false;
|
|
85
|
-
jsContext.dispatchEvent({
|
|
86
|
-
type: '__OnNativeAppReady',
|
|
87
|
-
data: undefined,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
markTimingInternal('layout_start', pipelineId);
|
|
91
|
-
markTimingInternal('ui_operation_flush_start', pipelineId);
|
|
92
|
-
await flushElementTree(operations);
|
|
93
|
-
markTimingInternal('ui_operation_flush_end', pipelineId);
|
|
94
|
-
markTimingInternal('layout_end', pipelineId);
|
|
95
|
-
markTimingInternal('dispatch_end', pipelineId);
|
|
96
|
-
postTimingFlags(timingFlags, pipelineId);
|
|
97
|
-
},
|
|
98
|
-
_ReportError: reportError,
|
|
99
|
-
__OnLifecycleEvent: (data) => {
|
|
100
|
-
jsContext.dispatchEvent({
|
|
101
|
-
type: '__OnLifecycleEvent',
|
|
102
|
-
data,
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Note :
|
|
107
|
-
* The parameter of lynx.performance.markTiming is (pipelineId:string, timingFlag:string)=>void
|
|
108
|
-
* But our markTimingInternal is (timingFlag:string, pipelineId?:string, timeStamp?:number) => void
|
|
109
|
-
*/
|
|
110
|
-
markTiming: (a, b) => markTimingInternal(b, a),
|
|
111
|
-
publishEvent,
|
|
112
|
-
publicComponentEvent,
|
|
113
|
-
postExposure,
|
|
114
|
-
},
|
|
115
|
-
}).globalThis;
|
|
116
|
-
markTimingInternal('decode_end');
|
|
117
|
-
entry(runtime);
|
|
118
|
-
jsContext.__start(); // start the jsContext after the runtime is created
|
|
119
26
|
});
|
|
120
27
|
}
|
|
121
28
|
//# sourceMappingURL=startMainThread.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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.0.
|
|
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.0.2",
|
|
26
|
+
"@lynx-js/web-constants": "0.13.1",
|
|
27
|
+
"@lynx-js/web-mainthread-apis": "0.13.1",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "0.13.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@lynx-js/lynx-core": "0.1.2"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type dispatchCoreContextOnBackgroundEndpoint, type LynxContextEventTarget, type Rpc } from '@lynx-js/web-constants';
|
|
2
|
-
export declare class LynxCrossThreadContext extends EventTarget implements LynxContextEventTarget {
|
|
3
|
-
private _config;
|
|
4
|
-
constructor(_config: {
|
|
5
|
-
rpc: Rpc;
|
|
6
|
-
receiveEventEndpoint: typeof dispatchCoreContextOnBackgroundEndpoint;
|
|
7
|
-
sendEventEndpoint: typeof dispatchCoreContextOnBackgroundEndpoint;
|
|
8
|
-
});
|
|
9
|
-
postMessage(...args: any[]): void;
|
|
10
|
-
dispatchEvent(event: ContextCrossThreadEvent): 3;
|
|
11
|
-
__start(): void;
|
|
12
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DispatchEventResult, } from '@lynx-js/web-constants';
|
|
2
|
-
export class LynxCrossThreadContext extends EventTarget {
|
|
3
|
-
_config;
|
|
4
|
-
constructor(_config) {
|
|
5
|
-
super();
|
|
6
|
-
this._config = _config;
|
|
7
|
-
}
|
|
8
|
-
postMessage(...args) {
|
|
9
|
-
console.error('[lynx-web] postMessage not implemented, args:', ...args);
|
|
10
|
-
}
|
|
11
|
-
// @ts-expect-error
|
|
12
|
-
dispatchEvent(event) {
|
|
13
|
-
const { rpc, sendEventEndpoint } = this._config;
|
|
14
|
-
rpc.invoke(sendEventEndpoint, [event]);
|
|
15
|
-
return DispatchEventResult.CanceledBeforeDispatch;
|
|
16
|
-
}
|
|
17
|
-
__start() {
|
|
18
|
-
const { rpc, receiveEventEndpoint } = this._config;
|
|
19
|
-
rpc.registerHandler(receiveEventEndpoint, ({ type, data }) => {
|
|
20
|
-
super.dispatchEvent(new MessageEvent(type, { data: data ?? {} }));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=LynxCrossThreadContext.js.map
|
|
@@ -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 { callLepusMethodEndpoint } from '@lynx-js/web-constants';
|
|
5
|
-
export function registerCallLepusMethodHandler(rpc, runtime) {
|
|
6
|
-
rpc.registerHandler(callLepusMethodEndpoint, (methodName, data) => {
|
|
7
|
-
(runtime[methodName])(data);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=registerCallLepusMethodHandler.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { getCustomSectionsEndpoint, } from '@lynx-js/web-constants';
|
|
2
|
-
export function registerGetCustomSectionHandler(rpc, customSections) {
|
|
3
|
-
rpc.registerHandler(getCustomSectionsEndpoint, (key) => {
|
|
4
|
-
return customSections[key]?.content;
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=registerGetCustomSectionHandler.js.map
|