igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
216 lines (215 loc) • 8.15 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { CodeGeneratingComponentRendererModuleEmitter } from "./CodeGeneratingComponentRendererModuleEmitter";
import { CodeGenerationTargetPlatforms_$type } from "./CodeGenerationTargetPlatforms";
import { Dictionary$2 } from "./Dictionary$2";
import { List$1 } from "./List$1";
import { HashSet$1 } from "./HashSet$1";
import { String_$type, EnumUtil, fromEnum, markType } from "./type";
import { stringReplace, stringEndsWith } from "./string";
/**
* @hidden
*/
var TSCodeGeneratingComponentRendererModuleEmitter = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(TSCodeGeneratingComponentRendererModuleEmitter, _super);
function TSCodeGeneratingComponentRendererModuleEmitter(a, b, c) {
var _this = _super.call(this, b, c) || this;
_this.q = 0;
_this.v = 0;
_this.r = false;
_this.t = new Dictionary$2(String_$type, List$1.$.specialize(String_$type), 0);
_this.u = new HashSet$1(String_$type, 0);
_this.s = false;
_this.q = a;
return _this;
}
TSCodeGeneratingComponentRendererModuleEmitter.prototype.p = function () {
_super.prototype.p.call(this);
this.v = 0;
};
Object.defineProperty(TSCodeGeneratingComponentRendererModuleEmitter.prototype, "x", {
get: function () {
switch (this.q) {
case 1: return "Igx";
case 2: return "Igr";
case 3: return "Igc";
}
return "";
},
enumerable: false,
configurable: true
});
Object.defineProperty(TSCodeGeneratingComponentRendererModuleEmitter.prototype, "w", {
get: function () {
switch (this.q) {
case 1: return "angular";
case 2: return "react";
case 3: return "webcomponents";
}
return "";
},
enumerable: false,
configurable: true
});
TSCodeGeneratingComponentRendererModuleEmitter.prototype.m = function (a, b, c) {
_super.prototype.m.call(this, a, b, c);
if (b == "withDescriptions") {
this.r = true;
return;
}
var d = "igniteui-" + this.w + "-core";
var e = "";
var f = b.split('/');
if (f.length == 1) {
e = f[0];
this.j.addPackageRef(e);
}
else {
d = f[0];
this.j.addPackageRef(d);
if (d == "webinputs") {
d = "igniteui-" + this.w;
}
else {
if (d == "webgrids") {
d = "grids";
}
d = "igniteui-" + this.w + "-" + d;
}
e = f[1];
}
var g = false;
var h = null;
var i = stringReplace(e, "Module", "");
if (c) {
i = "Web" + i;
}
if (a.getMetadata(i, "__skipModuleRegister" + EnumUtil.getName(CodeGenerationTargetPlatforms_$type, this.q)) != null) {
g = true;
}
if (a.getMetadata(i, "__importOverride" + EnumUtil.getName(CodeGenerationTargetPlatforms_$type, this.q)) != null) {
h = a.getMetadata(i, "__importOverride" + EnumUtil.getName(CodeGenerationTargetPlatforms_$type, this.q)).specificExternalType;
}
if (h != null) {
if (!this.u.contains(h)) {
this.u.add_1(h);
}
}
else {
if (!this.t.containsKey(d)) {
this.t.addItem(d, new List$1(String_$type, 0));
}
}
if (this.v > 0 && !g) {
this.d.l(",");
}
if (!g) {
this.d.j(this.x + e);
this.v++;
}
if (h == null && !g) {
var j = this.t.item(d);
j.add(this.x + e);
}
if (this.r) {
if (!this.s) {
this.s = true;
this.c.l("private _componentRenderer: ComponentRenderer = null;");
this.c.l("public get renderer(): ComponentRenderer {");
this.c.h();
this.c.l("if (this._componentRenderer == null) {");
this.c.h();
this.c.l("this._componentRenderer = new ComponentRenderer();");
this.c.l("var context = this._componentRenderer.context;");
this.g.addPackageImport("igniteui-" + this.w + "-core", "ComponentRenderer");
}
var k = e;
if (stringEndsWith(k, "Module")) {
k = k.substr(0, k.length - ("Module").length);
k += "DescriptionModule";
}
if (c) {
k = "Web" + k;
}
this.g.addPackageImport("igniteui-" + this.w + "-core", k);
this.c.l(k + ".register(context);");
}
};
TSCodeGeneratingComponentRendererModuleEmitter.prototype.o = function () {
var e_1, _a, e_2, _b, e_3, _c;
_super.prototype.o.call(this);
try {
for (var _d = __values(fromEnum(this.t.keys)), _e = _d.next(); !_e.done; _e = _d.next()) {
var a = _e.value;
var b = a;
var c = this.t.item(a);
try {
for (var _f = (e_2 = void 0, __values(fromEnum(c))), _g = _f.next(); !_g.done; _g = _f.next()) {
var d = _g.value;
this.h.addPackageImport(b, d);
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_g && !_g.done && (_b = _f.return))
_b.call(_f);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_e && !_e.done && (_a = _d.return))
_a.call(_d);
}
finally {
if (e_1)
throw e_1.error;
}
}
try {
for (var _h = __values(fromEnum(this.u)), _j = _h.next(); !_j.done; _j = _h.next()) {
var e = _j.value;
this.h.addDefaultImport(e, "@SELF@");
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_j && !_j.done && (_c = _h.return))
_c.call(_h);
}
finally {
if (e_3)
throw e_3.error;
}
}
if (this.r) {
this.c.f();
this.c.l("}");
this.c.l("return this._componentRenderer;");
this.c.f();
this.c.l("}");
}
};
TSCodeGeneratingComponentRendererModuleEmitter.$t = markType(TSCodeGeneratingComponentRendererModuleEmitter, 'TSCodeGeneratingComponentRendererModuleEmitter', CodeGeneratingComponentRendererModuleEmitter.$);
return TSCodeGeneratingComponentRendererModuleEmitter;
}(CodeGeneratingComponentRendererModuleEmitter));
export { TSCodeGeneratingComponentRendererModuleEmitter };