create-leo-app 0.0.13
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/README.md +36 -0
- package/dist/index.mjs +52 -0
- package/index.js +3 -0
- package/package.json +34 -0
- package/template-extension/.gitignore +2 -0
- package/template-extension/README.md +4 -0
- package/template-extension/package.json +15 -0
- package/template-extension/rollup.config.js +21 -0
- package/template-extension/src/offscreen.js +1 -0
- package/template-extension/src/service_worker.js +20 -0
- package/template-extension/src/worker.js +34 -0
- package/template-extension/static/manifest.json +16 -0
- package/template-extension/static/offscreen.html +9 -0
- package/template-nextjs-ts/README.md +19 -0
- package/template-nextjs-ts/_gitignore +35 -0
- package/template-nextjs-ts/next-env.d.ts +5 -0
- package/template-nextjs-ts/next.config.js +32 -0
- package/template-nextjs-ts/package.json +24 -0
- package/template-nextjs-ts/public/aleo.svg +8 -0
- package/template-nextjs-ts/public/next.svg +1 -0
- package/template-nextjs-ts/src/app/favicon.ico +0 -0
- package/template-nextjs-ts/src/app/globals.css +126 -0
- package/template-nextjs-ts/src/app/layout.tsx +22 -0
- package/template-nextjs-ts/src/app/page.module.css +160 -0
- package/template-nextjs-ts/src/app/page.tsx +94 -0
- package/template-nextjs-ts/src/app/worker.ts +47 -0
- package/template-nextjs-ts/tsconfig.json +27 -0
- package/template-node/README.md +5 -0
- package/template-node/_gitignore +24 -0
- package/template-node/index.js +59 -0
- package/template-node/package.json +12 -0
- package/template-node-ts/README.md +5 -0
- package/template-node-ts/_gitignore +24 -0
- package/template-node-ts/package.json +19 -0
- package/template-node-ts/rollup.config.js +19 -0
- package/template-node-ts/src/index.ts +66 -0
- package/template-node-ts/tsconfig.json +15 -0
- package/template-offline-public-transaction-ts/README.md +52 -0
- package/template-offline-public-transaction-ts/_gitignore +24 -0
- package/template-offline-public-transaction-ts/package.json +19 -0
- package/template-offline-public-transaction-ts/rollup.config.js +19 -0
- package/template-offline-public-transaction-ts/src/helpers.ts +70 -0
- package/template-offline-public-transaction-ts/src/index.ts +171 -0
- package/template-offline-public-transaction-ts/tsconfig.json +15 -0
- package/template-react-leo/.babelrc +6 -0
- package/template-react-leo/.eslintrc.cjs +20 -0
- package/template-react-leo/README.md +90 -0
- package/template-react-leo/_gitignore +24 -0
- package/template-react-leo/_headers +3 -0
- package/template-react-leo/helloworld/.env.example +2 -0
- package/template-react-leo/helloworld/.gitignore +5 -0
- package/template-react-leo/helloworld/README.md +13 -0
- package/template-react-leo/helloworld/build/main.aleo +7 -0
- package/template-react-leo/helloworld/build/program.json +6 -0
- package/template-react-leo/helloworld/inputs/helloworld.in +4 -0
- package/template-react-leo/helloworld/program.json +6 -0
- package/template-react-leo/helloworld/src/main.leo +7 -0
- package/template-react-leo/index.html +88 -0
- package/template-react-leo/install.sh +30 -0
- package/template-react-leo/package.json +44 -0
- package/template-react-leo/public/favicon.ico +0 -0
- package/template-react-leo/src/App.css +42 -0
- package/template-react-leo/src/App.jsx +103 -0
- package/template-react-leo/src/assets/aleo.svg +5 -0
- package/template-react-leo/src/assets/react.svg +1 -0
- package/template-react-leo/src/index.css +69 -0
- package/template-react-leo/src/main.jsx +10 -0
- package/template-react-leo/src/workers/AleoWorker.js +20 -0
- package/template-react-leo/src/workers/worker.js +72 -0
- package/template-react-leo/vite.config.js +16 -0
- package/template-react-leo/webpack.config.js +102 -0
- package/template-react-managed-worker/.babelrc +6 -0
- package/template-react-managed-worker/.eslintrc.cjs +20 -0
- package/template-react-managed-worker/README.md +8 -0
- package/template-react-managed-worker/_gitignore +24 -0
- package/template-react-managed-worker/index.html +88 -0
- package/template-react-managed-worker/package.json +41 -0
- package/template-react-managed-worker/public/favicon.ico +0 -0
- package/template-react-managed-worker/src/App.css +42 -0
- package/template-react-managed-worker/src/App.jsx +78 -0
- package/template-react-managed-worker/src/assets/aleo.png +0 -0
- package/template-react-managed-worker/src/assets/react.svg +1 -0
- package/template-react-managed-worker/src/index.css +69 -0
- package/template-react-managed-worker/src/main.jsx +10 -0
- package/template-react-managed-worker/vite.config.js +20 -0
- package/template-react-managed-worker/webpack.config.js +90 -0
- package/template-react-ts/.babelrc +7 -0
- package/template-react-ts/.eslintrc.cjs +20 -0
- package/template-react-ts/README.md +90 -0
- package/template-react-ts/_gitignore +24 -0
- package/template-react-ts/_headers +3 -0
- package/template-react-ts/helloworld/.env.example +2 -0
- package/template-react-ts/helloworld/.gitignore +5 -0
- package/template-react-ts/helloworld/README.md +13 -0
- package/template-react-ts/helloworld/build/main.aleo +7 -0
- package/template-react-ts/helloworld/build/program.json +6 -0
- package/template-react-ts/helloworld/inputs/helloworld.in +4 -0
- package/template-react-ts/helloworld/program.json +6 -0
- package/template-react-ts/helloworld/src/main.leo +7 -0
- package/template-react-ts/index.html +88 -0
- package/template-react-ts/install.sh +30 -0
- package/template-react-ts/package.json +49 -0
- package/template-react-ts/public/favicon.ico +0 -0
- package/template-react-ts/src/App.css +42 -0
- package/template-react-ts/src/App.tsx +103 -0
- package/template-react-ts/src/assets/aleo.svg +5 -0
- package/template-react-ts/src/assets/react.svg +1 -0
- package/template-react-ts/src/custom.d.ts +16 -0
- package/template-react-ts/src/index.css +69 -0
- package/template-react-ts/src/main.tsx +10 -0
- package/template-react-ts/src/workers/AleoWorker.ts +21 -0
- package/template-react-ts/src/workers/worker.ts +73 -0
- package/template-react-ts/tsconfig.json +16 -0
- package/template-react-ts/vite.config.ts +16 -0
- package/template-react-ts/webpack.config.ts +112 -0
- package/template-vanilla/_gitignore +24 -0
- package/template-vanilla/_headers +3 -0
- package/template-vanilla/index.html +13 -0
- package/template-vanilla/javascript.svg +1 -0
- package/template-vanilla/main.js +48 -0
- package/template-vanilla/package.json +16 -0
- package/template-vanilla/public/aleo.svg +76 -0
- package/template-vanilla/public/vite.svg +1 -0
- package/template-vanilla/style.css +97 -0
- package/template-vanilla/vite.config.js +12 -0
- package/template-vanilla/worker.js +95 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# create-leo-app
|
|
2
|
+
|
|
3
|
+
## Scaffolding Your First Aleo Project
|
|
4
|
+
|
|
5
|
+
> **Compatibility Note:**
|
|
6
|
+
> Please use [Node.js](https://nodejs.org/en/) version 18+
|
|
7
|
+
|
|
8
|
+
With NPM:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm create leo-app@latest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then follow the prompts!
|
|
15
|
+
|
|
16
|
+
You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold an Aleo + React project, run:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# npm 6.x
|
|
20
|
+
npm create leo-app@latest my-leo-app --template react
|
|
21
|
+
|
|
22
|
+
# npm 7+, extra double-dash is needed:
|
|
23
|
+
npm create leo-app@latest my-leo-app -- --template react
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Currently supported template presets include:
|
|
27
|
+
|
|
28
|
+
- `Vanilla`
|
|
29
|
+
- `React (JavaScript + Leo, React + TypeScript, or TypeScript + Next.js)`
|
|
30
|
+
- `Node.js`
|
|
31
|
+
|
|
32
|
+
You can use `.` for the project name to scaffold in the current directory.
|
|
33
|
+
|
|
34
|
+
## More Information
|
|
35
|
+
|
|
36
|
+
Based off of create-vite: https://github.com/vitejs/vite/tree/main/packages/create-vite
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import S from"node:fs";import O from"node:path";import{fileURLToPath as le}from"node:url";import he from"readline";import ae from"events";function xt(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function ue(s,t){var e=s;t.slice(0,-1).forEach(function(n){e=e[n]||{}});var i=t[t.length-1];return i in e}function St(s){return typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function Ot(s,t){return t==="constructor"&&typeof s[t]=="function"||t==="__proto__"}var ce=function(s,t){t||(t={});var e={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(e.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?e.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(u){e.bools[u]=!0});var i={};function n(u){return i[u].some(function(y){return e.bools[y]})}Object.keys(t.alias||{}).forEach(function(u){i[u]=[].concat(t.alias[u]),i[u].forEach(function(y){i[y]=[u].concat(i[u].filter(function(_){return y!==_}))})}),[].concat(t.string).filter(Boolean).forEach(function(u){e.strings[u]=!0,i[u]&&[].concat(i[u]).forEach(function(y){e.strings[y]=!0})});var o=t.default||{},r={_:[]};function h(u,y){return e.allBools&&/^--[^=]+$/.test(y)||e.strings[u]||e.bools[u]||i[u]}function v(u,y,_){for(var p=u,G=0;G<y.length-1;G++){var D=y[G];if(Ot(p,D))return;p[D]===void 0&&(p[D]={}),(p[D]===Object.prototype||p[D]===Number.prototype||p[D]===String.prototype)&&(p[D]={}),p[D]===Array.prototype&&(p[D]=[]),p=p[D]}var R=y[y.length-1];Ot(p,R)||((p===Object.prototype||p===Number.prototype||p===String.prototype)&&(p={}),p===Array.prototype&&(p=[]),p[R]===void 0||e.bools[R]||typeof p[R]=="boolean"?p[R]=_:Array.isArray(p[R])?p[R].push(_):p[R]=[p[R],_])}function l(u,y,_){if(!(_&&e.unknownFn&&!h(u,_)&&e.unknownFn(_)===!1)){var p=!e.strings[u]&&St(y)?Number(y):y;v(r,u.split("."),p),(i[u]||[]).forEach(function(G){v(r,G.split("."),p)})}}Object.keys(e.bools).forEach(function(u){l(u,o[u]===void 0?!1:o[u])});var T=[];s.indexOf("--")!==-1&&(T=s.slice(s.indexOf("--")+1),s=s.slice(0,s.indexOf("--")));for(var g=0;g<s.length;g++){var a=s[g],c,$;if(/^--.+=/.test(a)){var C=a.match(/^--([^=]+)=([\s\S]*)$/);c=C[1];var U=C[2];e.bools[c]&&(U=U!=="false"),l(c,U,a)}else if(/^--no-.+/.test(a))c=a.match(/^--no-(.+)/)[1],l(c,!1,a);else if(/^--.+/.test(a))c=a.match(/^--(.+)/)[1],$=s[g+1],$!==void 0&&!/^(-|--)[^-]/.test($)&&!e.bools[c]&&!e.allBools&&(!i[c]||!n(c))?(l(c,$,a),g+=1):/^(true|false)$/.test($)?(l(c,$==="true",a),g+=1):l(c,e.strings[c]?"":!0,a);else if(/^-[^-]+/.test(a)){for(var x=a.slice(1,-1).split(""),m=!1,f=0;f<x.length;f++){if($=a.slice(f+2),$==="-"){l(x[f],$,a);continue}if(/[A-Za-z]/.test(x[f])&&$[0]==="="){l(x[f],$.slice(1),a),m=!0;break}if(/[A-Za-z]/.test(x[f])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test($)){l(x[f],$,a),m=!0;break}if(x[f+1]&&x[f+1].match(/\W/)){l(x[f],a.slice(f+2),a),m=!0;break}else l(x[f],e.strings[x[f]]?"":!0,a)}c=a.slice(-1)[0],!m&&c!=="-"&&(s[g+1]&&!/^(-|--)[^-]/.test(s[g+1])&&!e.bools[c]&&(!i[c]||!n(c))?(l(c,s[g+1],a),g+=1):s[g+1]&&/^(true|false)$/.test(s[g+1])?(l(c,s[g+1]==="true",a),g+=1):l(c,e.strings[c]?"":!0,a))}else if((!e.unknownFn||e.unknownFn(a)!==!1)&&r._.push(e.strings._||!St(a)?a:Number(a)),t.stopEarly){r._.push.apply(r._,s.slice(g+1));break}}return Object.keys(o).forEach(function(u){ue(r,u.split("."))||(v(r,u.split("."),o[u]),(i[u]||[]).forEach(function(y){v(r,y.split("."),o[u])}))}),t["--"]?r["--"]=T.slice():T.forEach(function(u){r._.push(u)}),r};const de=xt(ce);var Mt={};const{FORCE_COLOR:fe,NODE_DISABLE_COLORS:pe,TERM:me}=process.env,d={enabled:!pe&&me!=="dumb"&&fe!=="0",reset:b(0,0),bold:b(1,22),dim:b(2,22),italic:b(3,23),underline:b(4,24),inverse:b(7,27),hidden:b(8,28),strikethrough:b(9,29),black:b(30,39),red:b(31,39),green:b(32,39),yellow:b(33,39),blue:b(34,39),magenta:b(35,39),cyan:b(36,39),white:b(37,39),gray:b(90,39),grey:b(90,39),bgBlack:b(40,49),bgRed:b(41,49),bgGreen:b(42,49),bgYellow:b(43,49),bgBlue:b(44,49),bgMagenta:b(45,49),bgCyan:b(46,49),bgWhite:b(47,49)};function Pt(s,t){let e=0,i,n="",o="";for(;e<s.length;e++)i=s[e],n+=i.open,o+=i.close,t.includes(i.close)&&(t=t.replace(i.rgx,i.close+i.open));return n+t+o}function ge(s,t){let e={has:s,keys:t};return e.reset=d.reset.bind(e),e.bold=d.bold.bind(e),e.dim=d.dim.bind(e),e.italic=d.italic.bind(e),e.underline=d.underline.bind(e),e.inverse=d.inverse.bind(e),e.hidden=d.hidden.bind(e),e.strikethrough=d.strikethrough.bind(e),e.black=d.black.bind(e),e.red=d.red.bind(e),e.green=d.green.bind(e),e.yellow=d.yellow.bind(e),e.blue=d.blue.bind(e),e.magenta=d.magenta.bind(e),e.cyan=d.cyan.bind(e),e.white=d.white.bind(e),e.gray=d.gray.bind(e),e.grey=d.grey.bind(e),e.bgBlack=d.bgBlack.bind(e),e.bgRed=d.bgRed.bind(e),e.bgGreen=d.bgGreen.bind(e),e.bgYellow=d.bgYellow.bind(e),e.bgBlue=d.bgBlue.bind(e),e.bgMagenta=d.bgMagenta.bind(e),e.bgCyan=d.bgCyan.bind(e),e.bgWhite=d.bgWhite.bind(e),e}function b(s,t){let e={open:`\x1B[${s}m`,close:`\x1B[${t}m`,rgx:new RegExp(`\\x1b\\[${t}m`,"g")};return function(i){return this!==void 0&&this.has!==void 0?(this.has.includes(s)||(this.has.push(s),this.keys.push(e)),i===void 0?this:d.enabled?Pt(this.keys,i+""):i+""):i===void 0?ge([s],[e]):d.enabled?Pt([e],i+""):i+""}}var M=d,be=(s,t)=>{if(!(s.meta&&s.name!=="escape")){if(s.ctrl){if(s.name==="a")return"first";if(s.name==="c"||s.name==="d")return"abort";if(s.name==="e")return"last";if(s.name==="g")return"reset"}if(t){if(s.name==="j")return"down";if(s.name==="k")return"up"}return s.name==="return"||s.name==="enter"?"submit":s.name==="backspace"?"delete":s.name==="delete"?"deleteForward":s.name==="abort"?"abort":s.name==="escape"?"exit":s.name==="tab"?"next":s.name==="pagedown"?"nextPage":s.name==="pageup"?"prevPage":s.name==="home"?"home":s.name==="end"?"end":s.name==="up"?"up":s.name==="down"?"down":s.name==="right"?"right":s.name==="left"?"left":!1}},nt=s=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),e=new RegExp(t,"g");return typeof s=="string"?s.replace(e,""):s};const ot="\x1B",w=`${ot}[`,ve="\x07",lt={to(s,t){return t?`${w}${t+1};${s+1}H`:`${w}${s+1}G`},move(s,t){let e="";return s<0?e+=`${w}${-s}D`:s>0&&(e+=`${w}${s}C`),t<0?e+=`${w}${-t}A`:t>0&&(e+=`${w}${t}B`),e},up:(s=1)=>`${w}${s}A`,down:(s=1)=>`${w}${s}B`,forward:(s=1)=>`${w}${s}C`,backward:(s=1)=>`${w}${s}D`,nextLine:(s=1)=>`${w}E`.repeat(s),prevLine:(s=1)=>`${w}F`.repeat(s),left:`${w}G`,hide:`${w}?25l`,show:`${w}?25h`,save:`${ot}7`,restore:`${ot}8`},we={up:(s=1)=>`${w}S`.repeat(s),down:(s=1)=>`${w}T`.repeat(s)},$e={screen:`${w}2J`,up:(s=1)=>`${w}1J`.repeat(s),down:(s=1)=>`${w}J`.repeat(s),line:`${w}2K`,lineEnd:`${w}K`,lineStart:`${w}1K`,lines(s){let t="";for(let e=0;e<s;e++)t+=this.line+(e<s-1?lt.up():"");return s&&(t+=lt.left),t}};var P={cursor:lt,scroll:we,erase:$e,beep:ve};const ye=nt,{erase:Tt,cursor:xe}=P,Se=s=>[...ye(s)].length;var Oe=function(s,t){if(!t)return Tt.line+xe.to(0);let e=0;const i=s.split(/\r?\n/);for(let n of i)e+=1+Math.floor(Math.max(Se(n)-1,0)/t);return Tt.lines(e)};const K={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},Me={arrowUp:K.arrowUp,arrowDown:K.arrowDown,arrowLeft:K.arrowLeft,arrowRight:K.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},Pe=process.platform==="win32"?Me:K;var Ct=Pe;const k=M,H=Ct,ht=Object.freeze({password:{scale:1,render:s=>"*".repeat(s.length)},emoji:{scale:2,render:s=>"\u{1F603}".repeat(s.length)},invisible:{scale:0,render:s=>""},default:{scale:1,render:s=>`${s}`}}),Te=s=>ht[s]||ht.default,W=Object.freeze({aborted:k.red(H.cross),done:k.green(H.tick),exited:k.yellow(H.cross),default:k.cyan("?")}),Ce=(s,t,e)=>t?W.aborted:e?W.exited:s?W.done:W.default,De=s=>k.gray(s?H.ellipsis:H.pointerSmall),Ee=(s,t)=>k.gray(s?t?H.pointerSmall:"+":H.line);var Ie={styles:ht,render:Te,symbols:W,symbol:Ce,delimiter:De,item:Ee};const _e=nt;var Re=function(s,t){let e=String(_e(s)||"").split(/\r?\n/);return t?e.map(i=>Math.ceil(i.length/t)).reduce((i,n)=>i+n):e.length},Ae=(s,t={})=>{const e=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",i=t.width;return(s||"").split(/\r?\n/g).map(n=>n.split(/\s+/g).reduce((o,r)=>(r.length+e.length>=i||o[o.length-1].length+r.length+1<i?o[o.length-1]+=` ${r}`:o.push(`${e}${r}`),o),[e]).join(`
|
|
2
|
+
`)).join(`
|
|
3
|
+
`)},je=(s,t,e)=>{e=e||t;let i=Math.min(t-e,s-Math.floor(e/2));i<0&&(i=0);let n=Math.min(i+e,t);return{startIndex:i,endIndex:n}},E={action:be,clear:Oe,style:Ie,strip:nt,figures:Ct,lines:Re,wrap:Ae,entriesToDisplay:je};const Dt=he,{action:Fe}=E,Ne=ae,{beep:Le,cursor:Ye}=P,He=M;let Ve=class extends Ne{constructor(t={}){super(),this.firstRender=!0,this.in=t.stdin||process.stdin,this.out=t.stdout||process.stdout,this.onRender=(t.onRender||(()=>{})).bind(this);const e=Dt.createInterface({input:this.in,escapeCodeTimeout:50});Dt.emitKeypressEvents(this.in,e),this.in.isTTY&&this.in.setRawMode(!0);const i=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,n=(o,r)=>{let h=Fe(r,i);h===!1?this._&&this._(o,r):typeof this[h]=="function"?this[h](r):this.bell()};this.close=()=>{this.out.write(Ye.show),this.in.removeListener("keypress",n),this.in.isTTY&&this.in.setRawMode(!1),e.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",n)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Le)}render(){this.onRender(He),this.firstRender&&(this.firstRender=!1)}};var N=Ve;const tt=M,Be=N,{erase:Ue,cursor:Z}=P,{style:at,clear:ut,lines:ke,figures:Je}=E;class ze extends Be{constructor(t={}){super(t),this.transform=at.render(t.style),this.scale=this.transform.scale,this.msg=t.message,this.initial=t.initial||"",this.validator=t.validate||(()=>!0),this.value="",this.errorMsg=t.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=ut("",this.out.columns),this.render()}set value(t){!t&&this.initial?(this.placeholder=!0,this.rendered=tt.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(t)),this._value=t,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
4
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
5
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(t){this.placeholder||(this.cursor=this.cursor+t,this.cursorOffset+=t)}_(t,e){let i=this.value.slice(0,this.cursor),n=this.value.slice(this.cursor);this.value=`${i}${t}${n}`,this.red=!1,this.cursor=this.placeholder?0:i.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let t=this.value.slice(0,this.cursor-1),e=this.value.slice(this.cursor);this.value=`${t}${e}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let t=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor+1);this.value=`${t}${e}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(Z.down(ke(this.outputError,this.out.columns)-1)+ut(this.outputError,this.out.columns)),this.out.write(ut(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[at.symbol(this.done,this.aborted),tt.bold(this.msg),at.delimiter(this.done),this.red?tt.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
6
|
+
`).reduce((t,e,i)=>t+`
|
|
7
|
+
${i?" ":Je.pointerSmall} ${tt.red().italic(e)}`,"")),this.out.write(Ue.line+Z.to(0)+this.outputText+Z.save+this.outputError+Z.restore+Z.move(this.cursorOffset,0)))}}var Ge=ze;const A=M,Ke=N,{style:Et,clear:It,figures:et,wrap:We,entriesToDisplay:Ze}=E,{cursor:qe}=P;class Xe extends Ke{constructor(t={}){super(t),this.msg=t.message,this.hint=t.hint||"- Use arrow-keys. Return to submit.",this.warn=t.warn||"- This option is disabled",this.cursor=t.initial||0,this.choices=t.choices.map((e,i)=>(typeof e=="string"&&(e={title:e,value:i}),{title:e&&(e.title||e.value||e),value:e&&(e.value===void 0?i:e.value),description:e&&e.description,selected:e&&e.selected,disabled:e&&e.disabled})),this.optionsPerPage=t.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=It("",this.out.columns),this.render()}moveCursor(t){this.cursor=t,this.value=this.choices[t].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
8
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
9
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(t,e){if(t===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(qe.hide):this.out.write(It(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:e}=Ze(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[Et.symbol(this.done,this.aborted),A.bold(this.msg),Et.delimiter(!1),this.done?this.selection.title:this.selection.disabled?A.yellow(this.warn):A.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
10
|
+
`;for(let i=t;i<e;i++){let n,o,r="",h=this.choices[i];i===t&&t>0?o=et.arrowUp:i===e-1&&e<this.choices.length?o=et.arrowDown:o=" ",h.disabled?(n=this.cursor===i?A.gray().underline(h.title):A.strikethrough().gray(h.title),o=(this.cursor===i?A.bold().gray(et.pointer)+" ":" ")+o):(n=this.cursor===i?A.cyan().underline(h.title):h.title,o=(this.cursor===i?A.cyan(et.pointer)+" ":" ")+o,h.description&&this.cursor===i&&(r=` - ${h.description}`,(o.length+n.length+r.length>=this.out.columns||h.description.split(/\r?\n/).length>1)&&(r=`
|
|
11
|
+
`+We(h.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${n}${A.gray(r)}
|
|
12
|
+
`}}this.out.write(this.outputText)}}var Qe=Xe;const st=M,ts=N,{style:_t,clear:es}=E,{cursor:Rt,erase:ss}=P;class is extends ts{constructor(t={}){super(t),this.msg=t.message,this.value=!!t.initial,this.active=t.active||"on",this.inactive=t.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
13
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
14
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(t,e){if(t===" ")this.value=!this.value;else if(t==="1")this.value=!0;else if(t==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Rt.hide):this.out.write(es(this.outputText,this.out.columns)),super.render(),this.outputText=[_t.symbol(this.done,this.aborted),st.bold(this.msg),_t.delimiter(this.done),this.value?this.inactive:st.cyan().underline(this.inactive),st.gray("/"),this.value?st.cyan().underline(this.active):this.active].join(" "),this.out.write(ss.line+Rt.to(0)+this.outputText))}}var rs=is;let ns=class yt{constructor({token:t,date:e,parts:i,locales:n}){this.token=t,this.date=e||new Date,this.parts=i||[this],this.locales=n||{}}up(){}down(){}next(){const t=this.parts.indexOf(this);return this.parts.find((e,i)=>i>t&&e instanceof yt)}setTo(t){}prev(){let t=[].concat(this.parts).reverse();const e=t.indexOf(this);return t.find((i,n)=>n>e&&i instanceof yt)}toString(){return String(this.date)}};var j=ns;const os=j;let ls=class extends os{constructor(t={}){super(t)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let t=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?t.toUpperCase():t}};var hs=ls;const as=j,us=s=>(s=s%10,s===1?"st":s===2?"nd":s===3?"rd":"th");let cs=class extends as{constructor(t={}){super(t)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(t){this.date.setDate(parseInt(t.substr(-2)))}toString(){let t=this.date.getDate(),e=this.date.getDay();return this.token==="DD"?String(t).padStart(2,"0"):this.token==="Do"?t+us(t):this.token==="d"?e+1:this.token==="ddd"?this.locales.weekdaysShort[e]:this.token==="dddd"?this.locales.weekdays[e]:t}};var ds=cs;const fs=j;let ps=class extends fs{constructor(t={}){super(t)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(t){this.date.setHours(parseInt(t.substr(-2)))}toString(){let t=this.date.getHours();return/h/.test(this.token)&&(t=t%12||12),this.token.length>1?String(t).padStart(2,"0"):t}};var ms=ps;const gs=j;let bs=class extends gs{constructor(t={}){super(t)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(t){this.date.setMilliseconds(parseInt(t.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};var vs=bs;const ws=j;let $s=class extends ws{constructor(t={}){super(t)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(t){this.date.setMinutes(parseInt(t.substr(-2)))}toString(){let t=this.date.getMinutes();return this.token.length>1?String(t).padStart(2,"0"):t}};var ys=$s;const xs=j;let Ss=class extends xs{constructor(t={}){super(t)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(t){t=parseInt(t.substr(-2))-1,this.date.setMonth(t<0?0:t)}toString(){let t=this.date.getMonth(),e=this.token.length;return e===2?String(t+1).padStart(2,"0"):e===3?this.locales.monthsShort[t]:e===4?this.locales.months[t]:String(t+1)}};var Os=Ss;const Ms=j;let Ps=class extends Ms{constructor(t={}){super(t)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(t){this.date.setSeconds(parseInt(t.substr(-2)))}toString(){let t=this.date.getSeconds();return this.token.length>1?String(t).padStart(2,"0"):t}};var Ts=Ps;const Cs=j;let Ds=class extends Cs{constructor(t={}){super(t)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(t){this.date.setFullYear(t.substr(-4))}toString(){let t=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?t.substr(-2):t}};var Es=Ds,Is={DatePart:j,Meridiem:hs,Day:ds,Hours:ms,Milliseconds:vs,Minutes:ys,Month:Os,Seconds:Ts,Year:Es};const ct=M,_s=N,{style:At,clear:jt,figures:Rs}=E,{erase:As,cursor:Ft}=P,{DatePart:Nt,Meridiem:js,Day:Fs,Hours:Ns,Milliseconds:Ls,Minutes:Ys,Month:Hs,Seconds:Vs,Year:Bs}=Is,Us=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,Lt={1:({token:s})=>s.replace(/\\(.)/g,"$1"),2:s=>new Fs(s),3:s=>new Hs(s),4:s=>new Bs(s),5:s=>new js(s),6:s=>new Ns(s),7:s=>new Ys(s),8:s=>new Vs(s),9:s=>new Ls(s)},ks={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class Js extends _s{constructor(t={}){super(t),this.msg=t.message,this.cursor=0,this.typed="",this.locales=Object.assign(ks,t.locales),this._date=t.initial||new Date,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.mask=t.mask||"YYYY-MM-DD HH:mm:ss",this.clear=jt("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(t){t&&this._date.setTime(t.getTime())}set mask(t){let e;for(this.parts=[];e=Us.exec(t);){let n=e.shift(),o=e.findIndex(r=>r!=null);this.parts.push(o in Lt?Lt[o]({token:e[o]||n,date:this.date,parts:this.parts,locales:this.locales}):e[o]||n)}let i=this.parts.reduce((n,o)=>(typeof o=="string"&&typeof n[n.length-1]=="string"?n[n.length-1]+=o:n.push(o),n),[]);this.parts.splice(0),this.parts.push(...i),this.reset()}moveCursor(t){this.typed="",this.cursor=t,this.fire()}reset(){this.moveCursor(this.parts.findIndex(t=>t instanceof Nt)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
15
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
16
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let t=this.parts[this.cursor].prev();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}right(){let t=this.parts[this.cursor].next();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}next(){let t=this.parts[this.cursor].next();this.moveCursor(t?this.parts.indexOf(t):this.parts.findIndex(e=>e instanceof Nt)),this.render()}_(t){/\d/.test(t)&&(this.typed+=t,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(Ft.hide):this.out.write(jt(this.outputText,this.out.columns)),super.render(),this.outputText=[At.symbol(this.done,this.aborted),ct.bold(this.msg),At.delimiter(!1),this.parts.reduce((t,e,i)=>t.concat(i===this.cursor&&!this.done?ct.cyan().underline(e.toString()):e),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
17
|
+
`).reduce((t,e,i)=>t+`
|
|
18
|
+
${i?" ":Rs.pointerSmall} ${ct.red().italic(e)}`,"")),this.out.write(As.line+Ft.to(0)+this.outputText))}}var zs=Js;const it=M,Gs=N,{cursor:rt,erase:Ks}=P,{style:dt,figures:Ws,clear:Yt,lines:Zs}=E,qs=/[0-9]/,ft=s=>s!==void 0,Ht=(s,t)=>{let e=Math.pow(10,t);return Math.round(s*e)/e};class Xs extends Gs{constructor(t={}){super(t),this.transform=dt.render(t.style),this.msg=t.message,this.initial=ft(t.initial)?t.initial:"",this.float=!!t.float,this.round=t.round||2,this.inc=t.increment||1,this.min=ft(t.min)?t.min:-1/0,this.max=ft(t.max)?t.max:1/0,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(t){!t&&t!==0?(this.placeholder=!0,this.rendered=it.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${Ht(t,this.round)}`),this._value=Ht(t,this.round)),this.fire()}get value(){return this._value}parse(t){return this.float?parseFloat(t):parseInt(t)}valid(t){return t==="-"||t==="."&&this.float||qs.test(t)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let t=this.value;this.value=t!==""?t:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
19
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let t=this.value;this.value=t!==""?t:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
20
|
+
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let t=this.value.toString();if(t.length===0)return this.bell();this.value=this.parse(t=t.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(t,e){if(!this.valid(t))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=t,this.lastHit=i,this.color="cyan",t===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(rt.down(Zs(this.outputError,this.out.columns)-1)+Yt(this.outputError,this.out.columns)),this.out.write(Yt(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[dt.symbol(this.done,this.aborted),it.bold(this.msg),dt.delimiter(this.done),!this.done||!this.done&&!this.placeholder?it[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
21
|
+
`).reduce((t,e,i)=>t+`
|
|
22
|
+
${i?" ":Ws.pointerSmall} ${it.red().italic(e)}`,"")),this.out.write(Ks.line+rt.to(0)+this.outputText+rt.save+this.outputError+rt.restore))}}var Qs=Xs;const I=M,{cursor:ti}=P,ei=N,{clear:Vt,figures:L,style:Bt,wrap:si,entriesToDisplay:ii}=E;let ri=class extends ei{constructor(t={}){super(t),this.msg=t.message,this.cursor=t.cursor||0,this.scrollIndex=t.cursor||0,this.hint=t.hint||"",this.warn=t.warn||"- This option is disabled -",this.minSelected=t.min,this.showMinError=!1,this.maxChoices=t.max,this.instructions=t.instructions,this.optionsPerPage=t.optionsPerPage||10,this.value=t.choices.map((e,i)=>(typeof e=="string"&&(e={title:e,value:i}),{title:e&&(e.title||e.value||e),description:e&&e.description,value:e&&(e.value===void 0?i:e.value),selected:e&&e.selected,disabled:e&&e.disabled})),this.clear=Vt("",this.out.columns),t.overrideRender||this.render()}reset(){this.value.map(t=>!t.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(t=>t.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
23
|
+
`),this.close()}submit(){const t=this.value.filter(e=>e.selected);this.minSelected&&t.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
24
|
+
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const t=this.value[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const t=!this.value[this.cursor].selected;this.value.filter(e=>!e.disabled).forEach(e=>e.selected=t),this.render()}_(t,e){if(t===" ")this.handleSpaceToggle();else if(t==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
25
|
+
Instructions:
|
|
26
|
+
${L.arrowUp}/${L.arrowDown}: Highlight option
|
|
27
|
+
${L.arrowLeft}/${L.arrowRight}/[space]: Toggle selection
|
|
28
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
29
|
+
`:"")+" enter/return: Complete answer":""}renderOption(t,e,i,n){const o=(e.selected?I.green(L.radioOn):L.radioOff)+" "+n+" ";let r,h;return e.disabled?r=t===i?I.gray().underline(e.title):I.strikethrough().gray(e.title):(r=t===i?I.cyan().underline(e.title):e.title,t===i&&e.description&&(h=` - ${e.description}`,(o.length+r.length+h.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(h=`
|
|
30
|
+
`+si(e.description,{margin:o.length,width:this.out.columns})))),o+r+I.gray(h||"")}paginateOptions(t){if(t.length===0)return I.red("No matches for this query.");let{startIndex:e,endIndex:i}=ii(this.cursor,t.length,this.optionsPerPage),n,o=[];for(let r=e;r<i;r++)r===e&&e>0?n=L.arrowUp:r===i-1&&i<t.length?n=L.arrowDown:n=" ",o.push(this.renderOption(this.cursor,t[r],r,n));return`
|
|
31
|
+
`+o.join(`
|
|
32
|
+
`)}renderOptions(t){return this.done?"":this.paginateOptions(t)}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(", ");const t=[I.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&t.push(I.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(ti.hide),super.render();let t=[Bt.symbol(this.done,this.aborted),I.bold(this.msg),Bt.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=I.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.value),this.out.write(this.clear+t),this.clear=Vt(t,this.out.columns)}};var Ut=ri;const q=M,ni=N,{erase:oi,cursor:kt}=P,{style:pt,clear:Jt,figures:mt,wrap:li,entriesToDisplay:hi}=E,zt=(s,t)=>s[t]&&(s[t].value||s[t].title||s[t]),ai=(s,t)=>s[t]&&(s[t].title||s[t].value||s[t]),ui=(s,t)=>{const e=s.findIndex(i=>i.value===t||i.title===t);return e>-1?e:void 0};class ci extends ni{constructor(t={}){super(t),this.msg=t.message,this.suggest=t.suggest,this.choices=t.choices,this.initial=typeof t.initial=="number"?t.initial:ui(t.choices,t.initial),this.select=this.initial||t.cursor||0,this.i18n={noMatches:t.noMatches||"no matches found"},this.fallback=t.fallback||this.initial,this.clearFirst=t.clearFirst||!1,this.suggestions=[],this.input="",this.limit=t.limit||10,this.cursor=0,this.transform=pt.render(t.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=Jt("",this.out.columns),this.complete(this.render),this.render()}set fallback(t){this._fb=Number.isSafeInteger(parseInt(t))?parseInt(t):t}get fallback(){let t;return typeof this._fb=="number"?t=this.choices[this._fb]:typeof this._fb=="string"&&(t={title:this._fb}),t||this._fb||{title:this.i18n.noMatches}}moveSelect(t){this.select=t,this.suggestions.length>0?this.value=zt(this.suggestions,t):this.value=this.fallback.value,this.fire()}async complete(t){const e=this.completing=this.suggest(this.input,this.choices),i=await e;if(this.completing!==e)return;this.suggestions=i.map((o,r,h)=>({title:ai(h,r),value:zt(h,r),description:o.description})),this.completing=!1;const n=Math.max(i.length-1,0);this.moveSelect(Math.min(n,this.select)),t&&t()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
33
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
34
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
35
|
+
`),this.close()}_(t,e){let i=this.input.slice(0,this.cursor),n=this.input.slice(this.cursor);this.input=`${i}${t}${n}`,this.cursor=i.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let t=this.input.slice(0,this.cursor-1),e=this.input.slice(this.cursor);this.input=`${t}${e}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let t=this.input.slice(0,this.cursor),e=this.input.slice(this.cursor+1);this.input=`${t}${e}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(t,e,i,n){let o,r=i?mt.arrowUp:n?mt.arrowDown:" ",h=e?q.cyan().underline(t.title):t.title;return r=(e?q.cyan(mt.pointer)+" ":" ")+r,t.description&&(o=` - ${t.description}`,(r.length+h.length+o.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(o=`
|
|
36
|
+
`+li(t.description,{margin:3,width:this.out.columns}))),r+" "+h+q.gray(o||"")}render(){if(this.closed)return;this.firstRender?this.out.write(kt.hide):this.out.write(Jt(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:e}=hi(this.select,this.choices.length,this.limit);if(this.outputText=[pt.symbol(this.done,this.aborted,this.exited),q.bold(this.msg),pt.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){const i=this.suggestions.slice(t,e).map((n,o)=>this.renderOption(n,this.select===o+t,o===0&&t>0,o+t===e-1&&e<this.choices.length)).join(`
|
|
37
|
+
`);this.outputText+=`
|
|
38
|
+
`+(i||q.gray(this.fallback.title))}this.out.write(oi.line+kt.to(0)+this.outputText)}}var di=ci;const F=M,{cursor:fi}=P,pi=Ut,{clear:Gt,style:Kt,figures:J}=E;class mi extends pi{constructor(t={}){t.overrideRender=!0,super(t),this.inputValue="",this.clear=Gt("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){const t=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(i=>this.inputValue?!!(typeof i.title=="string"&&i.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof i.value=="string"&&i.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const e=this.filteredOptions.findIndex(i=>i===t);this.cursor=e<0?0:e,this.render()}handleSpaceToggle(){const t=this.filteredOptions[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}handleInputChange(t){this.inputValue=this.inputValue+t,this.updateFilteredOptions()}_(t,e){t===" "?this.handleSpaceToggle():this.handleInputChange(t)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
39
|
+
Instructions:
|
|
40
|
+
${J.arrowUp}/${J.arrowDown}: Highlight option
|
|
41
|
+
${J.arrowLeft}/${J.arrowRight}/[space]: Toggle selection
|
|
42
|
+
[a,b,c]/delete: Filter choices
|
|
43
|
+
enter/return: Complete answer
|
|
44
|
+
`:""}renderCurrentInput(){return`
|
|
45
|
+
Filtered results for: ${this.inputValue?this.inputValue:F.gray("Enter something to filter")}
|
|
46
|
+
`}renderOption(t,e,i){let n;return e.disabled?n=t===i?F.gray().underline(e.title):F.strikethrough().gray(e.title):n=t===i?F.cyan().underline(e.title):e.title,(e.selected?F.green(J.radioOn):J.radioOff)+" "+n}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(", ");const t=[F.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&t.push(F.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(fi.hide),super.render();let t=[Kt.symbol(this.done,this.aborted),F.bold(this.msg),Kt.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=F.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+t),this.clear=Gt(t,this.out.columns)}}var gi=mi;const Wt=M,bi=N,{style:Zt,clear:vi}=E,{erase:wi,cursor:qt}=P;class $i extends bi{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.yesMsg=t.yes||"yes",this.yesOption=t.yesOption||"(Y/n)",this.noMsg=t.no||"no",this.noOption=t.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
47
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
48
|
+
`),this.close()}_(t,e){return t.toLowerCase()==="y"?(this.value=!0,this.submit()):t.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(qt.hide):this.out.write(vi(this.outputText,this.out.columns)),super.render(),this.outputText=[Zt.symbol(this.done,this.aborted),Wt.bold(this.msg),Zt.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Wt.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(wi.line+qt.to(0)+this.outputText))}}var yi=$i,xi={TextPrompt:Ge,SelectPrompt:Qe,TogglePrompt:rs,DatePrompt:zs,NumberPrompt:Qs,MultiselectPrompt:Ut,AutocompletePrompt:di,AutocompleteMultiselectPrompt:gi,ConfirmPrompt:yi};(function(s){const t=s,e=xi,i=r=>r;function n(r,h,v={}){return new Promise((l,T)=>{const g=new e[r](h),a=v.onAbort||i,c=v.onSubmit||i,$=v.onExit||i;g.on("state",h.onState||i),g.on("submit",C=>l(c(C))),g.on("exit",C=>l($(C))),g.on("abort",C=>T(a(C)))})}t.text=r=>n("TextPrompt",r),t.password=r=>(r.style="password",t.text(r)),t.invisible=r=>(r.style="invisible",t.text(r)),t.number=r=>n("NumberPrompt",r),t.date=r=>n("DatePrompt",r),t.confirm=r=>n("ConfirmPrompt",r),t.list=r=>{const h=r.separator||",";return n("TextPrompt",r,{onSubmit:v=>v.split(h).map(l=>l.trim())})},t.toggle=r=>n("TogglePrompt",r),t.select=r=>n("SelectPrompt",r),t.multiselect=r=>{r.choices=[].concat(r.choices||[]);const h=v=>v.filter(l=>l.selected).map(l=>l.value);return n("MultiselectPrompt",r,{onAbort:h,onSubmit:h})},t.autocompleteMultiselect=r=>{r.choices=[].concat(r.choices||[]);const h=v=>v.filter(l=>l.selected).map(l=>l.value);return n("AutocompleteMultiselectPrompt",r,{onAbort:h,onSubmit:h})};const o=(r,h)=>Promise.resolve(h.filter(v=>v.title.slice(0,r.length).toLowerCase()===r.toLowerCase()));t.autocomplete=r=>(r.suggest=r.suggest||o,r.choices=[].concat(r.choices||[]),n("AutocompletePrompt",r))})(Mt);const gt=Mt,Si=["suggest","format","onState","validate","onRender","type"],Xt=()=>{};async function Y(s=[],{onSubmit:t=Xt,onCancel:e=Xt}={}){const i={},n=Y._override||{};s=[].concat(s);let o,r,h,v,l,T;const g=async(a,c,$=!1)=>{if(!(!$&&a.validate&&a.validate(c)!==!0))return a.format?await a.format(c,i):c};for(r of s)if({name:v,type:l}=r,typeof l=="function"&&(l=await l(o,{...i},r),r.type=l),!!l){for(let a in r){if(Si.includes(a))continue;let c=r[a];r[a]=typeof c=="function"?await c(o,{...i},T):c}if(T=r,typeof r.message!="string")throw new Error("prompt message is required");if({name:v,type:l}=r,gt[l]===void 0)throw new Error(`prompt type (${l}) is not defined`);if(n[r.name]!==void 0&&(o=await g(r,n[r.name]),o!==void 0)){i[v]=o;continue}try{o=Y._injected?Oi(Y._injected,r.initial):await gt[l](r),i[v]=o=await g(r,o,!0),h=await t(r,o,i)}catch{h=!await e(r,i)}if(h)return i}return i}function Oi(s,t){const e=s.shift();if(e instanceof Error)throw e;return e===void 0?t:e}function Mi(s){Y._injected=(Y._injected||[]).concat(s)}function Pi(s){Y._override=Object.assign({},s)}var Ti=Object.assign(Y,{prompt:Y,prompts:gt,inject:Mi,override:Pi});const Ci=xt(Ti);let V=!0;const z=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let X=0;if(z.process&&z.process.env&&z.process.stdout){const{FORCE_COLOR:s,NODE_DISABLE_COLORS:t,NO_COLOR:e,TERM:i,COLORTERM:n}=z.process.env;t||e||s==="0"?V=!1:s==="1"||s==="2"||s==="3"?V=!0:i==="dumb"?V=!1:"CI"in z.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in z.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?X=3:i&&(i.endsWith("-256color")||i.endsWith("256"))?X=2:X=1)}let Qt={enabled:V,supportLevel:X};function B(s,t,e=1){const i=`\x1B[${s}m`,n=`\x1B[${t}m`,o=new RegExp(`\\x1b\\[${t}m`,"g");return r=>Qt.enabled&&Qt.supportLevel>=e?i+(""+r).replace(o,i)+n:""+r}const Q=B(0,0),bt=B(31,39),te=B(32,39),ee=B(33,39),Di=B(36,39),Ei=B(37,39),Ii=B(92,39),vt=de(process.argv.slice(2),{string:["_"]}),wt=process.cwd(),se=[{name:"vanilla",display:"Vanilla",color:ee,variants:[{name:"vanilla",display:"JavaScript",color:ee}]},{name:"react",display:"React",color:Di,variants:[{name:"react-leo",display:"JavaScript + Leo",color:Ii},{name:"react-ts",display:"React + TypeScript",color:bt},{name:"nextjs-ts",display:"TypeScript + Next.js",color:Ei}]},{name:"node",display:"Node.js",color:te,variants:[{name:"node",display:"Node.js",color:te}]}],ie=se.map(s=>s.variants&&s.variants.map(t=>t.name)||[s.name]).reduce((s,t)=>s.concat(t),[]),_i={_gitignore:".gitignore"},$t="aleo-project";async function Ri(){const s=re(vt._[0]),t=vt.template||vt.t;let e=s||$t;const i=()=>e==="."?O.basename(O.resolve()):e;let n;try{n=await Ci([{type:s?null:"text",name:"projectName",message:Q("Project name:"),initial:$t,onState:m=>{e=re(m.value)||$t}},{type:()=>!S.existsSync(e)||Fi(e)?null:"confirm",name:"overwrite",message:()=>(e==="."?"Current directory":`Target directory "${e}"`)+" is not empty. Remove existing files and continue?"},{type:(m,{overwrite:f})=>{if(f===!1)throw new Error(bt("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>oe(i())?null:"text",name:"packageName",message:Q("Package name:"),initial:()=>Ai(i()),validate:m=>oe(m)||"Invalid package.json name"},{type:t&&ie.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!ie.includes(t)?Q(`"${t}" isn't a valid template. Please choose from below: `):Q("Select a framework:"),initial:0,choices:se.map(m=>{const f=m.color;return{title:f(m.display||m.name),value:m}})},{type:m=>m&&m.variants?"select":null,name:"variant",message:Q("Select a variant:"),choices:m=>m.variants.map(f=>{const u=f.color;return{title:u(f.display||f.name),value:f.name}})}],{onCancel:()=>{throw new Error(bt("\u2716")+" Operation cancelled")}})}catch(m){console.log(m.message);return}const{framework:o,overwrite:r,packageName:h,variant:v}=n,l=O.join(wt,e);r?Ni(l):S.existsSync(l)||S.mkdirSync(l,{recursive:!0});let T=v||o?.name||t;const g=Li(process.env.npm_config_user_agent),a=g?g.name:"npm";console.log(`
|
|
49
|
+
Scaffolding project in ${l}...`);const c=O.resolve(le(import.meta.url),"../..",`template-${T}`),$=(m,f)=>{const u=O.join(l,_i[m]??m);f?S.writeFileSync(u,f):ne(O.join(c,m),u)},C=S.readdirSync(c);for(const m of C.filter(f=>f!=="package.json"))$(m);const U=JSON.parse(S.readFileSync(O.join(c,"package.json"),"utf-8"));U.name=h||i(),$("package.json",JSON.stringify(U,null,2)+`
|
|
50
|
+
`);const x=O.relative(wt,l);switch(console.log(`
|
|
51
|
+
Done. Now run:
|
|
52
|
+
`),l!==wt&&console.log(` cd ${x.includes(" ")?`"${x}"`:x}`),a){default:console.log(` ${a} install`),console.log(` ${a} run dev`);break}console.log()}function re(s){return s?.trim().replace(/\/+$/g,"")}function ne(s,t){S.statSync(s).isDirectory()?ji(s,t):S.copyFileSync(s,t)}function oe(s){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(s)}function Ai(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function ji(s,t){S.mkdirSync(t,{recursive:!0});for(const e of S.readdirSync(s)){const i=O.resolve(s,e),n=O.resolve(t,e);ne(i,n)}}function Fi(s){const t=S.readdirSync(s);return t.length===0||t.length===1&&t[0]===".git"}function Ni(s){if(S.existsSync(s))for(const t of S.readdirSync(s))t!==".git"&&S.rmSync(O.resolve(s,t),{recursive:!0,force:!0})}function Li(s){if(!s)return;const t=s.split(" ")[0].split("/");return{name:t[0],version:t[1]}}Ri().catch(s=>{console.error(s)});
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-leo-app",
|
|
3
|
+
"version": "0.0.13",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "GPL-3.0",
|
|
6
|
+
"collaborators": [
|
|
7
|
+
"The Provable Team"
|
|
8
|
+
],
|
|
9
|
+
"bin": {
|
|
10
|
+
"create-leo-app": "index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"template-*",
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "unbuild --stub",
|
|
19
|
+
"build": "unbuild",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "yarn build"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "^14.18.0 || >=16.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/minimist": "^1.2.2",
|
|
28
|
+
"@types/prompts": "^2.4.4",
|
|
29
|
+
"kolorist": "^1.8.0",
|
|
30
|
+
"minimist": "^1.2.8",
|
|
31
|
+
"prompts": "^2.4.2",
|
|
32
|
+
"unbuild": "^1.2.1"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "extension-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rimraf static/js && rollup --config"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@provablehq/sdk": "^0.6.0",
|
|
11
|
+
"@web/rollup-plugin-import-meta-assets": "^2.1.0",
|
|
12
|
+
"rimraf": "^5.0.1",
|
|
13
|
+
"rollup": "^4.0.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
|
+
import { importMetaAssets } from "@web/rollup-plugin-import-meta-assets";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
input: {
|
|
6
|
+
service_worker: "./src/service_worker.js",
|
|
7
|
+
offscreen: "./src/offscreen.js",
|
|
8
|
+
worker: "./src/worker.js",
|
|
9
|
+
},
|
|
10
|
+
output: {
|
|
11
|
+
dir: "static/js",
|
|
12
|
+
format: "es",
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
},
|
|
15
|
+
plugins: [
|
|
16
|
+
nodeResolve(),
|
|
17
|
+
importMetaAssets({
|
|
18
|
+
exclude: "./src/offscreen.js",
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
new Worker(new URL("worker.js", import.meta.url), { type: "module" });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
async function createOffscreen(path) {
|
|
2
|
+
const offscreenUrl = chrome.runtime.getURL(path);
|
|
3
|
+
|
|
4
|
+
const existingContexts = await chrome.runtime.getContexts({
|
|
5
|
+
contextTypes: ["OFFSCREEN_DOCUMENT"],
|
|
6
|
+
documentUrls: [offscreenUrl]
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
if (existingContexts.length > 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
await chrome.offscreen.createDocument({
|
|
14
|
+
url: offscreenUrl,
|
|
15
|
+
reasons: ["WORKERS"],
|
|
16
|
+
justification: "Top-level await and Workers cannot be used in service workers, but they are necessary to use the Aleo SDK.",
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
createOffscreen("offscreen.html");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {Account, initThreadPool, PrivateKey, ProgramManager,} from "@provablehq/sdk";
|
|
2
|
+
|
|
3
|
+
await initThreadPool();
|
|
4
|
+
|
|
5
|
+
const hello_hello_program =`
|
|
6
|
+
program hello_hello.aleo;
|
|
7
|
+
|
|
8
|
+
function hello:
|
|
9
|
+
input r0 as u32.public;
|
|
10
|
+
input r1 as u32.private;
|
|
11
|
+
add r0 r1 into r2;
|
|
12
|
+
output r2 as u32.private;`
|
|
13
|
+
|
|
14
|
+
async function localProgramExecution(program, aleoFunction, inputs) {
|
|
15
|
+
const programManager = new ProgramManager();
|
|
16
|
+
|
|
17
|
+
// Create a temporary account for the execution of the program
|
|
18
|
+
const account = new Account();
|
|
19
|
+
programManager.setAccount(account);
|
|
20
|
+
|
|
21
|
+
const executionResponse = await programManager.run(
|
|
22
|
+
program,
|
|
23
|
+
aleoFunction,
|
|
24
|
+
inputs,
|
|
25
|
+
false,
|
|
26
|
+
);
|
|
27
|
+
return executionResponse.getOutputs();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const start = Date.now();
|
|
31
|
+
console.log("Starting execute!");
|
|
32
|
+
const result = await localProgramExecution(hello_hello_program, "hello", ["5u32", "5u32"]);
|
|
33
|
+
console.log(result);
|
|
34
|
+
console.log("Execute finished!", Date.now() - start);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "extension-starter",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Example for using Aleo in a Chrome / Firefox extension",
|
|
6
|
+
"background": {
|
|
7
|
+
"service_worker": "./js/service_worker.js",
|
|
8
|
+
"type": "module"
|
|
9
|
+
},
|
|
10
|
+
"permissions": [
|
|
11
|
+
"offscreen"
|
|
12
|
+
],
|
|
13
|
+
"content_security_policy": {
|
|
14
|
+
"extension_pages": "default-src 'self' 'wasm-unsafe-eval'; connect-src https://s3-us-west-1.amazonaws.com/mainnet.parameters/powers-of-beta-15.usrs.eb7040c"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
This is a [Next.js](https://nextjs.org/) example project showing Aleo
|
|
2
|
+
integration via Web Workers.
|
|
3
|
+
|
|
4
|
+
This template is based off the default TypeScript configuration from
|
|
5
|
+
[`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app)
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
First, run the development server:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the
|
|
16
|
+
result.
|
|
17
|
+
|
|
18
|
+
You can start editing the page by modifying `app/page.tsx`. The page
|
|
19
|
+
auto-updates as you edit the file.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.js
|
|
7
|
+
|
|
8
|
+
# testing
|
|
9
|
+
/coverage
|
|
10
|
+
|
|
11
|
+
# next.js
|
|
12
|
+
/.next/
|
|
13
|
+
/out/
|
|
14
|
+
|
|
15
|
+
# production
|
|
16
|
+
/build
|
|
17
|
+
|
|
18
|
+
# misc
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.pem
|
|
21
|
+
|
|
22
|
+
# debug
|
|
23
|
+
npm-debug.log*
|
|
24
|
+
yarn-debug.log*
|
|
25
|
+
yarn-error.log*
|
|
26
|
+
|
|
27
|
+
# local env files
|
|
28
|
+
.env*.local
|
|
29
|
+
|
|
30
|
+
# vercel
|
|
31
|
+
.vercel
|
|
32
|
+
|
|
33
|
+
# typescript
|
|
34
|
+
*.tsbuildinfo
|
|
35
|
+
next-env.d.ts
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const TerserPlugin = require("terser-webpack-plugin")
|
|
2
|
+
/** @type {import('next').NextConfig} */
|
|
3
|
+
const nextConfig = {
|
|
4
|
+
async headers() {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
source: '/:path*',
|
|
8
|
+
headers: [
|
|
9
|
+
{
|
|
10
|
+
key: 'Cross-Origin-Opener-Policy',
|
|
11
|
+
value: 'same-origin',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: 'Cross-Origin-Embedder-Policy',
|
|
15
|
+
value: 'require-corp',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
webpack: (config) => {
|
|
22
|
+
config.experiments = { ...config.experiments, topLevelAwait: true };
|
|
23
|
+
config.optimization = { ...config.optimization, minimize: true, minimizer: [new TerserPlugin({
|
|
24
|
+
terserOptions: {
|
|
25
|
+
module: true,
|
|
26
|
+
}
|
|
27
|
+
})], }
|
|
28
|
+
return config;
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = nextConfig
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-nextjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"lint": "next lint"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@provablehq/sdk": "^0.6.2",
|
|
13
|
+
"next": "13.5.4",
|
|
14
|
+
"react": "^18",
|
|
15
|
+
"react-dom": "^18",
|
|
16
|
+
"terser-webpack-plugin": "^5.3.9"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20",
|
|
20
|
+
"@types/react": "^18",
|
|
21
|
+
"@types/react-dom": "^18",
|
|
22
|
+
"typescript": "^5"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg width="216" height="80" viewBox="0 0 216 80" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M73.426 0V8.93824H81.6842V78.8961H90.6045V0H73.426Z" fill="#121212"/>
|
|
3
|
+
<path d="M154.145 51.4216C154.145 32.5518 143.683 21.297 127.604 21.297C111.526 21.297 100.954 32.0007 100.954 50.8687C100.954 69.7367 111.415 80 127.604 80C140.378 80 149.96 72.6061 152.603 62.3447H142.692C140.488 67.0902 135.975 71.2829 127.604 71.2829C116.812 71.2829 111.307 64.4419 110.205 54.6209H154.145V51.4216ZM110.316 46.125C111.636 36.6357 117.364 29.9035 127.604 29.9035C137.845 29.9035 143.242 36.5251 144.564 46.125H110.316Z" fill="#121212"/>
|
|
4
|
+
<path d="M189.272 21.297C173.083 21.297 162.622 32.0007 162.622 50.8687C162.622 69.7367 173.083 80 189.272 80C205.461 80 215.812 70.0684 215.812 50.8687C215.812 31.669 205.351 21.297 189.272 21.297ZM189.272 71.5041C177.709 71.5041 171.432 62.4553 171.432 50.76C171.432 39.0647 177.709 29.6842 189.272 29.6842C200.836 29.6842 207.003 38.8436 207.003 50.76C207.003 62.6764 200.946 71.5041 189.272 71.5041Z" fill="#121212"/>
|
|
5
|
+
<path d="M46.5565 0H28.3849L12.6134 46.125H22.2179L34.9933 8.49593H39.6189L52.3925 46.125H22.2179L19.2457 54.6209H55.2561L63.5143 78.8961H73.426L46.5565 0Z" fill="#121212"/>
|
|
6
|
+
<path d="M1.40508 78.8961H10.9857L19.2457 54.6209L9.7074 54.6209L1.40508 78.8961Z" fill="#121212"/>
|
|
7
|
+
<path d="M3.0935 46.125L0.1875 54.6209H9.7074L12.6134 46.125H3.0935Z" fill="#121212"/>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
|
Binary file
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--max-width: 1100px;
|
|
3
|
+
--border-radius: 12px;
|
|
4
|
+
--font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono',
|
|
5
|
+
'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro',
|
|
6
|
+
'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;
|
|
7
|
+
|
|
8
|
+
--foreground-rgb: 0, 0, 0;
|
|
9
|
+
--background-start-rgb: 214, 219, 220;
|
|
10
|
+
--background-end-rgb: 255, 255, 255;
|
|
11
|
+
|
|
12
|
+
--primary-glow: conic-gradient(
|
|
13
|
+
from 180deg at 50% 50%,
|
|
14
|
+
#16abff33 0deg,
|
|
15
|
+
#0885ff33 55deg,
|
|
16
|
+
#54d6ff33 120deg,
|
|
17
|
+
#0071ff33 160deg,
|
|
18
|
+
transparent 360deg
|
|
19
|
+
);
|
|
20
|
+
--secondary-glow: radial-gradient(
|
|
21
|
+
rgba(255, 255, 255, 1),
|
|
22
|
+
rgba(255, 255, 255, 0)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
--tile-start-rgb: 239, 245, 249;
|
|
26
|
+
--tile-end-rgb: 228, 232, 233;
|
|
27
|
+
--tile-border: conic-gradient(
|
|
28
|
+
#00000080,
|
|
29
|
+
#00000040,
|
|
30
|
+
#00000030,
|
|
31
|
+
#00000020,
|
|
32
|
+
#00000010,
|
|
33
|
+
#00000010,
|
|
34
|
+
#00000080
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
--callout-rgb: 238, 240, 241;
|
|
38
|
+
--callout-border-rgb: 172, 175, 176;
|
|
39
|
+
--card-rgb: 180, 185, 188;
|
|
40
|
+
--card-border-rgb: 131, 134, 135;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
button {
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
border: 1px solid transparent;
|
|
46
|
+
padding: 0.6em 1.2em;
|
|
47
|
+
font-size: 1em;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
font-family: inherit;
|
|
50
|
+
background-color: #1a1a1a;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: border-color 0.25s;
|
|
53
|
+
}
|
|
54
|
+
button:hover {
|
|
55
|
+
border-color: #646cff;
|
|
56
|
+
}
|
|
57
|
+
button:focus,
|
|
58
|
+
button:focus-visible {
|
|
59
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (prefers-color-scheme: dark) {
|
|
63
|
+
:root {
|
|
64
|
+
--foreground-rgb: 255, 255, 255;
|
|
65
|
+
--background-start-rgb: 0, 0, 0;
|
|
66
|
+
--background-end-rgb: 0, 0, 0;
|
|
67
|
+
|
|
68
|
+
--primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
|
|
69
|
+
--secondary-glow: linear-gradient(
|
|
70
|
+
to bottom right,
|
|
71
|
+
rgba(1, 65, 255, 0),
|
|
72
|
+
rgba(1, 65, 255, 0),
|
|
73
|
+
rgba(1, 65, 255, 0.3)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
--tile-start-rgb: 2, 13, 46;
|
|
77
|
+
--tile-end-rgb: 2, 5, 19;
|
|
78
|
+
--tile-border: conic-gradient(
|
|
79
|
+
#ffffff80,
|
|
80
|
+
#ffffff40,
|
|
81
|
+
#ffffff30,
|
|
82
|
+
#ffffff20,
|
|
83
|
+
#ffffff10,
|
|
84
|
+
#ffffff10,
|
|
85
|
+
#ffffff80
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
--callout-rgb: 20, 20, 20;
|
|
89
|
+
--callout-border-rgb: 108, 108, 108;
|
|
90
|
+
--card-rgb: 100, 100, 100;
|
|
91
|
+
--card-border-rgb: 200, 200, 200;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
* {
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
padding: 0;
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
html,
|
|
102
|
+
body {
|
|
103
|
+
max-width: 100vw;
|
|
104
|
+
overflow-x: hidden;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
body {
|
|
108
|
+
color: rgb(var(--foreground-rgb));
|
|
109
|
+
background: linear-gradient(
|
|
110
|
+
to bottom,
|
|
111
|
+
transparent,
|
|
112
|
+
rgb(var(--background-end-rgb))
|
|
113
|
+
)
|
|
114
|
+
rgb(var(--background-start-rgb));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
a {
|
|
118
|
+
color: inherit;
|
|
119
|
+
text-decoration: none;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (prefers-color-scheme: dark) {
|
|
123
|
+
html {
|
|
124
|
+
color-scheme: dark;
|
|
125
|
+
}
|
|
126
|
+
}
|