@oidoid/void 0.1.0-3 → 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 (295) 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 +33 -39
  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/aseprite.d.ts +0 -37
  231. package/dist/atlas/aseprite.js +0 -2
  232. package/dist/atlas/aseprite.js.map +0 -1
  233. package/dist/atlas/atlas-parser.d.ts +0 -52
  234. package/dist/atlas/atlas-parser.js +0 -109
  235. package/dist/atlas/atlas-parser.js.map +0 -1
  236. package/dist/atlas/atlas.d.ts +0 -12
  237. package/dist/atlas/atlas.js +0 -2
  238. package/dist/atlas/atlas.js.map +0 -1
  239. package/dist/audio/synth.d.ts +0 -4
  240. package/dist/audio/synth.js +0 -21
  241. package/dist/audio/synth.js.map +0 -1
  242. package/dist/graphics/bitmap.d.ts +0 -14
  243. package/dist/graphics/bitmap.js +0 -14
  244. package/dist/graphics/bitmap.js.map +0 -1
  245. package/dist/graphics/cam.d.ts +0 -16
  246. package/dist/graphics/cam.js +0 -42
  247. package/dist/graphics/cam.js.map +0 -1
  248. package/dist/graphics/frag.glsl.d.ts +0 -1
  249. package/dist/graphics/frag.glsl.js +0 -15
  250. package/dist/graphics/frag.glsl.js.map +0 -1
  251. package/dist/graphics/frame-listener.d.ts +0 -16
  252. package/dist/graphics/frame-listener.js +0 -83
  253. package/dist/graphics/frame-listener.js.map +0 -1
  254. package/dist/graphics/renderer.d.ts +0 -12
  255. package/dist/graphics/renderer.js +0 -185
  256. package/dist/graphics/renderer.js.map +0 -1
  257. package/dist/graphics/vert.glsl.d.ts +0 -1
  258. package/dist/graphics/vert.glsl.js +0 -46
  259. package/dist/graphics/vert.glsl.js.map +0 -1
  260. package/dist/index.d.ts +0 -31
  261. package/dist/index.js +0 -79
  262. package/dist/index.js.map +0 -1
  263. package/dist/input/gamepad-poller.d.ts +0 -8
  264. package/dist/input/gamepad-poller.js +0 -38
  265. package/dist/input/gamepad-poller.js.map +0 -1
  266. package/dist/input/input.d.ts +0 -44
  267. package/dist/input/input.js +0 -175
  268. package/dist/input/input.js.map +0 -1
  269. package/dist/input/keyboard-poller.d.ts +0 -7
  270. package/dist/input/keyboard-poller.js +0 -30
  271. package/dist/input/keyboard-poller.js.map +0 -1
  272. package/dist/input/pointer-poller.d.ts +0 -12
  273. package/dist/input/pointer-poller.js +0 -67
  274. package/dist/input/pointer-poller.js.map +0 -1
  275. package/dist/sprite/sprite.d.ts +0 -51
  276. package/dist/sprite/sprite.js +0 -161
  277. package/dist/sprite/sprite.js.map +0 -1
  278. package/dist/storage/json-storage.d.ts +0 -4
  279. package/dist/storage/json-storage.js +0 -13
  280. package/dist/storage/json-storage.js.map +0 -1
  281. package/dist/test/tsconfig.json +0 -14
  282. package/dist/text/font.d.ts +0 -6
  283. package/dist/text/font.js +0 -18
  284. package/dist/text/font.js.map +0 -1
  285. package/dist/text/text-layout.d.ts +0 -11
  286. package/dist/text/text-layout.js +0 -73
  287. package/dist/text/text-layout.js.map +0 -1
  288. package/dist/tsconfig.json +0 -13
  289. package/dist/types/2d.d.ts +0 -9
  290. package/dist/types/2d.js +0 -2
  291. package/dist/types/2d.js.map +0 -1
  292. package/dist/void.js +0 -60
  293. package/dist/void.js.map +0 -7
  294. package/dist/void.meta.json +0 -299
  295. package/tools/void.js +0 -143
@@ -0,0 +1,12 @@
1
+ export type Argv = {
2
+ /** all the arguments not starting with `--` before `--`. */
3
+ args: string[];
4
+ /** all options starting with `--` before `--` and their optional value. */
5
+ opts: Opts;
6
+ /** everything after `--`. */
7
+ posargs: string[];
8
+ };
9
+ /** string-string|bool map. Eg, `'--config'?: string; '--minify'?: string | true` */
10
+ export interface Opts {
11
+ }
12
+ export declare function Argv(argv: readonly string[]): Argv;
@@ -0,0 +1,19 @@
1
+ export function Argv(argv) {
2
+ const args = [];
3
+ const posargs = [];
4
+ const opts = {};
5
+ for (let i = 2; i < argv.length; i++) {
6
+ if (argv[i] === '--') {
7
+ posargs.push(...argv.slice(i + 1));
8
+ break;
9
+ }
10
+ if (argv[i].startsWith('--')) {
11
+ const [k, v] = argv[i].split(/=(.*)/).slice(0, 2);
12
+ opts[k] = v ?? true;
13
+ }
14
+ else
15
+ args.push(argv[i]);
16
+ }
17
+ return { args, opts, posargs };
18
+ }
19
+ //# sourceMappingURL=argv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv.js","sourceRoot":"","sources":["../../../tools/utils/argv.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,IAAI,CAAC,IAAuB;IAC1C,MAAM,IAAI,GAAG,EAAE,CAAA;IACf,MAAM,OAAO,GAAG,EAAE,CAAA;IAClB,MAAM,IAAI,GAAiC,EAAE,CAAA;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAClC,MAAK;QACP,CAAC;QACD,IAAI,IAAI,CAAC,CAAC,CAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAClD,IAAI,CAAC,CAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAA;QACtB,CAAC;;YAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAA;IAC5B,CAAC;IACD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function exec(exe: string, ...args: readonly [...string[], {
2
+ stdin?: string | undefined;
3
+ }] | readonly string[]): Promise<string>;
@@ -0,0 +1,15 @@
1
+ import { execFile } from 'node:child_process';
2
+ import util from 'node:util';
3
+ export async function exec(exe, ...args) {
4
+ const opts = (typeof args.at(-1) === 'object' ? args.at(-1) : undefined);
5
+ args = (opts ? args.slice(0, -1) : args);
6
+ const promise = util.promisify(execFile)(exe, args, {});
7
+ if (promise.child.stdin && opts?.stdin != null) {
8
+ promise.child.stdin.write(opts.stdin);
9
+ promise.child.stdin.end();
10
+ }
11
+ const { stdout, stderr } = await promise;
12
+ process.stderr.write(stderr);
13
+ return stdout;
14
+ }
15
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../tools/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,GAAW,EACX,GAAG,IAEkB;IAErB,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAE1D,CAAA;IACb,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAa,CAAA;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACvD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QAC/C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;IAC3B,CAAC;IACD,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM,OAAO,CAAA;IACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function globAll(glob: string): Promise<string[]>;
@@ -0,0 +1,13 @@
1
+ import fs from 'node:fs/promises';
2
+ export async function globAll(glob) {
3
+ const filenames = [];
4
+ try {
5
+ for await (const filename of fs.glob(glob))
6
+ filenames.push(filename);
7
+ }
8
+ catch (err) {
9
+ throw Error(`glob \`${glob}\` unreadable`, { cause: err });
10
+ }
11
+ return filenames;
12
+ }
13
+ //# sourceMappingURL=file-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-util.js","sourceRoot":"","sources":["../../../tools/utils/file-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAEjC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY;IACxC,MAAM,SAAS,GAAG,EAAE,CAAA;IACpB,IAAI,CAAC;QACH,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,UAAU,IAAI,eAAe,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAA;IAC1D,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function parseHTML(filename: string): Promise<Document>;
@@ -0,0 +1,10 @@
1
+ import { JSDOM } from 'jsdom';
2
+ export async function parseHTML(filename) {
3
+ try {
4
+ return (await JSDOM.fromFile(filename)).window.document;
5
+ }
6
+ catch (err) {
7
+ throw Error(`HTML ${filename} unparsable`, { cause: err });
8
+ }
9
+ }
10
+ //# sourceMappingURL=html-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-parser.js","sourceRoot":"","sources":["../../../tools/utils/html-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAE3B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAA;IACzD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,QAAQ,QAAQ,aAAa,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ declare module './utils/argv.ts' {
3
+ interface Opts {
4
+ '--config'?: string;
5
+ '--minify'?: true;
6
+ /** inline everything into a single HTML file output. */
7
+ '--one-file'?: true;
8
+ /**
9
+ * run development server on http://localhost:1234 and reload on code
10
+ * change.
11
+ */
12
+ '--watch'?: true;
13
+ }
14
+ }
15
+ export declare function build(args: readonly string[], env: {
16
+ readonly [name: string]: string | undefined;
17
+ }): Promise<void>;
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ // void.ts --config=<void.json> [--minify] [--one-file] [--watch]
3
+ // compiles images into an atlas and bundles an HTML entrypoint.
4
+ import path from 'node:path';
5
+ import packageJSON from '../package.json' with { type: 'json' };
6
+ import { parseConfigFile } from "../schema/config-file.js";
7
+ import { bundle } from "./bundle/bundle.js";
8
+ import { Config } from "./types/config.js";
9
+ import { Argv } from "./utils/argv.js";
10
+ import { exec } from "./utils/exec.js";
11
+ import { parseHTML } from "./utils/html-parser.js";
12
+ export async function build(args, env) {
13
+ const argv = Argv(args);
14
+ const configFile = await parseConfigFile(argv.opts['--config'] ?? 'void.json');
15
+ const config = Config(configFile, argv, env.npm_package_version);
16
+ const doc = await parseHTML(config.entry);
17
+ const srcFilenames = [
18
+ ...doc.querySelectorAll("script[type='module'][src$='.ts']")
19
+ ].map(el => path.resolve(path.dirname(config.entry), el.getAttribute('src')));
20
+ const voidVersion = {
21
+ hash: (await exec('git', 'rev-parse', '--short', 'HEAD')).trim(),
22
+ published: packageJSON.published,
23
+ // imported JSON doesn't treeshake. define as a constant.
24
+ version: packageJSON.version
25
+ };
26
+ await bundle(config, srcFilenames, voidVersion);
27
+ }
28
+ if (import.meta.main)
29
+ await build(process.argv, process.env);
30
+ //# sourceMappingURL=void.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"void.js","sourceRoot":"","sources":["../../tools/void.ts"],"names":[],"mappings":";AACA,iEAAiE;AACjE,gEAAgE;AAEhE,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAgBhD,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,IAAuB,EACvB,GAAkD;IAElD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,WAAW,CAAC,CAAA;IAC9E,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAEhE,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG;QACnB,GAAG,GAAG,CAAC,gBAAgB,CACrB,mCAAmC,CACpC;KACF,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC,CAAC,CAAA;IAE9E,MAAM,WAAW,GAAgB;QAC/B,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;QAChE,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,yDAAyD;QACzD,OAAO,EAAE,WAAW,CAAC,OAAO;KAC7B,CAAA;IAED,MAAM,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;AACjD,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI;IAAE,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,72 +1,66 @@
1
1
  {
2
2
  "author": "Stephen Niedzielski <stephen@oidoid.com> (https://oidoid.com)",
3
3
  "bin": {
4
- "void": "tools/void.js"
4
+ "void": "tools/void.ts"
5
5
  },
6
6
  "bugs": "https://github.com/oidoid/void/issues",
7
- "description": "Tiny 2D game engine.",
7
+ "dependencies": {
8
+ "@biomejs/biome": "2.2.6",
9
+ "esbuild": "0.25.11",
10
+ "html-minifier-next": "3.0.0",
11
+ "jsdom": "27.0.1",
12
+ "mem-font": "11.0.0-6"
13
+ },
14
+ "description": "basic 2D game library.",
8
15
  "devDependencies": {
9
- "@ampproject/filesize": "4.3.0",
10
- "@types/jsdom": "21.1.6",
11
- "@types/node": "20.11.30",
12
- "esbuild": "0.20.2",
13
- "jsdom": "24.0.0",
14
- "mem-font": "11.0.0-2",
15
- "prettier": "3.2.5",
16
- "typescript": "5.4.3",
17
- "vitest": "1.4.0"
16
+ "@types/html-minifier-next": "2.1.0",
17
+ "@types/jsdom": "27.0.0",
18
+ "@types/node": "24.4.0",
19
+ "typescript": "5.9.3"
18
20
  },
19
21
  "engines": {
20
- "node": ">=18"
22
+ "node": ">=24.0"
23
+ },
24
+ "exports": {
25
+ ".": "./dist/index.js"
21
26
  },
22
27
  "files": [
23
28
  "dist",
24
- "!dist/**/tsconfig.tsbuildinfo"
29
+ "schema",
30
+ "tools",
31
+ "!tools/tsconfig*",
32
+ "!**/tsconfig.tsbuildinfo"
25
33
  ],
26
- "filesize": {
27
- "dist/void.js": {
28
- "none": "16.7 KB",
29
- "gzip": "6.3 KB"
30
- }
31
- },
32
34
  "homepage": "https://github.com/oidoid/void",
33
35
  "keywords": [
34
36
  "game engine",
35
37
  "webgl"
36
38
  ],
37
39
  "license": "AGPL-3.0-only",
38
- "main": "dist/index.js",
39
40
  "name": "@oidoid/void",
40
- "prettier": {
41
- "arrowParens": "avoid",
42
- "bracketSpacing": false,
43
- "jsxSingleQuote": true,
44
- "proseWrap": "always",
45
- "semi": false,
46
- "singleQuote": true,
47
- "trailingComma": "none"
48
- },
49
41
  "publishConfig": {
50
42
  "access": "public"
51
43
  },
44
+ "published": "20251020",
52
45
  "repository": {
53
46
  "type": "git",
54
47
  "url": "git+https://github.com/oidoid/void.git"
55
48
  },
56
49
  "scripts": {
57
- "build": "tsc --build",
50
+ "build": "tsc --build && npm run build:favicon && npm run build:demo -- --minify --one-file",
51
+ "build:favicon": "for s in 1 2 3 4 12 32; do f=dist/public/favicon/favicon$(($s * 16)).png; aseprite src/demo/assets/favicon.aseprite --batch --color-mode=indexed --scale=$s --save-as=$f; zopflipng -y $f $f > /dev/null; done",
52
+ "build:demo": "tools/void.ts --config=src/demo/void.json",
58
53
  "clean": "rm -rf dist",
59
- "format": "npm run formatter -- --write",
60
- "formatter": "prettier --cache --log-level warn './**/*.{js,json,md,ts,yaml}'",
54
+ "format": "npm run formatter -- --fix",
55
+ "formatter": "biome check --error-on-warnings",
61
56
  "preversion": "[ -z \"$(git status -z)\" ]",
62
57
  "prepublishOnly": "! git symbolic-ref --quiet HEAD || git push --follow-tags origin \"$(git branch --show-current)\"",
63
- "test": "npm run test:format && npm run test:unit && npm run build && npm run test:size",
64
- "test:format": "npm run formatter -- --check",
65
- "test:size": "npx esbuild --bundle --format=esm --metafile=dist/void.meta.json --minify --outfile=dist/void.js --sourcemap=linked --target=es2022 src/index.ts && filesize",
66
- "test:unit": "vitest --config=tools/vitest.config.ts run",
67
- "version": "npm test"
58
+ "start": "tsc --build --preserveWatchOutput --watch& npm run build:favicon && npm run build:demo -- --watch& wait",
59
+ "test": "npm run test:format && npm run test:unit && npm run build",
60
+ "test:format": "npm run formatter",
61
+ "test:unit": "sh -c 'node --experimental-test-coverage --test ${@:-$(find src schema tools -name \\*.test.ts -printf %p\\ )}' --",
62
+ "version": "npm pkg set published=$(date +%Y%m%d) && npm test"
68
63
  },
69
64
  "type": "module",
70
- "types": "dist/index.d.ts",
71
- "version": "0.1.0-3"
65
+ "version": "0.1.0-6"
72
66
  }
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # void
2
2
 
3
- All of my free time goes into void.
3
+ basic 2D game library.
4
4
 
5
5
  ## Installation
6
6
 
@@ -0,0 +1,55 @@
1
+ import assert from 'node:assert/strict'
2
+ import {test} from 'node:test'
3
+ import {type ConfigFile, type ConfigFileSchema, parse} from './config-file.ts'
4
+
5
+ test('defaults', () => {
6
+ const config: ConfigFileSchema = {}
7
+ assert.deepEqual<ConfigFile>(
8
+ parse('dirname/filename', JSON.stringify(config)),
9
+ {
10
+ $schema:
11
+ 'https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json',
12
+ entry: 'dirname/src/assets/index.html',
13
+ meta: 'dirname/dist/meta.json',
14
+ out: {dir: 'dirname/dist/public/', name: undefined},
15
+ preloadAtlas: undefined,
16
+
17
+ dirname: 'dirname',
18
+ filename: 'dirname/filename'
19
+ }
20
+ )
21
+ })
22
+
23
+ test('overrides', () => {
24
+ const config: Required<ConfigFileSchema> = {
25
+ $schema: '$schema',
26
+ entry: 'entry',
27
+ meta: 'meta',
28
+ out: {dir: 'outDir', name: 'name'},
29
+ preloadAtlas: {dir: 'dir/', image: 'image.png', json: 'json.json'}
30
+ }
31
+ assert.deepEqual<ConfigFile>(
32
+ parse('dirname/filename', JSON.stringify(config)),
33
+ {
34
+ $schema: '$schema',
35
+ entry: 'dirname/entry',
36
+ meta: 'dirname/meta',
37
+ out: {dir: 'dirname/outDir', name: 'name'},
38
+ preloadAtlas: {
39
+ dir: 'dirname/dir/',
40
+ image: 'dirname/image.png',
41
+ json: 'dirname/json.json'
42
+ },
43
+
44
+ dirname: 'dirname',
45
+ filename: 'dirname/filename'
46
+ }
47
+ )
48
+ })
49
+
50
+ test('overrides', () => {
51
+ assert.throws(
52
+ () => parse('dirname/filename', ''),
53
+ Error('config dirname/filename unparsable')
54
+ )
55
+ })
@@ -0,0 +1,69 @@
1
+ import {readFile} from 'node:fs/promises'
2
+ import path from 'node:path'
3
+ import schema from './config-file.v0.json' with {type: 'json'}
4
+
5
+ export type AtlasConfig = {dir: string; image: string; json: string}
6
+
7
+ export type ConfigFile = {
8
+ $schema: string
9
+ entry: string
10
+ meta: string | undefined
11
+ out: {dir: string; name: string | undefined}
12
+ preloadAtlas: AtlasConfig | undefined
13
+
14
+ /** config directory name. */
15
+ dirname: string
16
+ /** config filename. */
17
+ filename: string
18
+ }
19
+
20
+ export type ConfigFileSchema = {
21
+ $schema?: string | undefined
22
+ entry?: string | undefined
23
+ meta?: string | undefined
24
+ out?: {dir?: string | undefined; name?: string | undefined} | undefined
25
+ preloadAtlas?: AtlasConfig | undefined
26
+ }
27
+
28
+ export async function parseConfigFile(filename: string): Promise<ConfigFile> {
29
+ let str
30
+ try {
31
+ str = await readFile(filename, 'utf8')
32
+ } catch (err) {
33
+ throw Error(`config ${filename} unreadable`, {cause: err})
34
+ }
35
+
36
+ return parse(filename, str)
37
+ }
38
+
39
+ /** @internal */
40
+ export function parse(filename: string, str: string): ConfigFile {
41
+ const dirname = path.dirname(filename)
42
+ let json: ConfigFileSchema
43
+ try {
44
+ json = JSON.parse(str)
45
+ } catch (err) {
46
+ throw Error(`config ${filename} unparsable`, {cause: err})
47
+ }
48
+
49
+ return {
50
+ $schema: json.$schema ?? schema.properties.$schema.default,
51
+ entry: path.join(dirname, json.entry ?? schema.properties.entry.default),
52
+ meta: path.join(dirname, json.meta ?? schema.properties.meta.default),
53
+ out: {
54
+ dir: path.join(
55
+ dirname,
56
+ json.out?.dir ?? schema.properties.out.properties.dir.default
57
+ ),
58
+ name: json.out?.name
59
+ },
60
+ preloadAtlas: json.preloadAtlas && {
61
+ dir: path.join(dirname, json.preloadAtlas.dir),
62
+ image: path.join(dirname, json.preloadAtlas.image),
63
+ json: path.join(dirname, json.preloadAtlas.json)
64
+ },
65
+
66
+ dirname,
67
+ filename
68
+ }
69
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json",
4
+ "title": "void Config File Schema",
5
+ "type": "object",
6
+ "description": "a JSON representation of a void config file.",
7
+ "$defs": {
8
+ "Atlas": {
9
+ "type": "object",
10
+ "description": "sprite sheet config.",
11
+ "additionalProperties": false,
12
+ "required": ["dir", "image", "json"],
13
+ "properties": {
14
+ "dir": {
15
+ "type": "string",
16
+ "description": "Aseprite asset root directory. all `**.aseprite` files are input.",
17
+ "examples": ["src/assets/atlas/", "./"]
18
+ },
19
+ "image": {
20
+ "type": "string",
21
+ "description": "sprite sheet image output.",
22
+ "examples": ["dist/public/atlas.png", "atlas.png"]
23
+ },
24
+ "json": {
25
+ "type": "string",
26
+ "description": "sprite sheet JSON output.",
27
+ "examples": ["src/assets/atlas.json", "atlas.json"]
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "additionalProperties": false,
33
+ "properties": {
34
+ "$schema": {
35
+ "type": "string",
36
+ "description": "the configuration schema URI.",
37
+ "default": "https://raw.githubusercontent.com/oidoid/void/refs/heads/main/schema/config-file.v0.json"
38
+ },
39
+ "entry": {
40
+ "type": "string",
41
+ "default": "src/assets/index.html",
42
+ "description": "HTML entrypoint input. the file should include a script tag sourcing the TypeScript / JavaScript entrypoint."
43
+ },
44
+ "meta": {
45
+ "type": "string",
46
+ "default": "dist/meta.json",
47
+ "description": "esbuild bundle metadata file output."
48
+ },
49
+ "out": {
50
+ "type": "object",
51
+ "description": "output config.",
52
+ "additionalProperties": false,
53
+ "properties": {
54
+ "dir": {
55
+ "type": "string",
56
+ "description": "HTML and JavaScript output directory.",
57
+ "default": "dist/public/"
58
+ },
59
+ "name": {
60
+ "type": "string",
61
+ "description": "HTML output file stem when watch is disabled. defaults to entry.",
62
+ "examples": ["index", "super-patience"]
63
+ }
64
+ }
65
+ },
66
+ "preloadAtlas": {"$ref": "#/$defs/Atlas"}
67
+ }
68
+ }
@@ -0,0 +1,60 @@
1
+ import type {TagFormat} from '../../src/graphics/atlas.ts'
2
+ import type {Box, WH} from '../../src/types/geo.ts'
3
+
4
+ /** https://github.com/aseprite/aseprite/blob/master/docs/ase-file-specs.md */
5
+ export type Aseprite = {meta: AsepriteMeta; frames: AsepriteFrameMap}
6
+
7
+ export type AsepriteFrameMap = {[tag: AsepriteFrameTag]: AsepriteFrame}
8
+
9
+ export type AsepriteMeta = {
10
+ /** `--list-tags`. */
11
+ frameTags: AsepriteTagSpan[]
12
+ size: WH
13
+ /** `--list-slices`. */
14
+ slices: AsepriteSlice[]
15
+ }
16
+
17
+ /** `--filename-format='{title}--{tag}--{frame}'`. */
18
+ export type AsepriteFrameTag = `${TagFormat}--${bigint}`
19
+
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
+
29
+ export type AsepriteTagSpan = {
30
+ direction: AsepriteDirection | string
31
+ name: TagFormat | string
32
+ from: number
33
+ /** inclusive ending index, possibly equal to from. */
34
+ to: number
35
+ }
36
+
37
+ export type AsepriteSlice = {
38
+ /** '#ff0000ff' is hitbox, '#00ff00ff' is hurtbox, '#0000ffff is both. */
39
+ color: string
40
+ name: TagFormat | string
41
+ keys: {bounds: Box}[]
42
+ }
43
+
44
+ export type AsepriteDirection =
45
+ (typeof AsepriteDirection)[keyof typeof AsepriteDirection]
46
+ export const AsepriteDirection = {
47
+ /** animate from start to end; when looping, return to start. */
48
+ Forward: 'forward',
49
+ /** animate from end to start; when looping, return to end. */
50
+ Reverse: 'reverse',
51
+ /**
52
+ * animate from start to end - 1 or start, whichever is greater; when
53
+ * looping, change direction (initially, end to start + 1 or end, whichever
54
+ * is lesser. a traversal from start to end - 1 then end to start + 1 is
55
+ * considered a complete loop.
56
+ */
57
+ PingPong: 'pingpong',
58
+ /** like pingpong but start from end - 1 or start, whichever is greater. */
59
+ PingPongReverse: 'pingpong_reverse'
60
+ } as const