import { type GlkTypedArray } from '../common/misc.js';
import { FileRef } from './filerefs.js';
import type { GlkArray, GlkStream, RefStructArg } from './interface.js';
import type { Window } from './windows.js';
export type Stream = ArrayBackedStream | FileStream | NullStream | WindowStream;
type StreamType = 'array' | 'null' | 'window';
declare abstract class StreamBase implements GlkStream {
    disprock?: number;
    fmode: number;
    next: Stream | null;
    prev: Stream | null;
    rock: number;
    abstract type: StreamType;
    protected write_count: number;
    constructor(fmode: number, rock: number);
    close(result?: RefStructArg): void;
    get_buffer(_buf: GlkTypedArray): number;
    get_char(_unicode: boolean): number;
    get_line(_buf: GlkTypedArray): number;
    get_position(): number;
    abstract put_buffer(buf: GlkArray, uni: boolean): void;
    abstract put_char(ch: number): void;
    abstract put_string(str: string, style?: string): void;
    set_position(_mode: number, _pos: number): void;
}
/** A fixed-length TypedArray backed stream */
export declare class ArrayBackedStream extends StreamBase {
    protected buf: GlkTypedArray;
    private close_cb?;
    /** Whether we need to check if we should expand the buffer before writing */
    protected expandable: boolean;
    /** The length of the active region of the buffer.
     * This can be shorter than the actual length of the buffer in two situations: a file stream, or a `filemode_Write` memory stream.
     * See https://github.com/iftechfoundation/ifarchive-if-specs/issues/8
     */
    protected len: number;
    protected pos: number;
    private read_count;
    type: "array";
    protected uni: boolean;
    constructor(buf: GlkTypedArray, fmode: number, rock: number, close_cb?: () => void);
    close(result?: RefStructArg): void;
    protected expand(increase: number): void;
    get_buffer(buf: GlkTypedArray): number;
    get_char(unicode: boolean): number;
    get_line(buf: GlkTypedArray): number;
    get_position(): number;
    put_buffer(buf: GlkArray, uni: boolean): void;
    put_char(ch: number): void;
    put_string(str: string): void;
    set_position(mode: number, pos: number): void;
    protected write(): void;
}
/** FileStreams are based on array backed streams, but can grow in length */
export declare class FileStream extends ArrayBackedStream {
    private fref;
    constructor(fref: FileRef, buf: GlkTypedArray, fmode: number, rock: number);
    protected expand(increase: number): void;
    protected write(): void;
}
/** A null stream */
export declare class NullStream extends StreamBase {
    type: "null";
    put_buffer(buf: GlkArray, _uni: boolean): void;
    put_char(_ch: number): void;
    put_string(str: string, _style?: string): void;
}
/** Window streams operate a little bit differently */
export declare class WindowStream extends StreamBase {
    type: "window";
    private win;
    constructor(win: Window);
    put_buffer(buf: GlkArray, uni: boolean): void;
    put_char(ch: number): void;
    put_string(str: string, style?: string): void;
    set_css(name: string, val?: string | number): void;
    set_hyperlink(val: number): void;
    set_style(style: string): void;
}
export {};
