ansi-regex 6.0.1 → 6.1.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/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export interface Options {
1
+ export type Options = {
2
2
  /**
3
3
  Match only the first ANSI escape.
4
4
 
5
5
  @default false
6
6
  */
7
7
  readonly onlyFirst: boolean;
8
- }
8
+ };
9
9
 
10
10
  /**
11
11
  Regular expression for matching ANSI escape codes.
package/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export default function ansiRegex({onlyFirst = false} = {}) {
2
+ // Valid string terminator sequences are BEL, ESC\, and 0x9c
3
+ const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
2
4
  const pattern = [
3
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
4
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
5
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
6
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
5
7
  ].join('|');
6
8
 
7
9
  return new RegExp(pattern, onlyFirst ? undefined : 'g');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ansi-regex",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "Regular expression for matching ANSI escape codes",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/ansi-regex",
@@ -12,6 +12,8 @@
12
12
  },
13
13
  "type": "module",
14
14
  "exports": "./index.js",
15
+ "types": "./index.d.ts",
16
+ "sideEffects": false,
15
17
  "engines": {
16
18
  "node": ">=12"
17
19
  },
@@ -51,8 +53,9 @@
51
53
  "pattern"
52
54
  ],
53
55
  "devDependencies": {
56
+ "ansi-escapes": "^5.0.0",
54
57
  "ava": "^3.15.0",
55
- "tsd": "^0.14.0",
56
- "xo": "^0.38.2"
58
+ "tsd": "^0.21.0",
59
+ "xo": "^0.54.2"
57
60
  }
58
61
  }
package/readme.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  ## Install
6
6
 
7
- ```
8
- $ npm install ansi-regex
7
+ ```sh
8
+ npm install ansi-regex
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -58,15 +58,3 @@ On the historical side, those ECMA standards were established in the early 90's
58
58
 
59
59
  - [Sindre Sorhus](https://github.com/sindresorhus)
60
60
  - [Josh Junon](https://github.com/qix-)
61
-
62
- ---
63
-
64
- <div align="center">
65
- <b>
66
- <a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
67
- </b>
68
- <br>
69
- <sub>
70
- Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
71
- </sub>
72
- </div>