import { asset, IS_BROWSER } from 'fresh/runtime' import { App } from 'fresh' /** * List of css files imported by the current fresh route. */ const styles = new Map< string, { url: string; layer: string | undefined; scope: string | undefined } >() const baseRoute = '__smart_css__' /** * Generate a css scope for the given component/island based on its name. * * @param component - Component or island to scope. * @returns scope - css scope class. * * @example * ```ts * // ./(components|islands)/Button.tsx * import type { JSX } from 'preact' * import { getStyleScope, useSmartStylesheet } from './SmartStylesheet.tsx' * * const scope = getStyleScope(Button) * * export function Button(props: JSX.ButtonHTMLAttributes) { * useSmartStylesheet(import.meta, { scope }) * * return