@gaialabs/core 0.2.8 → 0.2.10
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.cjs +33 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +33 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2678,7 +2678,7 @@ var DbStringType = class {
|
|
|
2678
2678
|
}, {});
|
|
2679
2679
|
this.dictionaryLookup = Object.values(this.dictionaries).flatMap((y) => y.entries.map((z, ix) => ({
|
|
2680
2680
|
text: z,
|
|
2681
|
-
id: (y.command ?? 0) | (y.base ?? 0 + ix)
|
|
2681
|
+
id: (y.command ?? 0) << 8 | (y.base ?? 0 + ix)
|
|
2682
2682
|
}))).sort((a, b) => b.text.length - a.text.length);
|
|
2683
2683
|
}
|
|
2684
2684
|
};
|
|
@@ -3354,6 +3354,7 @@ var QuintetLZ = class QuintetLZ {
|
|
|
3354
3354
|
let srcIx = srcPosition ?? 0;
|
|
3355
3355
|
let dstIx = 0;
|
|
3356
3356
|
if (!srcLen) srcLen = srcData.length - srcIx;
|
|
3357
|
+
let endIx = srcIx + srcLen;
|
|
3357
3358
|
const outputBuffer = new Uint8Array(srcLen * 2);
|
|
3358
3359
|
outputBuffer[dstIx++] = srcLen & 255;
|
|
3359
3360
|
outputBuffer[dstIx++] = srcLen >> 8 & 255;
|
|
@@ -3363,28 +3364,38 @@ var QuintetLZ = class QuintetLZ {
|
|
|
3363
3364
|
* @returns Tuple of [startByte, length]
|
|
3364
3365
|
*/
|
|
3365
3366
|
const getCommand = () => {
|
|
3366
|
-
const maxLen = Math.min(
|
|
3367
|
+
const maxLen = Math.min(endIx - srcIx, 17);
|
|
3367
3368
|
if (maxLen < 2) return [0, 0];
|
|
3368
3369
|
let startByte = 0;
|
|
3369
3370
|
let bestLen = 0;
|
|
3370
|
-
let
|
|
3371
|
-
for (let i = 0; i < 256; i++,
|
|
3371
|
+
let baseIndex = offset;
|
|
3372
|
+
for (let i = 0; i < 256; i++, baseIndex = baseIndex + 1 & 255) {
|
|
3372
3373
|
let size = 0;
|
|
3373
|
-
let
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3374
|
+
let currentIndex = baseIndex;
|
|
3375
|
+
let sourceIndex = srcIx;
|
|
3376
|
+
let isEnd = false;
|
|
3377
|
+
while (size < maxLen) {
|
|
3378
|
+
if (isEnd) {
|
|
3379
|
+
if (srcData[sourceIndex++] !== srcData[srcIx + size]) break;
|
|
3380
|
+
} else if (dictionary[currentIndex] !== srcData[sourceIndex++]) break;
|
|
3381
|
+
else {
|
|
3382
|
+
currentIndex = currentIndex + 1 & 255;
|
|
3383
|
+
if (currentIndex === offset) {
|
|
3384
|
+
sourceIndex = srcIx;
|
|
3385
|
+
isEnd = true;
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3377
3388
|
size++;
|
|
3378
3389
|
}
|
|
3379
3390
|
if (size > bestLen) {
|
|
3380
|
-
startByte =
|
|
3391
|
+
startByte = baseIndex;
|
|
3381
3392
|
bestLen = size;
|
|
3382
3393
|
if (bestLen >= maxLen) break;
|
|
3383
3394
|
}
|
|
3384
3395
|
}
|
|
3385
3396
|
return [startByte, bestLen];
|
|
3386
3397
|
};
|
|
3387
|
-
while (srcIx <
|
|
3398
|
+
while (srcIx < endIx) {
|
|
3388
3399
|
const [cmdStart, cmdLen] = getCommand();
|
|
3389
3400
|
if (cmdLen >= 2) {
|
|
3390
3401
|
bitStream.writeBit(false);
|
|
@@ -4575,8 +4586,9 @@ var RomLayout = class RomLayout {
|
|
|
4575
4586
|
this.sfxFiles.unshift(newFile);
|
|
4576
4587
|
file.rawData = file.rawData.slice(0, end);
|
|
4577
4588
|
file.size -= offset;
|
|
4589
|
+
offset = 0;
|
|
4578
4590
|
}
|
|
4579
|
-
remain =
|
|
4591
|
+
remain = RomProcessingConstants.PAGE_SIZE;
|
|
4580
4592
|
break;
|
|
4581
4593
|
} else remain -= file.size;
|
|
4582
4594
|
}
|
|
@@ -5267,7 +5279,7 @@ var DbRootUtils = class {
|
|
|
5267
5279
|
name
|
|
5268
5280
|
});
|
|
5269
5281
|
extLookup[type.extension] = type;
|
|
5270
|
-
fileTypeLookup[type.
|
|
5282
|
+
fileTypeLookup[type.name] = type;
|
|
5271
5283
|
acc[name] = type;
|
|
5272
5284
|
return acc;
|
|
5273
5285
|
}, {});
|
|
@@ -5625,9 +5637,17 @@ var StringProcessor = class {
|
|
|
5625
5637
|
const cmdLookup = stringType.commands;
|
|
5626
5638
|
let currentLayer = stringType.layers[0];
|
|
5627
5639
|
let lastCmd = null;
|
|
5640
|
+
let fullMatch = false;
|
|
5628
5641
|
for (const entry of dictionary) {
|
|
5629
5642
|
let index;
|
|
5630
|
-
while ((index = str.indexOf(entry.text)) >= 0)
|
|
5643
|
+
while ((index = str.indexOf(entry.text)) >= 0) {
|
|
5644
|
+
if (index === 0 && str.length === entry.text.length) {
|
|
5645
|
+
fullMatch = true;
|
|
5646
|
+
break;
|
|
5647
|
+
}
|
|
5648
|
+
str = str.substring(0, index) + `[${entry.id.toString(16).toUpperCase()}]` + str.substring(index + entry.text.length);
|
|
5649
|
+
}
|
|
5650
|
+
if (fullMatch) break;
|
|
5631
5651
|
}
|
|
5632
5652
|
for (let x = 0; x < str.length; x++) {
|
|
5633
5653
|
const c = str[x];
|