@bemedev/app-solid
Version:
Middleware between @bemedev/app-ts and solidjs
57 lines • 3.79 kB
TypeScript
import { type AnyMachine, type InterpreterFrom, type InterpreterOptions, type WorkingStatus } from '@bemedev/app-ts';
import type { Ru, SoA } from '@bemedev/app-ts/lib/libs/bemedev/globals/types';
import type { StateValue } from '@bemedev/app-ts/lib/states/types';
import type { AddOptions_F, SendUI_F, State_F, StateSignal } from './interpreter.types';
declare class Interpreter<const M extends AnyMachine, S extends Ru> implements Disposable, AsyncDisposable {
#private;
private interpreterOptions?;
get __stateSignal(): StateSignal<M, S>;
constructor({ machine, options: interpreterOptions, uiThread, }: {
machine: M;
options?: InterpreterOptions<M>;
uiThread?: S;
});
get start(): () => Promise<void>;
get pause(): () => void;
get resume(): () => void;
stop: () => void;
get subscribe(): import("@bemedev/app-ts").AddSubscriber_F<Extract<M["eventsMap"], import("@bemedev/app-ts/lib/events").EventsMap>, Extract<M["promiseesMap"], import("@bemedev/app-ts/lib/events").PromiseeMap>, Extract<M["context"], import("@bemedev/app-ts/lib/libs/bemedev/globals/types").PrimitiveObject>>;
get send(): (_event: import("@bemedev/app-ts/lib/events").EventArg<Extract<M["eventsMap"], import("@bemedev/app-ts/lib/events").EventsMap>>) => void;
sendUI: SendUI_F<S>;
state: State_F<StateSignal<M, S>>;
watcher: <T>(accessor: (state: StateSignal<M, S>) => T) => (equals?: false | ((prev: T, next: T) => boolean)) => import("solid-js").Accessor<T>;
reducer: <T>(accessor: (state: StateSignal<M, S>) => T) => <R = T>(_accessor?: (state: T) => R, equals?: false | ((prev: R, next: R) => boolean)) => import("solid-js").Accessor<R>;
context: <R = M["context"]>(_accessor?: (state: M["context"]) => R, equals?: false | ((prev: R, next: R) => boolean) | undefined) => import("solid-js").Accessor<R>;
value: (equals?: false | ((prev: StateValue, next: StateValue) => boolean) | undefined) => import("solid-js").Accessor<StateValue>;
status: (equals?: false | ((prev: WorkingStatus, next: WorkingStatus) => boolean) | undefined) => import("solid-js").Accessor<WorkingStatus>;
tags: (equals?: false | ((prev: SoA<string>, next: SoA<string>) => boolean) | undefined) => import("solid-js").Accessor<SoA<string>>;
ui: <R = Partial<S> | undefined>(_accessor?: (state: Partial<S> | undefined) => R, equals?: false | ((prev: R, next: R) => boolean) | undefined) => import("solid-js").Accessor<R>;
hasTags: (...tags: string[]) => boolean;
/**
* @deprecated
* Only for testing purposes
*/
get __isUsedUi(): boolean;
dps: (equals?: false | ((prev: string[], next: string[]) => boolean) | undefined) => import("solid-js").Accessor<string[]>;
matches: (...values: string[]) => import("solid-js").Accessor<boolean>;
contains: (...values: string[]) => import("solid-js").Accessor<boolean>;
addOptions: AddOptions_F<M, S>;
provideOptions: (option: Parameters<InterpreterFrom<M>["addOptions"]>[0]) => Interpreter<M, S>;
dispose: () => void;
[Symbol.dispose]: () => void;
[Symbol.asyncDispose]: () => Promise<void>;
}
export type AnyInterpreter = Record<'__stateSignal' | 'state' | 'context' | 'ui' | 'value' | 'status' | 'tags' | 'dps', any>;
export type { Interpreter };
export type InterpreterArgs<M extends AnyMachine, S extends Ru> = {
machine: M;
uiThread?: S;
} & (object extends InterpreterOptions<M> ? {
options?: InterpreterOptions<M>;
} : {
options: InterpreterOptions<M>;
});
export type Interpreter_F = <const M extends AnyMachine, S extends Ru>(args: InterpreterArgs<M, S>) => Interpreter<M, S>;
export declare const createInterpreter: Interpreter_F;
export declare const interpret: Interpreter_F;
//# sourceMappingURL=interpreter.d.ts.map