| import { ISoftwareCredit, Licenses } from "@/Plugins/PluginInterfaces"; |
| import { waitForCondition } from "./Utils/MiscUtils"; |
|
|
| interface IDynamicImport { |
| credit: ISoftwareCredit; |
| module: Promise<any>; |
| } |
|
|
| const modulesAlreadyAddedToHeader: { [key: string]: Promise<any> } = {}; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function addToHeader( |
| id: string, |
| jsUrl: string, |
| getModule: () => any, |
| cssUrl?: string |
| ): Promise<any> { |
| if (modulesAlreadyAddedToHeader[id] !== undefined) { |
| |
| |
| |
| return Promise.resolve(modulesAlreadyAddedToHeader[id]); |
| } |
|
|
| |
| if (cssUrl) { |
| const css = document.createElement("link"); |
| css.rel = "stylesheet"; |
| css.type = "text/css"; |
| css.href = cssUrl; |
| document.head.appendChild(css); |
| } |
|
|
| modulesAlreadyAddedToHeader[id] = new Promise((resolve) => { |
| const script = document.createElement("script"); |
| script.src = jsUrl; |
| script.onload = async () => { |
| await waitForCondition(() => { |
| return getModule() !== undefined; |
| }, 100); |
|
|
| resolve(getModule()); |
| }; |
| document.head.appendChild(script); |
| }); |
|
|
| return modulesAlreadyAddedToHeader[id]; |
| } |
|
|
| export const dynamicImports = { |
| driverJs: { |
| credit: { |
| name: "driver.js", |
| url: "https://github.com/kamranahmedse/driver.js", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| |
| return import( |
| |
| |
| "driver.js" |
| ).then((mod) => { |
| return mod.driver; |
| }); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| }, |
| } as IDynamicImport, |
| jsZip: { |
| credit: { |
| name: "JSZip", |
| url: "https://stuk.github.io/jszip/", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "jszip" |
| ).then((mod) => { |
| return mod.default; |
| }); |
| }, |
| } as IDynamicImport, |
| kekule: { |
| credit: { |
| name: "Kekule.js", |
| url: "https://partridgejiang.github.io/Kekule.js/", |
| license: Licenses.MIT, |
| citations: [ |
| { |
| title: "Kekule.js: An Open Source JavaScript Chemoinformatics Toolkit", |
| authors: ["Jiang, Chen", "Jin, Xi"], |
| journal: "J. Chem. Inf. Model.", |
| year: 2016, |
| volume: 56, |
| issue: 6, |
| pages: "1132-1138", |
| }, |
| ], |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return addToHeader( |
| "kekule", |
| "js/kekule/kekule.min.js", |
| () => (window as any).Kekule, |
| "js/kekule/kekule.css" |
| ); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| }, |
| } as IDynamicImport, |
| indigo: { |
| credit: { |
| name: "Indigo", |
| url: "https://lifescience.opensource.epam.com/indigo/index.html", |
| license: Licenses.APACHE2, |
| citations: [ |
| { |
| title: "Indigo: universal cheminformatics API", |
| authors: [ |
| "Pavlov, D", |
| "Rybalkin, M", |
| "Karulin, B", |
| "Kozhevnikov, M", |
| "Savelyev, A", |
| "Churinov, A", |
| ], |
| journal: "J. Cheminform.", |
| year: 2011, |
| volume: 3, |
| issue: "Suppl 1", |
| pages: "P4", |
| }, |
| { |
| title: "Kekule.js: An Open Source JavaScript Chemoinformatics Toolkit", |
| authors: ["Jiang, Chen", "Jin, Xi"], |
| journal: "J. Chem. Inf. Model.", |
| year: 2016, |
| volume: 56, |
| issue: 6, |
| pages: "1132-1138", |
| }, |
| ], |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return addToHeader("indigo", "js/indigo/indigo.js", () => { |
| |
|
|
| return (window as any).IndigoModule; |
| }) |
| .then(() => { |
| return addToHeader( |
| "indigoadapter", |
| "js/indigo/indigoAdapter.js", |
| () => { |
| |
|
|
| return (window as any).CreateIndigo; |
| } |
| ); |
| }) |
| .then(() => { |
| return (window as any).CreateIndigo(); |
| }) |
| .then((Indigo: any) => { |
| return new Promise((resolve) => { |
| Indigo.Module.onRuntimeInitialized = () => { |
| resolve(Indigo); |
| }; |
| }); |
| }); |
| }, |
| } as IDynamicImport, |
| fileSaver: { |
| credit: { |
| name: "FileSaver.js", |
| url: "https://github.com/eligrey/FileSaver.js/", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "file-saver" |
| ).then((mod) => { |
| return mod.default; |
| }); |
| }, |
| } as IDynamicImport, |
| chartJs: { |
| credit: { |
| name: "Chart.js", |
| url: "https://www.chartjs.org/", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "chart.js/auto" |
| ); |
| }, |
| } as IDynamicImport, |
| mol3d: { |
| credit: { |
| name: "3Dmol.js", |
| url: "https://3dmol.csb.pitt.edu/", |
| license: Licenses.BSD3, |
| citations: [ |
| { |
| title: "3Dmol.js: molecular visualization with WebGL", |
| authors: ["Rego, Nicholas", "Koes, David"], |
| journal: "Bioinformatics", |
| year: 2015, |
| volume: 31, |
| issue: 8, |
| pages: "1322-1324", |
| }, |
| ], |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| |
| |
| "@/libs/3dmol-2.5.0/3Dmol" |
| |
| |
| |
| ).then(($3Dmol) => { |
| return $3Dmol; |
| }); |
| }, |
| } as IDynamicImport, |
|
|
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| reduce: { |
| credit: { |
| name: "Reduce", |
| url: "https://github.com/rlabduke/reduce", |
| license: Licenses.CUSTOM, |
| licenseUrl: |
| "https://github.com/rlabduke/reduce/blob/master/LICENSE.txt", |
| citations: [ |
| { |
| title: "Asparagine and glutamine: using hydrogen atom contacts in the choice of side-chain amide orientation", |
| authors: ["Word, J. Michael", "Lovell, Simon C."], |
| journal: "J. Mol. Biol.", |
| year: 1999, |
| volume: 285, |
| issue: 4, |
| pages: "1735-1747", |
| }, |
| ], |
| }, |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| } as IDynamicImport, |
| usalign: { |
| credit: { |
| name: "US-align", |
| url: "https://github.com/pylelab/USalign", |
| license: Licenses.CUSTOM, |
| licenseUrl: |
| "https://github.com/pylelab/USalign/blob/master/LICENSE", |
| citations: [ |
| { |
| title: "US-align: universal structure alignments of proteins, nucleic acids, and macromolecular complexes", |
| authors: [ |
| "Zhang, Chengxin", |
| "Shine, Morgan", |
| "Pyle, Anna Marie", |
| "Zhang, Yang", |
| ], |
| journal: "Nature Methods", |
| year: 2022, |
| volume: 19, |
| issue: 9, |
| pages: "1109-1115", |
| }, |
| { |
| title: "A unified approach to sequential and non-sequential structure alignment of proteins, RNAs, and DNAs", |
| authors: ["Zhang, Chengxin", "Pyle, Anna Marie"], |
| journal: "iScience", |
| year: 2022, |
| volume: 25, |
| issue: 10, |
| pages: "105218", |
| }, |
| ], |
| }, |
| }, |
| webina: { |
| credit: { |
| name: "Webina", |
| url: "https://durrantlab.pitt.edu/webina-download/", |
| license: Licenses.APACHE2, |
| citations: [ |
| { |
| title: "Webina: an open-source library and web app that runs AutoDock Vina entirely in the web browser", |
| authors: ["Kochnev, Yuri", "Hellemann, Erich"], |
| journal: "Bioinformatics", |
| year: 2020, |
| volume: 36, |
| issue: 16, |
| pages: "4513-4515", |
| }, |
| ], |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| |
| |
| "../../public/js/webina/vina.js" |
| ).then((mod) => { |
| return mod.default; |
| }); |
| }, |
| } as IDynamicImport, |
|
|
| hotkeys: { |
| credit: { |
| name: "HotKeys.js", |
| url: "https://github.com/jaywcjlove/hotkeys", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "hotkeys-js" |
| ).then((hotkeys) => { |
| return hotkeys.default; |
| }); |
| }, |
| } as IDynamicImport, |
|
|
| detectOs: { |
| credit: { |
| name: "Detect OS", |
| url: "https://github.com/jankapunkt/js-detect-os", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| |
| |
| "detect-os" |
| ).then((detectOs) => { |
| return detectOs.default; |
| }); |
| }, |
| } as IDynamicImport, |
|
|
| memfs: { |
| credit: { |
| name: "memfs", |
| url: "https://github.com/streamich/memfs", |
| license: Licenses.PUBLICDOMAIN, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "memfs" |
| ).then((memfs) => { |
| return memfs; |
| }); |
| }, |
| }, |
| browserfs: { |
| credit: { |
| name: "browserfs", |
| url: "https://github.com/jvilk/BrowserFS", |
| license: Licenses.MIT, |
| }, |
|
|
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "browserfs" |
| ).then((browserfs) => { |
| return browserfs; |
| }); |
| }, |
| }, |
| obabelwasm: { |
| |
| credit: { |
| name: "Open Babel", |
| url: "https://openbabel.org/wiki/Main_Page", |
| license: Licenses.GPL2, |
| citations: [ |
| { |
| title: "Open Babel: An open chemical toolbox", |
| authors: ["O'Boyle, Noel M", "Banck, Michael"], |
| journal: "J. Cheminformatics", |
| year: 2011, |
| volume: 3, |
| issue: 1, |
| pages: "1-14", |
| }, |
| ], |
| }, |
| }, |
| axios: { |
| credit: { |
| name: "axios", |
| url: "https://github.com/axios/axios", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "axios" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| rdkitjs: { |
| |
| credit: { |
| name: "rdkitjs", |
| url: "https://github.com/rdkit/rdkit-js", |
| license: Licenses.BSD3, |
| |
| |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return addToHeader( |
| "rdkitjs", |
| "js/rdkitjs/RDKit_minimal.js", |
| () => (window as any).initRDKitModule |
| ) |
| .then(() => { |
| return (window as any).initRDKitModule(); |
| }) |
| .then((instance: any) => { |
| return instance; |
| }); |
| }, |
| }, |
| exceljs: { |
| credit: { |
| name: "ExcelJS", |
| url: "https://github.com/exceljs/exceljs", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "exceljs" |
| ).then((exceljs) => { |
| return exceljs; |
| }); |
| }, |
| }, |
|
|
| bootstrapModal: { |
| credit: { |
| name: "Bootstrap", |
| url: "https://getbootstrap.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "bootstrap/js/dist/modal" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
|
|
| bootstrapTooltip: { |
| credit: { |
| name: "Bootstrap", |
| url: "https://getbootstrap.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "bootstrap/js/dist/tooltip" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
|
|
| bootstrapToast: { |
| credit: { |
| name: "Bootstrap", |
| url: "https://getbootstrap.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "bootstrap/js/dist/toast" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
|
|
| bootstrapCollapse: { |
| credit: { |
| name: "Bootstrap", |
| url: "https://getbootstrap.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "bootstrap/js/dist/collapse" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| bootstrapDropdown: { |
| credit: { |
| name: "Bootstrap", |
| url: "https://getbootstrap.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "bootstrap/js/dist/dropdown" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| fpocketweb: { |
| |
| credit: { |
| name: "fpocketweb", |
| url: "https://git.durrantlab.pitt.edu/jdurrant/fpocketweb", |
| license: Licenses.APACHE2, |
| citations: [ |
| { |
| title: "FPocketWeb: protein pocket hunting in a web browser", |
| authors: ["Kochnev, Yuri", "Durrant, Jacob D"], |
| journal: "J. Cheminformatics", |
| year: 2022, |
| volume: 14, |
| issue: 1, |
| pages: "58", |
| }, |
| ], |
| }, |
| }, |
|
|
| dexie: { |
| credit: { |
| name: "dexie", |
| url: "https://github.com/dexie/Dexie.js", |
| license: Licenses.APACHE2, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "dexie" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| dompurify: { |
| credit: { |
| name: "DOMPurify", |
| url: "https://github.com/cure53/DOMPurify", |
| license: Licenses.APACHE2, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "dompurify" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| clipboardJs: { |
| credit: { |
| name: "clipboard.js", |
| url: "https://clipboardjs.com/", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "clipboard" |
| ).then((mod: any) => { |
| return mod.default; |
| }); |
| }, |
| }, |
| qrcode: { |
| credit: { |
| name: "node-qrcode", |
| url: "https://github.com/soldair/node-qrcode", |
| license: Licenses.MIT, |
| }, |
| |
| |
| |
| |
| |
| get module(): Promise<any> { |
| return import( |
| |
| |
| "qrcode" |
| ).then((mod: any) => { |
| return mod; |
| }); |
| }, |
| }, |
| }; |
|
|