Socket
Socket
Sign inDemoInstall

rcs-core

Package Overview
Dependencies
61
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.6.5 to 3.7.0

4

CHANGELOG.md

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

3.7.0 - October, 20 2021
* 4a2378c Chore: update dependencies | remove package-lock.json (closes #143) (#144) (Jan Peer Stöcklmair)
3.6.5 - July, 14 2021

@@ -2,0 +6,0 @@

@@ -6,2 +6,3 @@ "use strict";

});
exports.Warnings = void 0;

@@ -8,0 +9,0 @@ class Warnings {

3

dest/attributeLibrary.js

@@ -12,2 +12,3 @@ "use strict";

});
exports.AttributeLibrary = void 0;

@@ -143,3 +144,3 @@ const postcss_1 = require("postcss");

const code = data.toString();
const result = postcss_1.parse(code); // todo jpeer: check postcss types
const result = (0, postcss_1.parse)(code); // todo jpeer: check postcss types

@@ -146,0 +147,0 @@ result.walk(root => {

@@ -12,2 +12,3 @@ "use strict";

});
exports.BaseLibrary = void 0;

@@ -107,3 +108,3 @@ const nameGenerator_1 = require("./nameGenerator");

let found = finalValue in this.values;
let found = (finalValue in this.values);
let result = this.values[finalValue] || finalValue; // change the objects if isOriginalValue are set to false

@@ -110,0 +111,0 @@ // to get information about the compressed values

@@ -12,2 +12,3 @@ "use strict";

});
exports.ClassSelectorLibrary = void 0;

@@ -14,0 +15,0 @@ const regex_1 = __importDefault(require("./replace/regex"));

@@ -12,2 +12,3 @@ "use strict";

});
exports.CssVariablesLibrary = void 0;

@@ -27,3 +28,3 @@ const postcss_1 = require("postcss");

const code = data.toString();
const result = postcss_1.parse(code);
const result = (0, postcss_1.parse)(code);
result.walk(root => {

@@ -30,0 +31,0 @@ if (root.type === 'decl' && root.prop.match(/^--/)) {

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

if (options.codeType === 'html') {
const htmlExtractedCss = extractFromHtml_1.default(code.toString()); // no css code found to fill
const htmlExtractedCss = (0, extractFromHtml_1.default)(code.toString()); // no css code found to fill

@@ -37,0 +37,0 @@ if (htmlExtractedCss.length <= 0) {

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

const extractFromHtml = (code, type = 'style') => {
const ast = htmlToAst_1.default(code);
const ast = (0, htmlToAst_1.default)(code);
const extractedParts = [];
parse5_traverse_1.default(ast, {
(0, parse5_traverse_1.default)(ast, {
pre: node => {

@@ -24,0 +24,0 @@ if (node.parentNode && node.parentNode.tagName === type) {

@@ -12,2 +12,3 @@ "use strict";

});
exports.IdSelectorLibrary = void 0;

@@ -14,0 +15,0 @@ const regex_1 = __importDefault(require("./replace/regex"));

@@ -48,3 +48,3 @@ /// <reference types="node" />

helpers: {
htmlToAst: (code: string) => object | import("parse5").DefaultTreeDocument | import("parse5").DefaultTreeDocumentFragment;
htmlToAst: (code: string) => any;
extractFromHtml: (code: string, type?: string) => string[];

@@ -51,0 +51,0 @@ };

"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k];
}
});
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v
});
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -18,0 +42,0 @@ value: true

@@ -12,2 +12,3 @@ "use strict";

});
exports.KeyframesLibrary = void 0;

@@ -14,0 +15,0 @@ const baseLibrary_1 = require("./baseLibrary");

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

declare const defaultGenerator: (obj: {
nameCounter: number;
alphabet: string;
selector: string;
type: string;
}) => string;
export declare class NameGenerator {

@@ -12,7 +18,3 @@ type: string;

}
export declare const useCustomGenerator: (generator: (obj: {
nameCounter: number;
alphabet: string;
selector: string;
type: string;
}) => string) => void;
export declare const useCustomGenerator: (generator: typeof defaultGenerator) => void;
export {};

@@ -12,6 +12,7 @@ "use strict";

});
exports.useCustomGenerator = exports.NameGenerator = void 0;
const decimal_to_any_1 = __importDefault(require("decimal-to-any"));
const defaultGenerator = obj => decimal_to_any_1.default(obj.nameCounter, obj.alphabet.length, obj);
const defaultGenerator = obj => (0, decimal_to_any_1.default)(obj.nameCounter, obj.alphabet.length, obj);

@@ -54,4 +55,6 @@ let customGenerator = null;

exports.useCustomGenerator = generator => {
const useCustomGenerator = generator => {
customGenerator = generator;
};
};
exports.useCustomGenerator = useCustomGenerator;

@@ -30,4 +30,4 @@ "use strict";

const optimize = () => {
const mapping = generate_1.default();
const statistics = statistics_1.getStatistics();
const mapping = (0, generate_1.default)();
const statistics = (0, statistics_1.getStatistics)();

@@ -40,3 +40,3 @@ if (!statistics) {

const separateMapping = separateMappingSelectors_1.default(mapping.selectors);
const separateMapping = (0, separateMappingSelectors_1.default)(mapping.selectors);
const optimizedMapping = {

@@ -51,3 +51,3 @@ ids: [],

const statisticsData = statistics[key];
const newSortedSelectors = sortSelectors_1.default(selectors.map(([s]) => s), statisticsData);
const newSortedSelectors = (0, sortSelectors_1.default)(selectors.map(([s]) => s), statisticsData);
optimizedMapping[key] = newSortedSelectors;

@@ -82,3 +82,3 @@ }); // could be a cold start but

load_1.default({
(0, load_1.default)({
attributeSelectors: mapping.attributeSelectors

@@ -85,0 +85,0 @@ });

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

import generate from '../mapping/generate';
import generateStatistics from '../statistics/generate';

@@ -5,5 +6,3 @@ declare type Result = {

};
declare const separateMappingSelectors: (mappingSelectors?: {
[s: string]: string;
} | undefined) => Result;
declare const separateMappingSelectors: (mappingSelectors?: ReturnType<typeof generate>['selectors']) => Result;
export default separateMappingSelectors;

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

data = data.replace(regex_1.default.strings, match => string_1.default(match, regex, opts));
data = data.replace(regex_1.default.strings, match => (0, string_1.default)(match, regex, opts));
return data;

@@ -30,0 +30,0 @@ };

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

const replaceCss = (css, opts = {}) => {
const cssAST = postcss_1.parse(css);
const cssAST = (0, postcss_1.parse)(css);
/* ******************** *

@@ -172,3 +172,3 @@ * replace id selectors *

if (node.value.match(regex_1.default.cssVariables)) {
const regex = arrayToRegex_1.default(Object.keys(cssVariablesLibrary_1.default.values), v => `--${v}`);
const regex = (0, arrayToRegex_1.default)(Object.keys(cssVariablesLibrary_1.default.values), v => `--${v}`);

@@ -175,0 +175,0 @@ if (regex) {

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

};
const options = lodash_merge_1.default({}, opts, defaultOptions);
const ast = htmlToAst_1.default(code);
const options = (0, lodash_merge_1.default)({}, opts, defaultOptions);
const ast = (0, htmlToAst_1.default)(code);
const srcOpt = {
sourceFile: opts.sourceFile
};
parse5_traverse_1.default(ast, {
(0, parse5_traverse_1.default)(ast, {
// todo jpeer: check correct type

@@ -56,3 +56,3 @@ pre: node => {

// eslint-disable-next-line no-param-reassign
node.value = js_1.default(node.value, lodash_merge_1.default({}, options.espreeOptions, srcOpt));
node.value = (0, js_1.default)(node.value, (0, lodash_merge_1.default)({}, options.espreeOptions, srcOpt));
}

@@ -70,3 +70,3 @@ } // rename <noscript> tags

// eslint-disable-next-line no-param-reassign
node.value = css_1.default(node.value, srcOpt);
node.value = (0, css_1.default)(node.value, srcOpt);
} // rename attributes

@@ -81,7 +81,7 @@

if (attr.name === 'class' || isVueClass || options.triggerClassAttributes.some(item => shouldTriggerAttribute_1.default(attr, item))) {
if (attr.name === 'class' || isVueClass || options.triggerClassAttributes.some(item => (0, shouldTriggerAttribute_1.default)(attr, item))) {
selectorType = '.';
}
if (attr.name === 'id' || isVueId || options.triggerIdAttributes.some(item => shouldTriggerAttribute_1.default(attr, item))) {
if (attr.name === 'id' || isVueId || options.triggerIdAttributes.some(item => (0, shouldTriggerAttribute_1.default)(attr, item))) {
selectorType = '#';

@@ -103,3 +103,3 @@ }

attr.value = attr.value.replace(/'[\s\S]*?'|"[\s\S]*?"/g, match => {
const replacedString = string_1.default(match, undefined, {
const replacedString = (0, string_1.default)(match, undefined, {
forceReplace: true,

@@ -106,0 +106,0 @@ source: {

@@ -9,3 +9,3 @@ /// <reference types="node" />

}
declare const replaceJs: (code: string | Buffer, espreeOptions?: any) => string;
declare const replaceJs: (code: string | Buffer, espreeOptions?: EspreeOptions) => string;
export default replaceJs;
"use strict";
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k];
}
});
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
Object.defineProperty(o, "default", {
enumerable: true,
value: v
});
} : function (o, v) {
o["default"] = v;
});
var __importStar = this && this.__importStar || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = this && this.__importDefault || function (mod) {

@@ -17,3 +49,3 @@ return mod && mod.__esModule ? mod : {

const espree_1 = __importDefault(require("espree"));
const espree = __importStar(require("espree"));

@@ -44,4 +76,4 @@ const lodash_merge_1 = __importDefault(require("lodash.merge"));

const regex = selectorsLibrary_1.default.getAllRegex();
const options = lodash_merge_1.default({
ecmaVersion: 10,
const options = (0, lodash_merge_1.default)({
ecmaVersion: 'latest',
sourceType: 'module',

@@ -52,5 +84,5 @@ ecmaFeatures: {

}, espreeOptions);
const ast = recast_1.parse(code, {
const ast = (0, recast_1.parse)(code, {
parser: {
parse: source => espree_1.default.parse(source, Object.assign(Object.assign({}, options), {
parse: source => espree.parse(source, Object.assign(Object.assign({}, options), {
range: true,

@@ -64,3 +96,3 @@ loc: true,

});
ast_traverse_1.default(ast, {
(0, ast_traverse_1.default)(ast, {
pre: (node, parentNode) => {

@@ -92,3 +124,3 @@ let isJSX = false; // Avoid recursing into a "in" node since it can't be a CSS class or variable.

const replacedAttr = newValue.replace(newValue, match => string_1.default(match, selectorLibRegex, // don't be too smart about selector detection and non replacement if we have
const replacedAttr = newValue.replace(newValue, match => (0, string_1.default)(match, selectorLibRegex, // don't be too smart about selector detection and non replacement if we have
// a class, since class="a b" should replace both entry here even if it looks like

@@ -109,3 +141,3 @@ // a selector text for parent child tags

node.raw = node.raw.replace(node.raw, match => string_1.default(match, regex, {
node.raw = node.raw.replace(node.raw, match => (0, string_1.default)(match, regex, {
isJSX,

@@ -118,3 +150,3 @@ source

const replacedCssSelectors = newValue.replace(newValue, match => string_1.default(match, regex, {
const replacedCssSelectors = newValue.replace(newValue, match => (0, string_1.default)(match, regex, {
isJSX,

@@ -135,3 +167,3 @@ countStats: false,

});
return recast_1.print(ast).code;
return (0, recast_1.print)(ast).code;
};

@@ -138,0 +170,0 @@

@@ -36,4 +36,4 @@ "use strict";

const replacePug = (code, opts = {}) => {
const lexed = pug_lexer_1.default(code);
const ast = pug_parser_1.default(lexed);
const lexed = (0, pug_lexer_1.default)(code);
const ast = (0, pug_parser_1.default)(lexed);
const defaultOptions = {

@@ -44,4 +44,4 @@ espreeOptions: {},

};
const options = lodash_merge_1.default({}, opts, defaultOptions);
pug_walk_1.default(ast, node => {
const options = (0, lodash_merge_1.default)({}, opts, defaultOptions);
(0, pug_walk_1.default)(ast, node => {
if (node.name === 'script' || node.name === 'style') {

@@ -58,8 +58,8 @@ const modifiedBlockNodes = node.block.nodes.map(block => {

});
const newCode = wrap_1.default(pug_code_gen_1.default(Object.assign(Object.assign({}, node.block), {
const newCode = (0, wrap_1.default)((0, pug_code_gen_1.default)(Object.assign(Object.assign({}, node.block), {
nodes: modifiedBlockNodes
})))();
const replacedCode = node.name === 'script' ? js_1.default(newCode, lodash_merge_1.default({}, options.espreeOptions, {
const replacedCode = node.name === 'script' ? (0, js_1.default)(newCode, (0, lodash_merge_1.default)({}, options.espreeOptions, {
sourceFile: opts.sourceFile
})) : css_1.default(newCode, {
})) : (0, css_1.default)(newCode, {
sourceFile: opts.sourceFile

@@ -69,3 +69,3 @@ }); // add one tab after each new line

const pugCode = `${node.name}.\n${replacedCode}`.replace(/\n/g, '\n\t');
const astReplaced = pug_parser_1.default(pug_lexer_1.default(pugCode));
const astReplaced = (0, pug_parser_1.default)((0, pug_lexer_1.default)(pugCode));
const scriptBlock = astReplaced.nodes[0].block; // do not change entire scriptBlock

@@ -93,3 +93,3 @@ // this might be look like the correct ast,

if (attr.name === 'class' || options.triggerClassAttributes.some(item => shouldTriggerAttribute_1.default(attr, item))) {
if (attr.name === 'class' || options.triggerClassAttributes.some(item => (0, shouldTriggerAttribute_1.default)(attr, item))) {
selectorType = '.';

@@ -99,3 +99,3 @@ shouldReplace = true;

if (attr.name === 'id' || options.triggerIdAttributes.some(item => shouldTriggerAttribute_1.default(attr, item))) {
if (attr.name === 'id' || options.triggerIdAttributes.some(item => (0, shouldTriggerAttribute_1.default)(attr, item))) {
selectorType = '#';

@@ -129,3 +129,3 @@ shouldReplace = true;

});
return pug_source_gen_1.default(ast);
return (0, pug_source_gen_1.default)(ast);
};

@@ -132,0 +132,0 @@

@@ -21,4 +21,5 @@ "use strict";

templateSelectors: /(class|for|id)+\s*=\s*(['"])((?:.(?!\2))*.?)\2/g,
likelySelector: /[ #.=,()"'[\]]+/
likelySelector: /[ #.=,()"'[\]]+/ // if it contains any of these chars, then the string is likely a selector
};
module.exports = exports.default;

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

return startSplitChar + selectorLib.get(tempElement, lodash_merge_1.default({
return startSplitChar + selectorLib.get(tempElement, (0, lodash_merge_1.default)({
addSelectorType: startWithSelector

@@ -89,0 +89,0 @@ }, options));

@@ -12,2 +12,3 @@ "use strict";

});
exports.SelectorsLibrary = void 0;

@@ -140,3 +141,3 @@ const attributeLibrary_1 = require("./attributeLibrary");

return arrayToRegex_1.default(ret.filter(Boolean).map(x => x.source));
return (0, arrayToRegex_1.default)(ret.filter(Boolean).map(x => x.source));
}

@@ -143,0 +144,0 @@

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k];
}
});
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", {

@@ -11,2 +24,2 @@ value: true

__export(require("./statistics"));
__exportStar(require("./statistics"), exports);

@@ -1,36 +0,5 @@

export declare const setStatistics: (statisticsMap: {
ids: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
classes: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
cssVariables: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
keyframes: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
}) => void;
export declare const getStatistics: () => {
ids: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
classes: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
cssVariables: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
keyframes: {
unused: string[];
usageCount: import("./generate").UsageCount;
};
} | null;
import generate from './generate';
declare let statistics: null | ReturnType<typeof generate>;
export declare const setStatistics: (statisticsMap: ReturnType<typeof generate>) => void;
export declare const getStatistics: () => typeof statistics;
export {};

@@ -6,8 +6,13 @@ "use strict";

});
exports.getStatistics = exports.setStatistics = void 0;
let statistics = null;
exports.setStatistics = statisticsMap => {
const setStatistics = statisticsMap => {
statistics = statisticsMap;
};
exports.getStatistics = () => statistics;
exports.setStatistics = setStatistics;
const getStatistics = () => statistics;
exports.getStatistics = getStatistics;

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

console.warn('rcs.stats is deprecated. Use rcs.statistics.generate instead');
return generate_1.default();
return (0, generate_1.default)();
};

@@ -20,0 +20,0 @@

{
"name": "rcs-core",
"version": "3.6.5",
"version": "3.7.0",
"description": "Rename css selectors across all files",

@@ -48,35 +48,35 @@ "main": "dest",

"decimal-to-any": "^1.0.5",
"espree": "^6.1.2",
"espree": "^9.0.0",
"lodash.merge": "^4.6.2",
"parse5": "^5.1.1",
"parse5": "^6.0.1",
"parse5-traverse": "^1.0.3",
"postcss": "^7.0.26",
"pug-code-gen": "^2.0.2",
"pug-lexer": "^4.1.0",
"pug-parser": "^5.0.1",
"pug-runtime": "^2.0.5",
"postcss": "^8.3.9",
"pug-code-gen": "^2.0.3",
"pug-lexer": "^5.0.1",
"pug-parser": "^6.0.0",
"pug-runtime": "^3.0.1",
"pug-source-gen": "^0.0.2",
"pug-walk": "^1.1.8",
"recast": "^0.18.5"
"pug-walk": "^2.0.0",
"recast": "^0.20.5"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@types/jest": "^25.1.2",
"@babel/cli": "^7.15.7",
"@types/jest": "^27.0.2",
"@types/lodash.merge": "^4.6.6",
"@types/node": "^13.7.1",
"@types/parse5": "^5.0.2",
"@typescript-eslint/eslint-plugin": "^2.19.2",
"@typescript-eslint/parser": "^2.19.2",
"babel-plugin-add-module-exports": "^1.0.2",
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.20.1",
"@types/node": "^16.11.1",
"@types/parse5": "^6.0.1",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"coveralls": "^3.1.1",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.25.2",
"html-minifier": "^4.0.0",
"husky": "^4.2.3",
"jest": "^25.1.0",
"lint-staged": "^10.0.7",
"husky": "^7.0.2",
"jest": "^27.3.1",
"lint-staged": "^11.2.3",
"rimraf": "^3.0.2",
"ts-jest": "^25.2.0",
"typescript": "^3.7.5"
"ts-jest": "^27.0.7",
"typescript": "^4.4.4"
},

@@ -83,0 +83,0 @@ "author": "Jan Peer Stöcklmair",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc