@lynx-js/web-mainthread-apis-canary 0.19.5 → 0.19.6-canary-20260112-6c2b51a6

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,14 @@
1
1
  # @lynx-js/web-mainthread-apis
2
2
 
3
+ ## 0.19.6-canary-20260112091442-6c2b51a661ae244eb40671f63f29ee971e084ed4
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: support main thread invoke ui method ([#2104](https://github.com/lynx-family/lynx-stack/pull/2104))
8
+
9
+ - Updated dependencies [[`6c2b51a`](https://github.com/lynx-family/lynx-stack/commit/6c2b51a661ae244eb40671f63f29ee971e084ed4)]:
10
+ - @lynx-js/web-constants@0.19.6-canary-20260112091442-6c2b51a661ae244eb40671f63f29ee971e084ed4
11
+
3
12
  ## 0.19.5
4
13
 
5
14
  ### Patch Changes
@@ -351,25 +360,25 @@
351
360
  lynxView.initI18nResources = [
352
361
  {
353
362
  options: {
354
- locale: 'en',
355
- channel: '1',
356
- fallback_url: '',
363
+ locale: "en",
364
+ channel: "1",
365
+ fallback_url: "",
357
366
  },
358
367
  resource: {
359
- hello: 'hello',
360
- lynx: 'lynx web platform1',
368
+ hello: "hello",
369
+ lynx: "lynx web platform1",
361
370
  },
362
371
  },
363
372
  ];
364
- lynxView.addEventListener('i18nResourceMissed', (e) => {
373
+ lynxView.addEventListener("i18nResourceMissed", (e) => {
365
374
  console.log(e);
366
375
  });
367
376
 
368
377
  // mts
369
378
  _I18nResourceTranslation({
370
- locale: 'en',
371
- channel: '1',
372
- fallback_url: '',
379
+ locale: "en",
380
+ channel: "1",
381
+ fallback_url: "",
373
382
  });
374
383
  ```
375
384
 
@@ -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 { lynxUniqueIdAttribute, systemInfo, parentComponentUniqueIdAttribute, componentIdAttribute, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, lynxTagAttribute, W3cEventNameToLynx, cssIdAttribute, lynxDefaultDisplayLinearAttribute, __lynx_timing_flag, lynxDisposedAttribute, lynxEntryNameAttribute, } from '@lynx-js/web-constants';
4
+ import { lynxUniqueIdAttribute, systemInfo, parentComponentUniqueIdAttribute, componentIdAttribute, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, lynxTagAttribute, W3cEventNameToLynx, cssIdAttribute, lynxDefaultDisplayLinearAttribute, __lynx_timing_flag, lynxDisposedAttribute, lynxEntryNameAttribute, ErrorCode, } from '@lynx-js/web-constants';
5
5
  import { createMainThreadLynx } from './createMainThreadLynx.js';
6
6
  import { __AddClass, __AddConfig, __AddDataset, __AddInlineStyle, __AppendElement, __ElementIsEqual, __FirstElement, __GetAttributes, __GetChildren, __GetClasses, __GetComponentID, __GetDataByKey, __GetDataset, __GetElementConfig, __GetElementUniqueID, __GetID, __GetParent, __GetTag, __GetTemplateParts, __InsertElementBefore, __LastElement, __MarkPartElement, __MarkTemplateElement, __NextElement, __RemoveElement, __ReplaceElement, __ReplaceElements, __SetClasses, __SetConfig, __SetCSSId, __SetDataset, __SetID, __SetInlineStyles, __UpdateComponentID, __UpdateComponentInfo, __GetAttributeByName, } from './pureElementPAPIs.js';
7
7
  import { createCrossThreadEvent } from './utils/createCrossThreadEvent.js';
@@ -501,6 +501,43 @@ export function createMainThreadGlobalThis(config) {
501
501
  _I18nResourceTranslation: callbacks._I18nResourceTranslation,
502
502
  _AddEventListener: () => { },
503
503
  renderPage: undefined,
504
+ __InvokeUIMethod: (element, method, params, callback) => {
505
+ try {
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
+ },
504
541
  };
505
542
  Object.assign(mtsRealm.globalWindow, mtsGlobalThis);
506
543
  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.5",
3
+ "version": "0.19.6-canary-20260112-6c2b51a6",
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.5",
29
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.6-canary-20260112-6c2b51a6",
30
30
  "hyphenate-style-name": "^1.1.0",
31
31
  "wasm-feature-detect": "^1.8.0"
32
32
  },