@tenphi/tasty 2.11.1 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{collector-AHZaBSv8.js → collector-D0cgyN6N.js} +13 -7
- package/dist/collector-D0cgyN6N.js.map +1 -0
- package/dist/{collector-DYA5AOwr.d.ts → collector-yqgjGje7.d.ts} +10 -4
- package/dist/{config-BtK9fUaz.d.ts → config-V0XC9iz_.d.ts} +15 -2
- package/dist/{config-YDAcLaVf.js → config-_cYm9LPl.js} +68 -15
- package/dist/config-_cYm9LPl.js.map +1 -0
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +5 -5
- package/dist/{core-CS4bzqGu.js → core-DdjoZG0r.js} +21 -7
- package/dist/core-DdjoZG0r.js.map +1 -0
- package/dist/{css-writer-BXSANVrq.js → css-writer-DTUwLjgD.js} +3 -3
- package/dist/{css-writer-BXSANVrq.js.map → css-writer-DTUwLjgD.js.map} +1 -1
- package/dist/{format-rules-CYriCDwq.js → format-rules-Bu_qoamZ.js} +2 -2
- package/dist/{format-rules-CYriCDwq.js.map → format-rules-Bu_qoamZ.js.map} +1 -1
- package/dist/{hydrate-GVTorHpU.js → hydrate-CKk-rgmY.js} +2 -2
- package/dist/{hydrate-GVTorHpU.js.map → hydrate-CKk-rgmY.js.map} +1 -1
- package/dist/{index-BYtnj_gA.d.ts → index-BjnGYI5D.d.ts} +15 -7
- package/dist/{index-B9ih23uv.d.ts → index-tRick_JW.d.ts} +12 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +122 -51
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-CtcSlw4k.js → keyframes-5LJYS8_P.js} +2 -2
- package/dist/{keyframes-CtcSlw4k.js.map → keyframes-5LJYS8_P.js.map} +1 -1
- package/dist/{merge-styles-D4ITH4bc.js → merge-styles-Blrs8kLM.js} +2 -2
- package/dist/{merge-styles-D4ITH4bc.js.map → merge-styles-Blrs8kLM.js.map} +1 -1
- package/dist/{merge-styles-BZV-XAwX.d.ts → merge-styles-DDss7wRH.d.ts} +2 -2
- package/dist/{resolve-recipes-llr0COs8.js → resolve-recipes-DR5cSG3X.js} +3 -3
- package/dist/{resolve-recipes-llr0COs8.js.map → resolve-recipes-DR5cSG3X.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +3 -3
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +4 -4
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/docs/injector.md +15 -0
- package/docs/react-api.md +21 -2
- package/package.json +4 -4
- package/dist/collector-AHZaBSv8.js.map +0 -1
- package/dist/config-YDAcLaVf.js.map +0 -1
- package/dist/core-CS4bzqGu.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-rules-CYriCDwq.js","names":[],"sources":["../src/ssr/ssr-collector-ref.ts","../src/ssr/format-property.ts","../src/ssr/format-rules.ts"],"sourcesContent":["/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n | SSRCollectorGetter\n | undefined;\n return getter ? getter() : null;\n}\n","/**\n * Format @property CSS rules for SSR output.\n *\n * Replicates the CSS construction from StyleInjector.property()\n * but returns a CSS string instead of inserting into the DOM.\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { getEffectiveDefinition } from '../properties';\nimport {\n colorInitialValueToComponents,\n getColorSpaceSuffix,\n getComponentPropertySyntax,\n} from '../utils/color-space';\nimport type { StyleValue } from '../utils/styles';\nimport { parseStyle } from '../utils/styles';\n\n/**\n * Format a single @property rule as a CSS string.\n *\n * Returns the full `@property --name { ... }` text, or empty string\n * if the token is invalid. For color properties, also returns\n * the companion component property.\n */\nexport function formatPropertyCSS(\n token: string,\n definition: PropertyDefinition,\n): string {\n const result = getEffectiveDefinition(token, definition);\n if (!result.isValid) return '';\n\n const rules: string[] = [];\n\n rules.push(buildPropertyRule(result.cssName, result.definition));\n\n if (result.isColor) {\n const suffix = getColorSpaceSuffix();\n const componentCssName = `${result.cssName}-${suffix}`;\n const componentInitial = colorInitialValueToComponents(\n result.definition.initialValue,\n );\n rules.push(\n buildPropertyRule(componentCssName, {\n syntax: getComponentPropertySyntax(),\n inherits: result.definition.inherits,\n initialValue: componentInitial,\n }),\n );\n }\n\n return rules.join('\\n');\n}\n\nfunction buildPropertyRule(\n cssName: string,\n definition: PropertyDefinition,\n): string {\n const parts: string[] = [];\n\n if (definition.syntax != null) {\n let syntax = String(definition.syntax).trim();\n if (!/^['\"]/u.test(syntax)) syntax = `\"${syntax}\"`;\n parts.push(`syntax: ${syntax};`);\n }\n\n const inherits = definition.inherits ?? true;\n parts.push(`inherits: ${inherits ? 'true' : 'false'};`);\n\n if (definition.initialValue != null) {\n let initialValueStr: string;\n if (typeof definition.initialValue === 'number') {\n initialValueStr = String(definition.initialValue);\n } else {\n initialValueStr = parseStyle(\n definition.initialValue as StyleValue,\n ).output;\n }\n parts.push(`initial-value: ${initialValueStr};`);\n }\n\n const declarations = parts.join(' ').trim();\n return `@property ${cssName} { ${declarations} }`;\n}\n","/**\n * Shared CSS rule formatting utility.\n *\n * Extracted from SheetManager to allow both the DOM-based injector (client)\n * and the ServerStyleCollector (server) to produce identical CSS text\n * from StyleResult arrays.\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Resolve selectors for a rule, applying className-based specificity doubling\n * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().\n */\nfunction resolveSelector(rule: StyleResult, className: string): string {\n let selector = rule.selector;\n\n if (rule.needsClassName) {\n const selectorParts = selector ? selector.split('|||') : [''];\n const classPrefix = `.${className}.${className}`;\n\n selector = selectorParts\n .map((part) => {\n const classSelector = part ? `${classPrefix}${part}` : classPrefix;\n\n if (rule.rootPrefix) {\n return `${rule.rootPrefix} ${classSelector}`;\n }\n return classSelector;\n })\n .join(', ');\n }\n\n return selector;\n}\n\ninterface GroupedRule {\n selector: string;\n declarations: string;\n atRules?: string[];\n startingStyle?: boolean;\n}\n\n/**\n * Group rules by selector + at-rules + startingStyle and merge their declarations.\n * Mirrors the grouping logic in SheetManager.insertRule().\n */\nfunction groupRules(rules: GroupedRule[]): GroupedRule[] {\n const groupMap = new Map<string, GroupedRule>();\n const order: string[] = [];\n\n const atKey = (at?: string[]) => (at && at.length ? at.join('|') : '');\n\n for (const r of rules) {\n const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? '1' : '0'}`;\n const existing = groupMap.get(key);\n if (existing) {\n existing.declarations = existing.declarations\n ? `${existing.declarations} ${r.declarations}`\n : r.declarations;\n } else {\n groupMap.set(key, {\n selector: r.selector,\n atRules: r.atRules,\n startingStyle: r.startingStyle,\n declarations: r.declarations,\n });\n order.push(key);\n }\n }\n\n return order.map((key) => groupMap.get(key)!);\n}\n\n/**\n * Format an array of StyleResult rules into a CSS text string.\n *\n * Applies className-based specificity doubling (.cls.cls),\n * groups rules by selector + at-rules, and wraps with at-rule blocks.\n *\n * Produces the same CSS text as SheetManager.insertRule() would insert\n * into the DOM, but as a plain string suitable for SSR output.\n */\nexport function formatRules(rules: StyleResult[], className: string): string {\n if (rules.length === 0) return '';\n\n const resolvedRules = rules.map((rule) => ({\n selector: resolveSelector(rule, className),\n declarations: rule.declarations,\n atRules: rule.atRules,\n startingStyle: rule.startingStyle,\n }));\n\n const grouped = groupRules(resolvedRules);\n const cssRules: string[] = [];\n\n for (const rule of grouped) {\n const innerContent = rule.startingStyle\n ? `@starting-style { ${rule.declarations} }`\n : rule.declarations;\n const baseRule = `${rule.selector} { ${innerContent} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"format-rules-Bu_qoamZ.js","names":[],"sources":["../src/ssr/ssr-collector-ref.ts","../src/ssr/format-property.ts","../src/ssr/format-rules.ts"],"sourcesContent":["/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n | SSRCollectorGetter\n | undefined;\n return getter ? getter() : null;\n}\n","/**\n * Format @property CSS rules for SSR output.\n *\n * Replicates the CSS construction from StyleInjector.property()\n * but returns a CSS string instead of inserting into the DOM.\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { getEffectiveDefinition } from '../properties';\nimport {\n colorInitialValueToComponents,\n getColorSpaceSuffix,\n getComponentPropertySyntax,\n} from '../utils/color-space';\nimport type { StyleValue } from '../utils/styles';\nimport { parseStyle } from '../utils/styles';\n\n/**\n * Format a single @property rule as a CSS string.\n *\n * Returns the full `@property --name { ... }` text, or empty string\n * if the token is invalid. For color properties, also returns\n * the companion component property.\n */\nexport function formatPropertyCSS(\n token: string,\n definition: PropertyDefinition,\n): string {\n const result = getEffectiveDefinition(token, definition);\n if (!result.isValid) return '';\n\n const rules: string[] = [];\n\n rules.push(buildPropertyRule(result.cssName, result.definition));\n\n if (result.isColor) {\n const suffix = getColorSpaceSuffix();\n const componentCssName = `${result.cssName}-${suffix}`;\n const componentInitial = colorInitialValueToComponents(\n result.definition.initialValue,\n );\n rules.push(\n buildPropertyRule(componentCssName, {\n syntax: getComponentPropertySyntax(),\n inherits: result.definition.inherits,\n initialValue: componentInitial,\n }),\n );\n }\n\n return rules.join('\\n');\n}\n\nfunction buildPropertyRule(\n cssName: string,\n definition: PropertyDefinition,\n): string {\n const parts: string[] = [];\n\n if (definition.syntax != null) {\n let syntax = String(definition.syntax).trim();\n if (!/^['\"]/u.test(syntax)) syntax = `\"${syntax}\"`;\n parts.push(`syntax: ${syntax};`);\n }\n\n const inherits = definition.inherits ?? true;\n parts.push(`inherits: ${inherits ? 'true' : 'false'};`);\n\n if (definition.initialValue != null) {\n let initialValueStr: string;\n if (typeof definition.initialValue === 'number') {\n initialValueStr = String(definition.initialValue);\n } else {\n initialValueStr = parseStyle(\n definition.initialValue as StyleValue,\n ).output;\n }\n parts.push(`initial-value: ${initialValueStr};`);\n }\n\n const declarations = parts.join(' ').trim();\n return `@property ${cssName} { ${declarations} }`;\n}\n","/**\n * Shared CSS rule formatting utility.\n *\n * Extracted from SheetManager to allow both the DOM-based injector (client)\n * and the ServerStyleCollector (server) to produce identical CSS text\n * from StyleResult arrays.\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Resolve selectors for a rule, applying className-based specificity doubling\n * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().\n */\nfunction resolveSelector(rule: StyleResult, className: string): string {\n let selector = rule.selector;\n\n if (rule.needsClassName) {\n const selectorParts = selector ? selector.split('|||') : [''];\n const classPrefix = `.${className}.${className}`;\n\n selector = selectorParts\n .map((part) => {\n const classSelector = part ? `${classPrefix}${part}` : classPrefix;\n\n if (rule.rootPrefix) {\n return `${rule.rootPrefix} ${classSelector}`;\n }\n return classSelector;\n })\n .join(', ');\n }\n\n return selector;\n}\n\ninterface GroupedRule {\n selector: string;\n declarations: string;\n atRules?: string[];\n startingStyle?: boolean;\n}\n\n/**\n * Group rules by selector + at-rules + startingStyle and merge their declarations.\n * Mirrors the grouping logic in SheetManager.insertRule().\n */\nfunction groupRules(rules: GroupedRule[]): GroupedRule[] {\n const groupMap = new Map<string, GroupedRule>();\n const order: string[] = [];\n\n const atKey = (at?: string[]) => (at && at.length ? at.join('|') : '');\n\n for (const r of rules) {\n const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? '1' : '0'}`;\n const existing = groupMap.get(key);\n if (existing) {\n existing.declarations = existing.declarations\n ? `${existing.declarations} ${r.declarations}`\n : r.declarations;\n } else {\n groupMap.set(key, {\n selector: r.selector,\n atRules: r.atRules,\n startingStyle: r.startingStyle,\n declarations: r.declarations,\n });\n order.push(key);\n }\n }\n\n return order.map((key) => groupMap.get(key)!);\n}\n\n/**\n * Format an array of StyleResult rules into a CSS text string.\n *\n * Applies className-based specificity doubling (.cls.cls),\n * groups rules by selector + at-rules, and wraps with at-rule blocks.\n *\n * Produces the same CSS text as SheetManager.insertRule() would insert\n * into the DOM, but as a plain string suitable for SSR output.\n */\nexport function formatRules(rules: StyleResult[], className: string): string {\n if (rules.length === 0) return '';\n\n const resolvedRules = rules.map((rule) => ({\n selector: resolveSelector(rule, className),\n declarations: rule.declarations,\n atRules: rule.atRules,\n startingStyle: rule.startingStyle,\n }));\n\n const grouped = groupRules(resolvedRules);\n const cssRules: string[] = [];\n\n for (const rule of grouped) {\n const innerContent = rule.startingStyle\n ? `@starting-style { ${rule.declarations} }`\n : rule.declarations;\n const baseRule = `${rule.selector} { ${innerContent} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as getGlobalInjector } from "./config-
|
|
1
|
+
import { s as getGlobalInjector } from "./config-_cYm9LPl.js";
|
|
2
2
|
//#region src/ssr/hydrate.ts
|
|
3
3
|
/**
|
|
4
4
|
* Client-side cache hydration for SSR/RSC.
|
|
@@ -42,4 +42,4 @@ function hydrateTastyCache(state) {
|
|
|
42
42
|
//#endregion
|
|
43
43
|
export { hydrateTastyClasses as n, hydrateTastyCache as t };
|
|
44
44
|
|
|
45
|
-
//# sourceMappingURL=hydrate-
|
|
45
|
+
//# sourceMappingURL=hydrate-CKk-rgmY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate-
|
|
1
|
+
{"version":3,"file":"hydrate-CKk-rgmY.js","names":[],"sources":["../src/ssr/hydrate.ts"],"sourcesContent":["/**\n * Client-side cache hydration for SSR/RSC.\n *\n * Pre-populates the client injector's rules map with class names\n * rendered on the server. With hash-based naming, the client derives\n * the same class name from the same cache key, so only the class name\n * list needs to cross the wire — no cache keys or counters.\n */\n\nimport { getGlobalInjector } from '../config';\nimport { HYDRATED_RULE_INDEX } from '../injector/types';\n\n/**\n * Pre-populate the client-side style registry from the server's class name list.\n *\n * Call this before ReactDOM.hydrateRoot() or ensure it runs before\n * any tasty() component renders on the client.\n *\n * When called without arguments, reads the class list from `window.__TASTY__`\n * (populated by inline scripts emitted during SSR/RSC streaming).\n */\nexport function hydrateTastyClasses(classes?: string[]): void {\n if (typeof document === 'undefined') return;\n\n if (!classes) {\n classes = typeof window !== 'undefined' ? window.__TASTY__ : undefined;\n }\n\n if (!classes?.length) return;\n\n const injector = getGlobalInjector();\n const registry = injector._sheetManager.getRegistry(document);\n\n for (const cls of classes) {\n if (!registry.rules.has(cls)) {\n registry.rules.set(cls, {\n className: cls,\n ruleIndex: HYDRATED_RULE_INDEX,\n sheetIndex: HYDRATED_RULE_INDEX,\n });\n registry.refCounts.set(cls, 0);\n }\n }\n}\n\n/**\n * @deprecated Use `hydrateTastyClasses()` instead. This alias exists\n * for backwards compatibility and will be removed in a future major version.\n */\nexport function hydrateTastyCache(state?: {\n entries?: Record<string, string>;\n}): void {\n if (state?.entries) {\n hydrateTastyClasses(Object.values(state.entries));\n } else {\n hydrateTastyClasses();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,SAA0B;CAC5D,IAAI,OAAO,aAAa,aAAa;CAErC,IAAI,CAAC,SACH,UAAU,OAAO,WAAW,cAAc,OAAO,YAAY,KAAA;CAG/D,IAAI,CAAC,SAAS,QAAQ;CAGtB,MAAM,WADW,kBACO,CAAC,CAAC,cAAc,YAAY,QAAQ;CAE5D,KAAK,MAAM,OAAO,SAChB,IAAI,CAAC,SAAS,MAAM,IAAI,GAAG,GAAG;EAC5B,SAAS,MAAM,IAAI,KAAK;GACtB,WAAW;GACX,WAAA;GACA,YAAA;EACF,CAAC;EACD,SAAS,UAAU,IAAI,KAAK,CAAC;CAC/B;AAEJ;;;;;AAMA,SAAgB,kBAAkB,OAEzB;CACP,IAAI,OAAO,SACT,oBAAoB,OAAO,OAAO,MAAM,OAAO,CAAC;MAEhD,oBAAoB;AAExB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dt as StyleInjectorConfig, I as StyleValue, L as StyleValueStateMap, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, st as CSSProperties$1, x as StylesInterface, xt as KeyframesSteps } from "./index-
|
|
2
|
-
import { g as TastyPluginFactory, x as StyleInjector } from "./config-
|
|
3
|
-
import { t as ServerStyleCollector } from "./collector-
|
|
1
|
+
import { Dt as StyleInjectorConfig, I as StyleValue, L as StyleValueStateMap, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, st as CSSProperties$1, x as StylesInterface, xt as KeyframesSteps } from "./index-tRick_JW.js";
|
|
2
|
+
import { g as TastyPluginFactory, x as StyleInjector } from "./config-V0XC9iz_.js";
|
|
3
|
+
import { t as ServerStyleCollector } from "./collector-yqgjGje7.js";
|
|
4
4
|
import { AllHTMLAttributes, CSSProperties, ComponentType, ElementType, ForwardRefExoticComponent, JSX, PropsWithoutRef, RefAttributes } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/name-prefix.d.ts
|
|
@@ -434,6 +434,10 @@ interface UseGlobalStylesOptions {
|
|
|
434
434
|
* Use the `id` option for update tracking when styles change over the
|
|
435
435
|
* component lifecycle.
|
|
436
436
|
*
|
|
437
|
+
* Update tracking is per-slot and per-root: a slot (`id`, or the selector when
|
|
438
|
+
* no `id` is given) holds exactly one injection per `root`. Changing the styles
|
|
439
|
+
* replaces it; rendering styles that produce no CSS clears it.
|
|
440
|
+
*
|
|
437
441
|
* @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
|
|
438
442
|
* @param styles - Tasty styles object
|
|
439
443
|
* @param options - Optional settings including `id` for update tracking
|
|
@@ -456,9 +460,8 @@ declare function useGlobalStyles(selector: string, styles?: Styles, options?: Us
|
|
|
456
460
|
//#region src/hooks/useRawCSS.d.ts
|
|
457
461
|
interface UseRawCSSOptions {
|
|
458
462
|
/**
|
|
459
|
-
* Shadow root or document to inject into.
|
|
460
|
-
*
|
|
461
|
-
* only the root for the same id/content will not re-inject.
|
|
463
|
+
* Shadow root or document to inject into. Update tracking is per-root: the
|
|
464
|
+
* same id in two roots holds a separate injection in each.
|
|
462
465
|
*/
|
|
463
466
|
root?: Document | ShadowRoot;
|
|
464
467
|
/**
|
|
@@ -484,6 +487,11 @@ interface UseKeyframesOptions {
|
|
|
484
487
|
*
|
|
485
488
|
* Works in all environments: client, SSR with collector, and React Server Components.
|
|
486
489
|
*
|
|
490
|
+
* Passing `name` claims a slot owned by that one call site (like `useRawCSS`'s
|
|
491
|
+
* `id`): when its steps change, the previous injection is disposed and the name
|
|
492
|
+
* is reused, so the rules don't accumulate. Anonymous keyframes are permanent
|
|
493
|
+
* and shared by content.
|
|
494
|
+
*
|
|
487
495
|
* @example Basic usage - steps object is the dependency
|
|
488
496
|
* ```tsx
|
|
489
497
|
* function MyComponent() {
|
|
@@ -1775,4 +1783,4 @@ declare const tastyDebug: {
|
|
|
1775
1783
|
};
|
|
1776
1784
|
//#endregion
|
|
1777
1785
|
export { UsePropertyOptions as $, BLOCK_OUTER_STYLES as $t, chunkSheetRegistry as A, BlockInnerStyleProps as At, DISPLAY_CHUNK_STYLES as B, Mods as Bt, injectRawCSS as C, VariantMap as Ct, property$1 as D, BaseProps as Dt, keyframes as E, AllBaseProps as Et, APPEARANCE_CHUNK_STYLES as F, DimensionStyleProps as Ft, categorizeStyleKeys as G, TagName as Gt, LAYOUT_CHUNK_STYLES as H, PositionStyleProps as Ht, CHUNK_NAMES as I, FlowStyleProps as It, okhslFunc as J, TextStyleProps as Jt, okhstFunc as K, TastyExtensionConfig as Kt, ChunkInfo$1 as L, GlobalStyledProps as Lt, ComputeStylesResult as M, BlockStyleProps as Mt, computeStyles as N, ColorStyleProps as Nt, touch as O, BasePropsWithoutChildren as Ot, styleHandlers as P, ContainerStyleProps as Pt, useFontFace as Q, BLOCK_INNER_STYLES as Qt, ChunkName as R, InnerStyleProps as Rt, injectGlobal as S, TokenPropsInput as St, isPropertyDefined as T, tasty as Tt, POSITION_CHUNK_STYLES as U, Props as Ut, FONT_CHUNK_STYLES as V, OuterStyleProps as Vt, STYLE_TO_CHUNK as W, ShortGridStyles as Wt, getDisplayName as X, Tokens as Xt, okhslPlugin as Y, TokenValue as Yt, useCounterStyle as Z, BASE_STYLES as Zt, getCssText as _, SubElementProps as _t, resolveRecipes as a, INNER_STYLES as an, UseStylesResult as at, getRawCSSText as b, TastyPolymorphicComponent as bt, color$1 as c, TEXT_STYLES as cn, Element$1 as ct, cleanup as d, ModPropsInput as dt, BLOCK_STYLES as en, useProperty as et, counterStyle as f, ResolveAsProps as ft, gc as g, SubElementDefinition as gt, fontFace as h, ResolveTokenProps as ht, warn as i, FLOW_STYLES as in, UseStylesOptions as it, ComputeStylesOptions as j, BlockOuterStyleProps as jt, ChunkSheetRegistry as k, BaseStyleProps as kt, filterBaseProps as l, DEFAULT_NAME_PREFIX as ln, ElementsDefinition as lt, destroy as m, ResolveModProps as mt, processTokens as n, CONTAINER_STYLES as nn, useRawCSS as nt, dotize as o, OUTER_STYLES as on, useStyles as ot, createInjector as p, ResolveModPropDef as pt, okhstPlugin as q, TastyThemeNames as qt, deprecationWarning as r, DIMENSION_STYLES as rn, useGlobalStyles as rt, _modAttrs as s, POSITION_STYLES as sn, AllBasePropsWithMods as st, tastyDebug as t, COLOR_STYLES as tn, useKeyframes as tt, PropertyOptions as u, DEFAULT_ZERO_NAME_PREFIX as un, ModPropDef as ut, getCssTextForNode as v, TastyElementOptions as vt, injector as w, WithVariant as wt, inject as x, TastyProps as xt, getIsTestEnvironment as y, TastyElementProps as yt, DIMENSION_CHUNK_STYLES as z, ModValue as zt };
|
|
1778
|
-
//# sourceMappingURL=index-
|
|
1786
|
+
//# sourceMappingURL=index-BjnGYI5D.d.ts.map
|
|
@@ -119,6 +119,17 @@ interface SheetInfo {
|
|
|
119
119
|
constructableSheet?: CSSStyleSheet;
|
|
120
120
|
ruleCount: number;
|
|
121
121
|
holes: number[];
|
|
122
|
+
/**
|
|
123
|
+
* True when this sheet is written through `textContent` instead of CSSOM.
|
|
124
|
+
* Decided once at sheet creation so a sheet is never half CSSOM / half text.
|
|
125
|
+
*/
|
|
126
|
+
textMode?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Inserted rule texts in rule-index order. Maintained only in text mode —
|
|
129
|
+
* it is what makes deletion possible there, since `textContent` cannot be
|
|
130
|
+
* edited rule-by-rule and has to be rebuilt.
|
|
131
|
+
*/
|
|
132
|
+
textRules?: string[];
|
|
122
133
|
}
|
|
123
134
|
interface CleanupStats {
|
|
124
135
|
timestamp: number;
|
|
@@ -1292,4 +1303,4 @@ declare function renderStyles(styles?: Styles, classNameOrSelector?: undefined,
|
|
|
1292
1303
|
declare function renderStyles(styles: Styles | undefined, classNameOrSelector: string, options?: RenderStylesOptions): StyleResult[];
|
|
1293
1304
|
//#endregion
|
|
1294
1305
|
export { strToRgb as $, RawStyleHandler as A, getGlobalFuncs as B, SuffixForSelector as C, RawCSSResult as Ct, CUSTOM_UNITS as D, StyleInjectorConfig as Dt, CSSMap as E, SheetInfo as Et, StylePropValue as F, parseStyle as G, getGlobalPredefinedTokens as H, StyleValue as I, stringifyStyles as J, resetGlobalPredefinedTokens as K, StyleValueStateMap as L, StyleHandlerDefinition as M, StyleHandlerResult as N, DIRECTIONS as O, StyleRule as Ot, StyleMap as P, hslToRgbValues as Q, customFunc as R, StylesWithoutSelectors as S, PropertyDefinition as St, TastyPresetNames as T, RuleInfo as Tt, normalizeColorTokenValue as U, getGlobalParser as V, parseColor as W, getRgbValuesFromRgbaString as X, getNamedColorHex as Y, hexToRgb as Z, NotSelector as _, InjectionMode as _t, ParseStateKeyOptions as a, StyleDetailsPart as at, Styles as b, KeyframesResult as bt, ParsedAdvancedState as c, CacheMetrics as ct, getGlobalPredefinedStates as d, FontFaceDescriptors as dt, StyleParser as et, setGlobalPredefinedStates as f, FontFaceInput as ft, NoType as g, InjectResult as gt, ConfigTokens as h, GlobalInjectResult as ht, renderStyles as i, StyleDetails as it, StyleHandler as j, ParsedColor as k, StyleUsage as kt, StateParserContext as l, CounterStyleDescriptors as lt, ConfigTokenValue as m, GCOptions as mt, StyleResult as n, ParserOptions as nt, parseStateKey as o, UnitHandler as ot, ConditionNode as p, GCConfig as pt, setGlobalPredefinedTokens as q, isSelector as r, ProcessedStyle as rt, AtRuleContext as s, CSSProperties as st, RenderResult as t, Bucket as tt, createStateParserContext as u, DisposeFunction as ut, RecipeStyles as v, KeyframesCacheEntry as vt, TastyNamedColors as w, RootRegistry as wt, StylesInterface as x, KeyframesSteps as xt, Selector as y, KeyframesInfo as yt, filterMods as z };
|
|
1295
|
-
//# sourceMappingURL=index-
|
|
1306
|
+
//# sourceMappingURL=index-tRick_JW.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as strToRgb, A as RawStyleHandler, B as getGlobalFuncs, C as SuffixForSelector, Ct as RawCSSResult, D as CUSTOM_UNITS, Dt as StyleInjectorConfig, E as CSSMap, Et as SheetInfo, F as StylePropValue, G as parseStyle, H as getGlobalPredefinedTokens, I as StyleValue, J as stringifyStyles, K as resetGlobalPredefinedTokens, L as StyleValueStateMap, M as StyleHandlerDefinition, N as StyleHandlerResult, O as DIRECTIONS, Ot as StyleRule, P as StyleMap, Q as hslToRgbValues, R as customFunc, S as StylesWithoutSelectors, St as PropertyDefinition, T as TastyPresetNames, Tt as RuleInfo, U as normalizeColorTokenValue, V as getGlobalParser, W as parseColor, X as getRgbValuesFromRgbaString, Y as getNamedColorHex, Z as hexToRgb, _ as NotSelector, _t as InjectionMode, a as ParseStateKeyOptions, at as StyleDetailsPart, b as Styles, bt as KeyframesResult, c as ParsedAdvancedState, ct as CacheMetrics, d as getGlobalPredefinedStates, dt as FontFaceDescriptors, et as StyleParser, f as setGlobalPredefinedStates, ft as FontFaceInput, g as NoType, gt as InjectResult, h as ConfigTokens, i as renderStyles, it as StyleDetails, j as StyleHandler, k as ParsedColor, kt as StyleUsage, l as StateParserContext, lt as CounterStyleDescriptors, m as ConfigTokenValue, mt as GCOptions, n as StyleResult, nt as ParserOptions, o as parseStateKey, ot as UnitHandler, p as ConditionNode, pt as GCConfig, q as setGlobalPredefinedTokens, r as isSelector, rt as ProcessedStyle, s as AtRuleContext, st as CSSProperties, t as RenderResult, tt as Bucket, u as createStateParserContext, ut as DisposeFunction, v as RecipeStyles, vt as KeyframesCacheEntry, w as TastyNamedColors, wt as RootRegistry, x as StylesInterface, xt as KeyframesSteps, y as Selector, yt as KeyframesInfo, z as filterMods } from "./index-
|
|
2
|
-
import { S as SheetManager, _ as TypographyPreset, a as getGlobalFontFace, b as ColorSpace, c as getNamePrefix, d as hasStylesGenerated, f as isConfigLocked, g as TastyPluginFactory, h as TastyPlugin, i as getGlobalCounterStyle, l as hasGlobalKeyframes, m as resetConfig, n as configure, o as getGlobalKeyframes, p as isTestEnvironment, r as getConfig, s as getGlobalRecipes, t as TastyConfig, u as hasGlobalRecipes, v as TypographyTokenValue, x as StyleInjector, y as generateTypographyTokens } from "./config-
|
|
3
|
-
import { $ as UsePropertyOptions, $t as BLOCK_OUTER_STYLES, A as chunkSheetRegistry, At as BlockInnerStyleProps, B as DISPLAY_CHUNK_STYLES, Bt as Mods, C as injectRawCSS, Ct as VariantMap, D as property, Dt as BaseProps, E as keyframes, Et as AllBaseProps, F as APPEARANCE_CHUNK_STYLES, Ft as DimensionStyleProps, G as categorizeStyleKeys, Gt as TagName, H as LAYOUT_CHUNK_STYLES, Ht as PositionStyleProps, I as CHUNK_NAMES, It as FlowStyleProps, J as okhslFunc, Jt as TextStyleProps, K as okhstFunc, Kt as TastyExtensionConfig, L as ChunkInfo, Lt as GlobalStyledProps, M as ComputeStylesResult, Mt as BlockStyleProps, N as computeStyles, Nt as ColorStyleProps, O as touch, Ot as BasePropsWithoutChildren, P as styleHandlers, Pt as ContainerStyleProps, Q as useFontFace, Qt as BLOCK_INNER_STYLES, R as ChunkName, Rt as InnerStyleProps, S as injectGlobal, St as TokenPropsInput, T as isPropertyDefined, Tt as tasty, U as POSITION_CHUNK_STYLES, Ut as Props, V as FONT_CHUNK_STYLES, Vt as OuterStyleProps, W as STYLE_TO_CHUNK, Wt as ShortGridStyles, X as getDisplayName, Xt as Tokens, Y as okhslPlugin, Yt as TokenValue, Z as useCounterStyle, Zt as BASE_STYLES, _ as getCssText, _t as SubElementProps, a as resolveRecipes, an as INNER_STYLES, at as UseStylesResult, b as getRawCSSText, bt as TastyPolymorphicComponent, c as color, cn as TEXT_STYLES, ct as Element, d as cleanup, dt as ModPropsInput, en as BLOCK_STYLES, et as useProperty, f as counterStyle, ft as ResolveAsProps, g as gc, gt as SubElementDefinition, h as fontFace, ht as ResolveTokenProps, i as warn, in as FLOW_STYLES, it as UseStylesOptions, j as ComputeStylesOptions, jt as BlockOuterStyleProps, k as ChunkSheetRegistry, kt as BaseStyleProps, l as filterBaseProps, ln as DEFAULT_NAME_PREFIX, lt as ElementsDefinition, m as destroy, mt as ResolveModProps, n as processTokens, nn as CONTAINER_STYLES, nt as useRawCSS, o as dotize, on as OUTER_STYLES, ot as useStyles, p as createInjector, pt as ResolveModPropDef, q as okhstPlugin, qt as TastyThemeNames, r as deprecationWarning, rn as DIMENSION_STYLES, rt as useGlobalStyles, s as _modAttrs, sn as POSITION_STYLES, st as AllBasePropsWithMods, t as tastyDebug, tn as COLOR_STYLES, tt as useKeyframes, u as PropertyOptions, un as DEFAULT_ZERO_NAME_PREFIX, ut as ModPropDef, v as getCssTextForNode, vt as TastyElementOptions, w as injector, wt as WithVariant, x as inject, xt as TastyProps, y as getIsTestEnvironment, yt as TastyElementProps, z as DIMENSION_CHUNK_STYLES, zt as ModValue } from "./index-
|
|
4
|
-
import { t as mergeStyles } from "./merge-styles-
|
|
1
|
+
import { $ as strToRgb, A as RawStyleHandler, B as getGlobalFuncs, C as SuffixForSelector, Ct as RawCSSResult, D as CUSTOM_UNITS, Dt as StyleInjectorConfig, E as CSSMap, Et as SheetInfo, F as StylePropValue, G as parseStyle, H as getGlobalPredefinedTokens, I as StyleValue, J as stringifyStyles, K as resetGlobalPredefinedTokens, L as StyleValueStateMap, M as StyleHandlerDefinition, N as StyleHandlerResult, O as DIRECTIONS, Ot as StyleRule, P as StyleMap, Q as hslToRgbValues, R as customFunc, S as StylesWithoutSelectors, St as PropertyDefinition, T as TastyPresetNames, Tt as RuleInfo, U as normalizeColorTokenValue, V as getGlobalParser, W as parseColor, X as getRgbValuesFromRgbaString, Y as getNamedColorHex, Z as hexToRgb, _ as NotSelector, _t as InjectionMode, a as ParseStateKeyOptions, at as StyleDetailsPart, b as Styles, bt as KeyframesResult, c as ParsedAdvancedState, ct as CacheMetrics, d as getGlobalPredefinedStates, dt as FontFaceDescriptors, et as StyleParser, f as setGlobalPredefinedStates, ft as FontFaceInput, g as NoType, gt as InjectResult, h as ConfigTokens, i as renderStyles, it as StyleDetails, j as StyleHandler, k as ParsedColor, kt as StyleUsage, l as StateParserContext, lt as CounterStyleDescriptors, m as ConfigTokenValue, mt as GCOptions, n as StyleResult, nt as ParserOptions, o as parseStateKey, ot as UnitHandler, p as ConditionNode, pt as GCConfig, q as setGlobalPredefinedTokens, r as isSelector, rt as ProcessedStyle, s as AtRuleContext, st as CSSProperties, t as RenderResult, tt as Bucket, u as createStateParserContext, ut as DisposeFunction, v as RecipeStyles, vt as KeyframesCacheEntry, w as TastyNamedColors, wt as RootRegistry, x as StylesInterface, xt as KeyframesSteps, y as Selector, yt as KeyframesInfo, z as filterMods } from "./index-tRick_JW.js";
|
|
2
|
+
import { S as SheetManager, _ as TypographyPreset, a as getGlobalFontFace, b as ColorSpace, c as getNamePrefix, d as hasStylesGenerated, f as isConfigLocked, g as TastyPluginFactory, h as TastyPlugin, i as getGlobalCounterStyle, l as hasGlobalKeyframes, m as resetConfig, n as configure, o as getGlobalKeyframes, p as isTestEnvironment, r as getConfig, s as getGlobalRecipes, t as TastyConfig, u as hasGlobalRecipes, v as TypographyTokenValue, x as StyleInjector, y as generateTypographyTokens } from "./config-V0XC9iz_.js";
|
|
3
|
+
import { $ as UsePropertyOptions, $t as BLOCK_OUTER_STYLES, A as chunkSheetRegistry, At as BlockInnerStyleProps, B as DISPLAY_CHUNK_STYLES, Bt as Mods, C as injectRawCSS, Ct as VariantMap, D as property, Dt as BaseProps, E as keyframes, Et as AllBaseProps, F as APPEARANCE_CHUNK_STYLES, Ft as DimensionStyleProps, G as categorizeStyleKeys, Gt as TagName, H as LAYOUT_CHUNK_STYLES, Ht as PositionStyleProps, I as CHUNK_NAMES, It as FlowStyleProps, J as okhslFunc, Jt as TextStyleProps, K as okhstFunc, Kt as TastyExtensionConfig, L as ChunkInfo, Lt as GlobalStyledProps, M as ComputeStylesResult, Mt as BlockStyleProps, N as computeStyles, Nt as ColorStyleProps, O as touch, Ot as BasePropsWithoutChildren, P as styleHandlers, Pt as ContainerStyleProps, Q as useFontFace, Qt as BLOCK_INNER_STYLES, R as ChunkName, Rt as InnerStyleProps, S as injectGlobal, St as TokenPropsInput, T as isPropertyDefined, Tt as tasty, U as POSITION_CHUNK_STYLES, Ut as Props, V as FONT_CHUNK_STYLES, Vt as OuterStyleProps, W as STYLE_TO_CHUNK, Wt as ShortGridStyles, X as getDisplayName, Xt as Tokens, Y as okhslPlugin, Yt as TokenValue, Z as useCounterStyle, Zt as BASE_STYLES, _ as getCssText, _t as SubElementProps, a as resolveRecipes, an as INNER_STYLES, at as UseStylesResult, b as getRawCSSText, bt as TastyPolymorphicComponent, c as color, cn as TEXT_STYLES, ct as Element, d as cleanup, dt as ModPropsInput, en as BLOCK_STYLES, et as useProperty, f as counterStyle, ft as ResolveAsProps, g as gc, gt as SubElementDefinition, h as fontFace, ht as ResolveTokenProps, i as warn, in as FLOW_STYLES, it as UseStylesOptions, j as ComputeStylesOptions, jt as BlockOuterStyleProps, k as ChunkSheetRegistry, kt as BaseStyleProps, l as filterBaseProps, ln as DEFAULT_NAME_PREFIX, lt as ElementsDefinition, m as destroy, mt as ResolveModProps, n as processTokens, nn as CONTAINER_STYLES, nt as useRawCSS, o as dotize, on as OUTER_STYLES, ot as useStyles, p as createInjector, pt as ResolveModPropDef, q as okhstPlugin, qt as TastyThemeNames, r as deprecationWarning, rn as DIMENSION_STYLES, rt as useGlobalStyles, s as _modAttrs, sn as POSITION_STYLES, st as AllBasePropsWithMods, t as tastyDebug, tn as COLOR_STYLES, tt as useKeyframes, u as PropertyOptions, un as DEFAULT_ZERO_NAME_PREFIX, ut as ModPropDef, v as getCssTextForNode, vt as TastyElementOptions, w as injector, wt as WithVariant, x as inject, xt as TastyProps, y as getIsTestEnvironment, yt as TastyElementProps, z as DIMENSION_CHUNK_STYLES, zt as ModValue } from "./index-BjnGYI5D.js";
|
|
4
|
+
import { t as mergeStyles } from "./merge-styles-DDss7wRH.js";
|
|
5
5
|
export { APPEARANCE_CHUNK_STYLES, type AllBaseProps, type AllBasePropsWithMods, type AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, type BaseStyleProps, type BlockInnerStyleProps, type BlockOuterStyleProps, type BlockStyleProps, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CSSMap, type CSSProperties, CUSTOM_UNITS, type CacheMetrics, type ChunkInfo, type ChunkName, ChunkSheetRegistry, type ColorSpace, type ColorStyleProps, type ComputeStylesOptions, type ComputeStylesResult, type ConditionNode, type ConfigTokenValue, type ConfigTokens, type ContainerStyleProps, type CounterStyleDescriptors, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_CHUNK_STYLES, DIMENSION_STYLES, DIRECTIONS, DISPLAY_CHUNK_STYLES, type DimensionStyleProps, type DisposeFunction, Element, type ElementsDefinition, FLOW_STYLES, FONT_CHUNK_STYLES, type FlowStyleProps, type FontFaceDescriptors, type FontFaceInput, type GCConfig, type GCOptions, type GlobalStyledProps, INNER_STYLES, type InjectResult, type InjectionMode, type InnerStyleProps, type KeyframesCacheEntry, type KeyframesInfo, type KeyframesResult, type KeyframesSteps, LAYOUT_CHUNK_STYLES, type ModPropDef, type ModPropsInput, type ModValue, type Mods, type NoType, type NotSelector, OUTER_STYLES, type OuterStyleProps, POSITION_CHUNK_STYLES, POSITION_STYLES, type ParseStateKeyOptions, type ParsedAdvancedState, ParsedColor, type ParserOptions, type PositionStyleProps, type ProcessedStyle, type PropertyDefinition, PropertyOptions, type Props, type RawCSSResult, RawStyleHandler, type RecipeStyles, type RenderResult, type ResolveAsProps, type ResolveModPropDef, type ResolveModProps, type ResolveTokenProps, type RootRegistry, type RuleInfo, STYLE_TO_CHUNK, type Selector, type SheetInfo, SheetManager, type ShortGridStyles, type StateParserContext, type StyleDetails, type StyleDetailsPart, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleInjector, type StyleInjectorConfig, StyleMap, StyleParser, StylePropValue, type StyleResult, type StyleRule, type StyleUsage, StyleValue, StyleValueStateMap, type Styles, type StylesInterface, type StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, type SuffixForSelector, TEXT_STYLES, type TagName, type TastyConfig, type TastyElementOptions, type TastyElementProps, type TastyExtensionConfig, type TastyNamedColors, type TastyPlugin, type TastyPluginFactory, type TastyPolymorphicComponent, type TastyPresetNames, type TastyProps, type TastyThemeNames, type TextStyleProps, type TokenPropsInput, type TokenValue, type Tokens, TypographyPreset, TypographyTokenValue, type UnitHandler, type UsePropertyOptions, type UseStylesOptions, type UseStylesResult, type VariantMap, type WithVariant, categorizeStyleKeys, chunkSheetRegistry, cleanup, color, computeStyles, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, gc, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamePrefix, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, okhstFunc, okhstPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as parseColor, A as StyleInjector, B as styleHandlers, C as parseStateKey, Dt as hslToRgbValues, Et as hexToRgb, F as fontFaceContentHash, G as CUSTOM_UNITS, H as warn, I as formatFontFaceRule, J as filterMods, K as DIRECTIONS, M as formatCounterStyleRule, O as getGlobalPredefinedStates, Ot as strToRgb, Q as normalizeColorTokenValue, R as SheetManager, S as renderStyles, T as createStateParserContext, Tt as getRgbValuesFromRgbaString, V as deprecationWarning, X as getGlobalParser, Y as getGlobalFuncs, Z as getGlobalPredefinedTokens, a as getGlobalCounterStyle, at as okhstPlugin, c as getGlobalKeyframes, ct as StyleParser, d as getNamePrefix, dt as DEFAULT_ZERO_NAME_PREFIX, et as parseStyle, f as hasGlobalKeyframes, g as isTestEnvironment, h as isConfigLocked, it as okhstFunc, k as setGlobalPredefinedStates, l as getGlobalRecipes, lt as Bucket, m as hasStylesGenerated, mt as makeKeyframeName, n as getConfig, nt as setGlobalPredefinedTokens, o as getGlobalFontFace, ot as okhslFunc, p as hasGlobalRecipes, pt as makeCounterStyleName, q as customFunc, rt as stringifyStyles, s as getGlobalInjector, st as okhslPlugin, t as configure, tt as resetGlobalPredefinedTokens, ut as DEFAULT_NAME_PREFIX, v as resetConfig, vt as hashString, wt as getNamedColorHex, x as isSelector, y as generateTypographyTokens } from "./config-
|
|
2
|
-
import { _ as categorizeStyleKeys, d as DIMENSION_CHUNK_STYLES, f as DISPLAY_CHUNK_STYLES, g as STYLE_TO_CHUNK, h as POSITION_CHUNK_STYLES, l as APPEARANCE_CHUNK_STYLES, m as LAYOUT_CHUNK_STYLES, p as FONT_CHUNK_STYLES, u as CHUNK_NAMES } from "./keyframes-
|
|
3
|
-
import { A as property, B as DIMENSION_STYLES, C as getRawCSSText, D as injector, E as injectRawCSS, F as BLOCK_INNER_STYLES, G as TEXT_STYLES, H as INNER_STYLES, I as BLOCK_OUTER_STYLES, L as BLOCK_STYLES, M as ChunkSheetRegistry, N as chunkSheetRegistry, O as isPropertyDefined, P as BASE_STYLES, R as COLOR_STYLES, S as getIsTestEnvironment, T as injectGlobal, U as OUTER_STYLES, V as FLOW_STYLES, W as POSITION_STYLES, _ as destroy, a as color, b as getCssText, c as hasKeys, d as collectAutoInferredPropertiesRSC, f as getStyleTarget, g as createInjector, h as counterStyle, i as _modAttrs, j as touch, k as keyframes, l as formatKeyframesCSS, m as cleanup, n as processTokens, o as filterBaseProps, p as pushRSCCSS, r as dotize, s as computeStyles, t as tastyDebug, u as collectAutoInferredProperties, v as fontFace, w as inject, x as getCssTextForNode, y as gc, z as CONTAINER_STYLES } from "./core-
|
|
4
|
-
import { n as formatPropertyCSS } from "./format-rules-
|
|
5
|
-
import { t as mergeStyles } from "./merge-styles-
|
|
6
|
-
import { t as resolveRecipes } from "./resolve-recipes-
|
|
1
|
+
import { $ as parseColor, A as StyleInjector, B as styleHandlers, C as parseStateKey, Dt as hslToRgbValues, Et as hexToRgb, F as fontFaceContentHash, G as CUSTOM_UNITS, H as warn, I as formatFontFaceRule, J as filterMods, K as DIRECTIONS, M as formatCounterStyleRule, O as getGlobalPredefinedStates, Ot as strToRgb, Q as normalizeColorTokenValue, R as SheetManager, S as renderStyles, T as createStateParserContext, Tt as getRgbValuesFromRgbaString, V as deprecationWarning, X as getGlobalParser, Y as getGlobalFuncs, Z as getGlobalPredefinedTokens, a as getGlobalCounterStyle, at as okhstPlugin, c as getGlobalKeyframes, ct as StyleParser, d as getNamePrefix, dt as DEFAULT_ZERO_NAME_PREFIX, et as parseStyle, f as hasGlobalKeyframes, g as isTestEnvironment, h as isConfigLocked, it as okhstFunc, k as setGlobalPredefinedStates, l as getGlobalRecipes, lt as Bucket, m as hasStylesGenerated, mt as makeKeyframeName, n as getConfig, nt as setGlobalPredefinedTokens, o as getGlobalFontFace, ot as okhslFunc, p as hasGlobalRecipes, pt as makeCounterStyleName, q as customFunc, rt as stringifyStyles, s as getGlobalInjector, st as okhslPlugin, t as configure, tt as resetGlobalPredefinedTokens, ut as DEFAULT_NAME_PREFIX, v as resetConfig, vt as hashString, wt as getNamedColorHex, x as isSelector, y as generateTypographyTokens } from "./config-_cYm9LPl.js";
|
|
2
|
+
import { _ as categorizeStyleKeys, d as DIMENSION_CHUNK_STYLES, f as DISPLAY_CHUNK_STYLES, g as STYLE_TO_CHUNK, h as POSITION_CHUNK_STYLES, l as APPEARANCE_CHUNK_STYLES, m as LAYOUT_CHUNK_STYLES, p as FONT_CHUNK_STYLES, u as CHUNK_NAMES } from "./keyframes-5LJYS8_P.js";
|
|
3
|
+
import { A as property, B as DIMENSION_STYLES, C as getRawCSSText, D as injector, E as injectRawCSS, F as BLOCK_INNER_STYLES, G as TEXT_STYLES, H as INNER_STYLES, I as BLOCK_OUTER_STYLES, L as BLOCK_STYLES, M as ChunkSheetRegistry, N as chunkSheetRegistry, O as isPropertyDefined, P as BASE_STYLES, R as COLOR_STYLES, S as getIsTestEnvironment, T as injectGlobal, U as OUTER_STYLES, V as FLOW_STYLES, W as POSITION_STYLES, _ as destroy, a as color, b as getCssText, c as hasKeys, d as collectAutoInferredPropertiesRSC, f as getStyleTarget, g as createInjector, h as counterStyle, i as _modAttrs, j as touch, k as keyframes, l as formatKeyframesCSS, m as cleanup, n as processTokens, o as filterBaseProps, p as pushRSCCSS, r as dotize, s as computeStyles, t as tastyDebug, u as collectAutoInferredProperties, v as fontFace, w as inject, x as getCssTextForNode, y as gc, z as CONTAINER_STYLES } from "./core-DdjoZG0r.js";
|
|
4
|
+
import { n as formatPropertyCSS } from "./format-rules-Bu_qoamZ.js";
|
|
5
|
+
import { t as mergeStyles } from "./merge-styles-Blrs8kLM.js";
|
|
6
|
+
import { t as resolveRecipes } from "./resolve-recipes-DR5cSG3X.js";
|
|
7
7
|
import { t as getTastySSRContext } from "./context-CA8YKeMn.js";
|
|
8
8
|
import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
|
|
9
9
|
import { Fragment, createElement, forwardRef, useContext } from "react";
|
|
@@ -287,8 +287,41 @@ function useStyles(styles, options) {
|
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
|
+
//#region src/utils/client-state.ts
|
|
291
|
+
/**
|
|
292
|
+
* Build a per-(injector, root) client state cache for the standalone style
|
|
293
|
+
* functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useCounterStyle`).
|
|
294
|
+
*
|
|
295
|
+
* Two levels, both weak:
|
|
296
|
+
*
|
|
297
|
+
* - **injector** — `configure()` replaces the global injector, and every dispose
|
|
298
|
+
* handle and generated name we cache belongs to the one that produced it.
|
|
299
|
+
* Keying by injector makes stale state fall away with it, instead of letting
|
|
300
|
+
* change-detection keys suppress re-injection into the new sheets.
|
|
301
|
+
* - **root** — the same selector or slot name can be used in several shadow
|
|
302
|
+
* roots, and each holds its own injection.
|
|
303
|
+
*/
|
|
304
|
+
function createClientState(create) {
|
|
305
|
+
const byInjector = /* @__PURE__ */ new WeakMap();
|
|
306
|
+
return (root) => {
|
|
307
|
+
const injector = getGlobalInjector();
|
|
308
|
+
let byRoot = byInjector.get(injector);
|
|
309
|
+
if (!byRoot) {
|
|
310
|
+
byRoot = /* @__PURE__ */ new WeakMap();
|
|
311
|
+
byInjector.set(injector, byRoot);
|
|
312
|
+
}
|
|
313
|
+
let state = byRoot.get(root);
|
|
314
|
+
if (!state) {
|
|
315
|
+
state = create();
|
|
316
|
+
byRoot.set(root, state);
|
|
317
|
+
}
|
|
318
|
+
return state;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
290
322
|
//#region src/hooks/useGlobalStyles.ts
|
|
291
|
-
const
|
|
323
|
+
const getClientGlobalSlots = createClientState(() => /* @__PURE__ */ new Map());
|
|
324
|
+
const noop = () => {};
|
|
292
325
|
/**
|
|
293
326
|
* Inject global styles for a given selector.
|
|
294
327
|
* Useful for styling elements by selector without generating classNames.
|
|
@@ -302,6 +335,10 @@ const clientGlobalEntries = /* @__PURE__ */ new Map();
|
|
|
302
335
|
* Use the `id` option for update tracking when styles change over the
|
|
303
336
|
* component lifecycle.
|
|
304
337
|
*
|
|
338
|
+
* Update tracking is per-slot and per-root: a slot (`id`, or the selector when
|
|
339
|
+
* no `id` is given) holds exactly one injection per `root`. Changing the styles
|
|
340
|
+
* replaces it; rendering styles that produce no CSS clears it.
|
|
341
|
+
*
|
|
305
342
|
* @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
|
|
306
343
|
* @param styles - Tasty styles object
|
|
307
344
|
* @param options - Optional settings including `id` for update tracking
|
|
@@ -326,21 +363,29 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
326
363
|
return;
|
|
327
364
|
}
|
|
328
365
|
const target = getStyleTarget();
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
366
|
+
const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
|
|
367
|
+
const slotKey = options?.id ?? selector;
|
|
368
|
+
const stylesKey = slots ? JSON.stringify(styles) : "";
|
|
369
|
+
const existing = slots?.get(slotKey);
|
|
370
|
+
if (existing && existing.stylesKey === stylesKey) return;
|
|
335
371
|
const resolvedStyles = resolveRecipes(styles);
|
|
336
372
|
const styleResults = renderStyles(resolvedStyles, selector);
|
|
337
|
-
if (styleResults.length === 0)
|
|
373
|
+
if (styleResults.length === 0) {
|
|
374
|
+
if (slots) {
|
|
375
|
+
existing?.dispose();
|
|
376
|
+
slots.set(slotKey, {
|
|
377
|
+
stylesKey,
|
|
378
|
+
dispose: noop
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
338
383
|
if (target.mode === "ssr") {
|
|
339
384
|
target.collector.collectInternals();
|
|
340
385
|
const css = formatGlobalRules(styleResults);
|
|
341
386
|
if (css) {
|
|
342
387
|
const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
|
|
343
|
-
target.collector.collectGlobalStyles(key, css);
|
|
388
|
+
target.collector.collectGlobalStyles(key, css, options?.id != null);
|
|
344
389
|
}
|
|
345
390
|
if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
|
|
346
391
|
return;
|
|
@@ -349,19 +394,19 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
349
394
|
const css = formatGlobalRules(styleResults);
|
|
350
395
|
if (css) {
|
|
351
396
|
const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
|
|
352
|
-
pushRSCCSS(target.cache, key, css);
|
|
397
|
+
pushRSCCSS(target.cache, key, css, options?.id != null);
|
|
353
398
|
}
|
|
354
399
|
if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
|
|
355
400
|
return;
|
|
356
401
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
402
|
+
if (slots) {
|
|
403
|
+
existing?.dispose();
|
|
404
|
+
const { dispose } = injectGlobal(styleResults, { root: options?.root });
|
|
405
|
+
slots.set(slotKey, {
|
|
406
|
+
stylesKey,
|
|
407
|
+
dispose
|
|
408
|
+
});
|
|
409
|
+
}
|
|
365
410
|
}
|
|
366
411
|
//#endregion
|
|
367
412
|
//#region src/utils/deps-equal.ts
|
|
@@ -377,9 +422,11 @@ function depsEqual(a, b) {
|
|
|
377
422
|
}
|
|
378
423
|
//#endregion
|
|
379
424
|
//#region src/hooks/useRawCSS.ts
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
425
|
+
const getClientState$1 = createClientState(() => ({
|
|
426
|
+
entries: /* @__PURE__ */ new Map(),
|
|
427
|
+
contentDedup: /* @__PURE__ */ new Set(),
|
|
428
|
+
factoryDeps: /* @__PURE__ */ new Map()
|
|
429
|
+
}));
|
|
383
430
|
/**
|
|
384
431
|
* Inject raw CSS text directly without parsing.
|
|
385
432
|
* This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
|
|
@@ -435,53 +482,59 @@ function useRawCSS(cssOrFactory, depsOrOptions, options) {
|
|
|
435
482
|
const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
|
|
436
483
|
const opts = isFactory ? options : depsOrOptions;
|
|
437
484
|
const target = getStyleTarget();
|
|
438
|
-
|
|
439
|
-
|
|
485
|
+
const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
|
|
486
|
+
if (isFactory && deps && opts?.id && state) {
|
|
487
|
+
const cachedDeps = state.factoryDeps.get(opts.id);
|
|
440
488
|
if (cachedDeps && depsEqual(cachedDeps, deps)) return;
|
|
441
489
|
}
|
|
442
490
|
const css = isFactory ? cssOrFactory() : cssOrFactory;
|
|
443
491
|
if (!css.trim()) return;
|
|
444
492
|
if (target.mode === "ssr") {
|
|
445
493
|
const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
|
|
446
|
-
target.collector.collectRawCSS(key, css);
|
|
494
|
+
target.collector.collectRawCSS(key, css, opts?.id != null);
|
|
447
495
|
return;
|
|
448
496
|
}
|
|
449
497
|
if (target.mode === "rsc") {
|
|
450
498
|
const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
|
|
451
|
-
pushRSCCSS(target.cache, key, css);
|
|
499
|
+
pushRSCCSS(target.cache, key, css, opts?.id != null);
|
|
452
500
|
return;
|
|
453
501
|
}
|
|
502
|
+
if (!state) return;
|
|
454
503
|
const id = opts?.id;
|
|
455
504
|
if (id) {
|
|
456
|
-
const existing =
|
|
505
|
+
const existing = state.entries.get(id);
|
|
457
506
|
if (existing) {
|
|
458
507
|
if (existing.contentKey === css) return;
|
|
459
508
|
existing.dispose();
|
|
460
509
|
}
|
|
461
510
|
const { dispose } = injectRawCSS(css, opts);
|
|
462
|
-
|
|
511
|
+
state.entries.set(id, {
|
|
463
512
|
contentKey: css,
|
|
464
513
|
dispose
|
|
465
514
|
});
|
|
466
|
-
if (deps)
|
|
515
|
+
if (deps) state.factoryDeps.set(id, deps);
|
|
467
516
|
} else {
|
|
468
517
|
const contentKey = hashString(css);
|
|
469
|
-
if (
|
|
470
|
-
|
|
518
|
+
if (state.contentDedup.has(contentKey)) return;
|
|
519
|
+
state.contentDedup.add(contentKey);
|
|
471
520
|
injectRawCSS(css, opts);
|
|
472
521
|
}
|
|
473
522
|
}
|
|
474
523
|
//#endregion
|
|
475
524
|
//#region src/hooks/useKeyframes.ts
|
|
476
|
-
const
|
|
477
|
-
|
|
525
|
+
const getClientState = createClientState(() => ({
|
|
526
|
+
contentToName: /* @__PURE__ */ new Map(),
|
|
527
|
+
namedSlots: /* @__PURE__ */ new Map(),
|
|
528
|
+
factoryDeps: /* @__PURE__ */ new Map()
|
|
529
|
+
}));
|
|
478
530
|
function useKeyframes(stepsOrFactory, depsOrOptions, options) {
|
|
479
531
|
const isFactory = typeof stepsOrFactory === "function";
|
|
480
532
|
const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
|
|
481
533
|
const opts = isFactory ? options : depsOrOptions;
|
|
482
534
|
const target = getStyleTarget();
|
|
483
|
-
|
|
484
|
-
|
|
535
|
+
const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
|
|
536
|
+
if (isFactory && deps && opts?.name && clientState) {
|
|
537
|
+
const cached = clientState.factoryDeps.get(opts.name);
|
|
485
538
|
if (cached && depsEqual(cached.deps, deps)) return cached.name;
|
|
486
539
|
}
|
|
487
540
|
const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
|
|
@@ -503,19 +556,36 @@ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
|
|
|
503
556
|
target.cache.generatedNames.set(key, actualName);
|
|
504
557
|
return actualName;
|
|
505
558
|
}
|
|
559
|
+
const state = clientState ?? getClientState(opts?.root ?? document);
|
|
506
560
|
const serializedContent = JSON.stringify(steps);
|
|
507
561
|
const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
|
|
508
|
-
const cachedName =
|
|
562
|
+
const cachedName = state.contentToName.get(cacheKey);
|
|
509
563
|
if (cachedName) return cachedName;
|
|
510
|
-
const
|
|
511
|
-
|
|
564
|
+
const providedName = opts?.name;
|
|
565
|
+
if (providedName) {
|
|
566
|
+
const slot = state.namedSlots.get(providedName);
|
|
567
|
+
if (slot && slot.cacheKey !== cacheKey) {
|
|
568
|
+
slot.dispose();
|
|
569
|
+
state.contentToName.delete(slot.cacheKey);
|
|
570
|
+
state.namedSlots.delete(providedName);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const result = keyframes(steps, {
|
|
574
|
+
name: providedName,
|
|
512
575
|
root: opts?.root
|
|
513
|
-
}).toString();
|
|
514
|
-
clientContentToName$1.set(cacheKey, name);
|
|
515
|
-
if (deps && opts?.name) factoryDepsCache.set(opts.name, {
|
|
516
|
-
deps,
|
|
517
|
-
name
|
|
518
576
|
});
|
|
577
|
+
const name = result.toString();
|
|
578
|
+
state.contentToName.set(cacheKey, name);
|
|
579
|
+
if (providedName) {
|
|
580
|
+
state.namedSlots.set(providedName, {
|
|
581
|
+
cacheKey,
|
|
582
|
+
dispose: result.dispose
|
|
583
|
+
});
|
|
584
|
+
if (deps) state.factoryDeps.set(providedName, {
|
|
585
|
+
deps,
|
|
586
|
+
name
|
|
587
|
+
});
|
|
588
|
+
}
|
|
519
589
|
return name;
|
|
520
590
|
}
|
|
521
591
|
//#endregion
|
|
@@ -671,7 +741,7 @@ function useFontFace(family, input, options) {
|
|
|
671
741
|
//#endregion
|
|
672
742
|
//#region src/hooks/useCounterStyle.ts
|
|
673
743
|
let clientCounterStyleCounter = 0;
|
|
674
|
-
const
|
|
744
|
+
const getClientContentToName = createClientState(() => /* @__PURE__ */ new Map());
|
|
675
745
|
/**
|
|
676
746
|
* Inject a CSS @counter-style rule and return the generated name.
|
|
677
747
|
* Permanent — no cleanup on unmount. Deduplicates by name.
|
|
@@ -717,12 +787,13 @@ function useCounterStyle(descriptors, options) {
|
|
|
717
787
|
target.cache.generatedNames.set(key, actualName);
|
|
718
788
|
return actualName;
|
|
719
789
|
}
|
|
790
|
+
const contentToName = getClientContentToName(options?.root ?? document);
|
|
720
791
|
const serializedContent = JSON.stringify(descriptors);
|
|
721
792
|
const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
|
|
722
|
-
const existingName =
|
|
793
|
+
const existingName = contentToName.get(cacheKey);
|
|
723
794
|
if (existingName) return existingName;
|
|
724
795
|
const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
|
|
725
|
-
|
|
796
|
+
contentToName.set(cacheKey, name);
|
|
726
797
|
getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
|
|
727
798
|
return name;
|
|
728
799
|
}
|