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
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefinitionGenerator = exports.DefinitionGeneratorDecorator = void 0;
4
- const kernel_1 = require("../framework/kernel");
5
- const _1_script_1 = require("../pre-made-components/events/1-script");
6
- const _2_script_test_1 = require("../pre-made-components/events/2-script-test");
7
- const _3_event_1 = require("../pre-made-components/events/3-event");
8
- const _4_event_test_1 = require("../pre-made-components/events/4-event-test");
9
- const scripting_setup_1 = require("../pre-made-components/events/scripting-setup");
10
- let moduleIsRegistered = false;
11
- function DefinitionGeneratorDecorator(meta) {
12
- return function (ModuleClass) {
13
- if (moduleIsRegistered) {
14
- console.error('There can be only one definition generator!');
15
- }
16
- else {
17
- moduleIsRegistered = true;
18
- let modules = [...meta.modules];
19
- if (scripting_setup_1.ScriptTestingInternal.isInitialized) {
20
- modules = [_1_script_1.ScriptComponent, _3_event_1.EventComponent, ...modules, _2_script_test_1.ScriptTestComponent, _4_event_test_1.EventTestComponent];
21
- }
22
- kernel_1.Kernel.process(modules, meta.indexFilePretext, meta.outputIndexFile);
23
- }
24
- };
25
- }
26
- exports.DefinitionGeneratorDecorator = DefinitionGeneratorDecorator;
27
- class DefinitionGenerator {
28
- }
29
- exports.DefinitionGenerator = DefinitionGenerator;
30
- //# sourceMappingURL=definition-generator.js.map
@@ -1,24 +0,0 @@
1
- import { DefinitionComponentMeta } from '../decorators/definition-component';
2
- import { AddFileOptions, Config, ErrorLog, FileInfo, RawDefinition } from './interfaces';
3
- export declare class Context {
4
- static compilerExecutionPath: string;
5
- static outputPath: string;
6
- static config: Config;
7
- static rawDefinitions: RawDefinition[];
8
- static files: FileInfo[];
9
- static output: FileInfo[];
10
- static exports: {
11
- variableName: string;
12
- path: string;
13
- }[];
14
- static componentInProgressData: {
15
- meta: DefinitionComponentMeta;
16
- idToReferencesMap: Map<string, Set<string>>;
17
- } | undefined;
18
- static addFile(request: AddFileOptions): Promise<void>;
19
- static get successful(): boolean;
20
- static addErrorLog(errorLog: ErrorLog | ErrorLog[], priority?: 'lowPriority' | 'default'): void;
21
- static flushErrorLogs(): void;
22
- static errorLogs: ErrorLog[];
23
- private static errorLogBuffer;
24
- }
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Context = void 0;
4
- const helpers_lib_1 = require("helpers-lib");
5
- const file_content_generator_1 = require("./file-content-generator/file-content-generator");
6
- class Context {
7
- static { this.compilerExecutionPath = ''; }
8
- static { this.outputPath = ''; }
9
- static { this.config = {
10
- projectRoot: '',
11
- compilerModulesPath: ''
12
- }; }
13
- static { this.rawDefinitions = []; }
14
- static { this.files = []; }
15
- static { this.output = []; }
16
- static { this.exports = []; }
17
- // Used for checking self referenced definitions "lazyReference"
18
- static { this.componentInProgressData = undefined; }
19
- static async addFile(request) {
20
- this.exports.push({ variableName: request.variableName, path: request.path });
21
- this.output.push({
22
- path: request.path,
23
- content: await file_content_generator_1.FileContentGenerator.generate({
24
- preText: helpers_lib_1.Comparator.isArray(request.preText) ? request.preText.join('\n') : request.preText,
25
- variableName: request.variableName,
26
- variableType: request.variableType,
27
- variable: request.variable,
28
- replaceMap: request.replaceMap,
29
- filePath: request.path,
30
- assetUrl: request.assetUrl
31
- })
32
- });
33
- }
34
- // ERROR LOGS
35
- static get successful() {
36
- return this.errorLogs.length === 0;
37
- }
38
- static addErrorLog(errorLog, priority = 'default') {
39
- if (helpers_lib_1.Comparator.isArray(errorLog)) {
40
- if (priority === 'lowPriority') {
41
- this.errorLogBuffer = [...errorLog, ...this.errorLogBuffer];
42
- }
43
- else {
44
- this.errorLogBuffer.push(...errorLog);
45
- }
46
- }
47
- else {
48
- if (priority === 'lowPriority') {
49
- this.errorLogBuffer = [errorLog, ...this.errorLogBuffer];
50
- }
51
- else {
52
- this.errorLogBuffer.push(errorLog);
53
- }
54
- }
55
- }
56
- static flushErrorLogs() {
57
- this.errorLogs = [...this.errorLogBuffer, ...this.errorLogs];
58
- this.errorLogBuffer = [];
59
- }
60
- static { this.errorLogs = []; }
61
- static { this.errorLogBuffer = []; }
62
- }
63
- exports.Context = Context;
64
- //# sourceMappingURL=context.js.map
@@ -1,20 +0,0 @@
1
- import Joi from 'joi';
2
- import { Output } from './framework.model';
3
- export type DefinitionComponentClassType<T> = new (...args: any[]) => DefinitionComponent<T> | SingleDefinitionComponent<T>;
4
- export interface DefinitionComponentMeta {
5
- componentName: string;
6
- keyName?: string;
7
- singleton?: boolean;
8
- validationSchema: Joi.Schema;
9
- }
10
- export declare function DefinitionComponentDecorator(
11
- meta: DefinitionComponentMeta
12
- ): (ComponentClass: DefinitionComponentClassType<any>) => any;
13
- export declare abstract class DefinitionComponent<T> {
14
- static getSchema(): Joi.Schema;
15
- abstract process(definitions: T[], context: Output): Promise<void>;
16
- }
17
- export declare abstract class SingleDefinitionComponent<T> {
18
- static getSchema(): Joi.Schema;
19
- abstract process(definitions: T, context: Output): Promise<void>;
20
- }
@@ -1,29 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.SingleDefinitionComponent = exports.DefinitionComponent = exports.DefinitionComponentDecorator = void 0;
4
- const definition_store_1 = require('./definition-store');
5
- function DefinitionComponentDecorator(meta) {
6
- return function (ComponentClass) {
7
- definition_store_1.FrameworkData.definitionComponentNames.add(meta.componentName);
8
- ComponentClass.$meta = {
9
- componentName: meta.componentName,
10
- keyName: meta.keyName,
11
- singleton: meta.singleton,
12
- validationSchema: meta.validationSchema
13
- };
14
- };
15
- }
16
- exports.DefinitionComponentDecorator = DefinitionComponentDecorator;
17
- class DefinitionComponent {
18
- static getSchema() {
19
- return this.$meta.validationSchema;
20
- }
21
- }
22
- exports.DefinitionComponent = DefinitionComponent;
23
- class SingleDefinitionComponent {
24
- static getSchema() {
25
- return this.$meta.validationSchema;
26
- }
27
- }
28
- exports.SingleDefinitionComponent = SingleDefinitionComponent;
29
- //# sourceMappingURL=definition-component.js.map
@@ -1,11 +0,0 @@
1
- import { DefinitionComponentClassType } from './definition-component';
2
- interface DefinitionGeneratorMeta {
3
- modules: DefinitionComponentClassType<any>[];
4
- interfaces: string;
5
- }
6
- export declare function DefinitionGeneratorDecorator(
7
- meta: DefinitionGeneratorMeta
8
- ): (ModuleClass: DefinitionGeneratorClassType) => any;
9
- export type DefinitionGeneratorClassType = new (...args: any[]) => DefinitionGenerator;
10
- export declare abstract class DefinitionGenerator {}
11
- export {};
@@ -1,22 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.DefinitionGenerator = exports.DefinitionGeneratorDecorator = void 0;
4
- const definition_store_1 = require('./definition-store');
5
- const kernel_1 = require('./kernel');
6
- let ModuleIsRegistered = false;
7
- function DefinitionGeneratorDecorator(meta) {
8
- return function (ModuleClass) {
9
- if (ModuleIsRegistered) {
10
- console.error('There can be only one definition module!');
11
- } else {
12
- ModuleIsRegistered = true;
13
- definition_store_1.FrameworkData.modules.push(...meta.modules);
14
- definition_store_1.FrameworkData.interfaces = meta.interfaces;
15
- kernel_1.Kernel.process();
16
- }
17
- };
18
- }
19
- exports.DefinitionGeneratorDecorator = DefinitionGeneratorDecorator;
20
- class DefinitionGenerator {}
21
- exports.DefinitionGenerator = DefinitionGenerator;
22
- //# sourceMappingURL=definition-generator.js.map
@@ -1,25 +0,0 @@
1
- import { DefinitionComponentClassType } from '../decorators/definition-component';
2
- import { LocationInFile } from './interfaces';
3
- export declare class DefinitionStore {
4
- private static idToRawDefinitionsMap;
5
- private static definitionToRawDefinitionsMap;
6
- private static definitionsMap;
7
- private static componentNameToComponentMap;
8
- static getDefinitions<T>(definitionClass: DefinitionComponentClassType<T>): T[];
9
- static getDefinition<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T | undefined;
10
- static getDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>, key: string): T;
11
- static getSingletonDefinition<T>(definitionClass: DefinitionComponentClassType<T>): T | undefined;
12
- static getSingletonDefinitionOrFail<T>(definitionClass: DefinitionComponentClassType<T>): T;
13
- static getLocationInFile<T>(definitionClass: DefinitionComponentClassType<T>, definition: T, path: readonly string[]): LocationInFile;
14
- static getLocationInFileById<T>(definitionClass: DefinitionComponentClassType<T>, key: string, path: readonly string[]): LocationInFile;
15
- private static isValidComponentName;
16
- private static getComponentClass;
17
- private static setComponents;
18
- private static setDefinition;
19
- private static setSingletonDefinition;
20
- private static isRawDefinitionExists;
21
- private static getRawDefinition;
22
- private static setRawDefinitionByKey;
23
- private static setRawDefinition;
24
- private static getComponentName;
25
- }
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefinitionStore = void 0;
4
- const helpers_lib_1 = require("helpers-lib");
5
- const raw_definition_helper_1 = require("../helpers/raw-definition-helper/raw-definition.helper");
6
- class DefinitionStore {
7
- static { this.idToRawDefinitionsMap = new Map(); }
8
- static { this.definitionToRawDefinitionsMap = new Map(); }
9
- static { this.definitionsMap = new Map(); }
10
- static { this.componentNameToComponentMap = new Map(); }
11
- static getDefinitions(definitionClass) {
12
- let classMap = this.definitionsMap.get(this.getComponentName(definitionClass));
13
- if (classMap) {
14
- return Array.from(classMap.values());
15
- }
16
- else {
17
- return [];
18
- }
19
- }
20
- static getDefinition(definitionClass, key) {
21
- if (!definitionClass.$meta.keyName) {
22
- throw new Error(`"${definitionClass.name}" doesn't have a keyName, getDefinition cannot be called on it.`);
23
- }
24
- return this.definitionsMap.get(this.getComponentName(definitionClass))?.get(key);
25
- }
26
- static getDefinitionOrFail(definitionClass, key) {
27
- let definition = this.getDefinition(definitionClass, key);
28
- if (!definition) {
29
- throw new Error(`No result found for "${key}" in "${definitionClass.name}".`);
30
- }
31
- return definition;
32
- }
33
- static getSingletonDefinition(definitionClass) {
34
- return this.definitionsMap.get(this.getComponentName(definitionClass))?.get(this.getComponentName(definitionClass));
35
- }
36
- static getSingletonDefinitionOrFail(definitionClass) {
37
- let definition = this.getSingletonDefinition(definitionClass);
38
- if (!definition) {
39
- throw new Error(`No result found for "${definitionClass.name}".`);
40
- }
41
- return definition;
42
- }
43
- static getLocationInFile(definitionClass, definition, path) {
44
- let rawDefinition = this.definitionToRawDefinitionsMap.get(definitionClass.name)?.get(definition);
45
- if (!rawDefinition) {
46
- throw new Error(`No raw definition found for "${definition}" in "${definitionClass.name}".`);
47
- }
48
- return {
49
- line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
50
- path: rawDefinition.location.path
51
- };
52
- }
53
- static getLocationInFileById(definitionClass, key, path) {
54
- let rawDefinition = this.getRawDefinition(definitionClass, key);
55
- if (!rawDefinition) {
56
- throw new Error(`No raw definition found for "${key}" in "${definitionClass.name}".`);
57
- }
58
- return {
59
- line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
60
- path: rawDefinition.location.path
61
- };
62
- }
63
- static isValidComponentName(componentName) {
64
- return this.definitionsMap.has(componentName);
65
- }
66
- static getComponentClass(componentName) {
67
- let componentClass = this.componentNameToComponentMap.get(componentName);
68
- if (!componentClass) {
69
- throw new Error(`No component found for "${componentName}".`);
70
- }
71
- return componentClass;
72
- }
73
- static setComponents(componentNameToComponentMap) {
74
- componentNameToComponentMap.forEach((_, componentName) => {
75
- this.definitionsMap.set(componentName, new Map());
76
- });
77
- this.componentNameToComponentMap = componentNameToComponentMap;
78
- }
79
- static setDefinition(definitionClass, key, definition) {
80
- let classMap = this.definitionsMap.get(this.getComponentName(definitionClass));
81
- if (classMap) {
82
- classMap.set(key, helpers_lib_1.JsonHelper.deepCopy(definition));
83
- }
84
- }
85
- static setSingletonDefinition(definitionClass, definition) {
86
- let componentName = this.getComponentName(definitionClass);
87
- let classMap = this.definitionsMap.get(componentName);
88
- if (classMap) {
89
- classMap.set(componentName, helpers_lib_1.JsonHelper.deepCopy(definition));
90
- }
91
- }
92
- static isRawDefinitionExists(definitionClass, key) {
93
- return this.idToRawDefinitionsMap.get(definitionClass.name)?.has(key) ? true : false;
94
- }
95
- static getRawDefinition(definitionClass, key) {
96
- return this.idToRawDefinitionsMap.get(definitionClass.name)?.get(key);
97
- }
98
- static setRawDefinitionByKey(definitionClass, key, rawDefinition) {
99
- if (!this.idToRawDefinitionsMap.has(definitionClass.name)) {
100
- this.idToRawDefinitionsMap.set(definitionClass.name, new Map());
101
- }
102
- let classMap = this.idToRawDefinitionsMap.get(definitionClass.name);
103
- if (classMap) {
104
- classMap.set(key, helpers_lib_1.JsonHelper.deepCopy(rawDefinition));
105
- }
106
- }
107
- static setRawDefinition(definitionClass, definition, rawDefinition) {
108
- if (!this.definitionToRawDefinitionsMap.has(definitionClass.name)) {
109
- this.definitionToRawDefinitionsMap.set(definitionClass.name, new Map());
110
- }
111
- let classMap = this.definitionToRawDefinitionsMap.get(definitionClass.name);
112
- if (classMap) {
113
- classMap.set(definition, helpers_lib_1.JsonHelper.deepCopy(rawDefinition));
114
- }
115
- }
116
- static getComponentName(definitionClass) {
117
- return definitionClass.$meta.componentName;
118
- }
119
- }
120
- exports.DefinitionStore = DefinitionStore;
121
- //# sourceMappingURL=definition-store.js.map
@@ -1,19 +0,0 @@
1
- export declare class FileContentGenerator {
2
- static generate(options: {
3
- preText?: string;
4
- variableName: string;
5
- variableType?: string;
6
- variable: any;
7
- replaceMap?: {
8
- target: string;
9
- replace: string;
10
- }[];
11
- filePath?: string;
12
- assetUrl?: string;
13
- }): Promise<string>;
14
- static format(str: string): Promise<string>;
15
- private static convertToRelativePath;
16
- private static replaceOutput;
17
- private static convertAssetUrls;
18
- private static stringify;
19
- }
@@ -1,117 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.FileContentGenerator = void 0;
30
- const helpers_lib_1 = require("helpers-lib");
31
- const path_1 = __importDefault(require("path"));
32
- const ESTree = __importStar(require("prettier/plugins/estree"));
33
- const TsParser = __importStar(require("prettier/plugins/typescript"));
34
- const standalone_1 = require("prettier/standalone");
35
- const context_1 = require("../context");
36
- class FileContentGenerator {
37
- static generate(options) {
38
- let output = '';
39
- if (options.preText) {
40
- output += `${options.preText}\n\n`;
41
- }
42
- let assetsReplaceMap;
43
- if (options.assetUrl) {
44
- if (!options.filePath) {
45
- throw new Error('filePath is required when using assetUrl');
46
- }
47
- if (!helpers_lib_1.Comparator.isArray(options.variable)) {
48
- throw new Error('variable should be an array when using assetUrl');
49
- }
50
- let { assetImports, replaceMap } = this.convertAssetUrls(options.variable, options.assetUrl, options.filePath);
51
- output += assetImports + '\n\n';
52
- assetsReplaceMap = replaceMap;
53
- }
54
- if (options.variableType) {
55
- output += `export const ${options.variableName}: ${options.variableType} = ${this.stringify(options.variable)}`;
56
- }
57
- else {
58
- output += `export const ${options.variableName} = ${this.stringify(options.variable)}`;
59
- }
60
- if (assetsReplaceMap) {
61
- output = this.replaceOutput(output, assetsReplaceMap);
62
- }
63
- if (options.replaceMap) {
64
- output = this.replaceOutput(output, options.replaceMap);
65
- }
66
- return this.format(output);
67
- }
68
- static async format(str) {
69
- return (0, standalone_1.format)(str, {
70
- parser: 'typescript',
71
- trailingComma: 'none',
72
- tabWidth: 2,
73
- printWidth: 130,
74
- singleQuote: true,
75
- arrowParens: 'avoid',
76
- plugins: [TsParser, ESTree]
77
- });
78
- }
79
- static convertToRelativePath(filePath, relativePathFromRoot) {
80
- let fromPath = context_1.Context.outputPath + filePath.substring(0, filePath.lastIndexOf('/'));
81
- let toPath = context_1.Context.config.projectRoot + relativePathFromRoot.substring(1);
82
- return path_1.default.relative(fromPath, toPath).replace(/\\/g, '/');
83
- }
84
- static replaceOutput(output, replaceMap) {
85
- replaceMap.forEach(item => {
86
- output = output.replace(new RegExp(item.target, 'g'), item.replace);
87
- });
88
- return output;
89
- }
90
- static convertAssetUrls(variable, assetUrl, filePath) {
91
- let urls = variable.map(item => {
92
- let url = helpers_lib_1.JsonHelper.deepFind(item, assetUrl);
93
- if (!url) {
94
- throw new Error(`OutputHelperClass: Asset url is not found in the given variable! item: "${JSON.stringify(item)}", assetUrl: "${assetUrl}"`);
95
- }
96
- return url;
97
- });
98
- let assetUrlToNameMap = new Map();
99
- urls.forEach(url => {
100
- if (!assetUrlToNameMap.has(url)) {
101
- let name = `asset${assetUrlToNameMap.size}`;
102
- assetUrlToNameMap.set(url, name);
103
- }
104
- });
105
- let assetImports = Array.from(assetUrlToNameMap, ([key, value]) => ({ name: value, url: key }))
106
- .map(item => `import ${item.name} from '${this.convertToRelativePath(filePath, item.url)}';`)
107
- .join('\n');
108
- let replaceMap = urls.reduce((map, url) => [...map, { target: `"${url}"`, replace: assetUrlToNameMap.get(url) }], []);
109
- return { assetImports, replaceMap };
110
- }
111
- static stringify(obj) {
112
- // biome-ignore lint:all
113
- return JSON.stringify(obj, (k, v) => (v === undefined ? null : v)).replace(/null/gm, 'undefined');
114
- }
115
- }
116
- exports.FileContentGenerator = FileContentGenerator;
117
- //# sourceMappingURL=file-content-generator.js.map
@@ -1,24 +0,0 @@
1
- export declare const Const: {
2
- type: string;
3
- material: string;
4
- maxQuantity: number;
5
- mainHand: undefined;
6
- offHand: undefined;
7
- bothHands: {
8
- imageOnCharacter: string;
9
- parryDice: undefined;
10
- attacks: {
11
- actionIcon: string;
12
- attackDices: string[];
13
- range: string;
14
- requiresSetup: boolean;
15
- unparryable: boolean;
16
- lowersQuantity: boolean;
17
- projectileType: string;
18
- sounds: {
19
- hit: string;
20
- pre: string;
21
- };
22
- }[];
23
- };
24
- };