Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**/.DS_Store
node_modules
deprecated
dist
package-lock.json
app/mixfile.js*
dist/wmk
dist/src
dist/work
dist/cdd
13 changes: 5 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks":
[
{
"label": "build",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher":
[
"$tsc"
],
"type": "npm",
"script": "build",
"group":
{
"kind": "build",
"isDefault": true
}
}
}
]
}
2 changes: 1 addition & 1 deletion app/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
Made available under the Gnu Public License v3.0
*/

let Mixtures = require(__dirname + '/mixfile.js');
let Mixtures = require(__dirname + '/mixtures-electron.js');
new Mixtures.Console(process.argv.slice(0)).run().then();

4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<link href="main.css" rel="stylesheet" type="text/css">
<link href="widgets.css" rel="stylesheet" type="text/css">
<script src="mixfile.js" type="text/javascript"></script>
<script src="mixtures-electron.js" type="text/javascript"></script>
<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline' 'unsafe-eval' serve://dist/">
</head>

<body>
<div id="root" style="background-color: #F8F8F8;"/>
<div id="root" style="background-color: #F8F8F8;"></div>
</body>

<script type="text/javascript">
Expand Down
1,448 changes: 1,448 additions & 0 deletions app/mixtures-electron.js

Large diffs are not rendered by default.

1,197 changes: 1,197 additions & 0 deletions app/mixtures-web.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions app/webdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<link rel="shortcut icon" href="img/icon.ico" type="image/x-icon" />
<link href="main.css" rel="stylesheet" type="text/css">
<link href="widgets.css" rel="stylesheet" type="text/css">
<script src="mixfile.js" type="text/javascript"></script>
<!--<script src="mixfile.js" type="text/javascript"></script>-->
<script src="mixtures-web.js" type="text/javascript"></script>
<!--<meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline' 'unsafe-eval' serve://dist/">-->
</head>

Expand Down Expand Up @@ -44,32 +45,31 @@ <h1>Mixfile Editor - Web Demo</h1>
import molfileToInChI from './inchi-run.js';
Mixtures.InChI.nativeMolfileToInChI = molfileToInChI;

//import {Mixtures, WebMolKit} from './mixfile.js';
let wmk = WebMolKit;
const {dom, DOM} = Mixtures;

wmk.initWebMolKit('res');
Mixtures.initWebMolKit('res');
var widget = new Mixtures.WebWidget();
var mixture = new Mixtures.Mixture(JSON.parse(wmk.dom('#data').text()));
widget.render(wmk.DOM.find('#root'), 700, 600);
var mixture = new Mixtures.Mixture(JSON.parse(DOM.find('#data').getText()));
widget.render(DOM.find('#root'), 700, 600);
widget.setMixture(mixture);

let btnMInChI = wmk.dom('<button class="wmk-button wmk-button-primary">Create MInChI</button>').appendTo(wmk.DOM.find('#buttons'));
btnMInChI.click(() =>
let btnMInChI = dom('<button class="wmk-button wmk-button-primary">Create MInChI</button>').appendTo(DOM.find('#buttons'));
btnMInChI.onClick(() =>
{
if (widget.isBlank())
{
alert('Mixture is empty.');
return;
}
wmk.DOM.find('#minchi').empty();
DOM.find('#minchi').empty();

let mixture = widget.getMixture();
let maker = new Mixtures.ExportMInChI(mixture.mixfile);
maker.fillInChI().then(() =>
{
maker.formulate();
let pre = wmk.dom('<pre></pre>').appendTo(wmk.DOM.find('#minchi')).css({'padding-top': '0.5em'});
pre.text(maker.getResult());
let pre = dom('<pre></pre>').appendTo(DOM.find('#minchi')).css({'padding-top': '0.5em'});
pre.setText(maker.getResult());
pre.append('\n');
pre.append(maker.getSegment().join(''));
});
Expand Down
8 changes: 8 additions & 0 deletions dist/index-electron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './index-web';

export * from '../src/startup';
export * from '../src/cmdline/Console';
export * from '../src/cmdline/RenderHTML';
export * from '../src/cmdline/TableExtract';
export * from '../src/cmdline/TransformMixtures';

35 changes: 35 additions & 0 deletions dist/index-web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export * from '../wmk/util/dom';
export * from '../wmk/util/util';
export * from '../wmk/util/Theme';
export * from '../wmk/util/Vec';
export * from '../wmk/util/XML';

export * from '../src/data/Mixfile';
export * from '../src/data/Mixture';
export * from '../src/data/MixtureCollection';
export * from '../src/data/NormMixture';
export * from '../src/data/Units';

export * from '../src/lookup/ExtractCTABComponent';
export * from '../src/lookup/LookupCompoundDialog';
export * from '../src/lookup/PubChemSearch';

export * from '../src/main/CollectionPanel';
export * from '../src/main/InChI';
export * from '../src/main/MainPanel';
export * from '../src/main/MenuBanner';
export * from '../src/main/MixturePanel';

export * from '../src/mixture/ArrangeMixture';
export * from '../src/mixture/DrawMixture';
export * from '../src/mixture/EditComponent';
export * from '../src/mixture/EditMixture';
export * from '../src/mixture/ExportMInChI';
export * from '../src/mixture/ExportSDFile';
export * from '../src/mixture/ImportSDFile';
export * from '../src/mixture/KeyValueWidget';
export * from '../src/mixture/MetadataWidget';
export * from '../src/mixture/SquarePacking';

export * from '../src/web/EditMixtureWeb';
export * from '../src/web/WebWidget';
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"@typescript-eslint/parser": "^4.7",
"electron-packager": "^8.1.0",
"eslint": "^7.0",
"typescript": "^4.6"
"ts-loader": "^9.3.1",
"typescript": "^4.6",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},
"build": {
"appId": "com.cdd.mixture.MixfileEditor",
Expand All @@ -21,6 +24,10 @@
}
},
"scripts": {
"eslint": "eslint -c ../WebMolKit/src/.eslintrc.js --ignore-pattern src/decl --quiet src/**/*.ts"
"eslint": "eslint -c ../WebMolKit/src/.eslintrc.js --ignore-pattern src/decl --quiet src/**/*.ts",
"build-tsc": "tsc",
"build-web": "webpack --config webpack-web.config.js",
"build-electron": "webpack --config webpack-electron.config.js",
"build": "tsc && webpack --config webpack-web.config.js && webpack --config webpack-electron.config.js"
}
}
34 changes: 0 additions & 34 deletions src/baselib.ts

This file was deleted.

17 changes: 10 additions & 7 deletions src/cmdline/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
Made available under the Gnu Public License v3.0
*/

namespace Mixtures /* BOF */ {
import {XML} from '../../wmk/util/XML';
import {InChI} from '../main/InChI';
import {setOnDesktop} from '../startup';
import {RenderHTML} from './RenderHTML';
import {TableExtract} from './TableExtract';
import {ALL_TRANSFORMMIXTURE_FORMATS, TransformMixtures} from './TransformMixtures';

/*
Console utilities, to be run from NodeJS with command line arguments.
Expand All @@ -32,11 +37,11 @@ export class Console

constructor(args:string[])
{
ON_DESKTOP = true;
setOnDesktop(true);

const {DOMParser, XMLSerializer} = require('xmldom/dom-parser.js');
wmk.XML.customParser = DOMParser;
wmk.XML.customSerial = XMLSerializer;
XML.customParser = DOMParser;
XML.customSerial = XMLSerializer;

for (let n = 0; n < args.length; n++)
{
Expand Down Expand Up @@ -94,6 +99,4 @@ export class Console
}

// if being run in NodeJS context, need to export the class
if (typeof module == 'object') module.exports['Console'] = Console;

/* EOF */ }
//if (typeof module == 'object') module.exports['Console'] = Console;
16 changes: 11 additions & 5 deletions src/cmdline/RenderHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
Made available under the Gnu Public License v3.0
*/

namespace Mixtures /* BOF */ {
import {OutlineMeasurement} from '../../wmk/gfx/ArrangeMeasurement';
import {MetaVector} from '../../wmk/gfx/MetaVector';
import {RenderPolicy} from '../../wmk/gfx/Rendering';
import {escapeHTML} from '../../wmk/util/util';
import {MixtureCollection} from '../data/MixtureCollection';
import {ArrangeMixture} from '../mixture/ArrangeMixture';
import {DrawMixture} from '../mixture/DrawMixture';
import {ExportMInChI, MInChISegment} from '../mixture/ExportMInChI';

/*
Loads a mixture collection and emits it as visualisable HTML.
Expand Down Expand Up @@ -49,8 +56,8 @@ export class RenderHTML

emitln('<body><table>');

let policy = wmk.RenderPolicy.defaultColourOnWhite(15);
let measure = new wmk.OutlineMeasurement(0, 0, policy.data.pointScale);
let policy = RenderPolicy.defaultColourOnWhite(15);
let measure = new OutlineMeasurement(0, 0, policy.data.pointScale);

for (let n = 0; n < mixlist.count; n++)
{
Expand All @@ -62,7 +69,7 @@ export class RenderHTML
let layout = new ArrangeMixture(mixture, measure, policy);
layout.arrange();

let gfx = new wmk.MetaVector();
let gfx = new MetaVector();
let draw = new DrawMixture(layout, gfx);
draw.draw();
gfx.normalise();
Expand Down Expand Up @@ -102,4 +109,3 @@ export class RenderHTML
// ------------ private methods ------------
}

/* EOF */ }
Loading