feat:fix dirty props cannot be rendered in promise
This commit is contained in:
parent
aa56fd93d9
commit
936bd60293
@ -198,11 +198,13 @@ - (BOOL)interceptType:(NSString *)type command:(NSString *)cmd payload:(NSDictio
|
|||||||
} @finally {
|
} @finally {
|
||||||
DoricLog(@"Unlock:%@", payload);
|
DoricLog(@"Unlock:%@", payload);
|
||||||
dispatch_semaphore_t semaphore = self.semaphores[callId];
|
dispatch_semaphore_t semaphore = self.semaphores[callId];
|
||||||
|
if (semaphore) {
|
||||||
[self.semaphores removeObjectForKey:callId];
|
[self.semaphores removeObjectForKey:callId];
|
||||||
DC_UNLOCK(semaphore);
|
DC_UNLOCK(semaphore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,6 +1324,9 @@ var doric = (function (exports) {
|
|||||||
}());
|
}());
|
||||||
var gContexts = new Map;
|
var gContexts = new Map;
|
||||||
var gModules = new Map;
|
var gModules = new Map;
|
||||||
|
function allContexts() {
|
||||||
|
return gContexts.values();
|
||||||
|
}
|
||||||
function jsObtainContext(id) {
|
function jsObtainContext(id) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
var context_1 = gContexts.get(id);
|
var context_1 = gContexts.get(id);
|
||||||
@ -13763,6 +13766,7 @@ var doric = (function (exports) {
|
|||||||
exports.Context = Context;
|
exports.Context = Context;
|
||||||
exports.__moduleExports = coreJs;
|
exports.__moduleExports = coreJs;
|
||||||
exports.__require__ = __require__;
|
exports.__require__ = __require__;
|
||||||
|
exports.allContexts = allContexts;
|
||||||
exports.jsCallEntityMethod = jsCallEntityMethod;
|
exports.jsCallEntityMethod = jsCallEntityMethod;
|
||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
|
@ -1325,6 +1325,9 @@ var doric = (function (exports) {
|
|||||||
}
|
}
|
||||||
const gContexts = new Map;
|
const gContexts = new Map;
|
||||||
const gModules = new Map;
|
const gModules = new Map;
|
||||||
|
function allContexts() {
|
||||||
|
return gContexts.values();
|
||||||
|
}
|
||||||
function jsObtainContext(id) {
|
function jsObtainContext(id) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id);
|
const context = gContexts.get(id);
|
||||||
@ -1526,6 +1529,7 @@ var doric = (function (exports) {
|
|||||||
|
|
||||||
exports.Context = Context;
|
exports.Context = Context;
|
||||||
exports.__require__ = __require__;
|
exports.__require__ = __require__;
|
||||||
|
exports.allContexts = allContexts;
|
||||||
exports.jsCallEntityMethod = jsCallEntityMethod;
|
exports.jsCallEntityMethod = jsCallEntityMethod;
|
||||||
exports.jsCallReject = jsCallReject;
|
exports.jsCallReject = jsCallReject;
|
||||||
exports.jsCallResolve = jsCallResolve;
|
exports.jsCallResolve = jsCallResolve;
|
||||||
|
@ -1354,6 +1354,9 @@ class Context {
|
|||||||
}
|
}
|
||||||
const gContexts = new Map;
|
const gContexts = new Map;
|
||||||
const gModules = new Map;
|
const gModules = new Map;
|
||||||
|
function allContexts() {
|
||||||
|
return gContexts.values();
|
||||||
|
}
|
||||||
function jsObtainContext(id) {
|
function jsObtainContext(id) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id);
|
const context = gContexts.get(id);
|
||||||
@ -1558,6 +1561,7 @@ var doric = /*#__PURE__*/Object.freeze({
|
|||||||
jsCallResolve: jsCallResolve,
|
jsCallResolve: jsCallResolve,
|
||||||
jsCallReject: jsCallReject,
|
jsCallReject: jsCallReject,
|
||||||
Context: Context,
|
Context: Context,
|
||||||
|
allContexts: allContexts,
|
||||||
jsObtainContext: jsObtainContext,
|
jsObtainContext: jsObtainContext,
|
||||||
jsReleaseContext: jsReleaseContext,
|
jsReleaseContext: jsReleaseContext,
|
||||||
__require__: __require__,
|
__require__: __require__,
|
||||||
@ -4235,6 +4239,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|||||||
};
|
};
|
||||||
let contextId = undefined;
|
let contextId = undefined;
|
||||||
let global$1 = new Function('return this')();
|
let global$1 = new Function('return this')();
|
||||||
|
const originSetTimeout = global$1.setTimeout;
|
||||||
global$1.setTimeout = global$1.doricSetTimeout;
|
global$1.setTimeout = global$1.doricSetTimeout;
|
||||||
global$1.setInterval = global$1.doricSetInterval;
|
global$1.setInterval = global$1.doricSetInterval;
|
||||||
global$1.clearTimeout = global$1.doricClearTimeout;
|
global$1.clearTimeout = global$1.doricClearTimeout;
|
||||||
@ -4287,10 +4292,16 @@ function initNativeEnvironment(source) {
|
|||||||
else if (type === 5) {
|
else if (type === 5) {
|
||||||
arg = JSON.parse(value);
|
arg = JSON.parse(value);
|
||||||
}
|
}
|
||||||
|
if (payload.name === "Environment") {
|
||||||
|
arg.debugging = true;
|
||||||
|
}
|
||||||
Reflect.set(global$1, payload.name, arg);
|
Reflect.set(global$1, payload.name, arg);
|
||||||
break;
|
break;
|
||||||
case "injectGlobalJSFunction":
|
case "injectGlobalJSFunction":
|
||||||
console.log("injectGlobalJSFunction", payload);
|
console.log("injectGlobalJSFunction", payload);
|
||||||
|
if (payload.name === "nativeEmpty") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
Reflect.set(global$1, payload.name, function () {
|
Reflect.set(global$1, payload.name, function () {
|
||||||
let args = [].slice.call(arguments);
|
let args = [].slice.call(arguments);
|
||||||
console.log(args);
|
console.log(args);
|
||||||
@ -4433,6 +4444,30 @@ global$1.Envrionment = new Proxy({}, {
|
|||||||
return Reflect.set(target, p, v, receiver);
|
return Reflect.set(target, p, v, receiver);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
global$1.nativeEmpty = () => {
|
||||||
|
originSetTimeout(() => {
|
||||||
|
for (let context of allContexts()) {
|
||||||
|
const entity = context.entity;
|
||||||
|
if (entity instanceof Panel) {
|
||||||
|
const panel = entity;
|
||||||
|
if (panel.getRootView().isDirty()) {
|
||||||
|
const model = panel.getRootView().toModel();
|
||||||
|
context.callNative("shader", "render", model);
|
||||||
|
panel.getRootView().clean();
|
||||||
|
}
|
||||||
|
for (let map of panel.allHeadViews()) {
|
||||||
|
for (let v of map.values()) {
|
||||||
|
if (v.isDirty()) {
|
||||||
|
const model = v.toModel();
|
||||||
|
context.callNative("shader", "render", model);
|
||||||
|
v.clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
exports.AnimationSet = AnimationSet;
|
exports.AnimationSet = AnimationSet;
|
||||||
exports.BOTTOM = BOTTOM;
|
exports.BOTTOM = BOTTOM;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import * as doric from './src/runtime/sandbox'
|
import * as doric from './src/runtime/sandbox'
|
||||||
import WebSocket from "ws"
|
import WebSocket from "ws"
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { Panel } from './src/ui/panel';
|
||||||
|
|
||||||
type MSG = {
|
type MSG = {
|
||||||
type: "D2C" | "C2D" | "C2S" | "D2S" | "S2C" | "S2D",
|
type: "D2C" | "C2D" | "C2S" | "D2S" | "S2C" | "S2D",
|
||||||
@ -26,6 +27,7 @@ type MSG = {
|
|||||||
let contextId: string | undefined = undefined;
|
let contextId: string | undefined = undefined;
|
||||||
|
|
||||||
let global = new Function('return this')()
|
let global = new Function('return this')()
|
||||||
|
const originSetTimeout = global.setTimeout
|
||||||
global.setTimeout = global.doricSetTimeout
|
global.setTimeout = global.doricSetTimeout
|
||||||
global.setInterval = global.doricSetInterval
|
global.setInterval = global.doricSetInterval
|
||||||
global.clearTimeout = global.doricClearTimeout
|
global.clearTimeout = global.doricClearTimeout
|
||||||
@ -73,10 +75,16 @@ async function initNativeEnvironment(source: string) {
|
|||||||
} else if (type === 5) {
|
} else if (type === 5) {
|
||||||
arg = JSON.parse(value)
|
arg = JSON.parse(value)
|
||||||
}
|
}
|
||||||
|
if (payload.name === "Environment") {
|
||||||
|
(arg as any).debugging = true
|
||||||
|
}
|
||||||
Reflect.set(global, payload.name as string, arg)
|
Reflect.set(global, payload.name as string, arg)
|
||||||
break
|
break
|
||||||
case "injectGlobalJSFunction":
|
case "injectGlobalJSFunction":
|
||||||
console.log("injectGlobalJSFunction", payload);
|
console.log("injectGlobalJSFunction", payload);
|
||||||
|
if (payload.name === "nativeEmpty") {
|
||||||
|
break
|
||||||
|
}
|
||||||
Reflect.set(global, payload.name as string, function () {
|
Reflect.set(global, payload.name as string, function () {
|
||||||
let args = [].slice.call(arguments)
|
let args = [].slice.call(arguments)
|
||||||
console.log(args)
|
console.log(args)
|
||||||
@ -222,4 +230,30 @@ global.Envrionment = new Proxy({}, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
global.nativeEmpty = () => {
|
||||||
|
originSetTimeout(() => {
|
||||||
|
for (let context of doric.allContexts()) {
|
||||||
|
const entity = context.entity
|
||||||
|
if (entity instanceof Panel) {
|
||||||
|
const panel = entity as Panel
|
||||||
|
if (panel.getRootView().isDirty()) {
|
||||||
|
const model = panel.getRootView().toModel()
|
||||||
|
context.callNative("shader", "render", model)
|
||||||
|
panel.getRootView().clean()
|
||||||
|
}
|
||||||
|
for (let map of panel.allHeadViews()) {
|
||||||
|
for (let v of map.values()) {
|
||||||
|
if (v.isDirty()) {
|
||||||
|
const model = v.toModel()
|
||||||
|
context.callNative("shader", "render", model)
|
||||||
|
v.clean()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
|
||||||
export * from './index'
|
export * from './index'
|
@ -25,8 +25,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
import * as doric from './src/runtime/sandbox';
|
import * as doric from './src/runtime/sandbox';
|
||||||
import WebSocket from "ws";
|
import WebSocket from "ws";
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { Panel } from './src/ui/panel';
|
||||||
let contextId = undefined;
|
let contextId = undefined;
|
||||||
let global = new Function('return this')();
|
let global = new Function('return this')();
|
||||||
|
const originSetTimeout = global.setTimeout;
|
||||||
global.setTimeout = global.doricSetTimeout;
|
global.setTimeout = global.doricSetTimeout;
|
||||||
global.setInterval = global.doricSetInterval;
|
global.setInterval = global.doricSetInterval;
|
||||||
global.clearTimeout = global.doricClearTimeout;
|
global.clearTimeout = global.doricClearTimeout;
|
||||||
@ -79,10 +81,16 @@ function initNativeEnvironment(source) {
|
|||||||
else if (type === 5) {
|
else if (type === 5) {
|
||||||
arg = JSON.parse(value);
|
arg = JSON.parse(value);
|
||||||
}
|
}
|
||||||
|
if (payload.name === "Environment") {
|
||||||
|
arg.debugging = true;
|
||||||
|
}
|
||||||
Reflect.set(global, payload.name, arg);
|
Reflect.set(global, payload.name, arg);
|
||||||
break;
|
break;
|
||||||
case "injectGlobalJSFunction":
|
case "injectGlobalJSFunction":
|
||||||
console.log("injectGlobalJSFunction", payload);
|
console.log("injectGlobalJSFunction", payload);
|
||||||
|
if (payload.name === "nativeEmpty") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
Reflect.set(global, payload.name, function () {
|
Reflect.set(global, payload.name, function () {
|
||||||
let args = [].slice.call(arguments);
|
let args = [].slice.call(arguments);
|
||||||
console.log(args);
|
console.log(args);
|
||||||
@ -225,4 +233,28 @@ global.Envrionment = new Proxy({}, {
|
|||||||
return Reflect.set(target, p, v, receiver);
|
return Reflect.set(target, p, v, receiver);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
global.nativeEmpty = () => {
|
||||||
|
originSetTimeout(() => {
|
||||||
|
for (let context of doric.allContexts()) {
|
||||||
|
const entity = context.entity;
|
||||||
|
if (entity instanceof Panel) {
|
||||||
|
const panel = entity;
|
||||||
|
if (panel.getRootView().isDirty()) {
|
||||||
|
const model = panel.getRootView().toModel();
|
||||||
|
context.callNative("shader", "render", model);
|
||||||
|
panel.getRootView().clean();
|
||||||
|
}
|
||||||
|
for (let map of panel.allHeadViews()) {
|
||||||
|
for (let v of map.values()) {
|
||||||
|
if (v.isDirty()) {
|
||||||
|
const model = v.toModel();
|
||||||
|
context.callNative("shader", "render", model);
|
||||||
|
v.clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
export * from './index';
|
export * from './index';
|
||||||
|
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@ -17,6 +17,7 @@ export declare class Context {
|
|||||||
function2Id(func: Function): string;
|
function2Id(func: Function): string;
|
||||||
removeFuncById(funcId: string): void;
|
removeFuncById(funcId: string): void;
|
||||||
}
|
}
|
||||||
|
export declare function allContexts(): IterableIterator<Context>;
|
||||||
export declare function jsObtainContext(id: string): Context | undefined;
|
export declare function jsObtainContext(id: string): Context | undefined;
|
||||||
export declare function jsReleaseContext(id: string): void;
|
export declare function jsReleaseContext(id: string): void;
|
||||||
export declare function __require__(name: string): any;
|
export declare function __require__(name: string): any;
|
||||||
|
@ -143,6 +143,9 @@ export class Context {
|
|||||||
}
|
}
|
||||||
const gContexts = new Map;
|
const gContexts = new Map;
|
||||||
const gModules = new Map;
|
const gModules = new Map;
|
||||||
|
export function allContexts() {
|
||||||
|
return gContexts.values();
|
||||||
|
}
|
||||||
export function jsObtainContext(id) {
|
export function jsObtainContext(id) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id);
|
const context = gContexts.get(id);
|
||||||
|
@ -165,6 +165,9 @@ export class Context {
|
|||||||
const gContexts: Map<string, Context> = new Map
|
const gContexts: Map<string, Context> = new Map
|
||||||
const gModules: Map<string, any> = new Map
|
const gModules: Map<string, any> = new Map
|
||||||
|
|
||||||
|
export function allContexts() {
|
||||||
|
return gContexts.values()
|
||||||
|
}
|
||||||
export function jsObtainContext(id: string) {
|
export function jsObtainContext(id: string) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id)
|
const context = gContexts.get(id)
|
||||||
|
@ -203,6 +203,9 @@ export class Context {
|
|||||||
const gContexts: Map<string, Context> = new Map
|
const gContexts: Map<string, Context> = new Map
|
||||||
const gModules: Map<string, any> = new Map
|
const gModules: Map<string, any> = new Map
|
||||||
|
|
||||||
|
export function allContexts() {
|
||||||
|
return gContexts.values()
|
||||||
|
}
|
||||||
export function jsObtainContext(id: string) {
|
export function jsObtainContext(id: string) {
|
||||||
if (gContexts.has(id)) {
|
if (gContexts.has(id)) {
|
||||||
const context = gContexts.get(id)
|
const context = gContexts.get(id)
|
||||||
|
Reference in New Issue
Block a user