UNPKG

@lwc/ssr-runtime

Version:

Runtime complement to @lwc/ssr-compiler

74 lines 4.76 kB
import { type Stylesheet } from '@lwc/shared'; import { SYMBOL__GENERATE_MARKUP } from './lightning-element'; import type { CompilationMode } from '@lwc/shared'; import type { LightningElement, LightningElementConstructor } from './lightning-element'; import type { Attributes, Properties } from './types'; /** Parameters used by all `generateMarkup` variants that don't get transmogrified. */ type BaseGenerateMarkupParams = readonly [ tagName: string, props: Properties | null, attrs: Attributes | null, parent: LightningElement | null, scopeToken: string | null, contextfulParent: LightningElement | null, renderContext: RenderContext ]; /** Slotted content function used by `asyncYield` mode. */ type SlottedContentGenerator = (instance: LightningElement) => AsyncGenerator<string, void, unknown>; /** Slotted content function used by `sync` and `async` modes. */ type SlottedContentEmitter = (instance: LightningElement) => void; /** Slotted content map used by `asyncYield` mode. */ type SlottedContentGeneratorMap = Record<number | string, SlottedContentGenerator[]>; /** Slotted content map used by `sync` and `async` modes. */ type SlottedContentEmitterMap = Record<number | string, SlottedContentEmitter[]>; /** `generateMarkup` parameters used by `asyncYield` mode. */ type GenerateMarkupGeneratorParams = readonly [ ...BaseGenerateMarkupParams, shadowSlottedContent: SlottedContentGenerator | null, lightSlottedContent: SlottedContentGeneratorMap | null, scopedSlottedContent: SlottedContentGeneratorMap | null ]; /** `generateMarkup` parameters used by `sync` and `async` modes. */ type GenerateMarkupEmitterParams = readonly [ ...BaseGenerateMarkupParams, shadowSlottedContent: SlottedContentEmitter | null, lightSlottedContent: SlottedContentEmitterMap | null, scopedSlottedContent: SlottedContentEmitterMap | null ]; /** Signature for `asyncYield` compilation mode. */ export type GenerateMarkupAsyncYield = (...args: GenerateMarkupGeneratorParams) => AsyncGenerator<string>; /** Signature for `async` compilation mode. */ export type GenerateMarkupAsync = (...args: GenerateMarkupEmitterParams) => Promise<string>; /** Signature for `sync` compilation mode. */ export type GenerateMarkupSync = (...args: GenerateMarkupEmitterParams) => string; type GenerateMarkupVariants = GenerateMarkupAsyncYield | GenerateMarkupAsync | GenerateMarkupSync; export declare function renderAttrs(instance: LightningElement, attrs: Attributes, hostScopeToken: string | undefined, scopeToken: string | undefined): Generator<string, void, unknown>; export declare function renderAttrsNoYield(instance: LightningElement, attrs: Attributes, hostScopeToken: string | undefined, scopeToken: string | undefined): string; export declare function fallbackTmpl(shadowSlottedContent: SlottedContentGenerator | null, _lightSlottedContent: SlottedContentGeneratorMap | null, _scopedSlottedContent: SlottedContentGeneratorMap | null, Cmp: LightningElementConstructor, instance: LightningElement, _renderContext: RenderContext): AsyncGenerator<string>; export declare function fallbackTmplNoYield(shadowSlottedContent: SlottedContentEmitter | null, _lightSlottedContent: SlottedContentEmitterMap | null, _scopedSlottedContent: SlottedContentEmitterMap | null, Cmp: LightningElementConstructor, instance: LightningElement, _renderContext: RenderContext): string; export declare function addSlottedContent(name: string, fn: unknown, contentMap: Record<string, unknown[]>): void; interface ComponentWithGenerateMarkup extends LightningElementConstructor { [SYMBOL__GENERATE_MARKUP]?: GenerateMarkupVariants; } export declare class RenderContext { styleDedupeIsEnabled: boolean; styleDedupePrefix: string; stylesheetToId: WeakMap<Stylesheet, string>; nextId: number; constructor(styleDedupe: string | boolean); getNextId(): number; } /** * Create a string representing an LWC component for server-side rendering. * @param tagName The HTML tag name of the component * @param Component The `LightningElement` component constructor * @param props HTML attributes to provide for the root component * @param styleDedupe Provide a string key or `true` to enable style deduping via the `<lwc-style>` * helper. The key is used to avoid collisions of global IDs. * @param mode SSR render mode. Can be 'sync', 'async' or 'asyncYield'. Must match the render mode * used to compile your component. * @returns String representation of the component */ export declare function serverSideRenderComponent(tagName: string, Component: ComponentWithGenerateMarkup, props?: Properties, styleDedupe?: string | boolean, mode?: CompilationMode): Promise<string>; export {}; //# sourceMappingURL=render.d.ts.map