@stylable/core
Advanced tools
Comparing version 5.3.0 to 5.3.1-rc.1
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'; | ||
import type { StylableResolver } from '../stylable-resolver'; | ||
export declare const parseImportMessages: { | ||
@@ -93,4 +93,14 @@ ST_IMPORT_STAR: { | ||
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>; | ||
declare type ImportEvent = { | ||
context: string; | ||
request: string; | ||
resolved: string; | ||
depth: number; | ||
}; | ||
declare type ImportCollectionHost = { | ||
resolver: StylableResolver; | ||
analyze: (fullPath: string) => StylableMeta; | ||
}; | ||
export declare function tryCollectImportsDeep(host: ImportCollectionHost, meta: StylableMeta, imports?: Set<string>, onImport?: undefined | ((e: ImportEvent) => void), depth?: number): Set<string>; | ||
export {}; | ||
//# sourceMappingURL=import.d.ts.map |
@@ -434,12 +434,13 @@ "use strict"; | ||
} | ||
function tryCollectImportsDeep(stylable, meta, imports = new Set()) { | ||
function tryCollectImportsDeep(host, meta, imports = new Set(), onImport = undefined, depth = 0) { | ||
for (const { context, request } of meta.getImportStatements()) { | ||
try { | ||
const resolved = stylable.resolver.resolvePath(context, request); | ||
const resolved = host.resolver.resolvePath(context, request); | ||
onImport === null || onImport === void 0 ? void 0 : onImport({ context, request, resolved, depth }); | ||
if (!imports.has(resolved)) { | ||
imports.add(resolved); | ||
tryCollectImportsDeep(stylable, stylable.analyze(resolved), imports); | ||
tryCollectImportsDeep(host, host.analyze(resolved), imports, onImport, depth + 1); | ||
} | ||
} | ||
catch (e) { | ||
catch { | ||
/** */ | ||
@@ -446,0 +447,0 @@ } |
@@ -9,3 +9,3 @@ export { safeParse } from './parser'; | ||
export { nativePseudoClasses, nativePseudoElements, knownPseudoClassesWithNestedSelectors, } from './native-reserved-lists'; | ||
export { isAsset, makeAbsolute } from './stylable-assets'; | ||
export { isAsset, makeAbsolute, fixRelativeUrls } from './stylable-assets'; | ||
export { namespace, namespaceDelimiter } from './helpers/namespace'; | ||
@@ -12,0 +12,0 @@ export { emitDiagnostics, DiagnosticsMode, EmitDiagnosticsContext, reportDiagnostic, } from './report-diagnostic'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
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.fixRelativeUrls = 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"); | ||
@@ -25,2 +25,3 @@ Object.defineProperty(exports, "safeParse", { enumerable: true, get: function () { return parser_1.safeParse; } }); | ||
Object.defineProperty(exports, "makeAbsolute", { enumerable: true, get: function () { return stylable_assets_1.makeAbsolute; } }); | ||
Object.defineProperty(exports, "fixRelativeUrls", { enumerable: true, get: function () { return stylable_assets_1.fixRelativeUrls; } }); | ||
var namespace_1 = require("./helpers/namespace"); | ||
@@ -27,0 +28,0 @@ Object.defineProperty(exports, "namespace", { enumerable: true, get: function () { return namespace_1.namespace; } }); |
@@ -14,2 +14,6 @@ import type * as postcss from 'postcss'; | ||
urls: string[]; | ||
transformCssDepth: { | ||
cssDepth: number; | ||
deepDependencies: Set<string>; | ||
} | undefined; | ||
transformDiagnostics: Diagnostics | null; | ||
@@ -16,0 +20,0 @@ transformedScopes: Record<string, SelectorList> | null; |
@@ -80,2 +80,3 @@ import * as postcss from 'postcss'; | ||
private handleCompoundNode; | ||
private calcCssDepth; | ||
private isDuplicateStScopeDiagnostic; | ||
@@ -82,0 +83,0 @@ private handleCustomSelector; |
@@ -46,2 +46,3 @@ "use strict"; | ||
const postcss_ast_extension_1 = require("./deprecated/postcss-ast-extension"); | ||
const import_1 = require("./helpers/import"); | ||
const { hasOwnProperty } = Object.prototype; | ||
@@ -86,2 +87,3 @@ exports.transformerDiagnostics = { | ||
meta.transformDiagnostics = this.diagnostics; | ||
meta.transformCssDepth = this.calcCssDepth(meta); | ||
const result = { meta, exports: metaExports }; | ||
@@ -437,2 +439,12 @@ return this.postProcessor ? this.postProcessor(result, this) : result; | ||
} | ||
calcCssDepth(meta) { | ||
let cssDepth = 0; | ||
const deepDependencies = (0, import_1.tryCollectImportsDeep)({ | ||
resolver: this.resolver, | ||
analyze: (filePath) => this.fileProcessor.process(filePath), | ||
}, meta, new Set(), ({ depth }) => { | ||
cssDepth = Math.max(cssDepth, depth); | ||
}, 1); | ||
return { cssDepth, deepDependencies }; | ||
} | ||
isDuplicateStScopeDiagnostic(context) { | ||
@@ -439,0 +451,0 @@ var _a; |
{ | ||
"name": "@stylable/core", | ||
"version": "5.3.0", | ||
"version": "5.3.1-rc.1", | ||
"description": "CSS for Components", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -9,3 +9,2 @@ import path from 'path'; | ||
import type { ParsedValue } from '../types'; | ||
import type { Stylable } from '../stylable'; | ||
import type { StylableMeta } from '../stylable-meta'; | ||
@@ -17,2 +16,3 @@ import type * as postcss from 'postcss'; | ||
} from 'postcss-value-parser'; | ||
import type { StylableResolver } from '../stylable-resolver'; | ||
@@ -585,16 +585,31 @@ export const parseImportMessages = { | ||
type ImportEvent = { | ||
context: string; | ||
request: string; | ||
resolved: string; | ||
depth: number; | ||
}; | ||
type ImportCollectionHost = { | ||
resolver: StylableResolver; | ||
analyze: (fullPath: string) => StylableMeta; | ||
}; | ||
export function tryCollectImportsDeep( | ||
stylable: Stylable, | ||
host: ImportCollectionHost, | ||
meta: StylableMeta, | ||
imports = new Set<string>() | ||
imports = new Set<string>(), | ||
onImport: undefined | ((e: ImportEvent) => void) = undefined, | ||
depth = 0 | ||
) { | ||
for (const { context, request } of meta.getImportStatements()) { | ||
try { | ||
const resolved = stylable.resolver.resolvePath(context, request); | ||
const resolved = host.resolver.resolvePath(context, request); | ||
onImport?.({ context, request, resolved, depth }); | ||
if (!imports.has(resolved)) { | ||
imports.add(resolved); | ||
tryCollectImportsDeep(stylable, stylable.analyze(resolved), imports); | ||
tryCollectImportsDeep(host, host.analyze(resolved), imports, onImport, depth + 1); | ||
} | ||
} catch (e) { | ||
} catch { | ||
/** */ | ||
@@ -601,0 +616,0 @@ } |
@@ -20,3 +20,3 @@ export { safeParse } from './parser'; | ||
} from './native-reserved-lists'; | ||
export { isAsset, makeAbsolute } from './stylable-assets'; | ||
export { isAsset, makeAbsolute, fixRelativeUrls } from './stylable-assets'; | ||
export { namespace, namespaceDelimiter } from './helpers/namespace'; | ||
@@ -23,0 +23,0 @@ export { |
@@ -45,2 +45,3 @@ import type * as postcss from 'postcss'; | ||
public urls: string[] = []; | ||
public transformCssDepth: { cssDepth: number; deepDependencies: Set<string> } | undefined; | ||
public transformDiagnostics: Diagnostics | null = null; | ||
@@ -47,0 +48,0 @@ public transformedScopes: Record<string, SelectorList> | null = null; |
@@ -45,2 +45,3 @@ import isVendorPrefixed from 'is-vendor-prefixed'; | ||
import { getRuleScopeSelector } from './deprecated/postcss-ast-extension'; | ||
import { tryCollectImportsDeep } from './helpers/import'; | ||
@@ -160,2 +161,3 @@ const { hasOwnProperty } = Object.prototype; | ||
meta.transformDiagnostics = this.diagnostics; | ||
meta.transformCssDepth = this.calcCssDepth(meta); | ||
const result = { meta, exports: metaExports }; | ||
@@ -573,2 +575,18 @@ | ||
} | ||
private calcCssDepth(meta: StylableMeta) { | ||
let cssDepth = 0; | ||
const deepDependencies = tryCollectImportsDeep( | ||
{ | ||
resolver: this.resolver, | ||
analyze: (filePath) => this.fileProcessor.process(filePath), | ||
}, | ||
meta, | ||
new Set(), | ||
({ depth }) => { | ||
cssDepth = Math.max(cssDepth, depth); | ||
}, | ||
1 | ||
); | ||
return { cssDepth, deepDependencies }; | ||
} | ||
private isDuplicateStScopeDiagnostic(context: ScopeContext) { | ||
@@ -575,0 +593,0 @@ const transformedScope = |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1102609
19730
1