1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var components = require('@pres/components');
|
6 | var program = require('@pres/program');
|
7 | var terminfoParser = require('@pres/terminfo-parser');
|
8 | var colors = require('@pres/util-blessed-colors');
|
9 | var helpers = require('@pres/util-helpers');
|
10 | var unicode = require('@pres/util-unicode');
|
11 | var url = require('url');
|
12 |
|
13 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
14 |
|
15 | function _interopNamespace(e) {
|
16 | if (e && e.__esModule) return e;
|
17 | var n = Object.create(null);
|
18 | if (e) {
|
19 | Object.keys(e).forEach(function (k) {
|
20 | if (k !== 'default') {
|
21 | var d = Object.getOwnPropertyDescriptor(e, k);
|
22 | Object.defineProperty(n, k, d.get ? d : {
|
23 | enumerable: true,
|
24 | get: function () {
|
25 | return e[k];
|
26 | }
|
27 | });
|
28 | }
|
29 | });
|
30 | }
|
31 | n['default'] = e;
|
32 | return Object.freeze(n);
|
33 | }
|
34 |
|
35 | var components__namespace = _interopNamespace(components);
|
36 | var colors__namespace = _interopNamespace(colors);
|
37 | var helpers__namespace = _interopNamespace(helpers);
|
38 | var unicode__namespace = _interopNamespace(unicode);
|
39 | var url__default = _interopDefaultLegacy(url);
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | class TI {}
|
106 | TI.program = program.Program.build;
|
107 | TI.build = program.Program.build;
|
108 | TI.helpers = helpers__namespace;
|
109 | TI.unicode = unicode__namespace;
|
110 | TI.colors = colors__namespace;
|
111 | TI.Tput = terminfoParser.Tput;
|
112 | Object.assign(TI, components__namespace);
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 | function OutputBuffer(options) {
|
175 | this.isTTY = true;
|
176 | this.columns = options.cols;
|
177 | this.rows = options.rows;
|
178 |
|
179 | this.write = function (s) {
|
180 | s = s.replace('\x1b8', '');
|
181 |
|
182 | options.res.write(s);
|
183 | };
|
184 |
|
185 | this.on = function () {};
|
186 | }
|
187 |
|
188 | function InputBuffer() {
|
189 | this.isTTY = true;
|
190 | this.isRaw = true;
|
191 |
|
192 | this.emit = function () {};
|
193 |
|
194 | this.setRawMode = function () {};
|
195 |
|
196 | this.resume = function () {};
|
197 |
|
198 | this.pause = function () {};
|
199 |
|
200 | this.on = function () {};
|
201 | }
|
202 |
|
203 | function serverError(req, res, err) {
|
204 | setTimeout(function () {
|
205 | if (!res.headersSent) res.writeHead(500, {
|
206 | 'Content-Type': 'text/plain'
|
207 | });
|
208 | res.write('\r\n\r\n' + err + '\r\n\r\n');
|
209 |
|
210 | res.end('\u001b[?25h');
|
211 | }, 0);
|
212 | return true;
|
213 | }
|
214 |
|
215 | function createScreen(req, res) {
|
216 | const query = url__default['default'].parse(req.url, true).query;
|
217 | const cols = query.cols || 250;
|
218 | const rows = query.rows || 50;
|
219 |
|
220 | if (cols <= 35 || cols >= 500 || rows <= 5 || rows >= 300) {
|
221 | serverError(req, res, 'cols must be bigger than 35 and rows must be bigger than 5');
|
222 | return null;
|
223 | }
|
224 |
|
225 | res.writeHead(200, {
|
226 | 'Content-Type': 'text/plain'
|
227 | });
|
228 | const output = new OutputBuffer({
|
229 | res: res,
|
230 | cols: cols,
|
231 | rows: rows
|
232 | });
|
233 | const input = new InputBuffer();
|
234 |
|
235 | const program = TI.program({
|
236 | output: output,
|
237 | input: input
|
238 | });
|
239 | if (query.terminal) program.terminal = query.terminal;
|
240 | if (query.isOSX) program.isOSXTerm = query.isOSX;
|
241 | if (query.isiTerm2) program.isiTerm2 = query.isiTerm2;
|
242 | return TI.screen({
|
243 | program: program
|
244 | });
|
245 | }
|
246 |
|
247 | Object.defineProperty(exports, 'ANSIImage', {
|
248 | enumerable: true,
|
249 | get: function () {
|
250 | return components.ANSIImage;
|
251 | }
|
252 | });
|
253 | Object.defineProperty(exports, 'BarChart', {
|
254 | enumerable: true,
|
255 | get: function () {
|
256 | return components.BarChart;
|
257 | }
|
258 | });
|
259 | Object.defineProperty(exports, 'BigText', {
|
260 | enumerable: true,
|
261 | get: function () {
|
262 | return components.BigText;
|
263 | }
|
264 | });
|
265 | Object.defineProperty(exports, 'Box', {
|
266 | enumerable: true,
|
267 | get: function () {
|
268 | return components.Box;
|
269 | }
|
270 | });
|
271 | Object.defineProperty(exports, 'Button', {
|
272 | enumerable: true,
|
273 | get: function () {
|
274 | return components.Button;
|
275 | }
|
276 | });
|
277 | Object.defineProperty(exports, 'Canvas', {
|
278 | enumerable: true,
|
279 | get: function () {
|
280 | return components.Canvas;
|
281 | }
|
282 | });
|
283 | Object.defineProperty(exports, 'Carousel', {
|
284 | enumerable: true,
|
285 | get: function () {
|
286 | return components.Carousel;
|
287 | }
|
288 | });
|
289 | Object.defineProperty(exports, 'Checkbox', {
|
290 | enumerable: true,
|
291 | get: function () {
|
292 | return components.Checkbox;
|
293 | }
|
294 | });
|
295 | Object.defineProperty(exports, 'DataTable', {
|
296 | enumerable: true,
|
297 | get: function () {
|
298 | return components.DataTable;
|
299 | }
|
300 | });
|
301 | Object.defineProperty(exports, 'DonutChart', {
|
302 | enumerable: true,
|
303 | get: function () {
|
304 | return components.DonutChart;
|
305 | }
|
306 | });
|
307 | Object.defineProperty(exports, 'FileManager', {
|
308 | enumerable: true,
|
309 | get: function () {
|
310 | return components.FileManager;
|
311 | }
|
312 | });
|
313 | Object.defineProperty(exports, 'Form', {
|
314 | enumerable: true,
|
315 | get: function () {
|
316 | return components.Form;
|
317 | }
|
318 | });
|
319 | Object.defineProperty(exports, 'Gauge', {
|
320 | enumerable: true,
|
321 | get: function () {
|
322 | return components.Gauge;
|
323 | }
|
324 | });
|
325 | Object.defineProperty(exports, 'GaugeList', {
|
326 | enumerable: true,
|
327 | get: function () {
|
328 | return components.GaugeList;
|
329 | }
|
330 | });
|
331 | Object.defineProperty(exports, 'Grid', {
|
332 | enumerable: true,
|
333 | get: function () {
|
334 | return components.Grid;
|
335 | }
|
336 | });
|
337 | Object.defineProperty(exports, 'Image', {
|
338 | enumerable: true,
|
339 | get: function () {
|
340 | return components.Image;
|
341 | }
|
342 | });
|
343 | Object.defineProperty(exports, 'Input', {
|
344 | enumerable: true,
|
345 | get: function () {
|
346 | return components.Input;
|
347 | }
|
348 | });
|
349 | Object.defineProperty(exports, 'LCD', {
|
350 | enumerable: true,
|
351 | get: function () {
|
352 | return components.LCD;
|
353 | }
|
354 | });
|
355 | Object.defineProperty(exports, 'Layout', {
|
356 | enumerable: true,
|
357 | get: function () {
|
358 | return components.Layout;
|
359 | }
|
360 | });
|
361 | Object.defineProperty(exports, 'Line', {
|
362 | enumerable: true,
|
363 | get: function () {
|
364 | return components.Line;
|
365 | }
|
366 | });
|
367 | Object.defineProperty(exports, 'LineChart', {
|
368 | enumerable: true,
|
369 | get: function () {
|
370 | return components.LineChart;
|
371 | }
|
372 | });
|
373 | Object.defineProperty(exports, 'List', {
|
374 | enumerable: true,
|
375 | get: function () {
|
376 | return components.List;
|
377 | }
|
378 | });
|
379 | Object.defineProperty(exports, 'ListBar', {
|
380 | enumerable: true,
|
381 | get: function () {
|
382 | return components.ListBar;
|
383 | }
|
384 | });
|
385 | Object.defineProperty(exports, 'ListTable', {
|
386 | enumerable: true,
|
387 | get: function () {
|
388 | return components.ListTable;
|
389 | }
|
390 | });
|
391 | Object.defineProperty(exports, 'Loading', {
|
392 | enumerable: true,
|
393 | get: function () {
|
394 | return components.Loading;
|
395 | }
|
396 | });
|
397 | Object.defineProperty(exports, 'Log', {
|
398 | enumerable: true,
|
399 | get: function () {
|
400 | return components.Log;
|
401 | }
|
402 | });
|
403 | Object.defineProperty(exports, 'LogList', {
|
404 | enumerable: true,
|
405 | get: function () {
|
406 | return components.LogList;
|
407 | }
|
408 | });
|
409 | Object.defineProperty(exports, 'Map', {
|
410 | enumerable: true,
|
411 | get: function () {
|
412 | return components.Map;
|
413 | }
|
414 | });
|
415 | Object.defineProperty(exports, 'Markdown', {
|
416 | enumerable: true,
|
417 | get: function () {
|
418 | return components.Markdown;
|
419 | }
|
420 | });
|
421 | Object.defineProperty(exports, 'Message', {
|
422 | enumerable: true,
|
423 | get: function () {
|
424 | return components.Message;
|
425 | }
|
426 | });
|
427 | Object.defineProperty(exports, 'Node', {
|
428 | enumerable: true,
|
429 | get: function () {
|
430 | return components.Node;
|
431 | }
|
432 | });
|
433 | Object.defineProperty(exports, 'OverlayImage', {
|
434 | enumerable: true,
|
435 | get: function () {
|
436 | return components.OverlayImage;
|
437 | }
|
438 | });
|
439 | Object.defineProperty(exports, 'Picture', {
|
440 | enumerable: true,
|
441 | get: function () {
|
442 | return components.Picture;
|
443 | }
|
444 | });
|
445 | Object.defineProperty(exports, 'ProgressBar', {
|
446 | enumerable: true,
|
447 | get: function () {
|
448 | return components.ProgressBar;
|
449 | }
|
450 | });
|
451 | Object.defineProperty(exports, 'Prompt', {
|
452 | enumerable: true,
|
453 | get: function () {
|
454 | return components.Prompt;
|
455 | }
|
456 | });
|
457 | Object.defineProperty(exports, 'Question', {
|
458 | enumerable: true,
|
459 | get: function () {
|
460 | return components.Question;
|
461 | }
|
462 | });
|
463 | Object.defineProperty(exports, 'RadioButton', {
|
464 | enumerable: true,
|
465 | get: function () {
|
466 | return components.RadioButton;
|
467 | }
|
468 | });
|
469 | Object.defineProperty(exports, 'RadioSet', {
|
470 | enumerable: true,
|
471 | get: function () {
|
472 | return components.RadioSet;
|
473 | }
|
474 | });
|
475 | Object.defineProperty(exports, 'Screen', {
|
476 | enumerable: true,
|
477 | get: function () {
|
478 | return components.Screen;
|
479 | }
|
480 | });
|
481 | Object.defineProperty(exports, 'ScrollableBox', {
|
482 | enumerable: true,
|
483 | get: function () {
|
484 | return components.ScrollableBox;
|
485 | }
|
486 | });
|
487 | Object.defineProperty(exports, 'ScrollableText', {
|
488 | enumerable: true,
|
489 | get: function () {
|
490 | return components.ScrollableText;
|
491 | }
|
492 | });
|
493 | Object.defineProperty(exports, 'Sparkline', {
|
494 | enumerable: true,
|
495 | get: function () {
|
496 | return components.Sparkline;
|
497 | }
|
498 | });
|
499 | Object.defineProperty(exports, 'StackedBarChart', {
|
500 | enumerable: true,
|
501 | get: function () {
|
502 | return components.StackedBarChart;
|
503 | }
|
504 | });
|
505 | Object.defineProperty(exports, 'Table', {
|
506 | enumerable: true,
|
507 | get: function () {
|
508 | return components.Table;
|
509 | }
|
510 | });
|
511 | Object.defineProperty(exports, 'Terminal', {
|
512 | enumerable: true,
|
513 | get: function () {
|
514 | return components.Terminal;
|
515 | }
|
516 | });
|
517 | Object.defineProperty(exports, 'Text', {
|
518 | enumerable: true,
|
519 | get: function () {
|
520 | return components.Text;
|
521 | }
|
522 | });
|
523 | Object.defineProperty(exports, 'Textarea', {
|
524 | enumerable: true,
|
525 | get: function () {
|
526 | return components.Textarea;
|
527 | }
|
528 | });
|
529 | Object.defineProperty(exports, 'Textbox', {
|
530 | enumerable: true,
|
531 | get: function () {
|
532 | return components.Textbox;
|
533 | }
|
534 | });
|
535 | Object.defineProperty(exports, 'Tree', {
|
536 | enumerable: true,
|
537 | get: function () {
|
538 | return components.Tree;
|
539 | }
|
540 | });
|
541 | Object.defineProperty(exports, 'Video', {
|
542 | enumerable: true,
|
543 | get: function () {
|
544 | return components.Video;
|
545 | }
|
546 | });
|
547 | exports.InputBuffer = InputBuffer;
|
548 | exports.OutputBuffer = OutputBuffer;
|
549 | exports.Pres = TI;
|
550 | exports.TI = TI;
|
551 | exports.TerminalInterface = TI;
|
552 | exports.blessed = TI;
|
553 | exports.contrib = TI;
|
554 | exports.createScreen = createScreen;
|
555 | exports.serverError = serverError;
|