From 8317e7ca41d29092a2f1e63307cb3d6689fb9b55 Mon Sep 17 00:00:00 2001 From: henryhale Date: Fri, 8 Dec 2023 09:52:42 +0000 Subject: [PATCH] deploy: d37c1ded7f59bc7e39857a99fe5b787a450232fe --- assets/index-9ffb866a.js | 41 ------------------- assets/index-lv_2IZuy.js | 37 +++++++++++++++++ ...{index-232722d1.css => index-oWf9XcRm.css} | 0 index.html | 5 +-- 4 files changed, 39 insertions(+), 44 deletions(-) delete mode 100644 assets/index-9ffb866a.js create mode 100644 assets/index-lv_2IZuy.js rename assets/{index-232722d1.css => index-oWf9XcRm.css} (100%) diff --git a/assets/index-9ffb866a.js b/assets/index-9ffb866a.js deleted file mode 100644 index c66fc32..0000000 --- a/assets/index-9ffb866a.js +++ /dev/null @@ -1,41 +0,0 @@ -var St=Object.defineProperty;var kt=(s,t,e)=>t in s?St(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var g=(s,t,e)=>(kt(s,typeof t!="symbol"?t+"":t,e),e),lt=(s,t,e)=>{if(!t.has(s))throw TypeError("Cannot "+e)};var c=(s,t,e)=>(lt(s,t,"read from private field"),e?e.call(s):t.get(s)),S=(s,t,e)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,e)},y=(s,t,e,i)=>(lt(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))i(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();/** - * XTerminal - v2.0.10 - * @author Henry Hale - * @license MIT - * @url https://github.com/henryhale/xterminal - */const z=new WeakMap;let gt=class{constructor(){this.isDisposed=!1,z.set(this,[])}register(t){var e;this.isDisposed?t==null||t.dispose():(e=z.get(this))===null||e===void 0||e.push(t)}dispose(){if(this.isDisposed)return;this.isDisposed=!0;const t=z.get(this);for(const e of t)e==null||e.dispose();z.delete(this)}},Z=class extends Error{constructor(t){super(t="[x] "+t),this.name="XTerminalError"}};const mt=Array.isArray;function ut(s){return typeof s=="object"&&s!==null}function P(s){return typeof s=="function"}const Q=new WeakMap,yt=()=>({stack:[],store:new Map});function tt(s){return Q.get(s)||yt()}function ht(s,t,e,i=!1){var n;if(typeof t!="string"&&typeof t!="symbol")throw new Z("EventEmitter: The event name (first argument) should either be a string or symbol, got "+typeof t);if(!P(e))throw new Z("EventEmitter: The event listener (second argument) is required and must be a function, got "+typeof e);const r=i?(...a)=>{e.call(void 0,...a),s.off(t,r)}:e,o=tt(s).store;return o.has(t)?(n=o.get(t))===null||n===void 0||n.add(r):o.set(t,new Set([r])),{dispose:()=>s.off(t,r)}}let Mt=class extends gt{constructor(){super(),Q.set(this,yt()),this.register({dispose:()=>Q.delete(this)})}on(t,e){this.register(ht(this,t,e))}once(t,e){this.register(ht(this,t,e,!0))}off(t,e){const i=tt(this).store.get(t);if(i){for(const n of i)if(n===e){i.delete(e);break}}}emit(t,...e){if(this.isDisposed)return;const i=tt(this);if(i.stack.includes(t))return;const n=i.store.get(t);if(n){i.stack.push(t);for(const r of n)r.call(void 0,...e);i.stack.pop()}}},Tt=class{constructor(t=[]){this.store=mt(t)?t:[],this.ptr=-1}get size(){return this.store.length}get list(){return[].slice.call(this.store).reverse()}add(t){return!(!t||t===this.store[0])&&(this.store.unshift(t),this.ptr=-1,!0)}get previous(){return this.ptr++,this.ptr>=this.size&&(this.ptr=this.size-1),this.store[this.ptr]||""}get next(){return this.ptr--,this.ptr<=-1&&(this.ptr=-1),this.store[this.ptr]||""}clear(){this.store.splice(0)}};const L=" ",Pt="xt",dt="xt-inactive",Nt="xt-cursor",Ct="xt-stdout",Lt="xt-stdin";function pt(s){s&&s.scrollTo(0,s.scrollHeight)}function k(s,t){const e=document.createElement(s);return ut(t)&&(t!=null&&t.id&&(e.id=t.id||""),t!=null&&t.class&&(e.className=t.class||""),t!=null&&t.content&&e.appendChild(document.createTextNode(""+t.content)),t!=null&&t.html&&(e.innerHTML=t.html),mt(t==null?void 0:t.children)&&t.children.forEach(i=>e.append(i)),ut(t==null?void 0:t.props)&&Object.entries(t.props).forEach(i=>e.setAttribute(i[0],i[1]))),e}function Dt(s){return(""+s).replace(/(\n)|(\n\r)|(\r\n)/g,"
").replace(/\s{2}/g,L.repeat(2)).replace(/\t/g,L.repeat(4))}class Ft{constructor(t){const{outputBox:e,consoleBox:i}=function(n){const r=k("span"),o=k("div",{class:Ct,children:[r]});return n.appendChild(o),{outputBox:o,consoleBox:r}}(t);this.el=e,this.console=i}write(t,e){this.lastOutput=k("span",{html:Dt(t)}),this.console.appendChild(this.lastOutput),P(this.onoutput)&&this.onoutput(),P(e)&&e()}clear(){this.console&&(this.console.innerHTML="")}clearLast(){var t;this.lastOutput&&((t=this.lastOutput.parentNode)===null||t===void 0||t.removeChild(this.lastOutput)),this.lastOutput=void 0}}const wt="Enter";function M(s,t,e,i){s.addEventListener(t,e,i);let n=!1;return{dispose(){n||(s.removeEventListener(t,e,i),n=!0)}}}const Ht=0;function bt(s,...t){return setTimeout(s,Ht,...t)}function ft(s){let t;return(...e)=>{P(s)&&(clearTimeout(t),t=bt(s,...e))}}let _;function W(s){const t=new Set;let e=!1;return{get value(){return!e&&P(_)&&t.add(_),s},set value(i){s=i,e||t.forEach(n=>n.call(void 0))},dispose(){e||(e=!0,t.clear())}}}function et(s){if(P(s)){_=s;try{s.call(void 0)}finally{_=null}}}class It extends gt{constructor(t){super(),this.el=function(r){const o=k("input",{props:{spellcheck:!1,autocapitalize:"off",autocomplete:"off"}}),a=k("div",{class:Lt,children:[o]});return r.appendChild(a),o}(t),this.data=W(""),this.ptr=W(0),this.isActive=W(!0),this.showInput=W(!0),this.isFocused=W(!1),this.register(this.data),this.register(this.ptr),this.register(this.isActive),this.register(this.showInput),this.register(this.isFocused);const e=()=>function(r,o,a){let u="selectionStart"in(v=r)?v.selectionStart:0;var v;const l=o.value.length;u>l?u=l:u<0&&(u=0),a.value=u}(this.el,this.data,this.ptr),i=ft(e),n=ft(()=>{this.data.value=this.el.value});et(e),this.register(M(this.el,"blur",()=>this.isFocused.value=!1)),this.register(M(this.el,"focus",()=>this.isFocused.value=!0,!1)),this.register(M(this.el,"keyup",()=>this.isActive.value&&i(),!1)),this.register(M(this.el,"input",()=>{n(),i()})),this.register(M(this.el,"keydown",r=>{r.stopImmediatePropagation();const o=this.data.value;r.key===wt&&(this.el&&(this.el.value=""),this.data.value="",this.showInput.value=!0),this.isActive.value&&P(this.onkeypress)&&(this.onkeypress({key:r.key,altKey:r.altKey,ctrlKey:r.ctrlKey,metaKey:r.metaKey,shiftKey:r.shiftKey,value:o,cancel(){r.preventDefault(),r.stopPropagation()}}),i())}))}blur(){this.el&&this.el.blur()}focus(){this.el&&this.el.focus()}pause(){this.isActive.value=!1}resume(){this.isActive.value=!0}setValue(t){this.el&&(this.el.value=t),this.data.value=t}pipe(t){var e;const i=k("span"),n=k("span",{class:Nt,html:L}),r=k("span");(e=t.el)===null||e===void 0||e.append(i,n,r),et(()=>{const o=this.ptr.value,a=this.data.value;if(!this.isActive.value||!this.showInput.value)return i.innerHTML="",n.innerHTML=L,void(r.innerHTML="");i.innerHTML=a.substring(0,o).replace(/\s{2}/g," "+L),n.innerHTML=a.substring(o,o+1).trim()||L,r.innerHTML=a.substring(o+1).replace(/\s{2}/g," "+L)})}}const rt=new WeakMap;function Et(s){const t=rt.get(s);return{state:t,process:function(e){t&&e.call(void 0,t)}}}const w=Et;function Rt(s,t){const e=k("div",{class:Pt,props:{tabindex:0}}),i=new Tt,n=new Ft(e),r=new It(e);r.pipe(n),n.onoutput=()=>pt(e),s.register(M(e,"keydown",function(o){r.focus(),bt(()=>{r.el.dispatchEvent(new KeyboardEvent("keydown",o)),r.el.dispatchEvent(new KeyboardEvent("input",o))})})),s.register(M(e,"focus",()=>r.isFocused.value=!0)),s.register(M(e,"blur",()=>r.isFocused.value=!1)),function(){const o=window||{},a=navigator||{};return!(!("ontouchstart"in o)&&!a.maxTouchPoints||!/Mobi/.test(a.userAgent))}()&&s.register(M(e,"click",r.focus.bind(r))),t.appendChild(e),r.onkeypress=o=>{o.key==wt?(o.cancel(),i.add(o.value),s.emit("data",o.value)):o.key=="Tab"?(o.cancel(),Et(s).process(a=>{a.completer&&r.setValue(a.completer(o.value))})):o.key=="ArrowDown"?(o.cancel(),r.setValue(i.next)):o.key=="ArrowUp"?(o.cancel(),r.setValue(i.previous)):s.emit("keypress",o),pt(e)},rt.set(s,{input:r,output:n,history:i,completer:void 0}),et(()=>{r.isFocused.value?e.classList.remove(dt):e.classList.add(dt)})}class jt extends Mt{constructor(t){super(),this.isMounted=!1,t!=null&&t.target&&this.mount(t.target)}focus(){var t;(t=w(this).state)===null||t===void 0||t.input.focus()}blur(){var t;(t=w(this).state)===null||t===void 0||t.input.blur()}pause(){var t;(t=w(this).state)===null||t===void 0||t.input.pause()}resume(){var t;(t=w(this).state)===null||t===void 0||t.input.resume()}write(t,e){var i;(i=w(this).state)===null||i===void 0||i.output.write(""+t,e)}writeln(t,e){var i;(i=w(this).state)===null||i===void 0||i.output.write(t+` -`,e)}clear(){var t;(t=w(this).state)===null||t===void 0||t.output.clear(),this.emit("clear")}clearLast(){var t;(t=w(this).state)===null||t===void 0||t.output.clearLast()}get history(){var t;return((t=w(this).state)===null||t===void 0?void 0:t.history.list)||[]}clearHistory(){var t;(t=w(this).state)===null||t===void 0||t.history.clear()}setCompleter(t){P(t)&&w(this).process(e=>e.completer=t)}mount(t){if(!this.isMounted){if(t&&typeof t=="string"&&(t=document.querySelector(t)),!(t instanceof HTMLElement))throw new Z("mount: A parent HTMLElement (target) is required");!t.isConnected&&console&&console.warn("'mount' was called on an HTMLElement (target) that is not attached to DOM."),t.innerHTML="",Rt(this,t),this.isMounted=!0}}dispose(){var t;super.dispose(),w(this).process(e=>{var i;e.history.clear(),e.completer=void 0,e.input.dispose();const n=e.output.el.parentNode;(i=n==null?void 0:n.parentNode)===null||i===void 0||i.removeChild(n)}),t=this,rt.delete(t)}static get version(){return"2.0.10"}}/** - * viteshell - v0.4.0 - * @author Henry Hale - * @license MIT - * @url https://github.com/henryhale/viteshell - */const X="v0.4.0",G="vsh",C="?",U="PS1",xt="Process aborted!",vt="Process terminated!",Kt=G+": inactive, use shell.init to activate";function D(s){return typeof s=="function"}function Ot(){return Math.floor(1024*Math.random()*30)}class Wt{constructor(){g(this,"buffer");g(this,"extractor");this.buffer=[],this.extractor=void 0}get isBusy(){return this.extractor!==void 0}insert(t=""){this.buffer.push(t),D(this.extractor)&&this.extractor.call(void 0)}get extract(){var t;return((t=this.buffer.shift())==null?void 0:t.trim())||""}readline(){return new Promise(t=>{this.buffer.length?t(this.extract):this.extractor=()=>{this.extractor=void 0,t(this.extract)}})}clear(){this.buffer.splice(0)}}class Bt{constructor(){g(this,"isActive");g(this,"bufferOutput");g(this,"buffer");g(this,"onoutput");g(this,"onerror");g(this,"onclear");g(this,"beforeOutput");this.isActive=!0,this.bufferOutput=!1,this.buffer=[],this.beforeOutput=void 0}disable(){this.isActive=!1}enable(){this.isActive=!0}clear(){var t;(t=this.onclear)==null||t.call(void 0)}write(t,e="data",i=!0){var n;this.isActive&&(t=t==null?void 0:t.toString(),i&&this.beforeOutput&&(t=this.beforeOutput(t)),this.bufferOutput?this.buffer.push({type:e,data:t}):(n=e=="data"?this.onoutput:this.onerror)==null||n.call(void 0,t))}error(t){this.write(t,"error")}get extract(){return this.buffer.splice(0).map(t=>t.data+"")}flush(){this.bufferOutput=!1,this.buffer.length&&this.buffer.splice(0).forEach(t=>{t.type==="error"?this.error(t.data):this.write(t.data)})}reset(){this.enable(),this.flush()}}const zt={SHELL:G,USERNAME:"user",HOSTNAME:"web",PWD:"/",PS1:` -$USERNAME@$HOSTNAME: $PWD $ `,"?":0,RANDOM:Ot()};function q(s,t=""){let e;return(""+t).replace(/(?:\$([a-z_][a-z0-9_]+|\?))/gi,i=>(e=s[i.slice(1)],e===void 0?"":e.toString()))}class Ut{constructor(){g(this,"env");g(this,"alias");g(this,"history");this.env=Object.assign(Object.create(null),zt),this.alias={},this.history=[]}import(t){const e=this.spawn(t);this.patch(e)}toJSON(){return JSON.stringify({history:this.history,alias:this.alias,env:this.env})}spawn(t){return JSON.parse(t||this.toJSON())}patch(t){Object.assign(this.alias,t.alias),Object.assign(this.env,t.env),this.history.splice(0,1,...t.history)}}const B=[";","|","&&","||"];function V(s){const t={cmd:"",argv:[],PIPE:void 0,AND:void 0,OR:void 0};t.cmd=s.shift()||"";const e=s.findIndex(i=>B.slice(1).includes(i));return e===-1?(t.argv=s.splice(0),t):(t.argv=s.splice(0,e),s[0]===B[1]&&(t.PIPE=V(s.splice(1))),s[0]===B[2]&&(t.AND=V(s.splice(1))),s[0]===B[3]&&(t.OR=V(s.splice(1))),t)}function qt(s){return function(t){const e=[];if(!t||typeof t!="string")return e;const i=[];let n,r=!1,o=!1,a=!1,u=!1,v="";if(B.some(l=>t.startsWith(n=l)||t.endsWith(l)))throw new SyntaxError("unexpected token '"+n+"'");if(t.split("").forEach((l,b,d)=>{if(r&&l==="'")return r=!1,void(u=!0);if(!r&&!o&&!a){if(l==="'")return void(r=!0);if(l==='"')return void(o=!0);if(l==="\\")return void(a=!0);if(["\b","\f",` -`,"\r"," "," ",";"].includes(l))return(v.length>0||u)&&(i.push(v),u=!1),l===";"&&i.length&&e.push(i.splice(0)),void(v="")}if(!r&&o&&!a&&l==='"')return o=!1,void(u=!0);!r&&o&&!a&&l==="\\"&&(a=!0,['"',"`","$","\\"].includes(d[b+1]))||(a&&(a=!1),v+=l)}),(v.length>0||u)&&(i.push(v),u=!1),i.length&&e.push(i),o)throw new SyntaxError("unexpected end of string while looking for matching double quote");if(r)throw new SyntaxError("unexpected end of string while looking for matching single quote");if(a)throw new SyntaxError("unexpected end of string right after slash");return e}(s).map(t=>V(t))}function Y(s){return s.match(/^([a-zA-Z0-9_]+)=(.*)$/)}function st(s,t){if(s)return t&&s.AND?s.AND:!t&&s.OR?s.OR:st(s.AND,t)||st(s.OR,t)}function Jt(s,t,e){const i=()=>new Promise((r,o)=>{s.onAbort(a=>o(a||xt));try{t==null||t.call(void 0,r,o)}catch(a){o(a==null?void 0:a.toString())}});if(!e)return i();let n;return Promise.race([n=i(),new Promise((r,o)=>{const a=setTimeout(()=>{s.abort("Process timed out!")},e);function u(v){a&&clearTimeout(a),o(v)}n==null||n.catch(u),s.onAbort(u)})])}class Vt{constructor(){g(this,"handlers");g(this,"isCancelled");this.handlers=new Set,this.isCancelled=!1}onAbort(t){D(t)&&(this.isCancelled?t.call(void 0):this.handlers.add(t))}abort(t){this.isCancelled||(this.isCancelled=!0,this.handlers.forEach(e=>e.call(void 0,t)),this.handlers.clear())}reset(){this.isCancelled=!1,this.handlers.size&&this.handlers.clear()}}var h,T,m,A,F,E,I,R;class _t{constructor(){S(this,h,void 0);S(this,T,void 0);S(this,m,void 0);S(this,A,void 0);S(this,F,void 0);S(this,E,void 0);S(this,I,void 0);S(this,R,void 0);var t,e;y(this,h,new Bt),y(this,T,new Wt),y(this,m,new Ut),y(this,A,new Map),y(this,F,!1),y(this,E,new Vt),y(this,I,void 0),y(this,R,void 0),c(this,h).beforeOutput=i=>q(c(this,m).env,i),t=c(this,A),e=c(this,m),t.set("exit",{synopsis:"exit",description:"Terminate current process",action:({exit:i})=>i()}),t.set("clear",{synopsis:"clear",description:"Clear the entire standard output stream.",action:({stdout:i})=>i.clear()}),t.set("pwd",{synopsis:"pwd",description:"Print current working directory.",action:({stdout:i})=>i.write("$PWD")}),t.set("echo",{synopsis:"echo [...args]",description:"Write arguments to the standard output followed by a new line character.",action({argv:i,stdout:n}){i.forEach(r=>n.write(r)),n.write(` -`)}}),t.set("alias",{synopsis:"alias [-p] [name=[value] ... ]",description:"Defines aliases for commands",action({argv:i,stdout:n}){!i.length||i.includes("-p")?(n.write("Aliases:"),Object.entries(e.alias).forEach(([r,o])=>{n.write(` - alias `+r+"='"+o+"'")})):i.forEach(r=>{const o=Y(r);if(o){const[,a,u]=o;e.alias[a.trim()]=u.trim()}})}}),t.set("unalias",{synopsis:"unalias [name=[value] ... ]",description:"Removes aliases for commands",action({argv:i}){i.length&&i.forEach(n=>{delete e.alias[n]})}}),t.set("export",{synopsis:"export [name=[value] ... ]",description:"Set shell variables by name and value",action({argv:i,env:n,stdout:r}){!i.length||i.includes("-p")?Object.entries(n).forEach(([o,a],u)=>{u&&r.write(` -`),r.write("var "+o+'="'+(a!=null&&a.toString().includes("$")?a.toString().split("").join("\\"):a)+'"')}):i.forEach(o=>{const a=Y(o);if(a){const[,u,v]=a;n[u.trim()]=v.trim()}})}}),t.set("history",{synopsis:"history [-c] [-n]",description:"Retrieve previous input entries",action:({argv:i,stdout:n})=>{i.includes("-c")?e.history.splice(0):i.includes("-n")?n.write(` -History: ${e.history.length}`):e.history.forEach((r,o)=>{n.write(` - `+o+" "+r)})}}),t.set("help",{synopsis:"help",description:"Displays information on available commands.",action({argv:i,stdout:n}){if(i[0]){const r=i[0];if(!t.has(r))throw"help: no information matching '"+r+"'";const{synopsis:o,description:a}=t.get(r);n.write(r+": "+o+` - `+a)}else{n.write(`ViteShell, ${X} Help - -A list of all available commands - -`);const r=Array.from(t.values()).map(a=>a.synopsis),o=r.reduce((a,u)=>a>u.length?a:u.length,0);r.sort((a,u)=>a>u?1:-1).forEach((a,u)=>{n.write(a.padEnd(o," ")),n.write(u%2?` -`:" ")})}}})}get alias(){return c(this,m).alias}get env(){return c(this,m).env}get history(){return c(this,m).history}set onoutput(t){if(!D(t))throw new TypeError("Output handler must be a function.");c(this,h).onoutput=t}set onerror(t){if(!D(t))throw new TypeError("Error handler must be a function.");c(this,h).onerror=t}set onclear(t){if(!D(t))throw new TypeError("Clear handler must be a function.");c(this,h).onclear=t}set onexit(t){if(!D(t))throw new Error("onexit handler must be a function.");y(this,R,t)}addCommand(t,e){if(c(this,A).has(t))throw new Error(`${G}: '${t}' command already exists`);if(!function(i){return typeof(n=i)=="object"&&n!==null&&D(i.action)&&!!i.description&&!!i.synopsis;var n}(e))throw new Error(`${G}: invalid command configuration`);c(this,A).set(t,e)}removeCommand(t){c(this,A).delete(t)}exportState(){return c(this,m).toJSON()}loadState(t){c(this,m).import(t)}init(t=""){c(this,F)||(y(this,F,!0),c(this,h).reset(),c(this,h).clear(),t&&c(this,h).write(t),c(this,h).write(this.env[U]))}setExecutionTimeout(t){typeof t=="number"&&t>=0&&y(this,I,t)}async execute(t){if(!c(this,F))return Promise.reject(Kt);if(c(this,h).reset(),c(this,T).isBusy)return c(this,h).write(`${t||""} -`,"data",!1),void c(this,T).insert(t);if(typeof t!="string"||!t.trim())return c(this,h).write(`${t||""} -`,"data",!1),void c(this,h).write(this.env[U]);let e=t.trim();c(this,h).write(e+` -`,"data",!1),e!=this.history.at(-1)&&this.history.push(e);const i=Y(e);if(i){const[,l,b]=i;return this.env[l]=b.trim(),this.env[C]=0,void c(this,h).write(this.env[U])}e=q(this.env,e);const n=c(this,m).spawn();c(this,h).beforeOutput=l=>q(n.env,l);const r=function(){let l,b,d=!1;const j=new Promise((K,p)=>{l=f=>!d&&(d=!0)&&K(f),b=f=>!d&&(d=!0)&&p(f)});return{get isComplete(){return d},get promise(){return j},get resolve(){return l},get reject(){return b}}}();c(this,E).reset(),c(this,E).onAbort(()=>r.reject(xt));const o={readline:c(this,T).readline.bind(c(this,T))},a={write:l=>!r.isComplete&&c(this,h).write(l),clear:()=>!r.isComplete&&c(this,h).clear()},u={write:l=>!r.isComplete&&c(this,h).error(l)},v={cmd:"",argv:[],get stdin(){return o},get stdout(){return a},get stderr(){return u},exit:()=>{throw new Error(vt)},onExit:c(this,E).onAbort.bind(c(this,E)),env:n.env,get exitCode(){return function(l,b=0){const d=parseInt(""+l);return isNaN(d)?b:d}(n.env[C])},get version(){return X}};return await Promise.race([r.promise,Jt(c(this,E),async(l,b)=>{let d;const j=async(p,f)=>{var at,ct;const nt=this.alias[p.cmd];if(nt){const O=nt.toString().split(" ");p.cmd=O.shift()||"",O.length&&p.argv.unshift(...O)}if(c(this,A).has(p.cmd)){if(p.cmd==="exit")return d=vt,void((at=c(this,R))==null?void 0:at.call(void 0));f.cmd=p.cmd,f.argv=p.argv,c(this,h).bufferOutput=p.PIPE!==void 0;try{await((ct=c(this,A).get(p.cmd))==null?void 0:ct.action.call(void 0,f))}catch(O){f.env[C]=1,d=O==null?void 0:O.toString()}}else d="'"+p.cmd+"' command not found";const ot=!(d!=null&&d.length)&&f.env[C]===0;if(ot&&p.PIPE)return p.PIPE.argv.push(...c(this,h).extract),void await j(p.PIPE,f);if(p.AND||p.OR){const O=st(p,ot);O&&(d&&(f.stderr.write(` -`+d),d=void 0),await j(O,f))}};let K;try{K=qt(e)}catch(p){return void b(p)}for(const p of K){if(r.isComplete)break;try{if(d=void 0,await j(p,v),d)throw d;v.env[C]=0}catch(f){if(v.env[C]=1,!(K.length>1))return void b(f==null?void 0:f.toString());v.stderr.write(` -`+(f==null?void 0:f.toString()))}}l()},c(this,I))]).then(()=>{c(this,m).patch(n)}).catch(l=>{this.env[C]=1,c(this,h).error("$SHELL: "+(l==null?void 0:l.toString()))}).finally(()=>{r.resolve(),c(this,E).reset(),this.env.RANDOM=Ot(),c(this,h).reset(),c(this,h).beforeOutput=l=>q(c(this,m).env,l),c(this,h).write(this.env[U])})}abort(t){c(this,E).abort(t)}static get version(){return X}}h=new WeakMap,T=new WeakMap,m=new WeakMap,A=new WeakMap,F=new WeakMap,E=new WeakMap,I=new WeakMap,R=new WeakMap;const H=function(t,e){return function(){const i=arguments,n=arguments.length;let r=arguments[0];if(n===0)return"";if(n>1)for(let a=1;a':"")+(this.bold?"":"")+(this.underline?"":"")+(this.strikethrough?"":"")+(this.italic?"":"")+(this.value||"")+(this.italic?"":"")+(this.strikethrough?"":"")+(this.underline?"":"")+(this.bold?"":"")+(a?"":"")},toJSON(){return this.toString()}};return o[t]=e,o.value=r,o}},J={black:"#000000",red:"#FA5E5E",green:"#50FA7B",yellow:"#FEF08A",blue:"#60A5FA",magenta:"#FF79C6",cyan:"#67E8F9",white:"#FFFFFF",gray:"#71717A"},N={};N.bold=H("bold",!0);N.italic=H("italic",!0);N.underline=H("underline",!0);N.strikethrough=H("strikethrough",!0);N.dim=H("dim",!0);for(const s in J)Object.hasOwnProperty.call(J,s)&&(N[s]=H("fg",J[s]),N["bg"+s[0].toUpperCase()+s.slice(1)]=H("bg",J[s]));const{bold:re,italic:Gt,underline:ne,strikethrough:oe,dim:Xt,black:ae,red:it,green:At,yellow:ce,blue:le,magenta:ue,cyan:$t,white:he,gray:Yt,bgBlack:de,bgRed:pe,bgGreen:fe,bgYellow:ve,bgBlue:ge,bgMagenta:me,bgCyan:ye,bgWhite:we,bgGray:be}=N,$=new _t,x=new jt;$.onoutput=s=>x.write(s);$.onerror=s=>x.write(it(s).toString());$.onclear=x.clear.bind(x);$.onexit=x.dispose.bind(x);x.on("data",async s=>{await $.execute(s)});x.on("keypress",s=>{const t=s;t.ctrlKey&&t.key==="c"&&(t.preventDefault(),$.abort())});$.env.PS1=` -${it("┌[")}${At("$USERNAME")}@${$t("$HOSTNAME")}${it(`] -└$`)} `;$.alias.print="echo";$.addCommand("login",{synopsis:"login",description:"Demo login process",async action({env:s,stdin:t,stdout:e}){e.write("Username: ");const i=await t.readline();e.write("Token: ");const n=await t.readline();e.write("Logging in as "+$t(i)+` -`),s.USERNAME=i,s.TOKEN=n}});function Zt(){return`
- - -${At("WELCOME TO THE COMMAND LINE INTERFACE")} - -${Xt(Gt("powered by")+"")} - -${Yt('ViteShell ~ Inken ~ XTerminal')} -
`}x.on("clear",()=>x.write(Zt()));x.mount("#app");$.init(); diff --git a/assets/index-lv_2IZuy.js b/assets/index-lv_2IZuy.js new file mode 100644 index 0000000..071b204 --- /dev/null +++ b/assets/index-lv_2IZuy.js @@ -0,0 +1,37 @@ +var Et=Object.defineProperty;var xt=(s,t,e)=>t in s?Et(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>(xt(s,typeof t!="symbol"?t+"":t,e),e),G=(s,t,e)=>{if(!t.has(s))throw TypeError("Cannot "+e)};var c=(s,t,e)=>(G(s,t,"read from private field"),e?e.call(s):t.get(s)),v=(s,t,e)=>{if(t.has(s))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(s):t.set(s,e)},y=(s,t,e,i)=>(G(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e);var T=(s,t,e)=>(G(s,t,"access private method"),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();/** + * XTerminal - v2.1.7 + * @author Henry Hale + * @license MIT + * @url https://github.com/henryhale/xterminal + */var F,pt;let gt=(pt=class{constructor(){v(this,F,void 0);h(this,"isDisposed");this.isDisposed=!1,y(this,F,[])}register(t){this.isDisposed?t==null||t.dispose():c(this,F).push(t)}dispose(){this.isDisposed||(this.isDisposed=!0,c(this,F).forEach(t=>t==null?void 0:t.dispose()))}},F=new WeakMap,pt);var x,ft;let it=(ft=class extends gt{constructor(){super();v(this,x,void 0);y(this,x,{stack:[],store:new Map}),this.register({dispose:()=>c(this,x).store.clear()})}on(e,i){var n;const r=c(this,x).store;r.has(e)?(n=r.get(e))==null||n.add(i):r.set(e,new Set([i]))}once(e,i){var o;const r=(...a)=>{i.call(void 0,...a),this.off(e,r)},n=c(this,x).store;n.has(e)?(o=n.get(e))==null||o.add(r):n.set(e,new Set([r]))}off(e,i){const r=c(this,x).store.get(e);if(r){for(const n of r)if(n===i){r.delete(i);break}}}emit(e,...i){if(this.isDisposed)return;const r=c(this,x).stack;if(r.includes(e))return;const n=c(this,x).store.get(e);if(n){r.push(e);for(const o of n)o.call(void 0,...i);r.pop()}}},x=new WeakMap,ft);const mt=Array.isArray;function rt(s){return typeof s=="object"&&s!==null}function $(s){return typeof s=="function"}let At=class{constructor(t=[]){h(this,"store");h(this,"ptr");this.store=mt(t)?t:[],this.ptr=-1}get size(){return this.store.length}get list(){return[].slice.call(this.store).reverse()}add(t){t&&t!==this.store[0]&&this.store.unshift(t),this.ptr=-1}get previous(){return this.ptr++,this.ptr>=this.size&&(this.ptr=this.size-1),this.store[this.ptr]||""}get next(){return this.ptr--,this.ptr<=-1&&(this.ptr=-1),this.store[this.ptr]||""}clear(){this.store.splice(0)}};const N=" ",St="xt",nt="xt-inactive",Ot="xt-cursor",$t="xt-stdout",kt="xt-stdin";function ot(s){s&&s.scrollTo(0,s.scrollHeight)}function S(s,t){const e=document.createElement(s);return rt(t)&&(t!=null&&t.id&&(e.id=t.id||""),t!=null&&t.class&&(e.className=t.class||""),t!=null&&t.content&&e.appendChild(document.createTextNode(""+t.content)),t!=null&&t.html&&(e.innerHTML=t.html),mt(t==null?void 0:t.children)&&t.children.forEach(i=>e.append(i)),rt(t==null?void 0:t.props)&&Object.entries(t.props).forEach(i=>e.setAttribute(i[0],i[1]))),e}function Tt(s=""){return(""+s).replace(/(\n)|(\n\r)|(\r\n)/g,"
").replace(/\s{2}/g,N.repeat(2)).replace(/\t/g,N.repeat(4))}let Mt=class{constructor(t){h(this,"el");h(this,"console");h(this,"lastOutput");h(this,"onoutput");const{outputBox:e,consoleBox:i}=function(r){const n=S("span"),o=S("div",{class:$t,children:[n]});return r.appendChild(o),{outputBox:o,consoleBox:n}}(t);this.el=e,this.console=i}write(t,e){this.lastOutput=S("span",{html:Tt(t)}),this.console.appendChild(this.lastOutput),$(this.onoutput)&&this.onoutput(),$(e)&&e()}clear(){this.console&&(this.console.innerHTML="")}clearLast(){var t;this.lastOutput&&((t=this.lastOutput.parentNode)==null||t.removeChild(this.lastOutput)),this.lastOutput=void 0}};const vt="Enter";function O(s,t,e,i){s.addEventListener(t,e,i);let r=!1;return{dispose(){r||(s.removeEventListener(t,e,i),r=!0)}}}const Nt=0;function yt(s,...t){return setTimeout(s,Nt,...t)}function at(s){let t;return(...e)=>{$(s)&&(clearTimeout(t),t=yt(s,...e))}}let J;function j(s){const t=new Set;let e=!1;return{get value(){return!e&&$(J)&&t.add(J),s},set value(i){s=i,e||t.forEach(r=>r.call(void 0))},dispose(){e||(e=!0,t.clear())}}}function Y(s){if($(s)){J=s;try{s.call(void 0)}finally{J=null}}}class Pt extends gt{constructor(e){super();h(this,"el");h(this,"buffer");h(this,"data");h(this,"ptr");h(this,"isActive");h(this,"showInput");h(this,"isFocused");h(this,"onkeypress");this.el=function(o){const a=S("input",{props:{spellcheck:!1,autocapitalize:"off",autocomplete:"off"}}),l=S("div",{class:kt,children:[a]});return o.appendChild(l),a}(e),this.buffer="",this.data=j(""),this.ptr=j(0),this.isActive=j(!0),this.showInput=j(!0),this.isFocused=j(!1),this.register(this.data),this.register(this.ptr),this.register(this.isActive),this.register(this.showInput),this.register(this.isFocused);const i=()=>function(o,a,l){let d="selectionStart"in(u=o)?u.selectionStart:0;var u;const m=a.value.length;d>m?d=m:d<0&&(d=0),l.value=d}(this.el,this.data,this.ptr),r=at(i),n=at(()=>{this.data.value=this.buffer=this.el.value});Y(i),this.register(O(this.el,"blur",()=>this.isFocused.value=!1)),this.register(O(this.el,"focus",()=>this.isFocused.value=!0,!1)),this.register(O(this.el,"keyup",()=>this.isActive.value&&r(),!1)),this.register(O(this.el,"input",()=>{n(),r()})),this.register(O(this.el,"keydown",o=>{o.stopImmediatePropagation();const a=this.data.value;o.key===vt&&(this.el&&(this.el.value=""),this.data.value="",this.buffer="",this.showInput.value=!0),this.isActive.value&&$(this.onkeypress)&&(this.onkeypress({key:o.key,altKey:o.altKey,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey,value:a,cancel(){o.preventDefault(),o.stopPropagation()}}),r())}))}blur(){this.el&&this.el.blur()}focus(){this.el&&this.el.focus()}pause(){this.isActive.value=!1}resume(){this.isActive.value=!0}setValue(e){e=e||this.buffer,this.el&&(this.el.value=e),this.data.value=e}pipe(e){var o;const i=S("span"),r=S("span",{class:Ot,html:N}),n=S("span");(o=e.el)==null||o.append(i,r,n),Y(()=>{const a=this.ptr.value,l=this.data.value;if(!this.isActive.value||!this.showInput.value)return i.innerHTML="",r.innerHTML=N,void(n.innerHTML="");i.innerHTML=l.substring(0,a).replace(/\s{2}/g," "+N),r.innerHTML=l.substring(a,a+1).trim()||N,n.innerHTML=l.substring(a+1).replace(/\s{2}/g," "+N)})}}function Lt(s,t){const e=S("div",{class:St,props:{tabindex:0}}),i=new At,r=new Mt(e),n=new Pt(e),o={input:n,output:r,history:i,completer:a=>a};return n.pipe(r),r.onoutput=()=>ot(e),s.register(O(e,"keydown",function(a){n.focus(),yt(()=>{n.el.dispatchEvent(new KeyboardEvent("keydown",a)),n.el.dispatchEvent(new KeyboardEvent("input",a))})})),s.register(O(e,"focus",()=>n.isFocused.value=!0)),s.register(O(e,"blur",()=>n.isFocused.value=!1)),function(){const a=window||{},l=navigator||{};return!(!("ontouchstart"in a)&&!l.maxTouchPoints||!/Mobi/.test(l.userAgent))}()&&s.register(O(e,"click",n.focus.bind(n))),t.appendChild(e),n.onkeypress=a=>{a.key==vt?(a.cancel(),i.add(a.value),s.writeln(a.value),s.emit("data",a.value)):a.key=="Tab"?(a.cancel(),$(o.completer)&&n.setValue(o.completer(a.value))):a.key=="ArrowDown"?(a.cancel(),n.setValue(i.next)):a.key=="ArrowUp"?(a.cancel(),n.setValue(i.previous)):s.emit("keypress",a),ot(e)},Y(()=>{n.isFocused.value?e.classList.remove(nt):e.classList.add(nt)}),o}class Dt extends Error{constructor(t){super(t="[x] "+t),this.name="XTerminalError"}}var p;class Ct extends it{constructor(e){super();v(this,p,void 0);h(this,"isMounted");this.isMounted=!1,e&&(e!=null&&e.target)&&this.mount(e.target)}focus(){c(this,p).input.focus()}blur(){c(this,p).input.blur()}pause(){c(this,p).input.pause(),this.emit("pause")}resume(){c(this,p).input.resume(),this.emit("resume")}write(e,i){c(this,p).output.write(""+e,i)}writeln(e,i){c(this,p).output.write(e+` +`,i)}clear(){c(this,p).output.clear(),this.emit("clear")}clearLast(){c(this,p).output.clearLast()}get history(){return c(this,p).history.list||[]}set history(e){e.forEach(i=>c(this,p).history.add(i))}clearHistory(){c(this,p).history.clear()}setCompleter(e){$(e)&&(c(this,p).completer=e)}mount(e){if(!this.isMounted){if(e&&typeof e=="string"&&(e=document.querySelector(e)),!(e instanceof HTMLElement))throw new Dt("mount: A parent HTMLElement (target) is required");!e.isConnected&&console&&console.warn("'mount' was called on an HTMLElement (target) that is not attached to DOM."),e.innerHTML="",y(this,p,Lt(this,e)),this.isMounted=!0}}dispose(){var r;super.dispose();const e=c(this,p);e.history.clear(),e.completer=void 0,e.input.dispose();const i=e.output.el.parentNode;(r=i==null?void 0:i.parentNode)==null||r.removeChild(i)}static get version(){return"2.1.7"}static get XEventEmitter(){return it}}p=new WeakMap;/** + * viteshell - v0.6.1 + * @author Henry Hale + * @license MIT + * @url https://github.com/henryhale/viteshell + */function M(s){return typeof s=="function"}function Z(){return Math.floor(1024*Math.random()*50)}class Ft{constructor(){h(this,"buffer");h(this,"extractor");this.buffer=[],this.extractor=void 0}get isBusy(){return this.extractor!==void 0}insert(t=""){this.buffer.push(t),M(this.extractor)&&this.extractor.call(void 0)}get extract(){var t;return((t=this.buffer.shift())==null?void 0:t.trim())||""}readline(){return new Promise(t=>{this.buffer.length?t(this.extract):this.extractor=()=>{this.extractor=void 0,t(this.extract)}})}clear(){this.buffer.splice(0)}}class It{constructor(){h(this,"isActive");h(this,"bufferOutput");h(this,"buffer");h(this,"onoutput");h(this,"onerror");h(this,"onclear");this.isActive=!0,this.bufferOutput=!1,this.buffer=[]}disable(){this.isActive=!1}enable(){this.isActive=!0}clear(){var t;(t=this.onclear)==null||t.call(void 0)}write(t,e="data"){var i;this.isActive&&(t=t==null?void 0:t.toString(),this.bufferOutput?this.buffer.push({type:e,data:t}):(i=e=="data"?this.onoutput:this.onerror)==null||i.call(void 0,t))}error(t){this.write(t,"error")}get extract(){return this.buffer.splice(0).map(t=>t.data+"")}flush(){this.bufferOutput=!1,this.buffer.length&&this.buffer.splice(0).forEach(t=>{t.type==="error"?this.error(t.data):this.write(t.data)})}reset(){this.flush(),this.enable()}}const Q="v0.6.1",D="vsh",U="?",ct=D+": process aborted!",Ht=D+": process timed out!",jt=D+": process terminated!",lt="RANDOM",Rt=D+": inactive, use shell.init() to activate",Kt={SHELL:D,USERNAME:"user",HOSTNAME:"web",CWD:"/",PS1:"$USERNAME@$HOSTNAME: $CWD $ ",PS2:"> ","?":"0",RANDOM:""+Z()};function X(s,t=""){let e;return(""+t).replace(/(?:\$([a-z_][a-z0-9_]+|\?))/gi,i=>(e=s[i.slice(1)],e===void 0?"":e.toString()))}function ut(s){return s.match(/^([a-zA-Z0-9_]+)=(.*)$/)}function tt(s,t){if(s)return t&&s.AND?s.AND:!t&&s.OR?s.OR:tt(s.AND,t)||tt(s.OR,t)}const R=[";","|","&&","||"];function W(s){const t={cmd:"",args:"",argv:[],PIPE:void 0,AND:void 0,OR:void 0};t.cmd=s.shift()||"";const e=s.findIndex(i=>R.slice(1).includes(i));return e===-1?(t.argv=s.splice(0),t.args=(t.cmd+" "+t.argv.join(" ")).trim(),t):(t.argv=s.splice(0,e),t.args=(t.cmd+" "+t.argv.join(" ")).trim(),s[0]===R[1]&&(t.PIPE=W(s.splice(1))),s[0]===R[2]&&(t.AND=W(s.splice(1))),s[0]===R[3]&&(t.OR=W(s.splice(1))),t)}function Bt(s){return function(t){const e=[];if(!t||typeof t!="string")return e;const i=[];let r,n=!1,o=!1,a=!1,l=!1,d="";if(R.some(u=>t.startsWith(r=u)||t.endsWith(u)))throw new SyntaxError("unexpected token '"+r+"'");if(t.split("").forEach((u,m,B)=>{if(n&&u==="'")return n=!1,void(l=!0);if(!n&&!o&&!a){if(u==="'")return void(n=!0);if(u==='"')return void(o=!0);if(u==="\\")return void(a=!0);if(["\b","\f",` +`,"\r"," "," ",";"].includes(u))return(d.length>0||l)&&(i.push(d),l=!1),u===";"&&i.length&&e.push(i.splice(0)),void(d="")}if(!n&&o&&!a&&u==='"')return o=!1,void(l=!0);!n&&o&&!a&&u==="\\"&&(a=!0,['"',"`","$","\\"].includes(B[m+1]))||(a&&(a=!1),d+=u)}),(d.length>0||l)&&(i.push(d),l=!1),i.length&&e.push(i),o)throw new SyntaxError("unexpected end of string while looking for matching double quote");if(n)throw new SyntaxError("unexpected end of string while looking for matching single quote");if(a)throw new SyntaxError("unexpected end of string right after slash");return e}(s).map(t=>W(t))}function zt(s,t,e,i){let r=!1;const n={readline:t.readline.bind(t)},o={clear:()=>!r&&e.clear(),write:l=>{r||e.write(X(s.env,l))},writeln:l=>o.write(l+` +`)},a={write:l=>{r||e.error(X(s.env,l))},writeln:l=>a.write(l+` +`)};return{cmd:"",args:"",argv:[],get env(){return s.env},get stderr(){return a},get stdin(){return n},get stdout(){return o},get history(){return s.history},get version(){return Q},get exitCode(){return function(l,d=0){const u=parseInt(""+l);return isNaN(u)?d:u}(s.env[U])},exit:l=>{i.onAbort(()=>r=!0),i.abort(typeof l=="number"?""+l:l||jt)},onExit:i.onAbort.bind(i)}}function ht(){return{env:Object.assign(Object.create(null),Kt),alias:{},history:[]}}function dt(s){return JSON.parse(typeof s=="string"?s:JSON.stringify(s))}var f,P,w,A,L,b,K,I,V,H,q;class Ut{constructor(){v(this,I);v(this,H);v(this,f,void 0);v(this,P,void 0);v(this,w,void 0);v(this,A,void 0);v(this,L,void 0);v(this,b,void 0);v(this,K,void 0);var t,e;y(this,f,new It),y(this,P,new Ft),y(this,w,ht()),y(this,A,new Map),y(this,L,!1),y(this,b,function(){const i=new Set;let r=!1;return{abort:function(n){r||(r=!0,i.forEach(o=>o.call(void 0,n)))},onAbort:function(n){M(n)&&(r?n.call(void 0):i.add(n))},reset:function(){r=!1,i.size&&i.clear()},get isAborted(){return r}}}()),t=c(this,A),e=c(this,w),t.set("exit",{synopsis:"exit",description:"Terminate the current process",action:({exit:i})=>i()}),t.set("clear",{synopsis:"clear",description:"Clear the entire standard output stream.",action:({stdout:i})=>i.clear()}),e.alias.cls="clear",t.set("pwd",{synopsis:"pwd",description:"Print current working directory.",action:({stdout:i})=>i.writeln("$CWD")}),t.set("echo",{synopsis:"echo [...args]",description:"Write arguments to the standard output followed by a new line character.",action:({argv:i,stdout:r})=>r.writeln(i.join(" "))}),e.alias.print="echo",t.set("alias",{synopsis:"alias [-p] [name=[value] ... ]",description:"Defines aliases for commands",action:({argv:i,stdout:r})=>{!i.length||i.includes("-p")?(r.write("Aliases:"),Object.entries(e.alias).forEach(([n,o])=>{r.write(` + alias `+n+"='"+o+"'")}),r.write(` +`)):i.forEach(n=>{const o=ut(n);if(o){const[,a,l]=o;e.alias[a.trim()]=l.trim()}})}}),t.set("unalias",{synopsis:"unalias [name ... ]",description:"Removes aliases for commands",action:({argv:i})=>{i.length&&i.forEach(r=>{delete e.alias[r]})}}),t.set("export",{synopsis:"export [-p] [name=[value] ... ]",description:"Set shell variables by name and value",action:({argv:i,env:r,stdout:n})=>{!i.length||i.includes("-p")?Object.entries(r).forEach(([o,a])=>{n.write("var "+o+'="'+(a!=null&&a.toString().includes("$")?a.toString().split("").join("\\"):a)+`" +`)}):i.forEach(o=>{const a=ut(o);if(a){const[,l,d]=a;r[l.trim()]=d.trim()}})}}),t.set("history",{synopsis:"history [-c] [-n]",description:"Retrieve previous input entries",action:({argv:i,history:r,stdout:n})=>{i.includes("-c")?r.splice(0):i.includes("-n")?n.writeln(`History: ${r.length}`):r.forEach((o,a)=>{n.writeln(" "+a+" "+o)})}}),t.set("help",{synopsis:"help [command]",description:"Displays information on available commands.",action:({argv:i,stdout:r})=>{if(i[0]){const n=i[0],o=t.get(n);if(!o)throw"help: no information matching '"+n+"'";const{synopsis:a,description:l}=o;r.writeln(n+": "+a+` + `+l)}else r.write(`ViteShell, ${Q} Help + +A list of all available commands + +`),Array.from(t.values()).map(n=>n.synopsis).sort().forEach(n=>r.writeln(n))}}),e.alias.info="help",e.alias.man="help",t.set("read",{synopsis:"read [prompt] [variable]",description:"Capture input and save it in the env object.",action:async({argv:i,env:r,stdin:n,stdout:o})=>{if(!i[0]||!i[1])throw"invalid arguments: specify the prompt and variable name";o.write(i[0]),r[i[1]]=await n.readline()}}),t.set("sleep",{synopsis:"sleep [seconds]",description:"Delay for a specified amount of time (in seconds).",action:async({argv:i})=>{const r=parseInt(i[0],10);if(isNaN(r)||r<=0)throw"invalid time specified (minimum is 1)";await new Promise(n=>setTimeout(()=>n(),1e3*r))}}),t.set("grep",{synopsis:"grep [keyword] [context ...]",description:"Searches for matching phrases in the text",action:async({argv:i,stdout:r})=>{if(i.length<2)throw"invalid arguments";const n=new RegExp(i[0],"g");i.slice(1).forEach(o=>{n.test(o)&&r.writeln(o.replaceAll(i[0],a=>"**"+a+"**"))})}})}get alias(){return c(this,w).alias}get env(){return c(this,w).env}get history(){return c(this,w).history}set onoutput(t){if(!M(t))throw new TypeError("onoutput handler must be a function.");c(this,f).onoutput=t}set onerror(t){if(!M(t))throw new TypeError("onerror handler must be a function.");c(this,f).onerror=t}set onclear(t){if(!M(t))throw new TypeError("onclear handler must be a function.");c(this,f).onclear=t}set onexit(t){if(!M(t))throw new TypeError("onexit handler must be a function.");c(this,b).onAbort=t}addCommand(t,e){if(c(this,A).has(t))throw new Error(`${D}: '${t}' command already exists. If you are providing a custom command implementation, remove the command first.`);if(!function(i){return typeof(r=i)=="object"&&r!==null&&M(i.action)&&!!i.description&&!!i.synopsis;var r}(e))throw new Error(`${D}: invalid command configuration`);c(this,A).set(t,e)}removeCommand(t){c(this,A).delete(t)}exportState(){return JSON.stringify(c(this,w))}loadState(t){y(this,w,Object.assign(ht(),dt(t)))}init(t=""){c(this,L)||(y(this,L,!0),c(this,f).clear(),t&&(t=X(this.env,t+` +`),c(this,f).write(t)),T(this,I,V).call(this))}setExecutionTimeout(t){typeof t=="number"&&t>=0&&y(this,K,t)}async execute(t=""){if(!c(this,L))return Promise.reject(Rt);if(c(this,f).reset(),c(this,P).isBusy)return c(this,P).insert(t),Promise.resolve();if(typeof t!="string"||!t.trim())return T(this,I,V).call(this),Promise.resolve();(t=t.trim())!=this.history.at(-1)&&this.history.push(t);const e=dt(c(this,w));c(this,b).reset();const i=zt(e,c(this,P),c(this,f),c(this,b));return await function(r,n,o){function a(){return new Promise((d,u)=>{r.onAbort(m=>u(m||ct));try{n==null||n.call(void 0,d,u)}catch(m){u(m==null?void 0:m.toString())}})}if(!o)return a();let l;return Promise.race([l=a(),new Promise((d,u)=>{const m=setTimeout(()=>{r.abort(Ht)},o);function B(bt){m&&clearTimeout(m),u(bt)}l==null||l.catch(B),r.onAbort(B)})])}(c(this,b),async(r,n)=>{try{const l=Bt(t);for(const d of l){if(c(this,b).isAborted)throw ct;try{await T(this,H,q).call(this,d,i),e.env[U]="0",o=c(this,w),a=e,Object.assign(o.alias,a.alias),Object.assign(o.env,a.env),o.history.splice(0),o.history.push(...a.history)}catch(u){if(!(l.length>1))throw u;i.stderr.write(u+` +`),e.env[U]="1"}}r()}catch(l){n(l)}var o,a},c(this,K)).catch(r=>{c(this,f).error(r+` +`),c(this,w).env[U]="1"}).finally(()=>{T(this,I,V).call(this)})}abort(t){c(this,b).abort(t)}static get version(){return Q}}f=new WeakMap,P=new WeakMap,w=new WeakMap,A=new WeakMap,L=new WeakMap,b=new WeakMap,K=new WeakMap,I=new WeakSet,V=function(){this.env[lt]=""+Z(),c(this,b).reset(),c(this,f).reset(),c(this,f).write(X(this.env,this.env.PS1))},H=new WeakSet,q=async function(t,e){const i=this.alias[t.cmd];if(i){const o=i.split(" ");t.cmd=o.shift()||"",o.length&&t.argv.unshift(...o),t.args=(t.cmd+" "+t.argv.join(" ")).trim()}const r=c(this,A).get(t.cmd);if(!r)throw t.cmd+": command not found";e.cmd=t.cmd,e.argv=t.argv,e.env[lt]=""+Z(),c(this,f).bufferOutput=t.PIPE!==void 0;let n="";try{await r.action.call(void 0,e),t.PIPE&&(t.PIPE.argv.push(...c(this,f).extract),await T(this,H,q).call(this,t.PIPE,e))}catch(o){n=t.cmd+": "+o}if(t.OR||t.AND){const o=tt(t,!n.length);o&&(n.length&&(e.stderr.writeln(n),n=""),await T(this,H,q).call(this,o,e))}if(n.length)throw n};const C=function(t,e){return function(){const i=arguments,r=arguments.length;let n=arguments[0];if(r===0)return"";if(r>1)for(let a=1;a':"")+(this.bold?"":"")+(this.underline?"":"")+(this.strikethrough?"":"")+(this.italic?"":"")+(this.value||"")+(this.italic?"":"")+(this.strikethrough?"":"")+(this.underline?"":"")+(this.bold?"":"")+(a?"":"")},toJSON(){return this.toString()}};return o[t]=e,o.value=n,o}},z={black:"#000000",red:"#FA5E5E",green:"#50FA7B",yellow:"#FEF08A",blue:"#60A5FA",magenta:"#FF79C6",cyan:"#67E8F9",white:"#FFFFFF",gray:"#71717A"},k={};k.bold=C("bold",!0);k.italic=C("italic",!0);k.underline=C("underline",!0);k.strikethrough=C("strikethrough",!0);k.dim=C("dim",!0);for(const s in z)Object.hasOwnProperty.call(z,s)&&(k[s]=C("fg",z[s]),k["bg"+s[0].toUpperCase()+s.slice(1)]=C("bg",z[s]));const{bold:Qt,italic:Wt,underline:te,strikethrough:ee,dim:Vt,black:se,red:et,green:st,yellow:ie,blue:re,magenta:ne,cyan:wt,white:oe,gray:qt,bgBlack:ae,bgRed:ce,bgGreen:le,bgYellow:ue,bgBlue:he,bgMagenta:de,bgCyan:pe,bgWhite:fe,bgGray:ge}=k,_={key:"viteshell",read(){return localStorage.getItem(this.key)},write(s){return localStorage.setItem(this.key,s)}},g=new Ut,E=new Ct;g.onoutput=s=>{E.write(st(s).toString())};g.onerror=s=>{E.write(et(s).toString())};g.onclear=E.clear.bind(E);g.onexit=()=>{_.write(g.exportState()),E.dispose.bind(E)};E.on("data",async s=>{await g.execute(s)});E.on("keypress",s=>{const t=s;t.ctrlKey&&t.key==="c"&&(t.preventDefault(),g.abort())});g.env.PS1=`${et("┌[")}${st("$USERNAME")}@${wt("$HOSTNAME")}${et(`] +└$`)} `;g.alias.println="echo";g.addCommand("login",{synopsis:"login",description:"Demo login process",async action({env:s,stdin:t,stdout:e}){e.write("Username: ");const i=await t.readline();e.write("Token: ");const r=await t.readline();e.write("Logging in as "+wt(i)+` +`),s.USERNAME=i,s.TOKEN=r}});function Jt(){return`
+ + +${st("WELCOME TO THE COMMAND LINE INTERFACE")} + +${Vt(Wt("powered by")+"")} + +${qt(`ViteShell ~ Inken ~ XTerminal +`)} +
`}E.on("clear",()=>E.write(Jt()));E.mount("#app");window.onload=()=>{const s=_.read();s?g.loadState(s):_.write(g.exportState()),g.init()};window.onunload=()=>{_.write(g.exportState())}; diff --git a/assets/index-232722d1.css b/assets/index-oWf9XcRm.css similarity index 100% rename from assets/index-232722d1.css rename to assets/index-oWf9XcRm.css diff --git a/index.html b/index.html index 464eb63..e5a31a4 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,10 @@ XTERMINAL | INKEN | VITESHELL - - + +
- \ No newline at end of file