@utsp/types 0.17.0-nightly.20260125163743.7efddab → 0.17.0-nightly.20260127101256.e83fcc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +89 -35
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1998,61 +1998,131 @@ interface ISoundLoader {
|
|
|
1998
1998
|
has(nameOrId: string | number): boolean;
|
|
1999
1999
|
}
|
|
2000
2000
|
|
|
2001
|
+
/**
|
|
2002
|
+
* Common interface for all UTSP Runtimes (Server, Client, Standalone).
|
|
2003
|
+
* Allows IApplication to interact with the underlying execution environment
|
|
2004
|
+
* in a type-safe way.
|
|
2005
|
+
*/
|
|
2006
|
+
interface IRuntime {
|
|
2007
|
+
/**
|
|
2008
|
+
* Get the current execution mode
|
|
2009
|
+
*/
|
|
2010
|
+
getMode(): string;
|
|
2011
|
+
/**
|
|
2012
|
+
* Check if the runtime is currently running
|
|
2013
|
+
*/
|
|
2014
|
+
isRunning(): boolean;
|
|
2015
|
+
/**
|
|
2016
|
+
* Get current tick rate (TPS)
|
|
2017
|
+
*/
|
|
2018
|
+
getTickRate(): number;
|
|
2019
|
+
/**
|
|
2020
|
+
* Set the tick rate (TPS)
|
|
2021
|
+
*/
|
|
2022
|
+
setTickRate(tickRate: number): void;
|
|
2023
|
+
/**
|
|
2024
|
+
* Disconnect a user from the game
|
|
2025
|
+
* In Server mode: Kicks the specified user.
|
|
2026
|
+
* In Client mode: Usually only applicable to the local user or ignored.
|
|
2027
|
+
*
|
|
2028
|
+
* @param userId - ID of the user to disconnect
|
|
2029
|
+
* @param reason - Optional reason for disconnection
|
|
2030
|
+
* @returns true if the disconnection was initiated
|
|
2031
|
+
*/
|
|
2032
|
+
disconnectUser(userId: string, reason?: string): boolean;
|
|
2033
|
+
/**
|
|
2034
|
+
* Get runtime statistics
|
|
2035
|
+
*/
|
|
2036
|
+
getStats(): any;
|
|
2037
|
+
/**
|
|
2038
|
+
* Shutdown the runtime
|
|
2039
|
+
*/
|
|
2040
|
+
destroy(): Promise<void>;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
/**
|
|
2044
|
+
* Metadata associated with a user when they connect to a runtime.
|
|
2045
|
+
* Includes both authentication info and client-provided preferences.
|
|
2046
|
+
*/
|
|
2047
|
+
interface UserMetadata {
|
|
2048
|
+
/**
|
|
2049
|
+
* User name (e.g. 'Player1', 'Admin')
|
|
2050
|
+
*/
|
|
2051
|
+
username: string;
|
|
2052
|
+
/**
|
|
2053
|
+
* Authentication token or object (optional)
|
|
2054
|
+
*/
|
|
2055
|
+
token?: string | Record<string, unknown>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Client-specific preferences or state (optional)
|
|
2058
|
+
*/
|
|
2059
|
+
preferences?: Record<string, unknown>;
|
|
2060
|
+
/**
|
|
2061
|
+
* Any other context-specific data
|
|
2062
|
+
*/
|
|
2063
|
+
[key: string]: any;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2001
2066
|
/**
|
|
2002
2067
|
* Application lifecycle interface for games, dashboards, signage, etc.
|
|
2003
2068
|
* Supports single-user (local) and multi-user (networked) scenarios.
|
|
2004
2069
|
*
|
|
2005
2070
|
* @template TCore - Core type (typically Core)
|
|
2006
2071
|
* @template TUser - User type (typically User)
|
|
2007
|
-
* @template TRuntime - Runtime type (optional)
|
|
2008
2072
|
*/
|
|
2009
|
-
interface IApplication<TCore = any, TUser = any
|
|
2073
|
+
interface IApplication<TCore = any, TUser = any> {
|
|
2010
2074
|
/**
|
|
2011
2075
|
* Initialize application (called once at startup, before users)
|
|
2012
2076
|
* Can be async if you need to load resources.
|
|
2077
|
+
* @param runtime - Isomorphic runtime instance
|
|
2013
2078
|
* @param core - Core instance
|
|
2014
|
-
* @param runtime - Runtime instance (optional)
|
|
2015
2079
|
*/
|
|
2016
|
-
init(
|
|
2080
|
+
init(runtime: IRuntime, core: TCore): void | Promise<void>;
|
|
2017
2081
|
/**
|
|
2018
2082
|
* Update global logic (called every frame, runs once) (optional)
|
|
2019
2083
|
* Use this for logic that doesn't depend on specific users.
|
|
2084
|
+
* @param runtime - Isomorphic runtime instance
|
|
2020
2085
|
* @param core - Core instance
|
|
2021
2086
|
* @param deltaTime - Time since last update (seconds)
|
|
2022
2087
|
*/
|
|
2023
|
-
update?(core: TCore, deltaTime: number): void;
|
|
2088
|
+
update?(runtime: IRuntime, core: TCore, deltaTime: number): void;
|
|
2024
2089
|
/**
|
|
2025
2090
|
* Initialize new user (called when user connects/joins)
|
|
2091
|
+
* @param runtime - Isomorphic runtime instance
|
|
2026
2092
|
* @param core - Core instance
|
|
2027
2093
|
* @param user - User instance
|
|
2028
2094
|
* @param metadata - Optional user metadata (username, preferences, etc.)
|
|
2029
2095
|
*/
|
|
2030
|
-
initUser(core: TCore, user: TUser, metadata?: UserMetadata): void;
|
|
2096
|
+
initUser(runtime: IRuntime, core: TCore, user: TUser, metadata?: UserMetadata): void;
|
|
2031
2097
|
/**
|
|
2032
2098
|
* Update user-specific logic (called every frame per user)
|
|
2099
|
+
* @param runtime - Isomorphic runtime instance
|
|
2033
2100
|
* @param core - Core instance
|
|
2034
2101
|
* @param user - User instance
|
|
2035
2102
|
* @param deltaTime - Time since last update (seconds)
|
|
2036
2103
|
*/
|
|
2037
|
-
updateUser(core: TCore, user: TUser, deltaTime: number): void;
|
|
2104
|
+
updateUser(runtime: IRuntime, core: TCore, user: TUser, deltaTime: number): void;
|
|
2038
2105
|
/**
|
|
2039
2106
|
* Cleanup when user disconnects (optional)
|
|
2107
|
+
* @param runtime - Isomorphic runtime instance
|
|
2040
2108
|
* @param core - Core instance
|
|
2041
2109
|
* @param user - User instance
|
|
2042
2110
|
* @param reason - Disconnect reason (optional)
|
|
2043
2111
|
*/
|
|
2044
|
-
destroyUser?(core: TCore, user: TUser, reason?: string): void;
|
|
2112
|
+
destroyUser?(runtime: IRuntime, core: TCore, user: TUser, reason?: string): void;
|
|
2045
2113
|
/**
|
|
2046
2114
|
* Cleanup when application shuts down (optional)
|
|
2115
|
+
* @param runtime - Runtime instance
|
|
2047
2116
|
*/
|
|
2048
|
-
destroy?(): void;
|
|
2117
|
+
destroy?(runtime: IRuntime): void;
|
|
2049
2118
|
/**
|
|
2050
2119
|
* Commit changes after all updates (optional)
|
|
2051
2120
|
* Called after update() and all updateUser() to trigger render/broadcast.
|
|
2121
|
+
* @param runtime - Isomorphic runtime instance
|
|
2052
2122
|
* @param core - Core instance
|
|
2053
2123
|
* @param deltaTime - Time since last update (seconds)
|
|
2054
2124
|
*/
|
|
2055
|
-
onCommit?(core: TCore, deltaTime: number): void;
|
|
2125
|
+
onCommit?(runtime: IRuntime, core: TCore, deltaTime: number): void;
|
|
2056
2126
|
/**
|
|
2057
2127
|
* Handle audio acknowledgments from clients (optional, server mode only)
|
|
2058
2128
|
*
|
|
@@ -2062,13 +2132,14 @@ interface IApplication<TCore = any, TUser = any, TRuntime = unknown> {
|
|
|
2062
2132
|
* - Tracking playback state across clients
|
|
2063
2133
|
* - Handling audio errors gracefully
|
|
2064
2134
|
*
|
|
2135
|
+
* @param runtime - Isomorphic runtime instance
|
|
2065
2136
|
* @param core - Core instance
|
|
2066
2137
|
* @param user - User who sent the ACK
|
|
2067
2138
|
* @param ack - The audio acknowledgment
|
|
2068
2139
|
*
|
|
2069
2140
|
* @example
|
|
2070
2141
|
* ```typescript
|
|
2071
|
-
* onAudioAck(core, user, ack) {
|
|
2142
|
+
* onAudioAck(core, user, runtime, ack) {
|
|
2072
2143
|
* if (ack.type === 'sound-loaded') {
|
|
2073
2144
|
* console.log(`User ${user.id} loaded sound ${ack.name}`);
|
|
2074
2145
|
* // Now safe to play this sound for this user
|
|
@@ -2078,7 +2149,7 @@ interface IApplication<TCore = any, TUser = any, TRuntime = unknown> {
|
|
|
2078
2149
|
* }
|
|
2079
2150
|
* ```
|
|
2080
2151
|
*/
|
|
2081
|
-
onAudioAck?(core: TCore, user: TUser, ack: AudioAck): void;
|
|
2152
|
+
onAudioAck?(runtime: IRuntime, core: TCore, user: TUser, ack: AudioAck): void;
|
|
2082
2153
|
/**
|
|
2083
2154
|
* Handle bridge messages from clients (optional, server mode only)
|
|
2084
2155
|
*
|
|
@@ -2093,6 +2164,7 @@ interface IApplication<TCore = any, TUser = any, TRuntime = unknown> {
|
|
|
2093
2164
|
* - Debug/admin commands
|
|
2094
2165
|
* - Integration with external systems
|
|
2095
2166
|
*
|
|
2167
|
+
* @param runtime - Isomorphic runtime instance
|
|
2096
2168
|
* @param core - Core instance
|
|
2097
2169
|
* @param user - User who sent the message
|
|
2098
2170
|
* @param channel - The bridge channel name (e.g., 'chat', 'lobby', 'debug')
|
|
@@ -2100,7 +2172,7 @@ interface IApplication<TCore = any, TUser = any, TRuntime = unknown> {
|
|
|
2100
2172
|
*
|
|
2101
2173
|
* @example
|
|
2102
2174
|
* ```typescript
|
|
2103
|
-
* onBridgeMessage(core, user, channel, data) {
|
|
2175
|
+
* onBridgeMessage(core, user, runtime, channel, data) {
|
|
2104
2176
|
* if (channel === 'chat') {
|
|
2105
2177
|
* const { message } = data as { message: string };
|
|
2106
2178
|
* console.log(`[Chat] ${user.id}: ${message}`);
|
|
@@ -2112,39 +2184,21 @@ interface IApplication<TCore = any, TUser = any, TRuntime = unknown> {
|
|
|
2112
2184
|
* }
|
|
2113
2185
|
* ```
|
|
2114
2186
|
*/
|
|
2115
|
-
onBridgeMessage?(core: TCore, user: TUser, channel: string, data: unknown): void;
|
|
2187
|
+
onBridgeMessage?(runtime: IRuntime, core: TCore, user: TUser, channel: string, data: unknown): void;
|
|
2116
2188
|
/**
|
|
2117
2189
|
* Handle errors during execution (optional)
|
|
2190
|
+
* @param runtime - Isomorphic runtime instance
|
|
2118
2191
|
* @param core - Core instance
|
|
2119
2192
|
* @param error - The error that occurred
|
|
2120
2193
|
* @param context - Error context (phase, user, timestamp)
|
|
2121
2194
|
* @returns true to continue, false to stop runtime
|
|
2122
2195
|
*/
|
|
2123
|
-
onError?(core: TCore, error: Error, context: {
|
|
2196
|
+
onError?(runtime: IRuntime, core: TCore, error: Error, context: {
|
|
2124
2197
|
phase: 'init' | 'update' | 'initUser' | 'updateUser' | 'destroyUser' | 'destroy';
|
|
2125
2198
|
user?: TUser;
|
|
2126
2199
|
timestamp: number;
|
|
2127
2200
|
}): boolean;
|
|
2128
2201
|
}
|
|
2129
|
-
/**
|
|
2130
|
-
* User metadata for initUser
|
|
2131
|
-
*/
|
|
2132
|
-
interface UserMetadata {
|
|
2133
|
-
/** Display name */
|
|
2134
|
-
username?: string;
|
|
2135
|
-
/** Avatar/skin ID */
|
|
2136
|
-
avatar?: string | number;
|
|
2137
|
-
/** Team/faction */
|
|
2138
|
-
team?: string | number;
|
|
2139
|
-
/** Color preference */
|
|
2140
|
-
color?: number;
|
|
2141
|
-
/** Theme preference */
|
|
2142
|
-
theme?: string;
|
|
2143
|
-
/** Auth token */
|
|
2144
|
-
token?: string;
|
|
2145
|
-
/** Custom data */
|
|
2146
|
-
[key: string]: unknown;
|
|
2147
|
-
}
|
|
2148
2202
|
|
|
2149
2203
|
/**
|
|
2150
2204
|
* Vibration types for tactile feedback
|
|
@@ -2253,4 +2307,4 @@ interface IGamepadVibrationProcessor {
|
|
|
2253
2307
|
type GamepadVibrationPreset = 'tap' | 'impact' | 'heavy' | 'success' | 'error' | 'explosion' | 'engine' | 'heartbeat';
|
|
2254
2308
|
|
|
2255
2309
|
export { GRID_DEFAULTS, GamepadInput, InputDeviceType, KeyboardInput, MouseInput, NetworkEvent, NetworkState, NetworkTransportType, POST_PROCESS_DEFAULTS, ScalingMode, ScalingModeValue, TVRemoteInput, TouchInput, TouchZoneInput, Vector2, Vector3, createInputDescriptor, deserializeInputDescriptor, gamepadAxisIndexToInput, gamepadButtonIndexToInput, getTouchXAxis, getTouchYAxis, getTouchZoneXAxis, getTouchZoneYAxis, inputDescriptorToString, isAxis, isButton, isGamepadAxis, isGamepadButton, isMouseAxis, isMouseButton, isNetworkEvent, isTVRemoteAxis, isTVRemoteButton, isTouchButton, isTouchGesture, isTouchPosition, isTouchZoneButton, isTouchZonePosition, keyCodeToKeyboardInput, keyboardInputToKeyCode, parseInputDescriptor, scalingModeToValue, serializeInputDescriptor, valueToScalingMode };
|
|
2256
|
-
export type { AmbientEffectConfig, AnyNetworkMessage, AnySoundLoadPacket, AudioAck, AudioAckBase, AudioAckHandler, AudioAckType, AudioConfigCommand, AudioPlayOptions, AudioPlayResult, AudioSpatialOptions, AxisBinding, AxisSource, BridgeClientHandler, BridgeServerHandler, ButtonBinding, ButtonSource, CancelVibrationCommand, ChatMessage, ClientInfo, ConfigureSpatialCommand, ConnectionHandler, DisconnectionHandler, ErrorMessage, FadeOutSoundCommand, GamepadCancelVibrationCommand, GamepadInputDescriptor, GamepadVibrateCommand, GamepadVibrationCommand, GamepadVibrationOptions, GamepadVibrationPreset, GridConfig, IApplication, IAudioProcessor, IColorPalette, IGamepadVibrationProcessor, IInputSystem, IMobileVibrationProcessor, INetworkClient, INetworkServer, IRenderer, ISoundLoader, InputBindingLoadPacket, InputDescriptor, InputEnum, InputMessage, JoinMessage, JoinResponseMessage, KeyboardInputDescriptor, LeaveMessage, LoadMessage, MessageType, MobileVibrationCommand, MobileVibrationPreset, MouseInputDescriptor, NetworkClientOptions, NetworkEventHandler, NetworkMessage, NetworkServerOptions, PauseSoundCommand, PingMessage, PlaySoundCommand, PlaybackEndedAck, PlaybackErrorAck, PlaybackStartedAck, PongMessage, PostProcessCommand, PostProcessCommandType, PostProcessConfig, RGBColor, RenderPassState, RenderState, RenderedCell, ResumeSoundCommand, ScanlinesConfig, ServerEventHandler, SetListenerPositionCommand, SetSoundEffectsCommand, SignalingInfo, SoundErrorAck, SoundExternalEntry, SoundExternalLoadPacket, SoundFileEntry, SoundFormat, SoundInstanceId, SoundLoadPacket, SoundLoadType, SoundLoadedAck, SpatialAudioConfig, StopSoundCommand, TVRemoteInputDescriptor, TouchInputDescriptor, TouchZoneBinding, TypedInputDescriptor, UpdateMessage, UserMetadata, UserRenderState, VibrateCommand, VibrationPattern };
|
|
2310
|
+
export type { AmbientEffectConfig, AnyNetworkMessage, AnySoundLoadPacket, AudioAck, AudioAckBase, AudioAckHandler, AudioAckType, AudioConfigCommand, AudioPlayOptions, AudioPlayResult, AudioSpatialOptions, AxisBinding, AxisSource, BridgeClientHandler, BridgeServerHandler, ButtonBinding, ButtonSource, CancelVibrationCommand, ChatMessage, ClientInfo, ConfigureSpatialCommand, ConnectionHandler, DisconnectionHandler, ErrorMessage, FadeOutSoundCommand, GamepadCancelVibrationCommand, GamepadInputDescriptor, GamepadVibrateCommand, GamepadVibrationCommand, GamepadVibrationOptions, GamepadVibrationPreset, GridConfig, IApplication, IAudioProcessor, IColorPalette, IGamepadVibrationProcessor, IInputSystem, IMobileVibrationProcessor, INetworkClient, INetworkServer, IRenderer, IRuntime, ISoundLoader, InputBindingLoadPacket, InputDescriptor, InputEnum, InputMessage, JoinMessage, JoinResponseMessage, KeyboardInputDescriptor, LeaveMessage, LoadMessage, MessageType, MobileVibrationCommand, MobileVibrationPreset, MouseInputDescriptor, NetworkClientOptions, NetworkEventHandler, NetworkMessage, NetworkServerOptions, PauseSoundCommand, PingMessage, PlaySoundCommand, PlaybackEndedAck, PlaybackErrorAck, PlaybackStartedAck, PongMessage, PostProcessCommand, PostProcessCommandType, PostProcessConfig, RGBColor, RenderPassState, RenderState, RenderedCell, ResumeSoundCommand, ScanlinesConfig, ServerEventHandler, SetListenerPositionCommand, SetSoundEffectsCommand, SignalingInfo, SoundErrorAck, SoundExternalEntry, SoundExternalLoadPacket, SoundFileEntry, SoundFormat, SoundInstanceId, SoundLoadPacket, SoundLoadType, SoundLoadedAck, SpatialAudioConfig, StopSoundCommand, TVRemoteInputDescriptor, TouchInputDescriptor, TouchZoneBinding, TypedInputDescriptor, UpdateMessage, UserMetadata, UserRenderState, VibrateCommand, VibrationPattern };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utsp/types",
|
|
3
|
-
"version": "0.17.0-nightly.
|
|
3
|
+
"version": "0.17.0-nightly.20260127101256.e83fcc8",
|
|
4
4
|
"description": "Type definitions and interfaces for UTSP (Universal Tile Stream Protocol)",
|
|
5
5
|
"author": "THP Software",
|
|
6
6
|
"license": "MIT",
|