Socket
Socket
Sign inDemoInstall

@csstools/media-query-list-parser

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/media-query-list-parser - npm Package Compare versions

Comparing version 2.1.5 to 2.1.6

80

CHANGELOG.md
# Changes to Media Query List Parser
### 2.1.6
_December 15, 2023_
- Fix type definitions
- Only `walk` child nodes if they are still part of the current AST tree [#1202](https://github.com/csstools/postcss-plugins/issues/1202)
- Make `walk` methods safe for mutations [#1204](https://github.com/csstools/postcss-plugins/issues/1204)
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#222) (patch)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#240) (minor)
### 2.1.5

@@ -16,70 +26,2 @@

### 2.1.3
_July 24, 2023_
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor)
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#231) (patch)
### 2.1.2
_July 3, 2023_
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#230) (minor)
### 2.1.1
_June 21, 2023_
- Fix parsing of `(width == 100px)`. This was erroneously parsed as a range query and will now instead be a general enclosed node.
### 2.1.0
_June 1, 2023_
- Fix `walk` for `MediaFeatureValue` with complex component values.
- Add `state` to `walk` methods.
This makes it possible pass down information from a parent structure to children.
e.g. you can set `entry.state.inInPrintQuery = true` for `print and (min-width: 30cm)`.
### 2.0.4
_April 10, 2023_
- Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
- Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
### 2.0.3
_April 10, 2023_
- Add support for `env()` functions as values in media queries.
- Improve the detection of math function as values in media queries.
### 2.0.2
_March 25, 2023_
- Improve case insensitive string matching.
### 2.0.1
_January 28, 2023_
- Improve `types` declaration in `package.json`
### 2.0.0
_January 19, 2023_
- Refactor `MediaFeatureBoolean` so that it follows the same structure as `MediaFeaturePlain` (breaking)
- Change the `ParseError` interface, this is now a subclass of `Error` (breaking)
- Add `getName` and `getNameToken` to all nodes that have a feature name.
- Add `@custom-media` parsing.
### 1.0.0
_November 14, 2022_
- Initial version
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser/CHANGELOG.md)

803

dist/index.d.ts

@@ -1,23 +0,780 @@

export { parse, parseFromTokens } from './parser/parse';
export { parseCustomMedia, parseCustomMediaFromTokens } from './parser/parse-custom-media';
export { NodeType } from './util/node-type';
export { isCustomMedia, isGeneralEnclosed, isMediaAnd, isMediaCondition, isMediaConditionList, isMediaConditionListWithAnd, isMediaConditionListWithOr, isMediaFeature, isMediaFeatureBoolean, isMediaFeatureName, isMediaFeaturePlain, isMediaFeatureRange, isMediaFeatureRangeNameValue, isMediaFeatureRangeValueName, isMediaFeatureRangeValueNameValue, isMediaFeatureValue, isMediaInParens, isMediaNot, isMediaOr, isMediaQuery, isMediaQueryInvalid, isMediaQueryWithType, isMediaQueryWithoutType, } from './util/type-predicates';
export { CustomMedia } from './nodes/custom-media';
export { GeneralEnclosed } from './nodes/general-enclosed';
export { MediaAnd } from './nodes/media-and';
export { MediaCondition } from './nodes/media-condition';
export { MediaConditionList, MediaConditionListWithAnd, MediaConditionListWithOr } from './nodes/media-condition-list';
export { MediaFeature, newMediaFeatureBoolean, newMediaFeaturePlain } from './nodes/media-feature';
export { MediaFeatureBoolean } from './nodes/media-feature-boolean';
export { MediaFeatureName } from './nodes/media-feature-name';
export { MediaFeaturePlain } from './nodes/media-feature-plain';
export { MediaFeatureRange, MediaFeatureRangeNameValue, MediaFeatureRangeValueName, MediaFeatureRangeValueNameValue } from './nodes/media-feature-range';
export { MediaFeatureValue, matchesRatio, matchesRatioExactly } from './nodes/media-feature-value';
export { MediaInParens } from './nodes/media-in-parens';
export { MediaNot } from './nodes/media-not';
export { MediaOr } from './nodes/media-or';
export { MediaQuery, MediaQueryWithType, MediaQueryWithoutType, MediaQueryInvalid } from './nodes/media-query';
export { MediaFeatureComparison, MediaFeatureEQ, MediaFeatureGT, MediaFeatureLT, invertComparison, matchesComparison, comparisonFromTokens } from './nodes/media-feature-comparison';
export { MediaType, typeFromToken } from './nodes/media-type';
export { MediaQueryModifier, modifierFromToken } from './nodes/media-query-modifier';
export { cloneMediaQuery } from './util/clone-media-query';
import { ComponentValue } from '@csstools/css-parser-algorithms';
import { ContainerNode } from '@csstools/css-parser-algorithms';
import { CSSToken } from '@csstools/css-tokenizer';
import { ParseError } from '@csstools/css-tokenizer';
import { TokenColon } from '@csstools/css-tokenizer';
import { TokenDelim } from '@csstools/css-tokenizer';
import { TokenIdent } from '@csstools/css-tokenizer';
export declare function cloneMediaQuery<T extends MediaQueryWithType | MediaQueryWithoutType | MediaQueryInvalid>(x: T): T;
export declare function comparisonFromTokens(tokens: [TokenDelim, TokenDelim] | [TokenDelim]): MediaFeatureComparison | false;
export declare class CustomMedia {
type: NodeType;
name: Array<CSSToken>;
mediaQueryList: Array<MediaQuery> | null;
trueOrFalseKeyword: Array<CSSToken> | null;
constructor(name: Array<CSSToken>, mediaQueryList: Array<MediaQuery> | null, trueOrFalseKeyword?: Array<CSSToken>);
getName(): string;
getNameToken(): CSSToken | null;
hasMediaQueryList(): boolean;
hasTrueKeyword(): boolean;
hasFalseKeyword(): boolean;
tokens(): Array<CSSToken>;
toString(): string;
toJSON(): {
type: NodeType;
string: string;
nameValue: string;
name: CSSToken[];
hasFalseKeyword: boolean;
hasTrueKeyword: boolean;
trueOrFalseKeyword: CSSToken[] | null;
mediaQueryList: ({
type: NodeType;
string: string;
modifier: CSSToken[];
mediaType: CSSToken[];
and: CSSToken[] | undefined;
media: MediaCondition | undefined;
} | {
type: NodeType;
string: string;
media: MediaCondition;
} | {
type: NodeType;
string: string;
media: ComponentValue[];
})[] | undefined;
};
isCustomMedia(): this is CustomMedia;
static isCustomMedia(x: unknown): x is CustomMedia;
}
export declare class GeneralEnclosed {
type: NodeType;
value: ComponentValue;
constructor(value: ComponentValue);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: ComponentValue): number | string;
at(index: number | string): ComponentValue | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: GeneralEnclosedWalkerEntry;
parent: GeneralEnclosedWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
tokens: CSSToken[];
};
isGeneralEnclosed(): this is GeneralEnclosed;
static isGeneralEnclosed(x: unknown): x is GeneralEnclosed;
}
export declare type GeneralEnclosedWalkerEntry = ComponentValue;
export declare type GeneralEnclosedWalkerParent = ContainerNode | GeneralEnclosed;
export declare function invertComparison(operator: MediaFeatureComparison): MediaFeatureComparison | false;
export declare function isCustomMedia(x: unknown): x is GeneralEnclosed;
export declare function isGeneralEnclosed(x: unknown): x is GeneralEnclosed;
export declare function isMediaAnd(x: unknown): x is MediaAnd;
export declare function isMediaCondition(x: unknown): x is MediaCondition;
export declare function isMediaConditionList(x: unknown): x is MediaConditionList;
export declare function isMediaConditionListWithAnd(x: unknown): x is MediaConditionListWithAnd;
export declare function isMediaConditionListWithOr(x: unknown): x is MediaConditionListWithOr;
export declare function isMediaFeature(x: unknown): x is MediaFeature;
export declare function isMediaFeatureBoolean(x: unknown): x is MediaFeatureBoolean;
export declare function isMediaFeatureName(x: unknown): x is MediaFeatureName;
export declare function isMediaFeaturePlain(x: unknown): x is MediaFeaturePlain;
export declare function isMediaFeatureRange(x: unknown): x is MediaFeatureRange;
export declare function isMediaFeatureRangeNameValue(x: unknown): x is MediaFeatureRangeNameValue;
export declare function isMediaFeatureRangeValueName(x: unknown): x is MediaFeatureRangeValueName;
export declare function isMediaFeatureRangeValueNameValue(x: unknown): x is MediaFeatureRangeValueNameValue;
export declare function isMediaFeatureValue(x: unknown): x is MediaFeatureValue;
export declare function isMediaInParens(x: unknown): x is MediaInParens;
export declare function isMediaNot(x: unknown): x is MediaNot;
export declare function isMediaOr(x: unknown): x is MediaOr;
export declare function isMediaQuery(x: unknown): x is MediaQuery;
export declare function isMediaQueryInvalid(x: unknown): x is MediaQueryInvalid;
export declare function isMediaQueryWithoutType(x: unknown): x is MediaQueryWithoutType;
export declare function isMediaQueryWithType(x: unknown): x is MediaQueryWithType;
export declare function matchesComparison(componentValues: Array<ComponentValue>): false | [number, number];
export declare function matchesRatio(componentValues: Array<ComponentValue>): number[] | -1;
export declare function matchesRatioExactly(componentValues: Array<ComponentValue>): number[] | -1;
export declare class MediaAnd {
type: NodeType;
modifier: Array<CSSToken>;
media: MediaInParens;
constructor(modifier: Array<CSSToken>, media: MediaInParens);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaInParens): number | string;
at(index: number | string): MediaInParens | null;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaAndWalkerEntry;
parent: MediaAndWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): unknown;
isMediaAnd(): this is MediaAnd;
static isMediaAnd(x: unknown): x is MediaAnd;
}
export declare type MediaAndWalkerEntry = MediaInParensWalkerEntry | MediaInParens;
export declare type MediaAndWalkerParent = MediaInParensWalkerParent | MediaAnd;
export declare class MediaCondition {
type: NodeType;
media: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr;
constructor(media: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr): number | string;
at(index: number | string): MediaNot | MediaInParens | MediaConditionListWithAnd | MediaConditionListWithOr | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaConditionWalkerEntry;
parent: MediaConditionWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): unknown;
isMediaCondition(): this is MediaCondition;
static isMediaCondition(x: unknown): x is MediaCondition;
}
export declare type MediaConditionList = MediaConditionListWithAnd | MediaConditionListWithOr;
export declare class MediaConditionListWithAnd {
type: NodeType;
leading: MediaInParens;
list: Array<MediaAnd>;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(leading: MediaInParens, list: Array<MediaAnd>, before?: Array<CSSToken>, after?: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaInParens | MediaAnd): number | string;
at(index: number | string): MediaInParens | MediaAnd | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaConditionListWithAndWalkerEntry;
parent: MediaConditionListWithAndWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): unknown;
isMediaConditionListWithAnd(): this is MediaConditionListWithAnd;
static isMediaConditionListWithAnd(x: unknown): x is MediaConditionListWithAnd;
}
export declare type MediaConditionListWithAndWalkerEntry = MediaAndWalkerEntry | MediaAnd;
export declare type MediaConditionListWithAndWalkerParent = MediaAndWalkerParent | MediaConditionListWithAnd;
export declare class MediaConditionListWithOr {
type: NodeType;
leading: MediaInParens;
list: Array<MediaOr>;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(leading: MediaInParens, list: Array<MediaOr>, before?: Array<CSSToken>, after?: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaInParens | MediaOr): number | string;
at(index: number | string): MediaInParens | MediaOr | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaConditionListWithOrWalkerEntry;
parent: MediaConditionListWithOrWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): unknown;
isMediaConditionListWithOr(): this is MediaConditionListWithOr;
static isMediaConditionListWithOr(x: unknown): x is MediaConditionListWithOr;
}
export declare type MediaConditionListWithOrWalkerEntry = MediaOrWalkerEntry | MediaOr;
export declare type MediaConditionListWithOrWalkerParent = MediaOrWalkerParent | MediaConditionListWithOr;
export declare type MediaConditionWalkerEntry = MediaNotWalkerEntry | MediaConditionListWithAndWalkerEntry | MediaConditionListWithOrWalkerEntry | MediaNot | MediaConditionListWithAnd | MediaConditionListWithOr;
export declare type MediaConditionWalkerParent = MediaNotWalkerParent | MediaConditionListWithAndWalkerParent | MediaConditionListWithOrWalkerParent | MediaCondition;
export declare class MediaFeature {
type: NodeType;
feature: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(feature: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange, before?: Array<CSSToken>, after?: Array<CSSToken>);
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange): number | string;
at(index: number | string): MediaFeatureBoolean | MediaFeaturePlain | MediaFeatureRange | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeatureWalkerEntry;
parent: MediaFeatureWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
feature: {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
before: CSSToken[];
after: CSSToken[];
};
isMediaFeature(): this is MediaFeature;
static isMediaFeature(x: unknown): x is MediaFeature;
}
export declare class MediaFeatureBoolean {
type: NodeType;
name: MediaFeatureName;
constructor(name: MediaFeatureName);
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeatureName): number | string;
at(index: number | string): MediaFeatureName | undefined;
toJSON(): {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
isMediaFeatureBoolean(): this is MediaFeatureBoolean;
static isMediaFeatureBoolean(x: unknown): x is MediaFeatureBoolean;
}
export declare type MediaFeatureComparison = MediaFeatureLT | MediaFeatureGT | MediaFeatureEQ;
export declare enum MediaFeatureEQ {
EQ = "="
}
export declare enum MediaFeatureGT {
GT = ">",
GT_OR_EQ = ">="
}
export declare enum MediaFeatureLT {
LT = "<",
LT_OR_EQ = "<="
}
export declare class MediaFeatureName {
type: NodeType;
name: ComponentValue;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(name: ComponentValue, before?: Array<CSSToken>, after?: Array<CSSToken>);
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: ComponentValue): number | string;
at(index: number | string): ComponentValue | undefined;
toJSON(): {
type: NodeType;
name: string;
tokens: CSSToken[];
};
isMediaFeatureName(): this is MediaFeatureName;
static isMediaFeatureName(x: unknown): x is MediaFeatureName;
}
export declare class MediaFeaturePlain {
type: NodeType;
name: MediaFeatureName;
colon: TokenColon;
value: MediaFeatureValue;
constructor(name: MediaFeatureName, colon: TokenColon, value: MediaFeatureValue);
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeatureName | MediaFeatureValue): number | string;
at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeaturePlainWalkerEntry;
parent: MediaFeaturePlainWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
value: {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
isMediaFeaturePlain(): this is MediaFeaturePlain;
static isMediaFeaturePlain(x: unknown): x is MediaFeaturePlain;
}
export declare type MediaFeaturePlainWalkerEntry = MediaFeatureValueWalkerEntry | MediaFeatureValue;
export declare type MediaFeaturePlainWalkerParent = MediaFeatureValueWalkerParent | MediaFeaturePlain;
export declare type MediaFeatureRange = MediaFeatureRangeNameValue | MediaFeatureRangeValueName | MediaFeatureRangeValueNameValue;
export declare class MediaFeatureRangeNameValue {
type: NodeType;
name: MediaFeatureName;
operator: [TokenDelim, TokenDelim] | [TokenDelim];
value: MediaFeatureValue;
constructor(name: MediaFeatureName, operator: [TokenDelim, TokenDelim] | [TokenDelim], value: MediaFeatureValue);
operatorKind(): MediaFeatureComparison | false;
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeatureName | MediaFeatureValue): number | string;
at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeatureRangeWalkerEntry;
parent: MediaFeatureRangeWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
value: {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
isMediaFeatureRangeNameValue(): this is MediaFeatureRangeNameValue;
static isMediaFeatureRangeNameValue(x: unknown): x is MediaFeatureRangeNameValue;
}
export declare class MediaFeatureRangeValueName {
type: NodeType;
name: MediaFeatureName;
operator: [TokenDelim, TokenDelim] | [TokenDelim];
value: MediaFeatureValue;
constructor(name: MediaFeatureName, operator: [TokenDelim, TokenDelim] | [TokenDelim], value: MediaFeatureValue);
operatorKind(): MediaFeatureComparison | false;
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeatureName | MediaFeatureValue): number | string;
at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeatureRangeWalkerEntry;
parent: MediaFeatureRangeWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
value: {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
isMediaFeatureRangeValueName(): this is MediaFeatureRangeValueName;
static isMediaFeatureRangeValueName(x: unknown): x is MediaFeatureRangeValueName;
}
export declare class MediaFeatureRangeValueNameValue {
type: NodeType;
name: MediaFeatureName;
valueOne: MediaFeatureValue;
valueOneOperator: [TokenDelim, TokenDelim] | [TokenDelim];
valueTwo: MediaFeatureValue;
valueTwoOperator: [TokenDelim, TokenDelim] | [TokenDelim];
constructor(name: MediaFeatureName, valueOne: MediaFeatureValue, valueOneOperator: [TokenDelim, TokenDelim] | [TokenDelim], valueTwo: MediaFeatureValue, valueTwoOperator: [TokenDelim, TokenDelim] | [TokenDelim]);
valueOneOperatorKind(): MediaFeatureComparison | false;
valueTwoOperatorKind(): MediaFeatureComparison | false;
getName(): string;
getNameToken(): CSSToken;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaFeatureName | MediaFeatureValue): number | string;
at(index: number | string): MediaFeatureName | MediaFeatureValue | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeatureRangeWalkerEntry;
parent: MediaFeatureRangeWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
name: {
type: NodeType;
name: string;
tokens: CSSToken[];
};
valueOne: {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
valueTwo: {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
tokens: CSSToken[];
};
isMediaFeatureRangeValueNameValue(): this is MediaFeatureRangeValueNameValue;
static isMediaFeatureRangeValueNameValue(x: unknown): x is MediaFeatureRangeValueNameValue;
}
export declare type MediaFeatureRangeWalkerEntry = MediaFeatureValueWalkerEntry | MediaFeatureValue;
export declare type MediaFeatureRangeWalkerParent = MediaFeatureValueWalkerParent | MediaFeatureRange;
export declare class MediaFeatureValue {
type: NodeType;
value: ComponentValue | Array<ComponentValue>;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(value: ComponentValue | Array<ComponentValue>, before?: Array<CSSToken>, after?: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: ComponentValue): number | string;
at(index: number | string): ComponentValue | Array<ComponentValue> | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaFeatureValueWalkerEntry;
parent: MediaFeatureValueWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
value: unknown;
tokens: CSSToken[];
};
isMediaFeatureValue(): this is MediaFeatureValue;
static isMediaFeatureValue(x: unknown): x is MediaFeatureValue;
}
export declare type MediaFeatureValueWalkerEntry = ComponentValue;
export declare type MediaFeatureValueWalkerParent = ContainerNode | MediaFeatureValue;
export declare type MediaFeatureWalkerEntry = MediaFeaturePlainWalkerEntry | MediaFeatureRangeWalkerEntry | MediaFeaturePlain | MediaFeatureBoolean | MediaFeatureRange;
export declare type MediaFeatureWalkerParent = MediaFeaturePlainWalkerParent | MediaFeatureRangeWalkerParent | MediaFeature;
export declare class MediaInParens {
type: NodeType;
media: MediaCondition | MediaFeature | GeneralEnclosed;
before: Array<CSSToken>;
after: Array<CSSToken>;
constructor(media: MediaCondition | MediaFeature | GeneralEnclosed, before?: Array<CSSToken>, after?: Array<CSSToken>);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaCondition | MediaFeature | GeneralEnclosed): number | string;
at(index: number | string): MediaCondition | MediaFeature | GeneralEnclosed | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaInParensWalkerEntry;
parent: MediaInParensWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
media: unknown;
before: CSSToken[];
after: CSSToken[];
};
isMediaInParens(): this is MediaInParens;
static isMediaInParens(x: unknown): x is MediaInParens;
}
export declare type MediaInParensWalkerEntry = ComponentValue | GeneralEnclosed | MediaAnd | MediaNot | MediaOr | MediaConditionList | MediaCondition | MediaFeatureBoolean | MediaFeatureName | MediaFeaturePlain | MediaFeatureRange | MediaFeatureValue | MediaFeature | GeneralEnclosed | MediaInParens;
export declare type MediaInParensWalkerParent = ContainerNode | GeneralEnclosed | MediaAnd | MediaNot | MediaOr | MediaConditionList | MediaCondition | MediaFeatureBoolean | MediaFeatureName | MediaFeaturePlain | MediaFeatureRange | MediaFeatureValue | MediaFeature | GeneralEnclosed | MediaInParens;
export declare class MediaNot {
type: NodeType;
modifier: Array<CSSToken>;
media: MediaInParens;
constructor(modifier: Array<CSSToken>, media: MediaInParens);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaInParens): number | string;
at(index: number | string): MediaInParens | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaNotWalkerEntry;
parent: MediaNotWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
modifier: CSSToken[];
media: {
type: NodeType;
media: unknown;
before: CSSToken[];
after: CSSToken[];
};
};
isMediaNot(): this is MediaNot;
static isMediaNot(x: unknown): x is MediaNot;
}
export declare type MediaNotWalkerEntry = MediaInParensWalkerEntry | MediaInParens;
export declare type MediaNotWalkerParent = MediaInParensWalkerParent | MediaNot;
export declare class MediaOr {
type: NodeType;
modifier: Array<CSSToken>;
media: MediaInParens;
constructor(modifier: Array<CSSToken>, media: MediaInParens);
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaInParens): number | string;
at(index: number | string): MediaInParens | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaOrWalkerEntry;
parent: MediaOrWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
modifier: CSSToken[];
media: {
type: NodeType;
media: unknown;
before: CSSToken[];
after: CSSToken[];
};
};
isMediaOr(): this is MediaOr;
static isMediaOr(x: unknown): x is MediaOr;
}
export declare type MediaOrWalkerEntry = MediaInParensWalkerEntry | MediaInParens;
export declare type MediaOrWalkerParent = MediaInParensWalkerParent | MediaOr;
export declare type MediaQuery = MediaQueryWithType | MediaQueryWithoutType | MediaQueryInvalid;
export declare class MediaQueryInvalid {
type: NodeType;
media: Array<ComponentValue>;
constructor(media: Array<ComponentValue>);
negateQuery(): MediaQuery;
tokens(): Array<CSSToken>;
toString(): string;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaQueryInvalidWalkerEntry;
parent: MediaQueryInvalidWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
string: string;
media: ComponentValue[];
};
isMediaQueryInvalid(): this is MediaQueryInvalid;
static isMediaQueryInvalid(x: unknown): x is MediaQueryInvalid;
}
export declare type MediaQueryInvalidWalkerEntry = ComponentValue;
export declare type MediaQueryInvalidWalkerParent = ComponentValue | MediaQueryInvalid;
export declare enum MediaQueryModifier {
Not = "not",
Only = "only"
}
export declare class MediaQueryWithoutType {
type: NodeType;
media: MediaCondition;
constructor(media: MediaCondition);
negateQuery(): MediaQuery;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaCondition): number | string;
at(index: number | string): MediaCondition | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaQueryWithoutTypeWalkerEntry;
parent: MediaQueryWithoutTypeWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
string: string;
media: MediaCondition;
};
isMediaQueryWithoutType(): this is MediaQueryWithoutType;
static isMediaQueryWithoutType(x: unknown): x is MediaQueryWithoutType;
}
export declare type MediaQueryWithoutTypeWalkerEntry = MediaConditionWalkerEntry | MediaCondition;
export declare type MediaQueryWithoutTypeWalkerParent = MediaConditionWalkerParent | MediaQueryWithoutType;
export declare class MediaQueryWithType {
type: NodeType;
modifier: Array<CSSToken>;
mediaType: Array<CSSToken>;
and: Array<CSSToken> | undefined;
media: MediaCondition | undefined;
constructor(modifier: Array<CSSToken>, mediaType: Array<CSSToken>, and?: Array<CSSToken> | undefined, media?: MediaCondition | undefined);
getModifier(): string;
negateQuery(): MediaQuery;
getMediaType(): string;
tokens(): Array<CSSToken>;
toString(): string;
indexOf(item: MediaCondition): number | string;
at(index: number | string): MediaCondition | undefined;
walk<T extends Record<string, unknown>>(cb: (entry: {
node: MediaQueryWithTypeWalkerEntry;
parent: MediaQueryWithTypeWalkerParent;
state?: T;
}, index: number | string) => boolean | void, state?: T): false | undefined;
toJSON(): {
type: NodeType;
string: string;
modifier: CSSToken[];
mediaType: CSSToken[];
and: CSSToken[] | undefined;
media: MediaCondition | undefined;
};
isMediaQueryWithType(): this is MediaQueryWithType;
static isMediaQueryWithType(x: unknown): x is MediaQueryWithType;
}
export declare type MediaQueryWithTypeWalkerEntry = MediaConditionWalkerEntry | MediaCondition;
export declare type MediaQueryWithTypeWalkerParent = MediaConditionWalkerParent | MediaQueryWithType;
export declare enum MediaType {
/** Always matches */
All = "all",
Print = "print",
Screen = "screen",
/** Never matches */
Tty = "tty",
/** Never matches */
Tv = "tv",
/** Never matches */
Projection = "projection",
/** Never matches */
Handheld = "handheld",
/** Never matches */
Braille = "braille",
/** Never matches */
Embossed = "embossed",
/** Never matches */
Aural = "aural",
/** Never matches */
Speech = "speech"
}
export declare function modifierFromToken(token: TokenIdent): MediaQueryModifier | false;
export declare function newMediaFeatureBoolean(name: string): MediaFeature;
export declare function newMediaFeaturePlain(name: string, ...value: Array<CSSToken>): MediaFeature;
export declare enum NodeType {
CustomMedia = "custom-media",
GeneralEnclosed = "general-enclosed",
MediaAnd = "media-and",
MediaCondition = "media-condition",
MediaConditionListWithAnd = "media-condition-list-and",
MediaConditionListWithOr = "media-condition-list-or",
MediaFeature = "media-feature",
MediaFeatureBoolean = "mf-boolean",
MediaFeatureName = "mf-name",
MediaFeaturePlain = "mf-plain",
MediaFeatureRangeNameValue = "mf-range-name-value",
MediaFeatureRangeValueName = "mf-range-value-name",
MediaFeatureRangeValueNameValue = "mf-range-value-name-value",
MediaFeatureValue = "mf-value",
MediaInParens = "media-in-parens",
MediaNot = "media-not",
MediaOr = "media-or",
MediaQueryWithType = "media-query-with-type",
MediaQueryWithoutType = "media-query-without-type",
MediaQueryInvalid = "media-query-invalid"
}
export declare function parse(source: string, options?: {
preserveInvalidMediaQueries?: boolean;
onParseError?: (error: ParseError) => void;
}): MediaQuery[];
export declare function parseCustomMedia(source: string, options?: {
preserveInvalidMediaQueries?: boolean;
onParseError?: (error: ParseError) => void;
}): CustomMedia | false;
export declare function parseCustomMediaFromTokens(tokens: Array<CSSToken>, options?: {
preserveInvalidMediaQueries?: boolean;
onParseError?: (error: ParseError) => void;
}): CustomMedia | false;
export declare function parseFromTokens(tokens: Array<CSSToken>, options?: {
preserveInvalidMediaQueries?: boolean;
onParseError?: (error: ParseError) => void;
}): MediaQuery[];
export declare function typeFromToken(token: TokenIdent): MediaType | false;
export { }
{
"name": "@csstools/media-query-list-parser",
"description": "Parse CSS media query lists.",
"version": "2.1.5",
"version": "2.1.6",
"contributors": [

@@ -30,11 +30,14 @@ {

},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"default": "./dist/index.cjs"
}
}

@@ -49,13 +52,5 @@ },

"peerDependencies": {
"@csstools/css-parser-algorithms": "^2.3.2",
"@csstools/css-tokenizer": "^2.2.1"
"@csstools/css-parser-algorithms": "^2.4.0",
"@csstools/css-tokenizer": "^2.2.2"
},
"scripts": {
"build": "rollup -c ../../rollup/default.mjs",
"lint": "node ../../.github/bin/format-package-json.mjs",
"prepublishOnly": "npm run build && npm run test",
"stryker": "stryker run --logLevel error",
"test": "node ./test/test.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
"test:rewrite-expects": "REWRITE_EXPECTS=true node ./test/test.mjs"
},
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/media-query-list-parser#readme",

@@ -72,6 +67,3 @@ "repository": {

"parser"
],
"volta": {
"extends": "../../package.json"
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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