├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── .npmrc ├── @types ├── arraybuffer-mime │ └── index.d.ts ├── prettysize │ └── index.d.ts └── string-to-arraybuffer │ └── index.d.ts ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── examples └── embed │ └── index.html ├── package.json ├── public ├── favicon.ico ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.test.js ├── App.tsx ├── components │ ├── channel │ │ ├── Channel.tsx │ │ ├── ChatForm.tsx │ │ ├── SidePanel.tsx │ │ └── index.ts │ ├── embed │ │ ├── Embed.tsx │ │ └── index.ts │ ├── footer │ │ ├── Footer.tsx │ │ └── index.ts │ ├── functional │ │ ├── Clipboard.tsx │ │ ├── DragAndDrop.tsx │ │ ├── HelpTooltip.tsx │ │ ├── MaxWidthContainer.tsx │ │ ├── Tag.tsx │ │ └── Terminal.tsx │ ├── header │ │ ├── Header.tsx │ │ └── index.ts │ ├── home │ │ ├── Demo.tsx │ │ ├── GettingStarted.tsx │ │ ├── Hero.tsx │ │ ├── Home.tsx │ │ ├── OpenSource.tsx │ │ ├── SelfHost.tsx │ │ ├── Subscribe.tsx │ │ ├── SubscribeForm.tsx │ │ ├── UseCases.tsx │ │ └── index.ts │ └── notFound │ │ ├── NotFound.tsx │ │ └── index.ts ├── config │ ├── config.ts │ └── index.ts ├── global.ts ├── index.tsx ├── react-app-env.d.ts ├── serviceWorker.ts ├── theme.ts ├── themeContext.tsx ├── utils │ ├── changeFavicon.ts │ ├── generateRandomString.ts │ ├── getUrlParams.ts │ └── updateWindowTitle.ts └── ws │ └── index.ts ├── tsconfig.json ├── tsconfig.paths.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | # use line feed 8 | end_of_line = lf 9 | 10 | # ensure file ends with a newline when saving 11 | insert_final_newline = true 12 | 13 | # soft tabs 14 | indent_style = space 15 | 16 | # number of columns used for each indentation level 17 | indent_size = 2 18 | 19 | # remove any whitespace characters preceding newline characters 20 | trim_trailing_whitespace = true 21 | 22 | # character set 23 | charset = utf-8 24 | 25 | max_line_length = 80 26 | 27 | [*.md] 28 | max_line_length = 0 29 | trim_trailing_whitespace = false 30 | 31 | [COMMIT_EDITMSG] 32 | max_line_length = 0 33 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [miguelmota] 2 | patreon: miguelmota 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # release 15 | /release 16 | 17 | # misc 18 | .DS_Store 19 | .env.local 20 | .env.development.local 21 | .env.test.local 22 | .env.production.local 23 | 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | .DS_Store 29 | 30 | *.tar.gz 31 | 32 | package-lock.json 33 | yarn.lock 34 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | npm_config_save_exact=true 3 | -------------------------------------------------------------------------------- /@types/arraybuffer-mime/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'arraybuffer-mime' 2 | -------------------------------------------------------------------------------- /@types/prettysize/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'prettysize' 2 | -------------------------------------------------------------------------------- /@types/string-to-arraybuffer/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'string-to-arraybuffer' 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@github.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT license 2 | 3 | Copyright (C) 2014 Miguel Mota 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | build: 3 | npm run build 4 | 5 | .PHONY: gzip 6 | gzip: 7 | mkdir -p release 8 | tar -cv build/ | gzip > release/streamhut-web.tar.gz 9 | 10 | .PHONY: unzip 11 | unzip: 12 | tar -zxvf release/streamhut-web.tar.gz 13 | 14 | .PHONY: release 15 | release: build gzip 16 | git tag $(version) 17 | hub release create -a release/streamhut-web.tar.gz -m '$(version)' $(version) 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # streamhut-web 2 | 3 | > Web app for [streamhut](https://github.com/streamhut/streamhut) 4 | 5 | [![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/streamhut/web/master/LICENSE) 6 | 7 | ## Development 8 | 9 | Install dependencies: 10 | 11 | ```bash 12 | npm install 13 | ``` 14 | 15 | Start application: 16 | 17 | ```bash 18 | npm run dev 19 | ``` 20 | 21 | Build: 22 | 23 | ```bash 24 | npm run build 25 | ``` 26 | 27 | ## License 28 | 29 | [MIT](LICENSE) 30 | -------------------------------------------------------------------------------- /examples/embed/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@streamhut/web", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "@material-ui/core": "3.9.2", 6 | "@types/ansi-styles": "^3.2.1", 7 | "@types/jest": "26.0.0", 8 | "@types/lodash": "^4.14.157", 9 | "@types/node": "14.0.13", 10 | "@types/randomstring": "^1.1.6", 11 | "@types/react": "16.9.38", 12 | "@types/react-dom": "16.9.8", 13 | "@types/react-router-dom": "5.1.5", 14 | "@types/styled-components": "^5.1.1", 15 | "ansi-styles": "3.2.1", 16 | "arraybuffer-mime": "1.0.0", 17 | "chalk": "2.4.2", 18 | "clipboard": "2.0.4", 19 | "hyperlinkify": "0.0.3", 20 | "lodash": "4.17.11", 21 | "mdi-material-ui": "5.10.0", 22 | "moment": "2.24.0", 23 | "prettysize": "2.0.0", 24 | "randomstring": "1.1.5", 25 | "react": "16.8.4", 26 | "react-clipboard.js": "2.0.6", 27 | "react-dom": "16.8.4", 28 | "react-dropzone": "10.0.4", 29 | "react-router-dom": "5.0.0", 30 | "react-scripts": "2.1.8", 31 | "screenfull": "5.0.2", 32 | "string-to-arraybuffer": "1.0.2", 33 | "styled-components": "4.1.3", 34 | "typescript": "3.9.5", 35 | "xterm": "3.12.2" 36 | }, 37 | "scripts": { 38 | "start": "HOST=0.0.0.0 PORT=3000 NODE_PATH=./ SKIP_PREFLIGHT_CHECK=true BROWSER=none react-scripts --max-old-space-size=4096 start", 39 | "dev": "npm run start", 40 | "build": "NODE_ENV=production NODE_PATH=./ SKIP_PREFLIGHT_CHECK=true GENERATE_SOURCEMAP=false react-scripts build", 41 | "test": "react-scripts test", 42 | "eject": "react-scripts eject", 43 | "lint": "tslint --fix -c tslint.json src/*.{ts,tsx} src/**/*.{ts,tsx} src/**/**/*.{ts,tsx}" 44 | }, 45 | "eslintConfig": { 46 | "extends": "react-app" 47 | }, 48 | "browserslist": [ 49 | ">0.2%", 50 | "not dead", 51 | "not ie <= 11", 52 | "not op_mini all" 53 | ], 54 | "devDependencies": { 55 | "eslint-config-standard": "10.2.1", 56 | "eslint-config-standard-jsx": "6.0.2", 57 | "eslint-config-standard-react": "5.0.0", 58 | "standard": "12.0.1", 59 | "standardx": "5.0.0", 60 | "tslint": "5.20.0", 61 | "tslint-config-standard": "8.0.1", 62 | "tslint-etc": "1.5.6", 63 | "tslint-origin-ordered-imports-rule": "1.2.2", 64 | "tslint-react": "4.0.0" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/streamhut/web/4df4bb8834e942e36b4b48c69f4533b3ebc82403/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 29 | Streamhut 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | 55 | 56 | 57 |
58 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import App from './App' 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div') 7 | ReactDOM.render(, div) 8 | ReactDOM.unmountComponentAtNode(div) 9 | }) 10 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { BrowserRouter as Router, Route, Switch } from 'react-router-dom' 3 | import Home from 'src/components/home' 4 | import Channel from 'src/components/channel' 5 | import Embed from 'src/components/embed' 6 | import NotFound from 'src/components/notFound' 7 | import { ThemeProvider } from 'styled-components' 8 | import { lightTheme, darkTheme } from './theme' 9 | import { GlobalStyles } from './global' 10 | import ThemeContext, { ThemeContextProvider } from './themeContext' 11 | 12 | function App () { 13 | return ( 14 | 15 | 16 | {theme => 17 | 18 | <> 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | } 31 | 32 | 33 | ) 34 | } 35 | 36 | export default App 37 | -------------------------------------------------------------------------------- /src/components/channel/Channel.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { arrayBufferWithMime, arrayBufferMimeDecouple } from 'arraybuffer-mime' 3 | import styled from 'styled-components' 4 | import Header from 'src/components/header' 5 | import Footer from 'src/components/footer' 6 | import Terminal from 'src/components/functional/Terminal' 7 | import ChatForm from 'src/components/channel/ChatForm' 8 | import { getShareUrl } from 'src/config' 9 | import getUrlParams from 'src/utils/getUrlParams' 10 | import { updateWindowTitle, resetWindowTitle } from 'src/utils/updateWindowTitle' 11 | import { createWs } from 'src/ws' 12 | 13 | const UI = { 14 | SiteContainer: styled.main` 15 | display: flex; 16 | flex-direction: column; 17 | `, 18 | Header: styled.header` 19 | display: flex; 20 | justify-content: space-between; 21 | background: #e2e2e2; 22 | padding: 5px; 23 | position: relative; 24 | padding-right: 35px; 25 | `, 26 | Connections: styled.div` 27 | display: inline-block; 28 | width: auto; 29 | max-height: 120px; 30 | overflow: auto; 31 | font-size: 0.8rem; 32 | white-space: pre-wrap; 33 | margin-bottom: 2rem; 34 | background: rgba(239, 239, 239, 0.35); 35 | padding: 1rem; 36 | ` 37 | } 38 | 39 | interface Props { 40 | 41 | } 42 | 43 | interface State { 44 | messages: any[] 45 | shareUrl: string 46 | fullscreen: boolean 47 | fullscreenUrl: string 48 | channel: string 49 | terminalText: any 50 | writable: boolean 51 | } 52 | 53 | class Channel extends Component { 54 | lineNumber: number 55 | ws: any 56 | 57 | constructor (props: Props) { 58 | super(props) 59 | 60 | const channel = window.location.pathname.substr(3) 61 | 62 | const state = { 63 | messages: [], 64 | shareUrl: getShareUrl(channel), 65 | fullscreen: false, 66 | fullscreenUrl: '', 67 | channel, 68 | terminalText: null, 69 | writable: false 70 | } 71 | 72 | const urlParams = getUrlParams() 73 | if ('f' in urlParams) { 74 | this.setFullScreen() 75 | } 76 | 77 | let p = window.location.pathname 78 | let q = window.location.search 79 | 80 | this.lineNumber = 0 81 | 82 | state.fullscreenUrl = `${p}${q}${q.length ? '&' : '?'}f=1` 83 | this.state = state 84 | } 85 | 86 | componentDidMount () { 87 | this.ws = createWs(this.state.channel) 88 | 89 | /* 90 | const connectionsLog = document.querySelector(`#connections`) 91 | */ 92 | 93 | // function logMessage(data) { 94 | // connectionsLog.innerHTML = JSON.stringify(data, null, 2) 95 | // } 96 | 97 | this.ws.addEventListener('message', (event: any) => { 98 | this.handleIncomingMessage(event) 99 | }) 100 | 101 | this.ws.addEventListener(`open`, () => { 102 | console.log(`connected`) 103 | // this.readCachedMessages() 104 | }) 105 | 106 | this.ws.addEventListener(`close`, () => { 107 | console.log(`connection closed`) 108 | }) 109 | 110 | document.addEventListener('visibilitychange', () => { 111 | if (!document.hidden) { 112 | resetWindowTitle() 113 | } 114 | }, false) 115 | } 116 | 117 | render () { 118 | const { writable } = this.state 119 | 120 | return ( 121 | <> 122 | 123 |
126 | 127 | {/* 128 | 129 |

130 |         
131 | */} 132 | 133 | this.resizeOutputContainer()} 135 | channel={this.state.channel} 136 | onData={this.handleFormSubmit} 137 | writable={writable} 138 | onWritable={this.handleWritableChange} 139 | text={this.state.terminalText} /> 140 | 143 | 144 |