@lynx-js/web-worker-runtime 0.13.1 → 0.13.3

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,42 @@
1
1
  # @lynx-js/web-worker-runtime
2
2
 
3
+ ## 0.13.3
4
+
5
+ ### Patch Changes
6
+
7
+ - refactor: code clean ([#897](https://github.com/lynx-family/lynx-stack/pull/897))
8
+
9
+ rename many internal apis to make logic be clear:
10
+
11
+ multi-thread: startMainWorker -> prepareMainThreadAPIs -> startMainThread -> createMainThreadContext(new MainThreadRuntime)
12
+ all-on-ui: prepareMainThreadAPIs -> startMainThread -> createMainThreadContext(new MainThreadRuntime)
13
+
14
+ - Updated dependencies [[`bb1f9d8`](https://github.com/lynx-family/lynx-stack/commit/bb1f9d845ef2395a0508666701409972e159389d), [`b6e27da`](https://github.com/lynx-family/lynx-stack/commit/b6e27daf865b0627b1c3238228a4fdf65ad87ee3), [`3d716d7`](https://github.com/lynx-family/lynx-stack/commit/3d716d79ae053b225e9bac2bbb036c968f5261e7)]:
15
+ - @lynx-js/offscreen-document@0.0.4
16
+ - @lynx-js/web-mainthread-apis@0.13.3
17
+ - @lynx-js/web-constants@0.13.3
18
+ - @lynx-js/web-worker-rpc@0.13.3
19
+
20
+ ## 0.13.2
21
+
22
+ ### Patch Changes
23
+
24
+ - feat: allow lynx code to get JS engine provided properties on globalThis ([#786](https://github.com/lynx-family/lynx-stack/pull/786))
25
+
26
+ ```
27
+ globalThis.Reflect; // this will be the Reflect Object
28
+ ```
29
+
30
+ Note that `assigning to the globalThis` is still not allowed.
31
+
32
+ - feat: return the offscreenDocument instance for startMainThread() ([#772](https://github.com/lynx-family/lynx-stack/pull/772))
33
+
34
+ - Updated dependencies [[`03a5f64`](https://github.com/lynx-family/lynx-stack/commit/03a5f64d7d09e38903f5d1c022f36f6e68b6432d), [`8cdd288`](https://github.com/lynx-family/lynx-stack/commit/8cdd28884288b9456aee3a919d6edbf72da1c67b), [`6d3d852`](https://github.com/lynx-family/lynx-stack/commit/6d3d8529d0d528419920102ca52da279bbe0f1e0)]:
35
+ - @lynx-js/web-mainthread-apis@0.13.2
36
+ - @lynx-js/web-constants@0.13.2
37
+ - @lynx-js/offscreen-document@0.0.3
38
+ - @lynx-js/web-worker-rpc@0.13.2
39
+
3
40
  ## 0.13.1
4
41
 
5
42
  ### Patch Changes
@@ -22,7 +22,20 @@ export async function createNativeApp(config) {
22
22
  return {
23
23
  init: (lynxCoreInject) => {
24
24
  lynxCoreInject.tt.lynxCoreInject = lynxCoreInject;
25
- lynxCoreInject.tt.globalThis ??= lynxCoreInject;
25
+ lynxCoreInject.tt.globalThis ??= new Proxy(lynxCoreInject, {
26
+ get(target, prop) {
27
+ // @ts-expect-error
28
+ return target[prop] ?? globalThis[prop];
29
+ },
30
+ set(target, prop, value) {
31
+ // @ts-expect-error
32
+ target[prop] = value;
33
+ return true;
34
+ },
35
+ ownKeys(target) {
36
+ return Reflect.ownKeys(target).filter((key) => key !== 'globalThis');
37
+ },
38
+ });
26
39
  Object.assign(lynxCoreInject.tt, {
27
40
  SystemInfo: { ...systemInfo, ...browserConfig },
28
41
  });
package/dist/index.js CHANGED
@@ -2,12 +2,12 @@
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 { startBackgroundThread } from './backgroundThread/index.js';
5
- import { startMainThread } from './mainThread/startMainThread.js';
6
- self.onmessage = (ev) => {
5
+ import { startMainThreadWorker } from './mainThread/startMainThread.js';
6
+ globalThis.onmessage = (ev) => {
7
7
  const { mode, toPeerThread, toUIThread } = ev
8
8
  .data;
9
9
  if (mode === 'main') {
10
- startMainThread(toUIThread, toPeerThread);
10
+ startMainThreadWorker(toUIThread, toPeerThread);
11
11
  }
12
12
  else {
13
13
  startBackgroundThread(toUIThread, toPeerThread);
@@ -1 +1 @@
1
- export { startMainThread } from './startMainThread.js';
1
+ export { startMainThreadWorker } from './startMainThread.js';
@@ -1,5 +1,5 @@
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
- export { startMainThread } from './startMainThread.js';
4
+ export { startMainThreadWorker } from './startMainThread.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export declare function startMainThread(uiThreadPort: MessagePort, backgroundThreadPort: MessagePort): void;
1
+ export declare function startMainThreadWorker(uiThreadPort: MessagePort, backgroundThreadPort: MessagePort): void;
@@ -7,8 +7,8 @@ import { createMarkTimingInternal } from './crossThreadHandlers/createMainthread
7
7
  import { OffscreenDocument } from '@lynx-js/offscreen-document/webworker';
8
8
  import { _onEvent } from '@lynx-js/offscreen-document/webworker';
9
9
  import { registerUpdateDataHandler } from './crossThreadHandlers/registerUpdateDataHandler.js';
10
- const { loadMainThread } = await import('@lynx-js/web-mainthread-apis');
11
- export function startMainThread(uiThreadPort, backgroundThreadPort) {
10
+ const { prepareMainThreadAPIs } = await import('@lynx-js/web-mainthread-apis');
11
+ export function startMainThreadWorker(uiThreadPort, backgroundThreadPort) {
12
12
  const uiThreadRpc = new Rpc(uiThreadPort, 'main-to-ui');
13
13
  const backgroundThreadRpc = new Rpc(backgroundThreadPort, 'main-to-bg');
14
14
  const markTimingInternal = createMarkTimingInternal(backgroundThreadRpc);
@@ -18,7 +18,7 @@ export function startMainThread(uiThreadPort, backgroundThreadPort) {
18
18
  onCommit: uiFlush,
19
19
  });
20
20
  uiThreadRpc.registerHandler(postOffscreenEventEndpoint, docu[_onEvent]);
21
- const { startMainThread } = loadMainThread(backgroundThreadRpc, docu, docu.commit.bind(docu), markTimingInternal, reportError);
21
+ const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, docu, docu.createElement.bind(docu), docu.commit.bind(docu), markTimingInternal, reportError);
22
22
  uiThreadRpc.registerHandler(mainThreadStartEndpoint, (config) => {
23
23
  startMainThread(config).then((runtime) => {
24
24
  registerUpdateDataHandler(uiThreadRpc, runtime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-worker-runtime",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
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.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"
25
+ "@lynx-js/offscreen-document": "0.0.4",
26
+ "@lynx-js/web-constants": "0.13.3",
27
+ "@lynx-js/web-mainthread-apis": "0.13.3",
28
+ "@lynx-js/web-worker-rpc": "0.13.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@lynx-js/lynx-core": "0.1.2"