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

@stylable/core

Package Overview
Dependencies
Maintainers
6
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylable/core - npm Package Compare versions

Comparing version 5.18.1 to 5.19.0

18

dist/features/css-custom-property.d.ts
import type { ImportSymbol } from './st-import';
import type { Stylable } from '../stylable';
import type { StylableMeta } from '../stylable-meta';
import type { StylableResolver, CSSResolve } from '../stylable-resolver';
import { type StylableResolver, type CSSResolve } from '../stylable-resolver';
import type * as postcss from 'postcss';
export interface CSSVarSymbol {

@@ -71,2 +73,16 @@ _kind: 'cssVar';

export declare function get(meta: StylableMeta, name: string): CSSVarSymbol | undefined;
export declare class StylablePublicApi {
private stylable;
constructor(stylable: Stylable);
getProperties(meta: StylableMeta): Record<string, {
meta: StylableMeta;
localName: string;
targetName: string;
source: {
meta: StylableMeta;
start: postcss.Position;
end: postcss.Position;
};
}>;
}
export declare function getRuntimeTypedDefinitionNames(meta: StylableMeta): string[];

@@ -73,0 +89,0 @@ export declare function getTransformedName({ symbol, meta }: CSSResolve<CSSVarSymbol>): string;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.scopeCSSVar = exports.getTransformedName = exports.getRuntimeTypedDefinitionNames = exports.get = exports.hooks = exports.diagnostics = void 0;
exports.scopeCSSVar = exports.getTransformedName = exports.getRuntimeTypedDefinitionNames = exports.StylablePublicApi = exports.get = exports.hooks = exports.diagnostics = void 0;
const feature_1 = require("./feature");

@@ -38,2 +38,3 @@ const STSymbol = __importStar(require("./st-symbol"));

const diagnostics_1 = require("../diagnostics");
const stylable_resolver_1 = require("../stylable-resolver");
// ToDo: refactor out - parse once and pass to hooks

@@ -231,2 +232,33 @@ const postcss_value_parser_1 = __importDefault(require("postcss-value-parser"));

}
const UNKNOWN_LOCATION = Object.freeze({
offset: -1,
line: -1,
column: -1,
});
class StylablePublicApi {
constructor(stylable) {
this.stylable = stylable;
}
getProperties(meta) {
const results = {};
const topLevelDiagnostics = new diagnostics_1.Diagnostics();
const getResolvedSymbols = (0, stylable_resolver_1.createSymbolResolverWithCache)(this.stylable.resolver, topLevelDiagnostics);
const { cssVar } = getResolvedSymbols(meta);
for (const [name, symbol] of Object.entries(cssVar)) {
const defAst = STSymbol.getSymbolAstNode(symbol.meta, symbol.symbol);
results[name] = {
meta: symbol.meta,
localName: symbol.symbol.name,
targetName: getTransformedName(symbol),
source: {
meta: symbol.meta,
start: defAst?.source?.start || UNKNOWN_LOCATION,
end: defAst?.source?.end || UNKNOWN_LOCATION,
},
};
}
return results;
}
}
exports.StylablePublicApi = StylablePublicApi;
function analyzeDeclValueVarCalls(context, decl) {

@@ -233,0 +265,0 @@ const parsed = (0, postcss_value_parser_1.default)(decl.value);

@@ -56,2 +56,3 @@ import { FeatureContext } from './feature';

};
symbolToAst: WeakMap<StylableSymbol, postcss.Node>;
}

@@ -86,4 +87,5 @@ export declare const diagnostics: {

}): StylableSymbol | undefined;
export declare function getSymbolAstNode(meta: StylableMeta, symbol: StylableSymbol): postcss.Node | undefined;
export declare function reportRedeclare(context: FeatureContext): void;
export {};
//# sourceMappingURL=st-symbol.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.reportRedeclare = exports.addSymbol = exports.getAllByType = exports.getAll = exports.get = exports.hooks = exports.diagnostics = exports.readableTypeMap = void 0;
exports.reportRedeclare = exports.getSymbolAstNode = exports.addSymbol = exports.getAllByType = exports.getAll = exports.get = exports.hooks = exports.diagnostics = exports.readableTypeMap = void 0;
const feature_1 = require("./feature");

@@ -53,2 +53,3 @@ const plugable_record_1 = require("../helpers/plugable-record");

},
symbolToAst: new WeakMap(),
};

@@ -84,3 +85,3 @@ }

function addSymbol({ context, symbol, node, safeRedeclare = false, localName, }) {
const { byNS, byNSFlat, byType } = plugable_record_1.plugableRecord.getUnsafe(context.meta.data, dataKey);
const { byNS, byNSFlat, byType, symbolToAst } = plugable_record_1.plugableRecord.getUnsafe(context.meta.data, dataKey);
const name = localName || symbol.name;

@@ -99,5 +100,11 @@ const typeTable = byType[symbol._kind];

typeTable[name] = symbol;
node && symbolToAst.set(symbol, node);
return symbol;
}
exports.addSymbol = addSymbol;
function getSymbolAstNode(meta, symbol) {
const { symbolToAst } = plugable_record_1.plugableRecord.getUnsafe(meta.data, dataKey);
return symbolToAst.get(symbol);
}
exports.getSymbolAstNode = getSymbolAstNode;
function reportRedeclare(context) {

@@ -104,0 +111,0 @@ const { byNS } = plugable_record_1.plugableRecord.getUnsafe(context.meta.data, dataKey);

@@ -23,2 +23,7 @@ import { FeatureTransformContext } from './feature';

input: CustomValueInput;
source: {
meta: StylableMeta;
start: postcss.Position;
end: postcss.Position;
};
}

@@ -28,2 +33,3 @@ export interface FlatComputedStVar {

path: string[];
source: ComputedStVar['source'];
}

@@ -30,0 +36,0 @@ export declare const diagnostics: {

@@ -151,2 +151,7 @@ "use strict";

// Stylable StVar Public APIs
const UNKNOWN_LOCATION = Object.freeze({
offset: -1,
line: -1,
column: -1,
});
class StylablePublicApi {

@@ -178,2 +183,7 @@ constructor(stylable) {

diagnostics,
source: {
meta: resolvedVar.meta,
start: resolvedVar.symbol.node.source?.start || UNKNOWN_LOCATION,
end: resolvedVar.symbol.node.source?.end || UNKNOWN_LOCATION,
},
};

@@ -188,7 +198,7 @@ computed[localName] = computedStVar;

for (const [symbol, stVar] of Object.entries(computed)) {
flatStVars.push(...this.flatSingle(stVar.input, [symbol]));
flatStVars.push(...this.flatSingle(stVar.input, [symbol], stVar.source));
}
return flatStVars;
}
flatSingle(input, path) {
flatSingle(input, path, source) {
const currentVars = [];

@@ -199,2 +209,3 @@ if (input.flatValue) {

path,
source,
});

@@ -204,3 +215,3 @@ }

for (const [key, innerInput] of Object.entries(input.value)) {
currentVars.push(...this.flatSingle(typeof innerInput === 'string' ? (0, custom_values_1.boxString)(innerInput) : innerInput, [...path, key]));
currentVars.push(...this.flatSingle(typeof innerInput === 'string' ? (0, custom_values_1.boxString)(innerInput) : innerInput, [...path, key], source));
}

@@ -207,0 +218,0 @@ }

2

dist/helpers/custom-state.js

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

const { errors } = validateStateArgument(stateParam, meta, stateParam.defaultValue || '', resolver, diagnostics, selectorNode, true, !!stateParam.defaultValue);
if (errors) {
if (errors && selectorNode.nodes) {
for (const node of selectorNode.nodes) {

@@ -472,0 +472,0 @@ if (node.type === 'decl' && node.prop === `-st-states`) {

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

const mixinRoot = mixinTarget ? mixinTarget : postcss.root();
root.nodes.forEach((node) => {
root.nodes?.forEach((node) => {
if (node.type === 'decl') {

@@ -60,0 +60,0 @@ mixinTarget?.append(node.clone());

@@ -9,3 +9,3 @@ import type { CacheItem, FileProcessor, MinimalFS } from './cached-process-file';

import type { IStylableOptimizer, ModuleResolver } from './types';
import { STImport, STScope, STVar, STMixin, CSSClass } from './features';
import { STImport, STScope, STVar, STMixin, CSSClass, CSSCustomProperty } from './features';
import { Dependency } from './visit-meta-css-dependencies';

@@ -44,2 +44,3 @@ import { type FeatureFlags } from './features/feature';

stScope: STScope.StylablePublicApi;
cssCustomProperty: CSSCustomProperty.StylablePublicApi;
stVar: STVar.StylablePublicApi;

@@ -46,0 +47,0 @@ stMixin: STMixin.StylablePublicApi;

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

this.stScope = new features_1.STScope.StylablePublicApi(this);
this.cssCustomProperty = new features_1.CSSCustomProperty.StylablePublicApi(this);
this.stVar = new features_1.STVar.StylablePublicApi(this);

@@ -62,0 +63,0 @@ this.stMixin = new features_1.STMixin.StylablePublicApi(this);

{
"name": "@stylable/core",
"version": "5.18.1",
"version": "5.19.0",
"description": "CSS for Components",

@@ -19,7 +19,7 @@ "main": "dist/index.js",

"cssesc": "^3.0.0",
"enhanced-resolve": "^5.15.0",
"enhanced-resolve": "^5.15.1",
"is-vendor-prefixed": "^4.0.0",
"lodash.clonedeep": "^4.5.0",
"lodash.clonedeepwith": "^4.5.0",
"postcss": "^8.4.32",
"postcss": "^8.4.35",
"postcss-js": "^4.0.1",

@@ -26,0 +26,0 @@ "postcss-nested": "^6.0.1",

@@ -10,8 +10,13 @@ import { createFeature, FeatureContext } from './feature';

} from '../helpers/css-custom-property';
import type { Stylable } from '../stylable';
import { validateAllowedNodesUntil, stringifyFunction } from '../helpers/value';
import { globalValue, GLOBAL_FUNC } from '../helpers/global';
import { plugableRecord } from '../helpers/plugable-record';
import { createDiagnosticReporter } from '../diagnostics';
import { createDiagnosticReporter, Diagnostics } from '../diagnostics';
import type { StylableMeta } from '../stylable-meta';
import type { StylableResolver, CSSResolve } from '../stylable-resolver';
import {
type StylableResolver,
type CSSResolve,
createSymbolResolverWithCache,
} from '../stylable-resolver';
import type * as postcss from 'postcss';

@@ -287,2 +292,50 @@ // ToDo: refactor out - parse once and pass to hooks

const UNKNOWN_LOCATION = Object.freeze({
offset: -1,
line: -1,
column: -1,
});
export class StylablePublicApi {
constructor(private stylable: Stylable) {}
public getProperties(meta: StylableMeta) {
const results: Record<
string,
{
meta: StylableMeta;
localName: string;
targetName: string;
source: {
meta: StylableMeta;
start: postcss.Position;
end: postcss.Position;
};
}
> = {};
const topLevelDiagnostics = new Diagnostics();
const getResolvedSymbols = createSymbolResolverWithCache(
this.stylable.resolver,
topLevelDiagnostics
);
const { cssVar } = getResolvedSymbols(meta);
for (const [name, symbol] of Object.entries(cssVar)) {
const defAst = STSymbol.getSymbolAstNode(symbol.meta, symbol.symbol);
results[name] = {
meta: symbol.meta,
localName: symbol.symbol.name,
targetName: getTransformedName(symbol),
source: {
meta: symbol.meta,
start: defAst?.source?.start || UNKNOWN_LOCATION,
end: defAst?.source?.end || UNKNOWN_LOCATION,
},
};
}
return results;
}
}
function analyzeDeclValueVarCalls(context: FeatureContext, decl: postcss.Declaration) {

@@ -289,0 +342,0 @@ const parsed = postcssValueParser(decl.value);

@@ -73,2 +73,3 @@ import { FeatureContext, createFeature } from './feature';

},
symbolToAst: new WeakMap(),
};

@@ -117,2 +118,3 @@ }

};
symbolToAst: WeakMap<StylableSymbol, postcss.Node>;
}

@@ -178,3 +180,6 @@

}) {
const { byNS, byNSFlat, byType } = plugableRecord.getUnsafe(context.meta.data, dataKey);
const { byNS, byNSFlat, byType, symbolToAst } = plugableRecord.getUnsafe(
context.meta.data,
dataKey
);
const name = localName || symbol.name;

@@ -193,5 +198,14 @@ const typeTable = byType[symbol._kind];

typeTable[name] = symbol;
node && symbolToAst.set(symbol, node);
return symbol;
}
export function getSymbolAstNode(
meta: StylableMeta,
symbol: StylableSymbol
): postcss.Node | undefined {
const { symbolToAst } = plugableRecord.getUnsafe(meta.data, dataKey);
return symbolToAst.get(symbol);
}
export function reportRedeclare(context: FeatureContext) {

@@ -198,0 +212,0 @@ const { byNS } = plugableRecord.getUnsafe(context.meta.data, dataKey);

@@ -39,2 +39,7 @@ import { createFeature, FeatureContext, FeatureTransformContext } from './feature';

input: CustomValueInput;
source: {
meta: StylableMeta;
start: postcss.Position;
end: postcss.Position;
};
}

@@ -45,2 +50,3 @@

path: string[];
source: ComputedStVar['source'];
}

@@ -208,2 +214,7 @@

const UNKNOWN_LOCATION = Object.freeze({
offset: -1,
line: -1,
column: -1,
} as const);
export class StylablePublicApi {

@@ -244,2 +255,7 @@ constructor(private stylable: Stylable) {}

diagnostics,
source: {
meta: resolvedVar.meta,
start: resolvedVar.symbol.node.source?.start || UNKNOWN_LOCATION,
end: resolvedVar.symbol.node.source?.end || UNKNOWN_LOCATION,
},
};

@@ -259,3 +275,3 @@

for (const [symbol, stVar] of Object.entries(computed)) {
flatStVars.push(...this.flatSingle(stVar.input, [symbol]));
flatStVars.push(...this.flatSingle(stVar.input, [symbol], stVar.source));
}

@@ -266,3 +282,3 @@

private flatSingle(input: CustomValueInput, path: string[]) {
private flatSingle(input: CustomValueInput, path: string[], source: ComputedStVar['source']) {
const currentVars: FlatComputedStVar[] = [];

@@ -274,2 +290,3 @@

path,
source,
});

@@ -283,3 +300,4 @@ }

typeof innerInput === 'string' ? boxString(innerInput) : innerInput,
[...path, key]
[...path, key],
source
)

@@ -286,0 +304,0 @@ );

@@ -783,3 +783,3 @@ import type * as postcss from 'postcss';

);
if (errors) {
if (errors && selectorNode.nodes) {
for (const node of selectorNode.nodes) {

@@ -786,0 +786,0 @@ if (node.type === 'decl' && node.prop === `-st-states`) {

@@ -57,3 +57,3 @@ import {

const mixinRoot = mixinTarget ? mixinTarget : postcss.root();
root.nodes.forEach((node) => {
root.nodes?.forEach((node) => {
if (node.type === 'decl') {

@@ -60,0 +60,0 @@ mixinTarget?.append(node.clone());

@@ -76,2 +76,3 @@ import type { CacheItem, FileProcessor, MinimalFS } from './cached-process-file';

public stScope = new STScope.StylablePublicApi(this);
public cssCustomProperty = new CSSCustomProperty.StylablePublicApi(this);
public stVar = new STVar.StylablePublicApi(this);

@@ -78,0 +79,0 @@ public stMixin = new STMixin.StylablePublicApi(this);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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