@tenphi/tasty 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
- package/dist/async-storage-B7_o6FKt.js.map +1 -0
- package/dist/{ssr/collector.js → collector-DrgDE7QB.js} +5 -10
- package/dist/collector-DrgDE7QB.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-LuU1vZ68.d.ts} +3 -3
- package/dist/config-_aQ_PZ-P.js +10131 -0
- package/dist/config-_aQ_PZ-P.js.map +1 -0
- package/dist/config-vuCRkBWX.d.ts +884 -0
- package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
- package/dist/context-CkSg-kDT.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +6 -27
- package/dist/core-BqO8pplb.js +1592 -0
- package/dist/core-BqO8pplb.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-D--REwtp.js} +74 -11
- package/dist/css-writer-D--REwtp.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
- package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
- package/dist/format-rules-xwteB7a1.js +143 -0
- package/dist/format-rules-xwteB7a1.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-BvPT4ndL.js} +3 -3
- package/dist/hydrate-BvPT4ndL.js.map +1 -0
- package/dist/index-ZRxZWzlj.d.ts +1602 -0
- package/dist/{styles/types.d.ts → index-dUtwpOux.d.ts} +707 -5
- package/dist/index.d.ts +5 -51
- package/dist/index.js +732 -36
- package/dist/index.js.map +1 -0
- package/dist/keyframes-ClPFWy33.js +587 -0
- package/dist/keyframes-ClPFWy33.js.map +1 -0
- package/dist/{utils/merge-styles.js → merge-styles-BUQsEpbv.js} +3 -4
- package/dist/merge-styles-BUQsEpbv.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-CtDJMhpJ.d.ts} +3 -3
- package/dist/{utils/resolve-recipes.js → resolve-recipes-C0-AMzCz.js} +4 -6
- package/dist/resolve-recipes-C0-AMzCz.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/index.d.ts +44 -4
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +6 -6
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +10 -6
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +67 -3
- package/dist/zero/index.js +1 -2
- package/docs/injector.md +2 -2
- package/package.json +10 -9
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -389
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -749
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize-contradictions.js +0 -125
- package/dist/pipeline/materialize-contradictions.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1038
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -725
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -73
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
package/dist/ssr/hydrate.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/ssr/hydrate.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Client-side cache hydration for SSR/RSC.
|
|
4
|
-
*
|
|
5
|
-
* Pre-populates the client injector's rules map with class names
|
|
6
|
-
* rendered on the server. With hash-based naming, the client derives
|
|
7
|
-
* the same class name from the same cache key, so only the class name
|
|
8
|
-
* list needs to cross the wire — no cache keys or counters.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Pre-populate the client-side style registry from the server's class name list.
|
|
12
|
-
*
|
|
13
|
-
* Call this before ReactDOM.hydrateRoot() or ensure it runs before
|
|
14
|
-
* any tasty() component renders on the client.
|
|
15
|
-
*
|
|
16
|
-
* When called without arguments, reads the class list from `window.__TASTY__`
|
|
17
|
-
* (populated by inline scripts emitted during SSR/RSC streaming).
|
|
18
|
-
*/
|
|
19
|
-
declare function hydrateTastyClasses(classes?: string[]): void;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `hydrateTastyClasses()` instead. This alias exists
|
|
22
|
-
* for backwards compatibility and will be removed in a future major version.
|
|
23
|
-
*/
|
|
24
|
-
declare function hydrateTastyCache(state?: {
|
|
25
|
-
entries?: Record<string, string>;
|
|
26
|
-
}): void;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { hydrateTastyCache, hydrateTastyClasses };
|
|
29
|
-
//# sourceMappingURL=hydrate.d.ts.map
|
package/dist/ssr/hydrate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate.js","names":[],"sources":["../../src/ssr/hydrate.ts"],"sourcesContent":["/**\n * Client-side cache hydration for SSR/RSC.\n *\n * Pre-populates the client injector's rules map with class names\n * rendered on the server. With hash-based naming, the client derives\n * the same class name from the same cache key, so only the class name\n * list needs to cross the wire — no cache keys or counters.\n */\n\nimport { getGlobalInjector } from '../config';\nimport { HYDRATED_RULE_INDEX } from '../injector/types';\n\n/**\n * Pre-populate the client-side style registry from the server's class name list.\n *\n * Call this before ReactDOM.hydrateRoot() or ensure it runs before\n * any tasty() component renders on the client.\n *\n * When called without arguments, reads the class list from `window.__TASTY__`\n * (populated by inline scripts emitted during SSR/RSC streaming).\n */\nexport function hydrateTastyClasses(classes?: string[]): void {\n if (typeof document === 'undefined') return;\n\n if (!classes) {\n classes = typeof window !== 'undefined' ? window.__TASTY__ : undefined;\n }\n\n if (!classes?.length) return;\n\n const injector = getGlobalInjector();\n const registry = injector._sheetManager.getRegistry(document);\n\n for (const cls of classes) {\n if (!registry.rules.has(cls)) {\n registry.rules.set(cls, {\n className: cls,\n ruleIndex: HYDRATED_RULE_INDEX,\n sheetIndex: HYDRATED_RULE_INDEX,\n });\n registry.refCounts.set(cls, 0);\n }\n }\n}\n\n/**\n * @deprecated Use `hydrateTastyClasses()` instead. This alias exists\n * for backwards compatibility and will be removed in a future major version.\n */\nexport function hydrateTastyCache(state?: {\n entries?: Record<string, string>;\n}): void {\n if (state?.entries) {\n hydrateTastyClasses(Object.values(state.entries));\n } else {\n hydrateTastyClasses();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,SAA0B;AAC5D,KAAI,OAAO,aAAa,YAAa;AAErC,KAAI,CAAC,QACH,WAAU,OAAO,WAAW,cAAc,OAAO,YAAY,KAAA;AAG/D,KAAI,CAAC,SAAS,OAAQ;CAGtB,MAAM,WADW,mBAAmB,CACV,cAAc,YAAY,SAAS;AAE7D,MAAK,MAAM,OAAO,QAChB,KAAI,CAAC,SAAS,MAAM,IAAI,IAAI,EAAE;AAC5B,WAAS,MAAM,IAAI,KAAK;GACtB,WAAW;GACX,WAAA;GACA,YAAA;GACD,CAAC;AACF,WAAS,UAAU,IAAI,KAAK,EAAE;;;;;;;AASpC,SAAgB,kBAAkB,OAEzB;AACP,KAAI,OAAO,QACT,qBAAoB,OAAO,OAAO,MAAM,QAAQ,CAAC;KAEjD,sBAAqB"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/ssr/ssr-collector-ref.ts
|
|
2
|
-
const GETTER_KEY = "__tasty_ssr_collector_getter__";
|
|
3
|
-
let _getSSRCollector = null;
|
|
4
|
-
/**
|
|
5
|
-
* Register the collector getter in the current module graph only.
|
|
6
|
-
* Used by Next.js TastyRegistry.
|
|
7
|
-
*/
|
|
8
|
-
function registerSSRCollectorGetter(fn) {
|
|
9
|
-
_getSSRCollector = fn;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Register the collector getter on globalThis so it is visible across
|
|
13
|
-
* separate module graphs (e.g. Astro middleware ↔ page components).
|
|
14
|
-
*/
|
|
15
|
-
function registerSSRCollectorGetterGlobal(fn) {
|
|
16
|
-
globalThis[GETTER_KEY] = fn;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve the SSR collector: module-level first, globalThis fallback.
|
|
20
|
-
*/
|
|
21
|
-
function getRegisteredSSRCollector() {
|
|
22
|
-
if (_getSSRCollector) return _getSSRCollector();
|
|
23
|
-
const getter = globalThis[GETTER_KEY];
|
|
24
|
-
return getter ? getter() : null;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { getRegisteredSSRCollector, registerSSRCollectorGetter, registerSSRCollectorGetterGlobal };
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=ssr-collector-ref.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-collector-ref.js","names":[],"sources":["../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n | SSRCollectorGetter\n | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":";AAsBA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;;;;;AAMlD,SAAgB,2BAA2B,IAA8B;AACvE,oBAAmB;;;;;;AAOrB,SAAgB,iCAAiC,IAA8B;AAC5E,YAAuC,cAAc;;;;;AAMxD,SAAgB,4BAAyD;AACvE,KAAI,iBAAkB,QAAO,kBAAkB;CAC/C,MAAM,SAAU,WAAuC;AAGvD,QAAO,SAAS,QAAQ,GAAG"}
|
package/dist/states/index.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Styles } from "../styles/types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/states/index.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Parsed advanced state information
|
|
6
|
-
*/
|
|
7
|
-
interface ParsedAdvancedState {
|
|
8
|
-
type: 'media' | 'container' | 'root' | 'parent' | 'own' | 'starting' | 'predefined' | 'modifier';
|
|
9
|
-
condition: string;
|
|
10
|
-
containerName?: string;
|
|
11
|
-
raw: string;
|
|
12
|
-
mediaType?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Context for state parsing operations
|
|
16
|
-
*/
|
|
17
|
-
interface StateParserContext {
|
|
18
|
-
localPredefinedStates: Record<string, string>;
|
|
19
|
-
globalPredefinedStates: Record<string, string>;
|
|
20
|
-
isSubElement?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* At-rule context for CSS generation
|
|
24
|
-
*/
|
|
25
|
-
interface AtRuleContext {
|
|
26
|
-
media?: string[];
|
|
27
|
-
container?: {
|
|
28
|
-
name?: string;
|
|
29
|
-
condition: string;
|
|
30
|
-
}[];
|
|
31
|
-
startingStyle?: boolean;
|
|
32
|
-
rootStates?: string[];
|
|
33
|
-
negatedRootStates?: string[];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Configure global predefined states
|
|
37
|
-
*/
|
|
38
|
-
declare function setGlobalPredefinedStates(states: Record<string, string>): void;
|
|
39
|
-
/**
|
|
40
|
-
* Get global predefined states
|
|
41
|
-
*/
|
|
42
|
-
declare function getGlobalPredefinedStates(): Record<string, string>;
|
|
43
|
-
/**
|
|
44
|
-
* Create a state parser context from styles
|
|
45
|
-
*/
|
|
46
|
-
declare function createStateParserContext(styles?: Styles, isSubElement?: boolean): StateParserContext;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { AtRuleContext, ParsedAdvancedState, StateParserContext, createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates };
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/states/index.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { isDevEnv } from "../utils/is-dev-env.js";
|
|
2
|
-
import { hasStylesGenerated } from "../config.js";
|
|
3
|
-
//#region src/states/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* Advanced State Mapping - Predefined States Management
|
|
6
|
-
*
|
|
7
|
-
* This module handles global and local predefined states for the Tasty styling system.
|
|
8
|
-
* See ADVANCED_STATE_MAPPING.md for full specification.
|
|
9
|
-
*/
|
|
10
|
-
const BUILTIN_STATES = new Set([
|
|
11
|
-
"@starting",
|
|
12
|
-
"@keyframes",
|
|
13
|
-
"@properties",
|
|
14
|
-
"@fontFace",
|
|
15
|
-
"@counterStyle",
|
|
16
|
-
"@supports",
|
|
17
|
-
"@inherit"
|
|
18
|
-
]);
|
|
19
|
-
let globalPredefinedStates = {};
|
|
20
|
-
const emittedWarnings = /* @__PURE__ */ new Set();
|
|
21
|
-
const devMode = isDevEnv();
|
|
22
|
-
/**
|
|
23
|
-
* Emit a warning only once
|
|
24
|
-
*/
|
|
25
|
-
function warnOnce(key, message) {
|
|
26
|
-
if (devMode && !emittedWarnings.has(key)) {
|
|
27
|
-
emittedWarnings.add(key);
|
|
28
|
-
console.warn(message);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Configure global predefined states
|
|
33
|
-
*/
|
|
34
|
-
function setGlobalPredefinedStates(states) {
|
|
35
|
-
if (hasStylesGenerated()) {
|
|
36
|
-
const newStateNames = Object.keys(states).join(", ");
|
|
37
|
-
warnOnce(`dynamic-states:${newStateNames}`, `[Tasty] Cannot update predefined states after styles have been generated.\nThe new definition(s) for ${newStateNames} will be ignored.`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
for (const [name, value] of Object.entries(states)) {
|
|
41
|
-
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(name)) {
|
|
42
|
-
warnOnce(`invalid-state-name:${name}`, `[Tasty] Invalid predefined state name '${name}'. Must start with '@' followed by a letter.`);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (BUILTIN_STATES.has(name)) {
|
|
46
|
-
warnOnce(`reserved-state:${name}`, `[Tasty] Cannot define predefined state '${name}'. This name is reserved for built-in functionality.`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (name === "@media" || name === "@root" || name === "@parent" || name === "@own" || name.startsWith("@(")) {
|
|
50
|
-
warnOnce(`reserved-prefix:${name}`, `[Tasty] Cannot define predefined state '${name}'. This prefix is reserved for built-in functionality.`);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const crossRefs = extractPredefinedStateRefs(value);
|
|
54
|
-
if (crossRefs.length > 0) {
|
|
55
|
-
warnOnce(`cross-ref:${name}`, `[Tasty] Predefined state '${name}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (globalPredefinedStates[name] && globalPredefinedStates[name] !== value) warnOnce(`duplicate-state:${name}`, `[Tasty] Duplicate predefined state '${name}' in configure(). The last definition will be used.`);
|
|
59
|
-
globalPredefinedStates[name] = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get global predefined states
|
|
64
|
-
*/
|
|
65
|
-
function getGlobalPredefinedStates() {
|
|
66
|
-
return globalPredefinedStates;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Regex to match predefined state references in a string
|
|
70
|
-
* Matches @name that is NOT followed by ( or : and is a complete word
|
|
71
|
-
* Uses word boundary and negative lookahead
|
|
72
|
-
*/
|
|
73
|
-
const PREDEFINED_STATE_PATTERN = /@([A-Za-z][A-Za-z0-9-]*)(?![A-Za-z0-9-:(])/g;
|
|
74
|
-
/**
|
|
75
|
-
* Extract predefined state references from a string
|
|
76
|
-
*/
|
|
77
|
-
function extractPredefinedStateRefs(value) {
|
|
78
|
-
const matches = value.matchAll(PREDEFINED_STATE_PATTERN);
|
|
79
|
-
const refs = [];
|
|
80
|
-
for (const match of matches) {
|
|
81
|
-
const stateName = "@" + match[1];
|
|
82
|
-
if (!BUILTIN_STATES.has(stateName) && !refs.includes(stateName)) refs.push(stateName);
|
|
83
|
-
}
|
|
84
|
-
return refs;
|
|
85
|
-
}
|
|
86
|
-
const _localStatesCache = /* @__PURE__ */ new WeakMap();
|
|
87
|
-
/**
|
|
88
|
-
* Extract local predefined states from a styles object
|
|
89
|
-
* Local predefined states are top-level keys starting with @ that have string values
|
|
90
|
-
* and are valid predefined state names (not built-in like @media, @root, etc.)
|
|
91
|
-
*
|
|
92
|
-
* Results are cached by object identity via WeakMap since the same styles object
|
|
93
|
-
* is passed to this function multiple times per pipeline run (once per chunk
|
|
94
|
-
* in renderStylesForChunk and generateChunkCacheKey).
|
|
95
|
-
*/
|
|
96
|
-
function extractLocalPredefinedStates(styles) {
|
|
97
|
-
if (!styles || typeof styles !== "object") return {};
|
|
98
|
-
const cached = _localStatesCache.get(styles);
|
|
99
|
-
if (cached !== void 0) return cached;
|
|
100
|
-
const localStates = {};
|
|
101
|
-
for (const [key, value] of Object.entries(styles)) if (key.startsWith("@") && typeof value === "string") {
|
|
102
|
-
if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(key)) continue;
|
|
103
|
-
if (BUILTIN_STATES.has(key)) continue;
|
|
104
|
-
if (key === "@media" || key === "@root" || key === "@parent" || key === "@own" || key.startsWith("@(")) continue;
|
|
105
|
-
const crossRefs = extractPredefinedStateRefs(value);
|
|
106
|
-
if (crossRefs.length > 0) {
|
|
107
|
-
warnOnce(`local-cross-ref:${key}`, `[Tasty] Predefined state '${key}' references another predefined state '${crossRefs[0]}'.\nPredefined states cannot reference each other. Use the full definition instead.`);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
localStates[key] = value;
|
|
111
|
-
}
|
|
112
|
-
_localStatesCache.set(styles, localStates);
|
|
113
|
-
return localStates;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Create a state parser context from styles
|
|
117
|
-
*/
|
|
118
|
-
function createStateParserContext(styles, isSubElement) {
|
|
119
|
-
return {
|
|
120
|
-
localPredefinedStates: styles ? extractLocalPredefinedStates(styles) : {},
|
|
121
|
-
globalPredefinedStates: getGlobalPredefinedStates(),
|
|
122
|
-
isSubElement
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Resolve a predefined state reference to its value
|
|
127
|
-
* Returns the resolved value or null if not found
|
|
128
|
-
*/
|
|
129
|
-
function resolvePredefinedState(stateKey, ctx) {
|
|
130
|
-
if (ctx.localPredefinedStates[stateKey]) return ctx.localPredefinedStates[stateKey];
|
|
131
|
-
if (ctx.globalPredefinedStates[stateKey]) return ctx.globalPredefinedStates[stateKey];
|
|
132
|
-
warnOnce(`undefined-state:${stateKey}`, `[Tasty] Undefined predefined state '${stateKey}'.\nDefine it in configure({ states: { '${stateKey}': '...' } }) or in the component's styles.`);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Expand dimension shorthands in a condition string
|
|
137
|
-
* w -> width, h -> height, is -> inline-size, bs -> block-size
|
|
138
|
-
*/
|
|
139
|
-
function expandDimensionShorthands(condition) {
|
|
140
|
-
let result = condition;
|
|
141
|
-
result = result.replace(/\bw\b/g, "width");
|
|
142
|
-
result = result.replace(/\bh\b/g, "height");
|
|
143
|
-
result = result.replace(/\bis\b/g, "inline-size");
|
|
144
|
-
result = result.replace(/\bbs\b/g, "block-size");
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Convert tasty units in a string (e.g., 40x -> calc(var(--gap) * 40))
|
|
149
|
-
*/
|
|
150
|
-
function expandTastyUnits(value) {
|
|
151
|
-
return value.replace(/(\d+(?:\.\d+)?)\s*x\b/g, (_, num) => {
|
|
152
|
-
return `calc(var(--gap) * ${num})`;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Find the index of the first comma at parentheses depth 0.
|
|
157
|
-
* Returns -1 if no top-level comma is found.
|
|
158
|
-
* This prevents splitting on commas inside function calls like scroll-state(a, b).
|
|
159
|
-
*/
|
|
160
|
-
function findTopLevelComma(s) {
|
|
161
|
-
let depth = 0;
|
|
162
|
-
for (let i = 0; i < s.length; i++) if (s[i] === "(") depth++;
|
|
163
|
-
else if (s[i] === ")") depth--;
|
|
164
|
-
else if (s[i] === "," && depth === 0) return i;
|
|
165
|
-
return -1;
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
export { createStateParserContext, expandDimensionShorthands, expandTastyUnits, extractLocalPredefinedStates, extractPredefinedStateRefs, findTopLevelComma, getGlobalPredefinedStates, resolvePredefinedState, setGlobalPredefinedStates };
|
|
169
|
-
|
|
170
|
-
//# sourceMappingURL=index.js.map
|
package/dist/states/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/states/index.ts"],"sourcesContent":["/**\n * Advanced State Mapping - Predefined States Management\n *\n * This module handles global and local predefined states for the Tasty styling system.\n * See ADVANCED_STATE_MAPPING.md for full specification.\n */\n\nimport { hasStylesGenerated } from '../config';\nimport type { Styles } from '../styles/types';\nimport { isDevEnv } from '../utils/is-dev-env';\n\n/**\n * Parsed advanced state information\n */\nexport interface ParsedAdvancedState {\n type:\n | 'media'\n | 'container'\n | 'root'\n | 'parent'\n | 'own'\n | 'starting'\n | 'predefined'\n | 'modifier';\n condition: string; // e.g., 'width <= 920px' or 'hovered'\n containerName?: string; // for container queries\n raw: string; // original state key\n mediaType?: string; // for @media:screen, @media:print, etc.\n}\n\n/**\n * Context for state parsing operations\n */\nexport interface StateParserContext {\n localPredefinedStates: Record<string, string>;\n globalPredefinedStates: Record<string, string>;\n isSubElement?: boolean; // true when processing sub-element styles (for @own() validation)\n}\n\n/**\n * At-rule context for CSS generation\n */\nexport interface AtRuleContext {\n media?: string[]; // @media conditions to wrap rule in (merged with 'and')\n container?: { name?: string; condition: string }[]; // @container conditions (nested)\n startingStyle?: boolean;\n rootStates?: string[]; // :root state selectors (e.g., '[data-theme=\"dark\"]')\n negatedRootStates?: string[]; // Negated :root state selectors for non-overlapping rules (e.g., ':not([data-theme=\"dark\"])')\n}\n\n// Built-in state names that cannot be overridden\nconst BUILTIN_STATES = new Set([\n '@starting',\n '@keyframes',\n '@properties',\n '@fontFace',\n '@counterStyle',\n '@supports',\n // @inherit is a value (not a key), but reserved here to prevent\n // users from accidentally defining a state named '@inherit'.\n '@inherit',\n]);\n\n// Reserved prefixes that are built-in\nconst RESERVED_PREFIXES = [\n '@media',\n '@root',\n '@parent',\n '@own',\n '@(',\n '@starting',\n '@keyframes',\n '@properties',\n '@supports',\n '@inherit',\n];\n\n// Global predefined states storage\nlet globalPredefinedStates: Record<string, string> = {};\n\n// Warnings tracking to avoid duplicates\nconst emittedWarnings = new Set<string>();\n\nconst devMode = isDevEnv();\n\n/**\n * Emit a warning only once\n */\nfunction warnOnce(key: string, message: string): void {\n if (devMode && !emittedWarnings.has(key)) {\n emittedWarnings.add(key);\n console.warn(message);\n }\n}\n\n/**\n * Configure global predefined states\n */\nexport function setGlobalPredefinedStates(\n states: Record<string, string>,\n): void {\n if (hasStylesGenerated()) {\n const newStateNames = Object.keys(states).join(', ');\n warnOnce(\n `dynamic-states:${newStateNames}`,\n `[Tasty] Cannot update predefined states after styles have been generated.\\n` +\n `The new definition(s) for ${newStateNames} will be ignored.`,\n );\n return;\n }\n\n // Validate state names\n for (const [name, value] of Object.entries(states)) {\n // Check for valid name format\n if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(name)) {\n warnOnce(\n `invalid-state-name:${name}`,\n `[Tasty] Invalid predefined state name '${name}'. Must start with '@' followed by a letter.`,\n );\n continue;\n }\n\n // Check for reserved names\n if (BUILTIN_STATES.has(name)) {\n warnOnce(\n `reserved-state:${name}`,\n `[Tasty] Cannot define predefined state '${name}'. This name is reserved for built-in functionality.`,\n );\n continue;\n }\n\n // Check for reserved prefixes (but only exact matches, not user-defined states like @mobile)\n // Reserved prefixes are: @media, @root, @parent, @own, @(\n // A user state like @mobile should NOT be blocked\n const isReservedPrefix =\n name === '@media' ||\n name === '@root' ||\n name === '@parent' ||\n name === '@own' ||\n name.startsWith('@(');\n\n if (isReservedPrefix) {\n warnOnce(\n `reserved-prefix:${name}`,\n `[Tasty] Cannot define predefined state '${name}'. This prefix is reserved for built-in functionality.`,\n );\n continue;\n }\n\n // Check for cross-references\n const crossRefs = extractPredefinedStateRefs(value);\n if (crossRefs.length > 0) {\n warnOnce(\n `cross-ref:${name}`,\n `[Tasty] Predefined state '${name}' references another predefined state '${crossRefs[0]}'.\\n` +\n `Predefined states cannot reference each other. Use the full definition instead.`,\n );\n continue;\n }\n\n // Check for duplicates\n if (\n globalPredefinedStates[name] &&\n globalPredefinedStates[name] !== value\n ) {\n warnOnce(\n `duplicate-state:${name}`,\n `[Tasty] Duplicate predefined state '${name}' in configure(). The last definition will be used.`,\n );\n }\n\n globalPredefinedStates[name] = value;\n }\n}\n\n/**\n * Get global predefined states\n */\nexport function getGlobalPredefinedStates(): Record<string, string> {\n return globalPredefinedStates;\n}\n\n/**\n * Clear global predefined states (for testing only)\n */\nexport function clearGlobalPredefinedStates(): void {\n globalPredefinedStates = {};\n emittedWarnings.clear();\n}\n\n/**\n * Regex to match predefined state references in a string\n * Matches @name that is NOT followed by ( or : and is a complete word\n * Uses word boundary and negative lookahead\n */\nconst PREDEFINED_STATE_PATTERN = /@([A-Za-z][A-Za-z0-9-]*)(?![A-Za-z0-9-:(])/g;\n\n/**\n * Extract predefined state references from a string\n */\nexport function extractPredefinedStateRefs(value: string): string[] {\n const matches = value.matchAll(PREDEFINED_STATE_PATTERN);\n const refs: string[] = [];\n\n for (const match of matches) {\n const stateName = '@' + match[1];\n // Skip built-in states (@starting) and duplicates\n // Note: @media, @root, @own are always followed by '(' so the regex\n // negative lookahead (?![A-Za-z0-9-:(]) already excludes them\n if (!BUILTIN_STATES.has(stateName) && !refs.includes(stateName)) {\n refs.push(stateName);\n }\n }\n\n return refs;\n}\n\n/**\n * Check if a state key is a predefined state reference\n */\nexport function isPredefinedStateRef(stateKey: string): boolean {\n if (!stateKey.startsWith('@')) return false;\n if (BUILTIN_STATES.has(stateKey)) return false;\n\n // Check if it's NOT a built-in prefix\n for (const prefix of RESERVED_PREFIXES) {\n if (stateKey === prefix || stateKey.startsWith(prefix)) {\n // Check if it's exactly @media, @root, @parent, @own, or starts with @( or @media(\n if (\n stateKey === '@media' ||\n stateKey.startsWith('@media(') ||\n stateKey.startsWith('@media:')\n ) {\n return false;\n }\n if (stateKey === '@root' || stateKey.startsWith('@root(')) return false;\n if (stateKey === '@parent' || stateKey.startsWith('@parent('))\n return false;\n if (stateKey === '@own' || stateKey.startsWith('@own(')) return false;\n if (stateKey.startsWith('@(')) return false;\n }\n }\n\n // Must match the predefined state pattern\n return /^@[A-Za-z][A-Za-z0-9-]*$/.test(stateKey);\n}\n\nconst _localStatesCache = new WeakMap<object, Record<string, string>>();\n\n/**\n * Extract local predefined states from a styles object\n * Local predefined states are top-level keys starting with @ that have string values\n * and are valid predefined state names (not built-in like @media, @root, etc.)\n *\n * Results are cached by object identity via WeakMap since the same styles object\n * is passed to this function multiple times per pipeline run (once per chunk\n * in renderStylesForChunk and generateChunkCacheKey).\n */\nexport function extractLocalPredefinedStates(\n styles: Styles,\n): Record<string, string> {\n if (!styles || typeof styles !== 'object') {\n return {};\n }\n\n const cached = _localStatesCache.get(styles as object);\n if (cached !== undefined) return cached;\n\n const localStates: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(styles)) {\n // Check if it's a predefined state definition (starts with @, has string value)\n if (key.startsWith('@') && typeof value === 'string') {\n // Validate name format - must be @[letter][letters/numbers/dashes]*\n if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(key)) {\n continue; // Skip invalid names silently (might be something else)\n }\n\n // Skip built-in states\n if (BUILTIN_STATES.has(key)) {\n continue;\n }\n\n // Skip reserved prefixes\n if (\n key === '@media' ||\n key === '@root' ||\n key === '@parent' ||\n key === '@own' ||\n key.startsWith('@(')\n ) {\n continue;\n }\n\n // Check for cross-references (predefined states cannot reference each other)\n const crossRefs = extractPredefinedStateRefs(value);\n if (crossRefs.length > 0) {\n warnOnce(\n `local-cross-ref:${key}`,\n `[Tasty] Predefined state '${key}' references another predefined state '${crossRefs[0]}'.\\n` +\n `Predefined states cannot reference each other. Use the full definition instead.`,\n );\n continue;\n }\n\n localStates[key] = value;\n }\n }\n\n _localStatesCache.set(styles as object, localStates);\n\n return localStates;\n}\n\n/**\n * Create a state parser context from styles\n */\nexport function createStateParserContext(\n styles?: Styles,\n isSubElement?: boolean,\n): StateParserContext {\n const localStates = styles ? extractLocalPredefinedStates(styles) : {};\n\n return {\n localPredefinedStates: localStates,\n globalPredefinedStates: getGlobalPredefinedStates(),\n isSubElement,\n };\n}\n\n/**\n * Resolve a predefined state reference to its value\n * Returns the resolved value or null if not found\n */\nexport function resolvePredefinedState(\n stateKey: string,\n ctx: StateParserContext,\n): string | null {\n // Check local first (higher priority)\n if (ctx.localPredefinedStates[stateKey]) {\n return ctx.localPredefinedStates[stateKey];\n }\n\n // Then check global\n if (ctx.globalPredefinedStates[stateKey]) {\n return ctx.globalPredefinedStates[stateKey];\n }\n\n // Not found - emit warning\n warnOnce(\n `undefined-state:${stateKey}`,\n `[Tasty] Undefined predefined state '${stateKey}'.\\n` +\n `Define it in configure({ states: { '${stateKey}': '...' } }) or in the component's styles.`,\n );\n\n return null;\n}\n\n/**\n * Normalize state key by trimming whitespace and removing trailing/leading operators\n */\nexport function normalizeStateKey(stateKey: string): {\n key: string;\n warnings: string[];\n} {\n const warnings: string[] = [];\n let key = stateKey;\n\n // Check for whitespace-only\n if (key.trim() === '') {\n if (key !== '') {\n warnings.push(\n `[Tasty] Whitespace-only state key normalized to default state ''.`,\n );\n }\n return { key: '', warnings };\n }\n\n // Trim whitespace\n key = key.trim();\n\n // Remove trailing operators\n const trailingOpMatch = key.match(/\\s*[&|^]\\s*$/);\n if (trailingOpMatch) {\n const originalKey = key;\n key = key.slice(0, -trailingOpMatch[0].length).trim();\n warnings.push(\n `[Tasty] State key '${originalKey}' has trailing operator. Normalized to '${key}'.`,\n );\n }\n\n // Remove leading operators (except !)\n const leadingOpMatch = key.match(/^\\s*[&|^]\\s*/);\n if (leadingOpMatch) {\n const originalKey = key;\n key = key.slice(leadingOpMatch[0].length).trim();\n warnings.push(\n `[Tasty] State key '${originalKey}' has leading operator. Normalized to '${key}'.`,\n );\n }\n\n return { key, warnings };\n}\n\n/**\n * Expand dimension shorthands in a condition string\n * w -> width, h -> height, is -> inline-size, bs -> block-size\n */\nexport function expandDimensionShorthands(condition: string): string {\n // Replace dimension shorthands (only when they appear as standalone words)\n let result = condition;\n\n // w -> width (but not part of other words)\n result = result.replace(/\\bw\\b/g, 'width');\n\n // h -> height\n result = result.replace(/\\bh\\b/g, 'height');\n\n // is -> inline-size\n result = result.replace(/\\bis\\b/g, 'inline-size');\n\n // bs -> block-size\n result = result.replace(/\\bbs\\b/g, 'block-size');\n\n return result;\n}\n\n/**\n * Convert tasty units in a string (e.g., 40x -> calc(var(--gap) * 40))\n */\nexport function expandTastyUnits(value: string): string {\n // Match number followed by 'x' unit (tasty gap unit)\n return value.replace(/(\\d+(?:\\.\\d+)?)\\s*x\\b/g, (_, num) => {\n return `calc(var(--gap) * ${num})`;\n });\n}\n\n/**\n * Parse an advanced state key and return its type and components\n */\nexport function parseAdvancedState(\n stateKey: string,\n ctx: StateParserContext,\n): ParsedAdvancedState {\n const raw = stateKey;\n\n // Check for @starting (exact match)\n if (stateKey === '@starting') {\n return {\n type: 'starting',\n condition: '',\n raw,\n };\n }\n\n // Check for @media:type (e.g., @media:print)\n if (stateKey.startsWith('@media:')) {\n const mediaType = stateKey.slice(7); // Remove '@media:'\n if (!['all', 'screen', 'print', 'speech'].includes(mediaType)) {\n warnOnce(\n `unknown-media-type:${mediaType}`,\n `[Tasty] Unknown media type '${mediaType}'. Valid types: all, screen, print, speech.`,\n );\n }\n return {\n type: 'media',\n condition: '',\n mediaType,\n raw,\n };\n }\n\n // Check for @media(...) - media query with condition\n if (stateKey.startsWith('@media(')) {\n const endParen = findMatchingParen(stateKey, 6);\n if (endParen === -1) {\n warnOnce(\n `unclosed-media:${stateKey}`,\n `[Tasty] Unclosed media query '${stateKey}'. Missing closing parenthesis.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n let condition = stateKey.slice(7, endParen);\n\n // Check for empty condition\n if (!condition.trim()) {\n warnOnce(\n `empty-media:${stateKey}`,\n `[Tasty] Empty media query condition '${stateKey}'.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n // Expand shorthands and units\n condition = expandDimensionShorthands(condition);\n condition = expandTastyUnits(condition);\n\n return {\n type: 'media',\n condition,\n raw,\n };\n }\n\n // Check for @root(...) - root state\n if (stateKey.startsWith('@root(')) {\n const endParen = findMatchingParen(stateKey, 5);\n if (endParen === -1) {\n warnOnce(\n `unclosed-root:${stateKey}`,\n `[Tasty] Unclosed root state '${stateKey}'. Missing closing parenthesis.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n const condition = stateKey.slice(6, endParen);\n\n if (!condition.trim()) {\n warnOnce(\n `empty-root:${stateKey}`,\n `[Tasty] Empty root state condition '${stateKey}'.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n return {\n type: 'root',\n condition,\n raw,\n };\n }\n\n // Check for @parent(...) - parent element state\n if (stateKey.startsWith('@parent(')) {\n const endParen = findMatchingParen(stateKey, 7);\n if (endParen === -1) {\n warnOnce(\n `unclosed-parent:${stateKey}`,\n `[Tasty] Unclosed parent state '${stateKey}'. Missing closing parenthesis.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n const condition = stateKey.slice(8, endParen);\n\n if (!condition.trim()) {\n warnOnce(\n `empty-parent:${stateKey}`,\n `[Tasty] Empty parent state condition '${stateKey}'.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n return {\n type: 'parent',\n condition,\n raw,\n };\n }\n\n // Check for @own(...) - sub-element own state\n if (stateKey.startsWith('@own(')) {\n const endParen = findMatchingParen(stateKey, 4);\n if (endParen === -1) {\n warnOnce(\n `unclosed-own:${stateKey}`,\n `[Tasty] Unclosed own state '${stateKey}'. Missing closing parenthesis.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n const condition = stateKey.slice(5, endParen);\n\n if (!condition.trim()) {\n warnOnce(\n `empty-own:${stateKey}`,\n `[Tasty] Empty own state condition '${stateKey}'.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n // Check if used outside sub-element context\n if (!ctx.isSubElement) {\n warnOnce(\n `own-outside-subelement:${stateKey}`,\n `[Tasty] @own(${condition}) used outside sub-element context.\\n` +\n `@own() is equivalent to '${condition}' at the root level. ` +\n `Did you mean to use it inside a sub-element?`,\n );\n // Treat as regular modifier\n return {\n type: 'modifier',\n condition,\n raw,\n };\n }\n\n return {\n type: 'own',\n condition,\n raw,\n };\n }\n\n // Check for @(...) - container query (unnamed or named)\n if (stateKey.startsWith('@(')) {\n const endParen = findMatchingParen(stateKey, 1);\n if (endParen === -1) {\n warnOnce(\n `unclosed-container:${stateKey}`,\n `[Tasty] Unclosed container query '${stateKey}'. Missing closing parenthesis.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n const content = stateKey.slice(2, endParen);\n\n if (!content.trim()) {\n warnOnce(\n `empty-container:${stateKey}`,\n `[Tasty] Empty container query '${stateKey}'.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n\n // Check if named container (first token is name, followed by comma)\n // Use parentheses-aware comma search so inner commas (e.g., scroll-state(a, b)) are skipped\n const commaIndex = findTopLevelComma(content);\n let containerName: string | undefined;\n let condition: string;\n\n if (commaIndex !== -1) {\n // Named container: @(layout, w < 600px)\n containerName = content.slice(0, commaIndex).trim();\n condition = content.slice(commaIndex + 1).trim();\n } else {\n // Unnamed container: @(w < 600px)\n condition = content.trim();\n }\n\n // Check for style query shorthand (starts with $)\n if (condition.startsWith('$')) {\n // Style query: @(layout, $compact) or @(layout, $variant=compact)\n const styleCondition = parseStyleQuery(condition);\n if (!styleCondition) {\n warnOnce(\n `invalid-style-query:${stateKey}`,\n `[Tasty] Invalid style query '${condition}' in container query.`,\n );\n return { type: 'modifier', condition: stateKey, raw };\n }\n condition = styleCondition;\n } else if (/^[a-zA-Z][\\w-]*\\s*\\(/.test(condition)) {\n // Function-like syntax: scroll-state(...), style(...), etc.\n // Pass through verbatim — no dimension expansion needed\n } else {\n // Dimension query - expand shorthands and units\n condition = expandDimensionShorthands(condition);\n condition = expandTastyUnits(condition);\n }\n\n return {\n type: 'container',\n condition,\n containerName,\n raw,\n };\n }\n\n // Check for predefined state reference\n if (isPredefinedStateRef(stateKey)) {\n const resolved = resolvePredefinedState(stateKey, ctx);\n if (resolved) {\n // Recursively parse the resolved value to extract the actual state type\n // (e.g., @mobile -> @media(w < 768px) should become a media state)\n const parsedResolved = parseAdvancedState(resolved, ctx);\n return {\n ...parsedResolved,\n raw, // Keep original raw for traceability\n };\n }\n // If not resolved, treat as modifier (will likely produce invalid CSS)\n return {\n type: 'modifier',\n condition: stateKey,\n raw,\n };\n }\n\n // Regular modifier (boolean mod, pseudo-class, class, attribute)\n return {\n type: 'modifier',\n condition: stateKey,\n raw,\n };\n}\n\n/**\n * Parse a style query condition (e.g., $compact, $variant=compact, $variant=\"very compact\")\n */\nfunction parseStyleQuery(condition: string): string | null {\n // Remove $ prefix\n const query = condition.slice(1);\n\n // Check for comparison operators (not supported)\n if (/[<>]/.test(query)) {\n warnOnce(\n `style-query-comparison:${condition}`,\n `[Tasty] Style queries only support equality. '${condition}' is invalid. Use '${condition.split(/[<>]/)[0]}=...' instead.`,\n );\n return null;\n }\n\n // Check for equality\n const eqIndex = query.indexOf('=');\n if (eqIndex === -1) {\n // Just existence check: style(--compact)\n return `style(--${query})`;\n }\n\n const propName = query.slice(0, eqIndex).trim();\n let value = query.slice(eqIndex + 1).trim();\n\n // Handle quoted values\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n // Keep quotes for CSS\n } else {\n // Add quotes if needed\n value = `\"${value}\"`;\n }\n\n // Expand tasty units in value\n value = expandTastyUnits(value);\n\n return `style(--${propName}: ${value})`;\n}\n\n/**\n * Find the index of the first comma at parentheses depth 0.\n * Returns -1 if no top-level comma is found.\n * This prevents splitting on commas inside function calls like scroll-state(a, b).\n */\nexport function findTopLevelComma(s: string): number {\n let depth = 0;\n\n for (let i = 0; i < s.length; i++) {\n if (s[i] === '(') depth++;\n else if (s[i] === ')') depth--;\n else if (s[i] === ',' && depth === 0) return i;\n }\n\n return -1;\n}\n\nfunction findMatchingParen(str: string, startIndex: number): number {\n let depth = 1;\n let i = startIndex + 1;\n\n while (i < str.length && depth > 0) {\n if (str[i] === '(') depth++;\n else if (str[i] === ')') depth--;\n i++;\n }\n\n return depth === 0 ? i - 1 : -1;\n}\n\n/**\n * Check if a state key is an advanced state (starts with @)\n */\nexport function isAdvancedState(stateKey: string): boolean {\n return stateKey.startsWith('@') || stateKey.startsWith('!@');\n}\n\n/**\n * Detect the type of advanced state from a raw state key\n */\nexport function detectAdvancedStateType(\n stateKey: string,\n): ParsedAdvancedState['type'] {\n // Handle negation prefix\n const key = stateKey.startsWith('!') ? stateKey.slice(1) : stateKey;\n\n if (key === '@starting') return 'starting';\n if (key.startsWith('@media')) return 'media';\n if (key.startsWith('@root(')) return 'root';\n if (key.startsWith('@parent(')) return 'parent';\n if (key.startsWith('@own(')) return 'own';\n if (key.startsWith('@(')) return 'container';\n if (isPredefinedStateRef(key)) return 'predefined';\n return 'modifier';\n}\n"],"mappings":";;;;;;;;;AAmDA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CAGA;CACD,CAAC;AAiBF,IAAI,yBAAiD,EAAE;AAGvD,MAAM,kCAAkB,IAAI,KAAa;AAEzC,MAAM,UAAU,UAAU;;;;AAK1B,SAAS,SAAS,KAAa,SAAuB;AACpD,KAAI,WAAW,CAAC,gBAAgB,IAAI,IAAI,EAAE;AACxC,kBAAgB,IAAI,IAAI;AACxB,UAAQ,KAAK,QAAQ;;;;;;AAOzB,SAAgB,0BACd,QACM;AACN,KAAI,oBAAoB,EAAE;EACxB,MAAM,gBAAgB,OAAO,KAAK,OAAO,CAAC,KAAK,KAAK;AACpD,WACE,kBAAkB,iBAClB,wGAC+B,cAAc,mBAC9C;AACD;;AAIF,MAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,EAAE;AAElD,MAAI,CAAC,2BAA2B,KAAK,KAAK,EAAE;AAC1C,YACE,sBAAsB,QACtB,0CAA0C,KAAK,8CAChD;AACD;;AAIF,MAAI,eAAe,IAAI,KAAK,EAAE;AAC5B,YACE,kBAAkB,QAClB,2CAA2C,KAAK,sDACjD;AACD;;AAaF,MANE,SAAS,YACT,SAAS,WACT,SAAS,aACT,SAAS,UACT,KAAK,WAAW,KAAK,EAED;AACpB,YACE,mBAAmB,QACnB,2CAA2C,KAAK,wDACjD;AACD;;EAIF,MAAM,YAAY,2BAA2B,MAAM;AACnD,MAAI,UAAU,SAAS,GAAG;AACxB,YACE,aAAa,QACb,6BAA6B,KAAK,yCAAyC,UAAU,GAAG,qFAEzF;AACD;;AAIF,MACE,uBAAuB,SACvB,uBAAuB,UAAU,MAEjC,UACE,mBAAmB,QACnB,uCAAuC,KAAK,qDAC7C;AAGH,yBAAuB,QAAQ;;;;;;AAOnC,SAAgB,4BAAoD;AAClE,QAAO;;;;;;;AAgBT,MAAM,2BAA2B;;;;AAKjC,SAAgB,2BAA2B,OAAyB;CAClE,MAAM,UAAU,MAAM,SAAS,yBAAyB;CACxD,MAAM,OAAiB,EAAE;AAEzB,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,YAAY,MAAM,MAAM;AAI9B,MAAI,CAAC,eAAe,IAAI,UAAU,IAAI,CAAC,KAAK,SAAS,UAAU,CAC7D,MAAK,KAAK,UAAU;;AAIxB,QAAO;;AAiCT,MAAM,oCAAoB,IAAI,SAAyC;;;;;;;;;;AAWvE,SAAgB,6BACd,QACwB;AACxB,KAAI,CAAC,UAAU,OAAO,WAAW,SAC/B,QAAO,EAAE;CAGX,MAAM,SAAS,kBAAkB,IAAI,OAAiB;AACtD,KAAI,WAAW,KAAA,EAAW,QAAO;CAEjC,MAAM,cAAsC,EAAE;AAE9C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAE/C,KAAI,IAAI,WAAW,IAAI,IAAI,OAAO,UAAU,UAAU;AAEpD,MAAI,CAAC,2BAA2B,KAAK,IAAI,CACvC;AAIF,MAAI,eAAe,IAAI,IAAI,CACzB;AAIF,MACE,QAAQ,YACR,QAAQ,WACR,QAAQ,aACR,QAAQ,UACR,IAAI,WAAW,KAAK,CAEpB;EAIF,MAAM,YAAY,2BAA2B,MAAM;AACnD,MAAI,UAAU,SAAS,GAAG;AACxB,YACE,mBAAmB,OACnB,6BAA6B,IAAI,yCAAyC,UAAU,GAAG,qFAExF;AACD;;AAGF,cAAY,OAAO;;AAIvB,mBAAkB,IAAI,QAAkB,YAAY;AAEpD,QAAO;;;;;AAMT,SAAgB,yBACd,QACA,cACoB;AAGpB,QAAO;EACL,uBAHkB,SAAS,6BAA6B,OAAO,GAAG,EAAE;EAIpE,wBAAwB,2BAA2B;EACnD;EACD;;;;;;AAOH,SAAgB,uBACd,UACA,KACe;AAEf,KAAI,IAAI,sBAAsB,UAC5B,QAAO,IAAI,sBAAsB;AAInC,KAAI,IAAI,uBAAuB,UAC7B,QAAO,IAAI,uBAAuB;AAIpC,UACE,mBAAmB,YACnB,uCAAuC,SAAS,0CACP,SAAS,6CACnD;AAED,QAAO;;;;;;AAqDT,SAAgB,0BAA0B,WAA2B;CAEnE,IAAI,SAAS;AAGb,UAAS,OAAO,QAAQ,UAAU,QAAQ;AAG1C,UAAS,OAAO,QAAQ,UAAU,SAAS;AAG3C,UAAS,OAAO,QAAQ,WAAW,cAAc;AAGjD,UAAS,OAAO,QAAQ,WAAW,aAAa;AAEhD,QAAO;;;;;AAMT,SAAgB,iBAAiB,OAAuB;AAEtD,QAAO,MAAM,QAAQ,2BAA2B,GAAG,QAAQ;AACzD,SAAO,qBAAqB,IAAI;GAChC;;;;;;;AAwTJ,SAAgB,kBAAkB,GAAmB;CACnD,IAAI,QAAQ;AAEZ,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,IAAK;UACT,EAAE,OAAO,IAAK;UACd,EAAE,OAAO,OAAO,UAAU,EAAG,QAAO;AAG/C,QAAO"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Styles } from "../styles/types.js";
|
|
2
|
-
import { StaticStyle } from "./types.js";
|
|
3
|
-
|
|
4
|
-
//#region src/static/tastyStatic.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Generate styles and return a StaticStyle object.
|
|
7
|
-
* The object has `className`, `styles`, and `toString()`.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const button = tastyStatic({
|
|
12
|
-
* fill: '#blue',
|
|
13
|
-
* padding: '2x',
|
|
14
|
-
* });
|
|
15
|
-
* // After build: { className: 'ts3f2a1b', styles: {...}, toString() }
|
|
16
|
-
*
|
|
17
|
-
* <div className={button} /> // Works via toString()
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function tastyStatic(styles: Styles): StaticStyle;
|
|
21
|
-
/**
|
|
22
|
-
* Extend an existing StaticStyle with additional styles.
|
|
23
|
-
* Uses mergeStyles() internally for proper nested selector handling.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const button = tastyStatic({ fill: '#blue' });
|
|
28
|
-
* const primary = tastyStatic(button, { fill: '#purple' });
|
|
29
|
-
* // After build: { className: 'ts8c4d2e', styles: {...merged...}, toString() }
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
declare function tastyStatic(base: StaticStyle, styles: Styles): StaticStyle;
|
|
33
|
-
/**
|
|
34
|
-
* Generate styles for a specific CSS selector.
|
|
35
|
-
* The call is completely removed after build transformation.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* tastyStatic('.heading', { preset: 'h1', color: '#primary' });
|
|
40
|
-
* // After build: (removed)
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
declare function tastyStatic(selector: string, styles: Styles): void;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { tastyStatic };
|
|
46
|
-
//# sourceMappingURL=tastyStatic.d.ts.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { mergeStyles } from "../utils/merge-styles.js";
|
|
2
|
-
import { createStaticStyle, isStaticStyle } from "./types.js";
|
|
3
|
-
//#region src/static/tastyStatic.ts
|
|
4
|
-
/**
|
|
5
|
-
* Build-time only function for zero-runtime static site generation.
|
|
6
|
-
*
|
|
7
|
-
* This function is transformed by the Babel plugin:
|
|
8
|
-
* - `tastyStatic(styles)` → StaticStyle object with className
|
|
9
|
-
* - `tastyStatic(base, styles)` → StaticStyle object with merged styles
|
|
10
|
-
* - `tastyStatic(selector, styles)` → removed entirely
|
|
11
|
-
*
|
|
12
|
-
* At runtime (during development/build), this function returns a placeholder.
|
|
13
|
-
* In production, all calls are replaced/removed by the build plugin.
|
|
14
|
-
*/
|
|
15
|
-
function tastyStatic(stylesOrBaseOrSelector, styles) {
|
|
16
|
-
if (typeof stylesOrBaseOrSelector === "string") {
|
|
17
|
-
console.warn(`[tasty] tastyStatic('${stylesOrBaseOrSelector}', styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (isStaticStyle(stylesOrBaseOrSelector)) {
|
|
21
|
-
console.warn("[tasty] tastyStatic(base, styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.");
|
|
22
|
-
return createStaticStyle("__TASTY_STATIC_NOT_TRANSFORMED__", mergeStyles(stylesOrBaseOrSelector.styles, styles || {}));
|
|
23
|
-
}
|
|
24
|
-
console.warn("[tasty] tastyStatic(styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.");
|
|
25
|
-
return createStaticStyle("__TASTY_STATIC_NOT_TRANSFORMED__", stylesOrBaseOrSelector);
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { tastyStatic };
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=tastyStatic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tastyStatic.js","names":[],"sources":["../../src/static/tastyStatic.ts"],"sourcesContent":["import type { Styles } from '../styles/types';\nimport { mergeStyles } from '../utils/merge-styles';\n\nimport type { StaticStyle } from './types';\nimport { createStaticStyle, isStaticStyle } from './types';\n\n/**\n * Generate styles and return a StaticStyle object.\n * The object has `className`, `styles`, and `toString()`.\n *\n * @example\n * ```typescript\n * const button = tastyStatic({\n * fill: '#blue',\n * padding: '2x',\n * });\n * // After build: { className: 'ts3f2a1b', styles: {...}, toString() }\n *\n * <div className={button} /> // Works via toString()\n * ```\n */\nexport function tastyStatic(styles: Styles): StaticStyle;\n\n/**\n * Extend an existing StaticStyle with additional styles.\n * Uses mergeStyles() internally for proper nested selector handling.\n *\n * @example\n * ```typescript\n * const button = tastyStatic({ fill: '#blue' });\n * const primary = tastyStatic(button, { fill: '#purple' });\n * // After build: { className: 'ts8c4d2e', styles: {...merged...}, toString() }\n * ```\n */\nexport function tastyStatic(base: StaticStyle, styles: Styles): StaticStyle;\n\n/**\n * Generate styles for a specific CSS selector.\n * The call is completely removed after build transformation.\n *\n * @example\n * ```typescript\n * tastyStatic('.heading', { preset: 'h1', color: '#primary' });\n * // After build: (removed)\n * ```\n */\nexport function tastyStatic(selector: string, styles: Styles): void;\n\n/**\n * Build-time only function for zero-runtime static site generation.\n *\n * This function is transformed by the Babel plugin:\n * - `tastyStatic(styles)` → StaticStyle object with className\n * - `tastyStatic(base, styles)` → StaticStyle object with merged styles\n * - `tastyStatic(selector, styles)` → removed entirely\n *\n * At runtime (during development/build), this function returns a placeholder.\n * In production, all calls are replaced/removed by the build plugin.\n */\nexport function tastyStatic(\n stylesOrBaseOrSelector: Styles | StaticStyle | string,\n styles?: Styles,\n): StaticStyle | void {\n // This code only executes if the Babel plugin hasn't processed the file yet.\n // In a properly configured build, this function is never called at runtime.\n\n if (typeof stylesOrBaseOrSelector === 'string') {\n // Selector mode: tastyStatic(selector, styles)\n // The plugin will remove this call entirely\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[tasty] tastyStatic('${stylesOrBaseOrSelector}', styles) was called at runtime. ` +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n return; // void\n }\n\n if (isStaticStyle(stylesOrBaseOrSelector)) {\n // Extension mode: tastyStatic(base, styles)\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[tasty] tastyStatic(base, styles) was called at runtime. ' +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n // Merge styles for dev mode preview (won't have real classNames)\n const mergedStyles = mergeStyles(\n stylesOrBaseOrSelector.styles,\n styles || {},\n );\n return createStaticStyle('__TASTY_STATIC_NOT_TRANSFORMED__', mergedStyles);\n }\n\n // Styles mode: tastyStatic(styles)\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[tasty] tastyStatic(styles) was called at runtime. ' +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n\n // Return placeholder - styles won't be applied without the plugin\n return createStaticStyle(\n '__TASTY_STATIC_NOT_TRANSFORMED__',\n stylesOrBaseOrSelector,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA2DA,SAAgB,YACd,wBACA,QACoB;AAIpB,KAAI,OAAO,2BAA2B,UAAU;AAI5C,UAAQ,KACN,wBAAwB,uBAAuB,2IAGhD;AAEH;;AAGF,KAAI,cAAc,uBAAuB,EAAE;AAGvC,UAAQ,KACN,mKAGD;AAOH,SAAO,kBAAkB,oCAJJ,YACnB,uBAAuB,QACvB,UAAU,EAAE,CACb,CACyE;;AAK1E,SAAQ,KACN,6JAGD;AAIH,QAAO,kBACL,oCACA,uBACD"}
|
package/dist/static/types.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Styles } from "../styles/types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/static/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Static style definition returned by tastyStatic().
|
|
6
|
-
*
|
|
7
|
-
* Supports both explicit className access and implicit string coercion via toString().
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const button = tastyStatic({ fill: '#blue' });
|
|
12
|
-
*
|
|
13
|
-
* // Both work in JSX:
|
|
14
|
-
* <div className={button} /> // Uses toString()
|
|
15
|
-
* <div className={button.className} /> // Explicit
|
|
16
|
-
*
|
|
17
|
-
* // Extension:
|
|
18
|
-
* const primary = tastyStatic(button, { fill: '#purple' });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
interface StaticStyle {
|
|
22
|
-
/**
|
|
23
|
-
* Generated className(s) for use in JSX.
|
|
24
|
-
* May contain multiple space-separated class names due to chunking.
|
|
25
|
-
*/
|
|
26
|
-
className: string;
|
|
27
|
-
/**
|
|
28
|
-
* The original (or merged) styles object.
|
|
29
|
-
* Available for extension via tastyStatic(base, overrides).
|
|
30
|
-
*/
|
|
31
|
-
styles: Styles;
|
|
32
|
-
/**
|
|
33
|
-
* Returns className for implicit string coercion.
|
|
34
|
-
* Enables `<div className={button} />` syntax.
|
|
35
|
-
*/
|
|
36
|
-
toString(): string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a StaticStyle object.
|
|
40
|
-
* Used internally by the Babel plugin to generate output.
|
|
41
|
-
*/
|
|
42
|
-
declare function createStaticStyle(className: string, styles: Styles): StaticStyle;
|
|
43
|
-
/**
|
|
44
|
-
* Type guard to check if a value is a StaticStyle object.
|
|
45
|
-
*/
|
|
46
|
-
declare function isStaticStyle(value: unknown): value is StaticStyle;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { StaticStyle, createStaticStyle, isStaticStyle };
|
|
49
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/static/types.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/static/types.ts
|
|
2
|
-
/**
|
|
3
|
-
* Create a StaticStyle object.
|
|
4
|
-
* Used internally by the Babel plugin to generate output.
|
|
5
|
-
*/
|
|
6
|
-
function createStaticStyle(className, styles) {
|
|
7
|
-
return {
|
|
8
|
-
className,
|
|
9
|
-
styles,
|
|
10
|
-
toString() {
|
|
11
|
-
return this.className;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to check if a value is a StaticStyle object.
|
|
17
|
-
*/
|
|
18
|
-
function isStaticStyle(value) {
|
|
19
|
-
return typeof value === "object" && value !== null && "className" in value && "styles" in value && "toString" in value && typeof value.className === "string" && typeof value.styles === "object";
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { createStaticStyle, isStaticStyle };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=types.js.map
|
package/dist/static/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/static/types.ts"],"sourcesContent":["import type { Styles } from '../styles/types';\n\n/**\n * Static style definition returned by tastyStatic().\n *\n * Supports both explicit className access and implicit string coercion via toString().\n *\n * @example\n * ```typescript\n * const button = tastyStatic({ fill: '#blue' });\n *\n * // Both work in JSX:\n * <div className={button} /> // Uses toString()\n * <div className={button.className} /> // Explicit\n *\n * // Extension:\n * const primary = tastyStatic(button, { fill: '#purple' });\n * ```\n */\nexport interface StaticStyle {\n /**\n * Generated className(s) for use in JSX.\n * May contain multiple space-separated class names due to chunking.\n */\n className: string;\n\n /**\n * The original (or merged) styles object.\n * Available for extension via tastyStatic(base, overrides).\n */\n styles: Styles;\n\n /**\n * Returns className for implicit string coercion.\n * Enables `<div className={button} />` syntax.\n */\n toString(): string;\n}\n\n/**\n * Create a StaticStyle object.\n * Used internally by the Babel plugin to generate output.\n */\nexport function createStaticStyle(\n className: string,\n styles: Styles,\n): StaticStyle {\n return {\n className,\n styles,\n toString() {\n return this.className;\n },\n };\n}\n\n/**\n * Type guard to check if a value is a StaticStyle object.\n */\nexport function isStaticStyle(value: unknown): value is StaticStyle {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'className' in value &&\n 'styles' in value &&\n 'toString' in value &&\n typeof (value as StaticStyle).className === 'string' &&\n typeof (value as StaticStyle).styles === 'object'\n );\n}\n"],"mappings":";;;;;AA2CA,SAAgB,kBACd,WACA,QACa;AACb,QAAO;EACL;EACA;EACA,WAAW;AACT,UAAO,KAAK;;EAEf;;;;;AAMH,SAAgB,cAAc,OAAsC;AAClE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,YAAY,SACZ,cAAc,SACd,OAAQ,MAAsB,cAAc,YAC5C,OAAQ,MAAsB,WAAW"}
|
package/dist/styles/border.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/styles/border.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Border style handler with multi-group support.
|
|
4
|
-
*
|
|
5
|
-
* Single group (backward compatible):
|
|
6
|
-
* - `border="1bw solid #red"` - all sides
|
|
7
|
-
* - `border="1bw solid #red top left"` - only top and left
|
|
8
|
-
*
|
|
9
|
-
* Multi-group (new):
|
|
10
|
-
* - `border="1bw #red, 2bw #blue top"` - all sides red 1bw, then top overridden to blue 2bw
|
|
11
|
-
* - `border="1bw, dashed top bottom, #purple left right"` - base 1bw, dashed on top/bottom, purple on left/right
|
|
12
|
-
*
|
|
13
|
-
* Later groups override earlier groups for conflicting directions.
|
|
14
|
-
*/
|
|
15
|
-
declare function borderStyle({
|
|
16
|
-
border
|
|
17
|
-
}: {
|
|
18
|
-
border?: string | number | boolean;
|
|
19
|
-
}): Record<string, string> | null;
|
|
20
|
-
declare namespace borderStyle {
|
|
21
|
-
var __lookupStyles: string[];
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { borderStyle };
|
|
25
|
-
//# sourceMappingURL=border.d.ts.map
|