Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,94 @@
# CSS Modules: CSS selector Tokenizer
Parses and stringifies CSS selectors.
``` js
import Tokenizer from "css-selector-tokenizer";
let input = "a#content.active > div::first-line [data-content], a:not(:visited)";
Tokenizer.parse(input); // === expected
let expected = {
type: "selectors",
nodes: [
{
type: "selector",
nodes: [
{ type: "element", name: "a" },
{ type: "id", name: "content" },
{ type: "class", name: "active" },
{ type: "operator", operator: ">", before: " ", after: " " },
{ type: "element", name: "div" },
{ type: "pseudo-element", name: "first-line" },
{ type: "spacing", value: " " },
{ type: "attribute", content: "data-content" },
]
},
{
type: "selector",
nodes: [
{ type: "element", name: "a" },
{ type: "nested-pseudo-class", name: "not", nodes: [
{
type: "selector",
nodes: [
{ type: "pseudo-class", name: "visited" }
]
}
] }
],
before: " "
}
]
}
Tokenizer.stringify(expected) // === input
// * => { type: "universal" }
// foo|element = { type: "element", name: "element", namespace: "foo" }
// *|* = { type: "universal", namespace: "*" }
// :has(h1, h2) => { type: "nested-pseudo-class", name: "has", nodes: [
// {
// type: "selector",
// nodes: [
// { type: "element", name: "h1" }
// ]
// },
// {
// type: "selector",
// nodes: [
// { type: "element", name: "h2" }
// ],
// before: " "
// }
// ] }
```
## Building
```
npm install
npm test
```
[![Build Status](https://travis-ci.org/css-modules/css-selector-tokenizer.svg?branch=master)](https://travis-ci.org/css-modules/css-selector-tokenizer)
* Lines: [![Coverage Status](https://coveralls.io/repos/css-modules/css-selector-tokenizer/badge.svg?branch=master)](https://coveralls.io/r/css-modules/css-selector-tokenizer?branch=master)
* Statements: [![codecov.io](http://codecov.io/github/css-modules/css-selector-tokenizer/coverage.svg?branch=master)](http://codecov.io/github/css-modules/css-selector-tokenizer?branch=master)
## Development
- `npm autotest` will watch `lib` and `test` for changes and retest
## License
MIT
## With thanks
- Mark Dalgleish
- Glen Maddern
- Guy Bedford
---
Tobias Koppers, 2015.

View File

@@ -0,0 +1,4 @@
exports.parse = require("./parse");
exports.stringify = require("./stringify");
exports.parseValues = require("./parseValues");
exports.stringifyValues = require("./stringifyValues");

View File

@@ -0,0 +1,239 @@
"use strict";
var Parser = require("fastparse");
var regexpu = require("regexpu-core");
function unescape(str) {
return str.replace(/\\(.)/g, "$1");
}
function commentMatch(match, content) {
this.selector.nodes.push({
type: "comment",
content: content
});
}
function typeMatch(type) {
return function(match, name) {
this.selector.nodes.push({
type: type,
name: unescape(name)
});
};
}
function pseudoClassStartMatch(match, name) {
var newToken = {
type: "pseudo-class",
name: unescape(name),
content: ""
};
this.selector.nodes.push(newToken);
this.token = newToken;
this.brackets = 1;
return "inBrackets";
}
function nestedPseudoClassStartMatch(match, name, after) {
var newSelector = {
type: "selector",
nodes: []
};
var newToken = {
type: "nested-pseudo-class",
name: unescape(name),
nodes: [newSelector]
};
if(after) {
newSelector.before = after;
}
this.selector.nodes.push(newToken);
this.stack.push(this.root);
this.root = newToken;
this.selector = newSelector;
}
function nestedEnd(match, before) {
if(this.stack.length > 0) {
if(before) {
this.selector.after = before;
}
this.root = this.stack.pop();
this.selector = this.root.nodes[this.root.nodes.length - 1];
} else {
this.selector.nodes.push({
type: "invalid",
value: match
});
}
}
function operatorMatch(match, before, operator, after) {
var token = {
type: "operator",
operator: operator
};
if(before) {
token.before = before;
}
if(after) {
token.after = after;
}
this.selector.nodes.push(token);
}
function spacingMatch(match) {
this.selector.nodes.push({
type: "spacing",
value: match
});
}
function elementMatch(match, namespace, name) {
var newToken = {
type: "element",
name: unescape(name)
};
if(namespace) {
newToken.namespace = unescape(namespace.substr(0, namespace.length - 1));
}
this.selector.nodes.push(newToken);
}
function universalMatch(match, namespace) {
var newToken = {
type: "universal"
};
if(namespace) {
newToken.namespace = unescape(namespace.substr(0, namespace.length - 1));
}
this.selector.nodes.push(newToken);
}
function attributeMatch(match, content) {
this.selector.nodes.push({
type: "attribute",
content: content
});
}
function invalidMatch(match) {
this.selector.nodes.push({
type: "invalid",
value: match
});
}
function irrelevantSpacingStartMatch(match) {
this.selector.before = match;
}
function irrelevantSpacingEndMatch(match) {
this.selector.after = match;
}
function nextSelectorMatch(match, before, after) {
var newSelector = {
type: "selector",
nodes: []
};
if(before) {
this.selector.after = before;
}
if(after) {
newSelector.before = after;
}
this.root.nodes.push(newSelector);
this.selector = newSelector;
}
function addToCurrent(match) {
this.token.content += match;
}
function bracketStart(match) {
this.token.content += match;
this.brackets++;
}
function bracketEnd(match) {
if(--this.brackets === 0) {
return "selector";
}
this.token.content += match;
}
function getSelectors() {
// The assignment here is split to preserve the property enumeration order.
var selectors = {
"/\\*([\\s\\S]*?)\\*/": commentMatch
};
// https://www.w3.org/TR/CSS21/syndata.html#characters
// 4.1.3: identifiers (...) can contain only the characters [a-zA-Z0-9] and
// ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_)
//
// 10ffff is the maximum allowed in current Unicode
selectors[regexpu("\\.((?:\\\\.|[A-Za-z_\\-\\u{00a0}-\\u{10ffff}])(?:\\\\.|[A-Za-z_\\-0-9\\u{00a0}-\\u{10ffff}])*)", "u")] = typeMatch("class");
selectors[regexpu("#((?:\\\\.|[A-Za-z_\\-\\u{00a0}-\\u{10ffff}])(?:\\\\.|[A-Za-z_\\-0-9\\u{00a0}-\\u{10ffff}])*)", "u")] = typeMatch("id");
var selectorsSecondHalf = {
":(not|matches|has|local|global)\\((\\s*)": nestedPseudoClassStartMatch,
":((?:\\\\.|[A-Za-z_\\-0-9])+)\\(": pseudoClassStartMatch,
":((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-class"),
"::((?:\\\\.|[A-Za-z_\\-0-9])+)": typeMatch("pseudo-element"),
"(\\*\\|)((?:\\\\.|[A-Za-z_\\-0-9])+)": elementMatch,
"(\\*\\|)\\*": universalMatch,
"((?:\\\\.|[A-Za-z_\\-0-9])*\\|)?\\*": universalMatch,
"((?:\\\\.|[A-Za-z_\\-0-9])*\\|)?((?:\\\\.|[A-Za-z_\\-])(?:\\\\.|[A-Za-z_\\-0-9])*)": elementMatch,
"\\[([^\\]]+)\\]": attributeMatch,
"(\\s*)\\)": nestedEnd,
"(\\s*)((?:\\|\\|)|(?:>>)|[>+~])(\\s*)": operatorMatch,
"(\\s*),(\\s*)": nextSelectorMatch,
"\\s+$": irrelevantSpacingEndMatch,
"^\\s+": irrelevantSpacingStartMatch,
"\\s+": spacingMatch,
".": invalidMatch
};
var selector;
for (selector in selectorsSecondHalf) {
if (Object.prototype.hasOwnProperty.call(selectorsSecondHalf, selector)) {
selectors[selector] = selectorsSecondHalf[selector];
}
}
return selectors;
}
var parser = new Parser({
selector: getSelectors(),
inBrackets: {
"/\\*[\\s\\S]*?\\*/": addToCurrent,
"\"([^\\\\\"]|\\\\.)*\"": addToCurrent,
"'([^\\\\']|\\\\.)*'": addToCurrent,
"[^()'\"/]+": addToCurrent,
"\\(": bracketStart,
"\\)": bracketEnd,
".": addToCurrent
}
});
function parse(str) {
var selectorNode = {
type: "selector",
nodes: []
};
var rootNode = {
type: "selectors",
nodes: [
selectorNode
]
};
parser.parse("selector", str, {
stack: [],
root: rootNode,
selector: selectorNode
});
return rootNode;
}
module.exports = parse;

View File

@@ -0,0 +1,167 @@
"use strict";
var Parser = require("fastparse");
function commentMatch(match, content) {
this.value.nodes.push({
type: "comment",
content: content
});
}
function spacingMatch(match) {
var item = this.value.nodes[this.value.nodes.length - 1];
item.after = (item.after || "") + match;
}
function initialSpacingMatch(match) {
this.value.before = match;
}
function endSpacingMatch(match) {
this.value.after = match;
}
function unescapeString(content) {
return content.replace(/\\(?:([a-fA-F0-9]{1,6})|(.))/g, function(all, unicode, otherCharacter) {
if (otherCharacter) {
return otherCharacter;
}
var C = parseInt(unicode, 16);
if(C < 0x10000) {
return String.fromCharCode(C);
} else {
return String.fromCharCode(Math.floor((C - 0x10000) / 0x400) + 0xD800) +
String.fromCharCode((C - 0x10000) % 0x400 + 0xDC00);
}
});
}
function stringMatch(match, content) {
var value = unescapeString(content);
this.value.nodes.push({
type: "string",
value: value,
stringType: match[0]
});
}
function commaMatch(match, spacing) {
var newValue = {
type: "value",
nodes: []
};
if(spacing) {
newValue.before = spacing;
}
this.root.nodes.push(newValue);
this.value = newValue;
}
function itemMatch(match) {
this.value.nodes.push({
type: "item",
name: match
});
}
function nestedItemMatch(match, name, spacing) {
this.stack.push(this.root);
this.root = {
type: "nested-item",
name: name,
nodes: [
{ type: "value", nodes: [] }
]
};
if(spacing) {
this.root.nodes[0].before = spacing;
}
this.value.nodes.push(this.root);
this.value = this.root.nodes[0];
}
function nestedItemEndMatch(match, spacing, remaining) {
if(this.stack.length === 0) {
if(spacing) {
var item = this.value.nodes[this.value.nodes.length - 1];
item.after = (item.after || "") + spacing;
}
this.value.nodes.push({
type: "invalid",
value: remaining
});
} else {
if(spacing) {
this.value.after = spacing;
}
this.root = this.stack.pop();
this.value = this.root.nodes[this.root.nodes.length - 1];
}
}
function urlMatch(match, innerSpacingBefore, content, innerSpacingAfter) {
var item = {
type: "url"
};
if(innerSpacingBefore) {
item.innerSpacingBefore = innerSpacingBefore;
}
if(innerSpacingAfter) {
item.innerSpacingAfter = innerSpacingAfter;
}
switch(content[0]) {
case "\"":
item.stringType = "\"";
item.url = unescapeString(content.substr(1, content.length - 2));
break;
case "'":
item.stringType = "'";
item.url = unescapeString(content.substr(1, content.length - 2));
break;
default:
item.url = unescapeString(content);
break;
}
this.value.nodes.push(item);
}
var parser = new Parser({
decl: {
"^\\s+": initialSpacingMatch,
"/\\*([\\s\\S]*?)\\*/": commentMatch,
"\"((?:[^\\\\\"]|\\\\.)*)\"": stringMatch,
"'((?:[^\\\\']|\\\\.)*)'": stringMatch,
"url\\((\\s*)(\"(?:[^\\\\\"]|\\\\.)*\")(\\s*)\\)": urlMatch,
"url\\((\\s*)('(?:[^\\\\']|\\\\.)*')(\\s*)\\)": urlMatch,
"url\\((\\s*)((?:[^\\\\)'\"]|\\\\.)*)(\\s*)\\)": urlMatch,
"([\\w\-]+)\\((\\s*)": nestedItemMatch,
"(\\s*)(\\))": nestedItemEndMatch,
",(\\s*)": commaMatch,
"\\s+$": endSpacingMatch,
"\\s+": spacingMatch,
"[^\\s,\)]+": itemMatch
}
});
function parseValues(str) {
var valueNode = {
type: "value",
nodes: []
};
var rootNode = {
type: "values",
nodes: [
valueNode
]
};
parser.parse("decl", str, {
stack: [],
root: rootNode,
value: valueNode
});
return rootNode;
}
module.exports = parseValues;

View File

@@ -0,0 +1,67 @@
"use strict";
var stringify;
var regexpu = require("regexpu-core");
var identifierEscapeRegexp = new RegExp(
regexpu("(^[^A-Za-z_\\-\\u{00a0}-\\u{10ffff}]|^\\-\\-|[^A-Za-z_0-9\\-\\u{00a0}-\\u{10ffff}])", "ug"),
"g"
);
function escape(str, identifier) {
if(str === "*") {
return "*";
}
if (identifier) {
return str.replace(identifierEscapeRegexp, "\\$1");
} else {
return str.replace(/(^[^A-Za-z_\\-]|^\-\-|[^A-Za-z_0-9\\-])/g, "\\$1");
}
}
function stringifyWithoutBeforeAfter(tree) {
switch(tree.type) {
case "selectors":
return tree.nodes.map(stringify).join(",");
case "selector":
return tree.nodes.map(stringify).join("");
case "element":
return (typeof tree.namespace === "string" ? escape(tree.namespace) + "|" : "") + escape(tree.name);
case "class":
return "." + escape(tree.name, true);
case "id":
return "#" + escape(tree.name, true);
case "attribute":
return "[" + tree.content + "]";
case "spacing":
return tree.value;
case "pseudo-class":
return ":" + escape(tree.name) + (typeof tree.content === "string" ? "(" + tree.content + ")" : "");
case "nested-pseudo-class":
return ":" + escape(tree.name) + "(" + tree.nodes.map(stringify).join(",") + ")";
case "pseudo-element":
return "::" + escape(tree.name);
case "universal":
return (typeof tree.namespace === "string" ? escape(tree.namespace) + "|" : "") + "*";
case "operator":
return tree.operator;
case "comment":
return "/*" + tree.content + "*/";
case "invalid":
return tree.value;
}
}
stringify = function stringify(tree) {
var str = stringifyWithoutBeforeAfter(tree);
if(tree.before) {
str = tree.before + str;
}
if(tree.after) {
str = str + tree.after;
}
return str;
};
module.exports = stringify;

View File

@@ -0,0 +1,62 @@
"use strict";
var cssesc = require("cssesc");
var stringify;
function escape(str, stringType) {
return cssesc(str, {
quotes: stringType === "\"" ? "double" : "single"
});
}
function stringifyWithoutBeforeAfter(tree) {
switch(tree.type) {
case "values":
return tree.nodes.map(stringify).join(",");
case "value":
return tree.nodes.map(stringify).join("");
case "item":
return tree.name;
case "nested-item":
return tree.name + "(" + tree.nodes.map(stringify).join(",") + ")";
case "invalid":
return tree.value;
case "comment":
return "/*" + tree.content + "*/";
case "string":
switch(tree.stringType) {
case "'":
return "'" + escape(tree.value, "'") + "'";
case "\"":
return "\"" + escape(tree.value, "\"") + "\"";
}
/* istanbul ignore next */
throw new Error("Invalid stringType");
case "url":
var start = "url(" + (tree.innerSpacingBefore || "");
var end = (tree.innerSpacingAfter || "") + ")";
switch(tree.stringType) {
case "'":
return start + "'" + tree.url.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'") + "'" + end;
case "\"":
return start + "\"" + tree.url.replace(/(\\)/g, "\\$1").replace(/"/g, "\\\"") + "\"" + end;
default:
return start + tree.url.replace(/("|'|\)|\\)/g, "\\$1") + end;
}
}
}
stringify = function stringify(tree) {
var str = stringifyWithoutBeforeAfter(tree);
if(tree.before) {
str = tree.before + str;
}
if(tree.after) {
str = str + tree.after;
}
return str;
};
module.exports = stringify;

View 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.

View File

@@ -0,0 +1,62 @@
# regexpu-core [![Build status](https://travis-ci.org/mathiasbynens/regexpu-core.svg?branch=master)](https://travis-ci.org/mathiasbynens/regexpu-core) [![Code coverage status](http://img.shields.io/coveralls/mathiasbynens/regexpu-core/master.svg)](https://coveralls.io/r/mathiasbynens/regexpu-core) [![Dependency status](https://gemnasium.com/mathiasbynens/regexpu-core.svg)](https://gemnasium.com/mathiasbynens/regexpu-core)
_regexpu_ is a source code transpiler that enables the use of ES6 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 ES6 `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-dev
```
Then, `require` it:
```js
const rewritePattern = require('regexpu-core');
```
## API
This module exports a single function named `rewritePattern`.
### `rewritePattern(pattern, flags)`
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 ES6 `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'
```
`rewritePattern` uses [regjsgen](https://github.com/d10/regjsgen), [regjsparser](https://github.com/jviereck/regjsparser), and [regenerate](https://github.com/mathiasbynens/regenerate) as internal dependencies.
## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](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.

View File

@@ -0,0 +1,104 @@
// Generated by `/scripts/character-class-escape-sets.js`. Do not edit.
var regenerate = require('regenerate');
exports.REGULAR = {
'd': regenerate()
.addRange(0x30, 0x39),
'D': regenerate()
.addRange(0x0, 0x2F)
.addRange(0x3A, 0xFFFF),
's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 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, 0x180D)
.addRange(0x180F, 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 = {
'd': regenerate()
.addRange(0x30, 0x39),
'D': regenerate()
.addRange(0x0, 0x2F)
.addRange(0x3A, 0x10FFFF),
's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 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, 0x180D)
.addRange(0x180F, 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 = {
'd': regenerate()
.addRange(0x30, 0x39),
'D': regenerate()
.addRange(0x0, 0x2F)
.addRange(0x3A, 0x10FFFF),
's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 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, 0x180D)
.addRange(0x180F, 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(0x4B, 0x53, 0x60)
.addRange(0x0, 0x2F)
.addRange(0x3A, 0x40)
.addRange(0x5B, 0x5E)
.addRange(0x7B, 0x10FFFF)
};

View File

@@ -0,0 +1,296 @@
{
"75": 8490,
"83": 383,
"107": 8490,
"115": 383,
"181": 924,
"197": 8491,
"383": 83,
"452": 453,
"453": 452,
"455": 456,
"456": 455,
"458": 459,
"459": 458,
"497": 498,
"498": 497,
"837": 8126,
"914": 976,
"917": 1013,
"920": 1012,
"921": 8126,
"922": 1008,
"924": 181,
"928": 982,
"929": 1009,
"931": 962,
"934": 981,
"937": 8486,
"962": 931,
"976": 914,
"977": 1012,
"981": 934,
"982": 928,
"1008": 922,
"1009": 929,
"1012": [
920,
977
],
"1013": 917,
"7776": 7835,
"7835": 7776,
"8126": [
837,
921
],
"8486": 937,
"8490": 75,
"8491": 197,
"66560": 66600,
"66561": 66601,
"66562": 66602,
"66563": 66603,
"66564": 66604,
"66565": 66605,
"66566": 66606,
"66567": 66607,
"66568": 66608,
"66569": 66609,
"66570": 66610,
"66571": 66611,
"66572": 66612,
"66573": 66613,
"66574": 66614,
"66575": 66615,
"66576": 66616,
"66577": 66617,
"66578": 66618,
"66579": 66619,
"66580": 66620,
"66581": 66621,
"66582": 66622,
"66583": 66623,
"66584": 66624,
"66585": 66625,
"66586": 66626,
"66587": 66627,
"66588": 66628,
"66589": 66629,
"66590": 66630,
"66591": 66631,
"66592": 66632,
"66593": 66633,
"66594": 66634,
"66595": 66635,
"66596": 66636,
"66597": 66637,
"66598": 66638,
"66599": 66639,
"66600": 66560,
"66601": 66561,
"66602": 66562,
"66603": 66563,
"66604": 66564,
"66605": 66565,
"66606": 66566,
"66607": 66567,
"66608": 66568,
"66609": 66569,
"66610": 66570,
"66611": 66571,
"66612": 66572,
"66613": 66573,
"66614": 66574,
"66615": 66575,
"66616": 66576,
"66617": 66577,
"66618": 66578,
"66619": 66579,
"66620": 66580,
"66621": 66581,
"66622": 66582,
"66623": 66583,
"66624": 66584,
"66625": 66585,
"66626": 66586,
"66627": 66587,
"66628": 66588,
"66629": 66589,
"66630": 66590,
"66631": 66591,
"66632": 66592,
"66633": 66593,
"66634": 66594,
"66635": 66595,
"66636": 66596,
"66637": 66597,
"66638": 66598,
"66639": 66599,
"68736": 68800,
"68737": 68801,
"68738": 68802,
"68739": 68803,
"68740": 68804,
"68741": 68805,
"68742": 68806,
"68743": 68807,
"68744": 68808,
"68745": 68809,
"68746": 68810,
"68747": 68811,
"68748": 68812,
"68749": 68813,
"68750": 68814,
"68751": 68815,
"68752": 68816,
"68753": 68817,
"68754": 68818,
"68755": 68819,
"68756": 68820,
"68757": 68821,
"68758": 68822,
"68759": 68823,
"68760": 68824,
"68761": 68825,
"68762": 68826,
"68763": 68827,
"68764": 68828,
"68765": 68829,
"68766": 68830,
"68767": 68831,
"68768": 68832,
"68769": 68833,
"68770": 68834,
"68771": 68835,
"68772": 68836,
"68773": 68837,
"68774": 68838,
"68775": 68839,
"68776": 68840,
"68777": 68841,
"68778": 68842,
"68779": 68843,
"68780": 68844,
"68781": 68845,
"68782": 68846,
"68783": 68847,
"68784": 68848,
"68785": 68849,
"68786": 68850,
"68800": 68736,
"68801": 68737,
"68802": 68738,
"68803": 68739,
"68804": 68740,
"68805": 68741,
"68806": 68742,
"68807": 68743,
"68808": 68744,
"68809": 68745,
"68810": 68746,
"68811": 68747,
"68812": 68748,
"68813": 68749,
"68814": 68750,
"68815": 68751,
"68816": 68752,
"68817": 68753,
"68818": 68754,
"68819": 68755,
"68820": 68756,
"68821": 68757,
"68822": 68758,
"68823": 68759,
"68824": 68760,
"68825": 68761,
"68826": 68762,
"68827": 68763,
"68828": 68764,
"68829": 68765,
"68830": 68766,
"68831": 68767,
"68832": 68768,
"68833": 68769,
"68834": 68770,
"68835": 68771,
"68836": 68772,
"68837": 68773,
"68838": 68774,
"68839": 68775,
"68840": 68776,
"68841": 68777,
"68842": 68778,
"68843": 68779,
"68844": 68780,
"68845": 68781,
"68846": 68782,
"68847": 68783,
"68848": 68784,
"68849": 68785,
"68850": 68786,
"71840": 71872,
"71841": 71873,
"71842": 71874,
"71843": 71875,
"71844": 71876,
"71845": 71877,
"71846": 71878,
"71847": 71879,
"71848": 71880,
"71849": 71881,
"71850": 71882,
"71851": 71883,
"71852": 71884,
"71853": 71885,
"71854": 71886,
"71855": 71887,
"71856": 71888,
"71857": 71889,
"71858": 71890,
"71859": 71891,
"71860": 71892,
"71861": 71893,
"71862": 71894,
"71863": 71895,
"71864": 71896,
"71865": 71897,
"71866": 71898,
"71867": 71899,
"71868": 71900,
"71869": 71901,
"71870": 71902,
"71871": 71903,
"71872": 71840,
"71873": 71841,
"71874": 71842,
"71875": 71843,
"71876": 71844,
"71877": 71845,
"71878": 71846,
"71879": 71847,
"71880": 71848,
"71881": 71849,
"71882": 71850,
"71883": 71851,
"71884": 71852,
"71885": 71853,
"71886": 71854,
"71887": 71855,
"71888": 71856,
"71889": 71857,
"71890": 71858,
"71891": 71859,
"71892": 71860,
"71893": 71861,
"71894": 71862,
"71895": 71863,
"71896": 71864,
"71897": 71865,
"71898": 71866,
"71899": 71867,
"71900": 71868,
"71901": 71869,
"71902": 71870,
"71903": 71871
}

View File

@@ -0,0 +1,92 @@
{
"_args": [
[
"regexpu-core@1.0.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "regexpu-core@1.0.0",
"_id": "regexpu-core@1.0.0",
"_inBundle": false,
"_integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=",
"_location": "/react-scripts/css-selector-tokenizer/regexpu-core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "regexpu-core@1.0.0",
"name": "regexpu-core",
"escapedName": "regexpu-core",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/react-scripts/css-selector-tokenizer"
],
"_resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Mathias Bynens",
"url": "https://mathiasbynens.be/"
},
"bugs": {
"url": "https://github.com/mathiasbynens/regexpu-core/issues"
},
"dependencies": {
"regenerate": "^1.2.1",
"regjsgen": "^0.2.0",
"regjsparser": "^0.1.4"
},
"description": "regexpus core functionality (i.e. `rewritePattern(pattern, flag)`), capable of translating ES6 Unicode regular expressions to ES5.",
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.4.0",
"jsesc": "^0.5.0",
"lodash": "^3.6.0",
"mocha": "^2.2.1",
"regexpu-fixtures": "^1.0.0",
"unicode-5.1.0": "^0.1.5",
"unicode-8.0.0": "^0.1.5"
},
"files": [
"LICENSE-MIT.txt",
"rewrite-pattern.js",
"data/character-class-escape-sets.js",
"data/iu-mappings.json"
],
"homepage": "https://mths.be/regexpu",
"keywords": [
"codegen",
"desugaring",
"ecmascript",
"es5",
"es6",
"harmony",
"javascript",
"refactoring",
"regex",
"regexp",
"regular expressions",
"rewriting",
"syntax",
"transformation",
"transpile",
"transpiler",
"unicode"
],
"license": "MIT",
"main": "rewrite-pattern.js",
"name": "regexpu-core",
"repository": {
"type": "git",
"url": "git+https://github.com/mathiasbynens/regexpu-core.git"
},
"scripts": {
"build": "node scripts/iu-mappings.js && node scripts/character-class-escape-sets.js",
"coverage": "istanbul cover --report html node_modules/.bin/_mocha tests/tests.js -- -u exports -R spec",
"test": "mocha tests"
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,193 @@
var generate = require('regjsgen').generate;
var parse = require('regjsparser').parse;
var regenerate = require('regenerate');
var iuMappings = require('./data/iu-mappings.json');
var ESCAPE_SETS = require('./data/character-class-escape-sets.js');
function getCharacterClassEscapeSet(character) {
if (unicode) {
if (ignoreCase) {
return ESCAPE_SETS.UNICODE_IGNORE_CASE[character];
}
return ESCAPE_SETS.UNICODE[character];
}
return ESCAPE_SETS.REGULAR[character];
}
var object = {};
var hasOwnProperty = object.hasOwnProperty;
function has(object, property) {
return hasOwnProperty.call(object, property);
}
// Prepare a Regenerate set containing all code points, used for negative
// character classes (if any).
var UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF);
// Without the `u` flag, the range stops at 0xFFFF.
// https://mths.be/es6#sec-pattern-semantics
var BMP_SET = regenerate().addRange(0x0, 0xFFFF);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./u`. https://mths.be/es6#sec-atom
var DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points
.remove(
// minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators):
0x000A, // Line Feed <LF>
0x000D, // Carriage Return <CR>
0x2028, // Line Separator <LS>
0x2029 // Paragraph Separator <PS>
);
// Prepare a Regenerate set containing all code points that are supposed to be
// matched by `/./` (only BMP code points).
var DOT_SET = DOT_SET_UNICODE.clone()
.intersection(BMP_SET);
// Add a range of code points + any case-folded code points in that range to a
// set.
regenerate.prototype.iuAddRange = function(min, max) {
var $this = this;
do {
var folded = caseFold(min);
if (folded) {
$this.add(folded);
}
} while (++min <= max);
return $this;
};
function assign(target, source) {
for (var key in source) {
// Note: `hasOwnProperty` is not needed here.
target[key] = source[key];
}
}
function update(item, pattern) {
// TODO: Test if memoizing `pattern` here is worth the effort.
if (!pattern) {
return;
}
var tree = parse(pattern, '');
switch (tree.type) {
case 'characterClass':
case 'group':
case 'value':
// No wrapping needed.
break;
default:
// Wrap the pattern in a non-capturing group.
tree = wrap(tree, pattern);
}
assign(item, tree);
}
function wrap(tree, pattern) {
// Wrap the pattern in a non-capturing group.
return {
'type': 'group',
'behavior': 'ignore',
'body': [tree],
'raw': '(?:' + pattern + ')'
};
}
function caseFold(codePoint) {
return has(iuMappings, codePoint) ? iuMappings[codePoint] : false;
}
var ignoreCase = false;
var unicode = false;
function processCharacterClass(characterClassItem) {
var set = regenerate();
var body = characterClassItem.body.forEach(function(item) {
switch (item.type) {
case 'value':
set.add(item.codePoint);
if (ignoreCase && unicode) {
var folded = caseFold(item.codePoint);
if (folded) {
set.add(folded);
}
}
break;
case 'characterClassRange':
var min = item.min.codePoint;
var max = item.max.codePoint;
set.addRange(min, max);
if (ignoreCase && unicode) {
set.iuAddRange(min, max);
}
break;
case 'characterClassEscape':
set.add(getCharacterClassEscapeSet(item.value));
break;
// The `default` clause is only here as a safeguard; it should never be
// reached. Code coverage tools should ignore it.
/* istanbul ignore next */
default:
throw Error('Unknown term type: ' + item.type);
}
});
if (characterClassItem.negative) {
set = (unicode ? UNICODE_SET : BMP_SET).clone().remove(set);
}
update(characterClassItem, set.toString());
return characterClassItem;
}
function processTerm(item) {
switch (item.type) {
case 'dot':
update(
item,
(unicode ? DOT_SET_UNICODE : DOT_SET).toString()
);
break;
case 'characterClass':
item = processCharacterClass(item);
break;
case 'characterClassEscape':
update(
item,
getCharacterClassEscapeSet(item.value).toString()
);
break;
case 'alternative':
case 'disjunction':
case 'group':
case 'quantifier':
item.body = item.body.map(processTerm);
break;
case 'value':
var codePoint = item.codePoint;
var set = regenerate(codePoint);
if (ignoreCase && unicode) {
var folded = caseFold(codePoint);
if (folded) {
set.add(folded);
}
}
update(item, set.toString());
break;
case 'anchor':
case 'empty':
case 'group':
case 'reference':
// Nothing to do here.
break;
// The `default` clause is only here as a safeguard; it should never be
// reached. Code coverage tools should ignore it.
/* istanbul ignore next */
default:
throw Error('Unknown term type: ' + item.type);
}
return item;
};
module.exports = function(pattern, flags) {
var tree = parse(pattern, flags);
ignoreCase = flags ? flags.indexOf('i') > -1 : false;
unicode = flags ? flags.indexOf('u') > -1 : false;
assign(tree, processTerm(tree));
return generate(tree);
};

View File

@@ -0,0 +1,85 @@
{
"_args": [
[
"css-selector-tokenizer@0.7.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "css-selector-tokenizer@0.7.0",
"_id": "css-selector-tokenizer@0.7.0",
"_inBundle": false,
"_integrity": "sha1-5piEdK6MlTR3v15+/s/OzNnPTIY=",
"_location": "/react-scripts/css-selector-tokenizer",
"_phantomChildren": {
"regenerate": "1.3.3",
"regjsgen": "0.2.0",
"regjsparser": "0.1.5"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "css-selector-tokenizer@0.7.0",
"name": "css-selector-tokenizer",
"escapedName": "css-selector-tokenizer",
"rawSpec": "0.7.0",
"saveSpec": null,
"fetchSpec": "0.7.0"
},
"_requiredBy": [
"/react-scripts/css-loader",
"/react-scripts/postcss-modules-local-by-default",
"/react-scripts/postcss-modules-scope"
],
"_resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.7.0.tgz",
"_spec": "0.7.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/css-modules/css-selector-tokenizer/issues"
},
"dependencies": {
"cssesc": "^0.1.0",
"fastparse": "^1.1.1",
"regexpu-core": "^1.0.0"
},
"description": "Parses and stringifies CSS selectors",
"devDependencies": {
"chokidar-cli": "^0.2.1",
"codecov.io": "^0.1.2",
"coveralls": "^2.11.2",
"eslint": "^0.21.2",
"istanbul": "^0.3.14",
"mocha": "^2.2.5"
},
"directories": {
"test": "test"
},
"files": [
"lib"
],
"homepage": "https://github.com/css-modules/css-selector-tokenizer",
"keywords": [
"css-modules",
"selectors"
],
"license": "MIT",
"main": "lib/index.js",
"name": "css-selector-tokenizer",
"repository": {
"type": "git",
"url": "git+https://github.com/css-modules/css-selector-tokenizer.git"
},
"scripts": {
"autotest": "chokidar lib test -c 'npm test'",
"cover": "istanbul cover node_modules/mocha/bin/_mocha",
"lint": "eslint lib",
"precover": "npm run lint",
"pretest": "npm run lint",
"publish-patch": "npm test && npm version patch && git push && git push --tags && npm publish",
"test": "mocha",
"travis": "npm run cover -- --report lcovonly"
},
"version": "0.7.0"
}