@rhyster/wow-casc-dbc 2.9.3 → 2.9.5

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 : void 0;
313
+ return allowMissingKey ? missingKeyBlocks : undefined;
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 !== void 0 && partialLength !== void 0 ? `bytes=${partialOffset.toString()}-${(partialOffset + partialLength - 1).toString()}` : "bytes=0-"
365
+ Range: partialOffset !== undefined && partialLength !== undefined ? `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 !== void 0) {
370
+ if (res.headers.location !== undefined) {
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 === void 0 || res.statusCode < 200 || res.statusCode > 302) {
379
+ if (res.statusCode === undefined || 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 !== 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;
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;
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 !== void 0) {
421
+ if (integrity !== undefined) {
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 void 0;
431
+ return undefined;
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 !== void 0 ? path.join(dir, name) : path.join(dir, key);
441
+ const file = name !== undefined ? path.join(dir, name) : path.join(dir, key);
442
442
  const cacheBuffer = await getFileCache(file);
443
443
  if (cacheBuffer) {
444
- if (name === void 0 && partialOffset !== void 0 && partialLength !== void 0) {
444
+ if (name === undefined && partialOffset !== undefined && partialLength !== undefined) {
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 === void 0 && partialLength === void 0 || name !== void 0) {
455
+ if (partialOffset === undefined && partialLength === undefined || name !== undefined) {
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");
@@ -1407,7 +1407,7 @@ class WDCReader {
1407
1407
  return;
1408
1408
  }
1409
1409
  for (let recordIndex = 0; recordIndex < header.recordCount; recordIndex += 1) {
1410
- let recordID = idList.length > 0 ? idList[recordIndex] : void 0;
1410
+ let recordID = idList.length > 0 ? idList[recordIndex] : undefined;
1411
1411
  const recordBuffer = isNormal ? records[recordIndex] : offsetMap[recordIndex].data;
1412
1412
  if (isNormal) {
1413
1413
  const recordData = fieldsInfo.map((fieldInfo, fieldIndex) => {
@@ -1424,7 +1424,7 @@ class WDCReader {
1424
1424
  data: value
1425
1425
  };
1426
1426
  }
1427
- if (recordID === void 0 && fieldIndex === idIndex) {
1427
+ if (recordID === undefined && fieldIndex === idIndex) {
1428
1428
  recordID = value;
1429
1429
  }
1430
1430
  const fieldOffset = fieldInfo.fieldOffsetBits >>> 3;
@@ -1436,7 +1436,7 @@ class WDCReader {
1436
1436
  };
1437
1437
  }
1438
1438
  case "commonData": {
1439
- const value = (recordID !== void 0 ? commonData.get(fieldIndex)?.get(recordID) : void 0) ?? fieldInfo.defaultValue;
1439
+ const value = (recordID !== undefined ? commonData.get(fieldIndex)?.get(recordID) : undefined) ?? fieldInfo.defaultValue;
1440
1440
  return {
1441
1441
  type: "commonData",
1442
1442
  data: value
@@ -1471,7 +1471,7 @@ class WDCReader {
1471
1471
  assert(fieldPalletData, `No pallet data for field ${fieldIndex.toString()}`);
1472
1472
  value = fieldPalletData[value];
1473
1473
  }
1474
- if (recordID === void 0 && fieldIndex === idIndex) {
1474
+ if (recordID === undefined && fieldIndex === idIndex) {
1475
1475
  recordID = value;
1476
1476
  }
1477
1477
  return {
@@ -1483,10 +1483,10 @@ class WDCReader {
1483
1483
  throw new Error("Unreachable");
1484
1484
  }
1485
1485
  });
1486
- assert(recordID !== void 0, "No record ID found");
1486
+ assert(recordID !== undefined, "No record ID found");
1487
1487
  this.rows.set(recordID, recordData);
1488
1488
  const foreignID = relationshipMap.get(recordIndex);
1489
- if (foreignID !== void 0) {
1489
+ if (foreignID !== undefined) {
1490
1490
  this.relationships.set(recordID, foreignID);
1491
1491
  }
1492
1492
  } else {
@@ -1494,10 +1494,10 @@ class WDCReader {
1494
1494
  type: "sparse",
1495
1495
  data: recordBuffer
1496
1496
  };
1497
- assert(recordID !== void 0, "No record ID found");
1497
+ assert(recordID !== undefined, "No record ID found");
1498
1498
  this.rows.set(recordID, recordData);
1499
1499
  const foreignID = relationshipMap.get(recordIndex);
1500
- if (foreignID !== void 0) {
1500
+ if (foreignID !== undefined) {
1501
1501
  this.relationships.set(recordID, foreignID);
1502
1502
  }
1503
1503
  }
@@ -1535,20 +1535,20 @@ class WDCReader {
1535
1535
  data: hotfix.data
1536
1536
  };
1537
1537
  case "delete":
1538
- return void 0;
1538
+ return undefined;
1539
1539
  default:
1540
1540
  throw new Error("Unreachable");
1541
1541
  }
1542
1542
  }
1543
1543
  const dst = this.copyTable.get(id);
1544
- if (dst !== void 0) {
1544
+ if (dst !== undefined) {
1545
1545
  return this.rows.get(dst);
1546
1546
  }
1547
1547
  return this.rows.get(id);
1548
1548
  }
1549
1549
  getRowRelationship(id) {
1550
1550
  const dst = this.copyTable.get(id);
1551
- if (dst !== void 0) {
1551
+ if (dst !== undefined) {
1552
1552
  return this.relationships.get(dst);
1553
1553
  }
1554
1554
  return this.relationships.get(id);
@@ -1633,7 +1633,7 @@ class CASCClient {
1633
1633
  const archiveKeys = cdnConfig.archives.split(" ");
1634
1634
  const archiveCount = archiveKeys.length;
1635
1635
  const archiveTotalSize = cdnConfig.archivesIndexSize.split(" ").reduce((a, b) => a + parseInt(b, 10), 0);
1636
- const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress.SingleBar({ etaBuffer: 100 }, cliProgress.Presets.shades_classic) : void 0;
1636
+ const archiveBar = this.logLevel >= 2 /* info */ ? new cliProgress.SingleBar({ etaBuffer: 100 }, cliProgress.Presets.shades_classic) : undefined;
1637
1637
  archiveBar?.start(archiveCount, 0);
1638
1638
  const archivesMapArray = await mapLimit(
1639
1639
  archiveKeys,
@@ -1681,7 +1681,7 @@ class CASCClient {
1681
1681
  }
1682
1682
  const cKey = configText;
1683
1683
  const eKeys = encoding.cKey2EKey.get(cKey);
1684
- assert(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1684
+ assert(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1685
1685
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1686
1686
  return [cKey, eKey];
1687
1687
  };
@@ -1809,7 +1809,7 @@ class CASCClient {
1809
1809
  assert(this.preload, "Client not initialized");
1810
1810
  const { prefixes, encoding, archives } = this.preload;
1811
1811
  const eKeys = encoding.cKey2EKey.get(cKey);
1812
- assert(eKeys !== void 0, `Failing to find encoding key for ${cKey}`);
1812
+ assert(eKeys !== undefined, `Failing to find encoding key for ${cKey}`);
1813
1813
  const eKey = typeof eKeys === "string" ? eKeys : eKeys[0];
1814
1814
  const archive = archives.get(eKey);
1815
1815
  const blte = archive ? await getDataFile(prefixes, archive.key, "data", this.version.BuildConfig, {
@@ -1830,7 +1830,7 @@ class CASCClient {
1830
1830
  return {
1831
1831
  type: "full",
1832
1832
  buffer: reader.buffer,
1833
- blocks: void 0
1833
+ blocks: undefined
1834
1834
  };
1835
1835
  }
1836
1836
  const blocks = reader.processBytes(allowMissingKey);
@@ -1840,7 +1840,7 @@ class CASCClient {
1840
1840
  return {
1841
1841
  type: "full",
1842
1842
  buffer: reader.buffer,
1843
- blocks: void 0
1843
+ blocks: undefined
1844
1844
  };
1845
1845
  }
1846
1846
  return {
@@ -1904,7 +1904,7 @@ class DBDParser {
1904
1904
  const manifests = await (await fetch(manifestsURL)).json();
1905
1905
  const tableHashHex = this.wdc.tableHash.toString(16).padStart(8, "0").toLowerCase();
1906
1906
  const manifest = manifests.find((v) => v.tableHash.toLowerCase() === tableHashHex);
1907
- assert(manifest?.tableName !== void 0, `No manifest found for table hash ${tableHashHex}`);
1907
+ assert(manifest?.tableName !== undefined, `No manifest found for table hash ${tableHashHex}`);
1908
1908
  const url = `https://raw.githubusercontent.com/wowdev/WoWDBDefs/master/definitions/${manifest.tableName}.dbd`;
1909
1909
  const text = await (await fetch(url)).text();
1910
1910
  const lines = text.split("\n").map((v) => v.trim());
@@ -1931,7 +1931,7 @@ class DBDParser {
1931
1931
  const layoutsMatch = PATTERN_LAYOUT.exec(line);
1932
1932
  const layouts = layoutsMatch?.[1].split(",").map((v) => v.trim().toLowerCase());
1933
1933
  return layouts?.includes(layoutHashHex) === true;
1934
- }) !== void 0);
1934
+ }) !== undefined);
1935
1935
  assert(versionChunk, `No version definition found for layout hash ${layoutHashHex}`);
1936
1936
  versionChunk.forEach((line) => {
1937
1937
  if (line.startsWith("LAYOUT") || line.startsWith("BUILD") || line.startsWith("COMMENT")) {
@@ -1951,10 +1951,10 @@ class DBDParser {
1951
1951
  arraySizeText
1952
1952
  ] = match;
1953
1953
  const type = this.definitions.get(name);
1954
- assert(type !== void 0, `No type found for column ${name}`);
1954
+ assert(type !== undefined, `No type found for column ${name}`);
1955
1955
  const annotations = annotationsText ? annotationsText.split(",").map((v) => v.trim()) : [];
1956
- const size = sizeText ? parseInt(sizeText, 10) : void 0;
1957
- const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : void 0;
1956
+ const size = sizeText ? parseInt(sizeText, 10) : undefined;
1957
+ const arraySize = arraySizeText ? parseInt(arraySizeText, 10) : undefined;
1958
1958
  const isID = !!annotations.includes("id");
1959
1959
  const isInline = !annotations.includes("noninline");
1960
1960
  const isRelation = !!annotations.includes("relation");
@@ -1986,7 +1986,7 @@ class DBDParser {
1986
1986
  }
1987
1987
  const row = this.wdc.getRowData(id);
1988
1988
  if (!row) {
1989
- return void 0;
1989
+ return undefined;
1990
1990
  }
1991
1991
  const data = {};
1992
1992
  if (Array.isArray(row)) {
@@ -2003,13 +2003,13 @@ class DBDParser {
2003
2003
  const fieldInfo = this.wdc.fieldsInfo[fieldIndex];
2004
2004
  const srcSigned = fieldInfo.storageType === "bitpackedSigned";
2005
2005
  const srcSize = fieldInfo.storageType === "none" || fieldInfo.storageType === "bitpacked" || fieldInfo.storageType === "bitpackedSigned" ? Math.ceil(fieldInfo.fieldSizeBits / 8) : 4;
2006
- const dstSize = column.size !== void 0 ? Math.ceil(column.size / 8) : void 0;
2006
+ const dstSize = column.size !== undefined ? Math.ceil(column.size / 8) : undefined;
2007
2007
  if (cell.type === "bitpackedArray") {
2008
2008
  data[column.name] = cell.data.map((v) => {
2009
2009
  if (column.type === "float") {
2010
2010
  return castFloat(v, srcSize, srcSigned);
2011
2011
  }
2012
- if (dstSize !== void 0) {
2012
+ if (dstSize !== undefined) {
2013
2013
  return castIntegerBySize(
2014
2014
  v,
2015
2015
  srcSize,
@@ -2027,7 +2027,7 @@ class DBDParser {
2027
2027
  data[column.name] = cell.string;
2028
2028
  }
2029
2029
  } else if (column.type === "float") {
2030
- if (column.arraySize !== void 0) {
2030
+ if (column.arraySize !== undefined) {
2031
2031
  const castBuffer = getCastBuffer(
2032
2032
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2033
2033
  srcSize,
@@ -2044,8 +2044,8 @@ class DBDParser {
2044
2044
  data[column.name] = castFloat(cell.data, srcSize, srcSigned);
2045
2045
  }
2046
2046
  } else if (column.type === "int") {
2047
- if (column.arraySize !== void 0) {
2048
- assert(dstSize !== void 0, `Missing size for int array column ${column.name}`);
2047
+ if (column.arraySize !== undefined) {
2048
+ assert(dstSize !== undefined, `Missing size for int array column ${column.name}`);
2049
2049
  const castBuffer = getCastBuffer(
2050
2050
  typeof cell.data === "number" ? BigInt(cell.data) : cell.data,
2051
2051
  srcSize,
@@ -2073,7 +2073,7 @@ class DBDParser {
2073
2073
  column.isSigned
2074
2074
  );
2075
2075
  } else {
2076
- assert(column.size === void 0 || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2076
+ assert(column.size === undefined || column.size === 64, `Unexpected size ${column.size?.toString() ?? ""} for column ${column.name}`);
2077
2077
  if (srcSigned !== column.isSigned) {
2078
2078
  data[column.name] = castBigInt64(
2079
2079
  cell.data,
@@ -2127,7 +2127,7 @@ class DBDParser {
2127
2127
  if (fieldIndex + 1 < this.wdc.fields.length) {
2128
2128
  count = Math.max((nextField.position - currField.position) / size, 1);
2129
2129
  } else {
2130
- count = column.arraySize !== void 0 ? (buffer.byteLength - offset) / size : 1;
2130
+ count = column.arraySize !== undefined ? (buffer.byteLength - offset) / size : 1;
2131
2131
  }
2132
2132
  for (let i = 0; i < count; i += 1) {
2133
2133
  if (column.type === "float") {