@tenphi/tasty 0.0.0-snapshot.d5c5a10 → 0.0.0-snapshot.d656d18
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 +197 -141
- package/dist/babel-_RVkw0iE.d.ts +83 -0
- package/dist/{ssr/async-storage.js → chunks/async-storage-DKK-wTD4.js} +17 -8
- package/dist/chunks/async-storage-DKK-wTD4.js.map +1 -0
- package/dist/chunks/collector-DBGcmUEq.js +326 -0
- package/dist/chunks/collector-DBGcmUEq.js.map +1 -0
- package/dist/chunks/css-resources-Cyl_axbI.js +149 -0
- package/dist/chunks/css-resources-Cyl_axbI.js.map +1 -0
- package/dist/{zero/extractor.js → chunks/css-writer-PFzrSPeu.js} +149 -26
- package/dist/chunks/css-writer-PFzrSPeu.js.map +1 -0
- package/dist/{debug.js → chunks/debug-BUwqo6vC.js} +193 -65
- package/dist/chunks/debug-BUwqo6vC.js.map +1 -0
- package/dist/chunks/dsl-CXvoaLnj.js +2097 -0
- package/dist/chunks/dsl-CXvoaLnj.js.map +1 -0
- package/dist/chunks/hydrate-6YoHZP6A.js +37 -0
- package/dist/chunks/hydrate-6YoHZP6A.js.map +1 -0
- package/dist/chunks/react-runtime-B3CmvDEQ.js +1525 -0
- package/dist/chunks/react-runtime-B3CmvDEQ.js.map +1 -0
- package/dist/chunks/runtime-engine-Y00VWjrS.js +4719 -0
- package/dist/chunks/runtime-engine-Y00VWjrS.js.map +1 -0
- package/dist/{utils/merge-styles.js → chunks/shared-utils-OIg0N_dp.js} +43 -6
- package/dist/chunks/shared-utils-OIg0N_dp.js.map +1 -0
- package/dist/chunks/style-engine-CqSmIlud.js +7196 -0
- package/dist/chunks/style-engine-CqSmIlud.js.map +1 -0
- package/dist/collector-CVdVIy7s.d.ts +163 -0
- package/dist/config-BI0y21JV.d.ts +1367 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +7 -27
- package/dist/index-BzAC3p06.d.ts +1616 -0
- package/dist/index-CrT0bsiI.d.ts +1980 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +8 -36
- package/dist/{utils/merge-styles.d.ts → merge-styles-BFktNP8J.d.ts} +3 -3
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +19 -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 +18 -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 +19 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +117 -11
- package/dist/ssr/astro.js +268 -33
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +37 -5
- package/dist/ssr/index.js +7 -9
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +66 -0
- package/dist/ssr/next-config.js +115 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +14 -7
- package/dist/ssr/next.js +39 -20
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -4
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/zero/babel.d.ts +2 -167
- package/dist/zero/babel.js +160 -57
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +81 -3
- package/dist/zero/index.js +2 -4
- package/dist/zero/next.d.ts +13 -1
- package/dist/zero/next.js +6 -5
- 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 -180
- package/docs/getting-started.md +62 -41
- package/docs/injector.md +157 -51
- package/docs/methodology.md +116 -35
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +741 -0
- package/docs/plugins.md +353 -0
- package/docs/react-api.md +681 -0
- package/docs/runtime-benchmarks.md +351 -0
- package/docs/ssr.md +356 -130
- package/docs/styles.md +127 -26
- package/docs/tasty-static.md +219 -70
- package/package.json +108 -23
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -8
- package/dist/chunks/cacheKey.js +0 -78
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -259
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/renderChunk.js +0 -60
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/config.d.ts +0 -366
- package/dist/config.js +0 -504
- 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/resolve-ssr-collector.js +0 -15
- package/dist/hooks/resolve-ssr-collector.js.map +0 -1
- package/dist/hooks/useCounterStyle.d.ts +0 -50
- package/dist/hooks/useCounterStyle.js +0 -47
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -43
- package/dist/hooks/useFontFace.js +0 -71
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -30
- package/dist/hooks/useGlobalStyles.js +0 -79
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -56
- package/dist/hooks/useKeyframes.js +0 -65
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -79
- package/dist/hooks/useProperty.js +0 -110
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -53
- package/dist/hooks/useRawCSS.js +0 -36
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -45
- package/dist/hooks/useStyles.js +0 -270
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -183
- package/dist/injector/index.js +0 -180
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -166
- package/dist/injector/injector.js +0 -465
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -136
- package/dist/injector/sheet-manager.js +0 -731
- 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 -320
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -33
- 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 -116
- 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 -231
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -53
- package/dist/pipeline/index.js +0 -699
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1105
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -447
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -516
- 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/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -98
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -76
- package/dist/properties/index.js +0 -223
- 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 -91
- 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.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -40
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.d.ts +0 -102
- package/dist/ssr/collector.js +0 -227
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.d.ts +0 -8
- package/dist/ssr/context.js +0 -14
- package/dist/ssr/context.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 -70
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -50
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -70
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -22
- package/dist/ssr/hydrate.js +0 -50
- 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 -171
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -31
- 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/align.d.ts +0 -15
- package/dist/styles/align.js +0 -14
- package/dist/styles/align.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -114
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -27
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/createStyle.js +0 -80
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -97
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/display.d.ts +0 -37
- package/dist/styles/display.js +0 -67
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -58
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -52
- 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 -37
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -20
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -2
- package/dist/styles/index.js +0 -9
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -52
- package/dist/styles/inset.js +0 -150
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/justify.d.ts +0 -15
- package/dist/styles/justify.js +0 -14
- package/dist/styles/justify.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -98
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -104
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -65
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -104
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -238
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -47
- package/dist/styles/preset.js +0 -112
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -14
- package/dist/styles/radius.js +0 -51
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -48
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -24
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -158
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -545
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -20
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -119
- package/dist/tasty.js +0 -232
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -22
- 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 -229
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -11
- 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 -8
- package/dist/utils/mod-attrs.js +0 -21
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -21
- package/dist/utils/process-tokens.js +0 -91
- 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 -147
- 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 -100
- package/dist/utils/styles.js +0 -222
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -47
- package/dist/utils/typography.js +0 -43
- 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 -74
- 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/docs/runtime.md +0 -485
package/dist/zero/babel.d.ts
CHANGED
|
@@ -1,167 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { StyleHandlerDefinition } from "../utils/styles.js";
|
|
4
|
-
import { ConfigTokens, RecipeStyles } from "../styles/types.js";
|
|
5
|
-
import { TastyPlugin } from "../plugins/types.js";
|
|
6
|
-
import * as _babel_core0 from "@babel/core";
|
|
7
|
-
import { PluginPass } from "@babel/core";
|
|
8
|
-
|
|
9
|
-
//#region src/zero/babel.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Build-time configuration for zero-runtime mode.
|
|
12
|
-
* Subset of TastyConfig that applies at build time.
|
|
13
|
-
*/
|
|
14
|
-
interface TastyZeroConfig {
|
|
15
|
-
/**
|
|
16
|
-
* Global predefined states for advanced state mapping.
|
|
17
|
-
* Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }
|
|
18
|
-
*/
|
|
19
|
-
states?: Record<string, string>;
|
|
20
|
-
/**
|
|
21
|
-
* Enable development mode features: source comments in generated CSS.
|
|
22
|
-
* Default: false
|
|
23
|
-
*/
|
|
24
|
-
devMode?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Parser LRU cache size (default: 1000).
|
|
27
|
-
* Larger values improve performance for builds with many unique style values.
|
|
28
|
-
*/
|
|
29
|
-
parserCacheSize?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Custom units for the style parser (merged with built-in units).
|
|
32
|
-
* Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
|
|
33
|
-
* @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
|
|
34
|
-
*/
|
|
35
|
-
units?: Record<string, string | UnitHandler>;
|
|
36
|
-
/**
|
|
37
|
-
* Custom functions for the style parser (merged with existing).
|
|
38
|
-
* Functions process parsed style groups and return CSS values.
|
|
39
|
-
* @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
|
|
40
|
-
*/
|
|
41
|
-
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
42
|
-
/**
|
|
43
|
-
* Plugins that extend tasty with custom functions, units, states, and handlers.
|
|
44
|
-
* Plugins are processed in order, with later plugins overriding earlier ones.
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* import { okhslPlugin } from '@tenphi/tasty';
|
|
48
|
-
*
|
|
49
|
-
* // babel.config.js
|
|
50
|
-
* module.exports = {
|
|
51
|
-
* plugins: [
|
|
52
|
-
* ['@tenphi/tasty/babel-plugin', {
|
|
53
|
-
* config: { plugins: [okhslPlugin()] }
|
|
54
|
-
* }]
|
|
55
|
-
* ]
|
|
56
|
-
* };
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
plugins?: TastyPlugin[];
|
|
60
|
-
/**
|
|
61
|
-
* Global keyframes definitions for static extraction.
|
|
62
|
-
* Keys are animation names, values are keyframes step definitions.
|
|
63
|
-
* @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }
|
|
64
|
-
*/
|
|
65
|
-
keyframes?: Record<string, KeyframesSteps>;
|
|
66
|
-
/**
|
|
67
|
-
* Global @font-face definitions for static extraction.
|
|
68
|
-
* Keys are font-family names, values are descriptors or arrays of descriptors.
|
|
69
|
-
*/
|
|
70
|
-
fontFace?: Record<string, FontFaceInput>;
|
|
71
|
-
/**
|
|
72
|
-
* Global @counter-style definitions for static extraction.
|
|
73
|
-
* Keys are counter-style names, values are descriptor objects.
|
|
74
|
-
*/
|
|
75
|
-
counterStyle?: Record<string, CounterStyleDescriptors>;
|
|
76
|
-
/**
|
|
77
|
-
* Custom style handlers that transform style properties into CSS declarations.
|
|
78
|
-
* Handlers replace built-in handlers for the same style name.
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* handlers: {
|
|
82
|
-
* fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
|
|
83
|
-
* elevation: ({ elevation }) => ({
|
|
84
|
-
* 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,
|
|
85
|
-
* }),
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
handlers?: Record<string, StyleHandlerDefinition>;
|
|
90
|
-
/**
|
|
91
|
-
* Design tokens injected as CSS custom properties on `:root`.
|
|
92
|
-
* Values are parsed through the Tasty DSL. Supports state maps.
|
|
93
|
-
* @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
|
|
94
|
-
*/
|
|
95
|
-
tokens?: ConfigTokens;
|
|
96
|
-
/**
|
|
97
|
-
* Predefined tokens replaced during style parsing (parse-time substitution).
|
|
98
|
-
* Use `$name` for custom properties and `#name` for color tokens.
|
|
99
|
-
* @example { $spacing: '2x', '#accent': '#purple' }
|
|
100
|
-
*/
|
|
101
|
-
replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
|
|
102
|
-
/**
|
|
103
|
-
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
104
|
-
* Recipe values are flat tasty styles (no sub-element keys).
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* recipes: {
|
|
108
|
-
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
109
|
-
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
recipes?: Record<string, RecipeStyles>;
|
|
114
|
-
/**
|
|
115
|
-
* Automatically infer and register CSS @property declarations from values.
|
|
116
|
-
* @default true
|
|
117
|
-
*/
|
|
118
|
-
autoPropertyTypes?: boolean;
|
|
119
|
-
}
|
|
120
|
-
interface TastyZeroBabelOptions {
|
|
121
|
-
/** Output path for generated CSS (default: 'tasty.css') */
|
|
122
|
-
output?: string;
|
|
123
|
-
/**
|
|
124
|
-
* Tasty configuration for build-time processing.
|
|
125
|
-
* Can be a static object or a factory function that returns fresh config.
|
|
126
|
-
* A factory is called on each plugin invocation, enabling hot reload
|
|
127
|
-
* of config values that depend on external files (e.g. theme tokens).
|
|
128
|
-
*/
|
|
129
|
-
config?: TastyZeroConfig | (() => TastyZeroConfig);
|
|
130
|
-
/**
|
|
131
|
-
* Absolute path to a TypeScript/JavaScript module that default-exports
|
|
132
|
-
* a `TastyZeroConfig` object. The module is loaded via jiti on each
|
|
133
|
-
* plugin invocation, enabling hot reload when the file changes.
|
|
134
|
-
*
|
|
135
|
-
* This option is JSON-serializable and is the primary way Turbopack
|
|
136
|
-
* passes config to the Babel plugin (since Turbopack loader options
|
|
137
|
-
* must be plain primitives/objects/arrays).
|
|
138
|
-
*
|
|
139
|
-
* When both `config` and `configFile` are set, `config` takes precedence.
|
|
140
|
-
*
|
|
141
|
-
* @example '/absolute/path/to/tasty-zero.config.ts'
|
|
142
|
-
*/
|
|
143
|
-
configFile?: string;
|
|
144
|
-
/**
|
|
145
|
-
* Absolute file paths whose content affects the generated CSS.
|
|
146
|
-
* When any of these files change, babel-loader invalidates its cache
|
|
147
|
-
* and re-runs the plugin with fresh config values.
|
|
148
|
-
*
|
|
149
|
-
* Typically includes theme files that define Glaze palettes or token values.
|
|
150
|
-
* Paths must be absolute (resolved by the Next.js wrapper).
|
|
151
|
-
*/
|
|
152
|
-
configDeps?: string[];
|
|
153
|
-
/**
|
|
154
|
-
* Automatically replace `@tenphi/tasty/static` imports with an import
|
|
155
|
-
* of the generated CSS file. This eliminates the need for users to
|
|
156
|
-
* manually import the CSS in their app entry point.
|
|
157
|
-
*
|
|
158
|
-
* @default true
|
|
159
|
-
*/
|
|
160
|
-
injectImport?: boolean;
|
|
161
|
-
}
|
|
162
|
-
/** Clear the shared CSSWriter cache. Exposed for testing. */
|
|
163
|
-
declare function clearWriterCache(): void;
|
|
164
|
-
declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
|
|
165
|
-
//#endregion
|
|
166
|
-
export { TastyZeroBabelOptions, TastyZeroConfig, clearWriterCache, _default as default };
|
|
167
|
-
//# sourceMappingURL=babel.d.ts.map
|
|
1
|
+
import { n as _default, r as TastyZeroConfig, t as TastyZeroBabelOptions } from "../babel-_RVkw0iE.js";
|
|
2
|
+
export { TastyZeroBabelOptions, type TastyZeroConfig, _default as default };
|
package/dist/zero/babel.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { configure,
|
|
3
|
-
import {
|
|
4
|
-
import { resolveRecipes } from "../utils/resolve-recipes.js";
|
|
5
|
-
import { extractCounterStyleFromStyles, extractFontFaceFromStyles, extractKeyframesFromStyles, extractPropertiesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
|
|
6
|
-
import { CSSWriter } from "./css-writer.js";
|
|
1
|
+
import { t as mergeStyles } from "../chunks/shared-utils-OIg0N_dp.js";
|
|
2
|
+
import { G as getGlobalConfigTokens, H as configure, J as getGlobalFunctions, Q as getGlobalStyles, a as resolveRecipes, at as resetConfig } from "../chunks/runtime-engine-Y00VWjrS.js";
|
|
3
|
+
import { a as extractFunctionsFromStyles, c as extractStylesForSelector, i as extractFontFaceFromStyles, l as extractStylesWithChunks, o as extractKeyframesFromStyles, r as extractCounterStyleFromStyles, s as extractPropertiesFromStyles, t as CSSWriter, u as setExtractorNamePrefix } from "../chunks/css-writer-PFzrSPeu.js";
|
|
7
4
|
import * as fs from "fs";
|
|
8
5
|
import * as path from "path";
|
|
9
6
|
import { declare } from "@babel/helper-plugin-utils";
|
|
10
7
|
import * as t from "@babel/types";
|
|
11
8
|
import { createJiti } from "jiti";
|
|
12
|
-
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/zero/writer-cache.ts
|
|
16
|
+
const writerCache = /* @__PURE__ */ new Map();
|
|
17
|
+
//#endregion
|
|
13
18
|
//#region src/zero/babel.ts
|
|
14
19
|
/**
|
|
15
20
|
* Babel plugin for zero-runtime tasty static site generation.
|
|
@@ -51,17 +56,13 @@ function clearRequireCacheTree(filePath) {
|
|
|
51
56
|
}
|
|
52
57
|
delete __require.cache[resolved];
|
|
53
58
|
}
|
|
54
|
-
const writerCache = /* @__PURE__ */ new Map();
|
|
55
|
-
/** Clear the shared CSSWriter cache. Exposed for testing. */
|
|
56
|
-
function clearWriterCache() {
|
|
57
|
-
writerCache.clear();
|
|
58
|
-
}
|
|
59
59
|
var babel_default = declare((api, options) => {
|
|
60
60
|
api.assertVersion(7);
|
|
61
|
+
const mode = options.mode ?? "file";
|
|
61
62
|
const outputPath = options.output || "tasty.css";
|
|
62
63
|
const resolvedOutputPath = path.resolve(outputPath);
|
|
63
64
|
const injectImport = options.injectImport ?? true;
|
|
64
|
-
if (injectImport) {
|
|
65
|
+
if (mode === "file" && injectImport) {
|
|
65
66
|
const dir = path.dirname(resolvedOutputPath);
|
|
66
67
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
67
68
|
if (!fs.existsSync(resolvedOutputPath)) fs.writeFileSync(resolvedOutputPath, "/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\n");
|
|
@@ -80,22 +81,33 @@ var babel_default = declare((api, options) => {
|
|
|
80
81
|
const configOption = options.config;
|
|
81
82
|
let resolvedConfig;
|
|
82
83
|
if (configOption) resolvedConfig = typeof configOption === "function" ? configOption() : configOption;
|
|
83
|
-
else if (options.configFile)
|
|
84
|
-
|
|
84
|
+
else if (options.configFile) {
|
|
85
|
+
const loaded = createJiti(path.dirname(options.configFile), { moduleCache: false })(options.configFile);
|
|
86
|
+
resolvedConfig = loaded && typeof loaded === "object" && "default" in loaded ? loaded.default : loaded;
|
|
87
|
+
} else resolvedConfig = {};
|
|
85
88
|
const devMode = resolvedConfig.devMode ?? false;
|
|
86
89
|
if (cached) resetConfig();
|
|
87
|
-
|
|
90
|
+
const finalConfig = {
|
|
91
|
+
namePrefix: "ts",
|
|
92
|
+
...resolvedConfig
|
|
93
|
+
};
|
|
94
|
+
configure(finalConfig);
|
|
95
|
+
setExtractorNamePrefix(finalConfig.namePrefix ?? "ts");
|
|
88
96
|
const newWriter = new CSSWriter(outputPath, { devMode });
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
if (mode !== "inject") {
|
|
98
|
+
const tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
|
|
99
|
+
if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
|
|
100
|
+
const globalStyles = getGlobalStyles();
|
|
101
|
+
if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
|
|
102
|
+
const css = extractCSSFromStyles(selector, styles);
|
|
103
|
+
if (css) newWriter.add(`global:${selector}`, css);
|
|
104
|
+
}
|
|
93
105
|
}
|
|
94
106
|
writerCache.set(resolvedOutputPath, {
|
|
95
107
|
writer: newWriter,
|
|
96
108
|
configKey,
|
|
97
109
|
registry: {},
|
|
98
|
-
config:
|
|
110
|
+
config: finalConfig
|
|
99
111
|
});
|
|
100
112
|
}
|
|
101
113
|
const entry = writerCache.get(resolvedOutputPath);
|
|
@@ -103,6 +115,21 @@ var babel_default = declare((api, options) => {
|
|
|
103
115
|
const globalRegistry = entry.registry;
|
|
104
116
|
const config = entry.config;
|
|
105
117
|
const devMode = config.devMode ?? false;
|
|
118
|
+
setExtractorNamePrefix(config.namePrefix ?? "ts");
|
|
119
|
+
let tokenCSS;
|
|
120
|
+
let globalStylesCSS;
|
|
121
|
+
if (mode === "inject") {
|
|
122
|
+
tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
|
|
123
|
+
const gs = getGlobalStyles();
|
|
124
|
+
if (gs) {
|
|
125
|
+
globalStylesCSS = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const [selector, styles] of Object.entries(gs)) {
|
|
127
|
+
const css = extractCSSFromStyles(selector, styles);
|
|
128
|
+
if (css) globalStylesCSS.set(selector, css);
|
|
129
|
+
}
|
|
130
|
+
if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
106
133
|
return {
|
|
107
134
|
name: "tasty-zero",
|
|
108
135
|
pre() {
|
|
@@ -113,7 +140,8 @@ var babel_default = declare((api, options) => {
|
|
|
113
140
|
visitor: {
|
|
114
141
|
ImportDeclaration(nodePath, state) {
|
|
115
142
|
const source = nodePath.node.source.value;
|
|
116
|
-
if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (
|
|
143
|
+
if (source === "@tenphi/tasty/static" || source.endsWith("/tasty/static")) if (mode === "inject") nodePath.replaceWith(t.importDeclaration([t.importSpecifier(t.identifier("_$i"), t.identifier("injectCSS"))], t.stringLiteral("@tenphi/tasty/static/inject")));
|
|
144
|
+
else if (injectImport) {
|
|
117
145
|
let importPath = resolvedOutputPath;
|
|
118
146
|
if (state.filename) {
|
|
119
147
|
const sourceDir = path.dirname(state.filename);
|
|
@@ -130,9 +158,9 @@ var babel_default = declare((api, options) => {
|
|
|
130
158
|
const args = path.node.arguments;
|
|
131
159
|
if (args.length === 0) throw path.buildCodeFrameError("tastyStatic() requires at least one argument");
|
|
132
160
|
const firstArg = args[0];
|
|
133
|
-
if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.
|
|
134
|
-
else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes, config.
|
|
135
|
-
else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, config.keyframes, config.autoPropertyTypes, config.
|
|
161
|
+
if (t.isStringLiteral(firstArg)) handleSelectorMode(path, args, cssWriter, mode, state.sourceFile, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
|
|
162
|
+
else if (t.isObjectExpression(firstArg)) handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
|
|
163
|
+
else if (t.isIdentifier(firstArg)) handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, config.keyframes, config.autoPropertyTypes, config.fontFaces, config.counterStyles, getGlobalFunctions() ?? void 0);
|
|
136
164
|
else throw path.buildCodeFrameError("tastyStatic() first argument must be an object (styles), identifier (base StaticStyle), or string (selector)");
|
|
137
165
|
},
|
|
138
166
|
VariableDeclarator(path, state) {
|
|
@@ -156,6 +184,24 @@ var babel_default = declare((api, options) => {
|
|
|
156
184
|
}
|
|
157
185
|
},
|
|
158
186
|
post() {
|
|
187
|
+
if (mode === "inject") {
|
|
188
|
+
if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
|
|
189
|
+
const program = this.file.ast.program;
|
|
190
|
+
let insertIndex = 0;
|
|
191
|
+
for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
|
|
192
|
+
if (tokenCSS) {
|
|
193
|
+
const injectCall = createInjectCallAST(":root", tokenCSS);
|
|
194
|
+
program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
|
|
195
|
+
insertIndex++;
|
|
196
|
+
}
|
|
197
|
+
if (globalStylesCSS) for (const [selector, css] of globalStylesCSS) {
|
|
198
|
+
const injectCall = createInjectCallAST(selector, css);
|
|
199
|
+
program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
|
|
200
|
+
insertIndex++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
159
205
|
if (this._fileAddedCSS && cssWriter.size > 0) cssWriter.write();
|
|
160
206
|
}
|
|
161
207
|
};
|
|
@@ -185,30 +231,31 @@ function extractClassNameFromStaticStyleObject(node) {
|
|
|
185
231
|
/**
|
|
186
232
|
* Handle tastyStatic(styles) - returns StaticStyle object
|
|
187
233
|
*/
|
|
188
|
-
function handleStylesMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
234
|
+
function handleStylesMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle, globalFunction) {
|
|
189
235
|
const stylesArg = args[0];
|
|
190
236
|
if (!t.isObjectExpression(stylesArg)) throw path.buildCodeFrameError("tastyStatic(styles) argument must be a static object literal");
|
|
191
237
|
const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
|
|
192
238
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
193
|
-
for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
|
|
194
239
|
const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
240
|
+
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
241
|
+
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
242
|
+
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
198
243
|
const chunks = extractStylesWithChunks(styles);
|
|
199
|
-
for (const chunk of chunks) {
|
|
200
|
-
const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
|
|
201
|
-
cssWriter.add(chunk.className, css, state.sourceFile);
|
|
202
|
-
}
|
|
203
244
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
204
245
|
const staticStyleObject = createStaticStyleAST(className, styles);
|
|
205
|
-
|
|
246
|
+
if (mode === "inject") {
|
|
247
|
+
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
|
|
248
|
+
path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
|
|
249
|
+
} else {
|
|
250
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
|
|
251
|
+
path.replaceWith(staticStyleObject);
|
|
252
|
+
}
|
|
206
253
|
registerIfVariableDeclaration(path, className, styles, state, globalRegistry);
|
|
207
254
|
}
|
|
208
255
|
/**
|
|
209
256
|
* Handle tastyStatic(base, styles) - extends base with additional styles
|
|
210
257
|
*/
|
|
211
|
-
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
258
|
+
function handleExtensionMode(path, args, cssWriter, state, globalRegistry, mode, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle, globalFunction) {
|
|
212
259
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(base, styles) requires two arguments");
|
|
213
260
|
const baseArg = args[0];
|
|
214
261
|
const stylesArg = args[1];
|
|
@@ -220,25 +267,26 @@ function handleExtensionMode(path, args, cssWriter, state, globalRegistry, globa
|
|
|
220
267
|
const overrideStyles = evaluateObjectExpression(stylesArg, path);
|
|
221
268
|
const mergedStyles = resolveRecipes(mergeStyles(baseEntry.styles, overrideStyles));
|
|
222
269
|
const { keyframes, nameMap } = extractKeyframesFromStyles(mergedStyles, globalKeyframes);
|
|
223
|
-
for (const kf of keyframes) cssWriter.add(kf.css, kf.css, state.sourceFile);
|
|
224
270
|
const properties = extractPropertiesFromStyles(mergedStyles, { autoPropertyTypes });
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
271
|
+
const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);
|
|
272
|
+
const counterStyles = extractCounterStyleFromStyles(mergedStyles, globalCounterStyle);
|
|
273
|
+
const functions = extractFunctionsFromStyles(mergedStyles, globalFunction);
|
|
228
274
|
const chunks = extractStylesWithChunks(mergedStyles);
|
|
229
|
-
for (const chunk of chunks) {
|
|
230
|
-
const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
|
|
231
|
-
cssWriter.add(chunk.className, css, state.sourceFile);
|
|
232
|
-
}
|
|
233
275
|
const className = chunks.length > 0 ? chunks.map((c) => c.className).join(" ") : "";
|
|
234
276
|
const staticStyleObject = createStaticStyleAST(className, mergedStyles);
|
|
235
|
-
|
|
277
|
+
if (mode === "inject") {
|
|
278
|
+
const injectCall = createInjectCallAST(className, collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap));
|
|
279
|
+
path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));
|
|
280
|
+
} else {
|
|
281
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, state.sourceFile);
|
|
282
|
+
path.replaceWith(staticStyleObject);
|
|
283
|
+
}
|
|
236
284
|
registerIfVariableDeclaration(path, className, mergedStyles, state, globalRegistry);
|
|
237
285
|
}
|
|
238
286
|
/**
|
|
239
287
|
* Handle tastyStatic(selector, styles) - removes the call entirely
|
|
240
288
|
*/
|
|
241
|
-
function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle) {
|
|
289
|
+
function handleSelectorMode(path, args, cssWriter, mode, sourceFile, globalKeyframes, autoPropertyTypes, globalFontFace, globalCounterStyle, globalFunction) {
|
|
242
290
|
if (args.length < 2) throw path.buildCodeFrameError("tastyStatic(selector, styles) requires two arguments");
|
|
243
291
|
const selectorArg = args[0];
|
|
244
292
|
const stylesArg = args[1];
|
|
@@ -247,17 +295,72 @@ function handleSelectorMode(path, args, cssWriter, sourceFile, globalKeyframes,
|
|
|
247
295
|
const selector = selectorArg.value;
|
|
248
296
|
const styles = resolveRecipes(evaluateObjectExpression(stylesArg, path));
|
|
249
297
|
const { keyframes, nameMap } = extractKeyframesFromStyles(styles, globalKeyframes);
|
|
250
|
-
for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
|
|
251
298
|
const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
299
|
+
const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);
|
|
300
|
+
const counterStyles = extractCounterStyleFromStyles(styles, globalCounterStyle);
|
|
301
|
+
const functions = extractFunctionsFromStyles(styles, globalFunction);
|
|
255
302
|
const result = extractStylesForSelector(selector, styles);
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
303
|
+
const selectorCSS = nameMap.size > 0 ? replaceAnimationNamesInCSS(result.css, nameMap) : result.css;
|
|
304
|
+
if (mode === "inject") {
|
|
305
|
+
const cssParts = [];
|
|
306
|
+
for (const kf of keyframes) cssParts.push(kf.css);
|
|
307
|
+
for (const prop of properties) cssParts.push(prop.css);
|
|
308
|
+
for (const ff of fontFaces) cssParts.push(ff.css);
|
|
309
|
+
for (const cs of counterStyles) cssParts.push(cs.css);
|
|
310
|
+
for (const fn of functions) cssParts.push(fn.css);
|
|
311
|
+
cssParts.push(selectorCSS);
|
|
312
|
+
const injectCall = createInjectCallAST(selector, cssParts.join("\n"));
|
|
313
|
+
const parent = path.parentPath;
|
|
314
|
+
if (parent && t.isExpressionStatement(parent.node)) parent.replaceWith(t.expressionStatement(injectCall));
|
|
315
|
+
else path.replaceWith(injectCall);
|
|
316
|
+
} else {
|
|
317
|
+
writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, [], nameMap, sourceFile);
|
|
318
|
+
cssWriter.add(selector, selectorCSS, sourceFile);
|
|
319
|
+
const parent = path.parentPath;
|
|
320
|
+
if (parent && t.isExpressionStatement(parent.node)) parent.remove();
|
|
321
|
+
else path.replaceWith(t.identifier("undefined"));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Collect all extracted CSS parts into a single string (for inject mode).
|
|
326
|
+
*/
|
|
327
|
+
function collectAllCSS(keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap) {
|
|
328
|
+
const parts = [];
|
|
329
|
+
for (const kf of keyframes) parts.push(kf.css);
|
|
330
|
+
for (const prop of properties) parts.push(prop.css);
|
|
331
|
+
for (const ff of fontFaces) parts.push(ff.css);
|
|
332
|
+
for (const cs of counterStyles) parts.push(cs.css);
|
|
333
|
+
for (const fn of functions) parts.push(fn.css);
|
|
334
|
+
for (const chunk of chunks) parts.push(nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css);
|
|
335
|
+
return parts.join("\n");
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Write all extracted CSS parts to a CSSWriter (for file mode).
|
|
339
|
+
*/
|
|
340
|
+
function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterStyles, functions, chunks, nameMap, sourceFile) {
|
|
341
|
+
for (const kf of keyframes) cssWriter.add(kf.css, kf.css, sourceFile);
|
|
342
|
+
for (const prop of properties) cssWriter.add(prop.css, prop.css, sourceFile);
|
|
343
|
+
for (const ff of fontFaces) cssWriter.add(ff.css, ff.css, sourceFile);
|
|
344
|
+
for (const cs of counterStyles) cssWriter.add(cs.css, cs.css, sourceFile);
|
|
345
|
+
for (const fn of functions) cssWriter.add(fn.css, fn.css, sourceFile);
|
|
346
|
+
for (const chunk of chunks) {
|
|
347
|
+
const css = nameMap.size > 0 ? replaceAnimationNamesInCSS(chunk.css, nameMap) : chunk.css;
|
|
348
|
+
cssWriter.add(chunk.className, css, sourceFile);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Extract CSS for a selector from a styles/tokens object.
|
|
353
|
+
* Returns undefined when there are no styles or no CSS output.
|
|
354
|
+
*/
|
|
355
|
+
function extractCSSFromStyles(selector, styles) {
|
|
356
|
+
if (!styles || Object.keys(styles).length === 0) return void 0;
|
|
357
|
+
return extractStylesForSelector(selector, styles).css || void 0;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Create an `_$i(id, css)` call expression AST node for inject mode.
|
|
361
|
+
*/
|
|
362
|
+
function createInjectCallAST(id, css) {
|
|
363
|
+
return t.callExpression(t.identifier("_$i"), [t.stringLiteral(id), t.stringLiteral(css)]);
|
|
261
364
|
}
|
|
262
365
|
/**
|
|
263
366
|
* Create a StaticStyle object AST node
|
|
@@ -368,7 +471,7 @@ function replaceAnimationNamesInCSS(css, nameMap) {
|
|
|
368
471
|
function escapeRegex(str) {
|
|
369
472
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
370
473
|
}
|
|
371
|
-
|
|
372
474
|
//#endregion
|
|
373
|
-
export {
|
|
475
|
+
export { babel_default as default };
|
|
476
|
+
|
|
374
477
|
//# sourceMappingURL=babel.js.map
|