@lynx-js/web-core 0.8.0 → 0.9.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 +83 -0
- package/dist/apis/LynxView.d.ts +9 -29
- package/dist/apis/LynxView.js +32 -129
- package/dist/apis/createLynxView.d.ts +6 -6
- package/dist/apis/createLynxView.js +4 -3
- package/dist/uiThread/crossThreadHandlers/bootTimingSystem.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/bootTimingSystem.js +2 -2
- package/dist/uiThread/crossThreadHandlers/createExposureService.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/createExposureService.js +5 -3
- package/dist/uiThread/crossThreadHandlers/queryNodes.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/queryNodes.js +4 -4
- package/dist/uiThread/crossThreadHandlers/registerFlushElementTreeHandler.d.ts +1 -3
- package/dist/uiThread/crossThreadHandlers/registerFlushElementTreeHandler.js +10 -15
- package/dist/uiThread/crossThreadHandlers/registerInvokeUIMethodHandler.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/registerInvokeUIMethodHandler.js +2 -2
- package/dist/uiThread/crossThreadHandlers/registerSelectComponentHandler.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/registerSelectComponentHandler.js +2 -2
- package/dist/uiThread/crossThreadHandlers/registerSetNativePropsHandler.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/registerSetNativePropsHandler.js +2 -2
- package/dist/uiThread/crossThreadHandlers/registerTriggerComponentEventHandler.d.ts +1 -1
- package/dist/uiThread/crossThreadHandlers/registerTriggerComponentEventHandler.js +2 -2
- package/dist/uiThread/decodeElementOperation.d.ts +0 -1
- package/dist/uiThread/decodeElementOperation.js +4 -7
- package/dist/uiThread/startUIThread.d.ts +2 -2
- package/dist/uiThread/startUIThread.js +10 -12
- package/dist/utils/createCrossThreadEvent.js +1 -1
- package/dist/utils/loadTemplate.js +1 -0
- package/index.css +2 -39
- package/package.json +5 -5
- package/dist/uiThread/getElementTag.d.ts +0 -1
- package/dist/uiThread/getElementTag.js +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @lynx-js/web-core
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: remove extra div #lynx-view-root ([#311](https://github.com/lynx-family/lynx-stack/pull/311))
|
|
8
|
+
|
|
9
|
+
In this commit we've re-implemented the lynx-view's auto-size. Now we use the `contain:content` instead of `resizeObserver`.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @lynx-js/web-constants@0.9.1
|
|
13
|
+
- @lynx-js/web-worker-rpc@0.9.1
|
|
14
|
+
- @lynx-js/web-worker-runtime@0.9.1
|
|
15
|
+
|
|
16
|
+
## 0.9.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 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))
|
|
21
|
+
|
|
22
|
+
"warning: This is a breaking change."
|
|
23
|
+
|
|
24
|
+
`nativeModulesMap` will be a map: key is module-name, value should be a esm url which export default a
|
|
25
|
+
function with two parameters(you never need to use `this`):
|
|
26
|
+
|
|
27
|
+
- `NativeModules`: oriented `NativeModules`, which you can use to call
|
|
28
|
+
other Native-Modules.
|
|
29
|
+
|
|
30
|
+
- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the deprecated `this.nativeModulesCall`.
|
|
31
|
+
|
|
32
|
+
example:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
const nativeModulesMap = {
|
|
36
|
+
CustomModule: URL.createObjectURL(
|
|
37
|
+
new Blob(
|
|
38
|
+
[
|
|
39
|
+
`export default function(NativeModules, NativeModulesCall) {
|
|
40
|
+
return {
|
|
41
|
+
async getColor(data, callback) {
|
|
42
|
+
const color = await NativeModulesCall('getColor', data);
|
|
43
|
+
callback(color);
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
};`,
|
|
47
|
+
],
|
|
48
|
+
{ type: 'text/javascript' },
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
lynxView.nativeModulesMap = nativeModulesMap;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
In addition, we will use Promise.all to load `nativeModules`, which will optimize performance in the case of multiple modules.
|
|
56
|
+
|
|
57
|
+
- refractor: remove entryId concept ([#217](https://github.com/lynx-family/lynx-stack/pull/217))
|
|
58
|
+
|
|
59
|
+
After the PR #198
|
|
60
|
+
All contents are isolated by a shadowroot.
|
|
61
|
+
Therefore we don't need to add the entryId selector to avoid the lynx-view's style taking effect on the whole page.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- refactor: code clean ([#266](https://github.com/lynx-family/lynx-stack/pull/266))
|
|
66
|
+
|
|
67
|
+
- refactor: clean the decodeOperations implementation ([#261](https://github.com/lynx-family/lynx-stack/pull/261))
|
|
68
|
+
|
|
69
|
+
- fix: When the width and height of lynx-view are not auto, the width and height of the `lynx-tag="page"` need to be correctly set to 100%. ([#228](https://github.com/lynx-family/lynx-stack/pull/228))
|
|
70
|
+
|
|
71
|
+
- refactor: remove customelement defined detecting logic ([#247](https://github.com/lynx-family/lynx-stack/pull/247))
|
|
72
|
+
|
|
73
|
+
Before this commit, for those element with tag without `-`, we always try to detect if the `x-${tagName}` is defined.
|
|
74
|
+
|
|
75
|
+
After this commit, we pre-define a map(could be override by the `overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.
|
|
76
|
+
|
|
77
|
+
This change is a path to SSR and the MTS support.
|
|
78
|
+
|
|
79
|
+
- fix: 'error' event for main-thread \_reportError ([#283](https://github.com/lynx-family/lynx-stack/pull/283))
|
|
80
|
+
|
|
81
|
+
- 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)]:
|
|
82
|
+
- @lynx-js/web-worker-runtime@0.9.0
|
|
83
|
+
- @lynx-js/web-constants@0.9.0
|
|
84
|
+
- @lynx-js/web-worker-rpc@0.9.0
|
|
85
|
+
|
|
3
86
|
## 0.8.0
|
|
4
87
|
|
|
5
88
|
### Minor Changes
|
package/dist/apis/LynxView.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type UpdateDataType } from '@lynx-js/web-constants';
|
|
1
|
+
import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } from '@lynx-js/web-constants';
|
|
2
2
|
/**
|
|
3
3
|
* Based on our experiences, these elements are almost used in all lynx cards.
|
|
4
4
|
*/
|
|
@@ -7,16 +7,14 @@ import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeM
|
|
|
7
7
|
* @param {Cloneable} globalProps [optional] The globalProps value of this Lynx card
|
|
8
8
|
* @param {Cloneable} initData [oprional] The initial data of this Lynx card
|
|
9
9
|
* @param {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
|
|
11
|
+
* @param {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
|
|
12
12
|
* @param {"auto" | null} height [optional] set it to "auto" for height auto-sizing
|
|
13
13
|
* @param {"auto" | null} width [optional] set it to "auto" for width auto-sizing
|
|
14
14
|
* @param {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
15
15
|
* @param {NapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
|
|
16
16
|
* @param {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
|
|
17
17
|
*
|
|
18
|
-
* @property entryId the currently Lynx view entryId.
|
|
19
|
-
*
|
|
20
18
|
* @event error lynx card fired an error
|
|
21
19
|
*
|
|
22
20
|
* @example
|
|
@@ -65,13 +63,6 @@ export declare class LynxView extends HTMLElement {
|
|
|
65
63
|
*/
|
|
66
64
|
get initData(): Cloneable;
|
|
67
65
|
set initData(val: string | Cloneable);
|
|
68
|
-
/**
|
|
69
|
-
* @public
|
|
70
|
-
* @readonly
|
|
71
|
-
* @property
|
|
72
|
-
* The random generated entryId of current lynxview
|
|
73
|
-
*/
|
|
74
|
-
get entryId(): string | undefined;
|
|
75
66
|
/**
|
|
76
67
|
* @public
|
|
77
68
|
* @property
|
|
@@ -87,13 +78,15 @@ export declare class LynxView extends HTMLElement {
|
|
|
87
78
|
set onNativeModulesCall(handler: NativeModulesCall);
|
|
88
79
|
/**
|
|
89
80
|
* @public
|
|
90
|
-
* @property
|
|
81
|
+
* @property nativeModulesMap
|
|
82
|
+
* @default {}
|
|
91
83
|
*/
|
|
92
|
-
get
|
|
93
|
-
set
|
|
84
|
+
get nativeModulesMap(): NativeModulesMap | undefined;
|
|
85
|
+
set nativeModulesMap(map: NativeModulesMap);
|
|
94
86
|
/**
|
|
95
87
|
* @param
|
|
96
|
-
* @property
|
|
88
|
+
* @property napiModulesMap
|
|
89
|
+
* @default {}
|
|
97
90
|
*/
|
|
98
91
|
get napiModulesMap(): NapiModulesMap | undefined;
|
|
99
92
|
set napiModulesMap(map: NapiModulesMap);
|
|
@@ -103,18 +96,6 @@ export declare class LynxView extends HTMLElement {
|
|
|
103
96
|
*/
|
|
104
97
|
get onNapiModulesCall(): NapiModulesCall | undefined;
|
|
105
98
|
set onNapiModulesCall(handler: NapiModulesCall);
|
|
106
|
-
/**
|
|
107
|
-
* @public
|
|
108
|
-
* "auto" for auto calculated height
|
|
109
|
-
*/
|
|
110
|
-
get height(): string | null;
|
|
111
|
-
/**
|
|
112
|
-
* @public
|
|
113
|
-
* "auto" for auto calculated width
|
|
114
|
-
*/
|
|
115
|
-
get width(): string | null;
|
|
116
|
-
set height(val: string | null);
|
|
117
|
-
set width(val: string | null);
|
|
118
99
|
/**
|
|
119
100
|
* @public
|
|
120
101
|
* @method
|
|
@@ -152,5 +133,4 @@ export declare class LynxView extends HTMLElement {
|
|
|
152
133
|
* @private
|
|
153
134
|
*/
|
|
154
135
|
connectedCallback(): void;
|
|
155
|
-
private cleanupResizeObserver;
|
|
156
136
|
}
|
package/dist/apis/LynxView.js
CHANGED
|
@@ -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 { createLynxView, } from './createLynxView.js';
|
|
5
|
-
import {
|
|
5
|
+
import {} from '@lynx-js/web-constants';
|
|
6
6
|
import { inShadowRootStyles } from './inShadowRootStyles.js';
|
|
7
7
|
/**
|
|
8
8
|
* Based on our experiences, these elements are almost used in all lynx cards.
|
|
@@ -12,16 +12,14 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
|
|
|
12
12
|
* @param {Cloneable} globalProps [optional] The globalProps value of this Lynx card
|
|
13
13
|
* @param {Cloneable} initData [oprional] The initial data of this Lynx card
|
|
14
14
|
* @param {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
15
|
+
* @param {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
|
|
16
|
+
* @param {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
|
|
17
17
|
* @param {"auto" | null} height [optional] set it to "auto" for height auto-sizing
|
|
18
18
|
* @param {"auto" | null} width [optional] set it to "auto" for width auto-sizing
|
|
19
19
|
* @param {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
20
20
|
* @param {NapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
|
|
21
21
|
* @param {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
|
|
22
22
|
*
|
|
23
|
-
* @property entryId the currently Lynx view entryId.
|
|
24
|
-
*
|
|
25
23
|
* @event error lynx card fired an error
|
|
26
24
|
*
|
|
27
25
|
* @example
|
|
@@ -48,7 +46,7 @@ export class LynxView extends HTMLElement {
|
|
|
48
46
|
'globalProps',
|
|
49
47
|
'initData',
|
|
50
48
|
'overrideLynxTagToHTMLTagMap',
|
|
51
|
-
'
|
|
49
|
+
'nativeModulesMap',
|
|
52
50
|
];
|
|
53
51
|
static attributeCamelCaseMap = Object.fromEntries(this.observedAttributeAsProperties.map((nm) => [nm.toLocaleLowerCase(), nm]));
|
|
54
52
|
/**
|
|
@@ -102,16 +100,6 @@ export class LynxView extends HTMLElement {
|
|
|
102
100
|
this.#initData = val;
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
|
-
#entryId;
|
|
106
|
-
/**
|
|
107
|
-
* @public
|
|
108
|
-
* @readonly
|
|
109
|
-
* @property
|
|
110
|
-
* The random generated entryId of current lynxview
|
|
111
|
-
*/
|
|
112
|
-
get entryId() {
|
|
113
|
-
return this.#entryId;
|
|
114
|
-
}
|
|
115
103
|
#overrideLynxTagToHTMLTagMap = { 'page': 'div' };
|
|
116
104
|
/**
|
|
117
105
|
* @public
|
|
@@ -146,21 +134,23 @@ export class LynxView extends HTMLElement {
|
|
|
146
134
|
}
|
|
147
135
|
}
|
|
148
136
|
}
|
|
149
|
-
#
|
|
137
|
+
#nativeModulesMap = {};
|
|
150
138
|
/**
|
|
151
139
|
* @public
|
|
152
|
-
* @property
|
|
140
|
+
* @property nativeModulesMap
|
|
141
|
+
* @default {}
|
|
153
142
|
*/
|
|
154
|
-
get
|
|
155
|
-
return this.#
|
|
143
|
+
get nativeModulesMap() {
|
|
144
|
+
return this.#nativeModulesMap;
|
|
156
145
|
}
|
|
157
|
-
set
|
|
158
|
-
this.#
|
|
146
|
+
set nativeModulesMap(map) {
|
|
147
|
+
this.#nativeModulesMap = map;
|
|
159
148
|
}
|
|
160
149
|
#napiModulesMap = {};
|
|
161
150
|
/**
|
|
162
151
|
* @param
|
|
163
|
-
* @property
|
|
152
|
+
* @property napiModulesMap
|
|
153
|
+
* @default {}
|
|
164
154
|
*/
|
|
165
155
|
get napiModulesMap() {
|
|
166
156
|
return this.#napiModulesMap;
|
|
@@ -179,81 +169,13 @@ export class LynxView extends HTMLElement {
|
|
|
179
169
|
set onNapiModulesCall(handler) {
|
|
180
170
|
this.#onNapiModulesCall = handler;
|
|
181
171
|
}
|
|
182
|
-
#autoHeight = false;
|
|
183
|
-
#autoWidth = false;
|
|
184
|
-
#currentWidth = 0;
|
|
185
|
-
#currentHeight = 0;
|
|
186
|
-
/**
|
|
187
|
-
* @public
|
|
188
|
-
* "auto" for auto calculated height
|
|
189
|
-
*/
|
|
190
|
-
get height() {
|
|
191
|
-
return this.#autoHeight ? 'auto' : null;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @public
|
|
195
|
-
* "auto" for auto calculated width
|
|
196
|
-
*/
|
|
197
|
-
get width() {
|
|
198
|
-
return this.#autoWidth ? 'auto' : null;
|
|
199
|
-
}
|
|
200
|
-
set height(val) {
|
|
201
|
-
this.#handleAutoSize();
|
|
202
|
-
this.#autoHeight = val === 'auto' ? true : false;
|
|
203
|
-
}
|
|
204
|
-
set width(val) {
|
|
205
|
-
this.#handleAutoSize();
|
|
206
|
-
this.#autoWidth = val === 'auto' ? true : false;
|
|
207
|
-
}
|
|
208
|
-
#handleAutoSize() {
|
|
209
|
-
if (this.#autoHeight || this.#autoWidth) {
|
|
210
|
-
if (this.#instance && !this.#instance.resizeObserver) {
|
|
211
|
-
this.#instance.resizeObserver = new ResizeObserver((sizes) => {
|
|
212
|
-
const size = sizes[0];
|
|
213
|
-
if (size) {
|
|
214
|
-
const { width, height } = size.contentRect;
|
|
215
|
-
if (this.#autoWidth) {
|
|
216
|
-
if (this.#currentWidth !== width) {
|
|
217
|
-
this.#currentWidth = width;
|
|
218
|
-
this.style.setProperty('--lynx-view-width', `${width}px`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (this.#autoHeight) {
|
|
222
|
-
if (this.#currentHeight !== height) {
|
|
223
|
-
this.#currentHeight = height;
|
|
224
|
-
this.style.setProperty('--lynx-view-height', `${height}px`);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
this.#instance.resizeObserver.observe(this.#instance.rootDom);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
if (this.#instance?.resizeObserver) {
|
|
234
|
-
this.#instance.resizeObserver.disconnect();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (this.#autoHeight) {
|
|
238
|
-
this.setAttribute('height', 'auto');
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
this.removeAttribute('height');
|
|
242
|
-
}
|
|
243
|
-
if (this.#autoWidth) {
|
|
244
|
-
this.setAttribute('width', 'auto');
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
this.removeAttribute('width');
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
172
|
/**
|
|
251
173
|
* @public
|
|
252
174
|
* @method
|
|
253
175
|
* update the `__initData` and trigger essential flow
|
|
254
176
|
*/
|
|
255
177
|
updateData(data, updateDataType, callback) {
|
|
256
|
-
this.#instance?.
|
|
178
|
+
this.#instance?.updateData(data, updateDataType, callback);
|
|
257
179
|
}
|
|
258
180
|
/**
|
|
259
181
|
* @public
|
|
@@ -261,7 +183,7 @@ export class LynxView extends HTMLElement {
|
|
|
261
183
|
* send global events, which can be listened to using the GlobalEventEmitter
|
|
262
184
|
*/
|
|
263
185
|
sendGlobalEvent(eventName, params) {
|
|
264
|
-
this.#instance?.
|
|
186
|
+
this.#instance?.sendGlobalEvent(eventName, params);
|
|
265
187
|
}
|
|
266
188
|
/**
|
|
267
189
|
* @public
|
|
@@ -301,11 +223,7 @@ export class LynxView extends HTMLElement {
|
|
|
301
223
|
* @private
|
|
302
224
|
*/
|
|
303
225
|
disconnectedCallback() {
|
|
304
|
-
this
|
|
305
|
-
if (this.#instance) {
|
|
306
|
-
this.#instance.lynxView.dispose();
|
|
307
|
-
this.#instance.rootDom.remove();
|
|
308
|
-
}
|
|
226
|
+
this.#instance?.dispose();
|
|
309
227
|
this.#instance = undefined;
|
|
310
228
|
if (this.shadowRoot) {
|
|
311
229
|
this.shadowRoot.innerHTML = '';
|
|
@@ -327,24 +245,25 @@ export class LynxView extends HTMLElement {
|
|
|
327
245
|
this.disconnectedCallback();
|
|
328
246
|
}
|
|
329
247
|
if (this.#url) {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
entryId,
|
|
248
|
+
const tagMap = {
|
|
249
|
+
'page': 'div',
|
|
250
|
+
'view': 'x-view',
|
|
251
|
+
'text': 'x-text',
|
|
252
|
+
'image': 'x-image',
|
|
253
|
+
'list': 'x-list',
|
|
254
|
+
'svg': 'x-svg',
|
|
255
|
+
...this.overrideLynxTagToHTMLTagMap,
|
|
339
256
|
};
|
|
257
|
+
if (!this.shadowRoot) {
|
|
258
|
+
this.attachShadow({ mode: 'open' });
|
|
259
|
+
}
|
|
340
260
|
const lynxView = createLynxView({
|
|
341
|
-
|
|
342
|
-
|
|
261
|
+
tagMap,
|
|
262
|
+
shadowRoot: this.shadowRoot,
|
|
343
263
|
templateUrl: this.#url,
|
|
344
264
|
globalProps: this.#globalProps,
|
|
345
265
|
initData: this.#initData,
|
|
346
|
-
|
|
347
|
-
nativeModulesUrl: this.#nativeModulesUrl,
|
|
266
|
+
nativeModulesMap: this.#nativeModulesMap,
|
|
348
267
|
napiModulesMap: this.#napiModulesMap,
|
|
349
268
|
callbacks: {
|
|
350
269
|
nativeModulesCall: (...args) => {
|
|
@@ -362,20 +281,11 @@ export class LynxView extends HTMLElement {
|
|
|
362
281
|
return this.#onNapiModulesCall?.(...args);
|
|
363
282
|
},
|
|
364
283
|
onError: () => {
|
|
365
|
-
this.dispatchEvent(new CustomEvent('error', {
|
|
366
|
-
detail: commonEventDetail,
|
|
367
|
-
}));
|
|
284
|
+
this.dispatchEvent(new CustomEvent('error', {}));
|
|
368
285
|
},
|
|
369
286
|
},
|
|
370
287
|
});
|
|
371
|
-
this.#instance =
|
|
372
|
-
lynxView,
|
|
373
|
-
rootDom,
|
|
374
|
-
};
|
|
375
|
-
this.#handleAutoSize();
|
|
376
|
-
if (!this.shadowRoot) {
|
|
377
|
-
this.attachShadow({ mode: 'open' });
|
|
378
|
-
}
|
|
288
|
+
this.#instance = lynxView;
|
|
379
289
|
const styleElement = document.createElement('style');
|
|
380
290
|
this.shadowRoot.append(styleElement);
|
|
381
291
|
const styleSheet = styleElement.sheet;
|
|
@@ -387,7 +297,6 @@ export class LynxView extends HTMLElement {
|
|
|
387
297
|
styleSheet.insertRule(`@import url("${href}");`);
|
|
388
298
|
});
|
|
389
299
|
}
|
|
390
|
-
this.shadowRoot.append(rootDom);
|
|
391
300
|
}
|
|
392
301
|
});
|
|
393
302
|
}
|
|
@@ -398,12 +307,6 @@ export class LynxView extends HTMLElement {
|
|
|
398
307
|
connectedCallback() {
|
|
399
308
|
this.#render();
|
|
400
309
|
}
|
|
401
|
-
cleanupResizeObserver() {
|
|
402
|
-
if (this.#instance?.resizeObserver) {
|
|
403
|
-
this.#instance.resizeObserver.disconnect();
|
|
404
|
-
this.#instance.resizeObserver = undefined;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
310
|
}
|
|
408
311
|
if (customElements.get(LynxView.tag)) {
|
|
409
312
|
console.warn(`[${LynxView.tag}] has already been defined`);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { Cloneable, NapiModulesMap, UpdateDataType } from '@lynx-js/web-constants';
|
|
1
|
+
import type { Cloneable, NapiModulesMap, NativeModulesMap, sendGlobalEventEndpoint, UpdateDataType } from '@lynx-js/web-constants';
|
|
2
2
|
import { startUIThread } from '../uiThread/startUIThread.js';
|
|
3
|
+
import type { RpcCallType } from '@lynx-js/web-worker-rpc';
|
|
3
4
|
export interface LynxViewConfigs {
|
|
4
5
|
templateUrl: string;
|
|
5
6
|
initData: Cloneable;
|
|
6
7
|
globalProps: Cloneable;
|
|
7
|
-
|
|
8
|
-
rootDom: HTMLElement;
|
|
8
|
+
shadowRoot: ShadowRoot;
|
|
9
9
|
callbacks: Parameters<typeof startUIThread>[3];
|
|
10
|
-
|
|
11
|
-
nativeModulesUrl: string | undefined;
|
|
10
|
+
nativeModulesMap: NativeModulesMap;
|
|
12
11
|
napiModulesMap: NapiModulesMap;
|
|
12
|
+
tagMap: Record<string, string>;
|
|
13
13
|
}
|
|
14
14
|
export interface LynxView {
|
|
15
15
|
updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
|
|
16
16
|
dispose(): Promise<void>;
|
|
17
|
-
sendGlobalEvent
|
|
17
|
+
sendGlobalEvent: RpcCallType<typeof sendGlobalEventEndpoint>;
|
|
18
18
|
}
|
|
19
19
|
export declare function createLynxView(configs: LynxViewConfigs): LynxView;
|
|
@@ -3,13 +3,14 @@
|
|
|
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 {
|
|
6
|
+
const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, } = configs;
|
|
7
7
|
return startUIThread(templateUrl, {
|
|
8
|
+
tagMap,
|
|
8
9
|
initData,
|
|
9
10
|
globalProps,
|
|
10
|
-
|
|
11
|
+
nativeModulesMap,
|
|
11
12
|
napiModulesMap,
|
|
12
13
|
browserConfig: {},
|
|
13
|
-
},
|
|
14
|
+
}, shadowRoot, callbacks);
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=createLynxView.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function bootTimingSystem(mainThreadRpc: Rpc, backgroundThreadRpc: Rpc,
|
|
2
|
+
export declare function bootTimingSystem(mainThreadRpc: Rpc, backgroundThreadRpc: Rpc, shadowRoot: ShadowRoot): {
|
|
3
3
|
markTimingInternal: (timingKey: string, pipelineId?: string, timeStamp?: number) => void;
|
|
4
4
|
sendTimingResult: (pipelineId: string | undefined, timingFlags: string[], isFp: boolean) => void;
|
|
5
5
|
};
|
|
@@ -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 { postTimingInfoFromBackgroundThread, postTimingInfoFromMainThread, postTimingResult, } from '@lynx-js/web-constants';
|
|
5
|
-
export function bootTimingSystem(mainThreadRpc, backgroundThreadRpc,
|
|
5
|
+
export function bootTimingSystem(mainThreadRpc, backgroundThreadRpc, shadowRoot) {
|
|
6
6
|
const setupTiming = {};
|
|
7
7
|
const pipelineIdToTiming = new Map();
|
|
8
8
|
let commonTimingFlags = [];
|
|
@@ -31,7 +31,7 @@ export function bootTimingSystem(mainThreadRpc, backgroundThreadRpc, rootDom) {
|
|
|
31
31
|
timingFlags,
|
|
32
32
|
isFp ? setupTiming : undefined,
|
|
33
33
|
]);
|
|
34
|
-
|
|
34
|
+
shadowRoot.dispatchEvent(new CustomEvent('timing', {
|
|
35
35
|
detail: isFp ? setupTiming : timingInfo,
|
|
36
36
|
bubbles: true,
|
|
37
37
|
cancelable: true,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function createExposureService(rpc: Rpc,
|
|
2
|
+
export declare function createExposureService(rpc: Rpc, shadowRoot: ShadowRoot): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lynxUniqueIdAttribute, postExposureEndpoint, switchExposureService, } from '@lynx-js/web-constants';
|
|
2
2
|
import { createCrossThreadEvent } from '../../utils/createCrossThreadEvent.js';
|
|
3
|
-
export function createExposureService(rpc,
|
|
3
|
+
export function createExposureService(rpc, shadowRoot) {
|
|
4
4
|
let working = true;
|
|
5
5
|
let exposureCache = [];
|
|
6
6
|
let disexposureCache = [];
|
|
@@ -30,8 +30,10 @@ export function createExposureService(rpc, rootDom) {
|
|
|
30
30
|
}]);
|
|
31
31
|
}
|
|
32
32
|
}, 1000 / 20);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
shadowRoot.addEventListener('exposure', exposureEventHandler, {
|
|
34
|
+
passive: true,
|
|
35
|
+
});
|
|
36
|
+
shadowRoot.addEventListener('disexposure', exposureEventHandler, {
|
|
35
37
|
passive: true,
|
|
36
38
|
});
|
|
37
39
|
rpc.registerHandler(switchExposureService, async (enable, sendEvent) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ErrorCode, IdentifierType } from '@lynx-js/web-constants';
|
|
2
|
-
export declare function queryNodes(
|
|
2
|
+
export declare function queryNodes(shadowRoot: ShadowRoot, type: IdentifierType, identifier: string, component_id: string, first_only: boolean, root_unique_id: number | undefined, callback: (dom: Element) => void, error?: (code: ErrorCode) => void): void;
|
|
@@ -2,10 +2,10 @@
|
|
|
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 { componentIdAttribute, ErrorCode, IdentifierType, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
|
|
5
|
-
export function queryNodes(
|
|
6
|
-
let queryRoot =
|
|
5
|
+
export function queryNodes(shadowRoot, type, identifier, component_id, first_only, root_unique_id, callback, error) {
|
|
6
|
+
let queryRoot = shadowRoot;
|
|
7
7
|
if (root_unique_id) {
|
|
8
|
-
const root =
|
|
8
|
+
const root = shadowRoot.querySelector(`[${lynxUniqueIdAttribute}="${root_unique_id}"]`);
|
|
9
9
|
if (root) {
|
|
10
10
|
queryRoot = root;
|
|
11
11
|
}
|
|
@@ -16,7 +16,7 @@ export function queryNodes(rootDom, type, identifier, component_id, first_only,
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
else if (component_id) {
|
|
19
|
-
const root =
|
|
19
|
+
const root = shadowRoot.querySelector(`[${componentIdAttribute}="${component_id}"]`);
|
|
20
20
|
if (root) {
|
|
21
21
|
queryRoot = root;
|
|
22
22
|
}
|
|
@@ -3,10 +3,8 @@ import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
|
3
3
|
import type { RuntimePropertyOnElement } from '../../types/RuntimePropertyOnElement.js';
|
|
4
4
|
export declare function registerFlushElementTreeHandler(mainThreadRpc: Rpc, endpoint: typeof flushElementTreeEndpoint, options: {
|
|
5
5
|
pageConfig: PageConfig;
|
|
6
|
-
overrideTagMap: Record<string, string>;
|
|
7
6
|
backgroundRpc: Rpc;
|
|
8
|
-
|
|
9
|
-
entryId: string;
|
|
7
|
+
shadowRoot: ShadowRoot;
|
|
10
8
|
}, onCommit: (info: {
|
|
11
9
|
pipelineId: string | undefined;
|
|
12
10
|
timingFlags: string[];
|
|
@@ -1,27 +1,24 @@
|
|
|
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 { componentIdAttribute, lynxDefaultDisplayLinearAttribute, lynxRuntimeValue, lynxTagAttribute, lynxUniqueIdAttribute, parentComponentUniqueIdAttribute, postMainThreadEvent, publicComponentEventEndpoint, publishEventEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { decodeElementOperation } from '../decodeElementOperation.js';
|
|
6
|
-
import { getElementTag } from '../getElementTag.js';
|
|
7
6
|
import { createCrossThreadEvent } from '../../utils/createCrossThreadEvent.js';
|
|
8
|
-
function applyPageAttributes(page, pageConfig
|
|
9
|
-
page.setAttribute(cardIdAttribute, entryId);
|
|
7
|
+
function applyPageAttributes(page, pageConfig) {
|
|
10
8
|
if (pageConfig.defaultDisplayLinear === false) {
|
|
11
9
|
page.setAttribute(lynxDefaultDisplayLinearAttribute, 'false');
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
12
|
export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options, onCommit, markTimingInternal) {
|
|
15
|
-
const { pageConfig,
|
|
13
|
+
const { pageConfig, backgroundRpc, shadowRoot, } = options;
|
|
16
14
|
const uniqueIdToElement = [];
|
|
17
15
|
const uniqueIdToCssInJsRule = [];
|
|
18
16
|
const rootStyleElementForCssInJs = document.createElement('style');
|
|
19
17
|
if (!pageConfig.enableCSSSelector) {
|
|
20
|
-
|
|
18
|
+
shadowRoot.append(rootStyleElementForCssInJs);
|
|
21
19
|
}
|
|
22
20
|
const createElementImpl = (tag) => {
|
|
23
|
-
const
|
|
24
|
-
const element = document.createElement(htmlTag);
|
|
21
|
+
const element = document.createElement(tag);
|
|
25
22
|
element[lynxRuntimeValue] = {
|
|
26
23
|
dataset: {},
|
|
27
24
|
eventHandler: {},
|
|
@@ -41,7 +38,7 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
|
|
|
41
38
|
const crossThreadEvent = createCrossThreadEvent(event);
|
|
42
39
|
const currentTarget = event.currentTarget;
|
|
43
40
|
const parentComponentUniqueId = currentTarget.getAttribute(parentComponentUniqueIdAttribute) ?? '0';
|
|
44
|
-
const componentTargetDom =
|
|
41
|
+
const componentTargetDom = shadowRoot.querySelector(`[${lynxUniqueIdAttribute}="${parentComponentUniqueId}"]`);
|
|
45
42
|
const componentId = componentTargetDom?.getAttribute(lynxTagAttribute) !== 'page'
|
|
46
43
|
? componentTargetDom?.getAttribute(componentIdAttribute) ?? undefined
|
|
47
44
|
: undefined;
|
|
@@ -61,15 +58,13 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
|
|
|
61
58
|
]);
|
|
62
59
|
}
|
|
63
60
|
};
|
|
64
|
-
mainThreadRpc.registerHandler(endpoint, (operations, options, cardCss) => {
|
|
61
|
+
mainThreadRpc.registerHandler(endpoint, (operations, options, cardCss, timingFlags) => {
|
|
65
62
|
const { pipelineOptions } = options;
|
|
66
63
|
const pipelineId = pipelineOptions?.pipelineID;
|
|
67
|
-
const timingFlags = [];
|
|
68
64
|
markTimingInternal('dispatch_start', pipelineId);
|
|
69
65
|
markTimingInternal('layout_start', pipelineId);
|
|
70
66
|
markTimingInternal('ui_operation_flush_start', pipelineId);
|
|
71
67
|
const page = decodeElementOperation(operations, {
|
|
72
|
-
timingFlags,
|
|
73
68
|
uniqueIdToElement,
|
|
74
69
|
uniqueIdToCssInJsRule,
|
|
75
70
|
createElementImpl,
|
|
@@ -85,9 +80,9 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
|
|
|
85
80
|
// on FP
|
|
86
81
|
const styleElement = document.createElement('style');
|
|
87
82
|
styleElement.innerHTML = cardCss;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
applyPageAttributes(page, pageConfig
|
|
83
|
+
shadowRoot.append(styleElement);
|
|
84
|
+
shadowRoot.append(page);
|
|
85
|
+
applyPageAttributes(page, pageConfig);
|
|
91
86
|
}
|
|
92
87
|
markTimingInternal('layout_end', pipelineId);
|
|
93
88
|
markTimingInternal('dispatch_end', pipelineId);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function registerInvokeUIMethodHandler(rpc: Rpc,
|
|
2
|
+
export declare function registerInvokeUIMethodHandler(rpc: Rpc, shadowRoot: ShadowRoot): void;
|
|
@@ -17,11 +17,11 @@ const methodAlias = {
|
|
|
17
17
|
};
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
|
-
export function registerInvokeUIMethodHandler(rpc,
|
|
20
|
+
export function registerInvokeUIMethodHandler(rpc, shadowRoot) {
|
|
21
21
|
let code = ErrorCode.UNKNOWN;
|
|
22
22
|
let data = undefined;
|
|
23
23
|
rpc.registerHandler(invokeUIMethodEndpoint, (type, identifier, component_id, method, params, root_unique_id) => {
|
|
24
|
-
queryNodes(
|
|
24
|
+
queryNodes(shadowRoot, type, identifier, component_id, true, root_unique_id, (element) => {
|
|
25
25
|
try {
|
|
26
26
|
const aliasMethod = methodAlias[method];
|
|
27
27
|
const hasDomMethod = typeof element[method] === 'function';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function registerSelectComponentHandler(rpc: Rpc,
|
|
2
|
+
export declare function registerSelectComponentHandler(rpc: Rpc, shadowRoot: ShadowRoot): void;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { componentIdAttribute, IdentifierType, selectComponentEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { queryNodes } from './queryNodes.js';
|
|
6
|
-
export function registerSelectComponentHandler(rpc,
|
|
6
|
+
export function registerSelectComponentHandler(rpc, shadowRoot) {
|
|
7
7
|
let element;
|
|
8
8
|
rpc.registerHandler(selectComponentEndpoint, (componentId, idSelector, single) => {
|
|
9
|
-
queryNodes(
|
|
9
|
+
queryNodes(shadowRoot, IdentifierType.ID_SELECTOR, idSelector, componentId === 'card' ? '0' : componentId, single, undefined, (ele) => {
|
|
10
10
|
element = ele;
|
|
11
11
|
});
|
|
12
12
|
return [element?.getAttribute(componentIdAttribute) ?? undefined];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function registerNativePropsHandler(rpc: Rpc,
|
|
2
|
+
export declare function registerNativePropsHandler(rpc: Rpc, shadowRoot: ShadowRoot): void;
|
|
@@ -22,9 +22,9 @@ function applyNativeProps(element, nativeProps) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export function registerNativePropsHandler(rpc,
|
|
25
|
+
export function registerNativePropsHandler(rpc, shadowRoot) {
|
|
26
26
|
rpc.registerHandler(setNativePropsEndpoint, (type, identifier, component_id, first_only, native_props, root_unique_id) => {
|
|
27
|
-
queryNodes(
|
|
27
|
+
queryNodes(shadowRoot, type, identifier, component_id, first_only, root_unique_id, (element) => {
|
|
28
28
|
applyNativeProps(element, native_props);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function registerTriggerComponentEventHandler(rpc: Rpc,
|
|
2
|
+
export declare function registerTriggerComponentEventHandler(rpc: Rpc, shadowRoot: ShadowRoot): void;
|
|
@@ -2,9 +2,9 @@
|
|
|
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 { componentIdAttribute, triggerComponentEventEndpoint, } from '@lynx-js/web-constants';
|
|
5
|
-
export function registerTriggerComponentEventHandler(rpc,
|
|
5
|
+
export function registerTriggerComponentEventHandler(rpc, shadowRoot) {
|
|
6
6
|
rpc.registerHandler(triggerComponentEventEndpoint, (id, params) => {
|
|
7
|
-
const componentDom =
|
|
7
|
+
const componentDom = shadowRoot.querySelector(`[${componentIdAttribute}="${params.componentId}"]`);
|
|
8
8
|
componentDom?.dispatchEvent(new CustomEvent(id, {
|
|
9
9
|
...params.eventOption,
|
|
10
10
|
detail: params.eventDetail,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ElementOperation } from '@lynx-js/web-constants';
|
|
2
2
|
import type { RuntimePropertyOnElement } from '../types/RuntimePropertyOnElement.js';
|
|
3
3
|
export declare function decodeElementOperation<T extends HTMLElement & RuntimePropertyOnElement>(operations: ElementOperation[], options: {
|
|
4
|
-
timingFlags: string[];
|
|
5
4
|
uniqueIdToElement: (WeakRef<T> | undefined)[];
|
|
6
5
|
uniqueIdToCssInJsRule: (WeakRef<CSSStyleRule> | undefined)[];
|
|
7
6
|
createElementImpl: (tag: string) => T;
|
|
@@ -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 { cssIdAttribute,
|
|
4
|
+
import { cssIdAttribute, lynxUniqueIdAttribute, OperationType, lynxRuntimeValue, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, W3cEventNameToLynx, __lynx_timing_flag, lynxTagAttribute, } from '@lynx-js/web-constants';
|
|
5
5
|
function getElement(uniqueId, uniqueIdToElement) {
|
|
6
6
|
const element = uniqueIdToElement[uniqueId]?.deref();
|
|
7
7
|
if (element) {
|
|
@@ -18,7 +18,6 @@ function createElement(tag, uniqueId, uniqueIdToElement, createElementImpl) {
|
|
|
18
18
|
}
|
|
19
19
|
const element = createElementImpl(tag);
|
|
20
20
|
element.setAttribute(lynxUniqueIdAttribute, uniqueId.toString());
|
|
21
|
-
element.setAttribute(lynxTagAttribute, tag);
|
|
22
21
|
uniqueIdToElement[uniqueId] = new WeakRef(element);
|
|
23
22
|
return element;
|
|
24
23
|
}
|
|
@@ -39,7 +38,7 @@ function handleHtmlEvent(event) {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
export function decodeElementOperation(operations, options) {
|
|
42
|
-
const { uniqueIdToElement, uniqueIdToCssInJsRule, createElementImpl, createStyleRuleImpl, eventHandler,
|
|
41
|
+
const { uniqueIdToElement, uniqueIdToCssInJsRule, createElementImpl, createStyleRuleImpl, eventHandler, } = options;
|
|
43
42
|
let pageElement;
|
|
44
43
|
for (const op of operations) {
|
|
45
44
|
if (op.type === OperationType.Create) {
|
|
@@ -47,8 +46,6 @@ export function decodeElementOperation(operations, options) {
|
|
|
47
46
|
if (typeof op.cssId === 'number') {
|
|
48
47
|
element.setAttribute(cssIdAttribute, op.cssId.toString());
|
|
49
48
|
}
|
|
50
|
-
if (op.tag === 'page')
|
|
51
|
-
pageElement = element;
|
|
52
49
|
}
|
|
53
50
|
else {
|
|
54
51
|
const target = getElement(op.uid, uniqueIdToElement);
|
|
@@ -87,8 +84,8 @@ export function decodeElementOperation(operations, options) {
|
|
|
87
84
|
}
|
|
88
85
|
else {
|
|
89
86
|
target.setAttribute(op.key, op.value);
|
|
90
|
-
if (op.
|
|
91
|
-
|
|
87
|
+
if (op.key === lynxTagAttribute && op.value === 'page') {
|
|
88
|
+
pageElement = target;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
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'>,
|
|
3
|
+
export declare function startUIThread(templateUrl: string, configs: Omit<MainThreadStartConfigs, 'template'>, shadowRoot: ShadowRoot, callbacks: {
|
|
4
4
|
nativeModulesCall: NativeModulesCall;
|
|
5
5
|
napiModulesCall: NapiModulesCall;
|
|
6
6
|
onError?: () => void;
|
|
7
|
-
}
|
|
7
|
+
}): LynxView;
|
|
@@ -16,14 +16,14 @@ import { flushElementTreeEndpoint, mainThreadChunkReadyEndpoint, mainThreadStart
|
|
|
16
16
|
import { loadTemplate } from '../utils/loadTemplate.js';
|
|
17
17
|
import { createUpdateData } from './crossThreadHandlers/createUpdateData.js';
|
|
18
18
|
import { registerNapiModulesCallHandler } from './crossThreadHandlers/registerNapiModulesCallHandler.js';
|
|
19
|
-
export function startUIThread(templateUrl, configs,
|
|
19
|
+
export function startUIThread(templateUrl, configs, shadowRoot, callbacks) {
|
|
20
20
|
const createLynxStartTiming = performance.now() + performance.timeOrigin;
|
|
21
|
-
const {
|
|
21
|
+
const { nativeModulesMap, napiModulesMap } = configs;
|
|
22
22
|
const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers();
|
|
23
23
|
const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
|
|
24
24
|
const uiThreadFpReady = backgroundRpc.createCall(uiThreadFpReadyEndpoint);
|
|
25
25
|
const mainThreadStart = mainThreadRpc.createCall(mainThreadStartEndpoint);
|
|
26
|
-
const { markTimingInternal, sendTimingResult } = bootTimingSystem(mainThreadRpc, backgroundRpc,
|
|
26
|
+
const { markTimingInternal, sendTimingResult } = bootTimingSystem(mainThreadRpc, backgroundRpc, shadowRoot);
|
|
27
27
|
markTimingInternal('create_lynx_start', undefined, createLynxStartTiming);
|
|
28
28
|
markTimingInternal('load_template_start');
|
|
29
29
|
loadTemplate(templateUrl).then((template) => {
|
|
@@ -31,7 +31,7 @@ export function startUIThread(templateUrl, configs, rootDom, callbacks, override
|
|
|
31
31
|
mainThreadStart({
|
|
32
32
|
...configs,
|
|
33
33
|
template,
|
|
34
|
-
|
|
34
|
+
nativeModulesMap,
|
|
35
35
|
napiModulesMap,
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -40,18 +40,16 @@ export function startUIThread(templateUrl, configs, rootDom, callbacks, override
|
|
|
40
40
|
const { pageConfig } = mainChunkInfo;
|
|
41
41
|
registerFlushElementTreeHandler(mainThreadRpc, flushElementTreeEndpoint, {
|
|
42
42
|
pageConfig,
|
|
43
|
-
overrideTagMap,
|
|
44
43
|
backgroundRpc,
|
|
45
|
-
|
|
46
|
-
entryId,
|
|
44
|
+
shadowRoot,
|
|
47
45
|
}, (info) => {
|
|
48
46
|
const { pipelineId, timingFlags, isFP } = info;
|
|
49
47
|
if (isFP) {
|
|
50
|
-
registerInvokeUIMethodHandler(backgroundRpc,
|
|
51
|
-
registerNativePropsHandler(backgroundRpc,
|
|
52
|
-
registerTriggerComponentEventHandler(backgroundRpc,
|
|
53
|
-
registerSelectComponentHandler(backgroundRpc,
|
|
54
|
-
createExposureService(backgroundRpc,
|
|
48
|
+
registerInvokeUIMethodHandler(backgroundRpc, shadowRoot);
|
|
49
|
+
registerNativePropsHandler(backgroundRpc, shadowRoot);
|
|
50
|
+
registerTriggerComponentEventHandler(backgroundRpc, shadowRoot);
|
|
51
|
+
registerSelectComponentHandler(backgroundRpc, shadowRoot);
|
|
52
|
+
createExposureService(backgroundRpc, shadowRoot);
|
|
55
53
|
uiThreadFpReady();
|
|
56
54
|
}
|
|
57
55
|
sendTimingResult(pipelineId, timingFlags, isFP);
|
|
@@ -33,7 +33,7 @@ export function createCrossThreadEvent(domEvent) {
|
|
|
33
33
|
currentTarget: {
|
|
34
34
|
id: currentTargetElement.id,
|
|
35
35
|
dataset: currentTargetElement[lynxRuntimeValue]?.dataset ?? {},
|
|
36
|
-
uniqueId: parseFloat(currentTargetElement.getAttribute(lynxUniqueIdAttribute)),
|
|
36
|
+
uniqueId: parseFloat(currentTargetElement.getAttribute?.(lynxUniqueIdAttribute)),
|
|
37
37
|
},
|
|
38
38
|
// @ts-expect-error
|
|
39
39
|
detail: domEvent.detail ?? {},
|
package/index.css
CHANGED
|
@@ -9,54 +9,17 @@ lynx-view {
|
|
|
9
9
|
display: flex;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
lynx-view::part(lynx-view-root) {
|
|
13
|
-
display: contents;
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: 100%;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
lynx-view[height="auto"] {
|
|
19
|
-
--lynx-view-height: 100%;
|
|
20
|
-
height: var(--lynx-view-height);
|
|
21
|
-
block-size: var(--lynx-view-height);
|
|
22
|
-
}
|
|
23
|
-
lynx-view[height="auto"]::part(lynx-view-root) {
|
|
24
|
-
height: unset;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
12
|
lynx-view[width="auto"] {
|
|
28
13
|
--lynx-view-width: 100%;
|
|
29
14
|
width: var(--lynx-view-width);
|
|
30
15
|
inline-size: var(--lynx-view-width);
|
|
31
16
|
}
|
|
32
|
-
lynx-view[width="auto"]::part(lynx-view-root) {
|
|
33
|
-
width: unset;
|
|
34
|
-
}
|
|
35
17
|
|
|
36
18
|
lynx-view[height="auto"], lynx-view[width="auto"] {
|
|
37
|
-
contain
|
|
38
|
-
}
|
|
39
|
-
lynx-view[height="auto"]::part(lynx-view-root),
|
|
40
|
-
lynx-view[width="auto"]::part(lynx-view-root) {
|
|
41
|
-
display: unset;
|
|
42
|
-
position: fixed;
|
|
43
|
-
top: 0;
|
|
44
|
-
left: 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@property --lynx-view-width {
|
|
48
|
-
syntax: "<length> | <percentage>";
|
|
49
|
-
inherits: false;
|
|
50
|
-
initial-value: 100%;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@property --lynx-view-height {
|
|
54
|
-
syntax: "<length> | <percentage>";
|
|
55
|
-
inherits: false;
|
|
56
|
-
initial-value: 100%;
|
|
19
|
+
contain: content;
|
|
57
20
|
}
|
|
58
21
|
|
|
59
|
-
lynx-view
|
|
22
|
+
lynx-view::part(page) {
|
|
60
23
|
height: 100%;
|
|
61
24
|
width: 100%;
|
|
62
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"**/*.css"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lynx-js/web-constants": "0.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
29
|
-
"@lynx-js/web-worker-runtime": "0.
|
|
27
|
+
"@lynx-js/web-constants": "0.9.1",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "0.9.1",
|
|
29
|
+
"@lynx-js/web-worker-runtime": "0.9.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@lynx-js/lynx-core": "0.1.0",
|
|
33
|
-
"@lynx-js/web-elements": "0.
|
|
33
|
+
"@lynx-js/web-elements": "0.5.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@lynx-js/lynx-core": "0.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getElementTag(tag: string, tagMap: Record<string, string>, currentLoadingTags?: Promise<any>[]): string;
|
|
@@ -1,20 +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
|
-
export function getElementTag(tag, tagMap, currentLoadingTags) {
|
|
5
|
-
if (tagMap[tag]) {
|
|
6
|
-
return tagMap[tag];
|
|
7
|
-
}
|
|
8
|
-
if (customElements.get(tag)) {
|
|
9
|
-
tagMap[tag] = tag;
|
|
10
|
-
return tag;
|
|
11
|
-
}
|
|
12
|
-
const normizedTag = tag.includes('-') ? tag : `x-${tag}`;
|
|
13
|
-
if (customElements.get(normizedTag)) {
|
|
14
|
-
tagMap[tag] = normizedTag;
|
|
15
|
-
return normizedTag;
|
|
16
|
-
}
|
|
17
|
-
currentLoadingTags?.push(customElements.whenDefined(normizedTag));
|
|
18
|
-
return normizedTag;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=getElementTag.js.map
|