@gaialabs/core 0.2.3 → 0.2.4
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 +56 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +56 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1790,12 +1790,14 @@ var DbStringCommand = class {
|
|
|
1790
1790
|
types;
|
|
1791
1791
|
delimiter;
|
|
1792
1792
|
halt;
|
|
1793
|
+
dictionary;
|
|
1793
1794
|
constructor(data) {
|
|
1794
1795
|
this.id = data.id ?? void 0;
|
|
1795
1796
|
this.name = data.name ?? "";
|
|
1796
1797
|
this.types = data.types ?? [];
|
|
1797
1798
|
this.delimiter = data.delimiter ?? void 0;
|
|
1798
1799
|
this.halt = data.halt ?? false;
|
|
1800
|
+
this.dictionary = data.dictionary ?? void 0;
|
|
1799
1801
|
if (!this.id && this.id !== 0) throw new Error("Id is required");
|
|
1800
1802
|
if (!this.name) throw new Error("Name is required");
|
|
1801
1803
|
}
|
|
@@ -1826,8 +1828,6 @@ var DbStringType = class {
|
|
|
1826
1828
|
name;
|
|
1827
1829
|
delimiter;
|
|
1828
1830
|
terminator;
|
|
1829
|
-
shiftType;
|
|
1830
|
-
characterMap;
|
|
1831
1831
|
commands;
|
|
1832
1832
|
commandLookup;
|
|
1833
1833
|
layers;
|
|
@@ -1838,8 +1838,6 @@ var DbStringType = class {
|
|
|
1838
1838
|
this.name = data.name ?? "";
|
|
1839
1839
|
this.delimiter = data.delimiter ?? "";
|
|
1840
1840
|
this.terminator = data.terminator ?? 0;
|
|
1841
|
-
this.shiftType = data.shiftType ?? void 0;
|
|
1842
|
-
this.characterMap = data.characterMap;
|
|
1843
1841
|
this.commands = data.commands ?? {};
|
|
1844
1842
|
this.layers = data.layers ?? [];
|
|
1845
1843
|
this.greedyTerminator = data.greedyTerminator ?? false;
|
|
@@ -1855,7 +1853,7 @@ var DbStringType = class {
|
|
|
1855
1853
|
if (!this.name) throw new Error("Name is required");
|
|
1856
1854
|
if (!this.delimiter) throw new Error("Delimiter is required");
|
|
1857
1855
|
if (!this.terminator && this.terminator !== 0) throw new Error("Terminator is required");
|
|
1858
|
-
if (!this.
|
|
1856
|
+
if (!this.layers.length) throw new Error("Layers are required");
|
|
1859
1857
|
}
|
|
1860
1858
|
};
|
|
1861
1859
|
/**
|
|
@@ -3350,14 +3348,17 @@ var TypeParser = class {
|
|
|
3350
3348
|
name: targetType.name,
|
|
3351
3349
|
parts
|
|
3352
3350
|
};
|
|
3353
|
-
for (let i = 0; i < memberCount; i++) parts[i] = this.parseType(types[i],
|
|
3351
|
+
for (let i = 0; i < memberCount; i++) parts[i] = this.parseType(types[i], reg, depth + 1, bank);
|
|
3354
3352
|
if (discOffset !== void 0 && discOffset === this._romDataReader.position - prevPosition) this._romDataReader.position++;
|
|
3355
3353
|
objects.push(def);
|
|
3356
3354
|
}
|
|
3357
3355
|
let checkPosition = startPosition;
|
|
3358
|
-
while (++checkPosition < this._romDataReader.position)
|
|
3359
|
-
this.
|
|
3360
|
-
|
|
3356
|
+
while (++checkPosition < this._romDataReader.position) {
|
|
3357
|
+
const struct = this._referenceManager.tryGetStruct(checkPosition);
|
|
3358
|
+
if (struct.found && struct.chunkType !== "Code") {
|
|
3359
|
+
this._romDataReader.position = checkPosition;
|
|
3360
|
+
break;
|
|
3361
|
+
}
|
|
3361
3362
|
}
|
|
3362
3363
|
if (!this._blockReader.partCanContinue()) break;
|
|
3363
3364
|
}
|
|
@@ -4437,10 +4438,16 @@ var DbRootUtils = class {
|
|
|
4437
4438
|
return acc$1;
|
|
4438
4439
|
}, {});
|
|
4439
4440
|
const dictionaries = Object.entries(stringType.dictionaries ?? {}).reduce((acc$1, y) => {
|
|
4440
|
-
|
|
4441
|
+
const dictionary = new DbStringDictionary({
|
|
4441
4442
|
...y[1],
|
|
4442
4443
|
name: y[0]
|
|
4443
4444
|
});
|
|
4445
|
+
acc$1[y[0]] = dictionary;
|
|
4446
|
+
if (dictionary.command !== void 0) commands[dictionary.command] = new DbStringCommand({
|
|
4447
|
+
id: dictionary.command,
|
|
4448
|
+
name: dictionary.name,
|
|
4449
|
+
dictionary
|
|
4450
|
+
});
|
|
4444
4451
|
return acc$1;
|
|
4445
4452
|
}, {});
|
|
4446
4453
|
const st = new DbStringType({
|
|
@@ -4621,7 +4628,8 @@ var StringReader = class StringReader {
|
|
|
4621
4628
|
this._romDataReader = blockReader._romDataReader;
|
|
4622
4629
|
}
|
|
4623
4630
|
resolveCommand(cmd, builder) {
|
|
4624
|
-
if (cmd.
|
|
4631
|
+
if (cmd.dictionary) builder.push(cmd.dictionary.entries[this._romDataReader.readByte() - (cmd.dictionary.base ?? 0)]);
|
|
4632
|
+
else if (cmd.types && cmd.types.length > 0) {
|
|
4625
4633
|
builder.push(`[${cmd.name}`);
|
|
4626
4634
|
let first = true;
|
|
4627
4635
|
for (const t of cmd.types) {
|
|
@@ -4664,8 +4672,8 @@ var StringReader = class StringReader {
|
|
|
4664
4672
|
const dictionaries = stringType.dictionaries;
|
|
4665
4673
|
const builder = [];
|
|
4666
4674
|
const strLoc = this._romDataReader.position;
|
|
4667
|
-
const map = stringType.characterMap;
|
|
4668
4675
|
const terminator = stringType.terminator;
|
|
4676
|
+
let currentLayer = stringType.layers[0];
|
|
4669
4677
|
do {
|
|
4670
4678
|
const c = this._romDataReader.readByte();
|
|
4671
4679
|
if (c === terminator) {
|
|
@@ -4684,8 +4692,25 @@ var StringReader = class StringReader {
|
|
|
4684
4692
|
break;
|
|
4685
4693
|
}
|
|
4686
4694
|
if (!found) {
|
|
4687
|
-
const
|
|
4688
|
-
|
|
4695
|
+
for (const layer of stringType.layers) if (layer.on !== void 0) {
|
|
4696
|
+
if (c === layer.on) {
|
|
4697
|
+
currentLayer = layer;
|
|
4698
|
+
found = true;
|
|
4699
|
+
break;
|
|
4700
|
+
}
|
|
4701
|
+
} else if (c >= (layer.base ?? 0) && c <= (layer.range ?? 255)) {
|
|
4702
|
+
let index = c - (layer.base ?? 0);
|
|
4703
|
+
if (index >= 0 && index < layer.map.length) {
|
|
4704
|
+
if (layer.shift) index = DbStringTypeUtils.getShiftDown(layer.shift)(index);
|
|
4705
|
+
builder.push(layer.map[index]);
|
|
4706
|
+
found = true;
|
|
4707
|
+
break;
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
if (!found) {
|
|
4712
|
+
const index = currentLayer.shift ? DbStringTypeUtils.getShiftDown(currentLayer.shift)(c) : c - (currentLayer.base ?? 0);
|
|
4713
|
+
if (index >= 0 && index < currentLayer.map.length) builder.push(currentLayer.map[index]);
|
|
4689
4714
|
else builder.push(`[${c.toString(16).toUpperCase()}]`);
|
|
4690
4715
|
}
|
|
4691
4716
|
}
|
|
@@ -4748,6 +4773,7 @@ var StringProcessor = class {
|
|
|
4748
4773
|
root;
|
|
4749
4774
|
stringCharLookup;
|
|
4750
4775
|
testRegex;
|
|
4776
|
+
inShift = false;
|
|
4751
4777
|
constructor(context) {
|
|
4752
4778
|
this.context = context;
|
|
4753
4779
|
this.root = context.root;
|
|
@@ -4799,6 +4825,7 @@ var StringProcessor = class {
|
|
|
4799
4825
|
const stringType = this.stringCharLookup[typeChar];
|
|
4800
4826
|
const dictionary = stringType.dictionaryLookup;
|
|
4801
4827
|
const cmdLookup = stringType.commands;
|
|
4828
|
+
let currentLayer = stringType.layers[0];
|
|
4802
4829
|
let lastCmd = null;
|
|
4803
4830
|
for (const entry of dictionary) {
|
|
4804
4831
|
let index;
|
|
@@ -4834,7 +4861,21 @@ var StringProcessor = class {
|
|
|
4834
4861
|
}
|
|
4835
4862
|
}
|
|
4836
4863
|
lastCmd = null;
|
|
4837
|
-
|
|
4864
|
+
let found = false;
|
|
4865
|
+
for (const layer of stringType.layers) {
|
|
4866
|
+
for (let i = 0, len = layer.map.length; i < len; i++) if (c === layer.map[i]) {
|
|
4867
|
+
if (layer.on !== void 0 && currentLayer !== layer) {
|
|
4868
|
+
this.memBuffer.push(layer.on);
|
|
4869
|
+
currentLayer = layer;
|
|
4870
|
+
}
|
|
4871
|
+
let value = i + (layer.base ?? 0);
|
|
4872
|
+
if (layer.shift) value = DbStringTypeUtils.getShiftUp(layer.shift)(value);
|
|
4873
|
+
this.memBuffer.push(value);
|
|
4874
|
+
found = true;
|
|
4875
|
+
break;
|
|
4876
|
+
}
|
|
4877
|
+
if (found) break;
|
|
4878
|
+
}
|
|
4838
4879
|
}
|
|
4839
4880
|
if (this.fixedStr) {
|
|
4840
4881
|
let count = this.fixedStr - this.totalSize;
|
|
@@ -4842,23 +4883,6 @@ var StringProcessor = class {
|
|
|
4842
4883
|
} else if (lastCmd === null || !lastCmd.halt) this.memBuffer.push(stringType.terminator);
|
|
4843
4884
|
this.flushBuffer(stringType, true);
|
|
4844
4885
|
}
|
|
4845
|
-
applyLayers(c, stringType) {
|
|
4846
|
-
if (this.applyMap(c, stringType.characterMap, DbStringTypeUtils.getShiftUp(stringType.shiftType))) return true;
|
|
4847
|
-
if (stringType.layers) {
|
|
4848
|
-
for (const layer of stringType.layers) if (this.applyMap(c, layer.map, (x) => x + layer.base)) return true;
|
|
4849
|
-
}
|
|
4850
|
-
return false;
|
|
4851
|
-
}
|
|
4852
|
-
applyMap(c, map, shift) {
|
|
4853
|
-
for (let i = 0, len = map.length; i < len; i++) {
|
|
4854
|
-
const v = map[i];
|
|
4855
|
-
if (v != null && c === v[0]) {
|
|
4856
|
-
this.memBuffer.push(shift(i));
|
|
4857
|
-
return true;
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
|
-
return false;
|
|
4861
|
-
}
|
|
4862
4886
|
processStringCommand(cmd, stringType, parts) {
|
|
4863
4887
|
const hasPointer = cmd.types.includes(MemberType.Address) || cmd.types.includes(MemberType.Offset);
|
|
4864
4888
|
if (hasPointer) this.flushBuffer(stringType, true);
|