@lynx-js/web-mainthread-apis-canary 0.19.6-canary-20260120-2bc3e7ef → 0.19.6-canary-20260120-556fe9fd
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 +4 -2
- package/dist/createMainThreadGlobalThis.js +80 -41
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
-
## 0.19.6-canary-
|
|
3
|
+
## 0.19.6-canary-20260120140407-556fe9fded90945a7926093897288d5302c314d3
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
- feat: support main thread invoke ui method ([#2104](https://github.com/lynx-family/lynx-stack/pull/2104))
|
|
10
10
|
|
|
11
|
+
- fix: mts && bts events can be binded both ([#2121](https://github.com/lynx-family/lynx-stack/pull/2121))
|
|
12
|
+
|
|
11
13
|
- Updated dependencies [[`179f984`](https://github.com/lynx-family/lynx-stack/commit/179f9844adf00ff4b2cd450ffb943649441c87d3), [`6c2b51a`](https://github.com/lynx-family/lynx-stack/commit/6c2b51a661ae244eb40671f63f29ee971e084ed4)]:
|
|
12
|
-
- @lynx-js/web-constants@0.19.6-canary-
|
|
14
|
+
- @lynx-js/web-constants@0.19.6-canary-20260120140407-556fe9fded90945a7926093897288d5302c314d3
|
|
13
15
|
|
|
14
16
|
## 0.19.5
|
|
15
17
|
|
|
@@ -46,37 +46,45 @@ export function createMainThreadGlobalThis(config) {
|
|
|
46
46
|
const lynxEventName = W3cEventNameToLynx[event.type] ?? event.type;
|
|
47
47
|
const runtimeInfo = elementToRuntimeInfoMap.get(currentTarget);
|
|
48
48
|
if (runtimeInfo) {
|
|
49
|
-
const
|
|
49
|
+
const handlerInfos = (isCapture
|
|
50
50
|
? runtimeInfo.eventHandlerMap[lynxEventName]?.capture
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
: runtimeInfo.eventHandlerMap[lynxEventName]?.bind);
|
|
52
|
+
let stopPropagation = false;
|
|
53
|
+
if (handlerInfos) {
|
|
54
|
+
for (const handlerInfo of handlerInfos) {
|
|
55
|
+
const hname = handlerInfo.handler;
|
|
56
|
+
const crossThreadEvent = createCrossThreadEvent(event, lynxEventName);
|
|
57
|
+
if (typeof hname === 'string') {
|
|
58
|
+
const parentComponentUniqueId = Number(currentTarget.getAttribute(parentComponentUniqueIdAttribute));
|
|
59
|
+
const parentComponent = lynxUniqueIdToElement[parentComponentUniqueId]
|
|
60
|
+
.deref();
|
|
61
|
+
const componentId = parentComponent?.getAttribute(lynxTagAttribute) !== 'page'
|
|
62
|
+
? parentComponent?.getAttribute(componentIdAttribute)
|
|
63
|
+
?? undefined
|
|
64
|
+
: undefined;
|
|
65
|
+
if (componentId) {
|
|
66
|
+
callbacks.publicComponentEvent(componentId, hname, crossThreadEvent);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
callbacks.publishEvent(hname, crossThreadEvent);
|
|
70
|
+
}
|
|
71
|
+
if (handlerInfos.length === 1) {
|
|
72
|
+
stopPropagation = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (hname) {
|
|
76
|
+
crossThreadEvent.target.elementRefptr =
|
|
77
|
+
event.target;
|
|
78
|
+
if (crossThreadEvent.currentTarget) {
|
|
79
|
+
crossThreadEvent.currentTarget
|
|
80
|
+
.elementRefptr = event.currentTarget;
|
|
81
|
+
}
|
|
82
|
+
mtsRealm.globalWindow
|
|
83
|
+
.runWorklet?.(hname.value, [crossThreadEvent]);
|
|
84
|
+
}
|
|
76
85
|
}
|
|
77
|
-
mtsRealm.globalWindow
|
|
78
|
-
.runWorklet?.(hname.value, [crossThreadEvent]);
|
|
79
86
|
}
|
|
87
|
+
return stopPropagation;
|
|
80
88
|
}
|
|
81
89
|
return false;
|
|
82
90
|
};
|
|
@@ -106,9 +114,10 @@ export function createMainThreadGlobalThis(config) {
|
|
|
106
114
|
componentAtIndex: undefined,
|
|
107
115
|
enqueueComponent: undefined,
|
|
108
116
|
};
|
|
109
|
-
const
|
|
117
|
+
const handlerList = (isCapture
|
|
110
118
|
? runtimeInfo.eventHandlerMap[eventName]?.capture
|
|
111
|
-
: runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
119
|
+
: runtimeInfo.eventHandlerMap[eventName]?.bind);
|
|
120
|
+
const currentHandler = handlerList && handlerList.length > 0;
|
|
112
121
|
const currentRegisteredHandler = isCatch
|
|
113
122
|
? (isCapture ? catchCaptureHandler : defaultCatchHandler)
|
|
114
123
|
: (isCapture ? captureHandler : defaultHandler);
|
|
@@ -126,6 +135,14 @@ export function createMainThreadGlobalThis(config) {
|
|
|
126
135
|
if (isExposure && element.getAttribute('exposure-id') === '-1') {
|
|
127
136
|
mtsGlobalThis.__SetAttribute(element, 'exposure-id', null);
|
|
128
137
|
}
|
|
138
|
+
if (runtimeInfo.eventHandlerMap[eventName]) {
|
|
139
|
+
if (isCapture) {
|
|
140
|
+
runtimeInfo.eventHandlerMap[eventName].capture = undefined;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
runtimeInfo.eventHandlerMap[eventName].bind = undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
129
146
|
}
|
|
130
147
|
}
|
|
131
148
|
else {
|
|
@@ -157,11 +174,25 @@ export function createMainThreadGlobalThis(config) {
|
|
|
157
174
|
bind: undefined,
|
|
158
175
|
};
|
|
159
176
|
}
|
|
177
|
+
let targetList = (isCapture
|
|
178
|
+
? runtimeInfo.eventHandlerMap[eventName].capture
|
|
179
|
+
: runtimeInfo.eventHandlerMap[eventName].bind);
|
|
180
|
+
if (!Array.isArray(targetList)) {
|
|
181
|
+
targetList = targetList ? [targetList] : [];
|
|
182
|
+
}
|
|
183
|
+
const typeOfNew = typeof newEventHandler;
|
|
184
|
+
const index = targetList.findIndex((h) => typeof h.handler === typeOfNew);
|
|
185
|
+
if (index !== -1) {
|
|
186
|
+
targetList[index] = info;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
targetList.push(info);
|
|
190
|
+
}
|
|
160
191
|
if (isCapture) {
|
|
161
|
-
runtimeInfo.eventHandlerMap[eventName].capture =
|
|
192
|
+
runtimeInfo.eventHandlerMap[eventName].capture = targetList;
|
|
162
193
|
}
|
|
163
194
|
else {
|
|
164
|
-
runtimeInfo.eventHandlerMap[eventName].bind =
|
|
195
|
+
runtimeInfo.eventHandlerMap[eventName].bind = targetList;
|
|
165
196
|
}
|
|
166
197
|
}
|
|
167
198
|
elementToRuntimeInfoMap.set(element, runtimeInfo);
|
|
@@ -171,9 +202,12 @@ export function createMainThreadGlobalThis(config) {
|
|
|
171
202
|
if (runtimeInfo) {
|
|
172
203
|
eventName = eventName.toLowerCase();
|
|
173
204
|
const isCapture = eventType.startsWith('capture');
|
|
174
|
-
const handler = isCapture
|
|
205
|
+
const handler = (isCapture
|
|
175
206
|
? runtimeInfo.eventHandlerMap[eventName]?.capture
|
|
176
|
-
: runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
207
|
+
: runtimeInfo.eventHandlerMap[eventName]?.bind);
|
|
208
|
+
if (Array.isArray(handler)) {
|
|
209
|
+
return handler[0]?.handler;
|
|
210
|
+
}
|
|
177
211
|
return handler?.handler;
|
|
178
212
|
}
|
|
179
213
|
else {
|
|
@@ -186,13 +220,18 @@ export function createMainThreadGlobalThis(config) {
|
|
|
186
220
|
for (const [lynxEventName, info] of Object.entries(eventHandlerMap)) {
|
|
187
221
|
for (const atomInfo of [info.bind, info.capture]) {
|
|
188
222
|
if (atomInfo) {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
223
|
+
const handlerList = (Array.isArray(atomInfo)
|
|
224
|
+
? atomInfo
|
|
225
|
+
: [atomInfo]);
|
|
226
|
+
for (const item of handlerList) {
|
|
227
|
+
const { type, handler } = item;
|
|
228
|
+
if (handler) {
|
|
229
|
+
eventInfos.push({
|
|
230
|
+
type: type,
|
|
231
|
+
name: lynxEventName,
|
|
232
|
+
function: handler,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
196
235
|
}
|
|
197
236
|
}
|
|
198
237
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis-canary",
|
|
3
|
-
"version": "0.19.6-canary-20260120-
|
|
3
|
+
"version": "0.19.6-canary-20260120-556fe9fd",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"**/*.css"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.6-canary-20260120-
|
|
29
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.6-canary-20260120-556fe9fd",
|
|
30
30
|
"hyphenate-style-name": "^1.1.0",
|
|
31
31
|
"wasm-feature-detect": "^1.8.0"
|
|
32
32
|
},
|