@aventusjs/cli 0.0.35 → 0.0.36
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 +1 -1
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealServer.js
CHANGED
|
@@ -123,7 +123,7 @@ if ('WebSocket' in window) {
|
|
|
123
123
|
})();
|
|
124
124
|
}
|
|
125
125
|
<\/script>`;var Le=class{static send(e,t){$.sendNotification(`aventus/server/start`,`http://`+e+`:`+t)}},Re=class{static send(){$.sendNotification(`aventus/server/stop`,{})}},D=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}static get isRunning(){return!!(this.instance?.server&&this.instance.server.listening)}config;server;wss;reloadTimeout;clients=[];port=8080;constructor(){this.config=P.getInstance().settings.liveserver}toggle(){this.server&&this.server.listening?this.stop():this.start()}async start(){if(!this.server||!this.server.listening){this.config=P.getInstance().settings.liveserver,this.port=this.config.port;var e=(0,_.default)();let t=this.createStaticServer();if(e.use(t).use(this.entryPoint(t,this.config.indexFile)).use((0,ee.default)(this.config.rootFolder,{icons:!0})),this.server=(0,b.createServer)(e),this.server.addListener(`listening`,()=>{let e=this.config.host;if(e==`0.0.0.0`&&(e=`127.0.0.1`),Le.send(e,this.port),this.config.launch_browser){let t={};this.config.browser&&(t={app:{name:this.config.browser}}),(0,ne.default)(`http://${e}:${this.port}`,t)}else{let e=`http://${this.config.host}:${this.port}`;$.showInformationMessage(`Liver server started on `+e)}}),this.clients=[],this.wss=new te.WebSocketServer({server:this.server}),this.wss.on(`connection`,e=>{e.onclose=()=>{this.clients=this.clients.filter(function(t){return t!==e})},this.clients.push(e)}),this.config.autoIncrementPort)for(;await this.portInUse(this.config.host,this.port);)this.port++;else if(await this.portInUse(this.config.host,this.port)){$.showErrorMessage(`The port `+this.port+` is already in use`);return}this.server.listen(this.port,this.config.host)}}stop(){for(let e of this.clients)e.close();this.clients=[],this.server&&=(this.server.close(),void 0),this.wss&&=(this.wss.close(),void 0),Re.send()}portInUse(e,t){return new Promise((n,r)=>{var i=(0,x.createServer)(function(e){e.write(`Echo server
|
|
126
|
-
`),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==te.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=y.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=Ie.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=y.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,v.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=Ie;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,Fe.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const ze={},Be=()=>$.extensionPath;let Ve;const He=()=>{if(Ve!==void 0)return Ve;let e=Be();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return Ve=e,Ve;e=(0,f.resolve)(e,`..`)}return Be()},Ue=()=>(0,f.join)(He(),`node_modules/typescript/lib`),We=()=>(0,f.join)(Be(),`lib/Aventus@Main.package.avt`),Ge=()=>(0,f.join)(Be(),`lib/Aventus@UI.package.avt`),Ke=()=>(0,f.join)(Be(),`lib/Aventus@I18n.package.avt`),qe=()=>(0,f.join)(Be(),`lib/Aventus@Sharp.package.avt`),Je=()=>(0,f.join)(Be(),`lib/Aventus@Php.package.avt`),Ye=()=>(0,f.join)(He(),`node_modules`),Xe=[];function Ze(){if(Xe.length>0)return;let e=(0,u.readdirSync)(Ue());for(let t of e)t.endsWith(`.d.ts`)&&Xe.push(t)}function Qe(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(F(e));else for(let e of i)n.push(F(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function $e(e){let t=ze[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(Ye(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=Xe.includes(e)?(0,f.join)(Ue(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(ze[e]=t)),t}var et=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(Ue(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},O=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function tt(e,t){return(e&t)!=0}function nt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function rt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:nt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:nt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const it=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var at=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(it.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=rt(e);t&&o.arguments.push(t)}r.push(o)}else A.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},ot=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},st=class e{static is(t){return t.name==`Internal`?new e:null}},ct=class e{static is(t){return t.name==`InternalProtected`?new e:null}},lt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},ut=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
|
|
126
|
+
`),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==te.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=y.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=Ie.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=y.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,v.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=Ie;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,Fe.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const ze={},Be=()=>$.extensionPath;let Ve;const He=()=>{if(Ve!==void 0)return Ve;let e=Be();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return Ve=e,Ve;e=(0,f.resolve)(e,`..`)}return Be()},Ue=()=>(0,f.join)(He(),`node_modules/typescript/lib`),We=()=>(0,f.join)(Be(),`lib/Aventus@Main.package.avt`),Ge=()=>(0,f.join)(Be(),`lib/Aventus@UI.package.avt`),Ke=()=>(0,f.join)(Be(),`lib/Aventus@I18n.package.avt`),qe=()=>(0,f.join)(Be(),`lib/Aventus@Sharp.package.avt`),Je=()=>(0,f.join)(Be(),`lib/Aventus@Php.package.avt`),Ye=()=>(0,f.join)(He(),`node_modules`),Xe=[];function Ze(){if(Xe.length>0)return;let e=(0,u.readdirSync)(Ue());for(let t of e)t.endsWith(`.d.ts`)&&Xe.push(t)}function Qe(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(F(e));else for(let e of i)n.push(F(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function $e(e){let t=ze[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(Ye(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=Xe.includes(e)?(0,f.join)(Ue(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(ze[e]=t)),t}var et=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(Ue(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},O=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function tt(e,t){return(e&t)!=0}function nt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};nt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];nt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function rt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:nt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:nt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const it=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.NoType.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var at=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(it.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=rt(e);t&&o.arguments.push(t)}r.push(o)}else A.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},ot=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},st=class e{static is(t){return t.name==`Internal`?new e:null}},ct=class e{static is(t){return t.name==`InternalProtected`?new e:null}},lt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},ut=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
|
|
127
127
|
`)),typeof t.comment==`string`&&this.definitions.push(t.comment),t.tags){for(let e of t.tags)if(e.kind==p.SyntaxKind.JSDocParameterTag){let t=e;typeof t.comment==`string`&&(this.documentationParameters[t.name.getText()]=t.comment)}else if(e.kind==p.SyntaxKind.JSDocReturnTag){let t=e;typeof t.comment==`string`&&(this.documentationReturn=t.comment)}else if(e.kind==p.SyntaxKind.JSDocTemplateTag){let t=e;if(typeof t.comment==`string`)for(let e of t.typeParameters)this.documentationTemplates[e.name.getText()]=t.comment}else if(e.kind==p.SyntaxKind.JSDocTag){let t=e.getText().trim();if(t.startsWith(`@slot`)){let e=/@slot\s*([a-zA-z\-]*)\s*?(-|$)(.*)/gm.exec(t);if(e){let t=e[1];t||=`default`;let n=e[3];n&&(this.documentationSlots[t]=n.trim())}}}}}}};function dt(){return`import type { StorybookConfig } from "@storybook/web-components-vite";
|
|
128
128
|
import remarkGfm from 'remark-gfm';
|
|
129
129
|
|
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"),r=require("child_process"),i=require("fs");var a=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=o,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}},o=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=a}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)}},s=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}},c=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,s.actions[n]||(s.actions[n]=r.command(e)),r=s.actions[n],n+=` `;r=r.description(this.description)}};function l(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function u(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=d(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function d(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function f(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 p={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var m=class extends s{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 o.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await o.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=o.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=o.getErrors(),i=!1,a={},s={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){a[n.typeName]||(a[n.typeName]=[]);let e=` ${n.path} - ${f(n.size)}`;a[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){s[n.typeName]||(s[n.typeName]=[]);let e=` ${n.path} - ${f(n.size)}`;s[n.typeName].push(e)}}let c=Object.keys(t.builds).length,u=Object.keys(t.statics).length,d=0;for(let o in t.builds){n(`Building `+o),n();let s=!1,f=r[o],m=t.builds[o],h=a[o];if(h){for(let e of h)n(e);n()}if(f){let t=!1;for(let n in f)for(let r of f[n]){let i=``,a;if(r.severity==p.Error)i=`\x1B[31m[error]\x1B[0m`,s=!0,a=console.error;else if(r.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${l(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}s?(n(` Build failed in `+m.buildTime+`ms`),i=!0):n(` Build success in `+m.buildTime+`ms`),d++,d==c&&u==0?n():(n(),n(`----`),n())}d=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=s[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),d++,d==u?n():(n(),n(`----`),n())}i&&process.exit(1)}handleResultJson(e){let t=o.getStatistics(),n={success:!0,builds:{},statics:{}},r=o.getErrors(),i=!1,a=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},s=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},c=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=l(r.path).replace(/\\/g,`/`);a(e),n.builds[e].outputSize[t]=c(r.size)}else if(r.type==`static`&&r.typeName){let e=l(r.path).replace(/\\/g,`/`);s(r.typeName),n.statics[r.typeName].outputSize[e]=c(r.size)}}for(let e in t.builds){a(e);let t=r[e];if(t)for(let r in t){let a=l(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[a]=o;for(let a of t[r]){let t;a.severity==p.Error?(n.builds[e].success=!1,n.success=!1,i=!0,t=`error`):a.severity==p.Warning?t=`warning`:a.severity==p.Information?t=`info`:a.severity==p.Hint&&(t=`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:t})}}}console.log(JSON.stringify(n,void 0,4)),i&&process.exit(1)}},h=class extends s{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 a.load({clear:!0,printLogo:!0}),await o.load(),console.clear(),await a.init(),await o.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(a.clear();;){let e=await a.select(`Which action shoud I perform?`,n);e==`create`?await o.create():e==`log`?await a.log():e==`quit`?process.exit(0):console.log(`WIP`),a.clear()}}},g=class extends s{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 o.load(),await o.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=o.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=o.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==p.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${l(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=o.getErrors(),r=!1,i=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){i(e);let a=n[e];if(a)for(let n in a){let i=l(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[i]=o;for(let i of a[n]){let n;i.severity==p.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):i.severity==p.Warning?n=`warning`:i.severity==p.Information?n=`info`:i.severity==p.Hint&&(n=`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:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},_=class extends s{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 o.load(),await o.start({noBuild:!0,configPath:r}),await o.executeCommand(`aventus.format`)}},v=class extends s{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 a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},y=class extends s{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},b=class extends s{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},x=class extends s{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await o.executeCommand(`aventus.create`,u(process.cwd()))}catch(e){console.log(e)}}},S=class extends s{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},C=class extends s{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},w=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},T=class extends s{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({loadFiles:!0,watchFiles:!0}),await o.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await o.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return o.notifications.allNotifications[w.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)})}},E=class extends s{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 o.load(),await o.start({noBuild:!0,loadFiles:!1,configPath:n}),await o.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},D=class extends s{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},O=class extends s{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},k=class extends c{get name(){return`project`}get description(){return`Manage project's templates`}},A=class extends c{get name(){return`template`}get description(){return`Manage templates`}},j=class extends c{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},M=class extends c{get name(){return`store`}get description(){return`Manage store`}},N=class extends s{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 o.load(),console.clear(),await o.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let i=o.getErrors(),a=n.json?this.renderLogJson:this.renderLog;a(i),o.subscribeErrors((e,t)=>{i[t]=e,a(i)}),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==p.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${l(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=l(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==p.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==p.Warning)e=`warning`;else if(n.severity==p.Information)e=`info`;else if(n.severity==p.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))}},P=class extends c{get name(){return`ai`}get description(){return`Manage ai helpers`}},F=class extends s{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 o.load(),await o.start({noBuild:!0,loadFiles:!1,configPath:n}),await o.executeCommand(`aventus.ai.dependencies`),await o.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},I=`0.0.35`;const L=`@aventusjs/cli`,R=[x,h,N,T,m,g,_,class extends s{get name(){return`update`}get description(){return`Update the cli`}registerArgs(e){}registerOptions(e){}async run(e,n){let r=(await this.runNpm([`view`,L,`version`])).trim();if(!r)throw Error(`npm did not return a version for ${L}.`);if(r===I){console.log(`${L} is already up to date (${I}).`);return}let a=(await this.runNpm([`root`,`--global`])).trim(),o=(0,i.realpathSync)((0,t.resolve)(__dirname,`..`,`..`)),s;try{s=(0,i.realpathSync)((0,t.resolve)(a,L))}catch{}let c=s===o?[`install`,`--global`,`${L}@${r}`]:[`install`,`--save-dev`,`${L}@${r}`];await this.runNpm(c,!0),console.log(`${L} was updated to ${r}.`)}runNpm(e,t=!1){return new Promise((n,i)=>{let a=(0,r.spawn)(`npm`,e,{cwd:process.cwd(),shell:process.platform===`win32`,stdio:t?`inherit`:[`ignore`,`pipe`,`pipe`]}),o=``,s=``;t||(a.stdout?.on(`data`,e=>o+=e.toString()),a.stderr?.on(`data`,e=>s+=e.toString())),a.on(`error`,i),a.on(`close`,t=>{if(t===0){n(o);return}let r=s.trim();i(Error(`npm ${e.join(` `)} failed with exit code ${t}${r?`: ${r}`:`.`}`))})})}},j,E,P,F,k,C,D,A,S,O,M,v,y,b];function z(e){for(let t of R)new t().register(e)}e.program.version(I).name(`aventus`).description(`Aventus CLI`),z(e.program),e.program.parse(process.argv);
|
|
2
|
+
let e=require("commander"),t=require("path"),n=require("vscode-languageserver"),r=require("child_process"),i=require("fs");var a=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=o,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}},o=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=a}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)}},s=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}},c=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,s.actions[n]||(s.actions[n]=r.command(e)),r=s.actions[n],n+=` `;r=r.description(this.description)}};function l(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function u(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=d(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function d(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function f(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 p={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var m=class extends s{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 o.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await o.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=o.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=o.getErrors(),i=!1,a={},s={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){a[n.typeName]||(a[n.typeName]=[]);let e=` ${n.path} - ${f(n.size)}`;a[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){s[n.typeName]||(s[n.typeName]=[]);let e=` ${n.path} - ${f(n.size)}`;s[n.typeName].push(e)}}let c=Object.keys(t.builds).length,u=Object.keys(t.statics).length,d=0;for(let o in t.builds){n(`Building `+o),n();let s=!1,f=r[o],m=t.builds[o],h=a[o];if(h){for(let e of h)n(e);n()}if(f){let t=!1;for(let n in f)for(let r of f[n]){let i=``,a;if(r.severity==p.Error)i=`\x1B[31m[error]\x1B[0m`,s=!0,a=console.error;else if(r.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${l(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}s?(n(` Build failed in `+m.buildTime+`ms`),i=!0):n(` Build success in `+m.buildTime+`ms`),d++,d==c&&u==0?n():(n(),n(`----`),n())}d=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=s[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),d++,d==u?n():(n(),n(`----`),n())}i&&process.exit(1)}handleResultJson(e){let t=o.getStatistics(),n={success:!0,builds:{},statics:{}},r=o.getErrors(),i=!1,a=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},s=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},c=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=l(r.path).replace(/\\/g,`/`);a(e),n.builds[e].outputSize[t]=c(r.size)}else if(r.type==`static`&&r.typeName){let e=l(r.path).replace(/\\/g,`/`);s(r.typeName),n.statics[r.typeName].outputSize[e]=c(r.size)}}for(let e in t.builds){a(e);let t=r[e];if(t)for(let r in t){let a=l(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[a]=o;for(let a of t[r]){let t;a.severity==p.Error?(n.builds[e].success=!1,n.success=!1,i=!0,t=`error`):a.severity==p.Warning?t=`warning`:a.severity==p.Information?t=`info`:a.severity==p.Hint&&(t=`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:t})}}}console.log(JSON.stringify(n,void 0,4)),i&&process.exit(1)}},h=class extends s{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 a.load({clear:!0,printLogo:!0}),await o.load(),console.clear(),await a.init(),await o.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(a.clear();;){let e=await a.select(`Which action shoud I perform?`,n);e==`create`?await o.create():e==`log`?await a.log():e==`quit`?process.exit(0):console.log(`WIP`),a.clear()}}},g=class extends s{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 o.load(),await o.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=o.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=o.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==p.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${l(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=o.getErrors(),r=!1,i=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){i(e);let a=n[e];if(a)for(let n in a){let i=l(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[i]=o;for(let i of a[n]){let n;i.severity==p.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):i.severity==p.Warning?n=`warning`:i.severity==p.Information?n=`info`:i.severity==p.Hint&&(n=`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:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},_=class extends s{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 o.load(),await o.start({noBuild:!0,configPath:r}),await o.executeCommand(`aventus.format`)}},v=class extends s{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 a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},y=class extends s{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},b=class extends s{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noStart:!0}),await o.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},x=class extends s{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await o.executeCommand(`aventus.create`,u(process.cwd()))}catch(e){console.log(e)}}},S=class extends s{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},C=class extends s{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},w=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},T=class extends s{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({loadFiles:!0,watchFiles:!0}),await o.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await o.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return o.notifications.allNotifications[w.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)})}},E=class extends s{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 o.load(),await o.start({noBuild:!0,loadFiles:!1,configPath:n}),await o.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},D=class extends s{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},O=class extends s{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await a.load(),await o.load(),await o.start({noBuild:!0,useTemplates:!0}),await o.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},k=class extends c{get name(){return`project`}get description(){return`Manage project's templates`}},A=class extends c{get name(){return`template`}get description(){return`Manage templates`}},j=class extends c{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},M=class extends c{get name(){return`store`}get description(){return`Manage store`}},N=class extends s{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 o.load(),console.clear(),await o.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let i=o.getErrors(),a=n.json?this.renderLogJson:this.renderLog;a(i),o.subscribeErrors((e,t)=>{i[t]=e,a(i)}),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==p.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==p.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==p.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==p.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${l(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=l(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==p.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==p.Warning)e=`warning`;else if(n.severity==p.Information)e=`info`;else if(n.severity==p.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))}},P=class extends c{get name(){return`ai`}get description(){return`Manage ai helpers`}},F=class extends s{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 o.load(),await o.start({noBuild:!0,loadFiles:!1,configPath:n}),await o.executeCommand(`aventus.ai.dependencies`),await o.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},I=`0.0.36`;const L=`@aventusjs/cli`,R=[x,h,N,T,m,g,_,class extends s{get name(){return`update`}get description(){return`Update the cli`}registerArgs(e){}registerOptions(e){}async run(e,n){let r=(await this.runNpm([`view`,L,`version`])).trim();if(!r)throw Error(`npm did not return a version for ${L}.`);if(r===I){console.log(`${L} is already up to date (${I}).`);return}let a=(await this.runNpm([`root`,`--global`])).trim(),o=(0,i.realpathSync)((0,t.resolve)(__dirname,`..`,`..`)),s;try{s=(0,i.realpathSync)((0,t.resolve)(a,L))}catch{}let c=s===o?[`install`,`--global`,`${L}@${r}`]:[`install`,`--save-dev`,`${L}@${r}`];await this.runNpm(c,!0),console.log(`${L} was updated to ${r}.`)}runNpm(e,t=!1){return new Promise((n,i)=>{let a=(0,r.spawn)(`npm`,e,{cwd:process.cwd(),shell:process.platform===`win32`,stdio:t?`inherit`:[`ignore`,`pipe`,`pipe`]}),o=``,s=``;t||(a.stdout?.on(`data`,e=>o+=e.toString()),a.stderr?.on(`data`,e=>s+=e.toString())),a.on(`error`,i),a.on(`close`,t=>{if(t===0){n(o);return}let r=s.trim();i(Error(`npm ${e.join(` `)} failed with exit code ${t}${r?`: ${r}`:`.`}`))})})}},j,E,P,F,k,C,D,A,S,O,M,v,y,b];function z(e){for(let t of R)new t().register(e)}e.program.version(I).name(`aventus`).description(`Aventus CLI`),z(e.program),e.program.parse(process.argv);
|
package/package.json
CHANGED