@gaialabs/core 0.2.12 → 0.2.13

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.mts CHANGED
@@ -255,6 +255,7 @@ declare class DbFile {
255
255
  upper?: boolean;
256
256
  group?: string;
257
257
  scene?: string;
258
+ base?: number;
258
259
  constructor(data: Partial<DbFile>);
259
260
  }
260
261
  declare class DbFileType {
@@ -265,6 +266,8 @@ declare class DbFileType {
265
266
  isBlock: boolean;
266
267
  header: number;
267
268
  compressed?: boolean;
269
+ struct?: string;
270
+ base?: number;
268
271
  constructor(data: Partial<DbFileType>);
269
272
  }
270
273
  //#endregion
@@ -328,70 +331,126 @@ interface ICompressionProvider {
328
331
  compact(srcData: Uint8Array, srcPosition?: number, srcLen?: number): Uint8Array;
329
332
  }
330
333
  //#endregion
331
- //#region src/types/files.d.ts
334
+ //#region src/database/entrypoints.d.ts
332
335
  /**
333
- * Chunk file for ROM processing
334
- * Converted from GaiaLib/Types/ChunkFile.cs
336
+ * Database entry point definition
337
+ * Converted from GaiaLib/Database/DbEntryPoint.cs
335
338
  */
336
- declare class ChunkFile {
339
+ interface DbEntryPoint {
340
+ location: number;
341
+ name: string;
342
+ }
343
+ //#endregion
344
+ //#region src/database/paths.d.ts
345
+ /**
346
+ * Database path configuration
347
+ * Converted from GaiaLib/Database/DbPath.cs
348
+ */
349
+ interface DbPath {
350
+ folder: string;
351
+ extension: string;
352
+ }
353
+ /**
354
+ * Creates a default DbPath
355
+ */
356
+ declare function createDbPath(folder?: string, extension?: string): DbPath;
357
+ //#endregion
358
+ //#region src/database/config.d.ts
359
+ /**
360
+ * Database configuration
361
+ * Converted from GaiaLib/Database/DbConfig.cs
362
+ */
363
+ interface DbConfig {
364
+ sfxLocation: number;
365
+ sfxCount: number;
366
+ sfxType: string;
367
+ sfxPack: string;
368
+ compression: string;
369
+ uncompress: boolean;
370
+ entryPoints: DbEntryPoint[];
371
+ paths: Record<BinType, DbPath>;
372
+ memoryMode: MemoryMapMode;
373
+ cpuMode: CpuMode;
374
+ chipset: number;
375
+ ramSize: number;
376
+ }
377
+ //#endregion
378
+ //#region src/database/structs.d.ts
379
+ /**
380
+ * Database structure definition
381
+ * Converted from GaiaLib/Database/DbStruct.cs
382
+ */
383
+ declare class DbStruct {
384
+ name: string;
385
+ types?: string[];
386
+ parent?: string;
387
+ delimiter?: number;
388
+ discriminator?: number;
389
+ constructor(data: Partial<DbStruct>);
390
+ }
391
+ //#endregion
392
+ //#region src/database/addressingMode.d.ts
393
+ declare class DbAddressingMode {
337
394
  name: string;
395
+ shorthand: string;
396
+ operands: string[];
338
397
  size: number;
339
- location: number;
340
- type: DbFileType;
341
- parts?: AsmBlock[];
342
- includes?: Set<string>;
343
- includeLookup?: Map<string, AsmBlock>;
344
- bank?: number;
345
- compressed?: boolean;
346
- upper?: boolean;
347
- rawData?: Uint8Array | null;
348
- textData?: string;
349
- transforms?: {
350
- key: string;
351
- value: string;
352
- }[];
353
- postProcess?: string;
354
- mnemonics: Record<number, string>;
355
- group?: string;
356
- scene?: string;
357
- constructor(name: string, size: number, location: number, type: DbFileType);
398
+ formatString?: string;
399
+ parseRegex?: string;
400
+ instructions: Record<string, number>;
401
+ constructor(data: Partial<DbAddressingMode>);
358
402
  }
359
- declare function createChunkFileFromDbFile(rom: Uint8Array, compression: ICompressionProvider | undefined, dbFile: DbFile, fileType: DbFileType): ChunkFile;
360
- declare function createChunkFileFromDbBlock(block: DbBlock, fileType: DbFileType, memoryMode: MemoryMapMode): ChunkFile;
403
+ //#endregion
404
+ //#region src/database/strings.d.ts
361
405
  /**
362
- * Chunk file utilities
406
+ * Database string command definition
407
+ * Converted from GaiaLib/Database/DbStringCommand.cs
363
408
  */
364
- declare class ChunkFileUtils {
365
- /**
366
- * Rebase blocks to a new location
367
- */
368
- static rebase(chunkFile: ChunkFile, newLocation?: number): void;
369
- /**
370
- * Calculate the total size of all blocks
371
- */
372
- static calculateSize(chunkFile: ChunkFile): number;
373
- /**
374
- * Check if a location is outside this block and return the part (matches C# IsOutside)
375
- * Returns [isOutside, part] where part is the part containing the location
376
- */
377
- static isOutsideWithPart(root: ChunkFile[], block: ChunkFile, location: number): [boolean, ChunkFile | null, AsmBlock | null];
378
- /**
379
- * Check if a location is inside this block and return the part (matches C# IsInside)
380
- * Returns [isInside, part] where part is the part containing the location
381
- */
382
- static isInsideWithPart(block: ChunkFile, location: number): [boolean, AsmBlock | null];
383
- /**
384
- * Check if a location is outside this block (shorthand version)
385
- */
386
- static isOutside(block: ChunkFile, location: number): boolean;
387
- /**
388
- * Check if a location is inside this block (shorthand version)
389
- */
390
- static isInside(block: ChunkFile, location: number): boolean;
391
- /**
392
- * Get all included blocks
393
- */
394
- static getIncludes(chunkFile: ChunkFile): ChunkFile[];
409
+ declare class DbStringCommand {
410
+ id: number;
411
+ name: string;
412
+ types: string[];
413
+ delimiter?: number;
414
+ halt: boolean;
415
+ dictionary?: DbStringDictionary;
416
+ constructor(data: Partial<DbStringCommand>);
417
+ }
418
+ /**
419
+ * Database string layer definition
420
+ * Converted from GaiaLib/Database/DbStringLayer.cs
421
+ */
422
+ interface DbStringLayer {
423
+ base?: number;
424
+ range?: number;
425
+ on?: number;
426
+ shiftBit?: number;
427
+ map: string[];
428
+ }
429
+ declare class DbStringDictionary {
430
+ command?: number;
431
+ commandName?: string;
432
+ name: string;
433
+ entries: string[];
434
+ constructor(data: Partial<DbStringDictionary>);
435
+ }
436
+ /**
437
+ * Database string type definition
438
+ * Converted from GaiaLib/Database/DbStringType.cs
439
+ */
440
+ declare class DbStringType {
441
+ name: string;
442
+ delimiter: string;
443
+ terminator: number;
444
+ commands: Record<string, DbStringCommand>;
445
+ commandLookup: Record<number, DbStringCommand>;
446
+ layers: DbStringLayer[];
447
+ greedyTerminator: boolean;
448
+ dictionaries: Record<string, DbStringDictionary>;
449
+ dictionaryLookup: {
450
+ text: string;
451
+ id: number;
452
+ }[];
453
+ constructor(data: Partial<DbStringType>);
395
454
  }
396
455
  //#endregion
397
456
  //#region src/database/cop.d.ts
@@ -416,491 +475,37 @@ declare class OpCode {
416
475
  constructor(code: number, mnem: string, mode: string);
417
476
  }
418
477
  //#endregion
419
- //#region src/types/assembly.d.ts
420
- /**
421
- * Represents a single assembly operation/instruction
422
- */
423
- declare class Op extends OpCode {
424
- location: number;
425
- operands: unknown[];
426
- size: number;
427
- copDef?: CopDef;
428
- constructor(code: OpCode, location?: number, operands?: unknown[], size?: number);
478
+ //#region src/database/assets.d.ts
479
+ interface DbAsset {
480
+ index: number;
481
+ type: string;
482
+ file: string;
483
+ scene: string;
484
+ meta: any;
429
485
  }
430
- /**
431
- * Represents a block of assembly code or data
432
- */
433
- declare class AsmBlock {
434
- label?: string;
435
- location: number;
436
- size: number;
437
- isString: boolean;
438
- objList: any[];
439
- structName?: string;
440
- bank?: number;
441
- includes?: Set<{
442
- block: ChunkFile;
443
- part: AsmBlock;
444
- }>;
445
- constructor(location?: number, size?: number, isString?: boolean, label?: string, structName?: string, bank?: number);
486
+ //#endregion
487
+ //#region src/database/scenes.d.ts
488
+ declare class DbScene {
489
+ name: string;
490
+ id: number;
491
+ description?: string;
492
+ assets: DbAsset[];
493
+ constructor(data: Partial<DbScene>);
446
494
  }
447
- /**
448
- * Database part utilities
449
- */
450
- declare class AsmBlockUtils {
451
- /**
452
- * Check if a location is inside this part
453
- */
454
- static isInside(part: AsmBlock, location: number): boolean;
455
- /**
456
- * Check if a location is outside this part
457
- */
458
- static isOutside(part: AsmBlock, location: number): boolean;
495
+ //#endregion
496
+ //#region src/database/groups.d.ts
497
+ declare class DbGroup {
498
+ name: string;
499
+ prefix: string;
500
+ description?: string;
501
+ scenes: Record<string, DbScene>;
502
+ constructor(data: Partial<DbGroup>);
459
503
  }
460
504
  //#endregion
461
- //#region src/types/bitstream.d.ts
505
+ //#region src/supabase/types.d.ts
462
506
  /**
463
- * Bit stream for reading/writing binary data at bit level
464
- * Converted from GaiaLib/Types/BitStream.cs
465
- */
466
- declare class BitStream {
467
- private static readonly NIBBLE_MASK;
468
- private static readonly NIBBLE_PERFECT_POSITION;
469
- private data;
470
- private position;
471
- private bitFlag;
472
- private writeSample;
473
- constructor(data: Uint8Array, position?: number);
474
- get dataArray(): Uint8Array;
475
- get currentPosition(): number;
476
- set currentPosition(value: number);
477
- /**
478
- * Read a byte from the stream
479
- * @returns The byte read, or -1 if the end of the data has been reached
480
- */
481
- readByte(): number;
482
- /**
483
- * Read a ushort from the stream (ignores the current bit flag)
484
- * @returns The short read, or -1 if the end of the data has been reached
485
- */
486
- readShort(): number;
487
- /**
488
- * Read a bit from the stream
489
- * @returns True if the current bit at bitFlag is set, false otherwise
490
- */
491
- readBit(): boolean;
492
- /**
493
- * Read a nibble from the stream
494
- * @returns The nibble read, or -1 if the end of the data has been reached
495
- */
496
- readNibble(): number;
497
- /**
498
- * Write a bit to the stream
499
- * @param set True if the current bit should be set, false otherwise
500
- */
501
- writeBit(set: boolean): void;
502
- /**
503
- * Write a byte to the stream
504
- * @param value The byte to write
505
- */
506
- writeByte(value: number): void;
507
- /**
508
- * Write a nibble to the stream
509
- * @param value The nibble to write
510
- */
511
- writeNibble(value: number): void;
512
- flush(): void;
513
- }
514
- //#endregion
515
- //#region src/types/compression-registry.d.ts
516
- /**
517
- * Registry for compression providers
518
- * Allows registration of compression implementations by string ID
519
- */
520
- declare class CompressionRegistry {
521
- private static providers;
522
- /**
523
- * Register a compression provider
524
- * @param id String identifier for the compression type
525
- * @param factory Factory function that creates the compression provider
526
- */
527
- static register(id: string, factory: () => ICompressionProvider): void;
528
- /**
529
- * Get a compression provider by ID
530
- * @param id String identifier for the compression type
531
- * @returns Compression provider instance
532
- */
533
- static get(id: string): ICompressionProvider;
534
- /**
535
- * Check if a compression provider is registered
536
- * @param id String identifier for the compression type
537
- * @returns True if provider is registered
538
- */
539
- static has(id: string): boolean;
540
- /**
541
- * Get list of registered provider IDs
542
- * @returns Array of registered provider IDs
543
- */
544
- static getRegisteredIds(): string[];
545
- /**
546
- * Clear all registered providers (mainly for testing)
547
- */
548
- static clear(): void;
549
- }
550
- //#endregion
551
- //#region src/types/constants.d.ts
552
- /**
553
- * ROM processing constants
554
- * Converted from GaiaLib/Types/RomProcessingConstants.cs
555
- */
556
- declare class RomProcessingConstants {
557
- static readonly PAGE_SIZE = 32768;
558
- static readonly SNES_HEADER_SIZE = 80;
559
- static readonly DICTIONARIES: string[];
560
- static readonly DICT_COMMANDS: number[];
561
- static readonly END_CHARS: number[];
562
- static readonly WHITESPACE: string[];
563
- static readonly OPERATORS: string[];
564
- static readonly COMMA_SPACE: string[];
565
- static readonly ADDRESS_SPACE: string[];
566
- static readonly SYMBOL_SPACE: string[];
567
- static readonly LABEL_SPACE: string[];
568
- static readonly OBJECT_SPACE: string[];
569
- static readonly COP_SPLIT_CHARS: string[];
570
- static readonly WHITESPACE_REGEX: RegExp;
571
- static readonly COMMA_SPACE_REGEX: RegExp;
572
- static readonly SYMBOL_SPACE_REGEX: RegExp;
573
- static readonly LABEL_SPACE_REGEX: RegExp;
574
- static readonly OBJECT_SPACE_REGEX: RegExp;
575
- static readonly ADDRESS_SPACE_REGEX: RegExp;
576
- static readonly COP_SPLIT_REGEX: RegExp;
577
- static readonly COMMA_SPACE_TRIM_REGEX: RegExp;
578
- /**
579
- * Gets the size of an object for processing purposes
580
- * @param obj The object to get the size for
581
- * @returns Size in bytes
582
- * @throws Error when unable to determine size
583
- */
584
- static getSize(obj: unknown): number;
585
- }
586
- /**
587
- * BlockReader specific constants
588
- */
589
- declare class BlockReaderConstants {
590
- static readonly REF_SEARCH_MAX_RANGE = 416;
591
- static readonly BANK_MASK_CHECK = 64;
592
- static readonly BYTE_DELIMITER_THRESHOLD = 256;
593
- static readonly BANK_HIGH_MEMORY_1 = 126;
594
- static readonly BANK_HIGH_MEMORY_2 = 127;
595
- static readonly POINTER_CHARACTERS: string[];
596
- static readonly WIDE_STRING_TYPE = "WideString";
597
- static readonly BINARY_TYPE = "Binary";
598
- static readonly CODE_TYPE = "Code";
599
- static readonly LOCATION_FORMAT = "loc_{0:X6}";
600
- static readonly TYPE_NAME_FORMAT = "{0}_{1:X6}";
601
- static readonly OFFSET_FORMAT = "+{0:X}";
602
- static readonly MARKER_FORMAT = "+M";
603
- static readonly NEGATIVE_OFFSET_FORMAT = "-{0:X}";
604
- static readonly NEGATIVE_MARKER_FORMAT = "-M";
605
- }
606
- //#endregion
607
- //#region src/types/location.d.ts
608
- /**
609
- * Location wrapper for additional metadata
610
- * Converted from GaiaLib/Types/LocationWrapper.cs
611
- */
612
- declare class LocationWrapper {
613
- location: number;
614
- type: AddressType;
615
- constructor(location: number, type: AddressType);
616
- }
617
- //#endregion
618
- //#region src/database/strings.d.ts
619
- /**
620
- * Database string command definition
621
- * Converted from GaiaLib/Database/DbStringCommand.cs
622
- */
623
- declare class DbStringCommand {
624
- id: number;
625
- name: string;
626
- types: string[];
627
- delimiter?: number;
628
- halt: boolean;
629
- dictionary?: DbStringDictionary;
630
- constructor(data: Partial<DbStringCommand>);
631
- }
632
- /**
633
- * Database string layer definition
634
- * Converted from GaiaLib/Database/DbStringLayer.cs
635
- */
636
- interface DbStringLayer {
637
- base?: number;
638
- range?: number;
639
- on?: number;
640
- shiftBit?: number;
641
- map: string[];
642
- }
643
- declare class DbStringDictionary {
644
- command?: number;
645
- commandName?: string;
646
- name: string;
647
- entries: string[];
648
- constructor(data: Partial<DbStringDictionary>);
649
- }
650
- /**
651
- * Database string type definition
652
- * Converted from GaiaLib/Database/DbStringType.cs
653
- */
654
- declare class DbStringType {
655
- name: string;
656
- delimiter: string;
657
- terminator: number;
658
- commands: Record<string, DbStringCommand>;
659
- commandLookup: Record<number, DbStringCommand>;
660
- layers: DbStringLayer[];
661
- greedyTerminator: boolean;
662
- dictionaries: Record<string, DbStringDictionary>;
663
- dictionaryLookup: {
664
- text: string;
665
- id: number;
666
- }[];
667
- constructor(data: Partial<DbStringType>);
668
- }
669
- //#endregion
670
- //#region src/types/strings.d.ts
671
- /**
672
- * String marker for positioning
673
- * Converted from GaiaLib/Types/StringMarker.cs
674
- */
675
- interface StringMarker {
676
- offset: number;
677
- }
678
- /**
679
- * String wrapper with type and location information
680
- * Converted from GaiaLib/Types/StringWrapper.cs
681
- */
682
- interface StringWrapper {
683
- string: string;
684
- type: DbStringType;
685
- marker: number;
686
- location: number;
687
- fixedSize: number;
688
- }
689
- /**
690
- * String entry (commented out in original C# code)
691
- * Converted from GaiaLib/Types/StringEntry.cs
692
- */
693
- interface StringEntry {
694
- block: AsmBlock;
695
- index: number;
696
- size: number;
697
- data: Uint8Array;
698
- }
699
- /**
700
- * String size comparer utility
701
- * Converted from GaiaLib/Types/StringSizeComparer.cs
702
- */
703
- declare class StringSizeComparer {
704
- /**
705
- * Compare two strings by length
706
- */
707
- static compare(a: string, b: string): number;
708
- /**
709
- * Compare two StringWrapper objects by string length
710
- */
711
- static compareWrappers(a: StringWrapper, b: StringWrapper): number;
712
- }
713
- //#endregion
714
- //#region src/types/structs.d.ts
715
- /**
716
- * Structure definition
717
- * Converted from GaiaLib/Types/StructDef.cs
718
- */
719
- interface StructDef {
720
- name: string;
721
- parts: unknown[];
722
- }
723
- //#endregion
724
- //#region src/types/tables.d.ts
725
- declare class TableEntry {
726
- location: number;
727
- object: unknown;
728
- constructor(location: number);
729
- }
730
- //#endregion
731
- //#region src/types/operands.d.ts
732
- declare class TypedNumber {
733
- value: number;
734
- size: number;
735
- constructor(value: number, size: number);
736
- }
737
- declare class Byte extends TypedNumber {
738
- constructor(value: number);
739
- }
740
- declare class Word extends TypedNumber {
741
- constructor(value: number);
742
- }
743
- declare class Long extends TypedNumber {
744
- constructor(value: number);
745
- }
746
- //#endregion
747
- //#region src/assembly/Registers.d.ts
748
- /**
749
- * Manages the 65816 processor registers and status flags
750
- */
751
- declare class Registers {
752
- value: Record<string, number>;
753
- stack: Stack;
754
- mode: MemoryMapMode;
755
- constructor(mode: MemoryMapMode);
756
- }
757
- //#endregion
758
- //#region src/rom/extraction/processor.d.ts
759
- declare class MapExt<K, V> extends Map<K, V> {
760
- constructor();
761
- tryAdd(key: K, value: V): boolean;
762
- setFlag(key: K, flag: number, value?: boolean): void;
763
- clearFlag(key: K, flag: number): void;
764
- }
765
- /**
766
- * Manages CPU processor state during ROM analysis
767
- * Converted from GaiaLib/Rom/Extraction/ProcessorStateManager.cs
768
- */
769
- declare class ProcessorStateManager {
770
- readonly stackPositions: MapExt<number, number>;
771
- private readonly _buckets;
772
- get(key: string): MapExt<number, number>;
773
- /**
774
- * Hydrate processor registers with stored state
775
- * Uses Registers from gaia-core/assembly for processor state management
776
- */
777
- hydrateRegisters(position: number, reg: Registers): void;
778
- getStackPosition(location: number): number | undefined;
779
- setStackPosition(location: number, value: number): void;
780
- tryAddStackPosition(location: number, value: number): boolean;
781
- }
782
- //#endregion
783
- //#region src/rom/extraction/reader.d.ts
784
- /**
785
- * Provides low-level ROM data reading functionality
786
- * Converted from GaiaLib/Rom/Extraction/RomDataReader.cs
787
- */
788
- declare class RomDataReader {
789
- readonly romData: Uint8Array;
790
- position: number;
791
- constructor(romData: Uint8Array);
792
- readByte(): number;
793
- readSByte(): number;
794
- readUShort(): number;
795
- readShort(): number;
796
- readAddress(): number;
797
- readInt(): number;
798
- peekByte(): number;
799
- peekShort(): number;
800
- peekAddress(): number;
801
- }
802
- //#endregion
803
- //#region src/database/entrypoints.d.ts
804
- /**
805
- * Database entry point definition
806
- * Converted from GaiaLib/Database/DbEntryPoint.cs
807
- */
808
- interface DbEntryPoint {
809
- location: number;
810
- name: string;
811
- }
812
- //#endregion
813
- //#region src/database/paths.d.ts
814
- /**
815
- * Database path configuration
816
- * Converted from GaiaLib/Database/DbPath.cs
817
- */
818
- interface DbPath {
819
- folder: string;
820
- extension: string;
821
- }
822
- /**
823
- * Creates a default DbPath
824
- */
825
- declare function createDbPath(folder?: string, extension?: string): DbPath;
826
- //#endregion
827
- //#region src/database/config.d.ts
828
- /**
829
- * Database configuration
830
- * Converted from GaiaLib/Database/DbConfig.cs
831
- */
832
- interface DbConfig {
833
- sfxLocation: number;
834
- sfxCount: number;
835
- sfxType: string;
836
- sfxPack: string;
837
- compression: string;
838
- uncompress: boolean;
839
- entryPoints: DbEntryPoint[];
840
- paths: Record<BinType, DbPath>;
841
- memoryMode: MemoryMapMode;
842
- cpuMode: CpuMode;
843
- chipset: number;
844
- ramSize: number;
845
- }
846
- //#endregion
847
- //#region src/database/structs.d.ts
848
- /**
849
- * Database structure definition
850
- * Converted from GaiaLib/Database/DbStruct.cs
851
- */
852
- declare class DbStruct {
853
- name: string;
854
- types?: string[];
855
- parent?: string;
856
- delimiter?: number;
857
- discriminator?: number;
858
- constructor(data: Partial<DbStruct>);
859
- }
860
- //#endregion
861
- //#region src/database/addressingMode.d.ts
862
- declare class DbAddressingMode {
863
- name: string;
864
- shorthand: string;
865
- operands: string[];
866
- size: number;
867
- formatString?: string;
868
- parseRegex?: string;
869
- instructions: Record<string, number>;
870
- constructor(data: Partial<DbAddressingMode>);
871
- }
872
- //#endregion
873
- //#region src/database/assets.d.ts
874
- interface DbAsset {
875
- index: number;
876
- type: string;
877
- file: string;
878
- scene: string;
879
- meta: any;
880
- }
881
- //#endregion
882
- //#region src/database/scenes.d.ts
883
- declare class DbScene {
884
- name: string;
885
- id: number;
886
- description?: string;
887
- assets: DbAsset[];
888
- constructor(data: Partial<DbScene>);
889
- }
890
- //#endregion
891
- //#region src/database/groups.d.ts
892
- declare class DbGroup {
893
- name: string;
894
- prefix: string;
895
- description?: string;
896
- scenes: Record<string, DbScene>;
897
- constructor(data: Partial<DbGroup>);
898
- }
899
- //#endregion
900
- //#region src/supabase/types.d.ts
901
- /**
902
- * TypeScript interfaces for Supabase API responses
903
- * These types represent the structured data returned from ROM database queries
507
+ * TypeScript interfaces for Supabase API responses
508
+ * These types represent the structured data returned from ROM database queries
904
509
  */
905
510
  interface PlatformData {
906
511
  id: string;
@@ -1134,248 +739,650 @@ interface ProjectData {
1134
739
  updatedAt: string;
1135
740
  }
1136
741
  /**
1137
- * Project branch with complete relationship chain
742
+ * Project branch with complete relationship chain
743
+ */
744
+ interface ProjectBranchData extends BranchBaseData {
745
+ projectId: string;
746
+ baseRomBranchId: string;
747
+ modules: any[];
748
+ project: ProjectData;
749
+ baseRomBranch: BaseRomBranchData;
750
+ }
751
+ /**
752
+ * Project file containing binary data
753
+ */
754
+ interface ProjectFileData extends FileBaseData {
755
+ module: string | null;
756
+ projectId: string;
757
+ }
758
+ interface ProjectBranchFileRaw {
759
+ id: string;
760
+ branchId: string;
761
+ fileId: string;
762
+ file: ProjectFileRaw;
763
+ }
764
+ /**
765
+ * Raw ProjectFile data as returned from Supabase (before conversion)
766
+ */
767
+ interface ProjectFileRaw extends FileBaseRaw {
768
+ module: string | null;
769
+ projectId: string;
770
+ }
771
+ /**
772
+ * Complete Project payload containing branch data and files
773
+ */
774
+ interface ProjectPayload {
775
+ projectBranch: ProjectBranchData;
776
+ projectFiles: ProjectFileData[];
777
+ baseRomBranch: BaseRomBranchData;
778
+ baseRomFiles: BaseRomFileData[];
779
+ }
780
+ /**
781
+ * Options for loading Project data by name
782
+ */
783
+ interface FromSupabaseByProjectOptions {
784
+ projectName: string;
785
+ /**
786
+ * Name of the branch to load
787
+ * Set to null to load the main/develop branch
788
+ * Set to undefined to not filter by branch name
789
+ */
790
+ branchName?: string | null;
791
+ /**
792
+ * Version of the branch to load
793
+ * Set to null to load the latest/main version
794
+ * Set to undefined to not filter by version
795
+ */
796
+ branchVersion?: number | null;
797
+ }
798
+ /**
799
+ * Query statistics for performance monitoring
800
+ */
801
+ interface QueryStats {
802
+ branchQueryTime: number;
803
+ fileQueryTime: number;
804
+ totalTime: number;
805
+ fileCount: number;
806
+ }
807
+ //#endregion
808
+ //#region src/database/modules.d.ts
809
+ interface DbGameRomModule {
810
+ supaProjectFiles?: ProjectFileData[];
811
+ supaBaseRomFiles?: BaseRomFileData[];
812
+ mnemonics: Record<number, string>;
813
+ overrides: Record<number, Record<string, number>>;
814
+ rewrites: Record<string, number>;
815
+ blocks: Record<string, Record<string, Partial<DbBlock>>>;
816
+ files: Record<string, Record<string, Record<string, Partial<DbFile>>>>;
817
+ config: DbConfig;
818
+ labels: Record<number, string>;
819
+ structs: Record<string, DbStruct>;
820
+ copdef: Record<string, Partial<CopDef>>;
821
+ strings: Record<string, Partial<DbStringType>>;
822
+ transforms: Record<string, Partial<DbTransform>[]>;
823
+ addrModes: Record<string, Partial<DbAddressingMode>>;
824
+ headers: Partial<DbHeader>[];
825
+ groups: Record<string, Partial<DbGroup>>;
826
+ fileTypes: Record<string, Partial<DbFileType>>;
827
+ }
828
+ interface DbBaseRomModule extends DbGameRomModule {
829
+ baseRomFiles: ChunkFile[];
830
+ }
831
+ interface DbProjectModule extends DbBaseRomModule {
832
+ projectFiles: ChunkFile[];
833
+ }
834
+ //#endregion
835
+ //#region src/database/header.d.ts
836
+ declare class DbHeader {
837
+ bank: number;
838
+ address: number;
839
+ condition?: string;
840
+ parts: DbHeaderPart[];
841
+ constructor(data: Partial<DbHeader>);
842
+ }
843
+ declare class DbHeaderPart {
844
+ name: string;
845
+ size: number;
846
+ type: string;
847
+ value?: any;
848
+ constructor(data: Partial<DbHeaderPart>);
849
+ }
850
+ //#endregion
851
+ //#region src/database/root.d.ts
852
+ /**
853
+ * Main database root class
854
+ * Converted from GaiaLib/Database/DbRoot.cs
855
+ */
856
+ interface DbRoot {
857
+ copDef: Record<number, CopDef>;
858
+ copLookup: Record<string, CopDef>;
859
+ mnemonics: Record<number, string>;
860
+ structs: Record<string, DbStruct>;
861
+ stringTypes: Record<string, DbStringType>;
862
+ stringDelimiters: string[];
863
+ stringDelimiterLookup: Record<string, DbStringType>;
864
+ headers: DbHeader[];
865
+ files: DbFile[];
866
+ config: DbConfig;
867
+ blocks: DbBlock[];
868
+ overrides: Record<number, Record<string, any>>;
869
+ labels: Record<number, string>;
870
+ rewrites: Record<number, number>;
871
+ entryPoints: DbEntryPoint[];
872
+ opCodes: Record<number, OpCode>;
873
+ opLookup: Record<string, OpCode[]>;
874
+ addrLookup: Record<string, DbAddressingMode>;
875
+ compression?: ICompressionProvider;
876
+ baseRomFiles?: ChunkFile[];
877
+ projectFiles?: ChunkFile[];
878
+ groups: Record<string, DbGroup>;
879
+ scenes: Record<number, DbScene>;
880
+ fileTypes: Record<string, DbFileType>;
881
+ fileExtLookup: Record<string, DbFileType>;
882
+ }
883
+ /**
884
+ * Database root utilities
885
+ */
886
+ declare class DbRootUtils {
887
+ /**
888
+ * JSON serialization options
889
+ */
890
+ static fromGameModule(module: DbGameRomModule): DbRoot;
891
+ static applyFolder(root: DbRoot, folderPath: string, sourceFiles?: ChunkFile[], group?: string): Promise<ChunkFile[]>;
892
+ static extractAllContent(root: DbRoot, romPath: string, outPath: string): Promise<void>;
893
+ static rebuildAllContent(root: DbRoot, inPath: string[], outPath: string): Promise<ChunkFile[]>;
894
+ }
895
+ //#endregion
896
+ //#region src/database/labels.d.ts
897
+ /**
898
+ * Database label definition
899
+ * Converted from GaiaLib/Database/DbLabel.cs
900
+ */
901
+ interface DbLabel {
902
+ location: number;
903
+ label: string;
904
+ }
905
+ //#endregion
906
+ //#region src/database/mnemonics.d.ts
907
+ /**
908
+ * Database mnemonic definition
909
+ * Converted from GaiaLib/Database/DbMnemonic.cs
910
+ */
911
+ interface DbMnemonic {
912
+ key: number;
913
+ value: string;
914
+ metadata?: string;
915
+ }
916
+ //#endregion
917
+ //#region src/database/overrides.d.ts
918
+ declare class DbOverride {
919
+ location: number;
920
+ register: string;
921
+ value: number;
922
+ constructor(values: Partial<DbOverride>);
923
+ }
924
+ //#endregion
925
+ //#region src/database/rewrites.d.ts
926
+ /**
927
+ * Database rewrite rule definition
928
+ * Converted from GaiaLib/Database/DbRewrite.cs
929
+ */
930
+ interface DbRewrite {
931
+ location: number;
932
+ value: number;
933
+ }
934
+ //#endregion
935
+ //#region src/database/sfx.d.ts
936
+ /**
937
+ * Database sound effect definition
938
+ * Converted from GaiaLib/Database/DbSfx.cs
939
+ */
940
+ interface DbSfx {
941
+ location: number;
942
+ size: number;
943
+ names: string[];
944
+ }
945
+ //#endregion
946
+ //#region src/rom/extraction/references.d.ts
947
+ /**
948
+ * Manages references, chunks, and markers during ROM analysis
949
+ * Converted from GaiaLib/Rom/Extraction/ReferenceManager.cs
950
+ */
951
+ declare class ReferenceManager {
952
+ readonly structTable: Map<number, string>;
953
+ readonly markerTable: Map<number, number>;
954
+ readonly nameTable: Map<number, string>;
955
+ private readonly root;
956
+ constructor(root: DbRoot);
957
+ tryGetStruct(location: number): {
958
+ found: boolean;
959
+ chunkType?: string;
960
+ };
961
+ tryAddStruct(location: number, chunkType: string): boolean;
962
+ containsStruct(location: number): boolean;
963
+ tryGetName(location: number): {
964
+ found: boolean;
965
+ referenceName?: string;
966
+ };
967
+ tryAddName(location: number, referenceName: string): boolean;
968
+ tryGetMarker(location: number): {
969
+ found: boolean;
970
+ offset?: number;
971
+ };
972
+ setMarker(location: number, offset: number): void;
973
+ createBranchLabel(location: number): string;
974
+ createTypeName(type: string, location: number): string;
975
+ createFallbackName(location: number): string;
976
+ /**
977
+ * Finds a reference location by its assigned name.
978
+ */
979
+ findLocationByName(name: string): number | undefined;
980
+ resolveName(location: number, type: AddressType, isBranch: boolean): string;
981
+ findClosestReference(location: number): string | null;
982
+ private processRewrite;
983
+ private processClosestMatch;
984
+ }
985
+ //#endregion
986
+ //#region src/types/files.d.ts
987
+ /**
988
+ * Chunk file for ROM processing
989
+ * Converted from GaiaLib/Types/ChunkFile.cs
990
+ */
991
+ declare class ChunkFile {
992
+ name: string;
993
+ size: number;
994
+ location: number;
995
+ type: DbFileType;
996
+ parts?: AsmBlock[];
997
+ includes?: Set<string>;
998
+ includeLookup?: Map<string, AsmBlock>;
999
+ bank?: number;
1000
+ compressed?: boolean;
1001
+ upper?: boolean;
1002
+ rawData?: Uint8Array | null;
1003
+ textData?: string;
1004
+ transforms?: {
1005
+ key: string;
1006
+ value: string;
1007
+ }[];
1008
+ postProcess?: string;
1009
+ mnemonics: Record<number, string>;
1010
+ group?: string;
1011
+ scene?: string;
1012
+ base?: number;
1013
+ referenceManager?: ReferenceManager;
1014
+ constructor(type: DbFileType, name: string, size?: number, location?: number);
1015
+ enrichWithRawDataFromDbFile(file: DbFile, rom: Uint8Array, compression: ICompressionProvider | undefined): void;
1016
+ enrichWithAsmBlocksFromDbBlock(block: DbBlock, memoryMode: MemoryMapMode): void;
1017
+ }
1018
+ declare function combineHeader(data: Uint8Array, position: number, length: number, header: Uint8Array | null, type: BinType): Uint8Array;
1019
+ /**
1020
+ * Chunk file utilities
1138
1021
  */
1139
- interface ProjectBranchData extends BranchBaseData {
1140
- projectId: string;
1141
- baseRomBranchId: string;
1142
- modules: any[];
1143
- project: ProjectData;
1144
- baseRomBranch: BaseRomBranchData;
1022
+ declare class ChunkFileUtils {
1023
+ /**
1024
+ * Rebase blocks to a new location
1025
+ */
1026
+ static rebase(chunkFile: ChunkFile, newLocation?: number): void;
1027
+ /**
1028
+ * Calculate the total size of all blocks
1029
+ */
1030
+ static calculateSize(chunkFile: ChunkFile): number;
1031
+ /**
1032
+ * Check if a location is outside this block and return the part (matches C# IsOutside)
1033
+ * Returns [isOutside, part] where part is the part containing the location
1034
+ */
1035
+ static isOutsideWithPart(root: ChunkFile[], block: ChunkFile, location: number): [boolean, ChunkFile | null, AsmBlock | null];
1036
+ /**
1037
+ * Check if a location is inside this block and return the part (matches C# IsInside)
1038
+ * Returns [isInside, part] where part is the part containing the location
1039
+ */
1040
+ static isInsideWithPart(block: ChunkFile, location: number): [boolean, AsmBlock | null];
1041
+ /**
1042
+ * Check if a location is outside this block (shorthand version)
1043
+ */
1044
+ static isOutside(block: ChunkFile, location: number): boolean;
1045
+ /**
1046
+ * Check if a location is inside this block (shorthand version)
1047
+ */
1048
+ static isInside(block: ChunkFile, location: number): boolean;
1049
+ /**
1050
+ * Get all included blocks
1051
+ */
1052
+ static getIncludes(chunkFile: ChunkFile): ChunkFile[];
1145
1053
  }
1054
+ //#endregion
1055
+ //#region src/types/assembly.d.ts
1146
1056
  /**
1147
- * Project file containing binary data
1057
+ * Represents a single assembly operation/instruction
1148
1058
  */
1149
- interface ProjectFileData extends FileBaseData {
1150
- module: string | null;
1151
- projectId: string;
1152
- }
1153
- interface ProjectBranchFileRaw {
1154
- id: string;
1155
- branchId: string;
1156
- fileId: string;
1157
- file: ProjectFileRaw;
1059
+ declare class Op extends OpCode {
1060
+ location: number;
1061
+ operands: unknown[];
1062
+ size: number;
1063
+ copDef?: CopDef;
1064
+ constructor(code: OpCode, location?: number, operands?: unknown[], size?: number);
1158
1065
  }
1159
1066
  /**
1160
- * Raw ProjectFile data as returned from Supabase (before conversion)
1067
+ * Represents a block of assembly code or data
1161
1068
  */
1162
- interface ProjectFileRaw extends FileBaseRaw {
1163
- module: string | null;
1164
- projectId: string;
1069
+ declare class AsmBlock {
1070
+ label?: string;
1071
+ location: number;
1072
+ size: number;
1073
+ isString: boolean;
1074
+ objList: any[];
1075
+ structName?: string;
1076
+ bank?: number;
1077
+ includes?: Set<{
1078
+ block: ChunkFile;
1079
+ part: AsmBlock;
1080
+ }>;
1081
+ constructor(location?: number, size?: number, isString?: boolean, label?: string, structName?: string, bank?: number);
1165
1082
  }
1166
1083
  /**
1167
- * Complete Project payload containing branch data and files
1084
+ * Database part utilities
1168
1085
  */
1169
- interface ProjectPayload {
1170
- projectBranch: ProjectBranchData;
1171
- projectFiles: ProjectFileData[];
1172
- baseRomBranch: BaseRomBranchData;
1173
- baseRomFiles: BaseRomFileData[];
1086
+ declare class AsmBlockUtils {
1087
+ /**
1088
+ * Check if a location is inside this part
1089
+ */
1090
+ static isInside(part: AsmBlock, location: number): boolean;
1091
+ /**
1092
+ * Check if a location is outside this part
1093
+ */
1094
+ static isOutside(part: AsmBlock, location: number): boolean;
1174
1095
  }
1096
+ //#endregion
1097
+ //#region src/types/bitstream.d.ts
1175
1098
  /**
1176
- * Options for loading Project data by name
1099
+ * Bit stream for reading/writing binary data at bit level
1100
+ * Converted from GaiaLib/Types/BitStream.cs
1177
1101
  */
1178
- interface FromSupabaseByProjectOptions {
1179
- projectName: string;
1102
+ declare class BitStream {
1103
+ private static readonly NIBBLE_MASK;
1104
+ private static readonly NIBBLE_PERFECT_POSITION;
1105
+ private data;
1106
+ private position;
1107
+ private bitFlag;
1108
+ private writeSample;
1109
+ constructor(data: Uint8Array, position?: number);
1110
+ get dataArray(): Uint8Array;
1111
+ get currentPosition(): number;
1112
+ set currentPosition(value: number);
1180
1113
  /**
1181
- * Name of the branch to load
1182
- * Set to null to load the main/develop branch
1183
- * Set to undefined to not filter by branch name
1114
+ * Read a byte from the stream
1115
+ * @returns The byte read, or -1 if the end of the data has been reached
1184
1116
  */
1185
- branchName?: string | null;
1117
+ readByte(): number;
1186
1118
  /**
1187
- * Version of the branch to load
1188
- * Set to null to load the latest/main version
1189
- * Set to undefined to not filter by version
1119
+ * Read a ushort from the stream (ignores the current bit flag)
1120
+ * @returns The short read, or -1 if the end of the data has been reached
1190
1121
  */
1191
- branchVersion?: number | null;
1122
+ readShort(): number;
1123
+ /**
1124
+ * Read a bit from the stream
1125
+ * @returns True if the current bit at bitFlag is set, false otherwise
1126
+ */
1127
+ readBit(): boolean;
1128
+ /**
1129
+ * Read a nibble from the stream
1130
+ * @returns The nibble read, or -1 if the end of the data has been reached
1131
+ */
1132
+ readNibble(): number;
1133
+ /**
1134
+ * Write a bit to the stream
1135
+ * @param set True if the current bit should be set, false otherwise
1136
+ */
1137
+ writeBit(set: boolean): void;
1138
+ /**
1139
+ * Write a byte to the stream
1140
+ * @param value The byte to write
1141
+ */
1142
+ writeByte(value: number): void;
1143
+ /**
1144
+ * Write a nibble to the stream
1145
+ * @param value The nibble to write
1146
+ */
1147
+ writeNibble(value: number): void;
1148
+ flush(): void;
1192
1149
  }
1150
+ //#endregion
1151
+ //#region src/types/compression-registry.d.ts
1193
1152
  /**
1194
- * Query statistics for performance monitoring
1153
+ * Registry for compression providers
1154
+ * Allows registration of compression implementations by string ID
1195
1155
  */
1196
- interface QueryStats {
1197
- branchQueryTime: number;
1198
- fileQueryTime: number;
1199
- totalTime: number;
1200
- fileCount: number;
1156
+ declare class CompressionRegistry {
1157
+ private static providers;
1158
+ /**
1159
+ * Register a compression provider
1160
+ * @param id String identifier for the compression type
1161
+ * @param factory Factory function that creates the compression provider
1162
+ */
1163
+ static register(id: string, factory: () => ICompressionProvider): void;
1164
+ /**
1165
+ * Get a compression provider by ID
1166
+ * @param id String identifier for the compression type
1167
+ * @returns Compression provider instance
1168
+ */
1169
+ static get(id: string): ICompressionProvider;
1170
+ /**
1171
+ * Check if a compression provider is registered
1172
+ * @param id String identifier for the compression type
1173
+ * @returns True if provider is registered
1174
+ */
1175
+ static has(id: string): boolean;
1176
+ /**
1177
+ * Get list of registered provider IDs
1178
+ * @returns Array of registered provider IDs
1179
+ */
1180
+ static getRegisteredIds(): string[];
1181
+ /**
1182
+ * Clear all registered providers (mainly for testing)
1183
+ */
1184
+ static clear(): void;
1201
1185
  }
1202
1186
  //#endregion
1203
- //#region src/database/modules.d.ts
1204
- interface DbGameRomModule {
1205
- supaProjectFiles?: ProjectFileData[];
1206
- supaBaseRomFiles?: BaseRomFileData[];
1207
- mnemonics: Record<number, string>;
1208
- overrides: Record<number, Record<string, number>>;
1209
- rewrites: Record<string, number>;
1210
- blocks: Record<string, Record<string, Partial<DbBlock>>>;
1211
- files: Record<string, Record<string, Record<string, Partial<DbFile>>>>;
1212
- config: DbConfig;
1213
- labels: Record<number, string>;
1214
- structs: Record<string, DbStruct>;
1215
- copdef: Record<string, Partial<CopDef>>;
1216
- strings: Record<string, Partial<DbStringType>>;
1217
- transforms: Record<string, Partial<DbTransform>[]>;
1218
- addrModes: Record<string, Partial<DbAddressingMode>>;
1219
- headers: Partial<DbHeader>[];
1220
- groups: Record<string, Partial<DbGroup>>;
1221
- fileTypes: Record<string, Partial<DbFileType>>;
1187
+ //#region src/types/constants.d.ts
1188
+ /**
1189
+ * ROM processing constants
1190
+ * Converted from GaiaLib/Types/RomProcessingConstants.cs
1191
+ */
1192
+ declare class RomProcessingConstants {
1193
+ static readonly PAGE_SIZE = 32768;
1194
+ static readonly SNES_HEADER_SIZE = 80;
1195
+ static readonly DICTIONARIES: string[];
1196
+ static readonly DICT_COMMANDS: number[];
1197
+ static readonly END_CHARS: number[];
1198
+ static readonly WHITESPACE: string[];
1199
+ static readonly OPERATORS: string[];
1200
+ static readonly COMMA_SPACE: string[];
1201
+ static readonly ADDRESS_SPACE: string[];
1202
+ static readonly SYMBOL_SPACE: string[];
1203
+ static readonly LABEL_SPACE: string[];
1204
+ static readonly OBJECT_SPACE: string[];
1205
+ static readonly COP_SPLIT_CHARS: string[];
1206
+ static readonly WHITESPACE_REGEX: RegExp;
1207
+ static readonly COMMA_SPACE_REGEX: RegExp;
1208
+ static readonly SYMBOL_SPACE_REGEX: RegExp;
1209
+ static readonly LABEL_SPACE_REGEX: RegExp;
1210
+ static readonly OBJECT_SPACE_REGEX: RegExp;
1211
+ static readonly ADDRESS_SPACE_REGEX: RegExp;
1212
+ static readonly COP_SPLIT_REGEX: RegExp;
1213
+ static readonly COMMA_SPACE_TRIM_REGEX: RegExp;
1214
+ /**
1215
+ * Gets the size of an object for processing purposes
1216
+ * @param obj The object to get the size for
1217
+ * @returns Size in bytes
1218
+ * @throws Error when unable to determine size
1219
+ */
1220
+ static getSize(obj: unknown): number;
1222
1221
  }
1223
- interface DbBaseRomModule extends DbGameRomModule {
1224
- baseRomFiles: ChunkFile[];
1222
+ /**
1223
+ * BlockReader specific constants
1224
+ */
1225
+ declare class BlockReaderConstants {
1226
+ static readonly REF_SEARCH_MAX_RANGE = 416;
1227
+ static readonly BANK_MASK_CHECK = 64;
1228
+ static readonly BYTE_DELIMITER_THRESHOLD = 256;
1229
+ static readonly BANK_HIGH_MEMORY_1 = 126;
1230
+ static readonly BANK_HIGH_MEMORY_2 = 127;
1231
+ static readonly POINTER_CHARACTERS: string[];
1232
+ static readonly WIDE_STRING_TYPE = "WideString";
1233
+ static readonly BINARY_TYPE = "Binary";
1234
+ static readonly CODE_TYPE = "Code";
1235
+ static readonly LOCATION_FORMAT = "loc_{0:X6}";
1236
+ static readonly TYPE_NAME_FORMAT = "{0}_{1:X6}";
1237
+ static readonly OFFSET_FORMAT = "+{0:X}";
1238
+ static readonly MARKER_FORMAT = "+M";
1239
+ static readonly NEGATIVE_OFFSET_FORMAT = "-{0:X}";
1240
+ static readonly NEGATIVE_MARKER_FORMAT = "-M";
1225
1241
  }
1226
- interface DbProjectModule extends DbBaseRomModule {
1227
- projectFiles: ChunkFile[];
1242
+ //#endregion
1243
+ //#region src/types/location.d.ts
1244
+ /**
1245
+ * Location wrapper for additional metadata
1246
+ * Converted from GaiaLib/Types/LocationWrapper.cs
1247
+ */
1248
+ declare class LocationWrapper {
1249
+ location: number;
1250
+ type: AddressType;
1251
+ constructor(location: number, type: AddressType);
1228
1252
  }
1229
1253
  //#endregion
1230
- //#region src/database/header.d.ts
1231
- declare class DbHeader {
1232
- bank: number;
1233
- address: number;
1234
- condition?: string;
1235
- parts: DbHeaderPart[];
1236
- constructor(data: Partial<DbHeader>);
1254
+ //#region src/types/strings.d.ts
1255
+ /**
1256
+ * String marker for positioning
1257
+ * Converted from GaiaLib/Types/StringMarker.cs
1258
+ */
1259
+ interface StringMarker {
1260
+ offset: number;
1237
1261
  }
1238
- declare class DbHeaderPart {
1239
- name: string;
1240
- size: number;
1241
- type: string;
1242
- value?: any;
1243
- constructor(data: Partial<DbHeaderPart>);
1262
+ /**
1263
+ * String wrapper with type and location information
1264
+ * Converted from GaiaLib/Types/StringWrapper.cs
1265
+ */
1266
+ interface StringWrapper {
1267
+ string: string;
1268
+ type: DbStringType;
1269
+ marker: number;
1270
+ location: number;
1271
+ fixedSize: number;
1244
1272
  }
1245
- //#endregion
1246
- //#region src/database/root.d.ts
1247
1273
  /**
1248
- * Main database root class
1249
- * Converted from GaiaLib/Database/DbRoot.cs
1274
+ * String entry (commented out in original C# code)
1275
+ * Converted from GaiaLib/Types/StringEntry.cs
1250
1276
  */
1251
- interface DbRoot {
1252
- copDef: Record<number, CopDef>;
1253
- copLookup: Record<string, CopDef>;
1254
- mnemonics: Record<number, string>;
1255
- structs: Record<string, DbStruct>;
1256
- stringTypes: Record<string, DbStringType>;
1257
- stringDelimiters: string[];
1258
- stringDelimiterLookup: Record<string, DbStringType>;
1259
- headers: DbHeader[];
1260
- files: DbFile[];
1261
- config: DbConfig;
1262
- blocks: DbBlock[];
1263
- overrides: Record<number, Record<string, any>>;
1264
- labels: Record<number, string>;
1265
- rewrites: Record<number, number>;
1266
- entryPoints: DbEntryPoint[];
1267
- opCodes: Record<number, OpCode>;
1268
- opLookup: Record<string, OpCode[]>;
1269
- addrLookup: Record<string, DbAddressingMode>;
1270
- compression?: ICompressionProvider;
1271
- baseRomFiles?: ChunkFile[];
1272
- projectFiles?: ChunkFile[];
1273
- groups: Record<string, DbGroup>;
1274
- scenes: Record<number, DbScene>;
1275
- fileTypes: Record<string, DbFileType>;
1276
- fileExtLookup: Record<string, DbFileType>;
1277
+ interface StringEntry {
1278
+ block: AsmBlock;
1279
+ index: number;
1280
+ size: number;
1281
+ data: Uint8Array;
1277
1282
  }
1278
1283
  /**
1279
- * Database root utilities
1284
+ * String size comparer utility
1285
+ * Converted from GaiaLib/Types/StringSizeComparer.cs
1280
1286
  */
1281
- declare class DbRootUtils {
1287
+ declare class StringSizeComparer {
1282
1288
  /**
1283
- * JSON serialization options
1289
+ * Compare two strings by length
1284
1290
  */
1285
- static fromGameModule(module: DbGameRomModule): DbRoot;
1286
- static applyFolder(root: DbRoot, folderPath: string, sourceFiles?: ChunkFile[], group?: string): Promise<ChunkFile[]>;
1287
- static extractAllContent(root: DbRoot, romPath: string, outPath: string): Promise<void>;
1288
- static rebuildAllContent(root: DbRoot, inPath: string[], outPath: string): Promise<ChunkFile[]>;
1291
+ static compare(a: string, b: string): number;
1292
+ /**
1293
+ * Compare two StringWrapper objects by string length
1294
+ */
1295
+ static compareWrappers(a: StringWrapper, b: StringWrapper): number;
1289
1296
  }
1290
1297
  //#endregion
1291
- //#region src/database/labels.d.ts
1298
+ //#region src/types/structs.d.ts
1292
1299
  /**
1293
- * Database label definition
1294
- * Converted from GaiaLib/Database/DbLabel.cs
1300
+ * Structure definition
1301
+ * Converted from GaiaLib/Types/StructDef.cs
1295
1302
  */
1296
- interface DbLabel {
1297
- location: number;
1298
- label: string;
1303
+ interface StructDef {
1304
+ name: string;
1305
+ parts: unknown[];
1299
1306
  }
1300
1307
  //#endregion
1301
- //#region src/database/mnemonics.d.ts
1302
- /**
1303
- * Database mnemonic definition
1304
- * Converted from GaiaLib/Database/DbMnemonic.cs
1305
- */
1306
- interface DbMnemonic {
1307
- key: number;
1308
- value: string;
1309
- metadata?: string;
1308
+ //#region src/types/tables.d.ts
1309
+ declare class TableEntry {
1310
+ location: number;
1311
+ object: unknown;
1312
+ constructor(location: number);
1310
1313
  }
1311
1314
  //#endregion
1312
- //#region src/database/overrides.d.ts
1313
- declare class DbOverride {
1314
- location: number;
1315
- register: string;
1315
+ //#region src/types/operands.d.ts
1316
+ declare class TypedNumber {
1316
1317
  value: number;
1317
- constructor(values: Partial<DbOverride>);
1318
+ size: number;
1319
+ constructor(value: number, size: number);
1320
+ }
1321
+ declare class Byte extends TypedNumber {
1322
+ constructor(value: number);
1323
+ }
1324
+ declare class Word extends TypedNumber {
1325
+ constructor(value: number);
1326
+ }
1327
+ declare class Long extends TypedNumber {
1328
+ constructor(value: number);
1318
1329
  }
1319
1330
  //#endregion
1320
- //#region src/database/rewrites.d.ts
1331
+ //#region src/assembly/Registers.d.ts
1321
1332
  /**
1322
- * Database rewrite rule definition
1323
- * Converted from GaiaLib/Database/DbRewrite.cs
1333
+ * Manages the 65816 processor registers and status flags
1324
1334
  */
1325
- interface DbRewrite {
1326
- location: number;
1327
- value: number;
1335
+ declare class Registers {
1336
+ value: Record<string, number>;
1337
+ stack: Stack;
1338
+ mode: MemoryMapMode;
1339
+ constructor(mode: MemoryMapMode);
1328
1340
  }
1329
1341
  //#endregion
1330
- //#region src/database/sfx.d.ts
1342
+ //#region src/rom/extraction/processor.d.ts
1343
+ declare class MapExt<K, V> extends Map<K, V> {
1344
+ constructor();
1345
+ tryAdd(key: K, value: V): boolean;
1346
+ setFlag(key: K, flag: number, value?: boolean): void;
1347
+ clearFlag(key: K, flag: number): void;
1348
+ }
1331
1349
  /**
1332
- * Database sound effect definition
1333
- * Converted from GaiaLib/Database/DbSfx.cs
1350
+ * Manages CPU processor state during ROM analysis
1351
+ * Converted from GaiaLib/Rom/Extraction/ProcessorStateManager.cs
1334
1352
  */
1335
- interface DbSfx {
1336
- location: number;
1337
- size: number;
1338
- names: string[];
1353
+ declare class ProcessorStateManager {
1354
+ readonly stackPositions: MapExt<number, number>;
1355
+ private readonly _buckets;
1356
+ get(key: string): MapExt<number, number>;
1357
+ /**
1358
+ * Hydrate processor registers with stored state
1359
+ * Uses Registers from gaia-core/assembly for processor state management
1360
+ */
1361
+ hydrateRegisters(position: number, reg: Registers): void;
1362
+ getStackPosition(location: number): number | undefined;
1363
+ setStackPosition(location: number, value: number): void;
1364
+ tryAddStackPosition(location: number, value: number): boolean;
1339
1365
  }
1340
1366
  //#endregion
1341
- //#region src/rom/extraction/references.d.ts
1367
+ //#region src/rom/extraction/reader.d.ts
1342
1368
  /**
1343
- * Manages references, chunks, and markers during ROM analysis
1344
- * Converted from GaiaLib/Rom/Extraction/ReferenceManager.cs
1369
+ * Provides low-level ROM data reading functionality
1370
+ * Converted from GaiaLib/Rom/Extraction/RomDataReader.cs
1345
1371
  */
1346
- declare class ReferenceManager {
1347
- readonly structTable: Map<number, string>;
1348
- readonly markerTable: Map<number, number>;
1349
- readonly nameTable: Map<number, string>;
1350
- private readonly root;
1351
- constructor(root: DbRoot);
1352
- tryGetStruct(location: number): {
1353
- found: boolean;
1354
- chunkType?: string;
1355
- };
1356
- tryAddStruct(location: number, chunkType: string): boolean;
1357
- containsStruct(location: number): boolean;
1358
- tryGetName(location: number): {
1359
- found: boolean;
1360
- referenceName?: string;
1361
- };
1362
- tryAddName(location: number, referenceName: string): boolean;
1363
- tryGetMarker(location: number): {
1364
- found: boolean;
1365
- offset?: number;
1366
- };
1367
- setMarker(location: number, offset: number): void;
1368
- createBranchLabel(location: number): string;
1369
- createTypeName(type: string, location: number): string;
1370
- createFallbackName(location: number): string;
1371
- /**
1372
- * Finds a reference location by its assigned name.
1373
- */
1374
- findLocationByName(name: string): number | undefined;
1375
- resolveName(location: number, type: AddressType, isBranch: boolean): string;
1376
- findClosestReference(location: number): string | null;
1377
- private processRewrite;
1378
- private processClosestMatch;
1372
+ declare class RomDataReader {
1373
+ romData: Uint8Array;
1374
+ position: number;
1375
+ offset: number;
1376
+ constructor(romData: Uint8Array, offset?: number);
1377
+ readByte(): number;
1378
+ readSByte(): number;
1379
+ readUShort(): number;
1380
+ readShort(): number;
1381
+ readAddress(): number;
1382
+ readInt(): number;
1383
+ peekByte(): number;
1384
+ peekShort(): number;
1385
+ peekAddress(): number;
1379
1386
  }
1380
1387
  //#endregion
1381
1388
  //#region src/rom/extraction/strings.d.ts
@@ -1452,10 +1459,10 @@ declare class BlockReader {
1452
1459
  readonly _root: DbRoot;
1453
1460
  readonly _stringReader: StringReader;
1454
1461
  readonly _asmReader: AsmReader;
1455
- readonly _typeParser: TypeParser;
1456
- readonly _romDataReader: RomDataReader;
1462
+ _typeParser: TypeParser;
1463
+ _romDataReader: RomDataReader;
1457
1464
  readonly _stateManager: ProcessorStateManager;
1458
- readonly _referenceManager: ReferenceManager;
1465
+ _referenceManager: ReferenceManager;
1459
1466
  _partEnd: number;
1460
1467
  _currentChunk: ChunkFile | null;
1461
1468
  _currentAsmBlock: AsmBlock | null;
@@ -1476,7 +1483,6 @@ declare class BlockReader {
1476
1483
  /**
1477
1484
  * Resolves name for a location (delegated to ReferenceManager)
1478
1485
  */
1479
- resolveName(location: number, type: AddressType, isBranch: boolean): string;
1480
1486
  /**
1481
1487
  * Resolves include for a location
1482
1488
  */
@@ -1505,7 +1511,7 @@ declare class BlockReader {
1505
1511
  /**
1506
1512
  * Processes a single part
1507
1513
  */
1508
- private processPart;
1514
+ processPart(part: AsmBlock): void;
1509
1515
  /**
1510
1516
  * Processes a continuous entry (same type as previous)
1511
1517
  */
@@ -1768,16 +1774,16 @@ declare class RomWriter {
1768
1774
  * Parse assembly blocks and write binary data to output buffer
1769
1775
  * Converted from ext/GaiaLib/Rom/Rebuild/RomWriter.cs ParseAssembly method
1770
1776
  */
1771
- private parseAssembly;
1777
+ static parseAssembly(root: DbRoot, blocks: AsmBlock[], fileLookup: Map<string, number>, includeLookup: Map<string, AsmBlock>, outBuffer: Uint8Array, addrOffset?: number): void;
1772
1778
  /**
1773
1779
  * Helper method to find index of any character from an array in a string
1774
1780
  */
1775
- private indexOfAny;
1781
+ static indexOfAny(str: string, chars: string[]): number;
1776
1782
  /**
1777
1783
  * Helper method to check if an object is a StringMarker
1778
1784
  */
1779
- private isStringMarker;
1780
- private isTableEntry;
1785
+ static isStringMarker(obj: unknown): obj is StringMarker;
1786
+ static isTableEntry(obj: unknown): obj is TableEntry;
1781
1787
  }
1782
1788
  //#endregion
1783
1789
  //#region src/rom/rebuild/processor.d.ts
@@ -3159,5 +3165,5 @@ declare const snes: {
3159
3165
  };
3160
3166
  declare const isPlatformNode: string | false;
3161
3167
  //#endregion
3162
- export { Address, AddressSpace, AddressType, AddressingModeHandler, AsmBlock, AsmBlockUtils, AsmReader, Assembler, AssemblerState, BaseRomBranchData, BaseRomBranchFileRaw, BaseRomData, BaseRomFileData, BaseRomFileRaw, BaseRomPayload, BinType, BitStream, BlockReader, BlockReaderConstants, BlockWriter, BranchBaseData, Byte, ChunkFile, ChunkFileUtils, CollaborationConfig, CompressionAlgorithms, CompressionRegistry, CopCommandProcessor, CopDef, CpuMode, Database, DbAddressingMode, DbAsset, DbBaseRomModule, DbBlock, DbConfig, DbEntryPoint, DbFile, DbFileType, DbGameRomModule, DbGroup, DbHeader, DbHeaderPart, DbLabel, DbMnemonic, DbOverride, DbPart, DbPath, DbProjectModule, DbRewrite, DbRoot, DbRootUtils, DbScene, DbSfx, DbStringCommand, DbStringDictionary, DbStringLayer, DbStringType, DbStruct, DbTransform, DeveloperData, DirectoryEntry, FileBaseData, FileBaseRaw, FileReadOptions, FromSupabaseByNameOptions, FromSupabaseByProjectOptions, GameData, GameDeveloperData, GameRomArtifactData, GameRomArtifactRaw, GameRomBranchArtifactRaw, GameRomBranchData, GameRomData, ICompressionProvider, LocationWrapper, Long, MapExt, MemberType, MemoryMapMode, ObjectType, Op, OpCode, OperationContext, PlatformBranchData, PlatformData, PostProcessor, ProcessorStateManager, ProjectBranchData, ProjectBranchFileRaw, ProjectConfig, ProjectData, ProjectFileData, ProjectFileRaw, ProjectPayload, QueryStats, QuintetLZ, ReferenceManager, RegionData, RegisterType, Registers, RomDataReader, RomGenerator, RomLayout, RomProcessingConstants, RomProcessor, RomState, RomStateUtils, RomWriter, SortedMap, SpriteFrame, SpriteGroup, SpriteMap, SpritePart, Stack, StackOperations, StatusFlags, StringEntry, StringMarker, StringProcessor, StringReader, StringSizeComparer, StringWrapper, StructDef, SupabaseErrorCode, SupabaseFromError, SupabaseResult, TableEntry, TransformProcessor, TypeParser, TypedNumber, Word, XformDef, XformType, base64ToUint8Array, binaryToUtf8String, bytesToHex, clamp, crc32_buffer, crc32_text_utf16, crc32_text_utf8, createChunkFileFromDbBlock, createChunkFileFromDbFile, createDbPath, createSupabaseClient, createTempDirectory, decodeBase64, decodeBase64String, decodeDataString, encodeBase64, encodeBase64String, fileExists, fromSupabaseByGameRom, fromSupabaseById, fromSupabaseByName, fromSupabaseByProject, getDirectory, getEnvVar, getNestedProperty, getSupabaseClient, hexToBytes, hexToUint8Array, indexOfAny, isPlatformNode, isValidBase64, listDirectory, readFileAsBinary, readFileAsText, readJsonFile, removeDirectory, resetSupabaseClient, saveFileAsBinary, saveFileAsText, snes, summaryFromSupabaseByProject, uint8ArrayToBase64, validateEnvironmentVariables };
3168
+ export { Address, AddressSpace, AddressType, AddressingModeHandler, AsmBlock, AsmBlockUtils, AsmReader, Assembler, AssemblerState, BaseRomBranchData, BaseRomBranchFileRaw, BaseRomData, BaseRomFileData, BaseRomFileRaw, BaseRomPayload, BinType, BitStream, BlockReader, BlockReaderConstants, BlockWriter, BranchBaseData, Byte, ChunkFile, ChunkFileUtils, CollaborationConfig, CompressionAlgorithms, CompressionRegistry, CopCommandProcessor, CopDef, CpuMode, Database, DbAddressingMode, DbAsset, DbBaseRomModule, DbBlock, DbConfig, DbEntryPoint, DbFile, DbFileType, DbGameRomModule, DbGroup, DbHeader, DbHeaderPart, DbLabel, DbMnemonic, DbOverride, DbPart, DbPath, DbProjectModule, DbRewrite, DbRoot, DbRootUtils, DbScene, DbSfx, DbStringCommand, DbStringDictionary, DbStringLayer, DbStringType, DbStruct, DbTransform, DeveloperData, DirectoryEntry, FileBaseData, FileBaseRaw, FileReadOptions, FromSupabaseByNameOptions, FromSupabaseByProjectOptions, GameData, GameDeveloperData, GameRomArtifactData, GameRomArtifactRaw, GameRomBranchArtifactRaw, GameRomBranchData, GameRomData, ICompressionProvider, LocationWrapper, Long, MapExt, MemberType, MemoryMapMode, ObjectType, Op, OpCode, OperationContext, PlatformBranchData, PlatformData, PostProcessor, ProcessorStateManager, ProjectBranchData, ProjectBranchFileRaw, ProjectConfig, ProjectData, ProjectFileData, ProjectFileRaw, ProjectPayload, QueryStats, QuintetLZ, ReferenceManager, RegionData, RegisterType, Registers, RomDataReader, RomGenerator, RomLayout, RomProcessingConstants, RomProcessor, RomState, RomStateUtils, RomWriter, SortedMap, SpriteFrame, SpriteGroup, SpriteMap, SpritePart, Stack, StackOperations, StatusFlags, StringEntry, StringMarker, StringProcessor, StringReader, StringSizeComparer, StringWrapper, StructDef, SupabaseErrorCode, SupabaseFromError, SupabaseResult, TableEntry, TransformProcessor, TypeParser, TypedNumber, Word, XformDef, XformType, base64ToUint8Array, binaryToUtf8String, bytesToHex, clamp, combineHeader, crc32_buffer, crc32_text_utf16, crc32_text_utf8, createDbPath, createSupabaseClient, createTempDirectory, decodeBase64, decodeBase64String, decodeDataString, encodeBase64, encodeBase64String, fileExists, fromSupabaseByGameRom, fromSupabaseById, fromSupabaseByName, fromSupabaseByProject, getDirectory, getEnvVar, getNestedProperty, getSupabaseClient, hexToBytes, hexToUint8Array, indexOfAny, isPlatformNode, isValidBase64, listDirectory, readFileAsBinary, readFileAsText, readJsonFile, removeDirectory, resetSupabaseClient, saveFileAsBinary, saveFileAsText, snes, summaryFromSupabaseByProject, uint8ArrayToBase64, validateEnvironmentVariables };
3163
3169
  //# sourceMappingURL=index.d.mts.map