UNPKG

@stylable/core

Version:

CSS for Components

147 lines 6.98 kB
import postcss from 'postcss'; import { FileProcessor } from './cached-process-file'; import { Diagnostics } from './diagnostics'; import { SelectorAstNode, SelectorChunk2 } from './selector-utils'; import { ClassSymbol, ElementSymbol, StylableMeta, StylableSymbol } from './stylable-processor'; import { CSSResolve, StylableResolver } from './stylable-resolver'; export interface ResolvedElement { name: string; type: string; resolved: Array<CSSResolve<ClassSymbol | ElementSymbol>>; } export interface KeyFrameWithNode { value: string; node: postcss.Node; } export interface StylableExports { classes: Record<string, string>; vars: Record<string, string>; stVars: Record<string, string>; keyframes: Record<string, string>; } export interface StylableResults { meta: StylableMeta; exports: StylableExports; } export interface ScopedSelectorResults { current: StylableMeta; symbol: StylableSymbol | null; selectorAst: SelectorAstNode; selector: string; elements: ResolvedElement[][]; } export declare type replaceValueHook = (value: string, name: string | { name: string; args: string[]; }, isLocal: boolean, passedThrough: string[]) => string; export declare type postProcessor<T = {}> = (stylableResults: StylableResults, transformer: StylableTransformer) => StylableResults & T; export interface TransformHooks { postProcessor?: postProcessor; replaceValueHook?: replaceValueHook; } declare type EnvMode = 'production' | 'development'; export interface TransformerOptions { fileProcessor: FileProcessor<StylableMeta>; requireModule: (modulePath: string) => any; diagnostics: Diagnostics; delimiter?: string; keepValues?: boolean; replaceValueHook?: replaceValueHook; postProcessor?: postProcessor; mode?: EnvMode; } export interface AdditionalSelector { selectorNode: SelectorAstNode; node: SelectorAstNode; customElementChunk: string; } export declare const transformerWarnings: { UNKNOWN_PSEUDO_ELEMENT(name: string): string; IMPORT_ISNT_EXTENDABLE(): string; CANNOT_EXTEND_UNKNOWN_SYMBOL(name: string): string; CANNOT_EXTEND_JS(): string; KEYFRAME_NAME_RESERVED(name: string): string; UNKNOWN_IMPORT_ALIAS(name: string): string; SCOPE_PARAM_NOT_ROOT(name: string): string; SCOPE_PARAM_NOT_CSS(name: string): string; UNKNOWN_SCOPING_PARAM(name: string): string; }; export declare class StylableTransformer { fileProcessor: FileProcessor<StylableMeta>; diagnostics: Diagnostics; resolver: StylableResolver; delimiter: string; keepValues: boolean; replaceValueHook: replaceValueHook | undefined; postProcessor: postProcessor | undefined; mode: EnvMode; private metaParts; constructor(options: TransformerOptions); transform(meta: StylableMeta): StylableResults; transformAst(ast: postcss.Root, meta: StylableMeta, metaExports?: StylableExports, variableOverride?: Record<string, string>, path?: string[], mixinTransform?: boolean): void; exportLocalVars(meta: StylableMeta, stVarsExport: Record<string, string>, variableOverride?: Record<string, string>): void; exportCSSVars(cssVarsMapping: Record<string, string>, varsExport: Record<string, string>): void; exportKeyframes(keyframeMapping: Record<string, KeyFrameWithNode>, keyframesExport: Record<string, string>): void; exportRootClass(meta: StylableMeta, classesExport: Record<string, string>): void; exportClass(meta: StylableMeta, name: string, classSymbol: ClassSymbol, metaExports?: Record<string, string>): string; scopeKeyframes(ast: postcss.Root, meta: StylableMeta): Record<string, KeyFrameWithNode>; createCSSVarsMapping(_ast: postcss.Root, meta: StylableMeta): Record<string, string>; getScopedCSSVar(decl: postcss.Declaration, meta: StylableMeta, cssVarsMapping: Record<string, string>): string; addGlobalsToMeta(selectorAst: SelectorAstNode[], meta?: StylableMeta): void; transformGlobals(ast: postcss.Root, meta: StylableMeta): void; resolveSelectorElements(meta: StylableMeta, selector: string): ResolvedElement[][]; scopeSelector(originMeta: StylableMeta, selector: string, classesExport?: Record<string, string>, calcPaths?: boolean, rule?: postcss.Rule): ScopedSelectorResults; addAdditionalSelectors(addedSelectors: AdditionalSelector[], selectorAst: SelectorAstNode): void; applyRootScoping(meta: StylableMeta, selectorAst: SelectorAstNode): void; scopeRule(meta: StylableMeta, rule: postcss.Rule, _classesExport?: Record<string, string>): string; handleClass(meta: StylableMeta, node: SelectorAstNode, name: string, classesExport?: Record<string, string>, rule?: postcss.Rule, originMeta?: StylableMeta): CSSResolve; handleElement(meta: StylableMeta, node: SelectorAstNode, name: string, originMeta?: StylableMeta): CSSResolve<StylableSymbol> | { meta: StylableMeta; symbol: StylableSymbol; }; handlePseudoElement(meta: StylableMeta, node: SelectorAstNode, name: string, selectorNode: SelectorAstNode, addedSelectors: AdditionalSelector[], rule?: postcss.Rule, originMeta?: StylableMeta): CSSResolve; scope(name: string, namespace: string, delimiter?: string): string; exportClasses(meta: StylableMeta): Record<string, string>; getPartExports(resolved: Array<CSSResolve<ClassSymbol | ElementSymbol>>): string[]; scopeSelector2(originMeta: StylableMeta, selector: string, _classesExport?: Record<string, string>, _calcPaths?: boolean, rule?: postcss.Rule): { selector: string; elements: ResolvedElement[][]; }; scopeSelectorAst(context: ScopeContext): SelectorAstNode; private handleChunkNode; private handleCustomSelector; private scopeClassNode; private resolveMetaParts; private addDevRules; private resetTransformProperties; } export declare function removeSTDirective(root: postcss.Root): void; interface ScopeAnchor { type: 'class' | 'element' | 'pseudo-element'; name: string; resolved: Array<CSSResolve<ClassSymbol | ElementSymbol>>; } declare class ScopeContext { originMeta: StylableMeta; selectorAst: SelectorAstNode; rule: postcss.Rule; additionalSelectors: Array<() => void>; selectorIndex: number; elements: any[]; transformGlobals: boolean; metaParts?: MetaParts; chunks?: SelectorChunk2[]; chunk?: SelectorChunk2; node?: SelectorAstNode; currentAnchor?: ScopeAnchor; constructor(originMeta: StylableMeta, selectorAst: SelectorAstNode, rule: postcss.Rule); initRootAnchor(anchor: ScopeAnchor): void; setCurrentAnchor(anchor: ScopeAnchor): void; createNestedContext(selectorAst: SelectorAstNode): ScopeContext; } interface MetaParts { class: Record<string, Array<CSSResolve<ClassSymbol | ElementSymbol>>>; element: Record<string, Array<CSSResolve<ClassSymbol | ElementSymbol>>>; } export {}; //# sourceMappingURL=stylable-transformer.d.ts.map