meo-canvas
    Preparing search index...

    Interface NativeCanvas

    The retained surface, as the addon hands it over.

    Declared here rather than imported so this file compiles without the native module, and so the shape the addon has to satisfy is written down in one place.

    Two encodes rather than one, and the difference is which thread does the work. NativeCanvas.encode runs on the event loop; NativeCanvas.encodeAsync takes the half of an export that needs the canvas, hands the rest to a worker, and resolves when that worker finishes. Both are required: a surface offering only the synchronous one would make Canvas.toBuffer a promise that was already settled, which is what this pair exists to stop being true.

    interface NativeCanvas {
        diagnostics: readonly Diagnostic[];
        engine: string;
        gpu: boolean;
        pageCount: number;
        scale: number;
        warnings: readonly ImageWarning[];
        encode(format: Format, options: EncodeOptions): Buffer;
        encodeAsync(
            format: Format,
            options: EncodeOptions,
        ): Promise<Buffer<ArrayBufferLike>>;
        release(): void;
        write(path: string, format: Format, options: EncodeOptions): void;
        writeAsync(
            path: string,
            format: Format,
            options: EncodeOptions,
        ): Promise<void>;
    }
    Index
    diagnostics: readonly Diagnostic[]

    What the input said that could not be used.

    engine: string

    Which rasteriser drew the pages: 'gpu' or 'cpu'.

    gpu: boolean

    Whether the GPU was asked for.

    pageCount: number

    How many pages were painted.

    scale: number

    The device-pixel multiplier the pages were drawn at.

    warnings: readonly ImageWarning[]

    Every image source that could not be resolved, in node order.

    • Encodes the painted pages and returns the bytes.

      A Node Buffer, which is what the addon hands back: it builds the result with Neon's JsBuffer::from_slice (crates/meo-canvas-node/src/lib.rs:485). A caller supplying their own native surface for a test may return any Buffer; a plain Uint8Array would be a different value from the one this package ships.

      Parameters

      Returns Buffer

    • Encodes the painted pages on a worker and resolves with the bytes.

      The same bytes NativeCanvas.encode returns — the addon defines the two as one path rather than two, so they cannot drift — produced without occupying the event loop for the encode.

      Rejects rather than throwing once the work has left the calling thread: a format the addon does not know is a synchronous TypeError, because there is still a call to throw from, while a failure inside the encode settles the promise.

      Parameters

      Returns Promise<Buffer<ArrayBufferLike>>

    • Frees the Skia surface. Calling it twice is not an error.

      Returns void

    • Encodes the painted pages straight into a file, blocking.

      Not NativeCanvas.encode followed by a write, and the difference is the whole reason it exists: a format that gathers every page streams into the file, where encoding first has to hold the entire document in memory to hand it back. A long animation is bounded by disk here and by RAM there.

      The format is passed rather than inferred from the path. The extension is resolved on this side, because the error for an unrecognised one names the file; inferring it again on the far side would be one question with two places to answer it.

      Parameters

      Returns void