feat: a new "island" based architechture (#97)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// This module adds twind support.
|
||||
|
||||
import { setup } from "../client_deps.ts";
|
||||
import { RenderContext, RenderFn, virtualSheet } from "../server_deps.ts";
|
||||
|
||||
const sheet = virtualSheet();
|
||||
sheet.reset();
|
||||
setup({ sheet });
|
||||
|
||||
export function render(ctx: RenderContext, render: RenderFn) {
|
||||
const snapshot = ctx.state.get("twindSnapshot") as unknown[] | null;
|
||||
sheet.reset(snapshot || undefined);
|
||||
render();
|
||||
ctx.styles.splice(0, ctx.styles.length, ...sheet.target);
|
||||
const newSnapshot = sheet.reset();
|
||||
ctx.state.set("twindSnapshot", newSnapshot);
|
||||
}
|
||||
Reference in New Issue
Block a user