@lumera/sdk-js
    Preparing search index...

    Class RaptorQProxy

    Proxy to the rq-library-wasm package for RaptorQ operations.

    This class handles initialization of the WASM module and provides a clean API for creating RaptorQ layouts using in-memory filesystem operations.

    The proxy implements the singleton pattern to ensure only one WASM instance is created. Files are stored in browser's in-memory filesystem before processing.

    const proxy = RaptorQProxy.getInstance();
    await proxy.initialize();

    // Create a layout from file data
    const layoutBytes = await proxy.createSingleBlockLayout(fileBytes);
    Index

    Methods

    • Creates a RaptorQ session with the specified parameters.

      Parameters

      • symbolSize: number = RaptorQProxy.DEFAULT_SYMBOL_SIZE

        Size of each symbol in bytes (default: 65535)

      • redundancyFactor: number = RaptorQProxy.DEFAULT_REDUNDANCY_FACTOR

        Redundancy factor for encoding (default: 10)

      • maxMemoryMb: bigint = RaptorQProxy.DEFAULT_MAX_MEMORY_MB

        Maximum memory in MB (default: 1024)

      • concurrencyLimit: bigint = RaptorQProxy.DEFAULT_CONCURRENCY_LIMIT

        Concurrency limit (default: 4)

      Returns Promise<RaptorQSession>

      A new RaptorQSession instance

      If WASM module is not initialized

    • Creates a single-block RaptorQ layout from file bytes.

      This generates metadata for a file by:

      1. Writing the file bytes to the in-memory filesystem
      2. Creating a RaptorQ session
      3. Calling create_metadata to generate the layout
      4. Reading the layout file from in-memory filesystem
      5. Cleaning up temporary files

      Parameters

      • fileBytes: Uint8Array

        The file content as a Uint8Array

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A promise that resolves to the raw layout file bytes (JSON format)

      If layout creation fails

      IMPORTANT: The file MUST be loaded into in-memory FS before creating RaptorQSession. This method follows the correct workflow:

      • Save file to in-memory FS
      • Create session
      • Call create_metadata
      • Read and return the layout file
    • Gets the recommended block size for a given file size.

      Parameters

      • fileSize: number

        The file size in bytes

      Returns Promise<number>

      The recommended block size

      If WASM module is not initialized

    • Gets the RaptorQ library version.

      Returns Promise<string>

      The library version string

      If WASM module is not initialized

    • Initializes the WASM module.

      Returns Promise<void>

      This loads the WASM module using the rq-library-wasm package. The package handles all platform-specific initialization automatically.

      If the WASM module cannot be loaded

    • Checks if the WASM module is currently initialized.

      Returns boolean

      True if the module is initialized, false otherwise

    • Internal

      Resets the singleton instance.

      Returns void

      Primarily useful for testing purposes. Should not be used in production code.