add new package

This commit is contained in:
lxsang
2020-08-06 23:21:42 +02:00
parent 694afc162d
commit 525badca3f
28 changed files with 1099 additions and 2 deletions

12
vTerm/README.md Normal file
View File

@ -0,0 +1,12 @@
# AntOS Virual Terminal
Terminal emulator to connect to remote server using AntOS Tunnel plugin.
Unlike wTerm that uses a dedicated websocket connection for each terminal to
communicate with remote terminal session via the Antd **wterm** plugin,
VTerm uses only one websocket connection for multiple terminal session
thanks to the Antd **tunnel** plugin.
VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel**
client side package

View File

@ -0,0 +1,12 @@
# AntOS Virual Terminal
Terminal emulator to connect to remote server using AntOS Tunnel plugin.
Unlike wTerm that uses a dedicated websocket connection for each terminal to
communicate with remote terminal session via the Antd **wterm** plugin,
VTerm uses only one websocket connection for multiple terminal session
thanks to the Antd **tunnel** plugin.
VTerm depends on the server side **tunnel** plugin and the AntOS **Antunnel**
client side package

173
vTerm/build/debug/main.css Normal file
View File

@ -0,0 +1,173 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/
/**
* Default styles for xterm.js
*/
.xterm {
font-feature-settings: "liga" 0;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.xterm.focus,
.xterm:focus {
outline: none;
}
.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 5;
}
.xterm .xterm-helper-textarea {
/*
* HACK: to fix IE's blinking cursor
* Move textarea out of the screen to the far left, so that the cursor is not visible.
*/
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}
.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}
.xterm .composition-view.active {
display: block;
}
.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
}
.xterm .xterm-screen {
position: relative;
}
.xterm .xterm-screen canvas {
position: absolute;
left: 0;
top: 0;
}
.xterm .xterm-scroll-area {
visibility: hidden;
}
.xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
top: 0;
left: -9999em;
line-height: normal;
}
.xterm {
cursor: text;
}
.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}
.xterm.xterm-cursor-pointer {
cursor: pointer;
}
.xterm.column-select.focus {
/* Column selection mode */
cursor: crosshair;
}
.xterm .xterm-accessibility,
.xterm .xterm-message {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 10;
color: transparent;
}
.xterm .live-region {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
.xterm-dim {
opacity: 0.5;
}
.xterm-underline {
text-decoration: underline;
}

167
vTerm/build/debug/main.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
{
"app":"vTerm",
"name":"Virtual Terminal",
"description":"Access Unix terminal from web",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.5-a",
"category":"System",
"iconclass":"fa fa-terminal",
"mimes":["none"],
"locales":{
"fr_FR": {
"Open terminal": "Ouvrir terminal",
"Edit": "Modifier",
"Please enter terminal URI": "Merci d'entrer l'URI du terminal",
"Unable to connect to: {0}": "Impossible de connecter a: {0}",
"Terminal connection closed": "Connexion terminal est fermee"
}
}
}

View File

@ -0,0 +1,5 @@
<afx-app-window apptitle="__(Terminal)" width="600" height="400">
<afx-hbox data-id = "mybox">
<div data-id="myterm" ></div>
</afx-hbox>
</afx-app-window>

Binary file not shown.

Binary file not shown.

119
vTerm/main.coffee Normal file
View File

@ -0,0 +1,119 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/
class vTerm extends this.OS.application.BaseApplication
constructor: (args) ->
super "vTerm", args
main: () ->
@mterm = @find "myterm"
@term = new Terminal { cursorBlink: true }
@fitAddon = new FitAddon.FitAddon()
@term.loadAddon(@fitAddon)
@term.setOption('fontSize', '12')
@term.open @mterm
@term.onKey (d) =>
return unless @sub
@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(d.key)
@sub = undefined
@on "focus", () => @term.focus()
@mterm.contextmenuHandle = (e, m) =>
m.items = [
{ text: "__(Copy)", id: "copy" },
{ text: "__(Paste)", id: "paste"}
]
m.onmenuselect = (e) =>
return unless e
@mctxHandle e.data.item.data
m.show e
@resizeContent()
# make desktop menu if not exist
@systemsetting.desktop.menu[@name] = { text: "__(Open terminal)", app: "vTerm" } unless @systemsetting.desktop.menu[@name]
@on "hboxchange", (e) =>
@resizeContent()
if not Antunnel.tunnel
@error __("The Antunnel service is not started, please start it first")
@_gui.pushService("Antunnel/AntunnelService")
.catch (e) =>
@error e.toString(), e
@quit()
else
@tunnel = Antunnel.tunnel
@openSession()
mctxHandle: (data) ->
switch data.id
when "paste"
@_api.getClipboard().then (text) =>
return unless text and text isnt ""
@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode(text) if @sub
.catch (e) => @error __("Unable to paste"), e
when "copy"
text = @term.getSelection()
return unless text and text isnt ""
@_api.setClipboard text
else
resizeContent: () ->
@fitAddon.fit()
ncol = @term.cols
nrow = @term.rows
return unless @sub
arr = new Uint8Array(8)
arr.set Antunnel.Msg.bytes_of(ncol), 0
arr.set Antunnel.Msg.bytes_of(nrow), 4
@sub.send Antunnel.Msg.CTRL, arr
openSession: () ->
@term.clear()
@term.focus()
@sub = new Antunnel.Subscriber("vterm")
@sub.onopen = () =>
console.log("Subscribed")
@resizeContent (($ @mterm).width()) , (($ @mterm).height())
@term.focus()
@sub.onerror = (e) =>
@error __("Unable to connect to: vterm"), e
@sub = undefined
@sub.onmessage = (e) =>
@term.write(new TextDecoder("utf-8").decode(e.data)) if @term and e.data
@sub.onclose = () =>
@sub = undefined
@notify __("Terminal connection closed")
@quit()
@tunnel.subscribe @sub
cleanup: (e) ->
@sub.close() if @sub
vTerm.dependencies = [
"pkg://Antunnel/main.js"
]
this.OS.register "vTerm", vTerm

0
vTerm/main.css Normal file
View File

22
vTerm/package.json Normal file
View File

@ -0,0 +1,22 @@
{
"app":"vTerm",
"name":"Virtual Terminal",
"description":"Access Unix terminal from web",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.5-a",
"category":"System",
"iconclass":"fa fa-terminal",
"mimes":["none"],
"locales":{
"fr_FR": {
"Open terminal": "Ouvrir terminal",
"Edit": "Modifier",
"Please enter terminal URI": "Merci d'entrer l'URI du terminal",
"Unable to connect to: {0}": "Impossible de connecter a: {0}",
"Terminal connection closed": "Connexion terminal est fermee"
}
}
}

8
vTerm/project.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "vTerm",
"root": "home://workspace/antosdk-apps/vTerm",
"css": ["xterm.css", "main.css"],
"javascripts": ["xterm-addon-fit.js", "xterm.js"],
"coffees": ["main.coffee"],
"copies": ["scheme.html", "package.json", "README.md"]
}

5
vTerm/scheme.html Normal file
View File

@ -0,0 +1,5 @@
<afx-app-window apptitle="__(Terminal)" width="600" height="400">
<afx-hbox data-id = "mybox">
<div data-id="myterm" ></div>
</afx-hbox>
</afx-app-window>

2
vTerm/xterm-addon-fit.js Normal file
View File

@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0;var n=function(){function e(){}return e.prototype.activate=function(e){this._terminal=e},e.prototype.dispose=function(){},e.prototype.fit=function(){var e=this.proposeDimensions();if(e&&this._terminal){var t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}},e.prototype.proposeDimensions=function(){if(this._terminal&&this._terminal.element&&this._terminal.element.parentElement){var e=this._terminal._core,t=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(t.getPropertyValue("height")),n=Math.max(0,parseInt(t.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),i=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),a=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-e.viewport.scrollBarWidth;return{cols:Math.max(2,Math.floor(a/e._renderService.dimensions.actualCellWidth)),rows:Math.max(1,Math.floor(i/e._renderService.dimensions.actualCellHeight))}}},e}();t.FitAddon=n}])}));
//# sourceMappingURL=xterm-addon-fit.js.map

171
vTerm/xterm.css Normal file
View File

@ -0,0 +1,171 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/
/**
* Default styles for xterm.js
*/
.xterm {
font-feature-settings: "liga" 0;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.xterm.focus,
.xterm:focus {
outline: none;
}
.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 5;
}
.xterm .xterm-helper-textarea {
/*
* HACK: to fix IE's blinking cursor
* Move textarea out of the screen to the far left, so that the cursor is not visible.
*/
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}
.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}
.xterm .composition-view.active {
display: block;
}
.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
}
.xterm .xterm-screen {
position: relative;
}
.xterm .xterm-screen canvas {
position: absolute;
left: 0;
top: 0;
}
.xterm .xterm-scroll-area {
visibility: hidden;
}
.xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
top: 0;
left: -9999em;
line-height: normal;
}
.xterm {
cursor: text;
}
.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}
.xterm.xterm-cursor-pointer {
cursor: pointer;
}
.xterm.column-select.focus {
/* Column selection mode */
cursor: crosshair;
}
.xterm .xterm-accessibility,
.xterm .xterm-message {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 10;
color: transparent;
}
.xterm .live-region {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
.xterm-dim {
opacity: 0.5;
}
.xterm-underline {
text-decoration: underline;
}

2
vTerm/xterm.js Normal file

File diff suppressed because one or more lines are too long