@tenphi/tasty 3.11.0 → 3.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/dist/chunks/{build-config-5d8WlQbq.js → build-config-DlxpZKk_.js} +4 -4
- package/dist/chunks/{build-config-5d8WlQbq.js.map → build-config-DlxpZKk_.js.map} +1 -1
- package/dist/chunks/{collector-CjCak4iE.js → collector-B4-yqFEs.js} +4 -4
- package/dist/chunks/{collector-CjCak4iE.js.map → collector-B4-yqFEs.js.map} +1 -1
- package/dist/chunks/{config-engine-uOFYZidB.js → config-engine-DJsb5WYu.js} +3 -3
- package/dist/chunks/{config-engine-uOFYZidB.js.map → config-engine-DJsb5WYu.js.map} +1 -1
- package/dist/chunks/{css-definitions-ubrHP97m.js → css-definitions-DW1TGGiy.js} +2 -2
- package/dist/chunks/{css-definitions-ubrHP97m.js.map → css-definitions-DW1TGGiy.js.map} +1 -1
- package/dist/chunks/{debug-CJ31U_WE.js → debug-DMMwe1rY.js} +4 -4
- package/dist/chunks/{debug-CJ31U_WE.js.map → debug-DMMwe1rY.js.map} +1 -1
- package/dist/chunks/{react-runtime-CyyCI02N.js → react-runtime-DhPtFlZs.js} +5 -5
- package/dist/chunks/react-runtime-DhPtFlZs.js.map +1 -0
- package/dist/chunks/{runtime-engine-BQmOu5-W.js → runtime-engine-BlrVXv8l.js} +5 -5
- package/dist/chunks/{runtime-engine-BQmOu5-W.js.map → runtime-engine-BlrVXv8l.js.map} +1 -1
- package/dist/chunks/{runtime-state-DEsyUMU-.js → runtime-state-BLyMRYFF.js} +2 -2
- package/dist/chunks/{runtime-state-DEsyUMU-.js.map → runtime-state-BLyMRYFF.js.map} +1 -1
- package/dist/chunks/{style-engine-BX2LshDZ.js → style-engine-of5Xbc27.js} +139 -34
- package/dist/chunks/style-engine-of5Xbc27.js.map +1 -0
- package/dist/chunks/{zero-engine-Dw0P4yGM.js → zero-engine-D2jPSpWA.js} +5 -5
- package/dist/chunks/{zero-engine-Dw0P4yGM.js.map → zero-engine-D2jPSpWA.js.map} +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +6 -6
- package/dist/{index-xtey-KDu.d.ts → index--GdqCPlp.d.ts} +16 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/ssr/astro.js +2 -2
- package/dist/ssr/index.js +2 -2
- package/dist/ssr/next-config.js +3 -3
- package/dist/ssr/next.js +3 -3
- package/dist/zero/babel.js +4 -4
- package/dist/zero/index.js +3 -3
- package/docs/ai-agents.md +5 -1
- package/docs/configuration.md +2 -1
- package/docs/design-system.md +1 -1
- package/docs/dsl.md +42 -3
- package/docs/injector.md +3 -1
- package/docs/methodology.md +7 -7
- package/docs/migration-v3.md +1 -1
- package/docs/pipeline.md +1 -1
- package/docs/plugins.md +1 -1
- package/docs/react-api.md +51 -8
- package/docs/ssr.md +29 -23
- package/docs/styles.md +6 -0
- package/docs/tasty-static.md +33 -16
- package/package.json +5 -5
- package/dist/chunks/react-runtime-CyyCI02N.js.map +0 -1
- package/dist/chunks/style-engine-BX2LshDZ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as DEFAULT_PROPERTIES, R as indexPropertiesByName } from "./css-definitions-
|
|
1
|
+
import { P as DEFAULT_PROPERTIES, R as indexPropertiesByName } from "./css-definitions-DW1TGGiy.js";
|
|
2
2
|
//#region src/config-resources.ts
|
|
3
3
|
let runtimeConfig = null;
|
|
4
4
|
let globalFontFace = null;
|
|
@@ -149,4 +149,4 @@ function getRegisteredSSRCollector() {
|
|
|
149
149
|
//#endregion
|
|
150
150
|
export { mergeGlobalKeyframes as _, getEffectivePropertiesByName as a, resetConfigResources as b, getGlobalFontFaces as c, getGlobalStyles as d, getRuntimeConfigState as f, mergeGlobalFunctions as g, mergeGlobalFontFaces as h, getEffectiveProperties as i, getGlobalFunctions as l, mergeGlobalCounterStyles as m, registerSSRCollectorGetter as n, getGlobalConfigTokens as o, mergeGlobalConfigTokens as p, registerSSRCollectorGetterGlobal as r, getGlobalCounterStyles as s, getRegisteredSSRCollector as t, getGlobalKeyframes as u, mergeGlobalProperties as v, setRuntimeConfigState as x, mergeGlobalStyles as y };
|
|
151
151
|
|
|
152
|
-
//# sourceMappingURL=runtime-state-
|
|
152
|
+
//# sourceMappingURL=runtime-state-BLyMRYFF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-state-DEsyUMU-.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { DeclaredPropertyEntry } from './properties';\nimport { indexPropertiesByName } from './properties';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nlet effectivePropertyIndex: {\n source: Record<string, PropertyDefinition> | null | undefined;\n index: ReadonlyMap<string, DeclaredPropertyEntry>;\n} | null = null;\n\n/**\n * The effective properties (Tasty's defaults and `configure({ properties })`)\n * keyed by the custom property each one registers — see\n * `indexPropertiesByName()`. Rebuilt only when `configure({ properties })`\n * replaces the set.\n */\nexport function getEffectivePropertiesByName(): ReadonlyMap<\n string,\n DeclaredPropertyEntry\n> {\n const source =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n\n if (effectivePropertyIndex && effectivePropertyIndex.source === source) {\n return effectivePropertyIndex.index;\n }\n\n const index = indexPropertiesByName(getEffectiveProperties());\n effectivePropertyIndex = { source, index };\n return index;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":";;AA2BA,IAAI,gBAA2C;AAC/C,IAAI,iBAAuD;AAC3D,IAAI,qBAAqE;AACzE,IAAI,iBAA4D;AAChE,IAAI,mBAA8D;AAClE,IAAI,qBAA0C;AAC9C,IAAI,eAA8C;AAClD,IAAI,kBAAyD;AAE7D,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AAExB,SAAS,gBAAgB,KAAa,OAAsB;CAC1D,WAAwC,OAAO;AACjD;AAEA,SAAS,kBAAqB,KAA4B;CACxD,OAAQ,WAAuC;AACjD;AAEA,SAAgB,wBAAmD;CACjE,OAAO;AACT;AAEA,SAAgB,sBAAsB,QAAkC;CACtE,gBAAgB;AAClB;AAEA,SAAgB,yBAA6D;CAC3E,MAAM,aACJ,oBACA,kBAAsD,gBAAgB;CACxE,OAAO,aACH;EAAE,GAAG;EAAoB,GAAG;CAAW,IACvC;AACN;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BAAgB,cAAc,kBAAkB;AAClD;AAEA,SAAgB,kBAAkB,QAAsC;CACtE,IAAI,cACF,KAAK,MAAM,CAAC,UAAU,mBAAmB,OAAO,QAAQ,MAAM,GAC5D,aAAa,YAAY,aAAa,YAClC;EAAE,GAAG,aAAa;EAAW,GAAG;CAAe,IAC/C;MAGN,eAAe,EAAE,GAAG,OAAO;CAE7B,gBAAgB,qBAAqB,YAAY;AACnD;AAEA,SAAgB,qBACd,WACM;CACN,kBAAkB;EAAE,GAAI,mBAAmB,KAAK,CAAC;EAAI,GAAG;CAAU;CAClE,gBAAgB,iBAAiB,eAAe;AAClD;AAEA,SAAgB,uBAA6B;CAC3C,gBAAgB;CAChB,mBAAmB;CACnB,iBAAiB;CACjB,qBAAqB;CACrB,iBAAiB;CACjB,qBAAqB;CACrB,eAAe;CACf,kBAAkB;CAElB,MAAM,cAAc;CACpB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;AACrB;;;ACpNA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;AAMlD,SAAgB,2BAA2B,IAA8B;CACvE,mBAAmB;AACrB;AAMA,SAAgB,iCAAiC,IAA8B;CAC7E,WAAwC,cAAc;AACxD;AAKA,SAAgB,4BAAyD;CACvE,IAAI,kBAAkB,OAAO,iBAAiB;CAC9C,MAAM,SAAU,WAAuC;CAEvD,OAAO,SAAS,OAAO,IAAI;AAC7B"}
|
|
1
|
+
{"version":3,"file":"runtime-state-BLyMRYFF.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { DeclaredPropertyEntry } from './properties';\nimport { indexPropertiesByName } from './properties';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nlet effectivePropertyIndex: {\n source: Record<string, PropertyDefinition> | null | undefined;\n index: ReadonlyMap<string, DeclaredPropertyEntry>;\n} | null = null;\n\n/**\n * The effective properties (Tasty's defaults and `configure({ properties })`)\n * keyed by the custom property each one registers — see\n * `indexPropertiesByName()`. Rebuilt only when `configure({ properties })`\n * replaces the set.\n */\nexport function getEffectivePropertiesByName(): ReadonlyMap<\n string,\n DeclaredPropertyEntry\n> {\n const source =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n\n if (effectivePropertyIndex && effectivePropertyIndex.source === source) {\n return effectivePropertyIndex.index;\n }\n\n const index = indexPropertiesByName(getEffectiveProperties());\n effectivePropertyIndex = { source, index };\n return index;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSR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AAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;AACrB;;;ACpNA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;AAMlD,SAAgB,2BAA2B,IAA8B;CACvE,mBAAmB;AACrB;AAMA,SAAgB,iCAAiC,IAA8B;CAC7E,WAAwC,cAAc;AACxD;AAKA,SAAgB,4BAAyD;CACvE,IAAI,kBAAkB,OAAO,iBAAiB;CAC9C,MAAM,SAAU,WAAuC;CAEvD,OAAO,SAAS,OAAO,IAAI;AAC7B"}
|
|
@@ -2044,6 +2044,48 @@ function rootStateIndex(selector) {
|
|
|
2044
2044
|
if (!isRoot) return -1;
|
|
2045
2045
|
return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
|
|
2046
2046
|
}
|
|
2047
|
+
function pseudoElementIndex(selector) {
|
|
2048
|
+
let pseudoElementAt = -1;
|
|
2049
|
+
let newCompound = false;
|
|
2050
|
+
let squareDepth = 0;
|
|
2051
|
+
let parenDepth = 0;
|
|
2052
|
+
let quote = "";
|
|
2053
|
+
for (let i = 0; i < selector.length; i++) {
|
|
2054
|
+
const char = selector[i];
|
|
2055
|
+
if (quote) {
|
|
2056
|
+
if (char === "\\") i++;
|
|
2057
|
+
else if (char === quote) quote = "";
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (char === "/" && selector[i + 1] === "*") {
|
|
2061
|
+
const end = selector.indexOf("*/", i + 2);
|
|
2062
|
+
if (end === -1) break;
|
|
2063
|
+
i = end + 1;
|
|
2064
|
+
continue;
|
|
2065
|
+
}
|
|
2066
|
+
if (squareDepth === 0 && parenDepth === 0) {
|
|
2067
|
+
if (/[\s>+~,]/.test(char)) {
|
|
2068
|
+
newCompound = true;
|
|
2069
|
+
continue;
|
|
2070
|
+
}
|
|
2071
|
+
if (newCompound) {
|
|
2072
|
+
pseudoElementAt = -1;
|
|
2073
|
+
newCompound = false;
|
|
2074
|
+
}
|
|
2075
|
+
if (pseudoElementAt === -1 && char === ":") {
|
|
2076
|
+
const name = /^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "";
|
|
2077
|
+
if (selector[i + 1] === ":" || LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
if (char === "\\") i++;
|
|
2081
|
+
else if (char === "\"" || char === "'") quote = char;
|
|
2082
|
+
else if (char === "[") squareDepth++;
|
|
2083
|
+
else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
|
|
2084
|
+
else if (char === "(") parenDepth++;
|
|
2085
|
+
else if (char === ")") parenDepth = Math.max(0, parenDepth - 1);
|
|
2086
|
+
}
|
|
2087
|
+
return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
|
|
2088
|
+
}
|
|
2047
2089
|
function splitSelectorsSafely(selectorList) {
|
|
2048
2090
|
if (!selectorList.includes(",")) {
|
|
2049
2091
|
const selector = selectorList.trim();
|
|
@@ -4615,6 +4657,35 @@ function clearParseCache() {
|
|
|
4615
4657
|
parseCache.clear();
|
|
4616
4658
|
}
|
|
4617
4659
|
//#endregion
|
|
4660
|
+
//#region src/pipeline/pseudo-element-states.ts
|
|
4661
|
+
const QUOTED_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g;
|
|
4662
|
+
const STRUCTURAL_PSEUDO_RE = /:(?:root|empty|scope|has|(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type))(?![\w-])/i;
|
|
4663
|
+
function leafMismatch(node) {
|
|
4664
|
+
if (node.kind !== "state") return null;
|
|
4665
|
+
if (node.type === "modifier") return "modifiers";
|
|
4666
|
+
if (node.type !== "pseudo") return null;
|
|
4667
|
+
const selector = node.pseudo.replace(QUOTED_RE, "\"\"");
|
|
4668
|
+
if (STRUCTURAL_PSEUDO_RE.test(selector)) return "position in the DOM tree";
|
|
4669
|
+
if (selector.includes("[")) return "attributes";
|
|
4670
|
+
if (selector.includes(".") || selector.includes("#")) return "classes or ids";
|
|
4671
|
+
return null;
|
|
4672
|
+
}
|
|
4673
|
+
function pseudoElementMismatch(condition, target) {
|
|
4674
|
+
const walk = (node, describesTarget) => {
|
|
4675
|
+
if (node.kind === "compound") {
|
|
4676
|
+
for (const child of node.children) {
|
|
4677
|
+
const found = walk(child, describesTarget);
|
|
4678
|
+
if (found) return found;
|
|
4679
|
+
}
|
|
4680
|
+
return null;
|
|
4681
|
+
}
|
|
4682
|
+
if (node.kind !== "state") return null;
|
|
4683
|
+
if (node.type === "own") return target.own || target.root ? walk(node.innerCondition, true) : null;
|
|
4684
|
+
return describesTarget ? leafMismatch(node) : null;
|
|
4685
|
+
};
|
|
4686
|
+
return walk(condition, target.root);
|
|
4687
|
+
}
|
|
4688
|
+
//#endregion
|
|
4618
4689
|
//#region src/pipeline/index.ts
|
|
4619
4690
|
const RE_UPPER_CASE = /[A-Z]/;
|
|
4620
4691
|
const pipelineCache = new Lru(5e3);
|
|
@@ -4624,9 +4695,9 @@ function hasPipelineCacheEntry(cacheKey) {
|
|
|
4624
4695
|
function clearPipelineCache() {
|
|
4625
4696
|
pipelineCache.clear();
|
|
4626
4697
|
}
|
|
4627
|
-
function runPipeline(styles, parserContext) {
|
|
4698
|
+
function runPipeline(styles, parserContext, pseudoElementRoot = false) {
|
|
4628
4699
|
const allRules = [];
|
|
4629
|
-
processStyles(styles, "", parserContext, allRules);
|
|
4700
|
+
processStyles(styles, "", parserContext, allRules, pseudoElementRoot);
|
|
4630
4701
|
const seen = /* @__PURE__ */ new Set();
|
|
4631
4702
|
const normal = [];
|
|
4632
4703
|
const starting = [];
|
|
@@ -4642,7 +4713,7 @@ function stableSortByOrder(rules) {
|
|
|
4642
4713
|
if (rules.length <= 1) return rules;
|
|
4643
4714
|
return [...rules].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
4644
4715
|
}
|
|
4645
|
-
function processStyles(styles, selectorSuffix, parserContext, allRules) {
|
|
4716
|
+
function processStyles(styles, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
|
|
4646
4717
|
const keys = Object.keys(styles);
|
|
4647
4718
|
const selectorKeys = [];
|
|
4648
4719
|
const styleKeys = [];
|
|
@@ -4658,10 +4729,10 @@ function processStyles(styles, selectorSuffix, parserContext, allRules) {
|
|
|
4658
4729
|
}
|
|
4659
4730
|
styleKeys.push(key);
|
|
4660
4731
|
}
|
|
4661
|
-
processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules);
|
|
4662
|
-
processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules);
|
|
4732
|
+
processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot);
|
|
4733
|
+
processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules, pseudoElementRoot);
|
|
4663
4734
|
}
|
|
4664
|
-
function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules) {
|
|
4735
|
+
function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
|
|
4665
4736
|
for (const key of selectorKeys) {
|
|
4666
4737
|
const nestedStyles = styles[key];
|
|
4667
4738
|
if (!nestedStyles || typeof nestedStyles !== "object") continue;
|
|
@@ -4678,30 +4749,34 @@ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserCont
|
|
|
4678
4749
|
...subLocalStates
|
|
4679
4750
|
} : parserContext.localPredefinedStates
|
|
4680
4751
|
};
|
|
4681
|
-
for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
|
|
4752
|
+
for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules, pseudoElementRoot);
|
|
4682
4753
|
}
|
|
4683
4754
|
}
|
|
4684
|
-
function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules) {
|
|
4755
|
+
function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
|
|
4756
|
+
const target = {
|
|
4757
|
+
own: pseudoElementIndex(selectorSuffix) < selectorSuffix.length,
|
|
4758
|
+
root: pseudoElementRoot
|
|
4759
|
+
};
|
|
4685
4760
|
for (const { handler, styleMap, hasStateMap } of handlerQueue) {
|
|
4686
4761
|
const lookupStyles = handler.__lookupStyles;
|
|
4687
|
-
const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext), lookupStyles) : [{
|
|
4762
|
+
const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target), lookupStyles) : [{
|
|
4688
4763
|
condition: trueCondition(),
|
|
4689
4764
|
values: styleMap,
|
|
4690
4765
|
order: 0
|
|
4691
4766
|
}], selectorSuffix));
|
|
4692
4767
|
for (const rule of mergedRules) {
|
|
4693
|
-
const cssRules = materializeComputedRule(rule);
|
|
4768
|
+
const cssRules = materializeComputedRule(rule, pseudoElementRoot);
|
|
4694
4769
|
allRules.push(...cssRules);
|
|
4695
4770
|
}
|
|
4696
4771
|
}
|
|
4697
4772
|
}
|
|
4698
|
-
function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
|
|
4773
|
+
function buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target) {
|
|
4699
4774
|
const exclusiveByStyle = /* @__PURE__ */ new Map();
|
|
4700
4775
|
for (const styleName of lookupStyles) {
|
|
4701
4776
|
const value = styleMap[styleName];
|
|
4702
4777
|
if (value === void 0) continue;
|
|
4703
4778
|
if (isValueMapping(value)) {
|
|
4704
|
-
const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
|
|
4779
|
+
const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(target.own || target.root ? dropPseudoElementMismatches(styleName, value, parserContext, target) : value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
|
|
4705
4780
|
exclusiveByStyle.set(styleName, fullyExpanded);
|
|
4706
4781
|
} else exclusiveByStyle.set(styleName, [{
|
|
4707
4782
|
styleKey: styleName,
|
|
@@ -4714,6 +4789,18 @@ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
|
|
|
4714
4789
|
}
|
|
4715
4790
|
return exclusiveByStyle;
|
|
4716
4791
|
}
|
|
4792
|
+
function dropPseudoElementMismatches(styleName, valueMap, parserContext, target) {
|
|
4793
|
+
let kept;
|
|
4794
|
+
for (const stateKey of Object.keys(valueMap)) {
|
|
4795
|
+
if (stateKey === "" || stateKey === "_" || isMisusedFallbackKey(stateKey)) continue;
|
|
4796
|
+
const mismatch = pseudoElementMismatch(parseStateKey(stateKey, { context: parserContext }), target);
|
|
4797
|
+
if (!mismatch) continue;
|
|
4798
|
+
emitWarning("PSEUDO_ELEMENT_STATE_IGNORED", `State "${stateKey}" (in "${styleName}") applies to a pseudo-element, which has no ${mismatch}, so it can never match. The state has been ignored. To condition on the element the pseudo-element belongs to, write it in the selector before the pseudo-element.`);
|
|
4799
|
+
kept ??= { ...valueMap };
|
|
4800
|
+
delete kept[stateKey];
|
|
4801
|
+
}
|
|
4802
|
+
return kept ?? valueMap;
|
|
4803
|
+
}
|
|
4717
4804
|
function invokeHandler(handler, stateSnapshots, selectorSuffix) {
|
|
4718
4805
|
const computedRules = [];
|
|
4719
4806
|
for (const snapshot of stateSnapshots) {
|
|
@@ -5044,20 +5131,23 @@ function mergeByValue(rules) {
|
|
|
5044
5131
|
}
|
|
5045
5132
|
return merged;
|
|
5046
5133
|
}
|
|
5047
|
-
function buildSelectorFromVariant(variant, selectorSuffix) {
|
|
5048
|
-
let selector = "";
|
|
5134
|
+
function buildSelectorFromVariant(variant, selectorSuffix, pseudoElementRoot) {
|
|
5049
5135
|
let rootSegment = branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
|
|
5050
5136
|
for (const group of variant.selectorGroups) rootSegment += selectorGroupToCSS(group);
|
|
5051
|
-
|
|
5052
|
-
|
|
5137
|
+
const parents = variant.parentGroups.length > 0 ? parentGroupsToCSS(variant.parentGroups) : "";
|
|
5138
|
+
const pseudoElementAt = pseudoElementRoot ? parents.length : 0;
|
|
5139
|
+
let selector = pseudoElementRoot ? parents + wrapWhere(rootSegment) : wrapWhere(rootSegment) + parents;
|
|
5053
5140
|
selector += selectorSuffix;
|
|
5054
5141
|
const ownOptimized = optimizeGroups(variant.ownGroups);
|
|
5055
5142
|
let ownSegment = "";
|
|
5056
5143
|
for (const group of ownOptimized) ownSegment += selectorGroupToCSS(group);
|
|
5057
5144
|
selector += wrapWhere(ownSegment);
|
|
5058
|
-
return
|
|
5145
|
+
return {
|
|
5146
|
+
selector,
|
|
5147
|
+
pseudoElementAt
|
|
5148
|
+
};
|
|
5059
5149
|
}
|
|
5060
|
-
function materializeComputedRule(rule) {
|
|
5150
|
+
function materializeComputedRule(rule, pseudoElementRoot) {
|
|
5061
5151
|
const components = conditionToCSS(rule.condition);
|
|
5062
5152
|
if (components.isImpossible || components.variants.length === 0) return [];
|
|
5063
5153
|
const declarations = Object.entries(rule.declarations).map(([prop, value]) => Array.isArray(value) ? value.map((v) => `${prop}: ${v};`).join(" ") : `${prop}: ${value};`).join(" ");
|
|
@@ -5080,12 +5170,13 @@ function materializeComputedRule(rule) {
|
|
|
5080
5170
|
}
|
|
5081
5171
|
const rules = [];
|
|
5082
5172
|
for (const [, group] of byAtRules) {
|
|
5083
|
-
const
|
|
5173
|
+
const built = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix, pseudoElementRoot));
|
|
5084
5174
|
const cssRule = {
|
|
5085
|
-
selector:
|
|
5175
|
+
selector: built.length === 1 ? built[0].selector : built.map((b) => b.selector),
|
|
5086
5176
|
declarations,
|
|
5087
5177
|
order: rule.order
|
|
5088
5178
|
};
|
|
5179
|
+
if (pseudoElementRoot) cssRule.pseudoElementAt = built.map((b) => b.pseudoElementAt);
|
|
5089
5180
|
if (group.atRules.length > 0) cssRule.atRules = group.atRules;
|
|
5090
5181
|
if (group.rootPrefix) {
|
|
5091
5182
|
cssRule.rootPrefix = group.rootPrefix;
|
|
@@ -5113,23 +5204,33 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
|
|
|
5113
5204
|
if (pipelineCacheKey) rules = pipelineCache.get(pipelineCacheKey);
|
|
5114
5205
|
if (!rules && !styles) return directSelector ? [] : { rules: [] };
|
|
5115
5206
|
const cacheKey = pipelineCacheKey || stringifyStyles(styles);
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5207
|
+
const rulesFor = (pseudoElementRoot) => {
|
|
5208
|
+
const key = pseudoElementRoot ? `${cacheKey}\0::` : cacheKey;
|
|
5209
|
+
let cached = pipelineCache.get(key);
|
|
5210
|
+
if (!cached) {
|
|
5211
|
+
cached = runPipeline(styles, createStateParserContext(styles), pseudoElementRoot);
|
|
5212
|
+
pipelineCache.set(key, cached);
|
|
5213
|
+
}
|
|
5214
|
+
return cached;
|
|
5215
|
+
};
|
|
5121
5216
|
if (directSelector) {
|
|
5122
5217
|
const shouldDouble = options?.doubleSelector ?? false;
|
|
5123
5218
|
const items = splitSelectorsSafely(classNameOrSelector);
|
|
5124
|
-
const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) =>
|
|
5125
|
-
base
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5219
|
+
const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => {
|
|
5220
|
+
const at = pseudoElementIndex(base);
|
|
5221
|
+
return {
|
|
5222
|
+
head: base.slice(0, at),
|
|
5223
|
+
pseudoElement: base.slice(at),
|
|
5224
|
+
rootAt: rootStateIndex(base)
|
|
5225
|
+
};
|
|
5226
|
+
});
|
|
5227
|
+
const toResults = (groupRules, group) => groupRules.map((rule) => {
|
|
5129
5228
|
const result = {
|
|
5130
|
-
selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part) =>
|
|
5229
|
+
selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part, index) => group.map(({ head, pseudoElement, rootAt }) => {
|
|
5131
5230
|
const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
|
|
5132
|
-
|
|
5231
|
+
const base = joinsRoot ? `${head.slice(0, rootAt)}${wrapWhere(rule.rootState)}${head.slice(rootAt)}` : head;
|
|
5232
|
+
const at = rule.pseudoElementAt?.[index] ?? 0;
|
|
5233
|
+
let sel = pseudoElement ? `${base}${part.slice(0, at)}${pseudoElement}${part.slice(at)}` : `${base}${part}`;
|
|
5133
5234
|
if (shouldDouble && sel.startsWith(".")) {
|
|
5134
5235
|
const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
|
|
5135
5236
|
if (classMatch) sel = classMatch[0] + sel;
|
|
@@ -5142,8 +5243,12 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
|
|
|
5142
5243
|
if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
|
|
5143
5244
|
if (rule.startingStyle) result.startingStyle = true;
|
|
5144
5245
|
return result;
|
|
5145
|
-
})
|
|
5246
|
+
});
|
|
5247
|
+
const plain = bases.filter((base) => !base.pseudoElement);
|
|
5248
|
+
const pseudo = bases.filter((base) => base.pseudoElement);
|
|
5249
|
+
return mergeStyleResults([...plain.length > 0 ? toResults(rulesFor(false), plain) : [], ...pseudo.length > 0 ? toResults(rulesFor(true), pseudo) : []]);
|
|
5146
5250
|
}
|
|
5251
|
+
rules ??= rulesFor(false);
|
|
5147
5252
|
return { rules: rules.map((r) => ({
|
|
5148
5253
|
selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
|
|
5149
5254
|
declarations: r.declarations,
|
|
@@ -5463,4 +5568,4 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
|
|
|
5463
5568
|
//#endregion
|
|
5464
5569
|
export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
|
|
5465
5570
|
|
|
5466
|
-
//# sourceMappingURL=style-engine-
|
|
5571
|
+
//# sourceMappingURL=style-engine-of5Xbc27.js.map
|