@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.
@@ -3214,6 +3214,75 @@ interface MulticolorSprite {
3214
3214
  data: CellBuffer;
3215
3215
  }
3216
3216
 
3217
+ /**
3218
+ * Public-facing types for Sprite Loading API
3219
+ * These types hide internal implementation details like LoadType
3220
+ * and support flexible input formats (strings, numbers, etc.)
3221
+ */
3222
+ /**
3223
+ * Single Multicolor Cell definition
3224
+ */
3225
+ interface MulticolorSpriteCell {
3226
+ /**
3227
+ * Character as a string (first char used) or numeric char code (0-65535).
3228
+ * Automatically converted to CP437 if a string is provided.
3229
+ */
3230
+ charCode: string | number;
3231
+ /**
3232
+ * Foreground color ID (0-255)
3233
+ */
3234
+ fgColorId: number;
3235
+ /**
3236
+ * Background color ID (0-255)
3237
+ */
3238
+ bgColorId: number;
3239
+ }
3240
+ /**
3241
+ * Definition for a Unicolor Sprite
3242
+ */
3243
+ interface UnicolorSpriteDefinition {
3244
+ /**
3245
+ * Unique sprite identifier (0-255)
3246
+ */
3247
+ spriteId: number;
3248
+ /**
3249
+ * Width in cells (1-255)
3250
+ */
3251
+ sizeX: number;
3252
+ /**
3253
+ * Height in cells (1-255)
3254
+ */
3255
+ sizeY: number;
3256
+ /**
3257
+ * Sprite data. Can be:
3258
+ * - Flat array of numbers (char codes)
3259
+ * - Single string (will be treated as a sequence of characters)
3260
+ * - Array of strings (one per row)
3261
+ */
3262
+ data: number[] | string | string[];
3263
+ }
3264
+ /**
3265
+ * Definition for a Multicolor Sprite
3266
+ */
3267
+ interface MulticolorSpriteDefinition {
3268
+ /**
3269
+ * Unique sprite identifier (0-255)
3270
+ */
3271
+ spriteId: number;
3272
+ /**
3273
+ * Width in cells (1-255)
3274
+ */
3275
+ sizeX: number;
3276
+ /**
3277
+ * Height in cells (1-255)
3278
+ */
3279
+ sizeY: number;
3280
+ /**
3281
+ * Array of multicolor cells (row-major order, length = sizeX * sizeY)
3282
+ */
3283
+ data: MulticolorSpriteCell[];
3284
+ }
3285
+
3217
3286
  /**
3218
3287
  * Central registry to manage unicolor and multicolor sprites
3219
3288
  *
@@ -3229,15 +3298,25 @@ declare class SpriteRegistry {
3229
3298
  private unicolorSprites;
3230
3299
  private multicolorSprites;
3231
3300
  /**
3232
- * Loads unicolor sprites from a LoadPacket
3233
- * Converts network format to optimized internal format
3301
+ * Loads unicolor sprites from public definitions
3302
+ * Supports strings, string arrays, and numbers
3234
3303
  */
3235
- loadUnicolorSprites(loadData: SpriteLoad): void;
3304
+ loadUnicolorSprites(definitions: UnicolorSpriteDefinition[] | SpriteLoad): void;
3236
3305
  /**
3237
- * Loads multicolor sprites from a LoadPacket
3238
- * Converts network format to optimized internal format
3306
+ * Internal method to load unicolor sprites from protocol packet
3307
+ * @internal
3308
+ */
3309
+ loadUnicolorSpritesFromPacket(loadData: SpriteLoad): void;
3310
+ /**
3311
+ * Loads multicolor sprites from public definitions
3312
+ * Supports string or number charCodes
3313
+ */
3314
+ loadMulticolorSprites(definitions: MulticolorSpriteDefinition[] | MulticolorSpriteLoad): void;
3315
+ /**
3316
+ * Internal method to load multicolor sprites from protocol packet
3317
+ * @internal
3239
3318
  */
3240
- loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
3319
+ loadMulticolorSpritesFromPacket(loadData: MulticolorSpriteLoad): void;
3241
3320
  /**
3242
3321
  * Retrieves a unicolor sprite by its ID
3243
3322
  */
@@ -8426,63 +8505,74 @@ declare class Core {
8426
8505
  */
8427
8506
  resetStats(): void;
8428
8507
  /**
8429
- * Loads unicolor sprites from a LoadPacket
8508
+ * Loads unicolor sprites into the registry.
8430
8509
  *
8431
- * Unicolor sprites only store charCode (1 byte per cell).
8432
- * Colors are applied during rendering via Orders.
8510
+ * Unicolor sprites store only character codes. Colors (fg/bg) are
8511
+ * defined at render time via SpriteOrder.
8433
8512
  *
8434
- * @param loadData - Loading data from a LoadPacket (type 0x02)
8513
+ * Supports strings for data (including row-by-row arrays) and auto-converts
8514
+ * characters to CP437 automatically.
8515
+ *
8516
+ * @param definitions - Array of sprite definitions
8435
8517
  *
8436
8518
  * @example
8437
8519
  * ```typescript
8438
- * // Load a 4x4 unicolor sprite
8439
- * engine.loadUnicolorSprites({
8440
- * sprites: [
8441
- * {
8442
- * spriteId: 1,
8443
- * sizeX: 4,
8444
- * sizeY: 4,
8445
- * data: [
8446
- * 0x2588, 0x2588, 0x2588, 0x2588,
8447
- * 0x2588, 0x0020, 0x0020, 0x2588,
8448
- * 0x2588, 0x0020, 0x0020, 0x2588,
8449
- * 0x2588, 0x2588, 0x2588, 0x2588
8450
- * ]
8451
- * }
8452
- * ]
8453
- * });
8520
+ * // Load a 4x4 unicolor sprite using a flat string
8521
+ * engine.loadUnicolorSprites([
8522
+ * {
8523
+ * spriteId: 1,
8524
+ * sizeX: 4,
8525
+ * sizeY: 4,
8526
+ * data: "##### ## #####"
8527
+ * }
8528
+ * ]);
8529
+ *
8530
+ * // Load using a string array (row by row) - cleaner!
8531
+ * engine.loadUnicolorSprites([
8532
+ * {
8533
+ * spriteId: 2,
8534
+ * sizeX: 4,
8535
+ * sizeY: 4,
8536
+ * data: [
8537
+ * "####",
8538
+ * "# #",
8539
+ * "# #",
8540
+ * "####"
8541
+ * ]
8542
+ * }
8543
+ * ]);
8454
8544
  * ```
8455
8545
  */
8456
- loadUnicolorSprites(loadData: SpriteLoad): void;
8546
+ loadUnicolorSprites(definitions: UnicolorSpriteDefinition[]): void;
8457
8547
  /**
8458
- * Loads multicolor sprites from a LoadPacket
8548
+ * Loads multicolor sprites into the registry.
8459
8549
  *
8460
- * Multicolor sprites store charCode + fgColorId + bgColorId (3 bytes per cell).
8550
+ * Multicolor sprites store charCode + fgColorId + bgColorId per cell.
8461
8551
  * Optimized for sprites with lots of visual detail.
8462
8552
  *
8463
- * @param loadData - Loading data from a LoadPacket (type 0x03)
8553
+ * Supports string characters for charCode and auto-converts to CP437.
8554
+ *
8555
+ * @param definitions - Array of sprite definitions
8464
8556
  *
8465
8557
  * @example
8466
8558
  * ```typescript
8467
8559
  * // Load a 2x2 multicolor sprite
8468
- * engine.loadMulticolorSprites({
8469
- * sprites: [
8470
- * {
8471
- * spriteId: 10,
8472
- * sizeX: 2,
8473
- * sizeY: 2,
8474
- * data: [
8475
- * { charCode: 0x2588, fgColorId: 12, bgColorId: 0 },
8476
- * { charCode: 0x2588, fgColorId: 14, bgColorId: 0 },
8477
- * { charCode: 0x2588, fgColorId: 14, bgColorId: 0 },
8478
- * { charCode: 0x2588, fgColorId: 12, bgColorId: 0 }
8479
- * ]
8480
- * }
8481
- * ]
8482
- * });
8560
+ * engine.loadMulticolorSprites([
8561
+ * {
8562
+ * spriteId: 10,
8563
+ * sizeX: 2,
8564
+ * sizeY: 2,
8565
+ * data: [
8566
+ * { charCode: 'A', fgColorId: 12, bgColorId: 0 },
8567
+ * { charCode: 'B', fgColorId: 14, bgColorId: 0 },
8568
+ * { charCode: 'C', fgColorId: 14, bgColorId: 0 },
8569
+ * { charCode: 'D', fgColorId: 12, bgColorId: 0 }
8570
+ * ]
8571
+ * }
8572
+ * ]);
8483
8573
  * ```
8484
8574
  */
8485
- loadMulticolorSprites(loadData: MulticolorSpriteLoad): void;
8575
+ loadMulticolorSprites(definitions: MulticolorSpriteDefinition[]): void;
8486
8576
  /**
8487
8577
  * Load Font structure (allocate font)
8488
8578
  * Defines the font dimensions and allocates the atlas in memory (empty)