@lynx-js/web-core
Version:
This is an internal experimental package, do not use
20 lines • 950 B
JavaScript
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { queryNodes } from './queryNodes.js';
import { selectComponentEndpoint } from '../../endpoints.js';
import { IdentifierType } from '../../../constants.js';
export function registerSelectComponentHandler(rpc, lynxViewInstance) {
rpc.registerHandler(selectComponentEndpoint, (componentId, idSelector, single) => {
let element = null;
queryNodes(lynxViewInstance, IdentifierType.ID_SELECTOR, idSelector, componentId === 'card' ? '0' : componentId, single, undefined, (ele) => {
element = ele;
});
if (!element)
return [];
return [
lynxViewInstance.mainThreadGlobalThis.__GetComponentID(element),
];
});
}
//# sourceMappingURL=registerSelectComponentHandler.js.map