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