1 | import { InspectionEvent } from "./inspection.js";
|
2 | import { ActorSystemInfo, AnyActorRef, Observer, EventObject } from "./types.js";
|
3 | export interface ScheduledEvent {
|
4 | id: string;
|
5 | event: EventObject;
|
6 | startedAt: number;
|
7 | delay: number;
|
8 | source: AnyActorRef;
|
9 | target: AnyActorRef;
|
10 | }
|
11 | export interface Clock {
|
12 | setTimeout(fn: (...args: any[]) => void, timeout: number): any;
|
13 | clearTimeout(id: any): void;
|
14 | }
|
15 | export interface Scheduler {
|
16 | schedule(source: AnyActorRef, target: AnyActorRef, event: EventObject, delay: number, id: string | undefined): void;
|
17 | cancel(source: AnyActorRef, id: string): void;
|
18 | cancelAll(actorRef: AnyActorRef): void;
|
19 | }
|
20 | export interface ActorSystem<T extends ActorSystemInfo> {
|
21 | get: <K extends keyof T['actors']>(key: K) => T['actors'][K] | undefined;
|
22 | inspect: (observer: Observer<InspectionEvent>) => void;
|
23 | scheduler: Scheduler;
|
24 | getSnapshot: () => {
|
25 | _scheduledEvents: Record<string, ScheduledEvent>;
|
26 | };
|
27 | start: () => void;
|
28 | _clock: Clock;
|
29 | _logger: (...args: any[]) => void;
|
30 | }
|
31 | export type AnyActorSystem = ActorSystem<any>;
|
32 | export declare function createSystem<T extends ActorSystemInfo>(rootActor: AnyActorRef, options: {
|
33 | clock: Clock;
|
34 | logger: (...args: any[]) => void;
|
35 | snapshot?: unknown;
|
36 | }): ActorSystem<T>;
|