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 5.0.0-rc.5 to 5.0.0

3

dist/helpers/import.d.ts
import { Diagnostics } from '../diagnostics';
import type { Imported } from '../features';
import { Root, Rule, AtRule } from 'postcss';
import type { Stylable } from '../stylable';
import type { StylableMeta } from '../stylable-meta';
import type * as postcss from 'postcss';

@@ -91,3 +93,4 @@ export declare const parseImportMessages: {

declare type ImportPatch = Partial<Pick<Imported, 'defaultExport' | 'named' | 'keyframes'>> & Pick<Imported, 'request'>;
export declare function tryCollectImportsDeep(stylable: Stylable, meta: StylableMeta, imports?: Set<string>): Set<string>;
export {};
//# sourceMappingURL=import.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.parsePseudoImportNamed = exports.parsePseudoImport = exports.parseStImport = exports.parseModuleImportStatement = exports.ensureModuleImport = exports.createAtImportProps = exports.ensureImportsMessages = exports.parseImportMessages = void 0;
exports.tryCollectImportsDeep = exports.parsePseudoImportNamed = exports.parsePseudoImport = exports.parseStImport = exports.parseModuleImportStatement = exports.ensureModuleImport = exports.createAtImportProps = exports.ensureImportsMessages = exports.parseImportMessages = void 0;
const path_1 = __importDefault(require("path"));

@@ -435,2 +435,16 @@ const imports_parser_1 = require("@tokey/imports-parser");

}
function tryCollectImportsDeep(stylable, meta, imports = new Set()) {
for (const { context, request } of meta.getImportStatements()) {
try {
const resolved = stylable.resolver.resolvePath(context, request);
imports.add(resolved);
tryCollectImportsDeep(stylable, stylable.analyze(resolved), imports);
}
catch (e) {
/** */
}
}
return imports;
}
exports.tryCollectImportsDeep = tryCollectImportsDeep;
//# sourceMappingURL=import.js.map

@@ -28,2 +28,3 @@ export { safeParse } from './parser';

export { getAstNodeAt } from './helpers/ast';
export { tryCollectImportsDeep } from './helpers/import';
//# sourceMappingURL=index-internal.d.ts.map

4

dist/index-internal.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAstNodeAt = exports.systemValidators = exports.createCustomValue = exports.pseudoStates = exports.packageNamespaceFactory = exports.createStylableFileProcessor = exports.cachedProcessFile = exports.StylableResolver = exports.reportDiagnostic = exports.emitDiagnostics = exports.namespaceDelimiter = exports.namespace = exports.makeAbsolute = exports.isAsset = exports.knownPseudoClassesWithNestedSelectors = exports.nativePseudoElements = exports.nativePseudoClasses = exports.cssParse = exports.murmurhash3_32_gc = exports.STCustomSelector = exports.transformerDiagnostics = exports.StylableTransformer = exports.StylableProcessor = exports.processorDiagnostics = exports.safeParse = void 0;
exports.tryCollectImportsDeep = exports.getAstNodeAt = exports.systemValidators = exports.createCustomValue = exports.pseudoStates = exports.packageNamespaceFactory = exports.createStylableFileProcessor = exports.cachedProcessFile = exports.StylableResolver = exports.reportDiagnostic = exports.emitDiagnostics = exports.namespaceDelimiter = exports.namespace = exports.makeAbsolute = exports.isAsset = exports.knownPseudoClassesWithNestedSelectors = exports.nativePseudoElements = exports.nativePseudoClasses = exports.cssParse = exports.murmurhash3_32_gc = exports.STCustomSelector = exports.transformerDiagnostics = exports.StylableTransformer = exports.StylableProcessor = exports.processorDiagnostics = exports.safeParse = void 0;
var parser_1 = require("./parser");

@@ -54,2 +54,4 @@ Object.defineProperty(exports, "safeParse", { enumerable: true, get: function () { return parser_1.safeParse; } });

Object.defineProperty(exports, "getAstNodeAt", { enumerable: true, get: function () { return ast_1.getAstNodeAt; } });
var import_1 = require("./helpers/import");
Object.defineProperty(exports, "tryCollectImportsDeep", { enumerable: true, get: function () { return import_1.tryCollectImportsDeep; } });
//# sourceMappingURL=index-internal.js.map

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

context: string;
resolvedPath: string | undefined;
}

@@ -59,6 +60,7 @@ export interface CachedStylableMeta {

protected requireModule: (resolvedPath: string) => any;
resolvePath: ModuleResolver;
protected moduleResolver: ModuleResolver;
protected cache?: StylableResolverCache | undefined;
constructor(fileProcessor: FileProcessor<StylableMeta>, requireModule: (resolvedPath: string) => any, resolvePath: ModuleResolver, cache?: StylableResolverCache | undefined);
constructor(fileProcessor: FileProcessor<StylableMeta>, requireModule: (resolvedPath: string) => any, moduleResolver: ModuleResolver, cache?: StylableResolverCache | undefined);
private getModule;
resolvePath(directoryPath: string, request: string): string;
resolveImported(imported: Imported, name: string, subtype?: 'mappedSymbols' | 'mappedKeyframes' | STSymbol.Namespaces): CSSResolve | JSResolve | null;

@@ -65,0 +67,0 @@ resolveImport(importSymbol: ImportSymbol): JSResolve | CSSResolve<StylableSymbol> | null;

@@ -15,6 +15,6 @@ "use strict";

class StylableResolver {
constructor(fileProcessor, requireModule, resolvePath, cache) {
constructor(fileProcessor, requireModule, moduleResolver, cache) {
this.fileProcessor = fileProcessor;
this.requireModule = requireModule;
this.resolvePath = resolvePath;
this.moduleResolver = moduleResolver;
this.cache = cache;

@@ -24,3 +24,3 @@ }

var _a, _b, _c;
const key = `${context}${safePathDelimiter}${request}`;
const key = cacheKey(context, request);
if ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.has(key)) {

@@ -32,3 +32,3 @@ return this.cache.get(key);

try {
resolvedPath = this.resolvePath(context, request);
resolvedPath = this.moduleResolver(context, request);
}

@@ -42,2 +42,3 @@ catch (error) {

context,
resolvedPath: undefined,
};

@@ -53,3 +54,3 @@ (_b = this.cache) === null || _b === void 0 ? void 0 : _b.set(key, entity);

catch (error) {
entity = { kind, value: null, error, request, context };
entity = { kind, value: null, error, request, context, resolvedPath };
}

@@ -63,3 +64,3 @@ }

catch (error) {
entity = { kind, value: null, error, request, context };
entity = { kind, value: null, error, request, context, resolvedPath };
}

@@ -70,2 +71,10 @@ }

}
resolvePath(directoryPath, request) {
var _a, _b;
const resolvedPath = (_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.get(cacheKey(directoryPath, request))) === null || _b === void 0 ? void 0 : _b.resolvedPath;
if (resolvedPath) {
return resolvedPath;
}
return this.moduleResolver(directoryPath, request);
}
resolveImported(imported, name, subtype = 'mappedSymbols') {

@@ -350,2 +359,5 @@ const res = this.getModule(imported);

exports.StylableResolver = StylableResolver;
function cacheKey(context, request) {
return `${context}${safePathDelimiter}${request}`;
}
function validateClassResolveExtends(meta, name, diagnostics, deepResolved) {

@@ -352,0 +364,0 @@ return (res, extend) => {

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

resolveNamespace?: typeof processNamespace;
resolvePath: ModuleResolver;
moduleResolver: ModuleResolver;
protected cssParser: CssParser;

@@ -77,4 +77,5 @@ protected resolverCache?: StylableResolverCache;

analyze(fullPath: string, overrideSrc?: string): StylableMeta;
resolvePath(directoryPath: string, request: string): string;
}
export {};
//# sourceMappingURL=stylable.d.ts.map

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

this.resolveNamespace = config.resolveNamespace;
this.resolvePath =
this.moduleResolver =
config.resolveModule || (0, module_resolver_1.createDefaultResolver)(this.fileSystem, this.resolveOptions);

@@ -94,3 +94,3 @@ this.cssParser = config.cssParser || parser_1.cssParse;

}
createResolver({ requireModule = this.requireModule, resolverCache = this.resolverCache, resolvePath = this.resolvePath, } = {}) {
createResolver({ requireModule = this.requireModule, resolverCache = this.resolverCache, resolvePath = this.moduleResolver, } = {}) {
return new stylable_resolver_1.StylableResolver(this.fileProcessor, requireModule, resolvePath, resolverCache);

@@ -103,3 +103,3 @@ }

return new stylable_transformer_1.StylableTransformer({
moduleResolver: this.resolvePath,
moduleResolver: this.moduleResolver,
diagnostics: new diagnostics_1.Diagnostics(),

@@ -149,4 +149,7 @@ fileProcessor: this.fileProcessor,

}
resolvePath(directoryPath, request) {
return this.resolver.resolvePath(directoryPath, request);
}
}
exports.Stylable = Stylable;
//# sourceMappingURL=stylable.js.map
{
"name": "@stylable/core",
"version": "5.0.0-rc.5",
"version": "5.0.0",
"description": "CSS for Components",

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

@@ -9,2 +9,4 @@ import path from 'path';

import type { ParsedValue } from '../types';
import type { Stylable } from '../stylable';
import type { StylableMeta } from '../stylable-meta';
import type * as postcss from 'postcss';

@@ -581,1 +583,18 @@ import postcssValueParser, {

}
export function tryCollectImportsDeep(
stylable: Stylable,
meta: StylableMeta,
imports = new Set<string>()
) {
for (const { context, request } of meta.getImportStatements()) {
try {
const resolved = stylable.resolver.resolvePath(context, request);
imports.add(resolved);
tryCollectImportsDeep(stylable, stylable.analyze(resolved), imports);
} catch (e) {
/** */
}
}
return imports;
}

@@ -50,1 +50,2 @@ export { safeParse } from './parser';

export { getAstNodeAt } from './helpers/ast';
export { tryCollectImportsDeep } from './helpers/import';

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

context: string;
resolvedPath: string | undefined;
}

@@ -105,7 +106,7 @@

protected requireModule: (resolvedPath: string) => any,
public resolvePath: ModuleResolver,
protected moduleResolver: ModuleResolver,
protected cache?: StylableResolverCache
) {}
private getModule({ context, request }: Imported): CachedModuleEntity {
const key = `${context}${safePathDelimiter}${request}`;
const key = cacheKey(context, request);
if (this.cache?.has(key)) {

@@ -119,3 +120,3 @@ return this.cache.get(key)!;

try {
resolvedPath = this.resolvePath(context, request);
resolvedPath = this.moduleResolver(context, request);
} catch (error) {

@@ -128,2 +129,3 @@ entity = {

context,
resolvedPath: undefined,
};

@@ -139,3 +141,3 @@ this.cache?.set(key, entity);

} catch (error) {
entity = { kind, value: null, error, request, context };
entity = { kind, value: null, error, request, context, resolvedPath };
}

@@ -147,3 +149,3 @@ } else {

} catch (error) {
entity = { kind, value: null, error, request, context };
entity = { kind, value: null, error, request, context, resolvedPath };
}

@@ -156,3 +158,9 @@ }

}
public resolvePath(directoryPath: string, request: string): string {
const resolvedPath = this.cache?.get(cacheKey(directoryPath, request))?.resolvedPath;
if (resolvedPath) {
return resolvedPath;
}
return this.moduleResolver(directoryPath, request);
}
public resolveImported(

@@ -469,2 +477,7 @@ imported: Imported,

}
function cacheKey(context: string, request: string) {
return `${context}${safePathDelimiter}${request}`;
}
function validateClassResolveExtends(

@@ -471,0 +484,0 @@ meta: StylableMeta,

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

public resolveNamespace?: typeof processNamespace;
public resolvePath: ModuleResolver;
public moduleResolver: ModuleResolver;
protected cssParser: CssParser;

@@ -87,3 +87,3 @@ protected resolverCache?: StylableResolverCache;

this.resolveNamespace = config.resolveNamespace;
this.resolvePath =
this.moduleResolver =
config.resolveModule || createDefaultResolver(this.fileSystem, this.resolveOptions);

@@ -129,3 +129,3 @@ this.cssParser = config.cssParser || cssParse;

resolverCache = this.resolverCache,
resolvePath = this.resolvePath,
resolvePath = this.moduleResolver,
}: Pick<StylableConfig, 'requireModule' | 'resolverCache'> & {

@@ -143,3 +143,3 @@ resolvePath?: ModuleResolver;

return new StylableTransformer({
moduleResolver: this.resolvePath,
moduleResolver: this.moduleResolver,
diagnostics: new Diagnostics(),

@@ -209,2 +209,5 @@ fileProcessor: this.fileProcessor,

}
public resolvePath(directoryPath: string, request: string) {
return this.resolver.resolvePath(directoryPath, request);
}
}

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