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,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const mocks_1 = require("../../_mocks/mocks");
5
- const _mocks_1 = require("../_mocks");
6
- const object_parser_1 = require("./object-parser");
7
- (0, vitest_1.describe)('OBJECT PARSER', () => {
8
- (0, vitest_1.test)('basic', () => {
9
- let result = object_parser_1.ObjectParser.parse(['Name: axe', 'Quantity: 1'], mocks_1.SampleLocation1);
10
- (0, vitest_1.expect)(result).toStrictEqual({
11
- line: mocks_1.SampleLocation1.line,
12
- rawData: {
13
- name: {
14
- line: mocks_1.SampleLocation1.line,
15
- rawData: 'axe'
16
- },
17
- quantity: {
18
- line: mocks_1.SampleLocation1.line + 1,
19
- rawData: '1'
20
- }
21
- }
22
- });
23
- });
24
- (0, vitest_1.test)('quote string value', () => {
25
- let result = object_parser_1.ObjectParser.parse(['Path: "D:/test"'], mocks_1.SampleLocation1);
26
- (0, vitest_1.expect)(result).toStrictEqual({
27
- line: mocks_1.SampleLocation1.line,
28
- rawData: {
29
- path: {
30
- line: mocks_1.SampleLocation1.line,
31
- rawData: 'D:/test'
32
- }
33
- }
34
- });
35
- });
36
- (0, vitest_1.test)('back-tick string value', () => {
37
- let result = object_parser_1.ObjectParser.parse(['Path: `D:/test`'], mocks_1.SampleLocation1);
38
- (0, vitest_1.expect)(result).toStrictEqual({
39
- line: mocks_1.SampleLocation1.line,
40
- rawData: {
41
- path: {
42
- line: mocks_1.SampleLocation1.line,
43
- rawData: 'D:/test'
44
- }
45
- }
46
- });
47
- });
48
- (0, vitest_1.test)('multiline string value', () => {
49
- let result = object_parser_1.ObjectParser.parse(['Str: `', 'text with space', 'text', '`'], mocks_1.SampleLocation1);
50
- (0, vitest_1.expect)(result).toStrictEqual({
51
- line: mocks_1.SampleLocation1.line,
52
- rawData: {
53
- str: {
54
- line: mocks_1.SampleLocation1.line,
55
- rawData: 'text with space\ntext'
56
- }
57
- }
58
- });
59
- });
60
- (0, vitest_1.test)('object contains object', () => {
61
- let result = object_parser_1.ObjectParser.parse(['Attacker:', ' Name: firstObjectName', ' Age: 25', 'Defender:', ' Name: secondObjectName', ' Age: 35'], mocks_1.SampleLocation1);
62
- (0, vitest_1.expect)(result).toStrictEqual({
63
- line: mocks_1.SampleLocation1.line,
64
- rawData: {
65
- attacker: {
66
- line: mocks_1.SampleLocation1.line,
67
- rawData: {
68
- name: {
69
- line: mocks_1.SampleLocation1.line + 1,
70
- rawData: 'firstObjectName'
71
- },
72
- age: {
73
- line: mocks_1.SampleLocation1.line + 2,
74
- rawData: '25'
75
- }
76
- }
77
- },
78
- defender: {
79
- line: mocks_1.SampleLocation1.line + 3,
80
- rawData: {
81
- name: {
82
- line: mocks_1.SampleLocation1.line + 4,
83
- rawData: 'secondObjectName'
84
- },
85
- age: {
86
- line: mocks_1.SampleLocation1.line + 5,
87
- rawData: '35'
88
- }
89
- }
90
- }
91
- }
92
- });
93
- });
94
- (0, vitest_1.test)('object contains array', () => {
95
- let result = object_parser_1.ObjectParser.parse(['Array1:', '- apple', '- orange', 'Array2:', '- xWing', '- tieFighter'], mocks_1.SampleLocation1);
96
- (0, vitest_1.expect)(result).toStrictEqual({
97
- line: mocks_1.SampleLocation1.line,
98
- rawData: {
99
- array1: {
100
- line: mocks_1.SampleLocation1.line,
101
- rawData: [
102
- {
103
- line: mocks_1.SampleLocation1.line + 1,
104
- rawData: 'apple'
105
- },
106
- {
107
- line: mocks_1.SampleLocation1.line + 2,
108
- rawData: 'orange'
109
- }
110
- ]
111
- },
112
- array2: {
113
- line: mocks_1.SampleLocation1.line + 3,
114
- rawData: [
115
- {
116
- line: mocks_1.SampleLocation1.line + 4,
117
- rawData: 'xWing'
118
- },
119
- {
120
- line: mocks_1.SampleLocation1.line + 5,
121
- rawData: 'tieFighter'
122
- }
123
- ]
124
- }
125
- }
126
- });
127
- });
128
- });
129
- (0, vitest_1.describe)('OBJECT PARSER - Error Detection', () => {
130
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(object_parser_1.ObjectParser);
131
- vitest_1.test.each(['Name:axe', 'Name: axe'])('one space after column, first line "%s"', (item) => {
132
- expectErrorHelper.expect([item], {
133
- description: `There should be one space after column operator! "${item}"`,
134
- location: mocks_1.SampleLocation1
135
- });
136
- });
137
- (0, vitest_1.test)('object cannot start with backtick', () => {
138
- expectErrorHelper.expect(['`'], {
139
- description: `Unexpected object element! "\`"`,
140
- location: mocks_1.SampleLocation1
141
- });
142
- });
143
- (0, vitest_1.test)('unexpected backtick', () => {
144
- expectErrorHelper.expect(['Group:', '- item', '`'], {
145
- description: `Unexpected object element! "\`"`,
146
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
147
- });
148
- });
149
- vitest_1.test.each(['Quantity:5', 'Quantity: 5'])('one space after column, second line "%s"', (item) => {
150
- expectErrorHelper.expect(['Name: axe', item], {
151
- description: `There should be one space after column operator! "${item}"`,
152
- location: { line: mocks_1.SampleLocation1.line + 1, path: mocks_1.SampleLocation1.path }
153
- });
154
- });
155
- vitest_1.test.each(['- apple', 'text'])('unexpected object element, "%s"', (item) => {
156
- expectErrorHelper.expect([item], {
157
- description: `Unexpected object element! "${item}"`,
158
- location: mocks_1.SampleLocation1
159
- });
160
- });
161
- (0, vitest_1.test)('multiple columns', () => {
162
- expectErrorHelper.expect(['Name:something: axe'], {
163
- description: `Invalid row, multiple columns! "Name:something: axe"`,
164
- location: mocks_1.SampleLocation1
165
- });
166
- });
167
- (0, vitest_1.test)('starting with column', () => {
168
- expectErrorHelper.expect([':something: axe'], {
169
- description: `Invalid row, row cannot start with columns! ":something: axe"`,
170
- location: mocks_1.SampleLocation1
171
- });
172
- });
173
- vitest_1.test.each([' Name: axe', ' Name: axe'])('invalid coding indent, "%s"', (item) => {
174
- expectErrorHelper.expect([item], {
175
- description: `Invalid coding indent! "${item}"`,
176
- location: mocks_1.SampleLocation1
177
- });
178
- });
179
- (0, vitest_1.test)('no value', () => {
180
- expectErrorHelper.expect(['Name:'], {
181
- description: `No value found after column! "Name:"`,
182
- location: mocks_1.SampleLocation1
183
- });
184
- });
185
- });
186
- //# sourceMappingURL=object-parser.test.js.map
@@ -1,7 +0,0 @@
1
- import { LocationInFile, ParsedStructure } from '../../framework/interfaces';
2
- export declare class PrimitiveParser {
3
- static parse(content: string[], location: LocationInFile): ParsedStructure;
4
- private static parsePlaneString;
5
- private static parseSingleLineString;
6
- private static parseMultilineString;
7
- }
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrimitiveParser = void 0;
4
- class PrimitiveParser {
5
- static parse(content, location) {
6
- let row = content[0];
7
- if (row.startsWith('`')) {
8
- if (content.length === 1) {
9
- return this.parseSingleLineString(row, location, '`');
10
- }
11
- else {
12
- return this.parseMultilineString(content, location);
13
- }
14
- }
15
- else if (content.length > 1) {
16
- let errorLog = {
17
- description: `Invalid row! "${content[1]}"`,
18
- location: { line: location.line + 2, path: location.path }
19
- };
20
- throw errorLog;
21
- }
22
- else {
23
- if (row.startsWith('"')) {
24
- return this.parseSingleLineString(row, location, '"');
25
- }
26
- else {
27
- return this.parsePlaneString(row, location);
28
- }
29
- }
30
- }
31
- static parsePlaneString(row, location) {
32
- if (row.indexOf(' ') !== -1) {
33
- let errorLog = {
34
- description: `Unexpected space! "${row}"`,
35
- location
36
- };
37
- throw errorLog;
38
- }
39
- else {
40
- return {
41
- line: location.line,
42
- rawData: row === 'undefined' ? undefined : row
43
- };
44
- }
45
- }
46
- static parseSingleLineString(row, location, quoteCharacter) {
47
- let regex = new RegExp(quoteCharacter, 'g');
48
- if ((row.match(regex) || []).length > 2) {
49
- let errorLog = {
50
- description: 'There should be only one opening and one closeing quote!',
51
- location
52
- };
53
- throw errorLog;
54
- }
55
- else if (!row.endsWith(quoteCharacter)) {
56
- let errorLog = {
57
- description: 'Quote is not get closed!',
58
- location
59
- };
60
- throw errorLog;
61
- }
62
- else {
63
- return {
64
- line: location.line,
65
- rawData: row.replace(regex, '')
66
- };
67
- }
68
- }
69
- static parseMultilineString(content, location) {
70
- let lastRow = content[content.length - 1];
71
- if (content[0] !== '`') {
72
- let errorLog = {
73
- description: `There should be new line after backtick "${content[0]}"!`,
74
- location: { line: location.line, path: location.path }
75
- };
76
- throw errorLog;
77
- }
78
- else if (lastRow.startsWith('`') && lastRow !== '`') {
79
- let errorLog = {
80
- description: `There should be new line after backtick "${lastRow}"!`,
81
- location: { line: location.line + content.length, path: location.path }
82
- };
83
- throw errorLog;
84
- }
85
- else if (!lastRow.trim().startsWith('`')) {
86
- let errorLog = {
87
- description: `Multiline string should end with backtick in new line "${lastRow}"!`,
88
- location: { line: location.line + content.length, path: location.path }
89
- };
90
- throw errorLog;
91
- }
92
- else if (lastRow !== '`') {
93
- let errorLog = {
94
- description: `Invalid coding indent!`,
95
- location: { line: location.line + content.length, path: location.path }
96
- };
97
- throw errorLog;
98
- }
99
- else {
100
- return {
101
- line: location.line,
102
- rawData: content
103
- .slice(0, content.length - 1)
104
- .slice(1)
105
- .join('\n')
106
- };
107
- }
108
- }
109
- }
110
- exports.PrimitiveParser = PrimitiveParser;
111
- //# sourceMappingURL=primitive-parser.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,79 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- const primitive_parser_1 = require('./primitive-parser');
4
- const _mocks_1 = require('../_mocks');
5
- const mocks_1 = require('../../_mocks/mocks');
6
- describe('PRIMITIVE PARSER', () => {
7
- test('primitive string', () => {
8
- let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
9
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
10
- });
11
- test('primitive quoted string', () => {
12
- let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
13
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
14
- });
15
- test('primitive multiline string', () => {
16
- let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
17
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
18
- });
19
- test('primitive number', () => {
20
- let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
21
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
22
- });
23
- test('primitive undefined', () => {
24
- let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
25
- expect(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
26
- });
27
- });
28
- describe('PRIMITIVE PARSER - Error Detection', () => {
29
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
30
- test.each([' text', 'some text'])('primitive with space "%s"', item => {
31
- expectErrorHelper.expect([item], {
32
- description: `Unexpected space! "${item}"`,
33
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
34
- });
35
- });
36
- test('not closed quote string', () => {
37
- expectErrorHelper.expect(['"some text'], {
38
- description: 'Quote is not get closed!',
39
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
40
- });
41
- });
42
- test('invalid quote text', () => {
43
- expectErrorHelper.expect(['"some "text"'], {
44
- description: 'There should be only one opening and one closeing quote!',
45
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
46
- });
47
- });
48
- test('multiline primitive', () => {
49
- expectErrorHelper.expect(['text', 'secondRow'], {
50
- description: 'Invalid row! "secondRow"',
51
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
52
- });
53
- });
54
- test('multiline string no character after backtick - openning', () => {
55
- expectErrorHelper.expect(['`test', 'something'], {
56
- description: 'There should be new line after backtick "`test"!',
57
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
58
- });
59
- });
60
- test('multiline string no character after backtick - closing', () => {
61
- expectErrorHelper.expect(['`', 'test', '`,'], {
62
- description: 'There should be new line after backtick "`,"!',
63
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
64
- });
65
- });
66
- test('multiline string should end with backtick', () => {
67
- expectErrorHelper.expect(['`', 'test`'], {
68
- description: 'Multiline string should end with backtick in new line "test`"!',
69
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
70
- });
71
- });
72
- test('multiline string should end with backtick in the same coding indent', () => {
73
- expectErrorHelper.expect(['`', 'test', ' `'], {
74
- description: 'Invalid coding indent!',
75
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
76
- });
77
- });
78
- });
79
- //# sourceMappingURL=primitive-parser.spec.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const mocks_1 = require("../../_mocks/mocks");
5
- const _mocks_1 = require("../_mocks");
6
- const primitive_parser_1 = require("./primitive-parser");
7
- (0, vitest_1.describe)('PRIMITIVE PARSER', () => {
8
- (0, vitest_1.test)('primitive string', () => {
9
- let result = primitive_parser_1.PrimitiveParser.parse(['text'], mocks_1.SampleLocation1);
10
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text', mocks_1.SampleLocation1));
11
- });
12
- (0, vitest_1.test)('primitive quoted string', () => {
13
- let result = primitive_parser_1.PrimitiveParser.parse(['"text with spaces"'], mocks_1.SampleLocation1);
14
- console.log(result);
15
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
16
- });
17
- (0, vitest_1.test)('primitive back-tick string', () => {
18
- let result = primitive_parser_1.PrimitiveParser.parse(['`text with spaces`'], mocks_1.SampleLocation1);
19
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text with spaces', mocks_1.SampleLocation1));
20
- });
21
- (0, vitest_1.test)('primitive back-tick multiline string', () => {
22
- let result = primitive_parser_1.PrimitiveParser.parse(['`', 'text text', 'text', '`'], mocks_1.SampleLocation1);
23
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('text text\ntext', mocks_1.SampleLocation1));
24
- });
25
- (0, vitest_1.test)('primitive number', () => {
26
- let result = primitive_parser_1.PrimitiveParser.parse(['123.123'], mocks_1.SampleLocation1);
27
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)('123.123', mocks_1.SampleLocation1));
28
- });
29
- (0, vitest_1.test)('primitive undefined', () => {
30
- let result = primitive_parser_1.PrimitiveParser.parse(['undefined'], mocks_1.SampleLocation1);
31
- (0, vitest_1.expect)(result).toStrictEqual((0, _mocks_1.getExpectedParsedStructure)(undefined, mocks_1.SampleLocation1));
32
- });
33
- });
34
- (0, vitest_1.describe)('PRIMITIVE PARSER - Error Detection', () => {
35
- let expectErrorHelper = new _mocks_1.ExpectErrorHelper(primitive_parser_1.PrimitiveParser);
36
- vitest_1.test.each([' text', 'some text'])('primitive with space "%s"', (item) => {
37
- expectErrorHelper.expect([item], {
38
- description: `Unexpected space! "${item}"`,
39
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
40
- });
41
- });
42
- (0, vitest_1.test)('not closed quote string', () => {
43
- expectErrorHelper.expect(['"some text'], {
44
- description: 'Quote is not get closed!',
45
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
46
- });
47
- });
48
- (0, vitest_1.test)('invalid quote text', () => {
49
- expectErrorHelper.expect(['"some "text"'], {
50
- description: 'There should be only one opening and one closeing quote!',
51
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
52
- });
53
- });
54
- (0, vitest_1.test)('multiline primitive', () => {
55
- expectErrorHelper.expect(['text', 'secondRow'], {
56
- description: 'Invalid row! "secondRow"',
57
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
58
- });
59
- });
60
- (0, vitest_1.test)('multiline string no character after backtick - openning', () => {
61
- expectErrorHelper.expect(['`test', 'something'], {
62
- description: 'There should be new line after backtick "`test"!',
63
- location: { line: mocks_1.SampleLocation1.line, path: mocks_1.SampleLocation1.path }
64
- });
65
- });
66
- (0, vitest_1.test)('multiline string no character after backtick - closing', () => {
67
- expectErrorHelper.expect(['`', 'test', '`,'], {
68
- description: 'There should be new line after backtick "`,"!',
69
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
70
- });
71
- });
72
- (0, vitest_1.test)('multiline string should end with backtick', () => {
73
- expectErrorHelper.expect(['`', 'test`'], {
74
- description: 'Multiline string should end with backtick in new line "test`"!',
75
- location: { line: mocks_1.SampleLocation1.line + 2, path: mocks_1.SampleLocation1.path }
76
- });
77
- });
78
- (0, vitest_1.test)('multiline string should end with backtick in the same coding indent', () => {
79
- expectErrorHelper.expect(['`', 'test', ' `'], {
80
- description: 'Invalid coding indent!',
81
- location: { line: mocks_1.SampleLocation1.line + 3, path: mocks_1.SampleLocation1.path }
82
- });
83
- });
84
- });
85
- //# sourceMappingURL=primitive-parser.test.js.map
@@ -1,5 +0,0 @@
1
- export declare class RawDataParser {
2
- private static selectDefinitionsHelper;
3
- private static structureParserHelper;
4
- static process(): void;
5
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RawDataParser = void 0;
4
- const context_1 = require("../framework/context");
5
- const _1_select_definitions_helper_1 = require("./1-select-definitions.helper");
6
- const _2_structure_parser_helper_1 = require("./2-structure-parser.helper");
7
- const _3_config_1 = require("./3-config");
8
- class RawDataParser {
9
- static { this.selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper(); }
10
- static { this.structureParserHelper = new _2_structure_parser_helper_1.StructureParserHelper(); }
11
- static process() {
12
- let definitionPlaneTexts = context_1.Context.files.reduce((acc, file) => {
13
- let selectDefinitionsResult = this.selectDefinitionsHelper.process(file);
14
- context_1.Context.addErrorLog(selectDefinitionsResult.errorLogs);
15
- acc.push(...selectDefinitionsResult.definitionPlaneTexts);
16
- return acc;
17
- }, []);
18
- let structureParserResult = this.structureParserHelper.process(definitionPlaneTexts);
19
- context_1.Context.rawDefinitions.push(...structureParserResult.rawDefinitions);
20
- context_1.Context.addErrorLog(structureParserResult.errorLogs);
21
- _3_config_1.Config.process();
22
- }
23
- }
24
- exports.RawDataParser = RawDataParser;
25
- //# sourceMappingURL=raw-data-parser.js.map
@@ -1,7 +0,0 @@
1
- import { Vec2 } from 'helpers-lib';
2
- import Joi from 'joi';
3
- export declare const PoligonSchema: () => Joi.ArraySchema<Vec2[][]>;
4
- export declare const Vec2Schema: () => Joi.ObjectSchema<Vec2>;
5
- export declare const HexColorSchema: () => Joi.StringSchema;
6
- export declare const RotationSchema: () => Joi.NumberSchema<number>;
7
- export declare const FixedArraySchema: (itemSchema: Joi.ObjectSchema<any>, size: number) => Joi.ArraySchema;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FixedArraySchema = exports.RotationSchema = exports.HexColorSchema = exports.Vec2Schema = exports.PoligonSchema = void 0;
7
- const helpers_lib_1 = require("helpers-lib");
8
- const joi_1 = __importDefault(require("joi"));
9
- const PoligonSchema = () => joi_1.default.array().items(joi_1.default.array().items((0, exports.Vec2Schema)().required()).min(3).required()).min(1);
10
- exports.PoligonSchema = PoligonSchema;
11
- const Vec2Schema = () => joi_1.default.object().keys({
12
- x: joi_1.default.number().required(),
13
- y: joi_1.default.number().required()
14
- });
15
- exports.Vec2Schema = Vec2Schema;
16
- const HexColorSchema = () => joi_1.default.string()
17
- .pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)
18
- .custom(value => helpers_lib_1.ColorHelper.stringColorToRGBColor(value));
19
- exports.HexColorSchema = HexColorSchema;
20
- const RotationSchema = () => joi_1.default.number().min(-Math.PI).max(Math.PI);
21
- exports.RotationSchema = RotationSchema;
22
- const FixedArraySchema = (itemSchema, size) => joi_1.default.array()
23
- .items(itemSchema)
24
- .max(size)
25
- .custom(value => {
26
- if (value.length > size) {
27
- throw new Error(`Array exceeds maximum size of ${size}`);
28
- }
29
- while (value.length < size) {
30
- value.push(undefined);
31
- }
32
- return value;
33
- })
34
- .default(helpers_lib_1.ArrayHelper.createEmptyArray(size))
35
- .optional();
36
- exports.FixedArraySchema = FixedArraySchema;
37
- //# sourceMappingURL=shape-validators.js.map
@@ -1,7 +0,0 @@
1
- import { Vector } from 'helpers-lib';
2
- import Joi from 'joi';
3
- export declare const PixelPerfectSpriteSchema: () => Joi.StringSchema;
4
- export declare const SpriteSchema: (restrictions?: {
5
- size?: Vector;
6
- scale?: number;
7
- }) => Joi.StringSchema;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SpriteSchema = exports.PixelPerfectSpriteSchema = void 0;
7
- const joi_1 = __importDefault(require("joi"));
8
- const definition_store_1 = require("../../framework/definition-store");
9
- const _1_sprite_1 = require("../assets/1-sprite");
10
- const PixelPerfectSpriteSchema = () => joi_1.default.string()
11
- .reference(_1_sprite_1.SpriteComponent)
12
- .custom((value) => {
13
- let spriteDefinition = definition_store_1.DefinitionStore.getDefinitionOrFail(_1_sprite_1.SpriteComponent, value);
14
- if (spriteDefinition.url.size.x % 4 !== 0) {
15
- throw new Error(`Sprite width must be multiplier of four in order to keep the pixel perfection. Got: '${spriteDefinition.url.size.x}'`);
16
- }
17
- if (spriteDefinition.url.size.y % 4 !== 0) {
18
- throw new Error(`Sprite height must be multiplier of four in order to keep the pixel perfection. Got: '${spriteDefinition.url.size.y}'`);
19
- }
20
- return value;
21
- });
22
- exports.PixelPerfectSpriteSchema = PixelPerfectSpriteSchema;
23
- const SpriteSchema = (restrictions) => joi_1.default.string()
24
- .reference(_1_sprite_1.SpriteComponent)
25
- .custom((value) => {
26
- let spriteDefinition = definition_store_1.DefinitionStore.getDefinitionOrFail(_1_sprite_1.SpriteComponent, value);
27
- if (restrictions?.size) {
28
- if (spriteDefinition.url.size.x !== restrictions.size.x) {
29
- throw new Error(`Sprite width must be '${restrictions.size.x}px'. Got: '${spriteDefinition.url.size.x}'`);
30
- }
31
- if (spriteDefinition.url.size.y !== restrictions.size.y) {
32
- throw new Error(`Sprite height must be '${restrictions.size.y}px'. Got: '${spriteDefinition.url.size.y}'`);
33
- }
34
- }
35
- if (restrictions?.scale) {
36
- if (spriteDefinition.scale !== restrictions.scale) {
37
- throw new Error(`Sprite '${value}' scale must be '${restrictions.scale}'. Got: '${spriteDefinition.scale}'`);
38
- }
39
- }
40
- return value;
41
- });
42
- exports.SpriteSchema = SpriteSchema;
43
- //# sourceMappingURL=sprite-validators.js.map
@@ -1,15 +0,0 @@
1
- import { Vec2 } from 'helpers-lib';
2
- import { DefinitionComponent } from '../../decorators/definition-component';
3
- import { Output } from '../../framework/interfaces';
4
- import { ValidatedSpriteUrl } from '../../helpers/validator/custom-validators/sprite.custom-validator';
5
- export type SpriteID = string;
6
- export interface RawSpriteDefinition {
7
- id: string;
8
- url: ValidatedSpriteUrl;
9
- scale: number;
10
- anchor: Vec2;
11
- boundingShapes: Vec2[][];
12
- }
13
- export declare class SpriteComponent extends DefinitionComponent<RawSpriteDefinition> {
14
- process(definitions: RawSpriteDefinition[], output: Output): Promise<void>;
15
- }