@utsp/core 0.15.0 → 0.16.0-nightly.20260101200530.42ed56f

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.
@@ -1,5 +1,5 @@
1
1
  import * as _utsp_types from '@utsp/types';
2
- import { ScalingModeValue, Vector2, AxisSource, ButtonSource, InputBindingLoadPacket, AxisBinding, ButtonBinding, TouchZoneBinding, SoundInstanceId, AudioConfigCommand, PlaySoundCommand, StopSoundCommand, FadeOutSoundCommand, PauseSoundCommand, ResumeSoundCommand, SetSoundEffectsCommand, IAudioProcessor, VibrationPattern, GamepadVibrationOptions, GamepadVibrationCommand, IGamepadVibrationProcessor, MobileVibrationCommand, IMobileVibrationProcessor, AudioAck, PostProcessConfig, PostProcessCommand, ScalingMode, GridConfig, SoundFormat, SoundLoadType, SoundLoadPacket, SoundExternalLoadPacket, UserRenderState, RenderState } from '@utsp/types';
2
+ import { Vector2, ScalingModeValue, AxisSource, ButtonSource, InputBindingLoadPacket, AxisBinding, ButtonBinding, TouchZoneBinding, SoundInstanceId, AudioConfigCommand, PlaySoundCommand, StopSoundCommand, FadeOutSoundCommand, PauseSoundCommand, ResumeSoundCommand, SetSoundEffectsCommand, IAudioProcessor, VibrationPattern, GamepadVibrationOptions, GamepadVibrationCommand, IGamepadVibrationProcessor, MobileVibrationCommand, IMobileVibrationProcessor, AudioAck, PostProcessConfig, PostProcessCommand, ScalingMode, GridConfig, SoundFormat, SoundLoadType, SoundLoadPacket, SoundExternalLoadPacket, UserRenderState, RenderState } from '@utsp/types';
3
3
  export { Vector2 } from '@utsp/types';
4
4
 
5
5
  /**
@@ -425,6 +425,100 @@ declare class OrderEncoder {
425
425
  private encodeFillSpriteMultiColorOrder;
426
426
  }
427
427
 
428
+ interface RenderPassConfig {
429
+ id: number;
430
+ zMin: number;
431
+ zMax: number;
432
+ enabled?: boolean;
433
+ }
434
+ /**
435
+ * Represents a display (camera) in the virtual world
436
+ *
437
+ * ARCHITECTURE (new protocol):
438
+ * - Display = camera looking into the virtual world
439
+ * - LAYERS are NO LONGER in Display, they are at User level
440
+ * - Display only defines WHICH PART of the world we see (origin)
441
+ */
442
+ declare class Display {
443
+ private id;
444
+ private origin;
445
+ private size;
446
+ private previousOrigin;
447
+ private previousSize;
448
+ private toDraw;
449
+ private renderPasses;
450
+ constructor(id?: number, sizeX?: number, sizeY?: number);
451
+ /**
452
+ * Gets the display ID (0-255)
453
+ */
454
+ getId(): number;
455
+ /**
456
+ * Gets the origin position in the world
457
+ */
458
+ getOrigin(): Vector2;
459
+ /**
460
+ * Sets the origin position in the world
461
+ */
462
+ setOrigin(origin: Vector2): void;
463
+ /**
464
+ * Moves the origin in the world
465
+ */
466
+ moveOrigin(deltaX: number, deltaY: number): void;
467
+ /**
468
+ * Checks if display origin has changed since last tick
469
+ * @internal - Used to calculate if update should be sent
470
+ */
471
+ hasOriginChanged(): boolean;
472
+ /**
473
+ * Checks if display size has changed since last tick
474
+ * @internal - Used to calculate if update should be sent
475
+ */
476
+ hasSizeChanged(): boolean;
477
+ /**
478
+ * Checks if display has changed (origin OR size)
479
+ * @internal
480
+ */
481
+ hasChanged(): boolean;
482
+ /**
483
+ * Resets change tracking
484
+ * @internal - Called by Core.endTick() after sending updates
485
+ */
486
+ resetChangeTracking(): void;
487
+ /**
488
+ * Gets the display size
489
+ */
490
+ getSize(): Vector2;
491
+ /**
492
+ * Sets the display size
493
+ */
494
+ setSize(size: Vector2): void;
495
+ /**
496
+ * Returns the validated render passes (undefined = single pass [0,255])
497
+ */
498
+ getRenderPasses(): RenderPassConfig[] | undefined;
499
+ /**
500
+ * Sets the render passes configuration (0..4 passes). Applies clamping and swap.
501
+ * Passing undefined resets to single pass behavior.
502
+ */
503
+ setRenderPasses(passes: RenderPassConfig[] | undefined): void;
504
+ private normalizePass;
505
+ /**
506
+ * Returns a debug-friendly snapshot of this display (metadata only)
507
+ */
508
+ getDebugInfo(): {
509
+ id: number;
510
+ origin: {
511
+ x: number;
512
+ y: number;
513
+ };
514
+ size: {
515
+ x: number;
516
+ y: number;
517
+ };
518
+ renderPasses?: RenderPassConfig[];
519
+ };
520
+ }
521
+
428
522
  /**
429
523
  * Network representation of a display
430
524
  * Layers are NO LONGER under displays - they are at User level
@@ -440,6 +534,8 @@ interface NetworkDisplay {
440
534
  sizeX: number;
441
535
  /** Display height in cells (1-256) */
442
536
  sizeY: number;
537
+ /** Optional render pass configuration (max 4 passes) */
538
+ renderPasses?: RenderPassConfig[];
443
539
  }
444
540
 
445
541
  /**
@@ -459,13 +555,15 @@ declare class DisplayEncoder {
459
555
  * - OriginY: 2 bytes (big-endian)
460
556
  * - SizeX: 1 byte (1-256 encoded as 0-255)
461
557
  * - SizeY: 1 byte (1-256 encoded as 0-255)
558
+ * - PassCount: 1 byte (0-4 render passes)
559
+ * - RenderPasses (optional): 4 bytes each → Id(1) + zMin(1) + zMax(1) + flags(1)
462
560
  *
463
- * Total: 7 bytes per display
561
+ * Total: 8 bytes + (4 * passCount) per display
464
562
  */
465
563
  encode(display: NetworkDisplay): Uint8Array;
466
564
  /**
467
565
  * Calculates the size of an encoded display
468
- * Always 7 bytes in the new protocol (DisplayId + OriginX + OriginY + SizeX + SizeY)
566
+ * 8 bytes + 4 * passCount (DisplayId + OriginX + OriginY + SizeX + SizeY + PassCount + RenderPasses)
469
567
  */
470
568
  calculateSize(_display: NetworkDisplay): number;
471
569
  }
@@ -1736,6 +1834,8 @@ interface UpdatePacket {
1736
1834
  * - OriginY: 2 bytes (big-endian)
1737
1835
  * - SizeX: 1 byte (1-256, encoded as 0-255)
1738
1836
  * - SizeY: 1 byte (1-256, encoded as 0-255)
1837
+ * - PassCount: 1 byte (0-4 render passes)
1838
+ * - RenderPasses: 4 bytes each (Id + zMin + zMax + flags)
1739
1839
  * - LayerCount: 2 bytes (big-endian)
1740
1840
  * - For each Layer: (encoded by LayerEncoder)
1741
1841
  * - AudioOrderCount: 1 byte (max 255 audio orders per frame)
@@ -1753,6 +1853,7 @@ declare class UpdatePacketEncoder {
1753
1853
  private vibrationOrderEncoder;
1754
1854
  private macroOrderEncoder;
1755
1855
  private postProcessOrderEncoder;
1856
+ private displayEncoder;
1756
1857
  constructor();
1757
1858
  /**
1758
1859
  * Encodes an UpdatePacket to binary buffer
@@ -2543,8 +2644,10 @@ declare class DisplayDecoder {
2543
2644
  * - OriginY: 2 bytes (big-endian)
2544
2645
  * - SizeX: 1 byte (encoded as 0-255, actual value 1-256)
2545
2646
  * - SizeY: 1 byte (encoded as 0-255, actual value 1-256)
2647
+ * - PassCount: 1 byte (0-4 render passes)
2648
+ * - RenderPasses (optional): 4 bytes each → Id(1) + zMin(1) + zMax(1) + flags(1)
2546
2649
  *
2547
- * Total: 7 bytes per display
2650
+ * Total: 8 bytes + (4 * passCount) per display
2548
2651
  */
2549
2652
  decode(buffer: BufferCompat, offset?: number): DisplayDecodeResult;
2550
2653
  private checkSize;
@@ -2602,7 +2705,7 @@ declare class UpdatePacketDecoder {
2602
2705
  * Structure (NEW PROTOCOL):
2603
2706
  * - Tick: 8 bytes (big-endian, 64-bit unsigned integer)
2604
2707
  * - DisplayCount: 1 byte (8-bit unsigned integer, max 255 displays)
2605
- * - Displays: variable (DisplayId + OriginX + OriginY + SizeX + SizeY = 7 bytes each)
2708
+ * - Displays: variable (DisplayId + OriginX + OriginY + SizeX + SizeY + PassCount + RenderPasses)
2606
2709
  * - LayerCount: 2 bytes (big-endian, 16-bit unsigned integer)
2607
2710
  * - Layers: variable (encoded layers)
2608
2711
  * - AudioOrderCount: 1 byte (max 255 audio orders)
@@ -3675,82 +3778,6 @@ declare class MacroEngine {
3675
3778
  clear(): void;
3676
3779
  }
3677
3780
 
3678
- /**
3679
- * Represents a display (camera) in the virtual world
3680
- *
3681
- * ARCHITECTURE (new protocol):
3682
- * - Display = camera looking into the virtual world
3683
- * - LAYERS are NO LONGER in Display, they are at User level
3684
- * - Display only defines WHICH PART of the world we see (origin)
3685
- */
3686
- declare class Display {
3687
- private id;
3688
- private origin;
3689
- private size;
3690
- private previousOrigin;
3691
- private previousSize;
3692
- private toDraw;
3693
- constructor(id?: number, sizeX?: number, sizeY?: number);
3694
- /**
3695
- * Gets the display ID (0-255)
3696
- */
3697
- getId(): number;
3698
- /**
3699
- * Gets the origin position in the world
3700
- */
3701
- getOrigin(): Vector2;
3702
- /**
3703
- * Sets the origin position in the world
3704
- */
3705
- setOrigin(origin: Vector2): void;
3706
- /**
3707
- * Moves the origin in the world
3708
- */
3709
- moveOrigin(deltaX: number, deltaY: number): void;
3710
- /**
3711
- * Checks if display origin has changed since last tick
3712
- * @internal - Used to calculate if update should be sent
3713
- */
3714
- hasOriginChanged(): boolean;
3715
- /**
3716
- * Checks if display size has changed since last tick
3717
- * @internal - Used to calculate if update should be sent
3718
- */
3719
- hasSizeChanged(): boolean;
3720
- /**
3721
- * Checks if display has changed (origin OR size)
3722
- * @internal
3723
- */
3724
- hasChanged(): boolean;
3725
- /**
3726
- * Resets change tracking
3727
- * @internal - Called by Core.endTick() after sending updates
3728
- */
3729
- resetChangeTracking(): void;
3730
- /**
3731
- * Gets the display size
3732
- */
3733
- getSize(): Vector2;
3734
- /**
3735
- * Sets the display size
3736
- */
3737
- setSize(size: Vector2): void;
3738
- /**
3739
- * Returns a debug-friendly snapshot of this display (metadata only)
3740
- */
3741
- getDebugInfo(): {
3742
- id: number;
3743
- origin: {
3744
- x: number;
3745
- y: number;
3746
- };
3747
- size: {
3748
- x: number;
3749
- y: number;
3750
- };
3751
- };
3752
- }
3753
-
3754
3781
  /**
3755
3782
  * MacroRegistry - Registry for macro templates and instances
3756
3783
  *
@@ -9053,6 +9080,8 @@ declare class DisplayRasterizer {
9053
9080
  private opacityBuffer;
9054
9081
  private visibleLayersBuffer;
9055
9082
  private visibleLayerIdsBuffer;
9083
+ private passCellsBuffers;
9084
+ private passOpacityBuffers;
9056
9085
  /**
9057
9086
  * Last computed visible layer IDs (sorted in actual composition order).
9058
9087
  * Updated on every rasterize() call.
@@ -9085,7 +9114,13 @@ declare class DisplayRasterizer {
9085
9114
  * @param layers - All user layers
9086
9115
  * @returns Render state with palette indices + RGB palette
9087
9116
  */
9088
- rasterize(origin: DisplayOrigin, layers: Layer[]): RenderState;
9117
+ rasterize(origin: DisplayOrigin, layers: Layer[], renderPasses?: RenderPassConfig[]): RenderState;
9118
+ private rasterizeSinglePass;
9119
+ private rasterizeMultiPass;
9120
+ private composePass;
9121
+ private preparePassBuffers;
9122
+ private ensurePassBuffers;
9123
+ private normalizePasses;
9089
9124
  /**
9090
9125
  * Variant that accepts an already sorted layer array (optimization)
9091
9126
  * Note: Still applies visibility filtering for optimization