jsii-rosetta
Version:
[](https://cdk.dev) [.
*
* @default No assemblies.
*/
readonly assemblies?: spec.Assembly[];
/**
* Whether to include compiler diagnostics in the compilation results.
*
* @default false
*/
readonly includeCompilerDiagnostics?: boolean;
/**
* Allow reading dirty translations from cache
*
* @default false
*/
readonly allowDirtyTranslations?: boolean;
}
/**
* Entry point for consumers that want to translate code on-the-fly
*
* If you want to generate and translate code on-the-fly, in ways that cannot
* be achieved by the rosetta CLI, use this class.
*/
export declare class RosettaTranslator {
/**
* Tablet with fresh translations
*
* All new translations (not read from cache) are added to this tablet.
*/
readonly tablet: LanguageTablet;
readonly cache: LanguageTablet;
private readonly fingerprinter;
private readonly includeCompilerDiagnostics;
private readonly allowDirtyTranslations;
constructor(options?: RosettaTranslatorOptions);
/**
* @deprecated use `addToCache` instead
*/
loadCache(fileName: string): Promise<void>;
addToCache(filename: string): Promise<void>;
addTabletsToCache(...tablets: LanguageTablet[]): void;
hasCache(): boolean;
/**
* For all the given snippets, try to read translations from the cache
*
* Will remove the cached snippets from the input array.
*/
readFromCache(snippets: TypeScriptSnippet[], addToTablet?: boolean, compiledOnly?: boolean): ReadFromCacheResults;
translateAll(snippets: TypeScriptSnippet[], addToTablet?: boolean): Promise<TranslateAllResult>;
translateAll(snippets: TypeScriptSnippet[], options?: TranslateAllOptions): Promise<TranslateAllResult>;
}
export type CacheHit = {
readonly type: 'miss';
} | {
readonly type: 'hit';
readonly snippet: TranslatedSnippet;
readonly infused: boolean;
} | {
readonly type: 'dirty';
readonly translation: TranslatedSnippet;
readonly dirtySource: boolean;
readonly dirtyTranslator: boolean;
readonly dirtyTypes: boolean;
readonly dirtyDidntCompile: boolean;
};
export interface ReadFromCacheResults {
/**
* Successful translations
*/
readonly translations: TranslatedSnippet[];
/**
* Successful but dirty hits
*/
readonly remaining: TypeScriptSnippet[];
/**
* How many successfully hit translations were infused
*/
readonly infusedCount: number;
readonly dirtyCount: number;
readonly dirtySourceCount: number;
readonly dirtyTranslatorCount: number;
readonly dirtyTypesCount: number;
readonly dirtyDidntCompile: number;
}
export interface TranslateAllOptions {
/**
* @default - Create a temporary directory with all necessary packages
*/
readonly compilationDirectory?: string;
/**
* @default true
*/
readonly addToTablet?: boolean;
/**
* @default true
*/
readonly cleanup?: boolean;
}
//# sourceMappingURL=rosetta-translator.d.ts.map