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

windicss

Package Overview
Dependencies
Maintainers
2
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

windicss - npm Package Compare versions

Comparing version 3.0.0-beta.13 to 3.0.0

153

cli/index.js
#!/usr/bin/env node
'use strict';
var tools_ts = require('../utils/index.js');
var path = require('path');
var index_ts = require('../lib/index.js');
var fs = require('fs');
var index_ts$1 = require('../utils/parser/index.js');
var index_ts$2 = require('../utils/style/index.js');
var index_ts$2 = require('../utils/parser/index.js');
var index_ts$1 = require('../utils/style/index.js');

@@ -211,2 +212,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

};
Console.time = function (label) {
// eslint-disable-next-line no-console
console.time(label);
};
Console.timeEnd = function (label) {
// eslint-disable-next-line no-console
console.timeEnd(label);
};
return Console;

@@ -268,6 +277,6 @@ }());

// eslint-disable-next-line quotes
return "windicss 3.0.0-beta.13"; // replace by rollup
return "windicss 3.0.0"; // replace by rollup
}
function generateTemplate(folder, outputPath) {
if (outputPath === void 0) { outputPath = 'windi.output.css'; }
if (outputPath === void 0) { outputPath = 'windi.css'; }
if (!(fs__default['default'].existsSync(folder) && fs__default['default'].lstatSync(folder).isDirectory())) {

@@ -287,4 +296,3 @@ fs__default['default'].mkdirSync(folder);

var _a, _b;
var doc = "\nGenerate css from text files that containing windi classes.\nBy default, it will use interpretation mode to generate a single css file.\n\nUsage:\n windicss [filenames]\n windicss [filenames] -c -m\n windicss [filenames] -c -s -m\n windicss [filenames] [-c | -i] [-a] [-b | -s] [-m] [-p <prefix:string>] [-o <path:string>] [--args arguments]\n\nOptions:\n -h, --help Print this help message and exit.\n -v, --version Print windicss current version and exit.\n\n -i, --interpret Interpretation mode, generate class selectors. This is the default behavior.\n -c, --compile Compilation mode, combine the class name in each row into a single class.\n -a, --attributify Attributify mode, generate attribute selectors. Attributify mode can be mixed with the other two modes.\n -t, --preflight Add preflights, default is false.\n\n -b, --combine Combine all css into one single file. This is the default behavior.\n -s, --separate Generate a separate css file for each input file.\n\n -m, --minify Generate minimized css file.\n -p, --prefix PREFIX Set the css class name prefix, only valid in compilation mode. The default prefix is 'windi-'.\n -o, --output PATH Set output css file path.\n -f, --config PATH Set config file path.\n\n --init PATH Start a new project on the path.\n";
var doc = "Generate css from text files that containing windi classes.\nBy default, it will use interpretation mode to generate a single css file.\n\nUsage:\n windicss [filenames]\n windicss [filenames] -c -m -w\n windicss [filenames] -c -s -m -w\n windicss [filenames] [-c | -i] [-a] [-b | -s] [-m] [-w] [-p <prefix:string>] [-o <path:string>] [--args arguments]\n\nOptions:\n -h, --help Print this help message and exit.\n -v, --version Print windicss current version and exit.\n\n -i, --interpret Interpretation mode, generate class selectors. This is the default behavior.\n -c, --compile Compilation mode, combine the class name in each row into a single class.\n -a, --attributify Attributify mode, generate attribute selectors. Attributify mode can be mixed with the other two modes.\n -t, --preflight Add preflights, default is false.\n\n -b, --combine Combine all css into one single file. This is the default behavior.\n -s, --separate Generate a separate css file for each input file.\n\n -m, --minify Generate minimized css file.\n -w, --watch Enable watch mode.\n -p, --prefix PREFIX Set the css class name prefix, only valid in compilation mode. The default prefix is 'windi-'.\n -o, --output PATH Set output css file path.\n -f, --config PATH Set config file path.\n\n --init PATH Start a new project on the path.\n";
var args = arg_1({

@@ -300,2 +308,3 @@ // Types

'--separate': Boolean,
'--watch': Boolean,
'--minify': Boolean,

@@ -315,2 +324,3 @@ '--init': String,

'-s': '--separate',
'-w': '--watch',
'-m': '--minify',

@@ -353,4 +363,4 @@ '-p': '--prefix',

};
for (var _i = 0, _c = args._; _i < _c.length; _i++) {
var pt = _c[_i];
for (var _i = 0, _a = args._; _i < _a.length; _i++) {
var pt = _a[_i];
_loop_1(pt);

@@ -360,9 +370,10 @@ }

var ignoredAttrs = [];
var preflights = [];
var styleSheets = [];
var preflights = {};
var styleSheets = {};
var processor = new index_ts.Processor(args['--config'] ? require(path.resolve(args['--config'])) : undefined);
if (args['--compile']) {
function compile(files) {
var _a;
// compilation mode
var prefix_1 = (_a = args['--prefix']) !== null && _a !== void 0 ? _a : 'windi-';
matchFiles.forEach(function (file) {
var prefix = (_a = args['--prefix']) !== null && _a !== void 0 ? _a : 'windi-';
files.forEach(function (file) {
var indexStart = 0;

@@ -372,7 +383,7 @@ var outputStyle = [];

var html = fs.readFileSync(file).toString();
var parser = new index_ts$1.HTMLParser(html);
var parser = new index_ts$2.HTMLParser(html);
// Match ClassName then replace with new ClassName
parser.parseClasses().forEach(function (p) {
outputHTML.push(html.substring(indexStart, p.start));
var utility = processor.compile(p.result, prefix_1, true); // Set third argument to false to hide comments;
var utility = processor.compile(p.result, prefix, true); // Set third argument to false to hide comments;
outputStyle.push(utility.styleSheet);

@@ -384,5 +395,5 @@ ignoredClasses = __spreadArray(__spreadArray([], ignoredClasses), utility.ignored);

outputHTML.push(html.substring(indexStart));
styleSheets.push(outputStyle.reduce(function (previousValue, currentValue) {
styleSheets[file] = (outputStyle.reduce(function (previousValue, currentValue) {
return previousValue.extend(currentValue);
}, new index_ts$2.StyleSheet()));
}, new index_ts$1.StyleSheet()));
var outputFile = file.replace(/(?=\.\w+$)/, '.windi');

@@ -392,9 +403,9 @@ fs.writeFileSync(outputFile, outputHTML.join(''));

if (args['--preflight'])
preflights.push(processor.preflight(parser.html));
preflights[file] = processor.preflight(parser.html);
});
}
else {
function interpret(files) {
// interpretation mode
matchFiles.forEach(function (file) {
var parser = new index_ts$1.HTMLParser(fs.readFileSync(file).toString());
files.forEach(function (file) {
var parser = new index_ts$2.HTMLParser(fs.readFileSync(file).toString());
var utility = processor.interpret(parser

@@ -404,12 +415,12 @@ .parseClasses()

.join(' '));
styleSheets.push(utility.styleSheet);
styleSheets[file] = utility.styleSheet;
ignoredClasses = __spreadArray(__spreadArray([], ignoredClasses), utility.ignored);
if (args['--preflight'])
preflights.push(processor.preflight(parser.html));
preflights[file] = processor.preflight(parser.html);
});
}
if (args['--attributify']) {
function attributify(files) {
// attributify mode
matchFiles.forEach(function (file) {
var parser = new index_ts$1.HTMLParser(fs.readFileSync(file).toString());
files.forEach(function (file) {
var parser = new index_ts$2.HTMLParser(fs.readFileSync(file).toString());
var attrs = parser

@@ -419,2 +430,4 @@ .parseAttrs()

var _a;
if (b.key === 'class' || b.key === 'className')
return a;
if (b.key in a) {

@@ -429,37 +442,67 @@ a[b.key] = Array.isArray(a[b.key])

var utility = processor.attributify(attrs);
styleSheets.push(utility.styleSheet);
styleSheets[file] = utility.styleSheet;
ignoredAttrs = __spreadArray(__spreadArray([], ignoredAttrs), utility.ignored);
});
}
if (args['--separate']) {
styleSheets.forEach(function (style, index) {
var filePath = matchFiles[index].replace(/\.\w+$/, '.windi.css');
if (args['--preflight'])
style = preflights[index].extend(style);
fs.writeFileSync(filePath, style.build(args['--minify']));
Console.log(matchFiles[index] + " -> " + filePath);
});
}
else {
var outputStyle = styleSheets
.reduce(function (previousValue, currentValue) {
return previousValue.extend(currentValue);
}, new index_ts$2.StyleSheet())
.sort()
.combine();
if (args['--preflight'])
outputStyle = preflights
function build(files, update) {
var _a;
if (update === void 0) { update = false; }
if (args['--compile']) {
compile(files);
}
else {
interpret(files);
}
if (args['--attributify']) {
attributify(files);
}
if (args['--separate']) {
for (var _i = 0, _b = Object.entries(styleSheets); _i < _b.length; _i++) {
var _c = _b[_i], file = _c[0], sheet = _c[1];
var outfile = file.replace(/\.\w+$/, '.windi.css');
fs.writeFileSync(outfile, (args['--preflight'] ? tools_ts.deepCopy(sheet).extend(preflights[file], false) : sheet).build(args['--minify']));
Console.log(file + " -> " + outfile);
}
}
else {
var outputStyle = Object.values(styleSheets)
.reduce(function (previousValue, currentValue) {
return previousValue.extend(currentValue);
}, new index_ts$2.StyleSheet())
}, new index_ts$1.StyleSheet())
.sort()
.combine()
.extend(outputStyle);
var filePath = (_b = args['--output']) !== null && _b !== void 0 ? _b : 'windi.output.css';
fs.writeFileSync(filePath, outputStyle.build(args['--minify']));
Console.log('matched files:', matchFiles);
Console.log('output file:', filePath);
.combine();
if (args['--preflight'])
outputStyle = Object.values(preflights)
.reduce(function (previousValue, currentValue) {
return previousValue.extend(currentValue);
}, new index_ts$1.StyleSheet())
.sort()
.combine()
.extend(outputStyle);
var filePath = (_a = args['--output']) !== null && _a !== void 0 ? _a : 'windi.css';
fs.writeFileSync(filePath, outputStyle.build(args['--minify']));
if (!update) {
Console.log('matched files:', matchFiles);
Console.log('output file:', filePath);
}
}
if (!update) {
Console.log('ignored classes:', ignoredClasses);
if (args['--attributify'])
Console.log('ignored attrs:', ignoredAttrs.slice(0, 5), "... " + (ignoredAttrs.length - 5) + " more items");
}
}
Console.log('ignored classes:', ignoredClasses);
if (args['--attributify'])
Console.log('ignored attrs:', ignoredAttrs);
build(matchFiles);
if (args['--watch']) {
for (var _b = 0, matchFiles_1 = matchFiles; _b < matchFiles_1.length; _b++) {
var file = matchFiles_1[_b];
fs.watch(file, function (event, path) {
if (event === 'change') {
Console.log('File', path, 'has been changed');
Console.time('Building');
build([path], true);
Console.timeEnd('Building');
}
});
}
}
{
"name": "windicss",
"version": "3.0.0-beta.13",
"version": "3.0.0",
"description": "Next generation utility-first CSS framework.",

@@ -5,0 +5,0 @@ "main": "index.js",

export declare class Console {
static log(...message: unknown[]): void;
static error(...message: unknown[]): void;
static time(label?: string): void;
static timeEnd(label?: string): void;
}

@@ -5,0 +7,0 @@ export declare function isFile(path: string): boolean;

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