Skip to content

Commit

Permalink
#196 create ketcher-core package (#268)
Browse files Browse the repository at this point in the history
* add ketcher-core package folder

* configure re-export inside ketcher-core package

* update signature of RemoteStructServiceProvider

* update dependencies in ketcher-standalone

* update Editor props interface

* make _editor property writable

* mark structservice fields as readonly

* reorder dependencies in package.json

* update tsconfig.json
  • Loading branch information
AndreiMazol authored Jan 26, 2021
1 parent b6ddb9b commit cacc433
Show file tree
Hide file tree
Showing 34 changed files with 1,240 additions and 604 deletions.
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"eject": "react-scripts eject"
},
"dependencies": {
"ketcher-react": "^2.1.0-beta",
"ketcher-core": "^1.0.0",
"ketcher-react": "^2.1.0",
"ketcher-standalone": "^1.0.0",
"miew": "^0.9.0",
"react": "^16.13.1",
Expand Down
13 changes: 8 additions & 5 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react'
//@ts-ignore
// @ts-ignore
import Miew from 'miew'
import 'miew/dist/Miew.min.css'
//@ts-ignore
import { Editor, RemoteStructServiceProvider } from 'ketcher-react'
// @ts-ignore
import { Editor } from 'ketcher-react'
// @ts-ignore
import { RemoteStructServiceProvider } from 'ketcher-core'
import 'ketcher-react/dist/index.css'
;(global as any).Miew = Miew

let structServiceProvider: any = new RemoteStructServiceProvider()
let structServiceProvider: any = new RemoteStructServiceProvider(
process.env.REACT_APP_API_PATH!
)
if (process.env.MODE === 'standalone') {
const { StandaloneStructServiceProvider } = require('ketcher-standalone')
structServiceProvider = new StandaloneStructServiceProvider()
Expand All @@ -18,7 +22,6 @@ const App = () => {
<div>
<Editor
staticResourcesUrl={process.env.PUBLIC_URL}
apiPath={process.env.REACT_APP_API_PATH}
structServiceProvider={structServiceProvider}
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/ketcher-core/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "../../.babelrc" }
Empty file.
1 change: 1 addition & 0 deletions packages/ketcher-core/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = "https://registry.npmjs.com/"
1 change: 1 addition & 0 deletions packages/ketcher-core/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
60 changes: 60 additions & 0 deletions packages/ketcher-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[![npm version](https://img.shields.io/npm/v/ketcher-core)](https://www.npmjs.com/package/ketcher-core)
[![Downloads](https://img.shields.io/npm/dm/ketcher-core)](https://www.npmjs.com/package/ketcher-core)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Copyright (c) 2020 [EPAM Systems, Inc.](https://www.epam.com/)

Ketcher is an open-source web-based chemical structure editor incorporating high performance, good portability, light weight, and ability to easily integrate into a custom web-application. Ketcher is designed for chemists, laboratory scientists and technicians who draw structures and reactions.

For more details please look at the following [link](https://github.com/epam/ketcher/blob/master/README.md).

## Installation

Ketcher library is available as an [NPM](https://www.npmjs.com/) package. Install it either with NPM:

```sh
npm install --save ketcher-core
```

or [Yarn](https://yarnpkg.com/):

```sh
yarn add ketcher-core
```

## Usage

### Indigo Service

Ketcher uses Indigo Service for server operations.
You may pass it as a property while Editor component is used or just add api_path query parameter:

```sh
<Editor staticResourcesUrl={process.env.PUBLIC_URL} apiPath={link to Indigo service} />
or
http://localhost:3000/?api_path={link to Indigo service}
```

You can find the instruction for service installation
[here](http://lifescience.opensource.epam.com/indigo/service/index.html).

### 3D Viewer

Ketcher uses Miew for viewing and editing data in 3D.
For use of this functionality you should add the link to miew by your own:

```sh
...
import Miew from 'miew'
import 'miew/dist/Miew.min.css'
...
;(global as any).Miew = Miew
...
```

You can find the latest version of viewer [here](https://github.com/epam/miew).
The last checked version - [0.9.0](https://github.com/epam/miew/releases/tag/v0.9.0).

## License

Please read [LICENSE](./../../LICENSE) and [NOTICE](./../../NOTICE) for details.
91 changes: 91 additions & 0 deletions packages/ketcher-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "ketcher-core",
"version": "1.0.0",
"description": "Web-based molecule sketcher",
"license": "Apache-2.0",
"homepage": "http://lifescience.opensource.epam.com/ketcher",
"author": {
"name": "EPAM Life Sciences",
"url": "http://lifescience.opensource.epam.com"
},
"repository": {
"type": "git",
"url": "https://github.com/epam/ketcher.git",
"directory": "packages/ketcher-core"
},
"keywords": [
"molecule",
"sketcher",
"chemistry"
],
"bugs": {
"url": "https://github.com/epam/ketcher/issues"
},
"main": "dist/index.js",
"module": "dist/index.modern.js",
"source": "src/index.ts",
"engines": {
"node": ">=10"
},
"scripts": {
"build": "cross-env NODE_ENV=production rollup -c -m true --silent",
"start": "cross-env NODE_ENV=development rollup -c -m true -w",
"test": "run-s test:unit test:lint prettier stylelint test:build",
"test:build": "run-s build",
"test:lint": "eslint src --ext .ts,.tsx,.js,.jsx",
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"prettier": "prettier --check \"src/**/*.{js,jsx,json,ts,tsx}\"",
"prettier:write": "prettier --write \"src/**/*.{js,jsx,json,ts,tsx}\"",
"stylelint": "stylelint \"src/**/*.{css,less,scss}\" --formatter verbose",
"stylelint:fix": "stylelint \"src/**/*.{css,less,scss}\" --formatter verbose --fix"
},
"dependencies": {
"@babel/runtime": "^7.12.5"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-strip": "^2.0.0",
"@rollup/plugin-typescript": "^8.1.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^25.1.4",
"@types/node": "^12.12.38",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.0.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-plugin-testing-library": "^3.9.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"react-scripts": "^3.4.1",
"rollup": "^2.33.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-visualizer": "^4.2.0",
"typescript": "^4.1.3"
},
"files": [
"dist"
]
}
76 changes: 76 additions & 0 deletions packages/ketcher-core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import babel from '@rollup/plugin-babel'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2'
import json from '@rollup/plugin-json'
import del from 'rollup-plugin-delete'
import cleanup from 'rollup-plugin-cleanup'
import strip from '@rollup/plugin-strip'
import pkg from './package.json'

const mode = {
PRODUCTION: 'production',
DEVELOPMENT: 'development'
}

const extensions = ['.js', '.ts']
const isProduction = process.env.NODE_ENV === mode.PRODUCTION

const config = {
input: pkg.source,
output: [
{
file: pkg.main,
exports: 'named',
format: 'cjs'
},
{
file: pkg.module,
exports: 'named',
format: 'es'
}
],
external: [
'url',
'remark-parse',
'unified',
'asap',
'object-assign',
'unist-util-visit',
'unist-util-visit-parents',
'xtend'
],
plugins: [
del({
targets: 'dist/*',
runOnce: true
}),
peerDepsExternal({ includeDependencies: true }),
resolve({ extensions, preferBuiltins: false }),
commonjs(),
typescript(),
replace(
{
'process.env.NODE_ENV': JSON.stringify(
isProduction ? mode.PRODUCTION : mode.DEVELOPMENT
)
},
{
include: 'src/**/*.{js,ts}'
}
),

json(),
babel({
extensions,
babelHelpers: 'runtime',
include: ['src/**/*']
}),
cleanup({ extensions, comments: 'none' }),
...(isProduction ? [strip()] : [])
]
}

export default config
60 changes: 60 additions & 0 deletions packages/ketcher-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
RemoteStructService,
RemoteStructServiceProvider,
ChemicalMimeType
} from './infrastructure/services'

import type {
StructService,
StructServiceOptions,
AromatizeData,
AromatizeResult,
AutomapData,
AutomapResult,
CalculateCipData,
CalculateCipResult,
CalculateData,
CalculateResult,
CheckData,
CheckResult,
CleanData,
CleanResult,
ConvertData,
ConvertResult,
DearomatizeData,
DearomatizeResult,
InfoResult,
LayoutData,
LayoutResult,
RecognizeResult,
ServiceMode,
StructServiceProvider
} from './infrastructure/services'

export { RemoteStructService, RemoteStructServiceProvider, ChemicalMimeType }
export type {
StructService,
StructServiceOptions,
AromatizeData,
AromatizeResult,
AutomapData,
AutomapResult,
CalculateCipData,
CalculateCipResult,
CalculateData,
CalculateResult,
CheckData,
CheckResult,
CleanData,
CleanResult,
ConvertData,
ConvertResult,
DearomatizeData,
DearomatizeResult,
InfoResult,
LayoutData,
LayoutResult,
RecognizeResult,
ServiceMode,
StructServiceProvider
}
59 changes: 59 additions & 0 deletions packages/ketcher-core/src/infrastructure/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
RemoteStructService,
RemoteStructServiceProvider,
ChemicalMimeType
} from './struct'
import type {
StructService,
StructServiceOptions,
AromatizeData,
AromatizeResult,
AutomapData,
AutomapResult,
CalculateCipData,
CalculateCipResult,
CalculateData,
CalculateResult,
CheckData,
CheckResult,
CleanData,
CleanResult,
ConvertData,
ConvertResult,
DearomatizeData,
DearomatizeResult,
InfoResult,
LayoutData,
LayoutResult,
RecognizeResult,
ServiceMode,
StructServiceProvider
} from './struct'

export { RemoteStructService, RemoteStructServiceProvider, ChemicalMimeType }
export type {
StructService,
StructServiceOptions,
AromatizeData,
AromatizeResult,
AutomapData,
AutomapResult,
CalculateCipData,
CalculateCipResult,
CalculateData,
CalculateResult,
CheckData,
CheckResult,
CleanData,
CleanResult,
ConvertData,
ConvertResult,
DearomatizeData,
DearomatizeResult,
InfoResult,
LayoutData,
LayoutResult,
RecognizeResult,
ServiceMode,
StructServiceProvider
}
Loading

0 comments on commit cacc433

Please sign in to comment.