@tenphi/tasty 0.0.0-snapshot.bbd10c7 → 0.0.0-snapshot.bbfcd75
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 +196 -140
- package/dist/babel-Zs1Q03qt.d.ts +83 -0
- package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
- package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
- package/dist/chunks/build-config-CUQVwdWF.js +42 -0
- package/dist/chunks/build-config-CUQVwdWF.js.map +1 -0
- package/dist/chunks/collector-B0LTHw6Z.js +208 -0
- package/dist/chunks/collector-B0LTHw6Z.js.map +1 -0
- package/dist/chunks/config-engine-C3pF9EK9.js +267 -0
- package/dist/chunks/config-engine-C3pF9EK9.js.map +1 -0
- package/dist/chunks/css-definitions-D_it4XZH.js +875 -0
- package/dist/chunks/css-definitions-D_it4XZH.js.map +1 -0
- package/dist/chunks/css-resources-BN8apgxt.js +142 -0
- package/dist/chunks/css-resources-BN8apgxt.js.map +1 -0
- package/dist/{debug.js → chunks/debug-C9LeNVoJ.js} +187 -139
- package/dist/chunks/debug-C9LeNVoJ.js.map +1 -0
- package/dist/chunks/dsl-C5yuAn41.js +1373 -0
- package/dist/chunks/dsl-C5yuAn41.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-O-OUrKLH.js +557 -0
- package/dist/chunks/react-runtime-O-OUrKLH.js.map +1 -0
- package/dist/chunks/runtime-engine-DvnE2g-E.js +2437 -0
- package/dist/chunks/runtime-engine-DvnE2g-E.js.map +1 -0
- package/dist/chunks/runtime-state-BTDqSYBk.js +127 -0
- package/dist/chunks/runtime-state-BTDqSYBk.js.map +1 -0
- package/dist/{utils/merge-styles.js → chunks/shared-utils-DWA4LjIa.js} +55 -55
- package/dist/chunks/shared-utils-DWA4LjIa.js.map +1 -0
- package/dist/chunks/style-engine-C1ECBZxR.js +5131 -0
- package/dist/chunks/style-engine-C1ECBZxR.js.map +1 -0
- package/dist/{zero/extractor.js → chunks/zero-engine-B6EnYcXY.js} +89 -82
- package/dist/chunks/zero-engine-B6EnYcXY.js.map +1 -0
- package/dist/collector-hl5KNH7k.d.ts +165 -0
- package/dist/config-DWL1ZYue.d.ts +1358 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +9 -27
- package/dist/index-D9N9GV24.d.ts +1947 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +11 -36
- package/dist/{utils/merge-styles.d.ts → merge-styles-C_oMoJVd.d.ts} +3 -3
- package/dist/ssr/astro-client.js +6 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +11 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +18 -0
- package/dist/ssr/astro-middleware-static.js +7 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +19 -0
- package/dist/ssr/astro-middleware.js +7 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +117 -11
- package/dist/ssr/astro.js +204 -48
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +37 -4
- package/dist/ssr/index.js +6 -6
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +66 -0
- package/dist/ssr/next-config.js +124 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +14 -5
- package/dist/ssr/next.js +31 -46
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +31 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.js.map +1 -1
- package/dist/types-jKZNpias.d.ts +1616 -0
- package/dist/zero/babel.d.ts +2 -182
- package/dist/zero/babel.js +82 -113
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +81 -3
- package/dist/zero/index.js +2 -3
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +0 -31
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +20 -12
- package/docs/adoption.md +59 -32
- package/docs/ai-agents.md +229 -0
- package/docs/comparison.md +76 -48
- package/docs/configuration.md +566 -69
- package/docs/debug.md +37 -23
- package/docs/design-system.md +63 -32
- package/docs/dsl.md +527 -179
- package/docs/getting-started.md +62 -41
- package/docs/injector.md +157 -51
- package/docs/methodology.md +69 -37
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +744 -0
- package/docs/plugins.md +353 -0
- package/docs/{runtime.md → react-api.md} +176 -67
- package/docs/runtime-benchmarks.md +377 -0
- package/docs/ssr.md +350 -94
- package/docs/styles.md +108 -27
- package/docs/tasty-static.md +149 -87
- package/package.json +121 -23
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- 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 -356
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -372
- package/dist/config.js +0 -507
- 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.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 -50
- package/dist/hooks/useCounterStyle.js +0 -45
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -43
- package/dist/hooks/useFontFace.js +0 -69
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -30
- package/dist/hooks/useGlobalStyles.js +0 -77
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -56
- package/dist/hooks/useKeyframes.js +0 -63
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -79
- package/dist/hooks/useProperty.js +0 -108
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -53
- package/dist/hooks/useRawCSS.js +0 -34
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -29
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -166
- package/dist/injector/index.js +0 -166
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -166
- package/dist/injector/injector.js +0 -464
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -136
- package/dist/injector/sheet-manager.js +0 -733
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -204
- 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 -230
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -708
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1103
- 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 -515
- 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 -76
- 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/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js +0 -34
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -39
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.d.ts +0 -102
- package/dist/ssr/collector.js +0 -219
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/format-global-rules.js +0 -22
- 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 -22
- package/dist/ssr/hydrate.js +0 -49
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -12
- 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/types.d.ts +0 -564
- 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 -240
- 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/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/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 +0 -146
- 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 -47
- 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/docs/PIPELINE.md +0 -519
- /package/dist/{chunks/cacheKey.d.ts → ssr/astro-client.d.ts} +0 -0
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { extractLocalProperties, hasLocalProperties } from "
|
|
2
|
-
import {
|
|
3
|
-
import { extractLocalFontFace, formatFontFaceRule, hasLocalFontFace } from "../font-face/index.js";
|
|
4
|
-
import { extractLocalCounterStyle, formatCounterStyleRule, hasLocalCounterStyle } from "../counter-style/index.js";
|
|
5
|
-
import { renderStyles } from "../pipeline/index.js";
|
|
6
|
-
import { categorizeStyleKeys } from "../chunks/definitions.js";
|
|
7
|
-
import { generateChunkCacheKey } from "../chunks/cacheKey.js";
|
|
8
|
-
import { renderStylesForChunk } from "../chunks/renderChunk.js";
|
|
9
|
-
import { extractAnimationNamesFromStyles, extractLocalKeyframes, filterUsedKeyframes, hasLocalKeyframes, mergeKeyframes } from "../keyframes/index.js";
|
|
1
|
+
import { A as validateNamePrefix, D as makeKeyframeName, G as registerLocalFunctionPolyfills, H as hasLocalFunctions, M as extractLocalProperties, P as hasLocalProperties, R as extractLocalFunctions, S as PropertyTypeResolver, T as makeClassName, U as parseFunctionName, V as formatFunctionRule, W as registerFunctionPolyfill, _ as extractLocalFontFace, b as formatFontFaceRule, c as filterUsedKeyframes, g as hasLocalCounterStyle, h as formatCounterStyleRule, l as hasLocalKeyframes, o as extractAnimationNamesFromStyles, p as extractLocalCounterStyle, s as extractLocalKeyframes, u as mergeKeyframes, x as hasLocalFontFace } from "./css-definitions-D_it4XZH.js";
|
|
2
|
+
import { U as isFunctionsPolyfillEnabled, b as renderStyles, n as generateChunkCacheKey, r as categorizeStyleKeys, t as renderStylesForChunk } from "./style-engine-C1ECBZxR.js";
|
|
10
3
|
import { createHash } from "crypto";
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
11
6
|
//#region src/zero/extractor.ts
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
let currentNamePrefix = "ts";
|
|
8
|
+
function setExtractorNamePrefix(prefix) {
|
|
9
|
+
validateNamePrefix(prefix);
|
|
10
|
+
currentNamePrefix = prefix;
|
|
11
|
+
}
|
|
17
12
|
function generateClassName(cacheKey) {
|
|
18
|
-
|
|
13
|
+
const hash = createHash("md5").update(cacheKey).digest("hex").slice(0, 6);
|
|
14
|
+
return makeClassName(currentNamePrefix, hash);
|
|
19
15
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Extract styles using chunking (for className mode).
|
|
22
|
-
* Returns multiple classes, one per chunk.
|
|
23
|
-
*/
|
|
24
16
|
function extractStylesWithChunks(styles) {
|
|
25
17
|
const chunks = [];
|
|
26
18
|
const chunkMap = categorizeStyleKeys(styles);
|
|
@@ -39,21 +31,12 @@ function extractStylesWithChunks(styles) {
|
|
|
39
31
|
}
|
|
40
32
|
return chunks;
|
|
41
33
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Extract styles for a specific selector (for global/selector mode).
|
|
44
|
-
* Returns a single CSS block.
|
|
45
|
-
*/
|
|
46
34
|
function extractStylesForSelector(selector, styles) {
|
|
47
35
|
return {
|
|
48
36
|
selector,
|
|
49
37
|
css: formatRulesDirectly(renderStyles(styles, selector))
|
|
50
38
|
};
|
|
51
39
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Format StyleResult[] to CSS string.
|
|
54
|
-
* Prefixes each rule's selector with the base selector.
|
|
55
|
-
* Used for chunked styles where rules have relative selectors.
|
|
56
|
-
*/
|
|
57
40
|
function formatRulesToCSS(rules, baseSelector) {
|
|
58
41
|
return rules.map((rule) => {
|
|
59
42
|
let css = `${(Array.isArray(rule.selector) ? rule.selector : rule.selector ? rule.selector.split("|||") : [""]).map((part) => {
|
|
@@ -69,10 +52,6 @@ function formatRulesToCSS(rules, baseSelector) {
|
|
|
69
52
|
return css;
|
|
70
53
|
}).join("\n\n");
|
|
71
54
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Format StyleResult[] to CSS string directly without prefixing.
|
|
74
|
-
* Used for global styles where rules already have the full selector.
|
|
75
|
-
*/
|
|
76
55
|
function formatRulesDirectly(rules) {
|
|
77
56
|
return rules.map((rule) => {
|
|
78
57
|
let css = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
|
|
@@ -80,24 +59,11 @@ function formatRulesDirectly(rules) {
|
|
|
80
59
|
return css;
|
|
81
60
|
}).join("\n\n");
|
|
82
61
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Generate a deterministic keyframes name from content hash.
|
|
85
|
-
* This ensures the same keyframes content always produces the same name,
|
|
86
|
-
* enabling automatic deduplication across elements and files.
|
|
87
|
-
*/
|
|
88
62
|
function generateKeyframesName(steps) {
|
|
89
63
|
const content = JSON.stringify(steps);
|
|
90
|
-
|
|
64
|
+
const hash = createHash("md5").update(content).digest("hex").slice(0, 6);
|
|
65
|
+
return makeKeyframeName(currentNamePrefix, hash);
|
|
91
66
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Extract keyframes that are used in styles.
|
|
94
|
-
* Merges local @keyframes with global keyframes, filters to only used ones.
|
|
95
|
-
* Generates hash-based names from content for automatic deduplication.
|
|
96
|
-
*
|
|
97
|
-
* @param styles - The styles object (may contain @keyframes and animation properties)
|
|
98
|
-
* @param globalKeyframes - Optional global keyframes from config
|
|
99
|
-
* @returns Keyframes to inject and name mapping for replacement
|
|
100
|
-
*/
|
|
101
67
|
function extractKeyframesFromStyles(styles, globalKeyframes) {
|
|
102
68
|
const emptyResult = {
|
|
103
69
|
keyframes: [],
|
|
@@ -127,9 +93,6 @@ function extractKeyframesFromStyles(styles, globalKeyframes) {
|
|
|
127
93
|
nameMap
|
|
128
94
|
};
|
|
129
95
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Convert keyframes steps to CSS string.
|
|
132
|
-
*/
|
|
133
96
|
function keyframesToCSS(name, steps) {
|
|
134
97
|
const stepRules = [];
|
|
135
98
|
for (const [key, value] of Object.entries(steps)) if (typeof value === "string") stepRules.push(`${key} { ${value.trim()} }`);
|
|
@@ -141,21 +104,9 @@ function keyframesToCSS(name, steps) {
|
|
|
141
104
|
}
|
|
142
105
|
return `@keyframes ${name} { ${stepRules.join(" ")} }`;
|
|
143
106
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Convert camelCase to kebab-case.
|
|
146
|
-
*/
|
|
147
107
|
function camelToKebab(str) {
|
|
148
108
|
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
149
109
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Extract auto-inferred @property declarations from styles.
|
|
152
|
-
* Scans rendered style declarations and keyframe declarations for custom properties
|
|
153
|
-
* whose types can be inferred from their values.
|
|
154
|
-
*
|
|
155
|
-
* @param styles - The styles object
|
|
156
|
-
* @param options - Options including autoPropertyTypes flag
|
|
157
|
-
* @returns Array of @property CSS rules to inject
|
|
158
|
-
*/
|
|
159
110
|
function extractPropertiesFromStyles(styles, options) {
|
|
160
111
|
if (options?.autoPropertyTypes === false) return [];
|
|
161
112
|
const registered = /* @__PURE__ */ new Set();
|
|
@@ -210,10 +161,6 @@ function scanKeyframeSteps(steps, resolver, isPropertyDefined, registerProperty)
|
|
|
210
161
|
resolver.scanDeclarations(declarations, isPropertyDefined, registerProperty);
|
|
211
162
|
}
|
|
212
163
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Extract @font-face rules from styles, merging with global config.
|
|
215
|
-
* Deduplicates by content hash.
|
|
216
|
-
*/
|
|
217
164
|
function extractFontFaceFromStyles(styles, globalFontFace) {
|
|
218
165
|
const results = [];
|
|
219
166
|
const seenHashes = /* @__PURE__ */ new Set();
|
|
@@ -237,30 +184,90 @@ function extractFontFaceFromStyles(styles, globalFontFace) {
|
|
|
237
184
|
}
|
|
238
185
|
return results;
|
|
239
186
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Extract @counter-style rules from styles, merging with global config.
|
|
242
|
-
* Deduplicates by name (first definition wins).
|
|
243
|
-
*/
|
|
244
187
|
function extractCounterStyleFromStyles(styles, globalCounterStyle) {
|
|
245
|
-
const
|
|
246
|
-
const seenNames = /* @__PURE__ */ new Set();
|
|
188
|
+
const byName = /* @__PURE__ */ new Map();
|
|
247
189
|
function addCounterStyle(name, descriptors) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
css: formatCounterStyleRule(name, descriptors)
|
|
253
|
-
});
|
|
254
|
-
}
|
|
190
|
+
byName.set(name, {
|
|
191
|
+
name,
|
|
192
|
+
css: formatCounterStyleRule(name, descriptors)
|
|
193
|
+
});
|
|
255
194
|
}
|
|
256
195
|
if (globalCounterStyle) for (const [name, descriptors] of Object.entries(globalCounterStyle)) addCounterStyle(name, descriptors);
|
|
257
196
|
if (hasLocalCounterStyle(styles)) {
|
|
258
197
|
const local = extractLocalCounterStyle(styles);
|
|
259
198
|
if (local) for (const [name, descriptors] of Object.entries(local)) addCounterStyle(name, descriptors);
|
|
260
199
|
}
|
|
261
|
-
return
|
|
200
|
+
return [...byName.values()];
|
|
201
|
+
}
|
|
202
|
+
function extractFunctionsFromStyles(styles, globalFunction) {
|
|
203
|
+
if (isFunctionsPolyfillEnabled()) {
|
|
204
|
+
if (globalFunction) for (const [name, definition] of Object.entries(globalFunction)) registerFunctionPolyfill(name, definition);
|
|
205
|
+
registerLocalFunctionPolyfills(styles);
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
const byName = /* @__PURE__ */ new Map();
|
|
209
|
+
function addFunction(name, definition) {
|
|
210
|
+
const cssName = parseFunctionName(name);
|
|
211
|
+
byName.set(cssName, {
|
|
212
|
+
name: cssName,
|
|
213
|
+
css: formatFunctionRule(name, definition)
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (globalFunction) for (const [name, definition] of Object.entries(globalFunction)) addFunction(name, definition);
|
|
217
|
+
if (hasLocalFunctions(styles)) {
|
|
218
|
+
const local = extractLocalFunctions(styles);
|
|
219
|
+
if (local) for (const [name, definition] of Object.entries(local)) addFunction(name, definition);
|
|
220
|
+
}
|
|
221
|
+
return [...byName.values()];
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/zero/css-writer.ts
|
|
225
|
+
var CSSWriter = class {
|
|
226
|
+
cssBlocks = /* @__PURE__ */ new Map();
|
|
227
|
+
outputPath;
|
|
228
|
+
devMode;
|
|
229
|
+
constructor(outputPath, options = {}) {
|
|
230
|
+
this.outputPath = outputPath;
|
|
231
|
+
this.devMode = options.devMode ?? false;
|
|
232
|
+
}
|
|
233
|
+
add(key, css, source) {
|
|
234
|
+
this.cssBlocks.set(key, {
|
|
235
|
+
css,
|
|
236
|
+
source
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
has(key) {
|
|
240
|
+
return this.cssBlocks.has(key);
|
|
241
|
+
}
|
|
242
|
+
get size() {
|
|
243
|
+
return this.cssBlocks.size;
|
|
244
|
+
}
|
|
245
|
+
write() {
|
|
246
|
+
const outputDir = path.dirname(this.outputPath);
|
|
247
|
+
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
|
|
248
|
+
const cssBlocks = [];
|
|
249
|
+
for (const block of this.cssBlocks.values()) if (this.devMode && block.source) cssBlocks.push(`/* from: ${block.source} */\n${block.css}`);
|
|
250
|
+
else cssBlocks.push(block.css);
|
|
251
|
+
const css = cssBlocks.join("\n\n");
|
|
252
|
+
fs.writeFileSync(this.outputPath, `/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n\n` + css);
|
|
253
|
+
}
|
|
254
|
+
getCSS() {
|
|
255
|
+
const cssBlocks = [];
|
|
256
|
+
for (const block of this.cssBlocks.values()) if (this.devMode && block.source) cssBlocks.push(`/* from: ${block.source} */\n${block.css}`);
|
|
257
|
+
else cssBlocks.push(block.css);
|
|
258
|
+
return cssBlocks.join("\n\n");
|
|
259
|
+
}
|
|
260
|
+
clear() {
|
|
261
|
+
this.cssBlocks.clear();
|
|
262
|
+
}
|
|
263
|
+
getOutputPath() {
|
|
264
|
+
return this.outputPath;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
function createCSSWriter(outputPath, options) {
|
|
268
|
+
return new CSSWriter(outputPath, options);
|
|
262
269
|
}
|
|
263
270
|
//#endregion
|
|
264
|
-
export {
|
|
271
|
+
export { extractFunctionsFromStyles as a, extractStylesForSelector as c, extractFontFaceFromStyles as i, extractStylesWithChunks as l, createCSSWriter as n, extractKeyframesFromStyles as o, extractCounterStyleFromStyles as r, extractPropertiesFromStyles as s, CSSWriter as t, setExtractorNamePrefix as u };
|
|
265
272
|
|
|
266
|
-
//# sourceMappingURL=
|
|
273
|
+
//# sourceMappingURL=zero-engine-B6EnYcXY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-engine-B6EnYcXY.js","names":[],"sources":["../../src/zero/extractor.ts","../../src/zero/css-writer.ts"],"sourcesContent":["import { createHash } from 'crypto';\n\nimport {\n categorizeStyleKeys,\n generateChunkCacheKey,\n renderStylesForChunk,\n} from '../chunks';\nimport type {\n CounterStyleDescriptors,\n FontFaceDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n} from '../injector/types';\nimport {\n extractLocalCounterStyle,\n formatCounterStyleRule,\n hasLocalCounterStyle,\n} from '../counter-style';\nimport {\n extractLocalFontFace,\n formatFontFaceRule,\n hasLocalFontFace,\n} from '../font-face';\nimport { isFunctionsPolyfillEnabled } from '../config-state';\nimport {\n extractLocalFunctions,\n formatFunctionRule,\n hasLocalFunctions,\n parseFunctionName,\n registerFunctionPolyfill,\n registerLocalFunctionPolyfills,\n} from '../functions';\nimport {\n extractAnimationNamesFromStyles,\n extractLocalKeyframes,\n filterUsedKeyframes,\n hasLocalKeyframes,\n mergeKeyframes,\n} from '../keyframes';\nimport type { StyleResult } from '../pipeline';\nimport { renderStyles } from '../pipeline';\nimport { extractLocalProperties, hasLocalProperties } from '../properties';\nimport { PropertyTypeResolver } from '../properties/property-type-resolver';\nimport type { Styles } from '../styles/types';\nimport {\n DEFAULT_ZERO_NAME_PREFIX,\n makeClassName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\n\nexport interface ExtractedChunk {\n className: string;\n css: string;\n}\n\nexport interface ExtractedSelector {\n selector: string;\n css: string;\n}\n\nexport interface ExtractedKeyframes {\n name: string;\n css: string;\n}\n\ninterface KeyframesExtractionResult {\n /** Keyframes to inject (deduplicated by content) */\n keyframes: ExtractedKeyframes[];\n /** Map from original animation name to canonical name (for replacement) */\n nameMap: Map<string, string>;\n}\n\n/**\n * Module-level prefix used by the zero-runtime extractor.\n * Defaults to `'ts'` so static classes never collide with the runtime\n * `'t'` classes when both are loaded on the same page. Override via\n * `setExtractorNamePrefix()` from the Babel plugin so user config flows\n * into the extractor.\n */\nlet currentNamePrefix: string = DEFAULT_ZERO_NAME_PREFIX;\n\n/**\n * Set the prefix used by the zero-runtime extractor.\n * Called by the Babel plugin after resolving user config so that\n * generated class and keyframe names match the user's configuration.\n */\nexport function setExtractorNamePrefix(prefix: string): void {\n validateNamePrefix(prefix);\n currentNamePrefix = prefix;\n}\n\n/**\n * Get the prefix currently used by the zero-runtime extractor.\n * Exposed primarily for tests.\n */\nexport function getExtractorNamePrefix(): string {\n return currentNamePrefix;\n}\n\n/**\n * Generate a deterministic className from a cache key using content hash.\n * This ensures the same styles always produce the same className,\n * regardless of build order or incremental compilation.\n */\nfunction generateClassName(cacheKey: string): string {\n const hash = createHash('md5').update(cacheKey).digest('hex').slice(0, 6);\n return makeClassName(currentNamePrefix, hash);\n}\n\n/**\n * Extract styles using chunking (for className mode).\n * Returns multiple classes, one per chunk.\n */\nexport function extractStylesWithChunks(styles: Styles): ExtractedChunk[] {\n const chunks: ExtractedChunk[] = [];\n\n // Categorize style keys into chunks\n const chunkMap = categorizeStyleKeys(styles as Record<string, unknown>);\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n\n // Generate cache key for this chunk (used for className hash)\n const cacheKey = generateChunkCacheKey(styles, chunkName, chunkStyleKeys);\n\n // Render styles for this chunk\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n\n if (renderResult.rules.length === 0) continue;\n\n // Generate deterministic className from content hash\n const className = generateClassName(cacheKey);\n const selector = `.${className}.${className}`;\n\n // Format CSS\n const css = formatRulesToCSS(renderResult.rules, selector);\n\n chunks.push({ className, css });\n }\n\n return chunks;\n}\n\n/**\n * Extract styles for a specific selector (for global/selector mode).\n * Returns a single CSS block.\n */\nexport function extractStylesForSelector(\n selector: string,\n styles: Styles,\n): ExtractedSelector {\n // renderStyles with selector returns StyleResult[] with selectors already applied\n const rules = renderStyles(styles, selector);\n // Format without re-prefixing - rules already have the full selector\n const css = formatRulesDirectly(rules);\n\n return { selector, css };\n}\n\n/**\n * Format StyleResult[] to CSS string.\n * Prefixes each rule's selector with the base selector.\n * Used for chunked styles where rules have relative selectors.\n */\nfunction formatRulesToCSS(rules: StyleResult[], baseSelector: string): string {\n return rules\n .map((rule) => {\n // Handle selector as array (OR conditions) or string\n // Note: renderStyles without className joins array selectors with '|||' placeholder\n const selectorParts = Array.isArray(rule.selector)\n ? rule.selector\n : rule.selector\n ? rule.selector.split('|||')\n : [''];\n\n // Prefix each selector part with the base selector\n const fullSelector = selectorParts\n .map((part) => {\n // Build selector: [rootPrefix] baseSelector[part]\n let selector: string;\n\n // If part is empty, just use base selector\n if (!part) {\n selector = baseSelector;\n } else if (part.startsWith(':') || part.startsWith('[')) {\n // If part starts with a pseudo-class or pseudo-element, append to base\n selector = `${baseSelector}${part}`;\n } else if (\n part.startsWith('>') ||\n part.startsWith('+') ||\n part.startsWith('~')\n ) {\n // If part starts with >, +, ~ combinator, append with space\n selector = `${baseSelector}${part}`;\n } else {\n // Otherwise, combine base with part\n selector = `${baseSelector}${part}`;\n }\n\n // Prepend rootPrefix if present (for @root() states)\n if (rule.rootPrefix) {\n selector = `${rule.rootPrefix} ${selector}`;\n }\n\n return selector;\n })\n .join(', ');\n\n let css = `${fullSelector} { ${rule.declarations} }`;\n\n // Wrap in at-rules (in reverse order for proper nesting)\n if (rule.atRules && rule.atRules.length > 0) {\n for (const atRule of [...rule.atRules].reverse()) {\n css = `${atRule} {\\n ${css}\\n}`;\n }\n }\n\n return css;\n })\n .join('\\n\\n');\n}\n\n/**\n * Format StyleResult[] to CSS string directly without prefixing.\n * Used for global styles where rules already have the full selector.\n */\nfunction formatRulesDirectly(rules: StyleResult[]): string {\n return rules\n .map((rule) => {\n // Prepend rootPrefix if present (for @root() states)\n const selector = rule.rootPrefix\n ? `${rule.rootPrefix} ${rule.selector}`\n : rule.selector;\n\n let css = `${selector} { ${rule.declarations} }`;\n\n // Wrap in at-rules (in reverse order for proper nesting)\n if (rule.atRules && rule.atRules.length > 0) {\n for (const atRule of [...rule.atRules].reverse()) {\n css = `${atRule} {\\n ${css}\\n}`;\n }\n }\n\n return css;\n })\n .join('\\n\\n');\n}\n\n// Note: With hash-based className generation, counter management functions\n// are no longer needed. ClassNames are deterministic based on content.\n\n/**\n * Generate a deterministic keyframes name from content hash.\n * This ensures the same keyframes content always produces the same name,\n * enabling automatic deduplication across elements and files.\n *\n * Uses the configured prefix with a `k` discriminator so keyframe names\n * stay visually distinct from class names sharing the same prefix.\n */\nfunction generateKeyframesName(steps: KeyframesSteps): string {\n const content = JSON.stringify(steps);\n const hash = createHash('md5').update(content).digest('hex').slice(0, 6);\n return makeKeyframeName(currentNamePrefix, hash);\n}\n\n/**\n * Extract keyframes that are used in styles.\n * Merges local @keyframes with global keyframes, filters to only used ones.\n * Generates hash-based names from content for automatic deduplication.\n *\n * @param styles - The styles object (may contain @keyframes and animation properties)\n * @param globalKeyframes - Optional global keyframes from config\n * @returns Keyframes to inject and name mapping for replacement\n */\nexport function extractKeyframesFromStyles(\n styles: Styles,\n globalKeyframes?: Record<string, KeyframesSteps> | null,\n): KeyframesExtractionResult {\n const emptyResult: KeyframesExtractionResult = {\n keyframes: [],\n nameMap: new Map(),\n };\n\n // Extract animation names from styles\n const usedNames = extractAnimationNamesFromStyles(styles);\n if (usedNames.size === 0) return emptyResult;\n\n // Merge local and global keyframes\n const local = hasLocalKeyframes(styles)\n ? extractLocalKeyframes(styles)\n : null;\n const allKeyframes = mergeKeyframes(local, globalKeyframes ?? null);\n\n // Filter to only used keyframes\n const usedKeyframes = filterUsedKeyframes(allKeyframes, usedNames);\n if (!usedKeyframes) return emptyResult;\n\n // Generate hash-based names and collect unique keyframes\n const seenHashes = new Set<string>();\n const nameMap = new Map<string, string>();\n const keyframesToEmit: ExtractedKeyframes[] = [];\n\n for (const [originalName, steps] of Object.entries(usedKeyframes)) {\n const hashedName = generateKeyframesName(steps);\n\n // Always map original name to hashed name (for CSS replacement)\n nameMap.set(originalName, hashedName);\n\n // Only emit each unique keyframe once\n if (!seenHashes.has(hashedName)) {\n seenHashes.add(hashedName);\n const css = keyframesToCSS(hashedName, steps);\n keyframesToEmit.push({ name: hashedName, css });\n }\n }\n\n return { keyframes: keyframesToEmit, nameMap };\n}\n\n/**\n * Convert keyframes steps to CSS string.\n */\nfunction keyframesToCSS(name: string, steps: KeyframesSteps): string {\n const stepRules: string[] = [];\n\n for (const [key, value] of Object.entries(steps)) {\n if (typeof value === 'string') {\n // Raw CSS string\n stepRules.push(`${key} { ${value.trim()} }`);\n } else if (value && typeof value === 'object') {\n // Style map - convert to CSS declarations\n const declarations = Object.entries(value)\n .map(([prop, val]) => {\n const cssProperty = camelToKebab(prop);\n return `${cssProperty}: ${val}`;\n })\n .join('; ');\n stepRules.push(`${key} { ${declarations} }`);\n }\n }\n\n return `@keyframes ${name} { ${stepRules.join(' ')} }`;\n}\n\n/**\n * Convert camelCase to kebab-case.\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n// ============================================================================\n// Property Extraction (auto-infer @property types for zero-runtime)\n// ============================================================================\n\nexport interface ExtractedProperty {\n name: string;\n css: string;\n}\n\n/**\n * Extract auto-inferred @property declarations from styles.\n * Scans rendered style declarations and keyframe declarations for custom properties\n * whose types can be inferred from their values.\n *\n * @param styles - The styles object\n * @param options - Options including autoPropertyTypes flag\n * @returns Array of @property CSS rules to inject\n */\nexport function extractPropertiesFromStyles(\n styles: Styles,\n options?: { autoPropertyTypes?: boolean },\n): ExtractedProperty[] {\n if (options?.autoPropertyTypes === false) return [];\n\n const registered = new Set<string>();\n const results: ExtractedProperty[] = [];\n\n // Collect explicitly declared properties (they take precedence)\n if (hasLocalProperties(styles)) {\n const localProps = extractLocalProperties(styles);\n if (localProps) {\n for (const token of Object.keys(localProps)) {\n // Normalize token to CSS name\n let cssName: string;\n if (token.startsWith('#')) {\n cssName = `--${token.slice(1)}-color`;\n } else if (token.startsWith('$')) {\n cssName = `--${token.slice(1)}`;\n } else if (token.startsWith('--')) {\n cssName = token;\n } else {\n cssName = `--${token}`;\n }\n registered.add(cssName);\n }\n }\n }\n\n const resolver = new PropertyTypeResolver();\n\n const registerProperty = (\n name: string,\n syntax: string,\n initialValue: string,\n ) => {\n if (registered.has(name)) return;\n registered.add(name);\n\n const parts: string[] = [];\n parts.push(`syntax: \"${syntax}\";`);\n parts.push(`inherits: true;`);\n parts.push(`initial-value: ${initialValue};`);\n\n const css = `@property ${name} { ${parts.join(' ')} }`;\n results.push({ name, css });\n };\n\n const isPropertyDefined = (name: string) => registered.has(name);\n\n // Scan rendered style declarations\n const chunkMap = categorizeStyleKeys(styles as Record<string, unknown>);\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n for (const rule of renderResult.rules) {\n if (!rule.declarations) continue;\n resolver.scanDeclarations(\n rule.declarations,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n\n // Scan keyframe declarations\n if (hasLocalKeyframes(styles)) {\n const localKf = extractLocalKeyframes(styles);\n if (localKf) {\n for (const steps of Object.values(localKf)) {\n scanKeyframeSteps(steps, resolver, isPropertyDefined, registerProperty);\n }\n }\n }\n\n return results;\n}\n\nfunction scanKeyframeSteps(\n steps: KeyframesSteps,\n resolver: PropertyTypeResolver,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n): void {\n for (const value of Object.values(steps)) {\n if (typeof value === 'string') {\n resolver.scanDeclarations(value, isPropertyDefined, registerProperty);\n } else if (value && typeof value === 'object') {\n const declarations = Object.entries(value)\n .map(([prop, val]) => {\n const cssProperty = camelToKebab(prop);\n return `${cssProperty}: ${val}`;\n })\n .join('; ');\n resolver.scanDeclarations(\n declarations,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n}\n\n// ============================================================================\n// Font Face Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedFontFace {\n css: string;\n}\n\n/**\n * Extract @font-face rules from styles, merging with global config.\n * Deduplicates by content hash.\n */\nexport function extractFontFaceFromStyles(\n styles: Styles,\n globalFontFace?: Record<string, FontFaceInput> | null,\n): ExtractedFontFace[] {\n const results: ExtractedFontFace[] = [];\n const seenHashes = new Set<string>();\n\n function addFontFace(family: string, input: FontFaceInput) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = createHash('md5')\n .update(JSON.stringify({ family, ...desc }))\n .digest('hex')\n .slice(0, 8);\n if (!seenHashes.has(hash)) {\n seenHashes.add(hash);\n results.push({ css: formatFontFaceRule(family, desc) });\n }\n }\n }\n\n // Global font faces first\n if (globalFontFace) {\n for (const [family, input] of Object.entries(globalFontFace)) {\n addFontFace(family, input);\n }\n }\n\n // Local font faces. @font-face is keyed by content hash, not family name, so\n // distinct definitions all emit and byte-identical ones collapse — there is\n // no \"winner\" to pick between a global and a local definition.\n if (hasLocalFontFace(styles)) {\n const local = extractLocalFontFace(styles);\n if (local) {\n for (const [family, input] of Object.entries(local)) {\n addFontFace(family, input);\n }\n }\n }\n\n return results;\n}\n\n// ============================================================================\n// Counter Style Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedCounterStyle {\n name: string;\n css: string;\n}\n\n/**\n * Extract @counter-style rules from styles, merging with global config.\n * Deduplicates by name; component-local definitions override global ones with\n * the same name (local wins).\n */\nexport function extractCounterStyleFromStyles(\n styles: Styles,\n globalCounterStyle?: Record<string, CounterStyleDescriptors> | null,\n): ExtractedCounterStyle[] {\n const byName = new Map<string, ExtractedCounterStyle>();\n\n function addCounterStyle(name: string, descriptors: CounterStyleDescriptors) {\n byName.set(name, { name, css: formatCounterStyleRule(name, descriptors) });\n }\n\n // Global counter styles first, then local — local replaces global on conflict.\n if (globalCounterStyle) {\n for (const [name, descriptors] of Object.entries(globalCounterStyle)) {\n addCounterStyle(name, descriptors);\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const local = extractLocalCounterStyle(styles);\n if (local) {\n for (const [name, descriptors] of Object.entries(local)) {\n addCounterStyle(name, descriptors);\n }\n }\n }\n\n return [...byName.values()];\n}\n\n// ============================================================================\n// Function Extraction (zero-runtime)\n// ============================================================================\n\nexport interface ExtractedFunction {\n name: string;\n css: string;\n}\n\n/**\n * Extract @function rules from styles, merging with global config.\n * Deduplicates by CSS function name; component-local definitions override\n * global ones with the same name (local wins).\n */\nexport function extractFunctionsFromStyles(\n styles: Styles,\n globalFunction?: Record<string, FunctionDefinition> | null,\n): ExtractedFunction[] {\n // @function polyfill: register definitions as inline closures so call sites\n // are expanded to plain CSS during chunk rendering. No native @function rules\n // are emitted. Global definitions are also registered here as a safety net in\n // case configure() ran in a separate module scope.\n if (isFunctionsPolyfillEnabled()) {\n if (globalFunction) {\n for (const [name, definition] of Object.entries(globalFunction)) {\n registerFunctionPolyfill(name, definition);\n }\n }\n registerLocalFunctionPolyfills(styles);\n return [];\n }\n\n const byName = new Map<string, ExtractedFunction>();\n\n function addFunction(name: string, definition: FunctionDefinition) {\n const cssName = parseFunctionName(name);\n byName.set(cssName, {\n name: cssName,\n css: formatFunctionRule(name, definition),\n });\n }\n\n // Global functions first, then local — local replaces global on conflict.\n if (globalFunction) {\n for (const [name, definition] of Object.entries(globalFunction)) {\n addFunction(name, definition);\n }\n }\n\n if (hasLocalFunctions(styles)) {\n const local = extractLocalFunctions(styles);\n if (local) {\n for (const [name, definition] of Object.entries(local)) {\n addFunction(name, definition);\n }\n }\n }\n\n return [...byName.values()];\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface CSSWriterOptions {\n /** Enable source comments in output (e.g., \"from: Button.tsx\") */\n devMode?: boolean;\n}\n\ninterface CSSBlock {\n css: string;\n source?: string;\n}\n\nexport class CSSWriter {\n private cssBlocks = new Map<string, CSSBlock>();\n private outputPath: string;\n private devMode: boolean;\n\n constructor(outputPath: string, options: CSSWriterOptions = {}) {\n this.outputPath = outputPath;\n this.devMode = options.devMode ?? false;\n }\n\n /**\n * Add CSS block with deduplication key\n * @param key - Unique key for deduplication\n * @param css - CSS content\n * @param source - Optional source file path (used in devMode)\n */\n add(key: string, css: string, source?: string): void {\n this.cssBlocks.set(key, { css, source });\n }\n\n /**\n * Check if a key already exists\n */\n has(key: string): boolean {\n return this.cssBlocks.has(key);\n }\n\n /**\n * Get the number of CSS blocks\n */\n get size(): number {\n return this.cssBlocks.size;\n }\n\n /**\n * Write all collected CSS to the output file\n */\n write(): void {\n const outputDir = path.dirname(this.outputPath);\n\n // Ensure directory exists\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Combine all CSS blocks with optional source comments\n const cssBlocks: string[] = [];\n for (const block of this.cssBlocks.values()) {\n if (this.devMode && block.source) {\n cssBlocks.push(`/* from: ${block.source} */\\n${block.css}`);\n } else {\n cssBlocks.push(block.css);\n }\n }\n const css = cssBlocks.join('\\n\\n');\n\n // Add header comment\n const header = `/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\\n\\n`;\n\n fs.writeFileSync(this.outputPath, header + css);\n }\n\n /**\n * Get all CSS as string (for testing or in-memory use)\n */\n getCSS(): string {\n const cssBlocks: string[] = [];\n for (const block of this.cssBlocks.values()) {\n if (this.devMode && block.source) {\n cssBlocks.push(`/* from: ${block.source} */\\n${block.css}`);\n } else {\n cssBlocks.push(block.css);\n }\n }\n return cssBlocks.join('\\n\\n');\n }\n\n /**\n * Clear all collected CSS\n */\n clear(): void {\n this.cssBlocks.clear();\n }\n\n /**\n * Get the output path\n */\n getOutputPath(): string {\n return this.outputPath;\n }\n}\n\n/**\n * Factory for creating a {@link CSSWriter} instance.\n *\n * Canonical functional entry point; the `CSSWriter` class remains exported\n * for advanced/internal use.\n *\n * @example\n * ```ts\n * import { createCSSWriter } from '@tenphi/tasty/zero';\n *\n * const writer = createCSSWriter('output.css', { devMode: true });\n * ```\n */\nexport function createCSSWriter(\n outputPath: string,\n options?: CSSWriterOptions,\n): CSSWriter {\n return new CSSWriter(outputPath, options);\n}\n"],"mappings":";;;;;;AAiFA,IAAI,oBAAA;AAOJ,SAAgB,uBAAuB,QAAsB;CAC3D,mBAAmB,MAAM;CACzB,oBAAoB;AACtB;AAeA,SAAS,kBAAkB,UAA0B;CACnD,MAAM,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,QAAQ,CAAC,C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,KAAsB;EACxB,OAAO,KAAK,UAAU,IAAI,GAAG;CAC/B;CAKA,IAAI,OAAe;EACjB,OAAO,KAAK,UAAU;CACxB;CAKA,QAAc;EACZ,MAAM,YAAY,KAAK,QAAQ,KAAK,UAAU;EAG9C,IAAI,CAAC,GAAG,WAAW,SAAS,GAC1B,GAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;EAI7C,MAAM,YAAsB,CAAC;EAC7B,KAAK,MAAM,SAAS,KAAK,UAAU,OAAO,GACxC,IAAI,KAAK,WAAW,MAAM,QACxB,UAAU,KAAK,YAAY,MAAM,OAAO,OAAO,MAAM,KAAK;OAE1D,UAAU,KAAK,MAAM,GAAG;EAG5B,MAAM,MAAM,UAAU,KAAK,MAAM;EAKjC,GAAG,cAAc,KAAK,YAAY,4DAAS,GAAG;CAChD;CAKA,SAAiB;EACf,MAAM,YAAsB,CAAC;EAC7B,KAAK,MAAM,SAAS,KAAK,UAAU,OAAO,GACxC,IAAI,KAAK,WAAW,MAAM,QACxB,UAAU,KAAK,YAAY,MAAM,OAAO,OAAO,MAAM,KAAK;OAE1D,UAAU,KAAK,MAAM,GAAG;EAG5B,OAAO,UAAU,KAAK,MAAM;CAC9B;CAKA,QAAc;EACZ,KAAK,UAAU,MAAM;CACvB;CAKA,gBAAwB;EACtB,OAAO,KAAK;CACd;AACF;AAeA,SAAgB,gBACd,YACA,SACW;CACX,OAAO,IAAI,UAAU,YAAY,OAAO;AAC1C"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { M as StyleResult } from "./types-jKZNpias.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ssr/artifacts.d.ts
|
|
4
|
+
type ServerStyleArtifactKind = 'property' | 'font-face' | 'counter-style' | 'function' | 'raw' | 'global' | 'chunk' | 'keyframes';
|
|
5
|
+
interface ServerStyleArtifact {
|
|
6
|
+
/** Stable identifier derived from the artifact kind, logical key, and CSS. */
|
|
7
|
+
id: string;
|
|
8
|
+
kind: ServerStyleArtifactKind;
|
|
9
|
+
css: string;
|
|
10
|
+
/** Zero-based position in the collector's final cascade order. */
|
|
11
|
+
order: number;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/ssr/collector.d.ts
|
|
15
|
+
declare class ServerStyleCollector {
|
|
16
|
+
private chunks;
|
|
17
|
+
private cacheKeyToClassName;
|
|
18
|
+
private flushedKeys;
|
|
19
|
+
private propertyRules;
|
|
20
|
+
private flushedPropertyKeys;
|
|
21
|
+
private keyframeRules;
|
|
22
|
+
private flushedKeyframeKeys;
|
|
23
|
+
private globalStyles;
|
|
24
|
+
private flushedGlobalKeys;
|
|
25
|
+
private rawCSS;
|
|
26
|
+
private flushedRawKeys;
|
|
27
|
+
private fontFaceRules;
|
|
28
|
+
private flushedFontFaceKeys;
|
|
29
|
+
private counterStyleRules;
|
|
30
|
+
private flushedCounterStyleKeys;
|
|
31
|
+
private functionRules;
|
|
32
|
+
private flushedFunctionKeys;
|
|
33
|
+
private keyframesCounter;
|
|
34
|
+
private counterStyleCounter;
|
|
35
|
+
private internalsCollected;
|
|
36
|
+
private namePrefix;
|
|
37
|
+
/**
|
|
38
|
+
* @param namePrefix - Optional override for the configured prefix.
|
|
39
|
+
* Defaults to the value from `configure({ namePrefix })` (or `'t'`).
|
|
40
|
+
* Pass an explicit prefix when constructing a collector outside the
|
|
41
|
+
* normal configure() lifecycle (e.g. in tests). Validated eagerly
|
|
42
|
+
* so misconfiguration fails before any CSS is collected.
|
|
43
|
+
*/
|
|
44
|
+
constructor(namePrefix?: string);
|
|
45
|
+
private generateClassName;
|
|
46
|
+
/**
|
|
47
|
+
* Collect internal @property rules and :root token defaults.
|
|
48
|
+
* Mirrors markStylesGenerated() from the client-side injector.
|
|
49
|
+
* Called automatically on first chunk collection; idempotent.
|
|
50
|
+
*
|
|
51
|
+
* Internals are always emitted here — the RSC path deliberately
|
|
52
|
+
* defers to SSR so that tokens appear exactly once per page in
|
|
53
|
+
* <style data-tasty-ssr> (avoiding duplication of large token sets).
|
|
54
|
+
*/
|
|
55
|
+
collectInternals(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Allocate a className for a cache key, server-side.
|
|
58
|
+
* Mirrors StyleInjector.allocateClassName but without DOM access.
|
|
59
|
+
*/
|
|
60
|
+
allocateClassName(cacheKey: string): {
|
|
61
|
+
className: string;
|
|
62
|
+
isNewAllocation: boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Record CSS rules for a chunk.
|
|
66
|
+
* Called by useStyles during server render.
|
|
67
|
+
*/
|
|
68
|
+
collectChunk(cacheKey: string, className: string, rules: StyleResult[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Record a @property rule. Deduplicated by name.
|
|
71
|
+
*/
|
|
72
|
+
collectProperty(name: string, css: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Record a @keyframes rule. Deduplicated by name.
|
|
75
|
+
*/
|
|
76
|
+
collectKeyframes(name: string, css: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Allocate a keyframe name for SSR. Uses provided name or generates one.
|
|
79
|
+
*/
|
|
80
|
+
allocateKeyframeName(providedName?: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Record a @font-face rule. Deduplicated by key (content hash).
|
|
83
|
+
*/
|
|
84
|
+
collectFontFace(key: string, css: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Record a @counter-style rule. Deduplicated by name and overrides an
|
|
87
|
+
* existing rule by default. Pass `weak: true` for global `configure()`
|
|
88
|
+
* definitions, which never clobber an existing rule.
|
|
89
|
+
*/
|
|
90
|
+
collectCounterStyle(name: string, css: string, options?: {
|
|
91
|
+
weak?: boolean;
|
|
92
|
+
}): void;
|
|
93
|
+
/**
|
|
94
|
+
* Record a @function rule. Deduplicated by CSS function name and overrides an
|
|
95
|
+
* existing rule by default. Pass `weak: true` for global `configure()`
|
|
96
|
+
* definitions, which never clobber an existing rule.
|
|
97
|
+
*/
|
|
98
|
+
collectFunction(name: string, css: string, options?: {
|
|
99
|
+
weak?: boolean;
|
|
100
|
+
}): void;
|
|
101
|
+
/**
|
|
102
|
+
* Allocate a counter-style name for SSR. Uses provided name or generates one.
|
|
103
|
+
*/
|
|
104
|
+
allocateCounterStyleName(providedName?: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Record global styles (from useGlobalStyles). Deduplicated by key.
|
|
107
|
+
*
|
|
108
|
+
* Pass `replace` for slot-keyed entries (an explicit `id`), where the last
|
|
109
|
+
* write must win to match the client's update-tracking behavior.
|
|
110
|
+
*/
|
|
111
|
+
collectGlobalStyles(key: string, css: string, replace?: boolean): void;
|
|
112
|
+
/**
|
|
113
|
+
* Record raw CSS text (from useRawCSS). Deduplicated by key.
|
|
114
|
+
*
|
|
115
|
+
* Pass `replace` for slot-keyed entries (an explicit `id`), where the last
|
|
116
|
+
* write must win to match the client's update-tracking behavior.
|
|
117
|
+
*/
|
|
118
|
+
collectRawCSS(key: string, css: string, replace?: boolean): void;
|
|
119
|
+
/**
|
|
120
|
+
* Return the collected CSS as structured, ordered artifacts.
|
|
121
|
+
*
|
|
122
|
+
* Artifact boundaries are part of the collector output so build tools never
|
|
123
|
+
* need to split or parse CSS text. IDs include the logical collection key
|
|
124
|
+
* and content, making them stable across equivalent page renders while a CSS
|
|
125
|
+
* change always produces a different ID.
|
|
126
|
+
*/
|
|
127
|
+
getArtifacts(): ServerStyleArtifact[];
|
|
128
|
+
/**
|
|
129
|
+
* Extract all CSS collected so far as a single string.
|
|
130
|
+
* Includes @property and @keyframes rules.
|
|
131
|
+
* Used for non-streaming SSR (renderToString).
|
|
132
|
+
*/
|
|
133
|
+
getCSS(): string;
|
|
134
|
+
/**
|
|
135
|
+
* Flush only newly collected CSS since the last flush.
|
|
136
|
+
* Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).
|
|
137
|
+
*/
|
|
138
|
+
flushCSS(): string;
|
|
139
|
+
private flushedClassNames;
|
|
140
|
+
/**
|
|
141
|
+
* Return class names rendered since the last call (for streaming).
|
|
142
|
+
* Used to emit lightweight class-list scripts for client hydration.
|
|
143
|
+
*/
|
|
144
|
+
getRenderedClassNames(): string[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Factory for creating a {@link ServerStyleCollector} instance.
|
|
148
|
+
*
|
|
149
|
+
* Canonical functional entry point; the `ServerStyleCollector` class remains
|
|
150
|
+
* exported for advanced/internal use.
|
|
151
|
+
*
|
|
152
|
+
* @param namePrefix - Optional override for the configured class-name prefix.
|
|
153
|
+
* Defaults to the value from `configure({ namePrefix })` (or `'t'`).
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { createServerStyleCollector } from '@tenphi/tasty/ssr';
|
|
158
|
+
*
|
|
159
|
+
* const collector = createServerStyleCollector();
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function createServerStyleCollector(namePrefix?: string): ServerStyleCollector;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { ServerStyleArtifactKind as i, createServerStyleCollector as n, ServerStyleArtifact as r, ServerStyleCollector as t };
|
|
165
|
+
//# sourceMappingURL=collector-hl5KNH7k.d.ts.map
|