definition-generator-framework 1.13.1 → 2.0.0-rc1

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 (173) hide show
  1. package/dist/index.d.mts +204 -0
  2. package/dist/index.d.ts +204 -17
  3. package/dist/index.js +43 -50
  4. package/dist/index.mjs +43 -0
  5. package/package.json +28 -14
  6. package/dist/_mocks/mocks.d.ts +0 -7
  7. package/dist/_mocks/mocks.js +0 -44
  8. package/dist/decorators/definition-component.d.ts +0 -18
  9. package/dist/decorators/definition-component.js +0 -52
  10. package/dist/decorators/definition-generator.d.ts +0 -11
  11. package/dist/decorators/definition-generator.js +0 -30
  12. package/dist/framework/context.d.ts +0 -24
  13. package/dist/framework/context.js +0 -64
  14. package/dist/framework/definition-component.d.ts +0 -20
  15. package/dist/framework/definition-component.js +0 -29
  16. package/dist/framework/definition-generator.d.ts +0 -11
  17. package/dist/framework/definition-generator.js +0 -22
  18. package/dist/framework/definition-store.d.ts +0 -25
  19. package/dist/framework/definition-store.js +0 -121
  20. package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
  21. package/dist/framework/file-content-generator/file-content-generator.js +0 -117
  22. package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
  23. package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
  24. package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
  25. package/dist/framework/file-generators/index-file-generator.js +0 -139
  26. package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
  27. package/dist/framework/file-generators/types-file-generator.js +0 -35
  28. package/dist/framework/framework.d.ts +0 -28
  29. package/dist/framework/framework.data.d.ts +0 -6
  30. package/dist/framework/framework.data.js +0 -17
  31. package/dist/framework/framework.js +0 -51
  32. package/dist/framework/framework.model.d.ts +0 -32
  33. package/dist/framework/framework.model.js +0 -3
  34. package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
  35. package/dist/framework/index-file-generator/index-file-generator.js +0 -118
  36. package/dist/framework/interfaces.d.ts +0 -46
  37. package/dist/framework/interfaces.js +0 -3
  38. package/dist/framework/kernel.d.ts +0 -12
  39. package/dist/framework/kernel.js +0 -308
  40. package/dist/helpers/common-functions/common-functions.d.ts +0 -10
  41. package/dist/helpers/common-functions/common-functions.js +0 -29
  42. package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
  43. package/dist/helpers/common-functions/common-functions.spec.js +0 -50
  44. package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
  45. package/dist/helpers/common-functions/common-functions.test.js +0 -51
  46. package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
  47. package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
  48. package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
  49. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
  50. package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
  51. package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
  52. package/dist/helpers/output-helper/output-helper.d.ts +0 -30
  53. package/dist/helpers/output-helper/output-helper.js +0 -143
  54. package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
  55. package/dist/helpers/output-helper/output-helper.spec.js +0 -261
  56. package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
  57. package/dist/helpers/output-helper/output-helper.test.js +0 -262
  58. package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
  59. package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
  60. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
  61. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
  62. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
  63. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
  64. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
  65. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
  66. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
  67. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
  68. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
  69. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
  70. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
  71. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
  72. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
  73. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
  74. package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
  75. package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
  76. package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
  77. package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
  78. package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
  79. package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
  80. package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
  81. package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
  82. package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
  83. package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
  84. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
  85. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
  86. package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
  87. package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
  88. package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
  89. package/dist/helpers/validator/joi-custom-validators.js +0 -54
  90. package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
  91. package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
  92. package/dist/helpers/validator/validator.d.ts +0 -21
  93. package/dist/helpers/validator/validator.js +0 -74
  94. package/dist/helpers/validator/validator.spec.d.ts +0 -1
  95. package/dist/helpers/validator/validator.spec.js +0 -332
  96. package/dist/helpers/validator/validator.test.d.ts +0 -1
  97. package/dist/helpers/validator/validator.test.js +0 -329
  98. package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
  99. package/dist/pipeline/1-select-definitions-helper.js +0 -76
  100. package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
  101. package/dist/pipeline/1-select-definitions.helper.js +0 -80
  102. package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
  103. package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
  104. package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
  105. package/dist/pipeline/1-select-definitions.spec.js +0 -140
  106. package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
  107. package/dist/pipeline/2-structure-parser.helper.js +0 -70
  108. package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
  109. package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
  110. package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
  111. package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
  112. package/dist/pipeline/3-config.d.ts +0 -9
  113. package/dist/pipeline/3-config.js +0 -36
  114. package/dist/pipeline/_mocks/index.d.ts +0 -13
  115. package/dist/pipeline/_mocks/index.js +0 -52
  116. package/dist/pipeline/parsers/array-parser.d.ts +0 -4
  117. package/dist/pipeline/parsers/array-parser.js +0 -69
  118. package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
  119. package/dist/pipeline/parsers/array-parser.spec.js +0 -128
  120. package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
  121. package/dist/pipeline/parsers/array-parser.test.js +0 -126
  122. package/dist/pipeline/parsers/object-parser.d.ts +0 -4
  123. package/dist/pipeline/parsers/object-parser.js +0 -135
  124. package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
  125. package/dist/pipeline/parsers/object-parser.spec.js +0 -179
  126. package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
  127. package/dist/pipeline/parsers/object-parser.test.js +0 -186
  128. package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
  129. package/dist/pipeline/parsers/primitive-parser.js +0 -111
  130. package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
  131. package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
  132. package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
  133. package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
  134. package/dist/pipeline/raw-data-parser.d.ts +0 -5
  135. package/dist/pipeline/raw-data-parser.js +0 -25
  136. package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
  137. package/dist/pre-made-components/_validators/shape-validators.js +0 -37
  138. package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
  139. package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
  140. package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
  141. package/dist/pre-made-components/assets/1-sprite.js +0 -74
  142. package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
  143. package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
  144. package/dist/pre-made-components/assets/3-font.d.ts +0 -17
  145. package/dist/pre-made-components/assets/3-font.js +0 -71
  146. package/dist/pre-made-components/events/1-event.d.ts +0 -6
  147. package/dist/pre-made-components/events/1-event.js +0 -206
  148. package/dist/pre-made-components/events/1-script.d.ts +0 -8
  149. package/dist/pre-made-components/events/1-script.js +0 -102
  150. package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
  151. package/dist/pre-made-components/events/2-event-test.js +0 -172
  152. package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
  153. package/dist/pre-made-components/events/2-script-test.js +0 -102
  154. package/dist/pre-made-components/events/3-event.d.ts +0 -7
  155. package/dist/pre-made-components/events/3-event.js +0 -100
  156. package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
  157. package/dist/pre-made-components/events/4-event-test.js +0 -89
  158. package/dist/pre-made-components/events/event-setup.d.ts +0 -13
  159. package/dist/pre-made-components/events/event-setup.js +0 -20
  160. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
  161. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
  162. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
  163. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
  164. package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
  165. package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
  166. package/dist/pre-made-components/events/script-setup.d.ts +0 -8
  167. package/dist/pre-made-components/events/script-setup.js +0 -16
  168. package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
  169. package/dist/pre-made-components/events/scripting-setup.js +0 -97
  170. package/dist/pre-made-components/events/validators.d.ts +0 -6
  171. package/dist/pre-made-components/events/validators.js +0 -96
  172. package/dist/setup.d.ts +0 -1
  173. package/dist/setup.js +0 -10
@@ -0,0 +1,204 @@
1
+ import Joi from 'joi';
2
+ import { Vec2, Vector } from 'helpers-lib';
3
+ import { ScriptDefinition, ScriptTestActionDefinition, ScriptEngineSimulatorFunctions } from 'script-engine-lib';
4
+
5
+ interface FileSystem {
6
+ existsSync: (path: string) => boolean;
7
+ }
8
+ interface AddFileOptions {
9
+ path: string;
10
+ variableName: string;
11
+ variable: any;
12
+ preText?: string | string[];
13
+ variableType?: string;
14
+ replaceMap?: {
15
+ target: string;
16
+ replace: string;
17
+ }[];
18
+ assetUrl?: string;
19
+ }
20
+ interface LocationInFile {
21
+ readonly path: string;
22
+ readonly line: number;
23
+ }
24
+ interface ErrorLog {
25
+ readonly description: string;
26
+ readonly location: LocationInFile;
27
+ }
28
+ type RawData = undefined | string | ParsedStructure[] | Record<string, ParsedStructure>;
29
+ interface ParsedStructure {
30
+ readonly rawData: RawData;
31
+ readonly line: number;
32
+ }
33
+ interface RawDefinition {
34
+ readonly componentName: string;
35
+ readonly parsedStructure: ParsedStructure;
36
+ readonly location: LocationInFile;
37
+ }
38
+ interface Output {
39
+ addFile: (request: AddFileOptions) => Promise<void>;
40
+ addError: (errorLog: ErrorLog) => void;
41
+ convertLocationInFileToLink: (location: LocationInFile) => string;
42
+ }
43
+
44
+ type DefinitionComponentClassType<T> = new (...args: any[]) => DefinitionComponent<T> | SingleDefinitionComponent<T>;
45
+ interface DefinitionComponentMeta {
46
+ componentName: string;
47
+ keyName?: string;
48
+ singleton?: boolean;
49
+ validationSchema: Joi.Schema;
50
+ }
51
+ declare function DefinitionComponentDecorator(meta: DefinitionComponentMeta): (ComponentClass: DefinitionComponentClassType<any>) => any;
52
+ declare abstract class DefinitionComponent<T> {
53
+ static getSchema(): Joi.Schema;
54
+ abstract process(definitions: T[], context: Output): Promise<void>;
55
+ }
56
+ declare abstract class SingleDefinitionComponent<T> {
57
+ static getSchema(): Joi.Schema;
58
+ abstract process(definitions: T, context: Output): Promise<void>;
59
+ }
60
+
61
+ interface DefinitionGeneratorMeta {
62
+ modules: DefinitionComponentClassType<any>[];
63
+ indexFilePretext: string;
64
+ outputIndexFile: string;
65
+ }
66
+ declare function DefinitionGeneratorDecorator(meta: DefinitionGeneratorMeta): (ModuleClass: DefinitionGeneratorClassType) => any;
67
+ type DefinitionGeneratorClassType = new (...args: any[]) => DefinitionGenerator;
68
+ declare abstract class DefinitionGenerator {
69
+ }
70
+
71
+ declare class DefinitionStore {
72
+ static getDefinitions<T>(definitionClass: DefinitionComponentClassType<T>): T[];
73
+ static getDefinition<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T | undefined;
74
+ static getDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T;
75
+ static getSingletonDefinition<T>(definitionClass: DefinitionComponentClassType<T>): T | undefined;
76
+ static getSingletonDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>): T;
77
+ static getLocationInFile<T>(definitionClass: DefinitionComponentClassType<T>, definition: T, path: readonly string[]): LocationInFile;
78
+ static getLocationInFileById<T>(definitionClass: DefinitionComponentClassType<T>, key: string, path: readonly string[]): LocationInFile;
79
+ }
80
+
81
+ type SpriteID = string;
82
+ interface RawSpriteDefinition {
83
+ id: string;
84
+ url: ValidatedSpriteUrl;
85
+ scale: number;
86
+ anchor: Vec2;
87
+ boundingShapes: Vec2[][];
88
+ }
89
+ declare class SpriteComponent extends DefinitionComponent<RawSpriteDefinition> {
90
+ process(definitions: RawSpriteDefinition[], output: Output): Promise<void>;
91
+ }
92
+
93
+ interface PositionOnSpriteValidationOptions {
94
+ selectSpriteDefinition: (value: any) => RawSpriteDefinition;
95
+ positionsJsonPath: string | string[];
96
+ includeRotationFromAnchor?: boolean;
97
+ checkIfPositionIsOnSprite?: boolean;
98
+ }
99
+
100
+ interface ReferenceCustomValidatorOptions {
101
+ additionalValidation?: Joi.Schema;
102
+ }
103
+ declare module 'joi' {
104
+ interface StringSchema {
105
+ unique(nameSpace: Set<string>): Joi.StringSchema;
106
+ path(): Joi.StringSchema;
107
+ sprite(): Joi.StringSchema;
108
+ reference(definitionComponentClass: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[], options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
109
+ lazyReference(componentName: string, options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
110
+ }
111
+ interface ObjectSchema {
112
+ /**
113
+ * Converts the values to relative position from anchor on sprite.
114
+ */
115
+ positionOnSprite(options: PositionOnSpriteValidationOptions): Joi.ObjectSchema;
116
+ }
117
+ }
118
+ declare class JoiCustomValidators {
119
+ static decorate(joi: object, fs: FileSystem): void;
120
+ }
121
+
122
+ interface ValidatedSpriteUrl {
123
+ readonly url: string;
124
+ readonly size: Vec2;
125
+ }
126
+
127
+ interface ValidatedItem<T> {
128
+ readonly definition: T;
129
+ readonly rawDefinition: RawDefinition;
130
+ }
131
+ declare class Validator {
132
+ static definitionToRawDefintion: Map<any, RawDefinition>;
133
+ static getRawDefinitions(componentName: string): RawDefinition[];
134
+ static validateAndConvert<T>(componentName: string, schema: Joi.AnySchema): ValidatedItem<T>[];
135
+ static validateAndConvertSingular<T>(componentName: string, schema: Joi.AnySchema): ValidatedItem<T> | undefined;
136
+ }
137
+
138
+ declare const PoligonSchema: () => Joi.ArraySchema<Vec2[][]>;
139
+ declare const Vec2Schema: () => Joi.ObjectSchema<Vec2>;
140
+ declare const HexColorSchema: () => Joi.StringSchema;
141
+ declare const RotationSchema: () => Joi.NumberSchema<number>;
142
+ declare const FixedArraySchema: (itemSchema: Joi.ObjectSchema<any>, size: number) => Joi.ArraySchema;
143
+
144
+ declare const PixelPerfectSpriteSchema: () => Joi.StringSchema;
145
+ declare const SpriteSchema: (restrictions?: {
146
+ size?: Vector;
147
+ scale?: number;
148
+ }) => Joi.StringSchema;
149
+
150
+ type SpriteGroupID = string;
151
+ interface SpriteGroupDefinition {
152
+ id: string;
153
+ group: string[];
154
+ }
155
+ declare class SpriteGroupComponent extends DefinitionComponent<SpriteGroupDefinition> {
156
+ process(definitions: SpriteGroupDefinition[], output: Output): Promise<void>;
157
+ }
158
+
159
+ type FontID = string;
160
+ interface RawFontDefinition {
161
+ id: string;
162
+ fontFamily: string;
163
+ url: string;
164
+ }
165
+ declare class FontComponent extends DefinitionComponent<RawFontDefinition> {
166
+ constructor();
167
+ process(definitions: RawFontDefinition[], output: Output): Promise<void>;
168
+ }
169
+
170
+ type ScriptID = string;
171
+ declare class ScriptComponent extends DefinitionComponent<ScriptDefinition> {
172
+ process(definitions: ScriptDefinition[], output: Output): Promise<void>;
173
+ }
174
+
175
+ interface ScriptTestCasesDefinition {
176
+ readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
177
+ }
178
+ interface ScriptTestDefinition {
179
+ readonly script: string;
180
+ readonly cases: readonly ScriptTestCasesDefinition[];
181
+ }
182
+
183
+ declare class ScriptTestComponent extends DefinitionComponent<ScriptTestDefinition> {
184
+ process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
185
+ }
186
+
187
+ type EventID = string;
188
+ declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
189
+ process(definitions: ScriptDefinition[], output: Output): Promise<void>;
190
+ }
191
+
192
+ declare class EventTestComponent extends DefinitionComponent<ScriptTestDefinition> {
193
+ process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
194
+ }
195
+
196
+ declare class ScriptTesting<ScriptInputType, EventInputType> {
197
+ constructor(scriptSimulatorFunctionsConstructor: new (input: ScriptInputType) => ScriptEngineSimulatorFunctions, eventSimulatorFunctionsConstructor: new (input: EventInputType) => ScriptEngineSimulatorFunctions, richTextTags: Set<string> | undefined);
198
+ setScriptInput(scriptId: string, input: ScriptInputType): void;
199
+ setEventInput(eventId: string, input: EventInputType): void;
200
+ addCustomScriptTestCase(customMessage: string, scriptId: string, testCase: ScriptTestCasesDefinition): void;
201
+ addCustomEventTestCase(customMessage: string, eventId: string, testCase: ScriptTestCasesDefinition): void;
202
+ }
203
+
204
+ export { DefinitionComponent, type DefinitionComponentClassType, DefinitionComponentDecorator, DefinitionGenerator, DefinitionGeneratorDecorator, DefinitionStore, type ErrorLog, EventComponent, type EventID, EventTestComponent, FixedArraySchema, FontComponent, type FontID, HexColorSchema, JoiCustomValidators, type LocationInFile, type Output, PixelPerfectSpriteSchema, PoligonSchema, RotationSchema, ScriptComponent, type ScriptID, ScriptTestComponent, ScriptTesting, SingleDefinitionComponent, SpriteComponent, SpriteGroupComponent, type SpriteGroupID, type SpriteID, SpriteSchema, type ValidatedSpriteUrl, Validator, Vec2Schema };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,204 @@
1
- export { DefinitionComponent, DefinitionComponentClassType, DefinitionComponentDecorator, SingleDefinitionComponent } from './decorators/definition-component';
2
- export { DefinitionGenerator, DefinitionGeneratorDecorator } from './decorators/definition-generator';
3
- export { DefinitionStore } from './framework/definition-store';
4
- export { ErrorLog, LocationInFile, Output } from './framework/interfaces';
5
- export { ValidatedSpriteUrl } from './helpers/validator/custom-validators/sprite.custom-validator';
6
- export { JoiCustomValidators } from './helpers/validator/joi-custom-validators';
7
- export { Validator } from './helpers/validator/validator';
8
- export * from './pre-made-components/_validators/shape-validators';
9
- export * from './pre-made-components/_validators/sprite-validators';
10
- export { SpriteComponent, SpriteID } from './pre-made-components/assets/1-sprite';
11
- export { SpriteGroupComponent, SpriteGroupID } from './pre-made-components/assets/2-sprite-group';
12
- export { FontComponent, FontID } from './pre-made-components/assets/3-font';
13
- export { ScriptComponent, ScriptID } from './pre-made-components/events/1-script';
14
- export { ScriptTestComponent } from './pre-made-components/events/2-script-test';
15
- export { EventComponent, EventID } from './pre-made-components/events/3-event';
16
- export { EventTestComponent } from './pre-made-components/events/4-event-test';
17
- export { ScriptTesting } from './pre-made-components/events/scripting-setup';
1
+ import Joi from 'joi';
2
+ import { Vec2, Vector } from 'helpers-lib';
3
+ import { ScriptDefinition, ScriptTestActionDefinition, ScriptEngineSimulatorFunctions } from 'script-engine-lib';
4
+
5
+ interface FileSystem {
6
+ existsSync: (path: string) => boolean;
7
+ }
8
+ interface AddFileOptions {
9
+ path: string;
10
+ variableName: string;
11
+ variable: any;
12
+ preText?: string | string[];
13
+ variableType?: string;
14
+ replaceMap?: {
15
+ target: string;
16
+ replace: string;
17
+ }[];
18
+ assetUrl?: string;
19
+ }
20
+ interface LocationInFile {
21
+ readonly path: string;
22
+ readonly line: number;
23
+ }
24
+ interface ErrorLog {
25
+ readonly description: string;
26
+ readonly location: LocationInFile;
27
+ }
28
+ type RawData = undefined | string | ParsedStructure[] | Record<string, ParsedStructure>;
29
+ interface ParsedStructure {
30
+ readonly rawData: RawData;
31
+ readonly line: number;
32
+ }
33
+ interface RawDefinition {
34
+ readonly componentName: string;
35
+ readonly parsedStructure: ParsedStructure;
36
+ readonly location: LocationInFile;
37
+ }
38
+ interface Output {
39
+ addFile: (request: AddFileOptions) => Promise<void>;
40
+ addError: (errorLog: ErrorLog) => void;
41
+ convertLocationInFileToLink: (location: LocationInFile) => string;
42
+ }
43
+
44
+ type DefinitionComponentClassType<T> = new (...args: any[]) => DefinitionComponent<T> | SingleDefinitionComponent<T>;
45
+ interface DefinitionComponentMeta {
46
+ componentName: string;
47
+ keyName?: string;
48
+ singleton?: boolean;
49
+ validationSchema: Joi.Schema;
50
+ }
51
+ declare function DefinitionComponentDecorator(meta: DefinitionComponentMeta): (ComponentClass: DefinitionComponentClassType<any>) => any;
52
+ declare abstract class DefinitionComponent<T> {
53
+ static getSchema(): Joi.Schema;
54
+ abstract process(definitions: T[], context: Output): Promise<void>;
55
+ }
56
+ declare abstract class SingleDefinitionComponent<T> {
57
+ static getSchema(): Joi.Schema;
58
+ abstract process(definitions: T, context: Output): Promise<void>;
59
+ }
60
+
61
+ interface DefinitionGeneratorMeta {
62
+ modules: DefinitionComponentClassType<any>[];
63
+ indexFilePretext: string;
64
+ outputIndexFile: string;
65
+ }
66
+ declare function DefinitionGeneratorDecorator(meta: DefinitionGeneratorMeta): (ModuleClass: DefinitionGeneratorClassType) => any;
67
+ type DefinitionGeneratorClassType = new (...args: any[]) => DefinitionGenerator;
68
+ declare abstract class DefinitionGenerator {
69
+ }
70
+
71
+ declare class DefinitionStore {
72
+ static getDefinitions<T>(definitionClass: DefinitionComponentClassType<T>): T[];
73
+ static getDefinition<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T | undefined;
74
+ static getDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T;
75
+ static getSingletonDefinition<T>(definitionClass: DefinitionComponentClassType<T>): T | undefined;
76
+ static getSingletonDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>): T;
77
+ static getLocationInFile<T>(definitionClass: DefinitionComponentClassType<T>, definition: T, path: readonly string[]): LocationInFile;
78
+ static getLocationInFileById<T>(definitionClass: DefinitionComponentClassType<T>, key: string, path: readonly string[]): LocationInFile;
79
+ }
80
+
81
+ type SpriteID = string;
82
+ interface RawSpriteDefinition {
83
+ id: string;
84
+ url: ValidatedSpriteUrl;
85
+ scale: number;
86
+ anchor: Vec2;
87
+ boundingShapes: Vec2[][];
88
+ }
89
+ declare class SpriteComponent extends DefinitionComponent<RawSpriteDefinition> {
90
+ process(definitions: RawSpriteDefinition[], output: Output): Promise<void>;
91
+ }
92
+
93
+ interface PositionOnSpriteValidationOptions {
94
+ selectSpriteDefinition: (value: any) => RawSpriteDefinition;
95
+ positionsJsonPath: string | string[];
96
+ includeRotationFromAnchor?: boolean;
97
+ checkIfPositionIsOnSprite?: boolean;
98
+ }
99
+
100
+ interface ReferenceCustomValidatorOptions {
101
+ additionalValidation?: Joi.Schema;
102
+ }
103
+ declare module 'joi' {
104
+ interface StringSchema {
105
+ unique(nameSpace: Set<string>): Joi.StringSchema;
106
+ path(): Joi.StringSchema;
107
+ sprite(): Joi.StringSchema;
108
+ reference(definitionComponentClass: DefinitionComponentClassType<any> | DefinitionComponentClassType<any>[], options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
109
+ lazyReference(componentName: string, options?: ReferenceCustomValidatorOptions): Joi.StringSchema;
110
+ }
111
+ interface ObjectSchema {
112
+ /**
113
+ * Converts the values to relative position from anchor on sprite.
114
+ */
115
+ positionOnSprite(options: PositionOnSpriteValidationOptions): Joi.ObjectSchema;
116
+ }
117
+ }
118
+ declare class JoiCustomValidators {
119
+ static decorate(joi: object, fs: FileSystem): void;
120
+ }
121
+
122
+ interface ValidatedSpriteUrl {
123
+ readonly url: string;
124
+ readonly size: Vec2;
125
+ }
126
+
127
+ interface ValidatedItem<T> {
128
+ readonly definition: T;
129
+ readonly rawDefinition: RawDefinition;
130
+ }
131
+ declare class Validator {
132
+ static definitionToRawDefintion: Map<any, RawDefinition>;
133
+ static getRawDefinitions(componentName: string): RawDefinition[];
134
+ static validateAndConvert<T>(componentName: string, schema: Joi.AnySchema): ValidatedItem<T>[];
135
+ static validateAndConvertSingular<T>(componentName: string, schema: Joi.AnySchema): ValidatedItem<T> | undefined;
136
+ }
137
+
138
+ declare const PoligonSchema: () => Joi.ArraySchema<Vec2[][]>;
139
+ declare const Vec2Schema: () => Joi.ObjectSchema<Vec2>;
140
+ declare const HexColorSchema: () => Joi.StringSchema;
141
+ declare const RotationSchema: () => Joi.NumberSchema<number>;
142
+ declare const FixedArraySchema: (itemSchema: Joi.ObjectSchema<any>, size: number) => Joi.ArraySchema;
143
+
144
+ declare const PixelPerfectSpriteSchema: () => Joi.StringSchema;
145
+ declare const SpriteSchema: (restrictions?: {
146
+ size?: Vector;
147
+ scale?: number;
148
+ }) => Joi.StringSchema;
149
+
150
+ type SpriteGroupID = string;
151
+ interface SpriteGroupDefinition {
152
+ id: string;
153
+ group: string[];
154
+ }
155
+ declare class SpriteGroupComponent extends DefinitionComponent<SpriteGroupDefinition> {
156
+ process(definitions: SpriteGroupDefinition[], output: Output): Promise<void>;
157
+ }
158
+
159
+ type FontID = string;
160
+ interface RawFontDefinition {
161
+ id: string;
162
+ fontFamily: string;
163
+ url: string;
164
+ }
165
+ declare class FontComponent extends DefinitionComponent<RawFontDefinition> {
166
+ constructor();
167
+ process(definitions: RawFontDefinition[], output: Output): Promise<void>;
168
+ }
169
+
170
+ type ScriptID = string;
171
+ declare class ScriptComponent extends DefinitionComponent<ScriptDefinition> {
172
+ process(definitions: ScriptDefinition[], output: Output): Promise<void>;
173
+ }
174
+
175
+ interface ScriptTestCasesDefinition {
176
+ readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
177
+ }
178
+ interface ScriptTestDefinition {
179
+ readonly script: string;
180
+ readonly cases: readonly ScriptTestCasesDefinition[];
181
+ }
182
+
183
+ declare class ScriptTestComponent extends DefinitionComponent<ScriptTestDefinition> {
184
+ process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
185
+ }
186
+
187
+ type EventID = string;
188
+ declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
189
+ process(definitions: ScriptDefinition[], output: Output): Promise<void>;
190
+ }
191
+
192
+ declare class EventTestComponent extends DefinitionComponent<ScriptTestDefinition> {
193
+ process(definitions: ScriptTestDefinition[], output: Output): Promise<void>;
194
+ }
195
+
196
+ declare class ScriptTesting<ScriptInputType, EventInputType> {
197
+ constructor(scriptSimulatorFunctionsConstructor: new (input: ScriptInputType) => ScriptEngineSimulatorFunctions, eventSimulatorFunctionsConstructor: new (input: EventInputType) => ScriptEngineSimulatorFunctions, richTextTags: Set<string> | undefined);
198
+ setScriptInput(scriptId: string, input: ScriptInputType): void;
199
+ setEventInput(eventId: string, input: EventInputType): void;
200
+ addCustomScriptTestCase(customMessage: string, scriptId: string, testCase: ScriptTestCasesDefinition): void;
201
+ addCustomEventTestCase(customMessage: string, eventId: string, testCase: ScriptTestCasesDefinition): void;
202
+ }
203
+
204
+ export { DefinitionComponent, type DefinitionComponentClassType, DefinitionComponentDecorator, DefinitionGenerator, DefinitionGeneratorDecorator, DefinitionStore, type ErrorLog, EventComponent, type EventID, EventTestComponent, FixedArraySchema, FontComponent, type FontID, HexColorSchema, JoiCustomValidators, type LocationInFile, type Output, PixelPerfectSpriteSchema, PoligonSchema, RotationSchema, ScriptComponent, type ScriptID, ScriptTestComponent, ScriptTesting, SingleDefinitionComponent, SpriteComponent, SpriteGroupComponent, type SpriteGroupID, type SpriteID, SpriteSchema, type ValidatedSpriteUrl, Validator, Vec2Schema };