From 595a943d7ce0da89fecc4019848b2a243b17a327 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 10 Jan 2024 04:50:08 -0600 Subject: [PATCH] refactor: react fast refresh --- build/flecks.yml | 3 ++- package.json | 2 +- packages/app/src/components/app/index.jsx | 3 +-- packages/app/src/components/app/play/renderable.jsx | 4 ++-- packages/app/src/components/app/play/ui/hotbar/index.jsx | 4 ++-- packages/app/src/components/app/play/ui/index.jsx | 4 ++-- .../app/src/components/app/play/ui/item-slot/index.jsx | 4 ++-- packages/app/src/components/app/ui/index.jsx | 4 ++-- packages/combat/src/persea/traits/harmful.jsx | 7 +++---- packages/core/src/persea/traits/item.jsx | 7 +++---- 10 files changed, 20 insertions(+), 22 deletions(-) diff --git a/build/flecks.yml b/build/flecks.yml index 58b6fea..a664846 100644 --- a/build/flecks.yml +++ b/build/flecks.yml @@ -73,7 +73,6 @@ - '@babel/core' - '@babel/parser' - '@babel/types' - - '@hot-loader/react-dom' - '@pixi/constants' - '@pixi/core' - '@pixi/display' @@ -92,6 +91,8 @@ - 'matter-js' - 'pako' - 'react' + - 'react-dom' + - 'react-refresh/runtime' - 'react-window' port: 32350 public: 'humus.localhost' diff --git a/package.json b/package.json index a7ed271..fef5018 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": "FLECKS_ENV__flecks_server__start=0 npm run build:only", "build:only": "flecks build", "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", "postinstall": "patch-package", "refresh": "rm -rf yarn.lock node_modules dist && yarn link-all", diff --git a/packages/app/src/components/app/index.jsx b/packages/app/src/components/app/index.jsx index 4a1778e..81fdc70 100644 --- a/packages/app/src/components/app/index.jsx +++ b/packages/app/src/components/app/index.jsx @@ -1,6 +1,5 @@ import { classnames, - hot, React, } from '@flecks/react'; import { @@ -54,4 +53,4 @@ function Humus() { ); } -export default hot(module)(Humus); +export default Humus; diff --git a/packages/app/src/components/app/play/renderable.jsx b/packages/app/src/components/app/play/renderable.jsx index dec970f..c87dea2 100644 --- a/packages/app/src/components/app/play/renderable.jsx +++ b/packages/app/src/components/app/play/renderable.jsx @@ -9,7 +9,7 @@ import {useRoom, useSelfEntity} from '../../../hooks'; import styles from './renderable.module.scss'; -const RoomStage = () => { +function RoomStage() { const selfEntity = useSelfEntity(); const [camera, setCamera] = useState(); const room = useRoom(); @@ -19,6 +19,6 @@ const RoomStage = () => { } }, [selfEntity]); return ; -}; +} export default RoomStage; diff --git a/packages/app/src/components/app/play/ui/hotbar/index.jsx b/packages/app/src/components/app/play/ui/hotbar/index.jsx index c927a22..3f9118d 100644 --- a/packages/app/src/components/app/play/ui/hotbar/index.jsx +++ b/packages/app/src/components/app/play/ui/hotbar/index.jsx @@ -5,7 +5,7 @@ import {PropTypes, React} from '@flecks/react'; import ItemSlot from '../item-slot'; import styles from './index.module.scss'; -const HotbarComponent = (props) => { +function HotbarComponent(props) { const {selfEntity} = props; const {inputActions} = selfEntity; // Render keys bound for each slot. @@ -35,7 +35,7 @@ const HotbarComponent = (props) => { )); return
{itemSlots}
; -}; +} HotbarComponent.propTypes = { selfEntity: PropTypes.shape({ diff --git a/packages/app/src/components/app/play/ui/index.jsx b/packages/app/src/components/app/play/ui/index.jsx index 0989482..8b18cf1 100644 --- a/packages/app/src/components/app/play/ui/index.jsx +++ b/packages/app/src/components/app/play/ui/index.jsx @@ -18,7 +18,7 @@ import Money from './money'; import Stamina from './stamina'; import styles from './index.module.scss'; -const PlayUi = () => { +function PlayUi() { const {config: {'@humus/app': {resolution}}} = useFlecks(); const ref = useRef(); const room = useRoom(); @@ -60,6 +60,6 @@ const PlayUi = () => { )} ); -}; +} export default PlayUi; diff --git a/packages/app/src/components/app/play/ui/item-slot/index.jsx b/packages/app/src/components/app/play/ui/item-slot/index.jsx index c23481d..b8fa5b2 100644 --- a/packages/app/src/components/app/play/ui/item-slot/index.jsx +++ b/packages/app/src/components/app/play/ui/item-slot/index.jsx @@ -9,7 +9,7 @@ import { import styles from './index.module.scss'; -const ItemSlotComponent = (props) => { +function ItemSlotComponent(props) { const { children, className, @@ -60,7 +60,7 @@ const ItemSlotComponent = (props) => { ); -}; +} ItemSlotComponent.defaultProps = { children: null, diff --git a/packages/app/src/components/app/ui/index.jsx b/packages/app/src/components/app/ui/index.jsx index 9489d3c..e1f6214 100644 --- a/packages/app/src/components/app/ui/index.jsx +++ b/packages/app/src/components/app/ui/index.jsx @@ -11,7 +11,7 @@ import styles from './index.module.scss'; export {Context}; -const Ui = ({children}) => { +function Ui({children}) { const [width, height] = useContext(Context); const $ui = useRef(); useEffect(() => { @@ -38,7 +38,7 @@ const Ui = ({children}) => { {children} ); -}; +} Ui.propTypes = { children: PropTypes.node.isRequired, diff --git a/packages/combat/src/persea/traits/harmful.jsx b/packages/combat/src/persea/traits/harmful.jsx index ab4e00b..9d6e2ab 100644 --- a/packages/combat/src/persea/traits/harmful.jsx +++ b/packages/combat/src/persea/traits/harmful.jsx @@ -3,12 +3,11 @@ import {join} from 'path'; import {Code} from '@avocado/react'; import {useJsonPatcher} from '@avocado/resource/persea'; import { - hot, PropTypes, React, } from '@flecks/react'; -const Harmful = ({json, path}) => { +function Harmful({json, path}) { const patch = useJsonPatcher(); return (
@@ -22,7 +21,7 @@ const Harmful = ({json, path}) => {
); -}; +} Harmful.defaultProps = {}; @@ -44,4 +43,4 @@ Harmful.propTypes = { Harmful.displayName = 'Harmful'; -export default hot(module)(Harmful); +export default Harmful; diff --git a/packages/core/src/persea/traits/item.jsx b/packages/core/src/persea/traits/item.jsx index d387fb5..c915de0 100644 --- a/packages/core/src/persea/traits/item.jsx +++ b/packages/core/src/persea/traits/item.jsx @@ -3,12 +3,11 @@ import {join} from 'path'; import {Code, Number} from '@avocado/react'; import {useJsonPatcher} from '@avocado/resource/persea'; import { - hot, PropTypes, React, } from '@flecks/react'; -const Item = ({json, path}) => { +function Item({json, path}) { const patch = useJsonPatcher(); return (
@@ -29,7 +28,7 @@ const Item = ({json, path}) => {
); -}; +} Item.defaultProps = {}; @@ -49,4 +48,4 @@ Item.propTypes = { path: PropTypes.string.isRequired, }; -export default hot(module)(Item); +export default Item;