( rootComponentInternalMetadata: ReactComponentInternalMetadata )
| 1315 | } |
| 1316 | |
| 1317 | export const buildReactTrees = ( |
| 1318 | rootComponentInternalMetadata: ReactComponentInternalMetadata |
| 1319 | ) => { |
| 1320 | const rootRenderTreeNode: ReactRenderTreeNode = |
| 1321 | rootComponentInternalMetadata.kind === "empty-slot" |
| 1322 | ? { |
| 1323 | kind: "empty-slot", |
| 1324 | parent: null, |
| 1325 | } |
| 1326 | : // this looks super weird, but we transform the root metadata into an implicit |
| 1327 | // component that returns the provided internal metadata |
| 1328 | { |
| 1329 | kind: "real-element", |
| 1330 | childNodes: [], |
| 1331 | computedViewTreeNodeId: null, |
| 1332 | hasRendered: false, |
| 1333 | hooks: [], |
| 1334 | id: crypto.randomUUID(), |
| 1335 | indexPath: [], |
| 1336 | internalMetadata: { |
| 1337 | component: { |
| 1338 | kind: "function", |
| 1339 | function: () => rootComponentInternalMetadata, |
| 1340 | name: "root", |
| 1341 | }, |
| 1342 | children: [], |
| 1343 | id: crypto.randomUUID(), |
| 1344 | kind: "real-element", |
| 1345 | props: null, |
| 1346 | provider: null, |
| 1347 | // parent: null |
| 1348 | }, |
| 1349 | parent: null, |
| 1350 | }; |
| 1351 | |
| 1352 | currentTreeRef.renderTree = { |
| 1353 | root: rootRenderTreeNode, |
| 1354 | currentLastRenderChildNodes: [], |
| 1355 | currentLocalCurrentHookOrder: 0, |
| 1356 | currentlyRendering: null, |
| 1357 | }; |
| 1358 | |
| 1359 | console.log("\n\nRENDER START----------------------------------------------"); |
| 1360 | const output = generateViewTree({ |
| 1361 | renderNode: rootRenderTreeNode, |
| 1362 | parentViewNode: null, |
| 1363 | }); |
| 1364 | |
| 1365 | console.log("RENDER END----------------------------------------------\n\n"); |
| 1366 | const reactViewTree: ReactViewTree = { |
| 1367 | root: output, |
| 1368 | }; |
| 1369 | |
| 1370 | currentTreeRef.viewTree = reactViewTree; |
| 1371 | currentTreeRef.renderTree.currentlyRendering = null; |
| 1372 | |
| 1373 | return { |
| 1374 | reactRenderTree: currentTreeRef.renderTree, |
no test coverage detected