import { IDisposable, IEvent } from '@kano/common/index.js';
import { PartComponent } from './component.js';
import { Microphone } from '../output/microphone.js';
/**
 * Declares the APIs available for the part to use.
 * This usually give access to the output's APIs.
 */
export interface IPartContext {
    visuals: {
        canvas: HTMLCanvasElement;
        width: number;
        height: number;
    };
    audio: {
        context: AudioContext;
        destination: AudioNode;
        microphone: Microphone;
    };
    dom: {
        root: HTMLElement;
        onDidResize: IEvent<void>;
    };
}
/**
 * [[include:Part.md]]
 *
 * This class is the parent for each Part. It handles setting up the components, and the lifecycle steps.
 */
export declare class Part {
    /**
     * A bug in EventEmitter makes it only accept arrays. No Disposables
     */
    protected subscriptions: IDisposable[];
    /**
     * Put all your user subscriptions in there, They will be disposed off on every app stop
     */
    protected userSubscriptions: IDisposable[];
    /**
     * Map of components for the part. See [[PartComponent]]
     */
    protected _components: Map<string, PartComponent>;
    /**
     * Unique id generated from the name by the editor when created
     */
    id?: string;
    /**
     * Unique name generated from the label by the editor when created. The user can update this name, and the id will be re-generated to match the new name
     */
    name?: string;
    /**
     * Unique type string for this part
     */
    static readonly type: string;
    /**
     * Apply a series of transformations to a legacy app to make it compatible with the most up-to-date APIs
     * @param app A previously saved app
     */
    static transformLegacy(app: any): void;
    constructor();
    /**
     * Called when the part is added to an output. Whether it is from an editor or a Player
     * @param context The context given by the output. Allowws to access the different output APIs
     */
    onInstall(context: IPartContext): void;
    /**
     * Called when an app starts
     */
    onStart(): void;
    /**
     * Called when an app stops
     */
    onStop(): void;
    /**
     * Called when the part needs to be disposed off. Free up resources
     */
    dispose(): void;
    /**
     * Returns a JSON object representation of the part
     */
    serialize(): {
        [K: string]: any;
    };
    /**
     * Re-hydrate a part with previously saved data
     * @param data JSON object representation of a part
     */
    load(data: any): void;
    /**
     * Reset all values in components to its default value
     */
    reset(): void;
    renderComponents(ctx: CanvasRenderingContext2D): Promise<void>;
    resetTransform(ctx: CanvasRenderingContext2D): void;
    applyTransform(ctx: CanvasRenderingContext2D): void;
}
