import { State } from "./state.js"; import { Host } from "./runtime.js"; //#region src/component.d.ts type IfEquals = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? A : B; /** Keys of T which are settable (excludes get-only accessors and `readonly`). */ type Acceptable = { [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P, never> }[keyof T]; declare namespace Component { /** * Host element type produced by `Component.render`. Delegates to the * {@link Host} manifest on the jsx-runtime entry; falls back to `any` * until an adapter augments it with `node`. `any` (not `unknown`) so an * un-annotated `render` override in a host-agnostic package still emits a * JSX-valid return - `any` is assignable to every host's node type, where * `unknown` is assignable to none. */ type Node = Host extends { node: infer T; } ? T : any; interface BaseProps { /** * Callback for newly created instance. Only called once. * * Runs after props apply but **before** the `new()` lifecycle hook - so it * may configure state that `new()` then observes. To react to a fully * initialized instance instead, use `watch` or an effect. */ is?: (instance: T) => void; /** * Fallback to show when suspended or in error recovery. * Pass `false` to opt out of the component's own suspense boundary, * letting suspension bubble to an ancestor. */ fallback?: Component.Node; } type StateProps = { [K in Exclude & Acceptable]?: T[K] }; type RenderProps = [T] extends [(props: infer P) => any] ? [keyof NonNullable

] extends [never] ? { children?: Component.Node; } : NonNullable

: { children?: Component.Node; }; type Props = StateProps & BaseProps & RenderProps; } declare class Component extends State { /** * All JSX attributes passed to this component. * Includes state-derived props, render props, and built-in props like `is` and `fallback`. * * Will incorperate extra props you declare as props parameter in `render` method. */ readonly props: Component.Props; /** Stable identity used when this instance is rendered in a collection. */ readonly key: string; /** * Content to display while this component or its children are suspended. * Will cover suspense by pending properties in `this.render` as well. * Can be set as a class property or overridden via the `fallback` JSX prop. * * Defaults to null - nothing will be rendered. * Set `false` to opt out of having a boundary at all - suspension then * bubbles to the nearest ancestor boundary. */ fallback: Component.Node; constructor(props?: any, ...rest: any[]); /** * Output for this component. Override to define custom JSX. * * Properties accessed via `this` are reactive and trigger a render when they * change, in addition to props. Accepts an optional parameter to receive extra * props from JSX, beyond those merged to state properties; declare its shape * via `props = {} as { ... }`. Without a parameter (the default below), * children pass through. * * The constructor installs a composed `render` per instance; the bootstrap * `type` pass seals this and any override non-configurable, keeping it the * content-render seam the chain reads. */ render(props?: {}): Component.Node; /** * Called when a child component throws during render. * While this is pending, `fallback` is displayed. * When resolved, the error boundary resets and `render` is called again. * * Override to handle errors - set `this.fallback` for error-specific UI, * await async recovery, or await user interaction before retrying. If you * assign a fallback within catch, it will be reverted after resolved. */ catch?(error: Error): Promise | void; } //#endregion export { Component }; //# sourceMappingURL=component.d.ts.map