refactor: serialize-addon, move SerializeAddon.benchmark.ts into addons/xterm-addon-serialize and add README.md
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
lib
|
lib
|
||||||
node_modules
|
node_modules
|
||||||
|
out-benchmark
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
## xterm-addon-serialize
|
||||||
|
|
||||||
|
An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables xterm.js to serialize a terminal framebuffer into string or html. This addon requires xterm.js v4+.
|
||||||
|
|
||||||
|
⚠️ This is an experimental addon that is still under construction ⚠️
|
||||||
|
|
||||||
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install --save xterm-addon-serialize
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Terminal } from "xterm";
|
||||||
|
import { SerializeAddon } from "xterm-addon-serialize";
|
||||||
|
|
||||||
|
const terminal = new Terminal();
|
||||||
|
const serializeAddon = new SerializeAddon();
|
||||||
|
terminal.loadAddon(serializeAddon);
|
||||||
|
|
||||||
|
terminal.write("something...", () => {
|
||||||
|
console.log(serializeAddon.serialize());
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
See the full [API](https://github.com/xtermjs/xterm.js/blob/master/addons/xterm-addon-serialize/typings/xterm-addon-serialize.d.ts) for more advanced usage.
|
||||||
|
|
||||||
|
### Benchmark
|
||||||
|
|
||||||
|
⚠️ Ensure you have `lolcat`, `hexdump` programs installed in your computer
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ git clone https://github.com/xtermjs/xterm.js.git
|
||||||
|
$ cd xterm.js
|
||||||
|
$ yarn
|
||||||
|
$ cd addons/xterm-addon-serialize
|
||||||
|
$ yarn benchmark && yarn benchmark-baseline
|
||||||
|
$ # change some code in `xterm-addon-serialize`
|
||||||
|
$ yarn benchmark-eval
|
||||||
|
```
|
||||||
+1
-1
@@ -8,7 +8,7 @@ import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark';
|
|||||||
import { spawn } from 'node-pty';
|
import { spawn } from 'node-pty';
|
||||||
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder';
|
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder';
|
||||||
import { Terminal } from 'public/Terminal';
|
import { Terminal } from 'public/Terminal';
|
||||||
import { SerializeAddon } from 'addons/xterm-addon-serialize/src/SerializeAddon';
|
import { SerializeAddon } from 'SerializeAddon';
|
||||||
|
|
||||||
class TestTerminal extends Terminal {
|
class TestTerminal extends Terminal {
|
||||||
writeSync(data: string): void {
|
writeSync(data: string): void {
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"APP_PATH": ".benchmark",
|
||||||
|
"evalConfig": {
|
||||||
|
"tolerance": {
|
||||||
|
"*": [0.75, 1.5],
|
||||||
|
"*.dev": [0.01, 1.5],
|
||||||
|
"*.cv": [0.01, 1.5],
|
||||||
|
"EscapeSequenceParser.benchmark.js.*.averageThroughput.mean": [0.9, 5]
|
||||||
|
},
|
||||||
|
"skip": [
|
||||||
|
"*.median",
|
||||||
|
"*.runs",
|
||||||
|
"*.dev",
|
||||||
|
"*.cv",
|
||||||
|
"EscapeSequenceParser.benchmark.js.*.averageRuntime",
|
||||||
|
"Terminal.benchmark.js.*.averageRuntime"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["dom", "es6"],
|
||||||
|
"outDir": "../out-benchmark",
|
||||||
|
"types": ["../../../node_modules/@types/node"],
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"strict": false,
|
||||||
|
"target": "es2015",
|
||||||
|
"module": "commonjs",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"common/*": ["../../../src/common/*"],
|
||||||
|
"browser/*": ["../../../src/browser/*"],
|
||||||
|
"public/*": ["../../../src/public/*"],
|
||||||
|
"Terminal": ["../../../src/Terminal"],
|
||||||
|
"SerializeAddon": ["../src/SerializeAddon"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["../**/*", "../../../typings/xterm.d.ts", "../../../out/**/*"],
|
||||||
|
"exclude": ["../../../**/*test.ts", "../../**/*api.ts"],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../../../src/common" },
|
||||||
|
{ "path": "../../../src/browser" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -12,7 +12,10 @@
|
|||||||
"build": "../../node_modules/.bin/tsc -p src",
|
"build": "../../node_modules/.bin/tsc -p src",
|
||||||
"prepackage": "npm run build",
|
"prepackage": "npm run build",
|
||||||
"package": "../../node_modules/.bin/webpack",
|
"package": "../../node_modules/.bin/webpack",
|
||||||
"prepublishOnly": "npm run package"
|
"prepublishOnly": "npm run package",
|
||||||
|
"benchmark": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json",
|
||||||
|
"benchmark-baseline": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json --baseline out-benchmark/addons/xterm-addon-serialize/benchmark/*benchmark.js",
|
||||||
|
"benchmark-eval": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json --eval out-benchmark/addons/xterm-addon-serialize/benchmark/*benchmark.js"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"xterm": "^3.14.0"
|
"xterm": "^3.14.0"
|
||||||
|
|||||||
+3
-3
@@ -23,9 +23,9 @@
|
|||||||
"presetup": "node ./bin/install-addons.js",
|
"presetup": "node ./bin/install-addons.js",
|
||||||
"prepublishOnly": "npm run package",
|
"prepublishOnly": "npm run package",
|
||||||
"watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
|
"watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
|
||||||
"benchmark": "NODE_PATH=./out:./out-test/benchmark xterm-benchmark -r 5 -c test/benchmark/benchmark.json",
|
"benchmark": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json",
|
||||||
"benchmark-baseline": "NODE_PATH=./out:./out-test/benchmark xterm-benchmark -r 5 -c test/benchmark/benchmark.json --baseline out-test/benchmark/test/benchmark/SerializeAddon.benchmark.js",
|
"benchmark-baseline": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --baseline out-test/benchmark/test/benchmark/*benchmark.js",
|
||||||
"benchmark-eval": "NODE_PATH=./out:./out-test/benchmark xterm-benchmark -r 5 -c test/benchmark/benchmark.json --eval out-test/benchmark/test/benchmark/SerializeAddon.benchmark.js",
|
"benchmark-eval": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --eval out-test/benchmark/test/benchmark/*benchmark.js",
|
||||||
"clean": "rm -rf lib out addons/*/lib addons/*/out"
|
"clean": "rm -rf lib out addons/*/lib addons/*/out"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
+2
-1
@@ -10,6 +10,7 @@
|
|||||||
{ "path": "./addons/xterm-addon-search/src" },
|
{ "path": "./addons/xterm-addon-search/src" },
|
||||||
{ "path": "./addons/xterm-addon-web-links/src" },
|
{ "path": "./addons/xterm-addon-web-links/src" },
|
||||||
{ "path": "./addons/xterm-addon-webgl/src" },
|
{ "path": "./addons/xterm-addon-webgl/src" },
|
||||||
{ "path": "./addons/xterm-addon-serialize/src" }
|
{ "path": "./addons/xterm-addon-serialize/src" },
|
||||||
|
{ "path": "./addons/xterm-addon-serialize/benchmark" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user