UNPKG

1.67 kBTypeScriptView Raw
1import { GroupedTag, Sheet, SheetOptions } from './types';
2type SheetConstructorArgs = {
3 isServer?: boolean;
4 useCSSOMInjection?: boolean;
5 target?: HTMLElement | undefined;
6};
7type GlobalStylesAllocationMap = {
8 [key: string]: number;
9};
10type NamesAllocationMap = Map<string, Set<string>>;
11/** Contains the main stylesheet logic for stringification and caching */
12export default class StyleSheet implements Sheet {
13 gs: GlobalStylesAllocationMap;
14 names: NamesAllocationMap;
15 options: SheetOptions;
16 server: boolean;
17 tag?: GroupedTag | undefined;
18 /** Register a group ID to give it an index */
19 static registerId(id: string): number;
20 constructor(options?: SheetConstructorArgs, globalStyles?: GlobalStylesAllocationMap, names?: NamesAllocationMap | undefined);
21 reconstructWithOptions(options: SheetConstructorArgs, withNames?: boolean): StyleSheet;
22 allocateGSInstance(id: string): number;
23 /** Lazily initialises a GroupedTag for when it's actually needed */
24 getTag(): GroupedTag;
25 /** Check whether a name is known for caching */
26 hasNameForId(id: string, name: string): boolean;
27 /** Mark a group's name as known for caching */
28 registerName(id: string, name: string): void;
29 /** Insert new rules which also marks the name as known */
30 insertRules(id: string, name: string, rules: string | string[]): void;
31 /** Clears all cached names for a given group ID */
32 clearNames(id: string): void;
33 /** Clears all rules for a given group ID */
34 clearRules(id: string): void;
35 /** Clears the entire tag which deletes all rules but not its names */
36 clearTag(): void;
37}
38export {};