@needle-tools/engine 5.1.0-canary.db0c38f → 5.1.0-canary.e6680fa

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 (381) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +133 -1
  3. package/SKILL.md +4 -1
  4. package/components.needle.json +1 -1
  5. package/dist/needle-engine.bundle-Bl_hyH5G.umd.cjs +1734 -0
  6. package/dist/needle-engine.bundle-Cduc1gj6.min.js +1734 -0
  7. package/dist/{needle-engine.bundle-B29kieh0.js → needle-engine.bundle-DNcqT8nJ.js} +13770 -12741
  8. package/dist/needle-engine.d.ts +1628 -402
  9. package/dist/needle-engine.js +591 -586
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/three.js +1 -0
  13. package/dist/three.min.js +21 -21
  14. package/dist/three.umd.cjs +16 -16
  15. package/lib/engine/api.d.ts +9 -2
  16. package/lib/engine/api.js +7 -1
  17. package/lib/engine/api.js.map +1 -1
  18. package/lib/engine/codegen/register_types.js +10 -18
  19. package/lib/engine/codegen/register_types.js.map +1 -1
  20. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  21. package/lib/engine/debug/debug_spatial_console.js +10 -7
  22. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  23. package/lib/engine/engine_addressables.d.ts +2 -0
  24. package/lib/engine/engine_addressables.js +6 -3
  25. package/lib/engine/engine_addressables.js.map +1 -1
  26. package/lib/engine/engine_audio.d.ts +68 -0
  27. package/lib/engine/engine_audio.js +172 -0
  28. package/lib/engine/engine_audio.js.map +1 -1
  29. package/lib/engine/engine_camera.fit.js +16 -4
  30. package/lib/engine/engine_camera.fit.js.map +1 -1
  31. package/lib/engine/engine_components.js +1 -1
  32. package/lib/engine/engine_components.js.map +1 -1
  33. package/lib/engine/engine_context.d.ts +41 -27
  34. package/lib/engine/engine_context.js +71 -30
  35. package/lib/engine/engine_context.js.map +1 -1
  36. package/lib/engine/engine_context_eventbus.d.ts +47 -0
  37. package/lib/engine/engine_context_eventbus.js +47 -0
  38. package/lib/engine/engine_context_eventbus.js.map +1 -0
  39. package/lib/engine/engine_disposable.d.ts +172 -0
  40. package/lib/engine/engine_disposable.js +136 -0
  41. package/lib/engine/engine_disposable.js.map +1 -0
  42. package/lib/engine/engine_gameobject.d.ts +1 -10
  43. package/lib/engine/engine_gameobject.js +22 -120
  44. package/lib/engine/engine_gameobject.js.map +1 -1
  45. package/lib/engine/engine_gltf_builtin_components.js +7 -69
  46. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  47. package/lib/engine/engine_init.js +16 -1
  48. package/lib/engine/engine_init.js.map +1 -1
  49. package/lib/engine/engine_input.d.ts +24 -5
  50. package/lib/engine/engine_input.js +3 -2
  51. package/lib/engine/engine_input.js.map +1 -1
  52. package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
  53. package/lib/engine/engine_instantiate_resolve.js +372 -0
  54. package/lib/engine/engine_instantiate_resolve.js.map +1 -0
  55. package/lib/engine/engine_license.d.ts +8 -6
  56. package/lib/engine/engine_license.js +195 -59
  57. package/lib/engine/engine_license.js.map +1 -1
  58. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  59. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  60. package/lib/engine/engine_mainloop_utils.js +7 -4
  61. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  62. package/lib/engine/engine_networking.d.ts +51 -37
  63. package/lib/engine/engine_networking.js +132 -82
  64. package/lib/engine/engine_networking.js.map +1 -1
  65. package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
  66. package/lib/engine/engine_networking.transport.websocket.js +38 -0
  67. package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
  68. package/lib/engine/engine_networking_blob.js +4 -4
  69. package/lib/engine/engine_networking_blob.js.map +1 -1
  70. package/lib/engine/engine_networking_instantiate.js +2 -2
  71. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  72. package/lib/engine/engine_networking_types.d.ts +39 -1
  73. package/lib/engine/engine_networking_types.js +7 -0
  74. package/lib/engine/engine_networking_types.js.map +1 -1
  75. package/lib/engine/engine_physics_rapier.d.ts +21 -3
  76. package/lib/engine/engine_physics_rapier.js +94 -25
  77. package/lib/engine/engine_physics_rapier.js.map +1 -1
  78. package/lib/engine/engine_pmrem.js +53 -5
  79. package/lib/engine/engine_pmrem.js.map +1 -1
  80. package/lib/engine/engine_scenedata.d.ts +13 -17
  81. package/lib/engine/engine_scenedata.js +58 -31
  82. package/lib/engine/engine_scenedata.js.map +1 -1
  83. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  84. package/lib/engine/engine_serialization_builtin_serializer.js +56 -46
  85. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  86. package/lib/engine/engine_serialization_core.d.ts +1 -0
  87. package/lib/engine/engine_serialization_core.js +7 -0
  88. package/lib/engine/engine_serialization_core.js.map +1 -1
  89. package/lib/engine/engine_ssr.d.ts +2 -0
  90. package/lib/engine/engine_ssr.js +20 -0
  91. package/lib/engine/engine_ssr.js.map +1 -1
  92. package/lib/engine/engine_types.d.ts +31 -11
  93. package/lib/engine/engine_types.js +1 -1
  94. package/lib/engine/engine_types.js.map +1 -1
  95. package/lib/engine/engine_util_decorator.js +7 -2
  96. package/lib/engine/engine_util_decorator.js.map +1 -1
  97. package/lib/engine/engine_utils.d.ts +1 -1
  98. package/lib/engine/engine_utils.js +19 -5
  99. package/lib/engine/engine_utils.js.map +1 -1
  100. package/lib/engine/engine_utils_format.js +20 -14
  101. package/lib/engine/engine_utils_format.js.map +1 -1
  102. package/lib/engine/engine_utils_qrcode.js +2 -2
  103. package/lib/engine/engine_utils_qrcode.js.map +1 -1
  104. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  105. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
  106. package/lib/engine/webcomponents/jsx.d.ts +51 -0
  107. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  108. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  109. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  110. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +3 -4
  111. package/lib/engine/webcomponents/needle menu/needle-menu.js +6 -6
  112. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  113. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  114. package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
  115. package/lib/engine/webcomponents/needle-engine.js +3 -3
  116. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  117. package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
  118. package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
  119. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  120. package/lib/engine/xr/NeedleXRSession.js +50 -14
  121. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  122. package/lib/engine/xr/TempXRContext.js +2 -2
  123. package/lib/engine/xr/TempXRContext.js.map +1 -1
  124. package/lib/engine/xr/events.d.ts +1 -1
  125. package/lib/engine/xr/events.js.map +1 -1
  126. package/lib/engine-components/Animation.js +17 -16
  127. package/lib/engine-components/Animation.js.map +1 -1
  128. package/lib/engine-components/AnimationBuilder.d.ts +158 -0
  129. package/lib/engine-components/AnimationBuilder.js +305 -0
  130. package/lib/engine-components/AnimationBuilder.js.map +1 -0
  131. package/lib/engine-components/Animator.d.ts +6 -0
  132. package/lib/engine-components/Animator.js +23 -13
  133. package/lib/engine-components/Animator.js.map +1 -1
  134. package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
  135. package/lib/engine-components/AnimatorController.builder.js +263 -0
  136. package/lib/engine-components/AnimatorController.builder.js.map +1 -0
  137. package/lib/engine-components/AnimatorController.d.ts +4 -119
  138. package/lib/engine-components/AnimatorController.js +37 -233
  139. package/lib/engine-components/AnimatorController.js.map +1 -1
  140. package/lib/engine-components/AudioSource.d.ts +19 -3
  141. package/lib/engine-components/AudioSource.js +121 -68
  142. package/lib/engine-components/AudioSource.js.map +1 -1
  143. package/lib/engine-components/Camera.d.ts +6 -1
  144. package/lib/engine-components/Camera.js +16 -3
  145. package/lib/engine-components/Camera.js.map +1 -1
  146. package/lib/engine-components/CameraUtils.js +14 -6
  147. package/lib/engine-components/CameraUtils.js.map +1 -1
  148. package/lib/engine-components/Collider.d.ts +18 -9
  149. package/lib/engine-components/Collider.js +61 -14
  150. package/lib/engine-components/Collider.js.map +1 -1
  151. package/lib/engine-components/Component.d.ts +72 -9
  152. package/lib/engine-components/Component.js +114 -10
  153. package/lib/engine-components/Component.js.map +1 -1
  154. package/lib/engine-components/ContactShadows.d.ts +1 -0
  155. package/lib/engine-components/ContactShadows.js +14 -1
  156. package/lib/engine-components/ContactShadows.js.map +1 -1
  157. package/lib/engine-components/DragControls.d.ts +7 -0
  158. package/lib/engine-components/DragControls.js +19 -7
  159. package/lib/engine-components/DragControls.js.map +1 -1
  160. package/lib/engine-components/DropListener.js +4 -0
  161. package/lib/engine-components/DropListener.js.map +1 -1
  162. package/lib/engine-components/EventList.d.ts +31 -9
  163. package/lib/engine-components/EventList.js +37 -76
  164. package/lib/engine-components/EventList.js.map +1 -1
  165. package/lib/engine-components/Joints.d.ts +4 -2
  166. package/lib/engine-components/Joints.js +19 -3
  167. package/lib/engine-components/Joints.js.map +1 -1
  168. package/lib/engine-components/Light.d.ts +6 -8
  169. package/lib/engine-components/Light.js +48 -27
  170. package/lib/engine-components/Light.js.map +1 -1
  171. package/lib/engine-components/Networking.d.ts +1 -1
  172. package/lib/engine-components/Networking.js +1 -1
  173. package/lib/engine-components/OrbitControls.d.ts +1 -2
  174. package/lib/engine-components/OrbitControls.js +37 -14
  175. package/lib/engine-components/OrbitControls.js.map +1 -1
  176. package/lib/engine-components/ReflectionProbe.js +2 -0
  177. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  178. package/lib/engine-components/RigidBody.d.ts +12 -4
  179. package/lib/engine-components/RigidBody.js +18 -4
  180. package/lib/engine-components/RigidBody.js.map +1 -1
  181. package/lib/engine-components/SceneSwitcher.js +3 -0
  182. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  183. package/lib/engine-components/SeeThrough.js +2 -2
  184. package/lib/engine-components/SeeThrough.js.map +1 -1
  185. package/lib/engine-components/VideoPlayer.d.ts +8 -2
  186. package/lib/engine-components/VideoPlayer.js +42 -19
  187. package/lib/engine-components/VideoPlayer.js.map +1 -1
  188. package/lib/engine-components/Voip.d.ts +16 -7
  189. package/lib/engine-components/Voip.js +90 -53
  190. package/lib/engine-components/Voip.js.map +1 -1
  191. package/lib/engine-components/api.d.ts +3 -1
  192. package/lib/engine-components/api.js +3 -1
  193. package/lib/engine-components/api.js.map +1 -1
  194. package/lib/engine-components/codegen/components.d.ts +7 -13
  195. package/lib/engine-components/codegen/components.js +7 -13
  196. package/lib/engine-components/codegen/components.js.map +1 -1
  197. package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
  198. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  199. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  200. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  201. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  202. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  203. package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
  204. package/lib/engine-components/timeline/PlayableDirector.js +75 -67
  205. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  206. package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
  207. package/lib/engine-components/timeline/SignalAsset.js +1 -0
  208. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  209. package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
  210. package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
  211. package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
  212. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
  213. package/lib/engine-components/timeline/TimelineModels.js +3 -0
  214. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  215. package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
  216. package/lib/engine-components/timeline/TimelineTracks.js +92 -26
  217. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  218. package/lib/engine-components/timeline/index.d.ts +2 -1
  219. package/lib/engine-components/timeline/index.js +2 -0
  220. package/lib/engine-components/timeline/index.js.map +1 -1
  221. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  222. package/lib/engine-components/ui/Canvas.js +2 -8
  223. package/lib/engine-components/ui/Canvas.js.map +1 -1
  224. package/lib/engine-components/ui/Text.d.ts +1 -0
  225. package/lib/engine-components/ui/Text.js +10 -7
  226. package/lib/engine-components/ui/Text.js.map +1 -1
  227. package/lib/engine-components/web/CursorFollow.d.ts +0 -1
  228. package/lib/engine-components/web/CursorFollow.js +21 -13
  229. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  230. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +62 -1
  231. package/lib/engine-components/webxr/WebXRImageTracking.js +59 -2
  232. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  233. package/lib/needle-engine.d.ts +2 -0
  234. package/lib/needle-engine.js +2 -0
  235. package/lib/needle-engine.js.map +1 -1
  236. package/package.json +4 -84
  237. package/plugins/common/cloud.js +6 -1
  238. package/plugins/common/license.js +55 -12
  239. package/plugins/common/worker.js +9 -4
  240. package/plugins/dts-generator/dts.codegen.js +255 -50
  241. package/plugins/dts-generator/dts.scan.js +37 -9
  242. package/plugins/dts-generator/dts.writer.js +1 -1
  243. package/plugins/dts-generator/glb.discovery.js +140 -23
  244. package/plugins/dts-generator/glb.extractor.js +48 -8
  245. package/plugins/dts-generator/glb.reader.js +80 -27
  246. package/plugins/dts-generator/index.js +1 -1
  247. package/plugins/types/needle-bindings.d.ts +25 -14
  248. package/plugins/types/userconfig.d.ts +16 -1
  249. package/plugins/vite/asap.js +18 -9
  250. package/plugins/vite/build-pipeline.js +57 -20
  251. package/plugins/vite/dependencies.js +29 -10
  252. package/plugins/vite/dependency-watcher.d.ts +2 -2
  253. package/plugins/vite/dependency-watcher.js +5 -6
  254. package/plugins/vite/drop.d.ts +2 -2
  255. package/plugins/vite/drop.js +3 -4
  256. package/plugins/vite/dts-generator.d.ts +2 -2
  257. package/plugins/vite/dts-generator.js +43 -9
  258. package/plugins/vite/editor-connection.js +3 -3
  259. package/plugins/vite/index.d.ts +9 -3
  260. package/plugins/vite/index.js +23 -10
  261. package/plugins/vite/license.js +42 -7
  262. package/plugins/vite/local-files-core.js +3 -3
  263. package/plugins/vite/local-files-utils.d.ts +3 -1
  264. package/plugins/vite/local-files-utils.js +29 -5
  265. package/plugins/vite/meta.js +4 -2
  266. package/plugins/vite/poster.d.ts +2 -2
  267. package/plugins/vite/poster.js +3 -5
  268. package/plugins/vite/reload.d.ts +2 -2
  269. package/plugins/vite/reload.js +23 -23
  270. package/plugins/vite/server.js +2 -1
  271. package/src/engine/api.ts +12 -2
  272. package/src/engine/codegen/register_types.ts +10 -18
  273. package/src/engine/debug/debug_spatial_console.ts +10 -7
  274. package/src/engine/engine_addressables.ts +6 -3
  275. package/src/engine/engine_audio.ts +184 -0
  276. package/src/engine/engine_camera.fit.ts +15 -4
  277. package/src/engine/engine_components.ts +1 -1
  278. package/src/engine/engine_context.ts +85 -38
  279. package/src/engine/engine_context_eventbus.ts +73 -0
  280. package/src/engine/engine_disposable.ts +214 -0
  281. package/src/engine/engine_gameobject.ts +54 -159
  282. package/src/engine/engine_gltf_builtin_components.ts +7 -76
  283. package/src/engine/engine_init.ts +15 -1
  284. package/src/engine/engine_input.ts +28 -7
  285. package/src/engine/engine_instantiate_resolve.ts +407 -0
  286. package/src/engine/engine_license.ts +209 -61
  287. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  288. package/src/engine/engine_mainloop_utils.ts +7 -4
  289. package/src/engine/engine_networking.transport.websocket.ts +45 -0
  290. package/src/engine/engine_networking.ts +161 -137
  291. package/src/engine/engine_networking_blob.ts +4 -4
  292. package/src/engine/engine_networking_instantiate.ts +2 -2
  293. package/src/engine/engine_networking_types.ts +41 -1
  294. package/src/engine/engine_physics_rapier.ts +102 -33
  295. package/src/engine/engine_pmrem.ts +56 -6
  296. package/src/engine/engine_scenedata.ts +56 -30
  297. package/src/engine/engine_serialization_builtin_serializer.ts +64 -52
  298. package/src/engine/engine_serialization_core.ts +9 -0
  299. package/src/engine/engine_ssr.ts +29 -3
  300. package/src/engine/engine_types.ts +48 -27
  301. package/src/engine/engine_util_decorator.ts +7 -2
  302. package/src/engine/engine_utils.ts +16 -5
  303. package/src/engine/engine_utils_format.ts +20 -14
  304. package/src/engine/engine_utils_qrcode.ts +2 -2
  305. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  306. package/src/engine/webcomponents/jsx.d.ts +51 -0
  307. package/src/engine/webcomponents/logo-element.ts +1 -0
  308. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  309. package/src/engine/webcomponents/needle menu/needle-menu.ts +8 -7
  310. package/src/engine/webcomponents/needle-button.ts +1 -0
  311. package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
  312. package/src/engine/webcomponents/needle-engine.ts +13 -6
  313. package/src/engine/xr/NeedleXRSession.ts +48 -13
  314. package/src/engine/xr/TempXRContext.ts +2 -2
  315. package/src/engine/xr/events.ts +1 -1
  316. package/src/engine-components/Animation.ts +19 -16
  317. package/src/engine-components/AnimationBuilder.ts +472 -0
  318. package/src/engine-components/Animator.ts +24 -12
  319. package/src/engine-components/AnimatorController.builder.ts +387 -0
  320. package/src/engine-components/AnimatorController.ts +24 -292
  321. package/src/engine-components/AudioSource.ts +130 -79
  322. package/src/engine-components/Camera.ts +16 -3
  323. package/src/engine-components/CameraUtils.ts +12 -5
  324. package/src/engine-components/Collider.ts +66 -18
  325. package/src/engine-components/Component.ts +118 -20
  326. package/src/engine-components/ContactShadows.ts +15 -1
  327. package/src/engine-components/DragControls.ts +18 -11
  328. package/src/engine-components/DropListener.ts +4 -0
  329. package/src/engine-components/EventList.ts +45 -83
  330. package/src/engine-components/Joints.ts +20 -4
  331. package/src/engine-components/Light.ts +49 -27
  332. package/src/engine-components/Networking.ts +1 -1
  333. package/src/engine-components/OrbitControls.ts +42 -16
  334. package/src/engine-components/ReflectionProbe.ts +2 -0
  335. package/src/engine-components/RigidBody.ts +18 -4
  336. package/src/engine-components/SceneSwitcher.ts +3 -0
  337. package/src/engine-components/SeeThrough.ts +2 -2
  338. package/src/engine-components/VideoPlayer.ts +40 -17
  339. package/src/engine-components/Voip.ts +88 -53
  340. package/src/engine-components/api.ts +3 -1
  341. package/src/engine-components/codegen/components.ts +7 -13
  342. package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
  343. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  344. package/src/engine-components/timeline/PlayableDirector.ts +83 -81
  345. package/src/engine-components/timeline/SignalAsset.ts +4 -1
  346. package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
  347. package/src/engine-components/timeline/TimelineModels.ts +5 -1
  348. package/src/engine-components/timeline/TimelineTracks.ts +96 -27
  349. package/src/engine-components/timeline/index.ts +2 -1
  350. package/src/engine-components/ui/Canvas.ts +2 -8
  351. package/src/engine-components/ui/Text.ts +12 -8
  352. package/src/engine-components/web/CursorFollow.ts +21 -14
  353. package/src/engine-components/webxr/WebXRImageTracking.ts +79 -7
  354. package/src/needle-engine.ts +3 -0
  355. package/dist/needle-engine.bundle-Dq0Ly8fW.umd.cjs +0 -1732
  356. package/dist/needle-engine.bundle-YnpzzOPL.min.js +0 -1732
  357. package/lib/engine-components/AvatarLoader.d.ts +0 -80
  358. package/lib/engine-components/AvatarLoader.js +0 -232
  359. package/lib/engine-components/AvatarLoader.js.map +0 -1
  360. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
  361. package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
  362. package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
  363. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
  364. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
  365. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
  366. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
  367. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
  368. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
  369. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
  370. package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
  371. package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
  372. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
  373. package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
  374. package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
  375. package/src/engine-components/AvatarLoader.ts +0 -264
  376. package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
  377. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
  378. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
  379. package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
  380. package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
  381. package/src/vite-env.d.ts +0 -16
@@ -1,28 +1,39 @@
1
- import { dof } from "three/src/nodes/TSL.js";
2
-
3
- import { isDevEnvironment } from "./debug/index.js";
4
1
  import { BUILD_TIME, GENERATOR, PUBLIC_KEY, VERSION } from "./engine_constants.js";
5
2
  import { ContextEvent, ContextRegistry } from "./engine_context_registry.js";
6
3
  import { onInitialized } from "./engine_lifecycle_api.js";
7
4
  import { isLocalNetwork } from "./engine_networking_utils.js";
8
5
  import { Context } from "./engine_setup.js";
6
+ import { SSR } from "./engine_ssr.js";
9
7
  import type { IContext } from "./engine_types.js";
10
8
  import { getParam } from "./engine_utils.js";
11
- import { InternalAttributeUtils } from "./engine_utils_attributes.js";
12
9
 
13
- const debug = getParam("debuglicense");
10
+ const debug = getParam("__debuglic__");
14
11
 
15
- const _licenseCheckResultChangedCallbacks: ((result: boolean) => void)[] = [];
12
+ const $nNBkvau: ((result: boolean) => void)[] = [];
16
13
 
17
- // This is modified by a bundler (e.g. vite)
18
- // Do not edit manually
19
- let NEEDLE_ENGINE_LICENSE_TYPE: string = "basic";
20
- if (debug)
21
- console.log("License Type: " + NEEDLE_ENGINE_LICENSE_TYPE)
14
+ // DO NOT EDIT MANUALLY
15
+ let _Ktp: string = "";
16
+ // eslint-disable-next-line prefer-const
17
+ let _HXKeIG: string = "";
18
+
19
+ if (debug) {
20
+ console.log("License Type: " + _Ktp);
21
+ if (_HXKeIG) {
22
+ console.log("License JWT: " + _HXKeIG);
23
+ try {
24
+ const payload = JSON.parse(atob(_HXKeIG.split(".")[1].replace(/-/g, '+').replace(/_/g, '/')));
25
+ console.log("License JWT payload:", payload);
26
+ }
27
+ catch { console.log("License JWT payload: (failed to decode)"); }
28
+ }
29
+ else {
30
+ console.log("License JWT: (none)");
31
+ }
32
+ }
22
33
 
23
34
  /** @internal */
24
- export function hasProLicense() {
25
- switch (NEEDLE_ENGINE_LICENSE_TYPE) {
35
+ export function $TXm() {
36
+ switch (_Ktp) {
26
37
  case "pro":
27
38
  case "enterprise":
28
39
  return true;
@@ -31,8 +42,8 @@ export function hasProLicense() {
31
42
  }
32
43
 
33
44
  /** @internal */
34
- export function hasIndieLicense() {
35
- switch (NEEDLE_ENGINE_LICENSE_TYPE) {
45
+ export function __CYjiNy() {
46
+ switch (_Ktp) {
36
47
  case "indie":
37
48
  return true;
38
49
  }
@@ -40,8 +51,8 @@ export function hasIndieLicense() {
40
51
  }
41
52
 
42
53
  /** @internal */
43
- export function hasEduLicense() {
44
- switch (NEEDLE_ENGINE_LICENSE_TYPE) {
54
+ export function _$qXuwVrGy() {
55
+ switch (_Ktp) {
45
56
  case "edu":
46
57
  return true;
47
58
  }
@@ -49,20 +60,20 @@ export function hasEduLicense() {
49
60
  }
50
61
 
51
62
  /** @internal */
52
- export function hasCommercialLicense() {
53
- return hasProLicense() || hasIndieLicense() || hasEduLicense();
63
+ export function __gGoBKfJa() {
64
+ return $TXm() || __CYjiNy() || _$qXuwVrGy();
54
65
  }
55
66
 
56
67
 
57
68
  /** @internal */
58
- export function onLicenseCheckResultChanged(cb: (result: boolean) => void) {
59
- if (hasProLicense() || hasIndieLicense() || hasEduLicense())
69
+ export function _MFjTEBcQ(cb: (result: boolean) => void) {
70
+ if ($TXm() || __CYjiNy() || _$qXuwVrGy())
60
71
  return cb(true);
61
- _licenseCheckResultChangedCallbacks.push(cb);
72
+ $nNBkvau.push(cb);
62
73
  }
63
74
 
64
- function invokeLicenseCheckResultChanged(result: boolean) {
65
- for (const cb of _licenseCheckResultChangedCallbacks) {
75
+ function __AiHRn(result: boolean) {
76
+ for (const cb of $nNBkvau) {
66
77
  try {
67
78
  cb(result);
68
79
  }
@@ -73,6 +84,128 @@ function invokeLicenseCheckResultChanged(result: boolean) {
73
84
  }
74
85
 
75
86
 
87
+ // #region JWT
88
+
89
+ // ECDSA P-256 public key for verifying license JWTs (verification-only, safe to ship)
90
+ /* eslint-disable no-secrets/no-secrets -- public key, not a secret */
91
+ const __jOdcGEzl = {
92
+ kty: "EC",
93
+ crv: "P-256",
94
+ x: "A34nyKMjhQYVgzeE4tyLUYdx34TAKogDa7v7PRaO9Lg",
95
+ y: "JZI9IQavGCpGjEG_-pa0J-MHQYWJYINUM-MnvSu0TmE",
96
+ } as const;
97
+ /* eslint-enable no-secrets/no-secrets */
98
+
99
+ /** Base64url decode (RFC 7515) */
100
+ function base64urlDecode(str: string): Uint8Array {
101
+ const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
102
+ const padded = base64 + '='.repeat((4 - base64.length % 4) % 4);
103
+ const binary = atob(padded);
104
+ const bytes = new Uint8Array(binary.length);
105
+ for (let i = 0; i < binary.length; i++) {
106
+ bytes[i] = binary.charCodeAt(i);
107
+ }
108
+ return bytes;
109
+ }
110
+
111
+ /**
112
+ * Verify a JWT license token and return the `type` claim if valid.
113
+ * Returns null if the JWT is missing, malformed, or has an invalid signature.
114
+ */
115
+ async function __sGba(jwt: string): Promise<string | null> {
116
+ if (!jwt) return null;
117
+ try {
118
+ const parts = jwt.split(".");
119
+ if (parts.length !== 3) return null;
120
+
121
+ const [headerB64, payloadB64, signatureB64] = parts;
122
+
123
+ const key = await crypto.subtle.importKey(
124
+ "jwk",
125
+ __jOdcGEzl,
126
+ { name: "ECDSA", namedCurve: "P-256" },
127
+ false,
128
+ ["verify"]
129
+ );
130
+
131
+ const signingInput = new TextEncoder().encode(`${headerB64}.${payloadB64}`);
132
+ const signature = base64urlDecode(signatureB64);
133
+
134
+ const valid = await crypto.subtle.verify(
135
+ { name: "ECDSA", hash: "SHA-256" },
136
+ key,
137
+ signature.buffer as ArrayBuffer,
138
+ signingInput
139
+ );
140
+
141
+ if (!valid) {
142
+ if (debug) console.warn("JWT: signature verification failed");
143
+ return null;
144
+ }
145
+
146
+ const payloadStr = new TextDecoder().decode(base64urlDecode(payloadB64));
147
+ const payload = JSON.parse(payloadStr);
148
+
149
+ if (typeof payload.type !== "string" || payload.type.length === 0) {
150
+ if (debug) console.warn("JWT: missing or invalid 'type' claim");
151
+ return null;
152
+ }
153
+
154
+ // Optional: check expiration if present (future-proof — server doesn't set this yet)
155
+ if (typeof payload.exp === "number") {
156
+ const nowSeconds = Math.floor(Date.now() / 1000);
157
+ if (nowSeconds > payload.exp) {
158
+ if (debug) console.warn("JWT: token has expired (exp=" + payload.exp + ", now=" + nowSeconds + ")");
159
+ return null;
160
+ }
161
+ }
162
+
163
+ // Optional: check audience/domain if present (future-proof — server doesn't set this yet)
164
+ if (payload.aud) {
165
+ const currentHost = typeof window !== "undefined" ? window.location.hostname : undefined;
166
+ if (currentHost) {
167
+ const allowed = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
168
+ if (!allowed.some((a: string) => currentHost === a || currentHost.endsWith("." + a))) {
169
+ if (debug) console.warn("JWT: domain '" + currentHost + "' not in allowed audience: " + allowed.join(", "));
170
+ return null;
171
+ }
172
+ }
173
+ }
174
+
175
+ if (debug) console.log("JWT: verified license type: " + payload.type);
176
+ return payload.type;
177
+ }
178
+ catch (err) {
179
+ if (debug) console.error("JWT: verification error", err);
180
+ return null;
181
+ }
182
+ }
183
+
184
+ /** Verify the injected JWT and update the license type if valid.
185
+ * The engine ONLY trusts the JWT — the plain _Ktp string is ignored. */
186
+ let _jwtVerificationPromise: Promise<void> | undefined = undefined;
187
+ async function $IHlIUG(): Promise<void> {
188
+ // NOTE: do NOT add an `if (!_HXKeIG) return` guard here.
189
+ // esbuild (Vite dependency pre-bundling) would see the variable as constant ""
190
+ // and tree-shake the entire JWT verification code path.
191
+ const jwt = _HXKeIG;
192
+ // Clear after reading — this reassignment also prevents esbuild from
193
+ // constant-folding the variable (it now has multiple assignment sites).
194
+ _HXKeIG = "";
195
+ const verifiedType = await __sGba(jwt);
196
+ if (verifiedType) {
197
+ _Ktp = verifiedType;
198
+ if (debug) console.log("License type set from verified JWT: " + verifiedType);
199
+ __AiHRn(__gGoBKfJa());
200
+ }
201
+ else {
202
+ _Ktp = "basic";
203
+ if (debug && jwt) console.warn("JWT verification failed — license reset to basic");
204
+ }
205
+ }
206
+
207
+ // #endregion JWT License Verification
208
+
76
209
 
77
210
  // #region Telemetry
78
211
  export namespace Telemetry {
@@ -90,7 +223,9 @@ export namespace Telemetry {
90
223
  });
91
224
  }
92
225
 
93
- onInitialized((ctx => sendPageViewEvent(ctx)), { once: true });
226
+ export function init() {
227
+ if(!SSR) onInitialized((ctx => sendPageViewEvent(ctx)), { once: true });
228
+ }
94
229
 
95
230
  function sendPageViewEvent(ctx: IContext): Promise<void> | void {
96
231
  if (!isAllowed(ctx)) {
@@ -136,7 +271,7 @@ export namespace Telemetry {
136
271
 
137
272
  const attribute = domElement?.getAttribute("no-telemetry");
138
273
  if (attribute === "" || attribute === "true" || attribute === "1") {
139
- if (NEEDLE_ENGINE_LICENSE_TYPE === "pro" || NEEDLE_ENGINE_LICENSE_TYPE === "enterprise") {
274
+ if (_Ktp === "pro" || _Ktp === "enterprise") {
140
275
  if (debug) console.debug("Telemetry is disabled via no-telemetry attribute");
141
276
  return false;
142
277
  }
@@ -243,19 +378,32 @@ export namespace Telemetry {
243
378
  }
244
379
 
245
380
 
246
- ContextRegistry.registerCallback(ContextEvent.ContextRegistered, evt => {
247
- showLicenseInfo(evt.context);
248
- handleForbidden(evt.context);
249
- setTimeout(() => sendUsageMessageToAnalyticsBackend(evt.context), 2000);
250
- });
381
+ export function YftDqQmq() {
251
382
 
252
- export let runtimeLicenseCheckPromise: Promise<void> | undefined = undefined;
383
+ if(_Ktp === "") _Ktp = "basic";
384
+
385
+ // Start JWT verification — must be here (not top-level) to avoid tree-shaking
386
+ _jwtVerificationPromise = $IHlIUG();
387
+
388
+ Telemetry.init();
389
+ ContextRegistry.registerCallback(ContextEvent.ContextRegistered, evt => {
390
+ $zlkki(evt.context);
391
+ __sRmQXZcI(evt.context);
392
+ setTimeout(() => __QwnVOJb(evt.context), 2000);
393
+ });
394
+ }
395
+
396
+ export let $NzCTiAr: Promise<void> | undefined = undefined;
253
397
  let applicationIsForbidden = false;
254
398
  let applicationForbiddenText = "";
255
- async function checkLicense() {
399
+ async function _eUjaC() {
256
400
  // Only perform the runtime license check once
257
- if (runtimeLicenseCheckPromise) return runtimeLicenseCheckPromise;
258
- if (NEEDLE_ENGINE_LICENSE_TYPE === "basic") {
401
+ if ($NzCTiAr) return $NzCTiAr;
402
+ // Wait for JWT verification to complete first (if running)
403
+ if (_jwtVerificationPromise) {
404
+ await _jwtVerificationPromise;
405
+ }
406
+ if (_Ktp === "basic") {
259
407
  try {
260
408
  const licenseUrl = "https://needle.tools/api/v1/needle-engine/check?location=" + encodeURIComponent(window.location.href) + "&version=" + VERSION + "&generator=" + encodeURIComponent(GENERATOR);
261
409
  const res = await fetch(licenseUrl, {
@@ -267,29 +415,29 @@ async function checkLicense() {
267
415
  if (res?.status === 200) {
268
416
  applicationIsForbidden = false;
269
417
  if (debug) console.log("License check succeeded");
270
- NEEDLE_ENGINE_LICENSE_TYPE = "pro";
271
- invokeLicenseCheckResultChanged(true);
418
+ _Ktp = "pro";
419
+ __AiHRn(true);
272
420
  }
273
421
  else if (res?.status === 403) {
274
- invokeLicenseCheckResultChanged(false);
422
+ __AiHRn(false);
275
423
  applicationIsForbidden = true;
276
424
  applicationForbiddenText = await res.text();
277
425
  }
278
426
  else {
279
- invokeLicenseCheckResultChanged(false);
427
+ __AiHRn(false);
280
428
  if (debug) console.log("License check failed with status " + res?.status);
281
429
  }
282
430
  }
283
431
  catch (err) {
284
- invokeLicenseCheckResultChanged(false);
432
+ __AiHRn(false);
285
433
  if (debug) console.error("License check failed", err);
286
434
  }
287
435
  }
288
- else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" + NEEDLE_ENGINE_LICENSE_TYPE + "\"");
436
+ else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" + _Ktp + "\"");
289
437
  }
290
- runtimeLicenseCheckPromise = checkLicense();
438
+ $NzCTiAr = _eUjaC();
291
439
 
292
- async function handleForbidden(ctx: IContext) {
440
+ async function __sRmQXZcI(ctx: IContext) {
293
441
  function createForbiddenElement() {
294
442
  const div = document.createElement("div");
295
443
  div.className = "needle-forbidden";
@@ -354,40 +502,40 @@ async function handleForbidden(ctx: IContext) {
354
502
  }, 500)
355
503
  }
356
504
 
357
- async function showLicenseInfo(ctx: IContext) {
505
+ async function $zlkki(ctx: IContext) {
358
506
  try {
359
- if (!hasProLicense() && !hasIndieLicense()) {
360
- return onNonCommercialVersionDetected(ctx);
507
+ if (!$TXm() && !__CYjiNy()) {
508
+ return _$ZUnMZ(ctx);
361
509
  }
362
510
  }
363
511
  catch (err) {
364
512
  if (debug) console.log("License check failed", err)
365
- return onNonCommercialVersionDetected(ctx)
513
+ return _$ZUnMZ(ctx)
366
514
  }
367
- if (debug) onNonCommercialVersionDetected(ctx)
515
+ if (debug) _$ZUnMZ(ctx)
368
516
  }
369
517
 
370
518
 
371
519
 
372
- async function onNonCommercialVersionDetected(ctx: IContext) {
520
+ async function _$ZUnMZ(ctx: IContext) {
373
521
 
374
522
  // if the engine loads faster than the license check, we need to capture the ready event here
375
523
  let isReady = false;
376
524
  ctx.domElement.addEventListener("ready", () => isReady = true);
377
525
 
378
- await runtimeLicenseCheckPromise?.catch(() => { });
526
+ await $NzCTiAr?.catch(() => { });
379
527
 
380
528
 
381
- if (hasProLicense() || hasIndieLicense()) return;
382
- if (hasCommercialLicense() === false) logNonCommercialUse();
529
+ if ($TXm() || __CYjiNy()) return;
530
+ if (__gGoBKfJa() === false) $wrvl();
383
531
 
384
532
  // check if the engine is already ready (meaning has finished loading)
385
533
  if (isReady) {
386
- insertNonCommercialUseHint(ctx);
534
+ $fObl(ctx);
387
535
  }
388
536
  else {
389
537
  ctx.domElement.addEventListener("ready", () => {
390
- insertNonCommercialUseHint(ctx);
538
+ $fObl(ctx);
391
539
  });
392
540
  }
393
541
  }
@@ -395,7 +543,7 @@ async function onNonCommercialVersionDetected(ctx: IContext) {
395
543
  // const licenseElementIdentifier = "needle-license-element";
396
544
  // const licenseDuration = 10000;
397
545
  // const licenseDelay = 1200;
398
- function insertNonCommercialUseHint(ctx: IContext) {
546
+ function $fObl(ctx: IContext) {
399
547
 
400
548
  const style = `
401
549
  position: relative;
@@ -408,7 +556,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
408
556
  padding: 10px;
409
557
  padding-left: 30px;
410
558
  `;
411
- if (NEEDLE_ENGINE_LICENSE_TYPE === "edu") {
559
+ if (_Ktp === "edu") {
412
560
  if (navigator.webdriver) {
413
561
  console.log("This project is supported by Needle for Education – https://needle.tools");
414
562
  }
@@ -465,7 +613,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
465
613
  }
466
614
  }, 1000);
467
615
 
468
- if (hasEduLicense()) {
616
+ if (_$qXuwVrGy()) {
469
617
  const removeDelay = 20_000;
470
618
  setTimeout(() => {
471
619
  clearInterval(interval);
@@ -474,7 +622,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
474
622
  const intervalInMinutes = 5;
475
623
  setTimeout(() => {
476
624
  if (ctx.domElement.parentNode)
477
- insertNonCommercialUseHint(ctx);
625
+ $fObl(ctx);
478
626
  }, 1000 * 60 * intervalInMinutes)
479
627
  }, removeDelay);
480
628
  }
@@ -485,7 +633,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
485
633
  const base64Logo = "data:image/webp;base64,UklGRrABAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSKEAAAARN6CmbSM4WR7vdARON11EBDq3fLiNbVtVzpMCPlKAEzsx0Y/x+Ovuv4dn0EFE/ydAvz6YggXzgh5sVgXM/zOC/4sii7qgGvB5N7hmuQYwkvazWAu1JPW41FXSHq6pnaQWvqYH18Fc0j1hO/BFTtIeSBlJi5w6qIIO7IOrwhFsB2Yxukif0FTRLpXswHR8MxbslKe9VZsn/Ub5C7YFOpqSTABWUDgg6AAAAFAGAJ0BKiAAIAA+7VyoTqmkpCI3+qgBMB2JbACdMt69DwMIQBLhkTO6XwY00UEDK6cNIDnuNibPf0EgAP7Y1myuiQHLDsF/0h5unrGh6WAbv7aegg2ZMd3uRKfT/3SJztcaujYfTvMXspfCTmYcoO6a+vhC3ss4M8uM58t4siiu59I4aOl59e9Sr6xoxYlHf2v+NnBNpJYeJf8jABQAId/PXuBkLEFkiCucgSGEcfhvajql/j3reCGl0M5/9gQWy7ayNPs+wlvIxFnNfSlfuND4CZOCyxOHhRqOmHN4ULHo3tCSrUNvgAA=";
486
634
 
487
635
  let lastLogTime = 0;
488
- async function logNonCommercialUse(_logo?: string) {
636
+ async function $wrvl(_logo?: string) {
489
637
  const now = Date.now();
490
638
  if (now - lastLogTime < 2000) return;
491
639
  lastLogTime = now;
@@ -518,7 +666,7 @@ async function logNonCommercialUse(_logo?: string) {
518
666
  }
519
667
 
520
668
 
521
- async function sendUsageMessageToAnalyticsBackend(context: IContext) {
669
+ async function __QwnVOJb(context: IContext) {
522
670
  // We can't send beacons from cross-origin isolated pages
523
671
  if (window.crossOriginIsolated) return;
524
672
 
@@ -533,7 +681,7 @@ async function sendUsageMessageToAnalyticsBackend(context: IContext) {
533
681
 
534
682
  // current url without query parameters
535
683
  const currentUrl = window.location.href.split("?")[0];
536
- const license = NEEDLE_ENGINE_LICENSE_TYPE;
684
+ const license = _Ktp;
537
685
 
538
686
  const beaconData = {
539
687
  license,
@@ -1,5 +1,6 @@
1
1
  import { type Context, FrameEvent } from "./engine_context.js";
2
2
  import { ContextEvent } from "./engine_context_registry.js";
3
+ import { SSR } from "./engine_ssr.js";
3
4
 
4
5
  export declare type Event = ContextEvent | FrameEvent;
5
6
 
@@ -38,6 +39,12 @@ let methodsWarningCounter = 0;
38
39
  * @param evt the event to call the function at
39
40
  */
40
41
  export function registerFrameEventCallback(cb: LifecycleMethod, evt: Event, opts?: LifecycleMethodOptions) {
42
+
43
+ // Don't register the callback if we are in SSR, because it will never be called and might cause memory leaks
44
+ if(SSR) {
45
+ return;
46
+ }
47
+
41
48
  if (!newMethods.has(evt)) {
42
49
  newMethods.set(evt, new Array());
43
50
  }
@@ -344,8 +344,11 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: Object3D, activeInHierarc
344
344
  if (allowEventCall) {
345
345
  const components = go.userData?.components;
346
346
  if (components) {
347
- for (let ci = components.length - 1, cl = -1; ci > cl; ci--) {
348
- const comp = components[ci];
347
+ // We need to iterate on components in the original order right now to work-around UI related initialization bugs where RectTransform must be initialized before e.g. Graphic components. https://linear.app/needle/issue/NE-6986
348
+ // In the future we can reverse iterate this once the UI system has been replaced (that being said it's probably expected that component enable in the order in which they're added to an object)
349
+ const componentsCopy = [...components];
350
+ for (let ci = 0; ci < componentsCopy.length; ci++) {
351
+ const comp = componentsCopy[ci];
349
352
  if (activeInHierarchy) {
350
353
  if (comp?.enabled) {
351
354
  try { comp.__internalAwake(); }
@@ -357,8 +360,8 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: Object3D, activeInHierarc
357
360
  }
358
361
  else if(comp) {
359
362
  if (comp["__didAwake"] && comp.enabled) {
360
- comp["__didEnable"] = false;
361
- comp.onDisable();
363
+ // autoCleanup uses __internalDisable; isRemovingFromScene=true preserves __isEnabled
364
+ comp.__internalDisable(true);
362
365
  }
363
366
  }
364
367
  }
@@ -0,0 +1,45 @@
1
+ import type { INetworkTransport } from './engine_networking_types.js';
2
+
3
+ /** Default transport that wraps the `websocket-ts` library */
4
+ export class WebsocketTransport implements INetworkTransport {
5
+ private _url: string;
6
+ private _ws: import('websocket-ts').Websocket | undefined;
7
+
8
+ onOpen: (() => void) | null = null;
9
+ onClose: (() => void) | null = null;
10
+ onError: ((err: any) => void) | null = null;
11
+ onMessage: ((data: string | Blob) => void) | null = null;
12
+
13
+ get url() { return this._ws?.url ?? this._url; }
14
+
15
+ constructor(url: string) {
16
+ this._url = url;
17
+ }
18
+
19
+ async start() {
20
+ const pkg = await import('websocket-ts');
21
+ // @ts-ignore
22
+ const WebsocketBuilder = pkg.default?.WebsocketBuilder ?? pkg.WebsocketBuilder;
23
+ const ExponentialBackoff = pkg.default?.ExponentialBackoff ?? pkg.ExponentialBackoff;
24
+ const ws = new WebsocketBuilder(this._url)
25
+ .withMaxRetries(10)
26
+ .withBackoff(new ExponentialBackoff(2000, 4))
27
+ .onOpen(() => { this._ws = ws; this.onOpen?.(); })
28
+ .onClose(() => { this.onClose?.(); })
29
+ .onError(() => { this.onError?.(new Error("Websocket connection failed")); })
30
+ .onRetry(() => { console.log("Retry connecting to networking websocket"); })
31
+ .build();
32
+ ws.addEventListener(pkg.WebsocketEvent.message, (_, msg) => {
33
+ this.onMessage?.(msg.data);
34
+ });
35
+ }
36
+
37
+ send(data: string | Uint8Array) {
38
+ this._ws?.send(data);
39
+ }
40
+
41
+ close() {
42
+ this._ws?.close();
43
+ this._ws = undefined;
44
+ }
45
+ }