create-playcanvas 0.3.0 → 0.4.0

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.
Files changed (79) hide show
  1. package/README.md +37 -25
  2. package/dist/index.mjs +48 -46
  3. package/package.json +2 -1
  4. package/templates/_shared/model-viewer/public/playcanvas-cube.glb +0 -0
  5. package/templates/{vanilla-ts → engine/base}/README.md +3 -19
  6. package/templates/{vanilla-ts → engine/base}/src/vite-env.d.ts +6 -0
  7. package/templates/{vanilla-ts → engine/interactive-sphere}/src/main.ts +1 -1
  8. package/templates/{vanilla-ts → engine/interactive-sphere}/src/style.css +1 -1
  9. package/templates/{vanilla-ts → engine/interactive-sphere}/src/utils.ts +0 -1
  10. package/templates/engine/model-viewer/index.html +13 -0
  11. package/templates/engine/model-viewer/src/main.ts +81 -0
  12. package/templates/engine/model-viewer/src/style.css +8 -0
  13. package/templates/engine/spinning-cube/index.html +13 -0
  14. package/templates/engine/spinning-cube/src/main.ts +65 -0
  15. package/templates/engine/spinning-cube/src/style.css +8 -0
  16. package/templates/engine/splat-viewer/index.html +13 -0
  17. package/templates/engine/splat-viewer/src/main.ts +74 -0
  18. package/templates/engine/splat-viewer/src/style.css +8 -0
  19. package/templates/index.ts +37 -5
  20. package/templates/{react-ts → react/base}/README.md +2 -19
  21. package/templates/{react-ts → react/base}/src/vite-env.d.ts +6 -0
  22. package/templates/{react-ts → react/interactive-sphere}/src/Scene.tsx +1 -2
  23. package/templates/react/model-viewer/index.html +13 -0
  24. package/templates/react/model-viewer/src/App.tsx +43 -0
  25. package/templates/react/model-viewer/src/index.css +9 -0
  26. package/templates/react/model-viewer/src/main.tsx +11 -0
  27. package/templates/react/spinning-cube/index.html +13 -0
  28. package/templates/react/spinning-cube/src/App.tsx +36 -0
  29. package/templates/react/spinning-cube/src/index.css +9 -0
  30. package/templates/react/spinning-cube/src/main.tsx +11 -0
  31. package/templates/react/splat-viewer/index.html +13 -0
  32. package/templates/react/splat-viewer/src/App.tsx +39 -0
  33. package/templates/react/splat-viewer/src/index.css +9 -0
  34. package/templates/react/splat-viewer/src/main.tsx +11 -0
  35. package/templates/web-components/base/README.md +66 -0
  36. package/templates/web-components/base/_gitignore +24 -0
  37. package/templates/web-components/base/eslint.config.mjs +3 -0
  38. package/templates/web-components/base/package.json +31 -0
  39. package/templates/web-components/base/prettier.config.mjs +1 -0
  40. package/templates/web-components/base/src/assets/playcanvas.png +0 -0
  41. package/templates/web-components/base/src/vite-env.d.ts +19 -0
  42. package/templates/web-components/base/tsconfig.json +25 -0
  43. package/templates/web-components/interactive-sphere/index.html +53 -0
  44. package/templates/web-components/interactive-sphere/src/assets/typescript.svg +1 -0
  45. package/templates/web-components/interactive-sphere/src/main.ts +76 -0
  46. package/templates/web-components/interactive-sphere/src/style.css +111 -0
  47. package/templates/web-components/model-viewer/index.html +34 -0
  48. package/templates/web-components/model-viewer/src/main.ts +26 -0
  49. package/templates/web-components/model-viewer/src/style.css +8 -0
  50. package/templates/web-components/spinning-cube/index.html +29 -0
  51. package/templates/web-components/spinning-cube/src/main.ts +20 -0
  52. package/templates/web-components/spinning-cube/src/style.css +8 -0
  53. package/templates/web-components/splat-viewer/index.html +31 -0
  54. package/templates/web-components/splat-viewer/src/main.ts +14 -0
  55. package/templates/web-components/splat-viewer/src/style.css +8 -0
  56. package/templates/vanilla-ts/public/environment-map.png +0 -0
  57. /package/templates/{react-ts → _shared/interactive-sphere}/public/environment-map.png +0 -0
  58. /package/templates/{react-ts → engine/base}/_gitignore +0 -0
  59. /package/templates/{vanilla-ts → engine/base}/eslint.config.mjs +0 -0
  60. /package/templates/{vanilla-ts → engine/base}/package.json +0 -0
  61. /package/templates/{react-ts → engine/base}/prettier.config.mjs +0 -0
  62. /package/templates/{react-ts → engine/base}/src/assets/playcanvas.png +0 -0
  63. /package/templates/{vanilla-ts → engine/base}/tsconfig.json +0 -0
  64. /package/templates/{vanilla-ts → engine/interactive-sphere}/index.html +0 -0
  65. /package/templates/{vanilla-ts → engine/interactive-sphere}/src/App.ts +0 -0
  66. /package/templates/{vanilla-ts → engine/interactive-sphere}/src/assets/typescript.svg +0 -0
  67. /package/templates/{vanilla-ts → react/base}/_gitignore +0 -0
  68. /package/templates/{react-ts → react/base}/eslint.config.mjs +0 -0
  69. /package/templates/{react-ts → react/base}/package.json +0 -0
  70. /package/templates/{vanilla-ts → react/base}/prettier.config.mjs +0 -0
  71. /package/templates/{vanilla-ts → react/base}/src/assets/playcanvas.png +0 -0
  72. /package/templates/{react-ts → react/base}/tsconfig.json +0 -0
  73. /package/templates/{react-ts → react/base}/vite.config.ts +0 -0
  74. /package/templates/{react-ts → react/interactive-sphere}/index.html +0 -0
  75. /package/templates/{react-ts → react/interactive-sphere}/src/App.css +0 -0
  76. /package/templates/{react-ts → react/interactive-sphere}/src/App.tsx +0 -0
  77. /package/templates/{react-ts → react/interactive-sphere}/src/assets/react.svg +0 -0
  78. /package/templates/{react-ts → react/interactive-sphere}/src/index.css +0 -0
  79. /package/templates/{react-ts → react/interactive-sphere}/src/main.tsx +0 -0
package/README.md CHANGED
@@ -9,51 +9,63 @@
9
9
 
10
10
  | [Engine Manual](https://developer.playcanvas.com/user-manual/engine/) | [React Manual](https://developer.playcanvas.com/user-manual/react/) | [Examples](https://playcanvas.github.io/) | [Forum](https://forum.playcanvas.com/) |
11
11
 
12
- Scaffold a Vite-powered PlayCanvas project with TypeScript. Choose the PlayCanvas Engine directly or build with [`@playcanvas/react`](https://github.com/playcanvas/react).
12
+ Scaffold a Vite-powered PlayCanvas project with TypeScript. Choose the PlayCanvas Engine directly, [`@playcanvas/react`](https://github.com/playcanvas/react) or [`@playcanvas/web-components`](https://github.com/playcanvas/web-components).
13
13
 
14
14
  ## Getting Started
15
15
 
16
- Requires Node.js 22.23.2 or later.
17
-
18
16
  ```bash
17
+ # npm
19
18
  npm create playcanvas@latest
20
- cd playcanvas-project
21
- npm install
22
- npm run dev
23
- ```
24
-
25
- The interactive setup asks for a project name, handles an existing target directory, sets the package name and lets you choose a template.
26
-
27
- You can also use another package manager:
28
-
29
- ```bash
19
+ # pnpm
30
20
  pnpm create playcanvas@latest
21
+ # yarn
31
22
  yarn create playcanvas
23
+ # bun
32
24
  bun x create-playcanvas@latest
33
25
  ```
34
26
 
27
+ Then follow the prompts. Requires Node.js 22.23.2 or later.
28
+
35
29
  ## Templates
36
30
 
37
- | Template | Description |
38
- | ------------ | ----------------------------------- |
39
- | `vanilla-ts` | TypeScript with PlayCanvas Engine |
40
- | `react-ts` | TypeScript with `@playcanvas/react` |
31
+ | Template | Description |
32
+ | ---------------- | -------------------------------------------- |
33
+ | `engine` | The PlayCanvas Engine API directly |
34
+ | `react` | `@playcanvas/react` components |
35
+ | `web-components` | `@playcanvas/web-components` custom elements |
36
+
37
+ Every template is TypeScript, and includes Vite, ESLint, Prettier and a production build.
38
+
39
+ ## Boilerplates
41
40
 
42
- Both templates include Vite, hot module replacement, ESLint, Prettier and a production build.
41
+ Each template offers a choice of starting scene. `spinning-cube` is the default.
42
+
43
+ | Boilerplate | Description |
44
+ | -------------------- | ---------------------------------------------- |
45
+ | `spinning-cube` | A rotating cube and a light |
46
+ | `interactive-sphere` | Orbit controls, a grid and pointer picking |
47
+ | `model-viewer` | A glTF model, orbit controls, a procedural sky |
48
+ | `splat-viewer` | A Gaussian splat and orbit controls |
49
+
50
+ A template is a `base` directory of shared tooling plus one directory per boilerplate, which is copied over the top. Assets a boilerplate needs in every template live once in `templates/_shared/<boilerplate>` and are seeded in first.
43
51
 
44
52
  ## CLI Options
45
53
 
46
- Pass a project name and template to skip the prompts:
54
+ Pass a project name, template and boilerplate to skip the prompts:
47
55
 
48
56
  ```bash
49
- npm create playcanvas@latest my-game -- --template react-ts
57
+ npm create playcanvas@latest my-game -- --template react --boilerplate spinning-cube
50
58
  ```
51
59
 
52
- | Option | Shorthand | Description |
53
- | ------------------- | --------- | ------------------------------------------------------- |
54
- | `--template <name>` | `-t` | Use a template from the list above |
55
- | `--overwrite` | | Remove existing files from a non-empty target directory |
56
- | `--help` | `-h` | Show command help |
60
+ | Option | Shorthand | Description |
61
+ | ---------------------- | --------- | ------------------------------------------------------- |
62
+ | `--template <name>` | `-t` | Use a template from the list above |
63
+ | `--boilerplate <name>` | `-b` | Use a boilerplate from the list above |
64
+ | `--overwrite` | | Remove existing files from a non-empty target directory |
65
+ | `--yes` | `-y` | Skip the prompts and take the defaults |
66
+ | `--help` | `-h` | Show command help |
67
+
68
+ `--yes` takes `playcanvas-project`, the `engine` template and the `spinning-cube` boilerplate for anything you don't pass. It never deletes files, so a non-empty target directory still needs `--overwrite`.
57
69
 
58
70
  ## Development
59
71
 
package/dist/index.mjs CHANGED
@@ -1,59 +1,61 @@
1
1
  #!/usr/bin/env node
2
- import{styleText as c}from"node:util";import C,{stdin as Tt,stdout as rt}from"node:process";import Ct from"node:readline";import"node:tty";import R from"node:fs";import F from"node:path";import{fileURLToPath as Rt}from"node:url";const At=(()=>{const t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let r=0;for(t.lastIndex=0;t.test(e);)r+=1;return e.length-r}})(),Lt=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,kt=t=>t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141,Ot=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Bt=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,it=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Mt=/\t{1,1000}/y,st=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),Nt=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Pt=new RegExp("\\p{M}+","gu"),Dt={limit:1/0,ellipsis:""},nt=(t,e={},r={})=>{const i=e.limit??1/0,o=e.ellipsis??"",l=e?.ellipsisWidth??(o?nt(o,Dt,r).width:0),n=0,a=r.controlWidth??0,s=r.tabWidth??8,u=r.emojiWidth??2,m=2,h=r.regularWidth??1,d=r.wideWidth??m,p=[[Nt,h],[Ot,n],[Bt,a],[Mt,s],[st,u],[it,d]];let f=0,g=0,b=t.length,_=0,I=!1,O=b,L=Math.max(0,i-l),w=0,v=0,x=0,y=0;t:for(;;){if(v>w||g>=b&&g>f){const E=t.slice(w,v)||t.slice(f,g);_=0;for(const B of E.replaceAll(Pt,"")){const S=B.codePointAt(0)||0;if(Lt(S)?y=m:kt(S)?y=d:y=h,x+y>L&&(O=Math.min(O,Math.max(w,f)+_)),x+y>i){I=!0;break t}_+=B.length,x+=y}w=v=0}if(g>=b)break t;for(let E=0,B=p.length;E<B;E++){const[S,et]=p[E];if(S.lastIndex=g,S.test(t)){if(_=S===it?At(t.slice(g,S.lastIndex)):S===st?1:S.lastIndex-g,y=_*et,x+y>L&&(O=Math.min(O,g+Math.floor((L-x)/et))),x+y>i){I=!0;break t}x+=y,w=f,v=g,g=f=S.lastIndex;continue t}}g+=1}return{width:I?L:x,index:I?O:b,truncated:I,ellipsed:I&&i>=l}},jt={limit:1/0,ellipsis:"",ellipsisWidth:0},k=(t,e={})=>nt(t,jt,e).width,j="\x1B",at="\x9B",Wt=39,z="\x07",ot="[",Vt="]",lt="m",J=`${Vt}8;;`,ct=new RegExp(`(?:\\${ot}(?<code>\\d+)m|\\${J}(?<uri>.*)${z})`,"y"),ut=t=>{if(t>=30&&t<=37||t>=90&&t<=97)return 39;if(t>=40&&t<=47||t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0},ht=t=>`${j}${ot}${t}${lt}`,mt=t=>`${j}${J}${t}${z}`,q=(t,e,r)=>{const i=e[Symbol.iterator]();let o=!1,l=!1,n=t.at(-1),a=n===void 0?0:k(n),s=i.next(),u=i.next(),m=0;for(;!s.done;){const h=s.value,d=k(h);a+d<=r?t[t.length-1]+=h:(t.push(h),a=0),(h===j||h===at)&&(o=!0,l=e.startsWith(J,m+1)),o?l?h===z&&(o=!1,l=!1):h===lt&&(o=!1):(a+=d,a===r&&!u.done&&(t.push(""),a=0)),s=u,u=i.next(),m+=h.length}n=t.at(-1),!a&&n!==void 0&&n.length&&t.length>1&&(t[t.length-2]+=t.pop())},Ut=t=>{const e=t.split(" ");let r=e.length;for(;r&&!k(e[r-1]);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},Gt=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let i="",o,l;const n=t.split(" ");let a=[""],s=0;for(let h=0;h<n.length;h++){const d=n[h];if(r.trim!==!1){const f=a.at(-1)??"",g=f.trimStart();f.length!==g.length&&(a[a.length-1]=g,s=k(g))}h!==0&&(s>=e&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),s=0),(s||r.trim===!1)&&(a[a.length-1]+=" ",s++));const p=k(d);if(r.hard&&p>e){const f=e-s,g=1+Math.floor((p-f-1)/e);Math.floor((p-1)/e)<g&&a.push(""),q(a,d,e),s=k(a.at(-1)??"");continue}if(s+p>e&&s&&p){if(r.wordWrap===!1&&s<e){q(a,d,e),s=k(a.at(-1)??"");continue}a.push(""),s=0}if(s+p>e&&r.wordWrap===!1){q(a,d,e),s=k(a.at(-1)??"");continue}a[a.length-1]+=d,s+=p}r.trim!==!1&&(a=a.map(h=>Ut(h)));const u=a.join(`
3
- `);let m=!1;for(let h=0;h<u.length;h++){const d=u[h];if(i+=d,m)m=!1;else if(m=d>="\uD800"&&d<="\uDBFF",m)continue;if(d===j||d===at){ct.lastIndex=h+1;const f=ct.exec(u)?.groups;if(f?.code!==void 0){const g=Number.parseFloat(f.code);o=g===Wt?void 0:g}else f?.uri!==void 0&&(l=f.uri.length===0?void 0:f.uri)}if(u[h+1]===`
4
- `){l&&(i+=mt(""));const p=o?ut(o):void 0;o&&p&&(i+=ht(p))}else d===`
5
- `&&(o&&ut(o)&&(i+=ht(o)),l&&(i+=mt(l)))}return i},Kt=/\r?\n/;function W(t,e,r){return String(t).normalize().split(Kt).map(i=>Gt(i,e,r)).join(`
6
- `)}function Ht(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Y,dt;function zt(){if(dt)return Y;dt=1;const t="\x1B",e=`${t}[`,r="\x07",i={to(n,a){return a?`${e}${a+1};${n+1}H`:`${e}${n+1}G`},move(n,a){let s="";return n<0?s+=`${e}${-n}D`:n>0&&(s+=`${e}${n}C`),a<0?s+=`${e}${-a}A`:a>0&&(s+=`${e}${a}B`),s},up:(n=1)=>`${e}${n}A`,down:(n=1)=>`${e}${n}B`,forward:(n=1)=>`${e}${n}C`,backward:(n=1)=>`${e}${n}D`,nextLine:(n=1)=>`${e}E`.repeat(n),prevLine:(n=1)=>`${e}F`.repeat(n),left:`${e}G`,hide:`${e}?25l`,show:`${e}?25h`,save:`${t}7`,restore:`${t}8`},o={up:(n=1)=>`${e}S`.repeat(n),down:(n=1)=>`${e}T`.repeat(n)},l={screen:`${e}2J`,up:(n=1)=>`${e}1J`.repeat(n),down:(n=1)=>`${e}J`.repeat(n),line:`${e}2K`,lineEnd:`${e}K`,lineStart:`${e}1K`,lines(n){let a="";for(let s=0;s<n;s++)a+=this.line+(s<n-1?i.up():"");return n&&(a+=i.left),a}};return Y={cursor:i,scroll:o,erase:l,beep:r},Y}var A=zt();function V(t,e,r){if(!r.some(n=>!n.disabled))return t;const i=t+e,o=Math.max(r.length-1,0),l=i<0?o:i>o?0:i;return r[l]?.disabled?V(l,e<0?-1:1,r):l}const Jt=["up","down","left","right","space","enter","cancel"],M={actions:new Set(Jt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),withGuide:!0};function ft(t,e){if(typeof t=="string")return M.aliases.get(t)===e;for(const r of t)if(r!==void 0&&ft(r,e))return!0;return!1}function qt(t,e){if(t===e)return;const r=t.split(`
7
- `),i=e.split(`
8
- `),o=Math.max(r.length,i.length),l=[];for(let n=0;n<o;n++)r[n]!==i[n]&&l.push(n);return{lines:l,numLinesBefore:r.length,numLinesAfter:i.length,numLines:o}}globalThis.process.platform.startsWith("win");const X=Symbol("clack:cancel");function U(t){return t===X}function G(t,e){const r=t;r.isTTY&&r.setRawMode(e)}const pt=t=>"columns"in t&&typeof t.columns=="number"?t.columns:80,gt=t=>"rows"in t&&typeof t.rows=="number"?t.rows:20;function Z(t,e,r,i=r,o=r,l){const n=pt(t??rt);return W(e,n-r.length,{hard:!0,trim:!1}).split(`
9
- `).map((a,s,u)=>{const m=a;return s===0?`${i}${m}`:s===u.length-1?`${o}${m}`:`${r}${m}`}).join(`
10
- `)}function Yt(t,e){if("~standard"in t){const r=t["~standard"].validate(e);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return t(e)}class bt{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,r=!0){const{input:i=Tt,output:o=rt,render:l,signal:n,...a}=e;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=l.bind(this),this._track=r,this._abortSignal=n,this.input=i,this.output=o}unsubscribe(){this._subscribers.clear()}setSubscriber(e,r){const i=this._subscribers.get(e)??[];i.push(r),this._subscribers.set(e,i)}on(e,r){this.setSubscriber(e,{cb:r})}once(e,r){this.setSubscriber(e,{cb:r,once:!0})}emit(e,...r){const i=this._subscribers.get(e)??[],o=[];for(const l of i)l.cb(...r),l.once&&o.push(()=>i.splice(i.indexOf(l),1));for(const l of o)l()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(X);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Ct.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),G(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(A.cursor.show),this.output.off("resize",this.render),G(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(A.cursor.show),this.output.off("resize",this.render),G(this.input,!1),e(X)})})}_isActionKey(e,r){return e===" "}_shouldSubmit(e,r){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,r){this.userInput=e??"",this.emit("userInput",this.userInput),r&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,r){if(this._track&&r.name!=="return"&&(r.name&&this._isActionKey(e,r)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&M.aliases.has(r.name)&&this.emit("cursor",M.aliases.get(r.name)),M.actions.has(r.name)&&this.emit("cursor",r.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,r),r?.name==="return"&&this._shouldSubmit(e,r)){if(this.opts.validate){const i=Yt(this.opts.validate,this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ft([e,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
11
- `),G(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const e=W(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
12
- `).length-1;this.output.write(A.cursor.move(-999,e*-1))}render(){const e=W(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(A.cursor.hide);else{const r=qt(this._prevFrame,e),i=gt(this.output);if(this.restoreCursor(),r){const o=Math.max(0,r.numLinesAfter-i),l=Math.max(0,r.numLinesBefore-i);let n=r.lines.find(a=>a>=o);if(n===void 0){this._prevFrame=e;return}if(r.lines.length===1){this.output.write(A.cursor.move(0,n-l)),this.output.write(A.erase.lines(1));const a=e.split(`
13
- `);this.output.write(a[n]),this._prevFrame=e,this.output.write(A.cursor.move(0,a.length-n-1));return}else if(r.lines.length>1){if(o<l)n=o;else{const s=n-l;s>0&&this.output.write(A.cursor.move(0,s))}this.output.write(A.erase.down());const a=e.split(`
14
- `).slice(n);this.output.write(a.join(`
15
- `)),this._prevFrame=e;return}}this.output.write(A.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}let Xt=class extends bt{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){const e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;const r=this.options.findIndex(({value:o})=>o===e.initialValue),i=r===-1?0:r;this.cursor=this.options[i]?.disabled?V(i,1,this.options):i,this.changeValue(),this.on("cursor",o=>{switch(o){case"left":case"up":this.cursor=V(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=V(this.cursor,1,this.options);break}this.changeValue()})}};class Zt extends bt{get userInputWithCursor(){if(this.state==="submit")return this.userInput;const e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;const r=e.slice(0,this.cursor),i=e.slice(this.cursor,this.cursor+1),o=e.slice(this.cursor+1);return`${r}${c("inverse",i)}${o}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}}function Qt(){return C.platform!=="win32"?C.env.TERM!=="linux":!!C.env.CI||!!C.env.WT_SESSION||!!C.env.TERMINUS_SUBLIME||C.env.ConEmuTask==="{cmd::Cmder}"||C.env.TERM_PROGRAM==="Terminus-Sublime"||C.env.TERM_PROGRAM==="vscode"||C.env.TERM==="xterm-256color"||C.env.TERM==="alacritty"||C.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const te=Qt(),T=(t,e)=>te?t:e,ee=T("\u25C6","*"),re=T("\u25A0","x"),ie=T("\u25B2","x"),xt=T("\u25C7","o"),$=T("\u2502","|"),P=T("\u2514","\u2014"),se=T("\u25CF",">"),$t=T("\u25CB"," "),ne=T("\u25CF","\u2022"),ae=T("\u25C6","*"),oe=T("\u25B2","!"),le=T("\u25A0","x"),wt=t=>{switch(t){case"initial":case"active":return c("cyan",ee);case"cancel":return c("red",re);case"error":return c("yellow",ie);case"submit":return c("green",xt)}},ce=t=>{switch(t){case"initial":case"active":return c("cyan",$);case"cancel":return c("red",$);case"error":return c("yellow",$);case"submit":return c("green",$)}};function ue(t,e){const r=[`${e?`${c("cyan",$)} `:""}${t.join(" \u2022 ")}`];return e&&r.push(c("cyan",P)),r}const _t=(t,e,r,i,o,l=!1)=>{let n=e,a=0;if(l)for(let s=i-1;s>=r;s--){const u=t[s];if(u&&(n-=u.length),a++,n<=o)break}else for(let s=r;s<i;s++){const u=t[s];if(u&&(n-=u.length),a++,n<=o)break}return{lineCount:n,removals:a}},he=({cursor:t,options:e,style:r,output:i=process.stdout,maxItems:o=Number.POSITIVE_INFINITY,columnPadding:l=0,rowPadding:n=4})=>{const a=pt(i)-l,s=gt(i),u=c("dim","..."),m=Math.max(s-n,0),h=Math.max(Math.min(o,m),5);let d=0;t>=h-3&&(d=Math.max(Math.min(t-h+3,e.length-h),0));let p=h<e.length&&d>0,f=h<e.length&&d+h<e.length;const g=Math.min(d+h,e.length),b=[];let _=0;p&&_++,f&&_++;const I=d+(p?1:0),O=g-(f?1:0);for(let w=I;w<O;w++){const v=e[w],x=v?r(v,w===t):"",y=W(x,a,{hard:!0,trim:!1}).split(`
16
- `);b.push(y),_+=y.length}if(_>m){let w=0,v=0,x=_;const y=t-I;let E=m;const B=()=>_t(b,x,0,y,E),S=()=>_t(b,x,y+1,b.length,E,!0);p?({lineCount:x,removals:w}=B(),x>E&&(f||(E-=1),{lineCount:x,removals:v}=S())):(f||(E-=1),{lineCount:x,removals:v}=S(),x>E&&(E-=1,{lineCount:x,removals:w}=B())),w>0&&(p=!0,b.splice(0,w)),v>0&&(f=!0,b.splice(b.length-v,v))}const L=[];p&&L.push(u);for(const w of b)for(const v of w)L.push(v);return f&&L.push(u),L};`${c("dim","\u2191/\u2193")}`,`${c("dim","Space:")}`,`${c("dim","Enter:")}`;const N={message:(t=[],{symbol:e=c("gray",$),secondarySymbol:r=c("gray",$),output:i=process.stdout,spacing:o=1,withGuide:l}={})=>{const n=[],a=l??M.withGuide,s=a?r:"",u=a?`${e} `:"",m=a?`${r} `:"";for(let d=0;d<o;d++)n.push(s);const h=Array.isArray(t)?t:t.split(`
17
- `);if(h.length>0){const[d,...p]=h;d.length>0?n.push(`${u}${d}`):n.push(a?e:"");for(const f of p)f.length>0?n.push(`${m}${f}`):n.push(a?r:"")}i.write(`${n.join(`
2
+ import{styleText as c}from"node:util";import k,{stdin as Ce,stdout as ae}from"node:process";import Re from"node:readline";import"node:tty";import I from"node:fs";import _ from"node:path";import{fileURLToPath as Ae}from"node:url";const ke=(()=>{const e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),Be=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Le=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Oe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Me=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,oe=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Ne=/\t{1,1000}/y,le=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),Pe=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,je=new RegExp("\\p{M}+","gu"),De={limit:1/0,ellipsis:""},ce=(e,t={},r={})=>{const s=t.limit??1/0,a=t.ellipsis??"",l=t?.ellipsisWidth??(a?ce(a,De,r).width:0),o=0,n=r.controlWidth??0,i=r.tabWidth??8,u=r.emojiWidth??2,m=2,h=r.regularWidth??1,d=r.wideWidth??m,f=[[Pe,h],[Oe,o],[Me,n],[Ne,i],[le,u],[oe,d]];let p=0,g=0,b=e.length,E=0,w=!1,C=b,R=Math.max(0,s-l),y=0,S=0,x=0,v=0;e:for(;;){if(S>y||g>=b&&g>p){const F=e.slice(y,S)||e.slice(p,g);E=0;for(const O of F.replaceAll(je,"")){const T=O.codePointAt(0)||0;if(Be(T)?v=m:Le(T)?v=d:v=h,x+v>R&&(C=Math.min(C,Math.max(y,p)+E)),x+v>s){w=!0;break e}E+=O.length,x+=v}y=S=0}if(g>=b)break e;for(let F=0,O=f.length;F<O;F++){const[T,ne]=f[F];if(T.lastIndex=g,T.test(e)){if(E=T===oe?ke(e.slice(g,T.lastIndex)):T===le?1:T.lastIndex-g,v=E*ne,x+v>R&&(C=Math.min(C,g+Math.floor((R-x)/ne))),x+v>s){w=!0;break e}x+=v,y=p,S=g,g=p=T.lastIndex;continue e}}g+=1}return{width:w?R:x,index:w?C:b,truncated:w,ellipsed:w&&s>=l}},We={limit:1/0,ellipsis:"",ellipsisWidth:0},L=(e,t={})=>ce(e,We,t).width,V="\x1B",ue="\x9B",Ve=39,Y="\x07",he="[",Ue="]",me="m",q=`${Ue}8;;`,de=new RegExp(`(?:\\${he}(?<code>\\d+)m|\\${q}(?<uri>.*)${Y})`,"y"),pe=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},fe=e=>`${V}${he}${e}${me}`,ge=e=>`${V}${q}${e}${Y}`,X=(e,t,r)=>{const s=t[Symbol.iterator]();let a=!1,l=!1,o=e.at(-1),n=o===void 0?0:L(o),i=s.next(),u=s.next(),m=0;for(;!i.done;){const h=i.value,d=L(h);n+d<=r?e[e.length-1]+=h:(e.push(h),n=0),(h===V||h===ue)&&(a=!0,l=t.startsWith(q,m+1)),a?l?h===Y&&(a=!1,l=!1):h===me&&(a=!1):(n+=d,n===r&&!u.done&&(e.push(""),n=0)),i=u,u=s.next(),m+=h.length}o=e.at(-1),!n&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ge=e=>{const t=e.split(" ");let r=t.length;for(;r&&!L(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Ke=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let s="",a,l;const o=e.split(" ");let n=[""],i=0;for(let h=0;h<o.length;h++){const d=o[h];if(r.trim!==!1){const p=n.at(-1)??"",g=p.trimStart();p.length!==g.length&&(n[n.length-1]=g,i=L(g))}h!==0&&(i>=t&&(r.wordWrap===!1||r.trim===!1)&&(n.push(""),i=0),(i||r.trim===!1)&&(n[n.length-1]+=" ",i++));const f=L(d);if(r.hard&&f>t){const p=t-i,g=1+Math.floor((f-p-1)/t);Math.floor((f-1)/t)<g&&n.push(""),X(n,d,t),i=L(n.at(-1)??"");continue}if(i+f>t&&i&&f){if(r.wordWrap===!1&&i<t){X(n,d,t),i=L(n.at(-1)??"");continue}n.push(""),i=0}if(i+f>t&&r.wordWrap===!1){X(n,d,t),i=L(n.at(-1)??"");continue}n[n.length-1]+=d,i+=f}r.trim!==!1&&(n=n.map(h=>Ge(h)));const u=n.join(`
3
+ `);let m=!1;for(let h=0;h<u.length;h++){const d=u[h];if(s+=d,m)m=!1;else if(m=d>="\uD800"&&d<="\uDBFF",m)continue;if(d===V||d===ue){de.lastIndex=h+1;const p=de.exec(u)?.groups;if(p?.code!==void 0){const g=Number.parseFloat(p.code);a=g===Ve?void 0:g}else p?.uri!==void 0&&(l=p.uri.length===0?void 0:p.uri)}if(u[h+1]===`
4
+ `){l&&(s+=ge(""));const f=a?pe(a):void 0;a&&f&&(s+=fe(f))}else d===`
5
+ `&&(a&&pe(a)&&(s+=fe(a)),l&&(s+=ge(l)))}return s},He=/\r?\n/;function U(e,t,r){return String(e).normalize().split(He).map(s=>Ke(s,t,r)).join(`
6
+ `)}function ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z,be;function Je(){if(be)return Z;be=1;const e="\x1B",t=`${e}[`,r="\x07",s={to(o,n){return n?`${t}${n+1};${o+1}H`:`${t}${o+1}G`},move(o,n){let i="";return o<0?i+=`${t}${-o}D`:o>0&&(i+=`${t}${o}C`),n<0?i+=`${t}${-n}A`:n>0&&(i+=`${t}${n}B`),i},up:(o=1)=>`${t}${o}A`,down:(o=1)=>`${t}${o}B`,forward:(o=1)=>`${t}${o}C`,backward:(o=1)=>`${t}${o}D`,nextLine:(o=1)=>`${t}E`.repeat(o),prevLine:(o=1)=>`${t}F`.repeat(o),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},a={up:(o=1)=>`${t}S`.repeat(o),down:(o=1)=>`${t}T`.repeat(o)},l={screen:`${t}2J`,up:(o=1)=>`${t}1J`.repeat(o),down:(o=1)=>`${t}J`.repeat(o),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(o){let n="";for(let i=0;i<o;i++)n+=this.line+(i<o-1?s.up():"");return o&&(n+=s.left),n}};return Z={cursor:s,scroll:a,erase:l,beep:r},Z}var B=Je();function G(e,t,r){if(!r.some(o=>!o.disabled))return e;const s=e+t,a=Math.max(r.length-1,0),l=s<0?a:s>a?0:s;return r[l]?.disabled?G(l,t<0?-1:1,r):l}const Ye=["up","down","left","right","space","enter","cancel"],M={actions:new Set(Ye),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),withGuide:!0};function xe(e,t){if(typeof e=="string")return M.aliases.get(e)===t;for(const r of e)if(r!==void 0&&xe(r,t))return!0;return!1}function qe(e,t){if(e===t)return;const r=e.split(`
7
+ `),s=t.split(`
8
+ `),a=Math.max(r.length,s.length),l=[];for(let o=0;o<a;o++)r[o]!==s[o]&&l.push(o);return{lines:l,numLinesBefore:r.length,numLinesAfter:s.length,numLines:a}}globalThis.process.platform.startsWith("win");const Q=Symbol("clack:cancel");function D(e){return e===Q}function K(e,t){const r=e;r.isTTY&&r.setRawMode(t)}const $e=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,ye=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function ee(e,t,r,s=r,a=r,l){const o=$e(e??ae);return U(t,o-r.length,{hard:!0,trim:!1}).split(`
9
+ `).map((n,i,u)=>{const m=n;return i===0?`${s}${m}`:i===u.length-1?`${a}${m}`:`${r}${m}`}).join(`
10
+ `)}function Xe(e,t){if("~standard"in e){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return e(t)}class we{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,r=!0){const{input:s=Ce,output:a=ae,render:l,signal:o,...n}=t;this.opts=n,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=l.bind(this),this._track=r,this._abortSignal=o,this.input=s,this.output=a}unsubscribe(){this._subscribers.clear()}setSubscriber(t,r){const s=this._subscribers.get(t)??[];s.push(r),this._subscribers.set(t,s)}on(t,r){this.setSubscriber(t,{cb:r})}once(t,r){this.setSubscriber(t,{cb:r,once:!0})}emit(t,...r){const s=this._subscribers.get(t)??[],a=[];for(const l of s)l.cb(...r),l.once&&a.push(()=>s.splice(s.indexOf(l),1));for(const l of a)l()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Q);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Re.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),K(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(B.cursor.show),this.output.off("resize",this.render),K(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(B.cursor.show),this.output.off("resize",this.render),K(this.input,!1),t(Q)})})}_isActionKey(t,r){return t===" "}_shouldSubmit(t,r){return!0}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,r){this.userInput=t??"",this.emit("userInput",this.userInput),r&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,r){if(this._track&&r.name!=="return"&&(r.name&&this._isActionKey(t,r)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&M.aliases.has(r.name)&&this.emit("cursor",M.aliases.get(r.name)),M.actions.has(r.name)&&this.emit("cursor",r.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t,r),r?.name==="return"&&this._shouldSubmit(t,r)){if(this.opts.validate){const s=Xe(this.opts.validate,this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}xe([t,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
11
+ `),K(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=U(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
12
+ `).length-1;this.output.write(B.cursor.move(-999,t*-1))}render(){const t=U(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(B.cursor.hide);else{const r=qe(this._prevFrame,t),s=ye(this.output);if(this.restoreCursor(),r){const a=Math.max(0,r.numLinesAfter-s),l=Math.max(0,r.numLinesBefore-s);let o=r.lines.find(n=>n>=a);if(o===void 0){this._prevFrame=t;return}if(r.lines.length===1){this.output.write(B.cursor.move(0,o-l)),this.output.write(B.erase.lines(1));const n=t.split(`
13
+ `);this.output.write(n[o]),this._prevFrame=t,this.output.write(B.cursor.move(0,n.length-o-1));return}else if(r.lines.length>1){if(a<l)o=a;else{const i=o-l;i>0&&this.output.write(B.cursor.move(0,i))}this.output.write(B.erase.down());const n=t.split(`
14
+ `).slice(o);this.output.write(n.join(`
15
+ `)),this._prevFrame=t;return}}this.output.write(B.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}let Ze=class extends we{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){const t=this._selectedValue;this.value=t===void 0?void 0:t.value}constructor(t){super(t,!1),this.options=t.options;const r=this.options.findIndex(({value:a})=>a===t.initialValue),s=r===-1?0:r;this.cursor=this.options[s]?.disabled?G(s,1,this.options):s,this.changeValue(),this.on("cursor",a=>{switch(a){case"left":case"up":this.cursor=G(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=G(this.cursor,1,this.options);break}this.changeValue()})}},Qe=class extends we{get userInputWithCursor(){if(this.state==="submit")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;const r=t.slice(0,this.cursor),s=t.slice(this.cursor,this.cursor+1),a=t.slice(this.cursor+1);return`${r}${c("inverse",s)}${a}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}};function et(){return k.platform!=="win32"?k.env.TERM!=="linux":!!k.env.CI||!!k.env.WT_SESSION||!!k.env.TERMINUS_SUBLIME||k.env.ConEmuTask==="{cmd::Cmder}"||k.env.TERM_PROGRAM==="Terminus-Sublime"||k.env.TERM_PROGRAM==="vscode"||k.env.TERM==="xterm-256color"||k.env.TERM==="alacritty"||k.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const tt=et(),A=(e,t)=>tt?e:t,rt=A("\u25C6","*"),it=A("\u25A0","x"),st=A("\u25B2","x"),ve=A("\u25C7","o"),$=A("\u2502","|"),j=A("\u2514","\u2014"),nt=A("\u25CF",">"),_e=A("\u25CB"," "),at=A("\u25CF","\u2022"),ot=A("\u25C6","*"),lt=A("\u25B2","!"),ct=A("\u25A0","x"),Ee=e=>{switch(e){case"initial":case"active":return c("cyan",rt);case"cancel":return c("red",it);case"error":return c("yellow",st);case"submit":return c("green",ve)}},ut=e=>{switch(e){case"initial":case"active":return c("cyan",$);case"cancel":return c("red",$);case"error":return c("yellow",$);case"submit":return c("green",$)}};function ht(e,t){const r=[`${t?`${c("cyan",$)} `:""}${e.join(" \u2022 ")}`];return t&&r.push(c("cyan",j)),r}const Se=(e,t,r,s,a,l=!1)=>{let o=t,n=0;if(l)for(let i=s-1;i>=r;i--){const u=e[i];if(u&&(o-=u.length),n++,o<=a)break}else for(let i=r;i<s;i++){const u=e[i];if(u&&(o-=u.length),n++,o<=a)break}return{lineCount:o,removals:n}},mt=({cursor:e,options:t,style:r,output:s=process.stdout,maxItems:a=Number.POSITIVE_INFINITY,columnPadding:l=0,rowPadding:o=4})=>{const n=$e(s)-l,i=ye(s),u=c("dim","..."),m=Math.max(i-o,0),h=Math.max(Math.min(a,m),5);let d=0;e>=h-3&&(d=Math.max(Math.min(e-h+3,t.length-h),0));let f=h<t.length&&d>0,p=h<t.length&&d+h<t.length;const g=Math.min(d+h,t.length),b=[];let E=0;f&&E++,p&&E++;const w=d+(f?1:0),C=g-(p?1:0);for(let y=w;y<C;y++){const S=t[y],x=S?r(S,y===e):"",v=U(x,n,{hard:!0,trim:!1}).split(`
16
+ `);b.push(v),E+=v.length}if(E>m){let y=0,S=0,x=E;const v=e-w;let F=m;const O=()=>Se(b,x,0,v,F),T=()=>Se(b,x,v+1,b.length,F,!0);f?({lineCount:x,removals:y}=O(),x>F&&(p||(F-=1),{lineCount:x,removals:S}=T())):(p||(F-=1),{lineCount:x,removals:S}=T(),x>F&&(F-=1,{lineCount:x,removals:y}=O())),y>0&&(f=!0,b.splice(0,y)),S>0&&(p=!0,b.splice(b.length-S,S))}const R=[];f&&R.push(u);for(const y of b)for(const S of y)R.push(S);return p&&R.push(u),R};`${c("dim","\u2191/\u2193")}`,`${c("dim","Space:")}`,`${c("dim","Enter:")}`;const N={message:(e=[],{symbol:t=c("gray",$),secondarySymbol:r=c("gray",$),output:s=process.stdout,spacing:a=1,withGuide:l}={})=>{const o=[],n=l??M.withGuide,i=n?r:"",u=n?`${t} `:"",m=n?`${r} `:"";for(let d=0;d<a;d++)o.push(i);const h=Array.isArray(e)?e:e.split(`
17
+ `);if(h.length>0){const[d,...f]=h;d.length>0?o.push(`${u}${d}`):o.push(n?t:"");for(const p of f)p.length>0?o.push(`${m}${p}`):o.push(n?r:"")}s.write(`${o.join(`
18
18
  `)}
19
- `)},info:(t,e)=>{N.message(t,{...e,symbol:c("blue",ne)})},success:(t,e)=>{N.message(t,{...e,symbol:c("green",ae)})},step:(t,e)=>{N.message(t,{...e,symbol:c("green",xt)})},warn:(t,e)=>{N.message(t,{...e,symbol:c("yellow",oe)})},warning:(t,e)=>{N.warn(t,e)},error:(t,e)=>{N.message(t,{...e,symbol:c("red",le)})}},me=(t="",e)=>{const r=process.stdout,i=`${c("gray",P)} `;r.write(`${i}${c("red",t)}
19
+ `)},info:(e,t)=>{N.message(e,{...t,symbol:c("blue",at)})},success:(e,t)=>{N.message(e,{...t,symbol:c("green",ot)})},step:(e,t)=>{N.message(e,{...t,symbol:c("green",ve)})},warn:(e,t)=>{N.message(e,{...t,symbol:c("yellow",lt)})},warning:(e,t)=>{N.warn(e,t)},error:(e,t)=>{N.message(e,{...t,symbol:c("red",ct)})}},dt=(e="",t)=>{const r=process.stdout,s=`${c("gray",j)} `;r.write(`${s}${c("red",e)}
20
20
 
21
- `)},de=(t="",e)=>{const r=process.stdout,i=`${c("gray",$)}
22
- ${c("gray",P)} `;r.write(`${i}${t}
21
+ `)},pt=(e="",t)=>{const r=process.stdout,s=`${c("gray",$)}
22
+ ${c("gray",j)} `;r.write(`${s}${e}
23
23
 
24
- `)},fe=[`${c("dim","\u2191/\u2193")} to navigate`,`${c("dim","Enter:")} confirm`],K=(t,e)=>t.includes(`
25
- `)?t.split(`
26
- `).map(r=>e(r)).join(`
27
- `):e(t),yt=t=>{const e=(i,o)=>{if(i===void 0)return"";const l=i.label??String(i.value);switch(o){case"disabled":return`${c("gray",$t)} ${K(l,n=>c("gray",n))}${i.hint?` ${c("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${K(l,n=>c("dim",n))}`;case"active":return`${c("green",se)} ${l}${i.hint?` ${c("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${K(l,n=>c(["strikethrough","dim"],n))}`;default:return`${c("dim",$t)} ${K(l,n=>c("dim",n))}`}},r=t.showInstructions??!0;return new Xt({options:t.options,signal:t.signal,input:t.input,output:t.output,initialValue:t.initialValue,render(){const i=t.withGuide??M.withGuide,o=`${wt(this.state)} `,l=`${ce(this.state)} `,n=Z(t.output,t.message,l,o),a=`${i?`${c("gray",$)}
28
- `:""}${n}
29
- `;switch(this.state){case"submit":{const s=i?`${c("gray",$)} `:"",u=Z(t.output,e(this.options[this.cursor],"selected"),s);return`${a}${u}`}case"cancel":{const s=i?`${c("gray",$)} `:"",u=Z(t.output,e(this.options[this.cursor],"cancelled"),s);return`${a}${u}${i?`
30
- ${c("gray",$)}`:""}`}default:{const s=i?`${c("cyan",$)} `:"",u=a.split(`
31
- `).length,m=r?ue(fe,i):i?[c("cyan",P)]:[],h=m.join(`
32
- `),d=m.length+1;return`${a}${s}${he({output:t.output,cursor:this.cursor,options:this.options,maxItems:t.maxItems,columnPadding:s.length,rowPadding:u+d,style:(p,f)=>e(p,p.disabled?"disabled":f?"active":"inactive")}).join(`
33
- ${s}`)}
24
+ `)},ft=[`${c("dim","\u2191/\u2193")} to navigate`,`${c("dim","Enter:")} confirm`],H=(e,t)=>e.includes(`
25
+ `)?e.split(`
26
+ `).map(r=>t(r)).join(`
27
+ `):t(e),te=e=>{const t=(s,a)=>{if(s===void 0)return"";const l=s.label??String(s.value);switch(a){case"disabled":return`${c("gray",_e)} ${H(l,o=>c("gray",o))}${s.hint?` ${c("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${H(l,o=>c("dim",o))}`;case"active":return`${c("green",nt)} ${l}${s.hint?` ${c("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${H(l,o=>c(["strikethrough","dim"],o))}`;default:return`${c("dim",_e)} ${H(l,o=>c("dim",o))}`}},r=e.showInstructions??!0;return new Ze({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=e.withGuide??M.withGuide,a=`${Ee(this.state)} `,l=`${ut(this.state)} `,o=ee(e.output,e.message,l,a),n=`${s?`${c("gray",$)}
28
+ `:""}${o}
29
+ `;switch(this.state){case"submit":{const i=s?`${c("gray",$)} `:"",u=ee(e.output,t(this.options[this.cursor],"selected"),i);return`${n}${u}`}case"cancel":{const i=s?`${c("gray",$)} `:"",u=ee(e.output,t(this.options[this.cursor],"cancelled"),i);return`${n}${u}${s?`
30
+ ${c("gray",$)}`:""}`}default:{const i=s?`${c("cyan",$)} `:"",u=n.split(`
31
+ `).length,m=r?ht(ft,s):s?[c("cyan",j)]:[],h=m.join(`
32
+ `),d=m.length+1;return`${n}${i}${mt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:i.length,rowPadding:u+d,style:(f,p)=>t(f,f.disabled?"disabled":p?"active":"inactive")}).join(`
33
+ ${i}`)}
34
34
  ${h}
35
- `}}}}).prompt()};`${c("gray",$)}`;const vt=t=>new Zt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,output:t.output,signal:t.signal,input:t.input,render(){const e=t?.withGuide??M.withGuide,r=`${`${e?`${c("gray",$)}
36
- `:""}${wt(this.state)} `}${t.message}
37
- `,i=t.placeholder&&t.placeholder.length>0?c("inverse",t.placeholder[0])+c("dim",t.placeholder.slice(1)):c(["inverse","hidden"],"_"),o=this.userInput?this.userInputWithCursor:i,l=this.value??"";switch(this.state){case"error":{const n=this.error?` ${c("yellow",this.error)}`:"",a=e?`${c("yellow",$)} `:"",s=e?c("yellow",P):"";return`${r.trim()}
38
- ${a}${o}
39
- ${s}${n}
40
- `}case"submit":{const n=l?` ${c("dim",l)}`:"",a=e?c("gray",$):"";return`${r}${a}${n}`}case"cancel":{const n=l?` ${c(["strikethrough","dim"],l)}`:"",a=e?c("gray",$):"";return`${r}${a}${n}${l.trim()?`
41
- ${a}`:""}`}default:{const n=e?`${c("cyan",$)} `:"",a=e?c("cyan",P):"";return`${r}${n}${o}
42
- ${a}
43
- `}}}}).prompt();function Q(t){return t==null?[]:Array.isArray(t)?t:[t]}function pe(t,e,r,i){var o,l=t[e],n=~i.string.indexOf(e)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~i.boolean.indexOf(e)?r==="false"?!1:r==="true"||(t._.push((o=+r,o*0===0?o:r)),!!r):(o=+r,o*0===0?o:r);t[e]=l==null?n:Array.isArray(l)?l.concat(n):[l,n]}function ge(t,e){t=t||[],e=e||{};var r,i,o,l,n,a={_:[]},s=0,u=0,m=0,h=t.length;const d=e.alias!==void 0,p=e.unknown!==void 0,f=e.default!==void 0;if(e.alias=e.alias||{},e.string=Q(e.string),e.boolean=Q(e.boolean),d)for(r in e.alias)for(i=e.alias[r]=Q(e.alias[r]),s=0;s<i.length;s++)(e.alias[i[s]]=i.concat(r)).splice(s,1);for(s=e.boolean.length;s-- >0;)for(i=e.alias[e.boolean[s]]||[],u=i.length;u-- >0;)e.boolean.push(i[u]);for(s=e.string.length;s-- >0;)for(i=e.alias[e.string[s]]||[],u=i.length;u-- >0;)e.string.push(i[u]);if(f){for(r in e.default)if(l=typeof e.default[r],i=e.alias[r]=e.alias[r]||[],e[l]!==void 0)for(e[l].push(r),s=0;s<i.length;s++)e[l].push(i[s])}const g=p?Object.keys(e.alias):[];for(s=0;s<h;s++){if(o=t[s],o==="--"){a._=a._.concat(t.slice(++s));break}for(u=0;u<o.length&&o.charCodeAt(u)===45;u++);if(u===0)a._.push(o);else if(o.substring(u,u+3)==="no-"){if(l=o.substring(u+3),p&&!~g.indexOf(l))return e.unknown(o);a[l]=!1}else{for(m=u+1;m<o.length&&o.charCodeAt(m)!==61;m++);for(l=o.substring(u,m),n=o.substring(++m)||s+1===h||(""+t[s+1]).charCodeAt(0)===45||t[++s],i=u===2?[l]:l,m=0;m<i.length;m++){if(l=i[m],p&&!~g.indexOf(l))return e.unknown("-".repeat(u)+l);pe(a,l,m+1<i.length||n,e)}}}if(f)for(r in e.default)a[r]===void 0&&(a[r]=e.default[r]);if(d)for(r in a)for(i=e.alias[r]||[];i.length>0;)a[i.shift()]=a[r];return a}var H={exports:{}},Et;function be(){if(Et)return H.exports;Et=1;let t=process||{},e=t.argv||[],r=t.env||{},i=!(r.NO_COLOR||e.includes("--no-color"))&&(!!r.FORCE_COLOR||e.includes("--color")||t.platform==="win32"||(t.stdout||{}).isTTY&&r.TERM!=="dumb"||!!r.CI),o=(a,s,u=a)=>m=>{let h=""+m,d=h.indexOf(s,a.length);return~d?a+l(h,s,u,d)+s:a+h+s},l=(a,s,u,m)=>{let h="",d=0;do h+=a.substring(d,m)+u,d=m+s.length,m=a.indexOf(s,d);while(~m);return h+a.substring(d)},n=(a=i)=>{let s=a?o:()=>String;return{isColorSupported:a,reset:s("\x1B[0m","\x1B[0m"),bold:s("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:s("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:s("\x1B[3m","\x1B[23m"),underline:s("\x1B[4m","\x1B[24m"),inverse:s("\x1B[7m","\x1B[27m"),hidden:s("\x1B[8m","\x1B[28m"),strikethrough:s("\x1B[9m","\x1B[29m"),black:s("\x1B[30m","\x1B[39m"),red:s("\x1B[31m","\x1B[39m"),green:s("\x1B[32m","\x1B[39m"),yellow:s("\x1B[33m","\x1B[39m"),blue:s("\x1B[34m","\x1B[39m"),magenta:s("\x1B[35m","\x1B[39m"),cyan:s("\x1B[36m","\x1B[39m"),white:s("\x1B[37m","\x1B[39m"),gray:s("\x1B[90m","\x1B[39m"),bgBlack:s("\x1B[40m","\x1B[49m"),bgRed:s("\x1B[41m","\x1B[49m"),bgGreen:s("\x1B[42m","\x1B[49m"),bgYellow:s("\x1B[43m","\x1B[49m"),bgBlue:s("\x1B[44m","\x1B[49m"),bgMagenta:s("\x1B[45m","\x1B[49m"),bgCyan:s("\x1B[46m","\x1B[49m"),bgWhite:s("\x1B[47m","\x1B[49m"),blackBright:s("\x1B[90m","\x1B[39m"),redBright:s("\x1B[91m","\x1B[39m"),greenBright:s("\x1B[92m","\x1B[39m"),yellowBright:s("\x1B[93m","\x1B[39m"),blueBright:s("\x1B[94m","\x1B[39m"),magentaBright:s("\x1B[95m","\x1B[39m"),cyanBright:s("\x1B[96m","\x1B[39m"),whiteBright:s("\x1B[97m","\x1B[39m"),bgBlackBright:s("\x1B[100m","\x1B[49m"),bgRedBright:s("\x1B[101m","\x1B[49m"),bgGreenBright:s("\x1B[102m","\x1B[49m"),bgYellowBright:s("\x1B[103m","\x1B[49m"),bgBlueBright:s("\x1B[104m","\x1B[49m"),bgMagentaBright:s("\x1B[105m","\x1B[49m"),bgCyanBright:s("\x1B[106m","\x1B[49m"),bgWhiteBright:s("\x1B[107m","\x1B[49m")}};return H.exports=n(),H.exports.createColors=n,H.exports}var xe=be();const $e=Ht(xe),{cyan:we,yellow:_e}=$e,St=[{name:"vanilla-ts",display:"Vanilla",description:"with PlayCanvas Engine",color:_e},{name:"react-ts",display:"React",description:"with @playcanvas/react",color:we}],ye=async({argTemplate:t,cancel:e})=>{if(t&&St.some(i=>i.name===t))return t;const r=await yt({message:t?`"${t}" isn't a valid template. Please choose from below: `:"Select a template:",options:St.map(i=>({label:i.color(i.display),value:i.name,hint:i.description}))});return U(r)&&e(),r},It=t=>/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(t),Ft=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-"),ve=async({targetDir:t,cancel:e})=>{let r=F.basename(F.resolve(t));if(!It(r)){const i=await vt({message:"Package name:",defaultValue:Ft(r),placeholder:Ft(r),validate:o=>{if(!o||!It(o))return"Invalid package.json name"}});if(U(i))return e();r=i}return r},tt=t=>t.trim().replace(/\/+$/g,""),Ee=t=>{const e=R.readdirSync(t);return e.length===0||e.length===1&&e[0]===".git"},Se=t=>{if(R.existsSync(t))for(const e of R.readdirSync(t))e!==".git"&&R.rmSync(F.resolve(t,e),{recursive:!0,force:!0})},Ie=async({argTargetDir:t,defaultTargetDir:e,cancel:r})=>{let i=t?tt(String(t)):void 0;if(!i){const o=await vt({message:"Project name:",defaultValue:e,placeholder:e});U(o)&&r(),i=tt(o)}return i},Fe=async({targetDir:t,argOverwrite:e,cancel:r})=>{if(R.existsSync(t)&&!Ee(t)){const i=e?"yes":await yt({message:(t==="."?"Current directory":`Target directory "${t}"`)+" is not empty. Please choose how to proceed:",options:[{label:"Cancel operation",value:"no"},{label:"Remove existing files and continue",value:"yes"},{label:"Ignore files and continue",value:"ignore"}]});if(U(i))return r();switch(i){case"yes":Se(t);break;case"no":r();return}}},Te=t=>{const{cwd:e,targetDir:r,template:i,packageName:o,renameFiles:l}=t,n=F.resolve(e,r);R.mkdirSync(n,{recursive:!0});const a=process.env.npm_config_user_agent?.split("/")[0]??"npm";N.step(`Creating project in ${n}...`);const s=Rt(import.meta.url),u=F.dirname(s),m=[F.resolve(u,"../templates",i),F.resolve(u,"../../templates",i)].find(b=>R.existsSync(b));if(!m)throw new Error(`Template directory not found for: ${i}`);const h=(b,_)=>{const I=F.join(n,l[b]??b);_!==void 0?R.writeFileSync(I,_):R.cpSync(F.join(m,b),I,{recursive:!0})},d=R.readdirSync(m);for(const b of d.filter(_=>_!=="package.json"))h(b);const p=JSON.parse(R.readFileSync(F.join(m,"package.json"),"utf-8"));p.name=o,h("package.json",JSON.stringify(p,null,4)+`
44
- `);let f=`Project created. Now run:
45
- `;const g=F.isAbsolute(r)?n:F.relative(e,n);switch(n!==e&&(f+=`
46
- cd ${g.includes(" ")?`"${g}"`:g}`),a){case"yarn":f+=`
47
- yarn`,f+=`
48
- yarn dev`;break;default:f+=`
49
- ${a} install`,f+=`
50
- ${a} run dev`;break}de(f)},D=ge(process.argv.slice(2),{alias:{h:"help",t:"template"},boolean:["help","overwrite"],string:["template"]}),Ce=process.cwd(),Re=`Usage: npm create playcanvas@latest [OPTION]...
35
+ `}}}}).prompt()};`${c("gray",$)}`;const Ie=e=>new Qe({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const t=e?.withGuide??M.withGuide,r=`${`${t?`${c("gray",$)}
36
+ `:""}${Ee(this.state)} `}${e.message}
37
+ `,s=e.placeholder&&e.placeholder.length>0?c("inverse",e.placeholder[0])+c("dim",e.placeholder.slice(1)):c(["inverse","hidden"],"_"),a=this.userInput?this.userInputWithCursor:s,l=this.value??"";switch(this.state){case"error":{const o=this.error?` ${c("yellow",this.error)}`:"",n=t?`${c("yellow",$)} `:"",i=t?c("yellow",j):"";return`${r.trim()}
38
+ ${n}${a}
39
+ ${i}${o}
40
+ `}case"submit":{const o=l?` ${c("dim",l)}`:"",n=t?c("gray",$):"";return`${r}${n}${o}`}case"cancel":{const o=l?` ${c(["strikethrough","dim"],l)}`:"",n=t?c("gray",$):"";return`${r}${n}${o}${l.trim()?`
41
+ ${n}`:""}`}default:{const o=t?`${c("cyan",$)} `:"",n=t?c("cyan",j):"";return`${r}${o}${a}
42
+ ${n}
43
+ `}}}}).prompt();function re(e){return e==null?[]:Array.isArray(e)?e:[e]}function gt(e,t,r,s){var a,l=e[t],o=~s.string.indexOf(t)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~s.boolean.indexOf(t)?r==="false"?!1:r==="true"||(e._.push((a=+r,a*0===0?a:r)),!!r):(a=+r,a*0===0?a:r);e[t]=l==null?o:Array.isArray(l)?l.concat(o):[l,o]}function bt(e,t){e=e||[],t=t||{};var r,s,a,l,o,n={_:[]},i=0,u=0,m=0,h=e.length;const d=t.alias!==void 0,f=t.unknown!==void 0,p=t.default!==void 0;if(t.alias=t.alias||{},t.string=re(t.string),t.boolean=re(t.boolean),d)for(r in t.alias)for(s=t.alias[r]=re(t.alias[r]),i=0;i<s.length;i++)(t.alias[s[i]]=s.concat(r)).splice(i,1);for(i=t.boolean.length;i-- >0;)for(s=t.alias[t.boolean[i]]||[],u=s.length;u-- >0;)t.boolean.push(s[u]);for(i=t.string.length;i-- >0;)for(s=t.alias[t.string[i]]||[],u=s.length;u-- >0;)t.string.push(s[u]);if(p){for(r in t.default)if(l=typeof t.default[r],s=t.alias[r]=t.alias[r]||[],t[l]!==void 0)for(t[l].push(r),i=0;i<s.length;i++)t[l].push(s[i])}const g=f?Object.keys(t.alias):[];for(i=0;i<h;i++){if(a=e[i],a==="--"){n._=n._.concat(e.slice(++i));break}for(u=0;u<a.length&&a.charCodeAt(u)===45;u++);if(u===0)n._.push(a);else if(a.substring(u,u+3)==="no-"){if(l=a.substring(u+3),f&&!~g.indexOf(l))return t.unknown(a);n[l]=!1}else{for(m=u+1;m<a.length&&a.charCodeAt(m)!==61;m++);for(l=a.substring(u,m),o=a.substring(++m)||i+1===h||(""+e[i+1]).charCodeAt(0)===45||e[++i],s=u===2?[l]:l,m=0;m<s.length;m++){if(l=s[m],f&&!~g.indexOf(l))return t.unknown("-".repeat(u)+l);gt(n,l,m+1<s.length||o,t)}}}if(p)for(r in t.default)n[r]===void 0&&(n[r]=t.default[r]);if(d)for(r in n)for(s=t.alias[r]||[];s.length>0;)n[s.shift()]=n[r];return n}var z={exports:{}},Fe;function xt(){if(Fe)return z.exports;Fe=1;let e=process||{},t=e.argv||[],r=e.env||{},s=!(r.NO_COLOR||t.includes("--no-color"))&&(!!r.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&r.TERM!=="dumb"||!!r.CI),a=(n,i,u=n)=>m=>{let h=""+m,d=h.indexOf(i,n.length);return~d?n+l(h,i,u,d)+i:n+h+i},l=(n,i,u,m)=>{let h="",d=0;do h+=n.substring(d,m)+u,d=m+i.length,m=n.indexOf(i,d);while(~m);return h+n.substring(d)},o=(n=s)=>{let i=n?a:()=>String;return{isColorSupported:n,reset:i("\x1B[0m","\x1B[0m"),bold:i("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:i("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:i("\x1B[3m","\x1B[23m"),underline:i("\x1B[4m","\x1B[24m"),inverse:i("\x1B[7m","\x1B[27m"),hidden:i("\x1B[8m","\x1B[28m"),strikethrough:i("\x1B[9m","\x1B[29m"),black:i("\x1B[30m","\x1B[39m"),red:i("\x1B[31m","\x1B[39m"),green:i("\x1B[32m","\x1B[39m"),yellow:i("\x1B[33m","\x1B[39m"),blue:i("\x1B[34m","\x1B[39m"),magenta:i("\x1B[35m","\x1B[39m"),cyan:i("\x1B[36m","\x1B[39m"),white:i("\x1B[37m","\x1B[39m"),gray:i("\x1B[90m","\x1B[39m"),bgBlack:i("\x1B[40m","\x1B[49m"),bgRed:i("\x1B[41m","\x1B[49m"),bgGreen:i("\x1B[42m","\x1B[49m"),bgYellow:i("\x1B[43m","\x1B[49m"),bgBlue:i("\x1B[44m","\x1B[49m"),bgMagenta:i("\x1B[45m","\x1B[49m"),bgCyan:i("\x1B[46m","\x1B[49m"),bgWhite:i("\x1B[47m","\x1B[49m"),blackBright:i("\x1B[90m","\x1B[39m"),redBright:i("\x1B[91m","\x1B[39m"),greenBright:i("\x1B[92m","\x1B[39m"),yellowBright:i("\x1B[93m","\x1B[39m"),blueBright:i("\x1B[94m","\x1B[39m"),magentaBright:i("\x1B[95m","\x1B[39m"),cyanBright:i("\x1B[96m","\x1B[39m"),whiteBright:i("\x1B[97m","\x1B[39m"),bgBlackBright:i("\x1B[100m","\x1B[49m"),bgRedBright:i("\x1B[101m","\x1B[49m"),bgGreenBright:i("\x1B[102m","\x1B[49m"),bgYellowBright:i("\x1B[103m","\x1B[49m"),bgBlueBright:i("\x1B[104m","\x1B[49m"),bgMagentaBright:i("\x1B[105m","\x1B[49m"),bgCyanBright:i("\x1B[106m","\x1B[49m"),bgWhiteBright:i("\x1B[107m","\x1B[49m")}};return z.exports=o(),z.exports.createColors=o,z.exports}var $t=xt();const yt=ze($t),{cyan:wt,magenta:vt,yellow:_t}=yt,J=[{name:"engine",display:"Engine",description:"with the PlayCanvas Engine API directly",color:_t},{name:"react",display:"React",description:"with @playcanvas/react",color:wt},{name:"web-components",display:"Web Components",description:"with @playcanvas/web-components",color:vt}],W=[{name:"spinning-cube",display:"Spinning Cube",description:"a rotating cube and a light"},{name:"interactive-sphere",display:"Interactive Sphere",description:"orbit controls, a grid and pointer picking"},{name:"model-viewer",display:"Model Viewer",description:"a glTF model, orbit controls and a procedural sky"},{name:"splat-viewer",display:"Splat Viewer",description:"a Gaussian splat and orbit controls"}],Et=async({argBoilerplate:e,yes:t,cancel:r})=>{if(e&&W.some(a=>a.name===e))return e;if(!process.stdout.isTTY||t){if(!e)return W[0].name;throw new Error(`Unknown boilerplate: ${e}. Choose from: ${W.map(a=>a.name).join(", ")}`)}const s=await te({message:e?`"${e}" isn't a valid boilerplate. Please choose from below: `:"Select a boilerplate:",initialValue:W[0].name,options:W.map(a=>({label:a.display,value:a.name,hint:a.description}))});return D(s)&&r(),s},St=async({argTemplate:e,yes:t,cancel:r})=>{if(e&&J.some(a=>a.name===e))return e;if(e&&(!process.stdout.isTTY||t))throw new Error(`Unknown template: ${e}. Choose from: ${J.map(a=>a.name).join(", ")}`);if(t)return J[0].name;const s=await te({message:e?`"${e}" isn't a valid template. Please choose from below: `:"Select a template:",options:J.map(a=>({label:a.color(a.display),value:a.name,hint:a.description}))});return D(s)&&r(),s},Te=e=>/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e),ie=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-"),It=async({targetDir:e,yes:t,cancel:r})=>{let s=_.basename(_.resolve(e));if(!Te(s)){if(t)return ie(s);const a=await Ie({message:"Package name:",defaultValue:ie(s),placeholder:ie(s),validate:l=>{if(!l||!Te(l))return"Invalid package.json name"}});if(D(a))return r();s=a}return s},se=e=>e.trim().replace(/\/+$/g,""),Ft=e=>{const t=I.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"},Tt=e=>{if(I.existsSync(e))for(const t of I.readdirSync(e))t!==".git"&&I.rmSync(_.resolve(e,t),{recursive:!0,force:!0})},Ct=async({argTargetDir:e,defaultTargetDir:t,yes:r,cancel:s})=>{let a=e?se(String(e)):void 0;if(!a&&r)return t;if(!a){const l=await Ie({message:"Project name:",defaultValue:t,placeholder:t});D(l)&&s(),a=se(l)}return a},Rt=async({targetDir:e,argOverwrite:t,yes:r,cancel:s})=>{if(I.existsSync(e)&&!Ft(e)){if(r&&!t)throw new Error(`Target directory "${e}" is not empty. Pass --overwrite to remove its contents.`);const a=t?"yes":await te({message:(e==="."?"Current directory":`Target directory "${e}"`)+" is not empty. Please choose how to proceed:",options:[{label:"Cancel operation",value:"no"},{label:"Remove existing files and continue",value:"yes"},{label:"Ignore files and continue",value:"ignore"}]});if(D(a))return s();switch(a){case"yes":Tt(e);break;case"no":s();return}}},At=e=>{const{cwd:t,targetDir:r,template:s,boilerplate:a,packageName:l,renameFiles:o}=e,n=_.resolve(t,r);I.mkdirSync(n,{recursive:!0});const i=process.env.npm_config_user_agent?.split("/")[0]??"npm";N.step(`Creating project in ${n}...`);const u=Ae(import.meta.url),m=_.dirname(u),h=[_.resolve(m,"../templates"),_.resolve(m,"../../templates")].find(w=>I.existsSync(_.join(w,s)));if(!h)throw new Error(`Template directory not found for: ${s}`);const d=_.join(h,s),f=_.join(h,"_shared",a);I.existsSync(f)&&I.cpSync(f,n,{recursive:!0});for(const w of["base",a]){const C=_.join(d,w);if(!I.existsSync(C))throw new Error(`Boilerplate directory not found: ${s}/${w}`);I.cpSync(C,n,{recursive:!0})}for(const[w,C]of Object.entries(o)){const R=_.join(n,w);I.existsSync(R)&&I.renameSync(R,_.join(n,C))}const p=_.join(n,"package.json"),g=JSON.parse(I.readFileSync(p,"utf-8"));g.name=l,I.writeFileSync(p,JSON.stringify(g,null,4)+`
44
+ `);let b=`Project created. Now run:
45
+ `;const E=_.isAbsolute(r)?n:_.relative(t,n);switch(n!==t&&(b+=`
46
+ cd ${E.includes(" ")?`"${E}"`:E}`),i){case"yarn":b+=`
47
+ yarn`,b+=`
48
+ yarn dev`;break;default:b+=`
49
+ ${i} install`,b+=`
50
+ ${i} run dev`;break}pt(b)},P=bt(process.argv.slice(2),{alias:{h:"help",t:"template",b:"boilerplate",y:"yes"},boolean:["help","overwrite","yes"],string:["template","boilerplate"]}),kt=process.cwd(),Bt=`Usage: npm create playcanvas@latest [OPTION]...
51
51
 
52
52
  Create a new PlayCanvas project with TypeScript.
53
53
  With no arguments, start the CLI in interactive mode.
54
54
 
55
55
  Options:
56
56
  -t, --template NAME use a specific template
57
+ -b, --boilerplate NAME use a specific boilerplate
57
58
  --overwrite remove existing files from a non-empty target directory
59
+ -y, --yes skip the prompts and take the defaults
58
60
  -h, --help show help
59
- `,Ae={_gitignore:".gitignore"},Le="playcanvas-project",ke=async()=>{const t=D._[0]?tt(String(D._[0])):void 0,e=D.template,r=D.overwrite;if(D.help){console.log(Re);return}const i=()=>{me("Operation cancelled"),process.exit(0)},o=await Ie({argTargetDir:t,defaultTargetDir:Le,cancel:i});await Fe({targetDir:o,argOverwrite:r,cancel:i});const l=await ve({targetDir:o,cancel:i}),n=await ye({argTemplate:e,cancel:i});await Te({cwd:Ce,targetDir:o,template:n,packageName:l,renameFiles:Ae})};ke().catch(t=>{console.error(t),process.exitCode=1});
61
+ `,Lt={_gitignore:".gitignore"},Ot="playcanvas-project",Mt=async()=>{const e=P._[0]?se(String(P._[0])):void 0,t=P.template,r=P.boilerplate,s=P.overwrite,a=P.yes;if(P.help){console.log(Bt);return}const l=()=>{dt("Operation cancelled"),process.exit(0)},o=await Ct({argTargetDir:e,defaultTargetDir:Ot,yes:a,cancel:l});await Rt({targetDir:o,argOverwrite:s,yes:a,cancel:l});const n=await It({targetDir:o,yes:a,cancel:l}),i=await St({argTemplate:t,yes:a,cancel:l}),u=await Et({argBoilerplate:r,yes:a,cancel:l});At({cwd:kt,targetDir:o,template:i,boilerplate:u,packageName:n,renameFiles:Lt})};Mt().catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-playcanvas",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Scaffold a PlayCanvas project",
5
5
  "keywords": [
6
6
  "playcanvas",
@@ -9,6 +9,7 @@
9
9
  "template",
10
10
  "vite",
11
11
  "react",
12
+ "web-components",
12
13
  "typescript",
13
14
  "webgl",
14
15
  "webgpu",
@@ -1,4 +1,4 @@
1
- # PlayCanvas + TypeScript Starter
1
+ # PlayCanvas Engine + TypeScript Starter
2
2
 
3
3
  A Vite-powered PlayCanvas Engine project with TypeScript, hot module replacement, ESLint and Prettier.
4
4
 
@@ -9,13 +9,13 @@ Node.js 22.23.2 or later.
9
9
  ## Getting started
10
10
 
11
11
  ```bash
12
- npm create playcanvas@latest playcanvas-project -- --template vanilla-ts
12
+ npm create playcanvas@latest playcanvas-project -- --template engine
13
13
  cd playcanvas-project
14
14
  npm install
15
15
  npm run dev
16
16
  ```
17
17
 
18
- Open <http://localhost:5173>. Edit `src/App.ts` to test hot module replacement.
18
+ Open <http://localhost:5173>. Edit the files under `src/` and save to see the scene update.
19
19
 
20
20
  ## Scripts
21
21
 
@@ -28,22 +28,6 @@ Open <http://localhost:5173>. Edit `src/App.ts` to test hot module replacement.
28
28
  | `npm run fmt` | Check formatting |
29
29
  | `npm run typecheck` | Run TypeScript checks |
30
30
 
31
- ## Project structure
32
-
33
- ```text
34
- .
35
- ├── public/
36
- │ └── environment-map.png
37
- ├── src/
38
- │ ├── assets/
39
- │ ├── App.ts
40
- │ ├── main.ts
41
- │ └── style.css
42
- ├── eslint.config.mjs
43
- ├── index.html
44
- └── tsconfig.json
45
- ```
46
-
47
31
  Run `npm run build` to generate a deployable static site in `dist/`.
48
32
 
49
33
  ## Further reading
@@ -11,3 +11,9 @@ declare module 'playcanvas/scripts/esm/grid.mjs' {
11
11
 
12
12
  export const Grid: typeof Script & (new () => Script);
13
13
  }
14
+
15
+ declare module 'playcanvas/scripts/esm/sky/procedural-sky.mjs' {
16
+ import type { Script } from 'playcanvas';
17
+
18
+ export const ProceduralSky: typeof Script & (new () => Script);
19
+ }
@@ -16,7 +16,7 @@ document.querySelector<HTMLDivElement>('#root')!.innerHTML = `
16
16
  <img src="${playcanvasLogo}" class="playcanvas-logo logo" alt="PlayCanvas logo" />
17
17
  </a>
18
18
  <a href="https://www.typescriptlang.org/" target="_blank">
19
- <img src="${typescriptLogo}" class="logo vanilla" alt="TypeScript logo" />
19
+ <img src="${typescriptLogo}" class="logo typescript" alt="TypeScript logo" />
20
20
  </a>
21
21
  </header>
22
22
  </div>
@@ -59,7 +59,7 @@ h1 {
59
59
  filter: drop-shadow(0 0 2em #646cffaa);
60
60
  }
61
61
 
62
- .logo.vanilla:hover {
62
+ .logo.typescript:hover {
63
63
  filter: drop-shadow(0 0 2em #3178c6aa);
64
64
  }
65
65
 
@@ -5,7 +5,6 @@
5
5
  * @returns A throttled function
6
6
  */
7
7
  export const throttle = <T extends unknown[]>(fn: (...args: T) => void, interval = 100) => {
8
- // interval in ms
9
8
  let last = 0;
10
9
  return (...args: T) => {
11
10
  const now = Date.now();
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/png" href="/src/assets/playcanvas.png" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>PlayCanvas + TS</title>
8
+ </head>
9
+ <body>
10
+ <canvas id="application-canvas"></canvas>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,81 @@
1
+ import type { ContainerResource } from 'playcanvas';
2
+ import {
3
+ AppBase,
4
+ AppOptions,
5
+ Asset,
6
+ AssetListLoader,
7
+ CameraComponentSystem,
8
+ ContainerHandler,
9
+ Entity,
10
+ FILLMODE_FILL_WINDOW,
11
+ RESOLUTION_AUTO,
12
+ RenderComponentSystem,
13
+ ScriptComponentSystem,
14
+ TONEMAP_ACES2,
15
+ TextureHandler,
16
+ createGraphicsDevice
17
+ } from 'playcanvas';
18
+ import { CameraControls } from 'playcanvas/scripts/esm/camera-controls.mjs';
19
+ import { ProceduralSky } from 'playcanvas/scripts/esm/sky/procedural-sky.mjs';
20
+
21
+ import './style.css';
22
+
23
+ // Swap this for your own model - anything you drop in public/ is served from the site root
24
+ const MODEL_URL = '/playcanvas-cube.glb';
25
+
26
+ const canvas = document.getElementById('application-canvas') as HTMLCanvasElement;
27
+
28
+ const device = await createGraphicsDevice(canvas);
29
+ device.maxPixelRatio = Math.min(window.devicePixelRatio, 2);
30
+
31
+ const createOptions = new AppOptions();
32
+ createOptions.graphicsDevice = device;
33
+ createOptions.componentSystems = [RenderComponentSystem, CameraComponentSystem, ScriptComponentSystem];
34
+ createOptions.resourceHandlers = [TextureHandler, ContainerHandler];
35
+
36
+ const app = new AppBase(canvas);
37
+ app.init(createOptions);
38
+
39
+ // Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
40
+ app.setCanvasFillMode(FILLMODE_FILL_WINDOW);
41
+ app.setCanvasResolution(RESOLUTION_AUTO);
42
+
43
+ // Ensure canvas is resized when window changes size
44
+ const resize = () => app.resizeCanvas();
45
+ window.addEventListener('resize', resize);
46
+ app.on('destroy', () => {
47
+ window.removeEventListener('resize', resize);
48
+ });
49
+
50
+ // Load the model before starting, so the first frame already has something in it
51
+ const model = new Asset('model', 'container', { url: MODEL_URL });
52
+
53
+ await new Promise<void>((resolve) => {
54
+ new AssetListLoader([model], app.assets).load(() => resolve());
55
+ });
56
+
57
+ app.start();
58
+
59
+ // A container asset holds the whole glTF scene, so instantiate it to get an entity hierarchy
60
+ app.root.addChild((model.resource as ContainerResource).instantiateRenderEntity());
61
+
62
+ // The procedural sky is both the background and the image-based lighting, so no light or
63
+ // environment map asset is needed. Its default luminance is scene-scale bright, so turn it down to
64
+ // keep the model out of clipping
65
+ const sky = new Entity('sky');
66
+ sky.addComponent('script');
67
+ sky.script?.create(ProceduralSky, {
68
+ properties: { luminance: 0.2 }
69
+ });
70
+ app.root.addChild(sky);
71
+
72
+ // Create camera entity with orbit controls. The sky is HDR, so it needs tone mapping to bring it
73
+ // back into displayable range - without it the whole image blows out to white
74
+ const camera = new Entity('camera');
75
+ camera.addComponent('camera', {
76
+ toneMapping: TONEMAP_ACES2
77
+ });
78
+ camera.setPosition(0, 0, 3);
79
+ camera.addComponent('script');
80
+ camera.script?.create(CameraControls);
81
+ app.root.addChild(camera);
@@ -0,0 +1,8 @@
1
+ body {
2
+ margin: 0;
3
+ overflow: hidden;
4
+ }
5
+
6
+ canvas {
7
+ display: block;
8
+ }