web-atoms-core
Version:
179 lines • 6.92 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RootObject = /** @class */ (function () {
function RootObject() {
}
Object.defineProperty(RootObject.prototype, "vsProps", {
get: function () {
return undefined;
},
enumerable: true,
configurable: true
});
return RootObject;
}());
exports.RootObject = RootObject;
var XNode = /** @class */ (function () {
function XNode(
// tslint:disable-next-line: ban-types
name, attributes, children, isProperty, isTemplate) {
this.name = name;
this.attributes = attributes;
this.children = children;
this.isProperty = isProperty;
this.isTemplate = isTemplate;
}
XNode.attach = function (n, tag) {
return {
factory: function (attributes) {
var nodes = [];
for (var _i = 1; _i < arguments.length; _i++) {
nodes[_i - 1] = arguments[_i];
}
return new XNode(n, attributes
? __assign(__assign({}, attributes), { for: tag }) : { for: tag }, nodes);
}
};
};
XNode.prepare = function (n, isProperty, isTemplate) {
return {
factory: function (a) {
var nodes = [];
for (var _i = 1; _i < arguments.length; _i++) {
nodes[_i - 1] = arguments[_i];
}
return new XNode(n, a, nodes, isProperty, isTemplate);
},
toString: function () {
return n;
}
};
};
XNode.template = function () {
return {
factory: true,
isTemplate: true,
};
};
/**
* This is only for intellisense...
*/
XNode.attached = function () {
return {
attached: true
};
};
XNode.property = function () {
return {
factory: true
};
};
/**
* Declares Root Namespace and Assembly. You can use return function to
* to declare the type
* @param ns Root Namespace
*/
XNode.namespace = function (ns, assemblyName) {
return function (type, isTemplate) {
return function (c) {
var _loop_1 = function (key) {
if (c.hasOwnProperty(key)) {
var element_1 = c[key];
if (element_1) {
var n_1 = ns + "." + type + ":" + key + ";" + assemblyName;
var af = function (a) {
var _a;
var r = (_a = {},
_a[n_1] = a,
_a);
Object.defineProperty(r, "toString", {
value: function () { return n_1; },
enumerable: false,
configurable: false
});
return r;
};
af.factory = function (a) {
var nodes = [];
for (var _i = 1; _i < arguments.length; _i++) {
nodes[_i - 1] = arguments[_i];
}
return new XNode(n_1, a, nodes, true, element_1.isTemplate);
};
af.toString = function () { return n_1; };
c[key] = af;
}
}
};
for (var key in c) {
_loop_1(key);
}
var tn = ns + "." + type + ";" + assemblyName;
c.factory = function (a) {
var nodes = [];
for (var _i = 1; _i < arguments.length; _i++) {
nodes[_i - 1] = arguments[_i];
}
return new XNode(tn, a, nodes, false, isTemplate);
};
c.toString = function () { return tn; };
};
};
};
XNode.create = function (
// tslint:disable-next-line: ban-types
name, attributes) {
var _a;
var children = [];
for (var _i = 2; _i < arguments.length; _i++) {
children[_i - 2] = arguments[_i];
}
if (name.factory) {
return (_a = name).factory.apply(_a, __spreadArrays([attributes], children));
}
if (name.isControl) {
return new XNode(name, attributes, children);
}
if (typeof name === "object") {
name = name.toString();
}
return new XNode(name, attributes, children);
};
XNode.prototype.toString = function () {
if (typeof this.name === "string") {
return "name is of type string and value is " + this.name;
}
return "name is of type " + typeof this.name;
};
return XNode;
}());
exports.default = XNode;
});
//# sourceMappingURL=XNode.js.map