@adaas/a-concept 0.1.24 → 0.1.25

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.
Files changed (227) hide show
  1. package/dist/index.cjs +3 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.mts +3952 -0
  4. package/dist/index.d.ts +3952 -50
  5. package/dist/index.mjs +3 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +5 -6
  8. package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +2 -1
  9. package/src/global/A-Context/A-Context.class.ts +81 -7
  10. package/src/global/A-Context/A-Context.error.ts +4 -0
  11. package/src/global/A-Dependency/A-Dependency-Default.decorator.ts +75 -0
  12. package/src/global/A-Dependency/A-Dependency-Load.decorator.ts +80 -0
  13. package/src/global/A-Dependency/A-Dependency-Require.decorator.ts +68 -0
  14. package/src/global/A-Dependency/A-Dependency.class.ts +33 -0
  15. package/src/global/A-Dependency/A-Dependency.error.ts +13 -0
  16. package/src/global/A-Dependency/A-Dependency.types.ts +28 -0
  17. package/src/global/A-Feature/A-Feature-Define.decorator.ts +2 -1
  18. package/src/global/A-Feature/A-Feature-Extend.decorator.ts +2 -1
  19. package/src/global/A-Feature/A-Feature.class.ts +11 -0
  20. package/src/global/A-Inject/A-Inject.decorator.ts +4 -2
  21. package/src/global/A-Inject/A-Inject.types.ts +5 -3
  22. package/src/global/A-Scope/A-Scope.class.ts +85 -57
  23. package/src/global/A-Stage/A-Stage.class.ts +22 -2
  24. package/src/global/A-Stage/A-Stage.error.ts +2 -0
  25. package/src/helpers/A_Common.helper.ts +101 -0
  26. package/src/helpers/A_TypeGuards.helper.ts +8 -0
  27. package/src/index.ts +88 -0
  28. package/tests/A-Component.test.ts +1 -1
  29. package/tests/A-Concept.test.ts +5 -6
  30. package/tests/A-Dependency.test.ts +93 -0
  31. package/tests/A-Feature.test.ts +7 -7
  32. package/tests/A-Scope.test.ts +10 -10
  33. package/tsconfig.json +2 -2
  34. package/tsup.config.ts +32 -0
  35. package/dist/index.js +0 -112
  36. package/dist/index.js.map +0 -1
  37. package/dist/src/constants/env.constants.d.ts +0 -33
  38. package/dist/src/constants/env.constants.js +0 -47
  39. package/dist/src/constants/env.constants.js.map +0 -1
  40. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -23
  41. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -96
  42. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
  43. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +0 -74
  44. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +0 -130
  45. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +0 -1
  46. package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +0 -7
  47. package/dist/src/global/A-Abstraction/A-Abstraction.error.js +0 -12
  48. package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +0 -1
  49. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +0 -38
  50. package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -3
  51. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +0 -1
  52. package/dist/src/global/A-Caller/A_Caller.class.d.ts +0 -33
  53. package/dist/src/global/A-Caller/A_Caller.class.js +0 -44
  54. package/dist/src/global/A-Caller/A_Caller.class.js.map +0 -1
  55. package/dist/src/global/A-Caller/A_Caller.error.d.ts +0 -7
  56. package/dist/src/global/A-Caller/A_Caller.error.js +0 -12
  57. package/dist/src/global/A-Caller/A_Caller.error.js.map +0 -1
  58. package/dist/src/global/A-Caller/A_Caller.types.d.ts +0 -18
  59. package/dist/src/global/A-Caller/A_Caller.types.js +0 -3
  60. package/dist/src/global/A-Caller/A_Caller.types.js.map +0 -1
  61. package/dist/src/global/A-Component/A-Component.class.d.ts +0 -34
  62. package/dist/src/global/A-Component/A-Component.class.js +0 -56
  63. package/dist/src/global/A-Component/A-Component.class.js.map +0 -1
  64. package/dist/src/global/A-Component/A-Component.constants.d.ts +0 -6
  65. package/dist/src/global/A-Component/A-Component.constants.js +0 -11
  66. package/dist/src/global/A-Component/A-Component.constants.js.map +0 -1
  67. package/dist/src/global/A-Component/A-Component.meta.d.ts +0 -34
  68. package/dist/src/global/A-Component/A-Component.meta.js +0 -78
  69. package/dist/src/global/A-Component/A-Component.meta.js.map +0 -1
  70. package/dist/src/global/A-Component/A-Component.types.d.ts +0 -76
  71. package/dist/src/global/A-Component/A-Component.types.js +0 -4
  72. package/dist/src/global/A-Component/A-Component.types.js.map +0 -1
  73. package/dist/src/global/A-Concept/A-Concept.class.d.ts +0 -153
  74. package/dist/src/global/A-Concept/A-Concept.class.js +0 -260
  75. package/dist/src/global/A-Concept/A-Concept.class.js.map +0 -1
  76. package/dist/src/global/A-Concept/A-Concept.constants.d.ts +0 -33
  77. package/dist/src/global/A-Concept/A-Concept.constants.js +0 -39
  78. package/dist/src/global/A-Concept/A-Concept.constants.js.map +0 -1
  79. package/dist/src/global/A-Concept/A-Concept.meta.d.ts +0 -6
  80. package/dist/src/global/A-Concept/A-Concept.meta.js +0 -12
  81. package/dist/src/global/A-Concept/A-Concept.meta.js.map +0 -1
  82. package/dist/src/global/A-Concept/A-Concept.types.d.ts +0 -66
  83. package/dist/src/global/A-Concept/A-Concept.types.js +0 -3
  84. package/dist/src/global/A-Concept/A-Concept.types.js.map +0 -1
  85. package/dist/src/global/A-Container/A-Container.class.d.ts +0 -52
  86. package/dist/src/global/A-Container/A-Container.class.js +0 -78
  87. package/dist/src/global/A-Container/A-Container.class.js.map +0 -1
  88. package/dist/src/global/A-Container/A-Container.constants.d.ts +0 -6
  89. package/dist/src/global/A-Container/A-Container.constants.js +0 -11
  90. package/dist/src/global/A-Container/A-Container.constants.js.map +0 -1
  91. package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -35
  92. package/dist/src/global/A-Container/A-Container.meta.js +0 -76
  93. package/dist/src/global/A-Container/A-Container.meta.js.map +0 -1
  94. package/dist/src/global/A-Container/A-Container.types.d.ts +0 -75
  95. package/dist/src/global/A-Container/A-Container.types.js +0 -4
  96. package/dist/src/global/A-Container/A-Container.types.js.map +0 -1
  97. package/dist/src/global/A-Context/A-Context.class.d.ts +0 -361
  98. package/dist/src/global/A-Context/A-Context.class.js +0 -603
  99. package/dist/src/global/A-Context/A-Context.class.js.map +0 -1
  100. package/dist/src/global/A-Context/A-Context.error.d.ts +0 -20
  101. package/dist/src/global/A-Context/A-Context.error.js +0 -25
  102. package/dist/src/global/A-Context/A-Context.error.js.map +0 -1
  103. package/dist/src/global/A-Context/A-Context.types.d.ts +0 -5
  104. package/dist/src/global/A-Context/A-Context.types.js +0 -3
  105. package/dist/src/global/A-Context/A-Context.types.js.map +0 -1
  106. package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -0
  107. package/dist/src/global/A-Dependency/A-DependencyReference.class.js +0 -49
  108. package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +0 -1
  109. package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +0 -0
  110. package/dist/src/global/A-Dependency/A-DependencyReference.types.js +0 -58
  111. package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +0 -1
  112. package/dist/src/global/A-Entity/A-Entity.class.d.ts +0 -214
  113. package/dist/src/global/A-Entity/A-Entity.class.js +0 -282
  114. package/dist/src/global/A-Entity/A-Entity.class.js.map +0 -1
  115. package/dist/src/global/A-Entity/A-Entity.constants.d.ts +0 -11
  116. package/dist/src/global/A-Entity/A-Entity.constants.js +0 -17
  117. package/dist/src/global/A-Entity/A-Entity.constants.js.map +0 -1
  118. package/dist/src/global/A-Entity/A-Entity.error.d.ts +0 -7
  119. package/dist/src/global/A-Entity/A-Entity.error.js +0 -12
  120. package/dist/src/global/A-Entity/A-Entity.error.js.map +0 -1
  121. package/dist/src/global/A-Entity/A-Entity.meta.d.ts +0 -11
  122. package/dist/src/global/A-Entity/A-Entity.meta.js +0 -18
  123. package/dist/src/global/A-Entity/A-Entity.meta.js.map +0 -1
  124. package/dist/src/global/A-Entity/A-Entity.types.d.ts +0 -56
  125. package/dist/src/global/A-Entity/A-Entity.types.js +0 -5
  126. package/dist/src/global/A-Entity/A-Entity.types.js.map +0 -1
  127. package/dist/src/global/A-Error/A_Error.class.d.ts +0 -229
  128. package/dist/src/global/A-Error/A_Error.class.js +0 -296
  129. package/dist/src/global/A-Error/A_Error.class.js.map +0 -1
  130. package/dist/src/global/A-Error/A_Error.constants.d.ts +0 -5
  131. package/dist/src/global/A-Error/A_Error.constants.js +0 -9
  132. package/dist/src/global/A-Error/A_Error.constants.js.map +0 -1
  133. package/dist/src/global/A-Error/A_Error.types.d.ts +0 -93
  134. package/dist/src/global/A-Error/A_Error.types.js +0 -3
  135. package/dist/src/global/A-Error/A_Error.types.js.map +0 -1
  136. package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +0 -15
  137. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +0 -76
  138. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +0 -1
  139. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.d.ts +0 -56
  140. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +0 -128
  141. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
  142. package/dist/src/global/A-Feature/A-Feature.class.d.ts +0 -175
  143. package/dist/src/global/A-Feature/A-Feature.class.js +0 -318
  144. package/dist/src/global/A-Feature/A-Feature.class.js.map +0 -1
  145. package/dist/src/global/A-Feature/A-Feature.error.d.ts +0 -25
  146. package/dist/src/global/A-Feature/A-Feature.error.js +0 -33
  147. package/dist/src/global/A-Feature/A-Feature.error.js.map +0 -1
  148. package/dist/src/global/A-Feature/A-Feature.types.d.ts +0 -334
  149. package/dist/src/global/A-Feature/A-Feature.types.js +0 -26
  150. package/dist/src/global/A-Feature/A-Feature.types.js.map +0 -1
  151. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +0 -36
  152. package/dist/src/global/A-Fragment/A-Fragment.class.js +0 -46
  153. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +0 -1
  154. package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +0 -21
  155. package/dist/src/global/A-Fragment/A-Fragment.types.js +0 -6
  156. package/dist/src/global/A-Fragment/A-Fragment.types.js.map +0 -1
  157. package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +0 -80
  158. package/dist/src/global/A-Inject/A-Inject.decorator.js +0 -49
  159. package/dist/src/global/A-Inject/A-Inject.decorator.js.map +0 -1
  160. package/dist/src/global/A-Inject/A-Inject.error.d.ts +0 -5
  161. package/dist/src/global/A-Inject/A-Inject.error.js +0 -10
  162. package/dist/src/global/A-Inject/A-Inject.error.js.map +0 -1
  163. package/dist/src/global/A-Inject/A-Inject.types.d.ts +0 -42
  164. package/dist/src/global/A-Inject/A-Inject.types.js +0 -3
  165. package/dist/src/global/A-Inject/A-Inject.types.js.map +0 -1
  166. package/dist/src/global/A-Meta/A-Meta.class.d.ts +0 -97
  167. package/dist/src/global/A-Meta/A-Meta.class.js +0 -164
  168. package/dist/src/global/A-Meta/A-Meta.class.js.map +0 -1
  169. package/dist/src/global/A-Meta/A-Meta.types.d.ts +0 -14
  170. package/dist/src/global/A-Meta/A-Meta.types.js +0 -3
  171. package/dist/src/global/A-Meta/A-Meta.types.js.map +0 -1
  172. package/dist/src/global/A-Scope/A-Scope.class.d.ts +0 -466
  173. package/dist/src/global/A-Scope/A-Scope.class.js +0 -791
  174. package/dist/src/global/A-Scope/A-Scope.class.js.map +0 -1
  175. package/dist/src/global/A-Scope/A-Scope.error.d.ts +0 -8
  176. package/dist/src/global/A-Scope/A-Scope.error.js +0 -13
  177. package/dist/src/global/A-Scope/A-Scope.error.js.map +0 -1
  178. package/dist/src/global/A-Scope/A-Scope.types.d.ts +0 -81
  179. package/dist/src/global/A-Scope/A-Scope.types.js +0 -3
  180. package/dist/src/global/A-Scope/A-Scope.types.js.map +0 -1
  181. package/dist/src/global/A-Stage/A-Stage.class.d.ts +0 -112
  182. package/dist/src/global/A-Stage/A-Stage.class.js +0 -240
  183. package/dist/src/global/A-Stage/A-Stage.class.js.map +0 -1
  184. package/dist/src/global/A-Stage/A-Stage.error.d.ts +0 -4
  185. package/dist/src/global/A-Stage/A-Stage.error.js +0 -11
  186. package/dist/src/global/A-Stage/A-Stage.error.js.map +0 -1
  187. package/dist/src/global/A-Stage/A-Stage.types.d.ts +0 -101
  188. package/dist/src/global/A-Stage/A-Stage.types.js +0 -43
  189. package/dist/src/global/A-Stage/A-Stage.types.js.map +0 -1
  190. package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +0 -20
  191. package/dist/src/global/A-StepManager/A-StepManager.class.js +0 -112
  192. package/dist/src/global/A-StepManager/A-StepManager.class.js.map +0 -1
  193. package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +0 -4
  194. package/dist/src/global/A-StepManager/A-StepManager.error.js +0 -9
  195. package/dist/src/global/A-StepManager/A-StepManager.error.js.map +0 -1
  196. package/dist/src/global/ASEID/ASEID.class.d.ts +0 -130
  197. package/dist/src/global/ASEID/ASEID.class.js +0 -167
  198. package/dist/src/global/ASEID/ASEID.class.js.map +0 -1
  199. package/dist/src/global/ASEID/ASEID.constants.d.ts +0 -0
  200. package/dist/src/global/ASEID/ASEID.constants.js +0 -2
  201. package/dist/src/global/ASEID/ASEID.constants.js.map +0 -1
  202. package/dist/src/global/ASEID/ASEID.error.d.ts +0 -5
  203. package/dist/src/global/ASEID/ASEID.error.js +0 -10
  204. package/dist/src/global/ASEID/ASEID.error.js.map +0 -1
  205. package/dist/src/global/ASEID/ASEID.types.d.ts +0 -65
  206. package/dist/src/global/ASEID/ASEID.types.js +0 -5
  207. package/dist/src/global/ASEID/ASEID.types.js.map +0 -1
  208. package/dist/src/helpers/A_Common.helper.d.ts +0 -28
  209. package/dist/src/helpers/A_Common.helper.js +0 -170
  210. package/dist/src/helpers/A_Common.helper.js.map +0 -1
  211. package/dist/src/helpers/A_Formatter.helper.d.ts +0 -35
  212. package/dist/src/helpers/A_Formatter.helper.js +0 -62
  213. package/dist/src/helpers/A_Formatter.helper.js.map +0 -1
  214. package/dist/src/helpers/A_Identity.helper.d.ts +0 -29
  215. package/dist/src/helpers/A_Identity.helper.js +0 -43
  216. package/dist/src/helpers/A_Identity.helper.js.map +0 -1
  217. package/dist/src/helpers/A_TypeGuards.helper.d.ts +0 -207
  218. package/dist/src/helpers/A_TypeGuards.helper.js +0 -296
  219. package/dist/src/helpers/A_TypeGuards.helper.js.map +0 -1
  220. package/dist/src/types/A_Common.types.d.ts +0 -36
  221. package/dist/src/types/A_Common.types.js +0 -3
  222. package/dist/src/types/A_Common.types.js.map +0 -1
  223. package/index.ts +0 -81
  224. package/src/global/A-Dependency/A-DependencyReference.class.ts +0 -61
  225. package/src/global/A-Dependency/A-DependencyReference.types.ts +0 -61
  226. package/trace-require.js +0 -46
  227. package/tsconfig.build.json +0 -58
@@ -1,791 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_Scope = void 0;
4
- const A_Fragment_class_1 = require("../A-Fragment/A-Fragment.class");
5
- const A_Context_class_1 = require("../A-Context/A-Context.class");
6
- const A_Component_class_1 = require("../A-Component/A-Component.class");
7
- const A_Entity_class_1 = require("../A-Entity/A-Entity.class");
8
- const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
9
- const A_Error_class_1 = require("../A-Error/A_Error.class");
10
- const A_Formatter_helper_1 = require("../../helpers/A_Formatter.helper");
11
- const ASEID_class_1 = require("../ASEID/ASEID.class");
12
- const A_Common_helper_1 = require("../../helpers/A_Common.helper");
13
- const A_Scope_error_1 = require("./A-Scope.error");
14
- const A_Component_constants_1 = require("../A-Component/A-Component.constants");
15
- class A_Scope {
16
- // ===========================================================================
17
- // --------------------Readonly Allowed Properties----------------------------
18
- // ===========================================================================
19
- /**
20
- * Returns the name of the scope
21
- */
22
- get name() { return this._name; }
23
- /**
24
- * Returns a list of Constructors for A-Components that are available in the scope
25
- */
26
- get allowedComponents() { return this._allowedComponents; }
27
- /**
28
- * Returns a list of Constructors for A-Entities that are available in the scope
29
- */
30
- get allowedEntities() { return this._allowedEntities; }
31
- /**
32
- * Returns a list of Constructors for A-Fragments that are available in the scope
33
- */
34
- get allowedFragments() { return this._allowedFragments; }
35
- /**
36
- * Returns a list of Constructors for A-Errors that are available in the scope
37
- */
38
- get allowedErrors() { return this._allowedErrors; }
39
- // ===========================================================================
40
- // --------------------Readonly Registered Properties--------------------------
41
- // ===========================================================================
42
- /**
43
- * Returns an Array of entities registered in the scope
44
- *
45
- * [!] One entity per aseid
46
- */
47
- get entities() { return Array.from(this._entities.values()); }
48
- /**
49
- * Returns an Array of fragments registered in the scope
50
- *
51
- * [!] One fragment per scope
52
- */
53
- get fragments() { return Array.from(this._fragments.values()); }
54
- /**
55
- * Returns an Array of components registered in the scope
56
- *
57
- * [!] One component instance per scope
58
- */
59
- get components() { return Array.from(this._components.values()); }
60
- /**
61
- * Returns the parent scope of the current scope
62
- *
63
- * @param setValue
64
- * @returns
65
- */
66
- get parent() {
67
- return this._parent;
68
- }
69
- constructor(param1, param2) {
70
- // ===========================================================================
71
- // --------------------ALLowed Constructors--------------------------------
72
- // ===========================================================================
73
- /**
74
- * A set of allowed components, A set of constructors that are allowed in the scope
75
- *
76
- */
77
- this._allowedComponents = new Set();
78
- /**
79
- * A set of allowed errors, A set of constructors that are allowed in the scope
80
- */
81
- this._allowedErrors = new Set();
82
- /**
83
- * A set of allowed entities, A set of constructors that are allowed in the scope
84
- */
85
- this._allowedEntities = new Set();
86
- /**
87
- * A set of allowed fragments, A set of constructors that are allowed in the scope
88
- */
89
- this._allowedFragments = new Set();
90
- // ===========================================================================
91
- // --------------------Internal Storage--------------------------------
92
- // ===========================================================================
93
- /**
94
- * Storage for the components, should be strong as components are unique per scope
95
- */
96
- this._components = new Map();
97
- /**
98
- * Storage for the errors, should be strong as errors are unique per code
99
- */
100
- this._errors = new Map();
101
- /**
102
- * Storage for the entities, should be strong as entities are unique per aseid
103
- */
104
- this._entities = new Map();
105
- /**
106
- * Storage for the fragments, should be weak as fragments are singletons per scope
107
- */
108
- this._fragments = new Map();
109
- const initializer = this.getInitializer(param1);
110
- // the returned initializer is already bound to `this` (we used .bind(this)),
111
- // so calling it will run the appropriate logic on this instance:
112
- initializer.call(this, param1, param2);
113
- }
114
- /**
115
- * Determines which initializer method to use based on the type of the first parameter.
116
- *
117
- * @param param1
118
- * @returns
119
- */
120
- getInitializer(param1, param2) {
121
- switch (true) {
122
- case !param1 && !param2:
123
- ;
124
- return this.defaultInitialized;
125
- case !!param1:
126
- return this.defaultInitialized;
127
- default:
128
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ConstructorError, 'Invalid parameters provided to A_Scope constructor');
129
- }
130
- }
131
- defaultInitialized(params = {}, config = {}) {
132
- this._name = params.name || this.constructor.name;
133
- this.initComponents(params.components);
134
- this.initErrors(params.errors);
135
- this.initFragments(params.fragments);
136
- this.initEntities(params.entities);
137
- if (config.parent) {
138
- this._parent = config.parent;
139
- }
140
- }
141
- //==========================================================================
142
- // --------------------Scope Initialization Methods---------------------------
143
- //==========================================================================
144
- /**
145
- * This method is used to initialize the components in the scope
146
- * To save memory components are initialized only when they are requested
147
- *
148
- * This method only registers the component in the scope in case they are not registered yet
149
- *
150
- * @param _components
151
- */
152
- initComponents(_components) { _components === null || _components === void 0 ? void 0 : _components.forEach(this.register.bind(this)); }
153
- /**
154
- * This method is used to initialize the errors in the scope
155
- *
156
- * This method only registers the errors in the scope in case they are not registered yet
157
- *
158
- * @param _errors
159
- */
160
- initErrors(_errors) { _errors === null || _errors === void 0 ? void 0 : _errors.forEach(this.register.bind(this)); }
161
- /**
162
- * This method is used to initialize the entities in the scope
163
- *
164
- * This method only registers the entities in the scope in case they are not registered yet
165
- *
166
- * @param _entities
167
- */
168
- initEntities(_entities) { _entities === null || _entities === void 0 ? void 0 : _entities.forEach(ent => this.register(ent)); }
169
- /**
170
- * This method is used to initialize the fragments in the scope
171
- *
172
- * This method only registers the fragments in the scope in case they are not registered yet
173
- *
174
- * @param _fragments
175
- */
176
- initFragments(_fragments) { _fragments === null || _fragments === void 0 ? void 0 : _fragments.forEach(this.register.bind(this)); }
177
- /**
178
- * Returns the issuer of the scope, useful for debugging and tracking purposes
179
- *
180
- * Issuer can be:
181
- * - A Container that allocated the scope
182
- * - A Feature that allocated the scope
183
- *
184
- * [!] Note that the issuer is the direct allocator of the scope, so if a Container allocated a Feature that allocated the scope, the issuer will be the Feature
185
- *
186
- * @returns
187
- */
188
- issuer() {
189
- try {
190
- return A_Context_class_1.A_Context.issuer(this);
191
- }
192
- catch (error) {
193
- return undefined;
194
- }
195
- }
196
- /**
197
- * This method is used to inherit from a parent scope
198
- *
199
- * [!] This method checks for circular inheritance and throws an error if detected
200
- *
201
- * @param parent
202
- * @returns
203
- */
204
- inherit(parent) {
205
- if (!parent)
206
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.InitializationError, `Invalid parent scope provided`);
207
- if (parent === this)
208
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.CircularInheritanceError, `Unable to inherit scope ${this.name} from itself`);
209
- if (parent === this._parent)
210
- return this;
211
- // Prevent circular inheritance
212
- const circularCheck = this.checkCircularInheritance(parent);
213
- if (circularCheck)
214
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.CircularInheritanceError, `Circular inheritance detected: ${[...circularCheck, parent.name].join(' -> ')}`);
215
- this._parent = parent;
216
- return this;
217
- }
218
- has(ctor) {
219
- let found = false;
220
- switch (true) {
221
- // 1) Check if it's a Scope. It's always true since it returns itself
222
- case A_TypeGuards_helper_1.A_TypeGuards.isScopeConstructor(ctor):
223
- return true;
224
- // 2) Check by string name.
225
- case typeof ctor === 'string': {
226
- // 2.1 Check if it's a component name
227
- const possibleComponent = Array.from(this.allowedComponents).find(c => c.name === ctor);
228
- if (possibleComponent)
229
- found = true;
230
- // 2.2 Check if it's a fragment name
231
- const possibleFragment = Array.from(this.allowedFragments).find(f => f.name === ctor);
232
- if (possibleFragment)
233
- found = true;
234
- // 2.3 Check if it's an entity name or entity static entity property
235
- const possibleEntity = Array.from(this.allowedEntities).find(e => e.name === ctor);
236
- if (possibleEntity)
237
- found = true;
238
- // 2.4 If not found in current scope, check parent scope
239
- if (!!this._parent)
240
- return this._parent.has(ctor);
241
- return false;
242
- }
243
- // 3) Check if it's a Component
244
- case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(ctor): {
245
- found = this.isAllowedComponent(ctor)
246
- || !![...this.allowedComponents]
247
- .find(c => A_Common_helper_1.A_CommonHelper.isInheritedFrom(c, ctor));
248
- break;
249
- }
250
- // 4) Check if it's an Entity
251
- case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(ctor): {
252
- found = this.isAllowedEntity(ctor)
253
- || !![...this.allowedEntities]
254
- .find(e => A_Common_helper_1.A_CommonHelper.isInheritedFrom(e, ctor));
255
- break;
256
- }
257
- // 5) Check if it's a Fragment
258
- case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(ctor): {
259
- found = this.isAllowedFragment(ctor)
260
- || !![...this.allowedFragments]
261
- .find(f => A_Common_helper_1.A_CommonHelper.isInheritedFrom(f, ctor));
262
- break;
263
- }
264
- // 6) Check scope issuer
265
- case this.issuer()
266
- && (this.issuer().constructor === ctor
267
- || A_Common_helper_1.A_CommonHelper.isInheritedFrom(this.issuer().constructor, ctor)):
268
- {
269
- found = true;
270
- break;
271
- }
272
- }
273
- // 7) Check parent scope in case not found
274
- if (!found && !!this._parent)
275
- try {
276
- return this._parent.has(ctor);
277
- }
278
- catch (error) {
279
- return false;
280
- }
281
- return found;
282
- }
283
- /**
284
- * Merges two scopes into a new one
285
- *
286
- * [!] Notes:
287
- * - this method does NOT modify the existing scopes
288
- * - parent of the new scope will be the parent of the current scope or the parent of anotherScope (if exists)
289
- *
290
- * @param anotherScope
291
- * @returns
292
- */
293
- merge(anotherScope) {
294
- const merged = new A_Scope({
295
- name: `${this.name} + ${anotherScope.name}`,
296
- components: [...this.allowedComponents, ...anotherScope.allowedComponents],
297
- fragments: [...this.fragments, ...anotherScope.fragments],
298
- entities: [
299
- ...this.entities, ...anotherScope.entities,
300
- ...this.allowedEntities, ...anotherScope.allowedEntities
301
- ],
302
- }, {
303
- parent: this._parent || anotherScope._parent
304
- });
305
- return merged;
306
- }
307
- resolveConstructor(name) {
308
- // 1) Check components
309
- const component = Array.from(this.allowedComponents).find(c => c.name === name
310
- || c.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
311
- if (component)
312
- return component;
313
- // 2) Check entities
314
- const entity = Array.from(this.allowedEntities).find(e => e.name === name
315
- || e.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name)
316
- || e.entity === name
317
- || e.entity === A_Formatter_helper_1.A_FormatterHelper.toKebabCase(name));
318
- if (entity)
319
- return entity;
320
- // 3) Check fragments
321
- const fragment = Array.from(this.allowedFragments).find(f => f.name === name
322
- || f.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
323
- if (fragment)
324
- return fragment;
325
- // If not found in current scope, check parent scope
326
- if (!!this._parent) {
327
- return this._parent.resolveConstructor(name);
328
- }
329
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Component or Entity with name ${name} not found in the scope ${this.name}`);
330
- }
331
- resolve(
332
- /**
333
- * Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
334
- */
335
- param1, param2) {
336
- switch (true) {
337
- case A_TypeGuards_helper_1.A_TypeGuards.isArray(param1): {
338
- return param1.map(c => {
339
- if (A_TypeGuards_helper_1.A_TypeGuards.isString(c))
340
- return this.resolveByName(c);
341
- else
342
- return this.resolveOnce(c, param2);
343
- }).filter(Boolean);
344
- }
345
- case A_TypeGuards_helper_1.A_TypeGuards.isFunction(param1): {
346
- return this.resolveOnce(param1, param2);
347
- }
348
- case A_TypeGuards_helper_1.A_TypeGuards.isString(param1): {
349
- return this.resolveByName(param1);
350
- }
351
- default: {
352
- throw new A_Error_class_1.A_Error(`Invalid parameter provided to resolve method: ${param1} in scope ${this.name}`);
353
- }
354
- }
355
- }
356
- // ==================================================================================================
357
- // --------------------------------------------------------------------------------------------------
358
- // -------------------------------------INTERNAL RESOLVERS-------------------------------------------
359
- // --------------------------------------------------------------------------------------------------
360
- // ==================================================================================================
361
- /**
362
- * This method is used internally to resolve a component, fragment or entity by its constructor name
363
- *
364
- * [!] Note that this method checks for the component, fragment or entity in the current scope and all parent scopes
365
- *
366
- * @param name - name of the component, fragment or entity to resolve (constructor name for components and fragments, static entity property for entities, static code property for commands)
367
- * @returns
368
- */
369
- resolveByName(
370
- /**
371
- * Provide the name of the component, fragment or entity to resolve
372
- */
373
- name) {
374
- // 1) Check components
375
- const component = Array.from(this.allowedComponents).find(c => c.name === name
376
- || c.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
377
- if (component)
378
- return this.resolveOnce(component);
379
- // 2) Check entities
380
- const entity = Array.from(this.allowedEntities).find(e => e.name === name
381
- || e.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name)
382
- || e.entity === name
383
- || e.entity === A_Formatter_helper_1.A_FormatterHelper.toKebabCase(name));
384
- if (entity)
385
- return this.resolveOnce(entity);
386
- // 3) Check fragments
387
- const fragment = Array.from(this.allowedFragments).find(f => f.name === name
388
- || f.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
389
- if (fragment)
390
- return this.resolveOnce(fragment);
391
- // If not found in current scope, check parent scope
392
- if (!!this._parent) {
393
- return this._parent.resolveByName(name);
394
- }
395
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Component or Entity with name ${name} not found in the scope ${this.name}`);
396
- }
397
- /**
398
- * This method is used internally to resolve a single component, fragment or entity from the scope
399
- *
400
- * @param component
401
- * @param instructions
402
- * @returns
403
- */
404
- resolveOnce(component, instructions) {
405
- const componentName = A_TypeGuards_helper_1.A_TypeGuards.isFunction(component) ? component.name : component.constructor.name || String(component);
406
- if (!component || !this.has(component))
407
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Injected Component ${componentName} not found in the scope`);
408
- if (A_TypeGuards_helper_1.A_TypeGuards.isScopeConstructor(component))
409
- component;
410
- if (typeof component == 'function' && component.name === 'A_Scope')
411
- component;
412
- switch (true) {
413
- case A_TypeGuards_helper_1.A_TypeGuards.isConstructorAllowedForScopeAllocation(component): {
414
- return this.resolveIssuer(component);
415
- }
416
- case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(component): {
417
- return this.resolveEntity(component, instructions);
418
- }
419
- case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(component): {
420
- return this.resolveFragment(component);
421
- }
422
- case A_TypeGuards_helper_1.A_TypeGuards.isScopeConstructor(component): {
423
- return this.resolveScope(component);
424
- }
425
- case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(component): {
426
- return this.resolveComponent(component);
427
- }
428
- default:
429
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Injected Component ${componentName} not found in the scope`);
430
- }
431
- }
432
- resolveIssuer(ctor) {
433
- const issuer = this.issuer();
434
- if (issuer
435
- && (issuer.constructor === ctor
436
- || A_Common_helper_1.A_CommonHelper.isInheritedFrom(issuer === null || issuer === void 0 ? void 0 : issuer.constructor, ctor))) {
437
- return issuer;
438
- }
439
- if (!!this._parent) {
440
- return this._parent.resolveIssuer(ctor);
441
- }
442
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Issuer ${ctor.name} not found in the scope ${this.name}`);
443
- }
444
- /**
445
- * This method is used internally to resolve a single entity from the scope based on the provided instructions
446
- *
447
- * [!] Note that this method can return either a single entity or an array of entities depending on the instructions provided
448
- *
449
- * @param entity
450
- * @param instructions
451
- * @returns
452
- */
453
- resolveEntity(entity, instructions) {
454
- var _a;
455
- const query = (instructions === null || instructions === void 0 ? void 0 : instructions.query) || {};
456
- const count = ((_a = instructions === null || instructions === void 0 ? void 0 : instructions.pagination) === null || _a === void 0 ? void 0 : _a.count) || 1;
457
- switch (true) {
458
- /**
459
- * 1) In case when no instructions provided, return the first found entity of the provided type
460
- *
461
- * [!] Note that it returns ONLY ONE entity
462
- * [!!] In case when no entity found in the current scope, it tries to resolve it from the parent scope (if exists)
463
- */
464
- case !instructions: {
465
- const found = this.entities.find(e => e instanceof entity);
466
- switch (true) {
467
- case !!found:
468
- return found;
469
- case !found && !!this._parent:
470
- return this._parent.resolveEntity(entity, instructions);
471
- default:
472
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Entity ${entity.name} not found in the scope ${this.name}`);
473
- }
474
- }
475
- /**
476
- * 2) In case when aseid is provided in the query, we can directly get the entity from the map
477
- *
478
- * [!] Note that it returns ONLY ONE entity
479
- */
480
- case !!query.aseid
481
- && typeof query.aseid === 'string'
482
- && this._entities.has(query.aseid):
483
- {
484
- return this._entities.get(query.aseid);
485
- }
486
- /**
487
- * 3) In case when aseid is provided as ASEID instance, we can directly get the entity from the map
488
- *
489
- * [!] Note that it returns ONLY ONE entity
490
- */
491
- case !!query.aseid
492
- && typeof query.aseid === 'object'
493
- && query.aseid instanceof ASEID_class_1.ASEID
494
- && this._entities.has(query.aseid.toString()):
495
- {
496
- return this._entities.get(query.aseid.toString());
497
- }
498
- /**
499
- * 4) In case when id is provided in the query, we have to find the entity by the id
500
- *
501
- * [!] Note that it returns ONLY ONE entity
502
- */
503
- case !!query.id: {
504
- const found = this.entities
505
- .filter(e => e instanceof entity)
506
- .find(e => String(e.id) === String(query.id));
507
- return found;
508
- }
509
- /**
510
- * 5) In case when there's a query object, we have to filter the entities by the query
511
- *
512
- * [!] Note that it can return either a single entity or an array of entities depending on the count instruction
513
- * [!!] In case when no entity found in the current scope, it tries to resolve it from the parent scope (if exists)
514
- */
515
- default: {
516
- const found = this.entities
517
- .filter(e => e instanceof entity)
518
- .filter(e => {
519
- return Object
520
- .entries(query)
521
- .every(([key, value]) => {
522
- if (key in e) {
523
- return e[key] === value;
524
- }
525
- return false;
526
- });
527
- });
528
- if (found.length === 0 && !!this._parent)
529
- return this._parent.resolveEntity(entity, instructions);
530
- if (count === 1)
531
- return found[0];
532
- return found;
533
- }
534
- }
535
- }
536
- /**
537
- * This method is used internally to resolve a single fragment from the scope
538
- *
539
- * @param fragment
540
- * @returns
541
- */
542
- resolveFragment(fragment) {
543
- const fragmentInstancePresented = this._fragments.get(fragment);
544
- switch (true) {
545
- case fragmentInstancePresented && this._fragments.has(fragment):
546
- return fragmentInstancePresented;
547
- case !fragmentInstancePresented && !!this._parent:
548
- return this._parent.resolveFragment(fragment);
549
- default:
550
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Fragment ${fragment.name} not found in the scope ${this.name}`);
551
- }
552
- }
553
- /**
554
- * This method is used internally to resolve a single scope from the current scope
555
- *
556
- * @param scope
557
- * @returns
558
- */
559
- resolveScope(scope) {
560
- return this;
561
- }
562
- /**
563
- * This method is used internally to resolve a single component from the scope
564
- *
565
- * @param component
566
- * @returns
567
- */
568
- resolveComponent(component) {
569
- // The idea here that in case when Scope has no exact component we have to resolve it from the _parent
570
- // BUT: if it's not presented in _parent we have to check for inheritance
571
- // That means that we should ensure that there's no components that are children of the required component
572
- switch (true) {
573
- // 1) In case when the component is available and exists in the scope
574
- case this.allowedComponents.has(component) && this._components.has(component): {
575
- return this._components.get(component);
576
- }
577
- // 2) In case the component available but does NOT exist in the scope
578
- case this.allowedComponents.has(component) && !this._components.has(component): {
579
- const componentMeta = A_Context_class_1.A_Context.meta(component);
580
- const argsMeta = componentMeta.get(A_Component_constants_1.A_TYPES__ComponentMetaKey.INJECTIONS);
581
- const resolvedArgs = ((argsMeta === null || argsMeta === void 0 ? void 0 : argsMeta.get('constructor')) || [])
582
- .map(arg => {
583
- if ('instructions' in arg) {
584
- const { target, instructions } = arg;
585
- return this.resolve(target, instructions);
586
- }
587
- // TODO: Fix types mismatch here
588
- return this.resolve(arg.target);
589
- });
590
- const newComponent = new component(...resolvedArgs);
591
- this.register(newComponent);
592
- return this._components.get(component);
593
- }
594
- // 3) In case when there's a component that is inherited from the required component
595
- case !this.allowedComponents.has(component) && Array.from(this.allowedComponents).some(el => A_Common_helper_1.A_CommonHelper.isInheritedFrom(el, component)): {
596
- const found = Array.from(this.allowedComponents).find(el => A_Common_helper_1.A_CommonHelper.isInheritedFrom(el, component));
597
- return this.resolveComponent(found);
598
- }
599
- // 4) In case when the component is not available in the scope but the _parent is available
600
- case !!this._parent: {
601
- return this._parent.resolveComponent(component);
602
- }
603
- default:
604
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ResolutionError, `Component ${component.name} not found in the scope ${this.name}`);
605
- }
606
- }
607
- register(param1) {
608
- var _a;
609
- switch (true) {
610
- // ------------------------------------------
611
- // ------------ Instances ----------------
612
- // ------------------------------------------
613
- // 1) In case when it's a A-Component instance
614
- case param1 instanceof A_Component_class_1.A_Component: {
615
- if (!this.allowedComponents.has(param1.constructor))
616
- this.allowedComponents.add(param1.constructor);
617
- this._components.set(param1.constructor, param1);
618
- A_Context_class_1.A_Context.register(this, param1);
619
- break;
620
- }
621
- // 3) In case when it's a A-Entity instance
622
- case param1 instanceof A_Entity_class_1.A_Entity && !this._entities.has(param1.aseid.toString()): {
623
- if (!this.allowedEntities.has(param1.constructor))
624
- this.allowedEntities.add(param1.constructor);
625
- this._entities.set(param1.aseid.toString(), param1);
626
- A_Context_class_1.A_Context.register(this, param1);
627
- break;
628
- }
629
- // 4) In case when it's a A-Fragment instance
630
- case param1 instanceof A_Fragment_class_1.A_Fragment: {
631
- if (!this.allowedFragments.has(param1.constructor))
632
- this.allowedFragments.add(param1.constructor);
633
- this._fragments.set(param1.constructor, param1);
634
- A_Context_class_1.A_Context.register(this, param1);
635
- break;
636
- }
637
- // 5) In case when it's a A-Error instance
638
- case param1 instanceof A_Error_class_1.A_Error: {
639
- if (!this.allowedErrors.has(param1.constructor))
640
- this.allowedErrors.add(param1.constructor);
641
- // A_Context.register(this, param1);
642
- break;
643
- }
644
- // ------------------------------------------
645
- // ------------ Constructors ----------------
646
- // ------------------------------------------
647
- // 6) In case when it's a A-Component constructor
648
- case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(param1): {
649
- if (!this.allowedComponents.has(param1))
650
- this.allowedComponents.add(param1);
651
- break;
652
- }
653
- // 8) In case when it's a A-Fragment constructor
654
- case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(param1): {
655
- if (!this.allowedFragments.has(param1))
656
- this.allowedFragments.add(param1);
657
- break;
658
- }
659
- // 9) In case when it's a A-Entity constructor
660
- case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(param1): {
661
- if (!this.allowedEntities.has(param1))
662
- this.allowedEntities.add(param1);
663
- break;
664
- }
665
- // 10) In case when it's a A-Error constructor
666
- case A_TypeGuards_helper_1.A_TypeGuards.isErrorConstructor(param1): {
667
- if (!this.allowedErrors.has(param1))
668
- this.allowedErrors.add(param1);
669
- break;
670
- }
671
- // ------------------------------------------
672
- // ------------ Invalid Cases ----------------
673
- // ------------------------------------------
674
- default:
675
- if (param1 instanceof A_Entity_class_1.A_Entity)
676
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.RegistrationError, `Entity with ASEID ${param1.aseid.toString()} is already registered in the scope ${this.name}`);
677
- else if (param1 instanceof A_Fragment_class_1.A_Fragment)
678
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.RegistrationError, `Fragment ${param1.constructor.name} is already registered in the scope ${this.name}`);
679
- else {
680
- const componentName = A_TypeGuards_helper_1.A_TypeGuards.isFunction(param1) ? param1.name : ((_a = param1 === null || param1 === void 0 ? void 0 : param1.constructor) === null || _a === void 0 ? void 0 : _a.name) || String(param1);
681
- throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.RegistrationError, `Cannot register ${componentName} in the scope ${this.name}`);
682
- }
683
- }
684
- }
685
- /**
686
- * This method is useful when you want to serialize the scope to JSON
687
- *
688
- * [!] Note this is not a deep serialization, only the fragments are serialized
689
- * [!] Fragments are a storage for information which is relevant to the scope
690
- *
691
- * @returns
692
- */
693
- toJSON() {
694
- return this.fragments
695
- .reduce((acc, fragment) => {
696
- const serialized = fragment.toJSON();
697
- return Object.assign(Object.assign({}, acc), { [serialized.name]: serialized });
698
- }, {});
699
- }
700
- //==========================================================================
701
- // --------------------Scope Type Check Helpers---------------------------
702
- //==========================================================================
703
- /**
704
- * Type guard to check if the constructor is of type A_Component and is allowed in the scope
705
- *
706
- * @param ctor
707
- * @returns
708
- */
709
- isAllowedComponent(ctor) {
710
- return A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(ctor) && this.allowedComponents.has(ctor);
711
- }
712
- /**
713
- * Type guard to check if the constructor is of type A_Entity and is allowed in the scope
714
- *
715
- * @param ctor
716
- * @returns
717
- */
718
- isAllowedEntity(ctor) {
719
- return A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(ctor) && this.allowedEntities.has(ctor);
720
- }
721
- /**
722
- * Type guard to check if the constructor is of type A_Fragment and is allowed in the scope
723
- *
724
- * @param ctor
725
- * @returns
726
- */
727
- isAllowedFragment(ctor) {
728
- return A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(ctor) && this.allowedFragments.has(ctor);
729
- }
730
- /**
731
- * Type guard to check if the constructor is of type A_Error and is allowed in the scope
732
- *
733
- * @param ctor
734
- * @returns
735
- */
736
- isAllowedError(ctor) {
737
- return A_TypeGuards_helper_1.A_TypeGuards.isErrorConstructor(ctor) && this.allowedErrors.has(ctor);
738
- }
739
- // ==========================================================================
740
- // --------------------DEBUG & Helpers Methods--------------------------------
741
- // ===========================================================================
742
- /**
743
- * This method is used to check if the scope is inherited from another scope
744
- *
745
- * @param scope
746
- * @returns
747
- */
748
- isInheritedFrom(scope) {
749
- let current = this;
750
- while (current) {
751
- if (current === scope) {
752
- return true;
753
- }
754
- current = current._parent;
755
- }
756
- return false;
757
- }
758
- /**
759
- * Helper method to check circular inheritance
760
- * Should return a full sequence of inheritance for logging purposes
761
- *
762
- * @param scope
763
- * @returns
764
- */
765
- checkCircularInheritance(scope) {
766
- const inheritanceChain = [];
767
- let current = this._parent;
768
- while (current) {
769
- inheritanceChain.push(current.name);
770
- if (current === scope) {
771
- return inheritanceChain;
772
- }
773
- current = current._parent;
774
- }
775
- return false;
776
- }
777
- /**
778
- * Helper method to print the inheritance chain of the scope
779
- */
780
- printInheritanceChain() {
781
- const chain = [];
782
- let current = this;
783
- while (current) {
784
- chain.push(current.name);
785
- current = current._parent;
786
- }
787
- console.log(chain.join(' -> '));
788
- }
789
- }
790
- exports.A_Scope = A_Scope;
791
- //# sourceMappingURL=A-Scope.class.js.map