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:
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 = ','; }
......@@ -20150,8 +20149,11 @@ 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) {
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]);
......@@ -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++) {
var cmdData = cmdDatas_1[_i];
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0 && target['__originConfig']) {
delete target['__originConfig'].properties[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
delete properties[cmdData.propName];
}
var cmd = commands$1[cmdData.cmdName];
if (!cmd) {
......@@ -20184,6 +20186,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
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];
......@@ -20191,13 +20194,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) || {};
......
module.exports = {
region: 'oss-cn-hangzhou',
id: 'LTAIqO2wblIxQvwc',
secret: '4brsaSRbRpjxw3oDIxJi6bNMcndIR6',
id: 'LTAI4Fw25WcfcGv7FvcHoiHK',
secret: 'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm',
bucket: 'duiba',
output: '/editor/zeroing/libs'
};
......@@ -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 {
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;
}
......
......@@ -4,7 +4,7 @@
* 过程
*/
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 {env} from "../game-warpper/enviroment";
import {getLogSwitch, Logs} from "../log-switch";
......@@ -241,7 +241,7 @@ export class Process {
props[key] = nameValue !== undefined ? nameValue : dataCenter.getDataByPath(name);
break;
case 'env':
props[key] = env[name];
props[key] = getDataByPath(env, name);
break;
case 'map':
this.updateProps(props[key] = {}, args, name, name);
......
......@@ -84,7 +84,7 @@ export class DataCenter extends EventDispatcher {
let name = args[0];
let dataMapping = this.getDataMapping(name);
try {
let data: any = this.getDataByPath(dataMapping.path, undefined, true);
let data: any = this.getDataByPath(dataMapping.path, undefined, false);
if (args[1] !== undefined) {
data = data[args[1]];
}
......
......@@ -199,6 +199,7 @@ export const commands: { [name: string]: Command } = {
parent.addChild(newNode);
// 生成子域
let newScope: any = Object.create(forScope);
// 这里一定要用defineProperty将目标定义在当前节点上,否则会影响forScope
Object.defineProperty(newScope, "$index", {
configurable: true,
......@@ -236,6 +237,13 @@ export const commands: { [name: string]: Command } = {
value: (isArray ? curList[curIndex] : curList[curIndex].value),
writable: false
});
// 把单项数据注入到显示对象上
Object.defineProperty(newNode, "$data", {
configurable: true,
enumerable: false,
value: (isArray ? curList[curIndex] : curList[curIndex].value),
writable: false
});
// 开始编译新节点
context.compiler.compile(newNode, newScope);
// 赋值上一个节点
......
......@@ -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,17 +25,24 @@ 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){
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){
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
needInterrupt = true;
cmdDatas.splice(0, cmdDatas.length - 1);
break;
......@@ -44,8 +51,8 @@ export class ZriCompiler implements Compiler {
}
for (let cmdData of cmdDatas) {
delete target[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0 && target['__originConfig']) {
delete target['__originConfig'].properties[cmdData.propName];
if (interruptCmds.indexOf(cmdData.cmdName) >= 0) {
delete properties[cmdData.propName];
}
let cmd: Command = commands[cmdData.cmdName];
if (!cmd) {
......@@ -61,10 +68,19 @@ export class ZriCompiler implements Compiler {
compiler: this,
})
}
/*if(props.length > 0){
this.props.push(props);
}*/
}
if (!needInterrupt && target.children && target.children.length > 0) {
for (let child of target.children) {
this.compile(child, scope);
}
}
}
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