1 | import { __decorate } from "tslib";
|
2 | import { singleton } from 'mana-syringe';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | var LayoutRegistry =
|
9 |
|
10 | function () {
|
11 | function LayoutRegistry() {
|
12 | this.registry = new Map();
|
13 | }
|
14 |
|
15 | LayoutRegistry_1 = LayoutRegistry;
|
16 | Object.defineProperty(LayoutRegistry.prototype, "size", {
|
17 | get: function get() {
|
18 | return this.registry.size;
|
19 | },
|
20 | enumerable: false,
|
21 | configurable: true
|
22 | });
|
23 |
|
24 | LayoutRegistry.prototype.hasLayout = function (name) {
|
25 | return this.registry.has(name);
|
26 | };
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | LayoutRegistry.prototype.getLayout = function (name) {
|
35 | if (name === void 0) {
|
36 | name = 'absolute';
|
37 | }
|
38 |
|
39 | if (!this.hasLayout(name)) {
|
40 | throw new Error("invalid layout property: ".concat(name));
|
41 | }
|
42 |
|
43 | return this.registry.get(name);
|
44 | };
|
45 |
|
46 | LayoutRegistry.prototype.updateLayout = function (name, layout) {
|
47 | this.registry.set(name, layout);
|
48 | };
|
49 |
|
50 | LayoutRegistry.prototype.registerLayout = function (name, layout) {
|
51 | if (name === '') {
|
52 | throw new TypeError("layout name cant't be empty");
|
53 | }
|
54 |
|
55 | if (LayoutRegistry_1.reservedLayout.includes(name)) {
|
56 | throw new Error("layout name '".concat(name, "' is a system reserved layout name, please use another name"));
|
57 | }
|
58 |
|
59 | if (this.hasLayout(name)) {
|
60 | throw new Error("layout '".concat(name, "' already exist."));
|
61 | }
|
62 |
|
63 | this.registry.set(name, layout);
|
64 | };
|
65 |
|
66 | LayoutRegistry.prototype.deleteLayout = function (name) {
|
67 | this.registry.delete(name);
|
68 | };
|
69 |
|
70 | var LayoutRegistry_1;
|
71 |
|
72 |
|
73 | LayoutRegistry.reservedLayout = [];
|
74 | LayoutRegistry = LayoutRegistry_1 = __decorate([singleton()], LayoutRegistry);
|
75 | return LayoutRegistry;
|
76 | }();
|
77 |
|
78 | export { LayoutRegistry }; |
\ | No newline at end of file |