@adaas/a-concept 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/examples/simple/components/A.component.d.ts +4 -2
- package/dist/examples/simple/components/A.component.js +7 -4
- package/dist/examples/simple/components/A.component.js.map +1 -1
- package/dist/examples/simple/components/B.component.d.ts +6 -2
- package/dist/examples/simple/components/B.component.js +18 -7
- package/dist/examples/simple/components/B.component.js.map +1 -1
- package/dist/examples/simple/concept.js +59 -32
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.d.ts +2 -3
- package/dist/examples/simple/containers/Main.container.js +28 -8
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js +3 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +1 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.container.d.ts +1 -3
- package/dist/src/base/A-Config/A-Config.container.js +6 -22
- package/dist/src/base/A-Config/A-Config.container.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.context.d.ts +1 -0
- package/dist/src/base/A-Config/A-Config.context.js +20 -2
- package/dist/src/base/A-Config/A-Config.context.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.types.d.ts +4 -2
- package/dist/src/base/A-Config/A-Config.types.js +4 -0
- package/dist/src/base/A-Config/A-Config.types.js.map +1 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +2 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js +3 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
- package/dist/src/base/A-Errors/A-Errors.component.d.ts +2 -1
- package/dist/src/base/A-Errors/A-Errors.component.js +3 -1
- package/dist/src/base/A-Errors/A-Errors.component.js.map +1 -1
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +4 -2
- package/dist/src/base/A-Logger/A-Logger.component.js +11 -3
- package/dist/src/base/A-Logger/A-Logger.component.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -9
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +0 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +4 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.class.d.ts +28 -1
- package/dist/src/global/A-Component/A-Component.class.js +22 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -1
- package/dist/src/global/A-Component/A-Component.meta.js +26 -0
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +43 -6
- package/dist/src/global/A-Component/A-Component.types.js +5 -0
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
- package/dist/src/global/A-Concept/A_Concept.class.js +1 -2
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +5 -4
- package/dist/src/global/A-Container/A-Container.class.js +13 -24
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -3
- package/dist/src/global/A-Container/A-Container.meta.js +0 -46
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +35 -5
- package/dist/src/global/A-Context/A-Context.class.js +138 -54
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -12
- package/dist/src/global/A-Context/A-Context.types.js +0 -1
- package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -17
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +47 -65
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +73 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +107 -1
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.meta.d.ts +4 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js +8 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +56 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +15 -0
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +11 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +48 -12
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +5 -4
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.js +1 -2
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +80 -1
- package/dist/src/global/A-Meta/A-Meta.class.js +121 -5
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +15 -6
- package/dist/src/global/A-Scope/A-Scope.class.js +61 -17
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/examples/simple/components/A.component.ts +6 -3
- package/examples/simple/components/B.component.ts +19 -6
- package/examples/simple/concept.ts +65 -33
- package/examples/simple/containers/Main.container.ts +36 -9
- package/examples/simple-http-server/components/http-error-handler.component.ts +5 -2
- package/examples/simple-http-server/components/http-request-handler.component.ts +3 -1
- package/index.ts +9 -1
- package/jest.config.ts +0 -4
- package/package.json +1 -1
- package/src/base/A-Config/A-Config.container.ts +5 -8
- package/src/base/A-Config/A-Config.context.ts +10 -2
- package/src/base/A-Config/A-Config.types.ts +8 -3
- package/src/base/A-Config/components/ConfigReader.component.ts +5 -2
- package/src/base/A-Errors/A-Errors.component.ts +3 -2
- package/src/base/A-Logger/A-Logger.component.ts +21 -3
- package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +0 -1
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +15 -10
- package/src/decorators/A-Inject/A-Inject.decorator.ts +13 -12
- package/src/global/A-Component/A-Component.class.ts +56 -1
- package/src/global/A-Component/A-Component.meta.ts +40 -1
- package/src/global/A-Component/A-Component.types.ts +51 -19
- package/src/global/A-Concept/A_Concept.class.ts +2 -2
- package/src/global/A-Container/A-Container.class.ts +22 -39
- package/src/global/A-Container/A-Container.meta.ts +0 -64
- package/src/global/A-Context/A-Context.class.ts +240 -80
- package/src/global/A-Context/A-Context.types.ts +0 -15
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -61
- package/src/global/A-Entity/A-Entity.class.ts +184 -2
- package/src/global/A-Entity/A-Entity.meta.ts +9 -0
- package/src/global/A-Entity/A-Entity.types.ts +75 -0
- package/src/global/A-Feature/A-Feature.class.ts +62 -20
- package/src/global/A-Feature/A-Feature.types.ts +8 -2
- package/src/global/A-Fragment/A-Fragment.class.ts +1 -5
- package/src/global/A-Meta/A-Meta.class.ts +140 -12
- package/src/global/A-Scope/A-Scope.class.ts +101 -31
- package/tsconfig.json +0 -4
- package/src/storage/A_Component.storage.ts +0 -28
- package/src/storage/A_Concept.storage.ts +0 -49
- package/src/storage/A_Container.storage.ts +0 -21
- package/src/storage/A_Inject.storage.ts +0 -30
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//
|
|
2
|
+
//
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
//
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -12,11 +14,34 @@ import { A_Container } from "../A-Container/A-Container.class";
|
|
|
12
14
|
export class A_Meta<
|
|
13
15
|
_StorageItems extends Record<string, any>
|
|
14
16
|
// _StorageItems extends Record<string, Map<string | Symbol, any> | Array<any> | A_TYPES__Dictionary<any>>
|
|
15
|
-
> {
|
|
17
|
+
> implements Iterable<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
16
18
|
|
|
17
19
|
protected meta: Map<keyof _StorageItems, _StorageItems[keyof _StorageItems]> = new Map();
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Method to get the iterator for the meta object
|
|
24
|
+
*
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
[Symbol.iterator](): Iterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
28
|
+
const iterator = this.meta.entries();
|
|
29
|
+
return {
|
|
30
|
+
next: () => iterator.next()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// ===================================================================================================
|
|
37
|
+
// ================================ META OPERATIONS ==================================================
|
|
38
|
+
// ===================================================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Allows to replicate received meta object by replacing internal meta to the received one
|
|
41
|
+
*
|
|
42
|
+
* @param meta
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
20
45
|
from(
|
|
21
46
|
meta: A_Meta<_StorageItems>
|
|
22
47
|
): A_Meta<_StorageItems> {
|
|
@@ -26,11 +51,12 @@ export class A_Meta<
|
|
|
26
51
|
}
|
|
27
52
|
|
|
28
53
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Method to set values in the map
|
|
56
|
+
*
|
|
57
|
+
* @param key
|
|
58
|
+
* @param value
|
|
59
|
+
*/
|
|
34
60
|
set<K extends keyof _StorageItems>(key: K, value: _StorageItems[K]) {
|
|
35
61
|
|
|
36
62
|
const inheritedValue = this.meta.get(key)
|
|
@@ -51,10 +77,112 @@ export class A_Meta<
|
|
|
51
77
|
|
|
52
78
|
}
|
|
53
79
|
|
|
54
|
-
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Method to get values from the map
|
|
84
|
+
*
|
|
85
|
+
* @param key
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
55
88
|
get<K extends keyof _StorageItems>(key: K): _StorageItems[K] | undefined {
|
|
56
89
|
return this.meta.get(key) as _StorageItems[K];
|
|
57
90
|
}
|
|
58
|
-
}
|
|
59
91
|
|
|
60
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Method to delete values from the map
|
|
95
|
+
*
|
|
96
|
+
* @param key
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
delete(key: keyof _StorageItems): boolean {
|
|
100
|
+
return this.meta.delete(key);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* This method is needed to convert the key to a regular expression and cover cases like:
|
|
106
|
+
*
|
|
107
|
+
* simple * e.g. "a*" instead of "a.*"
|
|
108
|
+
*
|
|
109
|
+
* simple ? e.g. "a?" instead of "a."
|
|
110
|
+
*
|
|
111
|
+
* etc.
|
|
112
|
+
*
|
|
113
|
+
* @param key
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
private convertToRegExp(key: string | RegExp): RegExp {
|
|
117
|
+
return key instanceof RegExp
|
|
118
|
+
? key
|
|
119
|
+
: new RegExp(key);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Method to find values in the map by name.
|
|
125
|
+
*
|
|
126
|
+
* Converts the Key in Map to a regular expression and then compares to the name
|
|
127
|
+
*
|
|
128
|
+
* @param name
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
find(name: string) {
|
|
132
|
+
const results: Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> = [];
|
|
133
|
+
for (const [key, value] of this.meta.entries()) {
|
|
134
|
+
if (this.convertToRegExp(name).test(key as string)) {
|
|
135
|
+
results.push([key, value]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return results;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Method to find values in the map by regular expression
|
|
144
|
+
*
|
|
145
|
+
* Compares Map Key to the input regular expression
|
|
146
|
+
*
|
|
147
|
+
* @param regex
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
findByRegex(regex: RegExp): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
151
|
+
const results: Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> = [];
|
|
152
|
+
for (const [key, value] of this.meta.entries()) {
|
|
153
|
+
if (regex.test(String(key))) {
|
|
154
|
+
results.push([key, value]);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return results;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Method to check if the map has a specific key
|
|
163
|
+
*
|
|
164
|
+
* @param key
|
|
165
|
+
* @returns
|
|
166
|
+
*/
|
|
167
|
+
has(key: keyof _StorageItems): boolean {
|
|
168
|
+
return this.meta.has(key);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Method to get the size of the map
|
|
174
|
+
*
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
entries(): IterableIterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
178
|
+
return this.meta.entries();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Method to clear the map
|
|
184
|
+
*/
|
|
185
|
+
clear(): void {
|
|
186
|
+
this.meta.clear();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { A_CommonHelper } from "@adaas/a-utils";
|
|
2
2
|
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "./A-Scope.types";
|
|
3
|
-
import { A_STORAGE__A_Inject_Instructions } from "@adaas/a-concept/storage/A_Inject.storage";
|
|
4
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
5
|
+
import { A_TYPES__ComponentMeta_InjectionParam, A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.types";
|
|
6
|
+
import { A_Component } from "../A-Component/A-Component.class";
|
|
7
|
+
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
*
|
|
@@ -20,8 +23,9 @@ export class A_Scope {
|
|
|
20
23
|
|
|
21
24
|
name: string = '';
|
|
22
25
|
|
|
23
|
-
private _components: WeakMap<
|
|
26
|
+
private _components: WeakMap<typeof A_Component.constructor, any> = new WeakMap();
|
|
24
27
|
private _fragments: WeakMap<typeof A_Fragment.constructor, any> = new WeakMap();
|
|
28
|
+
private _entities: Map<string, A_Entity> = new Map();
|
|
25
29
|
|
|
26
30
|
private parent?: A_Scope;
|
|
27
31
|
|
|
@@ -125,10 +129,10 @@ export class A_Scope {
|
|
|
125
129
|
* @param component
|
|
126
130
|
* @returns
|
|
127
131
|
*/
|
|
128
|
-
resolve<T extends
|
|
129
|
-
resolve<T extends
|
|
132
|
+
resolve<T extends A_TYPES__ComponentMeta_InjectionParam>(component: T): InstanceType<T>
|
|
133
|
+
resolve<T extends A_TYPES__ComponentMeta_InjectionParam>(component: Array<T>): Array<InstanceType<T>>
|
|
130
134
|
// base definition
|
|
131
|
-
resolve<T extends
|
|
135
|
+
resolve<T extends A_TYPES__ComponentMeta_InjectionParam>(
|
|
132
136
|
param1: Array<T> | T,
|
|
133
137
|
param2?: string
|
|
134
138
|
): Array<InstanceType<T>> | InstanceType<T> {
|
|
@@ -150,44 +154,28 @@ export class A_Scope {
|
|
|
150
154
|
|
|
151
155
|
|
|
152
156
|
|
|
153
|
-
|
|
154
|
-
private resolveOnce<T extends { new(...args: any[]): any }>(component: T): InstanceType<T> {
|
|
157
|
+
private resolveOnce<T extends A_TYPES__ComponentMeta_InjectionParam>(component: T): InstanceType<T> {
|
|
155
158
|
switch (true) {
|
|
156
159
|
case A_CommonHelper.isInheritedFrom(component, A_Fragment): {
|
|
157
|
-
return this.resolveFragment(component)
|
|
160
|
+
return this.resolveFragment(component as typeof A_Fragment) as InstanceType<T>;
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
case
|
|
161
|
-
|
|
162
|
-
return this._components.get(component);
|
|
163
|
+
case A_CommonHelper.isInheritedFrom(component, A_Scope): {
|
|
164
|
+
return this.resolveScope(component as typeof A_Scope) as InstanceType<T>;
|
|
163
165
|
}
|
|
164
|
-
case this.components.includes(component) && !this._components.has(component): {
|
|
165
|
-
|
|
166
|
-
const argsMeta = A_STORAGE__A_Inject_Instructions.get(component);
|
|
167
|
-
|
|
168
|
-
let resolvedArgs: Array<any> = [];
|
|
169
|
-
|
|
170
|
-
if (argsMeta)
|
|
171
|
-
resolvedArgs = (argsMeta.get('constructor') || [])
|
|
172
|
-
.map(arg => this.resolve(arg));
|
|
173
|
-
|
|
174
|
-
this._components.set(component, new component());
|
|
175
166
|
|
|
176
|
-
|
|
167
|
+
case A_CommonHelper.isInheritedFrom(component, A_Component): {
|
|
168
|
+
return this.resolveComponent(component as typeof A_Component) as InstanceType<T>;
|
|
177
169
|
}
|
|
178
170
|
|
|
179
|
-
case !this.components.includes(component) && !!this.parent: {
|
|
180
|
-
|
|
181
|
-
return this.parent.resolve(component);
|
|
182
|
-
}
|
|
183
171
|
default:
|
|
184
|
-
throw new Error(`Component ${component
|
|
172
|
+
throw new Error(`Injected Component ${component} not found in the scope`);
|
|
185
173
|
}
|
|
186
174
|
}
|
|
187
175
|
|
|
188
176
|
|
|
189
177
|
|
|
190
|
-
private resolveFragment<T extends
|
|
178
|
+
private resolveFragment<T extends typeof A_Fragment>(fragment: T): InstanceType<T> {
|
|
191
179
|
|
|
192
180
|
if (this._fragments.has(fragment)) {
|
|
193
181
|
return this._fragments.get(fragment);
|
|
@@ -200,9 +188,91 @@ export class A_Scope {
|
|
|
200
188
|
throw new Error(`Fragment ${fragment.name} not found in the scope ${this.name}`);
|
|
201
189
|
}
|
|
202
190
|
|
|
191
|
+
private resolveScope<T extends { new(...args: any[]): A_Scope }>(scope: T): InstanceType<T> {
|
|
192
|
+
|
|
193
|
+
if (A_CommonHelper.isInheritedFrom(scope, this.constructor)) {
|
|
194
|
+
return this as InstanceType<T>;
|
|
195
|
+
} else if (this.parent) {
|
|
196
|
+
return this.parent.resolveScope(scope);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
throw new Error(`Scope ${scope.name} not found in the scope ${this.name}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
private resolveComponent<T extends A_Component>(component: {
|
|
204
|
+
new(...args: any[]): T
|
|
205
|
+
}): T {
|
|
206
|
+
|
|
207
|
+
if (this.components.includes(component) && this._components.has(component))
|
|
208
|
+
return this._components.get(component);
|
|
209
|
+
|
|
210
|
+
else if (this.components.includes(component) && !this._components.has(component)) {
|
|
211
|
+
const componentMeta = A_Context.meta(component)
|
|
212
|
+
|
|
213
|
+
const argsMeta = componentMeta.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
214
|
+
|
|
215
|
+
const resolvedArgs = (argsMeta?.get('constructor') || [])
|
|
216
|
+
.map(arg => this.resolve(arg));
|
|
217
|
+
|
|
218
|
+
const newComponent = new component(...resolvedArgs)
|
|
219
|
+
|
|
220
|
+
this.register(newComponent);
|
|
221
|
+
|
|
222
|
+
return this._components.get(component);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
else if (!this.components.includes(component) && !!this.parent) {
|
|
226
|
+
return this.parent.resolveComponent(component);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
else {
|
|
230
|
+
throw new Error(`Component ${component.name} not found in the scope`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* This method is used to register the component in the scope
|
|
238
|
+
*
|
|
239
|
+
* @param fragment
|
|
240
|
+
*/
|
|
241
|
+
register(fragment: A_Entity): void
|
|
242
|
+
register(fragment: A_Component): void
|
|
243
|
+
register(fragment: A_Fragment): void
|
|
244
|
+
register(
|
|
245
|
+
param1: A_Fragment | A_Component | A_Entity
|
|
246
|
+
): void {
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
switch (true) {
|
|
250
|
+
case param1 instanceof A_Fragment && !this._fragments.has(param1.constructor): {
|
|
251
|
+
this._fragments.set(param1.constructor, param1);
|
|
252
|
+
// The same situation. Have not idea how to fix it
|
|
253
|
+
A_Context.register(this, param1 as any);
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
case param1 instanceof A_Entity && !this._entities.has(param1.aseid.toString()): {
|
|
258
|
+
this._entities.set(param1.aseid.toString(), param1);
|
|
259
|
+
// The same situation. Have not idea how to fix it
|
|
260
|
+
A_Context.register(this, param1 as any);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
case param1 instanceof A_Component: {
|
|
265
|
+
this._components.set(param1.constructor, param1);
|
|
266
|
+
// The same situation. Have not idea how to fix it
|
|
267
|
+
A_Context.register(this, param1 as any);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
default:
|
|
272
|
+
throw new Error('Invalid arguments provided');
|
|
273
|
+
}
|
|
274
|
+
|
|
203
275
|
|
|
204
276
|
|
|
205
|
-
register(fragment: A_Fragment): void {
|
|
206
|
-
this._fragments.set(fragment.constructor, fragment);
|
|
207
277
|
}
|
|
208
278
|
}
|
package/tsconfig.json
CHANGED
|
@@ -35,10 +35,6 @@
|
|
|
35
35
|
"@adaas/a-concept/types/*": ["src/types/*"],
|
|
36
36
|
"@adaas/a-concept/helpers/*": ["src/helpers/*"],
|
|
37
37
|
"@adaas/a-concept/decorators/*": ["src/decorators/*"],
|
|
38
|
-
"@adaas/a-concept/managers/*": ["src/managers/*"],
|
|
39
|
-
"@adaas/a-concept/providers/*": ["src/providers/*"],
|
|
40
|
-
"@adaas/a-concept/modules/*": ["src/modules/*"],
|
|
41
|
-
"@adaas/a-concept/storage/*": ["src/storage/*"],
|
|
42
38
|
"@adaas/a-concept/base/*": ["src/base/*"]
|
|
43
39
|
},
|
|
44
40
|
"lib": [
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// =================================================================================================
|
|
2
|
-
// ========== Component Storage ====================================================================
|
|
3
|
-
// =================================================================================================
|
|
4
|
-
|
|
5
|
-
import { A_Component } from "../global/A-Component/A-Component.class";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// -------------------------------------------------------------------------------
|
|
9
|
-
// ----- A Concept -> Component Declaration -> Symbol Declaration Keys ---------------
|
|
10
|
-
// -------------------------------------------------------------------------------
|
|
11
|
-
export const A_COMPONENT_STORAGE__Definition__Extensions = Symbol('a-container-extensions');
|
|
12
|
-
export const A_COMPONENT_STORAGE__Definition__Feature = Symbol('a-container-feature');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* This storage is used to store the containers metadata, definitions and configurations
|
|
19
|
-
*/
|
|
20
|
-
export const A_COMPONENT_Storage: Map<
|
|
21
|
-
typeof A_Component | { new(...args: any[]): any },
|
|
22
|
-
Map<
|
|
23
|
-
Symbol | string,
|
|
24
|
-
any
|
|
25
|
-
>
|
|
26
|
-
> = new Map();
|
|
27
|
-
|
|
28
|
-
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// --------------------------------------------------------------
|
|
4
|
-
// ----- A Concept -> Module Declaration -> Main Config ---------
|
|
5
|
-
|
|
6
|
-
import { A_Container } from "../global/A-Container/A-Container.class";
|
|
7
|
-
|
|
8
|
-
// --------------------------------------------------------------
|
|
9
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Config = Symbol('a-concept-modules-declaration');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// -------------------------------------------------------------------------------
|
|
14
|
-
// ----- A Concept -> Module Declaration -> Concept Lifecycle Extension_ ---------
|
|
15
|
-
// -------------------------------------------------------------------------------
|
|
16
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootRun = Symbol('a-concept-modules-declaration-lifecycle-root-run');
|
|
17
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootLoad = Symbol('a-concept-modules-declaration-lifecycle-root-load');
|
|
18
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootBuild = Symbol('a-concept-modules-declaration-lifecycle-root-build');
|
|
19
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootPublish = Symbol('a-concept-modules-declaration-lifecycle-root-publish');
|
|
20
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootTest = Symbol('a-concept-modules-declaration-lifecycle-root-test');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Storage to keep the module declarations across all modules
|
|
27
|
-
*/
|
|
28
|
-
export const A_CONCEPT_ModulesDeclarationStorage: WeakMap<
|
|
29
|
-
any,
|
|
30
|
-
Map<string | Symbol, any>
|
|
31
|
-
> = new WeakMap();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Storage to keep the lifecycle declarations across all modules
|
|
37
|
-
*/
|
|
38
|
-
export const A_CONCEPT_LifecycleDeclarationsStorage: Map<Symbol, any> = new Map();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The simplest way to store the decorators
|
|
46
|
-
* If any extra API is needed, it can be added here or replaced with a new class
|
|
47
|
-
*/
|
|
48
|
-
export const A_CONCEPT_Storage = new WeakMap();
|
|
49
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// =================================================================================================
|
|
2
|
-
// ========== Container Storage ====================================================================
|
|
3
|
-
// =================================================================================================
|
|
4
|
-
|
|
5
|
-
import { A_Container } from "../global/A-Container/A-Container.class";
|
|
6
|
-
|
|
7
|
-
// -------------------------------------------------------------------------------
|
|
8
|
-
// ----- A Concept -> Container Declaration -> Symbol Declaration Keys ---------------
|
|
9
|
-
// -------------------------------------------------------------------------------
|
|
10
|
-
export const A_CONTAINER_STORAGE__Definition__Lifecycle = Symbol('a-container-lifecycle');
|
|
11
|
-
export const A_CONTAINER_STORAGE__Definition__Feature = Symbol('a-container-feature');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This storage is used to store the containers metadata, definitions and configurations
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export const A_CONTAINER_Storage: WeakMap<typeof A_Container.constructor, Map<Symbol | string, any>> = new WeakMap();
|
|
20
|
-
|
|
21
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// =================================================================================================
|
|
5
|
-
// ========== A-Inject Storage ====================================================================
|
|
6
|
-
// =================================================================================================
|
|
7
|
-
|
|
8
|
-
import { A_TYPES__A_InjectDecoratorStorageInstruction } from "../decorators/A-Inject/A-Inject.decorator.types";
|
|
9
|
-
|
|
10
|
-
export const A_STORAGE__A_Inject_MethodArgumentsKey = Symbol('a-inject-method-arguments');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This storage is used to store the containers metadata, definitions and configurations
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export const A_STORAGE__A_Inject_Instructions: WeakMap<
|
|
18
|
-
// Any Class
|
|
19
|
-
{ new(...args: any[]): any },
|
|
20
|
-
|
|
21
|
-
// A set of instructions
|
|
22
|
-
Map<
|
|
23
|
-
// Where key is method name
|
|
24
|
-
Symbol | string,
|
|
25
|
-
// And value is Injection instructions
|
|
26
|
-
A_TYPES__A_InjectDecoratorStorageInstruction
|
|
27
|
-
>
|
|
28
|
-
> = new WeakMap();
|
|
29
|
-
|
|
30
|
-
|