Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update d.ts #415

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 110 additions & 2 deletions typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 = {
Expand Down