satisfactory-json
Advanced tools
Comparing version 0.0.23 to 0.0.24
{ | ||
"name": "satisfactory-json", | ||
"version": "0.0.23", | ||
"author": "ficsit-felix", | ||
"dependencies": { | ||
"pako": "^1.0.10" | ||
}, | ||
"description": "Convert Satisfactory save files to JSON and back", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"repository": "https://github.com/bitowl/satisfactory-json", | ||
"author": "bitowl", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^12.0.4", | ||
"gulp": "^4.0.2", | ||
"gulp-plumber": "^1.2.1", | ||
"gulp-typescript": "^5.0.1", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.17.0", | ||
"typescript": "^3.5.1" | ||
"@types/node": "^12.7.5", | ||
"@types/pako": "^1.0.1", | ||
"@typescript-eslint/eslint-plugin": "^2.3.1", | ||
"@typescript-eslint/parser": "^2.3.1", | ||
"commander": "^3.0.1", | ||
"eslint": "^6.5.0", | ||
"eslint-config-prettier": "^6.3.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"prettier": "^1.18.2", | ||
"ts-node": "^8.4.1", | ||
"typescript": "^3.6.3", | ||
"v8-profiler-next": "^1.1.1" | ||
}, | ||
"scripts": { | ||
"build": "gulp", | ||
"build:watch": "gulp watch", | ||
"lint": "tslint --project \"./tsconfig.json\"", | ||
"prepublish": "yarn build", | ||
"postversion": "git push && git push --tags", | ||
"sav2json": "node lib/cli/sav2json.js", | ||
"json2sav": "node lib/cli/json2sav.js" | ||
}, | ||
"files": [ | ||
"lib/**/*" | ||
], | ||
"bin": { | ||
"sav2json": "./lib/sav2json.js", | ||
"json2sav": "./lib/json2sav.js" | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"name": "satisfactory-json", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"commander": "^2.20.0" | ||
} | ||
"repository": "https://github.com/ficsit-felix/satisfactory-json", | ||
"scripts": { | ||
"build": "tsc --build tsconfig.json", | ||
"build:watch": "tsc -w", | ||
"lint": "eslint \"src/**\"", | ||
"sav2json": "ts-node src/cli/sav2json.ts", | ||
"sav2json:js": "node lib/cli/sav2json.js", | ||
"json2sav": "ts-node src/cli/json2sav.ts", | ||
"json2sav:js": "node lib/cli/json2sav.js", | ||
"prepare-gpr": "sed -i 's/\"name\": \"satisfactory-json\"/\"name\": \"@ficsit-felix\\\/satisfactory-json\"/' package.json" | ||
}, | ||
"types": "lib/index.d.ts", | ||
"version": "0.0.24" | ||
} |
@@ -5,3 +5,23 @@ # satisfactory-json | ||
## Usage | ||
Using node streams: | ||
```ts | ||
import { SaveGame, Sav2JsonTransform, Json2SavTransform } from 'satisfactory-json'; | ||
// convert sav -> json | ||
const readStream: ReadStream; // e.g. from fs.createReadStream | ||
readStream.pipe(new Sav2JsonTransform()).on('data', saveGame => { | ||
}); | ||
// convert json -> sav | ||
const saveGame: SaveGame; | ||
const writeStream: WriteStream; // e.g. from fs.createWriteStream | ||
const transform = new Json2SavTransform(); | ||
transform.pipe(writeStream); | ||
transform.write(saveGame); | ||
transform.end(); | ||
``` | ||
Or using something similar to the previous interface: | ||
```ts | ||
import { SaveGame, sav2json, json2sav } from 'satisfactory-json'; | ||
@@ -11,5 +31,12 @@ | ||
// convert sav -> json | ||
const saveGame: SaveGame = sav2json(saveFileData); | ||
sav2json(saveFileData).then((saveGame: SaveGame) => { | ||
}); | ||
// convert json -> sav | ||
const saveData: string = json2sav(saveGame); | ||
const saveGame: SaveGame; | ||
json2sav(saveGame).then((saveData: string) => { | ||
}); | ||
``` | ||
@@ -24,18 +51,1 @@ | ||
Progress towards a stable JSON interface can be observed at [milestone 0.1.0](https://github.com/ficsit-felix/satisfactory-json/issues?q=is%3Aopen+is%3Aissue+milestone%3A0.1.0). As Satisfactory itself is still in Early Access the save file format will also probably change in breaking ways with each new game update. | ||
### What does the preprocessor do? | ||
The goal was to achieve bidirectional transformations from Archive to the variable as in the Unreal code. This is useful, because binary data has to be read in the same way it was written, so writing that code once saves the effort to keep the two functions in sync. | ||
``` | ||
ar << property.name; | ||
``` | ||
Problem is, TypeScript passes parameters by value and not by reference. The only way to be able to read or write to a variable seems to be to pass an object and a key to a variable in it: | ||
```ts | ||
ar.transformString(property, 'name'); | ||
``` | ||
By using strings as key we lose the most important feature of TypeScript, the Type Safety. So I wrote a preprocessor that converts the following code to the code above before sending it t the TypeScript compiler so that we can have the best of both worlds. | ||
```ts | ||
ar.transformString(property.name); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
49
1
3881
12
3
0
2
+ Addedpako@^1.0.10
+ Addedpako@1.0.11(transitive)
- Removedcommander@^2.20.0
- Removedcommander@2.20.3(transitive)