gritty 7.2.0 → 8.0.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/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "gritty",
3
- "version": "7.2.0",
3
+ "version": "8.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Web terminal emulator",
7
- "commitType": "colon",
8
7
  "bin": {
9
8
  "gritty": "bin/gritty.js"
10
9
  },
@@ -59,35 +58,34 @@
59
58
  "@babel/preset-env": "^7.0.0",
60
59
  "@iocmd/wait": "^2.1.0",
61
60
  "babel-loader": "^9.1.3",
62
- "c8": "^8.0.1",
61
+ "c8": "^9.1.0",
63
62
  "clean-css-loader": "^4.1.1",
64
- "coveralls": "^3.0.0",
65
63
  "css-loader": "^6.2.0",
66
- "css-minimizer-webpack-plugin": "^5.0.1",
64
+ "css-minimizer-webpack-plugin": "^6.0.0",
67
65
  "css-modules-require-hook": "^4.0.6",
68
66
  "es6-promisify": "^7.0.0",
69
67
  "eslint": "^8.0.0-beta.0",
70
68
  "eslint-plugin-n": "^16.0.1",
71
- "eslint-plugin-putout": "^19.0.3",
69
+ "eslint-plugin-putout": "^22.4.1",
72
70
  "json-loader": "^0.5.4",
73
- "madrun": "^9.0.6",
71
+ "madrun": "^10.0.1",
74
72
  "mock-require": "^3.0.2",
75
73
  "nodemon": "^3.0.1",
76
74
  "optimize-css-assets-webpack-plugin": "^6.0.1",
77
- "putout": "^31.0.3",
75
+ "putout": "^35.7.3",
78
76
  "request": "^2.81.0",
79
77
  "serve-once": "^2.0.0",
80
78
  "socket.io-client": "^4.0.0",
81
79
  "style-loader": "^3.2.1",
82
- "supertape": "^8.1.0",
80
+ "supertape": "^10.4.0",
83
81
  "webpack": "^5.1.3",
84
82
  "webpack-cli": "^5.1.4",
85
- "xterm": "^5.0.0",
86
- "xterm-addon-fit": "^0.7.0",
87
- "xterm-addon-webgl": "^0.15.0"
83
+ "@xterm/xterm": "^5.0.0",
84
+ "@xterm/addon-fit": "^0.9.0",
85
+ "@xterm/addon-webgl": "^0.17.0"
88
86
  },
89
87
  "engines": {
90
- "node": ">=16"
88
+ "node": ">=18"
91
89
  },
92
90
  "license": "MIT",
93
91
  "publishConfig": {
package/server/gritty.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('node:process');
4
+ const isFn = (a) => typeof a === 'function';
3
5
  const path = require('path');
4
6
 
5
7
  const log = require('debug')('gritty');
@@ -7,11 +9,11 @@ const Router = require('router');
7
9
 
8
10
  const currify = require('currify');
9
11
  const wraptile = require('wraptile');
10
- const pty = require('node-pty');
12
+ const _pty = require('node-pty');
11
13
  const stringArgv = require('string-to-argv');
12
14
  const isBool = (a) => typeof a === 'boolean';
13
15
 
14
- const DIR_ROOT = __dirname + '/..';
16
+ const DIR_ROOT = `${__dirname}/..`;
15
17
 
16
18
  const terminalFn = currify(_terminalFn);
17
19
  const connectionWraped = wraptile(connection);
@@ -38,11 +40,10 @@ const choose = (a, b, options) => {
38
40
 
39
41
  module.exports = (options = {}) => {
40
42
  const router = Router();
41
- const {
42
- prefix = '/gritty',
43
- } = options;
43
+ const {prefix = '/gritty'} = options;
44
44
 
45
- router.route(prefix + '/*')
45
+ router
46
+ .route(`${prefix}/*`)
46
47
  .get(terminalFn(options))
47
48
  .get(staticFn);
48
49
 
@@ -50,9 +51,7 @@ module.exports = (options = {}) => {
50
51
  };
51
52
 
52
53
  function _terminalFn(options, req, res, next) {
53
- const {
54
- prefix = '/gritty',
55
- } = options;
54
+ const {prefix = '/gritty'} = options;
56
55
 
57
56
  req.url = req.url.replace(prefix, '');
58
57
 
@@ -67,7 +66,7 @@ function staticFn(req, res) {
67
66
  res.sendFile(file);
68
67
  }
69
68
 
70
- function createTerminal({command, env, cwd, cols, rows}) {
69
+ function createTerminal({command, env, cwd, cols, rows, pty = _pty}) {
71
70
  cols = cols || 80;
72
71
  rows = rows || 24;
73
72
 
@@ -91,10 +90,7 @@ function createTerminal({command, env, cwd, cols, rows}) {
91
90
  module.exports.listen = (socket, options = {}) => {
92
91
  check(socket, options);
93
92
 
94
- const {
95
- prefix,
96
- auth,
97
- } = options;
93
+ const {prefix, auth} = options;
98
94
 
99
95
  socket
100
96
  .of(prefix || '/gritty')
@@ -115,7 +111,7 @@ function check(socket, options) {
115
111
 
116
112
  const {auth} = options;
117
113
 
118
- if (auth && typeof auth !== 'function')
114
+ if (auth && !isFn(auth))
119
115
  throw Error('options.auth should be a function!');
120
116
  }
121
117
 
@@ -129,10 +125,7 @@ function connection(options, socket) {
129
125
  const onResize = (size) => {
130
126
  size = size || {};
131
127
 
132
- const {
133
- cols = 80,
134
- rows = 25,
135
- } = size;
128
+ const {cols = 80, rows = 25} = size;
136
129
 
137
130
  term.resize(cols, rows);
138
131
  log(`Resized terminal ${term.pid} to ${cols} cols and ${rows} rows.`);
@@ -152,6 +145,7 @@ function connection(options, socket) {
152
145
  } = params;
153
146
 
154
147
  const command = params.command || options.command || CMD;
148
+
155
149
  const autoRestart = choose(params.autoRestart, options.autoRestart, {
156
150
  default: true,
157
151
  });
@@ -198,4 +192,3 @@ function connection(options, socket) {
198
192
  socket.on('disconnect', onDisconnect);
199
193
  }
200
194
  }
201
-