@lifeart/gxt
Version:
<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">
44 lines (43 loc) • 1.49 kB
TypeScript
/**
* DOM provider factory for SSR.
*
* GXT's SSR entry historically bound itself to happy-dom via a hard dynamic
* import. That makes it impossible for a host environment — e.g. Ember's
* FastBoot, which uses SimpleDOM — to reuse GXT's SSR pipeline with a
* different DOM implementation.
*
* This module introduces a small factory interface so the host can inject
* their own DOM. When no provider is supplied, `defaultHappyDomProvider`
* is used and behavior is identical to before.
*/
export interface SsrDomInstance {
/** The DOM window object (or window-like). */
window: any;
/** The document created by the provider. */
document: any;
/**
* An `XMLSerializer` constructor compatible with the provider's nodes.
* `ssr.ts` uses this to serialize rendered children to HTML.
*/
XMLSerializer: {
new (): {
serializeToString(node: any): string;
};
};
/**
* Release any resources held by the provider (e.g. happy-dom's
* `cancelAsync` + `close`). Called unconditionally after render.
*/
dispose(): void;
}
export interface SsrDomProvider {
createDocument(options: {
url: string;
}): SsrDomInstance;
}
/**
* Default provider — lazily imports happy-dom and preserves the exact
* shutdown semantics of the previous inline implementation
* (`win.happyDOM.cancelAsync(); win.close();`).
*/
export declare function defaultHappyDomProvider(): Promise<SsrDomProvider>;