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

@stylable/core

Package Overview
Dependencies
Maintainers
7
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 4.14.2 to 4.15.0

dist/features/st-namespace.d.ts

1

dist/features/feature.d.ts

@@ -50,2 +50,3 @@ import type { StylableMeta } from '../stylable-meta';

prepareAST: (options: {
meta: StylableMeta;
node: postcss.ChildNode;

@@ -52,0 +53,0 @@ toRemove: Array<postcss.Node | (() => void)>;

@@ -6,2 +6,3 @@ export type { FeatureContext } from './feature';

export type { ImportSymbol, Imported } from './st-import';
export * as STNamespace from './st-namespace';
export * as STGlobal from './st-global';

@@ -8,0 +9,0 @@ export * as STScope from './st-scope';

3

dist/features/index.js

@@ -26,5 +26,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.CSSLayer = exports.CSSKeyframes = exports.CSSCustomProperty = exports.CSSType = exports.CSSClass = exports.STMixin = exports.STVar = exports.STScope = exports.STGlobal = exports.STImport = exports.STSymbol = void 0;
exports.CSSLayer = exports.CSSKeyframes = exports.CSSCustomProperty = exports.CSSType = exports.CSSClass = exports.STMixin = exports.STVar = exports.STScope = exports.STGlobal = exports.STNamespace = exports.STImport = exports.STSymbol = void 0;
exports.STSymbol = __importStar(require("./st-symbol"));
exports.STImport = __importStar(require("./st-import"));
exports.STNamespace = __importStar(require("./st-namespace"));
exports.STGlobal = __importStar(require("./st-global"));

@@ -31,0 +32,0 @@ exports.STScope = __importStar(require("./st-scope"));

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

features_1.STImport,
features_1.STNamespace,
features_1.STGlobal,

@@ -13,0 +14,0 @@ features_1.STVar,

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

import { StylableDirectives } from './features';
import { FeatureContext } from './features';
import { FeatureContext, STNamespace } from './features';
import type { SRule } from './deprecated/postcss-ast-extension';

@@ -14,5 +14,2 @@ export declare const processorWarnings: {

OVERRIDE_TYPED_RULE(key: string, name: string): string;
INVALID_NAMESPACE_DEF(): string;
EMPTY_NAMESPACE_DEF(): string;
INVALID_NAMESPACE_REFERENCE(): string;
INVALID_NESTING(child: string, parent: string): string;

@@ -25,7 +22,6 @@ };

private customSelectorData;
constructor(diagnostics?: Diagnostics, resolveNamespace?: typeof processNamespace);
constructor(diagnostics?: Diagnostics, resolveNamespace?: typeof STNamespace.defaultProcessNamespace);
process(root: postcss.Root): StylableMeta;
protected handleAtRules(root: postcss.Root): void;
private collectUrls;
private handleNamespaceReference;
protected handleRule(rule: SRule, { isScoped, reportUnscoped }: {

@@ -41,5 +37,5 @@ isScoped: boolean;

export declare function createEmptyMeta(root: postcss.Root, diagnostics: Diagnostics): StylableMeta;
export declare function processNamespace(namespace: string, origin: string, _source?: string): string;
export declare function process(root: postcss.Root, diagnostics?: Diagnostics, resolveNamespace?: typeof processNamespace): StylableMeta;
export declare function prepareAST(meta: StylableMeta, ast: postcss.Root): void;
export declare const processNamespace: typeof STNamespace.defaultProcessNamespace;
//# sourceMappingURL=stylable-processor.d.ts.map

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

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareAST = exports.process = exports.processNamespace = exports.createEmptyMeta = exports.validateScopingSelector = exports.StylableProcessor = exports.processorWarnings = void 0;
const path_1 = __importDefault(require("path"));
exports.processNamespace = exports.prepareAST = exports.process = exports.createEmptyMeta = exports.validateScopingSelector = exports.StylableProcessor = exports.processorWarnings = void 0;
const postcss = __importStar(require("postcss"));
const diagnostics_1 = require("./diagnostics");
const deprecated_selector_utils_1 = require("./deprecated/deprecated-selector-utils");
const murmurhash_1 = require("./murmurhash");
const native_reserved_lists_1 = require("./native-reserved-lists");

@@ -47,3 +42,2 @@ const stylable_meta_1 = require("./stylable-meta");

const stylable_value_parsers_1 = require("./stylable-value-parsers");
const string_1 = require("./helpers/string");
const deprecation_1 = require("./helpers/deprecation");

@@ -69,11 +63,2 @@ const parseStates = stylable_value_parsers_1.SBTypesParsers[`-st-states`];

},
INVALID_NAMESPACE_DEF() {
return 'invalid @namespace';
},
EMPTY_NAMESPACE_DEF() {
return '@namespace must contain at least one character or digit';
},
INVALID_NAMESPACE_REFERENCE() {
return 'st-namespace-reference dose not have any value';
},
INVALID_NESTING(child, parent) {

@@ -84,3 +69,3 @@ return `nesting of rules within rules is not supported, found: "${child}" inside "${parent}"`;

class StylableProcessor {
constructor(diagnostics = new diagnostics_1.Diagnostics(), resolveNamespace = processNamespace) {
constructor(diagnostics = new diagnostics_1.Diagnostics(), resolveNamespace = features_2.STNamespace.defaultProcessNamespace) {
this.diagnostics = diagnostics;

@@ -122,2 +107,3 @@ this.resolveNamespace = resolveNamespace;

});
features_2.STNamespace.setMetaNamespace(this, this.resolveNamespace);
features_2.STSymbol.reportRedeclare(this);

@@ -128,3 +114,2 @@ prepareAST(this.meta, root);

handleAtRules(root) {
let namespace = '';
const analyzeRule = (rule, { isScoped }) => {

@@ -146,15 +131,9 @@ return this.handleRule(rule, {

}
case 'namespace': {
const match = atRule.params.match(/["'](.*?)['"]/);
if (match) {
if (match[1].trim()) {
namespace = match[1];
}
else {
this.diagnostics.error(atRule, exports.processorWarnings.EMPTY_NAMESPACE_DEF());
}
}
else {
this.diagnostics.error(atRule, exports.processorWarnings.INVALID_NAMESPACE_DEF());
}
case 'namespace':
case 'st-namespace': {
features_2.STNamespace.hooks.analyzeAtRule({
context: this,
atRule,
analyzeRule,
});
break;

@@ -204,3 +183,7 @@ }

case 'st-global-custom-property': {
features_1.CSSCustomProperty.hooks.analyzeAtRule({ context: this, atRule, analyzeRule });
features_1.CSSCustomProperty.hooks.analyzeAtRule({
context: this,
atRule,
analyzeRule,
});
break;

@@ -210,4 +193,2 @@ }

});
namespace = namespace || (0, string_1.filename2varname)(path_1.default.basename(this.meta.source)) || 's';
this.meta.namespace = this.handleNamespaceReference(namespace);
}

@@ -221,22 +202,2 @@ collectUrls(decl) {

}
handleNamespaceReference(namespace) {
let pathToSource;
let length = this.meta.ast.nodes.length;
while (length--) {
const node = this.meta.ast.nodes[length];
if (node.type === 'comment' && node.text.includes('st-namespace-reference')) {
const i = node.text.indexOf('=');
if (i === -1) {
this.diagnostics.error(node, exports.processorWarnings.INVALID_NAMESPACE_REFERENCE());
}
else {
pathToSource = (0, string_1.stripQuotation)(node.text.slice(i + 1));
}
break;
}
}
return this.resolveNamespace(namespace, pathToSource
? path_1.default.resolve(path_1.default.dirname(this.meta.source), pathToSource)
: this.meta.source, this.meta.source);
}
handleRule(rule, { isScoped, reportUnscoped }) {

@@ -447,6 +408,2 @@ rule.selectorAst = (0, deprecated_selector_utils_1.parseSelector)(rule.selector);

exports.createEmptyMeta = createEmptyMeta;
function processNamespace(namespace, origin, _source) {
return namespace + (0, murmurhash_1.murmurhash3_32_gc)(origin); // .toString(36);
}
exports.processNamespace = processNamespace;
function process(root, diagnostics = new diagnostics_1.Diagnostics(), resolveNamespace) {

@@ -459,7 +416,5 @@ return new StylableProcessor(diagnostics, resolveNamespace).process(root);

ast.walk((node) => {
const input = { node, toRemove };
const input = { meta, node, toRemove };
// namespace
if (node.type === 'atrule' && node.name === `namespace`) {
toRemove.push(node);
}
features_2.STNamespace.hooks.prepareAST(input);
// custom selectors

@@ -483,2 +438,4 @@ if (node.type === 'rule') {

exports.prepareAST = prepareAST;
// ToDo: remove export and reroute import from feature
exports.processNamespace = features_2.STNamespace.defaultProcessNamespace;
//# sourceMappingURL=stylable-processor.js.map

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

protected mode: 'production' | 'development';
resolveNamespace?: typeof processNamespace | undefined;
resolveNamespace?: typeof import("./features/st-namespace").defaultProcessNamespace | undefined;
private moduleResolver;

@@ -58,3 +58,3 @@ protected cssParser: CssParser;

stVar: STVar.StylablePublicApi;
constructor(projectRoot: string, fileSystem: MinimalFS, requireModule: (path: string) => any, delimiter?: string, onProcess?: ((meta: StylableMeta, path: string) => StylableMeta) | undefined, diagnostics?: Diagnostics, hooks?: TransformHooks, resolveOptions?: any, optimizer?: IStylableOptimizer | undefined, mode?: 'production' | 'development', resolveNamespace?: typeof processNamespace | undefined, moduleResolver?: ModuleResolver, cssParser?: CssParser, resolverCache?: StylableResolverCache | undefined, // ToDo: v5 default to `new Map()`
constructor(projectRoot: string, fileSystem: MinimalFS, requireModule: (path: string) => any, delimiter?: string, onProcess?: ((meta: StylableMeta, path: string) => StylableMeta) | undefined, diagnostics?: Diagnostics, hooks?: TransformHooks, resolveOptions?: any, optimizer?: IStylableOptimizer | undefined, mode?: 'production' | 'development', resolveNamespace?: typeof import("./features/st-namespace").defaultProcessNamespace | undefined, moduleResolver?: ModuleResolver, cssParser?: CssParser, resolverCache?: StylableResolverCache | undefined, // ToDo: v5 default to `new Map()`
fileProcessorCache?: Record<string, CacheItem<StylableMeta>> | undefined);

@@ -61,0 +61,0 @@ initCache({ filter }?: InitCacheParams): void;

{
"name": "@stylable/core",
"version": "4.14.2",
"version": "4.15.0",
"description": "CSS for Components",

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

@@ -50,2 +50,3 @@ import type { StylableMeta } from '../stylable-meta';

prepareAST: (options: {
meta: StylableMeta;
node: postcss.ChildNode;

@@ -52,0 +53,0 @@ toRemove: Array<postcss.Node | (() => void)>;

@@ -9,2 +9,4 @@ export type { FeatureContext } from './feature';

export * as STNamespace from './st-namespace';
export * as STGlobal from './st-global';

@@ -11,0 +13,0 @@

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

STImport,
STNamespace,
STGlobal,

@@ -37,2 +38,3 @@ STVar,

STImport,
STNamespace,
STGlobal,

@@ -39,0 +41,0 @@ STVar,

@@ -1,6 +0,4 @@

import path from 'path';
import * as postcss from 'postcss';
import { Diagnostics } from './diagnostics';
import { parseSelector as deprecatedParseSelector } from './deprecated/deprecated-selector-utils';
import { murmurhash3_32_gc } from './murmurhash';
import { knownPseudoClassesWithNestedSelectors } from './native-reserved-lists';

@@ -21,2 +19,3 @@ import { StylableMeta } from './stylable-meta';

STImport,
STNamespace,
STGlobal,

@@ -42,3 +41,2 @@ STScope,

import { SBTypesParsers } from './stylable-value-parsers';
import { stripQuotation, filename2varname } from './helpers/string';
import { warnOnce } from './helpers/deprecation';

@@ -66,12 +64,2 @@

},
INVALID_NAMESPACE_DEF() {
return 'invalid @namespace';
},
EMPTY_NAMESPACE_DEF() {
return '@namespace must contain at least one character or digit';
},
INVALID_NAMESPACE_REFERENCE() {
return 'st-namespace-reference dose not have any value';
},
INVALID_NESTING(child: string, parent: string) {

@@ -87,3 +75,3 @@ return `nesting of rules within rules is not supported, found: "${child}" inside "${parent}"`;

public diagnostics = new Diagnostics(),
private resolveNamespace = processNamespace
private resolveNamespace = STNamespace.defaultProcessNamespace
) {}

@@ -134,2 +122,4 @@ public process(root: postcss.Root): StylableMeta {

STNamespace.setMetaNamespace(this, this.resolveNamespace);
STSymbol.reportRedeclare(this);

@@ -143,4 +133,2 @@

protected handleAtRules(root: postcss.Root) {
let namespace = '';
const analyzeRule = (rule: postcss.Rule, { isScoped }: { isScoped: boolean }) => {

@@ -163,13 +151,9 @@ return this.handleRule(rule as SRule, {

}
case 'namespace': {
const match = atRule.params.match(/["'](.*?)['"]/);
if (match) {
if (match[1].trim()) {
namespace = match[1];
} else {
this.diagnostics.error(atRule, processorWarnings.EMPTY_NAMESPACE_DEF());
}
} else {
this.diagnostics.error(atRule, processorWarnings.INVALID_NAMESPACE_DEF());
}
case 'namespace':
case 'st-namespace': {
STNamespace.hooks.analyzeAtRule({
context: this,
atRule,
analyzeRule,
});
break;

@@ -221,3 +205,7 @@ }

case 'st-global-custom-property': {
CSSCustomProperty.hooks.analyzeAtRule({ context: this, atRule, analyzeRule });
CSSCustomProperty.hooks.analyzeAtRule({
context: this,
atRule,
analyzeRule,
});
break;

@@ -227,4 +215,2 @@ }

});
namespace = namespace || filename2varname(path.basename(this.meta.source)) || 's';
this.meta.namespace = this.handleNamespaceReference(namespace);
}

@@ -242,29 +228,2 @@ private collectUrls(decl: postcss.Declaration) {

}
private handleNamespaceReference(namespace: string): string {
let pathToSource: string | undefined;
let length = this.meta.ast.nodes.length;
while (length--) {
const node = this.meta.ast.nodes[length];
if (node.type === 'comment' && node.text.includes('st-namespace-reference')) {
const i = node.text.indexOf('=');
if (i === -1) {
this.diagnostics.error(node, processorWarnings.INVALID_NAMESPACE_REFERENCE());
} else {
pathToSource = stripQuotation(node.text.slice(i + 1));
}
break;
}
}
return this.resolveNamespace(
namespace,
pathToSource
? path.resolve(path.dirname(this.meta.source), pathToSource)
: this.meta.source,
this.meta.source
);
}
protected handleRule(

@@ -512,6 +471,2 @@ rule: SRule,

export function processNamespace(namespace: string, origin: string, _source?: string) {
return namespace + murmurhash3_32_gc(origin); // .toString(36);
}
export function process(

@@ -528,7 +483,5 @@ root: postcss.Root,

ast.walk((node) => {
const input = { node, toRemove };
const input = { meta, node, toRemove };
// namespace
if (node.type === 'atrule' && node.name === `namespace`) {
toRemove.push(node);
}
STNamespace.hooks.prepareAST(input);
// custom selectors

@@ -550,1 +503,3 @@ if (node.type === 'rule') {

}
// ToDo: remove export and reroute import from feature
export const processNamespace = STNamespace.defaultProcessNamespace;

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