definition-generator-framework 1.13.0 → 2.0.0-rc0
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 +198 -0
- package/dist/index.d.ts +198 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +33 -22
- package/dist/_mocks/mocks.d.ts +0 -7
- package/dist/_mocks/mocks.js +0 -44
- package/dist/decorators/definition-component.d.ts +0 -18
- package/dist/decorators/definition-component.js +0 -52
- package/dist/decorators/definition-generator.d.ts +0 -11
- package/dist/decorators/definition-generator.js +0 -30
- package/dist/framework/context.d.ts +0 -24
- package/dist/framework/context.js +0 -64
- package/dist/framework/definition-component.d.ts +0 -20
- package/dist/framework/definition-component.js +0 -29
- package/dist/framework/definition-generator.d.ts +0 -11
- package/dist/framework/definition-generator.js +0 -22
- package/dist/framework/definition-store.d.ts +0 -25
- package/dist/framework/definition-store.js +0 -121
- package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
- package/dist/framework/file-content-generator/file-content-generator.js +0 -117
- package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
- package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
- package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
- package/dist/framework/file-generators/index-file-generator.js +0 -139
- package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
- package/dist/framework/file-generators/types-file-generator.js +0 -35
- package/dist/framework/framework.d.ts +0 -28
- package/dist/framework/framework.data.d.ts +0 -6
- package/dist/framework/framework.data.js +0 -17
- package/dist/framework/framework.js +0 -51
- package/dist/framework/framework.model.d.ts +0 -32
- package/dist/framework/framework.model.js +0 -3
- package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
- package/dist/framework/index-file-generator/index-file-generator.js +0 -118
- package/dist/framework/interfaces.d.ts +0 -46
- package/dist/framework/interfaces.js +0 -3
- package/dist/framework/kernel.d.ts +0 -12
- package/dist/framework/kernel.js +0 -308
- package/dist/helpers/common-functions/common-functions.d.ts +0 -10
- package/dist/helpers/common-functions/common-functions.js +0 -29
- package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js +0 -50
- package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.test.js +0 -51
- package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
- package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
- package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
- package/dist/helpers/output-helper/output-helper.d.ts +0 -30
- package/dist/helpers/output-helper/output-helper.js +0 -143
- package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.spec.js +0 -261
- package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.test.js +0 -262
- package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
- package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
- package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
- package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
- package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
- package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
- package/dist/helpers/validator/joi-custom-validators.js +0 -54
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
- package/dist/helpers/validator/validator.d.ts +0 -21
- package/dist/helpers/validator/validator.js +0 -74
- package/dist/helpers/validator/validator.spec.d.ts +0 -1
- package/dist/helpers/validator/validator.spec.js +0 -332
- package/dist/helpers/validator/validator.test.d.ts +0 -1
- package/dist/helpers/validator/validator.test.js +0 -329
- package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions-helper.js +0 -76
- package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions.helper.js +0 -80
- package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
- package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.spec.js +0 -140
- package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
- package/dist/pipeline/2-structure-parser.helper.js +0 -70
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
- package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
- package/dist/pipeline/3-config.d.ts +0 -9
- package/dist/pipeline/3-config.js +0 -36
- package/dist/pipeline/_mocks/index.d.ts +0 -13
- package/dist/pipeline/_mocks/index.js +0 -52
- package/dist/pipeline/parsers/array-parser.d.ts +0 -4
- package/dist/pipeline/parsers/array-parser.js +0 -69
- package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js +0 -128
- package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.test.js +0 -126
- package/dist/pipeline/parsers/object-parser.d.ts +0 -4
- package/dist/pipeline/parsers/object-parser.js +0 -135
- package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js +0 -179
- package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.test.js +0 -186
- package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
- package/dist/pipeline/parsers/primitive-parser.js +0 -111
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
- package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
- package/dist/pipeline/raw-data-parser.d.ts +0 -5
- package/dist/pipeline/raw-data-parser.js +0 -25
- package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/shape-validators.js +0 -37
- package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
- package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
- package/dist/pre-made-components/assets/1-sprite.js +0 -74
- package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
- package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
- package/dist/pre-made-components/assets/3-font.d.ts +0 -17
- package/dist/pre-made-components/assets/3-font.js +0 -71
- package/dist/pre-made-components/events/1-event.d.ts +0 -6
- package/dist/pre-made-components/events/1-event.js +0 -206
- package/dist/pre-made-components/events/1-script.d.ts +0 -8
- package/dist/pre-made-components/events/1-script.js +0 -102
- package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
- package/dist/pre-made-components/events/2-event-test.js +0 -172
- package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
- package/dist/pre-made-components/events/2-script-test.js +0 -102
- package/dist/pre-made-components/events/3-event.d.ts +0 -7
- package/dist/pre-made-components/events/3-event.js +0 -100
- package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
- package/dist/pre-made-components/events/4-event-test.js +0 -89
- package/dist/pre-made-components/events/event-setup.d.ts +0 -13
- package/dist/pre-made-components/events/event-setup.js +0 -20
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
- package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
- package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
- package/dist/pre-made-components/events/script-setup.d.ts +0 -8
- package/dist/pre-made-components/events/script-setup.js +0 -16
- package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
- package/dist/pre-made-components/events/scripting-setup.js +0 -97
- package/dist/pre-made-components/events/validators.d.ts +0 -6
- package/dist/pre-made-components/events/validators.js +0 -96
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Comparator,JsonHelper,ConsoleHelper,Vector,ColorHelper,ArrayHelper}from'helpers-lib';import*as lt from'path';import lt__default from'path';import*as Ce from'prettier/plugins/estree';import*as Te from'prettier/plugins/typescript';import {format}from'prettier/standalone';import Ue from'image-size';import {JSONPath}from'jsonpath-plus';import h from'joi';import*as S from'fs';import S__default from'fs';import*as Nt from'glob';import {RichTextValidator,ScriptTestSimulator,JSEngine,SimulationError,ActionsBeforeTestingError,BranchingBeforeTestingError}from'script-engine-lib';var w=(n,t)=>()=>(n&&(t=n(n=0)),t);var x=(n,t,e,i)=>{for(var r=t,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=(s(r))||r);return r};var J,$t=w(()=>{P();J=class{static generate(t){let e="";t.preText&&(e+=`${t.preText}
|
|
2
|
+
|
|
3
|
+
`);let i;if(t.assetUrl){if(!t.filePath)throw new Error("filePath is required when using assetUrl");if(!Comparator.isArray(t.variable))throw new Error("variable should be an array when using assetUrl");let{assetImports:r,replaceMap:o}=this.ɗi(t.variable,t.assetUrl,t.filePath);e+=r+`
|
|
4
|
+
|
|
5
|
+
`,i=o;}return t.variableType?e+=`export const ${t.variableName}: ${t.variableType} = ${this.ɗcb(t.variable)}`:e+=`export const ${t.variableName} = ${this.ɗcb(t.variable)}`,i&&(e=this.ɗbo(e,i)),t.replaceMap&&(e=this.ɗbo(e,t.replaceMap)),this.format(e)}static async format(t){return format(t,{parser:"typescript",trailingComma:"none",tabWidth:2,printWidth:130,singleQuote:true,arrowParens:"avoid",plugins:[Te,Ce]})}static ɗj(t,e){let i=l.outputPath+t.substring(0,t.lastIndexOf("/")),r=l.config.projectRoot+e.substring(1);return lt__default.relative(i,r).replace(/\\/g,"/")}static ɗbo(t,e){return e.forEach(i=>{t=t.replace(new RegExp(i.target,"g"),i.replace);}),t}static ɗi(t,e,i){let r=t.map(p=>{let c=JsonHelper.deepFind(p,e);if(!c)throw new Error(`OutputHelperClass: Asset url is not found in the given variable! item: "${JSON.stringify(p)}", assetUrl: "${e}"`);return c}),o=new Map;r.forEach(p=>{if(!o.has(p)){let c=`asset${o.size}`;o.set(p,c);}});let s=Array.from(o,([p,c])=>({name:c,url:p})).map(p=>`import ${p.name} from '${this.ɗj(i,p.url)}';`).join(`
|
|
6
|
+
`),a=r.reduce((p,c)=>[...p,{target:`"${c}"`,replace:o.get(c)}],[]);return {assetImports:s,replaceMap:a}}static ɗcb(t){return JSON.stringify(t,(e,i)=>i===void 0?null:i).replace(/null/gm,"undefined")}};});var l,P=w(()=>{$t();l=class{static{this.compilerExecutionPath="";}static{this.outputPath="";}static{this.config={projectRoot:"",compilerModulesPath:""};}static{this.rawDefinitions=[];}static{this.files=[];}static{this.output=[];}static{this.exports=[];}static{this.componentInProgressData=void 0;}static async addFile(t){this.exports.push({variableName:t.variableName,path:t.path}),this.output.push({path:t.path,content:await J.generate({preText:Comparator.isArray(t.preText)?t.preText.join(`
|
|
7
|
+
`):t.preText,variableName:t.variableName,variableType:t.variableType,variable:t.variable,replaceMap:t.replaceMap,filePath:t.path,assetUrl:t.assetUrl})});}static get successful(){return this.errorLogs.length===0}static addErrorLog(t,e="default"){Comparator.isArray(t)?e==="lowPriority"?this.ɗu=[...t,...this.ɗu]:this.ɗu.push(...t):e==="lowPriority"?this.ɗu=[t,...this.ɗu]:this.ɗu.push(t);}static flushErrorLogs(){this.errorLogs=[...this.ɗu,...this.errorLogs],this.ɗu=[];}static{this.errorLogs=[];}static{this.ɗu=[];}};});var Z,_t=w(()=>{P();Z=class{constructor(t){this.ɗar=t;this.ɗav=new Set;this.ɗau=new Map;this.ɗb=new Set;this.ɗt=[];}newEntry(t,e){if(this.ɗav.has(t)){if(!this.ɗb.has(t)){this.ɗb.add(t);let i=this.ɗau.get(t);i&&this.ɗt.push({identifier:t,location:i});}return this.ɗt.push({identifier:t,location:e}),false}else return this.ɗav.add(t),this.ɗau.set(t,e),true}logDuplicateErrors(){this.ɗt.forEach(t=>{let e={description:`Value should be singular! Group: "${this.ɗar}", Value: "${t.identifier}"`,location:t.location};l.addErrorLog(e);});}};});var T,q=w(()=>{_t();T=class{static{this.ɗs=new Map;}static logDuplicates(){this.ɗs.forEach(t=>t.logDuplicateErrors());}static getDefinitionComponentName(t){return t.$meta.componentName}static getDefinitionComponentNamesFromArray(t){return Comparator.isArray(t)?t.map(e=>this.getDefinitionComponentName(e)):[this.getDefinitionComponentName(t)]}static getValidationState(t){return t.state.path&&(t.state.path.length===0||t.state.path[0]!==void 0&&t.prefs.context.rawDefinition)?"valid":"notValid"}static getPathAndRawDefinition(t){let e=t.state.path,i=t.prefs.context.rawDefinition;return {path:e,rawDefinition:i}}static getDuplicateHelper(t){let e=this.ɗs.get(t);return e||(e=new Z(t),this.ɗs.set(t,e)),e}};});var R,X=w(()=>{R=class{static findLine(t,e){if(e.length===0)return t.parsedStructure.line;{let i,r=[...e];for(;i===void 0&&r.length>0;)i=this.ɗz(t.parsedStructure.rawData,[...r]),r.pop();return i||t.parsedStructure.line}}static flatten(t){return this.ɗaa(t.parsedStructure.rawData)}static ɗz(t,e){let i=e.shift(),r;if(t&&i!==void 0&&(Comparator.isNumber(i)?Comparator.isArray(t)&&(r=t[i]):Comparator.isObject(t)&&(r=t[i])),r)return e.length===0?r.line:this.ɗz(r.rawData,e)}static ɗaa(t){if(Comparator.isArray(t))return t.map(e=>this.ɗaa(e.rawData));if(Comparator.isObject(t)){let e=t;return Object.keys(e).reduce((i,r)=>{let o=e[r];return i[r]=this.ɗaa(o.rawData),i},{})}else return t}};});var m,j=w(()=>{X();m=class{static{this.ɗas=new Map;}static{this.ɗp=new Map;}static{this.ɗq=new Map;}static{this.ɗh=new Map;}static getDefinitions(t){let e=this.ɗq.get(this.ɗal(t));return e?Array.from(e.values()):[]}static getDefinition(t,e){if(!t.$meta.keyName)throw new Error(`"${t.name}" doesn't have a keyName, getDefinition cannot be called on it.`);return this.ɗq.get(this.ɗal(t))?.get(e)}static getDefinitionOrFail(t,e){let i=this.getDefinition(t,e);if(!i)throw new Error(`No result found for "${e}" in "${t.name}".`);return i}static getSingletonDefinition(t){return this.ɗq.get(this.ɗal(t))?.get(this.ɗal(t))}static getSingletonDefinitionOrFail(t){let e=this.getSingletonDefinition(t);if(!e)throw new Error(`No result found for "${t.name}".`);return e}static getLocationInFile(t,e,i){let r=this.ɗp.get(t.name)?.get(e);if(!r)throw new Error(`No raw definition found for "${e}" in "${t.name}".`);return {line:R.findLine(r,i),path:r.location.path}}static getLocationInFileById(t,e,i){let r=this.ɗap(t,e);if(!r)throw new Error(`No raw definition found for "${e}" in "${t.name}".`);return {line:R.findLine(r,i),path:r.location.path}}static ɗay(t){return this.ɗq.has(t)}static ɗak(t){let e=this.ɗh.get(t);if(!e)throw new Error(`No component found for "${t}".`);return e}static ɗbw(t){t.forEach((e,i)=>{this.ɗq.set(i,new Map);}),this.ɗh=t;}static ɗbx(t,e,i){let r=this.ɗq.get(this.ɗal(t));r&&r.set(e,JsonHelper.deepCopy(i));}static ɗca(t,e){let i=this.ɗal(t),r=this.ɗq.get(i);r&&r.set(i,JsonHelper.deepCopy(e));}static ɗax(t,e){return !!this.ɗas.get(t.name)?.has(e)}static ɗap(t,e){return this.ɗas.get(t.name)?.get(e)}static ɗbz(t,e,i){this.ɗas.has(t.name)||this.ɗas.set(t.name,new Map);let r=this.ɗas.get(t.name);r&&r.set(e,JsonHelper.deepCopy(i));}static ɗby(t,e,i){this.ɗp.has(t.name)||this.ɗp.set(t.name,new Map);let r=this.ɗp.get(t.name);r&&r.set(e,JsonHelper.deepCopy(i));}static ɗal(t){return t.$meta.componentName}};});var ht,At=w(()=>{P();q();ht=class{constructor(t){this.ɗac=t;this.regex=/^[\S]+$/;this.validate=(t,e)=>{if(T.getValidationState(e)==="valid"){let{rawDefinition:r}=T.getPathAndRawDefinition(e);if(t=r.location.path.substring(0,r.location.path.lastIndexOf("/")+1)+t,this.ɗac.existsSync(t))try{let s=Ue(t);return {url:t.replace(l.config.projectRoot,"."),size:{x:s.width,y:s.height}}}catch{throw new Error(`The file in the path "${t}" is not an image`)}else throw new Error(`No file is found in the path: "${t}"`)}else throw new Error(`Internal Error; joi validation context for image validator: Path: "${e.state.path}", RawDefinition: "${JSON.stringify(e.prefs.context.rawDefinition)}"`)};}};});var St,te=w(()=>{P();q();St=class{constructor(t){this.ɗac=t;this.regex=/^[\S]+$/;this.validate=(t,e)=>{if(T.getValidationState(e)==="valid"){let{rawDefinition:r}=T.getPathAndRawDefinition(e);if(t=r.location.path.substring(0,r.location.path.lastIndexOf("/")+1)+t,this.ɗac.existsSync(t))return t.replace(l.config.projectRoot,".");throw new Error(`No file is found in the path: "${t}"`)}else throw new Error(`Internal Error; joi validation context for path validator: Path: "${e.state.path}", RawDefinition: "${JSON.stringify(e.prefs.context.rawDefinition)}"`)};}};});var Dt,ee=w(()=>{Dt=class{constructor(t,e,i,r){t={x:t.x*i,y:t.y*i},this.ɗbq=i,this.ɗe=r||false,this.ɗc=this.ɗai(t,e),this.ɗd=this.ɗaj(t,this.ɗc);}convertPositionToSpriteAnchor(t){t={x:t.x*this.ɗbq,y:t.y*this.ɗbq};let e={x:t.x+this.ɗd.topLeft.x,y:t.y+this.ɗd.topLeft.y};if(this.ɗe&&!this.ɗce(e))throw new Error(`location is outside of the sprite boundaries. Entered position: {x: ${t.x}, y: ${t.y}}, position on sprite: {x: ${e.x}, y: ${e.y}}, bounding box: ${JSON.stringify(this.ɗd)}.`);return e}getRotationFromAnchor(t){return Vector.fromVec2(t).radian.value}ɗce(t){return !(t.x<this.ɗd.topLeft.x||t.x>this.ɗd.bottomRight.x||t.y<this.ɗd.topLeft.y||t.y>this.ɗd.bottomRight.y)}ɗai(t,e){return {x:t.x*e.x,y:t.y*e.y}}ɗaj(t,e){return {topLeft:{x:-e.x,y:-e.y},bottomRight:{x:t.x-e.x,y:t.y-e.y}}}};});var Ct,ie=w(()=>{ee();Ct=class{constructor(t){this.ɗbd=t;this.validate=(t,e)=>{let i=this.ɗbd.selectSpriteDefinition(t);if(!i)throw new Error("positionOnSprite - callback function did not return sprite definition.");let r=new Dt(i.url.size,i.anchor,i.scale,this.ɗbd.checkIfPositionIsOnSprite);return (Array.isArray(this.ɗbd.positionsJsonPath)?this.ɗbd.positionsJsonPath:[this.ɗbd.positionsJsonPath]).forEach(s=>JSONPath({json:t,path:s}).forEach(a=>{if(Comparator.isObject(a)){if(!Comparator.isNumber(a.x)||!Comparator.isNumber(a.y))throw new Error(`positionOnSprite, positions json path returned a non-vec2 result. Value: "${a}".`)}else throw new Error(`positionOnSprite, positions json path returned a non-object result. Value: "${a}".`);let p=r.convertPositionToSpriteAnchor(a);p={x:Math.round(p.x),y:Math.round(p.y)},this.ɗbd.includeRotationFromAnchor?(a.rotationFromAnchor=r.getRotationFromAnchor(p),a.positionFromAnchor=p,delete a.x,delete a.y):(a.x=p.x,a.y=p.y);})),t};}};});var Tt,wt,xt,re=w(()=>{P();j();X();q();Tt=class{constructor(t){this.options=t;this.regex=/^[a-z]+([a-zA-Z0-9]+)*$/;}validatePropertyExistence(t,e,i){if(i?.additionalValidation){let r=m.ɗap(t,e),o=r?R.flatten(r):void 0,s=i.additionalValidation.validate(o);if(s.error)throw new Error(s.error.message)}}},wt=class extends Tt{constructor(e,i){super(i);this.validate=(e,i)=>{if(T.getValidationState(i)==="valid"){let o=this.ɗbl.find(s=>m.getDefinition(s,e));if(o)return this.validatePropertyExistence(o,e,this.options),this.ɗaw?{value:e,type:T.getDefinitionComponentName(o)}:e;if(this.ɗbl.find(a=>m.ɗax(a,e)))i.prefs.context.failSilently=true;else throw new Error(`There is no "${this.ɗbl.map(a=>T.getDefinitionComponentName(a)).join(" or ")}" definition found for "${e}"`)}else throw new Error(`Internal Error; joi validation context for reference validator: Path: "${i.state.path}", RawDefinition: "${JSON.stringify(i.prefs.context)}"`)};this.ɗbl=[];Comparator.isArray(e)?(this.ɗaw=true,this.ɗbl=e):(this.ɗaw=false,this.ɗbl=[e]);}},xt=class extends Tt{constructor(e,i){super(i);this.ɗg=e;this.validate=(e,i)=>{if(!l.componentInProgressData)ConsoleHelper.log("Unexpected error: Lazy reference validation has been called outside of the validation cycle.","red");else if(!l.componentInProgressData.meta.keyName)ConsoleHelper.log("Lazy reference can only be used for definitions with key name defined.","red");else if(l.componentInProgressData.meta.componentName!==this.ɗg)ConsoleHelper.log(`Lazy reference can only be used for self referencing. It is used under: "${this.ɗg}"`,"red");else if(l.componentInProgressData.meta.singleton)ConsoleHelper.log(`Lazy reference cannot be used for singleton components. It is used under: "${this.ɗg}"`,"red");else {let a=i.state.ancestors.at(-1)[l.componentInProgressData.meta.keyName];a?(l.componentInProgressData.idToReferencesMap.has(a)||l.componentInProgressData.idToReferencesMap.set(a,new Set),l.componentInProgressData.idToReferencesMap.get(a).add(e)):ConsoleHelper.log("Unexpected error: definitionId cannot be retrieved by keyname.","red");}let r=m.ɗak(this.ɗg);if(T.getValidationState(i)==="valid"){if(m.ɗax(r,e))return this.validatePropertyExistence(r,e,this.options),e;throw new Error(`There is no "${this.ɗg}" definition found for "${e}"`)}else throw new Error(`Internal Error; joi validation context for reference validator: Path: "${i.state.path}", RawDefinition: "${JSON.stringify(i.prefs.context)}"`)};}};});var vt,ne=w(()=>{vt=class{constructor(t){this.ɗbb=t;this.regex=/^[\S]+$/;this.validate=(t,e)=>{if(this.ɗbb.has(t))throw new Error(`Value "${t}" is not unique in the name space: "${Array.from(this.ɗbb).join(", ")}"`);return this.ɗbb.add(t),t};}};});var bt,ae=w(()=>{te();ie();re();At();ne();bt=class n{static decorate(t,e){t.string().__proto__.unique=function(i){let r=new vt(i);return n.ɗn(this,r)},t.string().__proto__.path=function(){let i=new St(e);return n.ɗn(this,i)},t.string().__proto__.sprite=function(){let i=new ht(e);return n.ɗn(this,i)},t.string().__proto__.reference=function(i,r){let o=new wt(i,r);return n.ɗn(this,o)},t.string().__proto__.lazyReference=function(i,r){let o=new xt(i,r);return n.ɗn(this,o)},t.object().__proto__.positionOnSprite=function(i){let r=new Ct(i);return this.custom(r.validate)},t!==h&&this.decorate(h,e);}static ɗn(t,e){return t.regex(e.regex).custom(e.validate)}};});var se=w(()=>{ae();bt.decorate(h,S__default);});function ge(n){return n.replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function C(n){return function(t){if(n.singleton){if(n.keyName!==void 0)throw new Error(`Singleton components should not have keyName! Component: ${n.componentName}`);if(!(t.prototype instanceof Q))throw new Error(`Singleton components should extend SingleDefinitionComponent! Component: ${n.componentName}`)}else if(!(t.prototype instanceof g))throw new Error(`Non singleton components should extend DefinitionComponent! Component: ${n.componentName}`);t.$meta={componentName:n.componentName,pascalCaseComponentName:ge(n.componentName),keyName:n.keyName,singleton:n.singleton,validationSchema:n.validationSchema};}}var g=class{static getSchema(){return this.$meta.validationSchema}},Q=class{static getSchema(){return this.$meta.validationSchema}};q();P();X();var O=class{static{this.definitionToRawDefintion=new Map;}static getRawDefinitions(t){return l.rawDefinitions.filter(e=>e.componentName===t)}static validateAndConvert(t,e){return this.getRawDefinitions(t).map(i=>{let r=this.ɗcd(i,e);if(this.definitionToRawDefintion.set(r,i),r)return {definition:r,rawDefinition:i}}).filter(i=>i)}static validateAndConvertSingular(t,e){let i=this.validateAndConvert(t,e);if(i.length===0){if(l.successful){let r={description:`Singleton definition has no declared entry "${t}"`,location:{line:0,path:"*"}};l.addErrorLog(r,"lowPriority");}}else if(i.length>1)l.rawDefinitions.filter(r=>r.componentName===t).forEach(r=>{let o={description:`Only one definition can be defined for "${t}"`,location:r.location};l.addErrorLog(o,"lowPriority");});else return i[0]}static ɗcd(t,e){let i={rawDefinition:t,failSilently:false},{value:r,error:o}=e.validate(R.flatten(t),{abortEarly:false,context:i});if(o?.details){let s=o.details.reverse().map(a=>({description:a.message,location:{line:R.findLine(t,a.path),path:t.location.path}}));l.addErrorLog(s.reverse());}else if(!i.failSilently)return r}};P();var Y="CONFIG",Ut=h.object().keys({projectRoot:h.string().regex(/^[\S]+$/).required(),compilerModulesPath:h.string().regex(/^[\S]+$/).optional()}),B=class{static{this.$meta={componentName:Y,validationSchema:Ut};}static process(){let t=O.validateAndConvertSingular(Y,Ut);if(t){let e=t.definition;l.config.projectRoot=e.projectRoot,e.compilerModulesPath&&(l.config.compilerModulesPath=`${e.projectRoot}${e.compilerModulesPath.replace("./","")}`);}}};P();j();var Pt=class{decorateDefinitionName(t,e){return `${this.kebabCaseToCamelCase(e)}${this.upperCaseFirstLetter(t)}`}kebabCaseToCamelCase(t){return t.toLowerCase().replace(/-./g,e=>e[1].toUpperCase())}lowerCaseFirstLetter(t){return t.charAt(0).toLowerCase()+t.slice(1)}upperCaseFirstLetter(t){return t.charAt(0).toUpperCase()+t.slice(1)}removeWhiteSpace(t){return t.replace(/\r?\n|\r/g,"").replace(/\/\/.*$/gm,"").trim().replace(/ {2,}/g," ")}removeComments(t){return t.replace(/\/\/.*$/gm,"").trimEnd()}},_=new Pt;var et=class{constructor(){this.ɗr=false;this.ɗo=[];this.ɗv=[];this.ɗl="";}process(t){return this.ɗr=false,this.ɗm=void 0,this.ɗo=[],this.ɗv=[],this.ɗl=t.path,t.content.split(`
|
|
8
|
+
`).forEach((e,i)=>{let r=_.removeWhiteSpace(e);this.ɗr?r.startsWith("###")?(this.ɗab(),this.ɗbc(e,i,r.substring(4))):this.ɗm&&r.length>0&&this.ɗm.content.push(_.removeComments(e)):r==="# DEFINITIONS"&&(this.ɗr=true);}),this.ɗab(),{definitionPlaneTexts:this.ɗo,errorLogs:this.ɗv}}ɗab(){if(this.ɗm)if(this.ɗm.content.length>0)this.ɗo.push(this.ɗm);else {let t={description:"Definitions cannot be empty!",location:this.ɗm.location};this.ɗv.push(t);}this.ɗm=void 0;}ɗbc(t,e,i){if(m.ɗay(i))this.ɗm={type:i,location:{line:e+1,path:this.ɗl},content:[]};else {let r={description:`Invalid definition header: "${t.trim()}"`,location:{line:e+1,path:this.ɗl}};this.ɗv.push(r),this.ɗm=void 0;}}};var it=class{static parse(t,e){let i=[],r=e.line,o=[];if(t.forEach((s,a)=>{if(s.startsWith(" ")){if(a===0)throw {description:"Invalid coding indent!",location:{line:e.line+a,path:e.path}};i.push(s.substring(2));}else {if(s.match(/^- {2}/g)||s.match(/^-[\S]/g))throw {description:`There should be one space after dash operator! "${s}"`,location:{line:e.line+a,path:e.path}};if(s.startsWith("-")){if(i.length){let p=E.getParsedStructure(i,{line:r,path:e.path});o.push(p);}i=[s.substring(2)],r=e.line+a;}else throw s.startsWith(" ")?{description:"Invalid coding indent!",location:{line:e.line+a,path:e.path}}:{description:`Unexpected array element! "${s}"`,location:{line:e.line+a,path:e.path}}}}),i.length){let s=E.getParsedStructure(i,{line:r,path:e.path});o.push(s);}return {line:e.line,rawData:o}}};var rt=class{static parse(t,e){let i=[],r="",o=0,s,a={};if(t.forEach((p,c)=>{if(!p.startsWith(" ")&&!p.startsWith("- ")&&s!=="multiLineString"){if(p.startsWith(":"))throw {description:`Invalid row, row cannot start with columns! "${p}"`,location:{line:e.line+c,path:e.path}};if(p.match(/[\w]*:[\w]*:/g))throw {description:`Invalid row, multiple columns! "${p}"`,location:{line:e.line+c,path:e.path}};if(p.match(/: {2}/g)||p.match(/^[\w]+:[\S]/g))throw {description:`There should be one space after column operator! "${p}"`,location:{line:e.line+c,path:e.path}};if(p.startsWith(" "))throw {description:`Invalid coding indent! "${p}"`,location:{line:e.line+c,path:e.path}};if(p.indexOf(":")===-1)throw {description:`Unexpected object element! "${p}"`,location:{line:e.line+c,path:e.path}};{if(i.length){let F=E.getParsedStructure(i,{line:o,path:e.path});F.line-=1,a[r]=F,i=[],r="",o=0;}let d=_.lowerCaseFirstLetter(p.substring(0,p.indexOf(":")));if(p.trimEnd().endsWith(":"))if(r=d,o=e.line+c+1,t[c+1])s=t[c+1].startsWith("-")?"array":"object";else throw {description:`No value found after column! "${p}"`,location:{line:e.line+c,path:e.path}};else if(p.trimEnd().endsWith("`")&&p.indexOf("`")===p.lastIndexOf("`"))i.push("`"),r=d,o=e.line+c+1,s="multiLineString";else {let F=p.substring(p.indexOf(":")+2),K=E.getParsedStructure([F],{line:e.line+c,path:e.path});a[d]=K;}}}else {if(c===0)throw p.startsWith("-")?{description:`Unexpected object element! "${p}"`,location:{line:e.line+c,path:e.path}}:{description:`Invalid coding indent! "${p}"`,location:{line:e.line+c,path:e.path}};if(p.startsWith("`")){i.push(p);let d=E.getParsedStructure(i,{line:o,path:e.path});d.line-=1,a[r]=d,i=[],r="",o=0;}else i.push(p.substring(s==="object"?2:0));}}),i.length){let p=E.getParsedStructure(i,{line:o,path:e.path});p.line-=1,a[r]=p;}return {line:e.line,rawData:a}}};var nt=class{static parse(t,e){let i=t[0];if(i.startsWith("`"))return t.length===1?this.ɗbg(i,e,"`"):this.ɗbe(t,e);if(t.length>1)throw {description:`Invalid row! "${t[1]}"`,location:{line:e.line+2,path:e.path}};return i.startsWith('"')?this.ɗbg(i,e,'"'):this.ɗbf(i,e)}static ɗbf(t,e){if(t.indexOf(" ")!==-1)throw {description:`Unexpected space! "${t}"`,location:e};return {line:e.line,rawData:t==="undefined"?void 0:t}}static ɗbg(t,e,i){let r=new RegExp(i,"g");if((t.match(r)||[]).length>2)throw {description:"There should be only one opening and one closeing quote!",location:e};if(t.endsWith(i))return {line:e.line,rawData:t.replace(r,"")};throw {description:"Quote is not get closed!",location:e}}static ɗbe(t,e){let i=t[t.length-1];if(t[0]!=="`")throw {description:`There should be new line after backtick "${t[0]}"!`,location:{line:e.line,path:e.path}};if(i.startsWith("`")&&i!=="`")throw {description:`There should be new line after backtick "${i}"!`,location:{line:e.line+t.length,path:e.path}};if(i.trim().startsWith("`")){if(i!=="`")throw {description:"Invalid coding indent!",location:{line:e.line+t.length,path:e.path}};return {line:e.line,rawData:t.slice(0,t.length-1).slice(1).join(`
|
|
9
|
+
`)}}else throw {description:`Multiline string should end with backtick in new line "${i}"!`,location:{line:e.line+t.length,path:e.path}}}};var E=class n{static getParsedStructure(t,e){switch(this.ɗaq(t[0])){case "object":return rt.parse(t,e);case "array":return it.parse(t,e);case "primitive":return nt.parse(t,e)}}static ɗaq(t){return t.startsWith("-")&&!t.match(/^-?\d+(\.\d+)?$/)?"array":t.match(/^[\w]+:/)?"object":"primitive"}process(t){let e=[];return {rawDefinitions:t.map(r=>{try{if(r.content.length)return {componentName:r.type,location:r.location,parsedStructure:n.getParsedStructure(r.content,{line:r.location.line+1,path:r.location.path})}}catch(o){o?.description&&o?.location?e.push(o):e.push({description:`Unexpected Error! Error: "${o}"`,location:r.location});}}).filter(r=>r),errorLogs:e}}};var ot=class{static{this.ɗbv=new et;}static{this.ɗcc=new E;}static process(){let t=l.files.reduce((i,r)=>{let o=this.ɗbv.process(r);return l.addErrorLog(o.errorLogs),i.push(...o.definitionPlaneTexts),i},[]),e=this.ɗcc.process(t);l.rawDefinitions.push(...e.rawDefinitions),l.addErrorLog(e.errorLogs),B.process();}};P();j();P();$t();var Ft="// ---- INDEX OUTPUT ----",ve="// ---- END ----",A=class{static{this.ɗbi=[];}static{this.ɗat=[];}static addPremadeInterface(t){this.ɗbi.push(t);}static addIdType(t,e){let i=`export type ${t}ID = ${e.map(r=>`'${r}'`).join(" | ")};`;this.ɗat.push(i);}static async generateFile(t,e){if(l.config.compilerModulesPath){let i=await this.ɗaf(t);i&&await this.ɗk(i);}else await this.ɗk(e);}static async ɗk(t){let e=t,i=this.generateTypes();i&&(e+=`
|
|
10
|
+
|
|
11
|
+
`+i),l.output.push({path:"/index.ts",content:await J.format(e)});}static async ɗaf(t){let e=Nt.sync(`${l.config.compilerModulesPath}/**/*.ts`).map(o=>o.replace(/\\/g,"/"));e.length===0&&ConsoleHelper.log("No typescript file found to generate index.ts file.","red");let i=this.ɗae(),r=await this.ɗag(e);if(r!==void 0){let o=`${t}
|
|
12
|
+
${i}
|
|
13
|
+
|
|
14
|
+
${r}`;return o=await J.format(o),S.writeFileSync(`${l.compilerExecutionPath}/output-index-file.ts`,`// AUTO GENERATED - CHANGES WILL BE REPLACED
|
|
15
|
+
export const OutputIndexFile = \`${o}\`;
|
|
16
|
+
`),ConsoleHelper.log("Index content 'output-index-file.ts' is generated.","green"),o}}static ɗae(){return l.exports.map(t=>`export { ${t.variableName} } from '.${t.path.substring(0,t.path.lastIndexOf("."))}';`).join(`
|
|
17
|
+
`)}static async ɗag(t){let e=0,i=[];t.forEach(o=>{let s=o.substring(o.lastIndexOf("/")+1,o.lastIndexOf(".")),a=S.readFileSync(o,"utf-8");try{let p=this.ɗam(s,a);p&&i.push(p);}catch(p){e++,ConsoleHelper.log(`Error parsing file: ${o}, error: '${p.message}'`,"red");}});let r=`//-------------------------- DEFINITIONS --------------------------
|
|
18
|
+
`;return this.ɗbi.length>0&&(r+="// ---- premade ----",r+=this.ɗbi.join(`
|
|
19
|
+
`),r+=`
|
|
20
|
+
|
|
21
|
+
`),r+=i.join(`
|
|
22
|
+
`),e===0?r:void 0}static ɗam(t,e){let i=e.indexOf(Ft),r=i!==-1,o=[];for(;i!==-1;){let s=e.indexOf(ve,i);if(s===-1)throw new Error("No end command found.");o.push(e.substring(e.indexOf(`
|
|
23
|
+
`,i+Ft.length)+1,s)),i=e.indexOf(Ft,s);}if(r)return `// ---- ${t} ----
|
|
24
|
+
${o.join(`
|
|
25
|
+
`)}`}static generateTypes(){let t="";return this.ɗat.length>0&&(t+=`//-------------------------- ID TYPES --------------------------
|
|
26
|
+
`,t+=this.ɗat.join(`
|
|
27
|
+
`),t+=`
|
|
28
|
+
`),t}};var be=/^[a-z]+([a-zA-Z0-9]+)*$/,st="======================================================",Ee="------------------------------------------------------",Wt=n=>n.path.replace(l.compilerExecutionPath+"/","")+":"+n.line,pt=class{static async process(t,e,i){let r=new Map;r.set(Y,B),t.forEach(s=>{let a=s.$meta.componentName;if(r.has(a))throw new Error(`Component name "${a}" is used more than once.`);r.set(a,s);}),m.ɗbw(r),ConsoleHelper.log("Compilation is in progress.","white"),this.ɗbk();let o=await this.ɗah(t,e,i);this.ɗcf(o,l.outputPath);}static ɗbk(){l.compilerExecutionPath=lt.resolve("./").replace(/\\/g,"/"),l.outputPath=`${l.compilerExecutionPath}/.asset-build`,l.files=Nt.sync(`${l.compilerExecutionPath}/**/*.md`).map(t=>t.replace(/\\/g,"/")).map(t=>{let e=S.readFileSync(t).toString();return {path:t,content:e}});}static ɗcf(t,e){let i=new Set;Nt.sync(`${l.outputPath}/**/*`,{nodir:true}).map(a=>a.replace(/\\/g,"/")).forEach(a=>{i.add(a);}),t.forEach(a=>{a.path=e+a.path,i.delete(a.path);}),l.successful&&(ConsoleHelper.log(st,"gray"),ConsoleHelper.log("Changes:","gray"),ConsoleHelper.newLine());let r=0;l.successful&&i.forEach(a=>{r++,console.info(`${ConsoleHelper.red}Erasing file:${ConsoleHelper.gray} "${this.ɗf(a)}"${ConsoleHelper.default}`),S.unlinkSync(a);});let o=0,s=0;t.forEach(a=>{let p=a.path.substring(0,a.path.lastIndexOf("/"));S.mkdirSync(p,{recursive:true});let c=S.existsSync(a.path);(c?S.readFileSync(a.path).toString():"")!==a.content&&(c?(o++,console.info(`${ConsoleHelper.blue}Modifying file:${ConsoleHelper.gray} "${this.ɗf(a.path)}"${ConsoleHelper.default}`)):(s++,console.info(`${ConsoleHelper.cyan}Creating file:${ConsoleHelper.gray} "${this.ɗf(a.path)}"${ConsoleHelper.default}`)),S.writeFileSync(a.path,a.content));}),this.ɗbn(e),s+o+r>0&&ConsoleHelper.newLine(),ConsoleHelper.log(`Created file count: ${s}`,"gray"),ConsoleHelper.log(`Modified file count: ${o}`,"gray"),ConsoleHelper.log(`Erased file count: ${r}`,"gray"),ConsoleHelper.log(st,"gray"),l.successful?ConsoleHelper.log("Compilation is completed successfuly!","green"):ConsoleHelper.log("Compilation encountered errors!","red");}static ɗf(t){let e=l.compilerExecutionPath.length;return t.substring(e)}static ɗbn(t){let e=S.readdirSync(t),i=true;for(let r of e){let o=lt.join(t,r);S.statSync(o).isDirectory()&&this.ɗbn(o)?(S.rmdirSync(o),console.info(`${ConsoleHelper.red}Erasing folder:${ConsoleHelper.gray} "${o.substring(t.length).replace(/\\/g,"/")}"${ConsoleHelper.default}`)):i=false;}return i}static async ɗah(t,e,i){ot.process(),l.flushErrorLogs();let r=t.map(o=>{let s=o.$meta;l.componentInProgressData={meta:s,idToReferencesMap:new Map};let a={addFile:c=>l.addFile(c),addError:c=>l.addErrorLog(c),convertLocationInFileToLink:c=>Wt(c)};this.ɗaz(s.keyName,s.componentName,o);let p;if(s.singleton){let c=O.validateAndConvertSingular(s.componentName,s.validationSchema);c&&(p=c.definition,m.ɗby(o,c.definition,c.rawDefinition),m.ɗca(o,p));}else {let c=O.validateAndConvert(s.componentName,s.validationSchema);if(l.componentInProgressData.idToReferencesMap.size>0){let d=s.keyName;if(!d)throw new Error("Unexpected Error: KeyName should be defined for lazy references.");let F=l.componentInProgressData.idToReferencesMap,K=true;for(;K;){let pe=c.length,le=new Set(c.map(Et=>Et.definition[d]));c=c.filter(Et=>{let Bt=Et.definition[d];if(F.has(Bt)){let ce=F.get(Bt),Ht=true;return ce.forEach(me=>le.has(me)||(Ht=false)),Ht}return true}),K=pe!==c.length;}}c.forEach(d=>{m.ɗby(o,d.definition,d.rawDefinition);}),p=c.map(d=>d.definition),this.ɗbm(p,s.keyName,o);}return l.flushErrorLogs(),l.componentInProgressData=void 0,{definitionToProcess:p,output:a,moduleClass:o}});for(let o of r)if(o.definitionToProcess){let s=new o.moduleClass,a=o.moduleClass.$meta.keyName;a&&A.addIdType(o.moduleClass.$meta.pascalCaseComponentName,o.definitionToProcess.map(p=>p[a])),await s.process(o.definitionToProcess,o.output);}return l.flushErrorLogs(),T.logDuplicates(),l.successful&&await A.generateFile(e,i),this.ɗao()}static ɗaz(t,e,i){let r=O.getRawDefinitions(e);t&&r.forEach(o=>{let s=o.parsedStructure.rawData;if(!Comparator.isObject(s)||Comparator.isArray(s))l.addErrorLog({description:`KeyName shold not be used with a content which is not an object, keyName: "${t}" in "${e}"`,location:{line:o.parsedStructure.line,path:o.location.path}});else {let a=s[t]?.rawData;Comparator.isString(a)&&(be.test(a)===false?l.addErrorLog({description:`KeyValue should be a valid key, keyValue: "${a}"`,location:{line:s[t].line,path:o.location.path}}):m.ɗax(i,a)?l.addErrorLog({description:`Definition with key "${a}" already exists`,location:{line:s[t].line,path:o.location.path}}):m.ɗbz(i,a,o));}});}static ɗbm(t,e,i){e&&t.forEach(r=>{let o=r[e];m.ɗbx(i,o,r);});}static ɗao(){return l.successful?l.output:(ConsoleHelper.newLine(),ConsoleHelper.log("ERROR LOGS:","red"),ConsoleHelper.log(st,"gray"),l.errorLogs.forEach((t,e)=>{e>0&&ConsoleHelper.log(Ee,"gray"),ConsoleHelper.log("Error:","red"),console.info(`${ConsoleHelper.white}Details:${ConsoleHelper.green} ${t.description}`),console.info(`${ConsoleHelper.white}Location:${ConsoleHelper.green} ${Wt(t.location)}`);}),ConsoleHelper.log(st,"gray"),[{path:"/error-logs.md",content:l.errorLogs.map(t=>`${t.description}\r
|
|
29
|
+
Path: '${t.location.path}', Line: '${t.location.line}'\r
|
|
30
|
+
`).join(`\r
|
|
31
|
+
`)}])}};var Vt=class{constructor(t,e,i){u.setup(t,e,i);}setScriptInput(t,e){u.setScriptInput(t,e);}setEventInput(t,e){u.setEventInput(t,e);}addCustomScriptTestCase(t,e,i){u.addCustomScriptTestCase(e,i,t);}addCustomEventTestCase(t,e,i){u.addCustomEventTestCase(e,i,t);}},u=class{static{this.ɗbr=new Map;}static{this.ɗw=new Map;}static{this.ɗbt=new Map;}static{this.ɗy=new Map;}static get scriptSimulatorFunctionsConstructor(){if(!this.ɗbs)throw new Error("ScriptSimulatorFunctionsConstructor is not set");return this.ɗbs}static get eventSimulatorFunctionsConstructor(){if(!this.ɗx)throw new Error("ScriptSimulatorFunctionsConstructor is not set");return this.ɗx}static get richTextTags(){return this.ɗbp}static get isInitialized(){return this.ɗbs&&this.ɗx&&this.ɗbp!==void 0}static setup(t,e,i){this.ɗbs=t,this.ɗx=e,this.ɗbp=i;}static getScriptInput(t){return this.ɗbr.get(t)}static getEventInput(t){return this.ɗw.get(t)}static getCustomScriptTestCases(){return Array.from(this.ɗbt.values())}static getCustomEventTestCases(){return Array.from(this.ɗy.values())}static isCustomScriptTestCase(t){return this.ɗbt.has(t.script)}static isCustomEventTestCase(t){return this.ɗy.has(t.script)}static setScriptInput(t,e){if(this.ɗbr.has(t))throw new Error(`Script input for ${t} already set`);this.ɗbr.set(t,e);}static setEventInput(t,e){if(this.ɗw.has(t))throw new Error(`Event input for ${t} already set`);this.ɗw.set(t,e);}static addCustomScriptTestCase(t,e,i){let r={testDefinition:{script:t,cases:[e]},customMessage:`Prebuild Test Case:
|
|
32
|
+
${i}`};this.ɗbt.set(t,r);}static addCustomEventTestCase(t,e,i){let r={testDefinition:{script:t,cases:[e]},customMessage:`Prebuild Test Case:
|
|
33
|
+
${i}`};this.ɗy.set(t,r);}};var ct=class{static convert(t){let e=false,i=t.indexOf('"');for(;i>=0;){let r=e?'"</b>':'<b>"';t=t.substring(0,i)+r+t.substring(i+1),e=!e,i=t.indexOf('"',i+r.length);}if(e)throw new Error("Quote is not closed.");return RichTextValidator.validate(t,u.richTextTags),t}};var mt=()=>h.string().custom(n=>({type:"command",value:n})),ft=n=>h.object().keys({branchByCondition:h.array().items(h.object().keys({condition:h.string().optional(),actions:h.link("#"+n).default([]).optional()})).custom((t,e)=>{let i=t.length;if(i>1){for(let r=0;r<i-1;r++)if(t[r].condition===void 0)throw new Error(`Element at index ${r} must have "condition"`)}else if(i===1&&t[0].condition===void 0)throw new Error('Single element must have "condition"');return t})}).custom(t=>({type:"branchByCondition",value:t.branchByCondition})),Kt=n=>h.object().keys({branchByPlayerChoice:h.array().items(h.object().keys({text:h.string().min(2).required(),condition:h.string().optional(),actions:h.link("#"+n).default([]).optional()}))}).custom(t=>({type:"branchByPlayerChoice",value:t.branchByPlayerChoice})),dt=n=>h.object().keys({branchByChance:h.array().items(h.object().keys({label:h.string().optional(),weight:h.number().integer().min(1).max(100).required(),condition:h.string().optional(),actions:h.link("#"+n).default([]).optional()}))}).custom(t=>({type:"branchByChance",value:t.branchByChance})),Qt=()=>h.object().min(1).max(1).custom(n=>{let t=Object.keys(n);if(t.length!==1)throw new Error("object must have exactly one key/value pair");let e=t[0],i=n[e];if(typeof i!="string")throw new Error("value must be a string");return i=ct.convert(i),{type:"dialog",value:{text:i,speaker:e}}});var kt=new Set,Ie=h.object().keys({jumpTo:h.string().lazyReference("SCRIPT").required()}).custom(n=>({type:"jumpTo",value:n.jumpTo})),jt="ScriptActionsSchema",Pe=()=>h.array().items(h.alternatives().conditional(h.string(),{then:mt()}).conditional(h.object({jumpTo:h.exist()}).unknown(),{then:Ie}).conditional(h.object({branchByChance:h.exist()}).unknown(),{then:dt(jt)}).conditional(h.object({branchByCondition:h.exist()}).unknown(),{then:ft(jt)}).conditional(h.object({branchByPlayerChoice:h.exist()}).unknown(),{then:h.forbidden().messages({"any.unknown":"branchByPlayerChoice is not allowed in scripts"})}).conditional(h.object().min(1).max(1).unknown(),{then:h.forbidden().messages({"any.unknown":"dialogs are not allowed in scripts"})}).error(n=>n.map(t=>{if(t.code==="alternatives.any"){let e="command, jumpToScript, branchByCondition, branchByChance";t.message=`${t.local.label} does not match any of the allowed types: ${e}`;}return t}))).custom(n=>{let t=false,e=false;if(n.forEach(i=>{e?t=true:(i.type==="branchByCondition"||i.type==="branchByChance")&&(e=true);}),t)throw new Error("There should not be any command after branching.");return n}).id(jt),v=class extends g{async process(t,e){await e.addFile({path:"/_premade/script-engine-definitions/scripts.ts",preText:'import { ScriptDefinition } from "script-engine-lib";',variableName:"ScriptDefinitions",variableType:"Readonly<Record<string, ScriptDefinition>>",variable:JsonHelper.arrayToObject(t,"id")});}};v=x([C({componentName:"SCRIPT",keyName:"id",validationSchema:h.object().keys({id:h.string().unique(kt).required(),actions:Pe().min(1).required()}).required()})],v);j();var H=class{constructor(t,e,i){this.ɗad=e;this.ɗba=i;this.ɗbu=new ScriptTestSimulator(t);}runTests(t,e){let i=[];return t.forEach(r=>{let o=false;r.cases.forEach((s,a)=>{if(!o){let p=new JSEngine(new this.ɗad(r.scriptInput),{});try{this.ɗbu.simulateScript(r.script,p,s.actionsBeforeTesting);}catch(c){let d=this.ɗbj(c,r,a,e);i.push(d),o=true;}}});}),i}printErrors(t,e){t.length===0&&this.ɗbu.getUnvisitedBranchLocations().forEach(i=>e.addError({description:"Event branch is not reaced by any of the combinations during the tests.",location:this.ɗba.getLocationOfDefinition(i.scriptId,i.path)})),t.forEach(i=>e.addError(i));}ɗbj(t,e,i,r){if(t instanceof SimulationError)return {description:e.customMessage?e.customMessage+`
|
|
34
|
+
`+t.message:t.message,location:this.ɗba.getLocationOfDefinition(t.location.scriptId,t.location.path)};if(t instanceof ActionsBeforeTestingError){let o=e.customMessage?e.customMessage+`
|
|
35
|
+
`+t.message:t.message,s=this.ɗba.getLocationOfTestDefinition(e.testDefinitionRef,["cases",`${i}`,"actionsBeforeTesting",`${t.actionIndex}`]);return {description:o,location:s}}else if(t instanceof BranchingBeforeTestingError){let o=this.ɗba.getLocationOfTestDefinition(e.testDefinitionRef,[]),s=`Running the test: ${r.convertLocationInFileToLink(o)}
|
|
36
|
+
|
|
37
|
+
`,a=t.message.indexOf(`
|
|
38
|
+
`,t.message.indexOf("Execution history"))+1,p=t.message.slice(0,a)+s+t.message.slice(a);return {description:e.customMessage?e.customMessage+`
|
|
39
|
+
`+p:p,location:this.ɗba.getLocationOfDefinition(t.location.scriptId,t.location.path)}}else throw t}};var je=h.string().custom(n=>({type:"command",value:n})),ke=h.object().keys({runScript:h.string().reference(v).required()}).custom(n=>({type:"runScript",value:n.runScript})),Je=()=>h.array().items(h.alternatives().conditional(h.string(),{then:je}).conditional(h.object({runScript:h.exist()}).unknown(),{then:ke}).error(n=>n.map(t=>{if(t.code==="alternatives.any"){let e="command, runScript";t.message=`${t.local.label} does not match any of the allowed types: ${e}`;}return t}))).min(1),N=class extends g{async process(t,e){let i=m.getDefinitions(v),r=new H(i,u.scriptSimulatorFunctionsConstructor,this.ɗan()),o=t.map(c=>({cases:c.cases,script:m.getDefinitionOrFail(v,c.script),scriptInput:u.getScriptInput(c.script),testDefinitionRef:c})),s=u.getCustomScriptTestCases().map(c=>({cases:c.testDefinition.cases,script:m.getDefinitionOrFail(v,c.testDefinition.script),scriptInput:u.getScriptInput(c.testDefinition.script),testDefinitionRef:c.testDefinition,customMessage:c.customMessage})),a=o.concat(s),p=r.runTests(a,e);r.printErrors(p,e);}ɗan(){return {getLocationOfDefinition:(t,e)=>m.getLocationInFileById(v,t,e),getLocationOfTestDefinition:(t,e)=>{if(u.isCustomScriptTestCase(t)){let i=`Internal error: custom script test case is failing. Definition: ${JSON.stringify(t)}, Path: ${JSON.stringify(e)}`;throw new Error(i)}else return m.getLocationInFile(N,t,e)}}}};N=x([C({componentName:"SCRIPT-TEST",validationSchema:h.object().keys({script:h.string().reference(v).required(),cases:h.array().items(h.object().keys({actionsBeforeTesting:Je().default([]).optional()}).required()).required()}).required()})],N);var Me=h.object().keys({jumpTo:h.string().lazyReference("EVENT").required()}).custom(n=>({type:"jumpTo",value:n.jumpTo})),ut="EventActionsSchema",Be=()=>h.array().items(h.alternatives().conditional(h.string(),{then:mt()}).conditional(h.object({jumpTo:h.exist()}).unknown(),{then:Me}).conditional(h.object({branchByChance:h.exist()}).unknown(),{then:dt(ut)}).conditional(h.object({branchByCondition:h.exist()}).unknown(),{then:ft(ut)}).conditional(h.object({branchByPlayerChoice:h.exist()}).unknown(),{then:Kt(ut)}).conditional(h.object().min(1).max(1).unknown(),{then:Qt()}).error(n=>n.map(t=>{if(t.code==="alternatives.any"){let e="command, jumpTo, branchByCondition, branchByPlayerChoice, branchByChance";t.message=`${t.local.label} does not match any of the allowed types: ${e}`;}return t}))).custom(n=>{let t=false,e=false;if(n.forEach(i=>{e?t=true:(i.type==="branchByCondition"||i.type==="branchByPlayerChoice"||i.type==="branchByChance")&&(e=true);}),t)throw new Error("There should not be any command after branching.");return n}).id(ut),b=class extends g{async process(t,e){await e.addFile({path:"/_premade/script-engine-definitions/events.ts",preText:'import { ScriptDefinition } from "script-engine-lib";',variableName:"EventDefinitions",variableType:"Readonly<Record<string, ScriptDefinition>>",variable:JsonHelper.arrayToObject(t,"id")});}};b=x([C({componentName:"EVENT",keyName:"id",validationSchema:h.object().keys({id:h.string().unique(kt).required(),actions:Be().min(1).required()}).required()})],b);j();var He=h.string().custom(n=>({type:"command",value:n})),qe=h.object().keys({runEvent:h.string().reference(b).required()}).custom(n=>({type:"runScript",value:n.runEvent})),ze=()=>h.array().items(h.alternatives().conditional(h.string(),{then:He}).conditional(h.object({runEvent:h.exist()}).unknown(),{then:qe}).error(n=>n.map(t=>{if(t.code==="alternatives.any"){let e="command, runEvent";t.message=`${t.local.label} does not match any of the allowed types: ${e}`;}return t}))).min(1),V=class extends g{async process(t,e){let i=m.getDefinitions(b),r=new H(i,u.eventSimulatorFunctionsConstructor,this.ɗan()),o=r.runTests(t.map(s=>({cases:s.cases,script:m.getDefinitionOrFail(b,s.script),scriptInput:u.getEventInput(s.script),testDefinitionRef:s})),e);r.printErrors(o,e);}ɗan(){return {getLocationOfDefinition:(t,e)=>m.getLocationInFileById(b,t,e),getLocationOfTestDefinition:(t,e)=>m.getLocationInFile(V,t,e)}}};V=x([C({componentName:"EVENT-TEST",validationSchema:h.object().keys({event:h.string().reference(b).required(),cases:h.array().items(h.object().keys({actionsBeforeTesting:ze().default([]).optional()}).required()).required()}).required().custom(n=>({script:n.event,cases:n.cases}))})],V);var Zt=false;function _e(n){return function(t){if(Zt)console.error("There can be only one definition generator!");else {Zt=true;let e=[...n.modules];u.isInitialized&&(e=[v,b,...e,N,V]),pt.process(e,n.indexFilePretext,n.outputIndexFile);}}}var Jt=class{};j();At();var Xt=()=>h.array().items(h.array().items(Ke().required()).min(3).required()).min(1),Ke=()=>h.object().keys({x:h.number().required(),y:h.number().required()}),Sn=()=>h.string().pattern(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/).custom(n=>ColorHelper.stringColorToRGBColor(n)),Dn=()=>h.number().min(-Math.PI).max(Math.PI),Cn=(n,t)=>h.array().items(n).max(t).custom(e=>{if(e.length>t)throw new Error(`Array exceeds maximum size of ${t}`);for(;e.length<t;)e.push(void 0);return e}).default(ArrayHelper.createEmptyArray(t)).optional();j();var I=class extends g{async process(t,e){await e.addFile({path:"/_premade/assets/sprites.ts",preText:"import { AssetDefinition } from 'bard-legends-framework';",variableName:"SpriteAssets",variableType:"readonly AssetDefinition[]",assetUrl:"url",variable:t.map(i=>({id:i.id,url:i.url.url}))}),await e.addFile({path:"/_premade/asset-definitions/sprites.ts",preText:'import { SpriteDefinition } from "bard-legends-framework";',variableName:"SpriteDefinitions",variableType:"Readonly<Record<string, SpriteDefinition>>",variable:JsonHelper.arrayToObject(t,"id",{transformFunction:i=>({id:i.id,size:i.url.size,scale:i.scale,anchor:i.anchor,boundingShapes:i.boundingShapes})})});}};I=x([C({componentName:"SPRITE",keyName:"id",validationSchema:h.object().keys({id:h.string().required(),url:h.string().sprite().required(),scale:h.number().min(.1).max(1).default(1).optional(),anchor:h.object().keys({x:h.number().min(0).max(1).required(),y:h.number().min(0).max(1).required()}).default({x:.5,y:.5}).optional(),boundingShapes:Xt().optional()}).positionOnSprite({selectSpriteDefinition:n=>n,positionsJsonPath:["$..boundingShapes[*][*]"],includeRotationFromAnchor:false}).required()})],I);var Fn=()=>h.string().reference(I).custom(n=>{let t=m.getDefinitionOrFail(I,n);if(t.url.size.x%4!==0)throw new Error(`Sprite width must be multiplier of four in order to keep the pixel perfection. Got: '${t.url.size.x}'`);if(t.url.size.y%4!==0)throw new Error(`Sprite height must be multiplier of four in order to keep the pixel perfection. Got: '${t.url.size.y}'`);return n}),On=n=>h.string().reference(I).custom(t=>{let e=m.getDefinitionOrFail(I,t);if(n?.size){if(e.url.size.x!==n.size.x)throw new Error(`Sprite width must be '${n.size.x}px'. Got: '${e.url.size.x}'`);if(e.url.size.y!==n.size.y)throw new Error(`Sprite height must be '${n.size.y}px'. Got: '${e.url.size.y}'`)}if(n?.scale&&e.scale!==n.scale)throw new Error(`Sprite '${t}' scale must be '${n.scale}'. Got: '${e.scale}'`);return t});var U=class extends g{async process(t,e){await e.addFile({path:"/_premade/asset-definitions/sprite-groups.ts",preText:"",variableName:"SpriteGroupDefinitions",variableType:"Readonly<Record<string, readonly string[]>>",variable:JsonHelper.arrayToObject(t,"id",{transformFunction:i=>i.group})});}};U=x([C({componentName:"SPRITE-GROUP",keyName:"id",validationSchema:h.object().keys({id:h.string().required(),group:h.array().items(h.string().reference(I)).unique().required()}).required()})],U);var Ye=`
|
|
40
|
+
export interface FontDefinition {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly fontFamily: string;
|
|
43
|
+
}`,G=class extends g{constructor(){super(),A.addPremadeInterface(Ye);}async process(t,e){await e.addFile({path:"/_premade/assets/fonts.ts",preText:"import { AssetDefinition } from 'bard-legends-framework';",variableName:"FontAssets",variableType:"readonly AssetDefinition[]",assetUrl:"url",variable:t.map(i=>({id:i.id,url:i.url}))}),await e.addFile({path:"/_premade/asset-definitions/fonts.ts",preText:'import { FontDefinition } from "../../";',variableName:"FontDefinitions",variableType:"Readonly<Record<string, FontDefinition>>",variable:JsonHelper.arrayToObject(t,"id",{transformFunction:i=>({id:i.id,fontFamily:i.fontFamily})})});}};G=x([C({componentName:"FONT",keyName:"id",validationSchema:h.object().keys({id:h.string().required(),fontFamily:h.string().required(),url:h.string().path().required()}).required()})],G);se();export{g as DefinitionComponent,C as DefinitionComponentDecorator,Jt as DefinitionGenerator,_e as DefinitionGeneratorDecorator,m as DefinitionStore,b as EventComponent,V as EventTestComponent,Cn as FixedArraySchema,G as FontComponent,Sn as HexColorSchema,Fn as PixelPerfectSpriteSchema,Xt as PoligonSchema,Dn as RotationSchema,v as ScriptComponent,N as ScriptTestComponent,Vt as ScriptTesting,Q as SingleDefinitionComponent,I as SpriteComponent,U as SpriteGroupComponent,On as SpriteSchema,O as Validator,Ke as Vec2Schema};
|
package/package.json
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "definition-generator-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc0",
|
|
4
4
|
"description": "Definition Generator Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/**/*.js",
|
|
8
|
-
"dist/**/*.d.ts"
|
|
9
|
-
],
|
|
10
6
|
"publishConfig": {
|
|
11
7
|
"main": "dist/index.js",
|
|
12
|
-
"
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
13
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
14
20
|
"repository": {
|
|
15
21
|
"type": "git",
|
|
16
22
|
"url": "git+https://github.com/sefabaser/definition-generator-framework.git"
|
|
@@ -20,42 +26,47 @@
|
|
|
20
26
|
"bugs": {
|
|
21
27
|
"url": "https://github.com/sefabaser/definition-generator-framework/issues"
|
|
22
28
|
},
|
|
23
|
-
"prettier": {
|
|
24
|
-
"trailingComma": "none",
|
|
25
|
-
"tabWidth": 2,
|
|
26
|
-
"printWidth": 130,
|
|
27
|
-
"singleQuote": true,
|
|
28
|
-
"arrowParens": "avoid"
|
|
29
|
-
},
|
|
30
29
|
"homepage": "https://github.com/sefabaser/definition-generator-framework#readme",
|
|
31
30
|
"scripts": {
|
|
32
|
-
"clean-install": "cls && rm -rf node_modules && rm -rf package-lock.json && npm
|
|
31
|
+
"clean-install": "cls && rm -rf node_modules && rm -rf package-lock.json && npm run i",
|
|
32
|
+
"i": "npm cache clean --force && npm install",
|
|
33
33
|
"pretest": "cls",
|
|
34
|
-
"test": "vitest",
|
|
35
|
-
"
|
|
36
|
-
"build": "
|
|
34
|
+
"test": "vitest run --mode=quick",
|
|
35
|
+
"test-full": "vitest run",
|
|
36
|
+
"build": "npx ts-node scripts/generate-mangle-cache.ts && tsup && npx ts-node scripts/remove-private-properties-from-build.ts && npm run restart-vitest",
|
|
37
|
+
"restart-vitest": "touch vitest.config.ts",
|
|
37
38
|
"lint": "biome check . --write --max-diagnostics=1",
|
|
38
39
|
"deploy": "vitest run && npm run build && npm publish",
|
|
39
40
|
"prepack": "cp package.json package.json.bak && ts-node scripts/prepare-package-json.ts",
|
|
40
41
|
"postpack": "mv package.json.bak package.json"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"helpers-lib": "1.13.10",
|
|
44
44
|
"image-size": "1.1.1",
|
|
45
|
-
"joi": "17.11.0",
|
|
46
45
|
"prettier": "3.3.3",
|
|
47
46
|
"jsonpath-plus": "8.1.0",
|
|
48
|
-
"script-engine-lib": "0.4.3",
|
|
49
47
|
"glob": "10.3.14"
|
|
50
48
|
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"helpers-lib": "^2.0.0",
|
|
51
|
+
"joi": "^17.11.0",
|
|
52
|
+
"script-engine-lib": "^1.0.0"
|
|
53
|
+
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@biomejs/biome": "2.2.4",
|
|
53
56
|
"@types/glob": "8.1.0",
|
|
54
57
|
"@types/node": "20.10.5",
|
|
55
58
|
"@types/rimraf": "4.0.5",
|
|
59
|
+
"tsup": "8.5.1",
|
|
56
60
|
"ts-node": "10.9.2",
|
|
57
61
|
"typescript": "5.3.3",
|
|
58
|
-
"vitest": "
|
|
62
|
+
"vitest": "3.2.4"
|
|
59
63
|
},
|
|
60
|
-
"types": "dist/index.d.ts"
|
|
64
|
+
"types": "dist/index.d.ts",
|
|
65
|
+
"module": "dist/index.mjs",
|
|
66
|
+
"exports": {
|
|
67
|
+
".": {
|
|
68
|
+
"import": "./dist/index.mjs",
|
|
69
|
+
"require": "./dist/index.js"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
61
72
|
}
|
package/dist/_mocks/mocks.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FileInfo, LocationInFile } from '../framework/interfaces';
|
|
2
|
-
export declare function resetContext(): void;
|
|
3
|
-
export declare function setMockContextFromContents(contents: string[]): void;
|
|
4
|
-
export declare function getMockFileInfo(content: string): FileInfo;
|
|
5
|
-
export declare const SampleLocation1: LocationInFile;
|
|
6
|
-
export declare const SampleLocation2: LocationInFile;
|
|
7
|
-
export declare const SampleLocation3: LocationInFile;
|
package/dist/_mocks/mocks.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SampleLocation3 = exports.SampleLocation2 = exports.SampleLocation1 = exports.getMockFileInfo = exports.setMockContextFromContents = exports.resetContext = void 0;
|
|
4
|
-
const context_1 = require("../framework/context");
|
|
5
|
-
function resetContext() {
|
|
6
|
-
context_1.Context.compilerExecutionPath = 'D:/test';
|
|
7
|
-
context_1.Context.outputPath = 'D:/test/.asset-build';
|
|
8
|
-
context_1.Context.config.projectRoot = 'D:/';
|
|
9
|
-
context_1.Context.files = [];
|
|
10
|
-
context_1.Context.rawDefinitions = [];
|
|
11
|
-
context_1.Context.errorLogs = [];
|
|
12
|
-
context_1.Context['errorLogBuffer'] = [];
|
|
13
|
-
context_1.Context.output = [];
|
|
14
|
-
}
|
|
15
|
-
exports.resetContext = resetContext;
|
|
16
|
-
function setMockContextFromContents(contents) {
|
|
17
|
-
resetContext();
|
|
18
|
-
let fileIndex = 0;
|
|
19
|
-
contents.forEach(content => {
|
|
20
|
-
fileIndex++;
|
|
21
|
-
context_1.Context.files.push({ path: `D:/test/file-${fileIndex}.md`, content });
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.setMockContextFromContents = setMockContextFromContents;
|
|
25
|
-
function getMockFileInfo(content) {
|
|
26
|
-
return {
|
|
27
|
-
content,
|
|
28
|
-
path: 'D:/test/sample.md'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.getMockFileInfo = getMockFileInfo;
|
|
32
|
-
exports.SampleLocation1 = {
|
|
33
|
-
line: 2,
|
|
34
|
-
path: 'D:/test/file-1.md'
|
|
35
|
-
};
|
|
36
|
-
exports.SampleLocation2 = {
|
|
37
|
-
line: 2,
|
|
38
|
-
path: 'D:/test/file-2.md'
|
|
39
|
-
};
|
|
40
|
-
exports.SampleLocation3 = {
|
|
41
|
-
line: 2,
|
|
42
|
-
path: 'D:/test/file-3.md'
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=mocks.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { Output } from '../framework/interfaces';
|
|
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(meta: DefinitionComponentMeta): (ComponentClass: DefinitionComponentClassType<any>) => any;
|
|
11
|
-
export declare abstract class DefinitionComponent<T> {
|
|
12
|
-
static getSchema(): Joi.Schema;
|
|
13
|
-
abstract process(definitions: T[], context: Output): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare abstract class SingleDefinitionComponent<T> {
|
|
16
|
-
static getSchema(): Joi.Schema;
|
|
17
|
-
abstract process(definitions: T, context: Output): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SingleDefinitionComponent = exports.DefinitionComponent = exports.DefinitionComponentDecorator = void 0;
|
|
4
|
-
function toPascalCase(input) {
|
|
5
|
-
return input
|
|
6
|
-
.replace(/[-_]/g, ' ')
|
|
7
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
8
|
-
.replace(/\s+/g, ' ')
|
|
9
|
-
.trim()
|
|
10
|
-
.toLowerCase()
|
|
11
|
-
.split(' ')
|
|
12
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
13
|
-
.join('');
|
|
14
|
-
}
|
|
15
|
-
function DefinitionComponentDecorator(meta) {
|
|
16
|
-
return function (ComponentClass) {
|
|
17
|
-
if (meta.singleton) {
|
|
18
|
-
if (meta.keyName !== undefined) {
|
|
19
|
-
throw new Error(`Singleton components should not have keyName! Component: ${meta.componentName}`);
|
|
20
|
-
}
|
|
21
|
-
if (!(ComponentClass.prototype instanceof SingleDefinitionComponent)) {
|
|
22
|
-
throw new Error(`Singleton components should extend SingleDefinitionComponent! Component: ${meta.componentName}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (!(ComponentClass.prototype instanceof DefinitionComponent)) {
|
|
27
|
-
throw new Error(`Non singleton components should extend DefinitionComponent! Component: ${meta.componentName}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
ComponentClass.$meta = {
|
|
31
|
-
componentName: meta.componentName,
|
|
32
|
-
pascalCaseComponentName: toPascalCase(meta.componentName),
|
|
33
|
-
keyName: meta.keyName,
|
|
34
|
-
singleton: meta.singleton,
|
|
35
|
-
validationSchema: meta.validationSchema
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
exports.DefinitionComponentDecorator = DefinitionComponentDecorator;
|
|
40
|
-
class DefinitionComponent {
|
|
41
|
-
static getSchema() {
|
|
42
|
-
return this.$meta.validationSchema;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.DefinitionComponent = DefinitionComponent;
|
|
46
|
-
class SingleDefinitionComponent {
|
|
47
|
-
static getSchema() {
|
|
48
|
-
return this.$meta.validationSchema;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.SingleDefinitionComponent = SingleDefinitionComponent;
|
|
52
|
-
//# sourceMappingURL=definition-component.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponentClassType } from './definition-component';
|
|
2
|
-
interface DefinitionGeneratorMeta {
|
|
3
|
-
modules: DefinitionComponentClassType<any>[];
|
|
4
|
-
indexFilePretext: string;
|
|
5
|
-
outputIndexFile: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function DefinitionGeneratorDecorator(meta: DefinitionGeneratorMeta): (ModuleClass: DefinitionGeneratorClassType) => any;
|
|
8
|
-
export type DefinitionGeneratorClassType = new (...args: any[]) => DefinitionGenerator;
|
|
9
|
-
export declare abstract class DefinitionGenerator {
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -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
|
-
}
|