Skip to content

Commit

Permalink
feat(core): Created a separate simplyfied kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
FranklinWaller committed Dec 5, 2019
1 parent 10d009d commit 5f90a74
Show file tree
Hide file tree
Showing 43 changed files with 4,595 additions and 2,871 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"react/jsx-indent-props": [
"error",
4
],
"react/jsx-filename-extension": [
1,
{ "extensions": [".jsx", ".tsx"] }
]
},
"globals": {
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'babel-polyfill';
import App from './src/js/App';
import './src/scss/index.scss';
// import Sdk from '../SDK';
import InstanceBag from './src/js/InstanceBag';
import Configuration from './src/js/Configuration';
import packageJson from './package.json';

Expand Down
6,507 changes: 3,810 additions & 2,697 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 27 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,32 @@
"author": "PlayOS",
"license": "ISC",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@material-ui/core": "^4.6.0",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@material-ui/core": "^4.7.1",
"@material-ui/icons": "^4.5.1",
"@types/react-loadable": "^5.5.2",
"@types/react-resizable": "^1.7.1",
"@wasmer/wasm-terminal": "^0.4.7",
"@wasmer/wasm-transformer": "^0.4.7",
"@wasmer/wasm-terminal": "^0.5.0",
"@wasmer/wasm-transformer": "^0.5.0",
"@wasmer/wasmfs": "^0.5.0",
"babel-polyfill": "^6.26.0",
"classnames": "^2.2.6",
"connected-react-router": "^6.5.2",
"connected-react-router": "^6.6.1",
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"ethers": "^4.0.39",
"css-loader": "^3.2.1",
"ethers": "^4.0.40",
"inherits": "^2.0.4",
"jszip": "^3.2.2",
"keccak": "^2.1.0",
"material-ui": "^0.20.2",
"material-ui-dialogs": "^1.3.0",
"memfs": "^3.0.1",
"postcss-modules": "^1.4.1",
"prop-types": "^15.7.2",
"react": "^16.11.0",
"react": "^16.12.0",
"react-code-input": "^3.8.1",
"react-dom": "^16.11.0",
"react-dropzone": "^10.1.10",
"react-dom": "^16.12.0",
"react-dropzone": "^10.2.1",
"react-loadable": "^5.5.0",
"react-redux": "^7.1.3",
"react-rnd": "^10.1.1",
Expand All @@ -56,45 +59,45 @@
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"sass-loader": "^8.0.0",
"style-loader": "^1.0.0",
"style-loader": "^1.0.1",
"terminal-in-react": "^4.3.1",
"ts-loader": "^6.2.1",
"use-resize-observer": "^4.0.0",
"web3": "^1.2.2",
"web3": "^1.2.4",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/preset-env": "7.7.1",
"@babel/preset-react": "7.7.0",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/preset-env": "7.7.4",
"@babel/preset-react": "7.7.4",
"@types/classnames": "^2.2.9",
"@types/jszip": "^3.1.6",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.9.3",
"@types/react": "^16.9.14",
"@types/react-dom": "^16.9.4",
"@types/react-redux": "^7.1.5",
"@types/react-router": "^5.1.2",
"@types/react-router": "^5.1.3",
"@types/react-router-redux": "^5.0.18",
"@types/react-swipeable-views": "^0.13.0",
"@types/web3": "^1.2.2",
"babel-eslint": "10.0.3",
"babel-loader": "^8.0.6",
"documentation": "12.1.3",
"eslint": "6.6.0",
"documentation": "12.1.4",
"eslint": "6.7.2",
"eslint-config-airbnb": "^18.0.1",
"eslint-loader": "^3.0.2",
"eslint-plugin-babel": "5.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react": "^7.17.0",
"eslint-summary": "^1.0.0",
"jest": "^24.9.0",
"node-sass": "^4.13.0",
"standard-version": "^7.0.0",
"typescript": "^3.7.2",
"standard-version": "^7.0.1",
"typescript": "^3.7.3",
"url-loader": "^2.2.0"
}
}
14 changes: 12 additions & 2 deletions src/js/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ const config = {
domain: DEV_HOST + 'authentication/',
host: DEV_HOST,
homeUrl: DEV_HOST + 'home/',
provider: new RutileProvider('http://localhost:8545/', 866, '0x00c7109eb8c03ad5f4383ed0ccbc4035f167aacc'),
providerDetails: {
httpHost: 'http://localhost:8545/',
chainId: 929,
coreAddress: '0xc660ac9d984c1a65ab499c93e5749bdb0b4518f5',
},
provider: new RutileProvider('http://localhost:8545/', 929, '0xc660ac9d984c1a65ab499c93e5749bdb0b4518f5'),
coreAddress: '0xb8e0baafd907f3289dbdc0a5174ba786f4b78cf2',
},
production: {
Expand All @@ -21,7 +26,12 @@ const config = {
domain: '/',
host: '/',
homeUrl: '#/home',
provider: new RutileProvider('http://localhost:8545/', 866, '0x00c7109eb8c03ad5f4383ed0ccbc4035f167aacc'),
providerDetails: {
httpHost: 'http://localhost:8545/',
chainId: 929,
coreAddress: '0xc660ac9d984c1a65ab499c93e5749bdb0b4518f5',
},
provider: new RutileProvider('http://localhost:8545/', 929, '0xc660ac9d984c1a65ab499c93e5749bdb0b4518f5'),
coreAddress: '0xb8e0baafd907f3289dbdc0a5174ba786f4b78cf2',
},
};
Expand Down
8 changes: 5 additions & 3 deletions src/js/apps/Explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Collapse from '@material-ui/core/Collapse';
import ExpandLess from '@material-ui/icons/ExpandLess';
import ExpandMore from '@material-ui/icons/ExpandMore';
import InstanceBag from '../../InstanceBag';
import WasmFs from "@wasmer/wasmfs";
import Folder from './components/Folder';
import File from './components/File';
import Dirent from 'memfs/lib/Dirent';
import Dropzone from '../../components/molecules/Dropzone';
import Kernel from '../../kernel';
const styles = require('./Explorer.scss');

export default function Explorer() {
Expand All @@ -25,9 +25,11 @@ export default function Explorer() {
const [path, setPath] = React.useState('/');

React.useEffect(() => {
const wasmFs = InstanceBag.get<WasmFs>('fs');
const kernel = InstanceBag.get<Kernel>('kernel');
const { wasmFs } = kernel.fs;

const filesAndDirectories: any = wasmFs.fs.readdirSync(path, {
encoding: "utf8",
encoding: 'utf8',
withFileTypes: true,
});

Expand Down
16 changes: 7 additions & 9 deletions src/js/apps/Explorer/components/File/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import * as React from 'react';
import Dirent from 'memfs/lib/Dirent';
import InsertDriveFileOutlinedIcon from '@material-ui/icons/InsertDriveFileOutlined';
import WebIcon from '@material-ui/icons/Web';
import { getFileExtension, readFileAsync } from '../../../../services/FileSystemService';
import InstanceBag from '../../../../InstanceBag';
import { WasmFs } from '@wasmer/wasmfs';
import { getWappInformation } from '../../../../services/WappService';
import getFileExtension from '../../../../services/micro/getFileExtension';

const styles = require('./File.scss');

interface Props {
Expand All @@ -18,11 +16,11 @@ function getFileIcon(file: Dirent): any {
const fileName: any = file.name;
const fileExtension = getFileExtension(fileName);

switch(fileExtension) {
case 'wasm':
return <WebIcon className={styles.icon}/>
default:
return <InsertDriveFileOutlinedIcon className={styles.icon}/>
switch (fileExtension) {
case 'wasm':
return <WebIcon className={styles.icon}/>
default:
return <InsertDriveFileOutlinedIcon className={styles.icon}/>
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/js/apps/Explorer/components/Folder/Folder.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as React from 'react';
import Dirent from 'memfs/lib/Dirent';
import FolderIcon from '@material-ui/icons/Folder';
import { getFileExtension, readFileAsync } from '../../../../services/FileSystemService';
import InstanceBag from '../../../../InstanceBag';
import { WasmFs } from '@wasmer/wasmfs';
import getFileExtension from '../../../../services/micro/getFileExtension';
import { getWappInformation } from '../../../../services/WappService';

const styles = require('./Folder.scss');

const WAPP_EXTENSION = 'wapp';

interface Props {
folder: Dirent
folder: Dirent;
path: string;
onClick?: (folder: Dirent) => void;
}
Expand Down
15 changes: 7 additions & 8 deletions src/js/components/organims/AppTerminal/AppTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import WasmTerminal from "@wasmer/wasm-terminal/lib/unoptimized/wasm-terminal.es
// import '@wasmer/wasm-terminal/dist/xterm/xterm.css';
import TerminalService from '../../../services/TerminalService';
import InstanceBag from '../../../InstanceBag';
import Kernel from '../../../kernel';

const styles = require('./AppTerminal.scss');

Expand All @@ -18,21 +19,19 @@ function AppTerminal(props: Props) {
let wasmTerminal: any = null;

async function setup() {
const fs = InstanceBag.get<any>('fs');
const terminalService = new TerminalService(fs);

terminalService.setupEnv();
const kernel = InstanceBag.get<Kernel>('kernel');
const terminalService = new TerminalService(kernel.fs);

wasmTerminal = new WasmTerminal({
fetchCommand: terminalService.handleCommand,
wasmFs: fs,
wasmFs: kernel.fs.wasmFs,
});

wasmTerminal.xterm.setOption('cursorBlink', true);

wasmTerminal.open(terminalRef.current);
wasmTerminal.print("PlayOS Terminal [Version 1.0.0]");
wasmTerminal.print("Powered by Wasmer.io \n");
wasmTerminal.print('PlayOS Terminal [Version 1.0.0]');
wasmTerminal.print('Powered by Wasmer.io \n');
}

setup();
Expand All @@ -43,7 +42,7 @@ function AppTerminal(props: Props) {

return () => {
clearInterval(intervalId);
}
};
}, []);

return (
Expand Down
5 changes: 5 additions & 0 deletions src/js/components/organims/AppWindow/AppTitleBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ $window-border-radius: 5px;
z-index: 9999;
}

.placeholder {
width: 48px;
height: 48px;
}

@media screen and (min-width: $desktop-breakpoint) {
.appBar {
border-top-left-radius: $window-border-radius;
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/organims/AppWindow/AppTitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function AppTitleBar(props: Props) {

return (
<header className={styles.appBar} style={{ backgroundColor: props.process.app.theme_color }}>
<div></div>
<div className={styles.placeholder}></div>
{/* <IconButton aria-label="Back" style={{ color: textColor }}>
<ArrowBackIcon />
</IconButton> */}
Expand Down
41 changes: 41 additions & 0 deletions src/js/kernel/Kernel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Registry from './core/Registry';
import FileSystem from './core/FileSystem';
import IKernelProvider from './interfaces/IKernelProvider';
import VirtualMachine from './core/VirtualMachine';
import Encryption from './core/Encryption';

class Kernel {
registry: Registry;

fs: FileSystem;

vm: VirtualMachine;

encryption: Encryption;

privateSeed: string;

provider: IKernelProvider;

constructor(privateSeed: string, provider: IKernelProvider) {
this.privateSeed = privateSeed;
this.provider = provider;
}

/**
* "Boots" the kernel. This sets everything up (fs, vm, enc, etc)
*
* @memberof Kernel
*/
async boot() {
this.registry = new Registry({}, this.provider);
this.encryption = new Encryption(this.privateSeed);

this.provider.setKeys(this.encryption.createKey('provider'));

this.fs = await FileSystem.create(this.registry, this.provider);
this.vm = new VirtualMachine();
}
}

export default Kernel;
3 changes: 3 additions & 0 deletions src/js/kernel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 📀 PlayOS Kernel

The kernel for PlayOS is used across platforms for file storing and handling files. It can be used for different situations such as a headless version of PlayOS.
23 changes: 23 additions & 0 deletions src/js/kernel/apps/Airhorner.wapp/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "AppId",
"name": "Airhorner",
"short_name": "Airhorner",
"display": "standalone",
"background_color": "#2196F3",
"theme_color": "#2196F3",
"icons": [
{
"sizes": "512x512",
"src": "/images/touch/android-launchericon-512-512.png",
"type": "image/png"
}
],
"scope": "/",
"start_url": "/?homescreen=1",
"manifest_url": "https://airhorner.com/manifest.json",
"playos": {
"isPwa": true,
"isWasm": false,
"showTerminal": false
}
}
23 changes: 23 additions & 0 deletions src/js/kernel/apps/Terminal.wapp/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "AppId",
"name": "Terminal",
"short_name": "Terminal",
"display": "standalone",
"background_color": "#2196F3",
"theme_color": "#2196F3",
"icons": [
{
"sizes": "512x512",
"src": "/images/touch/android-launchericon-512-512.png",
"type": "image/png"
}
],
"scope": "/",
"start_url": "/?homescreen=1",
"manifest_url": "https://airhorner.com/manifest.json",
"playos": {
"isPwa": true,
"isWasm": false,
"showTerminal": false
}
}
Loading

0 comments on commit 5f90a74

Please sign in to comment.