s2cfgtojson 3.2.3 → 3.2.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/Struct.mts +15 -10
- package/Struct.test.mts +2 -3
- package/package.json +1 -1
package/Struct.mts
CHANGED
|
@@ -21,7 +21,7 @@ const INTERNAL_PROPS = new Set([
|
|
|
21
21
|
"filter",
|
|
22
22
|
"map",
|
|
23
23
|
"toString",
|
|
24
|
-
]);
|
|
24
|
+
] satisfies Array<keyof Struct>);
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* This file is part of the Stalker 2 Modding Tools project.
|
|
@@ -94,11 +94,13 @@ export class Struct {
|
|
|
94
94
|
return Struct.fromString(this.toString())[0] as this;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
entries
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
entries<
|
|
98
|
+
K extends Exclude<keyof this, Internal>,
|
|
99
|
+
V extends (typeof this)[K],
|
|
100
|
+
>() {
|
|
101
|
+
return Object.entries(this).filter(
|
|
102
|
+
([key]) => !INTERNAL_PROPS.has(key as any),
|
|
103
|
+
) as [K, V][];
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
forEach<K extends Exclude<keyof this, Internal>, V extends (typeof this)[K]>(
|
|
@@ -156,8 +158,7 @@ export class Struct {
|
|
|
156
158
|
|
|
157
159
|
text += "\n";
|
|
158
160
|
// Add all keys
|
|
159
|
-
text +=
|
|
160
|
-
.filter(([key]) => !INTERNAL_PROPS.has(key))
|
|
161
|
+
text += this.entries()
|
|
161
162
|
.map(([key, value]) => {
|
|
162
163
|
const nameAlreadyRendered =
|
|
163
164
|
value instanceof Struct && value.__internal__.rawName;
|
|
@@ -167,7 +168,7 @@ export class Struct {
|
|
|
167
168
|
let equalsOrColon = "";
|
|
168
169
|
let spaceOrNoSpace = "";
|
|
169
170
|
if (!nameAlreadyRendered) {
|
|
170
|
-
keyOrIndex = renderKeyName(key, useAsterisk) + " ";
|
|
171
|
+
keyOrIndex = renderKeyName(key as string, useAsterisk) + " ";
|
|
171
172
|
equalsOrColon = value instanceof Struct ? ":" : "=";
|
|
172
173
|
spaceOrNoSpace = value === "" ? "" : " ";
|
|
173
174
|
}
|
|
@@ -238,7 +239,11 @@ function parseHead(line: string, index: number): Struct {
|
|
|
238
239
|
|
|
239
240
|
const dummy = createDynamicClassInstance(match[1].trim(), index);
|
|
240
241
|
if (match[3]) {
|
|
241
|
-
|
|
242
|
+
const parsed = new Refs(match[3]);
|
|
243
|
+
dummy.__internal__.refurl = parsed.refurl;
|
|
244
|
+
dummy.__internal__.refkey = parsed.refkey;
|
|
245
|
+
dummy.__internal__.bskipref = parsed.bskipref;
|
|
246
|
+
dummy.__internal__.bpatch = parsed.bpatch;
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
return dummy as Struct;
|
package/Struct.test.mts
CHANGED
|
@@ -79,6 +79,7 @@ struct.end`,
|
|
|
79
79
|
test("1", () => {
|
|
80
80
|
const instance = createDynamicClassInstance("DynamicClass");
|
|
81
81
|
expect(instance).toBeInstanceOf(Struct);
|
|
82
|
+
expect(instance.__internal__.rawName).toBe("DynamicClass");
|
|
82
83
|
expect(instance.toString()).toBe(
|
|
83
84
|
`DynamicClass : struct.begin\n\nstruct.end`,
|
|
84
85
|
);
|
|
@@ -318,6 +319,4 @@ struct.end`;
|
|
|
318
319
|
// noinspection JSUnusedLocalSymbols
|
|
319
320
|
const MyRank: ERank = "ERank::Experienced, ERank::Veteran, ERank::Master";
|
|
320
321
|
// noinspection BadExpressionStatementJS
|
|
321
|
-
(
|
|
322
|
-
e.Cost *= 2;
|
|
323
|
-
});
|
|
322
|
+
({}) as ArmorPrototype["MeshGenerator"];
|