Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asamuzakjp/nwsapi

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asamuzakjp/nwsapi - npm Package Compare versions

Comparing version 2.2.10 to 2.2.11

2

package.json
{
"name": "@asamuzakjp/nwsapi",
"version": "2.2.10",
"version": "2.2.11",
"description": "Fast CSS Selectors API Engine",

@@ -5,0 +5,0 @@ "homepage": "http://javascript.nwbox.com/nwsapi/",

@@ -50,6 +50,6 @@ /**

// not enclosed in double/single/parens/square
double_enc: '(?=(?:[^"]*["][^"]*["])*[^"]*$)',
single_enc: "(?=(?:[^']*['][^']*['])*[^']*$)",
parens_enc: '(?![^\\x28]*\\x29)',
square_enc: '(?![^\\x5b]*\\x5d)'
doubleEnc: '(?=(?:[^"]*["][^"]*["])*[^"]*$)',
singleEnc: "(?=(?:[^']*['][^']*['])*[^']*$)",
parensEnc: '(?![^\\x28]*\\x29)',
squareEnc: '(?![^\\x5b]*\\x5d)'
};

@@ -59,19 +59,19 @@

// regular expressions
HasEscapes: RegExp('\\\\'),
HexNumbers: RegExp('^[0-9a-f]', 'i'),
EscOrQuote: RegExp('^\\\\|[\\x22\\x27]'),
RegExpChar: RegExp('(?:(?!\\\\)[\\\\^$.*+?()[\\]{}|/])', 'g'),
TrimSpaces: RegExp('[\\r\\n\\f]|^' + WSP + '+|' + WSP + '+$', 'g'),
CommaGroup: RegExp('(\\s*,\\s*)' + NOT.square_enc + NOT.parens_enc, 'g'),
SplitGroup: RegExp('((?:\\x28[^\\x29]*\\x29|\\[[^\\]]*\\]|\\\\.|[^,])+)', 'g'),
FixEscapes: RegExp('\\\\([0-9a-fA-F]{1,6}' + WSP + '?|.)|([\\x22\\x27])', 'g'),
CombineWSP: RegExp('[\\n\\r\\f\\x20]+' + NOT.single_enc + NOT.double_enc, 'g'),
TabCharWSP: RegExp('(\\x20?\\t+\\x20?)' + NOT.single_enc + NOT.double_enc, 'g'),
PseudosWSP: RegExp('\\s+([-+])\\s+' + NOT.square_enc, 'g')
hasEscapes: /\\/,
hexNumbers: /^[0-9a-f]/i,
escOrQuote: /^\\|[\x22\x27]/,
regExpChar: /(?:(?!\\)[\\^$.*+?()[\]{}|/])/g,
trimSpaces: RegExp('[\\r\\n\\f]|^' + WSP + '+|' + WSP + '+$', 'g'),
commaGroup: RegExp('(\\s*,\\s*)' + NOT.squareEnc + NOT.parensEnc, 'g'),
splitGroup: /((?:\x28[^\x29]*\x29|\[[^\]]*\]|\\.|[^,])+)/g,
fixEscapes: RegExp('\\\\([0-9a-fA-F]{1,6}' + WSP + '?|.)|([\\x22\\x27])', 'g'),
combineWSP: RegExp('[\\n\\r\\f\\x20]+' + NOT.singleEnc + NOT.doubleEnc, 'g'),
tabCharWSP: RegExp('(\\x20?\\t+\\x20?)' + NOT.singleEnc + NOT.doubleEnc, 'g'),
pseudosWSP: RegExp('\\s+([-+])\\s+' + NOT.squareEnc, 'g')
};
const STD = {
combinator: RegExp('\\s?([>+~])\\s?', 'g'),
apimethods: RegExp('^(?:[a-z]+|\\*)\\|', 'i'),
namespaces: RegExp('(\\*|[a-z]+)\\|[-a-z]+', 'i')
combinator: /\s?([>+~])\s?/g,
apimethods: /^(?:[a-z]+|\*)\|/i,
namespaces: /(\*|[a-z]+)\|[-a-z]+/i
};

@@ -88,7 +88,7 @@

// pseudo-classes for parsing only selectors
pseudo_nop: '(autofill|-webkit-autofill)\\b',
pseudoNop: '(autofill|-webkit-autofill)\\b',
// pseudo-elements starting with single colon (:)
pseudo_sng: '(after|before|first-letter|first-line)\\b',
pseudoSng: '(after|before|first-letter|first-line)\\b',
// pseudo-elements starting with double colon (::)
pseudo_dbl: ':(after|before|first-letter|first-line|selection|placeholder|slotted|-webkit-[-A-Za-z0-9]{2,})\\b'
pseudoDbl: ':(after|before|first-letter|first-line|selection|placeholder|slotted|-webkit-[-A-Za-z0-9]{2,})\\b'
};

@@ -103,5 +103,5 @@

logicalsel: RegExp('^:(?:' + GROUPS.logicalsel + ')(.*)', 'i'),
pseudo_nop: RegExp('^:(?:' + GROUPS.pseudo_nop + ')(.*)', 'i'),
pseudo_sng: RegExp('^:(?:' + GROUPS.pseudo_sng + ')(.*)', 'i'),
pseudo_dbl: RegExp('^:(?:' + GROUPS.pseudo_dbl + ')(.*)', 'i'),
pseudoNop: RegExp('^:(?:' + GROUPS.pseudoNop + ')(.*)', 'i'),
pseudoSng: RegExp('^:(?:' + GROUPS.pseudoSng + ')(.*)', 'i'),
pseudoDbl: RegExp('^:(?:' + GROUPS.pseudoDbl + ')(.*)', 'i'),
// combinator symbols

@@ -113,4 +113,4 @@ children: RegExp('^' + WSP + '?>' + WSP + '?(.*)'),

// universal & namespace
universal: RegExp('^\\*(.*)'),
namespace: RegExp('^(\\w+|\\*)?\\|(.*)')
universal: /^\*(.*)/,
namespace: /^(\w+|\*)?\|(.*)/
};

@@ -123,4 +123,4 @@

// detect structural pseudo-classes in selectors
const reNthElem = RegExp('(:nth(?:-last)?-child)', 'i');
const reNthType = RegExp('(:nth(?:-last)?-of-type)', 'i');
const reNthElem = /(:nth(?:-last)?-child)/i;
const reNthType = /(:nth(?:-last)?-of-type)/i;

@@ -328,4 +328,4 @@ // placeholder for global regexp

const convertEscapes = function (str) {
return REX.HasEscapes.test(str)
? str.replace(REX.FixEscapes, function (substring, p1, p2) {
return REX.hasEscapes.test(str)
? str.replace(REX.fixEscapes, function (substring, p1, p2) {
// unescaped " or '

@@ -335,6 +335,6 @@ return p2

// javascript strings are UTF-16 encoded
: REX.HexNumbers.test(p1)
: REX.hexNumbers.test(p1)
? codePointToUTF16(parseInt(p1, 16))
// \' \"
: REX.EscOrQuote.test(p1)
: REX.escOrQuote.test(p1)
? substring

@@ -350,9 +350,9 @@ // \g \h \. \# etc

const unescapeIdentifier = function (str) {
return REX.HasEscapes.test(str)
? str.replace(REX.FixEscapes, function (substring, p1, p2) {
return REX.hasEscapes.test(str)
? str.replace(REX.fixEscapes, function (substring, p1, p2) {
// unescaped " or '
return p2 || (REX.HexNumbers.test(p1)
return p2 || (REX.hexNumbers.test(p1)
? stringFromCodePoint(parseInt(p1, 16))
// \' \"
: REX.EscOrQuote.test(p1)
: REX.escOrQuote.test(p1)
? substring

@@ -405,3 +405,4 @@ // \g \h \. \# etc

if (api in context) {
return (e = context[api](id)) ? [e] : none;
e = context[api](id);
return e ? [e] : none;
}

@@ -487,3 +488,3 @@ } else if ('all' in context) {

'#': function (c, n) {
REX.HasEscapes.test(n) && (n = unescapeIdentifier(n));
REX.hasEscapes.test(n) && (n = unescapeIdentifier(n));
return function (e, f) {

@@ -494,3 +495,3 @@ return byId(n, c);

'*': function (c, n) {
REX.HasEscapes.test(n) && (n = unescapeIdentifier(n));
REX.hasEscapes.test(n) && (n = unescapeIdentifier(n));
return function (e, f) {

@@ -501,3 +502,3 @@ return byTag(n, c);

'|': function (c, n) {
REX.HasEscapes.test(n) && (n = unescapeIdentifier(n));
REX.hasEscapes.test(n) && (n = unescapeIdentifier(n));
return function (e, f) {

@@ -508,3 +509,3 @@ return byTag(n, c);

'.': function (c, n) {
REX.HasEscapes.test(n) && (n = unescapeIdentifier(n));
REX.hasEscapes.test(n) && (n = unescapeIdentifier(n));
return function (e, f) {

@@ -880,3 +881,3 @@ return byClass(n, c);

// original 'select' or 'match' selector string before normalization
const selector_string = mode ? lastSelected : lastMatched;
const selectorString = mode ? lastSelected : lastMatched;

@@ -888,3 +889,3 @@ // isolate selector combinators/components and normalize whitespace

// out of the while loops processing
selector_recursion_label:
selectorRecursionLabel:
while (selector) {

@@ -939,3 +940,3 @@ // get namespace prefix if present or get first char of selector

} else {
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}

@@ -952,3 +953,3 @@ break;

if (match[2] && !(test = Operators[match[2]])) {
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
return '';

@@ -967,3 +968,3 @@ }

} else if (match[4]) {
match[4] = convertEscapes(match[4]).replace(REX.RegExpChar, '\\$&');
match[4] = convertEscapes(match[4]).replace(REX.regExpChar, '\\$&');
}

@@ -1055,9 +1056,7 @@ type = match[5] === 'i' || (HTML_DOCUMENT && HTML_TABLE[expr.toLowerCase()]) ? 'i' : '';

default:
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
}
// *** child-indexed & typed child-indexed pseudo-classes
// :nth-child, :nth-of-type, :nth-last-child, :nth-last-of-type
else if ((match = selector.match(Patterns.treestruct))) {
} else if ((match = selector.match(Patterns.treestruct))) {
match[1] = match[1].toLowerCase();

@@ -1116,13 +1115,12 @@ switch (match[1]) {

} else {
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
break;
default:
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
}
// *** logical combination pseudo-classes
// :is( s1, [ s2, ... ]), :not( s1, [ s2, ... ])
else if ((match = selector.match(Patterns.logicalsel))) {
} else if ((match = selector.match(Patterns.logicalsel))) {
match[1] = match[1].toLowerCase();

@@ -1133,17 +1131,16 @@ switch (match[1]) {

case 'matches':
expr = match[2].replace(REX.CommaGroup, ',').replace(REX.TrimSpaces, '');
expr = match[2].replace(REX.commaGroup, ',').replace(REX.trimSpaces, '');
source = 'if(s.match("' + expr.replace(/\x22/g, '\\"') + '",e)){' + source + '}';
break;
case 'not':
expr = match[2].replace(REX.CommaGroup, ',').replace(REX.TrimSpaces, '');
expr = match[2].replace(REX.commaGroup, ',').replace(REX.trimSpaces, '');
source = 'if(!s.match("' + expr.replace(/\x22/g, '\\"') + '",e)){' + source + '}';
break;
default:
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
}
// *** location pseudo-classes
// :any-link, :link, :visited, :target
else if ((match = selector.match(Patterns.locationpc))) {
} else if ((match = selector.match(Patterns.locationpc))) {
match[1] = match[1].toLowerCase();

@@ -1164,9 +1161,8 @@ switch (match[1]) {

default:
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
}
// *** input pseudo-classes (for form validation)
// :checked, :indeterminate, :valid, :invalid, :in-range, :out-of-range, :required, :optional
else if ((match = selector.match(Patterns.inputvalue))) {
} else if ((match = selector.match(Patterns.inputvalue))) {
match[1] = match[1].toLowerCase();

@@ -1232,5 +1228,4 @@ switch (match[1]) {

default:
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
}
}

@@ -1240,6 +1235,5 @@ // allow pseudo-elements starting with single colon (:)

// assert: e.type is in double-colon format, like ::after
else if ((match = selector.match(Patterns.pseudo_sng))) {
} else if ((match = selector.match(Patterns.pseudoSng))) {
source = 'if(e.element&&e.type.toLowerCase()=="' +
':' + match[0].toLowerCase() + '"){e=e.element;' + source + '}';
}

@@ -1249,9 +1243,8 @@ // allow pseudo-elements starting with double colon (::)

// assert: e.type is in double-colon format, like ::after
else if ((match = selector.match(Patterns.pseudo_dbl))) {
} else if ((match = selector.match(Patterns.pseudoDbl))) {
source = 'if(e.element&&e.type.toLowerCase()=="' +
match[0].toLowerCase() + '"){e=e.element;' + source + '}';
}
// placeholder for parsed only no-op selectors
else if ((match = selector.match(Patterns.pseudo_nop))) {
} else if ((match = selector.match(Patterns.pseudoNop))) {
source = 'if(' + N + 'false' + '){' + source + '}';

@@ -1300,4 +1293,4 @@ } else {

default:
emit('\'' + selector_string + '\'' + qsInvalid);
break selector_recursion_label;
emit('\'' + selectorString + '\'' + qsInvalid);
break selectorRecursionLabel;
}

@@ -1307,3 +1300,3 @@ // end of switch symbol

if (!match) {
emit('\'' + selector_string + '\'' + qsInvalid);
emit('\'' + selectorString + '\'' + qsInvalid);
return '';

@@ -1441,3 +1434,3 @@ }

const match_assert = function (f, element, callback) {
const matchAssert = function (f, element, callback) {
let r = false;

@@ -1450,3 +1443,3 @@ for (let i = 0, l = f.length; l > i; ++i) {

const match_collect = function (selectors, callback) {
const matchCollect = function (selectors, callback) {
const f = [];

@@ -1464,3 +1457,3 @@ for (let i = 0, l = selectors.length; l > i; ++i) {

if (element && matchResolvers[selectors]) {
return match_assert(matchResolvers[selectors].factory, element, callback);
return matchAssert(matchResolvers[selectors].factory, element, callback);
}

@@ -1491,11 +1484,11 @@

.replace(/\0|\\$/g, '\ufffd')
.replace(REX.CombineWSP, '\x20')
.replace(REX.PseudosWSP, '$1')
.replace(REX.TabCharWSP, '\t')
.replace(REX.CommaGroup, ',')
.replace(REX.TrimSpaces, '');
.replace(REX.combineWSP, '\x20')
.replace(REX.pseudosWSP, '$1')
.replace(REX.tabCharWSP, '\t')
.replace(REX.commaGroup, ',')
.replace(REX.trimSpaces, '');
// parse, validate and split possible compound selectors
if ((expressions = parsed.match(reValidator)) && expressions.join('') === parsed) {
expressions = parsed.match(REX.SplitGroup);
expressions = parsed.match(REX.splitGroup);
if (parsed[parsed.length - 1] === ',') {

@@ -1510,5 +1503,5 @@ emit(qsInvalid);

matchResolvers[selectors] = match_collect(expressions, callback);
matchResolvers[selectors] = matchCollect(expressions, callback);
return match_assert(matchResolvers[selectors].factory, element, callback);
return matchAssert(matchResolvers[selectors].factory, element, callback);
};

@@ -1592,11 +1585,11 @@

.replace(/\0|\\$/g, '\ufffd')
.replace(REX.CombineWSP, '\x20')
.replace(REX.PseudosWSP, '$1')
.replace(REX.TabCharWSP, '\t')
.replace(REX.CommaGroup, ',')
.replace(REX.TrimSpaces, '');
.replace(REX.combineWSP, '\x20')
.replace(REX.pseudosWSP, '$1')
.replace(REX.tabCharWSP, '\t')
.replace(REX.commaGroup, ',')
.replace(REX.trimSpaces, '');
// parse, validate and split possible compound selectors
if ((expressions = parsed.match(reValidator)) && expressions.join('') === parsed) {
expressions = parsed.match(REX.SplitGroup);
expressions = parsed.match(REX.splitGroup);
if (parsed[parsed.length - 1] === ',') {

@@ -1603,0 +1596,0 @@ emit(qsInvalid);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc