dev android,and complete load context
This commit is contained in:
@@ -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
|
||||
|
@@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user