Coder Social home page Coder Social logo

console-io's Introduction

Console License NPM version

Web console used in Cloud Commander.

Console

Install

npm i console-io -g

Use as standalone

Start console, go to url http://localhost:1337

Hot keys

Key Operation
Ctrl + Z cancel input
Ctrl + L clear screen
Ctrl + C kill running task

For more details see Jq-console keyboard shortcuts.

API

Client API

Console(element [, options])

  • element - html element, or selector
  • options - (optional) {cwd}

When prefix set in server and client, you should use same prefix in html. For example, if you use prefix "any_prefix" you should connect console script in this way:

<script src="/any_prefix/console.js"></script>

addShortCuts(shortCuts)

  • shortCuts - object contain big letter and function.

Example: show alert on Ctrl + A:

async () => {
    const konsole = await Console();
    
    konsole.addShortCuts({
        A() {
            alert('hello');
        },
    });
};

getPromptText()

Get text of prompt.

setPromptText(text)

  • text - string of new text

Set new text of prompt.

focus()

Set focus on Console.

Server API

Console(options)

Could be used as middleware, or for init Console.

Console.listen(socket, {
    server, // when no socket
    online: true, // default
    prefix: '/console', // default
    prefixSocket: '/console', // default
    auth: (accept, reject) => (username, password) => {
        accept();
    },
});

Console.middle(options)

Middleware function if there is a need of init socket in another place.

Console({
    prefix: '/console', // default
    online: true, // default
});

Use as middleware

To use Console in your programs you should make local install:

npm i console-io express

And use it in your program

// server.js
const webconsole = require('console-io');
const http = require('http');
const express = require('express');

const app = express();
const server = http.createServer(app);

const port = 1337;
const ip = '0.0.0.0';

const online = true;
app
    .use(webconsole({
        server,
        online, // load jquery and socket.io from cdn
    }))
    .use(express.static(__dirname));

webconsole.listen({
    server,
});

server.listen(port, ip);
<!-- index.html -->

<div class="console"></div>
<script src="/console/console.js"></script>
<script>
    document.addEventListener('load', async () => {
        const konsole = await Console('.console', {
            prefix: 'console',
            env: {
                CURRENT_FILE: getCurrentFile(),
                CURRENT_APP: 'console-io'
            }
        });
        
        console.log('console ready')
        konsole.focus();
        
        function getCurrentFile() {
            return 'filename.txt';
        }
    });
</script>

License

MIT

console-io's People

Contributors

clochix avatar coderaiser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

console-io's Issues

angular view integrations

Hi, inside angular view as follow, my log show -1- -2- and don't call load,
any ideas ?

This is the webConsole view: {{ demo2 }}

<script src="libs/console-io/lib/client/console.js"></script> <script> (function() { 'use strict'; console.log('-1-'); window.addEventListener('load', load); console.log('-2-'); function load() { console.log('-3-'); window.removeEventListener('load', load); console.log('-4-'); Console('.console', function() { console.log('console ready') }); } })() </script>

some problems

"minify": "^1.4.1" not in package.json, otherwise system messages is:
1.
node node_modules/console-io/bin/console.js

module.js:340
throw err;
^
Error: Cannot find module 'minify'

ok, install minify...
and....
2. node node_modules/console-io/bin/console.js
node_modules/console-io/node_modules/minify/node_modules/checkup/lib/check.js:37
throw(Error(name + template));
^
Error: callback coud not be empty!

what is wrong ?

Column width not adjusted appropriately according to used character

Hi,
I noticed that often the name of folder or files are cut because lack of space. But in the same time, other columns that do not need the space (owner, mode, date) have too much space reserved. It would be better, if short columns only reserve the space they need and spent more space to name column.

TypeError: Cannot read property 'path' of undefined

I have a problem trying to get console-io working on a freshly installed linux box running Node.js 7.5.0.

The server would listen to port 1337 just fine, but as soon as I open http://:1337 it shows error messages on the console. In the front end, only a blank page is shown. Inspector show 500 error from http://:1337/console/modules.json

Maybe Socket.io API has changed? The version installed is [email protected]

root@arch-c1e2 / # npm i console-io -g
...

root@arch-c1e2 / # console
url: http://0.0.0.0:1337
TypeError: Cannot read property 'path' of undefined
    at Function.module.exports.getSocketPath (/usr/lib/node_modules/console-io/server/console.js:46:18)
    at modules.forEach (/usr/lib/node_modules/console-io/server/index.js:79:37)
    at Array.forEach (native)
    at _modulesFn (/usr/lib/node_modules/console-io/server/index.js:77:17)
    at currify (/usr/lib/node_modules/console-io/node_modules/currify/legacy/lib/currify.js:27:45)
    at again (/usr/lib/node_modules/console-io/node_modules/currify/legacy/lib/currify.js:30:24)
    at /usr/lib/node_modules/console-io/node_modules/currify/legacy/lib/currify.js:14:19
    at Layer.handle [as handle_request] (/usr/lib/node_modules/console-io/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/lib/node_modules/console-io/node_modules/express/lib/router/route.js:131:13)
    at _konsoleFn (/usr/lib/node_modules/console-io/server/index.js:116:5)
♥

root@arch-c1e2 / # node --version 
v7.5.0

Please improve client usage docs - remote log messaging

I'd like to use this to better debug hybrid mobile apps (ionic) and web apps in general.
The goal is to make it easy to log events that are sent across a socket and written to a remote web console. It is not clear from your docs how to do this.

I've also looked at client/console.js but can see nothing of this sort there. Is this even possible with this lib? How would I go about adding that feature? Any other better libs out there for this?
The ones I ave found look very dated or immature

I came upon this one which looks more recent

Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.