feat:fix when android excute js on same thread,cause stucked
This commit is contained in:
2
doric-js/lib/index.web.d.ts
vendored
2
doric-js/lib/index.web.d.ts
vendored
@@ -23,7 +23,7 @@ declare function _binaryValue(v: RawValue): {
|
||||
};
|
||||
declare function _wrappedValue(v: RawValue): WrappedValue;
|
||||
declare function _rawValue(v: WrappedValue): RawValue;
|
||||
declare function _injectGlobalObject(name: string, args: string): void;
|
||||
declare function __injectGlobalObject(name: string, args: string): void;
|
||||
declare function __injectGlobalFunction(name: string): void;
|
||||
declare function __invokeMethod(objectName: string, functionName: string, stringifiedArgs: string): void;
|
||||
declare function _prepared(): void;
|
||||
|
@@ -91,7 +91,7 @@ function _rawValue(v) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function _injectGlobalObject(name, args) {
|
||||
function __injectGlobalObject(name, args) {
|
||||
Reflect.set(window, name, JSON.parse(args));
|
||||
}
|
||||
function __injectGlobalFunction(name) {
|
||||
@@ -105,6 +105,7 @@ function __injectGlobalFunction(name) {
|
||||
});
|
||||
}
|
||||
function __invokeMethod(objectName, functionName, stringifiedArgs) {
|
||||
NativeClient.log(`invoke:${objectName}.${functionName}(${stringifiedArgs})`);
|
||||
try {
|
||||
const thisObject = Reflect.get(window, objectName);
|
||||
const thisFunction = Reflect.get(thisObject, functionName);
|
||||
@@ -112,6 +113,7 @@ function __invokeMethod(objectName, functionName, stringifiedArgs) {
|
||||
const rawArgs = args.map(e => _rawValue(e));
|
||||
const ret = Reflect.apply(thisFunction, thisObject, rawArgs);
|
||||
const returnVal = ret ? JSON.stringify(_wrappedValue(ret)) : "";
|
||||
NativeClient.log(`return:${returnVal}`);
|
||||
NativeClient.returnNative(returnVal);
|
||||
}
|
||||
catch (e) {
|
||||
|
Reference in New Issue
Block a user