Commit 9da58864 authored by rockyl's avatar rockyl

Merge branch 'mvvm' into res-group

# Conflicts:
#	debug/engine.js.map
#	manifest.json
parents 7c76d13a e746081c
...@@ -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 = ','; }
...@@ -20150,8 +20149,11 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -20150,8 +20149,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]);
...@@ -20167,8 +20169,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -20167,8 +20169,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) {
...@@ -20184,6 +20186,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -20184,6 +20186,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];
...@@ -20191,13 +20194,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: ...@@ -20191,13 +20194,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) || {};
......
module.exports = { module.exports = {
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
id: 'LTAIqO2wblIxQvwc', id: 'LTAI4Fw25WcfcGv7FvcHoiHK',
secret: '4brsaSRbRpjxw3oDIxJi6bNMcndIR6', secret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm',
bucket: 'duiba', bucket: 'duiba',
output: '/editor/zeroing/libs' output: '/editor/zeroing/libs'
}; };
...@@ -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;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* 过程 * 过程
*/ */
import {VM} from "./VM"; import {VM} from "./VM";
import {getDataByPath, linkedFlag, linkScheme, nodeScheme, objClone} from "../utils"; import {getDataByPath, linkScheme, nodeScheme, objClone} from "../utils/index";
import {dataCenter} from "../game-warpper/data-center"; import {dataCenter} from "../game-warpper/data-center";
import {env} from "../game-warpper/enviroment"; import {env} from "../game-warpper/enviroment";
import {getLogSwitch, Logs} from "../log-switch"; import {getLogSwitch, Logs} from "../log-switch";
...@@ -241,7 +241,7 @@ export class Process { ...@@ -241,7 +241,7 @@ export class Process {
props[key] = nameValue !== undefined ? nameValue : dataCenter.getDataByPath(name); props[key] = nameValue !== undefined ? nameValue : dataCenter.getDataByPath(name);
break; break;
case 'env': case 'env':
props[key] = env[name]; props[key] = getDataByPath(env, name);
break; break;
case 'map': case 'map':
this.updateProps(props[key] = {}, args, name, name); this.updateProps(props[key] = {}, args, name, name);
......
...@@ -84,7 +84,7 @@ export class DataCenter extends EventDispatcher { ...@@ -84,7 +84,7 @@ export class DataCenter extends EventDispatcher {
let name = args[0]; let name = args[0];
let dataMapping = this.getDataMapping(name); let dataMapping = this.getDataMapping(name);
try { try {
let data: any = this.getDataByPath(dataMapping.path, undefined, true); let data: any = this.getDataByPath(dataMapping.path, undefined, false);
if (args[1] !== undefined) { if (args[1] !== undefined) {
data = data[args[1]]; data = data[args[1]];
} }
......
...@@ -199,6 +199,7 @@ export const commands: { [name: string]: Command } = { ...@@ -199,6 +199,7 @@ export const commands: { [name: string]: Command } = {
parent.addChild(newNode); parent.addChild(newNode);
// 生成子域 // 生成子域
let newScope: any = Object.create(forScope); let newScope: any = Object.create(forScope);
// 这里一定要用defineProperty将目标定义在当前节点上,否则会影响forScope // 这里一定要用defineProperty将目标定义在当前节点上,否则会影响forScope
Object.defineProperty(newScope, "$index", { Object.defineProperty(newScope, "$index", {
configurable: true, configurable: true,
...@@ -236,6 +237,13 @@ export const commands: { [name: string]: Command } = { ...@@ -236,6 +237,13 @@ export const commands: { [name: string]: Command } = {
value: (isArray ? curList[curIndex] : curList[curIndex].value), value: (isArray ? curList[curIndex] : curList[curIndex].value),
writable: false writable: false
}); });
// 把单项数据注入到显示对象上
Object.defineProperty(newNode, "$data", {
configurable: true,
enumerable: false,
value: (isArray ? curList[curIndex] : curList[curIndex].value),
writable: false
});
// 开始编译新节点 // 开始编译新节点
context.compiler.compile(newNode, newScope); context.compiler.compile(newNode, newScope);
// 赋值上一个节点 // 赋值上一个节点
......
...@@ -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