@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.
package/dist/index.mjs CHANGED
@@ -310,7 +310,7 @@ class BLTEReader {
310
310
  this.processedBlock += 1;
311
311
  this.processedOffset += block.compressedSize;
312
312
  }
313
- return allowMissingKey ? missingKeyBlocks : undefined;
313
+ return allowMissingKey ? missingKeyBlocks : void 0;
314
314
  }
315
315
  }
316
316
 
@@ -362,12 +362,12 @@ const requestData = async (url, {
362
362
  // eslint-disable-next-line @typescript-eslint/naming-convention
363
363
  "User-Agent": USER_AGENT,
364
364
  // eslint-disable-next-line @typescript-eslint/naming-convention
365
- Range: partialOffset !== undefined && partialLength !== undefined ? `bytes=${partialOffset.toString()}-${(partialOffset + partialLength - 1).toString()}` : "bytes=0-"
365
+ Range: partialOffset !== void 0 && partialLength !== void 0 ? `bytes=${partialOffset.toString()}-${(partialOffset + partialLength - 1).toString()}` : "bytes=0-"
366
366
  }
367
367
  };
368
368
  http.get(url, options, (res) => {
369
369
  if (res.statusCode === 301 || res.statusCode === 302) {
370
- if (res.headers.location !== undefined) {
370
+ if (res.headers.location !== void 0) {
371
371
  requestData(res.headers.location, { partialOffset, partialLength, showProgress }).then(resolve).catch((err) => {
372
372
  throw err;
373
373
  });
@@ -376,13 +376,13 @@ const requestData = async (url, {
376
376
  }
377
377
  return;
378
378
  }
379
- if (res.statusCode === undefined || res.statusCode < 200 || res.statusCode > 302) {
379
+ if (res.statusCode === void 0 || res.statusCode < 200 || res.statusCode > 302) {
380
380
  reject(new Error(`Failed to request ${url}, Status Code: ${res.statusCode?.toString() ?? "undefined"}`));
381
381
  return;
382
382
  }
383
383
  const lengthText = res.headers["content-length"];
384
- const length = lengthText !== undefined ? parseInt(lengthText, 10) : 0;
385
- const bar = showProgress === true && !Number.isNaN(length) && length >= 10485760 ? new cliProgress.SingleBar({ etaBuffer: 10240 }, cliProgress.Presets.shades_classic) : undefined;
384
+ const length = lengthText !== void 0 ? parseInt(lengthText, 10) : 0;
385
+ const bar = showProgress === true && !Number.isNaN(length) && length >= 10485760 ? new cliProgress.SingleBar({ etaBuffer: 10240 }, cliProgress.Presets.shades_classic) : void 0;
386
386
  bar?.start(length, 0);
387
387
  const chunks = [];
388
388
  res.on("data", (chunk) => {
@@ -418,7 +418,7 @@ const downloadFile = (prefixes, type, key, {
418
418
  };
419
419
  const getFileCache = async (file) => {
420
420
  const integrity = await cacheIntegrity.get(file);
421
- if (integrity !== undefined) {
421
+ if (integrity !== void 0) {
422
422
  try {
423
423
  const buffer = await fs.readFile(path.resolve(CACHE_ROOT, file));
424
424
  const hash = crypto.createHash("sha256").update(buffer).digest("hex");
@@ -428,7 +428,7 @@ const getFileCache = async (file) => {
428
428
  } catch {
429
429
  }
430
430
  }
431
- return undefined;
431
+ return void 0;
432
432
  };
433
433
  const getDataFile = async (prefixes, key, type, buildCKey, {
434
434
  name,
@@ -438,10 +438,10 @@ const getDataFile = async (prefixes, key, type, buildCKey, {
438
438
  showAttemptFail
439
439
  } = {}) => {
440
440
  const dir = type === "build" ? path.join(CACHE_DIRS[type], buildCKey) : CACHE_DIRS[type];
441
- const file = name !== undefined ? path.join(dir, name) : path.join(dir, key);
441
+ const file = name !== void 0 ? path.join(dir, name) : path.join(dir, key);
442
442
  const cacheBuffer = await getFileCache(file);
443
443
  if (cacheBuffer) {
444
- if (name === undefined && partialOffset !== undefined && partialLength !== undefined) {
444
+ if (name === void 0 && partialOffset !== void 0 && partialLength !== void 0) {
445
445
  return cacheBuffer.subarray(partialOffset, partialOffset + partialLength);
446
446
  }
447
447
  return cacheBuffer;
@@ -452,7 +452,7 @@ const getDataFile = async (prefixes, key, type, buildCKey, {
452
452
  showProgress,
453
453
  showAttemptFail
454
454
  });
455
- if (partialOffset === undefined && partialLength === undefined || name !== undefined) {
455
+ if (partialOffset === void 0 && partialLength === void 0 || name !== void 0) {
456
456
  await fs.mkdir(path.resolve(CACHE_ROOT, dir), { recursive: true });
457
457
  await fs.writeFile(path.resolve(CACHE_ROOT, file), downloadBuffer);
458
458
  const hash = crypto.createHash("sha256").update(downloadBuffer).digest("hex");
@@ -1408,7 +1408,7 @@ class WDCReader {
1408
1408
  return;
1409
1409
  }
1410
1410
  for (let recordIndex = 0; recordIndex < header.recordCount; recordIndex += 1) {
1411
- let recordID = idList.length > 0 ? idList[recordIndex] : undefined;
1411
+ let recordID = idList.length > 0 ? idList[recordIndex] : void 0;
1412
1412
  const recordBuffer = isNormal ? records[recordIndex] : offsetMap[recordIndex].data;
1413
1413
  if (isNormal) {
1414
1414
  const recordData = fieldsInfo.map((fieldInfo, fieldIndex) => {
@@ -1425,7 +1425,7 @@ class WDCReader {
1425
1425
  data: value
1426
1426
  };
1427
1427
  }
1428
- if (recordID === undefined && fieldIndex === idIndex) {
1428
+ if (recordID === void 0 && fieldIndex === idIndex) {
1429
1429
  recordID = value;
1430
1430
  }
1431
1431
  const fieldOffset = fieldInfo.fieldOffsetBits >>> 3;
@@ -1437,8 +1437,8 @@ class WDCReader {
1437
1437
  };
1438
1438
  }
1439
1439
  case "commonData": {
1440
- let value = recordID !== undefined ? commonData.get(fieldIndex)?.get(recordID) : undefined;
1441
- if (value === undefined) {
1440
+ let value = recordID !== void 0 ? commonData.get(fieldIndex)?.get(recordID) : void 0;
1441
+ if (value === void 0) {
1442
1442
  value = fieldInfo.defaultValue;
1443
1443
  }
1444
1444
  return {
@@ -1475,7 +1475,7 @@ class WDCReader {
1475
1475
  assert(fieldPalletData, `No pallet data for field ${fieldIndex.toString()}`);
1476
1476
  value = fieldPalletData[value];
1477
1477
  }
1478
- if (recordID === undefined && fieldIndex === idIndex) {
1478
+ if (recordID === void 0 && fieldIndex === idIndex) {
1479
1479
  recordID = value;
1480
1480
  }
1481
1481
  return {
@@ -1487,10 +1487,10 @@ class WDCReader {
1487
1487
  throw new Error("Unreachable");
1488
1488
  }
1489
1489
  });
1490
- assert(recordID !== undefined, "No record ID found");
1490
+ assert(recordID !== void 0, "No record ID found");
1491
1491
  this.rows.set(recordID, recordData);
1492
1492
  const foreignID = relationshipMap.get(recordIndex);
1493
- if (foreignID !== undefined) {
1493
+ if (foreignID !== void 0) {
1494
1494
  this.relationships.set(recordID, foreignID);
1495
1495
  }
1496
1496
  } else {
@@ -1498,10 +1498,10 @@ class WDCReader {
1498
1498
  type: "sparse",
1499
1499
  data: recordBuffer
1500
1500
  };
1501
- assert(recordID !== undefined, "No record ID found");
1501
+ assert(recordID !== void 0, "No record ID found");
1502
1502
  this.rows.set(recordID, recordData);
1503
1503
  const foreignID = relationshipMap.get(recordIndex);
1504
- if (foreignID !== undefined) {
1504
+ if (foreignID !== void 0) {
1505
1505
  this.relationships.set(recordID, foreignID);
1506
1506
  }
1507
1507
  }
@@ -1539,20 +1539,20 @@ class WDCReader {
1539
1539
  data: hotfix.data
1540
1540
  };
1541
1541
  case "delete":
1542
- return undefined;
1542
+ return void 0;
1543
1543
  default:
1544
1544
  throw new Error("Unreachable");
1545
1545
  }
1546
1546
  }
1547
1547
  const dst = this.copyTable.get(id);
1548
- if (dst !== undefined) {
1548
+ if (dst !== void 0) {
1549
1549
  return this.rows.get(dst);
1550
1550
  }
1551
1551
  return this.rows.get(id);
1552
1552
  }
1553
1553
  getRowRelationship(id) {
1554
1554
  const dst = this.copyTable.get(id);
1555
- if (dst !== undefined) {
1555
+ if (dst !== void 0) {
1556
1556
  return this.relationships.get(dst);
1557
1557
  }
1558
1558
  return this.relationships.get(id);
@@ -1637,7 +1637,7 @@ class CASCClient {
1637
1637
  const archiveKeys = cdnConfig.archives.split(" ");
1638
1638
  const archiveCount = archiveKeys.length;
1639
1639
  const archiveTotalSize = cdnConfig.archivesIndexSize.split(" ").reduce((a, b) => a + parseInt(b, 10), 0);
1640
- const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress.SingleBar({ etaBuffer: 100 }, cliProgress.Presets.shades_classic) : undefined;
1640
+ const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress.SingleBar({ etaBuffer: 100 }, cliProgress.Presets.shades_classic) : void 0;
1641
1641
  archiveBar?.start(archiveCount, 0);
1642
1642
  const archivesMapArray = await mapLimit(
1643
1643
  archiveKeys,
@@ -1685,7 +1685,7 @@ class CASCClient {
1685
1685
  }
1686
1686
  const cKey = configText;
1687
1687
  const eKeys = encoding.cKey2EKey.get(cKey);
1688
- assert(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1688
+ assert(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1689
1689
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1690
1690
  return [cKey, eKey];
1691
1691
  };
@@ -1813,7 +1813,7 @@ class CASCClient {
1813
1813
  assert(this.preload, "Client not initialized");
1814
1814
  const { prefixes, encoding, archives } = this.preload;
1815
1815
  const eKeys = encoding.cKey2EKey.get(cKey);
1816
- assert(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1816
+ assert(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1817
1817
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1818
1818
  const archive = archives.get(eKey);
1819
1819
  const blte = archive ? await getDataFile(prefixes, archive.key, "data", this.version.BuildConfig, {
@@ -1834,7 +1834,7 @@ class CASCClient {
1834
1834
  return {
1835
1835
  type: "full",
1836
1836
  buffer: reader.buffer,
1837
- blocks: undefined
1837
+ blocks: void 0
1838
1838
  };
1839
1839
  }
1840
1840
  const blocks = reader.processBytes(allowMissingKey);
@@ -1844,7 +1844,7 @@ class CASCClient {
1844
1844
  return {
1845
1845
  type: "full",
1846
1846
  buffer: reader.buffer,
1847
- blocks: undefined
1847
+ blocks: void 0
1848
1848
  };
1849
1849
  }
1850
1850
  return {
@@ -1908,7 +1908,7 @@ class DBDParser {
1908
1908
  const manifests = await (await fetch(manifestsURL)).json();
1909
1909
  const tableHashHex = this.wdc.tableHash.toString(16).padStart(8, "0").toLowerCase();
1910
1910
  const manifest = manifests.find((v) => v.tableHash.toLowerCase() === tableHashHex);
1911
- assert(manifest?.tableName !== undefined, `No manifest found for table hash ${tableHashHex}`);
1911
+ assert(manifest?.tableName !== void 0, `No manifest found for table hash ${tableHashHex}`);
1912
1912
  const url = `https://raw.githubusercontent.com/wowdev/WoWDBDefs/master/definitions/${manifest.tableName}.dbd`;
1913
1913
  const text = await (await fetch(url)).text();
1914
1914
  const lines = text.split("\n").map((v) => v.trim());
@@ -1935,7 +1935,7 @@ class DBDParser {
1935
1935
  const layoutsMatch = PATTERN_LAYOUT.exec(line);
1936
1936
  const layouts = layoutsMatch?.[1].split(",").map((v) => v.trim().toLowerCase());
1937
1937
  return layouts?.includes(layoutHashHex) === true;
1938
- }) !== undefined);
1938
+ }) !== void 0);
1939
1939
  assert(versionChunk, `No version definition found for layout hash ${layoutHashHex}`);
1940
1940
  versionChunk.forEach((line) => {
1941
1941
  if (line.startsWith("LAYOUT") || line.startsWith("BUILD") || line.startsWith("COMMENT")) {
@@ -1955,10 +1955,10 @@ class DBDParser {
1955
1955
  arraySizeText
1956
1956
  ] = match;
1957
1957
  const type = this.definitions.get(name);
1958
- assert(type !== undefined, `No type found for column ${name}`);
1958
+ assert(type !== void 0, `No type found for column ${name}`);
1959
1959
  const annotations = annotationsText ? annotationsText.split(",").map((v) => v.trim()) : [];
1960
- const size = sizeText ? parseInt(sizeText, 10) : undefined;
1961
- const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : undefined;
1960
+ const size = sizeText ? parseInt(sizeText, 10) : void 0;
1961
+ const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : void 0;
1962
1962
  const isID = !!annotations.includes("id");
1963
1963
  const isInline = !annotations.includes("noninline");
1964
1964
  const isRelation = !!annotations.includes("relation");
@@ -1990,7 +1990,7 @@ class DBDParser {
1990
1990
  }
1991
1991
  const row = this.wdc.getRowData(id);
1992
1992
  if (!row) {
1993
- return undefined;
1993
+ return void 0;
1994
1994
  }
1995
1995
  const data = {};
1996
1996
  if (Array.isArray(row)) {
@@ -2007,13 +2007,13 @@ class DBDParser {
2007
2007
  const fieldInfo = this.wdc.fieldsInfo[fieldIndex];
2008
2008
  const srcSigned = fieldInfo.storageType === "bitpackedSigned";
2009
2009
  const srcSize = fieldInfo.storageType === "none" || fieldInfo.storageType === "bitpacked" || fieldInfo.storageType === "bitpackedSigned" ? Math.ceil(fieldInfo.fieldSizeBits / 8) : 4;
2010
- const dstSize = column.size !== undefined ? Math.ceil(column.size / 8) : undefined;
2010
+ const dstSize = column.size !== void 0 ? Math.ceil(column.size / 8) : void 0;
2011
2011
  if (cell.type === "bitpackedArray") {
2012
2012
  data[column.name] = cell.data.map((v) => {
2013
2013
  if (column.type === "float") {
2014
2014
  return castFloat(v, srcSize, srcSigned);
2015
2015
  }
2016
- if (dstSize !== undefined) {
2016
+ if (dstSize !== void 0) {
2017
2017
  return castIntegerBySize(
2018
2018
  v,
2019
2019
  srcSize,
@@ -2031,7 +2031,7 @@ class DBDParser {
2031
2031
  data[column.name] = cell.string;
2032
2032
  }
2033
2033
  } else if (column.type === "float") {
2034
- if (column.arraySize !== undefined) {
2034
+ if (column.arraySize !== void 0) {
2035
2035
  const castBuffer = getCastBuffer(
2036
2036
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2037
2037
  srcSize,
@@ -2048,8 +2048,8 @@ class DBDParser {
2048
2048
  data[column.name] = castFloat(cell.data, srcSize, srcSigned);
2049
2049
  }
2050
2050
  } else if (column.type === "int") {
2051
- if (column.arraySize !== undefined) {
2052
- assert(dstSize !== undefined, `Missing size for int array column ${column.name}`);
2051
+ if (column.arraySize !== void 0) {
2052
+ assert(dstSize !== void 0, `Missing size for int array column ${column.name}`);
2053
2053
  const castBuffer = getCastBuffer(
2054
2054
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2055
2055
  srcSize,
@@ -2094,7 +2094,7 @@ class DBDParser {
2094
2094
  column.isSigned
2095
2095
  );
2096
2096
  } else {
2097
- assert(column.size === undefined || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2097
+ assert(column.size === void 0 || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2098
2098
  if (srcSigned !== column.isSigned) {
2099
2099
  data[column.name] = castBigInt64(
2100
2100
  cell.data,
@@ -2148,7 +2148,7 @@ class DBDParser {
2148
2148
  if (fieldIndex + 1 < this.wdc.fields.length) {
2149
2149
  count = Math.max((nextField.position - currField.position) / size, 1);
2150
2150
  } else {
2151
- count = column.arraySize !== undefined ? (buffer.byteLength - offset) / size : 1;
2151
+ count = column.arraySize !== void 0 ? (buffer.byteLength - offset) / size : 1;
2152
2152
  }
2153
2153
  for (let i = 0; i < count; i += 1) {
2154
2154
  if (column.type === "float") {