@lynx-js/web-mainthread-apis-canary 0.19.6-canary-20260112-9e774c8d → 0.19.6-canary-20260116-ce265e8f
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 +5 -3
- package/dist/createMainThreadGlobalThis.js +61 -37
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
-
## 0.19.6-canary-
|
|
3
|
+
## 0.19.6-canary-20260116085656-ce265e8ff3d1a19e2f5b1b689fcb136c18c7913d
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- feat: add main-thread API: \_\_QuerySelector ([#2115](https://github.com/lynx-family/lynx-stack/pull/2115))
|
|
8
|
+
|
|
7
9
|
- feat: support main thread invoke ui method ([#2104](https://github.com/lynx-family/lynx-stack/pull/2104))
|
|
8
10
|
|
|
9
|
-
- Updated dependencies [[`6c2b51a`](https://github.com/lynx-family/lynx-stack/commit/6c2b51a661ae244eb40671f63f29ee971e084ed4)]:
|
|
10
|
-
- @lynx-js/web-constants@0.19.6-canary-
|
|
11
|
+
- 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-20260116085656-ce265e8ff3d1a19e2f5b1b689fcb136c18c7913d
|
|
11
13
|
|
|
12
14
|
## 0.19.5
|
|
13
15
|
|
|
@@ -357,6 +357,65 @@ export function createMainThreadGlobalThis(config) {
|
|
|
357
357
|
exposureChangedElements.clear();
|
|
358
358
|
callbacks.flushElementTree(options, timingFlagsCopied, exposureChangedElementsArray);
|
|
359
359
|
};
|
|
360
|
+
const __InvokeUIMethod = (element, method, params, callback) => {
|
|
361
|
+
try {
|
|
362
|
+
if (method === 'boundingClientRect') {
|
|
363
|
+
const rect = element.getBoundingClientRect();
|
|
364
|
+
callback({
|
|
365
|
+
code: ErrorCode.SUCCESS,
|
|
366
|
+
data: {
|
|
367
|
+
id: element.id,
|
|
368
|
+
width: rect.width,
|
|
369
|
+
height: rect.height,
|
|
370
|
+
left: rect.left,
|
|
371
|
+
right: rect.right,
|
|
372
|
+
top: rect.top,
|
|
373
|
+
bottom: rect.bottom,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (typeof element[method] === 'function') {
|
|
379
|
+
const data = element[method](params);
|
|
380
|
+
callback({
|
|
381
|
+
code: ErrorCode.SUCCESS,
|
|
382
|
+
data,
|
|
383
|
+
});
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
callback({
|
|
387
|
+
code: ErrorCode.METHOD_NOT_FOUND,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
catch (e) {
|
|
391
|
+
console.error(`[lynx-web] invokeUIMethod: apply method failed with`, e, element);
|
|
392
|
+
callback({
|
|
393
|
+
code: ErrorCode.PARAM_INVALID,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const __QuerySelector = (element, selector) => {
|
|
398
|
+
if (!element)
|
|
399
|
+
return null;
|
|
400
|
+
const el = element.querySelector(selector);
|
|
401
|
+
if (el) {
|
|
402
|
+
if (!el.invoke) {
|
|
403
|
+
el.invoke = (method, params) => {
|
|
404
|
+
return new Promise((resolve, reject) => {
|
|
405
|
+
__InvokeUIMethod(el, method, params, (res) => {
|
|
406
|
+
if (res.code === ErrorCode.SUCCESS) {
|
|
407
|
+
resolve(res.data);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
reject(res);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return el;
|
|
418
|
+
};
|
|
360
419
|
const __GetPageElement = () => {
|
|
361
420
|
return pageElement;
|
|
362
421
|
};
|
|
@@ -501,43 +560,8 @@ export function createMainThreadGlobalThis(config) {
|
|
|
501
560
|
_I18nResourceTranslation: callbacks._I18nResourceTranslation,
|
|
502
561
|
_AddEventListener: () => { },
|
|
503
562
|
renderPage: undefined,
|
|
504
|
-
__InvokeUIMethod
|
|
505
|
-
|
|
506
|
-
if (method === 'boundingClientRect') {
|
|
507
|
-
const rect = element.getBoundingClientRect();
|
|
508
|
-
callback({
|
|
509
|
-
code: ErrorCode.SUCCESS,
|
|
510
|
-
data: {
|
|
511
|
-
id: element.id,
|
|
512
|
-
width: rect.width,
|
|
513
|
-
height: rect.height,
|
|
514
|
-
left: rect.left,
|
|
515
|
-
right: rect.right,
|
|
516
|
-
top: rect.top,
|
|
517
|
-
bottom: rect.bottom,
|
|
518
|
-
},
|
|
519
|
-
});
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
if (typeof element[method] === 'function') {
|
|
523
|
-
const data = element[method](params);
|
|
524
|
-
callback({
|
|
525
|
-
code: ErrorCode.SUCCESS,
|
|
526
|
-
data,
|
|
527
|
-
});
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
callback({
|
|
531
|
-
code: ErrorCode.METHOD_NOT_FOUND,
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
catch (e) {
|
|
535
|
-
console.error(`[lynx-web] invokeUIMethod: apply method failed with`, e, element);
|
|
536
|
-
callback({
|
|
537
|
-
code: ErrorCode.PARAM_INVALID,
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
},
|
|
563
|
+
__InvokeUIMethod,
|
|
564
|
+
__QuerySelector,
|
|
541
565
|
};
|
|
542
566
|
Object.assign(mtsRealm.globalWindow, mtsGlobalThis);
|
|
543
567
|
Object.defineProperty(mtsRealm.globalWindow, 'renderPage', {
|
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-
|
|
3
|
+
"version": "0.19.6-canary-20260116-ce265e8f",
|
|
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-
|
|
29
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.6-canary-20260116-ce265e8f",
|
|
30
30
|
"hyphenate-style-name": "^1.1.0",
|
|
31
31
|
"wasm-feature-detect": "^1.8.0"
|
|
32
32
|
},
|