Askr documentation
Generated API snapshot

@askrjs/askr

Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.

Exports

This entrypoint publishes 53 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

AskrRuntimetype

AskrRuntime: typeof AskrRuntime

A scheduler + renderer host pairing; owns scheduling and renderer wiring for an app instance.

scheduler
readonly scheduler: Scheduler;
rendererHost
private rendererHost;
renderer
get renderer(): RuntimeRendererHost;
configureRenderer
configureRenderer(renderer: RuntimeRendererHost): void;

AskrRuntimeOptionstype

AskrRuntimeOptions: any

Options for {@link createRuntime}.

scheduler
scheduler?: Scheduler;
renderer
renderer?: RuntimeRendererHost;

Casetype

Case: (props: CaseProps) => JSXElement

Render the first matching {@link Match} child (by `when`), or `fallback` if none match.

CasePropstype

CaseProps: {
  fallback?: BoundaryChild;
  children?: unknown;
}

Props for {@link Case}.

children
children?: unknown;
fallback
fallback?: RenderableChild;

configureRenderDiagnosticstype

configureRenderDiagnostics: (options: RenderDiagnosticsOptions) => () => void

Configure development render diagnostics and return a function that restores the previous configuration. Component counters and timing remain enabled when warning output is disabled.

createQuerytype

createQuery: { <T extends {}>(options: QueryOptions<T>): Query<T>; <TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>, input: TInput, options?: Omit<QueryOptions<TResult>, "key" | "fetch">): Query<TResult>; }

Create a reactive {@link Query} cell bound to the current component, either from inline `options` (key + fetch) or a reusable {@link QueryDefinition} plus its input.

createQueryCollectiontype

createQueryCollection: <TInput, TResult extends {}, TKey extends QueryCollectionKey = string>(options: QueryCollectionOptions<TInput, TResult, TKey>) => QueryCollection<TInput, TResult, TKey>

Create one lifecycle-owned collection of dynamically keyed readers for a reusable query definition, with bounded collection-started fetches.

createReftype

createRef: <T extends Element = Element>() => Ref<T>

Create a new, empty {@link Ref} holder.

createRuntimetype

createRuntime: (options?: AskrRuntimeOptions) => AskrRuntime

Create a new {@link AskrRuntime} instance with its own scheduler/renderer wiring.

cspNoncetype

cspNonce: () => string | undefined

Read the CSP nonce for the current render from {@link CspNonceScope}.

CspNonceScopetype

CspNonceScope: Scope<string | undefined>

Lexical scope carrying the CSP nonce for the current render, if any.

DataRuntimetype

DataRuntime: any

Isolated cache/state container backing queries and mutations, e.g. one per test or request.

queryCache
readonly queryCache: Map<string, unknown>;
queryData
readonly queryData: Map<string, unknown>;
queryTestOverrides
Test-only query overrides keyed by the canonical query key.
mutationTestOverrides
Test-only mutation overrides keyed by the canonical mutation key.

defineQuerytype

defineQuery: <TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>) => QueryDefinition<TInput, TResult>

Freeze and return a reusable {@link QueryDefinition}.

defineScopetype

defineScope: <T>(defaultValue: T) => Scope<T>

Create a new lexical {@link Scope} with `defaultValue`, readable via {@link readScope}.

defineServerQueriestype

defineServerQueries: (...entries: readonly ServerQueryEntry<any, any>[]) => ServerQueryRegistry

Build a {@link ServerQueryRegistry} from one or more {@link serveQuery} entries.

dehydrateDataRuntimetype

dehydrateDataRuntime: (runtime: DataRuntime) => Record<string, unknown>

Extract a runtime's cached query data into a JSON-serializable snapshot, dropping non-serializable values.

derivetype

derive: { <TOut>(fn: () => TOut): Derived<TOut>; <TIn, TOut>(source: SnapshotSource<TIn> | TIn | (() => TIn), map: (value: TIn) => TOut): Derived<TOut | null>; }

Creates a render-scoped derived value; must be called during component render.

Derivedtype

Derived: any

A reactive derived value produced by {@link derive}; call it to read the current result.

Fortype

For: <T, K extends string | number = string | number>(props: ForProps<T, K>) => JSXElement

Render a keyed or indexed list, reconciling items by key instead of position.

ForPropstype

ForProps: KeyedForProps<T, K> | IndexedForProps<T>

Props for {@link For}.

by
by?: ((item: T, index: number) => K) | undefined;
byIndex
byIndex?: true | undefined;
children
Row renderer. Parent reactive reads must use `selector()` or thunk props; closure-captured values are snapshotted when the row is created or reconciled; changing the parent source does not rerun an existing row.
each
each: ForEachSource<T>;
fallback
fallback?: RenderableChild;

Fragmenttype

Fragment: typeof Fragment

The element type marker for JSX fragments (`<>...</>`), groups children without a wrapper element.

getDefaultRuntimetype

getDefaultRuntime: () => AskrRuntime

Get the process-wide default {@link AskrRuntime}.

getSignaltype

getSignal: () => AbortSignal

Get the abort signal for the current component. The signal is guaranteed to be aborted when: - Component unmounts - Navigation occurs (different route) - Parent is destroyed

hydrateDataRuntimetype

hydrateDataRuntime: (runtime: DataRuntime, data: unknown) => void

Load a {@link dehydrateDataRuntime} snapshot back into a runtime's query cache.

jsxtype

jsx: { (type: EagerControlPrimitive, props: Props | null, key?: string | number): unknown; <TTag extends keyof KnownIntrinsicElementProps>(type: TTag, props: KnownIntrinsicElementProps[TTag] | null, key?: string | number): JSXElement; <TTag extends string>(type: Exclude<TTag, keyof KnownIntrinsicElementProps>, props: IntrinsicFallbackProps | null, key?: string | number): JSXElement; <TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number): JSXElement; (type: symbol, props: Props | null, key?: string | number): JSXElement; }

JSX factory for elements with a single or no child, used by the `jsxImportSource` transform.

jsxstype

jsxs: { (type: EagerControlPrimitive, props: Props | null, key?: string | number): unknown; <TTag extends keyof KnownIntrinsicElementProps>(type: TTag, props: KnownIntrinsicElementProps[TTag] | null, key?: string | number): JSXElement; <TTag extends string>(type: Exclude<TTag, keyof KnownIntrinsicElementProps>, props: IntrinsicFallbackProps | null, key?: string | number): JSXElement; <TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number): JSXElement; (type: symbol, props: Props | null, key?: string | number): JSXElement; }

JSX factory for elements with multiple static children, used by the `jsxImportSource` transform.

Matchtype

Match: (_props: MatchProps) => null

Declares one branch of a {@link Case}; only valid as its direct child.

MatchPropstype

MatchProps: {
  key?: string | number | null;
  when: unknown;
  children: MatchChild;
}

Props for {@link Match}, valid only as a direct child of {@link Case}.

children
children: MatchChild;
key
key?: string | number | null | undefined;
when
when: unknown;

prefetchQuerytype

prefetchQuery: <TInput, TResult extends {}>(context: QueryPrefetchContext, query: QueryDefinition<TInput, TResult>, input: TInput) => Promise<boolean>

Prefetch `query` with `input` into a {@link QueryPrefetchContext}'s runtime.

Propstype

Props: any

Props accepted by components and elements. Intentionally permissive but provides a single named type.

children
Optional children slot
key
Optional key for keyed lists (string | number | symbol for internal frames)

QueryCollectiontype

QueryCollection: any

Aggregate reactive state for a lifecycle-owned dynamic query collection.

entries
readonly entries: readonly QueryCollectionEntry<TInput, TResult, TKey>[];
loading
readonly loading: boolean;
settled
readonly settled: boolean;
results
readonly results: ReadonlyMap<TKey, TResult>;
errors
readonly errors: ReadonlyMap<TKey, {}>;
get
get(key: TKey): QueryCollectionEntry<TInput, TResult, TKey> | undefined;
retry
retry(key: TKey): Promise<void>;

QueryCollectionEntrytype

QueryCollectionEntry: any

One keyed input and its underlying cache-backed query reader.

key
readonly key: TKey;
input
readonly input: TInput;
query
readonly query: Query<TResult>;

QueryCollectionKeytype

QueryCollectionKey: string | number | symbol

Stable identity for one member of a {@link QueryCollection}.

QueryCollectionOptionstype

QueryCollectionOptions: any

Options for {@link createQueryCollection}.

query
readonly query: QueryDefinition<TInput, TResult>;
inputs
readonly inputs: () => readonly TInput[];
key
readonly key: (input: TInput) => TKey;
concurrency
readonly concurrency?: number;
runtime
readonly runtime?: DataRuntime;

QueryDefinitiontype

QueryDefinition: any

Reusable query definition for {@link defineQuery}: key, fetcher, and freshness checks.

key
readonly key: (input: TInput) => string;
fetch
readonly fetch: (context: TInput & { signal: AbortSignal; }) => Promise<TResult>;
isConsistent
readonly isConsistent?: (data: TResult) => boolean;
reconcile
readonly reconcile?: (data: TResult, context: { key: string; }) => Promise<boolean> | boolean;

QueryPrefetchContexttype

QueryPrefetchContext: any

Context passed to server prefetch callbacks, exposing a scoped `prefetch` helper.

runtime
readonly runtime: DataRuntime;
request
readonly request?: Request;
signal
readonly signal: AbortSignal;
mode
readonly mode: 'ssr' | 'spa';
prefetch
prefetch<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>, input: TInput): Promise<boolean>;

readScopetype

readScope: <T>(context: Scope<T>) => T

Read the current value of a {@link Scope} during component render or an async resource.

Reftype

Ref: any

Creates a stable holder for an intrinsic element ref. The renderer mutates `current` during commit and clears it during cleanup. Updating the holder never schedules a render.

current
current: T | null;

registerSSRStyletype

registerSSRStyle: (id: string, cssText: string) => void

Register request-local CSS produced during SSR without importing the SSR renderer in clients.

RenderDiagnosticsOptionstype

RenderDiagnosticsOptions: any
slowRenderWarnings
Emit one warning per component instance when a render exceeds the threshold.
slowRenderThresholdMs
Slow-render threshold in milliseconds. The default is 5.

RuntimeKeyedReorderDecisiontype

RuntimeKeyedReorderDecision: any

Diagnostic breakdown of a keyed-list reorder decision, returned by {@link RuntimeRendererHost.isKeyedReorderFastPathEligible}.

useFastPath
useFastPath: boolean;
totalKeyed
totalKeyed: number;
totalChildren
totalChildren: number;
currentKeyCount
currentKeyCount: number;
moveCount
moveCount: number;
lisLen
lisLen: number;
hasPropChanges
hasPropChanges: boolean;
isWholeKeyedList
isWholeKeyedList: boolean;

RuntimeRendererHosttype

RuntimeRendererHost: any

The renderer implementation an {@link AskrRuntime} delegates DOM evaluation and cleanup to.

evaluate
evaluate(node: unknown, target: Element | null, context?: object, retainedOwner?: ComponentInstance): void;
cleanupInstancesUnder
cleanupInstancesUnder(node: Node): void;
replaceComponentRange
replaceComponentRange(instance: ComponentInstance, result: unknown, host: Element | Comment): Node | null;
resolveChildScopeRange
resolveChildScopeRange?(scope: ChildScope): DOMRange | null;
teardownNodeSubtree
teardownNodeSubtree(root: Node): void;
populateKeyMapForElement
populateKeyMapForElement(parent: Element): void;
getKeyMapForElement
getKeyMapForElement(parent: Element): Map<string | number, Element> | undefined;
isKeyedReorderFastPathEligible
isKeyedReorderFastPathEligible(parent: Element, children: unknown[], oldKeyMap: Map<string | number, Element> | undefined): RuntimeKeyedReorderDecision;
markReactivePropsDirtySource
markReactivePropsDirtySource(source: ReadableSource<unknown>): void;

Scopetype

Scope: any

A lexical scope created by {@link defineScope}; render it as a provider component, read it with {@link readScope}.

key
readonly key: ContextKey;
defaultValue
readonly defaultValue: T;

selectortype

selector: <T>(source: () => T, equals?: SelectorEquals<T>) => Selector<T>

Creates a render-scoped predicate for keyed membership in reactive list rows. Use this when a `<For>` child needs to compare each stable item with a changing selected value. Unlike a plain closure capture, the predicate subscribes the affected rows and updates them without rebuilding the list. Must be called during component render.

Selectortype

Selector: any

A fine-grained reactive membership check produced by {@link selector}.

serveQuerytype

serveQuery: <TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>, handler: ServerQueryHandler<TInput, TResult>) => ServerQueryEntry<TInput, TResult>

Pair a {@link QueryDefinition} with the server-side handler that resolves it.

ServerQueryHandlertype

ServerQueryHandler: (context: {
  input: TInput;
  request?: Request;
  signal: AbortSignal;
}) => Promise<TResult> | TResult

Server-side handler that resolves a {@link QueryDefinition}'s data for `serveQuery`.

Showtype

Show: <T>(props: ShowProps<T>) => JSXElement

Conditionally render children based on `when`, narrowing truthy values for the render function form.

ShowPropstype

ShowProps: {
  when: ShowSource<T>;
  fallback?: BoundaryChild;
  children: BoundaryChild | ((value: Truthy<T>) => BoundaryChild);
}

Props for {@link Show}.

children
children: RenderableChild | ((value: Truthy<T>) => BoundaryChild);
fallback
fallback?: RenderableChild;
when
when: ShowSource<T>;

statetype

state: <T>(initialValue: T) => StateTuple<T>

Creates a local state value for a component Optimized for: - O(1) read performance - Minimal allocation per state - Fast scheduler integration IMPORTANT: state() must be called during component render execution. It captures the current component instance from context. Calling outside a component function will throw an error.

```ts
// ✅ Correct: called during render
export function Counter() {
  const [count, setCount] = state(0);
  return { type: 'button', children: [count()] };
}

// ❌ Wrong: called outside component
const count = state(0);
export function BadComponent() {
  return { type: 'div' };
}
```

Statetype

State: any

State value holder - callable to read, has set method to update

const count = state(0);
count();           // read: 0
count.set(1);      // write: triggers re-render
set
set(...args: StateSetterArgs<T>): void;

StateSettertype

StateSetter: (...args: StateSetterArgs<T>) => void

Public setter type for state cells.

StateTupletype

StateTuple: [get: State<T>, set: StateSetter<T>] & State<T>

Tuple-first state handle returned by `state()`.