Remove nativeEmpty, check call change to native side

This commit is contained in:
pengfei.zhou
2021-09-16 11:53:32 +08:00
committed by osborn
parent 3d3f646845
commit dd4e8db3ad
20 changed files with 72 additions and 93 deletions

View File

@@ -1314,7 +1314,7 @@ var Panel = /** @class */ (function () {
var promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
//nativeEmpty()
if (this.__root__.isDirty()) {
var model = this.__root__.toModel();
promises.push(this.nativeRender(model));

View File

@@ -996,7 +996,7 @@ class Panel {
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
//nativeEmpty()
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
promises.push(this.nativeRender(model));

View File

@@ -1226,11 +1226,6 @@ var doric = (function (exports) {
context.hookBeforeNativeCall();
}
}
function hookAfterNativeCall(context) {
if (context) {
context.hookAfterNativeCall();
}
}
function getContext() {
return Reflect.getMetadata('__doric_context__', global$2);
}
@@ -1256,7 +1251,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
hookAfterNativeCall(context);
}
function jsCallReject(contextId, callbackId, args) {
var arguments$1 = arguments;
@@ -1277,7 +1271,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
hookAfterNativeCall(context);
}
var Context = /** @class */ (function () {
function Context(id) {
@@ -1391,7 +1384,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
var ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
hookAfterNativeCall(context);
return ret;
}
else {
@@ -1561,11 +1553,15 @@ var doric = (function (exports) {
return;
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context);
hookBeforeNativeCall(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) {
return it && it.Math == Math && it;
@@ -13797,6 +13793,7 @@ var doric = (function (exports) {
exports.jsCallReject = jsCallReject;
exports.jsCallResolve = jsCallResolve;
exports.jsCallbackTimer = jsCallbackTimer;
exports.jsHookAfterNativeCall = jsHookAfterNativeCall;
exports.jsObtainContext = jsObtainContext;
exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule;

View File

@@ -1204,11 +1204,6 @@ var doric = (function (exports) {
context.hookBeforeNativeCall();
}
}
function hookAfterNativeCall(context) {
if (context) {
context.hookAfterNativeCall();
}
}
function getContext() {
return Reflect.getMetadata('__doric_context__', global$1);
}
@@ -1232,7 +1227,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
hookAfterNativeCall(context);
}
function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -1251,7 +1245,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
hookAfterNativeCall(context);
}
class Context {
constructor(id) {
@@ -1390,7 +1383,6 @@ var doric = (function (exports) {
}
hookBeforeNativeCall(context);
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
hookAfterNativeCall(context);
return ret;
}
else {
@@ -1545,11 +1537,15 @@ var doric = (function (exports) {
return;
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context);
hookBeforeNativeCall(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.__require__ = __require__;
@@ -1558,6 +1554,7 @@ var doric = (function (exports) {
exports.jsCallReject = jsCallReject;
exports.jsCallResolve = jsCallResolve;
exports.jsCallbackTimer = jsCallbackTimer;
exports.jsHookAfterNativeCall = jsHookAfterNativeCall;
exports.jsObtainContext = jsObtainContext;
exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule;

View File

@@ -1233,11 +1233,6 @@ function hookBeforeNativeCall(context) {
context.hookBeforeNativeCall();
}
}
function hookAfterNativeCall(context) {
if (context) {
context.hookAfterNativeCall();
}
}
function getContext() {
return Reflect.getMetadata('__doric_context__', global$2);
}
@@ -1261,7 +1256,6 @@ function jsCallResolve(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
hookAfterNativeCall(context);
}
function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -1280,7 +1274,6 @@ function jsCallReject(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
hookAfterNativeCall(context);
}
class Context {
constructor(id) {
@@ -1419,7 +1412,6 @@ function jsCallEntityMethod(contextId, methodName, args) {
}
hookBeforeNativeCall(context);
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
hookAfterNativeCall(context);
return ret;
}
else {
@@ -1574,11 +1566,15 @@ function jsCallbackTimer(timerId) {
return;
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context);
hookBeforeNativeCall(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({
__proto__: null,
@@ -1593,7 +1589,8 @@ var doric = /*#__PURE__*/Object.freeze({
jsCallEntityMethod: jsCallEntityMethod,
pureCallEntityMethod: pureCallEntityMethod,
jsObtainEntry: jsObtainEntry,
jsCallbackTimer: jsCallbackTimer
jsCallbackTimer: jsCallbackTimer,
jsHookAfterNativeCall: jsHookAfterNativeCall
});
function obj2Model(obj, convertor) {
@@ -2520,7 +2517,7 @@ class Panel {
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
//nativeEmpty()
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
promises.push(this.nativeRender(model));

View File

@@ -27,4 +27,5 @@ export declare function pureCallEntityMethod(contextId: string, methodName: stri
declare type ClassType<T> = new (...args: any) => T;
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
export declare function jsCallbackTimer(timerId: number): void;
export declare function jsHookAfterNativeCall(): void;
export {};

View File

@@ -22,11 +22,6 @@ function hookBeforeNativeCall(context) {
context.hookBeforeNativeCall();
}
}
function hookAfterNativeCall(context) {
if (context) {
context.hookAfterNativeCall();
}
}
function getContext() {
return Reflect.getMetadata('__doric_context__', global);
}
@@ -50,7 +45,6 @@ export function jsCallResolve(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList);
hookAfterNativeCall(context);
}
export function jsCallReject(contextId, callbackId, args) {
const context = gContexts.get(contextId);
@@ -69,7 +63,6 @@ export function jsCallReject(contextId, callbackId, args) {
}
hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList);
hookAfterNativeCall(context);
}
export class Context {
constructor(id) {
@@ -208,7 +201,6 @@ export function jsCallEntityMethod(contextId, methodName, args) {
}
hookBeforeNativeCall(context);
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
hookAfterNativeCall(context);
return ret;
}
else {
@@ -363,8 +355,12 @@ export function jsCallbackTimer(timerId) {
return;
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context);
hookBeforeNativeCall(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();
}

View File

@@ -182,7 +182,7 @@ export class Panel {
const promises = [];
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty();
//nativeEmpty()
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
promises.push(this.nativeRender(model));

View File

@@ -59,12 +59,6 @@ function hookBeforeNativeCall(context?: Context) {
}
}
function hookAfterNativeCall(context?: Context) {
if (context) {
context.hookAfterNativeCall()
}
}
function getContext(): Context | undefined {
return Reflect.getMetadata('__doric_context__', global)
}
@@ -90,7 +84,6 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.resolve, context, argumentsList)
hookAfterNativeCall(context)
}
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
@@ -110,7 +103,6 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.reject, context.entity, argumentsList)
hookAfterNativeCall(context)
}
export class Context {
@@ -231,7 +223,6 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
}
hookBeforeNativeCall(context)
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
hookAfterNativeCall(context)
return ret
} else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
@@ -392,8 +383,13 @@ export function jsCallbackTimer(timerId: number) {
return
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context)
hookBeforeNativeCall(timerInfo.context)
Reflect.apply(timerInfo.callback, timerInfo.context, [])
hookAfterNativeCall(timerInfo.context)
}
}
}
export function jsHookAfterNativeCall() {
const context = getContext()
context?.hookAfterNativeCall()
}

View File

@@ -70,12 +70,6 @@ function hookBeforeNativeCall(context?: Context) {
}
}
function hookAfterNativeCall(context?: Context) {
if (context) {
context.hookAfterNativeCall()
}
}
function getContext(): Context | undefined {
return Reflect.getMetadata('__doric_context__', global)
}
@@ -101,7 +95,6 @@ export function jsCallResolve(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.resolve, context, argumentsList)
hookAfterNativeCall(context)
}
export function jsCallReject(contextId: string, callbackId: string, args?: any) {
@@ -121,7 +114,6 @@ export function jsCallReject(contextId: string, callbackId: string, args?: any)
}
hookBeforeNativeCall(context)
Reflect.apply(callback.reject, context.entity, argumentsList)
hookAfterNativeCall(context)
}
export class Context {
@@ -269,7 +261,6 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
}
hookBeforeNativeCall(context)
const ret = Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
hookAfterNativeCall(context)
return ret
} else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
@@ -431,8 +422,13 @@ export function jsCallbackTimer(timerId: number) {
return
}
if (timerInfo.callback instanceof Function) {
setContext(timerInfo.context)
hookBeforeNativeCall(timerInfo.context)
Reflect.apply(timerInfo.callback, timerInfo.context, [])
hookAfterNativeCall(timerInfo.context)
}
}
}
export function jsHookAfterNativeCall() {
const context = getContext()
context?.hookAfterNativeCall()
}

View File

@@ -212,7 +212,7 @@ export abstract class Panel {
const promises: Promise<any>[] = []
if (Environment.platform !== 'web') {
//Here insert a native call to ensure the promise is resolved done.
nativeEmpty()
//nativeEmpty()
if (this.__root__.isDirty()) {
const model = this.__root__.toModel()
promises.push(this.nativeRender(model))