refactor: react fast refresh

This commit is contained in:
cha0s 2024-01-10 04:50:08 -06:00
parent 21cfb7d900
commit 595a943d7c
10 changed files with 20 additions and 22 deletions

View File

@ -73,7 +73,6 @@
- '@babel/core' - '@babel/core'
- '@babel/parser' - '@babel/parser'
- '@babel/types' - '@babel/types'
- '@hot-loader/react-dom'
- '@pixi/constants' - '@pixi/constants'
- '@pixi/core' - '@pixi/core'
- '@pixi/display' - '@pixi/display'
@ -92,6 +91,8 @@
- 'matter-js' - 'matter-js'
- 'pako' - 'pako'
- 'react' - 'react'
- 'react-dom'
- 'react-refresh/runtime'
- 'react-window' - 'react-window'
port: 32350 port: 32350
public: 'humus.localhost' public: 'humus.localhost'

View File

@ -13,7 +13,7 @@
"build": "FLECKS_ENV__flecks_server__start=0 npm run build:only", "build": "FLECKS_ENV__flecks_server__start=0 npm run build:only",
"build:only": "flecks build", "build:only": "flecks build",
"debug": "DEBUG=*,-babel*,-compression*,-engine*,-eslint*,-express*,-send*,-sequelize*,-socket.io* npm run dev", "debug": "DEBUG=*,-babel*,-compression*,-engine*,-eslint*,-express*,-send*,-sequelize*,-socket.io* npm run dev",
"dev": "npm run -- build:only -h", "dev": "npm run -- build:only -dh",
"link-all": "yarn && for i in avocado humus; do yarn link $(for j in $(ls node_modules/@$i/); do echo \" @$i/$j\"; done); done", "link-all": "yarn && for i in avocado humus; do yarn link $(for j in $(ls node_modules/@$i/); do echo \" @$i/$j\"; done); done",
"postinstall": "patch-package", "postinstall": "patch-package",
"refresh": "rm -rf yarn.lock node_modules dist && yarn link-all", "refresh": "rm -rf yarn.lock node_modules dist && yarn link-all",

View File

@ -1,6 +1,5 @@
import { import {
classnames, classnames,
hot,
React, React,
} from '@flecks/react'; } from '@flecks/react';
import { import {
@ -54,4 +53,4 @@ function Humus() {
); );
} }
export default hot(module)(Humus); export default Humus;

View File

@ -9,7 +9,7 @@ import {useRoom, useSelfEntity} from '../../../hooks';
import styles from './renderable.module.scss'; import styles from './renderable.module.scss';
const RoomStage = () => { function RoomStage() {
const selfEntity = useSelfEntity(); const selfEntity = useSelfEntity();
const [camera, setCamera] = useState(); const [camera, setCamera] = useState();
const room = useRoom(); const room = useRoom();
@ -19,6 +19,6 @@ const RoomStage = () => {
} }
}, [selfEntity]); }, [selfEntity]);
return <RoomRenderable camera={camera} styles={styles} room={room} />; return <RoomRenderable camera={camera} styles={styles} room={room} />;
}; }
export default RoomStage; export default RoomStage;

View File

@ -5,7 +5,7 @@ import {PropTypes, React} from '@flecks/react';
import ItemSlot from '../item-slot'; import ItemSlot from '../item-slot';
import styles from './index.module.scss'; import styles from './index.module.scss';
const HotbarComponent = (props) => { function HotbarComponent(props) {
const {selfEntity} = props; const {selfEntity} = props;
const {inputActions} = selfEntity; const {inputActions} = selfEntity;
// Render keys bound for each slot. // Render keys bound for each slot.
@ -35,7 +35,7 @@ const HotbarComponent = (props) => {
</ItemSlot> </ItemSlot>
)); ));
return <div className={styles.hotbar}><div className={styles.inner}>{itemSlots}</div></div>; return <div className={styles.hotbar}><div className={styles.inner}>{itemSlots}</div></div>;
}; }
HotbarComponent.propTypes = { HotbarComponent.propTypes = {
selfEntity: PropTypes.shape({ selfEntity: PropTypes.shape({

View File

@ -18,7 +18,7 @@ import Money from './money';
import Stamina from './stamina'; import Stamina from './stamina';
import styles from './index.module.scss'; import styles from './index.module.scss';
const PlayUi = () => { function PlayUi() {
const {config: {'@humus/app': {resolution}}} = useFlecks(); const {config: {'@humus/app': {resolution}}} = useFlecks();
const ref = useRef(); const ref = useRef();
const room = useRoom(); const room = useRoom();
@ -60,6 +60,6 @@ const PlayUi = () => {
)} )}
</div> </div>
); );
}; }
export default PlayUi; export default PlayUi;

View File

@ -9,7 +9,7 @@ import {
import styles from './index.module.scss'; import styles from './index.module.scss';
const ItemSlotComponent = (props) => { function ItemSlotComponent(props) {
const { const {
children, children,
className, className,
@ -60,7 +60,7 @@ const ItemSlotComponent = (props) => {
</div> </div>
</button> </button>
); );
}; }
ItemSlotComponent.defaultProps = { ItemSlotComponent.defaultProps = {
children: null, children: null,

View File

@ -11,7 +11,7 @@ import styles from './index.module.scss';
export {Context}; export {Context};
const Ui = ({children}) => { function Ui({children}) {
const [width, height] = useContext(Context); const [width, height] = useContext(Context);
const $ui = useRef(); const $ui = useRef();
useEffect(() => { useEffect(() => {
@ -38,7 +38,7 @@ const Ui = ({children}) => {
{children} {children}
</div> </div>
); );
}; }
Ui.propTypes = { Ui.propTypes = {
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,

View File

@ -3,12 +3,11 @@ import {join} from 'path';
import {Code} from '@avocado/react'; import {Code} from '@avocado/react';
import {useJsonPatcher} from '@avocado/resource/persea'; import {useJsonPatcher} from '@avocado/resource/persea';
import { import {
hot,
PropTypes, PropTypes,
React, React,
} from '@flecks/react'; } from '@flecks/react';
const Harmful = ({json, path}) => { function Harmful({json, path}) {
const patch = useJsonPatcher(); const patch = useJsonPatcher();
return ( return (
<div className="harmful"> <div className="harmful">
@ -22,7 +21,7 @@ const Harmful = ({json, path}) => {
</div> </div>
</div> </div>
); );
}; }
Harmful.defaultProps = {}; Harmful.defaultProps = {};
@ -44,4 +43,4 @@ Harmful.propTypes = {
Harmful.displayName = 'Harmful'; Harmful.displayName = 'Harmful';
export default hot(module)(Harmful); export default Harmful;

View File

@ -3,12 +3,11 @@ import {join} from 'path';
import {Code, Number} from '@avocado/react'; import {Code, Number} from '@avocado/react';
import {useJsonPatcher} from '@avocado/resource/persea'; import {useJsonPatcher} from '@avocado/resource/persea';
import { import {
hot,
PropTypes, PropTypes,
React, React,
} from '@flecks/react'; } from '@flecks/react';
const Item = ({json, path}) => { function Item({json, path}) {
const patch = useJsonPatcher(); const patch = useJsonPatcher();
return ( return (
<div className="item"> <div className="item">
@ -29,7 +28,7 @@ const Item = ({json, path}) => {
</div> </div>
</div> </div>
); );
}; }
Item.defaultProps = {}; Item.defaultProps = {};
@ -49,4 +48,4 @@ Item.propTypes = {
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
}; };
export default hot(module)(Item); export default Item;