New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

media-query-parser

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

media-query-parser - npm Package Compare versions

Comparing version 3.0.0-beta.2 to 3.0.0-beta.3

2

dist/ast/ast.js

@@ -303,3 +303,3 @@ const n = '<'.codePointAt(0),

const t = matchQuery(i)
t && t.i === i.length ? n.push(t.n) : n.push({n: 'query', prefix: 'not', type: 'all'})
t && t.i === i.length ? n.push(t.n) : n.push(void 0)
}

@@ -306,0 +306,0 @@ return {n: 'query-list', qs: n}

@@ -1,2 +0,2 @@

export const generateQueryList = e => e.qs.map(e => generateQuery(e)).join(', ')
export const generateQueryList = e => e.qs.map(e => (e ? generateQuery(e) : 'not all')).join(', ')
export const generateQuery = e => {

@@ -3,0 +3,0 @@ var n

@@ -9,2 +9,3 @@ /**! media-query-parser | Tom Golden <oss@tom.bio> (https://tom.bio) | @license MIT */

* - _an invalid media-query child **does not** make the media-query-list invalid_
* - each invalid media query child is replaced with undefined
* - can **return** a ParserError (e.g. when there is a CSS syntax error, like an invalid string)

@@ -14,10 +15,25 @@ *

* ```ts
* console.log(parseMediaQueryList(`print, invalid, (min-width: 1000px)`));
* console.log(parseMediaQueryList(`print, #invalid, (min-width: 1000px)`));
* // {
* // type: "query-list",
* // mediaQueries: [
* // {type: "query", mediaType: "print"},
* // {type: "query", prefix: "not"},
* // {type: "query", mediaCondition: ...}
* // ],
* // n: 'query-list',
* // qs: [
* // { n: 'query', type: 'print' },
* // undefined,
* // {
* // n: 'query',
* // condition: {
* // n: 'condition',
* // op: 'and',
* // a: {
* // n: 'in-parens',
* // v: {
* // n: 'feature',
* // t: 'value',
* // f: 'min-width',
* // v: { n: 'dimension', v: 1000, u: 'px' }
* // }
* // }
* // }
* // }
* // ]
* // }

@@ -31,9 +47,14 @@ * ```

* ```ts
* console.log(parseMediaQuery(`(monochrome)`));
* console.log(parseMediaQuery(`screen and (monochrome)`));
* // {
* // type: "query",
* // mediaCondition: {
* // type: "condition",
* // children: [{ type: "feature", context: "boolean", feature: "monochrome" }],
* // },
* // n: 'query',
* // type: 'screen',
* // condition: {
* // n: 'condition',
* // op: 'and',
* // a: {
* // n: 'in-parens',
* // v: { n: 'feature', t: 'boolean', f: 'monochrome' }
* // }
* // }
* // }

@@ -50,22 +71,31 @@ * ```

* // {
* // type: "condition",
* // children: [{
* // type: "condition",
* // children: [
* // {
* // type: "feature",
* // context: "range",
* // feature: "aspect-ratio",
* // range: {
* // featureName: "aspect-ratio",
* // rightOp: ">",
* // rightToken: { denominator: 2, numerator: 1, type: "ratio" },
* // },
* // n: 'condition',
* // op: 'and',
* // a: {
* // n: 'in-parens',
* // v: {
* // n: 'condition',
* // op: 'or',
* // a: {
* // n: 'in-parens',
* // v: {
* // n: 'feature',
* // t: 'range',
* // f: 'aspect-ratio',
* // r: {
* // a: { n: 'ident', v: 'aspect-ratio' },
* // op: '>',
* // b: { n: 'ratio', l: 1, r: 2 }
* // }
* // }
* // },
* // { context: "boolean", feature: "monochrome", type: "feature" },
* // ],
* // operator: "or",
* // }],
* // bs: [
* // {
* // n: 'in-parens',
* // v: { n: 'feature', t: 'boolean', f: 'monochrome' }
* // }
* // ]
* // }
* // }
* // }
*
* ```

@@ -81,9 +111,7 @@ */

* // {
* // type: "feature",
* // context: "value",
* // feature: "width",
* // prefix: "min",
* // value: { type: "dimension", flag: "number", unit: "px", value: 768 },
* // n: 'feature',
* // t: 'value',
* // f: 'min-width',
* // v: { n: 'dimension', v: 768, u: 'px' }
* // }
*
* ```

@@ -98,22 +126,17 @@ */

* console.log(stringify({
* type: "query",
* mediaCondition: {
* type: "condition",
* children: [{ type: "feature", context: "boolean", feature: "monochrome" }],
* },
* n: 'query',
* type: 'screen',
* condition: {
* n: 'condition',
* op: 'and',
* a: {
* n: 'in-parens',
* v: { n: 'feature', t: 'boolean', f: 'monochrome' }
* }
* }
* }));
* // "(monochrome)"
* // 'screen and (monochrome)'
* ```
*
* note: stringifying a MediaCondition directly will always wrap the condition with parentheses.
* sometimes they are redundant, but calling this with a MediaQuery will remove them for you.
* e.g. `stringify({ type: 'query', mediaType: 'all', mediaCondition: <your condition> })`
*
* @example
* ```ts
* console.log(stringify(parseMediaFeature(`(min-width: 768px)`)));
* // "(min-width: 768px)"
* ```
*/
export declare const stringify: (node: QueryListNode | QueryNode | ConditionNode | FeatureNode | ValueNode) => string;
export * from "./utils.js";

@@ -96,3 +96,3 @@ import { Simplify } from "./internals.js";

n: "query-list";
qs: QueryNode[];
qs: Array<QueryNode | undefined>;
};

@@ -99,0 +99,0 @@ export type QueryNode = {

{
"name": "media-query-parser",
"description": "Parse CSS media queries (spec-compliant)",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"license": "MIT",

@@ -6,0 +6,0 @@ "keywords": [

@@ -68,4 +68,2 @@ # `media-query-parser`

> The shape of Errors are
## Usage

@@ -82,18 +80,19 @@

// {
// type: "query",
// mediaType: "screen",
// mediaCondition: {
// type: "condition",
// children: [{
// type: "feature",
// context: "value",
// prefix: "min",
// feature: "width",
// value: {
// type: "dimension", value: 768, unit: "px", flag: "number"
// },
// }],
// },
// n: 'query',
// type: 'screen',
// condition: {
// n: 'condition',
// op: 'and',
// a: {
// n: 'in-parens',
// v: {
// n: 'feature',
// t: 'value',
// f: 'min-width',
// v: { n: 'dimension', v: 768, u: 'px' }
// }
// }
// }
// }
console.log(stringify(mediaQuery.mediaCondition.children[0]));
console.log(stringify(mediaQuery.condition));
// "(min-width: 768px)"

@@ -100,0 +99,0 @@ }

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