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.
- package/dist/index.d.mts +204 -0
- package/dist/index.d.ts +204 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +28 -14
- package/dist/_mocks/mocks.d.ts +0 -7
- package/dist/_mocks/mocks.js +0 -44
- package/dist/decorators/definition-component.d.ts +0 -18
- package/dist/decorators/definition-component.js +0 -52
- package/dist/decorators/definition-generator.d.ts +0 -11
- package/dist/decorators/definition-generator.js +0 -30
- package/dist/framework/context.d.ts +0 -24
- package/dist/framework/context.js +0 -64
- package/dist/framework/definition-component.d.ts +0 -20
- package/dist/framework/definition-component.js +0 -29
- package/dist/framework/definition-generator.d.ts +0 -11
- package/dist/framework/definition-generator.js +0 -22
- package/dist/framework/definition-store.d.ts +0 -25
- package/dist/framework/definition-store.js +0 -121
- package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
- package/dist/framework/file-content-generator/file-content-generator.js +0 -117
- package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
- package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
- package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
- package/dist/framework/file-generators/index-file-generator.js +0 -139
- package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
- package/dist/framework/file-generators/types-file-generator.js +0 -35
- package/dist/framework/framework.d.ts +0 -28
- package/dist/framework/framework.data.d.ts +0 -6
- package/dist/framework/framework.data.js +0 -17
- package/dist/framework/framework.js +0 -51
- package/dist/framework/framework.model.d.ts +0 -32
- package/dist/framework/framework.model.js +0 -3
- package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
- package/dist/framework/index-file-generator/index-file-generator.js +0 -118
- package/dist/framework/interfaces.d.ts +0 -46
- package/dist/framework/interfaces.js +0 -3
- package/dist/framework/kernel.d.ts +0 -12
- package/dist/framework/kernel.js +0 -308
- package/dist/helpers/common-functions/common-functions.d.ts +0 -10
- package/dist/helpers/common-functions/common-functions.js +0 -29
- package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js +0 -50
- package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.test.js +0 -51
- package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
- package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
- package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
- package/dist/helpers/output-helper/output-helper.d.ts +0 -30
- package/dist/helpers/output-helper/output-helper.js +0 -143
- package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.spec.js +0 -261
- package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.test.js +0 -262
- package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
- package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
- package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
- package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
- package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
- package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
- package/dist/helpers/validator/joi-custom-validators.js +0 -54
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
- package/dist/helpers/validator/validator.d.ts +0 -21
- package/dist/helpers/validator/validator.js +0 -74
- package/dist/helpers/validator/validator.spec.d.ts +0 -1
- package/dist/helpers/validator/validator.spec.js +0 -332
- package/dist/helpers/validator/validator.test.d.ts +0 -1
- package/dist/helpers/validator/validator.test.js +0 -329
- package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions-helper.js +0 -76
- package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions.helper.js +0 -80
- package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
- package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.spec.js +0 -140
- package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
- package/dist/pipeline/2-structure-parser.helper.js +0 -70
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
- package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
- package/dist/pipeline/3-config.d.ts +0 -9
- package/dist/pipeline/3-config.js +0 -36
- package/dist/pipeline/_mocks/index.d.ts +0 -13
- package/dist/pipeline/_mocks/index.js +0 -52
- package/dist/pipeline/parsers/array-parser.d.ts +0 -4
- package/dist/pipeline/parsers/array-parser.js +0 -69
- package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js +0 -128
- package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.test.js +0 -126
- package/dist/pipeline/parsers/object-parser.d.ts +0 -4
- package/dist/pipeline/parsers/object-parser.js +0 -135
- package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js +0 -179
- package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.test.js +0 -186
- package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
- package/dist/pipeline/parsers/primitive-parser.js +0 -111
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
- package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
- package/dist/pipeline/raw-data-parser.d.ts +0 -5
- package/dist/pipeline/raw-data-parser.js +0 -25
- package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/shape-validators.js +0 -37
- package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
- package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
- package/dist/pre-made-components/assets/1-sprite.js +0 -74
- package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
- package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
- package/dist/pre-made-components/assets/3-font.d.ts +0 -17
- package/dist/pre-made-components/assets/3-font.js +0 -71
- package/dist/pre-made-components/events/1-event.d.ts +0 -6
- package/dist/pre-made-components/events/1-event.js +0 -206
- package/dist/pre-made-components/events/1-script.d.ts +0 -8
- package/dist/pre-made-components/events/1-script.js +0 -102
- package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
- package/dist/pre-made-components/events/2-event-test.js +0 -172
- package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
- package/dist/pre-made-components/events/2-script-test.js +0 -102
- package/dist/pre-made-components/events/3-event.d.ts +0 -7
- package/dist/pre-made-components/events/3-event.js +0 -100
- package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
- package/dist/pre-made-components/events/4-event-test.js +0 -89
- package/dist/pre-made-components/events/event-setup.d.ts +0 -13
- package/dist/pre-made-components/events/event-setup.js +0 -20
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
- package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
- package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
- package/dist/pre-made-components/events/script-setup.d.ts +0 -8
- package/dist/pre-made-components/events/script-setup.js +0 -16
- package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
- package/dist/pre-made-components/events/scripting-setup.js +0 -97
- package/dist/pre-made-components/events/validators.d.ts +0 -6
- package/dist/pre-made-components/events/validators.js +0 -96
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
package/dist/index.d.mts
ADDED
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 };
|