@esengine/ecs-framework 2.2.21 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/Core/DI/Decorators.d.ts +206 -0
- package/bin/Core/DI/Decorators.d.ts.map +1 -0
- package/bin/Core/DI/Decorators.js +253 -0
- package/bin/Core/DI/Decorators.js.map +1 -0
- package/bin/Core/DI/index.d.ts +8 -0
- package/bin/Core/DI/index.d.ts.map +1 -0
- package/bin/Core/DI/index.js +7 -0
- package/bin/Core/DI/index.js.map +1 -0
- package/bin/Core/Plugin.d.ts +112 -0
- package/bin/Core/Plugin.d.ts.map +1 -0
- package/bin/Core/Plugin.js +19 -0
- package/bin/Core/Plugin.js.map +1 -0
- package/bin/Core/PluginManager.d.ts +118 -0
- package/bin/Core/PluginManager.d.ts.map +1 -0
- package/bin/Core/PluginManager.js +229 -0
- package/bin/Core/PluginManager.js.map +1 -0
- package/bin/Core/ServiceContainer.d.ts +221 -0
- package/bin/Core/ServiceContainer.d.ts.map +1 -0
- package/bin/Core/ServiceContainer.js +352 -0
- package/bin/Core/ServiceContainer.js.map +1 -0
- package/bin/Core.d.ts +379 -0
- package/bin/Core.d.ts.map +1 -0
- package/bin/Core.js +553 -0
- package/bin/Core.js.map +1 -0
- package/bin/ECS/Component.d.ts +104 -0
- package/bin/ECS/Component.d.ts.map +1 -0
- package/bin/ECS/Component.js +105 -0
- package/bin/ECS/Component.js.map +1 -0
- package/bin/ECS/Components/HierarchyComponent.d.ts +46 -0
- package/bin/ECS/Components/HierarchyComponent.d.ts.map +1 -0
- package/bin/ECS/Components/HierarchyComponent.js +65 -0
- package/bin/ECS/Components/HierarchyComponent.js.map +1 -0
- package/bin/ECS/Components/index.d.ts +2 -0
- package/bin/ECS/Components/index.d.ts.map +1 -0
- package/bin/ECS/Components/index.js +2 -0
- package/bin/ECS/Components/index.js.map +1 -0
- package/bin/ECS/Core/ArchetypeSystem.d.ts +103 -0
- package/bin/ECS/Core/ArchetypeSystem.d.ts.map +1 -0
- package/bin/ECS/Core/ArchetypeSystem.js +244 -0
- package/bin/ECS/Core/ArchetypeSystem.js.map +1 -0
- package/bin/ECS/Core/CommandBuffer.d.ts +154 -0
- package/bin/ECS/Core/CommandBuffer.d.ts.map +1 -0
- package/bin/ECS/Core/CommandBuffer.js +244 -0
- package/bin/ECS/Core/CommandBuffer.js.map +1 -0
- package/bin/ECS/Core/ComponentPool.d.ts +139 -0
- package/bin/ECS/Core/ComponentPool.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentPool.js +276 -0
- package/bin/ECS/Core/ComponentPool.js.map +1 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts +127 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js +235 -0
- package/bin/ECS/Core/ComponentStorage/ComponentRegistry.js.map +1 -0
- package/bin/ECS/Core/ComponentStorage.d.ts +185 -0
- package/bin/ECS/Core/ComponentStorage.d.ts.map +1 -0
- package/bin/ECS/Core/ComponentStorage.js +321 -0
- package/bin/ECS/Core/ComponentStorage.js.map +1 -0
- package/bin/ECS/Core/EntityLifecyclePolicy.d.ts +26 -0
- package/bin/ECS/Core/EntityLifecyclePolicy.d.ts.map +1 -0
- package/bin/ECS/Core/EntityLifecyclePolicy.js +2 -0
- package/bin/ECS/Core/EntityLifecyclePolicy.js.map +1 -0
- package/bin/ECS/Core/EventBus.d.ts +210 -0
- package/bin/ECS/Core/EventBus.d.ts.map +1 -0
- package/bin/ECS/Core/EventBus.js +370 -0
- package/bin/ECS/Core/EventBus.js.map +1 -0
- package/bin/ECS/Core/EventSystem.d.ts +225 -0
- package/bin/ECS/Core/EventSystem.d.ts.map +1 -0
- package/bin/ECS/Core/EventSystem.js +448 -0
- package/bin/ECS/Core/EventSystem.js.map +1 -0
- package/bin/ECS/Core/Events/index.d.ts +3 -0
- package/bin/ECS/Core/Events/index.d.ts.map +1 -0
- package/bin/ECS/Core/Events/index.js +3 -0
- package/bin/ECS/Core/Events/index.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts +35 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js +48 -0
- package/bin/ECS/Core/FluentAPI/ComponentBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts +135 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js +166 -0
- package/bin/ECS/Core/FluentAPI/ECSFluentAPI.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts +58 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js +85 -0
- package/bin/ECS/Core/FluentAPI/EntityBatchOperator.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts +110 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js +181 -0
- package/bin/ECS/Core/FluentAPI/EntityBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts +53 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js +79 -0
- package/bin/ECS/Core/FluentAPI/SceneBuilder.js.map +1 -0
- package/bin/ECS/Core/FluentAPI/index.d.ts +6 -0
- package/bin/ECS/Core/FluentAPI/index.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI/index.js +6 -0
- package/bin/ECS/Core/FluentAPI/index.js.map +1 -0
- package/bin/ECS/Core/FluentAPI.d.ts +2 -0
- package/bin/ECS/Core/FluentAPI.d.ts.map +1 -0
- package/bin/ECS/Core/FluentAPI.js +3 -0
- package/bin/ECS/Core/FluentAPI.js.map +1 -0
- package/bin/ECS/Core/Query/TypedQuery.d.ts +214 -0
- package/bin/ECS/Core/Query/TypedQuery.d.ts.map +1 -0
- package/bin/ECS/Core/Query/TypedQuery.js +294 -0
- package/bin/ECS/Core/Query/TypedQuery.js.map +1 -0
- package/bin/ECS/Core/Query/index.d.ts +3 -0
- package/bin/ECS/Core/Query/index.d.ts.map +1 -0
- package/bin/ECS/Core/Query/index.js +3 -0
- package/bin/ECS/Core/Query/index.js.map +1 -0
- package/bin/ECS/Core/QuerySystem.d.ts +458 -0
- package/bin/ECS/Core/QuerySystem.d.ts.map +1 -0
- package/bin/ECS/Core/QuerySystem.js +1069 -0
- package/bin/ECS/Core/QuerySystem.js.map +1 -0
- package/bin/ECS/Core/QueryTypes.d.ts +34 -0
- package/bin/ECS/Core/QueryTypes.d.ts.map +1 -0
- package/bin/ECS/Core/QueryTypes.js +13 -0
- package/bin/ECS/Core/QueryTypes.js.map +1 -0
- package/bin/ECS/Core/ReactiveQuery.d.ts +211 -0
- package/bin/ECS/Core/ReactiveQuery.d.ts.map +1 -0
- package/bin/ECS/Core/ReactiveQuery.js +401 -0
- package/bin/ECS/Core/ReactiveQuery.js.map +1 -0
- package/bin/ECS/Core/ReferenceTracker.d.ts +111 -0
- package/bin/ECS/Core/ReferenceTracker.d.ts.map +1 -0
- package/bin/ECS/Core/ReferenceTracker.js +254 -0
- package/bin/ECS/Core/ReferenceTracker.js.map +1 -0
- package/bin/ECS/Core/SoASerializer.d.ts +28 -0
- package/bin/ECS/Core/SoASerializer.d.ts.map +1 -0
- package/bin/ECS/Core/SoASerializer.js +85 -0
- package/bin/ECS/Core/SoASerializer.js.map +1 -0
- package/bin/ECS/Core/SoAStorage.d.ts +129 -0
- package/bin/ECS/Core/SoAStorage.d.ts.map +1 -0
- package/bin/ECS/Core/SoAStorage.js +685 -0
- package/bin/ECS/Core/SoAStorage.js.map +1 -0
- package/bin/ECS/Core/SoATypeRegistry.d.ts +50 -0
- package/bin/ECS/Core/SoATypeRegistry.d.ts.map +1 -0
- package/bin/ECS/Core/SoATypeRegistry.js +135 -0
- package/bin/ECS/Core/SoATypeRegistry.js.map +1 -0
- package/bin/ECS/Core/Storage/index.d.ts +4 -0
- package/bin/ECS/Core/Storage/index.d.ts.map +1 -0
- package/bin/ECS/Core/Storage/index.js +4 -0
- package/bin/ECS/Core/Storage/index.js.map +1 -0
- package/bin/ECS/Core/StorageDecorators.d.ts +20 -0
- package/bin/ECS/Core/StorageDecorators.d.ts.map +1 -0
- package/bin/ECS/Core/StorageDecorators.js +27 -0
- package/bin/ECS/Core/StorageDecorators.js.map +1 -0
- package/bin/ECS/CoreEvents.d.ts +131 -0
- package/bin/ECS/CoreEvents.d.ts.map +1 -0
- package/bin/ECS/CoreEvents.js +163 -0
- package/bin/ECS/CoreEvents.js.map +1 -0
- package/bin/ECS/Decorators/EntityRefDecorator.d.ts +46 -0
- package/bin/ECS/Decorators/EntityRefDecorator.d.ts.map +1 -0
- package/bin/ECS/Decorators/EntityRefDecorator.js +118 -0
- package/bin/ECS/Decorators/EntityRefDecorator.js.map +1 -0
- package/bin/ECS/Decorators/PropertyDecorator.d.ts +168 -0
- package/bin/ECS/Decorators/PropertyDecorator.d.ts.map +1 -0
- package/bin/ECS/Decorators/PropertyDecorator.js +40 -0
- package/bin/ECS/Decorators/PropertyDecorator.js.map +1 -0
- package/bin/ECS/Decorators/TypeDecorators.d.ts +124 -0
- package/bin/ECS/Decorators/TypeDecorators.d.ts.map +1 -0
- package/bin/ECS/Decorators/TypeDecorators.js +151 -0
- package/bin/ECS/Decorators/TypeDecorators.js.map +1 -0
- package/bin/ECS/Decorators/index.d.ts +7 -0
- package/bin/ECS/Decorators/index.d.ts.map +1 -0
- package/bin/ECS/Decorators/index.js +4 -0
- package/bin/ECS/Decorators/index.js.map +1 -0
- package/bin/ECS/Entity.d.ts +415 -0
- package/bin/ECS/Entity.d.ts.map +1 -0
- package/bin/ECS/Entity.js +683 -0
- package/bin/ECS/Entity.js.map +1 -0
- package/bin/ECS/EntityTags.d.ts +71 -0
- package/bin/ECS/EntityTags.d.ts.map +1 -0
- package/bin/ECS/EntityTags.js +82 -0
- package/bin/ECS/EntityTags.js.map +1 -0
- package/bin/ECS/IScene.d.ts +308 -0
- package/bin/ECS/IScene.d.ts.map +1 -0
- package/bin/ECS/IScene.js +2 -0
- package/bin/ECS/IScene.js.map +1 -0
- package/bin/ECS/Scene.d.ts +799 -0
- package/bin/ECS/Scene.d.ts.map +1 -0
- package/bin/ECS/Scene.js +1203 -0
- package/bin/ECS/Scene.js.map +1 -0
- package/bin/ECS/SceneManager.d.ts +197 -0
- package/bin/ECS/SceneManager.d.ts.map +1 -0
- package/bin/ECS/SceneManager.js +264 -0
- package/bin/ECS/SceneManager.js.map +1 -0
- package/bin/ECS/Serialization/ComponentSerializer.d.ts +106 -0
- package/bin/ECS/Serialization/ComponentSerializer.d.ts.map +1 -0
- package/bin/ECS/Serialization/ComponentSerializer.js +251 -0
- package/bin/ECS/Serialization/ComponentSerializer.js.map +1 -0
- package/bin/ECS/Serialization/EntitySerializer.d.ts +111 -0
- package/bin/ECS/Serialization/EntitySerializer.d.ts.map +1 -0
- package/bin/ECS/Serialization/EntitySerializer.js +155 -0
- package/bin/ECS/Serialization/EntitySerializer.js.map +1 -0
- package/bin/ECS/Serialization/IncrementalSerializer.d.ts +259 -0
- package/bin/ECS/Serialization/IncrementalSerializer.d.ts.map +1 -0
- package/bin/ECS/Serialization/IncrementalSerializer.js +500 -0
- package/bin/ECS/Serialization/IncrementalSerializer.js.map +1 -0
- package/bin/ECS/Serialization/SceneSerializer.d.ts +213 -0
- package/bin/ECS/Serialization/SceneSerializer.d.ts.map +1 -0
- package/bin/ECS/Serialization/SceneSerializer.js +387 -0
- package/bin/ECS/Serialization/SceneSerializer.js.map +1 -0
- package/bin/ECS/Serialization/SerializationDecorators.d.ts +136 -0
- package/bin/ECS/Serialization/SerializationDecorators.d.ts.map +1 -0
- package/bin/ECS/Serialization/SerializationDecorators.js +216 -0
- package/bin/ECS/Serialization/SerializationDecorators.js.map +1 -0
- package/bin/ECS/Serialization/VersionMigration.d.ts +156 -0
- package/bin/ECS/Serialization/VersionMigration.d.ts.map +1 -0
- package/bin/ECS/Serialization/VersionMigration.js +279 -0
- package/bin/ECS/Serialization/VersionMigration.js.map +1 -0
- package/bin/ECS/Serialization/index.d.ts +18 -0
- package/bin/ECS/Serialization/index.d.ts.map +1 -0
- package/bin/ECS/Serialization/index.js +18 -0
- package/bin/ECS/Serialization/index.js.map +1 -0
- package/bin/ECS/Systems/EntityCache.d.ts +114 -0
- package/bin/ECS/Systems/EntityCache.d.ts.map +1 -0
- package/bin/ECS/Systems/EntityCache.js +145 -0
- package/bin/ECS/Systems/EntityCache.js.map +1 -0
- package/bin/ECS/Systems/EntitySystem.d.ts +591 -0
- package/bin/ECS/Systems/EntitySystem.d.ts.map +1 -0
- package/bin/ECS/Systems/EntitySystem.js +1102 -0
- package/bin/ECS/Systems/EntitySystem.js.map +1 -0
- package/bin/ECS/Systems/HierarchySystem.d.ts +155 -0
- package/bin/ECS/Systems/HierarchySystem.d.ts.map +1 -0
- package/bin/ECS/Systems/HierarchySystem.js +498 -0
- package/bin/ECS/Systems/HierarchySystem.js.map +1 -0
- package/bin/ECS/Systems/IntervalSystem.d.ts +33 -0
- package/bin/ECS/Systems/IntervalSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/IntervalSystem.js +50 -0
- package/bin/ECS/Systems/IntervalSystem.js.map +1 -0
- package/bin/ECS/Systems/PassiveSystem.d.ts +17 -0
- package/bin/ECS/Systems/PassiveSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/PassiveSystem.js +19 -0
- package/bin/ECS/Systems/PassiveSystem.js.map +1 -0
- package/bin/ECS/Systems/ProcessingSystem.d.ts +21 -0
- package/bin/ECS/Systems/ProcessingSystem.d.ts.map +1 -0
- package/bin/ECS/Systems/ProcessingSystem.js +20 -0
- package/bin/ECS/Systems/ProcessingSystem.js.map +1 -0
- package/bin/ECS/Systems/WorkerEntitySystem.d.ts +313 -0
- package/bin/ECS/Systems/WorkerEntitySystem.d.ts.map +1 -0
- package/bin/ECS/Systems/WorkerEntitySystem.js +792 -0
- package/bin/ECS/Systems/WorkerEntitySystem.js.map +1 -0
- package/bin/ECS/Systems/index.d.ts +8 -0
- package/bin/ECS/Systems/index.d.ts.map +1 -0
- package/bin/ECS/Systems/index.js +8 -0
- package/bin/ECS/Systems/index.js.map +1 -0
- package/bin/ECS/TypedEntity.d.ts +192 -0
- package/bin/ECS/TypedEntity.d.ts.map +1 -0
- package/bin/ECS/TypedEntity.js +254 -0
- package/bin/ECS/TypedEntity.js.map +1 -0
- package/bin/ECS/Utils/BigIntCompatibility.d.ts +151 -0
- package/bin/ECS/Utils/BigIntCompatibility.d.ts.map +1 -0
- package/bin/ECS/Utils/BigIntCompatibility.js +476 -0
- package/bin/ECS/Utils/BigIntCompatibility.js.map +1 -0
- package/bin/ECS/Utils/BitMaskHashMap.d.ts +28 -0
- package/bin/ECS/Utils/BitMaskHashMap.d.ts.map +1 -0
- package/bin/ECS/Utils/BitMaskHashMap.js +127 -0
- package/bin/ECS/Utils/BitMaskHashMap.js.map +1 -0
- package/bin/ECS/Utils/Bits.d.ts +154 -0
- package/bin/ECS/Utils/Bits.d.ts.map +1 -0
- package/bin/ECS/Utils/Bits.js +331 -0
- package/bin/ECS/Utils/Bits.js.map +1 -0
- package/bin/ECS/Utils/ComponentSparseSet.d.ts +143 -0
- package/bin/ECS/Utils/ComponentSparseSet.d.ts.map +1 -0
- package/bin/ECS/Utils/ComponentSparseSet.js +347 -0
- package/bin/ECS/Utils/ComponentSparseSet.js.map +1 -0
- package/bin/ECS/Utils/EntityList.d.ts +115 -0
- package/bin/ECS/Utils/EntityList.d.ts.map +1 -0
- package/bin/ECS/Utils/EntityList.js +258 -0
- package/bin/ECS/Utils/EntityList.js.map +1 -0
- package/bin/ECS/Utils/EntityProcessorList.d.ts +56 -0
- package/bin/ECS/Utils/EntityProcessorList.d.ts.map +1 -0
- package/bin/ECS/Utils/EntityProcessorList.js +113 -0
- package/bin/ECS/Utils/EntityProcessorList.js.map +1 -0
- package/bin/ECS/Utils/IdentifierPool.d.ts +203 -0
- package/bin/ECS/Utils/IdentifierPool.d.ts.map +1 -0
- package/bin/ECS/Utils/IdentifierPool.js +325 -0
- package/bin/ECS/Utils/IdentifierPool.js.map +1 -0
- package/bin/ECS/Utils/Matcher.d.ts +171 -0
- package/bin/ECS/Utils/Matcher.d.ts.map +1 -0
- package/bin/ECS/Utils/Matcher.js +293 -0
- package/bin/ECS/Utils/Matcher.js.map +1 -0
- package/bin/ECS/Utils/SparseSet.d.ts +170 -0
- package/bin/ECS/Utils/SparseSet.d.ts.map +1 -0
- package/bin/ECS/Utils/SparseSet.js +280 -0
- package/bin/ECS/Utils/SparseSet.js.map +1 -0
- package/bin/ECS/Utils/index.d.ts +9 -0
- package/bin/ECS/Utils/index.d.ts.map +1 -0
- package/bin/ECS/Utils/index.js +10 -0
- package/bin/ECS/Utils/index.js.map +1 -0
- package/bin/ECS/World.d.ts +238 -0
- package/bin/ECS/World.d.ts.map +1 -0
- package/bin/ECS/World.js +416 -0
- package/bin/ECS/World.js.map +1 -0
- package/bin/ECS/WorldManager.d.ts +224 -0
- package/bin/ECS/WorldManager.d.ts.map +1 -0
- package/bin/ECS/WorldManager.js +365 -0
- package/bin/ECS/WorldManager.js.map +1 -0
- package/bin/ECS/index.d.ts +26 -0
- package/bin/ECS/index.d.ts.map +1 -0
- package/bin/ECS/index.js +21 -0
- package/bin/ECS/index.js.map +1 -0
- package/bin/Platform/IPlatformAdapter.d.ts +169 -0
- package/bin/Platform/IPlatformAdapter.d.ts.map +1 -0
- package/bin/Platform/IPlatformAdapter.js +2 -0
- package/bin/Platform/IPlatformAdapter.js.map +1 -0
- package/bin/Platform/PlatformDetector.d.ts +56 -0
- package/bin/Platform/PlatformDetector.d.ts.map +1 -0
- package/bin/Platform/PlatformDetector.js +247 -0
- package/bin/Platform/PlatformDetector.js.map +1 -0
- package/bin/Platform/PlatformManager.d.ts +50 -0
- package/bin/Platform/PlatformManager.d.ts.map +1 -0
- package/bin/Platform/PlatformManager.js +114 -0
- package/bin/Platform/PlatformManager.js.map +1 -0
- package/bin/Platform/index.d.ts +19 -0
- package/bin/Platform/index.d.ts.map +1 -0
- package/bin/Platform/index.js +29 -0
- package/bin/Platform/index.js.map +1 -0
- package/bin/Plugins/DebugPlugin.d.ts +156 -0
- package/bin/Plugins/DebugPlugin.d.ts.map +1 -0
- package/bin/Plugins/DebugPlugin.js +248 -0
- package/bin/Plugins/DebugPlugin.js.map +1 -0
- package/bin/Plugins/index.d.ts +2 -0
- package/bin/Plugins/index.d.ts.map +1 -0
- package/bin/Plugins/index.js +2 -0
- package/bin/Plugins/index.js.map +1 -0
- package/bin/Types/IUpdatable.d.ts +18 -0
- package/bin/Types/IUpdatable.d.ts.map +1 -0
- package/bin/Types/IUpdatable.js +7 -0
- package/bin/Types/IUpdatable.js.map +1 -0
- package/bin/Types/TypeHelpers.d.ts +238 -0
- package/bin/Types/TypeHelpers.d.ts.map +1 -0
- package/bin/Types/TypeHelpers.js +19 -0
- package/bin/Types/TypeHelpers.js.map +1 -0
- package/bin/Types/index.d.ts +466 -0
- package/bin/Types/index.d.ts.map +1 -0
- package/bin/Types/index.js +7 -0
- package/bin/Types/index.js.map +1 -0
- package/bin/Utils/BinarySerializer.d.ts +23 -0
- package/bin/Utils/BinarySerializer.d.ts.map +1 -0
- package/bin/Utils/BinarySerializer.js +100 -0
- package/bin/Utils/BinarySerializer.js.map +1 -0
- package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts +153 -0
- package/bin/Utils/Debug/AdvancedProfilerCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/AdvancedProfilerCollector.js +406 -0
- package/bin/Utils/Debug/AdvancedProfilerCollector.js.map +1 -0
- package/bin/Utils/Debug/ComponentDataCollector.d.ts +32 -0
- package/bin/Utils/Debug/ComponentDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/ComponentDataCollector.js +250 -0
- package/bin/Utils/Debug/ComponentDataCollector.js.map +1 -0
- package/bin/Utils/Debug/DebugConfigService.d.ts +16 -0
- package/bin/Utils/Debug/DebugConfigService.d.ts.map +1 -0
- package/bin/Utils/Debug/DebugConfigService.js +42 -0
- package/bin/Utils/Debug/DebugConfigService.js.map +1 -0
- package/bin/Utils/Debug/DebugManager.d.ts +131 -0
- package/bin/Utils/Debug/DebugManager.d.ts.map +1 -0
- package/bin/Utils/Debug/DebugManager.js +848 -0
- package/bin/Utils/Debug/DebugManager.js.map +1 -0
- package/bin/Utils/Debug/EntityDataCollector.d.ts +115 -0
- package/bin/Utils/Debug/EntityDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/EntityDataCollector.js +870 -0
- package/bin/Utils/Debug/EntityDataCollector.js.map +1 -0
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts +31 -0
- package/bin/Utils/Debug/PerformanceDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/PerformanceDataCollector.js +203 -0
- package/bin/Utils/Debug/PerformanceDataCollector.js.map +1 -0
- package/bin/Utils/Debug/SceneDataCollector.d.ts +18 -0
- package/bin/Utils/Debug/SceneDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/SceneDataCollector.js +43 -0
- package/bin/Utils/Debug/SceneDataCollector.js.map +1 -0
- package/bin/Utils/Debug/SystemDataCollector.d.ts +14 -0
- package/bin/Utils/Debug/SystemDataCollector.d.ts.map +1 -0
- package/bin/Utils/Debug/SystemDataCollector.js +60 -0
- package/bin/Utils/Debug/SystemDataCollector.js.map +1 -0
- package/bin/Utils/Debug/WebSocketManager.d.ts +54 -0
- package/bin/Utils/Debug/WebSocketManager.d.ts.map +1 -0
- package/bin/Utils/Debug/WebSocketManager.js +141 -0
- package/bin/Utils/Debug/WebSocketManager.js.map +1 -0
- package/bin/Utils/Debug/index.d.ts +11 -0
- package/bin/Utils/Debug/index.d.ts.map +1 -0
- package/bin/Utils/Debug/index.js +10 -0
- package/bin/Utils/Debug/index.js.map +1 -0
- package/bin/Utils/Emitter.d.ts +61 -0
- package/bin/Utils/Emitter.d.ts.map +1 -0
- package/bin/Utils/Emitter.js +101 -0
- package/bin/Utils/Emitter.js.map +1 -0
- package/bin/Utils/Extensions/NumberExtension.d.ts +13 -0
- package/bin/Utils/Extensions/NumberExtension.d.ts.map +1 -0
- package/bin/Utils/Extensions/NumberExtension.js +17 -0
- package/bin/Utils/Extensions/NumberExtension.js.map +1 -0
- package/bin/Utils/Extensions/TypeUtils.d.ts +13 -0
- package/bin/Utils/Extensions/TypeUtils.d.ts.map +1 -0
- package/bin/Utils/Extensions/TypeUtils.js +15 -0
- package/bin/Utils/Extensions/TypeUtils.js.map +1 -0
- package/bin/Utils/Extensions/index.d.ts +3 -0
- package/bin/Utils/Extensions/index.d.ts.map +1 -0
- package/bin/Utils/Extensions/index.js +4 -0
- package/bin/Utils/Extensions/index.js.map +1 -0
- package/bin/Utils/GlobalManager.d.ts +29 -0
- package/bin/Utils/GlobalManager.d.ts.map +1 -0
- package/bin/Utils/GlobalManager.js +50 -0
- package/bin/Utils/GlobalManager.js.map +1 -0
- package/bin/Utils/Logger/ConsoleLogger.d.ts +74 -0
- package/bin/Utils/Logger/ConsoleLogger.d.ts.map +1 -0
- package/bin/Utils/Logger/ConsoleLogger.js +187 -0
- package/bin/Utils/Logger/ConsoleLogger.js.map +1 -0
- package/bin/Utils/Logger/Constants.d.ts +36 -0
- package/bin/Utils/Logger/Constants.d.ts.map +1 -0
- package/bin/Utils/Logger/Constants.js +40 -0
- package/bin/Utils/Logger/Constants.js.map +1 -0
- package/bin/Utils/Logger/LoggerManager.d.ts +91 -0
- package/bin/Utils/Logger/LoggerManager.d.ts.map +1 -0
- package/bin/Utils/Logger/LoggerManager.js +167 -0
- package/bin/Utils/Logger/LoggerManager.js.map +1 -0
- package/bin/Utils/Logger/Types.d.ts +40 -0
- package/bin/Utils/Logger/Types.d.ts.map +1 -0
- package/bin/Utils/Logger/Types.js +2 -0
- package/bin/Utils/Logger/Types.js.map +1 -0
- package/bin/Utils/Logger/index.d.ts +5 -0
- package/bin/Utils/Logger/index.d.ts.map +1 -0
- package/bin/Utils/Logger/index.js +5 -0
- package/bin/Utils/Logger/index.js.map +1 -0
- package/bin/Utils/PerformanceMonitor.d.ts +196 -0
- package/bin/Utils/PerformanceMonitor.d.ts.map +1 -0
- package/bin/Utils/PerformanceMonitor.js +244 -0
- package/bin/Utils/PerformanceMonitor.js.map +1 -0
- package/bin/Utils/Pool/IPoolable.d.ts +29 -0
- package/bin/Utils/Pool/IPoolable.d.ts.map +1 -0
- package/bin/Utils/Pool/IPoolable.js +2 -0
- package/bin/Utils/Pool/IPoolable.js.map +1 -0
- package/bin/Utils/Pool/Pool.d.ts +109 -0
- package/bin/Utils/Pool/Pool.d.ts.map +1 -0
- package/bin/Utils/Pool/Pool.js +238 -0
- package/bin/Utils/Pool/Pool.js.map +1 -0
- package/bin/Utils/Pool/PoolManager.d.ts +96 -0
- package/bin/Utils/Pool/PoolManager.d.ts.map +1 -0
- package/bin/Utils/Pool/PoolManager.js +199 -0
- package/bin/Utils/Pool/PoolManager.js.map +1 -0
- package/bin/Utils/Pool/index.d.ts +4 -0
- package/bin/Utils/Pool/index.d.ts.map +1 -0
- package/bin/Utils/Pool/index.js +4 -0
- package/bin/Utils/Pool/index.js.map +1 -0
- package/bin/Utils/Profiler/AutoProfiler.d.ts +160 -0
- package/bin/Utils/Profiler/AutoProfiler.d.ts.map +1 -0
- package/bin/Utils/Profiler/AutoProfiler.js +503 -0
- package/bin/Utils/Profiler/AutoProfiler.js.map +1 -0
- package/bin/Utils/Profiler/ProfilerSDK.d.ts +175 -0
- package/bin/Utils/Profiler/ProfilerSDK.d.ts.map +1 -0
- package/bin/Utils/Profiler/ProfilerSDK.js +727 -0
- package/bin/Utils/Profiler/ProfilerSDK.js.map +1 -0
- package/bin/Utils/Profiler/ProfilerTypes.d.ts +218 -0
- package/bin/Utils/Profiler/ProfilerTypes.d.ts.map +1 -0
- package/bin/Utils/Profiler/ProfilerTypes.js +47 -0
- package/bin/Utils/Profiler/ProfilerTypes.js.map +1 -0
- package/bin/Utils/Profiler/index.d.ts +8 -0
- package/bin/Utils/Profiler/index.d.ts.map +1 -0
- package/bin/Utils/Profiler/index.js +7 -0
- package/bin/Utils/Profiler/index.js.map +1 -0
- package/bin/Utils/Time.d.ts +47 -0
- package/bin/Utils/Time.d.ts.map +1 -0
- package/bin/Utils/Time.js +64 -0
- package/bin/Utils/Time.js.map +1 -0
- package/bin/Utils/Timers/ITimer.d.ts +16 -0
- package/bin/Utils/Timers/ITimer.d.ts.map +1 -0
- package/bin/Utils/Timers/ITimer.js +2 -0
- package/bin/Utils/Timers/ITimer.js.map +1 -0
- package/bin/Utils/Timers/Timer.d.ts +30 -0
- package/bin/Utils/Timers/Timer.d.ts.map +1 -0
- package/bin/Utils/Timers/Timer.js +58 -0
- package/bin/Utils/Timers/Timer.js.map +1 -0
- package/bin/Utils/Timers/TimerManager.d.ts +26 -0
- package/bin/Utils/Timers/TimerManager.d.ts.map +1 -0
- package/bin/Utils/Timers/TimerManager.js +48 -0
- package/bin/Utils/Timers/TimerManager.js.map +1 -0
- package/bin/Utils/index.d.ts +11 -0
- package/bin/Utils/index.d.ts.map +1 -0
- package/bin/Utils/index.js +11 -0
- package/bin/Utils/index.js.map +1 -0
- package/bin/index.d.ts +29 -0
- package/bin/index.d.ts.map +1 -0
- package/bin/index.js +36 -0
- package/bin/index.js.map +1 -0
- package/package.json +84 -47
- package/index.cjs +0 -2
- package/index.cjs.map +0 -1
- package/index.d.ts +0 -13129
- package/index.es5.js +0 -4
- package/index.es5.js.map +0 -1
- package/index.mjs +0 -2
- package/index.mjs.map +0 -1
- package/index.umd.js +0 -4
- package/index.umd.js.map +0 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 性能分析器 SDK
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的性能分析接口,支持:
|
|
5
|
+
* - 手动采样标记
|
|
6
|
+
* - 自动作用域测量
|
|
7
|
+
* - 调用层级追踪
|
|
8
|
+
* - 计数器和仪表
|
|
9
|
+
*/
|
|
10
|
+
import { ProfileCategory, DEFAULT_PROFILER_CONFIG } from './ProfilerTypes';
|
|
11
|
+
let idCounter = 0;
|
|
12
|
+
function generateId() {
|
|
13
|
+
return `sample_${++idCounter}_${Date.now()}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 性能分析器 SDK
|
|
17
|
+
*/
|
|
18
|
+
export class ProfilerSDK {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.currentFrame = null;
|
|
21
|
+
this.frameHistory = [];
|
|
22
|
+
this.frameNumber = 0;
|
|
23
|
+
this.activeSamples = new Map();
|
|
24
|
+
this.sampleStack = [];
|
|
25
|
+
this.counters = new Map();
|
|
26
|
+
this.callGraph = new Map();
|
|
27
|
+
this.gcCount = 0;
|
|
28
|
+
this.previousHeapSize = 0;
|
|
29
|
+
this.longTasks = [];
|
|
30
|
+
this.performanceObserver = null;
|
|
31
|
+
this.config = { ...DEFAULT_PROFILER_CONFIG, ...config };
|
|
32
|
+
if (this.config.detectLongTasks) {
|
|
33
|
+
this.setupLongTaskObserver();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 获取单例实例
|
|
38
|
+
*/
|
|
39
|
+
static getInstance(config) {
|
|
40
|
+
if (!ProfilerSDK.instance) {
|
|
41
|
+
ProfilerSDK.instance = new ProfilerSDK(config);
|
|
42
|
+
}
|
|
43
|
+
return ProfilerSDK.instance;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 重置实例(测试用)
|
|
47
|
+
*/
|
|
48
|
+
static resetInstance() {
|
|
49
|
+
if (ProfilerSDK.instance) {
|
|
50
|
+
ProfilerSDK.instance.dispose();
|
|
51
|
+
ProfilerSDK.instance = null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 开始采样
|
|
56
|
+
*/
|
|
57
|
+
static beginSample(name, category = ProfileCategory.Custom) {
|
|
58
|
+
return ProfilerSDK.getInstance().beginSample(name, category);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 结束采样
|
|
62
|
+
*/
|
|
63
|
+
static endSample(handle) {
|
|
64
|
+
if (handle) {
|
|
65
|
+
ProfilerSDK.getInstance().endSample(handle);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 测量同步函数执行时间
|
|
70
|
+
*/
|
|
71
|
+
static measure(name, fn, category = ProfileCategory.Custom) {
|
|
72
|
+
return ProfilerSDK.getInstance().measure(name, fn, category);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 测量异步函数执行时间
|
|
76
|
+
*/
|
|
77
|
+
static async measureAsync(name, fn, category = ProfileCategory.Custom) {
|
|
78
|
+
return ProfilerSDK.getInstance().measureAsync(name, fn, category);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 开始帧
|
|
82
|
+
*/
|
|
83
|
+
static beginFrame() {
|
|
84
|
+
ProfilerSDK.getInstance().beginFrame();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 结束帧
|
|
88
|
+
*/
|
|
89
|
+
static endFrame() {
|
|
90
|
+
ProfilerSDK.getInstance().endFrame();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 递增计数器
|
|
94
|
+
*/
|
|
95
|
+
static incrementCounter(name, value = 1, category = ProfileCategory.Custom) {
|
|
96
|
+
ProfilerSDK.getInstance().incrementCounter(name, value, category);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 设置仪表值
|
|
100
|
+
*/
|
|
101
|
+
static setGauge(name, value, category = ProfileCategory.Custom) {
|
|
102
|
+
ProfilerSDK.getInstance().setGauge(name, value, category);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 启用/禁用分析器
|
|
106
|
+
*/
|
|
107
|
+
static setEnabled(enabled) {
|
|
108
|
+
ProfilerSDK.getInstance().setEnabled(enabled);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 检查是否启用
|
|
112
|
+
*/
|
|
113
|
+
static isEnabled() {
|
|
114
|
+
return ProfilerSDK.getInstance().config.enabled;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 获取当前帧数据
|
|
118
|
+
*/
|
|
119
|
+
static getCurrentFrame() {
|
|
120
|
+
return ProfilerSDK.getInstance().currentFrame;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 获取帧历史
|
|
124
|
+
*/
|
|
125
|
+
static getFrameHistory() {
|
|
126
|
+
return ProfilerSDK.getInstance().frameHistory;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 获取分析报告
|
|
130
|
+
*/
|
|
131
|
+
static getReport(frameCount) {
|
|
132
|
+
return ProfilerSDK.getInstance().generateReport(frameCount);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 重置数据
|
|
136
|
+
*/
|
|
137
|
+
static reset() {
|
|
138
|
+
ProfilerSDK.getInstance().reset();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 开始采样
|
|
142
|
+
*/
|
|
143
|
+
beginSample(name, category = ProfileCategory.Custom) {
|
|
144
|
+
if (!this.config.enabled || !this.config.enabledCategories.has(category)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const parentHandle = this.sampleStack.length > 0
|
|
148
|
+
? this.sampleStack[this.sampleStack.length - 1]
|
|
149
|
+
: undefined;
|
|
150
|
+
if (parentHandle && this.sampleStack.length >= this.config.maxSampleDepth) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const handle = {
|
|
154
|
+
id: generateId(),
|
|
155
|
+
name,
|
|
156
|
+
category,
|
|
157
|
+
startTime: performance.now(),
|
|
158
|
+
depth: this.sampleStack.length,
|
|
159
|
+
parentId: parentHandle?.id
|
|
160
|
+
};
|
|
161
|
+
this.activeSamples.set(handle.id, handle);
|
|
162
|
+
this.sampleStack.push(handle);
|
|
163
|
+
return handle;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 结束采样
|
|
167
|
+
*/
|
|
168
|
+
endSample(handle) {
|
|
169
|
+
if (!this.config.enabled || !this.activeSamples.has(handle.id)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const endTime = performance.now();
|
|
173
|
+
const duration = endTime - handle.startTime;
|
|
174
|
+
// 获取父级 handle(在删除当前 handle 之前)
|
|
175
|
+
const parentHandle = handle.parentId ? this.activeSamples.get(handle.parentId) : undefined;
|
|
176
|
+
const sample = {
|
|
177
|
+
id: handle.id,
|
|
178
|
+
name: handle.name,
|
|
179
|
+
category: handle.category,
|
|
180
|
+
startTime: handle.startTime,
|
|
181
|
+
endTime,
|
|
182
|
+
duration,
|
|
183
|
+
selfTime: duration,
|
|
184
|
+
parentId: handle.parentId,
|
|
185
|
+
parentName: parentHandle?.name,
|
|
186
|
+
depth: handle.depth,
|
|
187
|
+
callCount: 1
|
|
188
|
+
};
|
|
189
|
+
if (this.currentFrame) {
|
|
190
|
+
this.currentFrame.samples.push(sample);
|
|
191
|
+
}
|
|
192
|
+
this.updateCallGraph(handle.name, handle.category, duration, parentHandle);
|
|
193
|
+
this.activeSamples.delete(handle.id);
|
|
194
|
+
const stackIndex = this.sampleStack.indexOf(handle);
|
|
195
|
+
if (stackIndex !== -1) {
|
|
196
|
+
this.sampleStack.splice(stackIndex, 1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 测量同步函数
|
|
201
|
+
*/
|
|
202
|
+
measure(name, fn, category = ProfileCategory.Custom) {
|
|
203
|
+
const handle = this.beginSample(name, category);
|
|
204
|
+
try {
|
|
205
|
+
return fn();
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
if (handle) {
|
|
209
|
+
this.endSample(handle);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* 测量异步函数
|
|
215
|
+
*/
|
|
216
|
+
async measureAsync(name, fn, category = ProfileCategory.Custom) {
|
|
217
|
+
const handle = this.beginSample(name, category);
|
|
218
|
+
try {
|
|
219
|
+
return await fn();
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
if (handle) {
|
|
223
|
+
this.endSample(handle);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* 开始帧
|
|
229
|
+
*/
|
|
230
|
+
beginFrame() {
|
|
231
|
+
if (!this.config.enabled)
|
|
232
|
+
return;
|
|
233
|
+
this.frameNumber++;
|
|
234
|
+
this.currentFrame = {
|
|
235
|
+
frameNumber: this.frameNumber,
|
|
236
|
+
startTime: performance.now(),
|
|
237
|
+
endTime: 0,
|
|
238
|
+
duration: 0,
|
|
239
|
+
samples: [],
|
|
240
|
+
sampleStats: [],
|
|
241
|
+
counters: new Map(this.counters),
|
|
242
|
+
memory: this.captureMemory(),
|
|
243
|
+
categoryStats: new Map()
|
|
244
|
+
};
|
|
245
|
+
this.resetFrameCounters();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* 结束帧
|
|
249
|
+
*/
|
|
250
|
+
endFrame() {
|
|
251
|
+
if (!this.config.enabled || !this.currentFrame)
|
|
252
|
+
return;
|
|
253
|
+
this.currentFrame.endTime = performance.now();
|
|
254
|
+
this.currentFrame.duration = this.currentFrame.endTime - this.currentFrame.startTime;
|
|
255
|
+
this.calculateSampleStats();
|
|
256
|
+
this.calculateCategoryStats();
|
|
257
|
+
this.frameHistory.push(this.currentFrame);
|
|
258
|
+
while (this.frameHistory.length > this.config.maxFrameHistory) {
|
|
259
|
+
this.frameHistory.shift();
|
|
260
|
+
}
|
|
261
|
+
this.sampleStack = [];
|
|
262
|
+
this.activeSamples.clear();
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 递增计数器
|
|
266
|
+
*/
|
|
267
|
+
incrementCounter(name, value = 1, category = ProfileCategory.Custom) {
|
|
268
|
+
if (!this.config.enabled)
|
|
269
|
+
return;
|
|
270
|
+
let counter = this.counters.get(name);
|
|
271
|
+
if (!counter) {
|
|
272
|
+
counter = {
|
|
273
|
+
name,
|
|
274
|
+
category,
|
|
275
|
+
value: 0,
|
|
276
|
+
type: 'counter',
|
|
277
|
+
history: []
|
|
278
|
+
};
|
|
279
|
+
this.counters.set(name, counter);
|
|
280
|
+
}
|
|
281
|
+
counter.value += value;
|
|
282
|
+
counter.history.push({ time: performance.now(), value: counter.value });
|
|
283
|
+
if (counter.history.length > 100) {
|
|
284
|
+
counter.history.shift();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 设置仪表值
|
|
289
|
+
*/
|
|
290
|
+
setGauge(name, value, category = ProfileCategory.Custom) {
|
|
291
|
+
if (!this.config.enabled)
|
|
292
|
+
return;
|
|
293
|
+
let counter = this.counters.get(name);
|
|
294
|
+
if (!counter) {
|
|
295
|
+
counter = {
|
|
296
|
+
name,
|
|
297
|
+
category,
|
|
298
|
+
value: 0,
|
|
299
|
+
type: 'gauge',
|
|
300
|
+
history: []
|
|
301
|
+
};
|
|
302
|
+
this.counters.set(name, counter);
|
|
303
|
+
}
|
|
304
|
+
counter.value = value;
|
|
305
|
+
counter.history.push({ time: performance.now(), value });
|
|
306
|
+
if (counter.history.length > 100) {
|
|
307
|
+
counter.history.shift();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 设置启用状态
|
|
312
|
+
*/
|
|
313
|
+
setEnabled(enabled) {
|
|
314
|
+
this.config.enabled = enabled;
|
|
315
|
+
if (enabled && this.config.detectLongTasks && !this.performanceObserver) {
|
|
316
|
+
this.setupLongTaskObserver();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 重置数据
|
|
321
|
+
*/
|
|
322
|
+
reset() {
|
|
323
|
+
this.frameHistory = [];
|
|
324
|
+
this.currentFrame = null;
|
|
325
|
+
this.frameNumber = 0;
|
|
326
|
+
this.activeSamples.clear();
|
|
327
|
+
this.sampleStack = [];
|
|
328
|
+
this.counters.clear();
|
|
329
|
+
this.callGraph.clear();
|
|
330
|
+
this.gcCount = 0;
|
|
331
|
+
this.longTasks = [];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* 生成分析报告
|
|
335
|
+
*/
|
|
336
|
+
generateReport(frameCount) {
|
|
337
|
+
const frames = frameCount
|
|
338
|
+
? this.frameHistory.slice(-frameCount)
|
|
339
|
+
: this.frameHistory;
|
|
340
|
+
if (frames.length === 0) {
|
|
341
|
+
return this.createEmptyReport();
|
|
342
|
+
}
|
|
343
|
+
const frameTimes = frames.map((f) => f.duration);
|
|
344
|
+
const sortedTimes = [...frameTimes].sort((a, b) => a - b);
|
|
345
|
+
const aggregatedStats = this.aggregateSampleStats(frames);
|
|
346
|
+
const hotspots = aggregatedStats
|
|
347
|
+
.sort((a, b) => b.inclusiveTime - a.inclusiveTime)
|
|
348
|
+
.slice(0, 20);
|
|
349
|
+
const categoryBreakdown = this.aggregateCategoryStats(frames);
|
|
350
|
+
// 根据帧历史重新计算 callGraph(不使用全局累积的数据)
|
|
351
|
+
const callGraph = this.buildCallGraphFromFrames(frames);
|
|
352
|
+
const firstFrame = frames[0];
|
|
353
|
+
const lastFrame = frames[frames.length - 1];
|
|
354
|
+
return {
|
|
355
|
+
startTime: firstFrame?.startTime ?? 0,
|
|
356
|
+
endTime: lastFrame?.endTime ?? 0,
|
|
357
|
+
totalFrames: frames.length,
|
|
358
|
+
averageFrameTime: frameTimes.reduce((a, b) => a + b, 0) / frameTimes.length,
|
|
359
|
+
minFrameTime: Math.min(...frameTimes),
|
|
360
|
+
maxFrameTime: Math.max(...frameTimes),
|
|
361
|
+
p95FrameTime: sortedTimes[Math.floor(sortedTimes.length * 0.95)] || 0,
|
|
362
|
+
p99FrameTime: sortedTimes[Math.floor(sortedTimes.length * 0.99)] || 0,
|
|
363
|
+
hotspots,
|
|
364
|
+
callGraph,
|
|
365
|
+
categoryBreakdown,
|
|
366
|
+
memoryTrend: frames.map((f) => f.memory),
|
|
367
|
+
longTasks: [...this.longTasks]
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* 从帧历史构建调用图
|
|
372
|
+
* 注意:totalTime 存储的是平均耗时(总耗时/调用次数),而不是累计总耗时
|
|
373
|
+
*/
|
|
374
|
+
buildCallGraphFromFrames(frames) {
|
|
375
|
+
// 临时存储累计数据
|
|
376
|
+
const tempData = new Map();
|
|
377
|
+
for (const frame of frames) {
|
|
378
|
+
for (const sample of frame.samples) {
|
|
379
|
+
// 获取或创建当前函数的节点
|
|
380
|
+
let node = tempData.get(sample.name);
|
|
381
|
+
if (!node) {
|
|
382
|
+
node = {
|
|
383
|
+
category: sample.category,
|
|
384
|
+
callCount: 0,
|
|
385
|
+
totalTime: 0,
|
|
386
|
+
callers: new Map(),
|
|
387
|
+
callees: new Map()
|
|
388
|
+
};
|
|
389
|
+
tempData.set(sample.name, node);
|
|
390
|
+
}
|
|
391
|
+
node.callCount++;
|
|
392
|
+
node.totalTime += sample.duration;
|
|
393
|
+
// 如果有父级,建立调用关系
|
|
394
|
+
if (sample.parentName) {
|
|
395
|
+
// 记录当前函数被谁调用
|
|
396
|
+
const callerData = node.callers.get(sample.parentName) || { count: 0, totalTime: 0 };
|
|
397
|
+
callerData.count++;
|
|
398
|
+
callerData.totalTime += sample.duration;
|
|
399
|
+
node.callers.set(sample.parentName, callerData);
|
|
400
|
+
// 确保父节点存在并记录它调用了谁
|
|
401
|
+
let parentNode = tempData.get(sample.parentName);
|
|
402
|
+
if (!parentNode) {
|
|
403
|
+
parentNode = {
|
|
404
|
+
category: sample.category,
|
|
405
|
+
callCount: 0,
|
|
406
|
+
totalTime: 0,
|
|
407
|
+
callers: new Map(),
|
|
408
|
+
callees: new Map()
|
|
409
|
+
};
|
|
410
|
+
tempData.set(sample.parentName, parentNode);
|
|
411
|
+
}
|
|
412
|
+
const calleeData = parentNode.callees.get(sample.name) || { count: 0, totalTime: 0 };
|
|
413
|
+
calleeData.count++;
|
|
414
|
+
calleeData.totalTime += sample.duration;
|
|
415
|
+
parentNode.callees.set(sample.name, calleeData);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// 转换为最终结果,将 totalTime 改为平均耗时
|
|
420
|
+
const callGraph = new Map();
|
|
421
|
+
for (const [name, data] of tempData) {
|
|
422
|
+
const avgCallers = new Map();
|
|
423
|
+
for (const [callerName, callerData] of data.callers) {
|
|
424
|
+
avgCallers.set(callerName, {
|
|
425
|
+
count: callerData.count,
|
|
426
|
+
totalTime: callerData.count > 0 ? callerData.totalTime / callerData.count : 0
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
const avgCallees = new Map();
|
|
430
|
+
for (const [calleeName, calleeData] of data.callees) {
|
|
431
|
+
avgCallees.set(calleeName, {
|
|
432
|
+
count: calleeData.count,
|
|
433
|
+
totalTime: calleeData.count > 0 ? calleeData.totalTime / calleeData.count : 0
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
callGraph.set(name, {
|
|
437
|
+
name,
|
|
438
|
+
category: data.category,
|
|
439
|
+
callCount: data.callCount,
|
|
440
|
+
totalTime: data.callCount > 0 ? data.totalTime / data.callCount : 0,
|
|
441
|
+
callers: avgCallers,
|
|
442
|
+
callees: avgCallees
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
return callGraph;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* 获取调用图数据
|
|
449
|
+
*/
|
|
450
|
+
getCallGraph() {
|
|
451
|
+
return new Map(this.callGraph);
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* 获取特定函数的调用关系
|
|
455
|
+
*/
|
|
456
|
+
getFunctionCallInfo(name) {
|
|
457
|
+
const node = this.callGraph.get(name);
|
|
458
|
+
if (!node)
|
|
459
|
+
return null;
|
|
460
|
+
return {
|
|
461
|
+
callers: Array.from(node.callers.entries()).map(([name, data]) => ({
|
|
462
|
+
name,
|
|
463
|
+
...data
|
|
464
|
+
})),
|
|
465
|
+
callees: Array.from(node.callees.entries()).map(([name, data]) => ({
|
|
466
|
+
name,
|
|
467
|
+
...data
|
|
468
|
+
}))
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* 释放资源
|
|
473
|
+
*/
|
|
474
|
+
dispose() {
|
|
475
|
+
if (this.performanceObserver) {
|
|
476
|
+
this.performanceObserver.disconnect();
|
|
477
|
+
this.performanceObserver = null;
|
|
478
|
+
}
|
|
479
|
+
this.reset();
|
|
480
|
+
}
|
|
481
|
+
captureMemory() {
|
|
482
|
+
const now = performance.now();
|
|
483
|
+
let usedHeapSize = 0;
|
|
484
|
+
let totalHeapSize = 0;
|
|
485
|
+
let heapSizeLimit = 0;
|
|
486
|
+
const perfWithMemory = performance;
|
|
487
|
+
if (perfWithMemory.memory) {
|
|
488
|
+
usedHeapSize = perfWithMemory.memory.usedJSHeapSize || 0;
|
|
489
|
+
totalHeapSize = perfWithMemory.memory.totalJSHeapSize || 0;
|
|
490
|
+
heapSizeLimit = perfWithMemory.memory.jsHeapSizeLimit || 0;
|
|
491
|
+
if (this.previousHeapSize > 0 && usedHeapSize < this.previousHeapSize - 1024 * 1024) {
|
|
492
|
+
this.gcCount++;
|
|
493
|
+
}
|
|
494
|
+
this.previousHeapSize = usedHeapSize;
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
timestamp: now,
|
|
498
|
+
usedHeapSize,
|
|
499
|
+
totalHeapSize,
|
|
500
|
+
heapSizeLimit,
|
|
501
|
+
utilizationPercent: heapSizeLimit > 0 ? (usedHeapSize / heapSizeLimit) * 100 : 0,
|
|
502
|
+
gcCount: this.gcCount
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
resetFrameCounters() {
|
|
506
|
+
for (const counter of this.counters.values()) {
|
|
507
|
+
if (counter.type === 'counter') {
|
|
508
|
+
counter.value = 0;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
calculateSampleStats() {
|
|
513
|
+
if (!this.currentFrame)
|
|
514
|
+
return;
|
|
515
|
+
const sampleMap = new Map();
|
|
516
|
+
for (const sample of this.currentFrame.samples) {
|
|
517
|
+
let stats = sampleMap.get(sample.name);
|
|
518
|
+
if (!stats) {
|
|
519
|
+
stats = {
|
|
520
|
+
name: sample.name,
|
|
521
|
+
category: sample.category,
|
|
522
|
+
inclusiveTime: 0,
|
|
523
|
+
exclusiveTime: 0,
|
|
524
|
+
callCount: 0,
|
|
525
|
+
averageTime: 0,
|
|
526
|
+
minTime: Number.MAX_VALUE,
|
|
527
|
+
maxTime: 0,
|
|
528
|
+
percentOfFrame: 0,
|
|
529
|
+
percentOfParent: 0,
|
|
530
|
+
children: [],
|
|
531
|
+
depth: sample.depth
|
|
532
|
+
};
|
|
533
|
+
sampleMap.set(sample.name, stats);
|
|
534
|
+
}
|
|
535
|
+
stats.inclusiveTime += sample.duration;
|
|
536
|
+
stats.callCount += 1;
|
|
537
|
+
stats.minTime = Math.min(stats.minTime, sample.duration);
|
|
538
|
+
stats.maxTime = Math.max(stats.maxTime, sample.duration);
|
|
539
|
+
}
|
|
540
|
+
for (const sample of this.currentFrame.samples) {
|
|
541
|
+
if (sample.parentId) {
|
|
542
|
+
const parentSample = this.currentFrame.samples.find((s) => s.id === sample.parentId);
|
|
543
|
+
if (parentSample) {
|
|
544
|
+
const parentStats = sampleMap.get(parentSample.name);
|
|
545
|
+
if (parentStats) {
|
|
546
|
+
parentStats.exclusiveTime = parentStats.inclusiveTime;
|
|
547
|
+
for (const childSample of this.currentFrame.samples) {
|
|
548
|
+
if (childSample.parentId === parentSample.id) {
|
|
549
|
+
parentStats.exclusiveTime -= childSample.duration;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const frameDuration = this.currentFrame.duration || 1;
|
|
557
|
+
for (const stats of sampleMap.values()) {
|
|
558
|
+
stats.averageTime = stats.inclusiveTime / stats.callCount;
|
|
559
|
+
stats.percentOfFrame = (stats.inclusiveTime / frameDuration) * 100;
|
|
560
|
+
if (stats.exclusiveTime === 0) {
|
|
561
|
+
stats.exclusiveTime = stats.inclusiveTime;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
this.currentFrame.sampleStats = Array.from(sampleMap.values())
|
|
565
|
+
.sort((a, b) => b.inclusiveTime - a.inclusiveTime);
|
|
566
|
+
}
|
|
567
|
+
calculateCategoryStats() {
|
|
568
|
+
if (!this.currentFrame)
|
|
569
|
+
return;
|
|
570
|
+
const categoryMap = new Map();
|
|
571
|
+
for (const sample of this.currentFrame.samples) {
|
|
572
|
+
if (sample.depth === 0) {
|
|
573
|
+
let stats = categoryMap.get(sample.category);
|
|
574
|
+
if (!stats) {
|
|
575
|
+
stats = { totalTime: 0, sampleCount: 0 };
|
|
576
|
+
categoryMap.set(sample.category, stats);
|
|
577
|
+
}
|
|
578
|
+
stats.totalTime += sample.duration;
|
|
579
|
+
stats.sampleCount += 1;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const frameDuration = this.currentFrame.duration || 1;
|
|
583
|
+
for (const [category, stats] of categoryMap) {
|
|
584
|
+
this.currentFrame.categoryStats.set(category, {
|
|
585
|
+
...stats,
|
|
586
|
+
percentOfFrame: (stats.totalTime / frameDuration) * 100
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
updateCallGraph(name, category, duration, parentHandle) {
|
|
591
|
+
let node = this.callGraph.get(name);
|
|
592
|
+
if (!node) {
|
|
593
|
+
node = {
|
|
594
|
+
name,
|
|
595
|
+
category,
|
|
596
|
+
callCount: 0,
|
|
597
|
+
totalTime: 0,
|
|
598
|
+
callers: new Map(),
|
|
599
|
+
callees: new Map()
|
|
600
|
+
};
|
|
601
|
+
this.callGraph.set(name, node);
|
|
602
|
+
}
|
|
603
|
+
node.callCount++;
|
|
604
|
+
node.totalTime += duration;
|
|
605
|
+
// 如果有父级,建立调用关系
|
|
606
|
+
if (parentHandle) {
|
|
607
|
+
// 记录当前函数被谁调用
|
|
608
|
+
const callerData = node.callers.get(parentHandle.name) || { count: 0, totalTime: 0 };
|
|
609
|
+
callerData.count++;
|
|
610
|
+
callerData.totalTime += duration;
|
|
611
|
+
node.callers.set(parentHandle.name, callerData);
|
|
612
|
+
// 确保父节点存在
|
|
613
|
+
let parentNode = this.callGraph.get(parentHandle.name);
|
|
614
|
+
if (!parentNode) {
|
|
615
|
+
parentNode = {
|
|
616
|
+
name: parentHandle.name,
|
|
617
|
+
category: parentHandle.category,
|
|
618
|
+
callCount: 0,
|
|
619
|
+
totalTime: 0,
|
|
620
|
+
callers: new Map(),
|
|
621
|
+
callees: new Map()
|
|
622
|
+
};
|
|
623
|
+
this.callGraph.set(parentHandle.name, parentNode);
|
|
624
|
+
}
|
|
625
|
+
// 记录父函数调用了谁
|
|
626
|
+
const calleeData = parentNode.callees.get(name) || { count: 0, totalTime: 0 };
|
|
627
|
+
calleeData.count++;
|
|
628
|
+
calleeData.totalTime += duration;
|
|
629
|
+
parentNode.callees.set(name, calleeData);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
aggregateSampleStats(frames) {
|
|
633
|
+
const aggregated = new Map();
|
|
634
|
+
for (const frame of frames) {
|
|
635
|
+
for (const stats of frame.sampleStats) {
|
|
636
|
+
let agg = aggregated.get(stats.name);
|
|
637
|
+
if (!agg) {
|
|
638
|
+
agg = {
|
|
639
|
+
...stats,
|
|
640
|
+
minTime: Number.MAX_VALUE
|
|
641
|
+
};
|
|
642
|
+
aggregated.set(stats.name, agg);
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
agg.inclusiveTime += stats.inclusiveTime;
|
|
646
|
+
agg.exclusiveTime += stats.exclusiveTime;
|
|
647
|
+
agg.callCount += stats.callCount;
|
|
648
|
+
agg.minTime = Math.min(agg.minTime, stats.minTime);
|
|
649
|
+
agg.maxTime = Math.max(agg.maxTime, stats.maxTime);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const totalTime = frames.reduce((sum, f) => sum + f.duration, 0);
|
|
654
|
+
for (const stats of aggregated.values()) {
|
|
655
|
+
stats.averageTime = stats.inclusiveTime / stats.callCount;
|
|
656
|
+
stats.percentOfFrame = (stats.inclusiveTime / totalTime) * 100;
|
|
657
|
+
}
|
|
658
|
+
return Array.from(aggregated.values());
|
|
659
|
+
}
|
|
660
|
+
aggregateCategoryStats(frames) {
|
|
661
|
+
const aggregated = new Map();
|
|
662
|
+
for (const frame of frames) {
|
|
663
|
+
for (const [category, stats] of frame.categoryStats) {
|
|
664
|
+
let agg = aggregated.get(category);
|
|
665
|
+
if (!agg) {
|
|
666
|
+
agg = { totalTime: 0, frameCount: 0 };
|
|
667
|
+
aggregated.set(category, agg);
|
|
668
|
+
}
|
|
669
|
+
agg.totalTime += stats.totalTime;
|
|
670
|
+
agg.frameCount++;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const totalTime = frames.reduce((sum, f) => sum + f.duration, 0);
|
|
674
|
+
const result = new Map();
|
|
675
|
+
for (const [category, agg] of aggregated) {
|
|
676
|
+
result.set(category, {
|
|
677
|
+
totalTime: agg.totalTime,
|
|
678
|
+
averageTime: agg.frameCount > 0 ? agg.totalTime / agg.frameCount : 0,
|
|
679
|
+
percentOfTotal: totalTime > 0 ? (agg.totalTime / totalTime) * 100 : 0
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
return result;
|
|
683
|
+
}
|
|
684
|
+
setupLongTaskObserver() {
|
|
685
|
+
if (typeof PerformanceObserver === 'undefined')
|
|
686
|
+
return;
|
|
687
|
+
try {
|
|
688
|
+
this.performanceObserver = new PerformanceObserver((list) => {
|
|
689
|
+
for (const entry of list.getEntries()) {
|
|
690
|
+
if (entry.duration > this.config.longTaskThreshold) {
|
|
691
|
+
this.longTasks.push({
|
|
692
|
+
startTime: entry.startTime,
|
|
693
|
+
duration: entry.duration,
|
|
694
|
+
attribution: entry.attribution?.map((a) => a.name) || []
|
|
695
|
+
});
|
|
696
|
+
if (this.longTasks.length > 100) {
|
|
697
|
+
this.longTasks.shift();
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
this.performanceObserver.observe({ entryTypes: ['longtask'] });
|
|
703
|
+
}
|
|
704
|
+
catch {
|
|
705
|
+
// Long Task API not supported
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
createEmptyReport() {
|
|
709
|
+
return {
|
|
710
|
+
startTime: 0,
|
|
711
|
+
endTime: 0,
|
|
712
|
+
totalFrames: 0,
|
|
713
|
+
averageFrameTime: 0,
|
|
714
|
+
minFrameTime: 0,
|
|
715
|
+
maxFrameTime: 0,
|
|
716
|
+
p95FrameTime: 0,
|
|
717
|
+
p99FrameTime: 0,
|
|
718
|
+
hotspots: [],
|
|
719
|
+
callGraph: new Map(),
|
|
720
|
+
categoryBreakdown: new Map(),
|
|
721
|
+
memoryTrend: [],
|
|
722
|
+
longTasks: []
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
ProfilerSDK.instance = null;
|
|
727
|
+
//# sourceMappingURL=ProfilerSDK.js.map
|