import { EventName } from '@lit/react'; import { StencilReactComponent } from './create-component.js'; type EventNames = Record; export type { ReactWebComponent, WebComponentProps } from '@lit/react'; export type SerializeShadowRootOptions = 'declarative-shadow-dom' | 'scoped' | { 'declarative-shadow-dom'?: string[]; scoped?: string[]; default: 'declarative-shadow-dom' | 'scoped'; } | boolean; /** * these types are defined by a Stencil hydrate app so we have to copy the minimal types here */ export interface RenderToStringOptions { fullDocument?: boolean; prettyHtml?: boolean; /** * Configure how Stencil serializes the components shadow root. * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM. * - If set to `scoped` Stencil will render the contents of the shadow root as a `scoped: true` component * and the shadow DOM will be created during client-side hydration. * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys, * the value arrays containing the tag names of the components that should be rendered in that mode. * * Examples: * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }` * Render all components as `scoped` apart from `my-component-1` and `another-component` * - `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }` * Render all components within `declarative-shadow-dom` apart from `an-option-component` * - `'scoped'` Render all components as `scoped` * - `false` disables shadow root serialization * * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped` * @default 'declarative-shadow-dom' */ serializeShadowRoot?: SerializeShadowRootOptions; /** * Render into one long-lived window instead of creating one for every call, so the SSR runtime * and components are set up once. Stencil v5+ only (see {@link HydrateModule.resetReusableWindows}). */ reuseWindow?: boolean; /** @deprecated use `beforeSsr` — kept for v4/v5 compatibility */ beforeHydrate?: (document: Document) => void | Promise; } export interface HydrateStyleElement { id?: string; href?: string | null; content?: string; } type RenderToString = (html: string, options: RenderToStringOptions) => Promise<{ html: string | null; styles: HydrateStyleElement[]; }>; export type HydrateModule = { renderToString: RenderToString; transformTag: (tagName: string) => string; setTagTransformer: (transformer: (tagName: string) => string) => void; /** * Exported by SSR modules that support the `reuseWindow` render option (Stencil v5+). Its * presence is how we detect that support: older modules don't have it. */ resetReusableWindows?: () => void; }; interface CreateComponentForServerSideRenderingOptions { tagName: string; properties: Record; renderToString: RenderToString; serializeShadowRoot?: SerializeShadowRootOptions; transformTag?: (tagName: string) => string; /** * Pass `reuseWindow: true` to `renderToString`. Every Stencil component renders with its own * `renderToString` call, so setting the SSR runtime up once instead of per call is a large share * of each render. */ reuseWindow?: boolean; } type ParseHTML = typeof import('html-react-parser').htmlToDOM; /** * Split a component rendered with `renderToString({ fullDocument: false })` into its parts. The * fragment is parsed (so quotes, comments and `<` in attribute values are handled) and the parts * are sliced from the original string, so they keep Stencil's markup exactly. * * Stencil v5 starts a fragment with the `