| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | // This keeps track of Server Component logs which may come from. |
| 11 | // This is in a shared module because Server Component logs don't come from a specific renderer |
| 12 | // but can become associated with a Virtual Instance of any renderer. |
| 13 | |
| 14 | import type {ReactComponentInfo} from 'shared/ReactTypes'; |
| 15 | |
| 16 | type ComponentLogs = { |
| 17 | errors: Map<string, number>, |
| 18 | errorsCount: number, |
| 19 | warnings: Map<string, number>, |
| 20 | warningsCount: number, |
| 21 | }; |
| 22 | |
| 23 | // This keeps it around as long as the ComponentInfo is alive which |
| 24 | // lets the Fiber get reparented/remounted and still observe the previous errors/warnings. |
| 25 | // Unless we explicitly clear the logs from a Fiber. |
| 26 | export const componentInfoToComponentLogsMap: WeakMap< |
| 27 | ReactComponentInfo, |
| 28 | ComponentLogs, |
| 29 | > = new WeakMap(); |