UNPKG

1.93 kBPlain TextView Raw
1import postcss from 'postcss';
2import { Box } from './custom-values';
3import { StylableMeta } from './stylable-meta';
4import { StylableResults } from './stylable-transformer';
5
6export type PartialObject<T> = Partial<T> & object;
7export type CSSObject = any & object;
8
9export interface ParsedValue {
10 type: string;
11 value: string;
12 nodes?: any;
13 resolvedValue?: string | Box<string, unknown>;
14 url?: string;
15}
16
17export interface StateTypeValidator {
18 name: string;
19 args: string[];
20}
21
22export type StateArguments = Array<StateTypeValidator | string>;
23
24export interface StateParsedValue {
25 type: string;
26 defaultValue?: string;
27 arguments: StateArguments;
28}
29
30export interface IStylableOptimizer {
31 classNameOptimizer: IStylableClassNameOptimizer;
32 namespaceOptimizer: IStylableNamespaceOptimizer;
33 minifyCSS(css: string): string;
34 optimize(
35 config: object,
36 stylableResult: StylableResults,
37 usageMapping: Record<string, boolean>,
38 delimiter?: string
39 ): void;
40 removeStylableDirectives(root: postcss.Root, shouldComment: boolean): void;
41}
42
43export interface IStylableClassNameOptimizer {
44 context: {
45 names: Record<string, string>;
46 };
47 rewriteSelector(
48 selector: string,
49 usageMapping: Record<string, boolean>,
50 globals: Record<string, boolean>
51 ): string;
52 generateName(name: string): string;
53 optimizeAstAndExports(
54 ast: postcss.Root,
55 exported: Record<string, string>,
56 classes: string[],
57 usageMapping: Record<string, boolean>,
58 globals?: Record<string, boolean>
59 ): void;
60}
61
62export interface IStylableNamespaceOptimizer {
63 index: number;
64 namespacePrefix: string;
65 namespaceMapping: Record<string, string>;
66 getNamespace(meta: StylableMeta, ..._env: any[]): string;
67}
68
69export type ModuleResolver = (directoryPath: string, request: string) => string;