@esengine/ecs-framework 2.3.0 → 2.3.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 (490) hide show
  1. package/index.cjs +2 -0
  2. package/index.cjs.map +1 -0
  3. package/index.d.ts +13466 -0
  4. package/index.es5.js +4 -0
  5. package/index.es5.js.map +1 -0
  6. package/index.mjs +2 -0
  7. package/index.mjs.map +1 -0
  8. package/index.umd.js +4 -0
  9. package/index.umd.js.map +1 -0
  10. package/package.json +47 -84
  11. package/bin/Core/DI/Decorators.d.ts +0 -206
  12. package/bin/Core/DI/Decorators.d.ts.map +0 -1
  13. package/bin/Core/DI/Decorators.js +0 -253
  14. package/bin/Core/DI/Decorators.js.map +0 -1
  15. package/bin/Core/DI/index.d.ts +0 -8
  16. package/bin/Core/DI/index.d.ts.map +0 -1
  17. package/bin/Core/DI/index.js +0 -7
  18. package/bin/Core/DI/index.js.map +0 -1
  19. package/bin/Core/Plugin.d.ts +0 -112
  20. package/bin/Core/Plugin.d.ts.map +0 -1
  21. package/bin/Core/Plugin.js +0 -19
  22. package/bin/Core/Plugin.js.map +0 -1
  23. package/bin/Core/PluginManager.d.ts +0 -118
  24. package/bin/Core/PluginManager.d.ts.map +0 -1
  25. package/bin/Core/PluginManager.js +0 -229
  26. package/bin/Core/PluginManager.js.map +0 -1
  27. package/bin/Core/ServiceContainer.d.ts +0 -221
  28. package/bin/Core/ServiceContainer.d.ts.map +0 -1
  29. package/bin/Core/ServiceContainer.js +0 -352
  30. package/bin/Core/ServiceContainer.js.map +0 -1
  31. package/bin/Core.d.ts +0 -379
  32. package/bin/Core.d.ts.map +0 -1
  33. package/bin/Core.js +0 -553
  34. package/bin/Core.js.map +0 -1
  35. package/bin/ECS/Component.d.ts +0 -104
  36. package/bin/ECS/Component.d.ts.map +0 -1
  37. package/bin/ECS/Component.js +0 -105
  38. package/bin/ECS/Component.js.map +0 -1
  39. package/bin/ECS/Components/HierarchyComponent.d.ts +0 -46
  40. package/bin/ECS/Components/HierarchyComponent.d.ts.map +0 -1
  41. package/bin/ECS/Components/HierarchyComponent.js +0 -65
  42. package/bin/ECS/Components/HierarchyComponent.js.map +0 -1
  43. package/bin/ECS/Components/index.d.ts +0 -2
  44. package/bin/ECS/Components/index.d.ts.map +0 -1
  45. package/bin/ECS/Components/index.js +0 -2
  46. package/bin/ECS/Components/index.js.map +0 -1
  47. package/bin/ECS/Core/ArchetypeSystem.d.ts +0 -103
  48. package/bin/ECS/Core/ArchetypeSystem.d.ts.map +0 -1
  49. package/bin/ECS/Core/ArchetypeSystem.js +0 -244
  50. package/bin/ECS/Core/ArchetypeSystem.js.map +0 -1
  51. package/bin/ECS/Core/CommandBuffer.d.ts +0 -154
  52. package/bin/ECS/Core/CommandBuffer.d.ts.map +0 -1
  53. package/bin/ECS/Core/CommandBuffer.js +0 -244
  54. package/bin/ECS/Core/CommandBuffer.js.map +0 -1
  55. package/bin/ECS/Core/ComponentPool.d.ts +0 -139
  56. package/bin/ECS/Core/ComponentPool.d.ts.map +0 -1
  57. package/bin/ECS/Core/ComponentPool.js +0 -276
  58. package/bin/ECS/Core/ComponentPool.js.map +0 -1
  59. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +0 -127
  60. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +0 -1
  61. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +0 -235
  62. package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +0 -1
  63. package/bin/ECS/Core/ComponentStorage.d.ts +0 -185
  64. package/bin/ECS/Core/ComponentStorage.d.ts.map +0 -1
  65. package/bin/ECS/Core/ComponentStorage.js +0 -321
  66. package/bin/ECS/Core/ComponentStorage.js.map +0 -1
  67. package/bin/ECS/Core/EntityLifecyclePolicy.d.ts +0 -26
  68. package/bin/ECS/Core/EntityLifecyclePolicy.d.ts.map +0 -1
  69. package/bin/ECS/Core/EntityLifecyclePolicy.js +0 -2
  70. package/bin/ECS/Core/EntityLifecyclePolicy.js.map +0 -1
  71. package/bin/ECS/Core/EventBus.d.ts +0 -210
  72. package/bin/ECS/Core/EventBus.d.ts.map +0 -1
  73. package/bin/ECS/Core/EventBus.js +0 -370
  74. package/bin/ECS/Core/EventBus.js.map +0 -1
  75. package/bin/ECS/Core/EventSystem.d.ts +0 -225
  76. package/bin/ECS/Core/EventSystem.d.ts.map +0 -1
  77. package/bin/ECS/Core/EventSystem.js +0 -448
  78. package/bin/ECS/Core/EventSystem.js.map +0 -1
  79. package/bin/ECS/Core/Events/index.d.ts +0 -3
  80. package/bin/ECS/Core/Events/index.d.ts.map +0 -1
  81. package/bin/ECS/Core/Events/index.js +0 -3
  82. package/bin/ECS/Core/Events/index.js.map +0 -1
  83. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +0 -35
  84. package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +0 -1
  85. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +0 -48
  86. package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +0 -1
  87. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +0 -135
  88. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +0 -1
  89. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +0 -166
  90. package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +0 -1
  91. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +0 -58
  92. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +0 -1
  93. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +0 -85
  94. package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +0 -1
  95. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +0 -110
  96. package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +0 -1
  97. package/bin/ECS/Core/FluentAPI/EntityBuilder.js +0 -181
  98. package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +0 -1
  99. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +0 -53
  100. package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +0 -1
  101. package/bin/ECS/Core/FluentAPI/SceneBuilder.js +0 -79
  102. package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +0 -1
  103. package/bin/ECS/Core/FluentAPI/index.d.ts +0 -6
  104. package/bin/ECS/Core/FluentAPI/index.d.ts.map +0 -1
  105. package/bin/ECS/Core/FluentAPI/index.js +0 -6
  106. package/bin/ECS/Core/FluentAPI/index.js.map +0 -1
  107. package/bin/ECS/Core/FluentAPI.d.ts +0 -2
  108. package/bin/ECS/Core/FluentAPI.d.ts.map +0 -1
  109. package/bin/ECS/Core/FluentAPI.js +0 -3
  110. package/bin/ECS/Core/FluentAPI.js.map +0 -1
  111. package/bin/ECS/Core/Query/TypedQuery.d.ts +0 -214
  112. package/bin/ECS/Core/Query/TypedQuery.d.ts.map +0 -1
  113. package/bin/ECS/Core/Query/TypedQuery.js +0 -294
  114. package/bin/ECS/Core/Query/TypedQuery.js.map +0 -1
  115. package/bin/ECS/Core/Query/index.d.ts +0 -3
  116. package/bin/ECS/Core/Query/index.d.ts.map +0 -1
  117. package/bin/ECS/Core/Query/index.js +0 -3
  118. package/bin/ECS/Core/Query/index.js.map +0 -1
  119. package/bin/ECS/Core/QuerySystem.d.ts +0 -458
  120. package/bin/ECS/Core/QuerySystem.d.ts.map +0 -1
  121. package/bin/ECS/Core/QuerySystem.js +0 -1069
  122. package/bin/ECS/Core/QuerySystem.js.map +0 -1
  123. package/bin/ECS/Core/QueryTypes.d.ts +0 -34
  124. package/bin/ECS/Core/QueryTypes.d.ts.map +0 -1
  125. package/bin/ECS/Core/QueryTypes.js +0 -13
  126. package/bin/ECS/Core/QueryTypes.js.map +0 -1
  127. package/bin/ECS/Core/ReactiveQuery.d.ts +0 -211
  128. package/bin/ECS/Core/ReactiveQuery.d.ts.map +0 -1
  129. package/bin/ECS/Core/ReactiveQuery.js +0 -401
  130. package/bin/ECS/Core/ReactiveQuery.js.map +0 -1
  131. package/bin/ECS/Core/ReferenceTracker.d.ts +0 -111
  132. package/bin/ECS/Core/ReferenceTracker.d.ts.map +0 -1
  133. package/bin/ECS/Core/ReferenceTracker.js +0 -254
  134. package/bin/ECS/Core/ReferenceTracker.js.map +0 -1
  135. package/bin/ECS/Core/SoASerializer.d.ts +0 -28
  136. package/bin/ECS/Core/SoASerializer.d.ts.map +0 -1
  137. package/bin/ECS/Core/SoASerializer.js +0 -85
  138. package/bin/ECS/Core/SoASerializer.js.map +0 -1
  139. package/bin/ECS/Core/SoAStorage.d.ts +0 -129
  140. package/bin/ECS/Core/SoAStorage.d.ts.map +0 -1
  141. package/bin/ECS/Core/SoAStorage.js +0 -685
  142. package/bin/ECS/Core/SoAStorage.js.map +0 -1
  143. package/bin/ECS/Core/SoATypeRegistry.d.ts +0 -50
  144. package/bin/ECS/Core/SoATypeRegistry.d.ts.map +0 -1
  145. package/bin/ECS/Core/SoATypeRegistry.js +0 -135
  146. package/bin/ECS/Core/SoATypeRegistry.js.map +0 -1
  147. package/bin/ECS/Core/Storage/index.d.ts +0 -4
  148. package/bin/ECS/Core/Storage/index.d.ts.map +0 -1
  149. package/bin/ECS/Core/Storage/index.js +0 -4
  150. package/bin/ECS/Core/Storage/index.js.map +0 -1
  151. package/bin/ECS/Core/StorageDecorators.d.ts +0 -20
  152. package/bin/ECS/Core/StorageDecorators.d.ts.map +0 -1
  153. package/bin/ECS/Core/StorageDecorators.js +0 -27
  154. package/bin/ECS/Core/StorageDecorators.js.map +0 -1
  155. package/bin/ECS/CoreEvents.d.ts +0 -131
  156. package/bin/ECS/CoreEvents.d.ts.map +0 -1
  157. package/bin/ECS/CoreEvents.js +0 -163
  158. package/bin/ECS/CoreEvents.js.map +0 -1
  159. package/bin/ECS/Decorators/EntityRefDecorator.d.ts +0 -46
  160. package/bin/ECS/Decorators/EntityRefDecorator.d.ts.map +0 -1
  161. package/bin/ECS/Decorators/EntityRefDecorator.js +0 -118
  162. package/bin/ECS/Decorators/EntityRefDecorator.js.map +0 -1
  163. package/bin/ECS/Decorators/PropertyDecorator.d.ts +0 -168
  164. package/bin/ECS/Decorators/PropertyDecorator.d.ts.map +0 -1
  165. package/bin/ECS/Decorators/PropertyDecorator.js +0 -40
  166. package/bin/ECS/Decorators/PropertyDecorator.js.map +0 -1
  167. package/bin/ECS/Decorators/TypeDecorators.d.ts +0 -124
  168. package/bin/ECS/Decorators/TypeDecorators.d.ts.map +0 -1
  169. package/bin/ECS/Decorators/TypeDecorators.js +0 -151
  170. package/bin/ECS/Decorators/TypeDecorators.js.map +0 -1
  171. package/bin/ECS/Decorators/index.d.ts +0 -7
  172. package/bin/ECS/Decorators/index.d.ts.map +0 -1
  173. package/bin/ECS/Decorators/index.js +0 -4
  174. package/bin/ECS/Decorators/index.js.map +0 -1
  175. package/bin/ECS/Entity.d.ts +0 -415
  176. package/bin/ECS/Entity.d.ts.map +0 -1
  177. package/bin/ECS/Entity.js +0 -683
  178. package/bin/ECS/Entity.js.map +0 -1
  179. package/bin/ECS/EntityTags.d.ts +0 -71
  180. package/bin/ECS/EntityTags.d.ts.map +0 -1
  181. package/bin/ECS/EntityTags.js +0 -82
  182. package/bin/ECS/EntityTags.js.map +0 -1
  183. package/bin/ECS/IScene.d.ts +0 -308
  184. package/bin/ECS/IScene.d.ts.map +0 -1
  185. package/bin/ECS/IScene.js +0 -2
  186. package/bin/ECS/IScene.js.map +0 -1
  187. package/bin/ECS/Scene.d.ts +0 -799
  188. package/bin/ECS/Scene.d.ts.map +0 -1
  189. package/bin/ECS/Scene.js +0 -1203
  190. package/bin/ECS/Scene.js.map +0 -1
  191. package/bin/ECS/SceneManager.d.ts +0 -197
  192. package/bin/ECS/SceneManager.d.ts.map +0 -1
  193. package/bin/ECS/SceneManager.js +0 -264
  194. package/bin/ECS/SceneManager.js.map +0 -1
  195. package/bin/ECS/Serialization/ComponentSerializer.d.ts +0 -106
  196. package/bin/ECS/Serialization/ComponentSerializer.d.ts.map +0 -1
  197. package/bin/ECS/Serialization/ComponentSerializer.js +0 -251
  198. package/bin/ECS/Serialization/ComponentSerializer.js.map +0 -1
  199. package/bin/ECS/Serialization/EntitySerializer.d.ts +0 -111
  200. package/bin/ECS/Serialization/EntitySerializer.d.ts.map +0 -1
  201. package/bin/ECS/Serialization/EntitySerializer.js +0 -155
  202. package/bin/ECS/Serialization/EntitySerializer.js.map +0 -1
  203. package/bin/ECS/Serialization/IncrementalSerializer.d.ts +0 -259
  204. package/bin/ECS/Serialization/IncrementalSerializer.d.ts.map +0 -1
  205. package/bin/ECS/Serialization/IncrementalSerializer.js +0 -500
  206. package/bin/ECS/Serialization/IncrementalSerializer.js.map +0 -1
  207. package/bin/ECS/Serialization/SceneSerializer.d.ts +0 -213
  208. package/bin/ECS/Serialization/SceneSerializer.d.ts.map +0 -1
  209. package/bin/ECS/Serialization/SceneSerializer.js +0 -387
  210. package/bin/ECS/Serialization/SceneSerializer.js.map +0 -1
  211. package/bin/ECS/Serialization/SerializationDecorators.d.ts +0 -136
  212. package/bin/ECS/Serialization/SerializationDecorators.d.ts.map +0 -1
  213. package/bin/ECS/Serialization/SerializationDecorators.js +0 -216
  214. package/bin/ECS/Serialization/SerializationDecorators.js.map +0 -1
  215. package/bin/ECS/Serialization/VersionMigration.d.ts +0 -156
  216. package/bin/ECS/Serialization/VersionMigration.d.ts.map +0 -1
  217. package/bin/ECS/Serialization/VersionMigration.js +0 -279
  218. package/bin/ECS/Serialization/VersionMigration.js.map +0 -1
  219. package/bin/ECS/Serialization/index.d.ts +0 -18
  220. package/bin/ECS/Serialization/index.d.ts.map +0 -1
  221. package/bin/ECS/Serialization/index.js +0 -18
  222. package/bin/ECS/Serialization/index.js.map +0 -1
  223. package/bin/ECS/Systems/EntityCache.d.ts +0 -114
  224. package/bin/ECS/Systems/EntityCache.d.ts.map +0 -1
  225. package/bin/ECS/Systems/EntityCache.js +0 -145
  226. package/bin/ECS/Systems/EntityCache.js.map +0 -1
  227. package/bin/ECS/Systems/EntitySystem.d.ts +0 -591
  228. package/bin/ECS/Systems/EntitySystem.d.ts.map +0 -1
  229. package/bin/ECS/Systems/EntitySystem.js +0 -1102
  230. package/bin/ECS/Systems/EntitySystem.js.map +0 -1
  231. package/bin/ECS/Systems/HierarchySystem.d.ts +0 -155
  232. package/bin/ECS/Systems/HierarchySystem.d.ts.map +0 -1
  233. package/bin/ECS/Systems/HierarchySystem.js +0 -498
  234. package/bin/ECS/Systems/HierarchySystem.js.map +0 -1
  235. package/bin/ECS/Systems/IntervalSystem.d.ts +0 -33
  236. package/bin/ECS/Systems/IntervalSystem.d.ts.map +0 -1
  237. package/bin/ECS/Systems/IntervalSystem.js +0 -50
  238. package/bin/ECS/Systems/IntervalSystem.js.map +0 -1
  239. package/bin/ECS/Systems/PassiveSystem.d.ts +0 -17
  240. package/bin/ECS/Systems/PassiveSystem.d.ts.map +0 -1
  241. package/bin/ECS/Systems/PassiveSystem.js +0 -19
  242. package/bin/ECS/Systems/PassiveSystem.js.map +0 -1
  243. package/bin/ECS/Systems/ProcessingSystem.d.ts +0 -21
  244. package/bin/ECS/Systems/ProcessingSystem.d.ts.map +0 -1
  245. package/bin/ECS/Systems/ProcessingSystem.js +0 -20
  246. package/bin/ECS/Systems/ProcessingSystem.js.map +0 -1
  247. package/bin/ECS/Systems/WorkerEntitySystem.d.ts +0 -313
  248. package/bin/ECS/Systems/WorkerEntitySystem.d.ts.map +0 -1
  249. package/bin/ECS/Systems/WorkerEntitySystem.js +0 -792
  250. package/bin/ECS/Systems/WorkerEntitySystem.js.map +0 -1
  251. package/bin/ECS/Systems/index.d.ts +0 -8
  252. package/bin/ECS/Systems/index.d.ts.map +0 -1
  253. package/bin/ECS/Systems/index.js +0 -8
  254. package/bin/ECS/Systems/index.js.map +0 -1
  255. package/bin/ECS/TypedEntity.d.ts +0 -192
  256. package/bin/ECS/TypedEntity.d.ts.map +0 -1
  257. package/bin/ECS/TypedEntity.js +0 -254
  258. package/bin/ECS/TypedEntity.js.map +0 -1
  259. package/bin/ECS/Utils/BigIntCompatibility.d.ts +0 -151
  260. package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +0 -1
  261. package/bin/ECS/Utils/BigIntCompatibility.js +0 -476
  262. package/bin/ECS/Utils/BigIntCompatibility.js.map +0 -1
  263. package/bin/ECS/Utils/BitMaskHashMap.d.ts +0 -28
  264. package/bin/ECS/Utils/BitMaskHashMap.d.ts.map +0 -1
  265. package/bin/ECS/Utils/BitMaskHashMap.js +0 -127
  266. package/bin/ECS/Utils/BitMaskHashMap.js.map +0 -1
  267. package/bin/ECS/Utils/Bits.d.ts +0 -154
  268. package/bin/ECS/Utils/Bits.d.ts.map +0 -1
  269. package/bin/ECS/Utils/Bits.js +0 -331
  270. package/bin/ECS/Utils/Bits.js.map +0 -1
  271. package/bin/ECS/Utils/ComponentSparseSet.d.ts +0 -143
  272. package/bin/ECS/Utils/ComponentSparseSet.d.ts.map +0 -1
  273. package/bin/ECS/Utils/ComponentSparseSet.js +0 -347
  274. package/bin/ECS/Utils/ComponentSparseSet.js.map +0 -1
  275. package/bin/ECS/Utils/EntityList.d.ts +0 -115
  276. package/bin/ECS/Utils/EntityList.d.ts.map +0 -1
  277. package/bin/ECS/Utils/EntityList.js +0 -258
  278. package/bin/ECS/Utils/EntityList.js.map +0 -1
  279. package/bin/ECS/Utils/EntityProcessorList.d.ts +0 -56
  280. package/bin/ECS/Utils/EntityProcessorList.d.ts.map +0 -1
  281. package/bin/ECS/Utils/EntityProcessorList.js +0 -113
  282. package/bin/ECS/Utils/EntityProcessorList.js.map +0 -1
  283. package/bin/ECS/Utils/IdentifierPool.d.ts +0 -203
  284. package/bin/ECS/Utils/IdentifierPool.d.ts.map +0 -1
  285. package/bin/ECS/Utils/IdentifierPool.js +0 -325
  286. package/bin/ECS/Utils/IdentifierPool.js.map +0 -1
  287. package/bin/ECS/Utils/Matcher.d.ts +0 -171
  288. package/bin/ECS/Utils/Matcher.d.ts.map +0 -1
  289. package/bin/ECS/Utils/Matcher.js +0 -293
  290. package/bin/ECS/Utils/Matcher.js.map +0 -1
  291. package/bin/ECS/Utils/SparseSet.d.ts +0 -170
  292. package/bin/ECS/Utils/SparseSet.d.ts.map +0 -1
  293. package/bin/ECS/Utils/SparseSet.js +0 -280
  294. package/bin/ECS/Utils/SparseSet.js.map +0 -1
  295. package/bin/ECS/Utils/index.d.ts +0 -9
  296. package/bin/ECS/Utils/index.d.ts.map +0 -1
  297. package/bin/ECS/Utils/index.js +0 -10
  298. package/bin/ECS/Utils/index.js.map +0 -1
  299. package/bin/ECS/World.d.ts +0 -238
  300. package/bin/ECS/World.d.ts.map +0 -1
  301. package/bin/ECS/World.js +0 -416
  302. package/bin/ECS/World.js.map +0 -1
  303. package/bin/ECS/WorldManager.d.ts +0 -224
  304. package/bin/ECS/WorldManager.d.ts.map +0 -1
  305. package/bin/ECS/WorldManager.js +0 -365
  306. package/bin/ECS/WorldManager.js.map +0 -1
  307. package/bin/ECS/index.d.ts +0 -26
  308. package/bin/ECS/index.d.ts.map +0 -1
  309. package/bin/ECS/index.js +0 -21
  310. package/bin/ECS/index.js.map +0 -1
  311. package/bin/Platform/IPlatformAdapter.d.ts +0 -169
  312. package/bin/Platform/IPlatformAdapter.d.ts.map +0 -1
  313. package/bin/Platform/IPlatformAdapter.js +0 -2
  314. package/bin/Platform/IPlatformAdapter.js.map +0 -1
  315. package/bin/Platform/PlatformDetector.d.ts +0 -56
  316. package/bin/Platform/PlatformDetector.d.ts.map +0 -1
  317. package/bin/Platform/PlatformDetector.js +0 -247
  318. package/bin/Platform/PlatformDetector.js.map +0 -1
  319. package/bin/Platform/PlatformManager.d.ts +0 -50
  320. package/bin/Platform/PlatformManager.d.ts.map +0 -1
  321. package/bin/Platform/PlatformManager.js +0 -114
  322. package/bin/Platform/PlatformManager.js.map +0 -1
  323. package/bin/Platform/index.d.ts +0 -19
  324. package/bin/Platform/index.d.ts.map +0 -1
  325. package/bin/Platform/index.js +0 -29
  326. package/bin/Platform/index.js.map +0 -1
  327. package/bin/Plugins/DebugPlugin.d.ts +0 -156
  328. package/bin/Plugins/DebugPlugin.d.ts.map +0 -1
  329. package/bin/Plugins/DebugPlugin.js +0 -248
  330. package/bin/Plugins/DebugPlugin.js.map +0 -1
  331. package/bin/Plugins/index.d.ts +0 -2
  332. package/bin/Plugins/index.d.ts.map +0 -1
  333. package/bin/Plugins/index.js +0 -2
  334. package/bin/Plugins/index.js.map +0 -1
  335. package/bin/Types/IUpdatable.d.ts +0 -18
  336. package/bin/Types/IUpdatable.d.ts.map +0 -1
  337. package/bin/Types/IUpdatable.js +0 -7
  338. package/bin/Types/IUpdatable.js.map +0 -1
  339. package/bin/Types/TypeHelpers.d.ts +0 -238
  340. package/bin/Types/TypeHelpers.d.ts.map +0 -1
  341. package/bin/Types/TypeHelpers.js +0 -19
  342. package/bin/Types/TypeHelpers.js.map +0 -1
  343. package/bin/Types/index.d.ts +0 -466
  344. package/bin/Types/index.d.ts.map +0 -1
  345. package/bin/Types/index.js +0 -7
  346. package/bin/Types/index.js.map +0 -1
  347. package/bin/Utils/BinarySerializer.d.ts +0 -23
  348. package/bin/Utils/BinarySerializer.d.ts.map +0 -1
  349. package/bin/Utils/BinarySerializer.js +0 -100
  350. package/bin/Utils/BinarySerializer.js.map +0 -1
  351. package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts +0 -153
  352. package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts.map +0 -1
  353. package/bin/Utils/Debug/AdvancedProfilerCollector.js +0 -406
  354. package/bin/Utils/Debug/AdvancedProfilerCollector.js.map +0 -1
  355. package/bin/Utils/Debug/ComponentDataCollector.d.ts +0 -32
  356. package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +0 -1
  357. package/bin/Utils/Debug/ComponentDataCollector.js +0 -250
  358. package/bin/Utils/Debug/ComponentDataCollector.js.map +0 -1
  359. package/bin/Utils/Debug/DebugConfigService.d.ts +0 -16
  360. package/bin/Utils/Debug/DebugConfigService.d.ts.map +0 -1
  361. package/bin/Utils/Debug/DebugConfigService.js +0 -42
  362. package/bin/Utils/Debug/DebugConfigService.js.map +0 -1
  363. package/bin/Utils/Debug/DebugManager.d.ts +0 -131
  364. package/bin/Utils/Debug/DebugManager.d.ts.map +0 -1
  365. package/bin/Utils/Debug/DebugManager.js +0 -848
  366. package/bin/Utils/Debug/DebugManager.js.map +0 -1
  367. package/bin/Utils/Debug/EntityDataCollector.d.ts +0 -115
  368. package/bin/Utils/Debug/EntityDataCollector.d.ts.map +0 -1
  369. package/bin/Utils/Debug/EntityDataCollector.js +0 -870
  370. package/bin/Utils/Debug/EntityDataCollector.js.map +0 -1
  371. package/bin/Utils/Debug/PerformanceDataCollector.d.ts +0 -31
  372. package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +0 -1
  373. package/bin/Utils/Debug/PerformanceDataCollector.js +0 -203
  374. package/bin/Utils/Debug/PerformanceDataCollector.js.map +0 -1
  375. package/bin/Utils/Debug/SceneDataCollector.d.ts +0 -18
  376. package/bin/Utils/Debug/SceneDataCollector.d.ts.map +0 -1
  377. package/bin/Utils/Debug/SceneDataCollector.js +0 -43
  378. package/bin/Utils/Debug/SceneDataCollector.js.map +0 -1
  379. package/bin/Utils/Debug/SystemDataCollector.d.ts +0 -14
  380. package/bin/Utils/Debug/SystemDataCollector.d.ts.map +0 -1
  381. package/bin/Utils/Debug/SystemDataCollector.js +0 -60
  382. package/bin/Utils/Debug/SystemDataCollector.js.map +0 -1
  383. package/bin/Utils/Debug/WebSocketManager.d.ts +0 -54
  384. package/bin/Utils/Debug/WebSocketManager.d.ts.map +0 -1
  385. package/bin/Utils/Debug/WebSocketManager.js +0 -141
  386. package/bin/Utils/Debug/WebSocketManager.js.map +0 -1
  387. package/bin/Utils/Debug/index.d.ts +0 -11
  388. package/bin/Utils/Debug/index.d.ts.map +0 -1
  389. package/bin/Utils/Debug/index.js +0 -10
  390. package/bin/Utils/Debug/index.js.map +0 -1
  391. package/bin/Utils/Emitter.d.ts +0 -61
  392. package/bin/Utils/Emitter.d.ts.map +0 -1
  393. package/bin/Utils/Emitter.js +0 -101
  394. package/bin/Utils/Emitter.js.map +0 -1
  395. package/bin/Utils/Extensions/NumberExtension.d.ts +0 -13
  396. package/bin/Utils/Extensions/NumberExtension.d.ts.map +0 -1
  397. package/bin/Utils/Extensions/NumberExtension.js +0 -17
  398. package/bin/Utils/Extensions/NumberExtension.js.map +0 -1
  399. package/bin/Utils/Extensions/TypeUtils.d.ts +0 -13
  400. package/bin/Utils/Extensions/TypeUtils.d.ts.map +0 -1
  401. package/bin/Utils/Extensions/TypeUtils.js +0 -15
  402. package/bin/Utils/Extensions/TypeUtils.js.map +0 -1
  403. package/bin/Utils/Extensions/index.d.ts +0 -3
  404. package/bin/Utils/Extensions/index.d.ts.map +0 -1
  405. package/bin/Utils/Extensions/index.js +0 -4
  406. package/bin/Utils/Extensions/index.js.map +0 -1
  407. package/bin/Utils/GlobalManager.d.ts +0 -29
  408. package/bin/Utils/GlobalManager.d.ts.map +0 -1
  409. package/bin/Utils/GlobalManager.js +0 -50
  410. package/bin/Utils/GlobalManager.js.map +0 -1
  411. package/bin/Utils/Logger/ConsoleLogger.d.ts +0 -74
  412. package/bin/Utils/Logger/ConsoleLogger.d.ts.map +0 -1
  413. package/bin/Utils/Logger/ConsoleLogger.js +0 -187
  414. package/bin/Utils/Logger/ConsoleLogger.js.map +0 -1
  415. package/bin/Utils/Logger/Constants.d.ts +0 -36
  416. package/bin/Utils/Logger/Constants.d.ts.map +0 -1
  417. package/bin/Utils/Logger/Constants.js +0 -40
  418. package/bin/Utils/Logger/Constants.js.map +0 -1
  419. package/bin/Utils/Logger/LoggerManager.d.ts +0 -91
  420. package/bin/Utils/Logger/LoggerManager.d.ts.map +0 -1
  421. package/bin/Utils/Logger/LoggerManager.js +0 -167
  422. package/bin/Utils/Logger/LoggerManager.js.map +0 -1
  423. package/bin/Utils/Logger/Types.d.ts +0 -40
  424. package/bin/Utils/Logger/Types.d.ts.map +0 -1
  425. package/bin/Utils/Logger/Types.js +0 -2
  426. package/bin/Utils/Logger/Types.js.map +0 -1
  427. package/bin/Utils/Logger/index.d.ts +0 -5
  428. package/bin/Utils/Logger/index.d.ts.map +0 -1
  429. package/bin/Utils/Logger/index.js +0 -5
  430. package/bin/Utils/Logger/index.js.map +0 -1
  431. package/bin/Utils/PerformanceMonitor.d.ts +0 -196
  432. package/bin/Utils/PerformanceMonitor.d.ts.map +0 -1
  433. package/bin/Utils/PerformanceMonitor.js +0 -244
  434. package/bin/Utils/PerformanceMonitor.js.map +0 -1
  435. package/bin/Utils/Pool/IPoolable.d.ts +0 -29
  436. package/bin/Utils/Pool/IPoolable.d.ts.map +0 -1
  437. package/bin/Utils/Pool/IPoolable.js +0 -2
  438. package/bin/Utils/Pool/IPoolable.js.map +0 -1
  439. package/bin/Utils/Pool/Pool.d.ts +0 -109
  440. package/bin/Utils/Pool/Pool.d.ts.map +0 -1
  441. package/bin/Utils/Pool/Pool.js +0 -238
  442. package/bin/Utils/Pool/Pool.js.map +0 -1
  443. package/bin/Utils/Pool/PoolManager.d.ts +0 -96
  444. package/bin/Utils/Pool/PoolManager.d.ts.map +0 -1
  445. package/bin/Utils/Pool/PoolManager.js +0 -199
  446. package/bin/Utils/Pool/PoolManager.js.map +0 -1
  447. package/bin/Utils/Pool/index.d.ts +0 -4
  448. package/bin/Utils/Pool/index.d.ts.map +0 -1
  449. package/bin/Utils/Pool/index.js +0 -4
  450. package/bin/Utils/Pool/index.js.map +0 -1
  451. package/bin/Utils/Profiler/AutoProfiler.d.ts +0 -160
  452. package/bin/Utils/Profiler/AutoProfiler.d.ts.map +0 -1
  453. package/bin/Utils/Profiler/AutoProfiler.js +0 -503
  454. package/bin/Utils/Profiler/AutoProfiler.js.map +0 -1
  455. package/bin/Utils/Profiler/ProfilerSDK.d.ts +0 -175
  456. package/bin/Utils/Profiler/ProfilerSDK.d.ts.map +0 -1
  457. package/bin/Utils/Profiler/ProfilerSDK.js +0 -727
  458. package/bin/Utils/Profiler/ProfilerSDK.js.map +0 -1
  459. package/bin/Utils/Profiler/ProfilerTypes.d.ts +0 -218
  460. package/bin/Utils/Profiler/ProfilerTypes.d.ts.map +0 -1
  461. package/bin/Utils/Profiler/ProfilerTypes.js +0 -47
  462. package/bin/Utils/Profiler/ProfilerTypes.js.map +0 -1
  463. package/bin/Utils/Profiler/index.d.ts +0 -8
  464. package/bin/Utils/Profiler/index.d.ts.map +0 -1
  465. package/bin/Utils/Profiler/index.js +0 -7
  466. package/bin/Utils/Profiler/index.js.map +0 -1
  467. package/bin/Utils/Time.d.ts +0 -47
  468. package/bin/Utils/Time.d.ts.map +0 -1
  469. package/bin/Utils/Time.js +0 -64
  470. package/bin/Utils/Time.js.map +0 -1
  471. package/bin/Utils/Timers/ITimer.d.ts +0 -16
  472. package/bin/Utils/Timers/ITimer.d.ts.map +0 -1
  473. package/bin/Utils/Timers/ITimer.js +0 -2
  474. package/bin/Utils/Timers/ITimer.js.map +0 -1
  475. package/bin/Utils/Timers/Timer.d.ts +0 -30
  476. package/bin/Utils/Timers/Timer.d.ts.map +0 -1
  477. package/bin/Utils/Timers/Timer.js +0 -58
  478. package/bin/Utils/Timers/Timer.js.map +0 -1
  479. package/bin/Utils/Timers/TimerManager.d.ts +0 -26
  480. package/bin/Utils/Timers/TimerManager.d.ts.map +0 -1
  481. package/bin/Utils/Timers/TimerManager.js +0 -48
  482. package/bin/Utils/Timers/TimerManager.js.map +0 -1
  483. package/bin/Utils/index.d.ts +0 -11
  484. package/bin/Utils/index.d.ts.map +0 -1
  485. package/bin/Utils/index.js +0 -11
  486. package/bin/Utils/index.js.map +0 -1
  487. package/bin/index.d.ts +0 -29
  488. package/bin/index.d.ts.map +0 -1
  489. package/bin/index.js +0 -36
  490. package/bin/index.js.map +0 -1
@@ -1,685 +0,0 @@
1
- import { SoATypeRegistry } from './SoATypeRegistry';
2
- import { SoASerializer } from './SoASerializer';
3
- export { SoATypeRegistry } from './SoATypeRegistry';
4
- export { SoASerializer } from './SoASerializer';
5
- /**
6
- * 启用SoA优化装饰器
7
- * 默认关闭SoA,只有在大规模批量操作场景下才建议开启
8
- */
9
- export function EnableSoA(target) {
10
- target.__enableSoA = true;
11
- return target;
12
- }
13
- /**
14
- * 64位浮点数装饰器
15
- * 标记字段使用Float64Array存储(更高精度但更多内存)
16
- */
17
- export function Float64(target, propertyKey) {
18
- const key = String(propertyKey);
19
- if (!target.constructor.__float64Fields) {
20
- target.constructor.__float64Fields = new Set();
21
- }
22
- target.constructor.__float64Fields.add(key);
23
- }
24
- /**
25
- * 32位浮点数装饰器
26
- * 标记字段使用Float32Array存储(默认类型,平衡性能和精度)
27
- */
28
- export function Float32(target, propertyKey) {
29
- const key = String(propertyKey);
30
- if (!target.constructor.__float32Fields) {
31
- target.constructor.__float32Fields = new Set();
32
- }
33
- target.constructor.__float32Fields.add(key);
34
- }
35
- /**
36
- * 32位整数装饰器
37
- * 标记字段使用Int32Array存储(适用于整数值)
38
- */
39
- export function Int32(target, propertyKey) {
40
- const key = String(propertyKey);
41
- if (!target.constructor.__int32Fields) {
42
- target.constructor.__int32Fields = new Set();
43
- }
44
- target.constructor.__int32Fields.add(key);
45
- }
46
- /**
47
- * 32位无符号整数装饰器
48
- * 标记字段使用Uint32Array存储(适用于无符号整数,如ID、标志位等)
49
- */
50
- export function Uint32(target, propertyKey) {
51
- const key = String(propertyKey);
52
- if (!target.constructor.__uint32Fields) {
53
- target.constructor.__uint32Fields = new Set();
54
- }
55
- target.constructor.__uint32Fields.add(key);
56
- }
57
- /**
58
- * 16位整数装饰器
59
- * 标记字段使用Int16Array存储(适用于小范围整数)
60
- */
61
- export function Int16(target, propertyKey) {
62
- const key = String(propertyKey);
63
- if (!target.constructor.__int16Fields) {
64
- target.constructor.__int16Fields = new Set();
65
- }
66
- target.constructor.__int16Fields.add(key);
67
- }
68
- /**
69
- * 16位无符号整数装饰器
70
- * 标记字段使用Uint16Array存储(适用于小范围无符号整数)
71
- */
72
- export function Uint16(target, propertyKey) {
73
- const key = String(propertyKey);
74
- if (!target.constructor.__uint16Fields) {
75
- target.constructor.__uint16Fields = new Set();
76
- }
77
- target.constructor.__uint16Fields.add(key);
78
- }
79
- /**
80
- * 8位整数装饰器
81
- * 标记字段使用Int8Array存储(适用于很小的整数值)
82
- */
83
- export function Int8(target, propertyKey) {
84
- const key = String(propertyKey);
85
- if (!target.constructor.__int8Fields) {
86
- target.constructor.__int8Fields = new Set();
87
- }
88
- target.constructor.__int8Fields.add(key);
89
- }
90
- /**
91
- * 8位无符号整数装饰器
92
- * 标记字段使用Uint8Array存储(适用于字节值、布尔标志等)
93
- */
94
- export function Uint8(target, propertyKey) {
95
- const key = String(propertyKey);
96
- if (!target.constructor.__uint8Fields) {
97
- target.constructor.__uint8Fields = new Set();
98
- }
99
- target.constructor.__uint8Fields.add(key);
100
- }
101
- /**
102
- * 8位夹紧整数装饰器
103
- * 标记字段使用Uint8ClampedArray存储(适用于颜色值等需要夹紧的数据)
104
- */
105
- export function Uint8Clamped(target, propertyKey) {
106
- const key = String(propertyKey);
107
- if (!target.constructor.__uint8ClampedFields) {
108
- target.constructor.__uint8ClampedFields = new Set();
109
- }
110
- target.constructor.__uint8ClampedFields.add(key);
111
- }
112
- /**
113
- * 序列化Map装饰器
114
- * 标记Map字段需要序列化/反序列化存储
115
- */
116
- export function SerializeMap(target, propertyKey) {
117
- const key = String(propertyKey);
118
- if (!target.constructor.__serializeMapFields) {
119
- target.constructor.__serializeMapFields = new Set();
120
- }
121
- target.constructor.__serializeMapFields.add(key);
122
- }
123
- /**
124
- * 序列化Set装饰器
125
- * 标记Set字段需要序列化/反序列化存储
126
- */
127
- export function SerializeSet(target, propertyKey) {
128
- const key = String(propertyKey);
129
- if (!target.constructor.__serializeSetFields) {
130
- target.constructor.__serializeSetFields = new Set();
131
- }
132
- target.constructor.__serializeSetFields.add(key);
133
- }
134
- /**
135
- * 序列化Array装饰器
136
- * 标记Array字段需要序列化/反序列化存储
137
- */
138
- export function SerializeArray(target, propertyKey) {
139
- const key = String(propertyKey);
140
- if (!target.constructor.__serializeArrayFields) {
141
- target.constructor.__serializeArrayFields = new Set();
142
- }
143
- target.constructor.__serializeArrayFields.add(key);
144
- }
145
- /**
146
- * 深拷贝装饰器
147
- * 标记字段需要深拷贝处理(适用于嵌套对象)
148
- */
149
- export function DeepCopy(target, propertyKey) {
150
- const key = String(propertyKey);
151
- if (!target.constructor.__deepCopyFields) {
152
- target.constructor.__deepCopyFields = new Set();
153
- }
154
- target.constructor.__deepCopyFields.add(key);
155
- }
156
- /**
157
- * SoA存储器(需要装饰器启用)
158
- * 使用Structure of Arrays存储模式,在大规模批量操作时提供优异性能
159
- */
160
- export class SoAStorage {
161
- constructor(componentType) {
162
- this.fields = new Map();
163
- this.stringFields = new Map();
164
- this.serializedFields = new Map();
165
- this.complexFields = new Map();
166
- this.entityToIndex = new Map();
167
- this.indexToEntity = [];
168
- this.freeIndices = [];
169
- this._size = 0;
170
- this._capacity = 1000;
171
- // 缓存字段类型信息,避免重复创建实例
172
- this.fieldTypes = new Map();
173
- // 缓存装饰器元数据
174
- this.serializeMapFields = new Set();
175
- this.serializeSetFields = new Set();
176
- this.serializeArrayFields = new Set();
177
- this.type = componentType;
178
- this.initializeFields(componentType);
179
- }
180
- initializeFields(componentType) {
181
- const instance = new componentType();
182
- const typeWithMeta = componentType;
183
- const float64Fields = typeWithMeta.__float64Fields || new Set();
184
- const float32Fields = typeWithMeta.__float32Fields || new Set();
185
- const int32Fields = typeWithMeta.__int32Fields || new Set();
186
- const uint32Fields = typeWithMeta.__uint32Fields || new Set();
187
- const int16Fields = typeWithMeta.__int16Fields || new Set();
188
- const uint16Fields = typeWithMeta.__uint16Fields || new Set();
189
- const int8Fields = typeWithMeta.__int8Fields || new Set();
190
- const uint8Fields = typeWithMeta.__uint8Fields || new Set();
191
- const uint8ClampedFields = typeWithMeta.__uint8ClampedFields || new Set();
192
- // 缓存装饰器元数据
193
- this.serializeMapFields = typeWithMeta.__serializeMapFields || new Set();
194
- this.serializeSetFields = typeWithMeta.__serializeSetFields || new Set();
195
- this.serializeArrayFields = typeWithMeta.__serializeArrayFields || new Set();
196
- // 先收集所有有装饰器的字段,避免重复遍历
197
- const decoratedFields = new Map(); // fieldName -> arrayType
198
- // 处理各类型装饰器标记的字段
199
- for (const key of float64Fields)
200
- decoratedFields.set(key, 'float64');
201
- for (const key of float32Fields)
202
- decoratedFields.set(key, 'float32');
203
- for (const key of int32Fields)
204
- decoratedFields.set(key, 'int32');
205
- for (const key of uint32Fields)
206
- decoratedFields.set(key, 'uint32');
207
- for (const key of int16Fields)
208
- decoratedFields.set(key, 'int16');
209
- for (const key of uint16Fields)
210
- decoratedFields.set(key, 'uint16');
211
- for (const key of int8Fields)
212
- decoratedFields.set(key, 'int8');
213
- for (const key of uint8Fields)
214
- decoratedFields.set(key, 'uint8');
215
- for (const key of uint8ClampedFields)
216
- decoratedFields.set(key, 'uint8clamped');
217
- // 只遍历实例自身的属性(不包括原型链),跳过 id
218
- const instanceKeys = Object.keys(instance).filter((key) => key !== 'id');
219
- for (const key of instanceKeys) {
220
- const value = instance[key];
221
- const type = typeof value;
222
- // 跳过函数(通常不会出现在 Object.keys 中,但以防万一)
223
- if (type === 'function')
224
- continue;
225
- // 检查装饰器类型
226
- const decoratorType = decoratedFields.get(key);
227
- const effectiveType = decoratorType ? 'number' : type;
228
- this.fieldTypes.set(key, effectiveType);
229
- if (decoratorType) {
230
- // 有装饰器标记的数字字段
231
- const ArrayConstructor = SoATypeRegistry.getConstructor(decoratorType);
232
- this.fields.set(key, new ArrayConstructor(this._capacity));
233
- }
234
- else if (type === 'number') {
235
- // 无装饰器的数字字段,默认使用 Float32Array
236
- this.fields.set(key, new Float32Array(this._capacity));
237
- }
238
- else if (type === 'boolean') {
239
- // 布尔值使用 Uint8Array 存储为 0/1
240
- this.fields.set(key, new Uint8Array(this._capacity));
241
- }
242
- else if (type === 'string') {
243
- // 字符串专门处理
244
- this.stringFields.set(key, new Array(this._capacity));
245
- }
246
- else if (type === 'object' && value !== null) {
247
- // 处理集合类型
248
- if (this.serializeMapFields.has(key) || this.serializeSetFields.has(key) || this.serializeArrayFields.has(key)) {
249
- // 序列化存储
250
- this.serializedFields.set(key, new Array(this._capacity));
251
- }
252
- // 其他对象类型会在updateComponentAtIndex中作为复杂对象处理
253
- }
254
- }
255
- }
256
- addComponent(entityId, component) {
257
- if (this.entityToIndex.has(entityId)) {
258
- const index = this.entityToIndex.get(entityId);
259
- this.updateComponentAtIndex(index, component);
260
- return;
261
- }
262
- let index;
263
- if (this.freeIndices.length > 0) {
264
- index = this.freeIndices.pop();
265
- }
266
- else {
267
- index = this._size;
268
- if (index >= this._capacity) {
269
- this.resize(this._capacity * 2);
270
- }
271
- }
272
- this.entityToIndex.set(entityId, index);
273
- this.indexToEntity[index] = entityId;
274
- this.updateComponentAtIndex(index, component);
275
- this._size++;
276
- }
277
- updateComponentAtIndex(index, component) {
278
- const entityId = this.indexToEntity[index];
279
- const complexFieldMap = new Map();
280
- const highPrecisionFields = this.type.__highPrecisionFields || new Set();
281
- const serializeMapFields = this.type.__serializeMapFields || new Set();
282
- const serializeSetFields = this.type.__serializeSetFields || new Set();
283
- const serializeArrayFields = this.type.__serializeArrayFields || new Set();
284
- const deepCopyFields = this.type.__deepCopyFields || new Set();
285
- // 处理所有字段
286
- for (const key in component) {
287
- if (component.hasOwnProperty(key) && key !== 'id') {
288
- const value = component[key];
289
- const type = typeof value;
290
- if (type === 'number') {
291
- if (highPrecisionFields.has(key) || !this.fields.has(key)) {
292
- // 标记为高精度或未在TypedArray中的数值作为复杂对象存储
293
- complexFieldMap.set(key, value);
294
- }
295
- else {
296
- // 存储到TypedArray
297
- const array = this.fields.get(key);
298
- array[index] = value;
299
- }
300
- }
301
- else if (type === 'boolean' && this.fields.has(key)) {
302
- // 布尔值存储到TypedArray
303
- const array = this.fields.get(key);
304
- array[index] = value ? 1 : 0;
305
- }
306
- else if (this.stringFields.has(key)) {
307
- // 字符串字段专门处理
308
- const stringArray = this.stringFields.get(key);
309
- stringArray[index] = String(value);
310
- }
311
- else if (this.serializedFields.has(key)) {
312
- // 序列化字段处理
313
- const serializedArray = this.serializedFields.get(key);
314
- serializedArray[index] = SoASerializer.serialize(value, key, {
315
- isMap: serializeMapFields.has(key),
316
- isSet: serializeSetFields.has(key),
317
- isArray: serializeArrayFields.has(key)
318
- });
319
- }
320
- else {
321
- // 复杂字段单独存储
322
- if (deepCopyFields.has(key)) {
323
- // 深拷贝处理
324
- complexFieldMap.set(key, SoASerializer.deepClone(value));
325
- }
326
- else {
327
- complexFieldMap.set(key, value);
328
- }
329
- }
330
- }
331
- }
332
- // 存储复杂字段
333
- if (complexFieldMap.size > 0) {
334
- this.complexFields.set(entityId, complexFieldMap);
335
- }
336
- }
337
- getComponent(entityId) {
338
- const index = this.entityToIndex.get(entityId);
339
- if (index === undefined) {
340
- return null;
341
- }
342
- // 返回 Proxy,直接操作底层 TypedArray
343
- return this.createProxyView(entityId, index);
344
- }
345
- /**
346
- * 创建组件的 Proxy 视图
347
- * 读写操作直接映射到底层 TypedArray,无数据复制
348
- */
349
- createProxyView(entityId, index) {
350
- // eslint-disable-next-line @typescript-eslint/no-this-alias
351
- const self = this;
352
- // Proxy handler 类型定义
353
- const handler = {
354
- get(_, prop) {
355
- const propStr = String(prop);
356
- // TypedArray 字段
357
- const array = self.fields.get(propStr);
358
- if (array) {
359
- const fieldType = self.getFieldType(propStr);
360
- if (fieldType === 'boolean') {
361
- return array[index] === 1;
362
- }
363
- return array[index];
364
- }
365
- // 字符串字段
366
- const stringArray = self.stringFields.get(propStr);
367
- if (stringArray) {
368
- return stringArray[index];
369
- }
370
- // 序列化字段
371
- const serializedArray = self.serializedFields.get(propStr);
372
- if (serializedArray) {
373
- const serialized = serializedArray[index];
374
- if (serialized) {
375
- return SoASerializer.deserialize(serialized, propStr, {
376
- isMap: self.serializeMapFields.has(propStr),
377
- isSet: self.serializeSetFields.has(propStr),
378
- isArray: self.serializeArrayFields.has(propStr)
379
- });
380
- }
381
- return undefined;
382
- }
383
- // 复杂字段
384
- const complexFieldMap = self.complexFields.get(entityId);
385
- if (complexFieldMap?.has(propStr)) {
386
- return complexFieldMap.get(propStr);
387
- }
388
- return undefined;
389
- },
390
- set(_, prop, value) {
391
- const propStr = String(prop);
392
- // entityId 是只读的
393
- if (propStr === 'entityId') {
394
- return false;
395
- }
396
- // TypedArray 字段
397
- const array = self.fields.get(propStr);
398
- if (array) {
399
- const fieldType = self.getFieldType(propStr);
400
- if (fieldType === 'boolean') {
401
- array[index] = value ? 1 : 0;
402
- }
403
- else {
404
- array[index] = value;
405
- }
406
- return true;
407
- }
408
- // 字符串字段
409
- const stringArray = self.stringFields.get(propStr);
410
- if (stringArray) {
411
- stringArray[index] = String(value);
412
- return true;
413
- }
414
- // 序列化字段
415
- if (self.serializedFields.has(propStr)) {
416
- const serializedArray = self.serializedFields.get(propStr);
417
- serializedArray[index] = SoASerializer.serialize(value, propStr, {
418
- isMap: self.serializeMapFields.has(propStr),
419
- isSet: self.serializeSetFields.has(propStr),
420
- isArray: self.serializeArrayFields.has(propStr)
421
- });
422
- return true;
423
- }
424
- // 复杂字段
425
- let complexFieldMap = self.complexFields.get(entityId);
426
- if (!complexFieldMap) {
427
- complexFieldMap = new Map();
428
- self.complexFields.set(entityId, complexFieldMap);
429
- }
430
- complexFieldMap.set(propStr, value);
431
- return true;
432
- },
433
- has(_, prop) {
434
- const propStr = String(prop);
435
- return self.fields.has(propStr) ||
436
- self.stringFields.has(propStr) ||
437
- self.serializedFields.has(propStr) ||
438
- self.complexFields.get(entityId)?.has(propStr) || false;
439
- },
440
- ownKeys() {
441
- const keys = [];
442
- for (const key of self.fields.keys())
443
- keys.push(key);
444
- for (const key of self.stringFields.keys())
445
- keys.push(key);
446
- for (const key of self.serializedFields.keys())
447
- keys.push(key);
448
- const complexFieldMap = self.complexFields.get(entityId);
449
- if (complexFieldMap) {
450
- for (const key of complexFieldMap.keys())
451
- keys.push(key);
452
- }
453
- return keys;
454
- },
455
- getOwnPropertyDescriptor(_, prop) {
456
- const propStr = String(prop);
457
- if (self.fields.has(propStr) ||
458
- self.stringFields.has(propStr) ||
459
- self.serializedFields.has(propStr) ||
460
- self.complexFields.get(entityId)?.has(propStr)) {
461
- return {
462
- enumerable: true,
463
- configurable: true,
464
- // entityId 是只读的
465
- writable: propStr !== 'entityId'
466
- };
467
- }
468
- return undefined;
469
- }
470
- };
471
- return new Proxy({}, handler);
472
- }
473
- /**
474
- * 获取组件的快照副本(用于序列化等需要独立副本的场景)
475
- */
476
- getComponentSnapshot(entityId) {
477
- const index = this.entityToIndex.get(entityId);
478
- if (index === undefined) {
479
- return null;
480
- }
481
- // 需要 any 因为要动态写入泛型 T 的属性
482
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
483
- const component = new this.type();
484
- // 恢复数值字段
485
- for (const [fieldName, array] of this.fields.entries()) {
486
- const value = array[index];
487
- const fieldType = this.getFieldType(fieldName);
488
- if (fieldType === 'boolean') {
489
- component[fieldName] = value === 1;
490
- }
491
- else {
492
- component[fieldName] = value;
493
- }
494
- }
495
- // 恢复字符串字段
496
- for (const [fieldName, stringArray] of this.stringFields.entries()) {
497
- component[fieldName] = stringArray[index];
498
- }
499
- // 恢复序列化字段
500
- for (const [fieldName, serializedArray] of this.serializedFields.entries()) {
501
- const serialized = serializedArray[index];
502
- if (serialized) {
503
- component[fieldName] = SoASerializer.deserialize(serialized, fieldName, {
504
- isMap: this.serializeMapFields.has(fieldName),
505
- isSet: this.serializeSetFields.has(fieldName),
506
- isArray: this.serializeArrayFields.has(fieldName)
507
- });
508
- }
509
- }
510
- // 恢复复杂字段
511
- const complexFieldMap = this.complexFields.get(entityId);
512
- if (complexFieldMap) {
513
- for (const [fieldName, value] of complexFieldMap.entries()) {
514
- component[fieldName] = value;
515
- }
516
- }
517
- return component;
518
- }
519
- getFieldType(fieldName) {
520
- // 使用缓存的字段类型
521
- return this.fieldTypes.get(fieldName) || 'unknown';
522
- }
523
- hasComponent(entityId) {
524
- return this.entityToIndex.has(entityId);
525
- }
526
- removeComponent(entityId) {
527
- const index = this.entityToIndex.get(entityId);
528
- if (index === undefined) {
529
- return null;
530
- }
531
- // 获取组件副本以便返回
532
- const component = this.getComponent(entityId);
533
- // 清理复杂字段
534
- this.complexFields.delete(entityId);
535
- this.entityToIndex.delete(entityId);
536
- this.freeIndices.push(index);
537
- this._size--;
538
- return component;
539
- }
540
- resize(newCapacity) {
541
- // 调整数值字段的TypedArray
542
- for (const [fieldName, oldArray] of this.fields.entries()) {
543
- const newArray = SoATypeRegistry.createSameType(oldArray, newCapacity);
544
- newArray.set(oldArray);
545
- this.fields.set(fieldName, newArray);
546
- }
547
- // 调整字符串字段的数组
548
- for (const [fieldName, oldArray] of this.stringFields.entries()) {
549
- const newArray = new Array(newCapacity);
550
- for (let i = 0; i < oldArray.length; i++) {
551
- newArray[i] = oldArray[i];
552
- }
553
- this.stringFields.set(fieldName, newArray);
554
- }
555
- // 调整序列化字段的数组
556
- for (const [fieldName, oldArray] of this.serializedFields.entries()) {
557
- const newArray = new Array(newCapacity);
558
- for (let i = 0; i < oldArray.length; i++) {
559
- newArray[i] = oldArray[i];
560
- }
561
- this.serializedFields.set(fieldName, newArray);
562
- }
563
- this._capacity = newCapacity;
564
- }
565
- getActiveIndices() {
566
- return Array.from(this.entityToIndex.values());
567
- }
568
- getFieldArray(fieldName) {
569
- return this.fields.get(fieldName) || null;
570
- }
571
- getTypedFieldArray(fieldName) {
572
- return this.fields.get(String(fieldName)) || null;
573
- }
574
- getEntityIndex(entityId) {
575
- return this.entityToIndex.get(entityId);
576
- }
577
- getEntityIdByIndex(index) {
578
- return this.indexToEntity[index];
579
- }
580
- size() {
581
- return this._size;
582
- }
583
- clear() {
584
- this.entityToIndex.clear();
585
- this.indexToEntity = [];
586
- this.freeIndices = [];
587
- this.complexFields.clear();
588
- this._size = 0;
589
- // 重置数值字段数组
590
- for (const array of this.fields.values()) {
591
- array.fill(0);
592
- }
593
- // 重置字符串字段数组
594
- for (const stringArray of this.stringFields.values()) {
595
- for (let i = 0; i < stringArray.length; i++) {
596
- stringArray[i] = undefined;
597
- }
598
- }
599
- // 重置序列化字段数组
600
- for (const serializedArray of this.serializedFields.values()) {
601
- for (let i = 0; i < serializedArray.length; i++) {
602
- serializedArray[i] = undefined;
603
- }
604
- }
605
- }
606
- compact() {
607
- if (this.freeIndices.length === 0) {
608
- return;
609
- }
610
- const activeEntries = Array.from(this.entityToIndex.entries())
611
- .sort((a, b) => a[1] - b[1]);
612
- // 重新映射索引
613
- const newEntityToIndex = new Map();
614
- const newIndexToEntity = [];
615
- for (let newIndex = 0; newIndex < activeEntries.length; newIndex++) {
616
- const entry = activeEntries[newIndex];
617
- if (!entry)
618
- continue;
619
- const [entityId, oldIndex] = entry;
620
- newEntityToIndex.set(entityId, newIndex);
621
- newIndexToEntity[newIndex] = entityId;
622
- // 移动字段数据
623
- if (newIndex !== oldIndex) {
624
- // 移动数值字段
625
- for (const [, array] of this.fields.entries()) {
626
- const value = array[oldIndex];
627
- if (value !== undefined) {
628
- array[newIndex] = value;
629
- }
630
- }
631
- // 移动字符串字段
632
- for (const [, stringArray] of this.stringFields.entries()) {
633
- const value = stringArray[oldIndex];
634
- if (value !== undefined) {
635
- stringArray[newIndex] = value;
636
- }
637
- }
638
- // 移动序列化字段
639
- for (const [, serializedArray] of this.serializedFields.entries()) {
640
- const value = serializedArray[oldIndex];
641
- if (value !== undefined) {
642
- serializedArray[newIndex] = value;
643
- }
644
- }
645
- }
646
- }
647
- this.entityToIndex = newEntityToIndex;
648
- this.indexToEntity = newIndexToEntity;
649
- this.freeIndices = [];
650
- this._size = activeEntries.length;
651
- }
652
- getStats() {
653
- let totalMemory = 0;
654
- const fieldStats = new Map();
655
- for (const [fieldName, array] of this.fields.entries()) {
656
- const typeName = SoATypeRegistry.getTypeName(array);
657
- const bytesPerElement = SoATypeRegistry.getBytesPerElement(typeName);
658
- const memory = array.length * bytesPerElement;
659
- totalMemory += memory;
660
- fieldStats.set(fieldName, {
661
- size: this._size,
662
- capacity: array.length,
663
- type: typeName,
664
- memory: memory
665
- });
666
- }
667
- return {
668
- size: this._size,
669
- capacity: this._capacity,
670
- usedSlots: this._size, // 兼容原测试
671
- fragmentation: this.freeIndices.length / this._capacity,
672
- memoryUsage: totalMemory,
673
- fieldStats: fieldStats
674
- };
675
- }
676
- /**
677
- * 执行向量化批量操作
678
- * @param operation 操作函数,接收字段数组和活跃索引
679
- */
680
- performVectorizedOperation(operation) {
681
- const activeIndices = this.getActiveIndices();
682
- operation(this.fields, activeIndices);
683
- }
684
- }
685
- //# sourceMappingURL=SoAStorage.js.map