@ansi-tools/parser 1.0.1 → 1.0.2
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/README.md +3 -12
- package/dist/escaped.js +2 -2
- package/dist/index.js +1 -1
- package/dist/{parse-DX-Po36R.js → parse-D-nJlcK3.js} +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -2,18 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Parser for ANSI escape sequences.
|
|
4
4
|
|
|
5
|
-
## Supported sequence types
|
|
6
|
-
|
|
7
|
-
- **CSI** (Control Sequence Introducer): `\x1b[...`
|
|
8
|
-
- **OSC** (Operating System Command): `\x1b]...`
|
|
9
|
-
- **DCS** (Device Control String): `\x1bP...`
|
|
10
|
-
- **ESC** (Escape): `\x1b...`
|
|
11
|
-
- **DEC** (DEC Private Mode): `\x1b[?...`
|
|
12
|
-
- **STRING** (APC/PM/SOS): `\x1b_...`, `\x1b^...`, `\x1bX...`
|
|
13
|
-
- **PRIVATE** (Private sequences): `\x1b[<...`, `\x1b[=...`, `\x1b[>...`
|
|
14
|
-
|
|
15
5
|
## Features
|
|
16
6
|
|
|
7
|
+
- ✅ Supports CSI, OSC, DCS, ESC, APC, SOS, PM, etc.
|
|
17
8
|
- ✅ Handles 7-bit (`\x1b` or `\u001b`) and 8-bit (`\u009b`) introducers
|
|
18
9
|
- ✅ Handles octal (`\033`) and shorthand `\e` introducers (only escaped)
|
|
19
10
|
- ✅ Multiple string terminators (`\x1b\\`, `\x07`)
|
|
@@ -44,8 +35,8 @@ There is a difference between escaped and unescaped input. Only with an escaped
|
|
|
44
35
|
input string the raw input and the positions can be preserved in the tokens and
|
|
45
36
|
control codes. See the example below for the default and the `/escaped` import.
|
|
46
37
|
|
|
47
|
-
The default and unescaped tokenization is roughly ~30% faster. Use this
|
|
48
|
-
|
|
38
|
+
The default and unescaped tokenization is roughly ~30% faster. Use this if you
|
|
39
|
+
just need the control codes.
|
|
49
40
|
|
|
50
41
|
## Examples
|
|
51
42
|
|
package/dist/escaped.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APC, APC_OPEN, BACKSLASH, BELL, CODE_TYPES, CSI, CSI_OPEN, DCS, DCS_OPEN, DEC_OPEN, ESC, OSC, OSC_OPEN, PM, PM_OPEN, PRIVATE_OPENERS, SOS, SOS_OPEN, ST, STRING_OPENERS, TOKEN_TYPES, parser } from "./parse-
|
|
1
|
+
import { APC, APC_OPEN, BACKSLASH, BELL, CODE_TYPES, CSI, CSI_OPEN, DCS, DCS_OPEN, DEC_OPEN, ESC, OSC, OSC_OPEN, PM, PM_OPEN, PRIVATE_OPENERS, SOS, SOS_OPEN, ST, STRING_OPENERS, TOKEN_TYPES, parser } from "./parse-D-nJlcK3.js";
|
|
2
2
|
|
|
3
3
|
//#region src/tokenize.escaped.ts
|
|
4
4
|
const CSI_ESCAPED = "\\u009b";
|
|
@@ -121,7 +121,7 @@ function* tokenizer(input) {
|
|
|
121
121
|
});
|
|
122
122
|
i += len;
|
|
123
123
|
setState("SEQUENCE", ESC);
|
|
124
|
-
}
|
|
124
|
+
} else i += len;
|
|
125
125
|
}
|
|
126
126
|
break;
|
|
127
127
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { APC, APC_OPEN, BACKSLASH, BELL, CODE_TYPES, CSI, CSI_OPEN, DCS, DCS_OPEN, DEC_OPEN, ESC, OSC, OSC_OPEN, PM, PM_OPEN, PRIVATE_OPENERS, SOS, SOS_OPEN, ST, STRING_OPENERS, TOKEN_TYPES, parse, parser, tokenize, tokenizer } from "./parse-
|
|
1
|
+
import { APC, APC_OPEN, BACKSLASH, BELL, CODE_TYPES, CSI, CSI_OPEN, DCS, DCS_OPEN, DEC_OPEN, ESC, OSC, OSC_OPEN, PM, PM_OPEN, PRIVATE_OPENERS, SOS, SOS_OPEN, ST, STRING_OPENERS, TOKEN_TYPES, parse, parser, tokenize, tokenizer } from "./parse-D-nJlcK3.js";
|
|
2
2
|
|
|
3
3
|
export { APC, APC_OPEN, BACKSLASH, BELL, CODE_TYPES, CSI, CSI_OPEN, DCS, DCS_OPEN, DEC_OPEN, ESC, OSC, OSC_OPEN, PM, PM_OPEN, PRIVATE_OPENERS, SOS, SOS_OPEN, ST, STRING_OPENERS, TOKEN_TYPES, parse, parser, tokenize, tokenizer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ansi-tools/parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Tokenize and parse strings containing ANSI escape sequences and control codes",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"prebuild": "pnpm type-check && pnpm test",
|
|
24
24
|
"build": "tsdown --dts src/index.ts src/escaped.ts",
|
|
25
|
+
"dev": "tsdown --dts src/index.ts src/escaped.ts --watch",
|
|
25
26
|
"test": "node --test",
|
|
26
27
|
"type-check": "tsc",
|
|
27
28
|
"prepack": "pnpm build"
|