Constructors

Methods

  • It JSON.stringifies any parsed content safely. The original JSON.stringify() has some flaws that get in the way, so it is custom wrapped. The original has some problems:

    1. it cannot stringify bigints. So we help out by converting it into a string.
    2. It cannot distinguish between 0 and -0. But a float32 is encoded in a uint8Array for 0 to be [0,0,0,0] (0x00000000) and -0 to be [0,0,0,128] (0x00000080) in little endian.

    Parameters

    • obj: any

      basically anything that can be stringified

    • indent: number = 0

      the indentation, just like with the real JSON stringify.

    Returns string

    a string that is safely stringified.

  • Parses two buffers (main blueprint file + config file) into a object

    Parameters

    • name: string

      the name of the blueprint, since it is not part of the binary data and has to be passed.

    • blueprintFile: ArrayBufferLike

      the main blueprint file ".sbp"

    • blueprintConfigFile: ArrayBufferLike

      the config blueprint file ".sbpcfg"

    • Optionaloptions: Partial<{
          onDecompressedBlueprintBody: ((buffer: ArrayBufferLike) => void);
      }>

      provides callbacks. onDecompressedBlueprintBody gets called when the body of the main blueprint file is decompressed.

    Returns Blueprint

  • Parses a given binary buffer as SatisfactorySave

    Parameters

    • name: string

      the save name. It won't be serialized, so it does not matter how you name it.

    • bytes: ArrayBufferLike

      the actual binary buffer

    • Optionaloptions: Partial<{
          onDecompressedSaveBody: ((buffer: ArrayBufferLike) => void);
          onProgressCallback: ((progress: number, msg?: string) => void);
      }>

      provides callbacks. Either on the decompressed save body or on reported progress as a number [0,1] with an occasional message.

    Returns SatisfactorySave

  • Writes a Blueprint object to binary. And reports back on individual callbacks.

    Parameters

    • blueprint: Blueprint

      the blueprint to be written

    • onMainFileHeader: ((header: Uint8Array) => void)
        • (header): void
        • Parameters

          • header: Uint8Array

          Returns void

    • onMainFileChunk: ((chunk: Uint8Array) => void)
        • (chunk): void
        • Parameters

          • chunk: Uint8Array

          Returns void

    • Optionaloptions: Partial<{
          onMainFileBinaryBeforeCompressing: ((binary: ArrayBuffer) => void);
      }>

      onMainFileBinaryBeforeCompressing gets called back when the main blueprint file binary is ready before compressing. onMainFileHeader gets called back when the main blueprint file header is ready. onMainFileChunk gets called back when a main blueprint file chunk is ready.

    Returns {
        configFileBinary: ArrayBuffer;
        mainFileChunkSummary: ChunkSummary[];
    }

    a chunk summary of the main file generated chunks. Plus the binary data of the config file, since it is often very small.

    • configFileBinary: ArrayBuffer
    • mainFileChunkSummary: ChunkSummary[]
  • serializes a SatisfactorySave into binary and reports back on individual callbacks.

    Parameters

    • save: SatisfactorySave

      the SatisfactorySave to serialize into binary.

    • onHeader: ((header: Uint8Array) => void)
        • (header): void
        • Parameters

          • header: Uint8Array

          Returns void

    • onChunk: ((chunk: Uint8Array) => void)
        • (chunk): void
        • Parameters

          • chunk: Uint8Array

          Returns void

    • Optionaloptions: Partial<{
          onBinaryBeforeCompressing: ((buffer: ArrayBuffer) => void);
      }>

      provides callbacks. onBinaryBeforeCompressing gets called on the binary save body before it is compressed. onHeader gets called on the binary save header, which is always uncompressed. onChunk gets called when a chunk of the compressed save body was generated. Often, files' save bodies consist of multiple chunks.

    Returns ChunkSummary[]

    a summary of the generated chunks.