🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@csstools/css-parser-algorithms

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/css-parser-algorithms - npm Package Compare versions

Comparing version

to
2.0.0

7

CHANGELOG.md

@@ -0,3 +1,10 @@

### 2.0.0 (January 19, 2023)
- Fix: Removes `UnclosedFunctionNode` and `UnclosedSimpleBlockNode`. (breaking)
- Change the `ParseError` interface, this is now a subclass of `Error` (breaking)
- Change `nameTokenValue` in `FunctionNode` to `getName` (breaking)
- Fix: Do not discard empty items in comma separated lists.
### 1.0.0 (November 14, 2022)
- Initial version

50

dist/consume/consume-component-block-function.d.ts
import { CSSToken, TokenFunction } from '@csstools/css-tokenizer';
import { Context } from '../interfaces/context';
import { ComponentValueType } from '../util/component-value-type';
export declare type ContainerNode = FunctionNode | SimpleBlockNode;
export declare type ComponentValue = FunctionNode | SimpleBlockNode | WhitespaceNode | CommentNode | TokenNode | UnclosedSimpleBlockNode | UnclosedFunctionNode;
export type ContainerNode = FunctionNode | SimpleBlockNode;
export type ComponentValue = FunctionNode | SimpleBlockNode | WhitespaceNode | CommentNode | TokenNode;
export declare function consumeComponentValue(ctx: Context, tokens: Array<CSSToken>): {

@@ -16,7 +16,12 @@ advance: number;

constructor(name: TokenFunction, endToken: CSSToken, value: Array<ComponentValue>);
nameTokenValue(): string;
getName(): string;
/**
* Normalize the current Function:
* - if the "endToken" is EOF, replace with a ")-token"
*/
normalize(): void;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: ComponentValue): number | string;
at(index: number | string): ComponentValue;
at(index: number | string): ComponentValue | undefined;
walk(cb: (entry: {

@@ -32,3 +37,3 @@ node: ComponentValue;

advance: number;
node: FunctionNode | UnclosedFunctionNode;
node: FunctionNode;
};

@@ -41,6 +46,11 @@ export declare class SimpleBlockNode {

constructor(startToken: CSSToken, endToken: CSSToken, value: Array<ComponentValue>);
/**
* Normalize the current Simple Block:
* - if the "endToken" is EOF, replace with the mirror token of the "startToken"
*/
normalize(): void;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: ComponentValue): number | string;
at(index: number | string): ComponentValue;
at(index: number | string): ComponentValue | undefined;
walk(cb: (entry: {

@@ -57,3 +67,3 @@ node: ComponentValue;

advance: number;
node: SimpleBlockNode | UnclosedSimpleBlockNode;
node: SimpleBlockNode;
};

@@ -111,27 +121,1 @@ export declare class WhitespaceNode {

}
export declare class UnclosedFunctionNode {
type: ComponentValueType;
value: Array<CSSToken>;
constructor(value: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
toJSON(): {
type: ComponentValueType;
tokens: CSSToken[];
};
isUnclosedFunctionNode(): this is UnclosedFunctionNode;
static isUnclosedFunctionNode(x: unknown): x is UnclosedFunctionNode;
}
export declare class UnclosedSimpleBlockNode {
type: ComponentValueType;
value: Array<CSSToken>;
constructor(value: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
toJSON(): {
type: ComponentValueType;
tokens: CSSToken[];
};
isUnclosedSimpleBlockNode(): this is UnclosedSimpleBlockNode;
static isUnclosedSimpleBlockNode(x: unknown): x is UnclosedSimpleBlockNode;
}

@@ -6,4 +6,3 @@ export * from './consume/consume-component-block-function';

export { gatherNodeAncestry } from './util/node-ancestry';
export { ParserError } from './interfaces/error';
export { ComponentValueType } from './util/component-value-type';
export { isCommentNode, isFunctionNode, isSimpleBlockNode, isTokenNode, isUnclosedFunctionNode, isUnclosedSimpleBlockNode, isWhitespaceNode, } from './util/type-predicates';
export { isCommentNode, isFunctionNode, isSimpleBlockNode, isTokenNode, isWhitespaceNode, } from './util/type-predicates';

@@ -1,4 +0,4 @@

import { ParserError } from './error';
export declare type Context = {
onParseError: (error: ParserError) => void;
import { ParseError } from '@csstools/css-tokenizer';
export type Context = {
onParseError: (error: ParseError) => void;
};

@@ -1,6 +0,5 @@

import { ParserError } from '../interfaces/error';
import { CSSToken } from '@csstools/css-tokenizer';
import { CSSToken, ParseError } from '@csstools/css-tokenizer';
import { ComponentValue } from '../consume/consume-component-block-function';
export declare function parseCommaSeparatedListOfComponentValues(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParserError) => void;
onParseError?: (error: ParseError) => void;
}): ComponentValue[][];

@@ -1,5 +0,4 @@

import { ParserError } from '../interfaces/error';
import { CSSToken } from '@csstools/css-tokenizer';
import { CSSToken, ParseError } from '@csstools/css-tokenizer';
export declare function parseComponentValue(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParserError) => void;
onParseError?: (error: ParseError) => void;
}): import("../consume/consume-component-block-function").ComponentValue;

@@ -1,6 +0,5 @@

import { ParserError } from '../interfaces/error';
import { CSSToken } from '@csstools/css-tokenizer';
import { CSSToken, ParseError } from '@csstools/css-tokenizer';
import { ComponentValue } from '../consume/consume-component-block-function';
export declare function parseListOfComponentValues(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParserError) => void;
onParseError?: (error: ParseError) => void;
}): ComponentValue[];

@@ -6,5 +6,3 @@ export declare enum ComponentValueType {

Comment = "comment",
Token = "token",
UnclosedFunction = "unclosed-function",
UnclosedSimpleBlock = "unclosed-simple-block"
Token = "token"
}

@@ -1,8 +0,6 @@

import { CommentNode, FunctionNode, SimpleBlockNode, TokenNode, UnclosedFunctionNode, UnclosedSimpleBlockNode, WhitespaceNode } from '../consume/consume-component-block-function';
import { CommentNode, FunctionNode, SimpleBlockNode, TokenNode, WhitespaceNode } from '../consume/consume-component-block-function';
export declare function isSimpleBlockNode(x: unknown): x is SimpleBlockNode;
export declare function isFunctionNode(x: unknown): x is FunctionNode;
export declare function isUnclosedSimpleBlockNode(x: unknown): x is UnclosedSimpleBlockNode;
export declare function isUnclosedFunctionNode(x: unknown): x is UnclosedFunctionNode;
export declare function isWhitespaceNode(x: unknown): x is WhitespaceNode;
export declare function isCommentNode(x: unknown): x is CommentNode;
export declare function isTokenNode(x: unknown): x is TokenNode;
{
"name": "@csstools/css-parser-algorithms",
"description": "Algorithms to help you parse CSS from an array of tokens.",
"version": "1.0.0",
"version": "2.0.0",
"contributors": [

@@ -41,7 +41,8 @@ {

"peerDependencies": {
"@csstools/css-tokenizer": "^1.0.0"
"@csstools/css-tokenizer": "^2.0.0"
},
"scripts": {
"prebuild": "npm run clean",
"build": "rollup -c ../../rollup/default.mjs",
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"",
"lint": "npm run lint:eslint && npm run lint:package-json",

@@ -48,0 +49,0 @@ "lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",

@@ -48,3 +48,3 @@ # CSS Parser Algorithms

onParseError: ((err) => {
throw new Error(JSON.stringify(err));
throw err;
}),

@@ -86,3 +86,3 @@ };

{
onParseError?: (error: ParserError) => void
onParseError?: (error: ParseError) => void
}

@@ -101,7 +101,2 @@ ```

`start` and `end` are the location in your CSS source code.
`UnclosedSimpleBlockNode` and `UnclosedFunctionNode` entries will be added to the output.
This allows you to recover from errors and/or show warnings.
## Goals and non-goals

@@ -108,0 +103,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet