Skip to content

Commit

Permalink
Merge pull request #22 from technote-space/release/next-v0.1.9
Browse files Browse the repository at this point in the history
release: v0.2.0
  • Loading branch information
technote-space authored Jun 13, 2020
2 parents 655936a + 3c7fb7a commit ae46901
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 63 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/ga-framework",
"version": "0.1.9",
"version": "0.2.0",
"description": "GA Framework",
"author": {
"name": "Technote",
Expand Down Expand Up @@ -31,10 +31,10 @@
],
"dependencies": {
"@egjs/hammerjs": "^2.0.17",
"@material-ui/core": "^4.10.1",
"@mui-treasury/layout": "^4.2.3",
"@material-ui/core": "^4.10.2",
"@mui-treasury/layout": "^4.4.0",
"@technote-space/genetic-algorithms-js": "^0.5.2",
"@technote-space/worker-controller": "^0.3.2",
"@technote-space/worker-controller": "^0.4.1",
"clsx": "^1.1.1",
"keycharm": "^0.3.1",
"moment": "^2.26.0",
Expand Down Expand Up @@ -69,7 +69,7 @@
"eslint-plugin-react-hooks": "^4.0.4",
"html-webpack-plugin": "^4.3.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.9",
"lint-staged": "^10.2.10",
"typescript": "^3.9.5",
"webpack": "^4.43.0"
},
Expand Down
24 changes: 13 additions & 11 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ const App: FC<{
const classes = useStyles({theme});

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const worker = new Controller((result: any | StatusResult) => {
if ('status' in result) {
dispatch({type: 'UPDATE_STATUS', result});
} else if (options.controllerListener) {
options.controllerListener(dispatch, result);
}
}, {
context: getProcessContext(options, store),
});
dispatch({type: 'WORKER', worker});
(async(): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const worker = new Controller((result: any | StatusResult) => {
if ('status' in result) {
dispatch({type: 'UPDATE_STATUS', result});
} else if (options.controllerListener) {
options.controllerListener(dispatch, result);
}
}, {
context: await getProcessContext(options, store),
});
dispatch({type: 'WORKER', worker});
})().then();
}, []);

return useMemo(() => (
Expand Down
4 changes: 2 additions & 2 deletions src/app/common.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AppOptions} from '../types';

// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
export const getProcessContext = (options: AppOptions, store: any): ({ [key: string]: any }) | undefined => ({
data: options?.getWorkerContext ? options?.getWorkerContext(store) : undefined,
export const getProcessContext = async(options: AppOptions, store: any): Promise<({ [key: string]: any }) | undefined> => ({
data: options?.getWorkerContext ? await options?.getWorkerContext(store) : undefined,
});
5 changes: 5 additions & 0 deletions src/app/logic/Algorithm/GeneticAlgorithmBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ import {AlgorithmBase} from '@technote-space/genetic-algorithms-js';
import {IGeneticAlgorithm} from '.';

export abstract class GeneticAlgorithmBase<ObjectType> extends AlgorithmBase implements IGeneticAlgorithm<ObjectType> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-unused-vars
public async init(context: any): Promise<void> {
//
}

public abstract async getObject(): Promise<ObjectType>;
}
3 changes: 3 additions & 0 deletions src/app/logic/Algorithm/IGeneticAlgorithm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {IAlgorithm} from '@technote-space/genetic-algorithms-js';

export interface IGeneticAlgorithm<ObjectType> extends IAlgorithm {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
init(context: any): Promise<void>;

getObject(): Promise<ObjectType>;
}
5 changes: 5 additions & 0 deletions src/app/logic/Process/Process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ global['Process'] = class Process extends ProcessBase<any> {
this.algorithm = new global[context['className'] ?? 'GeneticAlgorithm'](callback, context['data'] ?? undefined);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async init(context: any): Promise<void> {
await this.algorithm.init(context);
}

public get isFinished(): boolean {
return this.algorithm.hasReached;
}
Expand Down
44 changes: 29 additions & 15 deletions src/app/templates/NavContentEx.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {FC, useMemo} from 'react';
import React, {FC, useMemo, useState, useEffect} from 'react';
import {makeStyles, createStyles, Theme} from '@material-ui/core/styles';
import {grey, orange} from '@material-ui/core/colors';
import {
Expand Down Expand Up @@ -50,6 +50,7 @@ const NavContentEx: FC<{
const {dispatch} = useDispatchContext();
const classes = useStyles();
const {setOpen} = useSidebar('primarySidebar');
const [controller, setController] = useState<JSX.Element | null>(null);

const switchPerspective = next => (): void => {
if (next !== page) {
Expand All @@ -59,7 +60,7 @@ const NavContentEx: FC<{
setOpen('primarySidebar', false);
};

const menu = useMemo(() => <List>
const menu = useMemo(() => <List>
{Object.keys(options.pages).map(page => ({
page,
text: options.pages[page].text,
Expand All @@ -74,19 +75,32 @@ const NavContentEx: FC<{
</ListItem>,
)}
</List>, [classes, page]);
const controller = useMemo(() => !worker ? null : <div className={classes.wrap}>
<div className={classes.wrapButtons}>
<Button className={classes.button} onClick={(): void => worker.reset(getProcessContext(options, store))} disabled={status !== 'initialized' && status !== 'finished' && status !== 'canceled'}>
Reset
</Button>
<Button className={classes.button} onClick={(): void => worker.start()} disabled={status !== 'initialized' && status !== 'canceled'}>
Start
</Button>
<Button className={classes.button} onClick={(): void => worker.stop()} disabled={status !== 'started'}>
Stop
</Button>
</div>
</div>, [worker, status, classes]);

useEffect(() => {
(async(): Promise<void> => {
if (worker) {
setController(<div className={classes.wrap}>
<div className={classes.wrapButtons}>
<Button
className={classes.button}
onClick={async(): Promise<void> => worker.reset(await getProcessContext(options, store))}
disabled={status !== 'initialized' && status !== 'finished' && status !== 'canceled'}
>
Reset
</Button>
<Button className={classes.button} onClick={(): void => worker.start()} disabled={status !== 'initialized' && status !== 'canceled'}>
Start
</Button>
<Button className={classes.button} onClick={(): void => worker.stop()} disabled={status !== 'started'}>
Stop
</Button>
</div>
</div>);
} else {
setController(null);
}
})().then();
}, [worker, status, classes]);

return <>
{options.parts?.beforeMenu ? options.parts.beforeMenu() : null}
Expand Down
60 changes: 30 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1112,16 +1112,16 @@
mkdirp "^0.5.1"
rimraf "^2.5.2"

"@material-ui/core@^4.10.1":
version "4.10.1"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.10.1.tgz#e3db4ca55d2af6cc23a1159ef5c32ad97c43c39c"
integrity sha512-bJb/07JFTht0oSjoWMu0j7r1mx4EbJ2ZHx+OKiY+i6IYW/4JPZ1J6rZuFS2b9jT+slSONPZaZq/kHitbE5lcig==
"@material-ui/core@^4.10.2":
version "4.10.2"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.10.2.tgz#0ef78572132fcef1a25f6969bce0d34652d42e31"
integrity sha512-Uf4iDLi9sW6HKbVQDyDZDr1nMR4RUAE7w/RIIJZGNVZResC0xwmpLRZMtaUdSO43N0R0yJehfxTi4Z461Cd49A==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/styles" "^4.10.0"
"@material-ui/system" "^4.9.14"
"@material-ui/types" "^5.1.0"
"@material-ui/utils" "^4.9.12"
"@material-ui/utils" "^4.10.2"
"@types/react-transition-group" "^4.2.0"
clsx "^1.0.4"
hoist-non-react-statics "^3.3.2"
Expand Down Expand Up @@ -1167,19 +1167,19 @@
resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.1.0.tgz#efa1c7a0b0eaa4c7c87ac0390445f0f88b0d88f2"
integrity sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==

"@material-ui/utils@^4.9.12", "@material-ui/utils@^4.9.6":
version "4.9.12"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.9.12.tgz#0d639f1c1ed83fffb2ae10c21d15a938795d9e65"
integrity sha512-/0rgZPEOcZq5CFA4+4n6Q6zk7fi8skHhH2Bcra8R3epoJEYy5PL55LuMazPtPH1oKeRausDV/Omz4BbgFsn1HQ==
"@material-ui/utils@^4.10.2", "@material-ui/utils@^4.9.6":
version "4.10.2"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.10.2.tgz#3fd5470ca61b7341f1e0468ac8f29a70bf6df321"
integrity sha512-eg29v74P7W5r6a4tWWDAAfZldXIzfyO1am2fIsC39hdUUHm/33k6pGOKPbgDjg/U/4ifmgAePy/1OjkKN6rFRw==
dependencies:
"@babel/runtime" "^7.4.4"
prop-types "^15.7.2"
react-is "^16.8.0"

"@mui-treasury/layout@^4.2.3":
version "4.2.3"
resolved "https://registry.yarnpkg.com/@mui-treasury/layout/-/layout-4.2.3.tgz#a198fe1441075ff6d190c21ad069928f1222b1ec"
integrity sha512-LEHrXpokpjJLVorrzauMSgdB/I+AfoI5NQxk46RSYjEXpSAfMkC3vyhR2LiP8Dd1N56qRA6NJJOu+V+Re1vSGg==
"@mui-treasury/layout@^4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@mui-treasury/layout/-/layout-4.4.0.tgz#4da60c0530dc97cf685238f9537acbedcf2b340c"
integrity sha512-+SydC7psxVSbOirCGp4PGpSt4iBaREomvR6XIFYKuFuxNXSr8/4Ni/Tq3N//cSbxDAP2UcsEYnFaT/zkl8bXvw==
dependencies:
debounce "^1.2.0"
deepmerge "^4.2.2"
Expand Down Expand Up @@ -1217,10 +1217,10 @@
resolved "https://registry.yarnpkg.com/@technote-space/genetic-algorithms-js/-/genetic-algorithms-js-0.5.2.tgz#59dfb9958c2f767032bf07ff64c54f044643b3b7"
integrity sha512-C1VOPuEZeOmkdPNwjg7vqJqF0deD06D27FufrP8qr0fzSFxJenoQmpuVfwYJc0jbgrTXpLGE0ZV6RH6ymEj/Mw==

"@technote-space/worker-controller@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@technote-space/worker-controller/-/worker-controller-0.3.2.tgz#b347d2af6135146bc953f3f75c02b751c22911ef"
integrity sha512-x/baSdtENZ5DxwLW0nbj16gUkBz2LN7YJ8LNGt+rIt5jgL9pTlMUj9hhxy5AMYtHTvV2/n9D4uVlK0xDdiC8/w==
"@technote-space/worker-controller@^0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@technote-space/worker-controller/-/worker-controller-0.4.1.tgz#61385c354ab0dce51d5808c5cfd270fbd00b0b50"
integrity sha512-i+FU2xOuKtIPTDtn6Pz4zyhRijltsQYkvmtciFYxyznvrOGHVghZXnWmpo3mORaa7qOEJYcLCrn5uVaL3TOP9Q==

"@types/anymatch@*":
version "1.3.1"
Expand Down Expand Up @@ -1548,9 +1548,9 @@ acorn@^6.4.1:
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==

acorn@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.2.0.tgz#17ea7e40d7c8640ff54a694c889c26f31704effe"
integrity sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==
version "7.3.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==

aggregate-error@^3.0.0:
version "3.0.1"
Expand Down Expand Up @@ -2910,9 +2910,9 @@ duplexify@^3.4.2, duplexify@^3.6.0:
stream-shift "^1.0.0"

electron-to-chromium@^1.3.413:
version "1.3.466"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.466.tgz#89f716db3afc4bb482ea2aaaa16c4808f89f762a"
integrity sha512-eieqkoM2hCkZZRhETKyCouMziDV3l4XEKHRLuzcHG+HV+P7PeODU/z9HAmBgMQkzvHg2DoyQhfIDmmeguLZT/Q==
version "1.3.470"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.470.tgz#07ccfd481b96709f4ac20bb74bccf59705a41ced"
integrity sha512-SQzHdpUUmTSiIYwMFZ3P3271VdRxfdHqh2GoBA7sqeaz4SN3UlTA22fC+r9BHu8FpB0oI7f8pAxzm75O/kBc3w==

elliptic@^6.0.0, elliptic@^6.5.2:
version "6.5.2"
Expand Down Expand Up @@ -4234,9 +4234,9 @@ jss@^10.0.3, jss@^10.3.0:
tiny-warning "^1.0.2"

jsx-ast-utils@^2.2.3:
version "2.3.0"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.3.0.tgz#edd727794ea284d7fda575015ed1b0cde0289ab6"
integrity sha512-3HNoc7nZ1hpZIKB3hJ7BlFRkzCx2BynRtfSwbkqZdpRdvAPsGMnzclPwrvDBS7/lalHTj21NwIeaEpysHBOudg==
version "2.4.1"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.4.1.tgz#1114a4c1209481db06c690c2b4f488cc665f657e"
integrity sha512-z1xSldJ6imESSzOjd3NNkieVJKRlKYSOtMG8SFyCj2FIrvSaSuli/WjpBkEzCBoR9bYYYFgqJw61Xhu7Lcgk+w==
dependencies:
array-includes "^3.1.1"
object.assign "^4.1.0"
Expand Down Expand Up @@ -4295,10 +4295,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

lint-staged@^10.2.9:
version "10.2.9"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.2.9.tgz#6013ecfa80829cd422446b545fd30a96bca3098c"
integrity sha512-ziRAuXEqvJLSXg43ezBpHxRW8FOJCXISaXU//BWrxRrp5cBdRkIx7g5IsB3OI45xYGE0S6cOacfekSjDyDKF2g==
lint-staged@^10.2.10:
version "10.2.10"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-10.2.10.tgz#f0f78bf8786bbe90e1775a0dc540f7f12b6a79b2"
integrity sha512-dgelFaNH6puUGAcU+OVMgbfpKSerNYsPSn6+nlbRDjovL0KigpsVpCu0PFZG6BJxX8gnHJqaZlR9krZamQsb0w==
dependencies:
chalk "^4.0.0"
cli-truncate "2.1.0"
Expand Down

0 comments on commit ae46901

Please sign in to comment.