import { Filesystem } from "../file_system"; /** * A codec represents a specific file format that can be imported into and exported from Blockbench. The codec handles the compilation and parsing, as well as the loading and exporting logic * @module */ export interface LoadOptions { import_to_current_project?: boolean; externalDataLoader?: (path: string) => any; resolve_parent?: boolean; [key: string]: unknown; } export interface CodecOptions { name?: string; load?(model: any, file: Filesystem.FileResult, args?: LoadOptions): void; compile?(options?: any): string | ArrayBuffer | any; parse?(data: any, path: string, args?: LoadOptions): void; export?(): void; /** * Generate a file name to suggest when exporting */ fileName?(): string; startPath?(): string; write?(content: any, path: string): void; overwrite?(content: any, path: string, callback: (path: any) => void): void; afterDownload?(path: any): void; afterSave?(path: any): void; exportCollection?(collection: Collection): void; writeCollection?(collection: Collection): void; dispatchEvent?(event_name: string, data: any): void; extension?: string; /** * Whether to remember the models exported using this codec */ remember?: boolean; /** * Whether the codec can be used to export a part of the model via a collection */ support_partial_export?: boolean; support_offset?: boolean; load_filter?: { extensions: string[] | (() => string[]); type: 'json' | 'text' | 'image'; condition?: ConditionResolvable; }; /** * List of export option inputs, based on the Dialog form API */ export_options?: { [key: string]: FormElementOptions; }; /** * Default action that is used to export to the codec */ export_action?: Action; format?: ModelFormat; plugin?: string; } /** * A codec represents a specific file format that can be imported into and exported from Blockbench. The codec handles the compilation and parsing, as well as the loading and exporting logic */ export declare class Codec extends EventSystem { /** * The display name of the codec */ name: string; /** * The default file extension that the codec uses */ extension: string; /** * Whether to remember files that use this codec in the recent models list */ remember: boolean; /** * Whether the codec can be used to export a part of the model via a collection */ support_partial_export: boolean; support_offset: boolean; /** * If available, the action that is used to export files using this codec */ export_action?: Action; /** * List of export option inputs */ export_options: Record; /** * Additional properties */ [key: string]: any; /** * Default/main format of this codec */ format?: ModelFormat; plugin?: string; /** * Creates a new codec * @param id Codec ID * @param data Codec options */ constructor(id: string, data?: CodecOptions); /** * Return the stored export option values of the current project */ getExportOptions(): { [key: string]: any; }; /** * Load a file into the program * @param model * @param file * @param args Load options */ load(model: any, file?: Filesystem.FileResult, args?: LoadOptions): boolean | void; /** * Takes the content of a file, and loads the model into the current Blockbench project * @param data File content * @param path File path */ parse?(data: any, path: string, args?: LoadOptions): void; /** * Compiles the file content * @param options */ compile(options?: { [key: string]: any; }): any; /** * Prompt the user to enter their preferred export settings into the dialog */ promptExportOptions(): Promise<{ [key: string]: any; } | null>; /** * Opens the file browser to export a file of this type */ export(options?: Record): Promise; patchCollectionExport(collection: Collection, callback: any): Promise; exportCollection(collection: Collection): Promise; writeCollection(collection: Collection): Promise; /** * Generate a file name to suggest when exporting */ fileName(): string; /** * Generates the suggested file path. This is the path that the explorer opens in when exporting this type */ startPath(): string; /** * Write the content of this file to the selected location. The default method can be overwritten to achieve custom behavior * @param content File content, as generated by compile() * @param path The file export path */ write(content: any, path: string): void; overwrite?(content: any, path: string, callback: (path: string) => void): void; afterDownload(path: string): void; afterSave(path: string): void; delete(): void; /** * Get a list of all possible extensions of all codecs */ static getAllExtensions(): string[]; } export declare const Codecs: Record; declare const global: { Codec: typeof import("./codec").Codec; Codecs: Record; }; declare global { const Codec: typeof global.Codec; type Codec = import('./codec').Codec; const Codecs: Record; } export {};