@oidoid/void 0.1.0-4 → 0.1.0-6

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 (300) hide show
  1. package/dist/meta.json +1 -0
  2. package/dist/package.json +66 -0
  3. package/dist/public/favicon/favicon16.png +0 -0
  4. package/dist/public/favicon/favicon192.png +0 -0
  5. package/dist/public/favicon/favicon32.png +0 -0
  6. package/dist/public/favicon/favicon48.png +0 -0
  7. package/dist/public/favicon/favicon512.png +0 -0
  8. package/dist/public/favicon/favicon64.png +0 -0
  9. package/dist/public/index.html +23 -0
  10. package/dist/public/index.js +3844 -0
  11. package/dist/public/index.js.map +7 -0
  12. package/dist/public/manifest.json +1 -0
  13. package/dist/public/preload-atlas.png +0 -0
  14. package/dist/public/void-v0.1.0-4.html +111 -0
  15. package/dist/public/void-v0.1.0-5.html +111 -0
  16. package/dist/public/void-v0.1.0-6.html +111 -0
  17. package/dist/schema/config-file.d.ts +32 -0
  18. package/dist/schema/config-file.js +41 -0
  19. package/dist/schema/config-file.js.map +1 -0
  20. package/dist/schema/config-file.v0.json +68 -0
  21. package/dist/src/audio.d.ts +7 -0
  22. package/dist/src/audio.js +25 -0
  23. package/dist/src/audio.js.map +1 -0
  24. package/dist/src/demo/assets/manifest.json +46 -0
  25. package/dist/src/demo/assets/preload-atlas.json +193 -0
  26. package/dist/src/demo/ents/clock-ent.d.ts +10 -0
  27. package/dist/src/demo/ents/clock-ent.js +26 -0
  28. package/dist/src/demo/ents/clock-ent.js.map +1 -0
  29. package/dist/src/demo/ents/render-toggle-ent.d.ts +10 -0
  30. package/dist/src/demo/ents/render-toggle-ent.js +38 -0
  31. package/dist/src/demo/ents/render-toggle-ent.js.map +1 -0
  32. package/dist/src/demo/ents/work-counter-ent.d.ts +10 -0
  33. package/dist/src/demo/ents/work-counter-ent.js +24 -0
  34. package/dist/src/demo/ents/work-counter-ent.js.map +1 -0
  35. package/dist/src/demo/game.d.ts +13 -0
  36. package/dist/src/demo/game.js +155 -0
  37. package/dist/src/demo/game.js.map +1 -0
  38. package/dist/src/demo/index.d.ts +1 -0
  39. package/dist/src/demo/index.js +8 -0
  40. package/dist/src/demo/index.js.map +1 -0
  41. package/dist/src/demo/tsconfig.json +15 -0
  42. package/dist/src/demo/types/tag.d.ts +2 -0
  43. package/dist/src/demo/types/tag.js +2 -0
  44. package/dist/src/demo/types/tag.js.map +1 -0
  45. package/dist/src/demo/void.json +11 -0
  46. package/dist/src/ents/button-ent.d.ts +38 -0
  47. package/dist/src/ents/button-ent.js +124 -0
  48. package/dist/src/ents/button-ent.js.map +1 -0
  49. package/dist/src/ents/cursor-ent.d.ts +18 -0
  50. package/dist/src/ents/cursor-ent.js +58 -0
  51. package/dist/src/ents/cursor-ent.js.map +1 -0
  52. package/dist/src/ents/ent.d.ts +7 -0
  53. package/dist/src/ents/ent.js +2 -0
  54. package/dist/src/ents/ent.js.map +1 -0
  55. package/dist/src/ents/follow-cam-ent.d.ts +25 -0
  56. package/dist/src/ents/follow-cam-ent.js +87 -0
  57. package/dist/src/ents/follow-cam-ent.js.map +1 -0
  58. package/dist/src/ents/nine-patch-ent.d.ts +43 -0
  59. package/dist/src/ents/nine-patch-ent.js +143 -0
  60. package/dist/src/ents/nine-patch-ent.js.map +1 -0
  61. package/dist/src/ents/text-ent.d.ts +23 -0
  62. package/dist/src/ents/text-ent.js +109 -0
  63. package/dist/src/ents/text-ent.js.map +1 -0
  64. package/dist/src/ents/zoo.d.ts +16 -0
  65. package/dist/src/ents/zoo.js +38 -0
  66. package/dist/src/ents/zoo.js.map +1 -0
  67. package/dist/src/graphics/atlas-parser.d.ts +4 -0
  68. package/dist/src/graphics/atlas-parser.js +27 -0
  69. package/dist/src/graphics/atlas-parser.js.map +1 -0
  70. package/dist/src/graphics/atlas.d.ts +49 -0
  71. package/dist/src/graphics/atlas.js +7 -0
  72. package/dist/src/graphics/atlas.js.map +1 -0
  73. package/dist/src/graphics/cam.d.ts +89 -0
  74. package/dist/src/graphics/cam.js +211 -0
  75. package/dist/src/graphics/cam.js.map +1 -0
  76. package/dist/src/graphics/gl.d.ts +24 -0
  77. package/dist/src/graphics/gl.js +70 -0
  78. package/dist/src/graphics/gl.js.map +1 -0
  79. package/dist/src/graphics/layer.d.ts +21 -0
  80. package/dist/src/graphics/layer.js +23 -0
  81. package/dist/src/graphics/layer.js.map +1 -0
  82. package/dist/src/graphics/renderer.d.ts +22 -0
  83. package/dist/src/graphics/renderer.js +168 -0
  84. package/dist/src/graphics/renderer.js.map +1 -0
  85. package/dist/src/graphics/sprite-frag.glsl.d.ts +1 -0
  86. package/dist/src/graphics/sprite-frag.glsl.js +35 -0
  87. package/dist/src/graphics/sprite-frag.glsl.js.map +1 -0
  88. package/dist/src/graphics/sprite-vert.glsl.d.ts +1 -0
  89. package/dist/src/graphics/sprite-vert.glsl.js +68 -0
  90. package/dist/src/graphics/sprite-vert.glsl.js.map +1 -0
  91. package/dist/src/graphics/sprite.d.ts +108 -0
  92. package/dist/src/graphics/sprite.js +301 -0
  93. package/dist/src/graphics/sprite.js.map +1 -0
  94. package/dist/src/index.d.ts +30 -0
  95. package/dist/src/index.js +33 -0
  96. package/dist/src/index.js.map +1 -0
  97. package/dist/src/input/context-menu.d.ts +8 -0
  98. package/dist/src/input/context-menu.js +25 -0
  99. package/dist/src/input/context-menu.js.map +1 -0
  100. package/dist/src/input/gamepad.d.ts +18 -0
  101. package/dist/src/input/gamepad.js +49 -0
  102. package/dist/src/input/gamepad.js.map +1 -0
  103. package/dist/src/input/input.d.ts +148 -0
  104. package/dist/src/input/input.js +383 -0
  105. package/dist/src/input/input.js.map +1 -0
  106. package/dist/src/input/keyboard.d.ts +17 -0
  107. package/dist/src/input/keyboard.js +46 -0
  108. package/dist/src/input/keyboard.js.map +1 -0
  109. package/dist/src/input/pointer.d.ts +53 -0
  110. package/dist/src/input/pointer.js +162 -0
  111. package/dist/src/input/pointer.js.map +1 -0
  112. package/dist/src/input/wheel.d.ts +12 -0
  113. package/dist/src/input/wheel.js +30 -0
  114. package/dist/src/input/wheel.js.map +1 -0
  115. package/dist/src/looper.d.ts +15 -0
  116. package/dist/src/looper.js +48 -0
  117. package/dist/src/looper.js.map +1 -0
  118. package/dist/src/mem/pool.d.ts +31 -0
  119. package/dist/src/mem/pool.js +98 -0
  120. package/dist/src/mem/pool.js.map +1 -0
  121. package/dist/src/pixel-ratio-observer.d.ts +10 -0
  122. package/dist/src/pixel-ratio-observer.js +26 -0
  123. package/dist/src/pixel-ratio-observer.js.map +1 -0
  124. package/dist/src/random/random.d.ts +8 -0
  125. package/dist/src/random/random.js +23 -0
  126. package/dist/src/random/random.js.map +1 -0
  127. package/dist/src/storage/local-storage.d.ts +3 -0
  128. package/dist/src/storage/local-storage.js +11 -0
  129. package/dist/src/storage/local-storage.js.map +1 -0
  130. package/dist/src/text/font.d.ts +6 -0
  131. package/dist/src/text/font.js +20 -0
  132. package/dist/src/text/font.js.map +1 -0
  133. package/dist/src/text/mem-prop-5x6.json +573 -0
  134. package/dist/src/text/text-layout.d.ts +19 -0
  135. package/dist/src/text/text-layout.js +85 -0
  136. package/dist/src/text/text-layout.js.map +1 -0
  137. package/dist/src/tsconfig.json +15 -0
  138. package/dist/src/types/geo.d.ts +38 -0
  139. package/dist/src/types/geo.js +61 -0
  140. package/dist/src/types/geo.js.map +1 -0
  141. package/dist/src/types/json.d.ts +31 -0
  142. package/dist/src/types/json.js +2 -0
  143. package/dist/src/types/json.js.map +1 -0
  144. package/dist/src/types/time.d.ts +19 -0
  145. package/dist/src/types/time.js +10 -0
  146. package/dist/src/types/time.js.map +1 -0
  147. package/dist/src/types/void-version.d.ts +9 -0
  148. package/dist/src/types/void-version.js +2 -0
  149. package/dist/src/types/void-version.js.map +1 -0
  150. package/dist/src/utils/async-util.d.ts +11 -0
  151. package/dist/src/utils/async-util.js +36 -0
  152. package/dist/src/utils/async-util.js.map +1 -0
  153. package/dist/src/utils/canvas-util.d.ts +7 -0
  154. package/dist/src/utils/canvas-util.js +128 -0
  155. package/dist/src/utils/canvas-util.js.map +1 -0
  156. package/dist/src/utils/color-util.d.ts +1 -0
  157. package/dist/src/utils/color-util.js +4 -0
  158. package/dist/src/utils/color-util.js.map +1 -0
  159. package/dist/src/utils/debug.d.ts +17 -0
  160. package/dist/src/utils/debug.js +34 -0
  161. package/dist/src/utils/debug.js.map +1 -0
  162. package/dist/src/utils/dom-util.d.ts +3 -0
  163. package/dist/src/utils/dom-util.js +29 -0
  164. package/dist/src/utils/dom-util.js.map +1 -0
  165. package/dist/src/utils/fetch-util.d.ts +3 -0
  166. package/dist/src/utils/fetch-util.js +24 -0
  167. package/dist/src/utils/fetch-util.js.map +1 -0
  168. package/dist/src/utils/math.d.ts +6 -0
  169. package/dist/src/utils/math.js +18 -0
  170. package/dist/src/utils/math.js.map +1 -0
  171. package/dist/src/utils/vibrate.d.ts +1 -0
  172. package/dist/src/utils/vibrate.js +4 -0
  173. package/dist/src/utils/vibrate.js.map +1 -0
  174. package/dist/src/void.d.ts +43 -0
  175. package/dist/src/void.js +95 -0
  176. package/dist/src/void.js.map +1 -0
  177. package/dist/tools/atlas-pack/aseprite.d.ts +58 -0
  178. package/dist/tools/atlas-pack/aseprite.js +16 -0
  179. package/dist/tools/atlas-pack/aseprite.js.map +1 -0
  180. package/dist/tools/atlas-pack/atlas-json-parser.d.ts +21 -0
  181. package/dist/tools/atlas-pack/atlas-json-parser.js +116 -0
  182. package/dist/tools/atlas-pack/atlas-json-parser.js.map +1 -0
  183. package/dist/tools/atlas-pack/atlas-pack.d.ts +2 -0
  184. package/dist/tools/atlas-pack/atlas-pack.js +17 -0
  185. package/dist/tools/atlas-pack/atlas-pack.js.map +1 -0
  186. package/dist/tools/bundle/bundle.d.ts +3 -0
  187. package/dist/tools/bundle/bundle.js +48 -0
  188. package/dist/tools/bundle/bundle.js.map +1 -0
  189. package/dist/tools/bundle/html-plugin.d.ts +3 -0
  190. package/dist/tools/bundle/html-plugin.js +88 -0
  191. package/dist/tools/bundle/html-plugin.js.map +1 -0
  192. package/dist/tools/tsconfig-base.json +45 -0
  193. package/dist/tools/tsconfig.json +21 -0
  194. package/dist/tools/types/config.d.ts +20 -0
  195. package/dist/tools/types/config.js +22 -0
  196. package/dist/tools/types/config.js.map +1 -0
  197. package/dist/tools/utils/argv.d.ts +12 -0
  198. package/dist/tools/utils/argv.js +19 -0
  199. package/dist/tools/utils/argv.js.map +1 -0
  200. package/dist/tools/utils/exec.d.ts +3 -0
  201. package/dist/tools/utils/exec.js +15 -0
  202. package/dist/tools/utils/exec.js.map +1 -0
  203. package/dist/tools/utils/file-util.d.ts +1 -0
  204. package/dist/tools/utils/file-util.js +13 -0
  205. package/dist/tools/utils/file-util.js.map +1 -0
  206. package/dist/tools/utils/html-parser.d.ts +1 -0
  207. package/dist/tools/utils/html-parser.js +10 -0
  208. package/dist/tools/utils/html-parser.js.map +1 -0
  209. package/dist/tools/void.d.ts +17 -0
  210. package/dist/tools/void.js +30 -0
  211. package/dist/tools/void.js.map +1 -0
  212. package/package.json +31 -41
  213. package/readme.md +1 -1
  214. package/schema/config-file.test.ts +55 -0
  215. package/schema/config-file.ts +69 -0
  216. package/schema/config-file.v0.json +68 -0
  217. package/tools/atlas-pack/aseprite.ts +60 -0
  218. package/tools/atlas-pack/atlas-json-parser.test.ts +780 -0
  219. package/tools/atlas-pack/atlas-json-parser.ts +159 -0
  220. package/tools/atlas-pack/atlas-pack.ts +38 -0
  221. package/tools/bundle/bundle.ts +65 -0
  222. package/tools/bundle/html-plugin.ts +135 -0
  223. package/tools/types/config.ts +43 -0
  224. package/tools/utils/argv.test.ts +41 -0
  225. package/tools/utils/argv.ts +29 -0
  226. package/tools/utils/exec.ts +22 -0
  227. package/tools/utils/file-util.ts +11 -0
  228. package/tools/utils/html-parser.ts +9 -0
  229. package/tools/void.ts +54 -0
  230. package/dist/atlas/anim.d.ts +0 -30
  231. package/dist/atlas/anim.js +0 -16
  232. package/dist/atlas/anim.js.map +0 -1
  233. package/dist/atlas/aseprite.d.ts +0 -37
  234. package/dist/atlas/aseprite.js +0 -2
  235. package/dist/atlas/aseprite.js.map +0 -1
  236. package/dist/atlas/atlas-parser.d.ts +0 -52
  237. package/dist/atlas/atlas-parser.js +0 -109
  238. package/dist/atlas/atlas-parser.js.map +0 -1
  239. package/dist/atlas/atlas.d.ts +0 -4
  240. package/dist/atlas/atlas.js +0 -2
  241. package/dist/atlas/atlas.js.map +0 -1
  242. package/dist/audio/synth.d.ts +0 -4
  243. package/dist/audio/synth.js +0 -21
  244. package/dist/audio/synth.js.map +0 -1
  245. package/dist/graphics/bitmap.d.ts +0 -14
  246. package/dist/graphics/bitmap.js +0 -14
  247. package/dist/graphics/bitmap.js.map +0 -1
  248. package/dist/graphics/cam.d.ts +0 -16
  249. package/dist/graphics/cam.js +0 -42
  250. package/dist/graphics/cam.js.map +0 -1
  251. package/dist/graphics/frag.glsl.d.ts +0 -1
  252. package/dist/graphics/frag.glsl.js +0 -15
  253. package/dist/graphics/frag.glsl.js.map +0 -1
  254. package/dist/graphics/frame-listener.d.ts +0 -16
  255. package/dist/graphics/frame-listener.js +0 -83
  256. package/dist/graphics/frame-listener.js.map +0 -1
  257. package/dist/graphics/renderer.d.ts +0 -12
  258. package/dist/graphics/renderer.js +0 -184
  259. package/dist/graphics/renderer.js.map +0 -1
  260. package/dist/graphics/vert.glsl.d.ts +0 -1
  261. package/dist/graphics/vert.glsl.js +0 -46
  262. package/dist/graphics/vert.glsl.js.map +0 -1
  263. package/dist/index.d.ts +0 -31
  264. package/dist/index.js +0 -79
  265. package/dist/index.js.map +0 -1
  266. package/dist/input/gamepad-poller.d.ts +0 -8
  267. package/dist/input/gamepad-poller.js +0 -38
  268. package/dist/input/gamepad-poller.js.map +0 -1
  269. package/dist/input/input.d.ts +0 -44
  270. package/dist/input/input.js +0 -175
  271. package/dist/input/input.js.map +0 -1
  272. package/dist/input/keyboard-poller.d.ts +0 -7
  273. package/dist/input/keyboard-poller.js +0 -30
  274. package/dist/input/keyboard-poller.js.map +0 -1
  275. package/dist/input/pointer-poller.d.ts +0 -12
  276. package/dist/input/pointer-poller.js +0 -67
  277. package/dist/input/pointer-poller.js.map +0 -1
  278. package/dist/sprite/sprite.d.ts +0 -51
  279. package/dist/sprite/sprite.js +0 -161
  280. package/dist/sprite/sprite.js.map +0 -1
  281. package/dist/storage/json-storage.d.ts +0 -4
  282. package/dist/storage/json-storage.js +0 -13
  283. package/dist/storage/json-storage.js.map +0 -1
  284. package/dist/test/tsconfig.json +0 -14
  285. package/dist/text/font.d.ts +0 -6
  286. package/dist/text/font.js +0 -18
  287. package/dist/text/font.js.map +0 -1
  288. package/dist/text/text-layout.d.ts +0 -11
  289. package/dist/text/text-layout.js +0 -73
  290. package/dist/text/text-layout.js.map +0 -1
  291. package/dist/tsconfig.json +0 -13
  292. package/dist/types/2d.d.ts +0 -9
  293. package/dist/types/2d.js +0 -2
  294. package/dist/types/2d.js.map +0 -1
  295. package/dist/void.js +0 -60
  296. package/dist/void.js.map +0 -7
  297. package/dist/void.meta.json +0 -289
  298. package/src/atlas/anim.js +0 -17
  299. package/tools/atlas-parser.js +0 -120
  300. package/tools/void.js +0 -143
@@ -0,0 +1,95 @@
1
+ import { Zoo } from "./ents/zoo.js";
2
+ import { parseAtlas } from "./graphics/atlas-parser.js";
3
+ import { Cam } from "./graphics/cam.js";
4
+ import { Renderer } from "./graphics/renderer.js";
5
+ import { drawableBytes, Sprite } from "./graphics/sprite.js";
6
+ import { Input } from "./input/input.js";
7
+ import { Looper } from "./looper.js";
8
+ import { Pool } from "./mem/pool.js";
9
+ import { PixelRatioObserver } from "./pixel-ratio-observer.js";
10
+ import { initCanvas } from "./utils/canvas-util.js";
11
+ import { initBody, initMetaViewport } from "./utils/dom-util.js";
12
+ import { loadImage } from "./utils/fetch-util.js";
13
+ export class Void {
14
+ cam = new Cam();
15
+ canvas;
16
+ framer = new Looper();
17
+ input;
18
+ preload;
19
+ renderer;
20
+ sprites;
21
+ zoo = new Zoo();
22
+ #pixelRatioObserver = new PixelRatioObserver();
23
+ #preloadAtlasImage;
24
+ #resizeObserver = new ResizeObserver(() => this.onResize());
25
+ constructor(opts) {
26
+ initMetaViewport();
27
+ this.canvas = initCanvas(opts.canvas, opts.mode ?? 'Int');
28
+ initBody(this.canvas, opts.backgroundRGBA ?? 0x000000ff);
29
+ if (opts.minWH)
30
+ this.cam.minWH = opts.minWH;
31
+ this.cam.mode = opts.mode ?? 'Int';
32
+ this.cam.update(this.canvas);
33
+ this.input = new Input(this.cam, this.canvas);
34
+ if (opts.input !== 'Custom')
35
+ this.input.mapDefault();
36
+ this.input.onEvent = () => this.onEvent();
37
+ this.#pixelRatioObserver.onChange = () => this.onResize();
38
+ if (opts.preloadAtlas)
39
+ this.#preloadAtlasImage = opts.preloadAtlas.image;
40
+ this.preload = opts.preloadAtlas
41
+ ? parseAtlas(opts.preloadAtlas.json)
42
+ : { anim: {}, celXYWH: [], tags: [] };
43
+ this.renderer = new Renderer(this.preload ?? {}, this.canvas);
44
+ this.sprites = new Pool({
45
+ alloc: pool => this.onAllocSprite(pool),
46
+ allocBytes: drawableBytes,
47
+ minPages: opts.sprites?.minPages ?? 3,
48
+ pageBlocks: opts.sprites?.pageBlocks ?? 1000
49
+ });
50
+ this.framer.onFrame = millis => this.onFrame(millis);
51
+ }
52
+ onAllocSprite(pool) {
53
+ return new Sprite(pool, 0, this.preload, this.framer);
54
+ }
55
+ onEvent() {
56
+ this.framer.requestFrame();
57
+ }
58
+ /** update input, update canvas, update cam, update world, then render. */
59
+ onFrame(millis) {
60
+ if (document.hidden)
61
+ return;
62
+ this.input.update(millis);
63
+ this.onLoop(millis);
64
+ this.cam.postupdate();
65
+ }
66
+ // biome-ignore lint/correctness/noUnusedFunctionParameters:;
67
+ onLoop(millis) { }
68
+ onResize() {
69
+ this.framer.requestFrame();
70
+ }
71
+ async register(op) {
72
+ this.input.register(op);
73
+ this.renderer.register(op);
74
+ this.framer.register(op);
75
+ if (!this.canvas.parentElement)
76
+ throw Error('no canvas parent');
77
+ if (op === 'add')
78
+ this.#resizeObserver.observe(this.canvas.parentElement);
79
+ else
80
+ this.#resizeObserver.unobserve(this.canvas.parentElement);
81
+ this.#pixelRatioObserver.register(op);
82
+ this.framer.requestFrame();
83
+ if (this.#preloadAtlasImage)
84
+ await loadImage(this.#preloadAtlasImage);
85
+ this.renderer.load(this.#preloadAtlasImage);
86
+ }
87
+ requestFrame() {
88
+ if (this.renderer.always || this.input.anyOn || this.input.gamepad)
89
+ this.framer.requestFrame();
90
+ }
91
+ async [Symbol.asyncDispose]() {
92
+ await this.register('remove');
93
+ }
94
+ }
95
+ //# sourceMappingURL=void.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"void.js","sourceRoot":"","sources":["../../src/void.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,eAAe,CAAA;AAEjC,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,mBAAmB,CAAA;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,aAAa,EAAE,MAAM,EAAC,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAqB,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,IAAI,EAAgB,MAAM,eAAe,CAAA;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAA;AAG5D,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAc/C,MAAM,OAAO,IAAI;IAIN,GAAG,GAAQ,IAAI,GAAG,EAAE,CAAA;IACpB,MAAM,CAAmB;IACzB,MAAM,GAAW,IAAI,MAAM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AC,CAAA;IAC/B,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import type { TagFormat } from '../../src/graphics/atlas.ts';
2
+ import type { Box, WH } from '../../src/types/geo.ts';
3
+ /** https://github.com/aseprite/aseprite/blob/master/docs/ase-file-specs.md */
4
+ export type Aseprite = {
5
+ meta: AsepriteMeta;
6
+ frames: AsepriteFrameMap;
7
+ };
8
+ export type AsepriteFrameMap = {
9
+ [tag: AsepriteFrameTag]: AsepriteFrame;
10
+ };
11
+ export type AsepriteMeta = {
12
+ /** `--list-tags`. */
13
+ frameTags: AsepriteTagSpan[];
14
+ size: WH;
15
+ /** `--list-slices`. */
16
+ slices: AsepriteSlice[];
17
+ };
18
+ /** `--filename-format='{title}--{tag}--{frame}'`. */
19
+ export type AsepriteFrameTag = `${TagFormat}--${bigint}`;
20
+ export type AsepriteFrame = {
21
+ /** positive animation length in milliseconds. */
22
+ duration: number;
23
+ /** bounds including padding. */
24
+ frame: Box;
25
+ /** WH without padding. */
26
+ sourceSize: WH;
27
+ };
28
+ export type AsepriteTagSpan = {
29
+ direction: AsepriteDirection | string;
30
+ name: TagFormat | string;
31
+ from: number;
32
+ /** inclusive ending index, possibly equal to from. */
33
+ to: number;
34
+ };
35
+ export type AsepriteSlice = {
36
+ /** '#ff0000ff' is hitbox, '#00ff00ff' is hurtbox, '#0000ffff is both. */
37
+ color: string;
38
+ name: TagFormat | string;
39
+ keys: {
40
+ bounds: Box;
41
+ }[];
42
+ };
43
+ export type AsepriteDirection = (typeof AsepriteDirection)[keyof typeof AsepriteDirection];
44
+ export declare const AsepriteDirection: {
45
+ /** animate from start to end; when looping, return to start. */
46
+ readonly Forward: "forward";
47
+ /** animate from end to start; when looping, return to end. */
48
+ readonly Reverse: "reverse";
49
+ /**
50
+ * animate from start to end - 1 or start, whichever is greater; when
51
+ * looping, change direction (initially, end to start + 1 or end, whichever
52
+ * is lesser. a traversal from start to end - 1 then end to start + 1 is
53
+ * considered a complete loop.
54
+ */
55
+ readonly PingPong: "pingpong";
56
+ /** like pingpong but start from end - 1 or start, whichever is greater. */
57
+ readonly PingPongReverse: "pingpong_reverse";
58
+ };
@@ -0,0 +1,16 @@
1
+ export const AsepriteDirection = {
2
+ /** animate from start to end; when looping, return to start. */
3
+ Forward: 'forward',
4
+ /** animate from end to start; when looping, return to end. */
5
+ Reverse: 'reverse',
6
+ /**
7
+ * animate from start to end - 1 or start, whichever is greater; when
8
+ * looping, change direction (initially, end to start + 1 or end, whichever
9
+ * is lesser. a traversal from start to end - 1 then end to start + 1 is
10
+ * considered a complete loop.
11
+ */
12
+ PingPong: 'pingpong',
13
+ /** like pingpong but start from end - 1 or start, whichever is greater. */
14
+ PingPongReverse: 'pingpong_reverse'
15
+ };
16
+ //# sourceMappingURL=aseprite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aseprite.js","sourceRoot":"","sources":["../../../tools/atlas-pack/aseprite.ts"],"names":[],"mappings":"AA6CA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gEAAgE;IAChE,OAAO,EAAE,SAAS;IAClB,8DAA8D;IAC9D,OAAO,EAAE,SAAS;IAClB;;;;;OAKG;IACH,QAAQ,EAAE,UAAU;IACpB,2EAA2E;IAC3E,eAAe,EAAE,kBAAkB;CAC3B,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { type Anim, type AtlasJSON } from '../../src/graphics/atlas.ts';
2
+ import { type Box, type XY } from '../../src/types/geo.ts';
3
+ import { type Aseprite, type AsepriteFrame, type AsepriteFrameMap, type AsepriteSlice, type AsepriteTagSpan } from './aseprite.ts';
4
+ export declare function parseAtlasJSON(ase: Readonly<Aseprite>): AtlasJSON;
5
+ /** @internal */
6
+ export declare function parseAnim(id: number, span: Readonly<AsepriteTagSpan>, map: Readonly<AsepriteFrameMap>, slices: readonly Readonly<AsepriteSlice>[]): Anim;
7
+ /**
8
+ * every frame is guaranteed to be present for at least `celMillis`. cels are
9
+ * duplicated until cel duration is at least met. cels are unpacked until a full
10
+ * period is defined for the direction. no warns for overflowing past on second
11
+ * or uneven periods.
12
+ * @internal
13
+ */
14
+ export declare function parseAnimFrames(span: AsepriteTagSpan, map: AsepriteFrameMap): AsepriteFrame[];
15
+ /** @internal */
16
+ export declare function parseCel(frame: Readonly<AsepriteFrame>): XY;
17
+ /** @internal */
18
+ export declare function parseHitboxes(span: Readonly<AsepriteTagSpan>, slices: readonly Readonly<AsepriteSlice>[]): {
19
+ hitbox: Box | undefined;
20
+ hurtbox: Box | undefined;
21
+ };
@@ -0,0 +1,116 @@
1
+ import { animCels, animMillis, celMillis } from "../../src/graphics/atlas.js";
2
+ import { boxEq } from "../../src/types/geo.js";
3
+ import { AsepriteDirection } from "./aseprite.js";
4
+ export function parseAtlasJSON(ase) {
5
+ const anim = {};
6
+ const cels = [];
7
+ for (const span of ase.meta.frameTags) {
8
+ const tag = parseTag(span.name);
9
+ if (anim[tag])
10
+ throw Error(`atlas tag "${tag}" duplicate`);
11
+ const id = Object.keys(anim).length;
12
+ anim[tag] = parseAnim(id, span, ase.frames, ase.meta.slices);
13
+ for (const cel of parseAnimFrames(span, ase.frames).map(parseCel))
14
+ cels.push(cel.x, cel.y);
15
+ }
16
+ for (const slice of ase.meta.slices)
17
+ if (!anim[parseTag(slice.name)])
18
+ throw Error(`atlas hitbox "${slice.name}" has no animation`);
19
+ return { anim, celXY: cels };
20
+ }
21
+ /** @internal */
22
+ export function parseAnim(id, span, map, slices) {
23
+ const cels = parseAnimFrames(span, map);
24
+ if (!cels[0])
25
+ throw Error(`no atlas frame "${span.name}"`);
26
+ const { hitbox, hurtbox } = parseHitboxes(span, slices);
27
+ return {
28
+ cels: cels.length,
29
+ h: cels[0].sourceSize.h,
30
+ hitbox,
31
+ hurtbox,
32
+ id,
33
+ w: cels[0].sourceSize.w
34
+ };
35
+ }
36
+ /**
37
+ * every frame is guaranteed to be present for at least `celMillis`. cels are
38
+ * duplicated until cel duration is at least met. cels are unpacked until a full
39
+ * period is defined for the direction. no warns for overflowing past on second
40
+ * or uneven periods.
41
+ * @internal
42
+ */
43
+ export function parseAnimFrames(span, map) {
44
+ const cels = [];
45
+ let animDuration = 0;
46
+ const len = span.to - span.from + 1;
47
+ const peak = len - 1;
48
+ const cycle = Math.max(1, 2 * peak);
49
+ const end = span.direction === AsepriteDirection.Forward ||
50
+ span.direction === AsepriteDirection.Reverse
51
+ ? len
52
+ : cycle;
53
+ const indexByDir = {
54
+ forward: i => span.from + (i % len),
55
+ pingpong: i => span.from + peak - Math.abs((i % cycle) - peak),
56
+ pingpong_reverse: i => span.to - (peak - Math.abs((i % cycle) - peak)),
57
+ reverse: i => span.to - (i % len)
58
+ };
59
+ const frameIndex = indexByDir[span.direction];
60
+ for (let i = 0; i < end && cels.length < animCels && animDuration < animMillis; i++) {
61
+ const frameTag = `${span.name}--${frameIndex(i)}`;
62
+ const frame = map[frameTag];
63
+ if (!frame)
64
+ throw Error(`no atlas frame "${frameTag}"`);
65
+ for (let celDuration = 0; celDuration < frame.duration &&
66
+ cels.length < animCels &&
67
+ animDuration < animMillis; celDuration += celMillis, animDuration += celMillis) {
68
+ cels.push(frame);
69
+ if (span.from === span.to)
70
+ return cels; // optimize for long single cel.
71
+ }
72
+ }
73
+ return cels;
74
+ }
75
+ /** @internal */
76
+ export function parseCel(frame) {
77
+ return {
78
+ x: frame.frame.x + (frame.frame.w - frame.sourceSize.w) / 2,
79
+ y: frame.frame.y + (frame.frame.h - frame.sourceSize.h) / 2
80
+ };
81
+ }
82
+ /** @internal */
83
+ export function parseHitboxes(span, slices) {
84
+ let hitbox;
85
+ let hurtbox;
86
+ // https://github.com/aseprite/aseprite/issues/3524
87
+ for (const slice of slices) {
88
+ if (slice.name !== span.name)
89
+ continue;
90
+ if (!slice.keys[0])
91
+ continue;
92
+ for (const k of slice.keys)
93
+ if (!boxEq(k.bounds, slice.keys[0].bounds))
94
+ throw Error(`atlas tag "${span.name}" hitbox bounds varies across frames`);
95
+ const red = slice.color === '#ff0000ff';
96
+ const green = slice.color === '#00ff00ff';
97
+ const blue = slice.color === '#0000ffff'; // default Aseprite slice color.
98
+ if (!red && !green && !blue)
99
+ throw Error(`atlas tag "${span.name}" hitbox color ${slice.color} unsupported`);
100
+ if (hitbox && (red || blue))
101
+ throw Error(`atlas tag "${span.name}" has multiple hitboxes`);
102
+ if (hurtbox && (green || blue))
103
+ throw Error(`atlas tag "${span.name}" has multiple hurtboxes`);
104
+ if (red || blue)
105
+ hitbox = slice.keys[0].bounds;
106
+ if (green || blue)
107
+ hurtbox = slice.keys[0].bounds;
108
+ }
109
+ return { hitbox, hurtbox };
110
+ }
111
+ function parseTag(tag) {
112
+ if (!tag.includes('--'))
113
+ throw Error(`atlas tag "${tag}" not in <filestem>--<animation> format`);
114
+ return tag;
115
+ }
116
+ //# sourceMappingURL=atlas-json-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atlas-json-parser.js","sourceRoot":"","sources":["../../../tools/atlas-pack/atlas-json-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EACR,UAAU,EACV,SAAS,EAEV,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAW,KAAK,EAAU,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAEL,iBAAiB,EAMlB,MAAM,eAAe,CAAA;AAEtB,MAAM,UAAU,cAAc,CAAC,GAAuB;IACpD,MAAM,IAAI,GAA0B,EAAE,CAAA;IACtC,MAAM,IAAI,GAAa,EAAE,CAAA;IACzB,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,cAAc,GAAG,aAAa,CAAC,CAAA;QAC1D,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;QACnC,IAAI,CAAC,GAAG,CAAC,G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IAC3B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrB,MAAM,KAAK,CAAC,cAAc,GAAG,yCAAyC,CAAC,CAAA;IACzE,OAAO,GAAgB,CAAA;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { AtlasConfig } from '../../schema/config-file.ts';
2
+ export declare function packAtlas(config: Readonly<AtlasConfig>, minify: boolean): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { exec } from "../utils/exec.js";
4
+ import { globAll } from "../utils/file-util.js";
5
+ import { parseAtlasJSON } from "./atlas-json-parser.js";
6
+ // to-do: separate executable?
7
+ export async function packAtlas(config, minify) {
8
+ const filenames = await globAll(path.join(config.dir, '**.aseprite'));
9
+ if (!filenames.length)
10
+ return;
11
+ const json = await exec('aseprite', '--batch', '--color-mode=indexed', '--filename-format={title}--{tag}--{frame}', '--list-slices', '--list-tags', '--merge-duplicates', `--sheet=${config.image}`, '--sheet-pack', '--tagname-format={title}--{tag}', ...filenames);
12
+ if (minify)
13
+ await exec('zopflipng', '-y', config.image, config.image);
14
+ await fs.writeFile(config.json, JSON.stringify(parseAtlasJSON(JSON.parse(json))));
15
+ await exec('biome', 'check', '--fix', config.json);
16
+ }
17
+ //# sourceMappingURL=atlas-pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atlas-pack.js","sourceRoot":"","sources":["../../../tools/atlas-pack/atlas-pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AAErD,8BAA8B;AAC9B,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA6B,EAC7B,MAAe;IAEf,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAA;IACrE,IAAI,CAAC,SAAS,CAAC,MAAM;QAAE,OAAM;IAE7B,MAAM,IAAI,GAAG,MAAM,IAAI,CACrB,UAAU,EACV,SAAS,EACT,sBAAsB,EACtB,2CAA2C,EAC3C,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,WAAW,MAAM,CAAC,KAAK,EAAE,EACzB,cAAc,EACd,iCAAiC,EACjC,GAAG,SAAS,CACb,CAAA;IAED,IAAI,MAAM;QAAE,MAAM,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IAErE,MAAM,EAAE,CAAC,SAAS,CAChB,MAAM,CAAC,IAAI,EACX,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CACjD,CAAA;IAED,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { VoidVersion } from '../../src/types/void-version.ts';
2
+ import type { Config } from '../types/config.ts';
3
+ export declare function bundle(config: Readonly<Config>, srcFilenames: readonly string[], voidVersion: Readonly<VoidVersion>): Promise<void>;
@@ -0,0 +1,48 @@
1
+ import fs from 'node:fs';
2
+ import esbuild from 'esbuild';
3
+ import * as V from "../../src/index.js";
4
+ import { packAtlas } from "../atlas-pack/atlas-pack.js";
5
+ import { HTMLPlugin } from "./html-plugin.js";
6
+ export async function bundle(config, srcFilenames, voidVersion) {
7
+ const opts = {
8
+ banner: config.watch
9
+ ? {
10
+ js: "new EventSource('/esbuild').addEventListener('change', () => location.reload());"
11
+ }
12
+ : {},
13
+ bundle: true,
14
+ define: {
15
+ // define on globalThis to avoid ReferenceError in unit tests.
16
+ 'globalThis.voidVersion': JSON.stringify(voidVersion)
17
+ },
18
+ entryPoints: [...srcFilenames],
19
+ format: 'esm',
20
+ logLevel: 'info', // print the port and build demarcations.
21
+ metafile: true,
22
+ minify: config.minify,
23
+ outdir: config.out.dir,
24
+ plugins: [HTMLPlugin(config)],
25
+ sourcemap: 'linked',
26
+ target: 'es2024' // https://esbuild.github.io/content-types/#tsconfig-json
27
+ };
28
+ if (config.preloadAtlas)
29
+ await packAtlas(config.preloadAtlas, config.minify);
30
+ if (config.preloadAtlas && config.watch) {
31
+ fs.watch(config.preloadAtlas.dir, { recursive: true }, (ev, type) => onWatch(config.preloadAtlas, config.minify, ev, type));
32
+ const ctx = await esbuild.context(opts);
33
+ await Promise.all([
34
+ ctx.watch(),
35
+ ctx.serve({ port: 1234, servedir: config.out.dir })
36
+ ]);
37
+ }
38
+ else {
39
+ const build = await esbuild.build(opts);
40
+ if (config.meta)
41
+ await fs.promises.writeFile(config.meta, JSON.stringify(build.metafile));
42
+ }
43
+ }
44
+ const onWatch = V.debounce(async (config, minify, ev, file) => {
45
+ console.log(`asset ${file} ${ev}.`);
46
+ await packAtlas(config, minify);
47
+ }, 500);
48
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../tools/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAA;AAEvC,OAAO,EAAC,SAAS,EAAC,MAAM,6BAA6B,CAAA;AAErD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAE3C,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,MAAwB,EACxB,YAA+B,EAC/B,WAAkC;IAElC,MAAM,IAAI,GAAyB;QACjC,MAAM,EAAE,MAAM,CAAC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ACJ,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,IAAI,MAAM,CAAC,IAAI;YACb,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC5E,CAAC;AACH,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CACxB,KAAK,EACH,MAA6B,EAC7B,MAAe,EACf,EAAqB,EACrB,IAAmB,EACnB,EAAE;IACF,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACjC,CAAC,EACD,GAAe,CAChB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type esbuild from 'esbuild';
2
+ import type { Config } from '../types/config.ts';
3
+ export declare function HTMLPlugin(config: Readonly<Config>): esbuild.Plugin;
@@ -0,0 +1,88 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { minify } from 'html-minifier-next';
4
+ import { exec } from "../utils/exec.js";
5
+ import { parseHTML } from "../utils/html-parser.js";
6
+ export function HTMLPlugin(config) {
7
+ return {
8
+ name: 'HTMLPlugin',
9
+ setup(build) {
10
+ build.onEnd(async (_result) => {
11
+ const doc = await parseHTML(config.entry);
12
+ const scripts = doc.querySelectorAll("script[type='module'][src$='.ts']");
13
+ for (const script of scripts) {
14
+ // to-do: test.
15
+ const filename = path.basename(script.getAttribute('src').replace(/\.ts$/, '.js'));
16
+ if (config.oneFile) {
17
+ script.removeAttribute('src');
18
+ script.textContent = await fs.readFile(path.join(config.out.dir, filename), { encoding: 'utf8' });
19
+ }
20
+ else
21
+ script.src = filename;
22
+ }
23
+ if (config.oneFile) {
24
+ const imgs = doc.querySelectorAll('img[src]');
25
+ for (const img of imgs) {
26
+ const filename = img.getAttribute('src');
27
+ const b64 = await fs.readFile(path.join(config.out.dir, filename), {
28
+ encoding: 'base64'
29
+ });
30
+ const ext = filename.match(/\.([^.]+)$/)?.[1];
31
+ if (!ext)
32
+ throw Error('no asset extension');
33
+ img.src = `data:image/${ext};base64,${b64}`;
34
+ }
35
+ }
36
+ const manifestEl = doc.querySelector('link[href][rel="manifest"]');
37
+ if (manifestEl) {
38
+ const manifestFilename = path.resolve(path.dirname(config.entry), manifestEl.getAttribute('href'));
39
+ const manifest = JSON.parse(await fs.readFile(manifestFilename, 'utf8'));
40
+ if (process.env.npm_package_version)
41
+ manifest.version = process.env.npm_package_version;
42
+ for (const icon of manifest.icons ?? []) {
43
+ if (!icon.src || !icon.type)
44
+ continue;
45
+ const iconFilename = `${path.dirname(manifestFilename)}/${icon.src}`;
46
+ const file = await fs.readFile(iconFilename);
47
+ if (config.oneFile)
48
+ icon.src = `data:${icon.type};base64,${file.toString('base64')}`;
49
+ else
50
+ icon.src = path.relative(config.out.dir, iconFilename);
51
+ }
52
+ if (config.watch)
53
+ manifest.start_url = 'http://localhost:1234';
54
+ if (config.oneFile)
55
+ manifestEl.href = `data:application/json,${encodeURIComponent(JSON.stringify(manifest))}`;
56
+ else
57
+ await fs.writeFile(path.join(config.out.dir, path.basename(manifestFilename)), JSON.stringify(manifest));
58
+ }
59
+ if (config.oneFile) {
60
+ const icons = doc.querySelectorAll('link[href][rel="icon"][type]');
61
+ for (const icon of icons) {
62
+ const filename = path.resolve(config.out.dir, icon.getAttribute('href'));
63
+ const file = await fs.readFile(filename);
64
+ icon.href = `data:${icon.type};base64,${file.toString('base64')}`;
65
+ }
66
+ }
67
+ let html = `<!doctype html>\n${doc.documentElement.outerHTML}`;
68
+ if (config.minify)
69
+ html = await minify(html, {
70
+ caseSensitive: true,
71
+ collapseBooleanAttributes: true,
72
+ html5: true,
73
+ minifyCSS: true,
74
+ removeAttributeQuotes: true,
75
+ removeComments: true,
76
+ removeEmptyAttributes: true
77
+ });
78
+ // to-do: what biome config does this use outside of the repo?
79
+ else
80
+ html = await exec('biome', 'check', '--fix', `--stdin-file-path=${config.entry}`, { stdin: html });
81
+ // to-do: test.
82
+ const outHTMLFilename = path.join(config.out.dir, config.out.filename);
83
+ await fs.writeFile(outHTMLFilename, html);
84
+ });
85
+ }
86
+ };
87
+ }
88
+ //# sourceMappingURL=html-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-plugin.js","sourceRoot":"","sources":["../../../tools/bundle/html-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAEzC,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAA;AAcjD,MAAM,UAAU,UAAU,CAAC,MAAwB;IACjD,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,CAAC,KAAK;YACT,KAAK,CAAC,KAAK,CAAC,KAAK,EAAC,OAAO,EAAC,EAAE;gBAC1B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBAEzC,MAAM,OAAO,GAAG,GAAG,CAAC,gBAAgB,CAClC,mCAAmC,CACpC,CAAA;gBACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;oBAC7B,eAAe;oBACf,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAC5B,MAAM,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CACpD,CAAA;oBACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;wBACnB,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;wBAC7B,MAAM,CAAC,WAAW,GAAG,MAAM,EAAE,CAA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CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ // TypeScript config defaults for each sub-project (src, test, etc).
2
+ {
3
+ "$schema": "https://json.schemastore.org/tsconfig.json",
4
+ "compilerOptions": {
5
+ // enable incremental builds.
6
+ "composite": true,
7
+ // enable type-stripping.
8
+ "allowImportingTsExtensions": true,
9
+ // only allow type-strippable syntax.
10
+ "erasableSyntaxOnly": true,
11
+ // maximize type checking.
12
+ "allowUnreachableCode": false,
13
+ "allowUnusedLabels": false,
14
+ "exactOptionalPropertyTypes": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "noImplicitOverride": true,
17
+ "noUncheckedIndexedAccess": true,
18
+ "noUncheckedSideEffectImports": true,
19
+ "noUnusedLocals": true,
20
+ "resolveJsonModule": true,
21
+ "strict": true,
22
+ // projects add types as needed.
23
+ "lib": ["ES2024", "ESNext.disposable"],
24
+ "types": [],
25
+ "isolatedDeclarations": true, // require explicit types.
26
+ // improve compatibility with compilers that aren't type system aware.
27
+ "isolatedModules": true,
28
+ "esModuleInterop": true, // use ESM.
29
+ // allow JSON type-checking and imports.
30
+ "module": "ESNext",
31
+ "moduleResolution": "Bundler",
32
+ "rewriteRelativeImportExtensions": true, // rewrite .ts imports to .js.
33
+ "rootDir": "..",
34
+ // assume library types are checked and compatible.
35
+ "skipLibCheck": true,
36
+ "skipDefaultLibCheck": true,
37
+ "sourceMap": true,
38
+ "target": "ES2024",
39
+ "outDir": "../dist",
40
+ // don't transform type-only imports.
41
+ "verbatimModuleSyntax": true
42
+ },
43
+ "include": ["${configDir}/", "${configDir}/**/*.json"],
44
+ "exclude": ["${configDir}/**/*.test.*", "${configDir}/**/test/"]
45
+ }
@@ -0,0 +1,21 @@
1
+ // TypeScript config for all tools.
2
+ {
3
+ "extends": "./tsconfig-base.json",
4
+ "compilerOptions": {
5
+ "types": ["node"]
6
+ },
7
+ "include": [
8
+ "${configDir}/",
9
+ "${configDir}/**/*.json",
10
+ "../schema/",
11
+ "../schema/**/*.json",
12
+ "../package.json"
13
+ ],
14
+ "exclude": [
15
+ "${configDir}/**/*.test.*",
16
+ "${configDir}/**/test/",
17
+ "../schema/**/*.test.*",
18
+ "../schema/**/test/"
19
+ ],
20
+ "references": [{ "path": "../src" }]
21
+ }
@@ -0,0 +1,20 @@
1
+ import type { AtlasConfig, ConfigFile } from '../../schema/config-file.ts';
2
+ import type { Argv } from '../utils/argv.ts';
3
+ export type Config = {
4
+ $schema: string;
5
+ entry: string;
6
+ meta: string | undefined;
7
+ out: {
8
+ dir: string;
9
+ filename: string;
10
+ };
11
+ preloadAtlas: AtlasConfig | undefined;
12
+ /** config directory name. */
13
+ dirname: string;
14
+ /** config filename. */
15
+ filename: string;
16
+ minify: boolean;
17
+ oneFile: boolean;
18
+ watch: boolean;
19
+ };
20
+ export declare function Config(configFile: Readonly<ConfigFile>, argv: Readonly<Argv>, version: string | undefined): Config;
@@ -0,0 +1,22 @@
1
+ import path from 'node:path';
2
+ export function Config(configFile, argv, version) {
3
+ let stem = path.basename(configFile.entry).replace(/\.[^.]+$/, '');
4
+ if (configFile.out.name && !argv.opts['--watch'])
5
+ stem = configFile.out.name;
6
+ let suffix = '.html';
7
+ if (version && !argv.opts['--watch'])
8
+ suffix = `-v${version}.html`;
9
+ return {
10
+ $schema: configFile.$schema,
11
+ entry: configFile.entry,
12
+ meta: configFile.meta,
13
+ out: { dir: configFile.out.dir, filename: `${stem}${suffix}` },
14
+ preloadAtlas: configFile.preloadAtlas,
15
+ dirname: configFile.dirname,
16
+ filename: configFile.filename,
17
+ minify: argv.opts['--minify'] ?? false,
18
+ oneFile: argv.opts['--one-file'] ?? false,
19
+ watch: argv.opts['--watch'] ?? false
20
+ };
21
+ }
22
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../tools/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAqB5B,MAAM,UAAU,MAAM,CACpB,UAAgC,EAChC,IAAoB,EACpB,OAA2B;IAE3B,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IAClE,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAA;IAC5E,IAAI,MAAM,GAAG,OAAO,CAAA;IACpB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,MAAM,GAAG,KAAK,OAAO,OAAO,CAAA;IAClE,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,EAAE,EAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,MAAM,EAAE,EAAC;QAC5D,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK;QACtC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK;QACzC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK;KACrC,CAAA;AACH,CAAC"}