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

css-node-extract

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-node-extract - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

dist/interfaces/ICustomFilter.d.ts

4

dist/index.d.ts

@@ -5,3 +5,3 @@ import { IProcessOptions } from './interfaces/IProcessOptions';

*/
export declare const processSync: ({css, filters, customFilter, postcssSyntax}: IProcessOptions) => string;
export declare const processSync: ({css, filters, customFilters, postcssSyntax}: IProcessOptions) => string;
/**

@@ -13,4 +13,4 @@ * Asynchronously extract nodes from a string.

process: (options: IProcessOptions) => Promise<{}>;
processSync: ({css, filters, customFilter, postcssSyntax}: IProcessOptions) => string;
processSync: ({css, filters, customFilters, postcssSyntax}: IProcessOptions) => string;
};
export default _default;

@@ -8,3 +8,3 @@ "use strict";

*/
exports.processSync = ({ css, filters, customFilter, postcssSyntax, }) => postcss(postcssNodeExtract(filters, customFilter))
exports.processSync = ({ css, filters, customFilters, postcssSyntax, }) => postcss(postcssNodeExtract(filters, customFilters))
.process(css, { syntax: postcssSyntax }).css;

@@ -11,0 +11,0 @@ /**

import { IFilterGroup } from './IFilterGroup';
export interface IFilterDefinitions {
atRules: IFilterGroup;
custom: IFilterGroup;
declarations: IFilterGroup;
atRules: IFilterGroup[];
declarations: IFilterGroup[];
functions: IFilterGroup[];
mixins: IFilterGroup[];
rules: IFilterGroup;
rules: IFilterGroup[];
silent: IFilterGroup[];
variables: IFilterGroup[];
[key: string]: IFilterGroup[];
}

@@ -1,7 +0,7 @@

import { IFilterGroup } from './IFilterGroup';
import { ICustomFilter } from './ICustomFilter';
export interface IProcessOptions {
css: string;
filters: string | string[];
customFilter: IFilterGroup;
customFilters: ICustomFilter[];
postcssSyntax?: any;
}
import { IFilter } from '../interfaces/IFilter';
declare const _default: (node: {
parent: any;
}, filterGroups: IFilter[]) => boolean;
}, filterGroups: IFilter[][]) => boolean;
export = _default;

@@ -8,4 +8,3 @@ "use strict";

let extractNode = false;
filterGroups.some((groupOrFilter) => {
const filterGroup = Array.isArray(groupOrFilter) ? groupOrFilter : [groupOrFilter];
filterGroups.some((filterGroup) => {
extractNode = filterGroup.filter((filter) => !nodeMatchesFilter(node, filter)).length === 0;

@@ -12,0 +11,0 @@ return extractNode;

@@ -7,7 +7,10 @@ "use strict";

atRules: [
{ property: `type`, value: `atrule` },
[
{ property: `type`, value: `atrule` },
],
],
custom: [],
declarations: [
{ property: `type`, value: `decl` },
[
{ property: `type`, value: `decl` },
],
],

@@ -31,3 +34,5 @@ functions: [

rules: [
{ property: `type`, value: `rule` },
[
{ property: `type`, value: `rule` },
],
],

@@ -34,0 +39,0 @@ silent: [

import * as postcss from 'postcss';
import { IFilter } from '../interfaces/IFilter';
declare const _default: (filterNames: string | string[], customFilter: IFilter[]) => postcss.Plugin<{}>;
import { ICustomFilter } from '../interfaces/ICustomFilter';
declare const _default: (filterNames: string | string[], customFilters: ICustomFilter[]) => postcss.Plugin<{}>;
export = _default;

@@ -6,5 +6,5 @@ "use strict";

const filterDefinitions = require("./filter-definitions");
module.exports = function postcssNodeExtract(filterNames, customFilter) {
module.exports = function postcssNodeExtract(filterNames, customFilters) {
const filterNamesArray = Array.isArray(filterNames) ? filterNames : [filterNames];
filterDefinitions.custom = customFilter;
Object.assign(filterDefinitions, customFilters);
return postcss.plugin(`postcss-node-extract`, () => (nodes) => {

@@ -11,0 +11,0 @@ nodes.walk((rule) => {

@@ -7,3 +7,3 @@ {

],
"version": "1.1.0",
"version": "2.0.0",
"author": "Markus Oberlehner",

@@ -21,10 +21,10 @@ "homepage": "https://github.com/maoberlehner/css-node-extract",

"change-case": "^3.0.1",
"postcss": "^6.0.10"
"postcss": "^6.0.11"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^3.5.0",
"mocha": "^3.5.3",
"postcss-less": "^1.1.0",
"postcss-scss": "^1.0.2",
"rimraf": "^2.6.1",
"rimraf": "^2.6.2",
"tslint": "^5.7.0",

@@ -31,0 +31,0 @@ "typescript": "^2.5.2"

@@ -14,3 +14,3 @@ # css-node-extract

- **variables**: `$sass-variable` and `@less-variable`
- **custom**: Define a custom filter
- **make-your-own**: Define custom filters

@@ -48,9 +48,11 @@ ## Demos

css: '@keyframes { } .selector { } .other-selector { }',
filters: ['custom'],
customFilter: [
[
{ property: 'type', value: 'atrule' },
{ property: 'name', value: 'keyframes' }
filters: ['my-keyframe-filter'],
customFilters: {
myKeyframeFilter: [
[
{ property: 'type', value: 'atrule' },
{ property: 'name', value: 'keyframes' }
]
]
]
}
};

@@ -87,2 +89,5 @@

## Upgrade from 1.x.x to 2.x.x
With version 2.0.0 the handling of custom filters was changed. The `customFilter` option was renamed to `customFilters` and this option now takes an object instead of an array. Instead of defining one custom filter named `custom`, you can now define unlimited custom filters with custom names.
## Upgrade from 0.x.x to 1.x.x

@@ -89,0 +94,0 @@ With version 1.0.0 the `filterNames` option was renamed to `filters`.

@@ -13,5 +13,5 @@ import * as postcss from 'postcss';

filters,
customFilter,
customFilters,
postcssSyntax,
}: IProcessOptions) => postcss(postcssNodeExtract(filters, customFilter))
}: IProcessOptions) => postcss(postcssNodeExtract(filters, customFilters))
.process(css, { syntax: postcssSyntax }).css;

@@ -18,0 +18,0 @@

import { IFilterGroup } from './IFilterGroup';
export interface IFilterDefinitions {
atRules: IFilterGroup;
custom: IFilterGroup;
declarations: IFilterGroup;
atRules: IFilterGroup[];
declarations: IFilterGroup[];
functions: IFilterGroup[];
mixins: IFilterGroup[];
rules: IFilterGroup;
rules: IFilterGroup[];
silent: IFilterGroup[];
variables: IFilterGroup[];
[key: string]: IFilterGroup[];
}

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

import { IFilterGroup } from './IFilterGroup';
import { ICustomFilter } from './ICustomFilter';

@@ -6,4 +6,4 @@ export interface IProcessOptions {

filters: string|string[];
customFilter: IFilterGroup;
customFilters: ICustomFilter[];
postcssSyntax?: any;
}

@@ -9,3 +9,3 @@ import nodeMatchesFilter = require('./node-matches-filter');

*/
export = function extractNodeRecursively(node: { parent: any }, filterGroups: IFilterGroup): boolean {
export = function extractNodeRecursively(node: { parent: any }, filterGroups: IFilterGroup[]): boolean {
if (node.parent && node.parent.type !== `root`) {

@@ -17,4 +17,3 @@ return extractNodeRecursively(node.parent, filterGroups);

filterGroups.some((groupOrFilter) => {
const filterGroup = Array.isArray(groupOrFilter) ? groupOrFilter : [groupOrFilter];
filterGroups.some((filterGroup) => {
extractNode = filterGroup.filter(

@@ -21,0 +20,0 @@ (filter) => !nodeMatchesFilter(node, filter),

@@ -10,7 +10,10 @@ import { IFilter } from '../interfaces/IFilter';

atRules: [
{ property: `type`, value: `atrule` },
[
{ property: `type`, value: `atrule` },
],
],
custom: [] as IFilterGroup,
declarations: [
{ property: `type`, value: `decl` },
[
{ property: `type`, value: `decl` },
],
],

@@ -34,3 +37,5 @@ functions: [

rules: [
{ property: `type`, value: `rule` },
[
{ property: `type`, value: `rule` },
],
],

@@ -37,0 +42,0 @@ silent: [

@@ -7,2 +7,3 @@ import { camelCase } from 'change-case';

import { ICustomFilter } from '../interfaces/ICustomFilter';
import { IFilter } from '../interfaces/IFilter';

@@ -14,5 +15,8 @@ import { IFilterGroup } from '../interfaces/IFilterGroup';

*/
export = function postcssNodeExtract(filterNames: string|string[], customFilter: IFilterGroup) {
export = function postcssNodeExtract(
filterNames: string|string[],
customFilters: ICustomFilter[],
) {
const filterNamesArray = Array.isArray(filterNames) ? filterNames : [filterNames];
filterDefinitions.custom = customFilter;
Object.assign(filterDefinitions, customFilters);

@@ -19,0 +23,0 @@ return postcss.plugin(`postcss-node-extract`, () => (nodes) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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