feat(server): multiple island exports (#1397)
This commit is contained in:
@@ -47,8 +47,11 @@ function isElementNode(node: Node): node is HTMLElement {
|
||||
return node.nodeType === Node.ELEMENT_NODE;
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
export function revive(islands: Record<string, ComponentType>, props: any[]) {
|
||||
export function revive(
|
||||
islands: Record<string, Record<string, ComponentType>>,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
props: any[],
|
||||
) {
|
||||
_walkInner(
|
||||
islands,
|
||||
props,
|
||||
@@ -127,7 +130,7 @@ interface Marker {
|
||||
* fashion over an HTMLElement's children list.
|
||||
*/
|
||||
function _walkInner(
|
||||
islands: Record<string, ComponentType>,
|
||||
islands: Record<string, Record<string, ComponentType>>,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
props: any[],
|
||||
markerStack: Marker[],
|
||||
@@ -253,7 +256,7 @@ function _walkInner(
|
||||
}
|
||||
} else if (comment.startsWith("frsh")) {
|
||||
// We're opening a new island
|
||||
const [id, n] = comment.slice(5).split(":");
|
||||
const [id, exportName, n] = comment.slice(5).split(":");
|
||||
const islandProps = props[Number(n)];
|
||||
|
||||
markerStack.push({
|
||||
@@ -262,7 +265,7 @@ function _walkInner(
|
||||
text: comment,
|
||||
kind: MarkerKind.Island,
|
||||
});
|
||||
const vnode = h(islands[id], islandProps);
|
||||
const vnode = h(islands[id][exportName], islandProps);
|
||||
vnodeStack.push(vnode);
|
||||
}
|
||||
} else if (isTextNode(sib)) {
|
||||
|
||||
Reference in New Issue
Block a user