@utsp/core 0.5.0 → 0.6.0

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 CHANGED
@@ -149,1205 +149,2002 @@ declare class BitmapFont {
149
149
  }
150
150
 
151
151
  /**
152
- * UTSP Audio Order Types Enumeration
153
- *
154
- * Audio orders are separate from render orders and have their own type space.
155
- * They are included in the UpdatePacket but processed by the AudioProcessor,
156
- * not the Rasterizer.
157
- *
158
- * This separation ensures:
159
- * - Clear distinction between visual and audio orders
160
- * - Independent type numbering (0x01 audio ≠ 0x01 render)
161
- * - Extensibility without conflicts
152
+ * Base interface for all network orders
153
+ */
154
+ interface NetworkOrder {
155
+ type: number;
156
+ }
157
+ /**
158
+ * 0x01 - Char: Renders a single character at a specific position
159
+ */
160
+ interface CharOrder extends NetworkOrder {
161
+ type: 0x01;
162
+ posX: number;
163
+ posY: number;
164
+ charCode: number;
165
+ bgColorCode: number;
166
+ fgColorCode: number;
167
+ }
168
+ /**
169
+ * 0x02 - Text: Renders a string of characters with uniform colors
170
+ */
171
+ interface TextOrder extends NetworkOrder {
172
+ type: 0x02;
173
+ posX: number;
174
+ posY: number;
175
+ text: string;
176
+ bgColorCode: number;
177
+ fgColorCode: number;
178
+ }
179
+ /**
180
+ * 0x17 - TextMultiline: Renders multiple lines of text (\n for line breaks)
181
+ */
182
+ interface TextMultilineOrder extends NetworkOrder {
183
+ type: 0x17;
184
+ posX: number;
185
+ posY: number;
186
+ text: string;
187
+ bgColorCode: number;
188
+ fgColorCode: number;
189
+ }
190
+ /**
191
+ * 0x03 - SubFrame: Renders a rectangular region with uniform colors
192
+ */
193
+ interface SubFrameOrder extends NetworkOrder {
194
+ type: 0x03;
195
+ posX: number;
196
+ posY: number;
197
+ sizeX: number;
198
+ sizeY: number;
199
+ bgColorCode: number;
200
+ fgColorCode: number;
201
+ frame: number[];
202
+ }
203
+ /**
204
+ * 0x04 - SubFrameMultiColor: Rectangular region with per-cell colors
205
+ */
206
+ interface SubFrameMultiColorOrder extends NetworkOrder {
207
+ type: 0x04;
208
+ posX: number;
209
+ posY: number;
210
+ sizeX: number;
211
+ sizeY: number;
212
+ frame: Array<{
213
+ charCode: number;
214
+ bgColorCode: number;
215
+ fgColorCode: number;
216
+ }>;
217
+ }
218
+ /**
219
+ * 0x05 - FullFrame: Renders entire screen with uniform colors
220
+ */
221
+ interface FullFrameOrder extends NetworkOrder {
222
+ type: 0x05;
223
+ bgColorCode: number;
224
+ fgColorCode: number;
225
+ frame: number[];
226
+ }
227
+ /**
228
+ * 0x06 - FullFrameMultiColor: Entire screen with per-cell colors
229
+ */
230
+ interface FullFrameMultiColorOrder extends NetworkOrder {
231
+ type: 0x06;
232
+ frame: Array<{
233
+ charCode: number;
234
+ bgColorCode: number;
235
+ fgColorCode: number;
236
+ }>;
237
+ }
238
+ /**
239
+ * 0x07 - Sprite: Renders a preloaded unicolor sprite
240
+ */
241
+ interface SpriteOrder extends NetworkOrder {
242
+ type: 0x07;
243
+ posX: number;
244
+ posY: number;
245
+ spriteIndex: number;
246
+ bgColorCode: number;
247
+ fgColorCode: number;
248
+ }
249
+ /**
250
+ * 0x08 - SpriteMultiColor: Renders a preloaded multicolor sprite
251
+ */
252
+ interface SpriteMultiColorOrder extends NetworkOrder {
253
+ type: 0x08;
254
+ posX: number;
255
+ posY: number;
256
+ spriteIndex: number;
257
+ }
258
+ /**
259
+ * 0x09 - ColorMap: Applies colors to a region without changing characters
260
+ */
261
+ interface ColorMapOrder extends NetworkOrder {
262
+ type: 0x09;
263
+ posX: number;
264
+ posY: number;
265
+ sizeX: number;
266
+ sizeY: number;
267
+ colorData: Array<{
268
+ bgColorCode: number;
269
+ fgColorCode: number;
270
+ }>;
271
+ }
272
+ /**
273
+ * 0x0A - Shape: Renders geometric shapes
274
+ */
275
+ interface ShapeOrder extends NetworkOrder {
276
+ type: 0x0a;
277
+ shapeType: ShapeType;
278
+ shapeData: ShapeData;
279
+ }
280
+ declare enum ShapeType {
281
+ Rectangle = 1,
282
+ Circle = 2,
283
+ Line = 3,
284
+ Ellipse = 4,
285
+ Triangle = 5
286
+ }
287
+ type ShapeData = RectangleShape | CircleShape | LineShape | EllipseShape | TriangleShape;
288
+ interface RectangleShape {
289
+ posX: number;
290
+ posY: number;
291
+ width: number;
292
+ height: number;
293
+ filled: boolean;
294
+ charCode: number;
295
+ bgColorCode: number;
296
+ fgColorCode: number;
297
+ }
298
+ interface CircleShape {
299
+ centerX: number;
300
+ centerY: number;
301
+ radius: number;
302
+ filled: boolean;
303
+ charCode: number;
304
+ bgColorCode: number;
305
+ fgColorCode: number;
306
+ }
307
+ interface LineShape {
308
+ x1: number;
309
+ y1: number;
310
+ x2: number;
311
+ y2: number;
312
+ charCode: number;
313
+ bgColorCode: number;
314
+ fgColorCode: number;
315
+ }
316
+ interface EllipseShape {
317
+ centerX: number;
318
+ centerY: number;
319
+ radiusX: number;
320
+ radiusY: number;
321
+ filled: boolean;
322
+ charCode: number;
323
+ bgColorCode: number;
324
+ fgColorCode: number;
325
+ }
326
+ interface TriangleShape {
327
+ x1: number;
328
+ y1: number;
329
+ x2: number;
330
+ y2: number;
331
+ x3: number;
332
+ y3: number;
333
+ filled: boolean;
334
+ charCode: number;
335
+ bgColorCode: number;
336
+ fgColorCode: number;
337
+ }
338
+ /**
339
+ * 0x0B - DotCloud: Same character at multiple positions (up to 65535)
340
+ */
341
+ interface DotCloudOrder extends NetworkOrder {
342
+ type: 0x0b;
343
+ charCode: number;
344
+ bgColorCode: number;
345
+ fgColorCode: number;
346
+ positions: Array<{
347
+ posX: number;
348
+ posY: number;
349
+ }>;
350
+ }
351
+ /**
352
+ * 0x0C - DotCloudMultiColor: Different characters at multiple positions
353
+ */
354
+ interface DotCloudMultiColorOrder extends NetworkOrder {
355
+ type: 0x0c;
356
+ dots: Array<{
357
+ charCode: number;
358
+ bgColorCode: number;
359
+ fgColorCode: number;
360
+ posX: number;
361
+ posY: number;
362
+ }>;
363
+ }
364
+ /**
365
+ * 0x0D - SpriteCloud: Same unicolor sprite at multiple positions
366
+ */
367
+ interface SpriteCloudOrder extends NetworkOrder {
368
+ type: 0x0d;
369
+ spriteIndex: number;
370
+ bgColorCode: number;
371
+ fgColorCode: number;
372
+ positions: Array<{
373
+ posX: number;
374
+ posY: number;
375
+ }>;
376
+ }
377
+ /**
378
+ * 0x0E - SpriteCloudMultiColor: Same multicolor sprite at multiple positions
379
+ */
380
+ interface SpriteCloudMultiColorOrder extends NetworkOrder {
381
+ type: 0x0e;
382
+ spriteIndex: number;
383
+ positions: Array<{
384
+ posX: number;
385
+ posY: number;
386
+ }>;
387
+ }
388
+ /**
389
+ * 0x0F - SpriteCloudVaried: Different unicolor sprites at multiple positions
390
+ */
391
+ interface SpriteCloudVariedOrder extends NetworkOrder {
392
+ type: 0x0f;
393
+ sprites: Array<{
394
+ spriteIndex: number;
395
+ bgColorCode: number;
396
+ fgColorCode: number;
397
+ posX: number;
398
+ posY: number;
399
+ }>;
400
+ }
401
+ /**
402
+ * 0x10 - SpriteCloudVariedMultiColor: Different multicolor sprites at multiple positions
403
+ */
404
+ interface SpriteCloudVariedMultiColorOrder extends NetworkOrder {
405
+ type: 0x10;
406
+ sprites: Array<{
407
+ spriteIndex: number;
408
+ posX: number;
409
+ posY: number;
410
+ }>;
411
+ }
412
+ /**
413
+ * 0x11 - Bitmask: Renders a rectangular region with bitpacked presence mask
414
+ * Each bit represents presence (1) or absence (0) of the character at that position
415
+ * Ideal for: ore veins, destructible terrain, collision maps, fog of war, etc.
416
+ */
417
+ interface BitmaskOrder extends NetworkOrder {
418
+ type: 0x11;
419
+ posX: number;
420
+ posY: number;
421
+ sizeX: number;
422
+ sizeY: number;
423
+ charCode: number;
424
+ bgColorCode: number;
425
+ fgColorCode: number;
426
+ override: boolean;
427
+ mask: Uint8Array;
428
+ }
429
+ /**
430
+ * Cell variant definition for Bitmask4 order
431
+ */
432
+ interface Bitmask4Variant {
433
+ charCode: number;
434
+ bgColorCode: number;
435
+ fgColorCode: number;
436
+ }
437
+ /**
438
+ * 0x12 - Bitmask4: Renders a rectangular region with 2-bit packed mask
439
+ * Each 2-bit value represents: 0 = absence, 1-3 = variant index
440
+ */
441
+ interface Bitmask4Order extends NetworkOrder {
442
+ type: 0x12;
443
+ posX: number;
444
+ posY: number;
445
+ sizeX: number;
446
+ sizeY: number;
447
+ override: boolean;
448
+ variants: [Bitmask4Variant, Bitmask4Variant, Bitmask4Variant];
449
+ mask: Uint8Array;
450
+ }
451
+ /**
452
+ * Cell variant definition for Bitmask16 order
453
+ */
454
+ interface Bitmask16Variant {
455
+ charCode: number;
456
+ bgColorCode: number;
457
+ fgColorCode: number;
458
+ }
459
+ /**
460
+ * 0x18 - Bitmask16: Renders a rectangular region with 4-bit packed mask
461
+ * Each 4-bit value represents: 0 = absence, 1-15 = variant index
462
+ */
463
+ interface Bitmask16Order extends NetworkOrder {
464
+ type: 0x18;
465
+ posX: number;
466
+ posY: number;
467
+ sizeX: number;
468
+ sizeY: number;
469
+ override: boolean;
470
+ variants: Bitmask16Variant[];
471
+ mask: Uint8Array;
472
+ }
473
+ /**
474
+ * 0x19 - Polyline: Renders a line connecting multiple points
475
+ * Uses Bresenham algorithm to draw between consecutive points.
476
+ * Binary format: [type(1), charCode(1), fgColor(1), bgColor(1), pointCount(1), x1, y1, x2, y2, ...]
477
+ */
478
+ interface PolylineOrder extends NetworkOrder {
479
+ type: 0x19;
480
+ charCode: number;
481
+ fgColorCode: number;
482
+ bgColorCode: number;
483
+ points: Array<{
484
+ x: number;
485
+ y: number;
486
+ }>;
487
+ }
488
+ /**
489
+ * 0x13 - Clear: Fills entire layer with single character and colors
490
+ */
491
+ interface ClearOrder extends NetworkOrder {
492
+ type: 0x13;
493
+ charCode: number;
494
+ bgColorCode: number;
495
+ fgColorCode: number;
496
+ }
497
+ /**
498
+ * 0x14 - FillChar: Fills layer with repeating character pattern
499
+ */
500
+ interface FillCharOrder extends NetworkOrder {
501
+ type: 0x14;
502
+ patternWidth: number;
503
+ patternHeight: number;
504
+ bgColorCode: number;
505
+ fgColorCode: number;
506
+ pattern: number[];
507
+ }
508
+ /**
509
+ * 0x15 - FillSprite: Fills layer with repeating unicolor sprite
510
+ */
511
+ interface FillSpriteOrder extends NetworkOrder {
512
+ type: 0x15;
513
+ spriteIndex: number;
514
+ bgColorCode: number;
515
+ fgColorCode: number;
516
+ }
517
+ /**
518
+ * 0x16 - FillSpriteMultiColor: Fills layer with repeating multicolor sprite
519
+ */
520
+ interface FillSpriteMultiColorOrder extends NetworkOrder {
521
+ type: 0x16;
522
+ spriteIndex: number;
523
+ }
524
+ /**
525
+ * 0x20 - TriggerSound: Triggers positional sound effect
526
+ */
527
+ interface TriggerSoundOrder extends NetworkOrder {
528
+ type: 0x20;
529
+ posX: number;
530
+ posY: number;
531
+ soundId: number;
532
+ loop: boolean;
533
+ }
534
+ /**
535
+ * 0x21 - TriggerGlobalSound: Triggers global (non-positional) sound
536
+ */
537
+ interface TriggerGlobalSoundOrder extends NetworkOrder {
538
+ type: 0x21;
539
+ soundId: number;
540
+ loop: boolean;
541
+ }
542
+ type AnyNetworkOrder = CharOrder | TextOrder | TextMultilineOrder | SubFrameOrder | SubFrameMultiColorOrder | FullFrameOrder | FullFrameMultiColorOrder | SpriteOrder | SpriteMultiColorOrder | ColorMapOrder | ShapeOrder | DotCloudOrder | DotCloudMultiColorOrder | BitmaskOrder | Bitmask4Order | Bitmask16Order | PolylineOrder | SpriteCloudOrder | SpriteCloudMultiColorOrder | SpriteCloudVariedOrder | SpriteCloudVariedMultiColorOrder | ClearOrder | FillCharOrder | FillSpriteOrder | FillSpriteMultiColorOrder | TriggerSoundOrder | TriggerGlobalSoundOrder;
543
+
544
+ /**
545
+ * UTSP Macro System Types
162
546
  *
163
- * @example
164
- * ```typescript
165
- * import { AudioOrderType } from '@utsp/core';
547
+ * Macros provide client-side feedback without server round-trips.
548
+ * Used for: UI interactions (hover, focus), particle effects, visual effects.
166
549
  *
167
- * const order = { type: AudioOrderType.PlaySound, soundId: 0, volume: 200 };
168
- * ```
550
+ * NOT for: synchronized gameplay, business logic, shared state.
169
551
  */
170
- declare enum AudioOrderType {
171
- /**
172
- * 0x01 - PlaySound: Play a sound with optional spatial position
173
- *
174
- * Parameters: soundId, instanceId, flags, volume?, pitch?, fadeIn?, posX?, posY?
175
- */
176
- PlaySound = 1,
177
- /**
178
- * 0x02 - PlayGlobalSound: Play a non-positional (global) sound
179
- *
180
- * Parameters: soundId, instanceId, flags, volume?, pitch?, fadeIn?
181
- */
182
- PlayGlobalSound = 2,
552
+ /**
553
+ * Macro order types for UpdatePacket
554
+ * These are processed separately from render orders (like AudioOrderType)
555
+ */
556
+ declare enum MacroOrderType {
183
557
  /**
184
- * 0x03 - StopSound: Stop a sound immediately
185
- *
186
- * Parameters: targetType, target (instanceId, soundId, or 'all')
558
+ * 0x01 - CreateInstance: Create a new macro instance
187
559
  */
188
- StopSound = 3,
560
+ CreateInstance = 1,
189
561
  /**
190
- * 0x04 - FadeOutSound: Fade out and stop a sound
191
- *
192
- * Parameters: targetType, target, duration
562
+ * 0x02 - UpdateInstance: Update an existing instance's params
193
563
  */
194
- FadeOutSound = 4,
564
+ UpdateInstance = 2,
195
565
  /**
196
- * 0x05 - PauseSound: Pause a playing sound
197
- *
198
- * Parameters: targetType, target
566
+ * 0x03 - RemoveInstance: Remove an instance
199
567
  */
200
- PauseSound = 5,
568
+ RemoveInstance = 3
569
+ }
570
+ /**
571
+ * Macro event types sent from client to server
572
+ * UI interactions that need server-side handling
573
+ */
574
+ declare enum MacroEventType {
201
575
  /**
202
- * 0x06 - ResumeSound: Resume a paused sound
203
- *
204
- * Parameters: targetType, target
576
+ * 0x01 - Click: Button/element was clicked
205
577
  */
206
- ResumeSound = 6,
578
+ Click = 1,
207
579
  /**
208
- * 0x07 - SetListenerPosition: Set the listener position for spatial audio
209
- *
210
- * Parameters: x, y (16-bit each)
580
+ * 0x02 - Change: Value changed (slider, checkbox, etc.)
211
581
  */
212
- SetListenerPosition = 7,
582
+ Change = 2,
213
583
  /**
214
- * 0x08 - ConfigureSpatial: Configure spatial audio parameters
215
- *
216
- * Parameters: maxDistance, referenceDistance, rolloffFactor, panSpread
584
+ * 0x03 - Submit: Text/form was submitted
217
585
  */
218
- ConfigureSpatial = 8,
586
+ Submit = 3,
219
587
  /**
220
- * 0x09 - SetSoundEffects: Set audio effects on a playing sound
221
- *
222
- * Parameters: instanceId, flags, lowpass?, highpass?, reverb?
588
+ * 0x04 - Select: Item was selected (dropdown, list, etc.)
223
589
  */
224
- SetSoundEffects = 9
590
+ Select = 4
225
591
  }
226
592
  /**
227
- * Target type for stop/pause/resume/fadeout commands
593
+ * Macro types - determines behavior and rendering
228
594
  */
229
- declare enum AudioTargetType {
230
- /** Target a specific instance by ID */
231
- InstanceId = 0,
232
- /** Target all instances of a sound by soundId */
233
- SoundId = 1,
234
- /** Target all sounds */
235
- All = 2
595
+ type MacroType = 'ui' | 'particle' | 'effect' | 'reveal' | 'line';
596
+ /**
597
+ * UI state names for UI macros
598
+ */
599
+ type UIState = 'normal' | 'hover' | 'active' | 'focused' | 'disabled';
600
+ /**
601
+ * Base interface for all macro templates (loaded via LoadMacro)
602
+ */
603
+ interface MacroTemplateBase {
604
+ /** Unique template identifier */
605
+ id: string;
606
+ /** Macro type */
607
+ type: MacroType;
608
+ /** Parameter definitions (name → type) */
609
+ params?: Record<string, 'string' | 'number' | 'boolean'>;
610
+ /** Sound triggers */
611
+ sounds?: {
612
+ hover?: string;
613
+ active?: string;
614
+ focus?: string;
615
+ };
236
616
  }
237
617
  /**
238
- * Type guard to check if a number is a valid AudioOrderType
618
+ * Render command for UI macros
619
+ * Coordinates are relative to instance position
239
620
  */
240
- declare function isValidAudioOrderType(type: number): type is AudioOrderType;
621
+ type RenderCommand = {
622
+ fillRect: [
623
+ number | string,
624
+ number | string,
625
+ number | string,
626
+ number | string,
627
+ string,
628
+ string,
629
+ string
630
+ ];
631
+ } | {
632
+ text: [number | string, number | string, string, string];
633
+ } | {
634
+ setCell: [number | string, number | string, string, string, string];
635
+ };
241
636
  /**
242
- * Get human-readable name for an AudioOrderType
637
+ * UI subtypes for specialized behavior
243
638
  */
244
- declare function getAudioOrderTypeName(type: AudioOrderType | number): string;
245
-
639
+ type UISubtype = 'generic' | 'button';
246
640
  /**
247
- * UTSP Audio Orders
248
- *
249
- * Binary-encoded audio commands included in UpdatePacket.
250
- * Processed by AudioProcessor on client, synchronized with render orders.
251
- *
252
- * Each order has a specific binary structure optimized for network transmission.
641
+ * Border style for button
253
642
  */
254
-
643
+ type ButtonBorderStyle = 'single' | 'double' | 'rounded' | 'none';
255
644
  /**
256
- * Base interface for all audio orders
645
+ * Button-specific configuration
257
646
  */
258
- interface AudioOrder {
259
- /** Audio order type identifier */
260
- type: AudioOrderType;
647
+ interface ButtonConfig {
648
+ /** Button label (can be dynamic $paramName) */
649
+ label: string;
650
+ /** Button width (can be dynamic) */
651
+ width: number | string;
652
+ /** Button height (can be dynamic, default: 3 for bordered, 1 for none) */
653
+ height?: number | string;
654
+ /** Border style */
655
+ border?: ButtonBorderStyle;
656
+ /** Sound ID to play on hover (optional) */
657
+ soundHover?: number;
658
+ /** Sound ID to play on click (optional) */
659
+ soundClick?: number;
660
+ /** Sound ID to play on release (optional) */
661
+ soundRelease?: number;
662
+ }
663
+ /**
664
+ * Button state colors
665
+ */
666
+ interface ButtonStateColors {
667
+ /** Foreground color for border/frame */
668
+ fg?: number | string;
669
+ /** Background color */
670
+ bg?: number | string;
671
+ /** Text/label foreground color */
672
+ textFg?: number | string;
673
+ /** Vertical offset (for "pressed" effect) */
674
+ offsetY?: number;
675
+ }
676
+ /**
677
+ * UI macro template - interactive elements (button, slider, checkbox, etc.)
678
+ */
679
+ interface UIMacroTemplate extends MacroTemplateBase {
680
+ type: 'ui';
681
+ /** UI subtype for specialized behavior (default: 'generic') */
682
+ subtype?: UISubtype;
683
+ /** Button-specific configuration (required when subtype: 'button') */
684
+ button?: ButtonConfig;
685
+ /** Base render commands (executed in order) - used for generic subtype */
686
+ base?: RenderCommand[];
687
+ /** State-specific variable overrides */
688
+ states: {
689
+ normal: Record<string, unknown> | ButtonStateColors;
690
+ hover?: Record<string, unknown> | ButtonStateColors;
691
+ active?: Record<string, unknown> | ButtonStateColors;
692
+ focused?: Record<string, unknown> | ButtonStateColors;
693
+ disabled?: Record<string, unknown> | ButtonStateColors;
694
+ };
695
+ }
696
+ /**
697
+ * Emitter configuration for particle macros
698
+ */
699
+ interface ParticleEmitter {
700
+ /** Spawn zone - where particles are created (relative coordinates) */
701
+ zone: {
702
+ x: number | string;
703
+ y: number | string;
704
+ width: number | string;
705
+ height: number | string;
706
+ };
707
+ /** Viewport zone - only particles inside this area are rendered (relative coordinates)
708
+ * If not specified, defaults to zone. Use this to let particles spawn outside
709
+ * the visible area (e.g., rain spawning above screen) */
710
+ viewport?: {
711
+ x: number | string;
712
+ y: number | string;
713
+ width: number | string;
714
+ height: number | string;
715
+ };
716
+ /** Particles per tick (continuous mode) */
717
+ rate?: number | string;
718
+ /** Spawn N particles at once (burst mode) */
719
+ burst?: number | string;
720
+ /** Only emit once then stop */
721
+ once?: boolean;
722
+ /** Max simultaneous particles */
723
+ limit?: number;
261
724
  }
262
725
  /**
263
- * Flags for PlaySound/PlayGlobalSound orders
264
- * Packed into a single byte to minimize bandwidth
726
+ * Particle configuration
265
727
  */
266
- declare enum PlaySoundFlags {
267
- /** Sound should loop */
268
- Loop = 1,
269
- /** Volume is specified (otherwise default 100%) */
270
- HasVolume = 2,
271
- /** Pitch is specified (otherwise default 1.0x) */
272
- HasPitch = 4,
273
- /** FadeIn duration is specified (otherwise instant) */
274
- HasFadeIn = 8,
275
- /** Position is specified (only for PlaySound, not PlayGlobalSound) */
276
- HasPosition = 16,
277
- /** Low-pass filter is specified */
278
- HasLowpass = 32,
279
- /** High-pass filter is specified */
280
- HasHighpass = 64,
281
- /** Reverb mix is specified */
282
- HasReverb = 128
728
+ interface ParticleConfig {
729
+ /** Character(s) to display - string, char code, or array */
730
+ char: string | number | (string | number)[];
731
+ /** Foreground color - palette index 0-255 */
732
+ fg: number | number[];
733
+ /** Background color - palette index 0-255 (optional, 255 = transparent) */
734
+ bg?: number | number[];
735
+ /** Lifetime in ticks (fixed or [min, max]) */
736
+ lifetime: number | [number, number];
737
+ /** Velocity (cells per tick) */
738
+ velocity: {
739
+ x: number | string;
740
+ y: number | string;
741
+ } | {
742
+ angle: number | [number, number];
743
+ speed: number | [number, number] | string;
744
+ };
745
+ /** Fade out at end of lifetime */
746
+ fade?: boolean;
283
747
  }
284
748
  /**
285
- * 0x01 - PlaySound: Play a sound with optional spatial position
286
- *
287
- * Binary structure (variable size, 4-15 bytes):
288
- * - type: 1 byte (0x01)
289
- * - soundId: 1 byte (0-255)
290
- * - instanceId: 2 bytes (big-endian, unique ID for this playback)
291
- * - flags: 1 byte (PlaySoundFlags bitfield)
292
- * - volume?: 1 byte (0-255, maps to 0.0-1.0) - if HasVolume
293
- * - pitch?: 1 byte (0-255, maps to 0.25x-4.0x, 128=1.0x) - if HasPitch
294
- * - fadeIn?: 1 byte (0-255, duration in 1/10 seconds, 0=instant) - if HasFadeIn
295
- * - posX?: 2 bytes (big-endian, 0-65535) - if HasPosition
296
- * - posY?: 2 bytes (big-endian, 0-65535) - if HasPosition
297
- * - lowpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasLowpass
298
- * - highpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasHighpass
299
- * - reverb?: 1 byte (0-255, / 255 = wet mix 0.0-1.0) - if HasReverb
749
+ * Particle macro template - visual effects (rain, explosion, snow, etc.)
300
750
  */
301
- interface PlaySoundOrder extends AudioOrder {
302
- type: AudioOrderType.PlaySound;
303
- /** Sound ID (0-255) */
304
- soundId: number;
305
- /** Unique instance ID for this playback */
306
- instanceId: number;
307
- /** Flags bitfield */
308
- flags: number;
309
- /** Volume (0-255, maps to 0.0-1.0). Present if HasVolume flag set */
310
- volume?: number;
311
- /** Pitch (0-255, 128=1.0x). Present if HasPitch flag set */
312
- pitch?: number;
313
- /** Fade in duration in 1/10 seconds. Present if HasFadeIn flag set */
314
- fadeIn?: number;
315
- /** X position (0-65535). Present if HasPosition flag set */
316
- posX?: number;
317
- /** Y position (0-65535). Present if HasPosition flag set */
318
- posY?: number;
319
- /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
320
- lowpass?: number;
321
- /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
322
- highpass?: number;
323
- /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
324
- reverb?: number;
751
+ interface ParticleMacroTemplate extends MacroTemplateBase {
752
+ type: 'particle';
753
+ /** Emitter configuration */
754
+ emitter: ParticleEmitter;
755
+ /** Particle configuration */
756
+ particle: ParticleConfig;
325
757
  }
326
758
  /**
327
- * 0x02 - PlayGlobalSound: Play a non-positional sound
328
- *
329
- * Binary structure (variable size, 4-10 bytes):
330
- * - type: 1 byte (0x02)
331
- * - soundId: 1 byte (0-255)
332
- * - instanceId: 2 bytes (big-endian)
333
- * - flags: 1 byte (PlaySoundFlags, but HasPosition is ignored)
334
- * - volume?: 1 byte - if HasVolume
335
- * - pitch?: 1 byte - if HasPitch
336
- * - fadeIn?: 1 byte - if HasFadeIn
337
- * - lowpass?: 1 byte - if HasLowpass
338
- * - highpass?: 1 byte - if HasHighpass
339
- * - reverb?: 1 byte - if HasReverb
759
+ * Transform configuration for effect macros
340
760
  */
341
- interface PlayGlobalSoundOrder extends AudioOrder {
342
- type: AudioOrderType.PlayGlobalSound;
343
- /** Sound ID (0-255) */
344
- soundId: number;
345
- /** Unique instance ID for this playback */
346
- instanceId: number;
347
- /** Flags bitfield (HasPosition ignored) */
348
- flags: number;
349
- /** Volume (0-255). Present if HasVolume flag set */
350
- volume?: number;
351
- /** Pitch (0-255, 128=1.0x). Present if HasPitch flag set */
352
- pitch?: number;
353
- /** Fade in duration in 1/10 seconds. Present if HasFadeIn flag set */
354
- fadeIn?: number;
355
- /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
356
- lowpass?: number;
357
- /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
358
- highpass?: number;
359
- /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
360
- reverb?: number;
761
+ interface EffectTransform {
762
+ /** Offset applied to rendering */
763
+ offset?: {
764
+ x: number | string | {
765
+ random: [number | string, number | string];
766
+ };
767
+ y: number | string | {
768
+ random: [number | string, number | string];
769
+ };
770
+ };
771
+ /** Effect duration in ms */
772
+ duration: number | string;
773
+ /** Decay over time */
774
+ decay?: boolean;
361
775
  }
362
776
  /**
363
- * 0x03 - StopSound: Stop a sound immediately
364
- *
365
- * Binary structure (3-4 bytes):
366
- * - type: 1 byte (0x03)
367
- * - targetType: 1 byte (AudioTargetType)
368
- * - target: 1-2 bytes (instanceId=2B, soundId=1B, all=0B)
777
+ * Effect macro template - temporary visual effects (shake, flash, fade, etc.)
369
778
  */
370
- interface StopSoundOrder extends AudioOrder {
371
- type: AudioOrderType.StopSound;
372
- /** Type of target */
373
- targetType: AudioTargetType;
374
- /** Target value (instanceId, soundId, or undefined for 'all') */
375
- target?: number;
779
+ interface EffectMacroTemplate extends MacroTemplateBase {
780
+ type: 'effect';
781
+ /** Transform to apply */
782
+ transform: EffectTransform;
376
783
  }
377
784
  /**
378
- * 0x04 - FadeOutSound: Fade out and stop a sound
379
- *
380
- * Binary structure (4-5 bytes):
381
- * - type: 1 byte (0x04)
382
- * - targetType: 1 byte
383
- * - duration: 1 byte (1/10 seconds, 0-25.5s)
384
- * - target: 1-2 bytes
785
+ * Reveal patterns - how content is progressively shown/hidden
385
786
  */
386
- interface FadeOutSoundOrder extends AudioOrder {
387
- type: AudioOrderType.FadeOutSound;
388
- /** Type of target */
389
- targetType: AudioTargetType;
390
- /** Fade duration in 1/10 seconds (0-255 = 0-25.5 seconds) */
391
- duration: number;
392
- /** Target value */
393
- target?: number;
394
- }
787
+ type RevealPattern = 'typewriter' | 'typewriter-rev' | 'ltr' | 'rtl' | 'ttb' | 'btt' | 'random' | 'center-out' | 'spiral';
395
788
  /**
396
- * 0x05 - PauseSound: Pause a playing sound
397
- *
398
- * Binary structure (2-4 bytes):
399
- * - type: 1 byte (0x05)
400
- * - targetType: 1 byte
401
- * - target: 0-2 bytes
789
+ * Reveal direction - show or hide
402
790
  */
403
- interface PauseSoundOrder extends AudioOrder {
404
- type: AudioOrderType.PauseSound;
405
- /** Type of target */
406
- targetType: AudioTargetType;
407
- /** Target value */
408
- target?: number;
791
+ type RevealDirection = 'reveal' | 'hide';
792
+ /**
793
+ * Cursor configuration for reveal macros
794
+ */
795
+ interface RevealCursor {
796
+ /** Cursor character (e.g., "▌", "_", "█") or char code */
797
+ char: string | number;
798
+ /** Cursor foreground color (palette index) */
799
+ fg?: number;
800
+ /** Cursor background color (palette index) */
801
+ bg?: number;
802
+ /** Blink cursor */
803
+ blink?: boolean;
804
+ /** Blink rate in ticks (default: 15) */
805
+ blinkRate?: number;
409
806
  }
410
807
  /**
411
- * 0x06 - ResumeSound: Resume a paused sound
412
- *
413
- * Binary structure (2-4 bytes):
414
- * - type: 1 byte (0x06)
415
- * - targetType: 1 byte
416
- * - target: 0-2 bytes
808
+ * Pause configuration for reveal macros
417
809
  */
418
- interface ResumeSoundOrder extends AudioOrder {
419
- type: AudioOrderType.ResumeSound;
420
- /** Type of target */
421
- targetType: AudioTargetType;
422
- /** Target value */
423
- target?: number;
810
+ interface RevealPause {
811
+ /** Characters that trigger a pause (e.g., [".", "!", "?"]) */
812
+ chars: string[];
813
+ /** Pause duration in ticks */
814
+ duration: number;
424
815
  }
425
816
  /**
426
- * 0x07 - SetListenerPosition: Set listener position for spatial audio
427
- *
428
- * Binary structure (5 bytes):
429
- * - type: 1 byte (0x07)
430
- * - x: 2 bytes (big-endian, 0-65535)
431
- * - y: 2 bytes (big-endian, 0-65535)
817
+ * Content type for reveal macros
432
818
  */
433
- interface SetListenerPositionOrder extends AudioOrder {
434
- type: AudioOrderType.SetListenerPosition;
435
- /** X position (0-65535) */
819
+ type RevealContentType = 'text' | 'sprite' | 'cells' | 'fill';
820
+ /**
821
+ * Single cell definition for 'cells' content type
822
+ */
823
+ interface RevealCellDef {
824
+ /** Character to display */
825
+ char: string | number;
826
+ /** Foreground color (palette index) */
827
+ fg: number;
828
+ /** Background color (palette index) */
829
+ bg: number;
830
+ /** X position relative to instance */
436
831
  x: number;
437
- /** Y position (0-65535) */
832
+ /** Y position relative to instance */
438
833
  y: number;
439
834
  }
440
835
  /**
441
- * 0x08 - ConfigureSpatial: Configure spatial audio parameters
442
- *
443
- * Binary structure (5 bytes):
444
- * - type: 1 byte (0x08)
445
- * - maxDistance: 1 byte (0-255, scaled appropriately)
446
- * - referenceDistance: 1 byte (0-255)
447
- * - rolloffFactor: 1 byte (0-255, maps to 0.0-2.55)
448
- * - panSpread: 1 byte (0-255, maps to 0.0-1.0)
836
+ * Content to reveal - discriminated union with explicit type
837
+ * All string values can be dynamic ($paramName references)
449
838
  */
450
- interface ConfigureSpatialOrder extends AudioOrder {
451
- type: AudioOrderType.ConfigureSpatial;
452
- /** Maximum audible distance (encoded, 0-255) */
453
- maxDistance: number;
454
- /** Reference distance for full volume (encoded, 0-255) */
455
- referenceDistance: number;
456
- /** Rolloff factor (0-255, maps to 0.0-2.55) */
457
- rolloffFactor: number;
458
- /** Pan spread factor (0-255, maps to 0.0-1.0) */
459
- panSpread: number;
460
- }
839
+ type RevealContent = {
840
+ type: 'text';
841
+ /** Text to reveal (multiline with \n) */
842
+ text: string;
843
+ /** Foreground color (palette index, can be dynamic) */
844
+ fg?: number | string;
845
+ /** Background color (palette index, can be dynamic) */
846
+ bg?: number | string;
847
+ } | {
848
+ type: 'sprite';
849
+ /** Sprite ID (0-255) or dynamic reference ($paramName) */
850
+ sprite: number | string;
851
+ /** For unicolor sprites: foreground color (palette index, can be dynamic) */
852
+ fg?: number | string;
853
+ /** For unicolor sprites: background color (palette index, can be dynamic) */
854
+ bg?: number | string;
855
+ /** Use multicolor sprite instead of unicolor (default: true, tries multicolor first) */
856
+ multicolor?: boolean;
857
+ } | {
858
+ type: 'cells';
859
+ /** Array of cell definitions */
860
+ cells: RevealCellDef[];
861
+ } | {
862
+ type: 'fill';
863
+ /** Character to fill with */
864
+ char: string | number;
865
+ /** Foreground color (palette index, can be dynamic) */
866
+ fg: number | string;
867
+ /** Background color (palette index, can be dynamic) */
868
+ bg: number | string;
869
+ /** Width of fill area (can be dynamic) */
870
+ width: number | string;
871
+ /** Height of fill area (can be dynamic) */
872
+ height: number | string;
873
+ };
461
874
  /**
462
- * Flags for SetSoundEffects order
875
+ * Reveal macro template - progressive text/sprite display
463
876
  */
464
- declare enum SoundEffectsFlags {
465
- /** Low-pass filter is specified */
466
- HasLowpass = 1,
467
- /** High-pass filter is specified */
468
- HasHighpass = 2,
469
- /** Reverb mix is specified */
470
- HasReverb = 4
877
+ interface RevealMacroTemplate extends MacroTemplateBase {
878
+ type: 'reveal';
879
+ /** Content to reveal (text or sprite) */
880
+ content: RevealContent;
881
+ /** Reveal pattern */
882
+ pattern: RevealPattern;
883
+ /** Direction: 'reveal' to show, 'hide' to hide */
884
+ direction: RevealDirection;
885
+ /** Speed in cells per tick */
886
+ speed: number;
887
+ /** Initial delay in ticks before starting */
888
+ delay?: number;
889
+ /** Cursor configuration */
890
+ cursor?: RevealCursor;
891
+ /** Pause on specific characters */
892
+ pauseOn?: RevealPause;
471
893
  }
472
894
  /**
473
- * 0x09 - SetSoundEffects: Update audio effects on a playing sound
474
- *
475
- * Binary structure (variable size, 4-7 bytes):
476
- * - type: 1 byte (0x09)
477
- * - instanceId: 2 bytes (big-endian)
478
- * - flags: 1 byte (SoundEffectsFlags bitfield)
479
- * - lowpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasLowpass
480
- * - highpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasHighpass
481
- * - reverb?: 1 byte (0-255, / 255 = wet mix 0.0-1.0) - if HasReverb
895
+ * Line macro template - dynamic line renderer with point history
896
+ * The server sends only new points, the client maintains the full path
482
897
  */
483
- interface SetSoundEffectsOrder extends AudioOrder {
484
- type: AudioOrderType.SetSoundEffects;
485
- /** Target instance ID */
486
- instanceId: number;
487
- /** Flags bitfield */
488
- flags: number;
489
- /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
490
- lowpass?: number;
491
- /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
492
- highpass?: number;
493
- /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
494
- reverb?: number;
898
+ interface LineMacroTemplate extends MacroTemplateBase {
899
+ type: 'line';
900
+ /** Maximum number of points to keep in history (default: 100) */
901
+ maxPoints?: number;
902
+ /** Character to draw the line with (default: '*') */
903
+ char: string | number;
904
+ /** Foreground color (palette index) */
905
+ fg: number;
906
+ /** Background color (palette index, default: 255 = transparent) */
907
+ bg?: number;
908
+ /** Fade out older points (reduces alpha/color intensity) */
909
+ fadeOut?: boolean;
910
+ /** Number of points to fade (from tail), default: all points if fadeOut is true */
911
+ fadeLength?: number;
912
+ /** Close the path (connect last point to first) */
913
+ closed?: boolean;
495
914
  }
496
915
  /**
497
- * Union of all audio order types
916
+ * Any macro template type
498
917
  */
499
- type AnyAudioOrder = PlaySoundOrder | PlayGlobalSoundOrder | StopSoundOrder | FadeOutSoundOrder | PauseSoundOrder | ResumeSoundOrder | SetListenerPositionOrder | ConfigureSpatialOrder | SetSoundEffectsOrder;
500
-
918
+ type MacroTemplate = UIMacroTemplate | ParticleMacroTemplate | EffectMacroTemplate | RevealMacroTemplate | LineMacroTemplate;
501
919
  /**
502
- * Network representation of a display
503
- * Layers are NO LONGER under displays - they are at User level
920
+ * Base interface for macro orders
504
921
  */
505
- interface NetworkDisplay {
506
- /** Display ID (0-255) */
507
- id: number;
508
- /** Origin X position in virtual world (0-65535) */
509
- originX: number;
510
- /** Origin Y position in virtual world (0-65535) */
511
- originY: number;
512
- /** Display width in cells (1-256) */
513
- sizeX: number;
514
- /** Display height in cells (1-256) */
515
- sizeY: number;
922
+ interface MacroOrder {
923
+ type: MacroOrderType;
516
924
  }
517
-
518
925
  /**
519
- * Base interface for all network orders
926
+ * CreateInstance order - creates a new macro instance
520
927
  */
521
- interface NetworkOrder {
522
- type: number;
928
+ interface CreateInstanceOrder extends MacroOrder {
929
+ type: MacroOrderType.CreateInstance;
930
+ /** Instance ID (0-255) */
931
+ instanceId: number;
932
+ /** Macro template ID (0-255) */
933
+ macroId: number;
934
+ /** Layer ID (0-255) */
935
+ layerId: number;
936
+ /** Position X (cells) */
937
+ x: number;
938
+ /** Position Y (cells) */
939
+ y: number;
940
+ /** Tab index for keyboard navigation (0 = not focusable) */
941
+ tabIndex: number;
942
+ /** Instance parameters (JSON) */
943
+ params: Record<string, unknown>;
523
944
  }
524
945
  /**
525
- * 0x01 - Char: Renders a single character at a specific position
946
+ * UpdateInstance order - updates an existing instance's params
526
947
  */
527
- interface CharOrder extends NetworkOrder {
528
- type: 0x01;
529
- posX: number;
530
- posY: number;
531
- charCode: number;
532
- bgColorCode: number;
533
- fgColorCode: number;
948
+ interface UpdateInstanceOrder extends MacroOrder {
949
+ type: MacroOrderType.UpdateInstance;
950
+ /** Instance ID (0-255) */
951
+ instanceId: number;
952
+ /** Updated parameters (JSON) */
953
+ params: Record<string, unknown>;
534
954
  }
535
955
  /**
536
- * 0x02 - Text: Renders a string of characters with uniform colors
956
+ * RemoveInstance order - removes an instance
537
957
  */
538
- interface TextOrder extends NetworkOrder {
539
- type: 0x02;
540
- posX: number;
541
- posY: number;
542
- text: string;
543
- bgColorCode: number;
544
- fgColorCode: number;
958
+ interface RemoveInstanceOrder extends MacroOrder {
959
+ type: MacroOrderType.RemoveInstance;
960
+ /** Instance ID (0-255) */
961
+ instanceId: number;
962
+ }
963
+ /**
964
+ * Any macro order type
965
+ */
966
+ type AnyMacroOrder = CreateInstanceOrder | UpdateInstanceOrder | RemoveInstanceOrder;
967
+ /**
968
+ * Base interface for macro events
969
+ */
970
+ interface MacroEvent {
971
+ type: MacroEventType;
972
+ /** Instance ID (0-255) */
973
+ instanceId: number;
545
974
  }
546
975
  /**
547
- * 0x17 - TextMultiline: Renders multiple lines of text (\n for line breaks)
976
+ * Click event - element was clicked
548
977
  */
549
- interface TextMultilineOrder extends NetworkOrder {
550
- type: 0x17;
551
- posX: number;
552
- posY: number;
553
- text: string;
554
- bgColorCode: number;
555
- fgColorCode: number;
978
+ interface ClickEvent extends MacroEvent {
979
+ type: MacroEventType.Click;
556
980
  }
557
981
  /**
558
- * 0x03 - SubFrame: Renders a rectangular region with uniform colors
982
+ * Change event - value changed
559
983
  */
560
- interface SubFrameOrder extends NetworkOrder {
561
- type: 0x03;
562
- posX: number;
563
- posY: number;
564
- sizeX: number;
565
- sizeY: number;
566
- bgColorCode: number;
567
- fgColorCode: number;
568
- frame: number[];
984
+ interface ChangeEvent extends MacroEvent {
985
+ type: MacroEventType.Change;
986
+ /** New value (number or boolean) */
987
+ value: number | boolean;
569
988
  }
570
989
  /**
571
- * 0x04 - SubFrameMultiColor: Rectangular region with per-cell colors
990
+ * Submit event - text was submitted
572
991
  */
573
- interface SubFrameMultiColorOrder extends NetworkOrder {
574
- type: 0x04;
575
- posX: number;
576
- posY: number;
577
- sizeX: number;
578
- sizeY: number;
579
- frame: Array<{
580
- charCode: number;
581
- bgColorCode: number;
582
- fgColorCode: number;
583
- }>;
992
+ interface SubmitEvent extends MacroEvent {
993
+ type: MacroEventType.Submit;
994
+ /** Submitted text */
995
+ text: string;
584
996
  }
585
997
  /**
586
- * 0x05 - FullFrame: Renders entire screen with uniform colors
998
+ * Select event - item was selected
587
999
  */
588
- interface FullFrameOrder extends NetworkOrder {
589
- type: 0x05;
590
- bgColorCode: number;
591
- fgColorCode: number;
592
- frame: number[];
1000
+ interface SelectEvent extends MacroEvent {
1001
+ type: MacroEventType.Select;
1002
+ /** Selected index */
1003
+ index: number;
593
1004
  }
594
1005
  /**
595
- * 0x06 - FullFrameMultiColor: Entire screen with per-cell colors
1006
+ * Any macro event type
596
1007
  */
597
- interface FullFrameMultiColorOrder extends NetworkOrder {
598
- type: 0x06;
599
- frame: Array<{
600
- charCode: number;
601
- bgColorCode: number;
602
- fgColorCode: number;
603
- }>;
604
- }
1008
+ type AnyMacroEvent = ClickEvent | ChangeEvent | SubmitEvent | SelectEvent;
605
1009
  /**
606
- * 0x07 - Sprite: Renders a preloaded unicolor sprite
1010
+ * Check if a number is a valid MacroOrderType
607
1011
  */
608
- interface SpriteOrder extends NetworkOrder {
609
- type: 0x07;
610
- posX: number;
611
- posY: number;
612
- spriteIndex: number;
613
- bgColorCode: number;
1012
+ declare function isValidMacroOrderType(type: number): type is MacroOrderType;
1013
+ /**
1014
+ * Check if a number is a valid MacroEventType
1015
+ */
1016
+ declare function isValidMacroEventType(type: number): type is MacroEventType;
1017
+ /**
1018
+ * Get human-readable name for a MacroOrderType
1019
+ */
1020
+ declare function getMacroOrderTypeName(type: MacroOrderType): string;
1021
+ /**
1022
+ * Get human-readable name for a MacroEventType
1023
+ */
1024
+ declare function getMacroEventTypeName(type: MacroEventType): string;
1025
+
1026
+ interface Cell {
1027
+ charCode: number;
614
1028
  fgColorCode: number;
1029
+ bgColorCode: number;
615
1030
  }
616
1031
  /**
617
- * 0x08 - SpriteMultiColor: Renders a preloaded multicolor sprite
1032
+ * Optimized buffer for 65,536 cells with TypedArray
1033
+ * Interleaved structure: [char0, fg0, bg0, char1, fg1, bg1, ...]
1034
+ *
1035
+ * Performance:
1036
+ * - clear(): ~5-10μs (vs 826μs with object array)
1037
+ * - Better cache locality
1038
+ * - Less GC pressure
618
1039
  */
619
- interface SpriteMultiColorOrder extends NetworkOrder {
620
- type: 0x08;
621
- posX: number;
622
- posY: number;
623
- spriteIndex: number;
1040
+ declare class CellBuffer {
1041
+ private data;
1042
+ private size;
1043
+ constructor(size?: number);
1044
+ /**
1045
+ * Optimized clear: fills with "skip" values
1046
+ * - charCode = 0 (no character)
1047
+ * - fgColorCode = 255 (COLOR_SKIP = transparent)
1048
+ * - bgColorCode = 255 (COLOR_SKIP = transparent)
1049
+ * Performance: ~5-10μs (native TypedArray)
1050
+ */
1051
+ clear(): void;
1052
+ /**
1053
+ * Optimized clear with uniform color
1054
+ * Faster than clear() when clearing to specific char/colors
1055
+ * Useful for background layers with uniform color
1056
+ *
1057
+ * Performance: ~2-5μs (loop unrolling friendly)
1058
+ *
1059
+ * @param charCode - Character to fill (e.g., 0x20 for space)
1060
+ * @param fgColorCode - Foreground color (0-255)
1061
+ * @param bgColorCode - Background color (0-255)
1062
+ *
1063
+ * @example
1064
+ * // Clear to black background
1065
+ * buffer.clearWithColor(0x20, 15, 0);
1066
+ */
1067
+ clearWithColor(charCode: number, fgColorCode: number, bgColorCode: number): void;
1068
+ /**
1069
+ * Sets a cell at given index
1070
+ */
1071
+ set(index: number, charCode: number, fgColorCode: number, bgColorCode: number): void;
1072
+ /**
1073
+ * Optimized batch fill for uniform char+colors (DotCloud, SpriteCloud)
1074
+ * Writes only characters at multiple positions with uniform fg/bg colors
1075
+ *
1076
+ * Performance: 2-3x faster than individual set() calls for uniform colors
1077
+ * Reduces memory writes by 66% (writes chars only, then batch-fills colors)
1078
+ *
1079
+ * @param indices - Array of cell indices to fill
1080
+ * @param charCode - Character to write at all positions
1081
+ * @param fgColorCode - Uniform foreground color
1082
+ * @param bgColorCode - Uniform background color
1083
+ *
1084
+ * @example
1085
+ * // Rain drops (1,500 positions with same color)
1086
+ * const indices = raindrops.map(d => d.y * width + d.x);
1087
+ * buffer.fillCharsUniform(indices, 58, 20, 255); // ':' char, cyan, transparent
1088
+ */
1089
+ fillCharsUniform(indices: number[], charCode: number, fgColorCode: number, bgColorCode: number): void;
1090
+ /**
1091
+ * Gets a cell at given index
1092
+ * Returns a Cell object for compatibility
1093
+ */
1094
+ get(index: number): Cell;
1095
+ /**
1096
+ * Sets only character at given index (keeps existing colors)
1097
+ * Useful for operations that modify chars but preserve colors
1098
+ *
1099
+ * @param index - Cell index
1100
+ * @param charCode - Character code to write
1101
+ */
1102
+ setCharOnly(index: number, charCode: number): void;
1103
+ /**
1104
+ * Sets only colors at given index (keeps existing char)
1105
+ * Useful for ColorMapOrder (updates colors, preserves chars)
1106
+ *
1107
+ * @param index - Cell index
1108
+ * @param fgColorCode - Foreground color
1109
+ * @param bgColorCode - Background color
1110
+ */
1111
+ setColorsOnly(index: number, fgColorCode: number, bgColorCode: number): void;
1112
+ /**
1113
+ * Direct value access (faster than get())
1114
+ * Note: These are called in hot loops, keep as inline as possible
1115
+ */
1116
+ getCharCode(index: number): number;
1117
+ getFgColorCode(index: number): number;
1118
+ getBgColorCode(index: number): number;
1119
+ /**
1120
+ * Direct TypedArray access for batch operations
1121
+ */
1122
+ getRawData(): Uint8Array;
1123
+ /**
1124
+ * Buffer size (number of cells)
1125
+ */
1126
+ getSize(): number;
624
1127
  }
625
1128
  /**
626
- * 0x09 - ColorMap: Applies colors to a region without changing characters
1129
+ * Optimized buffer to store only charcodes (unicolor sprites)
1130
+ * Simple structure: [char0, char1, char2, ...]
1131
+ *
1132
+ * Performance:
1133
+ * - 3x less memory than CellBuffer (1 byte vs 3 bytes per cell)
1134
+ * - Ideal for unicolor sprites where colors are defined at render time
1135
+ * - Cache-friendly with TypedArray
627
1136
  */
628
- interface ColorMapOrder extends NetworkOrder {
629
- type: 0x09;
630
- posX: number;
631
- posY: number;
1137
+ declare class CharCodeBuffer {
1138
+ private data;
1139
+ private size;
1140
+ constructor(size: number);
1141
+ /**
1142
+ * Optimized clear: fills with zeros (no character)
1143
+ */
1144
+ clear(): void;
1145
+ /**
1146
+ * Sets a charcode at given index
1147
+ */
1148
+ set(index: number, charCode: number): void;
1149
+ /**
1150
+ * Gets a charcode at given index
1151
+ */
1152
+ get(index: number): number;
1153
+ /**
1154
+ * Direct TypedArray access for batch operations
1155
+ */
1156
+ getRawData(): Uint8Array;
1157
+ /**
1158
+ * Buffer size (number of cells)
1159
+ */
1160
+ getSize(): number;
1161
+ }
1162
+
1163
+ /**
1164
+ * Unicolor sprite - Stores only charcodes
1165
+ * Colors (fg/bg) are defined at render time via SpriteOrder
1166
+ *
1167
+ * Used with LoadType.Sprite (0x02) and SpriteOrder (0x07)
1168
+ */
1169
+ interface UnicolorSprite {
1170
+ id: number;
632
1171
  sizeX: number;
633
1172
  sizeY: number;
634
- colorData: Array<{
635
- bgColorCode: number;
636
- fgColorCode: number;
637
- }>;
1173
+ data: CharCodeBuffer;
638
1174
  }
639
1175
  /**
640
- * 0x0A - Shape: Renders geometric shapes
1176
+ * Multicolor sprite - Stores charcodes + fg/bg colors
1177
+ * Each cell contains its own color set
1178
+ *
1179
+ * Used with LoadType.MulticolorSprite (0x03) and SpriteMultiColorOrder (0x08)
641
1180
  */
642
- interface ShapeOrder extends NetworkOrder {
643
- type: 0x0a;
644
- shapeType: ShapeType;
645
- shapeData: ShapeData;
646
- }
647
- declare enum ShapeType {
648
- Rectangle = 1,
649
- Circle = 2,
650
- Line = 3,
651
- Ellipse = 4,
652
- Triangle = 5
653
- }
654
- type ShapeData = RectangleShape | CircleShape | LineShape | EllipseShape | TriangleShape;
655
- interface RectangleShape {
656
- posX: number;
657
- posY: number;
658
- width: number;
659
- height: number;
660
- filled: boolean;
661
- charCode: number;
662
- bgColorCode: number;
663
- fgColorCode: number;
664
- }
665
- interface CircleShape {
666
- centerX: number;
667
- centerY: number;
668
- radius: number;
669
- filled: boolean;
670
- charCode: number;
671
- bgColorCode: number;
672
- fgColorCode: number;
1181
+ interface MulticolorSprite {
1182
+ id: number;
1183
+ sizeX: number;
1184
+ sizeY: number;
1185
+ data: CellBuffer;
673
1186
  }
674
- interface LineShape {
675
- x1: number;
676
- y1: number;
677
- x2: number;
678
- y2: number;
679
- charCode: number;
680
- bgColorCode: number;
681
- fgColorCode: number;
1187
+
1188
+ /**
1189
+ * UTSP Macro Load Packet
1190
+ *
1191
+ * LoadType 0x07 - Macro template loading
1192
+ * JSON-based (not binary) since it's only loaded once at init time.
1193
+ */
1194
+
1195
+ /**
1196
+ * Macro Load (LoadType 0x07)
1197
+ * Loads a macro template for client-side instantiation
1198
+ */
1199
+ interface MacroLoad {
1200
+ loadType: 0x07;
1201
+ /** Macro ID (0-255) - numeric ID for network transmission */
1202
+ macroId: number;
1203
+ /** Macro template definition (JSON) */
1204
+ template: MacroTemplate;
682
1205
  }
683
- interface EllipseShape {
684
- centerX: number;
685
- centerY: number;
686
- radiusX: number;
687
- radiusY: number;
688
- filled: boolean;
689
- charCode: number;
690
- bgColorCode: number;
691
- fgColorCode: number;
1206
+
1207
+ /**
1208
+ * UTSP Load Packet Types
1209
+ * Based on UTSP Protocol v0.1 - Section 4: Load Section
1210
+ */
1211
+ /**
1212
+ * LoadType enumeration
1213
+ */
1214
+ declare enum LoadType {
1215
+ ColorPalette = 1,
1216
+ Sprite = 2,
1217
+ MulticolorSprite = 3,
1218
+ BitmapFont = 4,// Formerly "Charset" - pixel-based fonts
1219
+ Sound = 5,
1220
+ WebFont = 6,// CSS-based fonts for browser rendering
1221
+ Macro = 7
692
1222
  }
693
- interface TriangleShape {
694
- x1: number;
695
- y1: number;
696
- x2: number;
697
- y2: number;
698
- x3: number;
699
- y3: number;
700
- filled: boolean;
701
- charCode: number;
702
- bgColorCode: number;
703
- fgColorCode: number;
1223
+ /**
1224
+ * Color definition with RGBA+E values
1225
+ */
1226
+ interface Color {
1227
+ colorId: number;
1228
+ r: number;
1229
+ g: number;
1230
+ b: number;
1231
+ a: number;
1232
+ e?: number;
704
1233
  }
705
1234
  /**
706
- * 0x0B - DotCloud: Same character at multiple positions (up to 65535)
1235
+ * Color Palette Load (LoadType 0x01)
1236
+ * Loads a palette of RGBA+E colors
707
1237
  */
708
- interface DotCloudOrder extends NetworkOrder {
709
- type: 0x0b;
710
- charCode: number;
711
- bgColorCode: number;
712
- fgColorCode: number;
713
- positions: Array<{
714
- posX: number;
715
- posY: number;
716
- }>;
1238
+ interface ColorPaletteLoad {
1239
+ loadType: LoadType.ColorPalette;
1240
+ colors: Color[];
717
1241
  }
718
1242
  /**
719
- * 0x0C - DotCloudMultiColor: Different characters at multiple positions
1243
+ * Simple Sprite Load (LoadType 0x02)
1244
+ * Each cell contains only a character code
720
1245
  */
721
- interface DotCloudMultiColorOrder extends NetworkOrder {
722
- type: 0x0c;
723
- dots: Array<{
724
- charCode: number;
725
- bgColorCode: number;
726
- fgColorCode: number;
727
- posX: number;
728
- posY: number;
1246
+ interface SpriteLoad {
1247
+ loadType: LoadType.Sprite;
1248
+ sprites: Array<{
1249
+ spriteId: number;
1250
+ sizeX: number;
1251
+ sizeY: number;
1252
+ data: number[];
729
1253
  }>;
730
1254
  }
731
1255
  /**
732
- * 0x0D - SpriteCloud: Same unicolor sprite at multiple positions
1256
+ * Cell in a multicolor sprite
733
1257
  */
734
- interface SpriteCloudOrder extends NetworkOrder {
735
- type: 0x0d;
736
- spriteIndex: number;
737
- bgColorCode: number;
738
- fgColorCode: number;
739
- positions: Array<{
740
- posX: number;
741
- posY: number;
742
- }>;
1258
+ interface MulticolorCell {
1259
+ charCode: number;
1260
+ fgColorId: number;
1261
+ bgColorId: number;
743
1262
  }
744
1263
  /**
745
- * 0x0E - SpriteCloudMultiColor: Same multicolor sprite at multiple positions
1264
+ * Multicolor Sprite Load (LoadType 0x03)
1265
+ * Each cell contains charcode + foreground color + background color
746
1266
  */
747
- interface SpriteCloudMultiColorOrder extends NetworkOrder {
748
- type: 0x0e;
749
- spriteIndex: number;
750
- positions: Array<{
751
- posX: number;
752
- posY: number;
1267
+ interface MulticolorSpriteLoad {
1268
+ loadType: LoadType.MulticolorSprite;
1269
+ sprites: Array<{
1270
+ spriteId: number;
1271
+ sizeX: number;
1272
+ sizeY: number;
1273
+ data: MulticolorCell[];
753
1274
  }>;
754
1275
  }
755
1276
  /**
756
- * 0x0F - SpriteCloudVaried: Different unicolor sprites at multiple positions
1277
+ * BitmapFont Load (LoadType 0x04)
1278
+ * Custom character definitions (monochrome bitmaps)
1279
+ * Formerly known as "Charset" - renamed to BitmapFont for clarity
757
1280
  */
758
- interface SpriteCloudVariedOrder extends NetworkOrder {
759
- type: 0x0f;
760
- sprites: Array<{
761
- spriteIndex: number;
762
- bgColorCode: number;
763
- fgColorCode: number;
764
- posX: number;
765
- posY: number;
1281
+ interface BitmapFontLoad {
1282
+ loadType: LoadType.BitmapFont;
1283
+ fontId: number;
1284
+ width: number;
1285
+ height: number;
1286
+ cellWidth: number;
1287
+ cellHeight: number;
1288
+ characters: Array<{
1289
+ charCode: number;
1290
+ bitmap: Uint8Array;
766
1291
  }>;
767
1292
  }
768
1293
  /**
769
- * 0x10 - SpriteCloudVariedMultiColor: Different multicolor sprites at multiple positions
1294
+ * WebFont Load (LoadType 0x06)
1295
+ * CSS-based font definitions for browser rendering
1296
+ * Note: The default font is "Courier New" (monospace), but users can specify non-monospace fonts
770
1297
  */
771
- interface SpriteCloudVariedMultiColorOrder extends NetworkOrder {
772
- type: 0x10;
773
- sprites: Array<{
774
- spriteIndex: number;
775
- posX: number;
776
- posY: number;
1298
+ interface WebFontLoad {
1299
+ loadType: LoadType.WebFont;
1300
+ fontId: number;
1301
+ fontFamily: string;
1302
+ fontSize: number;
1303
+ offsetX?: number;
1304
+ offsetY?: number;
1305
+ charSpacing?: number;
1306
+ lineHeight?: number;
1307
+ fontWeight?: string;
1308
+ fontStyle?: string;
1309
+ }
1310
+ /**
1311
+ * Sound Load (LoadType 0x05)
1312
+ * MIDI sound data for audio playback
1313
+ */
1314
+ interface SoundLoad {
1315
+ loadType: LoadType.Sound;
1316
+ sounds: Array<{
1317
+ soundId: number;
1318
+ midiData: Uint8Array;
777
1319
  }>;
778
1320
  }
1321
+
779
1322
  /**
780
- * 0x11 - Bitmask: Renders a rectangular region with bitpacked presence mask
781
- * Each bit represents presence (1) or absence (0) of the character at that position
782
- * Ideal for: ore veins, destructible terrain, collision maps, fog of war, etc.
1323
+ * Union type for all load types
783
1324
  */
784
- interface BitmaskOrder extends NetworkOrder {
785
- type: 0x11;
786
- posX: number;
787
- posY: number;
788
- sizeX: number;
789
- sizeY: number;
790
- charCode: number;
791
- bgColorCode: number;
792
- fgColorCode: number;
793
- override: boolean;
794
- mask: Uint8Array;
1325
+ type AnyLoad = ColorPaletteLoad | SpriteLoad | MulticolorSpriteLoad | BitmapFontLoad | SoundLoad | WebFontLoad | MacroLoad;
1326
+
1327
+ /**
1328
+ * Central registry to manage unicolor and multicolor sprites
1329
+ *
1330
+ * Sprites are loaded via LoadPacket and referenced by their ID
1331
+ * in Orders (SpriteOrder, SpriteMultiColorOrder, etc.)
1332
+ *
1333
+ * Architecture:
1334
+ * - Two separate registries for unicolor and multicolor
1335
+ * - No possible collision between the two types
1336
+ * - Memory optimization with CharCodeBuffer for unicolor
1337
+ */
1338
+ declare class SpriteRegistry {
1339
+ private unicolorSprites;
1340
+ private multicolorSprites;
1341
+ /**
1342
+ * Loads unicolor sprites from a LoadPacket
1343
+ * Converts network format to optimized internal format
1344
+ */
1345
+ loadUnicolorSprites(loadData: SpriteLoad): void;
1346
+ /**
1347
+ * Loads multicolor sprites from a LoadPacket
1348
+ * Converts network format to optimized internal format
1349
+ */
1350
+ loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
1351
+ /**
1352
+ * Retrieves a unicolor sprite by its ID
1353
+ */
1354
+ getUnicolorSprite(id: number): UnicolorSprite | undefined;
1355
+ /**
1356
+ * Retrieves a multicolor sprite by its ID
1357
+ */
1358
+ getMulticolorSprite(id: number): MulticolorSprite | undefined;
1359
+ /**
1360
+ * Checks if a unicolor sprite exists
1361
+ */
1362
+ hasUnicolorSprite(id: number): boolean;
1363
+ /**
1364
+ * Checks if a multicolor sprite exists
1365
+ */
1366
+ hasMulticolorSprite(id: number): boolean;
1367
+ /**
1368
+ * Removes a unicolor sprite
1369
+ */
1370
+ unloadUnicolorSprite(id: number): boolean;
1371
+ /**
1372
+ * Removes a multicolor sprite
1373
+ */
1374
+ unloadMulticolorSprite(id: number): boolean;
1375
+ /**
1376
+ * Clears all unicolor sprites
1377
+ */
1378
+ clearUnicolorSprites(): void;
1379
+ /**
1380
+ * Clears all multicolor sprites
1381
+ */
1382
+ clearMulticolorSprites(): void;
1383
+ /**
1384
+ * Clears all sprites (unicolor and multicolor)
1385
+ */
1386
+ clearAll(): void;
1387
+ /**
1388
+ * Number of loaded unicolor sprites
1389
+ */
1390
+ getUnicolorSpriteCount(): number;
1391
+ /**
1392
+ * Number of loaded multicolor sprites
1393
+ */
1394
+ getMulticolorSpriteCount(): number;
1395
+ /**
1396
+ * Total number of loaded sprites
1397
+ */
1398
+ getTotalSpriteCount(): number;
795
1399
  }
1400
+
796
1401
  /**
797
- * Cell variant definition for Bitmask4 order
1402
+ * MacroHandler - Base interface for macro type handlers
1403
+ *
1404
+ * Each handler manages a specific type of macro:
1405
+ * - UIHandler: Buttons, interactive elements
1406
+ * - ParticleHandler: Particle systems (rain, snow, explosions)
1407
+ * - EffectHandler: Screen effects (shake, flash)
1408
+ * - RevealHandler: Progressive text/sprite reveal
798
1409
  */
799
- interface Bitmask4Variant {
800
- charCode: number;
801
- bgColorCode: number;
802
- fgColorCode: number;
803
- }
1410
+
804
1411
  /**
805
- * 0x12 - Bitmask4: Renders a rectangular region with 2-bit packed mask
806
- * Each 2-bit value represents: 0 = absence, 1-3 = variant index
1412
+ * Base interface for macro instance
807
1413
  */
808
- interface Bitmask4Order extends NetworkOrder {
809
- type: 0x12;
810
- posX: number;
811
- posY: number;
812
- sizeX: number;
813
- sizeY: number;
814
- override: boolean;
815
- variants: [Bitmask4Variant, Bitmask4Variant, Bitmask4Variant];
816
- mask: Uint8Array;
1414
+ interface BaseMacroInstance {
1415
+ instanceId: number;
1416
+ macroId: number;
1417
+ layerId: number;
1418
+ x: number;
1419
+ y: number;
1420
+ params: Record<string, unknown>;
817
1421
  }
818
1422
  /**
819
- * Cell variant definition for Bitmask16 order
1423
+ * UI macro instance with state tracking
820
1424
  */
821
- interface Bitmask16Variant {
822
- charCode: number;
823
- bgColorCode: number;
824
- fgColorCode: number;
1425
+ interface UIInstance extends BaseMacroInstance {
1426
+ type: 'ui';
1427
+ tabIndex: number;
1428
+ isHovered: boolean;
1429
+ isFocused: boolean;
1430
+ isActive: boolean;
1431
+ isDisabled: boolean;
825
1432
  }
826
1433
  /**
827
- * 0x18 - Bitmask16: Renders a rectangular region with 4-bit packed mask
828
- * Each 4-bit value represents: 0 = absence, 1-15 = variant index
1434
+ * Single particle in a particle system
829
1435
  */
830
- interface Bitmask16Order extends NetworkOrder {
831
- type: 0x18;
832
- posX: number;
833
- posY: number;
834
- sizeX: number;
835
- sizeY: number;
836
- override: boolean;
837
- variants: Bitmask16Variant[];
838
- mask: Uint8Array;
1436
+ interface Particle {
1437
+ x: number;
1438
+ y: number;
1439
+ vx: number;
1440
+ vy: number;
1441
+ char: string;
1442
+ fg: number;
1443
+ bg?: number;
1444
+ lifetime: number;
1445
+ maxLifetime: number;
839
1446
  }
840
1447
  /**
841
- * 0x13 - Clear: Fills entire layer with single character and colors
1448
+ * Particle macro instance with active particles
842
1449
  */
843
- interface ClearOrder extends NetworkOrder {
844
- type: 0x13;
845
- charCode: number;
846
- bgColorCode: number;
847
- fgColorCode: number;
1450
+ interface ParticleInstance extends BaseMacroInstance {
1451
+ type: 'particle';
1452
+ particles: Particle[];
1453
+ timeSinceEmit: number;
1454
+ emitDone: boolean;
848
1455
  }
849
1456
  /**
850
- * 0x14 - FillChar: Fills layer with repeating character pattern
1457
+ * Effect macro instance with animation state
851
1458
  */
852
- interface FillCharOrder extends NetworkOrder {
853
- type: 0x14;
854
- patternWidth: number;
855
- patternHeight: number;
856
- bgColorCode: number;
857
- fgColorCode: number;
858
- pattern: number[];
1459
+ interface EffectInstance extends BaseMacroInstance {
1460
+ type: 'effect';
1461
+ elapsed: number;
1462
+ duration: number;
1463
+ currentOffsetX: number;
1464
+ currentOffsetY: number;
859
1465
  }
860
1466
  /**
861
- * 0x15 - FillSprite: Fills layer with repeating unicolor sprite
1467
+ * Cell data for reveal macro
862
1468
  */
863
- interface FillSpriteOrder extends NetworkOrder {
864
- type: 0x15;
865
- spriteIndex: number;
866
- bgColorCode: number;
867
- fgColorCode: number;
1469
+ interface RevealCell {
1470
+ char: string;
1471
+ fg: number;
1472
+ bg: number;
1473
+ x: number;
1474
+ y: number;
1475
+ revealOrder: number;
868
1476
  }
869
1477
  /**
870
- * 0x16 - FillSpriteMultiColor: Fills layer with repeating multicolor sprite
1478
+ * Reveal macro instance with progressive display state
871
1479
  */
872
- interface FillSpriteMultiColorOrder extends NetworkOrder {
873
- type: 0x16;
874
- spriteIndex: number;
1480
+ interface RevealInstance extends BaseMacroInstance {
1481
+ type: 'reveal';
1482
+ cells: RevealCell[];
1483
+ revealedCount: number;
1484
+ totalCells: number;
1485
+ delayRemaining: number;
1486
+ pauseRemaining: number;
1487
+ finished: boolean;
1488
+ direction: 'reveal' | 'hide';
1489
+ speed: number;
1490
+ blinkState: boolean;
1491
+ blinkTimer: number;
875
1492
  }
876
1493
  /**
877
- * 0x20 - TriggerSound: Triggers positional sound effect
1494
+ * Point in a line renderer
878
1495
  */
879
- interface TriggerSoundOrder extends NetworkOrder {
880
- type: 0x20;
881
- posX: number;
882
- posY: number;
883
- soundId: number;
884
- loop: boolean;
1496
+ interface LinePoint {
1497
+ x: number;
1498
+ y: number;
1499
+ addedAt: number;
885
1500
  }
886
1501
  /**
887
- * 0x21 - TriggerGlobalSound: Triggers global (non-positional) sound
1502
+ * Line macro instance with point history
888
1503
  */
889
- interface TriggerGlobalSoundOrder extends NetworkOrder {
890
- type: 0x21;
891
- soundId: number;
892
- loop: boolean;
893
- }
894
- type AnyNetworkOrder = CharOrder | TextOrder | TextMultilineOrder | SubFrameOrder | SubFrameMultiColorOrder | FullFrameOrder | FullFrameMultiColorOrder | SpriteOrder | SpriteMultiColorOrder | ColorMapOrder | ShapeOrder | DotCloudOrder | DotCloudMultiColorOrder | BitmaskOrder | Bitmask4Order | Bitmask16Order | SpriteCloudOrder | SpriteCloudMultiColorOrder | SpriteCloudVariedOrder | SpriteCloudVariedMultiColorOrder | ClearOrder | FillCharOrder | FillSpriteOrder | FillSpriteMultiColorOrder | TriggerSoundOrder | TriggerGlobalSoundOrder;
895
-
896
- interface NetworkLayer {
897
- id: number;
898
- updateFlags: number;
899
- zIndex: number;
900
- originX: number;
901
- originY: number;
902
- width: number;
903
- height: number;
904
- orderCount: number;
905
- orders: AnyNetworkOrder[];
1504
+ interface LineInstance extends BaseMacroInstance {
1505
+ type: 'line';
1506
+ points: LinePoint[];
1507
+ currentTick: number;
906
1508
  }
1509
+ /**
1510
+ * Union of all macro instance types
1511
+ */
1512
+ type MacroInstance = UIInstance | ParticleInstance | EffectInstance | RevealInstance | LineInstance;
907
1513
 
908
1514
  /**
909
- * Update packet according to the new UTSP protocol
1515
+ * MacroEngine - Client-side macro execution engine
910
1516
  *
911
- * Structure:
912
- * - Tick (8 bytes): Frame counter for synchronization
913
- * - Displays: Viewport definitions
914
- * - Layers: Render orders for visual output
915
- * - Audio Orders: Audio commands synchronized with the frame
1517
+ * Manages:
1518
+ * - Macro template storage
1519
+ * - Instance lifecycle
1520
+ * - UI state machine (hover, focus, active)
1521
+ * - Particle systems
1522
+ * - Effect animations
1523
+ * - Order generation for rendering
916
1524
  *
917
- * Audio orders are in the same packet as render orders to ensure
918
- * perfect frame-level synchronization between visuals and sound.
1525
+ * This engine is part of @utsp/core and runs on the client side.
1526
+ * It receives macro orders from the server and generates render orders locally.
919
1527
  */
920
- interface UpdatePacket {
921
- /** Tick counter (8 bytes) */
922
- tick: number;
923
- /** Number of displays (1 byte) */
924
- displayCount: number;
925
- /** List of displays with their origins */
926
- displays: NetworkDisplay[];
927
- /** Number of layers (2 bytes) */
928
- layerCount: number;
929
- /** List of layers (shared across all displays) */
930
- layers: NetworkLayer[];
931
- /** Number of audio orders (1 byte) */
932
- audioOrderCount: number;
933
- /** List of audio orders (synchronized with this frame) */
934
- audioOrders: AnyAudioOrder[];
935
- }
936
1528
 
937
1529
  /**
938
- * Represents a display (camera) in the virtual world
939
- *
940
- * ARCHITECTURE (new protocol):
941
- * - Display = camera looking into the virtual world
942
- * - LAYERS are NO LONGER in Display, they are at User level
943
- * - Display only defines WHICH PART of the world we see (origin)
1530
+ * Result of macro engine update
1531
+ * Only contains events to send to server - sounds are played directly via callback
944
1532
  */
945
- declare class Display {
946
- private id;
947
- private origin;
948
- private size;
949
- private previousOrigin;
950
- private previousSize;
951
- private toDraw;
952
- constructor(id?: number, sizeX?: number, sizeY?: number);
1533
+ interface MacroUpdateResult {
1534
+ /** Events to send to server (click, change, etc.) */
1535
+ events: {
1536
+ instanceId: number;
1537
+ event: string;
1538
+ data?: unknown;
1539
+ }[];
1540
+ }
1541
+ /**
1542
+ * MacroEngine - Executes macros on the client side
1543
+ */
1544
+ declare class MacroEngine {
1545
+ private templates;
1546
+ private instances;
1547
+ private spriteRegistry;
1548
+ private playSound;
1549
+ private focusedInstanceId;
1550
+ private focusableInstances;
1551
+ private mouseX;
1552
+ private mouseY;
1553
+ private mouseDown;
1554
+ private readonly particleHandler;
1555
+ private readonly effectHandler;
1556
+ private readonly revealHandler;
1557
+ private readonly lineHandler;
1558
+ private instancesToDelete;
953
1559
  /**
954
- * Gets the display ID (0-255)
1560
+ * Injects SpriteRegistry (called by User when setting up)
1561
+ * Required for reveal macros with sprite content
955
1562
  */
956
- getId(): number;
1563
+ setSpriteRegistry(registry: SpriteRegistry): void;
957
1564
  /**
958
- * Gets the origin position in the world
1565
+ * Sets audio callback for playing sounds directly from macros
1566
+ * Sounds are played immediately on state changes (hover, click, etc.)
1567
+ *
1568
+ * @param callback - Function that plays a sound by ID
959
1569
  */
960
- getOrigin(): Vector2;
1570
+ setAudioCallback(callback: (soundId: number) => void): void;
961
1571
  /**
962
- * Sets the origin position in the world
1572
+ * Create the context object used by handlers
963
1573
  */
964
- setOrigin(origin: Vector2): void;
1574
+ private createContext;
965
1575
  /**
966
- * Moves the origin in the world
1576
+ * Load a macro template (called when receiving LoadMacro packet)
967
1577
  */
968
- moveOrigin(deltaX: number, deltaY: number): void;
1578
+ loadTemplate(macroId: number, template: MacroTemplate): void;
969
1579
  /**
970
- * Checks if display origin has changed since last tick
971
- * @internal - Used to calculate if update should be sent
1580
+ * Get a template by ID
972
1581
  */
973
- hasOriginChanged(): boolean;
1582
+ getTemplate(macroId: number): MacroTemplate | undefined;
974
1583
  /**
975
- * Checks if display size has changed since last tick
976
- * @internal - Used to calculate if update should be sent
1584
+ * Check if a template is loaded
977
1585
  */
978
- hasSizeChanged(): boolean;
1586
+ hasTemplate(macroId: number): boolean;
979
1587
  /**
980
- * Checks if display has changed (origin OR size)
981
- * @internal
1588
+ * Apply a macro order (called when decoding UpdatePacket)
982
1589
  */
983
- hasChanged(): boolean;
1590
+ applyOrder(order: AnyMacroOrder): void;
984
1591
  /**
985
- * Resets change tracking
986
- * @internal - Called by Core.endTick() after sending updates
1592
+ * Create a new instance
987
1593
  */
988
- resetChangeTracking(): void;
1594
+ private createInstance;
989
1595
  /**
990
- * Gets the display size
1596
+ * Update an existing instance
991
1597
  */
992
- getSize(): Vector2;
1598
+ private updateInstance;
993
1599
  /**
994
- * Sets the display size
1600
+ * Remove an instance
995
1601
  */
996
- setSize(size: Vector2): void;
997
- }
998
-
999
- interface Cell {
1000
- charCode: number;
1001
- fgColorCode: number;
1002
- bgColorCode: number;
1003
- }
1004
- /**
1005
- * Optimized buffer for 65,536 cells with TypedArray
1006
- * Interleaved structure: [char0, fg0, bg0, char1, fg1, bg1, ...]
1007
- *
1008
- * Performance:
1009
- * - clear(): ~5-10μs (vs 826μs with object array)
1010
- * - Better cache locality
1011
- * - Less GC pressure
1012
- */
1013
- declare class CellBuffer {
1014
- private data;
1015
- private size;
1016
- constructor(size?: number);
1602
+ private removeInstance;
1603
+ private addToFocusableList;
1604
+ private removeFromFocusableList;
1017
1605
  /**
1018
- * Optimized clear: fills with "skip" values
1019
- * - charCode = 0 (no character)
1020
- * - fgColorCode = 255 (COLOR_SKIP = transparent)
1021
- * - bgColorCode = 255 (COLOR_SKIP = transparent)
1022
- * Performance: ~5-10μs (native TypedArray)
1606
+ * Move focus to next focusable element
1023
1607
  */
1024
- clear(): void;
1608
+ focusNext(): void;
1025
1609
  /**
1026
- * Optimized clear with uniform color
1027
- * Faster than clear() when clearing to specific char/colors
1028
- * Useful for background layers with uniform color
1029
- *
1030
- * Performance: ~2-5μs (loop unrolling friendly)
1031
- *
1032
- * @param charCode - Character to fill (e.g., 0x20 for space)
1033
- * @param fgColorCode - Foreground color (0-255)
1034
- * @param bgColorCode - Background color (0-255)
1035
- *
1036
- * @example
1037
- * // Clear to black background
1038
- * buffer.clearWithColor(0x20, 15, 0);
1610
+ * Move focus to previous focusable element
1039
1611
  */
1040
- clearWithColor(charCode: number, fgColorCode: number, bgColorCode: number): void;
1612
+ focusPrevious(): void;
1041
1613
  /**
1042
- * Sets a cell at given index
1614
+ * Set focus to a specific instance
1043
1615
  */
1044
- set(index: number, charCode: number, fgColorCode: number, bgColorCode: number): void;
1616
+ setFocus(instanceId: number | null): void;
1045
1617
  /**
1046
- * Optimized batch fill for uniform char+colors (DotCloud, SpriteCloud)
1047
- * Writes only characters at multiple positions with uniform fg/bg colors
1048
- *
1049
- * Performance: 2-3x faster than individual set() calls for uniform colors
1050
- * Reduces memory writes by 66% (writes chars only, then batch-fills colors)
1051
- *
1052
- * @param indices - Array of cell indices to fill
1053
- * @param charCode - Character to write at all positions
1054
- * @param fgColorCode - Uniform foreground color
1055
- * @param bgColorCode - Uniform background color
1056
- *
1057
- * @example
1058
- * // Rain drops (1,500 positions with same color)
1059
- * const indices = raindrops.map(d => d.y * width + d.x);
1060
- * buffer.fillCharsUniform(indices, 58, 20, 255); // ':' char, cyan, transparent
1618
+ * Update mouse state for UI interaction
1619
+ * @param x - Mouse X position in cells (world coordinates)
1620
+ * @param y - Mouse Y position in cells (world coordinates)
1621
+ * @param isDown - Whether the mouse button is pressed
1061
1622
  */
1062
- fillCharsUniform(indices: number[], charCode: number, fgColorCode: number, bgColorCode: number): void;
1623
+ updateMouse(x: number, y: number, isDown: boolean): void;
1063
1624
  /**
1064
- * Gets a cell at given index
1065
- * Returns a Cell object for compatibility
1625
+ * Estimate UI element size from template configuration
1066
1626
  */
1067
- get(index: number): Cell;
1627
+ private estimateUISize;
1068
1628
  /**
1069
- * Sets only character at given index (keeps existing colors)
1070
- * Useful for operations that modify chars but preserve colors
1071
- *
1072
- * @param index - Cell index
1073
- * @param charCode - Character code to write
1629
+ * Activate the currently focused element (trigger click)
1074
1630
  */
1075
- setCharOnly(index: number, charCode: number): void;
1631
+ activateFocused(): void;
1076
1632
  /**
1077
- * Sets only colors at given index (keeps existing char)
1078
- * Useful for ColorMapOrder (updates colors, preserves chars)
1633
+ * Update all instances (called each tick)
1079
1634
  *
1080
- * @param index - Cell index
1081
- * @param fgColorCode - Foreground color
1082
- * @param bgColorCode - Background color
1635
+ * @returns Update result with events to send to server
1636
+ */
1637
+ update(): MacroUpdateResult;
1638
+ /**
1639
+ * Get render orders grouped by layer
1640
+ */
1641
+ getOrdersByLayer(): Map<number, AnyNetworkOrder[]>;
1642
+ /**
1643
+ * Render a single instance to orders
1644
+ */
1645
+ private renderInstance;
1646
+ /**
1647
+ * Resolve a value that may be a parameter reference ($param)
1648
+ */
1649
+ private resolveValue;
1650
+ /**
1651
+ * Resolve a random value (number or [min, max])
1083
1652
  */
1084
- setColorsOnly(index: number, fgColorCode: number, bgColorCode: number): void;
1653
+ private resolveRandomValue;
1085
1654
  /**
1086
- * Direct value access (faster than get())
1087
- * Note: These are called in hot loops, keep as inline as possible
1655
+ * Get the current effect offset (for screen shake, etc.)
1088
1656
  */
1089
- getCharCode(index: number): number;
1090
- getFgColorCode(index: number): number;
1091
- getBgColorCode(index: number): number;
1657
+ getEffectOffset(): {
1658
+ x: number;
1659
+ y: number;
1660
+ };
1092
1661
  /**
1093
- * Direct TypedArray access for batch operations
1662
+ * Get all active instances
1094
1663
  */
1095
- getRawData(): Uint8Array;
1664
+ getAllInstances(): MacroInstance[];
1096
1665
  /**
1097
- * Buffer size (number of cells)
1666
+ * Get instance count
1098
1667
  */
1099
- getSize(): number;
1668
+ getInstanceCount(): number;
1669
+ /**
1670
+ * Clear all templates and instances
1671
+ */
1672
+ clear(): void;
1100
1673
  }
1674
+
1101
1675
  /**
1102
- * Optimized buffer to store only charcodes (unicolor sprites)
1103
- * Simple structure: [char0, char1, char2, ...]
1676
+ * UTSP Audio Order Types Enumeration
1104
1677
  *
1105
- * Performance:
1106
- * - 3x less memory than CellBuffer (1 byte vs 3 bytes per cell)
1107
- * - Ideal for unicolor sprites where colors are defined at render time
1108
- * - Cache-friendly with TypedArray
1678
+ * Audio orders are separate from render orders and have their own type space.
1679
+ * They are included in the UpdatePacket but processed by the AudioProcessor,
1680
+ * not the Rasterizer.
1681
+ *
1682
+ * This separation ensures:
1683
+ * - Clear distinction between visual and audio orders
1684
+ * - Independent type numbering (0x01 audio ≠ 0x01 render)
1685
+ * - Extensibility without conflicts
1686
+ *
1687
+ * @example
1688
+ * ```typescript
1689
+ * import { AudioOrderType } from '@utsp/core';
1690
+ *
1691
+ * const order = { type: AudioOrderType.PlaySound, soundId: 0, volume: 200 };
1692
+ * ```
1109
1693
  */
1110
- declare class CharCodeBuffer {
1111
- private data;
1112
- private size;
1113
- constructor(size: number);
1694
+ declare enum AudioOrderType {
1114
1695
  /**
1115
- * Optimized clear: fills with zeros (no character)
1696
+ * 0x01 - PlaySound: Play a sound with optional spatial position
1697
+ *
1698
+ * Parameters: soundId, instanceId, flags, volume?, pitch?, fadeIn?, posX?, posY?
1116
1699
  */
1117
- clear(): void;
1700
+ PlaySound = 1,
1118
1701
  /**
1119
- * Sets a charcode at given index
1702
+ * 0x02 - PlayGlobalSound: Play a non-positional (global) sound
1703
+ *
1704
+ * Parameters: soundId, instanceId, flags, volume?, pitch?, fadeIn?
1120
1705
  */
1121
- set(index: number, charCode: number): void;
1706
+ PlayGlobalSound = 2,
1122
1707
  /**
1123
- * Gets a charcode at given index
1708
+ * 0x03 - StopSound: Stop a sound immediately
1709
+ *
1710
+ * Parameters: targetType, target (instanceId, soundId, or 'all')
1124
1711
  */
1125
- get(index: number): number;
1712
+ StopSound = 3,
1126
1713
  /**
1127
- * Direct TypedArray access for batch operations
1714
+ * 0x04 - FadeOutSound: Fade out and stop a sound
1715
+ *
1716
+ * Parameters: targetType, target, duration
1128
1717
  */
1129
- getRawData(): Uint8Array;
1718
+ FadeOutSound = 4,
1130
1719
  /**
1131
- * Buffer size (number of cells)
1720
+ * 0x05 - PauseSound: Pause a playing sound
1721
+ *
1722
+ * Parameters: targetType, target
1132
1723
  */
1133
- getSize(): number;
1724
+ PauseSound = 5,
1725
+ /**
1726
+ * 0x06 - ResumeSound: Resume a paused sound
1727
+ *
1728
+ * Parameters: targetType, target
1729
+ */
1730
+ ResumeSound = 6,
1731
+ /**
1732
+ * 0x07 - SetListenerPosition: Set the listener position for spatial audio
1733
+ *
1734
+ * Parameters: x, y (16-bit each)
1735
+ */
1736
+ SetListenerPosition = 7,
1737
+ /**
1738
+ * 0x08 - ConfigureSpatial: Configure spatial audio parameters
1739
+ *
1740
+ * Parameters: maxDistance, referenceDistance, rolloffFactor, panSpread
1741
+ */
1742
+ ConfigureSpatial = 8,
1743
+ /**
1744
+ * 0x09 - SetSoundEffects: Set audio effects on a playing sound
1745
+ *
1746
+ * Parameters: instanceId, flags, lowpass?, highpass?, reverb?
1747
+ */
1748
+ SetSoundEffects = 9
1134
1749
  }
1750
+ /**
1751
+ * Target type for stop/pause/resume/fadeout commands
1752
+ */
1753
+ declare enum AudioTargetType {
1754
+ /** Target a specific instance by ID */
1755
+ InstanceId = 0,
1756
+ /** Target all instances of a sound by soundId */
1757
+ SoundId = 1,
1758
+ /** Target all sounds */
1759
+ All = 2
1760
+ }
1761
+ /**
1762
+ * Type guard to check if a number is a valid AudioOrderType
1763
+ */
1764
+ declare function isValidAudioOrderType(type: number): type is AudioOrderType;
1765
+ /**
1766
+ * Get human-readable name for an AudioOrderType
1767
+ */
1768
+ declare function getAudioOrderTypeName(type: AudioOrderType | number): string;
1135
1769
 
1136
1770
  /**
1137
- * Unicolor sprite - Stores only charcodes
1138
- * Colors (fg/bg) are defined at render time via SpriteOrder
1771
+ * UTSP Audio Orders
1139
1772
  *
1140
- * Used with LoadType.Sprite (0x02) and SpriteOrder (0x07)
1773
+ * Binary-encoded audio commands included in UpdatePacket.
1774
+ * Processed by AudioProcessor on client, synchronized with render orders.
1775
+ *
1776
+ * Each order has a specific binary structure optimized for network transmission.
1141
1777
  */
1142
- interface UnicolorSprite {
1143
- id: number;
1144
- sizeX: number;
1145
- sizeY: number;
1146
- data: CharCodeBuffer;
1778
+
1779
+ /**
1780
+ * Base interface for all audio orders
1781
+ */
1782
+ interface AudioOrder {
1783
+ /** Audio order type identifier */
1784
+ type: AudioOrderType;
1147
1785
  }
1148
1786
  /**
1149
- * Multicolor sprite - Stores charcodes + fg/bg colors
1150
- * Each cell contains its own color set
1787
+ * Flags for PlaySound/PlayGlobalSound orders
1788
+ * Packed into a single byte to minimize bandwidth
1789
+ */
1790
+ declare enum PlaySoundFlags {
1791
+ /** Sound should loop */
1792
+ Loop = 1,
1793
+ /** Volume is specified (otherwise default 100%) */
1794
+ HasVolume = 2,
1795
+ /** Pitch is specified (otherwise default 1.0x) */
1796
+ HasPitch = 4,
1797
+ /** FadeIn duration is specified (otherwise instant) */
1798
+ HasFadeIn = 8,
1799
+ /** Position is specified (only for PlaySound, not PlayGlobalSound) */
1800
+ HasPosition = 16,
1801
+ /** Low-pass filter is specified */
1802
+ HasLowpass = 32,
1803
+ /** High-pass filter is specified */
1804
+ HasHighpass = 64,
1805
+ /** Reverb mix is specified */
1806
+ HasReverb = 128
1807
+ }
1808
+ /**
1809
+ * 0x01 - PlaySound: Play a sound with optional spatial position
1151
1810
  *
1152
- * Used with LoadType.MulticolorSprite (0x03) and SpriteMultiColorOrder (0x08)
1811
+ * Binary structure (variable size, 4-15 bytes):
1812
+ * - type: 1 byte (0x01)
1813
+ * - soundId: 1 byte (0-255)
1814
+ * - instanceId: 2 bytes (big-endian, unique ID for this playback)
1815
+ * - flags: 1 byte (PlaySoundFlags bitfield)
1816
+ * - volume?: 1 byte (0-255, maps to 0.0-1.0) - if HasVolume
1817
+ * - pitch?: 1 byte (0-255, maps to 0.25x-4.0x, 128=1.0x) - if HasPitch
1818
+ * - fadeIn?: 1 byte (0-255, duration in 1/10 seconds, 0=instant) - if HasFadeIn
1819
+ * - posX?: 2 bytes (big-endian, 0-65535) - if HasPosition
1820
+ * - posY?: 2 bytes (big-endian, 0-65535) - if HasPosition
1821
+ * - lowpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasLowpass
1822
+ * - highpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasHighpass
1823
+ * - reverb?: 1 byte (0-255, / 255 = wet mix 0.0-1.0) - if HasReverb
1153
1824
  */
1154
- interface MulticolorSprite {
1155
- id: number;
1156
- sizeX: number;
1157
- sizeY: number;
1158
- data: CellBuffer;
1825
+ interface PlaySoundOrder extends AudioOrder {
1826
+ type: AudioOrderType.PlaySound;
1827
+ /** Sound ID (0-255) */
1828
+ soundId: number;
1829
+ /** Unique instance ID for this playback */
1830
+ instanceId: number;
1831
+ /** Flags bitfield */
1832
+ flags: number;
1833
+ /** Volume (0-255, maps to 0.0-1.0). Present if HasVolume flag set */
1834
+ volume?: number;
1835
+ /** Pitch (0-255, 128=1.0x). Present if HasPitch flag set */
1836
+ pitch?: number;
1837
+ /** Fade in duration in 1/10 seconds. Present if HasFadeIn flag set */
1838
+ fadeIn?: number;
1839
+ /** X position (0-65535). Present if HasPosition flag set */
1840
+ posX?: number;
1841
+ /** Y position (0-65535). Present if HasPosition flag set */
1842
+ posY?: number;
1843
+ /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
1844
+ lowpass?: number;
1845
+ /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
1846
+ highpass?: number;
1847
+ /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
1848
+ reverb?: number;
1159
1849
  }
1160
-
1161
1850
  /**
1162
- * UTSP Load Packet Types
1163
- * Based on UTSP Protocol v0.1 - Section 4: Load Section
1851
+ * 0x02 - PlayGlobalSound: Play a non-positional sound
1852
+ *
1853
+ * Binary structure (variable size, 4-10 bytes):
1854
+ * - type: 1 byte (0x02)
1855
+ * - soundId: 1 byte (0-255)
1856
+ * - instanceId: 2 bytes (big-endian)
1857
+ * - flags: 1 byte (PlaySoundFlags, but HasPosition is ignored)
1858
+ * - volume?: 1 byte - if HasVolume
1859
+ * - pitch?: 1 byte - if HasPitch
1860
+ * - fadeIn?: 1 byte - if HasFadeIn
1861
+ * - lowpass?: 1 byte - if HasLowpass
1862
+ * - highpass?: 1 byte - if HasHighpass
1863
+ * - reverb?: 1 byte - if HasReverb
1164
1864
  */
1865
+ interface PlayGlobalSoundOrder extends AudioOrder {
1866
+ type: AudioOrderType.PlayGlobalSound;
1867
+ /** Sound ID (0-255) */
1868
+ soundId: number;
1869
+ /** Unique instance ID for this playback */
1870
+ instanceId: number;
1871
+ /** Flags bitfield (HasPosition ignored) */
1872
+ flags: number;
1873
+ /** Volume (0-255). Present if HasVolume flag set */
1874
+ volume?: number;
1875
+ /** Pitch (0-255, 128=1.0x). Present if HasPitch flag set */
1876
+ pitch?: number;
1877
+ /** Fade in duration in 1/10 seconds. Present if HasFadeIn flag set */
1878
+ fadeIn?: number;
1879
+ /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
1880
+ lowpass?: number;
1881
+ /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
1882
+ highpass?: number;
1883
+ /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
1884
+ reverb?: number;
1885
+ }
1165
1886
  /**
1166
- * LoadType enumeration
1887
+ * 0x03 - StopSound: Stop a sound immediately
1888
+ *
1889
+ * Binary structure (3-4 bytes):
1890
+ * - type: 1 byte (0x03)
1891
+ * - targetType: 1 byte (AudioTargetType)
1892
+ * - target: 1-2 bytes (instanceId=2B, soundId=1B, all=0B)
1167
1893
  */
1168
- declare enum LoadType {
1169
- ColorPalette = 1,
1170
- Sprite = 2,
1171
- MulticolorSprite = 3,
1172
- BitmapFont = 4,// Formerly "Charset" - pixel-based fonts
1173
- Sound = 5,
1174
- WebFont = 6
1894
+ interface StopSoundOrder extends AudioOrder {
1895
+ type: AudioOrderType.StopSound;
1896
+ /** Type of target */
1897
+ targetType: AudioTargetType;
1898
+ /** Target value (instanceId, soundId, or undefined for 'all') */
1899
+ target?: number;
1175
1900
  }
1176
1901
  /**
1177
- * Color definition with RGBA+E values
1902
+ * 0x04 - FadeOutSound: Fade out and stop a sound
1903
+ *
1904
+ * Binary structure (4-5 bytes):
1905
+ * - type: 1 byte (0x04)
1906
+ * - targetType: 1 byte
1907
+ * - duration: 1 byte (1/10 seconds, 0-25.5s)
1908
+ * - target: 1-2 bytes
1178
1909
  */
1179
- interface Color {
1180
- colorId: number;
1181
- r: number;
1182
- g: number;
1183
- b: number;
1184
- a: number;
1185
- e?: number;
1910
+ interface FadeOutSoundOrder extends AudioOrder {
1911
+ type: AudioOrderType.FadeOutSound;
1912
+ /** Type of target */
1913
+ targetType: AudioTargetType;
1914
+ /** Fade duration in 1/10 seconds (0-255 = 0-25.5 seconds) */
1915
+ duration: number;
1916
+ /** Target value */
1917
+ target?: number;
1186
1918
  }
1187
1919
  /**
1188
- * Color Palette Load (LoadType 0x01)
1189
- * Loads a palette of RGBA+E colors
1920
+ * 0x05 - PauseSound: Pause a playing sound
1921
+ *
1922
+ * Binary structure (2-4 bytes):
1923
+ * - type: 1 byte (0x05)
1924
+ * - targetType: 1 byte
1925
+ * - target: 0-2 bytes
1190
1926
  */
1191
- interface ColorPaletteLoad {
1192
- loadType: LoadType.ColorPalette;
1193
- colors: Color[];
1927
+ interface PauseSoundOrder extends AudioOrder {
1928
+ type: AudioOrderType.PauseSound;
1929
+ /** Type of target */
1930
+ targetType: AudioTargetType;
1931
+ /** Target value */
1932
+ target?: number;
1194
1933
  }
1195
1934
  /**
1196
- * Simple Sprite Load (LoadType 0x02)
1197
- * Each cell contains only a character code
1935
+ * 0x06 - ResumeSound: Resume a paused sound
1936
+ *
1937
+ * Binary structure (2-4 bytes):
1938
+ * - type: 1 byte (0x06)
1939
+ * - targetType: 1 byte
1940
+ * - target: 0-2 bytes
1198
1941
  */
1199
- interface SpriteLoad {
1200
- loadType: LoadType.Sprite;
1201
- sprites: Array<{
1202
- spriteId: number;
1203
- sizeX: number;
1204
- sizeY: number;
1205
- data: number[];
1206
- }>;
1942
+ interface ResumeSoundOrder extends AudioOrder {
1943
+ type: AudioOrderType.ResumeSound;
1944
+ /** Type of target */
1945
+ targetType: AudioTargetType;
1946
+ /** Target value */
1947
+ target?: number;
1207
1948
  }
1208
1949
  /**
1209
- * Cell in a multicolor sprite
1950
+ * 0x07 - SetListenerPosition: Set listener position for spatial audio
1951
+ *
1952
+ * Binary structure (5 bytes):
1953
+ * - type: 1 byte (0x07)
1954
+ * - x: 2 bytes (big-endian, 0-65535)
1955
+ * - y: 2 bytes (big-endian, 0-65535)
1210
1956
  */
1211
- interface MulticolorCell {
1212
- charCode: number;
1213
- fgColorId: number;
1214
- bgColorId: number;
1957
+ interface SetListenerPositionOrder extends AudioOrder {
1958
+ type: AudioOrderType.SetListenerPosition;
1959
+ /** X position (0-65535) */
1960
+ x: number;
1961
+ /** Y position (0-65535) */
1962
+ y: number;
1215
1963
  }
1216
1964
  /**
1217
- * Multicolor Sprite Load (LoadType 0x03)
1218
- * Each cell contains charcode + foreground color + background color
1965
+ * 0x08 - ConfigureSpatial: Configure spatial audio parameters
1966
+ *
1967
+ * Binary structure (5 bytes):
1968
+ * - type: 1 byte (0x08)
1969
+ * - maxDistance: 1 byte (0-255, scaled appropriately)
1970
+ * - referenceDistance: 1 byte (0-255)
1971
+ * - rolloffFactor: 1 byte (0-255, maps to 0.0-2.55)
1972
+ * - panSpread: 1 byte (0-255, maps to 0.0-1.0)
1219
1973
  */
1220
- interface MulticolorSpriteLoad {
1221
- loadType: LoadType.MulticolorSprite;
1222
- sprites: Array<{
1223
- spriteId: number;
1224
- sizeX: number;
1225
- sizeY: number;
1226
- data: MulticolorCell[];
1227
- }>;
1974
+ interface ConfigureSpatialOrder extends AudioOrder {
1975
+ type: AudioOrderType.ConfigureSpatial;
1976
+ /** Maximum audible distance (encoded, 0-255) */
1977
+ maxDistance: number;
1978
+ /** Reference distance for full volume (encoded, 0-255) */
1979
+ referenceDistance: number;
1980
+ /** Rolloff factor (0-255, maps to 0.0-2.55) */
1981
+ rolloffFactor: number;
1982
+ /** Pan spread factor (0-255, maps to 0.0-1.0) */
1983
+ panSpread: number;
1228
1984
  }
1229
1985
  /**
1230
- * BitmapFont Load (LoadType 0x04)
1231
- * Custom character definitions (monochrome bitmaps)
1232
- * Formerly known as "Charset" - renamed to BitmapFont for clarity
1986
+ * Flags for SetSoundEffects order
1233
1987
  */
1234
- interface BitmapFontLoad {
1235
- loadType: LoadType.BitmapFont;
1236
- fontId: number;
1237
- width: number;
1238
- height: number;
1239
- cellWidth: number;
1240
- cellHeight: number;
1241
- characters: Array<{
1242
- charCode: number;
1243
- bitmap: Uint8Array;
1244
- }>;
1988
+ declare enum SoundEffectsFlags {
1989
+ /** Low-pass filter is specified */
1990
+ HasLowpass = 1,
1991
+ /** High-pass filter is specified */
1992
+ HasHighpass = 2,
1993
+ /** Reverb mix is specified */
1994
+ HasReverb = 4
1245
1995
  }
1246
1996
  /**
1247
- * WebFont Load (LoadType 0x06)
1248
- * CSS-based font definitions for browser rendering
1249
- * Note: The default font is "Courier New" (monospace), but users can specify non-monospace fonts
1997
+ * 0x09 - SetSoundEffects: Update audio effects on a playing sound
1998
+ *
1999
+ * Binary structure (variable size, 4-7 bytes):
2000
+ * - type: 1 byte (0x09)
2001
+ * - instanceId: 2 bytes (big-endian)
2002
+ * - flags: 1 byte (SoundEffectsFlags bitfield)
2003
+ * - lowpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasLowpass
2004
+ * - highpass?: 1 byte (0-255, * 100 = Hz cutoff) - if HasHighpass
2005
+ * - reverb?: 1 byte (0-255, / 255 = wet mix 0.0-1.0) - if HasReverb
1250
2006
  */
1251
- interface WebFontLoad {
1252
- loadType: LoadType.WebFont;
1253
- fontId: number;
1254
- fontFamily: string;
1255
- fontSize: number;
1256
- offsetX?: number;
1257
- offsetY?: number;
1258
- charSpacing?: number;
1259
- lineHeight?: number;
1260
- fontWeight?: string;
1261
- fontStyle?: string;
2007
+ interface SetSoundEffectsOrder extends AudioOrder {
2008
+ type: AudioOrderType.SetSoundEffects;
2009
+ /** Target instance ID */
2010
+ instanceId: number;
2011
+ /** Flags bitfield */
2012
+ flags: number;
2013
+ /** Low-pass filter cutoff (0-255, * 100 = Hz). Present if HasLowpass flag set */
2014
+ lowpass?: number;
2015
+ /** High-pass filter cutoff (0-255, * 100 = Hz). Present if HasHighpass flag set */
2016
+ highpass?: number;
2017
+ /** Reverb wet mix (0-255, / 255 = 0.0-1.0). Present if HasReverb flag set */
2018
+ reverb?: number;
1262
2019
  }
1263
2020
  /**
1264
- * Sound Load (LoadType 0x05)
1265
- * MIDI sound data for audio playback
2021
+ * Union of all audio order types
1266
2022
  */
1267
- interface SoundLoad {
1268
- loadType: LoadType.Sound;
1269
- sounds: Array<{
1270
- soundId: number;
1271
- midiData: Uint8Array;
1272
- }>;
1273
- }
2023
+ type AnyAudioOrder = PlaySoundOrder | PlayGlobalSoundOrder | StopSoundOrder | FadeOutSoundOrder | PauseSoundOrder | ResumeSoundOrder | SetListenerPositionOrder | ConfigureSpatialOrder | SetSoundEffectsOrder;
2024
+
1274
2025
  /**
1275
- * Union type for all load types
2026
+ * Network representation of a display
2027
+ * Layers are NO LONGER under displays - they are at User level
1276
2028
  */
1277
- type AnyLoad = ColorPaletteLoad | SpriteLoad | MulticolorSpriteLoad | BitmapFontLoad | SoundLoad | WebFontLoad;
2029
+ interface NetworkDisplay {
2030
+ /** Display ID (0-255) */
2031
+ id: number;
2032
+ /** Origin X position in virtual world (0-65535) */
2033
+ originX: number;
2034
+ /** Origin Y position in virtual world (0-65535) */
2035
+ originY: number;
2036
+ /** Display width in cells (1-256) */
2037
+ sizeX: number;
2038
+ /** Display height in cells (1-256) */
2039
+ sizeY: number;
2040
+ }
2041
+
2042
+ interface NetworkLayer {
2043
+ id: number;
2044
+ updateFlags: number;
2045
+ zIndex: number;
2046
+ originX: number;
2047
+ originY: number;
2048
+ width: number;
2049
+ height: number;
2050
+ orderCount: number;
2051
+ orders: AnyNetworkOrder[];
2052
+ }
1278
2053
 
1279
2054
  /**
1280
- * Central registry to manage unicolor and multicolor sprites
2055
+ * Update packet according to the new UTSP protocol
1281
2056
  *
1282
- * Sprites are loaded via LoadPacket and referenced by their ID
1283
- * in Orders (SpriteOrder, SpriteMultiColorOrder, etc.)
2057
+ * Structure:
2058
+ * - Tick (8 bytes): Frame counter for synchronization
2059
+ * - Displays: Viewport definitions
2060
+ * - Layers: Render orders for visual output
2061
+ * - Audio Orders: Audio commands synchronized with the frame
2062
+ * - Macro Orders: Macro instance commands (create, update, remove)
1284
2063
  *
1285
- * Architecture:
1286
- * - Two separate registries for unicolor and multicolor
1287
- * - No possible collision between the two types
1288
- * - Memory optimization with CharCodeBuffer for unicolor
2064
+ * Audio orders are in the same packet as render orders to ensure
2065
+ * perfect frame-level synchronization between visuals and sound.
1289
2066
  */
1290
- declare class SpriteRegistry {
1291
- private unicolorSprites;
1292
- private multicolorSprites;
1293
- /**
1294
- * Loads unicolor sprites from a LoadPacket
1295
- * Converts network format to optimized internal format
1296
- */
1297
- loadUnicolorSprites(loadData: SpriteLoad): void;
1298
- /**
1299
- * Loads multicolor sprites from a LoadPacket
1300
- * Converts network format to optimized internal format
1301
- */
1302
- loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
1303
- /**
1304
- * Retrieves a unicolor sprite by its ID
1305
- */
1306
- getUnicolorSprite(id: number): UnicolorSprite | undefined;
1307
- /**
1308
- * Retrieves a multicolor sprite by its ID
1309
- */
1310
- getMulticolorSprite(id: number): MulticolorSprite | undefined;
2067
+ interface UpdatePacket {
2068
+ /** Tick counter (8 bytes) */
2069
+ tick: number;
2070
+ /** Number of displays (1 byte) */
2071
+ displayCount: number;
2072
+ /** List of displays with their origins */
2073
+ displays: NetworkDisplay[];
2074
+ /** Number of layers (2 bytes) */
2075
+ layerCount: number;
2076
+ /** List of layers (shared across all displays) */
2077
+ layers: NetworkLayer[];
2078
+ /** Number of audio orders (1 byte) */
2079
+ audioOrderCount: number;
2080
+ /** List of audio orders (synchronized with this frame) */
2081
+ audioOrders: AnyAudioOrder[];
2082
+ /** Number of macro orders (1 byte) */
2083
+ macroOrderCount: number;
2084
+ /** List of macro orders (create, update, remove instances) */
2085
+ macroOrders: AnyMacroOrder[];
2086
+ }
2087
+
2088
+ /**
2089
+ * Represents a display (camera) in the virtual world
2090
+ *
2091
+ * ARCHITECTURE (new protocol):
2092
+ * - Display = camera looking into the virtual world
2093
+ * - LAYERS are NO LONGER in Display, they are at User level
2094
+ * - Display only defines WHICH PART of the world we see (origin)
2095
+ */
2096
+ declare class Display {
2097
+ private id;
2098
+ private origin;
2099
+ private size;
2100
+ private previousOrigin;
2101
+ private previousSize;
2102
+ private toDraw;
2103
+ constructor(id?: number, sizeX?: number, sizeY?: number);
1311
2104
  /**
1312
- * Checks if a unicolor sprite exists
2105
+ * Gets the display ID (0-255)
1313
2106
  */
1314
- hasUnicolorSprite(id: number): boolean;
2107
+ getId(): number;
1315
2108
  /**
1316
- * Checks if a multicolor sprite exists
2109
+ * Gets the origin position in the world
1317
2110
  */
1318
- hasMulticolorSprite(id: number): boolean;
2111
+ getOrigin(): Vector2;
1319
2112
  /**
1320
- * Removes a unicolor sprite
2113
+ * Sets the origin position in the world
1321
2114
  */
1322
- unloadUnicolorSprite(id: number): boolean;
2115
+ setOrigin(origin: Vector2): void;
1323
2116
  /**
1324
- * Removes a multicolor sprite
2117
+ * Moves the origin in the world
1325
2118
  */
1326
- unloadMulticolorSprite(id: number): boolean;
2119
+ moveOrigin(deltaX: number, deltaY: number): void;
1327
2120
  /**
1328
- * Clears all unicolor sprites
2121
+ * Checks if display origin has changed since last tick
2122
+ * @internal - Used to calculate if update should be sent
1329
2123
  */
1330
- clearUnicolorSprites(): void;
2124
+ hasOriginChanged(): boolean;
1331
2125
  /**
1332
- * Clears all multicolor sprites
2126
+ * Checks if display size has changed since last tick
2127
+ * @internal - Used to calculate if update should be sent
1333
2128
  */
1334
- clearMulticolorSprites(): void;
2129
+ hasSizeChanged(): boolean;
1335
2130
  /**
1336
- * Clears all sprites (unicolor and multicolor)
2131
+ * Checks if display has changed (origin OR size)
2132
+ * @internal
1337
2133
  */
1338
- clearAll(): void;
2134
+ hasChanged(): boolean;
1339
2135
  /**
1340
- * Number of loaded unicolor sprites
2136
+ * Resets change tracking
2137
+ * @internal - Called by Core.endTick() after sending updates
1341
2138
  */
1342
- getUnicolorSpriteCount(): number;
2139
+ resetChangeTracking(): void;
1343
2140
  /**
1344
- * Number of loaded multicolor sprites
2141
+ * Gets the display size
1345
2142
  */
1346
- getMulticolorSpriteCount(): number;
2143
+ getSize(): Vector2;
1347
2144
  /**
1348
- * Total number of loaded sprites
2145
+ * Sets the display size
1349
2146
  */
1350
- getTotalSpriteCount(): number;
2147
+ setSize(size: Vector2): void;
1351
2148
  }
1352
2149
 
1353
2150
  declare class Layer {
@@ -1384,6 +2181,12 @@ declare class Layer {
1384
2181
  * Automatically rasterizes new orders in ADD mode
1385
2182
  */
1386
2183
  addOrders(orders: AnyNetworkOrder[]): void;
2184
+ /**
2185
+ * Adds temporary orders that are rasterized but not stored
2186
+ * Used for macro-generated content (particles, UI) that is regenerated each frame
2187
+ * Uses SET mode to clear previous content before drawing
2188
+ */
2189
+ addTemporaryOrders(orders: AnyNetworkOrder[]): void;
1387
2190
  /**
1388
2191
  * Replaces all orders in the layer (reset mode)
1389
2192
  * Automatically rasterizes all orders in SET mode
@@ -1509,6 +2312,169 @@ declare class Layer {
1509
2312
  resetCommit(): void;
1510
2313
  }
1511
2314
 
2315
+ /**
2316
+ * MacroRegistry - Registry for macro templates and instances
2317
+ *
2318
+ * Manages:
2319
+ * - Macro templates (loaded via loadMacro)
2320
+ * - Macro instances (created via createInstance)
2321
+ * - Name → ID mappings for network transmission
2322
+ *
2323
+ * Used on both server (for encoding) and client (for decoding and execution).
2324
+ */
2325
+
2326
+ /**
2327
+ * Internal representation of a registered macro template
2328
+ */
2329
+ interface MacroEntry {
2330
+ /** Unique macro identifier (0-255) */
2331
+ macroId: number;
2332
+ /** Human-readable name (from template.id) */
2333
+ name: string;
2334
+ /** Full template definition */
2335
+ template: MacroTemplate;
2336
+ }
2337
+ /**
2338
+ * Internal representation of an active macro instance
2339
+ */
2340
+ interface MacroInstanceEntry {
2341
+ /** Unique instance identifier (0-255) */
2342
+ instanceId: number;
2343
+ /** Human-readable name */
2344
+ name: string;
2345
+ /** Reference to macro template ID */
2346
+ macroId: number;
2347
+ /** Reference to layer ID */
2348
+ layerId: number;
2349
+ /** Position X (cells) */
2350
+ x: number;
2351
+ /** Position Y (cells) */
2352
+ y: number;
2353
+ /** Tab index for keyboard navigation */
2354
+ tabIndex: number;
2355
+ /** Current parameters */
2356
+ params: Record<string, unknown>;
2357
+ }
2358
+ /**
2359
+ * Configuration for creating a macro instance
2360
+ */
2361
+ interface CreateInstanceConfig {
2362
+ /** Instance name (will be mapped to numeric ID) */
2363
+ id: string;
2364
+ /** Macro template name (must be loaded first) */
2365
+ macro: string;
2366
+ /** Layer name (must exist) */
2367
+ layer: string;
2368
+ /** Position X (cells) */
2369
+ x: number;
2370
+ /** Position Y (cells) */
2371
+ y: number;
2372
+ /** Tab index for keyboard navigation (0 = not focusable) */
2373
+ tabIndex?: number;
2374
+ /** Instance parameters */
2375
+ params?: Record<string, unknown>;
2376
+ }
2377
+ /**
2378
+ * MacroRegistry - Manages macro templates and instances
2379
+ */
2380
+ declare class MacroRegistry {
2381
+ private macros;
2382
+ private macroNameToId;
2383
+ private nextMacroId;
2384
+ private instances;
2385
+ private instanceNameToId;
2386
+ private nextInstanceId;
2387
+ private layerNameToId;
2388
+ private pendingOrders;
2389
+ /**
2390
+ * Register a macro template
2391
+ *
2392
+ * @param template - The macro template definition
2393
+ * @returns The assigned macro ID
2394
+ */
2395
+ registerMacro(template: MacroTemplate): number;
2396
+ /**
2397
+ * Get macro template by name
2398
+ */
2399
+ getMacroByName(name: string): MacroEntry | undefined;
2400
+ /**
2401
+ * Get macro template by ID
2402
+ */
2403
+ getMacroById(macroId: number): MacroEntry | undefined;
2404
+ /**
2405
+ * Get macro ID by name
2406
+ */
2407
+ getMacroId(name: string): number | undefined;
2408
+ /**
2409
+ * Generate MacroLoad packet for a template
2410
+ */
2411
+ toMacroLoad(macroId: number): MacroLoad | undefined;
2412
+ /**
2413
+ * Generate all MacroLoad packets
2414
+ */
2415
+ toAllMacroLoads(): MacroLoad[];
2416
+ /**
2417
+ * Set layer name → ID mapping (called by User when layers change)
2418
+ */
2419
+ setLayerMapping(layerName: string, layerId: number): void;
2420
+ /**
2421
+ * Create a new macro instance
2422
+ * Generates a CreateInstanceOrder for the next update packet
2423
+ *
2424
+ * @param config - Instance configuration
2425
+ * @returns The assigned instance ID, or undefined if macro/layer not found
2426
+ */
2427
+ createInstance(config: CreateInstanceConfig): number | undefined;
2428
+ /**
2429
+ * Update an existing instance's parameters
2430
+ *
2431
+ * @param name - Instance name
2432
+ * @param params - Parameters to update (merged with existing)
2433
+ * @returns true if instance was found and updated
2434
+ */
2435
+ updateInstance(name: string, params: Record<string, unknown>): boolean;
2436
+ /**
2437
+ * Remove an instance
2438
+ *
2439
+ * @param name - Instance name
2440
+ * @returns true if instance was found and removed
2441
+ */
2442
+ removeInstance(name: string): boolean;
2443
+ /**
2444
+ * Get instance by name
2445
+ */
2446
+ getInstanceByName(name: string): MacroInstanceEntry | undefined;
2447
+ /**
2448
+ * Get instance by ID
2449
+ */
2450
+ getInstanceById(instanceId: number): MacroInstanceEntry | undefined;
2451
+ /**
2452
+ * Get instance name by ID (for event handling)
2453
+ */
2454
+ getInstanceName(instanceId: number): string | undefined;
2455
+ /**
2456
+ * Get pending orders and clear the queue
2457
+ * Called by UpdatePacketEncoder to include macro orders
2458
+ */
2459
+ flushPendingOrders(): AnyMacroOrder[];
2460
+ /**
2461
+ * Check if there are pending orders
2462
+ */
2463
+ hasPendingOrders(): boolean;
2464
+ /**
2465
+ * Get all active instances
2466
+ */
2467
+ getAllInstances(): MacroInstanceEntry[];
2468
+ /**
2469
+ * Clear all instances (but keep templates)
2470
+ */
2471
+ clearInstances(): void;
2472
+ /**
2473
+ * Clear everything (templates and instances)
2474
+ */
2475
+ clear(): void;
2476
+ }
2477
+
1512
2478
  /**
1513
2479
  * InputBindingRegistry - Input bindings registry
1514
2480
  *
@@ -1945,6 +2911,9 @@ declare class User<TData = Record<string, any>> {
1945
2911
  private loadedSounds;
1946
2912
  private soundLoadErrors;
1947
2913
  private playingSounds;
2914
+ private macroRegistry;
2915
+ private macroEngine;
2916
+ private macroEventHandlers;
1948
2917
  /**
1949
2918
  * Application-specific data storage
1950
2919
  * Use this to store game state, player data, or any custom information
@@ -1975,13 +2944,21 @@ declare class User<TData = Record<string, any>> {
1975
2944
  */
1976
2945
  clearDisplays(): void;
1977
2946
  getLayers(): Layer[];
2947
+ /**
2948
+ * Gets a layer by its ID
2949
+ *
2950
+ * @param layerId - The layer ID to find
2951
+ * @returns The layer, or undefined if not found
2952
+ */
2953
+ getLayerById(layerId: number): Layer | undefined;
1978
2954
  /**
1979
2955
  * Adds a layer to the user
1980
2956
  * Layers are shared across all displays
1981
2957
  *
1982
2958
  * @param layer - The layer to add
2959
+ * @param name - Optional name for macro system (used in createInstance)
1983
2960
  */
1984
- addLayer(layer: Layer): void;
2961
+ addLayer(layer: Layer, name?: string): void;
1985
2962
  /**
1986
2963
  * Removes a layer from the user
1987
2964
  *
@@ -3007,6 +3984,205 @@ declare class User<TData = Record<string, any>> {
3007
3984
  * Get the number of sounds currently playing on the client
3008
3985
  */
3009
3986
  getPlayingSoundCount(): number;
3987
+ /**
3988
+ * Load a macro template
3989
+ * The template will be sent to the client in the next config packet
3990
+ *
3991
+ * @param name - Template name (used for createInstance)
3992
+ * @param template - Macro template definition
3993
+ * @returns The assigned macro ID
3994
+ *
3995
+ * @example
3996
+ * ```typescript
3997
+ * user.loadMacro('button', {
3998
+ * id: 'button',
3999
+ * type: 'ui',
4000
+ * params: { text: 'string', width: 'number' },
4001
+ * base: [{ fillRect: [0, 0, '$width', 3, ' ', '$fg', '$bg'] }],
4002
+ * states: { normal: { fg: '#FFFFFF', bg: '#333333' } }
4003
+ * });
4004
+ * ```
4005
+ */
4006
+ loadMacro(name: string, template: MacroTemplate): number;
4007
+ /**
4008
+ * Create a macro instance
4009
+ * The instance will be created on the client in the next update packet
4010
+ *
4011
+ * @param config - Instance configuration
4012
+ * @returns The assigned instance ID, or undefined if macro/layer not found
4013
+ *
4014
+ * @example
4015
+ * ```typescript
4016
+ * user.createInstance({
4017
+ * id: 'btn-play',
4018
+ * macro: 'button',
4019
+ * layer: 'ui',
4020
+ * x: 10, y: 5,
4021
+ * tabIndex: 1,
4022
+ * params: { text: 'Play', width: 8 }
4023
+ * });
4024
+ * ```
4025
+ */
4026
+ createInstance(config: CreateInstanceConfig): number | undefined;
4027
+ /**
4028
+ * Update a macro instance's parameters
4029
+ *
4030
+ * @param name - Instance name
4031
+ * @param params - Parameters to update (merged with existing)
4032
+ * @returns true if instance was found and updated
4033
+ *
4034
+ * @example
4035
+ * ```typescript
4036
+ * user.updateInstance('weather', { intensity: 20 });
4037
+ * ```
4038
+ */
4039
+ updateInstance(name: string, params: Record<string, unknown>): boolean;
4040
+ /**
4041
+ * Remove a macro instance
4042
+ *
4043
+ * @param name - Instance name
4044
+ * @returns true if instance was found and removed
4045
+ *
4046
+ * @example
4047
+ * ```typescript
4048
+ * user.removeInstance('btn-play');
4049
+ * ```
4050
+ */
4051
+ removeInstance(name: string): boolean;
4052
+ /**
4053
+ * Register a handler for macro events
4054
+ *
4055
+ * @param instanceName - Instance name to listen to
4056
+ * @param eventType - Event type ('click', 'change', 'submit', 'select')
4057
+ * @param handler - Handler function
4058
+ *
4059
+ * @example
4060
+ * ```typescript
4061
+ * user.onMacroEvent('btn-play', 'click', () => {
4062
+ * console.log('Play button clicked!');
4063
+ * });
4064
+ *
4065
+ * user.onMacroEvent('slider-volume', 'change', (value: number) => {
4066
+ * console.log('Volume changed to:', value);
4067
+ * });
4068
+ * ```
4069
+ */
4070
+ onMacroEvent(instanceName: string, eventType: string, handler: (data?: unknown) => void): void;
4071
+ /**
4072
+ * Remove a macro event handler
4073
+ *
4074
+ * @param instanceName - Instance name
4075
+ * @param eventType - Event type to remove (optional, removes all if not specified)
4076
+ */
4077
+ offMacroEvent(instanceName: string, eventType?: string): void;
4078
+ /**
4079
+ * Handle a macro event received from the client
4080
+ * @internal - Called by the server runtime
4081
+ */
4082
+ handleMacroEvent(event: AnyMacroEvent): void;
4083
+ /**
4084
+ * Get pending macro orders for the next update packet
4085
+ * @internal - Called by UpdatePacketEncoder
4086
+ */
4087
+ flushMacroOrders(): AnyMacroOrder[];
4088
+ /**
4089
+ * Check if there are pending macro orders
4090
+ * @internal
4091
+ */
4092
+ hasPendingMacroOrders(): boolean;
4093
+ /**
4094
+ * Apply macro orders directly (for standalone/local mode)
4095
+ *
4096
+ * This is the local equivalent of receiving macro orders via network.
4097
+ * In local mode, macro orders don't go through encode/decode - they're
4098
+ * applied directly to the MacroEngine.
4099
+ *
4100
+ * @param orders - Array of macro orders to apply
4101
+ * @internal
4102
+ */
4103
+ applyMacroOrders(orders: AnyMacroOrder[]): void;
4104
+ /**
4105
+ * Get the macro registry (for advanced usage)
4106
+ * @internal
4107
+ */
4108
+ getMacroRegistry(): MacroRegistry;
4109
+ /**
4110
+ * Get all MacroLoad packets for this user's registered macros
4111
+ * @internal - Called by Core.generateAllLoadPackets()
4112
+ */
4113
+ getMacroLoads(): MacroLoad[];
4114
+ /**
4115
+ * Update layer name → ID mappings in the macro registry
4116
+ * @internal
4117
+ */
4118
+ private updateLayerMappings;
4119
+ /**
4120
+ * Register a layer with a name for macro system
4121
+ * This maps a layer name to its ID for createInstance()
4122
+ *
4123
+ * @param name - Layer name (used in createInstance)
4124
+ * @param layer - The layer object
4125
+ */
4126
+ registerLayerName(name: string, layer: Layer): void;
4127
+ /**
4128
+ * Load a macro template into the client-side MacroEngine
4129
+ * Called when receiving a LoadType.Macro packet
4130
+ *
4131
+ * @param macroId - The numeric ID of the macro
4132
+ * @param template - The macro template
4133
+ * @internal
4134
+ */
4135
+ loadMacroTemplate(macroId: number, template: MacroTemplate): void;
4136
+ /**
4137
+ * Update the client-side macro engine
4138
+ * Should be called once per tick (tick-based updates)
4139
+ *
4140
+ * @returns Update result with events and sounds to play
4141
+ */
4142
+ updateMacros(): MacroUpdateResult;
4143
+ /**
4144
+ * Update mouse state for the macro engine
4145
+ * Converts display-local coordinates to world coordinates using the display's origin
4146
+ *
4147
+ * @param displayX - Mouse X position in display cells (local to display)
4148
+ * @param displayY - Mouse Y position in display cells (local to display)
4149
+ * @param isDown - Whether the mouse button is pressed
4150
+ */
4151
+ updateMacroMouse(displayX: number, displayY: number, isDown: boolean): void;
4152
+ /**
4153
+ * Get render orders generated by the macro engine, grouped by layer
4154
+ * Orders are converted from world coordinates to display coordinates
4155
+ * by subtracting the display's origin.
4156
+ *
4157
+ * @returns Map of layerId → render orders (in display coordinates)
4158
+ */
4159
+ getMacroRenderOrders(): Map<number, AnyNetworkOrder[]>;
4160
+ /**
4161
+ * Get the effect offset (for screen shake, etc.)
4162
+ *
4163
+ * @returns Current offset from effect macros
4164
+ */
4165
+ getMacroEffectOffset(): {
4166
+ x: number;
4167
+ y: number;
4168
+ };
4169
+ /**
4170
+ * Get the macro engine (for advanced usage)
4171
+ * @internal
4172
+ */
4173
+ getMacroEngine(): MacroEngine;
4174
+ /**
4175
+ * Move focus to next focusable macro element
4176
+ */
4177
+ macroFocusNext(): void;
4178
+ /**
4179
+ * Move focus to previous focusable macro element
4180
+ */
4181
+ macroFocusPrevious(): void;
4182
+ /**
4183
+ * Activate the currently focused macro element
4184
+ */
4185
+ macroActivateFocused(): void;
3010
4186
  }
3011
4187
 
3012
4188
  /**
@@ -4183,6 +5359,13 @@ declare class Core {
4183
5359
  * ```
4184
5360
  */
4185
5361
  generateAllLoadPackets(): Uint8Array[];
5362
+ /**
5363
+ * Generates MacroLoad packets for a specific user's registered macros
5364
+ *
5365
+ * @param userId - Target user ID
5366
+ * @returns Array of encoded MacroLoad packets
5367
+ */
5368
+ generateMacroLoadPackets(userId: string): Uint8Array[];
4186
5369
  /**
4187
5370
  * Applies Input Bindings to a user (CLIENT-SIDE)
4188
5371
  *
@@ -4985,20 +6168,22 @@ declare function getASCII8x8FontConfig(): {
4985
6168
  * - SERVER: Receives → Decompresses → Stores in axes/buttons Maps
4986
6169
  *
4987
6170
  * MINIMALIST Format (V3):
4988
- * ┌────────┬───────────┬─────────────┬────────┬──────────┐
4989
- * │ Tick │ Axes │ Buttons │ Mouse │ Flags │
4990
- * │ 8 bytes│ N bytes │ M bytes │ 3 bytes│ 1 byte │
4991
- * └────────┴───────────┴─────────────┴────────┴──────────┘
6171
+ * ┌────────┬───────────┬─────────────┬────────┬──────────┬─────────────┐
6172
+ * │ Tick │ Axes │ Buttons │ Mouse │ Flags │ MacroEvents │
6173
+ * │ 8 bytes│ N bytes │ M bytes │ 3 bytes│ 1 byte │ variable │
6174
+ * └────────┴───────────┴─────────────┴────────┴──────────┴─────────────┘
4992
6175
  *
4993
6176
  * Tick (8 bytes) : Frame number (uint64, little-endian)
4994
6177
  * Axes (N bytes) : 1 byte per axis (int8, -127 to +127)
4995
6178
  * Buttons (M bytes) : Bitpacking (8 buttons per byte, ⌈ButtonCount/8⌉)
4996
6179
  * Mouse (3 bytes) : displayId (1) + mouseX (1) + mouseY (1)
4997
6180
  * Flags (1 byte) : Bit 0 = mouseOverDisplay
6181
+ * MacroEvents (var) : 1 byte count + encoded events (see MacroEventEncoder)
4998
6182
  *
4999
6183
  * Note: axisCount and buttonCount are known in advance via InputBindingRegistry
5000
- * Example: 5 axes + 12 buttons = 8 + 5 + 2 + 3 + 1 = 19 bytes
6184
+ * Example: 5 axes + 12 buttons = 8 + 5 + 2 + 3 + 1 = 19 bytes (+ macro events)
5001
6185
  */
6186
+
5002
6187
  /**
5003
6188
  * Represents a compressed input on the server side (after decoding)
5004
6189
  *
@@ -5007,6 +6192,7 @@ declare function getASCII8x8FontConfig(): {
5007
6192
  * - Buttons: boolean
5008
6193
  * - Mouse: position + display + flags
5009
6194
  * - TextInputs: array of key strings for text input (e.g., ['a', 'Backspace', 'Enter'])
6195
+ * - MacroEvents: array of macro events (clicks, changes, submits, selects)
5010
6196
  */
5011
6197
  interface CompressedInputPacket {
5012
6198
  /** Frame number (tick) - uint64 */
@@ -5025,6 +6211,8 @@ interface CompressedInputPacket {
5025
6211
  mouseOverDisplay: boolean;
5026
6212
  /** Text input events (e.g., ['a', 'Backspace', 'Enter']) - for input boxes, chat, etc. */
5027
6213
  textInputs: string[];
6214
+ /** Macro events (clicks, changes, submits, selects) from client-side macros */
6215
+ macroEvents: AnyMacroEvent[];
5028
6216
  }
5029
6217
  /**
5030
6218
  * Creates an empty CompressedInputPacket
@@ -5112,11 +6300,14 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
5112
6300
  * - Buttons: boolean → bitpacking = 8 buttons per byte
5113
6301
  * - DisplayId: uint8 (1 byte) = display ID
5114
6302
  * - Mouse: mouseX/Y (uint8) + flags = 3 bytes
6303
+ * - TextInputs: 1 byte count + length-prefixed strings
6304
+ * - MacroEvents: 1 byte count + encoded events
5115
6305
  *
5116
6306
  * PREREQUISITE: Client and server must have the SAME bindings defined!
5117
6307
  *
5118
- * Example: 5 axes + 12 buttons + mouse = 19 bytes total
6308
+ * Example: 5 axes + 12 buttons + mouse = 19 bytes total (+ text inputs + macro events)
5119
6309
  */
6310
+
5120
6311
  /**
5121
6312
  * Encodes inputs in compact binary format v3 (CLIENT-SIDE)
5122
6313
  *
@@ -5127,6 +6318,8 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
5127
6318
  * @param mouseX - Mouse X position (0-255)
5128
6319
  * @param mouseY - Mouse Y position (0-255)
5129
6320
  * @param mouseOverDisplay - Is the mouse over a display?
6321
+ * @param textInputs - Array of text input strings
6322
+ * @param macroEvents - Array of macro events (clicks, changes, submits, selects)
5130
6323
  * @returns Encoded buffer (without counts, minimalist format)
5131
6324
  *
5132
6325
  * @example
@@ -5134,10 +6327,10 @@ declare function getCompressedPacketSize(axisCount: number, buttonCount: number)
5134
6327
  * const axes = new Map([[0, -0.7], [1, 0.5]]);
5135
6328
  * const buttons = new Map([[0, true], [1, false], [2, true]]);
5136
6329
  * const buffer = encodeCompressedInput(42n, axes, buttons, 0, 128, 64, true);
5137
- * // buffer.length = 8 + 2 + 1 + 4 = 15 bytes
6330
+ * // buffer.length = 8 + 2 + 1 + 4 = 15 bytes (+ text inputs + macro events)
5138
6331
  * ```
5139
6332
  */
5140
- declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>, buttons: Map<number, boolean>, displayId: number, mouseX: number, mouseY: number, mouseOverDisplay: boolean, textInputs?: string[]): Uint8Array;
6333
+ 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[]): Uint8Array;
5141
6334
 
5142
6335
  /**
5143
6336
  * CompressedInputDecoder - Decodes inputs from compact binary format
@@ -5158,9 +6351,11 @@ declare function encodeCompressedInput(tick: bigint, axes: Map<number, number>,
5158
6351
  * - Buttons: bitpacking → boolean (8 buttons per byte)
5159
6352
  * - DisplayId: uint8 (1 byte) = display ID
5160
6353
  * - Mouse: uint8 → mouseX/Y + flags (mouseOverDisplay)
6354
+ * - TextInputs: 1 byte count + length-prefixed strings
6355
+ * - MacroEvents: 1 byte count + encoded events
5161
6356
  *
5162
6357
  * Example (2 axes, 3 buttons):
5163
- * - Tick (8) + Axes (2) + Buttons (1) + DisplayId (1) + Mouse (3) = 15 bytes
6358
+ * - Tick (8) + Axes (2) + Buttons (1) + DisplayId (1) + Mouse (3) = 15 bytes (+ text inputs + macro events)
5164
6359
  */
5165
6360
 
5166
6361
  /**
@@ -5520,6 +6715,75 @@ declare class OrderBuilder {
5520
6715
  * @param options.charCode - Character as string ('+') or charCode (0x2b)
5521
6716
  */
5522
6717
  static grid(startX: number, startY: number, cellWidth: number, cellHeight: number, rows: number, cols: number, options?: ColorOptions): DotCloudOrder;
6718
+ /**
6719
+ * 0x19 - Polyline: Connected line segments through multiple points
6720
+ * Uses Bresenham algorithm to draw lines between consecutive points
6721
+ *
6722
+ * @param points - Array of points to connect (minimum 2 for a line)
6723
+ * @param char - Character as string ('*') or charCode (0x2A)
6724
+ * @param fgColor - Foreground color (default: 15 = white)
6725
+ * @param bgColor - Background color (default: 0 = black)
6726
+ *
6727
+ * @example Simple line
6728
+ * ```typescript
6729
+ * OrderBuilder.polyline(
6730
+ * [{ x: 0, y: 0 }, { x: 10, y: 5 }],
6731
+ * '*', 14, 0
6732
+ * )
6733
+ * ```
6734
+ *
6735
+ * @example Path with multiple points
6736
+ * ```typescript
6737
+ * OrderBuilder.polyline(
6738
+ * [
6739
+ * { x: 10, y: 10 },
6740
+ * { x: 20, y: 15 },
6741
+ * { x: 30, y: 10 },
6742
+ * { x: 40, y: 20 }
6743
+ * ],
6744
+ * '#', 11, 0
6745
+ * )
6746
+ * ```
6747
+ */
6748
+ static polyline(points: Array<{
6749
+ x: number;
6750
+ y: number;
6751
+ }>, char?: string | number, fgColor?: number, bgColor?: number): PolylineOrder;
6752
+ /**
6753
+ * Helper: Create a polyline from flat coordinate array
6754
+ * @param coords - Flat array of coordinates [x1, y1, x2, y2, ...]
6755
+ * @param char - Character as string ('*') or charCode
6756
+ *
6757
+ * @example
6758
+ * ```typescript
6759
+ * OrderBuilder.polylineFromCoords(
6760
+ * [0, 0, 10, 5, 20, 0], // 3 points
6761
+ * '-', 14
6762
+ * )
6763
+ * ```
6764
+ */
6765
+ static polylineFromCoords(coords: number[], char?: string | number, fgColor?: number, bgColor?: number): PolylineOrder;
6766
+ /**
6767
+ * Helper: Create a closed polygon (polyline that returns to start)
6768
+ * @param points - Array of points forming the polygon
6769
+ * @param char - Character as string ('*') or charCode
6770
+ *
6771
+ * @example Triangle
6772
+ * ```typescript
6773
+ * OrderBuilder.polygon(
6774
+ * [
6775
+ * { x: 20, y: 5 },
6776
+ * { x: 10, y: 15 },
6777
+ * { x: 30, y: 15 }
6778
+ * ],
6779
+ * '#', 12
6780
+ * )
6781
+ * ```
6782
+ */
6783
+ static polygon(points: Array<{
6784
+ x: number;
6785
+ y: number;
6786
+ }>, char?: string | number, fgColor?: number, bgColor?: number): PolylineOrder;
5523
6787
  }
5524
6788
 
5525
6789
  /**
@@ -5569,6 +6833,7 @@ declare const DOTCLOUD_MULTICOLOR_ORDER_MIN_SIZE = 3;
5569
6833
  declare const BITMASK_ORDER_MIN_SIZE = 9;
5570
6834
  declare const BITMASK4_ORDER_MIN_SIZE = 15;
5571
6835
  declare const BITMASK16_ORDER_MIN_SIZE = 51;
6836
+ declare const POLYLINE_ORDER_MIN_SIZE = 5;
5572
6837
  declare const SPRITECLOUD_ORDER_MIN_SIZE = 6;
5573
6838
  declare const SPRITECLOUD_MULTICOLOR_ORDER_MIN_SIZE = 4;
5574
6839
  declare const SPRITECLOUD_VARIED_ORDER_MIN_SIZE = 3;
@@ -5688,6 +6953,11 @@ declare enum OrderType {
5688
6953
  * 4 bits per cell: 0 = absence, 1-15 = variant index
5689
6954
  */
5690
6955
  Bitmask16 = 24,
6956
+ /**
6957
+ * 0x19 - Polyline: Renders a line connecting multiple points
6958
+ * Uses Bresenham algorithm to draw between consecutive points
6959
+ */
6960
+ Polyline = 25,
5691
6961
  /**
5692
6962
  * 0x13 - Clear: Fills entire layer with single character and colors
5693
6963
  */
@@ -5893,6 +7163,7 @@ declare class UpdatePacketDecoder {
5893
7163
  private displayDecoder;
5894
7164
  private layerDecoder;
5895
7165
  private audioOrderDecoder;
7166
+ private macroOrderDecoder;
5896
7167
  constructor();
5897
7168
  /**
5898
7169
  * Decodes an UpdatePacket from binary buffer
@@ -5905,8 +7176,10 @@ declare class UpdatePacketDecoder {
5905
7176
  * - Layers: variable (encoded layers)
5906
7177
  * - AudioOrderCount: 1 byte (max 255 audio orders)
5907
7178
  * - AudioOrders: variable (encoded audio orders)
7179
+ * - MacroOrderCount: 1 byte (max 255 macro orders)
7180
+ * - MacroOrders: variable (encoded macro orders)
5908
7181
  *
5909
- * Minimum packet size: 12 bytes (Tick + DisplayCount + LayerCount + AudioOrderCount)
7182
+ * Minimum packet size: 13 bytes (Tick + DisplayCount + LayerCount + AudioOrderCount + MacroOrderCount)
5910
7183
  */
5911
7184
  decode(data: Uint8Array, offset?: number): UpdatePacket;
5912
7185
  /**
@@ -5915,7 +7188,7 @@ declare class UpdatePacketDecoder {
5915
7188
  */
5916
7189
  isValid(data: Uint8Array, offset?: number): boolean;
5917
7190
  /**
5918
- * Decodes only the tick and counts without decoding the displays/layers/audio
7191
+ * Decodes only the tick and counts without decoding the displays/layers/audio/macros
5919
7192
  * Useful for quick inspection of packet metadata
5920
7193
  */
5921
7194
  decodeHeader(data: Uint8Array, offset?: number): {
@@ -5923,6 +7196,7 @@ declare class UpdatePacketDecoder {
5923
7196
  displayCount: number;
5924
7197
  layerCount: number;
5925
7198
  audioOrderCount?: number;
7199
+ macroOrderCount?: number;
5926
7200
  };
5927
7201
  private checkSize;
5928
7202
  }
@@ -5985,6 +7259,10 @@ declare class BufferCompat {
5985
7259
  writeBigInt64BE(value: bigint, offset: number): void;
5986
7260
  writeBigUInt64LE(value: bigint, offset: number): void;
5987
7261
  writeBigInt64LE(value: bigint, offset: number): void;
7262
+ readFloatBE(offset: number): number;
7263
+ readFloatLE(offset: number): number;
7264
+ writeFloatBE(value: number, offset: number): void;
7265
+ writeFloatLE(value: number, offset: number): void;
5988
7266
  /**
5989
7267
  * Copies data from this buffer to another
5990
7268
  * @param target Destination buffer
@@ -6164,5 +7442,5 @@ declare class AudioOrderCollector {
6164
7442
  private encodeReverb;
6165
7443
  }
6166
7444
 
6167
- 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, InputBindingRegistry, LAYER_CELL_COUNT, LAYER_HEADER_SIZE, LAYER_SIZE, LINE_SHAPE_SIZE, Layer, LoadType, OrderBuilder, OrderType, PlaySoundFlags, 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, TRIGGERGLOBALSOUND_ORDER_SIZE, TRIGGERSOUND_ORDER_SIZE, UPDATE_PACKET_HEADER_SIZE, UpdateFlags, UpdateFlagsHelper, UpdatePacketDecoder, User, UserStats, WebFont, WebFontRegistry, createASCII8x8FontLoad, createEmptyCompressedInputPacket, decodeCompressedInput, decodeInt8ToAxis, encodeAxisToInt8, encodeCompressedInput, getASCII8x8FontConfig, getAllCharCodes, getAudioOrderTypeName, getButtonByteCount, getCharBitmap, getCompressedPacketSize, getOrderTypeName, hasChar, isValidAudioOrderType, isValidOrderType };
6168
- export type { AnyAudioOrder, AnyLoad, AudioOrder, BitmapFontConfig, BitmapFontLoad, Bitmask16Order, Bitmask16Variant, Bitmask4Order, Bitmask4Variant, BitmaskOrder, Cell, CircleShape, Color, ColorPaletteLoad, CompressedInputPacket, ConfigureSpatialOrder, CoreMode, CoreOptions, EllipseShape, FadeOutSoundOrder, LineShape, MulticolorCell, MulticolorSprite, MulticolorSpriteLoad, NetworkDisplay, NetworkLayer, PauseSoundOrder, PlayGlobalSoundOrder, PlaySoundOrder, RectangleShape, ResumeSoundOrder, SetListenerPositionOrder, SetSoundEffectsOrder, ShapeData, SoundEntry, SoundLoad, SpriteLoad, StopSoundOrder, TickStats, TriangleShape, UnicolorSprite, UpdatePacket, UserTickStats, WebFontConfig, WebFontLoad };
7445
+ 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, InputBindingRegistry, LAYER_CELL_COUNT, LAYER_HEADER_SIZE, LAYER_SIZE, LINE_SHAPE_SIZE, Layer, LoadType, MacroEngine, MacroEventType, MacroOrderType, MacroRegistry, OrderBuilder, OrderType, POLYLINE_ORDER_MIN_SIZE, PlaySoundFlags, 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, TRIGGERGLOBALSOUND_ORDER_SIZE, TRIGGERSOUND_ORDER_SIZE, UPDATE_PACKET_HEADER_SIZE, UpdateFlags, UpdateFlagsHelper, UpdatePacketDecoder, User, UserStats, WebFont, WebFontRegistry, createASCII8x8FontLoad, createEmptyCompressedInputPacket, decodeCompressedInput, decodeInt8ToAxis, encodeAxisToInt8, encodeCompressedInput, getASCII8x8FontConfig, getAllCharCodes, getAudioOrderTypeName, getButtonByteCount, getCharBitmap, getCompressedPacketSize, getMacroEventTypeName, getMacroOrderTypeName, getOrderTypeName, hasChar, isValidAudioOrderType, isValidMacroEventType, isValidMacroOrderType, isValidOrderType };
7446
+ export type { AnyAudioOrder, AnyLoad, AnyMacroEvent, AnyMacroOrder, AudioOrder, BitmapFontConfig, BitmapFontLoad, Bitmask16Order, Bitmask16Variant, Bitmask4Order, Bitmask4Variant, BitmaskOrder, ButtonBorderStyle, ButtonConfig, ButtonStateColors, Cell, ChangeEvent, CircleShape, ClickEvent, Color, ColorPaletteLoad, CompressedInputPacket, ConfigureSpatialOrder, CoreMode, CoreOptions, CreateInstanceConfig, CreateInstanceOrder, EffectMacroTemplate, EffectTransform, EllipseShape, FadeOutSoundOrder, LineMacroTemplate, LineShape, MacroEntry, MacroEvent, MacroInstanceEntry, MacroLoad, MacroOrder, MacroTemplate, MacroTemplateBase, MacroType, MacroUpdateResult, MulticolorCell, MulticolorSprite, MulticolorSpriteLoad, NetworkDisplay, NetworkLayer, ParticleConfig, ParticleEmitter, ParticleMacroTemplate, PauseSoundOrder, PlayGlobalSoundOrder, PlaySoundOrder, RectangleShape, RemoveInstanceOrder, RenderCommand, ResumeSoundOrder, RevealCellDef, RevealContent, RevealContentType, RevealCursor, RevealDirection, RevealMacroTemplate, RevealPattern, RevealPause, SelectEvent, SetListenerPositionOrder, SetSoundEffectsOrder, ShapeData, SoundEntry, SoundLoad, SpriteLoad, StopSoundOrder, SubmitEvent, TickStats, TriangleShape, UIMacroTemplate, UIState, UISubtype, UnicolorSprite, UpdateInstanceOrder, UpdatePacket, UserTickStats, WebFontConfig, WebFontLoad };