@relu-interactives/spatial-ecs 0.2.2

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 (308) hide show
  1. package/README.md +125 -0
  2. package/dist/System-rXAmagXA.d.cts +659 -0
  3. package/dist/System-rXAmagXA.d.ts +659 -0
  4. package/dist/Video-CDemv74U.d.cts +1261 -0
  5. package/dist/Video-ChKV1UI7.d.ts +1261 -0
  6. package/dist/assets/draco/draco_decoder.js +34 -0
  7. package/dist/assets/draco/draco_decoder.wasm +0 -0
  8. package/dist/assets/draco/draco_wasm_wrapper.js +117 -0
  9. package/dist/chunk-AYEF3X2P.js +223 -0
  10. package/dist/chunk-AYEF3X2P.js.map +1 -0
  11. package/dist/chunk-MAWBTMCG.js +1722 -0
  12. package/dist/chunk-MAWBTMCG.js.map +1 -0
  13. package/dist/chunk-NFDTIYR4.js +248 -0
  14. package/dist/chunk-NFDTIYR4.js.map +1 -0
  15. package/dist/chunk-OY7ZODZP.js +16 -0
  16. package/dist/chunk-OY7ZODZP.js.map +1 -0
  17. package/dist/chunk-P2YDX5DB.js +3304 -0
  18. package/dist/chunk-P2YDX5DB.js.map +1 -0
  19. package/dist/chunk-QHILSPT4.js +3 -0
  20. package/dist/chunk-QHILSPT4.js.map +1 -0
  21. package/dist/chunk-XWIEEJ7Z.js +1315 -0
  22. package/dist/chunk-XWIEEJ7Z.js.map +1 -0
  23. package/dist/components/index.cjs +1745 -0
  24. package/dist/components/index.cjs.map +1 -0
  25. package/dist/components/index.d.cts +4 -0
  26. package/dist/components/index.d.ts +4 -0
  27. package/dist/components/index.js +4 -0
  28. package/dist/components/index.js.map +1 -0
  29. package/dist/docs/api/Behaviour/classes/Behaviour.md +554 -0
  30. package/dist/docs/api/Behaviour/index.md +15 -0
  31. package/dist/docs/api/Component/classes/Component.md +57 -0
  32. package/dist/docs/api/Component/index.md +15 -0
  33. package/dist/docs/api/components/classes/AnimationComponent.md +318 -0
  34. package/dist/docs/api/components/classes/AudioComponent.md +114 -0
  35. package/dist/docs/api/components/classes/CameraComponent.md +59 -0
  36. package/dist/docs/api/components/classes/EntityType.md +48 -0
  37. package/dist/docs/api/components/classes/Environment.md +47 -0
  38. package/dist/docs/api/components/classes/ImageComponent.md +57 -0
  39. package/dist/docs/api/components/classes/ImageTarget.md +60 -0
  40. package/dist/docs/api/components/classes/ImageTargetAnchor.md +48 -0
  41. package/dist/docs/api/components/classes/LightComponent.md +70 -0
  42. package/dist/docs/api/components/classes/MaterialComponent.md +181 -0
  43. package/dist/docs/api/components/classes/MeshComponent.md +48 -0
  44. package/dist/docs/api/components/classes/MeshGeometryComponent.md +64 -0
  45. package/dist/docs/api/components/classes/ModelComponent.md +49 -0
  46. package/dist/docs/api/components/classes/Name.md +46 -0
  47. package/dist/docs/api/components/classes/Object3DRef.md +54 -0
  48. package/dist/docs/api/components/classes/ParentId.md +47 -0
  49. package/dist/docs/api/components/classes/PhysicsComponent.md +82 -0
  50. package/dist/docs/api/components/classes/Postprocessing.md +49 -0
  51. package/dist/docs/api/components/classes/ScriptComponent.md +54 -0
  52. package/dist/docs/api/components/classes/Selectable.md +46 -0
  53. package/dist/docs/api/components/classes/SelectionTransformState.md +54 -0
  54. package/dist/docs/api/components/classes/SpriteComponent.md +55 -0
  55. package/dist/docs/api/components/classes/TransformComponent.md +197 -0
  56. package/dist/docs/api/components/classes/VideoComponent.md +123 -0
  57. package/dist/docs/api/components/functions/normalizePhysicsState.md +23 -0
  58. package/dist/docs/api/components/index.md +94 -0
  59. package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +42 -0
  60. package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +45 -0
  61. package/dist/docs/api/components/type-aliases/CameraProjection.md +15 -0
  62. package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +15 -0
  63. package/dist/docs/api/components/type-aliases/ColliderShape.md +15 -0
  64. package/dist/docs/api/components/type-aliases/ColliderState.md +62 -0
  65. package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +27 -0
  66. package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +15 -0
  67. package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +37 -0
  68. package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +15 -0
  69. package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +15 -0
  70. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +34 -0
  71. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +15 -0
  72. package/dist/docs/api/components/type-aliases/EnvironmentState.md +29 -0
  73. package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +25 -0
  74. package/dist/docs/api/components/type-aliases/ImageTargetReference.md +33 -0
  75. package/dist/docs/api/components/type-aliases/LightValueState.md +41 -0
  76. package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +15 -0
  77. package/dist/docs/api/components/type-aliases/MaterialValueState.md +75 -0
  78. package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +13 -0
  79. package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +33 -0
  80. package/dist/docs/api/components/type-aliases/PhysicsState.md +25 -0
  81. package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +25 -0
  82. package/dist/docs/api/components/type-aliases/PostprocessingState.md +164 -0
  83. package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +25 -0
  84. package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +23 -0
  85. package/dist/docs/api/components/type-aliases/RigidbodyState.md +53 -0
  86. package/dist/docs/api/components/type-aliases/RigidbodyType.md +19 -0
  87. package/dist/docs/api/components/type-aliases/ScriptEntry.md +38 -0
  88. package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +15 -0
  89. package/dist/docs/api/components/type-aliases/TransformData.md +27 -0
  90. package/dist/docs/api/components/type-aliases/TransformModeValue.md +15 -0
  91. package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +15 -0
  92. package/dist/docs/api/components/type-aliases/Vec3.md +27 -0
  93. package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +13 -0
  94. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +13 -0
  95. package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +13 -0
  96. package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +13 -0
  97. package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +13 -0
  98. package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +13 -0
  99. package/dist/docs/api/index/classes/AnimationStateMachine.md +201 -0
  100. package/dist/docs/api/index/classes/AnimationStateManager.md +253 -0
  101. package/dist/docs/api/index/classes/AnimationSystem.md +68 -0
  102. package/dist/docs/api/index/classes/AudioSystem.md +98 -0
  103. package/dist/docs/api/index/classes/CameraSyncSystem.md +49 -0
  104. package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +75 -0
  105. package/dist/docs/api/index/classes/InputSystem.md +449 -0
  106. package/dist/docs/api/index/classes/LightSyncSystem.md +49 -0
  107. package/dist/docs/api/index/classes/MaterialSyncSystem.md +67 -0
  108. package/dist/docs/api/index/classes/MeshGeometrySystem.md +49 -0
  109. package/dist/docs/api/index/classes/ObjectManagementSystem.md +298 -0
  110. package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +49 -0
  111. package/dist/docs/api/index/classes/PhysicsSyncSystem.md +83 -0
  112. package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +80 -0
  113. package/dist/docs/api/index/classes/RenderSystem.md +64 -0
  114. package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +83 -0
  115. package/dist/docs/api/index/classes/TransformSyncSystem.md +49 -0
  116. package/dist/docs/api/index/classes/VideoSystem.md +97 -0
  117. package/dist/docs/api/index/classes/World.md +1405 -0
  118. package/dist/docs/api/index/functions/createAnimationComponent.md +28 -0
  119. package/dist/docs/api/index/functions/createAudioComponent.md +32 -0
  120. package/dist/docs/api/index/functions/createCameraComponent.md +28 -0
  121. package/dist/docs/api/index/functions/createEntityTypeComponent.md +28 -0
  122. package/dist/docs/api/index/functions/createEnvironmentComponent.md +28 -0
  123. package/dist/docs/api/index/functions/createImageComponent.md +28 -0
  124. package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +28 -0
  125. package/dist/docs/api/index/functions/createImageTargetComponent.md +28 -0
  126. package/dist/docs/api/index/functions/createLightComponent.md +28 -0
  127. package/dist/docs/api/index/functions/createMaterialComponent.md +28 -0
  128. package/dist/docs/api/index/functions/createMeshComponent.md +28 -0
  129. package/dist/docs/api/index/functions/createMeshGeometryComponent.md +28 -0
  130. package/dist/docs/api/index/functions/createModelComponent.md +28 -0
  131. package/dist/docs/api/index/functions/createNameComponent.md +28 -0
  132. package/dist/docs/api/index/functions/createObject3DRefComponent.md +28 -0
  133. package/dist/docs/api/index/functions/createParentIdComponent.md +28 -0
  134. package/dist/docs/api/index/functions/createPhysicsComponent.md +30 -0
  135. package/dist/docs/api/index/functions/createPostprocessingComponent.md +28 -0
  136. package/dist/docs/api/index/functions/createScriptComponent.md +28 -0
  137. package/dist/docs/api/index/functions/createSelectableComponent.md +28 -0
  138. package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +28 -0
  139. package/dist/docs/api/index/functions/createSpriteComponent.md +28 -0
  140. package/dist/docs/api/index/functions/createTransformComponent.md +28 -0
  141. package/dist/docs/api/index/functions/createVideoComponent.md +28 -0
  142. package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +28 -0
  143. package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +28 -0
  144. package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +23 -0
  145. package/dist/docs/api/index/functions/registerDefaultFactories.md +23 -0
  146. package/dist/docs/api/index/index.md +249 -0
  147. package/dist/docs/api/index/interfaces/EcsSystem.md +50 -0
  148. package/dist/docs/api/index/interfaces/StateMachine.md +26 -0
  149. package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +25 -0
  150. package/dist/docs/api/index/type-aliases/ComponentFactory.md +25 -0
  151. package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +37 -0
  152. package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +26 -0
  153. package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +25 -0
  154. package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +23 -0
  155. package/dist/docs/api/index/type-aliases/KeyboardKey.md +13 -0
  156. package/dist/docs/api/index/type-aliases/MouseButton.md +13 -0
  157. package/dist/docs/api/index/type-aliases/SelectionContext.md +31 -0
  158. package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +13 -0
  159. package/dist/docs/api/index/variables/KeyboardKeys.md +195 -0
  160. package/dist/docs/api/index.md +15 -0
  161. package/dist/docs/api/typedoc-sidebar.json +1 -0
  162. package/dist/docs/api/types/index.md +34 -0
  163. package/dist/docs/api/types/type-aliases/AssetInput.md +23 -0
  164. package/dist/docs/api/types/type-aliases/CheckboxInput.md +13 -0
  165. package/dist/docs/api/types/type-aliases/ColorInput.md +13 -0
  166. package/dist/docs/api/types/type-aliases/ComponentInput.md +52 -0
  167. package/dist/docs/api/types/type-aliases/ComponentKind.md +37 -0
  168. package/dist/docs/api/types/type-aliases/DropdownInput.md +23 -0
  169. package/dist/docs/api/types/type-aliases/DropdownOption.md +23 -0
  170. package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +15 -0
  171. package/dist/docs/api/types/type-aliases/EcsEntityKind.md +35 -0
  172. package/dist/docs/api/types/type-aliases/EntityId.md +16 -0
  173. package/dist/docs/api/types/type-aliases/EntityInput.md +23 -0
  174. package/dist/docs/api/types/type-aliases/FloatInput.md +13 -0
  175. package/dist/docs/api/types/type-aliases/IntersectionResult.md +29 -0
  176. package/dist/docs/api/types/type-aliases/ParentLookup.md +26 -0
  177. package/dist/docs/api/types/type-aliases/SelectionListener.md +25 -0
  178. package/dist/docs/api/types/type-aliases/SliderInput.md +27 -0
  179. package/dist/docs/api/types/type-aliases/TextInput.md +13 -0
  180. package/dist/docs/api/types/type-aliases/ToggleInput.md +13 -0
  181. package/dist/docs/api/types/type-aliases/Vec3.md +23 -0
  182. package/dist/docs/api/types/type-aliases/Vector2Input.md +23 -0
  183. package/dist/docs/api/types/type-aliases/Vector3Input.md +25 -0
  184. package/dist/docs/api/types/type-aliases/WorldEntityView.md +17 -0
  185. package/dist/docs/guide/accessing-components.md +399 -0
  186. package/dist/docs/guide/authoring-a-behaviour.md +166 -0
  187. package/dist/docs/guide/behaviour-lifecycle.md +43 -0
  188. package/dist/docs/guide/component-catalog.md +59 -0
  189. package/dist/docs/guide/components/_sidebar.json +78 -0
  190. package/dist/docs/guide/components/animation.md +171 -0
  191. package/dist/docs/guide/components/audio.md +181 -0
  192. package/dist/docs/guide/components/camera.md +179 -0
  193. package/dist/docs/guide/components/entity-type.md +141 -0
  194. package/dist/docs/guide/components/image-target-anchor.md +103 -0
  195. package/dist/docs/guide/components/image-target.md +122 -0
  196. package/dist/docs/guide/components/image.md +146 -0
  197. package/dist/docs/guide/components/light.md +157 -0
  198. package/dist/docs/guide/components/material.md +161 -0
  199. package/dist/docs/guide/components/mesh-geometry.md +153 -0
  200. package/dist/docs/guide/components/mesh.md +151 -0
  201. package/dist/docs/guide/components/model.md +96 -0
  202. package/dist/docs/guide/components/name.md +121 -0
  203. package/dist/docs/guide/components/object3d-ref.md +115 -0
  204. package/dist/docs/guide/components/parent-id.md +108 -0
  205. package/dist/docs/guide/components/physics.md +163 -0
  206. package/dist/docs/guide/components/script.md +142 -0
  207. package/dist/docs/guide/components/sprite.md +155 -0
  208. package/dist/docs/guide/components/transform.md +155 -0
  209. package/dist/docs/guide/components/video.md +153 -0
  210. package/dist/docs/guide/concepts.md +34 -0
  211. package/dist/docs/guide/getting-started/creating-objects.md +50 -0
  212. package/dist/docs/guide/getting-started/editing-objects.md +62 -0
  213. package/dist/docs/guide/getting-started/editor/assets-browser.md +55 -0
  214. package/dist/docs/guide/getting-started/editor/hierarchy.md +47 -0
  215. package/dist/docs/guide/getting-started/editor/index.md +16 -0
  216. package/dist/docs/guide/getting-started/editor/inspector.md +36 -0
  217. package/dist/docs/guide/getting-started/editor/modules.md +35 -0
  218. package/dist/docs/guide/getting-started/editor/scene-inspector.md +64 -0
  219. package/dist/docs/guide/getting-started/editor/toolbar.md +39 -0
  220. package/dist/docs/guide/getting-started/editor/viewport.md +43 -0
  221. package/dist/docs/guide/getting-started/first-launch.md +17 -0
  222. package/dist/docs/guide/getting-started/index.md +37 -0
  223. package/dist/docs/guide/getting-started/installation.md +59 -0
  224. package/dist/docs/guide/getting-started/preview-and-test.md +55 -0
  225. package/dist/docs/guide/getting-started/project-types/3d.md +30 -0
  226. package/dist/docs/guide/getting-started/project-types/ar.md +6 -0
  227. package/dist/docs/guide/getting-started/project-types/face-tracking.md +6 -0
  228. package/dist/docs/guide/getting-started/project-types/image-tracking.md +42 -0
  229. package/dist/docs/guide/getting-started/project-types/index.md +25 -0
  230. package/dist/docs/guide/getting-started/project-types/vr.md +6 -0
  231. package/dist/docs/guide/getting-started/projects.md +53 -0
  232. package/dist/docs/guide/getting-started/shortcuts.md +43 -0
  233. package/dist/docs/guide/inspector-data-binding.md +367 -0
  234. package/dist/docs/guide/reading-input.md +202 -0
  235. package/dist/docs/guide/scene/environment.md +101 -0
  236. package/dist/docs/guide/scene/index.md +36 -0
  237. package/dist/docs/guide/scene/postprocessing.md +108 -0
  238. package/dist/docs/guide/spawning/ambient-light.md +28 -0
  239. package/dist/docs/guide/spawning/area-light.md +32 -0
  240. package/dist/docs/guide/spawning/audio.md +42 -0
  241. package/dist/docs/guide/spawning/camera.md +50 -0
  242. package/dist/docs/guide/spawning/capsule.md +29 -0
  243. package/dist/docs/guide/spawning/cube.md +31 -0
  244. package/dist/docs/guide/spawning/cylinder.md +29 -0
  245. package/dist/docs/guide/spawning/directional-light.md +32 -0
  246. package/dist/docs/guide/spawning/empty.md +31 -0
  247. package/dist/docs/guide/spawning/image-target.md +48 -0
  248. package/dist/docs/guide/spawning/image.md +33 -0
  249. package/dist/docs/guide/spawning/index.md +79 -0
  250. package/dist/docs/guide/spawning/model.md +31 -0
  251. package/dist/docs/guide/spawning/plane.md +31 -0
  252. package/dist/docs/guide/spawning/point-light.md +32 -0
  253. package/dist/docs/guide/spawning/sphere.md +29 -0
  254. package/dist/docs/guide/spawning/spot-light.md +32 -0
  255. package/dist/docs/guide/spawning/sprite.md +31 -0
  256. package/dist/docs/guide/spawning/video.md +53 -0
  257. package/dist/docs/guide/system-overview.md +73 -0
  258. package/dist/docs/guide/systems/_sidebar.json +66 -0
  259. package/dist/docs/guide/systems/animation-system.md +32 -0
  260. package/dist/docs/guide/systems/audio-system.md +28 -0
  261. package/dist/docs/guide/systems/camera-sync-system.md +31 -0
  262. package/dist/docs/guide/systems/environment-sync-system.md +31 -0
  263. package/dist/docs/guide/systems/input-system.md +217 -0
  264. package/dist/docs/guide/systems/light-sync-system.md +29 -0
  265. package/dist/docs/guide/systems/material-sync-system.md +32 -0
  266. package/dist/docs/guide/systems/mesh-geometry-system.md +40 -0
  267. package/dist/docs/guide/systems/object-management-system.md +38 -0
  268. package/dist/docs/guide/systems/object-visibility-system.md +26 -0
  269. package/dist/docs/guide/systems/physics-sync-system.md +56 -0
  270. package/dist/docs/guide/systems/postprocessing-sync-system.md +43 -0
  271. package/dist/docs/guide/systems/render-system.md +22 -0
  272. package/dist/docs/guide/systems/script-behaviour-system.md +59 -0
  273. package/dist/docs/guide/systems/transform-sync-system.md +29 -0
  274. package/dist/docs/guide/systems/video-system.md +30 -0
  275. package/dist/docs/guide/world-api.md +405 -0
  276. package/dist/factories/index.cjs +3077 -0
  277. package/dist/factories/index.cjs.map +1 -0
  278. package/dist/factories/index.d.cts +69 -0
  279. package/dist/factories/index.d.ts +69 -0
  280. package/dist/factories/index.js +6 -0
  281. package/dist/factories/index.js.map +1 -0
  282. package/dist/index-B4-YyUNR.d.cts +73 -0
  283. package/dist/index-BZUOKeTO.d.ts +73 -0
  284. package/dist/index.cjs +8584 -0
  285. package/dist/index.cjs.map +1 -0
  286. package/dist/index.d.cts +283 -0
  287. package/dist/index.d.ts +283 -0
  288. package/dist/index.js +1729 -0
  289. package/dist/index.js.map +1 -0
  290. package/dist/systems/index.cjs +5119 -0
  291. package/dist/systems/index.cjs.map +1 -0
  292. package/dist/systems/index.d.cts +200 -0
  293. package/dist/systems/index.d.ts +200 -0
  294. package/dist/systems/index.js +6 -0
  295. package/dist/systems/index.js.map +1 -0
  296. package/dist/types.cjs +4 -0
  297. package/dist/types.cjs.map +1 -0
  298. package/dist/types.d.cts +3 -0
  299. package/dist/types.d.ts +3 -0
  300. package/dist/types.js +3 -0
  301. package/dist/types.js.map +1 -0
  302. package/dist/worldSnapshotUtils.cjs +259 -0
  303. package/dist/worldSnapshotUtils.cjs.map +1 -0
  304. package/dist/worldSnapshotUtils.d.cts +3 -0
  305. package/dist/worldSnapshotUtils.d.ts +3 -0
  306. package/dist/worldSnapshotUtils.js +4 -0
  307. package/dist/worldSnapshotUtils.js.map +1 -0
  308. package/package.json +80 -0
@@ -0,0 +1,259 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ // core/Component.ts
7
+ var _Component = class _Component {
8
+ };
9
+ __name(_Component, "Component");
10
+ var Component = _Component;
11
+
12
+ // core/worldSnapshotUtils.ts
13
+ var DEBUG_CHANGE_IGNORED_SYSTEMS = /* @__PURE__ */ new Set([
14
+ "OrbitCameraSystem",
15
+ "PhysicsSyncSystem"
16
+ ]);
17
+ function normalizeDebugValue(value, ctx) {
18
+ if (value === null || value === void 0) {
19
+ return value;
20
+ }
21
+ const valueType = typeof value;
22
+ if (valueType === "string" || valueType === "number" || valueType === "boolean") {
23
+ return value;
24
+ }
25
+ if (valueType === "function") {
26
+ const fn = value;
27
+ return `[Function:${fn.name || "anonymous"}]`;
28
+ }
29
+ if (value instanceof Date) {
30
+ return value.toISOString();
31
+ }
32
+ if (valueType !== "object") {
33
+ return String(value);
34
+ }
35
+ const objectValue = value;
36
+ const constructorName = objectValue.constructor?.name && objectValue.constructor.name !== "Object" ? objectValue.constructor.name : null;
37
+ if (constructorName === "AnimationClip") {
38
+ return {
39
+ __type: "AnimationClip",
40
+ name: typeof objectValue.name === "string" ? objectValue.name : ""
41
+ };
42
+ }
43
+ if (constructorName === "AnimationStateMachine") {
44
+ const clipValue = objectValue.clip && typeof objectValue.clip === "object" ? objectValue.clip : null;
45
+ return {
46
+ __type: "AnimationStateMachine",
47
+ name: typeof objectValue.name === "string" ? objectValue.name : "",
48
+ loop: Boolean(objectValue.loop),
49
+ isPlaying: Boolean(objectValue.isPlaying),
50
+ isPaused: Boolean(objectValue.isPaused),
51
+ clip: {
52
+ __type: "AnimationClip",
53
+ name: typeof clipValue?.name === "string" ? clipValue.name : ""
54
+ }
55
+ };
56
+ }
57
+ if (constructorName === "AnimationComponent") {
58
+ const clips = Array.isArray(objectValue.clips) ? objectValue.clips.map((clip) => {
59
+ if (!clip || typeof clip !== "object") {
60
+ return null;
61
+ }
62
+ const clipValue = clip;
63
+ return {
64
+ __type: "AnimationClip",
65
+ name: typeof clipValue.name === "string" ? clipValue.name : ""
66
+ };
67
+ }).filter((clip) => clip !== null) : [];
68
+ const availableClips = Array.isArray(objectValue.availableClips) ? objectValue.availableClips.filter(
69
+ (entry) => typeof entry === "string" && entry.length > 0
70
+ ) : clips.map((clip) => clip.name).filter((name) => name.length > 0);
71
+ const externalClipSources = Array.isArray(objectValue.externalClipSources) ? objectValue.externalClipSources.filter(
72
+ (entry) => typeof entry === "string" && entry.length > 0
73
+ ) : [];
74
+ const states = Array.isArray(objectValue.states) ? objectValue.states.map((state) => {
75
+ if (!state || typeof state !== "object") {
76
+ return null;
77
+ }
78
+ const stateValue = state;
79
+ const clipValue = stateValue.clip && typeof stateValue.clip === "object" ? stateValue.clip : null;
80
+ const name = typeof stateValue.name === "string" ? stateValue.name : "";
81
+ const clip = typeof clipValue?.name === "string" ? clipValue.name : "";
82
+ if (!name || !clip) {
83
+ return null;
84
+ }
85
+ return {
86
+ name,
87
+ clip,
88
+ clipId: typeof stateValue.clipId === "string" && stateValue.clipId.length > 0 ? stateValue.clipId : null,
89
+ loop: Boolean(stateValue.loop)
90
+ };
91
+ }).filter(
92
+ (state) => state !== null
93
+ ) : [];
94
+ const activeValue = objectValue.active && typeof objectValue.active === "object" ? objectValue.active : null;
95
+ const activeStateName = typeof objectValue.activeStateName === "string" ? objectValue.activeStateName : typeof activeValue?.name === "string" ? activeValue.name : null;
96
+ return {
97
+ __type: "AnimationComponent",
98
+ clips,
99
+ availableClips,
100
+ externalClipSources,
101
+ states,
102
+ activeStateName,
103
+ paused: Boolean(objectValue.paused),
104
+ reverse: Boolean(objectValue.reverse),
105
+ timeScale: typeof objectValue.timeScale === "number" && Number.isFinite(objectValue.timeScale) ? objectValue.timeScale : 1,
106
+ crossFadeDuration: typeof objectValue.crossFadeDuration === "number" && Number.isFinite(objectValue.crossFadeDuration) ? Math.max(0, objectValue.crossFadeDuration) : 0
107
+ };
108
+ }
109
+ if (constructorName === "PhysicsComponent") {
110
+ return {
111
+ __type: "PhysicsComponent",
112
+ values: normalizeDebugValue(objectValue.values, {
113
+ seen: ctx.seen,
114
+ depth: ctx.depth + 1,
115
+ maxDepth: ctx.maxDepth
116
+ })
117
+ };
118
+ }
119
+ if (constructorName === "MaterialComponent") {
120
+ return {
121
+ __type: "MaterialComponent",
122
+ values: normalizeDebugValue(objectValue.values, {
123
+ seen: ctx.seen,
124
+ depth: ctx.depth + 1,
125
+ maxDepth: ctx.maxDepth
126
+ })
127
+ };
128
+ }
129
+ if (constructorName === "VideoComponent") {
130
+ return {
131
+ __type: "VideoComponent",
132
+ path: typeof objectValue.path === "string" ? objectValue.path : "",
133
+ options: normalizeDebugValue(objectValue.options, {
134
+ seen: ctx.seen,
135
+ depth: ctx.depth + 1,
136
+ maxDepth: ctx.maxDepth
137
+ })
138
+ };
139
+ }
140
+ if (ctx.seen.has(objectValue)) {
141
+ return "[Circular]";
142
+ }
143
+ if (ctx.depth >= ctx.maxDepth) {
144
+ return constructorName ? `[MaxDepth:${constructorName}]` : "[MaxDepth:Object]";
145
+ }
146
+ if (objectValue.nodeType === 1 && typeof objectValue.tagName === "string") {
147
+ return `[HTMLElement:${String(objectValue.tagName)}]`;
148
+ }
149
+ if (objectValue.isObject3D === true) {
150
+ const position = objectValue.position;
151
+ return {
152
+ __type: "Object3D",
153
+ objectType: objectValue.type,
154
+ name: objectValue.name,
155
+ uuid: objectValue.uuid,
156
+ position: position && typeof position.x === "number" && typeof position.y === "number" && typeof position.z === "number" ? {
157
+ x: position.x,
158
+ y: position.y,
159
+ z: position.z
160
+ } : void 0
161
+ };
162
+ }
163
+ ctx.seen.add(objectValue);
164
+ const nextContext = {
165
+ seen: ctx.seen,
166
+ depth: ctx.depth + 1,
167
+ maxDepth: ctx.maxDepth
168
+ };
169
+ if (Array.isArray(objectValue)) {
170
+ return objectValue.map((item) => normalizeDebugValue(item, nextContext));
171
+ }
172
+ if (objectValue instanceof Map) {
173
+ return {
174
+ __type: "Map",
175
+ entries: [...objectValue.entries()].map(([key, mapValue]) => [
176
+ normalizeDebugValue(key, nextContext),
177
+ normalizeDebugValue(mapValue, nextContext)
178
+ ])
179
+ };
180
+ }
181
+ if (objectValue instanceof Set) {
182
+ return {
183
+ __type: "Set",
184
+ values: [...objectValue.values()].map(
185
+ (setValue) => normalizeDebugValue(setValue, nextContext)
186
+ )
187
+ };
188
+ }
189
+ const normalized = {};
190
+ const keys = Object.keys(objectValue).sort((a, b) => a.localeCompare(b));
191
+ for (const key of keys) {
192
+ normalized[key] = normalizeDebugValue(objectValue[key], nextContext);
193
+ }
194
+ return constructorName ? {
195
+ __type: constructorName,
196
+ ...normalized
197
+ } : normalized;
198
+ }
199
+ __name(normalizeDebugValue, "normalizeDebugValue");
200
+ function shouldPreserveReference(value) {
201
+ const objectValue = value;
202
+ if (objectValue.isObject3D === true) {
203
+ return true;
204
+ }
205
+ if (objectValue.nodeType === 1 && typeof objectValue.tagName === "string") {
206
+ return true;
207
+ }
208
+ return false;
209
+ }
210
+ __name(shouldPreserveReference, "shouldPreserveReference");
211
+ function cloneHistoryValue(value, seen = /* @__PURE__ */ new WeakMap()) {
212
+ if (value === null || value === void 0) {
213
+ return value;
214
+ }
215
+ const valueType = typeof value;
216
+ if (valueType === "string" || valueType === "number" || valueType === "boolean" || valueType === "bigint" || valueType === "symbol" || valueType === "function") {
217
+ return value;
218
+ }
219
+ if (value instanceof Date) {
220
+ return new Date(value.getTime());
221
+ }
222
+ if (valueType !== "object") {
223
+ return value;
224
+ }
225
+ const objectValue = value;
226
+ if (shouldPreserveReference(objectValue)) {
227
+ return value;
228
+ }
229
+ const seenValue = seen.get(objectValue);
230
+ if (seenValue !== void 0) {
231
+ return seenValue;
232
+ }
233
+ if (Array.isArray(objectValue)) {
234
+ const cloneArray = [];
235
+ seen.set(objectValue, cloneArray);
236
+ for (const item of objectValue) {
237
+ cloneArray.push(cloneHistoryValue(item, seen));
238
+ }
239
+ return cloneArray;
240
+ }
241
+ const prototype = Object.getPrototypeOf(objectValue);
242
+ const shouldCloneWithPrototype = objectValue instanceof Component || prototype === Object.prototype || prototype === null;
243
+ if (!shouldCloneWithPrototype) {
244
+ return value;
245
+ }
246
+ const cloneObject = Object.create(prototype);
247
+ seen.set(objectValue, cloneObject);
248
+ for (const key of Object.keys(objectValue)) {
249
+ cloneObject[key] = cloneHistoryValue(objectValue[key], seen);
250
+ }
251
+ return cloneObject;
252
+ }
253
+ __name(cloneHistoryValue, "cloneHistoryValue");
254
+
255
+ exports.DEBUG_CHANGE_IGNORED_SYSTEMS = DEBUG_CHANGE_IGNORED_SYSTEMS;
256
+ exports.cloneHistoryValue = cloneHistoryValue;
257
+ exports.normalizeDebugValue = normalizeDebugValue;
258
+ //# sourceMappingURL=worldSnapshotUtils.cjs.map
259
+ //# source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AAAA,EACT;AAEA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,cAAA,CAAe,WAAW,CAAA;AACnD,EAAA,MAAM,2BACJ,WAAA,YAAuB,SAAA,IACvB,SAAA,KAAc,MAAA,CAAO,aACrB,SAAA,KAAc,IAAA;AAEhB,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA;AAC3C,EAAA,IAAA,CAAK,GAAA,CAAI,aAAa,WAAW,CAAA;AAEjC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,WAAW,CAAA,EAAG;AAC1C,IAAA,WAAA,CAAY,GAAG,CAAA,GAAI,iBAAA,CAAkB,WAAA,CAAY,GAAG,GAAG,IAAI,CAAA;AAAA,EAC7D;AAEA,EAAA,OAAO,WAAA;AACT;AApEgB,MAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA","file":"worldSnapshotUtils.cjs","sourcesContent":["/**\n * Marker base class for every ECS component. Subclass `Component` to declare\n * a typed data container that systems can query.\n *\n * @remarks\n * Components own state only — runtime behaviour belongs in {@link Behaviour}\n * subclasses for user scripts. Keep fields plain (numbers, strings, vectors,\n * asset URLs).\n *\n * @category Components\n */\nexport class Component {}\n\n","import { Component } from \"./Component\";\nimport type { EntityId } from \"./types\";\n\nexport type ComponentClass<T extends Component> = new (...args: never[]) => T;\nexport type AnyComponent = Component;\n\nexport type WorldHistorySnapshot = {\n selectedEntityId: EntityId | null;\n entities: EntityId[];\n nextEntityId: number;\n components: Array<{\n componentType: ComponentClass<AnyComponent>;\n entries: Array<{\n entityId: EntityId;\n component: AnyComponent;\n }>;\n }>;\n};\n\nexport const DEBUG_CHANGE_IGNORED_SYSTEMS = new Set<string>([\n \"OrbitCameraSystem\",\n \"PhysicsSyncSystem\",\n]);\n\ntype NormalizeContext = {\n seen: WeakSet<object>;\n depth: number;\n maxDepth: number;\n};\n\nexport function normalizeDebugValue(\n value: unknown,\n ctx: NormalizeContext,\n): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n\n const valueType = typeof value;\n if (\n valueType === \"string\" ||\n valueType === \"number\" ||\n valueType === \"boolean\"\n ) {\n return value;\n }\n\n if (valueType === \"function\") {\n const fn = value as (...args: unknown[]) => unknown;\n return `[Function:${fn.name || \"anonymous\"}]`;\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (valueType !== \"object\") {\n return String(value);\n }\n\n const objectValue = value as Record<string, unknown>;\n\n const constructorName =\n objectValue.constructor?.name && objectValue.constructor.name !== \"Object\"\n ? objectValue.constructor.name\n : null;\n\n if (constructorName === \"AnimationClip\") {\n return {\n __type: \"AnimationClip\",\n name: typeof objectValue.name === \"string\" ? objectValue.name : \"\",\n };\n }\n\n if (constructorName === \"AnimationStateMachine\") {\n const clipValue =\n objectValue.clip && typeof objectValue.clip === \"object\"\n ? (objectValue.clip as Record<string, unknown>)\n : null;\n\n return {\n __type: \"AnimationStateMachine\",\n name: typeof objectValue.name === \"string\" ? objectValue.name : \"\",\n loop: Boolean(objectValue.loop),\n isPlaying: Boolean(objectValue.isPlaying),\n isPaused: Boolean(objectValue.isPaused),\n clip: {\n __type: \"AnimationClip\",\n name: typeof clipValue?.name === \"string\" ? clipValue.name : \"\",\n },\n };\n }\n\n if (constructorName === \"AnimationComponent\") {\n const clips = Array.isArray(objectValue.clips)\n ? objectValue.clips\n .map((clip) => {\n if (!clip || typeof clip !== \"object\") {\n return null;\n }\n\n const clipValue = clip as Record<string, unknown>;\n return {\n __type: \"AnimationClip\",\n name: typeof clipValue.name === \"string\" ? clipValue.name : \"\",\n };\n })\n .filter((clip): clip is { __type: \"AnimationClip\"; name: string } => clip !== null)\n : [];\n\n const availableClips = Array.isArray(objectValue.availableClips)\n ? objectValue.availableClips.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n )\n : clips.map((clip) => clip.name).filter((name) => name.length > 0);\n\n const externalClipSources = Array.isArray(objectValue.externalClipSources)\n ? objectValue.externalClipSources.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n )\n : [];\n\n const states = Array.isArray(objectValue.states)\n ? objectValue.states\n .map((state) => {\n if (!state || typeof state !== \"object\") {\n return null;\n }\n\n const stateValue = state as Record<string, unknown>;\n const clipValue =\n stateValue.clip && typeof stateValue.clip === \"object\"\n ? (stateValue.clip as Record<string, unknown>)\n : null;\n\n const name = typeof stateValue.name === \"string\" ? stateValue.name : \"\";\n const clip = typeof clipValue?.name === \"string\" ? clipValue.name : \"\";\n if (!name || !clip) {\n return null;\n }\n\n return {\n name,\n clip,\n clipId:\n typeof stateValue.clipId === \"string\" && stateValue.clipId.length > 0\n ? stateValue.clipId\n : null,\n loop: Boolean(stateValue.loop),\n };\n })\n .filter(\n (\n state,\n ): state is {\n name: string;\n clip: string;\n clipId: string | null;\n loop: boolean;\n } => state !== null,\n )\n : [];\n\n const activeValue =\n objectValue.active && typeof objectValue.active === \"object\"\n ? (objectValue.active as Record<string, unknown>)\n : null;\n\n const activeStateName =\n typeof objectValue.activeStateName === \"string\"\n ? objectValue.activeStateName\n : typeof activeValue?.name === \"string\"\n ? activeValue.name\n : null;\n\n return {\n __type: \"AnimationComponent\",\n clips,\n availableClips,\n externalClipSources,\n states,\n activeStateName,\n paused: Boolean(objectValue.paused),\n reverse: Boolean(objectValue.reverse),\n timeScale:\n typeof objectValue.timeScale === \"number\" && Number.isFinite(objectValue.timeScale)\n ? objectValue.timeScale\n : 1,\n crossFadeDuration:\n typeof objectValue.crossFadeDuration === \"number\" &&\n Number.isFinite(objectValue.crossFadeDuration)\n ? Math.max(0, objectValue.crossFadeDuration)\n : 0,\n };\n }\n\n if (constructorName === \"PhysicsComponent\") {\n // Only serialize the authoring `values` state. The live `rigidBody` and\n // `collider` Rapier references change every physics frame and must not\n // be included in the debug snapshot, otherwise the WorldChangeDetection-\n // System would detect a change every frame and flood the undo history.\n return {\n __type: \"PhysicsComponent\",\n values: normalizeDebugValue(objectValue.values, {\n seen: ctx.seen,\n depth: ctx.depth + 1,\n maxDepth: ctx.maxDepth,\n }),\n };\n }\n\n if (constructorName === \"MaterialComponent\") {\n // Only serialize the authoring `values` state. The live Three.js\n // `material` / `materials` objects mutate after transparency is toggled\n // (shader recompilation flags, `needsUpdate`, etc.) and must not be\n // included in the debug snapshot — doing so causes the\n // WorldChangeDetectionSystem to detect a spurious change every frame.\n return {\n __type: \"MaterialComponent\",\n values: normalizeDebugValue(objectValue.values, {\n seen: ctx.seen,\n depth: ctx.depth + 1,\n maxDepth: ctx.maxDepth,\n }),\n };\n }\n\n if (constructorName === \"VideoComponent\") {\n // Only serialize `path` and `options`. The live runtime fields\n // (`object`, `videoElement`, `texture`, `material`, `audioNode`) change\n // during video load/playback and must not be included in the debug\n // snapshot — doing so causes WorldChangeDetectionSystem to detect a\n // spurious change on every frame while a video is loading or playing.\n return {\n __type: \"VideoComponent\",\n path: typeof objectValue.path === \"string\" ? objectValue.path : \"\",\n options: normalizeDebugValue(objectValue.options, {\n seen: ctx.seen,\n depth: ctx.depth + 1,\n maxDepth: ctx.maxDepth,\n }),\n };\n }\n\n if (ctx.seen.has(objectValue)) {\n return \"[Circular]\";\n }\n\n if (ctx.depth >= ctx.maxDepth) {\n return constructorName\n ? `[MaxDepth:${constructorName}]`\n : \"[MaxDepth:Object]\";\n }\n\n if (objectValue.nodeType === 1 && typeof objectValue.tagName === \"string\") {\n return `[HTMLElement:${String(objectValue.tagName)}]`;\n }\n\n if (objectValue.isObject3D === true) {\n const position = objectValue.position as\n | { x?: number; y?: number; z?: number }\n | undefined;\n\n return {\n __type: \"Object3D\",\n objectType: objectValue.type,\n name: objectValue.name,\n uuid: objectValue.uuid,\n position:\n position &&\n typeof position.x === \"number\" &&\n typeof position.y === \"number\" &&\n typeof position.z === \"number\"\n ? {\n x: position.x,\n y: position.y,\n z: position.z,\n }\n : undefined,\n };\n }\n\n ctx.seen.add(objectValue);\n const nextContext: NormalizeContext = {\n seen: ctx.seen,\n depth: ctx.depth + 1,\n maxDepth: ctx.maxDepth,\n };\n\n if (Array.isArray(objectValue)) {\n return objectValue.map((item) => normalizeDebugValue(item, nextContext));\n }\n\n if (objectValue instanceof Map) {\n return {\n __type: \"Map\",\n entries: [...objectValue.entries()].map(([key, mapValue]) => [\n normalizeDebugValue(key, nextContext),\n normalizeDebugValue(mapValue, nextContext),\n ]),\n };\n }\n\n if (objectValue instanceof Set) {\n return {\n __type: \"Set\",\n values: [...objectValue.values()].map((setValue) =>\n normalizeDebugValue(setValue, nextContext),\n ),\n };\n }\n\n const normalized: Record<string, unknown> = {};\n const keys = Object.keys(objectValue).sort((a, b) => a.localeCompare(b));\n for (const key of keys) {\n normalized[key] = normalizeDebugValue(objectValue[key], nextContext);\n }\n\n return constructorName\n ? {\n __type: constructorName,\n ...normalized,\n }\n : normalized;\n}\n\nfunction shouldPreserveReference(value: object): boolean {\n const objectValue = value as Record<string, unknown>;\n\n if (objectValue.isObject3D === true) {\n return true;\n }\n\n if (objectValue.nodeType === 1 && typeof objectValue.tagName === \"string\") {\n return true;\n }\n\n return false;\n}\n\nexport function cloneHistoryValue<T>(\n value: T,\n seen: WeakMap<object, unknown> = new WeakMap<object, unknown>(),\n): T {\n if (value === null || value === undefined) {\n return value;\n }\n\n const valueType = typeof value;\n if (\n valueType === \"string\" ||\n valueType === \"number\" ||\n valueType === \"boolean\" ||\n valueType === \"bigint\" ||\n valueType === \"symbol\" ||\n valueType === \"function\"\n ) {\n return value;\n }\n\n if (value instanceof Date) {\n return new Date(value.getTime()) as T;\n }\n\n if (valueType !== \"object\") {\n return value;\n }\n\n const objectValue = value as Record<string, unknown>;\n\n if (shouldPreserveReference(objectValue)) {\n return value;\n }\n\n const seenValue = seen.get(objectValue);\n if (seenValue !== undefined) {\n return seenValue as T;\n }\n\n if (Array.isArray(objectValue)) {\n const cloneArray: unknown[] = [];\n seen.set(objectValue, cloneArray);\n\n for (const item of objectValue) {\n cloneArray.push(cloneHistoryValue(item, seen));\n }\n\n return cloneArray as T;\n }\n\n const prototype = Object.getPrototypeOf(objectValue);\n const shouldCloneWithPrototype =\n objectValue instanceof Component ||\n prototype === Object.prototype ||\n prototype === null;\n\n if (!shouldCloneWithPrototype) {\n return value;\n }\n\n const cloneObject = Object.create(prototype) as Record<string, unknown>;\n seen.set(objectValue, cloneObject);\n\n for (const key of Object.keys(objectValue)) {\n cloneObject[key] = cloneHistoryValue(objectValue[key], seen);\n }\n\n return cloneObject as T;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export { y as AnyComponent, c as ComponentClass, z as DEBUG_CHANGE_IGNORED_SYSTEMS, B as WorldHistorySnapshot, G as cloneHistoryValue, H as normalizeDebugValue } from './System-rXAmagXA.cjs';
2
+ import 'three';
3
+ import '@dimforge/rapier3d-compat';
@@ -0,0 +1,3 @@
1
+ export { y as AnyComponent, c as ComponentClass, z as DEBUG_CHANGE_IGNORED_SYSTEMS, B as WorldHistorySnapshot, G as cloneHistoryValue, H as normalizeDebugValue } from './System-rXAmagXA.js';
2
+ import 'three';
3
+ import '@dimforge/rapier3d-compat';
@@ -0,0 +1,4 @@
1
+ export { DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue, normalizeDebugValue } from './chunk-NFDTIYR4.js';
2
+ import './chunk-OY7ZODZP.js';
3
+ //# sourceMappingURL=worldSnapshotUtils.js.map
4
+ //# sourceMappingURL=worldSnapshotUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"worldSnapshotUtils.js"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@relu-interactives/spatial-ecs",
3
+ "version": "0.2.2",
4
+ "description": "Reusable ECS core engine for Relu Spatial editor and runtime experiences.",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/",
9
+ "access": "public"
10
+ },
11
+ "type": "module",
12
+ "main": "dist/index.cjs",
13
+ "module": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs"
20
+ },
21
+ "./components": {
22
+ "types": "./dist/components/index.d.ts",
23
+ "import": "./dist/components/index.js",
24
+ "require": "./dist/components/index.cjs"
25
+ },
26
+ "./systems": {
27
+ "types": "./dist/systems/index.d.ts",
28
+ "import": "./dist/systems/index.js",
29
+ "require": "./dist/systems/index.cjs"
30
+ },
31
+ "./factories": {
32
+ "types": "./dist/factories/index.d.ts",
33
+ "import": "./dist/factories/index.js",
34
+ "require": "./dist/factories/index.cjs"
35
+ },
36
+ "./types": {
37
+ "types": "./dist/types.d.ts",
38
+ "import": "./dist/types.js",
39
+ "require": "./dist/types.cjs"
40
+ },
41
+ "./worldSnapshotUtils": {
42
+ "types": "./dist/worldSnapshotUtils.d.ts",
43
+ "import": "./dist/worldSnapshotUtils.js",
44
+ "require": "./dist/worldSnapshotUtils.cjs"
45
+ }
46
+ },
47
+ "files": [
48
+ "dist"
49
+ ],
50
+ "sideEffects": false,
51
+ "scripts": {
52
+ "build": "tsup --config tsup.config.ts && node scripts/copy-assets.mjs && node scripts/copy-docs.mjs",
53
+ "dev": "tsup --config tsup.config.ts --watch",
54
+ "typecheck": "tsc --noEmit",
55
+ "clean": "rm -rf dist",
56
+ "docs:generate": "typedoc && node scripts/generate-component-guides.mjs",
57
+ "docs:dev": "pnpm docs:generate && vitepress dev docs",
58
+ "docs:build": "pnpm docs:generate && vitepress build docs",
59
+ "docs:preview": "vitepress preview docs",
60
+ "release:patch": "npm version patch",
61
+ "release:minor": "npm version minor",
62
+ "release:major": "npm version major"
63
+ },
64
+ "peerDependencies": {
65
+ "three": "^0.165.0"
66
+ },
67
+ "dependencies": {
68
+ "@dimforge/rapier3d-compat": "^0.17.3"
69
+ },
70
+ "devDependencies": {
71
+ "@types/three": "^0.165.0",
72
+ "three": "^0.165.0",
73
+ "tsup": "^8.5.0",
74
+ "typedoc": "^0.28.19",
75
+ "typedoc-plugin-markdown": "^4.11.0",
76
+ "typedoc-vitepress-theme": "^1.1.2",
77
+ "typescript": "^5.9.2",
78
+ "vitepress": "^1.6.4"
79
+ }
80
+ }