@difizen/libro-terminal 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/es/configuration.js +226 -0
- package/es/connection.d.ts +108 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +385 -0
- package/es/index.d.ts +2 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +1 -0
- package/es/manager.d.ts +104 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +469 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +22 -0
- package/es/protocol.d.ts +87 -0
- package/es/protocol.d.ts.map +1 -0
- package/es/protocol.js +16 -0
- package/es/restapi.d.ts +11 -0
- package/es/restapi.d.ts.map +1 -0
- package/es/restapi.js +181 -0
- package/es/theme-service.js +183 -0
- package/es/view.d.ts +85 -0
- package/es/view.d.ts.map +1 -0
- package/es/view.js +317 -0
- package/package.json +63 -0
- package/src/configuration.ts +276 -0
- package/src/connection.ts +347 -0
- package/src/index.spec.ts +8 -0
- package/src/index.ts +1 -0
- package/src/manager.ts +280 -0
- package/src/module.ts +29 -0
- package/src/protocol.ts +102 -0
- package/src/restapi.ts +75 -0
- package/src/theme-service.ts +180 -0
- package/src/view.tsx +327 -0
package/es/restapi.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
16
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
17
|
+
import { URL } from '@difizen/libro-common';
|
|
18
|
+
import { createResponseError } from '@difizen/libro-kernel';
|
|
19
|
+
import { ServerConnection } from '@difizen/libro-kernel';
|
|
20
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
21
|
+
export var TERMINAL_SERVICE_URL = 'api/terminals';
|
|
22
|
+
export var TerminalRestAPI = (_dec = singleton(), _dec2 = inject(ServerConnection), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
23
|
+
function TerminalRestAPI() {
|
|
24
|
+
_classCallCheck(this, TerminalRestAPI);
|
|
25
|
+
_initializerDefineProperty(this, "serverConnection", _descriptor, this);
|
|
26
|
+
}
|
|
27
|
+
_createClass(TerminalRestAPI, [{
|
|
28
|
+
key: "startNew",
|
|
29
|
+
value: function () {
|
|
30
|
+
var _startNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, serverSettings) {
|
|
31
|
+
var settings, url, init, response, err, data;
|
|
32
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
settings = _objectSpread(_objectSpread({}, this.serverConnection.settings), serverSettings);
|
|
36
|
+
url = URL.join(settings.baseUrl, TERMINAL_SERVICE_URL);
|
|
37
|
+
init = {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
body: JSON.stringify(options)
|
|
40
|
+
};
|
|
41
|
+
_context.next = 5;
|
|
42
|
+
return this.serverConnection.makeRequest(url, init, settings);
|
|
43
|
+
case 5:
|
|
44
|
+
response = _context.sent;
|
|
45
|
+
if (!(response.status !== 201)) {
|
|
46
|
+
_context.next = 11;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
_context.next = 9;
|
|
50
|
+
return createResponseError(response);
|
|
51
|
+
case 9:
|
|
52
|
+
err = _context.sent;
|
|
53
|
+
throw err;
|
|
54
|
+
case 11:
|
|
55
|
+
_context.next = 13;
|
|
56
|
+
return response.json();
|
|
57
|
+
case 13:
|
|
58
|
+
data = _context.sent;
|
|
59
|
+
return _context.abrupt("return", data);
|
|
60
|
+
case 15:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}, _callee, this);
|
|
65
|
+
}));
|
|
66
|
+
function startNew(_x, _x2) {
|
|
67
|
+
return _startNew.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
return startNew;
|
|
70
|
+
}()
|
|
71
|
+
}, {
|
|
72
|
+
key: "listRunning",
|
|
73
|
+
value: function () {
|
|
74
|
+
var _listRunning = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(serverSettings) {
|
|
75
|
+
var settings, url, response, err, data;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
settings = _objectSpread(_objectSpread({}, this.serverConnection.settings), serverSettings);
|
|
80
|
+
url = URL.join(settings.baseUrl, TERMINAL_SERVICE_URL);
|
|
81
|
+
_context2.next = 4;
|
|
82
|
+
return this.serverConnection.makeRequest(url, {}, settings);
|
|
83
|
+
case 4:
|
|
84
|
+
response = _context2.sent;
|
|
85
|
+
if (!(response.status !== 200)) {
|
|
86
|
+
_context2.next = 10;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
_context2.next = 8;
|
|
90
|
+
return createResponseError(response);
|
|
91
|
+
case 8:
|
|
92
|
+
err = _context2.sent;
|
|
93
|
+
throw err;
|
|
94
|
+
case 10:
|
|
95
|
+
_context2.next = 12;
|
|
96
|
+
return response.json();
|
|
97
|
+
case 12:
|
|
98
|
+
data = _context2.sent;
|
|
99
|
+
if (Array.isArray(data)) {
|
|
100
|
+
_context2.next = 15;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
throw new Error('Invalid Session list');
|
|
104
|
+
case 15:
|
|
105
|
+
return _context2.abrupt("return", data);
|
|
106
|
+
case 16:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context2.stop();
|
|
109
|
+
}
|
|
110
|
+
}, _callee2, this);
|
|
111
|
+
}));
|
|
112
|
+
function listRunning(_x3) {
|
|
113
|
+
return _listRunning.apply(this, arguments);
|
|
114
|
+
}
|
|
115
|
+
return listRunning;
|
|
116
|
+
}()
|
|
117
|
+
}, {
|
|
118
|
+
key: "shutdown",
|
|
119
|
+
value: function () {
|
|
120
|
+
var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(name, serverSettings) {
|
|
121
|
+
var settings, url, init, response, _data$message, data, msg, err;
|
|
122
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
123
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (name) {
|
|
126
|
+
_context3.next = 3;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
console.warn('No terminal name specified');
|
|
130
|
+
return _context3.abrupt("return");
|
|
131
|
+
case 3:
|
|
132
|
+
settings = _objectSpread(_objectSpread({}, this.serverConnection.settings), serverSettings);
|
|
133
|
+
url = URL.join(settings.baseUrl, TERMINAL_SERVICE_URL, name);
|
|
134
|
+
init = {
|
|
135
|
+
method: 'DELETE'
|
|
136
|
+
};
|
|
137
|
+
_context3.next = 8;
|
|
138
|
+
return this.serverConnection.makeRequest(url, init, settings);
|
|
139
|
+
case 8:
|
|
140
|
+
response = _context3.sent;
|
|
141
|
+
if (!(response.status === 404)) {
|
|
142
|
+
_context3.next = 17;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
_context3.next = 12;
|
|
146
|
+
return response.json();
|
|
147
|
+
case 12:
|
|
148
|
+
data = _context3.sent;
|
|
149
|
+
msg = (_data$message = data.message) !== null && _data$message !== void 0 ? _data$message : "The terminal session \"".concat(name, "\"\" does not exist on the server");
|
|
150
|
+
console.warn(msg);
|
|
151
|
+
_context3.next = 22;
|
|
152
|
+
break;
|
|
153
|
+
case 17:
|
|
154
|
+
if (!(response.status !== 204)) {
|
|
155
|
+
_context3.next = 22;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
_context3.next = 20;
|
|
159
|
+
return createResponseError(response);
|
|
160
|
+
case 20:
|
|
161
|
+
err = _context3.sent;
|
|
162
|
+
throw err;
|
|
163
|
+
case 22:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context3.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee3, this);
|
|
168
|
+
}));
|
|
169
|
+
function shutdown(_x4, _x5) {
|
|
170
|
+
return _shutdown.apply(this, arguments);
|
|
171
|
+
}
|
|
172
|
+
return shutdown;
|
|
173
|
+
}()
|
|
174
|
+
}]);
|
|
175
|
+
return TerminalRestAPI;
|
|
176
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "serverConnection", [_dec2], {
|
|
177
|
+
configurable: true,
|
|
178
|
+
enumerable: true,
|
|
179
|
+
writable: true,
|
|
180
|
+
initializer: null
|
|
181
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
10
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
11
|
+
import { ColorRegistry, ThemeService } from '@difizen/mana-app';
|
|
12
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
13
|
+
/**
|
|
14
|
+
* It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/terminal/common/terminalColorRegistry.ts#L40
|
|
15
|
+
*/
|
|
16
|
+
export var terminalAnsiColorMap = {
|
|
17
|
+
'terminal.ansiBlack': {
|
|
18
|
+
index: 0,
|
|
19
|
+
defaults: {
|
|
20
|
+
light: '#000000',
|
|
21
|
+
dark: '#000000',
|
|
22
|
+
hc: '#000000'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
'terminal.ansiRed': {
|
|
26
|
+
index: 1,
|
|
27
|
+
defaults: {
|
|
28
|
+
light: '#cd3131',
|
|
29
|
+
dark: '#cd3131',
|
|
30
|
+
hc: '#cd0000'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
'terminal.ansiGreen': {
|
|
34
|
+
index: 2,
|
|
35
|
+
defaults: {
|
|
36
|
+
light: '#00BC00',
|
|
37
|
+
dark: '#0DBC79',
|
|
38
|
+
hc: '#00cd00'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'terminal.ansiYellow': {
|
|
42
|
+
index: 3,
|
|
43
|
+
defaults: {
|
|
44
|
+
light: '#949800',
|
|
45
|
+
dark: '#e5e510',
|
|
46
|
+
hc: '#cdcd00'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
'terminal.ansiBlue': {
|
|
50
|
+
index: 4,
|
|
51
|
+
defaults: {
|
|
52
|
+
light: '#0451a5',
|
|
53
|
+
dark: '#2472c8',
|
|
54
|
+
hc: '#0000ee'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
'terminal.ansiMagenta': {
|
|
58
|
+
index: 5,
|
|
59
|
+
defaults: {
|
|
60
|
+
light: '#bc05bc',
|
|
61
|
+
dark: '#bc3fbc',
|
|
62
|
+
hc: '#cd00cd'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
'terminal.ansiCyan': {
|
|
66
|
+
index: 6,
|
|
67
|
+
defaults: {
|
|
68
|
+
light: '#0598bc',
|
|
69
|
+
dark: '#11a8cd',
|
|
70
|
+
hc: '#00cdcd'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
'terminal.ansiWhite': {
|
|
74
|
+
index: 7,
|
|
75
|
+
defaults: {
|
|
76
|
+
light: '#555555',
|
|
77
|
+
dark: '#e5e5e5',
|
|
78
|
+
hc: '#e5e5e5'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
'terminal.ansiBrightBlack': {
|
|
82
|
+
index: 8,
|
|
83
|
+
defaults: {
|
|
84
|
+
light: '#666666',
|
|
85
|
+
dark: '#666666',
|
|
86
|
+
hc: '#7f7f7f'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
'terminal.ansiBrightRed': {
|
|
90
|
+
index: 9,
|
|
91
|
+
defaults: {
|
|
92
|
+
light: '#cd3131',
|
|
93
|
+
dark: '#f14c4c',
|
|
94
|
+
hc: '#ff0000'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
'terminal.ansiBrightGreen': {
|
|
98
|
+
index: 10,
|
|
99
|
+
defaults: {
|
|
100
|
+
light: '#14CE14',
|
|
101
|
+
dark: '#23d18b',
|
|
102
|
+
hc: '#00ff00'
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
'terminal.ansiBrightYellow': {
|
|
106
|
+
index: 11,
|
|
107
|
+
defaults: {
|
|
108
|
+
light: '#b5ba00',
|
|
109
|
+
dark: '#f5f543',
|
|
110
|
+
hc: '#ffff00'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
'terminal.ansiBrightBlue': {
|
|
114
|
+
index: 12,
|
|
115
|
+
defaults: {
|
|
116
|
+
light: '#0451a5',
|
|
117
|
+
dark: '#3b8eea',
|
|
118
|
+
hc: '#5c5cff'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
'terminal.ansiBrightMagenta': {
|
|
122
|
+
index: 13,
|
|
123
|
+
defaults: {
|
|
124
|
+
light: '#bc05bc',
|
|
125
|
+
dark: '#d670d6',
|
|
126
|
+
hc: '#ff00ff'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
'terminal.ansiBrightCyan': {
|
|
130
|
+
index: 14,
|
|
131
|
+
defaults: {
|
|
132
|
+
light: '#0598bc',
|
|
133
|
+
dark: '#29b8db',
|
|
134
|
+
hc: '#00ffff'
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
'terminal.ansiBrightWhite': {
|
|
138
|
+
index: 15,
|
|
139
|
+
defaults: {
|
|
140
|
+
light: '#a5a5a5',
|
|
141
|
+
dark: '#e5e5e5',
|
|
142
|
+
hc: '#ffffff'
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
export var TerminalThemeService = (_dec = singleton(), _dec2 = inject(ColorRegistry), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
147
|
+
function TerminalThemeService() {
|
|
148
|
+
_classCallCheck(this, TerminalThemeService);
|
|
149
|
+
_initializerDefineProperty(this, "colorRegistry", _descriptor, this);
|
|
150
|
+
this.onDidChange = ThemeService.get().onDidColorThemeChange;
|
|
151
|
+
}
|
|
152
|
+
_createClass(TerminalThemeService, [{
|
|
153
|
+
key: "theme",
|
|
154
|
+
get: function get() {
|
|
155
|
+
var foregroundColor = this.colorRegistry.getCurrentColor('terminal.foreground');
|
|
156
|
+
var backgroundColor = this.colorRegistry.getCurrentColor('terminal.background') || this.colorRegistry.getCurrentColor('panel.background');
|
|
157
|
+
var cursorColor = this.colorRegistry.getCurrentColor('terminalCursor.foreground') || foregroundColor;
|
|
158
|
+
var cursorAccentColor = this.colorRegistry.getCurrentColor('terminalCursor.background') || backgroundColor;
|
|
159
|
+
var selectionColor = this.colorRegistry.getCurrentColor('terminal.selectionBackground');
|
|
160
|
+
var theme = {
|
|
161
|
+
background: backgroundColor,
|
|
162
|
+
foreground: foregroundColor,
|
|
163
|
+
cursor: cursorColor,
|
|
164
|
+
cursorAccent: cursorAccentColor,
|
|
165
|
+
selection: selectionColor
|
|
166
|
+
};
|
|
167
|
+
// eslint-disable-next-line guard-for-in
|
|
168
|
+
for (var id in terminalAnsiColorMap) {
|
|
169
|
+
var colorId = id.substring(13);
|
|
170
|
+
var colorName = colorId.charAt(0).toLowerCase() + colorId.slice(1);
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
|
+
theme[colorName] = this.colorRegistry.getCurrentColor(id);
|
|
173
|
+
}
|
|
174
|
+
return theme;
|
|
175
|
+
}
|
|
176
|
+
}]);
|
|
177
|
+
return TerminalThemeService;
|
|
178
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "colorRegistry", [_dec2], {
|
|
179
|
+
configurable: true,
|
|
180
|
+
enumerable: true,
|
|
181
|
+
writable: true,
|
|
182
|
+
initializer: null
|
|
183
|
+
})), _class2)) || _class);
|
package/es/view.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { BaseView, DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
3
|
+
import type { RendererType } from 'xterm';
|
|
4
|
+
import { Terminal } from 'xterm';
|
|
5
|
+
import { FitAddon } from 'xterm-addon-fit';
|
|
6
|
+
import type { CursorStyle, TerminalRendererType } from './configuration.js';
|
|
7
|
+
import { TerminalConfiguration } from './configuration.js';
|
|
8
|
+
import type { TerminalConnection } from './connection.js';
|
|
9
|
+
import { TerminalManager } from './manager.js';
|
|
10
|
+
import type { TerminalMessage } from './protocol.js';
|
|
11
|
+
import { TerminalViewOption } from './protocol.js';
|
|
12
|
+
import { TerminalThemeService } from './theme-service.js';
|
|
13
|
+
export declare const TerminalComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export declare class LibroTerminalView extends BaseView {
|
|
15
|
+
protected term: Terminal;
|
|
16
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
protected options: TerminalViewOption;
|
|
18
|
+
protected termOpened: boolean;
|
|
19
|
+
protected initialData: string;
|
|
20
|
+
protected fitAddon: FitAddon;
|
|
21
|
+
protected readonly config: TerminalConfiguration;
|
|
22
|
+
protected readonly themeService: TerminalThemeService;
|
|
23
|
+
protected readonly terminalManager: TerminalManager;
|
|
24
|
+
protected readonly toDisposeOnConnect: DisposableCollection;
|
|
25
|
+
protected readonly onDidOpenEmitter: Emitter<void>;
|
|
26
|
+
readonly onDidOpen: import("@difizen/mana-app").Event<void>;
|
|
27
|
+
protected readonly onDidOpenFailureEmitter: Emitter<void>;
|
|
28
|
+
readonly onDidOpenFailure: import("@difizen/mana-app").Event<void>;
|
|
29
|
+
protected readonly onSizeChangedEmitter: Emitter<{
|
|
30
|
+
cols: number;
|
|
31
|
+
rows: number;
|
|
32
|
+
}>;
|
|
33
|
+
readonly onSizeChanged: import("@difizen/mana-app").Event<{
|
|
34
|
+
cols: number;
|
|
35
|
+
rows: number;
|
|
36
|
+
}>;
|
|
37
|
+
protected readonly onDataEmitter: Emitter<string>;
|
|
38
|
+
readonly onData: import("@difizen/mana-app").Event<string>;
|
|
39
|
+
protected readonly onKeyEmitter: Emitter<{
|
|
40
|
+
key: string;
|
|
41
|
+
domEvent: KeyboardEvent;
|
|
42
|
+
}>;
|
|
43
|
+
readonly onKey: import("@difizen/mana-app").Event<{
|
|
44
|
+
key: string;
|
|
45
|
+
domEvent: KeyboardEvent;
|
|
46
|
+
}>;
|
|
47
|
+
protected readonly onDidCloseEmitter: Emitter<LibroTerminalView>;
|
|
48
|
+
readonly onDidClose: import("@difizen/mana-app").Event<LibroTerminalView>;
|
|
49
|
+
protected connection?: TerminalConnection;
|
|
50
|
+
constructor(options: TerminalViewOption);
|
|
51
|
+
protected createConnection: () => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Handle a message from the terminal session.
|
|
54
|
+
*/
|
|
55
|
+
protected onMessage(msg: TerminalMessage): void;
|
|
56
|
+
protected initialConnection(): void;
|
|
57
|
+
protected createTerm: () => void;
|
|
58
|
+
protected get enableCopy(): boolean;
|
|
59
|
+
protected get enablePaste(): boolean;
|
|
60
|
+
protected get copyOnSelection(): boolean;
|
|
61
|
+
protected customKeyHandler: (event: KeyboardEvent) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get the cursor style compatible with `xterm`.
|
|
64
|
+
* @returns CursorStyle
|
|
65
|
+
*/
|
|
66
|
+
protected getCursorStyle: () => CursorStyle;
|
|
67
|
+
/**
|
|
68
|
+
* Returns given renderer type if it is valid and supported or default renderer otherwise.
|
|
69
|
+
*
|
|
70
|
+
* @param terminalRendererType desired terminal renderer type
|
|
71
|
+
*/
|
|
72
|
+
protected getTerminalRendererType: (terminalRendererType?: string | TerminalRendererType) => RendererType;
|
|
73
|
+
protected resizeTerminal: () => void;
|
|
74
|
+
onViewResize: () => void;
|
|
75
|
+
protected open: () => void;
|
|
76
|
+
scrollLineUp: () => void;
|
|
77
|
+
scrollLineDown: () => void;
|
|
78
|
+
scrollToTop: () => void;
|
|
79
|
+
scrollToBottom: () => void;
|
|
80
|
+
scrollPageUp: () => void;
|
|
81
|
+
scrollPageDown: () => void;
|
|
82
|
+
resetTerminal: () => void;
|
|
83
|
+
writeLine: (text: string) => void;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=view.d.ts.map
|
package/es/view.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.tsx"],"names":[],"mappings":"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"}
|