@oidoid/void 0.1.0-7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/index.js +19 -15
- package/dist/public/index.js.map +4 -4
- package/dist/public/preload-atlas.webp +0 -0
- package/dist/public/void-v0.1.0+20251227.1060661.html +115 -0
- package/dist/schema/config-file.v0.json +86 -15
- package/dist/schema/level-file.v0.json +423 -0
- package/dist/src/audio.d.ts +1 -0
- package/dist/src/audio.d.ts.map +1 -0
- package/dist/src/demo/assets/manifest.json +2 -2
- package/dist/src/demo/assets/void.game.json +202 -0
- package/dist/src/demo/ents/cam.d.ts +6 -0
- package/dist/src/demo/ents/cam.d.ts.map +1 -0
- package/dist/src/demo/ents/cam.js +21 -0
- package/dist/src/demo/ents/cam.js.map +1 -0
- package/dist/src/demo/ents/clock.d.ts +10 -0
- package/dist/src/demo/ents/clock.d.ts.map +1 -0
- package/dist/src/demo/ents/clock.js +16 -0
- package/dist/src/demo/ents/clock.js.map +1 -0
- package/dist/src/demo/ents/draw.d.ts +6 -0
- package/dist/src/demo/ents/draw.d.ts.map +1 -0
- package/dist/src/demo/ents/draw.js +14 -0
- package/dist/src/demo/ents/draw.js.map +1 -0
- package/dist/src/demo/ents/ent.d.ts +6 -0
- package/dist/src/demo/ents/ent.d.ts.map +1 -0
- package/dist/src/demo/ents/ent.js +2 -0
- package/dist/src/demo/ents/ent.js.map +1 -0
- package/dist/src/demo/ents/loader.d.ts +6 -0
- package/dist/src/demo/ents/loader.d.ts.map +1 -0
- package/dist/src/demo/ents/loader.js +45 -0
- package/dist/src/demo/ents/loader.js.map +1 -0
- package/dist/src/demo/ents/render-toggle.d.ts +7 -0
- package/dist/src/demo/ents/render-toggle.d.ts.map +1 -0
- package/dist/src/demo/ents/render-toggle.js +8 -0
- package/dist/src/demo/ents/render-toggle.js.map +1 -0
- package/dist/src/demo/ents/tally.d.ts +8 -0
- package/dist/src/demo/ents/tally.d.ts.map +1 -0
- package/dist/src/demo/ents/tally.js +14 -0
- package/dist/src/demo/ents/tally.js.map +1 -0
- package/dist/src/demo/index.d.ts +1 -0
- package/dist/src/demo/index.d.ts.map +1 -0
- package/dist/src/demo/index.js +12 -3
- package/dist/src/demo/index.js.map +1 -1
- package/dist/src/demo/level/level-file.json +50 -0
- package/dist/src/demo/level/level-parser.d.ts +5 -0
- package/dist/src/demo/level/level-parser.d.ts.map +1 -0
- package/dist/src/demo/level/level-parser.js +21 -0
- package/dist/src/demo/level/level-parser.js.map +1 -0
- package/dist/src/demo/level/level-schema.d.ts +4 -0
- package/dist/src/demo/level/level-schema.d.ts.map +1 -0
- package/dist/src/demo/level/level-schema.js +2 -0
- package/dist/src/demo/level/level-schema.js.map +1 -0
- package/dist/src/demo/types/decl.d.ts +30 -0
- package/dist/src/demo/types/decl.d.ts.map +1 -0
- package/dist/src/demo/types/decl.js +2 -0
- package/dist/src/demo/types/decl.js.map +1 -0
- package/dist/src/demo/void.json +8 -4
- package/dist/src/ents/button.d.ts +14 -0
- package/dist/src/ents/button.d.ts.map +1 -0
- package/dist/src/ents/button.js +59 -0
- package/dist/src/ents/button.js.map +1 -0
- package/dist/src/ents/cam.d.ts +3 -0
- package/dist/src/ents/cam.d.ts.map +1 -0
- package/dist/src/ents/cam.js +2 -0
- package/dist/src/ents/cam.js.map +1 -0
- package/dist/src/ents/cursor.d.ts +20 -0
- package/dist/src/ents/cursor.d.ts.map +1 -0
- package/dist/src/ents/cursor.js +49 -0
- package/dist/src/ents/cursor.js.map +1 -0
- package/dist/src/ents/debug-input.d.ts +8 -0
- package/dist/src/ents/debug-input.d.ts.map +1 -0
- package/dist/src/ents/debug-input.js +25 -0
- package/dist/src/ents/debug-input.js.map +1 -0
- package/dist/src/ents/draw.d.ts +3 -0
- package/dist/src/ents/draw.d.ts.map +1 -0
- package/dist/src/ents/draw.js +2 -0
- package/dist/src/ents/draw.js.map +1 -0
- package/dist/src/ents/ent-query.d.ts +26 -0
- package/dist/src/ents/ent-query.d.ts.map +1 -0
- package/dist/src/ents/ent-query.js +10 -0
- package/dist/src/ents/ent-query.js.map +1 -0
- package/dist/src/ents/ent.d.ts +92 -6
- package/dist/src/ents/ent.d.ts.map +1 -0
- package/dist/src/ents/fps.d.ts +7 -0
- package/dist/src/ents/fps.d.ts.map +1 -0
- package/dist/src/ents/fps.js +14 -0
- package/dist/src/ents/fps.js.map +1 -0
- package/dist/src/ents/hud.d.ts +14 -0
- package/dist/src/ents/hud.d.ts.map +1 -0
- package/dist/src/ents/hud.js +38 -0
- package/dist/src/ents/hud.js.map +1 -0
- package/dist/src/ents/loader.d.ts +3 -0
- package/dist/src/ents/loader.d.ts.map +1 -0
- package/dist/src/ents/loader.js +2 -0
- package/dist/src/ents/loader.js.map +1 -0
- package/dist/src/ents/nine-patch.d.ts +17 -0
- package/dist/src/ents/nine-patch.d.ts.map +1 -0
- package/dist/src/ents/nine-patch.js +99 -0
- package/dist/src/ents/nine-patch.js.map +1 -0
- package/dist/src/ents/override.d.ts +8 -0
- package/dist/src/ents/override.d.ts.map +1 -0
- package/dist/src/ents/override.js +8 -0
- package/dist/src/ents/override.js.map +1 -0
- package/dist/src/ents/sprite.d.ts +8 -0
- package/dist/src/ents/sprite.d.ts.map +1 -0
- package/dist/src/ents/sprite.js +10 -0
- package/dist/src/ents/sprite.js.map +1 -0
- package/dist/src/ents/sys.d.ts +14 -0
- package/dist/src/ents/sys.d.ts.map +1 -0
- package/dist/src/ents/sys.js +2 -0
- package/dist/src/ents/sys.js.map +1 -0
- package/dist/src/ents/text.d.ts +21 -0
- package/dist/src/ents/text.d.ts.map +1 -0
- package/dist/src/ents/text.js +118 -0
- package/dist/src/ents/text.js.map +1 -0
- package/dist/src/ents/zoo.d.ts +18 -11
- package/dist/src/ents/zoo.d.ts.map +1 -0
- package/dist/src/ents/zoo.js +75 -15
- package/dist/src/ents/zoo.js.map +1 -1
- package/dist/src/graphics/atlas-parser.d.ts +3 -1
- package/dist/src/graphics/atlas-parser.d.ts.map +1 -0
- package/dist/src/graphics/atlas-parser.js.map +1 -1
- package/dist/src/graphics/atlas.d.ts +9 -15
- package/dist/src/graphics/atlas.d.ts.map +1 -0
- package/dist/src/graphics/cam.d.ts +13 -10
- package/dist/src/graphics/cam.d.ts.map +1 -0
- package/dist/src/graphics/cam.js +23 -17
- package/dist/src/graphics/cam.js.map +1 -1
- package/dist/src/graphics/gl.d.ts +1 -8
- package/dist/src/graphics/gl.d.ts.map +1 -0
- package/dist/src/graphics/gl.js +0 -1
- package/dist/src/graphics/gl.js.map +1 -1
- package/dist/src/graphics/layer.d.ts +21 -17
- package/dist/src/graphics/layer.d.ts.map +1 -0
- package/dist/src/graphics/layer.js +23 -18
- package/dist/src/graphics/layer.js.map +1 -1
- package/dist/src/graphics/pixel-ratio-observer.d.ts +8 -0
- package/dist/src/graphics/pixel-ratio-observer.d.ts.map +1 -0
- package/dist/src/graphics/pixel-ratio-observer.js +23 -0
- package/dist/src/graphics/pixel-ratio-observer.js.map +1 -0
- package/dist/src/graphics/render-mode.d.ts +2 -0
- package/dist/src/graphics/render-mode.d.ts.map +1 -0
- package/dist/src/graphics/render-mode.js +2 -0
- package/dist/src/graphics/render-mode.js.map +1 -0
- package/dist/src/graphics/renderer.d.ts +9 -4
- package/dist/src/graphics/renderer.d.ts.map +1 -0
- package/dist/src/graphics/renderer.js +30 -13
- package/dist/src/graphics/renderer.js.map +1 -1
- package/dist/src/graphics/sprite-frag.glsl.d.ts +1 -0
- package/dist/src/graphics/sprite-frag.glsl.d.ts.map +1 -0
- package/dist/src/graphics/sprite-frag.glsl.js +3 -4
- package/dist/src/graphics/sprite-frag.glsl.js.map +1 -1
- package/dist/src/graphics/sprite-vert.glsl.d.ts +1 -0
- package/dist/src/graphics/sprite-vert.glsl.d.ts.map +1 -0
- package/dist/src/graphics/sprite-vert.glsl.js +9 -7
- package/dist/src/graphics/sprite-vert.glsl.js.map +1 -1
- package/dist/src/graphics/sprite.d.ts +54 -16
- package/dist/src/graphics/sprite.d.ts.map +1 -0
- package/dist/src/graphics/sprite.js +109 -32
- package/dist/src/graphics/sprite.js.map +1 -1
- package/dist/src/index.d.ts +31 -6
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +33 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/input/context-menu.d.ts +1 -1
- package/dist/src/input/context-menu.d.ts.map +1 -0
- package/dist/src/input/context-menu.js +0 -1
- package/dist/src/input/context-menu.js.map +1 -1
- package/dist/src/input/gamepad.d.ts +1 -1
- package/dist/src/input/gamepad.d.ts.map +1 -0
- package/dist/src/input/gamepad.js +0 -1
- package/dist/src/input/gamepad.js.map +1 -1
- package/dist/src/input/input.d.ts +30 -23
- package/dist/src/input/input.d.ts.map +1 -0
- package/dist/src/input/input.js +53 -31
- package/dist/src/input/input.js.map +1 -1
- package/dist/src/input/keyboard.d.ts +1 -0
- package/dist/src/input/keyboard.d.ts.map +1 -0
- package/dist/src/input/pointer.d.ts +1 -0
- package/dist/src/input/pointer.d.ts.map +1 -0
- package/dist/src/input/pointer.js +11 -8
- package/dist/src/input/pointer.js.map +1 -1
- package/dist/src/input/wheel.d.ts +6 -1
- package/dist/src/input/wheel.d.ts.map +1 -0
- package/dist/src/input/wheel.js +5 -1
- package/dist/src/input/wheel.js.map +1 -1
- package/dist/src/level/level-parser.d.ts +26 -0
- package/dist/src/level/level-parser.d.ts.map +1 -0
- package/dist/src/level/level-parser.js +258 -0
- package/dist/src/level/level-parser.js.map +1 -0
- package/dist/src/level/level-schema-json.d.ts +5 -0
- package/dist/src/level/level-schema-json.d.ts.map +1 -0
- package/dist/src/level/level-schema-json.js +2 -0
- package/dist/src/level/level-schema-json.js.map +1 -0
- package/dist/src/level/level-schema.d.ts +87 -0
- package/dist/src/level/level-schema.d.ts.map +1 -0
- package/dist/src/level/level-schema.js +2 -0
- package/dist/src/level/level-schema.js.map +1 -0
- package/dist/src/level/level.d.ts +8 -0
- package/dist/src/level/level.d.ts.map +1 -0
- package/dist/src/level/level.js +2 -0
- package/dist/src/level/level.js.map +1 -0
- package/dist/src/looper.d.ts +1 -0
- package/dist/src/looper.d.ts.map +1 -0
- package/dist/src/looper.js +5 -2
- package/dist/src/looper.js.map +1 -1
- package/dist/src/mem/pool-map.d.ts +6 -0
- package/dist/src/mem/pool-map.d.ts.map +1 -0
- package/dist/src/mem/pool-map.js +2 -0
- package/dist/src/mem/pool-map.js.map +1 -0
- package/dist/src/mem/pool.d.ts +5 -1
- package/dist/src/mem/pool.d.ts.map +1 -0
- package/dist/src/mem/pool.js +22 -21
- package/dist/src/mem/pool.js.map +1 -1
- package/dist/src/mem/sprite-pool.d.ts +12 -0
- package/dist/src/mem/sprite-pool.d.ts.map +1 -0
- package/dist/src/mem/sprite-pool.js +11 -0
- package/dist/src/mem/sprite-pool.js.map +1 -0
- package/dist/src/random/random.d.ts +1 -0
- package/dist/src/random/random.d.ts.map +1 -0
- package/dist/src/storage/local-storage.d.ts +2 -1
- package/dist/src/storage/local-storage.d.ts.map +1 -0
- package/dist/src/storage/local-storage.js.map +1 -1
- package/dist/src/text/font.d.ts +5 -3
- package/dist/src/text/font.d.ts.map +1 -0
- package/dist/src/text/font.js +8 -5
- package/dist/src/text/font.js.map +1 -1
- package/dist/src/text/mem-prop-5x6.json +20 -5
- package/dist/src/text/text-layout.d.ts +16 -5
- package/dist/src/text/text-layout.d.ts.map +1 -0
- package/dist/src/text/text-layout.js +46 -28
- package/dist/src/text/text-layout.js.map +1 -1
- package/dist/src/types/bundle.d.ts +10 -0
- package/dist/src/types/bundle.d.ts.map +1 -0
- package/dist/src/types/bundle.js +2 -0
- package/dist/src/types/bundle.js.map +1 -0
- package/dist/src/types/game-config.d.ts +27 -0
- package/dist/src/types/game-config.d.ts.map +1 -0
- package/dist/src/types/game-config.js +2 -0
- package/dist/src/types/game-config.js.map +1 -0
- package/dist/src/types/geo.d.ts +9 -2
- package/dist/src/types/geo.d.ts.map +1 -0
- package/dist/src/types/geo.js +16 -0
- package/dist/src/types/geo.js.map +1 -1
- package/dist/src/types/json.d.ts +1 -0
- package/dist/src/types/json.d.ts.map +1 -0
- package/dist/src/types/time.d.ts +13 -2
- package/dist/src/types/time.d.ts.map +1 -0
- package/dist/src/types/time.js +10 -0
- package/dist/src/types/time.js.map +1 -1
- package/dist/src/utils/async-util.d.ts +1 -0
- package/dist/src/utils/async-util.d.ts.map +1 -0
- package/dist/src/utils/async-util.js +2 -0
- package/dist/src/utils/async-util.js.map +1 -1
- package/dist/src/utils/canvas-util.d.ts +3 -1
- package/dist/src/utils/canvas-util.d.ts.map +1 -0
- package/dist/src/utils/canvas-util.js +7 -3
- package/dist/src/utils/canvas-util.js.map +1 -1
- package/dist/src/utils/color-util.d.ts +6 -0
- package/dist/src/utils/color-util.d.ts.map +1 -0
- package/dist/src/utils/color-util.js +12 -0
- package/dist/src/utils/color-util.js.map +1 -1
- package/dist/src/utils/debug.d.ts +1 -0
- package/dist/src/utils/debug.d.ts.map +1 -0
- package/dist/src/utils/debug.js +4 -4
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/delay-interval.d.ts +1 -0
- package/dist/src/utils/delay-interval.d.ts.map +1 -0
- package/dist/src/utils/dom-util.d.ts +3 -2
- package/dist/src/utils/dom-util.d.ts.map +1 -0
- package/dist/src/utils/dom-util.js +16 -12
- package/dist/src/utils/dom-util.js.map +1 -1
- package/dist/src/utils/fetch-util.d.ts +2 -1
- package/dist/src/utils/fetch-util.d.ts.map +1 -0
- package/dist/src/utils/fetch-util.js +2 -2
- package/dist/src/utils/math.d.ts +1 -0
- package/dist/src/utils/math.d.ts.map +1 -0
- package/dist/src/utils/math.js +1 -1
- package/dist/src/utils/math.js.map +1 -1
- package/dist/src/utils/obj-util.d.ts +7 -0
- package/dist/src/utils/obj-util.d.ts.map +1 -0
- package/dist/src/utils/obj-util.js +8 -0
- package/dist/src/utils/obj-util.js.map +1 -0
- package/dist/src/utils/str-util.d.ts +2 -0
- package/dist/src/utils/str-util.d.ts.map +1 -0
- package/dist/src/utils/str-util.js +6 -0
- package/dist/src/utils/str-util.js.map +1 -0
- package/dist/src/utils/vibrate.d.ts +1 -0
- package/dist/src/utils/vibrate.d.ts.map +1 -0
- package/dist/src/void.d.ts +42 -30
- package/dist/src/void.d.ts.map +1 -0
- package/dist/src/void.js +78 -34
- package/dist/src/void.js.map +1 -1
- package/dist/tools/atlas-pack/aseprite-json.d.ts +5 -0
- package/dist/tools/atlas-pack/aseprite-json.d.ts.map +1 -0
- package/dist/tools/atlas-pack/aseprite-json.js +2 -0
- package/dist/tools/atlas-pack/aseprite-json.js.map +1 -0
- package/dist/tools/atlas-pack/aseprite.d.ts +58 -31
- package/dist/tools/atlas-pack/aseprite.d.ts.map +1 -0
- package/dist/tools/atlas-pack/aseprite.js +1 -1
- package/dist/tools/atlas-pack/aseprite.js.map +1 -1
- package/dist/tools/atlas-pack/atlas-json-parser.d.ts +11 -10
- package/dist/tools/atlas-pack/atlas-json-parser.d.ts.map +1 -0
- package/dist/tools/atlas-pack/atlas-json-parser.js +14 -14
- package/dist/tools/atlas-pack/atlas-json-parser.js.map +1 -1
- package/dist/tools/atlas-pack/atlas-pack.d.ts +4 -2
- package/dist/tools/atlas-pack/atlas-pack.d.ts.map +1 -0
- package/dist/tools/atlas-pack/atlas-pack.js +1 -6
- package/dist/tools/atlas-pack/atlas-pack.js.map +1 -1
- package/dist/tools/bundle/bundle.d.ts +3 -3
- package/dist/tools/bundle/bundle.d.ts.map +1 -0
- package/dist/tools/bundle/bundle.js +32 -7
- package/dist/tools/bundle/bundle.js.map +1 -1
- package/dist/tools/bundle/html-plugin.d.ts +1 -0
- package/dist/tools/bundle/html-plugin.d.ts.map +1 -0
- package/dist/tools/bundle/html-plugin.js +5 -20
- package/dist/tools/bundle/html-plugin.js.map +1 -1
- package/dist/tools/tsconfig-base.json +1 -1
- package/dist/tools/tsconfig.json +1 -2
- package/dist/{schema → tools/types}/config-file.d.ts +21 -9
- package/dist/tools/types/config-file.d.ts.map +1 -0
- package/dist/{schema → tools/types}/config-file.js +18 -5
- package/dist/tools/types/config-file.js.map +1 -0
- package/dist/tools/types/config.d.ts +10 -9
- package/dist/tools/types/config.d.ts.map +1 -0
- package/dist/tools/types/config.js +23 -5
- package/dist/tools/types/config.js.map +1 -1
- package/dist/tools/types/package-json.d.ts +3 -2
- package/dist/tools/types/package-json.d.ts.map +1 -0
- package/dist/tools/utils/argv.d.ts +3 -0
- package/dist/tools/utils/argv.d.ts.map +1 -0
- package/dist/tools/utils/argv.js +1 -1
- package/dist/tools/utils/argv.js.map +1 -1
- package/dist/tools/utils/exec.d.ts +2 -1
- package/dist/tools/utils/exec.d.ts.map +1 -0
- package/dist/tools/utils/exec.js.map +1 -1
- package/dist/tools/utils/file-util.d.ts +1 -0
- package/dist/tools/utils/file-util.d.ts.map +1 -0
- package/dist/tools/utils/html-parser.d.ts +1 -0
- package/dist/tools/utils/html-parser.d.ts.map +1 -0
- package/dist/tools/void.d.ts +1 -0
- package/dist/tools/void.d.ts.map +1 -0
- package/dist/tools/void.js +3 -16
- package/dist/tools/void.js.map +1 -1
- package/package.json +18 -20
- package/readme.md +63 -1
- package/dist/meta.json +0 -1
- package/dist/package.json +0 -66
- package/dist/public/favicon/favicon16.png +0 -0
- package/dist/public/favicon/favicon192.png +0 -0
- package/dist/public/favicon/favicon32.png +0 -0
- package/dist/public/favicon/favicon48.png +0 -0
- package/dist/public/favicon/favicon64.png +0 -0
- package/dist/public/preload-atlas.png +0 -0
- package/dist/public/void-v0.1.0-6+20251020.7cdf98d.html +0 -111
- package/dist/public/void-v0.1.0-6+20251020.e4e9eef.html +0 -111
- package/dist/public/void-v0.1.0-7+20251021.7cdf98d.html +0 -111
- package/dist/schema/config-file.js.map +0 -1
- package/dist/src/demo/assets/preload-atlas.json +0 -193
- package/dist/src/demo/ents/clock-ent.d.ts +0 -11
- package/dist/src/demo/ents/clock-ent.js +0 -26
- package/dist/src/demo/ents/clock-ent.js.map +0 -1
- package/dist/src/demo/ents/render-toggle-ent.d.ts +0 -12
- package/dist/src/demo/ents/render-toggle-ent.js +0 -41
- package/dist/src/demo/ents/render-toggle-ent.js.map +0 -1
- package/dist/src/demo/ents/work-counter-ent.d.ts +0 -10
- package/dist/src/demo/ents/work-counter-ent.js +0 -20
- package/dist/src/demo/ents/work-counter-ent.js.map +0 -1
- package/dist/src/demo/game.d.ts +0 -12
- package/dist/src/demo/game.js +0 -135
- package/dist/src/demo/game.js.map +0 -1
- package/dist/src/demo/types/tag.d.ts +0 -2
- package/dist/src/demo/types/tag.js +0 -2
- package/dist/src/demo/types/tag.js.map +0 -1
- package/dist/src/ents/button-ent.d.ts +0 -39
- package/dist/src/ents/button-ent.js +0 -128
- package/dist/src/ents/button-ent.js.map +0 -1
- package/dist/src/ents/cursor-ent.d.ts +0 -18
- package/dist/src/ents/cursor-ent.js +0 -63
- package/dist/src/ents/cursor-ent.js.map +0 -1
- package/dist/src/ents/follow-cam-ent.d.ts +0 -25
- package/dist/src/ents/follow-cam-ent.js +0 -87
- package/dist/src/ents/follow-cam-ent.js.map +0 -1
- package/dist/src/ents/nine-patch-ent.d.ts +0 -43
- package/dist/src/ents/nine-patch-ent.js +0 -143
- package/dist/src/ents/nine-patch-ent.js.map +0 -1
- package/dist/src/ents/text-ent.d.ts +0 -23
- package/dist/src/ents/text-ent.js +0 -109
- package/dist/src/ents/text-ent.js.map +0 -1
- package/dist/src/types/void-version.d.ts +0 -7
- package/dist/src/types/void-version.js +0 -2
- package/dist/src/types/void-version.js.map +0 -1
- package/schema/config-file.test.ts +0 -55
- package/schema/config-file.ts +0 -69
- package/schema/config-file.v0.json +0 -68
- package/tools/atlas-pack/aseprite.ts +0 -60
- package/tools/atlas-pack/atlas-json-parser.test.ts +0 -780
- package/tools/atlas-pack/atlas-json-parser.ts +0 -159
- package/tools/atlas-pack/atlas-pack.ts +0 -51
- package/tools/bundle/bundle.ts +0 -64
- package/tools/bundle/html-plugin.ts +0 -135
- package/tools/types/config.ts +0 -65
- package/tools/types/package-json.ts +0 -4
- package/tools/utils/argv.test.ts +0 -41
- package/tools/utils/argv.ts +0 -29
- package/tools/utils/exec.ts +0 -22
- package/tools/utils/file-util.ts +0 -11
- package/tools/utils/html-parser.ts +0 -9
- package/tools/void.ts +0 -55
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Anim,
|
|
3
|
-
type AtlasJSON,
|
|
4
|
-
animCels,
|
|
5
|
-
animMillis,
|
|
6
|
-
celMillis,
|
|
7
|
-
type TagFormat
|
|
8
|
-
} from '../../src/graphics/atlas.ts'
|
|
9
|
-
import {type Box, boxEq, type XY} from '../../src/types/geo.ts'
|
|
10
|
-
import {
|
|
11
|
-
type Aseprite,
|
|
12
|
-
AsepriteDirection,
|
|
13
|
-
type AsepriteFrame,
|
|
14
|
-
type AsepriteFrameMap,
|
|
15
|
-
type AsepriteFrameTag,
|
|
16
|
-
type AsepriteSlice,
|
|
17
|
-
type AsepriteTagSpan
|
|
18
|
-
} from './aseprite.ts'
|
|
19
|
-
|
|
20
|
-
export function parseAtlasJSON(ase: Readonly<Aseprite>): AtlasJSON {
|
|
21
|
-
const anim: {[tag: string]: Anim} = {}
|
|
22
|
-
const cels: number[] = []
|
|
23
|
-
for (const span of ase.meta.frameTags) {
|
|
24
|
-
const tag = parseTag(span.name)
|
|
25
|
-
if (anim[tag]) throw Error(`atlas tag "${tag}" duplicate`)
|
|
26
|
-
const id = Object.keys(anim).length
|
|
27
|
-
anim[tag] = parseAnim(id, span, ase.frames, ase.meta.slices)
|
|
28
|
-
for (const cel of parseAnimFrames(span, ase.frames).map(parseCel))
|
|
29
|
-
cels.push(cel.x, cel.y)
|
|
30
|
-
}
|
|
31
|
-
for (const slice of ase.meta.slices)
|
|
32
|
-
if (!anim[parseTag(slice.name)])
|
|
33
|
-
throw Error(`atlas hitbox "${slice.name}" has no animation`)
|
|
34
|
-
return {anim, celXY: cels}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** @internal */
|
|
38
|
-
export function parseAnim(
|
|
39
|
-
id: number,
|
|
40
|
-
span: Readonly<AsepriteTagSpan>,
|
|
41
|
-
map: Readonly<AsepriteFrameMap>,
|
|
42
|
-
slices: readonly Readonly<AsepriteSlice>[]
|
|
43
|
-
): Anim {
|
|
44
|
-
const cels = parseAnimFrames(span, map)
|
|
45
|
-
if (!cels[0]) throw Error(`no atlas frame "${span.name}"`)
|
|
46
|
-
const {hitbox, hurtbox} = parseHitboxes(span, slices)
|
|
47
|
-
return {
|
|
48
|
-
cels: cels.length,
|
|
49
|
-
h: cels[0].sourceSize.h,
|
|
50
|
-
hitbox,
|
|
51
|
-
hurtbox,
|
|
52
|
-
id,
|
|
53
|
-
w: cels[0].sourceSize.w
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* every frame is guaranteed to be present for at least `celMillis`. cels are
|
|
59
|
-
* duplicated until cel duration is at least met. cels are unpacked until a full
|
|
60
|
-
* period is defined for the direction. no warns for overflowing past on second
|
|
61
|
-
* or uneven periods.
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
export function parseAnimFrames(
|
|
65
|
-
span: AsepriteTagSpan,
|
|
66
|
-
map: AsepriteFrameMap
|
|
67
|
-
): AsepriteFrame[] {
|
|
68
|
-
const cels = []
|
|
69
|
-
let animDuration = 0
|
|
70
|
-
const len = span.to - span.from + 1
|
|
71
|
-
const peak = len - 1
|
|
72
|
-
const cycle = Math.max(1, 2 * peak)
|
|
73
|
-
const end =
|
|
74
|
-
span.direction === AsepriteDirection.Forward ||
|
|
75
|
-
span.direction === AsepriteDirection.Reverse
|
|
76
|
-
? len
|
|
77
|
-
: cycle
|
|
78
|
-
const indexByDir: {[dir in AsepriteDirection]: (i: number) => number} = {
|
|
79
|
-
forward: i => span.from + (i % len),
|
|
80
|
-
pingpong: i => span.from + peak - Math.abs((i % cycle) - peak),
|
|
81
|
-
pingpong_reverse: i => span.to - (peak - Math.abs((i % cycle) - peak)),
|
|
82
|
-
reverse: i => span.to - (i % len)
|
|
83
|
-
}
|
|
84
|
-
const frameIndex = indexByDir[span.direction as AsepriteDirection]
|
|
85
|
-
for (
|
|
86
|
-
let i = 0;
|
|
87
|
-
i < end && cels.length < animCels && animDuration < animMillis;
|
|
88
|
-
i++
|
|
89
|
-
) {
|
|
90
|
-
const frameTag = `${span.name}--${frameIndex(i)}` as AsepriteFrameTag
|
|
91
|
-
const frame = map[frameTag]
|
|
92
|
-
if (!frame) throw Error(`no atlas frame "${frameTag}"`)
|
|
93
|
-
for (
|
|
94
|
-
let celDuration = 0;
|
|
95
|
-
celDuration < frame.duration &&
|
|
96
|
-
cels.length < animCels &&
|
|
97
|
-
animDuration < animMillis;
|
|
98
|
-
celDuration += celMillis, animDuration += celMillis
|
|
99
|
-
) {
|
|
100
|
-
cels.push(frame)
|
|
101
|
-
|
|
102
|
-
if (span.from === span.to) return cels // optimize for long single cel.
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return cels
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** @internal */
|
|
109
|
-
export function parseCel(frame: Readonly<AsepriteFrame>): XY {
|
|
110
|
-
return {
|
|
111
|
-
x: frame.frame.x + (frame.frame.w - frame.sourceSize.w) / 2,
|
|
112
|
-
y: frame.frame.y + (frame.frame.h - frame.sourceSize.h) / 2
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** @internal */
|
|
117
|
-
export function parseHitboxes(
|
|
118
|
-
span: Readonly<AsepriteTagSpan>,
|
|
119
|
-
slices: readonly Readonly<AsepriteSlice>[]
|
|
120
|
-
): {hitbox: Box | undefined; hurtbox: Box | undefined} {
|
|
121
|
-
let hitbox
|
|
122
|
-
let hurtbox
|
|
123
|
-
// https://github.com/aseprite/aseprite/issues/3524
|
|
124
|
-
for (const slice of slices) {
|
|
125
|
-
if (slice.name !== span.name) continue
|
|
126
|
-
|
|
127
|
-
if (!slice.keys[0]) continue
|
|
128
|
-
|
|
129
|
-
for (const k of slice.keys)
|
|
130
|
-
if (!boxEq(k.bounds, slice.keys[0].bounds))
|
|
131
|
-
throw Error(
|
|
132
|
-
`atlas tag "${span.name}" hitbox bounds varies across frames`
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
const red = slice.color === '#ff0000ff'
|
|
136
|
-
const green = slice.color === '#00ff00ff'
|
|
137
|
-
const blue = slice.color === '#0000ffff' // default Aseprite slice color.
|
|
138
|
-
if (!red && !green && !blue)
|
|
139
|
-
throw Error(
|
|
140
|
-
`atlas tag "${span.name}" hitbox color ${slice.color} unsupported`
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
if (hitbox && (red || blue))
|
|
144
|
-
throw Error(`atlas tag "${span.name}" has multiple hitboxes`)
|
|
145
|
-
|
|
146
|
-
if (hurtbox && (green || blue))
|
|
147
|
-
throw Error(`atlas tag "${span.name}" has multiple hurtboxes`)
|
|
148
|
-
|
|
149
|
-
if (red || blue) hitbox = slice.keys[0].bounds
|
|
150
|
-
if (green || blue) hurtbox = slice.keys[0].bounds
|
|
151
|
-
}
|
|
152
|
-
return {hitbox, hurtbox}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function parseTag(tag: string): TagFormat {
|
|
156
|
-
if (!tag.includes('--'))
|
|
157
|
-
throw Error(`atlas tag "${tag}" not in <filestem>--<animation> format`)
|
|
158
|
-
return tag as TagFormat
|
|
159
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import type {AtlasConfig} from '../../schema/config-file.ts'
|
|
4
|
-
import {exec} from '../utils/exec.ts'
|
|
5
|
-
import {globAll} from '../utils/file-util.ts'
|
|
6
|
-
import {parseAtlasJSON} from './atlas-json-parser.ts'
|
|
7
|
-
|
|
8
|
-
// to-do: separate executable?
|
|
9
|
-
export async function packAtlas(config: Readonly<AtlasConfig>): Promise<void> {
|
|
10
|
-
const filenames = await globAll(path.join(config.dir, '**.aseprite'))
|
|
11
|
-
if (!filenames.length) return
|
|
12
|
-
|
|
13
|
-
const webp = config.image.endsWith('.webp')
|
|
14
|
-
const sheet = webp ? config.image.replace('.webp', '.png') : config.image
|
|
15
|
-
const json = await exec(
|
|
16
|
-
'aseprite',
|
|
17
|
-
'--batch',
|
|
18
|
-
'--color-mode=indexed',
|
|
19
|
-
'--filename-format={title}--{tag}--{frame}',
|
|
20
|
-
'--list-slices',
|
|
21
|
-
'--list-tags',
|
|
22
|
-
'--merge-duplicates',
|
|
23
|
-
`--sheet=${sheet}`,
|
|
24
|
-
'--sheet-pack',
|
|
25
|
-
'--tagname-format={title}--{tag}',
|
|
26
|
-
...filenames
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
if (webp)
|
|
30
|
-
await exec(
|
|
31
|
-
'cwebp',
|
|
32
|
-
'-exact',
|
|
33
|
-
'-lossless',
|
|
34
|
-
'-mt',
|
|
35
|
-
'-quiet',
|
|
36
|
-
'-z',
|
|
37
|
-
'9',
|
|
38
|
-
sheet,
|
|
39
|
-
'-o',
|
|
40
|
-
config.image
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
await fs.writeFile(
|
|
44
|
-
config.json,
|
|
45
|
-
JSON.stringify(parseAtlasJSON(JSON.parse(json)))
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
await exec('biome', 'check', '--fix', config.json)
|
|
50
|
-
} catch {}
|
|
51
|
-
}
|
package/tools/bundle/bundle.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import esbuild from 'esbuild'
|
|
3
|
-
import type {AtlasConfig} from '../../schema/config-file.ts'
|
|
4
|
-
import * as V from '../../src/index.ts'
|
|
5
|
-
import type {VoidVersion} from '../../src/types/void-version.ts'
|
|
6
|
-
import {packAtlas} from '../atlas-pack/atlas-pack.ts'
|
|
7
|
-
import type {Config} from '../types/config.ts'
|
|
8
|
-
import {HTMLPlugin} from './html-plugin.ts'
|
|
9
|
-
|
|
10
|
-
export async function bundle(
|
|
11
|
-
config: Readonly<Config>,
|
|
12
|
-
srcFilenames: readonly string[],
|
|
13
|
-
voidVersion: Readonly<VoidVersion>
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const opts: esbuild.BuildOptions = {
|
|
16
|
-
banner: config.watch
|
|
17
|
-
? {
|
|
18
|
-
js: "new EventSource('/esbuild').addEventListener('change', () => location.reload());"
|
|
19
|
-
}
|
|
20
|
-
: {},
|
|
21
|
-
bundle: true,
|
|
22
|
-
define: {
|
|
23
|
-
// define on globalThis to avoid ReferenceError in unit tests.
|
|
24
|
-
'globalThis.voidVersion': JSON.stringify(voidVersion)
|
|
25
|
-
},
|
|
26
|
-
entryPoints: [...srcFilenames],
|
|
27
|
-
format: 'esm',
|
|
28
|
-
logLevel: 'info', // print the port and build demarcations.
|
|
29
|
-
metafile: true,
|
|
30
|
-
minify: config.minify,
|
|
31
|
-
outdir: config.out.dir,
|
|
32
|
-
plugins: [HTMLPlugin(config)],
|
|
33
|
-
sourcemap: 'linked',
|
|
34
|
-
target: 'es2024' // https://esbuild.github.io/content-types/#tsconfig-json
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (config.preloadAtlas) await packAtlas(config.preloadAtlas)
|
|
38
|
-
if (config.preloadAtlas && config.watch) {
|
|
39
|
-
fs.watch(config.preloadAtlas.dir, {recursive: true}, (ev, type) =>
|
|
40
|
-
onWatch(config.preloadAtlas!, ev, type)
|
|
41
|
-
)
|
|
42
|
-
const ctx = await esbuild.context(opts)
|
|
43
|
-
await Promise.all([
|
|
44
|
-
ctx.watch(),
|
|
45
|
-
ctx.serve({port: 1234, servedir: config.out.dir})
|
|
46
|
-
])
|
|
47
|
-
} else {
|
|
48
|
-
const build = await esbuild.build(opts)
|
|
49
|
-
if (config.meta)
|
|
50
|
-
await fs.promises.writeFile(config.meta, JSON.stringify(build.metafile))
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const onWatch = V.debounce(
|
|
55
|
-
async (
|
|
56
|
-
config: Readonly<AtlasConfig>,
|
|
57
|
-
ev: fs.WatchEventType,
|
|
58
|
-
file: string | null
|
|
59
|
-
) => {
|
|
60
|
-
console.log(`asset ${file} ${ev}.`)
|
|
61
|
-
await packAtlas(config)
|
|
62
|
-
},
|
|
63
|
-
500 as V.Millis
|
|
64
|
-
)
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import type esbuild from 'esbuild'
|
|
4
|
-
import {minify} from 'html-minifier-next'
|
|
5
|
-
import type {Config} from '../types/config.ts'
|
|
6
|
-
import {exec} from '../utils/exec.ts'
|
|
7
|
-
import {parseHTML} from '../utils/html-parser.ts'
|
|
8
|
-
|
|
9
|
-
type Manifest = {
|
|
10
|
-
icons?:
|
|
11
|
-
| {
|
|
12
|
-
src?: string | undefined
|
|
13
|
-
size?: string | undefined
|
|
14
|
-
type?: string | undefined
|
|
15
|
-
}[]
|
|
16
|
-
| undefined
|
|
17
|
-
start_url?: string | undefined
|
|
18
|
-
version?: string | undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function HTMLPlugin(config: Readonly<Config>): esbuild.Plugin {
|
|
22
|
-
return {
|
|
23
|
-
name: 'HTMLPlugin',
|
|
24
|
-
setup(build) {
|
|
25
|
-
build.onEnd(async _result => {
|
|
26
|
-
const doc = await parseHTML(config.entry)
|
|
27
|
-
|
|
28
|
-
const scripts = doc.querySelectorAll<HTMLScriptElement>(
|
|
29
|
-
"script[type='module'][src$='.ts']"
|
|
30
|
-
)
|
|
31
|
-
for (const script of scripts) {
|
|
32
|
-
// to-do: test.
|
|
33
|
-
const filename = path.basename(
|
|
34
|
-
script.getAttribute('src')!.replace(/\.ts$/, '.js')
|
|
35
|
-
)
|
|
36
|
-
if (config.oneFile) {
|
|
37
|
-
script.removeAttribute('src')
|
|
38
|
-
script.textContent = await fs.readFile(
|
|
39
|
-
path.join(config.out.dir, filename),
|
|
40
|
-
{encoding: 'utf8'}
|
|
41
|
-
)
|
|
42
|
-
} else script.src = filename
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (config.oneFile) {
|
|
46
|
-
const imgs = doc.querySelectorAll<HTMLImageElement>('img[src]')
|
|
47
|
-
for (const img of imgs) {
|
|
48
|
-
const filename = img.getAttribute('src')!
|
|
49
|
-
const b64 = await fs.readFile(path.join(config.out.dir, filename), {
|
|
50
|
-
encoding: 'base64'
|
|
51
|
-
})
|
|
52
|
-
const ext = filename.match(/\.([^.]+)$/)?.[1]
|
|
53
|
-
if (!ext) throw Error('no asset extension')
|
|
54
|
-
img.src = `data:image/${ext};base64,${b64}`
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const manifestEl = doc.querySelector<HTMLLinkElement>(
|
|
59
|
-
'link[href][rel="manifest"]'
|
|
60
|
-
)
|
|
61
|
-
if (manifestEl) {
|
|
62
|
-
const manifestFilename = path.resolve(
|
|
63
|
-
path.dirname(config.entry),
|
|
64
|
-
manifestEl.getAttribute('href')!
|
|
65
|
-
)
|
|
66
|
-
const manifest: Manifest = JSON.parse(
|
|
67
|
-
await fs.readFile(manifestFilename, 'utf8')
|
|
68
|
-
)
|
|
69
|
-
if (config.version) manifest.version = config.version
|
|
70
|
-
|
|
71
|
-
for (const icon of manifest.icons ?? []) {
|
|
72
|
-
if (!icon.src || !icon.type) continue
|
|
73
|
-
const iconFilename = `${path.dirname(manifestFilename)}/${icon.src}`
|
|
74
|
-
const file = await fs.readFile(iconFilename)
|
|
75
|
-
if (config.oneFile)
|
|
76
|
-
icon.src = `data:${icon.type};base64,${file.toString('base64')}`
|
|
77
|
-
else icon.src = path.relative(config.out.dir, iconFilename)
|
|
78
|
-
}
|
|
79
|
-
if (config.watch) manifest.start_url = 'http://localhost:1234'
|
|
80
|
-
|
|
81
|
-
if (config.oneFile)
|
|
82
|
-
manifestEl.href = `data:application/json,${encodeURIComponent(
|
|
83
|
-
JSON.stringify(manifest)
|
|
84
|
-
)}`
|
|
85
|
-
else
|
|
86
|
-
await fs.writeFile(
|
|
87
|
-
path.join(config.out.dir, path.basename(manifestFilename)),
|
|
88
|
-
JSON.stringify(manifest)
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (config.oneFile) {
|
|
93
|
-
const icons = doc.querySelectorAll<HTMLLinkElement>(
|
|
94
|
-
'link[href][rel="icon"][type]'
|
|
95
|
-
)
|
|
96
|
-
for (const icon of icons) {
|
|
97
|
-
const filename = path.resolve(
|
|
98
|
-
config.out.dir,
|
|
99
|
-
icon.getAttribute('href')!
|
|
100
|
-
)
|
|
101
|
-
const file = await fs.readFile(filename)
|
|
102
|
-
icon.href = `data:${icon.type};base64,${file.toString('base64')}`
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let html = `<!doctype html>\n${doc.documentElement.outerHTML}`
|
|
107
|
-
|
|
108
|
-
if (config.minify)
|
|
109
|
-
html = await minify(html, {
|
|
110
|
-
caseSensitive: true,
|
|
111
|
-
collapseBooleanAttributes: true,
|
|
112
|
-
html5: true,
|
|
113
|
-
minifyCSS: true,
|
|
114
|
-
removeAttributeQuotes: true,
|
|
115
|
-
removeComments: true,
|
|
116
|
-
removeEmptyAttributes: true
|
|
117
|
-
})
|
|
118
|
-
else
|
|
119
|
-
try {
|
|
120
|
-
html = await exec(
|
|
121
|
-
'biome',
|
|
122
|
-
'check',
|
|
123
|
-
'--fix',
|
|
124
|
-
`--stdin-file-path=${config.entry}`,
|
|
125
|
-
{stdin: html}
|
|
126
|
-
)
|
|
127
|
-
} catch {}
|
|
128
|
-
|
|
129
|
-
// to-do: test.
|
|
130
|
-
const outHTMLFilename = path.join(config.out.dir, config.out.filename)
|
|
131
|
-
await fs.writeFile(outHTMLFilename, html)
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
package/tools/types/config.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import type {AtlasConfig, ConfigFile} from '../../schema/config-file.ts'
|
|
3
|
-
import type {Argv} from '../utils/argv.ts'
|
|
4
|
-
import type {PackageJSON} from './package-json.ts'
|
|
5
|
-
|
|
6
|
-
export type Config = {
|
|
7
|
-
$schema: string
|
|
8
|
-
entry: string
|
|
9
|
-
meta: string | undefined
|
|
10
|
-
out: {dir: string; filename: string}
|
|
11
|
-
preloadAtlas: AtlasConfig | undefined
|
|
12
|
-
|
|
13
|
-
/** config directory name. */
|
|
14
|
-
dirname: string
|
|
15
|
-
/** config filename. */
|
|
16
|
-
filename: string
|
|
17
|
-
|
|
18
|
-
minify: boolean
|
|
19
|
-
oneFile: boolean
|
|
20
|
-
watch: boolean
|
|
21
|
-
|
|
22
|
-
/** package publish date. */
|
|
23
|
-
published: string | undefined
|
|
24
|
-
/** package version. */
|
|
25
|
-
version: string | undefined
|
|
26
|
-
|
|
27
|
-
/** Git short hash. */
|
|
28
|
-
hash: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function Config(
|
|
32
|
-
configFile: Readonly<ConfigFile>,
|
|
33
|
-
argv: Readonly<Argv>,
|
|
34
|
-
packageJSON: Readonly<PackageJSON>,
|
|
35
|
-
hash: string
|
|
36
|
-
): Config {
|
|
37
|
-
let fileStem = path.basename(configFile.entry).replace(/\.[^.]+$/, '')
|
|
38
|
-
if (configFile.out.name && !argv.opts['--watch'])
|
|
39
|
-
fileStem = configFile.out.name
|
|
40
|
-
let fileSuffix = '.html'
|
|
41
|
-
if (!argv.opts['--watch']) {
|
|
42
|
-
const version = packageJSON.version ? `v${packageJSON.version}` : ''
|
|
43
|
-
const published =
|
|
44
|
-
packageJSON.version && packageJSON.published
|
|
45
|
-
? `+${packageJSON.published}`
|
|
46
|
-
: ''
|
|
47
|
-
const hashStr = packageJSON.version && hash ? `.${hash}` : ''
|
|
48
|
-
fileSuffix = `-${version}${published}${hashStr}.html`
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
$schema: configFile.$schema,
|
|
52
|
-
entry: configFile.entry,
|
|
53
|
-
meta: configFile.meta,
|
|
54
|
-
out: {dir: configFile.out.dir, filename: `${fileStem}${fileSuffix}`},
|
|
55
|
-
preloadAtlas: configFile.preloadAtlas,
|
|
56
|
-
dirname: configFile.dirname,
|
|
57
|
-
filename: configFile.filename,
|
|
58
|
-
minify: argv.opts['--minify'] ?? false,
|
|
59
|
-
oneFile: argv.opts['--one-file'] ?? false,
|
|
60
|
-
watch: argv.opts['--watch'] ?? false,
|
|
61
|
-
published: packageJSON.published,
|
|
62
|
-
version: packageJSON.version,
|
|
63
|
-
hash
|
|
64
|
-
}
|
|
65
|
-
}
|
package/tools/utils/argv.test.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import {test} from 'node:test'
|
|
3
|
-
import {Argv} from './argv.ts'
|
|
4
|
-
|
|
5
|
-
declare module './argv.ts' {
|
|
6
|
-
interface Opts {
|
|
7
|
-
'--config'?: string
|
|
8
|
-
'--minify'?: true
|
|
9
|
-
'--watch'?: true
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
test('parses empty.', () => {
|
|
14
|
-
assert.deepEqual<Argv>(Argv(['/usr/local/bin/node', 'tools/void.ts']), {
|
|
15
|
-
args: [],
|
|
16
|
-
opts: {},
|
|
17
|
-
posargs: []
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('parses nonempty.', () => {
|
|
22
|
-
assert.deepEqual<Argv>(
|
|
23
|
-
Argv([
|
|
24
|
-
'/usr/local/bin/node',
|
|
25
|
-
'tools/void.ts',
|
|
26
|
-
'--config=config',
|
|
27
|
-
'--minify',
|
|
28
|
-
'--watch',
|
|
29
|
-
'a.aseprite',
|
|
30
|
-
'b.aseprite',
|
|
31
|
-
'--',
|
|
32
|
-
'posarg0',
|
|
33
|
-
'posarg1'
|
|
34
|
-
]),
|
|
35
|
-
{
|
|
36
|
-
args: ['a.aseprite', 'b.aseprite'],
|
|
37
|
-
opts: {'--config': 'config', '--minify': true, '--watch': true},
|
|
38
|
-
posargs: ['posarg0', 'posarg1']
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
})
|
package/tools/utils/argv.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
/** string-string|bool map. Eg, `'--config'?: string; '--minify'?: string | true` */
|
|
11
|
-
// biome-ignore lint/suspicious/noEmptyInterface: declaration merging.
|
|
12
|
-
export interface Opts {}
|
|
13
|
-
|
|
14
|
-
export function Argv(argv: readonly string[]): Argv {
|
|
15
|
-
const args = []
|
|
16
|
-
const posargs = []
|
|
17
|
-
const opts: {[k: string]: string | true} = {}
|
|
18
|
-
for (let i = 2; i < argv.length; i++) {
|
|
19
|
-
if (argv[i] === '--') {
|
|
20
|
-
posargs.push(...argv.slice(i + 1))
|
|
21
|
-
break
|
|
22
|
-
}
|
|
23
|
-
if (argv[i]!.startsWith('--')) {
|
|
24
|
-
const [k, v] = argv[i]!.split(/=(.*)/).slice(0, 2)
|
|
25
|
-
opts[k!] = v ?? true
|
|
26
|
-
} else args.push(argv[i]!)
|
|
27
|
-
}
|
|
28
|
-
return {args, opts, posargs}
|
|
29
|
-
}
|
package/tools/utils/exec.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {execFile} from 'node:child_process'
|
|
2
|
-
import util from 'node:util'
|
|
3
|
-
|
|
4
|
-
export async function exec(
|
|
5
|
-
exe: string,
|
|
6
|
-
...args:
|
|
7
|
-
| readonly [...string[], {stdin?: string | undefined}]
|
|
8
|
-
| readonly string[]
|
|
9
|
-
): Promise<string> {
|
|
10
|
-
const opts = (typeof args.at(-1) === 'object' ? args.at(-1) : undefined) as
|
|
11
|
-
| {stdin?: string | undefined}
|
|
12
|
-
| undefined
|
|
13
|
-
args = (opts ? args.slice(0, -1) : args) as string[]
|
|
14
|
-
const promise = util.promisify(execFile)(exe, args, {})
|
|
15
|
-
if (promise.child.stdin && opts?.stdin != null) {
|
|
16
|
-
promise.child.stdin.write(opts.stdin)
|
|
17
|
-
promise.child.stdin.end()
|
|
18
|
-
}
|
|
19
|
-
const {stdout, stderr} = await promise
|
|
20
|
-
process.stderr.write(stderr)
|
|
21
|
-
return stdout
|
|
22
|
-
}
|
package/tools/utils/file-util.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises'
|
|
2
|
-
|
|
3
|
-
export async function globAll(glob: string): Promise<string[]> {
|
|
4
|
-
const filenames = []
|
|
5
|
-
try {
|
|
6
|
-
for await (const filename of fs.glob(glob)) filenames.push(filename)
|
|
7
|
-
} catch (err) {
|
|
8
|
-
throw Error(`glob \`${glob}\` unreadable`, {cause: err})
|
|
9
|
-
}
|
|
10
|
-
return filenames
|
|
11
|
-
}
|
package/tools/void.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
|
|
5
|
-
import path from 'node:path'
|
|
6
|
-
import voidPackageJSON from '../package.json' with {type: 'json'}
|
|
7
|
-
import {parseConfigFile} from '../schema/config-file.ts'
|
|
8
|
-
import type {VoidVersion} from '../src/types/void-version.ts'
|
|
9
|
-
import {bundle} from './bundle/bundle.ts'
|
|
10
|
-
import {Config} from './types/config.ts'
|
|
11
|
-
import type {PackageJSON} from './types/package-json.ts'
|
|
12
|
-
import {Argv} from './utils/argv.ts'
|
|
13
|
-
import {exec} from './utils/exec.ts'
|
|
14
|
-
import {parseHTML} from './utils/html-parser.ts'
|
|
15
|
-
|
|
16
|
-
declare module './utils/argv.ts' {
|
|
17
|
-
interface Opts {
|
|
18
|
-
'--config'?: string
|
|
19
|
-
'--minify'?: true
|
|
20
|
-
/** inline everything into a single HTML file output. */
|
|
21
|
-
'--one-file'?: true
|
|
22
|
-
/**
|
|
23
|
-
* run development server on http://localhost:1234 and reload on code
|
|
24
|
-
* change.
|
|
25
|
-
*/
|
|
26
|
-
'--watch'?: true
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function build(args: readonly string[]): Promise<void> {
|
|
31
|
-
const argv = Argv(args)
|
|
32
|
-
const configFile = await parseConfigFile(argv.opts['--config'] ?? 'void.json')
|
|
33
|
-
const hash = (await exec('git', 'rev-parse', '--short', 'HEAD')).trim()
|
|
34
|
-
const packageJSON: PackageJSON = JSON.parse(
|
|
35
|
-
(await exec('npm', 'pkg', 'get', 'version', 'published')) || '{}'
|
|
36
|
-
)
|
|
37
|
-
const config = Config(configFile, argv, packageJSON, hash)
|
|
38
|
-
|
|
39
|
-
const doc = await parseHTML(config.entry)
|
|
40
|
-
const srcFilenames = [
|
|
41
|
-
...doc.querySelectorAll<HTMLScriptElement>(
|
|
42
|
-
"script[type='module'][src$='.ts']"
|
|
43
|
-
)
|
|
44
|
-
].map(el => path.resolve(path.dirname(config.entry), el.getAttribute('src')!))
|
|
45
|
-
|
|
46
|
-
const voidVersion: VoidVersion = {
|
|
47
|
-
published: voidPackageJSON.published,
|
|
48
|
-
// imported JSON doesn't treeshake. define as a constant.
|
|
49
|
-
version: voidPackageJSON.version
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
await bundle(config, srcFilenames, voidVersion)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (import.meta.main) await build(process.argv)
|