From 0c6241c542cc2fca35614fe1cdb8b12508b93775 Mon Sep 17 00:00:00 2001 From: PepeElToro41 <101070050+PepeElToro41@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:23:07 -0600 Subject: [PATCH] feat: allow molecules in server sync (#20) --- src/index.d.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 4bbbd31..5aedfac 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -50,6 +50,7 @@ declare namespace Charm { }; type AtomMap = Record>; + type MoleculeMap = Record>; interface AtomOptions { /** @@ -225,7 +226,7 @@ declare namespace Charm { * @param options The atoms to synchronize with the client. * @returns A `ServerSyncer` object. */ - server: (options: ServerOptions) => ServerSyncer; + server: (options: ServerOptions) => ServerSyncer; /** * Checks whether a value is `None`. If `true`, the value is scheduled to be * removed from the state when the patch is applied. @@ -280,9 +281,9 @@ declare namespace Charm { * A payload that can be sent from the server to the client to synchronize * state between the two. */ - type SyncPayload = - | { type: "init"; data: StateOfMap } - | { type: "patch"; data: SyncPatch> }; + type SyncPayload = + | { type: "init"; data: StateOfMap } + | { type: "patch"; data: SyncPatch> }; interface ClientOptions { /** @@ -291,11 +292,11 @@ declare namespace Charm { atoms: Atoms; } - interface ServerOptions { + interface ServerOptions { /** * The atoms to synchronize with the client. */ - atoms: Atoms; + atoms: Molecules; /** * The interval at which to send patches to the client, in seconds. * Defaults to `0` (patches are sent up to once per frame). Set to a @@ -324,7 +325,7 @@ declare namespace Charm { sync(...payloads: SyncPayload[]): void; } - interface ServerSyncer { + interface ServerSyncer { /** * Sets up a subscription to each atom that schedules a patch to be sent to * the client whenever the state changes. When a change occurs, the `callback` @@ -336,7 +337,7 @@ declare namespace Charm { * @param callback The function to call when the state changes. * @returns A cleanup function that unsubscribes all listeners. */ - connect(callback: (player: Player, ...payloads: SyncPayload[]) => void): Cleanup; + connect(callback: (player: Player, ...payloads: SyncPayload[]) => void): Cleanup; /** * Hydrates the client's state with the server's state. This should be * called when a player joins the game and requires the server's state.