G-code Preview — API Reference
    Preparing search index...
    interface AsyncParseHooks {
        captureWindows?: { head: string; tail: string };
        onPartial?: (slice: ToolpathIR, cumulativeSegments: number) => void;
        onProgress?: (
            bytesProcessed: number,
            totalBytes: number,
            segments: number,
        ) => void;
        partialIntervalMs?: number;
        partialMinBytes?: number;
        shouldCancel?: () => boolean;
        yieldIntervalMs?: number;
    }
    Index

    Properties

    captureWindows?: { head: string; tail: string }

    DD-005 §4.5 stream detection windows: when set, the STREAMING driver fills head with the first ≤64 KB of decoded text and keeps tail as a bounded rolling window (last ≤16 KB) — read after the parse for late dialect detection on non-seekable streams. In-memory drivers ignore this (their windows are sliceable up front).

    onPartial?: (slice: ToolpathIR, cumulativeSegments: number) => void

    Progressive preview (DD-004 §5.4, issue #60): receives path-aligned delta snapshots of the IR built so far. Emission starts once bytesProcessed ≥ partialMinBytes and repeats at most every partialIntervalMs.

    onProgress?: (
        bytesProcessed: number,
        totalBytes: number,
        segments: number,
    ) => void

    Called after each cooperative yield with bytes processed so far.

    partialIntervalMs?: number

    Minimum ms between partial snapshots (default 1000).

    partialMinBytes?: number

    Bytes processed before the first partial may be emitted (default 0 when onPartial set).

    shouldCancel?: () => boolean

    Checked after each yield; returning true stops the parse with a partial result.

    yieldIntervalMs?: number

    Max CPU ms between yields (DD-003 §5.2 default 50).