e30e75b5d4
Changesets / Create Version PR (push) Waiting to run
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { Context } from "react";
|
|
|
|
type ContravariantResource<R, A extends readonly unknown[] = any[]> = (...args: A) => ResourceElement<R>;
|
|
|
|
type ExtractResourceReturnType<T> = T extends ResourceElement<infer R, any> ? R : T extends Resource<infer R, any> ? R : never;
|
|
|
|
type Resource<R, A extends readonly unknown[] = any[]> = (...args: A) => ResourceElement<R, A>;
|
|
|
|
type ResourceElement<R, A extends readonly unknown[] = any[]> = {
|
|
readonly hook: (...args: A) => R;
|
|
readonly args: Readonly<A>;
|
|
readonly key?: string | number;
|
|
readonly deps?: readonly unknown[];
|
|
};
|
|
|
|
declare const createTapRoot: <R>(render: () => R) => useTapRoot.Root<R> & {
|
|
unmount: () => void;
|
|
};
|
|
|
|
declare const flushTapSync: <T>(callback: () => T) => T;
|
|
|
|
declare namespace entry_root_exports {
|
|
export { ContravariantResource, Resource, ResourceElement, createTapRoot, flushTapSync, resource, useContextProvider, useResource, useResources, useTapHost, useTapRoot, withKey };
|
|
}
|
|
|
|
declare function resource<R, A extends readonly unknown[]>(hook: (...args: A) => R): Resource<R, A>;
|
|
|
|
declare const useContextProvider: <T, TResult>(context: Context<T>, value: T, fn: () => TResult) => TResult;
|
|
|
|
declare function useResource<E extends ResourceElement<any, any[]>>(element: E): ExtractResourceReturnType<E>;
|
|
|
|
declare function useResources<E extends ResourceElement<any, any[]>>(elements: readonly E[]): ExtractResourceReturnType<E>[];
|
|
|
|
declare namespace useTapHost {
|
|
interface Result<R> {
|
|
value: R;
|
|
effects: () => void;
|
|
}
|
|
}
|
|
|
|
declare const useTapHost: <R>(callback: () => R) => useTapHost.Result<R>;
|
|
|
|
declare namespace useTapRoot {
|
|
type Unsubscribe = () => void;
|
|
interface Root<R> {
|
|
getValue(): R;
|
|
subscribe(listener: () => void): Unsubscribe;
|
|
}
|
|
}
|
|
|
|
declare const useTapRoot: <R>(render: () => R) => useTapRoot.Root<R>;
|
|
|
|
declare function withKey<E extends ResourceElement<any, any>>(key: string | number, element: E, deps?: readonly unknown[]): E;
|
|
|
|
export { entry_root_exports as entry_root };
|