Sheet.d.ts 1.7 KB

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