Commit ab3b0784 authored by rockyl's avatar rockyl

优化mvvm编译

parent 96c534b8
......@@ -2007,7 +2007,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var cmdOldPrefix = '//z-';
function injectProperties(target, source) {
for (var key in source) {
if (!source.hasOwnProperty(cmdPrefix + key)) {
if (key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)) {
propertyParse(key, target, source);
}
}
......@@ -2026,7 +2026,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
}
//# sourceMappingURL=utils.js.map
function transPoint(str, sep) {
if (sep === void 0) { sep = ','; }
......@@ -20147,40 +20146,44 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
ZriCompiler.prototype.compile = function (target, scope) {
var cmdDatas = [];
var needInterrupt = false;
for (var key in target) {
if (key.indexOf(cmdPrefix) < 0) {
continue;
var originConfig = target['__originConfig'];
if (originConfig && originConfig.properties) {
var properties = originConfig.properties;
for (var key in properties) {
if (key.indexOf(cmdPrefix) != 0) {
continue;
}
var cmdData = this._entity.parseCommand(key, target[key]);
if (cmdData) {
cmdDatas.push(cmdData);
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
needInterrupt = true;
cmdDatas.splice(0, cmdDatas.length - 1);
break;
}
}
}
var cmdData = this._entity.parseCommand(key, target[key]);
if (cmdData) {
cmdDatas.push(cmdData);
for (var _i = 0, cmdDatas_1 = cmdDatas; _i < cmdDatas_1.length; _i++) {
var cmdData = cmdDatas_1[_i];
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
needInterrupt = true;
cmdDatas.splice(0, cmdDatas.length - 1);
break;
delete properties[cmdData.propName];
}
var cmd = commands$1[cmdData.cmdName];
if (!cmd) {
cmdData.subCmd = cmdData.cmdName || "";
cmdData.cmdName = "prop";
cmd = commands$1[cmdData.cmdName];
}
cmd({
scope: scope,
target: target,
entity: this._entity,
cmdData: cmdData,
compiler: this,
});
}
}
for (var _i = 0, cmdDatas_1 = cmdDatas; _i < cmdDatas_1.length; _i++) {
var cmdData = cmdDatas_1[_i];
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0 && target['__originConfig']) {
delete target['__originConfig'].properties[cmdData.propName];
}
var cmd = commands$1[cmdData.cmdName];
if (!cmd) {
cmdData.subCmd = cmdData.cmdName || "";
cmdData.cmdName = "prop";
cmd = commands$1[cmdData.cmdName];
}
cmd({
scope: scope,
target: target,
entity: this._entity,
cmdData: cmdData,
compiler: this,
});
}
if (!needInterrupt && target.children && target.children.length > 0) {
for (var _a = 0, _b = target.children; _a < _b.length; _a++) {
var child = _b[_a];
......@@ -20188,13 +20191,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
};
ZriCompiler.prototype.debug = function () {
};
return ZriCompiler;
}());
//# sourceMappingURL=ZriCompiler.js.map
function bind(store, view, options) {
var compiler = new ZriCompiler(view);
return new Zri(store, compiler, options);
var zri = new Zri(store, compiler, options);
compiler.debug();
return zri;
}
function createStore(exp, computed) {
var store = safeEval(exp) || {};
......
This diff is collapsed.
{"id":"engine","url":"engine.a00613f119b951548555b2f0d7ddcd5063975f8e.js"}
\ No newline at end of file
{"id":"engine","url":"engine.3792fc7af6815b498e54518f48fb3d29a80d61f7.js"}
\ No newline at end of file
......@@ -30,7 +30,8 @@
"build:debug": "rm -rf dist&&yarn build && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"ts": "dts-bundle --name engine --main types/src/index.d.ts --out ../../dist/index.d.ts",
"test": "echo \"Error: no test specified\" && exit 1",
"mergeDts": "node scripts/mergeDts.js"
"mergeDts": "node scripts/mergeDts.js",
"token": "uglifyjs -m -c -o px-token.min.js px-token.js"
},
"author": "",
"license": "ISC"
......
......@@ -9,7 +9,17 @@ function getPxToken(callback) {
window.eval(response.data);
callback(null, window['ohjaiohdf']());
} else {
callback('state invalid');
switch(response.code){
case '100001':
callback('need login');
break;
case '100024':
callback('state invalid');
break;
default:
callback(response.code);
break;
}
}
}
};
......
......@@ -743,15 +743,15 @@ export class TextField extends Sprite {
const texture = this._texture;
const baseTexture = texture.baseTexture;
baseTexture.hasLoaded = canvas.width && canvas.height ? true : false;
baseTexture.width = canvas.width
baseTexture.height = canvas.height
baseTexture.width = canvas.width;
baseTexture.height = canvas.height;
//texture,已绑定过尺寸改变onBaseTextureUpdated
baseTexture.dispatchEvent('update');
texture.valid = baseTexture.hasLoaded;
texture._frame.width = canvas.width
texture._frame.width = canvas.width;
texture._frame.height = canvas.height;
texture.orig.width = texture._frame.width
texture.orig.height = texture._frame.height
texture.orig.width = texture._frame.width;
texture.orig.height = texture._frame.height;
}
......
......@@ -2,7 +2,7 @@
* Created by rockyl on 2020-03-19.
*/
import {Compiler, IZri, ZriCommandData} from "./Interfaces";
import {Container, } from "../../../2d/display/index";
import {Container,} from "../../../2d/display/index";
import {Command, commands, CommandContext} from "./ZriCommands";
import {cmdPrefix} from "../../utils/utils";
......@@ -25,41 +25,53 @@ export class ZriCompiler implements Compiler {
this.compile(this._root, entity.data);
}
//props = [];
compile(target: any, scope: any): void {
let cmdDatas = [];
let needInterrupt = false;
for (let key in target) {
if(key.indexOf(cmdPrefix) < 0){
continue;
}
let cmdData = this._entity.parseCommand(key, target[key]);
if (cmdData) {
cmdDatas.push(cmdData);
if(interruptCmds.indexOf(cmdData.cmdName) >= 0){
needInterrupt = true;
cmdDatas.splice(0, cmdDatas.length - 1);
break;
let originConfig = target['__originConfig'];
if (originConfig && originConfig.properties) {
let properties = originConfig.properties;
let props = [];
for (let key in properties) {
if (key.indexOf(cmdPrefix) != 0) {
continue;
}
//props.push(key);
let cmdData = this._entity.parseCommand(key, target[key]);
if (cmdData) {
cmdDatas.push(cmdData);
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
needInterrupt = true;
cmdDatas.splice(0, cmdDatas.length - 1);
break;
}
}
}
}
for (let cmdData of cmdDatas) {
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0 && target['__originConfig']) {
delete target['__originConfig'].properties[cmdData.propName];
}
let cmd: Command = commands[cmdData.cmdName];
if (!cmd) {
cmdData.subCmd = cmdData.cmdName || "";
cmdData.cmdName = "prop";
cmd = commands[cmdData.cmdName];
for (let cmdData of cmdDatas) {
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
delete properties[cmdData.propName];
}
let cmd: Command = commands[cmdData.cmdName];
if (!cmd) {
cmdData.subCmd = cmdData.cmdName || "";
cmdData.cmdName = "prop";
cmd = commands[cmdData.cmdName];
}
cmd({
scope,
target,
entity: this._entity,
cmdData,
compiler: this,
})
}
cmd({
scope,
target,
entity: this._entity,
cmdData,
compiler: this,
})
/*if(props.length > 0){
this.props.push(props);
}*/
}
if (!needInterrupt && target.children && target.children.length > 0) {
for (let child of target.children) {
......@@ -67,4 +79,8 @@ export class ZriCompiler implements Compiler {
}
}
}
debug() {
//console.log(this.props);
}
}
......@@ -17,7 +17,9 @@ import {safeEval} from "../../utils/utils";
*/
export function bind(store: any, view: Container, options?: ZriOptions): IZri {
let compiler = new ZriCompiler(view);
return new Zri(store, compiler, options);
let zri = new Zri(store, compiler, options);
compiler.debug();
return zri;
}
/**
......
......@@ -329,7 +329,7 @@ export const cmdOldPrefix = '//z-';
*/
export function injectProperties(target, source) {
for (let key in source) {
if(!source.hasOwnProperty(cmdPrefix + key)){
if(key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)){
propertyParse(key, target, source);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment