@squareys/webdecks-sdk - v0.0.0
    Preparing search index...

    Class Scratch

    The SDK's one shared marshalling region. Every transient value crossing the wasm boundary — a UTF-8 string being passed in, an info struct being read back, a block of bytes — reuses this buffer instead of allocating per call, so the ergonomic wrapper surface costs no GC on the hot path.

    The engine's reserve call grows the buffer in place and returns its current base pointer. Because ALLOW_MEMORY_GROWTH can detach and replace the heap's ArrayBuffer on any allocation, Scratch.sync re-reads the heap views after every reserve, and callers must not hold a returned pointer or view across a further reserve.

    Index
    • Parameters

      Returns Scratch

    • get bytes(): Uint8Array

      The live byte view of the wasm heap (re-read after growth).

      Returns Uint8Array

    • get view(): DataView

      A DataView over the wasm heap, for offset-based struct reads.

      Returns DataView

    • Re-bind the cached heap views if a wasm call grew (and thus detached) the heap.

      Returns void

    • Reserve at least bytes of scratch and return its current base pointer.

      Parameters

      • bytes: number

      Returns number

    • Copy data into scratch and return its base pointer.

      Parameters

      Returns number

    • Encode text as UTF-8 into scratch; returns its base pointer and byte length.

      Parameters

      • text: string

      Returns { pointer: number; length: number }

    • Encode several strings into one reserved region; returns each one's pointer and length.

      Parameters

      • ...texts: string[]

      Returns { pointer: number; length: number }[]

    • Encode text as UTF-8 into scratch with a trailing NUL (for C-string arguments).

      Parameters

      • text: string

      Returns number

    • Decode length UTF-8 bytes of scratch at base into a string.

      Parameters

      • base: number
      • length: number

      Returns string

    • Copy length bytes of the heap at base out into a fresh Uint8Array.

      Parameters

      • base: number
      • length: number

      Returns Uint8Array