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

@windicss/plugin-utils

Package Overview
Dependencies
Maintainers
2
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@windicss/plugin-utils - npm Package Compare versions

Comparing version 0.14.6 to 0.15.1

18

dist/index.d.ts
import * as windicss_types_interfaces from 'windicss/types/interfaces';
import { FullConfig, Extractor, ExtractorResultDetailed } from 'windicss/types/interfaces';
export { FullConfig as WindiCssOptions } from 'windicss/types/interfaces';
import { StyleSheet } from 'windicss/utils/style';
import { generateCompletions } from 'windicss/utils';

@@ -276,2 +275,7 @@ import Processor from 'windicss';

declare type LayerName = 'base' | 'utilities' | 'components';
declare const SupportedLayers: readonly ["base", "utilities", "components"];
interface LayerMeta {
cssCache?: string;
timestamp?: number;
}
declare function createUtils(userOptions?: UserOptions | ResolvedOptions, utilsOptions?: WindiPluginUtilsOptions): {

@@ -285,3 +289,5 @@ init: () => Promise<Processor>;

clearCache: (clearAll?: boolean) => void;
transformCSS: (css: string) => string;
transformCSS: (css: string, id: string, transformOptions?: {
onLayerUpdated?: (() => void) | undefined;
} | undefined) => string;
transformGroups: typeof transformGroups;

@@ -300,7 +306,3 @@ transformGroupsWithSourcemap: typeof transformGroupsWithSourcemap;

tagsAvailable: Set<string>;
layersMeta: Record<LayerName, {
style: StyleSheet;
cssCache?: string | undefined;
timestamp?: number | undefined;
}>;
layersMeta: Record<LayerName, LayerMeta>;
addClasses: (classes: string[]) => boolean;

@@ -346,2 +348,2 @@ addTags: (tags: string[]) => boolean;

export { Arrayable, CompletionsResult, DefaultExtractor, LayerName, LoadConfigurationOptions, NestedArrayable, PugExtractor, ResolvedOptions, TagNames, Transformer, TransformerFunction, TransformerOptions, UserOptions, WindiPluginUtils, WindiPluginUtilsOptions, applyExtractors, configureFiles, createUtils, defaultAlias, defineConfig, exclude, flattenArray, getDefaultExtractors, htmlTags, include, isResolvedOptions, kebabCase, loadConfiguration, mergeArrays, partition, preflightTags, resolveOptions, slash, toArray, transformGroups, transformGroupsWithSourcemap };
export { Arrayable, CompletionsResult, DefaultExtractor, LayerMeta, LayerName, LoadConfigurationOptions, NestedArrayable, PugExtractor, ResolvedOptions, SupportedLayers, TagNames, Transformer, TransformerFunction, TransformerOptions, UserOptions, WindiPluginUtils, WindiPluginUtilsOptions, applyExtractors, configureFiles, createUtils, defaultAlias, defineConfig, exclude, flattenArray, getDefaultExtractors, htmlTags, include, isResolvedOptions, kebabCase, loadConfiguration, mergeArrays, partition, preflightTags, resolveOptions, slash, toArray, transformGroups, transformGroupsWithSourcemap };

@@ -6,3 +6,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;

var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
var __assign = (a, b) => {
var __objSpread = (a, b) => {
for (var prop in b || (b = {}))

@@ -270,3 +270,3 @@ if (__hasOwnProp.call(b, prop))

return _pirates.addHook.call(void 0, (code, filePath) => {
const {code: transformedCode, sourceMap} = _sucrase.transform.call(void 0, code, __assign(__assign({}, options), {
const {code: transformedCode, sourceMap} = _sucrase.transform.call(void 0, code, __objSpread(__objSpread({}, options), {
sourceMapOptions: {compiledFilename: filePath},

@@ -279,3 +279,3 @@ filePath

${suffix}`;
}, __assign(__assign({}, hookOptions), {exts: extension}));
}, __objSpread(__objSpread({}, hookOptions), {exts: extension}));
}

@@ -388,3 +388,3 @@ function registerJS(hookOptions) {

const debugOptions = _debug4.default.call(void 0, `${name}:options`);
let {resolved: config, configFilePath} = loadConfigFile ? await loadConfiguration(__assign(__assign({}, utilsOptions), {
let {resolved: config, configFilePath} = loadConfigFile ? await loadConfiguration(__objSpread(__objSpread({}, utilsOptions), {
root: utilsOptions.root || options.root,

@@ -416,3 +416,3 @@ config: options.config

const scanOptions = Object.assign({
fileExtensions: ["html", "vue", "md", "mdx", "pug", "jsx", "tsx", "svelte", "ts", "js"],
fileExtensions: ["html", "vue", "md", "mdx", "pug", "jsx", "tsx", "svelte", "ts", "js", "css", "postcss"],
dirs: ["src"],

@@ -425,3 +425,3 @@ exclude: [],

}, typeof scan === "boolean" ? {} : scan);
scanOptions.exclude = mergeArrays((_b = config.extract) == null ? void 0 : _b.exclude, scanOptions.exclude, ((_c = config.extract) == null ? void 0 : _c.exclude) ? [] : ["node_modules/**/*", ".git/**/*"]).map((i) => slash(_path.resolve.call(void 0, root, i)));
scanOptions.exclude = mergeArrays((_b = config.extract) == null ? void 0 : _b.exclude, scanOptions.exclude, ((_c = config.extract) == null ? void 0 : _c.exclude) ? [] : ["node_modules", ".git"]).map((i) => slash(_path.resolve.call(void 0, root, i)));
scanOptions.include = mergeArrays((_d = config.extract) == null ? void 0 : _d.include, scanOptions.include, ((_e = config.extract) == null ? void 0 : _e.include) ? [] : buildGlobs(scanOptions.dirs, scanOptions.fileExtensions)).map((i) => slash(_path.resolve.call(void 0, root, i)));

@@ -440,4 +440,4 @@ scanOptions.extractors = mergeArrays(getDefaultExtractors(), (_f = config.extract) == null ? void 0 : _f.extractors);

preflightOptions.blocklist = new Set(mergeArrays(configPreflightOptions == null ? void 0 : configPreflightOptions.blocklist, Array.from(preflightOptions.blocklist)).flatMap((i) => i.split(" ")));
preflightOptions.alias = Object.fromEntries(Object.entries(__assign(__assign(__assign({}, defaultAlias), configPreflightOptions.alias), preflightOptions.alias)).filter(([k, v]) => [kebabCase(k), v]));
let resolvedOptions = __assign(__assign({}, options), {
preflightOptions.alias = Object.fromEntries(Object.entries(__objSpread(__objSpread(__objSpread({}, defaultAlias), configPreflightOptions.alias), preflightOptions.alias)).filter(([k, v]) => [kebabCase(k), v]));
let resolvedOptions = __objSpread(__objSpread({}, options), {
root,

@@ -502,3 +502,3 @@ config,

const _import = new Function("modulePath", "return import(modulePath)");
if (true)
if (typeof require !== "undefined")
delete require.cache[require.resolve(configFilePath)];

@@ -535,2 +535,3 @@ resolved = ((_a = await _import(_url.pathToFileURL.call(void 0, configFilePath))) == null ? void 0 : _a.default) || {};

// src/createUtils.ts
var SupportedLayers = ["base", "utilities", "components"];
function createUtils(userOptions = {}, utilsOptions = {

@@ -545,6 +546,8 @@ name: "windicss-plugin-utils"

compile: _debug4.default.call(void 0, `${name}:compile`),
glob: _debug4.default.call(void 0, `${name}:scan:glob`),
scan: _debug4.default.call(void 0, `${name}:scan`),
scanGlob: _debug4.default.call(void 0, `${name}:scan:glob`),
scanTransform: _debug4.default.call(void 0, `${name}:scan:transform`),
detectClass: _debug4.default.call(void 0, `${name}:detect:class`),
detectTag: _debug4.default.call(void 0, `${name}:detect:tag`)
detectTag: _debug4.default.call(void 0, `${name}:detect:tag`),
compileLayer: _debug4.default.call(void 0, `${name}:compile:layer`)
};

@@ -567,4 +570,4 @@ let processor;

await ensureInit();
debug.glob("include", options.scanOptions.include);
debug.glob("exclude", options.scanOptions.exclude);
debug.scanGlob("include", options.scanOptions.include);
debug.scanGlob("exclude", options.scanOptions.exclude);
const files2 = await _fastglob2.default.call(void 0, options.scanOptions.include, {

@@ -577,3 +580,3 @@ cwd: options.root,

files2.sort();
debug.glob("files", files2);
debug.scanGlob("files", files2);
return files2;

@@ -587,6 +590,13 @@ }

_searching = (async () => {
debug.scan("started");
files.push(...await getFiles());
const contents = await Promise.all(files.filter((id) => isDetectTarget(id)).map(async (id) => [await _fs.promises.readFile(id, "utf-8"), id]));
await Promise.all(contents.map(([content, id]) => extractFile(content, id, true)));
await Promise.all(contents.map(async ([content, id]) => {
if (isCssTransformTarget(id))
return transformCSS(content, id);
else
return extractFile(content, id, true);
}));
scanned = true;
debug.scan("finished");
})();

@@ -669,38 +679,44 @@ }

}
function transformCSS(css) {
function transformCSS(css, id, transformOptions) {
var _a;
if (!options.transformCSS)
return css;
const style = new (0, _parser.CSSParser)(css, processor).parse();
const [layerBlocks, blocks] = partition(style.children, (i) => i.meta.group === "layer-block");
const [layerBlocks, blocks] = partition(style.children, (i) => i.meta.group === "layer-block" && SupportedLayers.includes(i.meta.type));
if (layerBlocks.length) {
updateLayers(layerBlocks);
updateLayers(layerBlocks, id);
style.children = blocks;
}
return style.build();
const transformed = style.build();
if (layerBlocks.length)
(_a = transformOptions == null ? void 0 : transformOptions.onLayerUpdated) == null ? void 0 : _a.call(transformOptions);
return transformed;
}
const layers = {
base: {
style: new (0, _style.StyleSheet)()
},
utilities: {
style: new (0, _style.StyleSheet)()
},
components: {
style: new (0, _style.StyleSheet)()
}
base: {},
utilities: {},
components: {}
};
function updateLayers(styles) {
const layerStylesMap = new Map();
function updateLayers(styles, filepath) {
const timestamp = +Date.now();
debug.compileLayer("update", filepath);
layerStylesMap.set(filepath, styles);
for (const s of styles) {
layers[s.meta.type].style.children.push(s);
layers[s.meta.type].timestamp = timestamp;
layers[s.meta.type].cssCache = void 0;
const layer = layers[s.meta.type];
layer.timestamp = timestamp;
layer.cssCache = void 0;
}
}
function buildLayerCss(name2) {
var _a;
const layer = layers[name2];
if (layer.cssCache == null) {
const style = new (0, _style.StyleSheet)(Array.from(layerStylesMap.values()).flatMap((i) => i).filter((i) => i.meta.type === name2));
style.prefixer = (_a = options.config.prefixer) != null ? _a : true;
debug.compileLayer(name2, style.children.length);
if (options.sortUtilities)
layer.style.sort();
layer.cssCache = layer.style.build();
style.sort();
layer.cssCache = `/* windicss layer ${name2} */
${style.build()}`;
}

@@ -720,3 +736,3 @@ return layer.cssCache;

debug.compile(result.success);
updateLayers(result.styleSheet.children);
updateLayers(result.styleSheet.children, "__classes");
include(classesGenerated, result.success);

@@ -729,3 +745,3 @@ classesPending.clear();

const preflightStyle = processor.preflight(options.preflightOptions.includeAll ? void 0 : Array.from(tagsPending).map((i) => `<${i}/>`).join(" "), options.preflightOptions.includeBase, options.preflightOptions.includeGlobal, options.preflightOptions.includePlugin);
updateLayers(preflightStyle.children);
updateLayers(preflightStyle.children, "__preflights");
include(tagsGenerated, tagsPending);

@@ -752,9 +768,5 @@ tagsPending.clear();

function clearCache(clearAll = false) {
var _a, _b, _c;
layers.base = {style: new (0, _style.StyleSheet)()};
layers.utilities = {style: new (0, _style.StyleSheet)()};
layers.components = {style: new (0, _style.StyleSheet)()};
layers.base.style.prefixer = (_a = options.config.prefixer) != null ? _a : true;
layers.utilities.style.prefixer = (_b = options.config.prefixer) != null ? _b : true;
layers.components.style.prefixer = (_c = options.config.prefixer) != null ? _c : true;
layers.base = {};
layers.utilities = {};
layers.components = {};
completions = void 0;

@@ -877,2 +889,3 @@ if (clearAll) {

exports.DefaultExtractor = DefaultExtractor; exports.PugExtractor = PugExtractor; exports.applyExtractors = applyExtractors; exports.configureFiles = configureFiles; exports.createUtils = createUtils; exports.defaultAlias = defaultAlias; exports.defineConfig = defineConfig; exports.exclude = exclude; exports.flattenArray = flattenArray; exports.getDefaultExtractors = getDefaultExtractors; exports.htmlTags = htmlTags; exports.include = include; exports.isResolvedOptions = isResolvedOptions; exports.kebabCase = kebabCase; exports.loadConfiguration = loadConfiguration; exports.mergeArrays = mergeArrays; exports.partition = partition; exports.preflightTags = preflightTags; exports.resolveOptions = resolveOptions; exports.slash = slash; exports.toArray = toArray; exports.transformGroups = transformGroups; exports.transformGroupsWithSourcemap = transformGroupsWithSourcemap;
exports.DefaultExtractor = DefaultExtractor; exports.PugExtractor = PugExtractor; exports.SupportedLayers = SupportedLayers; exports.applyExtractors = applyExtractors; exports.configureFiles = configureFiles; exports.createUtils = createUtils; exports.defaultAlias = defaultAlias; exports.defineConfig = defineConfig; exports.exclude = exclude; exports.flattenArray = flattenArray; exports.getDefaultExtractors = getDefaultExtractors; exports.htmlTags = htmlTags; exports.include = include; exports.isResolvedOptions = isResolvedOptions; exports.kebabCase = kebabCase; exports.loadConfiguration = loadConfiguration; exports.mergeArrays = mergeArrays; exports.partition = partition; exports.preflightTags = preflightTags; exports.resolveOptions = resolveOptions; exports.slash = slash; exports.toArray = toArray; exports.transformGroups = transformGroups; exports.transformGroupsWithSourcemap = transformGroupsWithSourcemap;
{
"name": "@windicss/plugin-utils",
"description": "Common utils for building integrations of Windi CSS",
"version": "0.14.6",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"author": "antfu <anthonyfu117@hotmail.com>",
"repository": {
"type": "git",
"url": "https://github.com/antfu/vite-plugin-windicss"
},
"homepage": "https://github.com/antfu/vite-plugin-windicss",
"bugs": "https://github.com/antfu/vite-plugin-windicss/issues",
"files": [
"dist"
],
"keywords": [
"windicss",
"tailwindcss"
],
"scripts": {
"dev": "npm run build -- --watch",
"build": "tsup src/index.ts --dts --format cjs,esm --external sucrase/register/ts,pug,windicss/utils/style,windicss/utils/parser,windicss/utils",
"prepublishOnly": "npm run build"
},
"dependencies": {
"debug": "^4.3.2",
"fast-glob": "^3.2.5",
"magic-string": "^0.25.7",
"micromatch": "^4.0.4",
"pirates": "^4.0.1",
"sucrase": "^3.17.1",
"windicss": "^2.5.14"
},
"devDependencies": {
"@antfu/ni": "^0.5.7",
"@types/debug": "^4.1.5",
"@types/micromatch": "^4.0.1",
"@types/node": "^14.14.37",
"@types/pug": "^2.0.4",
"pug": "^3.0.2",
"tsup": "^4.8.21",
"typescript": "^4.2.4"
}
"name": "@windicss/plugin-utils",
"version": "0.15.1",
"description": "Common utils for building integrations of Windi CSS",
"keywords": [
"windicss",
"tailwindcss"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/antfu/vite-plugin-windicss"
},
"funding": "https://github.com/sponsors/antfu",
"author": "antfu <anthonyfu117@hotmail.com>",
"files": [
"dist"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"homepage": "https://github.com/antfu/vite-plugin-windicss",
"bugs": "https://github.com/antfu/vite-plugin-windicss/issues",
"dependencies": {
"debug": "^4.3.2",
"fast-glob": "^3.2.5",
"magic-string": "^0.25.7",
"micromatch": "^4.0.4",
"pirates": "^4.0.1",
"sucrase": "^3.18.1",
"windicss": "^2.5.14"
},
"devDependencies": {
"@antfu/ni": "^0.5.8",
"@types/debug": "^4.1.5",
"@types/micromatch": "^4.0.1",
"@types/node": "^14.14.41",
"@types/pug": "^2.0.4",
"pug": "^3.0.2",
"tsup": "^4.9.1",
"typescript": "^4.2.4"
},
"scripts": {
"dev": "npm run build -- --watch",
"build": "tsup src/index.ts --dts --format cjs,esm --external sucrase/register/ts,pug,windicss/utils/style,windicss/utils/parser,windicss/utils"
}
}

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