@rhyster/wow-casc-dbc 2.11.5 → 2.11.7

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 +1 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU;;;;;CAKf,CAAC;AA0HF,eAAO,MAAM,WAAW,aACV,MAAM,EAAE,OACb,MAAM,QACL,MAAM,OAAO,UAAU,aAClB,MAAM,2EAOd;IACC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,KACF,OAAO,CAAC,MAAM,CA0BhB,CAAC;AAEF,eAAO,MAAM,aAAa,aACZ,MAAM,EAAE,OACb,MAAM,uCAGR;IACC,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACrD,KACF,OAAO,CAAC,MAAM,CAGhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,WACnB,MAAM,WACL,MAAM,KAChB,OAAO,CAAC,MAAM,CAQhB,CAAC;AAEF,eAAO,MAAM,cAAc,WACf,MAAM,WACL,MAAM,KAChB,OAAO,CAAC,MAAM,CAQhB,CAAC"}
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,UAAU;;;;;CAKf,CAAC;AA0HF,eAAO,MAAM,WAAW,GACpB,UAAU,MAAM,EAAE,EAClB,KAAK,MAAM,EACX,MAAM,MAAM,OAAO,UAAU,EAC7B,WAAW,MAAM,EACjB,yEAMG;IACC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CACxB,KACP,OAAO,CAAC,MAAM,CA0BhB,CAAC;AAEF,eAAO,MAAM,aAAa,GACtB,UAAU,MAAM,EAAE,EAClB,KAAK,MAAM,EACX,qCAEG;IACC,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CAChD,KACP,OAAO,CAAC,MAAM,CAGhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC3B,QAAQ,MAAM,EACd,SAAS,MAAM,KAChB,OAAO,CAAC,MAAM,CAQhB,CAAC;AAEF,eAAO,MAAM,cAAc,GACvB,QAAQ,MAAM,EACd,SAAS,MAAM,KAChB,OAAO,CAAC,MAAM,CAQhB,CAAC"}
package/dist/index.cjs CHANGED
@@ -322,7 +322,7 @@ class BLTEReader {
322
322
  this.processedBlock += 1;
323
323
  this.processedOffset += block.compressedSize;
324
324
  }
325
- return allowMissingKey ? missingKeyBlocks : undefined;
325
+ return allowMissingKey ? missingKeyBlocks : void 0;
326
326
  }
327
327
  }
328
328
 
@@ -374,12 +374,12 @@ const requestData = async (url, {
374
374
  // eslint-disable-next-line @typescript-eslint/naming-convention
375
375
  "User-Agent": USER_AGENT,
376
376
  // eslint-disable-next-line @typescript-eslint/naming-convention
377
- Range: partialOffset !== undefined && partialLength !== undefined ? `bytes=${partialOffset.toString()}-${(partialOffset + partialLength - 1).toString()}` : "bytes=0-"
377
+ Range: partialOffset !== void 0 && partialLength !== void 0 ? `bytes=${partialOffset.toString()}-${(partialOffset + partialLength - 1).toString()}` : "bytes=0-"
378
378
  }
379
379
  };
380
380
  http__default.get(url, options, (res) => {
381
381
  if (res.statusCode === 301 || res.statusCode === 302) {
382
- if (res.headers.location !== undefined) {
382
+ if (res.headers.location !== void 0) {
383
383
  requestData(res.headers.location, { partialOffset, partialLength, showProgress }).then(resolve).catch((err) => {
384
384
  throw err;
385
385
  });
@@ -388,13 +388,13 @@ const requestData = async (url, {
388
388
  }
389
389
  return;
390
390
  }
391
- if (res.statusCode === undefined || res.statusCode < 200 || res.statusCode > 302) {
391
+ if (res.statusCode === void 0 || res.statusCode < 200 || res.statusCode > 302) {
392
392
  reject(new Error(`Failed to request ${url}, Status Code: ${res.statusCode?.toString() ?? "undefined"}`));
393
393
  return;
394
394
  }
395
395
  const lengthText = res.headers["content-length"];
396
- const length = lengthText !== undefined ? parseInt(lengthText, 10) : 0;
397
- const bar = showProgress === true && !Number.isNaN(length) && length >= 10485760 ? new cliProgress__default.SingleBar({ etaBuffer: 10240 }, cliProgress__default.Presets.shades_classic) : undefined;
396
+ const length = lengthText !== void 0 ? parseInt(lengthText, 10) : 0;
397
+ const bar = showProgress === true && !Number.isNaN(length) && length >= 10485760 ? new cliProgress__default.SingleBar({ etaBuffer: 10240 }, cliProgress__default.Presets.shades_classic) : void 0;
398
398
  bar?.start(length, 0);
399
399
  const chunks = [];
400
400
  res.on("data", (chunk) => {
@@ -430,7 +430,7 @@ const downloadFile = (prefixes, type, key, {
430
430
  };
431
431
  const getFileCache = async (file) => {
432
432
  const integrity = await cacheIntegrity.get(file);
433
- if (integrity !== undefined) {
433
+ if (integrity !== void 0) {
434
434
  try {
435
435
  const buffer = await fs__default.readFile(path__default.resolve(CACHE_ROOT, file));
436
436
  const hash = crypto__default.createHash("sha256").update(buffer).digest("hex");
@@ -440,7 +440,7 @@ const getFileCache = async (file) => {
440
440
  } catch {
441
441
  }
442
442
  }
443
- return undefined;
443
+ return void 0;
444
444
  };
445
445
  const getDataFile = async (prefixes, key, type, buildCKey, {
446
446
  name,
@@ -450,10 +450,10 @@ const getDataFile = async (prefixes, key, type, buildCKey, {
450
450
  showAttemptFail
451
451
  } = {}) => {
452
452
  const dir = type === "build" ? path__default.join(CACHE_DIRS[type], buildCKey) : CACHE_DIRS[type];
453
- const file = name !== undefined ? path__default.join(dir, name) : path__default.join(dir, key);
453
+ const file = name !== void 0 ? path__default.join(dir, name) : path__default.join(dir, key);
454
454
  const cacheBuffer = await getFileCache(file);
455
455
  if (cacheBuffer) {
456
- if (name === undefined && partialOffset !== undefined && partialLength !== undefined) {
456
+ if (name === void 0 && partialOffset !== void 0 && partialLength !== void 0) {
457
457
  return cacheBuffer.subarray(partialOffset, partialOffset + partialLength);
458
458
  }
459
459
  return cacheBuffer;
@@ -464,7 +464,7 @@ const getDataFile = async (prefixes, key, type, buildCKey, {
464
464
  showProgress,
465
465
  showAttemptFail
466
466
  });
467
- if (partialOffset === undefined && partialLength === undefined || name !== undefined) {
467
+ if (partialOffset === void 0 && partialLength === void 0 || name !== void 0) {
468
468
  await fs__default.mkdir(path__default.resolve(CACHE_ROOT, dir), { recursive: true });
469
469
  await fs__default.writeFile(path__default.resolve(CACHE_ROOT, file), downloadBuffer);
470
470
  const hash = crypto__default.createHash("sha256").update(downloadBuffer).digest("hex");
@@ -1420,7 +1420,7 @@ class WDCReader {
1420
1420
  return;
1421
1421
  }
1422
1422
  for (let recordIndex = 0; recordIndex < header.recordCount; recordIndex += 1) {
1423
- let recordID = idList.length > 0 ? idList[recordIndex] : undefined;
1423
+ let recordID = idList.length > 0 ? idList[recordIndex] : void 0;
1424
1424
  const recordBuffer = isNormal ? records[recordIndex] : offsetMap[recordIndex].data;
1425
1425
  if (isNormal) {
1426
1426
  const recordData = fieldsInfo.map((fieldInfo, fieldIndex) => {
@@ -1437,7 +1437,7 @@ class WDCReader {
1437
1437
  data: value
1438
1438
  };
1439
1439
  }
1440
- if (recordID === undefined && fieldIndex === idIndex) {
1440
+ if (recordID === void 0 && fieldIndex === idIndex) {
1441
1441
  recordID = value;
1442
1442
  }
1443
1443
  const fieldOffset = fieldInfo.fieldOffsetBits >>> 3;
@@ -1449,8 +1449,8 @@ class WDCReader {
1449
1449
  };
1450
1450
  }
1451
1451
  case "commonData": {
1452
- let value = recordID !== undefined ? commonData.get(fieldIndex)?.get(recordID) : undefined;
1453
- if (value === undefined) {
1452
+ let value = recordID !== void 0 ? commonData.get(fieldIndex)?.get(recordID) : void 0;
1453
+ if (value === void 0) {
1454
1454
  value = fieldInfo.defaultValue;
1455
1455
  }
1456
1456
  return {
@@ -1487,7 +1487,7 @@ class WDCReader {
1487
1487
  assert__default(fieldPalletData, `No pallet data for field ${fieldIndex.toString()}`);
1488
1488
  value = fieldPalletData[value];
1489
1489
  }
1490
- if (recordID === undefined && fieldIndex === idIndex) {
1490
+ if (recordID === void 0 && fieldIndex === idIndex) {
1491
1491
  recordID = value;
1492
1492
  }
1493
1493
  return {
@@ -1499,10 +1499,10 @@ class WDCReader {
1499
1499
  throw new Error("Unreachable");
1500
1500
  }
1501
1501
  });
1502
- assert__default(recordID !== undefined, "No record ID found");
1502
+ assert__default(recordID !== void 0, "No record ID found");
1503
1503
  this.rows.set(recordID, recordData);
1504
1504
  const foreignID = relationshipMap.get(recordIndex);
1505
- if (foreignID !== undefined) {
1505
+ if (foreignID !== void 0) {
1506
1506
  this.relationships.set(recordID, foreignID);
1507
1507
  }
1508
1508
  } else {
@@ -1510,10 +1510,10 @@ class WDCReader {
1510
1510
  type: "sparse",
1511
1511
  data: recordBuffer
1512
1512
  };
1513
- assert__default(recordID !== undefined, "No record ID found");
1513
+ assert__default(recordID !== void 0, "No record ID found");
1514
1514
  this.rows.set(recordID, recordData);
1515
1515
  const foreignID = relationshipMap.get(recordIndex);
1516
- if (foreignID !== undefined) {
1516
+ if (foreignID !== void 0) {
1517
1517
  this.relationships.set(recordID, foreignID);
1518
1518
  }
1519
1519
  }
@@ -1551,20 +1551,20 @@ class WDCReader {
1551
1551
  data: hotfix.data
1552
1552
  };
1553
1553
  case "delete":
1554
- return undefined;
1554
+ return void 0;
1555
1555
  default:
1556
1556
  throw new Error("Unreachable");
1557
1557
  }
1558
1558
  }
1559
1559
  const dst = this.copyTable.get(id);
1560
- if (dst !== undefined) {
1560
+ if (dst !== void 0) {
1561
1561
  return this.rows.get(dst);
1562
1562
  }
1563
1563
  return this.rows.get(id);
1564
1564
  }
1565
1565
  getRowRelationship(id) {
1566
1566
  const dst = this.copyTable.get(id);
1567
- if (dst !== undefined) {
1567
+ if (dst !== void 0) {
1568
1568
  return this.relationships.get(dst);
1569
1569
  }
1570
1570
  return this.relationships.get(id);
@@ -1649,7 +1649,7 @@ class CASCClient {
1649
1649
  const archiveKeys = cdnConfig.archives.split(" ");
1650
1650
  const archiveCount = archiveKeys.length;
1651
1651
  const archiveTotalSize = cdnConfig.archivesIndexSize.split(" ").reduce((a, b) => a + parseInt(b, 10), 0);
1652
- const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress__default.SingleBar({ etaBuffer: 100 }, cliProgress__default.Presets.shades_classic) : undefined;
1652
+ const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress__default.SingleBar({ etaBuffer: 100 }, cliProgress__default.Presets.shades_classic) : void 0;
1653
1653
  archiveBar?.start(archiveCount, 0);
1654
1654
  const archivesMapArray = await async.mapLimit(
1655
1655
  archiveKeys,
@@ -1697,7 +1697,7 @@ class CASCClient {
1697
1697
  }
1698
1698
  const cKey = configText;
1699
1699
  const eKeys = encoding.cKey2EKey.get(cKey);
1700
- assert__default(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1700
+ assert__default(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1701
1701
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1702
1702
  return [cKey, eKey];
1703
1703
  };
@@ -1825,7 +1825,7 @@ class CASCClient {
1825
1825
  assert__default(this.preload, "Client not initialized");
1826
1826
  const { prefixes, encoding, archives } = this.preload;
1827
1827
  const eKeys = encoding.cKey2EKey.get(cKey);
1828
- assert__default(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1828
+ assert__default(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1829
1829
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1830
1830
  const archive = archives.get(eKey);
1831
1831
  const blte = archive ? await getDataFile(prefixes, archive.key, "data", this.version.BuildConfig, {
@@ -1846,7 +1846,7 @@ class CASCClient {
1846
1846
  return {
1847
1847
  type: "full",
1848
1848
  buffer: reader.buffer,
1849
- blocks: undefined
1849
+ blocks: void 0
1850
1850
  };
1851
1851
  }
1852
1852
  const blocks = reader.processBytes(allowMissingKey);
@@ -1856,7 +1856,7 @@ class CASCClient {
1856
1856
  return {
1857
1857
  type: "full",
1858
1858
  buffer: reader.buffer,
1859
- blocks: undefined
1859
+ blocks: void 0
1860
1860
  };
1861
1861
  }
1862
1862
  return {
@@ -1920,7 +1920,7 @@ class DBDParser {
1920
1920
  const manifests = await (await fetch(manifestsURL)).json();
1921
1921
  const tableHashHex = this.wdc.tableHash.toString(16).padStart(8, "0").toLowerCase();
1922
1922
  const manifest = manifests.find((v) => v.tableHash.toLowerCase() === tableHashHex);
1923
- assert__default(manifest?.tableName !== undefined, `No manifest found for table hash ${tableHashHex}`);
1923
+ assert__default(manifest?.tableName !== void 0, `No manifest found for table hash ${tableHashHex}`);
1924
1924
  const url = `https://raw.githubusercontent.com/wowdev/WoWDBDefs/master/definitions/${manifest.tableName}.dbd`;
1925
1925
  const text = await (await fetch(url)).text();
1926
1926
  const lines = text.split("\n").map((v) => v.trim());
@@ -1947,7 +1947,7 @@ class DBDParser {
1947
1947
  const layoutsMatch = PATTERN_LAYOUT.exec(line);
1948
1948
  const layouts = layoutsMatch?.[1].split(",").map((v) => v.trim().toLowerCase());
1949
1949
  return layouts?.includes(layoutHashHex) === true;
1950
- }) !== undefined);
1950
+ }) !== void 0);
1951
1951
  assert__default(versionChunk, `No version definition found for layout hash ${layoutHashHex}`);
1952
1952
  versionChunk.forEach((line) => {
1953
1953
  if (line.startsWith("LAYOUT") || line.startsWith("BUILD") || line.startsWith("COMMENT")) {
@@ -1967,10 +1967,10 @@ class DBDParser {
1967
1967
  arraySizeText
1968
1968
  ] = match;
1969
1969
  const type = this.definitions.get(name);
1970
- assert__default(type !== undefined, `No type found for column ${name}`);
1970
+ assert__default(type !== void 0, `No type found for column ${name}`);
1971
1971
  const annotations = annotationsText ? annotationsText.split(",").map((v) => v.trim()) : [];
1972
- const size = sizeText ? parseInt(sizeText, 10) : undefined;
1973
- const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : undefined;
1972
+ const size = sizeText ? parseInt(sizeText, 10) : void 0;
1973
+ const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : void 0;
1974
1974
  const isID = !!annotations.includes("id");
1975
1975
  const isInline = !annotations.includes("noninline");
1976
1976
  const isRelation = !!annotations.includes("relation");
@@ -2002,7 +2002,7 @@ class DBDParser {
2002
2002
  }
2003
2003
  const row = this.wdc.getRowData(id);
2004
2004
  if (!row) {
2005
- return undefined;
2005
+ return void 0;
2006
2006
  }
2007
2007
  const data = {};
2008
2008
  if (Array.isArray(row)) {
@@ -2019,13 +2019,13 @@ class DBDParser {
2019
2019
  const fieldInfo = this.wdc.fieldsInfo[fieldIndex];
2020
2020
  const srcSigned = fieldInfo.storageType === "bitpackedSigned";
2021
2021
  const srcSize = fieldInfo.storageType === "none" || fieldInfo.storageType === "bitpacked" || fieldInfo.storageType === "bitpackedSigned" ? Math.ceil(fieldInfo.fieldSizeBits / 8) : 4;
2022
- const dstSize = column.size !== undefined ? Math.ceil(column.size / 8) : undefined;
2022
+ const dstSize = column.size !== void 0 ? Math.ceil(column.size / 8) : void 0;
2023
2023
  if (cell.type === "bitpackedArray") {
2024
2024
  data[column.name] = cell.data.map((v) => {
2025
2025
  if (column.type === "float") {
2026
2026
  return castFloat(v, srcSize, srcSigned);
2027
2027
  }
2028
- if (dstSize !== undefined) {
2028
+ if (dstSize !== void 0) {
2029
2029
  return castIntegerBySize(
2030
2030
  v,
2031
2031
  srcSize,
@@ -2043,7 +2043,7 @@ class DBDParser {
2043
2043
  data[column.name] = cell.string;
2044
2044
  }
2045
2045
  } else if (column.type === "float") {
2046
- if (column.arraySize !== undefined) {
2046
+ if (column.arraySize !== void 0) {
2047
2047
  const castBuffer = getCastBuffer(
2048
2048
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2049
2049
  srcSize,
@@ -2060,8 +2060,8 @@ class DBDParser {
2060
2060
  data[column.name] = castFloat(cell.data, srcSize, srcSigned);
2061
2061
  }
2062
2062
  } else if (column.type === "int") {
2063
- if (column.arraySize !== undefined) {
2064
- assert__default(dstSize !== undefined, `Missing size for int array column ${column.name}`);
2063
+ if (column.arraySize !== void 0) {
2064
+ assert__default(dstSize !== void 0, `Missing size for int array column ${column.name}`);
2065
2065
  const castBuffer = getCastBuffer(
2066
2066
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2067
2067
  srcSize,
@@ -2106,7 +2106,7 @@ class DBDParser {
2106
2106
  column.isSigned
2107
2107
  );
2108
2108
  } else {
2109
- assert__default(column.size === undefined || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2109
+ assert__default(column.size === void 0 || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2110
2110
  if (srcSigned !== column.isSigned) {
2111
2111
  data[column.name] = castBigInt64(
2112
2112
  cell.data,
@@ -2160,7 +2160,7 @@ class DBDParser {
2160
2160
  if (fieldIndex + 1 < this.wdc.fields.length) {
2161
2161
  count = Math.max((nextField.position - currField.position) / size, 1);
2162
2162
  } else {
2163
- count = column.arraySize !== undefined ? (buffer.byteLength - offset) / size : 1;
2163
+ count = column.arraySize !== void 0 ? (buffer.byteLength - offset) / size : 1;
2164
2164
  }
2165
2165
  for (let i = 0; i < count; i += 1) {
2166
2166
  if (column.type === "float") {