UNPKG

@soleil-se/app-util

Version:

Utility functions for WebApps, RESTApps and Widgets in Sitevision.

41 lines (40 loc) 1.78 kB
/// <reference types="svelte" /> /** * @template {import('svelte').Component<any, any>} TComponent * @typedef {object} RenderSettings * @property {HTMLElement} [target] Target where app should be mounted. * @property {import('svelte').ComponentProps<TComponent>} [props] Root component props. * @property {boolean} [hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing DOM * (usually from server-side rendering) rather than creating new elements. By default the app will * hydrate when the target has any child nodes. * @property {boolean} [intro=false] If true, will play transitions on initial render, rather than * waiting for subsequent state changes. */ /** * Renders a client side Svelte application. * @template {import('svelte').Component<any, any>} TComponent * @param {TComponent} App Svelte app root component. * @param {RenderSettings<TComponent>} [settings={}] Settings object. */ export function render<TComponent extends import("svelte").Component<any, any, string>>(App: TComponent, { target, props, hydrate, intro, }?: RenderSettings<TComponent>): void; export type RenderSettings<TComponent extends import("svelte").Component<any, any, string>> = { /** * Target where app should be mounted. */ target?: HTMLElement; /** * Root component props. */ props?: import('svelte').ComponentProps<TComponent>; /** * Instructs Svelte to upgrade existing DOM * (usually from server-side rendering) rather than creating new elements. By default the app will * hydrate when the target has any child nodes. */ hydrate?: boolean; /** * If true, will play transitions on initial render, rather than * waiting for subsequent state changes. */ intro?: boolean; };