Skip to content

Commit

Permalink
merge with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Feb 1, 2024
2 parents fe8c75c + d3bcec8 commit 4e58ed9
Show file tree
Hide file tree
Showing 23 changed files with 1,034 additions and 484 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 2.38.0
### Breaking
* `onInit` runs before login
### Features
* add support for BigInt numbers when parsing commands
* add `--line-thickness` CSS variable to cursor animation
* improve performance with long typing animations [#820](https://github.com/jcubic/jquery.terminal/issues/820)
### Bugfix
* fix `\t` characters in ascii_table [#902](https://github.com/jcubic/jquery.terminal/issues/902)
* fix race condition in refresh and flush [#897](https://github.com/jcubic/jquery.terminal/issues/897)
* always execute function prompt after login [#898](https://github.com/jcubic/jquery.terminal/issues/898)
* fix background color in prompt [#906](https://github.com/jcubic/jquery.terminal/issues/906)
* update prism code to match function Prism.highlight [#905](https://github.com/jcubic/jquery.terminal/issues/905)
* fix keepWords during typing animation [#867](https://github.com/jcubic/jquery.terminal/issues/867)
* fix leading spaces during animation [#825](https://github.com/jcubic/jquery.terminal/issues/825)
* fix edge case of of multiple echo with `newline: false` [#878](https://github.com/jcubic/jquery.terminal/issues/878)

## 2.37.2
### Bugfix
* fix for TypeScript from [Antoine](https://github.com/antoineol) ([#896](https://github.com/jcubic/jquery.terminal/pull/896)) and [KiddoV](https://github.com/KiddoV) ([#901](https://github.com/jcubic/jquery.terminal/pull/901))
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ emoji:
./scripts/mkemoji $(VERSION) > css/emoji.css

test:
$(JEST) --coverage --env=jsdom --testMatch '**/__tests__/*.spec.js'
$(JEST) --coverage

test-watch:
$(JEST) --coverage --watch

assets/ascii_art.svg: templates/ascii_art.svg .$(VERSION)
$(SED) -e "s/{{VER}}/$(VERSION)/g" templates/ascii_art.svg > assets/ascii_art.svg
Expand Down
56 changes: 44 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<h1 align="center">
<img src="https://github.com/jcubic/jquery.terminal/blob/master/assets/ascii_art.svg?raw=true&ver=2.37.2"
<img src="https://github.com/jcubic/jquery.terminal/blob/devel/assets/ascii_art.svg?raw=true&ver=DEV"
alt="ASCII Art that represent text jQuery Terminal - JavaScript Library for Web Based Terminal Emulators" />
</h1>

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

[![npm](https://img.shields.io/badge/npm-2.37.2-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-2.37.2-yellow.svg)
[![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)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=master&75da0f6ae07388cf17379f7dcd13e04f)](https://coveralls.io/github/jcubic/jquery.terminal?branch=master)
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![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)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&e637f705f0dc86afeff501b675fef37c)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down Expand Up @@ -87,7 +87,7 @@ You can test current version at this URL:

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

* [https://jcubic.github.io/jquery.terminal/?ver=2.37.2](https://jcubic.github.io/jquery.terminal/?ver=2.37.2)
* [https://jcubic.github.io/jquery.terminal/?ver=DEV](https://jcubic.github.io/jquery.terminal/?ver=DEV)

And development version using:

Expand All @@ -106,20 +106,20 @@ or use jsDelivr:

```

Then include js/jquery.terminal-2.37.2.min.js and css/jquery.terminal-2.37.2.min.css
Then include js/jquery.terminal-DEV.min.js and css/jquery.terminal-DEV.min.css

You can grab the files from CDN:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.37.2/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.37.2/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/DEV/css/jquery.terminal.min.css" rel="stylesheet"/>
```

or

```html
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.37.2/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@2.37.2/css/jquery.terminal.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.terminal@DEV/css/jquery.terminal.min.css"/>
```

If you always want latest version, you can get it from [unpkg](https://unpkg.com/) without specifying version,
Expand All @@ -131,6 +131,14 @@ it will redirect to the latest ones:
<link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
```

or jsDelivr that is bit faster:

```html
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
```


#### Bleeding Edge Version

If you want to test bleeding edge, development version of jQuery Terminal. You can use those files:
Expand All @@ -147,7 +155,13 @@ but it's not refreshed as fast as rawgit was, because it's CDN and need to be pr
**NOTE:** From version 1.0.0 if you want to support old browsers then you'll need to use [key event property polyfill](https://rawgit.com/inexorabletash/polyfill/master/keyboard.js). You can check the support for it on [can I use](https://caniuse.com/#feat=keyboardevent-key).

```html
<script src="https://unpkg.com/js-polyfills@0.x.x/keyboard.js"></script>
<script src="https://unpkg.com/js-polyfills/keyboard.js"></script>
```

or

```html
<script src="https://cdn.jsdelivr.net/npm/js-polyfills/keyboard.js"></script>
```

#### Command Line
Expand Down Expand Up @@ -194,6 +208,24 @@ Here is a higher level call, using an object as an interpreter, By default the t
parse commands that a user types and replace number like strings with real numbers
regex with regexes and process escape characters in double quoted strings.

```javascript
$('body').terminal({
cat: function(width = 200, height = 300) {
return $(`<img src="https://placekitten.com/${width}/${height}">`);
},
title: function() {
return fetch('https://terminal.jcubic.pl')
.then(r => r.text())
.then(html => html.match(/<title>([^>]+)<\/title>/)[1]);
}
}, {
checkArity: false,
greetings: 'My Terminal\n'
});
```

And more advanced example:

```javascript
jQuery(function($, undefined) {
$('#term_demo').terminal({
Expand Down
53 changes: 45 additions & 8 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,15 +1417,15 @@ describe('Terminal utils', function() {
}
it('should handle emoji', function() {
var input = [
"\u263a\ufe0f xxxx \u261d\ufe0f xxxx \u0038\ufe0f\u20e3 xxx\u0038\ufe0f\u20e3",
"\u263a\ufe0f xxxx \u261d\ufe0f x \u0038\ufe0f\u20e3 xxx\u0038\ufe0f\u20e3"
"\u263a\ufe0f_xxxx_\u261d\ufe0f_xxxx_\u0038\ufe0f\u20e3_xxx\u0038\ufe0f\u20e3",
"\u263a\ufe0f_xxxx_\u261d\ufe0f_x_\u0038\ufe0f\u20e3_xxx\u0038\ufe0f\u20e3"
];
input.forEach(test_codepoints);
});
it('should handle combine characters', function() {
var input = [
's\u030A\u032A xxxx s\u030A\u032A xxxx s\u030A\u032A xxxx',
's\u030A\u032A xxxx s\u030A\u032A xxxx s\u030A\u032A xxxs\u030A\u032A'
's\u030A\u032A_xxxx_s\u030A\u032A_xxxx_s\u030A\u032A_xxxx',
's\u030A\u032A_xxxx_s\u030A\u032A_xxxx_s\u030A\u032A_xxxs\u030A\u032A'
];
input.forEach(test_codepoints);
});
Expand Down Expand Up @@ -5529,6 +5529,20 @@ describe('Terminal plugin', function() {
expect(term.token(true)).toEqual(token);
expect(term.get_prompt()).toEqual('$$$ ');
});
it('should echo during login #912', async () => {
var term = $('<div/>').terminal({}, {
login: function(user, password) {
return 'TOKEN';
},
greetings: false
});
term.echo('HELLO');
expect(term.get_output()).toEqual('HELLO');
await term.exec(['foo', 'bar']);
term.echo('WORLD');
const output = 'HELLO\nlogin: foo\npassword: ***\nWORLD';
expect(term.get_output()).toEqual(output);
});
});
describe('settings', function() {
var term = $('<div/>').appendTo('body').terminal();
Expand Down Expand Up @@ -5663,6 +5677,30 @@ describe('Terminal plugin', function() {
done();
}, 400);
});
it('should render greetings and auth once #897', async () => {
var term = $('<div/>').terminal($.noop, {
login(username, password) {
if (username === 'guest' && password === 'guest') {
return '__TOKEN__';
}
return null;
},
greetings() {
return 'HELLO THERE';
},
memory: true,
prompt() {
return `${this.login_name()}$`
}
});
await term.exec(['guest', 'guest']);
await delay(100);
expect(output(term)).toEqual([
'login: guest',
'password: *****',
'HELLO THERE'
]);
});
});
describe('pause/paused/resume', function() {
var term = $('<div/>').appendTo('body').terminal();
Expand Down Expand Up @@ -7282,11 +7320,10 @@ describe('Terminal plugin', function() {
$.terminal.defaults.allowedAttributes.pop();
});
it('should remove last line', function() {
var index = term.last_index();
term.echo('foo bar');
term.echo('quux');
expect(term.last_index()).toEqual(index + 1);
term.update(index + 1, null);
expect(term.last_index()).toEqual(index);
term.update(-1, null);
expect(term.get_output()).toEqual('foo bar');
});
it('should call finalize', function() {
var options = {
Expand Down

0 comments on commit 4e58ed9

Please sign in to comment.