woby
Version:
A high-performance framework with fine-grained observable/signal-based reactivity for building rich applications.
53 lines • 1.97 kB
TypeScript
/**
* Stylesheet utility functions for the Woby framework
*
* This module provides utility functions for working with stylesheets in the browser,
* including converting document stylesheets to constructed stylesheets with caching
* and observing stylesheet changes.
*
* @module stylesheetUtils
*/
/**
* Converts all document stylesheets to constructed stylesheets with caching
*
* This function converts all stylesheets in the document to CSSStyleSheet objects
* that can be used in shadow DOM. It caches the results for performance and
* automatically invalidates the cache when stylesheets change.
*
* @returns Array of CSSStyleSheet objects representing all stylesheets in the document
*
* @example
* ```typescript
* const stylesheets = convertAllDocumentStylesToConstructed()
* shadowRoot.adoptedStyleSheets = stylesheets
* ```
*/
export declare function convertAllDocumentStylesToConstructed(): CSSStyleSheet[];
/**
* Initializes stylesheet observation to automatically invalidate cache when stylesheets change
*
* This function sets up a MutationObserver to watch for changes to the document that
* might affect stylesheets. When changes are detected, the stylesheet cache is cleared
* to ensure styles are up-to-date.
*
* @example
* ```typescript
* observeStylesheetChanges()
* const stylesheets = convertAllDocumentStylesToConstructed() // Will be cached
* // When stylesheets change, cache is automatically cleared
* ```
*/
export declare function observeStylesheetChanges(): void;
/**
* Stops observing stylesheet changes and cleans up resources
*
* This function disconnects the MutationObserver and clears the stylesheet cache.
* It should be called when the functionality is no longer needed to prevent memory leaks.
*
* @example
* ```typescript
* unobserveStylesheetChanges() // Clean up resources
* ```
*/
export declare function unobserveStylesheetChanges(): void;
//# sourceMappingURL=stylesheets.d.ts.map