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
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SpriteComponent = void 0;
|
|
13
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const shape_validators_1 = require("../_validators/shape-validators");
|
|
17
|
-
let SpriteComponent = class SpriteComponent extends definition_component_1.DefinitionComponent {
|
|
18
|
-
async process(definitions, output) {
|
|
19
|
-
await output.addFile({
|
|
20
|
-
path: '/_premade/assets/sprites.ts',
|
|
21
|
-
preText: `import { AssetDefinition } from 'bard-legends-framework';`,
|
|
22
|
-
variableName: 'SpriteAssets',
|
|
23
|
-
variableType: 'readonly AssetDefinition[]',
|
|
24
|
-
assetUrl: 'url',
|
|
25
|
-
variable: definitions.map(definition => ({
|
|
26
|
-
id: definition.id,
|
|
27
|
-
url: definition.url.url
|
|
28
|
-
}))
|
|
29
|
-
});
|
|
30
|
-
await output.addFile({
|
|
31
|
-
path: '/_premade/asset-definitions/sprites.ts',
|
|
32
|
-
preText: `import { SpriteDefinition } from "bard-legends-framework";`,
|
|
33
|
-
variableName: 'SpriteDefinitions',
|
|
34
|
-
variableType: 'Readonly<Record<string, SpriteDefinition>>',
|
|
35
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id', {
|
|
36
|
-
transformFunction: definition => ({
|
|
37
|
-
id: definition.id,
|
|
38
|
-
size: definition.url.size,
|
|
39
|
-
scale: definition.scale,
|
|
40
|
-
anchor: definition.anchor,
|
|
41
|
-
boundingShapes: definition.boundingShapes
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.SpriteComponent = SpriteComponent;
|
|
48
|
-
exports.SpriteComponent = SpriteComponent = __decorate([
|
|
49
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
50
|
-
componentName: 'SPRITE',
|
|
51
|
-
keyName: 'id',
|
|
52
|
-
validationSchema: joi_1.default.object()
|
|
53
|
-
.keys({
|
|
54
|
-
id: joi_1.default.string().required(),
|
|
55
|
-
url: joi_1.default.string().sprite().required(),
|
|
56
|
-
scale: joi_1.default.number().min(0.1).max(1).default(1).optional(),
|
|
57
|
-
anchor: joi_1.default.object()
|
|
58
|
-
.keys({
|
|
59
|
-
x: joi_1.default.number().min(0).max(1).required(),
|
|
60
|
-
y: joi_1.default.number().min(0).max(1).required()
|
|
61
|
-
})
|
|
62
|
-
.default({ x: 0.5, y: 0.5 })
|
|
63
|
-
.optional(),
|
|
64
|
-
boundingShapes: (0, shape_validators_1.PoligonSchema)().optional()
|
|
65
|
-
})
|
|
66
|
-
.positionOnSprite({
|
|
67
|
-
selectSpriteDefinition: (value) => value,
|
|
68
|
-
positionsJsonPath: ['$..boundingShapes[*][*]'],
|
|
69
|
-
includeRotationFromAnchor: false
|
|
70
|
-
})
|
|
71
|
-
.required()
|
|
72
|
-
})
|
|
73
|
-
], SpriteComponent);
|
|
74
|
-
//# sourceMappingURL=1-sprite.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
2
|
-
import { Output } from '../../framework/interfaces';
|
|
3
|
-
export type SpriteGroupID = string;
|
|
4
|
-
interface SpriteGroupDefinition {
|
|
5
|
-
id: string;
|
|
6
|
-
group: string[];
|
|
7
|
-
}
|
|
8
|
-
export declare class SpriteGroupComponent extends DefinitionComponent<SpriteGroupDefinition> {
|
|
9
|
-
process(definitions: SpriteGroupDefinition[], output: Output): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SpriteGroupComponent = void 0;
|
|
13
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const _1_sprite_1 = require("./1-sprite");
|
|
17
|
-
let SpriteGroupComponent = class SpriteGroupComponent extends definition_component_1.DefinitionComponent {
|
|
18
|
-
async process(definitions, output) {
|
|
19
|
-
await output.addFile({
|
|
20
|
-
path: '/_premade/asset-definitions/sprite-groups.ts',
|
|
21
|
-
preText: ``,
|
|
22
|
-
variableName: 'SpriteGroupDefinitions',
|
|
23
|
-
variableType: 'Readonly<Record<string, readonly string[]>>',
|
|
24
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id', { transformFunction: definition => definition.group })
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.SpriteGroupComponent = SpriteGroupComponent;
|
|
29
|
-
exports.SpriteGroupComponent = SpriteGroupComponent = __decorate([
|
|
30
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
31
|
-
componentName: 'SPRITE-GROUP',
|
|
32
|
-
keyName: 'id',
|
|
33
|
-
validationSchema: joi_1.default.object()
|
|
34
|
-
.keys({
|
|
35
|
-
id: joi_1.default.string().required(),
|
|
36
|
-
group: joi_1.default.array().items(joi_1.default.string().reference(_1_sprite_1.SpriteComponent)).unique().required()
|
|
37
|
-
})
|
|
38
|
-
.required()
|
|
39
|
-
})
|
|
40
|
-
], SpriteGroupComponent);
|
|
41
|
-
//# sourceMappingURL=2-sprite-group.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
2
|
-
import { Output } from '../../framework/interfaces';
|
|
3
|
-
export type FontID = string;
|
|
4
|
-
interface RawFontDefinition {
|
|
5
|
-
id: string;
|
|
6
|
-
fontFamily: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}
|
|
9
|
-
export interface FontDefinition {
|
|
10
|
-
readonly id: FontID;
|
|
11
|
-
readonly fontFamily: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class FontComponent extends DefinitionComponent<RawFontDefinition> {
|
|
14
|
-
constructor();
|
|
15
|
-
process(definitions: RawFontDefinition[], output: Output): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.FontComponent = void 0;
|
|
16
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
17
|
-
const joi_1 = __importDefault(require("joi"));
|
|
18
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
19
|
-
const index_file_generator_1 = require("../../framework/file-generators/index-file-generator");
|
|
20
|
-
const INDEX_ENTRY = `
|
|
21
|
-
export interface FontDefinition {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly fontFamily: string;
|
|
24
|
-
}`;
|
|
25
|
-
let FontComponent = class FontComponent extends definition_component_1.DefinitionComponent {
|
|
26
|
-
constructor() {
|
|
27
|
-
super();
|
|
28
|
-
index_file_generator_1.IndexFileGenerator.addPremadeInterface(INDEX_ENTRY);
|
|
29
|
-
}
|
|
30
|
-
async process(definitions, output) {
|
|
31
|
-
await output.addFile({
|
|
32
|
-
path: '/_premade/assets/fonts.ts',
|
|
33
|
-
preText: `import { AssetDefinition } from 'bard-legends-framework';`,
|
|
34
|
-
variableName: 'FontAssets',
|
|
35
|
-
variableType: 'readonly AssetDefinition[]',
|
|
36
|
-
assetUrl: 'url',
|
|
37
|
-
variable: definitions.map(definition => ({
|
|
38
|
-
id: definition.id,
|
|
39
|
-
url: definition.url
|
|
40
|
-
}))
|
|
41
|
-
});
|
|
42
|
-
await output.addFile({
|
|
43
|
-
path: '/_premade/asset-definitions/fonts.ts',
|
|
44
|
-
preText: `import { FontDefinition } from "../../";`,
|
|
45
|
-
variableName: 'FontDefinitions',
|
|
46
|
-
variableType: 'Readonly<Record<string, FontDefinition>>',
|
|
47
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id', {
|
|
48
|
-
transformFunction: definition => ({
|
|
49
|
-
id: definition.id,
|
|
50
|
-
fontFamily: definition.fontFamily
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
exports.FontComponent = FontComponent;
|
|
57
|
-
exports.FontComponent = FontComponent = __decorate([
|
|
58
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
59
|
-
componentName: 'FONT',
|
|
60
|
-
keyName: 'id',
|
|
61
|
-
validationSchema: joi_1.default.object()
|
|
62
|
-
.keys({
|
|
63
|
-
id: joi_1.default.string().required(),
|
|
64
|
-
fontFamily: joi_1.default.string().required(),
|
|
65
|
-
url: joi_1.default.string().path().required()
|
|
66
|
-
})
|
|
67
|
-
.required()
|
|
68
|
-
}),
|
|
69
|
-
__metadata("design:paramtypes", [])
|
|
70
|
-
], FontComponent);
|
|
71
|
-
//# sourceMappingURL=3-font.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ScriptDefinition } from 'script-engine-lib';
|
|
2
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
|
-
import { Output } from '../../framework/interfaces';
|
|
4
|
-
export declare class EventComponent extends DefinitionComponent<ScriptDefinition> {
|
|
5
|
-
process(definitions: ScriptDefinition[], output: Output): Promise<void>;
|
|
6
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __decorate =
|
|
3
|
-
(this && this.__decorate) ||
|
|
4
|
-
function (decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length,
|
|
6
|
-
r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
|
|
7
|
-
d;
|
|
8
|
-
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
|
|
9
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
-
else
|
|
11
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
12
|
-
if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
-
};
|
|
15
|
-
var __importDefault =
|
|
16
|
-
(this && this.__importDefault) ||
|
|
17
|
-
function (mod) {
|
|
18
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
21
|
-
exports.EventComponent = void 0;
|
|
22
|
-
const helpers_lib_1 = require('helpers-lib');
|
|
23
|
-
const joi_1 = __importDefault(require('joi'));
|
|
24
|
-
const definition_component_1 = require('../../decorators/definition-component');
|
|
25
|
-
const quotes_to_tags_helper_1 = require('./helpers/quotes-to-tags.helper');
|
|
26
|
-
// ---- Conditions ----
|
|
27
|
-
const ActionCommandSchema = () =>
|
|
28
|
-
joi_1.default.string().custom(value => ({
|
|
29
|
-
type: 'command',
|
|
30
|
-
value: value
|
|
31
|
-
}));
|
|
32
|
-
// ---- Branches ----
|
|
33
|
-
const JumpToSchema = joi_1.default
|
|
34
|
-
.object()
|
|
35
|
-
.keys({
|
|
36
|
-
jumpTo: joi_1.default.string().lazyReference('EVENT').required()
|
|
37
|
-
})
|
|
38
|
-
.custom(value => ({
|
|
39
|
-
type: 'jumpTo',
|
|
40
|
-
value: value.jumpTo
|
|
41
|
-
}));
|
|
42
|
-
const BranchByConditionSchema = joi_1.default
|
|
43
|
-
.object()
|
|
44
|
-
.keys({
|
|
45
|
-
branchByCondition: joi_1.default
|
|
46
|
-
.array()
|
|
47
|
-
.items(
|
|
48
|
-
joi_1.default.object().keys({
|
|
49
|
-
condition: joi_1.default.string().optional(),
|
|
50
|
-
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
51
|
-
})
|
|
52
|
-
)
|
|
53
|
-
.custom((array, helpers) => {
|
|
54
|
-
let length = array.length;
|
|
55
|
-
if (length > 1) {
|
|
56
|
-
for (let i = 0; i < length - 1; i++) {
|
|
57
|
-
if (array[i].condition === undefined) {
|
|
58
|
-
throw new Error(`Element at index ${i} must have "condition"`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
} else if (length === 1) {
|
|
62
|
-
if (array[0].condition === undefined) {
|
|
63
|
-
throw new Error('Single element must have "condition"');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return array;
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
.custom(value => ({
|
|
70
|
-
type: 'branchByCondition',
|
|
71
|
-
value: value.branchByCondition
|
|
72
|
-
}));
|
|
73
|
-
const BranchByPlayerChoiceSchema = joi_1.default
|
|
74
|
-
.object()
|
|
75
|
-
.keys({
|
|
76
|
-
branchByPlayerChoice: joi_1.default.array().items(
|
|
77
|
-
joi_1.default.object().keys({
|
|
78
|
-
text: joi_1.default.string().min(2).required(),
|
|
79
|
-
condition: joi_1.default.string().optional(),
|
|
80
|
-
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
81
|
-
})
|
|
82
|
-
)
|
|
83
|
-
})
|
|
84
|
-
.custom(value => ({
|
|
85
|
-
type: 'branchByPlayerChoice',
|
|
86
|
-
value: value.branchByPlayerChoice
|
|
87
|
-
}));
|
|
88
|
-
const BranchByChanceSchema = joi_1.default
|
|
89
|
-
.object()
|
|
90
|
-
.keys({
|
|
91
|
-
branchByChance: joi_1.default.array().items(
|
|
92
|
-
joi_1.default.object().keys({
|
|
93
|
-
label: joi_1.default.string().required(),
|
|
94
|
-
weight: joi_1.default.number().integer().min(1).max(100).required(),
|
|
95
|
-
condition: joi_1.default.string().optional(),
|
|
96
|
-
actions: joi_1.default.link('#EventActionsSchema').default([]).optional()
|
|
97
|
-
})
|
|
98
|
-
)
|
|
99
|
-
})
|
|
100
|
-
.custom(value => ({
|
|
101
|
-
type: 'branchByChance',
|
|
102
|
-
value: value.branchByChance
|
|
103
|
-
}));
|
|
104
|
-
// ---- Dialog ----
|
|
105
|
-
const DialogSchema = joi_1.default
|
|
106
|
-
.object()
|
|
107
|
-
.min(1)
|
|
108
|
-
.max(1)
|
|
109
|
-
.custom(value => {
|
|
110
|
-
let keys = Object.keys(value);
|
|
111
|
-
if (keys.length !== 1) {
|
|
112
|
-
throw new Error('object must have exactly one key/value pair');
|
|
113
|
-
}
|
|
114
|
-
let key = keys[0];
|
|
115
|
-
let text = value[key];
|
|
116
|
-
if (typeof text !== 'string') {
|
|
117
|
-
throw new Error('value must be a string');
|
|
118
|
-
}
|
|
119
|
-
text = quotes_to_tags_helper_1.QuotesToTagsHelper.convert(text);
|
|
120
|
-
return { type: 'dialog', value: { text, speaker: key } };
|
|
121
|
-
});
|
|
122
|
-
// ---- Main Schema ----
|
|
123
|
-
const ActionsSchema = () =>
|
|
124
|
-
joi_1.default
|
|
125
|
-
.array()
|
|
126
|
-
.items(
|
|
127
|
-
joi_1.default
|
|
128
|
-
.alternatives()
|
|
129
|
-
.conditional(joi_1.default.string(), {
|
|
130
|
-
then: ActionCommandSchema()
|
|
131
|
-
})
|
|
132
|
-
.conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
|
|
133
|
-
then: JumpToSchema
|
|
134
|
-
})
|
|
135
|
-
.conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
|
|
136
|
-
then: BranchByChanceSchema
|
|
137
|
-
})
|
|
138
|
-
.conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
|
|
139
|
-
then: BranchByConditionSchema
|
|
140
|
-
})
|
|
141
|
-
.conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
|
|
142
|
-
then: BranchByPlayerChoiceSchema
|
|
143
|
-
})
|
|
144
|
-
.conditional(joi_1.default.object().min(1).max(1).unknown(), {
|
|
145
|
-
then: DialogSchema
|
|
146
|
-
})
|
|
147
|
-
.error(errors =>
|
|
148
|
-
errors.map(error => {
|
|
149
|
-
if (error.code === 'alternatives.any') {
|
|
150
|
-
let allowedTypes = 'command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance';
|
|
151
|
-
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
152
|
-
}
|
|
153
|
-
return error;
|
|
154
|
-
})
|
|
155
|
-
)
|
|
156
|
-
)
|
|
157
|
-
.custom(array => {
|
|
158
|
-
let commandFoundAfterBranching = false;
|
|
159
|
-
let emptyStackRequiresBranchingFound = false;
|
|
160
|
-
array.forEach(action => {
|
|
161
|
-
if (emptyStackRequiresBranchingFound) {
|
|
162
|
-
commandFoundAfterBranching = true;
|
|
163
|
-
} else if (
|
|
164
|
-
action.type === 'branchByCondition' ||
|
|
165
|
-
action.type === 'branchByPlayerChoice' ||
|
|
166
|
-
action.type === 'branchByChance'
|
|
167
|
-
) {
|
|
168
|
-
emptyStackRequiresBranchingFound = true;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (commandFoundAfterBranching) {
|
|
172
|
-
throw new Error('There should not be any command after branching.');
|
|
173
|
-
} else {
|
|
174
|
-
return array;
|
|
175
|
-
}
|
|
176
|
-
})
|
|
177
|
-
.id('EventActionsSchema');
|
|
178
|
-
let EventComponent = class EventComponent extends definition_component_1.DefinitionComponent {
|
|
179
|
-
async process(definitions, output) {
|
|
180
|
-
await output.addFile({
|
|
181
|
-
path: '/_premade/events/events.ts',
|
|
182
|
-
preText: `import { ScriptDefinition } from "script-engine-lib";`,
|
|
183
|
-
variableName: 'EventDefinitions',
|
|
184
|
-
variableType: 'Readonly<Record<string, ScriptDefinition>>',
|
|
185
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
exports.EventComponent = EventComponent;
|
|
190
|
-
exports.EventComponent = EventComponent = __decorate(
|
|
191
|
-
[
|
|
192
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
193
|
-
componentName: 'EVENT',
|
|
194
|
-
keyName: 'id',
|
|
195
|
-
validationSchema: joi_1.default
|
|
196
|
-
.object()
|
|
197
|
-
.keys({
|
|
198
|
-
id: joi_1.default.string().required(),
|
|
199
|
-
actions: ActionsSchema().min(1).required()
|
|
200
|
-
})
|
|
201
|
-
.required()
|
|
202
|
-
})
|
|
203
|
-
],
|
|
204
|
-
EventComponent
|
|
205
|
-
);
|
|
206
|
-
//# sourceMappingURL=1-event.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ScriptDefinition } from 'script-engine-lib';
|
|
2
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
|
-
import { Output } from '../../framework/interfaces';
|
|
4
|
-
export type ScriptID = string;
|
|
5
|
-
export declare const ScriptNames: Set<string>;
|
|
6
|
-
export declare class ScriptComponent extends DefinitionComponent<ScriptDefinition> {
|
|
7
|
-
process(definitions: ScriptDefinition[], output: Output): Promise<void>;
|
|
8
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ScriptComponent = exports.ScriptNames = void 0;
|
|
13
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
14
|
-
const joi_1 = __importDefault(require("joi"));
|
|
15
|
-
const definition_component_1 = require("../../decorators/definition-component");
|
|
16
|
-
const validators_1 = require("./validators");
|
|
17
|
-
exports.ScriptNames = new Set();
|
|
18
|
-
const JumpToScriptSchema = joi_1.default.object()
|
|
19
|
-
.keys({
|
|
20
|
-
jumpTo: joi_1.default.string().lazyReference('SCRIPT').required()
|
|
21
|
-
})
|
|
22
|
-
.custom(value => ({
|
|
23
|
-
type: 'jumpTo',
|
|
24
|
-
value: value.jumpTo
|
|
25
|
-
}));
|
|
26
|
-
// ---- Main Schema ----
|
|
27
|
-
const ScriptActionId = 'ScriptActionsSchema';
|
|
28
|
-
const ActionsSchema = () => joi_1.default.array()
|
|
29
|
-
.items(joi_1.default.alternatives()
|
|
30
|
-
.conditional(joi_1.default.string(), {
|
|
31
|
-
then: (0, validators_1.ActionCommandSchema)()
|
|
32
|
-
})
|
|
33
|
-
.conditional(joi_1.default.object({ jumpTo: joi_1.default.exist() }).unknown(), {
|
|
34
|
-
then: JumpToScriptSchema
|
|
35
|
-
})
|
|
36
|
-
.conditional(joi_1.default.object({ branchByChance: joi_1.default.exist() }).unknown(), {
|
|
37
|
-
then: (0, validators_1.BranchByChanceSchema)(ScriptActionId)
|
|
38
|
-
})
|
|
39
|
-
.conditional(joi_1.default.object({ branchByCondition: joi_1.default.exist() }).unknown(), {
|
|
40
|
-
then: (0, validators_1.BranchByConditionSchema)(ScriptActionId)
|
|
41
|
-
})
|
|
42
|
-
.conditional(joi_1.default.object({ branchByPlayerChoice: joi_1.default.exist() }).unknown(), {
|
|
43
|
-
then: joi_1.default.forbidden().messages({
|
|
44
|
-
'any.unknown': 'branchByPlayerChoice is not allowed in scripts'
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
.conditional(joi_1.default.object().min(1).max(1).unknown(), {
|
|
48
|
-
then: joi_1.default.forbidden().messages({
|
|
49
|
-
'any.unknown': 'dialogs are not allowed in scripts'
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
.error(errors => errors.map(error => {
|
|
53
|
-
if (error.code === 'alternatives.any') {
|
|
54
|
-
let allowedTypes = 'command, jumpToScript, branchByCondition, branchByChance';
|
|
55
|
-
error.message = `${error.local.label} does not match any of the allowed types: ${allowedTypes}`;
|
|
56
|
-
}
|
|
57
|
-
return error;
|
|
58
|
-
})))
|
|
59
|
-
.custom((array) => {
|
|
60
|
-
let commandFoundAfterBranching = false;
|
|
61
|
-
let emptyStackRequiresBranchingFound = false;
|
|
62
|
-
array.forEach(action => {
|
|
63
|
-
if (emptyStackRequiresBranchingFound) {
|
|
64
|
-
commandFoundAfterBranching = true;
|
|
65
|
-
}
|
|
66
|
-
else if (action.type === 'branchByCondition' || action.type === 'branchByChance') {
|
|
67
|
-
emptyStackRequiresBranchingFound = true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
if (commandFoundAfterBranching) {
|
|
71
|
-
throw new Error('There should not be any command after branching.');
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return array;
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
.id(ScriptActionId);
|
|
78
|
-
let ScriptComponent = class ScriptComponent extends definition_component_1.DefinitionComponent {
|
|
79
|
-
async process(definitions, output) {
|
|
80
|
-
await output.addFile({
|
|
81
|
-
path: '/_premade/script-engine-definitions/scripts.ts',
|
|
82
|
-
preText: `import { ScriptDefinition } from "script-engine-lib";`,
|
|
83
|
-
variableName: 'ScriptDefinitions',
|
|
84
|
-
variableType: 'Readonly<Record<string, ScriptDefinition>>',
|
|
85
|
-
variable: helpers_lib_1.JsonHelper.arrayToObject(definitions, 'id')
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
exports.ScriptComponent = ScriptComponent;
|
|
90
|
-
exports.ScriptComponent = ScriptComponent = __decorate([
|
|
91
|
-
(0, definition_component_1.DefinitionComponentDecorator)({
|
|
92
|
-
componentName: 'SCRIPT',
|
|
93
|
-
keyName: 'id',
|
|
94
|
-
validationSchema: joi_1.default.object()
|
|
95
|
-
.keys({
|
|
96
|
-
id: joi_1.default.string().unique(exports.ScriptNames).required(),
|
|
97
|
-
actions: ActionsSchema().min(1).required()
|
|
98
|
-
})
|
|
99
|
-
.required()
|
|
100
|
-
})
|
|
101
|
-
], ScriptComponent);
|
|
102
|
-
//# sourceMappingURL=1-script.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ScriptTestActionDefinition } from 'script-engine-lib';
|
|
2
|
-
import { DefinitionComponent } from '../../decorators/definition-component';
|
|
3
|
-
import { Output } from '../../framework/interfaces';
|
|
4
|
-
interface EventTestCasesDefinition {
|
|
5
|
-
readonly actionsBeforeTesting: readonly ScriptTestActionDefinition[];
|
|
6
|
-
}
|
|
7
|
-
interface EventTestDefinition {
|
|
8
|
-
readonly event: string;
|
|
9
|
-
readonly cases: readonly EventTestCasesDefinition[];
|
|
10
|
-
}
|
|
11
|
-
export declare class EventTestComponent extends DefinitionComponent<EventTestDefinition> {
|
|
12
|
-
process(definitions: EventTestDefinition[], output: Output): Promise<void>;
|
|
13
|
-
private createEventTestSimulator;
|
|
14
|
-
private runTests;
|
|
15
|
-
private prepareErrorLog;
|
|
16
|
-
private printErrors;
|
|
17
|
-
}
|
|
18
|
-
export {};
|