@etothepii/satisfactory-file-parser 0.4.9 → 0.4.11

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/README.md CHANGED
@@ -18,14 +18,14 @@ Game Version Files of U5 and below are NOT supported.
18
18
  | <= U5 | ❌ |
19
19
  | U6 + U7 | ✅ 0.0.1 - 0.0.34 |
20
20
  | U8 | ✅ 0.1.20 - 0.3.7 |
21
- | U1.0 | ✅ >= 0.4.9 |
21
+ | U1.0 | ✅ >= 0.4.11 |
22
22
 
23
23
 
24
24
  ## Installation via npm
25
25
  `npm install @etothepii/satisfactory-file-parser`
26
26
 
27
27
  ## Usage of Save Parsing
28
- Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
28
+ For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
29
29
  ```js
30
30
  import * as fs from 'fs';
31
31
  import { Parser } from "@etothepii/satisfactory-file-parser";
@@ -34,8 +34,33 @@ const file = fs.readFileSync('./MySave.sav') as Buffer;
34
34
  const parsedSave = Parser.ParseSaveFile(file);
35
35
  ```
36
36
 
37
+ ### Save Parsing via Stream
38
+
39
+ You can parse via stream, to save RAM. The binary data will still be in memory, but the converted JSON won't.
40
+ The returned `stream` is a readable WHATWG stream of type string.
41
+ WHATWG is used by default by browsers. Node js can use them using `Writable.toWeb()` and `Writable.fromWeb()` for example.
42
+
43
+ ```js
44
+ const jsonFileStream = fs.createWriteStream(outJsonPath, { highWaterMark: 1024 * 1024 * 200 }); // your outgoing JSON stream. In this case directly to file.
45
+ const whatwgWriteStream = Writable.toWeb(outJsonStream) as WritableStream<string>; // convert the file stream to WHATWG-compliant stream
46
+
47
+ const { stream, startStreaming } = ReadableStreamParser.CreateReadableStreamFromSaveToJson(savename, file, decompressedBody => {
48
+ console.log('on binary body data.');
49
+ }, (progress: number, msg: string | undefined) => {
50
+ // a callback for reporting progress as number [0,1]. Sometimes has a message.
51
+ console.log(`${new Date().toString()}: progress`, progress, msg);
52
+ });
53
+
54
+ stream.pipeTo(whatwgWriteStream);
55
+ whatwgWriteStream.on('close', () => {
56
+ // write stream finished
57
+ });
58
+
59
+ startStreaming();
60
+ ```
61
+
37
62
  Consequently, writing a parsed save file back is just as easy.
38
- The SaveParser has callbacks to assist in syncing on different occasions during the process.
63
+ The SaveParser has callbacks to assist during syncing on different occasions during the process.
39
64
  For example, when writing the header or when writing a chunk of the save body.
40
65
  The splitting in individual chunks enables you to more easily stream the binary data to somewhere else.
41
66
  ```js
@@ -15,8 +15,8 @@ class BlueprintWriter extends byte_writer_class_1.ByteWriter {
15
15
  }
16
16
  static SerializeHeader(writer, header) {
17
17
  writer.writeInt32(2);
18
- writer.writeInt32(42);
19
- writer.writeInt32(263910);
18
+ writer.writeInt32(46);
19
+ writer.writeInt32(366202);
20
20
  let dimensions = [
21
21
  header.designerDimension?.x ?? 4,
22
22
  header.designerDimension?.y ?? 4,
@@ -1619,7 +1619,7 @@ export declare const EDIT: {
1619
1619
  readonly CLASS_NAME: "BP_Golfcart_C";
1620
1620
  };
1621
1621
  readonly FACTORY_CART_GOLD: {
1622
- readonly TYPE_paTH: "/Game/FactoryGame/Buildable/Vehicle/Golfcart/BP_GolfcartGold.BP_GolfcartGold_C";
1622
+ readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Vehicle/Golfcart/BP_GolfcartGold.BP_GolfcartGold_C";
1623
1623
  readonly CLASS_NAME: "BP_GolfcartGold_C";
1624
1624
  };
1625
1625
  readonly EXPLORER: {
@@ -1632,7 +1632,7 @@ export declare const EDIT: {
1632
1632
  };
1633
1633
  readonly TRACTOR: {
1634
1634
  readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Vehicle/Tractor/BP_Tractor.BP_Tractor_C";
1635
- readonly CLAsS_NAME: "BP_Tractor_C";
1635
+ readonly CLASS_NAME: "BP_Tractor_C";
1636
1636
  };
1637
1637
  readonly TRAIN: {
1638
1638
  readonly LOCOMOTIVE: {
@@ -1777,6 +1777,10 @@ export declare const EDIT: {
1777
1777
  readonly CLASS_NAME: "Build_QuantumEncoder_C";
1778
1778
  };
1779
1779
  };
1780
+ readonly ALIEN_POWER_BUILDING: {
1781
+ readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Factory/AlienPower/Build_AlienPowerBuilding.Build_AlienPowerBuilding_C";
1782
+ readonly CLASS_NAME: "Build_AlienPowerBuilding_C";
1783
+ };
1780
1784
  readonly STORAGE: {
1781
1785
  readonly CONTAINER_MK_1: {
1782
1786
  readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Factory/StorageContainerMk1/Build_StorageContainerMk1.Build_StorageContainerMk1_C";
@@ -1822,6 +1826,10 @@ export declare const EDIT: {
1822
1826
  readonly CLASS_NAME: "Build_StorageMedkit_C";
1823
1827
  };
1824
1828
  };
1829
+ readonly POTTY: {
1830
+ readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Building/Potty/BUILD_Potty_mk1.BUILD_Potty_mk1_C";
1831
+ readonly CLASS_NAME: "BUILD_Potty_mk1_C";
1832
+ };
1825
1833
  readonly SIGN: {
1826
1834
  readonly SMALL: {
1827
1835
  readonly TYPE_PATH: "/Game/FactoryGame/Buildable/Factory/SignDigital/Build_StandaloneWidgetSign_Small.Build_StandaloneWidgetSign_Small_C";
@@ -1894,7 +1902,7 @@ export declare const EDIT: {
1894
1902
  readonly TYPE_PATH: "/Game/FactoryGame/Character/Creature/Enemy/Hog/Johnny/Char_Johnny.Char_Johnny_C";
1895
1903
  readonly CLASS_NAME: "Char_Johnny_C";
1896
1904
  };
1897
- readonly SPITTER_SMALL: {
1905
+ readonly SPITTER_ALPHA: {
1898
1906
  readonly TYPE_PATH: "/Game/FactoryGame/Character/Creature/Enemy/Spitter/AlternativeSpitter/Char_Spitter_Alternative.Char_Spitter_Alternative_C";
1899
1907
  readonly CLASS_NAME: "Char_Spitter_Alternative_C";
1900
1908
  };
@@ -1936,6 +1944,10 @@ export declare const EDIT: {
1936
1944
  readonly TYPE_PATH: "/Game/FactoryGame/Character/Creature/Wildlife/SpaceRabbit/Char_SpaceRabbit.Char_SpaceRabbit_C";
1937
1945
  readonly CLASS_NAME: "Char_SpaceRabbit_C";
1938
1946
  };
1947
+ readonly BEETLE: {
1948
+ readonly TYPE_PATH: "/Game/FactoryGame/Character/Creature/Wildlife/Beetle/Char_Beetle.Char_Beetle_C";
1949
+ readonly CLASS_NAME: "Char_Beetle_C";
1950
+ };
1939
1951
  readonly SPACE_GIRAFFE: {
1940
1952
  readonly TYPE_PATH: "/Game/FactoryGame/Character/Creature/Wildlife/SpaceGiraffe/Char_SpaceGiraffe.Char_SpaceGiraffe_C";
1941
1953
  readonly CLASS_NAME: "Char_SpaceGiraffe_C";
@@ -1703,7 +1703,7 @@ exports.EDIT = {
1703
1703
  CLASS_NAME: 'BP_Golfcart_C'
1704
1704
  },
1705
1705
  FACTORY_CART_GOLD: {
1706
- TYPE_paTH: '/Game/FactoryGame/Buildable/Vehicle/Golfcart/BP_GolfcartGold.BP_GolfcartGold_C',
1706
+ TYPE_PATH: '/Game/FactoryGame/Buildable/Vehicle/Golfcart/BP_GolfcartGold.BP_GolfcartGold_C',
1707
1707
  CLASS_NAME: 'BP_GolfcartGold_C'
1708
1708
  },
1709
1709
  EXPLORER: {
@@ -1716,7 +1716,7 @@ exports.EDIT = {
1716
1716
  },
1717
1717
  TRACTOR: {
1718
1718
  TYPE_PATH: '/Game/FactoryGame/Buildable/Vehicle/Tractor/BP_Tractor.BP_Tractor_C',
1719
- CLAsS_NAME: 'BP_Tractor_C'
1719
+ CLASS_NAME: 'BP_Tractor_C'
1720
1720
  },
1721
1721
  TRAIN: {
1722
1722
  LOCOMOTIVE: {
@@ -1861,6 +1861,10 @@ exports.EDIT = {
1861
1861
  CLASS_NAME: 'Build_QuantumEncoder_C'
1862
1862
  },
1863
1863
  },
1864
+ ALIEN_POWER_BUILDING: {
1865
+ TYPE_PATH: '/Game/FactoryGame/Buildable/Factory/AlienPower/Build_AlienPowerBuilding.Build_AlienPowerBuilding_C',
1866
+ CLASS_NAME: 'Build_AlienPowerBuilding_C'
1867
+ },
1864
1868
  STORAGE: {
1865
1869
  CONTAINER_MK_1: {
1866
1870
  TYPE_PATH: TYPE_PATH_CONTAINER_MK1,
@@ -1906,6 +1910,10 @@ exports.EDIT = {
1906
1910
  CLASS_NAME: CLASS_NAME_PLAYER_MEDICAL_CRATE
1907
1911
  },
1908
1912
  },
1913
+ POTTY: {
1914
+ TYPE_PATH: '/Game/FactoryGame/Buildable/Building/Potty/BUILD_Potty_mk1.BUILD_Potty_mk1_C',
1915
+ CLASS_NAME: 'BUILD_Potty_mk1_C'
1916
+ },
1909
1917
  SIGN: {
1910
1918
  SMALL: {
1911
1919
  TYPE_PATH: TYPE_PATH_SIGN_SMALL,
@@ -1978,7 +1986,7 @@ exports.EDIT = {
1978
1986
  TYPE_PATH: '/Game/FactoryGame/Character/Creature/Enemy/Hog/Johnny/Char_Johnny.Char_Johnny_C',
1979
1987
  CLASS_NAME: 'Char_Johnny_C'
1980
1988
  },
1981
- SPITTER_SMALL: {
1989
+ SPITTER_ALPHA: {
1982
1990
  TYPE_PATH: '/Game/FactoryGame/Character/Creature/Enemy/Spitter/AlternativeSpitter/Char_Spitter_Alternative.Char_Spitter_Alternative_C',
1983
1991
  CLASS_NAME: 'Char_Spitter_Alternative_C'
1984
1992
  },
@@ -2020,6 +2028,10 @@ exports.EDIT = {
2020
2028
  TYPE_PATH: TYPE_PATH_LIZARD_DOGGO,
2021
2029
  CLASS_NAME: CLASS_NAME_LIZARD_DOGGO
2022
2030
  },
2031
+ BEETLE: {
2032
+ TYPE_PATH: '/Game/FactoryGame/Character/Creature/Wildlife/Beetle/Char_Beetle.Char_Beetle_C',
2033
+ CLASS_NAME: 'Char_Beetle_C'
2034
+ },
2023
2035
  SPACE_GIRAFFE: {
2024
2036
  TYPE_PATH: TYPE_PATH_SPACE_GIRAFFE,
2025
2037
  CLASS_NAME: CLASS_NAME_SPACE_GIRAFFE
@@ -172,7 +172,7 @@ class DataFields {
172
172
  reader.readInt32();
173
173
  reader.readBytes(1);
174
174
  const recipeTypePath = reader.readString();
175
- reader.readInt64();
175
+ const blueprintProxy = ObjectReference_1.ObjectReference.read(reader);
176
176
  instances.push({
177
177
  transform,
178
178
  unknownUseNumbers,
@@ -180,6 +180,7 @@ class DataFields {
180
180
  paintFinishPath,
181
181
  recipeTypePath,
182
182
  patternPath,
183
+ blueprintProxy
183
184
  });
184
185
  }
185
186
  property.buildables.push({
@@ -383,7 +384,7 @@ class DataFields {
383
384
  writer.writeInt32(0);
384
385
  writer.writeByte(0);
385
386
  writer.writeString(instance.recipeTypePath);
386
- writer.writeInt64(0n);
387
+ ObjectReference_1.ObjectReference.write(writer, instance.blueprintProxy);
387
388
  }
388
389
  }
389
390
  }
@@ -42,6 +42,7 @@ export type BuildableTypeInstance = {
42
42
  paintFinishPath: string;
43
43
  recipeTypePath: string;
44
44
  patternPath: string;
45
+ blueprintProxy: ObjectReference;
45
46
  };
46
47
  export type BuildableSubsystemSpecialProperty = {
47
48
  buildables: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@etothepii/satisfactory-file-parser",
3
3
  "author": "etothepii",
4
- "version": "0.4.9",
4
+ "version": "0.4.11",
5
5
  "description": "A file parser for satisfactory files. Includes save files and blueprint files.",
6
6
  "types": "./build/index.d.ts",
7
7
  "main": "./build/index.js",