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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
42963b16ab
commit
7ce19f4359
@@ -18,8 +18,10 @@ class NoOpStreamInterceptor implements StreamInterceptor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async transformNodes(nodes: Map<Id, UINode>): Promise<Map<Id, UINode>> {
|
async transformNodes(
|
||||||
return nodes;
|
nodes: Map<Id, UINode>,
|
||||||
|
): Promise<[Map<Id, UINode>, Metadata[]]> {
|
||||||
|
return [nodes, []];
|
||||||
}
|
}
|
||||||
|
|
||||||
async transformMetadata(metadata: Metadata): Promise<Metadata> {
|
async transformMetadata(metadata: Metadata): Promise<Metadata> {
|
||||||
|
|||||||
@@ -238,9 +238,16 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
const seenNodes = new Set<Id>();
|
const seenNodes = new Set<Id>();
|
||||||
const processFrame = async (frameScan: FrameScanEvent) => {
|
const processFrame = async (frameScan: FrameScanEvent) => {
|
||||||
try {
|
try {
|
||||||
const processedNodes = await streamInterceptor.transformNodes(
|
const [processedNodes, additionalMetadata] =
|
||||||
new Map(frameScan.nodes.map((node) => [node.id, {...node}])),
|
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);
|
applyFrameData(processedNodes, frameScan.snapshot);
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,9 @@ export type InspectableUnknown = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface StreamInterceptor {
|
export interface StreamInterceptor {
|
||||||
transformNodes(nodes: Map<Id, UINode>): Promise<Map<Id, UINode>>;
|
transformNodes(
|
||||||
|
nodes: Map<Id, UINode>,
|
||||||
|
): Promise<[Map<Id, UINode>, Metadata[]]>;
|
||||||
|
|
||||||
transformMetadata(metadata: Metadata): Promise<Metadata>;
|
transformMetadata(metadata: Metadata): Promise<Metadata>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user