UNPKG

marko

Version:

Optimized runtime for Marko templates.

54 lines (53 loc) • 1.72 kB
import { type $Global, type Template } from "../common/types"; import { type ServerRenderer } from "./template"; import { type Boundary } from "./writer"; declare const kAssets: unique symbol; declare const kHead: unique symbol; export interface VisibleTrigger { type: "visible"; selector: string; options?: { rootMargin?: string; }; } export interface IdleTrigger { type: "idle"; selector?: never; options?: { timeout?: number; }; } export interface MediaTrigger { type: "media"; selector: string; options?: never; } export interface EventTrigger { type: `on-${string}`; selector: string; options?: never; } export type LoadTrigger = VisibleTrigger | IdleTrigger | MediaTrigger | EventTrigger; type Trigger = LoadTrigger; interface Asset { id: string; flush: AssetFlush; triggers: Trigger[] | undefined; block: string | undefined; defer: string | undefined; script: string | undefined; htmlAt: Boundary | null | undefined; scriptAt: Boundary | null | undefined; } declare module "../common/types" { interface $Global { [kAssets]?: Asset[]; [kHead]?: true; } } type AssetFlush = (g: $Global, type: "block" | "defer", asset: string) => string; export declare function withLoadAssets(renderer: ServerRenderer, flush: AssetFlush, assetId: string, triggers?: Trigger[]): ServerRenderer; export declare function writeLoadAsset(assetId: string, flush: AssetFlush, triggers?: Trigger[]): void; export declare function withPageAssets(template: ServerRenderer & Template, flush: AssetFlush, assetId: string, runtimeId?: string): Template; export declare function _flush_head(): string; export {};