Remove nativeEmpty, check call change to native side
This commit is contained in:
parent
3d3f646845
commit
dd4e8db3ad
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,6 +34,7 @@ captures/
|
|||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
*.iml
|
*.iml
|
||||||
|
.idea
|
||||||
.idea/workspace.xml
|
.idea/workspace.xml
|
||||||
.idea/tasks.xml
|
.idea/tasks.xml
|
||||||
.idea/gradle.xml
|
.idea/gradle.xml
|
||||||
|
@ -176,12 +176,6 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_EMPTY, new JavaFunction() {
|
|
||||||
@Override
|
|
||||||
public JavaValue exec(JSDecoder[] args) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_REQUIRE, new JavaFunction() {
|
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_REQUIRE, new JavaFunction() {
|
||||||
@Override
|
@Override
|
||||||
public JavaValue exec(JSDecoder[] args) {
|
public JavaValue exec(JSDecoder[] args) {
|
||||||
@ -292,8 +286,10 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
|||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
values.add(DoricUtils.toJavaValue(arg));
|
values.add(DoricUtils.toJavaValue(arg));
|
||||||
}
|
}
|
||||||
return mDoricJSE.invokeMethod(DoricConstant.GLOBAL_DORIC, method,
|
JSDecoder ret = mDoricJSE.invokeMethod(DoricConstant.GLOBAL_DORIC, method,
|
||||||
values.toArray(new JavaValue[0]), false);
|
values.toArray(new JavaValue[0]), false);
|
||||||
|
mDoricJSE.invokeMethod(DoricConstant.GLOBAL_DORIC, DoricConstant.DORIC_HOOK_NATIVE_CALL, new JavaValue[0], false);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +33,6 @@ public class DoricConstant {
|
|||||||
public static final String INJECT_TIMER_SET = "nativeSetTimer";
|
public static final String INJECT_TIMER_SET = "nativeSetTimer";
|
||||||
public static final String INJECT_TIMER_CLEAR = "nativeClearTimer";
|
public static final String INJECT_TIMER_CLEAR = "nativeClearTimer";
|
||||||
public static final String INJECT_BRIDGE = "nativeBridge";
|
public static final String INJECT_BRIDGE = "nativeBridge";
|
||||||
public static final String INJECT_EMPTY = "nativeEmpty";
|
|
||||||
|
|
||||||
public static final String TEMPLATE_CONTEXT_CREATE = "Reflect.apply(" +
|
public static final String TEMPLATE_CONTEXT_CREATE = "Reflect.apply(" +
|
||||||
"function(doric,context,Entry,require,exports){" + "\n" +
|
"function(doric,context,Entry,require,exports){" + "\n" +
|
||||||
@ -64,6 +63,7 @@ public class DoricConstant {
|
|||||||
public static final String DORIC_TIMER_CALLBACK = "jsCallbackTimer";
|
public static final String DORIC_TIMER_CALLBACK = "jsCallbackTimer";
|
||||||
public static final String DORIC_BRIDGE_RESOLVE = "jsCallResolve";
|
public static final String DORIC_BRIDGE_RESOLVE = "jsCallResolve";
|
||||||
public static final String DORIC_BRIDGE_REJECT = "jsCallReject";
|
public static final String DORIC_BRIDGE_REJECT = "jsCallReject";
|
||||||
|
public static final String DORIC_HOOK_NATIVE_CALL = "jsHookAfterNativeCall";
|
||||||
|
|
||||||
|
|
||||||
public static final String DORIC_ENTITY_RESPONSE = "__response__";
|
public static final String DORIC_ENTITY_RESPONSE = "__response__";
|
||||||
|
@ -57,9 +57,11 @@ class CounterVM extends ViewModel<CountModel, CounterView> {
|
|||||||
onAttached(s: CountModel, vh: CounterView) {
|
onAttached(s: CountModel, vh: CounterView) {
|
||||||
vh.counter.onClick = () => {
|
vh.counter.onClick = () => {
|
||||||
Promise.resolve(this.getState().count).then(count => {
|
Promise.resolve(this.getState().count).then(count => {
|
||||||
this.updateState((state) => {
|
Promise.resolve().then(() => {
|
||||||
state.count = count + 1;
|
this.updateState((state) => {
|
||||||
});
|
state.count = count + 1;
|
||||||
|
});
|
||||||
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,6 @@ - (void)initJSExecutor {
|
|||||||
} else {
|
} else {
|
||||||
[self.registry onLog:DoricLogTypeDebug message:message];
|
[self.registry onLog:DoricLogTypeDebug message:message];
|
||||||
}
|
}
|
||||||
}];
|
|
||||||
[self.jsExecutor injectGlobalJSObject:INJECT_EMPTY obj:^() {
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
[self.jsExecutor injectGlobalJSObject:INJECT_REQUIRE obj:^(NSString *name) {
|
[self.jsExecutor injectGlobalJSObject:INJECT_REQUIRE obj:^(NSString *name) {
|
||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
@ -262,11 +259,15 @@ - (JSValue *)invokeDoricMethod:(NSString *)method arguments:(va_list)args {
|
|||||||
[array addObject:arg];
|
[array addObject:arg];
|
||||||
arg = va_arg(args, JSValue *);
|
arg = va_arg(args, JSValue *);
|
||||||
}
|
}
|
||||||
return [self.jsExecutor invokeObject:GLOBAL_DORIC method:method args:array];
|
return [self invokeDoricMethod:method argumentsArray:array];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (JSValue *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArray *)args {
|
- (JSValue *)invokeDoricMethod:(NSString *)method argumentsArray:(NSArray *)args {
|
||||||
return [self.jsExecutor invokeObject:GLOBAL_DORIC method:method args:args];
|
JSValue *ret = [self.jsExecutor invokeObject:GLOBAL_DORIC method:method args:args];
|
||||||
|
if (![method isEqualToString:@"pureCallEntityMethod"]) {
|
||||||
|
[self.jsExecutor invokeObject:GLOBAL_DORIC method:DORIC_HOOK_NATIVE_CALL args:nil];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)packageContextScript:(NSString *)contextId content:(NSString *)content {
|
- (NSString *)packageContextScript:(NSString *)contextId content:(NSString *)content {
|
||||||
|
@ -32,7 +32,6 @@ extern NSString *const INJECT_REQUIRE;
|
|||||||
extern NSString *const INJECT_TIMER_SET;
|
extern NSString *const INJECT_TIMER_SET;
|
||||||
extern NSString *const INJECT_TIMER_CLEAR;
|
extern NSString *const INJECT_TIMER_CLEAR;
|
||||||
extern NSString *const INJECT_BRIDGE;
|
extern NSString *const INJECT_BRIDGE;
|
||||||
extern NSString *const INJECT_EMPTY;
|
|
||||||
|
|
||||||
extern NSString *const TEMPLATE_CONTEXT_CREATE;
|
extern NSString *const TEMPLATE_CONTEXT_CREATE;
|
||||||
|
|
||||||
@ -54,6 +53,8 @@ extern NSString *const DORIC_BRIDGE_RESOLVE;
|
|||||||
|
|
||||||
extern NSString *const DORIC_BRIDGE_REJECT;
|
extern NSString *const DORIC_BRIDGE_REJECT;
|
||||||
|
|
||||||
|
extern NSString *const DORIC_HOOK_NATIVE_CALL;
|
||||||
|
|
||||||
extern NSString *const DORIC_ENTITY_RESPONSE;
|
extern NSString *const DORIC_ENTITY_RESPONSE;
|
||||||
|
|
||||||
extern NSString *const DORIC_ENTITY_INIT;
|
extern NSString *const DORIC_ENTITY_INIT;
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
NSString *const INJECT_TIMER_SET = @"nativeSetTimer";
|
NSString *const INJECT_TIMER_SET = @"nativeSetTimer";
|
||||||
NSString *const INJECT_TIMER_CLEAR = @"nativeClearTimer";
|
NSString *const INJECT_TIMER_CLEAR = @"nativeClearTimer";
|
||||||
NSString *const INJECT_BRIDGE = @"nativeBridge";
|
NSString *const INJECT_BRIDGE = @"nativeBridge";
|
||||||
NSString *const INJECT_EMPTY = @"nativeEmpty";
|
|
||||||
|
|
||||||
NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
|
NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
|
||||||
"function(doric,context,Entry,require,exports){" "\n"
|
"function(doric,context,Entry,require,exports){" "\n"
|
||||||
@ -72,6 +71,8 @@
|
|||||||
|
|
||||||
NSString *const DORIC_BRIDGE_REJECT = @"jsCallReject";
|
NSString *const DORIC_BRIDGE_REJECT = @"jsCallReject";
|
||||||
|
|
||||||
|
NSString *const DORIC_HOOK_NATIVE_CALL = @"jsHookAfterNativeCall";
|
||||||
|
|
||||||
NSString *const DORIC_ENTITY_RESPONSE = @"__response__";
|
NSString *const DORIC_ENTITY_RESPONSE = @"__response__";
|
||||||
|
|
||||||
NSString *const DORIC_ENTITY_INIT = @"__init__";
|
NSString *const DORIC_ENTITY_INIT = @"__init__";
|
||||||
|
@ -1314,7 +1314,7 @@ var Panel = /** @class */ (function () {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty();
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
var model = this.__root__.toModel();
|
var model = this.__root__.toModel();
|
||||||
promises.push(this.nativeRender(model));
|
promises.push(this.nativeRender(model));
|
||||||
|
@ -996,7 +996,7 @@ class Panel {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty();
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
promises.push(this.nativeRender(model));
|
promises.push(this.nativeRender(model));
|
||||||
|
@ -1226,11 +1226,6 @@ var doric = (function (exports) {
|
|||||||
context.hookBeforeNativeCall();
|
context.hookBeforeNativeCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hookAfterNativeCall(context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getContext() {
|
function getContext() {
|
||||||
return Reflect.getMetadata('__doric_context__', global$2);
|
return Reflect.getMetadata('__doric_context__', global$2);
|
||||||
}
|
}
|
||||||
@ -1256,7 +1251,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.resolve, context, argumentsList);
|
Reflect.apply(callback.resolve, context, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
function jsCallReject(contextId, callbackId, args) {
|
function jsCallReject(contextId, callbackId, args) {
|
||||||
var arguments$1 = arguments;
|
var arguments$1 = arguments;
|
||||||
@ -1277,7 +1271,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList);
|
Reflect.apply(callback.reject, context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
var Context = /** @class */ (function () {
|
var Context = /** @class */ (function () {
|
||||||
function Context(id) {
|
function Context(id) {
|
||||||
@ -1391,7 +1384,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
var ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
var ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1561,11 +1553,15 @@ var doric = (function (exports) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context);
|
||||||
hookBeforeNativeCall(timerInfo.context);
|
hookBeforeNativeCall(timerInfo.context);
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
||||||
hookAfterNativeCall(timerInfo.context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function jsHookAfterNativeCall() {
|
||||||
|
var context = getContext();
|
||||||
|
context === null || context === void 0 ? void 0 : context.hookAfterNativeCall();
|
||||||
|
}
|
||||||
|
|
||||||
var check = function (it) {
|
var check = function (it) {
|
||||||
return it && it.Math == Math && it;
|
return it && it.Math == Math && it;
|
||||||
@ -13797,6 +13793,7 @@ var doric = (function (exports) {
|
|||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
exports.jsCallbackTimer = jsCallbackTimer;
|
exports.jsCallbackTimer = jsCallbackTimer;
|
||||||
|
exports.jsHookAfterNativeCall = jsHookAfterNativeCall;
|
||||||
exports.jsObtainContext = jsObtainContext;
|
exports.jsObtainContext = jsObtainContext;
|
||||||
exports.jsObtainEntry = jsObtainEntry;
|
exports.jsObtainEntry = jsObtainEntry;
|
||||||
exports.jsRegisterModule = jsRegisterModule;
|
exports.jsRegisterModule = jsRegisterModule;
|
||||||
|
@ -1204,11 +1204,6 @@ var doric = (function (exports) {
|
|||||||
context.hookBeforeNativeCall();
|
context.hookBeforeNativeCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hookAfterNativeCall(context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getContext() {
|
function getContext() {
|
||||||
return Reflect.getMetadata('__doric_context__', global$1);
|
return Reflect.getMetadata('__doric_context__', global$1);
|
||||||
}
|
}
|
||||||
@ -1232,7 +1227,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.resolve, context, argumentsList);
|
Reflect.apply(callback.resolve, context, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
function jsCallReject(contextId, callbackId, args) {
|
function jsCallReject(contextId, callbackId, args) {
|
||||||
const context = gContexts.get(contextId);
|
const context = gContexts.get(contextId);
|
||||||
@ -1251,7 +1245,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList);
|
Reflect.apply(callback.reject, context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
@ -1390,7 +1383,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1545,11 +1537,15 @@ var doric = (function (exports) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context);
|
||||||
hookBeforeNativeCall(timerInfo.context);
|
hookBeforeNativeCall(timerInfo.context);
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
||||||
hookAfterNativeCall(timerInfo.context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext();
|
||||||
|
context === null || context === void 0 ? void 0 : context.hookAfterNativeCall();
|
||||||
|
}
|
||||||
|
|
||||||
exports.Context = Context;
|
exports.Context = Context;
|
||||||
exports.__require__ = __require__;
|
exports.__require__ = __require__;
|
||||||
@ -1558,6 +1554,7 @@ var doric = (function (exports) {
|
|||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
exports.jsCallbackTimer = jsCallbackTimer;
|
exports.jsCallbackTimer = jsCallbackTimer;
|
||||||
|
exports.jsHookAfterNativeCall = jsHookAfterNativeCall;
|
||||||
exports.jsObtainContext = jsObtainContext;
|
exports.jsObtainContext = jsObtainContext;
|
||||||
exports.jsObtainEntry = jsObtainEntry;
|
exports.jsObtainEntry = jsObtainEntry;
|
||||||
exports.jsRegisterModule = jsRegisterModule;
|
exports.jsRegisterModule = jsRegisterModule;
|
||||||
|
@ -1233,11 +1233,6 @@ function hookBeforeNativeCall(context) {
|
|||||||
context.hookBeforeNativeCall();
|
context.hookBeforeNativeCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hookAfterNativeCall(context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getContext() {
|
function getContext() {
|
||||||
return Reflect.getMetadata('__doric_context__', global$2);
|
return Reflect.getMetadata('__doric_context__', global$2);
|
||||||
}
|
}
|
||||||
@ -1261,7 +1256,6 @@ function jsCallResolve(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.resolve, context, argumentsList);
|
Reflect.apply(callback.resolve, context, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
function jsCallReject(contextId, callbackId, args) {
|
function jsCallReject(contextId, callbackId, args) {
|
||||||
const context = gContexts.get(contextId);
|
const context = gContexts.get(contextId);
|
||||||
@ -1280,7 +1274,6 @@ function jsCallReject(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList);
|
Reflect.apply(callback.reject, context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
@ -1419,7 +1412,6 @@ function jsCallEntityMethod(contextId, methodName, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1574,11 +1566,15 @@ function jsCallbackTimer(timerId) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context);
|
||||||
hookBeforeNativeCall(timerInfo.context);
|
hookBeforeNativeCall(timerInfo.context);
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
||||||
hookAfterNativeCall(timerInfo.context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext();
|
||||||
|
context === null || context === void 0 ? void 0 : context.hookAfterNativeCall();
|
||||||
|
}
|
||||||
|
|
||||||
var doric = /*#__PURE__*/Object.freeze({
|
var doric = /*#__PURE__*/Object.freeze({
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
@ -1593,7 +1589,8 @@ var doric = /*#__PURE__*/Object.freeze({
|
|||||||
jsCallEntityMethod: jsCallEntityMethod,
|
jsCallEntityMethod: jsCallEntityMethod,
|
||||||
pureCallEntityMethod: pureCallEntityMethod,
|
pureCallEntityMethod: pureCallEntityMethod,
|
||||||
jsObtainEntry: jsObtainEntry,
|
jsObtainEntry: jsObtainEntry,
|
||||||
jsCallbackTimer: jsCallbackTimer
|
jsCallbackTimer: jsCallbackTimer,
|
||||||
|
jsHookAfterNativeCall: jsHookAfterNativeCall
|
||||||
});
|
});
|
||||||
|
|
||||||
function obj2Model(obj, convertor) {
|
function obj2Model(obj, convertor) {
|
||||||
@ -2520,7 +2517,7 @@ class Panel {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty();
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
promises.push(this.nativeRender(model));
|
promises.push(this.nativeRender(model));
|
||||||
|
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@ -27,4 +27,5 @@ export declare function pureCallEntityMethod(contextId: string, methodName: stri
|
|||||||
declare type ClassType<T> = new (...args: any) => T;
|
declare type ClassType<T> = new (...args: any) => T;
|
||||||
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
||||||
export declare function jsCallbackTimer(timerId: number): void;
|
export declare function jsCallbackTimer(timerId: number): void;
|
||||||
|
export declare function jsHookAfterNativeCall(): void;
|
||||||
export {};
|
export {};
|
||||||
|
@ -22,11 +22,6 @@ function hookBeforeNativeCall(context) {
|
|||||||
context.hookBeforeNativeCall();
|
context.hookBeforeNativeCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hookAfterNativeCall(context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getContext() {
|
function getContext() {
|
||||||
return Reflect.getMetadata('__doric_context__', global);
|
return Reflect.getMetadata('__doric_context__', global);
|
||||||
}
|
}
|
||||||
@ -50,7 +45,6 @@ export function jsCallResolve(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.resolve, context, argumentsList);
|
Reflect.apply(callback.resolve, context, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
export function jsCallReject(contextId, callbackId, args) {
|
export function jsCallReject(contextId, callbackId, args) {
|
||||||
const context = gContexts.get(contextId);
|
const context = gContexts.get(contextId);
|
||||||
@ -69,7 +63,6 @@ export function jsCallReject(contextId, callbackId, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList);
|
Reflect.apply(callback.reject, context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
export class Context {
|
export class Context {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
@ -208,7 +201,6 @@ export function jsCallEntityMethod(contextId, methodName, args) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -363,8 +355,12 @@ export function jsCallbackTimer(timerId) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context);
|
||||||
hookBeforeNativeCall(timerInfo.context);
|
hookBeforeNativeCall(timerInfo.context);
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
||||||
hookAfterNativeCall(timerInfo.context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext();
|
||||||
|
context === null || context === void 0 ? void 0 : context.hookAfterNativeCall();
|
||||||
|
}
|
||||||
|
@ -182,7 +182,7 @@ export class Panel {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty();
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
promises.push(this.nativeRender(model));
|
promises.push(this.nativeRender(model));
|
||||||
|
@ -59,12 +59,6 @@ function hookBeforeNativeCall(context?: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hookAfterNativeCall(context?: Context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContext(): Context | undefined {
|
function getContext(): Context | undefined {
|
||||||
return Reflect.getMetadata('__doric_context__', global)
|
return Reflect.getMetadata('__doric_context__', global)
|
||||||
}
|
}
|
||||||
@ -90,7 +84,6 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
Reflect.apply(callback.resolve, context, argumentsList)
|
Reflect.apply(callback.resolve, context, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
|
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
|
||||||
@ -110,7 +103,6 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList)
|
Reflect.apply(callback.reject, context.entity, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Context {
|
export class Context {
|
||||||
@ -231,7 +223,6 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
return ret
|
return ret
|
||||||
} else {
|
} else {
|
||||||
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
||||||
@ -392,8 +383,13 @@ export function jsCallbackTimer(timerId: number) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context)
|
||||||
hookBeforeNativeCall(timerInfo.context)
|
hookBeforeNativeCall(timerInfo.context)
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, [])
|
Reflect.apply(timerInfo.callback, timerInfo.context, [])
|
||||||
hookAfterNativeCall(timerInfo.context)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext()
|
||||||
|
context?.hookAfterNativeCall()
|
||||||
|
}
|
||||||
|
@ -70,12 +70,6 @@ function hookBeforeNativeCall(context?: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hookAfterNativeCall(context?: Context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContext(): Context | undefined {
|
function getContext(): Context | undefined {
|
||||||
return Reflect.getMetadata('__doric_context__', global)
|
return Reflect.getMetadata('__doric_context__', global)
|
||||||
}
|
}
|
||||||
@ -101,7 +95,6 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
Reflect.apply(callback.resolve, context, argumentsList)
|
Reflect.apply(callback.resolve, context, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
|
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
|
||||||
@ -121,7 +114,6 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList)
|
Reflect.apply(callback.reject, context.entity, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Context {
|
export class Context {
|
||||||
@ -269,7 +261,6 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context)
|
hookBeforeNativeCall(context)
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
|
||||||
hookAfterNativeCall(context)
|
|
||||||
return ret
|
return ret
|
||||||
} else {
|
} else {
|
||||||
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
|
||||||
@ -431,8 +422,13 @@ export function jsCallbackTimer(timerId: number) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context)
|
||||||
hookBeforeNativeCall(timerInfo.context)
|
hookBeforeNativeCall(timerInfo.context)
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, [])
|
Reflect.apply(timerInfo.callback, timerInfo.context, [])
|
||||||
hookAfterNativeCall(timerInfo.context)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext()
|
||||||
|
context?.hookAfterNativeCall()
|
||||||
|
}
|
||||||
|
@ -212,7 +212,7 @@ export abstract class Panel {
|
|||||||
const promises: Promise<any>[] = []
|
const promises: Promise<any>[] = []
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty()
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel()
|
const model = this.__root__.toModel()
|
||||||
promises.push(this.nativeRender(model))
|
promises.push(this.nativeRender(model))
|
||||||
|
17
doric-web/dist/index.js
vendored
17
doric-web/dist/index.js
vendored
@ -1206,11 +1206,6 @@ var doric = (function (exports) {
|
|||||||
context.hookBeforeNativeCall();
|
context.hookBeforeNativeCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function hookAfterNativeCall(context) {
|
|
||||||
if (context) {
|
|
||||||
context.hookAfterNativeCall();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getContext() {
|
function getContext() {
|
||||||
return Reflect.getMetadata('__doric_context__', global$1);
|
return Reflect.getMetadata('__doric_context__', global$1);
|
||||||
}
|
}
|
||||||
@ -1234,7 +1229,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.resolve, context, argumentsList);
|
Reflect.apply(callback.resolve, context, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
function jsCallReject(contextId, callbackId, args) {
|
function jsCallReject(contextId, callbackId, args) {
|
||||||
const context = gContexts.get(contextId);
|
const context = gContexts.get(contextId);
|
||||||
@ -1253,7 +1247,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
Reflect.apply(callback.reject, context.entity, argumentsList);
|
Reflect.apply(callback.reject, context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
}
|
}
|
||||||
class Context {
|
class Context {
|
||||||
constructor(id) {
|
constructor(id) {
|
||||||
@ -1392,7 +1385,6 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
hookBeforeNativeCall(context);
|
hookBeforeNativeCall(context);
|
||||||
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
|
||||||
hookAfterNativeCall(context);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1547,11 +1539,15 @@ var doric = (function (exports) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timerInfo.callback instanceof Function) {
|
if (timerInfo.callback instanceof Function) {
|
||||||
|
setContext(timerInfo.context);
|
||||||
hookBeforeNativeCall(timerInfo.context);
|
hookBeforeNativeCall(timerInfo.context);
|
||||||
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
Reflect.apply(timerInfo.callback, timerInfo.context, []);
|
||||||
hookAfterNativeCall(timerInfo.context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function jsHookAfterNativeCall() {
|
||||||
|
const context = getContext();
|
||||||
|
context === null || context === void 0 ? void 0 : context.hookAfterNativeCall();
|
||||||
|
}
|
||||||
|
|
||||||
exports.Context = Context;
|
exports.Context = Context;
|
||||||
exports.__require__ = __require__;
|
exports.__require__ = __require__;
|
||||||
@ -1560,6 +1556,7 @@ var doric = (function (exports) {
|
|||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
exports.jsCallbackTimer = jsCallbackTimer;
|
exports.jsCallbackTimer = jsCallbackTimer;
|
||||||
|
exports.jsHookAfterNativeCall = jsHookAfterNativeCall;
|
||||||
exports.jsObtainContext = jsObtainContext;
|
exports.jsObtainContext = jsObtainContext;
|
||||||
exports.jsObtainEntry = jsObtainEntry;
|
exports.jsObtainEntry = jsObtainEntry;
|
||||||
exports.jsRegisterModule = jsRegisterModule;
|
exports.jsRegisterModule = jsRegisterModule;
|
||||||
@ -2574,7 +2571,7 @@ class Panel {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
if (Environment.platform !== 'web') {
|
if (Environment.platform !== 'web') {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//Here insert a native call to ensure the promise is resolved done.
|
||||||
nativeEmpty();
|
//nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
promises.push(this.nativeRender(model));
|
promises.push(this.nativeRender(model));
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user