@utsp/core 0.14.1 → 0.15.0-nightly.20251227200128.cdc09ed
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/index.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 } 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 } from '@utsp/types';
|
|
3
3
|
export { AxisBinding, AxisSource, ButtonBinding, ButtonSource, InputBindingLoadPacket, RenderState, RenderedCell, ScalingModeValue, UserRenderState, Vector2 } from '@utsp/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -3279,14 +3279,17 @@ declare class MacroRegistry {
|
|
|
3279
3279
|
*
|
|
3280
3280
|
* Allows to:
|
|
3281
3281
|
* - Define axes and buttons (bindingId → name)
|
|
3282
|
+
* - Define touch zones (virtual screen regions for mobile)
|
|
3282
3283
|
* - Generate a JSON LoadPacket to send to client
|
|
3283
3284
|
* - Decode compressed inputs received from client (future)
|
|
3284
3285
|
*/
|
|
3285
3286
|
declare class InputBindingRegistry {
|
|
3286
3287
|
private axes;
|
|
3287
3288
|
private buttons;
|
|
3289
|
+
private touchZones;
|
|
3288
3290
|
private axisNameToId;
|
|
3289
3291
|
private buttonNameToId;
|
|
3292
|
+
private touchZoneNameToId;
|
|
3290
3293
|
private version;
|
|
3291
3294
|
/**
|
|
3292
3295
|
* Defines an axis binding
|
|
@@ -3330,6 +3333,44 @@ declare class InputBindingRegistry {
|
|
|
3330
3333
|
* ```
|
|
3331
3334
|
*/
|
|
3332
3335
|
defineButton(bindingId: number, name: string, sources?: ButtonSource[], defaultValue?: boolean): void;
|
|
3336
|
+
/**
|
|
3337
|
+
* Defines a touch zone (virtual screen region for mobile touch input)
|
|
3338
|
+
*
|
|
3339
|
+
* Touch zones allow you to define regions of the screen that act as
|
|
3340
|
+
* virtual buttons or joysticks. Each zone has:
|
|
3341
|
+
* - A button state (pressed when any touch is in the zone)
|
|
3342
|
+
* - X/Y axis values (last touch position within the zone, normalized to cell coords)
|
|
3343
|
+
*
|
|
3344
|
+
* @param zoneId - Unique zone ID (0-31)
|
|
3345
|
+
* @param name - Zone name (e.g., "DPadUp", "ButtonA", "LeftJoystick")
|
|
3346
|
+
* @param x - X position in grid cells
|
|
3347
|
+
* @param y - Y position in grid cells
|
|
3348
|
+
* @param width - Width in grid cells
|
|
3349
|
+
* @param height - Height in grid cells
|
|
3350
|
+
* @throws Error if zoneId or name already exists
|
|
3351
|
+
*
|
|
3352
|
+
* @example
|
|
3353
|
+
* ```typescript
|
|
3354
|
+
* // D-pad buttons (bottom-left corner)
|
|
3355
|
+
* registry.defineTouchZone(0, "DPadUp", 2, 16, 4, 4);
|
|
3356
|
+
* registry.defineTouchZone(1, "DPadDown", 2, 24, 4, 4);
|
|
3357
|
+
* registry.defineTouchZone(2, "DPadLeft", 0, 20, 4, 4);
|
|
3358
|
+
* registry.defineTouchZone(3, "DPadRight", 6, 20, 4, 4);
|
|
3359
|
+
*
|
|
3360
|
+
* // Action button (bottom-right)
|
|
3361
|
+
* registry.defineTouchZone(4, "ButtonA", 74, 20, 6, 6);
|
|
3362
|
+
*
|
|
3363
|
+
* // Virtual joystick (large touch area)
|
|
3364
|
+
* registry.defineTouchZone(10, "LeftJoystick", 0, 12, 20, 16);
|
|
3365
|
+
*
|
|
3366
|
+
* // Then bind them in button/axis sources:
|
|
3367
|
+
* registry.defineButton(0, "Up", [
|
|
3368
|
+
* { sourceId: 0, type: InputDeviceType.Keyboard, key: KeyboardInput.ArrowUp },
|
|
3369
|
+
* { sourceId: 100, type: InputDeviceType.TouchZone, touchZoneId: 0 },
|
|
3370
|
+
* ]);
|
|
3371
|
+
* ```
|
|
3372
|
+
*/
|
|
3373
|
+
defineTouchZone(zoneId: number, name: string, x: number, y: number, width: number, height: number): void;
|
|
3333
3374
|
/**
|
|
3334
3375
|
* Evaluates an axis by summing all its sources
|
|
3335
3376
|
*
|
|
@@ -3480,6 +3521,13 @@ declare class InputBindingRegistry {
|
|
|
3480
3521
|
* @returns true if defined
|
|
3481
3522
|
*/
|
|
3482
3523
|
hasButton(bindingId: number): boolean;
|
|
3524
|
+
/**
|
|
3525
|
+
* Checks if a touch zone is defined
|
|
3526
|
+
*
|
|
3527
|
+
* @param zoneId - Zone ID
|
|
3528
|
+
* @returns true if defined
|
|
3529
|
+
*/
|
|
3530
|
+
hasTouchZone(zoneId: number): boolean;
|
|
3483
3531
|
/**
|
|
3484
3532
|
* Counts the number of defined axes
|
|
3485
3533
|
*
|
|
@@ -3492,6 +3540,12 @@ declare class InputBindingRegistry {
|
|
|
3492
3540
|
* @returns number of buttons
|
|
3493
3541
|
*/
|
|
3494
3542
|
getButtonCount(): number;
|
|
3543
|
+
/**
|
|
3544
|
+
* Counts the number of defined touch zones
|
|
3545
|
+
*
|
|
3546
|
+
* @returns number of touch zones
|
|
3547
|
+
*/
|
|
3548
|
+
getTouchZoneCount(): number;
|
|
3495
3549
|
/**
|
|
3496
3550
|
* Retrieves all axes
|
|
3497
3551
|
*
|
|
@@ -3504,6 +3558,26 @@ declare class InputBindingRegistry {
|
|
|
3504
3558
|
* @returns array of all button bindings
|
|
3505
3559
|
*/
|
|
3506
3560
|
getAllButtons(): ButtonBinding[];
|
|
3561
|
+
/**
|
|
3562
|
+
* Retrieves all touch zones
|
|
3563
|
+
*
|
|
3564
|
+
* @returns array of all touch zone bindings
|
|
3565
|
+
*/
|
|
3566
|
+
getAllTouchZones(): TouchZoneBinding[];
|
|
3567
|
+
/**
|
|
3568
|
+
* Retrieves a touch zone by ID
|
|
3569
|
+
*
|
|
3570
|
+
* @param zoneId - Zone ID
|
|
3571
|
+
* @returns zone binding or null if not found
|
|
3572
|
+
*/
|
|
3573
|
+
getTouchZone(zoneId: number): TouchZoneBinding | null;
|
|
3574
|
+
/**
|
|
3575
|
+
* Retrieves a touch zone ID from its name
|
|
3576
|
+
*
|
|
3577
|
+
* @param name - Zone name
|
|
3578
|
+
* @returns zoneId or null if not found
|
|
3579
|
+
*/
|
|
3580
|
+
getTouchZoneId(name: string): number | null;
|
|
3507
3581
|
/**
|
|
3508
3582
|
* Retrieves the current binding version
|
|
3509
3583
|
*
|
|
@@ -3524,6 +3598,13 @@ declare class InputBindingRegistry {
|
|
|
3524
3598
|
* @returns true if removed, false if not found
|
|
3525
3599
|
*/
|
|
3526
3600
|
removeButton(bindingId: number): boolean;
|
|
3601
|
+
/**
|
|
3602
|
+
* Removes a touch zone
|
|
3603
|
+
*
|
|
3604
|
+
* @param zoneId - Zone ID to remove
|
|
3605
|
+
* @returns true if removed, false if not found
|
|
3606
|
+
*/
|
|
3607
|
+
removeTouchZone(zoneId: number): boolean;
|
|
3527
3608
|
/**
|
|
3528
3609
|
* Removes all axes
|
|
3529
3610
|
*/
|
|
@@ -3532,6 +3613,10 @@ declare class InputBindingRegistry {
|
|
|
3532
3613
|
* Removes all buttons
|
|
3533
3614
|
*/
|
|
3534
3615
|
clearButtons(): void;
|
|
3616
|
+
/**
|
|
3617
|
+
* Removes all touch zones
|
|
3618
|
+
*/
|
|
3619
|
+
clearTouchZones(): void;
|
|
3535
3620
|
/**
|
|
3536
3621
|
* Completely resets the registry
|
|
3537
3622
|
*/
|
|
@@ -5124,6 +5209,40 @@ declare class User<TData = Record<string, any>> {
|
|
|
5124
5209
|
* Get the number of sounds currently playing on the client
|
|
5125
5210
|
*/
|
|
5126
5211
|
getPlayingSoundCount(): number;
|
|
5212
|
+
/**
|
|
5213
|
+
* Get audio loading state for this client
|
|
5214
|
+
*
|
|
5215
|
+
* Provides a summary of the client's audio loading progress,
|
|
5216
|
+
* useful for showing loading screens or progress bars.
|
|
5217
|
+
*
|
|
5218
|
+
* @param totalExpected - Total number of sounds expected (from SoundRegistry)
|
|
5219
|
+
* @returns Audio loading state
|
|
5220
|
+
*
|
|
5221
|
+
* @example
|
|
5222
|
+
* ```typescript
|
|
5223
|
+
* updateUser(core: Core, user: User): void {
|
|
5224
|
+
* const totalSounds = core.getSoundRegistry().getAll().length;
|
|
5225
|
+
* const audioState = user.getAudioLoadingState(totalSounds);
|
|
5226
|
+
*
|
|
5227
|
+
* if (!audioState.isComplete) {
|
|
5228
|
+
* // Client still loading sounds
|
|
5229
|
+
* console.log(`Loading: ${audioState.loadedCount}/${audioState.totalExpected}`);
|
|
5230
|
+
* }
|
|
5231
|
+
* }
|
|
5232
|
+
* ```
|
|
5233
|
+
*/
|
|
5234
|
+
getAudioLoadingState(totalExpected: number): {
|
|
5235
|
+
/** Number of sounds successfully loaded on client */
|
|
5236
|
+
loadedCount: number;
|
|
5237
|
+
/** Total number of sounds expected */
|
|
5238
|
+
totalExpected: number;
|
|
5239
|
+
/** Number of sounds that failed to load */
|
|
5240
|
+
errorCount: number;
|
|
5241
|
+
/** Whether all expected sounds are loaded */
|
|
5242
|
+
isComplete: boolean;
|
|
5243
|
+
/** Names of sounds that failed to load */
|
|
5244
|
+
errors: string[];
|
|
5245
|
+
};
|
|
5127
5246
|
/**
|
|
5128
5247
|
* Load a macro template
|
|
5129
5248
|
* The template will be sent to the client in the next config packet
|