dyo-tools 0.2.0 → 0.3.0

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 (167) hide show
  1. package/dist/constants.js +4 -4
  2. package/dist/constants.js.map +1 -1
  3. package/dist/core/DTAction.d.ts +10 -0
  4. package/dist/core/DTAction.js +24 -0
  5. package/dist/core/DTAction.js.map +1 -0
  6. package/dist/core/DTBunch.d.ts +6 -7
  7. package/dist/core/DTBunch.js +16 -13
  8. package/dist/core/DTBunch.js.map +1 -1
  9. package/dist/core/DTComponentPhysical.d.ts +6 -4
  10. package/dist/core/DTComponentPhysical.js +6 -0
  11. package/dist/core/DTComponentPhysical.js.map +1 -1
  12. package/dist/core/DTElement.d.ts +5 -0
  13. package/dist/core/DTElement.js +12 -2
  14. package/dist/core/DTElement.js.map +1 -1
  15. package/dist/core/DTManager.d.ts +3 -1
  16. package/dist/core/DTManager.js +24 -14
  17. package/dist/core/DTManager.js.map +1 -1
  18. package/dist/core/DTMaster.d.ts +24 -0
  19. package/dist/core/DTMaster.js +133 -0
  20. package/dist/core/DTMaster.js.map +1 -0
  21. package/dist/core/DTModule.d.ts +14 -0
  22. package/dist/core/DTModule.js +39 -0
  23. package/dist/core/DTModule.js.map +1 -0
  24. package/dist/index.d.ts +5 -1
  25. package/dist/index.js +11 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/libs/player/DTPlayer.element.d.ts +5 -0
  28. package/dist/libs/player/DTPlayer.element.js +11 -0
  29. package/dist/libs/player/DTPlayer.element.js.map +1 -0
  30. package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
  31. package/dist/libs/player/DTPlayer.manager.js +42 -0
  32. package/dist/libs/player/DTPlayer.manager.js.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/types/core.d.ts +103 -0
  35. package/dist/types/core.js +15 -0
  36. package/dist/types/core.js.map +1 -0
  37. package/dist/types/index.d.ts +2 -98
  38. package/dist/types/index.js +16 -12
  39. package/dist/types/index.js.map +1 -1
  40. package/dist/types/player.d.ts +5 -0
  41. package/dist/types/player.js +3 -0
  42. package/dist/types/player.js.map +1 -0
  43. package/docs/assets/highlight.css +29 -29
  44. package/docs/assets/main.js +59 -58
  45. package/docs/assets/navigation.js +1 -0
  46. package/docs/assets/search.js +1 -1
  47. package/docs/assets/style.css +1414 -1367
  48. package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
  49. package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
  50. package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
  51. package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
  52. package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
  53. package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
  54. package/docs/classes/core_DTError.DYOToolsError.html +37 -0
  55. package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
  56. package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
  57. package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
  58. package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
  59. package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
  60. package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
  61. package/docs/enums/types_core.FilterOperatorType.html +10 -0
  62. package/docs/hierarchy.html +1 -0
  63. package/docs/index.html +1 -46
  64. package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
  65. package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
  66. package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
  67. package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
  68. package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
  69. package/docs/interfaces/types_core.DTElementToObject.html +7 -0
  70. package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
  71. package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
  72. package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
  73. package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
  74. package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
  75. package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
  76. package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
  77. package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
  78. package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
  79. package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
  80. package/docs/modules/constants.html +6 -0
  81. package/docs/modules/core_DTAction.html +2 -0
  82. package/docs/modules/core_DTBunch.html +2 -0
  83. package/docs/modules/core_DTComponent.html +2 -0
  84. package/docs/modules/core_DTComponentPhysical.html +2 -0
  85. package/docs/modules/core_DTComponentWithMeta.html +2 -0
  86. package/docs/modules/core_DTElement.html +2 -0
  87. package/docs/modules/core_DTError.html +2 -0
  88. package/docs/modules/core_DTManager.html +2 -0
  89. package/docs/modules/core_DTMaster.html +2 -0
  90. package/docs/modules/core_DTModule.html +2 -0
  91. package/docs/modules/libs_DYOFinder.html +2 -0
  92. package/docs/modules/libs_player_DTPlayer_element.html +2 -0
  93. package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
  94. package/docs/modules/types.html +29 -0
  95. package/docs/modules/types_core.html +28 -0
  96. package/docs/modules/types_player.html +2 -0
  97. package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
  98. package/docs/types/types_core.DTManagerItemType.html +1 -0
  99. package/docs/types/types_core.DTManagerItemsType.html +2 -0
  100. package/docs/types/types_core.DYOFinderComponentType.html +1 -0
  101. package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
  102. package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
  103. package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
  104. package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
  105. package/docs/types/types_core.DYOFinderFilters.html +1 -0
  106. package/docs/types/types_core.StandardPrimitiveType.html +2 -0
  107. package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
  108. package/docs/variables/constants.bunchDefaultOptions.html +2 -0
  109. package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
  110. package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
  111. package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
  112. package/docs/variables/constants.managerDefaultOptions.html +2 -0
  113. package/package.json +16 -17
  114. package/src/constants.ts +85 -85
  115. package/src/core/DTAction.ts +52 -0
  116. package/src/core/DTBunch.ts +467 -461
  117. package/src/core/DTComponent.ts +225 -225
  118. package/src/core/DTComponentPhysical.ts +53 -39
  119. package/src/core/DTComponentWithMeta.ts +65 -65
  120. package/src/core/DTElement.ts +102 -69
  121. package/src/core/DTError.ts +78 -78
  122. package/src/core/DTManager.ts +465 -446
  123. package/src/core/DTMaster.ts +318 -0
  124. package/src/core/DTModule.ts +90 -0
  125. package/src/index.ts +17 -9
  126. package/src/libs/DYOFinder.ts +175 -175
  127. package/src/libs/player/DTPlayer.element.ts +9 -0
  128. package/src/libs/player/DTPlayer.manager.ts +84 -0
  129. package/src/types/core.ts +169 -0
  130. package/src/types/index.ts +2 -162
  131. package/src/types/player.ts +6 -0
  132. package/test/core/DTAction.double.ts +78 -0
  133. package/test/core/DTAction.spec.ts +76 -0
  134. package/test/core/DTBunch.double.ts +18 -10
  135. package/test/core/DTBunch.spec.ts +70 -68
  136. package/test/core/DTComponentPhysical.double.ts +3 -3
  137. package/test/core/DTComponentPhysical.spec.ts +25 -11
  138. package/test/core/DTElement.double.ts +21 -5
  139. package/test/core/DTElement.spec.ts +52 -8
  140. package/test/core/DTError.double.ts +1 -1
  141. package/test/core/DTManager.double.ts +29 -5
  142. package/test/core/DTManager.spec.ts +80 -17
  143. package/test/core/DTMaster.double.ts +141 -0
  144. package/test/core/DTMaster.spec.ts +584 -0
  145. package/test/core/DTModule.double.ts +80 -0
  146. package/test/core/DTModule.spec.ts +138 -0
  147. package/test/core/copy.spec.ts +20 -4
  148. package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
  149. package/test/libs/player/DTPlayer.element.spec.ts +28 -0
  150. package/test/libs/player/DTPlayer.manager.double.ts +92 -0
  151. package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
  152. package/LICENSE +0 -21
  153. package/cucumber.js +0 -9
  154. package/dist/core/DTPlayer.d.ts +0 -8
  155. package/dist/core/DTPlayer.js +0 -30
  156. package/dist/core/DTPlayer.js.map +0 -1
  157. package/e2e/0.2.0/epic1.feature +0 -29
  158. package/e2e/0.2.0/epic2.feature +0 -22
  159. package/e2e/0.2.0/epic3.feature +0 -25
  160. package/e2e/0.2.0/resources/dominion.js +0 -195
  161. package/e2e/0.2.0/resources/utils.js +0 -27
  162. package/e2e/0.2.0/support/steps.js +0 -108
  163. package/e2e/future/epic4.feature +0 -39
  164. package/e2e/future/resources/dominion.js +0 -238
  165. package/e2e/future/resources/utils.js +0 -27
  166. package/src/core/DTPlayer.ts +0 -57
  167. package/test/core/DTPlayer.spec.ts +0 -80
@@ -1,225 +1,225 @@
1
- import * as uuid from 'uuid';
2
- import DYOToolsError from './DTError';
3
- import { DTComponentOptions } from '../types';
4
-
5
- /**
6
- * @template {string} DTComponentOptions
7
- */
8
- export default abstract class DYOToolsComponent<IComponentOptions extends DTComponentOptions = DTComponentOptions> {
9
- /**
10
- * Component unique ID. Use uuid v4 generator.
11
- */
12
- protected _id: string;
13
-
14
- /**
15
- * Component specific and accessible label.
16
- * If not provided, the key is set with ID by default.
17
- */
18
- protected _key: string;
19
-
20
- /**
21
- * Component Parent Context.
22
- *
23
- * A component can have only one *physical context*, and be managed by a parent Component.
24
- */
25
- protected _context?: DYOToolsComponent;
26
-
27
- /**
28
- * Higher Level Component category.
29
- *
30
- * Describing component Type, like Element, Bunch, Manager...
31
- */
32
- protected abstract _componentType: string;
33
-
34
- /**
35
- * Second Level Component category.
36
- *
37
- * Describing component Domain, like Card, Dice, Token...
38
- */
39
- protected _domain?: string;
40
-
41
- /**
42
- * Third Level Component category.
43
- *
44
- * Describing component extra type, like Hand, Deck, Trick...
45
- */
46
- protected _subKind?: string;
47
-
48
- /**
49
- * Array of current errors for the Component.
50
- *
51
- * Errors are only available if the **errors** option is enabled.
52
- */
53
- protected _errors: DYOToolsError[];
54
-
55
- /**
56
- * Component options configuration.
57
- * Defined by generic type IComponentOptions.
58
- *
59
- * For all component, global option can be :
60
- * * **errors** : Default *false*. If *true*, no exception is thrown when an error occurred, a new DTError instance is
61
- * added to the _errors property array instead. If *false*, throw the exception with a DTError instance.
62
- */
63
- protected _options: IComponentOptions;
64
-
65
- /**
66
- * Set automatic unique _id and _key.
67
- *
68
- * @param key Optional Key to set. If not provided, set the _key with the _id value.
69
- * @param options Specific options configuration for the instance. Default empty object.
70
- */
71
- constructor(key?: string, options: Partial<IComponentOptions> = {}) {
72
- this._id = uuid.v4();
73
- this._key = key || this._id;
74
- this._errors = [];
75
-
76
- const defaultOptions: DTComponentOptions = {
77
- errors: false,
78
- };
79
- this._options = {
80
- ...defaultOptions,
81
- ...options,
82
- } as IComponentOptions;
83
- }
84
-
85
- /**
86
- * Getter for _id property.
87
- */
88
- getId(): string {
89
- return this._id;
90
- }
91
-
92
- /**
93
- * Getter for _key property.
94
- */
95
- getKey(): string {
96
- return this._key;
97
- }
98
-
99
- /**
100
- * Getter for _context property.
101
- *
102
- * @param contextType If provided, the getter parse all component level hierarchy to find the corresponding component
103
- * with **contextType** as _componentType value, and returns it. Return undefined if not found.
104
- *
105
- * @returns Direct parent Component or higher level Component if filtered with **contextType**.
106
- * Returns undefined if context doesn't exist.
107
- */
108
- getContext<IContext extends DYOToolsComponent = DYOToolsComponent>(contextType?: string): IContext | undefined {
109
- if (this._context) {
110
- if (!contextType || this._context.getComponentType() === contextType) {
111
- return this._context as IContext;
112
- }
113
- return this._context.getContext(contextType);
114
- }
115
- return undefined;
116
- }
117
-
118
- /**
119
- * Setter for _context property.
120
- */
121
- setContext<IContext extends DYOToolsComponent = DYOToolsComponent>(value: IContext): void {
122
- this._context = value;
123
- }
124
-
125
- /**
126
- * Remove the current context of component.
127
- */
128
- removeContext(): void {
129
- this._context = undefined;
130
- }
131
-
132
- /**
133
- * Getter for _componentType property.
134
- */
135
- getComponentType(): string {
136
- return this._componentType;
137
- }
138
-
139
- /**
140
- * Getter for _domain property.
141
- */
142
- getDomain(): string {
143
- return this._domain;
144
- }
145
-
146
- /**
147
- * Getter for _subKind property.
148
- */
149
- getSubKind(): string {
150
- return this._subKind;
151
- }
152
-
153
- /**
154
- * Getter for _errors property.
155
- *
156
- * Note : Errors are always provided by the higher order component, defined into the _context property.
157
- */
158
- getErrors(): DYOToolsError[] {
159
- if (this.getContext()) {
160
- return this.getContext().getErrors();
161
- }
162
- return this._errors;
163
- }
164
-
165
- /**
166
- * Return the last error (most recent) of the current component. Undefined if _errors is empty.
167
- *
168
- * Note : Errors are always provided by the higher order component, defined into the _context property.
169
- */
170
- getLastError(): DYOToolsError | undefined {
171
- if (this.getContext()) {
172
- return this.getContext().getLastError();
173
- }
174
- return this._errors.length > 0 ? this._errors[this._errors.length - 1] : undefined;
175
- }
176
-
177
- /**
178
- * Generic method to trigger an error, depending on the **errors** option :
179
- * * if the option is set to *false*, throw the DTError instance passed as an argument.
180
- * * if the option is set to *true*, add DTError instance passed as an argument in the _errors array.
181
- *
182
- * Note : Errors are always stored into the higher order component, defined into the _context property.
183
- *
184
- * @param error DYOToolsError instance to trigger
185
- */
186
- triggerError(error: DYOToolsError): void {
187
- const { errors = false } = this._options;
188
- if (this.getContext()) {
189
- this.getContext().triggerError(error);
190
- } else if (!errors) {
191
- throw error;
192
- } else {
193
- this._errors.push(error);
194
- }
195
- }
196
-
197
- /**
198
- * Clear all current errors.
199
- *
200
- * Note : Errors are always stored into the higher order component, defined into the _context property.
201
- */
202
- clearErrors(): void {
203
- if (this.getContext()) {
204
- this.getContext().clearErrors();
205
- }
206
- this._errors = [];
207
- }
208
-
209
- /**
210
- * Getter for _options property.
211
- */
212
- getOptions(): IComponentOptions {
213
- return this._options;
214
- }
215
-
216
- /**
217
- * Abstract method for JSON Object representation of the component and returning it.
218
- */
219
- abstract toObject(): unknown;
220
-
221
- /**
222
- * Abstract method for String representation of the component and returning it.
223
- */
224
- abstract toString(): string;
225
- }
1
+ import * as uuid from 'uuid';
2
+ import DYOToolsError from './DTError';
3
+ import { DTComponentOptions } from '../types';
4
+
5
+ /**
6
+ * @template {string} DTComponentOptions
7
+ */
8
+ export default abstract class DYOToolsComponent<IComponentOptions extends DTComponentOptions = DTComponentOptions> {
9
+ /**
10
+ * Component unique ID. Use uuid v4 generator.
11
+ */
12
+ protected _id: string;
13
+
14
+ /**
15
+ * Component specific and accessible label.
16
+ * If not provided, the key is set with ID by default.
17
+ */
18
+ protected _key: string;
19
+
20
+ /**
21
+ * Component Parent Context.
22
+ *
23
+ * A component can have only one *context*, and be managed by a parent Component.
24
+ */
25
+ protected _context?: DYOToolsComponent;
26
+
27
+ /**
28
+ * Higher Level Component category.
29
+ *
30
+ * Describing component Type, like Element, Bunch, Manager...
31
+ */
32
+ protected abstract _componentType: string;
33
+
34
+ /**
35
+ * Second Level Component category.
36
+ *
37
+ * Describing component Domain, like Card, Dice, Token...
38
+ */
39
+ protected _domain?: string;
40
+
41
+ /**
42
+ * Third Level Component category.
43
+ *
44
+ * Describing component extra type, like Hand, Deck, Trick...
45
+ */
46
+ protected _subKind?: string;
47
+
48
+ /**
49
+ * Array of current errors for the Component.
50
+ *
51
+ * Errors are only available if the **errors** option is enabled.
52
+ */
53
+ protected _errors: DYOToolsError[];
54
+
55
+ /**
56
+ * Component options configuration.
57
+ * Defined by generic type IComponentOptions.
58
+ *
59
+ * For all component, global option can be :
60
+ * * **errors** : Default *false*. If *true*, no exception is thrown when an error occurred, a new DTError instance is
61
+ * added to the _errors property array instead. If *false*, throw the exception with a DTError instance.
62
+ */
63
+ protected _options: IComponentOptions;
64
+
65
+ /**
66
+ * Set automatic unique _id and _key.
67
+ *
68
+ * @param key Optional Key to set. If not provided, set the _key with the _id value.
69
+ * @param options Specific options configuration for the instance. Default empty object.
70
+ */
71
+ constructor(key?: string, options: Partial<IComponentOptions> = {}) {
72
+ this._id = uuid.v4();
73
+ this._key = key || this._id;
74
+ this._errors = [];
75
+
76
+ const defaultOptions: DTComponentOptions = {
77
+ errors: false,
78
+ };
79
+ this._options = {
80
+ ...defaultOptions,
81
+ ...options,
82
+ } as IComponentOptions;
83
+ }
84
+
85
+ /**
86
+ * Getter for _id property.
87
+ */
88
+ getId(): string {
89
+ return this._id;
90
+ }
91
+
92
+ /**
93
+ * Getter for _key property.
94
+ */
95
+ getKey(): string {
96
+ return this._key;
97
+ }
98
+
99
+ /**
100
+ * Getter for _context property.
101
+ *
102
+ * @param contextType If provided, the getter parse all component level hierarchy to find the corresponding component
103
+ * with **contextType** as _componentType value, and returns it. Return undefined if not found.
104
+ *
105
+ * @returns Direct parent Component or higher level Component if filtered with **contextType**.
106
+ * Returns undefined if context doesn't exist.
107
+ */
108
+ getContext<IContext extends DYOToolsComponent = DYOToolsComponent>(contextType?: string): IContext | undefined {
109
+ if (this._context) {
110
+ if (!contextType || this._context.getComponentType() === contextType) {
111
+ return this._context as IContext;
112
+ }
113
+ return this._context.getContext(contextType);
114
+ }
115
+ return undefined;
116
+ }
117
+
118
+ /**
119
+ * Setter for _context property.
120
+ */
121
+ setContext<IContext extends DYOToolsComponent = DYOToolsComponent>(value: IContext): void {
122
+ this._context = value;
123
+ }
124
+
125
+ /**
126
+ * Remove the current context of component.
127
+ */
128
+ removeContext(): void {
129
+ this._context = undefined;
130
+ }
131
+
132
+ /**
133
+ * Getter for _componentType property.
134
+ */
135
+ getComponentType(): string {
136
+ return this._componentType;
137
+ }
138
+
139
+ /**
140
+ * Getter for _domain property.
141
+ */
142
+ getDomain(): string {
143
+ return this._domain;
144
+ }
145
+
146
+ /**
147
+ * Getter for _subKind property.
148
+ */
149
+ getSubKind(): string {
150
+ return this._subKind;
151
+ }
152
+
153
+ /**
154
+ * Getter for _errors property.
155
+ *
156
+ * Note : Errors are always provided by the higher order component, defined into the _context property.
157
+ */
158
+ getErrors(): DYOToolsError[] {
159
+ if (this.getContext()) {
160
+ return this.getContext().getErrors();
161
+ }
162
+ return this._errors;
163
+ }
164
+
165
+ /**
166
+ * Return the last error (most recent) of the current component. Undefined if _errors is empty.
167
+ *
168
+ * Note : Errors are always provided by the higher order component, defined into the _context property.
169
+ */
170
+ getLastError(): DYOToolsError | undefined {
171
+ if (this.getContext()) {
172
+ return this.getContext().getLastError();
173
+ }
174
+ return this._errors.length > 0 ? this._errors[this._errors.length - 1] : undefined;
175
+ }
176
+
177
+ /**
178
+ * Generic method to trigger an error, depending on the **errors** option :
179
+ * * if the option is set to *false*, throw the DTError instance passed as an argument.
180
+ * * if the option is set to *true*, add DTError instance passed as an argument in the _errors array.
181
+ *
182
+ * Note : Errors are always stored into the higher order component, defined into the _context property.
183
+ *
184
+ * @param error DYOToolsError instance to trigger
185
+ */
186
+ triggerError(error: DYOToolsError): void {
187
+ const { errors = false } = this._options;
188
+ if (this.getContext()) {
189
+ this.getContext().triggerError(error);
190
+ } else if (!errors) {
191
+ throw error;
192
+ } else {
193
+ this._errors.push(error);
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Clear all current errors.
199
+ *
200
+ * Note : Errors are always stored into the higher order component, defined into the _context property.
201
+ */
202
+ clearErrors(): void {
203
+ if (this.getContext()) {
204
+ this.getContext().clearErrors();
205
+ }
206
+ this._errors = [];
207
+ }
208
+
209
+ /**
210
+ * Getter for _options property.
211
+ */
212
+ getOptions(): IComponentOptions {
213
+ return this._options;
214
+ }
215
+
216
+ /**
217
+ * Abstract method for JSON Object representation of the component and returning it.
218
+ */
219
+ abstract toObject(): unknown;
220
+
221
+ /**
222
+ * Abstract method for String representation of the component and returning it.
223
+ */
224
+ abstract toString(): string;
225
+ }
@@ -1,39 +1,53 @@
1
- import { DTAcceptedMetaData, DTComponentOptions } from '../types';
2
- import DYOToolsComponentWithMeta from './DTComponentWithMeta';
3
- import DYOToolsPlayer from './DTPlayer';
4
-
5
- export default abstract class DYOToolsComponentPhysical<
6
- IComponentMeta extends DTAcceptedMetaData,
7
- IComponentOptions extends DTComponentOptions = DTComponentOptions,
8
- > extends DYOToolsComponentWithMeta<IComponentMeta, IComponentOptions> {
9
- /**
10
- * Owner DTPlayer instance if defined
11
- */
12
- protected _owner?: DYOToolsPlayer<DTAcceptedMetaData>;
13
-
14
- /**
15
- * Getter for _owner property.
16
- */
17
- getOwner(): DYOToolsPlayer<DTAcceptedMetaData> {
18
- return this._owner;
19
- }
20
-
21
- /**
22
- * Setter for _owner property.
23
- */
24
- setOwner(value: DYOToolsPlayer<DTAcceptedMetaData>): void {
25
- this._owner = value;
26
- }
27
-
28
- /**
29
- * Remove the current owner of element.
30
- */
31
- removeOwner(): void {
32
- this._owner = undefined;
33
- }
34
-
35
- /**
36
- * Abstract method for copying the Component and returning it.
37
- */
38
- abstract copy(): DYOToolsComponentPhysical<IComponentMeta, IComponentOptions>;
39
- }
1
+ import { DTAcceptedMetaData, DTComponentOptions } from '../types';
2
+ import DYOToolsComponentWithMeta from './DTComponentWithMeta';
3
+ import DYOToolsMaster from './DTMaster';
4
+
5
+ export default abstract class DYOToolsComponentPhysical<
6
+ IComponentMeta extends DTAcceptedMetaData,
7
+ IComponentOptions extends DTComponentOptions = DTComponentOptions,
8
+ > extends DYOToolsComponentWithMeta<IComponentMeta, IComponentOptions> {
9
+ /**
10
+ * Owner string representation, if defined.
11
+ */
12
+ protected _owner?: string;
13
+
14
+ /**
15
+ * Returns Manager component from context, or undefined.
16
+ */
17
+ getManager(): DYOToolsMaster | undefined {
18
+ return this.getContext<DYOToolsMaster>('manager');
19
+ }
20
+
21
+ /**
22
+ * Returns Master component from context, or undefined.
23
+ */
24
+ getMaster(): DYOToolsMaster | undefined {
25
+ return this.getContext<DYOToolsMaster>('master');
26
+ }
27
+
28
+ /**
29
+ * Getter for _owner property.
30
+ */
31
+ getOwner(): string {
32
+ return this._owner;
33
+ }
34
+
35
+ /**
36
+ * Setter for _owner property.
37
+ */
38
+ setOwner(value: string): void {
39
+ this._owner = value;
40
+ }
41
+
42
+ /**
43
+ * Remove the current owner of element.
44
+ */
45
+ removeOwner(): void {
46
+ this._owner = undefined;
47
+ }
48
+
49
+ /**
50
+ * Abstract method for copying the Component and returning it.
51
+ */
52
+ abstract copy(): DYOToolsComponentPhysical<IComponentMeta, IComponentOptions>;
53
+ }
@@ -1,65 +1,65 @@
1
- import DYOToolsComponent from './DTComponent';
2
- import { DTAcceptedMetaData, DTComponentOptions } from '../types';
3
-
4
- export default abstract class DYOToolsComponentWithMeta<
5
- IComponentMeta extends DTAcceptedMetaData,
6
- IComponentOptions extends DTComponentOptions = DTComponentOptions,
7
- > extends DYOToolsComponent<IComponentOptions> {
8
- /**
9
- * Component meta data.
10
- * Defined by generic type IComponentMeta.
11
- * @default {}
12
- */
13
- protected _meta : Partial<IComponentMeta> = {} as Partial<IComponentMeta>;
14
-
15
- /**
16
- * Getter for one meta by key.
17
- *
18
- * @param metaKey Key name of one meta data.
19
- *
20
- * @returns Associated meta **metaKey** value or undefined if not found.
21
- */
22
- getMeta<K extends keyof IComponentMeta>(metaKey : K) : IComponentMeta[K] | undefined {
23
- return this._meta && this._meta[metaKey];
24
- }
25
-
26
- /**
27
- * Setter for one meta by key.
28
- *
29
- * @param metaKey Key name of the meta data to update.
30
- * @param metaValue New value to set into the meta data.
31
- */
32
- setMeta<K extends keyof IComponentMeta>(metaKey : K, metaValue : IComponentMeta[K]) : void {
33
- this._meta[metaKey] = metaValue;
34
- }
35
-
36
- /**
37
- * Returns multiple defined keys values of meta data.
38
- *
39
- * @param metaKeys Array of keys to filter for meta data. If not provided or empty, returns all keys.
40
- *
41
- * @returns Meta data object with **metaKeys** provided keys only.
42
- */
43
- getManyMeta(metaKeys : Array<keyof IComponentMeta> = []) : Partial<IComponentMeta> {
44
- const arrayMeta: Partial<IComponentMeta> = {} as Partial<IComponentMeta>;
45
- if (!metaKeys.length) {
46
- return this._meta;
47
- }
48
-
49
- metaKeys.forEach((key) => {
50
- if (this._meta && this._meta[key]) {
51
- arrayMeta[key] = this._meta[key];
52
- }
53
- });
54
- return arrayMeta;
55
- }
56
-
57
- /**
58
- * Set multiple meta data.
59
- *
60
- * @param metaValues Object of meta data to set, according to the meta data property type.
61
- */
62
- setManyMeta(metaValues : Partial<IComponentMeta>) : void {
63
- this._meta = { ...this._meta, ...metaValues };
64
- }
65
- }
1
+ import DYOToolsComponent from './DTComponent';
2
+ import { DTAcceptedMetaData, DTComponentOptions } from '../types';
3
+
4
+ export default abstract class DYOToolsComponentWithMeta<
5
+ IComponentMeta extends DTAcceptedMetaData,
6
+ IComponentOptions extends DTComponentOptions = DTComponentOptions,
7
+ > extends DYOToolsComponent<IComponentOptions> {
8
+ /**
9
+ * Component meta data.
10
+ * Defined by generic type IComponentMeta.
11
+ * @default {}
12
+ */
13
+ protected _meta : Partial<IComponentMeta> = {} as Partial<IComponentMeta>;
14
+
15
+ /**
16
+ * Getter for one meta by key.
17
+ *
18
+ * @param metaKey Key name of one meta data.
19
+ *
20
+ * @returns Associated meta **metaKey** value or undefined if not found.
21
+ */
22
+ getMeta<K extends keyof IComponentMeta>(metaKey : K) : IComponentMeta[K] | undefined {
23
+ return this._meta && this._meta[metaKey];
24
+ }
25
+
26
+ /**
27
+ * Setter for one meta by key.
28
+ *
29
+ * @param metaKey Key name of the meta data to update.
30
+ * @param metaValue New value to set into the meta data.
31
+ */
32
+ setMeta<K extends keyof IComponentMeta>(metaKey : K, metaValue : IComponentMeta[K]) : void {
33
+ this._meta[metaKey] = metaValue;
34
+ }
35
+
36
+ /**
37
+ * Returns multiple defined keys values of meta data.
38
+ *
39
+ * @param metaKeys Array of keys to filter for meta data. If not provided or empty, returns all keys.
40
+ *
41
+ * @returns Meta data object with **metaKeys** provided keys only.
42
+ */
43
+ getManyMeta(metaKeys : Array<keyof IComponentMeta> = []) : Partial<IComponentMeta> {
44
+ const arrayMeta: Partial<IComponentMeta> = {} as Partial<IComponentMeta>;
45
+ if (!metaKeys.length) {
46
+ return this._meta;
47
+ }
48
+
49
+ metaKeys.forEach((key) => {
50
+ if (this._meta && this._meta[key]) {
51
+ arrayMeta[key] = this._meta[key];
52
+ }
53
+ });
54
+ return arrayMeta;
55
+ }
56
+
57
+ /**
58
+ * Set multiple meta data.
59
+ *
60
+ * @param metaValues Object of meta data to set, according to the meta data property type.
61
+ */
62
+ setManyMeta(metaValues : Partial<IComponentMeta>) : void {
63
+ this._meta = { ...this._meta, ...metaValues };
64
+ }
65
+ }