c3c891cea0
* enable predictive back gesture * upgrade to rn 85 * remove deprecated * added timeout to theme switch * fix plugin items hit registration * fix SearchbarV2 hit registration * fix loading spinner * migrated to expo * migrated to expo * Fix reader footer animation * working again * added icons back * added splashscreen * clean up * nitro epub * fix * remove .env.local from git tracking * fix rn background actions not working * moving custom permissions to app.json * more cleanup * fix epub import * remove unused deps * Further cleanup for gradle build types * Update build.yml * ignore android/ and ios/ as they are generated by CNG * fix lint * Delete ios directory * Delete android directory * fix lint * fix test mocks * update packages * update eslint * fix ThemeProvider placement * fix test and lint * Add BackgroundTask native module * Add NativeFile changes * first round of fixing compatibility issues * added types for native modules
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import 'typescript';
|
|
import 'typescript/lib/lib.dom';
|
|
export interface State<T> {
|
|
val: T;
|
|
readonly oldVal: T;
|
|
readonly rawVal: T;
|
|
}
|
|
|
|
// Defining readonly view of State<T> for covariance.
|
|
// Basically we want StateView<string> to implement StateView<string | number>
|
|
export type StateView<T> = Readonly<State<T>>;
|
|
|
|
export type Val<T> = State<T> | T;
|
|
|
|
export type Primitive = string | number | boolean | bigint;
|
|
|
|
export type PropValue = Primitive | ((e: any) => void) | null;
|
|
|
|
export type PropValueOrDerived =
|
|
| PropValue
|
|
| StateView<PropValue>
|
|
| (() => PropValue);
|
|
|
|
export type Props = Record<string, PropValueOrDerived> & {
|
|
class?: PropValueOrDerived;
|
|
};
|
|
|
|
export type PropsWithKnownKeys<ElementType> = Partial<{
|
|
[K in keyof ElementType]: PropValueOrDerived;
|
|
}>;
|
|
|
|
export type ValidChildDomValue = Primitive | Node | null | undefined;
|
|
|
|
export type BindingFunc =
|
|
| ((dom?: Node) => ValidChildDomValue)
|
|
| ((dom?: Element) => Element);
|
|
|
|
export type ChildDom =
|
|
| ValidChildDomValue
|
|
| StateView<Primitive | null | undefined>
|
|
| BindingFunc
|
|
| readonly ChildDom[];
|
|
|
|
export type TagFunc<Result> = (
|
|
first?: (Props & PropsWithKnownKeys<Result>) | ChildDom,
|
|
...rest: readonly ChildDom[]
|
|
) => Result;
|
|
|
|
type Tags = Readonly<Record<string, TagFunc<Element>>> & {
|
|
[K in keyof HTMLElementTagNameMap]: TagFunc<HTMLElementTagNameMap[K]>;
|
|
};
|
|
|
|
declare function state<T>(): State<T>;
|
|
declare function state<T>(initVal: T): State<T>;
|
|
|
|
export interface Van {
|
|
readonly state: typeof state;
|
|
readonly derive: <T>(f: () => T) => State<T>;
|
|
readonly add: (dom: Element, ...children: readonly ChildDom[]) => Element;
|
|
readonly tags: Tags &
|
|
((namespaceURI: string) => Readonly<Record<string, TagFunc<Element>>>);
|
|
readonly hydrate: <T extends Node>(
|
|
dom: T,
|
|
f: (dom: T) => T | null | undefined,
|
|
) => T;
|
|
}
|
|
|
|
declare global {
|
|
const van: Van;
|
|
}
|