Repository navigation
Expand file tree
/
Copy pathcss-types.d.ts
More file actions
63 lines (55 loc) · 1.81 KB
/
Copy pathcss-types.d.ts
File metadata and controls
63 lines (55 loc) · 1.81 KB
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
// Type stub for `@bomb.sh/css`: the package ships untyped JS, so this file
// pins the surface the example uses. Wired up through `paths` in the
// example tsconfig (type-checking only; runtime always loads the real
// package). The WIT world `bombshell:css@0.4.0` is the source of truth.
/// Rendering environment consulted by `@media` evaluation.
export interface Environment {
viewportWidth?: number;
viewportHeight?: number;
colorScheme?: 'light' | 'dark';
reducedMotion?: boolean;
resolution?: number;
}
/// One element of the host tree: trees ship as a flat, document-ordered
/// list plus a parallel parent-index list (`NO_PARENT` marks a root).
export interface CssNode {
tag: string;
id?: string;
classes?: string[];
attributes?: [string, string][];
/// WIT `node-state` bits: focus = 1, hover = 2, active = 4.
state?: number;
width?: number;
height?: number;
/// Inline style declarations; a real cascade slot.
style?: string;
}
export interface Diagnostic {
/// 0 = error, 1 = warning.
severity: 0 | 1;
code: string;
message: string;
}
/// A `[name, value]` computed declaration.
export type ComputedProperty = [string, string];
export interface Sheet {
readonly ir: Uint8Array;
readonly diagnostics: Diagnostic[];
compute(
nodes: CssNode[],
options: { parents: number[]; target: number; env?: Environment },
): ComputedProperty[];
computeTree(
nodes: CssNode[],
options: { parents: number[]; env?: Environment },
): ComputedProperty[][];
release(): void;
[Symbol.dispose](): void;
}
export declare function compile(css: string, origin?: number): Sheet;
export declare function computeTree(
sheet: Sheet,
options: { nodes: CssNode[]; parents: number[]; env?: Environment },
): ComputedProperty[][];
/// Parent index marking a root with no parent (u32::MAX).
export declare const NO_PARENT: number;