@auraindustry/aurajs 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/README.md +103 -7
  2. package/benchmarks/perf-thresholds.json +54 -0
  3. package/package.json +4 -7
  4. package/src/asset-pack.mjs +5 -1
  5. package/src/authored-project.mjs +1449 -0
  6. package/src/authored-runtime.mjs +2016 -0
  7. package/src/authoring/avatar-animation-graph.mjs +648 -0
  8. package/src/bin-integrity.mjs +272 -0
  9. package/src/build-contract/assets.mjs +130 -0
  10. package/src/build-contract/capabilities.mjs +116 -0
  11. package/src/build-contract/constants.mjs +6 -0
  12. package/src/build-contract/helpers.mjs +44 -0
  13. package/src/build-contract/web-templates.mjs +5993 -0
  14. package/src/build-contract.mjs +27 -2910
  15. package/src/bundler.mjs +188 -55
  16. package/src/cli.mjs +4825 -1512
  17. package/src/commands/project-authoring.mjs +434 -0
  18. package/src/config.mjs +27 -0
  19. package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
  20. package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
  21. package/src/conformance/cases/index.mjs +11 -0
  22. package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
  23. package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
  24. package/src/conformance/shared.mjs +27 -0
  25. package/src/conformance-runner.mjs +25 -13
  26. package/src/conformance.mjs +619 -4020
  27. package/src/cutscene.mjs +362 -5
  28. package/src/dev-cli-action.mjs +249 -0
  29. package/src/dev-cli-inspect.mjs +92 -0
  30. package/src/dev-cli-state.mjs +80 -0
  31. package/src/external-asset-cache.mjs +587 -0
  32. package/src/external-asset-policy.mjs +217 -0
  33. package/src/external-package-surface.mjs +206 -0
  34. package/src/game-action-runtime.mjs +869 -0
  35. package/src/game-state-runtime.mjs +206 -6
  36. package/src/headless-action.mjs +186 -0
  37. package/src/headless-test/runtime-animation.mjs +1173 -0
  38. package/src/headless-test/runtime-coordinator.mjs +1514 -0
  39. package/src/headless-test/runtime-primitives.mjs +320 -0
  40. package/src/headless-test/runtime-world.mjs +2253 -0
  41. package/src/headless-test.mjs +392 -4298
  42. package/src/host-binary.mjs +342 -14
  43. package/src/icon-discovery.mjs +64 -0
  44. package/src/make-catalog.mjs +109 -0
  45. package/src/make.mjs +197 -0
  46. package/src/package-integrity.mjs +586 -0
  47. package/src/perf-benchmark.mjs +353 -0
  48. package/src/postinstall.mjs +5 -5
  49. package/src/prefabs/index.mjs +34 -0
  50. package/src/prefabs/scene-serialization.mjs +184 -0
  51. package/src/project-importer.mjs +620 -0
  52. package/src/project-registry.mjs +24 -0
  53. package/src/publish-command.mjs +195 -0
  54. package/src/publish-env-example.mjs +83 -0
  55. package/src/publish-validation.mjs +708 -0
  56. package/src/retro/assets/compile.mjs +232 -0
  57. package/src/retro/backend-gba/authoring.mjs +1029 -0
  58. package/src/retro/backend-gba/rom.mjs +363 -0
  59. package/src/retro/backend-gbc/rom.mjs +85 -0
  60. package/src/retro/build.mjs +278 -0
  61. package/src/retro/cli/commands.mjs +292 -0
  62. package/src/retro/cli/templates.mjs +84 -0
  63. package/src/retro/diagnostics/catalog.mjs +110 -0
  64. package/src/retro/diagnostics/emit.mjs +72 -0
  65. package/src/retro/emulator/case-overlay.mjs +64 -0
  66. package/src/retro/emulator/discovery.mjs +158 -0
  67. package/src/retro/emulator/macos-case-overlay.swift +220 -0
  68. package/src/retro/emulator/profiles.mjs +146 -0
  69. package/src/retro/emulator/runner.mjs +289 -0
  70. package/src/retro/frontend/load-project.mjs +98 -0
  71. package/src/retro/index.mjs +30 -0
  72. package/src/retro/ir/build-ir.mjs +108 -0
  73. package/src/retro/runtime-gba/contract.mjs +151 -0
  74. package/src/retro/runtime-gbc/contract.mjs +117 -0
  75. package/src/retro/shared/span.mjs +26 -0
  76. package/src/retro/shared/targets.mjs +64 -0
  77. package/src/retro/validator/check-project.mjs +114 -0
  78. package/src/runtime-hotspot-audit.mjs +707 -0
  79. package/src/scaffold/config.mjs +1000 -0
  80. package/src/scaffold/fs.mjs +56 -0
  81. package/src/scaffold/layout.mjs +318 -0
  82. package/src/scaffold/project-docs.mjs +438 -0
  83. package/src/scaffold.mjs +93 -596
  84. package/src/scene-composition/index.mjs +326 -0
  85. package/src/scene-composition/runtime.mjs +751 -0
  86. package/src/self-hosted-assets.mjs +604 -0
  87. package/src/session-client.mjs +750 -0
  88. package/src/session-native-launcher.mjs +74 -0
  89. package/src/session-protocol.mjs +75 -0
  90. package/src/session-runtime.mjs +321 -0
  91. package/src/session-server.mjs +360 -0
  92. package/src/shader-kits/index.mjs +773 -0
  93. package/src/starter-content-registry.mjs +292 -0
  94. package/src/state-artifacts.mjs +662 -24
  95. package/src/state-dev-reload.mjs +99 -2
  96. package/src/terminal-ui.mjs +245 -0
  97. package/src/web-conformance.mjs +219 -0
  98. package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
  99. package/templates/create/2d/content/gameplay/waves.json +26 -0
  100. package/templates/create/2d/content/registries/.gitkeep +1 -0
  101. package/templates/create/2d/docs/design/.gitkeep +1 -0
  102. package/templates/create/2d/docs/design/loop.md +5 -0
  103. package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
  104. package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
  105. package/templates/create/2d/prefabs/player.prefab.js +36 -0
  106. package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
  107. package/templates/create/2d/scenes/boot.scene.js +12 -0
  108. package/templates/create/2d/scenes/gameplay.scene.js +230 -0
  109. package/templates/create/2d/scenes/menu.scene.js +9 -0
  110. package/templates/create/2d/src/main.js +6 -185
  111. package/templates/create/2d/src/runtime/app.js +49 -0
  112. package/templates/create/2d/src/runtime/capabilities.js +35 -0
  113. package/templates/create/2d/ui/hud.screen.js +40 -0
  114. package/templates/create/2d/ui/pause.screen.js +149 -0
  115. package/templates/create/2d/ui/settings.screen.js +347 -0
  116. package/templates/create/2d/ui/title.screen.js +13 -0
  117. package/templates/create/2d-adventure/aura.config.json +28 -0
  118. package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
  119. package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
  120. package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
  121. package/templates/create/2d-adventure/docs/design/loop.md +5 -0
  122. package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
  123. package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
  124. package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
  125. package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
  126. package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
  127. package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
  128. package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
  129. package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
  130. package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
  131. package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
  132. package/templates/create/2d-survivor/docs/design/loop.md +5 -0
  133. package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
  134. package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
  135. package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
  136. package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
  137. package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
  138. package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
  139. package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
  140. package/templates/create/2d-survivor/src/main.js +5 -332
  141. package/templates/create/2d-survivor/src/runtime/app.js +49 -0
  142. package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
  143. package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
  144. package/templates/create/2d-survivor/ui/title.screen.js +13 -0
  145. package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
  146. package/templates/create/3d/config/gameplay/.gitkeep +1 -0
  147. package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
  148. package/templates/create/3d/content/gameplay/course.js +40 -0
  149. package/templates/create/3d/content/registries/.gitkeep +1 -0
  150. package/templates/create/3d/docs/design/.gitkeep +1 -0
  151. package/templates/create/3d/docs/design/loop.md +5 -0
  152. package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
  153. package/templates/create/3d/prefabs/player.prefab.js +204 -0
  154. package/templates/create/3d/prefabs/world.prefab.js +112 -0
  155. package/templates/create/3d/scenes/boot.scene.js +12 -0
  156. package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
  157. package/templates/create/3d/scenes/gameplay.scene.js +292 -0
  158. package/templates/create/3d/src/main.js +6 -295
  159. package/templates/create/3d/src/runtime/app.js +49 -0
  160. package/templates/create/3d/src/runtime/capabilities.js +53 -0
  161. package/templates/create/3d/src/runtime/materials.js +34 -0
  162. package/templates/create/3d/src/runtime/state.js +39 -0
  163. package/templates/create/3d/ui/hud.screen.js +75 -0
  164. package/templates/create/3d/ui/pause.screen.js +166 -0
  165. package/templates/create/3d/ui/settings.screen.js +387 -0
  166. package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
  167. package/templates/create/3d-adventure/aura.config.json +28 -0
  168. package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
  169. package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
  170. package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
  171. package/templates/create/3d-adventure/docs/design/loop.md +5 -0
  172. package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
  173. package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
  174. package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
  175. package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
  176. package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
  177. package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
  178. package/templates/create/3d-adventure/src/runtime/state.js +31 -0
  179. package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
  180. package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
  181. package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
  182. package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
  183. package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
  184. package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
  185. package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
  186. package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
  187. package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
  188. package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
  189. package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
  190. package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
  191. package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
  192. package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
  193. package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
  194. package/templates/create/3d-collectathon/src/main.js +5 -355
  195. package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
  196. package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
  197. package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
  198. package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
  199. package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
  200. package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
  201. package/templates/create/blank/config/gameplay/.gitkeep +1 -0
  202. package/templates/create/blank/content/gameplay/.gitkeep +1 -0
  203. package/templates/create/blank/content/registries/.gitkeep +1 -0
  204. package/templates/create/blank/docs/design/.gitkeep +1 -0
  205. package/templates/create/blank/docs/design/loop.md +5 -0
  206. package/templates/create/blank/prefabs/.gitkeep +1 -0
  207. package/templates/create/blank/scenes/.gitkeep +1 -0
  208. package/templates/create/blank/src/runtime/.gitkeep +1 -0
  209. package/templates/create/blank/ui/.gitkeep +1 -0
  210. package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
  211. package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
  212. package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
  213. package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
  214. package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
  215. package/templates/create/deckbuilder-2d/aura.config.json +28 -0
  216. package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
  217. package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
  218. package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
  219. package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
  220. package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
  221. package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
  222. package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
  223. package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
  224. package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
  225. package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
  226. package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
  227. package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
  228. package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
  229. package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
  230. package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
  231. package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
  232. package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
  233. package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
  234. package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
  235. package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
  236. package/templates/create/deckbuilder-2d/src/main.js +17 -0
  237. package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
  238. package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
  239. package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
  240. package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
  241. package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
  242. package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
  243. package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
  244. package/templates/create/local-multiplayer/aura.config.json +40 -0
  245. package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
  246. package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
  247. package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
  248. package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
  249. package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
  250. package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
  251. package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
  252. package/templates/create/local-multiplayer/src/main.js +17 -0
  253. package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
  254. package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
  255. package/templates/create/shared/src/runtime/project-inspector.js +105 -0
  256. package/templates/create/shared/src/runtime/scene-flow.js +290 -0
  257. package/templates/create/shared/src/runtime/screen-shell.js +222 -0
  258. package/templates/create/shared/src/runtime/ui-forms.js +209 -0
  259. package/templates/create/shared/src/runtime/ui-settings.js +237 -0
  260. package/templates/create/shared/src/runtime/ui-theme.js +352 -0
  261. package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
  262. package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
  263. package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
  264. package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
  265. package/templates/create/shared/src/starter-utils/core.js +39 -3
  266. package/templates/create/shared/src/starter-utils/index.js +8 -2
  267. package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
  268. package/templates/create/shared/src/starter-utils/triggers.js +662 -0
  269. package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
  270. package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
  271. package/templates/create/video-cutscene/aura.config.json +28 -0
  272. package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
  273. package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
  274. package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
  275. package/templates/create/video-cutscene/docs/design/loop.md +22 -0
  276. package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
  277. package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
  278. package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
  279. package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
  280. package/templates/create/video-cutscene/src/main.js +17 -0
  281. package/templates/create/video-cutscene/src/runtime/app.js +52 -0
  282. package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
  283. package/templates/create/video-cutscene/src/runtime/state.js +13 -0
  284. package/templates/create/video-cutscene/ui/.gitkeep +0 -0
  285. package/templates/create-bin/play.js +1187 -0
  286. package/templates/make/README.md +46 -0
  287. package/templates/make/catalog.json +51 -0
  288. package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
  289. package/templates/make/component/manifest.json +9 -0
  290. package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
  291. package/templates/make/data/manifest.json +9 -0
  292. package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
  293. package/templates/make/material/manifest.json +9 -0
  294. package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
  295. package/templates/make/prefab/manifest.json +9 -0
  296. package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
  297. package/templates/make/scene/manifest.json +9 -0
  298. package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
  299. package/templates/make/shader/manifest.json +9 -0
  300. package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
  301. package/templates/make/system/manifest.json +9 -0
  302. package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
  303. package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
  304. package/templates/make/ui-screen/manifest.json +10 -0
  305. package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
  306. package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
  307. package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
  308. package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
  309. package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
  310. package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
  311. package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
  312. package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
  313. package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
  314. package/templates/retro/platformer/README.md +10 -0
  315. package/templates/retro/platformer/assets/retro/assets.json +91 -0
  316. package/templates/retro/platformer/aura.config.json +7 -0
  317. package/templates/retro/platformer/package.json +5 -0
  318. package/templates/retro/platformer/src/main.js +40 -0
  319. package/templates/retro/puzzle-grid/README.md +10 -0
  320. package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
  321. package/templates/retro/puzzle-grid/aura.config.json +7 -0
  322. package/templates/retro/puzzle-grid/package.json +5 -0
  323. package/templates/retro/puzzle-grid/src/main.js +29 -0
  324. package/templates/retro/tactics-grid/README.md +10 -0
  325. package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
  326. package/templates/retro/tactics-grid/aura.config.json +7 -0
  327. package/templates/retro/tactics-grid/package.json +5 -0
  328. package/templates/retro/tactics-grid/src/main.js +35 -0
  329. package/templates/retro/topdown-adventure/README.md +10 -0
  330. package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
  331. package/templates/retro/topdown-adventure/aura.config.json +7 -0
  332. package/templates/retro/topdown-adventure/package.json +5 -0
  333. package/templates/retro/topdown-adventure/src/main.js +29 -0
  334. package/templates/skills/aurajs/SKILL.md +61 -5
@@ -217,6 +217,359 @@ export const DEFAULT_PERF_SCENES = [
217
217
  };
218
218
  `,
219
219
  },
220
+ {
221
+ id: 'ui_composition_surface_stress',
222
+ frames: 360,
223
+ source: `
224
+ let panelTarget = null;
225
+ let elapsed = 0;
226
+
227
+ aura.setup = function () {
228
+ panelTarget = aura.draw2d.createRenderTarget(128, 64);
229
+ aura.draw2d.resizeRenderTarget(panelTarget, 160, 72);
230
+ };
231
+
232
+ aura.update = function (dt) {
233
+ elapsed += dt;
234
+ };
235
+
236
+ aura.draw = function () {
237
+ aura.draw2d.clear(6, 8, 14);
238
+
239
+ aura.draw2d.withRenderTarget(panelTarget, () => {
240
+ aura.draw2d.clear(0, 0, 0, 0);
241
+ aura.draw2d.pushClipRect(4, 4, 152, 64);
242
+ aura.draw2d.rect(0, 0, 160, 72, aura.rgba(0.12, 0.16, 0.22, 0.92));
243
+ aura.draw2d.rect(10, 36, 112, 12, aura.rgba(0.35, 0.82, 1, 0.72));
244
+ aura.draw2d.text('ENERGY 72', 14, 18, { size: 12, color: aura.colors.white });
245
+ aura.draw2d.popClipRect();
246
+ });
247
+
248
+ aura.draw2d.pushClipRect(0, 0, aura.window.width, aura.window.height);
249
+ aura.draw2d.tileSprite(panelTarget, 0, 0, aura.window.width, aura.window.height, {
250
+ tileScaleX: 2,
251
+ tileScaleY: 2,
252
+ tileOffsetX: elapsed * 80,
253
+ tileOffsetY: elapsed * 40,
254
+ tint: aura.rgba(0.14, 0.18, 0.24, 0.6),
255
+ });
256
+ aura.draw2d.popClipRect();
257
+
258
+ for (let i = 0; i < 3; i += 1) {
259
+ const x = 24 + (i * 174);
260
+ const y = 28 + Math.sin((elapsed * 1.4) + (i * 0.35)) * 8;
261
+ aura.draw2d.pushClipRect(x, y, 168, 84);
262
+ aura.draw2d.sprite(panelTarget, x, y, { width: 168, height: 84 });
263
+ aura.draw2d.nineSlice(panelTarget, x + 8, y + 8, 152, 68, {
264
+ slice: 4,
265
+ tint: aura.rgba(0.2, 0.24, 0.32, 0.78),
266
+ });
267
+ aura.draw2d.tileSprite(panelTarget, x + 14, y + 50, 120, 10, {
268
+ tileScaleX: 0.25,
269
+ tileScaleY: 0.6,
270
+ tileOffsetX: (elapsed * 120) + (i * 6),
271
+ tint: aura.rgba(1, 0.82, 0.35, 0.72),
272
+ });
273
+ aura.draw2d.popClipRect();
274
+ }
275
+ };
276
+ `,
277
+ },
278
+ {
279
+ id: 'ui_masking_compositor_fx_stress',
280
+ frames: 360,
281
+ source: `
282
+ let maskTarget = null;
283
+ let stageBase = null;
284
+ let stageFx = null;
285
+ let stageFinal = null;
286
+ let elapsed = 0;
287
+ let frameIndex = 0;
288
+ let selectedItemId = 'sword';
289
+ let menuVolume = 5;
290
+ let pendingScroll = false;
291
+ let exportedGraph = false;
292
+
293
+ const hasRetainedUi =
294
+ !!aura.ui
295
+ && typeof aura.ui.beginContainer === 'function'
296
+ && typeof aura.ui.region === 'function'
297
+ && typeof aura.ui.selectOption === 'function'
298
+ && typeof aura.ui.endContainer === 'function'
299
+ && typeof aura.ui.getSelectionState === 'function'
300
+ && typeof aura.ui.getScrollState === 'function'
301
+ && typeof aura.ui.scrollBy === 'function'
302
+ && typeof aura.ui.activate === 'function';
303
+ const hasMask = typeof aura.draw2d.withMask === 'function';
304
+ const hasOrderedCapture = typeof aura.draw2d.withRenderTargets === 'function';
305
+ const hasNamedCompositor =
306
+ typeof aura.draw2d.runCompositorGraph === 'function'
307
+ && typeof aura.draw2d.exportRenderTarget === 'function';
308
+ const hasSpriteFx = typeof aura.draw2d.spriteFx === 'function';
309
+ const hasAnalyticMask = hasNamedCompositor;
310
+
311
+ function drawFallbackRows(originX, originY) {
312
+ const rows = [
313
+ 'INVENTORY',
314
+ 'SWORD',
315
+ 'SHIELD',
316
+ 'POTION',
317
+ ];
318
+ for (let i = 0; i < rows.length; i += 1) {
319
+ const isHeader = i === 0;
320
+ const rowY = originY + (i * 22);
321
+ aura.draw2d.rectFill(
322
+ originX,
323
+ rowY,
324
+ 184,
325
+ isHeader ? 18 : 18,
326
+ isHeader ? aura.rgba(0.08, 0.1, 0.16, 0.96) : aura.rgba(0.16, 0.2, 0.28, 0.9),
327
+ );
328
+ aura.draw2d.text(rows[i], originX + 8, rowY + 4, {
329
+ size: isHeader ? 12 : 11,
330
+ color: aura.colors.white,
331
+ });
332
+ }
333
+ }
334
+
335
+ function drawRetainedWidgets(originX, originY) {
336
+ if (!hasRetainedUi) {
337
+ drawFallbackRows(originX, originY);
338
+ return;
339
+ }
340
+
341
+ if (pendingScroll) {
342
+ aura.ui.scrollBy('frontier-menu', 0, 14);
343
+ pendingScroll = false;
344
+ }
345
+
346
+ aura.ui.beginContainer({
347
+ id: 'frontier-menu',
348
+ x: originX,
349
+ y: originY,
350
+ width: 188,
351
+ height: 52,
352
+ direction: 'vertical',
353
+ gap: 4,
354
+ padding: 2,
355
+ });
356
+ const header = aura.ui.region('header', {
357
+ width: 180,
358
+ height: 12,
359
+ });
360
+ const sword = aura.ui.selectOption('sword', {
361
+ label: 'Sword',
362
+ value: 'sword',
363
+ width: 180,
364
+ height: 12,
365
+ selected: selectedItemId === 'sword',
366
+ });
367
+ const shield = aura.ui.selectOption('shield', {
368
+ label: 'Shield',
369
+ value: 'shield',
370
+ width: 180,
371
+ height: 12,
372
+ selected: selectedItemId === 'shield',
373
+ });
374
+ const potion = aura.ui.selectOption('potion', {
375
+ label: 'Potion',
376
+ value: 'potion',
377
+ width: 180,
378
+ height: 12,
379
+ selected: selectedItemId === 'potion',
380
+ });
381
+ if ((frameIndex % 72) === 0) {
382
+ aura.ui.activate(selectedItemId);
383
+ }
384
+ aura.ui.endContainer();
385
+
386
+ const selection = aura.ui.getSelectionState('frontier-menu');
387
+ const widgets = [
388
+ { label: 'INVENTORY', x: header.x, y: header.y, width: header.width, height: header.height, header: true },
389
+ sword,
390
+ shield,
391
+ potion,
392
+ ];
393
+ if (selection && selection.selectedRegionId) {
394
+ selectedItemId = selection.selectedRegionId;
395
+ }
396
+
397
+ for (let i = 0; i < widgets.length; i += 1) {
398
+ const widget = widgets[i];
399
+ if (!widget || widget.ok !== true) continue;
400
+ const isHeader = widget.header === true;
401
+ aura.draw2d.rectFill(
402
+ widget.x,
403
+ widget.y,
404
+ widget.width,
405
+ widget.height,
406
+ isHeader ? aura.rgba(0.08, 0.1, 0.16, 0.9) : aura.rgba(0.14, 0.18, 0.26, 0.84),
407
+ );
408
+ aura.draw2d.text(widget.label || widget.itemId || 'widget', widget.x + 8, widget.y + 6, {
409
+ size: isHeader ? 12 : 11,
410
+ color: aura.colors.white,
411
+ });
412
+ }
413
+ }
414
+
415
+ function stageBaseDraw() {
416
+ aura.draw2d.clear(0, 0, 0, 0);
417
+ aura.draw2d.rectFill(0, 0, 224, 128, aura.rgba(0.1, 0.14, 0.22, 0.96));
418
+ aura.draw2d.nineSlice(maskTarget, 8, 8, 208, 112, {
419
+ slice: 6,
420
+ tint: aura.rgba(0.18, 0.22, 0.3, 0.76),
421
+ });
422
+ aura.draw2d.tileSprite(maskTarget, 14, 84, 196, 18, {
423
+ tileScaleX: 0.55,
424
+ tileScaleY: 0.45,
425
+ tileOffsetX: elapsed * 72,
426
+ tileOffsetY: elapsed * 20,
427
+ tint: aura.rgba(0.94, 0.78, 0.34, 0.6),
428
+ });
429
+ drawRetainedWidgets(18, 16);
430
+ aura.draw2d.text('VOL ' + menuVolume, 146, 96, {
431
+ size: 11,
432
+ color: aura.colors.white,
433
+ });
434
+ }
435
+
436
+ function stageFxDraw(source) {
437
+ aura.draw2d.clear(0, 0, 0, 0);
438
+ aura.draw2d.sprite(source, 0, 0, { width: 224, height: 128 });
439
+ aura.draw2d.tileSprite(source, 8, 92, 188, 18, {
440
+ tileScaleX: 0.45,
441
+ tileScaleY: 0.55,
442
+ tileOffsetX: elapsed * 96,
443
+ tileOffsetY: elapsed * 28,
444
+ tint: aura.rgba(0.18, 0.72, 0.98, 0.36),
445
+ });
446
+ if (hasSpriteFx) {
447
+ aura.draw2d.spriteFx(source, 18, 16, {
448
+ width: 180,
449
+ height: 84,
450
+ shadow: { offsetX: 3, offsetY: 4 },
451
+ outline: {
452
+ thickness: 1,
453
+ color: aura.rgba(0.98, 0.88, 0.48, 0.82),
454
+ },
455
+ });
456
+ } else {
457
+ aura.draw2d.sprite(source, 18, 16, { width: 180, height: 84 });
458
+ }
459
+ }
460
+
461
+ function stageFinalDraw(source) {
462
+ aura.draw2d.clear(0, 0, 0, 0);
463
+ aura.draw2d.sprite(source, 0, 0, { width: 224, height: 128 });
464
+ aura.draw2d.rectFill(16, 14, 192, 18, aura.rgba(0.07, 0.1, 0.16, 0.84));
465
+ aura.draw2d.text('UI FRONTIER', 24, 20, { size: 12, color: aura.colors.white });
466
+ aura.draw2d.text('FRAME ' + frameIndex, 132, 20, { size: 11, color: aura.colors.white });
467
+ }
468
+
469
+ function drawMaskedCard(source, x, y, width, height) {
470
+ const drawSurface = () => {
471
+ aura.draw2d.sprite(source, x, y, { width, height });
472
+ if (hasSpriteFx) {
473
+ aura.draw2d.spriteFx(source, x + 18, y + 58, {
474
+ width: 56,
475
+ height: 30,
476
+ shadow: { offsetX: 2, offsetY: 3 },
477
+ outline: {
478
+ thickness: 1,
479
+ color: aura.rgba(0.95, 0.82, 0.36, 0.78),
480
+ },
481
+ });
482
+ }
483
+ };
484
+
485
+ if (hasMask && hasAnalyticMask) {
486
+ aura.draw2d.withMask({ type: 'analytic', shape: 'circle', feather: 0.18 }, x + 10, y + 8, width - 20, height - 16, drawSurface);
487
+ return;
488
+ }
489
+
490
+ if (hasMask) {
491
+ aura.draw2d.withMask(maskTarget, x + 10, y + 8, width - 20, height - 16, drawSurface);
492
+ return;
493
+ }
494
+
495
+ aura.draw2d.pushClipRect(x + 10, y + 8, width - 20, height - 16);
496
+ drawSurface();
497
+ aura.draw2d.popClipRect();
498
+ }
499
+
500
+ aura.setup = function () {
501
+ maskTarget = aura.draw2d.createRenderTarget(96, 96);
502
+ stageBase = aura.draw2d.createRenderTarget(224, 128);
503
+ stageFx = aura.draw2d.createRenderTarget(224, 128);
504
+ stageFinal = aura.draw2d.createRenderTarget(224, 128);
505
+ };
506
+
507
+ aura.update = function (dt) {
508
+ elapsed += dt;
509
+ frameIndex += 1;
510
+ if ((frameIndex % 20) === 0) {
511
+ menuVolume = (menuVolume + 1) % 11;
512
+ }
513
+ if ((frameIndex % 36) === 0) {
514
+ pendingScroll = true;
515
+ }
516
+ if ((frameIndex % 48) === 0) {
517
+ selectedItemId = selectedItemId === 'sword'
518
+ ? 'shield'
519
+ : (selectedItemId === 'shield' ? 'potion' : 'sword');
520
+ }
521
+ };
522
+
523
+ aura.draw = function () {
524
+ aura.draw2d.clear(7, 10, 16);
525
+
526
+ aura.draw2d.withRenderTarget(maskTarget, () => {
527
+ aura.draw2d.clear(0, 0, 0, 0);
528
+ aura.draw2d.circleFill(48, 48, 28, aura.rgba(1, 1, 1, 1));
529
+ aura.draw2d.rectFill(18, 18, 60, 48, aura.rgba(1, 1, 1, 0.8));
530
+ });
531
+
532
+ let composedSource = stageFinal;
533
+
534
+ if (hasNamedCompositor) {
535
+ const graph = aura.draw2d.runCompositorGraph('perf-frontier', [
536
+ { id: 'base', target: stageBase, draw: stageBaseDraw },
537
+ {
538
+ id: 'fx',
539
+ target: stageFx,
540
+ draw: () => stageFxDraw({ type: 'compositorStage', graph: 'perf-frontier', stage: 'base' }),
541
+ },
542
+ {
543
+ id: 'final',
544
+ target: stageFinal,
545
+ draw: () => stageFinalDraw({ type: 'compositorStage', graph: 'perf-frontier', stage: 'fx' }),
546
+ },
547
+ ]);
548
+
549
+ if (graph && graph.ok === true && Array.isArray(graph.stages) && graph.stages.length === 3) {
550
+ composedSource = graph.stages[2];
551
+ if (!exportedGraph) {
552
+ aura.draw2d.exportRenderTarget(graph.stages[2], 'tmp/ui-frontier-perf.png');
553
+ exportedGraph = true;
554
+ }
555
+ }
556
+ } else if (hasOrderedCapture) {
557
+ aura.draw2d.withRenderTargets([
558
+ { target: stageBase, draw: stageBaseDraw },
559
+ { target: stageFx, draw: () => stageFxDraw(stageBase) },
560
+ { target: stageFinal, draw: () => stageFinalDraw(stageFx) },
561
+ ]);
562
+ }
563
+
564
+ for (let i = 0; i < 4; i += 1) {
565
+ const x = 18 + (i * 156);
566
+ const y = 22 + Math.sin((elapsed * 1.25) + (i * 0.45)) * 10;
567
+ drawMaskedCard(composedSource, x, y, 148, 100);
568
+ aura.draw2d.text('P' + i, x + 10, y + 78, { size: 10, color: aura.colors.white });
569
+ }
570
+ };
571
+ `,
572
+ },
220
573
  ];
221
574
 
222
575
  function mean(values) {
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { readFileSync } from 'node:fs';
4
- import { resolveAndCacheHostBinary, HostBinaryResolutionError } from './host-binary.mjs';
4
+ import { ensureHostBinaryAvailable, HostBinaryResolutionError } from './host-binary.mjs';
5
5
 
6
- function main() {
6
+ async function main() {
7
7
  const pkgPath = new URL('../package.json', import.meta.url);
8
8
  const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
9
9
 
10
10
  try {
11
- const result = resolveAndCacheHostBinary({ packageJsonVersion: pkg.version });
11
+ const result = await ensureHostBinaryAvailable({ packageJsonVersion: pkg.version });
12
12
  console.log(`[aurajs] host binary ready (${result.target}): ${result.binaryPath}`);
13
13
  if (result.cacheStatus !== 'hit') {
14
14
  console.log(`[aurajs] cache ${result.cacheStatus}: ${result.cacheDir}`);
@@ -16,11 +16,11 @@ function main() {
16
16
  } catch (error) {
17
17
  if (error instanceof HostBinaryResolutionError) {
18
18
  console.error(`[aurajs] postinstall warning: ${error.message}`);
19
- console.error('[aurajs] run "npm install" again after optionalDependencies are available.');
19
+ console.error('[aurajs] the host binary will be downloaded on first successful networked install or first CLI run.');
20
20
  process.exit(0);
21
21
  }
22
22
  throw error;
23
23
  }
24
24
  }
25
25
 
26
- main();
26
+ await main();
@@ -0,0 +1,34 @@
1
+ import { createSceneComposition } from '../scene-composition/index.mjs';
2
+ import {
3
+ SCENE_PREFAB_SCHEMA,
4
+ buildSceneCompositionFromPrefab,
5
+ createScenePrefab,
6
+ deserializeScenePrefab,
7
+ normalizeScenePrefab,
8
+ readScenePrefabFile,
9
+ serializeScenePrefab,
10
+ writeScenePrefabFile,
11
+ } from './scene-serialization.mjs';
12
+
13
+ export {
14
+ SCENE_PREFAB_SCHEMA,
15
+ buildSceneCompositionFromPrefab,
16
+ createScenePrefab,
17
+ deserializeScenePrefab,
18
+ normalizeScenePrefab,
19
+ readScenePrefabFile,
20
+ serializeScenePrefab,
21
+ writeScenePrefabFile,
22
+ };
23
+
24
+ export function instantiateScenePrefab(aura, prefab, overrides = {}) {
25
+ const normalizedPrefab = normalizeScenePrefab(prefab);
26
+ const sceneConfig = buildSceneCompositionFromPrefab(normalizedPrefab, overrides);
27
+ const scene = createSceneComposition(aura, sceneConfig);
28
+ if (normalizedPrefab.defaults.autoMount !== false && overrides.autoMount !== false) {
29
+ scene.mount();
30
+ }
31
+ return scene;
32
+ }
33
+
34
+ export default instantiateScenePrefab;
@@ -0,0 +1,184 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ import { writeCanonicalJsonFile } from '../build-contract.mjs';
5
+ import {
6
+ SCENE_COMPOSITION_SCHEMA,
7
+ mergeSceneCompositionConfig,
8
+ normalizeSceneCompositionConfig,
9
+ sanitizeSceneCompositionForSerialization,
10
+ } from '../scene-composition/index.mjs';
11
+
12
+ export const SCENE_PREFAB_SCHEMA = 'aurajs.scene-prefab.v1';
13
+
14
+ function isPlainObject(value) {
15
+ return !!value && typeof value === 'object' && !Array.isArray(value);
16
+ }
17
+
18
+ function cloneValue(value) {
19
+ return value == null ? value : structuredClone(value);
20
+ }
21
+
22
+ function normalizeString(value, fallback = null) {
23
+ if (typeof value !== 'string') return fallback;
24
+ const trimmed = value.trim();
25
+ return trimmed.length > 0 ? trimmed : fallback;
26
+ }
27
+
28
+ function normalizeVec3(value, fallback = { x: 0, y: 0, z: 0 }) {
29
+ const source = isPlainObject(value) ? value : {};
30
+ return {
31
+ x: Number.isFinite(Number(source.x)) ? Number(source.x) : fallback.x,
32
+ y: Number.isFinite(Number(source.y)) ? Number(source.y) : fallback.y,
33
+ z: Number.isFinite(Number(source.z)) ? Number(source.z) : fallback.z,
34
+ };
35
+ }
36
+
37
+ function looksLikeSceneComposition(value) {
38
+ if (!isPlainObject(value)) return false;
39
+ return value.schema === SCENE_COMPOSITION_SCHEMA
40
+ || Object.prototype.hasOwnProperty.call(value, 'camera')
41
+ || Object.prototype.hasOwnProperty.call(value, 'nodes')
42
+ || Object.prototype.hasOwnProperty.call(value, 'meshes')
43
+ || Object.prototype.hasOwnProperty.call(value, 'avatars');
44
+ }
45
+
46
+ export function normalizeScenePrefab(prefab = {}) {
47
+ if (!isPlainObject(prefab)) {
48
+ throw new TypeError('Scene prefab must be an object.');
49
+ }
50
+
51
+ const sourceScene = looksLikeSceneComposition(prefab.scene)
52
+ ? prefab.scene
53
+ : (looksLikeSceneComposition(prefab.composition) ? prefab.composition : prefab);
54
+
55
+ return {
56
+ schema: SCENE_PREFAB_SCHEMA,
57
+ kind: 'scene-prefab',
58
+ id: normalizeString(prefab.id, 'scene-prefab'),
59
+ name: normalizeString(prefab.name, normalizeString(prefab.id, null)),
60
+ version: Number.isInteger(prefab.version) && prefab.version > 0 ? prefab.version : 1,
61
+ tags: Array.isArray(prefab.tags)
62
+ ? [...new Set(prefab.tags.map((entry) => normalizeString(entry, null)).filter(Boolean))]
63
+ .sort((left, right) => left.localeCompare(right))
64
+ : [],
65
+ metadata: isPlainObject(prefab.metadata) ? cloneValue(prefab.metadata) : {},
66
+ defaults: {
67
+ autoMount: prefab.defaults?.autoMount !== false,
68
+ },
69
+ scene: sanitizeSceneCompositionForSerialization(sourceScene),
70
+ };
71
+ }
72
+
73
+ export function createScenePrefab(prefab = {}) {
74
+ return normalizeScenePrefab(prefab);
75
+ }
76
+
77
+ export function serializeScenePrefab(prefab, options = {}) {
78
+ const normalized = normalizeScenePrefab(prefab);
79
+ return options.pretty === false
80
+ ? `${JSON.stringify(normalized)}\n`
81
+ : `${JSON.stringify(normalized, null, 2)}\n`;
82
+ }
83
+
84
+ export function deserializeScenePrefab(value) {
85
+ if (typeof value === 'string') {
86
+ return normalizeScenePrefab(JSON.parse(value));
87
+ }
88
+ return normalizeScenePrefab(value);
89
+ }
90
+
91
+ export function buildSceneCompositionFromPrefab(prefab, overrides = {}) {
92
+ const normalizedPrefab = normalizeScenePrefab(prefab);
93
+ const overrideSource = isPlainObject(overrides) ? overrides : {};
94
+ const sceneOverride = looksLikeSceneComposition(overrideSource.scene)
95
+ ? overrideSource.scene
96
+ : (looksLikeSceneComposition(overrideSource) ? overrideSource : {});
97
+ const baseScene = {
98
+ ...normalizedPrefab.scene,
99
+ name: normalizedPrefab.scene.name || normalizedPrefab.name || normalizedPrefab.id,
100
+ };
101
+
102
+ let scene = mergeSceneCompositionConfig(baseScene, sceneOverride);
103
+ const origin = normalizeVec3(overrideSource.origin, { x: 0, y: 0, z: 0 });
104
+ const idPrefix = normalizeString(overrideSource.idPrefix, null);
105
+
106
+ if (origin.x !== 0 || origin.y !== 0 || origin.z !== 0) {
107
+ scene = offsetSceneComposition(scene, origin);
108
+ }
109
+ if (idPrefix) {
110
+ scene = prefixSceneCompositionIds(scene, idPrefix);
111
+ }
112
+
113
+ return scene;
114
+ }
115
+
116
+ export function writeScenePrefabFile(filePath, prefab) {
117
+ const absolutePath = resolve(filePath);
118
+ const normalized = normalizeScenePrefab(prefab);
119
+ writeCanonicalJsonFile(absolutePath, normalized);
120
+ return normalized;
121
+ }
122
+
123
+ export function readScenePrefabFile(filePath) {
124
+ return deserializeScenePrefab(readFileSync(resolve(filePath), 'utf8'));
125
+ }
126
+
127
+ function offsetSceneComposition(scene, offset) {
128
+ const normalized = normalizeSceneCompositionConfig(scene);
129
+ return {
130
+ ...normalized,
131
+ nodes: normalized.nodes.map((entry) => ({
132
+ ...entry,
133
+ transform: {
134
+ ...entry.transform,
135
+ position: {
136
+ x: entry.transform.position.x + offset.x,
137
+ y: entry.transform.position.y + offset.y,
138
+ z: entry.transform.position.z + offset.z,
139
+ },
140
+ },
141
+ })),
142
+ };
143
+ }
144
+
145
+ function prefixSceneCompositionIds(scene, prefix) {
146
+ const normalized = normalizeSceneCompositionConfig(scene);
147
+ const prefixId = (value) => (value ? `${prefix}/${value}` : value);
148
+
149
+ return {
150
+ ...normalized,
151
+ name: normalized.name ? `${prefix}/${normalized.name}` : normalized.name,
152
+ nodes: normalized.nodes.map((entry) => ({
153
+ ...entry,
154
+ id: prefixId(entry.id),
155
+ parentId: prefixId(entry.parentId),
156
+ })),
157
+ meshes: normalized.meshes.map((entry) => ({
158
+ ...entry,
159
+ id: prefixId(entry.id),
160
+ nodeId: prefixId(entry.nodeId),
161
+ })),
162
+ billboards: normalized.billboards.map((entry) => ({
163
+ ...entry,
164
+ id: prefixId(entry.id),
165
+ nodeId: prefixId(entry.nodeId),
166
+ })),
167
+ avatars: normalized.avatars.map((entry) => ({
168
+ ...entry,
169
+ id: prefixId(entry.id),
170
+ nodeId: prefixId(entry.nodeId),
171
+ })),
172
+ triggers: normalized.triggers.map((entry) => ({
173
+ ...entry,
174
+ id: prefixId(entry.id),
175
+ nodeId: prefixId(entry.nodeId),
176
+ watch: entry.watch.map((watcher) => ({
177
+ ...watcher,
178
+ id: prefixId(watcher.id),
179
+ avatarId: prefixId(watcher.avatarId),
180
+ nodeId: prefixId(watcher.nodeId),
181
+ })),
182
+ })),
183
+ };
184
+ }