@@ -7,7 +7,6 @@ import type {
77} from "@rivetkit/core/client" ;
88import { Derived , Effect , Store , type Updater } from "@tanstack/store" ;
99
10- // biome-ignore lint/suspicious/noExplicitAny: its a generic actor registry
1110export type AnyActorRegistry = Registry < any > ;
1211
1312interface ActorStateReference < AD extends AnyActorDefinition > {
@@ -113,11 +112,27 @@ export interface ActorOptions<
113112 enabled ?: boolean ;
114113}
115114
116- // biome-ignore lint/suspicious/noExplicitAny: actor name can be anything
115+ export type ActorsStateDerived <
116+ Registry extends AnyActorRegistry ,
117+ WorkerName extends keyof ExtractActorsFromRegistry < Registry > ,
118+ > = Derived <
119+ Omit <
120+ InternalRivetKitStore <
121+ Registry ,
122+ ExtractActorsFromRegistry < Registry >
123+ > [ "actors" ] [ string ] ,
124+ "handle" | "connection"
125+ > & {
126+ handle : ActorHandle < ExtractActorsFromRegistry < Registry > [ WorkerName ] > | null ;
127+ connection : ActorConn <
128+ ExtractActorsFromRegistry < Registry > [ WorkerName ]
129+ > | null ;
130+ }
131+ > ;
132+
117133export type AnyActorOptions = ActorOptions < AnyActorRegistry , any > ;
118134
119135export interface CreateRivetKitOptions < Registry extends AnyActorRegistry > {
120- // biome-ignore lint/suspicious/noExplicitAny: actor name can be anything
121136 hashFunction ?: ( opts : ActorOptions < Registry , any > ) => string ;
122137}
123138
@@ -144,7 +159,6 @@ export function createRivetKit<
144159 create : ( ) => void ;
145160 addEventListener ?: (
146161 event : string ,
147- // biome-ignore lint/suspicious/noExplicitAny: need any specific type here
148162 handler : ( ...args : any [ ] ) => void ,
149163 ) => void ;
150164 }
@@ -158,12 +172,7 @@ export function createRivetKit<
158172 if ( cached ) {
159173 return {
160174 ...cached ,
161- state : cached . state as Derived <
162- Omit < RivetKitStore [ "actors" ] [ string ] , "handle" | "connection" > & {
163- handle : ActorHandle < Actors [ ActorName ] > | null ;
164- connection : ActorConn < Actors [ ActorName ] > | null ;
165- }
166- > ,
175+ state : cached . state as ActorsStateDerived < Registry , ActorName > ,
167176 } ;
168177 }
169178
@@ -328,12 +337,7 @@ export function createRivetKit<
328337 return {
329338 mount,
330339 setState,
331- state : derived as Derived <
332- Omit < RivetKitStore [ "actors" ] [ string ] , "handle" | "connection" > & {
333- handle : ActorHandle < Actors [ ActorName ] > | null ;
334- connection : ActorConn < Actors [ ActorName ] > | null ;
335- }
336- > ,
340+ state : derived as ActorsStateDerived < Registry , ActorName > ,
337341 create,
338342 key,
339343 } ;
0 commit comments