1 | import { Stream } from 'xstream';
|
2 | export declare type FantasyObserver<T> = {
|
3 | next(x: T): void;
|
4 | error(err: any): void;
|
5 | complete(c?: any): void;
|
6 | };
|
7 | export declare type FantasySubscription = {
|
8 | unsubscribe(): void;
|
9 | };
|
10 | export declare type FantasyObservable<T> = {
|
11 | subscribe(observer: FantasyObserver<T>): FantasySubscription;
|
12 | };
|
13 | export declare type DevToolEnabledSource = {
|
14 | _isCycleSource: string;
|
15 | };
|
16 | export declare type SinkProxies<Si> = {
|
17 | [P in keyof Si]: Stream<any>;
|
18 | };
|
19 | export declare type Driver<Si, So> = Si extends void ? (() => So) : ((stream: Si) => So);
|
20 | export declare type DisposeFunction = () => void;
|
21 | export declare type Drivers = {
|
22 | [name: string]: Driver<Stream<any>, any | void>;
|
23 | };
|
24 | export declare type Main = (...args: Array<any>) => any;
|
25 | export declare type Sources<D extends Drivers> = {
|
26 | [k in keyof D]: ReturnType<D[k]>;
|
27 | };
|
28 | export declare type Sinks<M extends Main> = ReturnType<M>;
|
29 | export declare type MatchingMain<D extends Drivers, M extends Main> = (Main & {
|
30 | (so: Sources<D>): Sinks<M>;
|
31 | }) | (Main & {
|
32 | (): Sinks<M>;
|
33 | });
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | export declare type ToStream<S> = S extends FantasyObservable<infer T> ? Stream<T> : S;
|
40 | export declare type WidenStream<S, U> = S extends Stream<infer T> ? (T extends U ? U : never) : any;
|
41 | export declare type GetValidInputs<D extends Driver<any, any>> = D extends Driver<infer S, any> ? (S extends Stream<infer T> ? T : never) : never;
|
42 | export declare type MatchingDrivers<D extends Drivers, M extends Main> = Drivers & {
|
43 | [k in string & keyof Sinks<M>]: (() => Sources<D>[k]) | ((si: Stream<WidenStream<ToStream<Sinks<M>[k]>, GetValidInputs<D[k]>>>) => Sources<D>[k]);
|
44 | };
|
45 | export interface CycleProgram<D extends MatchingDrivers<D, M>, M extends MatchingMain<D, M>> {
|
46 | sources: Sources<D>;
|
47 | sinks: Sinks<M>;
|
48 | run(): DisposeFunction;
|
49 | }
|
50 | export interface Engine<D extends Drivers> {
|
51 | sources: Sources<D>;
|
52 | run<M extends MatchingMain<D, M>>(sinks: Sinks<M>): DisposeFunction;
|
53 | dispose(): void;
|
54 | }
|
55 |
|
\ | No newline at end of file |