1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | extendStatics(d, b);
|
11 | function __() { this.constructor = d; }
|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13 | };
|
14 | })();
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | exports.getLayoutByName = exports.unRegisterLayout = exports.registerLayout = void 0;
|
17 | var base_1 = require("../layout/base");
|
18 | var util_1 = require("../util");
|
19 | var map = new Map();
|
20 | var registerLayout = function (name, layoutOverride) {
|
21 | if (map.get(name)) {
|
22 | throw new Error("The layout with the name " + name + " exists already");
|
23 | }
|
24 | if (util_1.isObject(layoutOverride)) {
|
25 |
|
26 | var GLayout = (function (_super) {
|
27 | __extends(GLayout, _super);
|
28 | function GLayout(cfg) {
|
29 | var _this = _super.call(this) || this;
|
30 | var self = _this;
|
31 | var props = {};
|
32 | var defaultCfg = self.getDefaultCfg();
|
33 | Object.assign(props, defaultCfg, layoutOverride, cfg);
|
34 | Object.keys(props).forEach(function (key) {
|
35 | var value = props[key];
|
36 | self[key] = value;
|
37 | });
|
38 | return _this;
|
39 | }
|
40 | return GLayout;
|
41 | }(base_1.Base));
|
42 | map.set(name, GLayout);
|
43 | }
|
44 | else {
|
45 | map.set(name, layoutOverride);
|
46 | }
|
47 | };
|
48 | exports.registerLayout = registerLayout;
|
49 | var unRegisterLayout = function (name) {
|
50 | if (map.has(name)) {
|
51 | map.delete(name);
|
52 | }
|
53 | };
|
54 | exports.unRegisterLayout = unRegisterLayout;
|
55 | var getLayoutByName = function (name) {
|
56 | if (map.has(name)) {
|
57 | return map.get(name);
|
58 | }
|
59 | return null;
|
60 | };
|
61 | exports.getLayoutByName = getLayoutByName;
|
62 |
|
\ | No newline at end of file |