Skip to content

Commit 2993ef3

Browse files
committed
merge with devel
2 parents d39790b + 26f8c82 commit 2993ef3

18 files changed

+778
-189
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 2.43.0
2+
### Breaking
3+
* echo of undefined or Promise that resolve to undefined no longer display string undefined
4+
### Features
5+
* add support for `--rows` CSS custom property [#956](https://github.com/jcubic/jquery.terminal/issues/956)
6+
* add aborting signals [#940](https://github.com/jcubic/jquery.terminal/issues/940)
7+
### Bugfix
8+
* fix CMD update performace issue [#961](https://github.com/jcubic/jquery.terminal/issues/961)
9+
* don't reflow the reflow the cursor on update [#932](https://github.com/jcubic/jquery.terminal/issues/932)
10+
* fix unexpected uncaught exceptions in promises
11+
* fix skip/skip_stop return value and add types
12+
* fix recursive call to echo in renderHandler [#733](https://github.com/jcubic/jquery.terminal/issues/733)
13+
114
## 2.42.2
215
### Bugfix
316
* actual fix for blank lines typing animation [#946](https://github.com/jcubic/jquery.terminal/issues/946)

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<h1 align="center">
2-
<img src="https://github.com/jcubic/jquery.terminal/blob/master/assets/ascii_art.svg?raw=true&ver=2.42.2"
2+
<img src="https://github.com/jcubic/jquery.terminal/blob/devel/assets/ascii_art.svg?raw=true&ver=DEV"
33
alt="ASCII Art that represent text jQuery Terminal - JavaScript Library for Web Based Terminal Emulators" />
44
</h1>
55

66
[JavaScript Library for Web Based Terminal Emulators](https://terminal.jcubic.pl)
77

8-
[![npm](https://img.shields.io/badge/npm-2.42.2-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
9-
![bower](https://img.shields.io/badge/bower-2.42.2-yellow.svg)
10-
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=master&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
11-
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&3f75f3bdbaab431e0f8836338339f290)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
8+
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
9+
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
10+
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
11+
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&cd09bc55e55c92b2e6b07bb29830ae68)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
1212
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
1313
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
1414
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
@@ -87,7 +87,7 @@ You can test current version at this URL:
8787

8888
or if it doesn't use latest version (because of jsDelivr cache) you can force it with this URL:
8989

90-
* [https://jcubic.github.io/jquery.terminal/?ver=2.42.2](https://jcubic.github.io/jquery.terminal/?ver=2.42.2)
90+
* [https://jcubic.github.io/jquery.terminal/?ver=DEV](https://jcubic.github.io/jquery.terminal/?ver=DEV)
9191

9292
And development version using:
9393

@@ -106,20 +106,20 @@ or use jsDelivr:
106106

107107
```
108108

109-
Then include js/jquery.terminal-2.42.2.min.js and css/jquery.terminal-2.42.2.min.css
109+
Then include js/jquery.terminal-DEV.min.js and css/jquery.terminal-DEV.min.css
110110

111111
You can grab the files from CDN:
112112

113113
```html
114-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.2/js/jquery.terminal.min.js"></script>
115-
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.2/css/jquery.terminal.min.css" rel="stylesheet"/>
114+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/js/jquery.terminal.min.js"></script>
115+
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/css/jquery.terminal.min.css" rel="stylesheet"/>
116116
```
117117

118118
or
119119

120120
```html
121-
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.42.2/js/jquery.terminal.min.js"></script>
122-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.42.2/css/jquery.terminal.min.css"/>
121+
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/js/jquery.terminal.min.js"></script>
122+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/css/jquery.terminal.min.css"/>
123123
```
124124

125125
If you always want latest version, you can get it from [unpkg](https://unpkg.com/) without specifying version,
@@ -401,7 +401,7 @@ You can request paid support, you can find details at [support.jcubic.pl](https:
401401

402402
### Star History
403403

404-
[![Star History Chart](https://api.star-history.com/svg?repos=jcubic/jquery.terminal&type=Date&branch=master)](https://star-history.com/#jcubic/jquery.terminal&Date)
404+
[![Star History Chart](https://api.star-history.com/svg?repos=jcubic/jquery.terminal&type=Date&branch=devel)](https://star-history.com/#jcubic/jquery.terminal&Date)
405405

406406
### License
407407

__tests__/terminal.spec.js

Lines changed: 217 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ global.URL = window.URL = {
244244
revokeObjectURL: function() {}
245245
};
246246

247-
248247
require('../js/jquery.terminal-src')(global.$);
249248
require('../js/unix_formatting')(global.$);
250249
require('../js/xml_formatting')(global.$);
@@ -3441,33 +3440,48 @@ describe('Terminal plugin', function() {
34413440
});
34423441
});
34433442
describe('renderHandler', function() {
3444-
class Foo {
3445-
valueOf() {
3446-
return "Hello";
3443+
describe('default', () => {
3444+
class Foo {
3445+
valueOf() {
3446+
return "Hello";
3447+
}
34473448
}
3448-
}
3449-
let term;
3450-
beforeEach(() => {
3451-
term = $('<div/>').terminal(function() {
3452-
return new Foo();
3453-
}, {
3454-
renderHandler(value) {
3455-
if (value instanceof Foo) {
3456-
this.echo(value.valueOf());
3457-
return false;
3458-
}
3459-
},
3460-
greetings: false
3449+
let term;
3450+
beforeEach(() => {
3451+
term = $('<div/>').terminal(function() {
3452+
return new Foo();
3453+
}, {
3454+
renderHandler(value) {
3455+
if (value instanceof Foo) {
3456+
this.echo(value.valueOf());
3457+
return false;
3458+
}
3459+
},
3460+
greetings: false
3461+
});
3462+
});
3463+
it('should render object from echo', () => {
3464+
term.echo(new Foo());
3465+
expect(term.get_output()).toEqual('Hello');
3466+
});
3467+
it('should render object from interpreter', () => {
3468+
term.exec('foo', true);
3469+
expect(term.get_output()).toEqual('Hello');
3470+
expect(term.paused()).toBeFalsy(); // #857
34613471
});
34623472
});
3463-
it('should render object from echo', () => {
3464-
term.echo(new Foo());
3465-
expect(term.get_output()).toEqual('Hello');
3466-
});
3467-
it('should render object from interpreter', () => {
3468-
term.exec('foo', true);
3469-
expect(term.get_output()).toEqual('Hello');
3470-
expect(term.paused()).toBeFalsy(); // #857
3473+
describe('resursive', () => {
3474+
it('should render sync echo', () => {
3475+
const term = $('<div/>').terminal({}, {
3476+
renderHandler(value) {
3477+
this.echo(`Hello ${value}`);
3478+
return false;
3479+
},
3480+
greetings: false
3481+
});
3482+
term.echo('Terminal');
3483+
expect(term.get_output()).toEqual('Hello Terminal');
3484+
});
34713485
});
34723486
});
34733487
describe('pauseEvents', function() {
@@ -3672,6 +3686,182 @@ describe('Terminal plugin', function() {
36723686
};
36733687
}
36743688
describe('events', function() {
3689+
describe('abort signals', () => {
3690+
function ctrl_d() {
3691+
// invoke_key doesn't work here because this shortcut don't use keymap
3692+
shortcut(true, false, false, 'd');
3693+
}
3694+
const response = 'jQuery Terminal';
3695+
const fetch = function(url, { signal }) {
3696+
return new Promise((resolve, reject) => {
3697+
if (signal.aborted) {
3698+
reject(signal.reason);
3699+
}
3700+
setTimeout(() => {
3701+
resolve({
3702+
text: function() {
3703+
return Promise.resolve(response);
3704+
}
3705+
});
3706+
}, 100);
3707+
signal.addEventListener("abort", () => {
3708+
reject(signal.reason);
3709+
});
3710+
});
3711+
}
3712+
function terminal(fetch, options = {}) {
3713+
return $('<div/>').terminal(async function() {
3714+
const res = await fetch.call(this);
3715+
const text = await res.text();
3716+
this.echo(text);
3717+
}, { greetings: false, ...options });
3718+
}
3719+
describe('fetch with abort', () => {
3720+
let term;
3721+
beforeEach(() => {
3722+
term = terminal(function() {
3723+
const signal = this.signal();
3724+
return fetch('https://terminal.jcubic.pl', { signal });
3725+
});
3726+
});
3727+
it('should abort fetch on CTRL+D', async () => {
3728+
term.insert('fetch');
3729+
enter_key();
3730+
ctrl_d();
3731+
await delay(200);
3732+
expect(term.get_output()).toMatch(/> fetch\n.*Abort with CTRL\+D/);
3733+
});
3734+
it('should fetch the data', async () => {
3735+
term.insert('fetch');
3736+
enter_key();
3737+
await delay(200);
3738+
expect(term.get_output()).toEqual('> fetch\njQuery Terminal');
3739+
});
3740+
it('should change abort message', async () => {
3741+
term.insert('fetch');
3742+
enter_key();
3743+
term.abort('Nasty Abort');
3744+
await delay(200);
3745+
expect(term.get_output()).toMatch(/> fetch\n.*Nasty Abort/);
3746+
});
3747+
});
3748+
describe('fetch with timeout', () => {
3749+
let term;
3750+
beforeEach(() => {
3751+
term = terminal(function() {
3752+
const signal = this.timeout(100);
3753+
return fetch('https://terminal.jcubic.pl', { signal });
3754+
});
3755+
});
3756+
it('should abort fetch with error message', async () => {
3757+
term.insert('fetch');
3758+
enter_key();
3759+
await delay(200);
3760+
expect(term.get_output()).toMatch(/> fetch\n.*Signal timed out/);
3761+
});
3762+
it('should abort the timer with CTRL+D', async () => {
3763+
term.insert('fetch');
3764+
enter_key();
3765+
ctrl_d();
3766+
await delay(200);
3767+
expect(term.get_output()).toMatch(/> fetch\n.*Abort with CTRL\+D/);
3768+
});
3769+
});
3770+
describe('catch exceptions', () => {
3771+
let term;
3772+
beforeEach(() => {
3773+
term = $('<div/>').terminal(async function() {
3774+
try {
3775+
const signal = this.timeout(100);
3776+
const res = await fetch('https://terminal.jcubic.pl', { signal });
3777+
const text = await res.text();
3778+
this.echo(text);
3779+
} catch(err) {
3780+
if (!['AbortError', 'TimeoutError'].includes(err.name)) {
3781+
throw err;
3782+
}
3783+
}
3784+
}, { greetings: false });
3785+
});
3786+
it('should catch timeout', async () => {
3787+
term.insert('fetch');
3788+
enter_key();
3789+
await delay(200);
3790+
expect(term.get_output()).toEqual('> fetch');
3791+
});
3792+
it('should catch abort timeout', async () => {
3793+
term.insert('fetch');
3794+
enter_key();
3795+
ctrl_d();
3796+
await delay(200);
3797+
expect(term.get_output()).toEqual('> fetch');
3798+
});
3799+
});
3800+
describe('ignore errors', () => {
3801+
let term;
3802+
beforeEach(() => {
3803+
term = terminal(function() {
3804+
const signal = this.timeout(100);
3805+
return fetch('https://terminal.jcubic.pl', { signal });
3806+
}, { errorOnAbort: false });
3807+
});
3808+
it('should ingore timeout', async () => {
3809+
term.insert('fetch');
3810+
enter_key();
3811+
await delay(200);
3812+
expect(term.get_output()).toEqual('> fetch');
3813+
});
3814+
it('should ingore abort', async () => {
3815+
term.insert('fetch');
3816+
enter_key();
3817+
ctrl_d();
3818+
await delay(200);
3819+
expect(term.get_output()).toEqual('> fetch');
3820+
});
3821+
it('should show error', async () => {
3822+
const term = terminal(async function() {
3823+
throw new Error('Nasty Error');
3824+
}, { errorOnAbort: false });
3825+
term.insert('fetch');
3826+
enter_key();
3827+
expect(term.get_output()).toEqual('> fetch');
3828+
});
3829+
});
3830+
describe('read', () => {
3831+
let term;
3832+
beforeEach(() => {
3833+
term = $('<div/>').terminal({}, {
3834+
greetings: false
3835+
});
3836+
});
3837+
it('should aboort with CTRL+D and default signal', async () => {
3838+
expect.assertions(1);
3839+
try {
3840+
const ret = term.read('$ ');
3841+
setTimeout(() => {
3842+
term.focus();
3843+
ctrl_d();
3844+
}, 0);
3845+
await ret;
3846+
} catch(err) {
3847+
expect(err.name).toEqual('AbortError');
3848+
}
3849+
});
3850+
it('should timeout', async () => {
3851+
expect.assertions(1);
3852+
try {
3853+
await term.read('$ ', { signal: term.timeout(100) });
3854+
} catch(err) {
3855+
expect(err.name).toEqual('TimeoutError');
3856+
}
3857+
});
3858+
it('should read value', async () => {
3859+
const ret = term.read('$ ', { signal: term.timeout(100) });
3860+
term.exec('foo bar');
3861+
expect(await ret).toEqual('foo bar');
3862+
});
3863+
});
3864+
});
36753865
describe('click', function() {
36763866
var term = $('<div/>').terminal($.noop, {greetings: false, clickTimeout: 0});
36773867
var cmd = term.cmd();
@@ -6265,9 +6455,9 @@ describe('Terminal plugin', function() {
62656455
term.clear().echo(input);
62666456
expect(output().join('\n')).toEqual(input);
62676457
});
6268-
it('should print undefined', function() {
6458+
it('should not print undefined', function() {
62696459
term.clear().echo(undefined);
6270-
expect(output().join('\n')).toEqual('undefined');
6460+
expect(output().join('\n')).toEqual('');
62716461
});
62726462
it('should print value from function that return promise', function(done) {
62736463
var term = $('<div/>').terminal();

css/emoji.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)