@casual-simulation/aux-common
Version:
Common library for AUX projects
63 lines • 3.01 kB
TypeScript
import type { Bot, BotsState, CreateInitializationUpdateAction, GetInstStateFromUpdatesAction, InstUpdate } from '../bots';
import '../BlobPolyfill';
import type { PartitionRemoteEvents } from './AuxPartitionConfig';
import type { RemoteActions } from '../common';
/**
* Creates a new initialization update using the given action.
*/
export declare function constructInitializationUpdate(action: CreateInitializationUpdateAction): InstUpdate;
/**
* Constructs an initialization update from the given previous updates and bots.
* @param previousUpdates The previous updates.
* @param bots The bots that represent the desired final state.
*/
export declare function constructInitializationUpdateFromPreviousUpdates(previousUpdates: InstUpdate[], bots: Bot[]): InstUpdate;
/**
* Constructs an initialization update that transitions from the previous update to the state contained in the new state update.
* @param previousUpdates The previous updates.
* @param newState The new state update.
*/
export declare function updateToNewStateUpdate(previousUpdates: InstUpdate[], newState: InstUpdate | InstUpdate[]): InstUpdate;
/**
* Gets the bots state that is encoded from the given action.
* @param action The action.
*/
export declare function getStateFromUpdates(action: GetInstStateFromUpdatesAction): BotsState;
/**
* Merges the given inst updates into a single update.
* @param updates The list of updates to merge.
*/
export declare function mergeInstUpdates(updates: InstUpdate[], id?: number, timestamp?: number): InstUpdate;
/**
* Converts the given error to a copiable value.
* Returns a new value that can be sent over to web workers.
* @param err The error to convert.
*/
export declare function convertErrorToCopiableValue(err: unknown): any;
/**
* Converts the given value to a copiable value.
* Copiable values are strings, numbers, booleans, arrays, and objects made of any of those types.
* Non-copiable values are functions and errors.
* @param value
*/
export declare function convertToCopiableValue(value: any): any;
export declare class DeepObjectError extends Error {
constructor();
}
/**
* Checks each of the tags in the given bot to ensure that the bot is copiable and returns a new bot with serializable values if the given bot is contains non-serializable values.
* @param bot The bot to check.
*/
export declare function ensureBotIsSerializable(bot: Bot): Bot;
/**
* Checks that the given tag is copiable and returns the copiable version of the value if it is not.
* @param value The value to check.
*/
export declare function ensureTagIsSerializable(value: any): any;
/**
* Determines if the given config supports the given remote action.
* @param config The config. If this is true, then it will be treated as if every remote event is supported.
* @param action The action to test.
*/
export declare function supportsRemoteEvent(config: PartitionRemoteEvents | boolean, action: RemoteActions): boolean;
//# sourceMappingURL=PartitionUtils.d.ts.map