You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

lightningcss

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightningcss - npm Package Compare versions

Comparing version
1.31.1
to
1.32.0
+11
-3
node/composeVisitors.js
// @ts-check
/** @typedef {import('./index').Visitor} Visitor */
/** @typedef {import('./index').VisitorFunction} VisitorFunction */
/**
* Composes multiple visitor objects into a single one.
* @param {Visitor[]} visitors
* @return {Visitor}
* @param {(Visitor | VisitorFunction)[]} visitors
* @return {Visitor | VisitorFunction}
*/

@@ -13,2 +14,9 @@ function composeVisitors(visitors) {

}
if (visitors.some(v => typeof v === 'function')) {
return (opts) => {
let v = visitors.map(v => typeof v === 'function' ? v(opts) : v);
return composeVisitors(v);
};
}

@@ -370,3 +378,3 @@ /** @type Visitor */

// it before (to avoid cycles). This way, visitors can be composed in any order.
for (let v = 0; v < visitors.length;) {
for (let v = 0; v < visitors.length && i < arr.length;) {
if (seen.get(v)) {

@@ -373,0 +381,0 @@ v++;

@@ -66,3 +66,3 @@ import type { Angle, CssColor, Rule, CustomProperty, EnvironmentVariable, Function, Image, LengthValue, MediaQuery, Declaration, Ratio, Resolution, Selector, SupportsCondition, Time, Token, TokenOrValue, UnknownAtRule, Url, Variable, StyleRule, DeclarationBlock, ParsedComponent, Multiplier, StyleSheet, Location2 } from './ast';

*/
visitor?: Visitor<C>,
visitor?: Visitor<C> | VisitorFunction<C>,
/**

@@ -217,2 +217,9 @@ * Defines how to parse custom CSS at-rules. Each at-rule can have a prelude, defined using a CSS

export type VisitorDependency = FileDependency | GlobDependency;
export interface VisitorOptions {
addDependency: (dep: VisitorDependency) => void
}
export type VisitorFunction<C extends CustomAtRules> = (options: VisitorOptions) => Visitor<C>;
export interface CustomAtRules {

@@ -363,3 +370,3 @@ [name: string]: CustomAtRuleDefinition

export type Dependency = ImportDependency | UrlDependency;
export type Dependency = ImportDependency | UrlDependency | FileDependency | GlobDependency;

@@ -390,2 +397,12 @@ export interface ImportDependency {

export interface FileDependency {
type: 'file',
filePath: string
}
export interface GlobDependency {
type: 'glob',
glob: string
}
export interface SourceLocation {

@@ -445,3 +462,3 @@ /** The file path in which the dependency exists. */

*/
visitor?: Visitor<never>
visitor?: Visitor<never> | VisitorFunction<never>
}

@@ -482,2 +499,2 @@

*/
export declare function composeVisitors<C extends CustomAtRules>(visitors: Visitor<C>[]): Visitor<C>;
export declare function composeVisitors<C extends CustomAtRules>(visitors: (Visitor<C> | VisitorFunction<C>)[]): Visitor<C> | VisitorFunction<C>;

@@ -16,14 +16,45 @@ let parts = [process.platform, process.arch];

if (process.env.CSS_TRANSFORMER_WASM) {
module.exports = require(`../pkg`);
} else {
try {
module.exports = require(`lightningcss-${parts.join('-')}`);
} catch (err) {
module.exports = require(`../lightningcss.${parts.join('-')}.node`);
}
let native;
try {
native = require(`lightningcss-${parts.join('-')}`);
} catch (err) {
native = require(`../lightningcss.${parts.join('-')}.node`);
}
module.exports.transform = wrap(native.transform);
module.exports.transformStyleAttribute = wrap(native.transformStyleAttribute);
module.exports.bundle = wrap(native.bundle);
module.exports.bundleAsync = wrap(native.bundleAsync);
module.exports.browserslistToTargets = require('./browserslistToTargets');
module.exports.composeVisitors = require('./composeVisitors');
module.exports.Features = require('./flags').Features;
function wrap(call) {
return (options) => {
if (typeof options.visitor === 'function') {
let deps = [];
options.visitor = options.visitor({
addDependency(dep) {
deps.push(dep);
}
});
let result = call(options);
if (result instanceof Promise) {
result = result.then(res => {
if (deps.length) {
res.dependencies ??= [];
res.dependencies.push(...deps);
}
return res;
});
} else if (deps.length) {
result.dependencies ??= [];
result.dependencies.push(...deps);
}
return result;
} else {
return call(options);
}
};
}
{
"name": "lightningcss",
"version": "1.31.1",
"version": "1.32.0",
"license": "MPL-2.0",

@@ -51,6 +51,6 @@ "description": "A CSS parser, transformer, and minifier written in Rust",

"@codemirror/theme-one-dark": "^6.1.0",
"@mdn/browser-compat-data": "~7.2.4",
"@mdn/browser-compat-data": "~7.3.6",
"@napi-rs/cli": "^2.14.0",
"autoprefixer": "^10.4.23",
"caniuse-lite": "^1.0.30001765",
"autoprefixer": "^10.4.27",
"caniuse-lite": "^1.0.30001777",
"codemirror": "^6.0.1",

@@ -99,14 +99,14 @@ "cssnano": "^7.0.6",

"optionalDependencies": {
"lightningcss-darwin-x64": "1.31.1",
"lightningcss-linux-x64-gnu": "1.31.1",
"lightningcss-win32-x64-msvc": "1.31.1",
"lightningcss-win32-arm64-msvc": "1.31.1",
"lightningcss-darwin-arm64": "1.31.1",
"lightningcss-linux-arm64-gnu": "1.31.1",
"lightningcss-linux-arm-gnueabihf": "1.31.1",
"lightningcss-linux-arm64-musl": "1.31.1",
"lightningcss-linux-x64-musl": "1.31.1",
"lightningcss-freebsd-x64": "1.31.1",
"lightningcss-android-arm64": "1.31.1"
"lightningcss-darwin-x64": "1.32.0",
"lightningcss-linux-x64-gnu": "1.32.0",
"lightningcss-win32-x64-msvc": "1.32.0",
"lightningcss-win32-arm64-msvc": "1.32.0",
"lightningcss-darwin-arm64": "1.32.0",
"lightningcss-linux-arm64-gnu": "1.32.0",
"lightningcss-linux-arm-gnueabihf": "1.32.0",
"lightningcss-linux-arm64-musl": "1.32.0",
"lightningcss-linux-x64-musl": "1.32.0",
"lightningcss-freebsd-x64": "1.32.0",
"lightningcss-android-arm64": "1.32.0"
}
}

Sorry, the diff of this file is not supported yet