@tenphi/tasty 0.0.0-snapshot.a8b4749 → 0.0.0-snapshot.aae8679
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 → async-storage-DKK-wTD4.js} +1 -1
- package/dist/{async-storage-B7_o6FKt.js.map → async-storage-DKK-wTD4.js.map} +1 -1
- package/dist/{collector-C-keQH9m.js → collector-C3gQB0SA.js} +4 -4
- package/dist/{collector-C-keQH9m.js.map → collector-C3gQB0SA.js.map} +1 -1
- package/dist/{collector-osfWTeRd.d.ts → collector-C7gJvDRF.d.ts} +2 -2
- package/dist/{config-BoZDUHW5.d.ts → config-BFTzQlGr.d.ts} +2 -2
- package/dist/{config-BBiyxMCe.js → config-DwOYoUrU.js} +231 -232
- package/dist/config-DwOYoUrU.js.map +1 -0
- package/dist/{context-CkSg-kDT.js → context-CA8YKeMn.js} +1 -1
- package/dist/{context-CkSg-kDT.js.map → context-CA8YKeMn.js.map} +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +6 -6
- package/dist/{core-BO4319td.js → core-DA4yqHWy.js} +5 -5
- package/dist/core-DA4yqHWy.js.map +1 -0
- package/dist/{css-writer-BWvwQzz0.js → css-writer-CU3TRy-4.js} +3 -3
- package/dist/css-writer-CU3TRy-4.js.map +1 -0
- package/dist/{format-global-rules-Dbc_1tc3.js → format-global-rules-DklyaXv-.js} +1 -1
- package/dist/{format-global-rules-Dbc_1tc3.js.map → format-global-rules-DklyaXv-.js.map} +1 -1
- package/dist/{format-rules-BSjeH4Z7.js → format-rules-DI6asJ4W.js} +2 -2
- package/dist/{format-rules-BSjeH4Z7.js.map → format-rules-DI6asJ4W.js.map} +1 -1
- package/dist/{hydrate-CcvrP4qJ.js → hydrate-DcV9oyNg.js} +2 -2
- package/dist/{hydrate-CcvrP4qJ.js.map → hydrate-DcV9oyNg.js.map} +1 -1
- package/dist/{index-B_k47mc_.d.ts → index-D0jLMU8n.d.ts} +98 -5
- package/dist/{index-tcHuMPFt.d.ts → index-DyVaR8w2.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/{keyframes-BUQhdOSJ.js → keyframes-CB1Jdwt2.js} +10 -3
- package/dist/keyframes-CB1Jdwt2.js.map +1 -0
- package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-CNbuti_3.d.ts} +2 -2
- package/dist/{merge-styles-Cd2vBl9b.js → merge-styles-pkF8CM_w.js} +2 -2
- package/dist/{merge-styles-Cd2vBl9b.js.map → merge-styles-pkF8CM_w.js.map} +1 -1
- package/dist/{resolve-recipes-C1nrvnYh.js → resolve-recipes-DgSs-cR9.js} +3 -3
- package/dist/{resolve-recipes-C1nrvnYh.js.map → resolve-recipes-DgSs-cR9.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 +4 -4
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +5 -5
- 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 +2 -3
- 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/package.json +11 -2
- package/dist/config-BBiyxMCe.js.map +0 -1
- package/dist/core-BO4319td.js.map +0 -1
- package/dist/css-writer-BWvwQzz0.js.map +0 -1
- package/dist/keyframes-BUQhdOSJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-storage-
|
|
1
|
+
{"version":3,"file":"async-storage-DKK-wTD4.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,kBAAwC;CAE3D,OAAO,EAAE;AACX;;;;;;AAOA,SAAgB,iBACd,WACA,IACG;CACH,OAAO,iBAAiB,CAAC,CAAC,IAAI,WAAW,EAAE;AAC7C;;;;;AAMA,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,iBAAiB;CACjC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,SAAS,KAAK;AAC/B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
3
|
-
import { t as formatGlobalRules } from "./format-global-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-DwOYoUrU.js";
|
|
2
|
+
import { n as formatPropertyCSS, t as formatRules } from "./format-rules-DI6asJ4W.js";
|
|
3
|
+
import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
|
|
4
4
|
//#region src/ssr/collector.ts
|
|
5
5
|
/**
|
|
6
6
|
* ServerStyleCollector — server-safe style collector for SSR.
|
|
@@ -240,4 +240,4 @@ var ServerStyleCollector = class {
|
|
|
240
240
|
//#endregion
|
|
241
241
|
export { ServerStyleCollector as t };
|
|
242
242
|
|
|
243
|
-
//# sourceMappingURL=collector-
|
|
243
|
+
//# sourceMappingURL=collector-C3gQB0SA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector-C-keQH9m.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,KAAK,oBAAoB;EAC7B,KAAK,qBAAqB;EAE1B,KAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QACvC,wBAAwB,CACzB,EAAE;GACD,MAAM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AAI;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
|
+
{"version":3,"file":"collector-C3gQB0SA.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,IAAoB;CACzC,sCAA8B,IAAI,IAAoB;CACtD,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,I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;CAM5C,wBAAkC;EAChC,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,aAAa,KAAK,oBAAoB,OAAO,GACtD,IAAI,CAAC,KAAK,kBAAkB,IAAI,SAAS,GAAG;GAC1C,KAAK,kBAAkB,IAAI,SAAS;GACpC,MAAM,KAAK,SAAS;EACtB;EAEF,OAAO;CACT;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as StyleResult } from "./index-
|
|
1
|
+
import { n as StyleResult } from "./index-DyVaR8w2.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-C7gJvDRF.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-
|
|
1
|
+
import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-DyVaR8w2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/injector/sheet-manager.d.ts
|
|
4
4
|
declare class SheetManager {
|
|
@@ -942,4 +942,4 @@ declare function getNamePrefix(): string;
|
|
|
942
942
|
declare function resetConfig(): void;
|
|
943
943
|
//#endregion
|
|
944
944
|
export { SheetManager as S, TypographyPreset as _, getGlobalFontFace as a, ColorSpace as b, getNamePrefix as c, hasStylesGenerated as d, isConfigLocked as f, TastyPluginFactory as g, TastyPlugin as h, getGlobalCounterStyle as i, hasGlobalKeyframes as l, resetConfig as m, configure as n, getGlobalKeyframes as o, isTestEnvironment as p, getConfig as r, getGlobalRecipes as s, TastyConfig as t, hasGlobalRecipes as u, TypographyTokenValue as v, StyleInjector as x, generateTypographyTokens as y };
|
|
945
|
-
//# sourceMappingURL=config-
|
|
945
|
+
//# sourceMappingURL=config-BFTzQlGr.d.ts.map
|
|
@@ -55,6 +55,223 @@ function canonicalFuncName(lowered) {
|
|
|
55
55
|
return CANONICAL_FUNC_CASE.get(lowered) ?? lowered;
|
|
56
56
|
}
|
|
57
57
|
//#endregion
|
|
58
|
+
//#region src/properties/index.ts
|
|
59
|
+
const PROPERTIES_KEY = "@properties";
|
|
60
|
+
/**
|
|
61
|
+
* Valid CSS custom property name pattern (after the -- prefix).
|
|
62
|
+
* Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.
|
|
63
|
+
*/
|
|
64
|
+
const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
|
|
65
|
+
/**
|
|
66
|
+
* Validate a CSS custom property name (the part after --).
|
|
67
|
+
* Returns true if the name is valid for use as a CSS custom property.
|
|
68
|
+
*/
|
|
69
|
+
function isValidPropertyName(name) {
|
|
70
|
+
return VALID_PROPERTY_NAME_PATTERN.test(name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if styles object has local @properties definition.
|
|
74
|
+
* Fast path: single property lookup.
|
|
75
|
+
*/
|
|
76
|
+
function hasLocalProperties(styles) {
|
|
77
|
+
return PROPERTIES_KEY in styles;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract local @properties from styles object.
|
|
81
|
+
* Returns null if no local properties (fast path).
|
|
82
|
+
*/
|
|
83
|
+
function extractLocalProperties(styles) {
|
|
84
|
+
const properties = styles[PROPERTIES_KEY];
|
|
85
|
+
if (!properties || typeof properties !== "object") return null;
|
|
86
|
+
return properties;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parse a property token name and return the CSS property name and whether it's a color.
|
|
90
|
+
* Supports tasty token syntax and validates the property name.
|
|
91
|
+
*
|
|
92
|
+
* Token formats:
|
|
93
|
+
* - `$name` → { cssName: '--name', isColor: false }
|
|
94
|
+
* - `#name` → { cssName: '--name-color', isColor: true }
|
|
95
|
+
* - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)
|
|
96
|
+
* - `name` → { cssName: '--name', isColor: false } (legacy)
|
|
97
|
+
*
|
|
98
|
+
* @param token - The property token to parse
|
|
99
|
+
* @returns Parsed result with cssName, isColor, isValid, and optional error
|
|
100
|
+
*/
|
|
101
|
+
function parsePropertyToken(token) {
|
|
102
|
+
if (!token || typeof token !== "string") return {
|
|
103
|
+
cssName: "",
|
|
104
|
+
isColor: false,
|
|
105
|
+
isValid: false,
|
|
106
|
+
error: "Property token must be a non-empty string"
|
|
107
|
+
};
|
|
108
|
+
let name;
|
|
109
|
+
let isColor;
|
|
110
|
+
if (token.startsWith("$")) {
|
|
111
|
+
name = token.slice(1);
|
|
112
|
+
isColor = false;
|
|
113
|
+
} else if (token.startsWith("#")) {
|
|
114
|
+
name = token.slice(1);
|
|
115
|
+
isColor = true;
|
|
116
|
+
} else if (token.startsWith("--")) {
|
|
117
|
+
name = token.slice(2);
|
|
118
|
+
isColor = token.endsWith("-color");
|
|
119
|
+
} else {
|
|
120
|
+
name = token;
|
|
121
|
+
isColor = token.endsWith("-color");
|
|
122
|
+
}
|
|
123
|
+
if (!name) return {
|
|
124
|
+
cssName: "",
|
|
125
|
+
isColor,
|
|
126
|
+
isValid: false,
|
|
127
|
+
error: "Property name cannot be empty"
|
|
128
|
+
};
|
|
129
|
+
if (!isValidPropertyName(name)) return {
|
|
130
|
+
cssName: "",
|
|
131
|
+
isColor,
|
|
132
|
+
isValid: false,
|
|
133
|
+
error: `Invalid property name "${name}". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`
|
|
134
|
+
};
|
|
135
|
+
let cssName;
|
|
136
|
+
if (token.startsWith("#")) cssName = `--${name}-color`;
|
|
137
|
+
else cssName = `--${name}`;
|
|
138
|
+
return {
|
|
139
|
+
cssName,
|
|
140
|
+
isColor,
|
|
141
|
+
isValid: true
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Normalize a property definition to a consistent string representation.
|
|
146
|
+
* Used for comparing definitions to detect type conflicts.
|
|
147
|
+
*
|
|
148
|
+
* Only `syntax` and `inherits` are compared — `initialValue` is intentionally
|
|
149
|
+
* excluded because different components may set different defaults for the
|
|
150
|
+
* same typed property (e.g. auto-inferred `0px` vs explicit `6px`).
|
|
151
|
+
*
|
|
152
|
+
* Keys are sorted alphabetically to ensure consistent comparison:
|
|
153
|
+
* { inherits: true, syntax: '<color>' } === { syntax: '<color>', inherits: true }
|
|
154
|
+
*/
|
|
155
|
+
function normalizePropertyDefinition(def) {
|
|
156
|
+
const normalized = {};
|
|
157
|
+
if (def.inherits !== void 0) normalized.inherits = def.inherits;
|
|
158
|
+
if (def.syntax !== void 0) normalized.syntax = def.syntax;
|
|
159
|
+
return JSON.stringify(normalized);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the effective property definition for a token.
|
|
163
|
+
* For color tokens (#name), auto-sets syntax to '<color>' and defaults initialValue to 'transparent'.
|
|
164
|
+
*
|
|
165
|
+
* @param token - Property token ($name, #name, --name, or plain name)
|
|
166
|
+
* @param userDefinition - User-provided definition options
|
|
167
|
+
* @returns Effective definition with cssName, definition, isValid, and optional error
|
|
168
|
+
*/
|
|
169
|
+
function getEffectiveDefinition(token, userDefinition) {
|
|
170
|
+
const parsed = parsePropertyToken(token);
|
|
171
|
+
if (!parsed.isValid) return {
|
|
172
|
+
cssName: "",
|
|
173
|
+
definition: userDefinition,
|
|
174
|
+
isColor: false,
|
|
175
|
+
isValid: false,
|
|
176
|
+
error: parsed.error
|
|
177
|
+
};
|
|
178
|
+
if (parsed.isColor) return {
|
|
179
|
+
cssName: parsed.cssName,
|
|
180
|
+
definition: {
|
|
181
|
+
syntax: "<color>",
|
|
182
|
+
inherits: userDefinition.inherits,
|
|
183
|
+
initialValue: userDefinition.initialValue ?? "transparent"
|
|
184
|
+
},
|
|
185
|
+
isColor: true,
|
|
186
|
+
isValid: true
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
cssName: parsed.cssName,
|
|
190
|
+
definition: userDefinition,
|
|
191
|
+
isColor: false,
|
|
192
|
+
isValid: true
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const UNIT_TO_SYNTAX = {};
|
|
196
|
+
const LENGTH_UNITS = [
|
|
197
|
+
"px",
|
|
198
|
+
"em",
|
|
199
|
+
"rem",
|
|
200
|
+
"vw",
|
|
201
|
+
"vh",
|
|
202
|
+
"vmin",
|
|
203
|
+
"vmax",
|
|
204
|
+
"ch",
|
|
205
|
+
"ex",
|
|
206
|
+
"cap",
|
|
207
|
+
"ic",
|
|
208
|
+
"lh",
|
|
209
|
+
"rlh",
|
|
210
|
+
"svw",
|
|
211
|
+
"svh",
|
|
212
|
+
"lvw",
|
|
213
|
+
"lvh",
|
|
214
|
+
"dvw",
|
|
215
|
+
"dvh",
|
|
216
|
+
"cqw",
|
|
217
|
+
"cqh",
|
|
218
|
+
"cqi",
|
|
219
|
+
"cqb",
|
|
220
|
+
"cqmin",
|
|
221
|
+
"cqmax"
|
|
222
|
+
];
|
|
223
|
+
const ANGLE_UNITS = [
|
|
224
|
+
"deg",
|
|
225
|
+
"rad",
|
|
226
|
+
"grad",
|
|
227
|
+
"turn"
|
|
228
|
+
];
|
|
229
|
+
const TIME_UNITS = ["ms", "s"];
|
|
230
|
+
for (const u of LENGTH_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
231
|
+
syntax: "<length-percentage>",
|
|
232
|
+
initialValue: "0px"
|
|
233
|
+
};
|
|
234
|
+
UNIT_TO_SYNTAX["%"] = {
|
|
235
|
+
syntax: "<length-percentage>",
|
|
236
|
+
initialValue: "0px"
|
|
237
|
+
};
|
|
238
|
+
for (const u of ANGLE_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
239
|
+
syntax: "<angle>",
|
|
240
|
+
initialValue: "0deg"
|
|
241
|
+
};
|
|
242
|
+
for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
243
|
+
syntax: "<time>",
|
|
244
|
+
initialValue: "0s"
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Infer CSS @property syntax from a concrete value.
|
|
248
|
+
* Detects numeric types: \<number\>, \<length-percentage\>, \<angle\>, \<time\>.
|
|
249
|
+
* Length and percentage values both map to \<length-percentage\> for maximum flexibility.
|
|
250
|
+
* Color properties are handled separately via the #name token convention
|
|
251
|
+
* (--name-color gets \<color\> syntax automatically in getEffectiveDefinition).
|
|
252
|
+
*
|
|
253
|
+
* @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')
|
|
254
|
+
* @returns Inferred syntax and initial value, or null if not inferable
|
|
255
|
+
*/
|
|
256
|
+
function inferSyntaxFromValue(value) {
|
|
257
|
+
if (!value || typeof value !== "string") return null;
|
|
258
|
+
const trimmed = value.trim();
|
|
259
|
+
if (!trimmed) return null;
|
|
260
|
+
if (RE_NUMBER.test(trimmed)) {
|
|
261
|
+
if (parseFloat(trimmed) === 0) return null;
|
|
262
|
+
return {
|
|
263
|
+
syntax: "<number>",
|
|
264
|
+
initialValue: "0"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const unitMatch = trimmed.match(RE_RAW_UNIT);
|
|
268
|
+
if (unitMatch) {
|
|
269
|
+
const mapping = UNIT_TO_SYNTAX[unitMatch[2]];
|
|
270
|
+
if (mapping) return mapping;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
58
275
|
//#region src/parser/lru.ts
|
|
59
276
|
var Lru = class {
|
|
60
277
|
limit;
|
|
@@ -233,7 +450,7 @@ function srgbLinearToGamma(val) {
|
|
|
233
450
|
const TAU = 2 * Math.PI;
|
|
234
451
|
const K1 = .206;
|
|
235
452
|
const K2 = .03;
|
|
236
|
-
const K3 =
|
|
453
|
+
const K3 = 1.206 / 1.03;
|
|
237
454
|
const clamp$1 = (value, min, max) => Math.max(Math.min(value, max), min);
|
|
238
455
|
const constrainAngle = (angle) => (angle % 360 + 360) % 360;
|
|
239
456
|
const toeInv = (x) => (x ** 2 + K1 * x) / (K3 * (x + K2));
|
|
@@ -1131,223 +1348,6 @@ function getComponentPropertySyntax() {
|
|
|
1131
1348
|
}
|
|
1132
1349
|
}
|
|
1133
1350
|
//#endregion
|
|
1134
|
-
//#region src/properties/index.ts
|
|
1135
|
-
const PROPERTIES_KEY = "@properties";
|
|
1136
|
-
/**
|
|
1137
|
-
* Valid CSS custom property name pattern (after the -- prefix).
|
|
1138
|
-
* Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.
|
|
1139
|
-
*/
|
|
1140
|
-
const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
|
|
1141
|
-
/**
|
|
1142
|
-
* Validate a CSS custom property name (the part after --).
|
|
1143
|
-
* Returns true if the name is valid for use as a CSS custom property.
|
|
1144
|
-
*/
|
|
1145
|
-
function isValidPropertyName(name) {
|
|
1146
|
-
return VALID_PROPERTY_NAME_PATTERN.test(name);
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Check if styles object has local @properties definition.
|
|
1150
|
-
* Fast path: single property lookup.
|
|
1151
|
-
*/
|
|
1152
|
-
function hasLocalProperties(styles) {
|
|
1153
|
-
return PROPERTIES_KEY in styles;
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Extract local @properties from styles object.
|
|
1157
|
-
* Returns null if no local properties (fast path).
|
|
1158
|
-
*/
|
|
1159
|
-
function extractLocalProperties(styles) {
|
|
1160
|
-
const properties = styles[PROPERTIES_KEY];
|
|
1161
|
-
if (!properties || typeof properties !== "object") return null;
|
|
1162
|
-
return properties;
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* Parse a property token name and return the CSS property name and whether it's a color.
|
|
1166
|
-
* Supports tasty token syntax and validates the property name.
|
|
1167
|
-
*
|
|
1168
|
-
* Token formats:
|
|
1169
|
-
* - `$name` → { cssName: '--name', isColor: false }
|
|
1170
|
-
* - `#name` → { cssName: '--name-color', isColor: true }
|
|
1171
|
-
* - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)
|
|
1172
|
-
* - `name` → { cssName: '--name', isColor: false } (legacy)
|
|
1173
|
-
*
|
|
1174
|
-
* @param token - The property token to parse
|
|
1175
|
-
* @returns Parsed result with cssName, isColor, isValid, and optional error
|
|
1176
|
-
*/
|
|
1177
|
-
function parsePropertyToken(token) {
|
|
1178
|
-
if (!token || typeof token !== "string") return {
|
|
1179
|
-
cssName: "",
|
|
1180
|
-
isColor: false,
|
|
1181
|
-
isValid: false,
|
|
1182
|
-
error: "Property token must be a non-empty string"
|
|
1183
|
-
};
|
|
1184
|
-
let name;
|
|
1185
|
-
let isColor;
|
|
1186
|
-
if (token.startsWith("$")) {
|
|
1187
|
-
name = token.slice(1);
|
|
1188
|
-
isColor = false;
|
|
1189
|
-
} else if (token.startsWith("#")) {
|
|
1190
|
-
name = token.slice(1);
|
|
1191
|
-
isColor = true;
|
|
1192
|
-
} else if (token.startsWith("--")) {
|
|
1193
|
-
name = token.slice(2);
|
|
1194
|
-
isColor = token.endsWith("-color");
|
|
1195
|
-
} else {
|
|
1196
|
-
name = token;
|
|
1197
|
-
isColor = token.endsWith("-color");
|
|
1198
|
-
}
|
|
1199
|
-
if (!name) return {
|
|
1200
|
-
cssName: "",
|
|
1201
|
-
isColor,
|
|
1202
|
-
isValid: false,
|
|
1203
|
-
error: "Property name cannot be empty"
|
|
1204
|
-
};
|
|
1205
|
-
if (!isValidPropertyName(name)) return {
|
|
1206
|
-
cssName: "",
|
|
1207
|
-
isColor,
|
|
1208
|
-
isValid: false,
|
|
1209
|
-
error: `Invalid property name "${name}". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`
|
|
1210
|
-
};
|
|
1211
|
-
let cssName;
|
|
1212
|
-
if (token.startsWith("#")) cssName = `--${name}-color`;
|
|
1213
|
-
else cssName = `--${name}`;
|
|
1214
|
-
return {
|
|
1215
|
-
cssName,
|
|
1216
|
-
isColor,
|
|
1217
|
-
isValid: true
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Normalize a property definition to a consistent string representation.
|
|
1222
|
-
* Used for comparing definitions to detect type conflicts.
|
|
1223
|
-
*
|
|
1224
|
-
* Only `syntax` and `inherits` are compared — `initialValue` is intentionally
|
|
1225
|
-
* excluded because different components may set different defaults for the
|
|
1226
|
-
* same typed property (e.g. auto-inferred `0px` vs explicit `6px`).
|
|
1227
|
-
*
|
|
1228
|
-
* Keys are sorted alphabetically to ensure consistent comparison:
|
|
1229
|
-
* { inherits: true, syntax: '<color>' } === { syntax: '<color>', inherits: true }
|
|
1230
|
-
*/
|
|
1231
|
-
function normalizePropertyDefinition(def) {
|
|
1232
|
-
const normalized = {};
|
|
1233
|
-
if (def.inherits !== void 0) normalized.inherits = def.inherits;
|
|
1234
|
-
if (def.syntax !== void 0) normalized.syntax = def.syntax;
|
|
1235
|
-
return JSON.stringify(normalized);
|
|
1236
|
-
}
|
|
1237
|
-
/**
|
|
1238
|
-
* Get the effective property definition for a token.
|
|
1239
|
-
* For color tokens (#name), auto-sets syntax to '<color>' and defaults initialValue to 'transparent'.
|
|
1240
|
-
*
|
|
1241
|
-
* @param token - Property token ($name, #name, --name, or plain name)
|
|
1242
|
-
* @param userDefinition - User-provided definition options
|
|
1243
|
-
* @returns Effective definition with cssName, definition, isValid, and optional error
|
|
1244
|
-
*/
|
|
1245
|
-
function getEffectiveDefinition(token, userDefinition) {
|
|
1246
|
-
const parsed = parsePropertyToken(token);
|
|
1247
|
-
if (!parsed.isValid) return {
|
|
1248
|
-
cssName: "",
|
|
1249
|
-
definition: userDefinition,
|
|
1250
|
-
isColor: false,
|
|
1251
|
-
isValid: false,
|
|
1252
|
-
error: parsed.error
|
|
1253
|
-
};
|
|
1254
|
-
if (parsed.isColor) return {
|
|
1255
|
-
cssName: parsed.cssName,
|
|
1256
|
-
definition: {
|
|
1257
|
-
syntax: "<color>",
|
|
1258
|
-
inherits: userDefinition.inherits,
|
|
1259
|
-
initialValue: userDefinition.initialValue ?? "transparent"
|
|
1260
|
-
},
|
|
1261
|
-
isColor: true,
|
|
1262
|
-
isValid: true
|
|
1263
|
-
};
|
|
1264
|
-
return {
|
|
1265
|
-
cssName: parsed.cssName,
|
|
1266
|
-
definition: userDefinition,
|
|
1267
|
-
isColor: false,
|
|
1268
|
-
isValid: true
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
const UNIT_TO_SYNTAX = {};
|
|
1272
|
-
const LENGTH_UNITS = [
|
|
1273
|
-
"px",
|
|
1274
|
-
"em",
|
|
1275
|
-
"rem",
|
|
1276
|
-
"vw",
|
|
1277
|
-
"vh",
|
|
1278
|
-
"vmin",
|
|
1279
|
-
"vmax",
|
|
1280
|
-
"ch",
|
|
1281
|
-
"ex",
|
|
1282
|
-
"cap",
|
|
1283
|
-
"ic",
|
|
1284
|
-
"lh",
|
|
1285
|
-
"rlh",
|
|
1286
|
-
"svw",
|
|
1287
|
-
"svh",
|
|
1288
|
-
"lvw",
|
|
1289
|
-
"lvh",
|
|
1290
|
-
"dvw",
|
|
1291
|
-
"dvh",
|
|
1292
|
-
"cqw",
|
|
1293
|
-
"cqh",
|
|
1294
|
-
"cqi",
|
|
1295
|
-
"cqb",
|
|
1296
|
-
"cqmin",
|
|
1297
|
-
"cqmax"
|
|
1298
|
-
];
|
|
1299
|
-
const ANGLE_UNITS = [
|
|
1300
|
-
"deg",
|
|
1301
|
-
"rad",
|
|
1302
|
-
"grad",
|
|
1303
|
-
"turn"
|
|
1304
|
-
];
|
|
1305
|
-
const TIME_UNITS = ["ms", "s"];
|
|
1306
|
-
for (const u of LENGTH_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1307
|
-
syntax: "<length-percentage>",
|
|
1308
|
-
initialValue: "0px"
|
|
1309
|
-
};
|
|
1310
|
-
UNIT_TO_SYNTAX["%"] = {
|
|
1311
|
-
syntax: "<length-percentage>",
|
|
1312
|
-
initialValue: "0px"
|
|
1313
|
-
};
|
|
1314
|
-
for (const u of ANGLE_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1315
|
-
syntax: "<angle>",
|
|
1316
|
-
initialValue: "0deg"
|
|
1317
|
-
};
|
|
1318
|
-
for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
|
|
1319
|
-
syntax: "<time>",
|
|
1320
|
-
initialValue: "0s"
|
|
1321
|
-
};
|
|
1322
|
-
/**
|
|
1323
|
-
* Infer CSS @property syntax from a concrete value.
|
|
1324
|
-
* Detects numeric types: \<number\>, \<length-percentage\>, \<angle\>, \<time\>.
|
|
1325
|
-
* Length and percentage values both map to \<length-percentage\> for maximum flexibility.
|
|
1326
|
-
* Color properties are handled separately via the #name token convention
|
|
1327
|
-
* (--name-color gets \<color\> syntax automatically in getEffectiveDefinition).
|
|
1328
|
-
*
|
|
1329
|
-
* @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')
|
|
1330
|
-
* @returns Inferred syntax and initial value, or null if not inferable
|
|
1331
|
-
*/
|
|
1332
|
-
function inferSyntaxFromValue(value) {
|
|
1333
|
-
if (!value || typeof value !== "string") return null;
|
|
1334
|
-
const trimmed = value.trim();
|
|
1335
|
-
if (!trimmed) return null;
|
|
1336
|
-
if (RE_NUMBER.test(trimmed)) {
|
|
1337
|
-
if (parseFloat(trimmed) === 0) return null;
|
|
1338
|
-
return {
|
|
1339
|
-
syntax: "<number>",
|
|
1340
|
-
initialValue: "0"
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
const unitMatch = trimmed.match(RE_RAW_UNIT);
|
|
1344
|
-
if (unitMatch) {
|
|
1345
|
-
const mapping = UNIT_TO_SYNTAX[unitMatch[2]];
|
|
1346
|
-
if (mapping) return mapping;
|
|
1347
|
-
}
|
|
1348
|
-
return null;
|
|
1349
|
-
}
|
|
1350
|
-
//#endregion
|
|
1351
1351
|
//#region src/utils/hash.ts
|
|
1352
1352
|
/**
|
|
1353
1353
|
* Fast string hash (djb2) for deduplication keys.
|
|
@@ -1371,8 +1371,7 @@ function isDevEnv() {
|
|
|
1371
1371
|
if (forceTastyDebug !== null && forceTastyDebug.toLowerCase() === "true") return true;
|
|
1372
1372
|
} catch {}
|
|
1373
1373
|
if (typeof process === "undefined") return false;
|
|
1374
|
-
|
|
1375
|
-
return nodeEnv !== "test" && nodeEnv !== "production";
|
|
1374
|
+
return true;
|
|
1376
1375
|
}
|
|
1377
1376
|
//#endregion
|
|
1378
1377
|
//#region src/utils/name-prefix.ts
|
|
@@ -3783,7 +3782,7 @@ function resetHandlers() {
|
|
|
3783
3782
|
for (const key of Object.keys(STYLE_HANDLER_MAP$1)) delete STYLE_HANDLER_MAP$1[key];
|
|
3784
3783
|
for (const key of Object.keys(initialHandlerMapSnapshot)) STYLE_HANDLER_MAP$1[key] = [...initialHandlerMapSnapshot[key]];
|
|
3785
3784
|
}
|
|
3786
|
-
function defineCustomStyle
|
|
3785
|
+
function defineCustomStyle(names, handler) {
|
|
3787
3786
|
let handlerWithLookup;
|
|
3788
3787
|
if (typeof names === "function") {
|
|
3789
3788
|
handlerWithLookup = names;
|
|
@@ -3798,16 +3797,16 @@ function defineCustomStyle$1(names, handler) {
|
|
|
3798
3797
|
STYLE_HANDLER_MAP$1[name].push(handlerWithLookup);
|
|
3799
3798
|
});
|
|
3800
3799
|
}
|
|
3801
|
-
function defineStyleAlias
|
|
3800
|
+
function defineStyleAlias(styleName, cssStyleName, converter) {
|
|
3802
3801
|
const styleHandler = createStyle(styleName, cssStyleName, converter);
|
|
3803
3802
|
if (!STYLE_HANDLER_MAP$1[styleName]) STYLE_HANDLER_MAP$1[styleName] = [];
|
|
3804
3803
|
STYLE_HANDLER_MAP$1[styleName].push(styleHandler);
|
|
3805
3804
|
}
|
|
3806
3805
|
function predefine() {
|
|
3807
|
-
defineStyleAlias
|
|
3808
|
-
defineStyleAlias
|
|
3809
|
-
defineStyleAlias
|
|
3810
|
-
defineStyleAlias
|
|
3806
|
+
defineStyleAlias("gridAreas", "grid-template-areas");
|
|
3807
|
+
defineStyleAlias("gridColumns", "grid-template-columns", columnsConverter);
|
|
3808
|
+
defineStyleAlias("gridRows", "grid-template-rows", rowsConverter);
|
|
3809
|
+
defineStyleAlias("gridTemplate", "grid-template", (val) => {
|
|
3811
3810
|
if (typeof val !== "string") return;
|
|
3812
3811
|
return val.split("/").map((s, i) => (i ? columnsConverter : rowsConverter)(s)).join("/");
|
|
3813
3812
|
});
|
|
@@ -3833,12 +3832,12 @@ function predefine() {
|
|
|
3833
3832
|
scrollbarStyle,
|
|
3834
3833
|
fadeStyle,
|
|
3835
3834
|
insetStyle
|
|
3836
|
-
].forEach((handler) => defineCustomStyle
|
|
3835
|
+
].forEach((handler) => defineCustomStyle(handler));
|
|
3837
3836
|
captureInitialHandlerState();
|
|
3838
3837
|
return {
|
|
3839
3838
|
STYLE_HANDLER_MAP: STYLE_HANDLER_MAP$1,
|
|
3840
|
-
defineCustomStyle
|
|
3841
|
-
defineStyleAlias
|
|
3839
|
+
defineCustomStyle,
|
|
3840
|
+
defineStyleAlias
|
|
3842
3841
|
};
|
|
3843
3842
|
}
|
|
3844
3843
|
/**
|
|
@@ -3969,7 +3968,7 @@ const styleHandlers = {
|
|
|
3969
3968
|
};
|
|
3970
3969
|
//#endregion
|
|
3971
3970
|
//#region src/styles/index.ts
|
|
3972
|
-
const { STYLE_HANDLER_MAP
|
|
3971
|
+
const { STYLE_HANDLER_MAP } = predefine();
|
|
3973
3972
|
//#endregion
|
|
3974
3973
|
//#region src/injector/sheet-manager.ts
|
|
3975
3974
|
const supportsConstructableSheets = typeof CSSStyleSheet !== "undefined" && (() => {
|
|
@@ -10554,6 +10553,6 @@ function resetConfig() {
|
|
|
10554
10553
|
delete storage[GLOBAL_INJECTOR_KEY];
|
|
10555
10554
|
}
|
|
10556
10555
|
//#endregion
|
|
10557
|
-
export { parseColor as $, StyleInjector as A,
|
|
10556
|
+
export { parseColor as $, StyleInjector as A, hasLocalProperties as At, styleHandlers as B, parseStateKey as C, getRgbValuesFromRgbaString as Ct, extractPredefinedStateRefs as D, Lru as Dt, extractLocalPredefinedStates as E, strToRgb 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, extractLocalProperties as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getNamedColorHex as St, createStateParserContext as T, hslToRgbValues as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, colorInitialValueToComponents as _t, getGlobalCounterStyle as a, okhslPlugin as at, hasPipelineCacheEntry as b, getColorSpaceSuffix 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, parsePropertyToken as jt, setGlobalPredefinedStates as k, getEffectiveDefinition 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, getColorSpaceComponents as vt, camelToKebab as w, hexToRgb as wt, isSelector as x, getComponentPropertySyntax as xt, generateTypographyTokens as y, getColorSpaceFunc as yt, STYLE_HANDLER_MAP as z };
|
|
10558
10557
|
|
|
10559
|
-
//# sourceMappingURL=config-
|
|
10558
|
+
//# sourceMappingURL=config-DwOYoUrU.js.map
|