create-playcanvas 0.2.6 → 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.
- package/README.md +51 -47
- package/dist/index.mjs +49 -46
- package/package.json +54 -49
- package/templates/_shared/model-viewer/public/playcanvas-cube.glb +0 -0
- package/templates/engine/base/README.md +38 -0
- package/templates/engine/base/eslint.config.mjs +3 -0
- package/templates/engine/base/package.json +30 -0
- package/templates/engine/base/prettier.config.mjs +1 -0
- package/templates/engine/base/src/vite-env.d.ts +19 -0
- package/templates/engine/base/tsconfig.json +25 -0
- package/templates/engine/interactive-sphere/index.html +13 -0
- package/templates/engine/interactive-sphere/src/App.ts +180 -0
- package/templates/{vanilla-ts → engine/interactive-sphere}/src/main.ts +8 -8
- package/templates/engine/interactive-sphere/src/style.css +107 -0
- package/templates/engine/interactive-sphere/src/utils.ts +16 -0
- package/templates/engine/model-viewer/index.html +13 -0
- package/templates/engine/model-viewer/src/main.ts +81 -0
- package/templates/engine/model-viewer/src/style.css +8 -0
- package/templates/engine/spinning-cube/index.html +13 -0
- package/templates/engine/spinning-cube/src/main.ts +65 -0
- package/templates/engine/spinning-cube/src/style.css +8 -0
- package/templates/engine/splat-viewer/index.html +13 -0
- package/templates/engine/splat-viewer/src/main.ts +74 -0
- package/templates/engine/splat-viewer/src/style.css +8 -0
- package/templates/index.ts +47 -57
- package/templates/react/base/README.md +38 -0
- package/templates/react/base/eslint.config.mjs +14 -0
- package/templates/react/base/package.json +36 -0
- package/templates/react/base/prettier.config.mjs +1 -0
- package/templates/react/base/src/vite-env.d.ts +19 -0
- package/templates/react/base/tsconfig.json +26 -0
- package/templates/react/base/vite.config.ts +7 -0
- package/templates/react/interactive-sphere/index.html +13 -0
- package/templates/react/interactive-sphere/src/App.css +75 -0
- package/templates/react/interactive-sphere/src/App.tsx +43 -0
- package/templates/react/interactive-sphere/src/Scene.tsx +69 -0
- package/templates/react/interactive-sphere/src/index.css +51 -0
- package/templates/react/interactive-sphere/src/main.tsx +11 -0
- package/templates/react/model-viewer/index.html +13 -0
- package/templates/react/model-viewer/src/App.tsx +43 -0
- package/templates/react/model-viewer/src/index.css +9 -0
- package/templates/react/model-viewer/src/main.tsx +11 -0
- package/templates/react/spinning-cube/index.html +13 -0
- package/templates/react/spinning-cube/src/App.tsx +36 -0
- package/templates/react/spinning-cube/src/index.css +9 -0
- package/templates/react/spinning-cube/src/main.tsx +11 -0
- package/templates/react/splat-viewer/index.html +13 -0
- package/templates/react/splat-viewer/src/App.tsx +39 -0
- package/templates/react/splat-viewer/src/index.css +9 -0
- package/templates/react/splat-viewer/src/main.tsx +11 -0
- package/templates/web-components/base/README.md +66 -0
- package/templates/web-components/base/_gitignore +24 -0
- package/templates/web-components/base/eslint.config.mjs +3 -0
- package/templates/web-components/base/package.json +31 -0
- package/templates/web-components/base/prettier.config.mjs +1 -0
- package/templates/web-components/base/src/assets/playcanvas.png +0 -0
- package/templates/web-components/base/src/vite-env.d.ts +19 -0
- package/templates/web-components/base/tsconfig.json +25 -0
- package/templates/web-components/interactive-sphere/index.html +53 -0
- package/templates/web-components/interactive-sphere/src/assets/typescript.svg +1 -0
- package/templates/web-components/interactive-sphere/src/main.ts +76 -0
- package/templates/web-components/interactive-sphere/src/style.css +111 -0
- package/templates/web-components/model-viewer/index.html +34 -0
- package/templates/web-components/model-viewer/src/main.ts +26 -0
- package/templates/web-components/model-viewer/src/style.css +8 -0
- package/templates/web-components/spinning-cube/index.html +29 -0
- package/templates/web-components/spinning-cube/src/main.ts +20 -0
- package/templates/web-components/spinning-cube/src/style.css +8 -0
- package/templates/web-components/splat-viewer/index.html +31 -0
- package/templates/web-components/splat-viewer/src/main.ts +14 -0
- package/templates/web-components/splat-viewer/src/style.css +8 -0
- package/index.js +0 -3
- package/templates/react-ts/README.md +0 -82
- package/templates/react-ts/index.html +0 -13
- package/templates/react-ts/package.json +0 -29
- package/templates/react-ts/scripts/ensure-node-version.cjs +0 -12
- package/templates/react-ts/src/App.css +0 -87
- package/templates/react-ts/src/App.tsx +0 -46
- package/templates/react-ts/src/Scene.tsx +0 -70
- package/templates/react-ts/src/index.css +0 -73
- package/templates/react-ts/src/main.tsx +0 -10
- package/templates/react-ts/src/vite-env.d.ts +0 -1
- package/templates/react-ts/tsconfig.app.json +0 -27
- package/templates/react-ts/tsconfig.json +0 -7
- package/templates/react-ts/tsconfig.node.json +0 -25
- package/templates/react-ts/vite.config.ts +0 -7
- package/templates/vanilla-ts/README.md +0 -114
- package/templates/vanilla-ts/index.html +0 -13
- package/templates/vanilla-ts/package.json +0 -23
- package/templates/vanilla-ts/public/environment-map.png +0 -0
- package/templates/vanilla-ts/scripts/ensure-node-version.cjs +0 -12
- package/templates/vanilla-ts/src/App.ts +0 -182
- package/templates/vanilla-ts/src/style.css +0 -140
- package/templates/vanilla-ts/src/utils.ts +0 -16
- package/templates/vanilla-ts/src/vite-env.d.ts +0 -1
- package/templates/vanilla-ts/tsconfig.json +0 -25
- /package/templates/{react-ts → _shared/interactive-sphere}/public/environment-map.png +0 -0
- /package/templates/{react-ts → engine/base}/_gitignore +0 -0
- /package/templates/{react-ts → engine/base}/src/assets/playcanvas.png +0 -0
- /package/templates/{vanilla-ts → engine/interactive-sphere}/src/assets/typescript.svg +0 -0
- /package/templates/{vanilla-ts → react/base}/_gitignore +0 -0
- /package/templates/{vanilla-ts → react/base}/src/assets/playcanvas.png +0 -0
- /package/templates/{react-ts → react/interactive-sphere}/src/assets/react.svg +0 -0
package/README.md
CHANGED
|
@@ -1,78 +1,82 @@
|
|
|
1
1
|
# create-playcanvas
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/create-playcanvas)
|
|
4
|
-
[](https://npmtrends.com/create-playcanvas)
|
|
5
|
+
[](https://github.com/playcanvas/create-playcanvas/blob/main/LICENSE)
|
|
6
|
+
[](https://discord.gg/RSaMRzg)
|
|
7
|
+
[](https://www.reddit.com/r/PlayCanvas)
|
|
8
|
+
[](https://x.com/intent/follow?screen_name=playcanvas)
|
|
5
9
|
|
|
6
|
-
|
|
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/) |
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
npm create playcanvas@latest
|
|
10
|
-
```
|
|
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).
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
## Getting Started
|
|
13
15
|
|
|
14
16
|
```bash
|
|
15
|
-
|
|
17
|
+
# npm
|
|
18
|
+
npm create playcanvas@latest
|
|
19
|
+
# pnpm
|
|
20
|
+
pnpm create playcanvas@latest
|
|
21
|
+
# yarn
|
|
16
22
|
yarn create playcanvas
|
|
17
|
-
bun
|
|
23
|
+
# bun
|
|
24
|
+
bun x create-playcanvas@latest
|
|
18
25
|
```
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
Then follow the prompts. Requires Node.js 22.23.2 or later.
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
2. **Overwrite behavior** - if the folder already exists
|
|
24
|
-
3. **Package name** - used in `package.json`
|
|
25
|
-
4. **Framework & variant** - pick from templates below
|
|
29
|
+
## Templates
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
| Template | Description |
|
|
32
|
+
| ---------------- | -------------------------------------------- |
|
|
33
|
+
| `engine` | The PlayCanvas Engine API directly |
|
|
34
|
+
| `react` | `@playcanvas/react` components |
|
|
35
|
+
| `web-components` | `@playcanvas/web-components` custom elements |
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
Every template is TypeScript, and includes Vite, ESLint, Prettier and a production build.
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
npm create playcanvas@latest my-game -- -t react-ts --overwrite
|
|
33
|
-
```
|
|
39
|
+
## Boilerplates
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
| ------------------- | --------- | -------------------------------------------------- |
|
|
37
|
-
| `--template <name>` | `-t` | Directly choose template variant (see list below) |
|
|
38
|
-
| `--overwrite` | | Remove existing files in target directory |
|
|
39
|
-
| `--help` | `-h` | Show help/usage information |
|
|
41
|
+
Each template offers a choice of starting scene. `spinning-cube` is the default.
|
|
40
42
|
|
|
41
|
-
|
|
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 |
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
| ------------ | -------------------------------------- |
|
|
45
|
-
| `vanilla-ts` | Vanilla TypeScript + PlayCanvas Engine |
|
|
46
|
-
| `react-ts` | React + TypeScript + PlayCanvas React |
|
|
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.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
## CLI Options
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Clone the repo, then:
|
|
54
|
+
Pass a project name, template and boilerplate to skip the prompts:
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
|
-
npm
|
|
56
|
-
npm run dev # stub build for local development
|
|
57
|
-
node index.js # test the CLI locally
|
|
57
|
+
npm create playcanvas@latest my-game -- --template react --boilerplate spinning-cube
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
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 |
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
npm link
|
|
64
|
-
create-playcanvas
|
|
65
|
-
```
|
|
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`.
|
|
66
69
|
|
|
67
|
-
##
|
|
70
|
+
## Development
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
```bash
|
|
73
|
+
npm install
|
|
74
|
+
npm run build
|
|
75
|
+
node dist/index.mjs
|
|
76
|
+
```
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
2. Create a branch: `git checkout -b feat/my-awesome-idea`
|
|
73
|
-
3. Commit with conventional-commit messages
|
|
74
|
-
4. Push and open a PR
|
|
78
|
+
Contributions are welcome. Please open an issue before proposing a new template or another substantial change.
|
|
75
79
|
|
|
76
80
|
## License
|
|
77
81
|
|
|
78
|
-
MIT
|
|
82
|
+
[MIT](LICENSE)
|
package/dist/index.mjs
CHANGED
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
import{styleText as m}from"node:util";import D,{stdin as Te,stdout as oe}from"node:process";import ke from"node:readline";import"node:tty";import B from"node:fs";import _ from"node:path";import{fileURLToPath as Me}from"node:url";import{promises as Re}from"fs";import Le from"path";function Y(e){return e==null?[]:Array.isArray(e)?e:[e]}function Oe(e,t,r,s){var o,l=e[t],n=~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((o=+r,o*0===0?o:r)),!!r):(o=+r,o*0===0?o:r);e[t]=l==null?n:Array.isArray(l)?l.concat(n):[l,n]}function je(e,t){e=e||[],t=t||{};var r,s,o,l,n,a={_:[]},i=0,c=0,d=0,u=e.length;const f=t.alias!==void 0,g=t.unknown!==void 0,p=t.default!==void 0;if(t.alias=t.alias||{},t.string=Y(t.string),t.boolean=Y(t.boolean),f)for(r in t.alias)for(s=t.alias[r]=Y(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]]||[],c=s.length;c-- >0;)t.boolean.push(s[c]);for(i=t.string.length;i-- >0;)for(s=t.alias[t.string[i]]||[],c=s.length;c-- >0;)t.string.push(s[c]);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 h=g?Object.keys(t.alias):[];for(i=0;i<u;i++){if(o=e[i],o==="--"){a._=a._.concat(e.slice(++i));break}for(c=0;c<o.length&&o.charCodeAt(c)===45;c++);if(c===0)a._.push(o);else if(o.substring(c,c+3)==="no-"){if(l=o.substring(c+3),g&&!~h.indexOf(l))return t.unknown(o);a[l]=!1}else{for(d=c+1;d<o.length&&o.charCodeAt(d)!==61;d++);for(l=o.substring(c,d),n=o.substring(++d)||i+1===u||(""+e[i+1]).charCodeAt(0)===45||e[++i],s=c===2?[l]:l,d=0;d<s.length;d++){if(l=s[d],g&&!~h.indexOf(l))return t.unknown("-".repeat(c)+l);Oe(a,l,d+1<s.length||n,t)}}}if(p)for(r in t.default)a[r]===void 0&&(a[r]=t.default[r]);if(f)for(r in a)for(s=t.alias[r]||[];s.length>0;)a[s.shift()]=a[r];return a}const We=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Ne=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Pe=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||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>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,Z=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,N=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,P=/\t{1,1000}/y,X=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"),V=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Ve=new RegExp("\\p{M}+","gu"),Ue={limit:1/0,ellipsis:""},le=(e,t={},r={})=>{const s=t.limit??1/0,o=t.ellipsis??"",l=t?.ellipsisWidth??(o?le(o,Ue,r).width:0),n=r.ansiWidth??0,a=r.controlWidth??0,i=r.tabWidth??8,c=r.ambiguousWidth??1,d=r.emojiWidth??2,u=r.fullWidthWidth??2,f=r.regularWidth??1,g=r.wideWidth??2;let p=0,h=0,y=e.length,x=0,w=!1,v=y,C=Math.max(0,s-l),E=0,$=0,F=0,b=0;e:for(;;){if($>E||h>=y&&h>p){const R=e.slice(E,$)||e.slice(p,h);x=0;for(const W of R.replaceAll(Ve,"")){const L=W.codePointAt(0)||0;if(Ne(L)?b=u:Pe(L)?b=g:c!==f&&We(L)?b=c:b=f,F+b>C&&(v=Math.min(v,Math.max(E,p)+x)),F+b>s){w=!0;break e}x+=W.length,F+=b}E=$=0}if(h>=y)break;if(V.lastIndex=h,V.test(e)){if(x=V.lastIndex-h,b=x*f,F+b>C&&(v=Math.min(v,h+Math.floor((C-F)/f))),F+b>s){w=!0;break}F+=b,E=p,$=h,h=p=V.lastIndex;continue}if(Z.lastIndex=h,Z.test(e)){if(F+n>C&&(v=Math.min(v,h)),F+n>s){w=!0;break}F+=n,E=p,$=h,h=p=Z.lastIndex;continue}if(N.lastIndex=h,N.test(e)){if(x=N.lastIndex-h,b=x*a,F+b>C&&(v=Math.min(v,h+Math.floor((C-F)/a))),F+b>s){w=!0;break}F+=b,E=p,$=h,h=p=N.lastIndex;continue}if(P.lastIndex=h,P.test(e)){if(x=P.lastIndex-h,b=x*i,F+b>C&&(v=Math.min(v,h+Math.floor((C-F)/i))),F+b>s){w=!0;break}F+=b,E=p,$=h,h=p=P.lastIndex;continue}if(X.lastIndex=h,X.test(e)){if(F+d>C&&(v=Math.min(v,h)),F+d>s){w=!0;break}F+=d,E=p,$=h,h=p=X.lastIndex;continue}h+=1}return{width:w?C:F,index:w?v:y,truncated:w,ellipsed:w&&s>=l}},Ge={limit:1/0,ellipsis:"",ellipsisWidth:0},T=(e,t={})=>le(e,Ge,t).width,U="\x1B",ce="\x9B",Ke=39,Q="\x07",ue="[",ze="]",he="m",ee=`${ze}8;;`,me=new RegExp(`(?:\\${ue}(?<code>\\d+)m|\\${ee}(?<uri>.*)${Q})`,"y"),fe=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},de=e=>`${U}${ue}${e}${he}`,pe=e=>`${U}${ee}${e}${Q}`,te=(e,t,r)=>{const s=t[Symbol.iterator]();let o=!1,l=!1,n=e.at(-1),a=n===void 0?0:T(n),i=s.next(),c=s.next(),d=0;for(;!i.done;){const u=i.value,f=T(u);a+f<=r?e[e.length-1]+=u:(e.push(u),a=0),(u===U||u===ce)&&(o=!0,l=t.startsWith(ee,d+1)),o?l?u===Q&&(o=!1,l=!1):u===he&&(o=!1):(a+=f,a===r&&!c.done&&(e.push(""),a=0)),i=c,c=s.next(),d+=u.length}n=e.at(-1),!a&&n!==void 0&&n.length&&e.length>1&&(e[e.length-2]+=e.pop())},He=e=>{const t=e.split(" ");let r=t.length;for(;r&&!T(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Je=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let s="",o,l;const n=e.split(" ");let a=[""],i=0;for(let u=0;u<n.length;u++){const f=n[u];if(r.trim!==!1){const p=a.at(-1)??"",h=p.trimStart();p.length!==h.length&&(a[a.length-1]=h,i=T(h))}u!==0&&(i>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),i=0),(i||r.trim===!1)&&(a[a.length-1]+=" ",i++));const g=T(f);if(r.hard&&g>t){const p=t-i,h=1+Math.floor((g-p-1)/t);Math.floor((g-1)/t)<h&&a.push(""),te(a,f,t),i=T(a.at(-1)??"");continue}if(i+g>t&&i&&g){if(r.wordWrap===!1&&i<t){te(a,f,t),i=T(a.at(-1)??"");continue}a.push(""),i=0}if(i+g>t&&r.wordWrap===!1){te(a,f,t),i=T(a.at(-1)??"");continue}a[a.length-1]+=f,i+=g}r.trim!==!1&&(a=a.map(u=>He(u)));const c=a.join(`
|
|
2
|
-
|
|
3
|
-
`){
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
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(`
|
|
6
7
|
`),s=t.split(`
|
|
7
|
-
`),
|
|
8
|
-
`).map((
|
|
9
|
-
`)}
|
|
10
|
-
`),
|
|
11
|
-
`).length-1;this.output.write(
|
|
12
|
-
`);this.output.write(n[
|
|
13
|
-
`).slice(
|
|
14
|
-
`)),this._prevFrame=
|
|
15
|
-
`);
|
|
16
|
-
`);if(
|
|
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(`
|
|
17
18
|
`)}
|
|
18
|
-
`)},info:(e,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)}
|
|
19
20
|
|
|
20
|
-
`)},
|
|
21
|
-
${
|
|
21
|
+
`)},pt=(e="",t)=>{const r=process.stdout,s=`${c("gray",$)}
|
|
22
|
+
${c("gray",j)} `;r.write(`${s}${e}
|
|
22
23
|
|
|
23
|
-
`)},
|
|
24
|
+
`)},ft=[`${c("dim","\u2191/\u2193")} to navigate`,`${c("dim","Enter:")} confirm`],H=(e,t)=>e.includes(`
|
|
24
25
|
`)?e.split(`
|
|
25
26
|
`).map(r=>t(r)).join(`
|
|
26
|
-
`):t(e),
|
|
27
|
-
`:""}${
|
|
28
|
-
`;switch(this.state){case"submit":{const
|
|
29
|
-
${
|
|
30
|
-
`).length,
|
|
31
|
-
${
|
|
32
|
-
${i}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
|
|
39
|
-
${
|
|
40
|
-
${a}
|
|
41
|
-
|
|
42
|
-
`),o=
|
|
43
|
-
`);let
|
|
44
|
-
|
|
45
|
-
cd ${
|
|
46
|
-
yarn`,
|
|
47
|
-
yarn dev`;break;default:
|
|
48
|
-
${i} install`,
|
|
49
|
-
${i} run dev`;break}
|
|
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
|
+
${h}
|
|
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]...
|
|
50
51
|
|
|
51
|
-
Create a new PlayCanvas project
|
|
52
|
+
Create a new PlayCanvas project with TypeScript.
|
|
52
53
|
With no arguments, start the CLI in interactive mode.
|
|
53
54
|
|
|
54
55
|
Options:
|
|
55
56
|
-t, --template NAME use a specific template
|
|
57
|
+
-b, --boilerplate NAME use a specific boilerplate
|
|
58
|
+
--overwrite remove existing files from a non-empty target directory
|
|
59
|
+
-y, --yes skip the prompts and take the defaults
|
|
56
60
|
-h, --help show help
|
|
57
|
-
|
|
58
|
-
`,kt={_gitignore:".gitignore"},Mt="playcanvas-project";async function Rt(){const e=j._[0]?ae(String(j._[0])):void 0,t=j.template,r=j.overwrite;if(j.help){console.log(Tt);return}const s=Lt(process.env.npm_config_user_agent),o=()=>pt("Operation cancelled"),l=await Bt({argTargetDir:e,defaultTargetDir:Mt,cancel:o});await _t({targetDir:l,argOverwrite:r,cancel:o});const n=await It({targetDir:l,cancel:o}),a=await Dt({argTemplate:t,FRAMEWORKS:Ie,TEMPLATES:Ct,pkgInfo:s,getFullCustomCommand:Et,cancel:o});await yt({cwd:St,targetDir:l,template:a,packageName:n,renameFiles:kt,pkgInfo:s})}function Lt(e){if(!e)return;const t=e.split(" ")[0].split("/");return{name:t[0],version:t[1]}}Rt().catch(e=>{console.error(e)});
|
|
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,51 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
2
|
+
"name": "create-playcanvas",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Scaffold a PlayCanvas project",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"playcanvas",
|
|
7
|
+
"create",
|
|
8
|
+
"scaffold",
|
|
9
|
+
"template",
|
|
10
|
+
"vite",
|
|
11
|
+
"react",
|
|
12
|
+
"web-components",
|
|
13
|
+
"typescript",
|
|
14
|
+
"webgl",
|
|
15
|
+
"webgpu",
|
|
16
|
+
"game",
|
|
17
|
+
"3d"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://github.com/playcanvas/create-playcanvas#readme",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/playcanvas/create-playcanvas.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "PlayCanvas <support@playcanvas.com>",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"create-playcanvas": "dist/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"templates",
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "unbuild",
|
|
36
|
+
"dev": "unbuild --stub",
|
|
37
|
+
"fmt": "prettier --check .",
|
|
38
|
+
"fmt:fix": "prettier --write .",
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint . --fix",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@clack/prompts": "^1.7.0",
|
|
45
|
+
"@playcanvas/eslint-config": "3.0.0-beta.8",
|
|
46
|
+
"@types/node": "22.20.1",
|
|
47
|
+
"eslint": "^9.39.5",
|
|
48
|
+
"mri": "^1.2.0",
|
|
49
|
+
"picocolors": "^1.1.1",
|
|
50
|
+
"prettier": "^3.9.6",
|
|
51
|
+
"unbuild": "^3.6.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.23.2"
|
|
55
|
+
}
|
|
51
56
|
}
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# PlayCanvas Engine + TypeScript Starter
|
|
2
|
+
|
|
3
|
+
A Vite-powered PlayCanvas Engine project with TypeScript, hot module replacement, ESLint and Prettier.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Node.js 22.23.2 or later.
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm create playcanvas@latest playcanvas-project -- --template engine
|
|
13
|
+
cd playcanvas-project
|
|
14
|
+
npm install
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Open <http://localhost:5173>. Edit the files under `src/` and save to see the scene update.
|
|
19
|
+
|
|
20
|
+
## Scripts
|
|
21
|
+
|
|
22
|
+
| Command | Description |
|
|
23
|
+
| ------------------- | --------------------------------- |
|
|
24
|
+
| `npm run dev` | Start the Vite development server |
|
|
25
|
+
| `npm run build` | Build for production |
|
|
26
|
+
| `npm run start` | Preview the production build |
|
|
27
|
+
| `npm run lint` | Run ESLint |
|
|
28
|
+
| `npm run fmt` | Check formatting |
|
|
29
|
+
| `npm run typecheck` | Run TypeScript checks |
|
|
30
|
+
|
|
31
|
+
Run `npm run build` to generate a deployable static site in `dist/`.
|
|
32
|
+
|
|
33
|
+
## Further reading
|
|
34
|
+
|
|
35
|
+
- [PlayCanvas Engine manual](https://developer.playcanvas.com/user-manual/engine/)
|
|
36
|
+
- [PlayCanvas examples](https://playcanvas.github.io/)
|
|
37
|
+
- [Vite documentation](https://vite.dev/)
|
|
38
|
+
- [TypeScript documentation](https://www.typescriptlang.org/docs/)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "playcanvas-project",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "A PlayCanvas TypeScript project",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"fmt": "prettier --check .",
|
|
11
|
+
"fmt:fix": "prettier --write .",
|
|
12
|
+
"lint": "eslint .",
|
|
13
|
+
"lint:fix": "eslint . --fix",
|
|
14
|
+
"start": "vite preview",
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"playcanvas": "^2.21.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@playcanvas/eslint-config": "3.0.0-beta.8",
|
|
22
|
+
"eslint": "^9.39.5",
|
|
23
|
+
"prettier": "^3.9.6",
|
|
24
|
+
"typescript": "~6.0.3",
|
|
25
|
+
"vite": "^8.2.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.23.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@playcanvas/eslint-config/prettier';
|