@utsp/core 0.14.1 → 0.14.2
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/benchmark.cjs +8 -6
- package/dist/benchmark.d.ts +120 -1
- package/dist/benchmark.mjs +8 -6
- package/dist/index.cjs +7 -5
- package/dist/index.d.ts +120 -1
- package/dist/index.mjs +8 -6
- package/package.json +2 -2
package/dist/benchmark.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _utsp_types from '@utsp/types';
|
|
2
|
-
import { ScalingModeValue, Vector2, AxisSource, ButtonSource, InputBindingLoadPacket, AxisBinding, ButtonBinding, SoundInstanceId, AudioConfigCommand, PlaySoundCommand, StopSoundCommand, FadeOutSoundCommand, PauseSoundCommand, ResumeSoundCommand, SetSoundEffectsCommand, IAudioProcessor, VibrationPattern, GamepadVibrationOptions, GamepadVibrationCommand, IGamepadVibrationProcessor, MobileVibrationCommand, IMobileVibrationProcessor, AudioAck, PostProcessConfig, PostProcessCommand, ScalingMode, GridConfig, SoundFormat, SoundLoadType, SoundLoadPacket, SoundExternalLoadPacket, UserRenderState, RenderState } from '@utsp/types';
|
|
2
|
+
import { ScalingModeValue, Vector2, AxisSource, ButtonSource, InputBindingLoadPacket, AxisBinding, ButtonBinding, TouchZoneBinding, SoundInstanceId, AudioConfigCommand, PlaySoundCommand, StopSoundCommand, FadeOutSoundCommand, PauseSoundCommand, ResumeSoundCommand, SetSoundEffectsCommand, IAudioProcessor, VibrationPattern, GamepadVibrationOptions, GamepadVibrationCommand, IGamepadVibrationProcessor, MobileVibrationCommand, IMobileVibrationProcessor, AudioAck, PostProcessConfig, PostProcessCommand, ScalingMode, GridConfig, SoundFormat, SoundLoadType, SoundLoadPacket, SoundExternalLoadPacket, UserRenderState, RenderState } from '@utsp/types';
|
|
3
3
|
export { Vector2 } from '@utsp/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -3905,14 +3905,17 @@ declare class MacroRegistry {
|
|
|
3905
3905
|
*
|
|
3906
3906
|
* Allows to:
|
|
3907
3907
|
* - Define axes and buttons (bindingId → name)
|
|
3908
|
+
* - Define touch zones (virtual screen regions for mobile)
|
|
3908
3909
|
* - Generate a JSON LoadPacket to send to client
|
|
3909
3910
|
* - Decode compressed inputs received from client (future)
|
|
3910
3911
|
*/
|
|
3911
3912
|
declare class InputBindingRegistry {
|
|
3912
3913
|
private axes;
|
|
3913
3914
|
private buttons;
|
|
3915
|
+
private touchZones;
|
|
3914
3916
|
private axisNameToId;
|
|
3915
3917
|
private buttonNameToId;
|
|
3918
|
+
private touchZoneNameToId;
|
|
3916
3919
|
private version;
|
|
3917
3920
|
/**
|
|
3918
3921
|
* Defines an axis binding
|
|
@@ -3956,6 +3959,44 @@ declare class InputBindingRegistry {
|
|
|
3956
3959
|
* ```
|
|
3957
3960
|
*/
|
|
3958
3961
|
defineButton(bindingId: number, name: string, sources?: ButtonSource[], defaultValue?: boolean): void;
|
|
3962
|
+
/**
|
|
3963
|
+
* Defines a touch zone (virtual screen region for mobile touch input)
|
|
3964
|
+
*
|
|
3965
|
+
* Touch zones allow you to define regions of the screen that act as
|
|
3966
|
+
* virtual buttons or joysticks. Each zone has:
|
|
3967
|
+
* - A button state (pressed when any touch is in the zone)
|
|
3968
|
+
* - X/Y axis values (last touch position within the zone, normalized to cell coords)
|
|
3969
|
+
*
|
|
3970
|
+
* @param zoneId - Unique zone ID (0-31)
|
|
3971
|
+
* @param name - Zone name (e.g., "DPadUp", "ButtonA", "LeftJoystick")
|
|
3972
|
+
* @param x - X position in grid cells
|
|
3973
|
+
* @param y - Y position in grid cells
|
|
3974
|
+
* @param width - Width in grid cells
|
|
3975
|
+
* @param height - Height in grid cells
|
|
3976
|
+
* @throws Error if zoneId or name already exists
|
|
3977
|
+
*
|
|
3978
|
+
* @example
|
|
3979
|
+
* ```typescript
|
|
3980
|
+
* // D-pad buttons (bottom-left corner)
|
|
3981
|
+
* registry.defineTouchZone(0, "DPadUp", 2, 16, 4, 4);
|
|
3982
|
+
* registry.defineTouchZone(1, "DPadDown", 2, 24, 4, 4);
|
|
3983
|
+
* registry.defineTouchZone(2, "DPadLeft", 0, 20, 4, 4);
|
|
3984
|
+
* registry.defineTouchZone(3, "DPadRight", 6, 20, 4, 4);
|
|
3985
|
+
*
|
|
3986
|
+
* // Action button (bottom-right)
|
|
3987
|
+
* registry.defineTouchZone(4, "ButtonA", 74, 20, 6, 6);
|
|
3988
|
+
*
|
|
3989
|
+
* // Virtual joystick (large touch area)
|
|
3990
|
+
* registry.defineTouchZone(10, "LeftJoystick", 0, 12, 20, 16);
|
|
3991
|
+
*
|
|
3992
|
+
* // Then bind them in button/axis sources:
|
|
3993
|
+
* registry.defineButton(0, "Up", [
|
|
3994
|
+
* { sourceId: 0, type: InputDeviceType.Keyboard, key: KeyboardInput.ArrowUp },
|
|
3995
|
+
* { sourceId: 100, type: InputDeviceType.TouchZone, touchZoneId: 0 },
|
|
3996
|
+
* ]);
|
|
3997
|
+
* ```
|
|
3998
|
+
*/
|
|
3999
|
+
defineTouchZone(zoneId: number, name: string, x: number, y: number, width: number, height: number): void;
|
|
3959
4000
|
/**
|
|
3960
4001
|
* Evaluates an axis by summing all its sources
|
|
3961
4002
|
*
|
|
@@ -4106,6 +4147,13 @@ declare class InputBindingRegistry {
|
|
|
4106
4147
|
* @returns true if defined
|
|
4107
4148
|
*/
|
|
4108
4149
|
hasButton(bindingId: number): boolean;
|
|
4150
|
+
/**
|
|
4151
|
+
* Checks if a touch zone is defined
|
|
4152
|
+
*
|
|
4153
|
+
* @param zoneId - Zone ID
|
|
4154
|
+
* @returns true if defined
|
|
4155
|
+
*/
|
|
4156
|
+
hasTouchZone(zoneId: number): boolean;
|
|
4109
4157
|
/**
|
|
4110
4158
|
* Counts the number of defined axes
|
|
4111
4159
|
*
|
|
@@ -4118,6 +4166,12 @@ declare class InputBindingRegistry {
|
|
|
4118
4166
|
* @returns number of buttons
|
|
4119
4167
|
*/
|
|
4120
4168
|
getButtonCount(): number;
|
|
4169
|
+
/**
|
|
4170
|
+
* Counts the number of defined touch zones
|
|
4171
|
+
*
|
|
4172
|
+
* @returns number of touch zones
|
|
4173
|
+
*/
|
|
4174
|
+
getTouchZoneCount(): number;
|
|
4121
4175
|
/**
|
|
4122
4176
|
* Retrieves all axes
|
|
4123
4177
|
*
|
|
@@ -4130,6 +4184,26 @@ declare class InputBindingRegistry {
|
|
|
4130
4184
|
* @returns array of all button bindings
|
|
4131
4185
|
*/
|
|
4132
4186
|
getAllButtons(): ButtonBinding[];
|
|
4187
|
+
/**
|
|
4188
|
+
* Retrieves all touch zones
|
|
4189
|
+
*
|
|
4190
|
+
* @returns array of all touch zone bindings
|
|
4191
|
+
*/
|
|
4192
|
+
getAllTouchZones(): TouchZoneBinding[];
|
|
4193
|
+
/**
|
|
4194
|
+
* Retrieves a touch zone by ID
|
|
4195
|
+
*
|
|
4196
|
+
* @param zoneId - Zone ID
|
|
4197
|
+
* @returns zone binding or null if not found
|
|
4198
|
+
*/
|
|
4199
|
+
getTouchZone(zoneId: number): TouchZoneBinding | null;
|
|
4200
|
+
/**
|
|
4201
|
+
* Retrieves a touch zone ID from its name
|
|
4202
|
+
*
|
|
4203
|
+
* @param name - Zone name
|
|
4204
|
+
* @returns zoneId or null if not found
|
|
4205
|
+
*/
|
|
4206
|
+
getTouchZoneId(name: string): number | null;
|
|
4133
4207
|
/**
|
|
4134
4208
|
* Retrieves the current binding version
|
|
4135
4209
|
*
|
|
@@ -4150,6 +4224,13 @@ declare class InputBindingRegistry {
|
|
|
4150
4224
|
* @returns true if removed, false if not found
|
|
4151
4225
|
*/
|
|
4152
4226
|
removeButton(bindingId: number): boolean;
|
|
4227
|
+
/**
|
|
4228
|
+
* Removes a touch zone
|
|
4229
|
+
*
|
|
4230
|
+
* @param zoneId - Zone ID to remove
|
|
4231
|
+
* @returns true if removed, false if not found
|
|
4232
|
+
*/
|
|
4233
|
+
removeTouchZone(zoneId: number): boolean;
|
|
4153
4234
|
/**
|
|
4154
4235
|
* Removes all axes
|
|
4155
4236
|
*/
|
|
@@ -4158,6 +4239,10 @@ declare class InputBindingRegistry {
|
|
|
4158
4239
|
* Removes all buttons
|
|
4159
4240
|
*/
|
|
4160
4241
|
clearButtons(): void;
|
|
4242
|
+
/**
|
|
4243
|
+
* Removes all touch zones
|
|
4244
|
+
*/
|
|
4245
|
+
clearTouchZones(): void;
|
|
4161
4246
|
/**
|
|
4162
4247
|
* Completely resets the registry
|
|
4163
4248
|
*/
|
|
@@ -5726,6 +5811,40 @@ declare class User<TData = Record<string, any>> {
|
|
|
5726
5811
|
* Get the number of sounds currently playing on the client
|
|
5727
5812
|
*/
|
|
5728
5813
|
getPlayingSoundCount(): number;
|
|
5814
|
+
/**
|
|
5815
|
+
* Get audio loading state for this client
|
|
5816
|
+
*
|
|
5817
|
+
* Provides a summary of the client's audio loading progress,
|
|
5818
|
+
* useful for showing loading screens or progress bars.
|
|
5819
|
+
*
|
|
5820
|
+
* @param totalExpected - Total number of sounds expected (from SoundRegistry)
|
|
5821
|
+
* @returns Audio loading state
|
|
5822
|
+
*
|
|
5823
|
+
* @example
|
|
5824
|
+
* ```typescript
|
|
5825
|
+
* updateUser(core: Core, user: User): void {
|
|
5826
|
+
* const totalSounds = core.getSoundRegistry().getAll().length;
|
|
5827
|
+
* const audioState = user.getAudioLoadingState(totalSounds);
|
|
5828
|
+
*
|
|
5829
|
+
* if (!audioState.isComplete) {
|
|
5830
|
+
* // Client still loading sounds
|
|
5831
|
+
* console.log(`Loading: ${audioState.loadedCount}/${audioState.totalExpected}`);
|
|
5832
|
+
* }
|
|
5833
|
+
* }
|
|
5834
|
+
* ```
|
|
5835
|
+
*/
|
|
5836
|
+
getAudioLoadingState(totalExpected: number): {
|
|
5837
|
+
/** Number of sounds successfully loaded on client */
|
|
5838
|
+
loadedCount: number;
|
|
5839
|
+
/** Total number of sounds expected */
|
|
5840
|
+
totalExpected: number;
|
|
5841
|
+
/** Number of sounds that failed to load */
|
|
5842
|
+
errorCount: number;
|
|
5843
|
+
/** Whether all expected sounds are loaded */
|
|
5844
|
+
isComplete: boolean;
|
|
5845
|
+
/** Names of sounds that failed to load */
|
|
5846
|
+
errors: string[];
|
|
5847
|
+
};
|
|
5729
5848
|
/**
|
|
5730
5849
|
* Load a macro template
|
|
5731
5850
|
* The template will be sent to the client in the next config packet
|