@lynx-js/web-worker-runtime 0.13.3 → 0.13.5
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 +28 -0
- package/dist/backgroundThread/background-apis/createBackgroundLynx.d.ts +4 -1
- package/dist/backgroundThread/background-apis/createBackgroundLynx.js +5 -1
- package/dist/backgroundThread/background-apis/createElement.d.ts +5 -0
- package/dist/backgroundThread/background-apis/createElement.js +18 -0
- package/dist/backgroundThread/background-apis/createNativeApp.js +8 -6
- package/dist/backgroundThread/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.d.ts +3 -0
- package/dist/backgroundThread/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.js +8 -0
- package/dist/backgroundThread/background-apis/startBackgroundThread.js +1 -1
- package/dist/mainThread/crossThreadHandlers/registerUpdateDataHandler.d.ts +2 -2
- package/dist/mainThread/crossThreadHandlers/registerUpdateDataHandler.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.13.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- refactor: implement mts apis in closure pattern ([#1004](https://github.com/lynx-family/lynx-stack/pull/1004))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`70b82d2`](https://github.com/lynx-family/lynx-stack/commit/70b82d23744d6b6ec945dff9f8895ab3488ba4c8), [`5651e24`](https://github.com/lynx-family/lynx-stack/commit/5651e24827358963c3261252bcc53c2ad981c13e), [`9499ea9`](https://github.com/lynx-family/lynx-stack/commit/9499ea91debdf73b2d31af0b31bcbc216135543b), [`50f0193`](https://github.com/lynx-family/lynx-stack/commit/50f01933942268b697bf5abe790da86c932f1dfc), [`57bf0ef`](https://github.com/lynx-family/lynx-stack/commit/57bf0ef19f1d79bc52ab6a4f0cd2939e7901d98b), [`5651e24`](https://github.com/lynx-family/lynx-stack/commit/5651e24827358963c3261252bcc53c2ad981c13e), [`0525fbf`](https://github.com/lynx-family/lynx-stack/commit/0525fbf38baa7a977a7a8c66e8a4d8bf34cc3b68), [`b6b87fd`](https://github.com/lynx-family/lynx-stack/commit/b6b87fd11dbc76c28f3b5022aa8c6afeb773d90f), [`c014327`](https://github.com/lynx-family/lynx-stack/commit/c014327ad0cf599b32d4182d95116b46c35f5fa5)]:
|
|
10
|
+
- @lynx-js/web-mainthread-apis@0.13.5
|
|
11
|
+
- @lynx-js/web-constants@0.13.5
|
|
12
|
+
- @lynx-js/offscreen-document@0.1.1
|
|
13
|
+
- @lynx-js/web-worker-rpc@0.13.5
|
|
14
|
+
|
|
15
|
+
## 0.13.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- feat: lynx-view supports `updateGlobalProps` method, which can be used to update lynx.\_\_globalProps ([#918](https://github.com/lynx-family/lynx-stack/pull/918))
|
|
20
|
+
|
|
21
|
+
- feat: supports `lynx.getElementById()` && `animate()`. ([#912](https://github.com/lynx-family/lynx-stack/pull/912))
|
|
22
|
+
|
|
23
|
+
After this commit, you can use `lynx.getElementById()` to get the element by id, and use `element.animate()` to animate the element.
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`96d3133`](https://github.com/lynx-family/lynx-stack/commit/96d3133b149b61af01c5478f4dc7b0a071137d98), [`75e5b2f`](https://github.com/lynx-family/lynx-stack/commit/75e5b2ff16ecf5f7072a45cd130e653dee747461), [`569618d`](https://github.com/lynx-family/lynx-stack/commit/569618d8e2665f5c9e1672f7ee5900ec2a5179a2), [`f9f88d6`](https://github.com/lynx-family/lynx-stack/commit/f9f88d6fb9c42d3370a6622d9d799d671ffcf1a7)]:
|
|
26
|
+
- @lynx-js/web-mainthread-apis@0.13.4
|
|
27
|
+
- @lynx-js/offscreen-document@0.1.0
|
|
28
|
+
- @lynx-js/web-constants@0.13.4
|
|
29
|
+
- @lynx-js/web-worker-rpc@0.13.4
|
|
30
|
+
|
|
3
31
|
## 0.13.3
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ export interface CreateLynxConfig {
|
|
|
4
4
|
globalProps: unknown;
|
|
5
5
|
customSections: Record<string, Cloneable>;
|
|
6
6
|
}
|
|
7
|
-
export declare function createBackgroundLynx(config: CreateLynxConfig, nativeApp: NativeApp, mainThreadRpc: Rpc): {
|
|
7
|
+
export declare function createBackgroundLynx(config: CreateLynxConfig, nativeApp: NativeApp, mainThreadRpc: Rpc, uiThreadRpc: Rpc): {
|
|
8
8
|
__globalProps: unknown;
|
|
9
9
|
getJSModule(_moduleName: string): any;
|
|
10
10
|
getNativeApp(): NativeApp;
|
|
@@ -12,4 +12,7 @@ export declare function createBackgroundLynx(config: CreateLynxConfig, nativeApp
|
|
|
12
12
|
getCustomSectionSync(key: string): Cloneable;
|
|
13
13
|
getCustomSection: (key: string, callback: (object: Cloneable) => void) => void;
|
|
14
14
|
queueMicrotask: (callback: () => void) => void;
|
|
15
|
+
createElement(_: string, id: string): {
|
|
16
|
+
animate(operation: import("@lynx-js/web-constants").AnimationOperation, id: string, keyframes?: Record<string, any>[], timingOptions?: Record<string, any>): void;
|
|
17
|
+
};
|
|
15
18
|
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { dispatchCoreContextOnBackgroundEndpoint, dispatchJSContextOnMainThreadEndpoint, LynxCrossThreadContext, } from '@lynx-js/web-constants';
|
|
5
5
|
import { createGetCustomSection } from './crossThreadHandlers/createGetCustomSection.js';
|
|
6
|
-
|
|
6
|
+
import { createElement } from './createElement.js';
|
|
7
|
+
export function createBackgroundLynx(config, nativeApp, mainThreadRpc, uiThreadRpc) {
|
|
7
8
|
const coreContext = new LynxCrossThreadContext({
|
|
8
9
|
rpc: mainThreadRpc,
|
|
9
10
|
receiveEventEndpoint: dispatchCoreContextOnBackgroundEndpoint,
|
|
@@ -26,6 +27,9 @@ export function createBackgroundLynx(config, nativeApp, mainThreadRpc) {
|
|
|
26
27
|
queueMicrotask: (callback) => {
|
|
27
28
|
queueMicrotask(callback);
|
|
28
29
|
},
|
|
30
|
+
createElement(_, id) {
|
|
31
|
+
return createElement(id, uiThreadRpc);
|
|
32
|
+
},
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=createBackgroundLynx.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnimationOperation } from '@lynx-js/web-constants/src/types/Element.js';
|
|
2
|
+
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
+
export declare const createElement: (elementId: string, uiThreadRpc: Rpc) => {
|
|
4
|
+
animate(operation: AnimationOperation, id: string, keyframes?: Record<string, any>[], timingOptions?: Record<string, any>): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { triggerElementMethodEndpoint } from '@lynx-js/web-constants';
|
|
5
|
+
export const createElement = (elementId, uiThreadRpc) => {
|
|
6
|
+
const triggerElementMethod = uiThreadRpc.createCall(triggerElementMethodEndpoint);
|
|
7
|
+
return {
|
|
8
|
+
animate(operation, id, keyframes, timingOptions) {
|
|
9
|
+
triggerElementMethod('animate', elementId, {
|
|
10
|
+
operation,
|
|
11
|
+
id,
|
|
12
|
+
keyframes,
|
|
13
|
+
timingOptions,
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=createElement.js.map
|
|
@@ -8,6 +8,7 @@ import { registerPublishEventHandler } from './crossThreadHandlers/registerPubli
|
|
|
8
8
|
import { createPerformanceApis } from './createPerformanceApis.js';
|
|
9
9
|
import { registerSendGlobalEventHandler } from './crossThreadHandlers/registerSendGlobalEvent.js';
|
|
10
10
|
import { createJSObjectDestructionObserver } from './crossThreadHandlers/createJSObjectDestructionObserver.js';
|
|
11
|
+
import { registerUpdateGlobalPropsHandler } from './crossThreadHandlers/registerUpdateGlobalPropsHandler.js';
|
|
11
12
|
let nativeAppCount = 0;
|
|
12
13
|
const sharedData = {};
|
|
13
14
|
export async function createNativeApp(config) {
|
|
@@ -53,9 +54,9 @@ export async function createNativeApp(config) {
|
|
|
53
54
|
clearInterval: clearInterval,
|
|
54
55
|
nativeModuleProxy: await createNativeModules(uiThreadRpc, mainThreadRpc, nativeModulesMap),
|
|
55
56
|
loadScriptAsync: function (sourceURL, callback) {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
sourceURL =
|
|
57
|
+
const manifestUrl = template.manifest[`/${sourceURL}`];
|
|
58
|
+
if (manifestUrl)
|
|
59
|
+
sourceURL = manifestUrl;
|
|
59
60
|
import(
|
|
60
61
|
/* webpackIgnore: true */
|
|
61
62
|
sourceURL).catch(callback).then(async () => {
|
|
@@ -63,9 +64,9 @@ export async function createNativeApp(config) {
|
|
|
63
64
|
});
|
|
64
65
|
},
|
|
65
66
|
loadScript: (sourceURL) => {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
sourceURL =
|
|
67
|
+
const manifestUrl = template.manifest[`/${sourceURL}`];
|
|
68
|
+
if (manifestUrl)
|
|
69
|
+
sourceURL = manifestUrl;
|
|
69
70
|
importScripts(sourceURL);
|
|
70
71
|
return createBundleInitReturnObj();
|
|
71
72
|
},
|
|
@@ -84,6 +85,7 @@ export async function createNativeApp(config) {
|
|
|
84
85
|
registerGlobalExposureEventHandler(mainThreadRpc, tt);
|
|
85
86
|
registerUpdateDataHandler(uiThreadRpc, tt);
|
|
86
87
|
registerSendGlobalEventHandler(uiThreadRpc, tt);
|
|
88
|
+
registerUpdateGlobalPropsHandler(uiThreadRpc, tt);
|
|
87
89
|
timingSystem.registerGlobalEmitter(tt.GlobalEventEmitter);
|
|
88
90
|
tt.lynx.getCoreContext().__start();
|
|
89
91
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { updateGlobalPropsEndpoint, } from '@lynx-js/web-constants';
|
|
5
|
+
export function registerUpdateGlobalPropsHandler(rpc, tt) {
|
|
6
|
+
rpc.registerHandlerLazy(updateGlobalPropsEndpoint, tt, 'updateGlobalProps');
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=registerUpdateGlobalPropsHandler.js.map
|
|
@@ -25,7 +25,7 @@ export function startBackgroundThread(uiThreadPort, mainThreadPort) {
|
|
|
25
25
|
});
|
|
26
26
|
globalThis['napiLoaderOnRT' + nativeApp.id] =
|
|
27
27
|
await createNapiLoader(uiThreadRpc, config.napiModulesMap);
|
|
28
|
-
const nativeLynx = createBackgroundLynx(config, nativeApp, mainThreadRpc);
|
|
28
|
+
const nativeLynx = createBackgroundLynx(config, nativeApp, mainThreadRpc, uiThreadRpc);
|
|
29
29
|
lynxCore.then(({ loadCard, destroyCard, callDestroyLifetimeFun }) => {
|
|
30
30
|
loadCard(nativeApp, config, nativeLynx);
|
|
31
31
|
registerDisposeHandler(uiThreadRpc, nativeApp, destroyCard, callDestroyLifetimeFun);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MainThreadGlobalThis } from '@lynx-js/web-constants';
|
|
2
2
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
-
export declare function registerUpdateDataHandler(rpc: Rpc, runtime:
|
|
3
|
+
export declare function registerUpdateDataHandler(rpc: Rpc, runtime: MainThreadGlobalThis): void;
|
|
@@ -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 { updateDataEndpoint } from '@lynx-js/web-constants';
|
|
4
|
+
import { updateDataEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
export function registerUpdateDataHandler(rpc, runtime) {
|
|
6
6
|
rpc.registerHandler(updateDataEndpoint, (...args) => {
|
|
7
7
|
runtime.updatePage?.(...args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
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.
|
|
26
|
-
"@lynx-js/web-constants": "0.13.
|
|
27
|
-
"@lynx-js/web-mainthread-apis": "0.13.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "0.13.
|
|
25
|
+
"@lynx-js/offscreen-document": "0.1.1",
|
|
26
|
+
"@lynx-js/web-constants": "0.13.5",
|
|
27
|
+
"@lynx-js/web-mainthread-apis": "0.13.5",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "0.13.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@lynx-js/lynx-core": "0.1.2"
|