@tenphi/tasty 2.1.1 → 2.2.0
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-QwpPODsy.js → collector-MOYY2SOr.js} +3 -3
- package/dist/{collector-QwpPODsy.js.map → collector-MOYY2SOr.js.map} +1 -1
- package/dist/{config-rrijM-U2.js → config-A237aY9H.js} +109 -11
- package/dist/config-A237aY9H.js.map +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +5 -5
- package/dist/{core-BvTG0J_M.js → core-BkKav78f.js} +5 -5
- package/dist/{core-BvTG0J_M.js.map → core-BkKav78f.js.map} +1 -1
- package/dist/{css-writer-C7HJGEmN.js → css-writer-Cos9tQRM.js} +3 -3
- package/dist/{css-writer-C7HJGEmN.js.map → css-writer-Cos9tQRM.js.map} +1 -1
- package/dist/{format-rules-BvokPr1L.js → format-rules-C2oiTsEO.js} +2 -2
- package/dist/{format-rules-BvokPr1L.js.map → format-rules-C2oiTsEO.js.map} +1 -1
- package/dist/{hydrate-Dsv7Pwon.js → hydrate-miFzWIKR.js} +2 -2
- package/dist/{hydrate-Dsv7Pwon.js.map → hydrate-miFzWIKR.js.map} +1 -1
- package/dist/{index-FuQphaEO.d.ts → index-ZRxZWzlj.d.ts} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/{keyframes-DDqRjwa9.js → keyframes-DDtNo_hl.js} +2 -2
- package/dist/{keyframes-DDqRjwa9.js.map → keyframes-DDtNo_hl.js.map} +1 -1
- package/dist/{merge-styles-B8jV6zu3.js → merge-styles-D_HbBOlq.js} +2 -2
- package/dist/{merge-styles-B8jV6zu3.js.map → merge-styles-D_HbBOlq.js.map} +1 -1
- package/dist/{resolve-recipes-BnTZz2I_.js → resolve-recipes-B7-823LL.js} +3 -3
- package/dist/{resolve-recipes-BnTZz2I_.js.map → resolve-recipes-B7-823LL.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.d.ts +1 -12
- package/dist/ssr/astro.js +3 -3
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.js +3 -3
- package/dist/ssr/next.js +4 -4
- package/dist/static/index.js +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.js +1 -1
- package/docs/dsl.md +1 -2
- package/package.json +1 -1
- package/tasty.config.ts +1 -0
- package/dist/config-rrijM-U2.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as formatFontFaceRule, P as fontFaceContentHash, a as getGlobalCounterStyle, ct as hashString, i as getGlobalConfigTokens, j as formatCounterStyleRule, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, x as renderStyles } from "./config-
|
|
2
|
-
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-
|
|
1
|
+
import { F as formatFontFaceRule, P as fontFaceContentHash, a as getGlobalCounterStyle, ct as hashString, i as getGlobalConfigTokens, j as formatCounterStyleRule, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, x as renderStyles } from "./config-A237aY9H.js";
|
|
2
|
+
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-C2oiTsEO.js";
|
|
3
3
|
import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
|
|
4
4
|
//#region src/ssr/collector.ts
|
|
5
5
|
/**
|
|
@@ -227,4 +227,4 @@ var ServerStyleCollector = class {
|
|
|
227
227
|
//#endregion
|
|
228
228
|
export { ServerStyleCollector as t };
|
|
229
229
|
|
|
230
|
-
//# sourceMappingURL=collector-
|
|
230
|
+
//# sourceMappingURL=collector-MOYY2SOr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector-QwpPODsy.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names (`t${hash}`), formats CSS rules into text,\n * and tracks rendered class names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nfunction generateClassName(cacheKey: string): string {\n return `t${hashString(cacheKey)}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return providedName ?? `k${this.keyframesCounter++}`;\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return providedName ?? `cs${this.counterStyleCounter++}`;\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,SAAS,kBAAkB,UAA0B;AACnD,QAAO,IAAI,WAAW,SAAS;;AAGjC,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;C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I,IAAI,EAAE;AACtC,SAAM,KAAK,IAAI;AACf,QAAK,oBAAoB,IAAI,IAAI;;AAIrC,OAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,kBAC5B,KAAI,CAAC,KAAK,wBAAwB,IAAI,IAAI,EAAE;AAC1C,SAAM,KAAK,IAAI;AACf,QAAK,wBAAwB,IAAI,IAAI;;AAIzC,OAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,OAC5B,KAAI,CAAC,KAAK,eAAe,IAAI,IAAI,EAAE;AACjC,SAAM,KAAK,IAAI;AACf,QAAK,eAAe,IAAI,IAAI;;AAIhC,OAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,aAC5B,KAAI,CAAC,KAAK,kBAAkB,IAAI,IAAI,EAAE;AACpC,SAAM,KAAK,IAAI;AACf,QAAK,kBAAkB,IAAI,IAAI;;AAInC,OAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,OAC5B,KAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;AAC9B,SAAM,KAAK,IAAI;AACf,QAAK,YAAY,IAAI,IAAI;;AAI7B,OAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,cAC7B,KAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;AACvC,SAAM,KAAK,IAAI;AACf,QAAK,oBAAoB,IAAI,KAAK;;AAItC,SAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,CACvD,KAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;AAC1C,QAAK,kBAAkB,IAAI,UAAU;AACrC,SAAM,KAAK,UAAU;;AAGzB,SAAO"}
|
|
1
|
+
{"version":3,"file":"collector-MOYY2SOr.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names (`t${hash}`), formats CSS rules into text,\n * and tracks rendered class names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nfunction generateClassName(cacheKey: string): string {\n return `t${hashString(cacheKey)}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return providedName ?? `k${this.keyframesCounter++}`;\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return providedName ?? `cs${this.counterStyleCounter++}`;\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,SAAS,kBAAkB,UAA0B;AACnD,QAAO,IAAI,WAAW,SAAS;;AAGjC,IAAa,uBAAb,MA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Terms(terms);
|
|
6090
6090
|
terms = applyAbsorptionAnd(terms);
|
|
6091
6091
|
terms = applyConsensusAnd(terms);
|
|
6092
|
+
terms = pruneContradictedOrBranches(terms);
|
|
6092
6093
|
if (terms.length === 0) return trueCondition();
|
|
6093
6094
|
if (terms.length === 1) return terms[0];
|
|
6094
6095
|
return {
|
|
@@ -6375,11 +6376,14 @@ function hasContainerStyleConflict(terms) {
|
|
|
6375
6376
|
*/
|
|
6376
6377
|
function buildImpliedNegationCheck(terms) {
|
|
6377
6378
|
const positiveValues = /* @__PURE__ */ new Map();
|
|
6379
|
+
const negatedBooleanAttrs = /* @__PURE__ */ new Set();
|
|
6378
6380
|
for (const term of terms) {
|
|
6379
|
-
if (term.kind !== "state"
|
|
6380
|
-
if (term.
|
|
6381
|
-
if (term.
|
|
6382
|
-
|
|
6381
|
+
if (term.kind !== "state") continue;
|
|
6382
|
+
if (!term.negated) {
|
|
6383
|
+
if (term.type === "container" && term.subtype === "style") {
|
|
6384
|
+
if (term.propertyValue !== void 0) positiveValues.set(`c:${term.containerName || "_"}:${term.property}`, term.propertyValue);
|
|
6385
|
+
} else if (term.type === "modifier" && term.value !== void 0) positiveValues.set(`m:${term.attribute}`, term.value);
|
|
6386
|
+
} else if (term.type === "modifier" && term.value === void 0) negatedBooleanAttrs.add(term.attribute);
|
|
6383
6387
|
}
|
|
6384
6388
|
return (term) => {
|
|
6385
6389
|
if (term.kind !== "state" || !term.negated) return false;
|
|
@@ -6389,6 +6393,7 @@ function buildImpliedNegationCheck(terms) {
|
|
|
6389
6393
|
return pos !== void 0 && term.propertyValue !== pos;
|
|
6390
6394
|
}
|
|
6391
6395
|
if (term.type === "modifier" && term.value !== void 0) {
|
|
6396
|
+
if (negatedBooleanAttrs.has(term.attribute)) return true;
|
|
6392
6397
|
const pos = positiveValues.get(`m:${term.attribute}`);
|
|
6393
6398
|
return pos !== void 0 && term.value !== pos;
|
|
6394
6399
|
}
|
|
@@ -6736,6 +6741,50 @@ function tryResolvePair(aChildren, bChildren) {
|
|
|
6736
6741
|
if (common.length === 1) return common[0];
|
|
6737
6742
|
return or(...common);
|
|
6738
6743
|
}
|
|
6744
|
+
/**
|
|
6745
|
+
* For each OR child of an AND, prune branches that are impossible
|
|
6746
|
+
* given the other AND siblings.
|
|
6747
|
+
*
|
|
6748
|
+
* Example: A & OR(!A & X, Y) → A & Y
|
|
6749
|
+
*
|
|
6750
|
+
* This catches dead OR branches left by exclusive negation (Stage 2b)
|
|
6751
|
+
* where `NOT(combined)` introduces branches contradicting flat siblings.
|
|
6752
|
+
*/
|
|
6753
|
+
function pruneContradictedOrBranches(terms) {
|
|
6754
|
+
if (!terms.some((t) => t.kind === "compound" && t.operator === "OR")) return terms;
|
|
6755
|
+
let changed = false;
|
|
6756
|
+
const result = [];
|
|
6757
|
+
for (let i = 0; i < terms.length; i++) {
|
|
6758
|
+
const term = terms[i];
|
|
6759
|
+
if (term.kind !== "compound" || term.operator !== "OR") {
|
|
6760
|
+
result.push(term);
|
|
6761
|
+
continue;
|
|
6762
|
+
}
|
|
6763
|
+
const siblings = [...terms.slice(0, i), ...terms.slice(i + 1)];
|
|
6764
|
+
const surviving = [];
|
|
6765
|
+
for (const branch of term.children) if (simplifyInner({
|
|
6766
|
+
kind: "compound",
|
|
6767
|
+
operator: "AND",
|
|
6768
|
+
children: [branch, ...siblings]
|
|
6769
|
+
}).kind !== "false") surviving.push(branch);
|
|
6770
|
+
if (surviving.length === term.children.length) result.push(term);
|
|
6771
|
+
else if (surviving.length === 0) return [falseCondition()];
|
|
6772
|
+
else {
|
|
6773
|
+
changed = true;
|
|
6774
|
+
if (surviving.length === 1) result.push(surviving[0]);
|
|
6775
|
+
else result.push({
|
|
6776
|
+
kind: "compound",
|
|
6777
|
+
operator: "OR",
|
|
6778
|
+
children: surviving
|
|
6779
|
+
});
|
|
6780
|
+
}
|
|
6781
|
+
}
|
|
6782
|
+
if (!changed) return terms;
|
|
6783
|
+
const flattened = [];
|
|
6784
|
+
for (const term of result) if (term.kind === "compound" && term.operator === "AND") flattened.push(...term.children);
|
|
6785
|
+
else flattened.push(term);
|
|
6786
|
+
return flattened;
|
|
6787
|
+
}
|
|
6739
6788
|
//#endregion
|
|
6740
6789
|
//#region src/pipeline/exclusive.ts
|
|
6741
6790
|
/**
|
|
@@ -7777,7 +7826,9 @@ function dedupeSelectorConditions(conditions) {
|
|
|
7777
7826
|
if (facts.negatedBooleanAttrs.size === 0 && facts.positiveExactValuesByAttr.size === 0) return result;
|
|
7778
7827
|
return result.filter((c) => {
|
|
7779
7828
|
if (!("attribute" in c)) return true;
|
|
7780
|
-
|
|
7829
|
+
if (isSubsumedNegatedModifier(c, facts)) return false;
|
|
7830
|
+
if (!c.negated && c.value === void 0 && facts.positiveExactValuesByAttr.has(c.attribute)) return false;
|
|
7831
|
+
return true;
|
|
7781
7832
|
});
|
|
7782
7833
|
}
|
|
7783
7834
|
/**
|
|
@@ -8218,6 +8269,19 @@ function factorAndGroup(variants) {
|
|
|
8218
8269
|
modifierConditions: commonModifiers,
|
|
8219
8270
|
pseudoConditions: commonPseudos
|
|
8220
8271
|
};
|
|
8272
|
+
const factoredGroups = tryFactorIntoDimensions(branches);
|
|
8273
|
+
if (factoredGroups) return {
|
|
8274
|
+
modifierConditions: commonModifiers,
|
|
8275
|
+
pseudoConditions: commonPseudos,
|
|
8276
|
+
selectorGroups: [...variants[0].selectorGroups, ...factoredGroups],
|
|
8277
|
+
ownGroups: [...variants[0].ownGroups],
|
|
8278
|
+
mediaConditions: [...variants[0].mediaConditions],
|
|
8279
|
+
containerConditions: [...variants[0].containerConditions],
|
|
8280
|
+
supportsConditions: [...variants[0].supportsConditions],
|
|
8281
|
+
rootGroups: [...variants[0].rootGroups],
|
|
8282
|
+
parentGroups: [...variants[0].parentGroups],
|
|
8283
|
+
startingStyle: variants[0].startingStyle
|
|
8284
|
+
};
|
|
8221
8285
|
return {
|
|
8222
8286
|
modifierConditions: commonModifiers,
|
|
8223
8287
|
pseudoConditions: commonPseudos,
|
|
@@ -8235,6 +8299,39 @@ function factorAndGroup(variants) {
|
|
|
8235
8299
|
};
|
|
8236
8300
|
}
|
|
8237
8301
|
/**
|
|
8302
|
+
* Detect when branches form a complete Cartesian product of independent
|
|
8303
|
+
* modifier attribute dimensions and return one SelectorGroup per dimension.
|
|
8304
|
+
*
|
|
8305
|
+
* Example: 4 branches for 2 attributes × 2 values each →
|
|
8306
|
+
* :is(A1, A2):is(B1, B2) instead of :is(A1B1, A1B2, A2B1, A2B2)
|
|
8307
|
+
*/
|
|
8308
|
+
function tryFactorIntoDimensions(branches) {
|
|
8309
|
+
if (branches.length < 4) return null;
|
|
8310
|
+
const dimensions = /* @__PURE__ */ new Map();
|
|
8311
|
+
for (const branch of branches) for (const cond of branch) {
|
|
8312
|
+
if (!("attribute" in cond)) return null;
|
|
8313
|
+
if (!dimensions.has(cond.attribute)) dimensions.set(cond.attribute, /* @__PURE__ */ new Map());
|
|
8314
|
+
dimensions.get(cond.attribute).set(getModifierKey(cond), cond);
|
|
8315
|
+
}
|
|
8316
|
+
if (dimensions.size < 2) return null;
|
|
8317
|
+
for (const branch of branches) {
|
|
8318
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8319
|
+
for (const cond of branch) {
|
|
8320
|
+
const attr = cond.attribute;
|
|
8321
|
+
if (seen.has(attr)) return null;
|
|
8322
|
+
seen.add(attr);
|
|
8323
|
+
}
|
|
8324
|
+
if (seen.size !== dimensions.size) return null;
|
|
8325
|
+
}
|
|
8326
|
+
let expectedCount = 1;
|
|
8327
|
+
for (const vals of dimensions.values()) expectedCount *= vals.size;
|
|
8328
|
+
if (branches.length !== expectedCount) return null;
|
|
8329
|
+
return [...dimensions.values()].map((vals) => ({
|
|
8330
|
+
branches: [...vals.values()].map((cond) => [cond]),
|
|
8331
|
+
negated: false
|
|
8332
|
+
}));
|
|
8333
|
+
}
|
|
8334
|
+
/**
|
|
8238
8335
|
* Build at-rules array from a variant
|
|
8239
8336
|
*/
|
|
8240
8337
|
function buildAtRulesFromVariant(variant) {
|
|
@@ -8244,7 +8341,7 @@ function buildAtRulesFromVariant(variant) {
|
|
|
8244
8341
|
if (c.subtype === "type") return c.negated ? `not ${c.condition}` : c.condition;
|
|
8245
8342
|
else return c.negated ? `(not ${c.condition})` : c.condition;
|
|
8246
8343
|
});
|
|
8247
|
-
atRules.push(`@media ${conditionParts.join(" and ")}`);
|
|
8344
|
+
atRules.push(`@media ${conditionParts.sort().join(" and ")}`);
|
|
8248
8345
|
}
|
|
8249
8346
|
if (variant.containerConditions.length > 0) {
|
|
8250
8347
|
const byName = /* @__PURE__ */ new Map();
|
|
@@ -9106,14 +9203,15 @@ function validatePattern(pattern) {
|
|
|
9106
9203
|
* processSinglePattern('>Body>Row>', 'Cell')
|
|
9107
9204
|
* // → '> [data-element="Body"] > [data-element="Row"] > [data-element="Cell"]'
|
|
9108
9205
|
*
|
|
9109
|
-
* processSinglePattern('
|
|
9110
|
-
* // → '::before' (
|
|
9206
|
+
* processSinglePattern('&::before', 'Before')
|
|
9207
|
+
* // → '::before' (& attaches pseudo directly to root, no key injection)
|
|
9111
9208
|
*
|
|
9112
9209
|
* processSinglePattern('>@:hover', 'Item')
|
|
9113
9210
|
* // → '> [data-element="Item"]:hover'
|
|
9114
9211
|
*/
|
|
9115
9212
|
function processSinglePattern(pattern, key) {
|
|
9116
|
-
const
|
|
9213
|
+
const startsWithAmpersand = pattern.startsWith("&");
|
|
9214
|
+
const normalized = (startsWithAmpersand ? pattern.slice(1) : pattern).trim();
|
|
9117
9215
|
if (!normalized) return ` [data-element="${key}"]`;
|
|
9118
9216
|
const startsWithPseudo = /^::?[a-z]/.test(normalized);
|
|
9119
9217
|
let result = transformPattern(normalized);
|
|
@@ -9124,7 +9222,7 @@ function processSinglePattern(pattern, key) {
|
|
|
9124
9222
|
return result;
|
|
9125
9223
|
}
|
|
9126
9224
|
if (shouldInjectKey(normalized, key)) result = result + ` [data-element="${key}"]`;
|
|
9127
|
-
if (!
|
|
9225
|
+
if (!startsWithAmpersand && !result.startsWith(" ")) result = " " + result;
|
|
9128
9226
|
return result;
|
|
9129
9227
|
}
|
|
9130
9228
|
/**
|
|
@@ -10134,4 +10232,4 @@ function resetConfig() {
|
|
|
10134
10232
|
//#endregion
|
|
10135
10233
|
export { parseStyle as $, extractLocalCounterStyle as A, deprecationWarning as B, camelToKebab as C, Lru as Ct, getGlobalPredefinedStates as D, extractPredefinedStateRefs as E, formatFontFaceRule as F, DIRECTIONS as G, createStyle as H, hasLocalFontFace as I, getGlobalFuncs as J, customFunc as K, SheetManager as L, hasLocalCounterStyle as M, extractLocalFontFace as N, setGlobalPredefinedStates as O, fontFaceContentHash as P, parseColor as Q, STYLE_HANDLER_MAP as R, parseStateKey as S, strToRgb as St, extractLocalPredefinedStates as T, PropertyTypeResolver as U, warn as V, CUSTOM_UNITS as W, getGlobalPredefinedTokens as X, getGlobalParser as Y, normalizeColorTokenValue as Z, resetConfig as _, getComponentPropertySyntax as _t, getGlobalCounterStyle as a, StyleParser as at, isSelector as b, hexToRgb as bt, getGlobalKeyframes as c, hashString as ct, hasGlobalKeyframes as d, hasLocalProperties as dt, resetGlobalPredefinedTokens as et, hasGlobalRecipes as f, parsePropertyToken as ft, markStylesGenerated as g, getColorSpaceSuffix as gt, isTestEnvironment as h, getColorSpaceFunc as ht, getGlobalConfigTokens as i, okhslPlugin as it, formatCounterStyleRule as j, StyleInjector as k, getGlobalRecipes as l, extractLocalProperties as lt, isConfigLocked as m, getColorSpaceComponents as mt, getConfig as n, stringifyStyles as nt, getGlobalFontFace as o, Bucket as ot, hasStylesGenerated as p, colorInitialValueToComponents as pt, filterMods as q, getEffectiveProperties as r, okhslFunc as rt, getGlobalInjector as s, isDevEnv as st, configure as t, setGlobalPredefinedTokens as tt, getGlobalStyles as u, getEffectiveDefinition as ut, generateTypographyTokens as v, getNamedColorHex as vt, createStateParserContext as w, renderStyles as x, hslToRgbValues as xt, hasPipelineCacheEntry as y, getRgbValuesFromRgbaString as yt, styleHandlers as z };
|
|
10136
10234
|
|
|
10137
|
-
//# sourceMappingURL=config-
|
|
10235
|
+
//# sourceMappingURL=config-A237aY9H.js.map
|