create-threenative 0.2.6 → 0.2.8
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 +5 -3
- package/agent-docs/references/build-profiles.md +126 -0
- package/agent-docs/references/capability-reference.md +607 -26
- package/agent-docs/references/performance-basics.md +8 -5
- package/agent-docs/references/sculpt-from-a-reference.md +1 -1
- package/agent-docs/references/trace-a-slow-frame.md +1 -1
- package/agent-docs/references/visual-baseline.md +8 -4
- package/agent-files/.agents/skills/file-engine-bug/SKILL.md +15 -4
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +5 -5
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-context/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +3 -3
- package/agent-files/.agents/skills/threenative-playtest/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-ui/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-visuals/SKILL.md +4 -4
- package/capabilities.json +801 -24
- package/dist/index.d.ts +30 -1
- package/dist/index.js +300 -56
- package/dist/threenative.js +717 -156
- package/package.json +6 -6
- package/template-assets/assets/mannequin-combat.glb +0 -0
- package/template-assets/assets/mannequin.glb +0 -0
- package/template-assets/assets/player-viewmodel.glb +0 -0
- package/template-assets/assets/sky.jpg +0 -0
- package/template-assets/clearwater/README.md +141 -0
- package/template-assets/clearwater/install.mjs +50 -0
- package/template-assets/clearwater/src/clearwater.ts +180 -0
- package/template-assets/clearwater/src/clearwaterDemo.ts +28 -0
- package/template-assets/clearwater/src/clearwaterLifetime.ts +28 -0
- package/{LICENSE → template-assets/clearwater/src/render/CLEARWATER-LICENSE.txt} +4 -1
- package/template-assets/clearwater/src/render/clearwater.ts +278 -0
- package/template-assets/clearwater/src/render/clearwaterCaustics.ts +138 -0
- package/template-assets/clearwater/src/render/clearwaterDemo.ts +65 -0
- package/template-assets/clearwater/src/render/clearwaterOptics.ts +33 -0
- package/template-assets/clearwater/src/render/clearwaterOptions.ts +177 -0
- package/template-assets/clearwater/src/render/clearwaterPass.ts +51 -0
- package/template-assets/patches/three@0.185.1.patch +2101 -138
- package/template-assets/worldEnvironment.ts +52 -1
- package/templates/action-rpg/AGENTS.md +42 -42
- package/templates/action-rpg/CLAUDE.md +42 -42
- package/templates/action-rpg/kit.json +1 -1
- package/templates/action-rpg/package.json +13 -7
- package/templates/action-rpg/playtests/combat.playtest.json +162 -23
- package/templates/action-rpg/playtests/performance.playtest.json +4 -3
- package/templates/action-rpg/playtests/survives.playtest.json +25 -8
- package/templates/action-rpg/src/conventions.ts +24 -18
- package/templates/action-rpg/src/entities/Enemy.ts +74 -24
- package/templates/action-rpg/src/entities/Fighter.ts +127 -0
- package/templates/action-rpg/src/entities/Player.ts +102 -32
- package/templates/action-rpg/src/game.ts +3 -3
- package/templates/action-rpg/src/render/camera.ts +18 -16
- package/templates/action-rpg/src/render/dungeon.ts +192 -0
- package/templates/action-rpg/src/render/lighting.ts +45 -28
- package/templates/action-rpg/src/render/loading.ts +4 -4
- package/templates/action-rpg/src/render/materials.ts +191 -47
- package/templates/action-rpg/src/render/palette.ts +14 -13
- package/templates/action-rpg/src/render/postprocessing.ts +12 -2
- package/templates/action-rpg/src/render/props.ts +117 -0
- package/templates/action-rpg/src/render/quality.ts +40 -82
- package/templates/action-rpg/src/render/sky.ts +36 -13
- package/templates/action-rpg/src/render/touch-controls.ts +1 -1
- package/templates/action-rpg/src/render/worldEnvironment.ts +52 -1
- package/templates/action-rpg/src/scenes/Play.ts +61 -39
- package/templates/action-rpg/src/style.css +9 -7
- package/templates/action-rpg/src/ui/AbilityBar.tsx +3 -1
- package/templates/action-rpg/src/ui/Hud.tsx +3 -3
- package/templates/action-rpg/threenative.config.ts +14 -1
- package/templates/action-rpg/vite.config.ts +4 -1
- package/templates/minimal/AGENTS.md +10 -10
- package/templates/minimal/CLAUDE.md +10 -10
- package/templates/minimal/package.json +12 -6
- package/templates/minimal/playtests/play.playtest.json +6 -5
- package/templates/minimal/playtests/sky.playtest.json +27 -0
- package/templates/minimal/src/conventions.ts +6 -3
- package/templates/minimal/src/entities/Player.ts +73 -27
- package/templates/minimal/src/main.ts +2 -3
- package/templates/minimal/src/render/camera.ts +22 -4
- package/templates/minimal/src/render/lighting.ts +24 -48
- package/templates/minimal/src/render/materials.ts +158 -13
- package/templates/minimal/src/render/palette.ts +10 -7
- package/templates/minimal/src/render/postprocessing.ts +12 -25
- package/templates/minimal/src/render/quality.ts +35 -69
- package/templates/minimal/src/render/sky.ts +35 -54
- package/templates/minimal/src/render/touch-controls.ts +1 -1
- package/templates/minimal/src/render/worldEnvironment.ts +52 -1
- package/templates/minimal/src/scenes/Play.ts +121 -111
- package/templates/minimal/src/state.ts +0 -4
- package/templates/minimal/src/style.css +0 -10
- package/templates/minimal/threenative.config.ts +14 -1
- package/templates/minimal/vite.config.ts +4 -1
- package/templates/platformer/AGENTS.md +18 -56
- package/templates/platformer/CLAUDE.md +18 -56
- package/templates/platformer/kit.json +2 -2
- package/templates/platformer/package.json +13 -9
- package/templates/platformer/playtests/buffer.playtest.json +15 -5
- package/templates/platformer/playtests/collect.playtest.json +8 -34
- package/templates/platformer/playtests/coyote.playtest.json +12 -34
- package/templates/platformer/playtests/damage.playtest.json +40 -15
- package/templates/platformer/playtests/hud.playtest.json +34 -0
- package/templates/platformer/playtests/move.playtest.json +24 -0
- package/templates/platformer/playtests/performance.playtest.json +24 -7
- package/templates/platformer/playtests/respawn.playtest.json +46 -11
- package/templates/platformer/playtests/stomp.playtest.json +49 -12
- package/templates/platformer/playtests/survives.playtest.json +3 -19
- package/templates/platformer/playtests/world.playtest.json +26 -0
- package/templates/platformer/src/entities/Fox.ts +273 -0
- package/templates/platformer/src/entities/Pickup.ts +43 -60
- package/templates/platformer/src/entities/Walker.ts +88 -0
- package/templates/platformer/src/game.ts +11 -8
- package/templates/platformer/src/level/Checkpoints.ts +29 -16
- package/templates/platformer/src/level/Stage.ts +469 -0
- package/templates/platformer/src/render/blocks.ts +94 -0
- package/templates/platformer/src/render/camera.ts +28 -3
- package/templates/platformer/src/render/fox.ts +196 -0
- package/templates/platformer/src/render/lighting.ts +42 -33
- package/templates/platformer/src/render/materials.ts +115 -5
- package/templates/platformer/src/render/palette.ts +68 -53
- package/templates/platformer/src/render/pickups.ts +142 -0
- package/templates/platformer/src/render/postprocessing.ts +12 -2
- package/templates/platformer/src/render/props.ts +147 -0
- package/templates/platformer/src/render/quality.ts +47 -99
- package/templates/platformer/src/render/scenery.ts +172 -0
- package/templates/platformer/src/render/sky.ts +120 -31
- package/templates/platformer/src/render/touch-controls.ts +5 -2
- package/templates/platformer/src/render/walkers.ts +96 -0
- package/templates/platformer/src/render/waterfall.ts +85 -0
- package/templates/platformer/src/render/worldEnvironment.ts +52 -1
- package/templates/platformer/src/scenes/Boot.ts +3 -4
- package/templates/platformer/src/scenes/Play.ts +362 -0
- package/templates/platformer/src/state.ts +16 -14
- package/templates/platformer/src/style.css +9 -8
- package/templates/platformer/src/ui/Hud.tsx +62 -29
- package/templates/platformer/src/ui/Menu.tsx +2 -2
- package/templates/platformer/threenative.config.ts +14 -1
- package/templates/platformer/vite.config.ts +4 -1
- package/templates/puzzle/AGENTS.md +19 -20
- package/templates/puzzle/CLAUDE.md +19 -20
- package/templates/puzzle/assets/native-proof.glb +0 -0
- package/templates/puzzle/assets/native-proof.png +0 -0
- package/templates/puzzle/kit.json +1 -1
- package/templates/puzzle/package.json +13 -7
- package/templates/puzzle/playtests/axis.playtest.json +20 -0
- package/templates/puzzle/playtests/blocked.playtest.json +73 -0
- package/templates/puzzle/playtests/caused.playtest.json +65 -0
- package/templates/puzzle/playtests/lit.playtest.json +74 -0
- package/templates/puzzle/playtests/performance.playtest.json +24 -7
- package/templates/{starter/playtests/respawn.playtest.json → puzzle/playtests/push.playtest.json} +24 -19
- package/templates/puzzle/playtests/replay.playtest.json +81 -0
- package/templates/puzzle/playtests/restart.playtest.json +108 -0
- package/templates/puzzle/playtests/seal.playtest.json +98 -0
- package/templates/puzzle/playtests/settle.playtest.json +100 -0
- package/templates/puzzle/playtests/survives.playtest.json +6 -29
- package/templates/{starter/playtests/hot-reload.playtest.json → puzzle/playtests/travel.playtest.json} +6 -5
- package/templates/puzzle/src/entities/Crate.ts +99 -42
- package/templates/puzzle/src/entities/Seal.ts +69 -0
- package/templates/puzzle/src/entities/Warden.ts +135 -0
- package/templates/puzzle/src/game.ts +15 -11
- package/templates/puzzle/src/render/camera.ts +66 -31
- package/templates/puzzle/src/render/crateShape.ts +70 -0
- package/templates/puzzle/src/render/lighting.ts +41 -41
- package/templates/puzzle/src/render/loading.ts +4 -4
- package/templates/puzzle/src/render/materials.ts +131 -27
- package/templates/puzzle/src/render/palette.ts +19 -29
- package/templates/puzzle/src/render/postprocessing.ts +15 -3
- package/templates/puzzle/src/render/quality.ts +71 -80
- package/templates/puzzle/src/render/shapes.ts +109 -108
- package/templates/puzzle/src/render/sky.ts +18 -10
- package/templates/puzzle/src/render/touch-controls.ts +8 -51
- package/templates/puzzle/src/render/vault.ts +315 -0
- package/templates/puzzle/src/render/warden.ts +46 -0
- package/templates/puzzle/src/render/worldEnvironment.ts +52 -1
- package/templates/puzzle/src/scenes/Play.ts +793 -0
- package/templates/puzzle/src/state.ts +55 -24
- package/templates/puzzle/src/style.css +7 -8
- package/templates/puzzle/src/ui/App.tsx +2 -2
- package/templates/puzzle/src/ui/Hud.tsx +92 -40
- package/templates/puzzle/src/ui/Menu.tsx +40 -2
- package/templates/puzzle/threenative.config.ts +14 -1
- package/templates/puzzle/vite.config.ts +4 -1
- package/templates/racing/AGENTS.md +19 -20
- package/templates/racing/CLAUDE.md +19 -20
- package/templates/racing/package.json +13 -7
- package/templates/racing/playtests/boost.playtest.json +33 -12
- package/templates/racing/playtests/outcome.playtest.json +32 -50
- package/templates/racing/playtests/performance.playtest.json +2 -1
- package/templates/racing/playtests/ranking.playtest.json +5 -14
- package/templates/racing/playtests/rescue.playtest.json +2 -2
- package/templates/racing/playtests/reverse.playtest.json +30 -8
- package/templates/racing/playtests/shortcut.playtest.json +54 -9
- package/templates/racing/playtests/touch-controls.playtest.json +32 -5
- package/templates/racing/src/entities/CarBody.ts +327 -0
- package/templates/racing/src/entities/LineDriver.ts +220 -0
- package/templates/racing/src/entities/RacingCar.ts +150 -89
- package/templates/racing/src/entities/Rival.ts +61 -24
- package/templates/racing/src/game.ts +5 -0
- package/templates/racing/src/render/camera.ts +49 -7
- package/templates/racing/src/render/lighting.ts +36 -37
- package/templates/racing/src/render/materials.ts +239 -19
- package/templates/racing/src/render/palette.ts +19 -21
- package/templates/racing/src/render/postprocessing.ts +12 -2
- package/templates/racing/src/render/quality.ts +43 -82
- package/templates/racing/src/render/shapes.ts +20 -6
- package/templates/racing/src/render/sky.ts +47 -39
- package/templates/racing/src/render/touch-controls.ts +1 -1
- package/templates/racing/src/render/worldEnvironment.ts +52 -1
- package/templates/racing/src/scenes/Race.ts +107 -54
- package/templates/racing/src/state.ts +2 -0
- package/templates/racing/src/track/Checkline.ts +22 -7
- package/templates/racing/src/track/Lap.ts +64 -36
- package/templates/racing/src/track/Ranking.ts +20 -11
- package/templates/racing/src/track/Track.ts +809 -361
- package/templates/racing/src/track/TrackSector.ts +40 -11
- package/templates/racing/src/track/circuit.ts +477 -0
- package/templates/racing/src/track/rescue.ts +16 -4
- package/templates/racing/threenative.config.ts +14 -1
- package/templates/racing/vite.config.ts +4 -1
- package/templates/rain/AGENTS.md +96 -0
- package/templates/rain/CLAUDE.md +98 -0
- package/templates/rain/assets/rain-loop.wav +0 -0
- package/templates/rain/assets/thunder.wav +0 -0
- package/templates/rain/assets/wind-loop.wav +0 -0
- package/templates/rain/index.html +18 -0
- package/templates/rain/kit.json +7 -0
- package/templates/rain/native-playtests/boot.playtest.json +13 -0
- package/templates/rain/native-playtests/lightning.playtest.json +173 -0
- package/templates/rain/package.json +56 -0
- package/templates/rain/playtests/auto-lightning-clear.playtest.json +66 -0
- package/templates/rain/playtests/auto-lightning.playtest.json +26 -0
- package/templates/rain/playtests/automation.playtest.json +133 -0
- package/templates/rain/playtests/cinematic.playtest.json +59 -0
- package/templates/rain/playtests/flash.playtest.json +27 -0
- package/templates/rain/playtests/fly.playtest.json +54 -0
- package/templates/rain/playtests/lightning.playtest.json +220 -0
- package/templates/rain/playtests/loading.playtest.json +57 -0
- package/templates/rain/playtests/paused.playtest.json +59 -0
- package/templates/rain/playtests/performance.playtest.json +22 -0
- package/templates/rain/playtests/reduced-motion.playtest.json +87 -0
- package/templates/rain/playtests/simulation.playtest.json +20 -0
- package/templates/rain/playtests/storm.playtest.json +150 -0
- package/templates/rain/playtests/survives.playtest.json +58 -0
- package/templates/rain/playtests/tiers.playtest.json +179 -0
- package/templates/rain/playtests/weather.playtest.json +77 -0
- package/templates/rain/public/favicon.svg +5 -0
- package/templates/rain/src/audio/storm.ts +314 -0
- package/templates/rain/src/game.ts +114 -0
- package/templates/rain/src/render/bloom-shader.ts +65 -0
- package/templates/rain/src/render/camera.ts +160 -0
- package/templates/rain/src/render/clouds-shader.ts +242 -0
- package/templates/rain/src/render/clouds.ts +142 -0
- package/templates/rain/src/render/lighting.ts +39 -0
- package/templates/rain/src/render/lightning.ts +360 -0
- package/templates/rain/src/render/loading.ts +327 -0
- package/templates/rain/src/render/materials.ts +19 -0
- package/templates/rain/src/render/noise-volume.ts +159 -0
- package/templates/rain/src/render/palette.ts +18 -0
- package/templates/rain/src/render/post-shader.ts +178 -0
- package/templates/rain/src/render/postprocessing.ts +226 -0
- package/templates/rain/src/render/quality.ts +135 -0
- package/templates/rain/src/render/rain.ts +299 -0
- package/templates/rain/src/render/sky.ts +28 -0
- package/templates/rain/src/render/world-shader.ts +680 -0
- package/templates/rain/src/render/world.ts +146 -0
- package/templates/{defense → rain}/src/render/worldEnvironment.ts +52 -1
- package/templates/rain/src/scenes/Boot.ts +334 -0
- package/templates/rain/src/state.ts +257 -0
- package/templates/rain/src/style.css +1160 -0
- package/templates/rain/src/ui/App.tsx +29 -0
- package/templates/rain/src/ui/GameUi.tsx +187 -0
- package/templates/rain/src/ui/Hud.tsx +327 -0
- package/templates/rain/src/ui/LoadingOverlay.tsx +46 -0
- package/templates/rain/src/ui/Menu.tsx +370 -0
- package/templates/rain/src/ui/automation.ts +60 -0
- package/templates/rain/src/ui/main.tsx +7 -0
- package/templates/rain/src/ui/tempest.ts +149 -0
- package/templates/rain/tailwind.config.ts +2 -0
- package/templates/rain/threenative.config.ts +66 -0
- package/templates/rain/tools/generate-shaders.mjs +656 -0
- package/templates/rain/tools/make-storm-audio.mjs +387 -0
- package/templates/rain/tools/storm-dsp.mjs +177 -0
- package/templates/rain/tools/tempest-bloom.frag +10 -0
- package/templates/rain/tools/tempest-clouds.frag +86 -0
- package/templates/rain/tools/tempest-post.frag +47 -0
- package/templates/rain/tools/tempest-world.frag +210 -0
- package/templates/rain/tools/verify-noise-volume.mjs +61 -0
- package/templates/rain/tsconfig.json +17 -0
- package/templates/rain/vite.config.ts +37 -0
- package/templates/rts/.codex/config.toml +19 -0
- package/templates/rts/.cursor/mcp.json +32 -0
- package/templates/rts/.gemini/settings.json +32 -0
- package/templates/rts/.mcp.json +32 -0
- package/templates/rts/.vscode/mcp.json +36 -0
- package/templates/rts/.zed/settings.json +36 -0
- package/templates/rts/AGENTS.md +96 -0
- package/templates/rts/CLAUDE.md +98 -0
- package/templates/rts/kit.json +7 -0
- package/templates/rts/opencode.json +41 -0
- package/templates/{defense → rts}/package.json +13 -7
- package/templates/rts/playtests/performance.playtest.json +41 -0
- package/templates/rts/playtests/rts-ai-attack.playtest.json +24 -0
- package/templates/rts/playtests/rts-attack.playtest.json +75 -0
- package/templates/rts/playtests/rts-build.playtest.json +68 -0
- package/templates/rts/playtests/rts-orders.playtest.json +150 -0
- package/templates/rts/playtests/rts-train.playtest.json +62 -0
- package/templates/rts/playtests/survives.playtest.json +58 -0
- package/templates/rts/public/favicon.svg +4 -0
- package/templates/rts/src/game.ts +64 -0
- package/templates/rts/src/main.ts +15 -0
- package/templates/rts/src/orders.ts +22 -0
- package/templates/rts/src/render/army.ts +346 -0
- package/templates/rts/src/render/camera.ts +123 -0
- package/templates/rts/src/render/lighting.ts +61 -0
- package/templates/rts/src/render/loading.ts +33 -0
- package/templates/rts/src/render/materials.ts +152 -0
- package/templates/rts/src/render/models.ts +705 -0
- package/templates/rts/src/render/palette.ts +17 -0
- package/templates/rts/src/render/picking.ts +93 -0
- package/templates/rts/src/render/postprocessing.ts +46 -0
- package/templates/rts/src/render/quality.ts +128 -0
- package/templates/rts/src/render/resources.ts +141 -0
- package/templates/rts/src/render/sky.ts +44 -0
- package/templates/rts/src/render/terrain.ts +116 -0
- package/templates/rts/src/render/worldEnvironment.ts +809 -0
- package/templates/rts/src/scenes/Play.ts +650 -0
- package/templates/rts/src/sim/ai.ts +1140 -0
- package/templates/rts/src/sim/combat.ts +416 -0
- package/templates/rts/src/sim/construction.ts +374 -0
- package/templates/rts/src/sim/economy.ts +167 -0
- package/templates/rts/src/sim/game.ts +1082 -0
- package/templates/rts/src/sim/movement.ts +371 -0
- package/templates/rts/src/sim/nav.ts +276 -0
- package/templates/rts/src/sim/production.ts +180 -0
- package/templates/rts/src/sim/terrain.ts +170 -0
- package/templates/rts/src/sim/types.ts +647 -0
- package/templates/rts/src/sim/vision.ts +46 -0
- package/templates/rts/src/state.ts +100 -0
- package/templates/{defense → rts}/src/style.css +21 -8
- package/templates/rts/src/ui/App.tsx +21 -0
- package/templates/rts/src/ui/Commands.tsx +129 -0
- package/templates/rts/src/ui/GameUi.tsx +22 -0
- package/templates/rts/src/ui/Hud.tsx +165 -0
- package/templates/rts/src/ui/Minimap.tsx +84 -0
- package/templates/rts/tailwind.config.ts +2 -0
- package/templates/rts/threenative.config.ts +56 -0
- package/templates/rts/tsconfig.json +17 -0
- package/templates/{defense → rts}/vite.config.ts +4 -1
- package/templates/runner/AGENTS.md +6 -10
- package/templates/runner/CLAUDE.md +6 -10
- package/templates/runner/README.md +3 -3
- package/templates/runner/package.json +13 -7
- package/templates/runner/playtests/performance.playtest.json +2 -2
- package/templates/runner/src/conventions.ts +4 -3
- package/templates/runner/src/entities/Runner.ts +54 -7
- package/templates/runner/src/game.ts +2 -0
- package/templates/runner/src/render/camera.ts +4 -2
- package/templates/runner/src/render/dust.ts +5 -2
- package/templates/runner/src/render/lighting.ts +41 -45
- package/templates/runner/src/render/loading.ts +2 -2
- package/templates/runner/src/render/materials.ts +165 -25
- package/templates/runner/src/render/palette.ts +17 -28
- package/templates/runner/src/render/postprocessing.ts +12 -2
- package/templates/runner/src/render/quality.ts +42 -96
- package/templates/runner/src/render/shapes.ts +59 -37
- package/templates/runner/src/render/sky.ts +32 -41
- package/templates/runner/src/render/touch-controls.ts +1 -1
- package/templates/runner/src/render/worldEnvironment.ts +52 -1
- package/templates/runner/src/scenes/Run.ts +26 -6
- package/templates/runner/src/track.ts +6 -1
- package/templates/runner/threenative.config.ts +14 -1
- package/templates/runner/vite.config.ts +4 -1
- package/templates/sailing/AGENTS.md +12 -12
- package/templates/sailing/CLAUDE.md +12 -12
- package/templates/sailing/assets/ship.glb +0 -0
- package/templates/sailing/package.json +13 -7
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +10 -6
- package/templates/sailing/playtests/sails.playtest.json +33 -0
- package/templates/sailing/playtests/win.playtest.json +156 -8
- package/templates/sailing/src/conventions.ts +29 -2
- package/templates/sailing/src/entities/Ship.ts +381 -57
- package/templates/sailing/src/game.ts +14 -0
- package/templates/sailing/src/render/camera.ts +63 -9
- package/templates/sailing/src/render/lighting.ts +49 -27
- package/templates/sailing/src/render/materials.ts +50 -15
- package/templates/sailing/src/render/ocean.ts +647 -60
- package/templates/sailing/src/render/palette.ts +16 -12
- package/templates/sailing/src/render/postprocessing.ts +12 -2
- package/templates/sailing/src/render/props.ts +316 -442
- package/templates/sailing/src/render/quality.ts +14 -4
- package/templates/sailing/src/render/sky.ts +116 -23
- package/templates/sailing/src/render/worldEnvironment.ts +52 -1
- package/templates/sailing/src/scenes/Boot.ts +21 -0
- package/templates/sailing/src/scenes/Sailing.ts +173 -39
- package/templates/sailing/src/state.ts +6 -0
- package/templates/sailing/src/ui/Hud.tsx +41 -9
- package/templates/sailing/threenative.config.ts +14 -1
- package/templates/sailing/vite.config.ts +4 -1
- package/templates/shooter/AGENTS.md +27 -42
- package/templates/shooter/CLAUDE.md +27 -42
- package/templates/shooter/index.html +1 -0
- package/templates/shooter/package.json +13 -7
- package/templates/shooter/playtests/aim-alignment.playtest.json +58 -0
- package/templates/shooter/playtests/breakable-shatters.playtest.json +62 -0
- package/templates/shooter/playtests/bullet-holes.playtest.json +56 -0
- package/templates/shooter/playtests/camera-tracks-body-vertically.playtest.json +61 -0
- package/templates/shooter/playtests/crouch-lowers-the-eye.playtest.json +41 -0
- package/templates/shooter/playtests/death-no-snap.playtest.json +77 -0
- package/templates/shooter/playtests/debug-ads.playtest.json +58 -0
- package/templates/shooter/playtests/debug-clear.playtest.json +383 -0
- package/templates/shooter/playtests/debug-endurance.playtest.json +61 -0
- package/templates/shooter/playtests/debug-fire.playtest.json +119 -0
- package/templates/shooter/playtests/debug-restart.playtest.json +24 -0
- package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +79 -0
- package/templates/shooter/playtests/enemy-death-settles.playtest.json +64 -0
- package/templates/shooter/playtests/enemy-flinches-when-hit.playtest.json +75 -0
- package/templates/shooter/playtests/enemy-foot-contact.playtest.json +41 -0
- package/templates/shooter/playtests/enemy-material-is-not-shared.playtest.json +59 -0
- package/templates/shooter/playtests/enemy-reaches-walkway.playtest.json +80 -0
- package/templates/shooter/playtests/enemy-rifle-grip.playtest.json +101 -0
- package/templates/shooter/playtests/enemy-scale.playtest.json +56 -0
- package/templates/shooter/playtests/enemy-stops-without-snapping.playtest.json +486 -0
- package/templates/shooter/playtests/enemy-stride-matches-speed.playtest.json +198 -0
- package/templates/shooter/playtests/enemy-stride-under-crouch.playtest.json +87 -0
- package/templates/shooter/playtests/enemy-uses-crouch-clips.playtest.json +74 -0
- package/templates/shooter/playtests/five-soldiers.playtest.json +83 -0
- package/templates/shooter/playtests/flash-retires.playtest.json +62 -0
- package/templates/shooter/playtests/headshot-hits-head.playtest.json +132 -0
- package/templates/shooter/playtests/hold-to-fire.playtest.json +45 -0
- package/templates/shooter/playtests/input-control.playtest.json +43 -98
- package/templates/shooter/playtests/minimap-state.playtest.json +75 -0
- package/templates/shooter/playtests/performance.playtest.json +62 -26
- package/templates/{starter/playtests/forward.playtest.json → shooter/playtests/round-clock.playtest.json} +11 -16
- package/templates/shooter/playtests/shot-tracks-crosshair.playtest.json +79 -0
- package/templates/shooter/playtests/survives.playtest.json +36 -30
- package/templates/shooter/playtests/walkway-reachable.playtest.json +67 -0
- package/templates/shooter/src/entities/Breakables.ts +412 -0
- package/templates/shooter/src/entities/Enemy.ts +2095 -0
- package/templates/shooter/src/entities/FpsPlayer.ts +283 -0
- package/templates/shooter/src/entities/Rifle.ts +442 -0
- package/templates/shooter/src/entities/Target.ts +199 -83
- package/templates/shooter/src/entities/TouchControls.ts +276 -0
- package/templates/shooter/src/game.ts +75 -41
- package/templates/shooter/src/main.ts +0 -1
- package/templates/shooter/src/postPhysics.ts +36 -0
- package/templates/shooter/src/render/camera.ts +78 -74
- package/templates/shooter/src/render/decals.ts +142 -82
- package/templates/shooter/src/render/facade.ts +1373 -0
- package/templates/shooter/src/render/gunfx.ts +704 -0
- package/templates/shooter/src/render/lighting.ts +52 -38
- package/templates/shooter/src/render/loading.ts +2 -2
- package/templates/shooter/src/render/materials.ts +100 -88
- package/templates/shooter/src/render/occlusion.ts +108 -0
- package/templates/shooter/src/render/palette.ts +10 -10
- package/templates/shooter/src/render/palm.ts +455 -0
- package/templates/shooter/src/render/pooled-billboards.ts +144 -0
- package/templates/shooter/src/render/postprocessing.ts +15 -3
- package/templates/shooter/src/render/quality.ts +40 -82
- package/templates/shooter/src/render/scale.ts +148 -15
- package/templates/shooter/src/render/shapes.ts +138 -613
- package/templates/shooter/src/render/sky.ts +35 -35
- package/templates/shooter/src/render/town-schematic.ts +120 -0
- package/templates/shooter/src/render/town.ts +986 -0
- package/templates/shooter/src/render/townMaterials.ts +160 -0
- package/templates/shooter/src/render/vehicles.ts +741 -0
- package/templates/shooter/src/render/worldEnvironment.ts +52 -1
- package/templates/shooter/src/scenes/Play.ts +727 -650
- package/templates/shooter/src/state.ts +26 -41
- package/templates/shooter/src/style.css +207 -11
- package/templates/shooter/src/surfaces.ts +131 -0
- package/templates/shooter/src/ui/App.tsx +9 -10
- package/templates/shooter/src/ui/Crosshair.tsx +25 -18
- package/templates/shooter/src/ui/GameUi.tsx +6 -9
- package/templates/shooter/src/ui/Hud.tsx +428 -39
- package/templates/shooter/src/ui/Minimap.tsx +164 -0
- package/templates/shooter/src/ui/TouchOverlay.tsx +54 -0
- package/templates/shooter/src/ui/main.tsx +2 -3
- package/templates/shooter/threenative.config.ts +14 -1
- package/templates/shooter/vite.config.ts +4 -1
- package/templates/snow/.codex/config.toml +19 -0
- package/templates/snow/.cursor/mcp.json +32 -0
- package/templates/snow/.gemini/settings.json +32 -0
- package/templates/snow/.mcp.json +32 -0
- package/templates/snow/.vscode/mcp.json +36 -0
- package/templates/snow/.zed/settings.json +36 -0
- package/templates/snow/AGENTS.md +88 -0
- package/templates/snow/CLAUDE.md +90 -0
- package/templates/snow/README.md +26 -0
- package/templates/snow/assets/crunch.wav +0 -0
- package/templates/snow/assets/wind.wav +0 -0
- package/templates/snow/index.html +12 -0
- package/templates/snow/kit.json +7 -0
- package/templates/snow/native-playtests/snow-physics.playtest.json +150 -0
- package/templates/snow/native-playtests/survives.playtest.json +47 -0
- package/templates/snow/opencode.json +41 -0
- package/templates/snow/package.json +58 -0
- package/templates/snow/playtests/footsteps.playtest.json +95 -0
- package/templates/{defense → snow}/playtests/performance.playtest.json +4 -7
- package/templates/snow/playtests/snow-physics.playtest.json +154 -0
- package/templates/{defense → snow}/playtests/survives.playtest.json +26 -6
- package/templates/snow/playtests/touch-controls.playtest.json +71 -0
- package/templates/snow/playtests/weather.playtest.json +119 -0
- package/templates/snow/public/favicon.svg +5 -0
- package/templates/snow/src/audio.ts +58 -0
- package/templates/snow/src/commands.ts +8 -0
- package/templates/snow/src/entities/Explorer.ts +279 -0
- package/templates/snow/src/game.ts +69 -0
- package/templates/snow/src/main.ts +15 -0
- package/templates/snow/src/render/bootPrint.ts +50 -0
- package/templates/snow/src/render/camera.ts +84 -0
- package/templates/snow/src/render/explorer.ts +321 -0
- package/templates/snow/src/render/lighting.ts +50 -0
- package/templates/snow/src/render/loading.ts +325 -0
- package/templates/snow/src/render/materials.ts +36 -0
- package/templates/snow/src/render/palette.ts +17 -0
- package/templates/{defense → snow}/src/render/postprocessing.ts +12 -2
- package/templates/snow/src/render/props.ts +42 -0
- package/templates/{defense → snow}/src/render/quality.ts +37 -72
- package/templates/snow/src/render/scenery.ts +244 -0
- package/templates/snow/src/render/sky.ts +57 -0
- package/templates/snow/src/render/snowSurface.ts +259 -0
- package/templates/snow/src/render/touch-controls.ts +143 -0
- package/templates/snow/src/render/weather.ts +279 -0
- package/templates/snow/src/render/worldEnvironment.ts +809 -0
- package/templates/{defense → snow}/src/scenes/Boot.ts +4 -4
- package/templates/snow/src/scenes/Snow.ts +635 -0
- package/templates/snow/src/state.ts +46 -0
- package/templates/snow/src/style.css +143 -0
- package/templates/snow/src/terrain.ts +64 -0
- package/templates/snow/src/ui/App.tsx +15 -0
- package/templates/snow/src/ui/Controls.tsx +322 -0
- package/templates/snow/src/ui/GameUi.tsx +354 -0
- package/templates/snow/src/ui/icons.tsx +54 -0
- package/templates/snow/src/ui/main.tsx +7 -0
- package/templates/snow/tailwind.config.ts +2 -0
- package/templates/snow/threenative.config.ts +51 -0
- package/templates/snow/tsconfig.json +17 -0
- package/templates/snow/vite.config.ts +37 -0
- package/templates/starter/AGENTS.md +17 -17
- package/templates/starter/CLAUDE.md +17 -17
- package/templates/starter/native-playtests/render-chain.playtest.json +13 -45
- package/templates/starter/package.json +13 -7
- package/templates/starter/playtests/play.playtest.json +2 -1
- package/templates/starter/playtests/survives.playtest.json +1 -1
- package/templates/starter/src/conventions.ts +6 -3
- package/templates/starter/src/entities/Goal.ts +35 -42
- package/templates/starter/src/entities/Player.ts +99 -16
- package/templates/starter/src/render/arena.ts +131 -0
- package/templates/starter/src/render/lighting.ts +27 -44
- package/templates/starter/src/render/materials.ts +164 -35
- package/templates/starter/src/render/palette.ts +16 -16
- package/templates/starter/src/render/postprocessing.ts +6 -7
- package/templates/starter/src/render/quality.ts +43 -101
- package/templates/starter/src/render/shapes.ts +1 -1
- package/templates/starter/src/render/sky.ts +39 -45
- package/templates/starter/src/render/touch-controls.ts +3 -1
- package/templates/starter/src/render/worldEnvironment.ts +52 -1
- package/templates/starter/src/scenes/Play.ts +82 -81
- package/templates/starter/threenative.config.ts +14 -1
- package/templates/starter/vite.config.ts +4 -1
- package/templates/tower-defense/.codex/config.toml +19 -0
- package/templates/tower-defense/.cursor/mcp.json +32 -0
- package/templates/tower-defense/.gemini/settings.json +32 -0
- package/templates/tower-defense/.mcp.json +32 -0
- package/templates/tower-defense/.vscode/mcp.json +36 -0
- package/templates/tower-defense/.zed/settings.json +36 -0
- package/templates/{defense → tower-defense}/AGENTS.md +14 -12
- package/templates/{defense → tower-defense}/CLAUDE.md +14 -12
- package/templates/tower-defense/README.md +16 -0
- package/templates/tower-defense/index.html +12 -0
- package/templates/tower-defense/kit.json +7 -0
- package/templates/tower-defense/opencode.json +41 -0
- package/templates/tower-defense/package.json +56 -0
- package/templates/tower-defense/playtests/arsenal.playtest.json +214 -0
- package/templates/tower-defense/playtests/defeat.playtest.json +85 -0
- package/templates/tower-defense/playtests/look.playtest.json +130 -0
- package/templates/tower-defense/playtests/performance.playtest.json +77 -0
- package/templates/tower-defense/playtests/placement.playtest.json +115 -0
- package/templates/{defense → tower-defense}/playtests/pointer-placement.playtest.json +21 -49
- package/templates/tower-defense/playtests/strike.playtest.json +98 -0
- package/templates/tower-defense/playtests/survives.playtest.json +85 -0
- package/templates/tower-defense/playtests/target-priority.playtest.json +177 -0
- package/templates/tower-defense/playtests/upgrade-recycle.playtest.json +124 -0
- package/templates/tower-defense/playtests/victory.playtest.json +810 -0
- package/templates/tower-defense/src/balance.ts +187 -0
- package/templates/tower-defense/src/board/Board.ts +100 -0
- package/templates/tower-defense/src/board/Route.ts +84 -0
- package/templates/tower-defense/src/camera-rig.ts +62 -0
- package/templates/tower-defense/src/economy.ts +64 -0
- package/templates/tower-defense/src/effects/Effects.ts +284 -0
- package/templates/tower-defense/src/enemies/Enemy.ts +198 -0
- package/templates/tower-defense/src/game.ts +72 -0
- package/templates/tower-defense/src/intents.ts +21 -0
- package/templates/tower-defense/src/main.ts +15 -0
- package/templates/tower-defense/src/physics.ts +6 -0
- package/templates/tower-defense/src/render/camera.ts +38 -0
- package/templates/tower-defense/src/render/lighting.ts +42 -0
- package/templates/{defense → tower-defense}/src/render/loading.ts +3 -3
- package/templates/tower-defense/src/render/materials.ts +103 -0
- package/templates/tower-defense/src/render/palette.ts +58 -0
- package/templates/tower-defense/src/render/postprocessing.ts +46 -0
- package/templates/tower-defense/src/render/quality.ts +128 -0
- package/templates/tower-defense/src/render/shapes.ts +550 -0
- package/templates/tower-defense/src/render/sky.ts +27 -0
- package/templates/tower-defense/src/render/worldEnvironment.ts +809 -0
- package/templates/tower-defense/src/scenes/Battle.ts +539 -0
- package/templates/{shooter → tower-defense}/src/scenes/Boot.ts +3 -3
- package/templates/tower-defense/src/state.ts +88 -0
- package/templates/tower-defense/src/style.css +137 -0
- package/templates/tower-defense/src/towers/Tower.ts +230 -0
- package/templates/tower-defense/src/towers/targeting.ts +97 -0
- package/templates/tower-defense/src/ui/Hud.tsx +270 -0
- package/templates/tower-defense/src/ui/Menu.tsx +134 -0
- package/templates/tower-defense/src/ui/icons.tsx +54 -0
- package/templates/tower-defense/src/ui/main.tsx +14 -0
- package/templates/tower-defense/src/waves.ts +90 -0
- package/templates/{defense → tower-defense}/threenative.config.ts +14 -1
- package/templates/tower-defense/vite.config.ts +41 -0
- package/agent-files/.claude/skills/file-engine-bug/SKILL.md +0 -59
- package/agent-files/.claude/skills/ponytail/SKILL.md +0 -68
- package/agent-files/.claude/skills/prd-creator/SKILL.md +0 -40
- package/agent-files/.claude/skills/threenative-assets/SKILL.md +0 -53
- package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +0 -27
- package/agent-files/.claude/skills/threenative-context/SKILL.md +0 -65
- package/agent-files/.claude/skills/threenative-performance/SKILL.md +0 -58
- package/agent-files/.claude/skills/threenative-playtest/SKILL.md +0 -44
- package/agent-files/.claude/skills/threenative-ui/SKILL.md +0 -20
- package/agent-files/.claude/skills/threenative-visuals/SKILL.md +0 -41
- package/agent-files/AGENT-ROLES.md +0 -26
- package/templates/action-rpg/src/render/shapes.ts +0 -269
- package/templates/action-rpg/src/render/types.ts +0 -3
- package/templates/action-rpg/src/scenes/Boot.ts +0 -12
- package/templates/defense/README.md +0 -10
- package/templates/defense/kit.json +0 -7
- package/templates/defense/playtests/leak.playtest.json +0 -23
- package/templates/defense/playtests/placement.playtest.json +0 -40
- package/templates/defense/playtests/scan.playtest.json +0 -20
- package/templates/defense/playtests/survive.playtest.json +0 -45
- package/templates/defense/src/attackers/Attacker.ts +0 -120
- package/templates/defense/src/board/Route.ts +0 -94
- package/templates/defense/src/conventions.ts +0 -18
- package/templates/defense/src/economy.ts +0 -36
- package/templates/defense/src/entities/Player.ts +0 -52
- package/templates/defense/src/game.ts +0 -51
- package/templates/defense/src/physics.ts +0 -13
- package/templates/defense/src/placement/Buildable.ts +0 -49
- package/templates/defense/src/render/camera.ts +0 -16
- package/templates/defense/src/render/lighting.ts +0 -37
- package/templates/defense/src/render/materials.ts +0 -22
- package/templates/defense/src/render/palette.ts +0 -28
- package/templates/defense/src/render/shapes.ts +0 -246
- package/templates/defense/src/render/sky.ts +0 -45
- package/templates/defense/src/scenes/Defense.ts +0 -231
- package/templates/defense/src/state.ts +0 -56
- package/templates/defense/src/towers/Tower.ts +0 -95
- package/templates/defense/src/towers/targeting.ts +0 -53
- package/templates/defense/src/ui/Hud.tsx +0 -62
- package/templates/defense/src/ui/Menu.tsx +0 -7
- package/templates/defense/src/waves.ts +0 -40
- package/templates/minimal/playtests/atmosphere.playtest.json +0 -32
- package/templates/minimal/src/render/hud.ts +0 -69
- package/templates/platformer/playtests/avoidance.playtest.json +0 -28
- package/templates/platformer/playtests/chase.playtest.json +0 -21
- package/templates/platformer/playtests/collision-layers.playtest.json +0 -36
- package/templates/platformer/playtests/oneway.playtest.json +0 -44
- package/templates/platformer/playtests/patrol.playtest.json +0 -13
- package/templates/platformer/playtests/physics.playtest.json +0 -14
- package/templates/platformer/playtests/stomp-rise.playtest.json +0 -55
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +0 -41
- package/templates/platformer/playtests/terminal-loop-win.playtest.json +0 -52
- package/templates/platformer/src/conventions.ts +0 -18
- package/templates/platformer/src/entities/Character.ts +0 -286
- package/templates/platformer/src/entities/Chaser.ts +0 -118
- package/templates/platformer/src/entities/Patrol.ts +0 -93
- package/templates/platformer/src/level/Platform.ts +0 -46
- package/templates/platformer/src/render/rig.ts +0 -60
- package/templates/platformer/src/render/terrain.ts +0 -31
- package/templates/platformer/src/scenes/Level.ts +0 -241
- package/templates/puzzle/README.md +0 -43
- package/templates/puzzle/playtests/carry.playtest.json +0 -71
- package/templates/puzzle/playtests/swing.playtest.json +0 -38
- package/templates/puzzle/src/conventions.ts +0 -25
- package/templates/puzzle/src/entities/Ball.ts +0 -70
- package/templates/puzzle/src/entities/Gripper.ts +0 -69
- package/templates/puzzle/src/entities/Pendulum.ts +0 -89
- package/templates/puzzle/src/physics.ts +0 -19
- package/templates/puzzle/src/room.ts +0 -83
- package/templates/puzzle/src/scenes/Boot.ts +0 -12
- package/templates/puzzle/src/scenes/Puzzle.ts +0 -158
- package/templates/shooter/playtests/combat.playtest.json +0 -48
- package/templates/shooter/playtests/fail.playtest.json +0 -31
- package/templates/shooter/playtests/per-item.playtest.json +0 -59
- package/templates/shooter/playtests/shooter.playtest.json +0 -99
- package/templates/shooter/playtests/touch-controls.playtest.json +0 -42
- package/templates/shooter/playtests/weapon-cycle.playtest.json +0 -164
- package/templates/shooter/src/combat/damage.ts +0 -40
- package/templates/shooter/src/conventions.ts +0 -51
- package/templates/shooter/src/entities/Pickup.ts +0 -70
- package/templates/shooter/src/entities/Player.ts +0 -310
- package/templates/shooter/src/level/SpawnPoints.ts +0 -28
- package/templates/shooter/src/playtest-events.ts +0 -15
- package/templates/shooter/src/render/touch-controls.ts +0 -305
- package/templates/shooter/src/render/types.ts +0 -3
- package/templates/shooter/src/render/ui.css +0 -330
- package/templates/shooter/src/render/ui.ts +0 -75
- package/templates/shooter/src/render/vfx.ts +0 -215
- package/templates/shooter/src/ui/Menu.tsx +0 -41
- package/templates/shooter/src/waves.ts +0 -50
- package/templates/shooter/src/weapons/Hitscan.ts +0 -42
- package/templates/shooter/src/weapons/Projectile.ts +0 -92
- package/templates/shooter/src/weapons/Viewmodel.ts +0 -275
- package/templates/starter/playtests/assets.playtest.json +0 -65
- package/templates/starter/playtests/buffer.playtest.json +0 -79
- package/templates/starter/playtests/cloth.playtest.json +0 -113
- package/templates/starter/playtests/coyote.playtest.json +0 -87
- package/templates/starter/playtests/gameover.playtest.json +0 -66
- package/templates/starter/playtests/goal.playtest.json +0 -67
- package/templates/starter/playtests/look.playtest.json +0 -175
- package/templates/starter/playtests/models-baseline.png +0 -0
- package/templates/starter/playtests/models.playtest.json +0 -74
- package/templates/starter/playtests/monitoring.playtest.json +0 -72
- package/templates/starter/playtests/odometer.playtest.json +0 -54
- package/templates/starter/playtests/restart.playtest.json +0 -91
- package/templates/starter/playtests/seed.playtest.json +0 -54
- package/templates/starter/playtests/textures-baseline.png +0 -0
- package/templates/starter/playtests/textures.playtest.json +0 -74
- package/templates/starter/playtests/touch-controls.playtest.json +0 -42
- package/templates/starter/playtests/zoom-pinch.playtest.json +0 -86
- package/templates/starter/playtests/zoom-wheel.playtest.json +0 -59
- package/templates/starter/src/render/coast.ts +0 -199
- package/templates/starter/src/render/hero.ts +0 -88
- package/templates/starter/src/render/implicitSurface.ts +0 -199
- package/templates/starter/src/render/kuwahara.ts +0 -174
- package/templates/starter/src/render/outline.ts +0 -141
- package/templates/starter/src/render/painterly.ts +0 -86
- package/templates/starter/src/render/rockRidge.ts +0 -198
- package/templates/starter/src/render/rockRidge.worker.ts +0 -77
- package/templates/starter/src/render/scenery.ts +0 -40
- package/templates/starter/src/render/textureLifetime.ts +0 -53
- package/templates/starter/src/render/water.ts +0 -38
- package/templates/starter/src/render/watercolor.ts +0 -85
- /package/templates/{starter → puzzle}/playtests/boot-failure.playtest.json +0 -0
- /package/templates/{starter → puzzle}/playtests/pause.playtest.json +0 -0
- /package/templates/{defense → rain}/.codex/config.toml +0 -0
- /package/templates/{defense → rain}/.cursor/mcp.json +0 -0
- /package/templates/{defense → rain}/.gemini/settings.json +0 -0
- /package/templates/{defense → rain}/.mcp.json +0 -0
- /package/templates/{defense → rain}/.vscode/mcp.json +0 -0
- /package/templates/{defense → rain}/.zed/settings.json +0 -0
- /package/templates/{defense → rain}/opencode.json +0 -0
- /package/templates/{defense → rain}/src/main.ts +0 -0
- /package/templates/{defense → rts}/index.html +0 -0
- /package/templates/{defense → rts}/src/ui/main.tsx +0 -0
- /package/templates/{defense → tower-defense}/public/favicon.svg +0 -0
- /package/templates/{defense → tower-defense}/src/playtest-events.ts +0 -0
- /package/templates/{defense → tower-defense}/src/ui/App.tsx +0 -0
- /package/templates/{defense → tower-defense}/src/ui/GameUi.tsx +0 -0
- /package/templates/{defense → tower-defense}/tailwind.config.ts +0 -0
- /package/templates/{defense → tower-defense}/tsconfig.json +0 -0
package/dist/threenative.js
CHANGED
|
@@ -3,20 +3,83 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { spawnSync, execFileSync, spawn } from 'child_process';
|
|
4
4
|
import { randomUUID, createHash } from 'crypto';
|
|
5
5
|
import { existsSync, realpathSync, readFileSync, statSync, openSync, readSync, closeSync, accessSync, constants } from 'fs';
|
|
6
|
-
import {
|
|
6
|
+
import { mkdir, rm, open, readFile, writeFile, readdir, stat, rename, access, unlink } from 'fs/promises';
|
|
7
7
|
import { createRequire as createRequire$1 } from 'module';
|
|
8
|
-
import
|
|
8
|
+
import path4 from 'path';
|
|
9
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
9
10
|
import { compileAssets, parsePng, parseAudioConfig } from '@threenative/assets';
|
|
10
11
|
import { brotliCompressSync, constants as constants$1, gzipSync } from 'zlib';
|
|
11
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
12
12
|
import { platform, homedir } from 'os';
|
|
13
13
|
|
|
14
14
|
createRequire(import.meta.url);
|
|
15
|
+
var BUILD_REPORT_SUFFIX = ".build-report.json";
|
|
16
|
+
function sha256(bytes) {
|
|
17
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
18
|
+
}
|
|
19
|
+
async function listFiles(target, prefix = "") {
|
|
20
|
+
const entries = await readdir(target, { withFileTypes: true });
|
|
21
|
+
const files = [];
|
|
22
|
+
for (const entry of entries.sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
23
|
+
const relative = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
24
|
+
if (entry.isDirectory())
|
|
25
|
+
files.push(...await listFiles(path4.join(target, entry.name), relative));
|
|
26
|
+
else if (entry.isFile()) files.push(relative);
|
|
27
|
+
}
|
|
28
|
+
return files;
|
|
29
|
+
}
|
|
30
|
+
async function hashArtifact(target) {
|
|
31
|
+
const name = path4.basename(target);
|
|
32
|
+
if (!(await stat(target)).isDirectory()) {
|
|
33
|
+
return { kind: "file", name, sha256: sha256(await readFile(target)) };
|
|
34
|
+
}
|
|
35
|
+
const lines = [];
|
|
36
|
+
for (const file of await listFiles(target)) {
|
|
37
|
+
lines.push(`${file} ${sha256(await readFile(path4.join(target, file)))}`);
|
|
38
|
+
}
|
|
39
|
+
return { kind: "directory", name, sha256: sha256(Buffer.from(lines.join("\n"), "utf8")) };
|
|
40
|
+
}
|
|
41
|
+
async function measureTreeBytes(target) {
|
|
42
|
+
const info = await stat(target);
|
|
43
|
+
if (!info.isDirectory()) return info.size;
|
|
44
|
+
let total = 0;
|
|
45
|
+
for (const entry of await readdir(target))
|
|
46
|
+
total += await measureTreeBytes(path4.join(target, entry));
|
|
47
|
+
return total;
|
|
48
|
+
}
|
|
49
|
+
async function writeBuildReport(options) {
|
|
50
|
+
const { artifact, assets, config, target } = options;
|
|
51
|
+
const report = {
|
|
52
|
+
artifact: await hashArtifact(artifact),
|
|
53
|
+
measured: {
|
|
54
|
+
artifactBytes: await measureTreeBytes(artifact),
|
|
55
|
+
packagedAssetBytes: options.packagedAssetBytes
|
|
56
|
+
},
|
|
57
|
+
manifestSha256: await fileSha(path4.join(assets, "assets.manifest.json")),
|
|
58
|
+
performanceBudget: config.buildProfile?.performanceBudget ?? null,
|
|
59
|
+
profile: config.buildProfile?.name ?? null,
|
|
60
|
+
schemaVersion: 1,
|
|
61
|
+
target
|
|
62
|
+
};
|
|
63
|
+
const destination = path4.join(
|
|
64
|
+
path4.dirname(artifact),
|
|
65
|
+
`${path4.basename(artifact)}${BUILD_REPORT_SUFFIX}`
|
|
66
|
+
);
|
|
67
|
+
await writeFile(destination, `${JSON.stringify(report, null, 2)}
|
|
68
|
+
`);
|
|
69
|
+
return destination;
|
|
70
|
+
}
|
|
71
|
+
async function fileSha(target) {
|
|
72
|
+
try {
|
|
73
|
+
return sha256(await readFile(target));
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
15
78
|
var COMPRESSIBLE_EXTENSIONS = /* @__PURE__ */ new Set([".css", ".html", ".js", ".json", ".mjs", ".wasm"]);
|
|
16
79
|
var MIN_BYTES = 1024;
|
|
17
80
|
async function walk(directory, files) {
|
|
18
81
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
19
|
-
const file =
|
|
82
|
+
const file = path4.join(directory, entry.name);
|
|
20
83
|
if (entry.isDirectory()) await walk(file, files);
|
|
21
84
|
else if (entry.isFile()) files.push(file);
|
|
22
85
|
}
|
|
@@ -38,7 +101,7 @@ async function writeCompressionSidecars(outputDirectory) {
|
|
|
38
101
|
}
|
|
39
102
|
await walk(outputDirectory, files);
|
|
40
103
|
for (const file of files) {
|
|
41
|
-
if (!COMPRESSIBLE_EXTENSIONS.has(
|
|
104
|
+
if (!COMPRESSIBLE_EXTENSIONS.has(path4.extname(file).toLowerCase())) continue;
|
|
42
105
|
try {
|
|
43
106
|
const data = await readFile(file);
|
|
44
107
|
if (data.byteLength <= MIN_BYTES) continue;
|
|
@@ -46,24 +109,24 @@ async function writeCompressionSidecars(outputDirectory) {
|
|
|
46
109
|
await writeFile(`${file}.gz`, gzip(data));
|
|
47
110
|
} catch (error) {
|
|
48
111
|
throw new Error(
|
|
49
|
-
`TN_WEB_COMPRESSION_FAILED: ${
|
|
112
|
+
`TN_WEB_COMPRESSION_FAILED: ${path4.relative(outputDirectory, file)}: ${error.message}`
|
|
50
113
|
);
|
|
51
114
|
}
|
|
52
115
|
}
|
|
53
116
|
return mainEntryReport(outputDirectory, files);
|
|
54
117
|
}
|
|
55
118
|
async function mainEntryReport(outputDirectory, files) {
|
|
56
|
-
const html = files.find((file) =>
|
|
119
|
+
const html = files.find((file) => path4.basename(file) === "index.html");
|
|
57
120
|
if (html === void 0) return void 0;
|
|
58
121
|
const match = /<script[^>]+src="([^"]+\.m?js)"/u.exec(await readFile(html, "utf8"));
|
|
59
122
|
const source = match?.[1];
|
|
60
123
|
if (source === void 0) return void 0;
|
|
61
|
-
const entry =
|
|
124
|
+
const entry = path4.join(outputDirectory, source.replace(/^\//u, ""));
|
|
62
125
|
const raw = (await stat(entry)).size;
|
|
63
126
|
if (raw <= MIN_BYTES) return void 0;
|
|
64
127
|
return {
|
|
65
128
|
brotli: (await stat(`${entry}.br`)).size,
|
|
66
|
-
entry:
|
|
129
|
+
entry: path4.relative(outputDirectory, entry),
|
|
67
130
|
gzip: (await stat(`${entry}.gz`)).size,
|
|
68
131
|
raw
|
|
69
132
|
};
|
|
@@ -142,13 +205,13 @@ function defaultAppId(name) {
|
|
|
142
205
|
return `com.threenative.${segment}`;
|
|
143
206
|
}
|
|
144
207
|
function projectRequire(cwd) {
|
|
145
|
-
return createRequire$1(
|
|
208
|
+
return createRequire$1(path4.join(cwd, "package.json"));
|
|
146
209
|
}
|
|
147
210
|
function configLoaderSearch(cwd) {
|
|
148
211
|
return [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
212
|
+
path4.join(cwd, "node_modules", "vite"),
|
|
213
|
+
path4.join(cwd, "node_modules", "esbuild"),
|
|
214
|
+
path4.resolve(path4.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
|
|
152
215
|
];
|
|
153
216
|
}
|
|
154
217
|
var CONFIG_BUILD_COMMAND = "pnpm exec threenative build --target web";
|
|
@@ -156,7 +219,7 @@ function configContext(cwd, layer, sources, searched, fix) {
|
|
|
156
219
|
return { cwd, fix, layer, searched, sources };
|
|
157
220
|
}
|
|
158
221
|
function packageContext(cwd) {
|
|
159
|
-
const packagePath =
|
|
222
|
+
const packagePath = path4.join(cwd, "package.json");
|
|
160
223
|
return configContext(
|
|
161
224
|
cwd,
|
|
162
225
|
"package manifest",
|
|
@@ -179,8 +242,8 @@ function validationContext(cwd, sources) {
|
|
|
179
242
|
cwd,
|
|
180
243
|
"config validation",
|
|
181
244
|
sources,
|
|
182
|
-
[
|
|
183
|
-
`fix '${
|
|
245
|
+
[path4.join(cwd, "package.json"), path4.join(cwd, CONFIG_FILE)],
|
|
246
|
+
`fix '${path4.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
|
|
184
247
|
);
|
|
185
248
|
}
|
|
186
249
|
function configFailure(code, context, detail) {
|
|
@@ -220,7 +283,7 @@ function resolveEsbuild(cwd) {
|
|
|
220
283
|
}
|
|
221
284
|
}
|
|
222
285
|
async function importConfig(cwd) {
|
|
223
|
-
const sourcePath =
|
|
286
|
+
const sourcePath = path4.join(cwd, CONFIG_FILE);
|
|
224
287
|
try {
|
|
225
288
|
await access(sourcePath);
|
|
226
289
|
} catch {
|
|
@@ -281,7 +344,7 @@ async function importConfig(cwd) {
|
|
|
281
344
|
error instanceof Error ? error.message : String(error)
|
|
282
345
|
);
|
|
283
346
|
}
|
|
284
|
-
const compiledPath =
|
|
347
|
+
const compiledPath = path4.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
|
|
285
348
|
try {
|
|
286
349
|
await writeFile(compiledPath, code, "utf8");
|
|
287
350
|
} catch (error) {
|
|
@@ -317,7 +380,7 @@ async function importConfig(cwd) {
|
|
|
317
380
|
async function readManifest(cwd) {
|
|
318
381
|
let parsed;
|
|
319
382
|
try {
|
|
320
|
-
parsed = JSON.parse(await readFile(
|
|
383
|
+
parsed = JSON.parse(await readFile(path4.join(cwd, "package.json"), "utf8"));
|
|
321
384
|
} catch (error) {
|
|
322
385
|
fail("TN_CONFIG_PACKAGE_INVALID", error instanceof Error ? error.message : String(error));
|
|
323
386
|
}
|
|
@@ -336,12 +399,12 @@ function packageNativeEntry(manifest) {
|
|
|
336
399
|
}
|
|
337
400
|
function validateNativeEntry(value, cwd) {
|
|
338
401
|
const entry = nonEmptyString(value, "TN_NATIVE_ENTRY_MISSING", "nativeEntry");
|
|
339
|
-
if (
|
|
402
|
+
if (path4.isAbsolute(entry)) {
|
|
340
403
|
fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must be project-relative.");
|
|
341
404
|
}
|
|
342
|
-
const resolved =
|
|
343
|
-
const relative =
|
|
344
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
405
|
+
const resolved = path4.resolve(cwd, entry);
|
|
406
|
+
const relative = path4.relative(cwd, resolved);
|
|
407
|
+
if (relative === ".." || relative.startsWith(`..${path4.sep}`) || path4.isAbsolute(relative)) {
|
|
345
408
|
fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must stay inside the project.");
|
|
346
409
|
}
|
|
347
410
|
return entry;
|
|
@@ -385,18 +448,18 @@ async function validateApp(raw, name, cwd) {
|
|
|
385
448
|
}
|
|
386
449
|
async function validateProjectAsset(raw, cwd, label, options) {
|
|
387
450
|
const relative = nonEmptyString(raw, `${options.codePrefix}_INVALID`, label);
|
|
388
|
-
if (
|
|
451
|
+
if (path4.isAbsolute(relative)) {
|
|
389
452
|
fail(`${options.codePrefix}_PATH_INVALID`, `${label} must be project-relative: ${relative}`);
|
|
390
453
|
}
|
|
391
|
-
const resolved =
|
|
392
|
-
const withinProject =
|
|
393
|
-
if (withinProject === ".." || withinProject.startsWith(`..${
|
|
454
|
+
const resolved = path4.resolve(cwd, relative);
|
|
455
|
+
const withinProject = path4.relative(cwd, resolved);
|
|
456
|
+
if (withinProject === ".." || withinProject.startsWith(`..${path4.sep}`) || path4.isAbsolute(withinProject)) {
|
|
394
457
|
fail(
|
|
395
458
|
`${options.codePrefix}_PATH_INVALID`,
|
|
396
459
|
`${label} must stay inside the project: ${relative}`
|
|
397
460
|
);
|
|
398
461
|
}
|
|
399
|
-
const extension =
|
|
462
|
+
const extension = path4.extname(relative).slice(1).toLowerCase();
|
|
400
463
|
if (!options.formats.includes(extension)) {
|
|
401
464
|
fail(
|
|
402
465
|
options.codePrefix === "TN_CONFIG_ICON" ? `${options.codePrefix}_INVALID` : `${options.codePrefix}_FORMAT_INVALID`,
|
|
@@ -823,6 +886,7 @@ function validateModels(raw) {
|
|
|
823
886
|
if (raw === "none") return "none";
|
|
824
887
|
const models = assertRecord(raw, "assets.models");
|
|
825
888
|
assertKeys(models, "assets.models", [
|
|
889
|
+
"compact",
|
|
826
890
|
"lightmap",
|
|
827
891
|
"passes",
|
|
828
892
|
"quantize",
|
|
@@ -886,6 +950,7 @@ function validateModels(raw) {
|
|
|
886
950
|
}
|
|
887
951
|
const simplify = models.simplify;
|
|
888
952
|
const textures = models.textures;
|
|
953
|
+
const compact = models.compact;
|
|
889
954
|
let virtual;
|
|
890
955
|
if (models.virtual === "none") {
|
|
891
956
|
virtual = "none";
|
|
@@ -915,6 +980,7 @@ function validateModels(raw) {
|
|
|
915
980
|
virtual = bake;
|
|
916
981
|
}
|
|
917
982
|
return {
|
|
983
|
+
...compact === void 0 ? {} : { compact },
|
|
918
984
|
...lightmap === void 0 ? {} : { lightmap },
|
|
919
985
|
...passes === void 0 || Object.keys(passes).length === 0 ? {} : { passes },
|
|
920
986
|
...quantize === void 0 || Object.keys(quantize).length === 0 ? {} : { quantize },
|
|
@@ -1139,9 +1205,239 @@ function validateAssets(raw) {
|
|
|
1139
1205
|
...textures === void 0 ? {} : { textures }
|
|
1140
1206
|
};
|
|
1141
1207
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1208
|
+
var PROFILE_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
|
|
1209
|
+
var PROFILE_ASSET_KEYS = [
|
|
1210
|
+
"audio",
|
|
1211
|
+
"budget",
|
|
1212
|
+
"lod",
|
|
1213
|
+
"models",
|
|
1214
|
+
"targets",
|
|
1215
|
+
"textures"
|
|
1216
|
+
];
|
|
1217
|
+
var PROFILE_TARGETS = ["android", "desktop", "ios", "web"];
|
|
1218
|
+
var ARTIFACT_BUDGET_KEYS = ["artifactBytes", "packagedAssetBytes"];
|
|
1219
|
+
var ARTIFACT_BUDGET_SEVERITIES = ["error", "warn"];
|
|
1220
|
+
var PERFORMANCE_BUDGET_KEYS = [
|
|
1221
|
+
"maxDrawCalls",
|
|
1222
|
+
"maxFrameMsP95",
|
|
1223
|
+
"maxPassDrawCalls",
|
|
1224
|
+
"maxPassTriangles",
|
|
1225
|
+
"maxPhaseMsP95",
|
|
1226
|
+
"maxTriangles",
|
|
1227
|
+
"minFps"
|
|
1228
|
+
];
|
|
1229
|
+
var PERFORMANCE_BUDGET_PHASES = [
|
|
1230
|
+
"hostGap",
|
|
1231
|
+
"overlay",
|
|
1232
|
+
"render",
|
|
1233
|
+
"residual",
|
|
1234
|
+
"update"
|
|
1235
|
+
];
|
|
1236
|
+
var PERFORMANCE_BUDGET_PASSES = ["main", "shadow", "reflection", "nested"];
|
|
1237
|
+
function validatePerformanceBudgetMap(raw, label, names, unit) {
|
|
1238
|
+
const map = assertRecord(raw, label);
|
|
1239
|
+
const entries = Object.entries(map);
|
|
1240
|
+
if (entries.length === 0)
|
|
1241
|
+
fail("TN_CONFIG_PROFILE_INVALID", `${label} must name at least one entry.`);
|
|
1242
|
+
const budget = {};
|
|
1243
|
+
for (const [name, ceiling] of entries) {
|
|
1244
|
+
if (!names.includes(name)) {
|
|
1245
|
+
fail(
|
|
1246
|
+
"TN_CONFIG_PROFILE_INVALID",
|
|
1247
|
+
`${label}.${name} is not recognised. Expected one of: ${names.join(", ")}.`
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
if (typeof ceiling !== "number" || !Number.isFinite(ceiling) || ceiling < 0) {
|
|
1251
|
+
fail(
|
|
1252
|
+
"TN_CONFIG_PROFILE_INVALID",
|
|
1253
|
+
`${label}.${name} must be a non-negative number of ${unit}.`
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
budget[name] = ceiling;
|
|
1257
|
+
}
|
|
1258
|
+
return budget;
|
|
1259
|
+
}
|
|
1260
|
+
function validatePerformanceBudget(raw, label) {
|
|
1261
|
+
const budget = assertRecord(raw, `${label}.performanceBudget`);
|
|
1262
|
+
assertKeys(budget, `${label}.performanceBudget`, PERFORMANCE_BUDGET_KEYS);
|
|
1263
|
+
if (Object.keys(budget).length === 0) {
|
|
1264
|
+
fail(
|
|
1265
|
+
"TN_CONFIG_PROFILE_INVALID",
|
|
1266
|
+
`${label}.performanceBudget must declare at least one ceiling; an empty budget bounds nothing.`
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
const out = {};
|
|
1270
|
+
for (const key of ["maxDrawCalls", "maxFrameMsP95", "maxTriangles", "minFps"]) {
|
|
1271
|
+
const value = budget[key];
|
|
1272
|
+
if (value === void 0) continue;
|
|
1273
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
1274
|
+
fail(
|
|
1275
|
+
"TN_CONFIG_PROFILE_INVALID",
|
|
1276
|
+
`${label}.performanceBudget.${key} must be a non-negative number.`
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
out[key] = value;
|
|
1280
|
+
}
|
|
1281
|
+
for (const [key, names, unit] of [
|
|
1282
|
+
["maxPassDrawCalls", PERFORMANCE_BUDGET_PASSES, "draw calls"],
|
|
1283
|
+
["maxPassTriangles", PERFORMANCE_BUDGET_PASSES, "triangles"],
|
|
1284
|
+
["maxPhaseMsP95", PERFORMANCE_BUDGET_PHASES, "milliseconds"]
|
|
1285
|
+
]) {
|
|
1286
|
+
if (budget[key] === void 0) continue;
|
|
1287
|
+
out[key] = validatePerformanceBudgetMap(
|
|
1288
|
+
budget[key],
|
|
1289
|
+
`${label}.performanceBudget.${key}`,
|
|
1290
|
+
names,
|
|
1291
|
+
unit
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
return out;
|
|
1295
|
+
}
|
|
1296
|
+
function artifactBudgetLimit(raw, label) {
|
|
1297
|
+
const limit = assertRecord(raw, label);
|
|
1298
|
+
assertKeys(limit, label, ["limit", "severity"]);
|
|
1299
|
+
const bytes = positiveInteger(limit.limit, 1, "TN_CONFIG_PROFILE_INVALID", `${label}.limit`);
|
|
1300
|
+
if (typeof limit.severity !== "string" || !ARTIFACT_BUDGET_SEVERITIES.includes(limit.severity)) {
|
|
1301
|
+
fail(
|
|
1302
|
+
"TN_CONFIG_PROFILE_INVALID",
|
|
1303
|
+
`${label}.severity must be one of ${ARTIFACT_BUDGET_SEVERITIES.join(", ")}.`
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
return { limit: bytes, severity: limit.severity };
|
|
1307
|
+
}
|
|
1308
|
+
function validateArtifactBudget(raw, label) {
|
|
1309
|
+
const budget = assertRecord(raw, `${label}.artifactBudget`);
|
|
1310
|
+
assertKeys(budget, `${label}.artifactBudget`, ARTIFACT_BUDGET_KEYS);
|
|
1311
|
+
const artifactBytes = budget.artifactBytes === void 0 ? void 0 : artifactBudgetLimit(budget.artifactBytes, `${label}.artifactBudget.artifactBytes`);
|
|
1312
|
+
const packagedAssetBytes = budget.packagedAssetBytes === void 0 ? void 0 : artifactBudgetLimit(
|
|
1313
|
+
budget.packagedAssetBytes,
|
|
1314
|
+
`${label}.artifactBudget.packagedAssetBytes`
|
|
1315
|
+
);
|
|
1316
|
+
return {
|
|
1317
|
+
...artifactBytes === void 0 ? {} : { artifactBytes },
|
|
1318
|
+
...packagedAssetBytes === void 0 ? {} : { packagedAssetBytes }
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
function resolveBuildProfile(raw, selection) {
|
|
1322
|
+
if (raw === void 0) {
|
|
1323
|
+
if (selection?.profile !== void 0) {
|
|
1324
|
+
fail(
|
|
1325
|
+
"TN_CONFIG_PROFILE_UNKNOWN",
|
|
1326
|
+
`--profile ${selection.profile} was requested but ${CONFIG_FILE} declares no buildProfiles.`
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
return void 0;
|
|
1330
|
+
}
|
|
1331
|
+
const group = assertRecord(raw, "buildProfiles");
|
|
1332
|
+
assertKeys(group, "buildProfiles", ["defaults", "profiles"]);
|
|
1333
|
+
const defaults = assertRecord(group.defaults, "buildProfiles.defaults");
|
|
1334
|
+
assertKeys(defaults, "buildProfiles.defaults", PROFILE_TARGETS);
|
|
1335
|
+
for (const [target, name2] of Object.entries(defaults)) {
|
|
1336
|
+
if (typeof name2 !== "string" || name2.length === 0) {
|
|
1337
|
+
fail("TN_CONFIG_PROFILE_INVALID", `buildProfiles.defaults.${target} must name a profile.`);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
const profiles = assertRecord(group.profiles, "buildProfiles.profiles");
|
|
1341
|
+
const declared = Object.keys(profiles);
|
|
1342
|
+
if (declared.length === 0) {
|
|
1343
|
+
fail("TN_CONFIG_GROUP_INVALID", "buildProfiles.profiles must declare at least one profile.");
|
|
1344
|
+
}
|
|
1345
|
+
const budgets = {};
|
|
1346
|
+
const performanceBudgets = {};
|
|
1347
|
+
for (const name2 of declared) {
|
|
1348
|
+
const label = `buildProfiles.profiles['${name2}']`;
|
|
1349
|
+
if (!PROFILE_NAME.test(name2)) {
|
|
1350
|
+
fail(
|
|
1351
|
+
"TN_CONFIG_PROFILE_NAME_INVALID",
|
|
1352
|
+
`${label} is not a usable profile name ('${name2}'): names are one lower-case path segment matching /^[a-z0-9][a-z0-9_-]{0,63}$/, so no name can traverse out of the build directory or collide by case.`
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
const profile2 = assertRecord(profiles[name2], label);
|
|
1356
|
+
assertKeys(profile2, label, ["artifactBudget", "assets", "performanceBudget"]);
|
|
1357
|
+
assertKeys(
|
|
1358
|
+
assertRecord(profile2.assets, `${label}.assets`),
|
|
1359
|
+
`${label}.assets`,
|
|
1360
|
+
PROFILE_ASSET_KEYS
|
|
1361
|
+
);
|
|
1362
|
+
if (profile2.artifactBudget !== void 0) {
|
|
1363
|
+
budgets[name2] = validateArtifactBudget(profile2.artifactBudget, label);
|
|
1364
|
+
}
|
|
1365
|
+
if (profile2.performanceBudget !== void 0) {
|
|
1366
|
+
performanceBudgets[name2] = validatePerformanceBudget(profile2.performanceBudget, label);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
for (const [target, name2] of Object.entries(defaults)) {
|
|
1370
|
+
if (typeof name2 === "string" && !Object.hasOwn(profiles, name2)) {
|
|
1371
|
+
fail(
|
|
1372
|
+
"TN_CONFIG_PROFILE_UNKNOWN",
|
|
1373
|
+
`buildProfiles.defaults.${target} names '${name2}', which is not declared. Declared profiles: ${declared.join(", ")}.`
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (selection === void 0) return void 0;
|
|
1378
|
+
const requested = selection.profile;
|
|
1379
|
+
const name = requested ?? defaults[selection.target];
|
|
1380
|
+
if (name === void 0) return void 0;
|
|
1381
|
+
const profile = profiles[name];
|
|
1382
|
+
if (profile === void 0) {
|
|
1383
|
+
const asked = requested === void 0 ? `buildProfiles.defaults.${selection.target}` : `--profile ${name}`;
|
|
1384
|
+
fail(
|
|
1385
|
+
"TN_CONFIG_PROFILE_UNKNOWN",
|
|
1386
|
+
`${asked} names a profile this project does not declare. Declared profiles: ${declared.join(", ")}.`
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
return {
|
|
1390
|
+
assets: isRecord(profile.assets) ? profile.assets : {},
|
|
1391
|
+
...budgets[name] === void 0 ? {} : { artifactBudget: budgets[name] },
|
|
1392
|
+
...performanceBudgets[name] === void 0 ? {} : { performanceBudget: performanceBudgets[name] },
|
|
1393
|
+
name,
|
|
1394
|
+
source: requested === void 0 ? "default" : "flag",
|
|
1395
|
+
target: selection.target
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
function mergeProfileOverlay(base, overlay) {
|
|
1399
|
+
if (!isRecord(base)) return overlay;
|
|
1400
|
+
const merged = { ...base };
|
|
1401
|
+
for (const [key, value] of Object.entries(overlay)) {
|
|
1402
|
+
const current = merged[key];
|
|
1403
|
+
merged[key] = isRecord(current) && isRecord(value) ? mergeProfileOverlay(current, value) : value;
|
|
1404
|
+
}
|
|
1405
|
+
return merged;
|
|
1406
|
+
}
|
|
1407
|
+
function assertProfileCapReachable(assets, overlay, name) {
|
|
1408
|
+
const overlayTextures = overlay.textures;
|
|
1409
|
+
const overlayModels = overlay.models;
|
|
1410
|
+
const caps = isRecord(overlayTextures) && overlayTextures.maxSize !== void 0 || isRecord(overlayModels) && isRecord(overlayModels.textures) && overlayModels.textures.maxSize !== void 0;
|
|
1411
|
+
if (!caps) return;
|
|
1412
|
+
const conflicts = [];
|
|
1413
|
+
if (assets.textures !== void 0 && assets.textures !== "none") {
|
|
1414
|
+
for (const override of assets.textures.overrides ?? []) {
|
|
1415
|
+
if (override.codec === "none") {
|
|
1416
|
+
conflicts.push(`assets.textures.overrides glob '${override.glob}' declares codec "none"`);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
const models = assets.models;
|
|
1421
|
+
const modelTextures = models === void 0 || models === "none" ? void 0 : models.textures;
|
|
1422
|
+
if (modelTextures !== void 0 && modelTextures !== "none") {
|
|
1423
|
+
for (const override of modelTextures.overrides ?? []) {
|
|
1424
|
+
if (override.codec === "none") {
|
|
1425
|
+
conflicts.push(
|
|
1426
|
+
`assets.models.textures.overrides slot '${override.slot}' declares codec "none"`
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
if (conflicts.length > 0) {
|
|
1432
|
+
fail(
|
|
1433
|
+
"TN_CONFIG_PROFILE_CONFLICT",
|
|
1434
|
+
`profile '${name}' caps texture size, and ${conflicts.join("; ")}, which returns the authored bytes before resizing. Drop the override, or take the cap out of the profile.`
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
async function loadConfigInternal(root, selection) {
|
|
1439
|
+
const packagePath = path4.join(root, "package.json");
|
|
1440
|
+
const sourcePath = path4.join(root, CONFIG_FILE);
|
|
1145
1441
|
const manifest = await withConfigContext(
|
|
1146
1442
|
packageContext(root),
|
|
1147
1443
|
"TN_CONFIG_PACKAGE_INVALID",
|
|
@@ -1172,7 +1468,8 @@ async function loadConfigInternal(root) {
|
|
|
1172
1468
|
"nativeEntry",
|
|
1173
1469
|
"renderer",
|
|
1174
1470
|
"ui",
|
|
1175
|
-
"assets"
|
|
1471
|
+
"assets",
|
|
1472
|
+
"buildProfiles"
|
|
1176
1473
|
]);
|
|
1177
1474
|
}
|
|
1178
1475
|
const configuredEntry = raw?.nativeEntry;
|
|
@@ -1184,7 +1481,12 @@ async function loadConfigInternal(root) {
|
|
|
1184
1481
|
}
|
|
1185
1482
|
const app = await validateApp(raw?.app, name, root);
|
|
1186
1483
|
const bootSplash = await validateBootSplash(raw?.bootSplash, root);
|
|
1187
|
-
const
|
|
1484
|
+
const profile = resolveBuildProfile(raw?.buildProfiles, selection);
|
|
1485
|
+
const rawAssets = profile === void 0 ? raw?.assets : mergeProfileOverlay(raw?.assets, profile.assets);
|
|
1486
|
+
const assets = rawAssets === void 0 ? void 0 : validateAssets(rawAssets);
|
|
1487
|
+
if (assets !== void 0 && profile !== void 0) {
|
|
1488
|
+
assertProfileCapReachable(assets, profile.assets, profile.name);
|
|
1489
|
+
}
|
|
1188
1490
|
return {
|
|
1189
1491
|
app,
|
|
1190
1492
|
display: validateDisplay(raw?.display),
|
|
@@ -1193,28 +1495,37 @@ async function loadConfigInternal(root) {
|
|
|
1193
1495
|
renderer: validateRenderer(raw?.renderer),
|
|
1194
1496
|
ui: validateUi(raw?.ui),
|
|
1195
1497
|
...bootSplash === void 0 ? {} : { bootSplash },
|
|
1196
|
-
...assets === void 0 ? {} : { assets }
|
|
1498
|
+
...assets === void 0 ? {} : { assets },
|
|
1499
|
+
...profile === void 0 ? {} : {
|
|
1500
|
+
buildProfile: {
|
|
1501
|
+
name: profile.name,
|
|
1502
|
+
source: profile.source,
|
|
1503
|
+
target: profile.target,
|
|
1504
|
+
...profile.artifactBudget === void 0 ? {} : { artifactBudget: profile.artifactBudget },
|
|
1505
|
+
...profile.performanceBudget === void 0 ? {} : { performanceBudget: profile.performanceBudget }
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1197
1508
|
};
|
|
1198
1509
|
}
|
|
1199
1510
|
);
|
|
1200
1511
|
}
|
|
1201
|
-
async function loadConfig(cwd) {
|
|
1202
|
-
const root =
|
|
1512
|
+
async function loadConfig(cwd, selection) {
|
|
1513
|
+
const root = path4.resolve(cwd);
|
|
1203
1514
|
return withConfigContext(
|
|
1204
|
-
validationContext(root, [
|
|
1515
|
+
validationContext(root, [path4.join(root, CONFIG_FILE), path4.join(root, "package.json")]),
|
|
1205
1516
|
"TN_CONFIG_VALIDATION_FAILED",
|
|
1206
|
-
() => loadConfigInternal(root)
|
|
1517
|
+
() => loadConfigInternal(root, selection)
|
|
1207
1518
|
);
|
|
1208
1519
|
}
|
|
1209
1520
|
|
|
1210
1521
|
// src/build.ts
|
|
1211
1522
|
var TARGETS = ["web", "desktop", "android", "ios"];
|
|
1212
1523
|
function projectRequire2(cwd) {
|
|
1213
|
-
return createRequire$1(
|
|
1524
|
+
return createRequire$1(path4.join(cwd, "package.json"));
|
|
1214
1525
|
}
|
|
1215
1526
|
function packageRoot(cwd, packageName) {
|
|
1216
1527
|
try {
|
|
1217
|
-
return
|
|
1528
|
+
return path4.dirname(projectRequire2(cwd).resolve(`${packageName}/package.json`));
|
|
1218
1529
|
} catch {
|
|
1219
1530
|
throw new Error(`Cannot build because '${packageName}' is not installed in ${cwd}.`);
|
|
1220
1531
|
}
|
|
@@ -1225,12 +1536,12 @@ async function run(command, args, cwd) {
|
|
|
1225
1536
|
child.once("error", reject);
|
|
1226
1537
|
child.once("exit", (code) => {
|
|
1227
1538
|
if (code === 0) resolve();
|
|
1228
|
-
else reject(new Error(`${
|
|
1539
|
+
else reject(new Error(`${path4.basename(command)} exited with code ${code ?? "unknown"}.`));
|
|
1229
1540
|
});
|
|
1230
1541
|
});
|
|
1231
1542
|
}
|
|
1232
1543
|
async function projectName(cwd) {
|
|
1233
|
-
const manifest = JSON.parse(await readFile(
|
|
1544
|
+
const manifest = JSON.parse(await readFile(path4.join(cwd, "package.json"), "utf8"));
|
|
1234
1545
|
const name = manifest.name?.replace(/^@[^/]+\//u, "").replace(/[^a-zA-Z0-9._-]/gu, "-");
|
|
1235
1546
|
if (name === void 0 || name.length === 0) throw new Error("package.json must name the game.");
|
|
1236
1547
|
return name;
|
|
@@ -1277,10 +1588,13 @@ function namedAssets(logicalPaths) {
|
|
|
1277
1588
|
const rest = logicalPaths.length - 3;
|
|
1278
1589
|
return rest > 0 ? `${shown} and ${rest} more` : shown;
|
|
1279
1590
|
}
|
|
1591
|
+
function assetRoot(cwd, config) {
|
|
1592
|
+
return path4.resolve(cwd, config.assets?.output ?? "public");
|
|
1593
|
+
}
|
|
1280
1594
|
async function assertNativeAssetsCompatible(cwd, target, config) {
|
|
1281
1595
|
if (target === "desktop" || target === "web") return;
|
|
1282
|
-
const outputRoot =
|
|
1283
|
-
const manifestPath =
|
|
1596
|
+
const outputRoot = assetRoot(cwd, config);
|
|
1597
|
+
const manifestPath = path4.join(outputRoot, "assets.manifest.json");
|
|
1284
1598
|
let raw;
|
|
1285
1599
|
try {
|
|
1286
1600
|
raw = await readFile(manifestPath, "utf8");
|
|
@@ -1319,11 +1633,19 @@ async function assertNativeAssetsCompatible(cwd, target, config) {
|
|
|
1319
1633
|
);
|
|
1320
1634
|
}
|
|
1321
1635
|
}
|
|
1322
|
-
|
|
1636
|
+
function announceProfile(config) {
|
|
1637
|
+
const selected = config.buildProfile;
|
|
1638
|
+
if (selected === void 0) return;
|
|
1639
|
+
process.stdout.write(
|
|
1640
|
+
`threenative build: profile ${selected.name} (${selected.source}) for ${selected.target}
|
|
1641
|
+
`
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
var UI_ENTRY = path4.join("src", "ui", "main.tsx");
|
|
1323
1645
|
var UI_PAGE_PREFIX = ".threenative-ui-";
|
|
1324
1646
|
async function buildUi(cwd, config) {
|
|
1325
|
-
const output =
|
|
1326
|
-
const entry =
|
|
1647
|
+
const output = path4.join(cwd, ".threenative", "build", "ui");
|
|
1648
|
+
const entry = path4.join(cwd, UI_ENTRY);
|
|
1327
1649
|
try {
|
|
1328
1650
|
if (!(await stat(entry)).isFile()) throw new Error("not a file");
|
|
1329
1651
|
} catch {
|
|
@@ -1331,9 +1653,9 @@ async function buildUi(cwd, config) {
|
|
|
1331
1653
|
`TN_UI_ENTRY_MISSING: ui.renderer is "${config.ui.renderer}" but ${UI_ENTRY} does not exist. It is the entry every platform's web view loads; create it, or set ui.renderer to "native".`
|
|
1332
1654
|
);
|
|
1333
1655
|
}
|
|
1334
|
-
const buildRoot =
|
|
1656
|
+
const buildRoot = path4.join(cwd, ".threenative", "build");
|
|
1335
1657
|
await mkdir(buildRoot, { recursive: true });
|
|
1336
|
-
const page =
|
|
1658
|
+
const page = path4.join(cwd, `${UI_PAGE_PREFIX}${randomUUID()}.html`);
|
|
1337
1659
|
await writeFile(
|
|
1338
1660
|
page,
|
|
1339
1661
|
[
|
|
@@ -1346,20 +1668,20 @@ async function buildUi(cwd, config) {
|
|
|
1346
1668
|
" </head>",
|
|
1347
1669
|
" <body>",
|
|
1348
1670
|
' <div id="tn-ui"></div>',
|
|
1349
|
-
` <script type="module" src="/${UI_ENTRY.split(
|
|
1671
|
+
` <script type="module" src="/${UI_ENTRY.split(path4.sep).join("/")}"></script>`,
|
|
1350
1672
|
" </body>",
|
|
1351
1673
|
"</html>"
|
|
1352
1674
|
].join("\n")
|
|
1353
1675
|
);
|
|
1354
|
-
const driver =
|
|
1676
|
+
const driver = path4.join(buildRoot, "build-ui.mjs");
|
|
1355
1677
|
await writeFile(driver, uiBuildDriver(cwd, page, output));
|
|
1356
1678
|
try {
|
|
1357
1679
|
await run(process.execPath, [driver], cwd);
|
|
1358
1680
|
} finally {
|
|
1359
1681
|
await rm(page, { force: true });
|
|
1360
1682
|
}
|
|
1361
|
-
const generatedPage =
|
|
1362
|
-
const index =
|
|
1683
|
+
const generatedPage = path4.join(output, path4.basename(page));
|
|
1684
|
+
const index = path4.join(output, "index.html");
|
|
1363
1685
|
await rename(generatedPage, index);
|
|
1364
1686
|
return output;
|
|
1365
1687
|
}
|
|
@@ -1399,31 +1721,94 @@ function uiBuildDriver(cwd, page, output) {
|
|
|
1399
1721
|
].join("\n")}
|
|
1400
1722
|
`;
|
|
1401
1723
|
}
|
|
1402
|
-
async function buildWeb(cwd, viteArgs = []) {
|
|
1403
|
-
const config = await loadConfig(cwd);
|
|
1724
|
+
async function buildWeb(cwd, viteArgs = [], profile) {
|
|
1725
|
+
const config = await loadConfig(cwd, { target: "web", profile });
|
|
1726
|
+
announceProfile(config);
|
|
1404
1727
|
await compileAssets({ config: config.assets, cwd, platform: "web" });
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1728
|
+
const assets = assetRoot(cwd, config);
|
|
1729
|
+
const outDir = path4.resolve(cwd, viteOutDir(viteArgs));
|
|
1730
|
+
const staging = stagingPath(outDir);
|
|
1731
|
+
const driver = path4.join(cwd, ".threenative", "build", "vite.web.mjs");
|
|
1732
|
+
try {
|
|
1733
|
+
await mkdir(path4.dirname(staging), { recursive: true });
|
|
1734
|
+
await mkdir(path4.dirname(driver), { recursive: true });
|
|
1735
|
+
await writeFile(driver, webBuildDriver(cwd, assets));
|
|
1736
|
+
await run(
|
|
1737
|
+
process.execPath,
|
|
1738
|
+
[
|
|
1739
|
+
path4.join(packageRoot(cwd, "vite"), "bin/vite.js"),
|
|
1740
|
+
"build",
|
|
1741
|
+
...stagedViteArgs(viteArgs, staging),
|
|
1742
|
+
...ownConfigArgs(viteArgs, driver, assets === path4.resolve(cwd, "public"))
|
|
1743
|
+
],
|
|
1744
|
+
cwd
|
|
1415
1745
|
);
|
|
1746
|
+
await pruneUnpackagedAssets(cwd, config, staging);
|
|
1747
|
+
const report = await writeCompressionSidecars(staging);
|
|
1748
|
+
if (report !== void 0) {
|
|
1749
|
+
process.stdout.write(
|
|
1750
|
+
`web main chunk ${report.entry}: raw ${report.raw} B, gzip ${report.gzip} B, brotli ${report.brotli} B
|
|
1751
|
+
`
|
|
1752
|
+
);
|
|
1753
|
+
}
|
|
1754
|
+
await assertArtifactBudget(cwd, config, outDir, staging, assets);
|
|
1755
|
+
await writeBuildReport({
|
|
1756
|
+
artifact: staging,
|
|
1757
|
+
assets,
|
|
1758
|
+
config,
|
|
1759
|
+
packagedAssetBytes: await measurePackagedAssetBytes(cwd, assets),
|
|
1760
|
+
target: "web"
|
|
1761
|
+
});
|
|
1762
|
+
await publishStagedArtifact(outDir, staging);
|
|
1763
|
+
} catch (error) {
|
|
1764
|
+
await rm(path4.dirname(staging), { force: true, recursive: true });
|
|
1765
|
+
throw error;
|
|
1416
1766
|
}
|
|
1417
1767
|
}
|
|
1768
|
+
function webBuildDriver(cwd, assets) {
|
|
1769
|
+
const literal = (value) => JSON.stringify(value);
|
|
1770
|
+
return `${[
|
|
1771
|
+
'import { defineConfig, loadConfigFromFile, mergeConfig } from "vite";',
|
|
1772
|
+
"",
|
|
1773
|
+
`const root = ${literal(cwd)};`,
|
|
1774
|
+
`const assets = ${literal(assets)};`,
|
|
1775
|
+
"export default defineConfig(async ({ command, mode }) => {",
|
|
1776
|
+
" const own = (await loadConfigFromFile({ command, mode }, undefined, root))?.config ?? {};",
|
|
1777
|
+
" return mergeConfig(own, own.publicDir === undefined ? { publicDir: assets } : {});",
|
|
1778
|
+
"});",
|
|
1779
|
+
""
|
|
1780
|
+
].join("\n")}
|
|
1781
|
+
`;
|
|
1782
|
+
}
|
|
1783
|
+
function ownConfigArgs(viteArgs, driver, defaultRoot) {
|
|
1784
|
+
const named = viteArgs.some((arg) => arg === "--config" || arg.startsWith("--config="));
|
|
1785
|
+
return named || defaultRoot ? [] : ["--config", driver];
|
|
1786
|
+
}
|
|
1787
|
+
async function pruneUnpackagedAssets(cwd, config, outDir) {
|
|
1788
|
+
const assets = assetRoot(cwd, config);
|
|
1789
|
+
if (!existsSync(assets)) return;
|
|
1790
|
+
const selector = await packagingSelector(cwd);
|
|
1791
|
+
if (selector === void 0) return;
|
|
1792
|
+
for (const file of selector.selectManifestAssets(assets).dropped)
|
|
1793
|
+
await rm(path4.join(outDir, file), { force: true });
|
|
1794
|
+
}
|
|
1418
1795
|
function viteOutDir(viteArgs) {
|
|
1419
1796
|
const index = viteArgs.findIndex((arg) => arg === "--outDir" || arg.startsWith("--outDir="));
|
|
1420
1797
|
if (index === -1) return "dist";
|
|
1421
1798
|
const flag = viteArgs[index];
|
|
1422
1799
|
return flag.startsWith("--outDir=") ? flag.slice("--outDir=".length) : viteArgs[index + 1] ?? "dist";
|
|
1423
1800
|
}
|
|
1801
|
+
function stagedViteArgs(viteArgs, staging) {
|
|
1802
|
+
const index = viteArgs.findIndex((arg) => arg === "--outDir" || arg.startsWith("--outDir="));
|
|
1803
|
+
if (index === -1) return [...viteArgs, "--outDir", staging];
|
|
1804
|
+
const staged = [...viteArgs];
|
|
1805
|
+
if (staged[index].startsWith("--outDir=")) staged[index] = `--outDir=${staging}`;
|
|
1806
|
+
else staged[index + 1] = staging;
|
|
1807
|
+
return staged;
|
|
1808
|
+
}
|
|
1424
1809
|
async function nativeEntry(cwd, config) {
|
|
1425
1810
|
const relative = (config ?? await loadConfig(cwd)).nativeEntry;
|
|
1426
|
-
const entry =
|
|
1811
|
+
const entry = path4.resolve(cwd, relative);
|
|
1427
1812
|
try {
|
|
1428
1813
|
if (!(await stat(entry)).isFile()) throw new Error("not a file");
|
|
1429
1814
|
} catch {
|
|
@@ -1432,25 +1817,25 @@ async function nativeEntry(cwd, config) {
|
|
|
1432
1817
|
return entry;
|
|
1433
1818
|
}
|
|
1434
1819
|
function resolvePackagingConfig(cwd, config) {
|
|
1435
|
-
const resolve = (value) => value === void 0 ? void 0 :
|
|
1820
|
+
const resolve = (value) => value === void 0 ? void 0 : path4.resolve(cwd, value);
|
|
1436
1821
|
const artifact = {
|
|
1437
1822
|
...config,
|
|
1438
1823
|
app: {
|
|
1439
1824
|
...config.app,
|
|
1440
|
-
...config.app.icon === void 0 ? {} : { icon:
|
|
1825
|
+
...config.app.icon === void 0 ? {} : { icon: path4.resolve(cwd, config.app.icon) },
|
|
1441
1826
|
...config.app.icons === void 0 ? {} : {
|
|
1442
1827
|
icons: {
|
|
1443
1828
|
...config.app.icons.android === void 0 ? {} : {
|
|
1444
1829
|
android: {
|
|
1445
|
-
...config.app.icons.android.foreground === void 0 ? {} : { foreground:
|
|
1830
|
+
...config.app.icons.android.foreground === void 0 ? {} : { foreground: path4.resolve(cwd, config.app.icons.android.foreground) },
|
|
1446
1831
|
...config.app.icons.android.background === void 0 ? {} : { background: config.app.icons.android.background },
|
|
1447
|
-
...config.app.icons.android.monochrome === void 0 ? {} : { monochrome:
|
|
1832
|
+
...config.app.icons.android.monochrome === void 0 ? {} : { monochrome: path4.resolve(cwd, config.app.icons.android.monochrome) }
|
|
1448
1833
|
}
|
|
1449
1834
|
},
|
|
1450
1835
|
...config.app.icons.ios === void 0 ? {} : {
|
|
1451
1836
|
ios: {
|
|
1452
|
-
...config.app.icons.ios.dark === void 0 ? {} : { dark:
|
|
1453
|
-
...config.app.icons.ios.tinted === void 0 ? {} : { tinted:
|
|
1837
|
+
...config.app.icons.ios.dark === void 0 ? {} : { dark: path4.resolve(cwd, config.app.icons.ios.dark) },
|
|
1838
|
+
...config.app.icons.ios.tinted === void 0 ? {} : { tinted: path4.resolve(cwd, config.app.icons.ios.tinted) }
|
|
1454
1839
|
}
|
|
1455
1840
|
},
|
|
1456
1841
|
...config.app.icons.web === void 0 ? {} : {
|
|
@@ -1467,17 +1852,17 @@ function resolvePackagingConfig(cwd, config) {
|
|
|
1467
1852
|
...config.bootSplash === void 0 ? {} : {
|
|
1468
1853
|
bootSplash: {
|
|
1469
1854
|
...config.bootSplash,
|
|
1470
|
-
...config.bootSplash.image === void 0 ? {} : { image:
|
|
1855
|
+
...config.bootSplash.image === void 0 ? {} : { image: path4.resolve(cwd, config.bootSplash.image) }
|
|
1471
1856
|
}
|
|
1472
1857
|
}
|
|
1473
1858
|
};
|
|
1474
1859
|
return artifact;
|
|
1475
1860
|
}
|
|
1476
1861
|
async function writePackagingConfig(cwd, config) {
|
|
1477
|
-
const directory =
|
|
1862
|
+
const directory = path4.join(cwd, ".threenative", "build");
|
|
1478
1863
|
await mkdir(directory, { recursive: true });
|
|
1479
1864
|
const artifact = resolvePackagingConfig(cwd, config);
|
|
1480
|
-
const output =
|
|
1865
|
+
const output = path4.join(directory, "config.json");
|
|
1481
1866
|
await writeFile(output, `${JSON.stringify(artifact, null, 2)}
|
|
1482
1867
|
`);
|
|
1483
1868
|
return output;
|
|
@@ -1495,11 +1880,11 @@ function runtimeHasWebAssembly(binary = process.env.THREENATIVE_RUNTIME_BINARY,
|
|
|
1495
1880
|
return !/^(?:quickjs|jsc)$/iu.test(engine);
|
|
1496
1881
|
}
|
|
1497
1882
|
async function bundleNative(cwd, runtimeRoot, entry, target, nativeBackend) {
|
|
1498
|
-
const output =
|
|
1883
|
+
const output = path4.join(cwd, ".threenative", "build", "game.js");
|
|
1499
1884
|
await run(
|
|
1500
1885
|
process.execPath,
|
|
1501
1886
|
[
|
|
1502
|
-
|
|
1887
|
+
path4.join(runtimeRoot, "scripts", "bundle.mjs"),
|
|
1503
1888
|
"--project",
|
|
1504
1889
|
cwd,
|
|
1505
1890
|
"--entry",
|
|
@@ -1514,8 +1899,61 @@ async function bundleNative(cwd, runtimeRoot, entry, target, nativeBackend) {
|
|
|
1514
1899
|
);
|
|
1515
1900
|
return output;
|
|
1516
1901
|
}
|
|
1517
|
-
async function
|
|
1518
|
-
|
|
1902
|
+
async function packagingSelector(cwd) {
|
|
1903
|
+
try {
|
|
1904
|
+
const module = path4.join(
|
|
1905
|
+
packageRoot(cwd, "@threenative/runtime-native"),
|
|
1906
|
+
"scripts",
|
|
1907
|
+
"asset-manifest.mjs"
|
|
1908
|
+
);
|
|
1909
|
+
return await import(pathToFileURL(module).href);
|
|
1910
|
+
} catch {
|
|
1911
|
+
return void 0;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
async function measurePackagedAssetBytes(cwd, assets) {
|
|
1915
|
+
if (!existsSync(assets)) return 0;
|
|
1916
|
+
const selector = await packagingSelector(cwd);
|
|
1917
|
+
if (selector === void 0) return measureTreeBytes(assets);
|
|
1918
|
+
let total = 0;
|
|
1919
|
+
for (const file of selector.selectManifestAssets(assets, { log: () => {
|
|
1920
|
+
} }).selected)
|
|
1921
|
+
total += (await stat(path4.join(assets, file))).size;
|
|
1922
|
+
return total;
|
|
1923
|
+
}
|
|
1924
|
+
function budgetSentence(metric, measured, limit) {
|
|
1925
|
+
return `threenative build: ${metric} measured ${measured} bytes over its ${limit}-byte limit.`;
|
|
1926
|
+
}
|
|
1927
|
+
async function assertArtifactBudget(cwd, config, final, staged, assets) {
|
|
1928
|
+
const budget = config.buildProfile?.artifactBudget;
|
|
1929
|
+
if (budget === void 0) return;
|
|
1930
|
+
const metrics = [
|
|
1931
|
+
{
|
|
1932
|
+
declared: budget.artifactBytes,
|
|
1933
|
+
measured: await measureTreeBytes(staged),
|
|
1934
|
+
name: "artifactBytes"
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
declared: budget.packagedAssetBytes,
|
|
1938
|
+
measured: await measurePackagedAssetBytes(cwd, assets),
|
|
1939
|
+
name: "packagedAssetBytes"
|
|
1940
|
+
}
|
|
1941
|
+
];
|
|
1942
|
+
for (const { declared, measured, name } of metrics) {
|
|
1943
|
+
if (declared === void 0 || measured <= declared.limit) continue;
|
|
1944
|
+
const sentence = budgetSentence(name, measured, declared.limit);
|
|
1945
|
+
if (declared.severity === "error") {
|
|
1946
|
+
throw new Error(
|
|
1947
|
+
`TN_BUILD_ARTIFACT_BUDGET_EXCEEDED: ${sentence} The build did not publish, so ${final} is still the previous artifact.`
|
|
1948
|
+
);
|
|
1949
|
+
}
|
|
1950
|
+
process.stdout.write(`${sentence}
|
|
1951
|
+
`);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
async function buildNative(target, cwd, allowSourceBuild = false, mode = "debug", format = "apk", profile) {
|
|
1955
|
+
const config = await loadConfig(cwd, { target, profile });
|
|
1956
|
+
announceProfile(config);
|
|
1519
1957
|
assertNativeUiRendererCompatible(target, config.ui.renderer);
|
|
1520
1958
|
const webAssembly = runtimeHasWebAssembly();
|
|
1521
1959
|
await compileAssets({
|
|
@@ -1531,14 +1969,15 @@ async function buildNative(target, cwd, allowSourceBuild = false, mode = "debug"
|
|
|
1531
1969
|
const runtimeRoot = packageRoot(cwd, "@threenative/runtime-native");
|
|
1532
1970
|
const bundle = await bundleNative(cwd, runtimeRoot, entry, target, !webAssembly);
|
|
1533
1971
|
await assertNativeBundleCompatible(bundle, target);
|
|
1534
|
-
const assets =
|
|
1972
|
+
const assets = assetRoot(cwd, config);
|
|
1535
1973
|
const ui = config.ui.renderer === "web" ? await buildUi(cwd, config) : void 0;
|
|
1536
1974
|
if (target === "ios") {
|
|
1537
|
-
const output2 =
|
|
1538
|
-
await
|
|
1539
|
-
|
|
1975
|
+
const output2 = path4.join(cwd, "dist-native", `${await projectName(cwd)}.app`);
|
|
1976
|
+
await packageStaged(
|
|
1977
|
+
output2,
|
|
1978
|
+
runtimeRoot,
|
|
1540
1979
|
[
|
|
1541
|
-
|
|
1980
|
+
path4.join(runtimeRoot, "scripts", "package-ios.mjs"),
|
|
1542
1981
|
"--bundle",
|
|
1543
1982
|
bundle,
|
|
1544
1983
|
"--assets",
|
|
@@ -1551,20 +1990,21 @@ async function buildNative(target, cwd, allowSourceBuild = false, mode = "debug"
|
|
|
1551
1990
|
"--output",
|
|
1552
1991
|
output2
|
|
1553
1992
|
],
|
|
1554
|
-
|
|
1993
|
+
{ assets, config, target: "ios" }
|
|
1555
1994
|
);
|
|
1556
1995
|
return;
|
|
1557
1996
|
}
|
|
1558
1997
|
if (target === "android") {
|
|
1559
|
-
const output2 =
|
|
1998
|
+
const output2 = path4.join(
|
|
1560
1999
|
cwd,
|
|
1561
2000
|
"dist-native",
|
|
1562
2001
|
`${await projectName(cwd)}.${format === "aab" ? "aab" : "apk"}`
|
|
1563
2002
|
);
|
|
1564
|
-
await
|
|
1565
|
-
|
|
2003
|
+
await packageStaged(
|
|
2004
|
+
output2,
|
|
2005
|
+
runtimeRoot,
|
|
1566
2006
|
[
|
|
1567
|
-
|
|
2007
|
+
path4.join(runtimeRoot, "scripts", "package-android.mjs"),
|
|
1568
2008
|
...allowSourceBuild ? ["--allow-source-build"] : [],
|
|
1569
2009
|
"--mode",
|
|
1570
2010
|
mode,
|
|
@@ -1586,15 +2026,16 @@ async function buildNative(target, cwd, allowSourceBuild = false, mode = "debug"
|
|
|
1586
2026
|
"--output",
|
|
1587
2027
|
output2
|
|
1588
2028
|
],
|
|
1589
|
-
|
|
2029
|
+
{ assets, config, target: "android" }
|
|
1590
2030
|
);
|
|
1591
2031
|
return;
|
|
1592
2032
|
}
|
|
1593
|
-
const output =
|
|
1594
|
-
await
|
|
1595
|
-
|
|
2033
|
+
const output = path4.join(cwd, "dist-native", await projectName(cwd));
|
|
2034
|
+
await packageStaged(
|
|
2035
|
+
output,
|
|
2036
|
+
cwd,
|
|
1596
2037
|
[
|
|
1597
|
-
|
|
2038
|
+
path4.join(runtimeRoot, "scripts", "package-desktop.mjs"),
|
|
1598
2039
|
"--mode",
|
|
1599
2040
|
mode,
|
|
1600
2041
|
"--bundle",
|
|
@@ -1604,13 +2045,115 @@ async function buildNative(target, cwd, allowSourceBuild = false, mode = "debug"
|
|
|
1604
2045
|
...ui === void 0 ? [] : ["--ui", ui],
|
|
1605
2046
|
"--config",
|
|
1606
2047
|
configPath,
|
|
1607
|
-
...process.env.THREENATIVE_RUNTIME_BINARY ? ["--runtime",
|
|
2048
|
+
...process.env.THREENATIVE_RUNTIME_BINARY ? ["--runtime", path4.resolve(process.env.THREENATIVE_RUNTIME_BINARY)] : [],
|
|
1608
2049
|
"--output",
|
|
1609
2050
|
output
|
|
1610
2051
|
],
|
|
1611
|
-
|
|
2052
|
+
{ assets, config, target: "desktop" }
|
|
1612
2053
|
);
|
|
1613
2054
|
}
|
|
2055
|
+
async function packageStaged(output, cwd, args, report) {
|
|
2056
|
+
const staged = stagingPath(output);
|
|
2057
|
+
const index = args.indexOf("--output");
|
|
2058
|
+
if (index < 0 || index + 1 >= args.length) {
|
|
2059
|
+
throw new Error("packageStaged needs the packager's --output <path> argument to stage it.");
|
|
2060
|
+
}
|
|
2061
|
+
const packager = [...args];
|
|
2062
|
+
packager[index + 1] = staged;
|
|
2063
|
+
try {
|
|
2064
|
+
await mkdir(path4.dirname(staged), { recursive: true });
|
|
2065
|
+
await run(process.execPath, packager, cwd);
|
|
2066
|
+
if (report !== void 0) {
|
|
2067
|
+
const produced = await producedArtifact(staged);
|
|
2068
|
+
if (report.config.buildProfile?.artifactBudget !== void 0)
|
|
2069
|
+
await assertArtifactBudget(cwd, report.config, output, produced, report.assets);
|
|
2070
|
+
await writeBuildReport({
|
|
2071
|
+
artifact: produced,
|
|
2072
|
+
assets: report.assets,
|
|
2073
|
+
config: report.config,
|
|
2074
|
+
packagedAssetBytes: await measurePackagedAssetBytes(cwd, report.assets),
|
|
2075
|
+
target: report.target
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
} catch (error) {
|
|
2079
|
+
await rm(path4.dirname(staged), { force: true, recursive: true });
|
|
2080
|
+
throw error;
|
|
2081
|
+
}
|
|
2082
|
+
await publishStagedArtifact(output, staged);
|
|
2083
|
+
}
|
|
2084
|
+
function stagingPath(final) {
|
|
2085
|
+
return path4.join(path4.dirname(final), `.staging-${process.pid}`, path4.basename(final));
|
|
2086
|
+
}
|
|
2087
|
+
async function producedArtifact(staged) {
|
|
2088
|
+
const directory = path4.dirname(staged);
|
|
2089
|
+
const name = path4.basename(staged);
|
|
2090
|
+
const entries = existsSync(directory) ? await readdir(directory) : [];
|
|
2091
|
+
for (const candidate of [name, `${name}.exe`, `${name}.app`, `${name}.tar.gz`, `${name}.zip`]) {
|
|
2092
|
+
if (entries.includes(candidate)) return path4.join(directory, candidate);
|
|
2093
|
+
}
|
|
2094
|
+
const other = entries.filter((entry) => !entry.endsWith(BUILD_REPORT_SUFFIX)).sort()[0];
|
|
2095
|
+
if (other === void 0) {
|
|
2096
|
+
throw new Error(
|
|
2097
|
+
`TN_BUILD_ARTIFACT_MISSING: the packager exited successfully but wrote no artifact to ${staged}.`
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
2100
|
+
return path4.join(directory, other);
|
|
2101
|
+
}
|
|
2102
|
+
async function publishStagedArtifact(final, staging) {
|
|
2103
|
+
const from = path4.dirname(staging);
|
|
2104
|
+
const produced = existsSync(from) ? await readdir(from) : [];
|
|
2105
|
+
if (!produced.some((name) => !name.endsWith(BUILD_REPORT_SUFFIX))) {
|
|
2106
|
+
throw new Error(
|
|
2107
|
+
`TN_BUILD_ARTIFACT_MISSING: the packager exited successfully but wrote no artifact to ${staging}; ${final} is unchanged.`
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
const directory = path4.dirname(final);
|
|
2111
|
+
for (const name of produced) {
|
|
2112
|
+
const source = path4.join(from, name);
|
|
2113
|
+
const to = path4.join(directory, name);
|
|
2114
|
+
if (!existsSync(to)) {
|
|
2115
|
+
await rename(source, to);
|
|
2116
|
+
continue;
|
|
2117
|
+
}
|
|
2118
|
+
const previous = path4.join(from, `${name}.previous`);
|
|
2119
|
+
await rename(to, previous);
|
|
2120
|
+
try {
|
|
2121
|
+
await rename(source, to);
|
|
2122
|
+
} catch (error) {
|
|
2123
|
+
await rename(previous, to);
|
|
2124
|
+
throw error;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
await rm(from, { force: true, recursive: true });
|
|
2128
|
+
}
|
|
2129
|
+
var BUILD_LOCK = path4.join(".threenative", "build.lock");
|
|
2130
|
+
function pidAlive(pid) {
|
|
2131
|
+
try {
|
|
2132
|
+
process.kill(pid, 0);
|
|
2133
|
+
return true;
|
|
2134
|
+
} catch (error) {
|
|
2135
|
+
return error.code === "EPERM";
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
async function acquireBuildLock(lock) {
|
|
2139
|
+
for (; ; ) {
|
|
2140
|
+
try {
|
|
2141
|
+
const handle = await open(lock, "wx");
|
|
2142
|
+
await handle.writeFile(String(process.pid));
|
|
2143
|
+
await handle.close();
|
|
2144
|
+
return;
|
|
2145
|
+
} catch (error) {
|
|
2146
|
+
if (error.code !== "EEXIST") throw error;
|
|
2147
|
+
const pid = Number.parseInt((await readFile(lock, "utf8").catch(() => "")).trim(), 10);
|
|
2148
|
+
if (Number.isSafeInteger(pid) && pid > 0 && pidAlive(pid)) {
|
|
2149
|
+
throw new Error(
|
|
2150
|
+
`TN_BUILD_BUSY: another threenative build (pid ${pid}) holds ${lock}. Wait for it to finish; if that process is gone, delete the lock.`
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
await rm(lock, { force: true });
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
1614
2157
|
async function build(options) {
|
|
1615
2158
|
if (options.allowSourceBuild && options.target !== "android") {
|
|
1616
2159
|
throw new Error("--allow-source-build is supported only for --target android.");
|
|
@@ -1625,15 +2168,29 @@ async function build(options) {
|
|
|
1625
2168
|
if (format === "aab" && mode !== "release") {
|
|
1626
2169
|
throw new Error("--format aab requires --mode release.");
|
|
1627
2170
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
2171
|
+
if (options.target !== "web" && (options.viteArgs?.length ?? 0) > 0) {
|
|
2172
|
+
throw new Error(
|
|
2173
|
+
`${options.target} build does not accept ${options.viteArgs?.join(" ")}. iOS output is simulator-only; device signing remains OPEN.`
|
|
2174
|
+
);
|
|
2175
|
+
}
|
|
2176
|
+
const cwd = path4.resolve(options.cwd ?? process.cwd());
|
|
2177
|
+
const lock = path4.join(cwd, BUILD_LOCK);
|
|
2178
|
+
await mkdir(path4.dirname(lock), { recursive: true });
|
|
2179
|
+
await acquireBuildLock(lock);
|
|
2180
|
+
try {
|
|
2181
|
+
if (options.target === "web") await buildWeb(cwd, options.viteArgs, options.profile);
|
|
2182
|
+
else {
|
|
2183
|
+
await buildNative(
|
|
2184
|
+
options.target,
|
|
2185
|
+
cwd,
|
|
2186
|
+
options.allowSourceBuild === true,
|
|
2187
|
+
mode,
|
|
2188
|
+
format,
|
|
2189
|
+
options.profile
|
|
1634
2190
|
);
|
|
1635
2191
|
}
|
|
1636
|
-
|
|
2192
|
+
} finally {
|
|
2193
|
+
await rm(lock, { force: true });
|
|
1637
2194
|
}
|
|
1638
2195
|
}
|
|
1639
2196
|
function buildHelp() {
|
|
@@ -1644,6 +2201,7 @@ function buildHelp() {
|
|
|
1644
2201
|
" --target <target> Choose web, desktop, android, or ios (default: web).",
|
|
1645
2202
|
" --mode <mode> debug (default) or release. Desktop release wraps the executable in one complete OS container.",
|
|
1646
2203
|
" --format <format> Android only: apk (default) or aab. aab requires --mode release.",
|
|
2204
|
+
" --profile <name> A buildProfiles name; wins over buildProfiles.defaults for the target.",
|
|
1647
2205
|
" --allow-source-build Explicitly allow Android maintainer source compilation.",
|
|
1648
2206
|
" --help Show this help."
|
|
1649
2207
|
].join("\n")}
|
|
@@ -1670,6 +2228,7 @@ function parseBuildArgs(argv) {
|
|
|
1670
2228
|
if (format !== void 0 && format !== "apk" && format !== "aab") {
|
|
1671
2229
|
throw new Error(`Unknown build format '${format}'. Choose apk or aab.`);
|
|
1672
2230
|
}
|
|
2231
|
+
const profile = flagValue(argv, "--profile");
|
|
1673
2232
|
if (mode !== void 0 && value !== "android" && value !== "desktop" || format !== void 0 && value !== "android") {
|
|
1674
2233
|
throw new Error(
|
|
1675
2234
|
"--mode is supported only for --target android or desktop; --format only for --target android."
|
|
@@ -1684,7 +2243,7 @@ function parseBuildArgs(argv) {
|
|
|
1684
2243
|
if (argv[index] === "--allow-source-build") consumed.add(index);
|
|
1685
2244
|
}
|
|
1686
2245
|
}
|
|
1687
|
-
for (const flag of ["--mode", "--format"]) {
|
|
2246
|
+
for (const flag of ["--mode", "--format", "--profile"]) {
|
|
1688
2247
|
for (let index = 1; index < argv.length; index += 1) {
|
|
1689
2248
|
if (argv[index] === flag) {
|
|
1690
2249
|
consumed.add(index);
|
|
@@ -1701,6 +2260,7 @@ function parseBuildArgs(argv) {
|
|
|
1701
2260
|
...allowSourceBuild ? { allowSourceBuild: true } : {},
|
|
1702
2261
|
...mode === void 0 ? {} : { mode },
|
|
1703
2262
|
...format === void 0 ? {} : { format },
|
|
2263
|
+
...profile === void 0 ? {} : { profile },
|
|
1704
2264
|
viteArgs: argv.filter((_, index) => !consumed.has(index))
|
|
1705
2265
|
};
|
|
1706
2266
|
}
|
|
@@ -1747,13 +2307,13 @@ function binaryNames(platformName) {
|
|
|
1747
2307
|
function pathCandidates(environment, platformName) {
|
|
1748
2308
|
const raw = environment.PATH ?? environment.Path ?? "";
|
|
1749
2309
|
if (raw.trim().length === 0) return [];
|
|
1750
|
-
return raw.split(
|
|
2310
|
+
return raw.split(path4.delimiter).filter((directory) => directory.trim().length > 0).flatMap((directory) => binaryNames(platformName).map((name) => path4.join(directory, name)));
|
|
1751
2311
|
}
|
|
1752
2312
|
function conventionalCandidates(platformName, home) {
|
|
1753
2313
|
if (platformName === "darwin") {
|
|
1754
2314
|
return [
|
|
1755
2315
|
"/Applications/Blender.app/Contents/MacOS/Blender",
|
|
1756
|
-
|
|
2316
|
+
path4.join(home, "Applications/Blender.app/Contents/MacOS/Blender")
|
|
1757
2317
|
];
|
|
1758
2318
|
}
|
|
1759
2319
|
if (platformName === "win32") {
|
|
@@ -1763,7 +2323,7 @@ function conventionalCandidates(platformName, home) {
|
|
|
1763
2323
|
];
|
|
1764
2324
|
return roots.flatMap(
|
|
1765
2325
|
(root) => ["5.2", "5.1", "5.0", "4.5", "4.2"].map(
|
|
1766
|
-
(release) =>
|
|
2326
|
+
(release) => path4.join(root, "Blender Foundation", `Blender ${release}`, "blender.exe")
|
|
1767
2327
|
)
|
|
1768
2328
|
);
|
|
1769
2329
|
}
|
|
@@ -1772,7 +2332,7 @@ function conventionalCandidates(platformName, home) {
|
|
|
1772
2332
|
"/usr/local/bin/blender",
|
|
1773
2333
|
"/snap/bin/blender",
|
|
1774
2334
|
"/var/lib/flatpak/exports/bin/org.blender.Blender",
|
|
1775
|
-
|
|
2335
|
+
path4.join(home, ".local/bin/blender")
|
|
1776
2336
|
];
|
|
1777
2337
|
}
|
|
1778
2338
|
function parseBlenderVersion(output) {
|
|
@@ -1805,7 +2365,7 @@ function resolveBlender(environment = process.env, options = {}) {
|
|
|
1805
2365
|
const install = BLENDER_INSTALL_GUIDANCE;
|
|
1806
2366
|
const override = environment.THREENATIVE_BLENDER_PATH;
|
|
1807
2367
|
if (override !== void 0 && override.trim().length > 0) {
|
|
1808
|
-
const candidate =
|
|
2368
|
+
const candidate = path4.resolve(override.trim());
|
|
1809
2369
|
if (!executableFile(candidate)) {
|
|
1810
2370
|
return {
|
|
1811
2371
|
available: false,
|
|
@@ -1899,10 +2459,10 @@ var MCP_SERVERS = Object.freeze({
|
|
|
1899
2459
|
})
|
|
1900
2460
|
});
|
|
1901
2461
|
var MCP_PACKAGES = Object.freeze({
|
|
1902
|
-
assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.9.
|
|
2462
|
+
assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.9.5" }),
|
|
1903
2463
|
sculpt: Object.freeze({ name: "threenative-sculpt-mcp", version: "0.1.1" }),
|
|
1904
|
-
engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.
|
|
1905
|
-
blender: Object.freeze({ name: "threenative-blender-mcp", version: "0.1.
|
|
2464
|
+
engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.4" }),
|
|
2465
|
+
blender: Object.freeze({ name: "threenative-blender-mcp", version: "0.1.4" })
|
|
1906
2466
|
});
|
|
1907
2467
|
var SERVER_FORMATS = Object.freeze({
|
|
1908
2468
|
// Claude Code (`.mcp.json`), Cursor and the Gemini CLI all read this one.
|
|
@@ -2037,14 +2597,14 @@ function requiredAndroidSdkFromRoot(root) {
|
|
|
2037
2597
|
if (root === void 0) return DEFAULT_ANDROID_COMPILE_SDK;
|
|
2038
2598
|
try {
|
|
2039
2599
|
return androidGradleSdk(
|
|
2040
|
-
readFileSync(
|
|
2600
|
+
readFileSync(path4.join(root, "android", "app", "build.gradle.kts"), "utf8")
|
|
2041
2601
|
) ?? DEFAULT_ANDROID_COMPILE_SDK;
|
|
2042
2602
|
} catch {
|
|
2043
2603
|
return DEFAULT_ANDROID_COMPILE_SDK;
|
|
2044
2604
|
}
|
|
2045
2605
|
}
|
|
2046
2606
|
var CORE_PACKAGE_NAME = "@threenative/core";
|
|
2047
|
-
var CORE_PACKAGE_VERSION = "0.3.
|
|
2607
|
+
var CORE_PACKAGE_VERSION = "0.3.4";
|
|
2048
2608
|
var CORE_RESOLVED_SERVERS = /* @__PURE__ */ new Set([
|
|
2049
2609
|
"threenative-engine",
|
|
2050
2610
|
"threenative-blender"
|
|
@@ -2215,11 +2775,11 @@ function nativeEntryCompat(value) {
|
|
|
2215
2775
|
return typeof entry === "string" && entry.length > 0 ? { nativeEntry: entry } : void 0;
|
|
2216
2776
|
}
|
|
2217
2777
|
function resolvePackageDirectoryFrom(start, name) {
|
|
2218
|
-
let directory =
|
|
2778
|
+
let directory = path4.resolve(start);
|
|
2219
2779
|
while (true) {
|
|
2220
|
-
const candidate =
|
|
2221
|
-
if (existsSync(
|
|
2222
|
-
const parent =
|
|
2780
|
+
const candidate = path4.join(directory, "node_modules", name);
|
|
2781
|
+
if (existsSync(path4.join(candidate, "package.json"))) return candidate;
|
|
2782
|
+
const parent = path4.dirname(directory);
|
|
2223
2783
|
if (parent === directory) return void 0;
|
|
2224
2784
|
directory = parent;
|
|
2225
2785
|
}
|
|
@@ -2240,13 +2800,13 @@ function resolvePackageDirectory(snapshot, name) {
|
|
|
2240
2800
|
}
|
|
2241
2801
|
}
|
|
2242
2802
|
function resolveBinaryFrom(start, name) {
|
|
2243
|
-
let directory =
|
|
2803
|
+
let directory = path4.resolve(start);
|
|
2244
2804
|
while (true) {
|
|
2245
|
-
const binDirectory =
|
|
2246
|
-
const candidates = process.platform === "win32" ? [
|
|
2805
|
+
const binDirectory = path4.join(directory, "node_modules", ".bin");
|
|
2806
|
+
const candidates = process.platform === "win32" ? [path4.join(binDirectory, `${name}.cmd`), path4.join(binDirectory, name)] : [path4.join(binDirectory, name)];
|
|
2247
2807
|
const found = candidates.find((candidate) => existsSync(candidate));
|
|
2248
2808
|
if (found !== void 0) return found;
|
|
2249
|
-
const parent =
|
|
2809
|
+
const parent = path4.dirname(directory);
|
|
2250
2810
|
if (parent === directory) return void 0;
|
|
2251
2811
|
directory = parent;
|
|
2252
2812
|
}
|
|
@@ -2319,7 +2879,7 @@ function mcpServerCheck(snapshot, spec, value, file) {
|
|
|
2319
2879
|
status: "fail"
|
|
2320
2880
|
};
|
|
2321
2881
|
}
|
|
2322
|
-
if (snapshot.projectRoot !== void 0 && !existsSync(
|
|
2882
|
+
if (snapshot.projectRoot !== void 0 && !existsSync(path4.resolve(snapshot.projectRoot, spec.expectedArgs))) {
|
|
2323
2883
|
return {
|
|
2324
2884
|
detail: `${spec.configName} points at missing ${spec.expectedArgs}; @threenative/core is not providing the configured server shim`,
|
|
2325
2885
|
fix: "Install @threenative/core again so the generated MCP server entry exists.",
|
|
@@ -2345,7 +2905,7 @@ function mcpServerCheck(snapshot, spec, value, file) {
|
|
|
2345
2905
|
status: "warn"
|
|
2346
2906
|
};
|
|
2347
2907
|
}
|
|
2348
|
-
const manifest = readJsonSync(
|
|
2908
|
+
const manifest = readJsonSync(path4.join(packageDirectory, "package.json"));
|
|
2349
2909
|
const installedVersion = record(manifest)?.version;
|
|
2350
2910
|
if (typeof installedVersion !== "string") {
|
|
2351
2911
|
return {
|
|
@@ -2376,7 +2936,7 @@ function probeMcpServer(projectRoot, spec) {
|
|
|
2376
2936
|
method: "initialize",
|
|
2377
2937
|
params: {
|
|
2378
2938
|
capabilities: {},
|
|
2379
|
-
clientInfo: { name: "threenative-doctor", version: "0.3.
|
|
2939
|
+
clientInfo: { name: "threenative-doctor", version: "0.3.4" },
|
|
2380
2940
|
protocolVersion: "2025-06-18"
|
|
2381
2941
|
}
|
|
2382
2942
|
});
|
|
@@ -2506,10 +3066,10 @@ function configuredTargets(snapshot) {
|
|
|
2506
3066
|
function directoryCanBeWritten(snapshot, relative) {
|
|
2507
3067
|
if (snapshot.directoryWritable !== void 0) return snapshot.directoryWritable(relative);
|
|
2508
3068
|
if (snapshot.projectRoot === void 0) return void 0;
|
|
2509
|
-
const root =
|
|
2510
|
-
let candidate =
|
|
2511
|
-
if (candidate !== root && !candidate.startsWith(`${root}${
|
|
2512
|
-
while (candidate !== root && !existsSync(candidate)) candidate =
|
|
3069
|
+
const root = path4.resolve(snapshot.projectRoot);
|
|
3070
|
+
let candidate = path4.resolve(root, relative);
|
|
3071
|
+
if (candidate !== root && !candidate.startsWith(`${root}${path4.sep}`)) return false;
|
|
3072
|
+
while (candidate !== root && !existsSync(candidate)) candidate = path4.dirname(candidate);
|
|
2513
3073
|
if (!existsSync(candidate)) return false;
|
|
2514
3074
|
try {
|
|
2515
3075
|
if (!statSync(candidate).isDirectory()) return false;
|
|
@@ -2722,13 +3282,13 @@ function parseApkSizeRecord(source) {
|
|
|
2722
3282
|
const bytesText = bytesMatch[1];
|
|
2723
3283
|
const artifact = artifactMatch[1];
|
|
2724
3284
|
const buildDirectory = buildDirectoryMatch[1];
|
|
2725
|
-
const
|
|
2726
|
-
if (bytesText === void 0 || artifact === void 0 || buildDirectory === void 0 ||
|
|
3285
|
+
const sha2562 = sha256Match[1];
|
|
3286
|
+
if (bytesText === void 0 || artifact === void 0 || buildDirectory === void 0 || sha2562 === void 0)
|
|
2727
3287
|
return void 0;
|
|
2728
3288
|
const bytes = Number(bytesText.replaceAll(",", ""));
|
|
2729
3289
|
if (!Number.isSafeInteger(bytes) || bytes <= 0) return void 0;
|
|
2730
3290
|
if (artifact.length === 0 || buildDirectory.length === 0) return void 0;
|
|
2731
|
-
return { artifact, buildDirectory, bytes, sha256:
|
|
3291
|
+
return { artifact, buildDirectory, bytes, sha256: sha2562.toLowerCase() };
|
|
2732
3292
|
}
|
|
2733
3293
|
function sha256File(file) {
|
|
2734
3294
|
const hash = createHash("sha256");
|
|
@@ -2746,10 +3306,10 @@ function sha256File(file) {
|
|
|
2746
3306
|
}
|
|
2747
3307
|
}
|
|
2748
3308
|
function evidencePath(snapshot, relative) {
|
|
2749
|
-
if (snapshot.projectRoot === void 0 ||
|
|
2750
|
-
const root =
|
|
2751
|
-
const resolved =
|
|
2752
|
-
return resolved === root || resolved.startsWith(`${root}${
|
|
3309
|
+
if (snapshot.projectRoot === void 0 || path4.isAbsolute(relative)) return void 0;
|
|
3310
|
+
const root = path4.resolve(snapshot.projectRoot);
|
|
3311
|
+
const resolved = path4.resolve(root, relative);
|
|
3312
|
+
return resolved === root || resolved.startsWith(`${root}${path4.sep}`) ? resolved : void 0;
|
|
2753
3313
|
}
|
|
2754
3314
|
function evidenceExists(snapshot, relative, directory) {
|
|
2755
3315
|
const absolute = evidencePath(snapshot, relative);
|
|
@@ -2832,6 +3392,7 @@ function dependencyChecks(snapshot) {
|
|
|
2832
3392
|
const declared = declaredDependencies(snapshot.packageJson);
|
|
2833
3393
|
const missing = declared.filter((name) => !snapshot.installedVersions.has(name));
|
|
2834
3394
|
const installed = [...snapshot.installedVersions].sort(([a], [b]) => a.localeCompare(b));
|
|
3395
|
+
const series = new Set(installed.map(([, version]) => version.split(".").slice(0, 2).join(".")));
|
|
2835
3396
|
const versions = new Set(installed.map(([, version]) => version));
|
|
2836
3397
|
return [
|
|
2837
3398
|
missing.length > 0 ? {
|
|
@@ -2844,13 +3405,13 @@ function dependencyChecks(snapshot) {
|
|
|
2844
3405
|
name: "dependencies",
|
|
2845
3406
|
status: "ok"
|
|
2846
3407
|
},
|
|
2847
|
-
|
|
3408
|
+
series.size > 1 ? {
|
|
2848
3409
|
detail: `@threenative packages disagree on version: ${installed.map(([name, version]) => `${name}@${version}`).join(", ")}`,
|
|
2849
3410
|
fix: "Install one version across all @threenative packages; mixed versions break at the package boundary.",
|
|
2850
3411
|
name: "versions",
|
|
2851
3412
|
status: "fail"
|
|
2852
3413
|
} : {
|
|
2853
|
-
detail: versions.size === 0 ? "nothing installed to compare" : `all at ${[...versions][0]}`,
|
|
3414
|
+
detail: versions.size === 0 ? "nothing installed to compare" : versions.size === 1 ? `all at ${[...versions][0]}` : `all on the ${[...series][0]} series (${installed.map(([name, version]) => `${name}@${version}`).join(", ")})`,
|
|
2854
3415
|
name: "versions",
|
|
2855
3416
|
status: "ok"
|
|
2856
3417
|
}
|
|
@@ -2978,7 +3539,7 @@ function nativeRuntimeCheck(snapshot) {
|
|
|
2978
3539
|
};
|
|
2979
3540
|
}
|
|
2980
3541
|
const binary = `prebuilt/${key}/${nativeRuntimeFilename()}`;
|
|
2981
|
-
const exists = snapshot.runtimeFileExists?.(binary) ?? existsSync(
|
|
3542
|
+
const exists = snapshot.runtimeFileExists?.(binary) ?? existsSync(path4.join(snapshot.runtimeRoot, binary));
|
|
2982
3543
|
if (!exists) {
|
|
2983
3544
|
return {
|
|
2984
3545
|
detail: `unavailable \u2014 ${key} prebuilt binary is missing`,
|
|
@@ -2987,7 +3548,7 @@ function nativeRuntimeCheck(snapshot) {
|
|
|
2987
3548
|
status: "fail"
|
|
2988
3549
|
};
|
|
2989
3550
|
}
|
|
2990
|
-
const host = snapshot.nativeHost ?? probeNativeHost(
|
|
3551
|
+
const host = snapshot.nativeHost ?? probeNativeHost(path4.join(snapshot.runtimeRoot, binary));
|
|
2991
3552
|
const reported = host.runtimeVersion;
|
|
2992
3553
|
if (reported === void 0) {
|
|
2993
3554
|
return {
|
|
@@ -3064,7 +3625,7 @@ function javaVersion(output) {
|
|
|
3064
3625
|
return Number.isSafeInteger(major) ? { major, version } : void 0;
|
|
3065
3626
|
}
|
|
3066
3627
|
function androidSdkVersion(root, requiredSdk) {
|
|
3067
|
-
const sourceProperties =
|
|
3628
|
+
const sourceProperties = path4.join(
|
|
3068
3629
|
root,
|
|
3069
3630
|
"platforms",
|
|
3070
3631
|
`android-${requiredSdk}`,
|
|
@@ -3080,7 +3641,7 @@ function androidSdkVersion(root, requiredSdk) {
|
|
|
3080
3641
|
}
|
|
3081
3642
|
function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_ANDROID_COMPILE_SDK) {
|
|
3082
3643
|
const javaHome = environment.JAVA_HOME?.trim() || void 0;
|
|
3083
|
-
const java = javaHome === void 0 ? "java" :
|
|
3644
|
+
const java = javaHome === void 0 ? "java" : path4.join(javaHome, "bin", process.platform === "win32" ? "java.exe" : "java");
|
|
3084
3645
|
let jdkMajor;
|
|
3085
3646
|
let jdkVersion;
|
|
3086
3647
|
try {
|
|
@@ -3098,7 +3659,7 @@ function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_
|
|
|
3098
3659
|
const sdkCandidates = [
|
|
3099
3660
|
environment.ANDROID_HOME,
|
|
3100
3661
|
environment.ANDROID_SDK_ROOT,
|
|
3101
|
-
|
|
3662
|
+
path4.join(homedir(), "Android", "Sdk")
|
|
3102
3663
|
].map((candidate) => candidate?.trim()).filter((candidate) => candidate !== void 0 && candidate.length > 0);
|
|
3103
3664
|
const sdkRoot = sdkCandidates.find((candidate) => existsSync(candidate));
|
|
3104
3665
|
return {
|
|
@@ -3109,7 +3670,7 @@ function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_
|
|
|
3109
3670
|
}
|
|
3110
3671
|
function runtimeFileAvailable(snapshot, relative) {
|
|
3111
3672
|
if (snapshot.runtimeRoot === void 0) return false;
|
|
3112
|
-
return snapshot.runtimeFileExists?.(relative) ?? existsSync(
|
|
3673
|
+
return snapshot.runtimeFileExists?.(relative) ?? existsSync(path4.join(snapshot.runtimeRoot, relative));
|
|
3113
3674
|
}
|
|
3114
3675
|
function androidTargetCheck(snapshot) {
|
|
3115
3676
|
if (!runtimeFileAvailable(snapshot, "scripts/package-android.mjs")) {
|
|
@@ -3406,7 +3967,7 @@ function diagnoseProject(snapshot, options = {}) {
|
|
|
3406
3967
|
}
|
|
3407
3968
|
async function collectFiles(root, relative = "", depth = 0) {
|
|
3408
3969
|
if (depth > 3) return [];
|
|
3409
|
-
const absolute =
|
|
3970
|
+
const absolute = path4.join(root, relative);
|
|
3410
3971
|
if (!existsSync(absolute)) return [];
|
|
3411
3972
|
const entries = await readdir(absolute, { withFileTypes: true });
|
|
3412
3973
|
const files = [];
|
|
@@ -3427,7 +3988,7 @@ async function readJson(file) {
|
|
|
3427
3988
|
}
|
|
3428
3989
|
async function runtimeReleaseManifestUrl(runtimeRoot, version) {
|
|
3429
3990
|
try {
|
|
3430
|
-
const module = await import(pathToFileURL(
|
|
3991
|
+
const module = await import(pathToFileURL(path4.join(runtimeRoot, "scripts", "install-prebuilt.mjs")).href);
|
|
3431
3992
|
const releaseUrl = record(module)?.releaseManifestUrl;
|
|
3432
3993
|
if (typeof releaseUrl !== "function") return void 0;
|
|
3433
3994
|
const result = releaseUrl(version);
|
|
@@ -3437,19 +3998,19 @@ async function runtimeReleaseManifestUrl(runtimeRoot, version) {
|
|
|
3437
3998
|
}
|
|
3438
3999
|
}
|
|
3439
4000
|
async function readProject(root) {
|
|
3440
|
-
const projectRoot =
|
|
3441
|
-
const packageJson = await readJson(
|
|
3442
|
-
const typeScriptConfig =
|
|
4001
|
+
const projectRoot = path4.resolve(root);
|
|
4002
|
+
const packageJson = await readJson(path4.join(projectRoot, "package.json"));
|
|
4003
|
+
const typeScriptConfig = path4.join(projectRoot, "threenative.config.ts");
|
|
3443
4004
|
const config = existsSync(typeScriptConfig) ? await readTypeScriptConfig(projectRoot) : nativeEntryCompat(record(packageJson)?.threenative);
|
|
3444
4005
|
const files = new Set(await collectFiles(projectRoot));
|
|
3445
4006
|
const installedVersions = /* @__PURE__ */ new Map();
|
|
3446
4007
|
for (const name of declaredDependencies(packageJson)) {
|
|
3447
|
-
const manifest = await readJson(
|
|
4008
|
+
const manifest = await readJson(path4.join(projectRoot, "node_modules", name, "package.json"));
|
|
3448
4009
|
const version = record(manifest)?.version;
|
|
3449
4010
|
if (typeof version === "string") installedVersions.set(name, version);
|
|
3450
4011
|
}
|
|
3451
4012
|
const runtimeRoot = installedVersions.has(RUNTIME_PACKAGE) ? (() => {
|
|
3452
|
-
const candidate =
|
|
4013
|
+
const candidate = path4.join(projectRoot, "node_modules", RUNTIME_PACKAGE);
|
|
3453
4014
|
try {
|
|
3454
4015
|
return realpathSync(candidate);
|
|
3455
4016
|
} catch {
|
|
@@ -3462,7 +4023,7 @@ async function readProject(root) {
|
|
|
3462
4023
|
const mcpServerHealth = /* @__PURE__ */ new Map();
|
|
3463
4024
|
if (SHAPE_VERIFIABLE_HOSTS.some(({ file }) => files.has(file))) {
|
|
3464
4025
|
for (const spec of MCP_SERVER_SPECS) {
|
|
3465
|
-
if (existsSync(
|
|
4026
|
+
if (existsSync(path4.resolve(projectRoot, spec.expectedArgs))) {
|
|
3466
4027
|
mcpServerHealth.set(spec.configName, probeMcpServer(projectRoot, spec));
|
|
3467
4028
|
}
|
|
3468
4029
|
}
|
|
@@ -3475,7 +4036,7 @@ async function readProject(root) {
|
|
|
3475
4036
|
packageJson,
|
|
3476
4037
|
projectRoot,
|
|
3477
4038
|
readText: (relative) => {
|
|
3478
|
-
const file =
|
|
4039
|
+
const file = path4.join(projectRoot, relative);
|
|
3479
4040
|
try {
|
|
3480
4041
|
return existsSync(file) ? readFileSync(file, "utf8") : void 0;
|
|
3481
4042
|
} catch {
|
|
@@ -3501,14 +4062,14 @@ async function readProject(root) {
|
|
|
3501
4062
|
...runtimeRoot === void 0 ? {} : {
|
|
3502
4063
|
readRuntimeText: (relative) => {
|
|
3503
4064
|
try {
|
|
3504
|
-
return readFileSync(
|
|
4065
|
+
return readFileSync(path4.join(runtimeRoot, relative), "utf8");
|
|
3505
4066
|
} catch {
|
|
3506
4067
|
return void 0;
|
|
3507
4068
|
}
|
|
3508
4069
|
},
|
|
3509
|
-
runtimeFileExists: (relative) => existsSync(
|
|
4070
|
+
runtimeFileExists: (relative) => existsSync(path4.join(runtimeRoot, relative)),
|
|
3510
4071
|
nativeHost: probeNativeHost(
|
|
3511
|
-
|
|
4072
|
+
path4.join(runtimeRoot, "prebuilt", nativeRuntimeKey(), nativeRuntimeFilename())
|
|
3512
4073
|
),
|
|
3513
4074
|
...runtimeManifestUrl === void 0 ? {} : { runtimeManifestUrl },
|
|
3514
4075
|
runtimeRoot
|