Optimize unify panel hook after code
This commit is contained in:
99
doric-web/dist/index.js
vendored
99
doric-web/dist/index.js
vendored
@@ -1202,7 +1202,7 @@ var doric = (function (exports) {
|
||||
*/
|
||||
function hookBeforeNativeCall(context) {
|
||||
if (context) {
|
||||
Reflect.defineMetadata('__doric_context__', context, global$1);
|
||||
setContext(context);
|
||||
context.hookBeforeNativeCall();
|
||||
}
|
||||
}
|
||||
@@ -2555,74 +2555,37 @@ class Panel {
|
||||
return this.context.callNative("shader", "render", model);
|
||||
}
|
||||
hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'web') {
|
||||
this.__root__.clean();
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hookAfterNativeCall() {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
const promises = [];
|
||||
if (Environment.platform !== 'web') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
//nativeEmpty()
|
||||
if (this.__root__.isDirty()) {
|
||||
const model = this.__root__.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
}
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
}
|
||||
if (this.__root__.isDirty()) {
|
||||
const model = this.__root__.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
this.__root__.clean();
|
||||
}
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
if (this.__rendering__) {
|
||||
//skip
|
||||
Promise.all(promises).then(_ => {
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.__rendering__ = true;
|
||||
Promise.all(promises).then(_ => {
|
||||
this.__rendering__ = false;
|
||||
this.onRenderFinished();
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.__rendering__) {
|
||||
//skip
|
||||
Promise.all(promises).then(_ => {
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (this.__rendering__) {
|
||||
//skip
|
||||
return;
|
||||
}
|
||||
this.__rendering__ = true;
|
||||
Function("return this")().setTimeout(() => {
|
||||
if (this.__root__.isDirty()) {
|
||||
const model = this.__root__.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
this.__root__.clean();
|
||||
}
|
||||
for (let map of this.headviews.values()) {
|
||||
for (let v of map.values()) {
|
||||
if (v.isDirty()) {
|
||||
const model = v.toModel();
|
||||
promises.push(this.nativeRender(model));
|
||||
v.clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
Promise.all(promises).then(_ => {
|
||||
this.__rendering__ = false;
|
||||
Promise.all(promises).then(_ => {
|
||||
this.onRenderFinished();
|
||||
});
|
||||
}, 0);
|
||||
this.onRenderFinished();
|
||||
});
|
||||
}
|
||||
}
|
||||
onRenderFinished() {
|
||||
@@ -7525,7 +7488,6 @@ ${content}
|
||||
injectGlobalObject("Environment", {
|
||||
platform: "web"
|
||||
});
|
||||
injectGlobalObject("nativeEmpty", () => undefined);
|
||||
injectGlobalObject('nativeLog', (type, message) => {
|
||||
switch (type) {
|
||||
case 'd':
|
||||
@@ -7578,13 +7540,16 @@ ${content}
|
||||
if (ret instanceof Promise) {
|
||||
ret.then(e => {
|
||||
sandbox.jsCallResolve(contextId, callbackId, e);
|
||||
markNeedHook();
|
||||
}, e => {
|
||||
sandbox.jsCallReject(contextId, callbackId, e);
|
||||
markNeedHook();
|
||||
});
|
||||
}
|
||||
else if (ret !== undefined) {
|
||||
Promise.resolve(ret).then((ret) => {
|
||||
sandbox.jsCallResolve(contextId, callbackId, ret);
|
||||
markNeedHook();
|
||||
});
|
||||
}
|
||||
return true;
|
||||
@@ -7593,12 +7558,14 @@ ${content}
|
||||
if (repeat) {
|
||||
const handleId = originSetInterval(() => {
|
||||
sandbox.jsCallbackTimer(timerId);
|
||||
markNeedHook();
|
||||
}, time);
|
||||
timers.set(timerId, { handleId, repeat });
|
||||
}
|
||||
else {
|
||||
const handleId = originSetTimeout(() => {
|
||||
sandbox.jsCallbackTimer(timerId);
|
||||
markNeedHook();
|
||||
}, time);
|
||||
timers.set(timerId, { handleId, repeat });
|
||||
}
|
||||
@@ -7625,6 +7592,17 @@ ${content}
|
||||
document.body.removeChild(scriptElement);
|
||||
}
|
||||
}
|
||||
let requesting = false;
|
||||
function markNeedHook() {
|
||||
if (requesting) {
|
||||
return;
|
||||
}
|
||||
requesting = true;
|
||||
requestAnimationFrame(() => {
|
||||
sandbox.jsHookAfterNativeCall();
|
||||
requesting = false;
|
||||
});
|
||||
}
|
||||
initDoric();
|
||||
|
||||
const doricContexts = new Map;
|
||||
@@ -7663,7 +7641,9 @@ ${content}
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
argumentsList.push(arguments[i]);
|
||||
}
|
||||
return Reflect.apply(sandbox.jsCallEntityMethod, this.panel, argumentsList);
|
||||
const ret = Reflect.apply(sandbox.jsCallEntityMethod, this.panel, argumentsList);
|
||||
markNeedHook();
|
||||
return ret;
|
||||
}
|
||||
pureInvokeEntityMethod(method, ...otherArgs) {
|
||||
const argumentsList = [this.contextId];
|
||||
@@ -7841,6 +7821,7 @@ ${content}
|
||||
exports.destroyContext = destroyContext;
|
||||
exports.injectGlobalObject = injectGlobalObject;
|
||||
exports.loadJS = loadJS;
|
||||
exports.markNeedHook = markNeedHook;
|
||||
exports.pixelString2Number = pixelString2Number;
|
||||
exports.registerJSBundle = registerJSBundle;
|
||||
exports.registerPlugin = registerPlugin;
|
||||
|
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