@tenphi/tasty 2.6.1 → 2.6.3
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/async-storage-B7_o6FKt.js.map +1 -1
- package/dist/{collector-CLKusMeM.js → collector-Crs9kGJW.js} +3 -3
- package/dist/{collector-CLKusMeM.js.map → collector-Crs9kGJW.js.map} +1 -1
- package/dist/{collector-CoababzP.d.ts → collector-osfWTeRd.d.ts} +2 -2
- package/dist/{config-D0ZQMdY8.js → config-BaxtQMS3.js} +109 -45
- package/dist/config-BaxtQMS3.js.map +1 -0
- package/dist/{config-Cp05bCvj.d.ts → config-BoZDUHW5.d.ts} +19 -2
- package/dist/context-CkSg-kDT.js.map +1 -1
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +5 -5
- package/dist/{core-DOcbMGRf.js → core-CmxaoZ-N.js} +5 -5
- package/dist/{core-DOcbMGRf.js.map → core-CmxaoZ-N.js.map} +1 -1
- package/dist/{css-writer-BZdDWI6L.js → css-writer-CPy_cbFJ.js} +3 -3
- package/dist/{css-writer-BZdDWI6L.js.map → css-writer-CPy_cbFJ.js.map} +1 -1
- package/dist/format-global-rules-Dbc_1tc3.js.map +1 -1
- package/dist/{format-rules-BT_JwzeT.js → format-rules-CPirO_Mj.js} +2 -2
- package/dist/{format-rules-BT_JwzeT.js.map → format-rules-CPirO_Mj.js.map} +1 -1
- package/dist/{hydrate-BLh7OkxZ.js → hydrate-CVn-A_3y.js} +2 -2
- package/dist/{hydrate-BLh7OkxZ.js.map → hydrate-CVn-A_3y.js.map} +1 -1
- package/dist/{index-sk1sxVI3.d.ts → index-B_k47mc_.d.ts} +43 -19
- package/dist/{index-B_QCrcpe.d.ts → index-tcHuMPFt.d.ts} +10 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-DW6FxDsz.js → keyframes-vpzoVdUR.js} +2 -2
- package/dist/{keyframes-DW6FxDsz.js.map → keyframes-vpzoVdUR.js.map} +1 -1
- package/dist/{merge-styles-DQO22J7_.d.ts → merge-styles-BMWcH6MF.d.ts} +2 -2
- package/dist/{merge-styles-Bv2DKtHJ.js → merge-styles-BzQutdAK.js} +2 -2
- package/dist/{merge-styles-Bv2DKtHJ.js.map → merge-styles-BzQutdAK.js.map} +1 -1
- package/dist/{resolve-recipes-x4ElcO5U.js → resolve-recipes-DgH8A3Nn.js} +3 -3
- package/dist/{resolve-recipes-x4ElcO5U.js.map → resolve-recipes-DgH8A3Nn.js.map} +1 -1
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.js +3 -3
- package/dist/ssr/astro.js.map +1 -1
- 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/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +2 -2
- package/dist/static/index.js +1 -1
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +4 -4
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +1 -1
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/pipeline.md +40 -14
- package/package.json +2 -2
- package/dist/config-D0ZQMdY8.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,IAAI,mBAAyC;CAE5D,OAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;CACH,OAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;CAClC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,UAAU,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-
|
|
2
|
-
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-
|
|
1
|
+
import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-BaxtQMS3.js";
|
|
2
|
+
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-CPirO_Mj.js";
|
|
3
3
|
import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
|
|
4
4
|
//#region src/ssr/collector.ts
|
|
5
5
|
/**
|
|
@@ -240,4 +240,4 @@ var ServerStyleCollector = class {
|
|
|
240
240
|
//#endregion
|
|
241
241
|
export { ServerStyleCollector as t };
|
|
242
242
|
|
|
243
|
-
//# sourceMappingURL=collector-
|
|
243
|
+
//# sourceMappingURL=collector-Crs9kGJW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector-CLKusMeM.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 using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * 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 getNamePrefix,\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 {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\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 private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\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 = this.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 (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\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 (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\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":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gC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SAAM,KAAK,UAAU;;AAGzB,SAAO"}
|
|
1
|
+
{"version":3,"file":"collector-Crs9kGJW.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 using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * 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 getNamePrefix,\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 {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\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 private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\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 = this.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 (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\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 (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\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":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACnD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;;;;;;;;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,WAAW;EAEhC,KAAK,aAAa,cAAc,eAAe;;CAGjD,kBAA0B,UAA0B;EAClD,OAAO,cAAc,KAAK,YAAY,WAAW,SAAS,CAAC;;;;;;;;;;;CAY7D,mBAAyB;EACvB,IAAI,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EAIhC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,cAC5B,IAAI,CAAC,KAAK,kBAAkB,IAAI,IAAI,EAAE;GACpC,MAAM,KAAK,IAAI;GACf,KAAK,kBAAkB,IAAI,IAAI;;EAInC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;GAC9B,MAAM,KAAK,IAAI;GACf,KAAK,YAAY,IAAI,IAAI;;EAI7B,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;GACvC,MAAM,KAAK,IAAI;GACf,KAAK,oBAAoB,IAAI,KAAK;;EAItC,OAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;EAC1B,KAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,EACvD,IAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;GAC1C,KAAK,kBAAkB,IAAI,UAAU;GACrC,MAAM,KAAK,UAAU;;EAGzB,OAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as StyleResult } from "./index-
|
|
1
|
+
import { n as StyleResult } from "./index-tcHuMPFt.js";
|
|
2
2
|
|
|
3
3
|
//#region src/ssr/collector.d.ts
|
|
4
4
|
declare class ServerStyleCollector {
|
|
@@ -105,4 +105,4 @@ declare class ServerStyleCollector {
|
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
export { ServerStyleCollector as t };
|
|
108
|
-
//# sourceMappingURL=collector-
|
|
108
|
+
//# sourceMappingURL=collector-osfWTeRd.d.ts.map
|
|
@@ -57,6 +57,7 @@ function canonicalFuncName(lowered) {
|
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region src/parser/lru.ts
|
|
59
59
|
var Lru = class {
|
|
60
|
+
limit;
|
|
60
61
|
map = /* @__PURE__ */ new Map();
|
|
61
62
|
head = null;
|
|
62
63
|
tail = null;
|
|
@@ -1875,6 +1876,7 @@ function scan(src, cb) {
|
|
|
1875
1876
|
//#endregion
|
|
1876
1877
|
//#region src/parser/parser.ts
|
|
1877
1878
|
var StyleParser = class {
|
|
1879
|
+
opts;
|
|
1878
1880
|
cache;
|
|
1879
1881
|
constructor(opts = {}) {
|
|
1880
1882
|
this.opts = opts;
|
|
@@ -4222,7 +4224,7 @@ var SheetManager = class {
|
|
|
4222
4224
|
}
|
|
4223
4225
|
}
|
|
4224
4226
|
if (!anyInserted) {}
|
|
4225
|
-
} else console.warn("[tasty] Browser rejected CSS rule:", fullRule, e);
|
|
4227
|
+
} else if (!(fullRule.startsWith("@property ") && !this.engineSupportsAtProperty(registry, styleSheet))) console.warn("[tasty] Browser rejected CSS rule:", fullRule, e);
|
|
4226
4228
|
}
|
|
4227
4229
|
} else if (styleElement) {
|
|
4228
4230
|
const atomicRuleIndex = this.findAvailableRuleIndex(targetSheet);
|
|
@@ -4374,6 +4376,37 @@ var SheetManager = class {
|
|
|
4374
4376
|
return sheet.ruleCount;
|
|
4375
4377
|
}
|
|
4376
4378
|
/**
|
|
4379
|
+
* Probe whether the underlying CSS engine supports `@property` at-rules.
|
|
4380
|
+
* Result is cached per registry on `registry.atPropertySupported`.
|
|
4381
|
+
*
|
|
4382
|
+
* The probe inserts and immediately deletes a minimal known-valid rule
|
|
4383
|
+
* (`@property --__tasty_probe__ { syntax: "*"; inherits: true; }`).
|
|
4384
|
+
* Engines that lack `@property` support (jsdom, happy-dom) reject any
|
|
4385
|
+
* `@property` rule including this one, so a probe failure is a reliable
|
|
4386
|
+
* signal that further `@property` rejections are environmental noise and
|
|
4387
|
+
* not user-authored bugs.
|
|
4388
|
+
*
|
|
4389
|
+
* The probe is intentionally a separate operation from the user's failing
|
|
4390
|
+
* insertion: we don't want to leak `--__tasty_probe__` into the sheet, so
|
|
4391
|
+
* on success we delete the probe rule immediately, leaving `ruleCount`
|
|
4392
|
+
* and `cssRules.length` unchanged.
|
|
4393
|
+
*/
|
|
4394
|
+
engineSupportsAtProperty(registry, styleSheet) {
|
|
4395
|
+
if (registry.atPropertySupported !== void 0) return registry.atPropertySupported;
|
|
4396
|
+
const probeRule = "@property --__tasty_probe__ { syntax: \"*\"; inherits: true; }";
|
|
4397
|
+
try {
|
|
4398
|
+
const probeIdx = styleSheet.cssRules.length;
|
|
4399
|
+
styleSheet.insertRule(probeRule, probeIdx);
|
|
4400
|
+
try {
|
|
4401
|
+
styleSheet.deleteRule(probeIdx);
|
|
4402
|
+
} catch {}
|
|
4403
|
+
registry.atPropertySupported = true;
|
|
4404
|
+
} catch {
|
|
4405
|
+
registry.atPropertySupported = false;
|
|
4406
|
+
}
|
|
4407
|
+
return registry.atPropertySupported;
|
|
4408
|
+
}
|
|
4409
|
+
/**
|
|
4377
4410
|
* Force cleanup of unused styles
|
|
4378
4411
|
*/
|
|
4379
4412
|
forceCleanup(registry) {
|
|
@@ -5312,8 +5345,8 @@ var StyleInjector = class {
|
|
|
5312
5345
|
selector: `@property ${cssName}`,
|
|
5313
5346
|
declarations
|
|
5314
5347
|
};
|
|
5315
|
-
if (!this.sheetManager.insertGlobalRule(registry, [rule], `property:${cacheKey}`, root)) return;
|
|
5316
5348
|
registry.injectedProperties.set(cssName, normalizePropertyDefinition(definition));
|
|
5349
|
+
this.sheetManager.insertGlobalRule(registry, [rule], `property:${cacheKey}`, root);
|
|
5317
5350
|
}
|
|
5318
5351
|
/**
|
|
5319
5352
|
* Check whether a given @property name was already injected by this injector.
|
|
@@ -8175,58 +8208,89 @@ function parseStyleEntries(styleKey, valueMap, parseCondition) {
|
|
|
8175
8208
|
* This must happen **before** exclusive expansion and OR branch splitting
|
|
8176
8209
|
* to avoid combinatorial explosion and duplicate CSS output.
|
|
8177
8210
|
*
|
|
8178
|
-
*
|
|
8211
|
+
* **Merging must preserve the authored cascade.** Merging two same-value
|
|
8212
|
+
* entries with priorities `p_h > p_l` lifts the lower-priority entry up
|
|
8213
|
+
* to `p_h` and changes the "blocker" for intermediate-priority entries
|
|
8214
|
+
* from `!C_h` to `!(C_h | C_l) = !C_h & !C_l`. The added `!C_l`
|
|
8215
|
+
* constraint can incorrectly block an intermediate entry that should
|
|
8216
|
+
* have won.
|
|
8217
|
+
*
|
|
8218
|
+
* Two same-value entries with conditions `C_h` (higher priority) and
|
|
8219
|
+
* `C_l` (lower priority) are safe to merge iff for every entry
|
|
8220
|
+
* `e_m` strictly between them in priority with a different value,
|
|
8221
|
+
*
|
|
8222
|
+
* simplify(C_m & C_l & !C_h) = FALSE
|
|
8223
|
+
*
|
|
8224
|
+
* i.e. there is no scenario where the intermediate state could have
|
|
8225
|
+
* matched (`C_m`), the lower-priority same-value entry would also have
|
|
8226
|
+
* matched (`C_l`), and the higher-priority entry would not (`!C_h`).
|
|
8227
|
+
* In such scenarios the intermediate is supposed to win; the merge
|
|
8228
|
+
* would block it by introducing `!C_l`.
|
|
8229
|
+
*
|
|
8230
|
+
* Example (UNSAFE — must not merge):
|
|
8231
|
+
* `{ hovered: 'red', pressed: 'blue', disabled: 'red' }`.
|
|
8232
|
+
* C_h = disabled, C_l = hovered, C_m = pressed. `pressed & hovered &
|
|
8233
|
+
* !disabled` is satisfiable (three independent modifiers), so the
|
|
8234
|
+
* intermediate `pressed` would lose to a merged red rule when both
|
|
8235
|
+
* `pressed` and `hovered` are active — breaking the cascade
|
|
8236
|
+
* `disabled > pressed > hovered`.
|
|
8237
|
+
*
|
|
8238
|
+
* Example (SAFE — still merges):
|
|
8239
|
+
* `{ '': light, '@dark': dark, '@hc': hc, '@dark & @hc': dark }`.
|
|
8240
|
+
* C_h = `@dark & @hc`, C_l = `@dark`, C_m = `@hc`.
|
|
8241
|
+
* `@hc & @dark & !(@dark & @hc) = @hc & @dark & (!@dark | !@hc)`
|
|
8242
|
+
* simplifies to FALSE, so merging the two darks into one `@dark` rule
|
|
8243
|
+
* at the higher priority does not affect the `@hc` rule.
|
|
8244
|
+
*
|
|
8245
|
+
* Default (TRUE) entries are never merged with non-default entries.
|
|
8179
8246
|
* Merging `TRUE | X` collapses to `TRUE`, destroying the non-default
|
|
8180
|
-
* condition's participation in exclusive building.
|
|
8181
|
-
*
|
|
8182
|
-
*
|
|
8183
|
-
* both active. Stage 6 `mergeByValue` handles combining rules with
|
|
8184
|
-
* identical CSS output after exclusive conditions are correctly built.
|
|
8185
|
-
*
|
|
8186
|
-
* Example: `{ '@dark': 'red', '@dark & @hc': 'red' }` merges into a
|
|
8187
|
-
* single entry with condition `@dark | (@dark & @hc)` = `@dark`.
|
|
8247
|
+
* condition's participation in exclusive building. Stage 6
|
|
8248
|
+
* `mergeByValue` handles combining rules with identical CSS output
|
|
8249
|
+
* after exclusive conditions are correctly built.
|
|
8188
8250
|
*
|
|
8189
|
-
*
|
|
8190
|
-
* highest priority of the group.
|
|
8251
|
+
* The merged entry keeps the highest priority of the merged entries.
|
|
8191
8252
|
*/
|
|
8192
8253
|
function mergeEntriesByValue(entries) {
|
|
8193
8254
|
if (entries.length <= 1) return entries;
|
|
8194
|
-
const groups = /* @__PURE__ */ new Map();
|
|
8195
|
-
for (const entry of entries) {
|
|
8196
|
-
const valueKey = serializeValue(entry.value);
|
|
8197
|
-
const group = groups.get(valueKey);
|
|
8198
|
-
if (group) {
|
|
8199
|
-
group.entries.push(entry);
|
|
8200
|
-
group.maxPriority = Math.max(group.maxPriority, entry.priority);
|
|
8201
|
-
} else groups.set(valueKey, {
|
|
8202
|
-
entries: [entry],
|
|
8203
|
-
maxPriority: entry.priority
|
|
8204
|
-
});
|
|
8205
|
-
}
|
|
8206
|
-
if (groups.size === entries.length) return entries;
|
|
8207
8255
|
const merged = [];
|
|
8208
|
-
for (const
|
|
8209
|
-
if (
|
|
8210
|
-
merged.push(
|
|
8256
|
+
for (const entry of entries) {
|
|
8257
|
+
if (entry.condition.kind === "true") {
|
|
8258
|
+
merged.push(entry);
|
|
8211
8259
|
continue;
|
|
8212
8260
|
}
|
|
8213
|
-
const
|
|
8214
|
-
|
|
8215
|
-
for (
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
merged.
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
condition
|
|
8225
|
-
|
|
8226
|
-
|
|
8261
|
+
const valueKey = serializeValue(entry.value);
|
|
8262
|
+
let mergeIdx = -1;
|
|
8263
|
+
for (let j = merged.length - 1; j >= 0; j--) {
|
|
8264
|
+
const prev = merged[j];
|
|
8265
|
+
if (prev.condition.kind === "true") continue;
|
|
8266
|
+
if (serializeValue(prev.value) !== valueKey) continue;
|
|
8267
|
+
let safe = true;
|
|
8268
|
+
for (let k = j + 1; k < merged.length; k++) {
|
|
8269
|
+
const inter = merged[k];
|
|
8270
|
+
if (inter.condition.kind === "true") continue;
|
|
8271
|
+
if (serializeValue(inter.value) === valueKey) continue;
|
|
8272
|
+
if (simplifyCondition(and(inter.condition, entry.condition, not(prev.condition))).kind !== "false") {
|
|
8273
|
+
safe = false;
|
|
8274
|
+
break;
|
|
8275
|
+
}
|
|
8276
|
+
}
|
|
8277
|
+
if (safe) {
|
|
8278
|
+
mergeIdx = j;
|
|
8279
|
+
break;
|
|
8280
|
+
}
|
|
8227
8281
|
}
|
|
8282
|
+
if (mergeIdx >= 0) {
|
|
8283
|
+
const prev = merged[mergeIdx];
|
|
8284
|
+
const newCondition = simplifyCondition(or(prev.condition, entry.condition));
|
|
8285
|
+
merged[mergeIdx] = {
|
|
8286
|
+
styleKey: prev.styleKey,
|
|
8287
|
+
stateKey: `${prev.stateKey} | ${entry.stateKey}`,
|
|
8288
|
+
value: prev.value,
|
|
8289
|
+
condition: newCondition,
|
|
8290
|
+
priority: Math.max(prev.priority, entry.priority)
|
|
8291
|
+
};
|
|
8292
|
+
} else merged.push(entry);
|
|
8228
8293
|
}
|
|
8229
|
-
merged.sort((a, b) => b.priority - a.priority);
|
|
8230
8294
|
return merged;
|
|
8231
8295
|
}
|
|
8232
8296
|
function serializeValue(value) {
|
|
@@ -10397,4 +10461,4 @@ function resetConfig() {
|
|
|
10397
10461
|
//#endregion
|
|
10398
10462
|
export { parseColor as $, StyleInjector as A, strToRgb as At, styleHandlers as B, parseStateKey as C, getColorSpaceFunc as Ct, extractPredefinedStateRefs as D, getRgbValuesFromRgbaString as Dt, extractLocalPredefinedStates as E, getNamedColorHex as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalCounterStyle as N, getGlobalPredefinedStates as O, hexToRgb as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getColorSpaceComponents as St, createStateParserContext as T, getComponentPropertySyntax as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, extractLocalProperties as _t, getGlobalCounterStyle as a, okhslPlugin as at, hasPipelineCacheEntry as b, parsePropertyToken as bt, getGlobalKeyframes as c, DEFAULT_NAME_PREFIX as ct, getNamePrefix as d, makeCounterStyleName as dt, parseStyle as et, hasGlobalKeyframes as f, makeKeyframeName as ft, isTestEnvironment as g, hashString as gt, isConfigLocked as h, isDevEnv as ht, getGlobalConfigTokens as i, okhslFunc as it, extractLocalCounterStyle as j, Lru as jt, setGlobalPredefinedStates as k, hslToRgbValues as kt, getGlobalRecipes as l, DEFAULT_ZERO_NAME_PREFIX as lt, hasStylesGenerated as m, validateNamePrefix as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, StyleParser as ot, hasGlobalRecipes as p, tastyClassRegex as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, Bucket as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, makeClassName as ut, resetConfig as v, getEffectiveDefinition as vt, camelToKebab as w, getColorSpaceSuffix as wt, isSelector as x, colorInitialValueToComponents as xt, generateTypographyTokens as y, hasLocalProperties as yt, STYLE_HANDLER_MAP as z };
|
|
10399
10463
|
|
|
10400
|
-
//# sourceMappingURL=config-
|
|
10464
|
+
//# sourceMappingURL=config-BaxtQMS3.js.map
|