Spaces:
Running
Running
File size: 11,120 Bytes
7dfae77 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | import { S as SourceLocation, U as UserConfig, P as Plugin } from './types-CJYAW1ql.mjs';
import { V as Variant, C as Candidate } from './resolve-config-QUZ9b-Gn.mjs';
import './colors.mjs';
declare const enum ThemeOptions {
NONE = 0,
INLINE = 1,
REFERENCE = 2,
DEFAULT = 4,
STATIC = 8,
USED = 16
}
declare class Theme {
#private;
private values;
private keyframes;
prefix: string | null;
constructor(values?: Map<string, {
value: string;
options: ThemeOptions;
src: Declaration["src"];
}>, keyframes?: Set<AtRule>);
get size(): number;
add(key: string, value: string, options?: ThemeOptions, src?: Declaration['src']): void;
keysInNamespaces(themeKeys: Iterable<ThemeKey>): string[];
get(themeKeys: ThemeKey[]): string | null;
hasDefault(key: string): boolean;
getOptions(key: string): ThemeOptions;
entries(): IterableIterator<[string, {
value: string;
options: ThemeOptions;
src: Declaration["src"];
}]> | [string, {
value: string;
options: ThemeOptions;
src: Declaration["src"];
}][];
prefixKey(key: string): string;
clearNamespace(namespace: string, clearOptions: ThemeOptions): void;
markUsedVariable(themeKey: string): boolean;
resolve(candidateValue: string | null, themeKeys: ThemeKey[], options?: ThemeOptions): string | null;
resolveValue(candidateValue: string | null, themeKeys: ThemeKey[]): string | null;
resolveWith(candidateValue: string, themeKeys: ThemeKey[], nestedKeys?: `--${string}`[]): [string, Record<string, string>] | null;
namespace(namespace: string): Map<string | null, string>;
addKeyframes(value: AtRule): void;
getKeyframes(): AtRule[];
}
type ThemeKey = `--${string}`;
type VariantFn<T extends Variant['kind']> = (rule: Rule, variant: Extract<Variant, {
kind: T;
}>) => null | void;
type CompareFn = (a: Variant, z: Variant) => number;
declare const enum Compounds {
Never = 0,
AtRules = 1,
StyleRules = 2
}
declare class Variants {
compareFns: Map<number, CompareFn>;
variants: Map<string, {
kind: Variant["kind"];
order: number;
applyFn: VariantFn<any>;
compoundsWith: Compounds;
compounds: Compounds;
}>;
private completions;
/**
* Registering a group of variants should result in the same sort number for
* all the variants. This is to ensure that the variants are applied in the
* correct order.
*/
private groupOrder;
/**
* Keep track of the last sort order instead of using the size of the map to
* avoid unnecessarily skipping order numbers.
*/
private lastOrder;
static(name: string, applyFn: VariantFn<'static'>, { compounds, order }?: {
compounds?: Compounds;
order?: number;
}): void;
fromAst(name: string, ast: AstNode[], designSystem: DesignSystem): void;
functional(name: string, applyFn: VariantFn<'functional'>, { compounds, order }?: {
compounds?: Compounds;
order?: number;
}): void;
compound(name: string, compoundsWith: Compounds, applyFn: VariantFn<'compound'>, { compounds, order }?: {
compounds?: Compounds;
order?: number;
}): void;
group(fn: () => void, compareFn?: CompareFn): void;
has(name: string): boolean;
get(name: string): {
kind: Variant["kind"];
order: number;
applyFn: VariantFn<any>;
compoundsWith: Compounds;
compounds: Compounds;
} | undefined;
kind(name: string): "arbitrary" | "static" | "functional" | "compound";
compoundsWith(parent: string, child: string | Variant): boolean;
suggest(name: string, suggestions: () => string[]): void;
getCompletions(name: string): string[];
compare(a: Variant | null, z: Variant | null): number;
keys(): IterableIterator<string>;
entries(): IterableIterator<[string, {
kind: Variant["kind"];
order: number;
applyFn: VariantFn<any>;
compoundsWith: Compounds;
compounds: Compounds;
}]>;
private set;
private nextOrder;
}
declare function compileAstNodes(candidate: Candidate, designSystem: DesignSystem, flags: CompileAstFlags): {
node: AstNode;
propertySort: {
order: number[];
count: number;
};
}[];
interface CanonicalizeOptions {
/**
* The root font size in pixels. If provided, `rem` values will be normalized
* to `px` values.
*
* E.g.: `mt-[16px]` with `rem: 16` will become `mt-4` (assuming `--spacing: 0.25rem`).
*/
rem?: number;
/**
* Whether to collapse multiple utilities into a single utility if possible.
*
* E.g.: `mt-2 mr-2 mb-2 ml-2` → `m-2`
*/
collapse?: boolean;
/**
* Whether to convert between logical and physical properties when collapsing
* utilities.
*
* E.g.: `mr-2 ml-2` → `mx-2`
*/
logicalToPhysical?: boolean;
}
interface ClassMetadata {
modifiers: string[];
}
type ClassEntry = [string, ClassMetadata];
interface SelectorOptions {
modifier?: string;
value?: string;
}
interface VariantEntry {
name: string;
isArbitrary: boolean;
values: string[];
hasDash: boolean;
selectors: (options: SelectorOptions) => string[];
}
type CompileFn<T extends Candidate['kind']> = (value: Extract<Candidate, {
kind: T;
}>) => AstNode[] | undefined | null;
interface SuggestionGroup {
supportsNegative?: boolean;
values: (string | null)[];
modifiers: string[];
}
type UtilityOptions = {
types: string[];
};
type Utility = {
kind: 'static' | 'functional';
compileFn: CompileFn<any>;
options?: UtilityOptions;
};
declare class Utilities {
private utilities;
private completions;
static(name: string, compileFn: CompileFn<'static'>): void;
functional(name: string, compileFn: CompileFn<'functional'>, options?: UtilityOptions): void;
has(name: string, kind: 'static' | 'functional'): boolean;
get(name: string): Utility[];
getCompletions(name: string): SuggestionGroup[];
suggest(name: string, groups: () => SuggestionGroup[]): void;
keys(kind: 'static' | 'functional'): string[];
}
declare const enum CompileAstFlags {
None = 0,
RespectImportant = 1
}
type DesignSystem = {
theme: Theme;
utilities: Utilities;
variants: Variants;
invalidCandidates: Set<string>;
important: boolean;
getClassOrder(classes: string[]): [string, bigint | null][];
getClassList(): ClassEntry[];
getVariants(): VariantEntry[];
parseCandidate(candidate: string): Readonly<Candidate>[];
parseVariant(variant: string): Readonly<Variant> | null;
compileAstNodes(candidate: Candidate, flags?: CompileAstFlags): ReturnType<typeof compileAstNodes>;
printCandidate(candidate: Candidate): string;
printVariant(variant: Variant): string;
getVariantOrder(): Map<Variant, number>;
resolveThemeValue(path: string, forceInline?: boolean): string | undefined;
trackUsedVariables(raw: string): void;
canonicalizeCandidates(candidates: string[], options?: CanonicalizeOptions): string[];
candidatesToCss(classes: string[]): (string | null)[];
candidatesToAst(classes: string[]): AstNode[][];
storage: Record<symbol, unknown>;
};
type StyleRule = {
kind: 'rule';
selector: string;
nodes: AstNode[];
src?: SourceLocation;
dst?: SourceLocation;
};
type AtRule = {
kind: 'at-rule';
name: string;
params: string;
nodes: AstNode[];
src?: SourceLocation;
dst?: SourceLocation;
};
type Declaration = {
kind: 'declaration';
property: string;
value: string | undefined;
important: boolean;
src?: SourceLocation;
dst?: SourceLocation;
};
type Comment = {
kind: 'comment';
value: string;
src?: SourceLocation;
dst?: SourceLocation;
};
type Context = {
kind: 'context';
context: Record<string, string | boolean>;
nodes: AstNode[];
src?: undefined;
dst?: undefined;
};
type AtRoot = {
kind: 'at-root';
nodes: AstNode[];
src?: undefined;
dst?: undefined;
};
type Rule = StyleRule | AtRule;
type AstNode = StyleRule | AtRule | Declaration | Comment | Context | AtRoot;
/**
* Line offset tables are the key to generating our source maps. They allow us
* to store indexes with our AST nodes and later convert them into positions as
* when given the source that the indexes refer to.
*/
/**
* A position in source code
*
* https://tc39.es/ecma426/#sec-position-record-type
*/
interface Position {
/** The line number, one-based */
line: number;
/** The column/character number, one-based */
column: number;
}
interface OriginalPosition extends Position {
source: DecodedSource;
}
/**
* A "decoded" sourcemap
*
* @see https://tc39.es/ecma426/#decoded-source-map-record
*/
interface DecodedSourceMap {
file: string | null;
sources: DecodedSource[];
mappings: DecodedMapping[];
}
/**
* A "decoded" source
*
* @see https://tc39.es/ecma426/#decoded-source-record
*/
interface DecodedSource {
url: string | null;
content: string | null;
ignore: boolean;
}
/**
* A "decoded" mapping
*
* @see https://tc39.es/ecma426/#decoded-mapping-record
*/
interface DecodedMapping {
originalPosition: OriginalPosition | null;
generatedPosition: Position;
name: string | null;
}
type Config = UserConfig;
declare const enum Polyfills {
None = 0,
AtProperty = 1,
ColorMix = 2,
All = 3
}
type CompileOptions = {
base?: string;
from?: string;
polyfills?: Polyfills;
loadModule?: (id: string, base: string, resourceHint: 'plugin' | 'config') => Promise<{
path: string;
base: string;
module: Plugin | Config;
}>;
loadStylesheet?: (id: string, base: string) => Promise<{
path: string;
base: string;
content: string;
}>;
};
type Root = null | 'none' | {
base: string;
pattern: string;
};
declare const enum Features {
None = 0,
AtApply = 1,
AtImport = 2,
JsPluginCompat = 4,
ThemeFunction = 8,
Utilities = 16,
Variants = 32,
AtTheme = 64
}
declare function compileAst(input: AstNode[], opts?: CompileOptions): Promise<{
sources: {
base: string;
pattern: string;
negated: boolean;
}[];
root: Root;
features: Features;
build(candidates: string[]): AstNode[];
}>;
declare function compile(css: string, opts?: CompileOptions): Promise<{
sources: {
base: string;
pattern: string;
negated: boolean;
}[];
root: Root;
features: Features;
build(candidates: string[]): string;
buildSourceMap(): DecodedSourceMap;
}>;
declare function __unstable__loadDesignSystem(css: string, opts?: CompileOptions): Promise<DesignSystem>;
declare function postcssPluginWarning(): void;
export { type Config, type DecodedSourceMap, Features, Polyfills, __unstable__loadDesignSystem, compile, compileAst, postcssPluginWarning as default };
|