Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"private": true,
"scripts": {
"dashboard": "node packages/dashboard/run",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why you was not able to run the dashboard. Sorry.

"build-nars-common": "cd packages/nars-common && yarn && ./generate_proto.sh && yarn build",
"build-nars": "cd packages/nars && yarn && yarn build",
"build-nars-client": "cd packages/nars-client && yarn build",
"build": "yarn build-nars-common && yarn build-nars && yarn build-nars-client"
},
"workspaces": [
"packages/nars",
"packages/dashboard",
"packages/nars-common",
"packages/nars-client",
"packages/reason-react-reconciler",
Expand Down
47 changes: 47 additions & 0 deletions packages/dashboard/Process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from "react";
import { spawn } from "child_process";

import stylesheet from "./stylesheet";

// type Props = {
// label: string;
// arg: string;
// width: string;
// height: string;
// top: string;
// right: string;
// left: string;
// };

const Pro = ({ width, height, top, right, left, label, arg }) => {
const [logs, setLogs] = React.useState([]);

React.useEffect(() => {
const subprocess = spawn("yarn", [arg], {
stdio: ["pipe", "pipe", "pipe"],
});

subprocess.stdout.on("data", data => {
setLogs(state => [data.toString("utf-8"), ...state]);
});

return () => subprocess.kill();
}, []);

return (
<box
label={label}
class={stylesheet.bordered}
top={top}
right={right}
left={left}
width={width}
height={height}
draggable={true}
>
<list items={logs} />
</box>
);
};

export default Pro;
53 changes: 53 additions & 0 deletions packages/dashboard/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import blessed from "blessed";
import { render } from "react-blessed";

import Process from "./Process";

const Core = () => {
return (
<element>
<Process label="Nars - TS" arg="build-nars-ts" height="50%" width="50%" />

<Process
label="Nars - RE"
arg="build-nars-re"
top="50%"
height="50%"
width="50%"
/>

<Process
label="Nars Client"
arg="build-nars-client"
right="0"
height="50%"
width="50%"
/>

<Process
label="Nars Common"
arg="build-nars-common"
top="50%"
right="0"
height="50%"
width="50%"
/>
</element>
);
};

/**
* Rendering the screen.
*/
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: "Nars core dashboard",
});

screen.key(["escape", "q", "C-c"], function(ch, key) {
return process.exit(0);
});

render(<Core />, screen);
45 changes: 45 additions & 0 deletions packages/dashboard/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react";
import blessed from "blessed";
import { render } from "react-blessed";

import Process from "./Process";

const Examples = () => {
return (
<element>
<Process label="Client" arg="build-client" height="50%" width="100%" />

<Process
label="Server"
arg="build-server"
top="50%"
height="50%"
width="70%"
/>

<Process
label="Common"
arg="build-common"
top="50%"
height="50%"
width="30%"
right="0"
/>
</element>
);
};

/**
* Rendering the screen.
*/
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: "Nars examples dashboard",
});

screen.key(["escape", "q", "C-c"], function(ch, key) {
return process.exit(0);
});

render(<Examples />, screen);
79 changes: 79 additions & 0 deletions packages/dashboard/full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from "react";
import blessed from "blessed";
import { render } from "react-blessed";

import Process from "./Process";

const Full = () => {
return (
<element>
<Process label="Client" arg="build-client" height="33%" width="50%" />

<Process
label="Server"
arg="build-server"
top="33%"
height="33%"
width="50%"
/>

<Process
label="Common"
arg="build-common"
top="66%"
height="33%"
width="50%"
/>

<Process
label="Nars - TS"
arg="build-nars-ts"
right="0"
height="25%"
width="50%"
/>

<Process
label="Nars - RE"
arg="build-nars-re"
top="25%"
right="0"
height="25%"
width="50%"
/>

<Process
label="Nars Client"
arg="build-nars-client"
top="50%"
right="0"
height="25%"
width="50%"
/>

<Process
label="Nars Common"
arg="build-nars-common"
top="75%"
right="0"
height="25%"
width="50%"
/>
</element>
);
};

/**
* Rendering the screen.
*/
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: "Nars dashboard",
});

screen.key(["escape", "q", "C-c"], function(ch, key) {
return process.exit(0);
});

render(<Full />, screen);
26 changes: 26 additions & 0 deletions packages/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "dashboard",
"version": "0.1.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build-client": "cd ../../examples/client && yarn start",
"build-server": "cd ../../examples/server && yarn start",
"build-common": "cd ../../examples/common && yarn build",
"build-nars-re": "cd ../nars && yarn re:watch",
"build-nars-ts": "cd ../nars && yarn watch",
"build-nars-client": "cd ../nars-client && yarn watch",
"build-nars-common": "cd ../nars-common && yarn watch"
},
"dependencies": {
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.6.0",
"blessed": "^0.1.81",
"react": "^16.9.0",
"react-blessed": "^0.6.1",
"react-devtools-core": "^3.6.3",
"ws": "^7.1.2"
}
}
20 changes: 20 additions & 0 deletions packages/dashboard/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require("@babel/register")({
presets: [["@babel/preset-env"], ["@babel/preset-react"]],
});

const argv = process.argv.slice(2);

const version = argv[0];
const versions = ["full", "examples", "core"];

if (versions.indexOf(version) === -1) {
console.warn(
"Invalid dashboard type %s selected. Must be one of:\n *",
version,
versions.join("\n * ")
);

process.exit(0);
}

require("./" + version);
14 changes: 14 additions & 0 deletions packages/dashboard/stylesheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const stylesheet = {
bordered: {
border: {
type: "line",
},
style: {
border: {
fg: "blue",
},
},
},
};

export default stylesheet;
3 changes: 2 additions & 1 deletion packages/nars-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"license": "MIT",
"private": false,
"scripts": {
"build": "tsc"
"build": "tsc",
"watch": "tsc --watch"
},
"peerDependencies": {
"react-native": ">=0.60.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/nars-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"license": "MIT",
"private": false,
"scripts": {
"build": "tsc"
"build": "tsc",
"watch": "tsc --watch"
},
"devDependencies": {
"prettier": "^1.18.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/nars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"license": "MIT",
"private": false,
"scripts": {
"build": "bsb -make-world && tsc && cp ./src/*.bs.js ./dist/"
"build": "bsb -make-world && tsc && cp ./src/*.bs.js ./dist/",
"re:watch": "bsb -make-world -w",
"watch": "tsc --watch"
},
"dependencies": {
"@types/analytics-node": "^3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/nars/src/ComponentRegistry.rei
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ let registerRawTextEncodedReactElementInitializer:
(string => Instance.encodedReactElement) => unit;

[@genType]
let createRawTextEncodedReactElement: string => Instance.encodedReactElement;
let createRawTextEncodedReactElement: string => Instance.encodedReactElement;
Loading