1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15type Any = Object | undefined | null; 16 17export interface CallbackUrl { 18 key: string; 19 filePath: string; 20 className: string; 21 methodName: string; 22 staticMethod?: (input: Any) => Object; 23 dynamicMethod?: (input: Object) => Any; 24} 25 26export const staticRegisterMap = new Map<string, CallbackUrl>(); 27export const dynamicRegisterMap = new Map<string, CallbackUrl>(); 28 29export function registerStaticCB(key: string, filePath: string, className: string, methodName: string) { 30 let callbackUrl: CallbackUrl = { 31 key: key, 32 filePath: filePath, 33 className: className, 34 methodName: methodName 35 }; 36 staticRegisterMap.set(key, callbackUrl); 37} 38 39export function registerDynamicCB(key: string, filePath: string, className: string, methodName: string) { 40 let callbackUrl: CallbackUrl = { 41 key: key, 42 filePath: filePath, 43 className: className, 44 methodName: methodName 45 }; 46 dynamicRegisterMap.set(key, callbackUrl); 47} 48 49export function registerStaticCB(key: string, staticMethod: (input: Any) => Object) { 50 let callbackUrl: CallbackUrl = { 51 key: key, 52 filePath: '', 53 className: '', 54 methodName: '', 55 staticMethod: staticMethod 56 }; 57 staticRegisterMap.set(key, callbackUrl); 58} 59 60export function registerDynamicCB(key: string, dynamicMethod: (input: Object) => Any) { 61 let callbackUrl: CallbackUrl = { 62 key: key, 63 filePath: '', 64 className: '', 65 methodName: '', 66 dynamicMethod: dynamicMethod 67 }; 68 dynamicRegisterMap.set(key, callbackUrl); 69} 70