Commit ab3b0784 authored by rockyl's avatar rockyl

优化mvvm编译

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