Initial YakPanel commit
This commit is contained in:
5
YakPanel/static/build/addons/terminado/package.json
Normal file
5
YakPanel/static/build/addons/terminado/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "xterm.terminado",
|
||||
"main": "terminado.js",
|
||||
"private": true
|
||||
}
|
||||
134
YakPanel/static/build/addons/terminado/terminado.js
Normal file
134
YakPanel/static/build/addons/terminado/terminado.js
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*
|
||||
* This module provides methods for attaching a terminal to a terminado
|
||||
* WebSocket stream.
|
||||
*/
|
||||
|
||||
(function (attach) {
|
||||
if (typeof exports === 'object' && typeof module === 'object') {
|
||||
/*
|
||||
* CommonJS environment
|
||||
*/
|
||||
module.exports = attach(require('../../Terminal').Terminal);
|
||||
} else if (typeof define == 'function') {
|
||||
/*
|
||||
* Require.js is available
|
||||
*/
|
||||
define(['../../xterm'], attach);
|
||||
} else {
|
||||
/*
|
||||
* Plain browser environment
|
||||
*/
|
||||
attach(window.Terminal);
|
||||
}
|
||||
})(function (Terminal) {
|
||||
'use strict';
|
||||
|
||||
var exports = {};
|
||||
|
||||
/**
|
||||
* Attaches the given terminal to the given socket.
|
||||
*
|
||||
* @param {Terminal} term - The terminal to be attached to the given socket.
|
||||
* @param {WebSocket} socket - The socket to attach the current terminal.
|
||||
* @param {boolean} bidirectional - Whether the terminal should send data
|
||||
* to the socket as well.
|
||||
* @param {boolean} buffered - Whether the rendering of incoming data
|
||||
* should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
exports.terminadoAttach = function (term, socket, bidirectional, buffered) {
|
||||
bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional;
|
||||
term.socket = socket;
|
||||
|
||||
term._flushBuffer = function () {
|
||||
term.write(term._attachSocketBuffer);
|
||||
term._attachSocketBuffer = null;
|
||||
};
|
||||
|
||||
term._pushToBuffer = function (data) {
|
||||
if (term._attachSocketBuffer) {
|
||||
term._attachSocketBuffer += data;
|
||||
} else {
|
||||
term._attachSocketBuffer = data;
|
||||
setTimeout(term._flushBuffer, 10);
|
||||
}
|
||||
};
|
||||
|
||||
term._getMessage = function (ev) {
|
||||
var data = JSON.parse(ev.data)
|
||||
if( data[0] == "stdout" ) {
|
||||
if (buffered) {
|
||||
term._pushToBuffer(data[1]);
|
||||
} else {
|
||||
term.write(data[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
term._sendData = function (data) {
|
||||
socket.send(JSON.stringify(['stdin', data]));
|
||||
};
|
||||
|
||||
term._setSize = function (size) {
|
||||
socket.send(JSON.stringify(['set_size', size.rows, size.cols]));
|
||||
};
|
||||
|
||||
socket.addEventListener('message', term._getMessage);
|
||||
|
||||
if (bidirectional) {
|
||||
term.on('data', term._sendData);
|
||||
}
|
||||
term.on('resize', term._setSize);
|
||||
|
||||
socket.addEventListener('close', term.terminadoDetach.bind(term, socket));
|
||||
socket.addEventListener('error', term.terminadoDetach.bind(term, socket));
|
||||
};
|
||||
|
||||
/**
|
||||
* Detaches the given terminal from the given socket
|
||||
*
|
||||
* @param {Xterm} term - The terminal to be detached from the given socket.
|
||||
* @param {WebSocket} socket - The socket from which to detach the current
|
||||
* terminal.
|
||||
*/
|
||||
exports.terminadoDetach = function (term, socket) {
|
||||
term.off('data', term._sendData);
|
||||
|
||||
socket = (typeof socket == 'undefined') ? term.socket : socket;
|
||||
|
||||
if (socket) {
|
||||
socket.removeEventListener('message', term._getMessage);
|
||||
}
|
||||
|
||||
delete term.socket;
|
||||
};
|
||||
|
||||
/**
|
||||
* Attaches the current terminal to the given socket
|
||||
*
|
||||
* @param {WebSocket} socket - The socket to attach the current terminal.
|
||||
* @param {boolean} bidirectional - Whether the terminal should send data
|
||||
* to the socket as well.
|
||||
* @param {boolean} buffered - Whether the rendering of incoming data
|
||||
* should happen instantly or at a maximum
|
||||
* frequency of 1 rendering per 10ms.
|
||||
*/
|
||||
Terminal.prototype.terminadoAttach = function (socket, bidirectional, buffered) {
|
||||
return exports.terminadoAttach(this, socket, bidirectional, buffered);
|
||||
};
|
||||
|
||||
/**
|
||||
* Detaches the current terminal from the given socket.
|
||||
*
|
||||
* @param {WebSocket} socket - The socket from which to detach the current
|
||||
* terminal.
|
||||
*/
|
||||
Terminal.prototype.terminadoDetach = function (socket) {
|
||||
return exports.terminadoDetach(this, socket);
|
||||
};
|
||||
|
||||
return exports;
|
||||
});
|
||||
1
YakPanel/static/build/addons/terminado/terminado.min.js
vendored
Normal file
1
YakPanel/static/build/addons/terminado/terminado.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).terminado=e()}}(function(){return function i(f,s,u){function a(t,e){if(!s[t]){if(!f[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(_)return _(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=s[t]={exports:{}};f[t][0].call(o.exports,function(e){return a(f[t][1][e]||e)},o,o.exports,i,f,s,u)}return s[t].exports}for(var _="function"==typeof require&&require,e=0;e<u.length;e++)a(u[e]);return a}({1:[function(e,t,n){"use strict";function r(e,t,n,r){var o=e;n=void 0===n||n,o.__socket=t,o.__flushBuffer=function(){o.write(o.__attachSocketBuffer),o.__attachSocketBuffer=null},o.__pushToBuffer=function(e){o.__attachSocketBuffer?o.__attachSocketBuffer+=e:(o.__attachSocketBuffer=e,setTimeout(o.__flushBuffer,10))},o.__getMessage=function(e){var t=JSON.parse(e.data);"stdout"===t[0]&&(r?o.__pushToBuffer(t[1]):o.write(t[1]))},o.__sendData=function(e){t.send(JSON.stringify(["stdin",e]))},o.__setSize=function(e){t.send(JSON.stringify(["set_size",e.rows,e.cols]))},t.addEventListener("message",o.__getMessage),n&&o._core.register(o.onData(o.__sendData)),o._core.register(o.onResize(o.__setSize)),t.addEventListener("close",function(){return i(o,t)}),t.addEventListener("error",function(){return i(o,t)})}function i(e,t){var n=e;n.__dataListener.dispose(),(t=(n.__dataListener=void 0)===t?n.__socket:t)&&t.removeEventListener("message",n.__getMessage),delete n.__socket}Object.defineProperty(n,"__esModule",{value:!0}),n.terminadoAttach=r,n.terminadoDetach=i,n.apply=function(e){e.prototype.terminadoAttach=function(e,t,n){return r(this,e,t,n)},e.prototype.terminadoDetach=function(e){return i(this,e)}}},{}]},{},[1])(1)});
|
||||
Reference in New Issue
Block a user