@fluixi/core 1.0.0-alpha.53
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/LICENSE +21 -0
- package/README.md +611 -0
- package/dist/cdn/core.global.js +3 -0
- package/dist/cli/generate.cjs +1814 -0
- package/dist/cli/generate.d.ts +7 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +2580 -0
- package/dist/cli/generate.mjs +1814 -0
- package/dist/cli/index.cjs +1814 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2580 -0
- package/dist/cli/index.mjs +1814 -0
- package/dist/cli/run.cjs +2 -0
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +62 -0
- package/dist/cli/run.mjs +2 -0
- package/dist/fluixi.d.ts +5 -0
- package/dist/src/cdn/chunk-PFM5O5UE.mjs +1 -0
- package/dist/src/cdn/core.cjs +1 -0
- package/dist/src/cdn/core.d.ts +16 -0
- package/dist/src/cdn/core.d.ts.map +1 -0
- package/dist/src/cdn/core.js +15 -0
- package/dist/src/cdn/core.mjs +1 -0
- package/dist/src/cdn/router-next-WNWCFVC2.mjs +1 -0
- package/dist/src/index.cjs +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.mjs +1 -0
- package/dist/src/jsx-dev-runtime.cjs +1 -0
- package/dist/src/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/jsx-dev-runtime.js +1 -0
- package/dist/src/jsx-dev-runtime.mjs +1 -0
- package/dist/src/jsx-runtime.cjs +1 -0
- package/dist/src/jsx-runtime.d.ts +7 -0
- package/dist/src/jsx-runtime.d.ts.map +1 -0
- package/dist/src/jsx-runtime.js +17 -0
- package/dist/src/jsx-runtime.mjs +1 -0
- package/dist/src/lib/client/chunk-D3VTWVNJ.mjs +1 -0
- package/dist/src/lib/client/index.cjs +1 -0
- package/dist/src/lib/client/index.d.ts +54 -0
- package/dist/src/lib/client/index.d.ts.map +1 -0
- package/dist/src/lib/client/index.js +142 -0
- package/dist/src/lib/client/index.mjs +1 -0
- package/dist/src/lib/client/router-next-UYIYMRJL.mjs +1 -0
- package/dist/src/lib/context/context.cjs +1 -0
- package/dist/src/lib/context/context.d.ts +337 -0
- package/dist/src/lib/context/context.d.ts.map +1 -0
- package/dist/src/lib/context/context.js +462 -0
- package/dist/src/lib/context/context.mjs +1 -0
- package/dist/src/lib/context/index.cjs +1 -0
- package/dist/src/lib/context/index.d.ts +3 -0
- package/dist/src/lib/context/index.d.ts.map +1 -0
- package/dist/src/lib/context/index.js +5 -0
- package/dist/src/lib/context/index.mjs +1 -0
- package/dist/src/lib/control-flow.cjs +1 -0
- package/dist/src/lib/control-flow.d.ts +4 -0
- package/dist/src/lib/control-flow.d.ts.map +1 -0
- package/dist/src/lib/control-flow.js +1 -0
- package/dist/src/lib/control-flow.mjs +1 -0
- package/dist/src/lib/core.cjs +1 -0
- package/dist/src/lib/core.d.ts +90 -0
- package/dist/src/lib/core.d.ts.map +1 -0
- package/dist/src/lib/core.js +181 -0
- package/dist/src/lib/core.mjs +1 -0
- package/dist/src/lib/directives/lit.cjs +1 -0
- package/dist/src/lib/directives/lit.d.ts +2 -0
- package/dist/src/lib/directives/lit.d.ts.map +1 -0
- package/dist/src/lib/directives/lit.js +31 -0
- package/dist/src/lib/directives/lit.mjs +0 -0
- package/dist/src/lib/env/index.cjs +1 -0
- package/dist/src/lib/env/index.d.ts +39 -0
- package/dist/src/lib/env/index.d.ts.map +1 -0
- package/dist/src/lib/env/index.js +50 -0
- package/dist/src/lib/env/index.mjs +1 -0
- package/dist/src/lib/i18n/index.cjs +1 -0
- package/dist/src/lib/i18n/index.d.ts +79 -0
- package/dist/src/lib/i18n/index.d.ts.map +1 -0
- package/dist/src/lib/i18n/index.js +127 -0
- package/dist/src/lib/i18n/index.mjs +1 -0
- package/dist/src/lib/index.cjs +1 -0
- package/dist/src/lib/index.d.ts +83 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +147 -0
- package/dist/src/lib/index.mjs +1 -0
- package/dist/src/lib/isomorphic.cjs +1 -0
- package/dist/src/lib/isomorphic.d.ts +69 -0
- package/dist/src/lib/isomorphic.d.ts.map +1 -0
- package/dist/src/lib/isomorphic.js +92 -0
- package/dist/src/lib/isomorphic.mjs +1 -0
- package/dist/src/lib/jsx-runtime/index.cjs +1 -0
- package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
- package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/index.js +23 -0
- package/dist/src/lib/jsx-runtime/index.mjs +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +13 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +21 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +102 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +13 -0
- package/dist/src/lib/plugins/index.cjs +13 -0
- package/dist/src/lib/plugins/index.d.ts +4 -0
- package/dist/src/lib/plugins/index.d.ts.map +1 -0
- package/dist/src/lib/plugins/index.js +3 -0
- package/dist/src/lib/plugins/index.mjs +13 -0
- package/dist/src/lib/plugins/route-codegen.cjs +8 -0
- package/dist/src/lib/plugins/route-codegen.d.ts +13 -0
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-codegen.js +81 -0
- package/dist/src/lib/plugins/route-codegen.mjs +8 -0
- package/dist/src/lib/plugins/route-scanner.cjs +1 -0
- package/dist/src/lib/plugins/route-scanner.d.ts +39 -0
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-scanner.js +216 -0
- package/dist/src/lib/plugins/route-scanner.mjs +1 -0
- package/dist/src/lib/plugins/vite.cjs +1 -0
- package/dist/src/lib/plugins/vite.d.ts +3 -0
- package/dist/src/lib/plugins/vite.d.ts.map +1 -0
- package/dist/src/lib/plugins/vite.js +1 -0
- package/dist/src/lib/plugins/vite.mjs +1 -0
- package/dist/src/lib/render/component.cjs +1 -0
- package/dist/src/lib/render/component.d.ts +328 -0
- package/dist/src/lib/render/component.d.ts.map +1 -0
- package/dist/src/lib/render/component.js +520 -0
- package/dist/src/lib/render/component.mjs +1 -0
- package/dist/src/lib/render/index.cjs +1 -0
- package/dist/src/lib/render/index.d.ts +113 -0
- package/dist/src/lib/render/index.d.ts.map +1 -0
- package/dist/src/lib/render/index.js +201 -0
- package/dist/src/lib/render/index.mjs +1 -0
- package/dist/src/lib/render/lazy.cjs +1 -0
- package/dist/src/lib/render/lazy.d.ts +28 -0
- package/dist/src/lib/render/lazy.d.ts.map +1 -0
- package/dist/src/lib/render/lazy.js +62 -0
- package/dist/src/lib/render/lazy.mjs +1 -0
- package/dist/src/lib/render/suspense.cjs +1 -0
- package/dist/src/lib/render/suspense.d.ts +25 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -0
- package/dist/src/lib/render/suspense.js +139 -0
- package/dist/src/lib/render/suspense.mjs +1 -0
- package/dist/src/lib/router-next/data.cjs +1 -0
- package/dist/src/lib/router-next/data.d.ts +101 -0
- package/dist/src/lib/router-next/data.d.ts.map +1 -0
- package/dist/src/lib/router-next/data.js +179 -0
- package/dist/src/lib/router-next/data.mjs +1 -0
- package/dist/src/lib/router-next/index.cjs +1 -0
- package/dist/src/lib/router-next/index.d.ts +156 -0
- package/dist/src/lib/router-next/index.d.ts.map +1 -0
- package/dist/src/lib/router-next/index.js +464 -0
- package/dist/src/lib/router-next/index.mjs +1 -0
- package/dist/src/lib/server/hydration.cjs +1 -0
- package/dist/src/lib/server/hydration.d.ts +238 -0
- package/dist/src/lib/server/hydration.d.ts.map +1 -0
- package/dist/src/lib/server/hydration.js +384 -0
- package/dist/src/lib/server/hydration.mjs +1 -0
- package/dist/src/lib/server/index.cjs +16 -0
- package/dist/src/lib/server/index.d.ts +91 -0
- package/dist/src/lib/server/index.d.ts.map +1 -0
- package/dist/src/lib/server/index.js +141 -0
- package/dist/src/lib/server/index.mjs +16 -0
- package/dist/src/lib/server/reactive.cjs +1 -0
- package/dist/src/lib/server/reactive.d.ts +298 -0
- package/dist/src/lib/server/reactive.d.ts.map +1 -0
- package/dist/src/lib/server/reactive.js +472 -0
- package/dist/src/lib/server/reactive.mjs +1 -0
- package/dist/src/lib/theme/index.cjs +1 -0
- package/dist/src/lib/theme/index.d.ts +51 -0
- package/dist/src/lib/theme/index.d.ts.map +1 -0
- package/dist/src/lib/theme/index.js +79 -0
- package/dist/src/lib/theme/index.mjs +1 -0
- package/dist/src/lib/utils/index.cjs +1 -0
- package/dist/src/lib/utils/index.d.ts +379 -0
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +527 -0
- package/dist/src/lib/utils/index.mjs +1 -0
- package/dist/src/rx.cjs +1 -0
- package/dist/src/rx.d.ts +2 -0
- package/dist/src/rx.d.ts.map +1 -0
- package/dist/src/rx.js +101 -0
- package/dist/src/rx.mjs +0 -0
- package/dist/src/server.cjs +16 -0
- package/dist/src/server.d.ts +64 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +63 -0
- package/dist/src/server.mjs +16 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +128 -0
- package/src/index.ts +31 -0
- package/types/fluixi.d.ts +5 -0
- package/types/vinxi.d.ts +50 -0
|
@@ -0,0 +1,1814 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var De=Object.create;var re=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var y=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Me=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Re(e))!Ve.call(i,o)&&o!==t&&re(i,o,{get:()=>e[o],enumerable:!(r=Ie(e,o))||r.enumerable});return i};var F=(i,e,t)=>(t=i!=null?De(He(i)):{},Me(e||!i||!i.__esModule?re(t,"default",{value:i,enumerable:!0}):t,i));var O=y(M=>{"use strict";var L=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},V=class extends L{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};M.CommanderError=L;M.InvalidArgumentError=V});var j=y(N=>{"use strict";var{InvalidArgumentError:Be}=O(),B=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Be(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ne(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}N.Argument=B;N.humanReadableArgName=Ne});var U=y(oe=>{"use strict";var{humanReadableArgName:We}=j(),W=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(r=>!r._hidden);if(e._hasImplicitHelpCommand()){let[,r,o]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),n=e.createCommand(r).helpOption(!1);n.description(e._helpCommandDescription),o&&n.arguments(o),t.push(n)}return this.sortSubcommands&&t.sort((r,o)=>r.name().localeCompare(o.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),o=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||o){let n;r?o?n=e.createOption(e._helpFlags,e._helpDescription):n=e.createOption(e._helpShortFlag,e._helpDescription):n=e.createOption(e._helpLongFlag,e._helpDescription),t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(n=>!n.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>We(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,n=2,s=2;function l(h,_){if(_){let H=`${h.padEnd(r+s)}${_}`;return t.wrap(H,o-n,r+s)}return h}function a(h){return h.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(n))}let c=[`Usage: ${t.commandUsage(e)}`,""],u=t.commandDescription(e);u.length>0&&(c=c.concat([t.wrap(u,o,0),""]));let m=t.visibleArguments(e).map(h=>l(t.argumentTerm(h),t.argumentDescription(h)));m.length>0&&(c=c.concat(["Arguments:",a(m),""]));let C=t.visibleOptions(e).map(h=>l(t.optionTerm(h),t.optionDescription(h)));if(C.length>0&&(c=c.concat(["Options:",a(C),""])),this.showGlobalOptions){let h=t.visibleGlobalOptions(e).map(_=>l(t.optionTerm(_),t.optionDescription(_)));h.length>0&&(c=c.concat(["Global Options:",a(h),""]))}let x=t.visibleCommands(e).map(h=>l(t.subcommandTerm(h),t.subcommandDescription(h)));return x.length>0&&(c=c.concat(["Commands:",a(x),""])),c.join(`
|
|
4
|
+
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,o=40){let n=" \\f\\t\\v - \uFEFF",s=new RegExp(`[\\n][${n}]+`);if(e.match(s))return e;let l=t-r;if(l<o)return e;let a=e.slice(0,r),c=e.slice(r).replace(`\r
|
|
5
|
+
`,`
|
|
6
|
+
`),u=" ".repeat(r),C="\\s",x=new RegExp(`
|
|
7
|
+
|.{1,${l-1}}([${C}]|$)|[^${C}]+?([${C}]|$)`,"g"),h=c.match(x)||[];return a+h.map((_,H)=>_===`
|
|
8
|
+
`?"":(H>0?u:"")+_.trimEnd()).join(`
|
|
9
|
+
`)}};oe.Help=W});var J=y(T=>{"use strict";var{InvalidArgumentError:Ue}=O(),q=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=ne(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new Ue(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return qe(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},G=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,n=o!==void 0?o:!1;return t.negate===(n===e)}};function qe(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ne(i){let e,t,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}T.Option=q;T.splitOptionFlags=ne;T.DualOptions=G});var ae=y(se=>{"use strict";function Ge(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let r=0;r<=i.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let n=1;i[o-1]===e[r-1]?n=0:n=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+n),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[i.length][e.length]}function Je(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(s=>s.slice(2)));let r=[],o=3,n=.4;return e.forEach(s=>{if(s.length<=1)return;let l=Ge(i,s),a=Math.max(i.length,s.length);(a-l)/a>n&&(l<o?(o=l,r=[s]):l===o&&r.push(s))}),r.sort((s,l)=>s.localeCompare(l)),t&&(r=r.map(s=>`--${s}`)),r.length>1?`
|
|
10
|
+
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
11
|
+
(Did you mean ${r[0]}?)`:""}se.suggestSimilar=Je});var de=y(he=>{"use strict";var ze=require("events").EventEmitter,z=require("child_process"),w=require("path"),Y=require("fs"),g=require("process"),{Argument:Ye,humanReadableArgName:Ke}=j(),{CommanderError:K}=O(),{Help:Xe}=U(),{Option:le,splitOptionFlags:Ze,DualOptions:Qe}=J(),{suggestSimilar:ce}=ae(),X=class i extends ze{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._hasHelpOption=e._hasHelpOption,this._helpFlags=e._helpFlags,this._helpDescription=e._helpDescription,this._helpShortFlag=e._helpShortFlag,this._helpLongFlag=e._helpLongFlag,this._helpCommandName=e._helpCommandName,this._helpCommandnameAndArgs=e._helpCommandnameAndArgs,this._helpCommandDescription=e._helpCommandDescription,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let o=t,n=r;typeof o=="object"&&o!==null&&(n=o,o=null),n=n||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return o&&(a.description(o),a._executableHandler=!0),n.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(n.noHelp||n.hidden),a._executableFile=n.executableFile||null,l&&a.arguments(l),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),o?this:a}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Xe,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this.commands.push(e),e.parent=this,this}createArgument(e,t){return new Ye(e,t)}argument(e,t,r,o){let n=this.createArgument(e,t);return typeof r=="function"?n.default(o).argParser(r):n.default(r),this.addArgument(n),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}addHelpCommand(e,t){return e===!1?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,typeof e=="string"&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return this._addImplicitHelpCommand===void 0?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
+
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new K(e,t,r)),g.exit(e)}action(e){let t=r=>{let o=this.registeredArguments.length,n=r.slice(0,o);return this._storeOptionsAsProperties?n[o]=this:n[o]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new le(e,t)}_callParseArg(e,t,r,o){try{return e.parseArg(t,r)}catch(n){if(n.code==="commander.invalidArgument"){let s=`${o} ${n.message}`;this.error(s,{exitCode:n.exitCode,code:n.code})}throw n}}addOption(e){let t=e.name(),r=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");this.options.push(e);let o=(n,s,l)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let a=this.getOptionValue(r);n!==null&&e.parseArg?n=this._callParseArg(e,n,a,s):n!==null&&e.variadic&&(n=e._concatValue(n,a)),n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(r,n,l)};return this.on("option:"+t,n=>{let s=`error: option '${e.flags}' argument '${n}' is invalid.`;o(n,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let s=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;o(n,s,"env")}),this}_optionEx(e,t,r,o,n){if(typeof t=="object"&&t instanceof le)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,r);if(s.makeOptionMandatory(!!e.mandatory),typeof o=="function")s.default(n).argParser(o);else if(o instanceof RegExp){let l=o;o=(a,c)=>{let u=l.exec(a);return u?u[0]:c},s.default(n).argParser(o)}else s.default(o);return this.addOption(s)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");t=t||{},e===void 0&&(e=g.argv,g.versions&&g.versions.electron&&(t.from="electron")),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function n(u,m){let C=w.resolve(u,m);if(Y.existsSync(C))return C;if(o.includes(w.extname(m)))return;let x=o.find(h=>Y.existsSync(`${C}${h}`));if(x)return`${C}${x}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let u;try{u=Y.realpathSync(this._scriptPath)}catch{u=this._scriptPath}l=w.resolve(w.dirname(u),l)}if(l){let u=n(l,s);if(!u&&!e._executableFile&&this._scriptPath){let m=w.basename(this._scriptPath,w.extname(this._scriptPath));m!==this._name&&(u=n(l,`${m}-${e._name}`))}s=u||s}r=o.includes(w.extname(s));let a;g.platform!=="win32"?r?(t.unshift(s),t=pe(g.execArgv).concat(t),a=z.spawn(g.argv[0],t,{stdio:"inherit"})):a=z.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=pe(g.execArgv).concat(t),a=z.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(m=>{g.on(m,()=>{a.killed===!1&&a.exitCode===null&&a.kill(m)})});let c=this._exitCallback;c?a.on("close",()=>{c(new K(g.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):a.on("close",g.exit.bind(g)),a.on("error",u=>{if(u.code==="ENOENT"){let m=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",C=`'${s}' does not exist
|
|
14
|
+
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
15
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
16
|
+
- ${m}`;throw new Error(C)}else if(u.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)g.exit(1);else{let m=new K(1,"commander.executeSubCommandAsync","(error)");m.nestedError=u,c(m)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let n;return n=this._chainOrCallSubCommandHook(n,o,"preSubcommand"),n=this._chainOrCall(n,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),n}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,n)=>{let s=o;if(o!==null&&r.parseArg){let l=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;s=this._callParseArg(r,o,n,l)}return s};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,o)=>{let n=r.defaultValue;r.variadic?o<this.args.length?(n=this.args.slice(o),r.parseArg&&(n=n.reduce((s,l)=>e(r,l,s),r.defaultValue))):n===void 0&&(n=[]):o<this.args.length&&(n=this.args[o],r.parseArg&&(n=e(r,n,r.defaultValue))),t[o]=n}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return this._getCommandAndAncestors().reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(s=>{o.push({hookedCommand:n,callback:s})})}),t==="postAction"&&o.reverse(),o.forEach(n=>{r=this._chainOrCall(r,()=>n.callback(n.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(n=>{o=this._chainOrCall(o,()=>n(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return ue(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),ue(this,r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(n,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(n))o(),this._processArguments(),this.parent.emit(n,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(n=>r.conflictsWith.includes(n.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],o=t,n=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;n.length;){let a=n.shift();if(a==="--"){o===r&&o.push(a),o.push(...n);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let u=n.shift();u===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,u)}else if(c.optional){let u=null;n.length>0&&!s(n[0])&&(u=n.shift()),this.emit(`option:${c.name()}`,u)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),n.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),u=this._findOption(a.slice(0,c));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,a.slice(c+1));continue}}if(s(a)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(a)){t.push(a),n.length>0&&r.push(...n);break}else if(a===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(a),n.length>0&&t.push(...n);break}else if(this._defaultCommandName){r.push(a),n.length>0&&r.push(...n);break}}if(this._passThroughOptions){o.push(a),n.length>0&&o.push(...n);break}o.push(a)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
17
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
18
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
19
|
+
`),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,n=r.code||"commander.error";this._exit(o,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Qe(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(m=>m.negate&&l===m.attributeName()),u=this.options.find(m=>!m.negate&&l===m.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:u||s},o=s=>{let l=r(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},n=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],n=this;do{let s=n.createHelp().visibleOptions(n).filter(l=>l.long).map(l=>l.long);o=o.concat(s),n=n.parent}while(n&&!n._enablePositionalOptions);t=ce(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(n=>{o.push(n.name()),n.alias()&&o.push(n.alias())}),t=ce(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this.options.push(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
20
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>Ke(r));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=w.basename(e,w.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(n=>n.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(n=>n.emit("afterAllHelp",r))}helpOption(e,t){if(typeof e=="boolean")return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;let r=Ze(this._helpFlags);return this._helpShortFlag=r.shortFlag,this._helpLongFlag=r.longFlag,this}help(e){this.outputHelp(e);let t=g.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
21
|
+
Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,n=>{let s;typeof t=="function"?s=t({error:n.error,command:n.command}):s=t,s&&n.write(`${s}
|
|
22
|
+
`)}),this}};function ue(i,e){i._hasHelpOption&&e.find(r=>r===i._helpLongFlag||r===i._helpShortFlag)&&(i.outputHelp(),i._exit(0,"commander.helpDisplayed","(outputHelp)"))}function pe(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?o=n[3]:r=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],r=n[3],o=n[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}he.Command=X});var ve=y((b,ge)=>{"use strict";var{Argument:et}=j(),{Command:me}=de(),{CommanderError:tt,InvalidArgumentError:fe}=O(),{Help:it}=U(),{Option:rt}=J();b=ge.exports=new me;b.program=b;b.Command=me;b.Option=rt;b.Argument=et;b.Help=it;b.CommanderError=tt;b.InvalidArgumentError=fe;b.InvalidOptionArgumentError=fe});var Ce=F(ve(),1),{program:A,createCommand:It,createArgument:Rt,createOption:Ht,CommanderError:Vt,InvalidArgumentError:Mt,InvalidOptionArgumentError:Bt,Command:Nt,Argument:Wt,Option:Ut,Help:qt}=Ce.default;var R=F(require("inquirer"),1);var be=(i=0)=>e=>`\x1B[${e+i}m`,$e=(i=0)=>e=>`\x1B[${38+i};5;${e}m`,xe=(i=0)=>(e,t,r)=>`\x1B[${38+i};2;${e};${t};${r}m`,v={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Jt=Object.keys(v.modifier),ot=Object.keys(v.color),nt=Object.keys(v.bgColor),zt=[...ot,...nt];function st(){let i=new Map;for(let[e,t]of Object.entries(v)){for(let[r,o]of Object.entries(t))v[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[r]=v[r],i.set(o[0],o[1]);Object.defineProperty(v,e,{value:t,enumerable:!1})}return Object.defineProperty(v,"codes",{value:i,enumerable:!1}),v.color.close="\x1B[39m",v.bgColor.close="\x1B[49m",v.color.ansi=be(),v.color.ansi256=$e(),v.color.ansi16m=xe(),v.bgColor.ansi=be(10),v.bgColor.ansi256=$e(10),v.bgColor.ansi16m=xe(10),Object.defineProperties(v,{rgbToAnsi256:{value(e,t,r){return e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;r.length===3&&(r=[...r].map(n=>n+n).join(""));let o=Number.parseInt(r,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:e=>v.rgbToAnsi256(...v.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,r,o;if(e>=232)t=((e-232)*10+8)/255,r=t,o=t;else{e-=16;let l=e%36;t=Math.floor(e/36)/5,r=Math.floor(l/6)/5,o=l%6/5}let n=Math.max(t,r,o)*2;if(n===0)return 30;let s=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(t));return n===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>v.ansi256ToAnsi(v.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>v.ansi256ToAnsi(v.hexToAnsi256(e)),enumerable:!1}}),v}var at=st(),$=at;var D=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){let i=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(i&&i.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),we=D!==0&&{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3},lt={stdout:we,stderr:we},_e=lt;function ye(i,e,t){let r=i.indexOf(e);if(r===-1)return i;let o=e.length,n=0,s="";do s+=i.slice(n,r)+e+t,n=r+o,r=i.indexOf(e,n);while(r!==-1);return s+=i.slice(n),s}function Ae(i,e,t,r){let o=0,n="";do{let s=i[r-1]==="\r";n+=i.slice(o,s?r-1:r)+e+(s?`\r
|
|
23
|
+
`:`
|
|
24
|
+
`)+t,o=r+1,r=i.indexOf(`
|
|
25
|
+
`,o)}while(r!==-1);return n+=i.slice(o),n}var{stdout:Se,stderr:Ee}=_e,Z=Symbol("GENERATOR"),S=Symbol("STYLER"),P=Symbol("IS_EMPTY"),Oe=["ansi","ansi","ansi256","ansi16m"],E=Object.create(null),ct=(i,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Se?Se.level:0;i.level=e.level===void 0?t:e.level};var ut=i=>{let e=(...t)=>t.join(" ");return ct(e,i),Object.setPrototypeOf(e,k.prototype),e};function k(i){return ut(i)}Object.setPrototypeOf(k.prototype,Function.prototype);for(let[i,e]of Object.entries($))E[i]={get(){let t=I(this,ee(e.open,e.close,this[S]),this[P]);return Object.defineProperty(this,i,{value:t}),t}};E.visible={get(){let i=I(this,this[S],!0);return Object.defineProperty(this,"visible",{value:i}),i}};var Q=(i,e,t,...r)=>i==="rgb"?e==="ansi16m"?$[t].ansi16m(...r):e==="ansi256"?$[t].ansi256($.rgbToAnsi256(...r)):$[t].ansi($.rgbToAnsi(...r)):i==="hex"?Q("rgb",e,t,...$.hexToRgb(...r)):$[t][i](...r),pt=["rgb","hex","ansi256"];for(let i of pt){E[i]={get(){let{level:t}=this;return function(...r){let o=ee(Q(i,Oe[t],"color",...r),$.color.close,this[S]);return I(this,o,this[P])}}};let e="bg"+i[0].toUpperCase()+i.slice(1);E[e]={get(){let{level:t}=this;return function(...r){let o=ee(Q(i,Oe[t],"bgColor",...r),$.bgColor.close,this[S]);return I(this,o,this[P])}}}}var ht=Object.defineProperties(()=>{},{...E,level:{enumerable:!0,get(){return this[Z].level},set(i){this[Z].level=i}}}),ee=(i,e,t)=>{let r,o;return t===void 0?(r=i,o=e):(r=t.openAll+i,o=e+t.closeAll),{open:i,close:e,openAll:r,closeAll:o,parent:t}},I=(i,e,t)=>{let r=(...o)=>dt(r,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(r,ht),r[Z]=i,r[S]=e,r[P]=t,r},dt=(i,e)=>{if(i.level<=0||!e)return i[P]?"":e;let t=i[S];if(t===void 0)return e;let{openAll:r,closeAll:o}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=ye(e,t.close,t.open),t=t.parent;let n=e.indexOf(`
|
|
26
|
+
`);return n!==-1&&(e=Ae(e,o,r,n)),r+e+o};Object.defineProperties(k.prototype,E);var mt=k(),ti=k({level:Ee?Ee.level:0});var p=mt;var d=F(require("fs-extra"),1),f=F(require("path"),1),ke="0.0.1";function Pe(i,e="functional"){return e==="fluixilement"?`/**
|
|
27
|
+
* @fileoverview ${i} component
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { html } from 'lit';
|
|
31
|
+
import { customElement } from 'lit/decorators.js';
|
|
32
|
+
import { FluixiElement } from '@fluixi/core';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ${i} component using FluixiElement pattern
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* \`\`\`html
|
|
39
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
40
|
+
* \`\`\`
|
|
41
|
+
*/
|
|
42
|
+
@customElement('${i.toLowerCase()}')
|
|
43
|
+
export class ${i} extends FluixiElement {
|
|
44
|
+
view() {
|
|
45
|
+
return html\`
|
|
46
|
+
<div class="${i.toLowerCase()}">
|
|
47
|
+
<h2>${i}</h2>
|
|
48
|
+
<p>Component created with Fluixi CLI (FluixiElement pattern)</p>
|
|
49
|
+
</div>
|
|
50
|
+
\`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default ${i};
|
|
55
|
+
`:e==="withsignals"?`/**
|
|
56
|
+
* @fileoverview ${i} component
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
import { html, LitElement } from 'lit';
|
|
60
|
+
import { customElement } from 'lit/decorators.js';
|
|
61
|
+
import { WithSignals } from '@fluixi/core';
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* ${i} component using WithSignals mixin
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* \`\`\`html
|
|
68
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
69
|
+
* \`\`\`
|
|
70
|
+
*/
|
|
71
|
+
@customElement('${i.toLowerCase()}')
|
|
72
|
+
export class ${i} extends WithSignals(LitElement) {
|
|
73
|
+
render() {
|
|
74
|
+
return html\`
|
|
75
|
+
<div class="${i.toLowerCase()}">
|
|
76
|
+
<h2>${i}</h2>
|
|
77
|
+
<p>Component created with Fluixi CLI (WithSignals pattern)</p>
|
|
78
|
+
</div>
|
|
79
|
+
\`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default ${i};
|
|
84
|
+
`:e==="controller"?`/**
|
|
85
|
+
* @fileoverview ${i} component
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
import { html, LitElement } from 'lit';
|
|
89
|
+
import { customElement } from 'lit/decorators.js';
|
|
90
|
+
import { SignalController } from '@fluixi/core';
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* ${i} component using manual controller pattern
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* \`\`\`html
|
|
97
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
98
|
+
* \`\`\`
|
|
99
|
+
*/
|
|
100
|
+
@customElement('${i.toLowerCase()}')
|
|
101
|
+
export class ${i} extends LitElement {
|
|
102
|
+
private signals = new SignalController(this);
|
|
103
|
+
|
|
104
|
+
render() {
|
|
105
|
+
return html\`
|
|
106
|
+
<div class="${i.toLowerCase()}">
|
|
107
|
+
<h2>${i}</h2>
|
|
108
|
+
<p>Component created with Fluixi CLI (Controller pattern)</p>
|
|
109
|
+
</div>
|
|
110
|
+
\`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default ${i};
|
|
115
|
+
`:e==="litelement"?`/**
|
|
116
|
+
* @fileoverview ${i} component
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
import { html, css, LitElement } from 'lit';
|
|
120
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* ${i} component using plain LitElement
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* \`\`\`html
|
|
127
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
128
|
+
* \`\`\`
|
|
129
|
+
*/
|
|
130
|
+
@customElement('${i.toLowerCase()}')
|
|
131
|
+
export class ${i} extends LitElement {
|
|
132
|
+
static styles = css\`
|
|
133
|
+
:host {
|
|
134
|
+
display: block;
|
|
135
|
+
padding: 1rem;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.${i.toLowerCase()} {
|
|
139
|
+
font-family: sans-serif;
|
|
140
|
+
}
|
|
141
|
+
\`;
|
|
142
|
+
|
|
143
|
+
render() {
|
|
144
|
+
return html\`
|
|
145
|
+
<div class="${i.toLowerCase()}">
|
|
146
|
+
<h2>${i}</h2>
|
|
147
|
+
<p>Component created with Fluixi CLI (LitElement pattern)</p>
|
|
148
|
+
</div>
|
|
149
|
+
\`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default ${i};
|
|
154
|
+
`:`/**
|
|
155
|
+
* @fileoverview ${i} component
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
import { html, Component, ComponentProps } from '@fluixi/core';
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Props for ${i} component
|
|
162
|
+
*/
|
|
163
|
+
export interface ${i}Props extends ComponentProps {
|
|
164
|
+
// Add your props here
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* ${i} component (functional pattern)
|
|
169
|
+
* @param {${i}Props} props - Component props
|
|
170
|
+
* @returns {TemplateResult} Rendered template
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* \`\`\`typescript
|
|
174
|
+
* const MyPage = () => {
|
|
175
|
+
* return html\`
|
|
176
|
+
* <div>
|
|
177
|
+
* \${${i}({})}
|
|
178
|
+
* </div>
|
|
179
|
+
* \`;
|
|
180
|
+
* };
|
|
181
|
+
* \`\`\`
|
|
182
|
+
*/
|
|
183
|
+
export const ${i}: Component<${i}Props> = (props) => {
|
|
184
|
+
return html\`
|
|
185
|
+
<div class="${i.toLowerCase()}">
|
|
186
|
+
<h2>${i}</h2>
|
|
187
|
+
<p>Component created with Fluixi CLI</p>
|
|
188
|
+
</div>
|
|
189
|
+
\`;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export default ${i};
|
|
193
|
+
`}function Fe(i,e="functional"){return e==="litelement"?`/**
|
|
194
|
+
* @fileoverview ${i} component with state
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
import { html, css, LitElement } from 'lit';
|
|
198
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* ${i} component with state using plain LitElement
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* \`\`\`html
|
|
205
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
206
|
+
* \`\`\`
|
|
207
|
+
*/
|
|
208
|
+
@customElement('${i.toLowerCase()}')
|
|
209
|
+
export class ${i} extends LitElement {
|
|
210
|
+
static styles = css\`
|
|
211
|
+
:host {
|
|
212
|
+
display: block;
|
|
213
|
+
padding: 1rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.${i.toLowerCase()} {
|
|
217
|
+
font-family: sans-serif;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.counter {
|
|
221
|
+
display: flex;
|
|
222
|
+
gap: 1rem;
|
|
223
|
+
align-items: center;
|
|
224
|
+
margin: 1rem 0;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
button {
|
|
228
|
+
padding: 0.5rem 1rem;
|
|
229
|
+
font-size: 1rem;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.count {
|
|
234
|
+
font-size: 2rem;
|
|
235
|
+
font-weight: bold;
|
|
236
|
+
min-width: 3rem;
|
|
237
|
+
text-align: center;
|
|
238
|
+
}
|
|
239
|
+
\`;
|
|
240
|
+
|
|
241
|
+
@state()
|
|
242
|
+
private count = 0;
|
|
243
|
+
|
|
244
|
+
@state()
|
|
245
|
+
private message = '';
|
|
246
|
+
|
|
247
|
+
connectedCallback() {
|
|
248
|
+
super.connectedCallback();
|
|
249
|
+
this.updateMessage();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private updateMessage() {
|
|
253
|
+
this.message = \`Count is \${this.count}\`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private increment() {
|
|
257
|
+
this.count++;
|
|
258
|
+
this.updateMessage();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private decrement() {
|
|
262
|
+
this.count--;
|
|
263
|
+
this.updateMessage();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private reset() {
|
|
267
|
+
this.count = 0;
|
|
268
|
+
this.updateMessage();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
render() {
|
|
272
|
+
return html\`
|
|
273
|
+
<div class="${i.toLowerCase()}">
|
|
274
|
+
<h2>${i} Counter</h2>
|
|
275
|
+
<p>\${this.message}</p>
|
|
276
|
+
<div class="counter">
|
|
277
|
+
<button @click=\${this.decrement}>-</button>
|
|
278
|
+
<span class="count">\${this.count}</span>
|
|
279
|
+
<button @click=\${this.increment}>+</button>
|
|
280
|
+
</div>
|
|
281
|
+
<button @click=\${this.reset}>Reset</button>
|
|
282
|
+
</div>
|
|
283
|
+
\`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export default ${i};
|
|
288
|
+
`:e==="fluixilement"?`/**
|
|
289
|
+
* @fileoverview ${i} component with reactive state
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
import { html } from 'lit';
|
|
293
|
+
import { customElement } from 'lit/decorators.js';
|
|
294
|
+
import { FluixiElement } from '@fluixi/core';
|
|
295
|
+
import { createSignal, createEffect } from '@fluixi/reactive';
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* ${i} component with reactive state using FluixiElement
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* \`\`\`html
|
|
302
|
+
* <${i.toLowerCase()} initial-value="10"></${i.toLowerCase()}>
|
|
303
|
+
* \`\`\`
|
|
304
|
+
*/
|
|
305
|
+
@customElement('${i.toLowerCase()}')
|
|
306
|
+
export class ${i} extends FluixiElement {
|
|
307
|
+
private count = createSignal(0);
|
|
308
|
+
private message = createSignal('');
|
|
309
|
+
|
|
310
|
+
connectedCallback() {
|
|
311
|
+
super.connectedCallback();
|
|
312
|
+
|
|
313
|
+
// Effect to update message when count changes
|
|
314
|
+
this.runInScope(() => {
|
|
315
|
+
createEffect(() => {
|
|
316
|
+
const current = this.count[0]();
|
|
317
|
+
this.message[1](\`Count is \${current}\`);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private increment = () => this.count[1](c => c + 1);
|
|
323
|
+
private decrement = () => this.count[1](c => c - 1);
|
|
324
|
+
private reset = () => this.count[1](0);
|
|
325
|
+
|
|
326
|
+
view() {
|
|
327
|
+
return html\`
|
|
328
|
+
<div class="${i.toLowerCase()}">
|
|
329
|
+
<h2>${i}</h2>
|
|
330
|
+
<div class="counter">
|
|
331
|
+
<p class="count">\${this.count[0]()}</p>
|
|
332
|
+
<p class="message">\${this.message[0]()}</p>
|
|
333
|
+
<div class="controls">
|
|
334
|
+
<button @click=\${this.decrement}>-</button>
|
|
335
|
+
<button @click=\${this.reset}>Reset</button>
|
|
336
|
+
<button @click=\${this.increment}>+</button>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
\`;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export default ${i};
|
|
345
|
+
`:e==="withsignals"?`/**
|
|
346
|
+
* @fileoverview ${i} component with reactive state
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
import { html, LitElement } from 'lit';
|
|
350
|
+
import { customElement } from 'lit/decorators.js';
|
|
351
|
+
import { WithSignals } from '@fluixi/core';
|
|
352
|
+
import { createSignal, createEffect } from '@fluixi/reactive';
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* ${i} component with reactive state using WithSignals mixin
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* \`\`\`html
|
|
359
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
360
|
+
* \`\`\`
|
|
361
|
+
*/
|
|
362
|
+
@customElement('${i.toLowerCase()}')
|
|
363
|
+
export class ${i} extends WithSignals(LitElement) {
|
|
364
|
+
private count = createSignal(0);
|
|
365
|
+
private message = createSignal('');
|
|
366
|
+
|
|
367
|
+
connectedCallback() {
|
|
368
|
+
super.connectedCallback();
|
|
369
|
+
|
|
370
|
+
// Effect to update message when count changes
|
|
371
|
+
this.runInReactiveScope(() => {
|
|
372
|
+
createEffect(() => {
|
|
373
|
+
const current = this.count[0]();
|
|
374
|
+
this.message[1](\`Count is \${current}\`);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
private increment = () => this.count[1](c => c + 1);
|
|
380
|
+
private decrement = () => this.count[1](c => c - 1);
|
|
381
|
+
private reset = () => this.count[1](0);
|
|
382
|
+
|
|
383
|
+
render() {
|
|
384
|
+
return html\`
|
|
385
|
+
<div class="${i.toLowerCase()}">
|
|
386
|
+
<h2>${i}</h2>
|
|
387
|
+
<div class="counter">
|
|
388
|
+
<p class="count">\${this.count[0]()}</p>
|
|
389
|
+
<p class="message">\${this.message[0]()}</p>
|
|
390
|
+
<div class="controls">
|
|
391
|
+
<button @click=\${this.decrement}>-</button>
|
|
392
|
+
<button @click=\${this.reset}>Reset</button>
|
|
393
|
+
<button @click=\${this.increment}>+</button>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
\`;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export default ${i};
|
|
402
|
+
`:e==="controller"?`/**
|
|
403
|
+
* @fileoverview ${i} component with reactive state
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
import { html, LitElement } from 'lit';
|
|
407
|
+
import { customElement } from 'lit/decorators.js';
|
|
408
|
+
import { SignalController } from '@fluixi/core';
|
|
409
|
+
import { createSignal, createEffect } from '@fluixi/reactive';
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* ${i} component with reactive state using manual controller
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* \`\`\`html
|
|
416
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
417
|
+
* \`\`\`
|
|
418
|
+
*/
|
|
419
|
+
@customElement('${i.toLowerCase()}')
|
|
420
|
+
export class ${i} extends LitElement {
|
|
421
|
+
private signals = new SignalController(this);
|
|
422
|
+
private count = createSignal(0);
|
|
423
|
+
private message = createSignal('');
|
|
424
|
+
|
|
425
|
+
connectedCallback() {
|
|
426
|
+
super.connectedCallback();
|
|
427
|
+
|
|
428
|
+
// Effect to update message when count changes
|
|
429
|
+
this.signals.runInScope(() => {
|
|
430
|
+
createEffect(() => {
|
|
431
|
+
const current = this.count[0]();
|
|
432
|
+
this.message[1](\`Count is \${current}\`);
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
private increment = () => this.count[1](c => c + 1);
|
|
438
|
+
private decrement = () => this.count[1](c => c - 1);
|
|
439
|
+
private reset = () => this.count[1](0);
|
|
440
|
+
|
|
441
|
+
render() {
|
|
442
|
+
return html\`
|
|
443
|
+
<div class="${i.toLowerCase()}">
|
|
444
|
+
<h2>${i}</h2>
|
|
445
|
+
<div class="counter">
|
|
446
|
+
<p class="count">\${this.count[0]()}</p>
|
|
447
|
+
<p class="message">\${this.message[0]()}</p>
|
|
448
|
+
<div class="controls">
|
|
449
|
+
<button @click=\${this.decrement}>-</button>
|
|
450
|
+
<button @click=\${this.reset}>Reset</button>
|
|
451
|
+
<button @click=\${this.increment}>+</button>
|
|
452
|
+
</div>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
\`;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export default ${i};
|
|
460
|
+
`:`/**
|
|
461
|
+
* @fileoverview ${i} component with reactive state
|
|
462
|
+
*/
|
|
463
|
+
|
|
464
|
+
import { html, Component, ComponentProps } from '@fluixi/core';
|
|
465
|
+
import { createSignal, createEffect } from '@fluixi/reactive';
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Props for ${i} component
|
|
469
|
+
*/
|
|
470
|
+
export interface ${i}Props extends ComponentProps {
|
|
471
|
+
initialValue?: number;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* ${i} component with reactive state management
|
|
476
|
+
* @param {${i}Props} props - Component props
|
|
477
|
+
* @returns {TemplateResult} Rendered template
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* \`\`\`typescript
|
|
481
|
+
* const MyPage = () => {
|
|
482
|
+
* return html\`
|
|
483
|
+
* <div>
|
|
484
|
+
* \${${i}({ initialValue: 10 })}
|
|
485
|
+
* </div>
|
|
486
|
+
* \`;
|
|
487
|
+
* };
|
|
488
|
+
* \`\`\`
|
|
489
|
+
*/
|
|
490
|
+
export const ${i}: Component<${i}Props> = (props) => {
|
|
491
|
+
const [count, setCount] = createSignal(props.initialValue ?? 0);
|
|
492
|
+
const [message, setMessage] = createSignal('');
|
|
493
|
+
|
|
494
|
+
// Effect to update message when count changes
|
|
495
|
+
createEffect(() => {
|
|
496
|
+
const current = count();
|
|
497
|
+
setMessage(\`Count is \${current}\`);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const increment = () => setCount(count() + 1);
|
|
501
|
+
const decrement = () => setCount(count() - 1);
|
|
502
|
+
const reset = () => setCount(props.initialValue ?? 0);
|
|
503
|
+
|
|
504
|
+
return html\`
|
|
505
|
+
<div class="${i.toLowerCase()}">
|
|
506
|
+
<h2>${i}</h2>
|
|
507
|
+
<div class="counter">
|
|
508
|
+
<p class="count">\${count()}</p>
|
|
509
|
+
<p class="message">\${message()}</p>
|
|
510
|
+
<div class="controls">
|
|
511
|
+
<button @click=\${decrement}>-</button>
|
|
512
|
+
<button @click=\${reset}>Reset</button>
|
|
513
|
+
<button @click=\${increment}>+</button>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
\`;
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
export default ${i};
|
|
521
|
+
`}function ft(i,e="functional"){return e==="litelement"?`/**
|
|
522
|
+
* @fileoverview ${i} component with async resource fetching
|
|
523
|
+
*/
|
|
524
|
+
|
|
525
|
+
import { html, css, LitElement } from 'lit';
|
|
526
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
527
|
+
|
|
528
|
+
interface ${i}Data {
|
|
529
|
+
id: string;
|
|
530
|
+
title: string;
|
|
531
|
+
description: string;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* ${i} component with resource fetching using LitElement
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* \`\`\`html
|
|
539
|
+
* <${i.toLowerCase()} resource-id="123"></${i.toLowerCase()}>
|
|
540
|
+
* \`\`\`
|
|
541
|
+
*/
|
|
542
|
+
@customElement('${i.toLowerCase()}')
|
|
543
|
+
export class ${i} extends LitElement {
|
|
544
|
+
static styles = css\`
|
|
545
|
+
:host {
|
|
546
|
+
display: block;
|
|
547
|
+
padding: 1rem;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.loading, .error {
|
|
551
|
+
padding: 1rem;
|
|
552
|
+
margin: 1rem 0;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.error {
|
|
556
|
+
color: #dc3545;
|
|
557
|
+
background: #f8d7da;
|
|
558
|
+
border: 1px solid #f5c6cb;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
button {
|
|
562
|
+
padding: 0.5rem 1rem;
|
|
563
|
+
cursor: pointer;
|
|
564
|
+
}
|
|
565
|
+
\`;
|
|
566
|
+
|
|
567
|
+
@state()
|
|
568
|
+
private data: ${i}Data | null = null;
|
|
569
|
+
|
|
570
|
+
@state()
|
|
571
|
+
private loading = false;
|
|
572
|
+
|
|
573
|
+
@state()
|
|
574
|
+
private error: Error | null = null;
|
|
575
|
+
|
|
576
|
+
connectedCallback() {
|
|
577
|
+
super.connectedCallback();
|
|
578
|
+
this.fetchData();
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
private async fetchData() {
|
|
582
|
+
this.loading = true;
|
|
583
|
+
this.error = null;
|
|
584
|
+
|
|
585
|
+
try {
|
|
586
|
+
const response = await fetch('https://jsonplaceholder.typicode.com/posts/1');
|
|
587
|
+
if (!response.ok) throw new Error('Failed to fetch');
|
|
588
|
+
const json = await response.json();
|
|
589
|
+
this.data = {
|
|
590
|
+
id: json.id,
|
|
591
|
+
title: json.title,
|
|
592
|
+
description: json.body,
|
|
593
|
+
};
|
|
594
|
+
} catch (err) {
|
|
595
|
+
this.error = err as Error;
|
|
596
|
+
} finally {
|
|
597
|
+
this.loading = false;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
render() {
|
|
602
|
+
return html\`
|
|
603
|
+
<div class="${i.toLowerCase()}">
|
|
604
|
+
<h2>${i}</h2>
|
|
605
|
+
|
|
606
|
+
\${this.loading ? html\`<div class="loading">Loading...</div>\` : ''}
|
|
607
|
+
|
|
608
|
+
\${this.error ? html\`
|
|
609
|
+
<div class="error">
|
|
610
|
+
<p>Error: \${this.error.message}</p>
|
|
611
|
+
<button @click=\${this.fetchData}>Retry</button>
|
|
612
|
+
</div>
|
|
613
|
+
\` : ''}
|
|
614
|
+
|
|
615
|
+
\${this.data && !this.loading && !this.error ? html\`
|
|
616
|
+
<div class="content">
|
|
617
|
+
<h3>\${this.data.title}</h3>
|
|
618
|
+
<p>\${this.data.description}</p>
|
|
619
|
+
<button @click=\${this.fetchData}>Refresh</button>
|
|
620
|
+
</div>
|
|
621
|
+
\` : ''}
|
|
622
|
+
</div>
|
|
623
|
+
\`;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export default ${i};
|
|
628
|
+
`:`/**
|
|
629
|
+
* @fileoverview ${i} component with async resource fetching
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
import { html, Component, ComponentProps, createResource, Show } from '@fluixi/core';
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Props for ${i} component
|
|
636
|
+
*/
|
|
637
|
+
export interface ${i}Props extends ComponentProps {
|
|
638
|
+
resourceId?: string | number;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Data type returned by the resource
|
|
643
|
+
*/
|
|
644
|
+
interface ${i}Data {
|
|
645
|
+
id: string | number;
|
|
646
|
+
title: string;
|
|
647
|
+
description: string;
|
|
648
|
+
// Add more fields as needed
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Fetches data for the component
|
|
653
|
+
* @param {string | number} id - Resource ID
|
|
654
|
+
* @returns {Promise<${i}Data>} Fetched data
|
|
655
|
+
*/
|
|
656
|
+
async function fetch${i}Data(id: string | number): Promise<${i}Data> {
|
|
657
|
+
// Replace with your actual API call
|
|
658
|
+
const response = await fetch(\`/api/${i.toLowerCase()}/\${id}\`);
|
|
659
|
+
|
|
660
|
+
if (!response.ok) {
|
|
661
|
+
throw new Error('Failed to fetch data');
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
return response.json();
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* ${i} component with async resource fetching
|
|
669
|
+
* @param {${i}Props} props - Component props
|
|
670
|
+
* @returns {TemplateResult} Rendered template
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* \`\`\`typescript
|
|
674
|
+
* const MyPage = () => {
|
|
675
|
+
* return html\`
|
|
676
|
+
* <div>
|
|
677
|
+
* \${${i}({ resourceId: '123' })}
|
|
678
|
+
* </div>
|
|
679
|
+
* \`;
|
|
680
|
+
* };
|
|
681
|
+
* \`\`\`
|
|
682
|
+
*/
|
|
683
|
+
export const ${i}: Component<${i}Props> = (props) => {
|
|
684
|
+
const [data, { refetch }] = createResource(
|
|
685
|
+
() => props.resourceId ?? '1',
|
|
686
|
+
fetch${i}Data,
|
|
687
|
+
{
|
|
688
|
+
onError: (error) => console.error('Failed to load ${i}:', error),
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
return html\`
|
|
693
|
+
<div class="${i.toLowerCase()}">
|
|
694
|
+
<h2>${i}</h2>
|
|
695
|
+
|
|
696
|
+
\${Show({
|
|
697
|
+
when: data.loading,
|
|
698
|
+
children: html\`<div class="loading">Loading...</div>\`,
|
|
699
|
+
})}
|
|
700
|
+
|
|
701
|
+
\${Show({
|
|
702
|
+
when: data.error,
|
|
703
|
+
children: html\`
|
|
704
|
+
<div class="error">
|
|
705
|
+
<p>Error: \${data.error?.message}</p>
|
|
706
|
+
<button @click=\${refetch}>Retry</button>
|
|
707
|
+
</div>
|
|
708
|
+
\`,
|
|
709
|
+
})}
|
|
710
|
+
|
|
711
|
+
\${Show({
|
|
712
|
+
when: () => data() && !data.loading && !data.error,
|
|
713
|
+
children: () => {
|
|
714
|
+
const resource = data()!;
|
|
715
|
+
return html\`
|
|
716
|
+
<div class="content">
|
|
717
|
+
<h3>\${resource.title}</h3>
|
|
718
|
+
<p>\${resource.description}</p>
|
|
719
|
+
<button @click=\${refetch}>Refresh</button>
|
|
720
|
+
</div>
|
|
721
|
+
\`;
|
|
722
|
+
},
|
|
723
|
+
})}
|
|
724
|
+
</div>
|
|
725
|
+
\`;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
export default ${i};
|
|
729
|
+
`}function gt(i,e="functional"){return e==="litelement"?`/**
|
|
730
|
+
* @fileoverview ${i} component with router integration
|
|
731
|
+
*/
|
|
732
|
+
|
|
733
|
+
import { html, css, LitElement } from 'lit';
|
|
734
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* ${i} component with router integration using LitElement
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* \`\`\`html
|
|
741
|
+
* <${i.toLowerCase()}></${i.toLowerCase()}>
|
|
742
|
+
* \`\`\`
|
|
743
|
+
*/
|
|
744
|
+
@customElement('${i.toLowerCase()}')
|
|
745
|
+
export class ${i} extends LitElement {
|
|
746
|
+
static styles = css\`
|
|
747
|
+
:host {
|
|
748
|
+
display: block;
|
|
749
|
+
padding: 1rem;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
nav {
|
|
753
|
+
display: flex;
|
|
754
|
+
gap: 1rem;
|
|
755
|
+
margin: 1rem 0;
|
|
756
|
+
padding: 1rem;
|
|
757
|
+
background: #f5f5f5;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
nav a {
|
|
761
|
+
padding: 0.5rem 1rem;
|
|
762
|
+
text-decoration: none;
|
|
763
|
+
color: #333;
|
|
764
|
+
background: white;
|
|
765
|
+
border-radius: 4px;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
nav a:hover {
|
|
769
|
+
background: #007bff;
|
|
770
|
+
color: white;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.route-info {
|
|
774
|
+
margin: 1rem 0;
|
|
775
|
+
padding: 1rem;
|
|
776
|
+
background: #e9ecef;
|
|
777
|
+
}
|
|
778
|
+
\`;
|
|
779
|
+
|
|
780
|
+
@state()
|
|
781
|
+
private currentPath = window.location.pathname;
|
|
782
|
+
|
|
783
|
+
connectedCallback() {
|
|
784
|
+
super.connectedCallback();
|
|
785
|
+
window.addEventListener('popstate', this.handlePopState);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
disconnectedCallback() {
|
|
789
|
+
super.disconnectedCallback();
|
|
790
|
+
window.removeEventListener('popstate', this.handlePopState);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
private handlePopState = () => {
|
|
794
|
+
this.currentPath = window.location.pathname;
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
private navigate(path: string) {
|
|
798
|
+
window.history.pushState({}, '', path);
|
|
799
|
+
this.currentPath = path;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
render() {
|
|
803
|
+
return html\`
|
|
804
|
+
<div class="${i.toLowerCase()}">
|
|
805
|
+
<h2>${i} - Router Component</h2>
|
|
806
|
+
|
|
807
|
+
<nav>
|
|
808
|
+
<a href="/" @click=\${(e: Event) => {
|
|
809
|
+
e.preventDefault();
|
|
810
|
+
this.navigate('/');
|
|
811
|
+
}}>Home</a>
|
|
812
|
+
<a href="/about" @click=\${(e: Event) => {
|
|
813
|
+
e.preventDefault();
|
|
814
|
+
this.navigate('/about');
|
|
815
|
+
}}>About</a>
|
|
816
|
+
<a href="/contact" @click=\${(e: Event) => {
|
|
817
|
+
e.preventDefault();
|
|
818
|
+
this.navigate('/contact');
|
|
819
|
+
}}>Contact</a>
|
|
820
|
+
</nav>
|
|
821
|
+
|
|
822
|
+
<div class="route-info">
|
|
823
|
+
<p><strong>Current Route:</strong> \${this.currentPath}</p>
|
|
824
|
+
<p>Router integration active</p>
|
|
825
|
+
</div>
|
|
826
|
+
|
|
827
|
+
<div class="content">
|
|
828
|
+
\${this.renderRoute()}
|
|
829
|
+
</div>
|
|
830
|
+
</div>
|
|
831
|
+
\`;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
private renderRoute() {
|
|
835
|
+
switch (this.currentPath) {
|
|
836
|
+
case '/':
|
|
837
|
+
return html\`<h3>Home Page</h3><p>Welcome to the home page!</p>\`;
|
|
838
|
+
case '/about':
|
|
839
|
+
return html\`<h3>About Page</h3><p>Learn more about us.</p>\`;
|
|
840
|
+
case '/contact':
|
|
841
|
+
return html\`<h3>Contact Page</h3><p>Get in touch with us.</p>\`;
|
|
842
|
+
default:
|
|
843
|
+
return html\`<h3>404 Not Found</h3><p>Page not found.</p>\`;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
export default ${i};
|
|
849
|
+
`:`/**
|
|
850
|
+
* @fileoverview ${i} component with router integration
|
|
851
|
+
*/
|
|
852
|
+
|
|
853
|
+
import {
|
|
854
|
+
html,
|
|
855
|
+
Component,
|
|
856
|
+
ComponentProps,
|
|
857
|
+
useParams,
|
|
858
|
+
useNavigate,
|
|
859
|
+
useLocation,
|
|
860
|
+
createSignal,
|
|
861
|
+
} from '@fluixi/core';
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Props for ${i} component
|
|
865
|
+
*/
|
|
866
|
+
export interface ${i}Props extends ComponentProps {
|
|
867
|
+
// Add your props here
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* ${i} component with router integration
|
|
872
|
+
* @param {${i}Props} props - Component props
|
|
873
|
+
* @returns {TemplateResult} Rendered template
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* \`\`\`typescript
|
|
877
|
+
* // In your routes configuration:
|
|
878
|
+
* const routes = [
|
|
879
|
+
* {
|
|
880
|
+
* path: '/${i.toLowerCase()}/:id',
|
|
881
|
+
* component: ${i}
|
|
882
|
+
* }
|
|
883
|
+
* ];
|
|
884
|
+
* \`\`\`
|
|
885
|
+
*/
|
|
886
|
+
export const ${i}: Component<${i}Props> = (props) => {
|
|
887
|
+
const params = useParams();
|
|
888
|
+
const navigate = useNavigate();
|
|
889
|
+
const location = useLocation();
|
|
890
|
+
|
|
891
|
+
const [selectedTab, setSelectedTab] = createSignal('overview');
|
|
892
|
+
|
|
893
|
+
const goBack = () => {
|
|
894
|
+
navigate(-1);
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
const navigateToTab = (tab: string) => {
|
|
898
|
+
setSelectedTab(tab);
|
|
899
|
+
navigate(\`\${location().pathname}?tab=\${tab}\`);
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
return html\`
|
|
903
|
+
<div class="${i.toLowerCase()}">
|
|
904
|
+
<div class="header">
|
|
905
|
+
<button @click=\${goBack}>← Back</button>
|
|
906
|
+
<h2>${i}</h2>
|
|
907
|
+
<p>ID: \${params.id || 'N/A'}</p>
|
|
908
|
+
</div>
|
|
909
|
+
|
|
910
|
+
<div class="tabs">
|
|
911
|
+
<button
|
|
912
|
+
class=\${selectedTab() === 'overview' ? 'active' : ''}
|
|
913
|
+
@click=\${() => navigateToTab('overview')}
|
|
914
|
+
>
|
|
915
|
+
Overview
|
|
916
|
+
</button>
|
|
917
|
+
<button
|
|
918
|
+
class=\${selectedTab() === 'details' ? 'active' : ''}
|
|
919
|
+
@click=\${() => navigateToTab('details')}
|
|
920
|
+
>
|
|
921
|
+
Details
|
|
922
|
+
</button>
|
|
923
|
+
<button
|
|
924
|
+
class=\${selectedTab() === 'settings' ? 'active' : ''}
|
|
925
|
+
@click=\${() => navigateToTab('settings')}
|
|
926
|
+
>
|
|
927
|
+
Settings
|
|
928
|
+
</button>
|
|
929
|
+
</div>
|
|
930
|
+
|
|
931
|
+
<div class="content">
|
|
932
|
+
<p>Current tab: \${selectedTab()}</p>
|
|
933
|
+
<p>Full path: \${location().pathname}</p>
|
|
934
|
+
</div>
|
|
935
|
+
</div>
|
|
936
|
+
\`;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
export default ${i};
|
|
940
|
+
`}function vt(i){return`/**
|
|
941
|
+
* @fileoverview ${i} - Full-featured component with state, resources, and router
|
|
942
|
+
*/
|
|
943
|
+
|
|
944
|
+
import {
|
|
945
|
+
html,
|
|
946
|
+
Component,
|
|
947
|
+
ComponentProps,
|
|
948
|
+
createSignal,
|
|
949
|
+
createEffect,
|
|
950
|
+
createResource,
|
|
951
|
+
createContext,
|
|
952
|
+
useContext,
|
|
953
|
+
useParams,
|
|
954
|
+
useNavigate,
|
|
955
|
+
Show,
|
|
956
|
+
For,
|
|
957
|
+
onMount,
|
|
958
|
+
onUnmount,
|
|
959
|
+
} from '@fluixi/core';
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Props for ${i} component
|
|
963
|
+
*/
|
|
964
|
+
export interface ${i}Props extends ComponentProps {
|
|
965
|
+
initialData?: ${i}Data[];
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Data interface for ${i}
|
|
970
|
+
*/
|
|
971
|
+
export interface ${i}Data {
|
|
972
|
+
id: string | number;
|
|
973
|
+
title: string;
|
|
974
|
+
description: string;
|
|
975
|
+
createdAt: string;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* ${i} context type
|
|
980
|
+
*/
|
|
981
|
+
interface ${i}Context {
|
|
982
|
+
selectedId: () => string | null;
|
|
983
|
+
selectItem: (id: string) => void;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Context for ${i} component
|
|
988
|
+
*/
|
|
989
|
+
const ${i}Context = createContext<${i}Context | null>(null, '${i}Context');
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Fetches items for ${i}
|
|
993
|
+
* @returns {Promise<${i}Data[]>} Fetched items
|
|
994
|
+
*/
|
|
995
|
+
async function fetch${i}Items(): Promise<${i}Data[]> {
|
|
996
|
+
// Replace with your actual API call
|
|
997
|
+
const response = await fetch('/api/${i.toLowerCase()}');
|
|
998
|
+
|
|
999
|
+
if (!response.ok) {
|
|
1000
|
+
throw new Error('Failed to fetch items');
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
return response.json();
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* ${i} component - Full-featured implementation
|
|
1008
|
+
* @param {${i}Props} props - Component props
|
|
1009
|
+
* @returns {TemplateResult} Rendered template
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* \`\`\`typescript
|
|
1013
|
+
* const App = () => {
|
|
1014
|
+
* return html\`
|
|
1015
|
+
* <div>
|
|
1016
|
+
* \${${i}({ initialData: [] })}
|
|
1017
|
+
* </div>
|
|
1018
|
+
* \`;
|
|
1019
|
+
* };
|
|
1020
|
+
* \`\`\`
|
|
1021
|
+
*/
|
|
1022
|
+
export const ${i}: Component<${i}Props> = (props) => {
|
|
1023
|
+
const params = useParams();
|
|
1024
|
+
const navigate = useNavigate();
|
|
1025
|
+
|
|
1026
|
+
// State
|
|
1027
|
+
const [selectedId, setSelectedId] = createSignal<string | null>(params.id || null);
|
|
1028
|
+
const [filter, setFilter] = createSignal('');
|
|
1029
|
+
const [sortBy, setSortBy] = createSignal<'title' | 'date'>('title');
|
|
1030
|
+
|
|
1031
|
+
// Resource
|
|
1032
|
+
const [items, { refetch, mutate }] = createResource(
|
|
1033
|
+
fetch${i}Items,
|
|
1034
|
+
{
|
|
1035
|
+
initialValue: props.initialData || [],
|
|
1036
|
+
onError: (error) => console.error('Failed to load items:', error),
|
|
1037
|
+
}
|
|
1038
|
+
);
|
|
1039
|
+
|
|
1040
|
+
// Computed filtered and sorted items
|
|
1041
|
+
const filteredItems = () => {
|
|
1042
|
+
const all = items() || [];
|
|
1043
|
+
const filterText = filter().toLowerCase();
|
|
1044
|
+
|
|
1045
|
+
let filtered = all.filter(item =>
|
|
1046
|
+
item.title.toLowerCase().includes(filterText) ||
|
|
1047
|
+
item.description.toLowerCase().includes(filterText)
|
|
1048
|
+
);
|
|
1049
|
+
|
|
1050
|
+
if (sortBy() === 'title') {
|
|
1051
|
+
filtered.sort((a, b) => a.title.localeCompare(b.title));
|
|
1052
|
+
} else {
|
|
1053
|
+
filtered.sort((a, b) =>
|
|
1054
|
+
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return filtered;
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
// Effects
|
|
1062
|
+
createEffect(() => {
|
|
1063
|
+
if (params.id) {
|
|
1064
|
+
setSelectedId(params.id);
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
// Lifecycle
|
|
1069
|
+
onMount(() => {
|
|
1070
|
+
console.log('${i} mounted');
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
onUnmount(() => {
|
|
1074
|
+
console.log('${i} unmounted');
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
// Handlers
|
|
1078
|
+
const selectItem = (id: string) => {
|
|
1079
|
+
setSelectedId(id);
|
|
1080
|
+
navigate(\`/${i.toLowerCase()}/\${id}\`);
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
const addNewItem = async () => {
|
|
1084
|
+
// Optimistic update
|
|
1085
|
+
const newItem: ${i}Data = {
|
|
1086
|
+
id: Date.now(),
|
|
1087
|
+
title: 'New Item',
|
|
1088
|
+
description: 'New item description',
|
|
1089
|
+
createdAt: new Date().toISOString(),
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
mutate(prev => [...(prev || []), newItem]);
|
|
1093
|
+
|
|
1094
|
+
// Sync with server
|
|
1095
|
+
try {
|
|
1096
|
+
await fetch('/api/${i.toLowerCase()}', {
|
|
1097
|
+
method: 'POST',
|
|
1098
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1099
|
+
body: JSON.stringify(newItem),
|
|
1100
|
+
});
|
|
1101
|
+
refetch();
|
|
1102
|
+
} catch (error) {
|
|
1103
|
+
console.error('Failed to add item:', error);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
const deleteItem = async (id: string | number) => {
|
|
1108
|
+
// Optimistic update
|
|
1109
|
+
mutate(prev => prev?.filter(item => item.id !== id));
|
|
1110
|
+
|
|
1111
|
+
// Sync with server
|
|
1112
|
+
try {
|
|
1113
|
+
await fetch(\`/api/${i.toLowerCase()}/\${id}\`, {
|
|
1114
|
+
method: 'DELETE',
|
|
1115
|
+
});
|
|
1116
|
+
} catch (error) {
|
|
1117
|
+
console.error('Failed to delete item:', error);
|
|
1118
|
+
refetch();
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
// Context value
|
|
1123
|
+
const contextValue: ${i}Context = {
|
|
1124
|
+
selectedId,
|
|
1125
|
+
selectItem,
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
return html\`
|
|
1129
|
+
<div class="${i.toLowerCase()}">
|
|
1130
|
+
<div class="header">
|
|
1131
|
+
<h2>${i}</h2>
|
|
1132
|
+
<button @click=\${refetch}>Refresh</button>
|
|
1133
|
+
<button @click=\${addNewItem}>Add New</button>
|
|
1134
|
+
</div>
|
|
1135
|
+
|
|
1136
|
+
<div class="controls">
|
|
1137
|
+
<input
|
|
1138
|
+
type="text"
|
|
1139
|
+
placeholder="Filter items..."
|
|
1140
|
+
.value=\${filter()}
|
|
1141
|
+
@input=\${(e: Event) => setFilter((e.target as HTMLInputElement).value)}
|
|
1142
|
+
/>
|
|
1143
|
+
<select
|
|
1144
|
+
.value=\${sortBy()}
|
|
1145
|
+
@change=\${(e: Event) => setSortBy((e.target as HTMLSelectElement).value as any)}
|
|
1146
|
+
>
|
|
1147
|
+
<option value="title">Sort by Title</option>
|
|
1148
|
+
<option value="date">Sort by Date</option>
|
|
1149
|
+
</select>
|
|
1150
|
+
</div>
|
|
1151
|
+
|
|
1152
|
+
\${Show({
|
|
1153
|
+
when: items.loading,
|
|
1154
|
+
children: html\`<div class="loading">Loading...</div>\`,
|
|
1155
|
+
})}
|
|
1156
|
+
|
|
1157
|
+
\${Show({
|
|
1158
|
+
when: items.error,
|
|
1159
|
+
children: html\`
|
|
1160
|
+
<div class="error">
|
|
1161
|
+
<p>Error: \${items.error?.message}</p>
|
|
1162
|
+
<button @click=\${refetch}>Retry</button>
|
|
1163
|
+
</div>
|
|
1164
|
+
\`,
|
|
1165
|
+
})}
|
|
1166
|
+
|
|
1167
|
+
\${Show({
|
|
1168
|
+
when: () => !items.loading && !items.error,
|
|
1169
|
+
children: html\`
|
|
1170
|
+
<div class="items">
|
|
1171
|
+
\${For({
|
|
1172
|
+
each: filteredItems,
|
|
1173
|
+
children: (item, index) => html\`
|
|
1174
|
+
<div
|
|
1175
|
+
class=\${selectedId() === String(item.id) ? 'item selected' : 'item'}
|
|
1176
|
+
@click=\${() => selectItem(String(item.id))}
|
|
1177
|
+
>
|
|
1178
|
+
<h3>\${item.title}</h3>
|
|
1179
|
+
<p>\${item.description}</p>
|
|
1180
|
+
<span class="date">\${new Date(item.createdAt).toLocaleDateString()}</span>
|
|
1181
|
+
<button
|
|
1182
|
+
@click=\${(e: Event) => {
|
|
1183
|
+
e.stopPropagation();
|
|
1184
|
+
deleteItem(item.id);
|
|
1185
|
+
}}
|
|
1186
|
+
>
|
|
1187
|
+
Delete
|
|
1188
|
+
</button>
|
|
1189
|
+
</div>
|
|
1190
|
+
\`,
|
|
1191
|
+
})}
|
|
1192
|
+
</div>
|
|
1193
|
+
\`,
|
|
1194
|
+
})}
|
|
1195
|
+
|
|
1196
|
+
\${Show({
|
|
1197
|
+
when: () => filteredItems().length === 0 && !items.loading,
|
|
1198
|
+
children: html\`<p class="empty">No items found</p>\`,
|
|
1199
|
+
})}
|
|
1200
|
+
</div>
|
|
1201
|
+
\`;
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
export default ${i};
|
|
1205
|
+
`}function te(i,e="basic"){let t=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return e==="basic"?`/** @jsx h */
|
|
1206
|
+
import { h, Fragment } from '@fluixi/core/jsx-runtime';
|
|
1207
|
+
import { createSignal } from '@fluixi/reactive/signal';
|
|
1208
|
+
import './${t}.css';
|
|
1209
|
+
|
|
1210
|
+
export interface ${i}Props {
|
|
1211
|
+
title?: string;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
export function ${i}({ title = 'Hello' }: ${i}Props) {
|
|
1215
|
+
return (
|
|
1216
|
+
<div class="${t}">
|
|
1217
|
+
<h1>{title}</h1>
|
|
1218
|
+
<p>This is a Fluixi JSX component</p>
|
|
1219
|
+
</div>
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
export default ${i};
|
|
1224
|
+
`:e==="with-state"?`/** @jsx h */
|
|
1225
|
+
import { h, Fragment } from '@fluixi/core/jsx-runtime';
|
|
1226
|
+
import { createSignal } from '@fluixi/reactive/signal';
|
|
1227
|
+
import './${t}.css';
|
|
1228
|
+
|
|
1229
|
+
export interface ${i}Props {
|
|
1230
|
+
initialCount?: number;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
export function ${i}({ initialCount = 0 }: ${i}Props) {
|
|
1234
|
+
const [count, setCount] = createSignal(initialCount);
|
|
1235
|
+
|
|
1236
|
+
const increment = () => setCount(count() + 1);
|
|
1237
|
+
const decrement = () => setCount(count() - 1);
|
|
1238
|
+
const reset = () => setCount(initialCount);
|
|
1239
|
+
|
|
1240
|
+
return (
|
|
1241
|
+
<div class="${t}">
|
|
1242
|
+
<h2>Counter Component</h2>
|
|
1243
|
+
<div class="counter">
|
|
1244
|
+
<button onClick={decrement}>-</button>
|
|
1245
|
+
<span class="count">{count()}</span>
|
|
1246
|
+
<button onClick={increment}>+</button>
|
|
1247
|
+
</div>
|
|
1248
|
+
<button onClick={reset}>Reset</button>
|
|
1249
|
+
</div>
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
export default ${i};
|
|
1254
|
+
`:te(i,"basic")}function ie(i,e="basic"){let t=i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return e==="basic"?`import React from 'react';
|
|
1255
|
+
import { useSignal } from '@fluixi/core/react-bridge';
|
|
1256
|
+
import './${t}.css';
|
|
1257
|
+
|
|
1258
|
+
export interface ${i}Props {
|
|
1259
|
+
title?: string;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
export function ${i}({ title = 'Hello' }: ${i}Props) {
|
|
1263
|
+
return (
|
|
1264
|
+
<div className="${t}">
|
|
1265
|
+
<h1>{title}</h1>
|
|
1266
|
+
<p>This is a Fluixi React Bridge component</p>
|
|
1267
|
+
</div>
|
|
1268
|
+
);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
export default ${i};
|
|
1272
|
+
`:e==="with-state"?`import React from 'react';
|
|
1273
|
+
import { useSignal, useFluixiEffect } from '@fluixi/core/react-bridge';
|
|
1274
|
+
import './${t}.css';
|
|
1275
|
+
|
|
1276
|
+
export interface ${i}Props {
|
|
1277
|
+
initialCount?: number;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
export function ${i}({ initialCount = 0 }: ${i}Props) {
|
|
1281
|
+
const [count, setCount] = useSignal(initialCount);
|
|
1282
|
+
|
|
1283
|
+
useFluixiEffect(() => {
|
|
1284
|
+
console.log('Count changed:', count());
|
|
1285
|
+
});
|
|
1286
|
+
|
|
1287
|
+
const increment = () => setCount(count() + 1);
|
|
1288
|
+
const decrement = () => setCount(count() - 1);
|
|
1289
|
+
const reset = () => setCount(initialCount);
|
|
1290
|
+
|
|
1291
|
+
return (
|
|
1292
|
+
<div className="${t}">
|
|
1293
|
+
<h2>Counter Component</h2>
|
|
1294
|
+
<div className="counter">
|
|
1295
|
+
<button onClick={decrement}>-</button>
|
|
1296
|
+
<span className="count">{count()}</span>
|
|
1297
|
+
<button onClick={increment}>+</button>
|
|
1298
|
+
</div>
|
|
1299
|
+
<button onClick={reset}>Reset</button>
|
|
1300
|
+
</div>
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
export default ${i};
|
|
1305
|
+
`:ie(i,"basic")}async function Le(i,e,t="basic",r="functional",o="lit-html"){let n=f.default.dirname(i);await d.default.mkdir(n,{recursive:!0});let s;if(o==="jsx")s=te(e,t);else if(o==="react-bridge")s=ie(e,t);else switch(t){case"basic":s=Pe(e,r);break;case"with-state":s=Fe(e,r);break;case"with-resource":s=ft(e,r);break;case"with-router":s=gt(e,r);break;case"full":s=vt(e);break;default:s=Pe(e,r)}await d.default.writeFile(i,s,"utf-8");let l=i.replace(/\.tsx?$/,".spec.ts"),a=Ct(e);await d.default.writeFile(l,a,"utf-8");let c=i.replace(/\.tsx?$/,".css"),u=je(e);await d.default.writeFile(c,u,"utf-8"),console.log(p.green(`✓ Created component: ${e}`)),console.log(p.gray(` - ${i}`)),console.log(p.gray(` - ${l}`)),console.log(p.gray(` - ${c}`))}function Ct(i){return`/**
|
|
1306
|
+
* @fileoverview Tests for ${i} component
|
|
1307
|
+
*/
|
|
1308
|
+
|
|
1309
|
+
import { describe, it, expect } from 'vitest';
|
|
1310
|
+
import { render } from '@fluixi/core';
|
|
1311
|
+
import { ${i} } from './${i}';
|
|
1312
|
+
|
|
1313
|
+
describe('${i}', () => {
|
|
1314
|
+
it('should render successfully', () => {
|
|
1315
|
+
const container = document.createElement('div');
|
|
1316
|
+
const dispose = render(() => ${i}({}), container);
|
|
1317
|
+
|
|
1318
|
+
expect(container.querySelector('.${i.toLowerCase()}')).toBeTruthy();
|
|
1319
|
+
|
|
1320
|
+
dispose();
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
it('should display component title', () => {
|
|
1324
|
+
const container = document.createElement('div');
|
|
1325
|
+
const dispose = render(() => ${i}({}), container);
|
|
1326
|
+
|
|
1327
|
+
const heading = container.querySelector('h2');
|
|
1328
|
+
expect(heading?.textContent).toBe('${i}');
|
|
1329
|
+
|
|
1330
|
+
dispose();
|
|
1331
|
+
});
|
|
1332
|
+
});
|
|
1333
|
+
`}function je(i){return`.${i.toLowerCase()} {
|
|
1334
|
+
padding: 1rem;
|
|
1335
|
+
border: 1px solid #e0e0e0;
|
|
1336
|
+
border-radius: 8px;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
.${i.toLowerCase()} h2 {
|
|
1340
|
+
margin: 0 0 1rem 0;
|
|
1341
|
+
color: #333;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
.${i.toLowerCase()} p {
|
|
1345
|
+
margin: 0.5rem 0;
|
|
1346
|
+
color: #666;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
.${i.toLowerCase()} button {
|
|
1350
|
+
padding: 0.5rem 1rem;
|
|
1351
|
+
margin: 0.25rem;
|
|
1352
|
+
border: none;
|
|
1353
|
+
border-radius: 4px;
|
|
1354
|
+
background: #007bff;
|
|
1355
|
+
color: white;
|
|
1356
|
+
cursor: pointer;
|
|
1357
|
+
font-size: 0.875rem;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
.${i.toLowerCase()} button:hover {
|
|
1361
|
+
background: #0056b3;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
.${i.toLowerCase()} button:active {
|
|
1365
|
+
transform: scale(0.98);
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
.${i.toLowerCase()} .loading,
|
|
1369
|
+
.${i.toLowerCase()} .error,
|
|
1370
|
+
.${i.toLowerCase()} .empty {
|
|
1371
|
+
padding: 2rem;
|
|
1372
|
+
text-align: center;
|
|
1373
|
+
color: #666;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
.${i.toLowerCase()} .error {
|
|
1377
|
+
color: #dc3545;
|
|
1378
|
+
}
|
|
1379
|
+
`}async function bt(){let i=await R.default.prompt([{type:"input",name:"name",message:"Component name:",validate:t=>t?/^[A-Z][a-zA-Z0-9]*$/.test(t)?!0:"Component name must start with uppercase letter":"Component name is required"},{type:"list",name:"mode",message:"Component mode:",choices:[{name:"Lit-HTML (Recommended - native Fluixi with lit-html)",value:"lit-html"},{name:"JSX (Native JSX runtime for Fluixi)",value:"jsx"},{name:"React Bridge (React compatibility with Fluixi signals)",value:"react-bridge"}],default:"lit-html"},{type:"list",name:"pattern",message:"Component pattern:",choices:[{name:"FluixiElement (Recommended - extends FluixiElement base class)",value:"fluixilement"},{name:"LitElement (Plain LitElement class component)",value:"litelement"},{name:"WithSignals (Mixin - adds signals to LitElement)",value:"withsignals"},{name:"Controller (Manual - uses SignalController)",value:"controller"},{name:"Functional (Function-based component)",value:"functional"}],default:"fluixilement",when:t=>t.mode==="lit-html"},{type:"list",name:"type",message:"Component features:",choices:[{name:"Basic (Simple component)",value:"basic"},{name:"With State (Reactive state management)",value:"with-state"},{name:"With Resource (Async data fetching)",value:"with-resource"},{name:"With Router (Router integration)",value:"with-router"},{name:"Full (All features)",value:"full"}]},{type:"input",name:"path",message:"Component path (relative to src):",default:t=>{let r=t.mode==="lit-html"?"ts":"tsx";return`components/${t.name}/${t.name}.${r}`}}]),e=f.default.join(process.cwd(),"src",i.path);await Le(e,i.name,i.type,i.pattern||"functional",i.mode||"lit-html")}async function Te(i,e,t="lit-html",r={}){let o=f.default.join(process.cwd(),i);console.log(p.blue(`
|
|
1380
|
+
Creating Fluixi project: ${i}`)),console.log(p.gray(`Template: ${e}
|
|
1381
|
+
`)),await d.default.ensureDir(o),await d.default.ensureDir(f.default.join(o,"src")),await d.default.ensureDir(f.default.join(o,"src/components")),await d.default.ensureDir(f.default.join(o,"src/pages")),await d.default.ensureDir(f.default.join(o,"src/styles")),await d.default.ensureDir(f.default.join(o,"public"));let n={name:i,version:"0.0.1",type:"module",scripts:{dev:"vite",build:"tsc && vite build",preview:"vite preview",test:"vitest"},dependencies:{"@fluixi/core":"workspace:*","@fluixi/reactive":"workspace:*",lit:"^3.3.1"},devDependencies:{typescript:"^5.0.0",vite:"^5.0.0",vitest:"^1.0.0"}};t==="react-bridge"&&(n.dependencies.react="^18.0.0",n.dependencies["react-dom"]="^18.0.0",n.devDependencies["@types/react"]="^18.0.0",n.devDependencies["@types/react-dom"]="^18.0.0"),r.cssPreprocessor==="scss"?n.devDependencies.sass="^1.69.0":r.cssPreprocessor==="less"?n.devDependencies.less="^4.2.0":r.cssPreprocessor==="postcss"&&(n.devDependencies.postcss="^8.4.31",n.devDependencies.autoprefixer="^10.4.16"),r.includeESLint&&(n.devDependencies.eslint="^8.53.0",n.devDependencies["@typescript-eslint/eslint-plugin"]="^6.10.0",n.devDependencies["@typescript-eslint/parser"]="^6.10.0",n.scripts.lint="eslint src --ext ts,tsx"),r.includePrettier&&(n.devDependencies.prettier="^3.1.0",n.scripts.format='prettier --write "src/**/*.{ts,tsx,css}"'),r.includeSSR&&(n.dependencies["@lit-labs/ssr"]="^3.3.1",n.dependencies["@lit-labs/ssr-client"]="^1.1.7"),r.author&&(n.author=r.author),r.description&&(n.description=r.description),r.license&&(n.license=r.license),await d.default.writeJSON(f.default.join(o,"package.json"),n,{spaces:2});let s={compilerOptions:{target:"ES2020",module:"ESNext",lib:["ES2020","DOM","DOM.Iterable"],moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,resolveJsonModule:!0},include:["src"]};t==="jsx"?(s.compilerOptions.jsx="react-jsx",s.compilerOptions.jsxImportSource="@fluixi/core/jsx-runtime"):t==="react-bridge"?s.compilerOptions.jsx="react-jsx":s.compilerOptions.jsx="preserve",await d.default.writeJSON(f.default.join(o,"tsconfig.json"),s,{spaces:2}),await d.default.writeFile(f.default.join(o,"vite.config.ts"),`import { defineConfig } from 'vite';
|
|
1382
|
+
|
|
1383
|
+
export default defineConfig({
|
|
1384
|
+
server: {
|
|
1385
|
+
port: 3000,
|
|
1386
|
+
},
|
|
1387
|
+
build: {
|
|
1388
|
+
target: 'esnext',
|
|
1389
|
+
},
|
|
1390
|
+
});
|
|
1391
|
+
`);let a=`<!DOCTYPE html>
|
|
1392
|
+
<html lang="en">
|
|
1393
|
+
<head>
|
|
1394
|
+
<meta charset="UTF-8" />
|
|
1395
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1396
|
+
<title>${i}</title>
|
|
1397
|
+
</head>
|
|
1398
|
+
<body>
|
|
1399
|
+
<div id="app"></div>
|
|
1400
|
+
<script type="module" src="/src/main.ts"><\/script>
|
|
1401
|
+
</body>
|
|
1402
|
+
</html>
|
|
1403
|
+
`;await d.default.writeFile(f.default.join(o,"index.html"),a);let c,u=t==="lit-html"?"ts":"tsx";t==="jsx"?c=`import { render } from '@fluixi/core';
|
|
1404
|
+
import { App } from './App';
|
|
1405
|
+
import './styles/main.css';
|
|
1406
|
+
|
|
1407
|
+
const root = document.getElementById('app');
|
|
1408
|
+
|
|
1409
|
+
if (root) {
|
|
1410
|
+
render(App, root);
|
|
1411
|
+
}
|
|
1412
|
+
`:t==="react-bridge"?c=`import React from 'react';
|
|
1413
|
+
import { createRoot } from 'react-dom/client';
|
|
1414
|
+
import { App } from './App';
|
|
1415
|
+
import './styles/main.css';
|
|
1416
|
+
|
|
1417
|
+
const root = document.getElementById('app');
|
|
1418
|
+
|
|
1419
|
+
if (root) {
|
|
1420
|
+
const reactRoot = createRoot(root);
|
|
1421
|
+
reactRoot.render(<App />);
|
|
1422
|
+
}
|
|
1423
|
+
`:c=`import { render, html } from '@fluixi/core';
|
|
1424
|
+
import { App } from './App';
|
|
1425
|
+
import './styles/main.css';
|
|
1426
|
+
|
|
1427
|
+
const root = document.getElementById('app');
|
|
1428
|
+
|
|
1429
|
+
if (root) {
|
|
1430
|
+
render(App, root);
|
|
1431
|
+
}
|
|
1432
|
+
`,await d.default.writeFile(f.default.join(o,"src/main.ts"),c);let m=$t(e,t);if(await d.default.writeFile(f.default.join(o,`src/App.${u}`),m),r.exampleComponents&&r.exampleComponents.length>0){console.log(p.blue(`
|
|
1433
|
+
Generating example components...`));for(let h of r.exampleComponents)await _t(o,h,t)}if(r.examplePages&&r.examplePages.length>0){console.log(p.blue(`
|
|
1434
|
+
Generating example pages...`));for(let h of r.examplePages)await yt(o,h,t)}if(r.includeESLint){let h={parser:"@typescript-eslint/parser",extends:["eslint:recommended","plugin:@typescript-eslint/recommended"],parserOptions:{ecmaVersion:2020,sourceType:"module"},rules:{}};await d.default.writeJSON(f.default.join(o,".eslintrc.json"),h,{spaces:2})}if(r.includePrettier){let h={semi:!0,trailingComma:"es5",singleQuote:!0,printWidth:80,tabWidth:2};await d.default.writeJSON(f.default.join(o,".prettierrc.json"),h,{spaces:2})}await d.default.writeFile(f.default.join(o,"src/styles/main.css"),`* {
|
|
1435
|
+
margin: 0;
|
|
1436
|
+
padding: 0;
|
|
1437
|
+
box-sizing: border-box;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
body {
|
|
1441
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
1442
|
+
line-height: 1.6;
|
|
1443
|
+
color: #333;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
#app {
|
|
1447
|
+
max-width: 1200px;
|
|
1448
|
+
margin: 0 auto;
|
|
1449
|
+
padding: 2rem;
|
|
1450
|
+
}
|
|
1451
|
+
`);let x=`# ${i}
|
|
1452
|
+
|
|
1453
|
+
A Fluixi application.
|
|
1454
|
+
|
|
1455
|
+
## Getting Started
|
|
1456
|
+
|
|
1457
|
+
\`\`\`bash
|
|
1458
|
+
# Install dependencies
|
|
1459
|
+
npm install
|
|
1460
|
+
|
|
1461
|
+
# Start development server
|
|
1462
|
+
npm run dev
|
|
1463
|
+
|
|
1464
|
+
# Build for production
|
|
1465
|
+
npm run build
|
|
1466
|
+
|
|
1467
|
+
# Run tests
|
|
1468
|
+
npm test
|
|
1469
|
+
\`\`\`
|
|
1470
|
+
|
|
1471
|
+
## Project Structure
|
|
1472
|
+
|
|
1473
|
+
\`\`\`
|
|
1474
|
+
${i}/
|
|
1475
|
+
├── src/
|
|
1476
|
+
│ ├── components/ # Reusable components
|
|
1477
|
+
│ ├── pages/ # Page components
|
|
1478
|
+
│ ├── styles/ # Global styles
|
|
1479
|
+
│ ├── App.ts # Root component
|
|
1480
|
+
│ └── main.ts # Application entry point
|
|
1481
|
+
├── public/ # Static assets
|
|
1482
|
+
├── index.html # HTML template
|
|
1483
|
+
├── package.json
|
|
1484
|
+
├── tsconfig.json
|
|
1485
|
+
└── vite.config.ts
|
|
1486
|
+
\`\`\`
|
|
1487
|
+
|
|
1488
|
+
## Learn More
|
|
1489
|
+
|
|
1490
|
+
- [Fluixi Documentation](https://github.com/your-org/fluixi)
|
|
1491
|
+
- [Lit Documentation](https://lit.dev)
|
|
1492
|
+
`;await d.default.writeFile(f.default.join(o,"README.md"),x),console.log(p.green(`
|
|
1493
|
+
✓ Project created successfully!
|
|
1494
|
+
`)),console.log(p.blue("Next steps:")),console.log(p.gray(` cd ${i}`)),console.log(p.gray(" npm install")),console.log(p.gray(` npm run dev
|
|
1495
|
+
`))}function $t(i,e="lit-html"){return e==="jsx"?xt(i):e==="react-bridge"?wt(i):i==="full"?`import { html, createRouter, Router, Link, Component } from '@fluixi/core';
|
|
1496
|
+
|
|
1497
|
+
const Home = () => html\`
|
|
1498
|
+
<div>
|
|
1499
|
+
<h1>Home Page</h1>
|
|
1500
|
+
<p>Welcome to your Fluixi application!</p>
|
|
1501
|
+
</div>
|
|
1502
|
+
\`;
|
|
1503
|
+
|
|
1504
|
+
const About = () => html\`
|
|
1505
|
+
<div>
|
|
1506
|
+
<h1>About Page</h1>
|
|
1507
|
+
<p>This is a full-featured Fluixi application.</p>
|
|
1508
|
+
</div>
|
|
1509
|
+
\`;
|
|
1510
|
+
|
|
1511
|
+
const routes = [
|
|
1512
|
+
{ path: '/', component: Home },
|
|
1513
|
+
{ path: '/about', component: About },
|
|
1514
|
+
];
|
|
1515
|
+
|
|
1516
|
+
export const App: Component = () => {
|
|
1517
|
+
const router = createRouter(routes);
|
|
1518
|
+
|
|
1519
|
+
return Router({
|
|
1520
|
+
router,
|
|
1521
|
+
children: html\`
|
|
1522
|
+
<div class="app">
|
|
1523
|
+
<nav>
|
|
1524
|
+
\${Link({ href: '/', children: 'Home' })}
|
|
1525
|
+
\${Link({ href: '/about', children: 'About' })}
|
|
1526
|
+
</nav>
|
|
1527
|
+
<main id="content"></main>
|
|
1528
|
+
</div>
|
|
1529
|
+
\`,
|
|
1530
|
+
});
|
|
1531
|
+
};
|
|
1532
|
+
`:`import { html, createSignal, Component } from '@fluixi/core';
|
|
1533
|
+
|
|
1534
|
+
export const App: Component = () => {
|
|
1535
|
+
const [count, setCount] = createSignal(0);
|
|
1536
|
+
|
|
1537
|
+
return html\`
|
|
1538
|
+
<div class="app">
|
|
1539
|
+
<h1>Welcome to Fluixi</h1>
|
|
1540
|
+
<p>A reactive framework for lit-html</p>
|
|
1541
|
+
<div class="counter">
|
|
1542
|
+
<p>Count: \${count()}</p>
|
|
1543
|
+
<button @click=\${() => setCount(count() + 1)}>Increment</button>
|
|
1544
|
+
</div>
|
|
1545
|
+
</div>
|
|
1546
|
+
\`;
|
|
1547
|
+
};
|
|
1548
|
+
export default App;
|
|
1549
|
+
`}function xt(i){return`/** @jsx h */
|
|
1550
|
+
import { h, Fragment } from '@fluixi/core/jsx-runtime';
|
|
1551
|
+
import { createSignal } from '@fluixi/reactive/signal';
|
|
1552
|
+
import './styles/main.css';
|
|
1553
|
+
|
|
1554
|
+
export function App() {
|
|
1555
|
+
const [count, setCount] = createSignal(0);
|
|
1556
|
+
|
|
1557
|
+
return (
|
|
1558
|
+
<div class="app">
|
|
1559
|
+
<header>
|
|
1560
|
+
<h1>Welcome to Fluixi</h1>
|
|
1561
|
+
<p>A reactive framework powered by signals</p>
|
|
1562
|
+
</header>
|
|
1563
|
+
|
|
1564
|
+
<main>
|
|
1565
|
+
<div class="counter">
|
|
1566
|
+
<h2>Counter Example</h2>
|
|
1567
|
+
<div class="controls">
|
|
1568
|
+
<button onClick={() => setCount(count() - 1)}>-</button>
|
|
1569
|
+
<span class="count">{count()}</span>
|
|
1570
|
+
<button onClick={() => setCount(count() + 1)}>+</button>
|
|
1571
|
+
</div>
|
|
1572
|
+
</div>
|
|
1573
|
+
</main>
|
|
1574
|
+
|
|
1575
|
+
<footer>
|
|
1576
|
+
<p>Built with Fluixi JSX</p>
|
|
1577
|
+
</footer>
|
|
1578
|
+
</div>
|
|
1579
|
+
);
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
export default App;
|
|
1583
|
+
`}function wt(i){return`import React from 'react';
|
|
1584
|
+
import { useSignal, useFluixiEffect } from '@fluixi/core/react-bridge';
|
|
1585
|
+
import './styles/main.css';
|
|
1586
|
+
|
|
1587
|
+
export function App() {
|
|
1588
|
+
const [count, setCount] = useSignal(0);
|
|
1589
|
+
|
|
1590
|
+
useFluixiEffect(() => {
|
|
1591
|
+
console.log('Count changed:', count());
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
return (
|
|
1595
|
+
<div className="app">
|
|
1596
|
+
<header>
|
|
1597
|
+
<h1>Welcome to Fluixi</h1>
|
|
1598
|
+
<p>A reactive framework with React compatibility</p>
|
|
1599
|
+
</header>
|
|
1600
|
+
|
|
1601
|
+
<main>
|
|
1602
|
+
<div className="counter">
|
|
1603
|
+
<h2>Counter Example</h2>
|
|
1604
|
+
<div className="controls">
|
|
1605
|
+
<button onClick={() => setCount(count() - 1)}>-</button>
|
|
1606
|
+
<span className="count">{count()}</span>
|
|
1607
|
+
<button onClick={() => setCount(count() + 1)}>+</button>
|
|
1608
|
+
</div>
|
|
1609
|
+
</div>
|
|
1610
|
+
</main>
|
|
1611
|
+
|
|
1612
|
+
<footer>
|
|
1613
|
+
<p>Built with Fluixi React Bridge</p>
|
|
1614
|
+
</footer>
|
|
1615
|
+
</div>
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
export default App;
|
|
1620
|
+
`}async function _t(i,e,t){let r=f.default.join(i,"src/components",e);await d.default.ensureDir(r);let o=t==="lit-html"?"ts":"tsx",n=f.default.join(r,`${e}.${o}`),s="";e==="counter"?s=t==="jsx"?te("Counter","with-state"):t==="react-bridge"?ie("Counter","with-state"):Fe("Counter","functional"):e==="todolist"?s=At(t):e==="usercard"?s=St(t):e==="datafetcher"&&(s=Et(t)),await d.default.writeFile(n,s);let l=f.default.join(r,`${e}.css`);await d.default.writeFile(l,je(e)),console.log(p.gray(` ✓ ${e} component created`))}async function yt(i,e,t){let r=f.default.join(i,"src/pages",e);await d.default.ensureDir(r);let o=t==="lit-html"?"ts":"tsx",n=f.default.join(r,`${e}.${o}`),s="";t==="jsx"?s=`/** @jsx h */
|
|
1621
|
+
import { h } from '@fluixi/core/jsx-runtime';
|
|
1622
|
+
import './${e}.css';
|
|
1623
|
+
|
|
1624
|
+
export function ${e.charAt(0).toUpperCase()+e.slice(1)}Page() {
|
|
1625
|
+
return (
|
|
1626
|
+
<div class="${e}-page">
|
|
1627
|
+
<h1>${e.charAt(0).toUpperCase()+e.slice(1)} Page</h1>
|
|
1628
|
+
<p>Welcome to the ${e} page.</p>
|
|
1629
|
+
</div>
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
export default ${e.charAt(0).toUpperCase()+e.slice(1)}Page;
|
|
1634
|
+
`:t==="react-bridge"?s=`import React from 'react';
|
|
1635
|
+
import './${e}.css';
|
|
1636
|
+
|
|
1637
|
+
export function ${e.charAt(0).toUpperCase()+e.slice(1)}Page() {
|
|
1638
|
+
return (
|
|
1639
|
+
<div className="${e}-page">
|
|
1640
|
+
<h1>${e.charAt(0).toUpperCase()+e.slice(1)} Page</h1>
|
|
1641
|
+
<p>Welcome to the ${e} page.</p>
|
|
1642
|
+
</div>
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
export default ${e.charAt(0).toUpperCase()+e.slice(1)}Page;
|
|
1647
|
+
`:s=`import { html } from 'lit';
|
|
1648
|
+
import './${e}.css';
|
|
1649
|
+
|
|
1650
|
+
export const ${e.charAt(0).toUpperCase()+e.slice(1)}Page = () => html\`
|
|
1651
|
+
<div class="${e}-page">
|
|
1652
|
+
<h1>${e.charAt(0).toUpperCase()+e.slice(1)} Page</h1>
|
|
1653
|
+
<p>Welcome to the ${e} page.</p>
|
|
1654
|
+
</div>
|
|
1655
|
+
\`;
|
|
1656
|
+
|
|
1657
|
+
export default ${e.charAt(0).toUpperCase()+e.slice(1)}Page;
|
|
1658
|
+
`,await d.default.writeFile(n,s);let l=f.default.join(r,`${e}.css`);await d.default.writeFile(l,`.${e}-page { padding: 2rem; }`),console.log(p.gray(` ✓ ${e} page created`))}function At(i){return i==="jsx"?`/** @jsx h */
|
|
1659
|
+
import { h } from '@fluixi/core/jsx-runtime';
|
|
1660
|
+
import { createSignal } from '@fluixi/reactive/signal';
|
|
1661
|
+
import './todolist.css';
|
|
1662
|
+
|
|
1663
|
+
export function TodoList() {
|
|
1664
|
+
const [todos, setTodos] = createSignal<string[]>([]);
|
|
1665
|
+
const [input, setInput] = createSignal('');
|
|
1666
|
+
|
|
1667
|
+
const addTodo = () => {
|
|
1668
|
+
if (input().trim()) {
|
|
1669
|
+
setTodos([...todos(), input()]);
|
|
1670
|
+
setInput('');
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
return (
|
|
1675
|
+
<div class="todolist">
|
|
1676
|
+
<h2>Todo List</h2>
|
|
1677
|
+
<div class="input-group">
|
|
1678
|
+
<input
|
|
1679
|
+
type="text"
|
|
1680
|
+
value={input()}
|
|
1681
|
+
onInput={(e) => setInput((e.target as HTMLInputElement).value)}
|
|
1682
|
+
placeholder="Add a todo..."
|
|
1683
|
+
/>
|
|
1684
|
+
<button onClick={addTodo}>Add</button>
|
|
1685
|
+
</div>
|
|
1686
|
+
<ul>
|
|
1687
|
+
{todos().map((todo, index) => (
|
|
1688
|
+
<li key={index}>{todo}</li>
|
|
1689
|
+
))}
|
|
1690
|
+
</ul>
|
|
1691
|
+
</div>
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
export default TodoList;
|
|
1696
|
+
`:`import { html } from 'lit';
|
|
1697
|
+
import { createSignal } from '@fluixi/reactive/signal';
|
|
1698
|
+
import './todolist.css';
|
|
1699
|
+
|
|
1700
|
+
export const TodoList = () => {
|
|
1701
|
+
const [todos, setTodos] = createSignal<string[]>([]);
|
|
1702
|
+
const [input, setInput] = createSignal('');
|
|
1703
|
+
|
|
1704
|
+
const addTodo = () => {
|
|
1705
|
+
if (input().trim()) {
|
|
1706
|
+
setTodos([...todos(), input()]);
|
|
1707
|
+
setInput('');
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
return html\`
|
|
1712
|
+
<div class="todolist">
|
|
1713
|
+
<h2>Todo List</h2>
|
|
1714
|
+
<div class="input-group">
|
|
1715
|
+
<input
|
|
1716
|
+
type="text"
|
|
1717
|
+
.value=\${input()}
|
|
1718
|
+
@input=\${(e: Event) => setInput((e.target as HTMLInputElement).value)}
|
|
1719
|
+
placeholder="Add a todo..."
|
|
1720
|
+
/>
|
|
1721
|
+
<button @click=\${addTodo}>Add</button>
|
|
1722
|
+
</div>
|
|
1723
|
+
<ul>
|
|
1724
|
+
\${todos().map((todo) => html\`<li>\${todo}</li>\`)}
|
|
1725
|
+
</ul>
|
|
1726
|
+
</div>
|
|
1727
|
+
\`;
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
export default TodoList;
|
|
1731
|
+
`}function St(i){return i==="jsx"?`/** @jsx h */
|
|
1732
|
+
import { h } from '@fluixi/core/jsx-runtime';
|
|
1733
|
+
import './usercard.css';
|
|
1734
|
+
|
|
1735
|
+
export interface UserCardProps {
|
|
1736
|
+
name: string;
|
|
1737
|
+
email: string;
|
|
1738
|
+
avatar?: string;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
export function UserCard({ name, email, avatar }: UserCardProps) {
|
|
1742
|
+
return (
|
|
1743
|
+
<div class="usercard">
|
|
1744
|
+
<img src={avatar || 'https://via.placeholder.com/100'} alt={name} />
|
|
1745
|
+
<h3>{name}</h3>
|
|
1746
|
+
<p>{email}</p>
|
|
1747
|
+
</div>
|
|
1748
|
+
);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
export default UserCard;
|
|
1752
|
+
`:`import { html } from 'lit';
|
|
1753
|
+
import './usercard.css';
|
|
1754
|
+
|
|
1755
|
+
export interface UserCardProps {
|
|
1756
|
+
name: string;
|
|
1757
|
+
email: string;
|
|
1758
|
+
avatar?: string;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
export const UserCard = (props: UserCardProps) => html\`
|
|
1762
|
+
<div class="usercard">
|
|
1763
|
+
<img src="\${props.avatar || 'https://via.placeholder.com/100'}" alt="\${props.name}" />
|
|
1764
|
+
<h3>\${props.name}</h3>
|
|
1765
|
+
<p>\${props.email}</p>
|
|
1766
|
+
</div>
|
|
1767
|
+
\`;
|
|
1768
|
+
|
|
1769
|
+
export default UserCard;
|
|
1770
|
+
`}function Et(i){return`import { html } from 'lit';
|
|
1771
|
+
import { createResource } from '@fluixi/core/resources';
|
|
1772
|
+
import { Show } from '@fluixi/core/control-flow';
|
|
1773
|
+
import './datafetcher.css';
|
|
1774
|
+
|
|
1775
|
+
async function fetchData() {
|
|
1776
|
+
const response = await fetch('https://jsonplaceholder.typicode.com/posts/1');
|
|
1777
|
+
return response.json();
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
export const DataFetcher = () => {
|
|
1781
|
+
const [data] = createResource(fetchData);
|
|
1782
|
+
|
|
1783
|
+
return html\`
|
|
1784
|
+
<div class="datafetcher">
|
|
1785
|
+
<h2>Data Fetcher</h2>
|
|
1786
|
+
\${Show({
|
|
1787
|
+
when: () => data.loading,
|
|
1788
|
+
children: html\`<p>Loading...</p>\`,
|
|
1789
|
+
})}
|
|
1790
|
+
\${Show({
|
|
1791
|
+
when: () => data.error,
|
|
1792
|
+
children: html\`<p>Error: \${data.error?.message}</p>\`,
|
|
1793
|
+
})}
|
|
1794
|
+
\${Show({
|
|
1795
|
+
when: () => data(),
|
|
1796
|
+
children: html\`
|
|
1797
|
+
<div>
|
|
1798
|
+
<h3>\${data()?.title}</h3>
|
|
1799
|
+
<p>\${data()?.body}</p>
|
|
1800
|
+
</div>
|
|
1801
|
+
\`,
|
|
1802
|
+
})}
|
|
1803
|
+
</div>
|
|
1804
|
+
\`;
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1807
|
+
export default DataFetcher;
|
|
1808
|
+
`}async function Ot(){let i=await R.default.prompt([{type:"input",name:"name",message:"Project name:",validate:t=>t?/^[a-z][a-z0-9-]*$/.test(t)?!0:"Project name must start with lowercase letter and contain only lowercase letters, numbers, and hyphens":"Project name is required"},{type:"list",name:"template",message:"Project template:",choices:[{name:"Minimal (Basic setup)",value:"minimal"},{name:"Standard (With router and examples)",value:"standard"},{name:"Full (Complete setup with all features)",value:"full"}]},{type:"list",name:"mode",message:"Default component mode:",choices:[{name:"Lit-HTML (Native Fluixi)",value:"lit-html"},{name:"JSX (Native JSX runtime)",value:"jsx"},{name:"React Bridge (React compatibility)",value:"react-bridge"}],default:"lit-html"},{type:"confirm",name:"advancedConfig",message:"Configure advanced project settings?",default:!1}]),e={...i};if(i.advancedConfig){let t=await R.default.prompt([{type:"confirm",name:"includeRouter",message:"Include router setup?",default:i.template!=="minimal"},{type:"confirm",name:"includeSSR",message:"Include Server-Side Rendering (SSR) support?",default:!1},{type:"confirm",name:"includeStateManagement",message:"Include state management utilities?",default:i.template==="full"},{type:"confirm",name:"includeTesting",message:"Setup testing framework (Vitest)?",default:!0},{type:"confirm",name:"includeESLint",message:"Include ESLint configuration?",default:!0},{type:"confirm",name:"includePrettier",message:"Include Prettier configuration?",default:!0},{type:"list",name:"cssPreprocessor",message:"CSS preprocessor:",choices:[{name:"None (Plain CSS)",value:"none"},{name:"SCSS/SASS",value:"scss"},{name:"Less",value:"less"},{name:"PostCSS",value:"postcss"}],default:"none"},{type:"checkbox",name:"exampleComponents",message:"Generate example components:",choices:[{name:"Counter (Basic state management)",value:"counter",checked:!0},{name:"TodoList (CRUD operations)",value:"todolist"},{name:"UserCard (Props & styling)",value:"usercard"},{name:"DataFetcher (Async resources)",value:"datafetcher"}]},{type:"checkbox",name:"examplePages",message:"Generate example pages:",choices:[{name:"Home",value:"home",checked:!0},{name:"About",value:"about"},{name:"Dashboard",value:"dashboard"},{name:"NotFound (404)",value:"notfound",checked:!0}]},{type:"input",name:"author",message:"Author name (optional):",default:""},{type:"input",name:"description",message:"Project description (optional):",default:"A Fluixi application"},{type:"input",name:"license",message:"License:",default:"MIT"}]);e={...e,...t}}await Te(e.name,e.template,e.mode,e),console.log(p.yellow(`
|
|
1809
|
+
Note: Component mode preference saved.`)),console.log(p.gray(`Default mode: ${e.mode}`))}A.name("fluixi").description("Fluixi CLI - Generate projects and components").version(ke);A.command("new [project-name]").description("Create a new Fluixi project").option("-t, --template <template>","Project template (minimal|standard|full)","standard").action(async(i,e)=>{try{i?await Te(i,e?.template||"standard"):await Ot()}catch(t){console.error(p.red("Error creating project:"),t),process.exit(1)}});A.command("generate <type> [name]").alias("g").description("Generate a component or other artifact").option("-t, --type <type>","Component type (basic|with-state|with-resource|with-router|full)").option("-p, --path <path>","Component path").option("-m, --mode <mode>","Component mode (lit-html|jsx|react-bridge)").action(async(i,e,t)=>{try{if(i==="component"||i==="c")if(e&&t?.path){let r=t.type||"basic",o=t.mode||"lit-html",n=f.default.join(process.cwd(),"src",t.path);await Le(n,e,r,"functional",o)}else await bt();else console.error(p.red(`Unknown type: ${i}`)),console.log(p.gray("Available types: component (or c)")),process.exit(1)}catch(r){console.error(p.red("Error generating component:"),r),process.exit(1)}});A.command("info").description("Display Fluixi information").action(()=>{console.log(p.blue(`
|
|
1810
|
+
╔═══════════════════════════════════╗`)),console.log(p.blue("║ Fluixi CLI v"+ke+" ║")),console.log(p.blue(`╚═══════════════════════════════════╝
|
|
1811
|
+
`)),console.log(p.gray(`A reactive framework for lit-html
|
|
1812
|
+
`)),console.log("Commands:"),console.log(p.cyan(" new [project-name] ")+"Create a new project"),console.log(p.cyan(" generate <type> [name] ")+"Generate a component"),console.log(p.cyan(" info ")+"Show this information"),console.log(p.cyan(" help ")+`Show help
|
|
1813
|
+
`),console.log("Examples:"),console.log(p.gray(" fluixi new my-app")),console.log(p.gray(" fluixi generate component MyComponent")),console.log(p.gray(" fluixi generate component MyComponent --mode jsx")),console.log(p.gray(" fluixi generate component MyComponent --mode react-bridge")),console.log(p.gray(` fluixi g c MyComponent -t with-state -p components/MyComponent/MyComponent.ts
|
|
1814
|
+
`))});A.parse();
|