$
This commit is contained in:
20
node_modules/regexpu-core/LICENSE-MIT.txt
generated
vendored
Normal file
20
node_modules/regexpu-core/LICENSE-MIT.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
204
node_modules/regexpu-core/README.md
generated
vendored
Normal file
204
node_modules/regexpu-core/README.md
generated
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
# regexpu-core [](https://github.com/mathiasbynens/regexpu-core/actions?query=workflow%3Arun-checks) [](https://www.npmjs.com/package/regexpu-core)
|
||||
|
||||
_regexpu_ is a source code transpiler that enables the use of ES2015 Unicode regular expressions in JavaScript-of-today (ES5).
|
||||
|
||||
_regexpu-core_ contains _regexpu_’s core functionality, i.e. `rewritePattern(pattern, flag)`, which enables rewriting regular expressions that make use of [the ES2015 `u` flag](https://mathiasbynens.be/notes/es6-unicode-regex) into equivalent ES5-compatible regular expression patterns.
|
||||
|
||||
## Installation
|
||||
|
||||
To use _regexpu-core_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
npm install regexpu-core --save
|
||||
```
|
||||
|
||||
Then, `require` it:
|
||||
|
||||
```js
|
||||
const rewritePattern = require('regexpu-core');
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This module exports a single function named `rewritePattern`.
|
||||
|
||||
### `rewritePattern(pattern, flags, options)`
|
||||
|
||||
This function takes a string that represents a regular expression pattern as well as a string representing its flags, and returns an ES5-compatible version of the pattern.
|
||||
|
||||
```js
|
||||
rewritePattern('foo.bar', 'u');
|
||||
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uDC00-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF])bar'
|
||||
|
||||
rewritePattern('[\\u{1D306}-\\u{1D308}a-z]', 'u');
|
||||
// → '(?:[a-z]|\\uD834[\\uDF06-\\uDF08])'
|
||||
|
||||
rewritePattern('[\\u{1D306}-\\u{1D308}a-z]', 'ui');
|
||||
// → '(?:[a-z\\u017F\\u212A]|\\uD834[\\uDF06-\\uDF08])'
|
||||
```
|
||||
|
||||
_regexpu-core_ can rewrite non-ES6 regular expressions too, which is useful to demonstrate how their behavior changes once the `u` and `i` flags are added:
|
||||
|
||||
```js
|
||||
// In ES5, the dot operator only matches BMP symbols:
|
||||
rewritePattern('foo.bar');
|
||||
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uFFFF])bar'
|
||||
|
||||
// But with the ES2015 `u` flag, it matches astral symbols too:
|
||||
rewritePattern('foo.bar', 'u');
|
||||
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uDC00-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF])bar'
|
||||
```
|
||||
|
||||
The optional `options` argument recognizes the following properties:
|
||||
|
||||
#### Stable regular expression features
|
||||
|
||||
These options can be set to `false` or `'transform'`. When using `'transform'`, the corresponding features are compiled to older syntax that can run in older browsers. When using `false` (the default), they are not compiled and they can be relied upon to compile more modern features.
|
||||
|
||||
- `unicodeFlag` - The `u` flag, enabling support for Unicode code point escapes in the form `\u{...}`.
|
||||
|
||||
```js
|
||||
rewritePattern('\\u{ab}', '', {
|
||||
unicodeFlag: 'transform'
|
||||
});
|
||||
// → '\\u{ab}'
|
||||
|
||||
rewritePattern('\\u{ab}', 'u', {
|
||||
unicodeFlag: 'transform'
|
||||
});
|
||||
// → '\\xAB'
|
||||
```
|
||||
|
||||
- `dotAllFlag` - The [`s` (`dotAll`) flag](https://github.com/mathiasbynens/es-regexp-dotall-flag).
|
||||
|
||||
```js
|
||||
rewritePattern('.', '', {
|
||||
dotAllFlag: 'transform'
|
||||
});
|
||||
// → '[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uFFFF]'
|
||||
|
||||
rewritePattern('.', 's', {
|
||||
dotAllFlag: 'transform'
|
||||
});
|
||||
// → '[\\0-\\uFFFF]'
|
||||
|
||||
rewritePattern('.', 'su', {
|
||||
dotAllFlag: 'transform'
|
||||
});
|
||||
// → '(?:[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])'
|
||||
```
|
||||
|
||||
- `unicodePropertyEscapes` - [Unicode property escapes](property-escapes.md).
|
||||
|
||||
By default they are compiled to Unicode code point escapes of the form `\u{...}`. If the `unicodeFlag` option is set to `'transform'` they often result in larger output, although there are cases (such as `\p{Lu}`) where it actually _decreases_ the output size.
|
||||
|
||||
```js
|
||||
rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {
|
||||
unicodePropertyEscapes: 'transform'
|
||||
});
|
||||
// → '[\\u{14400}-\\u{14646}]'
|
||||
|
||||
rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', {
|
||||
unicodeFlag: 'transform',
|
||||
unicodePropertyEscapes: 'transform'
|
||||
});
|
||||
// → '(?:\\uD811[\\uDC00-\\uDE46])'
|
||||
```
|
||||
|
||||
- `namedGroups` - [Named capture groups](https://github.com/tc39/proposal-regexp-named-groups).
|
||||
|
||||
```js
|
||||
rewritePattern('(?<name>.)\\k<name>', '', {
|
||||
namedGroups: 'transform'
|
||||
});
|
||||
// → '(.)\1'
|
||||
```
|
||||
|
||||
#### Experimental regular expression features
|
||||
|
||||
These options can be set to `false`, `'parse'` and `'transform'`. When using `'transform'`, the corresponding features are compiled to older syntax that can run in older browsers. When using `'parse'`, they are parsed and left as-is in the output pattern. When using `false` (the default), they result in a syntax error if used.
|
||||
|
||||
Once these features become stable (when the proposals are accepted as part of ECMAScript), they will be parsed by default and thus `'parse'` will behave like `false`.
|
||||
|
||||
- `unicodeSetsFlag` - [The `v` (`unicodeSets`) flag](https://github.com/tc39/proposal-regexp-set-notation)
|
||||
|
||||
```js
|
||||
rewritePattern('[\\p{Emoji}&&\\p{ASCII}]', 'u', {
|
||||
unicodeSetsFlag: 'transform'
|
||||
});
|
||||
// → '[#\*0-9]'
|
||||
```
|
||||
|
||||
By default, patterns with the `v` flag are transformed to patterns with the `u` flag. If you want to downlevel them more you can set the `unicodeFlag: 'transform'` option.
|
||||
|
||||
```js
|
||||
rewritePattern('[^[a-h]&&[f-z]]', 'v', {
|
||||
unicodeSetsFlag: 'transform'
|
||||
});
|
||||
// → '[^f-h]' (to be used with /u)
|
||||
```
|
||||
|
||||
```js
|
||||
rewritePattern('[^[a-h]&&[f-z]]', 'v', {
|
||||
unicodeSetsFlag: 'transform',
|
||||
unicodeFlag: 'transform'
|
||||
});
|
||||
// → '(?:(?![f-h])[\s\S])' (to be used without /u)
|
||||
```
|
||||
|
||||
|
||||
#### Miscellaneous options
|
||||
|
||||
- `onNamedGroup`
|
||||
|
||||
This option is a function that gets called when a named capture group is found. It receives two parameters:
|
||||
the name of the group, and its index.
|
||||
|
||||
```js
|
||||
rewritePattern('(?<name>.)\\k<name>', '', {
|
||||
onNamedGroup(name, index) {
|
||||
console.log(name, index);
|
||||
// → 'name', 1
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Caveats
|
||||
|
||||
- [Lookbehind assertions](https://github.com/tc39/proposal-regexp-lookbehind) cannot be transformed to older syntax.
|
||||
- When using `namedGroups: 'transform'`, _regexpu-core_ only takes care of the _syntax_: you will still need a runtime wrapper around the regular expression to populate the `.groups` property of `RegExp.prototype.match()`'s result. If you are using _regexpu-core_ via Babel, it's handled automatically.
|
||||
|
||||
## For maintainers
|
||||
|
||||
### How to publish a new release
|
||||
|
||||
1. On the `main` branch, bump the version number in `package.json`:
|
||||
|
||||
```sh
|
||||
npm version patch -m 'Release v%s'
|
||||
```
|
||||
|
||||
Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/).
|
||||
|
||||
Note that this produces a Git commit + tag.
|
||||
|
||||
1. Push the release commit and tag:
|
||||
|
||||
```sh
|
||||
git push && git push --tags
|
||||
```
|
||||
|
||||
Our CI then automatically publishes the new release to npm.
|
||||
|
||||
1. Once the release has been published to npm, update [`regexpu`](https://github.com/mathiasbynens/regexpu) to make use of it, and [cut a new release of `regexpu` as well](https://github.com/mathiasbynens/regexpu#how-to-publish-a-new-release).
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||
|---|
|
||||
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||
|
||||
## License
|
||||
|
||||
_regexpu-core_ is available under the [MIT](https://mths.be/mit) license.
|
||||
105
node_modules/regexpu-core/data/character-class-escape-sets.js
generated
vendored
Normal file
105
node_modules/regexpu-core/data/character-class-escape-sets.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
// Generated using `npm run build`. Do not edit.
|
||||
'use strict';
|
||||
|
||||
const regenerate = require('regenerate');
|
||||
|
||||
exports.REGULAR = new Map([
|
||||
['d', regenerate()
|
||||
.addRange(0x30, 0x39)],
|
||||
['D', regenerate()
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0xFFFF)],
|
||||
['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF)
|
||||
.addRange(0x9, 0xD)
|
||||
.addRange(0x2000, 0x200A)
|
||||
.addRange(0x2028, 0x2029)],
|
||||
['S', regenerate()
|
||||
.addRange(0x0, 0x8)
|
||||
.addRange(0xE, 0x1F)
|
||||
.addRange(0x21, 0x9F)
|
||||
.addRange(0xA1, 0x167F)
|
||||
.addRange(0x1681, 0x1FFF)
|
||||
.addRange(0x200B, 0x2027)
|
||||
.addRange(0x202A, 0x202E)
|
||||
.addRange(0x2030, 0x205E)
|
||||
.addRange(0x2060, 0x2FFF)
|
||||
.addRange(0x3001, 0xFEFE)
|
||||
.addRange(0xFF00, 0xFFFF)],
|
||||
['w', regenerate(0x5F)
|
||||
.addRange(0x30, 0x39)
|
||||
.addRange(0x41, 0x5A)
|
||||
.addRange(0x61, 0x7A)],
|
||||
['W', regenerate(0x60)
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0x40)
|
||||
.addRange(0x5B, 0x5E)
|
||||
.addRange(0x7B, 0xFFFF)]
|
||||
]);
|
||||
|
||||
exports.UNICODE = new Map([
|
||||
['d', regenerate()
|
||||
.addRange(0x30, 0x39)],
|
||||
['D', regenerate()
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0x10FFFF)],
|
||||
['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF)
|
||||
.addRange(0x9, 0xD)
|
||||
.addRange(0x2000, 0x200A)
|
||||
.addRange(0x2028, 0x2029)],
|
||||
['S', regenerate()
|
||||
.addRange(0x0, 0x8)
|
||||
.addRange(0xE, 0x1F)
|
||||
.addRange(0x21, 0x9F)
|
||||
.addRange(0xA1, 0x167F)
|
||||
.addRange(0x1681, 0x1FFF)
|
||||
.addRange(0x200B, 0x2027)
|
||||
.addRange(0x202A, 0x202E)
|
||||
.addRange(0x2030, 0x205E)
|
||||
.addRange(0x2060, 0x2FFF)
|
||||
.addRange(0x3001, 0xFEFE)
|
||||
.addRange(0xFF00, 0x10FFFF)],
|
||||
['w', regenerate(0x5F)
|
||||
.addRange(0x30, 0x39)
|
||||
.addRange(0x41, 0x5A)
|
||||
.addRange(0x61, 0x7A)],
|
||||
['W', regenerate(0x60)
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0x40)
|
||||
.addRange(0x5B, 0x5E)
|
||||
.addRange(0x7B, 0x10FFFF)]
|
||||
]);
|
||||
|
||||
exports.UNICODE_IGNORE_CASE = new Map([
|
||||
['d', regenerate()
|
||||
.addRange(0x30, 0x39)],
|
||||
['D', regenerate()
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0x10FFFF)],
|
||||
['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF)
|
||||
.addRange(0x9, 0xD)
|
||||
.addRange(0x2000, 0x200A)
|
||||
.addRange(0x2028, 0x2029)],
|
||||
['S', regenerate()
|
||||
.addRange(0x0, 0x8)
|
||||
.addRange(0xE, 0x1F)
|
||||
.addRange(0x21, 0x9F)
|
||||
.addRange(0xA1, 0x167F)
|
||||
.addRange(0x1681, 0x1FFF)
|
||||
.addRange(0x200B, 0x2027)
|
||||
.addRange(0x202A, 0x202E)
|
||||
.addRange(0x2030, 0x205E)
|
||||
.addRange(0x2060, 0x2FFF)
|
||||
.addRange(0x3001, 0xFEFE)
|
||||
.addRange(0xFF00, 0x10FFFF)],
|
||||
['w', regenerate(0x5F, 0x17F, 0x212A)
|
||||
.addRange(0x30, 0x39)
|
||||
.addRange(0x41, 0x5A)
|
||||
.addRange(0x61, 0x7A)],
|
||||
['W', regenerate(0x60)
|
||||
.addRange(0x0, 0x2F)
|
||||
.addRange(0x3A, 0x40)
|
||||
.addRange(0x5B, 0x5E)
|
||||
.addRange(0x7B, 0x17E)
|
||||
.addRange(0x180, 0x2129)
|
||||
.addRange(0x212B, 0x10FFFF)]
|
||||
]);
|
||||
656
node_modules/regexpu-core/data/iu-mappings.js
generated
vendored
Normal file
656
node_modules/regexpu-core/data/iu-mappings.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
67
node_modules/regexpu-core/package.json
generated
vendored
Normal file
67
node_modules/regexpu-core/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "regexpu-core",
|
||||
"version": "5.1.0",
|
||||
"description": "regexpu’s core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.",
|
||||
"homepage": "https://mths.be/regexpu",
|
||||
"main": "rewrite-pattern.js",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"keywords": [
|
||||
"codegen",
|
||||
"desugaring",
|
||||
"ecmascript",
|
||||
"es5",
|
||||
"es6",
|
||||
"harmony",
|
||||
"javascript",
|
||||
"refactoring",
|
||||
"regex",
|
||||
"regexp",
|
||||
"regular expressions",
|
||||
"rewriting",
|
||||
"syntax",
|
||||
"transformation",
|
||||
"transpile",
|
||||
"transpiler",
|
||||
"unicode"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathiasbynens/regexpu-core.git"
|
||||
},
|
||||
"bugs": "https://github.com/mathiasbynens/regexpu-core/issues",
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"rewrite-pattern.js",
|
||||
"data/character-class-escape-sets.js",
|
||||
"data/iu-mappings.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "node scripts/iu-mappings.js && node scripts/character-class-escape-sets.js",
|
||||
"test": "mocha tests",
|
||||
"cover": "istanbul cover --report html node_modules/.bin/_mocha tests -- -u exports -R spec"
|
||||
},
|
||||
"dependencies": {
|
||||
"regenerate": "^1.4.2",
|
||||
"regenerate-unicode-properties": "^10.0.1",
|
||||
"regjsgen": "^0.6.0",
|
||||
"regjsparser": "^0.8.2",
|
||||
"unicode-match-property-ecmascript": "^2.0.0",
|
||||
"unicode-match-property-value-ecmascript": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"codecov": "^3.8.3",
|
||||
"istanbul": "^0.4.5",
|
||||
"jsesc": "^3.0.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mocha": "^9.1.1",
|
||||
"regexpu-fixtures": "2.1.4",
|
||||
"@unicode/unicode-14.0.0": "^1.2.1"
|
||||
}
|
||||
}
|
||||
730
node_modules/regexpu-core/rewrite-pattern.js
generated
vendored
Normal file
730
node_modules/regexpu-core/rewrite-pattern.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user