@auraindustry/aurajs 0.0.7 → 0.1.1
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 +8 -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 +4840 -1512
- package/src/commands/project-authoring.mjs +454 -0
- package/src/config.mjs +44 -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 +439 -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 +41 -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 +16 -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 +472 -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 +65 -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 +1192 -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
package/src/bundler.mjs
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
readdirSync,
|
|
10
10
|
watch,
|
|
11
11
|
} from 'node:fs';
|
|
12
|
-
import { dirname, join, normalize, relative, resolve, sep } from 'node:path';
|
|
12
|
+
import { dirname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path';
|
|
13
|
+
import { buildGameActionRuntimeBootstrapSource } from './game-action-runtime.mjs';
|
|
14
|
+
import { buildStateRestoreRuntimeBootstrapSource } from './game-state-runtime.mjs';
|
|
13
15
|
|
|
14
16
|
export const BUNDLE_ERROR_CODES = {
|
|
15
17
|
MISSING_ENTRY: 'AURA_MOD_001',
|
|
@@ -30,6 +32,16 @@ class BundleError extends Error {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
const AUTHORED_SOURCE_ROOT_DIRS = Object.freeze([
|
|
36
|
+
'src',
|
|
37
|
+
'scenes',
|
|
38
|
+
'ui',
|
|
39
|
+
'prefabs',
|
|
40
|
+
'config',
|
|
41
|
+
'content',
|
|
42
|
+
'data',
|
|
43
|
+
]);
|
|
44
|
+
|
|
33
45
|
export function isBundleError(error) {
|
|
34
46
|
return error instanceof BundleError;
|
|
35
47
|
}
|
|
@@ -123,16 +135,12 @@ export function bundleProject(options = {}) {
|
|
|
123
135
|
);
|
|
124
136
|
}
|
|
125
137
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const graph = buildModuleGraph({ srcDir, entryFile, cache });
|
|
138
|
+
const graph = inspectProjectModuleGraph({
|
|
139
|
+
projectRoot,
|
|
140
|
+
entryFile,
|
|
141
|
+
cache,
|
|
142
|
+
moduleRoot: srcDir,
|
|
143
|
+
});
|
|
136
144
|
const bundleText = emitBundle(graph);
|
|
137
145
|
const bundleHash = sha1(bundleText);
|
|
138
146
|
|
|
@@ -158,6 +166,37 @@ export function bundleProject(options = {}) {
|
|
|
158
166
|
};
|
|
159
167
|
}
|
|
160
168
|
|
|
169
|
+
export function inspectProjectModuleGraph(options = {}) {
|
|
170
|
+
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
171
|
+
const cache = options.cache || { files: new Map() };
|
|
172
|
+
const entryFile = options.entryFile
|
|
173
|
+
? resolve(projectRoot, options.entryFile)
|
|
174
|
+
: resolve(projectRoot, 'src/main.js');
|
|
175
|
+
const moduleRoot = resolve(options.moduleRoot || resolve(projectRoot, 'src'));
|
|
176
|
+
const allowedSourceRoots = resolveAllowedSourceRoots(
|
|
177
|
+
projectRoot,
|
|
178
|
+
options.allowedSourceRoots || options.sourceRootDirs || null,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (!existsSync(entryFile)) {
|
|
182
|
+
throw new BundleError(
|
|
183
|
+
BUNDLE_ERROR_CODES.MISSING_ENTRY,
|
|
184
|
+
`Missing entrypoint ${relPath(projectRoot, entryFile)}.`,
|
|
185
|
+
{ file: entryFile },
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
ensureEntryWithinSource(projectRoot, allowedSourceRoots, entryFile);
|
|
190
|
+
|
|
191
|
+
return buildModuleGraph({
|
|
192
|
+
projectRoot,
|
|
193
|
+
srcDir: moduleRoot,
|
|
194
|
+
entryFile,
|
|
195
|
+
cache,
|
|
196
|
+
allowedSourceRoots,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
161
200
|
function buildModuleGraph(ctx) {
|
|
162
201
|
const state = new Map();
|
|
163
202
|
const modules = new Map();
|
|
@@ -192,7 +231,13 @@ function buildModuleGraph(ctx) {
|
|
|
192
231
|
const dependencies = [];
|
|
193
232
|
|
|
194
233
|
for (const entry of parsed.imports) {
|
|
195
|
-
const resolved = resolveSpecifier(
|
|
234
|
+
const resolved = resolveSpecifier(
|
|
235
|
+
ctx.projectRoot,
|
|
236
|
+
ctx.allowedSourceRoots,
|
|
237
|
+
ctx.srcDir,
|
|
238
|
+
filePath,
|
|
239
|
+
entry,
|
|
240
|
+
);
|
|
196
241
|
dependencies.push({ ...entry, resolved });
|
|
197
242
|
visit(resolved, [...stack, filePath]);
|
|
198
243
|
}
|
|
@@ -211,6 +256,8 @@ function buildModuleGraph(ctx) {
|
|
|
211
256
|
|
|
212
257
|
function emitBundle(graph) {
|
|
213
258
|
const lines = [];
|
|
259
|
+
const stateRuntimeBootstrap = buildStateRestoreRuntimeBootstrapSource();
|
|
260
|
+
const actionRuntimeBootstrap = buildGameActionRuntimeBootstrapSource();
|
|
214
261
|
lines.push('// AuraJS bundle v1');
|
|
215
262
|
lines.push('// Generated by AuraJS bundler (AS-043 semantics, AS-004 module rules)');
|
|
216
263
|
lines.push('(function(){');
|
|
@@ -240,6 +287,9 @@ function emitBundle(graph) {
|
|
|
240
287
|
lines.push(' return module.exports;');
|
|
241
288
|
lines.push(' }');
|
|
242
289
|
lines.push('');
|
|
290
|
+
lines.push(` ${stateRuntimeBootstrap}`);
|
|
291
|
+
lines.push(` ${actionRuntimeBootstrap}`);
|
|
292
|
+
lines.push('');
|
|
243
293
|
lines.push(` __require(${JSON.stringify(graph.entryId)});`);
|
|
244
294
|
lines.push('})();');
|
|
245
295
|
lines.push('');
|
|
@@ -249,8 +299,12 @@ function emitBundle(graph) {
|
|
|
249
299
|
|
|
250
300
|
function transformModule(moduleMeta, srcDir) {
|
|
251
301
|
const importByLine = new Map();
|
|
302
|
+
const importContinuationLines = new Set();
|
|
252
303
|
for (const item of moduleMeta.imports) {
|
|
253
304
|
importByLine.set(item.line, item);
|
|
305
|
+
for (let line = item.line + 1; line <= item.endLine; line += 1) {
|
|
306
|
+
importContinuationLines.add(line);
|
|
307
|
+
}
|
|
254
308
|
}
|
|
255
309
|
|
|
256
310
|
const out = [];
|
|
@@ -271,6 +325,10 @@ function transformModule(moduleMeta, srcDir) {
|
|
|
271
325
|
continue;
|
|
272
326
|
}
|
|
273
327
|
|
|
328
|
+
if (importContinuationLines.has(lineNo)) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
274
332
|
const transformedExport = transformExportLine(source, lineNo, moduleMeta.filePath, exportAssignments);
|
|
275
333
|
out.push(...transformedExport);
|
|
276
334
|
}
|
|
@@ -464,31 +522,34 @@ function scanImports(code, filePath) {
|
|
|
464
522
|
}
|
|
465
523
|
|
|
466
524
|
const lineNo = idx + 1;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
525
|
+
let endIdx = idx;
|
|
526
|
+
let statement = line;
|
|
527
|
+
let parsed = parseImportStatement(statement);
|
|
528
|
+
|
|
529
|
+
while (!parsed && endIdx + 1 < lines.length) {
|
|
530
|
+
if (statement.trim().endsWith(';')) {
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
endIdx += 1;
|
|
534
|
+
statement += `\n${lines[endIdx]}`;
|
|
535
|
+
parsed = parseImportStatement(statement);
|
|
476
536
|
}
|
|
477
537
|
|
|
478
|
-
|
|
479
|
-
if (fromImport) {
|
|
538
|
+
if (parsed) {
|
|
480
539
|
imports.push({
|
|
481
540
|
line: lineNo,
|
|
482
541
|
column: line.indexOf('import') + 1,
|
|
483
|
-
|
|
484
|
-
|
|
542
|
+
endLine: endIdx + 1,
|
|
543
|
+
clause: parsed.clause,
|
|
544
|
+
specifier: parsed.specifier,
|
|
485
545
|
});
|
|
546
|
+
idx = endIdx;
|
|
486
547
|
continue;
|
|
487
548
|
}
|
|
488
549
|
|
|
489
550
|
throw new BundleError(
|
|
490
551
|
BUNDLE_ERROR_CODES.SYNTAX_ERROR,
|
|
491
|
-
'Unsupported import syntax. Use
|
|
552
|
+
'Unsupported import syntax. Use static relative imports.',
|
|
492
553
|
{ file: filePath, line: lineNo },
|
|
493
554
|
);
|
|
494
555
|
}
|
|
@@ -496,7 +557,28 @@ function scanImports(code, filePath) {
|
|
|
496
557
|
return imports;
|
|
497
558
|
}
|
|
498
559
|
|
|
499
|
-
function
|
|
560
|
+
function parseImportStatement(statement) {
|
|
561
|
+
const normalized = statement.replace(/\s+/g, ' ').trim();
|
|
562
|
+
const sideEffect = normalized.match(/^import\s+['"]([^'"\n]+)['"]\s*;?$/);
|
|
563
|
+
if (sideEffect) {
|
|
564
|
+
return {
|
|
565
|
+
clause: null,
|
|
566
|
+
specifier: sideEffect[1],
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const fromImport = normalized.match(/^import\s+(.+?)\s+from\s+['"]([^'"\n]+)['"]\s*;?$/);
|
|
571
|
+
if (fromImport) {
|
|
572
|
+
return {
|
|
573
|
+
clause: fromImport[1].trim(),
|
|
574
|
+
specifier: fromImport[2],
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function resolveSpecifier(projectRoot, allowedSourceRoots, srcDir, importer, importEntry) {
|
|
500
582
|
const specifier = importEntry.specifier;
|
|
501
583
|
|
|
502
584
|
if (!(specifier.startsWith('./') || specifier.startsWith('../'))) {
|
|
@@ -522,7 +604,7 @@ function resolveSpecifier(srcDir, importer, importEntry) {
|
|
|
522
604
|
];
|
|
523
605
|
|
|
524
606
|
for (const candidate of candidates) {
|
|
525
|
-
ensureWithinSource(
|
|
607
|
+
ensureWithinSource(projectRoot, allowedSourceRoots, candidate, importer, importEntry);
|
|
526
608
|
if (existsSync(candidate) && statSync(candidate).isFile()) {
|
|
527
609
|
return candidate;
|
|
528
610
|
}
|
|
@@ -541,22 +623,59 @@ function resolveSpecifier(srcDir, importer, importEntry) {
|
|
|
541
623
|
);
|
|
542
624
|
}
|
|
543
625
|
|
|
544
|
-
function
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
},
|
|
557
|
-
);
|
|
626
|
+
function resolveAllowedSourceRoots(projectRoot, explicitRoots = null) {
|
|
627
|
+
if (Array.isArray(explicitRoots) && explicitRoots.length > 0) {
|
|
628
|
+
return explicitRoots
|
|
629
|
+
.map((value) => resolve(projectRoot, value))
|
|
630
|
+
.filter((root) => existsSync(root));
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const roots = [];
|
|
634
|
+
for (const dir of AUTHORED_SOURCE_ROOT_DIRS) {
|
|
635
|
+
const root = resolve(projectRoot, dir);
|
|
636
|
+
if (existsSync(root)) {
|
|
637
|
+
roots.push(root);
|
|
558
638
|
}
|
|
559
639
|
}
|
|
640
|
+
return roots;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function ensureEntryWithinSource(projectRoot, allowedSourceRoots, entryFile) {
|
|
644
|
+
if (allowedSourceRoots.some((root) => pathIsWithinRoot(root, entryFile))) {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
throw new BundleError(
|
|
649
|
+
BUNDLE_ERROR_CODES.PATH_ESCAPE,
|
|
650
|
+
'Entrypoint must stay within the authored source boundary.',
|
|
651
|
+
{
|
|
652
|
+
file: entryFile,
|
|
653
|
+
candidates: allowedSourceRoots.map((root) => relPath(projectRoot, root)),
|
|
654
|
+
},
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function pathIsWithinRoot(root, candidate) {
|
|
659
|
+
const rel = relative(root, candidate);
|
|
660
|
+
return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function ensureWithinSource(projectRoot, allowedSourceRoots, candidate, importer, importEntry) {
|
|
664
|
+
if (allowedSourceRoots.some((root) => pathIsWithinRoot(root, candidate))) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
throw new BundleError(
|
|
669
|
+
BUNDLE_ERROR_CODES.PATH_ESCAPE,
|
|
670
|
+
`Import "${importEntry.specifier}" escapes the authored source boundary.`,
|
|
671
|
+
{
|
|
672
|
+
file: importer,
|
|
673
|
+
importer,
|
|
674
|
+
specifier: importEntry.specifier,
|
|
675
|
+
line: importEntry.line,
|
|
676
|
+
candidates: allowedSourceRoots.map((root) => relPath(projectRoot, root)),
|
|
677
|
+
},
|
|
678
|
+
);
|
|
560
679
|
}
|
|
561
680
|
|
|
562
681
|
function moduleId(srcDir, filePath) {
|
|
@@ -634,12 +753,12 @@ function stopSourceWatch(cache) {
|
|
|
634
753
|
function startSourceWatch(projectRoot, cache, onChange, onError) {
|
|
635
754
|
stopSourceWatch(cache);
|
|
636
755
|
|
|
637
|
-
const
|
|
756
|
+
const sourceRoots = resolveAllowedSourceRoots(projectRoot);
|
|
638
757
|
let closed = false;
|
|
639
758
|
|
|
640
|
-
if (
|
|
759
|
+
if (sourceRoots.length === 0) {
|
|
641
760
|
throw new BundleError(BUNDLE_ERROR_CODES.MISSING_ENTRY, 'Missing src/ directory for dev watch.', {
|
|
642
|
-
file:
|
|
761
|
+
file: resolve(projectRoot, 'src'),
|
|
643
762
|
});
|
|
644
763
|
}
|
|
645
764
|
|
|
@@ -650,19 +769,22 @@ function startSourceWatch(projectRoot, cache, onChange, onError) {
|
|
|
650
769
|
};
|
|
651
770
|
|
|
652
771
|
try {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
772
|
+
for (const root of sourceRoots) {
|
|
773
|
+
const watcher = watch(root, { recursive: true }, (_eventType, filename) => {
|
|
774
|
+
if (!filename) return;
|
|
775
|
+
if (isGeneratedSourceFile(filename)) return;
|
|
776
|
+
if (!String(filename).endsWith('.js') && !String(filename).endsWith('.mjs')) return;
|
|
777
|
+
onChange(join(root, String(filename)));
|
|
778
|
+
});
|
|
779
|
+
cache.watchers.push(watcher);
|
|
780
|
+
}
|
|
659
781
|
return close;
|
|
660
782
|
} catch (_err) {
|
|
661
783
|
// Fallback for platforms that do not support recursive fs.watch.
|
|
662
|
-
cache.pollFingerprint =
|
|
784
|
+
cache.pollFingerprint = fingerprintSourceRoots(sourceRoots);
|
|
663
785
|
cache.poller = setInterval(() => {
|
|
664
786
|
try {
|
|
665
|
-
const next =
|
|
787
|
+
const next = fingerprintSourceRoots(sourceRoots);
|
|
666
788
|
if (next !== cache.pollFingerprint) {
|
|
667
789
|
cache.pollFingerprint = next;
|
|
668
790
|
onChange('poll');
|
|
@@ -675,9 +797,11 @@ function startSourceWatch(projectRoot, cache, onChange, onError) {
|
|
|
675
797
|
}
|
|
676
798
|
}
|
|
677
799
|
|
|
678
|
-
function
|
|
800
|
+
function fingerprintSourceRoots(rootDirs) {
|
|
679
801
|
const files = [];
|
|
680
|
-
|
|
802
|
+
for (const rootDir of rootDirs) {
|
|
803
|
+
walk(rootDir, files);
|
|
804
|
+
}
|
|
681
805
|
files.sort();
|
|
682
806
|
return sha1(files.join('\n'));
|
|
683
807
|
}
|
|
@@ -687,6 +811,9 @@ function walk(dir, output) {
|
|
|
687
811
|
const full = join(dir, entry);
|
|
688
812
|
const stat = statSync(full);
|
|
689
813
|
if (stat.isDirectory()) {
|
|
814
|
+
if (entry === '.aurajs-generated') {
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
690
817
|
walk(full, output);
|
|
691
818
|
continue;
|
|
692
819
|
}
|
|
@@ -696,3 +823,9 @@ function walk(dir, output) {
|
|
|
696
823
|
output.push(`${full}:${stat.mtimeMs}:${stat.size}`);
|
|
697
824
|
}
|
|
698
825
|
}
|
|
826
|
+
|
|
827
|
+
function isGeneratedSourceFile(filename) {
|
|
828
|
+
const normalized = String(filename || '').split('\\').join('/');
|
|
829
|
+
return normalized === '.aurajs-generated'
|
|
830
|
+
|| normalized.startsWith('.aurajs-generated/');
|
|
831
|
+
}
|