Skip to content

Commit

Permalink
preact: convert to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed May 26, 2019
1 parent 2b30756 commit 3f52934
Show file tree
Hide file tree
Showing 21 changed files with 4,515 additions and 3,261 deletions.
14 changes: 14 additions & 0 deletions preact/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { src, dest, task } = require("gulp");
const clean = require('gulp-clean');
const inlinesource = require('gulp-inline-source');

task('clean', () => {
return src('build', {read: false, allowEmpty: true})
.pipe(clean());
});

task('default', () => {
return src('build/index.html')
.pipe(inlinesource())
.pipe(dest('../src/'));
});
33 changes: 28 additions & 5 deletions preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,39 @@
"author": "Shuanglei Tao <tsl0922@gmail.com>",
"license": "MIT",
"scripts": {
"start": "preact watch",
"build": "preact build --no-service-worker --no-prerender"
"prestart": "gulp clean",
"start": "webpack-dev-server",
"build": "NODE_ENV=production webpack && gulp",
"lint": "tslint -c tslint.json 'src/**/*.ts'"
},
"devDependencies": {
"preact-cli": "^2.2.1"
"copy-webpack-plugin": "^5.0.3",
"css-loader": "^1.0.1",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-inline-source": "^4.0.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.3.0",
"ts-loader": "^6.0.1",
"tslint": "^5.16.0",
"tslint-consistent-codestyle": "^1.15.1",
"tslint-loader": "^3.5.4",
"typescript": "^3.4.5",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.4.1",
"webpack-merge": "^4.2.1"
},
"dependencies": {
"decko": "^1.2.0",
"fast-text-encoding": "^1.0.0",
"preact": "^8.4.2",
"xterm": "^3.12.2"
"preact-compat": "^3.18.5",
"preact-router": "^2.6.1",
"xterm": "^3.13.2"
}
}
19 changes: 0 additions & 19 deletions preact/preact.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions preact/src/.babelrc

This file was deleted.

Binary file removed preact/src/assets/favicon.ico
Binary file not shown.
15 changes: 0 additions & 15 deletions preact/src/components/app.js

This file was deleted.

45 changes: 45 additions & 0 deletions preact/src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { h, Component } from 'preact';

import { ITerminalOptions, ITheme } from 'xterm';
import Terminal from './terminal';

if ((module as any).hot) {
require('preact/debug');
}

const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
const wsPath = window.location.pathname.endsWith('/') ? 'ws' : '/ws';
const url = [protocol, window.location.host, window.location.pathname, wsPath, window.location.search].join('');
const termOptions = {
fontSize: 13,
fontFamily: '"Menlo for Powerline", Menlo, Consolas, "Liberation Mono", Courier, monospace',
theme: {
foreground: '#d2d2d2',
background: '#2b2b2b',
cursor: '#adadad',
black: '#000000',
red: '#d81e00',
green: '#5ea702',
yellow: '#cfae00',
blue: '#427ab3',
magenta: '#89658e',
cyan: '#00a7aa',
white: '#dbded8',
brightBlack: '#686a66',
brightRed: '#f54235',
brightGreen: '#99e343',
brightYellow: '#fdeb61',
brightBlue: '#84b0d8',
brightMagenta: '#bc94b7',
brightCyan: '#37e6e8',
brightWhite: '#f1f1f0'
} as ITheme
} as ITerminalOptions;

export default class App extends Component {
public render() {
return (
<Terminal id='terminal-container' url={url} options={termOptions} />
);
}
}
177 changes: 0 additions & 177 deletions preact/src/components/terminal/index.js

This file was deleted.

0 comments on commit 3f52934

Please sign in to comment.