@jamiephan/casclib 0.0.0-dev.6 → 0.0.1

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/README.md CHANGED
@@ -58,8 +58,16 @@ import { Storage, File } from '@jamiephan/casclib';
58
58
  // CommonJS
59
59
  const { Storage, File } = require('@jamiephan/casclib');
60
60
 
61
- // Advanced: Direct binding access
62
- import { CascStorageBinding, CascStorage, CascFile } from '@jamiephan/casclib/bindings';
61
+ // Advanced: Direct binding access (low-level API)
62
+ import { CascStorageBinding, CascStorage, CascFile } from '@jamiephan/casclib';
63
+
64
+ // Import constants and enums
65
+ import {
66
+ CASC_OPEN_BY_NAME,
67
+ CASC_LOCALE_ENUS,
68
+ CascStorageInfoClass,
69
+ CascFileInfoClass
70
+ } from '@jamiephan/casclib';
63
71
  ```
64
72
 
65
73
  ### Opening a CASC Storage
@@ -231,6 +239,31 @@ storage.open('/path/to/heroes/HeroesData');
231
239
  storage.open('/path/to/heroes/HeroesData', { flags: 0 });
232
240
  ```
233
241
 
242
+ ##### `openEx(params: string, options?: CascOpenStorageExOptions): void`
243
+ Opens a CASC storage with extended parameters.
244
+
245
+ **Parameters:**
246
+ - `params`: Path or parameter string
247
+ - `options`: Extended opening options
248
+ - `localPath`: Local path to storage
249
+ - `codeName`: Product code name
250
+ - `region`: Server region
251
+ - `localeMask`: Locale mask for filtering files
252
+ - `flags`: Opening flags
253
+ - `buildKey`: Specific build key
254
+ - `cdnHostUrl`: CDN host URL
255
+ - `online`: Whether to use online mode
256
+
257
+ **Example:**
258
+ ```typescript
259
+ storage.openEx('/path/to/storage', {
260
+ localPath: '/path/to/storage',
261
+ codeName: 'hero',
262
+ region: 'us',
263
+ flags: 0
264
+ });
265
+ ```
266
+
234
267
  ##### `openOnline(path: string, options?: StorageOpenOptions): void`
235
268
  Opens an online CASC storage.
236
269
 
@@ -275,7 +308,7 @@ Closes the storage and releases resources.
275
308
  const closed = storage.close();
276
309
  ```
277
310
 
278
- ##### `getStorageInfo(infoClass: number): StorageInfo`
311
+ ##### `getStorageInfo(infoClass: number): CascStorageInfo`
279
312
  Gets storage information.
280
313
 
281
314
  **Parameters:**
@@ -341,7 +374,7 @@ if (info) {
341
374
 
342
375
  #### File Finding
343
376
 
344
- ##### `findFirstFile(mask?: string, listFile?: string): FindData | null`
377
+ ##### `findFirstFile(mask?: string, listFile?: string): CascFindData | null`
345
378
  Finds the first file matching the mask.
346
379
 
347
380
  **Parameters:**
@@ -358,7 +391,7 @@ if (findData) {
358
391
  }
359
392
  ```
360
393
 
361
- ##### `findNextFile(): FindData | null`
394
+ ##### `findNextFile(): CascFindData | null`
362
395
  Finds the next file in the search.
363
396
 
364
397
  **Returns:** Find data object or `null` if no more files
@@ -512,7 +545,7 @@ Gets the file size in bytes (64-bit).
512
545
  const size = file.getSize64();
513
546
  ```
514
547
 
515
- ##### `getFileInfo(infoClass: number): FileInfoResult`
548
+ ##### `getFileInfo(infoClass: number): CascFileInfoResult`
516
549
  Gets detailed file information.
517
550
 
518
551
  **Parameters:**
@@ -599,43 +632,165 @@ interface FileOpenOptions {
599
632
  flags?: number;
600
633
  }
601
634
 
635
+ interface CascOpenStorageExOptions {
636
+ localPath?: string;
637
+ codeName?: string;
638
+ region?: string;
639
+ localeMask?: number;
640
+ flags?: number;
641
+ buildKey?: string;
642
+ cdnHostUrl?: string;
643
+ online?: boolean;
644
+ }
645
+
602
646
  interface FileInfo {
603
647
  name: string;
604
648
  size: number;
605
649
  }
606
650
 
607
- interface FindData {
651
+ interface CascFindData {
608
652
  fileName: string;
653
+ ckey: Buffer;
654
+ ekey: Buffer;
655
+ tagBitMask: number;
609
656
  fileSize: number;
610
- localeFlags: number;
657
+ plainName: string | null;
611
658
  fileDataId: number;
659
+ localeFlags: number;
612
660
  contentFlags: number;
613
- // ... additional fields
661
+ spanCount: number;
662
+ available: boolean;
663
+ nameType: CascNameType;
614
664
  }
615
665
 
616
- interface StorageInfo {
617
- // Storage-specific information
666
+ interface CascStorageInfo {
667
+ fileCount?: number;
668
+ features?: number;
669
+ codeName?: string;
670
+ buildNumber?: number;
618
671
  }
619
672
 
620
- interface FileInfoResult {
621
- // File-specific information
673
+ interface CascFileInfoResult {
674
+ ckey?: Buffer;
675
+ ekey?: Buffer;
676
+ dataFileName?: string;
677
+ storageOffset?: number;
678
+ segmentOffset?: number;
679
+ tagBitMask?: number;
680
+ fileNameHash?: number;
681
+ contentSize?: number;
682
+ encodedSize?: number;
683
+ segmentIndex?: number;
684
+ spanCount?: number;
685
+ fileDataId?: number;
686
+ localeFlags?: number;
687
+ contentFlags?: number;
622
688
  }
623
689
  ```
624
690
 
691
+ ## Enums
692
+
693
+ ```typescript
694
+ enum CascStorageInfoClass {
695
+ LocalFileCount = 0,
696
+ TotalFileCount = 1,
697
+ Features = 2,
698
+ InstalledLocales = 3,
699
+ Product = 4,
700
+ Tags = 5,
701
+ PathProduct = 6
702
+ }
703
+
704
+ enum CascFileInfoClass {
705
+ ContentKey = 0,
706
+ EncodedKey = 1,
707
+ FullInfo = 2,
708
+ SpanInfo = 3
709
+ }
710
+
711
+ enum CascNameType {
712
+ Full = 0,
713
+ DataId = 1,
714
+ CKey = 2,
715
+ EKey = 3
716
+ }
717
+ ```
718
+
719
+ ## Constants
720
+
721
+ The package exports numerous constants from CascLib. Here are some commonly used ones:
722
+
723
+ ### File Open Flags
724
+ ```typescript
725
+ CASC_OPEN_BY_NAME // Open file by name
726
+ CASC_OPEN_BY_CKEY // Open file by content key
727
+ CASC_OPEN_BY_EKEY // Open file by encoded key
728
+ CASC_OPEN_BY_FILEID // Open file by file ID
729
+ CASC_STRICT_DATA_CHECK // Enable strict data checking
730
+ CASC_OVERCOME_ENCRYPTED // Try to overcome encryption
731
+ ```
732
+
733
+ ### Locale Flags
734
+ ```typescript
735
+ CASC_LOCALE_ALL // All locales
736
+ CASC_LOCALE_ENUS // English (US)
737
+ CASC_LOCALE_KOKR // Korean
738
+ CASC_LOCALE_FRFR // French
739
+ CASC_LOCALE_DEDE // German
740
+ CASC_LOCALE_ZHCN // Chinese (Simplified)
741
+ CASC_LOCALE_ESES // Spanish (Spain)
742
+ CASC_LOCALE_ZHTW // Chinese (Traditional)
743
+ CASC_LOCALE_ENGB // English (GB)
744
+ // ... and more
745
+ ```
746
+
747
+ ### Content Flags
748
+ ```typescript
749
+ CASC_CFLAG_INSTALL // Install file
750
+ CASC_CFLAG_LOAD_ON_WINDOWS // Load on Windows
751
+ CASC_CFLAG_LOAD_ON_MAC // Load on macOS
752
+ CASC_CFLAG_ENCRYPTED // File is encrypted
753
+ CASC_CFLAG_NO_COMPRESSION // No compression
754
+ // ... and more
755
+ ```
756
+
757
+ ### Feature Flags
758
+ ```typescript
759
+ CASC_FEATURE_FILE_NAMES // Storage has file names
760
+ CASC_FEATURE_FILE_DATA_IDS // Storage has file data IDs
761
+ CASC_FEATURE_LOCALE_FLAGS // Storage has locale flags
762
+ CASC_FEATURE_ONLINE // Online storage
763
+ // ... and more
764
+ ```
765
+
766
+ ### File Positioning
767
+ ```typescript
768
+ FILE_BEGIN // Beginning of file
769
+ FILE_CURRENT // Current position
770
+ FILE_END // End of file
771
+ ```
772
+
773
+ See [lib/bindings.ts](lib/bindings.ts) for a complete list of available constants.
774
+
625
775
  ## Advanced Usage
626
776
 
627
777
  ### Direct Binding Access
628
778
 
629
- For advanced users who need direct access to the native bindings:
779
+ For advanced users who need direct access to the native bindings with exact CascLib.h function names:
630
780
 
631
781
  ```typescript
632
- import { CascStorageBinding, CascStorage, CascFile } from '@jamiephan/casclib/bindings';
633
- import * as constants from '@jamiephan/casclib';
782
+ import {
783
+ CascStorageBinding,
784
+ CascStorage,
785
+ CascFile,
786
+ CASC_OPEN_BY_NAME
787
+ } from '@jamiephan/casclib';
634
788
 
789
+ // Use the low-level binding interface directly
635
790
  const storage: CascStorage = new CascStorageBinding();
636
791
  storage.CascOpenStorage('/path/to/storage', 0);
637
792
 
638
- const file: CascFile = storage.CascOpenFile('filename.txt', constants.CASC_OPEN_BY_NAME);
793
+ const file: CascFile = storage.CascOpenFile('filename.txt', CASC_OPEN_BY_NAME);
639
794
  const size = file.CascGetFileSize64();
640
795
  const content = file.readFileAll();
641
796
  file.CascCloseFile();
@@ -643,6 +798,36 @@ file.CascCloseFile();
643
798
  storage.CascCloseStorage();
644
799
  ```
645
800
 
801
+ ### Utility Functions
802
+
803
+ The package also exports some utility functions:
804
+
805
+ ```typescript
806
+ import {
807
+ CascOpenLocalFile,
808
+ GetCascError,
809
+ SetCascError,
810
+ CascCdnGetDefault,
811
+ CascCdnDownload
812
+ } from '@jamiephan/casclib';
813
+
814
+ // Open a local file directly (outside of storage)
815
+ const localFile = CascOpenLocalFile('/path/to/file.txt');
816
+
817
+ // Get the last CASC error code
818
+ const errorCode = GetCascError();
819
+
820
+ // Get default CDN URL
821
+ const defaultCdn = CascCdnGetDefault();
822
+
823
+ // Download from CDN
824
+ const data = CascCdnDownload(
825
+ 'http://us.patch.battle.net:1119',
826
+ 'hero',
827
+ 'some-file.idx'
828
+ );
829
+ ```
830
+
646
831
  ### Binding Naming Convention
647
832
 
648
833
  The low-level bindings use **exact names from CascLib.h**:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamiephan/casclib",
3
- "version": "0.0.0-dev.6",
3
+ "version": "0.0.1",
4
4
  "description": "Node.js native bindings for CascLib - A library to read CASC storage from Blizzard games",
5
5
  "repository": {
6
6
  "type": "git",