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 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(): [keyof this, (typeof this)[keyof this]][] {
98
- return Object.entries(this).filter(([key]) => !INTERNAL_PROPS.has(key)) as [
99
- keyof this,
100
- (typeof this)[keyof this],
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 += Object.entries(this)
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
- Object.assign(dummy.__internal__, new Refs(match[3]));
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
- (({}) as ArmorPrototype["MeshGenerator"]).forEach(([_k, e]) => {
322
- e.Cost *= 2;
323
- });
322
+ ({}) as ArmorPrototype["MeshGenerator"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s2cfgtojson",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "description": "Converts Stalker 2 Cfg file into POJOs",
5
5
  "keywords": [
6
6
  "stalker",