create-playcanvas 0.5.0 → 0.6.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.
- package/README.md +20 -27
- package/dist/index.mjs +44 -42
- package/package.json +1 -1
- package/templates/_features/physics/assets/public/ammo/LICENSE +21 -0
- package/templates/_features/physics/assets/public/ammo/SOURCE.md +16 -0
- package/templates/_features/physics/assets/public/ammo/ammo.js +973 -0
- package/templates/_features/physics/assets/public/ammo/ammo.wasm.js +937 -0
- package/templates/_features/physics/assets/public/ammo/ammo.wasm.wasm +0 -0
- package/templates/_features/physics/react/package.json +5 -0
- package/templates/_features/physics/react/src/sync-ammo.d.ts +4 -0
- package/templates/_shared/ar-placement/README.md +7 -0
- package/templates/_shared/ar-placement/src/ar-placement.ts +123 -0
- package/templates/_shared/first-person-controller/README.md +7 -0
- package/templates/_shared/first-person-controller/src/controller.ts +18 -0
- package/templates/_shared/first-person-controller/src/scripts.d.ts +5 -0
- package/templates/_shared/interactive-sphere/README.md +7 -0
- package/templates/_shared/model-viewer/README.md +7 -0
- package/templates/_shared/physics-playground/README.md +7 -0
- package/templates/_shared/product-configurator/ASSET_LICENSES.md +3 -0
- package/templates/_shared/product-configurator/README.md +7 -0
- package/templates/_shared/product-configurator/src/product.css +14 -0
- package/templates/_shared/scene-editor/README.md +7 -0
- package/templates/_shared/scene-editor/src/scene-editor.ts +57 -0
- package/templates/_shared/spinning-cube/README.md +7 -0
- package/templates/_shared/splat-viewer/README.md +7 -0
- package/templates/_shared/sprite-game/README.md +7 -0
- package/templates/_shared/sprite-game/src/sprite-game.ts +197 -0
- package/templates/_shared/third-person-controller/README.md +7 -0
- package/templates/_shared/third-person-controller/src/controller.ts +53 -0
- package/templates/_shared/third-person-controller/src/scripts.d.ts +5 -0
- package/templates/_shared/vr-starter/README.md +7 -0
- package/templates/_shared/vr-starter/src/vr.ts +40 -0
- package/templates/_shared/vr-starter/src/xr.d.ts +11 -0
- package/templates/engine/ar-placement/src/main.ts +77 -0
- package/templates/engine/base/.prettierignore +1 -0
- package/templates/engine/base/README.md +1 -1
- package/templates/engine/base/_npmrc +1 -0
- package/templates/engine/base/eslint.config.mjs +1 -1
- package/templates/engine/base/index.html +13 -0
- package/templates/engine/base/package.json +2 -2
- package/templates/engine/base/src/starter.css +104 -0
- package/templates/engine/first-person-controller/src/main.ts +139 -0
- package/templates/engine/interactive-sphere/src/App.ts +9 -7
- package/templates/engine/interactive-sphere/src/main.ts +2 -29
- package/templates/engine/interactive-sphere/src/style.css +18 -97
- package/templates/engine/model-viewer/src/main.ts +3 -2
- package/templates/engine/physics-playground/src/main.ts +132 -0
- package/templates/engine/product-configurator/src/main.ts +156 -0
- package/templates/engine/scene-editor/src/main.ts +90 -0
- package/templates/engine/splat-viewer/src/main.ts +4 -3
- package/templates/engine/sprite-game/src/main.ts +72 -0
- package/templates/engine/third-person-controller/src/main.ts +216 -0
- package/templates/engine/vr-starter/src/main.ts +101 -0
- package/templates/index.ts +66 -5
- package/templates/react/ar-placement/src/App.tsx +58 -0
- package/templates/react/base/.prettierignore +1 -0
- package/templates/react/base/README.md +1 -1
- package/templates/react/base/_npmrc +1 -0
- package/templates/react/base/eslint.config.mjs +1 -1
- package/templates/react/base/index.html +13 -0
- package/templates/react/base/package.json +2 -2
- package/templates/react/base/src/main.tsx +10 -0
- package/templates/react/base/src/starter.css +104 -0
- package/templates/react/first-person-controller/src/App.tsx +115 -0
- package/templates/react/interactive-sphere/src/App.css +18 -68
- package/templates/react/interactive-sphere/src/App.tsx +1 -22
- package/templates/react/interactive-sphere/src/Scene.tsx +7 -6
- package/templates/react/interactive-sphere/src/index.css +1 -48
- package/templates/react/model-viewer/src/App.tsx +2 -2
- package/templates/react/physics-playground/src/App.tsx +85 -0
- package/templates/react/product-configurator/src/App.tsx +157 -0
- package/templates/react/scene-editor/src/App.tsx +84 -0
- package/templates/react/splat-viewer/src/App.tsx +3 -3
- package/templates/react/sprite-game/src/App.tsx +38 -0
- package/templates/react/third-person-controller/src/App.tsx +193 -0
- package/templates/react/vr-starter/src/App.tsx +99 -0
- package/templates/web-components/ar-placement/index.html +44 -0
- package/templates/web-components/ar-placement/src/main.ts +13 -0
- package/templates/web-components/base/.prettierignore +1 -0
- package/templates/web-components/base/README.md +1 -1
- package/templates/web-components/base/_npmrc +1 -0
- package/templates/web-components/base/eslint.config.mjs +1 -1
- package/templates/web-components/base/package.json +3 -3
- package/templates/web-components/base/src/starter.css +104 -0
- package/templates/web-components/first-person-controller/index.html +168 -0
- package/templates/web-components/first-person-controller/src/main.ts +15 -0
- package/templates/web-components/interactive-sphere/index.html +5 -22
- package/templates/web-components/interactive-sphere/src/main.ts +5 -4
- package/templates/web-components/interactive-sphere/src/style.css +18 -76
- package/templates/web-components/model-viewer/index.html +1 -1
- package/templates/web-components/model-viewer/src/main.ts +2 -1
- package/templates/web-components/physics-playground/index.html +51 -0
- package/templates/web-components/physics-playground/src/main.ts +32 -0
- package/templates/web-components/product-configurator/index.html +51 -0
- package/templates/web-components/product-configurator/src/main.ts +93 -0
- package/templates/web-components/scene-editor/index.html +51 -0
- package/templates/web-components/scene-editor/src/main.ts +26 -0
- package/templates/web-components/spinning-cube/src/main.ts +1 -0
- package/templates/web-components/splat-viewer/index.html +2 -2
- package/templates/web-components/splat-viewer/src/main.ts +2 -1
- package/templates/web-components/sprite-game/index.html +34 -0
- package/templates/web-components/sprite-game/src/main.ts +9 -0
- package/templates/web-components/third-person-controller/index.html +183 -0
- package/templates/web-components/third-person-controller/src/main.ts +16 -0
- package/templates/web-components/vr-starter/index.html +80 -0
- package/templates/web-components/vr-starter/src/main.ts +12 -0
- package/templates/engine/interactive-sphere/src/assets/typescript.svg +0 -1
- package/templates/react/interactive-sphere/src/assets/react.svg +0 -1
- package/templates/web-components/interactive-sphere/src/assets/typescript.svg +0 -1
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/create-playcanvas)
|
|
4
4
|
[](https://npmtrends.com/create-playcanvas)
|
|
5
|
-
[](
|
|
5
|
+
[](LICENSE)
|
|
6
6
|
[](https://discord.gg/RSaMRzg)
|
|
7
7
|
[](https://www.reddit.com/r/PlayCanvas)
|
|
8
8
|
[](https://x.com/intent/follow?screen_name=playcanvas)
|
|
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.
|
|
12
|
+
Scaffold a Vite-powered PlayCanvas project with TypeScript. Pick a format and a runnable starter, then build from there.
|
|
13
13
|
|
|
14
14
|
## Getting Started
|
|
15
15
|
|
|
@@ -26,47 +26,40 @@ bun x create-playcanvas@latest
|
|
|
26
26
|
|
|
27
27
|
Then follow the prompts. Requires Node.js 22.23.2 or later.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Formats
|
|
30
30
|
|
|
31
|
-
|
|
|
31
|
+
| Format | Description |
|
|
32
32
|
| ---------------- | -------------------------------------------- |
|
|
33
33
|
| `engine` | The PlayCanvas Engine API directly |
|
|
34
34
|
| `react` | `@playcanvas/react` components |
|
|
35
35
|
| `web-components` | `@playcanvas/web-components` custom elements |
|
|
36
36
|
|
|
37
|
-
Every
|
|
37
|
+
Every format uses TypeScript and includes Vite, ESLint, Prettier and a production build.
|
|
38
38
|
|
|
39
|
-
##
|
|
39
|
+
## Starters
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Choose from 12 starter kits across basics, viewers, games, tools and XR. Run the creator to browse them; `spinning-cube` is the default.
|
|
42
42
|
|
|
43
|
-
|
|
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
45
|
## CLI Options
|
|
53
46
|
|
|
54
|
-
Pass a project name
|
|
47
|
+
Pass a project name and options to skip the prompts:
|
|
55
48
|
|
|
56
49
|
```bash
|
|
57
|
-
npm create playcanvas@latest my-game --
|
|
50
|
+
npm create playcanvas@latest my-game -- -f react -y
|
|
58
51
|
```
|
|
59
52
|
|
|
60
|
-
| Option
|
|
61
|
-
|
|
|
62
|
-
| `--
|
|
63
|
-
| `--
|
|
64
|
-
| `--overwrite`
|
|
65
|
-
| `--no-skills`
|
|
66
|
-
| `--yes`
|
|
67
|
-
| `--help`
|
|
53
|
+
| Option | Shorthand | Description |
|
|
54
|
+
| ------------------ | --------- | ------------------------------------------------------- |
|
|
55
|
+
| `--format <name>` | `-f` | Use a format from the list above |
|
|
56
|
+
| `--starter <name>` | `-s` | Use a starter from the list above |
|
|
57
|
+
| `--overwrite` | | Remove existing files from a non-empty target directory |
|
|
58
|
+
| `--no-skills` | | Omit the PlayCanvas agent skills (included by default) |
|
|
59
|
+
| `--yes` | `-y` | Skip the prompts and take the defaults |
|
|
60
|
+
| `--help` | `-h` | Show command help |
|
|
68
61
|
|
|
69
|
-
`--yes` takes `playcanvas-project`, the `engine`
|
|
62
|
+
`--yes` takes `playcanvas-project`, the `engine` format and the `spinning-cube` starter for anything you don't pass. It never deletes files, so a non-empty target directory still needs `--overwrite`. The previous `--template` and `--boilerplate` long flags remain accepted for compatibility.
|
|
70
63
|
|
|
71
64
|
## Agent skills
|
|
72
65
|
|
|
@@ -80,7 +73,7 @@ npm run build
|
|
|
80
73
|
node dist/index.mjs
|
|
81
74
|
```
|
|
82
75
|
|
|
83
|
-
Contributions are welcome. Please open an issue before proposing a new
|
|
76
|
+
Contributions are welcome. Please open an issue before proposing a new format, starter or another substantial change.
|
|
84
77
|
|
|
85
78
|
## License
|
|
86
79
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,62 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{styleText as u}from"node:util";import
|
|
3
|
-
`);let d=!1;for(let h=0;h<
|
|
4
|
-
`){
|
|
5
|
-
`&&(n&&
|
|
6
|
-
`)}function
|
|
7
|
-
`),
|
|
8
|
-
`),n=Math.max(r.length,
|
|
9
|
-
`).map((o,
|
|
10
|
-
`)}function
|
|
11
|
-
`),
|
|
12
|
-
`).length-1;this.output.write(
|
|
13
|
-
`);this.output.write(o[a]),this._prevFrame=t,this.output.write(
|
|
2
|
+
import{styleText as u}from"node:util";import M,{stdin as Pe,stdout as he}from"node:process";import Le from"node:readline";import"node:tty";import x from"node:fs";import y from"node:path";import{fileURLToPath as Ne}from"node:url";const De=(()=>{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}})(),We=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ve=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,Ue=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Ge=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,me=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Ke=/\t{1,1000}/y,de=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"),He=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ze=new RegExp("\\p{M}+","gu"),Je={limit:1/0,ellipsis:""},fe=(e,t={},r={})=>{const i=t.limit??1/0,n=t.ellipsis??"",c=t?.ellipsisWidth??(n?fe(n,Je,r).width:0),a=0,o=r.controlWidth??0,s=r.tabWidth??8,l=r.emojiWidth??2,d=2,h=r.regularWidth??1,m=r.wideWidth??d,p=[[He,h],[Ue,a],[Ge,o],[Ke,s],[de,l],[me,m]];let f=0,b=0,F=e.length,C=0,O=!1,B=F,k=Math.max(0,i-c),w=0,S=0,$=0,E=0;e:for(;;){if(S>w||b>=F&&b>f){const _=e.slice(w,S)||e.slice(f,b);C=0;for(const R of _.replaceAll(ze,"")){const I=R.codePointAt(0)||0;if(We(I)?E=d:Ve(I)?E=m:E=h,$+E>k&&(B=Math.min(B,Math.max(w,f)+C)),$+E>i){O=!0;break e}C+=R.length,$+=E}w=S=0}if(b>=F)break e;for(let _=0,R=p.length;_<R;_++){const[I,g]=p[_];if(I.lastIndex=b,I.test(e)){if(C=I===me?De(e.slice(b,I.lastIndex)):I===de?1:I.lastIndex-b,E=C*g,$+E>k&&(B=Math.min(B,b+Math.floor((k-$)/g))),$+E>i){O=!0;break e}$+=E,w=f,S=b,b=f=I.lastIndex;continue e}}b+=1}return{width:O?k:$,index:O?B:F,truncated:O,ellipsed:O&&i>=c}},Ye={limit:1/0,ellipsis:"",ellipsisWidth:0},N=(e,t={})=>fe(e,Ye,t).width,z="\x1B",pe="\x9B",qe=39,ee="\x07",ge="[",Xe="]",be="m",te=`${Xe}8;;`,ye=new RegExp(`(?:\\${ge}(?<code>\\d+)m|\\${te}(?<uri>.*)${ee})`,"y"),xe=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},$e=e=>`${z}${ge}${e}${be}`,we=e=>`${z}${te}${e}${ee}`,re=(e,t,r)=>{const i=t[Symbol.iterator]();let n=!1,c=!1,a=e.at(-1),o=a===void 0?0:N(a),s=i.next(),l=i.next(),d=0;for(;!s.done;){const h=s.value,m=N(h);o+m<=r?e[e.length-1]+=h:(e.push(h),o=0),(h===z||h===pe)&&(n=!0,c=t.startsWith(te,d+1)),n?c?h===ee&&(n=!1,c=!1):h===be&&(n=!1):(o+=m,o===r&&!l.done&&(e.push(""),o=0)),s=l,l=i.next(),d+=h.length}a=e.at(-1),!o&&a!==void 0&&a.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ze=e=>{const t=e.split(" ");let r=t.length;for(;r&&!N(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Qe=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,c;const a=e.split(" ");let o=[""],s=0;for(let h=0;h<a.length;h++){const m=a[h];if(r.trim!==!1){const f=o.at(-1)??"",b=f.trimStart();f.length!==b.length&&(o[o.length-1]=b,s=N(b))}h!==0&&(s>=t&&(r.wordWrap===!1||r.trim===!1)&&(o.push(""),s=0),(s||r.trim===!1)&&(o[o.length-1]+=" ",s++));const p=N(m);if(r.hard&&p>t){const f=t-s,b=1+Math.floor((p-f-1)/t);Math.floor((p-1)/t)<b&&o.push(""),re(o,m,t),s=N(o.at(-1)??"");continue}if(s+p>t&&s&&p){if(r.wordWrap===!1&&s<t){re(o,m,t),s=N(o.at(-1)??"");continue}o.push(""),s=0}if(s+p>t&&r.wordWrap===!1){re(o,m,t),s=N(o.at(-1)??"");continue}o[o.length-1]+=m,s+=p}r.trim!==!1&&(o=o.map(h=>Ze(h)));const l=o.join(`
|
|
3
|
+
`);let d=!1;for(let h=0;h<l.length;h++){const m=l[h];if(i+=m,d)d=!1;else if(d=m>="\uD800"&&m<="\uDBFF",d)continue;if(m===z||m===pe){ye.lastIndex=h+1;const f=ye.exec(l)?.groups;if(f?.code!==void 0){const b=Number.parseFloat(f.code);n=b===qe?void 0:b}else f?.uri!==void 0&&(c=f.uri.length===0?void 0:f.uri)}if(l[h+1]===`
|
|
4
|
+
`){c&&(i+=we(""));const p=n?xe(n):void 0;n&&p&&(i+=$e(p))}else m===`
|
|
5
|
+
`&&(n&&xe(n)&&(i+=$e(n)),c&&(i+=we(c)))}return i},et=/\r?\n/;function J(e,t,r){return String(e).normalize().split(et).map(i=>Qe(i,t,r)).join(`
|
|
6
|
+
`)}function tt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var se,ve;function rt(){if(ve)return se;ve=1;const e="\x1B",t=`${e}[`,r="\x07",i={to(a,o){return o?`${t}${o+1};${a+1}H`:`${t}${a+1}G`},move(a,o){let s="";return a<0?s+=`${t}${-a}D`:a>0&&(s+=`${t}${a}C`),o<0?s+=`${t}${-o}A`:o>0&&(s+=`${t}${o}B`),s},up:(a=1)=>`${t}${a}A`,down:(a=1)=>`${t}${a}B`,forward:(a=1)=>`${t}${a}C`,backward:(a=1)=>`${t}${a}D`,nextLine:(a=1)=>`${t}E`.repeat(a),prevLine:(a=1)=>`${t}F`.repeat(a),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},n={up:(a=1)=>`${t}S`.repeat(a),down:(a=1)=>`${t}T`.repeat(a)},c={screen:`${t}2J`,up:(a=1)=>`${t}1J`.repeat(a),down:(a=1)=>`${t}J`.repeat(a),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(a){let o="";for(let s=0;s<a;s++)o+=this.line+(s<a-1?i.up():"");return a&&(o+=i.left),o}};return se={cursor:i,scroll:n,erase:c,beep:r},se}var P=rt();function Y(e,t,r){if(!r.some(a=>!a.disabled))return e;const i=e+t,n=Math.max(r.length-1,0),c=i<0?n:i>n?0:i;return r[c]?.disabled?Y(c,t<0?-1:1,r):c}const st=["up","down","left","right","space","enter","cancel"],W={actions:new Set(st),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),withGuide:!0};function Se(e,t){if(typeof e=="string")return W.aliases.get(e)===t;for(const r of e)if(r!==void 0&&Se(r,t))return!0;return!1}function it(e,t){if(e===t)return;const r=e.split(`
|
|
7
|
+
`),i=t.split(`
|
|
8
|
+
`),n=Math.max(r.length,i.length),c=[];for(let a=0;a<n;a++)r[a]!==i[a]&&c.push(a);return{lines:c,numLinesBefore:r.length,numLinesAfter:i.length,numLines:n}}globalThis.process.platform.startsWith("win");const ie=Symbol("clack:cancel");function K(e){return e===ie}function q(e,t){const r=e;r.isTTY&&r.setRawMode(t)}const Ee=e=>"columns"in e&&typeof e.columns=="number"?e.columns:80,_e=e=>"rows"in e&&typeof e.rows=="number"?e.rows:20;function ne(e,t,r,i=r,n=r,c){const a=Ee(e??he);return J(t,a-r.length,{hard:!0,trim:!1}).split(`
|
|
9
|
+
`).map((o,s,l)=>{const d=o;return s===0?`${i}${d}`:s===l.length-1?`${n}${d}`:`${r}${d}`}).join(`
|
|
10
|
+
`)}function nt(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 Ie{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:i=Pe,output:n=he,render:c,signal:a,...o}=t;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=c.bind(this),this._track=r,this._abortSignal=a,this.input=i,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(t,r){const i=this._subscribers.get(t)??[];i.push(r),this._subscribers.set(t,i)}on(t,r){this.setSubscriber(t,{cb:r})}once(t,r){this.setSubscriber(t,{cb:r,once:!0})}emit(t,...r){const i=this._subscribers.get(t)??[],n=[];for(const c of i)c.cb(...r),c.once&&n.push(()=>i.splice(i.indexOf(c),1));for(const c of n)c()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(ie);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Le.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),q(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),q(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),q(this.input,!1),t(ie)})})}_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&&W.aliases.has(r.name)&&this.emit("cursor",W.aliases.get(r.name)),W.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 i=nt(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")}Se([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
|
+
`),q(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=J(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
12
|
+
`).length-1;this.output.write(P.cursor.move(-999,t*-1))}render(){const t=J(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(P.cursor.hide);else{const r=it(this._prevFrame,t),i=_e(this.output);if(this.restoreCursor(),r){const n=Math.max(0,r.numLinesAfter-i),c=Math.max(0,r.numLinesBefore-i);let a=r.lines.find(o=>o>=n);if(a===void 0){this._prevFrame=t;return}if(r.lines.length===1){this.output.write(P.cursor.move(0,a-c)),this.output.write(P.erase.lines(1));const o=t.split(`
|
|
13
|
+
`);this.output.write(o[a]),this._prevFrame=t,this.output.write(P.cursor.move(0,o.length-a-1));return}else if(r.lines.length>1){if(n<c)a=n;else{const s=a-c;s>0&&this.output.write(P.cursor.move(0,s))}this.output.write(P.erase.down());const o=t.split(`
|
|
14
14
|
`).slice(a);this.output.write(o.join(`
|
|
15
|
-
`)),this._prevFrame=t;return}}this.output.write(
|
|
16
|
-
`);
|
|
17
|
-
`);if(h.length>0){const[m,...
|
|
15
|
+
`)),this._prevFrame=t;return}}this.output.write(P.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}let at=class extends Ie{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:n})=>n===t.initialValue),i=r===-1?0:r;this.cursor=this.options[i]?.disabled?Y(i,1,this.options):i,this.changeValue(),this.on("cursor",n=>{switch(n){case"left":case"up":this.cursor=Y(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=Y(this.cursor,1,this.options);break}this.changeValue()})}};class ot extends Ie{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),i=t.slice(this.cursor,this.cursor+1),n=t.slice(this.cursor+1);return`${r}${u("inverse",i)}${n}`}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 ct(){return M.platform!=="win32"?M.env.TERM!=="linux":!!M.env.CI||!!M.env.WT_SESSION||!!M.env.TERMINUS_SUBLIME||M.env.ConEmuTask==="{cmd::Cmder}"||M.env.TERM_PROGRAM==="Terminus-Sublime"||M.env.TERM_PROGRAM==="vscode"||M.env.TERM==="xterm-256color"||M.env.TERM==="alacritty"||M.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const lt=ct(),j=(e,t)=>lt?e:t,ut=j("\u25C6","*"),ht=j("\u25A0","x"),mt=j("\u25B2","x"),Fe=j("\u25C7","o"),v=j("\u2502","|"),U=j("\u2514","\u2014"),dt=j("\u25CF",">"),Te=j("\u25CB"," "),ft=j("\u25CF","\u2022"),pt=j("\u25C6","*"),gt=j("\u25B2","!"),bt=j("\u25A0","x"),Ce=e=>{switch(e){case"initial":case"active":return u("cyan",ut);case"cancel":return u("red",ht);case"error":return u("yellow",mt);case"submit":return u("green",Fe)}},yt=e=>{switch(e){case"initial":case"active":return u("cyan",v);case"cancel":return u("red",v);case"error":return u("yellow",v);case"submit":return u("green",v)}};function xt(e,t){const r=[`${t?`${u("cyan",v)} `:""}${e.join(" \u2022 ")}`];return t&&r.push(u("cyan",U)),r}const Re=(e,t,r,i,n,c=!1)=>{let a=t,o=0;if(c)for(let s=i-1;s>=r;s--){const l=e[s];if(l&&(a-=l.length),o++,a<=n)break}else for(let s=r;s<i;s++){const l=e[s];if(l&&(a-=l.length),o++,a<=n)break}return{lineCount:a,removals:o}},$t=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:c=0,rowPadding:a=4})=>{const o=Ee(i)-c,s=_e(i),l=u("dim","..."),d=Math.max(s-a,0),h=Math.max(Math.min(n,d),5);let m=0;e>=h-3&&(m=Math.max(Math.min(e-h+3,t.length-h),0));let p=h<t.length&&m>0,f=h<t.length&&m+h<t.length;const b=Math.min(m+h,t.length),F=[];let C=0;p&&C++,f&&C++;const O=m+(p?1:0),B=b-(f?1:0);for(let w=O;w<B;w++){const S=t[w],$=S?r(S,w===e):"",E=J($,o,{hard:!0,trim:!1}).split(`
|
|
16
|
+
`);F.push(E),C+=E.length}if(C>d){let w=0,S=0,$=C;const E=e-O;let _=d;const R=()=>Re(F,$,0,E,_),I=()=>Re(F,$,E+1,F.length,_,!0);p?({lineCount:$,removals:w}=R(),$>_&&(f||(_-=1),{lineCount:$,removals:S}=I())):(f||(_-=1),{lineCount:$,removals:S}=I(),$>_&&(_-=1,{lineCount:$,removals:w}=R())),w>0&&(p=!0,F.splice(0,w)),S>0&&(f=!0,F.splice(F.length-S,S))}const k=[];p&&k.push(l);for(const w of F)for(const S of w)k.push(S);return f&&k.push(l),k};`${u("dim","\u2191/\u2193")}`,`${u("dim","Space:")}`,`${u("dim","Enter:")}`;const D={message:(e=[],{symbol:t=u("gray",v),secondarySymbol:r=u("gray",v),output:i=process.stdout,spacing:n=1,withGuide:c}={})=>{const a=[],o=c??W.withGuide,s=o?r:"",l=o?`${t} `:"",d=o?`${r} `:"";for(let m=0;m<n;m++)a.push(s);const h=Array.isArray(e)?e:e.split(`
|
|
17
|
+
`);if(h.length>0){const[m,...p]=h;m.length>0?a.push(`${l}${m}`):a.push(o?t:"");for(const f of p)f.length>0?a.push(`${d}${f}`):a.push(o?r:"")}i.write(`${a.join(`
|
|
18
18
|
`)}
|
|
19
|
-
`)},info:(e,t)=>{
|
|
19
|
+
`)},info:(e,t)=>{D.message(e,{...t,symbol:u("blue",ft)})},success:(e,t)=>{D.message(e,{...t,symbol:u("green",pt)})},step:(e,t)=>{D.message(e,{...t,symbol:u("green",Fe)})},warn:(e,t)=>{D.message(e,{...t,symbol:u("yellow",gt)})},warning:(e,t)=>{D.warn(e,t)},error:(e,t)=>{D.message(e,{...t,symbol:u("red",bt)})}},wt=(e="",t)=>{const r=process.stdout,i=`${u("gray",U)} `;r.write(`${i}${u("red",e)}
|
|
20
20
|
|
|
21
|
-
`)},
|
|
22
|
-
${u("gray",
|
|
21
|
+
`)},vt=(e="",t)=>{const r=process.stdout,i=`${u("gray",v)}
|
|
22
|
+
${u("gray",U)} `;r.write(`${i}${e}
|
|
23
23
|
|
|
24
|
-
`)},
|
|
24
|
+
`)},St=[`${u("dim","\u2191/\u2193")} to navigate`,`${u("dim","Enter:")} confirm`],X=(e,t)=>e.includes(`
|
|
25
25
|
`)?e.split(`
|
|
26
26
|
`).map(r=>t(r)).join(`
|
|
27
|
-
`):t(e),
|
|
27
|
+
`):t(e),ae=e=>{const t=(i,n)=>{if(i===void 0)return"";const c=i.label??String(i.value);switch(n){case"disabled":return`${u("gray",Te)} ${X(c,a=>u("gray",a))}${i.hint?` ${u("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${X(c,a=>u("dim",a))}`;case"active":return`${u("green",dt)} ${c}${i.hint?` ${u("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${X(c,a=>u(["strikethrough","dim"],a))}`;default:return`${u("dim",Te)} ${X(c,a=>u("dim",a))}`}},r=e.showInstructions??!0;return new at({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const i=e.withGuide??W.withGuide,n=`${Ce(this.state)} `,c=`${yt(this.state)} `,a=ne(e.output,e.message,c,n),o=`${i?`${u("gray",v)}
|
|
28
28
|
`:""}${a}
|
|
29
|
-
`;switch(this.state){case"submit":{const i
|
|
30
|
-
${u("gray"
|
|
31
|
-
`).length,d=r?
|
|
32
|
-
`),m=d.length+1;return`${o}${
|
|
33
|
-
${
|
|
29
|
+
`;switch(this.state){case"submit":{const s=i?`${u("gray",v)} `:"",l=ne(e.output,t(this.options[this.cursor],"selected"),s);return`${o}${l}`}case"cancel":{const s=i?`${u("gray",v)} `:"",l=ne(e.output,t(this.options[this.cursor],"cancelled"),s);return`${o}${l}${i?`
|
|
30
|
+
${u("gray",v)}`:""}`}default:{const s=i?`${u("cyan",v)} `:"",l=o.split(`
|
|
31
|
+
`).length,d=r?xt(St,i):i?[u("cyan",U)]:[],h=d.join(`
|
|
32
|
+
`),m=d.length+1;return`${o}${s}${$t({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:s.length,rowPadding:l+m,style:(p,f)=>t(p,p.disabled?"disabled":f?"active":"inactive")}).join(`
|
|
33
|
+
${s}`)}
|
|
34
34
|
${h}
|
|
35
|
-
`}}}}).prompt()};`${u("gray"
|
|
36
|
-
`:""}${
|
|
37
|
-
`,
|
|
35
|
+
`}}}}).prompt()};`${u("gray",v)}`;const Ae=e=>new ot({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??W.withGuide,r=`${`${t?`${u("gray",v)}
|
|
36
|
+
`:""}${Ce(this.state)} `}${e.message}
|
|
37
|
+
`,i=e.placeholder&&e.placeholder.length>0?u("inverse",e.placeholder[0])+u("dim",e.placeholder.slice(1)):u(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,c=this.value??"";switch(this.state){case"error":{const a=this.error?` ${u("yellow",this.error)}`:"",o=t?`${u("yellow",v)} `:"",s=t?u("yellow",U):"";return`${r.trim()}
|
|
38
38
|
${o}${n}
|
|
39
|
-
${
|
|
40
|
-
`}case"submit":{const a=
|
|
41
|
-
${o}`:""}`}default:{const a=t?`${u("cyan"
|
|
39
|
+
${s}${a}
|
|
40
|
+
`}case"submit":{const a=c?` ${u("dim",c)}`:"",o=t?u("gray",v):"";return`${r}${o}${a}`}case"cancel":{const a=c?` ${u(["strikethrough","dim"],c)}`:"",o=t?u("gray",v):"";return`${r}${o}${a}${c.trim()?`
|
|
41
|
+
${o}`:""}`}default:{const a=t?`${u("cyan",v)} `:"",o=t?u("cyan",U):"";return`${r}${a}${n}
|
|
42
42
|
${o}
|
|
43
|
-
`}}}}).prompt();function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
yarn
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
`}}}}).prompt();function oe(e){return e==null?[]:Array.isArray(e)?e:[e]}function Et(e,t,r,i){var n,c=e[t],a=~i.string.indexOf(t)?r==null||r===!0?"":String(r):typeof r=="boolean"?r:~i.boolean.indexOf(t)?r==="false"?!1:r==="true"||(e._.push((n=+r,n*0===0?n:r)),!!r):(n=+r,n*0===0?n:r);e[t]=c==null?a:Array.isArray(c)?c.concat(a):[c,a]}function _t(e,t){e=e||[],t=t||{};var r,i,n,c,a,o={_:[]},s=0,l=0,d=0,h=e.length;const m=t.alias!==void 0,p=t.unknown!==void 0,f=t.default!==void 0;if(t.alias=t.alias||{},t.string=oe(t.string),t.boolean=oe(t.boolean),m)for(r in t.alias)for(i=t.alias[r]=oe(t.alias[r]),s=0;s<i.length;s++)(t.alias[i[s]]=i.concat(r)).splice(s,1);for(s=t.boolean.length;s-- >0;)for(i=t.alias[t.boolean[s]]||[],l=i.length;l-- >0;)t.boolean.push(i[l]);for(s=t.string.length;s-- >0;)for(i=t.alias[t.string[s]]||[],l=i.length;l-- >0;)t.string.push(i[l]);if(f){for(r in t.default)if(c=typeof t.default[r],i=t.alias[r]=t.alias[r]||[],t[c]!==void 0)for(t[c].push(r),s=0;s<i.length;s++)t[c].push(i[s])}const b=p?Object.keys(t.alias):[];for(s=0;s<h;s++){if(n=e[s],n==="--"){o._=o._.concat(e.slice(++s));break}for(l=0;l<n.length&&n.charCodeAt(l)===45;l++);if(l===0)o._.push(n);else if(n.substring(l,l+3)==="no-"){if(c=n.substring(l+3),p&&!~b.indexOf(c))return t.unknown(n);o[c]=!1}else{for(d=l+1;d<n.length&&n.charCodeAt(d)!==61;d++);for(c=n.substring(l,d),a=n.substring(++d)||s+1===h||(""+e[s+1]).charCodeAt(0)===45||e[++s],i=l===2?[c]:c,d=0;d<i.length;d++){if(c=i[d],p&&!~b.indexOf(c))return t.unknown("-".repeat(l)+c);Et(o,c,d+1<i.length||a,t)}}}if(f)for(r in t.default)o[r]===void 0&&(o[r]=t.default[r]);if(m)for(r in o)for(i=t.alias[r]||[];i.length>0;)o[i.shift()]=o[r];return o}var Z={exports:{}},ke;function It(){if(ke)return Z.exports;ke=1;let e=process||{},t=e.argv||[],r=e.env||{},i=!(r.NO_COLOR||t.includes("--no-color"))&&(!!r.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&r.TERM!=="dumb"||!!r.CI),n=(o,s,l=o)=>d=>{let h=""+d,m=h.indexOf(s,o.length);return~m?o+c(h,s,l,m)+s:o+h+s},c=(o,s,l,d)=>{let h="",m=0;do h+=o.substring(m,d)+l,m=d+s.length,d=o.indexOf(s,m);while(~d);return h+o.substring(m)},a=(o=i)=>{let s=o?n:()=>String;return{isColorSupported:o,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 Z.exports=a(),Z.exports.createColors=a,Z.exports}var Ft=It();const Tt=tt(Ft),{cyan:Ct,magenta:Rt,yellow:At}=Tt,H=[{name:"engine",display:"Engine",description:"with the PlayCanvas Engine API directly",color:At},{name:"react",display:"React",description:"with @playcanvas/react",color:Ct},{name:"web-components",display:"Web Components",description:"with @playcanvas/web-components",color:Rt}],je={physics:{engine:["assets"],react:["react"],"web-components":["assets"]}},V=[{name:"spinning-cube",display:"Spinning Cube",category:"Basics",description:"a rotating cube and a light"},{name:"interactive-sphere",display:"Interactive Sphere",category:"Basics",description:"orbit controls, a grid and pointer picking"},{name:"model-viewer",display:"Model Viewer",category:"Viewers",description:"a glTF model, orbit controls and a procedural sky"},{name:"splat-viewer",display:"Splat Viewer",category:"Viewers",description:"a Gaussian splat and orbit controls"},{name:"product-configurator",display:"Product Configurator",category:"Viewers",description:"product variants, materials and orbit controls"},{name:"physics-playground",display:"Physics Playground",category:"Games",description:"rigid bodies, collisions, spawning and reset",features:["physics"]},{name:"first-person-controller",display:"First-Person Controller",category:"Games",description:"first-person movement, mouse look and jumping",features:["physics"]},{name:"third-person-controller",display:"Third-Person Controller",category:"Games",description:"an animated character, follow camera and locomotion",features:["physics"]},{name:"sprite-game",display:"Sprite Game",category:"Games",description:"an orthographic camera, sprite animation and input"},{name:"scene-editor",display:"Scene Editor",category:"Tools",description:"selection and translate, rotate and scale gizmos"},{name:"vr-starter",display:"VR Starter",category:"XR",description:"immersive VR, controllers and locomotion"},{name:"ar-placement",display:"AR Placement",category:"XR",description:"mobile AR, hit testing and object placement"}],kt=async({argFormat:e,yes:t,cancel:r})=>{if(e&&H.some(n=>n.name===e))return e;if(e&&(!process.stdout.isTTY||t))throw new Error(`Unknown format: ${e}. Choose from: ${H.map(n=>n.name).join(", ")}`);if(t)return H[0].name;const i=await ae({message:e?`"${e}" isn't a valid format. Please choose from below: `:"Select a format:",options:H.map(n=>({label:n.color(n.display),value:n.name,hint:n.description}))});return K(i)&&r(),i},jt=async({argStarter:e,yes:t,cancel:r})=>{if(e&&V.some(n=>n.name===e))return e;if(!process.stdout.isTTY||t){if(!e)return V[0].name;throw new Error(`Unknown starter: ${e}. Choose from: ${V.map(n=>n.name).join(", ")}`)}const i=await ae({message:e?`"${e}" isn't a valid starter. Please choose from below: `:"Select a starter:",initialValue:V[0].name,options:V.map(n=>({label:n.display,value:n.name,hint:`${n.category} \xB7 ${n.description}`}))});return K(i)&&r(),i},Oe=e=>/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e),ce=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-"),Ot=async({targetDir:e,yes:t,cancel:r})=>{let i=y.basename(y.resolve(e));if(!Oe(i)){if(t)return ce(i);const n=await Ae({message:"Package name:",defaultValue:ce(i),placeholder:ce(i),validate:c=>{if(!c||!Oe(c))return"Invalid package.json name"}});if(K(n))return r();i=n}return i},le=e=>e.trim().replace(/\/+$/g,""),Mt=e=>{const t=x.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"},Bt=e=>{if(x.existsSync(e))for(const t of x.readdirSync(e))t!==".git"&&x.rmSync(y.resolve(e,t),{recursive:!0,force:!0})},Pt=async({argTargetDir:e,defaultTargetDir:t,yes:r,cancel:i})=>{let n=e?le(String(e)):void 0;if(!n&&r)return t;if(!n){const c=await Ae({message:"Project name:",defaultValue:t,placeholder:t});K(c)&&i(),n=le(c)}return n},Lt=async({targetDir:e,argOverwrite:t,yes:r,cancel:i})=>{if(x.existsSync(e)&&!Mt(e)){if(r&&!t)throw new Error(`Target directory "${e}" is not empty. Pass --overwrite to remove its contents.`);const n=t?"yes":await ae({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(K(n))return i();switch(n){case"yes":Bt(e);break;case"no":i();return}}},Nt=["scripts","dependencies","devDependencies","peerDependencies","engines"],Me="## Prerequisites",Dt={engine:"src/main.ts",react:"src/App.tsx","web-components":"src/main.ts"},Wt=e=>{const{cwd:t,targetDir:r,format:i,starter:n,packageName:c,skills:a,renameFiles:o}=e,s=y.resolve(t,r);x.mkdirSync(s,{recursive:!0});const l=process.env.npm_config_user_agent?.split("/")[0]??"npm";D.step(`Creating project in ${s}...`);const d=Ne(import.meta.url),h=y.dirname(d),m=[y.resolve(h,"../templates"),y.resolve(h,"../../templates")].find(g=>x.existsSync(y.join(g,i)));if(!m)throw new Error(`Format directory not found for: ${i}`);const p=y.join(m,i);for(const g of H)for(const T of V){const A=y.join(m,g.name,T.name),G=Dt[g.name];if(!G||!x.existsSync(y.join(A,G)))throw new Error(`Incomplete starter matrix: ${g.name}/${T.name}`);for(const Q of T.features??[]){const ue=je[Q]?.[g.name];if(!ue?.length||ue.some(Be=>!x.existsSync(y.join(m,"_features",Q,Be))))throw new Error(`Incomplete feature matrix: ${Q}/${g.name}`)}}const f=V.find(g=>g.name===n);if(!f)throw new Error(`Starter not found: ${n}`);const b=y.join(m,"_shared",n),F=y.join(p,"base"),C=y.join(p,n),O=(f.features??[]).flatMap(g=>je[g][i].map(T=>y.join(m,"_features",g,T))),B=[b,F,...O,C],k=B.map(g=>{const T=y.join(g,"package.json");return x.existsSync(T)?JSON.parse(x.readFileSync(T,"utf-8")):{}}),w=[k[1],k[0],...k.slice(2)];if(!x.existsSync(C))throw new Error(`Starter directory not found: ${i}/${n}`);for(const g of B)x.existsSync(g)&&x.cpSync(g,s,{recursive:!0});const S=y.join(b,"README.md"),$=y.join(s,"README.md");x.existsSync(S)&&x.writeFileSync($,x.readFileSync($,"utf8").replace(Me,`${x.readFileSync(S,"utf8").trimEnd()}
|
|
44
|
+
|
|
45
|
+
${Me}`));for(const[g,T]of Object.entries(o)){const A=y.join(s,g);x.existsSync(A)&&x.renameSync(A,y.join(s,T))}const E=y.join(s,"package.json"),_=Object.assign({},...w);for(const g of Nt){const T=Object.assign({},...w.map(A=>A?.[g]));Object.keys(T).length?_[g]=T:delete _[g]}if(_.name=c,x.writeFileSync(E,JSON.stringify(_,null,4)+`
|
|
46
|
+
`),a){const g=[y.resolve(h,"../skills"),y.resolve(h,"../../skills")].find(A=>x.existsSync(A));if(!g)throw new Error("Skills directory not found");const T=x.readdirSync(g,{withFileTypes:!0}).filter(A=>A.isDirectory()).map(A=>A.name);for(const A of[".claude/skills",".agents/skills"])for(const G of T)x.cpSync(y.join(g,G),y.join(s,A,G),{recursive:!0});D.step("Added PlayCanvas agent skills (opt out with --no-skills)")}let R=`Project created. Now run:
|
|
47
|
+
`;const I=y.isAbsolute(r)?s:y.relative(t,s);switch(s!==t&&(R+=`
|
|
48
|
+
cd ${I.includes(" ")?`"${I}"`:I}`),l){case"yarn":R+=`
|
|
49
|
+
yarn`,R+=`
|
|
50
|
+
yarn dev`;break;default:R+=`
|
|
51
|
+
${l} install`,R+=`
|
|
52
|
+
${l} run dev`;break}vt(R)},L=_t(process.argv.slice(2),{alias:{b:"boilerplate",f:"format",h:"help",s:"starter",t:"template",y:"yes"},boolean:["help","overwrite","yes"],string:["format","starter","template","boilerplate"]}),Vt=process.cwd(),Ut=`Usage: npm create playcanvas@latest [OPTION]...
|
|
51
53
|
|
|
52
54
|
Create a new PlayCanvas project with TypeScript.
|
|
53
55
|
With no arguments, start the CLI in interactive mode.
|
|
54
56
|
|
|
55
57
|
Options:
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
+
-f, --format NAME use a specific format
|
|
59
|
+
-s, --starter NAME use a specific starter
|
|
58
60
|
--overwrite remove existing files from a non-empty target directory
|
|
59
61
|
--no-skills omit the PlayCanvas agent skills
|
|
60
62
|
-y, --yes skip the prompts and take the defaults
|
|
61
63
|
-h, --help show help
|
|
62
|
-
`,
|
|
64
|
+
`,Gt={_gitignore:".gitignore",_npmrc:".npmrc"},Kt="playcanvas-project",Ht=async()=>{const e=L._[0]?le(String(L._[0])):void 0,t=L.format??L.template,r=L.starter??L.boilerplate,i=L.overwrite,n=L.yes;if(L.help){console.log(Ut);return}const c=()=>{wt("Operation cancelled"),process.exit(0)},a=await Pt({argTargetDir:e,defaultTargetDir:Kt,yes:n,cancel:c});await Lt({targetDir:a,argOverwrite:i,yes:n,cancel:c});const o=await Ot({targetDir:a,yes:n,cancel:c}),s=await kt({argFormat:t,yes:n,cancel:c}),l=await jt({argStarter:r,yes:n,cancel:c}),d=L.skills??!0;Wt({cwd:Vt,targetDir:a,format:s,starter:l,packageName:o,skills:d,renameFiles:Gt})};Ht().catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2011 ammo.js contributors
|
|
2
|
+
|
|
3
|
+
This software is provided 'as-is', without any express or implied
|
|
4
|
+
warranty. In no event will the authors be held liable for any damages
|
|
5
|
+
arising from the use of this software.
|
|
6
|
+
|
|
7
|
+
Permission is granted to anyone to use this software for any purpose,
|
|
8
|
+
including commercial applications, and to alter it and redistribute it
|
|
9
|
+
freely, subject to the following restrictions:
|
|
10
|
+
|
|
11
|
+
1. The origin of this software must not be misrepresented; you must not
|
|
12
|
+
claim that you wrote the original software. If you use this software
|
|
13
|
+
in a product, an acknowledgment in the product documentation would be
|
|
14
|
+
appreciated but is not required.
|
|
15
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
|
16
|
+
misrepresented as being the original software.
|
|
17
|
+
3. This notice may not be removed or altered from any source distribution.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
See AUTHORS for list of contributors.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Ammo.js
|
|
2
|
+
|
|
3
|
+
These files are copied from `playcanvas/engine` tag `v2.21.4` (commit
|
|
4
|
+
`e287e0c67f3c20c689a52b7c53d2b7fedbe887da`) at
|
|
5
|
+
`examples/assets/wasm/ammo/`.
|
|
6
|
+
|
|
7
|
+
They are a WebAssembly build of [ammo.js](https://github.com/kripken/ammo.js),
|
|
8
|
+
distributed under the zlib license in `LICENSE`.
|
|
9
|
+
|
|
10
|
+
## SHA-256
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
ef166d1315bc4a6441a8de341ecdf6ac4e7d69055caec65c523ed1a4e8e19b15 ammo.js
|
|
14
|
+
5645b5a0c4f03be9d9d1ae604ffacd5e5e525310cfd1d0ed27474cdd1f34aab0 ammo.wasm.js
|
|
15
|
+
a61b504d4a6ce6bb93bd843e0f61edb8115e7317f1b3462247031a83ddb25d09 ammo.wasm.wasm
|
|
16
|
+
```
|