refactor: app structure

This commit is contained in:
cha0s 2021-03-23 11:58:53 -05:00
parent 2c7e897376
commit 44073c7005
85 changed files with 5703 additions and 4563 deletions

3
.gitignore vendored
View File

@ -114,3 +114,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# local
/build

8
.neutrinorc.js Normal file
View File

@ -0,0 +1,8 @@
require('dotenv/config');
module.exports = {
options: {
root: __dirname,
},
use: [],
};

120
app/.gitignore vendored
View File

@ -1,120 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/build
/latus.yml
/resource*

View File

@ -1,15 +0,0 @@
require('dotenv/config');
const {server} = require('@latus/build');
module.exports = {
options: {
root: __dirname,
},
use: [
(neutrino) => {
const entry = neutrino.config.entry('electron').clear();
entry.add('./src/electron');
},
],
};

View File

@ -1,50 +0,0 @@
'@latus/core': {
up: [
'@latus/db',
'@latus/redis',
'@latus/user/session',
'@latus/user/passport',
'@latus/user/local',
'@latus/http',
'@latus/repl',
],
}
'@latus/db': {
models.decorate: [
'@latus/user/local',
],
docker: 'cached',
}
'@latus/governor': {}
'@latus/http': {
client.up: [
'@latus/socket/client',
'@latus/react/client',
],
request: [
'@latus/user/session',
'@latus/user/passport',
],
}
'@latus/react': {}
'@latus/redis': {
docker: 'cached',
}
'@latus/redis/session': {}
'@latus/repl': {}
'@latus/socket': {
authenticate: [
'@latus/user/session',
'@latus/user/passport',
],
connect: [
'@latus/socket',
],
packets.decorate: [
'@latus/governor',
]
}
'@latus/user/local': {}
'@latus/user/models': {}
'@latus/user/passport': {}
'@latus/user/session': {}

View File

@ -1,65 +0,0 @@
{
"name": "latus",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "latus-build",
"clean": "latus-build clean",
"client": "LATUS_EXCLUDE_BUILD=server latus-build -d --hot --watch",
"dev": "latus-build -d --hot --watch --start-server --inspect",
"docker": "yarn run build && docker build",
"electron": "NODE_ENV=production NODE_PATH=./node_modules electron build/electron.js",
"lint": "latus-build lint",
"repl": "rlwrap -C qmp socat STDIO UNIX:$(ls /tmp/latus-*.sock | tail -n 1)",
"server": "LATUS_EXCLUDE_BUILD=http latus-build -d --start-server --inspect --watch",
"start": "NODE_ENV=production NODE_PATH=./node_modules node build/index.js",
"test": "latus-build test"
},
"dependencies": {
"@avocado/behavior": "^2.0.0",
"@avocado/color": "^1.0.0",
"@avocado/core": "^2.0.0",
"@avocado/dialog": "^1.0.0",
"@avocado/entity": "^2.0.0",
"@avocado/graphics": "^2.0.0",
"@avocado/input": "^2.0.0",
"@avocado/math": "^2.0.0",
"@avocado/physics": "^1.0.0",
"@avocado/resource": "^2.0.0",
"@avocado/s13n": "^2.0.0",
"@avocado/sound": "^1.0.0",
"@avocado/timing": "^2.0.0",
"@avocado/topdown": "^2.0.0",
"@humus/combat": "^1.0.0",
"@humus/core": "^1.0.0",
"@humus/farm": "^1.0.0",
"@humus/inventory": "^1.0.0",
"@humus/universe": "^1.0.0",
"@inlet/react-pixi": "^6.0.7",
"@latus/core": "2.0.0",
"@latus/db": "2.0.0",
"@latus/governor": "2.0.0",
"@latus/http": "2.0.0",
"@latus/react": "2.0.0",
"@latus/redis": "2.0.0",
"@latus/redux": "^2.0.0",
"@latus/repl": "2.0.0",
"@latus/socket": "2.0.0",
"@latus/user": "2.0.0",
"classnames": "^2.2.6",
"connected-react-router": "^6.8.0",
"dotenv": "8.2.0",
"electron": "^11.1.1",
"history": "^4.7.2",
"is-electron": "^2.2.0",
"pixi.js-legacy": "^5.3.7",
"react-hot-loader": "4.13.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"screenfull": "^5.1.0"
},
"devDependencies": {
"@latus/build": "^1.0.0",
"source-map-support": "0.5.19"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

View File

@ -1 +0,0 @@
process.stdout.write('Your application is starting...\n');

118
latus.yml Normal file
View File

@ -0,0 +1,118 @@
'@latus/core': {}
'@latus/core/server': {
up: [
'@latus/db/server',
'@latus/redis/server',
'@latus/user/session/server',
'@latus/user/server',
'@latus/user/local/server',
'@latus/http/server',
'@humus/universe/server',
'@latus/repl/server',
],
}
'@latus/db': {}
'@latus/db/server': {
models.decorate: [
'@latus/user/local/server',
],
docker: 'cached',
}
'@latus/governor': {}
'@latus/http': {}
'@latus/http/client': {
up: [
'@latus/socket/client',
'@humus/universe/client',
'@latus/react/client',
],
}
'@latus/http/server': {
devPort: 32351,
devPublic: 'humus.localhost',
request.page: [
'@latus/user/session/server',
'@latus/user/server',
],
request.socket: [
'@humus/universe/server',
],
port: 32350,
}
'@latus/react': {
providers: [
'@latus/redux/client',
],
}
'@latus/redis': {}
'@latus/redis/server': {
docker: 'cached',
}
'@latus/redis/session': {}
'@latus/redux': {}
'@latus/repl': {}
'@latus/socket': {
packets.decorate: [
'@latus/governor/server',
'@humus/universe/server',
],
}
'@latus/socket/server': {
authenticate: [
'@latus/user/session/server',
'@latus/user/server',
],
connect: [
'@latus/socket/server',
],
}
'@latus/user': {}
'@latus/user/local': {}
'@latus/user/session': {}
'@avocado/behavior': {}
'@avocado/color': {}
'@avocado/core': {}
'@avocado/dialog': {}
'@avocado/entity': {}
'@avocado/graphics': {}
'@avocado/input': {
actions: [
'HotbarSlot0',
'HotbarSlot1',
'HotbarSlot2',
'HotbarSlot3',
'HotbarSlot4',
'HotbarSlot5',
'HotbarSlot6',
'HotbarSlot7',
'HotbarSlot8',
'HotbarSlot9',
'HotbarSlotNext',
'HotbarSlotPrevious',
'MoveUp',
'MoveLeft',
'MoveDown',
'MoveRight',
'UseItem',
'Interact',
],
}
'@avocado/math': {}
'@avocado/physics': {}
'@avocado/resource': {}
'@avocado/s13n': {}
'@avocado/sound': {}
'@avocado/timing': {}
'@avocado/topdown': {}
'@avocado/traits': {}
'@humus/combat': {}
'@humus/core': {}
'@humus/farm': {}
'@humus/http': {}
'@humus/inventory': {}
'@humus/universe': {
root: '../persea/app/projects/c41ddaac-89c2-46a4-b3e5-1d634a1a7c36',
}
'@humus/universe/server': {
running: 'c41ddaac-89c2-46a4-b3e5-1d634a1a7c36',
}

View File

@ -4,12 +4,52 @@
"scripts": {
"build": "lerna run build",
"clean": "lerna run clean",
"docker": "yarn run build && docker build",
"electron": "NODE_ENV=production NODE_PATH=./node_modules electron build/electron.js",
"fp": "lerna run fp",
"http": "LATUS_ONLY_BUILD=http latus-build -d --hot --watch",
"lint": "lerna run lint",
"package": "node ./package.js",
"refresh": "yarn run clean && npx lerna exec link-all && yarn run build && yarn run test",
"repl": "rlwrap -C qmp socat STDIO UNIX:$(ls /tmp/latus-*.sock | tail -n 1)",
"server": "LATUS_ONLY_BUILD=server latus-build -d --start-server --inspect --watch",
"start": "NODE_ENV=production NODE_PATH=./node_modules node build/index.js",
"test": "lerna run test --no-bail -- --silent"
},
"dependencies": {
"@avocado/behavior": "^2.0.0",
"@avocado/color": "^1.0.0",
"@avocado/core": "^2.0.0",
"@avocado/dialog": "^1.0.0",
"@avocado/entity": "^2.0.0",
"@avocado/graphics": "^2.0.0",
"@avocado/input": "^2.0.0",
"@avocado/math": "^2.0.0",
"@avocado/physics": "^1.0.0",
"@avocado/resource": "^2.0.0",
"@avocado/s13n": "^2.0.0",
"@avocado/sound": "^1.0.0",
"@avocado/timing": "^2.0.0",
"@avocado/topdown": "^2.0.0",
"@humus/combat": "^1.0.0",
"@humus/core": "^1.0.0",
"@humus/farm": "^1.0.0",
"@humus/http": "^1.0.0",
"@humus/inventory": "^1.0.0",
"@humus/universe": "^1.0.0",
"@inlet/react-pixi": "^6.0.7",
"@latus/core": "2.0.0",
"@latus/db": "2.0.0",
"@latus/governor": "2.0.0",
"@latus/http": "2.0.0",
"@latus/react": "2.0.0",
"@latus/redis": "2.0.0",
"@latus/redux": "^2.0.0",
"@latus/repl": "2.0.0",
"@latus/socket": "2.0.0",
"@latus/user": "2.0.0",
"dotenv": "^8.2.0"
},
"devDependencies": {
"@latus/build": "1.x"
}

7
packages/http/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
**/*.js
**/*.map
!/.*
!/postcss.config.js
!/webpack.config.js
!src/**/*.js
!/test/**/*.js

View File

Before

Width:  |  Height:  |  Size: 594 KiB

After

Width:  |  Height:  |  Size: 594 KiB

View File

Before

Width:  |  Height:  |  Size: 581 KiB

After

Width:  |  Height:  |  Size: 581 KiB

View File

@ -0,0 +1,48 @@
{
"name": "@humus/http",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"build": "latus-build",
"clean": "latus-build clean",
"dev": "latus-build -d --hot --watch --start-server --inspect",
"lint": "latus-build lint",
"test": "latus-build test"
},
"files": [
"client.js",
"client.js.map",
"index.js",
"index.js.map",
"test.js",
"test.js.map"
],
"dependencies": {
"@avocado/graphics": "^2.0.0",
"@avocado/input": "^2.0.0",
"@avocado/math": "^2.0.0",
"@avocado/timing": "^2.0.0",
"@avocado/topdown": "^2.0.0",
"@humus/core": "^1.0.0",
"@humus/universe": "^1.0.0",
"@inlet/react-pixi": "^6.0.7",
"@latus/redux": "^2.0.0",
"@latus/socket": "2.0.0",
"@latus/user": "2.0.0",
"@latus/react": "2.0.0",
"classnames": "^2.2.6",
"connected-react-router": "^6.8.0",
"dotenv": "8.2.0",
"electron": "^11.1.1",
"history": "^4.7.2",
"is-electron": "^2.2.0",
"pixi.js-legacy": "^5.3.7",
"react-hot-loader": "4.13.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"screenfull": "^5.1.0"
},
"devDependencies": {
"@latus/build": "^1.0.0"
}
}

View File

@ -1,22 +1,11 @@
import './index.scss';
import React from 'react';
import {connectRouter, routerMiddleware} from 'connected-react-router';
import Humus from 'components/humus';
import history from './history';
const Index = () => (
<>
<Humus history={history} />
</>
);
import App from './components/app';
import history from './components/app/history';
export default {
hooks: {
'@latus/react/components': () => Index,
'@latus/react/components': () => App,
'@latus/redux/slices': () => ({
router: connectRouter(history),
}),

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,13 @@
import './index.scss';
import {React} from '@latus/react';
import Humus from '../humus';
import history from './history';
export default () => (
<>
<Humus history={history} />
</>
);

View File

@ -1,4 +1,4 @@
@import 'scss/colors.scss';
@import '../../scss/colors.scss';
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
@ -298,6 +298,6 @@ select {
@font-face {
font-family: "joystix";
src:
url("/joystix-monospace.ttf") format("truetype")
url("./fonts/joystix-monospace.ttf") format("truetype")
;
}

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,23 +2,22 @@ import './humus.scss';
import {hot} from 'react-hot-loader';
import {PropTypes, React} from '@latus/react';
import {ConnectedRouter} from 'connected-react-router';
import PropTypes from 'prop-types';
import React from 'react';
import {
Redirect,
Route,
Switch,
} from 'react-router-dom';
import Login from 'components/login';
import Play from 'components/play';
import Renderer from 'components/renderer';
import Title from 'components/title';
import Ui from 'components/ui';
import Universe from 'components/universe';
import useIsNative from '../hooks/use-is-native';
import useIsNative from 'hooks/use-is-native';
import Login from './login';
import Play from './play';
import Renderer from './renderer';
import Title from './title';
import Ui from './ui';
import Universe from './universe';
const WIDTH = 1600;
const HEIGHT = 900;

View File

@ -1,4 +1,4 @@
import React from 'react';
import {React} from '@latus/react';
import LatusLogin from '@latus/user/client/components/login';

View File

@ -1,13 +1,12 @@
import './index.scss';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import {PropTypes, React} from '@latus/react';
import ItemSlot from 'components/play/item-slot';
import usePropertyChange from '../../../hooks/use-property-change';
import useInventorySlice from '../../../hooks/use-inventory-slice';
import usePropertyChange from 'hooks/use-property-change';
import useInventorySlice from 'hooks/use-inventory-slice';
import ItemSlot from '../item-slot';
const HotbarComponent = (props) => {
const {selfEntity} = props;

View File

@ -1,4 +1,4 @@
@import 'scss/graphics.scss';
@import '../../../scss/graphics.scss';
.hotbar {
position: absolute;

View File

@ -3,15 +3,15 @@ import './index.scss';
import {join} from 'path';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import {
PropTypes,
React,
useCallback,
useLatus,
useState,
} from '@latus/react';
import useEvent from 'hooks/use-event';
import useEvent from '../../../hooks/use-event';
const ItemSlotComponent = (props) => {
const {

View File

@ -1,4 +1,4 @@
@import 'scss/graphics.scss';
@import '../../../scss/graphics.scss';
.item-slot {
border: 4px dashed rgba(0, 0, 0, 0.5);

View File

@ -1,11 +1,10 @@
// TODO should be betta
import 'pixi.js-legacy';
import {LatusContext, useLatus} from '@latus/react';
import {LatusContext, React, useLatus} from '@latus/react';
import {Provider, useStore} from '@latus/redux';
import React from 'react';
import {
__RouterContext,
__RouterContext as RouterContext,
} from 'react-router';
import {
Route,
@ -13,7 +12,7 @@ import {
useLocation,
} from 'react-router-dom';
import Stage from 'components/stage';
import Stage from '../stage';
import Dumb from './dumb';
import RoomView from './room-view';
@ -25,7 +24,7 @@ const Renderer = () => {
return (
<Stage width={320} height={180}>
<LatusContext.Provider value={latus}>
<__RouterContext.Provider value={{location}}>
<RouterContext.Provider value={{location}}>
<Provider store={store}>
<Switch>
<Route path="/login">
@ -36,7 +35,7 @@ const Renderer = () => {
</Route>
</Switch>
</Provider>
</__RouterContext.Provider>
</RouterContext.Provider>
</LatusContext.Provider>
</Stage>
);

View File

@ -1,4 +1,9 @@
import React, {useEffect, useMemo, useState} from 'react';
import {
React,
useEffect,
useMemo,
useState,
} from '@latus/react';
import {Container, Renderer} from '@avocado/graphics';
import {Vector} from '@avocado/math';

View File

@ -1,8 +1,7 @@
import './stage.scss';
import {Stage as PStage} from '@inlet/react-pixi';
import PropTypes from 'prop-types';
import React from 'react';
import {PropTypes, React} from '@latus/react';
const Stage = ({children, width, height}) => (
<div className="stage">

View File

@ -1,6 +1,6 @@
import './index.scss';
import React from 'react';
import {React} from '@latus/react';
import {
Redirect,

View File

@ -1,5 +1,5 @@
.title {
background-image: url('/rooted.jpg');
background-image: url('./rooted.jpg');
background-size: cover;
height: 100%;
position: absolute;

View File

@ -1,6 +1,6 @@
import './index.scss';
import React from 'react';
import {React} from '@latus/react';
import {
Link,
} from 'react-router-dom';

View File

@ -1,6 +1,6 @@
import './index.scss';
import React from 'react';
import {React} from '@latus/react';
import {
Link,
} from 'react-router-dom';

View File

@ -1,6 +1,6 @@
import './index.scss';
import React from 'react';
import {React} from '@latus/react';
import {
Link,
} from 'react-router-dom';

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

View File

@ -2,8 +2,7 @@ import './index.scss';
import {universesByLocalitySelector} from '@humus/universe';
import {useSelector} from '@latus/redux';
import PropTypes from 'prop-types';
import React from 'react';
import {PropTypes, React} from '@latus/react';
import Universe from './universe';

View File

@ -1,7 +1,6 @@
import './index.scss';
import PropTypes from 'prop-types';
import React from 'react';
import {PropTypes, React} from '@latus/react';
import {
Link,
} from 'react-router-dom';

View File

@ -1,4 +1,4 @@
@import 'scss/colors.scss';
@import '../../../../scss/colors.scss';
.universes-universe {
align-items: baseline;

View File

@ -1,7 +1,11 @@
import './ui.scss';
import PropTypes from 'prop-types';
import React, {useEffect, useRef} from 'react';
import {
PropTypes,
React,
useEffect,
useRef,
} from '@latus/react';
import screenfull from 'screenfull';
const Ui = ({children, width, height}) => {

View File

@ -12,7 +12,7 @@
.fullscreen {
background-color: transparent;
background-image: url('/arrow-inout.png');
background-image: url('./arrow-inout.png');
background-size: contain;
border: none;
font-size: 3em;

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

View File

@ -2,8 +2,7 @@ import './index.scss';
import {universesByLocalitySelector, universesSelector} from '@humus/universe';
import {useSelector} from '@latus/redux';
import PropTypes from 'prop-types';
import React from 'react';
import {PropTypes, React} from '@latus/react';
import {
Link,
Redirect,
@ -11,7 +10,7 @@ import {
useLocation,
} from 'react-router-dom';
import useIsNative from 'hooks/use-is-native';
import useIsNative from '../../hooks/use-is-native';
const Universe = ({match: {params: {uuid}}}) => {
const history = useHistory();

View File

@ -1,5 +1,5 @@
.universe {
background-image: url('/cave-mouth.jpg');
background-image: url('./cave-mouth.jpg');
background-position: bottom;
height: 100%;
position: absolute;

View File

@ -1,4 +1,4 @@
import {useEffect} from 'react';
import {useEffect} from '@latus/react';
export default function useEvent(object, eventName, fn) {
useEffect(() => {

View File

@ -1,4 +1,4 @@
import {useCallback, useState} from 'react';
import {useCallback, useState} from '@latus/react';
import useEvent from './use-event';

View File

@ -1,4 +1,4 @@
import {useCallback, useState} from 'react';
import {useCallback, useState} from '@latus/react';
import useEvent from './use-event';

View File

View File

@ -0,0 +1,5 @@
import {expect} from 'chai';
it('exists', () => {
expect(true).to.be.true;
});

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@ const neutrino = require('neutrino');
const server = require('./.neutrinorc');
const {
LATUS_EXCLUDE_BUILD = '',
LATUS_ONLY_BUILD = '',
} = process.env;
const excludeBuilds = LATUS_EXCLUDE_BUILD.split(',').map((name) => name.trim());
const onlyBuilds = LATUS_ONLY_BUILD.split(',').map((name) => name.trim());
module.exports = process.env.LATUS_LINTING
? neutrino(server).webpack()
@ -25,7 +25,7 @@ module.exports = process.env.LATUS_LINTING
.reduce(
(r, [name, config]) => ({
...r,
...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}),
...(-1 === onlyBuilds.indexOf(name) ? {} : {[name]: config}),
}),
{},
)

6923
yarn.lock

File diff suppressed because it is too large Load Diff