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

@emmetio/css-abbreviation

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emmetio/css-abbreviation - npm Package Compare versions

Comparing version 2.0.0-rc.4 to 2.0.0-rc.5

52

dist/css-abbreviation.cjs.js

@@ -17,3 +17,2 @@ 'use strict';

token = field(scanner)
|| literal(scanner, brackets === 0 && !isValue)
|| numberValue(scanner)

@@ -25,2 +24,3 @@ || colorValue(scanner)

|| whiteSpace(scanner)
|| literal(scanner, brackets === 0 && !isValue)
|| void 0;

@@ -117,9 +117,11 @@ if (!token) {

// consume alpha characters only to allow embedded variables
scanner.eatWhile(start ? isKeyword : Scanner.isAlphaWord);
scanner.eatWhile(start ? isKeyword : isLiteral);
}
else if (scanner.eat(Scanner.isAlphaWord)) {
scanner.eatWhile(short ? Scanner.isAlphaWord : isKeyword);
scanner.eatWhile(short ? isLiteral : isKeyword);
}
else if (scanner.eat(37 /* Percent */)) {
scanner.eatWhile(37 /* Percent */);
else {
// Allow dots only at the beginning of literal
scanner.eat(46 /* Dot */);
scanner.eatWhile(isLiteral);
}

@@ -147,3 +149,3 @@ if (start !== scanner.pos) {

scanner.start = start;
const value = Number(scanner.current());
const rawValue = scanner.current();
// eat unit, which can be a % or alpha word

@@ -154,3 +156,4 @@ scanner.start = scanner.pos;

type: 'NumberValue',
value,
value: Number(rawValue),
rawValue,
unit: scanner.current(),

@@ -239,3 +242,3 @@ start,

const ch = scanner.peek();
if (ch === 40 /* RoundBracketOpen */ || ch === 41 /* RoundBracketClose */) {
if (isBracket(ch)) {
return {

@@ -271,7 +274,12 @@ type: 'Bracket',

const afterNegative = stream.pos;
stream.eatWhile(Scanner.isNumber);
const hasDecimal = stream.eatWhile(Scanner.isNumber);
const prevPos = stream.pos;
if (stream.eat(46 /* Dot */) && !stream.eatWhile(Scanner.isNumber)) {
// Number followed by a dot, but then no number
stream.pos = prevPos;
if (stream.eat(46 /* Dot */)) {
// It’s perfectly valid to have numbers like `1.`, which enforces
// value to float unit type
const hasFloat = stream.eatWhile(Scanner.isNumber);
if (!hasDecimal && !hasFloat) {
// Lone dot
stream.pos = prevPos;
}
}

@@ -307,2 +315,8 @@ // Edge case: consumed dash only: not a number, bail-out

}
function isBracket(code) {
return code === 40 /* RoundBracketOpen */ || code === 41 /* RoundBracketClose */;
}
function isLiteral(code) {
return Scanner.isAlphaWord(code) || code === 37 /* Percent */;
}
/**

@@ -440,3 +454,3 @@ * Parses given color value from abbreviation into RGBA format

const token = peek(scanner);
if (!options.value && isLiteral(token) && !isFunctionStart(scanner)) {
if (!options.value && isLiteral$1(token) && !isFunctionStart(scanner)) {
scanner.pos++;

@@ -475,3 +489,3 @@ name = token.value;

scanner.pos++;
if (isLiteral(token) && (args = consumeArguments(scanner))) {
if (isLiteral$1(token) && (args = consumeArguments(scanner))) {
result.push({

@@ -515,13 +529,13 @@ type: 'FunctionCall',

}
function isLiteral(token) {
function isLiteral$1(token) {
return token && token.type === 'Literal';
}
function isBracket(token, open) {
function isBracket$1(token, open) {
return token && token.type === 'Bracket' && (open == null || token.open === open);
}
function isOpenBracket(token) {
return isBracket(token, true);
return isBracket$1(token, true);
}
function isCloseBracket(token) {
return isBracket(token, false);
return isBracket$1(token, false);
}

@@ -561,3 +575,3 @@ function isWhiteSpace(token) {

const t2 = scanner.tokens[scanner.pos + 1];
return t1 && t2 && isLiteral(t1) && t2.type === 'Bracket';
return t1 && t2 && isLiteral$1(t1) && t2.type === 'Bracket';
}

@@ -564,0 +578,0 @@

@@ -10,3 +10,2 @@ import Scanner, { isNumber, isAlpha, isAlphaWord, isQuote, isSpace, isAlphaNumericWord, ScannerError } from '@emmetio/scanner';

token = field(scanner)
|| literal(scanner, brackets === 0 && !isValue)
|| numberValue(scanner)

@@ -18,2 +17,3 @@ || colorValue(scanner)

|| whiteSpace(scanner)
|| literal(scanner, brackets === 0 && !isValue)
|| void 0;

@@ -110,9 +110,11 @@ if (!token) {

// consume alpha characters only to allow embedded variables
scanner.eatWhile(start ? isKeyword : isAlphaWord);
scanner.eatWhile(start ? isKeyword : isLiteral);
}
else if (scanner.eat(isAlphaWord)) {
scanner.eatWhile(short ? isAlphaWord : isKeyword);
scanner.eatWhile(short ? isLiteral : isKeyword);
}
else if (scanner.eat(37 /* Percent */)) {
scanner.eatWhile(37 /* Percent */);
else {
// Allow dots only at the beginning of literal
scanner.eat(46 /* Dot */);
scanner.eatWhile(isLiteral);
}

@@ -140,3 +142,3 @@ if (start !== scanner.pos) {

scanner.start = start;
const value = Number(scanner.current());
const rawValue = scanner.current();
// eat unit, which can be a % or alpha word

@@ -147,3 +149,4 @@ scanner.start = scanner.pos;

type: 'NumberValue',
value,
value: Number(rawValue),
rawValue,
unit: scanner.current(),

@@ -232,3 +235,3 @@ start,

const ch = scanner.peek();
if (ch === 40 /* RoundBracketOpen */ || ch === 41 /* RoundBracketClose */) {
if (isBracket(ch)) {
return {

@@ -264,7 +267,12 @@ type: 'Bracket',

const afterNegative = stream.pos;
stream.eatWhile(isNumber);
const hasDecimal = stream.eatWhile(isNumber);
const prevPos = stream.pos;
if (stream.eat(46 /* Dot */) && !stream.eatWhile(isNumber)) {
// Number followed by a dot, but then no number
stream.pos = prevPos;
if (stream.eat(46 /* Dot */)) {
// It’s perfectly valid to have numbers like `1.`, which enforces
// value to float unit type
const hasFloat = stream.eatWhile(isNumber);
if (!hasDecimal && !hasFloat) {
// Lone dot
stream.pos = prevPos;
}
}

@@ -300,2 +308,8 @@ // Edge case: consumed dash only: not a number, bail-out

}
function isBracket(code) {
return code === 40 /* RoundBracketOpen */ || code === 41 /* RoundBracketClose */;
}
function isLiteral(code) {
return isAlphaWord(code) || code === 37 /* Percent */;
}
/**

@@ -433,3 +447,3 @@ * Parses given color value from abbreviation into RGBA format

const token = peek(scanner);
if (!options.value && isLiteral(token) && !isFunctionStart(scanner)) {
if (!options.value && isLiteral$1(token) && !isFunctionStart(scanner)) {
scanner.pos++;

@@ -468,3 +482,3 @@ name = token.value;

scanner.pos++;
if (isLiteral(token) && (args = consumeArguments(scanner))) {
if (isLiteral$1(token) && (args = consumeArguments(scanner))) {
result.push({

@@ -508,13 +522,13 @@ type: 'FunctionCall',

}
function isLiteral(token) {
function isLiteral$1(token) {
return token && token.type === 'Literal';
}
function isBracket(token, open) {
function isBracket$1(token, open) {
return token && token.type === 'Bracket' && (open == null || token.open === open);
}
function isOpenBracket(token) {
return isBracket(token, true);
return isBracket$1(token, true);
}
function isCloseBracket(token) {
return isBracket(token, false);
return isBracket$1(token, false);
}

@@ -554,3 +568,3 @@ function isWhiteSpace(token) {

const t2 = scanner.tokens[scanner.pos + 1];
return t1 && t2 && isLiteral(t1) && t2.type === 'Bracket';
return t1 && t2 && isLiteral$1(t1) && t2.type === 'Bracket';
}

@@ -557,0 +571,0 @@

@@ -32,2 +32,3 @@ export declare type AllTokens = Bracket | Literal | Operator | WhiteSpace | ColorValue | NumberValue | StringValue | Field;

unit: string;
rawValue: string;
}

@@ -34,0 +35,0 @@ export interface ColorValue extends Token {

{
"name": "@emmetio/css-abbreviation",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"description": "Parses Emmet CSS abbreviation into AST tree",

@@ -46,3 +46,3 @@ "main": "./dist/css-abbreviation.cjs.js",

},
"gitHead": "ed867e19b761c8283a4aae584478c7df9510a170"
"gitHead": "9c4c482aef8602da94dc86fa69f36c9ff8807b6a"
}
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