@guinetik/gcanvas 1.0.2 โ†’ 1.0.4

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 (217) hide show
  1. package/dist/gcanvas.es.js +25656 -0
  2. package/dist/gcanvas.es.min.js +1 -0
  3. package/dist/gcanvas.umd.js +1 -0
  4. package/dist/gcanvas.umd.min.js +1 -0
  5. package/package.json +23 -6
  6. package/src/game/objects/index.js +1 -0
  7. package/src/game/objects/spritesheet.js +260 -0
  8. package/src/game/ui/theme.js +6 -0
  9. package/src/io/keys.js +9 -1
  10. package/src/math/boolean.js +481 -0
  11. package/src/math/index.js +1 -0
  12. package/.github/workflows/release.yaml +0 -70
  13. package/.jshintrc +0 -4
  14. package/.vscode/settings.json +0 -22
  15. package/CLAUDE.md +0 -310
  16. package/blackhole.jpg +0 -0
  17. package/demo.png +0 -0
  18. package/demos/CNAME +0 -1
  19. package/demos/animations.html +0 -31
  20. package/demos/basic.html +0 -38
  21. package/demos/baskara.html +0 -31
  22. package/demos/bezier.html +0 -35
  23. package/demos/beziersignature.html +0 -29
  24. package/demos/blackhole.html +0 -28
  25. package/demos/blob.html +0 -35
  26. package/demos/coordinates.html +0 -698
  27. package/demos/cube3d.html +0 -23
  28. package/demos/demos.css +0 -303
  29. package/demos/dino.html +0 -42
  30. package/demos/easing.html +0 -28
  31. package/demos/events.html +0 -195
  32. package/demos/fluent.html +0 -647
  33. package/demos/fluid-simple.html +0 -22
  34. package/demos/fluid.html +0 -37
  35. package/demos/fractals.html +0 -36
  36. package/demos/gameobjects.html +0 -626
  37. package/demos/genart.html +0 -26
  38. package/demos/gendream.html +0 -26
  39. package/demos/group.html +0 -36
  40. package/demos/home.html +0 -587
  41. package/demos/index.html +0 -376
  42. package/demos/isometric.html +0 -34
  43. package/demos/js/animations.js +0 -452
  44. package/demos/js/basic.js +0 -204
  45. package/demos/js/baskara.js +0 -751
  46. package/demos/js/bezier.js +0 -692
  47. package/demos/js/beziersignature.js +0 -241
  48. package/demos/js/blackhole/accretiondisk.obj.js +0 -379
  49. package/demos/js/blackhole/blackhole.obj.js +0 -318
  50. package/demos/js/blackhole/index.js +0 -409
  51. package/demos/js/blackhole/particle.js +0 -56
  52. package/demos/js/blackhole/starfield.obj.js +0 -218
  53. package/demos/js/blob.js +0 -2276
  54. package/demos/js/coordinates.js +0 -840
  55. package/demos/js/cube3d.js +0 -789
  56. package/demos/js/dino.js +0 -1420
  57. package/demos/js/easing.js +0 -477
  58. package/demos/js/fluent.js +0 -183
  59. package/demos/js/fluid-simple.js +0 -253
  60. package/demos/js/fluid.js +0 -527
  61. package/demos/js/fractals.js +0 -931
  62. package/demos/js/fractalworker.js +0 -93
  63. package/demos/js/gameobjects.js +0 -176
  64. package/demos/js/genart.js +0 -268
  65. package/demos/js/gendream.js +0 -209
  66. package/demos/js/group.js +0 -140
  67. package/demos/js/info-toggle.js +0 -25
  68. package/demos/js/isometric.js +0 -863
  69. package/demos/js/kerr.js +0 -1556
  70. package/demos/js/lavalamp.js +0 -590
  71. package/demos/js/layout.js +0 -354
  72. package/demos/js/mondrian.js +0 -285
  73. package/demos/js/opacity.js +0 -275
  74. package/demos/js/painter.js +0 -484
  75. package/demos/js/particles-showcase.js +0 -514
  76. package/demos/js/particles.js +0 -299
  77. package/demos/js/patterns.js +0 -397
  78. package/demos/js/penrose/artifact.js +0 -69
  79. package/demos/js/penrose/blackhole.js +0 -121
  80. package/demos/js/penrose/constants.js +0 -73
  81. package/demos/js/penrose/game.js +0 -943
  82. package/demos/js/penrose/lore.js +0 -278
  83. package/demos/js/penrose/penrosescene.js +0 -892
  84. package/demos/js/penrose/ship.js +0 -216
  85. package/demos/js/penrose/sounds.js +0 -211
  86. package/demos/js/penrose/voidparticle.js +0 -55
  87. package/demos/js/penrose/voidscene.js +0 -258
  88. package/demos/js/penrose/voidship.js +0 -144
  89. package/demos/js/penrose/wormhole.js +0 -46
  90. package/demos/js/pipeline.js +0 -555
  91. package/demos/js/plane3d.js +0 -256
  92. package/demos/js/platformer.js +0 -1579
  93. package/demos/js/scene.js +0 -304
  94. package/demos/js/scenes.js +0 -320
  95. package/demos/js/schrodinger.js +0 -410
  96. package/demos/js/schwarzschild.js +0 -1023
  97. package/demos/js/shapes.js +0 -628
  98. package/demos/js/space/alien.js +0 -171
  99. package/demos/js/space/boom.js +0 -98
  100. package/demos/js/space/boss.js +0 -353
  101. package/demos/js/space/buff.js +0 -73
  102. package/demos/js/space/bullet.js +0 -102
  103. package/demos/js/space/constants.js +0 -85
  104. package/demos/js/space/game.js +0 -1884
  105. package/demos/js/space/hud.js +0 -112
  106. package/demos/js/space/laserbeam.js +0 -179
  107. package/demos/js/space/lightning.js +0 -277
  108. package/demos/js/space/minion.js +0 -192
  109. package/demos/js/space/missile.js +0 -212
  110. package/demos/js/space/player.js +0 -430
  111. package/demos/js/space/powerup.js +0 -90
  112. package/demos/js/space/starfield.js +0 -58
  113. package/demos/js/space/starpower.js +0 -90
  114. package/demos/js/spacetime.js +0 -559
  115. package/demos/js/sphere3d.js +0 -229
  116. package/demos/js/sprite.js +0 -473
  117. package/demos/js/svgtween.js +0 -204
  118. package/demos/js/tde/accretiondisk.js +0 -471
  119. package/demos/js/tde/blackhole.js +0 -219
  120. package/demos/js/tde/blackholescene.js +0 -209
  121. package/demos/js/tde/config.js +0 -59
  122. package/demos/js/tde/index.js +0 -820
  123. package/demos/js/tde/jets.js +0 -290
  124. package/demos/js/tde/lensedstarfield.js +0 -154
  125. package/demos/js/tde/tdestar.js +0 -297
  126. package/demos/js/tde/tidalstream.js +0 -372
  127. package/demos/js/tde_old/blackhole.obj.js +0 -354
  128. package/demos/js/tde_old/debris.obj.js +0 -791
  129. package/demos/js/tde_old/flare.obj.js +0 -239
  130. package/demos/js/tde_old/index.js +0 -448
  131. package/demos/js/tde_old/star.obj.js +0 -812
  132. package/demos/js/tiles.js +0 -312
  133. package/demos/js/tweendemo.js +0 -79
  134. package/demos/js/visibility.js +0 -102
  135. package/demos/kerr.html +0 -28
  136. package/demos/lavalamp.html +0 -27
  137. package/demos/layouts.html +0 -37
  138. package/demos/logo.svg +0 -4
  139. package/demos/loop.html +0 -84
  140. package/demos/mondrian.html +0 -32
  141. package/demos/og_image.png +0 -0
  142. package/demos/opacity.html +0 -36
  143. package/demos/painter.html +0 -39
  144. package/demos/particles-showcase.html +0 -28
  145. package/demos/particles.html +0 -24
  146. package/demos/patterns.html +0 -33
  147. package/demos/penrose-game.html +0 -31
  148. package/demos/pipeline.html +0 -737
  149. package/demos/plane3d.html +0 -24
  150. package/demos/platformer.html +0 -43
  151. package/demos/scene.html +0 -33
  152. package/demos/scenes.html +0 -96
  153. package/demos/schrodinger.html +0 -27
  154. package/demos/schwarzschild.html +0 -27
  155. package/demos/shapes.html +0 -16
  156. package/demos/space.html +0 -85
  157. package/demos/spacetime.html +0 -27
  158. package/demos/sphere3d.html +0 -24
  159. package/demos/sprite.html +0 -18
  160. package/demos/svgtween.html +0 -29
  161. package/demos/tde.html +0 -28
  162. package/demos/tiles.html +0 -28
  163. package/demos/transforms.html +0 -400
  164. package/demos/tween.html +0 -45
  165. package/demos/visibility.html +0 -33
  166. package/docs/README.md +0 -230
  167. package/docs/api/FluidSystem.md +0 -173
  168. package/docs/concepts/architecture-overview.md +0 -204
  169. package/docs/concepts/coordinate-system.md +0 -384
  170. package/docs/concepts/lifecycle.md +0 -255
  171. package/docs/concepts/rendering-pipeline.md +0 -279
  172. package/docs/concepts/shapes-vs-gameobjects.md +0 -187
  173. package/docs/concepts/tde-zorder.md +0 -106
  174. package/docs/concepts/two-layer-architecture.md +0 -229
  175. package/docs/fluid-dynamics.md +0 -99
  176. package/docs/getting-started/first-game.md +0 -354
  177. package/docs/getting-started/hello-world.md +0 -269
  178. package/docs/getting-started/installation.md +0 -175
  179. package/docs/modules/collision/README.md +0 -453
  180. package/docs/modules/fluent/README.md +0 -1075
  181. package/docs/modules/game/README.md +0 -303
  182. package/docs/modules/isometric-camera.md +0 -210
  183. package/docs/modules/isometric.md +0 -275
  184. package/docs/modules/painter/README.md +0 -328
  185. package/docs/modules/particle/README.md +0 -559
  186. package/docs/modules/shapes/README.md +0 -221
  187. package/docs/modules/shapes/base/euclidian.md +0 -123
  188. package/docs/modules/shapes/base/geometry2d.md +0 -204
  189. package/docs/modules/shapes/base/renderable.md +0 -215
  190. package/docs/modules/shapes/base/shape.md +0 -262
  191. package/docs/modules/shapes/base/transformable.md +0 -243
  192. package/docs/modules/shapes/hierarchy.md +0 -218
  193. package/docs/modules/state/README.md +0 -577
  194. package/docs/modules/util/README.md +0 -99
  195. package/docs/modules/util/camera3d.md +0 -412
  196. package/docs/modules/util/scene3d.md +0 -395
  197. package/index.html +0 -17
  198. package/jsdoc.json +0 -50
  199. package/scripts/build-demo.js +0 -69
  200. package/scripts/bundle4llm.js +0 -276
  201. package/scripts/clearconsole.js +0 -48
  202. package/test/math/orbital.test.js +0 -61
  203. package/test/math/tensor.test.js +0 -114
  204. package/test/particle/emitter.test.js +0 -204
  205. package/test/particle/particle-system.test.js +0 -310
  206. package/test/particle/particle.test.js +0 -116
  207. package/test/particle/updaters.test.js +0 -386
  208. package/test/setup.js +0 -120
  209. package/test/shapes/euclidian.test.js +0 -44
  210. package/test/shapes/geometry.test.js +0 -86
  211. package/test/shapes/group.test.js +0 -86
  212. package/test/shapes/rectangle.test.js +0 -64
  213. package/test/shapes/transform.test.js +0 -379
  214. package/test/util/camera3d.test.js +0 -428
  215. package/test/util/scene3d.test.js +0 -352
  216. package/vite.config.js +0 -50
  217. package/vitest.config.js +0 -13
@@ -1,395 +0,0 @@
1
- # Scene3D
2
-
3
- > A Scene that automatically projects children through Camera3D for pseudo-3D effects.
4
-
5
- ## Overview
6
-
7
- Scene3D bridges the GameObject/Scene system with Camera3D. It allows you to position GameObjects in 3D space (x, y, z) and automatically projects them through the camera for rendering.
8
-
9
- **Key Features:**
10
- - Extends the standard Scene class
11
- - Projects children through Camera3D automatically
12
- - Supports z-coordinate on any GameObject
13
- - Depth sorting (back-to-front rendering)
14
- - Perspective scaling based on depth
15
-
16
- ## Quick Start
17
-
18
- ```js
19
- import { Game, Camera3D, Scene3D, GameObject, Rectangle } from '@guinetik/gcanvas';
20
-
21
- class BoxObject extends GameObject {
22
- constructor(game) {
23
- super(game);
24
- this.z = 0; // Add z coordinate
25
- this.shape = new Rectangle({
26
- width: 60,
27
- height: 60,
28
- color: '#4a9eff',
29
- stroke: '#fff',
30
- });
31
- }
32
-
33
- draw() {
34
- this.shape.draw();
35
- }
36
- }
37
-
38
- class My3DDemo extends Game {
39
- init() {
40
- super.init();
41
-
42
- // Create camera
43
- this.camera = new Camera3D({
44
- rotationX: 0.3,
45
- perspective: 800,
46
- });
47
- this.camera.enableMouseControl(this.canvas);
48
-
49
- // Create 3D scene (centered on screen)
50
- this.scene3d = new Scene3D(this, {
51
- x: this.width / 2,
52
- y: this.height / 2,
53
- camera: this.camera,
54
- depthSort: true,
55
- });
56
-
57
- // Add objects with different z positions
58
- const front = new BoxObject(this);
59
- front.x = -80;
60
- front.z = 100; // In front
61
-
62
- const middle = new BoxObject(this);
63
- middle.x = 0;
64
- middle.z = 0; // Center
65
-
66
- const back = new BoxObject(this);
67
- back.x = 80;
68
- back.z = -100; // Behind
69
-
70
- this.scene3d.add(front);
71
- this.scene3d.add(middle);
72
- this.scene3d.add(back);
73
-
74
- this.pipeline.add(this.scene3d);
75
- }
76
-
77
- update(dt) {
78
- super.update(dt);
79
- this.camera.update(dt);
80
- }
81
- }
82
- ```
83
-
84
- ## Constructor Options
85
-
86
- ```js
87
- const scene3d = new Scene3D(game, {
88
- // Position (screen coordinates where scene is centered)
89
- x: game.width / 2,
90
- y: game.height / 2,
91
-
92
- // Required: Camera for projection
93
- camera: myCamera,
94
-
95
- // Optional settings
96
- depthSort: true, // Sort children by depth (back-to-front)
97
- scaleByDepth: true, // Scale children based on perspective
98
- });
99
- ```
100
-
101
- | Option | Type | Default | Description |
102
- |--------|------|---------|-------------|
103
- | `camera` | `Camera3D` | **required** | Camera for 3D projection |
104
- | `depthSort` | `boolean` | `true` | Sort children back-to-front |
105
- | `scaleByDepth` | `boolean` | `true` | Apply perspective scaling |
106
- | `x`, `y` | `number` | `0` | Scene position (typically screen center) |
107
-
108
- ---
109
-
110
- ## Adding Objects
111
-
112
- Scene3D works with any GameObject. Just add a `z` property:
113
-
114
- ```js
115
- // Standard GameObject
116
- class MyObject extends GameObject {
117
- constructor(game) {
118
- super(game);
119
- this.z = 0; // Initialize z coordinate
120
- }
121
- }
122
-
123
- // Add to scene
124
- const obj = new MyObject(this);
125
- obj.x = 100; // Horizontal position
126
- obj.y = 50; // Vertical position
127
- obj.z = -200; // Depth (negative = behind, positive = in front)
128
- scene3d.add(obj);
129
- ```
130
-
131
- If an object doesn't have a `z` property, it defaults to `0` (center plane).
132
-
133
- ---
134
-
135
- ## Depth Sorting
136
-
137
- When `depthSort: true`, Scene3D renders objects from back to front, ensuring correct overlap:
138
-
139
- ```js
140
- // Objects overlap correctly
141
- const scene3d = new Scene3D(this, {
142
- camera: this.camera,
143
- depthSort: true, // Enable depth sorting
144
- });
145
-
146
- // Back object won't obscure front object
147
- backObj.z = -100; // Behind
148
- frontObj.z = 100; // In front
149
- ```
150
-
151
- Disable for performance if objects don't overlap:
152
-
153
- ```js
154
- // All objects at same z - no need to sort
155
- const scene3d = new Scene3D(this, {
156
- camera: this.camera,
157
- depthSort: false,
158
- });
159
- ```
160
-
161
- ---
162
-
163
- ## Perspective Scaling
164
-
165
- When `scaleByDepth: true`, objects scale based on their distance from the camera:
166
-
167
- ```js
168
- // Objects shrink as they move away
169
- const scene3d = new Scene3D(this, {
170
- camera: this.camera,
171
- scaleByDepth: true, // Enable perspective scaling
172
- });
173
-
174
- nearObj.z = 200; // Appears larger
175
- farObj.z = -300; // Appears smaller
176
- ```
177
-
178
- Disable for flat rendering (no size change with depth):
179
-
180
- ```js
181
- // All objects same size regardless of z
182
- const scene3d = new Scene3D(this, {
183
- camera: this.camera,
184
- scaleByDepth: false,
185
- });
186
- ```
187
-
188
- ---
189
-
190
- ## Common Patterns
191
-
192
- ### Responsive Centering
193
-
194
- Keep Scene3D centered when window resizes:
195
-
196
- ```js
197
- class MyDemo extends Game {
198
- init() {
199
- super.init();
200
- this.enableFluidSize();
201
-
202
- this.scene3d = new Scene3D(this, {
203
- x: this.width / 2,
204
- y: this.height / 2,
205
- camera: this.camera,
206
- });
207
- }
208
-
209
- update(dt) {
210
- super.update(dt);
211
-
212
- // Keep centered on resize
213
- this.scene3d.x = this.width / 2;
214
- this.scene3d.y = this.height / 2;
215
- }
216
- }
217
- ```
218
-
219
- ### Grid of Objects
220
-
221
- Create a 3D grid layout:
222
-
223
- ```js
224
- const spacing = 80;
225
- const gridSize = 5;
226
-
227
- for (let x = 0; x < gridSize; x++) {
228
- for (let z = 0; z < gridSize; z++) {
229
- const obj = new GridCell(this);
230
- obj.x = (x - gridSize / 2) * spacing;
231
- obj.y = 0;
232
- obj.z = (z - gridSize / 2) * spacing;
233
- this.scene3d.add(obj);
234
- }
235
- }
236
- ```
237
-
238
- ### Orbiting Objects
239
-
240
- Animate z-coordinates for 3D motion:
241
-
242
- ```js
243
- class OrbitingObject extends GameObject {
244
- constructor(game, angle, radius) {
245
- super(game);
246
- this.angle = angle;
247
- this.radius = radius;
248
- this.z = 0;
249
- }
250
-
251
- update(dt) {
252
- this.angle += dt;
253
- this.x = Math.cos(this.angle) * this.radius;
254
- this.z = Math.sin(this.angle) * this.radius;
255
- }
256
- }
257
- ```
258
-
259
- ### Multiple Layers
260
-
261
- Use multiple Scene3D instances for layered effects:
262
-
263
- ```js
264
- // Background layer (far away, slow parallax)
265
- this.bgScene = new Scene3D(this, {
266
- x: cx, y: cy,
267
- camera: this.camera,
268
- });
269
-
270
- // Main layer
271
- this.mainScene = new Scene3D(this, {
272
- x: cx, y: cy,
273
- camera: this.camera,
274
- });
275
-
276
- // Foreground layer (close, fast parallax)
277
- this.fgScene = new Scene3D(this, {
278
- x: cx, y: cy,
279
- camera: this.camera,
280
- });
281
-
282
- // Add to pipeline in order
283
- this.pipeline.add(this.bgScene);
284
- this.pipeline.add(this.mainScene);
285
- this.pipeline.add(this.fgScene);
286
- ```
287
-
288
- ---
289
-
290
- ## With ParticleSystem
291
-
292
- Scene3D and ParticleSystem both use Camera3D independently. Add them to the same pipeline:
293
-
294
- ```js
295
- class EffectsDemo extends Game {
296
- init() {
297
- super.init();
298
-
299
- this.camera = new Camera3D({ rotationX: 0.3 });
300
- this.camera.enableMouseControl(this.canvas);
301
-
302
- // 3D scene for objects
303
- this.scene3d = new Scene3D(this, {
304
- x: this.width / 2,
305
- y: this.height / 2,
306
- camera: this.camera,
307
- });
308
-
309
- // Particle system with same camera
310
- this.particles = new ParticleSystem(this, {
311
- camera: this.camera,
312
- depthSort: true,
313
- });
314
-
315
- // Both in pipeline
316
- this.pipeline.add(this.scene3d);
317
- this.pipeline.add(this.particles);
318
- }
319
- }
320
- ```
321
-
322
- ---
323
-
324
- ## How It Works
325
-
326
- Scene3D overrides the Scene's `draw()` method to:
327
-
328
- 1. **Build render list** - Collect visible children with their 3D positions
329
- 2. **Project through camera** - Convert 3D (x, y, z) to 2D screen coordinates
330
- 3. **Cull behind camera** - Skip objects behind the camera plane
331
- 4. **Sort by depth** - Order back-to-front (if enabled)
332
- 5. **Render with scaling** - Draw each child at projected position with perspective scale
333
-
334
- ```
335
- Child Object (x, y, z)
336
- โ”‚
337
- โ–ผ
338
- Camera3D.project()
339
- โ”‚
340
- โ–ผ
341
- Screen Position (x, y, scale)
342
- โ”‚
343
- โ–ผ
344
- Painter.translateTo() + scale()
345
- โ”‚
346
- โ–ผ
347
- child.draw()
348
- ```
349
-
350
- ---
351
-
352
- ## Differences from Scene
353
-
354
- | Feature | Scene | Scene3D |
355
- |---------|-------|---------|
356
- | Coordinate system | 2D (x, y) | 3D (x, y, z) |
357
- | Projection | None | Camera3D |
358
- | Depth sorting | By zIndex | By projected z |
359
- | Perspective scaling | No | Yes (optional) |
360
- | Camera required | No | Yes |
361
-
362
- ---
363
-
364
- ## API Reference
365
-
366
- ### Properties
367
-
368
- | Property | Type | Description |
369
- |----------|------|-------------|
370
- | `camera` | `Camera3D` | Camera used for projection |
371
- | `depthSort` | `boolean` | Whether to sort by depth |
372
- | `scaleByDepth` | `boolean` | Whether to scale by perspective |
373
- | `children` | `Array` | Child GameObjects (inherited) |
374
-
375
- ### Methods
376
-
377
- Inherits all methods from Scene:
378
-
379
- | Method | Description |
380
- |--------|-------------|
381
- | `add(child)` | Add a GameObject |
382
- | `remove(child)` | Remove a GameObject |
383
- | `clear()` | Remove all children |
384
-
385
- ---
386
-
387
- ## Related
388
-
389
- - [Camera3D](./camera3d.md) - Camera projection and controls
390
- - [Game Module](../game/README.md) - Scene base class
391
-
392
- ## See Also
393
-
394
- - [Particle Module](../particle/README.md) - 3D particle effects
395
- - [Shapes Module](../shapes/README.md) - Shape primitives
package/index.html DELETED
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <title>GCanvas Demos</title>
7
- </head>
8
-
9
- <body>
10
- <div id="info">
11
- <h1>๐Ÿงช GCanvas Demo Gallery</h1>
12
- <p>Explore demos powered by the GCanvas engine:</p>
13
- <a href="demos/index.html">Go to demos</a>
14
- </div>
15
- </body>
16
-
17
- </html>
package/jsdoc.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "tags": {
3
- "allowUnknownTags": ["category"]
4
- },
5
- "source": {
6
- "include": ["./src"],
7
- "includePattern": ".js$",
8
- "excludePattern": "(node_modules/|docs)"
9
- },
10
- "plugins": [
11
- "./node_modules/better-docs/category"
12
- ],
13
- "opts": {
14
- "encoding": "utf8",
15
- "destination": "docs-gen",
16
- "readme": "readme.md",
17
- "recurse": true,
18
- "verbose": true,
19
- "tutorials": "",
20
- "template": "./node_modules/better-docs"
21
- },
22
- "templates": {
23
- "cleverLinks": false,
24
- "monospaceLinks": false,
25
- "search": true,
26
- "default": {
27
- "staticFiles": {
28
- "include": [""]
29
- }
30
- },
31
- "better-docs": {
32
- "name": "GCanvas",
33
- "logo": "images/logo.png",
34
- "title": "GCanvas",
35
- "css": "style.css",
36
- "trackingCode": "",
37
- "hideGenerator": false,
38
- "navLinks": [
39
- {
40
- "label": "Github",
41
- "href": "https://github.com/guinetik/gcanvas"
42
- },
43
- {
44
- "label": "Tech Demo",
45
- "href": "https://gcanvas.guinetik.com"
46
- }
47
- ]
48
- }
49
- }
50
- }
@@ -1,69 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { fileURLToPath } from "url";
4
- import { execSync } from "child_process";
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- const ROOT = path.join(__dirname, "..");
10
- const DEMOS = path.join(ROOT, "demos");
11
- const DIST = path.join(ROOT, "dist");
12
- const PUBLIC = path.join(ROOT, "public");
13
- const ESM_FILE = path.join(DIST, "gcanvas.es.min.js");
14
-
15
- function cleanPublic() {
16
- if (fs.existsSync(PUBLIC)) fs.rmSync(PUBLIC, { recursive: true });
17
- fs.mkdirSync(PUBLIC);
18
- }
19
-
20
- function copyRecursive(src, dest) {
21
- fs.mkdirSync(dest, { recursive: true });
22
- for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
23
- const srcPath = path.join(src, entry.name);
24
- const destPath = path.join(dest, entry.name);
25
- if (entry.isDirectory()) copyRecursive(srcPath, destPath);
26
- else fs.copyFileSync(srcPath, destPath);
27
- }
28
- }
29
-
30
- function rewriteImports(dir) {
31
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
32
- const fullPath = path.join(dir, entry.name);
33
-
34
- if (entry.isDirectory()) {
35
- rewriteImports(fullPath);
36
- } else if (entry.isFile() && /\.(js|html)$/.test(entry.name)) {
37
- let content = fs.readFileSync(fullPath, "utf-8");
38
-
39
- // Replace all imports pointing to any form of src/
40
- content = content.replace(
41
- /from\s+["'](\.{1,2}\/)+src\/[^"']+["']/g,
42
- `from "/gcanvas.es.min.js"`
43
- );
44
-
45
- fs.writeFileSync(fullPath, content);
46
- }
47
- }
48
- }
49
-
50
- function run() {
51
- console.log("๐Ÿงน Cleaning public/");
52
- cleanPublic();
53
-
54
- console.log("๐Ÿ“ฆ Running build");
55
- execSync("npm run build", { stdio: "inherit" });
56
-
57
- console.log("๐Ÿ“ Copying demos โ†’ public/");
58
- copyRecursive(DEMOS, PUBLIC);
59
-
60
- console.log("๐Ÿ“ Copying gcanvas.es.min.js โ†’ public/");
61
- fs.copyFileSync(ESM_FILE, path.join(PUBLIC, "gcanvas.es.min.js"));
62
-
63
- console.log("โœ๏ธ Rewriting imports in public/...");
64
- rewriteImports(PUBLIC);
65
-
66
- console.log("โœ… build:demo complete");
67
- }
68
-
69
- run();