import { ComponentStyles } from "@microsoft/fast-jss-manager"; import { JSSManagerSubscriber, JSSStyleSheet } from "./jss-manager"; export declare type SheetTracker = [JSSStyleSheet, number]; export declare type DesignSystemRegistry = WeakMap; export declare type SheetRegistry = WeakMap, DesignSystemRegistry>; export interface JSSSheetOptions { meta?: string; index?: number; generateClassName?: (sheet: unknown, rules: unknown) => string; } /** * A class for managing instance of stylesheets. The SheetManager * tracks and associates compiled stylesheets with their style/design-system inputs, * as well as tracking number of times a style/design-system combination has been used. * Tracking this allows us to memoize compiled stylesheets and only compile a new sheet * when one does not already exist. */ export default class SheetManager { jss: any; private registry; private subscribers; /** * Creates a new JSS stylesheet from a stylesheet and design-system. * If a JSS style sheet has been created with this stylesheet and design system already, * then simply track that another instance has been added */ add(styles: ComponentStyles, designSystem: any, options?: JSSSheetOptions): void; /** * Return the compiled jss stylesheet associated with a given style object and design system */ get(styles: ComponentStyles, designSystem: any): JSSStyleSheet | void; /** * Removes a reference for a stylesheet and designSystem and adds a new reference. Useful * when the design system changes and the stylesheet should be associated with a new * design system */ update(styles: ComponentStyles, previousDesignSystem: any, nextDesignSystem: any): void; /** * Reduces the internal count for a stylesheet and designsystem. If the count becomes zero, * the sheet will be detached */ remove(styles: ComponentStyles, designSystem: any): void; /** * Returns the number of components using a stylesheet with a designSystem */ count(styles: ComponentStyles, designSystem: object): number; /** * Removes all entries */ clean(): void; /** * Retrieve the sheet tracker tracking the styles and design system */ private getTracker; /** * Creates a JSS StyleSheet and attaches it to the DOM */ private createStyleSheet; private notify; /** * Subscribe to add, update, and remove events taken by the sheet manager. * @param subscriber The subscription function to invoke */ subscribe(subscriber: JSSManagerSubscriber): () => void; unsubscribe(subscriber: JSSManagerSubscriber): void; }