| 23 | } from './views/Profiler/types'; |
| 24 | |
| 25 | export default class ProfilerStore extends EventEmitter<{ |
| 26 | isProcessingData: [], |
| 27 | isProfiling: [], |
| 28 | profilingData: [], |
| 29 | }> { |
| 30 | _bridge: FrontendBridge; |
| 31 | |
| 32 | // Suspense cache for lazily calculating derived profiling data. |
| 33 | _cache: ProfilingCache; |
| 34 | |
| 35 | // Temporary store of profiling data from the backend renderer(s). |
| 36 | // This data will be converted to the ProfilingDataFrontend format after being collected from all renderers. |
| 37 | _dataBackends: Array<ProfilingDataBackend> = []; |
| 38 | |
| 39 | // Data from the most recently completed profiling session, |
| 40 | // or data that has been imported from a previously exported session. |
| 41 | // This object contains all necessary data to drive the Profiler UI interface, |
| 42 | // even though some of it is lazily parsed/derived via the ProfilingCache. |
| 43 | _dataFrontend: ProfilingDataFrontend | null = null; |
| 44 | |
| 45 | // Snapshot of all attached renderer IDs. |
| 46 | // Once profiling is finished, this snapshot will be used to query renderers for profiling data. |
| 47 | // |
| 48 | // This map is initialized when profiling starts and updated when a new root is added while profiling; |
| 49 | // Upon completion, it is converted into the exportable ProfilingDataFrontend format. |
| 50 | _initialRendererIDs: Set<number> = new Set(); |
| 51 | |
| 52 | // Snapshot of the state of the main Store (including all roots) when profiling started. |
| 53 | // Once profiling is finished, this snapshot can be used along with "operations" messages emitted during profiling, |
| 54 | // to reconstruct the state of each root for each commit. |
| 55 | // It's okay to use a single root to store this information because node IDs are unique across all roots. |
| 56 | // |
| 57 | // This map is initialized when profiling starts and updated when a new root is added while profiling; |
| 58 | // Upon completion, it is converted into the exportable ProfilingDataFrontend format. |
| 59 | _initialSnapshotsByRootID: Map<number, Map<number, SnapshotNode>> = new Map(); |
| 60 | |
| 61 | // Map of root (id) to a list of tree mutation that occur during profiling. |
| 62 | // Once profiling is finished, these mutations can be used, along with the initial tree snapshots, |
| 63 | // to reconstruct the state of each root for each commit. |
| 64 | // |
| 65 | // This map is only updated while profiling is in progress; |
| 66 | // Upon completion, it is converted into the exportable ProfilingDataFrontend format. |
| 67 | _inProgressOperationsByRootID: Map<number, Array<Array<number>>> = new Map(); |
| 68 | |
| 69 | // The backend is currently profiling. |
| 70 | // When profiling is in progress, operations are stored so that we can later reconstruct past commit trees. |
| 71 | _isBackendProfiling: boolean = false; |
| 72 | |
| 73 | // Mainly used for optimistic UI. |
| 74 | // This could be false, but at the same time _isBackendProfiling could be true |
| 75 | // for cases when Backend is busy serializing a chunky payload. |
| 76 | _isProfilingBasedOnUserInput: boolean = false; |
| 77 | |
| 78 | // Tracks whether a specific renderer logged any profiling data during the most recent session. |
| 79 | _rendererIDsThatReportedProfilingData: Set<number> = new Set(); |
| 80 | |
| 81 | // After profiling, data is requested from each attached renderer using this queue. |
| 82 | // So long as this queue is not empty, the store is retrieving and processing profiling data from the backend. |
nothing calls this directly
no test coverage detected