@utsp/core 0.14.0 → 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 +10 -5
- package/dist/benchmark.d.ts +157 -30
- package/dist/benchmark.mjs +10 -5
- package/dist/index.cjs +10 -5
- package/dist/index.d.ts +210 -55
- package/dist/index.mjs +10 -5
- 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
|
/**
|
|
@@ -2884,6 +2884,11 @@ declare class Display {
|
|
|
2884
2884
|
setSize(size: Vector2): void;
|
|
2885
2885
|
}
|
|
2886
2886
|
|
|
2887
|
+
/**
|
|
2888
|
+
* Maximum number of orders per layer (encoded as 1 byte)
|
|
2889
|
+
* Exceeding this limit will cause packet corruption!
|
|
2890
|
+
*/
|
|
2891
|
+
declare const MAX_ORDERS_PER_LAYER = 255;
|
|
2887
2892
|
/**
|
|
2888
2893
|
* Layer configuration options
|
|
2889
2894
|
*/
|
|
@@ -3075,14 +3080,19 @@ declare class Layer {
|
|
|
3075
3080
|
* ```
|
|
3076
3081
|
*/
|
|
3077
3082
|
commit(): void;
|
|
3083
|
+
/**
|
|
3084
|
+
* Returns a breakdown of order types for debugging
|
|
3085
|
+
* @internal
|
|
3086
|
+
*/
|
|
3087
|
+
private getOrdersBreakdown;
|
|
3078
3088
|
/**
|
|
3079
3089
|
* Checks if layer needs to be sent
|
|
3080
|
-
* @internal - Used by Core.
|
|
3090
|
+
* @internal - Used by Core.endTick()
|
|
3081
3091
|
*/
|
|
3082
3092
|
getNeedsCommit(): boolean;
|
|
3083
3093
|
/**
|
|
3084
3094
|
* Resets commit flag after sending
|
|
3085
|
-
* @internal - Used by Core.
|
|
3095
|
+
* @internal - Used by Core.endTick()
|
|
3086
3096
|
*/
|
|
3087
3097
|
resetCommit(): void;
|
|
3088
3098
|
}
|
|
@@ -3269,14 +3279,17 @@ declare class MacroRegistry {
|
|
|
3269
3279
|
*
|
|
3270
3280
|
* Allows to:
|
|
3271
3281
|
* - Define axes and buttons (bindingId → name)
|
|
3282
|
+
* - Define touch zones (virtual screen regions for mobile)
|
|
3272
3283
|
* - Generate a JSON LoadPacket to send to client
|
|
3273
3284
|
* - Decode compressed inputs received from client (future)
|
|
3274
3285
|
*/
|
|
3275
3286
|
declare class InputBindingRegistry {
|
|
3276
3287
|
private axes;
|
|
3277
3288
|
private buttons;
|
|
3289
|
+
private touchZones;
|
|
3278
3290
|
private axisNameToId;
|
|
3279
3291
|
private buttonNameToId;
|
|
3292
|
+
private touchZoneNameToId;
|
|
3280
3293
|
private version;
|
|
3281
3294
|
/**
|
|
3282
3295
|
* Defines an axis binding
|
|
@@ -3320,6 +3333,44 @@ declare class InputBindingRegistry {
|
|
|
3320
3333
|
* ```
|
|
3321
3334
|
*/
|
|
3322
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;
|
|
3323
3374
|
/**
|
|
3324
3375
|
* Evaluates an axis by summing all its sources
|
|
3325
3376
|
*
|
|
@@ -3470,6 +3521,13 @@ declare class InputBindingRegistry {
|
|
|
3470
3521
|
* @returns true if defined
|
|
3471
3522
|
*/
|
|
3472
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;
|
|
3473
3531
|
/**
|
|
3474
3532
|
* Counts the number of defined axes
|
|
3475
3533
|
*
|
|
@@ -3482,6 +3540,12 @@ declare class InputBindingRegistry {
|
|
|
3482
3540
|
* @returns number of buttons
|
|
3483
3541
|
*/
|
|
3484
3542
|
getButtonCount(): number;
|
|
3543
|
+
/**
|
|
3544
|
+
* Counts the number of defined touch zones
|
|
3545
|
+
*
|
|
3546
|
+
* @returns number of touch zones
|
|
3547
|
+
*/
|
|
3548
|
+
getTouchZoneCount(): number;
|
|
3485
3549
|
/**
|
|
3486
3550
|
* Retrieves all axes
|
|
3487
3551
|
*
|
|
@@ -3494,6 +3558,26 @@ declare class InputBindingRegistry {
|
|
|
3494
3558
|
* @returns array of all button bindings
|
|
3495
3559
|
*/
|
|
3496
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;
|
|
3497
3581
|
/**
|
|
3498
3582
|
* Retrieves the current binding version
|
|
3499
3583
|
*
|
|
@@ -3514,6 +3598,13 @@ declare class InputBindingRegistry {
|
|
|
3514
3598
|
* @returns true if removed, false if not found
|
|
3515
3599
|
*/
|
|
3516
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;
|
|
3517
3608
|
/**
|
|
3518
3609
|
* Removes all axes
|
|
3519
3610
|
*/
|
|
@@ -3522,6 +3613,10 @@ declare class InputBindingRegistry {
|
|
|
3522
3613
|
* Removes all buttons
|
|
3523
3614
|
*/
|
|
3524
3615
|
clearButtons(): void;
|
|
3616
|
+
/**
|
|
3617
|
+
* Removes all touch zones
|
|
3618
|
+
*/
|
|
3619
|
+
clearTouchZones(): void;
|
|
3525
3620
|
/**
|
|
3526
3621
|
* Completely resets the registry
|
|
3527
3622
|
*/
|
|
@@ -5114,6 +5209,40 @@ declare class User<TData = Record<string, any>> {
|
|
|
5114
5209
|
* Get the number of sounds currently playing on the client
|
|
5115
5210
|
*/
|
|
5116
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
|
+
};
|
|
5117
5246
|
/**
|
|
5118
5247
|
* Load a macro template
|
|
5119
5248
|
* The template will be sent to the client in the next config packet
|
|
@@ -6677,38 +6806,22 @@ declare class Core {
|
|
|
6677
6806
|
*
|
|
6678
6807
|
* This method:
|
|
6679
6808
|
* 1. Encodes displays and layers of each user into binary packets
|
|
6680
|
-
* 2.
|
|
6681
|
-
* 3.
|
|
6682
|
-
*
|
|
6683
|
-
*
|
|
6684
|
-
*
|
|
6685
|
-
* @returns Map<userId, packet> - Encoded packets for each user
|
|
6686
|
-
*
|
|
6687
|
-
* @example
|
|
6688
|
-
* ```typescript
|
|
6689
|
-
* const packets = engine.endTick();
|
|
6690
|
-
* packets.forEach((packet, userId) => {
|
|
6691
|
-
* networkSend(userId, packet);
|
|
6692
|
-
* });
|
|
6693
|
-
* ```
|
|
6694
|
-
*/
|
|
6695
|
-
endTick(): Map<string, Uint8Array>;
|
|
6696
|
-
/**
|
|
6697
|
-
* Ends tick and generates SEPARATE packets for static and dynamic layers
|
|
6698
|
-
*
|
|
6699
|
-
* This method allows sending:
|
|
6700
|
-
* - STATIC Layers on a reliable Socket.IO channel (guaranteed delivery)
|
|
6701
|
-
* - DYNAMIC Layers on a volatile Socket.IO channel (can drop packets)
|
|
6809
|
+
* 2. Only sends layers that have called commit() (optimization)
|
|
6810
|
+
* 3. Separates static and dynamic layers for network optimization
|
|
6811
|
+
* 4. Increments tick counter
|
|
6812
|
+
* 5. Returns a Map with split packets ready to send
|
|
6702
6813
|
*
|
|
6703
|
-
*
|
|
6704
|
-
*
|
|
6814
|
+
* Network strategy:
|
|
6815
|
+
* - STATIC Layers → Reliable channel (guaranteed delivery)
|
|
6816
|
+
* - DYNAMIC Layers → Volatile channel (can drop packets for performance)
|
|
6817
|
+
* - Audio/Vibration/Macro/PostProcess orders → Only in dynamic packet
|
|
6705
6818
|
*
|
|
6706
6819
|
* @returns Map<userId, { static: Uint8Array | null, dynamic: Uint8Array | null }>
|
|
6707
6820
|
*
|
|
6708
6821
|
* @example
|
|
6709
6822
|
* ```typescript
|
|
6710
|
-
* const
|
|
6711
|
-
*
|
|
6823
|
+
* const packets = engine.endTick();
|
|
6824
|
+
* packets.forEach(({ static: staticPacket, dynamic: dynamicPacket }, userId) => {
|
|
6712
6825
|
* if (staticPacket) {
|
|
6713
6826
|
* network.sendToClient(userId, 'update-static', staticPacket); // Reliable
|
|
6714
6827
|
* }
|
|
@@ -6718,7 +6831,7 @@ declare class Core {
|
|
|
6718
6831
|
* });
|
|
6719
6832
|
* ```
|
|
6720
6833
|
*/
|
|
6721
|
-
|
|
6834
|
+
endTick(): Map<string, {
|
|
6722
6835
|
static: Uint8Array | null;
|
|
6723
6836
|
dynamic: Uint8Array | null;
|
|
6724
6837
|
}>;
|
|
@@ -7001,6 +7114,25 @@ declare class Core {
|
|
|
7001
7114
|
* @returns Array of encoded MacroLoad packets
|
|
7002
7115
|
*/
|
|
7003
7116
|
generateMacroLoadPackets(userId: string): Uint8Array[];
|
|
7117
|
+
/**
|
|
7118
|
+
* Generates an initial update packet for a specific user (SERVER-SIDE)
|
|
7119
|
+
*
|
|
7120
|
+
* This is used to send any pending PostProcessCommands (like switchPalette)
|
|
7121
|
+
* that were created during initUser() but before the first regular tick.
|
|
7122
|
+
*
|
|
7123
|
+
* @param userId - Target user ID
|
|
7124
|
+
* @returns Encoded update packet, or null if no pending commands
|
|
7125
|
+
*
|
|
7126
|
+
* @example
|
|
7127
|
+
* ```typescript
|
|
7128
|
+
* // Server side - after initUser and load packets
|
|
7129
|
+
* const initialPacket = core.generateInitialUpdatePacket(clientId);
|
|
7130
|
+
* if (initialPacket) {
|
|
7131
|
+
* socket.emit('update', initialPacket);
|
|
7132
|
+
* }
|
|
7133
|
+
* ```
|
|
7134
|
+
*/
|
|
7135
|
+
generateInitialUpdatePacket(userId: string): Uint8Array | null;
|
|
7004
7136
|
/**
|
|
7005
7137
|
* Applies Input Bindings to a user (CLIENT-SIDE)
|
|
7006
7138
|
*
|
|
@@ -8051,29 +8183,30 @@ declare function getASCII8x8FontConfig(): {
|
|
|
8051
8183
|
};
|
|
8052
8184
|
|
|
8053
8185
|
/**
|
|
8054
|
-
* CompressedInputPacket - Ultra-compact binary format for inputs (
|
|
8186
|
+
* CompressedInputPacket - Ultra-compact binary format for inputs (V5)
|
|
8055
8187
|
*
|
|
8056
8188
|
* Architecture:
|
|
8057
8189
|
* - CLIENT: Evaluates sources → Compresses → Sends
|
|
8058
8190
|
* - SERVER: Receives → Decompresses → Stores in axes/buttons Maps
|
|
8059
8191
|
*
|
|
8060
|
-
* MINIMALIST Format (
|
|
8061
|
-
*
|
|
8062
|
-
* │ Tick │ Axes │ Buttons │ Mouse │ Flags │ TextInputs │ MacroEvents │ DisplayViewports │
|
|
8063
|
-
* │ 8 bytes│ N bytes │ M bytes │ 3 bytes│ 1 byte │ variable │ variable │ 1 + 5×count bytes│
|
|
8064
|
-
*
|
|
8065
|
-
*
|
|
8066
|
-
* Tick (8 bytes)
|
|
8067
|
-
* Axes (N bytes)
|
|
8068
|
-
* Buttons (M bytes)
|
|
8069
|
-
* Mouse (3 bytes)
|
|
8070
|
-
* Flags (1 byte)
|
|
8071
|
-
* TextInputs (var)
|
|
8072
|
-
* MacroEvents (var)
|
|
8192
|
+
* MINIMALIST Format (V5):
|
|
8193
|
+
* ┌────────┬───────────┬─────────────┬────────┬──────────┬─────────────┬─────────────┬──────────────────┬────────────────┐
|
|
8194
|
+
* │ Tick │ Axes │ Buttons │ Mouse │ Flags │ TextInputs │ MacroEvents │ DisplayViewports │ TouchPositions │
|
|
8195
|
+
* │ 8 bytes│ N bytes │ M bytes │ 3 bytes│ 1 byte │ variable │ variable │ 1 + 5×count bytes│ 1 + 4×count │
|
|
8196
|
+
* └────────┴───────────┴─────────────┴────────┴──────────┴─────────────┴─────────────┴──────────────────┴────────────────┘
|
|
8197
|
+
*
|
|
8198
|
+
* Tick (8 bytes) : Frame number (uint64, little-endian)
|
|
8199
|
+
* Axes (N bytes) : 1 byte per axis (int8, -127 to +127)
|
|
8200
|
+
* Buttons (M bytes) : Bitpacking (8 buttons per byte, ⌈ButtonCount/8⌉)
|
|
8201
|
+
* Mouse (3 bytes) : displayId (1) + mouseX (1) + mouseY (1)
|
|
8202
|
+
* Flags (1 byte) : Bit 0 = mouseOverDisplay
|
|
8203
|
+
* TextInputs (var) : 1 byte count + length-prefixed UTF-8 strings
|
|
8204
|
+
* MacroEvents (var) : 1 byte count + encoded events (see MacroEventEncoder)
|
|
8073
8205
|
* DisplayViewports (var): 1 byte count + per display: id(1) + pixelWidth(2) + pixelHeight(2)
|
|
8206
|
+
* TouchPositions (var) : 1 byte count + per touch: id(1) + x(1) + y(1) + flags(1)
|
|
8074
8207
|
*
|
|
8075
8208
|
* Note: axisCount and buttonCount are known in advance via InputBindingRegistry
|
|
8076
|
-
* Example: 5 axes + 12 buttons = 8 + 5 + 2 + 3 + 1 = 19 bytes (+ text + macro + viewports)
|
|
8209
|
+
* Example: 5 axes + 12 buttons = 8 + 5 + 2 + 3 + 1 = 19 bytes (+ text + macro + viewports + touches)
|
|
8077
8210
|
*/
|
|
8078
8211
|
|
|
8079
8212
|
/**
|
|
@@ -8088,6 +8221,20 @@ interface DisplayViewport {
|
|
|
8088
8221
|
/** Available height in pixels (0-65535) */
|
|
8089
8222
|
pixelHeight: number;
|
|
8090
8223
|
}
|
|
8224
|
+
/**
|
|
8225
|
+
* Represents a touch position for multi-touch support
|
|
8226
|
+
* Each active touch point is encoded separately
|
|
8227
|
+
*/
|
|
8228
|
+
interface TouchPosition {
|
|
8229
|
+
/** Touch ID (0-9) */
|
|
8230
|
+
id: number;
|
|
8231
|
+
/** Touch X position in display cells (0-255) */
|
|
8232
|
+
x: number;
|
|
8233
|
+
/** Touch Y position in display cells (0-255) */
|
|
8234
|
+
y: number;
|
|
8235
|
+
/** Is touch active/over a display? */
|
|
8236
|
+
over: boolean;
|
|
8237
|
+
}
|
|
8091
8238
|
/**
|
|
8092
8239
|
* Represents a compressed input on the server side (after decoding)
|
|
8093
8240
|
*
|
|
@@ -8098,6 +8245,7 @@ interface DisplayViewport {
|
|
|
8098
8245
|
* - TextInputs: array of key strings for text input (e.g., ['a', 'Backspace', 'Enter'])
|
|
8099
8246
|
* - MacroEvents: array of macro events (clicks, changes, submits, selects)
|
|
8100
8247
|
* - DisplayViewports: array of available viewport sizes in pixels per display
|
|
8248
|
+
* - TouchPositions: array of active touch positions (multi-touch support)
|
|
8101
8249
|
*/
|
|
8102
8250
|
interface CompressedInputPacket {
|
|
8103
8251
|
/** Frame number (tick) - uint64 */
|
|
@@ -8120,6 +8268,8 @@ interface CompressedInputPacket {
|
|
|
8120
8268
|
macroEvents: AnyMacroEvent[];
|
|
8121
8269
|
/** Display viewports available on client side (in pixels) - for responsive display sizing */
|
|
8122
8270
|
displayViewports: DisplayViewport[];
|
|
8271
|
+
/** Active touch positions (multi-touch support, up to 10 touches) */
|
|
8272
|
+
touchPositions: TouchPosition[];
|
|
8123
8273
|
}
|
|
8124
8274
|
/**
|
|
8125
8275
|
* Creates an empty CompressedInputPacket
|
|
@@ -8201,7 +8351,7 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
|
|
|
8201
8351
|
* 2. Client encodes final values in compact binary
|
|
8202
8352
|
* 3. Client sends buffer to server via WebSocket
|
|
8203
8353
|
*
|
|
8204
|
-
* MINIMALIST
|
|
8354
|
+
* MINIMALIST V5 Format (without counts):
|
|
8205
8355
|
* - Tick: uint64 (8 bytes)
|
|
8206
8356
|
* - Axes: float (-1.0 to +1.0) → int8 (-127 to +127) = 1 byte per axis
|
|
8207
8357
|
* - Buttons: boolean → bitpacking = 8 buttons per byte
|
|
@@ -8210,14 +8360,15 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
|
|
|
8210
8360
|
* - TextInputs: 1 byte count + length-prefixed strings
|
|
8211
8361
|
* - MacroEvents: 1 byte count + encoded events
|
|
8212
8362
|
* - DisplayViewports: 1 byte count + per display: id(1) + pixelWidth(2) + pixelHeight(2)
|
|
8363
|
+
* - TouchPositions: 1 byte count + per touch: id(1) + x(1) + y(1) + flags(1)
|
|
8213
8364
|
*
|
|
8214
8365
|
* PREREQUISITE: Client and server must have the SAME bindings defined!
|
|
8215
8366
|
*
|
|
8216
|
-
* Example: 5 axes + 12 buttons + mouse = 19 bytes total (+ text inputs + macro events + viewports)
|
|
8367
|
+
* Example: 5 axes + 12 buttons + mouse = 19 bytes total (+ text inputs + macro events + viewports + touches)
|
|
8217
8368
|
*/
|
|
8218
8369
|
|
|
8219
8370
|
/**
|
|
8220
|
-
* Encodes inputs in compact binary format
|
|
8371
|
+
* Encodes inputs in compact binary format v5 (CLIENT-SIDE)
|
|
8221
8372
|
*
|
|
8222
8373
|
* @param tick - Frame number (bigint for uint64)
|
|
8223
8374
|
* @param axes - Map of axis values (bindingId → float between -1.0 and +1.0)
|
|
@@ -8229,6 +8380,7 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
|
|
|
8229
8380
|
* @param textInputs - Array of text input strings
|
|
8230
8381
|
* @param macroEvents - Array of macro events (clicks, changes, submits, selects)
|
|
8231
8382
|
* @param displayViewports - Array of display viewports (pixels) that have changed
|
|
8383
|
+
* @param touchPositions - Array of active touch positions (multi-touch support)
|
|
8232
8384
|
* @returns Encoded buffer (without counts, minimalist format)
|
|
8233
8385
|
*
|
|
8234
8386
|
* @example
|
|
@@ -8236,10 +8388,11 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
|
|
|
8236
8388
|
* const axes = new Map([[0, -0.7], [1, 0.5]]);
|
|
8237
8389
|
* const buttons = new Map([[0, true], [1, false], [2, true]]);
|
|
8238
8390
|
* const viewports = [{ displayId: 0, pixelWidth: 800, pixelHeight: 600 }];
|
|
8239
|
-
* const
|
|
8391
|
+
* const touches = [{ id: 0, x: 10, y: 20, over: true }];
|
|
8392
|
+
* const buffer = encodeCompressedInput(42n, axes, buttons, 0, 128, 64, true, [], [], viewports, touches);
|
|
8240
8393
|
* ```
|
|
8241
8394
|
*/
|
|
8242
|
-
declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>, buttons: Map<number, boolean>, displayId: number, mouseX: number, mouseY: number, mouseOverDisplay: boolean, textInputs?: string[], macroEvents?: AnyMacroEvent[], displayViewports?: DisplayViewport[]): Uint8Array;
|
|
8395
|
+
declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>, buttons: Map<number, boolean>, displayId: number, mouseX: number, mouseY: number, mouseOverDisplay: boolean, textInputs?: string[], macroEvents?: AnyMacroEvent[], displayViewports?: DisplayViewport[], touchPositions?: TouchPosition[]): Uint8Array;
|
|
8243
8396
|
|
|
8244
8397
|
/**
|
|
8245
8398
|
* CompressedInputDecoder - Decodes inputs from compact binary format
|
|
@@ -8248,10 +8401,10 @@ declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>,
|
|
|
8248
8401
|
*
|
|
8249
8402
|
* Workflow:
|
|
8250
8403
|
* 1. Server receives binary buffer from client via WebSocket
|
|
8251
|
-
* 2. Server decodes values (MINIMALIST
|
|
8404
|
+
* 2. Server decodes values (MINIMALIST V5 format - without counts)
|
|
8252
8405
|
* 3. Server stores in user.axes and user.buttons Maps
|
|
8253
8406
|
*
|
|
8254
|
-
* MINIMALIST
|
|
8407
|
+
* MINIMALIST V5 Format (without counts):
|
|
8255
8408
|
* - PREREQUISITE: Client and server must have the SAME bindings defined!
|
|
8256
8409
|
* - Buffer does NOT contain AxisCount nor ButtonCount
|
|
8257
8410
|
* - Server must pass its registry to know expected structure
|
|
@@ -8263,9 +8416,10 @@ declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>,
|
|
|
8263
8416
|
* - TextInputs: 1 byte count + length-prefixed strings
|
|
8264
8417
|
* - MacroEvents: 1 byte count + encoded events
|
|
8265
8418
|
* - DisplayViewports: 1 byte count + per display: id(1) + pixelWidth(2) + pixelHeight(2)
|
|
8419
|
+
* - TouchPositions: 1 byte count + per touch: id(1) + x(1) + y(1) + flags(1)
|
|
8266
8420
|
*
|
|
8267
8421
|
* Example (2 axes, 3 buttons):
|
|
8268
|
-
* - Tick (8) + Axes (2) + Buttons (1) + DisplayId (1) + Mouse (3) = 15 bytes (+ text + macro + viewports)
|
|
8422
|
+
* - Tick (8) + Axes (2) + Buttons (1) + DisplayId (1) + Mouse (3) = 15 bytes (+ text + macro + viewports + touches)
|
|
8269
8423
|
*/
|
|
8270
8424
|
|
|
8271
8425
|
/**
|
|
@@ -8292,6 +8446,7 @@ declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>,
|
|
|
8292
8446
|
* // packet.displayId → 0
|
|
8293
8447
|
* // packet.mouseOverDisplay → true
|
|
8294
8448
|
* // packet.displayViewports → [{ displayId: 0, pixelWidth: 800, pixelHeight: 600 }]
|
|
8449
|
+
* // packet.touchPositions → [{ id: 0, x: 10, y: 20, over: true }]
|
|
8295
8450
|
* ```
|
|
8296
8451
|
*/
|
|
8297
8452
|
declare function decodeCompressedInput(buffer: Uint8Array, registry: InputBindingRegistry): CompressedInputPacket;
|
|
@@ -9597,5 +9752,5 @@ declare class PostProcessOrderCollector {
|
|
|
9597
9752
|
private parseColor;
|
|
9598
9753
|
}
|
|
9599
9754
|
|
|
9600
|
-
export { ASCII_8X8_FONT, AUDIO_CONFIGURE_SPATIAL_SIZE, AUDIO_FADEOUT_SOUND_MIN_SIZE, AUDIO_PAUSE_SOUND_MIN_SIZE, AUDIO_PLAY_GLOBAL_SOUND_MIN_SIZE, AUDIO_PLAY_SOUND_MIN_SIZE, AUDIO_RESUME_SOUND_MIN_SIZE, AUDIO_SET_LISTENER_POSITION_SIZE, AUDIO_SET_SOUND_EFFECTS_MIN_SIZE, AUDIO_STOP_SOUND_MIN_SIZE, AudioOrderCollector, AudioOrderDecoder, AudioOrderType, AudioTargetType, BITMASK16_ORDER_MIN_SIZE, BITMASK4_ORDER_MIN_SIZE, BITMASK_ORDER_MIN_SIZE, BitmapFont, BitmapFontRegistry, CHAR_ORDER_SIZE, CIRCLE_SHAPE_SIZE, CLEAR_ORDER_SIZE, COLORMAP_ORDER_MIN_SIZE, COLOR_SKIP, CellBuffer, CharCodeBuffer, Core, CoreStats, DISPLAY_HEADER_SIZE, DOTCLOUD_MULTICOLOR_ORDER_MIN_SIZE, DOTCLOUD_ORDER_MIN_SIZE, Display, ELLIPSE_SHAPE_SIZE, FILLCHAR_ORDER_MIN_SIZE, FILLSPRITE_MULTICOLOR_ORDER_SIZE, FILLSPRITE_ORDER_SIZE, FULLFRAME_MULTICOLOR_ORDER_MIN_SIZE, FULLFRAME_ORDER_MIN_SIZE, FontType, GamepadVibrateFlags, ImageFont, ImageFontRegistry, InputBindingRegistry, LAYER_CELL_COUNT, LAYER_HEADER_SIZE, LAYER_SIZE, LINE_SHAPE_SIZE, Layer, LoadType, MacroEngine, MacroEventType, MacroOrderType, MacroRegistry, MobileVibrateFlags, OrderBuilder, OrderType, POLYLINE_ORDER_MIN_SIZE, POSTPROCESS_SET_AMBIENT_EFFECT_SIZE, POSTPROCESS_SET_CELL_SIZE_SIZE, POSTPROCESS_SET_CONFIG_MIN_SIZE, POSTPROCESS_SET_GRID_SIZE, POSTPROCESS_SET_SCALING_MODE_SIZE, POSTPROCESS_SET_SCANLINES_SIZE, POSTPROCESS_SWITCH_PALETTE_SIZE, PlaySoundFlags, PostProcessOrderCollector, PostProcessOrderDecoder, PostProcessOrderType, RECTANGLE_SHAPE_SIZE, SHAPE_ORDER_MIN_SIZE, SPRITECLOUD_MULTICOLOR_ORDER_MIN_SIZE, SPRITECLOUD_ORDER_MIN_SIZE, SPRITECLOUD_VARIED_MULTICOLOR_ORDER_MIN_SIZE, SPRITECLOUD_VARIED_ORDER_MIN_SIZE, SPRITE_MULTICOLOR_ORDER_SIZE, SPRITE_ORDER_SIZE, SUBFRAME_MULTICOLOR_ORDER_MIN_SIZE, SUBFRAME_ORDER_MIN_SIZE, ShapeType, SoundEffectsFlags, SoundRegistry, SpriteRegistry, TEXT_MULTILINE_ORDER_MIN_SIZE, TEXT_ORDER_MIN_SIZE, TRIANGLE_SHAPE_SIZE, UPDATE_PACKET_HEADER_SIZE, UpdateFlags, UpdateFlagsHelper, UpdatePacketDecoder, User, UserStats, VibrationOrderCollector, VibrationOrderDecoder, VibrationOrderEncoder, VibrationOrderType, WebFont, WebFontRegistry, charCodeByteSize, createASCII8x8FontLoad, createEmptyCompressedInputPacket, decodeCompressedInput, decodeInt8ToAxis, encodeAxisToInt8, encodeCompressedInput, getASCII8x8FontConfig, getAllCharCodes, getAtlasColumns, getAtlasDimensions, getAudioOrderTypeName, getButtonByteCount, getCharBitmap, getCompressedPacketSize, getMacroEventTypeName, getMacroOrderTypeName, getMaxCharCode, getOrderTypeName, hasChar, isValidAudioOrderType, isValidMacroEventType, isValidMacroOrderType, isValidOrderType };
|
|
9601
|
-
export type { AnyAudioOrder, AnyLoad, AnyMacroEvent, AnyMacroOrder, AnyPostProcessOrder, AnyVibrationOrder, AtlasBlocks, AudioOrder, BitmapFontConfig, BitmapFontLoad, Bitmask16Order, Bitmask16Variant, Bitmask4Order, Bitmask4Variant, BitmaskOrder, ButtonBorderStyle, ButtonConfig, ButtonStateColors, Cell, ChangeEvent, CharCodeMode, CircleShape, ClickEvent, Color, ColorPaletteLoad, CompressedInputPacket, ConfigureSpatialOrder, CoreMode, CoreOptions, CreateInstanceConfig, CreateInstanceOrder, DisplayViewport, EffectMacroTemplate, EffectTransform, EllipseShape, FadeOutSoundOrder, GamepadCancelOrder, GamepadVibrateOrder, GamepadVibrationOrder, GlyphSize, ImageFontConfig, ImageFontLoad, ImageFontOptions, LineMacroTemplate, LineShape, MacroEntry, MacroEvent, MacroInstanceEntry, MacroLoad, MacroOrder, MacroTemplate, MacroTemplateBase, MacroType, MacroUpdateResult, MobileCancelOrder, MobileVibrateOrder, MobileVibrationOrder, MulticolorCell, MulticolorSprite, MulticolorSpriteLoad, NetworkDisplay, NetworkLayer, ParticleConfig, ParticleEmitter, ParticleMacroTemplate, PauseSoundOrder, PlayGlobalSoundOrder, PlaySoundOrder, RectangleShape, RemoveInstanceOrder, RenderCommand, ResumeSoundOrder, RevealCellDef, RevealContent, RevealContentType, RevealCursor, RevealDirection, RevealMacroTemplate, RevealPattern, RevealPause, SelectEvent, SetAmbientEffectOrder, SetConfigOrder, SetGridOrder, SetListenerPositionOrder, SetScalingModeOrder, SetScanlinesOrder, SetSoundEffectsOrder, ShapeData, SoundEntry, SoundLoad, SpriteLoad, StopSoundOrder, SubmitEvent, SwitchPaletteOrder, TickStats, TriangleShape, UIMacroTemplate, UIState, UISubtype, UnicolorSprite, UpdateInstanceOrder, UpdatePacket, UserTickStats, VibrationOrder, WebFontConfig, WebFontLoad };
|
|
9755
|
+
export { ASCII_8X8_FONT, AUDIO_CONFIGURE_SPATIAL_SIZE, AUDIO_FADEOUT_SOUND_MIN_SIZE, AUDIO_PAUSE_SOUND_MIN_SIZE, AUDIO_PLAY_GLOBAL_SOUND_MIN_SIZE, AUDIO_PLAY_SOUND_MIN_SIZE, AUDIO_RESUME_SOUND_MIN_SIZE, AUDIO_SET_LISTENER_POSITION_SIZE, AUDIO_SET_SOUND_EFFECTS_MIN_SIZE, AUDIO_STOP_SOUND_MIN_SIZE, AudioOrderCollector, AudioOrderDecoder, AudioOrderType, AudioTargetType, BITMASK16_ORDER_MIN_SIZE, BITMASK4_ORDER_MIN_SIZE, BITMASK_ORDER_MIN_SIZE, BitmapFont, BitmapFontRegistry, CHAR_ORDER_SIZE, CIRCLE_SHAPE_SIZE, CLEAR_ORDER_SIZE, COLORMAP_ORDER_MIN_SIZE, COLOR_SKIP, CellBuffer, CharCodeBuffer, Core, CoreStats, DISPLAY_HEADER_SIZE, DOTCLOUD_MULTICOLOR_ORDER_MIN_SIZE, DOTCLOUD_ORDER_MIN_SIZE, Display, ELLIPSE_SHAPE_SIZE, FILLCHAR_ORDER_MIN_SIZE, FILLSPRITE_MULTICOLOR_ORDER_SIZE, FILLSPRITE_ORDER_SIZE, FULLFRAME_MULTICOLOR_ORDER_MIN_SIZE, FULLFRAME_ORDER_MIN_SIZE, FontType, GamepadVibrateFlags, ImageFont, ImageFontRegistry, InputBindingRegistry, LAYER_CELL_COUNT, LAYER_HEADER_SIZE, LAYER_SIZE, LINE_SHAPE_SIZE, Layer, LoadType, MAX_ORDERS_PER_LAYER, MacroEngine, MacroEventType, MacroOrderType, MacroRegistry, MobileVibrateFlags, OrderBuilder, OrderType, POLYLINE_ORDER_MIN_SIZE, POSTPROCESS_SET_AMBIENT_EFFECT_SIZE, POSTPROCESS_SET_CELL_SIZE_SIZE, POSTPROCESS_SET_CONFIG_MIN_SIZE, POSTPROCESS_SET_GRID_SIZE, POSTPROCESS_SET_SCALING_MODE_SIZE, POSTPROCESS_SET_SCANLINES_SIZE, POSTPROCESS_SWITCH_PALETTE_SIZE, PlaySoundFlags, PostProcessOrderCollector, PostProcessOrderDecoder, PostProcessOrderType, RECTANGLE_SHAPE_SIZE, SHAPE_ORDER_MIN_SIZE, SPRITECLOUD_MULTICOLOR_ORDER_MIN_SIZE, SPRITECLOUD_ORDER_MIN_SIZE, SPRITECLOUD_VARIED_MULTICOLOR_ORDER_MIN_SIZE, SPRITECLOUD_VARIED_ORDER_MIN_SIZE, SPRITE_MULTICOLOR_ORDER_SIZE, SPRITE_ORDER_SIZE, SUBFRAME_MULTICOLOR_ORDER_MIN_SIZE, SUBFRAME_ORDER_MIN_SIZE, ShapeType, SoundEffectsFlags, SoundRegistry, SpriteRegistry, TEXT_MULTILINE_ORDER_MIN_SIZE, TEXT_ORDER_MIN_SIZE, TRIANGLE_SHAPE_SIZE, UPDATE_PACKET_HEADER_SIZE, UpdateFlags, UpdateFlagsHelper, UpdatePacketDecoder, User, UserStats, VibrationOrderCollector, VibrationOrderDecoder, VibrationOrderEncoder, VibrationOrderType, WebFont, WebFontRegistry, charCodeByteSize, createASCII8x8FontLoad, createEmptyCompressedInputPacket, decodeCompressedInput, decodeInt8ToAxis, encodeAxisToInt8, encodeCompressedInput, getASCII8x8FontConfig, getAllCharCodes, getAtlasColumns, getAtlasDimensions, getAudioOrderTypeName, getButtonByteCount, getCharBitmap, getCompressedPacketSize, getMacroEventTypeName, getMacroOrderTypeName, getMaxCharCode, getOrderTypeName, hasChar, isValidAudioOrderType, isValidMacroEventType, isValidMacroOrderType, isValidOrderType };
|
|
9756
|
+
export type { AnyAudioOrder, AnyLoad, AnyMacroEvent, AnyMacroOrder, AnyPostProcessOrder, AnyVibrationOrder, AtlasBlocks, AudioOrder, BitmapFontConfig, BitmapFontLoad, Bitmask16Order, Bitmask16Variant, Bitmask4Order, Bitmask4Variant, BitmaskOrder, ButtonBorderStyle, ButtonConfig, ButtonStateColors, Cell, ChangeEvent, CharCodeMode, CircleShape, ClickEvent, Color, ColorPaletteLoad, CompressedInputPacket, ConfigureSpatialOrder, CoreMode, CoreOptions, CreateInstanceConfig, CreateInstanceOrder, DisplayViewport, EffectMacroTemplate, EffectTransform, EllipseShape, FadeOutSoundOrder, GamepadCancelOrder, GamepadVibrateOrder, GamepadVibrationOrder, GlyphSize, ImageFontConfig, ImageFontLoad, ImageFontOptions, LineMacroTemplate, LineShape, MacroEntry, MacroEvent, MacroInstanceEntry, MacroLoad, MacroOrder, MacroTemplate, MacroTemplateBase, MacroType, MacroUpdateResult, MobileCancelOrder, MobileVibrateOrder, MobileVibrationOrder, MulticolorCell, MulticolorSprite, MulticolorSpriteLoad, NetworkDisplay, NetworkLayer, ParticleConfig, ParticleEmitter, ParticleMacroTemplate, PauseSoundOrder, PlayGlobalSoundOrder, PlaySoundOrder, RectangleShape, RemoveInstanceOrder, RenderCommand, ResumeSoundOrder, RevealCellDef, RevealContent, RevealContentType, RevealCursor, RevealDirection, RevealMacroTemplate, RevealPattern, RevealPause, SelectEvent, SetAmbientEffectOrder, SetConfigOrder, SetGridOrder, SetListenerPositionOrder, SetScalingModeOrder, SetScanlinesOrder, SetSoundEffectsOrder, ShapeData, SoundEntry, SoundLoad, SpriteLoad, StopSoundOrder, SubmitEvent, SwitchPaletteOrder, TickStats, TouchPosition, TriangleShape, UIMacroTemplate, UIState, UISubtype, UnicolorSprite, UpdateInstanceOrder, UpdatePacket, UserTickStats, VibrationOrder, WebFontConfig, WebFontLoad };
|