@awesome-flow/ecs 0.12.0 → 0.14.1

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 (85) hide show
  1. package/dist/canvas/index.cjs +5 -0
  2. package/dist/canvas/index.d.cts +2 -0
  3. package/dist/canvas/index.d.mts +2 -0
  4. package/dist/canvas/index.mjs +3 -0
  5. package/dist/canvas-WWAJ6C2l.cjs +688 -0
  6. package/dist/canvas-WWAJ6C2l.cjs.map +1 -0
  7. package/dist/canvas-cO2NAQyX.mjs +677 -0
  8. package/dist/canvas-cO2NAQyX.mjs.map +1 -0
  9. package/dist/context/index.cjs +501 -0
  10. package/dist/context/index.cjs.map +1 -0
  11. package/dist/context/index.d.cts +2 -0
  12. package/dist/context/index.d.mts +2 -0
  13. package/dist/context/index.mjs +496 -0
  14. package/dist/context/index.mjs.map +1 -0
  15. package/dist/entity-component-inspector-CNaN8Scf.mjs +79 -0
  16. package/dist/entity-component-inspector-CNaN8Scf.mjs.map +1 -0
  17. package/dist/entity-component-inspector-VlwcaUqy.cjs +90 -0
  18. package/dist/entity-component-inspector-VlwcaUqy.cjs.map +1 -0
  19. package/dist/hooks/index.cjs +19 -0
  20. package/dist/hooks/index.d.cts +2 -0
  21. package/dist/hooks/index.d.mts +2 -0
  22. package/dist/hooks/index.mjs +3 -0
  23. package/dist/id-generator-C2_8g29M.cjs +45 -0
  24. package/dist/id-generator-C2_8g29M.cjs.map +1 -0
  25. package/dist/id-generator-DDsv3NdX.mjs +34 -0
  26. package/dist/id-generator-DDsv3NdX.mjs.map +1 -0
  27. package/dist/index-2l9Vdh2S.d.mts +54 -0
  28. package/dist/index-2l9Vdh2S.d.mts.map +1 -0
  29. package/dist/index-BFqa6aqs.d.mts +99 -0
  30. package/dist/index-BFqa6aqs.d.mts.map +1 -0
  31. package/dist/index-BTs_8SY-.d.cts +20 -0
  32. package/dist/index-BTs_8SY-.d.cts.map +1 -0
  33. package/dist/index-C3QIukqX.d.cts +157 -0
  34. package/dist/index-C3QIukqX.d.cts.map +1 -0
  35. package/dist/index-CPTq4oOA.d.cts +67 -0
  36. package/dist/index-CPTq4oOA.d.cts.map +1 -0
  37. package/dist/index-CyeezgDI.d.mts +20 -0
  38. package/dist/index-CyeezgDI.d.mts.map +1 -0
  39. package/dist/index-D9zIjQH9.d.mts +1 -0
  40. package/dist/index-DLoAMD9J.d.cts +1 -0
  41. package/dist/index-Ht3fVcsn.d.cts +54 -0
  42. package/dist/index-Ht3fVcsn.d.cts.map +1 -0
  43. package/dist/index-edb-X9uc.d.mts +157 -0
  44. package/dist/index-edb-X9uc.d.mts.map +1 -0
  45. package/dist/index-pInK6VDK.d.cts +99 -0
  46. package/dist/index-pInK6VDK.d.cts.map +1 -0
  47. package/dist/index-vf1CSWta.d.mts +67 -0
  48. package/dist/index-vf1CSWta.d.mts.map +1 -0
  49. package/dist/index.cjs +55 -531
  50. package/dist/index.d.cts +9 -106
  51. package/dist/index.d.mts +9 -106
  52. package/dist/index.mjs +10 -520
  53. package/dist/inspectors/index.cjs +6 -0
  54. package/dist/inspectors/index.d.cts +2 -0
  55. package/dist/inspectors/index.d.mts +2 -0
  56. package/dist/inspectors/index.mjs +3 -0
  57. package/dist/node-props-Bryks8-5.d.cts +45 -0
  58. package/dist/node-props-Bryks8-5.d.cts.map +1 -0
  59. package/dist/node-props-Cusf_qtn.d.mts +45 -0
  60. package/dist/node-props-Cusf_qtn.d.mts.map +1 -0
  61. package/dist/node-systems-module-B8aKhvBo.d.mts +22 -0
  62. package/dist/node-systems-module-B8aKhvBo.d.mts.map +1 -0
  63. package/dist/node-systems-module-Dx-hISbg.d.cts +22 -0
  64. package/dist/node-systems-module-Dx-hISbg.d.cts.map +1 -0
  65. package/dist/node-types-CNO_-52M.cjs +1866 -0
  66. package/dist/node-types-CNO_-52M.cjs.map +1 -0
  67. package/dist/node-types-l0GwV0mz.mjs +1651 -0
  68. package/dist/node-types-l0GwV0mz.mjs.map +1 -0
  69. package/dist/nodes/index.cjs +10 -0
  70. package/dist/nodes/index.d.cts +3 -0
  71. package/dist/nodes/index.d.mts +3 -0
  72. package/dist/nodes/index.mjs +3 -0
  73. package/dist/template-tool-nodes-CiwTFU-N.d.cts +35 -0
  74. package/dist/template-tool-nodes-CiwTFU-N.d.cts.map +1 -0
  75. package/dist/template-tool-nodes-DWhekyQg.d.mts +35 -0
  76. package/dist/template-tool-nodes-DWhekyQg.d.mts.map +1 -0
  77. package/dist/templates/index.cjs +11 -0
  78. package/dist/templates/index.d.cts +2 -0
  79. package/dist/templates/index.d.mts +2 -0
  80. package/dist/templates/index.mjs +3 -0
  81. package/package.json +85 -25
  82. package/dist/index.cjs.map +0 -1
  83. package/dist/index.d.cts.map +0 -1
  84. package/dist/index.d.mts.map +0 -1
  85. package/dist/index.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["EntityTypeUid","IEntityProxy","Node","EcsIdGenerator","EntityNodeData","ScopeGroupNodeData","SystemsModuleNodeData","EcsFlowRepository","nodes","Map","constructor","sizeNodes","size","addSystemModuleNode","node","set","data","entityType","toString","getSystemModuleNode","get","addScopeGroupNode","scope","scopeId","getScopeGroupNode","addEntityNode","entity","entityProxy","getEntityNode","addToolNode","tool","type","getToolNode","listAllNodes","Array","from","values","EntityEventUid","EntityUpdateType","EntityTypeUid","EntityUid","IEntity","IEntityEvent","IEntityEventsManager","IEntityModel","IEntityProxy","IEntityProxyRepository","IEntityRepository","IEntityRuntimeSchedulerInspector","IEntityUpdate","IEventData","PipelineCategory","PipelineCategoryName","SystemType","ISystemsModule","ISystemsModuleRepository","IPerformanceTimer","MiddlewareMetricsSummary","PerformanceTimeEntry","EcsEntitySpawnRequest","EcsEntityTypeDescriptor","EcsIdGenerator","EcsFlowRepository","INSTRUMENTATION","Symbol","for","InstrumentationListener","args","result","InstrumentedFunction","listeners","Set","original","EcsBridgeStoreName","EcsBridgeStore","getSnapshot","notify","subscribe","listener","TelemetryMetricsSource","metrics","ReadonlyMap","ReadonlyArray","clearMetrics","EntityUpdateCounts","removes","updates","EcsEventLogEntry","event","recordedAt","targets","EcsScopeSummary","entities","scopeId","scopedProxies","EcsEventStreamFilter","limit","source","target","type","EcsMetricsFilter","category","entityType","phase","PipelineMetricsSummary","avgMs","count","lastMs","maxMs","minMs","name","samples","totalMs","EcsSchedulerSnapshot","frameSubscriptions","isPaused","pendingCount","schedules","skippedEntityTypes","EcsUpdateQueueSnapshot","items","size","EcsBridgeInput","defaultScopeId","ecsFlowRepository","entityEventsManager","entityProxyRepository","entityRepository","entityScheduler","entityTypeDescriptors","eventLogSize","performanceTimer","systemsModuleRepository","createVersionStore","version","add","delete","notifyInstrumentedListeners","Array","from","instrumentMethod","TTarget","methodName","undefined","mutableTarget","Record","method","instrumented","bridgeInstrumentedMethod","this","apply","maybePromise","Promise","finally","isProxy","value","sameProxy","a","b","entityUid","entityTypeKey","toString","normalizeEntityTypeDescriptor","descriptor","id","normalizePhase","entryMs","entry","msPassed","endedAt","startedAt","matchesMetric","filter","toLowerCase","includes","system","EcsBridge","stores","Map","eventLog","metricEntries","updateCounts","unsubscribeInstrumentation","constructor","input","entityTypes","events","modules","proxies","queue","scheduler","scopes","subscriptions","normalized","set","instrumentRepositories","dispose","unsubscribe","splice","getEntityUpdateCounts","get","getEntitiesInScope","listAll","entity","identity","model","getEntityTypeDescriptor","idOrEntityType","key","values","find","getEntityTypeDescriptors","descriptors","explicitEntityTypes","list","keys","has","proxy","sort","localeCompare","registerEntityTypeDescriptor","getScopes","entitiesByScope","push","entries","map","getEventStream","data","uid","origin","some","slice","getMetricEntries","flat","getMiddlewareMetrics","summaries","ms","existing","Math","min","max","getPipelineMetrics","module","length","reduce","sum","Boolean","join","getSchedulerSnapshot","getUpdateQueueSnapshot","inspectDirtyUpdates","dirtyCount","createEntitySpawnUpdate","spawn","descriptorId","modelInput","createModel","snapshot","createSnapshot","update","enqueueEntitySpawn","enqueue","listSystemsModules","recordEvent","Date","now","bumpUpdate","counts","_args","createEcsBridge","PropsWithChildren","useMemo","EcsBridge","EcsCanvasContextOptions","EcsFlowContext","EcsFlowContextProps","EcsCanvasProviderProps","bridge","EcsCanvasProvider","t0","$","_c","children","readOnly","t1","telemetryThresholdMs","undefined","t2","Object","assign","value","t3"],"sources":["../../src/context/ecs-flow-repository.ts","../../src/context/ecs-bridge.ts","../../src/context/ecs-canvas-provider.tsx"],"sourcesContent":["import { EntityTypeUid, IEntityProxy } from '@awesome-ecs/abstract/entities';\nimport { Node } from '@xyflow/react';\nimport { EcsIdGenerator } from '../utils/id-generator';\nimport { EntityNodeData, ScopeGroupNodeData, SystemsModuleNodeData } from '../abstract/node-props';\n\nexport class EcsFlowRepository {\n private readonly nodes: Map<string, Node>;\n\n constructor() {\n this.nodes = new Map();\n }\n\n get sizeNodes(): number {\n return this.nodes.size;\n }\n\n addSystemModuleNode(node: Node<SystemsModuleNodeData>) {\n this.nodes.set(node.data.entityType.toString(), node);\n }\n\n getSystemModuleNode(entityType: EntityTypeUid): Node<SystemsModuleNodeData> {\n return this.nodes.get(entityType.toString()) as Node<SystemsModuleNodeData>;\n }\n\n addScopeGroupNode(node: Node<ScopeGroupNodeData>) {\n this.nodes.set(EcsIdGenerator.scope(node.data.scopeId), node);\n }\n\n getScopeGroupNode(scopeId: string): Node<ScopeGroupNodeData> {\n return this.nodes.get(EcsIdGenerator.scope(scopeId)) as Node<ScopeGroupNodeData>;\n }\n\n addEntityNode(node: Node<EntityNodeData>) {\n if (!node.data.entity) {\n return;\n }\n\n this.nodes.set(EcsIdGenerator.entityProxy(node.data.entity), node);\n }\n\n getEntityNode(entity: IEntityProxy): Node<EntityNodeData> {\n return this.nodes.get(EcsIdGenerator.entityProxy(entity)) as Node<EntityNodeData>;\n }\n\n addToolNode(node: Node) {\n this.nodes.set(EcsIdGenerator.tool(node.type), node);\n }\n\n getToolNode(type: string): Node {\n return this.nodes.get(EcsIdGenerator.tool(type));\n }\n\n listAllNodes(): Node[] {\n return Array.from(this.nodes.values());\n }\n}\n","import {\n EntityEventUid,\n EntityUpdateType,\n EntityTypeUid,\n EntityUid,\n IEntity,\n IEntityEvent,\n IEntityEventsManager,\n IEntityModel,\n IEntityProxy,\n IEntityProxyRepository,\n IEntityRepository,\n IEntityRuntimeSchedulerInspector,\n IEntityUpdate,\n IEventData\n} from '@awesome-ecs/abstract/entities';\nimport { PipelineCategory, PipelineCategoryName } from '@awesome-ecs/abstract/factories';\nimport { SystemType, ISystemsModule, ISystemsModuleRepository } from '@awesome-ecs/abstract/systems';\nimport { IPerformanceTimer, MiddlewareMetricsSummary, PerformanceTimeEntry } from '@awesome-ecs/abstract/utils';\nimport { EcsEntitySpawnRequest, EcsEntityTypeDescriptor } from '../abstract/entity-type-descriptor';\nimport { EcsIdGenerator } from '../utils/id-generator';\nimport { EcsFlowRepository } from './ecs-flow-repository';\n\nconst INSTRUMENTATION = Symbol.for('@awesome-flow/ecs.bridge.instrumentation');\n\ntype InstrumentationListener = (args: unknown[], result: unknown) => void;\ntype InstrumentedFunction = ((...args: unknown[]) => unknown) & {\n [INSTRUMENTATION]?: {\n listeners: Set<InstrumentationListener>;\n original: (...args: unknown[]) => unknown;\n };\n};\n\nexport type EcsBridgeStoreName =\n | 'entities'\n | 'entityTypes'\n | 'events'\n | 'metrics'\n | 'modules'\n | 'proxies'\n | 'queue'\n | 'scheduler'\n | 'scopes'\n | 'subscriptions'\n | 'updates';\n\nexport type EcsBridgeStore = {\n getSnapshot(): number;\n notify(): void;\n subscribe(listener: () => void): () => void;\n};\n\nexport type TelemetryMetricsSource = IPerformanceTimer & {\n readonly metrics?: ReadonlyMap<string, ReadonlyArray<PerformanceTimeEntry>>;\n clearMetrics?(): void;\n};\n\nexport type EntityUpdateCounts = {\n removes: number;\n updates: number;\n};\n\nexport type EcsEventLogEntry = {\n event: IEntityEvent<IEventData>;\n recordedAt: number;\n targets: readonly IEntityProxy[];\n};\n\nexport type EcsScopeSummary = {\n entities: readonly IEntity[];\n scopeId: string;\n scopedProxies: ReadonlyMap<EntityTypeUid, IEntityProxy>;\n};\n\nexport type EcsEventStreamFilter = {\n limit?: number;\n scopeId?: string;\n source?: IEntityProxy;\n target?: IEntityProxy;\n type?: EntityEventUid;\n};\n\nexport type EcsMetricsFilter = {\n category?: PipelineCategoryName;\n entityType?: EntityTypeUid;\n phase?: SystemType | string;\n};\n\nexport type PipelineMetricsSummary = {\n avgMs: number;\n count: number;\n lastMs: number;\n maxMs: number;\n minMs: number;\n name: string;\n samples: readonly number[];\n totalMs: number;\n};\n\nexport type EcsSchedulerSnapshot = {\n frameSubscriptions: readonly IEntityProxy[];\n isPaused: boolean;\n pendingCount: number;\n schedules: readonly unknown[];\n skippedEntityTypes: readonly EntityTypeUid[];\n};\n\nexport type EcsUpdateQueueSnapshot = {\n items: readonly IEntityUpdate[];\n size: number;\n};\n\nexport type EcsBridgeInput = {\n defaultScopeId?: string;\n ecsFlowRepository?: EcsFlowRepository;\n entityEventsManager: IEntityEventsManager;\n entityProxyRepository: IEntityProxyRepository;\n entityRepository: IEntityRepository;\n entityScheduler?: IEntityRuntimeSchedulerInspector;\n entityTypeDescriptors?: readonly EcsEntityTypeDescriptor[];\n eventLogSize?: number;\n performanceTimer?: TelemetryMetricsSource;\n systemsModuleRepository: ISystemsModuleRepository;\n};\n\nfunction createVersionStore(): EcsBridgeStore {\n let version = 0;\n const listeners = new Set<() => void>();\n\n return {\n getSnapshot: () => version,\n notify: () => {\n version += 1;\n for (const listener of listeners) {\n listener();\n }\n },\n subscribe: (listener: () => void) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n }\n };\n}\n\nfunction notifyInstrumentedListeners(listeners: Set<InstrumentationListener>, args: unknown[], result: unknown) {\n for (const listener of Array.from(listeners)) {\n listener(args, result);\n }\n}\n\nfunction instrumentMethod<TTarget extends object>(\n target: TTarget | undefined,\n methodName: string,\n listener: InstrumentationListener\n): () => void {\n if (!target) {\n return () => undefined;\n }\n\n const mutableTarget = target as Record<string, unknown>;\n const method = mutableTarget[methodName] as InstrumentedFunction | undefined;\n\n if (typeof method !== 'function') {\n return () => undefined;\n }\n\n let instrumented = method;\n if (!instrumented[INSTRUMENTATION]) {\n const original = method;\n const listeners = new Set<InstrumentationListener>();\n\n instrumented = function bridgeInstrumentedMethod(this: unknown, ...args: unknown[]) {\n const result = original.apply(this, args);\n const maybePromise = result as Promise<unknown> | undefined;\n\n if (maybePromise && typeof maybePromise.finally === 'function') {\n return maybePromise.finally(() => notifyInstrumentedListeners(listeners, args, result));\n }\n\n notifyInstrumentedListeners(listeners, args, result);\n return result;\n } as InstrumentedFunction;\n\n instrumented[INSTRUMENTATION] = { listeners, original };\n mutableTarget[methodName] = instrumented;\n }\n\n instrumented[INSTRUMENTATION].listeners.add(listener);\n\n return () => {\n instrumented[INSTRUMENTATION]?.listeners.delete(listener);\n };\n}\n\nfunction isProxy(value: unknown): value is IEntityProxy {\n return !!value && typeof value === 'object' && 'entityType' in value && 'entityUid' in value;\n}\n\nfunction sameProxy(a?: IEntityProxy, b?: IEntityProxy): boolean {\n return !!a && !!b && a.entityType === b.entityType && a.entityUid === b.entityUid;\n}\n\nfunction entityTypeKey(entityType: EntityTypeUid): string {\n return entityType.toString();\n}\n\nfunction normalizeEntityTypeDescriptor(descriptor: EcsEntityTypeDescriptor): EcsEntityTypeDescriptor & { id: string } {\n return {\n ...descriptor,\n id: descriptor.id ?? EcsIdGenerator.entityType(descriptor.entityType)\n };\n}\n\nfunction normalizePhase(phase?: SystemType | string): string | undefined {\n if (phase === undefined || phase === null) {\n return undefined;\n }\n\n if (typeof phase === 'number') {\n return SystemType[phase];\n }\n\n return phase;\n}\n\nfunction entryMs(entry: PerformanceTimeEntry): number | undefined {\n if (entry.msPassed !== undefined) {\n return entry.msPassed;\n }\n\n if (entry.endedAt !== undefined) {\n return entry.endedAt - entry.startedAt;\n }\n\n return undefined;\n}\n\nfunction matchesMetric(entry: PerformanceTimeEntry, filter?: EcsMetricsFilter): boolean {\n if (!filter) {\n return true;\n }\n\n if (filter.category && entry.category !== filter.category) {\n return false;\n }\n\n const phase = normalizePhase(filter.phase)?.toString().toLowerCase();\n if (phase && !entry.name.toLowerCase().includes(phase)) {\n return false;\n }\n\n if (filter.entityType && entry.category !== PipelineCategory.system) {\n const entityType = filter.entityType.toString().toLowerCase();\n if (!entry.name.toLowerCase().includes(entityType)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport class EcsBridge {\n readonly ecsFlowRepository: EcsFlowRepository;\n readonly entityEventsManager: IEntityEventsManager;\n readonly entityProxyRepository: IEntityProxyRepository;\n readonly entityRepository: IEntityRepository;\n readonly entityScheduler?: IEntityRuntimeSchedulerInspector;\n readonly performanceTimer?: TelemetryMetricsSource;\n readonly stores: Record<EcsBridgeStoreName, EcsBridgeStore>;\n readonly systemsModuleRepository: ISystemsModuleRepository;\n\n private readonly defaultScopeId?: string;\n private readonly entityTypeDescriptors = new Map<string, EcsEntityTypeDescriptor & { id: string }>();\n private readonly eventLogSize: number;\n private readonly eventLog: EcsEventLogEntry[] = [];\n private readonly metricEntries: PerformanceTimeEntry[] = [];\n private readonly scopedProxies = new Map<string, Map<EntityTypeUid, IEntityProxy>>();\n private readonly updateCounts = new Map<EntityUid, EntityUpdateCounts>();\n private readonly unsubscribeInstrumentation: (() => void)[] = [];\n\n constructor(input: EcsBridgeInput) {\n this.ecsFlowRepository = input.ecsFlowRepository ?? new EcsFlowRepository();\n this.entityEventsManager = input.entityEventsManager;\n this.entityProxyRepository = input.entityProxyRepository;\n this.entityRepository = input.entityRepository;\n this.entityScheduler = input.entityScheduler;\n this.defaultScopeId = input.defaultScopeId;\n this.performanceTimer = input.performanceTimer;\n this.systemsModuleRepository = input.systemsModuleRepository;\n this.eventLogSize = input.eventLogSize ?? 250;\n this.stores = {\n entities: createVersionStore(),\n entityTypes: createVersionStore(),\n events: createVersionStore(),\n metrics: createVersionStore(),\n modules: createVersionStore(),\n proxies: createVersionStore(),\n queue: createVersionStore(),\n scheduler: createVersionStore(),\n scopes: createVersionStore(),\n subscriptions: createVersionStore(),\n updates: createVersionStore()\n };\n\n for (const descriptor of input.entityTypeDescriptors ?? []) {\n const normalized = normalizeEntityTypeDescriptor(descriptor);\n this.entityTypeDescriptors.set(normalized.id, normalized);\n }\n\n this.instrumentRepositories();\n }\n\n dispose(): void {\n for (const unsubscribe of this.unsubscribeInstrumentation.splice(0)) {\n unsubscribe();\n }\n }\n\n getEntityUpdateCounts(target: IEntityProxy | EntityUid): EntityUpdateCounts {\n const entityUid = isProxy(target) ? target.entityUid : target;\n return this.updateCounts.get(entityUid) ?? { removes: 0, updates: 0 };\n }\n\n getEntitiesInScope(scopeId: string): IEntity[] {\n return Array.from(this.entityRepository.listAll()).filter((entity) => entity.identity?.model?.scopeId === scopeId);\n }\n\n getEntityTypeDescriptor(idOrEntityType: string | EntityTypeUid): EcsEntityTypeDescriptor | undefined {\n const key = idOrEntityType.toString();\n return (\n this.entityTypeDescriptors.get(key) ??\n Array.from(this.entityTypeDescriptors.values()).find((descriptor) => entityTypeKey(descriptor.entityType) === key)\n );\n }\n\n getEntityTypeDescriptors(): EcsEntityTypeDescriptor[] {\n const descriptors = new Map<string, EcsEntityTypeDescriptor>();\n const explicitEntityTypes = new Set<string>();\n\n for (const descriptor of this.entityTypeDescriptors.values()) {\n descriptors.set(descriptor.id, descriptor);\n explicitEntityTypes.add(entityTypeKey(descriptor.entityType));\n }\n\n for (const entityType of this.systemsModuleRepository.list().keys()) {\n if (!explicitEntityTypes.has(entityTypeKey(entityType))) {\n const descriptor = normalizeEntityTypeDescriptor({ entityType });\n descriptors.set(descriptor.id, descriptor);\n }\n }\n\n for (const entity of this.entityRepository.listAll()) {\n const { entityType } = entity.identity.proxy;\n if (!explicitEntityTypes.has(entityTypeKey(entityType))) {\n const descriptor = normalizeEntityTypeDescriptor({ entityType });\n descriptors.set(descriptor.id, descriptor);\n }\n }\n\n return Array.from(descriptors.values()).sort((a, b) => a.entityType.toString().localeCompare(b.entityType.toString()));\n }\n\n registerEntityTypeDescriptor(descriptor: EcsEntityTypeDescriptor): EcsEntityTypeDescriptor {\n const normalized = normalizeEntityTypeDescriptor(descriptor);\n this.entityTypeDescriptors.set(normalized.id, normalized);\n this.stores.entityTypes.notify();\n return normalized;\n }\n\n getScopes(): EcsScopeSummary[] {\n const entitiesByScope = new Map<string, IEntity[]>();\n\n for (const entity of this.entityRepository.listAll()) {\n const scopeId = entity.identity?.model?.scopeId;\n if (!scopeId) {\n continue;\n }\n\n const entities = entitiesByScope.get(scopeId) ?? [];\n entities.push(entity);\n entitiesByScope.set(scopeId, entities);\n }\n\n for (const scopeId of this.scopedProxies.keys()) {\n if (!entitiesByScope.has(scopeId)) {\n entitiesByScope.set(scopeId, []);\n }\n }\n\n return Array.from(entitiesByScope.entries()).map(([scopeId, entities]) => ({\n scopeId,\n entities,\n scopedProxies: this.scopedProxies.get(scopeId) ?? new Map()\n }));\n }\n\n getEventStream(filter?: EcsEventStreamFilter): EcsEventLogEntry[] {\n const entries = this.eventLog.filter((entry) => {\n if (filter?.type !== undefined && entry.event.data.uid !== filter.type) {\n return false;\n }\n\n if (filter?.scopeId && entry.event.scopeId !== filter.scopeId) {\n return false;\n }\n\n if (filter?.source && !sameProxy(entry.event.origin, filter.source)) {\n return false;\n }\n\n if (filter?.target) {\n const targets = entry.event.target ? [entry.event.target] : entry.targets;\n if (!targets.some((target) => sameProxy(target, filter.target))) {\n return false;\n }\n }\n\n return true;\n });\n\n return filter?.limit ? entries.slice(-filter.limit) : entries;\n }\n\n getMetricEntries(filter?: EcsMetricsFilter): PerformanceTimeEntry[] {\n const entries = this.performanceTimer?.metrics\n ? Array.from(this.performanceTimer.metrics.values()).flat()\n : this.metricEntries;\n\n return entries.filter((entry) => matchesMetric(entry, filter));\n }\n\n getMiddlewareMetrics(filter?: EcsMetricsFilter): MiddlewareMetricsSummary[] {\n const summaries = new Map<string, MiddlewareMetricsSummary>();\n\n for (const entry of this.getMetricEntries(filter)) {\n const ms = entryMs(entry);\n if (ms === undefined) {\n continue;\n }\n\n const category = entry.category ?? PipelineCategory.system;\n const key = `${category}:${entry.name}`;\n const existing = summaries.get(key);\n\n if (existing) {\n existing.count += 1;\n existing.totalMs += ms;\n existing.avgMs = existing.totalMs / existing.count;\n existing.minMs = Math.min(existing.minMs, ms);\n existing.maxMs = Math.max(existing.maxMs, ms);\n existing.lastMs = ms;\n } else {\n summaries.set(key, {\n name: entry.name,\n category,\n count: 1,\n totalMs: ms,\n avgMs: ms,\n minMs: ms,\n maxMs: ms,\n lastMs: ms\n });\n }\n }\n\n return Array.from(summaries.values()).sort((a, b) => b.totalMs - a.totalMs);\n }\n\n getPipelineMetrics(entityType?: EntityTypeUid, phase?: SystemType | string): PipelineMetricsSummary | undefined {\n const entries = this.getMetricEntries({\n category: PipelineCategory.module,\n entityType,\n phase\n });\n const samples = entries.map(entryMs).filter((ms): ms is number => ms !== undefined);\n\n if (!samples.length) {\n return undefined;\n }\n\n const totalMs = samples.reduce((sum, ms) => sum + ms, 0);\n\n return {\n name: [entityType, normalizePhase(phase)].filter(Boolean).join(':') || 'pipeline',\n count: samples.length,\n totalMs,\n avgMs: totalMs / samples.length,\n minMs: Math.min(...samples),\n maxMs: Math.max(...samples),\n lastMs: samples[samples.length - 1],\n samples\n };\n }\n\n getSchedulerSnapshot(): EcsSchedulerSnapshot | undefined {\n if (!this.entityScheduler) {\n return undefined;\n }\n\n return {\n frameSubscriptions: Array.from(this.entityScheduler.frameSubscriptions),\n isPaused: this.entityScheduler.isPaused,\n pendingCount: this.entityScheduler.pendingCount,\n schedules: Array.from(this.entityScheduler.schedules),\n skippedEntityTypes: Array.from(this.entityScheduler.skippedEntityTypes)\n };\n }\n\n getUpdateQueueSnapshot(limit?: number): EcsUpdateQueueSnapshot | undefined {\n if (!this.entityScheduler) {\n return undefined;\n }\n\n const items = this.entityScheduler.inspectDirtyUpdates();\n\n return {\n items: limit ? items.slice(-limit) : items,\n size: this.entityScheduler.dirtyCount\n };\n }\n\n createEntitySpawnUpdate(spawn: EcsEntitySpawnRequest): IEntityUpdate {\n const descriptor = spawn.descriptorId\n ? this.getEntityTypeDescriptor(spawn.descriptorId)\n : this.getEntityTypeDescriptor(spawn.entityType);\n const entityType = descriptor?.entityType ?? spawn.entityType;\n const uid = spawn.uid ?? EcsIdGenerator.entityUid(entityType);\n const scopeId = spawn.scopeId ?? descriptor?.scopeId ?? this.defaultScopeId;\n const modelInput = {\n descriptor: descriptor ?? normalizeEntityTypeDescriptor({ entityType }),\n entityType,\n scopeId,\n uid\n };\n const model: IEntityModel = descriptor?.createModel?.(modelInput) ?? {\n uid,\n scopeId\n };\n const snapshot = descriptor?.createSnapshot?.(modelInput);\n\n return {\n type: EntityUpdateType.update,\n entity: {\n entityType,\n entityUid: model.uid\n },\n model,\n snapshot\n };\n }\n\n enqueueEntitySpawn(spawn: EcsEntitySpawnRequest): IEntityUpdate | undefined {\n if (!this.entityScheduler) {\n return undefined;\n }\n\n const update = this.createEntitySpawnUpdate(spawn);\n this.entityScheduler.enqueue(update);\n return update;\n }\n\n listSystemsModules(): ReadonlyMap<EntityTypeUid, ISystemsModule<IEntity>> {\n return this.systemsModuleRepository.list() as ReadonlyMap<EntityTypeUid, ISystemsModule<IEntity>>;\n }\n\n recordEvent(event: IEntityEvent<IEventData>, targets: readonly IEntityProxy[] = []): void {\n this.eventLog.push({\n event,\n targets,\n recordedAt: Date.now()\n });\n\n if (this.eventLog.length > this.eventLogSize) {\n this.eventLog.splice(0, this.eventLog.length - this.eventLogSize);\n }\n\n this.stores.events.notify();\n }\n\n private bumpUpdate(entityUid: EntityUid, key: keyof EntityUpdateCounts): void {\n const counts = this.updateCounts.get(entityUid) ?? { removes: 0, updates: 0 };\n counts[key] += 1;\n this.updateCounts.set(entityUid, counts);\n this.stores.updates.notify();\n }\n\n private instrumentRepositories(): void {\n this.unsubscribeInstrumentation.push(\n instrumentMethod(this.entityRepository, 'set', (args) => {\n const entity = args[0] as IEntity | undefined;\n if (entity?.identity.proxy) {\n this.bumpUpdate(entity.identity.proxy.entityUid, 'updates');\n }\n this.stores.entities.notify();\n this.stores.entityTypes.notify();\n this.stores.scopes.notify();\n }),\n instrumentMethod(this.entityRepository, 'delete', (args) => {\n const proxy = args[0];\n if (isProxy(proxy)) {\n this.bumpUpdate(proxy.entityUid, 'removes');\n }\n this.stores.entities.notify();\n this.stores.entityTypes.notify();\n this.stores.scopes.notify();\n }),\n instrumentMethod(this.entityRepository, 'clear', () => {\n this.stores.entities.notify();\n this.stores.entityTypes.notify();\n this.stores.scopes.notify();\n }),\n instrumentMethod(this.systemsModuleRepository, 'set', () => {\n this.stores.modules.notify();\n this.stores.entityTypes.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'register', () => {\n this.stores.proxies.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'registerMany', () => {\n this.stores.proxies.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'remove', () => {\n this.stores.proxies.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'removeAllFor', () => {\n this.stores.proxies.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'setScopedProxy', (args) => {\n const entity = args[0];\n const scopeId = args[1];\n if (isProxy(entity) && typeof scopeId === 'string') {\n const proxies = this.scopedProxies.get(scopeId) ?? new Map<EntityTypeUid, IEntityProxy>();\n proxies.set(entity.entityType, entity);\n this.scopedProxies.set(scopeId, proxies);\n }\n this.stores.proxies.notify();\n this.stores.scopes.notify();\n }),\n instrumentMethod(this.entityProxyRepository, 'removeScopedProxy', (args) => {\n const entity = args[0];\n const scopeId = args[1];\n if (isProxy(entity) && typeof scopeId === 'string') {\n const proxies = this.scopedProxies.get(scopeId);\n const existing = proxies?.get(entity.entityType);\n if (existing?.entityUid === entity.entityUid) {\n proxies.delete(entity.entityType);\n }\n if (proxies?.size === 0) {\n this.scopedProxies.delete(scopeId);\n }\n }\n this.stores.proxies.notify();\n this.stores.scopes.notify();\n }),\n instrumentMethod(this.entityEventsManager, 'subscribe', () => {\n this.stores.subscriptions.notify();\n }),\n instrumentMethod(this.entityEventsManager, 'unsubscribe', () => {\n this.stores.subscriptions.notify();\n }),\n instrumentMethod(this.entityEventsManager, 'clearSubscriptions', () => {\n this.stores.subscriptions.notify();\n }),\n instrumentMethod(this.entityEventsManager, 'clearSubscriptionsForEntity', () => {\n this.stores.subscriptions.notify();\n }),\n instrumentMethod(this.entityEventsManager, 'clearSubscriptionsForEvent', () => {\n this.stores.subscriptions.notify();\n }),\n instrumentMethod(this.performanceTimer, 'endTimer', (_args, result) => {\n const entry = result as PerformanceTimeEntry | undefined;\n if (!this.performanceTimer?.metrics && entry?.name) {\n this.metricEntries.push(entry);\n }\n this.stores.metrics.notify();\n }),\n instrumentMethod(this.entityScheduler, 'schedule', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'removeSchedule', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'clearSchedules', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'skipEntityType', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'unskipEntityType', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'pause', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'resume', () => {\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'enqueue', () => {\n this.stores.queue.notify();\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'enqueueEvent', () => {\n this.stores.queue.notify();\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'enqueueEvents', () => {\n this.stores.queue.notify();\n this.stores.scheduler.notify();\n }),\n instrumentMethod(this.entityScheduler, 'clearDirtyUpdates', () => {\n this.stores.queue.notify();\n this.stores.scheduler.notify();\n })\n );\n }\n}\n\nexport function createEcsBridge(input: EcsBridgeInput): EcsBridge {\n return new EcsBridge(input);\n}\n","import { PropsWithChildren, useMemo } from 'react';\nimport { EcsBridge } from './ecs-bridge';\nimport {\n EcsCanvasContextOptions,\n EcsFlowContext,\n EcsFlowContextProps\n} from './ecs-flow-context';\n\nexport type EcsCanvasProviderProps = PropsWithChildren<\n EcsCanvasContextOptions & {\n bridge: EcsBridge;\n }\n>;\n\nexport function EcsCanvasProvider({\n bridge,\n children,\n readOnly = false,\n telemetryThresholdMs\n}: Readonly<EcsCanvasProviderProps>) {\n const value = useMemo<EcsFlowContextProps>(() => {\n return Object.assign(bridge, {\n readOnly,\n telemetryThresholdMs\n });\n }, [bridge, readOnly, telemetryThresholdMs]);\n\n return <EcsFlowContext.Provider value={value}>{children}</EcsFlowContext.Provider>;\n}\n"],"mappings":";;;;;;;;;AAKA,IAAaO,oBAAb,MAA+B;CAC7B,AAAiBC;CAEjBE,cAAc;EACZ,KAAKF,wBAAQ,IAAIC,IAAI;CACvB;CAEA,IAAIE,YAAoB;EACtB,OAAO,KAAKH,MAAMI;CACpB;CAEAC,oBAAoBC,MAAmC;EACrD,KAAKN,MAAMO,IAAID,KAAKE,KAAKC,WAAWC,SAAS,GAAGJ,IAAI;CACtD;CAEAK,oBAAoBF,YAAwD;EAC1E,OAAO,KAAKT,MAAMY,IAAIH,WAAWC,SAAS,CAAC;CAC7C;CAEAG,kBAAkBP,MAAgC;EAChD,KAAKN,MAAMO,IAAIZ,oCAAemB,MAAMR,KAAKE,KAAKO,OAAO,GAAGT,IAAI;CAC9D;CAEAU,kBAAkBD,SAA2C;EAC3D,OAAO,KAAKf,MAAMY,IAAIjB,oCAAemB,MAAMC,OAAO,CAAC;CACrD;CAEAE,cAAcX,MAA4B;EACxC,IAAI,CAACA,KAAKE,KAAKU,QACb;EAGF,KAAKlB,MAAMO,IAAIZ,oCAAewB,YAAYb,KAAKE,KAAKU,MAAM,GAAGZ,IAAI;CACnE;CAEAc,cAAcF,QAA4C;EACxD,OAAO,KAAKlB,MAAMY,IAAIjB,oCAAewB,YAAYD,MAAM,CAAC;CAC1D;CAEAG,YAAYf,MAAY;EACtB,KAAKN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AH,EAAA,OAAAK,sBAAA;EAIPE,KAAAC,OAAMC,OAAQZ,QAAQ;GAAAM;GAAAE;EAG7B,CAAC;EAACL,EAAA,KAAAH;EAAAG,EAAA,KAAAG;EAAAH,EAAA,KAAAK;EAAAL,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAJJ,MAAAU,QACEH;CAI2C,IAAAI;CAAA,IAAAX,EAAA,OAAAE,YAAAF,EAAA,OAAAU,OAAA;EAEtCC,KAAA,2CAAA,oCAAA,UAAA;GAAgCD;GAAQR;EAAS;EAA0BF,EAAA,KAAAE;EAAAF,EAAA,KAAAU;EAAAV,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAA3EW;AAA2E"}
@@ -0,0 +1,2 @@
1
+ import { _ as PipelineMetricsSummary, a as EcsFlowContextProps, b as EcsFlowRepository, c as EcsBridgeStore, d as EcsEventStreamFilter, f as EcsMetricsFilter, g as EntityUpdateCounts, h as EcsUpdateQueueSnapshot, i as EcsFlowContext, l as EcsBridgeStoreName, m as EcsScopeSummary, n as EcsCanvasProviderProps, o as EcsBridge, p as EcsSchedulerSnapshot, r as EcsCanvasContextOptions, s as EcsBridgeInput, t as EcsCanvasProvider, u as EcsEventLogEntry, v as TelemetryMetricsSource, y as createEcsBridge } from "../index-C3QIukqX.cjs";
2
+ export { EcsBridge, EcsBridgeInput, EcsBridgeStore, EcsBridgeStoreName, EcsCanvasContextOptions, EcsCanvasProvider, EcsCanvasProviderProps, EcsEventLogEntry, EcsEventStreamFilter, EcsFlowContext, EcsFlowContextProps, EcsFlowRepository, EcsMetricsFilter, EcsSchedulerSnapshot, EcsScopeSummary, EcsUpdateQueueSnapshot, EntityUpdateCounts, PipelineMetricsSummary, TelemetryMetricsSource, createEcsBridge };
@@ -0,0 +1,2 @@
1
+ import { _ as PipelineMetricsSummary, a as EcsFlowContextProps, b as EcsFlowRepository, c as EcsBridgeStore, d as EcsEventStreamFilter, f as EcsMetricsFilter, g as EntityUpdateCounts, h as EcsUpdateQueueSnapshot, i as EcsFlowContext, l as EcsBridgeStoreName, m as EcsScopeSummary, n as EcsCanvasProviderProps, o as EcsBridge, p as EcsSchedulerSnapshot, r as EcsCanvasContextOptions, s as EcsBridgeInput, t as EcsCanvasProvider, u as EcsEventLogEntry, v as TelemetryMetricsSource, y as createEcsBridge } from "../index-edb-X9uc.mjs";
2
+ export { EcsBridge, EcsBridgeInput, EcsBridgeStore, EcsBridgeStoreName, EcsCanvasContextOptions, EcsCanvasProvider, EcsCanvasProviderProps, EcsEventLogEntry, EcsEventStreamFilter, EcsFlowContext, EcsFlowContextProps, EcsFlowRepository, EcsMetricsFilter, EcsSchedulerSnapshot, EcsScopeSummary, EcsUpdateQueueSnapshot, EntityUpdateCounts, PipelineMetricsSummary, TelemetryMetricsSource, createEcsBridge };
@@ -0,0 +1,496 @@
1
+ import { n as EcsFlowContext, t as EcsIdGenerator } from "../id-generator-DDsv3NdX.mjs";
2
+ import { c } from "react/compiler-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { SystemType } from "@awesome-ecs/abstract/systems";
5
+ import { EntityUpdateType } from "@awesome-ecs/abstract/entities";
6
+ import { PipelineCategory } from "@awesome-ecs/abstract/factories";
7
+
8
+ //#region src/context/ecs-flow-repository.ts
9
+ var EcsFlowRepository = class {
10
+ nodes;
11
+ constructor() {
12
+ this.nodes = /* @__PURE__ */ new Map();
13
+ }
14
+ get sizeNodes() {
15
+ return this.nodes.size;
16
+ }
17
+ addSystemModuleNode(node) {
18
+ this.nodes.set(node.data.entityType.toString(), node);
19
+ }
20
+ getSystemModuleNode(entityType) {
21
+ return this.nodes.get(entityType.toString());
22
+ }
23
+ addScopeGroupNode(node) {
24
+ this.nodes.set(EcsIdGenerator.scope(node.data.scopeId), node);
25
+ }
26
+ getScopeGroupNode(scopeId) {
27
+ return this.nodes.get(EcsIdGenerator.scope(scopeId));
28
+ }
29
+ addEntityNode(node) {
30
+ if (!node.data.entity) return;
31
+ this.nodes.set(EcsIdGenerator.entityProxy(node.data.entity), node);
32
+ }
33
+ getEntityNode(entity) {
34
+ return this.nodes.get(EcsIdGenerator.entityProxy(entity));
35
+ }
36
+ addToolNode(node) {
37
+ this.nodes.set(EcsIdGenerator.tool(node.type), node);
38
+ }
39
+ getToolNode(type) {
40
+ return this.nodes.get(EcsIdGenerator.tool(type));
41
+ }
42
+ listAllNodes() {
43
+ return Array.from(this.nodes.values());
44
+ }
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/context/ecs-bridge.ts
49
+ const INSTRUMENTATION = Symbol.for("@awesome-flow/ecs.bridge.instrumentation");
50
+ function createVersionStore() {
51
+ let version = 0;
52
+ const listeners = /* @__PURE__ */ new Set();
53
+ return {
54
+ getSnapshot: () => version,
55
+ notify: () => {
56
+ version += 1;
57
+ for (const listener of listeners) listener();
58
+ },
59
+ subscribe: (listener) => {
60
+ listeners.add(listener);
61
+ return () => listeners.delete(listener);
62
+ }
63
+ };
64
+ }
65
+ function notifyInstrumentedListeners(listeners, args, result) {
66
+ for (const listener of Array.from(listeners)) listener(args, result);
67
+ }
68
+ function instrumentMethod(target, methodName, listener) {
69
+ if (!target) return () => void 0;
70
+ const mutableTarget = target;
71
+ const method = mutableTarget[methodName];
72
+ if (typeof method !== "function") return () => void 0;
73
+ let instrumented = method;
74
+ if (!instrumented[INSTRUMENTATION]) {
75
+ const original = method;
76
+ const listeners = /* @__PURE__ */ new Set();
77
+ instrumented = function bridgeInstrumentedMethod(...args) {
78
+ const result = original.apply(this, args);
79
+ const maybePromise = result;
80
+ if (maybePromise && typeof maybePromise.finally === "function") return maybePromise.finally(() => notifyInstrumentedListeners(listeners, args, result));
81
+ notifyInstrumentedListeners(listeners, args, result);
82
+ return result;
83
+ };
84
+ instrumented[INSTRUMENTATION] = {
85
+ listeners,
86
+ original
87
+ };
88
+ mutableTarget[methodName] = instrumented;
89
+ }
90
+ instrumented[INSTRUMENTATION].listeners.add(listener);
91
+ return () => {
92
+ instrumented[INSTRUMENTATION]?.listeners.delete(listener);
93
+ };
94
+ }
95
+ function isProxy(value) {
96
+ return !!value && typeof value === "object" && "entityType" in value && "entityUid" in value;
97
+ }
98
+ function sameProxy(a, b) {
99
+ return !!a && !!b && a.entityType === b.entityType && a.entityUid === b.entityUid;
100
+ }
101
+ function entityTypeKey(entityType) {
102
+ return entityType.toString();
103
+ }
104
+ function normalizeEntityTypeDescriptor(descriptor) {
105
+ return {
106
+ ...descriptor,
107
+ id: descriptor.id ?? EcsIdGenerator.entityType(descriptor.entityType)
108
+ };
109
+ }
110
+ function normalizePhase(phase) {
111
+ if (phase === void 0 || phase === null) return;
112
+ if (typeof phase === "number") return SystemType[phase];
113
+ return phase;
114
+ }
115
+ function entryMs(entry) {
116
+ if (entry.msPassed !== void 0) return entry.msPassed;
117
+ if (entry.endedAt !== void 0) return entry.endedAt - entry.startedAt;
118
+ }
119
+ function matchesMetric(entry, filter) {
120
+ if (!filter) return true;
121
+ if (filter.category && entry.category !== filter.category) return false;
122
+ const phase = normalizePhase(filter.phase)?.toString().toLowerCase();
123
+ if (phase && !entry.name.toLowerCase().includes(phase)) return false;
124
+ if (filter.entityType && entry.category !== PipelineCategory.system) {
125
+ const entityType = filter.entityType.toString().toLowerCase();
126
+ if (!entry.name.toLowerCase().includes(entityType)) return false;
127
+ }
128
+ return true;
129
+ }
130
+ var EcsBridge = class {
131
+ ecsFlowRepository;
132
+ entityEventsManager;
133
+ entityProxyRepository;
134
+ entityRepository;
135
+ entityScheduler;
136
+ performanceTimer;
137
+ stores;
138
+ systemsModuleRepository;
139
+ defaultScopeId;
140
+ entityTypeDescriptors = /* @__PURE__ */ new Map();
141
+ eventLogSize;
142
+ eventLog = [];
143
+ metricEntries = [];
144
+ scopedProxies = /* @__PURE__ */ new Map();
145
+ updateCounts = /* @__PURE__ */ new Map();
146
+ unsubscribeInstrumentation = [];
147
+ constructor(input) {
148
+ this.ecsFlowRepository = input.ecsFlowRepository ?? new EcsFlowRepository();
149
+ this.entityEventsManager = input.entityEventsManager;
150
+ this.entityProxyRepository = input.entityProxyRepository;
151
+ this.entityRepository = input.entityRepository;
152
+ this.entityScheduler = input.entityScheduler;
153
+ this.defaultScopeId = input.defaultScopeId;
154
+ this.performanceTimer = input.performanceTimer;
155
+ this.systemsModuleRepository = input.systemsModuleRepository;
156
+ this.eventLogSize = input.eventLogSize ?? 250;
157
+ this.stores = {
158
+ entities: createVersionStore(),
159
+ entityTypes: createVersionStore(),
160
+ events: createVersionStore(),
161
+ metrics: createVersionStore(),
162
+ modules: createVersionStore(),
163
+ proxies: createVersionStore(),
164
+ queue: createVersionStore(),
165
+ scheduler: createVersionStore(),
166
+ scopes: createVersionStore(),
167
+ subscriptions: createVersionStore(),
168
+ updates: createVersionStore()
169
+ };
170
+ for (const descriptor of input.entityTypeDescriptors ?? []) {
171
+ const normalized = normalizeEntityTypeDescriptor(descriptor);
172
+ this.entityTypeDescriptors.set(normalized.id, normalized);
173
+ }
174
+ this.instrumentRepositories();
175
+ }
176
+ dispose() {
177
+ for (const unsubscribe of this.unsubscribeInstrumentation.splice(0)) unsubscribe();
178
+ }
179
+ getEntityUpdateCounts(target) {
180
+ const entityUid = isProxy(target) ? target.entityUid : target;
181
+ return this.updateCounts.get(entityUid) ?? {
182
+ removes: 0,
183
+ updates: 0
184
+ };
185
+ }
186
+ getEntitiesInScope(scopeId) {
187
+ return Array.from(this.entityRepository.listAll()).filter((entity) => entity.identity?.model?.scopeId === scopeId);
188
+ }
189
+ getEntityTypeDescriptor(idOrEntityType) {
190
+ const key = idOrEntityType.toString();
191
+ return this.entityTypeDescriptors.get(key) ?? Array.from(this.entityTypeDescriptors.values()).find((descriptor) => entityTypeKey(descriptor.entityType) === key);
192
+ }
193
+ getEntityTypeDescriptors() {
194
+ const descriptors = /* @__PURE__ */ new Map();
195
+ const explicitEntityTypes = /* @__PURE__ */ new Set();
196
+ for (const descriptor of this.entityTypeDescriptors.values()) {
197
+ descriptors.set(descriptor.id, descriptor);
198
+ explicitEntityTypes.add(entityTypeKey(descriptor.entityType));
199
+ }
200
+ for (const entityType of this.systemsModuleRepository.list().keys()) if (!explicitEntityTypes.has(entityTypeKey(entityType))) {
201
+ const descriptor = normalizeEntityTypeDescriptor({ entityType });
202
+ descriptors.set(descriptor.id, descriptor);
203
+ }
204
+ for (const entity of this.entityRepository.listAll()) {
205
+ const { entityType } = entity.identity.proxy;
206
+ if (!explicitEntityTypes.has(entityTypeKey(entityType))) {
207
+ const descriptor = normalizeEntityTypeDescriptor({ entityType });
208
+ descriptors.set(descriptor.id, descriptor);
209
+ }
210
+ }
211
+ return Array.from(descriptors.values()).sort((a, b) => a.entityType.toString().localeCompare(b.entityType.toString()));
212
+ }
213
+ registerEntityTypeDescriptor(descriptor) {
214
+ const normalized = normalizeEntityTypeDescriptor(descriptor);
215
+ this.entityTypeDescriptors.set(normalized.id, normalized);
216
+ this.stores.entityTypes.notify();
217
+ return normalized;
218
+ }
219
+ getScopes() {
220
+ const entitiesByScope = /* @__PURE__ */ new Map();
221
+ for (const entity of this.entityRepository.listAll()) {
222
+ const scopeId = entity.identity?.model?.scopeId;
223
+ if (!scopeId) continue;
224
+ const entities = entitiesByScope.get(scopeId) ?? [];
225
+ entities.push(entity);
226
+ entitiesByScope.set(scopeId, entities);
227
+ }
228
+ for (const scopeId of this.scopedProxies.keys()) if (!entitiesByScope.has(scopeId)) entitiesByScope.set(scopeId, []);
229
+ return Array.from(entitiesByScope.entries()).map(([scopeId, entities]) => ({
230
+ scopeId,
231
+ entities,
232
+ scopedProxies: this.scopedProxies.get(scopeId) ?? /* @__PURE__ */ new Map()
233
+ }));
234
+ }
235
+ getEventStream(filter) {
236
+ const entries = this.eventLog.filter((entry) => {
237
+ if (filter?.type !== void 0 && entry.event.data.uid !== filter.type) return false;
238
+ if (filter?.scopeId && entry.event.scopeId !== filter.scopeId) return false;
239
+ if (filter?.source && !sameProxy(entry.event.origin, filter.source)) return false;
240
+ if (filter?.target) {
241
+ if (!(entry.event.target ? [entry.event.target] : entry.targets).some((target) => sameProxy(target, filter.target))) return false;
242
+ }
243
+ return true;
244
+ });
245
+ return filter?.limit ? entries.slice(-filter.limit) : entries;
246
+ }
247
+ getMetricEntries(filter) {
248
+ return (this.performanceTimer?.metrics ? Array.from(this.performanceTimer.metrics.values()).flat() : this.metricEntries).filter((entry) => matchesMetric(entry, filter));
249
+ }
250
+ getMiddlewareMetrics(filter) {
251
+ const summaries = /* @__PURE__ */ new Map();
252
+ for (const entry of this.getMetricEntries(filter)) {
253
+ const ms = entryMs(entry);
254
+ if (ms === void 0) continue;
255
+ const category = entry.category ?? PipelineCategory.system;
256
+ const key = `${category}:${entry.name}`;
257
+ const existing = summaries.get(key);
258
+ if (existing) {
259
+ existing.count += 1;
260
+ existing.totalMs += ms;
261
+ existing.avgMs = existing.totalMs / existing.count;
262
+ existing.minMs = Math.min(existing.minMs, ms);
263
+ existing.maxMs = Math.max(existing.maxMs, ms);
264
+ existing.lastMs = ms;
265
+ } else summaries.set(key, {
266
+ name: entry.name,
267
+ category,
268
+ count: 1,
269
+ totalMs: ms,
270
+ avgMs: ms,
271
+ minMs: ms,
272
+ maxMs: ms,
273
+ lastMs: ms
274
+ });
275
+ }
276
+ return Array.from(summaries.values()).sort((a, b) => b.totalMs - a.totalMs);
277
+ }
278
+ getPipelineMetrics(entityType, phase) {
279
+ const samples = this.getMetricEntries({
280
+ category: PipelineCategory.module,
281
+ entityType,
282
+ phase
283
+ }).map(entryMs).filter((ms) => ms !== void 0);
284
+ if (!samples.length) return;
285
+ const totalMs = samples.reduce((sum, ms) => sum + ms, 0);
286
+ return {
287
+ name: [entityType, normalizePhase(phase)].filter(Boolean).join(":") || "pipeline",
288
+ count: samples.length,
289
+ totalMs,
290
+ avgMs: totalMs / samples.length,
291
+ minMs: Math.min(...samples),
292
+ maxMs: Math.max(...samples),
293
+ lastMs: samples[samples.length - 1],
294
+ samples
295
+ };
296
+ }
297
+ getSchedulerSnapshot() {
298
+ if (!this.entityScheduler) return;
299
+ return {
300
+ frameSubscriptions: Array.from(this.entityScheduler.frameSubscriptions),
301
+ isPaused: this.entityScheduler.isPaused,
302
+ pendingCount: this.entityScheduler.pendingCount,
303
+ schedules: Array.from(this.entityScheduler.schedules),
304
+ skippedEntityTypes: Array.from(this.entityScheduler.skippedEntityTypes)
305
+ };
306
+ }
307
+ getUpdateQueueSnapshot(limit) {
308
+ if (!this.entityScheduler) return;
309
+ const items = this.entityScheduler.inspectDirtyUpdates();
310
+ return {
311
+ items: limit ? items.slice(-limit) : items,
312
+ size: this.entityScheduler.dirtyCount
313
+ };
314
+ }
315
+ createEntitySpawnUpdate(spawn) {
316
+ const descriptor = spawn.descriptorId ? this.getEntityTypeDescriptor(spawn.descriptorId) : this.getEntityTypeDescriptor(spawn.entityType);
317
+ const entityType = descriptor?.entityType ?? spawn.entityType;
318
+ const uid = spawn.uid ?? EcsIdGenerator.entityUid(entityType);
319
+ const scopeId = spawn.scopeId ?? descriptor?.scopeId ?? this.defaultScopeId;
320
+ const modelInput = {
321
+ descriptor: descriptor ?? normalizeEntityTypeDescriptor({ entityType }),
322
+ entityType,
323
+ scopeId,
324
+ uid
325
+ };
326
+ const model = descriptor?.createModel?.(modelInput) ?? {
327
+ uid,
328
+ scopeId
329
+ };
330
+ const snapshot = descriptor?.createSnapshot?.(modelInput);
331
+ return {
332
+ type: EntityUpdateType.update,
333
+ entity: {
334
+ entityType,
335
+ entityUid: model.uid
336
+ },
337
+ model,
338
+ snapshot
339
+ };
340
+ }
341
+ enqueueEntitySpawn(spawn) {
342
+ if (!this.entityScheduler) return;
343
+ const update = this.createEntitySpawnUpdate(spawn);
344
+ this.entityScheduler.enqueue(update);
345
+ return update;
346
+ }
347
+ listSystemsModules() {
348
+ return this.systemsModuleRepository.list();
349
+ }
350
+ recordEvent(event, targets = []) {
351
+ this.eventLog.push({
352
+ event,
353
+ targets,
354
+ recordedAt: Date.now()
355
+ });
356
+ if (this.eventLog.length > this.eventLogSize) this.eventLog.splice(0, this.eventLog.length - this.eventLogSize);
357
+ this.stores.events.notify();
358
+ }
359
+ bumpUpdate(entityUid, key) {
360
+ const counts = this.updateCounts.get(entityUid) ?? {
361
+ removes: 0,
362
+ updates: 0
363
+ };
364
+ counts[key] += 1;
365
+ this.updateCounts.set(entityUid, counts);
366
+ this.stores.updates.notify();
367
+ }
368
+ instrumentRepositories() {
369
+ this.unsubscribeInstrumentation.push(instrumentMethod(this.entityRepository, "set", (args) => {
370
+ const entity = args[0];
371
+ if (entity?.identity.proxy) this.bumpUpdate(entity.identity.proxy.entityUid, "updates");
372
+ this.stores.entities.notify();
373
+ this.stores.entityTypes.notify();
374
+ this.stores.scopes.notify();
375
+ }), instrumentMethod(this.entityRepository, "delete", (args) => {
376
+ const proxy = args[0];
377
+ if (isProxy(proxy)) this.bumpUpdate(proxy.entityUid, "removes");
378
+ this.stores.entities.notify();
379
+ this.stores.entityTypes.notify();
380
+ this.stores.scopes.notify();
381
+ }), instrumentMethod(this.entityRepository, "clear", () => {
382
+ this.stores.entities.notify();
383
+ this.stores.entityTypes.notify();
384
+ this.stores.scopes.notify();
385
+ }), instrumentMethod(this.systemsModuleRepository, "set", () => {
386
+ this.stores.modules.notify();
387
+ this.stores.entityTypes.notify();
388
+ }), instrumentMethod(this.entityProxyRepository, "register", () => {
389
+ this.stores.proxies.notify();
390
+ }), instrumentMethod(this.entityProxyRepository, "registerMany", () => {
391
+ this.stores.proxies.notify();
392
+ }), instrumentMethod(this.entityProxyRepository, "remove", () => {
393
+ this.stores.proxies.notify();
394
+ }), instrumentMethod(this.entityProxyRepository, "removeAllFor", () => {
395
+ this.stores.proxies.notify();
396
+ }), instrumentMethod(this.entityProxyRepository, "setScopedProxy", (args) => {
397
+ const entity = args[0];
398
+ const scopeId = args[1];
399
+ if (isProxy(entity) && typeof scopeId === "string") {
400
+ const proxies = this.scopedProxies.get(scopeId) ?? /* @__PURE__ */ new Map();
401
+ proxies.set(entity.entityType, entity);
402
+ this.scopedProxies.set(scopeId, proxies);
403
+ }
404
+ this.stores.proxies.notify();
405
+ this.stores.scopes.notify();
406
+ }), instrumentMethod(this.entityProxyRepository, "removeScopedProxy", (args) => {
407
+ const entity = args[0];
408
+ const scopeId = args[1];
409
+ if (isProxy(entity) && typeof scopeId === "string") {
410
+ const proxies = this.scopedProxies.get(scopeId);
411
+ if ((proxies?.get(entity.entityType))?.entityUid === entity.entityUid) proxies.delete(entity.entityType);
412
+ if (proxies?.size === 0) this.scopedProxies.delete(scopeId);
413
+ }
414
+ this.stores.proxies.notify();
415
+ this.stores.scopes.notify();
416
+ }), instrumentMethod(this.entityEventsManager, "subscribe", () => {
417
+ this.stores.subscriptions.notify();
418
+ }), instrumentMethod(this.entityEventsManager, "unsubscribe", () => {
419
+ this.stores.subscriptions.notify();
420
+ }), instrumentMethod(this.entityEventsManager, "clearSubscriptions", () => {
421
+ this.stores.subscriptions.notify();
422
+ }), instrumentMethod(this.entityEventsManager, "clearSubscriptionsForEntity", () => {
423
+ this.stores.subscriptions.notify();
424
+ }), instrumentMethod(this.entityEventsManager, "clearSubscriptionsForEvent", () => {
425
+ this.stores.subscriptions.notify();
426
+ }), instrumentMethod(this.performanceTimer, "endTimer", (_args, result) => {
427
+ const entry = result;
428
+ if (!this.performanceTimer?.metrics && entry?.name) this.metricEntries.push(entry);
429
+ this.stores.metrics.notify();
430
+ }), instrumentMethod(this.entityScheduler, "schedule", () => {
431
+ this.stores.scheduler.notify();
432
+ }), instrumentMethod(this.entityScheduler, "removeSchedule", () => {
433
+ this.stores.scheduler.notify();
434
+ }), instrumentMethod(this.entityScheduler, "clearSchedules", () => {
435
+ this.stores.scheduler.notify();
436
+ }), instrumentMethod(this.entityScheduler, "skipEntityType", () => {
437
+ this.stores.scheduler.notify();
438
+ }), instrumentMethod(this.entityScheduler, "unskipEntityType", () => {
439
+ this.stores.scheduler.notify();
440
+ }), instrumentMethod(this.entityScheduler, "pause", () => {
441
+ this.stores.scheduler.notify();
442
+ }), instrumentMethod(this.entityScheduler, "resume", () => {
443
+ this.stores.scheduler.notify();
444
+ }), instrumentMethod(this.entityScheduler, "enqueue", () => {
445
+ this.stores.queue.notify();
446
+ this.stores.scheduler.notify();
447
+ }), instrumentMethod(this.entityScheduler, "enqueueEvent", () => {
448
+ this.stores.queue.notify();
449
+ this.stores.scheduler.notify();
450
+ }), instrumentMethod(this.entityScheduler, "enqueueEvents", () => {
451
+ this.stores.queue.notify();
452
+ this.stores.scheduler.notify();
453
+ }), instrumentMethod(this.entityScheduler, "clearDirtyUpdates", () => {
454
+ this.stores.queue.notify();
455
+ this.stores.scheduler.notify();
456
+ }));
457
+ }
458
+ };
459
+ function createEcsBridge(input) {
460
+ return new EcsBridge(input);
461
+ }
462
+
463
+ //#endregion
464
+ //#region src/context/ecs-canvas-provider.tsx
465
+ function EcsCanvasProvider(t0) {
466
+ const $ = c(7);
467
+ const { bridge, children, readOnly: t1, telemetryThresholdMs } = t0;
468
+ const readOnly = t1 === void 0 ? false : t1;
469
+ let t2;
470
+ if ($[0] !== bridge || $[1] !== readOnly || $[2] !== telemetryThresholdMs) {
471
+ t2 = Object.assign(bridge, {
472
+ readOnly,
473
+ telemetryThresholdMs
474
+ });
475
+ $[0] = bridge;
476
+ $[1] = readOnly;
477
+ $[2] = telemetryThresholdMs;
478
+ $[3] = t2;
479
+ } else t2 = $[3];
480
+ const value = t2;
481
+ let t3;
482
+ if ($[4] !== children || $[5] !== value) {
483
+ t3 = /* @__PURE__ */ jsx(EcsFlowContext.Provider, {
484
+ value,
485
+ children
486
+ });
487
+ $[4] = children;
488
+ $[5] = value;
489
+ $[6] = t3;
490
+ } else t3 = $[6];
491
+ return t3;
492
+ }
493
+
494
+ //#endregion
495
+ export { EcsBridge, EcsCanvasProvider, EcsFlowContext, EcsFlowRepository, createEcsBridge };
496
+ //# sourceMappingURL=index.mjs.map