@lynx-js/web-core 0.10.0 → 0.11.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 +53 -0
- package/dist/apis/LynxView.d.ts +20 -14
- package/dist/apis/LynxView.js +46 -23
- package/dist/apis/createLynxView.d.ts +2 -1
- package/dist/apis/createLynxView.js +2 -2
- package/dist/uiThread/bootWorkers.d.ts +1 -1
- package/dist/uiThread/bootWorkers.js +33 -8
- package/dist/uiThread/crossThreadHandlers/registerFlushElementTreeHandler.d.ts +1 -3
- package/dist/uiThread/crossThreadHandlers/registerFlushElementTreeHandler.js +1 -8
- package/dist/uiThread/crossThreadHandlers/registerNapiModulesCallHandler.js +5 -2
- package/dist/uiThread/startUIThread.d.ts +1 -1
- package/dist/uiThread/startUIThread.js +9 -17
- package/dist/utils/loadTemplate.js +1 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @lynx-js/web-core
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: upgrade @lynx-js/lynx-core to 0.1.2 ([#465](https://github.com/lynx-family/lynx-stack/pull/465))
|
|
8
|
+
|
|
9
|
+
refactor some internal logic
|
|
10
|
+
|
|
11
|
+
- \_\_OnLifeCycleEvent
|
|
12
|
+
- \_\_OnNativeAppReady
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- feat: support mts event handler (1/n) ([#495](https://github.com/lynx-family/lynx-stack/pull/495))
|
|
17
|
+
|
|
18
|
+
now the main-thread:bind handler could be invoked. The params of the handler will be implemented later.
|
|
19
|
+
|
|
20
|
+
- feat: allow multi lynx-view to share bts worker ([#520](https://github.com/lynx-family/lynx-stack/pull/520))
|
|
21
|
+
|
|
22
|
+
Now we allow users to enable so-called "shared-context" feature on the Web Platform.
|
|
23
|
+
|
|
24
|
+
Similar to the same feature for Lynx iOS/Android, this feature let multi lynx cards to share one js context.
|
|
25
|
+
|
|
26
|
+
The `lynx.getSharedData` and `lynx.setSharedData` are also supported in this commit.
|
|
27
|
+
|
|
28
|
+
To enable this feature, set property `lynxGroupId` or attribute `lynx-group-id` before a lynx-view starts rendering. Those card with same context id will share one web worker for the bts scripts.
|
|
29
|
+
|
|
30
|
+
- perf: dispatchLynxViewEventEndpoint is a void call ([#506](https://github.com/lynx-family/lynx-stack/pull/506))
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`ea42e62`](https://github.com/lynx-family/lynx-stack/commit/ea42e62fbcd5c743132c3e6e7c4851770742d544), [`a0f5ca4`](https://github.com/lynx-family/lynx-stack/commit/a0f5ca4ea0895ccbaa6aa63f449f53a677a1cf73)]:
|
|
33
|
+
- @lynx-js/web-worker-runtime@0.11.0
|
|
34
|
+
- @lynx-js/web-constants@0.11.0
|
|
35
|
+
- @lynx-js/web-worker-rpc@0.11.0
|
|
36
|
+
|
|
37
|
+
## 0.10.1
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- docs: fix documents about lynx-view's properties ([#412](https://github.com/lynx-family/lynx-stack/pull/412))
|
|
42
|
+
|
|
43
|
+
Attributes should be hyphen-name: 'init-data', 'global-props'.
|
|
44
|
+
|
|
45
|
+
now all properties has corresponding attributes.
|
|
46
|
+
|
|
47
|
+
- feat: onNapiModulesCall function add new param: `dispatchNapiModules`, napiModulesMap val add new param: `handleDispatch`. ([#414](https://github.com/lynx-family/lynx-stack/pull/414))
|
|
48
|
+
|
|
49
|
+
Now you can use them to actively communicate to napiModules (background thread) in onNapiModulesCall (ui thread).
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [[`1af3b60`](https://github.com/lynx-family/lynx-stack/commit/1af3b6052ab27f98bf0e4d1b0ec9f7d9e88e0afc)]:
|
|
52
|
+
- @lynx-js/web-constants@0.10.1
|
|
53
|
+
- @lynx-js/web-worker-runtime@0.10.1
|
|
54
|
+
- @lynx-js/web-worker-rpc@0.10.1
|
|
55
|
+
|
|
3
56
|
## 0.10.0
|
|
4
57
|
|
|
5
58
|
### Minor Changes
|
package/dist/apis/LynxView.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } from '@lynx-js/web-constants';
|
|
2
|
-
export type INapiModulesCall = (name: string, data: any, moduleName: string, lynxView: LynxView) => Promise<{
|
|
2
|
+
export type INapiModulesCall = (name: string, data: any, moduleName: string, lynxView: LynxView, dispatchNapiModules: (data: Cloneable) => void) => Promise<{
|
|
3
3
|
data: unknown;
|
|
4
4
|
transfer?: Transferable[];
|
|
5
5
|
}> | {
|
|
@@ -10,17 +10,18 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
|
|
|
10
10
|
* Based on our experiences, these elements are almost used in all lynx cards.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
13
|
+
* @property {string} url [required] (attribute: "url") The url of the entry of your Lynx card
|
|
14
|
+
* @property {Cloneable} globalProps [optional] (attribute: "global-props") The globalProps value of this Lynx card
|
|
15
|
+
* @property {Cloneable} initData [oprional] (attribute: "init-data") The initial data of this Lynx card
|
|
16
|
+
* @property {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
|
|
17
|
+
* @property {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
|
|
18
|
+
* @property {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
|
|
19
|
+
* @property {"auto" | null} height [optional] (attribute: "height") set it to "auto" for height auto-sizing
|
|
20
|
+
* @property {"auto" | null} width [optional] (attribute: "width") set it to "auto" for width auto-sizing
|
|
21
|
+
* @property {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
22
|
+
* @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
|
|
23
|
+
* @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
|
|
24
|
+
* @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
|
|
24
25
|
*
|
|
25
26
|
* @event error lynx card fired an error
|
|
26
27
|
*
|
|
@@ -30,7 +31,7 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
|
|
|
30
31
|
* Note that you should declarae the size of lynx-view
|
|
31
32
|
*
|
|
32
33
|
* ```html
|
|
33
|
-
* <lynx-view url="https://path/to/main-thread.js"
|
|
34
|
+
* <lynx-view url="https://path/to/main-thread.js" raw-data="{}" global-props="{}" style="height:300px;width:300px">
|
|
34
35
|
* </lynx-view>
|
|
35
36
|
* ```
|
|
36
37
|
*
|
|
@@ -45,7 +46,6 @@ export declare class LynxView extends HTMLElement {
|
|
|
45
46
|
static lynxViewCount: number;
|
|
46
47
|
static tag: "lynx-view";
|
|
47
48
|
private static observedAttributeAsProperties;
|
|
48
|
-
private static attributeCamelCaseMap;
|
|
49
49
|
/**
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
@@ -103,6 +103,12 @@ export declare class LynxView extends HTMLElement {
|
|
|
103
103
|
*/
|
|
104
104
|
get onNapiModulesCall(): NapiModulesCall | undefined;
|
|
105
105
|
set onNapiModulesCall(handler: INapiModulesCall);
|
|
106
|
+
/**
|
|
107
|
+
* @param
|
|
108
|
+
* @property
|
|
109
|
+
*/
|
|
110
|
+
get lynxGroupId(): number | undefined;
|
|
111
|
+
set lynxGroupId(val: number | undefined);
|
|
106
112
|
/**
|
|
107
113
|
* @public
|
|
108
114
|
* @method
|
package/dist/apis/LynxView.js
CHANGED
|
@@ -8,17 +8,18 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
|
|
|
8
8
|
* Based on our experiences, these elements are almost used in all lynx cards.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
11
|
+
* @property {string} url [required] (attribute: "url") The url of the entry of your Lynx card
|
|
12
|
+
* @property {Cloneable} globalProps [optional] (attribute: "global-props") The globalProps value of this Lynx card
|
|
13
|
+
* @property {Cloneable} initData [oprional] (attribute: "init-data") The initial data of this Lynx card
|
|
14
|
+
* @property {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
|
|
15
|
+
* @property {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
|
|
16
|
+
* @property {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
|
|
17
|
+
* @property {"auto" | null} height [optional] (attribute: "height") set it to "auto" for height auto-sizing
|
|
18
|
+
* @property {"auto" | null} width [optional] (attribute: "width") set it to "auto" for width auto-sizing
|
|
19
|
+
* @property {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
20
|
+
* @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
|
|
21
|
+
* @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
|
|
22
|
+
* @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
|
|
22
23
|
*
|
|
23
24
|
* @event error lynx card fired an error
|
|
24
25
|
*
|
|
@@ -28,7 +29,7 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
|
|
|
28
29
|
* Note that you should declarae the size of lynx-view
|
|
29
30
|
*
|
|
30
31
|
* ```html
|
|
31
|
-
* <lynx-view url="https://path/to/main-thread.js"
|
|
32
|
+
* <lynx-view url="https://path/to/main-thread.js" raw-data="{}" global-props="{}" style="height:300px;width:300px">
|
|
32
33
|
* </lynx-view>
|
|
33
34
|
* ```
|
|
34
35
|
*
|
|
@@ -43,12 +44,9 @@ export class LynxView extends HTMLElement {
|
|
|
43
44
|
static tag = 'lynx-view';
|
|
44
45
|
static observedAttributeAsProperties = [
|
|
45
46
|
'url',
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'overrideLynxTagToHTMLTagMap',
|
|
49
|
-
'nativeModulesMap',
|
|
47
|
+
'global-props',
|
|
48
|
+
'init-data',
|
|
50
49
|
];
|
|
51
|
-
static attributeCamelCaseMap = Object.fromEntries(this.observedAttributeAsProperties.map((nm) => [nm.toLocaleLowerCase(), nm]));
|
|
52
50
|
/**
|
|
53
51
|
* @private
|
|
54
52
|
*/
|
|
@@ -167,10 +165,27 @@ export class LynxView extends HTMLElement {
|
|
|
167
165
|
return this.#onNapiModulesCall;
|
|
168
166
|
}
|
|
169
167
|
set onNapiModulesCall(handler) {
|
|
170
|
-
this.#onNapiModulesCall = (name, data, moduleName) => {
|
|
171
|
-
return handler(name, data, moduleName, this);
|
|
168
|
+
this.#onNapiModulesCall = (name, data, moduleName, dispatchNapiModules) => {
|
|
169
|
+
return handler(name, data, moduleName, this, dispatchNapiModules);
|
|
172
170
|
};
|
|
173
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* @param
|
|
174
|
+
* @property
|
|
175
|
+
*/
|
|
176
|
+
get lynxGroupId() {
|
|
177
|
+
return this.getAttribute('lynx-group-id')
|
|
178
|
+
? Number(this.getAttribute('lynx-group-id'))
|
|
179
|
+
: undefined;
|
|
180
|
+
}
|
|
181
|
+
set lynxGroupId(val) {
|
|
182
|
+
if (val) {
|
|
183
|
+
this.setAttribute('lynx-group-id', val.toString());
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
this.removeAttribute('lynx-group-id');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
174
189
|
/**
|
|
175
190
|
* @public
|
|
176
191
|
* @method
|
|
@@ -214,10 +229,16 @@ export class LynxView extends HTMLElement {
|
|
|
214
229
|
*/
|
|
215
230
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
216
231
|
if (oldValue !== newValue) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
232
|
+
switch (name) {
|
|
233
|
+
case 'url':
|
|
234
|
+
this.#url = newValue;
|
|
235
|
+
break;
|
|
236
|
+
case 'global-props':
|
|
237
|
+
this.#globalProps = JSON.parse(newValue);
|
|
238
|
+
break;
|
|
239
|
+
case 'init-data':
|
|
240
|
+
this.#initData = JSON.parse(newValue);
|
|
241
|
+
break;
|
|
221
242
|
}
|
|
222
243
|
}
|
|
223
244
|
}
|
|
@@ -259,6 +280,7 @@ export class LynxView extends HTMLElement {
|
|
|
259
280
|
if (!this.shadowRoot) {
|
|
260
281
|
this.attachShadow({ mode: 'open' });
|
|
261
282
|
}
|
|
283
|
+
const lynxGroupId = this.lynxGroupId;
|
|
262
284
|
const lynxView = createLynxView({
|
|
263
285
|
tagMap,
|
|
264
286
|
shadowRoot: this.shadowRoot,
|
|
@@ -267,6 +289,7 @@ export class LynxView extends HTMLElement {
|
|
|
267
289
|
initData: this.#initData,
|
|
268
290
|
nativeModulesMap: this.#nativeModulesMap,
|
|
269
291
|
napiModulesMap: this.#napiModulesMap,
|
|
292
|
+
lynxGroupId,
|
|
270
293
|
callbacks: {
|
|
271
294
|
nativeModulesCall: (...args) => {
|
|
272
295
|
if (this.#onNativeModulesCall) {
|
|
@@ -6,10 +6,11 @@ export interface LynxViewConfigs {
|
|
|
6
6
|
initData: Cloneable;
|
|
7
7
|
globalProps: Cloneable;
|
|
8
8
|
shadowRoot: ShadowRoot;
|
|
9
|
-
callbacks: Parameters<typeof startUIThread>[
|
|
9
|
+
callbacks: Parameters<typeof startUIThread>[4];
|
|
10
10
|
nativeModulesMap: NativeModulesMap;
|
|
11
11
|
napiModulesMap: NapiModulesMap;
|
|
12
12
|
tagMap: Record<string, string>;
|
|
13
|
+
lynxGroupId: number | undefined;
|
|
13
14
|
}
|
|
14
15
|
export interface LynxView {
|
|
15
16
|
updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { startUIThread } from '../uiThread/startUIThread.js';
|
|
5
5
|
export function createLynxView(configs) {
|
|
6
|
-
const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, } = configs;
|
|
6
|
+
const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, lynxGroupId, } = configs;
|
|
7
7
|
return startUIThread(templateUrl, {
|
|
8
8
|
tagMap,
|
|
9
9
|
initData,
|
|
@@ -11,6 +11,6 @@ export function createLynxView(configs) {
|
|
|
11
11
|
nativeModulesMap,
|
|
12
12
|
napiModulesMap,
|
|
13
13
|
browserConfig: {},
|
|
14
|
-
}, shadowRoot, callbacks);
|
|
14
|
+
}, shadowRoot, lynxGroupId, callbacks);
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=createLynxView.js.map
|
|
@@ -2,24 +2,41 @@
|
|
|
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 { Rpc } from '@lynx-js/web-worker-rpc';
|
|
5
|
+
const backgroundWorkerContextCount = [];
|
|
6
|
+
const contextIdToBackgroundWorker = [];
|
|
5
7
|
let preHeatedMainWorker = createMainWorker();
|
|
6
|
-
export function bootWorkers() {
|
|
8
|
+
export function bootWorkers(lynxGroupId) {
|
|
7
9
|
const curMainWorker = preHeatedMainWorker;
|
|
8
|
-
const curBackgroundWorker = createBackgroundWorker(curMainWorker.channelMainThreadWithBackground);
|
|
9
10
|
preHeatedMainWorker = createMainWorker();
|
|
11
|
+
const curBackgroundWorker = createBackgroundWorker(lynxGroupId, curMainWorker.channelMainThreadWithBackground);
|
|
12
|
+
if (lynxGroupId !== undefined) {
|
|
13
|
+
if (backgroundWorkerContextCount[lynxGroupId]) {
|
|
14
|
+
backgroundWorkerContextCount[lynxGroupId]++;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
backgroundWorkerContextCount[lynxGroupId] = 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
10
20
|
return {
|
|
11
21
|
mainThreadRpc: curMainWorker.mainThreadRpc,
|
|
12
22
|
backgroundRpc: curBackgroundWorker.backgroundRpc,
|
|
13
23
|
terminateWorkers: () => {
|
|
14
24
|
curMainWorker.mainThreadWorker.terminate();
|
|
15
|
-
|
|
25
|
+
if (lynxGroupId === undefined) {
|
|
26
|
+
curBackgroundWorker.backgroundThreadWorker.terminate();
|
|
27
|
+
}
|
|
28
|
+
else if (backgroundWorkerContextCount[lynxGroupId] === 1) {
|
|
29
|
+
curBackgroundWorker.backgroundThreadWorker.terminate();
|
|
30
|
+
backgroundWorkerContextCount[lynxGroupId] = 0;
|
|
31
|
+
contextIdToBackgroundWorker[lynxGroupId] = undefined;
|
|
32
|
+
}
|
|
16
33
|
},
|
|
17
34
|
};
|
|
18
35
|
}
|
|
19
36
|
function createMainWorker() {
|
|
20
37
|
const channelToMainThread = new MessageChannel();
|
|
21
38
|
const channelMainThreadWithBackground = new MessageChannel();
|
|
22
|
-
const mainThreadWorker = createWebWorker();
|
|
39
|
+
const mainThreadWorker = createWebWorker('lynx-main');
|
|
23
40
|
const mainThreadMessage = {
|
|
24
41
|
mode: 'main',
|
|
25
42
|
toUIThread: channelToMainThread.port2,
|
|
@@ -37,9 +54,17 @@ function createMainWorker() {
|
|
|
37
54
|
channelMainThreadWithBackground,
|
|
38
55
|
};
|
|
39
56
|
}
|
|
40
|
-
function createBackgroundWorker(channelMainThreadWithBackground) {
|
|
57
|
+
function createBackgroundWorker(lynxGroupId, channelMainThreadWithBackground) {
|
|
41
58
|
const channelToBackground = new MessageChannel();
|
|
42
|
-
|
|
59
|
+
let backgroundThreadWorker;
|
|
60
|
+
if (lynxGroupId) {
|
|
61
|
+
backgroundThreadWorker = contextIdToBackgroundWorker[lynxGroupId]
|
|
62
|
+
?? createWebWorker('lynx-bg');
|
|
63
|
+
contextIdToBackgroundWorker[lynxGroupId] = backgroundThreadWorker;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
backgroundThreadWorker = createWebWorker('lynx-bg');
|
|
67
|
+
}
|
|
43
68
|
const backgroundThreadMessage = {
|
|
44
69
|
mode: 'background',
|
|
45
70
|
toUIThread: channelToBackground.port2,
|
|
@@ -53,10 +78,10 @@ function createBackgroundWorker(channelMainThreadWithBackground) {
|
|
|
53
78
|
const backgroundRpc = new Rpc(channelToBackground.port1, 'ui-to-bg');
|
|
54
79
|
return { backgroundRpc, backgroundThreadWorker };
|
|
55
80
|
}
|
|
56
|
-
function createWebWorker() {
|
|
81
|
+
function createWebWorker(name) {
|
|
57
82
|
return new Worker(new URL('@lynx-js/web-worker-runtime', import.meta.url), {
|
|
58
83
|
type: 'module',
|
|
59
|
-
name
|
|
84
|
+
name,
|
|
60
85
|
});
|
|
61
86
|
}
|
|
62
87
|
//# sourceMappingURL=bootWorkers.js.map
|
|
@@ -3,22 +3,15 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { flushElementTreeEndpoint, postOffscreenEventEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { initOffscreenDocument } from '@lynx-js/offscreen-document/main';
|
|
6
|
-
export function registerFlushElementTreeHandler(mainThreadRpc, options
|
|
6
|
+
export function registerFlushElementTreeHandler(mainThreadRpc, options) {
|
|
7
7
|
const { shadowRoot, } = options;
|
|
8
8
|
const onEvent = mainThreadRpc.createCall(postOffscreenEventEndpoint);
|
|
9
9
|
const { decodeOperation } = initOffscreenDocument({
|
|
10
10
|
shadowRoot,
|
|
11
11
|
onEvent,
|
|
12
12
|
});
|
|
13
|
-
let isFP = true;
|
|
14
13
|
mainThreadRpc.registerHandler(flushElementTreeEndpoint, (operations) => {
|
|
15
14
|
decodeOperation(operations);
|
|
16
|
-
onCommit({
|
|
17
|
-
isFP,
|
|
18
|
-
});
|
|
19
|
-
if (isFP) {
|
|
20
|
-
isFP = false;
|
|
21
|
-
}
|
|
22
15
|
});
|
|
23
16
|
}
|
|
24
17
|
//# sourceMappingURL=registerFlushElementTreeHandler.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { napiModulesCallEndpoint, } from '@lynx-js/web-constants';
|
|
1
|
+
import { dispatchNapiModuleEndpoint, napiModulesCallEndpoint, } from '@lynx-js/web-constants';
|
|
2
2
|
export function registerNapiModulesCallHandler(rpc, napiModulesCall) {
|
|
3
|
-
rpc.
|
|
3
|
+
const dispatchNapiModules = rpc.createCall(dispatchNapiModuleEndpoint);
|
|
4
|
+
rpc.registerHandler(napiModulesCallEndpoint, (name, data, moduleName) => {
|
|
5
|
+
return napiModulesCall(name, data, moduleName, dispatchNapiModules);
|
|
6
|
+
});
|
|
4
7
|
}
|
|
5
8
|
//# sourceMappingURL=registerNapiModulesCallHandler.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LynxView } from '../apis/createLynxView.js';
|
|
2
2
|
import { type MainThreadStartConfigs, type NapiModulesCall, type NativeModulesCall } from '@lynx-js/web-constants';
|
|
3
|
-
export declare function startUIThread(templateUrl: string, configs: Omit<MainThreadStartConfigs, 'template'>, shadowRoot: ShadowRoot, callbacks: {
|
|
3
|
+
export declare function startUIThread(templateUrl: string, configs: Omit<MainThreadStartConfigs, 'template'>, shadowRoot: ShadowRoot, lynxGroupId: number | undefined, callbacks: {
|
|
4
4
|
nativeModulesCall: NativeModulesCall;
|
|
5
5
|
napiModulesCall: NapiModulesCall;
|
|
6
6
|
onError?: () => void;
|
|
@@ -10,17 +10,16 @@ import { registerFlushElementTreeHandler } from './crossThreadHandlers/registerF
|
|
|
10
10
|
import { createDispose } from './crossThreadHandlers/createDispose.js';
|
|
11
11
|
import { registerTriggerComponentEventHandler } from './crossThreadHandlers/registerTriggerComponentEventHandler.js';
|
|
12
12
|
import { registerSelectComponentHandler } from './crossThreadHandlers/registerSelectComponentHandler.js';
|
|
13
|
-
import {
|
|
13
|
+
import { mainThreadStartEndpoint, markTimingEndpoint, sendGlobalEventEndpoint, } from '@lynx-js/web-constants';
|
|
14
14
|
import { loadTemplate } from '../utils/loadTemplate.js';
|
|
15
15
|
import { createUpdateData } from './crossThreadHandlers/createUpdateData.js';
|
|
16
16
|
import { registerNapiModulesCallHandler } from './crossThreadHandlers/registerNapiModulesCallHandler.js';
|
|
17
17
|
import { registerDispatchLynxViewEventHandler } from './crossThreadHandlers/registerDispatchLynxViewEventHandler.js';
|
|
18
|
-
export function startUIThread(templateUrl, configs, shadowRoot, callbacks) {
|
|
18
|
+
export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, callbacks) {
|
|
19
19
|
const createLynxStartTiming = performance.now() + performance.timeOrigin;
|
|
20
20
|
const { nativeModulesMap, napiModulesMap } = configs;
|
|
21
|
-
const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers();
|
|
21
|
+
const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers(lynxGroupId);
|
|
22
22
|
const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
|
|
23
|
-
const uiThreadFpReady = backgroundRpc.createCall(uiThreadFpReadyEndpoint);
|
|
24
23
|
const mainThreadStart = mainThreadRpc.createCall(mainThreadStartEndpoint);
|
|
25
24
|
const markTiming = backgroundRpc.createCall(markTimingEndpoint);
|
|
26
25
|
const markTimingInternal = (timingKey, pipelineId, timeStamp) => {
|
|
@@ -41,20 +40,13 @@ export function startUIThread(templateUrl, configs, shadowRoot, callbacks) {
|
|
|
41
40
|
});
|
|
42
41
|
registerReportErrorHandler(mainThreadRpc, callbacks.onError);
|
|
43
42
|
registerDispatchLynxViewEventHandler(backgroundRpc, shadowRoot);
|
|
44
|
-
mainThreadRpc
|
|
45
|
-
|
|
46
|
-
shadowRoot,
|
|
47
|
-
}, (info) => {
|
|
48
|
-
const { isFP } = info;
|
|
49
|
-
if (isFP) {
|
|
50
|
-
registerInvokeUIMethodHandler(backgroundRpc, shadowRoot);
|
|
51
|
-
registerNativePropsHandler(backgroundRpc, shadowRoot);
|
|
52
|
-
registerTriggerComponentEventHandler(backgroundRpc, shadowRoot);
|
|
53
|
-
registerSelectComponentHandler(backgroundRpc, shadowRoot);
|
|
54
|
-
uiThreadFpReady();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
43
|
+
registerFlushElementTreeHandler(mainThreadRpc, {
|
|
44
|
+
shadowRoot,
|
|
57
45
|
});
|
|
46
|
+
registerInvokeUIMethodHandler(backgroundRpc, shadowRoot);
|
|
47
|
+
registerNativePropsHandler(backgroundRpc, shadowRoot);
|
|
48
|
+
registerTriggerComponentEventHandler(backgroundRpc, shadowRoot);
|
|
49
|
+
registerSelectComponentHandler(backgroundRpc, shadowRoot);
|
|
58
50
|
registerNativeModulesCallHandler(backgroundRpc, callbacks.nativeModulesCall);
|
|
59
51
|
registerNapiModulesCallHandler(backgroundRpc, callbacks.napiModulesCall);
|
|
60
52
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@lynx-js/offscreen-document": "0.0.0",
|
|
28
|
-
"@lynx-js/web-constants": "0.
|
|
29
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
30
|
-
"@lynx-js/web-worker-runtime": "0.
|
|
28
|
+
"@lynx-js/web-constants": "0.11.0",
|
|
29
|
+
"@lynx-js/web-worker-rpc": "0.11.0",
|
|
30
|
+
"@lynx-js/web-worker-runtime": "0.11.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@lynx-js/lynx-core": "0.1.
|
|
34
|
-
"@lynx-js/web-elements": "0.5.
|
|
33
|
+
"@lynx-js/lynx-core": "0.1.2",
|
|
34
|
+
"@lynx-js/web-elements": "0.5.4"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@lynx-js/lynx-core": "0.1.
|
|
37
|
+
"@lynx-js/lynx-core": "0.1.2",
|
|
38
38
|
"@lynx-js/web-elements": ">=0.3.1"
|
|
39
39
|
}
|
|
40
40
|
}
|