@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,90 +0,0 @@
|
|
|
1
|
-
import { inferSyntaxFromValue } from "./index.js";
|
|
2
|
-
//#region src/properties/property-type-resolver.ts
|
|
3
|
-
/**
|
|
4
|
-
* PropertyTypeResolver
|
|
5
|
-
*
|
|
6
|
-
* Automatically infers CSS @property types from custom property values.
|
|
7
|
-
* Supports deferred resolution for var() reference chains of arbitrary depth.
|
|
8
|
-
*/
|
|
9
|
-
const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(.+?)\s*$/i;
|
|
10
|
-
const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
|
|
11
|
-
var PropertyTypeResolver = class {
|
|
12
|
-
/** propName → the prop it depends on */
|
|
13
|
-
pendingDeps = /* @__PURE__ */ new Map();
|
|
14
|
-
/** propName → list of props waiting on it */
|
|
15
|
-
reverseDeps = /* @__PURE__ */ new Map();
|
|
16
|
-
/**
|
|
17
|
-
* Scan CSS declarations and auto-register @property for custom properties
|
|
18
|
-
* whose types can be inferred from their values.
|
|
19
|
-
*/
|
|
20
|
-
scanDeclarations(declarations, isPropertyDefined, registerProperty) {
|
|
21
|
-
if (!declarations.includes("--")) return;
|
|
22
|
-
const parts = declarations.split(/;+/);
|
|
23
|
-
for (const part of parts) {
|
|
24
|
-
if (!part.trim()) continue;
|
|
25
|
-
const match = CUSTOM_PROP_DECL.exec(part);
|
|
26
|
-
if (!match) continue;
|
|
27
|
-
const propName = match[1];
|
|
28
|
-
const value = match[2].trim();
|
|
29
|
-
if (isPropertyDefined(propName)) continue;
|
|
30
|
-
if (propName.endsWith("-color")) {
|
|
31
|
-
registerProperty(propName, "<color>", "transparent");
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (propName.endsWith("-line-height")) {
|
|
35
|
-
registerProperty(propName, "<number> | <length-percentage>", "0");
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (propName.endsWith("-opacity")) {
|
|
39
|
-
registerProperty(propName, "<number> | <percentage>", "0");
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const varMatch = SINGLE_VAR_REF.exec(value);
|
|
43
|
-
if (varMatch) {
|
|
44
|
-
const depName = varMatch[1];
|
|
45
|
-
this.addDependency(propName, depName);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (this.isComplexValue(value)) continue;
|
|
49
|
-
const inferred = inferSyntaxFromValue(value);
|
|
50
|
-
if (!inferred) continue;
|
|
51
|
-
this.resolve(propName, inferred.syntax, inferred.initialValue, isPropertyDefined, registerProperty);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
addDependency(propName, depName) {
|
|
55
|
-
if (propName === depName) return;
|
|
56
|
-
this.pendingDeps.set(propName, depName);
|
|
57
|
-
let dependents = this.reverseDeps.get(depName);
|
|
58
|
-
if (!dependents) {
|
|
59
|
-
dependents = [];
|
|
60
|
-
this.reverseDeps.set(depName, dependents);
|
|
61
|
-
}
|
|
62
|
-
if (!dependents.includes(propName)) dependents.push(propName);
|
|
63
|
-
}
|
|
64
|
-
resolve(propName, syntax, initialValue, isPropertyDefined, registerProperty, resolving) {
|
|
65
|
-
if (!resolving) resolving = /* @__PURE__ */ new Set();
|
|
66
|
-
if (resolving.has(propName)) return;
|
|
67
|
-
resolving.add(propName);
|
|
68
|
-
if (!isPropertyDefined(propName)) registerProperty(propName, syntax, initialValue);
|
|
69
|
-
const dependents = this.reverseDeps.get(propName);
|
|
70
|
-
if (dependents) {
|
|
71
|
-
this.reverseDeps.delete(propName);
|
|
72
|
-
for (const dependent of dependents) {
|
|
73
|
-
this.pendingDeps.delete(dependent);
|
|
74
|
-
if (isPropertyDefined(dependent)) continue;
|
|
75
|
-
this.resolve(dependent, syntax, initialValue, isPropertyDefined, registerProperty, resolving);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
isComplexValue(value) {
|
|
80
|
-
if (value.includes("calc(")) return true;
|
|
81
|
-
const firstVar = value.indexOf("var(");
|
|
82
|
-
if (firstVar === -1) return false;
|
|
83
|
-
if (value.indexOf("var(", firstVar + 4) !== -1) return true;
|
|
84
|
-
return !SINGLE_VAR_REF.test(value);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
//#endregion
|
|
88
|
-
export { PropertyTypeResolver };
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=property-type-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property-type-resolver.js","names":[],"sources":["../../src/properties/property-type-resolver.ts"],"sourcesContent":["/**\n * PropertyTypeResolver\n *\n * Automatically infers CSS @property types from custom property values.\n * Supports deferred resolution for var() reference chains of arbitrary depth.\n */\n\nimport { inferSyntaxFromValue } from './index';\n\nconst CUSTOM_PROP_DECL = /^\\s*(--[a-z0-9_-]+)\\s*:\\s*(.+?)\\s*$/i;\nconst SINGLE_VAR_REF = /^var\\((--[a-z0-9_-]+)\\)$/i;\n\nexport class PropertyTypeResolver {\n /** propName → the prop it depends on */\n private pendingDeps = new Map<string, string>();\n /** propName → list of props waiting on it */\n private reverseDeps = new Map<string, string[]>();\n\n /**\n * Scan CSS declarations and auto-register @property for custom properties\n * whose types can be inferred from their values.\n */\n scanDeclarations(\n declarations: string,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n ): void {\n if (!declarations.includes('--')) return;\n\n const parts = declarations.split(/;+/);\n\n for (const part of parts) {\n if (!part.trim()) continue;\n\n const match = CUSTOM_PROP_DECL.exec(part);\n if (!match) continue;\n\n const propName = match[1];\n const value = match[2].trim();\n\n if (isPropertyDefined(propName)) continue;\n\n // Name-based: --*-color properties are always <color> (from #name tokens)\n if (propName.endsWith('-color')) {\n registerProperty(propName, '<color>', 'transparent');\n continue;\n }\n\n // Name-based: --*-line-height accepts numbers, lengths, and percentages\n if (propName.endsWith('-line-height')) {\n registerProperty(propName, '<number> | <length-percentage>', '0');\n continue;\n }\n\n // Name-based: --*-opacity accepts numbers and percentages\n if (propName.endsWith('-opacity')) {\n registerProperty(propName, '<number> | <percentage>', '0');\n continue;\n }\n\n // Single var() reference → record dependency for deferred resolution\n const varMatch = SINGLE_VAR_REF.exec(value);\n if (varMatch) {\n const depName = varMatch[1];\n this.addDependency(propName, depName);\n continue;\n }\n\n // Skip complex expressions (calc, multiple var, etc.)\n if (this.isComplexValue(value)) continue;\n\n const inferred = inferSyntaxFromValue(value);\n if (!inferred) continue;\n\n this.resolve(\n propName,\n inferred.syntax,\n inferred.initialValue,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n\n private addDependency(propName: string, depName: string): void {\n if (propName === depName) return;\n\n this.pendingDeps.set(propName, depName);\n\n let dependents = this.reverseDeps.get(depName);\n if (!dependents) {\n dependents = [];\n this.reverseDeps.set(depName, dependents);\n }\n if (!dependents.includes(propName)) {\n dependents.push(propName);\n }\n }\n\n private resolve(\n propName: string,\n syntax: string,\n initialValue: string,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n resolving?: Set<string>,\n ): void {\n if (!resolving) resolving = new Set();\n if (resolving.has(propName)) return;\n resolving.add(propName);\n\n if (!isPropertyDefined(propName)) {\n registerProperty(propName, syntax, initialValue);\n }\n\n const dependents = this.reverseDeps.get(propName);\n if (dependents) {\n this.reverseDeps.delete(propName);\n\n for (const dependent of dependents) {\n this.pendingDeps.delete(dependent);\n\n if (isPropertyDefined(dependent)) continue;\n\n this.resolve(\n dependent,\n syntax,\n initialValue,\n isPropertyDefined,\n registerProperty,\n resolving,\n );\n }\n }\n }\n\n private isComplexValue(value: string): boolean {\n if (value.includes('calc(')) return true;\n const firstVar = value.indexOf('var(');\n if (firstVar === -1) return false;\n if (value.indexOf('var(', firstVar + 4) !== -1) return true;\n return !SINGLE_VAR_REF.test(value);\n }\n}\n"],"mappings":";;;;;;;;AASA,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AAEvB,IAAa,uBAAb,MAAkC;;CAEhC,8BAAsB,IAAI,KAAqB;;CAE/C,8BAAsB,IAAI,KAAuB;;;;;CAMjD,iBACE,cACA,mBACA,kBAKM;AACN,MAAI,CAAC,aAAa,SAAS,KAAK,CAAE;EAElC,MAAM,QAAQ,aAAa,MAAM,KAAK;AAEtC,OAAK,MAAM,QAAQ,OAAO;AACxB,OAAI,CAAC,KAAK,MAAM,CAAE;GAElB,MAAM,QAAQ,iBAAiB,KAAK,KAAK;AACzC,OAAI,CAAC,MAAO;GAEZ,MAAM,WAAW,MAAM;GACvB,MAAM,QAAQ,MAAM,GAAG,MAAM;AAE7B,OAAI,kBAAkB,SAAS,CAAE;AAGjC,OAAI,SAAS,SAAS,SAAS,EAAE;AAC/B,qBAAiB,UAAU,WAAW,cAAc;AACpD;;AAIF,OAAI,SAAS,SAAS,eAAe,EAAE;AACrC,qBAAiB,UAAU,kCAAkC,IAAI;AACjE;;AAIF,OAAI,SAAS,SAAS,WAAW,EAAE;AACjC,qBAAiB,UAAU,2BAA2B,IAAI;AAC1D;;GAIF,MAAM,WAAW,eAAe,KAAK,MAAM;AAC3C,OAAI,UAAU;IACZ,MAAM,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|
|
2
|
-
|
|
3
|
-
//#region src/ssr/async-storage.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Run a function with a ServerStyleCollector bound to the current
|
|
6
|
-
* async context. All useStyles() calls within `fn` (and any async
|
|
7
|
-
* continuations) will find this collector via getSSRCollector().
|
|
8
|
-
*/
|
|
9
|
-
declare function runWithCollector<T>(collector: ServerStyleCollector, fn: () => T): T;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve the ServerStyleCollector bound to the current async context.
|
|
12
|
-
* Returns null when called outside of runWithCollector() or on the client.
|
|
13
|
-
*/
|
|
14
|
-
declare function getSSRCollector(): ServerStyleCollector | null;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { getSSRCollector, runWithCollector };
|
|
17
|
-
//# sourceMappingURL=async-storage.d.ts.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
//#region src/ssr/async-storage.ts
|
|
3
|
-
/**
|
|
4
|
-
* AsyncLocalStorage integration for SSR collector discovery.
|
|
5
|
-
*
|
|
6
|
-
* Used by Astro middleware and generic framework integrations where
|
|
7
|
-
* the library cannot wrap the React tree with a context provider.
|
|
8
|
-
* The middleware calls runWithCollector() around the render, and
|
|
9
|
-
* useStyles() calls getSSRCollector() to find it.
|
|
10
|
-
*
|
|
11
|
-
* This module imports from 'node:async_hooks' — it must be excluded
|
|
12
|
-
* from client bundles via the build configuration.
|
|
13
|
-
*/
|
|
14
|
-
const tastySSRStorage = new AsyncLocalStorage();
|
|
15
|
-
/**
|
|
16
|
-
* Run a function with a ServerStyleCollector bound to the current
|
|
17
|
-
* async context. All useStyles() calls within `fn` (and any async
|
|
18
|
-
* continuations) will find this collector via getSSRCollector().
|
|
19
|
-
*/
|
|
20
|
-
function runWithCollector(collector, fn) {
|
|
21
|
-
return tastySSRStorage.run(collector, fn);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Retrieve the ServerStyleCollector bound to the current async context.
|
|
25
|
-
* Returns null when called outside of runWithCollector() or on the client.
|
|
26
|
-
*/
|
|
27
|
-
function getSSRCollector() {
|
|
28
|
-
if (typeof tastySSRStorage?.getStore !== "function") return null;
|
|
29
|
-
return tastySSRStorage.getStore() ?? null;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { getSSRCollector, runWithCollector };
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=async-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-storage.js","names":[],"sources":["../../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst tastySSRStorage = new AsyncLocalStorage<ServerStyleCollector>();\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return tastySSRStorage.run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n if (typeof tastySSRStorage?.getStore !== 'function') return null;\n return tastySSRStorage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,kBAAkB,IAAI,mBAAyC;;;;;;AAOrE,SAAgB,iBACd,WACA,IACG;AACH,QAAO,gBAAgB,IAAI,WAAW,GAAG;;;;;;AAO3C,SAAgB,kBAA+C;AAC7D,KAAI,OAAO,iBAAiB,aAAa,WAAY,QAAO;AAC5D,QAAO,gBAAgB,UAAU,IAAI"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { parsePropertyToken } from "../properties/index.js";
|
|
2
|
-
import { PropertyTypeResolver } from "../properties/property-type-resolver.js";
|
|
3
|
-
import { formatPropertyCSS } from "./format-property.js";
|
|
4
|
-
//#region src/ssr/collect-auto-properties.ts
|
|
5
|
-
/**
|
|
6
|
-
* Scan rendered rules for custom property declarations and collect
|
|
7
|
-
* auto-inferred @property rules via the SSR collector.
|
|
8
|
-
*
|
|
9
|
-
* @param rules - Rendered style rules containing CSS declarations
|
|
10
|
-
* @param collector - SSR collector to emit @property CSS into
|
|
11
|
-
* @param styles - Original styles object (used to skip explicit @properties)
|
|
12
|
-
*/
|
|
13
|
-
function collectAutoInferredProperties(rules, collector, styles) {
|
|
14
|
-
const registered = /* @__PURE__ */ new Set();
|
|
15
|
-
if (styles) {
|
|
16
|
-
const localProps = styles["@properties"];
|
|
17
|
-
if (localProps && typeof localProps === "object") for (const token of Object.keys(localProps)) {
|
|
18
|
-
const parsed = parsePropertyToken(token);
|
|
19
|
-
if (parsed.isValid) registered.add(parsed.cssName);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const resolver = new PropertyTypeResolver();
|
|
23
|
-
for (const rule of rules) {
|
|
24
|
-
if (!rule.declarations) continue;
|
|
25
|
-
resolver.scanDeclarations(rule.declarations, (name) => registered.has(name), (name, syntax, initialValue) => {
|
|
26
|
-
registered.add(name);
|
|
27
|
-
const css = formatPropertyCSS(name, {
|
|
28
|
-
syntax,
|
|
29
|
-
inherits: true,
|
|
30
|
-
initialValue
|
|
31
|
-
});
|
|
32
|
-
if (css) collector.collectProperty(`__auto:${name}`, css);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { collectAutoInferredProperties };
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=collect-auto-properties.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-auto-properties.js","names":[],"sources":["../../src/ssr/collect-auto-properties.ts"],"sourcesContent":["/**\n * SSR auto-property inference.\n *\n * Scans rendered CSS declarations for custom properties whose types\n * can be inferred from their values (e.g. `--angle: 30deg` → `<angle>`).\n * Mirrors the client-side auto-inference in StyleInjector.inject().\n */\n\nimport type { StyleResult } from '../pipeline';\nimport { parsePropertyToken } from '../properties';\nimport { PropertyTypeResolver } from '../properties/property-type-resolver';\nimport type { Styles } from '../styles/types';\n\nimport type { ServerStyleCollector } from './collector';\nimport { formatPropertyCSS } from './format-property';\n\n/**\n * Scan rendered rules for custom property declarations and collect\n * auto-inferred @property rules via the SSR collector.\n *\n * @param rules - Rendered style rules containing CSS declarations\n * @param collector - SSR collector to emit @property CSS into\n * @param styles - Original styles object (used to skip explicit @properties)\n */\nexport function collectAutoInferredProperties(\n rules: StyleResult[],\n collector: ServerStyleCollector,\n styles?: Styles,\n): void {\n const registered = new Set<string>();\n\n if (styles) {\n const localProps = styles['@properties'];\n if (localProps && typeof localProps === 'object') {\n for (const token of Object.keys(localProps as Record<string, unknown>)) {\n const parsed = parsePropertyToken(token);\n if (parsed.isValid) {\n registered.add(parsed.cssName);\n }\n }\n }\n }\n\n const resolver = new PropertyTypeResolver();\n\n for (const rule of rules) {\n if (!rule.declarations) continue;\n resolver.scanDeclarations(\n rule.declarations,\n (name) => registered.has(name),\n (name, syntax, initialValue) => {\n registered.add(name);\n const css = formatPropertyCSS(name, {\n syntax,\n inherits: true,\n initialValue,\n });\n if (css) {\n collector.collectProperty(`__auto:${name}`, css);\n }\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,SAAgB,8BACd,OACA,WACA,QACM;CACN,MAAM,6BAAa,IAAI,KAAa;AAEpC,KAAI,QAAQ;EACV,MAAM,aAAa,OAAO;AAC1B,MAAI,cAAc,OAAO,eAAe,SACtC,MAAK,MAAM,SAAS,OAAO,KAAK,WAAsC,EAAE;GACtE,MAAM,SAAS,mBAAmB,MAAM;AACxC,OAAI,OAAO,QACT,YAAW,IAAI,OAAO,QAAQ;;;CAMtC,MAAM,WAAW,IAAI,sBAAsB;AAE3C,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,KAAK,aAAc;AACxB,WAAS,iBACP,KAAK,eACJ,SAAS,WAAW,IAAI,KAAK,GAC7B,MAAM,QAAQ,iBAAiB;AAC9B,cAAW,IAAI,KAAK;GACpB,MAAM,MAAM,kBAAkB,MAAM;IAClC;IACA,UAAU;IACV;IACD,CAAC;AACF,OAAI,IACF,WAAU,gBAAgB,UAAU,QAAQ,IAAI;IAGrD"}
|
package/dist/ssr/collector.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { StyleResult } from "../pipeline/index.js";
|
|
2
|
-
|
|
3
|
-
//#region src/ssr/collector.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Cache state serialized to the client for hydration.
|
|
6
|
-
*/
|
|
7
|
-
interface SSRCacheState {
|
|
8
|
-
/** cacheKey → className map, to pre-populate the client registry */
|
|
9
|
-
entries: Record<string, string>;
|
|
10
|
-
/** Counter value so client allocations don't collide with server ones */
|
|
11
|
-
classCounter: number;
|
|
12
|
-
}
|
|
13
|
-
declare class ServerStyleCollector {
|
|
14
|
-
private chunks;
|
|
15
|
-
private cacheKeyToClassName;
|
|
16
|
-
private classCounter;
|
|
17
|
-
private flushedKeys;
|
|
18
|
-
private propertyRules;
|
|
19
|
-
private flushedPropertyKeys;
|
|
20
|
-
private keyframeRules;
|
|
21
|
-
private flushedKeyframeKeys;
|
|
22
|
-
private globalStyles;
|
|
23
|
-
private flushedGlobalKeys;
|
|
24
|
-
private rawCSS;
|
|
25
|
-
private flushedRawKeys;
|
|
26
|
-
private fontFaceRules;
|
|
27
|
-
private flushedFontFaceKeys;
|
|
28
|
-
private counterStyleRules;
|
|
29
|
-
private flushedCounterStyleKeys;
|
|
30
|
-
private keyframesCounter;
|
|
31
|
-
private counterStyleCounter;
|
|
32
|
-
private internalsCollected;
|
|
33
|
-
/**
|
|
34
|
-
* Collect internal @property rules and :root token defaults.
|
|
35
|
-
* Mirrors markStylesGenerated() from the client-side injector.
|
|
36
|
-
* Called automatically on first chunk collection; idempotent.
|
|
37
|
-
*/
|
|
38
|
-
collectInternals(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Allocate a className for a cache key, server-side.
|
|
41
|
-
* Mirrors StyleInjector.allocateClassName but without DOM access.
|
|
42
|
-
*/
|
|
43
|
-
allocateClassName(cacheKey: string): {
|
|
44
|
-
className: string;
|
|
45
|
-
isNewAllocation: boolean;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Record CSS rules for a chunk.
|
|
49
|
-
* Called by useStyles during server render.
|
|
50
|
-
*/
|
|
51
|
-
collectChunk(cacheKey: string, className: string, rules: StyleResult[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* Record a @property rule. Deduplicated by name.
|
|
54
|
-
*/
|
|
55
|
-
collectProperty(name: string, css: string): void;
|
|
56
|
-
/**
|
|
57
|
-
* Record a @keyframes rule. Deduplicated by name.
|
|
58
|
-
*/
|
|
59
|
-
collectKeyframes(name: string, css: string): void;
|
|
60
|
-
/**
|
|
61
|
-
* Allocate a keyframe name for SSR. Uses provided name or generates one.
|
|
62
|
-
*/
|
|
63
|
-
allocateKeyframeName(providedName?: string): string;
|
|
64
|
-
/**
|
|
65
|
-
* Record a @font-face rule. Deduplicated by key (content hash).
|
|
66
|
-
*/
|
|
67
|
-
collectFontFace(key: string, css: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Record a @counter-style rule. Deduplicated by name.
|
|
70
|
-
*/
|
|
71
|
-
collectCounterStyle(name: string, css: string): void;
|
|
72
|
-
/**
|
|
73
|
-
* Allocate a counter-style name for SSR. Uses provided name or generates one.
|
|
74
|
-
*/
|
|
75
|
-
allocateCounterStyleName(providedName?: string): string;
|
|
76
|
-
/**
|
|
77
|
-
* Record global styles (from useGlobalStyles). Deduplicated by key.
|
|
78
|
-
*/
|
|
79
|
-
collectGlobalStyles(key: string, css: string): void;
|
|
80
|
-
/**
|
|
81
|
-
* Record raw CSS text (from useRawCSS). Deduplicated by key.
|
|
82
|
-
*/
|
|
83
|
-
collectRawCSS(key: string, css: string): void;
|
|
84
|
-
/**
|
|
85
|
-
* Extract all CSS collected so far as a single string.
|
|
86
|
-
* Includes @property and @keyframes rules.
|
|
87
|
-
* Used for non-streaming SSR (renderToString).
|
|
88
|
-
*/
|
|
89
|
-
getCSS(): string;
|
|
90
|
-
/**
|
|
91
|
-
* Flush only newly collected CSS since the last flush.
|
|
92
|
-
* Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).
|
|
93
|
-
*/
|
|
94
|
-
flushCSS(): string;
|
|
95
|
-
/**
|
|
96
|
-
* Serialize the cache state for client hydration.
|
|
97
|
-
*/
|
|
98
|
-
getCacheState(): SSRCacheState;
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
export { SSRCacheState, ServerStyleCollector };
|
|
102
|
-
//# sourceMappingURL=collector.d.ts.map
|
package/dist/ssr/collector.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { fontFaceContentHash, formatFontFaceRule } from "../font-face/index.js";
|
|
2
|
-
import { formatCounterStyleRule } from "../counter-style/index.js";
|
|
3
|
-
import { renderStyles } from "../pipeline/index.js";
|
|
4
|
-
import { getEffectiveProperties, getGlobalConfigTokens, getGlobalCounterStyle, getGlobalFontFace } from "../config.js";
|
|
5
|
-
import { formatPropertyCSS } from "./format-property.js";
|
|
6
|
-
import { formatGlobalRules } from "./format-global-rules.js";
|
|
7
|
-
import { formatRules } from "./format-rules.js";
|
|
8
|
-
//#region src/ssr/collector.ts
|
|
9
|
-
/**
|
|
10
|
-
* ServerStyleCollector — server-safe style collector for SSR.
|
|
11
|
-
*
|
|
12
|
-
* Accumulates CSS rules and cache metadata during server rendering.
|
|
13
|
-
* This is the server-side counterpart to StyleInjector: it allocates
|
|
14
|
-
* sequential class names (t0, t1, …), formats CSS rules into text,
|
|
15
|
-
* and serializes the cache state for client hydration.
|
|
16
|
-
*
|
|
17
|
-
* One instance is created per HTTP request. Concurrent requests
|
|
18
|
-
* each get their own collector (via AsyncLocalStorage or React context).
|
|
19
|
-
*/
|
|
20
|
-
function generateClassName(counter) {
|
|
21
|
-
return `t${counter}`;
|
|
22
|
-
}
|
|
23
|
-
var ServerStyleCollector = class {
|
|
24
|
-
chunks = /* @__PURE__ */ new Map();
|
|
25
|
-
cacheKeyToClassName = /* @__PURE__ */ new Map();
|
|
26
|
-
classCounter = 0;
|
|
27
|
-
flushedKeys = /* @__PURE__ */ new Set();
|
|
28
|
-
propertyRules = /* @__PURE__ */ new Map();
|
|
29
|
-
flushedPropertyKeys = /* @__PURE__ */ new Set();
|
|
30
|
-
keyframeRules = /* @__PURE__ */ new Map();
|
|
31
|
-
flushedKeyframeKeys = /* @__PURE__ */ new Set();
|
|
32
|
-
globalStyles = /* @__PURE__ */ new Map();
|
|
33
|
-
flushedGlobalKeys = /* @__PURE__ */ new Set();
|
|
34
|
-
rawCSS = /* @__PURE__ */ new Map();
|
|
35
|
-
flushedRawKeys = /* @__PURE__ */ new Set();
|
|
36
|
-
fontFaceRules = /* @__PURE__ */ new Map();
|
|
37
|
-
flushedFontFaceKeys = /* @__PURE__ */ new Set();
|
|
38
|
-
counterStyleRules = /* @__PURE__ */ new Map();
|
|
39
|
-
flushedCounterStyleKeys = /* @__PURE__ */ new Set();
|
|
40
|
-
keyframesCounter = 0;
|
|
41
|
-
counterStyleCounter = 0;
|
|
42
|
-
internalsCollected = false;
|
|
43
|
-
/**
|
|
44
|
-
* Collect internal @property rules and :root token defaults.
|
|
45
|
-
* Mirrors markStylesGenerated() from the client-side injector.
|
|
46
|
-
* Called automatically on first chunk collection; idempotent.
|
|
47
|
-
*/
|
|
48
|
-
collectInternals() {
|
|
49
|
-
if (this.internalsCollected) return;
|
|
50
|
-
this.internalsCollected = true;
|
|
51
|
-
for (const [token, definition] of Object.entries(getEffectiveProperties())) {
|
|
52
|
-
const css = formatPropertyCSS(token, definition);
|
|
53
|
-
if (css) this.collectProperty(`__prop:${token}`, css);
|
|
54
|
-
}
|
|
55
|
-
const tokenStyles = getGlobalConfigTokens();
|
|
56
|
-
if (tokenStyles && Object.keys(tokenStyles).length > 0) {
|
|
57
|
-
const tokenRules = renderStyles(tokenStyles, ":root");
|
|
58
|
-
if (tokenRules.length > 0) {
|
|
59
|
-
const css = formatGlobalRules(tokenRules);
|
|
60
|
-
if (css) this.collectGlobalStyles("__global:tokens", css);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const globalFF = getGlobalFontFace();
|
|
64
|
-
if (globalFF) for (const [family, input] of Object.entries(globalFF)) {
|
|
65
|
-
const descriptors = Array.isArray(input) ? input : [input];
|
|
66
|
-
for (const desc of descriptors) {
|
|
67
|
-
const hash = fontFaceContentHash(family, desc);
|
|
68
|
-
const css = formatFontFaceRule(family, desc);
|
|
69
|
-
this.collectFontFace(hash, css);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const globalCS = getGlobalCounterStyle();
|
|
73
|
-
if (globalCS) for (const [name, descriptors] of Object.entries(globalCS)) {
|
|
74
|
-
const css = formatCounterStyleRule(name, descriptors);
|
|
75
|
-
this.collectCounterStyle(name, css);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Allocate a className for a cache key, server-side.
|
|
80
|
-
* Mirrors StyleInjector.allocateClassName but without DOM access.
|
|
81
|
-
*/
|
|
82
|
-
allocateClassName(cacheKey) {
|
|
83
|
-
const existing = this.cacheKeyToClassName.get(cacheKey);
|
|
84
|
-
if (existing) return {
|
|
85
|
-
className: existing,
|
|
86
|
-
isNewAllocation: false
|
|
87
|
-
};
|
|
88
|
-
const className = generateClassName(this.classCounter++);
|
|
89
|
-
this.cacheKeyToClassName.set(cacheKey, className);
|
|
90
|
-
return {
|
|
91
|
-
className,
|
|
92
|
-
isNewAllocation: true
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Record CSS rules for a chunk.
|
|
97
|
-
* Called by useStyles during server render.
|
|
98
|
-
*/
|
|
99
|
-
collectChunk(cacheKey, className, rules) {
|
|
100
|
-
if (this.chunks.has(cacheKey)) return;
|
|
101
|
-
const css = formatRules(rules, className);
|
|
102
|
-
if (css) this.chunks.set(cacheKey, css);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Record a @property rule. Deduplicated by name.
|
|
106
|
-
*/
|
|
107
|
-
collectProperty(name, css) {
|
|
108
|
-
if (!this.propertyRules.has(name)) this.propertyRules.set(name, css);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Record a @keyframes rule. Deduplicated by name.
|
|
112
|
-
*/
|
|
113
|
-
collectKeyframes(name, css) {
|
|
114
|
-
if (!this.keyframeRules.has(name)) this.keyframeRules.set(name, css);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Allocate a keyframe name for SSR. Uses provided name or generates one.
|
|
118
|
-
*/
|
|
119
|
-
allocateKeyframeName(providedName) {
|
|
120
|
-
return providedName ?? `k${this.keyframesCounter++}`;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Record a @font-face rule. Deduplicated by key (content hash).
|
|
124
|
-
*/
|
|
125
|
-
collectFontFace(key, css) {
|
|
126
|
-
if (!this.fontFaceRules.has(key)) this.fontFaceRules.set(key, css);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Record a @counter-style rule. Deduplicated by name.
|
|
130
|
-
*/
|
|
131
|
-
collectCounterStyle(name, css) {
|
|
132
|
-
if (!this.counterStyleRules.has(name)) this.counterStyleRules.set(name, css);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Allocate a counter-style name for SSR. Uses provided name or generates one.
|
|
136
|
-
*/
|
|
137
|
-
allocateCounterStyleName(providedName) {
|
|
138
|
-
return providedName ?? `cs${this.counterStyleCounter++}`;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Record global styles (from useGlobalStyles). Deduplicated by key.
|
|
142
|
-
*/
|
|
143
|
-
collectGlobalStyles(key, css) {
|
|
144
|
-
if (!this.globalStyles.has(key)) this.globalStyles.set(key, css);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Record raw CSS text (from useRawCSS). Deduplicated by key.
|
|
148
|
-
*/
|
|
149
|
-
collectRawCSS(key, css) {
|
|
150
|
-
if (!this.rawCSS.has(key)) this.rawCSS.set(key, css);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Extract all CSS collected so far as a single string.
|
|
154
|
-
* Includes @property and @keyframes rules.
|
|
155
|
-
* Used for non-streaming SSR (renderToString).
|
|
156
|
-
*/
|
|
157
|
-
getCSS() {
|
|
158
|
-
const parts = [];
|
|
159
|
-
for (const css of this.propertyRules.values()) parts.push(css);
|
|
160
|
-
for (const css of this.fontFaceRules.values()) parts.push(css);
|
|
161
|
-
for (const css of this.counterStyleRules.values()) parts.push(css);
|
|
162
|
-
for (const css of this.rawCSS.values()) parts.push(css);
|
|
163
|
-
for (const css of this.globalStyles.values()) parts.push(css);
|
|
164
|
-
for (const css of this.chunks.values()) parts.push(css);
|
|
165
|
-
for (const css of this.keyframeRules.values()) parts.push(css);
|
|
166
|
-
return parts.join("\n");
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Flush only newly collected CSS since the last flush.
|
|
170
|
-
* Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).
|
|
171
|
-
*/
|
|
172
|
-
flushCSS() {
|
|
173
|
-
const parts = [];
|
|
174
|
-
for (const [name, css] of this.propertyRules) if (!this.flushedPropertyKeys.has(name)) {
|
|
175
|
-
parts.push(css);
|
|
176
|
-
this.flushedPropertyKeys.add(name);
|
|
177
|
-
}
|
|
178
|
-
for (const [key, css] of this.fontFaceRules) if (!this.flushedFontFaceKeys.has(key)) {
|
|
179
|
-
parts.push(css);
|
|
180
|
-
this.flushedFontFaceKeys.add(key);
|
|
181
|
-
}
|
|
182
|
-
for (const [key, css] of this.counterStyleRules) if (!this.flushedCounterStyleKeys.has(key)) {
|
|
183
|
-
parts.push(css);
|
|
184
|
-
this.flushedCounterStyleKeys.add(key);
|
|
185
|
-
}
|
|
186
|
-
for (const [key, css] of this.rawCSS) if (!this.flushedRawKeys.has(key)) {
|
|
187
|
-
parts.push(css);
|
|
188
|
-
this.flushedRawKeys.add(key);
|
|
189
|
-
}
|
|
190
|
-
for (const [key, css] of this.globalStyles) if (!this.flushedGlobalKeys.has(key)) {
|
|
191
|
-
parts.push(css);
|
|
192
|
-
this.flushedGlobalKeys.add(key);
|
|
193
|
-
}
|
|
194
|
-
for (const [key, css] of this.chunks) if (!this.flushedKeys.has(key)) {
|
|
195
|
-
parts.push(css);
|
|
196
|
-
this.flushedKeys.add(key);
|
|
197
|
-
}
|
|
198
|
-
for (const [name, css] of this.keyframeRules) if (!this.flushedKeyframeKeys.has(name)) {
|
|
199
|
-
parts.push(css);
|
|
200
|
-
this.flushedKeyframeKeys.add(name);
|
|
201
|
-
}
|
|
202
|
-
return parts.join("\n");
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Serialize the cache state for client hydration.
|
|
206
|
-
*/
|
|
207
|
-
getCacheState() {
|
|
208
|
-
const entries = {};
|
|
209
|
-
for (const [cacheKey, className] of this.cacheKeyToClassName) entries[cacheKey] = className;
|
|
210
|
-
return {
|
|
211
|
-
entries,
|
|
212
|
-
classCounter: this.classCounter
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
//#endregion
|
|
217
|
-
export { ServerStyleCollector };
|
|
218
|
-
|
|
219
|
-
//# sourceMappingURL=collector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collector.js","names":[],"sources":["../../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * sequential class names (t0, t1, …), formats CSS rules into text,\n * and serializes the cache state for client hydration.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\n/**\n * Cache state serialized to the client for hydration.\n */\nexport interface SSRCacheState {\n /** cacheKey → className map, to pre-populate the client registry */\n entries: Record<string, string>;\n /** Counter value so client allocations don't collide with server ones */\n classCounter: number;\n}\n\nfunction generateClassName(counter: number): string {\n return `t${counter}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private classCounter = 0;\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n // Inject configured tokens as :root CSS custom properties\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n // Inject global @font-face rules (mirrors markStylesGenerated)\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n // Inject global @counter-style rules (mirrors markStylesGenerated)\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = generateClassName(this.classCounter++);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return providedName ?? `k${this.keyframesCounter++}`;\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return providedName ?? `cs${this.counterStyleCounter++}`;\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Serialize the cache state for client hydration.\n */\n getCacheState(): SSRCacheState {\n const entries: Record<string, string> = {};\n for (const [cacheKey, className] of this.cacheKeyToClassName) {\n entries[cacheKey] = className;\n }\n return { entries, classCounter: this.classCounter };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,SAAS,kBAAkB,SAAyB;AAClD,QAAO,IAAI;;AAGb,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,eAAuB;CACvB,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;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,QAAQ,KAAK,aAC5B,KAAI,CAAC,KAAK,kBAAkB,IAAI,IAAI,EAAE;AACpC,SAAM,KAAK,IAAI;AACf,QAAK,kBAAkB,IAAI,IAAI;;AAInC,OAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,OAC5B,KAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;AAC9B,SAAM,KAAK,IAAI;AACf,QAAK,YAAY,IAAI,IAAI;;AAI7B,OAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,cAC7B,KAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;AACvC,SAAM,KAAK,IAAI;AACf,QAAK,oBAAoB,IAAI,KAAK;;AAItC,SAAO,MAAM,KAAK,KAAK;;;;;CAMzB,gBAA+B;EAC7B,MAAM,UAAkC,EAAE;AAC1C,OAAK,MAAM,CAAC,UAAU,cAAc,KAAK,oBACvC,SAAQ,YAAY;AAEtB,SAAO;GAAE;GAAS,cAAc,KAAK;GAAc"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/ssr/format-global-rules.ts
|
|
2
|
-
/**
|
|
3
|
-
* Format an array of global StyleResult rules into a CSS text string.
|
|
4
|
-
*
|
|
5
|
-
* Rules already have their full selectors applied by renderStyles().
|
|
6
|
-
* Handles rootPrefix prepending and at-rule wrapping.
|
|
7
|
-
*/
|
|
8
|
-
function formatGlobalRules(rules) {
|
|
9
|
-
if (rules.length === 0) return "";
|
|
10
|
-
const cssRules = [];
|
|
11
|
-
for (const rule of rules) {
|
|
12
|
-
const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
|
|
13
|
-
let fullRule = baseRule;
|
|
14
|
-
if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
|
|
15
|
-
cssRules.push(fullRule);
|
|
16
|
-
}
|
|
17
|
-
return cssRules.join("\n");
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { formatGlobalRules };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=format-global-rules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-global-rules.js","names":[],"sources":["../../src/ssr/format-global-rules.ts"],"sourcesContent":["/**\n * Format global CSS rules for SSR output.\n *\n * Unlike formatRules() which applies className-based specificity doubling,\n * this function formats rules that already have their full selectors\n * (from renderStyles called with a selector string).\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Format an array of global StyleResult rules into a CSS text string.\n *\n * Rules already have their full selectors applied by renderStyles().\n * Handles rootPrefix prepending and at-rule wrapping.\n */\nexport function formatGlobalRules(rules: StyleResult[]): string {\n if (rules.length === 0) return '';\n\n const cssRules: string[] = [];\n\n for (const rule of rules) {\n const selector = rule.rootPrefix\n ? `${rule.rootPrefix} ${rule.selector}`\n : rule.selector;\n\n const baseRule = `${selector} { ${rule.declarations} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,kBAAkB,OAA8B;AAC9D,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,MAAM,WAAqB,EAAE;AAE7B,MAAK,MAAM,QAAQ,OAAO;EAKxB,MAAM,WAAW,GAJA,KAAK,aAClB,GAAG,KAAK,WAAW,GAAG,KAAK,aAC3B,KAAK,SAEoB,KAAK,KAAK,aAAa;EAEpD,IAAI,WAAW;AACf,MAAI,KAAK,WAAW,KAAK,QAAQ,SAAS,EACxC,YAAW,KAAK,QAAQ,QACrB,KAAK,WAAW,GAAG,OAAO,KAAK,IAAI,KACpC,SACD;AAGH,WAAS,KAAK,SAAS;;AAGzB,QAAO,SAAS,KAAK,KAAK"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createStyle } from "../styles/createStyle.js";
|
|
2
|
-
import { STYLE_HANDLER_MAP } from "../styles/index.js";
|
|
3
|
-
//#region src/ssr/format-keyframes.ts
|
|
4
|
-
/**
|
|
5
|
-
* Convert keyframes steps to a CSS string.
|
|
6
|
-
* Replicates SheetManager.stepsToCSS() without the class instance.
|
|
7
|
-
*/
|
|
8
|
-
function stepsToCSS(steps) {
|
|
9
|
-
const rules = [];
|
|
10
|
-
for (const [key, value] of Object.entries(steps)) {
|
|
11
|
-
if (typeof value === "string") {
|
|
12
|
-
rules.push(`${key} { ${value.trim()} }`);
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const styleMap = value || {};
|
|
16
|
-
const styleNames = Object.keys(styleMap).sort();
|
|
17
|
-
const handlerQueue = [];
|
|
18
|
-
const seenHandlers = /* @__PURE__ */ new Set();
|
|
19
|
-
styleNames.forEach((styleName) => {
|
|
20
|
-
let handlers = STYLE_HANDLER_MAP[styleName];
|
|
21
|
-
if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
|
|
22
|
-
handlers.forEach((handler) => {
|
|
23
|
-
if (!seenHandlers.has(handler)) {
|
|
24
|
-
seenHandlers.add(handler);
|
|
25
|
-
handlerQueue.push(handler);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
const declarationPairs = [];
|
|
30
|
-
handlerQueue.forEach((handler) => {
|
|
31
|
-
const result = handler(handler.__lookupStyles.reduce((acc, name) => {
|
|
32
|
-
const v = styleMap[name];
|
|
33
|
-
if (v !== void 0) acc[name] = v;
|
|
34
|
-
return acc;
|
|
35
|
-
}, {}));
|
|
36
|
-
if (!result) return;
|
|
37
|
-
(Array.isArray(result) ? result : [result]).forEach((cssMap) => {
|
|
38
|
-
if (!cssMap || typeof cssMap !== "object") return;
|
|
39
|
-
const { $: _$, ...props } = cssMap;
|
|
40
|
-
Object.entries(props).forEach(([prop, val]) => {
|
|
41
|
-
if (val == null || val === "") return;
|
|
42
|
-
if (Array.isArray(val)) val.forEach((v) => {
|
|
43
|
-
if (v != null && v !== "") declarationPairs.push({
|
|
44
|
-
prop,
|
|
45
|
-
value: String(v)
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
else declarationPairs.push({
|
|
49
|
-
prop,
|
|
50
|
-
value: String(val)
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
|
|
56
|
-
rules.push(`${key} { ${declarations.trim()} }`);
|
|
57
|
-
}
|
|
58
|
-
return rules.join(" ");
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Format a @keyframes rule as a CSS string.
|
|
62
|
-
*/
|
|
63
|
-
function formatKeyframesCSS(name, steps) {
|
|
64
|
-
return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { formatKeyframesCSS };
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=format-keyframes.js.map
|