feat: entity view

This commit is contained in:
cha0s 2021-01-24 21:47:44 -06:00
parent b351f4484a
commit a03e482852
9 changed files with 140 additions and 5 deletions

View File

@ -15,8 +15,17 @@
}, },
"dependencies": { "dependencies": {
"@avocado/behavior": "^2.0.0", "@avocado/behavior": "^2.0.0",
"@avocado/core": "^2.0.0",
"@avocado/entity": "^2.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/resource": "^2.0.0",
"@avocado/s13n": "^2.0.0",
"@avocado/sound": "^1.0.0",
"@avocado/timing": "^2.0.0",
"@avocado/topdown": "^2.0.0",
"@avocado/traits": "^2.0.0", "@avocado/traits": "^2.0.0",
"@latus/core": "^2.0.0", "@latus/core": "^2.0.0",
"@latus/db": "^2.0.0", "@latus/db": "^2.0.0",

View File

@ -3,8 +3,10 @@
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
.sidebar { .sidebar {
padding: 1em; height: 100%;
min-width: 25rem; min-width: 25rem;
overflow: auto;
padding: 1em;
} }
.m-tree > .m-node { .m-tree > .m-node {
> .children { > .children {

View File

@ -1,5 +1,8 @@
import './index.scss'; import './index.scss';
import {join} from 'path';
import {Resource} from '@avocado/resource';
import {PropTypes, React} from '@latus/react'; import {PropTypes, React} from '@latus/react';
import {useSelector} from '@latus/redux'; import {useSelector} from '@latus/redux';
import {projectsSelector} from '@persea/core'; import {projectsSelector} from '@persea/core';
@ -8,6 +11,7 @@ import Project from '../index';
const ProjectRoute = ({match: {params: {uuid}}}) => { const ProjectRoute = ({match: {params: {uuid}}}) => {
const {projects} = useSelector(projectsSelector); const {projects} = useSelector(projectsSelector);
Resource.root = join('/projects', uuid);
return <Project uuid={uuid} project={projects[uuid]} />; return <Project uuid={uuid} project={projects[uuid]} />;
}; };

View File

@ -64,7 +64,7 @@
debug "4.3.1" debug "4.3.1"
image-size "^0.9.3" image-size "^0.9.3"
"@avocado/input@2.0.0": "@avocado/input@2.0.0", "@avocado/input@^2.0.0":
version "2.0.0" version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2finput/-/input-2.0.0.tgz#b4b9a0753ecdd10ff23e5a19d7caecb2f30b9da0" resolved "http://npm.cha0sdev/@avocado%2finput/-/input-2.0.0.tgz#b4b9a0753ecdd10ff23e5a19d7caecb2f30b9da0"
integrity sha512-DWvKaKugOP4HVSU/UUcEL17afz5RK2+tVm/e2oGOLj5Sz2KK4OVmspylWt4AgDB7kceJ2n+Tu94BsR2bBf5/ig== integrity sha512-DWvKaKugOP4HVSU/UUcEL17afz5RK2+tVm/e2oGOLj5Sz2KK4OVmspylWt4AgDB7kceJ2n+Tu94BsR2bBf5/ig==
@ -73,7 +73,7 @@
"@latus/socket" "2.0.0" "@latus/socket" "2.0.0"
debug "4.3.1" debug "4.3.1"
"@avocado/math@2.0.0": "@avocado/math@2.0.0", "@avocado/math@^2.0.0":
version "2.0.0" version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fmath/-/math-2.0.0.tgz#0e314ceed56997588045ffb0e4c3202308df8811" resolved "http://npm.cha0sdev/@avocado%2fmath/-/math-2.0.0.tgz#0e314ceed56997588045ffb0e4c3202308df8811"
integrity sha512-cpyQzHuB7fTlJy+5uAYyrekPbuJsGNkqhmIS+rjBwDncr0BZ9+pRxl4GUxrm/6WL4ebkFX1FdsGfSnnZ8TWlQw== integrity sha512-cpyQzHuB7fTlJy+5uAYyrekPbuJsGNkqhmIS+rjBwDncr0BZ9+pRxl4GUxrm/6WL4ebkFX1FdsGfSnnZ8TWlQw==
@ -83,6 +83,29 @@
d3-quadtree "^2.0.0" d3-quadtree "^2.0.0"
debug "4.3.1" debug "4.3.1"
"@avocado/physics@^1.0.0":
version "1.0.0"
resolved "http://npm.cha0sdev/@avocado%2fphysics/-/physics-1.0.0.tgz#8d07cad7ff928dce0edd1118b69dde047b999862"
integrity sha512-Tl4enel7xWOWzhNVU8SM8eI6l6DwfLg7sDfzcfJI78Oc+oDzdrFOznaXxdjOV6vefIjO/q626EYDN0QPH5SxOw==
dependencies:
"@avocado/behavior" "^2.0.0"
"@avocado/core" "^2.0.0"
"@avocado/entity" "^2.0.0"
"@avocado/graphics" "^2.0.0"
"@avocado/math" "^2.0.0"
"@avocado/resource" "^2.0.0"
"@avocado/s13n" "^2.0.0"
"@avocado/timing" "^2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "^2.0.0"
debug "4.3.1"
deepmerge "^4.2.2"
immutable "^4.0.0-rc.12"
kefir "^3.8.8"
matter-js "0.14.2"
poly-decomp "0.3.0"
proton-engine "^4.2.1"
"@avocado/resource@2.0.0", "@avocado/resource@^2.0.0": "@avocado/resource@2.0.0", "@avocado/resource@^2.0.0":
version "2.0.0" version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2fresource/-/resource-2.0.0.tgz#590ab5b6abfcfc222ab45f7173d0481d077a2b57" resolved "http://npm.cha0sdev/@avocado%2fresource/-/resource-2.0.0.tgz#590ab5b6abfcfc222ab45f7173d0481d077a2b57"
@ -105,7 +128,18 @@
debug "4.3.1" debug "4.3.1"
msgpack-lite "^0.1.26" msgpack-lite "^0.1.26"
"@avocado/timing@2.0.0": "@avocado/sound@^1.0.0":
version "1.0.0"
resolved "http://npm.cha0sdev/@avocado%2fsound/-/sound-1.0.0.tgz#f623da165638976d3b5e202e215cae3223e152ef"
integrity sha512-ooCpXkJcwRMLO13lWAn7ZGyEkpunljyWblEOt/b7wPmKYo6IJG5miLqW/ITQaiETqnr77MPcOkoSbLaHc8TC9Q==
dependencies:
"@avocado/resource" "^2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "^2.0.0"
debug "4.3.1"
howler "2.1.2"
"@avocado/timing@2.0.0", "@avocado/timing@^2.0.0":
version "2.0.0" version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2ftiming/-/timing-2.0.0.tgz#63738a29a1040e454192bcccd77d1901096bfc69" resolved "http://npm.cha0sdev/@avocado%2ftiming/-/timing-2.0.0.tgz#63738a29a1040e454192bcccd77d1901096bfc69"
integrity sha512-ow6eown7Bb3TtufWwhURjbszIcXTAMzB4skbKCA8nroSK2dxbGlgXzh5MXcFa56I+C6CQJNbKGMg+HdwvyoAKg== integrity sha512-ow6eown7Bb3TtufWwhURjbszIcXTAMzB4skbKCA8nroSK2dxbGlgXzh5MXcFa56I+C6CQJNbKGMg+HdwvyoAKg==
@ -120,6 +154,22 @@
debug "4.3.1" debug "4.3.1"
lodash.mapvalues "^4.6.0" lodash.mapvalues "^4.6.0"
"@avocado/topdown@^2.0.0":
version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2ftopdown/-/topdown-2.0.0.tgz#538b65562f69cfdba57545b485d3ceea74558b8d"
integrity sha512-lcmWxTt6xJexzgt3Ur23pIJH26odk/YwaMKlc8+TCPZi1FBUJwYAWFAXGgaOgo84pXDZL3qsMRhPw0ckQ8g/aw==
dependencies:
"@avocado/core" "2.0.0"
"@avocado/entity" "^2.0.0"
"@avocado/graphics" "2.0.0"
"@avocado/math" "2.0.0"
"@avocado/resource" "2.0.0"
"@avocado/s13n" "2.0.0"
"@avocado/traits" "^2.0.0"
"@latus/core" "2.0.0"
"@latus/socket" "^2.0.0"
debug "4.3.1"
"@avocado/traits@^2.0.0": "@avocado/traits@^2.0.0":
version "2.0.0" version "2.0.0"
resolved "http://npm.cha0sdev/@avocado%2ftraits/-/traits-2.0.0.tgz#4308132bb42a9765a47c8e5c4f15ae9dccbf8425" resolved "http://npm.cha0sdev/@avocado%2ftraits/-/traits-2.0.0.tgz#4308132bb42a9765a47c8e5c4f15ae9dccbf8425"
@ -5024,6 +5074,11 @@ hosted-git-info@^2.1.4:
resolved "http://npm.cha0sdev/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488" resolved "http://npm.cha0sdev/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg== integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
howler@2.1.2:
version "2.1.2"
resolved "http://npm.cha0sdev/howler/-/howler-2.1.2.tgz#8433a09d8fe84132a3e726e05cb2bd352ef8bd49"
integrity sha512-oKrTFaVXsDRoB/jik7cEpWKTj7VieoiuzMYJ7E/EU5ayvmpRhumCv3YQ3823zi9VTJkSWAhbryHnlZAionGAJg==
hpack.js@^2.1.6: hpack.js@^2.1.6:
version "2.1.6" version "2.1.6"
resolved "http://npm.cha0sdev/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" resolved "http://npm.cha0sdev/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2"
@ -5243,6 +5298,11 @@ immer@^8.0.0:
resolved "http://npm.cha0sdev/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" resolved "http://npm.cha0sdev/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656"
integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA== integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA==
immutable@^4.0.0-rc.12:
version "4.0.0-rc.12"
resolved "http://npm.cha0sdev/immutable/-/immutable-4.0.0-rc.12.tgz#ca59a7e4c19ae8d9bf74a97bdf0f6e2f2a5d0217"
integrity sha512-0M2XxkZLx/mi3t8NVwIm1g8nHoEmM9p9UBl/G9k4+hm0kBgOVdMV/B3CY5dQ8qG8qc80NN4gDV4HQv6FTJ5q7A==
import-cwd@^2.0.0: import-cwd@^2.0.0:
version "2.1.0" version "2.1.0"
resolved "http://npm.cha0sdev/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9" resolved "http://npm.cha0sdev/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
@ -5818,6 +5878,11 @@ jsprim@^1.2.2:
array-includes "^3.1.2" array-includes "^3.1.2"
object.assign "^4.1.2" object.assign "^4.1.2"
kefir@^3.8.8:
version "3.8.8"
resolved "http://npm.cha0sdev/kefir/-/kefir-3.8.8.tgz#235932ddfbed422acebf5d7cba503035e9ea05c5"
integrity sha512-xWga7QCZsR2Wjy2vNL3Kq/irT+IwxwItEWycRRlT5yhqHZK2fmEhziP+LzcJBWSTAMranGKtGTQ6lFpyJS3+jA==
keyv@^3.0.0: keyv@^3.0.0:
version "3.1.0" version "3.1.0"
resolved "http://npm.cha0sdev/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" resolved "http://npm.cha0sdev/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9"
@ -6150,6 +6215,11 @@ matcher@^3.0.0:
dependencies: dependencies:
escape-string-regexp "^4.0.0" escape-string-regexp "^4.0.0"
matter-js@0.14.2:
version "0.14.2"
resolved "http://npm.cha0sdev/matter-js/-/matter-js-0.14.2.tgz#8169af9e06fdc356ba9e72b49624eb329839883b"
integrity sha512-3ttVT8cJlQnGRjBa8MyVrGyvGmnmOkZ3YsyemIw+KwEEdVi70mo32FH1Eta2b3GfdDJFbMDRqyMQt4heNKBUEA==
md5.js@^1.3.4: md5.js@^1.3.4:
version "1.3.5" version "1.3.5"
resolved "http://npm.cha0sdev/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" resolved "http://npm.cha0sdev/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
@ -7417,6 +7487,11 @@ pkg-dir@^4.1.0:
dependencies: dependencies:
find-up "^4.0.0" find-up "^4.0.0"
poly-decomp@0.3.0:
version "0.3.0"
resolved "http://npm.cha0sdev/poly-decomp/-/poly-decomp-0.3.0.tgz#aa499289bbc1a4ca2213e966587fa5bffc1ca5f5"
integrity sha512-hWeBxGzPYiybmI4548Fca7Up/0k1qS5+79cVHI9+H33dKya5YNb9hxl0ZnDaDgvrZSuYFBhkCK/HOnqN7gefkQ==
portfinder@^1.0.26: portfinder@^1.0.26:
version "1.0.28" version "1.0.28"
resolved "http://npm.cha0sdev/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" resolved "http://npm.cha0sdev/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778"
@ -7568,6 +7643,11 @@ proto-list@~1.2.1:
resolved "http://npm.cha0sdev/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" resolved "http://npm.cha0sdev/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk= integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=
proton-engine@^4.2.1:
version "4.2.1"
resolved "http://npm.cha0sdev/proton-engine/-/proton-engine-4.2.1.tgz#db938e4f673ddbd91ac70628b0733283a4571ef7"
integrity sha512-c72hgcnwMyyvUoy7Jq/HX3HQZnAo5MUNvFbyZHiWZrwcERX9+lYzM9YyT0iueXVAJpt+r8nrPan9F3HTXj7IsA==
proxy-addr@^2.0.6, proxy-addr@~2.0.5: proxy-addr@^2.0.6, proxy-addr@~2.0.5:
version "2.0.6" version "2.0.6"
resolved "http://npm.cha0sdev/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf" resolved "http://npm.cha0sdev/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"

View File

@ -26,6 +26,7 @@
"@latus/react": "^2.0.0", "@latus/react": "^2.0.0",
"autoprefixer": "^9.8.6", "autoprefixer": "^9.8.6",
"debug": "4.3.1", "debug": "4.3.1",
"express": "^4.17.1",
"glob": "^7.1.6", "glob": "^7.1.6",
"lodash.flatten": "^4.4.0", "lodash.flatten": "^4.4.0",
"natsort": "^2.0.2", "natsort": "^2.0.2",

View File

@ -3,10 +3,13 @@ import {join} from 'path';
import {promisify} from 'util'; import {promisify} from 'util';
import {decorateWithLatus, gatherWithLatus} from '@latus/core'; import {decorateWithLatus, gatherWithLatus} from '@latus/core';
import express from 'express';
const readFile = promisify(fs.readFile).bind(fs); const readFile = promisify(fs.readFile).bind(fs);
const stat = promisify(fs.stat).bind(fs); const stat = promisify(fs.stat).bind(fs);
const resources = express.static(join(process.cwd(), 'projects'));
export default { export default {
hooks: { hooks: {
'@latus/db/server/models': gatherWithLatus( '@latus/db/server/models': gatherWithLatus(
@ -16,6 +19,10 @@ export default {
require.context('../models/decorators', false, /\.js$/), require.context('../models/decorators', false, /\.js$/),
), ),
'@latus/http/server/request.socket': () => (req, res, next) => { '@latus/http/server/request.socket': () => (req, res, next) => {
if (req.url.startsWith('/projects')) {
resources(req, res, next);
return;
}
if (req.url.startsWith('/project')) { if (req.url.startsWith('/project')) {
req.url = '/'; req.url = '/';
} }

View File

@ -9,6 +9,7 @@ import {
} from 'react-tabs'; } from 'react-tabs';
import Traits from './traits'; import Traits from './traits';
import View from './view';
const EntityRendererComponent = ({buffer}) => { const EntityRendererComponent = ({buffer}) => {
const json = JSON.parse(buffer.toString()); const json = JSON.parse(buffer.toString());
@ -19,7 +20,9 @@ const EntityRendererComponent = ({buffer}) => {
<TabPanel> <TabPanel>
<Traits json={json.traits} /> <Traits json={json.traits} />
</TabPanel> </TabPanel>
<TabPanel /> <TabPanel>
<View json={json} />
</TabPanel>
</div> </div>
<div className="entity-renderer__workspaceTabs"> <div className="entity-renderer__workspaceTabs">
<TabList> <TabList>

View File

@ -0,0 +1,29 @@
import './index.scss';
import {PropTypes, React} from '@latus/react';
import {useLatus} from '@latus/react/client';
const {useEffect, useState} = React;
const View = ({json}) => {
const latus = useLatus();
const {Entity} = latus.get('%resources');
const [entity, setEntity] = useState(new Entity());
useEffect(() => {
const loadEntity = async () => {
setEntity(await Entity.load(json));
};
loadEntity();
}, [Entity, json]);
return (
<div className="view">
{entity.is('Visible') ? 'visible' : 'not visible'}
</div>
);
};
View.propTypes = {
json: PropTypes.shape({}).isRequired,
};
export default View;