@utsp/core 0.17.0-nightly.20260125201607.c6707a1 → 0.17.0-nightly.20260127111647.165f2b8

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
@@ -1476,6 +1476,75 @@ interface ImageFontBlockLoad {
1476
1476
  */
1477
1477
  type AnyLoad = ColorPaletteLoad | SpriteLoad | MulticolorSpriteLoad | SoundLoad | MacroLoad | ImageFontLoad | ImageFontBlockLoad;
1478
1478
 
1479
+ /**
1480
+ * Public-facing types for Sprite Loading API
1481
+ * These types hide internal implementation details like LoadType
1482
+ * and support flexible input formats (strings, numbers, etc.)
1483
+ */
1484
+ /**
1485
+ * Single Multicolor Cell definition
1486
+ */
1487
+ interface MulticolorSpriteCell {
1488
+ /**
1489
+ * Character as a string (first char used) or numeric char code (0-65535).
1490
+ * Automatically converted to CP437 if a string is provided.
1491
+ */
1492
+ charCode: string | number;
1493
+ /**
1494
+ * Foreground color ID (0-255)
1495
+ */
1496
+ fgColorId: number;
1497
+ /**
1498
+ * Background color ID (0-255)
1499
+ */
1500
+ bgColorId: number;
1501
+ }
1502
+ /**
1503
+ * Definition for a Unicolor Sprite
1504
+ */
1505
+ interface UnicolorSpriteDefinition {
1506
+ /**
1507
+ * Unique sprite identifier (0-255)
1508
+ */
1509
+ spriteId: number;
1510
+ /**
1511
+ * Width in cells (1-255)
1512
+ */
1513
+ sizeX: number;
1514
+ /**
1515
+ * Height in cells (1-255)
1516
+ */
1517
+ sizeY: number;
1518
+ /**
1519
+ * Sprite data. Can be:
1520
+ * - Flat array of numbers (char codes)
1521
+ * - Single string (will be treated as a sequence of characters)
1522
+ * - Array of strings (one per row)
1523
+ */
1524
+ data: number[] | string | string[];
1525
+ }
1526
+ /**
1527
+ * Definition for a Multicolor Sprite
1528
+ */
1529
+ interface MulticolorSpriteDefinition {
1530
+ /**
1531
+ * Unique sprite identifier (0-255)
1532
+ */
1533
+ spriteId: number;
1534
+ /**
1535
+ * Width in cells (1-255)
1536
+ */
1537
+ sizeX: number;
1538
+ /**
1539
+ * Height in cells (1-255)
1540
+ */
1541
+ sizeY: number;
1542
+ /**
1543
+ * Array of multicolor cells (row-major order, length = sizeX * sizeY)
1544
+ */
1545
+ data: MulticolorSpriteCell[];
1546
+ }
1547
+
1479
1548
  /**
1480
1549
  * Central registry to manage unicolor and multicolor sprites
1481
1550
  *
@@ -1491,15 +1560,25 @@ declare class SpriteRegistry {
1491
1560
  private unicolorSprites;
1492
1561
  private multicolorSprites;
1493
1562
  /**
1494
- * Loads unicolor sprites from a LoadPacket
1495
- * Converts network format to optimized internal format
1563
+ * Loads unicolor sprites from public definitions
1564
+ * Supports strings, string arrays, and numbers
1496
1565
  */
1497
- loadUnicolorSprites(loadData: SpriteLoad): void;
1566
+ loadUnicolorSprites(definitions: UnicolorSpriteDefinition[] | SpriteLoad): void;
1498
1567
  /**
1499
- * Loads multicolor sprites from a LoadPacket
1500
- * Converts network format to optimized internal format
1568
+ * Internal method to load unicolor sprites from protocol packet
1569
+ * @internal
1570
+ */
1571
+ loadUnicolorSpritesFromPacket(loadData: SpriteLoad): void;
1572
+ /**
1573
+ * Loads multicolor sprites from public definitions
1574
+ * Supports string or number charCodes
1575
+ */
1576
+ loadMulticolorSprites(definitions: MulticolorSpriteDefinition[] | MulticolorSpriteLoad): void;
1577
+ /**
1578
+ * Internal method to load multicolor sprites from protocol packet
1579
+ * @internal
1501
1580
  */
1502
- loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
1581
+ loadMulticolorSpritesFromPacket(loadData: MulticolorSpriteLoad): void;
1503
1582
  /**
1504
1583
  * Retrieves a unicolor sprite by its ID
1505
1584
  */
@@ -8000,63 +8079,74 @@ declare class Core {
8000
8079
  */
8001
8080
  resetStats(): void;
8002
8081
  /**
8003
- * Loads unicolor sprites from a LoadPacket
8082
+ * Loads unicolor sprites into the registry.
8004
8083
  *
8005
- * Unicolor sprites only store charCode (1 byte per cell).
8006
- * Colors are applied during rendering via Orders.
8084
+ * Unicolor sprites store only character codes. Colors (fg/bg) are
8085
+ * defined at render time via SpriteOrder.
8007
8086
  *
8008
- * @param loadData - Loading data from a LoadPacket (type 0x02)
8087
+ * Supports strings for data (including row-by-row arrays) and auto-converts
8088
+ * characters to CP437 automatically.
8089
+ *
8090
+ * @param definitions - Array of sprite definitions
8009
8091
  *
8010
8092
  * @example
8011
8093
  * ```typescript
8012
- * // Load a 4x4 unicolor sprite
8013
- * engine.loadUnicolorSprites({
8014
- * sprites: [
8015
- * {
8016
- * spriteId: 1,
8017
- * sizeX: 4,
8018
- * sizeY: 4,
8019
- * data: [
8020
- * 0x2588, 0x2588, 0x2588, 0x2588,
8021
- * 0x2588, 0x0020, 0x0020, 0x2588,
8022
- * 0x2588, 0x0020, 0x0020, 0x2588,
8023
- * 0x2588, 0x2588, 0x2588, 0x2588
8024
- * ]
8025
- * }
8026
- * ]
8027
- * });
8094
+ * // Load a 4x4 unicolor sprite using a flat string
8095
+ * engine.loadUnicolorSprites([
8096
+ * {
8097
+ * spriteId: 1,
8098
+ * sizeX: 4,
8099
+ * sizeY: 4,
8100
+ * data: "##### ## #####"
8101
+ * }
8102
+ * ]);
8103
+ *
8104
+ * // Load using a string array (row by row) - cleaner!
8105
+ * engine.loadUnicolorSprites([
8106
+ * {
8107
+ * spriteId: 2,
8108
+ * sizeX: 4,
8109
+ * sizeY: 4,
8110
+ * data: [
8111
+ * "####",
8112
+ * "# #",
8113
+ * "# #",
8114
+ * "####"
8115
+ * ]
8116
+ * }
8117
+ * ]);
8028
8118
  * ```
8029
8119
  */
8030
- loadUnicolorSprites(loadData: SpriteLoad): void;
8120
+ loadUnicolorSprites(definitions: UnicolorSpriteDefinition[]): void;
8031
8121
  /**
8032
- * Loads multicolor sprites from a LoadPacket
8122
+ * Loads multicolor sprites into the registry.
8033
8123
  *
8034
- * Multicolor sprites store charCode + fgColorId + bgColorId (3 bytes per cell).
8124
+ * Multicolor sprites store charCode + fgColorId + bgColorId per cell.
8035
8125
  * Optimized for sprites with lots of visual detail.
8036
8126
  *
8037
- * @param loadData - Loading data from a LoadPacket (type 0x03)
8127
+ * Supports string characters for charCode and auto-converts to CP437.
8128
+ *
8129
+ * @param definitions - Array of sprite definitions
8038
8130
  *
8039
8131
  * @example
8040
8132
  * ```typescript
8041
8133
  * // Load a 2x2 multicolor sprite
8042
- * engine.loadMulticolorSprites({
8043
- * sprites: [
8044
- * {
8045
- * spriteId: 10,
8046
- * sizeX: 2,
8047
- * sizeY: 2,
8048
- * data: [
8049
- * { charCode: 0x2588, fgColorId: 12, bgColorId: 0 },
8050
- * { charCode: 0x2588, fgColorId: 14, bgColorId: 0 },
8051
- * { charCode: 0x2588, fgColorId: 14, bgColorId: 0 },
8052
- * { charCode: 0x2588, fgColorId: 12, bgColorId: 0 }
8053
- * ]
8054
- * }
8055
- * ]
8056
- * });
8134
+ * engine.loadMulticolorSprites([
8135
+ * {
8136
+ * spriteId: 10,
8137
+ * sizeX: 2,
8138
+ * sizeY: 2,
8139
+ * data: [
8140
+ * { charCode: 'A', fgColorId: 12, bgColorId: 0 },
8141
+ * { charCode: 'B', fgColorId: 14, bgColorId: 0 },
8142
+ * { charCode: 'C', fgColorId: 14, bgColorId: 0 },
8143
+ * { charCode: 'D', fgColorId: 12, bgColorId: 0 }
8144
+ * ]
8145
+ * }
8146
+ * ]);
8057
8147
  * ```
8058
8148
  */
8059
- loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
8149
+ loadMulticolorSprites(definitions: MulticolorSpriteDefinition[]): void;
8060
8150
  /**
8061
8151
  * Load Font structure (allocate font)
8062
8152
  * Defines the font dimensions and allocates the atlas in memory (empty)