@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,146 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
|
|
3
|
+
const ALL_RETRO_TARGETS = Object.freeze(['gb', 'gbc', 'gba']);
|
|
4
|
+
|
|
5
|
+
export const RETRO_EMULATOR_PROFILES = Object.freeze([
|
|
6
|
+
Object.freeze({
|
|
7
|
+
id: 'mgba-headless',
|
|
8
|
+
commandNames: Object.freeze(['mgba-headless']),
|
|
9
|
+
supportedTargets: ALL_RETRO_TARGETS,
|
|
10
|
+
supportsHeadless: true,
|
|
11
|
+
preferForSmoke: true,
|
|
12
|
+
launchArgs: ({ romPath, scale }) => {
|
|
13
|
+
const args = [];
|
|
14
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
15
|
+
args.push('--scale', String(scale));
|
|
16
|
+
}
|
|
17
|
+
args.push(romPath);
|
|
18
|
+
return args;
|
|
19
|
+
},
|
|
20
|
+
smokeArgs: ({ romPath, scale }) => {
|
|
21
|
+
const args = [];
|
|
22
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
23
|
+
args.push('--scale', String(scale));
|
|
24
|
+
}
|
|
25
|
+
args.push(romPath);
|
|
26
|
+
return args;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
Object.freeze({
|
|
30
|
+
id: 'mgba',
|
|
31
|
+
commandNames: Object.freeze(['mgba']),
|
|
32
|
+
supportedTargets: ALL_RETRO_TARGETS,
|
|
33
|
+
supportsHeadless: false,
|
|
34
|
+
preferForSmoke: false,
|
|
35
|
+
launchArgs: ({ romPath, scale }) => {
|
|
36
|
+
const args = [];
|
|
37
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
38
|
+
args.push('--scale', String(scale));
|
|
39
|
+
}
|
|
40
|
+
args.push(romPath);
|
|
41
|
+
return args;
|
|
42
|
+
},
|
|
43
|
+
smokeArgs: ({ romPath, scale }) => {
|
|
44
|
+
const args = [];
|
|
45
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
46
|
+
args.push('--scale', String(scale));
|
|
47
|
+
}
|
|
48
|
+
args.push(romPath);
|
|
49
|
+
return args;
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
Object.freeze({
|
|
53
|
+
id: 'mgba-qt',
|
|
54
|
+
commandNames: Object.freeze(['mgba-qt']),
|
|
55
|
+
supportedTargets: ALL_RETRO_TARGETS,
|
|
56
|
+
supportsHeadless: false,
|
|
57
|
+
preferForSmoke: false,
|
|
58
|
+
launchArgs: ({ romPath, scale }) => {
|
|
59
|
+
const args = [];
|
|
60
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
61
|
+
args.push('--scale', String(scale));
|
|
62
|
+
}
|
|
63
|
+
args.push(romPath);
|
|
64
|
+
return args;
|
|
65
|
+
},
|
|
66
|
+
smokeArgs: ({ romPath, scale }) => {
|
|
67
|
+
const args = [];
|
|
68
|
+
if (Number.isFinite(scale) && scale > 0) {
|
|
69
|
+
args.push('--scale', String(scale));
|
|
70
|
+
}
|
|
71
|
+
args.push(romPath);
|
|
72
|
+
return args;
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
Object.freeze({
|
|
76
|
+
id: 'visualboyadvance-m',
|
|
77
|
+
commandNames: Object.freeze(['visualboyadvance-m']),
|
|
78
|
+
supportedTargets: ALL_RETRO_TARGETS,
|
|
79
|
+
supportsHeadless: false,
|
|
80
|
+
preferForSmoke: false,
|
|
81
|
+
launchArgs: ({ romPath }) => [romPath],
|
|
82
|
+
smokeArgs: ({ romPath }) => [romPath],
|
|
83
|
+
}),
|
|
84
|
+
Object.freeze({
|
|
85
|
+
id: 'sameboy',
|
|
86
|
+
commandNames: Object.freeze(['sameboy']),
|
|
87
|
+
supportedTargets: Object.freeze(['gb', 'gbc']),
|
|
88
|
+
supportsHeadless: false,
|
|
89
|
+
preferForSmoke: false,
|
|
90
|
+
launchArgs: ({ romPath }) => [romPath],
|
|
91
|
+
smokeArgs: ({ romPath }) => [romPath],
|
|
92
|
+
}),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
function normalizeExecutableName(value) {
|
|
96
|
+
return basename(String(value || '')).toLowerCase();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getRetroEmulatorProfile(profileId) {
|
|
100
|
+
return RETRO_EMULATOR_PROFILES.find((entry) => entry.id === profileId) || null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function detectRetroEmulatorProfile(executablePath) {
|
|
104
|
+
const name = normalizeExecutableName(executablePath);
|
|
105
|
+
for (const profile of RETRO_EMULATOR_PROFILES) {
|
|
106
|
+
if (profile.commandNames.includes(name)) {
|
|
107
|
+
return profile;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getRetroEmulatorCandidateNames({ target, smoke = false } = {}) {
|
|
114
|
+
const names = [];
|
|
115
|
+
for (const profile of RETRO_EMULATOR_PROFILES) {
|
|
116
|
+
if (!profile.supportedTargets.includes(target)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (smoke && !profile.supportsHeadless) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
for (const commandName of profile.commandNames) {
|
|
123
|
+
if (!names.includes(commandName)) {
|
|
124
|
+
names.push(commandName);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return names;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function supportsRetroEmulatorTarget(profile, target) {
|
|
132
|
+
return Array.isArray(profile?.supportedTargets) && profile.supportedTargets.includes(target);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function buildRetroEmulatorArgs(profile, { romPath, smoke = false, headless = false, scale = null }) {
|
|
136
|
+
if (!profile) {
|
|
137
|
+
return [romPath];
|
|
138
|
+
}
|
|
139
|
+
if (smoke && typeof profile.smokeArgs === 'function') {
|
|
140
|
+
return profile.smokeArgs({ romPath, headless, scale });
|
|
141
|
+
}
|
|
142
|
+
if (!smoke && typeof profile.launchArgs === 'function') {
|
|
143
|
+
return profile.launchArgs({ romPath, headless, scale });
|
|
144
|
+
}
|
|
145
|
+
return [romPath];
|
|
146
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { basename, extname, resolve } from 'node:path';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { RetroCompileError } from '../diagnostics/emit.mjs';
|
|
5
|
+
import { discoverRetroEmulator } from './discovery.mjs';
|
|
6
|
+
import { launchRetroCaseOverlay, shouldUseRetroCaseOverlay } from './case-overlay.mjs';
|
|
7
|
+
|
|
8
|
+
const TARGET_EXTENSION_MAP = Object.freeze({
|
|
9
|
+
'.gb': 'gb',
|
|
10
|
+
'.gbc': 'gbc',
|
|
11
|
+
'.gba': 'gba',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function inferTargetFromRomPath(romPath) {
|
|
15
|
+
return TARGET_EXTENSION_MAP[extname(String(romPath || '')).toLowerCase()] || null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function resolveBuiltRomFromManifest({ projectRoot, target }) {
|
|
19
|
+
const manifestPath = resolve(projectRoot, 'build', target, 'retro-build-manifest.json');
|
|
20
|
+
if (!existsSync(manifestPath)) {
|
|
21
|
+
throw new RetroCompileError(
|
|
22
|
+
'retro_emulator_rom_not_found',
|
|
23
|
+
`No Retro build manifest was found for target "${target}". Run \`aura build --target ${target}\` first.`,
|
|
24
|
+
{ manifestPath, target },
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
28
|
+
const romPath = typeof manifest?.romPath === 'string' && manifest.romPath.trim().length > 0
|
|
29
|
+
? resolve(projectRoot, manifest.romPath)
|
|
30
|
+
: null;
|
|
31
|
+
if (!romPath || !existsSync(romPath)) {
|
|
32
|
+
throw new RetroCompileError(
|
|
33
|
+
'retro_emulator_rom_not_found',
|
|
34
|
+
`The Retro build manifest for target "${target}" does not point to a usable ROM artifact.`,
|
|
35
|
+
{ manifestPath, romPath, target },
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
target,
|
|
40
|
+
romPath,
|
|
41
|
+
manifestPath,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resolveRetroRom({ projectRoot, target, romPath }) {
|
|
46
|
+
const explicitRomPath = String(romPath || '').trim();
|
|
47
|
+
if (explicitRomPath) {
|
|
48
|
+
const absoluteRomPath = resolve(projectRoot, explicitRomPath);
|
|
49
|
+
if (!existsSync(absoluteRomPath)) {
|
|
50
|
+
throw new RetroCompileError(
|
|
51
|
+
'retro_emulator_rom_not_found',
|
|
52
|
+
`Retro ROM path "${explicitRomPath}" does not exist.`,
|
|
53
|
+
{ romPath: absoluteRomPath },
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const inferredTarget = inferTargetFromRomPath(absoluteRomPath);
|
|
57
|
+
return {
|
|
58
|
+
target: target || inferredTarget,
|
|
59
|
+
romPath: absoluteRomPath,
|
|
60
|
+
manifestPath: null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!target) {
|
|
64
|
+
throw new RetroCompileError(
|
|
65
|
+
'retro_emulator_rom_not_found',
|
|
66
|
+
'Missing retro target or explicit ROM path. Use `--target <gb|gbc|gba>` or pass `--rom <path>`.',
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return resolveBuiltRomFromManifest({ projectRoot, target });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function formatCheckedCandidates(checked) {
|
|
73
|
+
return checked.map((entry) => entry.command).filter(Boolean).join(', ');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function spawnAndWait(child, { timeoutMs = null, allowTimeoutSuccess = false }) {
|
|
77
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
78
|
+
let finished = false;
|
|
79
|
+
let timeoutId = null;
|
|
80
|
+
if (Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
81
|
+
timeoutId = setTimeout(() => {
|
|
82
|
+
if (finished) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
finished = true;
|
|
86
|
+
child.kill('SIGTERM');
|
|
87
|
+
resolvePromise({
|
|
88
|
+
status: 'timed_out',
|
|
89
|
+
code: null,
|
|
90
|
+
signal: 'SIGTERM',
|
|
91
|
+
timedOut: true,
|
|
92
|
+
ok: allowTimeoutSuccess,
|
|
93
|
+
});
|
|
94
|
+
}, timeoutMs);
|
|
95
|
+
}
|
|
96
|
+
child.once('error', (error) => {
|
|
97
|
+
if (finished) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
finished = true;
|
|
101
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
102
|
+
rejectPromise(error);
|
|
103
|
+
});
|
|
104
|
+
child.once('exit', (code, signal) => {
|
|
105
|
+
if (finished) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
finished = true;
|
|
109
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
110
|
+
resolvePromise({
|
|
111
|
+
status: code === 0 ? 'exited' : 'failed',
|
|
112
|
+
code,
|
|
113
|
+
signal,
|
|
114
|
+
timedOut: false,
|
|
115
|
+
ok: code === 0,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function runRetroEmulator({
|
|
122
|
+
projectRoot = process.cwd(),
|
|
123
|
+
target = null,
|
|
124
|
+
romPath = null,
|
|
125
|
+
emulator = null,
|
|
126
|
+
headless = false,
|
|
127
|
+
scale = null,
|
|
128
|
+
caseOverlay = false,
|
|
129
|
+
} = {}) {
|
|
130
|
+
const resolvedRom = resolveRetroRom({ projectRoot, target, romPath });
|
|
131
|
+
const discovery = discoverRetroEmulator({
|
|
132
|
+
target: resolvedRom.target,
|
|
133
|
+
explicitEmulator: emulator,
|
|
134
|
+
smoke: false,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (discovery.unsupportedProfile) {
|
|
138
|
+
throw new RetroCompileError(
|
|
139
|
+
'retro_emulator_target_unsupported',
|
|
140
|
+
`Emulator "${discovery.unsupportedProfile.id}" does not support target "${resolvedRom.target}".`,
|
|
141
|
+
{ checked: discovery.checked, target: resolvedRom.target },
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (!discovery.emulator) {
|
|
145
|
+
throw new RetroCompileError(
|
|
146
|
+
'retro_emulator_not_found',
|
|
147
|
+
`No supported emulator was found for target "${resolvedRom.target}". Tried: ${formatCheckedCandidates(discovery.checked) || '<none>'}.`,
|
|
148
|
+
{ checked: discovery.checked, target: resolvedRom.target },
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const args = discovery.emulator.argsFor({
|
|
153
|
+
romPath: resolvedRom.romPath,
|
|
154
|
+
smoke: false,
|
|
155
|
+
headless,
|
|
156
|
+
scale,
|
|
157
|
+
});
|
|
158
|
+
const child = spawn(discovery.emulator.executablePath, args, {
|
|
159
|
+
cwd: projectRoot,
|
|
160
|
+
stdio: 'inherit',
|
|
161
|
+
env: process.env,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
let overlayChild = null;
|
|
165
|
+
if (shouldUseRetroCaseOverlay({
|
|
166
|
+
caseEnabled: caseOverlay,
|
|
167
|
+
profileId: discovery.emulator.profile?.id || null,
|
|
168
|
+
headless,
|
|
169
|
+
})) {
|
|
170
|
+
overlayChild = launchRetroCaseOverlay({
|
|
171
|
+
emulatorPid: child.pid,
|
|
172
|
+
profileId: discovery.emulator.profile?.id || null,
|
|
173
|
+
});
|
|
174
|
+
if (!overlayChild) {
|
|
175
|
+
process.stderr.write('Aura Retro: could not attach the macOS case overlay. The emulator will keep running without it.\n');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const result = await spawnAndWait(child, { timeoutMs: null, allowTimeoutSuccess: false });
|
|
180
|
+
if (overlayChild && !overlayChild.killed) {
|
|
181
|
+
overlayChild.kill('SIGTERM');
|
|
182
|
+
}
|
|
183
|
+
if (!result.ok) {
|
|
184
|
+
throw new RetroCompileError(
|
|
185
|
+
'retro_emulator_launch_failed',
|
|
186
|
+
`Emulator "${basename(discovery.emulator.executablePath)}" exited unexpectedly while launching "${basename(resolvedRom.romPath)}".`,
|
|
187
|
+
{ result, romPath: resolvedRom.romPath, executablePath: discovery.emulator.executablePath },
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
ok: true,
|
|
192
|
+
status: 'passed',
|
|
193
|
+
target: resolvedRom.target,
|
|
194
|
+
romPath: resolvedRom.romPath,
|
|
195
|
+
emulatorId: discovery.emulator.profile?.id || 'custom',
|
|
196
|
+
executablePath: discovery.emulator.executablePath,
|
|
197
|
+
caseOverlay: Boolean(caseOverlay && overlayChild),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function smokeRetroEmulator({
|
|
202
|
+
projectRoot = process.cwd(),
|
|
203
|
+
target = null,
|
|
204
|
+
romPath = null,
|
|
205
|
+
emulator = null,
|
|
206
|
+
timeoutMs = 1500,
|
|
207
|
+
} = {}) {
|
|
208
|
+
const resolvedRom = resolveRetroRom({ projectRoot, target, romPath });
|
|
209
|
+
const discovery = discoverRetroEmulator({
|
|
210
|
+
target: resolvedRom.target,
|
|
211
|
+
explicitEmulator: emulator,
|
|
212
|
+
smoke: true,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (discovery.unsupportedProfile) {
|
|
216
|
+
throw new RetroCompileError(
|
|
217
|
+
'retro_emulator_target_unsupported',
|
|
218
|
+
`Emulator "${discovery.unsupportedProfile.id}" does not support target "${resolvedRom.target}".`,
|
|
219
|
+
{ checked: discovery.checked, target: resolvedRom.target },
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
if (!discovery.emulator) {
|
|
223
|
+
return {
|
|
224
|
+
ok: true,
|
|
225
|
+
status: 'skipped',
|
|
226
|
+
reasonCode: 'retro_emulator_not_found',
|
|
227
|
+
target: resolvedRom.target,
|
|
228
|
+
romPath: resolvedRom.romPath,
|
|
229
|
+
checked: discovery.checked,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const args = discovery.emulator.argsFor({
|
|
234
|
+
romPath: resolvedRom.romPath,
|
|
235
|
+
smoke: true,
|
|
236
|
+
headless: true,
|
|
237
|
+
scale: null,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const child = spawn(discovery.emulator.executablePath, args, {
|
|
241
|
+
cwd: projectRoot,
|
|
242
|
+
stdio: 'ignore',
|
|
243
|
+
env: process.env,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
let result;
|
|
247
|
+
try {
|
|
248
|
+
result = await spawnAndWait(child, {
|
|
249
|
+
timeoutMs,
|
|
250
|
+
allowTimeoutSuccess: true,
|
|
251
|
+
});
|
|
252
|
+
} catch (error) {
|
|
253
|
+
throw new RetroCompileError(
|
|
254
|
+
'retro_emulator_launch_failed',
|
|
255
|
+
`Failed to launch emulator "${basename(discovery.emulator.executablePath)}" for "${basename(resolvedRom.romPath)}".`,
|
|
256
|
+
{
|
|
257
|
+
target: resolvedRom.target,
|
|
258
|
+
romPath: resolvedRom.romPath,
|
|
259
|
+
executablePath: discovery.emulator.executablePath,
|
|
260
|
+
cause: error instanceof Error ? error.message : String(error),
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (!result.ok) {
|
|
266
|
+
throw new RetroCompileError(
|
|
267
|
+
'retro_emulator_launch_failed',
|
|
268
|
+
`Emulator "${basename(discovery.emulator.executablePath)}" failed while boot-checking "${basename(resolvedRom.romPath)}".`,
|
|
269
|
+
{
|
|
270
|
+
target: resolvedRom.target,
|
|
271
|
+
romPath: resolvedRom.romPath,
|
|
272
|
+
executablePath: discovery.emulator.executablePath,
|
|
273
|
+
result,
|
|
274
|
+
},
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
ok: true,
|
|
280
|
+
status: 'passed',
|
|
281
|
+
reasonCode: result.timedOut ? 'retro_emulator_boot_smoke_passed' : 'retro_emulator_boot_smoke_exited_cleanly',
|
|
282
|
+
target: resolvedRom.target,
|
|
283
|
+
romPath: resolvedRom.romPath,
|
|
284
|
+
emulatorId: discovery.emulator.profile?.id || 'custom',
|
|
285
|
+
executablePath: discovery.emulator.executablePath,
|
|
286
|
+
timeoutMs,
|
|
287
|
+
checked: discovery.checked,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
2
|
+
import {
|
|
3
|
+
inspectProjectModuleGraph,
|
|
4
|
+
isBundleError,
|
|
5
|
+
BUNDLE_ERROR_CODES,
|
|
6
|
+
} from '../../bundler.mjs';
|
|
7
|
+
import { createRetroDiagnostic } from '../diagnostics/emit.mjs';
|
|
8
|
+
import { getRetroTargetProfile } from '../shared/targets.mjs';
|
|
9
|
+
|
|
10
|
+
function normalizePath(projectRoot, value) {
|
|
11
|
+
if (!value) return null;
|
|
12
|
+
return isAbsolute(value) ? value : resolve(projectRoot, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function mapBundleErrorToDiagnostic(error) {
|
|
16
|
+
const detailMap = {
|
|
17
|
+
[BUNDLE_ERROR_CODES.SYNTAX_ERROR]: 'retro_module_syntax_error',
|
|
18
|
+
[BUNDLE_ERROR_CODES.MODULE_NOT_FOUND]: 'retro_module_not_found',
|
|
19
|
+
[BUNDLE_ERROR_CODES.UNSUPPORTED_SPECIFIER]: 'retro_import_specifier_unsupported',
|
|
20
|
+
[BUNDLE_ERROR_CODES.PATH_ESCAPE]: 'retro_import_path_escape',
|
|
21
|
+
[BUNDLE_ERROR_CODES.DYNAMIC_IMPORT]: 'retro_dynamic_import_unsupported',
|
|
22
|
+
[BUNDLE_ERROR_CODES.CIRCULAR_DEP]: 'retro_circular_dependency_unsupported',
|
|
23
|
+
};
|
|
24
|
+
const reasonCode = detailMap[error.code] || 'retro_module_syntax_error';
|
|
25
|
+
return createRetroDiagnostic({
|
|
26
|
+
reasonCode,
|
|
27
|
+
filePath: error.details?.file || error.details?.importer || null,
|
|
28
|
+
span: {
|
|
29
|
+
line: error.details?.line || null,
|
|
30
|
+
column: error.details?.column || 1,
|
|
31
|
+
endLine: error.details?.line || null,
|
|
32
|
+
endColumn: error.details?.column || 1,
|
|
33
|
+
},
|
|
34
|
+
message: error.message,
|
|
35
|
+
source: 'retro-frontend',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function loadRetroProjectGraph(options = {}) {
|
|
40
|
+
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
41
|
+
const targetProfile = getRetroTargetProfile(options.target || 'gbc');
|
|
42
|
+
const entryFile = normalizePath(projectRoot, options.entryFile || 'src/main.js');
|
|
43
|
+
const sourceRoots = Array.isArray(options.sourceRoots) && options.sourceRoots.length > 0
|
|
44
|
+
? options.sourceRoots.map((value) => normalizePath(projectRoot, value))
|
|
45
|
+
: [resolve(projectRoot, 'src')];
|
|
46
|
+
const moduleRoot = normalizePath(projectRoot, options.moduleRoot || sourceRoots[0] || projectRoot);
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const graph = inspectProjectModuleGraph({
|
|
50
|
+
projectRoot,
|
|
51
|
+
entryFile,
|
|
52
|
+
moduleRoot,
|
|
53
|
+
allowedSourceRoots: sourceRoots,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
ok: true,
|
|
57
|
+
target: targetProfile.target,
|
|
58
|
+
targetProfile,
|
|
59
|
+
projectRoot,
|
|
60
|
+
entryFile,
|
|
61
|
+
moduleRoot,
|
|
62
|
+
sourceRoots,
|
|
63
|
+
graph,
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (isBundleError(error)) {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
target: targetProfile.target,
|
|
70
|
+
targetProfile,
|
|
71
|
+
projectRoot,
|
|
72
|
+
entryFile,
|
|
73
|
+
moduleRoot,
|
|
74
|
+
sourceRoots,
|
|
75
|
+
graph: null,
|
|
76
|
+
diagnostics: [mapBundleErrorToDiagnostic(error)],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function summarizeRetroGraph(frontend) {
|
|
84
|
+
const graph = frontend?.graph;
|
|
85
|
+
if (!graph) return [];
|
|
86
|
+
return graph.order.map((filePath) => {
|
|
87
|
+
const moduleMeta = graph.modules.get(filePath);
|
|
88
|
+
return {
|
|
89
|
+
id: moduleMeta.id,
|
|
90
|
+
filePath: moduleMeta.filePath,
|
|
91
|
+
imports: moduleMeta.imports.map((entry) => ({
|
|
92
|
+
specifier: entry.specifier,
|
|
93
|
+
resolved: entry.resolved,
|
|
94
|
+
line: entry.line,
|
|
95
|
+
})),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { buildRetroProject } from './build.mjs';
|
|
2
|
+
export { compileRetroAssets } from './assets/compile.mjs';
|
|
3
|
+
export { buildRetroIr } from './ir/build-ir.mjs';
|
|
4
|
+
export { buildGameBoyRom, computeGlobalChecksum, computeHeaderChecksum } from './backend-gbc/rom.mjs';
|
|
5
|
+
export { buildGameBoyAdvanceRom, computeGbaHeaderComplementCheck } from './backend-gba/rom.mjs';
|
|
6
|
+
export {
|
|
7
|
+
RetroCompileError,
|
|
8
|
+
formatRetroCompileError,
|
|
9
|
+
formatRetroDiagnosticReport,
|
|
10
|
+
} from './diagnostics/emit.mjs';
|
|
11
|
+
export { loadRetroProjectGraph } from './frontend/load-project.mjs';
|
|
12
|
+
export { explainRetroProject, checkRetroProject } from './validator/check-project.mjs';
|
|
13
|
+
export {
|
|
14
|
+
RETRO_TARGET_PROFILES,
|
|
15
|
+
SUPPORTED_RETRO_BUILD_TARGETS,
|
|
16
|
+
getRetroTargetProfile,
|
|
17
|
+
isRetroBuildTarget,
|
|
18
|
+
} from './shared/targets.mjs';
|
|
19
|
+
export { createGbcRuntimeContract } from './runtime-gbc/contract.mjs';
|
|
20
|
+
export { createGbaRuntimeContract } from './runtime-gba/contract.mjs';
|
|
21
|
+
export { discoverRetroEmulator } from './emulator/discovery.mjs';
|
|
22
|
+
export { runRetroEmulator, smokeRetroEmulator } from './emulator/runner.mjs';
|
|
23
|
+
export {
|
|
24
|
+
runRetroCommand,
|
|
25
|
+
runRetroCheckCommand,
|
|
26
|
+
runRetroExplainCommand,
|
|
27
|
+
runRetroRunCommand,
|
|
28
|
+
runRetroSmokeCommand,
|
|
29
|
+
RetroCliArgumentError,
|
|
30
|
+
} from './cli/commands.mjs';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { loadRetroProjectGraph } from '../frontend/load-project.mjs';
|
|
3
|
+
import { checkRetroProject } from '../validator/check-project.mjs';
|
|
4
|
+
import { RetroCompileError } from '../diagnostics/emit.mjs';
|
|
5
|
+
|
|
6
|
+
const RUNTIME_HANDLE_PATTERNS = Object.freeze([
|
|
7
|
+
['input', /\baura\.input\./g],
|
|
8
|
+
['sprite', /\baura\.sprite\./g],
|
|
9
|
+
['tilemap', /\baura\.tilemap\./g],
|
|
10
|
+
['text', /\baura\.text\./g],
|
|
11
|
+
['audio', /\baura\.audio\./g],
|
|
12
|
+
['save', /\baura\.save\./g],
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
function scanLifecycle(code) {
|
|
16
|
+
return {
|
|
17
|
+
exportsState: /\bexport\s+const\s+state\b/.test(code),
|
|
18
|
+
exportsSetup: /\bexport\s+function\s+setup\s*\(/.test(code),
|
|
19
|
+
exportsUpdate: /\bexport\s+function\s+update\s*\(/.test(code),
|
|
20
|
+
exportsDraw: /\bexport\s+function\s+draw\s*\(/.test(code),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function scanRuntimeHandles(code) {
|
|
25
|
+
const handles = [];
|
|
26
|
+
for (const [name, pattern] of RUNTIME_HANDLE_PATTERNS) {
|
|
27
|
+
if (pattern.test(code)) {
|
|
28
|
+
handles.push(name);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return handles;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function buildRetroIr(options = {}) {
|
|
35
|
+
const validation = checkRetroProject(options);
|
|
36
|
+
if (!validation.ok) {
|
|
37
|
+
throw new RetroCompileError(
|
|
38
|
+
'retro_build_blocked_by_diagnostics',
|
|
39
|
+
'Aura Retro IR build is blocked by compiler diagnostics.',
|
|
40
|
+
{ diagnostics: validation.diagnostics, report: validation },
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const frontend = loadRetroProjectGraph(options);
|
|
45
|
+
if (!frontend.ok) {
|
|
46
|
+
throw new RetroCompileError(
|
|
47
|
+
'retro_build_blocked_by_diagnostics',
|
|
48
|
+
'Aura Retro IR build could not load the project graph.',
|
|
49
|
+
{ diagnostics: frontend.diagnostics || [] },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const lifecycle = {
|
|
54
|
+
setup: [],
|
|
55
|
+
update: [],
|
|
56
|
+
draw: [],
|
|
57
|
+
};
|
|
58
|
+
let stateOwner = null;
|
|
59
|
+
const modules = frontend.graph.order.map((filePath) => {
|
|
60
|
+
const moduleMeta = frontend.graph.modules.get(filePath);
|
|
61
|
+
const code = readFileSync(filePath, 'utf8');
|
|
62
|
+
const flags = scanLifecycle(code);
|
|
63
|
+
const runtimeHandles = scanRuntimeHandles(code);
|
|
64
|
+
if (flags.exportsState && !stateOwner) {
|
|
65
|
+
stateOwner = moduleMeta.id;
|
|
66
|
+
}
|
|
67
|
+
if (flags.exportsSetup) lifecycle.setup.push(moduleMeta.id);
|
|
68
|
+
if (flags.exportsUpdate) lifecycle.update.push(moduleMeta.id);
|
|
69
|
+
if (flags.exportsDraw) lifecycle.draw.push(moduleMeta.id);
|
|
70
|
+
return {
|
|
71
|
+
id: moduleMeta.id,
|
|
72
|
+
filePath: moduleMeta.filePath,
|
|
73
|
+
imports: moduleMeta.imports.map((entry) => ({
|
|
74
|
+
specifier: entry.specifier,
|
|
75
|
+
resolved: entry.resolved,
|
|
76
|
+
targetModuleId: frontend.graph.modules.get(entry.resolved)?.id || null,
|
|
77
|
+
})),
|
|
78
|
+
exports: {
|
|
79
|
+
state: flags.exportsState,
|
|
80
|
+
setup: flags.exportsSetup,
|
|
81
|
+
update: flags.exportsUpdate,
|
|
82
|
+
draw: flags.exportsDraw,
|
|
83
|
+
},
|
|
84
|
+
runtimeHandles,
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
schemaVersion: 1,
|
|
90
|
+
target: frontend.target,
|
|
91
|
+
targetProfile: frontend.targetProfile,
|
|
92
|
+
entryFile: frontend.entryFile,
|
|
93
|
+
moduleCount: modules.length,
|
|
94
|
+
modules,
|
|
95
|
+
lifecycle,
|
|
96
|
+
state: {
|
|
97
|
+
ownerModuleId: stateOwner,
|
|
98
|
+
exportName: stateOwner ? 'state' : null,
|
|
99
|
+
representation: stateOwner ? 'plain-object-export' : 'none',
|
|
100
|
+
},
|
|
101
|
+
runtimeOwnership: {
|
|
102
|
+
setupOwners: lifecycle.setup,
|
|
103
|
+
updateOwners: lifecycle.update,
|
|
104
|
+
drawOwners: lifecycle.draw,
|
|
105
|
+
handles: [...new Set(modules.flatMap((entry) => entry.runtimeHandles))].sort(),
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|