From 7ce19f435925dd4f38a95839e8a2dbc6052cb079 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Thu, 27 Apr 2023 07:28:41 -0700 Subject: [PATCH] Add static attributes from reduction trace Summary: In order to support this the stream inceptor transform nodes now is able to return a list of new meta enties, since these are new attributes we try to mimic what would have happened if they were generated on the client. This makes the rest of the logic downstream simpler Introduced metadata register, same idea as on the clients. The attributes available are a mixed bag, will work with blok server to imporove Reviewed By: antonk52 Differential Revision: D45177781 fbshipit-source-id: 9d761b2f682e7e0fd4710f5b2e9d9d6ff26741fc --- .../ui-debugger/fb-stubs/StreamInterceptor.tsx | 6 ++++-- desktop/plugins/public/ui-debugger/index.tsx | 13 ++++++++++--- desktop/plugins/public/ui-debugger/types.tsx | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/fb-stubs/StreamInterceptor.tsx b/desktop/plugins/public/ui-debugger/fb-stubs/StreamInterceptor.tsx index f3a2d2f17..e2561b64b 100644 --- a/desktop/plugins/public/ui-debugger/fb-stubs/StreamInterceptor.tsx +++ b/desktop/plugins/public/ui-debugger/fb-stubs/StreamInterceptor.tsx @@ -18,8 +18,10 @@ class NoOpStreamInterceptor implements StreamInterceptor { return null; } - async transformNodes(nodes: Map): Promise> { - return nodes; + async transformNodes( + nodes: Map, + ): Promise<[Map, Metadata[]]> { + return [nodes, []]; } async transformMetadata(metadata: Metadata): Promise { diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 93aad26b7..45acc3141 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -238,9 +238,16 @@ export function plugin(client: PluginClient) { const seenNodes = new Set(); const processFrame = async (frameScan: FrameScanEvent) => { try { - const processedNodes = await streamInterceptor.transformNodes( - new Map(frameScan.nodes.map((node) => [node.id, {...node}])), - ); + const [processedNodes, additionalMetadata] = + await streamInterceptor.transformNodes( + new Map(frameScan.nodes.map((node) => [node.id, {...node}])), + ); + + metadata.update((draft) => { + for (const metadata of additionalMetadata) { + draft.set(metadata.id, metadata); + } + }); applyFrameData(processedNodes, frameScan.snapshot); diff --git a/desktop/plugins/public/ui-debugger/types.tsx b/desktop/plugins/public/ui-debugger/types.tsx index 623aff641..7a02b670f 100644 --- a/desktop/plugins/public/ui-debugger/types.tsx +++ b/desktop/plugins/public/ui-debugger/types.tsx @@ -284,7 +284,9 @@ export type InspectableUnknown = { }; export interface StreamInterceptor { - transformNodes(nodes: Map): Promise>; + transformNodes( + nodes: Map, + ): Promise<[Map, Metadata[]]>; transformMetadata(metadata: Metadata): Promise; }