import type { Children, Component, Context } from "./crank.js";
/**
* Creates a lazy-loaded component from an initializer function.
*
* @param initializer - Function that returns a Promise resolving to a component or module
* @returns A component that loads the target component on first render
*
* @example
* ```jsx
* const LazyComponent = lazy(() => import('./MyComponent'));
*
* Loading...}>
*
*
* ```
*/
export declare function lazy(initializer: () => Promise): T;
/**
* A component that displays a fallback while its children are loading.
*
* When used within a SuspenseList, coordinates with siblings to control
* reveal order and fallback behavior.
*
* @param children - The content to display when loading is complete
* @param fallback - The content to display while children are loading
* @param timeout - Time in milliseconds before showing fallback (defaults to
* 300ms standalone, or inherits from SuspenseList)
*
* @example
* ```jsx
* Loading...}>
*
*
* ```
*/
export declare function Suspense(this: Context, { children, fallback, timeout, }: {
children: Children;
fallback: Children;
timeout?: number;
}): AsyncGenerator;
declare const SuspenseListController: unique symbol;
interface SuspenseListItem {
ctx: Context;
resolve: () => void;
promise: Promise;
}
interface SuspenseListController {
timeout?: number;
revealOrder?: "forwards" | "backwards" | "together";
tail?: "collapsed" | "hidden";
register(ctx: Context): Promise>;
isHead(ctx: Context, items: Array): boolean;
scheduleFallback(ctx: Context, items: Array): Promise;
scheduleChildren(ctx: Context, items: Array): Promise;
}
declare global {
namespace Crank {
interface ProvisionMap {
[SuspenseListController]: SuspenseListController;
}
}
}
/**
* Controls when child components show their content or fallbacks
* based on the specified reveal order. The resolves when
* coordination effort is complete (not necessarily when all content is
* loaded).
*
* @param revealOrder - How children should be revealed:
* - "forwards" (default): Show children in document order, waiting for
* predecessors
* - "backwards": Show children in reverse order, waiting for successors
* - "together": Show all children simultaneously when all are ready
* In Crank, the default behavior of async components is to render together,
* so "together" might not be necessary if you are not using
* fallbacks.
*e@param tail - How to handle fallbacks:
* - "collapsed" (default): Show only the fallback for the next unresolved
* Suspense component
* - "hidden": Hide all fallbacks
* Tail behavior only applies when revealOrder is not "together".
* @param timeout - Default timeout for Suspense children in milliseconds
* @param children - The elements containing Suspense components to coordinate.
* Suspense components which are not rendered immediately (because they are
* the children of another async component) will not be coordinated.
*
* @example
* ```jsx
*
* Loading A...}>
*
*
* Loading B...}>
*
*
*
* ```
*/
export declare function SuspenseList(this: Context, { revealOrder, tail, timeout, children, }: {
revealOrder?: "forwards" | "backwards" | "together";
tail?: "collapsed" | "hidden";
timeout?: number;
children: Children;
}): Generator;
export {};