Skip to content

Commit

Permalink
Merge pull request #131 from technote-space/release/next-v0.14.21
Browse files Browse the repository at this point in the history
release: v0.15.0
  • Loading branch information
technote-space authored Dec 25, 2022
2 parents 50f7c44 + 22e20c6 commit acc81d2
Show file tree
Hide file tree
Showing 23 changed files with 2,653 additions and 2,511 deletions.
81 changes: 41 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/ga-framework",
"version": "0.14.21",
"version": "0.15.0",
"description": "GA Framework",
"keywords": [
"genetic algorithm"
Expand Down Expand Up @@ -36,55 +36,56 @@
"prepublishOnly": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --disable",
"postpublish": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --enable",
"test": "yarn lint",
"update": "npx npm-check-updates -u && yarn install && yarn upgrade && yarn audit"
"update": "npm_config_yes=true npx npm-check-updates -u --timeout 100000 && yarn install && yarn upgrade && yarn audit"
},
"dependencies": {
"@egjs/hammerjs": "^2.0.17",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@mui-treasury/layout": "^4.5.1",
"@technote-space/genetic-algorithms-js": "^0.8.24",
"@technote-space/worker-controller": "^0.5.46",
"chart.js": "^3.7.0",
"clsx": "^1.1.1",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mui-treasury/layout": "^5.0.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.1",
"@technote-space/genetic-algorithms-js": "^0.8.27",
"@technote-space/worker-controller": "^0.5.56",
"chart.js": "^4.1.1",
"clsx": "^1.2.1",
"keycharm": "^0.4.0",
"moment": "^2.29.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"moment": "^2.29.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"styled-components": "^5.3.3",
"vis-data": "^7.1.2",
"vis-network": "^9.1.0",
"vis-util": "^5.0.2"
"vis-data": "^7.1.4",
"vis-network": "^9.1.2",
"vis-util": "^5.0.3"
},
"devDependencies": {
"@babel/core": "^7.16.12",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
"@babel/plugin-transform-react-inline-elements": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-flow": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.0.0",
"@types/node": "^17.0.14",
"@types/react-helmet": "^6.1.5",
"@types/styled-components": "^5.1.21",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@babel/core": "^7.20.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-transform-react-inline-elements": "^7.18.6",
"@babel/preset-env": "^7.20.2",
"@babel/preset-flow": "^7.18.6",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@types/node": "^18.11.17",
"@types/react-helmet": "^6.1.6",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"babel-plugin-react-html-attrs": "^3.0.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"copy-webpack-plugin": "^10.2.4",
"eslint": "^8.8.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.30.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^7.0.4",
"lint-staged": "^12.3.2",
"pinst": "^2.1.6",
"typescript": "^4.5.5",
"webpack": "^5.68.0"
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"pinst": "^3.0.0",
"typescript": "^4.9.4",
"webpack": "^5.75.0"
},
"publishConfig": {
"access": "public"
Expand Down
170 changes: 84 additions & 86 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,127 +1,125 @@
import type {FC} from 'react';
import type {AppOptions} from '$/types';
import type {StatusResult} from '@technote-space/worker-controller';
import React, {memo, useMemo, useEffect} from 'react';
import {Helmet} from 'react-helmet';
import styled from 'styled-components';
import LayoutBuilder, {
import type { FC } from 'react';
import type { AppOptions } from '$/types';
import type { StatusResult } from '@technote-space/worker-controller';
import React, { memo, useMemo, useEffect } from 'react';
import { Helmet } from 'react-helmet';
import {
Root,
getHeader,
getDrawerSidebar,
getSidebarContent,
getContent,
getSidebarTrigger,
Header,
SidebarContent,
Content,
EdgeTrigger,
EdgeSidebar,
EdgeTriggerProps,
} from '@mui-treasury/layout';
import {
Toolbar,
CssBaseline,
} from '@material-ui/core';
import {createTheme, responsiveFontSizes, makeStyles, createStyles} from '@material-ui/core/styles';
import {useTheme} from './hooks';
} from '@mui/material';
import { ThemeProvider, createTheme, responsiveFontSizes } from '@mui/material/styles';
import { useTheme } from './hooks';
import {
ContentEx,
HeaderEx,
NavContentEx,
} from './templates';
import {useDispatchContext, useStoreContext} from './Store';
import {Controller} from '@technote-space/worker-controller';
import {getProcessContext, getTitle, updateStatus} from './common';

const useStyles = makeStyles(() => createStyles({
content: {
height: '100%',
},
}));

const scheme = LayoutBuilder();
scheme.configureHeader(builder => {
builder
.registerConfig('xs', {
position: 'sticky',
initialHeight: 56,
})
.registerConfig('md', {
position: 'sticky',
initialHeight: 64,
clipped: true,
});
});
scheme.configureEdgeSidebar(builder => {
builder
.create('primarySidebar', {
anchor: 'left',
})
.registerTemporaryConfig('xs', {
width: 275,
})
.registerPermanentConfig('md', {
width: 275,
collapsible: false,
})
.registerPermanentConfig('lg', {
width: 275,
collapsible: false,
});
});
const Header = getHeader(styled);
const DrawerSidebar = getDrawerSidebar(styled);
const SidebarContent = getSidebarContent(styled);
const SidebarTrigger = getSidebarTrigger(styled);
const Content = getContent(styled);
import { useDispatchContext, useStoreContext } from './Store';
import { Controller } from '@technote-space/worker-controller';
import { getProcessContext, getTitle, updateStatus } from './common';

const App: FC<{
options: AppOptions;
}> = memo(({options}: { options: AppOptions }) => {
const {store: {themeColor, reloadWorker}, store} = useStoreContext();
const {dispatch} = useDispatchContext();
const themeObject = useTheme(themeColor);
const theme = responsiveFontSizes(createTheme(themeObject));
const classes = useStyles({theme});
}> = memo(({ options }: { options: AppOptions }) => {
const { store: { themeColor, reloadWorker }, store } = useStoreContext();
const { dispatch } = useDispatchContext();
const themeObject = useTheme(themeColor);
const theme = responsiveFontSizes(createTheme(themeObject));

const title = useMemo(() => getTitle(options, store), [store]);
const cssBaseline = useMemo(() => <CssBaseline/>, []);
const header = useMemo(() => <Header>
<Toolbar>
<SidebarTrigger sidebarId="primarySidebar"/>
<EdgeTrigger target={{ anchor: 'left', field: 'open' }}>
{((open, setOpen) => (
<button onClick={() => setOpen(!open)}>{open ? 'Close' : 'Open'}</button>
)) as EdgeTriggerProps['children']}
</EdgeTrigger>
<HeaderEx options={options}/>
</Toolbar>
</Header>, []);
const sidebar = useMemo(() => <DrawerSidebar sidebarId="primarySidebar">
<SidebarContent>
<NavContentEx options={options}/>
</SidebarContent>
</DrawerSidebar>, []);
const content = useMemo(() => <Content className={classes.content}>
const sidebar = useMemo(() => <EdgeSidebar anchor="left">
{({ setOpen }) => (
<SidebarContent>
<NavContentEx options={options} setOpen={setOpen}/>
</SidebarContent>
)}
</EdgeSidebar>, []);
const content = useMemo(() => <Content sx={{ height: '100%' }}>
<ContentEx options={options}/>
</Content>, [classes]);
</Content>, []);

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

return useMemo(() => (
<Root scheme={scheme} theme={theme}>
<Helmet title={title}/>
{cssBaseline}
{header}
{sidebar}
{content}
</Root>
), [title, classes, theme]);
<ThemeProvider theme={theme}>
<Root scheme={{
header: {
config: {
xs: {
position: 'sticky',
height: 56,
},
md: {
position: 'relative',
height: 64,
clipped: true,
},
},
},
leftEdgeSidebar: {
autoCollapse: 'sm',
config: {
xs: {
variant: 'temporary',
width: 275,
},
md: {
variant: 'permanent',
width: 275,
collapsible: false,
},
lg: {
variant: 'permanent',
width: 275,
collapsible: false,
},
},
},
}}>
<Helmet title={title}/>
{cssBaseline}
{header}
{sidebar}
{content}
</Root>
</ThemeProvider>
), [title, theme]);
});

App.displayName = 'App';
Expand Down
36 changes: 18 additions & 18 deletions src/app/Store.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {FC} from 'react';
import type {AppOptions} from '$/types';
import React, {memo, useReducer, createContext, useContext, useCallback, useEffect} from 'react';
import {getProcessContext} from './common';
import type { FC, PropsWithChildren } from 'react';
import type { AppOptions } from '$/types';
import React, { memo, useReducer, createContext, useContext, useCallback, useEffect } from 'react';
import { getProcessContext } from './common';

const StoreContext = createContext({});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -59,7 +59,7 @@ const resultReducer = (store, result) => {
const index = histories.findIndex(value => value.x === dataX);
// eslint-disable-next-line no-magic-numbers
if (index < 0) {
histories.push({x: dataX, y: dataY});
histories.push({ x: dataX, y: dataY });
} else {
histories[index].y = dataY;
}
Expand All @@ -71,20 +71,20 @@ const resultReducer = (store, result) => {
};

const reducerActions = {
PAGE: (store, action) => ({...store, page: action.page}),
THEME_COLOR: (store, action) => ({...store, themeColor: action.themeColor}),
WORKER: (store, action) => ({...store, worker: action.worker}),
PAGE: (store, action) => ({ ...store, page: action.page }),
THEME_COLOR: (store, action) => ({ ...store, themeColor: action.themeColor }),
WORKER: (store, action) => ({ ...store, worker: action.worker }),
UPDATE_STATUS: (store, action) => {
if (store.status === 'disabled') {
return store;
}

return {...store, status: action.result.status};
return { ...store, status: action.result.status };
},
RELOAD_WORKER: (store) => ({...store, reloadWorker: !store.reloadWorker}),
SET_NOTICE: (store, action) => ({...store, notice: {...store.notice, ...{open: true, variant: 'success'}, ...action.notice}}),
SET_ERROR: (store, action) => ({...store, notice: {...store.notice, ...{open: true, variant: 'error'}, ...action.notice}}),
CLOSE_NOTICE: (store) => ({...store, notice: {...store.notice, ...{open: false}}}),
RELOAD_WORKER: (store) => ({ ...store, reloadWorker: !store.reloadWorker }),
SET_NOTICE: (store, action) => ({ ...store, notice: { ...store.notice, ...{ open: true, variant: 'success' }, ...action.notice } }),
SET_ERROR: (store, action) => ({ ...store, notice: { ...store.notice, ...{ open: true, variant: 'error' }, ...action.notice } }),
CLOSE_NOTICE: (store) => ({ ...store, notice: { ...store.notice, ...{ open: false } } }),
PAGINATION_INITIALIZED: (store) => ({
...store,
pagination: {
Expand Down Expand Up @@ -116,9 +116,9 @@ const reducerActions = {
return store;
},
};
const StoreContextProvider: FC<{
const StoreContextProvider: FC<PropsWithChildren<{
options: AppOptions;
}> = memo(({children, options}) => {
}>> = memo(({ children, options }) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const getReducer = useCallback((store, action): any => {
if (action.type in reducerActions) {
Expand All @@ -141,11 +141,11 @@ const StoreContextProvider: FC<{
onReloadNeeded().then();
}, []);

return <StoreContext.Provider value={{store}}>
<DispatchContext.Provider value={{dispatch, onReloadNeeded}}>
return <StoreContext.Provider value={{ store }}>
<DispatchContext.Provider value={{ dispatch, onReloadNeeded }}>
{children}
</DispatchContext.Provider>
</StoreContext.Provider>;
});
StoreContextProvider.displayName = 'StoreContextProvider';
export {StoreContextProvider};
export { StoreContextProvider };
Loading

0 comments on commit acc81d2

Please sign in to comment.