* Parse a component ID that may be a stringified JSON object. * This handles dict IDs like '{"index":0,"type":"output"}' that need * to be parsed back to objects for getPath to work correctly.
(
componentId: string
)
| 27 | * to be parsed back to objects for getPath to work correctly. |
| 28 | */ |
| 29 | function parseComponentId( |
| 30 | componentId: string |
| 31 | ): string | Record<string, unknown> { |
| 32 | if (componentId.startsWith('{') && componentId.endsWith('}')) { |
| 33 | try { |
| 34 | return JSON.parse(componentId); |
| 35 | } catch { |
| 36 | // Not valid JSON, return as-is |
| 37 | return componentId; |
| 38 | } |
| 39 | } |
| 40 | return componentId; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Initialize the WebSocket observer. |
no test coverage detected
searching dependent graphs…