08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

5
node_modules/CSSwhat/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
- "0.10"
- 0.11

11
node_modules/CSSwhat/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

182
node_modules/CSSwhat/index.js generated vendored Normal file
View File

@@ -0,0 +1,182 @@
"use strict";
module.exports = parse;
var re_ws = /^\s/,
re_name = /^(?:\\.|[\w\-\u00c0-\uFFFF])+/,
re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig,
//modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])(.*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
var actionTypes = {
__proto__: null,
"undefined": "exists",
"": "equals",
"~": "element",
"^": "start",
"$": "end",
"*": "any",
"!": "not",
"|": "hyphen"
};
var simpleSelectors = {
__proto__: null,
">": "child",
"<": "parent",
"~": "sibling",
"+": "adjacent"
};
var attribSelectors = {
__proto__: null,
"#": ["id", "equals"],
".": ["class", "element"]
};
//unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
function funescape( _, escaped, escapedWhitespace ) {
var high = "0x" + escaped - 0x10000;
// NaN means non-codepoint
// Support: Firefox
// Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ?
escaped :
// BMP codepoint
high < 0 ?
String.fromCharCode( high + 0x10000 ) :
// Supplemental Plane codepoint (surrogate pair)
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
}
function unescapeCSS(str){
return str.replace(re_escape, funescape);
}
function getClosingPos(selector){
var pos = 1, counter = 1, len = selector.length;
for(; counter > 0 && pos < len; pos++){
if(selector.charAt(pos) === "(") counter++;
else if(selector.charAt(pos) === ")") counter--;
}
return pos;
}
function parse(selector, options){
selector = (selector + "").trimLeft();
var subselects = [],
tokens = [],
sawWS = false,
data, firstChar, name;
function getName(){
var sub = selector.match(re_name)[0];
selector = selector.substr(sub.length);
return unescapeCSS(sub);
}
while(selector !== ""){
if(re_name.test(selector)){
if(sawWS){
tokens.push({type: "descendant"});
sawWS = false;
}
name = getName();
if(!options || ("lowerCaseTags" in options ? options.lowerCaseTags : !options.xmlMode)){
name = name.toLowerCase();
}
tokens.push({type: "tag", name: name});
} else if(re_ws.test(selector)){
sawWS = true;
selector = selector.trimLeft();
} else {
firstChar = selector.charAt(0);
selector = selector.substr(1);
if(firstChar in simpleSelectors){
tokens.push({type: simpleSelectors[firstChar]});
selector = selector.trimLeft();
sawWS = false;
continue;
} else if(firstChar === ","){
if(tokens.length === 0){
throw new SyntaxError("empty sub-selector");
}
subselects.push(tokens);
tokens = [];
selector = selector.trimLeft();
sawWS = false;
continue;
} else if(sawWS){
tokens.push({type: "descendant"});
sawWS = false;
}
if(firstChar === "*"){
tokens.push({type: "universal"});
} else if(firstChar in attribSelectors){
tokens.push({
type: "attribute",
name: attribSelectors[firstChar][0],
action: attribSelectors[firstChar][1],
value: getName(),
ignoreCase: false
});
} else if(firstChar === "["){
data = selector.match(re_attr);
if(!data){
throw new SyntaxError("Malformed attribute selector: " + selector);
}
selector = selector.substr(data[0].length);
name = unescapeCSS(data[1]);
if(
!options || (
"lowerCaseAttributeNames" in options ?
options.lowerCaseAttributeNames :
!options.xmlMode
)
){
name = name.toLowerCase();
}
tokens.push({
type: "attribute",
name: name,
action: actionTypes[data[2]],
value: unescapeCSS(data[4] || data[5] || ""),
ignoreCase: !!data[6]
});
} else if(firstChar === ":"){
//if(selector.charAt(0) === ":"){} //TODO pseudo-element
name = getName().toLowerCase();
data = null;
if(selector.charAt(0) === "("){
var pos = getClosingPos(selector);
data = selector.substr(1, pos - 2);
selector = selector.substr(pos);
}
tokens.push({type: "pseudo", name: name, data: data});
} else {
//otherwise, the parser needs to throw or it would enter an infinite loop
throw new SyntaxError("Unmatched selector: " + firstChar + selector);
}
}
}
if(subselects.length > 0 && tokens.length === 0){
throw new SyntaxError("empty sub-selector");
}
subselects.push(tokens);
return subselects;
}

102
node_modules/CSSwhat/package.json generated vendored Normal file
View File

@@ -0,0 +1,102 @@
{
"_args": [
[
{
"name": "CSSwhat",
"raw": "CSSwhat@0.4",
"rawSpec": "0.4",
"scope": null,
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"F:\\tmp\\gitbook\\node_modules\\CSSselect"
]
],
"_from": "CSSwhat@>=0.4.0 <0.5.0",
"_id": "CSSwhat@0.4.7",
"_inCache": true,
"_installable": true,
"_location": "/CSSwhat",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "1.4.10",
"_phantomChildren": {},
"_requested": {
"name": "CSSwhat",
"raw": "CSSwhat@0.4",
"rawSpec": "0.4",
"scope": null,
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/CSSselect"
],
"_resolved": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz",
"_shasum": "867da0ff39f778613242c44cfea83f0aa4ebdf9b",
"_shrinkwrap": null,
"_spec": "CSSwhat@0.4",
"_where": "F:\\tmp\\gitbook\\node_modules\\CSSselect",
"author": {
"email": "me@feedic.com",
"name": "Felix Böhm",
"url": "http://feedic.com"
},
"bugs": {
"url": "https://github.com/FB55/CSSwhat/issues"
},
"dependencies": {},
"deprecated": "the module is now available as 'css-what'",
"description": "a CSS selector parser",
"devDependencies": {
"jshint": "2"
},
"directories": {},
"dist": {
"shasum": "867da0ff39f778613242c44cfea83f0aa4ebdf9b",
"tarball": "https://registry.npmjs.org/CSSwhat/-/CSSwhat-0.4.7.tgz"
},
"engines": {
"node": "*"
},
"homepage": "https://github.com/FB55/CSSwhat",
"jshintConfig": {
"eqeqeq": true,
"eqnull": true,
"freeze": true,
"globals": {
"describe": true,
"it": true
},
"latedef": "nofunc",
"noarg": true,
"node": true,
"nonbsp": true,
"proto": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true
},
"license": "BSD-like",
"main": "./index.js",
"maintainers": [
{
"email": "me@feedic.com",
"name": "feedic"
}
],
"name": "CSSwhat",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"url": "git+https://github.com/FB55/CSSwhat.git"
},
"scripts": {
"test": "node tests/test.js && jshint *.js"
},
"version": "0.4.7"
}

46
node_modules/CSSwhat/readme.md generated vendored Normal file
View File

@@ -0,0 +1,46 @@
#CSSwhat [![Build Status](https://secure.travis-ci.org/fb55/CSSwhat.png?branch=master)](http://travis-ci.org/fb55/CSSwhat)
a CSS selector parser
##Example
```js
require('CSSwhat')('foo[bar]:baz')
~> [ [ { type: 'tag', name: 'foo' },
{ type: 'attribute',
name: 'bar',
action: 'exists',
value: '',
ignoreCase: false },
{ type: 'pseudo',
name: 'baz',
data: null } ] ]
```
##API
__`CSSwhat(selector, options)` - Parses `str`, with the passed `options`.__
The function returns a two-dimensional array. The first array represents subselects separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
name | attributes | example | output
---- | ---------- | ------- | ------
`tag`| `name` | `div` | `{ type: 'tag', name: 'div' }`
`universal`| - | `*` | `{ type: 'universal' }`
`pseudo`| `name`, `data`|`:name(data)`| `{ type: 'pseudo', name: 'name', data: 'data' }`
`pseudo`| `name`, `data`|`:name`| `{ type: 'pseudo', name: 'name', data: null }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr]`|`{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr=val]`|`{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr^=val]`|`{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr$=val]`|`{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }`
//TODO complete list
__Options:__
- `xmlMode`: When enabled, tagnames will be case-sensitive (ie. the output won't be lowercased).
---
License: BSD-like

14664
node_modules/CSSwhat/tests/out.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

392
node_modules/CSSwhat/tests/test.js generated vendored Normal file
View File

@@ -0,0 +1,392 @@
var assert = require("assert"),
CSSwhat = require("../");
var tests = [
//tag names
[
'div',
[
[
{
'type': 'tag',
'name': 'div'
}
]
],
'simple tag'
],
[
'*',
[
[
{
'type': 'universal'
}
]
],
'universal'
],
//traversal
[
'div div',
[
[
{
'type': 'tag',
'name': 'div'
},
{
'type': 'descendant'
},
{
'type': 'tag',
'name': 'div'
}
]
],
'descendant'
],
[
'div\t \n \tdiv',
[
[
{
'type': 'tag',
'name': 'div'
},
{
'type': 'descendant'
},
{
'type': 'tag',
'name': 'div'
}
]
],
'descendant /w whitespace'
],
[
'div + div',
[
[
{
'type': 'tag',
'name': 'div'
},
{
'type': 'adjacent'
},
{
'type': 'tag',
'name': 'div'
}
]
],
'adjacent'
],
[
'div ~ div',
[
[
{
'type': 'tag',
'name': 'div'
},
{
'type': 'sibling'
},
{
'type': 'tag',
'name': 'div'
}
]
],
'sibling'
],
[
'p < div',
[
[
{
'type': 'tag',
'name': 'p'
},
{
'type': 'parent'
},
{
'type': 'tag',
'name': 'div'
}
]
],
'parent'
],
//Escaped whitespace
[
'#\\ > a ',
[
[
{
'type': 'attribute',
'action': 'equals',
'name': 'id',
'value': ' ',
'ignoreCase': false
},
{
'type': 'child'
},
{
'type': 'tag',
'name': 'a'
}
]
],
'Space between escaped space and combinator'
],
[
'.\\ ',
[
[
{
'type': 'attribute',
'name': 'class',
'action': 'element',
'value': ' ',
'ignoreCase': false
}
]
],
'Space after escaped space'
],
[
'\\61 ',
[
[
{
'type': 'tag',
'name': 'a'
}
]
],
'Numeric escape with space (BMP)'
],
[
'\\1d306\\01d306',
[
[
{
'type': 'tag',
'name': '\uD834\uDF06\uD834\uDF06'
}
]
],
'Numeric escape (outside BMP)'
],
//attributes
[
'[name^=\'foo[\']',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'start',
'value': 'foo[',
'ignoreCase': false
}
]
],
'quoted attribute'
],
[
'[name^=\'foo[bar]\']',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'start',
'value': 'foo[bar]',
'ignoreCase': false
}
]
],
'quoted attribute'
],
[
'[name$=\'[bar]\']',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'end',
'value': '[bar]',
'ignoreCase': false
}
]
],
'quoted attribute'
],
[
'[href *= \'google\']',
[
[
{
'type': 'attribute',
'name': 'href',
'action': 'any',
'value': 'google',
'ignoreCase': false
}
]
],
'quoted attribute with spaces'
],
[
'[name=foo\\.baz]',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'equals',
'value': 'foo.baz',
'ignoreCase': false
}
]
],
'attribute with escaped dot'
],
[
'[name=foo\\[bar\\]]',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'equals',
'value': 'foo[bar]',
'ignoreCase': false
}
]
],
'attribute with escaped square brackets'
],
[
'[xml\\:test]',
[
[
{
'type': 'attribute',
'name': 'xml:test',
'action': 'exists',
'value': '',
'ignoreCase': false
}
]
],
'escaped attribute'
],
[
'[name="foo ~ < > , bar" i]',
[
[
{
'type': 'attribute',
'name': 'name',
'action': 'equals',
'value': 'foo ~ < > , bar',
'ignoreCase': true
}
]
],
'attribute with previously normalized characters'
],
//pseudo selectors
[
':foo',
[
[
{
'type': 'pseudo',
'name': 'foo',
'data': null
}
]
],
'pseudo selector without any data'
],
[
':bar(baz)',
[
[
{
'type': 'pseudo',
'name': 'bar',
'data': 'baz'
}
]
],
'pseudo selector with data'
],
[
':contains(\'(foo)\')',
[
[
{
'type': 'pseudo',
'name': 'contains',
'data': '\'(foo)\''
}
]
],
'pseudo selector with data'
],
//multiple selectors
[
'a , b',
[
[
{
'type': 'tag',
'name': 'a'
}
],
[
{
'type': 'tag',
'name': 'b'
}
]
],
'multiple selectors'
]
];
tests.forEach(function(arr, i){
arr[0] = CSSwhat(arr[0]);
assert.deepEqual.apply(null, arr);
console.log("\t%d: '%s' passed", i + 1, arr[2]);
});
console.log("\nCollected selectors (qwery, sizzle, nwmatcher)...");
var out = require("./out.json");
Object.keys(out).forEach(function(s){
assert.deepEqual(CSSwhat(s), out[s], s);
});
console.log("Passed!");