@lcap/asl
Version:
NetEase Application Specific Language
82 lines • 2.54 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Block = void 0;
const decorators_1 = require("../decorators");
const __1 = require("..");
/**
* 区块类
*/
class Block extends __1.Vertex {
/**
* @param source 需要合并的部分参数
*/
constructor(source) {
super();
/**
* 概念类型
*/
this.level = __1.LEVEL_ENUM.block;
/**
* 逻辑相关定义
*/
this.$def = {
logics: [],
params: [],
variables: [],
lifecycles: [],
};
source && this.assign(source);
}
/**
* 从模板解析出 AST
* @param template 模板代码
*/
parseTemplate(template) {
template = template || this.template || '<div></div>';
this.assign({ $html: __1.Element.parse(template) });
}
parseDefinition(definition = this.definition) {
definition = definition || this.definition || '{}';
this.assign({ $def: JSON.parse(definition) });
}
parseAll() {
this.parseTemplate();
this.parseDefinition();
}
}
__decorate([
decorators_1.immutable()
], Block.prototype, "level", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "id", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "name", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "title", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "$html", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "definition", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "$def", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "style", void 0);
__decorate([
decorators_1.immutable()
], Block.prototype, "script", void 0);
exports.Block = Block;
exports.default = Block;
//# sourceMappingURL=Block.js.map