Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

satisfactory-json

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

satisfactory-json - npm Package Compare versions

Comparing version 0.0.36 to 0.0.37

12

lib/cli/json2sav.js

@@ -70,5 +70,2 @@ #!/usr/bin/env node

else {
if (commander_1.default.time) {
console.time('readFile');
}
if (commander_1.default.profile) {

@@ -80,11 +77,3 @@ profiler.startProfiling('probe', true);

var outStream = fs.createWriteStream(targetValue, opts);
/*
fs.readFile(sourceValue!, 'binary', (error, data) => {
if (error) {
quitWithError(error);
}
const binaryData = Buffer.from(data, 'binary');*/
if (commander_1.default.time) {
console.timeEnd('readFile');
console.time('json2sav');

@@ -120,3 +109,2 @@ }

console.timeEnd('json2sav');
//console.time('writeFile');
}

@@ -123,0 +111,0 @@ if (commander_1.default.profile) {

@@ -56,5 +56,2 @@ #!/usr/bin/env node

else {
if (commander_1.default.time) {
console.time('readFile');
}
if (commander_1.default.profile) {

@@ -66,11 +63,3 @@ profiler.startProfiling('probe', true);

var outStream = fs.createWriteStream(targetValue, opts);
/*
fs.readFile(sourceValue!, 'binary', (error, data) => {
if (error) {
quitWithError(error);
}
const binaryData = Buffer.from(data, 'binary');*/
if (commander_1.default.time) {
console.timeEnd('readFile');
console.time('sav2json');

@@ -96,3 +85,2 @@ }

console.timeEnd('sav2json');
//console.time('writeFile');
}

@@ -108,13 +96,4 @@ if (commander_1.default.profile) {

}
/*const output = JSON.stringify(transformed);
fs.writeFile(targetValue!, output, 'utf8', (error2) => {
if (error2) {
quitWithError(error2);
}
console.timeEnd('writeFile');
console.log('Converted ' + sourceValue + ' to ' + targetValue);
});*/
});
}
//# sourceMappingURL=sav2json.js.map

@@ -178,3 +178,2 @@ "use strict";

setVar(ctx, ref, result);
//ctx.obj._length = result; // TODO remove
if (resetBytesRead) {

@@ -602,8 +601,2 @@ this.resetBytesRead();

lengthPlaceholder.startBufferLength + actualLengthInBytes;
//console.log(ctx.path);
/*if (value != ctx.obj._length) {
console.warn(`Wrong length: ${value} != ${ctx.obj._length} ${ctx.path}`);
// TODO remove
//debugger;
}*/
var buffer = lengthPlaceholder.buffer < this.buffers.length

@@ -635,3 +628,2 @@ ? this.buffers[lengthPlaceholder.buffer]

return true;
//throw new Error("Method not implemented.");
};

@@ -638,0 +630,0 @@ // correctly puts the values in the chunks

18

lib/engine/Builder.js

@@ -91,18 +91,4 @@ "use strict";

};
Builder.prototype.call = function (functionName /*rulesFunction: (builder: Builder) => void*/) {
/*if (rulesFunction.name === '') {
throw new Error('call() can only be used with named functions');
}
// Only build each function once
if (functionCommands[rulesFunction.name] === undefined) {
//console.log('building', rulesFunction.name);
// Already set this, so that we don't get into infinite recursion
functionCommands[rulesFunction.name] = [];
const builder = new Builder();
rulesFunction(builder);
functionCommands[rulesFunction.name] = builder.getCommands();
}*/
this.commands.push(new commands_1.CallCommand(functionName /*rulesFunction.name*/));
Builder.prototype.call = function (functionName) {
this.commands.push(new commands_1.CallCommand(functionName));
return this;

@@ -109,0 +95,0 @@ };

@@ -247,19 +247,2 @@ "use strict";

return 0;
/* if (ctx.isLoading) {
const result = ar.readInt(this.shouldCount);
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result);
return 0;
} else {
const value = getVar(ctx, this.name);
ar.writeInt(value, this.shouldCount);
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -283,14 +266,2 @@ return IntCommand;

return 0;
/* if (ctx.isLoading) {
const result = ar.readStr(this.shouldCount);
if (result === undefined) {
return ar.missingBytes;
}
setVar(ctx, this.name, result);
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -313,15 +284,2 @@ return StrCommand;

return 0;
/* if (ctx.isLoading) {
const result = ar.readLong();
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result);
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -345,16 +303,2 @@ return LongCommand;

return 0;
/*
if (ctx.isLoading) {
const result = ar.readByte(this.shouldCount);
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result);
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -377,16 +321,2 @@ return ByteCommand;

return 0;
/*
if (ctx.isLoading) {
const result = ar.readFloat();
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result);
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -409,19 +339,2 @@ return FloatCommand;

return 0;
/*
if (ctx.isLoading) {
const result = ar.readByte(this.shouldCount);
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
const zero = result;
if (zero !== 0) {
throw new Error(`Byte not 0, but ${zero}`);
}
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -446,16 +359,2 @@ return AssertNullByteCommand;

return 0;
/*
if (ctx.isLoading) {
const result = ar.read(this.bytes, this.shouldCount);
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result.toString("hex"));
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -517,3 +416,2 @@ return HexCommand;

var result = this.cond(ctx);
//console.log(`----------COND: ${result}`);
if (result) {

@@ -577,20 +475,2 @@ // execute then branch

return 0;
/*
if (ctx.isLoading) {
const result = ar.readInt();
if (result === undefined) {
return ar.missingBytes;
}
setVar(ctx, this.name, result);
if (this.resetBytesRead) {
ar.resetBytesRead();
}
// TODO preload the next ${result} bytes?
} else {
// TODO writing
throw Error("Unimplemented");
}
return 0;
*/
};

@@ -611,8 +491,2 @@ return BufferStartCommand;

return 0;
/*if (ctx.isLoading) {
} else {
// TODO writing
throw Error("Unimplemented");
}
return 0;*/
};

@@ -636,18 +510,2 @@ return BufferEndCommand;

return 0;
/*
if (ctx.isLoading) {
const length = getVar(ctx, this.lengthVar);
const result = ar.readUntil(length);
if (result === undefined) {
// return the amount of missing bytes
return ar.missingBytes;
}
setVar(ctx, this.name, result.toString("hex"));
return 0;
} else {
// TODO writing
throw Error("Unimplemented");
return 0;
}*/
};

@@ -667,3 +525,2 @@ return HexRemainingCommand;

var value = getVar(ctx, this.name).toString();
//console.log(`Fetch ${value}`);
if (this.cases[value] !== undefined) {

@@ -726,3 +583,2 @@ newStackFrameCallback(this.cases[value]);

EndSaveGameCommand.prototype.exec = function (_ctx, ar, _newStackFrameCallback, _dropStackFrameCallback) {
//console.log('finished');
ar.endSaveGame();

@@ -729,0 +585,0 @@ return -3;

@@ -28,4 +28,2 @@ "use strict";

var _this = _super.call(this, { highWaterMark: 131072 }) || this;
//private buffers: Buffer[] = [];
//private bufferedBytes: number = 0;
_this.maxChunkSize = 131072;

@@ -36,12 +34,3 @@ _this.packageFileTag = jsbi_1.default.BigInt('2653586369');

CompressionTransform.prototype._transform = function (buffer, encoding, callback) {
//this.bufferedBytes += buffer.length;
/*if (this.buffers.length > 0) {
// concatenate all the buffers
this.buffers.push(buffer);
buffer = Buffer.concat(this.buffers);
this.buffers = [];
}
while (this.bufferedBytes >= this.maxChunkSize) {*/
var chunk = buffer.slice(0, this.maxChunkSize);
//this.bufferedBytes -= this.maxChunkSize;
var deflatedChunk = pako_1.deflate(chunk);

@@ -57,3 +46,2 @@ var chunkHeader = Buffer.alloc(48);

this.push(deflatedChunk);
//}
callback();

@@ -60,0 +48,0 @@ };

@@ -15,3 +15,2 @@ "use strict";

DecompressionTransform.prototype.transform = function (buffer, transformationEngine) {
//console.log('transform');
var result;

@@ -39,3 +38,2 @@ if (buffer !== undefined) {

if (compressedChunk === undefined) {
//console.log('READ MORE: ' + chunk.missingBytes);
// need to read more

@@ -47,3 +45,3 @@ this.needBytes = this.chunk.missingBytes + this.chunk.rollback();

var inflated = pako_1.inflate(compressedChunk);
this.uncompressedBuffer = Buffer.from(inflated); // Buffer.from(this.firstRead ? inflated.slice(4) : inflated);
this.uncompressedBuffer = Buffer.from(inflated);
this.firstRead = false;

@@ -53,5 +51,2 @@ result = transformationEngine.transformRead(this.uncompressedBuffer);

else {
/*if (this.firstRead) {
console.log('first 4 bytes', Buffer.from(inflated.slice(0, 4)).readInt32LE(0));
}*/
result = transformationEngine.transformRead(undefined);

@@ -76,3 +71,2 @@ }

}
//console.log(packageFileTag);
var maxChunkSize = chunk.readLong();

@@ -98,3 +92,2 @@ if (maxChunkSize === undefined) {

}
// return compressedSize;
return chunk.read(Number(compressedSize));

@@ -101,0 +94,0 @@ };

@@ -125,3 +125,2 @@ "use strict";

registerFunction(RegisteredFunction.transformInt8Property, Int8Property_1.transformInt8Property);
//console.log('commands', inspect(this.commands, false, 10));
}

@@ -136,3 +135,2 @@ TransformationEngine.prototype.prepare = function (isLoading) {

if (this.bufferedBytes < this.needBytes) {
//console.log(`still missing ${this.needBytes - this.bufferedBytes} bytes`);
this.buffers.push(buffer);

@@ -152,3 +150,2 @@ // need to read more

if (this.stack.length === 0) {
//console.info('Starting program...');
// Stack empty: Begin of program or something went wrong

@@ -182,19 +179,3 @@ var saveGame = {};

var cmd = frame.commands[frame.currentCommand];
//console.log('executing', cmd);
var needBytes = cmd.exec(frame.ctx, this_1.chunk, function (commands) {
// console.log(frame.ctx.vars);
/* const vars = {
_length: frame.ctx.vars._length,
_index: frame.ctx.vars._index,
_name: frame.ctx.vars._name,
_entryCount: frame.ctx.vars._entryCount,
_tagSize: frame.ctx.vars._tagSize,
_type: frame.ctx.vars._type,
_keyTransform: frame.ctx.vars._keyTransform,
_valueTransform: frame.ctx.vars._valueTransform,
_withNames: frame.ctx.vars._withNames,
_className: frame.ctx.vars._className,
_itemCount: frame.ctx.vars._itemCount,
_childCount: frame.ctx.vars._childCount,
};*/
// create new stack frame

@@ -204,3 +185,3 @@ _this.stack.push({

currentCommand: 0,
ctx: /*frame.ctx*/ {
ctx: {
obj: frame.ctx.obj,

@@ -230,6 +211,2 @@ tmp: frame.ctx.tmp,

// This command needs more bytes to successfully execute
/*console.log(chunk.cursor);
console.log('---------------------------');
console.error(`Need ${needBytes} more bytes.`);
console.log(frame.ctx.vars);*/
this_1.needBytes = needBytes;

@@ -257,3 +234,2 @@ // pass bytesRead to next chunk

else if (needBytes === -3) {
console.log('finihsed');
// end of the save game

@@ -277,3 +253,2 @@ this_1.finished = true;

}
//console.log(saveGame);
return TransformResult.WaitForNextChunk;

@@ -292,3 +267,2 @@ };

if (this.stack.length === 0) {
//console.info('Starting program...');
// Stack empty: Begin of program or something went wrong

@@ -324,19 +298,3 @@ if (saveGame !== undefined) {

var cmd = frame.commands[frame.currentCommand];
//console.log('executing', cmd);
var needBytes = cmd.exec(frame.ctx, ar, function (commands) {
// console.log(frame.ctx.vars);
/* const vars = {
_length: frame.ctx.vars._length,
_index: frame.ctx.vars._index,
_name: frame.ctx.vars._name,
_entryCount: frame.ctx.vars._entryCount,
_tagSize: frame.ctx.vars._tagSize,
_type: frame.ctx.vars._type,
_keyTransform: frame.ctx.vars._keyTransform,
_valueTransform: frame.ctx.vars._valueTransform,
_withNames: frame.ctx.vars._withNames,
_className: frame.ctx.vars._className,
_itemCount: frame.ctx.vars._itemCount,
_childCount: frame.ctx.vars._childCount,
};*/
// create new stack frame

@@ -346,3 +304,3 @@ _this.stack.push({

currentCommand: 0,
ctx: /*frame.ctx*/ {
ctx: {
obj: frame.ctx.obj,

@@ -407,3 +365,2 @@ tmp: frame.ctx.tmp,

}
//console.log(saveGame);
return TransformResult.WaitForNextChunk;

@@ -410,0 +367,0 @@ };

@@ -11,3 +11,3 @@ "use strict";

for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -48,23 +48,2 @@ exports.json2sav = exports.sav2json = void 0;

exports.json2sav = json2sav;
/*
export function sav2json(buffer: Buffer): SaveGame {
const saveGame: SaveGame = {
saveHeaderType: 0,
saveVersion: 0,
buildVersion: 0,
mapName: '',
mapOptions: '',
sessionName: '',
playDurationSeconds: 0,
saveDateTime: '',
sessionVisibility: 0,
actors: [],
components: [],
collected: [],
missing: ''
};
return saveGame;
}
*/
//# sourceMappingURL=index.js.map

@@ -67,3 +67,2 @@ "use strict";

this.compressionTransform.write(chunk_1);
// this.compressionTransform.push(chunk);
}

@@ -70,0 +69,0 @@ else {

@@ -28,5 +28,3 @@ "use strict";

_this.progressTimeoutMs = progressTimeoutMs;
//console.time('buildRules');
_this.transformationEngine = new TransformationEngine_1.TransformationEngine(transform_1.transform, function (buffer) {
//console.log('enable compression')
_this.compressionTransform = new DecompressionTransform_1.DecompressionTransform();

@@ -39,3 +37,2 @@ _this._transform(buffer, 'buffer', function () { });

return _this;
//console.timeEnd('buildRules');
}

@@ -42,0 +39,0 @@ Sav2JsonTransform.prototype._transform = function (chunk, encoding, callback) {

@@ -31,3 +31,2 @@ "use strict";

.if(function (ctx) { return ctx.tmp._name === 'None'; }, function (builder) { return builder.break(); })
//.exec(ctx => console.log('properties._index', ctx.vars._index))
.elem('_index')

@@ -71,8 +70,2 @@ .exec(function (ctx) { return (ctx.obj.name = ctx.tmp._name); })

.call(TransformationEngine_1.RegisteredFunction.transformProperties)
/*.exec(ctx => {
if (ctx.path.startsWith('saveGame.actors[473]')) {
debugger;
}
})*/
//.exec(ctx => console.log('entity', ctx.obj))
.int('_extraObjectCount', function () { return 0; })

@@ -87,3 +80,2 @@ .exec(function (ctx) {

// TODO read missing data
//.debug('>_entityLength', ctx => ctx.tmp._entityLength)
.hexRemaining('missing', '_entityLength')

@@ -90,0 +82,0 @@ .exec(function (ctx) {

4

lib/transforms/extras/ConveyorBelt.js

@@ -15,5 +15,3 @@ "use strict";

if (ar.getBytesRead() >= ctx.tmp._entityLength) {
//console.warn('Item count is ' + items.length +
//' while there are only ' + i + ' items in there');
// break:
// wrong amount of items on conveyor belt
dropStackFrameCallback();

@@ -20,0 +18,0 @@ }

@@ -127,5 +127,3 @@ "use strict";

.str('_name')
//.debug('_name', ctx => ctx.vars._name)
.if(function (ctx) { return ctx.tmp._name === 'None'; }, function (builder) { return builder.break(); })
//.exec(ctx => console.log('properties._index', ctx.vars._index))
.elem('_index')

@@ -132,0 +130,0 @@ .exec(function (ctx) { return (ctx.obj.name = ctx.tmp._name); })

@@ -71,6 +71,3 @@ "use strict";

StructProperty: function (builder) {
builder
//.obj('value') TODO add value here
.call(TransformationEngine_1.RegisteredFunction.transformProperties);
//.endObj();
builder.call(TransformationEngine_1.RegisteredFunction.transformProperties);
},

@@ -77,0 +74,0 @@ ByteProperty: function (builder) {

@@ -54,2 +54,3 @@ "use strict";

SlateBrush: function (builder) { return SlateBrush_1.transformSlateBrush(builder); },
Hotbar: function (builder) { return ArbitraryStruct_1.transformArbitraryStruct(builder); },
$default: function (builder) {

@@ -56,0 +57,0 @@ return builder.error(function (ctx) { return "Unknown struct property: " + ctx.obj.type; });

@@ -85,6 +85,4 @@ "use strict";

.call(TransformationEngine_1.RegisteredFunction.transformHeader)
//.exec(() => console.log('Header done'))
.int('_entryCount', function (ctx) { return ctx.obj.actors.length + ctx.obj.components.length; })
.loop('_entryCount', function (builder) {
//builder.debug("AoC", ctx => ctx.tmp._index);
builder

@@ -94,7 +92,4 @@ .emitEntityProgress(50, 0)

})
//.exec(() => console.log('Actors and Components done'))
.int('_entryCount')
//.exec((ctx) => console.log('entryCount', ctx.vars._entryCount))
.loop('_entryCount', function (builder) {
//builder.debug("entity", ctx => ctx.tmp._index);
builder.emitEntityProgress(50, 50).if(function (ctx) { return ctx.tmp._index < ctx.obj.actors.length; }, function (builder) {

@@ -101,0 +96,0 @@ builder

@@ -38,4 +38,6 @@ {

"sav2json:js": "node lib/cli/sav2json.js",
"sav2json:debug": "node -r ts-node/register --inspect-brk src/cli/sav2json.ts",
"json2sav": "ts-node src/cli/json2sav.ts",
"json2sav:js": "node lib/cli/json2sav.js",
"json2sav:debug": "node -r ts-node/register --inspect-brk src/cli/json2sav.ts",
"prepare-gpr": "sed -i 's/\"name\": \"satisfactory-json\"/\"name\": \"@ficsit-felix\\/satisfactory-json\"/' package.json"

@@ -47,3 +49,3 @@ },

},
"version": "0.0.36"
"version": "0.0.37"
}

@@ -49,1 +49,4 @@ # satisfactory-json

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.
### Debugging
To debug using the cli call `yarn sav2json:debug` or `yarn json2sav:debug` and then use a node.js Inspector Client, e.g. Chrome DevTool to debug the program.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc