@auraindustry/aurajs 0.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/README.md +98 -2
- package/benchmarks/perf-thresholds.json +54 -0
- package/package.json +4 -7
- package/src/asset-pack.mjs +5 -1
- package/src/authored-project.mjs +1449 -0
- package/src/authored-runtime.mjs +2016 -0
- package/src/authoring/avatar-animation-graph.mjs +648 -0
- package/src/bin-integrity.mjs +272 -0
- package/src/build-contract/assets.mjs +130 -0
- package/src/build-contract/capabilities.mjs +116 -0
- package/src/build-contract/constants.mjs +6 -0
- package/src/build-contract/helpers.mjs +44 -0
- package/src/build-contract/web-templates.mjs +5993 -0
- package/src/build-contract.mjs +27 -2910
- package/src/bundler.mjs +188 -55
- package/src/cli.mjs +4825 -1512
- package/src/commands/project-authoring.mjs +434 -0
- package/src/config.mjs +27 -0
- package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
- package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
- package/src/conformance/cases/index.mjs +11 -0
- package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
- package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
- package/src/conformance/shared.mjs +27 -0
- package/src/conformance-runner.mjs +25 -13
- package/src/conformance.mjs +619 -4020
- package/src/cutscene.mjs +362 -5
- package/src/dev-cli-action.mjs +249 -0
- package/src/dev-cli-inspect.mjs +92 -0
- package/src/dev-cli-state.mjs +80 -0
- package/src/external-asset-cache.mjs +587 -0
- package/src/external-asset-policy.mjs +217 -0
- package/src/external-package-surface.mjs +206 -0
- package/src/game-action-runtime.mjs +869 -0
- package/src/game-state-runtime.mjs +206 -6
- package/src/headless-action.mjs +186 -0
- package/src/headless-test/runtime-animation.mjs +1173 -0
- package/src/headless-test/runtime-coordinator.mjs +1514 -0
- package/src/headless-test/runtime-primitives.mjs +320 -0
- package/src/headless-test/runtime-world.mjs +2253 -0
- package/src/headless-test.mjs +392 -4298
- package/src/host-binary.mjs +342 -14
- package/src/icon-discovery.mjs +64 -0
- package/src/make-catalog.mjs +109 -0
- package/src/make.mjs +197 -0
- package/src/package-integrity.mjs +586 -0
- package/src/perf-benchmark.mjs +353 -0
- package/src/postinstall.mjs +5 -5
- package/src/prefabs/index.mjs +34 -0
- package/src/prefabs/scene-serialization.mjs +184 -0
- package/src/project-importer.mjs +620 -0
- package/src/project-registry.mjs +24 -0
- package/src/publish-command.mjs +195 -0
- package/src/publish-env-example.mjs +83 -0
- package/src/publish-validation.mjs +708 -0
- package/src/retro/assets/compile.mjs +232 -0
- package/src/retro/backend-gba/authoring.mjs +1029 -0
- package/src/retro/backend-gba/rom.mjs +363 -0
- package/src/retro/backend-gbc/rom.mjs +85 -0
- package/src/retro/build.mjs +278 -0
- package/src/retro/cli/commands.mjs +292 -0
- package/src/retro/cli/templates.mjs +84 -0
- package/src/retro/diagnostics/catalog.mjs +110 -0
- package/src/retro/diagnostics/emit.mjs +72 -0
- package/src/retro/emulator/case-overlay.mjs +64 -0
- package/src/retro/emulator/discovery.mjs +158 -0
- package/src/retro/emulator/macos-case-overlay.swift +220 -0
- package/src/retro/emulator/profiles.mjs +146 -0
- package/src/retro/emulator/runner.mjs +289 -0
- package/src/retro/frontend/load-project.mjs +98 -0
- package/src/retro/index.mjs +30 -0
- package/src/retro/ir/build-ir.mjs +108 -0
- package/src/retro/runtime-gba/contract.mjs +151 -0
- package/src/retro/runtime-gbc/contract.mjs +117 -0
- package/src/retro/shared/span.mjs +26 -0
- package/src/retro/shared/targets.mjs +64 -0
- package/src/retro/validator/check-project.mjs +114 -0
- package/src/runtime-hotspot-audit.mjs +707 -0
- package/src/scaffold/config.mjs +1000 -0
- package/src/scaffold/fs.mjs +56 -0
- package/src/scaffold/layout.mjs +318 -0
- package/src/scaffold/project-docs.mjs +438 -0
- package/src/scaffold.mjs +93 -596
- package/src/scene-composition/index.mjs +326 -0
- package/src/scene-composition/runtime.mjs +751 -0
- package/src/self-hosted-assets.mjs +604 -0
- package/src/session-client.mjs +750 -0
- package/src/session-native-launcher.mjs +74 -0
- package/src/session-protocol.mjs +75 -0
- package/src/session-runtime.mjs +321 -0
- package/src/session-server.mjs +360 -0
- package/src/shader-kits/index.mjs +773 -0
- package/src/starter-content-registry.mjs +292 -0
- package/src/state-artifacts.mjs +662 -24
- package/src/state-dev-reload.mjs +99 -2
- package/src/terminal-ui.mjs +245 -0
- package/src/web-conformance.mjs +219 -0
- package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
- package/templates/create/2d/content/gameplay/waves.json +26 -0
- package/templates/create/2d/content/registries/.gitkeep +1 -0
- package/templates/create/2d/docs/design/.gitkeep +1 -0
- package/templates/create/2d/docs/design/loop.md +5 -0
- package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
- package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
- package/templates/create/2d/prefabs/player.prefab.js +36 -0
- package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
- package/templates/create/2d/scenes/boot.scene.js +12 -0
- package/templates/create/2d/scenes/gameplay.scene.js +230 -0
- package/templates/create/2d/scenes/menu.scene.js +9 -0
- package/templates/create/2d/src/main.js +6 -185
- package/templates/create/2d/src/runtime/app.js +49 -0
- package/templates/create/2d/src/runtime/capabilities.js +35 -0
- package/templates/create/2d/ui/hud.screen.js +40 -0
- package/templates/create/2d/ui/pause.screen.js +149 -0
- package/templates/create/2d/ui/settings.screen.js +347 -0
- package/templates/create/2d/ui/title.screen.js +13 -0
- package/templates/create/2d-adventure/aura.config.json +28 -0
- package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
- package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
- package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/2d-adventure/docs/design/loop.md +5 -0
- package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
- package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
- package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
- package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
- package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
- package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
- package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
- package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
- package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/loop.md +5 -0
- package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
- package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
- package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
- package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
- package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
- package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
- package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
- package/templates/create/2d-survivor/src/main.js +5 -332
- package/templates/create/2d-survivor/src/runtime/app.js +49 -0
- package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
- package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
- package/templates/create/2d-survivor/ui/title.screen.js +13 -0
- package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
- package/templates/create/3d/content/gameplay/course.js +40 -0
- package/templates/create/3d/content/registries/.gitkeep +1 -0
- package/templates/create/3d/docs/design/.gitkeep +1 -0
- package/templates/create/3d/docs/design/loop.md +5 -0
- package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
- package/templates/create/3d/prefabs/player.prefab.js +204 -0
- package/templates/create/3d/prefabs/world.prefab.js +112 -0
- package/templates/create/3d/scenes/boot.scene.js +12 -0
- package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d/scenes/gameplay.scene.js +292 -0
- package/templates/create/3d/src/main.js +6 -295
- package/templates/create/3d/src/runtime/app.js +49 -0
- package/templates/create/3d/src/runtime/capabilities.js +53 -0
- package/templates/create/3d/src/runtime/materials.js +34 -0
- package/templates/create/3d/src/runtime/state.js +39 -0
- package/templates/create/3d/ui/hud.screen.js +75 -0
- package/templates/create/3d/ui/pause.screen.js +166 -0
- package/templates/create/3d/ui/settings.screen.js +387 -0
- package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-adventure/aura.config.json +28 -0
- package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
- package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
- package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/3d-adventure/docs/design/loop.md +5 -0
- package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
- package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
- package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
- package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
- package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
- package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
- package/templates/create/3d-adventure/src/runtime/state.js +31 -0
- package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
- package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
- package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
- package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
- package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
- package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
- package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
- package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
- package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
- package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
- package/templates/create/3d-collectathon/src/main.js +5 -355
- package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
- package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
- package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
- package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
- package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
- package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
- package/templates/create/blank/config/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/registries/.gitkeep +1 -0
- package/templates/create/blank/docs/design/.gitkeep +1 -0
- package/templates/create/blank/docs/design/loop.md +5 -0
- package/templates/create/blank/prefabs/.gitkeep +1 -0
- package/templates/create/blank/scenes/.gitkeep +1 -0
- package/templates/create/blank/src/runtime/.gitkeep +1 -0
- package/templates/create/blank/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
- package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/aura.config.json +28 -0
- package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
- package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
- package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
- package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
- package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
- package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
- package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
- package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
- package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
- package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/main.js +17 -0
- package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
- package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
- package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
- package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
- package/templates/create/local-multiplayer/aura.config.json +40 -0
- package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
- package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
- package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
- package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
- package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
- package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
- package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
- package/templates/create/local-multiplayer/src/main.js +17 -0
- package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
- package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
- package/templates/create/shared/src/runtime/project-inspector.js +105 -0
- package/templates/create/shared/src/runtime/scene-flow.js +290 -0
- package/templates/create/shared/src/runtime/screen-shell.js +222 -0
- package/templates/create/shared/src/runtime/ui-forms.js +209 -0
- package/templates/create/shared/src/runtime/ui-settings.js +237 -0
- package/templates/create/shared/src/runtime/ui-theme.js +352 -0
- package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
- package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
- package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
- package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
- package/templates/create/shared/src/starter-utils/core.js +39 -3
- package/templates/create/shared/src/starter-utils/index.js +8 -2
- package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
- package/templates/create/shared/src/starter-utils/triggers.js +662 -0
- package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
- package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
- package/templates/create/video-cutscene/aura.config.json +28 -0
- package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
- package/templates/create/video-cutscene/docs/design/loop.md +22 -0
- package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
- package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
- package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
- package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
- package/templates/create/video-cutscene/src/main.js +17 -0
- package/templates/create/video-cutscene/src/runtime/app.js +52 -0
- package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
- package/templates/create/video-cutscene/src/runtime/state.js +13 -0
- package/templates/create/video-cutscene/ui/.gitkeep +0 -0
- package/templates/create-bin/play.js +1187 -0
- package/templates/make/README.md +46 -0
- package/templates/make/catalog.json +51 -0
- package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
- package/templates/make/component/manifest.json +9 -0
- package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
- package/templates/make/data/manifest.json +9 -0
- package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
- package/templates/make/material/manifest.json +9 -0
- package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
- package/templates/make/prefab/manifest.json +9 -0
- package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
- package/templates/make/scene/manifest.json +9 -0
- package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
- package/templates/make/shader/manifest.json +9 -0
- package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
- package/templates/make/system/manifest.json +9 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
- package/templates/make/ui-screen/manifest.json +10 -0
- package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
- package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
- package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
- package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
- package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
- package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
- package/templates/retro/platformer/README.md +10 -0
- package/templates/retro/platformer/assets/retro/assets.json +91 -0
- package/templates/retro/platformer/aura.config.json +7 -0
- package/templates/retro/platformer/package.json +5 -0
- package/templates/retro/platformer/src/main.js +40 -0
- package/templates/retro/puzzle-grid/README.md +10 -0
- package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
- package/templates/retro/puzzle-grid/aura.config.json +7 -0
- package/templates/retro/puzzle-grid/package.json +5 -0
- package/templates/retro/puzzle-grid/src/main.js +29 -0
- package/templates/retro/tactics-grid/README.md +10 -0
- package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
- package/templates/retro/tactics-grid/aura.config.json +7 -0
- package/templates/retro/tactics-grid/package.json +5 -0
- package/templates/retro/tactics-grid/src/main.js +35 -0
- package/templates/retro/topdown-adventure/README.md +10 -0
- package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
- package/templates/retro/topdown-adventure/aura.config.json +7 -0
- package/templates/retro/topdown-adventure/package.json +5 -0
- package/templates/retro/topdown-adventure/src/main.js +29 -0
- package/templates/skills/aurajs/SKILL.md +61 -5
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const REPEATABLE_BUTTONS = ['left', 'right', 'up', 'down'];
|
|
2
|
+
|
|
3
|
+
function repeatTriggered(frames) {
|
|
4
|
+
return frames === 1 || frames >= 3;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function normalizeInputState(value = {}, previousRepeatFrames = Object.create(null)) {
|
|
8
|
+
const pressed = new Set(Array.isArray(value.pressed) ? value.pressed.map((entry) => String(entry)) : []);
|
|
9
|
+
const justPressed = new Set(Array.isArray(value.justPressed) ? value.justPressed.map((entry) => String(entry)) : []);
|
|
10
|
+
const explicitRepeatPressed = new Set(Array.isArray(value.repeatPressed) ? value.repeatPressed.map((entry) => String(entry)) : []);
|
|
11
|
+
const repeatFrames = Object.create(null);
|
|
12
|
+
const repeatPressed = new Set(explicitRepeatPressed);
|
|
13
|
+
for (const button of REPEATABLE_BUTTONS) {
|
|
14
|
+
const nextFrames = pressed.has(button) ? ((previousRepeatFrames[button] || 0) + 1) : 0;
|
|
15
|
+
repeatFrames[button] = nextFrames;
|
|
16
|
+
if (repeatTriggered(nextFrames)) {
|
|
17
|
+
repeatPressed.add(button);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
repeatFrames,
|
|
22
|
+
pressed(button) {
|
|
23
|
+
return pressed.has(String(button));
|
|
24
|
+
},
|
|
25
|
+
justPressed(button) {
|
|
26
|
+
return justPressed.has(String(button));
|
|
27
|
+
},
|
|
28
|
+
repeatPressed(button) {
|
|
29
|
+
return repeatPressed.has(String(button));
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function emptyFrameState() {
|
|
35
|
+
return {
|
|
36
|
+
backgrounds: [],
|
|
37
|
+
sprites: [],
|
|
38
|
+
text: [],
|
|
39
|
+
audio: [],
|
|
40
|
+
saveWrites: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function createGbaRuntimeContract() {
|
|
45
|
+
const runtime = {
|
|
46
|
+
frame: 0,
|
|
47
|
+
setupRan: false,
|
|
48
|
+
input: normalizeInputState(),
|
|
49
|
+
repeatFrames: Object.create(null),
|
|
50
|
+
saveStore: Object.create(null),
|
|
51
|
+
frameState: emptyFrameState(),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const aura = {
|
|
55
|
+
input: {
|
|
56
|
+
pressed(button) {
|
|
57
|
+
return runtime.input.pressed(button);
|
|
58
|
+
},
|
|
59
|
+
justPressed(button) {
|
|
60
|
+
return runtime.input.justPressed(button);
|
|
61
|
+
},
|
|
62
|
+
repeatPressed(button) {
|
|
63
|
+
return runtime.input.repeatPressed(button);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
tilemap: {
|
|
67
|
+
setTile(layer, x, y, tile, options = {}) {
|
|
68
|
+
runtime.frameState.backgrounds.push({
|
|
69
|
+
kind: 'tile',
|
|
70
|
+
layer: String(layer),
|
|
71
|
+
x: Number(x),
|
|
72
|
+
y: Number(y),
|
|
73
|
+
tile: String(tile),
|
|
74
|
+
options: { ...options },
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
sprite: {
|
|
79
|
+
draw(spriteId, x, y, options = {}) {
|
|
80
|
+
runtime.frameState.sprites.push({
|
|
81
|
+
spriteId: String(spriteId),
|
|
82
|
+
x: Number(x),
|
|
83
|
+
y: Number(y),
|
|
84
|
+
options: { ...options },
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
text: {
|
|
89
|
+
write(text, x, y, options = {}) {
|
|
90
|
+
runtime.frameState.text.push({
|
|
91
|
+
text: String(text),
|
|
92
|
+
x: Number(x),
|
|
93
|
+
y: Number(y),
|
|
94
|
+
options: { ...options },
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
audio: {
|
|
99
|
+
playMusic(trackId) {
|
|
100
|
+
runtime.frameState.audio.push({ kind: 'music', trackId: String(trackId) });
|
|
101
|
+
},
|
|
102
|
+
playSfx(effectId) {
|
|
103
|
+
runtime.frameState.audio.push({ kind: 'sfx', effectId: String(effectId) });
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
save: {
|
|
107
|
+
write(key, value) {
|
|
108
|
+
runtime.saveStore[String(key)] = value;
|
|
109
|
+
runtime.frameState.saveWrites.push({ key: String(key), value });
|
|
110
|
+
},
|
|
111
|
+
read(key) {
|
|
112
|
+
return runtime.saveStore[String(key)] ?? null;
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
function snapshot() {
|
|
118
|
+
return {
|
|
119
|
+
frame: runtime.frame,
|
|
120
|
+
setupRan: runtime.setupRan,
|
|
121
|
+
target: 'gba',
|
|
122
|
+
backgrounds: runtime.frameState.backgrounds.slice(),
|
|
123
|
+
sprites: runtime.frameState.sprites.slice(),
|
|
124
|
+
text: runtime.frameState.text.slice(),
|
|
125
|
+
audio: runtime.frameState.audio.slice(),
|
|
126
|
+
saveWrites: runtime.frameState.saveWrites.slice(),
|
|
127
|
+
saveStore: { ...runtime.saveStore },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
aura,
|
|
133
|
+
step(program, inputState = {}) {
|
|
134
|
+
runtime.frame += 1;
|
|
135
|
+
runtime.input = normalizeInputState(inputState, runtime.repeatFrames);
|
|
136
|
+
runtime.repeatFrames = runtime.input.repeatFrames;
|
|
137
|
+
runtime.frameState = emptyFrameState();
|
|
138
|
+
if (!runtime.setupRan && typeof program.setup === 'function') {
|
|
139
|
+
program.setup(aura);
|
|
140
|
+
runtime.setupRan = true;
|
|
141
|
+
}
|
|
142
|
+
if (typeof program.update === 'function') {
|
|
143
|
+
program.update(aura);
|
|
144
|
+
}
|
|
145
|
+
if (typeof program.draw === 'function') {
|
|
146
|
+
program.draw(aura);
|
|
147
|
+
}
|
|
148
|
+
return snapshot();
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function normalizeInputState(value = {}) {
|
|
2
|
+
const pressed = new Set(Array.isArray(value.pressed) ? value.pressed.map((entry) => String(entry)) : []);
|
|
3
|
+
return {
|
|
4
|
+
pressed(button) {
|
|
5
|
+
return pressed.has(String(button));
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function emptyFrameState() {
|
|
11
|
+
return {
|
|
12
|
+
background: [],
|
|
13
|
+
sprites: [],
|
|
14
|
+
text: [],
|
|
15
|
+
audio: [],
|
|
16
|
+
saveWrites: [],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createGbcRuntimeContract() {
|
|
21
|
+
const runtime = {
|
|
22
|
+
frame: 0,
|
|
23
|
+
setupRan: false,
|
|
24
|
+
input: normalizeInputState(),
|
|
25
|
+
saveStore: Object.create(null),
|
|
26
|
+
frameState: emptyFrameState(),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const aura = {
|
|
30
|
+
input: {
|
|
31
|
+
pressed(button) {
|
|
32
|
+
return runtime.input.pressed(button);
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
tilemap: {
|
|
36
|
+
setTile(layer, x, y, tile) {
|
|
37
|
+
runtime.frameState.background.push({
|
|
38
|
+
kind: 'tile',
|
|
39
|
+
layer: String(layer),
|
|
40
|
+
x: Number(x),
|
|
41
|
+
y: Number(y),
|
|
42
|
+
tile: String(tile),
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
sprite: {
|
|
47
|
+
draw(spriteId, x, y, options = {}) {
|
|
48
|
+
runtime.frameState.sprites.push({
|
|
49
|
+
spriteId: String(spriteId),
|
|
50
|
+
x: Number(x),
|
|
51
|
+
y: Number(y),
|
|
52
|
+
options: { ...options },
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
text: {
|
|
57
|
+
write(text, x, y, options = {}) {
|
|
58
|
+
runtime.frameState.text.push({
|
|
59
|
+
text: String(text),
|
|
60
|
+
x: Number(x),
|
|
61
|
+
y: Number(y),
|
|
62
|
+
options: { ...options },
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
audio: {
|
|
67
|
+
playMusic(trackId) {
|
|
68
|
+
runtime.frameState.audio.push({ kind: 'music', trackId: String(trackId) });
|
|
69
|
+
},
|
|
70
|
+
playSfx(effectId) {
|
|
71
|
+
runtime.frameState.audio.push({ kind: 'sfx', effectId: String(effectId) });
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
save: {
|
|
75
|
+
write(key, value) {
|
|
76
|
+
runtime.saveStore[String(key)] = value;
|
|
77
|
+
runtime.frameState.saveWrites.push({ key: String(key), value });
|
|
78
|
+
},
|
|
79
|
+
read(key) {
|
|
80
|
+
return runtime.saveStore[String(key)] ?? null;
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function snapshot() {
|
|
86
|
+
return {
|
|
87
|
+
frame: runtime.frame,
|
|
88
|
+
setupRan: runtime.setupRan,
|
|
89
|
+
background: runtime.frameState.background.slice(),
|
|
90
|
+
sprites: runtime.frameState.sprites.slice(),
|
|
91
|
+
text: runtime.frameState.text.slice(),
|
|
92
|
+
audio: runtime.frameState.audio.slice(),
|
|
93
|
+
saveWrites: runtime.frameState.saveWrites.slice(),
|
|
94
|
+
saveStore: { ...runtime.saveStore },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
aura,
|
|
100
|
+
step(program, inputState = {}) {
|
|
101
|
+
runtime.frame += 1;
|
|
102
|
+
runtime.input = normalizeInputState(inputState);
|
|
103
|
+
runtime.frameState = emptyFrameState();
|
|
104
|
+
if (!runtime.setupRan && typeof program.setup === 'function') {
|
|
105
|
+
program.setup(aura);
|
|
106
|
+
runtime.setupRan = true;
|
|
107
|
+
}
|
|
108
|
+
if (typeof program.update === 'function') {
|
|
109
|
+
program.update(aura);
|
|
110
|
+
}
|
|
111
|
+
if (typeof program.draw === 'function') {
|
|
112
|
+
program.draw(aura);
|
|
113
|
+
}
|
|
114
|
+
return snapshot();
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { relative, sep } from 'node:path';
|
|
2
|
+
|
|
3
|
+
export function lineColumnFromIndex(code, index) {
|
|
4
|
+
const normalizedIndex = Math.max(0, Number(index) || 0);
|
|
5
|
+
const slice = String(code || '').slice(0, normalizedIndex);
|
|
6
|
+
const lines = slice.split(/\r?\n/);
|
|
7
|
+
const line = lines.length;
|
|
8
|
+
const column = lines[lines.length - 1].length + 1;
|
|
9
|
+
return { line, column };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function spanFromIndex(code, index, width = 1) {
|
|
13
|
+
const start = lineColumnFromIndex(code, index);
|
|
14
|
+
const end = lineColumnFromIndex(code, index + Math.max(1, width));
|
|
15
|
+
return {
|
|
16
|
+
line: start.line,
|
|
17
|
+
column: start.column,
|
|
18
|
+
endLine: end.line,
|
|
19
|
+
endColumn: end.column,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function relFile(projectRoot, filePath) {
|
|
24
|
+
const rel = relative(projectRoot, filePath);
|
|
25
|
+
return rel.split(sep).join('/');
|
|
26
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const RETRO_TARGET_PROFILES = Object.freeze({
|
|
2
|
+
gb: Object.freeze({
|
|
3
|
+
target: 'gb',
|
|
4
|
+
displayName: 'Game Boy',
|
|
5
|
+
family: 'gb',
|
|
6
|
+
architecture: 'sm83',
|
|
7
|
+
colorMode: 'mono',
|
|
8
|
+
suggestedToolchain: 'gbdk-2020',
|
|
9
|
+
outputExtension: '.gb',
|
|
10
|
+
budgets: Object.freeze({
|
|
11
|
+
palettes: 1,
|
|
12
|
+
tiles: 192,
|
|
13
|
+
sprites: 40,
|
|
14
|
+
fonts: 2,
|
|
15
|
+
glyphsPerFont: 96,
|
|
16
|
+
}),
|
|
17
|
+
}),
|
|
18
|
+
gbc: Object.freeze({
|
|
19
|
+
target: 'gbc',
|
|
20
|
+
displayName: 'Game Boy Color',
|
|
21
|
+
family: 'gb',
|
|
22
|
+
architecture: 'sm83',
|
|
23
|
+
colorMode: 'color',
|
|
24
|
+
suggestedToolchain: 'gbdk-2020',
|
|
25
|
+
outputExtension: '.gbc',
|
|
26
|
+
budgets: Object.freeze({
|
|
27
|
+
palettes: 8,
|
|
28
|
+
tiles: 256,
|
|
29
|
+
sprites: 40,
|
|
30
|
+
fonts: 2,
|
|
31
|
+
glyphsPerFont: 96,
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
gba: Object.freeze({
|
|
35
|
+
target: 'gba',
|
|
36
|
+
displayName: 'Game Boy Advance',
|
|
37
|
+
family: 'gba',
|
|
38
|
+
architecture: 'arm7tdmi',
|
|
39
|
+
colorMode: 'color',
|
|
40
|
+
suggestedToolchain: 'devkitARM',
|
|
41
|
+
outputExtension: '.gba',
|
|
42
|
+
budgets: Object.freeze({
|
|
43
|
+
palettes: 16,
|
|
44
|
+
tiles: 512,
|
|
45
|
+
sprites: 128,
|
|
46
|
+
fonts: 4,
|
|
47
|
+
glyphsPerFont: 128,
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const SUPPORTED_RETRO_BUILD_TARGETS = new Set(Object.keys(RETRO_TARGET_PROFILES));
|
|
53
|
+
|
|
54
|
+
export function isRetroBuildTarget(target) {
|
|
55
|
+
return SUPPORTED_RETRO_BUILD_TARGETS.has(String(target || '').trim().toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getRetroTargetProfile(target) {
|
|
59
|
+
const normalized = String(target || '').trim().toLowerCase();
|
|
60
|
+
if (!isRetroBuildTarget(normalized)) {
|
|
61
|
+
throw new Error(`Unsupported Aura Retro target "${target}". Supported values: gb, gbc, gba.`);
|
|
62
|
+
}
|
|
63
|
+
return RETRO_TARGET_PROFILES[normalized];
|
|
64
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { createRetroDiagnostic } from '../diagnostics/emit.mjs';
|
|
2
|
+
import { spanFromIndex } from '../shared/span.mjs';
|
|
3
|
+
import { loadRetroProjectGraph, summarizeRetroGraph } from '../frontend/load-project.mjs';
|
|
4
|
+
import { compileRetroAssets } from '../assets/compile.mjs';
|
|
5
|
+
|
|
6
|
+
const RULES = Object.freeze([
|
|
7
|
+
{
|
|
8
|
+
reasonCode: 'retro_async_unsupported',
|
|
9
|
+
regex: /(^|[^\w$])(?:async\s+function\b|await\b)/m,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
reasonCode: 'retro_eval_unsupported',
|
|
13
|
+
regex: /(^|[^\w$.])eval\s*\(/m,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
reasonCode: 'retro_dynamic_property_access_unsupported',
|
|
17
|
+
regex: /\[[A-Za-z_$][A-Za-z0-9_$]*\]/m,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
reasonCode: 'retro_runtime_asset_load_unsupported',
|
|
21
|
+
regex: /(^|[^\w$.])(?:fetch\s*\(|XMLHttpRequest\b|WebSocket\b|aura\.(?:assets|fs|net)\.)/m,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
reasonCode: 'retro_3d_api_unsupported',
|
|
25
|
+
regex: /\baura\.(?:draw3d|camera3d|light|mesh|material|scene3d|character3d)\b/m,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
reasonCode: 'retro_desktop_api_unsupported',
|
|
29
|
+
regex: /\baura\.(?:platform|net|multiplayer|fs|video)\b/m,
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const TARGET_RULES = Object.freeze({
|
|
34
|
+
gb: Object.freeze([
|
|
35
|
+
{
|
|
36
|
+
reasonCode: 'retro_gb_color_feature_unsupported',
|
|
37
|
+
regex: /\b(?:palette|color)\s*:/m,
|
|
38
|
+
},
|
|
39
|
+
]),
|
|
40
|
+
gbc: Object.freeze([]),
|
|
41
|
+
gba: Object.freeze([]),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function collectModuleDiagnostics(moduleMeta, target) {
|
|
45
|
+
const diagnostics = [];
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
|
|
48
|
+
const activeRules = [...RULES, ...(TARGET_RULES[target] || [])];
|
|
49
|
+
for (const rule of activeRules) {
|
|
50
|
+
const match = rule.regex.exec(moduleMeta.code);
|
|
51
|
+
if (!match || seen.has(rule.reasonCode)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
seen.add(rule.reasonCode);
|
|
55
|
+
const index = typeof match.index === 'number' ? match.index + (match[1]?.length || 0) : 0;
|
|
56
|
+
diagnostics.push(
|
|
57
|
+
createRetroDiagnostic({
|
|
58
|
+
reasonCode: rule.reasonCode,
|
|
59
|
+
filePath: moduleMeta.filePath,
|
|
60
|
+
span: spanFromIndex(moduleMeta.code, index, String(match[0] || '').length),
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return diagnostics;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function finalizeReport(frontend, diagnostics) {
|
|
69
|
+
const reasonCodes = [...new Set(diagnostics.map((entry) => entry.reasonCode))].sort();
|
|
70
|
+
const assetReport = compileRetroAssets({
|
|
71
|
+
projectRoot: frontend.projectRoot,
|
|
72
|
+
target: frontend.target,
|
|
73
|
+
});
|
|
74
|
+
const combinedDiagnostics = [...diagnostics, ...(assetReport.diagnostics || [])];
|
|
75
|
+
const combinedReasonCodes = [...new Set(combinedDiagnostics.map((entry) => entry.reasonCode))].sort();
|
|
76
|
+
return {
|
|
77
|
+
ok: combinedDiagnostics.length === 0,
|
|
78
|
+
valid: combinedDiagnostics.length === 0,
|
|
79
|
+
target: frontend.target,
|
|
80
|
+
targetProfile: frontend.targetProfile,
|
|
81
|
+
projectRoot: frontend.projectRoot,
|
|
82
|
+
entryFile: frontend.entryFile,
|
|
83
|
+
moduleCount: frontend.graph ? frontend.graph.order.length : 0,
|
|
84
|
+
modules: summarizeRetroGraph(frontend),
|
|
85
|
+
assets: assetReport.summary,
|
|
86
|
+
reasonCodes: combinedReasonCodes,
|
|
87
|
+
diagnostics: combinedDiagnostics,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function checkRetroProject(options = {}) {
|
|
92
|
+
const frontend = loadRetroProjectGraph(options);
|
|
93
|
+
if (!frontend.ok) {
|
|
94
|
+
return finalizeReport(frontend, frontend.diagnostics || []);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const diagnostics = [];
|
|
98
|
+
for (const filePath of frontend.graph.order) {
|
|
99
|
+
const moduleMeta = frontend.graph.modules.get(filePath);
|
|
100
|
+
diagnostics.push(...collectModuleDiagnostics(moduleMeta, frontend.target));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
diagnostics.sort((left, right) => {
|
|
104
|
+
const leftKey = `${left.filePath}:${left.span?.line || 0}:${left.reasonCode}`;
|
|
105
|
+
const rightKey = `${right.filePath}:${right.span?.line || 0}:${right.reasonCode}`;
|
|
106
|
+
return leftKey.localeCompare(rightKey);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return finalizeReport(frontend, diagnostics);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function explainRetroProject(options = {}) {
|
|
113
|
+
return checkRetroProject(options);
|
|
114
|
+
}
|