create-playcanvas 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +39 -47
  2. package/dist/index.mjs +51 -45
  3. package/package.json +53 -49
  4. package/templates/index.ts +15 -57
  5. package/templates/react-ts/README.md +32 -59
  6. package/templates/react-ts/eslint.config.mjs +14 -0
  7. package/templates/react-ts/index.html +10 -10
  8. package/templates/react-ts/package.json +34 -27
  9. package/templates/react-ts/prettier.config.mjs +1 -0
  10. package/templates/react-ts/src/App.css +37 -49
  11. package/templates/react-ts/src/App.tsx +38 -41
  12. package/templates/react-ts/src/Scene.tsx +50 -50
  13. package/templates/react-ts/src/index.css +30 -52
  14. package/templates/react-ts/src/main.tsx +9 -8
  15. package/templates/react-ts/src/vite-env.d.ts +12 -0
  16. package/templates/react-ts/tsconfig.json +24 -5
  17. package/templates/react-ts/vite.config.ts +4 -4
  18. package/templates/vanilla-ts/README.md +31 -91
  19. package/templates/vanilla-ts/eslint.config.mjs +3 -0
  20. package/templates/vanilla-ts/index.html +10 -10
  21. package/templates/vanilla-ts/package.json +28 -21
  22. package/templates/vanilla-ts/prettier.config.mjs +1 -0
  23. package/templates/vanilla-ts/src/App.ts +149 -151
  24. package/templates/vanilla-ts/src/main.ts +7 -7
  25. package/templates/vanilla-ts/src/style.css +60 -93
  26. package/templates/vanilla-ts/src/utils.ts +9 -8
  27. package/templates/vanilla-ts/src/vite-env.d.ts +12 -0
  28. package/templates/vanilla-ts/tsconfig.json +22 -22
  29. package/index.js +0 -3
  30. package/templates/react-ts/scripts/ensure-node-version.cjs +0 -12
  31. package/templates/react-ts/tsconfig.app.json +0 -27
  32. package/templates/react-ts/tsconfig.node.json +0 -25
  33. package/templates/vanilla-ts/scripts/ensure-node-version.cjs +0 -12
@@ -1,140 +1,107 @@
1
1
  :root {
2
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
2
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
5
 
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
9
 
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
14
  }
15
15
 
16
16
  header {
17
- display: flex;
18
- flex-direction: row;
19
- align-items: center;
20
- padding: 2rem;
17
+ display: flex;
18
+ flex-direction: row;
19
+ align-items: center;
20
+ padding: 2rem;
21
21
  }
22
22
 
23
23
  a {
24
- font-weight: 500;
25
- color: #646cff;
26
- pointer-events: auto;
27
- text-decoration: inherit;
24
+ font-weight: 500;
25
+ color: #646cff;
26
+ pointer-events: auto;
27
+ text-decoration: inherit;
28
28
  }
29
29
  a:hover {
30
- color: #535bf2;
30
+ color: #535bf2;
31
31
  }
32
32
 
33
33
  body {
34
- width: 100%;
35
- height: 100%;
36
- padding: 0;
37
- margin: 0;
38
- overflow: hidden;
34
+ width: 100%;
35
+ height: 100%;
36
+ padding: 0;
37
+ margin: 0;
38
+ overflow: hidden;
39
39
  }
40
40
 
41
41
  h1 {
42
- font-size: 2.4em;
43
- line-height: 1.1;
44
- opacity: 0.85;
45
- }
46
-
47
- #app {
48
- max-width: 1280px;
49
- margin: 0 auto;
50
- padding: 2rem;
51
- text-align: center;
42
+ font-size: 2.4em;
43
+ line-height: 1.1;
44
+ opacity: 0.85;
52
45
  }
53
46
 
54
47
  .logo {
55
- height: 2em;
56
- padding: .5em;
57
- will-change: filter;
58
- transition: filter 300ms;
48
+ height: 2em;
49
+ padding: 0.5em;
50
+ will-change: filter;
51
+ transition: filter 300ms;
59
52
  }
60
53
 
61
54
  .playcanvas-logo {
62
- border-radius: 100%;
55
+ border-radius: 100%;
63
56
  }
64
57
 
65
58
  .logo:hover {
66
- filter: drop-shadow(0 0 2em #646cffaa);
59
+ filter: drop-shadow(0 0 2em #646cffaa);
67
60
  }
68
61
 
69
62
  .logo.vanilla:hover {
70
- filter: drop-shadow(0 0 2em #3178c6aa);
71
- }
72
-
73
- .card {
74
- padding: 2em;
63
+ filter: drop-shadow(0 0 2em #3178c6aa);
75
64
  }
76
65
 
77
66
  .read-the-docs {
78
- color: #888;
79
- }
80
-
81
- button {
82
- border-radius: 8px;
83
- border: 1px solid transparent;
84
- padding: 0.6em 1.2em;
85
- font-size: 1em;
86
- font-weight: 500;
87
- font-family: inherit;
88
- background-color: #1a1a1a;
89
- cursor: pointer;
90
- transition: border-color 0.25s;
91
- }
92
- button:hover {
93
- border-color: #646cff;
94
- }
95
- button:focus,
96
- button:focus-visible {
97
- outline: 4px auto -webkit-focus-ring-color;
67
+ color: #888;
98
68
  }
99
69
 
100
70
  @media (prefers-color-scheme: light) {
101
- :root {
102
- color: #213547;
103
- background-color: #ffffff;
104
- }
105
- a:hover {
106
- color: #747bff;
107
- }
108
- button {
109
- background-color: #f9f9f9;
110
- }
71
+ :root {
72
+ color: #213547;
73
+ background-color: #ffffff;
74
+ }
75
+ a:hover {
76
+ color: #747bff;
77
+ }
111
78
  }
112
79
 
113
80
  .overlay {
114
- margin: 0 auto;
115
- text-align: center;
116
- display: flex;
117
- flex-direction: column;
118
- align-items: center;
119
- justify-content: stretch;
120
- width: 100vw;
121
- height: 100vh;
122
- pointer-events: none;
81
+ margin: 0 auto;
82
+ text-align: center;
83
+ display: flex;
84
+ flex-direction: column;
85
+ align-items: center;
86
+ justify-content: stretch;
87
+ width: 100vw;
88
+ height: 100vh;
89
+ pointer-events: none;
123
90
  }
124
91
 
125
92
  .overlay > .grow {
126
- flex-grow: 1;
93
+ flex-grow: 1;
127
94
  }
128
95
 
129
96
  .absolute {
130
- position: absolute;
131
- top: 0;
132
- left: 0;
97
+ position: absolute;
98
+ top: 0;
99
+ left: 0;
133
100
  }
134
101
 
135
102
  .pill {
136
- background-color: #000;
137
- color: #fff;
138
- padding: 0.5rem 1rem;
139
- border-radius: 0.5rem;
140
- }
103
+ background-color: #000;
104
+ color: #fff;
105
+ padding: 0.5rem 1rem;
106
+ border-radius: 0.5rem;
107
+ }
@@ -4,13 +4,14 @@
4
4
  * @param interval - The interval in milliseconds
5
5
  * @returns A throttled function
6
6
  */
7
- export function throttle(fn: (...args: any[]) => void, interval = 100) { // interval in ms
7
+ export const throttle = <T extends unknown[]>(fn: (...args: T) => void, interval = 100) => {
8
+ // interval in ms
8
9
  let last = 0;
9
- return (...args: any[]) => {
10
- const now = Date.now();
11
- if (now - last >= interval) {
12
- last = now;
13
- fn(...args);
14
- }
10
+ return (...args: T) => {
11
+ const now = Date.now();
12
+ if (now - last >= interval) {
13
+ last = now;
14
+ fn(...args);
15
+ }
15
16
  };
16
- }
17
+ };
@@ -1 +1,13 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ declare module 'playcanvas/scripts/esm/camera-controls.mjs' {
4
+ import type { Script } from 'playcanvas';
5
+
6
+ export const CameraControls: typeof Script & (new () => Script);
7
+ }
8
+
9
+ declare module 'playcanvas/scripts/esm/grid.mjs' {
10
+ import type { Script } from 'playcanvas';
11
+
12
+ export const Grid: typeof Script & (new () => Script);
13
+ }
@@ -1,25 +1,25 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "skipLibCheck": true,
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
8
 
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
15
 
16
- /* Linting */
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "erasableSyntaxOnly": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "noUncheckedSideEffectImports": true
23
- },
24
- "include": ["src"]
25
- }
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "erasableSyntaxOnly": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedSideEffectImports": true
23
+ },
24
+ "include": ["src"]
25
+ }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import './dist/index.mjs'
@@ -1,12 +0,0 @@
1
- const semver = require('semver');
2
- const pkg = require('../package.json');
3
-
4
- const requiredVersion = pkg.engines.node;
5
- const currentVersion = process.version;
6
-
7
- if (!semver.satisfies(currentVersion, requiredVersion)) {
8
- console.error(`\n❌ Unsupported Node.js version: ${currentVersion}`);
9
- console.error(`Required: ${requiredVersion}`);
10
- console.error('Please upgrade your Node.js to continue.\n');
11
- process.exit(1);
12
- }
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2022",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
16
- "jsx": "react-jsx",
17
-
18
- /* Linting */
19
- "strict": true,
20
- "noUnusedLocals": true,
21
- "noUnusedParameters": true,
22
- "erasableSyntaxOnly": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedSideEffectImports": true
25
- },
26
- "include": ["src"]
27
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2023",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
-
16
- /* Linting */
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "erasableSyntaxOnly": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "noUncheckedSideEffectImports": true
23
- },
24
- "include": ["vite.config.ts"]
25
- }
@@ -1,12 +0,0 @@
1
- const semver = require('semver');
2
- const pkg = require('../package.json');
3
-
4
- const requiredVersion = pkg.engines.node;
5
- const currentVersion = process.version;
6
-
7
- if (!semver.satisfies(currentVersion, requiredVersion)) {
8
- console.error(`\n❌ Unsupported Node.js version: ${currentVersion}`);
9
- console.error(`Required: ${requiredVersion}`);
10
- console.error('Please upgrade your Node.js to continue.\n');
11
- process.exit(1);
12
- }