imports.ts (924B) - raw
1 import { Config, FriendInfo } from "./types"; 2 3 declare var _getImportsFunctionName: string; 4 declare var _runtimeName: boolean; 5 export const runtimeName = _runtimeName; 6 7 const remoteImports = require(_runtimeName + '_core/src/DeviceBridge')[_getImportsFunctionName](); 8 9 function callRemoteFunction(method: string, ...args: any[]): any | null { 10 return remoteImports[method](...args); 11 } 12 13 14 export const log = (logLevel: string, message: string) => callRemoteFunction("log", logLevel, message); 15 16 export const getConfig = () => callRemoteFunction("getConfig") as Config; 17 18 export const downloadLastOperaMedia = (isLongPress: boolean) => callRemoteFunction("downloadLastOperaMedia", isLongPress); 19 20 export function getFriendInfoByUsername(username: string): FriendInfo | null { 21 const friendInfo = callRemoteFunction("getFriendInfoByUsername", username); 22 if (!friendInfo) return null; 23 return JSON.parse(friendInfo); 24 }