@aventusjs/cli 0.0.28 → 0.0.30
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/out/RealServer.js +10 -6
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealServer.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
4
4
|
`)}}function Pe(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
5
5
|
`)}}function Fe(e,t){return Ie(e,t,0,e.getText().length)}function Ie(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
6
6
|
`)}}function Le(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Warning,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
7
|
-
`)}}function Re(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function ze(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function Be(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Ve(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Ve(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function He(e){return e===13||e===10}const Ue=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function We(e,t){let n=Ue,r=t;for(;r>0&&!He(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function Ge(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function Ke(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}const qe={};function Je(e,t,n,r){t=t.replace(/\r\n
|
|
7
|
+
`)}}function Re(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function ze(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function Be(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Ve(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Ve(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function He(e){return e===13||e===10}const Ue=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function We(e,t){let n=Ue,r=t;for(;r>0&&!He(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function Ge(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function Ke(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}const qe={};function Je(e,t,n,r){t=t.replace(/\r\n?/g,`
|
|
8
8
|
`);let i=Ye(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!qe[e]||qe[e]!=i||!o)&&(qe[e]=i,Ce.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function Ye(e){return(0,_.createHash)(`md5`).update(e).digest(`hex`)}var Xe=class{static timers={};static start(e){this.timers[e]=process.hrtime()}static stop(e){let t=process.hrtime(this.timers[e]),n=t[1]/1e6;return delete this.timers[e],t[0]*1e3+Math.round(n)}static stopNano(e){let t=process.hrtime(this.timers[e]);return delete this.timers[e],t[0]*1e9+t[1]}};const Ze=new Uint8Array(16);function Qe(){return crypto.getRandomValues(Ze)}const $e=[];for(let e=0;e<256;++e)$e.push((e+256).toString(16).slice(1));function et(e,t=0){return($e[e[t+0]]+$e[e[t+1]]+$e[e[t+2]]+$e[e[t+3]]+`-`+$e[e[t+4]]+$e[e[t+5]]+`-`+$e[e[t+6]]+$e[e[t+7]]+`-`+$e[e[t+8]]+$e[e[t+9]]+`-`+$e[e[t+10]]+$e[e[t+11]]+$e[e[t+12]]+$e[e[t+13]]+$e[e[t+14]]+$e[e[t+15]]).toLowerCase()}function k(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():tt(e,t,n)}function tt(e,t,n){e||={};let r=e.random??e.rng?.()??Qe();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return et(r)}var A=class{_documentUser;_documentInternal;get documentUser(){return this._documentUser}get documentInternal(){return this._documentInternal}linkInternalAndUser=!0;setDocumentInternal(e){this._documentInternal=e,this._versionInternal=e.version}constructor(e){this._documentUser=e,this._documentInternal=e,this._versionUser=e.version,this._versionInternal=e.version}get uri(){return this.documentUser.uri}get path(){return D(this.uri)}get name(){return this.path.split(`/`).pop()??``}_versionUser=0;get versionUser(){return this._versionUser}_versionInternal=0;get versionInternal(){return this._versionInternal}get contentUser(){return this.documentUser.getText()}get contentInternal(){return this.documentInternal.getText()}get folderUri(){return Re(this.uri)}get folderPath(){return Re(this.path)}_shortname=``;get shortname(){if(!this._shortname){let e=this.uri.split(`/`);this._shortname=e[e.length-1]}return this._shortname}onGetBuildCb={};getBuild(){let e=[],t=!1;for(let n in this.onGetBuildCb){let r=this.onGetBuildCb[n]();if(r===null)t=!0;else for(let t of r)e.indexOf(t)==-1&&e.push(t)}return e.length==0&&t?null:e}onGetBuild(e){let t=k();for(;this.onGetBuildCb[t]!=null;)t=k();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};async validate(e=!0){let t={};for(let e in this.onValidateCb){let n=await this.onValidateCb[e](this);for(let e of n){let n=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;t[n]||(t[n]=e)}}if(e)if(T.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});else for(let n of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)},n)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});return Object.values(t)}onValidate(e){let t=k();for(;this.onValidateCb[t]!=null;)t=k();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};triggerContentChange(e){return new Promise(t=>{if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{this.waitingDocContentChange[e.uri]?(this.resolveContentChange[e.uri]||(this.resolveContentChange[e.uri]={}),this.resolveContentChange[e.uri][e.version]||(this.resolveContentChange[e.uri][e.version]=[]),this.resolveContentChange[e.uri][e.version].push(t),this.waitingDocContentChange[e.uri]=e):(this.waitingDocContentChange[e.uri]=!0,this.resolveContentChange[e.uri]={[e.version]:[t]},this.triggerContentChangeNoBuffer(e))},0)})}async triggerContentChangeNoBuffer(e){let t=e.version;this._documentUser=e,this._versionUser=e.version,this.linkInternalAndUser&&(this._documentInternal=e,this._versionInternal=e.version);let n=[];for(let e in this.onContentChangeCb)n.push(this.onContentChangeCb[e](this));if(await Promise.all(n),this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(async()=>{this.validate()},500),this.resolveContentChange[e.uri]){let n=Object.keys(this.resolveContentChange[e.uri]);for(let r of n){if(Number(r)>t)break;if(this.resolveContentChange[e.uri][r]){for(let t of this.resolveContentChange[e.uri][r])t();delete this.resolveContentChange[e.uri][r]}}Object.keys(this.resolveContentChange[e.uri]).length==0&&delete this.resolveContentChange[e.uri]}let r=this.waitingDocContentChange[e.uri];r&&typeof r!=`boolean`?(this.waitingDocContentChange[e.uri]=!0,this.triggerContentChangeNoBuffer(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=k();for(;this.onContentChangeCb[t]!=null;)t=k();return this.onContentChangeCb[t]=e,t}removeOnContentChange(e){delete this.onContentChangeCb[e]}onCanContentChangeCb={};triggerCanContentChange(e){for(let t in this.onCanContentChangeCb)if(!this.onCanContentChangeCb[t](e))return!1;return!0}onCanContentChange(e){let t=k();for(;this.onCanContentChangeCb[t]!=null;)t=k();return this.onCanContentChangeCb[t]=e,t}removeOnCanContentChange(e){delete this.onCanContentChangeCb[e]}async applyTextEdits(e){let t=this.contentUser;e.sort((e,t)=>this.documentUser.offsetAt(t.range.end)-this.documentUser.offsetAt(e.range.end));for(let n of e){let e=this.documentUser.offsetAt(n.range.start),r=this.documentUser.offsetAt(n.range.end);t=t.slice(0,e)+n.newText+t.slice(r,t.length)}let n=d.TextDocument.create(this.uri,C.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb)await this.onSaveCb[e](this)}onSave(e){let t=k();for(;this.onSaveCb[t]!=null;)t=k();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));await Promise.all(e),this.removeAllCallbacks()}removeAllCallbacks(){this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=k();for(;this.onDeleteCb[t]!=null;)t=k();return this.onDeleteCb[t]=e,t}removeOnDelete(e){delete this.onDeleteCb[e]}onCompletionCb={};async getCompletion(e){let t={isIncomplete:!1,items:[]},n=[];for(let t in this.onCompletionCb)n.push(this.onCompletionCb[t](this,e));let r=await Promise.all(n),i={};for(let e of r)for(let t of e.items){let e=JSON.stringify(t);i[e]||(i[e]=t)}return t.items=Object.values(i),t}onCompletion(e){let t=k();for(;this.onCompletionCb[t]!=null;)t=k();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e,n=[];for(let t in this.onCompletionResolveCb)n.push(this.onCompletionResolveCb[t](this,e));return t}onCompletionResolve(e){let t=k();for(;this.onCompletionResolveCb[t]!=null;)t=k();return this.onCompletionResolveCb[t]=e,t}removeOnCompletionResolve(e){delete this.onCompletionResolveCb[e]}onHoverCb={};async getHover(e){let t=[];for(let n in this.onHoverCb)t.push(this.onHoverCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onHover(e){let t=k();for(;this.onHoverCb[t]!=null;)t=k();return this.onHoverCb[t]=e,t}removeOnHover(e){delete this.onHoverCb[e]}onDefinitionCb={};async getDefinition(e){let t=[];for(let n in this.onDefinitionCb)t.push(this.onDefinitionCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onDefinition(e){let t=k();for(;this.onDefinitionCb[t]!=null;)t=k();return this.onDefinitionCb[t]=e,t}removeOnDefinition(e){delete this.onDefinitionCb[e]}onFormattingCb={};async getFormatting(e){e||={insertSpaces:!0,tabSize:4};let t={},n=[],r={start:this.documentUser.positionAt(0),end:this.documentUser.positionAt(this.documentUser.getText().length)};for(let t in this.onFormattingCb)n.push(this.onFormattingCb[t](this,r,e));let i=await Promise.all(n);for(let e of i)for(let n of e){let e=JSON.stringify(n);t[e]||(t[e]=n)}return Object.values(t)}onFormatting(e){let t=k();for(;this.onFormattingCb[t]!=null;)t=k();return this.onFormattingCb[t]=e,t}removeOnFormatting(e){delete this.onFormattingCb[e]}onCodeActionCb={};async getCodeAction(e){let t=[],n=[];for(let t in this.onCodeActionCb)n.push(this.onCodeActionCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onCodeAction(e){let t=k();for(;this.onCodeActionCb[t]!=null;)t=k();return this.onCodeActionCb[t]=e,t}removeOnCodeAction(e){delete this.onCodeActionCb[e]}onReferencesCb={};async getReferences(e){let t=[],n=[];for(let t in this.onReferencesCb)n.push(this.onReferencesCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onReferences(e){let t=k();for(;this.onReferencesCb[t]!=null;)t=k();return this.onReferencesCb[t]=e,t}removeOnReferences(e){delete this.onReferencesCb[e]}onCodeLensCb={};async getCodeLens(){let e=[],t=[];for(let e in this.onCodeLensCb)t.push(this.onCodeLensCb[e](this));let n=await Promise.all(t);for(let t of n)e=[...e,...t];return e}onCodeLens(e){let t=k();for(;this.onCodeLensCb[t]!=null;)t=k();return this.onCodeLensCb[t]=e,t}removeOnCodeLens(e){delete this.onCodeLensCb[e]}onRenameCb={};async getRename(e,t){let n=[];for(let r in this.onRenameCb)n.push(this.onRenameCb[r](this,e,t));let r=await Promise.all(n);for(let e of r)if(e)return e;return null}onRename(e){let t=k();for(;this.onRenameCb[t]!=null;)t=k();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},nt=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},rt=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){T.getInstance().settings.watchFiles&&(this.watcher=(0,v.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onContentChange.bind(this)).on(`change`,this.onContentChange.bind(this)).on(`unlink`,this.onRemove.bind(this)))}watcheUris=[];watch(e){if(this.watcheUris.includes(e)||!this.watcher)return;this.watcheUris.push(e);let t=D(e);this.watcher.add(t)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&this.watcheUris.splice(t,1)}async onContentChange(e){$.debug(`onContentChange : `+e);let t=E(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=E(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}};const it={$schema:`foo://aventus/conf.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for all your builds (x.x.x)`},description:{type:`string`,description:`Description of the package`},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},hideWarnings:{type:`boolean`,description:`Hide warnings for all your builds`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},dependencies:{$ref:`#/$defs/dependencies`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},build:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:"Part name for the module. The export file will be ${module}@${name}",pattern:`^[a-zA-Z0-9_]+$`},description:{type:`string`,description:`Description of the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for this build (x.x.x)`},disabled:{type:`boolean`,description:`Disable auto-build`,default:!0},hideWarnings:{type:`boolean`,description:`Hide warnings for this build`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},src:{type:`array`,items:{type:`string`},description:`List of all pathes to listen watch`},stories:{type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define where to export your stories`},workspace:{type:`string`,description:`Define where to add the .storybook`},live:{type:`boolean`,description:`Define if the story content must be recompiled on change`},format:{type:`string`,enum:[`all`,`public`,`protected`,`manual`],default:`all`,description:`All will export all elements, public only public elements, protected only public and protected elements, manual only elements with tag Storybook`},prefix:{type:`string`,description:`Define a prefix for all your stories name. Allow to group stories`},srcBaseUrl:{type:`string`,description:`Define a base url to link file to your repo`}}},outsideModule:{type:`array`,items:{type:`string`},description:`List of all pathes to import outside the module`},compile:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{input:{type:[`string`,`array`],items:{type:`string`},description:`List of all pathes to import inside this build`},output:{type:[`string`,`array`,`object`],description:`The script file generated path`,pattern:`^\\S+\\.js`,items:{type:[`string`,`object`],pattern:`^\\S+\\.js`,properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},outputNpm:{type:[`string`,`array`,`object`],additionalProperties:!1,properties:{path:{type:[`string`,`array`]},packageJson:{type:`boolean`,description:`Define if you need to generate a package.json`},npmName:{type:`string`,description:`Define the name set inside your package.json`},manifest:{type:`boolean`,description:`Define if you need to generate manifest for your components`},live:{type:`boolean`,description:`Define if the npm content must be recompiled on change. Default is false`}},items:{type:`string`},description:`Define where to export as npm files`},compressed:{type:`boolean`},package:{type:[`string`,`array`],items:{type:`string`,pattern:`^\\S+\\.package\\.avt`},pattern:`^\\S+\\.package\\.avt`,description:`The package file generated path (for lib)`},i18n:{type:[`string`,`array`],items:{type:`object`,additionalProperties:!1,properties:{output:{type:[`string`,`array`],items:{type:`string`}},mount:{type:`string`},mode:{type:`string`,enum:[`singleFile`,`oneToOne`,`groupComponent`,`basedOnAttribute`,`include`],default:`singleFile`}},required:[`output`]}}}}},dependencies:{$ref:`#/$defs/dependencies`},module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module for this build`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},nodeModulesDir:{type:[`string`,`array`],items:{type:`string`},description:`The dirs where node_modules are located`},i18n:{type:`object`,properties:{locales:{type:`array`,items:{type:`string`},description:`Locales that is required inside your project`},fallback:{type:`string`},autoRegister:{type:`boolean`}},description:`Define options for i18n`}},required:[`src`]},minItems:1},static:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:`Part name for the static export`,pattern:`^[a-zA-Z0-9_]+$`},input:{type:`string`,description:`Input path to watch to export as static files`},output:{type:[`string`,`array`],items:{type:`string`},description:`Define where to export static files`}},required:[`name`,`input`,`output`]}},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},aliases:{type:`object`}},required:[`build`,`module`],$defs:{dependencies:{type:`object`,description:`List of dependencies for this build`,patternProperties:{"^\\S+$":{type:[`object`,`string`],additionalProperties:!1,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,properties:{uri:{type:`string`,description:`Where to find the package or the json file`},npm:{type:`string`,description:`The npm package name`},version:{type:`string`,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,description:`The version to use for this file. (default is x.x.x)`,default:`x.x.x`},isLocal:{type:`boolean`,description:`Define if you want to use a local package`},include:{type:`string`,description:`Determine if the package must be included inside the final export. (default is need)`,enum:[`none`,`need`,`full`],default:`need`},subDependenciesInclude:{type:`object`,description:`Inclusion pattern for each lib. You can use a star to select everythink. If nothink find for a lib, the need value ll be used`,patternProperties:{"^\\S+$":{type:`string`,enum:[`none`,`need`,`full`],default:`need`}}}}}}},compileOutput:{type:[`string`,`object`],pattern:`^\\S+\\.js`,additionalProperties:!1,properties:{path:{type:`string`,pattern:`^\\S+\\.js`},compressed:{type:`boolean`}}}}},at={$schema:`foo://aventus/sharp.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{csProj:{type:`string`,pattern:`^\\S+\\.csproj`,description:`Path to your csproj file`},outputPath:{type:`string`,description:`Define the folder where to export the code`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if errors must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEndPointByDefault:{type:`boolean`,default:!0,description:`Define if websocket endpoint must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEventByDefault:{type:`boolean`,default:!0,description:`Define if websocket event must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsRouteByDefault:{type:`boolean`,default:!0,description:`Define if websocket route must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},wsEndPoint:{$ref:`#/$defs/replacerPart`},wsEvent:{$ref:`#/$defs/replacerPart`},wsRouter:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to use for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`},addFormData:{type:`boolean`,default:!0,description:"Add ` | FormData` to the route body"},cacheByDefault:{type:`boolean`,default:!1,description:`Add cache to the function generated`},clearCacheFct:{type:`boolean`,default:!1,description:`Add function to clear cache to the function generated`}}},wsEndpoint:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},prefix:{type:`string`,default:`Define a prefix for your websocket events`},host:{type:`string`,description:`The host to connect to the websocket`},port:{type:`number`,description:`The port to connect to the websocket`},useHttps:{type:`boolean`,description:`Define if you want to use http or https. Be default, Aventus will check if your connection is secure to use https or not`},parent:{type:`string`,default:`AventusSharp.WebSocket.EndPoint`,description:`Define the parent type to use for your router`}}}},required:[`csProj`,`outputPath`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}},ot={$schema:`foo://aventus/php.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define the folder where to export the code`},exportAsTs:{type:`boolean`,description:`Define if the code must be compiled as typescript`},useNamespace:{type:`boolean`,description:`Define if the compiler must used namespace`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRequestByDefault:{type:`boolean`,default:!0,description:`Define if request must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpResourceByDefault:{type:`boolean`,default:!0,description:`Define if resource must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if erros must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},httpRequest:{$ref:`#/$defs/replacerPart`},httpResource:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to load for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`}}}},required:[`output`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}};var st=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,y.getLanguageService)({schemaRequestService:async e=>JSON.stringify(it)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.Config],uri:it.$schema??``,schema:it},{fileMatch:[`**`+w.CsharpConfig],uri:at.$schema??``,schema:at},{fileMatch:[`**`+w.PhpConfig],uri:ot.$schema??``,schema:ot}]})}async format(e,t,n){let r=e.documentUser;return await this.languageService.format(r,t,n)}async doComplete(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doComplete(e.documentUser,t,r),a=r.getNodeFromOffset(n.offsetAt(t));return this.isKeyOfObject(a,`dependencies`)&&(i||={isIncomplete:!1,items:[]},i?.items.push({label:`Aventus@Main`},{label:`Aventus@UI`},{label:`Aventus@I18n`},{label:`Aventus@Sharp`},{label:`Aventus@Php`})),i||{isIncomplete:!1,items:[]}}async doResolve(e){return await this.languageService.doResolve(e)}async doHover(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n);return await this.languageService.doHover(n,t,r)}async validate(e){let t=e.documentUser,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=this.removeComments(t.getText());try{return JSON.parse(e),r}catch{r.push(Ae(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}isKeyOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.keyNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}isValueOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.valueNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}async getConfig(e){let t=`documentUser`in e?e.documentUser:e,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n,void 0,it);if(r.length==0){let e=this.removeComments(t.getText());try{let n=JSON.parse(e);return n=this.prepareConfigFile(t.uri,n),n}catch{r.push(Ae(t,`Can't parse the json`,1001))}}return null}prepareConfigFile(e,t){if(t={...this.defaultConfigValue(),...t},t.componentPrefix==``){let e=t.module.match(/([A-Z][a-z]*)|([0-9][a-z]*)/g);e?t.componentPrefix=e.join(`-`).toLowerCase():t.componentPrefix=`av`}let n=[];for(let r of t.build)n.push(this.prepareBuild(e,r,t));if(t.build=n,t.static){let n=[];for(let r of t.static)n.push(this.prepareStatic(e,r));t.static=n}return t}replaceEnvVar(e,t){if(!e||e.startsWith(`@`)||e.startsWith(`Aventus@`))return e;let n=/%(.*?)%/gm,r;for(;r=n.exec(e);){let t=b.env[r[1]]??`undefined`;e=e.replace(r[0],t)}return/^https?:\/\/.*/.exec(e)||(!e.startsWith(`/`)&&!/^[a-zA-Z]:/gm.test(e)?(e=`/`+e,e=(0,f.normalize)(D(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=Re(e);t={...this.defaultConfigBuildValue(n),...t},t.name?t.fullname=t.module+`@`+t.name:t.fullname=t.module;let i=e=>this.replaceEnvVar(e,r),a=t.compile;for(let e of a){if(!e.input)e.inputPathRegex=RegExp(`.*`);else{Array.isArray(e.input)||(e.input=[e.input]);let t=[];for(let n of e.input){let e=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(e=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+e+n).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),t.push(`(^`+a+`$)`)}let n=t.join(`|`);n==``&&(n=`(?!)`),e.inputPathRegex=new RegExp(n)}if(!e.output)e.output=[];else{Array.isArray(e.output)||(e.output=[e.output]);for(let t=0;t<e.output.length;t++){let n=e.output[t];typeof n==`string`&&(e.output[t]={"@default":{path:n}},n=e.output[t]);let r=!1;for(let a in n){a==`@default`&&(r=!0);let o=n[a];typeof o==`string`&&(e.output[t][a]={path:o}),e.output[t][a].path=n[a].path.trim(),n[a].path.length>0&&(e.output[t][a].path=i(n[a].path))}r||(e.output[t][`@default`]={path:`./dist/script.js`})}}if(!e.outputNpm)e.outputNpm={path:[],packageJson:!1,npmName:``,live:!1};else{typeof e.outputNpm==`string`?e.outputNpm={path:[e.outputNpm],packageJson:!0,npmName:``,manifest:{},live:!1}:Array.isArray(e.outputNpm)&&(e.outputNpm={path:e.outputNpm,packageJson:!0,npmName:``,manifest:{},live:!1}),Array.isArray(e.outputNpm.path)||(e.outputNpm.path=[e.outputNpm.path]),e.outputNpm.packageJson===void 0&&(e.outputNpm.packageJson=!0),e.outputNpm.manifest===void 0&&(e.outputNpm.manifest={}),e.outputNpm.npmName===void 0&&(e.outputNpm.npmName=``),e.outputNpm.live===void 0&&(e.outputNpm.live=!1);for(let t=0;t<e.outputNpm.path.length;t++){let n=i(e.outputNpm.path[t]);n.endsWith(`*`)&&(n=n.slice(0,-1)),n.endsWith(`/`)&&(n=n.slice(0,-1)),n=n.replace(/\\/g,`/`),e.outputNpm.path[t]=n}}if(!e.package)e.package=[];else{Array.isArray(e.package)||(e.package=[e.package]);for(let t=0;t<e.package.length;t++)e.package[t]=e.package[t].trim(),e.package[t].length>0&&(e.package[t]=i(e.package[t]))}if(t.i18n)if(e.i18n){Array.isArray(e.i18n)||(e.i18n=[{output:[e.i18n],mount:``,mode:`singleFile`}]);for(let t=0;t<e.i18n.length;t++){if(!Array.isArray(e.i18n[t].output)){let n=e.i18n[t].output;e.i18n[t].output=[n]}for(let n=0;n<e.i18n[t].output.length;n++)e.i18n[t].output[n].endsWith(`/`)&&(e.i18n[t].output[n]=e.i18n[t].output[n].slice(0,-1)),e.i18n[t].output[n]=e.i18n[t].output[n].trim(),e.i18n[t].output[n].length>0&&(e.i18n[t].output[n]=i(e.i18n[t].output[n]));if(!e.i18n[t].mount&&e.i18n[t].output.length>0){let n=(0,f.normalize)(D($.getWorkspaceUri())),r=e.i18n[t].output[0].replace(n,``).replace(/\\/g,`/`);r.startsWith(`/dist`)&&(r=r.replace(`/dist`,``)),e.i18n[t].mount=r}e.i18n[t].mount.endsWith(`/`)&&(e.i18n[t].mount=e.i18n[t].mount.slice(0,-1))}}else{e.i18n=[];for(let t of e.output){let n=t[`@default`].path.split(f.sep);n.pop();let r=(0,f.join)(n.join(f.sep),`locales`),i=(0,f.normalize)(D($.getWorkspaceUri())),a=r.replace(i,``).replace(/\\/g,`/`);a.startsWith(`/dist`)&&(a=a.replace(`/dist`,``)),e.i18n.push({output:[r],mount:a,mode:`singleFile`})}}}let o=[];for(let e of t.src){let n=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(n=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=Ve(a,!0).replace(`*`,`.*`),o.push(`(^`+a+`$)`)}if(t.stories){t.stories={...this.defaultConfigBuildStories(r,n),...t.stories};let e=i(t.stories.output);e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.stories.output=e}let s=o.join(`|`);s==``&&(s=`(?!)`),t.srcPathRegex=new RegExp(s),t.nodeModulesDir=t.nodeModulesDir.trim(),t.nodeModulesDir==``?t.nodeModulesDir=(0,f.normalize)(D(r)+`/node_modules`):t.nodeModulesDir=i(t.nodeModulesDir);let c={};t.rawDependencies=JSON.parse(JSON.stringify(t.dependencies));for(let e in t.dependencies){let n=t.dependencies[e];typeof n==`string`&&(n={version:n}),c[e]={...this.defaultConfigBuildDependencyValue(n),...n};let r=c[e];r.subDependenciesInclude||={},r.subDependenciesInclude[`*`]||(r.subDependenciesInclude[`*`]=n.include??`need`),r.uri&&=i(r.uri)}if(t.dependencies=c,t.outsideModule){let e=[];for(let n of t.outsideModule){let t=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(t=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+t+n).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),e.push(`(^`+a+`$)`)}let n=e.join(`|`);n==``&&(n=`(?!)`),t.outsideModulePathRegex=new RegExp(n)}if(t.namespaceStrategy==`rules`)for(let e in t.namespaceRules){let n=[],i=t.namespaceRules[e];for(let e of i){let t=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(t=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+t+e).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),n.push(`(^`+a+`$)`)}let a=n.join(`|`);a==``&&(a=`(?!)`),t.namespaceRulesRegex[e]=new RegExp(a)}else if(t.namespaceStrategy==`followFolders`||t.namespaceStrategy==`followFoldersCamelCase`){let e=``;t.namespaceRoot.startsWith(`/`)||(e=`/`),t.namespaceRoot=(0,f.normalize)(D(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=Re(e),r=``;t.input.startsWith(`/`)||(r=`/`),t.input.endsWith(`*`)&&(t.input=t.input.slice(0,-1)),t.input.endsWith(`/`)&&(t.input=t.input.slice(0,-1)),t.inputPathFolder=(0,f.normalize)(D(n)+r+t.input),t.inputPathFolder=t.inputPathFolder.replace(/\\/g,`/`),r=``,Array.isArray(t.output)||(t.output=[t.output]),t.outputPathFolder=[];for(let e of t.output)e=this.replaceEnvVar(e,n),e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:T.getInstance().settings.defaultHideWarnings,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`}}defaultConfigBuildValue(e){return{fullname:``,name:``,tags:e.tags,version:e.version,organization:e.organization,description:e.description,readme:e.readme,repository:e.repository,documentation:e.documentation,disabled:!1,hideWarnings:e.hideWarnings,src:[],srcPath:[],stories:void 0,compile:[],srcPathRegex:RegExp(`(?!)`),outsideModule:[],outsideModulePathRegex:RegExp(`(?!)`),module:e.module,componentPrefix:e.componentPrefix,namespaceStrategy:e.namespaceStrategy,namespaceRules:{...e.namespaceRules},namespaceRulesRegex:{...e.namespaceRulesRegex},namespaceRoot:e.namespaceRoot,dependencies:{...e.dependencies},rawDependencies:{},avoidParsingInsideTags:[...e.avoidParsingInsideTags],nodeModulesDir:``}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}},ct=class{_file;_build;get file(){return this._file}get build(){if(this._build)return this._build;throw`No build found`}constructor(e,t){this._file=e,this._build=t,this.addEvents()}uuidEvents={onCanContentChange:``,onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onGetBuild:``,onRename:``};addEvents(){this.uuidEvents.onCanContentChange=this.file.onCanContentChange(this.onCanContentChange.bind(this)),this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onGetBuild=this.file.onGetBuild(this.onGetBuild.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnCanContentChange(this.uuidEvents.onCanContentChange),this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnGetBuild(this.uuidEvents.onGetBuild),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}async triggerSave(){this.file instanceof A&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof A&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof A&&await this.file.triggerContentChange(e)}onCanContentChange(e){return this._file.versionUser!=e.version}oldResult=[];async _onValidate(){let e=this._build?.diagnostics.get(this)??[];return e=[...e,...await this.onValidate()],this._build&&this.build.hideWarnings&&(e=e.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},lt=o(((e,t)=>{var n=require("stream");e=t.exports=r,r.through=r;function r(e,t,r){e||=function(e){this.queue(e)},t||=function(){this.queue(null)};var i=!1,a=!1,o=[],s=!1,c=new n;c.readable=c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&r.autoDestroy===!1),c.write=function(t){return e.call(this,t),!c.paused};function l(){for(;o.length&&!c.paused;){var e=o.shift();if(e===null)return c.emit(`end`);c.emit(`data`,e)}}c.queue=c.push=function(e){return s?c:(e===null&&(s=!0),o.push(e),l(),c)},c.on(`end`,function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick(function(){c.destroy()})});function u(){c.writable=!1,t.call(c),!c.readable&&c.autoDestroy&&c.destroy()}return c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),u(),c},c.destroy=function(){if(!a)return a=!0,i=!0,o.length=0,c.writable=c.readable=!1,c.emit(`close`),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit(`resume`)),l(),c.paused||c.emit(`drain`),c},c}})),ut=o(((e,t)=>{var n=require("stream");t.exports=function e(t){if(Array.isArray(t)){var r=0,i=t.length;return e(function(e){return r<i?this.emit(`data`,t[r++]):this.emit(`end`),!0})}var a=new n,o=0;a.ended=!1,a.started=!1,a.readable=!0,a.writable=!1,a.paused=!1,a.ended=!1,a.pause=function(){a.started=!0,a.paused=!0};function s(){if(a.started=!0,!a.ended)for(;!a.ended&&!a.paused&&t.call(a,o++,function(){!a.ended&&!a.paused&&process.nextTick(s)}););}return a.resume=function(){a.started=!0,a.paused=!1,s()},a.on(`end`,function(){a.ended=!0,a.readable=!1,process.nextTick(a.destroy)}),a.destroy=function(){a.ended=!0,a.emit(`close`)},process.nextTick(function(){a.started||a.resume()}),a}})),dt=o(((e,t)=>{var n=require("stream"),r=[`write`,`end`,`destroy`],i=[`resume`,`pause`],a=[`data`,`close`],o=Array.prototype.slice;t.exports=c;function s(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n)}function c(e,t){var c=new n,l=!1;return s(r,u),s(i,d),s(a,f),t.on(`end`,p),e.on(`drain`,function(){c.emit(`drain`)}),e.on(`error`,m),t.on(`error`,m),c.writable=e.writable,c.readable=t.readable,c;function u(t){c[t]=n;function n(){return e[t].apply(e,arguments)}}function d(e){c[e]=n;function n(){c.emit(e);var n=t[e];if(n)return n.apply(t,arguments);t.emit(e)}}function f(e){t.on(e,n);function n(){var t=o.call(arguments);t.unshift(e),c.emit.apply(c,t)}}function p(){if(!l){l=!0;var e=o.call(arguments);e.unshift(`end`),c.emit.apply(c,e)}}function m(e){c.emit(`error`,e)}}})),ft=o(((e,t)=>{var n=require("stream").Stream;t.exports=function(e,t){var r=new n,i=0,a=0,o=!1,s=!1,c=!1,l=0,u=!1;t||={};var d=t.failures?`failure`:`error`,f={};r.writable=!0,r.readable=!0;function p(e,t){var n=l+1;if(t===n?(e!==void 0&&r.emit.apply(r,[`data`,e]),l++,n++):f[t]=e,f.hasOwnProperty(n)){var c=f[n];return delete f[n],p(c,n)}a++,i===a&&(s&&(s=!1,r.emit(`drain`)),o&&g())}function m(e,n,i){c||(u=!0,(!e||t.failures)&&p(n,i),e&&r.emit.apply(r,[d,e]),u=!1)}function h(t,n,r){return e.call(null,t,function(e,t){r(e,t,n)})}r.write=function(e){if(o)throw Error(`map stream is not writable`);u=!1,i++;try{return s=h(e,i,m)===!1,!s}catch(e){if(u)throw e;return m(e),!s}};function g(e){if(o=!0,r.writable=!1,e!==void 0)return p(e,i);i==a&&(r.readable=!1,r.emit(`end`),r.destroy())}return r.end=function(e){o||g(e)},r.destroy=function(){o=c=!0,r.writable=r.readable=s=!1,process.nextTick(function(){r.emit(`close`)})},r.pause=function(){s=!0},r.resume=function(){s=!1},r}})),pt=o(((e,t)=>{t.exports=lt()})),mt=o(((e,t)=>{var n=lt(),r=require("string_decoder").StringDecoder;t.exports=i;function i(e,t,i){var a=new r,o=``,s=i&&i.maxLength,c=!(i&&i.trailing===!1);typeof e==`function`&&(t=e,e=null),e||=/\r?\n/;function l(e,n){if(t){try{n=t(n)}catch(t){return e.emit(`error`,t)}n!==void 0&&e.queue(n)}else e.queue(n)}function u(t,n){var r=((o??``)+n).split(e);if(o=r.pop(),s&&o.length>s)return t.emit(`error`,Error(`maximum buffer reached`));for(var i=0;i<r.length;i++){var a=r[i];l(t,a)}}return n(function(e){u(this,a.write(e))},function(){a.end&&u(this,a.end()),c&&o!=null&&l(this,o),this.queue(null)})}})),ht=o(((e,t)=>{var n=dt(),r=lt();t.exports=function(){var e=arguments.length==1&&Array.isArray(arguments[0])?arguments[0]:[].slice.call(arguments);if(e.length==0)return r();if(e.length==1)return e[0];var t=e[0],i=e[e.length-1],a=n(t,i);function o(e){e.length<2||(e[0].pipe(e[1]),o(e.slice(1)))}o(e);function s(){var e=[].slice.call(arguments);e.unshift(`error`),a.emit.apply(a,e)}for(var c=1;c<e.length-1;c++)e[c].on(`error`,s);return a}})),gt=o((e=>{var t=require("stream").Stream,n=e,r=lt(),i=ut(),a=dt(),o=ft(),s=pt(),c=mt(),l=ht(),u=global.setImmediate||process.nextTick;n.Stream=t,n.through=r,n.from=i,n.duplex=a,n.map=o,n.pause=s,n.split=c,n.pipeline=n.connect=n.pipe=l,n.concat=n.merge=function(){var e=[].slice.call(arguments);e.length===1&&e[0]instanceof Array&&(e=e[0]);var n=new t;n.setMaxListeners(0);var r=0;return n.writable=n.readable=!0,e.length?e.forEach(function(t){t.pipe(n,{end:!1});var i=!1;t.on(`end`,function(){i||(i=!0,r++,r==e.length&&n.emit(`end`))})}):process.nextTick(function(){n.emit(`end`)}),n.write=function(e){this.emit(`data`,e)},n.destroy=function(){e.forEach(function(e){e.destroy&&e.destroy()})},n},n.collect=n.writeArray=function(e){if(typeof e!=`function`)throw Error(`function writeArray (done): done must be function`);var n=new t,r=[],i=!1;return n.write=function(e){r.push(e)},n.end=function(){i=!0,e(null,r)},n.writable=!0,n.readable=!1,n.destroy=function(){n.writable=n.readable=!1,!i&&e(Error(`destroyed before end`),r)},n},n.readArray=function(e){var n=new t,r=0,i=!1,a=!1;if(n.readable=!0,n.writable=!1,!Array.isArray(e))throw Error(`event-stream.read expects an array`);return n.resume=function(){if(!a){i=!1;for(var t=e.length;r<t&&!i&&!a;)n.emit(`data`,e[r++]);r==t&&!a&&(a=!0,n.readable=!1,n.emit(`end`))}},process.nextTick(n.resume),n.pause=function(){i=!0},n.destroy=function(){a=!0,n.emit(`close`)},n},n.readable=function(e,n){var r=new t,i=0,a=!1,o=!1,s=!1;if(r.readable=!0,r.writable=!1,typeof e!=`function`)throw Error(`event-stream.readable expects async function`);r.on(`end`,function(){o=!0});function c(t,l){t?(r.emit(`error`,t),n||r.emit(`end`)):arguments.length>1&&r.emit(`data`,l),u(function(){if(!(o||a||s))try{s=!0,e.call(r,i++,function(){s=!1,c.apply(null,arguments)})}catch(e){r.emit(`error`,e)}})}return r.resume=function(){a=!1,c()},process.nextTick(c),r.pause=function(){a=!0},r.destroy=function(){r.emit(`end`),r.emit(`close`),o=!0},r},n.mapSync=function(e){return n.through(function(t){var n;try{n=e(t)}catch(e){return this.emit(`error`,e)}n!==void 0&&this.emit(`data`,n)})},n.filterSync=function(e){return n.through(function(t){var n=this;e(t)&&n.queue(t)})},n.flatmapSync=function(e){return n.through(function(t){var n=this;t.forEach(function(t){n.queue(e(t))})})},n.log=function(e){return n.through(function(t){[].slice.call(arguments),e?console.error(e,t):console.error(t),this.emit(`data`,t)})},n.child=function(e){return n.duplex(e.stdin,e.stdout)},n.parse=function(e){var t=!!(e&&e.error);return n.through(function(e){var n;try{e&&(n=JSON.parse(e.toString()))}catch(n){return t?this.emit(`error`,n):console.error(n,`attempting to parse:`,e)}n!==void 0&&this.emit(`data`,n)})},n.stringify=function(){var e=require("buffer").Buffer;return n.mapSync(function(t){return JSON.stringify(e.isBuffer(t)?t.toString():t)+`
|
|
9
9
|
`})},n.replace=function(e,t){return n.pipeline(n.split(e),n.join(t))},n.join=function(e){if(typeof e==`function`)return n.wait(e);var t=!0;return n.through(function(n){return t||this.emit(`data`,e),t=!1,this.emit(`data`,n),!0})},n.wait=function(e){var t=[];return n.through(function(e){t.push(e)},function(){var n=Buffer.isBuffer(t[0])?Buffer.concat(t):t.join(``);this.emit(`data`,n),this.emit(`end`),e&&e(null,n)})},n.pipeable=function(){throw Error(`[EVENT-STREAM] es.pipeable is deprecated`)}}))();const _t=`<script type="text/javascript">
|
|
10
10
|
if ('WebSocket' in window) {
|
|
@@ -331,7 +331,8 @@ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push(
|
|
|
331
331
|
`,d=`namespace `+t+` {
|
|
332
332
|
`+d+`}
|
|
333
333
|
`),e.isExported?n.docVisible=d:n.docInvisible=d}let m=()=>{let r=``,i=t.build.namespaces.includes(e.fullName);i&&(r+=`_n = `+e.fullName+`;
|
|
334
|
-
`);let a=n.compiled;if(e instanceof mn)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof dn){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.
|
|
334
|
+
`);let a=n.compiled;if(e instanceof mn)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof dn){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.replace(/\r\n?/g,`
|
|
335
|
+
`).split(`
|
|
335
336
|
`);e.splice(0,1),a=e.join(`
|
|
336
337
|
`)}}else a=e.fullName+`=`+n.compiled,e.fullName.includes(`.`)||(a=`let ${a}`);return e.isExported&&(a+=`__as1(_${e.namespace==``?``:`.`+e.namespace}, '${e.name}', ${e.fullName});`,a+=`
|
|
337
338
|
`),r+=a,i&&(r+=`
|
|
@@ -512,7 +513,8 @@ protected ${t}(){
|
|
|
512
513
|
throw new Error("Method not implemented.");
|
|
513
514
|
}
|
|
514
515
|
`}return e!=``&&(e=`
|
|
515
|
-
`+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},Qn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==rr.tagName}get isIf(){return this.tagName==ir.tagName}get isContextEditing(){return this.tagName==ar.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),$n.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const $n=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],er=[`_id`];var tr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):er.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new sr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new or(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Un.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Un[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=cr(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},nr=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=cr(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},rr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=lr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},ir=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:ur(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=lr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},ar=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=ur(this.fctTs)}}),this.variables=lr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},or=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=ur(t),this.variables=lr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},sr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=ur(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=lr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function cr(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!ur(r[1])&&(i.once=!1),a){a.variables=lr(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function lr(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function ur(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=class e{static languageService=(0,S.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:C.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=Ye(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof rr||!(t instanceof Qn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof rr||t instanceof Qn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<(\/?.*?)>/g,`'$1'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new ir(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new rr(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new ar(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new nr(i,n,r,e,!1))}}else if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new Qn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Pe(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Pe(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new tr(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new nr(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>([\s\S]*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>[\s\S]*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},dr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),fr=o(((e,t)=>{let n=dr();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),pr=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),mr=o(((e,t)=>{let n=dr();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),hr=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),gr=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),_r=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),vr=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),yr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),br=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),xr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Sr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Cr=o(((e,t)=>{let n=_r(),r=vr(),i=yr(),a=br(),o=xr(),s=Sr();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),wr=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
516
|
+
`+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},Qn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==rr.tagName}get isIf(){return this.tagName==ir.tagName}get isContextEditing(){return this.tagName==ar.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),$n.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const $n=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],er=[`_id`];var tr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):er.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new sr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new or(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Un.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Un[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=cr(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},nr=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=cr(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},rr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=lr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},ir=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:ur(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=lr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},ar=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=ur(this.fctTs)}}),this.variables=lr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},or=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=ur(t),this.variables=lr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},sr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=ur(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=lr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function cr(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!ur(r[1])&&(i.once=!1),a){a.variables=lr(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t).replace(/\r\n?/g,`
|
|
517
|
+
`),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function lr(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function ur(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=class e{static languageService=(0,S.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:C.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=Ye(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof rr||!(t instanceof Qn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof rr||t instanceof Qn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<\/?[A-Za-z][A-Za-z0-9:_-]*(?:\s+(?:[^"'<>]|"[^"]*"|'[^']*')*)?\s*\/?>/g,e=>`'`+e.slice(1,-1)+`'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new ir(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new rr(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new ar(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new nr(i,n,r,e,!1))}}else if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new Qn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Pe(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Pe(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new tr(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new nr(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>([\s\S]*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>[\s\S]*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},dr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),fr=o(((e,t)=>{let n=dr();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),pr=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),mr=o(((e,t)=>{let n=dr();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),hr=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),gr=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),_r=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),vr=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),yr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),br=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),xr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Sr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Cr=o(((e,t)=>{let n=_r(),r=vr(),i=yr(),a=br(),o=xr(),s=Sr();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),wr=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
516
518
|
`)&&t.prev())return e;let a=i||r.initialIndex;return t.position=r.position,t.initialIndex=a-1e-4,n([t,...e],t.prev(),r,t.initialIndex)}function r(e,t,n,i){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
|
|
517
519
|
`))return e;let a=i||n.initialIndex;return t.position=n.position,t.initialIndex=a+1e-4,r([...e,t],t.next(),n,t.initialIndex)}function i(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
518
520
|
`))return e;let a=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=a-1e-4,i([o,...e],t.prev(),n,o.initialIndex)}function a(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
|
|
@@ -538,7 +540,8 @@ protected ${t}(){
|
|
|
538
540
|
`?(n=1,r+=1):n+=1}return i}var l=class{get proxyOf(){return this}constructor(e={}){this.raws={},this[a]=!1,this[o]=!0;for(let t in e)if(t===`nodes`){this.nodes=[];for(let n of e[t])typeof n.clone==`function`?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=s(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new n(e)}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:t===`root`?()=>e.root().toProxy():e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`prop`||t===`value`||t===`name`||t===`params`||t===`important`||t===`text`)&&e.markDirty(),!0)}}}markClean(){this[a]=!0}markDirty(){if(this[a]){this[a]=!1;let e=this;for(;e=e.parent;)e[a]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e={}){let t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){let n=`document`in this.source.input?this.source.input.document:this.source.input.css,r=n.slice(c(n,this.source.start),c(n,this.source.end)).indexOf(e.word);r!==-1&&(t=this.positionInside(r))}return t}positionInside(e){let t=this.source.start.column,n=this.source.start.line,r=`document`in this.source.input?this.source.input.document:this.source.input.css,i=c(r,this.source.start),a=i+e;for(let e=i;e<a;e++)r[e]===`
|
|
539
541
|
`?(t=1,n+=1):t+=1;return{column:t,line:n,offset:a}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t=`document`in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:c(t,this.source.start)},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset==`number`?this.source.end.offset:c(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let i=t.slice(c(t,this.source.start),c(t,this.source.end)).indexOf(e.word);i!==-1&&(n=this.positionInside(i),r=this.positionInside(i+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:c(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line,offset:c(t,e.end)}:typeof e.endIndex==`number`?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<n.line||r.line===n.line&&r.column<=n.column)&&(r={column:n.column+1,line:n.line,offset:n.offset+1}),{end:r,start:n}}raw(e,t){return new r().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!==`document`;)e=e.parent;return e}toJSON(e,t){let n={},r=t==null;t||=new Map;let i=0;for(let e in this){if(!Object.prototype.hasOwnProperty.call(this,e)||e===`parent`||e===`proxyCache`)continue;let r=this[e];if(Array.isArray(r))n[e]=r.map(e=>typeof e==`object`&&e.toJSON?e.toJSON(null,t):e);else if(typeof r==`object`&&r.toJSON)n[e]=r.toJSON(null,t);else if(e===`source`){if(r==null)continue;let a=t.get(r.input);a??(a=i,t.set(r.input,i),i++),n[e]={end:r.end,inputId:a,start:r.start}}else n[e]=r}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||=new Proxy(this,this.getProxyProcessor()),this.proxyCache}toString(e=i){e.stringify&&(e=e.stringify);let t=``;return e(this,e=>{t+=e}),t}warn(e,t,n={}){let r={node:this};for(let e in n)r[e]=n[e];return e.warn(t,r)}};t.exports=l,l.default=l})),qr=o(((e,t)=>{let n=Kr();var r=class extends n{constructor(e){super(e),this.type=`comment`}};t.exports=r,r.default=r})),Jr=o(((e,t)=>{let n=Kr();var r=class extends n{get variable(){return this.prop.startsWith(`--`)||this.prop[0]===`$`}constructor(e){e&&e.value!==void 0&&typeof e.value!=`string`&&(e={...e,value:String(e.value)}),super(e),this.type=`decl`}};t.exports=r,r.default=r})),Yr=o(((e,t)=>{let n=qr(),r=Jr(),i=Kr(),{isClean:a,my:o}=Gr(),s,c,l,u;function d(e){return e.map(e=>(e.nodes&&=d(e.nodes),delete e.source,e))}function f(e){if(e[a]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)f(t)}var p=class e extends i{get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t=this.getIterator(),n,r;for(;this.indexes[t]<this.proxyOf.nodes.length&&(n=this.indexes[t],r=e(this.proxyOf.nodes[n],n),r!==!1);)this.indexes[t]+=1;return delete this.indexes[t],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||=0,this.indexes||={},this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:e[t]?t===`each`||typeof t==`string`&&t.startsWith(`walk`)?(...n)=>e[t](...n.map(e=>typeof e==`function`?(t,n)=>e(t.toProxy(),n):e)):t===`every`||t===`some`?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):t===`root`?()=>e.root().toProxy():t===`nodes`?e.nodes.map(e=>e.toProxy()):t===`first`||t===`last`?e[t].toProxy():e[t]:e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`name`||t===`params`||t===`selector`)&&e.markDirty(),!0)}}}index(e){return typeof e==`number`?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n=this.index(e),r=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let e of r)this.proxyOf.nodes.splice(n+1,0,e);let i;for(let e in this.indexes)i=this.indexes[e],n<i&&(this.indexes[e]=i+r.length);return this.markDirty(),this}insertBefore(e,t){let n=this.index(e),r=n===0?`prepend`:!1,i=this.normalize(t,this.proxyOf.nodes[n],r).reverse();n=this.index(e);for(let e of i)this.proxyOf.nodes.splice(n,0,e);let a;for(let e in this.indexes)a=this.indexes[e],n<=a&&(this.indexes[e]=a+i.length);return this.markDirty(),this}normalize(t,i){if(typeof t==`string`)t=d(c(t).nodes);else if(t===void 0)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type===`root`&&this.type!==`document`){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type)t=[t];else if(t.prop){if(t.value===void 0)throw Error(`Value field is missed in node creation`);typeof t.value!=`string`&&(t.value=String(t.value)),t=[new r(t)]}else if(t.selector||t.selectors)t=[new u(t)];else if(t.name)t=[new s(t)];else if(t.text)t=[new n(t)];else throw Error(`Unknown node type in node creation`);return t.map(t=>(t[o]||e.rebuild(t),t=t.proxyOf,t.parent&&t.parent.removeChild(t),t[a]&&f(t),t.raws||={},t.raws.before===void 0&&i&&i.raws.before!==void 0&&(t.raws.before=i.raws.before.replace(/\S/g,``)),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,`prepend`).reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);let t;for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return r!==!1&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`atrule`&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if(n.type===`atrule`&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`atrule`)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if(t.type===`comment`)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`decl`&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if(n.type===`decl`&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`decl`)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`rule`&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if(n.type===`rule`&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`rule`)return t(e,n)}))}};p.registerParse=e=>{c=e},p.registerRule=e=>{u=e},p.registerAtRule=e=>{s=e},p.registerRoot=e=>{l=e},t.exports=p,p.default=p,p.rebuild=e=>{e.type===`atrule`?Object.setPrototypeOf(e,s.prototype):e.type===`rule`?Object.setPrototypeOf(e,u.prototype):e.type===`decl`?Object.setPrototypeOf(e,r.prototype):e.type===`comment`?Object.setPrototypeOf(e,n.prototype):e.type===`root`&&Object.setPrototypeOf(e,l.prototype),e[o]=!0,e.nodes&&e.nodes.forEach(e=>{p.rebuild(e)})}})),Xr=o(((e,t)=>{let n=Yr();var r=class extends n{constructor(e){super(e),this.type=`atrule`}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}};t.exports=r,r.default=r,n.registerAtRule(r)})),Zr=o(((e,t)=>{let n=Yr(),r,i;var a=class extends n{constructor(e){super(e),this.type=`root`,this.nodes||=[]}normalize(e,t,n){let r=super.normalize(e);if(t){if(n===`prepend`)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let e of r)e.raws.before=t.raws.before}return r}removeChild(e,t){let n=this.index(e);return!t&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new r(new i,this,e).stringify()}};a.registerLazyResult=e=>{r=e},a.registerProcessor=e=>{i=e},t.exports=a,a.default=a,n.registerRoot(a)})),Qr=o(((e,t)=>{let n={comma(e){return n.split(e,[`,`],!0)},space(e){return n.split(e,[` `,`
|
|
540
542
|
`,` `])},split(e,t,n){let r=[],i=``,a=!1,o=0,s=!1,c=``,l=!1;for(let n of e)l?l=!1:n===`\\`?l=!0:s?n===c&&(s=!1):n===`"`||n===`'`?(s=!0,c=n):n===`(`?o+=1:n===`)`?o>0&&--o:o===0&&t.includes(n)&&(a=!0),a?(i!==``&&r.push(i.trim()),i=``,a=!1):i+=n;return(n||i!==``)&&r.push(i.trim()),r}};t.exports=n,n.default=n})),$r=o(((e,t)=>{let n=Yr(),r=Qr();var i=class extends n{get selectors(){return r.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:`,`+this.raw(`between`,`beforeOpen`);this.selector=e.join(n)}constructor(e){super(e),this.type=`rule`,this.nodes||=[]}};t.exports=i,i.default=i,n.registerRule(i)})),ei=o(((e,t)=>{let n=Xr(),r=qr(),i=Jr(),a=Zr(),o=$r(),s=Vr(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}function u(e,t,n){let r=``;for(let i=t;i<n;i++)r+=e[i][1];return r}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;let a=0;for(;e[a][0]!==`word`;)a===e.length-1&&this.unknownWord([e[a]]),a++;n.raws.before+=u(e,0,a),n.source.start=this.getPosition(e[a][2]);let o=a;for(;a<e.length;){let t=e[a][0];if(t===`:`||t===`space`||t===`comment`)break;a++}n.prop=u(e,o,a);let s=a,c;for(;a<e.length&&(c=e[a],a++,c[0]!==`:`);)c[0]===`word`&&/\w/.test(c[1])&&this.unknownWord([c]);n.raws.between=u(e,s,a),(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let d=a;for(;a<e.length;){let t=e[a][0];if(t!==`space`&&t!==`comment`)break;a++}let f=e.slice(d,a);e=e.slice(a),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(c=e[t],c[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(c[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(c[0]!==`space`&&c[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=f.map(e=>e[1]).join(``),f=[]),this.raw(n,`value`,f.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),ti=o(((e,t)=>{let{Container:n}=require("postcss");t.exports=class extends n{constructor(e){super(e),this.type=`decl`,this.isNested=!0,this.nodes||=[]}}})),ni=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[,\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i,o=/[\n\f\r]/g;t.exports=function(e,t={}){let s=e.css.valueOf(),c=t.ignoreErrors,l,u,d,f,p,m,h,g,_,v=s.length,y=0,b=[],x=[],ee;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function re(){return x.length===0&&y>=v}function ie(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ne(`interpolation`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),t?!n&&l===t?(t=!1,n=!1):l===92?n=!n:n&&=!1:l===39||l===34?t=l:l===125?--e:l===35&&g===123&&(e+=1)}function ae(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(l=s.charCodeAt(y),l){case 10:case 32:case 9:case 13:case 12:u=y;do u+=1,l=s.charCodeAt(u);while(l===32||l===10||l===9||l===13||l===12);_=[`space`,s.slice(y,u)],y=u-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(l);_=[e,e,y];break}case 44:_=[`word`,`,`,y,y+1];break;case 40:if(h=b.length?b.pop()[1]:``,g=s.charCodeAt(y+1),h===`url`&&g!==39&&g!==34){for(ee=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)ee+=1;else if(g===41&&(--ee,ee===0))break;u+=1}f=s.slice(y,u+1),_=[`brackets`,f,y,u],y=u}else u=s.indexOf(`)`,y+1),f=s.slice(y,u+1),u===-1||i.test(f)?_=[`(`,`(`,y]:(_=[`brackets`,f,y,u],y=u);break;case 39:case 34:for(d=l,u=y,m=!1;u<v&&(u++,u===v&&ne(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&ie();_=[`string`,s.slice(y,u+1),y,u],y=u;break;case 64:n.lastIndex=y+1,n.test(s),u=n.lastIndex===0?s.length-1:n.lastIndex-2,_=[`at-word`,s.slice(y,u+1),y,u],y=u;break;case 92:for(u=y,p=!0;s.charCodeAt(u+1)===92;)u+=1,p=!p;if(l=s.charCodeAt(u+1),p&&l!==47&&l!==32&&l!==10&&l!==9&&l!==13&&l!==12&&(u+=1,a.test(s.charAt(u)))){for(;a.test(s.charAt(u+1));)u+=1;s.charCodeAt(u+1)===32&&(u+=1)}_=[`word`,s.slice(y,u+1),y,u],y=u;break;default:g=s.charCodeAt(y+1),l===35&&g===123?(u=y,ie(),f=s.slice(y,u+1),_=[`word`,f,y,u],y=u):l===47&&g===42?(u=s.indexOf(`*/`,y+2)+1,u===0&&(c||t?u=s.length:ne(`comment`)),_=[`comment`,s.slice(y,u+1),y,u],y=u):l===47&&g===47?(o.lastIndex=y+1,o.test(s),u=o.lastIndex===0?s.length-1:o.lastIndex-2,f=s.slice(y,u+1),_=[`comment`,f,y,u,`inline`],y=u):(r.lastIndex=y+1,r.test(s),u=r.lastIndex===0?s.length-1:r.lastIndex-2,_=[`word`,s.slice(y,u+1),y,u],b.push(_),y=u);break}return y++,_}function oe(e){x.push(e)}return{back:oe,endOfFile:re,nextToken:ae,position:te}}})),ri=o(((e,t)=>{let{Comment:n}=require("postcss"),r=ei(),i=ti(),a=ni();t.exports=class extends r{atrule(e){let t=e[1],n=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if(e[0]===`word`&&e[2]===n[3]+1)t+=e[1],n=e;else{this.tokenizer.back(e);break}}super.atrule([`at-word`,t,e[2],n[3]])}comment(e){if(e[4]===`inline`){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let i=e[1].slice(2);if(/^\s*$/.test(i))t.text=``,t.raws.left=i,t.raws.right=``;else{let e=i.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2].replace(/(\*\/|\/\*)/g,`*//*`),t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=a(this.input)}raw(e,t,n,r){if(super.raw(e,t,n,r),e.raws[t]){let r=e.raws[t].raw;e.raws[t].raw=n.reduce((e,t)=>{if(t[0]===`comment`&&t[4]===`inline`){let n=t[1].slice(2).replace(/(\*\/|\/\*)/g,`*//*`);return e+`/*`+n+`*/`}else return e+t[1]},``),r!==e.raws[t].raw&&(e.raws[t].scss=r)}}rule(e){let t=!1,n=0,r=``;for(let i of e)if(t)i[0]!==`comment`&&i[0]!==`{`&&(r+=i[1]);else if(i[0]===`space`&&i[1].includes(`
|
|
541
|
-
`))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),ii=o(((e,t)=>{let{Input:n}=require("postcss"),r=ri();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),ai=o(((e,t)=>{let n=zr();t.exports={parse:ii(),stringify:n}})),oi=l(Ir()),si=s({default:()=>li,parse:()=>di,stringify:()=>ui}),ci=l(ai(),1),li=ci.default;const ui=ci.default.stringify,di=ci.default.parse;function fi(e,t){let n=null;return!e||t<e.offset||t>e.end?null:(e.accept(e=>e.offset===-1&&e.length===-1?!0:e.offset<=t&&e.end>=t?(n?e.length<=n.length&&(n=e):n=e,!0):!1),n)}function pi(e,t){let n=fi(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var mi=class{languageService;documentationInfo={};externalDocumentation={};internalDocumentation={};build;_allowRebuildDefinition=!0;getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}constructor(e){this.build=e,this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){let t=[];t=this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser));for(let e=0;e<t.length;e++)t[e].code==`emptyRules`&&(t.splice(e,1),e--);return t}async doComplete(e,t){let n=[],r={isIncomplete:!1,items:[]};r=this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));let i={};for(let e of r.items)i[e.label]=e;let a=this.getTree(e,t).reverse()[0];if(this.documentationInfo[a])for(let e of this.documentationInfo[a])n.indexOf(e.name)==-1&&(n.push(e.name),i[e.name]={label:e.name});let o=/^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;for(let e in this.build.globalSCSSLanguageService.variablesByName)this.build.globalSCSSLanguageService.variablesByName[e].value.match(o)?i[e]={label:e}:i[``+e]={label:``+e};return r.items=Object.values(i),r}async doHover(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return[{uri:e.uri,range:e.range}]}let r=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return r&&[r]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,oi.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:si,syntax:si,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(this._allowRebuildDefinition){this.documentationInfo={};for(let e in this.externalDocumentation){let t=this.externalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}}}addExternalDefinition(e,t){this.externalDocumentation[e]=t,this.rebuildDefinition()}getExternalDefinition(e){return this.externalDocumentation[e]}removeExternalDefinition(e){delete this.externalDocumentation[e],this.rebuildDefinition()}addInternalDefinition(e,t){this.internalDocumentation[e]=t,this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.rebuildDefinition()}getLinkToHtml(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.htmlFile;if(i&&i.fileParsed)for(let e of i.fileParsed.styleLinks){let t=e[1];r>=t.start&&r<=t.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(e[0].start),end:i.file.documentUser.positionAt(e[0].end)}})}return n}getTree(e,t){let n=[];if(this.languageService){let r=pi(this.languageService.parseStylesheet(e.documentUser),e.documentUser.offsetAt(t));for(let e of r)if(e.type==3){let t=e.getChild(0);if(t){let e=t.getText();n.push(e)}}}return n}getRules(e){let t=new Map,n=this.languageService.parseStylesheet(e.documentUser),r=e=>t=>{let n=e.getText().replace(`.`,``),r=RegExp(`((?:^|\\W))(`+n+`)(?:$|\\W)`,`gi`);return!!t.attributes.class?.value?.match(r)},i=e=>t=>{let n=e.getText();return t.tagName==n},a=(e=null,t)=>n=>{if(e){let t=!1,r=n.parent;for(;r;){if(e(r)){t=!0;break}r=r.parent}if(!t)return!1}for(let e of t)if(!e(n))return!1;return!0},o=(e,n=null)=>{if(e.type==3){let o=e.getChildren();if(o.length>1){for(let e of o[1].getChildren())if(e.type==19||e.type==69||e.type==34||e.type==58||e.type==37)break}if(o.length>0){let e=o[0]?.getChildren()[0],s=null;if(e){for(let t of e.getChildren())if(t.type==5){s?s.start>t.offset?s.start=t.offset:s.end<t.offset+t.length&&(s.end=t.offset+t.length):s={start:t.offset,end:t.offset+t.length};let e=[];for(let n of t.getChildren())n.type==14?e.push(r(n)):n.type==16&&e.push(i(n));e.length>0&&(n=a(n,e))}else t.getText(),$.warning(`css node to implement`);n&&s&&t.set(n,s)}}}else if(e.type==21)return;if(e.hasChildren())for(let t of e.getChildren())o(t,n)},s=pi(n,0);return s.length>0&&o(s[0]),t}getElementAtPosition(e,t){if(this.languageService){let n=this.languageService.parseStylesheet(e.documentUser),r=e.documentUser.offsetAt(t),i=e=>{let t=e.getChildren();for(let e of t)if(e.offset<=r&&e.end>=r)return e.hasChildren()?i(e):e;return null};return i(n)}return null}static getCustomProperty(e){let t=d.TextDocument.create(`temp.scss`,`scss`,1,e),n={},r=(e,t)=>{let n=e.parent?.getText()??``,r=RegExp(`\/\\*([\\s\\S]*?)\\*\/\\s*${t}\\s*:\\s*[^;]+;`,`g`).exec(n);if(r&&r[1]){let e={documentation:[],type:`*`},t=r[1].trim().
|
|
543
|
+
`))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),ii=o(((e,t)=>{let{Input:n}=require("postcss"),r=ri();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),ai=o(((e,t)=>{let n=zr();t.exports={parse:ii(),stringify:n}})),oi=l(Ir()),si=s({default:()=>li,parse:()=>di,stringify:()=>ui}),ci=l(ai(),1),li=ci.default;const ui=ci.default.stringify,di=ci.default.parse;function fi(e,t){let n=null;return!e||t<e.offset||t>e.end?null:(e.accept(e=>e.offset===-1&&e.length===-1?!0:e.offset<=t&&e.end>=t?(n?e.length<=n.length&&(n=e):n=e,!0):!1),n)}function pi(e,t){let n=fi(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var mi=class{languageService;documentationInfo={};externalDocumentation={};internalDocumentation={};build;_allowRebuildDefinition=!0;getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}constructor(e){this.build=e,this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){let t=[];t=this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser));for(let e=0;e<t.length;e++)t[e].code==`emptyRules`&&(t.splice(e,1),e--);return t}async doComplete(e,t){let n=[],r={isIncomplete:!1,items:[]};r=this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));let i={};for(let e of r.items)i[e.label]=e;let a=this.getTree(e,t).reverse()[0];if(this.documentationInfo[a])for(let e of this.documentationInfo[a])n.indexOf(e.name)==-1&&(n.push(e.name),i[e.name]={label:e.name});let o=/^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;for(let e in this.build.globalSCSSLanguageService.variablesByName)this.build.globalSCSSLanguageService.variablesByName[e].value.match(o)?i[e]={label:e}:i[``+e]={label:``+e};return r.items=Object.values(i),r}async doHover(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return[{uri:e.uri,range:e.range}]}let r=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return r&&[r]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,oi.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:si,syntax:si,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(this._allowRebuildDefinition){this.documentationInfo={};for(let e in this.externalDocumentation){let t=this.externalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}}}addExternalDefinition(e,t){this.externalDocumentation[e]=t,this.rebuildDefinition()}getExternalDefinition(e){return this.externalDocumentation[e]}removeExternalDefinition(e){delete this.externalDocumentation[e],this.rebuildDefinition()}addInternalDefinition(e,t){this.internalDocumentation[e]=t,this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.rebuildDefinition()}getLinkToHtml(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.htmlFile;if(i&&i.fileParsed)for(let e of i.fileParsed.styleLinks){let t=e[1];r>=t.start&&r<=t.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(e[0].start),end:i.file.documentUser.positionAt(e[0].end)}})}return n}getTree(e,t){let n=[];if(this.languageService){let r=pi(this.languageService.parseStylesheet(e.documentUser),e.documentUser.offsetAt(t));for(let e of r)if(e.type==3){let t=e.getChild(0);if(t){let e=t.getText();n.push(e)}}}return n}getRules(e){let t=new Map,n=this.languageService.parseStylesheet(e.documentUser),r=e=>t=>{let n=e.getText().replace(`.`,``),r=RegExp(`((?:^|\\W))(`+n+`)(?:$|\\W)`,`gi`);return!!t.attributes.class?.value?.match(r)},i=e=>t=>{let n=e.getText();return t.tagName==n},a=(e=null,t)=>n=>{if(e){let t=!1,r=n.parent;for(;r;){if(e(r)){t=!0;break}r=r.parent}if(!t)return!1}for(let e of t)if(!e(n))return!1;return!0},o=(e,n=null)=>{if(e.type==3){let o=e.getChildren();if(o.length>1){for(let e of o[1].getChildren())if(e.type==19||e.type==69||e.type==34||e.type==58||e.type==37)break}if(o.length>0){let e=o[0]?.getChildren()[0],s=null;if(e){for(let t of e.getChildren())if(t.type==5){s?s.start>t.offset?s.start=t.offset:s.end<t.offset+t.length&&(s.end=t.offset+t.length):s={start:t.offset,end:t.offset+t.length};let e=[];for(let n of t.getChildren())n.type==14?e.push(r(n)):n.type==16&&e.push(i(n));e.length>0&&(n=a(n,e))}else t.getText(),$.warning(`css node to implement`);n&&s&&t.set(n,s)}}}else if(e.type==21)return;if(e.hasChildren())for(let t of e.getChildren())o(t,n)},s=pi(n,0);return s.length>0&&o(s[0]),t}getElementAtPosition(e,t){if(this.languageService){let n=this.languageService.parseStylesheet(e.documentUser),r=e.documentUser.offsetAt(t),i=e=>{let t=e.getChildren();for(let e of t)if(e.offset<=r&&e.end>=r)return e.hasChildren()?i(e):e;return null};return i(n)}return null}static getCustomProperty(e){let t=d.TextDocument.create(`temp.scss`,`scss`,1,e),n={},r=(e,t)=>{let n=e.parent?.getText()??``,r=RegExp(`\/\\*([\\s\\S]*?)\\*\/\\s*${t}\\s*:\\s*[^;]+;`,`g`).exec(n);if(r&&r[1]){let e={documentation:[],type:`*`},t=r[1].trim().replace(/\r\n?/g,`
|
|
544
|
+
`).split(`
|
|
542
545
|
`);for(let n of t){let t=!1;n=n.replace(`*`,``).trim(),n.startsWith(`@`)?(t=!0,n.startsWith(`@type`)&&(e.type=n.replace(`@type`,``).trim()),n.startsWith(`@default`)&&(e.default=n.replace(`@default`,``).trim())):t||e.documentation.push(n.trim())}return e}return null},i=e=>{if(e.type==69){let t=e;for(;t&&t.selectors==null;)t=t.parent;if(t&&t.selectors.getText()==`:host`){let t=e.getChild(0),i=e.getChild(1);if(t&&i){let a=null;t.getText().startsWith(`--internal`)?a=t.getText().replace(`--internal-`,`--`):t.getText().startsWith(`--_`)&&(a=t.getText().replace(`--_`,`--`));let o=r(e,t.getText());if(a&&i.getText().indexOf(a)!=-1){let e={name:a};o?.documentation&&(e.documentation=o.documentation.join(`
|
|
543
546
|
`).trim()),o?.type&&(e.type=o.type),o?.default&&(e.defaultValue=o.default);let t=i,r=[],s=``;for(;t&&t.getChildren().length>0;){let e=t.getChildren(),n=t.getText();n&&n.startsWith(`--`)&&(n=n.split(`,`)[0],s!=n&&n!=a&&(s=n,r.push(n))),t=e[e.length-1]}let c=t.getText()??``;c&&(c.startsWith(`--`)||r.push(c)),r.length>0&&(e.chainValues=r,e.defaultValue??=e.chainValues[e.chainValues.length-1]),n[e.name]=e}}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=pi((0,ce.getSCSSLanguageService)().parseStylesheet(t),0);for(let e of a)i(e);return Object.values(n)}},hi=class e extends ct{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;namespace=``;_rules=new Map;customProperties=[];get compileResult(){return this.compiledTxt}get rules(){return this._rules}get htmlFile(){let e=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];return e instanceof gi?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(w.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}async init(){await this.loadDependencies(),await this.compile(!1)}async onValidate(){return this.diagnostics=await this.build.scssLanguageService.doValidation(this.file),await this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onContentChange(){}async onSave(){await this.compileRoot()}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(e=!0){try{let t=this.compiledTxt,n=`|error|`,r=async e=>{let t=e.contentUser;t=t.replace(/\/\*[\s\S]*?@import[\s\S]*?\*\/|\/\/.*@import.*/g,``);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(t);){let i=a[2],o=await this.resolvePath(i,e.folderPath);if(o){let e=await r(o);if(e==n)return e;t=t.replace(a[0],e)}else return n}return t},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=mi.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,le.compileString)(i,{style:`compressed`}).css.toString().trim();e=e.replace(/\\/g,`\\\\`),t=e,this.diagnosticCompile&&(this.diagnosticCompile=void 0,$.sendDiagnostics({uri:this.file.uri,diagnostics:this.diagnostics},this.build))}catch(e){if(e instanceof le.Exception){this.diagnosticCompile=Me(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)j.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentLogic)];if(t instanceof F&&e&&(t.canUpdateComponent=!1,await t.triggerSave(),t.compilationResult)){let e=this.namespace,n=t.fileParsed?.classes[t.compilationResult.componentName].namespace;n&&(e+=n),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),j.getInstance().updateCSS(this.compiledTxt,e+t.compilationResult.componentName,[])}}this._rules=this.build.scssLanguageService.getRules(this.file);let a=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];a instanceof gi&&I.refreshStyle(a,this.build)}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange()}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.build.scssLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.build.scssLanguageService.doHover(e,t)}async onDefinition(e,t){return this.build.scssLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.build.scssLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.build.scssLanguageService.doCodeAction(e,t)}async onReferences(e,t){let n=await this.build.scssLanguageService.onReferences(e,t);return n=[...n,...this.build.scssLanguageService.getLinkToHtml(this,t)],n}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return null}async loadDependencies(){let e=this.file.contentUser,t=e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`),n=/@import *?('|")(\S*?)('|");?/g,r=null;for(let e in this.dependencies)this.removeDependency(e);for(;r=n.exec(t);){let t=r[2],n=await this.resolvePath(t,this.file.folderPath);if(n)await this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Ne(this.file.documentUser,`Can't load this file`,t,n))}}}removeDependency(e){this.dependencies[e]&&(delete this.dependencies[e].usedBy[this.file.uri],delete this.dependencies[e])}async addDependency(t){this.build.scssFiles[t.uri]?(this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.ComponentStyle)&&(this.build.scssFiles[t.uri]=new e(t,this.build),await this.build.scssFiles[t.uri].init(),this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this)}async getByPath(e){let t=R.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(E(e),C.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await R.getInstance().registerFile(t),R.getInstance().getByPath(e)}}async resolvePath(e,t){e=this.build.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=await this.getByPath(e);if(n)return n;let r=e+w.ComponentStyle;if(n=await this.getByPath(r),n)return n;let i=e.split(f.sep);i[i.length-1]=`_`+i[i.length-1];let a=i.join(f.sep);if(n=await this.getByPath(a),n)return n;let o=a+w.ComponentStyle;if(n=await this.getByPath(o),n)return n}},gi=class extends ct{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(w.ComponentView,w.ComponentLogic)];return e instanceof F?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(w.ComponentView,w.ComponentStyle)];return e instanceof hi?e:null}_slotsInfo;slotsInfoVersion=0;get slotsInfo(){return(this.slotsInfoVersion!=this.file.versionInternal||!this._slotsInfo)&&(this._slotsInfo=this.getSlotsInfo(),this.slotsInfoVersion=this.file.versionInternal),this._slotsInfo}constructor(e,t){super(e,t)}async init(){await this.refreshFileParsed()}refreshFileParsed(){this.fileParsed=I.parse(this,this.build);let e=I.getVersion(this);return this.version==e?!1:(this.version=e,this.file.validate(),!0)}async onValidate(){let e=await this.build.htmlLanguageService.doValidation(this.file);this.fileParsed&&(e=[...e,...this.fileParsed.errors]),e=[...e,...this.tsErrors],this.tsFile&&(e=[...e,...this.tsFile.htmlDiagnostics]),this.codeactions=[];let t=e=>{let t=this.file.documentUser.offsetAt(e.range.start),n=this.file.contentUser.slice(t-3,t-1),r=n==`.t`;if(n!=` t`&&n!=`.t`&&n!=`{t`)return;let i=this.file.documentUser.getText(e.range).slice(1,-1),a={title:`Add value into translation file`,command:{command:`aventus.i18n.add`,title:`Add value into translation file`,arguments:[this.file.uri,i,r]},diagnostics:[e],range:{start:t,end:this.file.documentUser.offsetAt(e.range.end)}};this.codeactions.push(a)};for(let n of e)(n.message.endsWith(`keyof AventusI18n'.`)||/Argument of type .*? is not assignable to parameter of type .*?\./.test(n.message))&&t(n);return e}async onContentChange(){await this.compile()}async onSave(){await this.tsFile?.triggerSave()}async compile(){try{this.refreshFileParsed()&&await this.tsFile?.validate()}catch(e){console.error(e)}}async onDelete(){}async onCompletion(e,t){return await this.tsFile?.doViewCompletion(t)||this.build.htmlLanguageService.doComplete(this,t)}async onCompletionResolve(e,t){return t}async getHover(e){return this.onHover(this.file,this.file.documentUser.positionAt(e))}async onHover(e,t){return await this.tsFile?.doHover(t)||await this.build.htmlLanguageService.doHover(this,t)}async onDefinition(e,t){return await this.tsFile?.doDefinition(t)||this.build.htmlLanguageService.onDefinition(this,t)}async onFormatting(e,t,n){await this.compile();let r=await this.applyJsFormatting(t,n);return this.applyHtmlFormatting(e,t,n,r)}async applyJsFormatting(e,t){let n=await this.tsFile?.doFormatting(e,t)??[];if(!this.fileParsed)return{};let r=new Map,i=new Map,a=new Map;for(let e of n)if(e.kind==`fct`)for(let t in this.fileParsed.fcts){let n=this.fileParsed.fcts[t];if(n.positions.find(t=>t.start==e.start&&t.end==e.end)){let t=r.get(n);t||(t=[],r.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText});break}}else if(e.kind==`loop`){for(let t of this.fileParsed.loops)if(t.start==e.start&&t.startBlock==e.end){let n=i.get(t);n||(n=[],i.set(t,n)),n.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}else if(e.kind==`if`){for(let t of this.fileParsed.ifs)for(let n of t.conditions)if(n.start==e.start&&n.end==e.end){let t=a.get(n);t||(t=[],a.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}let o={};for(let[e,t]of r){let n=`{{`+e.txt+`}}`;o[n]=n,t.sort((e,t)=>t.end-e.end);for(let e of t)o[n]=o[n].slice(0,e.start)+e.txt+o[n].slice(e.end)}for(let[e,t]of i){let n=e.idTemplate,r=e.loopTxt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);r=r.slice(0,r.length-1),o[`<`+rr.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+rr.tagName+` id="`+e.idTemplate+`">`]=e.loopTxt.slice(0,e.loopTxt.length-1));for(let[e,t]of a){let n=e.idTemplate,r=e.txt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);e.type==`if`?r=`if(`+r+`) {`:e.type==`elif`&&(r=`else if(`+r+`) {`),o[`<`+ir.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.ifs){for(let t of e.conditions)if(!a.has(t)){let e=t.txt;t.type==`if`?e=`if(`+e+`) {`:t.type==`elif`&&(e=`else if(`+e+`) {`),o[`<`+ir.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+ir.tagName+` id="`+e.idsTemplate[e.idsTemplate.length-1]+`">`]=`else {`)}for(let e of this.fileParsed.contextEdits){let t=e.mapping.length>0?e.mapping[0]:``,n=e.mapping.length>1?e.mapping[1]:``,r=`@Context(`+t+`, `+n+`)`;o[`<`+ar.tagName+` id="`+e.id+`"></`+ar.tagName+`>`]=r}return o[`</`+rr.tagName+`>`]=`}`,o[`</`+ir.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt,a=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),o=(await this.build.htmlLanguageService.format(a,t,n))[0].newText;for(let e in r){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);o=o.replace(t,r[e])}return o=o.replace(/\{\{ *([^\n][\s|\S]*?) *\n?\}\}/g,`{{ $1 }}`),[{newText:o,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}async onCodeAction(e,t){let n=e.documentUser.offsetAt(t.start),r=e.documentUser.offsetAt(t.end);return this.codeactions.filter(e=>e.range.start<=n&&e.range.end>=r)}async onReferences(e,t){return await this.tsFile?.doReferences(t)||this.build.htmlLanguageService.getLinkToStyle(this,t)}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return await this.tsFile?.doRename(t,n)||null}getSlotsInfo(){let e=this.tsFile?.fileParsed?.classes[this.tsFile.componentClassName]??null;return e?this.build.getSlotsInfo(e):{}}};const _i=[{name:`@element`,description:`Add a selector for the element inside your logical part`},{name:`@bind`,description:`Bind a watcher to a variable`},{name:`@press`,description:`Add an event for when the element is clicked`},{name:`@press-start`,description:`Add an event for when mouse down or touch start on the element`},{name:`@press-stop`,description:`Add an event for when mouse up or touch start on the element`},{name:`@longpress`,description:`Add an event for when the element is long pressed`},{name:`@longpress-delay`,description:`Add the delay for the long press`},{name:`@dblpress`,description:`Add an event for when the element is double press`},{name:`@dblpress-delay`,description:`Add the delay for the double press`},{name:`@drag`,description:`Add an event for when the element is dragged`},{name:`@drag-start`,description:`Add an event for when the element first drag`},{name:`@drag-end`,description:`Add an event for when the element drag end`}],vi={a:`HTMLAnchorElement`,abbr:`HTMLElement`,address:`HTMLElement`,area:`HTMLAreaElement`,article:`HTMLElement`,aside:`HTMLElement`,audio:`HTMLAudioElement`,b:`HTMLElement`,base:`HTMLBaseElement`,bdi:`HTMLElement`,bdo:`HTMLElement`,blockquote:`HTMLQuoteElement`,body:`HTMLBodyElement`,br:`HTMLBRElement`,button:`HTMLButtonElement`,canvas:`HTMLCanvasElement`,caption:`HTMLTableCaptionElement`,cite:`HTMLElement`,code:`HTMLElement`,col:`HTMLTableColElement`,colgroup:`HTMLTableColElement`,data:`HTMLDataElement`,datalist:`HTMLDataListElement`,dd:`HTMLElement`,del:`HTMLModElement`,details:`HTMLDetailsElement`,dfn:`HTMLElement`,dialog:`HTMLDialogElement`,div:`HTMLDivElement`,dl:`HTMLDListElement`,dt:`HTMLElement`,em:`HTMLElement`,embed:`HTMLEmbedElement`,fieldset:`HTMLFieldSetElement`,figcaption:`HTMLElement`,figure:`HTMLElement`,footer:`HTMLElement`,form:`HTMLFormElement`,h1:`HTMLHeadingElement`,h2:`HTMLHeadingElement`,h3:`HTMLHeadingElement`,h4:`HTMLHeadingElement`,h5:`HTMLHeadingElement`,h6:`HTMLHeadingElement`,head:`HTMLHeadElement`,header:`HTMLElement`,hgroup:`HTMLElement`,hr:`HTMLHRElement`,html:`HTMLHtmlElement`,i:`HTMLElement`,iframe:`HTMLIFrameElement`,img:`HTMLImageElement`,input:`HTMLInputElement`,ins:`HTMLModElement`,kbd:`HTMLElement`,label:`HTMLLabelElement`,legend:`HTMLLegendElement`,li:`HTMLLIElement`,link:`HTMLLinkElement`,main:`HTMLElement`,map:`HTMLMapElement`,mark:`HTMLElement`,menu:`HTMLMenuElement`,meta:`HTMLMetaElement`,meter:`HTMLMeterElement`,nav:`HTMLElement`,noscript:`HTMLElement`,object:`HTMLObjectElement`,ol:`HTMLOListElement`,optgroup:`HTMLOptGroupElement`,option:`HTMLOptionElement`,output:`HTMLOutputElement`,p:`HTMLParagraphElement`,picture:`HTMLPictureElement`,pre:`HTMLPreElement`,progress:`HTMLProgressElement`,q:`HTMLQuoteElement`,rp:`HTMLElement`,rt:`HTMLElement`,ruby:`HTMLElement`,s:`HTMLElement`,samp:`HTMLElement`,script:`HTMLScriptElement`,section:`HTMLElement`,select:`HTMLSelectElement`,slot:`HTMLSlotElement`,small:`HTMLElement`,source:`HTMLSourceElement`,span:`HTMLSpanElement`,strong:`HTMLElement`,style:`HTMLStyleElement`,sub:`HTMLElement`,summary:`HTMLElement`,sup:`HTMLElement`,table:`HTMLTableElement`,tbody:`HTMLTableSectionElement`,td:`HTMLTableCellElement`,template:`HTMLTemplateElement`,textarea:`HTMLTextAreaElement`,tfoot:`HTMLTableSectionElement`,th:`HTMLTableCellElement`,thead:`HTMLTableSectionElement`,time:`HTMLTimeElement`,title:`HTMLTitleElement`,tr:`HTMLTableRowElement`,track:`HTMLTrackElement`,u:`HTMLElement`,ul:`HTMLUListElement`,var:`HTMLElement`,video:`HTMLVideoElement`,wbr:`HTMLElement`,acronym:`HTMLElement`,applet:`HTMLUnknownElement`,basefont:`HTMLElement`,bgsound:`HTMLUnknownElement`,big:`HTMLElement`,blink:`HTMLUnknownElement`,center:`HTMLElement`,dir:`HTMLDirectoryElement`,font:`HTMLFontElement`,frame:`HTMLFrameElement`,frameset:`HTMLFrameSetElement`,isindex:`HTMLUnknownElement`,keygen:`HTMLUnknownElement`,listing:`HTMLPreElement`,marquee:`HTMLMarqueeElement`,menuitem:`HTMLElement`,multicol:`HTMLUnknownElement`,nextid:`HTMLUnknownElement`,nobr:`HTMLElement`,noembed:`HTMLElement`,noframes:`HTMLElement`,param:`HTMLParamElement`,plaintext:`HTMLElement`,rb:`HTMLElement`,rtc:`HTMLElement`,spacer:`HTMLUnknownElement`,strike:`HTMLElement`,tt:`HTMLElement`,xmp:`HTMLPreElement`,animate:`SVGAnimateElement`,animateMotion:`SVGAnimateMotionElement`,animateTransform:`SVGAnimateTransformElement`,circle:`SVGCircleElement`,clipPath:`SVGClipPathElement`,defs:`SVGDefsElement`,desc:`SVGDescElement`,ellipse:`SVGEllipseElement`,feBlend:`SVGFEBlendElement`,feColorMatrix:`SVGFEColorMatrixElement`,feComponentTransfer:`SVGFEComponentTransferElement`,feComposite:`SVGFECompositeElement`,feConvolveMatrix:`SVGFEConvolveMatrixElement`,feDiffuseLighting:`SVGFEDiffuseLightingElement`,feDisplacementMap:`SVGFEDisplacementMapElement`,feDistantLight:`SVGFEDistantLightElement`,feDropShadow:`SVGFEDropShadowElement`,feFlood:`SVGFEFloodElement`,feFuncA:`SVGFEFuncAElement`,feFuncB:`SVGFEFuncBElement`,feFuncG:`SVGFEFuncGElement`,feFuncR:`SVGFEFuncRElement`,feGaussianBlur:`SVGFEGaussianBlurElement`,feImage:`SVGFEImageElement`,feMerge:`SVGFEMergeElement`,feMergeNode:`SVGFEMergeNodeElement`,feMorphology:`SVGFEMorphologyElement`,feOffset:`SVGFEOffsetElement`,fePointLight:`SVGFEPointLightElement`,feSpecularLighting:`SVGFESpecularLightingElement`,feSpotLight:`SVGFESpotLightElement`,feTile:`SVGFETileElement`,feTurbulence:`SVGFETurbulenceElement`,filter:`SVGFilterElement`,foreignObject:`SVGForeignObjectElement`,g:`SVGGElement`,image:`SVGImageElement`,line:`SVGLineElement`,linearGradient:`SVGLinearGradientElement`,marker:`SVGMarkerElement`,mask:`SVGMaskElement`,metadata:`SVGMetadataElement`,mpath:`SVGMPathElement`,path:`SVGPathElement`,pattern:`SVGPatternElement`,polygon:`SVGPolygonElement`,polyline:`SVGPolylineElement`,radialGradient:`SVGRadialGradientElement`,rect:`SVGRectElement`,set:`SVGSetElement`,stop:`SVGStopElement`,svg:`SVGSVGElement`,switch:`SVGSwitchElement`,symbol:`SVGSymbolElement`,text:`SVGTextElement`,textPath:`SVGTextPathElement`,tspan:`SVGTSpanElement`,use:`SVGUseElement`,view:`SVGViewElement`},yi={for:"for(let ${1:i} = 0; ${1:i} < ${2:this.elements}; ${1:i}++) {\n ${3}\n}",forIn:"for(let ${1:index} in ${2:this.elements}) {\n ${3}\n}",forOf:"for(let ${1:element} of ${2:this.elements}) {\n ${3}\n}",if:`if(\${1:true}) {
|
|
544
547
|
\${2}
|
|
@@ -995,7 +998,8 @@ var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=_o(cs,t),t=xo(t),t}function As
|
|
|
995
998
|
<style>
|
|
996
999
|
${vd(p)}
|
|
997
1000
|
</style>
|
|
998
|
-
`,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(D(_.uri),g),f&&((0,u.unlinkSync)(f.path),R.getInstance().onClose(f.documentUser),gd.send(f.uri)),c&&((0,u.unlinkSync)(c.path),R.getInstance().onClose(c.documentUser),gd.send(c.uri)),m&&((0,u.unlinkSync)(m.path),R.getInstance().onClose(m.documentUser),gd.send(m.uri)),(0,u.rmdirSync)(D(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),ld.send(_.uri)}};function vd(e){return e.
|
|
1001
|
+
`,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(D(_.uri),g),f&&((0,u.unlinkSync)(f.path),R.getInstance().onClose(f.documentUser),gd.send(f.uri)),c&&((0,u.unlinkSync)(c.path),R.getInstance().onClose(c.documentUser),gd.send(c.uri)),m&&((0,u.unlinkSync)(m.path),R.getInstance().onClose(m.documentUser),gd.send(m.uri)),(0,u.rmdirSync)(D(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),ld.send(_.uri)}};function vd(e){return e.replace(/\r\n?/g,`
|
|
1002
|
+
`).split(`
|
|
999
1003
|
`).join(`
|
|
1000
1004
|
`)}var yd=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(w.Component,``),n=R.getInstance().getByUri(e);if(n){let r=D(e.replace(w.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(w.Component,``)+`/`+t,a=Vi.getRegion(n),o=i+w.ComponentStyle,s=d.TextDocument.create(o,C.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(D(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(D(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(D(f),p.getText()),(0,u.unlinkSync)(n.path),R.getInstance().onClose(n.documentUser),gd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),ld.send(p.uri)}}},bd=class{static cmd=`aventus.liveserver.start`;static run(){j.getInstance().start()}},xd=class{static cmd=`aventus.liveserver.toggle`;static run(){j.getInstance().toggle()}},Sd=class{static cmd=`aventus.static`;static async run(){let e=[],t=L.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Static to export`});if(n){let e=n.detail??``,t=n.label;await L.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Cd=class{static cmd=`aventus.liveserver.stop`;static run(){j.getInstance().stop()}},wd=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Td=class e{static cmd=`aventus.wc.create.attribute`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n){if(!t||typeof n!=`number`)return;let r=await $.Input({title:`Provide a name for your Attribute`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}]});if(!r)return;let i=await $.Select(e.attrType,{placeHolder:`Choose a type?`});if(!i)return;De(e.attrType,i);let a=i.detail,o=R.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()
|
|
1001
1005
|
public `+r+e+`:`+a+`;
|
|
@@ -1032,7 +1036,7 @@ public `+r+`?:`+i+`;
|
|
|
1032
1036
|
import { AventusTemplate, log } from 'file://${(0,f.join)(xt(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
1033
1037
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
1034
1038
|
const t = new Template();
|
|
1035
|
-
log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await we(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}(0,u.unlinkSync)(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},uf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=T.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof lf)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){T.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}T.getInstance().setSettings({quickCreations:e},!0)}}},df=class{static cmd=`aventus.template.quick`;static async run(){let e=T.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof lf)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await lf.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await lf.create(r);i&&await i.init(n,n)}},ff=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!Ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=D(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await lf.create(t);if(e){let t=await Ni.publishTemplate(e);if(t instanceof Pi)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},pf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},mf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},hf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},gf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris();for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof A)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(console.log(r),(0,u.writeFileSync)(D(e),t.contentUser))}catch(e){console.error(e)}}}},_f=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new ia(t,!1);await e.init();for(let t of e.getBuilds())await Ri.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=Ri.getInstance().packages,t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=Ii.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},vf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},yf=class{static cmd=`aventus.emmet`;static async run(){Ii.write(!0)}};const bf={allCommandes:{[dd.cmd]:dd,[bd.cmd]:bd,[Cd.cmd]:Cd,[xd.cmd]:xd,[fd.cmd]:fd,[Ad.cmd]:Ad,[jd.cmd]:jd,[_d.cmd]:_d,[yd.cmd]:yd,[Sd.cmd]:Sd,[ud.cmd]:ud,[Yd.cmd]:Yd,[Td.cmd]:Td,[Ed.cmd]:Ed,[Dd.cmd]:Dd,[Od.cmd]:Od,[kd.cmd]:kd,[pd.cmd]:pd,[hd.cmd]:hd,[md.cmd]:md,[Md.cmd]:Md,[Pd.cmd]:Pd,[Id.cmd]:Id,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Vd.cmd]:Vd,[Zd.cmd]:Zd,[qd.cmd]:qd,[nf.cmd]:nf,[Jd.cmd]:Jd,[Xd.cmd]:Xd,[Qd.cmd]:Qd,[$d.cmd]:$d,[rf.cmd]:rf,[af.cmd]:af,[of.cmd]:of,[ff.cmd]:ff,[pf.cmd]:pf,[df.cmd]:df,[uf.cmd]:uf,[mf.cmd]:mf,[hf.cmd]:hf,[gf.cmd]:gf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var xf=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=D(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Sf=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>D(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),T.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=T.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=T.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=T.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await lf.create(a);r&&(Ke(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await lf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await lf.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await lf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof lf){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{placeHolder:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${Ni.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+Ni.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await lf.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?ue.get:ne.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),(0,u.unlinkSync)(e),n(!1)})})}catch{r.close(),(0,u.unlinkSync)(e),n(!1)}})}async extractZip(e,t){try{return await(await de.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=D(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Cf=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Mt(),this.filesNeeded=[E((0,f.join)(xt(),`lib/templateScript/AventusTemplate.d.ts`))];let e=Pt((0,f.join)(xt(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>wf,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:Pt(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!Pt(e),t},directoryExists:e=>(0,u.existsSync)(D(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(require("module").builtinModules.includes(r)){let e=(0,f.join)(At(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,wf,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
1039
|
+
log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await we(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}(0,u.unlinkSync)(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},uf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=T.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof lf)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){T.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}T.getInstance().setSettings({quickCreations:e},!0)}}},df=class{static cmd=`aventus.template.quick`;static async run(){let e=T.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof lf)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await lf.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await lf.create(r);i&&await i.init(n,n)}},ff=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!Ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=D(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await lf.create(t);if(e){let t=await Ni.publishTemplate(e);if(t instanceof Pi)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},pf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},mf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},hf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},gf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris();for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof A)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(D(e),t.contentUser)}catch(e){console.error(e)}}}},_f=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new ia(t,!1);await e.init();for(let t of e.getBuilds())await Ri.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=Ri.getInstance().packages,t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=Ii.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},vf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},yf=class{static cmd=`aventus.emmet`;static async run(){Ii.write(!0)}};const bf={allCommandes:{[dd.cmd]:dd,[bd.cmd]:bd,[Cd.cmd]:Cd,[xd.cmd]:xd,[fd.cmd]:fd,[Ad.cmd]:Ad,[jd.cmd]:jd,[_d.cmd]:_d,[yd.cmd]:yd,[Sd.cmd]:Sd,[ud.cmd]:ud,[Yd.cmd]:Yd,[Td.cmd]:Td,[Ed.cmd]:Ed,[Dd.cmd]:Dd,[Od.cmd]:Od,[kd.cmd]:kd,[pd.cmd]:pd,[hd.cmd]:hd,[md.cmd]:md,[Md.cmd]:Md,[Pd.cmd]:Pd,[Id.cmd]:Id,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Vd.cmd]:Vd,[Zd.cmd]:Zd,[qd.cmd]:qd,[nf.cmd]:nf,[Jd.cmd]:Jd,[Xd.cmd]:Xd,[Qd.cmd]:Qd,[$d.cmd]:$d,[rf.cmd]:rf,[af.cmd]:af,[of.cmd]:of,[ff.cmd]:ff,[pf.cmd]:pf,[df.cmd]:df,[uf.cmd]:uf,[mf.cmd]:mf,[hf.cmd]:hf,[gf.cmd]:gf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var xf=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=D(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Sf=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>D(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),T.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=T.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=T.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=T.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await lf.create(a);r&&(Ke(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await lf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await lf.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{placeHolder:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await lf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await we(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof lf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof lf){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{placeHolder:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${Ni.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+Ni.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await lf.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?ue.get:ne.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),(0,u.unlinkSync)(e),n(!1)})})}catch{r.close(),(0,u.unlinkSync)(e),n(!1)}})}async extractZip(e,t){try{return await(await de.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=D(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Cf=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Mt(),this.filesNeeded=[E((0,f.join)(xt(),`lib/templateScript/AventusTemplate.d.ts`))];let e=Pt((0,f.join)(xt(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>wf,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:Pt(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!Pt(e),t},directoryExists:e=>(0,u.existsSync)(D(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(require("module").builtinModules.includes(r)){let e=(0,f.join)(At(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,wf,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
1036
1040
|
`)}`;r.reportsUnnecessary?n.push({range:ze(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:ze(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=ze(n,We(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Tf)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:kn(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(` `);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
|
|
1037
1041
|
\`\`\`
|
|
1038
1042
|
***
|
package/out/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.27`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
|
|
2
|
+
let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.29`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
|
package/package.json
CHANGED