dev android,and complete load context

This commit is contained in:
pengfei.zhou
2019-07-18 16:29:24 +08:00
parent f2fc57bbc7
commit 2a34d7b638
21 changed files with 425 additions and 43 deletions

View File

@@ -8,9 +8,9 @@ import { loge } from "../util/log";
* function(hego,context,require){
* //Script content
* REG()
* },hego.obtainContext(id),[
* },hego.jsObtainContext(id),[
* undefined,
* hego.obtainContext(id),
* hego.jsObtainContext(id),
* hego.__require__,
* ])
* // load module in global scope
@@ -24,6 +24,7 @@ import { loge } from "../util/log";
*
* ```
*/
declare function nativeRequire(moduleName: string): boolean
declare function nativeBridge(contextId: string, namespace: string, method: string, args?: any, callbackId?: string): boolean

View File

@@ -1,11 +1,29 @@
declare function nativeLog(type: 'd' | 'w' | 'e', message: string): void
function toString(message: any) {
if (message instanceof Function) {
return message.toString()
} else if (message instanceof Object) {
try {
return JSON.stringify(message)
} catch (e) {
return message.toString()
}
} else if (message === undefined) {
return "undefined"
} else {
return message.toString()
}
}
export function log(message: any) {
console.log(message)
nativeLog('d', toString(message))
}
export function loge(message: any) {
console.error(message)
nativeLog('e', toString(message))
}
export function logw(message: any) {
console.warn(message)
nativeLog('w', toString(message))
}