diff --git a/typescript/index.d.ts b/typescript/index.d.ts index 0c3a4c45..6784dfe5 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -8,7 +8,7 @@ type JSONString = string; * Represents a molecule object generated by RDKit.js * * @remarks - * JSMol's are created using the {@link RDKitModule.get_mol | RDKitModule.get_mol()} methods. + * JSMols are created using the {@link RDKitModule.get_mol | RDKitModule.get_mol()} methods. */ export interface JSMol { @@ -211,7 +211,9 @@ export interface JSMol { options: JSONString ): string; - /** Returns true if the molecule's structure is valid */ + /** + * @deprecated Please check the get_mol return value for non-nullness instead + */ is_valid(): boolean; /** Check is the molecule has any 2D coordinates generated */ @@ -369,6 +371,86 @@ export interface JSMol { } +/** + * Represents a reaction object generated by RDKit.js + * + * @remarks + * JSReactions are created using the {@link RDKitModule.get_rxn | RDKitModule.get_rxn()} methods. + */ +export interface JSReaction { + + /** Returns an SVG of the reaction */ + get_svg(): string; + + /** + * Returns an SVG of the reaction + * + * @param width Width in pixels + * @param height Height in pixels + */ + get_svg(width: number, height: number): string; + + /** + * Returns an SVG of the reaction, with atoms highlighted + * + * @param details A stringified JSON object containing any of the following options https://www.rdkitjs.com/#drawing-molecules-all-options + */ + get_svg_with_highlights(details: string): string; + + /** + * Draw the reaction to an HTML5 canvas + * + * @param canvas canvas ID + * @param width width in pixels + * @param height height in pixels + */ + draw_to_canvas( + canvas: HTMLCanvasElement, + width: number, + height: number + ): void; + + /** + * Draw the reaction to an HTML5 canvas with an offset + * + * @param canvas canvas ID + * @param offsetx offset X in pixels + * @param offsety offset Y in pixels + * @param width width in pixels + * @param height height in pixels + */ + draw_to_canvas_with_offset( + canvas: HTMLCanvasElement, + offsetx: number, + offsety: number, + width: number, + height: number + ): void; + + /** + * Draw the reaction to an HTML5 canvas, with atom highlights + * + * @param canvas canvas ID + * @param details A stringified JSON object containing any of the following options https://www.rdkitjs.com/#drawing-molecules-all-options + */ + draw_to_canvas_with_highlights( + canvas: HTMLCanvasElement, + details: string + ): void; + + /** Delete C++ reaction objects manually from memory + * + * See {@link https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html#memory-management | Emscripten docs} for more details + */ + delete(): void; + + /** + * @deprecated Please check the get_rxn return value for non-nullness instead + */ + is_valid(): boolean +} + + /** * An object containing a collection of structures. Used for efficient substructure searching. * @@ -456,6 +538,12 @@ export interface SubstructLibrary { count_matches(q: JSMol, useChirality: boolean, numThreads: number): number; } +export interface JSLog { + clear_buffer(): void; + get_buffer(): string; + delete(): void; +} + // constructor interfaces /** Returns a new SubstructLibrary instance */ @@ -531,6 +619,26 @@ export interface RDKitModule { * @param value */ use_legacy_stereo_perception(value: boolean): void; + + /** + * Set whether to allow non-tetrahedral chirality + * + * @param value + */ + allow_non_tetrahedral_chirality(value: boolean): boolean; + + /** + * Create a reaction from a variety of input strings. + * This will return null if the input is invalid. + * @param input + * @param details_json + */ + get_rxn(input: string, details_json?: string): JSReaction | null + + enable_logging(): void; + disable_logging(): void; + set_log_capture(log_name: string): JSLog; + set_log_tee(log_name: string): JSLog; } type RDKitLoaderOptions = {