import { LdmlKeyboardTypes } from '@keymanapp/common-types';
import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifacts, KeymanCompilerArtifactOptional, KeymanCompilerResult } from '@keymanapp/developer-utils';
import * as Osk from './osk.js';
export declare const STORETYPE_STORE = 1;
export declare const STORETYPE_RESERVED = 2;
export declare const STORETYPE_OPTION = 4;
export declare const STORETYPE_DEBUG = 8;
export declare const STORETYPE_CALL = 16;
export declare const STORETYPE__MASK = 31;
/** @internal */
export interface CompilerResultExtraStore {
    storeType: number;
    name: string;
    line: number;
}
/** @internal */
export interface CompilerResultExtraGroup {
    isReadOnly: boolean;
    name: string;
}
export declare const COMPILETARGETS_KMX = 1;
export declare const COMPILETARGETS_JS = 2;
export declare const COMPILETARGETS__MASK = 3;
/**
 * @internal
 * Data in CompilerResultExtra comes from kmcmplib. This is used by other
 * compilers such as KmwCompiler and is not intended for external use.
 */
export interface KmnCompilerResultExtra {
    /**
     * A bitmask, consisting of COMPILETARGETS_KMX and/or COMPILETARGETS_JS
     */
    targets: number;
    kvksFilename?: string;
    displayMapFilename?: string;
    stores: CompilerResultExtraStore[];
    groups: CompilerResultExtraGroup[];
}
/** @internal */
export interface KmnCompilerResultMessage {
    errorCode: number;
    lineNumber: number;
    columnNumber: number;
    filename: string;
    parameters: string[];
}
/**
 * @public
 * Internal in-memory build artifacts from a successful compilation
 */
export interface KmnCompilerArtifacts extends KeymanCompilerArtifacts {
    /**
     * Binary keyboard filedata and filename - installable into Keyman desktop
     * projects
     */
    kmx?: KeymanCompilerArtifactOptional;
    /**
     * Binary on screen keyboard filedata and filename - installable into Keyman
     * desktop projects alongside .kmx
     */
    kvk?: KeymanCompilerArtifactOptional;
    /**
     * Javascript keyboard filedata and filename - installable into KeymanWeb,
     * Keyman mobile products
     */
    js?: KeymanCompilerArtifactOptional;
}
/**
 * @public
 * Build artifacts from the .kmn compiler
 */
export interface KmnCompilerResult extends KeymanCompilerResult {
    /**
     * Internal in-memory build artifacts from a successful compilation. Caller
     * can write these to disk with {@link KmnCompiler.write}
     */
    artifacts: KmnCompilerArtifacts;
    /**
     * Internal additional metadata used by secondary compile phases such as
     * KmwCompiler, not intended for external use
     */
    extra: KmnCompilerResultExtra;
    /**
     * Mapping data for `&displayMap`, intended for use by kmc-analyze
     */
    displayMap?: Osk.PuaMap;
}
/**
 * @public
 * Options for the .kmn compiler
 */
export interface KmnCompilerOptions extends CompilerOptions {
}
/**
 * @public
 * Compiles a .kmn file to a .kmx, .kvk, and/or .js. The compiler does not read
 * or write from filesystem or network directly, but relies on callbacks for all
 * external IO.
 */
export declare class KmnCompiler implements KeymanCompiler, LdmlKeyboardTypes.UnicodeSetParser {
    private callbacks;
    private wasmExports;
    private options;
    /**
     * Initialize the compiler, including loading the WASM host for kmcmplib.
     * Copies options.
     * @param callbacks - Callbacks for external interfaces, including message
     *                    reporting and file io
     * @param options   - Compiler options
     * @returns false if initialization fails
     */
    init(callbacks: CompilerCallbacks, options: KmnCompilerOptions): Promise<boolean>;
    /**
     * Verify that wasm is spun up OK.
     * @returns true if OK
     */
    verifyInitialized(): boolean;
    /**
     * Write artifacts from a successful compile to disk, via callbacks methods.
     * The artifacts written may include:
     *
     * - .kmx file - binary keyboard used by Keyman on desktop platforms
     * - .kvk file - binary on screen keyboard used by Keyman on desktop platforms
     * - .js file - Javascript keyboard for web and touch platforms
     *
     * @param artifacts - object containing artifact binary data to write out
     * @returns true on success
     */
    write(artifacts: KmnCompilerArtifacts): Promise<boolean>;
    private copyWasmResult;
    /**
     * By default, when a `Uint8Array` is created from an `ArrayBuffer` (e.g.
     * `Module.HEAP8.buffer`), it is a dynamic view into that buffer. This module
     * buffer can be dynamically reallocated at any time, which can happen when
     * allocating memory in WASM code (so the change will  look _really_ weird in
     * a stack trace). Thus, to ensure we don't trip over ourselves, we need to
     * copy the buffer. Fortunately, creating a `Uint8Array` from a `Uint8Array`
     * copies the data, and is pretty quick.
     * @param offset  - Offset into the WASM memory space, in bytes.
     * @param size    - Size of the buffer to copy, in bytes.
     * @returns         A _copy_ of the data in a new Uint8Array.
     */
    private copyWasmBuffer;
    private toTitleCase;
    private generateKmcmpLibMessage;
    /**
     * Compiles a .kmn file to .kmx, .kvk, and/or .js files. Returns an object
     * containing binary artifacts on success. The files are passed in by name,
     * and the compiler will use callbacks as passed to the
     * {@link KmnCompiler.init} function to read any input files by disk.
     * @param infile  - Path to source file. Path will be parsed to find relative
     *                  references in the .kmn file, such as icon or On Screen
     *                  Keyboard file
     * @param outfile - Path to output file. The file will not be written to, but
     *                  will be included in the result for use by
     *                  {@link KmnCompiler.write}.
     * @returns         Binary artifacts on success, null on failure.
     */
    run(infile: string, outfile: string): Promise<KmnCompilerResult>;
    private runWebCompiler;
    private keyboardIdFromKmnFilename;
    private runKvkCompiler;
    private loadDisplayMapping;
    /**
     * @internal
     * Generates an exception in kmcmplib to verify that Sentry error capture is
     * working correctly
     */
    testSentry(): any;
    /**
     * @internal
     * convert `\u{1234}` to `\u1234` etc
     */
    static fixNewPattern(pattern: string): string;
    /**
     * @internal
     * @param pattern    - UnicodeSet pattern such as `[a-z]`
     * @param rangeCount - number of ranges to allocate
     * @returns            UnicodeSet accessor object, or null on failure
     */
    parseUnicodeSet(pattern: string, rangeCount: number): LdmlKeyboardTypes.UnicodeSet | null;
    /**
     * @internal
     */
    sizeUnicodeSet(pattern: string): number;
}
//# sourceMappingURL=compiler.d.ts.map