create-threenative 0.2.6 → 0.2.7

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.
Files changed (622) hide show
  1. package/README.md +2 -2
  2. package/agent-docs/references/build-profiles.md +126 -0
  3. package/agent-docs/references/capability-reference.md +431 -20
  4. package/agent-docs/references/performance-basics.md +8 -5
  5. package/agent-docs/references/sculpt-from-a-reference.md +1 -1
  6. package/agent-docs/references/trace-a-slow-frame.md +1 -1
  7. package/agent-docs/references/visual-baseline.md +8 -4
  8. package/agent-files/.agents/skills/file-engine-bug/SKILL.md +15 -4
  9. package/agent-files/.agents/skills/threenative-assets/SKILL.md +5 -5
  10. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +1 -1
  11. package/agent-files/.agents/skills/threenative-context/SKILL.md +1 -1
  12. package/agent-files/.agents/skills/threenative-performance/SKILL.md +3 -3
  13. package/agent-files/.agents/skills/threenative-playtest/SKILL.md +1 -1
  14. package/agent-files/.agents/skills/threenative-ui/SKILL.md +1 -1
  15. package/agent-files/.agents/skills/threenative-visuals/SKILL.md +4 -4
  16. package/capabilities.json +555 -21
  17. package/dist/index.d.ts +30 -1
  18. package/dist/index.js +294 -55
  19. package/dist/threenative.js +714 -154
  20. package/package.json +6 -6
  21. package/template-assets/assets/mannequin-combat.glb +0 -0
  22. package/template-assets/assets/mannequin.glb +0 -0
  23. package/template-assets/assets/player-viewmodel.glb +0 -0
  24. package/template-assets/assets/sky.jpg +0 -0
  25. package/template-assets/clearwater/README.md +141 -0
  26. package/template-assets/clearwater/install.mjs +50 -0
  27. package/template-assets/clearwater/src/clearwater.ts +180 -0
  28. package/template-assets/clearwater/src/clearwaterDemo.ts +28 -0
  29. package/template-assets/clearwater/src/clearwaterLifetime.ts +28 -0
  30. package/{LICENSE → template-assets/clearwater/src/render/CLEARWATER-LICENSE.txt} +4 -1
  31. package/template-assets/clearwater/src/render/clearwater.ts +278 -0
  32. package/template-assets/clearwater/src/render/clearwaterCaustics.ts +138 -0
  33. package/template-assets/clearwater/src/render/clearwaterDemo.ts +65 -0
  34. package/template-assets/clearwater/src/render/clearwaterOptics.ts +33 -0
  35. package/template-assets/clearwater/src/render/clearwaterOptions.ts +177 -0
  36. package/template-assets/clearwater/src/render/clearwaterPass.ts +51 -0
  37. package/template-assets/patches/three@0.185.1.patch +2101 -138
  38. package/template-assets/worldEnvironment.ts +52 -1
  39. package/templates/action-rpg/AGENTS.md +42 -42
  40. package/templates/action-rpg/CLAUDE.md +42 -42
  41. package/templates/action-rpg/kit.json +1 -1
  42. package/templates/action-rpg/package.json +13 -7
  43. package/templates/action-rpg/playtests/combat.playtest.json +162 -23
  44. package/templates/action-rpg/playtests/performance.playtest.json +4 -3
  45. package/templates/action-rpg/playtests/survives.playtest.json +25 -8
  46. package/templates/action-rpg/src/conventions.ts +24 -18
  47. package/templates/action-rpg/src/entities/Enemy.ts +74 -24
  48. package/templates/action-rpg/src/entities/Fighter.ts +127 -0
  49. package/templates/action-rpg/src/entities/Player.ts +102 -32
  50. package/templates/action-rpg/src/game.ts +3 -3
  51. package/templates/action-rpg/src/render/camera.ts +18 -16
  52. package/templates/action-rpg/src/render/dungeon.ts +192 -0
  53. package/templates/action-rpg/src/render/lighting.ts +45 -28
  54. package/templates/action-rpg/src/render/loading.ts +4 -4
  55. package/templates/action-rpg/src/render/materials.ts +191 -47
  56. package/templates/action-rpg/src/render/palette.ts +14 -13
  57. package/templates/action-rpg/src/render/postprocessing.ts +12 -2
  58. package/templates/action-rpg/src/render/props.ts +117 -0
  59. package/templates/action-rpg/src/render/quality.ts +40 -82
  60. package/templates/action-rpg/src/render/sky.ts +36 -13
  61. package/templates/action-rpg/src/render/touch-controls.ts +1 -1
  62. package/templates/action-rpg/src/render/worldEnvironment.ts +52 -1
  63. package/templates/action-rpg/src/scenes/Play.ts +61 -39
  64. package/templates/action-rpg/src/style.css +9 -7
  65. package/templates/action-rpg/src/ui/AbilityBar.tsx +3 -1
  66. package/templates/action-rpg/src/ui/Hud.tsx +3 -3
  67. package/templates/action-rpg/threenative.config.ts +14 -1
  68. package/templates/action-rpg/vite.config.ts +4 -1
  69. package/templates/minimal/AGENTS.md +10 -10
  70. package/templates/minimal/CLAUDE.md +10 -10
  71. package/templates/minimal/package.json +12 -6
  72. package/templates/minimal/playtests/play.playtest.json +6 -5
  73. package/templates/minimal/playtests/sky.playtest.json +27 -0
  74. package/templates/minimal/src/conventions.ts +6 -3
  75. package/templates/minimal/src/entities/Player.ts +73 -27
  76. package/templates/minimal/src/main.ts +2 -3
  77. package/templates/minimal/src/render/camera.ts +22 -4
  78. package/templates/minimal/src/render/lighting.ts +24 -48
  79. package/templates/minimal/src/render/materials.ts +158 -13
  80. package/templates/minimal/src/render/palette.ts +10 -7
  81. package/templates/minimal/src/render/postprocessing.ts +12 -25
  82. package/templates/minimal/src/render/quality.ts +35 -69
  83. package/templates/minimal/src/render/sky.ts +35 -54
  84. package/templates/minimal/src/render/touch-controls.ts +1 -1
  85. package/templates/minimal/src/render/worldEnvironment.ts +52 -1
  86. package/templates/minimal/src/scenes/Play.ts +121 -111
  87. package/templates/minimal/src/state.ts +0 -4
  88. package/templates/minimal/src/style.css +0 -10
  89. package/templates/minimal/threenative.config.ts +14 -1
  90. package/templates/minimal/vite.config.ts +4 -1
  91. package/templates/platformer/AGENTS.md +18 -56
  92. package/templates/platformer/CLAUDE.md +18 -56
  93. package/templates/platformer/kit.json +2 -2
  94. package/templates/platformer/package.json +13 -9
  95. package/templates/platformer/playtests/buffer.playtest.json +15 -5
  96. package/templates/platformer/playtests/collect.playtest.json +8 -34
  97. package/templates/platformer/playtests/coyote.playtest.json +12 -34
  98. package/templates/platformer/playtests/damage.playtest.json +40 -15
  99. package/templates/platformer/playtests/hud.playtest.json +34 -0
  100. package/templates/platformer/playtests/move.playtest.json +24 -0
  101. package/templates/platformer/playtests/performance.playtest.json +24 -7
  102. package/templates/platformer/playtests/respawn.playtest.json +46 -11
  103. package/templates/platformer/playtests/stomp.playtest.json +49 -12
  104. package/templates/platformer/playtests/survives.playtest.json +3 -19
  105. package/templates/platformer/playtests/world.playtest.json +26 -0
  106. package/templates/platformer/src/entities/Fox.ts +273 -0
  107. package/templates/platformer/src/entities/Pickup.ts +43 -60
  108. package/templates/platformer/src/entities/Walker.ts +88 -0
  109. package/templates/platformer/src/game.ts +11 -8
  110. package/templates/platformer/src/level/Checkpoints.ts +29 -16
  111. package/templates/platformer/src/level/Stage.ts +469 -0
  112. package/templates/platformer/src/render/blocks.ts +94 -0
  113. package/templates/platformer/src/render/camera.ts +28 -3
  114. package/templates/platformer/src/render/fox.ts +196 -0
  115. package/templates/platformer/src/render/lighting.ts +42 -33
  116. package/templates/platformer/src/render/materials.ts +115 -5
  117. package/templates/platformer/src/render/palette.ts +68 -53
  118. package/templates/platformer/src/render/pickups.ts +142 -0
  119. package/templates/platformer/src/render/postprocessing.ts +12 -2
  120. package/templates/platformer/src/render/props.ts +147 -0
  121. package/templates/platformer/src/render/quality.ts +47 -99
  122. package/templates/platformer/src/render/scenery.ts +172 -0
  123. package/templates/platformer/src/render/sky.ts +120 -31
  124. package/templates/platformer/src/render/touch-controls.ts +5 -2
  125. package/templates/platformer/src/render/walkers.ts +96 -0
  126. package/templates/platformer/src/render/waterfall.ts +85 -0
  127. package/templates/platformer/src/render/worldEnvironment.ts +52 -1
  128. package/templates/platformer/src/scenes/Boot.ts +3 -4
  129. package/templates/platformer/src/scenes/Play.ts +362 -0
  130. package/templates/platformer/src/state.ts +16 -14
  131. package/templates/platformer/src/style.css +9 -8
  132. package/templates/platformer/src/ui/Hud.tsx +62 -29
  133. package/templates/platformer/src/ui/Menu.tsx +2 -2
  134. package/templates/platformer/threenative.config.ts +14 -1
  135. package/templates/platformer/vite.config.ts +4 -1
  136. package/templates/puzzle/AGENTS.md +19 -20
  137. package/templates/puzzle/CLAUDE.md +19 -20
  138. package/templates/puzzle/assets/native-proof.glb +0 -0
  139. package/templates/puzzle/assets/native-proof.png +0 -0
  140. package/templates/puzzle/kit.json +1 -1
  141. package/templates/puzzle/package.json +13 -7
  142. package/templates/puzzle/playtests/axis.playtest.json +20 -0
  143. package/templates/puzzle/playtests/blocked.playtest.json +73 -0
  144. package/templates/puzzle/playtests/caused.playtest.json +65 -0
  145. package/templates/puzzle/playtests/lit.playtest.json +74 -0
  146. package/templates/puzzle/playtests/performance.playtest.json +24 -7
  147. package/templates/{starter/playtests/respawn.playtest.json → puzzle/playtests/push.playtest.json} +24 -19
  148. package/templates/puzzle/playtests/replay.playtest.json +81 -0
  149. package/templates/puzzle/playtests/restart.playtest.json +108 -0
  150. package/templates/puzzle/playtests/seal.playtest.json +98 -0
  151. package/templates/puzzle/playtests/settle.playtest.json +100 -0
  152. package/templates/puzzle/playtests/survives.playtest.json +6 -29
  153. package/templates/{starter/playtests/hot-reload.playtest.json → puzzle/playtests/travel.playtest.json} +6 -5
  154. package/templates/puzzle/src/entities/Crate.ts +99 -42
  155. package/templates/puzzle/src/entities/Seal.ts +69 -0
  156. package/templates/puzzle/src/entities/Warden.ts +135 -0
  157. package/templates/puzzle/src/game.ts +15 -11
  158. package/templates/puzzle/src/render/camera.ts +66 -31
  159. package/templates/puzzle/src/render/crateShape.ts +70 -0
  160. package/templates/puzzle/src/render/lighting.ts +41 -41
  161. package/templates/puzzle/src/render/loading.ts +4 -4
  162. package/templates/puzzle/src/render/materials.ts +131 -27
  163. package/templates/puzzle/src/render/palette.ts +19 -29
  164. package/templates/puzzle/src/render/postprocessing.ts +15 -3
  165. package/templates/puzzle/src/render/quality.ts +71 -80
  166. package/templates/puzzle/src/render/shapes.ts +109 -108
  167. package/templates/puzzle/src/render/sky.ts +18 -10
  168. package/templates/puzzle/src/render/touch-controls.ts +8 -51
  169. package/templates/puzzle/src/render/vault.ts +315 -0
  170. package/templates/puzzle/src/render/warden.ts +46 -0
  171. package/templates/puzzle/src/render/worldEnvironment.ts +52 -1
  172. package/templates/puzzle/src/scenes/Play.ts +793 -0
  173. package/templates/puzzle/src/state.ts +55 -24
  174. package/templates/puzzle/src/style.css +7 -8
  175. package/templates/puzzle/src/ui/App.tsx +2 -2
  176. package/templates/puzzle/src/ui/Hud.tsx +92 -40
  177. package/templates/puzzle/src/ui/Menu.tsx +40 -2
  178. package/templates/puzzle/threenative.config.ts +14 -1
  179. package/templates/puzzle/vite.config.ts +4 -1
  180. package/templates/racing/AGENTS.md +19 -20
  181. package/templates/racing/CLAUDE.md +19 -20
  182. package/templates/racing/package.json +13 -7
  183. package/templates/racing/playtests/boost.playtest.json +33 -12
  184. package/templates/racing/playtests/outcome.playtest.json +32 -50
  185. package/templates/racing/playtests/performance.playtest.json +2 -1
  186. package/templates/racing/playtests/ranking.playtest.json +5 -14
  187. package/templates/racing/playtests/rescue.playtest.json +2 -2
  188. package/templates/racing/playtests/reverse.playtest.json +30 -8
  189. package/templates/racing/playtests/shortcut.playtest.json +54 -9
  190. package/templates/racing/playtests/touch-controls.playtest.json +32 -5
  191. package/templates/racing/src/entities/CarBody.ts +327 -0
  192. package/templates/racing/src/entities/LineDriver.ts +220 -0
  193. package/templates/racing/src/entities/RacingCar.ts +150 -89
  194. package/templates/racing/src/entities/Rival.ts +61 -24
  195. package/templates/racing/src/game.ts +5 -0
  196. package/templates/racing/src/render/camera.ts +49 -7
  197. package/templates/racing/src/render/lighting.ts +36 -37
  198. package/templates/racing/src/render/materials.ts +239 -19
  199. package/templates/racing/src/render/palette.ts +19 -21
  200. package/templates/racing/src/render/postprocessing.ts +12 -2
  201. package/templates/racing/src/render/quality.ts +43 -82
  202. package/templates/racing/src/render/shapes.ts +20 -6
  203. package/templates/racing/src/render/sky.ts +47 -39
  204. package/templates/racing/src/render/touch-controls.ts +1 -1
  205. package/templates/racing/src/render/worldEnvironment.ts +52 -1
  206. package/templates/racing/src/scenes/Race.ts +107 -54
  207. package/templates/racing/src/state.ts +2 -0
  208. package/templates/racing/src/track/Checkline.ts +22 -7
  209. package/templates/racing/src/track/Lap.ts +64 -36
  210. package/templates/racing/src/track/Ranking.ts +20 -11
  211. package/templates/racing/src/track/Track.ts +809 -361
  212. package/templates/racing/src/track/TrackSector.ts +40 -11
  213. package/templates/racing/src/track/circuit.ts +477 -0
  214. package/templates/racing/src/track/rescue.ts +16 -4
  215. package/templates/racing/threenative.config.ts +14 -1
  216. package/templates/racing/vite.config.ts +4 -1
  217. package/templates/rts/AGENTS.md +96 -0
  218. package/templates/rts/CLAUDE.md +98 -0
  219. package/templates/rts/kit.json +7 -0
  220. package/templates/{defense → rts}/package.json +13 -7
  221. package/templates/{defense → rts}/playtests/performance.playtest.json +28 -26
  222. package/templates/rts/playtests/rts-ai-attack.playtest.json +24 -0
  223. package/templates/rts/playtests/rts-attack.playtest.json +75 -0
  224. package/templates/rts/playtests/rts-build.playtest.json +68 -0
  225. package/templates/rts/playtests/rts-orders.playtest.json +150 -0
  226. package/templates/rts/playtests/rts-train.playtest.json +62 -0
  227. package/templates/rts/playtests/survives.playtest.json +58 -0
  228. package/templates/rts/public/favicon.svg +4 -0
  229. package/templates/rts/src/game.ts +64 -0
  230. package/templates/rts/src/orders.ts +22 -0
  231. package/templates/rts/src/render/army.ts +346 -0
  232. package/templates/rts/src/render/camera.ts +123 -0
  233. package/templates/rts/src/render/lighting.ts +61 -0
  234. package/templates/rts/src/render/loading.ts +33 -0
  235. package/templates/rts/src/render/materials.ts +152 -0
  236. package/templates/rts/src/render/models.ts +705 -0
  237. package/templates/rts/src/render/palette.ts +17 -0
  238. package/templates/rts/src/render/picking.ts +93 -0
  239. package/templates/{defense → rts}/src/render/postprocessing.ts +15 -3
  240. package/templates/rts/src/render/quality.ts +128 -0
  241. package/templates/rts/src/render/resources.ts +141 -0
  242. package/templates/rts/src/render/sky.ts +44 -0
  243. package/templates/rts/src/render/terrain.ts +116 -0
  244. package/templates/{defense → rts}/src/render/worldEnvironment.ts +52 -1
  245. package/templates/rts/src/scenes/Play.ts +650 -0
  246. package/templates/rts/src/sim/ai.ts +1140 -0
  247. package/templates/rts/src/sim/combat.ts +416 -0
  248. package/templates/rts/src/sim/construction.ts +374 -0
  249. package/templates/rts/src/sim/economy.ts +167 -0
  250. package/templates/rts/src/sim/game.ts +1082 -0
  251. package/templates/rts/src/sim/movement.ts +371 -0
  252. package/templates/rts/src/sim/nav.ts +276 -0
  253. package/templates/rts/src/sim/production.ts +180 -0
  254. package/templates/rts/src/sim/terrain.ts +170 -0
  255. package/templates/rts/src/sim/types.ts +647 -0
  256. package/templates/rts/src/sim/vision.ts +46 -0
  257. package/templates/rts/src/state.ts +100 -0
  258. package/templates/{defense → rts}/src/style.css +21 -8
  259. package/templates/rts/src/ui/App.tsx +21 -0
  260. package/templates/rts/src/ui/Commands.tsx +129 -0
  261. package/templates/rts/src/ui/GameUi.tsx +22 -0
  262. package/templates/rts/src/ui/Hud.tsx +165 -0
  263. package/templates/rts/src/ui/Minimap.tsx +84 -0
  264. package/templates/rts/tailwind.config.ts +2 -0
  265. package/templates/rts/threenative.config.ts +56 -0
  266. package/templates/rts/tsconfig.json +17 -0
  267. package/templates/{defense → rts}/vite.config.ts +4 -1
  268. package/templates/runner/AGENTS.md +6 -10
  269. package/templates/runner/CLAUDE.md +6 -10
  270. package/templates/runner/README.md +3 -3
  271. package/templates/runner/package.json +13 -7
  272. package/templates/runner/playtests/performance.playtest.json +2 -2
  273. package/templates/runner/src/conventions.ts +4 -3
  274. package/templates/runner/src/entities/Runner.ts +54 -7
  275. package/templates/runner/src/game.ts +2 -0
  276. package/templates/runner/src/render/camera.ts +4 -2
  277. package/templates/runner/src/render/dust.ts +5 -2
  278. package/templates/runner/src/render/lighting.ts +41 -45
  279. package/templates/runner/src/render/loading.ts +2 -2
  280. package/templates/runner/src/render/materials.ts +165 -25
  281. package/templates/runner/src/render/palette.ts +17 -28
  282. package/templates/runner/src/render/postprocessing.ts +12 -2
  283. package/templates/runner/src/render/quality.ts +42 -96
  284. package/templates/runner/src/render/shapes.ts +59 -37
  285. package/templates/runner/src/render/sky.ts +32 -41
  286. package/templates/runner/src/render/touch-controls.ts +1 -1
  287. package/templates/runner/src/render/worldEnvironment.ts +52 -1
  288. package/templates/runner/src/scenes/Run.ts +26 -6
  289. package/templates/runner/src/track.ts +6 -1
  290. package/templates/runner/threenative.config.ts +14 -1
  291. package/templates/runner/vite.config.ts +4 -1
  292. package/templates/sailing/AGENTS.md +12 -12
  293. package/templates/sailing/CLAUDE.md +12 -12
  294. package/templates/sailing/assets/ship.glb +0 -0
  295. package/templates/sailing/package.json +13 -7
  296. package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +10 -6
  297. package/templates/sailing/playtests/sails.playtest.json +33 -0
  298. package/templates/sailing/playtests/win.playtest.json +156 -8
  299. package/templates/sailing/src/conventions.ts +29 -2
  300. package/templates/sailing/src/entities/Ship.ts +381 -57
  301. package/templates/sailing/src/game.ts +14 -0
  302. package/templates/sailing/src/render/camera.ts +63 -9
  303. package/templates/sailing/src/render/lighting.ts +49 -27
  304. package/templates/sailing/src/render/materials.ts +50 -15
  305. package/templates/sailing/src/render/ocean.ts +647 -60
  306. package/templates/sailing/src/render/palette.ts +16 -12
  307. package/templates/sailing/src/render/postprocessing.ts +12 -2
  308. package/templates/sailing/src/render/props.ts +316 -442
  309. package/templates/sailing/src/render/quality.ts +14 -4
  310. package/templates/sailing/src/render/sky.ts +116 -23
  311. package/templates/sailing/src/render/worldEnvironment.ts +52 -1
  312. package/templates/sailing/src/scenes/Boot.ts +21 -0
  313. package/templates/sailing/src/scenes/Sailing.ts +173 -39
  314. package/templates/sailing/src/state.ts +6 -0
  315. package/templates/sailing/src/ui/Hud.tsx +41 -9
  316. package/templates/sailing/threenative.config.ts +14 -1
  317. package/templates/sailing/vite.config.ts +4 -1
  318. package/templates/shooter/AGENTS.md +27 -42
  319. package/templates/shooter/CLAUDE.md +27 -42
  320. package/templates/shooter/index.html +1 -0
  321. package/templates/shooter/package.json +13 -7
  322. package/templates/shooter/playtests/aim-alignment.playtest.json +58 -0
  323. package/templates/shooter/playtests/breakable-shatters.playtest.json +62 -0
  324. package/templates/shooter/playtests/bullet-holes.playtest.json +56 -0
  325. package/templates/shooter/playtests/camera-tracks-body-vertically.playtest.json +61 -0
  326. package/templates/shooter/playtests/crouch-lowers-the-eye.playtest.json +41 -0
  327. package/templates/shooter/playtests/death-no-snap.playtest.json +77 -0
  328. package/templates/shooter/playtests/debug-ads.playtest.json +58 -0
  329. package/templates/shooter/playtests/debug-clear.playtest.json +383 -0
  330. package/templates/shooter/playtests/debug-endurance.playtest.json +61 -0
  331. package/templates/shooter/playtests/debug-fire.playtest.json +119 -0
  332. package/templates/shooter/playtests/debug-restart.playtest.json +24 -0
  333. package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +79 -0
  334. package/templates/shooter/playtests/enemy-death-settles.playtest.json +64 -0
  335. package/templates/shooter/playtests/enemy-flinches-when-hit.playtest.json +75 -0
  336. package/templates/shooter/playtests/enemy-foot-contact.playtest.json +41 -0
  337. package/templates/shooter/playtests/enemy-material-is-not-shared.playtest.json +59 -0
  338. package/templates/shooter/playtests/enemy-reaches-walkway.playtest.json +80 -0
  339. package/templates/shooter/playtests/enemy-rifle-grip.playtest.json +101 -0
  340. package/templates/shooter/playtests/enemy-scale.playtest.json +56 -0
  341. package/templates/shooter/playtests/enemy-stops-without-snapping.playtest.json +486 -0
  342. package/templates/shooter/playtests/enemy-stride-matches-speed.playtest.json +198 -0
  343. package/templates/shooter/playtests/enemy-stride-under-crouch.playtest.json +87 -0
  344. package/templates/shooter/playtests/enemy-uses-crouch-clips.playtest.json +74 -0
  345. package/templates/shooter/playtests/five-soldiers.playtest.json +83 -0
  346. package/templates/shooter/playtests/flash-retires.playtest.json +62 -0
  347. package/templates/shooter/playtests/headshot-hits-head.playtest.json +132 -0
  348. package/templates/shooter/playtests/hold-to-fire.playtest.json +45 -0
  349. package/templates/shooter/playtests/input-control.playtest.json +43 -98
  350. package/templates/shooter/playtests/minimap-state.playtest.json +75 -0
  351. package/templates/shooter/playtests/performance.playtest.json +62 -26
  352. package/templates/{starter/playtests/forward.playtest.json → shooter/playtests/round-clock.playtest.json} +11 -16
  353. package/templates/shooter/playtests/shot-tracks-crosshair.playtest.json +79 -0
  354. package/templates/shooter/playtests/survives.playtest.json +36 -30
  355. package/templates/shooter/playtests/walkway-reachable.playtest.json +67 -0
  356. package/templates/shooter/src/entities/Breakables.ts +412 -0
  357. package/templates/shooter/src/entities/Enemy.ts +2095 -0
  358. package/templates/shooter/src/entities/FpsPlayer.ts +283 -0
  359. package/templates/shooter/src/entities/Rifle.ts +442 -0
  360. package/templates/shooter/src/entities/Target.ts +199 -83
  361. package/templates/shooter/src/entities/TouchControls.ts +276 -0
  362. package/templates/shooter/src/game.ts +75 -41
  363. package/templates/shooter/src/main.ts +0 -1
  364. package/templates/shooter/src/postPhysics.ts +36 -0
  365. package/templates/shooter/src/render/camera.ts +78 -74
  366. package/templates/shooter/src/render/decals.ts +142 -82
  367. package/templates/shooter/src/render/facade.ts +1373 -0
  368. package/templates/shooter/src/render/gunfx.ts +704 -0
  369. package/templates/shooter/src/render/lighting.ts +52 -38
  370. package/templates/shooter/src/render/loading.ts +2 -2
  371. package/templates/shooter/src/render/materials.ts +100 -88
  372. package/templates/shooter/src/render/occlusion.ts +108 -0
  373. package/templates/shooter/src/render/palette.ts +10 -10
  374. package/templates/shooter/src/render/palm.ts +455 -0
  375. package/templates/shooter/src/render/pooled-billboards.ts +144 -0
  376. package/templates/shooter/src/render/postprocessing.ts +15 -3
  377. package/templates/shooter/src/render/quality.ts +40 -82
  378. package/templates/shooter/src/render/scale.ts +148 -15
  379. package/templates/shooter/src/render/shapes.ts +138 -613
  380. package/templates/shooter/src/render/sky.ts +35 -35
  381. package/templates/shooter/src/render/town-schematic.ts +120 -0
  382. package/templates/shooter/src/render/town.ts +986 -0
  383. package/templates/shooter/src/render/townMaterials.ts +160 -0
  384. package/templates/shooter/src/render/vehicles.ts +741 -0
  385. package/templates/shooter/src/render/worldEnvironment.ts +52 -1
  386. package/templates/shooter/src/scenes/Play.ts +727 -650
  387. package/templates/shooter/src/state.ts +26 -41
  388. package/templates/shooter/src/style.css +207 -11
  389. package/templates/shooter/src/surfaces.ts +131 -0
  390. package/templates/shooter/src/ui/App.tsx +9 -10
  391. package/templates/shooter/src/ui/Crosshair.tsx +25 -18
  392. package/templates/shooter/src/ui/GameUi.tsx +6 -9
  393. package/templates/shooter/src/ui/Hud.tsx +428 -39
  394. package/templates/shooter/src/ui/Minimap.tsx +164 -0
  395. package/templates/shooter/src/ui/TouchOverlay.tsx +54 -0
  396. package/templates/shooter/src/ui/main.tsx +2 -3
  397. package/templates/shooter/threenative.config.ts +14 -1
  398. package/templates/shooter/vite.config.ts +4 -1
  399. package/templates/starter/AGENTS.md +17 -17
  400. package/templates/starter/CLAUDE.md +17 -17
  401. package/templates/starter/native-playtests/render-chain.playtest.json +13 -45
  402. package/templates/starter/package.json +13 -7
  403. package/templates/starter/playtests/play.playtest.json +2 -1
  404. package/templates/starter/playtests/survives.playtest.json +1 -1
  405. package/templates/starter/src/conventions.ts +6 -3
  406. package/templates/starter/src/entities/Goal.ts +35 -42
  407. package/templates/starter/src/entities/Player.ts +99 -16
  408. package/templates/starter/src/render/arena.ts +131 -0
  409. package/templates/starter/src/render/lighting.ts +27 -44
  410. package/templates/starter/src/render/materials.ts +164 -35
  411. package/templates/starter/src/render/palette.ts +16 -16
  412. package/templates/starter/src/render/postprocessing.ts +6 -7
  413. package/templates/starter/src/render/quality.ts +43 -101
  414. package/templates/starter/src/render/shapes.ts +1 -1
  415. package/templates/starter/src/render/sky.ts +39 -45
  416. package/templates/starter/src/render/touch-controls.ts +3 -1
  417. package/templates/starter/src/render/worldEnvironment.ts +52 -1
  418. package/templates/starter/src/scenes/Play.ts +82 -81
  419. package/templates/starter/threenative.config.ts +14 -1
  420. package/templates/starter/vite.config.ts +4 -1
  421. package/templates/tower-defense/.codex/config.toml +19 -0
  422. package/templates/tower-defense/.cursor/mcp.json +32 -0
  423. package/templates/tower-defense/.gemini/settings.json +32 -0
  424. package/templates/tower-defense/.mcp.json +32 -0
  425. package/templates/tower-defense/.vscode/mcp.json +36 -0
  426. package/templates/tower-defense/.zed/settings.json +36 -0
  427. package/templates/{defense → tower-defense}/AGENTS.md +14 -12
  428. package/templates/{defense → tower-defense}/CLAUDE.md +14 -12
  429. package/templates/tower-defense/README.md +16 -0
  430. package/templates/tower-defense/index.html +12 -0
  431. package/templates/tower-defense/kit.json +7 -0
  432. package/templates/tower-defense/opencode.json +41 -0
  433. package/templates/tower-defense/package.json +56 -0
  434. package/templates/tower-defense/playtests/arsenal.playtest.json +214 -0
  435. package/templates/tower-defense/playtests/defeat.playtest.json +85 -0
  436. package/templates/tower-defense/playtests/look.playtest.json +130 -0
  437. package/templates/tower-defense/playtests/performance.playtest.json +77 -0
  438. package/templates/tower-defense/playtests/placement.playtest.json +115 -0
  439. package/templates/{defense → tower-defense}/playtests/pointer-placement.playtest.json +21 -49
  440. package/templates/tower-defense/playtests/strike.playtest.json +98 -0
  441. package/templates/tower-defense/playtests/survives.playtest.json +85 -0
  442. package/templates/tower-defense/playtests/target-priority.playtest.json +177 -0
  443. package/templates/tower-defense/playtests/upgrade-recycle.playtest.json +124 -0
  444. package/templates/tower-defense/playtests/victory.playtest.json +810 -0
  445. package/templates/tower-defense/src/balance.ts +187 -0
  446. package/templates/tower-defense/src/board/Board.ts +100 -0
  447. package/templates/tower-defense/src/board/Route.ts +84 -0
  448. package/templates/tower-defense/src/camera-rig.ts +62 -0
  449. package/templates/tower-defense/src/economy.ts +64 -0
  450. package/templates/tower-defense/src/effects/Effects.ts +284 -0
  451. package/templates/tower-defense/src/enemies/Enemy.ts +198 -0
  452. package/templates/tower-defense/src/game.ts +72 -0
  453. package/templates/tower-defense/src/intents.ts +21 -0
  454. package/templates/tower-defense/src/main.ts +15 -0
  455. package/templates/tower-defense/src/physics.ts +6 -0
  456. package/templates/tower-defense/src/render/camera.ts +38 -0
  457. package/templates/tower-defense/src/render/lighting.ts +42 -0
  458. package/templates/{defense → tower-defense}/src/render/loading.ts +3 -3
  459. package/templates/tower-defense/src/render/materials.ts +103 -0
  460. package/templates/tower-defense/src/render/palette.ts +58 -0
  461. package/templates/tower-defense/src/render/postprocessing.ts +46 -0
  462. package/templates/tower-defense/src/render/quality.ts +128 -0
  463. package/templates/tower-defense/src/render/shapes.ts +550 -0
  464. package/templates/tower-defense/src/render/sky.ts +27 -0
  465. package/templates/tower-defense/src/render/worldEnvironment.ts +809 -0
  466. package/templates/tower-defense/src/scenes/Battle.ts +539 -0
  467. package/templates/{shooter → tower-defense}/src/scenes/Boot.ts +3 -3
  468. package/templates/tower-defense/src/state.ts +88 -0
  469. package/templates/tower-defense/src/style.css +137 -0
  470. package/templates/tower-defense/src/towers/Tower.ts +230 -0
  471. package/templates/tower-defense/src/towers/targeting.ts +97 -0
  472. package/templates/tower-defense/src/ui/Hud.tsx +270 -0
  473. package/templates/tower-defense/src/ui/Menu.tsx +134 -0
  474. package/templates/tower-defense/src/ui/icons.tsx +54 -0
  475. package/templates/tower-defense/src/ui/main.tsx +14 -0
  476. package/templates/tower-defense/src/waves.ts +90 -0
  477. package/templates/{defense → tower-defense}/threenative.config.ts +14 -1
  478. package/templates/tower-defense/vite.config.ts +41 -0
  479. package/agent-files/.claude/skills/file-engine-bug/SKILL.md +0 -59
  480. package/agent-files/.claude/skills/ponytail/SKILL.md +0 -68
  481. package/agent-files/.claude/skills/prd-creator/SKILL.md +0 -40
  482. package/agent-files/.claude/skills/threenative-assets/SKILL.md +0 -53
  483. package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +0 -27
  484. package/agent-files/.claude/skills/threenative-context/SKILL.md +0 -65
  485. package/agent-files/.claude/skills/threenative-performance/SKILL.md +0 -58
  486. package/agent-files/.claude/skills/threenative-playtest/SKILL.md +0 -44
  487. package/agent-files/.claude/skills/threenative-ui/SKILL.md +0 -20
  488. package/agent-files/.claude/skills/threenative-visuals/SKILL.md +0 -41
  489. package/agent-files/AGENT-ROLES.md +0 -26
  490. package/templates/action-rpg/src/render/shapes.ts +0 -269
  491. package/templates/action-rpg/src/render/types.ts +0 -3
  492. package/templates/action-rpg/src/scenes/Boot.ts +0 -12
  493. package/templates/defense/README.md +0 -10
  494. package/templates/defense/kit.json +0 -7
  495. package/templates/defense/playtests/leak.playtest.json +0 -23
  496. package/templates/defense/playtests/placement.playtest.json +0 -40
  497. package/templates/defense/playtests/scan.playtest.json +0 -20
  498. package/templates/defense/playtests/survive.playtest.json +0 -45
  499. package/templates/defense/playtests/survives.playtest.json +0 -36
  500. package/templates/defense/src/attackers/Attacker.ts +0 -120
  501. package/templates/defense/src/board/Route.ts +0 -94
  502. package/templates/defense/src/conventions.ts +0 -18
  503. package/templates/defense/src/economy.ts +0 -36
  504. package/templates/defense/src/entities/Player.ts +0 -52
  505. package/templates/defense/src/game.ts +0 -51
  506. package/templates/defense/src/physics.ts +0 -13
  507. package/templates/defense/src/placement/Buildable.ts +0 -49
  508. package/templates/defense/src/render/camera.ts +0 -16
  509. package/templates/defense/src/render/lighting.ts +0 -37
  510. package/templates/defense/src/render/materials.ts +0 -22
  511. package/templates/defense/src/render/palette.ts +0 -28
  512. package/templates/defense/src/render/quality.ts +0 -170
  513. package/templates/defense/src/render/shapes.ts +0 -246
  514. package/templates/defense/src/render/sky.ts +0 -45
  515. package/templates/defense/src/scenes/Boot.ts +0 -12
  516. package/templates/defense/src/scenes/Defense.ts +0 -231
  517. package/templates/defense/src/state.ts +0 -56
  518. package/templates/defense/src/towers/Tower.ts +0 -95
  519. package/templates/defense/src/towers/targeting.ts +0 -53
  520. package/templates/defense/src/ui/Hud.tsx +0 -62
  521. package/templates/defense/src/ui/Menu.tsx +0 -7
  522. package/templates/defense/src/waves.ts +0 -40
  523. package/templates/minimal/playtests/atmosphere.playtest.json +0 -32
  524. package/templates/minimal/src/render/hud.ts +0 -69
  525. package/templates/platformer/playtests/avoidance.playtest.json +0 -28
  526. package/templates/platformer/playtests/chase.playtest.json +0 -21
  527. package/templates/platformer/playtests/collision-layers.playtest.json +0 -36
  528. package/templates/platformer/playtests/oneway.playtest.json +0 -44
  529. package/templates/platformer/playtests/patrol.playtest.json +0 -13
  530. package/templates/platformer/playtests/physics.playtest.json +0 -14
  531. package/templates/platformer/playtests/stomp-rise.playtest.json +0 -55
  532. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +0 -41
  533. package/templates/platformer/playtests/terminal-loop-win.playtest.json +0 -52
  534. package/templates/platformer/src/conventions.ts +0 -18
  535. package/templates/platformer/src/entities/Character.ts +0 -286
  536. package/templates/platformer/src/entities/Chaser.ts +0 -118
  537. package/templates/platformer/src/entities/Patrol.ts +0 -93
  538. package/templates/platformer/src/level/Platform.ts +0 -46
  539. package/templates/platformer/src/render/rig.ts +0 -60
  540. package/templates/platformer/src/render/terrain.ts +0 -31
  541. package/templates/platformer/src/scenes/Level.ts +0 -241
  542. package/templates/puzzle/README.md +0 -43
  543. package/templates/puzzle/playtests/carry.playtest.json +0 -71
  544. package/templates/puzzle/playtests/swing.playtest.json +0 -38
  545. package/templates/puzzle/src/conventions.ts +0 -25
  546. package/templates/puzzle/src/entities/Ball.ts +0 -70
  547. package/templates/puzzle/src/entities/Gripper.ts +0 -69
  548. package/templates/puzzle/src/entities/Pendulum.ts +0 -89
  549. package/templates/puzzle/src/physics.ts +0 -19
  550. package/templates/puzzle/src/room.ts +0 -83
  551. package/templates/puzzle/src/scenes/Boot.ts +0 -12
  552. package/templates/puzzle/src/scenes/Puzzle.ts +0 -158
  553. package/templates/shooter/playtests/combat.playtest.json +0 -48
  554. package/templates/shooter/playtests/fail.playtest.json +0 -31
  555. package/templates/shooter/playtests/per-item.playtest.json +0 -59
  556. package/templates/shooter/playtests/shooter.playtest.json +0 -99
  557. package/templates/shooter/playtests/touch-controls.playtest.json +0 -42
  558. package/templates/shooter/playtests/weapon-cycle.playtest.json +0 -164
  559. package/templates/shooter/src/combat/damage.ts +0 -40
  560. package/templates/shooter/src/conventions.ts +0 -51
  561. package/templates/shooter/src/entities/Pickup.ts +0 -70
  562. package/templates/shooter/src/entities/Player.ts +0 -310
  563. package/templates/shooter/src/level/SpawnPoints.ts +0 -28
  564. package/templates/shooter/src/playtest-events.ts +0 -15
  565. package/templates/shooter/src/render/touch-controls.ts +0 -305
  566. package/templates/shooter/src/render/types.ts +0 -3
  567. package/templates/shooter/src/render/ui.css +0 -330
  568. package/templates/shooter/src/render/ui.ts +0 -75
  569. package/templates/shooter/src/render/vfx.ts +0 -215
  570. package/templates/shooter/src/ui/Menu.tsx +0 -41
  571. package/templates/shooter/src/waves.ts +0 -50
  572. package/templates/shooter/src/weapons/Hitscan.ts +0 -42
  573. package/templates/shooter/src/weapons/Projectile.ts +0 -92
  574. package/templates/shooter/src/weapons/Viewmodel.ts +0 -275
  575. package/templates/starter/playtests/assets.playtest.json +0 -65
  576. package/templates/starter/playtests/buffer.playtest.json +0 -79
  577. package/templates/starter/playtests/cloth.playtest.json +0 -113
  578. package/templates/starter/playtests/coyote.playtest.json +0 -87
  579. package/templates/starter/playtests/gameover.playtest.json +0 -66
  580. package/templates/starter/playtests/goal.playtest.json +0 -67
  581. package/templates/starter/playtests/look.playtest.json +0 -175
  582. package/templates/starter/playtests/models-baseline.png +0 -0
  583. package/templates/starter/playtests/models.playtest.json +0 -74
  584. package/templates/starter/playtests/monitoring.playtest.json +0 -72
  585. package/templates/starter/playtests/odometer.playtest.json +0 -54
  586. package/templates/starter/playtests/restart.playtest.json +0 -91
  587. package/templates/starter/playtests/seed.playtest.json +0 -54
  588. package/templates/starter/playtests/textures-baseline.png +0 -0
  589. package/templates/starter/playtests/textures.playtest.json +0 -74
  590. package/templates/starter/playtests/touch-controls.playtest.json +0 -42
  591. package/templates/starter/playtests/zoom-pinch.playtest.json +0 -86
  592. package/templates/starter/playtests/zoom-wheel.playtest.json +0 -59
  593. package/templates/starter/src/render/coast.ts +0 -199
  594. package/templates/starter/src/render/hero.ts +0 -88
  595. package/templates/starter/src/render/implicitSurface.ts +0 -199
  596. package/templates/starter/src/render/kuwahara.ts +0 -174
  597. package/templates/starter/src/render/outline.ts +0 -141
  598. package/templates/starter/src/render/painterly.ts +0 -86
  599. package/templates/starter/src/render/rockRidge.ts +0 -198
  600. package/templates/starter/src/render/rockRidge.worker.ts +0 -77
  601. package/templates/starter/src/render/scenery.ts +0 -40
  602. package/templates/starter/src/render/textureLifetime.ts +0 -53
  603. package/templates/starter/src/render/water.ts +0 -38
  604. package/templates/starter/src/render/watercolor.ts +0 -85
  605. /package/templates/{starter → puzzle}/playtests/boot-failure.playtest.json +0 -0
  606. /package/templates/{starter → puzzle}/playtests/pause.playtest.json +0 -0
  607. /package/templates/{defense → rts}/.codex/config.toml +0 -0
  608. /package/templates/{defense → rts}/.cursor/mcp.json +0 -0
  609. /package/templates/{defense → rts}/.gemini/settings.json +0 -0
  610. /package/templates/{defense → rts}/.mcp.json +0 -0
  611. /package/templates/{defense → rts}/.vscode/mcp.json +0 -0
  612. /package/templates/{defense → rts}/.zed/settings.json +0 -0
  613. /package/templates/{defense → rts}/index.html +0 -0
  614. /package/templates/{defense → rts}/opencode.json +0 -0
  615. /package/templates/{defense → rts}/src/main.ts +0 -0
  616. /package/templates/{defense → rts}/src/ui/main.tsx +0 -0
  617. /package/templates/{defense → tower-defense}/public/favicon.svg +0 -0
  618. /package/templates/{defense → tower-defense}/src/playtest-events.ts +0 -0
  619. /package/templates/{defense → tower-defense}/src/ui/App.tsx +0 -0
  620. /package/templates/{defense → tower-defense}/src/ui/GameUi.tsx +0 -0
  621. /package/templates/{defense → tower-defense}/tailwind.config.ts +0 -0
  622. /package/templates/{defense → tower-defense}/tsconfig.json +0 -0
@@ -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 { readFile, readdir, writeFile, stat, mkdir, rm, rename, access, unlink } from 'fs/promises';
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 path3 from 'path';
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 = path3.join(directory, entry.name);
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(path3.extname(file).toLowerCase())) continue;
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: ${path3.relative(outputDirectory, file)}: ${error.message}`
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) => path3.basename(file) === "index.html");
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 = path3.join(outputDirectory, source.replace(/^\//u, ""));
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: path3.relative(outputDirectory, 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(path3.join(cwd, "package.json"));
208
+ return createRequire$1(path4.join(cwd, "package.json"));
146
209
  }
147
210
  function configLoaderSearch(cwd) {
148
211
  return [
149
- path3.join(cwd, "node_modules", "vite"),
150
- path3.join(cwd, "node_modules", "esbuild"),
151
- path3.resolve(path3.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
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 = path3.join(cwd, "package.json");
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
- [path3.join(cwd, "package.json"), path3.join(cwd, CONFIG_FILE)],
183
- `fix '${path3.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
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 = path3.join(cwd, CONFIG_FILE);
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 = path3.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
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(path3.join(cwd, "package.json"), "utf8"));
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 (path3.isAbsolute(entry)) {
402
+ if (path4.isAbsolute(entry)) {
340
403
  fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must be project-relative.");
341
404
  }
342
- const resolved = path3.resolve(cwd, entry);
343
- const relative = path3.relative(cwd, resolved);
344
- if (relative === ".." || relative.startsWith(`..${path3.sep}`) || path3.isAbsolute(relative)) {
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 (path3.isAbsolute(relative)) {
451
+ if (path4.isAbsolute(relative)) {
389
452
  fail(`${options.codePrefix}_PATH_INVALID`, `${label} must be project-relative: ${relative}`);
390
453
  }
391
- const resolved = path3.resolve(cwd, relative);
392
- const withinProject = path3.relative(cwd, resolved);
393
- if (withinProject === ".." || withinProject.startsWith(`..${path3.sep}`) || path3.isAbsolute(withinProject)) {
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 = path3.extname(relative).slice(1).toLowerCase();
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
- async function loadConfigInternal(root) {
1143
- const packagePath = path3.join(root, "package.json");
1144
- const sourcePath = path3.join(root, CONFIG_FILE);
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 assets = raw?.assets === void 0 ? void 0 : validateAssets(raw.assets);
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 = path3.resolve(cwd);
1512
+ async function loadConfig(cwd, selection) {
1513
+ const root = path4.resolve(cwd);
1203
1514
  return withConfigContext(
1204
- validationContext(root, [path3.join(root, CONFIG_FILE), path3.join(root, "package.json")]),
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(path3.join(cwd, "package.json"));
1524
+ return createRequire$1(path4.join(cwd, "package.json"));
1214
1525
  }
1215
1526
  function packageRoot(cwd, packageName) {
1216
1527
  try {
1217
- return path3.dirname(projectRequire2(cwd).resolve(`${packageName}/package.json`));
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(`${path3.basename(command)} exited with code ${code ?? "unknown"}.`));
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(path3.join(cwd, "package.json"), "utf8"));
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 = path3.resolve(cwd, config.assets?.output ?? "public");
1283
- const manifestPath = path3.join(outputRoot, "assets.manifest.json");
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
- var UI_ENTRY = path3.join("src", "ui", "main.tsx");
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 = path3.join(cwd, ".threenative", "build", "ui");
1326
- const entry = path3.join(cwd, UI_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 = path3.join(cwd, ".threenative", "build");
1656
+ const buildRoot = path4.join(cwd, ".threenative", "build");
1335
1657
  await mkdir(buildRoot, { recursive: true });
1336
- const page = path3.join(cwd, `${UI_PAGE_PREFIX}${randomUUID()}.html`);
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(path3.sep).join("/")}"></script>`,
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 = path3.join(buildRoot, "build-ui.mjs");
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 = path3.join(output, path3.basename(page));
1362
- const index = path3.join(output, "index.html");
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
- await run(
1406
- process.execPath,
1407
- [path3.join(packageRoot(cwd, "vite"), "bin/vite.js"), "build", ...viteArgs],
1408
- cwd
1409
- );
1410
- const report = await writeCompressionSidecars(path3.resolve(cwd, viteOutDir(viteArgs)));
1411
- if (report !== void 0) {
1412
- process.stdout.write(
1413
- `web main chunk ${report.entry}: raw ${report.raw} B, gzip ${report.gzip} B, brotli ${report.brotli} B
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 = path3.resolve(cwd, relative);
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 : path3.resolve(cwd, value);
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: path3.resolve(cwd, config.app.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: path3.resolve(cwd, config.app.icons.android.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: path3.resolve(cwd, config.app.icons.android.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: path3.resolve(cwd, config.app.icons.ios.dark) },
1453
- ...config.app.icons.ios.tinted === void 0 ? {} : { tinted: path3.resolve(cwd, config.app.icons.ios.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: path3.resolve(cwd, config.bootSplash.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 = path3.join(cwd, ".threenative", "build");
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 = path3.join(directory, "config.json");
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 = path3.join(cwd, ".threenative", "build", "game.js");
1883
+ const output = path4.join(cwd, ".threenative", "build", "game.js");
1499
1884
  await run(
1500
1885
  process.execPath,
1501
1886
  [
1502
- path3.join(runtimeRoot, "scripts", "bundle.mjs"),
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 buildNative(target, cwd, allowSourceBuild = false, mode = "debug", format = "apk") {
1518
- const config = await loadConfig(cwd);
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 = path3.join(cwd, "public");
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 = path3.join(cwd, "dist-native", `${await projectName(cwd)}.app`);
1538
- await run(
1539
- process.execPath,
1975
+ const output2 = path4.join(cwd, "dist-native", `${await projectName(cwd)}.app`);
1976
+ await packageStaged(
1977
+ output2,
1978
+ runtimeRoot,
1540
1979
  [
1541
- path3.join(runtimeRoot, "scripts", "package-ios.mjs"),
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
- runtimeRoot
1993
+ { assets, config, target: "ios" }
1555
1994
  );
1556
1995
  return;
1557
1996
  }
1558
1997
  if (target === "android") {
1559
- const output2 = path3.join(
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 run(
1565
- process.execPath,
2003
+ await packageStaged(
2004
+ output2,
2005
+ runtimeRoot,
1566
2006
  [
1567
- path3.join(runtimeRoot, "scripts", "package-android.mjs"),
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
- runtimeRoot
2029
+ { assets, config, target: "android" }
1590
2030
  );
1591
2031
  return;
1592
2032
  }
1593
- const output = path3.join(cwd, "dist-native", await projectName(cwd));
1594
- await run(
1595
- process.execPath,
2033
+ const output = path4.join(cwd, "dist-native", await projectName(cwd));
2034
+ await packageStaged(
2035
+ output,
2036
+ cwd,
1596
2037
  [
1597
- path3.join(runtimeRoot, "scripts", "package-desktop.mjs"),
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", path3.resolve(process.env.THREENATIVE_RUNTIME_BINARY)] : [],
2048
+ ...process.env.THREENATIVE_RUNTIME_BINARY ? ["--runtime", path4.resolve(process.env.THREENATIVE_RUNTIME_BINARY)] : [],
1608
2049
  "--output",
1609
2050
  output
1610
2051
  ],
1611
- cwd
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
- const cwd = path3.resolve(options.cwd ?? process.cwd());
1629
- if (options.target === "web") await buildWeb(cwd, options.viteArgs);
1630
- else {
1631
- if ((options.viteArgs?.length ?? 0) > 0) {
1632
- throw new Error(
1633
- `${options.target} build does not accept ${options.viteArgs?.join(" ")}. iOS output is simulator-only; device signing remains OPEN.`
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
- await buildNative(options.target, cwd, options.allowSourceBuild === true, mode, format);
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(path3.delimiter).filter((directory) => directory.trim().length > 0).flatMap((directory) => binaryNames(platformName).map((name) => path3.join(directory, name)));
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
- path3.join(home, "Applications/Blender.app/Contents/MacOS/Blender")
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) => path3.join(root, "Blender Foundation", `Blender ${release}`, "blender.exe")
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
- path3.join(home, ".local/bin/blender")
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 = path3.resolve(override.trim());
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.1" }),
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.3" }),
1905
- blender: Object.freeze({ name: "threenative-blender-mcp", version: "0.1.3" })
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(path3.join(root, "android", "app", "build.gradle.kts"), "utf8")
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.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 = path3.resolve(start);
2778
+ let directory = path4.resolve(start);
2219
2779
  while (true) {
2220
- const candidate = path3.join(directory, "node_modules", name);
2221
- if (existsSync(path3.join(candidate, "package.json"))) return candidate;
2222
- const parent = path3.dirname(directory);
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 = path3.resolve(start);
2803
+ let directory = path4.resolve(start);
2244
2804
  while (true) {
2245
- const binDirectory = path3.join(directory, "node_modules", ".bin");
2246
- const candidates = process.platform === "win32" ? [path3.join(binDirectory, `${name}.cmd`), path3.join(binDirectory, name)] : [path3.join(binDirectory, name)];
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 = path3.dirname(directory);
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(path3.resolve(snapshot.projectRoot, spec.expectedArgs))) {
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(path3.join(packageDirectory, "package.json"));
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.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 = path3.resolve(snapshot.projectRoot);
2510
- let candidate = path3.resolve(root, relative);
2511
- if (candidate !== root && !candidate.startsWith(`${root}${path3.sep}`)) return false;
2512
- while (candidate !== root && !existsSync(candidate)) candidate = path3.dirname(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 sha256 = sha256Match[1];
2726
- if (bytesText === void 0 || artifact === void 0 || buildDirectory === void 0 || sha256 === 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: sha256.toLowerCase() };
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 || path3.isAbsolute(relative)) return void 0;
2750
- const root = path3.resolve(snapshot.projectRoot);
2751
- const resolved = path3.resolve(root, relative);
2752
- return resolved === root || resolved.startsWith(`${root}${path3.sep}`) ? resolved : void 0;
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);
@@ -2978,7 +3538,7 @@ function nativeRuntimeCheck(snapshot) {
2978
3538
  };
2979
3539
  }
2980
3540
  const binary = `prebuilt/${key}/${nativeRuntimeFilename()}`;
2981
- const exists = snapshot.runtimeFileExists?.(binary) ?? existsSync(path3.join(snapshot.runtimeRoot, binary));
3541
+ const exists = snapshot.runtimeFileExists?.(binary) ?? existsSync(path4.join(snapshot.runtimeRoot, binary));
2982
3542
  if (!exists) {
2983
3543
  return {
2984
3544
  detail: `unavailable \u2014 ${key} prebuilt binary is missing`,
@@ -2987,7 +3547,7 @@ function nativeRuntimeCheck(snapshot) {
2987
3547
  status: "fail"
2988
3548
  };
2989
3549
  }
2990
- const host = snapshot.nativeHost ?? probeNativeHost(path3.join(snapshot.runtimeRoot, binary));
3550
+ const host = snapshot.nativeHost ?? probeNativeHost(path4.join(snapshot.runtimeRoot, binary));
2991
3551
  const reported = host.runtimeVersion;
2992
3552
  if (reported === void 0) {
2993
3553
  return {
@@ -3064,7 +3624,7 @@ function javaVersion(output) {
3064
3624
  return Number.isSafeInteger(major) ? { major, version } : void 0;
3065
3625
  }
3066
3626
  function androidSdkVersion(root, requiredSdk) {
3067
- const sourceProperties = path3.join(
3627
+ const sourceProperties = path4.join(
3068
3628
  root,
3069
3629
  "platforms",
3070
3630
  `android-${requiredSdk}`,
@@ -3080,7 +3640,7 @@ function androidSdkVersion(root, requiredSdk) {
3080
3640
  }
3081
3641
  function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_ANDROID_COMPILE_SDK) {
3082
3642
  const javaHome = environment.JAVA_HOME?.trim() || void 0;
3083
- const java = javaHome === void 0 ? "java" : path3.join(javaHome, "bin", process.platform === "win32" ? "java.exe" : "java");
3643
+ const java = javaHome === void 0 ? "java" : path4.join(javaHome, "bin", process.platform === "win32" ? "java.exe" : "java");
3084
3644
  let jdkMajor;
3085
3645
  let jdkVersion;
3086
3646
  try {
@@ -3098,7 +3658,7 @@ function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_
3098
3658
  const sdkCandidates = [
3099
3659
  environment.ANDROID_HOME,
3100
3660
  environment.ANDROID_SDK_ROOT,
3101
- path3.join(homedir(), "Android", "Sdk")
3661
+ path4.join(homedir(), "Android", "Sdk")
3102
3662
  ].map((candidate) => candidate?.trim()).filter((candidate) => candidate !== void 0 && candidate.length > 0);
3103
3663
  const sdkRoot = sdkCandidates.find((candidate) => existsSync(candidate));
3104
3664
  return {
@@ -3109,7 +3669,7 @@ function probeAndroidToolchain(environment = process.env, requiredSdk = DEFAULT_
3109
3669
  }
3110
3670
  function runtimeFileAvailable(snapshot, relative) {
3111
3671
  if (snapshot.runtimeRoot === void 0) return false;
3112
- return snapshot.runtimeFileExists?.(relative) ?? existsSync(path3.join(snapshot.runtimeRoot, relative));
3672
+ return snapshot.runtimeFileExists?.(relative) ?? existsSync(path4.join(snapshot.runtimeRoot, relative));
3113
3673
  }
3114
3674
  function androidTargetCheck(snapshot) {
3115
3675
  if (!runtimeFileAvailable(snapshot, "scripts/package-android.mjs")) {
@@ -3406,7 +3966,7 @@ function diagnoseProject(snapshot, options = {}) {
3406
3966
  }
3407
3967
  async function collectFiles(root, relative = "", depth = 0) {
3408
3968
  if (depth > 3) return [];
3409
- const absolute = path3.join(root, relative);
3969
+ const absolute = path4.join(root, relative);
3410
3970
  if (!existsSync(absolute)) return [];
3411
3971
  const entries = await readdir(absolute, { withFileTypes: true });
3412
3972
  const files = [];
@@ -3427,7 +3987,7 @@ async function readJson(file) {
3427
3987
  }
3428
3988
  async function runtimeReleaseManifestUrl(runtimeRoot, version) {
3429
3989
  try {
3430
- const module = await import(pathToFileURL(path3.join(runtimeRoot, "scripts", "install-prebuilt.mjs")).href);
3990
+ const module = await import(pathToFileURL(path4.join(runtimeRoot, "scripts", "install-prebuilt.mjs")).href);
3431
3991
  const releaseUrl = record(module)?.releaseManifestUrl;
3432
3992
  if (typeof releaseUrl !== "function") return void 0;
3433
3993
  const result = releaseUrl(version);
@@ -3437,19 +3997,19 @@ async function runtimeReleaseManifestUrl(runtimeRoot, version) {
3437
3997
  }
3438
3998
  }
3439
3999
  async function readProject(root) {
3440
- const projectRoot = path3.resolve(root);
3441
- const packageJson = await readJson(path3.join(projectRoot, "package.json"));
3442
- const typeScriptConfig = path3.join(projectRoot, "threenative.config.ts");
4000
+ const projectRoot = path4.resolve(root);
4001
+ const packageJson = await readJson(path4.join(projectRoot, "package.json"));
4002
+ const typeScriptConfig = path4.join(projectRoot, "threenative.config.ts");
3443
4003
  const config = existsSync(typeScriptConfig) ? await readTypeScriptConfig(projectRoot) : nativeEntryCompat(record(packageJson)?.threenative);
3444
4004
  const files = new Set(await collectFiles(projectRoot));
3445
4005
  const installedVersions = /* @__PURE__ */ new Map();
3446
4006
  for (const name of declaredDependencies(packageJson)) {
3447
- const manifest = await readJson(path3.join(projectRoot, "node_modules", name, "package.json"));
4007
+ const manifest = await readJson(path4.join(projectRoot, "node_modules", name, "package.json"));
3448
4008
  const version = record(manifest)?.version;
3449
4009
  if (typeof version === "string") installedVersions.set(name, version);
3450
4010
  }
3451
4011
  const runtimeRoot = installedVersions.has(RUNTIME_PACKAGE) ? (() => {
3452
- const candidate = path3.join(projectRoot, "node_modules", RUNTIME_PACKAGE);
4012
+ const candidate = path4.join(projectRoot, "node_modules", RUNTIME_PACKAGE);
3453
4013
  try {
3454
4014
  return realpathSync(candidate);
3455
4015
  } catch {
@@ -3462,7 +4022,7 @@ async function readProject(root) {
3462
4022
  const mcpServerHealth = /* @__PURE__ */ new Map();
3463
4023
  if (SHAPE_VERIFIABLE_HOSTS.some(({ file }) => files.has(file))) {
3464
4024
  for (const spec of MCP_SERVER_SPECS) {
3465
- if (existsSync(path3.resolve(projectRoot, spec.expectedArgs))) {
4025
+ if (existsSync(path4.resolve(projectRoot, spec.expectedArgs))) {
3466
4026
  mcpServerHealth.set(spec.configName, probeMcpServer(projectRoot, spec));
3467
4027
  }
3468
4028
  }
@@ -3475,7 +4035,7 @@ async function readProject(root) {
3475
4035
  packageJson,
3476
4036
  projectRoot,
3477
4037
  readText: (relative) => {
3478
- const file = path3.join(projectRoot, relative);
4038
+ const file = path4.join(projectRoot, relative);
3479
4039
  try {
3480
4040
  return existsSync(file) ? readFileSync(file, "utf8") : void 0;
3481
4041
  } catch {
@@ -3501,14 +4061,14 @@ async function readProject(root) {
3501
4061
  ...runtimeRoot === void 0 ? {} : {
3502
4062
  readRuntimeText: (relative) => {
3503
4063
  try {
3504
- return readFileSync(path3.join(runtimeRoot, relative), "utf8");
4064
+ return readFileSync(path4.join(runtimeRoot, relative), "utf8");
3505
4065
  } catch {
3506
4066
  return void 0;
3507
4067
  }
3508
4068
  },
3509
- runtimeFileExists: (relative) => existsSync(path3.join(runtimeRoot, relative)),
4069
+ runtimeFileExists: (relative) => existsSync(path4.join(runtimeRoot, relative)),
3510
4070
  nativeHost: probeNativeHost(
3511
- path3.join(runtimeRoot, "prebuilt", nativeRuntimeKey(), nativeRuntimeFilename())
4071
+ path4.join(runtimeRoot, "prebuilt", nativeRuntimeKey(), nativeRuntimeFilename())
3512
4072
  ),
3513
4073
  ...runtimeManifestUrl === void 0 ? {} : { runtimeManifestUrl },
3514
4074
  runtimeRoot